]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/CGI.pm
remove dup bug report
[git.ikiwiki.info.git] / IkiWiki / CGI.pm
index 82b619592e1d9b916b0d9a1037df919edfe8502d..c2dacf78d46253a74015cd67155bbb33fc34ad70 100644 (file)
@@ -33,10 +33,9 @@ sub showform ($$$$) { #{{{
                                buttons => $buttons);
                });
        }
-       else {
-               printheader($session);
-               print misctemplate($form->title, $form->render(submit => $buttons));
-       }
+
+       printheader($session);
+       print misctemplate($form->title, $form->render(submit => $buttons));
 }
 
 sub redirect ($$) { #{{{
@@ -249,7 +248,7 @@ sub cgi_prefs ($$) { #{{{
        $form->field(name => "email", size => 50, fieldset => "preferences");
        $form->field(name => "subscriptions", size => 50,
                fieldset => "preferences",
-               comment => "(".htmllink("", "", "PageSpec", noimageinline => 1).")");
+               comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")");
        $form->field(name => "banned_users", size => 50,
                fieldset => "admin");
        
@@ -311,9 +310,6 @@ sub cgi_editpage ($$) { #{{{
                fields => \@fields,
                charset => "utf-8",
                method => 'POST',
-               validate => {
-                       editcontent => '/.+/',
-               },
                required => [qw{editcontent}],
                javascript => 0,
                params => $q,
@@ -335,7 +331,8 @@ sub cgi_editpage ($$) { #{{{
        # characters.
        my ($page)=$form->field('page');
        $page=titlepage(possibly_foolish_untaint($page));
-       if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
+       if (! defined $page || ! length $page ||
+           file_pruned($page, $config{srcdir}) || $page=~/^\//) {
                error("bad page name");
        }
        
@@ -356,6 +353,7 @@ sub cgi_editpage ($$) { #{{{
                        $form->field(name => "rcsinfo",
                                value => rcs_prepedit($file), force => 1);
                }
+               $form->field(name => "editcontent", validate => '/.*/');
        }
        else {
                $type=$form->param('type');
@@ -371,6 +369,7 @@ sub cgi_editpage ($$) { #{{{
                if (! $form->submitted) {
                        $form->field(name => "rcsinfo", value => "", force => 1);
                }
+               $form->field(name => "editcontent", validate => '/.+/');
        }
 
        $form->field(name => "do", type => 'hidden');
@@ -385,7 +384,9 @@ sub cgi_editpage ($$) { #{{{
        $form->tmpl_param("can_commit", $config{rcs});
        $form->tmpl_param("indexlink", indexlink());
        $form->tmpl_param("helponformattinglink",
-               htmllink("", "", "HelpOnFormatting", noimageinline => 1));
+               htmllink("", "", "ikiwiki/formatting",
+                       noimageinline => 1,
+                       linktext => "FormattingHelp"));
        $form->tmpl_param("baseurl", baseurl());
        
        if ($form->submitted eq "Cancel") {
@@ -505,6 +506,7 @@ sub cgi_editpage ($$) { #{{{
                }
                
                showform($form, \@buttons, $session, $q);
+               saveindex();
        }
        else {
                # save page
@@ -512,8 +514,8 @@ sub cgi_editpage ($$) { #{{{
 
                my $exists=-e "$config{srcdir}/$file";
 
-               if ($form->field("do") ne "create" &&
-                   ! $exists && ! -e "$config{underlaydir}/$file") {
+               if ($form->field("do") ne "create" && ! $exists &&
+                   ! eval { srcfile($file) }) {
                        $form->tmpl_param("page_gone", 1);
                        $form->field(name => "do", value => "create", force => 1);
                        $form->tmpl_param("page_select", 0);
@@ -549,6 +551,7 @@ sub cgi_editpage ($$) { #{{{
                });
                $content=~s/\r\n/\n/g;
                $content=~s/\r/\n/g;
+               $content.="\n" if $content !~ /\n$/;
 
                $config{cgi}=0; # avoid cgi error message
                eval { writefile($file, $config{srcdir}, $content) };
@@ -594,6 +597,10 @@ sub cgi_editpage ($$) { #{{{
                # may have been committed while the post-commit hook was
                # disabled.
                require IkiWiki::Render;
+               # Reload index, since the first time it's loaded is before
+               # the wiki is locked, and things may have changed in the
+               # meantime.
+               loadindex();
                refresh();
                saveindex();