aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-01-29 01:48:55 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-01-29 01:48:55 -0500
commit21f44880cdd8f23264b2416bf39793aadcb87df6 (patch)
tree90507c97f7de0772b2da7418a8db0eafeba7bd1f
parentd72753e100b018dfa82feb06e06fc2ad2c61f4ed (diff)
downloadikiwiki-21f44880cdd8f23264b2416bf39793aadcb87df6.tar
ikiwiki-21f44880cdd8f23264b2416bf39793aadcb87df6.tar.gz
non-tabular recentchanges display
Doesn't look as good as the old table, but works as a rss feed.
-rw-r--r--IkiWiki.pm23
-rw-r--r--IkiWiki/CGI.pm53
-rw-r--r--IkiWiki/Plugin/recentchanges.pm23
-rw-r--r--doc/recentchanges.mdwn3
-rw-r--r--doc/wikitemplates.mdwn1
-rw-r--r--templates/change.tmpl49
-rw-r--r--templates/recentchanges.tmpl16
7 files changed, 58 insertions, 110 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 2c3ddac23..c70307b5f 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -607,14 +607,11 @@ sub htmllink ($$$;@) { #{{{
return "<a href=\"$bestlink\"@attrs>$linktext</a>";
} #}}}
-sub userlink ($) { #{{{
+sub openiduser ($) { #{{{
my $user=shift;
- eval q{use CGI 'escapeHTML'};
- error($@) if $@;
if ($user =~ m!^https?://! &&
eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) {
- # Munge user-urls, as used by eg, OpenID.
my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user);
my $display=$oid->display;
# Convert "user.somehost.com" to "user [somehost.com]".
@@ -626,10 +623,24 @@ sub userlink ($) { #{{{
$display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/;
}
$display=~s!^https?://!!; # make sure this is removed
- return "<a href=\"$user\">".escapeHTML($display)."</a>";
+ eval q{use CGI 'escapeHTML'};
+ error($@) if $@;
+ return escapeHTML($display);
+ }
+ return;
+}
+
+sub userlink ($) { #{{{
+ my $user=shift;
+
+ my $oiduser=openiduser($user);
+ if (defined $oiduser) {
+ return "<a href=\"$user\">$oiduser</a>";
}
else {
- return $user;
+ return htmllink("", "", escapeHTML(
+ length $config{userdir} ? $config{userdir}."/".$user : $user
+ ), noimageinline => 1);
}
} #}}}
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 55ee5d86a..c8c1b63dd 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -84,53 +84,6 @@ sub decode_cgi_utf8 ($) { #{{{
}
} #}}}
-sub cgi_recentchanges ($) { #{{{
- my $q=shift;
-
- # Optimisation: building recentchanges means calculating lots of
- # links. Memoizing htmllink speeds it up a lot (can't be memoized
- # during page builds as the return values may change, but they
- # won't here.)
- eval q{use Memoize};
- error($@) if $@;
- memoize("htmllink");
-
- eval q{use Time::Duration};
- error($@) if $@;
-
- my $changelog=[rcs_recentchanges(100)];
- foreach my $change (@$changelog) {
- $change->{when} = concise(ago(time - $change->{when}));
-
- $change->{user} = userlink($change->{user});
-
- my $is_excess = exists $change->{pages}[10]; # limit pages to first 10
- delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess;
- $change->{pages} = [
- map {
- $_->{link} = htmllink("", "", $_->{page},
- noimageinline => 1,
- linktext => pagetitle($_->{page}));
- $_;
- } @{$change->{pages}}
- ];
- push @{$change->{pages}}, { link => '...' } if $is_excess;
- }
-
- my $template=template("recentchanges.tmpl");
- $template->param(
- title => "RecentChanges",
- indexlink => indexlink(),
- wikiname => $config{wikiname},
- changelog => $changelog,
- baseurl => baseurl(),
- );
- run_hooks(pagetemplate => sub {
- shift->(page => "", destpage => "", template => $template);
- });
- print $q->header(-charset => 'utf-8'), $template->output;
-} #}}}
-
# Check if the user is signed in. If not, redirect to the signin form and
# save their place to return to later.
sub needsignin ($$) { #{{{
@@ -661,12 +614,6 @@ sub cgi (;$$) { #{{{
}
}
- # Things that do not need a session.
- if ($do eq 'recentchanges') {
- cgi_recentchanges($q);
- return;
- }
-
# Need to lock the wiki before getting a session.
lockwiki();
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 6b36ea4c8..fb9841ffd 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -67,14 +67,25 @@ sub store ($$) { #{{{
];
push @{$change->{pages}}, { link => '...' } if $is_excess;
+ # Take the first line of the commit message as a summary.
+ my $m=shift @{$change->{message}};
+ $change->{summary}=$m->{line};
+
+ # See if the committer is an openid.
+ my $oiduser=IkiWiki::openiduser($change->{user});
+ if (defined $oiduser) {
+ $change->{authorurl}=$change->{user};
+ $change->{user}=$oiduser;
+ }
+ elsif (length $config{url}) {
+ $change->{authorurl}="$config{url}/".
+ (length $config{userdir} ? "$config{userdir}/" : "").
+ $change->{user};
+ }
+
# Fill out a template with the change info.
my $template=template("change.tmpl", blind_cache => 1);
- $template->param(
- user => IkiWiki::userlink($change->{user}),
- when => IkiWiki::displaytime($change->{when}, "%X %x"),
- pages => $change->{pages},
- message => $change->{message},
- );
+ $template->param(%$change);
$template->param(baseurl => "$config{url}/") if length $config{url};
IkiWiki::run_hooks(pagetemplate => sub {
shift->(page => $page, destpage => $page, template => $template);
diff --git a/doc/recentchanges.mdwn b/doc/recentchanges.mdwn
index a027bf462..b2c7f5d07 100644
--- a/doc/recentchanges.mdwn
+++ b/doc/recentchanges.mdwn
@@ -1,3 +1,2 @@
[[recentchanges pages="*" num=100 template=change]]
-[[inline pages="recentchanges/change_* and !*/Discussion"
-template=recentchanges show=0]]
+[[inline pages="recentchanges/change_* and !*/Discussion" show=0]]
diff --git a/doc/wikitemplates.mdwn b/doc/wikitemplates.mdwn
index b8341b637..1f6325b4b 100644
--- a/doc/wikitemplates.mdwn
+++ b/doc/wikitemplates.mdwn
@@ -11,7 +11,6 @@ located in /usr/share/ikiwiki/templates by default.
* `misc.tmpl` - Generic template used for any page that doesn't
have a custom template.
* `editpage.tmpl` - Create/edit 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.
diff --git a/templates/change.tmpl b/templates/change.tmpl
index 9dbc97ec2..f02b5eb19 100644
--- a/templates/change.tmpl
+++ b/templates/change.tmpl
@@ -1,27 +1,24 @@
+[[meta author="""<TMPL_VAR USER>"""]]
+<TMPL_IF AUTHORURL>
+[[meta authorurl="""<TMPL_VAR AUTHORURL>"""]]
+</TMPL_IF>
+[[meta title="""<TMPL_VAR SUMMARY>"""]]
+<p class=changelog>
+<TMPL_LOOP NAME="MESSAGE">
+ <TMPL_IF NAME="LINE">
+ <TMPL_VAR NAME="LINE" ESCAPE="HTML"><br />
+ </TMPL_IF>
+</TMPL_LOOP>
+</p>
+<p>
+<span 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_IF>
+ <TMPL_VAR LINK>
+</TMPL_LOOP>
+changed via <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>
diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl
deleted file mode 100644
index 2e33b79f9..000000000
--- a/templates/recentchanges.tmpl
+++ /dev/null
@@ -1,16 +0,0 @@
-<TMPL_IF FIRST>
-<table border="1" frame="border" rules="groups">
-<thead>
- <tr class="changeheader">
- <th class="changeheader" align="left">user</th>
- <th class="changeheader" align="left">time</th>
- <th class="changeheader" align="left" colspan="2">changes</th>
- </tr>
-</thead>
-<tbody>
-</TMPL_IF>
-<TMPL_VAR CONTENT>
-<TMPL_IF LAST>
-</tbody>
-</table>
-</TMPL_IF>