Ok, all fixed and now both RSS and ATOM feeds are valid. @AmauryPi - If you still come around here, could you please consider making the following updates? If you don't come back and reply here, maybe after a few more weeks to a month, I'll fork this and re-release it. FYI, @arthrfrts. Edit: I went ahead and forked and did a pull request. See this post below.
Here's what you need to do everyone... it's very simple. Edit two files.
- atom.blade.php
- rss.blade.php
Both are within this extension's views folder.
Replace atom.blade.php's code with:
{!! '<'.'?xml version="1.0" encoding="utf-8"?'.'>' !!}
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[{!! $title !!}]]></title>
<subtitle><![CDATA[{!! $description !!}]]></subtitle>
<link href="{{ $self_link }}" rel="self" />
<link href="{{ $link }}" />
<id><![CDATA[{!! $link !!}]]></id>
<updated>{{ $pubDate->format(DateTime::ATOM) }}</updated>
@foreach ($entries as $entry)
<entry>
<title><![CDATA[{!! $entry['title'] !!}]]></title>
<link rel="alternate" type="text/html" href="{{ $entry['permalink'] }}"/>
<id>{{ $entry['permalink'] }}</id>
<updated>{{ $entry['pubdate']->format(DateTime::ATOM) }}</updated>
<summary><![CDATA[{!! $entry['description'] !!}]]></summary>
<content type="html"><![CDATA[{!! $entry['content'] !!}]]></content>
<author>
<name>{{ $entry['author'] }}</name>
</author>
</entry>
@endforeach
</feed>
Replace rss.blade.php's code with:
{!! '<'.'?xml version="1.0" encoding="utf-8"?'.'>' !!}
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title><![CDATA[{!! $title !!}]]></title>
@if (!empty($description))<description><![CDATA[{!! $description !!}]]></description>@endif
<link><![CDATA[{!! $link !!}]]></link>
<pubDate>{{ $pubDate->format(DateTime::RSS) }}</pubDate>
<atom:link href="{{ $self_link }}" rel="self" type="application/rss+xml" />
@foreach ($entries as $entry)
<item>
<title><![CDATA[{!! $entry['title'] !!}]]></title>
<description><![CDATA[{!! $entry['description'] !!}]]></description>
<content:encoded><![CDATA[{!! $entry['content'] !!}]]></content:encoded>
<guid>{{ $entry['permalink'] }}</guid>
<pubDate>{{ $entry['pubdate']->format(DateTime::RSS) }}</pubDate>
</item>
@endforeach
</channel>
</rss>
Final tip - up to you if you want to do this. The feeds are more likely to validate if you remove the full content portion of each feed. In other words, the code above includes a description/summary, plus full content with HTML tags. Feed validators don't like certain HTML tags. Plus, maybe you don't want people to be able to subscribe to a feed and see EVERYTHING. If this is the case, then...
In the above atom code remove this line:
<content type="html"><![CDATA[{!! $entry['content'] !!}]]></content>
In the rss code, remove:
<content:encoded><![CDATA[{!! $entry['content'] !!}]]></content:encoded>
Now you will still have all of the important parts of the feeds, including a description or summary of posts, but you won't have the full HTML of the posts.
Edit: @AmauryPi - In the pull request I went with taking the full HTML content portions out. It’s obviously up to you if you want to leave it that way. As you’ll see above, I had feed validation issues when leaving the full HTML content lines in. And so my pull request sticks with the basic text summaries only.