]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - ikiwiki
web commit by joey
[git.ikiwiki.info.git] / ikiwiki
diff --git a/ikiwiki b/ikiwiki
index ea5604365bad5986dd69c40cdf0cc5257d4a638e..d1173d399fe330f503c173f916dca2ff5fe1851d 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -19,9 +19,9 @@ sub getconfig () { #{{{
        if (! exists $ENV{WRAPPED_OPTIONS}) {
                %config=(
                        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
        if (! exists $ENV{WRAPPED_OPTIONS}) {
                %config=(
                        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
-                       wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
+                       wiki_link_regexp => qr/\[\[(?:([^\s\]\|]+)\|)?([^\s\]]+)\]\]/,
                        wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
                        wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
-                       wiki_file_regexp => qr/(^[-A-Za-z0-9_.\&;:\/+]+$)/,
+                       wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
                        verbose => 0,
                        wikiname => "wiki",
                        default_pageext => ".mdwn",
                        verbose => 0,
                        wikiname => "wiki",
                        default_pageext => ".mdwn",
@@ -34,6 +34,8 @@ sub getconfig () { #{{{
                        anonok => 0,
                        rss => 0,
                        rebuild => 0,
                        anonok => 0,
                        rss => 0,
                        rebuild => 0,
+                       refresh => 0,
+                       getctime => 0,
                        wrapper => undef,
                        wrappermode => undef,
                        srcdir => undef,
                        wrapper => undef,
                        wrappermode => undef,
                        srcdir => undef,
@@ -49,6 +51,8 @@ sub getconfig () { #{{{
                        "wikiname=s" => \$config{wikiname},
                        "verbose|v!" => \$config{verbose},
                        "rebuild!" => \$config{rebuild},
                        "wikiname=s" => \$config{wikiname},
                        "verbose|v!" => \$config{verbose},
                        "rebuild!" => \$config{rebuild},
+                       "refresh!" => \$config{refresh},
+                       "getctime" => \$config{getctime},
                        "wrappermode=i" => \$config{wrappermode},
                        "svn!" => \$config{svn},
                        "anonok!" => \$config{anonok},
                        "wrappermode=i" => \$config{wrappermode},
                        "svn!" => \$config{svn},
                        "anonok!" => \$config{anonok},
@@ -238,7 +242,7 @@ sub bestlink ($$) { #{{{
 sub isinlinableimage ($) { #{{{
        my $file=shift;
        
 sub isinlinableimage ($) { #{{{
        my $file=shift;
        
-       $file=~/\.(png|gif|jpg|jpeg)$/;
+       $file=~/\.(png|gif|jpg|jpeg)$/i;
 } #}}}
 
 sub pagetitle ($) { #{{{
 } #}}}
 
 sub pagetitle ($) { #{{{
@@ -248,11 +252,25 @@ sub pagetitle ($) { #{{{
        return $page;
 } #}}}
 
        return $page;
 } #}}}
 
-sub htmllink ($$;$$) { #{{{
+sub titlepage ($) { #{{{
+       my $title=shift;
+       $title=~y/ /_/;
+       $title=~s/([^-A-Za-z0-9_:+\/.])/"__".ord($1)."__"/eg;
+       return $title;
+} #}}}
+
+sub cgiurl (@) { #{{{
+       my %params=@_;
+
+       return $config{cgiurl}."?".join("&", map "$_=$params{$_}", keys %params);
+} #}}}
+
+sub htmllink ($$;$$$) { #{{{
        my $page=shift;
        my $link=shift;
        my $noimageinline=shift; # don't turn links into inline html images
        my $forcesubpage=shift; # force a link to a subpage
        my $page=shift;
        my $link=shift;
        my $noimageinline=shift; # don't turn links into inline html images
        my $forcesubpage=shift; # force a link to a subpage
+       my $linktext=shift; # set to force the link text to something
 
        my $bestlink;
        if (! $forcesubpage) {
 
        my $bestlink;
        if (! $forcesubpage) {
@@ -262,7 +280,7 @@ sub htmllink ($$;$$) { #{{{
                $bestlink="$page/".lc($link);
        }
 
                $bestlink="$page/".lc($link);
        }
 
-       my $linktext=pagetitle($link);
+       $linktext=pagetitle(basename($link)) unless defined $linktext;
        
        return $linktext if length $bestlink && $page eq $bestlink;
        
        
        return $linktext if length $bestlink && $page eq $bestlink;
        
@@ -274,13 +292,15 @@ sub htmllink ($$;$$) { #{{{
                $bestlink=htmlpage($bestlink);
        }
        if (! grep { $_ eq $bestlink } values %renderedfiles) {
                $bestlink=htmlpage($bestlink);
        }
        if (! grep { $_ eq $bestlink } values %renderedfiles) {
-               return "<span><a href=\"$config{cgiurl}?do=create&page=$link&from=$page\">?</a>$linktext</span>"
+               return "<span><a href=\"".
+                       cgiurl(do => "create", page => $link, from =>$page).
+                       "\">?</a>$linktext</span>"
        }
        
        $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
        
        if (! $noimageinline && isinlinableimage($bestlink)) {
        }
        
        $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
        
        if (! $noimageinline && isinlinableimage($bestlink)) {
-               return "<img src=\"$bestlink\">";
+               return "<img src=\"$bestlink\" alt=\"$linktext\">";
        }
        return "<a href=\"$bestlink\">$linktext</a>";
 } #}}}
        }
        return "<a href=\"$bestlink\">$linktext</a>";
 } #}}}
@@ -486,6 +506,7 @@ sub main () { #{{{
                loadindex();
                require IkiWiki::Render;
                rcs_update();
                loadindex();
                require IkiWiki::Render;
                rcs_update();
+               rcs_getctime() if $config{getctime};
                refresh();
                saveindex();
        }
                refresh();
                saveindex();
        }