X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6c89a635bb0715fd06b0061692fe39b3e79fcad7..0266946af0f912b5c97c20d6180040a9b3a0141d:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 82b619592..c2dacf78d 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -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();