]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/inline.pm
headers
[git.ikiwiki.info.git] / IkiWiki / Plugin / inline.pm
index 452fdd267eab2d0b3b2e3fc182171f76ffa60dde..08e1f2769b8b7ca3b526e04808cd171d7ba3a2b4 100644 (file)
@@ -4,7 +4,7 @@ package IkiWiki::Plugin::inline;
 
 use warnings;
 use strict;
 
 use warnings;
 use strict;
-use IkiWiki 1.00;
+use IkiWiki 2.00;
 use URI;
 
 sub import { #{{{
 use URI;
 
 sub import { #{{{
@@ -88,7 +88,7 @@ sub preprocess_inline (@) { #{{{
        my @list;
        foreach my $page (keys %pagesources) {
                next if $page eq $params{page};
        my @list;
        foreach my $page (keys %pagesources) {
                next if $page eq $params{page};
-               if (pagespec_match($page, $params{pages}, $params{page})) {
+               if (pagespec_match($page, $params{pages}, location => $params{page})) {
                        push @list, $page;
                }
        }
                        push @list, $page;
                }
        }
@@ -155,6 +155,7 @@ sub preprocess_inline (@) { #{{{
                $ret.=$linktemplate->output;
        }
        
                $ret.=$linktemplate->output;
        }
        
+       require HTML::Template;
        my @params=IkiWiki::template_params($params{template}.".tmpl", blind_cache => 1);
        if (! @params) {
                return sprintf(gettext("nonexistant template %s"), $params{template});
        my @params=IkiWiki::template_params($params{template}.".tmpl", blind_cache => 1);
        if (! @params) {
                return sprintf(gettext("nonexistant template %s"), $params{template});
@@ -212,7 +213,7 @@ sub preprocess_inline (@) { #{{{
                                $ret.="\n".
                                      linkify($page, $params{page},
                                      preprocess($page, $params{page},
                                $ret.="\n".
                                      linkify($page, $params{page},
                                      preprocess($page, $params{page},
-                                     filter($page,
+                                     filter($page, $params{page},
                                      readfile(srcfile($file)))));
                        }
                }
                                      readfile(srcfile($file)))));
                        }
                }
@@ -222,6 +223,9 @@ sub preprocess_inline (@) { #{{{
                if (exists $params{feedshow} && @list > $params{feedshow}) {
                        @list=@list[0..$params{feedshow} - 1];
                }
                if (exists $params{feedshow} && @list > $params{feedshow}) {
                        @list=@list[0..$params{feedshow} - 1];
                }
+               if (exists $params{feedpages}) {
+                       @list=grep { pagespec_match($_, $params{feedpages}, location => $params{page}) } @list;
+               }
        
                if ($rss) {
                        my $rssp=rsspage($params{page});
        
                if ($rss) {
                        my $rssp=rsspage($params{page});
@@ -263,7 +267,7 @@ sub get_inline_content ($$) { #{{{
                return htmlize($page, $type,
                       linkify($page, $destpage,
                       preprocess($page, $destpage,
                return htmlize($page, $type,
                       linkify($page, $destpage,
                       preprocess($page, $destpage,
-                      filter($page,
+                      filter($page, $destpage,
                       readfile(srcfile($file))))));
        }
        else {
                       readfile(srcfile($file))))));
        }
        else {
@@ -299,9 +303,9 @@ sub absolute_urls ($$) { #{{{
        my $url=$baseurl;
        $url=~s/[^\/]+$//;
        
        my $url=$baseurl;
        $url=~s/[^\/]+$//;
        
-       $content=~s/(<a(?:\s+(?:class|id)="?\w+"?)?)\s+href="(#[^"]+)"/$1 href="$baseurl$2"/ig;
-       $content=~s/(<a(?:\s+(?:class|id)="?\w+"?)?)\s+href="(?!\w+:\/\/)([^"]+)"/$1 href="$url$2"/ig;
-       $content=~s/(<img(?:\s+(?:class|id)="?\w+"?)?)\s+src="(?!\w+:\/\/)([^"]+)"/$1 src="$url$2"/ig;
+       $content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(#[^"]+)"/$1 href="$baseurl$2"/mig;
+       $content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(?!\w+:\/\/)([^"]+)"/$1 href="$url$2"/mig;
+       $content=~s/(<img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"(?!\w+:\/\/)([^"]+)"/$1 src="$url$2"/mig;
        return $content;
 } #}}}
 
        return $content;
 } #}}}
 
@@ -330,7 +334,7 @@ sub genfeed ($$$$@) { #{{{
                my $pcontent = absolute_urls(get_inline_content($p, $page), $url);
 
                $itemtemplate->param(
                my $pcontent = absolute_urls(get_inline_content($p, $page), $url);
 
                $itemtemplate->param(
-                       title => pagetitle(basename($p), 1),
+                       title => pagetitle(basename($p)),
                        url => $u,
                        permalink => $u,
                        date_822 => date_822($pagectime{$p}),
                        url => $u,
                        permalink => $u,
                        date_822 => date_822($pagectime{$p}),
@@ -374,7 +378,7 @@ sub genfeed ($$$$@) { #{{{
 
        my $template=template($feedtype."page.tmpl", blind_cache => 1);
        $template->param(
 
        my $template=template($feedtype."page.tmpl", blind_cache => 1);
        $template->param(
-               title => $page ne "index" ? pagetitle($page, 1) : $config{wikiname},
+               title => $page ne "index" ? pagetitle($page) : $config{wikiname},
                wikiname => $config{wikiname},
                pageurl => $url,
                content => $content,
                wikiname => $config{wikiname},
                pageurl => $url,
                content => $content,