summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/editpage.pm28
-rw-r--r--IkiWiki/Plugin/skeleton.pm.example10
2 files changed, 38 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm
index ed994306f..91d125a5c 100644
--- a/IkiWiki/Plugin/editpage.pm
+++ b/IkiWiki/Plugin/editpage.pm
@@ -81,6 +81,33 @@ sub check_canedit ($$$;$) {
return $canedit;
}
+sub check_cansave ($$$$) {
+ my $page=shift;
+ my $content=shift;
+ my $q=shift;
+ my $session=shift;
+
+ my $cansave;
+ run_hooks(cansave => sub {
+ return if defined $cansave;
+ my $ret=shift->($page, $content, $q, $session);
+ if (defined $ret) {
+ if ($ret eq "") {
+ $cansave=1;
+ }
+ elsif (ref $ret eq 'CODE') {
+ $ret->();
+ $cansave=0;
+ }
+ else {
+ error($ret);
+ $cansave=0;
+ }
+ }
+ });
+ return $cansave;
+}
+
sub cgi_editpage ($$) {
my $q=shift;
my $session=shift;
@@ -370,6 +397,7 @@ sub cgi_editpage ($$) {
}
my $content=$form->field('editcontent');
+ check_cansave($page, $content, $q, $session);
run_hooks(editcontent => sub {
$content=shift->(
content => $content,
diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example
index 96c4a5d6b..496a4dfe4 100644
--- a/IkiWiki/Plugin/skeleton.pm.example
+++ b/IkiWiki/Plugin/skeleton.pm.example
@@ -30,6 +30,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 => "cansave", id => "skeleton", call => \&cansave);
hook(type => "editcontent", id => "skeleton", call => \&editcontent);
hook(type => "formbuilder_setup", id => "skeleton", call => \&formbuilder_setup);
hook(type => "formbuilder", id => "skeleton", call => \&formbuilder);
@@ -180,6 +181,15 @@ sub canedit ($$$) {
debug("skeleton plugin running in canedit");
}
+sub cansave ($$$$) {
+ my $page=shift;
+ my $content=shift;
+ my $cgi=shift;
+ my $session=shift;
+
+ debug("skeleton plugin running in cansave")
+}
+
sub editcontent ($$$) {
my %params=@_;