+my %knownfeeds;
+my %page_numfeeds;
+my @inline;
+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",
+ call => \&IkiWiki::preprocess_inline);
+ hook(type => "pagetemplate", id => "inline",
+ call => \&IkiWiki::pagetemplate_inline);
+ 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 () {
+ eval q{use Getopt::Long};
+ error($@) if $@;
+ Getopt::Long::Configure('pass_through');
+ GetOptions(
+ "rss!" => \$config{rss},
+ "atom!" => \$config{atom},
+ "allowrss!" => \$config{allowrss},
+ "allowatom!" => \$config{allowatom},
+ "pingurl=s" => sub {
+ push @{$config{pingurl}}, $_[1];
+ },
+ );
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ safe => 1,
+ rebuild => undef,
+ section => "core",
+ },
+ 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}) {
+ error(gettext("Must specify url to wiki with --url when using --rss or --atom"));
+ }
+ if ($config{rss}) {
+ push @{$config{wiki_file_prune_regexps}}, qr/\.rss$/;
+ }
+ if ($config{atom}) {
+ push @{$config{wiki_file_prune_regexps}}, qr/\.atom$/;
+ }
+ if (! exists $config{pingurl}) {
+ $config{pingurl}=[];
+ }
+}
+
+sub format (@) {
+ my %params=@_;
+
+ # Fill in the inline content generated earlier. This is actually an
+ # optimisation.
+ $params{content}=~s{<div class="inline" id="([^"]+)"></div>}{
+ delete @inline[$1,]
+ }eg;
+ return $params{content};
+}
+
+sub sessioncgi ($$) {
+ my $q=shift;
+ my $session=shift;
+
+ if ($q->param('do') eq 'blog') {
+ my $page=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."/".$page.$add)}) {
+ $add=1 unless length $add;
+ $add++;
+ }
+ $q->param('page', $page.$add);
+ # now go create the page
+ $q->param('do', 'create');
+ # make sure the editpage plugin in loaded
+ if (IkiWiki->can("cgi_editpage")) {
+ IkiWiki::cgi_editpage($q, $session);
+ }
+ else {
+ error(gettext("page editing not allowed"));
+ }
+ exit;
+ }
+}