X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8d3a3c6a1e2a5a2be4213c2ce80c02e8f31dc9b4..0993933ea30f4fb28402f12a033cdd37015da427:/IkiWiki/Plugin/inline.pm diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index d6ef6c54c..d8b5f8548 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -5,7 +5,7 @@ package IkiWiki::Plugin::inline; use warnings; use strict; use Encode; -use IkiWiki 2.00; +use IkiWiki 3.00; use URI; my %knownfeeds; @@ -13,7 +13,7 @@ my %page_numfeeds; 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); @@ -22,14 +22,14 @@ sub import { #{{{ call => \&IkiWiki::preprocess_inline); hook(type => "pagetemplate", id => "inline", call => \&IkiWiki::pagetemplate_inline); - hook(type => "format", id => "inline", call => \&format); + hook(type => "format", id => "inline", call => \&format, first => 1); # Hook to change to do pinging since it's called late. # 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'); @@ -42,9 +42,9 @@ sub getopt () { #{{{ push @{$config{pingurl}}, $_[1]; }, ); -} #}}} +} -sub getsetup () { #{{{ +sub getsetup () { return plugin => { safe => 1, @@ -85,9 +85,9 @@ sub getsetup () { #{{{ 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")); } @@ -100,9 +100,9 @@ sub checkconfig () { #{{{ if (! exists $config{pingurl}) { $config{pingurl}=[]; } -} #}}} +} -sub format (@) { #{{{ +sub format (@) { my %params=@_; # Fill in the inline content generated earlier. This is actually an @@ -111,9 +111,9 @@ sub format (@) { #{{{ delete @inline[$1,] }eg; return $params{content}; -} #}}} +} -sub sessioncgi ($$) { #{{{ +sub sessioncgi ($$) { my $q=shift; my $session=shift; @@ -148,7 +148,7 @@ package IkiWiki; my %toping; my %feedlinks; -sub preprocess_inline (@) { #{{{ +sub preprocess_inline (@) { my %params=@_; if (! exists $params{pages}) { @@ -340,6 +340,7 @@ sub preprocess_inline (@) { #{{{ $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})); @@ -416,18 +417,18 @@ sub preprocess_inline (@) { #{{{ return $ret if $raw || $nested; push @inline, $ret; return "
\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; @@ -446,9 +447,9 @@ sub get_inline_content ($$) { #{{{ else { return ""; } -} #}}} +} -sub date_822 ($) { #{{{ +sub date_822 ($) { my $time=shift; my $lc_time=POSIX::setlocale(&POSIX::LC_TIME); @@ -456,9 +457,9 @@ sub date_822 ($) { #{{{ 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); @@ -466,9 +467,9 @@ sub date_3339 ($) { #{{{ 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; @@ -489,9 +490,9 @@ sub absolute_urls ($$) { #{{{ $content=~s/(output; -} #}}} +} -sub pingurl (@) { #{{{ +sub pingurl (@) { return unless @{$config{pingurl}} && %toping; eval q{require RPC::XML::Client}; @@ -624,6 +625,6 @@ sub pingurl (@) { #{{{ } exit 0; # daemon done -} #}}} +} 1