aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>2013-02-20 20:53:50 -0500
committerAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>2013-02-20 20:53:50 -0500
commita629b276b27bb900ec9e544820cd42aa140e8bdc (patch)
tree773514fd20f9af946d2e2d3ee3c1ac6546e512a1
parent3d2be49420b0f29f169ec015f11af1f0624b9ec9 (diff)
downloadikiwiki-a629b276b27bb900ec9e544820cd42aa140e8bdc.tar
ikiwiki-a629b276b27bb900ec9e544820cd42aa140e8bdc.tar.gz
Extract genenclosure(). No functional change intended.
-rw-r--r--IkiWiki/Plugin/inline.pm45
1 files changed, 25 insertions, 20 deletions
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 8eb033951..20cb8a27c 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -611,6 +611,26 @@ sub absolute_urls ($$) {
return $ret;
}
+sub genenclosure {
+ my $itemtemplate=shift;
+ my $url=shift;
+ my $file=shift;
+
+ return unless $itemtemplate->query(name => "enclosure");
+
+ my $size=(srcfile_stat($file))[8];
+ my $mime="unknown";
+ eval q{use File::MimeInfo};
+ if (! $@) {
+ $mime = mimetype($file);
+ }
+ $itemtemplate->param(
+ enclosure => $url,
+ type => $mime,
+ length => $size,
+ );
+}
+
sub genfeed ($$$$$@) {
my $feedtype=shift;
my $feedurl=shift;
@@ -650,28 +670,13 @@ sub genfeed ($$$$$@) {
}
}
- if ($itemtemplate->query(name => "enclosure")) {
- my $file=$pagesources{$p};
- my $type=pagetype($file);
- if (defined $type) {
- $itemtemplate->param(content => $pcontent);
- }
- else {
- my $size=(srcfile_stat($file))[8];
- my $mime="unknown";
- eval q{use File::MimeInfo};
- if (! $@) {
- $mime = mimetype($file);
- }
- $itemtemplate->param(
- enclosure => $u,
- type => $mime,
- length => $size,
- );
- }
+ my $file=$pagesources{$p};
+ my $type=pagetype($file);
+ if (defined $type) {
+ $itemtemplate->param(content => $pcontent);
}
else {
- $itemtemplate->param(content => $pcontent);
+ genenclosure($itemtemplate, $u, $file);
}
run_hooks(pagetemplate => sub {