From 92065444d982a443d3862f9ce5094bd32faffb85 Mon Sep 17 00:00:00 2001 From: joey Date: Sun, 3 Sep 2006 19:53:23 +0000 Subject: * Simplify the data structure returned by rcs_recentchanges to avoid each rcs plugin needing to form complex strings on its own. --- IkiWiki/CGI.pm | 16 +++++++++++++++- IkiWiki/Rcs/Stub.pm | 29 ++++++++++++++++++++--------- IkiWiki/Rcs/git.pm | 7 +++---- IkiWiki/Rcs/svn.pm | 6 +++--- debian/changelog | 7 +++++++ 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 99fc5c0ed..6e1efbd69 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -76,12 +76,26 @@ sub cgi_recentchanges ($) { #{{{ eval q{use Memoize}; memoize("htmllink"); + eval q{use Time::Duration}; + + my $changelog=[rcs_recentchanges(100)]; + foreach my $change (@$changelog) { + $change->{when} = concise(ago($change->{when})); + $change->{user} = htmllink("", "", $change->{user}, 1); + $change->{pages} = [ + map { + $_->{link} = htmllink("", "", $_->{page}, 1); + $_; + } @{$change->{pages}} + ]; + } + my $template=template("recentchanges.tmpl"); $template->param( title => "RecentChanges", indexlink => indexlink(), wikiname => $config{wikiname}, - changelog => [rcs_recentchanges(100)], + changelog => $changelog, baseurl => baseurl(), ); print $q->header(-charset => 'utf-8'), $template->output; diff --git a/IkiWiki/Rcs/Stub.pm b/IkiWiki/Rcs/Stub.pm index ffd9e1865..01696a8b0 100644 --- a/IkiWiki/Rcs/Stub.pm +++ b/IkiWiki/Rcs/Stub.pm @@ -32,15 +32,26 @@ sub rcs_add ($) { } sub rcs_recentchanges ($) { - # Examine the RCS history and generate a data structure for - # the recentchanges page. - # This structure is a list of items, each item is a hash reference - # representing one change to the repo. - # The hash has keys user (a link to the user making the change), - # committype (web or the name of the rcs), when (when the change - # happened, relative to the current time), message (a reference - # to an array of lines for the commit message), and pages (a - # reference to an array of links to the pages that were changed). + # Examine the RCS history and generate a list of recent changes. + # The data structure returned for each change is: + # { + # user => # name of user who made the change, + # committype => # either "web" or the name of the rcs, + # when => # time when the change was made, + # message => [ + # "commit message line", + # "commit message line", + # "...", + # ], + # pages => [ + # { + # page => # name of page changed, + # diffurl => # optional url to a diff showing + # # the changes, + # } + # # repeat for each page changed in this commit + # ], + # } } sub rcs_notify () { diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm index 271c27af6..a156f0b4e 100644 --- a/IkiWiki/Rcs/git.pm +++ b/IkiWiki/Rcs/git.pm @@ -345,7 +345,6 @@ sub rcs_recentchanges ($) { #{{{ eval q{use CGI 'escapeHTML'}; eval q{use Date::Parse}; - eval q{use Time::Duration}; my ($sha1, $type, $when, $diffurl, $user, @pages, @message, @rets); INFO: foreach my $ci (git_commit_info('HEAD', $num)) { @@ -356,7 +355,7 @@ sub rcs_recentchanges ($) { #{{{ $sha1 = $ci->{'sha1'}; $type = "web"; - $when = concise(ago(time - $ci->{'author_epoch'})); + $when = time - $ci->{'author_epoch'}; foreach my $bit (@{ $ci->{'details'} }) { my $diffurl = $config{'diffurl'}; @@ -368,7 +367,7 @@ sub rcs_recentchanges ($) { #{{{ $diffurl =~ s/\[\[sha1_to\]\]/$bit->{'sha1_to'}/go; push @pages, { - link => htmllink("", "", pagename($file), 1), + page => pagename($file), diffurl => $diffurl, }, } @@ -386,7 +385,7 @@ sub rcs_recentchanges ($) { #{{{ push @rets, { rev => $sha1, - user => htmllink("", "", $user, 1), + user => $user, committype => $type, when => $when, message => [@message], diff --git a/IkiWiki/Rcs/svn.pm b/IkiWiki/Rcs/svn.pm index 2d203c7ca..9345b7fd2 100644 --- a/IkiWiki/Rcs/svn.pm +++ b/IkiWiki/Rcs/svn.pm @@ -153,7 +153,7 @@ sub rcs_recentchanges ($) { #{{{ my $rev = $logentry->{revision}; my $user = $logentry->{author}; - my $when=concise(ago(time - str2time($logentry->{date}, 'UTC'))); + my $when=time - str2time($logentry->{date}, 'UTC'); foreach my $msgline (split(/\n/, $logentry->{msg})) { push @message, { line => escapeHTML($msgline) }; @@ -177,12 +177,12 @@ sub rcs_recentchanges ($) { #{{{ $diffurl=~s/\[\[r1\]\]/$rev - 1/eg; $diffurl=~s/\[\[r2\]\]/$rev/g; push @pages, { - link => htmllink("", "", pagename($file), 1), + page => pagename($file), diffurl => $diffurl, } if length $file; } push @ret, { rev => $rev, - user => htmllink("", "", $user, 1), + user => $user, committype => $committype, when => $when, message => [@message], diff --git a/debian/changelog b/debian/changelog index 72f4554b5..b4c362ff5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ikiwiki (1.24) UNRELEASED; urgency=low + + * Simplify the data structure returned by rcs_recentchanges to avoid + each rcs plugin needing to form complex strings on its own. + + -- Joey Hess Sun, 3 Sep 2006 13:32:34 -0400 + ikiwiki (1.23) unstable; urgency=low * Allow inline directives to be nested inside eg, sidebars. Closes: #385512 -- cgit v1.2.3