X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/2f33f294d95def3c50a467c5b5b9c5f5cae9e5fb..3bb00d142a4d31316fc6f0eb1277aa2fafe4dbe9:/doc/todo/color_plugin.mdwn?ds=inline
diff --git a/doc/todo/color_plugin.mdwn b/doc/todo/color_plugin.mdwn
index 68370158c..19fba3b35 100644
--- a/doc/todo/color_plugin.mdwn
+++ b/doc/todo/color_plugin.mdwn
@@ -103,6 +103,23 @@ Of course, I'm open for discussion or exchange of ideas :) --[[PaweÅ|ptecza]]
> One question, why the 2px padding for span.color? --[[Joey]]
+>> Sorry for a long silence, but I had Internet free summer holiday :)
+>> I did that, because backgrounded text without any padding looks
+>> strange for me ;) You can remove it if you don't like that padding.
+>> --[[PaweÅ|ptecza]]
+
+>>> Joey, will you add that plugin to Ikiwiki 2.61? :) --[[PaweÅ|ptecza]]
+
+>>>> I also had a long net-free summer holiday. :-) The [[patch]] is
+>>>> ready for integration (made a few minor changes). Is this GPL 2?
+>>>> --[[Joey]]
+
+>>>>> No problem. I guessed it, because I've not seen your commits
+>>>>> at [[RecentChanges]] page in last days and I subscribe your
+>>>>> [blog](http://kitenet.net/~joey/blog/entry/vacation/) :D
+>>>>> It's GPL-2+ like your Ikiwiki and the most external plugins.
+>>>>> --[[PaweÅ|ptecza]]
+
--- /dev/null 2008-06-21 02:02:15.000000000 +0200
+++ color.pm 2008-07-27 14:58:12.000000000 +0200
@@ -0,0 +1,69 @@
@@ -115,12 +132,12 @@ Of course, I'm open for discussion or exchange of ideas :) --[[PaweÅ|ptecza]]
+use strict;
+use IkiWiki 2.00;
+
- +sub import { #{{{
+ +sub import {
+ hook(type => "preprocess", id => "color", call => \&preprocess);
+ hook(type => "format", id => "color", call => \&format);
- +} #}}}
+ +}
+
- +sub preserve_style($$$) { #{{{
+ +sub preserve_style ($$$) {
+ my $foreground = shift;
+ my $background = shift;
+ my $text = shift;
@@ -145,18 +162,18 @@ Of course, I'm open for discussion or exchange of ideas :) --[[PaweÅ|ptecza]]
+
+ return $preserved;
+
- +} #}}}
+ +}
+
- +sub replace_preserved_style($) { #{{{
+ +sub replace_preserved_style ($) {
+ my $content = shift;
+
+ $content =~ s!((color: ([a-z]+|\#[0-9a-f]{3,6})?)?((; )?(background-color: ([a-z]+|\#[0-9a-f]{3,6})?)?)?)!!g;
+ $content =~ s!!!g;
+
+ return $content;
- +} #}}}
+ +}
+
- +sub preprocess(@) { #{{{
+ +sub preprocess (@) {
+ my %params = @_;
+
+ # Preprocess the text to expand any preprocessor directives
@@ -165,14 +182,14 @@ Of course, I'm open for discussion or exchange of ideas :) --[[PaweÅ|ptecza]]
+ IkiWiki::filter($params{page}, $params{destpage}, $params{text}));
+
+ return preserve_style($params{foreground}, $params{background}, $params{text});
- +} #}}}
+ +}
+
- +sub format(@) { #{{{
+ +sub format (@) {
+ my %params = @_;
+
+ $params{content} = replace_preserved_style($params{content});
+ return $params{content};
- +} #}}}
+ +}
+
+1
--- /dev/null 2008-06-21 02:02:15.000000000 +0200
@@ -180,29 +197,26 @@ Of course, I'm open for discussion or exchange of ideas :) --[[PaweÅ|ptecza]]
@@ -0,0 +1,25 @@
+\[[!template id=plugin name=color core=0 author="[[ptecza]]"]]
+
- +This plugin can be used to color a piece of text on Ikiwiki page.
- +It's possible setting foreground and/or background color of the text.
+ +This plugin can be used to color a piece of text on a page.
+ +It can be used to set the foreground and/or background color of the text.
+
- +You can use name (e.g. `white`) or HTML code of colors (e.g. `#ffffff`)
+ +You can use a color name (e.g. `white`) or HTML code (e.g. `#ffffff`)
+to define colors.
+
+Below are a few examples:
+
+ \[[!color foreground=white background=#ff0000 text="White text on red background"]]
+
- +Foreground color is defined as a word, background color is defined as HTML
+ +In the above example, the foreground color is defined as a word, while the background color is defined as a HTML
+color code.
+
+ \[[!color foreground=white text="White text on default color background"]]
+
- +Background color is missing, so the text is displayed on default background.
+ +The background color is missing, so the text is displayed on default background.
+
+ \[[!color background=#ff0000 text="Default color text on red background"]]
+
- +Foreground is missing, so the text has default color.
- +
- +This plugin is not enabled by default. You can do that in [[ikiwiki.setup]]
- +file (hint: `add_plugins` variable).
+ +The foreground is missing, so the text has the default foreground color.
--- style.css-orig 2008-07-27 15:12:39.000000000 +0200
+++ style.css 2008-07-27 15:15:06.000000000 +0200
@@ -333,3 +333,7 @@
@@ -213,3 +227,5 @@ Of course, I'm open for discussion or exchange of ideas :) --[[PaweÅ|ptecza]]
+span.color {
+ padding: 2px;
+}
+
+[[done]]