]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Render.pm
add rss button
[ikiwiki.git] / IkiWiki / Render.pm
index a981dcb24979da75d8f83923b9d629230a3dc1a2..1fc047a62f78ed8b21d2cde47940363a65930d09 100644 (file)
@@ -9,7 +9,8 @@ sub linkify ($$) { #{{{
        my $page=shift;
 
        $content =~ s{(\\?)$config{wiki_link_regexp}}{
-               $1 ? "[[$2]]" : htmllink($page, $2)
+               $2 ? ( $1 ? "[[$2|$3]]" : htmllink($page, titlepage($3), 0, 0, pagetitle($2)))
+                  : ( $1 ? "[[$3]]" :    htmllink($page, titlepage($3)))
        }eg;
        
        return $content;
@@ -160,12 +161,22 @@ sub postprocess_html_inline { #{{{
        }
        $inlinepages{$parentpage}=$params{pages};
        
+       my $ret="";
+       
+       if (exists $params{rootpage}) {
+               my $formtemplate=HTML::Template->new(blind_cache => 1,
+                       filename => "$config{templatedir}/blogpost.tmpl");
+               $formtemplate->param(cgiurl => $config{cgiurl});
+               $formtemplate->param(rootpage => $params{rootpage});
+               my $form=$formtemplate->output;
+               $ret.=$form;
+       }
+       
        my $template=HTML::Template->new(blind_cache => 1,
                filename => (($params{archive} eq "no") 
                                ? "$config{templatedir}/inlinepage.tmpl"
                                : "$config{templatedir}/inlinepagetitle.tmpl"));
        
-       my $ret="";
        foreach my $page (blog_list($params{pages}, $params{show})) {
                next if $page eq $parentpage;
                $template->param(pagelink => htmllink($parentpage, $page));
@@ -175,7 +186,7 @@ sub postprocess_html_inline { #{{{
                $ret.=$template->output;
        }
        
-       return $ret;
+       return "</p>$ret<p>";
 } #}}}
 
 sub genpage ($$$) { #{{{
@@ -191,10 +202,10 @@ sub genpage ($$$) { #{{{
                filename => "$config{templatedir}/page.tmpl");
        
        if (length $config{cgiurl}) {
-               $template->param(editurl => "$config{cgiurl}?do=edit&page=$page");
-               $template->param(prefsurl => "$config{cgiurl}?do=prefs");
+               $template->param(editurl => cgiurl(do => "edit", page => $page));
+               $template->param(prefsurl => cgiurl(do => "prefs"));
                if ($config{rcs}) {
-                       $template->param(recentchangesurl => "$config{cgiurl}?do=recentchanges");
+                       $template->param(recentchangesurl => cgiurl(do => "recentchanges"));
                }
        }
 
@@ -205,7 +216,7 @@ sub genpage ($$$) { #{{{
        }
 
        if ($config{rss} && $inlinepages{$page}) {
-               $template->param(rssurl => rsspage($page));
+               $template->param(rssurl => rsspage(basename($page)));
        }
        
        $template->param(
@@ -256,8 +267,6 @@ sub genrss ($$$) { #{{{
                my $parentpage=shift;
                my %params=@_;
                
-               return "" if exists $params{archive} && $params{archive} eq 'yes';
-               
                if (! exists $params{show}) {
                        $params{show}=10;
                }
@@ -305,9 +314,9 @@ sub check_overwrite ($$) { #{{{
 } #}}}
 
 sub mtime ($) { #{{{
-       my $page=shift;
+       my $file=shift;
        
-       return (stat($page))[9];
+       return (stat($file))[9];
 } #}}}
 
 sub findlinks ($$) { #{{{
@@ -316,7 +325,7 @@ sub findlinks ($$) { #{{{
 
        my @links;
        while ($content =~ /(?<!\\)$config{wiki_link_regexp}/g) {
-               push @links, lc($1);
+               push @links, titlepage($2);
        }
        # Discussion links are a special case since they're not in the text
        # of the page, but on its template.
@@ -408,7 +417,8 @@ sub refresh () { #{{{
                        push @add, $file;
                        $links{$page}=[];
                        $pagesources{$page}=$file;
-                       $pagectime{$page}=time unless exists $pagectime{$page};
+                       $pagectime{$page}=mtime("$config{srcdir}/$file") 
+                               unless exists $pagectime{$page};
                }
        }
        my @del;
@@ -463,20 +473,24 @@ FILE:             foreach my $file (@files) {
        # problem is the backlinks could be wrong in the first pass render
        # above
        if (%rendered || @del) {
+               foreach my $f (@files) {
+                       my $p=pagename($f);
+                       if (exists $inlinepages{$p}) {
+                               foreach my $file (keys %rendered, @del) {
+                                       my $page=pagename($file);
+                                       if (globlist_match($page, $inlinepages{$p})) {
+                                               debug("rendering $f, which inlines $page");
+                                               render($f);
+                                               last;
+                                       }
+                               }
+                       }
+               }
+               
                my %linkchanged;
                foreach my $file (keys %rendered, @del) {
                        my $page=pagename($file);
                        
-                       foreach my $f (@files) {
-                               my $p=pagename($f);
-                               if (exists $inlinepages{$p} && 
-                                   globlist_match($page, $inlinepages{$p})) {
-                                       debug("rendering $f, which inlines $page");
-                                       render($f);
-                                       next;
-                               }
-                       }
-                       
                        if (exists $links{$page}) {
                                foreach my $link (map { bestlink($page, $_) } @{$links{$page}}) {
                                        if (length $link &&