From 546da9bac7135d7d1b02dce0c0eef2209d939fc6 Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Mon, 18 Feb 2013 16:24:22 -0500 Subject: Make [[!meta enclosure=foo.mp3]] "work" for HTML. --- IkiWiki/Plugin/meta.pm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 421f1dc86..cb0768b91 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -121,6 +121,9 @@ sub preprocess (@) { add_link($page, $value); return ""; } + elsif ($key eq 'enclosure') { + $pagestate{$page}{meta}{enclosure}=$value; + } elsif ($key eq 'author') { $pagestate{$page}{meta}{author}=$value; if (exists $params{sortas}) { @@ -318,6 +321,11 @@ sub pagetemplate (@) { $template->param(title_overridden => 1); } + if (exists $pagestate{$page}{meta}{enclosure}) { + # XXX what if the enclosure doesn't exist? + $template->param(enclosure => $pagestate{$page}{meta}{enclosure}); + } + foreach my $field (qw{authorurl}) { eval q{use HTML::Entities}; $template->param($field => HTML::Entities::encode_entities($pagestate{$page}{meta}{$field})) -- cgit v1.2.3 From 0e278c4a848e0b3ddc0162db9dc135e791bd9477 Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Mon, 18 Feb 2013 18:01:13 -0500 Subject: Make enclosure follow WikiLink LinkingRules. --- IkiWiki/Plugin/meta.pm | 8 +++++++- t/podcast.t | 40 +++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index cb0768b91..c77837e3c 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -122,6 +122,13 @@ sub preprocess (@) { return ""; } elsif ($key eq 'enclosure') { + my $link=bestlink($page, $value); + if (! length $link) { + error gettext("enclosure not found") + } + add_depends($page, $link, deptype("presence")); + + $value=urlto($link, $page); $pagestate{$page}{meta}{enclosure}=$value; } elsif ($key eq 'author') { @@ -322,7 +329,6 @@ sub pagetemplate (@) { } if (exists $pagestate{$page}{meta}{enclosure}) { - # XXX what if the enclosure doesn't exist? $template->param(enclosure => $pagestate{$page}{meta}{enclosure}); } diff --git a/t/podcast.t b/t/podcast.t index 77f146871..993814742 100755 --- a/t/podcast.t +++ b/t/podcast.t @@ -3,16 +3,18 @@ use warnings; use strict; BEGIN { - eval q{use XML::Feed; use HTML::Parser}; + eval q{use XML::Feed; use HTML::Parser; use HTML::LinkExtor}; if ($@) { eval q{use Test::More skip_all => "XML::Feed and/or HTML::Parser not available"}; } else { - eval q{use Test::More tests => 77}; + eval q{use Test::More tests => 78}; } } +use Cwd; + my $tmp = 't/tmp'; my $statedir = 't/tinypodcast/.ikiwiki'; @@ -23,8 +25,8 @@ sub simple_podcast { push @command, qw(-set underlaydirbase=underlays -templatedir=templates); push @command, "-url=$baseurl", qw(t/tinypodcast), "$tmp/out"; - ok(! system("mkdir $tmp")); - ok(! system(@command)); + ok(! system("mkdir $tmp"), q{setup}); + ok(! system(@command), q{build}); my %media_types = ( 'simplepost' => undef, @@ -86,7 +88,7 @@ sub simple_podcast { } } - ok(! system("rm -rf $tmp $statedir")); + ok(! system("rm -rf $tmp $statedir"), q{teardown}); } sub single_page_html { @@ -95,8 +97,9 @@ sub single_page_html { push @command, qw(-set underlaydirbase=underlays -templatedir=templates); push @command, qw(t/tinypodcast), "$tmp/out"; - ok(! system("mkdir $tmp")); - ok(! system(@command)); + ok(! system("mkdir $tmp"), q{setup}); + ok(! system(@command), q{build}); + my $html = "$tmp/out/pianopost/index.html"; my $body = _extract_html_content($html, 'content'); @@ -105,10 +108,12 @@ sub single_page_html { my $enclosure = _extract_html_content($html, 'enclosure'); like($enclosure, qr/Download this episode/m, q{html enclosure}); - # XXX die if specified enclosure doesn't exist + my ($href) = _extract_html_links($html, 'piano'); + ok(-f $href, q{html enclosure exists}); + # XXX die if more than one enclosure is specified - ok(! system("rm -rf $tmp $statedir")); + ok(! system("rm -rf $tmp $statedir"), q{teardown}); } sub _extract_html_content { @@ -139,5 +144,22 @@ sub _extract_html_content { return $content; } +sub _extract_html_links { + my ($file, $desired_value) = @_; + + my @hrefs = (); + + my $p = HTML::LinkExtor->new(sub { + my ($tag, %attr) = @_; + return if $tag ne 'a'; + return unless $attr{href} =~ qr/$desired_value/; + push(@hrefs, values %attr); + }, getcwd() . '/' . $file); + + $p->parse_file($file); + + return @hrefs; +} + simple_podcast(); single_page_html(); -- cgit v1.2.3 From c3b17740aed9e7f2697999163e1a1c4f84b6ef8f Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Mon, 18 Feb 2013 18:19:45 -0500 Subject: Document that last enclosure wins. --- IkiWiki/Plugin/meta.pm | 1 + t/podcast.t | 39 +++++++++++++++--------- t/tinypodcast/attempted_multiple_enclosures.mdwn | 4 +++ 3 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 t/tinypodcast/attempted_multiple_enclosures.mdwn (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index c77837e3c..70233decf 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -130,6 +130,7 @@ sub preprocess (@) { $value=urlto($link, $page); $pagestate{$page}{meta}{enclosure}=$value; + # fallthrough } elsif ($key eq 'author') { $pagestate{$page}{meta}{author}=$value; diff --git a/t/podcast.t b/t/podcast.t index 993814742..3125a7e55 100755 --- a/t/podcast.t +++ b/t/podcast.t @@ -9,7 +9,7 @@ BEGIN { "XML::Feed and/or HTML::Parser not available"}; } else { - eval q{use Test::More tests => 78}; + eval q{use Test::More tests => 81}; } } @@ -25,8 +25,10 @@ sub simple_podcast { push @command, qw(-set underlaydirbase=underlays -templatedir=templates); push @command, "-url=$baseurl", qw(t/tinypodcast), "$tmp/out"; - ok(! system("mkdir $tmp"), q{setup}); - ok(! system(@command), q{build}); + ok(! system("mkdir $tmp"), + q{setup}); + ok(! system(@command), + q{build}); my %media_types = ( 'simplepost' => undef, @@ -97,21 +99,28 @@ sub single_page_html { push @command, qw(-set underlaydirbase=underlays -templatedir=templates); push @command, qw(t/tinypodcast), "$tmp/out"; - ok(! system("mkdir $tmp"), q{setup}); - ok(! system(@command), q{build}); + ok(! system("mkdir $tmp"), + q{setup}); + ok(! system(@command), + q{build}); my $html = "$tmp/out/pianopost/index.html"; - - my $body = _extract_html_content($html, 'content'); - like($body, qr/article has content and/m, q{html body text}); - - my $enclosure = _extract_html_content($html, 'enclosure'); - like($enclosure, qr/Download this episode/m, q{html enclosure}); - + like(_extract_html_content($html, 'content'), qr/has content and/m, + q{html body text}); + like(_extract_html_content($html, 'enclosure'), qr/this episode/m, + q{html enclosure}); my ($href) = _extract_html_links($html, 'piano'); - ok(-f $href, q{html enclosure exists}); - - # XXX die if more than one enclosure is specified + ok(-f $href, + q{html enclosure exists}); + + $html = "$tmp/out/attempted_multiple_enclosures/index.html"; + like(_extract_html_content($html, 'content'), qr/has content and/m, + q{html body text}); + like(_extract_html_content($html, 'enclosure'), qr/this episode/m, + q{html enclosure}); + ($href) = _extract_html_links($html, 'walter'); + ok(-f $href, + q{html enclosure exists}); ok(! system("rm -rf $tmp $statedir"), q{teardown}); } diff --git a/t/tinypodcast/attempted_multiple_enclosures.mdwn b/t/tinypodcast/attempted_multiple_enclosures.mdwn new file mode 100644 index 000000000..ea7bae8d0 --- /dev/null +++ b/t/tinypodcast/attempted_multiple_enclosures.mdwn @@ -0,0 +1,4 @@ +[[!meta enclosure="piano.mp3" enclosure="scroll.3gp"]] +[[!meta enclosure="walter.ogg"]] + +this article has content _and_ only one enclosure! -- cgit v1.2.3 From 3d2be49420b0f29f169ec015f11af1f0624b9ec9 Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Wed, 20 Feb 2013 19:14:20 -0500 Subject: Make enclosures absolute (in feeds they have to be). --- IkiWiki/Plugin/meta.pm | 4 ++-- t/podcast.t | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 70233decf..f5b9bb521 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -128,7 +128,7 @@ sub preprocess (@) { } add_depends($page, $link, deptype("presence")); - $value=urlto($link, $page); + $value=urlto($link, $page, 1); $pagestate{$page}{meta}{enclosure}=$value; # fallthrough } @@ -330,7 +330,7 @@ sub pagetemplate (@) { } if (exists $pagestate{$page}{meta}{enclosure}) { - $template->param(enclosure => $pagestate{$page}{meta}{enclosure}); + $template->param(enclosure => HTML::Entities::encode_entities(IkiWiki::urlabs($pagestate{$page}{meta}{enclosure}, $config{url}))); } foreach my $field (qw{authorurl}) { diff --git a/t/podcast.t b/t/podcast.t index 235c2e768..88d2ca074 100755 --- a/t/podcast.t +++ b/t/podcast.t @@ -9,7 +9,7 @@ BEGIN { "XML::Feed and/or HTML::Parser not available"}; } else { - eval q{use Test::More tests => 89}; + eval q{use Test::More tests => 92}; } } @@ -110,8 +110,8 @@ sub single_page_html { like(_extract_html_content($html, 'enclosure'), qr/this episode/m, q{html enclosure}); my ($href) = _extract_html_links($html, 'piano'); - ok(-f $href, - q{html enclosure exists}); + is($href, '/piano.mp3', + q{html enclosure sans -url is site-absolute}); $html = "$tmp/out/attempted_multiple_enclosures/index.html"; like(_extract_html_content($html, 'content'), qr/has content and/m, @@ -119,8 +119,21 @@ sub single_page_html { like(_extract_html_content($html, 'enclosure'), qr/this episode/m, q{html enclosure}); ($href) = _extract_html_links($html, 'walter'); - ok(-f $href, - q{html enclosure exists}); + is($href, '/walter.ogg', + q{html enclosure sans -url is site-absolute}); + + my $baseurl = 'http://example.com'; + ok(! system(@command, "-url=$baseurl", q{--rebuild})); + + $html = "$tmp/out/pianopost/index.html"; + ($href) = _extract_html_links($html, 'piano'); + is($href, "$baseurl/piano.mp3", + q{html enclosure with -url is fully absolute}); + + $html = "$tmp/out/attempted_multiple_enclosures/index.html"; + ($href) = _extract_html_links($html, 'walter'); + is($href, "$baseurl/walter.ogg", + q{html enclosure with -url is fully absolute}); ok(! system("rm -rf $tmp $statedir"), q{teardown}); } @@ -146,11 +159,11 @@ sub inlined_pages_html { like($enclosures, qr/this episode/m, q{html enclosure}); my ($href) = _extract_html_links($html, 'piano.mp3'); - ok(-f $href, - q{html enclosure from pianopost exists}); + is($href, '/piano.mp3', + q{html enclosure from pianopost sans -url}); ($href) = _extract_html_links($html, 'walter.ogg'); - ok(-f $href, - q{html enclosure from attempted_multiple_enclosures exists}); + is($href, '/walter.ogg', + q{html enclosure from attempted_multiple_enclosures sans -url}); ok(! system("rm -rf $tmp $statedir"), q{teardown}); } -- cgit v1.2.3 From a629b276b27bb900ec9e544820cd42aa140e8bdc Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Wed, 20 Feb 2013 20:53:50 -0500 Subject: Extract genenclosure(). No functional change intended. --- IkiWiki/Plugin/inline.pm | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'IkiWiki/Plugin') 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 { -- cgit v1.2.3 From d77ee60b1506302ca6e2a5bd2023c380334167c0 Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Wed, 20 Feb 2013 21:16:19 -0500 Subject: Render fancy podcast enclosures. Simple podcast feeds didn't have content tags and I made sure to keep it that way. This may be unnecessarily conservative. Changing the behavior to include empty content tags might be fine, but I don't want to think about it right now, I just want my tests to keep passing! The new fancy-podcast tests are copy-pasted-edited from the simple-podcast tests. These tests shall be refactored. --- IkiWiki/Plugin/inline.pm | 21 ++++++++--- t/podcast.t | 92 +++++++++++++++++++++++++++++++++++++++++++++++- templates/atomitem.tmpl | 5 +-- templates/rssitem.tmpl | 5 +-- 4 files changed, 113 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 20cb8a27c..9b4cee4e4 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -647,6 +647,7 @@ sub genfeed ($$$$$@) { foreach my $p (@pages) { my $u=URI->new(encode_utf8(urlto($p, "", 1))); my $pcontent = absolute_urls(get_inline_content($p, $page), $url); + my $fancy_enclosure_seen = 0; $itemtemplate->param( title => pagetitle(basename($p)), @@ -668,17 +669,27 @@ sub genfeed ($$$$$@) { $itemtemplate->param(mdate_822 => date_822($pagestate{$p}{meta}{updated})); $itemtemplate->param(mdate_3339 => date_3339($pagestate{$p}{meta}{updated})); } + + if (exists $pagestate{$p}{meta}{enclosure}) { + my $absurl = $pagestate{$p}{meta}{enclosure}; + + # XXX better way to compute relative to srcdir? + my $file = $absurl; + $file =~ s|^$config{url}/||; + + genenclosure($itemtemplate, $absurl, $file); + $fancy_enclosure_seen = 1; + } } my $file=$pagesources{$p}; - my $type=pagetype($file); - if (defined $type) { - $itemtemplate->param(content => $pcontent); - } - else { + unless ($fancy_enclosure_seen || defined(pagetype($file))) { genenclosure($itemtemplate, $u, $file); + $itemtemplate->param(simplepodcast => 1); } + $itemtemplate->param(content => $pcontent); + run_hooks(pagetemplate => sub { shift->(page => $p, destpage => $page, template => $itemtemplate); diff --git a/t/podcast.t b/t/podcast.t index 88d2ca074..6a2c25ee1 100755 --- a/t/podcast.t +++ b/t/podcast.t @@ -9,7 +9,7 @@ BEGIN { "XML::Feed and/or HTML::Parser not available"}; } else { - eval q{use Test::More tests => 92}; + eval q{use Test::More tests => 136}; } } @@ -72,6 +72,11 @@ sub simple_podcast { qq{$format $title id}); is($body, undef, qq{$format $title no body text}); + + # prevent undef method killing test harness + $enclosure = XML::Feed::Enclosure->new({}) + unless defined $enclosure; + is($enclosure->url, $url, qq{$format $title enclosure url}); is($enclosure->type, $media_types{$title}, @@ -93,6 +98,90 @@ sub simple_podcast { ok(! system("rm -rf $tmp $statedir"), q{teardown}); } +sub fancy_podcast { + my $baseurl = 'http://example.com'; + my @command = (qw(./ikiwiki.out -plugin inline -rss -atom)); + push @command, qw(-underlaydir=underlays/basewiki); + push @command, qw(-set underlaydirbase=underlays -templatedir=templates); + push @command, "-url=$baseurl", qw(t/tinypodcast), "$tmp/out"; + + ok(! system("mkdir $tmp"), + q{setup}); + ok(! system(@command), + q{build}); + + my %media_types = ( + 'piano.mp3' => 'audio/mpeg', + 'walter.ogg' => 'video/x-theora+ogg', + ); + + for my $format (qw(atom rss)) { + my $feed = XML::Feed->parse("$tmp/out/fancy/index.$format"); + + is($feed->title, 'fancy', + qq{$format feed title}); + is($feed->link, "$baseurl/fancy/", + qq{$format feed link}); + is($feed->description, 'wiki', + qq{$format feed description}); + if ('atom' eq $format) { + is($feed->author, $feed->description, + qq{$format feed author}); + is($feed->id, $feed->link, + qq{$format feed id}); + is($feed->generator, "ikiwiki", + qq{$format feed generator}); + } + + # XXX compare against simple_podcast + # XXX make them table-driven shared code + for my $entry ($feed->entries) { + my $title = $entry->title; + my $url = $entry->id; + my $body = $entry->content->body; + my $enclosure = $entry->enclosure; + + is($entry->link, $url, qq{$format $title link}); + isnt($entry->issued, undef, + qq{$format $title issued date}); + isnt($entry->modified, undef, + qq{$format $title modified date}); + + if (defined $media_types{$title}) { + is($url, "$baseurl/$title", + qq{$format $title id}); + is($body, undef, + qq{$format $title no body text}); + is($enclosure->url, $url, + qq{$format $title enclosure url}); + is($enclosure->type, $media_types{$title}, + qq{$format $title enclosure type}); + cmp_ok($enclosure->length, '>', 0, + qq{$format $title enclosure length}); + } + else { + my $expected_id = "$baseurl/$title/"; + $expected_id =~ s/\ /_/g; + + is($url, $expected_id, + qq{$format $title id}); + isnt($body, undef, + qq{$format $title body text}); + isnt($enclosure, undef, + qq{$format $title enclosure}); + use File::Basename; + my $filename = basename($enclosure->url); + is($enclosure->type, $media_types{$filename}, + qq{$format $title enclosure type}); + cmp_ok($enclosure->length, '>', 0, + qq{$format $title enclosure length}); + } + } + } + + ok(! system("rm -rf $tmp $statedir"), q{teardown}); +} + sub single_page_html { my @command = (qw(./ikiwiki.out)); push @command, qw(-underlaydir=underlays/basewiki); @@ -211,3 +300,4 @@ sub _extract_html_links { simple_podcast(); single_page_html(); inlined_pages_html(); +fancy_podcast(); diff --git a/templates/atomitem.tmpl b/templates/atomitem.tmpl index 4ed17bc62..9b056e0f4 100644 --- a/templates/atomitem.tmpl +++ b/templates/atomitem.tmpl @@ -34,11 +34,12 @@ - + + - + diff --git a/templates/rssitem.tmpl b/templates/rssitem.tmpl index 831daa871..2d315173b 100644 --- a/templates/rssitem.tmpl +++ b/templates/rssitem.tmpl @@ -20,9 +20,10 @@ - - + + + -- cgit v1.2.3 From 4b6ea05ac87f5085e4df5c2ebc3d1a17a6cd2397 Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Fri, 22 Feb 2013 12:54:16 -0500 Subject: Catch up rsspage to atompage. Validates. --- IkiWiki/Plugin/inline.pm | 1 + templates/rsspage.tmpl | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 9b4cee4e4..e313eb775 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -710,6 +710,7 @@ sub genfeed ($$$$$@) { feeddesc => $feeddesc, guid => $guid, feeddate => date_3339($lasttime), + feeddate_822 => date_822($lasttime), feedurl => $feedurl, ); run_hooks(pagetemplate => sub { diff --git a/templates/rsspage.tmpl b/templates/rsspage.tmpl index e54094aaa..fec6775c2 100644 --- a/templates/rsspage.tmpl +++ b/templates/rsspage.tmpl @@ -1,11 +1,18 @@ <TMPL_VAR TITLE> + + + + +ikiwiki + -- cgit v1.2.3 From b25f7700bde4981d1fb69d89c1451abc0c7bb87a Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Thu, 27 Jun 2013 00:21:20 -0400 Subject: Instead of hacking back to $link, just provide it. --- IkiWiki/Plugin/inline.pm | 6 +----- IkiWiki/Plugin/meta.pm | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index e313eb775..455ac3ad5 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -672,11 +672,7 @@ sub genfeed ($$$$$@) { if (exists $pagestate{$p}{meta}{enclosure}) { my $absurl = $pagestate{$p}{meta}{enclosure}; - - # XXX better way to compute relative to srcdir? - my $file = $absurl; - $file =~ s|^$config{url}/||; - + my $file = $pagestate{$p}{meta}{enclosurefile}; genenclosure($itemtemplate, $absurl, $file); $fancy_enclosure_seen = 1; } diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 794f6d861..e7b96bdf1 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -130,6 +130,7 @@ sub preprocess (@) { $value=urlto($link, $page, 1); $pagestate{$page}{meta}{enclosure}=$value; + $pagestate{$page}{meta}{enclosurefile}=$link; # fallthrough } elsif ($key eq 'author') { -- cgit v1.2.3 From 97d0c09a18d9c9b1defb3f4849e04e06745000c7 Mon Sep 17 00:00:00 2001 From: Amitai Schlair Date: Wed, 17 Jul 2013 16:38:08 -0400 Subject: Show author in addition to feedname, if different. While here, mollify http://validator.w3.org/feed/ and s/dcterms:creator/dc:creator/g, which happens to make rss2email see and do nice things with authors. --- IkiWiki/Plugin/aggregate.pm | 4 ++++ templates/aggregatepost.tmpl | 4 ++++ templates/rssitem.tmpl | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 89da5c453..be6e8d476 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -593,6 +593,7 @@ sub aggregate (@) { feed => $feed, copyright => $f->copyright, title => defined $entry->title ? decode_entities($entry->title) : "untitled", + author => defined $entry->author ? decode_entities($entry->author) : "", link => $entry->link, content => (defined $c && defined $c->body) ? $c->body : "", guid => defined $entry->id ? $entry->id : time."_".$feed->{name}, @@ -690,6 +691,9 @@ sub write_page ($$$$$) { } $template->param(title => $params{title}) if defined $params{title} && length($params{title}); + $template->param(author => $params{author}) + if defined $params{author} && length($params{author} + && $params{author} ne $feed->{name}); $template->param(content => wikiescape(htmlabs($params{content}, defined $params{base} ? $params{base} : $feed->{feedurl}))); $template->param(name => $feed->{name}); diff --git a/templates/aggregatepost.tmpl b/templates/aggregatepost.tmpl index 4e89efe32..a89ccfcdf 100644 --- a/templates/aggregatepost.tmpl +++ b/templates/aggregatepost.tmpl @@ -11,5 +11,9 @@ [[!meta copyright=""]] + +[[!meta author=": "]] + [[!meta author=""]] + [[!meta authorurl=""]] diff --git a/templates/rssitem.tmpl b/templates/rssitem.tmpl index 9acefb5d3..bb03ca5bc 100644 --- a/templates/rssitem.tmpl +++ b/templates/rssitem.tmpl @@ -7,7 +7,7 @@ - + -- cgit v1.2.3