add news item for ikiwiki 1.43
[ikiwiki.git] / doc / patchqueue / disappearing_pages.mdwn
1 If one user (via SVN or otherwise) deletes or moves a page while another user 
2 is editing it via the web, bad things happen. This patch addresses this by
3 failing gracefully, and allowing the user to commit a new file with the same 
4 name if desired.
5
6 The patch is [here](http://ikidev.betacantrips.com//patches/disappear.patch).
7 It requires a strip level of 4 -- sorry about that. There are also some
8 other changes in the conflict-resolution section which seemed to make sense,
9 let me know what you think. --Ethan
10
11     diff -urX /home/glasserc/ignorepats /home/glasserc/ikiclean/IkiWiki/CGI.pm /home/glasserc/ikidev/IkiWiki/CGI.pm
12     --- /home/glasserc/ikiclean/IkiWiki/CGI.pm  2007-02-11 21:40:32.419641000 -0800
13     +++ /home/glasserc/ikidev/IkiWiki/CGI.pm    2007-02-12 15:35:55.178886000 -0800
14     @@ -278,7 +278,7 @@
15         my $q=shift;
16         my $session=shift;
17      
18     -   my @fields=qw(do rcsinfo subpage from page type editcontent comments);
19     +   my @fields=qw(do rcsinfo subpage from page type editcontent comments newfile);
20         my @buttons=("Save Page", "Preview", "Cancel");
21         
22         eval q{use CGI::FormBuilder};
23     @@ -340,10 +340,6 @@
24                 $file=$page.".".$type;
25         }
26      
27     -   my $newfile=0;
28     -   if (! -e "$config{srcdir}/$file") {
29     -           $newfile=1;
30     -   }
31      
32         $form->field(name => "do", type => 'hidden');
33         $form->field(name => "from", type => 'hidden');
34     @@ -354,6 +350,7 @@
35         $form->field(name => "comments", type => "text", size => 80);
36         $form->field(name => "editcontent", type => "textarea", rows => 20,
37                 cols => 80);
38     +   $form->field(name => "newfile", type => 'hidden');
39         $form->tmpl_param("can_commit", $config{rcs});
40         $form->tmpl_param("indexlink", indexlink());
41         $form->tmpl_param("helponformattinglink",
42     @@ -362,8 +359,12 @@
43         if (! $form->submitted) {
44                 $form->field(name => "rcsinfo", value => rcs_prepedit($file),
45                         force => 1);
46     +           $form->field(name => "newfile", 
47     +                        value => ! -e "$config{srcdir}/$file",
48     +                        force => 1);
49         }
50     -   
51     +   my $newfile = $form->field(name => "newfile");
52     +
53         if ($form->submitted eq "Cancel") {
54                 if ($newfile && defined $from) {
55                         redirect($q, "$config{url}/".htmlpage($from));
56     @@ -482,6 +485,16 @@
57         else {
58                 # save page
59                 check_canedit($page, $q, $session);
60     +           if (! -e "$config{srcdir}/$file" && ! $form->field(name => 'newfile')){
61     +                   $form->tmpl_param("page_gone", 1);
62     +                   $form->field(name => "newfile",
63     +                                value => 1, force => 1);
64     +                   $form->tmpl_param("page_select", 0);
65     +                   $form->field(name => "page", type => 'hidden');
66     +                   $form->field(name => "type", type => 'hidden');
67     +                   print $form->render(submit => \@buttons);
68     +                   return;
69     +           }
70                 
71                 my $content=$form->field('editcontent');
72      
73     @@ -512,8 +525,7 @@
74                                         force => 1);
75                                 $form->tmpl_param("page_conflict", 1);
76                                 $form->field("editcontent", value => $conflict, force => 1);
77     -                           $form->field(name => "comments", value => $form->field('comments'), force => 1);
78     -                           $form->field("do", "edit)");
79     +                           $form->field("do", "edit");
80                                 $form->tmpl_param("page_select", 0);
81                                 $form->field(name => "page", type => 'hidden');
82                                 $form->field(name => "type", type => 'hidden');
83     diff -urX /home/glasserc/ignorepats /home/glasserc/ikiclean/templates/editpage.tmpl /home/glasserc/ikidev/templates/editpage.tmpl
84     --- /home/glasserc/ikiclean/templates/editpage.tmpl 2007-02-11 21:40:35.046470000 -0800
85     +++ /home/glasserc/ikidev/templates/editpage.tmpl   2007-02-12 15:33:38.503571000 -0800
86     @@ -21,6 +21,15 @@
87      conflict and commit again to save your changes.
88      </p>
89      </TMPL_IF>
90     +<TMPL_IF NAME="PAGE_GONE">
91     +<p>
92     +<b>The page you were editing has disappeared.</b>
93     +</p>
94     +<p>
95     +Perhaps someone else has deleted it or moved it. If you want to recreate
96     +this page with your text, click "Save Page" again.
97     +</p>
98     +</TMPL_IF>
99      <TMPL_VAR FORM-START>
100      <div class="header">
101      <span><TMPL_VAR INDEXLINK>/ <TMPL_VAR FORM-TITLE></span>
102     @@ -28,6 +37,7 @@
103      <TMPL_VAR FIELD-DO>
104      <TMPL_VAR FIELD-FROM>
105      <TMPL_VAR FIELD-RCSINFO>
106     +<TMPL_VAR FIELD-NEWFILE>
107      <TMPL_IF NAME="PAGE_SELECT">
108      Page location: <TMPL_VAR FIELD-PAGE>
109      Page type: <TMPL_VAR FIELD-TYPE>