add theme plugin
authorJoey Hess <joey@kitenet.net>
Wed, 16 Jun 2010 19:43:42 +0000 (15:43 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 16 Jun 2010 19:43:42 +0000 (15:43 -0400)
IkiWiki/Plugin/theme.pm [new file with mode: 0644]
Makefile.PL
debian/changelog
doc/plugins/theme.pm [new file with mode: 0644]
themes/actiontabs/style.css [moved from underlays/themes/actiontabs/style.css with 100% similarity]
themes/bzed/background_darkness.png [moved from underlays/themes/bzed/background_darkness.png with 100% similarity]
themes/bzed/style.css [moved from underlays/themes/bzed/style.css with 100% similarity]

diff --git a/IkiWiki/Plugin/theme.pm b/IkiWiki/Plugin/theme.pm
new file mode 100644 (file)
index 0000000..5e6e4b0
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::theme;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+       hook(type => "getsetup", id => "theme", call => \&getsetup);
+       hook(type => "checkconfig", id => "theme", call => \&checkconfig);
+}
+
+sub getsetup () {
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => 0,
+                       section => "web",
+               },
+               theme => {
+                       type => "string",
+                       example => "actiontabs",
+                       description => "name of theme to enable",
+                       safe => 1,
+                       rebuild => 0,
+               },
+}
+
+my $added=0;
+sub checkconfig () {
+       if (! $added && exists $config{theme} && $config{theme} =~ /^\w+$/) {
+               add_underlay("themes/".$config{theme});
+               $added=1;
+       }
+}
+
+1
index 4001c841b8f79c9a98870f526f2553db615602ca..29ec9c20976361a88ac8eb7f805c7b483fea2ca4 100755 (executable)
@@ -78,7 +78,19 @@ underlay_install:
                        install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive; \
                fi \
        done
-       
+
+       # Themes have their style.css appended to the normal one.
+       for theme in themes/*; do \
+               install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$theme; \
+               for file in $$theme/*; do \
+                       if echo "$$file" | grep -q style.css; then \
+                               (cat doc/style.css; cat $$file) >> $(DESTDIR)$(PREFIX)/share/ikiwiki/$$theme/style.css; \
+                       elif [ -f "$$file" ]; then \
+                               install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$file; \
+                       fi \
+               done; \
+       done
+
 extra_install: underlay_install
        # Install example sites.
        for dir in `cd doc/examples; find . -type d ! -regex '.*\.svn.*'`; do \
index 1f350912e5d8e40f7b05d94ce5d0a8df827a7171..0d49df676d2ac1be5fa7cba0b65776072f215d52 100644 (file)
@@ -22,6 +22,7 @@ ikiwiki (3.20100611) UNRELEASED; urgency=low
   * git: Gix --gettime to properly support utf8 filenames.
   * attachment: Support Windows paths when taking basename of client-supplied
     file name.
+  * theme: New plugin, allows easily theming a site via the underlay.
 
  -- Joey Hess <joeyh@debian.org>  Fri, 11 Jun 2010 13:39:15 -0400
 
diff --git a/doc/plugins/theme.pm b/doc/plugins/theme.pm
new file mode 100644 (file)
index 0000000..7149cc1
--- /dev/null
@@ -0,0 +1,11 @@
+[[!template id=plugin name=theme author="[[Joey]]"]]
+[[!tag type/web]]
+
+The theme plugin allows easily applying a theme to your wiki, by
+configuring the `theme` setting in the setup file with the name of a theme
+to use. The themes you can choose from are all subdirectories, typically
+inside `/usr/share/ikiwiki/themes/`.
+
+A theme provides, via the underlay, an enhanced version of the regular
+[[style.css]]. This leaves [[local.css]] free for you to further
+customise. Themes can also provide header and background images.