]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - ikiwiki
Take basename of page link when creating a link. Makes blog posts look
[git.ikiwiki.info.git] / ikiwiki
diff --git a/ikiwiki b/ikiwiki
index 9001c5e2a424b7653a1e9ae0478c83320be16f34..235a72102f61ee3078871ae7d2be37ccb2de99d2 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -9,7 +9,7 @@ use HTML::Template;
 use lib '.'; # For use without installation, removed by Makefile.
 
 use vars qw{%config %links %oldlinks %oldpagemtime %pagectime
-            %renderedfiles %pagesources};
+            %renderedfiles %pagesources %inlinepages};
 
 sub usage () { #{{{
        die "usage: ikiwiki [options] source dest\n";
@@ -20,7 +20,8 @@ sub getconfig () { #{{{
                %config=(
                        wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$)},
                        wiki_link_regexp => qr/\[\[([^\s\]]+)\]\]/,
-                       wiki_file_regexp => qr/(^[-A-Za-z0-9_.\&;:\/+]+$)/,
+                       wiki_processor_regexp => qr/\[\[(\w+)\s+([^\]]+)\]\]/,
+                       wiki_file_regexp => qr/(^[-A-Za-z0-9_.:\/+]+$)/,
                        verbose => 0,
                        wikiname => "wiki",
                        default_pageext => ".mdwn",
@@ -261,7 +262,7 @@ sub htmllink ($$;$$) { #{{{
                $bestlink="$page/".lc($link);
        }
 
-       my $linktext=pagetitle($link);
+       my $linktext=pagetitle(basename($link));
        
        return $linktext if length $bestlink && $page eq $bestlink;
        
@@ -273,7 +274,7 @@ sub htmllink ($$;$$) { #{{{
                $bestlink=htmlpage($bestlink);
        }
        if (! grep { $_ eq $bestlink } values %renderedfiles) {
-               return "<a href=\"$config{cgiurl}?do=create&page=$link&from=$page\">?</a>$linktext"
+               return "<span><a href=\"$config{cgiurl}?do=create&page=$link&from=$page\">?</a>$linktext</span>"
        }
        
        $bestlink=File::Spec->abs2rel($bestlink, dirname($page));
@@ -324,13 +325,19 @@ sub loadindex () { #{{{
                        push @{$items{$item}}, $val;
                }
 
+               next unless exists $items{src}; # skip bad lines for now
+
                my $page=pagename($items{src}[0]);
-               $pagesources{$page}=$items{src}[0];
-               $oldpagemtime{$page}=$items{mtime}[0];
+               if (! $config{rebuild}) {
+                       $pagesources{$page}=$items{src}[0];
+                       $oldpagemtime{$page}=$items{mtime}[0];
+                       $oldlinks{$page}=[@{$items{link}}];
+                       $links{$page}=[@{$items{link}}];
+                       $inlinepages{$page}=join(" ", @{$items{inlinepage}})
+                               if exists $items{inlinepage};
+                       $renderedfiles{$page}=$items{dest}[0];
+               }
                $pagectime{$page}=$items{ctime}[0];
-               $oldlinks{$page}=[@{$items{link}}];
-               $links{$page}=[@{$items{link}}];
-               $renderedfiles{$page}=$items{dest}[0];
        }
        close IN;
 } #}}}
@@ -342,12 +349,14 @@ sub saveindex () { #{{{
        open (OUT, ">$config{wikistatedir}/index") || 
                error("cannot write to $config{wikistatedir}/index: $!");
        foreach my $page (keys %oldpagemtime) {
+               next unless $oldpagemtime{$page};
                my $line="mtime=$oldpagemtime{$page} ".
                        "ctime=$pagectime{$page} ".
                        "src=$pagesources{$page} ".
                        "dest=$renderedfiles{$page}";
-               if ($oldpagemtime{$page}) {
-                       $line.=" link=$_" foreach @{$links{$page}};
+               $line.=" link=$_" foreach @{$links{$page}};
+               if (exists $inlinepages{$page}) {
+                       $line.=" inlinepage=$_" foreach split " ", $inlinepages{$page};
                }
                print OUT $line."\n";
        }
@@ -457,7 +466,13 @@ sub globlist_match ($$) { #{{{
 sub main () { #{{{
        getconfig();
        
-       if ($config{setup}) {
+       if ($config{cgi}) {
+               lockwiki();
+               loadindex();
+               require IkiWiki::CGI;
+               cgi();
+       }
+       elsif ($config{setup}) {
                require IkiWiki::Setup;
                setup();
        }
@@ -466,14 +481,9 @@ sub main () { #{{{
                require IkiWiki::Wrapper;
                gen_wrapper();
        }
-       elsif ($config{cgi}) {
-               lockwiki();
-               require IkiWiki::CGI;
-               cgi();
-       }
        else {
                lockwiki();
-               loadindex() unless $config{rebuild};
+               loadindex();
                require IkiWiki::Render;
                rcs_update();
                refresh();