App-WRT

 view release on metacpan or  search on metacpan

example/blog/public/feed  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>wrt::feed</title><subtitle>a test wrt site</subtitle><link href="https://example.com/"/><link href="https://example.com/feed" rel="self"/><icon>https://example.com/favicon.png</icon><author><name>Examp...

&lt;article&gt;&lt;div class=&#34;entry&#34;&gt;&lt;h1&gt;Thursday, January 2, 2014&lt;/h1&gt;

&lt;p&gt;Test.&lt;/p&gt;

&lt;p class=&#34;centerpiece&#34;&gt; ✨ &lt;/p&gt;


&lt;p&gt;Test more.&lt;/p&gt;



&lt;p class=&#34;tags&#34;&gt;&lt;b&gt;tags:&lt;/b&gt; &lt;a href=&#34;https://example.com/something&#34;&gt;something&lt;/a&gt;&lt;/p&gt;&lt;p class=&#34;datestamp&#34;&gt;&lt;a href=&#34;https://example.com/&#34;&gt;wrt&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/&#34; title=&#34;2014&#34;&gt;2014&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/&#34; title=&#34;1&#34;&gt;1&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/2/&#34; title=&#34;2&#34;&gt;2&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/article&gt;

</content><updated>2020-07-23T16:45:33Z</updated></entry><entry><title>Wednesday, January 1, 2014</title><link href="https://example.com/2014/1/1"/><id>https://example.com/2014/1/1</id><content type="html">

&lt;article&gt;&lt;div class=&#34;entry&#34;&gt;&lt;h1&gt;Wednesday, January 1, 2014&lt;/h1&gt;

&lt;p&gt;Test.&lt;/p&gt;
&lt;p class=&#34;centerpiece&#34;&gt;+&lt;/p&gt;Test entry contents.
&lt;p&gt;&lt;em&gt;more:&lt;/em&gt;  &lt;a href=&#34;https://example.com/2014/1/1/test_entry&#34; title=&#34;test_entry&#34;&gt;test_entry&lt;/a&gt;&lt;/p&gt;

&lt;p class=&#34;datestamp&#34;&gt;&lt;a href=&#34;https://example.com/&#34;&gt;wrt&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/&#34; title=&#34;2014&#34;&gt;2014&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/&#34; title=&#34;1&#34;&gt;1&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/1/&#34; title=&#34;1&#34;&gt;1&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/article&gt;

</content><updated>2020-07-23T16:45:33Z</updated></entry><entry><title>Wednesday, February 13, 1952</title><link href="https://example.com/1952/2/13"/><id>https://example.com/1952/2/13</id><content type="html">

&lt;article&gt;&lt;div class=&#34;entry&#34;&gt;&lt;h1&gt;Wednesday, February 13, 1952&lt;/h1&gt;

&lt;p&gt;I still miss you.&lt;/p&gt;

&lt;p class=&#34;datestamp&#34;&gt;&lt;a href=&#34;https://example.com/&#34;&gt;wrt&lt;/a&gt; /
&lt;a href=&#34;https://example.com/1952/&#34; title=&#34;1952&#34;&gt;1952&lt;/a&gt; /
&lt;a href=&#34;https://example.com/1952/2/&#34; title=&#34;2&#34;&gt;2&lt;/a&gt; /
&lt;a href=&#34;https://example.com/1952/2/13/&#34; title=&#34;13&#34;&gt;13&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/article&gt;

</content><updated>2020-07-23T16:45:33Z</updated></entry></feed>

example/blog/public/feed.xml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>wrt::feed</title><subtitle>a test wrt site</subtitle><link href="https://example.com/"/><link href="https://example.com/feed" rel="self"/><icon>https://example.com/favicon.png</icon><author><name>Examp...

&lt;article&gt;&lt;div class=&#34;entry&#34;&gt;&lt;h1&gt;Thursday, January 2, 2014&lt;/h1&gt;

&lt;p&gt;Test.&lt;/p&gt;

&lt;p class=&#34;centerpiece&#34;&gt; ✨ &lt;/p&gt;


&lt;p&gt;Test more.&lt;/p&gt;



&lt;p class=&#34;tags&#34;&gt;&lt;b&gt;tags:&lt;/b&gt; &lt;a href=&#34;https://example.com/something&#34;&gt;something&lt;/a&gt;&lt;/p&gt;&lt;p class=&#34;datestamp&#34;&gt;&lt;a href=&#34;https://example.com/&#34;&gt;wrt&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/&#34; title=&#34;2014&#34;&gt;2014&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/&#34; title=&#34;1&#34;&gt;1&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/2/&#34; title=&#34;2&#34;&gt;2&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/article&gt;

</content><updated>2020-07-23T16:45:33Z</updated></entry><entry><title>Wednesday, January 1, 2014</title><link href="https://example.com/2014/1/1"/><id>https://example.com/2014/1/1</id><content type="html">

&lt;article&gt;&lt;div class=&#34;entry&#34;&gt;&lt;h1&gt;Wednesday, January 1, 2014&lt;/h1&gt;

&lt;p&gt;Test.&lt;/p&gt;
&lt;p class=&#34;centerpiece&#34;&gt;+&lt;/p&gt;Test entry contents.
&lt;p&gt;&lt;em&gt;more:&lt;/em&gt;  &lt;a href=&#34;https://example.com/2014/1/1/test_entry&#34; title=&#34;test_entry&#34;&gt;test_entry&lt;/a&gt;&lt;/p&gt;

&lt;p class=&#34;datestamp&#34;&gt;&lt;a href=&#34;https://example.com/&#34;&gt;wrt&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/&#34; title=&#34;2014&#34;&gt;2014&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/&#34; title=&#34;1&#34;&gt;1&lt;/a&gt; /
&lt;a href=&#34;https://example.com/2014/1/1/&#34; title=&#34;1&#34;&gt;1&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/article&gt;

</content><updated>2020-07-23T16:45:33Z</updated></entry><entry><title>Wednesday, February 13, 1952</title><link href="https://example.com/1952/2/13"/><id>https://example.com/1952/2/13</id><content type="html">

&lt;article&gt;&lt;div class=&#34;entry&#34;&gt;&lt;h1&gt;Wednesday, February 13, 1952&lt;/h1&gt;

&lt;p&gt;I still miss you.&lt;/p&gt;

&lt;p class=&#34;datestamp&#34;&gt;&lt;a href=&#34;https://example.com/&#34;&gt;wrt&lt;/a&gt; /
&lt;a href=&#34;https://example.com/1952/&#34; title=&#34;1952&#34;&gt;1952&lt;/a&gt; /
&lt;a href=&#34;https://example.com/1952/2/&#34; title=&#34;2&#34;&gt;2&lt;/a&gt; /
&lt;a href=&#34;https://example.com/1952/2/13/&#34; title=&#34;13&#34;&gt;13&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/article&gt;

</content><updated>2020-07-23T16:45:33Z</updated></entry></feed>

lib/App/WRT.pm  view on Meta::CPAN

  my $feed = XML::Atom::SimpleFeed->new(
    -encoding => 'UTF-8',
    title     => $self->{title_prefix} . "::" . $self->{feed_alias},
    subtitle  => $self->{description},
    link      => $self->{url_root},
    link      => { rel => 'self', href => $feed_url, },
    icon      => $self->{favicon_url},
    author    => $self->{author},
    id        => $self->{url_root},
    generator => 'App::WRT.pm / XML::Atom::SimpleFeed',
    updated   => iso_date(get_mtime($first_entry_file)),
  );

  foreach my $entry (@entries) {
    my $content = $self->{html_cache}{$entry};
    if ( $self->{metadata_html_cache}{$entry} ) {
      $content .= '<div class=entry-metadata>'
                . $self->{metadata_html_cache}{$entry}
                . '</div>';
    }

    my ($entry_file, $entry_url) = $self->root_locations($entry);

    $feed->add_entry(
      title   => $self->get_title($entry),
      link    => $entry_url,
      id      => $entry_url,
      content => $content,
      updated => iso_date(get_mtime($entry_file)),
    );
  }

  # Note: This output should be served with
  # Content-type: application/atom+xml
  #
  # I'm not, to be frank, entirely clear on why the decode() call here is
  # necessary:
  return decode('UTF-8', $feed->as_string);
}



( run in 0.283 second using v1.01-cache-2.11-cpan-05444aca049 )