fixes, and make dir optional

master
joey 2006-07-30 05:14:35 +00:00
parent e49ff966a3
commit c5b02885e9
3 changed files with 12 additions and 9 deletions

View File

@ -53,7 +53,7 @@ sub filter (@) { #{{{
sub preprocess (@) { #{{{
my %params=@_;
foreach my $required (qw{name url dir}) {
foreach my $required (qw{name url}) {
if (! exists $params{$required}) {
return "[[aggregate plugin missing $required parameter]]";
}
@ -70,10 +70,12 @@ sub preprocess (@) { #{{{
$feed->{name}=$name;
$feed->{sourcepage}=$params{page};
$feed->{url}=$params{url};
($feed->{dir})=$params{dir}=~/$IkiWiki::config{wiki_file_regexp}/;
$feed->{dir}=~s/^\/+//;
my $dir=exists $params{dir} ? $params{dir} : IkiWiki::titlepage($params{name});
$dir=~s/^\/+//;
($dir)=$dir=~/$IkiWiki::config{wiki_file_regexp}/;
$feed->{dir}=$dir;
$feed->{feedurl}=defined $params{feedurl} ? $params{feedurl} : $params{url};
$feed->{updateinterval}=defined $params{updateinterval} ? $params{updateinterval} : 15;
$feed->{updateinterval}=defined $params{updateinterval} ? $params{updateinterval} * 60 : 15 * 60;
$feed->{expireage}=defined $params{expireage} ? $params{expireage} : 0;
$feed->{expirecount}=defined $params{expirecount} ? $params{expirecount} : 0;
delete $feed->{remove};
@ -179,7 +181,7 @@ sub aggregate () { #{{{
die $@ if $@;
FEED: foreach my $feed (values %feeds) {
# TODO: check updateinterval
next unless time - $feed->{lastupdate} >= $feed->{updateinterval};
$feed->{lastupdate}=time;
$feed->{newposts}=0;
$IkiWiki::forcerebuild{$feed->{sourcepage}}=1;
@ -269,7 +271,7 @@ sub add_page (@) { #{{{
$template->param(name => $feed->{name});
$template->param(link => $params{link}) if defined $params{link};
if (ref $feed->{tags}) {
$template->param(tags => map { tag => $_ }, @{$feed->{tags}});
$template->param(tags => [map { tag => $_ }, @{$feed->{tags}}]);
}
IkiWiki::writefile($guid->{page}.".html", $IkiWiki::config{srcdir},
$template->output);

View File

@ -1,7 +1,7 @@
This plugin allows content from other blogs to be aggregated into the wiki.
Aggregate a blog as follows:
\[[aggregate name="example blog" feedurl="http://example.com/index.rss" url="http://example.com/" updateinterval="15" dir="example"]
\[[aggregate name="example blog" feedurl="http://example.com/index.rss" url="http://example.com/" updateinterval="15"]
That example aggregates posts from the expecified RSS feed, updating no
more frequently than once every 15 minutes, and puts a page per post under
@ -30,7 +30,8 @@ directive:
Required.
* `url` - The url to the web page for the blog that's being aggregated.
Required.
* `dir` - The directory in the wiki where pages should be saved. Required.
* `dir` - The directory in the wiki where pages should be saved. Optional,
if not specified, the directory is based on the name of the feed.
* `feedurl` - The url to the feed. Optional, if it's not specified ikiwiki
will look for feeds on the `blogurl`. RSS and atom feeds are supported.
* `updateinterval` - How often to check for new posts, in minutes. Default

View File

@ -9,5 +9,5 @@ From <a href="<TMPL_VAR URL>"><TMPL_VAR NAME></a>
</i>
</p>
<TMPL_LOOP NAME="TAGS">
[[<TMPL_VAR TAG>]]
[[tag <TMPL_VAR TAG>]]
</TMPL_LOOP>