/usr/share/perl5/IkiWiki/Plugin/theme.pm is in ikiwiki 3.20141016.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #!/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);
hook(type => "needsbuild", id => "theme", call => \&needsbuild);
hook(type => "pagetemplate", id => "theme", call => \&pagetemplate);
}
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;
}
}
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;
}
sub pagetemplate (@) {
my %params=@_;
my $template=$params{template};
if (exists $config{theme} && length $config{theme}) {
$template->param("theme_$config{theme}" => 1);
}
}
1
|