X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/340fe9707c61064774658e6ec2aec3b07b33c120..5e713047b4eda5b9ae6d7154729cc238d5284776:/IkiWiki/Plugin/recentchanges.pm

diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index e23ee491f..7bc482974 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -6,6 +6,7 @@ use strict;
 use IkiWiki 2.00;
 
 sub import { #{{{
+	hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
 	hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
 	hook(type => "refresh", id => "recentchanges", call => \&refresh);
 	hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
@@ -13,6 +14,28 @@ sub import { #{{{
 	hook(type => "cgi", id => "recentchanges", call => \&cgi);
 } #}}}
 
+sub getsetup () { #{{{
+	return
+		plugin => {
+			safe => 1,
+			rebuild => 1,
+		},
+		recentchangespage => {
+			type => "string",
+			example => "recentchanges",
+			description => "name of the recentchanges page",
+			safe => 1,
+			rebuild => 1,
+		},
+		recentchangesnum => {
+			type => "integer",
+			example => 100,
+			description => "number of changes to track",
+			safe => 1,
+			rebuild => 0,
+		},
+} #}}}
+
 sub checkconfig () { #{{{
 	$config{recentchangespage}='recentchanges' unless defined $config{recentchangespage};
 	$config{recentchangesnum}=100 unless defined $config{recentchangesnum};
@@ -28,7 +51,7 @@ sub refresh ($) { #{{{
 	
 	# delete old and excess changes
 	foreach my $page (keys %pagesources) {
-		if ($page=~/^\Q$config{recentchangespage}\E\/change_/ && ! $seen{$page}) {
+		if ($pagesources{$page} =~ /\._change$/ && ! $seen{$page}) {
 			unlink($config{srcdir}.'/'.$pagesources{$page});
 		}
 	}
@@ -39,7 +62,9 @@ sub pagetemplate (@) { #{{{
 	my %params=@_;
 	my $template=$params{template};
 	my $page=$params{page};
-	if ($config{rcs} && $page ne $config{recentchangespage} &&
+
+	if (defined $config{recentchangespage} && $config{rcs} &&
+	    $page ne $config{recentchangespage} &&
 	    $template->query(name => "recentchangesurl")) {
 		$template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
 		$template->param(have_actions => 1);
@@ -78,7 +103,7 @@ sub cgi ($) { #{{{
 				"</p>");
 		}
 		else {
-			IkiWiki::redirect($cgi, $config{url}."/".htmlpage($link));
+			IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link)));
 		}
 
 		exit;
@@ -133,7 +158,7 @@ sub store ($$$) { #{{{
 		);
 	}
 
-	# escape  wikilinks and preprocessor stuff in commit messages
+	# escape wikilinks and preprocessor stuff in commit messages
 	if (ref $change->{message}) {
 		foreach my $field (@{$change->{message}}) {
 			if (exists $field->{line}) {
@@ -150,7 +175,8 @@ sub store ($$$) { #{{{
 		wikiname => $config{wikiname},
 	);
 	IkiWiki::run_hooks(pagetemplate => sub {
-		shift->(page => $page, destpage => $page, template => $template);
+		shift->(page => $page, destpage => $page,
+			template => $template, rev => $change->{rev});
 	});
 
 	my $file=$page."._change";
@@ -160,10 +186,4 @@ sub store ($$$) { #{{{
 	return $page;
 } #}}}
 
-sub updatechanges ($$) { #{{{
-	my $subdir=shift;
-	my @changes=@{shift()};
-	
-} #}}}
-
 1