Update feeds to have absolute permalinks

This commit is contained in:
Deimos
2021-02-27 14:11:59 -07:00
parent a021b96bc7
commit 5093fca18e
3 changed files with 11 additions and 6 deletions

View File

@@ -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."""

View File

@@ -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>

View File

@@ -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 %}