]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki.pm
po: better rootpage logic for inline's post form
[git.ikiwiki.info.git] / IkiWiki.pm
index a11b330f2126a038f69678512e1a1ba2f2c238fb..5563a03af7d028a88c184d8f2ac227284c475f52 100644 (file)
@@ -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 {
@@ -1499,8 +1515,13 @@ sub loadindex () {
                                $links{$page}=$d->{links};
                                $oldlinks{$page}=[@{$d->{links}}];
                        }
-                       if (exists $d->{depends}) {
-                               $depends{$page}=$d->{depends};
+                       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 +1567,7 @@ sub saveindex () {
                };
 
                if (exists $depends{$page}) {
-                       $index{page}{$src}{depends} = $depends{$page};
+                       $index{page}{$src}{dependslist} = [ keys %{$depends{$page}} ];
                }
 
                if (exists $pagestate{$page}) {
@@ -1716,16 +1737,10 @@ 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);
-       }
+       return unless pagespec_valid($pagespec);
 
+       $depends{$page}{$pagespec} = 1;
        return 1;
 }
 
@@ -1809,14 +1824,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 +2055,7 @@ sub match_created_before ($$;@) {
                }
        }
        else {
-               return IkiWiki::FailReason->new("$testpage has no ctime");
+               return IkiWiki::ErrorReason->new("$testpage does not exist");
        }
 }
 
@@ -2068,7 +2075,7 @@ sub match_created_after ($$;@) {
                }
        }
        else {
-               return IkiWiki::FailReason->new("$testpage has no ctime");
+               return IkiWiki::ErrorReason->new("$testpage does not exist");
        }
 }