diff options
author | Amitai Schlair <schmonz-web-ikiwiki@schmonz.com> | 2013-03-17 15:01:13 -0400 |
---|---|---|
committer | Amitai Schlair <schmonz-web-ikiwiki@schmonz.com> | 2013-03-17 15:01:13 -0400 |
commit | 137ed653ea6b080d540f0740e280e22aa2d40e43 (patch) | |
tree | 966cdf5eb9326f1e2c91ebe72eb867928506c8a9 | |
parent | b5bbe66b178a6634a37f6597e55272e8a6869263 (diff) | |
parent | 030c7a4f8b06b097e18f638b0650baa966c50964 (diff) | |
download | ikiwiki-137ed653ea6b080d540f0740e280e22aa2d40e43.tar ikiwiki-137ed653ea6b080d540f0740e280e22aa2d40e43.tar.gz |
Merge branch 'master' into fancypodcast
Conflicts:
doc/todo/fancypodcast.mdwn
22 files changed, 583 insertions, 24 deletions
diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 38f090ff7..4a9bf58db 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -72,6 +72,9 @@ sub preprocess (@) { $common_prefix=IkiWiki::dirname($common_prefix); } + # Set this to 1 or more spaces to pretty-print maps for debugging + my $spaces = ""; + # Create the map. my $parent=""; my $indent=0; @@ -94,33 +97,37 @@ sub preprocess (@) { if defined $common_prefix && length $common_prefix; my $depth = ($item =~ tr/\//\//) + 1; my $baseitem=IkiWiki::dirname($item); - my $parentbase=IkiWiki::dirname($parent); - while (length $parentbase && length $baseitem && $baseitem !~ /^\Q$parentbase\E(\/|$)/) { - $parentbase=IkiWiki::dirname($parentbase); + while (length $parent && length $baseitem && $baseitem !~ /^\Q$parent\E(\/|$)/) { + $parent=IkiWiki::dirname($parent); last if length $addparent && $baseitem =~ /^\Q$addparent\E(\/|$)/; $addparent=""; - $indent--; - $map .= "</li>\n"; - if ($indent > 0) { - $map .= "</ul>\n"; + $map .= ($spaces x $indent) . "</li>\n"; + if ($indent > 1) { + $map .= ($spaces x $indent) . "</ul><map:collapse>\n"; } + $indent--; } while ($depth < $indent) { - $indent--; - $map .= "</li>\n"; - if ($indent > 0) { - $map .= "</ul>\n"; + $map .= ($spaces x $indent) . "</li>\n"; + if ($indent > 1) { + $map .= ($spaces x $indent) . "</ul>\n"; } + $indent--; } my @bits=split("/", $item); my $p=""; - $indent++ unless length $parent; $p.="/".shift(@bits) for 1..$indent; while ($depth > $indent) { - if (@bits && !(length $parent && "/$parent" eq $p)) { + $indent++; + if ($indent > 1) { + $map .= ($spaces x $indent) . "<ul><map:collapse>\n"; + } + if ($depth > $indent) { + $p.="/".shift(@bits); $addparent=$p; $addparent=~s/^\///; - $map .= "<li>" + $map .= ($spaces x $indent) . "<li>\n"; + $map .= ($spaces x $indent) .htmllink($params{page}, $params{destpage}, "/".$common_prefix.$p, class => "mapparent", noimageinline => 1) @@ -130,14 +137,10 @@ sub preprocess (@) { else { $openli=0; } - $indent++; - $p.="/".shift(@bits) if @bits; - if ($indent > 1) { - $map .= "<ul>\n"; - } } - $map .= "</li>\n" if $openli; - $map .= "<li>" + $map .= ($spaces x $indent) . "</li>\n" if $openli; + $map .= ($spaces x $indent) . "<li>\n"; + $map .= ($spaces x $indent) .htmllink($params{page}, $params{destpage}, "/".$common_prefix."/".$item, @linktext, @@ -147,9 +150,12 @@ sub preprocess (@) { $parent=$item; } while ($indent > 0) { + $map .= ($spaces x $indent) . "</li>\n"; $indent--; - $map .= "</li>\n</ul>\n"; + $map .= ($spaces x $indent) . "</ul>\n"; } + $map =~ s{\n *</ul><map:collapse>\n *<ul><map:collapse>\n}{\n}gs; + $map =~ s{<map:collapse>}{}g; $map .= "</div>\n"; return $map; } diff --git a/IkiWiki/Plugin/underlay.pm b/IkiWiki/Plugin/underlay.pm index 3ea19c635..2967761c8 100644 --- a/IkiWiki/Plugin/underlay.pm +++ b/IkiWiki/Plugin/underlay.pm @@ -18,6 +18,7 @@ sub getsetup () { plugin => { safe => 0, rebuild => undef, + section => "special-purpose", }, add_underlays => { type => "string", diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 48f3d4634..453d19670 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -172,6 +172,11 @@ sub getsetup () { my @s=eval { $IkiWiki::hooks{getsetup}{$plugin}{call}->() }; next unless @s; + if (scalar(@s) % 2 != 0) { + print STDERR "warning: plugin $plugin has a broken getsetup; ignoring\n"; + next; + } + # set default section value (note use of shared # hashref between array and hash) my %s=@s; @@ -223,6 +228,10 @@ sub commented_dump ($$) { my $setup=$pair->[1]; my %s=@{$setup}; my $section=$s{plugin}->{section}; + if (! defined $section) { + print STDERR "warning: missing section in $plugin\n"; + $section="other"; + } push @{$section_plugins{$section}}, $plugin; if (@{$section_plugins{$section}} == 1) { push @ret, "", $indent.("#" x 70), "$indent# $section plugins", diff --git a/debian/changelog b/debian/changelog index 7905ae6fc..1657ffcb6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,10 @@ ikiwiki (3.20130213) UNRELEASED; urgency=low * Allow dots in directive parameter names. (tango) + * Add missing plugin section, and deal with missing sections with a warning. + * Detect plugins with a broken getsetup and warn. + * map: Correct reversion introduced in version 3.20110225 that could + generate invalid html. (smcv) -- Joey Hess <joeyh@debian.org> Fri, 15 Feb 2013 17:23:12 -0400 diff --git a/doc/bugs/map_generates_malformed_HTML.mdwn b/doc/bugs/map_generates_malformed_HTML.mdwn index d47d066a8..890a6ef7f 100644 --- a/doc/bugs/map_generates_malformed_HTML.mdwn +++ b/doc/bugs/map_generates_malformed_HTML.mdwn @@ -1,4 +1,5 @@ [[!template id=gitbranch branch=smcv/ready/map author="[[Simon McVittie|smcv]]"]] +[[!tag patch]] `\[[!map]]` can generate bad HTML with unbalanced open/close tags (in XML terms: "not well-formed") in certain situations. This @@ -21,8 +22,8 @@ In particular, on a site with these pages: * 3 * beta -the maps "alpha/1 or beta", "alpha/1/i* or alpha/2/a or beta" and -"alpha/1/i* or alpha/2/a" have malformed HTML. +the maps "`alpha/1 or beta`", "`alpha/1/i* or alpha/2/a or beta`" and +"`alpha/1/i* or alpha/2/a`" have malformed HTML. My `ready/map` branch adds a regression test and makes it pass. @@ -31,3 +32,5 @@ HTML with redundant `</ul><ul>` pairs, marks the redundant pairs, and edits them out afterwards - but it works. If anyone can come up with a cleaner algorithm that avoids generating the redundant tags in the first place, that would be even better. --[[smcv]] + +> [[merged|done]] (not thrilled at this solution, but it works) --[[Joey]] diff --git a/doc/bugs/search_plugin_finds_no_results_with_xapian_1.2.7.mdwn b/doc/bugs/search_plugin_finds_no_results_with_xapian_1.2.7.mdwn index 5509efefe..3bc430f68 100644 --- a/doc/bugs/search_plugin_finds_no_results_with_xapian_1.2.7.mdwn +++ b/doc/bugs/search_plugin_finds_no_results_with_xapian_1.2.7.mdwn @@ -8,3 +8,7 @@ I found that Debian stable is currently shipping 1.2.3, and on a hunch, I built > Debian has 1.2.7 now, and I have it installed and searching is working > fine with it. --[[Joey]] + +> I have this same issue. I tried xapian version 1.2.5. 1.2.8, 1.2.13. I will try and see if installing 1.2.3 fixes this issue. --[[Ramsey]] + +> 1.2.3 didn't fix the issue either --[[Ramsey]] diff --git a/doc/bugs/template_creation_error.mdwn b/doc/bugs/template_creation_error.mdwn index abf50cdc0..79dccc136 100644 --- a/doc/bugs/template_creation_error.mdwn +++ b/doc/bugs/template_creation_error.mdwn @@ -34,3 +34,78 @@ To ssh://b-odelama-com@odelama-com.branchable.com/ </pre> Please, let me know what to do to avoid this kind of error. + +> When you add a template page `templates/foo.mdwn` for use +> the [[ikiwiki/directive/template]] directive, two things happen: +> +> 1. `\[[!template id=foo ...]]` becomes available; +> 2. a wiki page `templates/foo` is built, resulting in a HTML file, +> typically `templates/foo/index.html` +> +> The warnings you're seeing are the second of these: when ikiwiki +> tries to process `templates/foo.mdwn` as an ordinary page, without +> interpreting the `<TMPL_VAR>` directives, `inline` receives invalid +> input. +> +> This is a bit of a design flaw in [[plugins/template]] and +> [[plugins/edittemplate]], I think - ideally it would be possible to +> avoid parts of the page being interpreted when the page is being +> rendered normally rather than being used as a template. +> +> There *is* a trick to avoid parts of the page being interpreted when +> the page is being used as a template, while having them appear +> when it's rendered as a page: +> +> <TMPL_IF FALSE> +> <!-- This part only appears when being used as a page. +> It assumes that you never set FALSE to a true value :-) --> +> \[[!meta robots="noindex,nofollow"]] +> This template is used to describe a thing. Parameters: +> * name: the name of the thing +> * size: the size of the thing +> </TMPL_IF> +> +> The thing is called <TMPL_VAR name> and its size is <TMPL_VAR size> +> +> I suppose you could maybe extend that to something like this: +> +> <TMPL_IF FALSE> +> <!-- This part only appears when being used as a page. +> It assumes that you never set FALSE to a true value :-) --> +> \[[!meta robots="noindex,nofollow"]] +> This template is used to describe a thing. Parameters: +> * name: the name of the thing +> * size: the size of the thing +> </TMPL_IF> +> +> <TMPL_IF FALSE> +> \[[!if test="included() and !included()" then=""" +> </TMPL_IF> +> <!-- This part only appears when being used as a template. It also +> assumes that you never set FALSE to a true value, and it +> relies on the [[ikiwiki/pagespec]] "included() and !included()" +> never being true. --> +> The thing is called <TMPL_VAR name> and its size is <TMPL_VAR size> +> <TMPL_IF FALSE> +> """]] +> </TMPL_IF> +> +> but that's far harder than it ought to be! +> +> Perhaps the right solution would be to change how the template plugin +> works, so that templates are expected to contain a new `definetemplate` +> directive: +> +> This template is used to describe a thing. Parameters: +> * name: the name of the thing +> * size: the size of the thing +> +> \[[!definetemplate """ +> The thing is called <TMPL_VAR name> and its size is <TMPL_VAR size> +> """]] +> +> with templates not containing a `\[[!definetemplate]]` being treated +> as if the whole text of the page was copied into a `\[[!definetemplate]]`, +> for backwards compatibility? +> +> --[[smcv]] diff --git a/doc/bugs/undefined_value_as_a_HASH_reference.mdwn b/doc/bugs/undefined_value_as_a_HASH_reference.mdwn new file mode 100644 index 000000000..228c3baac --- /dev/null +++ b/doc/bugs/undefined_value_as_a_HASH_reference.mdwn @@ -0,0 +1,68 @@ +Hello, + +does anyone have an idea why I see the following error when I run websetup (Setup button in Preferences)? + + Error: Can't use an undefined value as a HASH reference at /usr/share/perl5/IkiWiki/Plugin/websetup.pm line 82, line 97. + +Maybe, related to this is also + + $ ikiwiki --setup /etc/ikiwiki/auto-blog.setup + What will the blog be named? tmpblog + What revision control system to use? git + What wiki user (or openid) will be admin? wsh + + + Setting up tmpblog ... + Importing /home/wsh/tmpblog into git + Initialized empty shared Git repository in /home/wsh/tmpblog.git/ + Initialized empty Git repository in /home/wsh/tmpblog/.git/ + [master (root-commit) d6847e1] initial commit + 8 files changed, 48 insertions(+) + create mode 100644 .gitignore + create mode 100644 archives.mdwn + create mode 100644 comments.mdwn + create mode 100644 index.mdwn + create mode 100644 posts.mdwn + create mode 100644 posts/first_post.mdwn + create mode 100644 sidebar.mdwn + create mode 100644 tags.mdwn + Counting objects: 11, done. + Delta compression using up to 4 threads. + Compressing objects: 100% (9/9), done. + Writing objects: 100% (11/11), 1.53 KiB, done. + Total 11 (delta 0), reused 0 (delta 0) + Unpacking objects: 100% (11/11), done. + To /home/wsh/tmpblog.git + * [new branch] master -> master + Directory /home/wsh/tmpblog is now a clone of git repository /home/wsh/tmpblog.git + Reference found where even-sized list expected at /usr/share/perl5/IkiWiki/Setup.pm line 177, <GEN4> line 97. + Reference found where even-sized list expected at /usr/share/perl5/IkiWiki/Setup.pm line 224, <GEN4> line 97. + Use of uninitialized value $section in hash element at /usr/share/perl5/IkiWiki/Setup.pm line 226, <GEN4> line 97. + Use of uninitialized value $section in hash element at /usr/share/perl5/IkiWiki/Setup.pm line 227, <GEN4> line 97. + Use of uninitialized value $section in concatenation (.) or string at /usr/share/perl5/IkiWiki/Setup.pm line 233, <GEN4> line 97. + /etc/ikiwiki/auto-blog.setup: Can't use an undefined value as a HASH reference at /usr/share/perl5/IkiWiki/Setup.pm line 252, <GEN4> line 97. + + usage: ikiwiki [options] source dest + ikiwiki --setup configfile + +I'm on Debian unstable. + +Thanks, +-Michal + +> Some plugin has a broken getsetup hook, and is feeding a corrupted setup list in. Both the websetup and the auto.setup files cause all plugins to be loaded and all their setup to be available. +> +> This command will help you find the plugin. Here it prints some noise around the rst plugin, for unrelated reasons, +> but what you're looking for is the plugin printed before the "even sized list" message. + +<pre> +perl -le 'use warnings; use strict; use Data::Dumper; use IkiWiki; %config=IkiWiki::defaultconfig(); use IkiWiki::Setup; my @s=IkiWiki::Setup::getsetup(); foreach my $pair (@s) { print "plugin ".$pair->[0]; my $setup=$pair->[1]; if ($pair->[0] eq "rst") { print Dumper($setup)} my %s=@{$setup} }' +</pre> + +> I was able to replicate this by making a plugin's getsetup hook return a list reference, rather than a list, +> and have put in a guard against that sort of thing. +> --[[Joey]] + +>> Thanks. Your command didn't helped me, but with trial and error approach I found that the victim an old version asciidoc plugin. For some reason, asciidoc was never listed in the output of the command. --[[wentasah]] + +>>> Ok. My fix should prevent the problem, so [[done]] --[[Joey]] diff --git a/doc/forum/Email_notifications_for_comment_moderation/comment_1_668bf6a21310dcc8b882bc60a130ba06._comment b/doc/forum/Email_notifications_for_comment_moderation/comment_1_668bf6a21310dcc8b882bc60a130ba06._comment new file mode 100644 index 000000000..06140728e --- /dev/null +++ b/doc/forum/Email_notifications_for_comment_moderation/comment_1_668bf6a21310dcc8b882bc60a130ba06._comment @@ -0,0 +1,12 @@ +[[!comment format=mdwn + username="https://www.google.com/accounts/o8/id?id=AItOawm6VdLM7IKcNgkDiJ2YKHpcWli9bRLsZDk" + nickname="Oscar" + subject="How to get a comment moderation feed" + date="2013-02-25T18:04:21Z" + content=""" +I was looking for the same subject and I have found the following: + +http://ikiwiki.info/tips/comments_feed/ + + +"""]] diff --git a/doc/forum/How_to_set_up_a_page_as_internal__63__.mdwn b/doc/forum/How_to_set_up_a_page_as_internal__63__.mdwn new file mode 100644 index 000000000..ed771292d --- /dev/null +++ b/doc/forum/How_to_set_up_a_page_as_internal__63__.mdwn @@ -0,0 +1,5 @@ +I have a folder with few administrative tasks, like a page showing the comments waiting for moderation. + +There is no link from "normal/public" pages in my site to this administrative pages, but it doesn't prevent the possibility of any person writing down that address in the browser address-bar or finding that address in the browser navigation history. + +Please, is there any way or best-practice restricting the access to this kind of pages? I know that these pages will eventually ask the user to log-in as admin, but I don't want them to see this stuff. diff --git a/doc/forum/Xapian_search:_empty_postlist_table/comment_4_40479ac2cfbca609f5f423e539a20ee0._comment b/doc/forum/Xapian_search:_empty_postlist_table/comment_4_40479ac2cfbca609f5f423e539a20ee0._comment new file mode 100644 index 000000000..a120f976d --- /dev/null +++ b/doc/forum/Xapian_search:_empty_postlist_table/comment_4_40479ac2cfbca609f5f423e539a20ee0._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="https://www.google.com/accounts/o8/id?id=AItOawlXywgEUJjKArnORJR-5hmNFv8bTraXO1Y" + nickname="Ramsey" + subject="The same issue is happening with me" + date="2013-03-06T13:10:15Z" + content=""" +I use ikiwiki version 3.20130212 and tried xapian versions 1.2.5, 1.2.8, 1.2.13. All to no avail. The postlist.DB file is empty for me. I think that is the crux of the problem. Does anybody know why this could be? +"""]] diff --git a/doc/forum/Xapian_search:_empty_postlist_table/comment_5_397443138da276e11c2e9b9fa7b51406._comment b/doc/forum/Xapian_search:_empty_postlist_table/comment_5_397443138da276e11c2e9b9fa7b51406._comment new file mode 100644 index 000000000..56dd7c61d --- /dev/null +++ b/doc/forum/Xapian_search:_empty_postlist_table/comment_5_397443138da276e11c2e9b9fa7b51406._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="https://www.google.com/accounts/o8/id?id=AItOawljJoWAYhI55qm4hRLdzIOQBNMVB6fgrs8" + nickname="Ramsey" + subject="comment 5" + date="2013-03-06T22:42:54Z" + content=""" +Tried version xapian 1.2.3 and it did not work either. Can someone please help me debug this? +"""]] diff --git a/doc/ikiwikiusers.mdwn b/doc/ikiwikiusers.mdwn index bb94242bb..309814558 100644 --- a/doc/ikiwikiusers.mdwn +++ b/doc/ikiwikiusers.mdwn @@ -187,3 +187,6 @@ Personal sites and blogs * [Puckspage]( http://www.puckspage.org/ ) Political and personal blog in German. The name comes from the elf out of midsummer nights dream. * [[LucaCapello]]'s [homepage](http://luca.pca.it) * [[MartÃn Ferrari's homepage|http://tincho.org/]] and [[blog|http://blog.tincho.org/]] +* [WikiAtoBR](http://wiki.hi.ato.br) Open, free and annoymous wiki. No need for account registering and login. It is Brazilian so it is in Portuguese. +* [Manifesto](http://manifesto.hi.ato.br) Open, free and annoymous blog. No need for account registering and login. It is Brazilian so it is in Portuguese. + diff --git a/doc/logo.mdwn b/doc/logo.mdwn index 5e2b3c736..3608cb382 100644 --- a/doc/logo.mdwn +++ b/doc/logo.mdwn @@ -57,3 +57,13 @@ added). A simplified (442 byte) plain SVG version of the ikiwiki favicon. Contributed by [[JasonBlevins]] + +* <https://archive.org/download/IkiwikiLogo-hi.ato.br/ikiwiki_logo-hiato.png> + + Hosted on: <https://archive.org/details/IkiwikiLogo-hi.ato.br> + + I had to change the black letters to #c8c8c8 to put in my website. + + This was created from the svg source. + + Contributed by [[hiato]] diff --git a/doc/plugins/comments/discussion.mdwn b/doc/plugins/comments/discussion.mdwn index ceb02406d..2b8add938 100644 --- a/doc/plugins/comments/discussion.mdwn +++ b/doc/plugins/comments/discussion.mdwn @@ -227,3 +227,6 @@ use those formats because it would be a security problem. Any suggestions or hints how to implement this? -- [[wentasah]] + +> I've implemented this. See [[todo/Restrict_formats_allowed_for_comments]]. +> --[[wentasah]] diff --git a/doc/sandbox.mdwn b/doc/sandbox.mdwn index 757190fb0..c7c91e4fb 100644 --- a/doc/sandbox.mdwn +++ b/doc/sandbox.mdwn @@ -1,6 +1,8 @@ This is the [[SandBox]], a page anyone can edit to try out ikiwiki (version [[!version ]]). +hello world + > This is a blockquote. > > This is the first level of quoting. diff --git a/doc/test.mdwn b/doc/test.mdwn new file mode 100644 index 000000000..8ae056963 --- /dev/null +++ b/doc/test.mdwn @@ -0,0 +1 @@ +# Test diff --git a/doc/todo/Restrict_formats_allowed_for_comments.mdwn b/doc/todo/Restrict_formats_allowed_for_comments.mdwn new file mode 100644 index 000000000..cfae38465 --- /dev/null +++ b/doc/todo/Restrict_formats_allowed_for_comments.mdwn @@ -0,0 +1,97 @@ +I want to write my blog posts in a convenient format (Emacs org mode) +but do not want commenters to be able to use this format for security +reasons. This patch allows to configure which formats are allowed for +writing comments. + +Effectively, it restricts the formats enabled with add_plugin to those +mentioned in comments_allowformats. If this is empty, all formats are +allowed, which is the behavior without this patch. + +The patch can be pulled from my repo ([gitweb](https://rtime.felk.cvut.cz/gitweb/sojka/ikiwiki.git/commitdiff/c42fd7d7580d081f3e3f624fd74219b0435230f6?hp=bfc9dc93c9f64a9acfff4683b69995d5a0edb0ea)) + + git pull git://rtime.felk.cvut.cz/sojka/ikiwiki.git restrict-comment-formats +--- + +<pre> +From c42fd7d7580d081f3e3f624fd74219b0435230f6 Mon Sep 17 00:00:00 2001 +From: Michal Sojka <sojkam1@fel.cvut.cz> +Date: Tue, 5 Mar 2013 10:54:51 +0100 +Subject: [PATCH] Add configuration to restrict the formats allowed for + comments + +I want to write my blog posts in a convenient format (Emacs org mode) +but do not want commenters to be able to use this format for security +reasons. This patch allows to configure which formats are allowed for +writing comments. + +Effectively, it restricts the formats enabled with add_plugin to those +mentioned in comments_allowformats. If this is empty, all formats are +allowed, which is the behavior without this patch. +--- + IkiWiki/Plugin/comments.pm | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm +index 285013e..151e839 100644 +--- a/IkiWiki/Plugin/comments.pm ++++ b/IkiWiki/Plugin/comments.pm +@@ -90,6 +90,15 @@ sub getsetup () { + safe => 0, + rebuild => 0, + }, ++ comments_allowformats => { ++ type => 'string', ++ default => '', ++ example => 'mdwn txt', ++ description => 'Restrict formats for comments to (no restriction if empty)', ++ safe => 1, ++ rebuild => 0, ++ }, ++ + } + + sub checkconfig () { +@@ -101,6 +110,8 @@ sub checkconfig () { + unless defined $config{comments_closed_pagespec}; + $config{comments_pagename} = 'comment_' + unless defined $config{comments_pagename}; ++ $config{comments_allowformats} = '' ++ unless defined $config{comments_allowformats}; + } + + sub htmlize { +@@ -128,12 +139,18 @@ sub safeurl ($) { + } + } + ++sub isallowed ($) { ++ my $format = shift; ++ return ! $config{comments_allowformats} || $config{comments_allowformats} =~ /\b$format\b/; ++} ++ + sub preprocess { + my %params = @_; + my $page = $params{page}; + + my $format = $params{format}; +- if (defined $format && ! exists $IkiWiki::hooks{htmlize}{$format}) { ++ if (defined $format && (! exists $IkiWiki::hooks{htmlize}{$format} || ++ ! isallowed($format))) { + error(sprintf(gettext("unsupported page format %s"), $format)); + } + +@@ -332,7 +349,7 @@ sub editcomment ($$) { + + my @page_types; + if (exists $IkiWiki::hooks{htmlize}) { +- foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) { ++ foreach my $key (grep { !/^_/ && isallowed($_) } keys %{$IkiWiki::hooks{htmlize}}) { + push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key]; + } + } +-- +1.7.10.4 + +</pre> + +[[!tag patch]] diff --git a/doc/todo/sortable_tables.mdwn b/doc/todo/sortable_tables.mdwn new file mode 100644 index 000000000..8e7e6fe25 --- /dev/null +++ b/doc/todo/sortable_tables.mdwn @@ -0,0 +1 @@ +It would be nice if ikiwiki's table plugin could create sortable tables like Mediawiki does. diff --git a/doc/users/Ramsey.mdwn b/doc/users/Ramsey.mdwn new file mode 100644 index 000000000..696f00bf6 --- /dev/null +++ b/doc/users/Ramsey.mdwn @@ -0,0 +1,3 @@ +Hi everyone, I'm Ramsey. I am a web developer/aerospace engineer in order of preference. + +I am using ikiwiki to create a [[blog|http://blog.coderfly.com]] and [[wiki|http://wiki.coderfly.com]] diff --git a/t/map.t b/t/map.t new file mode 100755 index 000000000..7f3df61f7 --- /dev/null +++ b/t/map.t @@ -0,0 +1,235 @@ +#!/usr/bin/perl +package IkiWiki; + +use warnings; +use strict; +use XML::Twig; +use Test::More; + +BEGIN { use_ok("IkiWiki"); } +BEGIN { use_ok("IkiWiki::Render"); } +BEGIN { use_ok("IkiWiki::Plugin::map"); } +BEGIN { use_ok("IkiWiki::Plugin::mdwn"); } + +ok(! system("rm -rf t/tmp; mkdir t/tmp")); + +$config{verbose} = 1; +$config{srcdir} = 't/tmp'; +$config{underlaydir} = 't/tmp'; +$config{underlaydirbase} = '.'; +$config{templatedir} = 'templates'; +$config{usedirs} = 1; +$config{htmlext} = 'html'; +$config{wiki_file_chars} = "-[:alnum:]+/.:_"; +$config{userdir} = "users"; +$config{tagbase} = "tags"; +$config{default_pageext} = "mdwn"; +$config{wiki_file_prune_regexps} = [qr/^\./]; +$config{autoindex_commit} = 0; + +is(checkconfig(), 1); + +%oldrenderedfiles=%pagectime=(); +%pagesources=%pagemtime=%oldlinks=%links=%depends=%typedlinks=%oldtypedlinks= +%destsources=%renderedfiles=%pagecase=%pagestate=(); + +my @pages = qw( +alpha +alpha/1 +alpha/1/i +alpha/1/ii +alpha/1/iii +alpha/1/iv +alpha/2 +alpha/2/a +alpha/2/b +alpha/3 +beta +); + +foreach my $page (@pages) { + # we use a non-default extension for these, so they're distinguishable + # from programmatically-created pages + $pagesources{$page} = "$page.mdwn"; + $destsources{$page} = "$page.mdwn"; + $pagemtime{$page} = $pagectime{$page} = 1000000; + writefile("$page.mdwn", "t/tmp", "your ad here"); +} + +sub comment { + my $str = shift; + $str =~ s/^/# /gm; + print $str; +} + +sub node { + my $name = shift; + my $kids = shift; + my %stuff = @_; + + return { %stuff, name => $name, kids => $kids }; +} + +sub check_nodes { + my $ul = shift; + my $expected = shift; + + is($ul->tag, 'ul'); + + # expected is a list of hashes + # ul is a list of li + foreach my $li ($ul->children) { + my @kids = $li->children; + + is($li->tag, 'li'); + + my $expectation = shift @$expected; + + is($kids[0]->tag, 'a'); + my $a = $kids[0]; + + if ($expectation->{parent}) { + is($a->att('class'), 'mapparent'); + } + else { + is($a->att('class'), 'mapitem'); + } + + is_deeply([$a->text], [$expectation->{name}]); + + if (@{$expectation->{kids}}) { + is(scalar @kids, 2); + + check_nodes($kids[1], $expectation->{kids}); + } + else { + is_deeply([@kids], [$a]); + } + } +} + +sub check { + my $pagespec = shift; + my $expected = shift; + comment("*** $pagespec ***\n"); + + my $html = IkiWiki::Plugin::map::preprocess(pages => $pagespec, + page => 'map', + destpage => 'map'); + comment($html); + my $tree = XML::Twig->new(pretty_print => 'indented'); + eval { + $tree->parse($html); + }; + if ($@) { + print "malformed XML: $@\n$html\n"; + ok(0); + } + my $fragment = $tree->root; + + is($fragment->tag, 'div'); + is($fragment->att('class'), 'map'); + + if (@$expected) { + check_nodes(($fragment->children)[0], $expected); + } + else { + ok(! $fragment->children); + } + + $tree->dispose; +} + +check('doesnotexist', []); + +check('alpha', [node('alpha', [])]); + +check('alpha/*', + [ + node('1', [ + node('i', []), + node('ii', []), + node('iii', []), + node('iv', []), + ]), + node('2', [ + node('a', []), + node('b', []), + ]), + node('3', []), + ]); + +check('alpha or alpha/*', + [ + node('alpha', [ + node('1', [ + node('i', []), + node('ii', []), + node('iii', []), + node('iv', []), + ]), + node('2', [ + node('a', []), + node('b', []), + ]), + node('3', []), + ]), + ]); + +check('alpha or alpha/1 or beta', + [ + node('alpha', [ + node('1', []), + ]), + node('beta', []), + ]); + +check('alpha/1 or beta', + [ + node('alpha', [ + node('1', []), + ], parent => 1), + node('beta', []), + ]); + +check('alpha/1/i* or alpha/2/a or beta', + [ + node('alpha', [ + node('1', [ + node('i', []), + node('ii', []), + node('iii', []), + node('iv', []), + ], parent => 1), + node('2', [ + node('a', []), + ], parent => 1), + ], parent => 1), + node('beta', []), + ]); + +check('alpha/1/i* or alpha/2/a', + [ + node('1', [ + node('i', []), + node('ii', []), + node('iii', []), + node('iv', []), + ], parent => 1), + node('2', [ + node('a', []), + ], parent => 1), + ]); + +check('alpha/1/i*', + [ + node('i', []), + node('ii', []), + node('iii', []), + node('iv', []), + ]); + +ok(! system("rm -rf t/tmp")); +done_testing; + +1; diff --git a/t/permalink.t b/t/permalink.t index 81d4d1820..36be984c5 100755 --- a/t/permalink.t +++ b/t/permalink.t @@ -3,6 +3,7 @@ use warnings; use strict; use Test::More 'no_plan'; +ok(! system("rm -rf t/tmp")); ok(! system("mkdir t/tmp")); ok(! system("make -s ikiwiki.out")); ok(! system("perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tinyblog t/tmp/out")); |