]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki.pm
web commit by ppp
[ikiwiki.git] / IkiWiki.pm
index 560647e067f224bd62d2c9cd49b9c17359933b9f..b6e160ab6e0010ab1007c98d80e7ebb0c6b19a1a 100644 (file)
@@ -15,12 +15,14 @@ memoize("pagespec_translate");
 use vars qw{%config %links %oldlinks %oldpagemtime %pagectime %pagecase
             %renderedfiles %pagesources %depends %hooks %forcerebuild};
 
+my $installdir=''; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
+
 sub defaultconfig () { #{{{
        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.x?html?$|\.rss$)},
        wiki_link_regexp => qr/\[\[(?:([^\]\|]+)\|)?([^\s\]]+)\]\]/,
-       wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]*)\]\]/,
        wiki_file_regexp => qr/(^[-[:alnum:]_.:\/+]+$)/,
        verbose => 0,
+       syslog => 0,
        wikiname => "wiki",
        default_pageext => "mdwn",
        cgi => 0,
@@ -44,8 +46,8 @@ sub defaultconfig () { #{{{
        srcdir => undef,
        destdir => undef,
        pingurl => [],
-       templatedir => "/usr/share/ikiwiki/templates",
-       underlaydir => "/usr/share/ikiwiki/basewiki",
+       templatedir => "$installdir/share/ikiwiki/templates",
+       underlaydir => "$installdir/share/ikiwiki/basewiki",
        setup => undef,
        adminuser => undef,
        adminemail => undef,
@@ -119,12 +121,31 @@ sub error ($) { #{{{
                print "Content-type: text/html\n\n";
                print misctemplate("Error", "<p>Error: @_</p>");
        }
-       die @_;
+       log_message(error => @_);
+       exit(1);
 } #}}}
 
 sub debug ($) { #{{{
        return unless $config{verbose};
-       if (! $config{cgi}) {
+       log_message(debug => @_);
+} #}}}
+
+my $log_open=0;
+sub log_message ($$) { #{{{
+       my $type=shift;
+
+       if ($config{syslog}) {
+               require Sys::Syslog;
+               unless ($log_open) {
+                       Sys::Syslog::setlogsock('unix');
+                       Sys::Syslog::openlog('ikiwiki', '', 'user');
+                       $log_open=1;
+               }
+               eval {
+                       Sys::Syslog::syslog($type, join(" ", @_));
+               }
+       }
+       elsif (! $config{cgi}) {
                print "@_\n";
        }
        else {
@@ -284,14 +305,14 @@ sub cgiurl (@) { #{{{
        return $config{cgiurl}."?".join("&amp;", map "$_=$params{$_}", keys %params);
 } #}}}
 
-sub styleurl (;$) { #{{{
+sub baseurl (;$) { #{{{
        my $page=shift;
 
-       return "$config{url}/style.css" if ! defined $page;
+       return "$config{url}/" if ! defined $page;
        
        $page=~s/[^\/]+$//;
        $page=~s/[^\/]+\//..\//g;
-       return $page."style.css";
+       return $page;
 } #}}}
 
 sub abs2rel ($$) { #{{{
@@ -325,7 +346,8 @@ sub htmllink ($$$;$$$) { #{{{
 
        $linktext=pagetitle(basename($link)) unless defined $linktext;
        
-       return $linktext if length $bestlink && $page eq $bestlink;
+       return "<span class=\"selflink\">$linktext</span>"
+               if length $bestlink && $page eq $bestlink;
        
        # TODO BUG: %renderedfiles may not have it, if the linked to page
        # was also added and isn't yet rendered! Note that this bug is
@@ -455,8 +477,7 @@ sub misctemplate ($$) { #{{{
                indexlink => indexlink(),
                wikiname => $config{wikiname},
                pagebody => $pagebody,
-               styleurl => styleurl(),
-               baseurl => "$config{url}/",
+               baseurl => baseurl(),
        );
        return $template->output;
 }#}}}
@@ -525,6 +546,8 @@ sub pagespec_merge ($$) { #{{{
        my $a=shift;
        my $b=shift;
 
+       return $a if $a eq $b;
+
         # Support for old-style GlobLists.
         if (is_globlist($a)) {
                 $a=globlist_to_pagespec($a);