use warnings;
use strict;
use Encode;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
use URI;
my %knownfeeds;
my @inline;
my $nested=0;
-sub import { #{{{
+sub import {
hook(type => "getopt", id => "inline", call => \&getopt);
hook(type => "getsetup", id => "inline", call => \&getsetup);
hook(type => "checkconfig", id => "inline", call => \&checkconfig);
# This ensures each page only pings once and prevents slow
# pings interrupting page builds.
hook(type => "change", id => "inline", call => \&IkiWiki::pingurl);
-} # }}}
+}
-sub getopt () { #{{{
+sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
push @{$config{pingurl}}, $_[1];
},
);
-} #}}}
+}
-sub getsetup () { #{{{
+sub getsetup () {
return
plugin => {
safe => 1,
safe => 1,
rebuild => 0,
},
-} #}}}
+}
-sub checkconfig () { #{{{
+sub checkconfig () {
if (($config{rss} || $config{atom}) && ! length $config{url}) {
error(gettext("Must specify url to wiki with --url when using --rss or --atom"));
}
if (! exists $config{pingurl}) {
$config{pingurl}=[];
}
-} #}}}
+}
-sub format (@) { #{{{
+sub format (@) {
my %params=@_;
# Fill in the inline content generated earlier. This is actually an
delete @inline[$1,]
}eg;
return $params{content};
-} #}}}
+}
-sub sessioncgi ($$) { #{{{
+sub sessioncgi ($$) {
my $q=shift;
my $session=shift;
my %toping;
my %feedlinks;
-sub preprocess_inline (@) { #{{{
+sub preprocess_inline (@) {
my %params=@_;
if (! exists $params{pages}) {
$template->param(content => $content);
}
$template->param(pageurl => urlto(bestlink($params{page}, $page), $params{destpage}));
+ $template->param(inlinepage => $page);
$template->param(title => pagetitle(basename($page)));
$template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
$template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
return $ret if $raw || $nested;
push @inline, $ret;
return "<div class=\"inline\" id=\"$#inline\"></div>\n\n";
-} #}}}
+}
-sub pagetemplate_inline (@) { #{{{
+sub pagetemplate_inline (@) {
my %params=@_;
my $page=$params{page};
my $template=$params{template};
$template->param(feedlinks => $feedlinks{$page})
if exists $feedlinks{$page} && $template->query(name => "feedlinks");
-} #}}}
+}
-sub get_inline_content ($$) { #{{{
+sub get_inline_content ($$) {
my $page=shift;
my $destpage=shift;
else {
return "";
}
-} #}}}
+}
-sub date_822 ($) { #{{{
+sub date_822 ($) {
my $time=shift;
my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
my $ret=POSIX::strftime("%a, %d %b %Y %H:%M:%S %z", localtime($time));
POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
return $ret;
-} #}}}
+}
-sub date_3339 ($) { #{{{
+sub date_3339 ($) {
my $time=shift;
my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
my $ret=POSIX::strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($time));
POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
return $ret;
-} #}}}
+}
-sub absolute_urls ($$) { #{{{
+sub absolute_urls ($$) {
# sucky sub because rss sucks
my $content=shift;
my $baseurl=shift;
$content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(?!\w+:)(\/[^"]*)"/$1 href="$urltop$2"/mig;
$content=~s/(<img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"(?!\w+:)(\/[^"]*)"/$1 src="$urltop$2"/mig;
return $content;
-} #}}}
+}
-sub genfeed ($$$$$@) { #{{{
+sub genfeed ($$$$$@) {
my $feedtype=shift;
my $feedurl=shift;
my $feeddesc=shift;
});
return $template->output;
-} #}}}
+}
-sub pingurl (@) { #{{{
+sub pingurl (@) {
return unless @{$config{pingurl}} && %toping;
eval q{require RPC::XML::Client};
}
exit 0; # daemon done
-} #}}}
+}
1