Extract genenclosure(). No functional change intended.
authorAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>
Thu, 21 Feb 2013 01:53:50 +0000 (20:53 -0500)
committerAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>
Thu, 21 Feb 2013 01:53:50 +0000 (20:53 -0500)
IkiWiki/Plugin/inline.pm

index 8eb033951a365ce2ada82394c94c8e903ae858df..20cb8a27c9e9ea544540f2521b1793be54be8a45 100644 (file)
@@ -611,6 +611,26 @@ sub absolute_urls ($$) {
        return $ret;
 }
 
        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;
 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 {
                }
                else {
-                       $itemtemplate->param(content => $pcontent);
+                       genenclosure($itemtemplate, $u, $file);
                }
 
                run_hooks(pagetemplate => sub {
                }
 
                run_hooks(pagetemplate => sub {