]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/inline.pm
poll: Use urlto to produce redirection URLs, avoiding mentions of index.html
[git.ikiwiki.info.git] / IkiWiki / Plugin / inline.pm
index cdd0ab0dc2b7cf86ae3b5c7367bd24fe980d2462..8efef3fc85ccc7883172f185b67dc57ff86ec19c 100644 (file)
@@ -47,6 +47,10 @@ sub getopt () { #{{{
 
 sub getsetup () { #{{{
        return
 
 sub getsetup () { #{{{
        return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
                rss => {
                        type => "boolean",
                        example => 0,
                rss => {
                        type => "boolean",
                        example => 0,
@@ -127,7 +131,13 @@ sub sessioncgi () { #{{{
                $q->param('page', $page.$add);
                # now go create the page
                $q->param('do', 'create');
                $q->param('page', $page.$add);
                # now go create the page
                $q->param('do', 'create');
-               IkiWiki::cgi_editpage($q, $session);
+               # 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;
        }
 }
                exit;
        }
 }
@@ -182,7 +192,7 @@ sub preprocess_inline (@) { #{{{
        }
 
        if (exists $params{sort} && $params{sort} eq 'title') {
        }
 
        if (exists $params{sort} && $params{sort} eq 'title') {
-               @list=sort @list;
+               @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
        }
        elsif (exists $params{sort} && $params{sort} eq 'mtime') {
                @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
        }
        elsif (exists $params{sort} && $params{sort} eq 'mtime') {
                @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
@@ -247,13 +257,20 @@ sub preprocess_inline (@) { #{{{
        my $atomurl=basename(atompage($params{destpage}).$feednum) if $feeds && $atom;
        my $ret="";
 
        my $atomurl=basename(atompage($params{destpage}).$feednum) if $feeds && $atom;
        my $ret="";
 
-       if ($config{cgiurl} && ! $params{preview} && (exists $params{rootpage} ||
-                       (exists $params{postform} && yesno($params{postform})))) {
+       if (length $config{cgiurl} && ! $params{preview} && (exists $params{rootpage} ||
+           (exists $params{postform} && yesno($params{postform}))) &&
+           IkiWiki->can("cgi_editpage")) {
                # Add a blog post form, with feed buttons.
                my $formtemplate=template("blogpost.tmpl", blind_cache => 1);
                $formtemplate->param(cgiurl => $config{cgiurl});
                # Add a blog post form, with feed buttons.
                my $formtemplate=template("blogpost.tmpl", blind_cache => 1);
                $formtemplate->param(cgiurl => $config{cgiurl});
-               $formtemplate->param(rootpage => 
-                       exists $params{rootpage} ? $params{rootpage} : $params{page});
+               my $rootpage;
+               if (exists $params{rootpage}) {
+                       $rootpage=bestlink($params{page}, $params{rootpage});
+               }
+               else {
+                       $rootpage=$params{page};
+               }
+               $formtemplate->param(rootpage => $rootpage);
                $formtemplate->param(rssurl => $rssurl) if $feeds && $rss;
                $formtemplate->param(atomurl => $atomurl) if $feeds && $atom;
                if (exists $params{postformtext}) {
                $formtemplate->param(rssurl => $rssurl) if $feeds && $rss;
                $formtemplate->param(atomurl => $atomurl) if $feeds && $atom;
                if (exists $params{postformtext}) {
@@ -353,7 +370,7 @@ sub preprocess_inline (@) { #{{{
                        if (! $params{preview}) {
                                writefile($rssp, $config{destdir},
                                        genfeed("rss",
                        if (! $params{preview}) {
                                writefile($rssp, $config{destdir},
                                        genfeed("rss",
-                                               $config{url}."/".rsspage($params{destpage}).$feednum, $desc, $params{guid}, $params{destpage}, @feedlist));
+                                               $config{url}."/".$rssp, $desc, $params{guid}, $params{destpage}, @feedlist));
                                $toping{$params{destpage}}=1 unless $config{rebuild};
                                $feedlinks{$params{destpage}}=qq{<link rel="alternate" type="application/rss+xml" title="RSS" href="$rssurl" />};
                        }
                                $toping{$params{destpage}}=1 unless $config{rebuild};
                                $feedlinks{$params{destpage}}=qq{<link rel="alternate" type="application/rss+xml" title="RSS" href="$rssurl" />};
                        }
@@ -363,7 +380,7 @@ sub preprocess_inline (@) { #{{{
                        will_render($params{destpage}, $atomp);
                        if (! $params{preview}) {
                                writefile($atomp, $config{destdir},
                        will_render($params{destpage}, $atomp);
                        if (! $params{preview}) {
                                writefile($atomp, $config{destdir},
-                                       genfeed("atom", $config{url}."/".atompage($params{destpage}).$feednum, $desc, $params{guid}, $params{destpage}, @feedlist));
+                                       genfeed("atom", $config{url}."/".$atomp, $desc, $params{guid}, $params{destpage}, @feedlist));
                                $toping{$params{destpage}}=1 unless $config{rebuild};
                                $feedlinks{$params{destpage}}=qq{<link rel="alternate" type="application/atom+xml" title="Atom" href="$atomurl" />};
                        }
                                $toping{$params{destpage}}=1 unless $config{rebuild};
                                $feedlinks{$params{destpage}}=qq{<link rel="alternate" type="application/atom+xml" title="Atom" href="$atomurl" />};
                        }
@@ -575,15 +592,15 @@ sub pingurl (@) { #{{{
                                        $title, $url);
                                my $res = $client->send_request($req);
                                if (! ref $res) {
                                        $title, $url);
                                my $res = $client->send_request($req);
                                if (! ref $res) {
-                                       debug("Did not receive response to ping");
+                                       error("Did not receive response to ping");
                                }
                                my $r=$res->value;
                                if (! exists $r->{flerror} || $r->{flerror}) {
                                }
                                my $r=$res->value;
                                if (! exists $r->{flerror} || $r->{flerror}) {
-                                       debug("Ping rejected: ".(exists $r->{message} ? $r->{message} : "[unknown reason]"));
+                                       error("Ping rejected: ".(exists $r->{message} ? $r->{message} : "[unknown reason]"));
                                }
                        };
                        if ($@) {
                                }
                        };
                        if ($@) {
-                               debug "Ping failed: $@";
+                               error "Ping failed: $@";
                        }
                }
        }
                        }
                }
        }