]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Run page through any relevant filters when generating a page preview.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 26 Jul 2006 21:54:44 +0000 (21:54 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 26 Jul 2006 21:54:44 +0000 (21:54 +0000)
* Noticed a bug in the wikitext markup plugin -- it made CamelCase links the
  default throughout the wiki, not only on wikitext pages. Decided to call
  this a feature, and split the camelcase support out into a separate plugin
  that is independant of wikitext.

IkiWiki/CGI.pm
IkiWiki/Plugin/camelcase.pm [new file with mode: 0644]
IkiWiki/Plugin/wikitext.pm
IkiWiki/Render.pm
debian/changelog
doc/plugins/camelcase.mdwn [new file with mode: 0644]
doc/plugins/wikitext.mdwn

index 759a49b7da6697df3b305930836acbf74914dd89..7360ca998f29757032955d343122ab2cf32002e8 100644 (file)
@@ -417,7 +417,7 @@ sub cgi_editpage ($$) { #{{{
                $form->field(name => "comments",
                                value => $comments, force => 1);
                $form->tmpl_param("page_preview",
                $form->field(name => "comments",
                                value => $comments, force => 1);
                $form->tmpl_param("page_preview",
-                       htmlize($type, linkify($page, $page, $content)));
+                       htmlize($type, linkify($page, $page, filter($page, $content))));
        }
        else {
                $form->tmpl_param("page_preview", "");
        }
        else {
                $form->tmpl_param("page_preview", "");
diff --git a/IkiWiki/Plugin/camelcase.pm b/IkiWiki/Plugin/camelcase.pm
new file mode 100644 (file)
index 0000000..0934b27
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+# CamelCase links
+package IkiWiki::Plugin::camelcase;
+
+use warnings;
+use strict;
+
+sub import { #{{{
+       IkiWiki::hook(type => "filter", id => "camelcase", call => \&filter);
+} # }}}
+
+sub filter (@) { #{{{
+       my %params=@_;
+
+       # Make CamelCase links work by promoting them to fullfledged
+       # WikiLinks. This regexp is based on the one in Text::WikiFormat.
+       $params{content}=~s#(?<![["/>=])\b((?:[A-Z][a-z0-9]\w*){2,})#[[$1]]#g;
+
+       return $params{content};
+} #}}}
+
+1
index 310b86724358db7ea68a0af9f8da0d4d899772c2..8b8cbe75e7711c3d17abe7f94ecedfca94f99d16 100644 (file)
@@ -7,20 +7,9 @@ use strict;
 use Text::WikiFormat;
 
 sub import { #{{{
 use Text::WikiFormat;
 
 sub import { #{{{
-       IkiWiki::hook(type => "filter", id => "wiki", call => \&filter);
        IkiWiki::hook(type => "htmlize", id => "wiki", call => \&htmlize);
 } # }}}
 
        IkiWiki::hook(type => "htmlize", id => "wiki", call => \&htmlize);
 } # }}}
 
-sub filter (@) { #{{{
-       my %params=@_;
-
-       # Make CamelCase links work by promoting them to fullfledged
-       # WikiLinks. This regexp is based on the one in Text::WikiFormat.
-       $params{content}=~s#(?<![["/>=])\b((?:[A-Z][a-z0-9]\w*){2,})#[[$1]]#g;
-
-       return $params{content};
-} #}}}
-
 sub htmlize ($) { #{{{
        my $content = shift;
 
 sub htmlize ($) { #{{{
        my $content = shift;
 
index 6d5ea9ee587ebe470d6ee2b55d681f659da73572..e5a1679f8fbf9df3e91c54cb5f973ac3dca2d414 100644 (file)
@@ -250,6 +250,22 @@ sub findlinks ($$) { #{{{
        }
 } #}}}
 
        }
 } #}}}
 
+sub filter ($$) {
+       my $page=shift;
+       my $content=shift;
+
+       if (exists $hooks{filter}) {
+               foreach my $id (keys %{$hooks{filter}}) {
+                       $content=$hooks{filter}{$id}{call}->(
+                               page => $page,
+                               content => $content
+                       );
+               }
+       }
+
+       return $content;
+}
+
 sub render ($) { #{{{
        my $file=shift;
        
 sub render ($) { #{{{
        my $file=shift;
        
@@ -260,14 +276,7 @@ sub render ($) { #{{{
                my $page=pagename($file);
                delete $depends{$page};
                
                my $page=pagename($file);
                delete $depends{$page};
                
-               if (exists $hooks{filter}) {
-                       foreach my $id (keys %{$hooks{filter}}) {
-                               $content=$hooks{filter}{$id}{call}->(
-                                       page => $page,
-                                       content => $content
-                               );
-                       }
-               }
+               $content=filter($page, $content);
                
                $links{$page}=[findlinks($page, $content)];
                
                
                $links{$page}=[findlinks($page, $content)];
                
index 69436fb41d3267a5e57ba0383830fa14a4a8c5ce..aa139be64d7c751ed23c82fb62b8f268a6b56c40 100644 (file)
@@ -1,3 +1,13 @@
+ikiwiki (1.10) UNRELEASED; urgency=low
+
+  * Run page through any relevant filters when generating a page preview.
+  * Noticed a bug in the wikitext markup plugin -- it made CamelCase links the
+    default throughout the wiki, not only on wikitext pages. Decided to call
+    this a feature, and split the camelcase support out into a separate plugin
+    that is independant of wikitext.
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 26 Jul 2006 17:44:25 -0400
+
 ikiwiki (1.9) unstable; urgency=low
 
   * Improve display of parentlinks and page title of toplevel index page.
 ikiwiki (1.9) unstable; urgency=low
 
   * Improve display of parentlinks and page title of toplevel index page.
diff --git a/doc/plugins/camelcase.mdwn b/doc/plugins/camelcase.mdwn
new file mode 100644 (file)
index 0000000..1344609
--- /dev/null
@@ -0,0 +1,7 @@
+This plugin makes words in CamelCase be treated as [[WikiLinks]]. That is
+to say, any two or more words capitalised and mashed together are assumed
+to be the name of some other page on the wiki, and so become a link.
+
+This plugin is included in ikiwiki, but is not enabled by default.
+
+If this plugin is enabled, here is a link: SandBox
index 5c5383fc5db76f8c2b9d18c44b88aa5028b73c56..1c2d72bb20e71f6f7957d5a2b9bcf675f8dc4f24 100644 (file)
@@ -4,12 +4,13 @@ installed, enable the plugin, then files with the extention `.wiki` will be
 processed as wiki text.
 
 Wiki formatting is very simple. An item wrapped in three single quotes is
 processed as wiki text.
 
 Wiki formatting is very simple. An item wrapped in three single quotes is
-strong. An item wrapped in two single quotes is emphasized. Any word with
-multiple CapitalLetters (e. g., StudlyCaps) will become a link (standard
-[[WikiLinks|WikiLink]] work too). Four or more
-hyphen characters at the start of a line create a horizontal line.
-Newlines turn into the appropriate tags. Headers are matching equals signs
-around the header text -- the more signs, the lesser the header.
+strong. An item wrapped in two single quotes is emphasized. Four or more
+hyphen characters at the start of a line create a horizontal line. Newlines
+turn into the appropriate tags. Headers are matching equals signs around
+the header text -- the more signs, the lesser the header.
+
+Links are standard [[WikiLinks|WikiLink]], although you can also enable
+[[CamelCase]] links.
 
 Lists are indented text, by one tab or four spaces. In unordered lists,
 where each item has its own bullet point, each item needs a leading
 
 Lists are indented text, by one tab or four spaces. In unordered lists,
 where each item has its own bullet point, each item needs a leading