summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/CGI.pm23
-rw-r--r--IkiWiki/Plugin/skeleton.pm9
-rw-r--r--debian/changelog6
-rw-r--r--doc/plugins/write.mdwn11
-rw-r--r--doc/todo/plugin.mdwn2
-rw-r--r--doc/todo/sigs.mdwn16
-rw-r--r--doc/todo/wikiwyg/discussion.mdwn7
7 files changed, 58 insertions, 16 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=@_;
diff --git a/debian/changelog b/debian/changelog
index 09833ac06..8552edfd1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ikiwiki (2.6.2) UNRELEASED; urgency=low
+
+ * Add an editcontent hook.
+
+ -- Joey Hess <joeyh@debian.org> Sun, 26 Aug 2007 16:50:24 -0400
+
ikiwiki (2.6.1) unstable; urgency=low
* Ye olde brown paper bag.
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index d09367f1b..0c192eb64 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -251,6 +251,17 @@ by this hook, the hook should return an error message for the user to see.
If the hook has no opinion about whether the edit can proceed, return
`undef`, and the next plugin will be asked to decide.
+### editcontent
+
+ hook(type => "editcontent", id => "foo", call => \&editcontent);
+
+This hook is called when a page is saved (or previewed) using the web
+interface. It is passed named parameters: `content`, `page`, `cgi`, and
+`session`. These are, respectively, the new page content as entered by the
+user, the page name, a `CGI` object, and the user's `CGI::Session`.
+
+It can modify the content as desired, and should return the content.
+
### formbuilder
hook(type => "formbuilder_setup", id => "foo", call => \&formbuilder_setup);
diff --git a/doc/todo/plugin.mdwn b/doc/todo/plugin.mdwn
index 4d034a814..0d702975f 100644
--- a/doc/todo/plugin.mdwn
+++ b/doc/todo/plugin.mdwn
@@ -6,8 +6,6 @@ Suggestions of ideas for plugins:
> web-server-specific code to list all users, and openid can't feasibly do so
> at all. --[[JoshTriplett]]
-* [[sigs]] ?
-
* Support [[RecentChanges]] as a regular page containing a plugin that
updates each time there is a change, and statically builds the recent
changes list. (Would this be too expensive/inflexible? There might be
diff --git a/doc/todo/sigs.mdwn b/doc/todo/sigs.mdwn
index f3ec2cbe8..f4f8edf13 100644
--- a/doc/todo/sigs.mdwn
+++ b/doc/todo/sigs.mdwn
@@ -1,8 +1,8 @@
Need a way to sign name in page that's easier to type than "--\[[Joey]]"
and that includes the date.
-What syntax do other wikis use for this? I'm considering "\[[--]]" (with
-spaces removed) as it has a nice nmemonic.
+What syntax do other wikis use for this? I'm considering "\[[--]]"
+as it has a nice nmemonic.
OTOH, adding additional syntax for this would be counter to one of the
design goals for ikiwiki: keeping as much markup as possible out of the
@@ -15,7 +15,11 @@ out svn commits.
---
-Alternate idea: Make a sig plugin, which would expand --Name to
---[[user/Name]] (the "user/" bit would be configurable). This would be very
-easy to do, although it would need to try to avoid false positives, such
-as `--foo` in C code..
+Or, just make a sig plugin that expands `~~~~` and `~~~` as wikipedia does.
+The plugin could be an editcontent hook, so it would take effect only when a
+page was edited via the web.
+
+I tried implementing this, but to make the link to the user, I wanted to
+use `userlink()`, which generates html. But the right thing to generate is
+really a wikilink. Except for openid, when the best thing to generate is a
+markdown link. Except when the page isn't formatted in markdown..
diff --git a/doc/todo/wikiwyg/discussion.mdwn b/doc/todo/wikiwyg/discussion.mdwn
index 33554e12c..44d282a5a 100644
--- a/doc/todo/wikiwyg/discussion.mdwn
+++ b/doc/todo/wikiwyg/discussion.mdwn
@@ -67,10 +67,9 @@ changes.diff:
prefer a translated underlay, and use the english version of untranslated
pages, for example.
* When is the WIKIWYG variable in misc.tmpl used?
-* I wish there were a good way to move the code to handle saving a part of
- a page into the plugin. But there doesn't seem to be one that's any
- cleaner than keeping the code where it is. So I'll probably just apply
- that hunk.
+* Could you move the code that handles saving a page of the page into the
+ plugin? I just added an editcontent hook, which should allow you to do
+ that.
* Your patch exports run_hooks, but I don't see the plugin using that.
* I don't know about exporting pagetitle. So far, only the inline plugin
needs to use that function, I generally only export things after it's