diff options
author | Amitai Schlair <schmonz@magnetic-babysitter.(none)> | 2009-08-30 03:02:15 -0400 |
---|---|---|
committer | Amitai Schlair <schmonz@magnetic-babysitter.(none)> | 2009-08-30 03:02:15 -0400 |
commit | c36d2fa896e9ea42c0b6b0135ba04b4f4f60950f (patch) | |
tree | 22f1314d8e974c73bde4970c97d497628f2a1465 /IkiWiki.pm | |
parent | 5e94e973eeb4ba75d9c37bd801278f686f0977c3 (diff) | |
parent | 517432273b96fc9e6bad9b7667ef6d1b04c699ee (diff) | |
download | ikiwiki-c36d2fa896e9ea42c0b6b0135ba04b4f4f60950f.tar ikiwiki-c36d2fa896e9ea42c0b6b0135ba04b4f4f60950f.tar.gz |
Merge branch 'master' of git://github.com/joeyh/ikiwiki
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r-- | IkiWiki.pm | 74 |
1 files changed, 49 insertions, 25 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 2355c0780..453bc9f8c 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -13,8 +13,8 @@ use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %pagestate %wikistate %renderedfiles %oldrenderedfiles - %pagesources %destsources %depends %hooks %forcerebuild - %loaded_plugins}; + %pagesources %destsources %depends %depends_simple %hooks + %forcerebuild %loaded_plugins}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match @@ -220,6 +220,13 @@ sub getsetup () { safe => 1, rebuild => 1, }, + discussionpage => { + type => "string", + default => gettext("Discussion"), + description => "name of Discussion pages", + safe => 1, + rebuild => 1, + }, sslcookie => { type => "boolean", default => 0, @@ -654,9 +661,15 @@ sub pagetype ($) { return; } +my %pagename_cache; + sub pagename ($) { my $file=shift; + if (exists $pagename_cache{$file}) { + return $pagename_cache{$file}; + } + my $type=pagetype($file); my $page=$file; $page=~s/\Q.$type\E*$// @@ -665,6 +678,8 @@ sub pagename ($) { if ($config{indexpages} && $page=~/(.*)\/index$/) { $page=$1; } + + $pagename_cache{$file} = $page; return $page; } @@ -1248,9 +1263,10 @@ sub preprocess ($$$;$$) { ); }; if ($@) { - chomp $@; + my $error=$@; + chomp $error; $ret="[[!$command <span class=\"error\">". - gettext("Error").": $@"."</span>]]"; + gettext("Error").": $error"."</span>]]"; } } else { @@ -1459,7 +1475,8 @@ sub loadindex () { %oldrenderedfiles=%pagectime=(); if (! $config{rebuild}) { %pagesources=%pagemtime=%oldlinks=%links=%depends= - %destsources=%renderedfiles=%pagecase=%pagestate=(); + %destsources=%renderedfiles=%pagecase=%pagestate= + %depends_simple=(); } my $in; if (! open ($in, "<", "$config{wikistatedir}/indexdb")) { @@ -1499,8 +1516,18 @@ sub loadindex () { $links{$page}=$d->{links}; $oldlinks{$page}=[@{$d->{links}}]; } - if (exists $d->{depends}) { - $depends{$page}=$d->{depends}; + if (exists $d->{depends_simple}) { + $depends_simple{$page}={ + map { $_ => 1 } @{$d->{depends_simple}} + }; + } + if (exists $d->{dependslist}) { + $depends{$page}={ + map { $_ => 1 } @{$d->{dependslist}} + }; + } + elsif (exists $d->{depends}) { + $depends{$page}={$d->{depends} => 1}; } if (exists $d->{state}) { $pagestate{$page}=$d->{state}; @@ -1546,7 +1573,11 @@ sub saveindex () { }; if (exists $depends{$page}) { - $index{page}{$src}{depends} = $depends{$page}; + $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ]; + } + + if (exists $depends_simple{$page}) { + $index{page}{$src}{depends_simple} = [ keys %{$depends_simple{$page}} ]; } if (exists $pagestate{$page}) { @@ -1716,16 +1747,17 @@ sub rcs_receive () { sub add_depends ($$) { my $page=shift; my $pagespec=shift; - - return unless pagespec_valid($pagespec); - if (! exists $depends{$page}) { - $depends{$page}=$pagespec; - } - else { - $depends{$page}=pagespec_merge($depends{$page}, $pagespec); + if ($pagespec =~ /$config{wiki_file_regexp}/ && + $pagespec !~ /[\s*?()!]/) { + # a simple dependency, which can be matched by string eq + $depends_simple{$page}{lc $pagespec} = 1; + return 1; } + return unless pagespec_valid($pagespec); + + $depends{$page}{$pagespec} = 1; return 1; } @@ -1809,14 +1841,6 @@ sub add_link ($$) { unless grep { $_ eq $link } @{$links{$page}}; } -sub pagespec_merge ($$) { - my $a=shift; - my $b=shift; - - return $a if $a eq $b; - return "($a) or ($b)"; -} - sub pagespec_translate ($) { my $spec=shift; @@ -2048,7 +2072,7 @@ sub match_created_before ($$;@) { } } else { - return IkiWiki::FailReason->new("$testpage has no ctime"); + return IkiWiki::ErrorReason->new("$testpage does not exist"); } } @@ -2068,7 +2092,7 @@ sub match_created_after ($$;@) { } } else { - return IkiWiki::FailReason->new("$testpage has no ctime"); + return IkiWiki::ErrorReason->new("$testpage does not exist"); } } |