]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
web commit by http://joey.kitenet.net/
[ikiwiki.git] / IkiWiki.pm
index 848f1dda8079494d639dac1fd7c1748c58e187cd..0c1df8b474067375f6eb6d637a0250bf095a93fd 100644 (file)
@@ -17,6 +17,7 @@ use Exporter q{import};
 our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match
                  bestlink htmllink readfile writefile pagetype srcfile pagename
                  displaytime will_render gettext urlto targetpage
+                add_underlay
                  %config %links %renderedfiles %pagesources %destsources);
 our $VERSION = 2.00; # plugin interface version, next is ikiwiki version
 our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
@@ -38,7 +39,7 @@ sub defaultconfig () { #{{{
        wiki_link_regexp => qr{
                \[\[                    # beginning of link
                (?:
-                       ([^\]\|]+)      # 1: link text
+                       ([^\]\|\n]+)    # 1: link text
                        \|              # followed by '|'
                )?                      # optional
                
@@ -83,6 +84,7 @@ sub defaultconfig () { #{{{
        pingurl => [],
        templatedir => "$installdir/share/ikiwiki/templates",
        underlaydir => "$installdir/share/ikiwiki/basewiki",
+       underlaydirs => [],
        setup => undef,
        adminuser => undef,
        adminemail => undef,
@@ -285,11 +287,26 @@ sub srcfile ($) { #{{{
        my $file=shift;
 
        return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
-       return "$config{underlaydir}/$file" if -e "$config{underlaydir}/$file";
-       error("internal error: $file cannot be found in $config{srcdir} or $config{underlaydir}");
+       foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
+               return "$dir/$file" if -e "$dir/$file";
+       }
+       error("internal error: $file cannot be found in $config{srcdir} or underlay");
        return;
 } #}}}
 
+sub add_underlay ($) { #{{{
+       my $dir=shift;
+
+       if ($dir=~/^\//) {
+               unshift @{$config{underlaydirs}}, $dir;
+       }
+       else {
+               unshift @{$config{underlaydirs}}, "$config{underlaydir}/../$dir";
+       }
+
+       return 1;
+} #}}}
+
 sub readfile ($;$$) { #{{{
        my $file=shift;
        my $binary=shift;
@@ -774,7 +791,8 @@ sub lockwiki (;$) { #{{{
 } #}}}
 
 sub unlockwiki () { #{{{
-       return close($wikilock);
+       return close($wikilock) if $wikilock;
+       return;
 } #}}}
 
 my $commitlock;
@@ -800,7 +818,8 @@ sub disable_commit_hook () { #{{{
 } #}}}
 
 sub enable_commit_hook () { #{{{
-       return close($commitlock);
+       return close($commitlock) if $commitlock;
+       return;
 } #}}}
 
 sub loadindex () { #{{{
@@ -1017,7 +1036,9 @@ sub file_pruned ($$) { #{{{
 
 sub gettext { #{{{
        # Only use gettext in the rare cases it's needed.
-       if (exists $ENV{LANG} || exists $ENV{LC_ALL} || exists $ENV{LC_MESSAGES}) {
+       if ((exists $ENV{LANG} && length $ENV{LANG}) ||
+           (exists $ENV{LC_ALL} && length $ENV{LC_ALL}) ||
+           (exists $ENV{LC_MESSAGES} && length $ENV{LC_MESSAGES})) {
                if (! $gettext_obj) {
                        $gettext_obj=eval q{
                                use Locale::gettext q{textdomain};