]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/CGI.pm
* Fix for missing backlinks() in pagestats plugin.
[ikiwiki.git] / IkiWiki / CGI.pm
index 511358ff55046157cfd7635800153d9c19f5dbb6..0c66705469185954acf8eadf4200bb17e0e18d36 100644 (file)
@@ -46,6 +46,8 @@ sub page_locked ($$;$) { #{{{
                if (pagespec_match($page, userinfo_get($admin, "locked_pages"))) {
                        return 1 if $nonfatal;
 
+                       #translators: The first parameter is a page name,
+                       #translators: second is the user who locked it.
                        error(sprintf(gettext("%s is locked by %s and cannot be edited"),
                                htmllink("", "", $page, 1),
                                userlink($admin)));
@@ -90,7 +92,7 @@ sub cgi_recentchanges ($) { #{{{
                delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess;
                $change->{pages} = [
                        map {
-                               $_->{link} = htmllink("", "", $_->{page}, 1);
+                               $_->{link} = htmllink("", "", $_->{page}, 1, 0, pagetitle($_->{page}));
                                $_;
                        } @{$change->{pages}}
                ];
@@ -127,8 +129,7 @@ sub cgi_signin ($$) { #{{{
                params => $q,
                action => $config{cgiurl},
                header => 0,
-               template => (-e "$config{templatedir}/signin.tmpl" ?
-                            {template_params("signin.tmpl")} : ""),
+               template => scalar template_params("signin.tmpl"),
                stylesheet => baseurl()."style.css",
        );
        my $buttons=["Login"];
@@ -196,8 +197,7 @@ sub cgi_prefs ($$) { #{{{
                javascript => 0,
                params => $q,
                action => $config{cgiurl},
-               template => (-e "$config{templatedir}/prefs.tmpl" ?
-                            {template_params("prefs.tmpl")} : ""),
+               template => scalar template_params("prefs.tmpl"),
                stylesheet => baseurl()."style.css",
        );
        my $buttons=["Save Preferences", "Logout", "Cancel"];
@@ -291,8 +291,7 @@ sub cgi_editpage ($$) { #{{{
                params => $q,
                action => $config{cgiurl},
                table => 0,
-               template => (-e "$config{templatedir}/editpage.tmpl" ?
-                               {template_params("editpage.tmpl")} : ""),
+               template => scalar template_params("editpage.tmpl"),
        );
        
        run_hooks(formbuilder_setup => sub {
@@ -419,6 +418,8 @@ sub cgi_editpage ($$) { #{{{
                                        push @page_locs, $dir.$page;
                                }
                        }
+                       push @page_locs, "$config{userdir}/$page"
+                               if length $config{userdir};
 
                        @page_locs = grep {
                                ! exists $pagecase{lc $_} &&
@@ -506,6 +507,12 @@ sub cgi_editpage ($$) { #{{{
                                print $form->render(submit => \@buttons);
                                return;
                        }
+                       else {
+                               # Make sure that the repo is up-to-date;
+                               # locking prevents the post-commit hook
+                               # from updating it.
+                               rcs_update();
+                       }
                }
                else {
                        require IkiWiki::Render;
@@ -632,6 +639,7 @@ sub cgi (;$$) { #{{{
        }
        elsif ($do eq 'blog') {
                my $page=titlepage(decode_utf8($q->param('title')));
+               $page=~s/(\/)/"__".ord($1)."__"/eg; # escape slashes too
                # if the page already exists, munge it to be unique
                my $from=$q->param('from');
                my $add="";
@@ -644,6 +652,9 @@ sub cgi (;$$) { #{{{
                $q->param('do', 'create');
                cgi_editpage($q, $session);
        }
+       elsif ($do eq 'postsignin') {
+               error(gettext("login failed, perhaps you need to turn on cookies?"));
+       }
        else {
                error("unknown do parameter");
        }
@@ -663,6 +674,10 @@ sub userlink ($) { #{{{
                if ($display !~ /\[/) {
                        $display=~s/^(.*?)\.([^.]+\.[a-z]+)$/$1 [$2]/;
                }
+               # Convert "http://somehost.com/user" to "user [somehost.com]".
+               if ($display !~ /\[/) {
+                       $display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/;
+               }
                $display=~s!^https?://!!; # make sure this is removed
                return "<a href=\"$user\">".escapeHTML($display)."</a>";
        }