Skip to content

Commit

Permalink
Remove Atom summaries when they are unnecessary
Browse files Browse the repository at this point in the history
Do not include a summary tag to Atom entries when:
- the summary is empty
- the summary and the full content are the same

Fixes #2403
  • Loading branch information
NicolasLM committed Dec 18, 2018
1 parent 6f0743b commit 1b8a782
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 274 deletions.
8 changes: 1 addition & 7 deletions pelican/tests/output/basic/feeds/alexis-metaireau.atom.xml
Expand Up @@ -13,13 +13,7 @@ as well as <strong>inline markup</strong>.</p>
</pre>
<p>→ And now try with some utf8 hell: ééé</p>
</div>
</content><category term="foo"></category><category term="bar"></category><category term="foobar"></category></entry><entry><title>Oh yeah !</title><link href="/oh-yeah.html" rel="alternate"></link><published>2010-10-20T10:14:00+00:00</published><updated>2010-10-20T10:14:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-10-20:/oh-yeah.html</id><summary type="html">&lt;div class="section" id="why-not"&gt;
&lt;h2&gt;Why not ?&lt;/h2&gt;
&lt;p&gt;After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !&lt;/p&gt;
&lt;img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" /&gt;
&lt;/div&gt;
</summary><content type="html">&lt;div class="section" id="why-not"&gt;
</content><category term="foo"></category><category term="bar"></category><category term="foobar"></category></entry><entry><title>Oh yeah !</title><link href="/oh-yeah.html" rel="alternate"></link><published>2010-10-20T10:14:00+00:00</published><updated>2010-10-20T10:14:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-10-20:/oh-yeah.html</id><content type="html">&lt;div class="section" id="why-not"&gt;
&lt;h2&gt;Why not ?&lt;/h2&gt;
&lt;p&gt;After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !&lt;/p&gt;
Expand Down
30 changes: 8 additions & 22 deletions pelican/tests/output/basic/feeds/all-en.atom.xml
@@ -1,18 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>A Pelican Blog</title><link href="/" rel="alternate"></link><link href="/feeds/all-en.atom.xml" rel="self"></link><id>/</id><updated>2013-11-17T23:29:00+00:00</updated><entry><title>FILENAME_METADATA example</title><link href="/filename_metadata-example.html" rel="alternate"></link><published>2012-11-30T00:00:00+00:00</published><updated>2012-11-30T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2012-11-30:/filename_metadata-example.html</id><summary type="html">&lt;p&gt;Some cool stuff!&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Some cool stuff!&lt;/p&gt;
</content></entry><entry><title>Second article</title><link href="/second-article.html" rel="alternate"></link><published>2012-02-29T00:00:00+00:00</published><updated>2012-02-29T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2012-02-29:/second-article.html</id><summary type="html">&lt;p&gt;This is some article, in english&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This is some article, in english&lt;/p&gt;
</content><category term="foo"></category><category term="bar"></category><category term="baz"></category></entry><entry><title>A markdown powered article</title><link href="/a-markdown-powered-article.html" rel="alternate"></link><published>2011-04-20T00:00:00+00:00</published><updated>2011-04-20T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-04-20:/a-markdown-powered-article.html</id><summary type="html">&lt;p&gt;You're mutually oblivious.&lt;/p&gt;
<feed xmlns="http://www.w3.org/2005/Atom"><title>A Pelican Blog</title><link href="/" rel="alternate"></link><link href="/feeds/all-en.atom.xml" rel="self"></link><id>/</id><updated>2013-11-17T23:29:00+00:00</updated><entry><title>FILENAME_METADATA example</title><link href="/filename_metadata-example.html" rel="alternate"></link><published>2012-11-30T00:00:00+00:00</published><updated>2012-11-30T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2012-11-30:/filename_metadata-example.html</id><content type="html">&lt;p&gt;Some cool stuff!&lt;/p&gt;
</content></entry><entry><title>Second article</title><link href="/second-article.html" rel="alternate"></link><published>2012-02-29T00:00:00+00:00</published><updated>2012-02-29T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2012-02-29:/second-article.html</id><content type="html">&lt;p&gt;This is some article, in english&lt;/p&gt;
</content><category term="foo"></category><category term="bar"></category><category term="baz"></category></entry><entry><title>A markdown powered article</title><link href="/a-markdown-powered-article.html" rel="alternate"></link><published>2011-04-20T00:00:00+00:00</published><updated>2011-04-20T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-04-20:/a-markdown-powered-article.html</id><content type="html">&lt;p&gt;You're mutually oblivious.&lt;/p&gt;
&lt;p&gt;&lt;a href="/unbelievable.html"&gt;a root-relative link to unbelievable&lt;/a&gt;
&lt;a href="/unbelievable.html"&gt;a file-relative link to unbelievable&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;p&gt;You're mutually oblivious.&lt;/p&gt;
&lt;p&gt;&lt;a href="/unbelievable.html"&gt;a root-relative link to unbelievable&lt;/a&gt;
&lt;a href="/unbelievable.html"&gt;a file-relative link to unbelievable&lt;/a&gt;&lt;/p&gt;</content></entry><entry><title>Article 1</title><link href="/article-1.html" rel="alternate"></link><published>2011-02-17T00:00:00+00:00</published><updated>2011-02-17T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-02-17:/article-1.html</id><summary type="html">&lt;p&gt;Article 1&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Article 1&lt;/p&gt;
</content></entry><entry><title>Article 2</title><link href="/article-2.html" rel="alternate"></link><published>2011-02-17T00:00:00+00:00</published><updated>2011-02-17T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-02-17:/article-2.html</id><summary type="html">&lt;p&gt;Article 2&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Article 2&lt;/p&gt;
</content></entry><entry><title>Article 3</title><link href="/article-3.html" rel="alternate"></link><published>2011-02-17T00:00:00+00:00</published><updated>2011-02-17T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-02-17:/article-3.html</id><summary type="html">&lt;p&gt;Article 3&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Article 3&lt;/p&gt;
&lt;a href="/unbelievable.html"&gt;a file-relative link to unbelievable&lt;/a&gt;&lt;/p&gt;</content></entry><entry><title>Article 1</title><link href="/article-1.html" rel="alternate"></link><published>2011-02-17T00:00:00+00:00</published><updated>2011-02-17T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-02-17:/article-1.html</id><content type="html">&lt;p&gt;Article 1&lt;/p&gt;
</content></entry><entry><title>Article 2</title><link href="/article-2.html" rel="alternate"></link><published>2011-02-17T00:00:00+00:00</published><updated>2011-02-17T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-02-17:/article-2.html</id><content type="html">&lt;p&gt;Article 2&lt;/p&gt;
</content></entry><entry><title>Article 3</title><link href="/article-3.html" rel="alternate"></link><published>2011-02-17T00:00:00+00:00</published><updated>2011-02-17T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2011-02-17:/article-3.html</id><content type="html">&lt;p&gt;Article 3&lt;/p&gt;
</content></entry><entry><title>This is a super article !</title><link href="/this-is-a-super-article.html" rel="alternate"></link><published>2010-12-02T10:14:00+00:00</published><updated>2013-11-17T23:29:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-12-02:/this-is-a-super-article.html</id><summary type="html">&lt;p class="first last"&gt;Multi-line metadata should be supported
as well as &lt;strong&gt;inline markup&lt;/strong&gt;.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Some content here !&lt;/p&gt;
Expand All @@ -27,13 +20,7 @@ as well as &lt;strong&gt;inline markup&lt;/strong&gt;.&lt;/p&gt;
&lt;/pre&gt;
&lt;p&gt;→ And now try with some utf8 hell: ééé&lt;/p&gt;
&lt;/div&gt;
</content><category term="foo"></category><category term="bar"></category><category term="foobar"></category></entry><entry><title>Oh yeah !</title><link href="/oh-yeah.html" rel="alternate"></link><published>2010-10-20T10:14:00+00:00</published><updated>2010-10-20T10:14:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-10-20:/oh-yeah.html</id><summary type="html">&lt;div class="section" id="why-not"&gt;
&lt;h2&gt;Why not ?&lt;/h2&gt;
&lt;p&gt;After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !&lt;/p&gt;
&lt;img alt="alternate text" src="/pictures/Sushi.jpg" style="width: 600px; height: 450px;" /&gt;
&lt;/div&gt;
</summary><content type="html">&lt;div class="section" id="why-not"&gt;
</content><category term="foo"></category><category term="bar"></category><category term="foobar"></category></entry><entry><title>Oh yeah !</title><link href="/oh-yeah.html" rel="alternate"></link><published>2010-10-20T10:14:00+00:00</published><updated>2010-10-20T10:14:00+00:00</updated><author><name>Alexis Métaireau</name></author><id>tag:None,2010-10-20:/oh-yeah.html</id><content type="html">&lt;div class="section" id="why-not"&gt;
&lt;h2&gt;Why not ?&lt;/h2&gt;
&lt;p&gt;After all, why not ? It's pretty simple to do it, and it will allow me to write my blogposts in rst !
YEAH !&lt;/p&gt;
Expand Down Expand Up @@ -83,6 +70,5 @@ pelican.conf, it will have nothing in default.&lt;/p&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Lovely.&lt;/p&gt;
&lt;/div&gt;
</content></entry><entry><title>The baz tag</title><link href="/tag/baz.html" rel="alternate"></link><published>2010-03-14T00:00:00+00:00</published><updated>2010-03-14T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2010-03-14:/tag/baz.html</id><summary type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
</content></entry><entry><title>The baz tag</title><link href="/tag/baz.html" rel="alternate"></link><published>2010-03-14T00:00:00+00:00</published><updated>2010-03-14T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2010-03-14:/tag/baz.html</id><content type="html">&lt;p&gt;This article overrides the listening of the articles under the &lt;em&gt;baz&lt;/em&gt; tag.&lt;/p&gt;
</content></entry></feed>
3 changes: 1 addition & 2 deletions pelican/tests/output/basic/feeds/all-fr.atom.xml
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>A Pelican Blog</title><link href="/" rel="alternate"></link><link href="/feeds/all-fr.atom.xml" rel="self"></link><id>/</id><updated>2012-02-29T00:00:00+00:00</updated><entry><title>Deuxième article</title><link href="/second-article-fr.html" rel="alternate"></link><published>2012-02-29T00:00:00+00:00</published><updated>2012-02-29T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2012-02-29:/second-article-fr.html</id><summary type="html">&lt;p&gt;Ceci est un article, en français.&lt;/p&gt;
</summary><content type="html">&lt;p&gt;Ceci est un article, en français.&lt;/p&gt;
<feed xmlns="http://www.w3.org/2005/Atom"><title>A Pelican Blog</title><link href="/" rel="alternate"></link><link href="/feeds/all-fr.atom.xml" rel="self"></link><id>/</id><updated>2012-02-29T00:00:00+00:00</updated><entry><title>Deuxième article</title><link href="/second-article-fr.html" rel="alternate"></link><published>2012-02-29T00:00:00+00:00</published><updated>2012-02-29T00:00:00+00:00</updated><author><name></name></author><id>tag:None,2012-02-29:/second-article-fr.html</id><content type="html">&lt;p&gt;Ceci est un article, en français.&lt;/p&gt;
</content><category term="foo"></category><category term="bar"></category><category term="baz"></category></entry></feed>

0 comments on commit 1b8a782

Please sign in to comment.