From 200d0fca370e113ecd31c38a31ba51c5532c94b6 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Sun, 8 Mar 2009 19:40:47 -0400 Subject: Dump untested updates so that others can have a look (I wont have time for a few weeks). --- doc/todo/mdwn_preview.mdwn | 215 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/mdwn_preview.mdwn b/doc/todo/mdwn_preview.mdwn index 3008eb529..bbb105041 100644 --- a/doc/todo/mdwn_preview.mdwn +++ b/doc/todo/mdwn_preview.mdwn @@ -87,3 +87,218 @@ remains. Some CSS to clean up the display of the live WMD preview would be good > I assume that is designed for websites that do not use markdown > internally. Doesn't it have a setting to leave it as markdown? >> Found setting, fixed. --[[Joey]] + +>>> As I noted above, I've been working on the non-markdown page issue. +>>> Below is my a new javascript file that I'm using, and below that a patch +>>> to enable it. This patch makes the normal usage prettier - you get +>>> a side panel with the live preview in it. It also adds a new config +>>> option, `wmd_use101api`, which turns on code that tries to use the +>>> wmd api. At the moment this code doesn't seem to work - moreover the +>>> code that uses the new API dies early, so any code after that point is +>>> completely untested. I will not +>>> get a chance to look at this again soon though, so I thought I'd post +>>> my progress so far. -- [[Will]] + + +Place the following file in `underlays/wmd/wmd-ikiwiki.js`. + +---- + + // This is some code to interface the WMD interface 1.0.1 with IkiWiki + // The WMD interface is planned to change, so this file will likely need + // updating in future. + + if (useWMDinterface) { + wmd_options = { autostart: false, output: "Markdown" }; + var instance = null; + + hook("onload", initwmd); + } else { + var typeSelector = document.getElementById("type"); + + var currentType = getType(typeSelector); + + if (currentType == "mdwn") { + wmd_options = { output: "Markdown" }; + document.getElementById("wmd-preview-container").style.hidden = false; + } else { + wmd_options = { autostart: false }; + document.getElementById("wmd-preview-container").style.hidden = true; + } + } + + function initwmd() { + if (!Attacklab || !Attacklab.wmd) { + alert("WMD hasn't finished loading!"); + return; + } + + var typeSelector = document.getElementById("type"); + + var currentType = getType(typeSelector); + + if (currentType == "mdwn") { + enableWMD(); + } + + typeSelector.onchange=function() { + var docType=getType(this); + + if (docType=="mdwn") { + enableWMD(); + } else { + disableWMD(); + } + } + } + + function getType(typeSelector) + { + if (typeSelector.nodeName.toLowerCase() == 'input') { + return typeSelector.getAttribute('value'); + } else if (typeSelector.nodeName.toLowerCase() == 'selector') { + return typeSelector.options[typeSelector.selectedIndex]; + } + return ""; + } + + function enableWMD() + { + var editContent = document.getElementById("editcontent"); + var previewDiv = document.getElementById("wmd-preview"); + var previewDivContainer = document.getElementById("wmd-preview-container"); + + previewDivContainer.style.hidden = false; + // editContent.style.width = previewDivContainer.style.width; + + /***** build the preview manager *****/ + var panes = {input:editContent, preview:previewDiv, output:null}; + var previewManager = new Attacklab.wmd.previewManager(panes); + + /***** build the editor and tell it to refresh the preview after commands *****/ + var editor = new Attacklab.wmd.editor(editContent,previewManager.refresh); + + // save everything so we can destroy it all later + instance = {ta:textarea, div:previewDiv, ed:editor, pm:previewManager}; + } + + function disableWMD() + { + document.getElementById("wmd-preview-container").style.hidden = true; + + if (instance != null) { + instance.pm.destroy(); + instance.ed.destroy(); + //inst.ta.style.width='100%' + } + instance = null; + } + + +---- + + diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm + index 9ddd237..743a0b8 100644 + --- a/IkiWiki/Plugin/wmd.pm + +++ b/IkiWiki/Plugin/wmd.pm + @@ -17,6 +17,13 @@ sub getsetup () { + return + plugin => { + safe => 1, + + rebuild => 1, + + }, + + wmd_use101api => { + + type => "boolean", + + description => "Use the advanced, but unstable, WMD api for markdown preview.", + + safe => 0, + + rebuild => 0, + }, + } + + @@ -24,29 +31,25 @@ sub formbuilder_setup (@) { + my %params=@_; + my $form=$params{form}; + + - return if ! defined $form->field("do"); + + return unless defined $form->field("do"); + + 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)); + -} + - + -sub include_javascript ($;$) { + - my $page=shift; + - my $absolute=shift; + - + - my $wmdjs=urlto("wmd/wmd.js", $page, $absolute); + - return <<"EOF" + - + - + -EOF + + $form->field("do") eq "create" || + + $form->field("do") eq "comment"; + + + + my $useAPI = $config{wmd_use101api}?'true':'false'; + + my $ikiwikijs = urlto("ikiwiki.js", undef, 1); + + my $wmdIkiwikijs = urlto("wmd-ikiwiki.js", undef, 1); + + my $wmdjs = urlto("wmd.js", undef, 1); + + + + my $previewScripts = <<"EOS"; + + + + + + + + + +EOS + + + + $form->tmpl_param("wmd_preview", $previewScripts); + } + + 1 + diff --git a/doc/style.css b/doc/style.css + index a6e6734..36c2b13 + --- a/doc/style.css + +++ b/doc/style.css + @@ -76,9 +76,16 @@ div.tags { + float: right; + } + + +/* + #editcontent { + width: 100%; + } + +*/ + + + +#wmd-preview-container { + + width: 49%; + + float: right; + +} + + img { + border-style: none; + diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl + index b1cf015..1d2f080 100644 + --- a/templates/editpage.tmpl + +++ b/templates/editpage.tmpl + @@ -15,6 +15,14 @@ Page type: + + + + + + +
+ +
+ +Live preview: + +
+ +
+ +
+ +
+
+ + Optional comment about this change:
-- cgit v1.2.3 From a948f6d275668236a2c005f14fcf713f9933d9d7 Mon Sep 17 00:00:00 2001 From: "http://www.cse.unsw.edu.au/~willu/" Date: Mon, 9 Mar 2009 08:39:42 -0400 Subject: Update the javascript - this now turns things on and off based on the type. It still has some display issues. --- doc/todo/mdwn_preview.mdwn | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/mdwn_preview.mdwn b/doc/todo/mdwn_preview.mdwn index bbb105041..c20314c28 100644 --- a/doc/todo/mdwn_preview.mdwn +++ b/doc/todo/mdwn_preview.mdwn @@ -120,10 +120,10 @@ Place the following file in `underlays/wmd/wmd-ikiwiki.js`. if (currentType == "mdwn") { wmd_options = { output: "Markdown" }; - document.getElementById("wmd-preview-container").style.hidden = false; + document.getElementById("wmd-preview-container").style.display = 'none'; } else { wmd_options = { autostart: false }; - document.getElementById("wmd-preview-container").style.hidden = true; + document.getElementById("wmd-preview-container").style.display = 'block'; } } @@ -138,7 +138,7 @@ Place the following file in `underlays/wmd/wmd-ikiwiki.js`. var currentType = getType(typeSelector); if (currentType == "mdwn") { - enableWMD(); + window.setTimeout(enableWMD,10); } typeSelector.onchange=function() { @@ -156,8 +156,9 @@ Place the following file in `underlays/wmd/wmd-ikiwiki.js`. { if (typeSelector.nodeName.toLowerCase() == 'input') { return typeSelector.getAttribute('value'); - } else if (typeSelector.nodeName.toLowerCase() == 'selector') { - return typeSelector.options[typeSelector.selectedIndex]; + } else if (typeSelector.nodeName.toLowerCase() == 'select') { + return typeSelector.value; + // return typeSelector.options[typeSelector.selectedIndex].innerText; } return ""; } @@ -168,7 +169,7 @@ Place the following file in `underlays/wmd/wmd-ikiwiki.js`. var previewDiv = document.getElementById("wmd-preview"); var previewDivContainer = document.getElementById("wmd-preview-container"); - previewDivContainer.style.hidden = false; + previewDivContainer.style.display = 'block'; // editContent.style.width = previewDivContainer.style.width; /***** build the preview manager *****/ @@ -179,17 +180,17 @@ Place the following file in `underlays/wmd/wmd-ikiwiki.js`. var editor = new Attacklab.wmd.editor(editContent,previewManager.refresh); // save everything so we can destroy it all later - instance = {ta:textarea, div:previewDiv, ed:editor, pm:previewManager}; + instance = {ta:editContent, div:previewDiv, ed:editor, pm:previewManager}; } function disableWMD() { - document.getElementById("wmd-preview-container").style.hidden = true; + document.getElementById("wmd-preview-container").style.display = 'none'; if (instance != null) { instance.pm.destroy(); instance.ed.destroy(); - //inst.ta.style.width='100%' + // inst.ta.style.width='100%' } instance = null; } -- cgit v1.2.3 From 35460e3153286381a6019e5afd46b2880a95cb88 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 17 Mar 2009 21:22:26 +0100 Subject: new wishlist item, patch included --- doc/todo/natural_sorting.mdwn | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 doc/todo/natural_sorting.mdwn (limited to 'doc/todo') diff --git a/doc/todo/natural_sorting.mdwn b/doc/todo/natural_sorting.mdwn new file mode 100644 index 000000000..84f35c5da --- /dev/null +++ b/doc/todo/natural_sorting.mdwn @@ -0,0 +1,16 @@ +[[!tag wishlist]] +[[!tag patch]] + +the inline plugin's sorting is plain lexical, thich may not be appropriate for +page titles if they have numeric components. the +[Sort::Naturally](http://search.cpan.org/dist/Sort-Naturally/) perl module +provides an algorithm for that. + +there is a +[patch](http://github.com/github076986099/ikiwiki/commit/25617577746dc1e4ab5ab69aa70d633daddcc01b) +attached that makes the [[plugins/inline]] plugin use Sort::Naturally if sort +is set to "title_natural". + +the current patch uses `require Sort::Naturally`, so +[libsort-naturally-perl](http://packages.debian.org/libsort-naturally-perl) +does not become a dependency; it might be worth suggesting, though. -- cgit v1.2.3 From 888e67bf4e44b66dcecde07395a50135e19b911d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 19 Mar 2009 14:03:38 -0400 Subject: github error and comment --- doc/todo/natural_sorting.mdwn | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/natural_sorting.mdwn b/doc/todo/natural_sorting.mdwn index 84f35c5da..2215d533e 100644 --- a/doc/todo/natural_sorting.mdwn +++ b/doc/todo/natural_sorting.mdwn @@ -14,3 +14,9 @@ is set to "title_natural". the current patch uses `require Sort::Naturally`, so [libsort-naturally-perl](http://packages.debian.org/libsort-naturally-perl) does not become a dependency; it might be worth suggesting, though. + +> Great, but all I get from the github link is a server error page, so I +> have not figured out how to merge the patch. --[[Joey]] +> +> See also: [[inline:_numerical_ordering_by_title]] (I probably prefer your +> approach..) --[[Joey]] -- cgit v1.2.3 From 86956b3392f7e768fa8f527a0b3a4b7d1a080aef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 19 Mar 2009 15:36:31 -0400 Subject: title_natural patch merged --- debian/changelog | 7 +++++++ doc/todo/inline:_numerical_ordering_by_title.mdwn | 2 ++ doc/todo/natural_sorting.mdwn | 5 ++--- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'doc/todo') diff --git a/debian/changelog b/debian/changelog index a8f47bfc7..8266afa09 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ikiwiki (3.09) UNRELEASED; urgency=low + + * inline: Add title_natural sort order, using Sort::Naturally + (chrysn) + + -- Joey Hess Thu, 19 Mar 2009 15:32:49 -0400 + ikiwiki (3.08) unstable; urgency=low * git: Fix utf-8 encoding of author names. diff --git a/doc/todo/inline:_numerical_ordering_by_title.mdwn b/doc/todo/inline:_numerical_ordering_by_title.mdwn index 3f6c8b598..3d7424b3f 100644 --- a/doc/todo/inline:_numerical_ordering_by_title.mdwn +++ b/doc/todo/inline:_numerical_ordering_by_title.mdwn @@ -1,6 +1,8 @@ Could you please add numerical ordering by title to [[inline|plugins/inline]] plugin? Now I can do only alphabetical order by title, but sometime it's not enough. +> Implemented, see [[natural_sorting]] [[!tag done]] --[[Joey]] + BTW, it seems that ordering by title is rather ordering by filename of page. For me "title" means title of page I can set using `title` parameter of [[meta|plugins/meta]] plugin :) diff --git a/doc/todo/natural_sorting.mdwn b/doc/todo/natural_sorting.mdwn index 2215d533e..faa523043 100644 --- a/doc/todo/natural_sorting.mdwn +++ b/doc/todo/natural_sorting.mdwn @@ -15,8 +15,7 @@ the current patch uses `require Sort::Naturally`, so [libsort-naturally-perl](http://packages.debian.org/libsort-naturally-perl) does not become a dependency; it might be worth suggesting, though. -> Great, but all I get from the github link is a server error page, so I -> have not figured out how to merge the patch. --[[Joey]] -> > See also: [[inline:_numerical_ordering_by_title]] (I probably prefer your > approach..) --[[Joey]] + +> [[applied|done]] -- cgit v1.2.3 From 1d9b58b0d4efe4ad4f752eeda7e52b263edaec87 Mon Sep 17 00:00:00 2001 From: chrysn Date: Fri, 20 Mar 2009 05:30:28 -0400 Subject: (replace github link with ikwiki gitweb link so that github branch can go away) --- doc/todo/natural_sorting.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/todo') diff --git a/doc/todo/natural_sorting.mdwn b/doc/todo/natural_sorting.mdwn index faa523043..5df17e95b 100644 --- a/doc/todo/natural_sorting.mdwn +++ b/doc/todo/natural_sorting.mdwn @@ -7,7 +7,7 @@ page titles if they have numeric components. the provides an algorithm for that. there is a -[patch](http://github.com/github076986099/ikiwiki/commit/25617577746dc1e4ab5ab69aa70d633daddcc01b) +[patch](http://git.ikiwiki.info/?p=ikiwiki;a=commit;h=55b83cb7bd1cd7c60bb45dc22c3745dd80a63fed) attached that makes the [[plugins/inline]] plugin use Sort::Naturally if sort is set to "title_natural". -- cgit v1.2.3 From 82281d1aef347080ff235ad18e92613012093f49 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 24 Mar 2009 08:21:22 +0100 Subject: wishlist, patch: inline autotitles --- doc/todo/inline_autotitles.mdwn | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 doc/todo/inline_autotitles.mdwn (limited to 'doc/todo') diff --git a/doc/todo/inline_autotitles.mdwn b/doc/todo/inline_autotitles.mdwn new file mode 100644 index 000000000..9846687e9 --- /dev/null +++ b/doc/todo/inline_autotitles.mdwn @@ -0,0 +1,45 @@ +[[!tag wishlist]] +[[!tag patch]] + +for inlines of pages which follow a certain scheme, it might not be required to +set the title for each individual post, but to automatically set the title. +this can either be based on timestamp formatting, or use the already existing +munging mechanism, which appends numbers to page titles in case that page +already exists. + +two [patches][1] set inline up for that, adding an additional `autotitle` +parameter. if that is given, the regular input of the inline postform will be +replaced with a hidden input of that text. in addition, the empty title is +permitted (both for autotitle and regular titles, as they go in the same GET +parameter, `title`). as the empty page title is illegal, munging is used, +resulting in ascending numeric page titles to be created. + +the second patch is actually a one-liner, filtering the title through sprintf. + +### potential user interaction issues + +this has two side effects which have to be considered: first, the empty page +title is accepted also in normal postforms (previously, this resulted in a "bad +page name" error); second, entering a percent sign in that field might result +in unexpexted sprintf substitution (sprintf might not even substitute for +common uses of percent as in "reach 10% market share", but might in others as +in "the 10%-rule"). + +both can be circumvented by using another GET parameter for autotexts, for +which i could provide a patch. (as of writing this, i think i'll do that.) + +### potential security issues + +* the autotitle's value is directly output through the template (but that's + done in other places as well, so i assume it's safe) +* i don't know if anything bad can happen if unfiltered content is passed to + POSIX::strftime. + +### further extension + +having a pre-filled input field instead of an unchangable hidden input might be +cool (eg for creating an entry with yesterday's date), but would be a bit of a +problem with static pages. javascript could help with the date part, but name +munging would be yet another thing. + +[1]: http://... -- cgit v1.2.3 From ce81e2e286ed5435eb114de21be73cd02da8a666 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 24 Mar 2009 08:25:35 +0100 Subject: (urls for inline autotitle) --- doc/todo/inline_autotitles.mdwn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/inline_autotitles.mdwn b/doc/todo/inline_autotitles.mdwn index 9846687e9..afc726c48 100644 --- a/doc/todo/inline_autotitles.mdwn +++ b/doc/todo/inline_autotitles.mdwn @@ -7,7 +7,7 @@ this can either be based on timestamp formatting, or use the already existing munging mechanism, which appends numbers to page titles in case that page already exists. -two [patches][1] set inline up for that, adding an additional `autotitle` +two patches ([1], [2]) set inline up for that, adding an additional `autotitle` parameter. if that is given, the regular input of the inline postform will be replaced with a hidden input of that text. in addition, the empty title is permitted (both for autotitle and regular titles, as they go in the same GET @@ -42,4 +42,5 @@ cool (eg for creating an entry with yesterday's date), but would be a bit of a problem with static pages. javascript could help with the date part, but name munging would be yet another thing. -[1]: http://... +[1]: http://github.com/github076986099/ikiwiki/commit/b568eb257a3ef5ff49a84ac00a3a7465b643c1e1 +[2]: http://github.com/github076986099/ikiwiki/commit/34bc82f232be141edf036d35e8ef5aa289415072 -- cgit v1.2.3 From 16735bd194095306e4a8f6e2b8d771068e19e497 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 24 Mar 2009 09:20:18 +0100 Subject: (corrected bug in inline autotitle description) --- doc/todo/inline_autotitles.mdwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/inline_autotitles.mdwn b/doc/todo/inline_autotitles.mdwn index afc726c48..4c45ebf00 100644 --- a/doc/todo/inline_autotitles.mdwn +++ b/doc/todo/inline_autotitles.mdwn @@ -14,14 +14,14 @@ permitted (both for autotitle and regular titles, as they go in the same GET parameter, `title`). as the empty page title is illegal, munging is used, resulting in ascending numeric page titles to be created. -the second patch is actually a one-liner, filtering the title through sprintf. +the second patch is actually a one-liner, filtering the title through strftime. ### potential user interaction issues this has two side effects which have to be considered: first, the empty page title is accepted also in normal postforms (previously, this resulted in a "bad page name" error); second, entering a percent sign in that field might result -in unexpexted sprintf substitution (sprintf might not even substitute for +in unexpexted strftime substitution (strftime might not even substitute for common uses of percent as in "reach 10% market share", but might in others as in "the 10%-rule"). -- cgit v1.2.3 From fcf72069cb9c70a353f9fb8eca7d2a36fc883748 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 24 Mar 2009 10:55:27 +0100 Subject: inline autotitles: additional patch --- doc/todo/inline_autotitles.mdwn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'doc/todo') diff --git a/doc/todo/inline_autotitles.mdwn b/doc/todo/inline_autotitles.mdwn index 4c45ebf00..9d3c986ed 100644 --- a/doc/todo/inline_autotitles.mdwn +++ b/doc/todo/inline_autotitles.mdwn @@ -25,8 +25,8 @@ in unexpexted strftime substitution (strftime might not even substitute for common uses of percent as in "reach 10% market share", but might in others as in "the 10%-rule"). -both can be circumvented by using another GET parameter for autotexts, for -which i could provide a patch. (as of writing this, i think i'll do that.) +both can be circumvented by using another GET parameter for autotexts, as +implemented in [3]. ### potential security issues @@ -44,3 +44,4 @@ munging would be yet another thing. [1]: http://github.com/github076986099/ikiwiki/commit/b568eb257a3ef5ff49a84ac00a3a7465b643c1e1 [2]: http://github.com/github076986099/ikiwiki/commit/34bc82f232be141edf036d35e8ef5aa289415072 +[3]: http://github.com/github076986099/ikiwiki/commit/40dc10a4ec7809e401b4497c2abccfba30f7a2af -- cgit v1.2.3 From ca862d5127192392cd4614ff60504ec5bb28d512 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 24 Mar 2009 18:23:44 -0400 Subject: inline autotitles: open issue --- doc/todo/inline_autotitles.mdwn | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'doc/todo') diff --git a/doc/todo/inline_autotitles.mdwn b/doc/todo/inline_autotitles.mdwn index 9d3c986ed..8bf71deae 100644 --- a/doc/todo/inline_autotitles.mdwn +++ b/doc/todo/inline_autotitles.mdwn @@ -27,6 +27,10 @@ in "the 10%-rule"). both can be circumvented by using another GET parameter for autotexts, as implemented in [3]. +> this patch still does not work perfectly; especially, it should make a +> distinction between "autotitle is set but equal ''" (in which case it +> should create a page named `1.mdwn`, and "autotitle is not set, and title is +> equal ''" (in which case it should display the old error message) --[[chrysn]] ### potential security issues -- cgit v1.2.3