X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/1dddec0ba9f66f082f4b8349916cdb6bdb5636e3..42ac4ec00959bd6162076af799023545b698bed9:/IkiWiki/Plugin/inline.pm diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 344620ebe..cdd0ab0dc 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -15,6 +15,7 @@ my $nested=0; sub import { #{{{ hook(type => "getopt", id => "inline", call => \&getopt); + hook(type => "getsetup", id => "inline", call => \&getsetup); hook(type => "checkconfig", id => "inline", call => \&checkconfig); hook(type => "sessioncgi", id => "inline", call => \&sessioncgi); hook(type => "preprocess", id => "inline", @@ -27,7 +28,6 @@ sub import { #{{{ # pings interrupting page builds. hook(type => "change", id => "inline", call => \&IkiWiki::pingurl); - } # }}} sub getopt () { #{{{ @@ -39,8 +39,50 @@ sub getopt () { #{{{ "atom!" => \$config{atom}, "allowrss!" => \$config{allowrss}, "allowatom!" => \$config{allowatom}, + "pingurl=s" => sub { + push @{$config{pingurl}}, $_[1]; + }, ); -} +} #}}} + +sub getsetup () { #{{{ + return + rss => { + type => "boolean", + example => 0, + description => "enable rss feeds by default?", + safe => 1, + rebuild => 1, + }, + atom => { + type => "boolean", + example => 0, + description => "enable atom feeds by default?", + safe => 1, + rebuild => 1, + }, + allowrss => { + type => "boolean", + example => 0, + description => "allow rss feeds to be used?", + safe => 1, + rebuild => 1, + }, + allowatom => { + type => "boolean", + example => 0, + description => "allow atom feeds to be used?", + safe => 1, + rebuild => 1, + }, + pingurl => { + type => "string", + example => "http://rpc.technorati.com/rpc/ping", + description => "urls to ping (using XML-RPC) on feed update", + safe => 1, + rebuild => 0, + }, +} #}}} sub checkconfig () { #{{{ if (($config{rss} || $config{atom}) && ! length $config{url}) { @@ -52,6 +94,9 @@ sub checkconfig () { #{{{ if ($config{atom}) { push @{$config{wiki_file_prune_regexps}}, qr/\.atom$/; } + if (! exists $config{pingurl}) { + $config{pingurl}=[]; + } } #}}} sub format (@) { #{{{ @@ -70,12 +115,12 @@ sub sessioncgi () { #{{{ my $session=shift; if ($q->param('do') eq 'blog') { - my $page=decode_utf8($q->param('title')); - $page=~s/\///g; # no slashes in blog posts + my $page=IkiWiki::titlepage(decode_utf8($q->param('title'))); + $page=~s/(\/)/"__".ord($1)."__"/eg; # don't create subdirs # if the page already exists, munge it to be unique my $from=$q->param('from'); my $add=""; - while (exists $IkiWiki::pagecase{lc($from."/".IkiWiki::titlepage($page).$add)}) { + while (exists $IkiWiki::pagecase{lc($from."/".$page.$add)}) { $add=1 unless length $add; $add++; } @@ -94,16 +139,11 @@ package IkiWiki; my %toping; my %feedlinks; -sub yesno ($) { #{{{ - my $val=shift; - return (defined $val && lc($val) eq "yes"); -} #}}} - sub preprocess_inline (@) { #{{{ my %params=@_; if (! exists $params{pages}) { - return "[[inline ".gettext("missing pages parameter")."]]"; + error gettext("missing pages parameter"); } my $raw=yesno($params{raw}); my $archive=yesno($params{archive}); @@ -278,7 +318,7 @@ sub preprocess_inline (@) { #{{{ } if (length $config{cgiurl} && defined $type) { $template->param(have_actions => 1); - $template->param(editurl => cgiurl(do => "edit", page => pagetitle($page, 1))); + $template->param(editurl => cgiurl(do => "edit", page => $page)); } } @@ -313,7 +353,7 @@ sub preprocess_inline (@) { #{{{ if (! $params{preview}) { writefile($rssp, $config{destdir}, genfeed("rss", - $config{url}."/".rsspage($params{destpage}).$feednum, $desc, $params{destpage}, @feedlist)); + $config{url}."/".rsspage($params{destpage}).$feednum, $desc, $params{guid}, $params{destpage}, @feedlist)); $toping{$params{destpage}}=1 unless $config{rebuild}; $feedlinks{$params{destpage}}=qq{}; } @@ -323,7 +363,7 @@ sub preprocess_inline (@) { #{{{ will_render($params{destpage}, $atomp); if (! $params{preview}) { writefile($atomp, $config{destdir}, - genfeed("atom", $config{url}."/".atompage($params{destpage}).$feednum, $desc, $params{destpage}, @feedlist)); + genfeed("atom", $config{url}."/".atompage($params{destpage}).$feednum, $desc, $params{guid}, $params{destpage}, @feedlist)); $toping{$params{destpage}}=1 unless $config{rebuild}; $feedlinks{$params{destpage}}=qq{}; } @@ -416,20 +456,21 @@ sub atompage ($) { #{{{ return targetpage(shift, "atom"); } #}}} -sub genfeed ($$$$@) { #{{{ +sub genfeed ($$$$$@) { #{{{ my $feedtype=shift; my $feedurl=shift; my $feeddesc=shift; + my $guid=shift; my $page=shift; my @pages=@_; - my $url=URI->new(encode_utf8($config{url}."/".urlto($page,""))); + my $url=URI->new(encode_utf8(urlto($page,"",1))); my $itemtemplate=template($feedtype."item.tmpl", blind_cache => 1); my $content=""; my $lasttime = 0; foreach my $p (@pages) { - my $u=URI->new(encode_utf8($config{url}."/".urlto($p, ""))); + my $u=URI->new(encode_utf8(urlto($p, "", 1))); my $pcontent = absolute_urls(get_inline_content($p, $page), $url); $itemtemplate->param( @@ -442,6 +483,11 @@ sub genfeed ($$$$@) { #{{{ mdate_3339 => date_3339($pagemtime{$p}), ); + if (exists $pagestate{$p} && + exists $pagestate{$p}{meta}{guid}) { + $itemtemplate->param(guid => $pagestate{$p}{meta}{guid}); + } + if ($itemtemplate->query(name => "enclosure")) { my $file=$pagesources{$p}; my $type=pagetype($file); @@ -484,6 +530,7 @@ sub genfeed ($$$$@) { #{{{ pageurl => $url, content => $content, feeddesc => $feeddesc, + guid => $guid, feeddate => date_3339($lasttime), feedurl => $feedurl, version => $IkiWiki::version, @@ -519,7 +566,7 @@ sub pingurl (@) { #{{{ foreach my $page (keys %toping) { my $title=pagetitle(basename($page), 0); - my $url="$config{url}/".urlto($page, ""); + my $url=urlto($page, "", 1); foreach my $pingurl (@{$config{pingurl}}) { debug("Pinging $pingurl for $page"); eval {