X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/f70bc8184ace2cf10687daedf2b7176f32ef8a97..d8deff0a0c8fcb10784d06535d313e3cf880f799:/IkiWiki/Plugin/theme.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/theme.pm b/IkiWiki/Plugin/theme.pm index ba6966381..ee94547e9 100644 --- a/IkiWiki/Plugin/theme.pm +++ b/IkiWiki/Plugin/theme.pm @@ -8,6 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "theme", call => \&getsetup); hook(type => "checkconfig", id => "theme", call => \&checkconfig); + hook(type => "needsbuild", id => "theme", call => \&needsbuild); } sub getsetup () { @@ -22,7 +23,7 @@ sub getsetup () { example => "actiontabs", description => "name of theme to enable", safe => 1, - rebuild => 1, + rebuild => 0, }, } @@ -34,4 +35,32 @@ sub checkconfig () { } } +sub needsbuild ($) { + my $needsbuild=shift; + if (($config{theme} || '') ne ($wikistate{theme}{currenttheme} || '')) { + # theme changed; ensure all files in the theme are built + my %needsbuild=map { $_ => 1 } @$needsbuild; + if ($config{theme}) { + foreach my $file (glob("$config{underlaydirbase}/themes/$config{theme}/*")) { + if (-f $file) { + my $f=IkiWiki::basename($file); + push @$needsbuild, $f + unless $needsbuild{$f}; + } + } + } + elsif ($wikistate{theme}{currenttheme}) { + foreach my $file (glob("$config{underlaydirbase}/themes/$wikistate{theme}{currenttheme}/*")) { + my $f=IkiWiki::basename($file); + if (-f $file && defined eval { srcfile($f) }) { + push @$needsbuild, $f; + } + } + } + + $wikistate{theme}{currenttheme}=$config{theme}; + } + return $needsbuild; +} + 1