]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Fix some issues with toggles in preview mode.
authorJoey Hess <joey@kodama.kitenet.net>
Mon, 29 Oct 2007 21:16:10 +0000 (17:16 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Mon, 29 Oct 2007 21:16:10 +0000 (17:16 -0400)
IkiWiki/Plugin/toggle.pm
debian/changelog
doc/bugs/bug_when_toggling_in_a_preview_page.mdwn

index 3f9c4867256ab0f9aa9f23bd1026f9594ee27a39..df5a2a7373290026a11910b97b94a291f24eed5c 100644 (file)
@@ -80,7 +80,13 @@ sub preprocess_toggle (@) { #{{{
        my %params=(id => "default", text => "more", @_);
 
        my $id=genid($params{page}, $params{id});
-       return "<a class=\"toggle\" href=\"#$id\">$params{text}</a>";
+       if (! $params{preview}) {
+               return "<a class=\"toggle\" href=\"#$id\">$params{text}</a>";
+       }
+       else {
+               return "$params{text} ".
+                       gettext("(not toggleable in preview mode)");
+       }
 } # }}}
 
 sub preprocess_toggleable (@) { #{{{
index 15d60114eaf6f8e5e1803b2b6c0b3a29a0800f2c..9684a02d5a6e53806d033b44d25c6d1026da67db 100644 (file)
@@ -1,3 +1,9 @@
+ikiwiki (2.12) UNRELEASED; urgency=low
+
+  * Fix some issues with toggles in preview mode.
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 29 Oct 2007 17:15:04 -0400
+
 ikiwiki (2.11) unstable; urgency=low
 
   * Correct a pair of logic errors that triggered if svnpath was empty.
index 2d5b881c249c83927aaf95bb37879ba5d45fea21..2f1b5f68c6bd98bdaa9826935563a14f0363895c 100644 (file)
@@ -1,3 +1,29 @@
 When toggling an item while being in a web-editing session in the *Preview* frame,
 you'll lose the context of the editing session and will be directed to the wiki's
 main page instead.  --[[tschwinge]]
+
+Making toggles actually work in preview is hard: The toggle plugin uses
+a format hook to add javascript to the page, after htmlscrubber runs. Page
+preview does not currently run the format hook.
+
+I think that is not done because the format hook is supposed to get the
+entire html file contents, including the html head and body elements, and
+in the case of page preview, such a full page is not being generated,
+instead it's just inlining the previewed page into the edit form.
+
+If the format hook were called on this partial data, hooks that looked for
+body tags etc would break. OTOH, if in preview mode it were run on the
+whole edit form page, ones like toc that parse the page would have
+unexpected results, since they would also parse the edit form.
+
+(Also, if format were run in preview mode then plugins like linkmap, which
+generate object files in their format hook, would need to be changed to not
+do this during preview (to avoid preview mode writing files to the wiki).
+So the format hook would need to be passed a flag indicating preview mode.)
+
+So I don't see a good way to call the format hook in preview mode.
+Failing that, the best I can do is make the toggle plugin detect preview
+mode, and generate nonfunctional toggles that warn they're not toggleable
+in preview mode. I've [[done]] that, which also fixes the incidental issue of
+the toggle link pointing to the wrong place, which was due to the use of the
+&lt;base&gt; tag in the preview page template. --[[Joey]]