X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/1f88cad3a2fa127ec76f8429ce9ca594c59d11f0..1cbcdd2d8a2545da5b6426c038e54a0d9da16d61:/IkiWiki/Plugin/aggregate.pm

diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index a9c7447fa..b5354a823 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -154,6 +154,13 @@ sub preprocess (@) { #{{{
 	$feed->{updateinterval}=defined $params{updateinterval} ? $params{updateinterval} * 60 : 15 * 60;
 	$feed->{expireage}=defined $params{expireage} ? $params{expireage} : 0;
 	$feed->{expirecount}=defined $params{expirecount} ? $params{expirecount} : 0;
+        if (exists $params{template}) {
+                $params{template}=~s/[^-_a-zA-Z0-9]+//g;
+        }
+        else {
+                $params{template} = "aggregatepost"
+        }
+	$feed->{template}=$params{template} . ".tmpl";
 	delete $feed->{unseen};
 	$feed->{lastupdate}=0 unless defined $feed->{lastupdate};
 	$feed->{numposts}=0 unless defined $feed->{numposts};
@@ -407,14 +414,14 @@ sub aggregate (@) { #{{{
 			# that contains invalid UTF-8 sequences. Convert
 			# feed to ascii to try to work around.
 			$feed->{message}.=" ".sprintf(gettext("(invalid UTF-8 stripped from feed)"));
-			$content=Encode::decode_utf8($content);
+			$content=Encode::decode_utf8($content, 0);
 			$f=eval{XML::Feed->parse(\$content)};
 		}
 		if ($@) {
 			# Another possibility is badly escaped entities.
 			$feed->{message}.=" ".sprintf(gettext("(feed entities escaped)"));
 			$content=~s/\&(?!amp)(\w+);/&$1;/g;
-			$content=Encode::decode_utf8($content);
+			$content=Encode::decode_utf8($content, 0);
 			$f=eval{XML::Feed->parse(\$content)};
 		}
 		if ($@) {
@@ -507,7 +514,7 @@ sub add_page (@) { #{{{
 	$guid->{md5}=$digest;
 
 	# Create the page.
-	my $template=template("aggregatepost.tmpl", blind_cache => 1);
+	my $template=template($feed->{template}, blind_cache => 1);
 	$template->param(title => $params{title})
 		if defined $params{title} && length($params{title});
 	$template->param(content => htmlescape(htmlabs($params{content}, $feed->{feedurl})));