From 52e16d4ec9aa0ec896dd8f0d8651bc5f7fb71531 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 17 Mar 2008 21:28:31 -0400 Subject: [PATCH] * Record new pages in %pagesources temporarily when previewing so that things that need to know the page source or type can query it from there. Fixes previewing of tables when creating a new page. --- IkiWiki/CGI.pm | 10 ++++++++++ debian/changelog | 3 +++ ...preview_does_not_work_on_new_page_with_a_table.mdwn | 2 ++ 3 files changed, 15 insertions(+) diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 042e168aa..470677088 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -344,6 +344,12 @@ sub cgi_editpage ($$) { #{{{ return; } elsif ($form->submitted eq "Preview") { + my $new=not exists $pagesources{$page}; + if ($new) { + # temporarily record its type + $pagesources{$page}=$page.".".$type; + } + my $content=$form->field('editcontent'); run_hooks(editcontent => sub { $content=shift->( @@ -358,6 +364,10 @@ sub cgi_editpage ($$) { #{{{ linkify($page, $page, preprocess($page, $page, filter($page, $page, $content), 0, 1)))); + + if ($new) { + delete $pagesources{$page}; + } # previewing may have created files on disk saveindex(); } diff --git a/debian/changelog b/debian/changelog index dc950790f..2b1193edf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -47,6 +47,9 @@ ikiwiki (2.41) UNRELEASED; urgency=low * Correct bug in encoding of %pagestate keys, fixes edittemplate. * Detect invalid pagespecs and do not merge them in add_depends, as that can result in a broken merged pagespec that matches nothing. + * Record new pages in %pagesources temporarily when previewing so that + things that need to know the page source or type can query it from there. + Fixes previewing of tables when creating a new page. -- martin f. krafft Sun, 02 Mar 2008 17:46:38 +0100 diff --git a/doc/bugs/page_preview_does_not_work_on_new_page_with_a_table.mdwn b/doc/bugs/page_preview_does_not_work_on_new_page_with_a_table.mdwn index 6c999e0f7..65dffd671 100644 --- a/doc/bugs/page_preview_does_not_work_on_new_page_with_a_table.mdwn +++ b/doc/bugs/page_preview_does_not_work_on_new_page_with_a_table.mdwn @@ -1 +1,3 @@ If the table plugin is enabled, then creating a page, inserting a `\[[!table ...]` and clicking preview yields "htmlization of not supported" (sic). --[[madduck]] + +[[fix0red|done]] --[[Joey]] -- 2.26.2