From: Simon McVittie Date: Tue, 9 Dec 2014 19:58:36 +0000 (+0000) Subject: Merge remote-tracking branch 'spalax/paternal/libdirs' X-Git-Tag: 3.20150107~37 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/23b91e69b02065534e5c57449ec82d7fee9f93e0?hp=-c Merge remote-tracking branch 'spalax/paternal/libdirs' --- 23b91e69b02065534e5c57449ec82d7fee9f93e0 diff --combined IkiWiki.pm index 83679243f,9e2eb0b1a..7c55764be --- a/IkiWiki.pm +++ b/IkiWiki.pm @@@ -5,7 -5,6 +5,7 @@@ package IkiWiki use warnings; use strict; use Encode; +use Fcntl q{:flock}; use URI::Escape q{uri_escape_utf8}; use POSIX (); use Storable; @@@ -275,7 -274,7 +275,7 @@@ sub getsetup () html5 => { type => "boolean", default => 0, - description => "generate HTML5?", + description => "use elements new in HTML5 like
?", advanced => 0, safe => 1, rebuild => 1, @@@ -362,7 -361,7 +362,7 @@@ type => "string", default => "", example => "$ENV{HOME}/.ikiwiki/", - description => "extra library and plugin directory", + description => "extra library and plugin directorys. Can be either a string (for backward compatibility) or a list of strings.", advanced => 1, safe => 0, # directory rebuild => 0, @@@ -550,15 -549,22 +550,29 @@@ safe => 0, rebuild => 0, }, + responsive_layout => { + type => "boolean", + default => 1, + description => "theme has a responsive layout? (mobile-optimized)", + safe => 1, + rebuild => 1, + }, } + sub getlibdirs () { + my $libdirs; + if (! ref $config{libdir}) { + if (length $config{libdir}) { + $libdirs = [$config{libdir}]; + } else { + $libdirs = []; + } + } else { + $libdirs = $config{libdir}; + } + return @{$libdirs}; + } + sub defaultconfig () { my %s=getsetup(); my @ret; @@@ -701,14 -707,14 +715,14 @@@ sub checkconfig () sub listplugins () { my %ret; - foreach my $dir (@INC, $config{libdir}) { + foreach my $dir (@INC, getlibdirs()) { next unless defined $dir && length $dir; foreach my $file (glob("$dir/IkiWiki/Plugin/*.pm")) { my ($plugin)=$file=~/.*\/(.*)\.pm$/; $ret{$plugin}=1; } } - foreach my $dir ($config{libdir}, "$installdir/lib/ikiwiki") { + foreach my $dir (getlibdirs(), "$installdir/lib/ikiwiki") { next unless defined $dir && length $dir; foreach my $file (glob("$dir/plugins/*")) { $ret{basename($file)}=1 if -x $file; @@@ -720,7 -726,9 +734,9 @@@ sub loadplugins () { if (defined $config{libdir} && length $config{libdir}) { - unshift @INC, possibly_foolish_untaint($config{libdir}); + foreach my $dir (getlibdirs()) { + unshift @INC, possibly_foolish_untaint($dir); + } } foreach my $plugin (@{$config{default_plugins}}, @{$config{add_plugins}}) { @@@ -753,8 -761,8 +769,8 @@@ sub loadplugin ($;$) return if ! $force && grep { $_ eq $plugin} @{$config{disable_plugins}}; - foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef, - "$installdir/lib/ikiwiki") { + foreach my $possiblytainteddir (getlibdirs(), "$installdir/lib/ikiwiki") { + my $dir = defined $possiblytainteddir ? possibly_foolish_untaint($possiblytainteddir) : undef; if (defined $dir && -x "$dir/plugins/$plugin") { eval { require IkiWiki::Plugin::external }; if ($@) { @@@ -1814,11 -1822,8 +1830,11 @@@ sub lockwiki () } open($wikilock, '>', "$config{wikistatedir}/lockfile") || error ("cannot write to $config{wikistatedir}/lockfile: $!"); - if (! flock($wikilock, 2)) { # LOCK_EX - error("failed to get lock"); + if (! flock($wikilock, LOCK_EX | LOCK_NB)) { + debug("failed to get lock; waiting..."); + if (! flock($wikilock, LOCK_EX)) { + error("failed to get lock"); + } } return 1; }