]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/localstyle.pm
localstyle: New plugin, allows overrding the toplevel local.css with one that is...
[git.ikiwiki.info.git] / IkiWiki / Plugin / localstyle.pm
diff --git a/IkiWiki/Plugin/localstyle.pm b/IkiWiki/Plugin/localstyle.pm
new file mode 100644 (file)
index 0000000..111f4dc
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+package IkiWiki::Plugin::localstyle;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+       hook(type => "getsetup", id => "localstyle", call => \&getsetup);
+       hook(type => "pagetemplate", id => "localstyle", call => \&pagetemplate);
+}
+
+sub getsetup () {
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => 1,
+               },
+}
+
+sub pagetemplate (@) {
+       my %params=@_;
+       
+       my $template=$params{template};
+       
+       if ($template->query(name => "local_css")) {
+               my $best=bestlink($params{page}, 'local.css');
+               if ($best) {
+                       $template->param(local_css => $best);
+               }
+       }
+}
+
+1