X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/2c5fbe844b3137b2e3f84d5f1d1ea9ef37564852..868d78293f68d54daf704b80558564c2259c35b7:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index c800ddf6e..155010a97 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -335,7 +335,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"); } @@ -401,19 +402,27 @@ sub cgi_editpage ($$) { #{{{ return; } elsif ($form->submitted eq "Preview") { + my $content=$form->field('editcontent'); + run_hooks(editcontent => sub { + $content=shift->( + content => $content, + page => $page, + cgi => $q, + session => $session, + ); + }); $form->tmpl_param("page_preview", htmlize($page, $type, linkify($page, "", preprocess($page, $page, - filter($page, $page, $form->field('editcontent')), 0, 1)))); + filter($page, $page, $content), 0, 1)))); } elsif ($form->submitted eq "Save Page") { $form->tmpl_param("page_preview", ""); } $form->tmpl_param("page_conflict", ""); - if ($form->submitted ne "Save Page" || - ! $form->validate) { + if ($form->submitted ne "Save Page" || ! $form->validate) { if ($form->field("do") eq "create") { my @page_locs; my $best_loc; @@ -497,6 +506,7 @@ sub cgi_editpage ($$) { #{{{ } showform($form, \@buttons, $session, $q); + saveindex(); } else { # save page @@ -504,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); @@ -531,7 +541,14 @@ sub cgi_editpage ($$) { #{{{ } my $content=$form->field('editcontent'); - + run_hooks(editcontent => sub { + $content=shift->( + content => $content, + page => $page, + cgi => $q, + session => $session, + ); + }); $content=~s/\r\n/\n/g; $content=~s/\r/\n/g;