2 package IkiWiki::Plugin::theme;
9 hook(type => "getsetup", id => "theme", call => \&getsetup);
10 hook(type => "checkconfig", id => "theme", call => \&checkconfig);
11 hook(type => "needsbuild", id => "theme", call => \&needsbuild);
12 hook(type => "pagetemplate", id => "theme", call => \&pagetemplate);
24 example => "actiontabs",
25 description => "name of theme to enable",
33 if (! $added && exists $config{theme} && $config{theme} =~ /^\w+$/) {
34 add_underlay("themes/".$config{theme});
41 if (($config{theme} || '') ne ($wikistate{theme}{currenttheme} || '')) {
42 # theme changed; ensure all files in the theme are built
43 my %needsbuild=map { $_ => 1 } @$needsbuild;
45 foreach my $file (glob("$config{underlaydirbase}/themes/$config{theme}/*")) {
47 my $f=IkiWiki::basename($file);
49 unless $needsbuild{$f};
53 elsif ($wikistate{theme}{currenttheme}) {
54 foreach my $file (glob("$config{underlaydirbase}/themes/$wikistate{theme}{currenttheme}/*")) {
55 my $f=IkiWiki::basename($file);
56 if (-f $file && defined eval { srcfile($f) }) {
57 push @$needsbuild, $f;
62 $wikistate{theme}{currenttheme}=$config{theme};
67 sub pagetemplate (@) {
69 my $template=$params{template};
70 if (exists $config{theme} && length $config{theme}) {
71 $template->param("theme_$config{theme}" => 1);