]> sipb.mit.edu Git - ikiwiki.git/commitdiff
When editing a page, show that page's sidebar. (Thanks, privat)
authorJoey Hess <joey@kitenet.net>
Wed, 9 Jun 2010 20:00:12 +0000 (16:00 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 9 Jun 2010 20:00:12 +0000 (16:00 -0400)
IkiWiki.pm
IkiWiki/Plugin/editpage.pm
debian/changelog
doc/bugs/misctemplate_does_not_respect_the_current_page___40__if_any__41__.mdwn

index 27fa4ca17dd3a17fa6768acb5e496758a3eb55a7..d2ed999239b16a36de61bfcff65f892bb8bbd642 100644 (file)
@@ -1739,11 +1739,20 @@ sub template ($;@) {
 sub misctemplate ($$;@) {
        my $title=shift;
        my $content=shift;
 sub misctemplate ($$;@) {
        my $title=shift;
        my $content=shift;
+       my %params=@_;
        
        my $template=template("page.tmpl");
 
        
        my $template=template("page.tmpl");
 
+       my $page="";
+       if (exists $params{page}) {
+               $page=delete $params{page};
+       }
        run_hooks(pagetemplate => sub {
        run_hooks(pagetemplate => sub {
-               shift->(page => "", destpage => "", template => $template);
+               shift->(
+                       page => $page,
+                       destpage => $page,
+                       template => $template,
+               );
        });
        templateactions($template, "");
 
        });
        templateactions($template, "");
 
@@ -1754,7 +1763,7 @@ sub misctemplate ($$;@) {
                content => $content,
                baseurl => baseurl(),
                html5 => $config{html5},
                content => $content,
                baseurl => baseurl(),
                html5 => $config{html5},
-               @_,
+               %params,
        );
        
        return $template->output;
        );
        
        return $template->output;
index 670eedfd97699eee7b3eca3ce112cda5944d3d09..aa73eb87db20e2acf134f961ad52641dfc72774a 100644 (file)
@@ -312,7 +312,8 @@ sub cgi_editpage ($$) {
                        $form->title(sprintf(gettext("editing %s"), pagetitle($page)));
                }
                
                        $form->title(sprintf(gettext("editing %s"), pagetitle($page)));
                }
                
-               showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl);
+               showform($form, \@buttons, $session, $q,
+                       forcebaseurl => $baseurl, page => $page);
        }
        else {
                # save page
        }
        else {
                # save page
@@ -329,7 +330,8 @@ sub cgi_editpage ($$) {
                        $form->field(name => "page", type => 'hidden');
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        $form->field(name => "page", type => 'hidden');
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
-                       showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl);
+                       showform($form, \@buttons, $session, $q,
+                               forcebaseurl => $baseurl, page => $page);
                        exit;
                }
                elsif ($form->field("do") eq "create" && $exists) {
                        exit;
                }
                elsif ($form->field("do") eq "create" && $exists) {
@@ -343,7 +345,8 @@ sub cgi_editpage ($$) {
                                value => readfile("$config{srcdir}/$file").
                                         "\n\n\n".$form->field("editcontent"),
                                force => 1);
                                value => readfile("$config{srcdir}/$file").
                                         "\n\n\n".$form->field("editcontent"),
                                force => 1);
-                       showform($form, \@buttons, $session, $q, forcebaseurl => $baseurl);
+                       showform($form, \@buttons, $session, $q,
+                               forcebaseurl => $baseurl, page => $page);
                        exit;
                }
                        
                        exit;
                }
                        
@@ -384,7 +387,7 @@ sub cgi_editpage ($$) {
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
-                               forcebaseurl => $baseurl);
+                               forcebaseurl => $baseurl, page => $page);
                        exit;
                }
                
                        exit;
                }
                
@@ -423,7 +426,7 @@ sub cgi_editpage ($$) {
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
                        $form->field(name => "type", type => 'hidden');
                        $form->title(sprintf(gettext("editing %s"), $page));
                        showform($form, \@buttons, $session, $q,
-                               forcebaseurl => $baseurl);
+                               forcebaseurl => $baseurl, page => $page);
                }
                else {
                        # The trailing question mark tries to avoid broken
                }
                else {
                        # The trailing question mark tries to avoid broken
index 36848d680461a5897eef6ea92dcacb1d78d22756..66d525572dbaef86557c0664b73c60ea3b6f57fc 100644 (file)
@@ -6,6 +6,7 @@ ikiwiki (3.20100609) unstable; urgency=low
   * Remove example blog tag pages; allow autotag creation to create them
     when used.
   * Fix support for globbing in tagged() pagespecs.
   * Remove example blog tag pages; allow autotag creation to create them
     when used.
   * Fix support for globbing in tagged() pagespecs.
+  * When editing a page, show that page's sidebar. (Thanks, privat)
 
  -- Joey Hess <joeyh@debian.org>  Mon, 31 May 2010 20:44:17 -0400
 
 
  -- Joey Hess <joeyh@debian.org>  Mon, 31 May 2010 20:44:17 -0400
 
index 58cf9d737a1f1454c968b392c6b7e5b602a5e80e..2ef5cdba3d56e0cd85271108518bfda2dc148a2b 100644 (file)
@@ -18,6 +18,12 @@ But it causes some nasty bugs for plugins that use the pagetemplate hook. It is
 * -> Problem: 404, the browser goes to "/bar/foo" 
 * -> Was expected: the browser goes to "/foo"
 
 * -> Problem: 404, the browser goes to "/bar/foo" 
 * -> Was expected: the browser goes to "/foo"
 
+> You must have a locally modified `page.tmpl` that omits the "TMPL_IF DYNAMIC"
+> that adds a `<base>` tag. That is needed to make all links displayed by
+> cgis work reliably. Not just in this page editing case.
+> The [[version_3.20100515]] announcment mentions that you need to
+> update old `page.tmpl` files to include that on upgrade. --[[Joey]]
+
 ### A second example
 
 * create "/bar/sidebar.mdwn" with "world"
 ### A second example
 
 * create "/bar/sidebar.mdwn" with "world"
@@ -28,6 +34,10 @@ But it causes some nasty bugs for plugins that use the pagetemplate hook. It is
 * -> Problem: the sidebar now shows the foo link (it is the root sidebar!)
 * -> Was expecte : the sidebar displays "world"
 
 * -> Problem: the sidebar now shows the foo link (it is the root sidebar!)
 * -> Was expecte : the sidebar displays "world"
 
+> One could argue that the behavior here is right, or wrong. 
+> Is a page edit page really the same as the page being edited?
+> The next case is more clear.. --[[Joey]]
+
 ### A last example
 
 * with the web browser edit the page "bar"
 ### A last example
 
 * with the web browser edit the page "bar"
@@ -36,6 +46,8 @@ But it causes some nasty bugs for plugins that use the pagetemplate hook. It is
 * -> Problem: the sidebar still displays the foo link
 * -> Was expected: the sidebar display "goodby"
 
 * -> Problem: the sidebar still displays the foo link
 * -> Was expected: the sidebar display "goodby"
 
+> I think this is worth fixing. --[[Joey]]
+
 ## Some superficial hacking
 
 With the following workaround hacks, I manage to solve the 3 examples shown above:
 ## Some superficial hacking
 
 With the following workaround hacks, I manage to solve the 3 examples shown above:
@@ -47,4 +59,9 @@ With the following workaround hacks, I manage to solve the 3 examples shown abov
 <pre>my %params=@_;
 shift->(page => $params{page}, destpage => $params{destpage}, template => $template);</pre>
 
 <pre>my %params=@_;
 shift->(page => $params{page}, destpage => $params{destpage}, template => $template);</pre>
 
-I do not guarantee (I do not even expect) that it is the proper way to solve this bug but it may help developers to find and solve the real problem. 
+I do not guarantee (I do not even expect) that it is the proper way to solve
+this bug but it may help developers to find and solve the real problem. 
+
+> Oh, it's pretty reasonable. I don't think it breaks anything. :)
+> [[done]]
+> --[[Joey]]