From 27193a2eeba3aa2f5ed8c0168f828149696b2b7f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 21 May 2009 15:50:25 -0400 Subject: support longname for page types in commands and rename Also, sort the list of page types. --- IkiWiki/Plugin/comments.pm | 7 ++++++- IkiWiki/Plugin/editpage.pm | 1 + IkiWiki/Plugin/rename.pm | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index e618d1a90..0aa4759d8 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -287,10 +287,15 @@ sub editcomment ($$) { else { $type = $config{default_pageext}; } + + my @page_types; if (exists $IkiWiki::hooks{htmlize}) { - @page_types = grep { ! /^_/ } keys %{$IkiWiki::hooks{htmlize}}; + foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) { + push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key]; + } } + @page_types=sort @page_types; $form->field(name => 'do', type => 'hidden'); $form->field(name => 'sid', type => 'hidden', value => $session->id, diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index af42097ba..8effc02d0 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -280,6 +280,7 @@ sub cgi_editpage ($$) { push @page_types, [$key, $hooks{htmlize}{$key}{longname} || $key]; } } + @page_types=sort @page_types; $form->tmpl_param("page_select", 1); $form->field(name => "page", type => 'select', diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index 41af3ca4d..0b6e74705 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -116,14 +116,16 @@ sub rename_form ($$$) { # insert the standard extensions my @page_types; if (exists $IkiWiki::hooks{htmlize}) { - @page_types=grep { !/^_/ } - keys %{$IkiWiki::hooks{htmlize}}; + foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) { + push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key]; + } } + @page_types=sort @page_types; # make sure the current extension is in the list my ($ext) = $pagesources{$page}=~/\.([^.]+)$/; if (! $IkiWiki::hooks{htmlize}{$ext}) { - unshift(@page_types, $ext); + unshift(@page_types, [$ext, $ext]); } $f->field(name => "type", type => 'select', -- cgit v1.2.3 From 8f6cdf3ae07536fdf1a197297b91677a1345eebc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 May 2009 14:17:26 -0400 Subject: listdirectives: Avoid listing _comment directives and generally assume any directive starting with _ is likewise internal. --- IkiWiki/Plugin/listdirectives.pm | 2 +- debian/NEWS | 2 +- debian/changelog | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index d2cebca34..bd73f1a04 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -45,7 +45,7 @@ sub checkconfig () { sub needsbuild (@) { my $needsbuild=shift; - @fulllist = sort keys %{$IkiWiki::hooks{preprocess}}; + @fulllist = grep { ! /^_/ } sort keys %{$IkiWiki::hooks{preprocess}}; @shortlist = grep { ! $IkiWiki::hooks{preprocess}{$_}{shortcut} } @fulllist; $pluginstring = join(' ', @shortlist) . " : " . join(' ', @fulllist); diff --git a/debian/NEWS b/debian/NEWS index c3574bdb6..75b6d0471 100644 --- a/debian/NEWS +++ b/debian/NEWS @@ -1,4 +1,4 @@ -ikiwiki (3.13) UNRELEASED; urgency=low +ikiwiki (3.13) unstable; urgency=low The `ikiwiki-transition deduplinks` command introduced in the last release was buggy. If you followed the NEWS file instructions diff --git a/debian/changelog b/debian/changelog index f25cab5bb..71445ea71 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -ikiwiki (3.13) UNRELEASED; urgency=low +ikiwiki (3.13) unstable; urgency=low * ikiwiki-transition: If passed a nonexistant srcdir, or one not containing .ikiwiki, abort with an error rather than creating it. @@ -13,8 +13,10 @@ ikiwiki (3.13) UNRELEASED; urgency=low that need a srcdir. * ikiwiki-transition: deduplinks was broken and threw away all metadata stored by plugins in the index. Fix this bug. + * listdirectives: Avoid listing _comment directives and generally + assume any directive starting with _ is likewise internal. - -- Joey Hess Wed, 06 May 2009 20:45:44 -0400 + -- Joey Hess Fri, 22 May 2009 14:10:56 -0400 ikiwiki (3.12) unstable; urgency=low -- cgit v1.2.3 From 8ae260015fa6ecd5aa39a84898f42837935c9953 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 22 May 2009 22:57:03 -0400 Subject: highlight: New plugin supporting syntax highlighting of pretty much anything. * debian/control: Add suggests for libhighlight-perl, although that package is not yet created by Debian's highlight source package. (See #529869) --- IkiWiki/Plugin/highlight.pm | 118 +++++++++++++++++++++ debian/changelog | 10 ++ debian/control | 2 +- doc/plugins/highlight.mdwn | 72 +++++++++++++ doc/style.css | 18 ++++ ..._use_of_syntax_plugin_on_source_code_files.mdwn | 3 + doc/todo/syntax_highlighting.mdwn | 28 ++--- doc/todo/syntax_highlighting/discussion.mdwn | 2 + ...wiki-formatted_comments_with_syntax_plugin.mdwn | 5 + 9 files changed, 240 insertions(+), 18 deletions(-) create mode 100644 IkiWiki/Plugin/highlight.pm create mode 100644 doc/plugins/highlight.mdwn (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm new file mode 100644 index 000000000..f43f18628 --- /dev/null +++ b/IkiWiki/Plugin/highlight.pm @@ -0,0 +1,118 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::highlight; + +use warnings; +use strict; +use IkiWiki 3.00; +use highlight; + +# locations of highlight's files +my $filetypes="/etc/highlight/filetypes.conf"; +my $langdefdir="/usr/share/highlight/langDefs"; + +sub import { + hook(type => "getsetup", id => "highlight", call => \&getsetup); + hook(type => "checkconfig", id => "highlight", call => \&checkconfig); +} + +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => 1, # format plugin + }, + tohighlight => { + type => "string", + example => ".c, .h, .cpp, .pl, .py, Makefile:make", + description => "source files to syntax highlight", + safe => 1, + rebuild => 1, + }, +} + +sub checkconfig () { + if (exists $config{tohighlight}) { + foreach my $file (split /, /, $config{tohighlight}) { + my @opts = $file=~s/^\.// ? + (keepextension => 1) : + (noextension => 1); + my $ext = $file=~s/:(.*)// ? $1 : $file; + + my $langfile=ext2langfile($ext); + if (! defined $langfile) { + error(sprintf(gettext( + "tohighlight contains unknown file type '%s'"), + $ext)); + } + + hook( + type => "htmlize", + id => $file, + call => sub { + my %params=@_; + highlight($langfile, $params{content}); + }, + longname => sprintf(gettext("Source code: %s"), $file), + @opts, + ); + } + } +} + +my %ext2lang; +my $filetypes_read=0; + +# Parse highlight's config file to get extension => language mappings. +sub read_filetypes () { + open (IN, $filetypes); + while () { + chomp; + if (/^\$ext\((.*)\)=(.*)$/) { + $ext2lang{$_}=$1 foreach $1, split ' ', $2; + } + } + close IN; + $filetypes_read=1; +} + +sub langfile ($) { + return "$langdefdir/$_[0].lang"; +} + +# Given a filename extension, determines the language definition to +# use to highlight it. +sub ext2langfile ($) { + my $ext=shift; + + read_filetypes() unless $filetypes_read; + if (exists $ext2lang{$ext}) { + return langfile($ext2lang{$ext}); + } + # If a language only has one common extension, it will not + # be listed in filetypes, so check the langfile. + elsif (-e langfile($ext)) { + return langfile($ext); + } + else { + return undef; + } +} + +# Interface to the highlight C library. +sub highlight ($$) { + my $langfile=shift; + my $input=shift; + + my $gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML); + $gen->setFragmentCode(1); # generate html fragment + $gen->setHTMLEnclosePreTag(1); # include stylish
+	$gen->initLanguage($langfile);
+	$gen->initTheme("/dev/null"); # theme is not needed because CSS is not emitted
+	$gen->setEncoding("utf-8");
+
+	my $output=$gen->generateString($input);
+	highlightc::CodeGenerator_deleteInstance($gen);
+	return $output;
+}
+
+1
diff --git a/debian/changelog b/debian/changelog
index 71445ea71..db3e32cda 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+ikiwiki (3.14) UNRELEASED; urgency=low
+
+  * highlight: New plugin supporting syntax highlighting of pretty much
+    anything.
+  * debian/control: Add suggests for libhighlight-perl, although
+    that package is not yet created by Debian's highlight source package.
+    (See #529869)
+
+ -- Joey Hess   Fri, 22 May 2009 22:03:12 -0400
+
 ikiwiki (3.13) unstable; urgency=low
 
   * ikiwiki-transition: If passed a nonexistant srcdir, or one not
diff --git a/debian/control b/debian/control
index 57c5f917a..233de8f7c 100644
--- a/debian/control
+++ b/debian/control
@@ -35,7 +35,7 @@ Suggests: viewvc | gitweb | viewcvs, libsearch-xapian-perl,
   liblocale-gettext-perl (>= 1.05-1), libtext-typography-perl,
   libtext-csv-perl, libdigest-sha1-perl, graphviz, libnet-amazon-s3-perl,
   sparkline-php, texlive, dvipng, libtext-wikicreole-perl,
-  libsort-naturally-perl, libtext-textile-perl
+  libsort-naturally-perl, libtext-textile-perl, libhighlight-perl
 Conflicts: ikiwiki-plugin-table
 Replaces: ikiwiki-plugin-table
 Provides: ikiwiki-plugin-table
diff --git a/doc/plugins/highlight.mdwn b/doc/plugins/highlight.mdwn
new file mode 100644
index 000000000..07e888f36
--- /dev/null
+++ b/doc/plugins/highlight.mdwn
@@ -0,0 +1,72 @@
+[[!template id=plugin name=highlight author="[[Joey]]"]]
+[[!tag type/format]]
+
+This plugin allows ikiwiki to syntax highlight source files, using
+a fast syntax highlighter that supports over a hundred programming
+languages and file formats.
+
+## prerequisites
+
+You will need to install the perl bindings to the
+[highlight library](http://www.andre-simon.de/), which in Debian
+are in the [[!debpkg libhighlight-perl]] package.
+
+## configuration
+
+Nothing will be highlighted by default.
+To enable syntax highlighting, use the `tohighlight` setting in your
+setup file to control which files should be syntax highlighted.
+Here is a typical setting for it, enabling highlighting for files
+with the extensions .c, etc, and also for any files named "Makefile".
+
+	tohighlight => .c, .h, .cpp, .pl, .py, Makefile:make",
+
+It knows what language to use for most filename extensions (see
+`/etc/highlight/filetypes.conf` for a partial list), but if you want to
+bind an unusual filename extension, or any file without an extension
+(such as a Makefile), to a language, you can do so by appending a colon
+and the name of the language, as illustrated for Makefiles above.
+
+## embedding highlighted code
+
+To embed highlighted code on a page, you can use the
+[[ikiwiki/directive/format]] directive.
+
+For example:
+
+	\[[!format c """
+	void main () {
+		printf("hello, world!");
+	}
+	"""]]
+
+You can do this for any of the extensions/filenames enabled in
+`tohighlight`.
+
+## colors
+
+The colors etc used for the syntax highlighting are entirely configurable
+by CSS. See ikiwiki's [[style.css]] for the defaults.
+
+## limitations
+
+With this plugin enabled, source files become full-fledged ikiwiki pages,
+which means they can include [[WikiLinks|ikiwiki/wikilink]] and
+[[directives|ikiwiki/directive]] like any other page can, and are also
+affected by the [[smiley]] plugin, if it is enabled. This can be
+annoying if your code accidentially contains things that look like those.
+
+On the other hand, this also allows your syntax highlighed
+source code to contain markdown formatted comments and hyperlinks
+to other code files, like this:
+
+	/* \[[!format mdwn """
+		This comment will be formatted as *markdown*!
+
+		See [[bar.h]].
+	""]] */
+
+## security
+
+This lets anyone who can edit a page in your wiki also edit
+source code files that are in your wiki. Use appropriate caution.
diff --git a/doc/style.css b/doc/style.css
index 74d968ddf..e6512aed8 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -389,3 +389,21 @@ span.color {
 	border: 1px solid #aaa;
 	padding: 3px;
 }
+
+/* Used by the highlight plugin. */
+
+pre.hl { color:#000000; background-color:#ffffff; }
+.hl.num { color:#2928ff; }
+.hl.esc { color:#ff00ff; }
+.hl.str { color:#ff0000; }
+.hl.dstr { color:#818100; }
+.hl.slc { color:#838183; font-style:italic; }
+.hl.com { color:#838183; font-style:italic; }
+.hl.dir { color:#008200; }
+.hl.sym { color:#000000; }
+.hl.line { color:#555555; }
+.hl.mark { background-color:#ffffbb; }
+.hl.kwa { color:#000000; font-weight:bold; }
+.hl.kwb { color:#830000; }
+.hl.kwc { color:#000000; font-weight:bold; }
+.hl.kwd { color:#010181; }
diff --git a/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn b/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn
index cd5ff34de..71b4b88f0 100644
--- a/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn
+++ b/doc/todo/automatic_use_of_syntax_plugin_on_source_code_files.mdwn
@@ -12,3 +12,6 @@ this would allow the use of ikiwiki for [[!wikipedia literate programming]].
 * I have started something along these lines see [[plugins/contrib/sourcehighlight]].  For some reason I started with source-highlight [[DavidBremner]]
 
 * I wonder if this is similar to what you want: 
+
+> The new [[plugins/highlight]] plugin is in ikiwiki core and supports
+> source code files natively. [[done]] --[[Joey]] 
diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn
index 81ba19bc8..01aa7b576 100644
--- a/doc/todo/syntax_highlighting.mdwn
+++ b/doc/todo/syntax_highlighting.mdwn
@@ -28,13 +28,17 @@ things easier for the user.
   also uses source-highlight, and operates on whole source files.
   Updated to work with the fix for [[bugs/multiple_pages_with_same_name]].  Untested with files with no extension, e.g. `Makefile`.
 * [[users/jasonblevins]]'s code plugin uses source-highlight, and supports both
-  while file and directive use.
+  whole file and directive use.
 
 * [hlsimple](http://pivot.cs.unb.ca/git/?p=ikiplugins.git;a=blob_plain;f=IkiWiki/Plugin/hlsimple.pm;hb=HEAD) is a wrapper for the the perl module [[!cpan Syntax::Highlight::Engine::Simple]].  This is pure perl, pretty simple, uses css. It ought to be pretty fast (according to the author, and just because it is not external).
 On the other hand, there are not many predefined languages yet.  Defining language syntaxes is about as much 
 work as source-highlight, but in perl.  I plan to package the base module for debian. Perhaps after the author 
 releases the 5 or 6 language definitions he has running on his web site, it might be suitable for inclusion in ikiwiki. [[DavidBremner]]
 
+* [[plugins/highlight]] uses [highlight](http://www.andre-simon.de) via
+  its swig bindings. It supports whole files only. It uses either
+  keepextension or noextension, as appropriate for the type of file.
+
 ## General problems / requirements
 
 * Using non-perl syntax highlighting backends is slower. All things equal,
@@ -56,7 +60,6 @@ releases the 5 or 6 language definitions he has running on his web site, it migh
   > it has a pass-through feature that I find very useful.  My memory is unfortunately a bit fuzzy as to how
   > well the swig bindings work. [[DavidBremner]]
 
-
 * Engines that already support a wide variety of file types are of
   course preferred. If the engine doesn't support a particular type
   of file, it could fall back to doing something simple like
@@ -105,20 +108,11 @@ releases the 5 or 6 language definitions he has running on his web site, it migh
 
   Perhaps the thing to do here is to use the new `longname` parameter to
   the format hook, to give them all names that will group together at or
-  near the end of the list. Ie: "Syntax: perl", "Syntax: C", etc.
-
-## format directive and comments
-
-Hmm, the [[ikiwiki/directive/format]] directive would also allow comments
-inside source files to have mdwn embedded in them, without making the use
-of mdwn a special case, or needing to postprocess the syntax highlighter
-output to find comments.
-
-	/* \[[!format mdwn """
-
-	This is a comment in my C file. You can use mdwn in here.
+  near the end of the list. Ie: "Syntax: perl", "Source code: c", etc.
 
-	"""]] */
+---
 
-Note that this assumes that directives are expanded in source files,
-which has its own set of problems.
+I'm calling this [[done]] since I added the [[plugins/highlight]]
+plugin. There are some unresolved issues touched on here,
+but they either have the own other bug reports, or are documented
+as semi-features in the docs to the plugin. --[[Joey]] 
diff --git a/doc/todo/syntax_highlighting/discussion.mdwn b/doc/todo/syntax_highlighting/discussion.mdwn
index 7a4095c65..27cb7084b 100644
--- a/doc/todo/syntax_highlighting/discussion.mdwn
+++ b/doc/todo/syntax_highlighting/discussion.mdwn
@@ -24,3 +24,5 @@ repository?  --[[JasonBlevins]]
 >> [[sourcecode|todo/automatic_use_of_syntax_plugin_on_source_code_files/discussion]]
 >> plugin only adds the file extensions listed in the config.  This shouldn't cause
 >> massive drop-down menu pollution.  -- [[Will]]
+
+>>> That seems to be the way to go! --[[Joey]] 
diff --git a/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn b/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn
index a5244c9ef..7a4a295d4 100644
--- a/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn
+++ b/doc/todo/wiki-formatted_comments_with_syntax_plugin.mdwn
@@ -2,3 +2,8 @@
 wiki syntax within the comments of code pretty-printed with the
 [[plugins/contrib/syntax]] plugin.  This would allow the use of links and
 formatting in comments.
+
+> You can do this using the [[plugins/highlight]] plugin, but you have
+> to explicitly put a format directive in the comment to do it. Thus,
+> I'm leaving this open for now.. ideally, comments would be detected,
+> and formatted as markdown. --[[Joey]] 
-- 
cgit v1.2.3


From cdd1b58b386da575f3c73ab94ae72e5e66be797b Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Sat, 23 May 2009 00:09:14 -0400
Subject: remove commas in tohighlight list

---
 IkiWiki/Plugin/highlight.pm | 4 ++--
 doc/plugins/highlight.mdwn  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'IkiWiki')

diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index f43f18628..117ab5898 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -23,7 +23,7 @@ sub getsetup () {
 		},
 		tohighlight => {
 			type => "string",
-			example => ".c, .h, .cpp, .pl, .py, Makefile:make",
+			example => ".c .h .cpp .pl .py Makefile:make",
 			description => "source files to syntax highlight",
 			safe => 1,
 			rebuild => 1,
@@ -32,7 +32,7 @@ sub getsetup () {
 
 sub checkconfig () {
 	if (exists $config{tohighlight}) {
-		foreach my $file (split /, /, $config{tohighlight}) {
+		foreach my $file (split ' ', $config{tohighlight}) {
 			my @opts = $file=~s/^\.// ?
 				(keepextension => 1) :
 				(noextension => 1);
diff --git a/doc/plugins/highlight.mdwn b/doc/plugins/highlight.mdwn
index 0cab8717b..5172af759 100644
--- a/doc/plugins/highlight.mdwn
+++ b/doc/plugins/highlight.mdwn
@@ -19,7 +19,7 @@ setup file to control which files should be syntax highlighted.
 Here is a typical setting for it, enabling highlighting for files
 with the extensions .c, etc, and also for any files named "Makefile".
 
-	tohighlight => .c, .h, .cpp, .pl, .py, Makefile:make",
+	tohighlight => ".c .h .cpp .pl .py Makefile:make",
 
 It knows what language to use for most filename extensions (see
 `/etc/highlight/filetypes.conf` for a partial list), but if you want to
-- 
cgit v1.2.3


From 47298b01c1921deff7e056406245a90f8371bd59 Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Sat, 23 May 2009 05:17:26 -0400
Subject: allow format to use any language supported by highlight

format: Provide a htmlizefallback hook that other plugins can use to
handle formats that are not suitable for general-purpose htmlize hooks.

highlight: Use the hook to allow formatting of any language/extension,
without it needing to be enabled for standalone source files.

highlight: If the highlight perl binding is not available, fallback
safely to a passthrough mode.
---
 IkiWiki/Plugin/format.pm          | 28 +++++++++++-----
 IkiWiki/Plugin/highlight.pm       | 21 +++++++++++-
 debian/changelog                  |  3 ++
 doc/plugins/highlight.mdwn        | 67 ++++++++++++++++++++-------------------
 doc/todo/syntax_highlighting.mdwn |  6 ++--
 5 files changed, 82 insertions(+), 43 deletions(-)

(limited to 'IkiWiki')

diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm
index bbe3aa9fe..1513cbed7 100644
--- a/IkiWiki/Plugin/format.pm
+++ b/IkiWiki/Plugin/format.pm
@@ -10,21 +10,33 @@ sub import {
 }
 
 sub preprocess (@) {
-	my $format=$_[0];
-	shift; shift;
-	my $text=$_[0];
-	shift; shift;
 	my %params=@_;
+	my $format=shift;
+	shift;
+	my $text=IkiWiki::preprocess($params{page}, $params{destpage}, shift);
+	shift;
 
 	if (! defined $format || ! defined $text) {
 		error(gettext("must specify format and text"));
 	}
-	elsif (! exists $IkiWiki::hooks{htmlize}{$format}) {
-		error(sprintf(gettext("unsupported page format %s"), $format));
+	elsif (exists $IkiWiki::hooks{htmlize}{$format}) {
+		return IkiWiki::htmlize($params{page}, $params{destpage},
+		                        $format, $text);
 	}
+	else {
+		# Other plugins can register htmlizefallback
+		# hooks to add support for page types
+		# not suitable for htmlize. Try them until
+		# one succeeds.
+		my $ret;
+		IkiWiki::run_hooks(htmlizefallback => sub {
+			$ret=shift->($format, $text)
+				unless defined $ret;
+		});
+		return $ret if defined $ret;
 
-	return IkiWiki::htmlize($params{page}, $params{destpage}, $format,
-		IkiWiki::preprocess($params{page}, $params{destpage}, $text));
+		error(sprintf(gettext("unsupported page format %s"), $format));
+	}
 }
 
 1
diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index 117ab5898..f116c41dd 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -4,7 +4,6 @@ package IkiWiki::Plugin::highlight;
 use warnings;
 use strict;
 use IkiWiki 3.00;
-use highlight;
 
 # locations of highlight's files
 my $filetypes="/etc/highlight/filetypes.conf";
@@ -13,6 +12,9 @@ my $langdefdir="/usr/share/highlight/langDefs";
 sub import {
 	hook(type => "getsetup", id => "highlight",  call => \&getsetup);
 	hook(type => "checkconfig", id => "highlight", call => \&checkconfig);
+	# this hook is used by the format plugin
+	hook(type => "htmlizefallback", id => "highlight", call =>
+		\&htmlizefallback);
 }
 
 sub getsetup () {
@@ -59,6 +61,17 @@ sub checkconfig () {
 	}
 }
 
+sub htmlizefallback {
+	my $format=lc shift;
+	my $langfile=ext2langfile($format);
+
+	if (! defined $langfile) {
+		return;
+	}
+
+	return highlight($langfile, shift);
+}
+
 my %ext2lang;
 my $filetypes_read=0;
 
@@ -103,6 +116,12 @@ sub highlight ($$) {
 	my $langfile=shift;
 	my $input=shift;
 
+	eval q{use highlight};
+	if ($@) {
+		print STDERR gettext("warning: highlight perl module not available; falling back to pass through");
+		return $input;
+	}
+
 	my $gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML);
 	$gen->setFragmentCode(1); # generate html fragment
 	$gen->setHTMLEnclosePreTag(1); # include stylish 
diff --git a/debian/changelog b/debian/changelog
index db3e32cda..8088fa705 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,9 @@ ikiwiki (3.14) UNRELEASED; urgency=low
   * debian/control: Add suggests for libhighlight-perl, although
     that package is not yet created by Debian's highlight source package.
     (See #529869)
+  * format: Provide a htmlizefallback hook that other plugins
+    can use to handle formats that are not suitable for general-purpose
+    htmlize hooks. Used by highlight.
 
  -- Joey Hess   Fri, 22 May 2009 22:03:12 -0400
 
diff --git a/doc/plugins/highlight.mdwn b/doc/plugins/highlight.mdwn
index 5172af759..44ced80f7 100644
--- a/doc/plugins/highlight.mdwn
+++ b/doc/plugins/highlight.mdwn
@@ -1,7 +1,7 @@
 [[!template id=plugin name=highlight author="[[Joey]]"]]
 [[!tag type/format]]
 
-This plugin allows ikiwiki to syntax highlight source files, using
+This plugin allows ikiwiki to syntax highlight source code, using
 a fast syntax highlighter that supports over a hundred programming
 languages and file formats.
 
@@ -11,26 +11,10 @@ You will need to install the perl bindings to the
 [highlight library](http://www.andre-simon.de/), which in Debian
 are in the [[!debpkg libhighlight-perl]] package.
 
-## configuration
-
-Nothing will be highlighted by default.
-To enable syntax highlighting, use the `tohighlight` setting in your
-setup file to control which files should be syntax highlighted.
-Here is a typical setting for it, enabling highlighting for files
-with the extensions .c, etc, and also for any files named "Makefile".
-
-	tohighlight => ".c .h .cpp .pl .py Makefile:make",
-
-It knows what language to use for most filename extensions (see
-`/etc/highlight/filetypes.conf` for a partial list), but if you want to
-bind an unusual filename extension, or any file without an extension
-(such as a Makefile), to a language, you can do so by appending a colon
-and the name of the language, as illustrated for Makefiles above.
-
 ## embedding highlighted code
 
 To embed highlighted code on a page, you can use the
-[[ikiwiki/directive/format]] directive.
+[[format]] plugin.
 
 For example:
 
@@ -40,21 +24,36 @@ For example:
 	}
 	"""]]
 
-You can do this for any of the extensions/filenames enabled in
-`tohighlight`.
+	\[[!format diff """
+	-bar
+	+foo
+	"""]]
 
-## colors
+You can do this for any extension or language name supported by
+the [highlight library](http://www.andre-simon.de/) -- basically anything
+you can think of should work.
 
-The colors etc used for the syntax highlighting are entirely configurable
-by CSS. See ikiwiki's [[style.css]] for the defaults.
+## highlighting entire source files
 
-## limitations
+To enable syntax highlighting of entire standalone source files, use the
+`tohighlight` setting in your setup file to control which files should be
+syntax highlighted. Here is a typical setting for it, enabling highlighting
+for files with the extensions .c, etc, and also for any files named
+"Makefile".
 
-With this plugin enabled, source files become full-fledged ikiwiki pages,
-which means they can include [[WikiLinks|ikiwiki/wikilink]] and
-[[directives|ikiwiki/directive]] like any other page can, and are also
-affected by the [[smiley]] plugin, if it is enabled. This can be
-annoying if your code accidentially contains things that look like those.
+	tohighlight => ".c .h .cpp .pl .py Makefile:make",
+
+It knows what language to use for most filename extensions (see
+`/etc/highlight/filetypes.conf` for a partial list), but if you want to
+bind an unusual filename extension, or any file without an extension
+(such as a Makefile), to a language, you can do so by appending a colon
+and the name of the language, as illustrated for Makefiles above.
+
+With the plugin configured this way, source files become full-fledged
+wiki pages, which means they can include [[WikiLinks|ikiwiki/wikilink]]
+and [[directives|ikiwiki/directive]] like any other page can, and are also
+affected by the [[smiley]] plugin, if it is enabled. This can be annoying
+if your code accidentially contains things that look like those.
 
 On the other hand, this also allows your syntax highlighed
 source code to contain markdown formatted comments and hyperlinks
@@ -66,7 +65,11 @@ to other code files, like this:
 		See \[[bar.h]].
 	""]] */
 
-## security
+Finally, bear in mind that this lets anyone who can edit a page in your
+wiki also edit source code files that are in your wiki. Use appropriate
+caution.
+
+## colors
 
-This lets anyone who can edit a page in your wiki also edit
-source code files that are in your wiki. Use appropriate caution.
+The colors etc used for the syntax highlighting are entirely configurable
+by CSS. See ikiwiki's [[style.css]] for the defaults.
diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn
index 01aa7b576..3d122829b 100644
--- a/doc/todo/syntax_highlighting.mdwn
+++ b/doc/todo/syntax_highlighting.mdwn
@@ -36,8 +36,10 @@ work as source-highlight, but in perl.  I plan to package the base module for de
 releases the 5 or 6 language definitions he has running on his web site, it might be suitable for inclusion in ikiwiki. [[DavidBremner]]
 
 * [[plugins/highlight]] uses [highlight](http://www.andre-simon.de) via
-  its swig bindings. It supports whole files only. It uses either
-  keepextension or noextension, as appropriate for the type of file.
+  its swig bindings. It optionally supports whole files, but also
+  integrates with the format directive to allow formatting of *any* of
+  highlight's supported formats. (For whole files, it uses either
+  keepextension or noextension, as appropriate for the type of file.)
 
 ## General problems / requirements
 
-- 
cgit v1.2.3


From 8ba98ad1dcbffe32150745c98d72512a6fa6149e Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Sat, 23 May 2009 05:33:08 -0400
Subject: update

---
 IkiWiki/Plugin/highlight.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'IkiWiki')

diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index f116c41dd..90e7053d9 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -26,7 +26,7 @@ sub getsetup () {
 		tohighlight => {
 			type => "string",
 			example => ".c .h .cpp .pl .py Makefile:make",
-			description => "source files to syntax highlight",
+			description => "types of source files to syntax highlight",
 			safe => 1,
 			rebuild => 1,
 		},
-- 
cgit v1.2.3


From 39e5e250006421535c13b97e9ca28600c8447877 Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Sat, 23 May 2009 18:39:49 -0400
Subject: cache highlighters to optimise

Setting up a new highlighter object is slightly expensive since it
reads and parses the langfile each time. So cache them.

This also speeds up ext2langfile by avoiding it needing to check for the
existence of a language file in some cases.
---
 IkiWiki/Plugin/highlight.pm | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

(limited to 'IkiWiki')

diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index 90e7053d9..4c02f6c23 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -74,6 +74,7 @@ sub htmlizefallback {
 
 my %ext2lang;
 my $filetypes_read=0;
+my %highlighters;
 
 # Parse highlight's config file to get extension => language mappings.
 sub read_filetypes () {
@@ -88,23 +89,23 @@ sub read_filetypes () {
 	$filetypes_read=1;
 }
 
-sub langfile ($) {
-	return "$langdefdir/$_[0].lang";
-}
 
 # Given a filename extension, determines the language definition to
 # use to highlight it.
 sub ext2langfile ($) {
 	my $ext=shift;
 
+	my $langfile="$langdefdir/$ext.lang";
+	return $langfile if exists $highlighters{$langfile};
+
 	read_filetypes() unless $filetypes_read;
 	if (exists $ext2lang{$ext}) {
-		return langfile($ext2lang{$ext});
+		return "$langdefdir/$ext2lang{$ext}.lang";
 	}
 	# If a language only has one common extension, it will not
 	# be listed in filetypes, so check the langfile.
-	elsif (-e langfile($ext)) {
-		return langfile($ext);
+	elsif (-e $langfile) {
+		return $langfile;
 	}
 	else {
 		return undef;
@@ -122,16 +123,21 @@ sub highlight ($$) {
 		return $input;
 	}
 
-	my $gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML);
-	$gen->setFragmentCode(1); # generate html fragment
-	$gen->setHTMLEnclosePreTag(1); # include stylish 
-	$gen->initLanguage($langfile);
-	$gen->initTheme("/dev/null"); # theme is not needed because CSS is not emitted
-	$gen->setEncoding("utf-8");
+	my $gen;
+	if (! exists $highlighters{$langfile}) {
+		$gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML);
+		$gen->setFragmentCode(1); # generate html fragment
+		$gen->setHTMLEnclosePreTag(1); # include stylish 
+		$gen->initLanguage($langfile);
+		$gen->initTheme("/dev/null"); # theme is not needed because CSS is not emitted
+		$gen->setEncoding("utf-8");
+		$highlighters{$langfile}=$gen;
+	}
+	else {		
+		$gen=$highlighters{$langfile};
+	}
 
-	my $output=$gen->generateString($input);
-	highlightc::CodeGenerator_deleteInstance($gen);
-	return $output;
+	return $gen->generateString($input);
 }
 
 1
-- 
cgit v1.2.3


From 96087cbd88fd056ae34675abfb0e3e411f019763 Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Tue, 26 May 2009 17:04:49 -0400
Subject: call initLanguage after initTheme

See #530654
---
 IkiWiki/Plugin/highlight.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'IkiWiki')

diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm
index 4c02f6c23..20f79ef57 100644
--- a/IkiWiki/Plugin/highlight.pm
+++ b/IkiWiki/Plugin/highlight.pm
@@ -128,8 +128,8 @@ sub highlight ($$) {
 		$gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML);
 		$gen->setFragmentCode(1); # generate html fragment
 		$gen->setHTMLEnclosePreTag(1); # include stylish 
-		$gen->initLanguage($langfile);
 		$gen->initTheme("/dev/null"); # theme is not needed because CSS is not emitted
+		$gen->initLanguage($langfile); # must come after initTheme
 		$gen->setEncoding("utf-8");
 		$highlighters{$langfile}=$gen;
 	}
-- 
cgit v1.2.3


From 5cdee82ef6c8f9fa888b35ef81f2bcc35dd8ce4a Mon Sep 17 00:00:00 2001
From: Joey Hess 
Date: Tue, 2 Jun 2009 17:06:46 -0400
Subject: comment: Make comment directives no longer use the internal
 "_comment" form, and document the comment directive syntax.

Rationalle: Comments need to be user-editable so that they can be posted
via git commit etc.

The _comment directive is still supported, for back-compat.
---
 IkiWiki/Plugin/comments.pm         |  4 +++-
 debian/changelog                   |  7 +++++++
 doc/ikiwiki/directive/comment.mdwn | 38 ++++++++++++++++++++++++++++++++++++++
 doc/plugins/comments.mdwn          |  2 +-
 templates/editcomment.tmpl         |  1 -
 5 files changed, 49 insertions(+), 3 deletions(-)
 create mode 100644 doc/ikiwiki/directive/comment.mdwn

(limited to 'IkiWiki')

diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm
index 0aa4759d8..517e16f9f 100644
--- a/IkiWiki/Plugin/comments.pm
+++ b/IkiWiki/Plugin/comments.pm
@@ -21,6 +21,8 @@ my %commentstate;
 sub import {
 	hook(type => "checkconfig", id => 'comments',  call => \&checkconfig);
 	hook(type => "getsetup", id => 'comments',  call => \&getsetup);
+	hook(type => "preprocess", id => 'comment', call => \&preprocess);
+	# here for backwards compatability with old comments
 	hook(type => "preprocess", id => '_comment', call => \&preprocess);
 	hook(type => "sessioncgi", id => 'comment', call => \&sessioncgi);
 	hook(type => "htmlize", id => "_comment", call => \&htmlize);
@@ -377,7 +379,7 @@ sub editcomment ($$) {
 
 	my $location=unique_comment_location($page, $config{srcdir});
 
-	my $content = "[[!_comment format=$type\n";
+	my $content = "[[!comment format=$type\n";
 
 	# FIXME: handling of double quotes probably wrong?
 	if (defined $session->param('name')) {
diff --git a/debian/changelog b/debian/changelog
index 4a1844e06..cee073b3a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ikiwiki (3.15) UNRELEASED; urgency=low
+
+  * comment: Make comment directives no longer use the internal "_comment"
+    form, and document the comment directive syntax.
+
+ -- Joey Hess   Tue, 02 Jun 2009 17:03:41 -0400
+
 ikiwiki (3.14) unstable; urgency=low
 
   * highlight: New plugin supporting syntax highlighting of pretty much
diff --git a/doc/ikiwiki/directive/comment.mdwn b/doc/ikiwiki/directive/comment.mdwn
new file mode 100644
index 000000000..f03664d13
--- /dev/null
+++ b/doc/ikiwiki/directive/comment.mdwn
@@ -0,0 +1,38 @@
+The `comment` directive is supplied by the
+[[!iki plugins/comment desc=comment]] plugin, and is used to add a comment
+to a page. Typically, the directive is the only thing on a comment page,
+and is filled out by the comment plugin when a user posts a comment.
+
+Example:
+
+	\[[!comment format=mdwn
+	username="foo"
+	subject="Bar"
+	date="2009-06-02T19:05:01Z"
+	content="""
+	Blah blah.
+	"""
+	]]
+
+## usage
+
+The only required parameter is `content`, the others just add or override
+metadata of the comment.
+
+* `content` - Text to display for the comment.
+  Note that [[directives|ikiwiki/directive]]
+  may not be allowed, depending on the configuration
+  of the comment plugin.
+* `format` - Specifies the markup used for the content.
+* `subject` - Subject for the comment.
+* `date` - Date the comment was posted. Can be entered in
+  nearly any format, since it's parsed by [[!cpan TimeDate]]
+* `username` - Used to record the username (or OpenID)
+  of a logged in commenter.
+* `ip` - Can be used to record the IP address of a commenter,
+  if they posted anonymously.
+* `claimedauthor` - Records the name that the user entered,
+  if anonmous commenters are allowed to enter their (unverified)
+  name.
+
+[[!meta robots="noindex, follow"]]
diff --git a/doc/plugins/comments.mdwn b/doc/plugins/comments.mdwn
index c13a6daa6..7e2232411 100644
--- a/doc/plugins/comments.mdwn
+++ b/doc/plugins/comments.mdwn
@@ -19,7 +19,7 @@ users can only post comments.
 
 Individual comments are stored as internal-use pages named something like
 `page/comment_1`, `page/comment_2`, etc. These pages internally use a
-`\[[!_comment]]` [[ikiwiki/directive]].
+[[comment_directive|ikiwiki/directive/comment]].
 
 There are some global options for the setup file:
 
diff --git a/templates/editcomment.tmpl b/templates/editcomment.tmpl
index 27d9457d4..545edb596 100644
--- a/templates/editcomment.tmpl
+++ b/templates/editcomment.tmpl
@@ -16,7 +16,6 @@ Website:  (optional)
Subject:


-IkiWiki directives ([[!directive]]) are not allowed in comments on this wiki.
-- cgit v1.2.3 From 6842328405494dd4971d3bfa443901084efe87ed Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 4 Jun 2009 13:15:05 -0400 Subject: Avoid relying on translators preserving the case when translating "discussion", which caused Discussion pages to get unwanted Discussion links. --- IkiWiki/Render.pm | 2 +- debian/changelog | 3 +++ doc/bugs/unwanted_discussion_links_on_discussion_pages.mdwn | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index adae9f0d5..ba1d1eae5 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -76,7 +76,7 @@ sub genpage ($$) { $actions++; } if ($config{discussion}) { - my $discussionlink=gettext("discussion"); + my $discussionlink=lc(gettext("Discussion")); if ($page !~ /.*\/\Q$discussionlink\E$/ && (length $config{cgiurl} || exists $links{$page."/".$discussionlink})) { diff --git a/debian/changelog b/debian/changelog index cee073b3a..be1db6f3c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ ikiwiki (3.15) UNRELEASED; urgency=low * comment: Make comment directives no longer use the internal "_comment" form, and document the comment directive syntax. + * Avoid relying on translators preserving the case when translating + "discussion", which caused Discussion pages to get unwanted Discussion + links. -- Joey Hess Tue, 02 Jun 2009 17:03:41 -0400 diff --git a/doc/bugs/unwanted_discussion_links_on_discussion_pages.mdwn b/doc/bugs/unwanted_discussion_links_on_discussion_pages.mdwn index c7506c6de..c74a094ce 100644 --- a/doc/bugs/unwanted_discussion_links_on_discussion_pages.mdwn +++ b/doc/bugs/unwanted_discussion_links_on_discussion_pages.mdwn @@ -31,4 +31,6 @@ A simple fix that seems to work is to make this regexp case-insensitive: But the best way would be to avoid assuming implicitely that translators will translate "discussion" and "Discussion" the same way. +> [[done]] --[[Joey]] + [[!tag patch]] -- cgit v1.2.3 From 059d6f01fa7b34b67d60b99ccbc21bf188543531 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 4 Jun 2009 13:20:52 -0400 Subject: fix further places where translated discussion case was assumed Another benefit is that consistently using gettext("Discussion") eliminates the need to translate one string. --- IkiWiki/Plugin/brokenlinks.pm | 2 +- IkiWiki/Plugin/editpage.pm | 2 +- IkiWiki/Plugin/inline.pm | 2 +- IkiWiki/Plugin/opendiscussion.pm | 2 +- IkiWiki/Plugin/orphans.pm | 2 +- IkiWiki/Render.pm | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index da97dbc28..cf8f25281 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -30,7 +30,7 @@ sub preprocess (@) { my %broken; foreach my $page (pagespec_match_list([keys %links], $params{pages}, location => $params{page})) { - my $discussion=gettext("discussion"); + my $discussion=gettext("Discussion"); my %seen; foreach my $link (@{$links{$page}}) { next if $seen{$link}; diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 8effc02d0..467cd9ed5 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -230,7 +230,7 @@ sub cgi_editpage ($$) { $dir=~s![^/]+/+$!!; if ((defined $form->field('subpage') && length $form->field('subpage')) || - $page eq gettext('discussion')) { + $page eq lc(gettext('Discussion'))) { $best_loc="$from/$page"; } else { diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 27ea1c4a6..9d5ebc34d 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -354,7 +354,7 @@ sub preprocess_inline (@) { my $file = $pagesources{$page}; my $type = pagetype($file); if ($config{discussion}) { - my $discussionlink=gettext("discussion"); + my $discussionlink=lc(gettext("Discussion")); if ($page !~ /.*\/\Q$discussionlink\E$/ && (length $config{cgiurl} || exists $links{$page."/".$discussionlink})) { diff --git a/IkiWiki/Plugin/opendiscussion.pm b/IkiWiki/Plugin/opendiscussion.pm index 3da01efee..60b193eca 100644 --- a/IkiWiki/Plugin/opendiscussion.pm +++ b/IkiWiki/Plugin/opendiscussion.pm @@ -23,7 +23,7 @@ sub canedit ($$) { my $cgi=shift; my $session=shift; - my $discussion=gettext("discussion"); + my $discussion=lc(gettext("Discussion")); return "" if $page=~/(\/|^)\Q$discussion\E$/; return undef; } diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index cf74c9b79..944eba541 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -34,7 +34,7 @@ sub preprocess (@) { } my @orphans; - my $discussion=gettext("discussion"); + my $discussion=lc(gettext("Discussion")); foreach my $page (pagespec_match_list( [ grep { ! $linkedto{$_} && $_ ne 'index' } keys %pagesources ], diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index ba1d1eae5..f4de19378 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -146,7 +146,7 @@ sub scan ($) { if ($config{discussion}) { # Discussion links are a special case since they're # not in the text of the page, but on its template. - $links{$page}=[ $page."/".gettext("discussion") ]; + $links{$page}=[ $page."/".lc(gettext("Discussion")) ]; } else { $links{$page}=[]; -- cgit v1.2.3 From 0293ae8e3d8e7dfd0a92bf20aa4c3d28e2d78ddb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 5 Jun 2009 16:58:06 -0400 Subject: Setup automator: Check that each plugin added to the generated setup file can be loaded and that its config is ok. If a plugin fails for any reason, disable it in the generated file. Closes: 532001 --- IkiWiki/Setup/Automator.pm | 23 +++++++++++++++++++++++ debian/changelog | 4 ++++ 2 files changed, 27 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index 5111541e4..742d67666 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -98,6 +98,29 @@ sub import (@) { } } + # Make sure that all the listed plugins can load + # and checkconfig is ok. If a plugin fails to work, + # remove it from the configuration and keep on truckin'. + my %bakconfig=%config; # checkconfig can modify %config so back up + if (! eval { IkiWiki::loadplugins(); IkiWiki::checkconfig() }) { + foreach my $plugin (@{$config{default_plugins}}, @{$bakconfig{add_plugins}}) { + eval { + # delete all hooks so that only this plugins's + # checkconfig will be run + %IkiWiki::hooks=(); + IkiWiki::loadplugin($plugin); + IkiWiki::run_hooks(checkconfig => sub { shift->() }); + }; + if ($@) { + print STDERR sprintf(gettext("** Disabling plugin %s, since it is failing with this message:"), + $plugin)."\n"; + print STDERR "$@\n"; + push @{$bakconfig{disable_plugins}}, $plugin; + } + } + } + %config=%bakconfig; + # Generate setup file. require IkiWiki::Setup; IkiWiki::Setup::dump($config{dumpsetup}); diff --git a/debian/changelog b/debian/changelog index bbc9b2c15..7d0fb5c80 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,10 @@ ikiwiki (3.15) UNRELEASED; urgency=low allow an unterminated """ string to be treated as a series of bare words. Fixes runaway regexp recursion/backtracking in strange situations. + * Setup automator: Check that each plugin added to the generated + setup file can be loaded and that its config is ok. If a plugin + fails for any reason, disable it in the generated file. + Closes: 532001 -- Joey Hess Tue, 02 Jun 2009 17:03:41 -0400 -- cgit v1.2.3 From e8d8386e5258c055f253b20ad717461972b11c7d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 5 Jun 2009 18:04:39 -0400 Subject: pagecount: Fix broken optimisation for * pagespec. --- IkiWiki/Plugin/pagecount.pm | 9 +++++++-- debian/changelog | 1 + doc/bugs/pagecount_is_broken.mdwn | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index 1955603b0..5a2301af4 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -26,8 +26,13 @@ sub preprocess (@) { # register a dependency. add_depends($params{page}, $params{pages}); - my @pages=pagespec_match_list([keys %pagesources], $params{pages}, location => $params{page}) - if $params{pages} ne "*"; # optimisation; + my @pages; + if ($params{pages} eq "*") { + @pages=keys %pagesources; + } + else { + @pages=pagespec_match_list([keys %pagesources], $params{pages}, location => $params{page}); + } return $#pages+1; } diff --git a/debian/changelog b/debian/changelog index 7d0fb5c80..df4429326 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,7 @@ ikiwiki (3.15) UNRELEASED; urgency=low setup file can be loaded and that its config is ok. If a plugin fails for any reason, disable it in the generated file. Closes: 532001 + * pagecount: Fix broken optimisation for * pagespec. -- Joey Hess Tue, 02 Jun 2009 17:03:41 -0400 diff --git a/doc/bugs/pagecount_is_broken.mdwn b/doc/bugs/pagecount_is_broken.mdwn index 179981855..101230d94 100644 --- a/doc/bugs/pagecount_is_broken.mdwn +++ b/doc/bugs/pagecount_is_broken.mdwn @@ -1 +1,3 @@ The [[plugins/pagecount]] plugin seems to be broken, as it claims there are [[!pagecount ]] pages in this wiki. (if it's not 0, the bug is fixed) + +[[fixed|done]] --[[Joey]] -- cgit v1.2.3 From e40d2a6b2b1bdf677f11cc4a71595acf609d1e75 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 6 Jun 2009 02:36:40 -0400 Subject: goto: Support being passed a page title that is not a valid page name, to support several cases including mercurial's long user names on the RecentChanges page, and urls with spaces being handled by the 404 plugin. --- IkiWiki/Plugin/goto.pm | 6 ++++++ debian/changelog | 4 ++++ doc/bugs/goto_with_bad_page_name.mdwn | 2 ++ 3 files changed, 12 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm index 3f40c5859..2e2dc04a1 100644 --- a/IkiWiki/Plugin/goto.pm +++ b/IkiWiki/Plugin/goto.pm @@ -32,6 +32,12 @@ sub cgi_goto ($;$) { } } + # It's possible that $page is not a valid page name; + # if so attempt to turn it into one. + if ($page !~ /$config{wiki_file_regexp}/) { + $page=titlepage($page); + } + IkiWiki::loadindex(); # If the page is internal (like a comment), see if it has a diff --git a/debian/changelog b/debian/changelog index df4429326..7f8257813 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,10 @@ ikiwiki (3.15) UNRELEASED; urgency=low fails for any reason, disable it in the generated file. Closes: 532001 * pagecount: Fix broken optimisation for * pagespec. + * goto: Support being passed a page title that is not a valid page + name, to support several cases including mercurial's long user + names on the RecentChanges page, and urls with spaces being handled + by the 404 plugin. -- Joey Hess Tue, 02 Jun 2009 17:03:41 -0400 diff --git a/doc/bugs/goto_with_bad_page_name.mdwn b/doc/bugs/goto_with_bad_page_name.mdwn index 722c4e266..bc462c840 100644 --- a/doc/bugs/goto_with_bad_page_name.mdwn +++ b/doc/bugs/goto_with_bad_page_name.mdwn @@ -20,4 +20,6 @@ pass it through titlepage if not. with spaces" to "http://wiki/some_page_with_spaces", if the latter exists. That seems like a fairly good thing.) +[[done]] + --[[Joey]] -- cgit v1.2.3