]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
* Implemented expiry options for aggregate plugin.
[ikiwiki.git] / IkiWiki.pm
index 6c0bc1f60eb5a4e8eabf0a5d3a72fae492abb054..73bc747f9b443c6aee916b057b3f21c9d61c3c66 100644 (file)
@@ -14,9 +14,9 @@ use vars qw{%config %links %oldlinks %oldpagemtime %pagectime %pagecase
 use Exporter q{import};
 our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
                  bestlink htmllink readfile writefile pagetype srcfile pagename
-                 displaytime
+                 displaytime will_render
                  %config %links %renderedfiles %pagesources);
-our $VERSION = 1.01;
+our $VERSION = 1.01; # plugin interface version
 
 # Optimisation.
 use Memoize;
@@ -24,9 +24,10 @@ memoize("abs2rel");
 memoize("pagespec_translate");
 
 my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
+our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
 
 sub defaultconfig () { #{{{
-       wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.x?html?$|\.rss$|.arch-ids/|{arch}/)},
+       wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.x?html?$|\.rss$|\.atom$|.arch-ids/|{arch}/)},
        wiki_link_regexp => qr/\[\[(?:([^\]\|]+)\|)?([^\s\]]+)\]\]/,
        wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/,
        verbose => 0,
@@ -42,6 +43,7 @@ sub defaultconfig () { #{{{
        diffurl => '',
        anonok => 0,
        rss => 0,
+       atom => 0,
        discussion => 1,
        rebuild => 0,
        refresh => 0,
@@ -90,8 +92,8 @@ sub checkconfig () { #{{{
        if ($config{cgi} && ! length $config{url}) {
                error("Must specify url to wiki with --url when using --cgi\n");
        }
-       if ($config{rss} && ! length $config{url}) {
-               error("Must specify url to wiki with --url when using --rss\n");
+       if (($config{rss} || $config{atom}) && ! length $config{url}) {
+               error("Must specify url to wiki with --url when using --rss or --atom\n");
        }
        
        $config{wikistatedir}="$config{srcdir}/.ikiwiki"
@@ -262,6 +264,7 @@ sub writefile ($$$;$) { #{{{
        close OUT;
 } #}}}
 
+my %cleared;
 sub will_render ($$;$) { #{{{
        my $page=shift;
        my $dest=shift;
@@ -273,11 +276,12 @@ sub will_render ($$;$) { #{{{
                error("$config{destdir}/$dest independently created, not overwriting with version from $page");
        }
 
-       if (! $clear) {
+       if (! $clear || $cleared{$page}) {
                $renderedfiles{$page}=[$dest, grep { $_ ne $dest } @{$renderedfiles{$page}}];
        }
        else {
                $renderedfiles{$page}=[$dest];
+               $cleared{$page}=1;
        }
 } #}}}
 
@@ -442,10 +446,11 @@ sub linkify ($$$) { #{{{
 } #}}}
 
 my %preprocessing;
-sub preprocess ($$$) { #{{{
+sub preprocess ($$$;$) { #{{{
        my $page=shift; # the page the data comes from
        my $destpage=shift; # the page the data will appear in (different for inline)
        my $content=shift;
+       my $scan=shift;
 
        my $handle=sub {
                my $escape=shift;
@@ -455,6 +460,7 @@ sub preprocess ($$$) { #{{{
                        return "[[$command $params]]";
                }
                elsif (exists $hooks{preprocess}{$command}) {
+                       return "" if $scan && ! $hooks{preprocess}{$command}{scan};
                        # Note: preserve order of params, some plugins may
                        # consider it significant.
                        my @params;
@@ -503,7 +509,7 @@ sub preprocess ($$$) { #{{{
        return $content;
 } #}}}
 
-sub filter ($$) {
+sub filter ($$) { #{{{
        my $page=shift;
        my $content=shift;
 
@@ -512,7 +518,7 @@ sub filter ($$) {
        });
 
        return $content;
-}
+} #}}}
 
 sub indexlink () { #{{{
        return "<a href=\"$config{url}\">$config{wikiname}</a>";
@@ -587,7 +593,8 @@ sub saveindex () { #{{{
                        "ctime=$pagectime{$page} ".
                        "src=$pagesources{$page}";
                $line.=" dest=$_" foreach @{$renderedfiles{$page}};
-               $line.=" link=$_" foreach @{$links{$page}};
+               my %count;
+               $line.=" link=$_" foreach grep { ++$count{$_} == 1 } @{$links{$page}};
                if (exists $depends{$page}) {
                        $line.=" depends=".encode_entities($depends{$page}, " \t\n");
                }
@@ -639,6 +646,8 @@ sub hook (@) { # {{{
        if (! exists $param{type} || ! ref $param{call} || ! exists $param{id}) {
                error "hook requires type, call, and id parameters";
        }
+
+       return if $param{no_override} && exists $hooks{$param{type}}{$param{id}};
        
        $hooks{$param{type}}{$param{id}}=\%param;
 } # }}}