Browse Source

Update feeds to have absolute permalinks

merge-requests/127/merge
Deimos 3 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 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
def is_text_type(self) -> bool:
"""Return whether this is a text topic."""

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

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

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

@ -15,7 +15,7 @@
{% if topic.is_link_type %}
<link>{{ topic.link }}</link>
{% else %}
<link>{{ topic.permalink }}</link>
<link>{{ topic.permalink_absolute }}</link>
{% endif %}
<description><![CDATA[
{% if topic.is_link_type %}
@ -24,12 +24,12 @@
{{ topic.rendered_html|safe }}
<hr/>
{% 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>Comments: {{ topic.num_comments }}</p>
]]></description>
<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>
</item>
{% endfor %}

Loading…
Cancel
Save