* Put categories in rss feeds for tagged items.
parent
a0653933d3
commit
267f98e2e1
|
@ -152,7 +152,8 @@ sub genrss ($@) { #{{{
|
||||||
|
|
||||||
my $url="$config{url}/".htmlpage($page);
|
my $url="$config{url}/".htmlpage($page);
|
||||||
|
|
||||||
my $template=template("rsspage.tmpl", blind_cache => 1);
|
my $template=template("rsspage.tmpl", blind_cache => 1,
|
||||||
|
die_on_bad_params => 0);
|
||||||
|
|
||||||
my @items;
|
my @items;
|
||||||
foreach my $p (@pages) {
|
foreach my $p (@pages) {
|
||||||
|
@ -161,6 +162,7 @@ sub genrss ($@) { #{{{
|
||||||
itemurl => "$config{url}/$renderedfiles{$p}",
|
itemurl => "$config{url}/$renderedfiles{$p}",
|
||||||
itempubdate => date_822($pagectime{$p}),
|
itempubdate => date_822($pagectime{$p}),
|
||||||
itemcontent => absolute_urls(get_inline_content($p, $page), $url),
|
itemcontent => absolute_urls(get_inline_content($p, $page), $url),
|
||||||
|
page => $p, # used by category adding code in tag plugin
|
||||||
} if exists $renderedfiles{$p};
|
} if exists $renderedfiles{$p};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +172,14 @@ sub genrss ($@) { #{{{
|
||||||
items => \@items,
|
items => \@items,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foreach my $id (keys %{$hooks{pagetemplate}}) {
|
||||||
|
$hooks{pagetemplate}{$id}{call}->(
|
||||||
|
page => $page,
|
||||||
|
destpage => $page,
|
||||||
|
template => $template,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $template->output;
|
return $template->output;
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,17 @@ sub getopt () { #{{{
|
||||||
GetOptions("tagbase=s" => \$IkiWiki::config{tagbase});
|
GetOptions("tagbase=s" => \$IkiWiki::config{tagbase});
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
|
sub tagpage ($) { #{{{
|
||||||
|
my $tag=shift;
|
||||||
|
|
||||||
|
if (exists $IkiWiki::config{tagbase} &&
|
||||||
|
defined $IkiWiki::config{tagbase}) {
|
||||||
|
$tag=$IkiWiki::config{tagbase}."/".$tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
} #}}}
|
||||||
|
|
||||||
sub preprocess (@) { #{{{
|
sub preprocess (@) { #{{{
|
||||||
if (! @_) {
|
if (! @_) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -34,13 +45,9 @@ sub preprocess (@) { #{{{
|
||||||
|
|
||||||
$tags{$page} = [];
|
$tags{$page} = [];
|
||||||
foreach my $tag (keys %params) {
|
foreach my $tag (keys %params) {
|
||||||
if (exists $IkiWiki::config{tagbase} &&
|
|
||||||
defined $IkiWiki::config{tagbase}) {
|
|
||||||
$tag=$IkiWiki::config{tagbase}."/".$tag;
|
|
||||||
}
|
|
||||||
push @{$tags{$page}}, $tag;
|
push @{$tags{$page}}, $tag;
|
||||||
# hidden WikiLink
|
# hidden WikiLink
|
||||||
push @{$IkiWiki::links{$page}}, $tag;
|
push @{$IkiWiki::links{$page}}, tagpage($tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -53,9 +60,26 @@ sub pagetemplate (@) { #{{{
|
||||||
my $template=$params{template};
|
my $template=$params{template};
|
||||||
|
|
||||||
$template->param(tags => [
|
$template->param(tags => [
|
||||||
map { link => IkiWiki::htmllink($page, $destpage, $_) },
|
map {
|
||||||
@{$tags{$page}}
|
link => IkiWiki::htmllink($page, $destpage, tagpage($_))
|
||||||
|
}, @{$tags{$page}}
|
||||||
]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags");
|
]) if exists $tags{$page} && @{$tags{$page}} && $template->query(name => "tags");
|
||||||
|
|
||||||
|
if ($template->query(name => "items")) {
|
||||||
|
# It's an rss template. Modify each item in the feed,
|
||||||
|
# adding any categories based on the page for that item.
|
||||||
|
foreach my $item (@{$template->param("items")}) {
|
||||||
|
my $p=$item->{page};
|
||||||
|
if (exists $tags{$p} && @{$tags{$p}}) {
|
||||||
|
$item->{categories}=[];
|
||||||
|
foreach my $tag (@{$tags{$p}}) {
|
||||||
|
push @{$item->{categories}}, {
|
||||||
|
category => $tag,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} # }}}
|
} # }}}
|
||||||
|
|
||||||
1
|
1
|
||||||
|
|
|
@ -3,8 +3,9 @@ ikiwiki (1.12) UNRELEASED; urgency=low
|
||||||
* Add getopt hook type, this allows plugins to add new command-line options.
|
* Add getopt hook type, this allows plugins to add new command-line options.
|
||||||
* Add --tagbase option to tag plugin.
|
* Add --tagbase option to tag plugin.
|
||||||
* Add exclude option in setup files, works same as --exclude.
|
* Add exclude option in setup files, works same as --exclude.
|
||||||
|
* Put categories in rss feeds for tagged items.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Fri, 28 Jul 2006 13:47:34 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 29 Jul 2006 02:58:23 -0400
|
||||||
|
|
||||||
ikiwiki (1.11) unstable; urgency=low
|
ikiwiki (1.11) unstable; urgency=low
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,9 @@ Some of ikiwiki's features:
|
||||||
|
|
||||||
* [[tags]]
|
* [[tags]]
|
||||||
|
|
||||||
You can tag pages and use these tags in various ways.
|
You can tag pages and use these tags in various ways. Tags will show
|
||||||
|
up in the ways you'd expect, like at the bottom of pages, in blogs, and
|
||||||
|
in rss feeds.
|
||||||
|
|
||||||
* Fast compiler
|
* Fast compiler
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@ This plugin allows tagging pages. List tags as follows:
|
||||||
|
|
||||||
The tags work the same as if you had put a (hidden) [[WikiLink]] on the page
|
The tags work the same as if you had put a (hidden) [[WikiLink]] on the page
|
||||||
for each tag, so you can use a [[GlobList]] to link to all pages that are
|
for each tag, so you can use a [[GlobList]] to link to all pages that are
|
||||||
tagged with a given tag, for example.
|
tagged with a given tag, for example. The tags will also show up on blog
|
||||||
|
entries and at the bottom of the tagged pages, as well as in rss feeds.
|
||||||
|
|
||||||
This plugin has a configuration option. Set --tagbase=tag and all tags will
|
This plugin has a configuration option. Set --tagbase=tag and all tags will
|
||||||
be located inside a "tag" subdirectory, so in the above example, the tags
|
be located inside a "tag" subdirectory, This is a useful way to avoid having
|
||||||
are really set to tag/tech, tag/life, and tag/linux. This is a useful way
|
to write the full path to tags, if you want to keep them grouped together out
|
||||||
to avoid having to write the full path to tags, if you want to keep them
|
of the way.
|
||||||
grouped together out of the way.
|
|
||||||
|
|
||||||
This plugin is included in ikiwiki, but is not enabled by default. If it is
|
This plugin is included in ikiwiki, but is not enabled by default. If it is
|
||||||
enabled, you'll see a note below that this page is tagged with the "tags"
|
enabled, you'll see a note below that this page is tagged with the "tags"
|
||||||
|
|
|
@ -107,12 +107,13 @@ languages to ikiwiki.
|
||||||
|
|
||||||
IkiWiki::hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
|
IkiWiki::hook(type => "pagetemplate", id => "foo", call => \&pagetemplate);
|
||||||
|
|
||||||
Each time a page is rendered, a [[template|templates]] is filled out.
|
Each time a page (or part of a blog page, or an rss feed) is rendered, a
|
||||||
This hook allows modifying that template. The function is passed named
|
[[template|templates]] is filled out. This hook allows modifying that
|
||||||
parameters. The "page" and "destpage" parameters are the same as for a
|
template. The function is passed named parameters. The "page" and
|
||||||
preprocess hook. The "template" parameter is a `HTML::Template` object that
|
"destpage" parameters are the same as for a preprocess hook. The "template"
|
||||||
is the template that will be used to generate the page. The function
|
parameter is a `HTML::Template` object that is the template that will be
|
||||||
can manipulate that template object.
|
used to generate the page. The function can manipulate that template
|
||||||
|
object.
|
||||||
|
|
||||||
The most common thing to do is probably to call $template->param() to add
|
The most common thing to do is probably to call $template->param() to add
|
||||||
a new custom parameter to the template. Note that in order to be robust,
|
a new custom parameter to the template. Note that in order to be robust,
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
Stuff still needing to be done with tags:
|
Stuff still needing to be done with tags:
|
||||||
|
|
||||||
* Move the pages they link to into an automatic tag/ namespace?
|
* It's unfortunate that the rss category (tag) support doesn't include
|
||||||
* Include tag info in the RSS feed.
|
a domain="" attribute in the category elements. That would let readers
|
||||||
* Technorati tag support?
|
know how to follow back to the tag page in the wiki. However, the domain
|
||||||
|
attribute is specified to be the base url, to which the category is just
|
||||||
|
appended. So there's no way to add ".html", so the url won't be right.
|
||||||
|
|
||||||
|
This is one good argument for changing ikiwiki so that pages are all
|
||||||
|
dir/index.html, then a link to just "dir" works.
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
<TMPL_LOOP NAME="ITEMS">
|
<TMPL_LOOP NAME="ITEMS">
|
||||||
<item>
|
<item>
|
||||||
<title><TMPL_VAR ITEMTITLE ESCAPE=HTML></title>
|
<title><TMPL_VAR ITEMTITLE ESCAPE=HTML></title>
|
||||||
<TMPL_IF NAME="ITEMGUID">
|
|
||||||
<guid isPermaLink="false"><TMPL_VAR ITEMGUID></guid>
|
|
||||||
<TMPL_ELSE>
|
|
||||||
<guid><TMPL_VAR ITEMURL></guid>
|
<guid><TMPL_VAR ITEMURL></guid>
|
||||||
</TMPL_IF>
|
|
||||||
<link><TMPL_VAR ITEMURL></link>
|
<link><TMPL_VAR ITEMURL></link>
|
||||||
|
<TMPL_IF NAME="CATEGORIES">
|
||||||
|
<TMPL_LOOP NAME="CATEGORIES">
|
||||||
|
<category><TMPL_VAR NAME=CATEGORY></category>
|
||||||
|
</TMPL_LOOP>
|
||||||
|
</TMPL_IF>
|
||||||
<pubDate><TMPL_VAR ITEMPUBDATE></pubDate>
|
<pubDate><TMPL_VAR ITEMPUBDATE></pubDate>
|
||||||
<description><![CDATA[<TMPL_VAR ITEMCONTENT>]]></description>
|
<description><![CDATA[<TMPL_VAR ITEMCONTENT>]]></description>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue