+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},
+ );
+}
+
+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$/;
+ }
+} #}}}
+
+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=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."/".$page.$add)}) {
+ $add=1 unless length $add;
+ $add++;
+ }
+ $q->param('page', $page.$add);
+ # now go create the page
+ $q->param('do', 'create');
+ IkiWiki::cgi_editpage($q, $session);
+ exit;
+ }
+}
+