hook(type => "checkconfig", id => "inline", call => \&checkconfig);
hook(type => "sessioncgi", id => "inline", call => \&sessioncgi);
hook(type => "preprocess", id => "inline",
- call => \&IkiWiki::preprocess_inline);
+ call => \&IkiWiki::preprocess_inline, scan => 1);
hook(type => "pagetemplate", id => "inline",
call => \&IkiWiki::pagetemplate_inline);
hook(type => "format", id => "inline", call => \&format, first => 1);
if (! exists $params{pages} && ! exists $params{pagenames}) {
error gettext("missing pages parameter");
}
+
+ if (! defined wantarray) {
+ # Running in scan mode: only do the essentials
+
+ if (yesno($params{trail}) && IkiWiki::Plugin::trail->can("preprocess_trailitems")) {
+ # default to sorting age, the same as inline itself,
+ # but let the params override that
+ IkiWiki::Plugin::trail::preprocess_trailitems(sort => 'age', %params);
+ }
+
+ return;
+ }
+
+ if (yesno($params{trail}) && IkiWiki::Plugin::trail->can("preprocess_trailitems")) {
+ scalar IkiWiki::Plugin::trail::preprocess_trailitems(sort => 'age', %params);
+ }
+
my $raw=yesno($params{raw});
my $archive=yesno($params{archive});
my $rss=(($config{rss} || $config{allowrss}) && exists $params{rss}) ? yesno($params{rss}) : $config{rss};
#!/usr/bin/perl
# Copyright © 2008-2011 Joey Hess
-# Copyright © 2009-2011 Simon McVittie <http://smcv.pseudorandom.co.uk/>
+# Copyright © 2009-2012 Simon McVittie <http://smcv.pseudorandom.co.uk/>
# Licensed under the GNU GPL, version 2, or any later version published by the
# Free Software Foundation
package IkiWiki::Plugin::trail;
hook(type => "getsetup", id => "trail", call => \&getsetup);
hook(type => "needsbuild", id => "trail", call => \&needsbuild);
hook(type => "preprocess", id => "trailoptions", call => \&preprocess_trailoptions, scan => 1);
- hook(type => "preprocess", id => "trailinline", call => \&preprocess_trailinline, scan => 1);
hook(type => "preprocess", id => "trailitem", call => \&preprocess_trailitem, scan => 1);
hook(type => "preprocess", id => "trailitems", call => \&preprocess_trailitems, scan => 1);
hook(type => "preprocess", id => "traillink", call => \&preprocess_traillink, scan => 1);
return "";
}
-sub preprocess_trailinline (@) {
- my %params = @_;
-
- if (! exists $params{sort}) {
- # sort in the same order as [[plugins/inline]]'s default
- $params{sort} = 'age';
- }
-
- if (defined wantarray) {
- scalar preprocess_trailitems(%params);
-
- if (IkiWiki->can("preprocess_inline")) {
- return IkiWiki::preprocess_inline(@_);
- }
- else {
- error("trailinline directive requires the inline plugin");
- }
- }
- else {
- preprocess_trailitems(%params);
- }
-}
-
sub preprocess_trailitem (@) {
my $link = shift;
shift;
Here is a full list of posts to the [[blog|index]].
-[[!trailinline pages="page(./posts/*) and !*/Discussion" archive=yes feedshow=10 quick=yes]]
+[[!inline pages="page(./posts/*) and !*/Discussion" archive=yes feedshow=10 quick=yes trail=yes]]
[[SubPage/LinkingRules]] as in a [[ikiwiki/WikiLink]]), and they are inlined
in exactly the order given: the `sort` and `pages` parameters cannot be used
in conjunction with this one.
+* `trail` - If the [[!iki plugins/trail desc=trail]] plugin is enabled, turn
+ the inlined pages into a trail with next/previous links, by passing the same
+ options to [[ikiwiki/directive/trailitems]]. The `skip` and `show` options
+ are ignored by the trail, so the next/previous links traverse through
+ all matching pages.
[[!meta robots="noindex, follow"]]
+++ /dev/null
-The `trailinline` directive is provided by the
-[[!iki plugins/trail desc=trail]]
-plugin. It is equivalent to combining [[ikiwiki/directive/trailitems]] and
-[[ikiwiki/directive/inline]] directives with the same options.
-
-A typical use is to navigate through all posts in a blog:
-
- \[[!trailinline pages="page(./posts/*) and !*/Discussion" archive=yes
- feedshow=10 quick=yes]]
-
-[[!meta robots="noindex, follow"]]
This plugin provides the [[ikiwiki/directive/trailoptions]],
[[ikiwiki/directive/traillink]], [[ikiwiki/directive/trailitem]],
-[[ikiwiki/directive/trailitems]]
-and [[ikiwiki/directive/trailinline]] [[directives|ikiwiki/directive]].
+and [[ikiwiki/directive/trailitems]] [[directives|ikiwiki/directive]].
It's sometimes useful to have "trails" of pages in a wiki where each
page links to the next and/or previous page. For instance, you could use
Pages can be included in a trail in various ways:
-* The [[ikiwiki/directive/trailinline]] directive sets up an [[inline]],
- and at the same time adds the matching pages (from `pages` or `pagenames`)
- to the trail. One use is to navigate through all posts in a blog:
+* The [[ikiwiki/directive/inline]] directive with `trail="yes"` sets up an
+ [[inline]], and at the same time adds the matching pages (from `pages` or
+ `pagenames`) to the trail. One use is to navigate through all posts in
+ a blog:
- \[[!trailinline pages="page(./posts/*) and !*/Discussion" archive=yes
- feedshow=10 quick=yes]]
+ \[[!inline pages="page(./posts/*) and !*/Discussion" archive=yes
+ feedshow=10 quick=yes trail=yes]]
- This directive only works if the [[!iki plugins/inline desc=inline]]
- plugin is also enabled.
+ This only works if the trail and [[!iki plugins/inline desc=inline]]
+ plugins are both enabled.
* The [[ikiwiki/directive/trailitems]] directive has optional `pages` and
`pagenames` options which behave the same as in [[inline]], but don't
ok(utime(222222222, 222222222, "t/tmp/in/sorting/old.mdwn"));
ok(utime(111111111, 111111111, "t/tmp/in/sorting/ancient.mdwn"));
writefile("sorting/linked2.mdwn", "t/tmp/in", "linked2");
-# This initially uses the default sort order: age for trailinline, and path
-# for trail. We change it later.
+# This initially uses the default sort order: age for the inline, and path
+# for trailitems. We change it later.
writefile("sorting.mdwn", "t/tmp/in",
'[[!traillink linked]] ' .
'[[!trailitems pages="sorting/z/a or sorting/a/b or sorting/a/c"]] ' .
'[[!trailitems pagenames="beginning middle end"]] ' .
- '[[!trailinline pages="sorting/old or sorting/ancient or sorting/new"]] ' .
+ '[[!inline pages="sorting/old or sorting/ancient or sorting/new" trail="yes"]] ' .
'[[!traillink linked2]]');
writefile("meme.mdwn", "t/tmp/in", <<EOF