Browse Source

Update feeds to have absolute permalinks

merge-requests/135/head
Deimos 4 years ago
parent
commit
5093fca18e
  1. 5
      tildes/tildes/models/topic/topic.py
  2. 6
      tildes/tildes/templates/topic_listing.atom.jinja2
  3. 6
      tildes/tildes/templates/topic_listing.rss.jinja2

5
tildes/tildes/models/topic/topic.py

@ -419,6 +419,11 @@ class Topic(DatabaseModel):
"""Return the permalink for this topic.""" """Return the permalink for this topic."""
return f"/~{self.group.path}/{self.topic_id36}/{self.url_slug}" return f"/~{self.group.path}/{self.topic_id36}/{self.url_slug}"
@property
def permalink_absolute(self) -> str:
"""Return the absolute permalink for this topic (domain included)."""
return f"https://tildes.net{self.permalink}"
@property @property
def is_text_type(self) -> bool: def is_text_type(self) -> bool:
"""Return whether this is a text topic.""" """Return whether this is a text topic."""

6
tildes/tildes/templates/topic_listing.atom.jinja2

@ -10,11 +10,11 @@
{% for topic in topics %} {% for topic in topics %}
<entry> <entry>
<title><![CDATA[{{ topic.title }}]]></title> <title><![CDATA[{{ topic.title }}]]></title>
<id>https://tildes.net{{ topic.permalink }}</id>
<id>{{ topic.permalink_absolute }}</id>
{% if topic.is_link_type %} {% if topic.is_link_type %}
<link rel="alternate" href="{{ topic.link }}"/> <link rel="alternate" href="{{ topic.link }}"/>
{% else %} {% else %}
<link rel="alternate" href="{{ topic.permalink }}"/>
<link rel="alternate" href="{{ topic.permalink_absolute }}"/>
{% endif %} {% endif %}
<content type="html"><![CDATA[ <content type="html"><![CDATA[
{% if topic.is_link_type %} {% if topic.is_link_type %}
@ -23,7 +23,7 @@
{{ topic.rendered_html|safe }} {{ topic.rendered_html|safe }}
<hr/> <hr/>
{% endif %} {% endif %}
<p>Comments URL: <a href="{{ topic.permalink }}">https://tildes.net{{ topic.permalink }}</a></p>
<p>Comments URL: <a href="{{ topic.permalink_absolute }}">{{ topic.permalink_absolute }}</a></p>
<p>Votes: {{ topic.num_votes }}</p> <p>Votes: {{ topic.num_votes }}</p>
<p>Comments: {{ topic.num_comments }}</p> <p>Comments: {{ topic.num_comments }}</p>
]]></content> ]]></content>

6
tildes/tildes/templates/topic_listing.rss.jinja2

@ -15,7 +15,7 @@
{% if topic.is_link_type %} {% if topic.is_link_type %}
<link>{{ topic.link }}</link> <link>{{ topic.link }}</link>
{% else %} {% else %}
<link>{{ topic.permalink }}</link>
<link>{{ topic.permalink_absolute }}</link>
{% endif %} {% endif %}
<description><![CDATA[ <description><![CDATA[
{% if topic.is_link_type %} {% if topic.is_link_type %}
@ -24,12 +24,12 @@
{{ topic.rendered_html|safe }} {{ topic.rendered_html|safe }}
<hr/> <hr/>
{% endif %} {% endif %}
<p>Comments URL: <a href="{{ topic.permalink }}">https://tildes.net{{ topic.permalink }}</a></p>
<p>Comments URL: <a href="{{ topic.permalink_absolute }}">{{ topic.permalink_absolute }}</a></p>
<p>Votes: {{ topic.num_votes }}</p> <p>Votes: {{ topic.num_votes }}</p>
<p>Comments: {{ topic.num_comments }}</p> <p>Comments: {{ topic.num_comments }}</p>
]]></description> ]]></description>
<author>{{ topic.user.username }}</author> <author>{{ topic.user.username }}</author>
<comments>{{ topic.permalink }}</comments>
<comments>{{ topic.permalink_absolute }}</comments>
<pubDate>{{ topic.created_time.strftime("%a, %d %b %Y %T %z") }}</pubDate> <pubDate>{{ topic.created_time.strftime("%a, %d %b %Y %T %z") }}</pubDate>
</item> </item>
{% endfor %} {% endfor %}

Loading…
Cancel
Save