summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/inline.pm
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin/inline.pm')
-rw-r--r--IkiWiki/Plugin/inline.pm57
1 files changed, 24 insertions, 33 deletions
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index ccfadfd69..748e02df4 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -195,41 +195,38 @@ sub preprocess_inline (@) {
@list = map { bestlink($params{page}, $_) }
split ' ', $params{pagenames};
- }
- else {
- add_depends($params{page}, $params{pages});
- @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;
+ if (yesno($params{reverse})) {
+ @list=reverse(@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;
+
+ foreach my $p (@list) {
+ add_depends($params{page}, $p, deptype($quick ? "presence" : "content"));
}
- elsif (exists $params{sort} && $params{sort} eq 'mtime') {
- @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
+ }
+ else {
+ my $num=0;
+ if ($params{show}) {
+ $num=$params{show};
}
- elsif (! exists $params{sort} || $params{sort} eq 'age') {
- @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
+ if ($params{feedshow} && $num < $params{feedshow}) {
+ $num=$params{feedshow};
}
- else {
- error sprintf(gettext("unknown sort type %s"), $params{sort});
+ if ($params{skip}) {
+ $num+=$params{skip};
}
- }
- if (yesno($params{reverse})) {
- @list=reverse(@list);
+ @list = use_pagespec($params{page}, $params{pages},
+ deptype => deptype($quick ? "presence" : "content"),
+ limit => sub { $_[0] ne $params{page} },
+ sort => exists $params{sort} ? $params{sort} : "age",
+ reverse => yesno($params{reverse}),
+ num => $num,
+ );
}
if (exists $params{skip}) {
- @list=@list[$params{skip} .. scalar @list - 1];
+ @list=@list[$params{skip} .. $#list];
}
my @feedlist;
@@ -247,15 +244,9 @@ sub preprocess_inline (@) {
@list=@list[0..$params{show} - 1];
}
- # Explicitly add all currently displayed pages as dependencies, so
- # that if they are removed or otherwise changed, the inline will be
- # sure to be updated.
- foreach my $p ($#list >= $#feedlist ? @list : @feedlist) {
- add_depends($params{page}, $p);
- }
-
if ($feeds && exists $params{feedpages}) {
- @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page});
+ @feedlist = use_pagespec($params{page}, $params{feedpages},
+ list => \@feedlist);
}
my ($feedbase, $feednum);