]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/inline.pm
Merge commit 'upstream/master' into pub/master
[git.ikiwiki.info.git] / IkiWiki / Plugin / inline.pm
index 4d96001ed7bffdf653de4ef631fdbdf029d24205..7fe5a4dcf5c2f0543bef836067820133b2014405 100644 (file)
@@ -47,39 +47,42 @@ sub getopt () { #{{{
 
 sub getsetup () { #{{{
        return
 
 sub getsetup () { #{{{
        return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
                rss => {
                        type => "boolean",
                rss => {
                        type => "boolean",
-                       default => 0,
-                       description => "enable rss feeds by default",
+                       example => 0,
+                       description => "enable rss feeds by default?",
                        safe => 1,
                        rebuild => 1,
                },
                atom => {
                        type => "boolean",
                        safe => 1,
                        rebuild => 1,
                },
                atom => {
                        type => "boolean",
-                       default => 0,
-                       description => "enable atom feeds by default",
+                       example => 0,
+                       description => "enable atom feeds by default?",
                        safe => 1,
                        rebuild => 1,
                },
                allowrss => {
                        type => "boolean",
                        safe => 1,
                        rebuild => 1,
                },
                allowrss => {
                        type => "boolean",
-                       default => 0,
-                       description => "allow rss feeds to be used",
+                       example => 0,
+                       description => "allow rss feeds to be used?",
                        safe => 1,
                        rebuild => 1,
                },
                allowatom => {
                        type => "boolean",
                        safe => 1,
                        rebuild => 1,
                },
                allowatom => {
                        type => "boolean",
-                       default => 0,
-                       description => "allow atom feeds to be used",
+                       example => 0,
+                       description => "allow atom feeds to be used?",
                        safe => 1,
                        rebuild => 1,
                },
                pingurl => {
                        type => "string",
                        safe => 1,
                        rebuild => 1,
                },
                pingurl => {
                        type => "string",
-                       default => "",
                        example => "http://rpc.technorati.com/rpc/ping",
                        example => "http://rpc.technorati.com/rpc/ping",
-                       description => "urls to ping (using XMP-RPC) on feed update",
+                       description => "urls to ping (using XML-RPC) on feed update",
                        safe => 1,
                        rebuild => 0,
                },
                        safe => 1,
                        rebuild => 0,
                },
@@ -111,12 +114,12 @@ sub format (@) { #{{{
        return $params{content};
 } #}}}
 
        return $params{content};
 } #}}}
 
-sub sessioncgi () { #{{{
+sub sessioncgi ($$) { #{{{
        my $q=shift;
        my $session=shift;
 
        if ($q->param('do') eq 'blog') {
        my $q=shift;
        my $session=shift;
 
        if ($q->param('do') eq 'blog') {
-               my $page=IkiWiki::titlepage(decode_utf8($q->param('title')));
+               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');
                $page=~s/(\/)/"__".ord($1)."__"/eg; # don't create subdirs
                # if the page already exists, munge it to be unique
                my $from=$q->param('from');
@@ -128,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;
        }
 }
@@ -183,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;
@@ -192,7 +201,7 @@ sub preprocess_inline (@) { #{{{
                @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
        }
        else {
                @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
        }
        else {
-               return sprintf(gettext("unknown sort type %s"), $params{sort});
+               error sprintf(gettext("unknown sort type %s"), $params{sort});
        }
 
        if (yesno($params{reverse})) {
        }
 
        if (yesno($params{reverse})) {
@@ -248,13 +257,23 @@ 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});
+                       if (!length $rootpage) {
+                               $rootpage=$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}) {
@@ -279,7 +298,7 @@ sub preprocess_inline (@) { #{{{
                require HTML::Template;
                my @params=IkiWiki::template_params($params{template}.".tmpl", blind_cache => 1);
                if (! @params) {
                require HTML::Template;
                my @params=IkiWiki::template_params($params{template}.".tmpl", blind_cache => 1);
                if (! @params) {
-                       return sprintf(gettext("nonexistant template %s"), $params{template});
+                       error sprintf(gettext("nonexistant template %s"), $params{template});
                }
                my $template=HTML::Template->new(@params) unless $raw;
        
                }
                my $template=HTML::Template->new(@params) unless $raw;
        
@@ -297,6 +316,7 @@ sub preprocess_inline (@) { #{{{
                                $template->param(pageurl => urlto(bestlink($params{page}, $page), $params{destpage}));
                                $template->param(title => pagetitle(basename($page)));
                                $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
                                $template->param(pageurl => urlto(bestlink($params{page}, $page), $params{destpage}));
                                $template->param(title => pagetitle(basename($page)));
                                $template->param(ctime => displaytime($pagectime{$page}, $params{timeformat}));
+                               $template->param(mtime => displaytime($pagemtime{$page}, $params{timeformat}));
                                $template->param(first => 1) if $page eq $list[0];
                                $template->param(last => 1) if $page eq $list[$#list];
        
                                $template->param(first => 1) if $page eq $list[0];
                                $template->param(last => 1) if $page eq $list[$#list];
        
@@ -354,9 +374,9 @@ 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};
                                $toping{$params{destpage}}=1 unless $config{rebuild};
-                               $feedlinks{$params{destpage}}=qq{<link rel="alternate" type="application/rss+xml" title="RSS" href="$rssurl" />};
+                               $feedlinks{$params{destpage}}.=qq{<link rel="alternate" type="application/rss+xml" title="$desc (RSS)" href="$rssurl" />};
                        }
                }
                if ($atom) {
                        }
                }
                if ($atom) {
@@ -364,9 +384,9 @@ 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};
                                $toping{$params{destpage}}=1 unless $config{rebuild};
-                               $feedlinks{$params{destpage}}=qq{<link rel="alternate" type="application/atom+xml" title="Atom" href="$atomurl" />};
+                               $feedlinks{$params{destpage}}.=qq{<link rel="alternate" type="application/atom+xml" title="$desc (Atom)" href="$atomurl" />};
                        }
                }
        }
                        }
                }
        }
@@ -576,15 +596,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: $@";
                        }
                }
        }
                        }
                }
        }