From 72dd9a9a0434e1682d7e27b935500c010a03dddc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 7 Mar 2009 18:54:26 -0500 Subject: make wmd comment support comment editing (I think) --- IkiWiki/Plugin/wmd.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm index 3372ffe38..9e9f17f7f 100644 --- a/IkiWiki/Plugin/wmd.pm +++ b/IkiWiki/Plugin/wmd.pm @@ -26,8 +26,9 @@ sub formbuilder_setup (@) { return if ! defined $form->field("do"); - return unless (($form->field("do") eq "edit") || - ($form->field("do") eq "create")); + return unless $form->field("do") eq "edit" || + $form->field("do") eq "create" || + $form->field("do") eq "comment"; $form->tmpl_param("wmd_preview", "
\n". include_javascript(undef, 1)); -- cgit v1.2.3 From 9a82ef32b96b07278b90a1219fa555fa2a970912 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 7 Mar 2009 19:22:27 -0500 Subject: look for wmd/wmd.js This means that the underlay needs to have a wmd/wmd/wmd.js, which is a trifle weird, but it isolates all the wmd stuff in a single wmd subdirectory of the built wiki. The wmd/images creating a toplevel images directory was particularly bad. --- IkiWiki/Plugin/wmd.pm | 2 +- doc/plugins/wmd.mdwn | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm index 9e9f17f7f..bdbcecc06 100644 --- a/IkiWiki/Plugin/wmd.pm +++ b/IkiWiki/Plugin/wmd.pm @@ -38,7 +38,7 @@ sub include_javascript ($;$) { my $page=shift; my $absolute=shift; - return ''."\n"; } diff --git a/doc/plugins/wmd.mdwn b/doc/plugins/wmd.mdwn index 31a508cdb..dc9a30703 100644 --- a/doc/plugins/wmd.mdwn +++ b/doc/plugins/wmd.mdwn @@ -6,10 +6,11 @@ To use the plugin, you will need to install WMD. Download the [WMD source](http://wmd-editor.com/downloads/wmd-1.0.1.zip). In that zip file -you'll find a few example html files, a readme and `wmd` directory. Move the -`wmd` directory into the ikiwiki `underlaydir` directory (ie -`/usr/share/ikiwiki/`). You should now have a `wmd/wmd.js` file as well as -some other javascript files and an images directory in the same place. +you'll find a few example html files, a readme and `wmd` directory. Create +a 'wmd' subdirectory in the ikiwiki `underlaydir` directory (ie `sudo mkdir +/usr/share/ikiwiki/wmd`). Move the `wmd` directory into the directory you +made. You should now have a `wmd/wmd/wmd.js` file as well as some other +javascript files and an images directory in the same place. Note that the WMD plugin does **not** handle ikiwiki directives. For this reason the normal `preview` button remains. -- cgit v1.2.3 From 1bf100cfdebee69fc53d2cdf77d626b9fe8be987 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 8 Mar 2009 13:11:26 -0400 Subject: configure wmd to leave text in markdown --- IkiWiki/Plugin/wmd.pm | 13 ++++++++++--- doc/todo/mdwn_preview.mdwn | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm index bdbcecc06..9ddd237ab 100644 --- a/IkiWiki/Plugin/wmd.pm +++ b/IkiWiki/Plugin/wmd.pm @@ -37,9 +37,16 @@ sub formbuilder_setup (@) { sub include_javascript ($;$) { my $page=shift; my $absolute=shift; - - return ''."\n"; + + my $wmdjs=urlto("wmd/wmd.js", $page, $absolute); + return <<"EOF" + + +EOF } 1 diff --git a/doc/todo/mdwn_preview.mdwn b/doc/todo/mdwn_preview.mdwn index 2fa460336..3008eb529 100644 --- a/doc/todo/mdwn_preview.mdwn +++ b/doc/todo/mdwn_preview.mdwn @@ -85,4 +85,5 @@ remains. Some CSS to clean up the display of the live WMD preview would be good > converted from mdwn to html. I think that wmd is converting the mdwn > into html when the form is posted, so it would also save like that. > I assume that is designed for websites that do not use markdown -> internally. Doesn't it have a setting to leave it as markdown? --[[Joey]] +> internally. Doesn't it have a setting to leave it as markdown? +>> Found setting, fixed. --[[Joey]] -- cgit v1.2.3 From d3b4c2dbd13f6721042db7a7b6843851c9037551 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 8 Mar 2009 18:46:18 -0400 Subject: avoid potential infinite loop in smiley expansion - In 3.05, ikiwiki began expanding templates in scan mode, for annoying, expensive, but ultimatly necessary reasons of correctness. - Smiley processing has a bug: It inserts a span for the smiley, and then continues searching forward in the content for more, starting at $end_of_smiley+1. Which means it searches for smilies in the span too! And if it somehow finds one, we get an infinite loop here. - This bug can, probably, only be tickled if a htmllink to show the smiley fails, because the smiley file doesn't exist, or because ikiwiki doesn't know about it. In that case, a link will be inserted to _create_ the missing page, and that link will include the smiley inside the . - When a template is expanded in scan mode, and it contains an inline, the sanitize hook is run during scan mode, which never happened before. That causes the smiley processor to run, before ikiwiki is, necessarily, aware that all the smiley files exist (depending on scan order). So it inserts creation links for them, and triggers the bug. I've put in the simple fix of jumping forward past the inserted span, and it does fix the problem. I will need to look in a bit more detail into why an inline nested inside a template is fully expanded during the scan pass -- that really shouldn't be necessary, and it makes things much slower than they need to be. --- IkiWiki/Plugin/smiley.pm | 6 +++--- debian/changelog | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm index 1697a37c1..0d77916d0 100644 --- a/IkiWiki/Plugin/smiley.pm +++ b/IkiWiki/Plugin/smiley.pm @@ -87,10 +87,10 @@ MATCH: while (m{(?:^|(?<=\s|>))(\\?)$smiley_regexp(?:(?=\s|<)|$)}g) { } else { # Replace the smiley with its expanded value. - substr($_, $spos, length($smiley))= - htmllink($params{page}, $params{destpage}, + my $link=htmllink($params{page}, $params{destpage}, $smileys{$smiley}, linktext => $smiley); - pos=$epos+1; + substr($_, $spos, length($smiley))=$link; + pos=$epos+length($link); } } diff --git a/debian/changelog b/debian/changelog index d6ee6fd8a..e5d522200 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ ikiwiki (3.07) UNRELEASED; urgency=low * Updated French translation (Jean-Luc Coulon). Closes: #518510 * wmd: New plugin contributed by William Uther to support the WMD Wysiwym markdown editor. + * smiley: Avoid infinite loop in smiley expansion. Closes: #518805 -- Joey Hess Thu, 05 Mar 2009 15:43:02 -0500 -- cgit v1.2.3 From dd2fa2efb956f8af6c98d37f8cfd280df2f97cb5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 8 Mar 2009 18:57:47 -0400 Subject: When loading a template in scan mode, let preprocess know it only needs to scan. This makes wikis such as zack's much faster in the scan pass. In that pass, when a template contains an inline, there is no reason to process the entire inline and all its pages. I'd forgotten to pass along the flag to let preprocess() know it was in scan mode, leading to much unncessary churning. --- IkiWiki/Plugin/template.pm | 6 +++++- debian/changelog | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index b872f0962..b6097bb49 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -69,9 +69,13 @@ sub preprocess (@) { } } + # This needs to run even in scan mode, in order to process + # links and other metadata includes via the template. + my $scan=! defined wantarray; + return IkiWiki::preprocess($params{page}, $params{destpage}, IkiWiki::filter($params{page}, $params{destpage}, - $template->output)); + $template->output), $scan); } 1 diff --git a/debian/changelog b/debian/changelog index e5d522200..95d414bc7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ ikiwiki (3.07) UNRELEASED; urgency=low * wmd: New plugin contributed by William Uther to support the WMD Wysiwym markdown editor. * smiley: Avoid infinite loop in smiley expansion. Closes: #518805 + * template: When loading a template in scan mode, let preprocess + know it only needs to scan. -- Joey Hess Thu, 05 Mar 2009 15:43:02 -0500 -- cgit v1.2.3