I kept it to a simple global configuration, rather than using the
preprocessor directive for recentchanges, because that had chicken and egg
problems and seemed overcomplicated. This should work reasonably well,
though it would be good to add some more metadata so that more customised
recentchanges pages can be made.
use IkiWiki 2.00;
sub import { #{{{
use IkiWiki 2.00;
sub import { #{{{
- hook(type => "refresh", id => "recentchanges",
- call => \&refresh);
- hook(type => "preprocess", id => "recentchanges",
- call => \&preprocess);
- hook(type => "htmlize", id => "_change",
- call => \&htmlize);
+ hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
+ hook(type => "refresh", id => "recentchanges", call => \&refresh);
+ hook(type => "htmlize", id => "_change", call => \&htmlize);
-sub refresh ($) { #{{{
- my @changes=IkiWiki::rcs_recentchanges(100);
- updatechanges("*", "recentchanges", \@changes);
+sub checkconfig () { #{{{
+ $config{recentchangespage}='recentchanges' unless defined $config{recentchangespage};
+ $config{recentchangesnum}=100 unless defined $config{recentchangesnum};
-sub preprocess (@) { #{{{
- my %params=@_;
-
- # TODO
+sub refresh ($) { #{{{
+ my %seen;
+ # add new changes
+ foreach my $change (IkiWiki::rcs_recentchanges($config{recentchangesnum})) {
+ $seen{store($change, $config{recentchangespage})}=1;
+ }
+
+ # delete old and excess changes
+ foreach my $page (keys %pagesources) {
+ if ($page=~/^\Q$config{recentchangespage}\E\/change_/ && ! $seen{$page}) {
+ unlink($config{srcdir}.'/'.$pagesources{$page});
+ }
+ }
} #}}}
# Pages with extension _change have plain html markup, pass through.
} #}}}
# Pages with extension _change have plain html markup, pass through.
return $params{content};
} #}}}
return $params{content};
} #}}}
- my $subdir=shift;
-
- my $page="$subdir/change_".IkiWiki::titlepage($change->{rev});
+
+ my $page="$config{recentchangespage}/change_".IkiWiki::titlepage($change->{rev});
# Optimisation to avoid re-writing pages. Assumes commits never
# change (or that any changes are not important).
# Optimisation to avoid re-writing pages. Assumes commits never
# change (or that any changes are not important).
} #}}}
sub updatechanges ($$) { #{{{
} #}}}
sub updatechanges ($$) { #{{{
my $subdir=shift;
my @changes=@{shift()};
my $subdir=shift;
my @changes=@{shift()};
- my %seen;
-
- # add new changes
- foreach my $change (@changes) {
- $seen{store($change, $subdir)}=1;
- }
-
- # delete old and excess changes
- foreach my $page (keys %pagesources) {
- if ($page=~/^\Q$subdir\E\/change_/ && ! $seen{$page}) {
- unlink($config{srcdir}.'/'.$pagesources{$page});
- }
- }
- if ($config{rcs}) {
- $template->param(recentchangesurl => urlto("recentchanges", $page));
+ if ($config{rcs} && exists $config{recentchangespage}) {
+ $template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
-While ikiwiki is primarily a wiki compiler, which generates static html pages, it does use CGI for two important wiki features, online page editing and the [[RecentChanges]] display.
+While ikiwiki is primarily a wiki compiler, which generates static html
+pages, it does use CGI for online page editing.
-To enable CGI, you need to create and install an ikiwiki.cgi wrapper. [[Setup]] explains how to do this.
\ No newline at end of file
+To enable CGI, you need to create and install an ikiwiki.cgi wrapper.
+[[Setup]] explains how to do this.
#account_creation_password => "example",
# Uncomment to force ikiwiki to run with a particular umask.
#umask => 022,
#account_creation_password => "example",
# Uncomment to force ikiwiki to run with a particular umask.
#umask => 022,
+ # Default settings for the recentchanges page.
+ #recentchangespage => "recentchanges",
+ #recentchangesnum => 100,
# To add plugins, list them here.
#add_plugins => [qw{goodstuff search wikitext camelcase
# To add plugins, list them here.
#add_plugins => [qw{goodstuff search wikitext camelcase
pages can be joined together with [[inline]] to generate the
[[RecentChanges]] page.
pages can be joined together with [[inline]] to generate the
[[RecentChanges]] page.
-Typically only the RecentChanges page will use the plugin, but you can
-use it elsewhere too if you like. It's used like this:
+Typically only the RecentChanges page will use the pages generated by this
+plugin, but you can use it elsewhere too if you like. It's used like this:
- \[[recentchanges pages="*" num=100 template=change]]
\[[inline pages="internal(recentchanges/change_*)"
template=recentchanges show=0]]
\[[inline pages="internal(recentchanges/change_*)"
template=recentchanges show=0]]
-
-The pages describing recent changes will be created as [[subpages|subpage]]
-of the page where the `recentchanges` directive is placed.
Recent changes to this wiki:
Recent changes to this wiki:
-[[recentchanges pages="*" num=100 template=change]]
[[inline pages="internal(recentchanges/change_*) and !*/Discussion"
template=recentchanges show=0]]
[[inline pages="internal(recentchanges/change_*) and !*/Discussion"
template=recentchanges show=0]]
* --cgi
Enable [[CGI]] mode. In cgi mode ikiwiki runs as a cgi script, and
* --cgi
Enable [[CGI]] mode. In cgi mode ikiwiki runs as a cgi script, and
- supports editing pages, signing in, registration, and displaying
- [[RecentChanges]].
+ supports editing pages, signing in, and registration.
To use ikiwiki as a [[CGI]] program you need to use --wrapper or --setup
to generate a wrapper. The wrapper will generally need to run suid 6755 to
To use ikiwiki as a [[CGI]] program you need to use --wrapper or --setup
to generate a wrapper. The wrapper will generally need to run suid 6755 to
whatever the revision control system you select uses.
In [[CGI]] mode, with a revision control system enabled, pages edited via
whatever the revision control system you select uses.
In [[CGI]] mode, with a revision control system enabled, pages edited via
- the web will be committed. Also, the [[RecentChanges]] link will be placed
- on pages.
+ the web will be committed.
No revision control is enabled by default.
No revision control is enabled by default.
syslog => 0,
userdir => "users",
usedirs => 0,
syslog => 0,
userdir => "users",
usedirs => 0,
- rcs => 'git',
- rss => 1,
- cgiurl => "http://ikiwiki.info/ikiwiki.cgi",
- url => "http://ikiwiki.info",
- add_plugins => [qw{goodstuff version haiku polygen fortune
- recentchanges }],
+ add_plugins => [qw{goodstuff version haiku polygen fortune}],
+ disable_plugins => [qw{recentchanges}],
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-01-29 15:21-0500\n"
+"POT-Creation-Date: 2008-01-29 15:46-0500\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"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
ok(! pagespec_match("foo", "no_such_function(foo)"), "foo");
ok(! pagespec_match("foo", "no_such_function(foo)"), "foo");
-ok(pagespec_match("foo", "foo and user(bar)", user => "bar"), "user");
-ok(! pagespec_match("foo", "foo and user(bar)", user => "baz"), "user fail");
-
my $ret=pagespec_match("foo", "(invalid");
ok(! $ret, "syntax error");
ok($ret eq "syntax error", "error message");
my $ret=pagespec_match("foo", "(invalid");
ok(! $ret, "syntax error");
ok($ret eq "syntax error", "error message");