proof of concept implementation of static recentchanges
Currently hardcoded to write to recentchanges/*, and the page format needs to be rethought to be usable for aggregation, but it basically works.master
parent
2d3dc86d07
commit
5921b86fcc
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/perl
|
||||
package IkiWiki::Plugin::recentchanges;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use IkiWiki 2.00;
|
||||
|
||||
sub import { #{{{
|
||||
hook(type => "checkconfig", id => "recentchanges",
|
||||
call => \&checkconfig);
|
||||
hook(type => "needsbuild", id => "recentchanges",
|
||||
call => \&needsbuild);
|
||||
hook(type => "preprocess", id => "recentchanges",
|
||||
call => \&preprocess);
|
||||
hook(type => "htmlize", id => "_change",
|
||||
call => \&htmlize);
|
||||
} #}}}
|
||||
|
||||
sub checkconfig () { #{{{
|
||||
updatechanges();
|
||||
} #}}}
|
||||
|
||||
sub needsbuild () { #{{{
|
||||
# TODO
|
||||
} #}}}
|
||||
|
||||
sub preprocess (@) { #{{{
|
||||
my %params=@_;
|
||||
|
||||
# TODO
|
||||
|
||||
return "";
|
||||
} #}}}
|
||||
|
||||
# Pages with extension _change have plain html markup, pass through.
|
||||
sub htmlize (@) { #{{{
|
||||
my %params=@_;
|
||||
return $params{content};
|
||||
} #}}}
|
||||
|
||||
sub store ($$) { #{{{
|
||||
my $change=shift;
|
||||
my $subdir=shift;
|
||||
|
||||
my $page="$subdir/change_".IkiWiki::titlepage($change->{rev});
|
||||
|
||||
# Optimisation to avoid re-writing pages. Assumes commits never
|
||||
# change, or that any changes are not important.
|
||||
return if exists $pagesources{$page} && ! $config{rebuild};
|
||||
|
||||
# Limit pages to first 10, and add links to the changed pages.
|
||||
my $is_excess = exists $change->{pages}[10];
|
||||
delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess;
|
||||
$change->{pages} = [
|
||||
map {
|
||||
if (length $config{url}) {
|
||||
$_->{link} = "<a href=\"$config{url}/".
|
||||
urlto($_->{page},"")."\">".
|
||||
IkiWiki::pagetitle($_->{page})."</a>";
|
||||
}
|
||||
else {
|
||||
$_->{link} = IkiWiki::pagetitle($_->{page});
|
||||
}
|
||||
$_;
|
||||
} @{$change->{pages}}
|
||||
];
|
||||
push @{$change->{pages}}, { link => '...' } if $is_excess;
|
||||
|
||||
# Fill out a template with the change info.
|
||||
$change->{user} = IkiWiki::userlink($change->{user});
|
||||
my $ctime=$change->{when};
|
||||
$change->{when} = IkiWiki::displaytime($change->{when}, "%X %x");
|
||||
my $template=template("change.tmpl", blind_cache => 1);
|
||||
$template->param(%$change);
|
||||
$template->param(baseurl => "$config{url}/") if length $config{url};
|
||||
IkiWiki::run_hooks(pagetemplate => sub {
|
||||
shift->(page => $page, destpage => $page, template => $template);
|
||||
});
|
||||
|
||||
writefile($page."._change", $config{srcdir}, $template->output);
|
||||
utime $ctime, $ctime, "$config{srcdir}/$page._change";
|
||||
} #}}}
|
||||
|
||||
sub updatechanges () { #{{{
|
||||
my @changelog=IkiWiki::rcs_recentchanges(100);
|
||||
foreach my $change (@changelog) {
|
||||
store($change, "recentchanges");
|
||||
}
|
||||
# TODO: delete old
|
||||
} #}}}
|
||||
|
||||
1
|
|
@ -0,0 +1,14 @@
|
|||
[[template id=plugin name=recentchanges core=1 author="[[Joey]]"]]
|
||||
|
||||
This plugin examines the [[revision_control_system|rcs]] history and
|
||||
generates a page describing each recent change made to the wiki. These
|
||||
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:
|
||||
|
||||
\[[recentchanges pages="*" num=100 template=change]]
|
||||
|
||||
The pages describing recent changes will be created as [[subpages|subpage]]
|
||||
of the page where the `recentchanges` directive is placed.
|
|
@ -1,3 +1,3 @@
|
|||
ikiwiki generates the list of recent changes by examining the history of
|
||||
the [[revision_control_system|rcs]] that the wiki is configured to use. You
|
||||
have to have [[CGI]] set up for this feature to be enabled.
|
||||
[[recentchanges pages="*" num=100 template=change]]
|
||||
[[inline pages="recentchanges/change_* and !*/Discussion"
|
||||
template=recentchanges show=0]]
|
||||
|
|
|
@ -107,11 +107,8 @@ Here's a full design for redoing recentchanges, based on Ethan's ideas:
|
|||
aggregator, or they can set up their own page that uses the recentchanges
|
||||
directive for only the pages they want.
|
||||
* The `rcs_notify` functions will be removed.
|
||||
* `rcs_getchange` is passed a change id (as returned from rcs_recentchanges)
|
||||
and a partially filled out HTML::Template and fills out the remainer of the
|
||||
template. So if a template is used that includes diffs, it will need to run
|
||||
some expensive diffing operation, wikis with less resources can use a
|
||||
template that doesn't include diffs and avoid that overhead.
|
||||
* To add diffs, another plugin can add a pagetemplate hook that calls
|
||||
a `rcs_diff`. (optional)
|
||||
* So to update the changes files, just call `rcs_recentchanges`, create
|
||||
files for each new id, and delete files for each id that is no longer
|
||||
included.
|
||||
|
|
|
@ -10,11 +10,12 @@ located in /usr/share/ikiwiki/templates by default.
|
|||
* `page.tmpl` - Used for displaying all regular wiki pages.
|
||||
* `misc.tmpl` - Generic template used for any page that doesn't
|
||||
have a custom template.
|
||||
* `recentchanges.tmpl` - Used for the RecentChanges page.
|
||||
* `editpage.tmpl` - Create/edit page.
|
||||
* `notifymail.tmpl` - Not a html template, this is used to
|
||||
generate change notification mails for users who have subscribed to
|
||||
changes to a page.
|
||||
* `recentchanges.tmpl` - Used to generate a RecentChanges table with inline.
|
||||
* `change.tmpl` - Used to create a page describing a change made to the wiki.
|
||||
* `passwordmail.tmpl` - Not a html template, this is used to
|
||||
generate the mail with the user's password in it.
|
||||
* `rsspage.tmpl` - Used for generating rss feeds for [blogs|[ikiwiki/blog]].
|
||||
|
|
|
@ -1,15 +1,27 @@
|
|||
[[meta title="""
|
||||
<TMPL_LOOP NAME="MESSAGE"><TMPL_IF NAME="LINE"><TMPL_VAR NAME="LINE" ESCAPE="HTML"><br /></TMPL_IF></TMPL_LOOP>
|
||||
"""]]
|
||||
[[meta author="<TMPL_VAR NAME="USER">"]]
|
||||
<TMPL_LOOP NAME="PAGES">
|
||||
<TMPL_IF NAME="DIFFURL">
|
||||
<TMPL_IF NAME="BASEURL">
|
||||
<a href="<TMPL_VAR NAME="DIFFURL">">
|
||||
<img alt="diff" src="<TMPL_VAR BASEURL>wikiicons/diff.png" />
|
||||
</a>
|
||||
</TMPL_IF>
|
||||
</TMPL_IF>
|
||||
<TMPL_VAR NAME="LINK">
|
||||
</TMPL_LOOP>
|
||||
<TMPL_VAR NAME="COMMITTYPE">
|
||||
<!-- <TMPL_VAR NAME="REV"> -->
|
||||
<tr class="changeinfo">
|
||||
<td class="changeinfo"><TMPL_VAR NAME="USER"></td>
|
||||
<td class="changetime"><TMPL_VAR NAME="WHEN"></td>
|
||||
<td class="changeinfo">
|
||||
<TMPL_LOOP NAME="PAGES">
|
||||
<TMPL_IF NAME="DIFFURL">
|
||||
<a href="<TMPL_VAR NAME="DIFFURL">">
|
||||
<img alt="diff" src="wikiicons/diff.png" />
|
||||
</a>
|
||||
<TMPL_VAR NAME="LINK">
|
||||
<TMPL_ELSE>
|
||||
<TMPL_VAR NAME="LINK">
|
||||
</TMPL_IF>
|
||||
</TMPL_LOOP>
|
||||
</td>
|
||||
<td class="changeinfo"><TMPL_VAR NAME="COMMITTYPE"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="changelog" colspan="4">
|
||||
<TMPL_LOOP NAME="MESSAGE">
|
||||
<TMPL_IF NAME="LINE">
|
||||
<TMPL_VAR NAME="LINE" ESCAPE="HTML"><br />
|
||||
</TMPL_IF>
|
||||
</TMPL_LOOP>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1,26 +1,4 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<base href="<TMPL_VAR BASEURL>" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><TMPL_VAR TITLE></title>
|
||||
<link rel="stylesheet" href="<TMPL_VAR BASEURL>style.css" type="text/css" />
|
||||
<link rel="stylesheet" href="<TMPL_VAR BASEURL>local.css" type="text/css" />
|
||||
<TMPL_IF NAME="FAVICON">
|
||||
<link rel="icon" href="<TMPL_VAR BASEURL><TMPL_VAR FAVICON>" type="image/x-icon" />
|
||||
</TMPL_IF>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="header">
|
||||
<span>
|
||||
<TMPL_VAR INDEXLINK>/ <TMPL_VAR TITLE>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<br />
|
||||
<TMPL_IF FIRST>
|
||||
<table border="1" frame="border" rules="groups">
|
||||
<thead>
|
||||
<tr class="changeheader">
|
||||
|
@ -30,42 +8,9 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<TMPL_LOOP NAME="CHANGELOG">
|
||||
<!-- <TMPL_VAR NAME="REV"> -->
|
||||
<tr class="changeinfo">
|
||||
<td class="changeinfo"><TMPL_VAR NAME="USER"></td>
|
||||
<td class="changetime"><TMPL_VAR NAME="WHEN"></td>
|
||||
<td class="changeinfo">
|
||||
<TMPL_LOOP NAME="PAGES">
|
||||
<TMPL_IF NAME="DIFFURL">
|
||||
<a href="<TMPL_VAR NAME="DIFFURL">">
|
||||
<img alt="diff" src="wikiicons/diff.png" />
|
||||
</a>
|
||||
<TMPL_VAR NAME="LINK">
|
||||
<TMPL_ELSE>
|
||||
<TMPL_VAR NAME="LINK">
|
||||
</TMPL_IF>
|
||||
</TMPL_LOOP>
|
||||
</td>
|
||||
<td class="changeinfo"><TMPL_VAR NAME="COMMITTYPE"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="changelog" colspan="4">
|
||||
<TMPL_LOOP NAME="MESSAGE">
|
||||
<TMPL_IF NAME="LINE">
|
||||
<TMPL_VAR NAME="LINE" ESCAPE="HTML"><br />
|
||||
</TMPL_IF>
|
||||
</TMPL_LOOP>
|
||||
</td>
|
||||
</tr>
|
||||
</TMPL_LOOP>
|
||||
</TMPL_IF>
|
||||
<TMPL_VAR CONTENT>
|
||||
<TMPL_IF LAST>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<!-- from <TMPL_VAR NAME=WIKINAME> -->
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</TMPL_IF>
|
||||
|
|
Loading…
Reference in New Issue