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.

master
Joey Hess 2008-05-05 20:20:45 -04:00
parent 86c6f2b963
commit 1f88cad3a2
5 changed files with 110 additions and 57 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/perl #!/usr/bin/perl
# Blog aggregation plugin. # Feed aggregation plugin.
package IkiWiki::Plugin::aggregate; package IkiWiki::Plugin::aggregate;
use warnings; use warnings;
@ -21,6 +21,9 @@ sub import { #{{{
hook(type => "preprocess", id => "aggregate", call => \&preprocess); hook(type => "preprocess", id => "aggregate", call => \&preprocess);
hook(type => "delete", id => "aggregate", call => \&delete); hook(type => "delete", id => "aggregate", call => \&delete);
hook(type => "savestate", id => "aggregate", call => \&savestate); hook(type => "savestate", id => "aggregate", call => \&savestate);
if (exists $config{aggregate_webtrigger} && $config{aggregate_webtrigger}) {
hook(type => "cgi", id => "aggregate", call => \&cgi);
}
} # }}} } # }}}
sub getopt () { #{{{ sub getopt () { #{{{
@ -33,6 +36,36 @@ sub getopt () { #{{{
sub checkconfig () { #{{{ sub checkconfig () { #{{{
if ($config{aggregate} && ! ($config{post_commit} && if ($config{aggregate} && ! ($config{post_commit} &&
IkiWiki::commit_hook_enabled())) { IkiWiki::commit_hook_enabled())) {
launchaggregation();
}
} #}}}
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();
}
else {
print gettext("Nothing to do right now, all feeds are up-to-date!")."\n";
}
exit 0;
}
} #}}}
sub launchaggregation () { #{{{
# See if any feeds need aggregation. # See if any feeds need aggregation.
loadstate(); loadstate();
my @feeds=needsaggregate(); my @feeds=needsaggregate();
@ -52,7 +85,6 @@ sub checkconfig () { #{{{
defined(my $pid = fork) or error("Can't fork: $!"); defined(my $pid = fork) or error("Can't fork: $!");
if (! $pid) { if (! $pid) {
IkiWiki::loadindex(); IkiWiki::loadindex();
# Aggregation happens without the main wiki lock # Aggregation happens without the main wiki lock
# being held. This allows editing pages etc while # being held. This allows editing pages etc while
# aggregation is running. # aggregation is running.
@ -74,7 +106,8 @@ sub checkconfig () { #{{{
clearstate(); clearstate();
unlockaggregate(); unlockaggregate();
}
return 1;
} #}}} } #}}}
sub needsbuild (@) { #{{{ sub needsbuild (@) { #{{{

8
debian/changelog vendored
View File

@ -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 ikiwiki (2.45) unstable; urgency=low
* toc: Add the table of contents at sanitize time, rather than at format * toc: Add the table of contents at sanitize time, rather than at format

View File

@ -163,4 +163,8 @@ use IkiWiki::Setup::Standard {
# For use with the anonok plugin, a PageSpec specifying what # For use with the anonok plugin, a PageSpec specifying what
# pages anonymous users can edit # pages anonymous users can edit
#anonok_pagespec => "*", #anonok_pagespec => "*",
# For use with the aggregate plugin, to allow aggregation to be
# triggered via the web.
#aggregate_webtrigger => 1,
} }

View File

@ -28,6 +28,14 @@ crontab entry:
*/15 * * * * ikiwiki --setup my.wiki --aggregate --refresh */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 ## usage
Here are descriptions of all the supported parameters to the `aggregate` Here are descriptions of all the supported parameters to the `aggregate`

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -71,67 +71,67 @@ msgstr ""
msgid "You are banned." msgid "You are banned."
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:101 #: ../IkiWiki/Plugin/aggregate.pm:126
#, perl-format #, perl-format
msgid "missing %s parameter" msgid "missing %s parameter"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:128 #: ../IkiWiki/Plugin/aggregate.pm:153
msgid "new feed" msgid "new feed"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:142 #: ../IkiWiki/Plugin/aggregate.pm:167
msgid "posts" msgid "posts"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:144 #: ../IkiWiki/Plugin/aggregate.pm:169
msgid "new" msgid "new"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:307 #: ../IkiWiki/Plugin/aggregate.pm:332
#, perl-format #, perl-format
msgid "expiring %s (%s days old)" msgid "expiring %s (%s days old)"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:314 #: ../IkiWiki/Plugin/aggregate.pm:339
#, perl-format #, perl-format
msgid "expiring %s" msgid "expiring %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:341 #: ../IkiWiki/Plugin/aggregate.pm:366
#, perl-format #, perl-format
msgid "processed ok at %s" msgid "processed ok at %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:345 #: ../IkiWiki/Plugin/aggregate.pm:370
#, perl-format #, perl-format
msgid "checking feed %s ..." msgid "checking feed %s ..."
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:350 #: ../IkiWiki/Plugin/aggregate.pm:375
#, perl-format #, perl-format
msgid "could not find feed at %s" msgid "could not find feed at %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:365 #: ../IkiWiki/Plugin/aggregate.pm:390
msgid "feed not found" msgid "feed not found"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:376 #: ../IkiWiki/Plugin/aggregate.pm:401
#, perl-format #, perl-format
msgid "(invalid UTF-8 stripped from feed)" msgid "(invalid UTF-8 stripped from feed)"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:382 #: ../IkiWiki/Plugin/aggregate.pm:407
#, perl-format #, perl-format
msgid "(feed entities escaped)" msgid "(feed entities escaped)"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:388 #: ../IkiWiki/Plugin/aggregate.pm:413
msgid "feed crashed XML::Feed!" msgid "feed crashed XML::Feed!"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/aggregate.pm:462 #: ../IkiWiki/Plugin/aggregate.pm:487
#, perl-format #, perl-format
msgid "creating new page %s" msgid "creating new page %s"
msgstr "" msgstr ""