]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/CGI.pm
fix breakage
[ikiwiki.git] / IkiWiki / CGI.pm
index 973053427b4957aa40c46b4841661c8e0387d259..e62bcf477601ec38be1178ba3ce3207c1e588293 100644 (file)
@@ -89,7 +89,9 @@ sub cgi_recentchanges ($) { #{{{
                delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess;
                $change->{pages} = [
                        map {
-                               $_->{link} = htmllink("", "", $_->{page}, 1, 0, pagetitle($_->{page}));
+                               $_->{link} = htmllink("", "", $_->{page},
+                                       noimageinline => 1,
+                                       linktext => pagetitle($_->{page}));
                                $_;
                        } @{$change->{pages}}
                ];
@@ -219,7 +221,7 @@ sub cgi_prefs ($$) { #{{{
        $form->field(name => "do", type => "hidden");
        $form->field(name => "email", size => 50);
        $form->field(name => "subscriptions", size => 50,
-               comment => "(".htmllink("", "", "PageSpec", 1).")");
+               comment => "(".htmllink("", "", "PageSpec", noimageinline => 1).")");
        $form->field(name => "banned_users", size => 50);
        
        my $user_name=$session->param("name");
@@ -360,7 +362,7 @@ sub cgi_editpage ($$) { #{{{
        $form->tmpl_param("can_commit", $config{rcs});
        $form->tmpl_param("indexlink", indexlink());
        $form->tmpl_param("helponformattinglink",
-               htmllink("", "", "HelpOnFormatting", 1));
+               htmllink("", "", "HelpOnFormatting", noimageinline => 1));
        $form->tmpl_param("baseurl", baseurl());
        if (! $form->submitted) {
                $form->field(name => "rcsinfo", value => rcs_prepedit($file),
@@ -457,7 +459,8 @@ sub cgi_editpage ($$) { #{{{
                        
                        $form->tmpl_param("page_select", 1);
                        $form->field(name => "page", type => 'select',
-                               options => \@editable_locs, value => $best_loc);
+                               options => { map { $_ => pagetitle($_, 1) } @editable_locs },
+                               value => $best_loc);
                        $form->field(name => "type", type => 'select',
                                options => \@page_types);
                        $form->title(sprintf(gettext("creating %s"), pagetitle($page)));
@@ -510,6 +513,7 @@ sub cgi_editpage ($$) { #{{{
                        return;
                }
                
+               my $conflict;
                if ($config{rcs}) {
                        my $message="";
                        if (defined $form->field('comments') &&
@@ -520,44 +524,44 @@ sub cgi_editpage ($$) { #{{{
                        if ($newfile) {
                                rcs_add($file);
                        }
-                       # prevent deadlock with post-commit hook
-                       unlockwiki();
-                       # presumably the commit will trigger an update
-                       # of the wiki
-                       my $conflict=rcs_commit($file, $message,
+
+                       # Prevent deadlock with post-commit hook by
+                       # signaling to it that it should not try to
+                       # do anything (except send commit mails).
+                       disable_commit_hook();
+                       $conflict=rcs_commit($file, $message,
                                $form->field("rcsinfo"),
                                $session->param("name"), $ENV{REMOTE_ADDR});
+                       enable_commit_hook();
+                       rcs_update();
+               }
                
-                       if (defined $conflict) {
-                               $form->field(name => "rcsinfo", value => rcs_prepedit($file),
-                                       force => 1);
-                               $form->tmpl_param("page_conflict", 1);
-                               $form->field("editcontent", value => $conflict, force => 1);
-                               $form->field(name => "comments", value => $form->field('comments'), force => 1);
-                               $form->field("do", "edit)");
-                               $form->tmpl_param("page_select", 0);
-                               $form->field(name => "page", type => 'hidden');
-                               $form->field(name => "type", type => 'hidden');
-                               $form->title(sprintf(gettext("editing %s"), $page));
-                               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();
-                       }
+               # Refresh even if there was a conflict, since other changes
+               # may have been committed while the post-commit hook was
+               # disabled.
+               require IkiWiki::Render;
+               refresh();
+               saveindex();
+
+               if (defined $conflict) {
+                       $form->field(name => "rcsinfo", value => rcs_prepedit($file),
+                               force => 1);
+                       $form->tmpl_param("page_conflict", 1);
+                       $form->field("editcontent", value => $conflict, force => 1);
+                       $form->field(name => "comments", value => $form->field('comments'), force => 1);
+                       $form->field("do", "edit)");
+                       $form->tmpl_param("page_select", 0);
+                       $form->field(name => "page", type => 'hidden');
+                       $form->field(name => "type", type => 'hidden');
+                       $form->title(sprintf(gettext("editing %s"), $page));
+                       print $form->render(submit => \@buttons);
+                       return;
                }
                else {
-                       require IkiWiki::Render;
-                       refresh();
-                       saveindex();
+                       # The trailing question mark tries to avoid broken
+                       # caches and get the most recent version of the page.
+                       redirect($q, "$config{url}/".htmlpage($page)."?updated");
                }
-               
-               # The trailing question mark tries to avoid broken
-               # caches and get the most recent version of the page.
-               redirect($q, "$config{url}/".htmlpage($page)."?updated");
        }
 } #}}}
 
@@ -709,7 +713,7 @@ sub userlink ($) { #{{{
        else {
                return htmllink("", "", escapeHTML(
                        length $config{userdir} ? $config{userdir}."/".$user : $user
-               ), 1);
+               ), noimageinline => 1);
        }
 } #}}}