diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-08-26 21:33:25 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2007-08-26 21:33:25 +0000 |
commit | 6c89a635bb0715fd06b0061692fe39b3e79fcad7 (patch) | |
tree | 13b2c665fdb30a534aa33ed83abba0d308f4e7b1 /IkiWiki | |
parent | 68db2dceb87a83e2bfa201dc52cc48c9b389c403 (diff) | |
download | ikiwiki-6c89a635bb0715fd06b0061692fe39b3e79fcad7.tar ikiwiki-6c89a635bb0715fd06b0061692fe39b3e79fcad7.tar.gz |
* Add an editcontent hook.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/CGI.pm | 23 | ||||
-rw-r--r-- | IkiWiki/Plugin/skeleton.pm | 9 |
2 files changed, 28 insertions, 4 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index c800ddf6e..82b619592 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -401,19 +401,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; @@ -531,7 +539,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; diff --git a/IkiWiki/Plugin/skeleton.pm b/IkiWiki/Plugin/skeleton.pm index 72e088770..0e7f2e014 100644 --- a/IkiWiki/Plugin/skeleton.pm +++ b/IkiWiki/Plugin/skeleton.pm @@ -25,6 +25,7 @@ sub import { #{{{ hook(type => "auth", id => "skeleton", call => \&auth); hook(type => "sessioncgi", id => "skeleton", call => \&sessioncgi); hook(type => "canedit", id => "skeleton", call => \&canedit); + hook(type => "editcontent", id => "skeleton", call => \&editcontent); hook(type => "formbuilder_setup", id => "skeleton", call => \&formbuilder_setup); hook(type => "formbuilder", id => "skeleton", call => \&formbuilder); hook(type => "savestate", id => "skeleton", call => \&savestate); @@ -135,6 +136,14 @@ sub canedit ($$$) { #{{{ debug("skeleton plugin running in canedit"); } #}}} +sub editcontent ($$$) { #{{{ + my %params=@_; + + debug("skeleton plugin running in editcontent"); + + return $params{content}; +} #}}} + sub formbuilder_setup (@) { #{{{ my %params=@_; |