X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6154dd03cb9f46f58c04f91c12ac9e42c696dbbb..efbb1121ffdc146f5c9a481a51f23ad151b9f240:/IkiWiki/Plugin/tla.pm?ds=inline diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index b95c1a522..11be248e8 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -4,8 +4,9 @@ package IkiWiki::Plugin::tla; use warnings; use strict; use IkiWiki; +use URI::Escape q{uri_escape_utf8}; -sub import { #{{{ +sub import { hook(type => "checkconfig", id => "tla", call => \&checkconfig); hook(type => "getsetup", id => "tla", call => \&getsetup); hook(type => "rcs", id => "rcs_update", call => \&rcs_update); @@ -18,26 +19,29 @@ sub import { #{{{ hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); -} #}}} + hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); +} -sub checkconfig () { #{{{ - if (! defined $config{diffurl}) { - $config{diffurl}=""; - } +sub checkconfig () { if (defined $config{tla_wrapper} && length $config{tla_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{tla_wrapper}, wrappermode => (defined $config{tla_wrappermode} ? $config{tla_wrappermode} : "06755"), }; } -} #}}} +} -sub getsetup () { #{{{ +sub getsetup () { return + plugin => { + safe => 0, # rcs plugin + rebuild => undef, + section => "rcs", + }, tla_wrapper => { type => "string", #example => "", # TODO example - description => "tla post-commit executable to generate", + description => "tla post-commit hook to generate", safe => 0, # file rebuild => 0, }, @@ -62,9 +66,9 @@ sub getsetup () { #{{{ safe => 1, rebuild => 1, }, -} #}}} +} -sub quiet_system (@) { #{{{ +sub quiet_system (@) { # See Debian bug #385939. open (SAVEOUT, ">&STDOUT"); close STDOUT; @@ -74,17 +78,17 @@ sub quiet_system (@) { #{{{ open (STDOUT, ">&SAVEOUT"); close SAVEOUT; return $ret; -} #}}} +} -sub rcs_update () { #{{{ +sub rcs_update () { if (-d "$config{srcdir}/{arch}") { if (quiet_system("tla", "replay", "-d", $config{srcdir}) != 0) { warn("tla replay failed\n"); } } -} #}}} +} -sub rcs_prepedit ($) { #{{{ +sub rcs_prepedit ($) { my $file=shift; if (-d "$config{srcdir}/{arch}") { @@ -93,20 +97,25 @@ sub rcs_prepedit ($) { #{{{ my $rev=`tla tree-id $config{srcdir}`; return defined $rev ? $rev : ""; } -} #}}} +} -sub rcs_commit ($$$;$$) { #{{{ - my $file=shift; - my $message=shift; - my $rcstoken=shift; - my $user=shift; - my $ipaddr=shift; +sub rcs_commit (@) { + my %params=@_; - if (defined $user) { - $message="web commit by $user".(length $message ? ": $message" : ""); - } - elsif (defined $ipaddr) { - $message="web commit from $ipaddr".(length $message ? ": $message" : ""); + my ($file, $message, $rcstoken)= + ($params{file}, $params{message}, $params{token}); + + if (defined $params{session}) { + if (defined $params{session}->param("name")) { + $message="web commit by ". + $params{session}->param("name"). + (length $message ? ": $message" : ""); + } + elsif (defined $params{session}->remote_addr()) { + $message="web commit from ". + $params{session}->remote_addr(). + (length $message ? ": $message" : ""); + } } if (-d "$config{srcdir}/{arch}") { @@ -134,17 +143,17 @@ sub rcs_commit ($$$;$$) { #{{{ } } return undef # success -} #}}} +} -sub rcs_commit_staged ($$$) { +sub rcs_commit_staged (@) { # Commits all staged changes. Changes can be staged using rcs_add, # rcs_remove, and rcs_rename. - my ($message, $user, $ipaddr)=@_; + my %params=@_; error("rcs_commit_staged not implemented for tla"); # TODO } -sub rcs_add ($) { #{{{ +sub rcs_add ($) { my $file=shift; if (-d "$config{srcdir}/{arch}") { @@ -152,19 +161,19 @@ sub rcs_add ($) { #{{{ warn("tla add failed\n"); } } -} #}}} +} -sub rcs_remove ($) { # {{{ +sub rcs_remove ($) { my $file = shift; error("rcs_remove not implemented for tla"); # TODO -} #}}} +} -sub rcs_rename ($$) { # {{{a +sub rcs_rename ($$) { my ($src, $dest) = @_; error("rcs_rename not implemented for tla"); # TODO -} #}}} +} sub rcs_recentchanges ($) { my $num=shift; @@ -215,8 +224,9 @@ sub rcs_recentchanges ($) { my @pages; foreach my $file (@paths) { - my $diffurl=$config{diffurl}; - $diffurl=~s/\[\[file\]\]/$file/g; + my $diffurl=defined $config{diffurl} ? $config{diffurl} : ""; + my $efile = uri_escape_utf8($file); + $diffurl=~s/\[\[file\]\]/$efile/g; $diffurl=~s/\[\[rev\]\]/$change/g; push @pages, { page => pagename($file), @@ -238,7 +248,7 @@ sub rcs_recentchanges ($) { return @ret; } -sub rcs_diff ($) { #{{{ +sub rcs_diff ($) { my $rev=shift; my $logs = `tla logs -d $config{srcdir}`; my @changesets = reverse split(/\n/, $logs); @@ -250,9 +260,9 @@ sub rcs_diff ($) { #{{{ my $revminusone = $changesets[$i+1]; return `tla diff -d $config{srcdir} $revminusone`; -} #}}} +} -sub rcs_getctime ($) { #{{{ +sub rcs_getctime ($) { my $file=shift; eval q{use Date::Parse}; error($@) if $@; @@ -280,6 +290,10 @@ sub rcs_getctime ($) { #{{{ my $date=str2time($sdate, 'UTC'); debug("found ctime ".localtime($date)." for $file"); return $date; -} #}}} +} + +sub rcs_getmtime ($) { + error "rcs_getmtime is not implemented for tla\n"; # TODO +} 1