From: Joey Hess Date: Wed, 16 Jun 2010 19:43:42 +0000 (-0400) Subject: add theme plugin X-Git-Tag: 3.20100623~47^2~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=062ed44f47d61c3bbbf2e8a7944a9b4e423b735a;p=ikiwiki.git add theme plugin --- diff --git a/IkiWiki/Plugin/theme.pm b/IkiWiki/Plugin/theme.pm new file mode 100644 index 000000000..5e6e4b092 --- /dev/null +++ b/IkiWiki/Plugin/theme.pm @@ -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 diff --git a/Makefile.PL b/Makefile.PL index 4001c841b..29ec9c209 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -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 \ diff --git a/debian/changelog b/debian/changelog index 1f350912e..0d49df676 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Fri, 11 Jun 2010 13:39:15 -0400 diff --git a/doc/plugins/theme.pm b/doc/plugins/theme.pm new file mode 100644 index 000000000..7149cc163 --- /dev/null +++ b/doc/plugins/theme.pm @@ -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. diff --git a/underlays/themes/actiontabs/style.css b/themes/actiontabs/style.css similarity index 100% rename from underlays/themes/actiontabs/style.css rename to themes/actiontabs/style.css diff --git a/underlays/themes/bzed/background_darkness.png b/themes/bzed/background_darkness.png similarity index 100% rename from underlays/themes/bzed/background_darkness.png rename to themes/bzed/background_darkness.png diff --git a/underlays/themes/bzed/style.css b/themes/bzed/style.css similarity index 100% rename from underlays/themes/bzed/style.css rename to themes/bzed/style.css