Skip to content

Commit

Permalink
atom: include source URL in rel=alternate link along with actor URL
Browse files Browse the repository at this point in the history
fixes #151
  • Loading branch information
snarfed committed Jul 2, 2018
1 parent 05f206e commit 2310f03
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ This release is intentionally small and limited in scope to contain any impact o
* Atom:
* Add `atom_to_activities()` for converting full feed documents.
* Add to REST API and web UI.
* Include source URL in `rel=alternate` link as well as actor/author URL ([#151](https://github.com/snarfed/granary/issues/151)).
* JSON Feed:
* Fix bug that omitted title in some cases ([#122](https://github.com/snarfed/granary/issues/122)).
Expand Down
5 changes: 4 additions & 1 deletion granary/templates/user_feed.atom
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:thr="http://purl.org/syndication/thread/1.0"
{% if xml_base %}xml:base="{{ xml_base }}"{% endif %}>
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>{{ host_url }}</id>
<title>{{ title }}</title>
{% if actor.description %}
Expand All @@ -18,7 +18,10 @@
<updated>{{ updated }}</updated>
{% include "author.atom" %}

<link rel="alternate" href="{{ host_url }}" type="text/html" />
{% if actor.url and actor.url != host_url %}
<link rel="alternate" href="{{ actor.url }}" type="text/html" />
{% endif %}
{% if actor.image.url %}
<link rel="avatar" href="{{ actor.image.url }}" />
{% endif %}
Expand Down
6 changes: 4 additions & 2 deletions granary/test/test_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def test_html_to_atom(self):
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:base="https://my.site/">
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>https://my.site/feed</id>
<title>my title</title>
Expand All @@ -515,6 +515,7 @@ def test_html_to_atom(self):
<name>My Name</name>
</author>
<link rel="alternate" href="https://my.site/feed" type="text/html" />
<link rel="alternate" href="http://my/site" type="text/html" />
<link rel="avatar" href="http://my/picture" />
<link rel="self" href="https://my.site/feed" type="application/atom+xml" />
Expand Down Expand Up @@ -620,6 +621,7 @@ def test_html_to_atom_fetch_author(self):
<name>Tantek Çelik</name>
</author>
<link rel="alternate" href="https://my.site/" type="text/html" />
<link rel="alternate" href="https://my.site/author" type="text/html" />
<link rel="avatar" href="https://my.site/photo.jpg" />
<link rel="self" href="https://my.site/" type="application/atom+xml" />
Expand All @@ -634,7 +636,7 @@ def test_html_to_atom_fetch_author(self):

def test_html_to_atom_title_without_hfeed_name(self):
self.assert_multiline_in("""\
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>https://my.site/feed</id>
<title>unmarked feed title</title>
""", atom.html_to_atom("""\
Expand Down
3 changes: 2 additions & 1 deletion granary/test/test_facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ def tag_uri(name):
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:base="%(base_url)s">
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>%(host_url)s</id>
<title>User feed for Ryan Barrett</title>
Expand All @@ -963,6 +963,7 @@ def tag_uri(name):
<name>Ryan Barrett</name>
</author>
<link rel="alternate" href="%(host_url)s" type="text/html" />
<link rel="alternate" href="https://snarfed.org/" type="text/html" />
<link rel="avatar" href="https://graph.facebook.com/v2.10/212038/picture?type=large" />
<link rel="self" href="%(request_url)s" type="application/atom+xml" />
Expand Down
3 changes: 2 additions & 1 deletion granary/test/test_instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def tag_uri(name):
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:base="%(base_url)s">
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>%(host_url)s</id>
<title>User feed for Ryan B</title>
Expand All @@ -380,6 +380,7 @@ def tag_uri(name):
<name>Ryan B</name>
</author>
<link rel="alternate" href="%(host_url)s" type="text/html" />
<link rel="alternate" href="http://snarfed.org" type="text/html" />
<link rel="avatar" href="http://picture/ryan" />
<link rel="self" href="%(request_url)s" type="application/atom+xml" />
Expand Down
3 changes: 2 additions & 1 deletion granary/test/test_twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def tag_uri(name):
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:base="%(base_url)s">
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>%(host_url)s</id>
<title>User feed for Ryan Barrett</title>
Expand All @@ -619,6 +619,7 @@ def tag_uri(name):
<name>Ryan Barrett</name>
</author>
<link rel="alternate" href="%(host_url)s" type="text/html" />
<link rel="alternate" href="https://snarfed.org/" type="text/html" />
<link rel="avatar" href="http://a0.twimg.com/profile_images/866165047/ryan.jpg" />
<link rel="self" href="%(request_url)s" type="application/atom+xml" />
Expand Down
5 changes: 4 additions & 1 deletion test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
xmlns:ostatus="http://ostatus.org/schema/1.0"
xmlns:thr="http://purl.org/syndication/thread/1.0"
xml:base="http://my/">
<generator uri="https://github.com/snarfed/granary">granary</generator>
<generator uri="https://granary.io/">granary</generator>
<id>http://my/posts.html</id>
<title>my title</title>
Expand All @@ -148,6 +148,7 @@
<name>My Name</name>
</author>
<link rel="alternate" href="http://my/posts.html" type="text/html" />
<link rel="alternate" href="http://my/site" type="text/html" />
<link rel="avatar" href="http://my/picture" />
<link rel="self" href="http://localhost/url?url=http://my/posts.html&amp;input=html&amp;output=atom" type="application/atom+xml" />
Expand Down Expand Up @@ -348,6 +349,7 @@ def test_url_html_to_atom_rel_author(self):
<name>Someone Else</name>
</author>
<link rel="alternate" href="http://my/posts.html" type="text/html" />
<link rel="alternate" href="http://my/author" type="text/html" />
<link rel="avatar" href="http://someone/picture" />
<link rel="self" href="http://localhost/url?url=http://my/posts.html&amp;input=html&amp;output=atom" type="application/atom+xml" />
Expand Down Expand Up @@ -380,6 +382,7 @@ def test_url_html_to_atom_skip_silo_rel_authors(self):
<uri>https://plus.google.com/+Author</uri>
</author>
<link rel="alternate" href="http://my/posts.html" type="text/html" />
<link rel="alternate" href="https://plus.google.com/+Author" type="text/html" />
<link rel="self" href="http://localhost/url?url=http://my/posts.html&amp;input=html&amp;output=atom" type="application/atom+xml" />
Expand Down

0 comments on commit 2310f03

Please sign in to comment.