]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/inline.pm
minor problem
[git.ikiwiki.info.git] / IkiWiki / Plugin / inline.pm
index 27ea1c4a64bf8ebca3be99755c86a08a2192cb65..3a2f4b7bc37caa0d52113ec30ddbcbc310314a82 100644 (file)
@@ -151,7 +151,7 @@ my %feedlinks;
 sub preprocess_inline (@) {
        my %params=@_;
        
-       if (! exists $params{pages}) {
+       if (! exists $params{pages} && ! exists $params{pagenames}) {
                error gettext("missing pages parameter");
        }
        my $raw=yesno($params{raw});
@@ -183,28 +183,45 @@ sub preprocess_inline (@) {
                $params{template} = $archive ? "archivepage" : "inlinepage";
        }
 
-       my @list=pagespec_match_list(
-               [ grep { $_ ne $params{page} } keys %pagesources ],
-               $params{pages}, location => $params{page});
+       my @list;
 
-       if (exists $params{sort} && $params{sort} eq 'title') {
-               @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
-       }
-       elsif (exists $params{sort} && $params{sort} eq 'title_natural') {
-               eval q{use Sort::Naturally};
-               if ($@) {
-                       error(gettext("Sort::Naturally needed for title_natural sort"));
+       if (exists $params{pagenames}) {
+               foreach my $p (qw(sort pages)) {
+                       if (exists $params{$p}) {
+                               error sprintf(gettext("the %s and %s parameters cannot be used together"),
+                                       "pagenames", $p);
+                       }
                }
-               @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @list;
-       }
-       elsif (exists $params{sort} && $params{sort} eq 'mtime') {
-               @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
-       }
-       elsif (! exists $params{sort} || $params{sort} eq 'age') {
-               @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
+
+               @list = map { bestlink($params{page}, $_) }
+                       split ' ', $params{pagenames};
+
+               $params{pages} = join(" or ", @list);
        }
        else {
-               error sprintf(gettext("unknown sort type %s"), $params{sort});
+               @list = pagespec_match_list(
+                       [ grep { $_ ne $params{page} } keys %pagesources ],
+                       $params{pages}, location => $params{page});
+
+               if (exists $params{sort} && $params{sort} eq 'title') {
+                       @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
+               }
+               elsif (exists $params{sort} && $params{sort} eq 'title_natural') {
+                       eval q{use Sort::Naturally};
+                       if ($@) {
+                               error(gettext("Sort::Naturally needed for title_natural sort"));
+                       }
+                       @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @list;
+               }
+               elsif (exists $params{sort} && $params{sort} eq 'mtime') {
+                       @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
+               }
+               elsif (! exists $params{sort} || $params{sort} eq 'age') {
+                       @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
+               }
+               else {
+                       error sprintf(gettext("unknown sort type %s"), $params{sort});
+               }
        }
 
        if (yesno($params{reverse})) {
@@ -237,7 +254,7 @@ sub preprocess_inline (@) {
        add_depends($params{page}, join(" or ", $#list >= $#feedlist ? @list : @feedlist));
        
        if ($feeds && exists $params{feedpages}) {
-               @feedlist=grep { pagespec_match($_, $params{feedpages}, location => $params{page}) } @feedlist;
+               @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page});
        }
 
        my ($feedbase, $feednum);
@@ -354,15 +371,14 @@ sub preprocess_inline (@) {
                                        my $file = $pagesources{$page};
                                        my $type = pagetype($file);
                                        if ($config{discussion}) {
-                                               my $discussionlink=gettext("discussion");
-                                               if ($page !~ /.*\/\Q$discussionlink\E$/ &&
+                                               if ($page !~ /.*\/\Q$config{discussionpage}\E$/ &&
                                                    (length $config{cgiurl} ||
-                                                    exists $links{$page."/".$discussionlink})) {
+                                                    exists $links{$page."/".$config{discussionpage}})) {
                                                        $template->param(have_actions => 1);
                                                        $template->param(discussionlink =>
                                                                htmllink($page,
                                                                        $params{destpage},
-                                                                       gettext("Discussion"),
+                                                                       $config{discussionpage},
                                                                        noimageinline => 1,
                                                                        forcesubpage => 1));
                                                }