]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/tla.pm
Merge commit 'upstream/master' into prv/po
[git.ikiwiki.info.git] / IkiWiki / Plugin / tla.pm
index e1389a34677e5b4fa1f3ade6acc10891bd2d0d0b..0a5c161b25e32c74bee0c14f538cc98d85375a0a 100644 (file)
@@ -1,29 +1,44 @@
 #!/usr/bin/perl
-
-package IkiWiki;
+package IkiWiki::Plugin::tla;
 
 use warnings;
 use strict;
 use IkiWiki;
 
-hook(type => "checkconfig", id => "tla", call => sub { #{{{
-       if (! defined $config{diffurl}) {
-               $config{diffurl}="";
-       }
-       if (length $config{tla_wrapper}) {
+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);
+       hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
+       hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit);
+       hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged);
+       hook(type => "rcs", id => "rcs_add", call => \&rcs_add);
+       hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove);
+       hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename);
+       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);
+} #}}}
+
+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"),
                };
        }
-}); #}}}
+} #}}}
 
-hook(type => "getsetup", id => "tla", call => sub { #{{{
+sub getsetup () { #{{{
        return
+               plugin => {
+                       safe => 0, # rcs plugin
+                       rebuild => undef,
+               },
                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,
                },
@@ -48,9 +63,9 @@ hook(type => "getsetup", id => "tla", call => sub { #{{{
                        safe => 1,
                        rebuild => 1,
                },
-}); #}}}
+} #}}}
 
-sub quiet_system (@) {
+sub quiet_system (@) { #{{{
        # See Debian bug #385939.
        open (SAVEOUT, ">&STDOUT");
        close STDOUT;
@@ -60,7 +75,7 @@ sub quiet_system (@) {
        open (STDOUT, ">&SAVEOUT");
        close SAVEOUT;
        return $ret;
-}
+} #}}}
 
 sub rcs_update () { #{{{
        if (-d "$config{srcdir}/{arch}") {
@@ -110,7 +125,7 @@ sub rcs_commit ($$$;$$) { #{{{
                }
 
                if (quiet_system("tla", "commit",
-                          "-L".possibly_foolish_untaint($message),
+                          "-L".IkiWiki::possibly_foolish_untaint($message),
                           '-d', $config{srcdir}) != 0) {
                        my $conflict=readfile("$config{srcdir}/$file");
                        if (system("tla", "undo", "-n", "--quiet", "-d", "$config{srcdir}") != 0) {
@@ -201,7 +216,7 @@ sub rcs_recentchanges ($) {
                my @pages;
 
                foreach my $file (@paths) {
-                       my $diffurl=$config{diffurl};
+                       my $diffurl=defined $config{diffurl} ? $config{diffurl} : "";
                        $diffurl=~s/\[\[file\]\]/$file/g;
                        $diffurl=~s/\[\[rev\]\]/$change/g;
                        push @pages, {