[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /xml londefdef.pm lonxml.pm

raeburn raeburn@source.lon-capa.org
Mon, 13 Apr 2009 20:42:32 -0000


raeburn		Mon Apr 13 20:42:32 2009 EDT

  Modified files:              
    /loncom	loncapa_apache.conf 
    /loncom/xml	londefdef.pm lonxml.pm 
  Log:
  - Bug 5826.
    - Edit button in Construction Space for files with extensions: css, js, or txt.
  
  
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.184 loncom/loncapa_apache.conf:1.185
--- loncom/loncapa_apache.conf:1.184	Thu Apr  2 13:48:07 2009
+++ loncom/loncapa_apache.conf	Mon Apr 13 20:42:28 2009
@@ -1,7 +1,7 @@
 ##
 ## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
 ##
-## $Id: loncapa_apache.conf,v 1.184 2009/04/02 13:48:07 foxr Exp $
+## $Id: loncapa_apache.conf,v 1.185 2009/04/13 20:42:28 raeburn Exp $
 ##
 
 #
@@ -393,6 +393,11 @@
 PerlHandler Apache::lonhomework
 </LocationMatch>
 
+<LocationMatch "^/+\~.*\.(js|css|txt)$">
+SetHandler perl-script
+PerlHandler Apache::lonxml
+</LocationMatch>
+
 <LocationMatch "^/adm/wrapper/">
 AuthType LONCAPA
 Require valid-user
@@ -684,6 +689,17 @@
 ErrorDocument	  500 /adm/errorhandler
 </Location>
 
+<Location /adm/courseprefs>
+AuthType LONCAPA
+Require valid-user
+PerlAuthzHandler       Apache::lonacc
+SetHandler perl-script
+PerlHandler Apache::courseprefs
+ErrorDocument     403 /adm/login
+ErrorDocument     406 /adm/roles
+ErrorDocument     500 /adm/errorhandler
+</Location>
+
 <Location /adm/slotrequest>
 AuthType LONCAPA
 Require valid-user
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.400 loncom/xml/londefdef.pm:1.401
--- loncom/xml/londefdef.pm:1.400	Sat Apr 11 01:11:02 2009
+++ loncom/xml/londefdef.pm	Mon Apr 13 20:42:32 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.400 2009/04/11 01:11:02 raeburn Exp $
+# $Id: londefdef.pm,v 1.401 2009/04/13 20:42:32 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -558,13 +558,18 @@
 }
 
 sub edit_controls {
+    my ($nochgview) = @_;
     my $result .= '
 <form method="post">
-<div class="LC_edit_problem_header">
+<div class="LC_edit_problem_header">';
+    unless ($nochgview) {
+        $result .= '
 <div class="LC_edit_problem_header_row1">'.
 &Apache::lonxml::renderingoptions().'
 <input type="submit" name="changeproblemmode" value="'.&mt('Change View').'" />
-</div>
+</div>';
+    }
+    $result .= '
 <div class="LC_edit_problem_header_edit_row"><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" /></div></div>
 </form>
 <br />';
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.492 loncom/xml/lonxml.pm:1.493
--- loncom/xml/lonxml.pm:1.492	Mon Apr 13 20:15:44 2009
+++ loncom/xml/lonxml.pm	Mon Apr 13 20:42:32 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.492 2009/04/13 20:15:44 raeburn Exp $
+# $Id: lonxml.pm,v 1.493 2009/04/13 20:42:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1504,6 +1504,15 @@
   return $filecontents;
 }
 
+sub createnewjs {
+    my $filecontents=(<<SIMPLECONTENT);
+<script type="text/javascript" language="Javascript">
+
+</script>
+SIMPLECONTENT
+    return $filecontents;
+}
+
 sub verify_html {
     my ($filecontents)=@_;
     if ($filecontents!~/(?:\<|\&lt\;)(?:html|xml)[^\<]*(?:\>|\&gt\;)/is) {
@@ -1679,9 +1688,8 @@
 
 sub handler {
     my $request=shift;
-    
+
     my $target=&get_target();
-    
     $Apache::lonxml::debug=$env{'user.debug'};
     
     &Apache::loncommon::content_type($request,'text/html');
@@ -1697,11 +1705,12 @@
 
     my $file=&Apache::lonnet::filelocation("",$request->uri);
     my $filetype;
-    if ($file =~ /\.sty$/) {
-	$filetype='sty';
+    if ($file =~ /\.(sty|css|js|txt)$/) {
+	$filetype=$1;
     } else {
 	$filetype='html';
     }
+
 #
 # Edit action? Save file.
 #
@@ -1730,7 +1739,9 @@
 	if ($env{'request.state'} ne 'published') {
 	    if ($filetype eq 'sty') {
 		$filecontents=&createnewsty();
-	    } else {
+            } elsif ($filetype eq 'js') {
+                $filecontents=&createnewjs();
+            } elsif (($filetype ne 'css') && ($filetype ne 'txt')) {
 		$filecontents=&createnewhtml();
 	    }
 	    $env{'form.editmode'}='Edit'; #force edit mode
@@ -1746,27 +1757,43 @@
 						    ['editmode']);
 	}
 	if (!$env{'form.editmode'} || $env{'form.viewmode'} || $env{'form.discardview'}) {
-	    &Apache::structuretags::reset_problem_globals();
-	    $result = &Apache::lonxml::xmlparse($request,$target,$filecontents,
-						'',%mystyle);
+            if ($filetype eq 'html' || $filetype eq 'sty') {
+	        &Apache::structuretags::reset_problem_globals();
+	        $result = &Apache::lonxml::xmlparse($request,$target,
+                                                    $filecontents,'',%mystyle);
 	    # .html files may contain <problem> or <Task> need to clean
 	    # up if it did
-	    &Apache::structuretags::reset_problem_globals();
-	    &Apache::lonhomework::finished_parsing();
+	        &Apache::structuretags::reset_problem_globals();
+	        &Apache::lonhomework::finished_parsing();
+            } else {
+                $result = $filecontents;
+            }
 	    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 						    ['rawmode']);
 	    if ($env{'form.rawmode'}) { $result = $filecontents; }
-	    if ($filetype eq 'sty') {
+	    if ($filetype ne 'html') {
+                my $nochgview = 1; 
 		my $controls =
-		    ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls()
+		    ($env{'request.state'} eq 'construct') ? &Apache::londefdef::edit_controls($nochgview)
 		                                           : '';
-		my %options = ('bgcolor' => '#FFFFFF');
-		$result = 
-		    &Apache::loncommon::start_page(undef,undef,\%options).
-		    $controls.
-		    $result.
-		    &Apache::loncommon::end_page();
-	    }
+                if ($filetype ne 'sty') {
+                    $result =~ s/</&lt;/g;
+                    $result =~ s/>/&gt;/g;
+                    $result = '<table class="LC_sty_begin">'.
+                              '<tr><td><b><pre>'.$result.
+                              '</pre></b></td></tr></table>';
+                }
+                if ($env{'environment.remote'} eq 'off') {
+                    my %options = ('bgcolor' => '#FFFFFF');
+		    $result = 
+		        &Apache::loncommon::start_page(undef,undef,\%options).
+		        $controls.
+		        $result.
+		        &Apache::loncommon::end_page();
+                } else {
+                    $result = $controls.$result;
+                }
+            }
 	}
     }
 
@@ -1800,7 +1827,7 @@
 		&Apache::lonxml::message_location().
 		$edit_info.
 		&Apache::loncommon::end_page();
-	}
+        }
     }
     if ($filetype eq 'html') { &writeallows($request->uri); }