[LON-CAPA-cvs] cvs: doc /loncapafiles loncapafiles.lpml loncom/html/res/adm/pages webpage.png loncom/interface londocs.pm

raeburn raeburn at source.lon-capa.org
Mon Mar 11 18:16:34 EDT 2013


raeburn		Mon Mar 11 22:16:34 2013 EDT

  Added files:                 
    /loncom/html/res/adm/pages	webpage.png 

  Modified files:              
    /loncom/interface	londocs.pm 
    /doc/loncapafiles	loncapafiles.lpml 
  Log:
  - Bug 4586.
    - Create a new blank HTML page directly via the Course Editor, and use the
      RichText editor to edit it, and "Manage Dependencies" button to upload
      any dependendencies.  
  
  
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.533 loncom/interface/londocs.pm:1.534
--- loncom/interface/londocs.pm:1.533	Mon Mar 11 01:46:47 2013
+++ loncom/interface/londocs.pm	Mon Mar 11 22:16:11 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.533 2013/03/11 01:46:47 raeburn Exp $
+# $Id: londocs.pm,v 1.534 2013/03/11 22:16:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -289,7 +289,7 @@
             $env{'form.output'}=$newmapstr;
             my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                 'output',$1.$2);
-            if ($result != m|^/uploaded/|) {
+            if ($result !~ m{^/uploaded/}) {
                 $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
                 $fatal = 2;
             }
@@ -300,7 +300,7 @@
 	if ($url) {
             if (($caller eq 'londocs') &&
                 ($folder =~ /^default/)) {
-                unless ($donechk) {
+                if (($url =~ /\.(page|sequence)$/) && (!$donechk)) {
                     my $chome = &Apache::lonnet::homeserver($coursenum,$coursedom);
                     my $cid = $coursedom.'_'.$coursenum;
                     $allmaps =
@@ -325,6 +325,48 @@
 	    if ($url=~m{^http://} || $url=~m{^https://}) { $ext = 'true'; }
 	    $url  = &LONCAPA::map::qtunescape($url);
 	    $name = &LONCAPA::map::qtunescape($name);
+            if ($name eq '') {
+                $name = &mt('Web Page');
+            }
+            if ($url =~ m{^/uploaded/$coursedom/$coursenum/((?:docs|supplemental)/(?:default|\d+))/new\.html$}) {
+                my $filepath = $1;
+                my $fname = $name;
+                if ($fname =~ /^\W+$/) {
+                    $fname = 'web';
+                } else {
+                    $fname =~ s/\W/_/g;
+                }
+                if (length($fname > 15)) {
+                    $fname = substr($fname,0,14);
+                }
+                my $initialtext = &mt('Replace with your own content.');
+                my $newhtml = <<END;
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>$name</title>
+</head>
+<body bgcolor="#ffffff">
+$initialtext
+</body>
+</html>
+END
+                $env{'form.output'}=$newhtml;
+                my $result = 
+                    &Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
+                                                          'output',
+                                                          "$filepath/$residx/$fname.html");
+                if ($result =~ m{^/uploaded/}) {
+                    $url = $result;
+                    if ($filepath =~ /^supplemental/) {
+                        $name = time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+                                $env{'user.domain'}.'___&&&___'.$name;
+                    }
+                } else {
+                    return (&mt('Failed to save new web page.'),1);
+                }
+            }
 	    $LONCAPA::map::resources[$residx] =
 		join(':', ($name, $url, $ext, 'normal', 'res'));
 	}
@@ -2043,6 +2085,22 @@
                         } else {
                             return $errortxt;
                         }
+                    } elsif ($url =~ m{^/uploaded/$coursedom/$coursenum/(docs|supplemental)/(default|\d+)/new.html$}) {
+                        if ($supplementalflag) {
+                            next unless ($1 eq 'supplemental');
+                            if ($folder eq 'supplemental') {
+                                next unless ($2 eq 'default');
+                            } else {
+                                next unless ($folder eq 'supplemental_'.$2);
+                            }
+                        } else {
+                            next unless ($1 eq 'docs');
+                            if ($folder eq 'default') {
+                                next unless ($2 eq 'default');
+                            } else {
+                                next unless ($folder eq 'default_'.$2);
+                            }
+                        }
                     }
 		    push(@imports, [$name, $url, $residx]);
 		}
@@ -2216,15 +2274,11 @@
             $container='page';
         }
         ($errtext,$fatal)=
-              &mapread($coursenum,$coursedom,$folder.'.'.$container);
+            &mapread($coursenum,$coursedom,$folder.'.'.$container);
         if ($#LONCAPA::map::order<1) {
             $LONCAPA::map::order[0]=1;
             $LONCAPA::map::resources[1]='';
         }
-        if ($fatal) {
-            $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
-            return;
-        }
         my $destination = 'docs/';
         if ($folder =~ /^supplemental/) {
             $destination = 'supplemental/';
@@ -2234,6 +2288,10 @@
         } elsif ($folder =~ /^(default|supplemental)_(\d+)$/) {
             $destination .=  $2.'/';
         }
+        if ($fatal) {
+            $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
+            return;
+        }
 # this is for a course, not a user, so set context to coursedoc.
         my $newidx=&LONCAPA::map::getresidx();
         $destination .= $newidx;
@@ -3424,8 +3482,9 @@
 		  'Docs_About_My_Personal_Info,Docs_Editing_Templated_Pages');
     $help{'Group Portfolio'} = &Apache::loncommon::help_open_topic('Docs_About_Group_Files');
     $help{'Caching'} = &Apache::loncommon::help_open_topic('Caching');
-
-    
+    $help{'Course Roster'} = &Apache::loncommon::help_open_topic('Docs_Course_Roster');
+    $help{'Web Page'} =  &Apache::loncommon::help_open_topic('Docs_Web_Page');
+ 
     my $allowed;
 # URI is /adm/supplemental when viewing supplemental docs in non-edit mode.
     unless ($r->uri eq '/adm/supplemental') {
@@ -3759,6 +3818,7 @@
                 'navc' => 'Table of Contents',
                 'sipa' => 'Simple Course Page',
                 'sipr' => 'Simple Problem',
+                'webp' => 'Blank Web Page (editable)', 
                 'drbx' => 'Drop Box',
                 'scuf' => 'External Scores (handgrade, upload, clicker)',
                 'bull' => 'Discussion Board',
@@ -4011,7 +4071,6 @@
 	</form>
 NASOFORM
 
-
 	my $newrosterform=(<<NROSTFORM);
 	<form action="/adm/coursedocs" method="post" name="newroster">
 	<input type="hidden" name="active" value="cc" />
@@ -4023,6 +4082,27 @@
 	</form>
 NROSTFORM
 
+        my $newwebpage;
+        if ($folder =~ /^default_?(\d*)$/) {
+            $newwebpage = "/uploaded/$coursedom/$coursenum/docs/";
+            if ($1) {
+                $newwebpage .= $1;
+            } else {
+                $newwebpage .= 'default';
+            }
+            $newwebpage .= '/new.html';
+        }
+        my $newwebpageform =(<<NWEBFORM);
+        <form action="/adm/coursedocs" method="post" name="newwebpage">
+        <input type="hidden" name="active" value="cc" />
+        $pathitem
+        <input type="hidden" name="importdetail" value="$newwebpage" />
+        <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
+        $help{'Web Page'}
+        </form>
+NWEBFORM
+ 
+
 my $specialdocumentsform;
 my @specialdocumentsforma;
 my $gradingform;
@@ -4081,6 +4161,7 @@
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.newsyl.submit()" />'=>$newsylform},
 	{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/navigation.png" alt="'.$lt{navc}.'" onclick="document.newnav.submit()" />'=>$newnavform},
         {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simple.png" alt="'.$lt{sipa}.'" onclick="javascript:makesmppage();" />'=>$newsmppageform},
+        {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage();" />'=>$newwebpageform},
         );
         $specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
 
@@ -4218,12 +4299,34 @@
 	</form>
 SNAMFORM
 
+        my $supwebpage;
+        if ($folder =~ /^supplemental_?(\d*)$/) {
+            $supwebpage = "/uploaded/$coursedom/$coursenum/supplemental/";
+            if ($1) {
+                $supwebpage .= $1;
+            } else {
+                $supwebpage .= 'default';
+            }
+            $supwebpage .= '/new.html';
+        }
+        my $supwebpageform =(<<SWEBFORM);
+        <form action="/adm/coursedocs" method="post" name="supwebpage">
+        <input type="hidden" name="active" value="cc" />
+        $pathitem
+        <input type="hidden" name="importdetail" value="$supwebpage" />
+        <a class="LC_menubuttons_link" href="javascript:makewebpage('supp');">$lt{'webp'}</a>
+        $help{'Web Page'}
+        </form>
+SWEBFORM
+
 
 my @specialdocs = (
 		{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/syllabus.png" alt="'.$lt{syll}.'" onclick="document.supnewsyl.submit()" />'
             =>$supnewsylform},
 		{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/myaboutme.png" alt="'.$lt{mypi}.'" onclick="document.supnewaboutme.submit()" />'
             =>$supnewaboutmeform},
+                {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/webpage.png" alt="'.$lt{webp}.'" onclick="javascript:makewebpage('."'supp'".');" />'=>$supwebpageform},
+
 		);
 my @supimportdoc = (
 		{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:toggleUpload(\'suppext\')" />'
@@ -4588,6 +4691,7 @@
                                           p_msb => 'Title for the Problem',
                                           p_mdb => 'Title for the Drop Box',
                                           p_mbb => 'Title for the Discussion Board',
+                                          p_mwp => 'Title for Web Page', 
                                           p_mab => "Enter user:domain for User's Personal Information Page",
                                           p_mab2 => 'Personal Information Page of ',
                                           p_mab_alrt1 => 'Not a valid user:domain',
@@ -4680,6 +4784,21 @@
    }
 }
 
+function makewebpage(type) {
+   var title=prompt('$lt{"p_mwp"}');
+   var formname;
+   if (type == 'supp') {
+       formname = this.document.forms.supwebpage;
+   } else {
+       formname = this.document.forms.newwebpage;
+   }
+   if (title) {
+       var webpage = formname.importdetail.value; 
+       formname.importdetail.value = escape(title)+'='+webpage;
+       formname.submit();
+   }
+}
+
 function makesmpproblem() {
    var title=prompt('$lt{"p_msb"}');
    if (title) {
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.826 doc/loncapafiles/loncapafiles.lpml:1.827
--- doc/loncapafiles/loncapafiles.lpml:1.826	Tue Feb  5 21:23:04 2013
+++ doc/loncapafiles/loncapafiles.lpml	Mon Mar 11 22:16:34 2013
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.826 2013/02/05 21:23:04 raeburn Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.827 2013/03/11 22:16:34 raeburn Exp $ -->
 
 <!--
 
@@ -7557,6 +7557,7 @@
 thumbsdown.png;
 thumbsdown_gray.png;
 thumbsdown_novote.png;
+webpage.png;
 back.png;
 catalog.png;
 com.png;


More information about the LON-CAPA-cvs mailing list