switch HTML feed to template

for #265
pull/292/head
Ryan Barrett 2022-11-17 07:58:08 -08:00
rodzic 4e0fb6536c
commit dbf4712af4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 30 dodań i 12 usunięć

Wyświetl plik

@ -113,7 +113,7 @@ def following(domain):
def feed(domain):
format = request.args.get('format', 'html')
if format not in ('html', 'atom', 'rss'):
error(f'format {format} not supported; expected html, atom, or rss')
error(f'format {format} not supported; expected html, atom, or rss')
as2_activities, _, _ = Activity.query(
Activity.domain == domain, Activity.direction == 'in'
@ -130,21 +130,18 @@ def feed(domain):
'url': f'https://{domain}',
}
title = f'Bridgy Fed feed for {domain}'
extra = '<link rel="stylesheet" href="/static/feed.css" type="text/css" />'
if not as1_activities:
extra += '\n<p>Nothing yet. Follow more people, check back soon!</p>'
if format == 'html':
return microformats2.activities_to_html(as1_activities, extra=extra,
body_class='h-feed')
entries = [microformats2.object_to_html(a) for a in as1_activities]
return render_template('feed.html', **locals())
elif format == 'atom':
body = atom.activities_to_atom(as1_activities, actor=actor, title=title,
request_url=request.url)
return body, {'Content-Type': atom.CONTENT_TYPE}
body = atom.activities_to_atom(as1_activities, actor=actor, title=title,
request_url=request.url)
return body, {'Content-Type': atom.CONTENT_TYPE}
elif format == 'rss':
body = rss.from_activities(as1_activities, actor=actor, title=title,
feed_url=request.url)
return body, {'Content-Type': rss.CONTENT_TYPE}
body = rss.from_activities(as1_activities, actor=actor, title=title,
feed_url=request.url)
return body, {'Content-Type': rss.CONTENT_TYPE}
@app.get('/responses') # deprecated

Wyświetl plik

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block title %}{{ domain }}'s feed - Bridgy Fed{% endblock %}
{% block content %}
<h2 class="row">
<a href="/user/{{ domain }}">🌐 {{ domain }}</a>'s feed
</h2>
<br>
<link rel="stylesheet" href="/static/feed.css" type="text/css" />
<div class="row h-feed">
{% for e in entries %}
{{ e|safe }}
{% else %}
Nothing yet. <a href="/#To+use+it">Follow more people</a>, check back soon!
{% endfor %}
</div>
{% endblock %}