Skip to content

Commit

Permalink
Add tags to quotation, blogmark and entries in the atom feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 10, 2024
1 parent be50da8 commit 55dd5ef
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
25 changes: 24 additions & 1 deletion blog/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def item_title(self, item):
return item.title

def item_description(self, item):
return item.body
tags = ", ".join(
f'<a href="https://simonwillison.net/tags/{tag.tag}">{tag.tag}</a>'
for tag in item.tags.all()
)
return f"{item.body}<p>Tags: {tags}</p>"


class Blogmarks(Base):
Expand All @@ -62,6 +66,13 @@ def items(self):
def item_title(self, item):
return item.link_title

def item_description(self, item):
tags = ", ".join(
f'<a href="https://simonwillison.net/tags/{tag.tag}">{tag.tag}</a>'
for tag in item.tags.all()
)
return f"{item.commentary}<p>Tags: {tags}</p>"


class Everything(Base):
title = "Simon Willison's Weblog"
Expand Down Expand Up @@ -92,6 +103,18 @@ def item_title(self, item):
else:
return "Quoting %s" % item.source

def item_description(self, item):
tags = ", ".join(
f'<a href="https://simonwillison.net/tags/{tag.tag}">{tag.tag}</a>'
for tag in item.tags.all()
)
if isinstance(item, Entry):
return f"{item.body}<p>Tags: {tags}</p>"
elif isinstance(item, Blogmark):
return f"{item.commentary}<p>Tags: {tags}</p>"
else:
return f"{item.quotation}<p>Tags: {tags}</p>"


class SeriesFeed(Everything):
ga_source = "series"
Expand Down
3 changes: 3 additions & 0 deletions templates/feeds/blogmark.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
{% if obj.via_title %}
<p>Via <a href="{{ obj.via_url }}">{{ obj.via_title }}</a></p>
{% endif %}
{% if obj.tags.count %}
<p>Tags: {% for tag in obj.tags.all %}<a href="https://simonwillison.net/tags/{{ tag.tag }}">{{ tag.tag }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
{% endif %}
9 changes: 9 additions & 0 deletions templates/feeds/everything.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{% if obj.is_entry %}
{{ obj.body|safe }}
{% if obj.tags.count %}
<p>Tags: {% for tag in obj.tags.all %}<a href="https://simonwillison.net/tags/{{ tag.tag }}">{{ tag.tag }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
{% endif %}
{% elif obj.is_blogmark %}
{% include "feeds/blogmark.html" %}
{% if obj.tags.count %}
<p>Tags: {% for tag in obj.tags.all %}<a href="https://simonwillison.net/tags/{{ tag.tag }}">{{ tag.tag }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
{% endif %}
{% elif obj.is_quotation %}
{% include "feeds/quotation.html" %}
{% if obj.tags.count %}
<p>Tags: {% for tag in obj.tags.all %}<a href="https://simonwillison.net/tags/{{ tag.tag }}">{{ tag.tag }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
{% endif %}
{% endif %}
5 changes: 4 additions & 1 deletion templates/feeds/quotation.html
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<blockquote{% if obj.source_url %} cite="{{ obj.source_url }}"{% endif %}>{{ obj.body }}</blockquote><p class="cite">&mdash; {% if obj.source_url %}<a href="{{ obj.source_url }}">{{ obj.source }}</a>{% else %}{{ obj.source }}{% endif %}
<blockquote{% if obj.source_url %} cite="{{ obj.source_url }}"{% endif %}>{{ obj.body }}</blockquote><p class="cite">&mdash; {% if obj.source_url %}<a href="{{ obj.source_url }}">{{ obj.source }}</a>{% else %}{{ obj.source }}{% endif %}</p>
{% if obj.tags.count %}
<p>Tags: {% for tag in obj.tags.all %}<a href="https://simonwillison.net/tags/{{ tag.tag }}">{{ tag.tag }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
{% endif %}

0 comments on commit 55dd5ef

Please sign in to comment.