aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-05-05 20:20:45 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-05-05 20:20:45 -0400
commit1f88cad3a2fa127ec76f8429ce9ca594c59d11f0 (patch)
treedda799e5084ca721e9417a3d73ef244f440ad4e6
parent86c6f2b96323980f75b4435809769ef2193dd157 (diff)
downloadikiwiki-1f88cad3a2fa127ec76f8429ce9ca594c59d11f0.tar
ikiwiki-1f88cad3a2fa127ec76f8429ce9ca594c59d11f0.tar.gz
aggregate: Add support for web-based triggering of aggregation for people stuck on shared hosting without cron. (Sheesh.) Enabled via the `aggregate_webtrigger` configuration optiom.
-rw-r--r--IkiWiki/Plugin/aggregate.pm109
-rw-r--r--debian/changelog8
-rw-r--r--doc/ikiwiki.setup4
-rw-r--r--doc/plugins/aggregate.mdwn8
-rw-r--r--po/ikiwiki.pot30
5 files changed, 106 insertions, 53 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index cb165acd2..a9c7447fa 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# Blog aggregation plugin.
+# Feed aggregation plugin.
package IkiWiki::Plugin::aggregate;
use warnings;
@@ -21,6 +21,9 @@ sub import { #{{{
hook(type => "preprocess", id => "aggregate", call => \&preprocess);
hook(type => "delete", id => "aggregate", call => \&delete);
hook(type => "savestate", id => "aggregate", call => \&savestate);
+ if (exists $config{aggregate_webtrigger} && $config{aggregate_webtrigger}) {
+ hook(type => "cgi", id => "aggregate", call => \&cgi);
+ }
} # }}}
sub getopt () { #{{{
@@ -33,48 +36,78 @@ sub getopt () { #{{{
sub checkconfig () { #{{{
if ($config{aggregate} && ! ($config{post_commit} &&
IkiWiki::commit_hook_enabled())) {
- # See if any feeds need aggregation.
- loadstate();
- my @feeds=needsaggregate();
- return unless @feeds;
- if (! lockaggregate()) {
- debug("an aggregation process is already running");
- return;
- }
- # force a later rebuild of source pages
- $IkiWiki::forcerebuild{$_->{sourcepage}}=1
- foreach @feeds;
-
- # Fork a child process to handle the aggregation.
- # The parent process will then handle building the
- # result. This avoids messy code to clear state
- # accumulated while aggregating.
- defined(my $pid = fork) or error("Can't fork: $!");
- if (! $pid) {
- IkiWiki::loadindex();
+ launchaggregation();
+ }
+} #}}}
- # Aggregation happens without the main wiki lock
- # being held. This allows editing pages etc while
- # aggregation is running.
- aggregate(@feeds);
-
- IkiWiki::lockwiki;
- # Merge changes, since aggregation state may have
- # changed on disk while the aggregation was happening.
- mergestate();
- expire();
- savestate();
- IkiWiki::unlockwiki;
- exit 0;
+sub cgi ($) { #{{{
+ my $cgi=shift;
+
+ if (defined $cgi->param('do') &&
+ $cgi->param("do") eq "aggregate_webtrigger") {
+ $|=1;
+ print "Content-Type: text/plain\n\n";
+ $config{cgi}=0;
+ $config{verbose}=1;
+ $config{syslog}=0;
+ print gettext("Aggregation triggered via web.")."\n\n";
+ if (launchaggregation()) {
+ IkiWiki::lockwiki();
+ IkiWiki::loadindex();
+ require IkiWiki::Render;
+ IkiWiki::refresh();
+ IkiWiki::saveindex();
}
- waitpid($pid,0);
- if ($?) {
- error "aggregation failed with code $?";
+ else {
+ print gettext("Nothing to do right now, all feeds are up-to-date!")."\n";
}
+ exit 0;
+ }
+} #}}}
- clearstate();
- unlockaggregate();
+sub launchaggregation () { #{{{
+ # See if any feeds need aggregation.
+ loadstate();
+ my @feeds=needsaggregate();
+ return unless @feeds;
+ if (! lockaggregate()) {
+ debug("an aggregation process is already running");
+ return;
+ }
+ # force a later rebuild of source pages
+ $IkiWiki::forcerebuild{$_->{sourcepage}}=1
+ foreach @feeds;
+
+ # Fork a child process to handle the aggregation.
+ # The parent process will then handle building the
+ # result. This avoids messy code to clear state
+ # accumulated while aggregating.
+ defined(my $pid = fork) or error("Can't fork: $!");
+ if (! $pid) {
+ IkiWiki::loadindex();
+ # Aggregation happens without the main wiki lock
+ # being held. This allows editing pages etc while
+ # aggregation is running.
+ aggregate(@feeds);
+
+ IkiWiki::lockwiki;
+ # Merge changes, since aggregation state may have
+ # changed on disk while the aggregation was happening.
+ mergestate();
+ expire();
+ savestate();
+ IkiWiki::unlockwiki;
+ exit 0;
}
+ waitpid($pid,0);
+ if ($?) {
+ error "aggregation failed with code $?";
+ }
+
+ clearstate();
+ unlockaggregate();
+
+ return 1;
} #}}}
sub needsbuild (@) { #{{{
diff --git a/debian/changelog b/debian/changelog
index be6cb205c..9b5cfd1b3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+ikiwiki (2.46) UNRELEASED; urgency=low
+
+ * aggregate: Add support for web-based triggering of aggregation
+ for people stuck on shared hosting without cron. (Sheesh.) Enabled
+ via the `aggregate_webtrigger` configuration optiom.
+
+ -- Joey Hess <joeyh@debian.org> Mon, 05 May 2008 19:34:51 -0400
+
ikiwiki (2.45) unstable; urgency=low
* toc: Add the table of contents at sanitize time, rather than at format
diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup
index cbc4cbc9f..33710d1d7 100644
--- a/doc/ikiwiki.setup
+++ b/doc/ikiwiki.setup
@@ -163,4 +163,8 @@ use IkiWiki::Setup::Standard {
# For use with the anonok plugin, a PageSpec specifying what
# pages anonymous users can edit
#anonok_pagespec => "*",
+
+ # For use with the aggregate plugin, to allow aggregation to be
+ # triggered via the web.
+ #aggregate_webtrigger => 1,
}
diff --git a/doc/plugins/aggregate.mdwn b/doc/plugins/aggregate.mdwn
index d224516df..aab5f079a 100644
--- a/doc/plugins/aggregate.mdwn
+++ b/doc/plugins/aggregate.mdwn
@@ -28,6 +28,14 @@ crontab entry:
*/15 * * * * ikiwiki --setup my.wiki --aggregate --refresh
+Alternatively, you can allow `ikiwiki.cgi` to trigger the aggregation. You
+should only need this if for some reason you cannot use cron, and instead
+want to use a service such as [WebCron](http://webcron.org). To enable
+this, enable on `aggregate_webtrigger` in your setup file. The url to
+visit is `http://whatever/ikiwiki.cgi?do=aggregate_webtrigger`. Anyone
+can visit the url to trigger an aggregation run, but it will only check
+each feed if its `updateinterval` has passed.
+
## usage
Here are descriptions of all the supported parameters to the `aggregate`
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index ad94f5acf..38a677eae 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-05-05 15:06-0400\n"
+"POT-Creation-Date: 2008-05-05 20:05-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -71,67 +71,67 @@ msgstr ""
msgid "You are banned."
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:101
+#: ../IkiWiki/Plugin/aggregate.pm:126
#, perl-format
msgid "missing %s parameter"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:128
+#: ../IkiWiki/Plugin/aggregate.pm:153
msgid "new feed"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:142
+#: ../IkiWiki/Plugin/aggregate.pm:167
msgid "posts"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:144
+#: ../IkiWiki/Plugin/aggregate.pm:169
msgid "new"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:307
+#: ../IkiWiki/Plugin/aggregate.pm:332
#, perl-format
msgid "expiring %s (%s days old)"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:314
+#: ../IkiWiki/Plugin/aggregate.pm:339
#, perl-format
msgid "expiring %s"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:341
+#: ../IkiWiki/Plugin/aggregate.pm:366
#, perl-format
msgid "processed ok at %s"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:345
+#: ../IkiWiki/Plugin/aggregate.pm:370
#, perl-format
msgid "checking feed %s ..."
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:350
+#: ../IkiWiki/Plugin/aggregate.pm:375
#, perl-format
msgid "could not find feed at %s"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:365
+#: ../IkiWiki/Plugin/aggregate.pm:390
msgid "feed not found"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:376
+#: ../IkiWiki/Plugin/aggregate.pm:401
#, perl-format
msgid "(invalid UTF-8 stripped from feed)"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:382
+#: ../IkiWiki/Plugin/aggregate.pm:407
#, perl-format
msgid "(feed entities escaped)"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:388
+#: ../IkiWiki/Plugin/aggregate.pm:413
msgid "feed crashed XML::Feed!"
msgstr ""
-#: ../IkiWiki/Plugin/aggregate.pm:462
+#: ../IkiWiki/Plugin/aggregate.pm:487
#, perl-format
msgid "creating new page %s"
msgstr ""