1 Here's an idea with [[patch]] for extending inline in two directions:
3 1. Permit the content-fetching function to return undef to skip a page. The limiting of @list to a set size is performed after that filtering.
4 2. Permit other directive plugins to pass a function to generate content via an inliner_ parameter. The current patch doesn't try to remove that key from the parameters, so hilarity might ensue if someone is too clever. I suppose I should fix that... My *intent* is that other, custom directives can add inliner_.
6 The diff looks large because the first requires switching some loops.
8 I'm using this along with a custom BibTeX formatter (one item per file) to generate larger pages and tiny listings. I still need to hammer the templates for that, but I think that's possible without further patches.
10 (Setting up a git branch for a single plugin is a pain, but I can if necessary. I also could separate this into some sequence rather than all at once, but I won't have time for a week or two.)
15 --- /home/ejr/src/git.ikiwiki.info/IkiWiki/Plugin/inline.pm 2011-03-05 14:18:30.261293808 -0500
16 +++ inline.pm 2011-03-06 21:44:18.887903638 -0500
23 if (exists $params{pagenames}) {
24 foreach my $p (qw(sort pages)) {
25 @@ -213,23 +214,121 @@
26 if ($params{feedshow} && $num < $params{feedshow} && $num > 0) {
27 $num=$params{feedshow};
29 - if ($params{skip} && $num) {
30 - $num+=$params{skip};
33 @list = pagespec_match_list($params{page}, $params{pages},
34 deptype => deptype($quick ? "presence" : "content"),
35 filter => sub { $_[0] eq $params{page} },
36 sort => exists $params{sort} ? $params{sort} : "age",
37 reverse => yesno($params{reverse}),
38 - ($num ? (num => $num) : ()),
42 if (exists $params{skip}) {
43 @list=@list[$params{skip} .. $#list];
46 + if ($params{show} && $params{show} > $num) {
47 + $num = $params{show}
57 + # cannot use wiki pages as templates; template not sanitized due to
60 + $template=template_depends($params{template}.".tmpl", $params{page},
64 + error sprintf(gettext("failed to process template %s"), $params{template}.".tmpl").": $@";
67 + my $needcontent=$raw || (!($archive && $quick) && $template->query(name => 'content'));
69 + foreach my $page (@list) {
70 + last if ($num && scalar @displist >= $num);
71 + my $file = $pagesources{$page};
72 + my $type = pagetype($file);
74 + # Get the content before populating the
75 + # template, since getting the content uses
76 + # the same template if inlines are nested.
79 + if (exists $params{inliner_} && defined $params{inliner_}) {
80 + $content = &{$params{inliner_}}($page, $template, %params);
82 + $content=get_inline_content($page, $params{destpage});
84 + next if !defined $content;
85 + $template->param(content => $content);
86 + push @displist, $page;
88 + $template->param(pageurl => urlto($page, $params{destpage}));
89 + $template->param(inlinepage => $page);
90 + $template->param(title => pagetitle(basename($page)));
91 + $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}, 1));
92 + $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
93 + $template->param(first => 1) if $page eq $list[0];
94 + $template->param(last => 1) if ($num && scalar @displist == $num);
95 + $template->param(html5 => $config{html5});
98 + my $file = $pagesources{$page};
99 + my $type = pagetype($file);
100 + if ($config{discussion}) {
101 + if ($page !~ /.*\/\Q$config{discussionpage}\E$/i &&
102 + (length $config{cgiurl} ||
103 + exists $pagesources{$page."/".lc($config{discussionpage})})) {
104 + $template->param(have_actions => 1);
105 + $template->param(discussionlink =>
108 + $config{discussionpage},
109 + noimageinline => 1,
110 + forcesubpage => 1));
113 + if (length $config{cgiurl} &&
115 + IkiWiki->can("cgi_editpage")) {
116 + $template->param(have_actions => 1);
117 + $template->param(editurl => cgiurl(do => "edit", page => $page));
122 + run_hooks(pagetemplate => sub {
123 + shift->(page => $page, destpage => $params{destpage},
124 + template => $template,);
127 + $ret.=$template->output;
128 + $template->clear_params;
131 + if (defined $type) {
133 + linkify($page, $params{destpage},
134 + preprocess($page, $params{destpage},
135 + filter($page, $params{destpage},
136 + readfile(srcfile($file)))));
140 + readfile(srcfile($file));
142 + push @displist, $page;
150 if (exists $params{feedshow} &&
155 - if ($params{show} && @list > $params{show}) {
156 - @list=@list[0..$params{show} - 1];
159 if ($feeds && exists $params{feedpages}) {
160 @feedlist = pagespec_match_list(
161 $params{page}, "($params{pages}) and ($params{feedpages})",
168 if (length $config{cgiurl} && ! $params{preview} && (exists $params{rootpage} ||
169 (exists $params{postform} && yesno($params{postform}))) &&
170 IkiWiki->can("cgi_editpage")) {
173 $ret.=$linktemplate->output;
179 - # cannot use wiki pages as templates; template not sanitized due to
182 - $template=template_depends($params{template}.".tmpl", $params{page},
186 - error sprintf(gettext("failed to process template %s"), $params{template}.".tmpl").": $@";
189 - my $needcontent=$raw || (!($archive && $quick) && $template->query(name => 'content'));
191 - foreach my $page (@list) {
192 - my $file = $pagesources{$page};
193 - my $type = pagetype($file);
195 - if ($needcontent) {
196 - # Get the content before populating the
197 - # template, since getting the content uses
198 - # the same template if inlines are nested.
199 - my $content=get_inline_content($page, $params{destpage});
200 - $template->param(content => $content);
202 - $template->param(pageurl => urlto($page, $params{destpage}));
203 - $template->param(inlinepage => $page);
204 - $template->param(title => pagetitle(basename($page)));
205 - $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}, 1));
206 - $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
207 - $template->param(first => 1) if $page eq $list[0];
208 - $template->param(last => 1) if $page eq $list[$#list];
209 - $template->param(html5 => $config{html5});
212 - my $file = $pagesources{$page};
213 - my $type = pagetype($file);
214 - if ($config{discussion}) {
215 - if ($page !~ /.*\/\Q$config{discussionpage}\E$/i &&
216 - (length $config{cgiurl} ||
217 - exists $pagesources{$page."/".lc($config{discussionpage})})) {
218 - $template->param(have_actions => 1);
219 - $template->param(discussionlink =>
222 - $config{discussionpage},
223 - noimageinline => 1,
224 - forcesubpage => 1));
227 - if (length $config{cgiurl} &&
229 - IkiWiki->can("cgi_editpage")) {
230 - $template->param(have_actions => 1);
231 - $template->param(editurl => cgiurl(do => "edit", page => $page));
236 - run_hooks(pagetemplate => sub {
237 - shift->(page => $page, destpage => $params{destpage},
238 - template => $template,);
241 - $ret.=$template->output;
242 - $template->clear_params;
245 - if (defined $type) {
247 - linkify($page, $params{destpage},
248 - preprocess($page, $params{destpage},
249 - filter($page, $params{destpage},
250 - readfile(srcfile($file)))));
254 - readfile(srcfile($file));
260 if ($feeds && ($emptyfeeds || @feedlist)) {
262 my $rssp=$feedbase."rss".$feednum;