forked from tanner/qotnews
feat: Render homepage feed server-side
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -175,12 +175,19 @@ def story(sid):
|
|||||||
@flask_app.route('/')
|
@flask_app.route('/')
|
||||||
@flask_app.route('/search')
|
@flask_app.route('/search')
|
||||||
def index():
|
def index():
|
||||||
|
stories_json = database.get_stories(settings.FEED_LENGTH, 0)
|
||||||
|
stories = [json.loads(s) for s in stories_json]
|
||||||
|
for s in stories:
|
||||||
|
url = urlparse(s.get('url') or s.get('link') or '').hostname or ''
|
||||||
|
s['hostname'] = url.replace('www.', '')
|
||||||
|
|
||||||
return render_template('index.html',
|
return render_template('index.html',
|
||||||
title='QotNews',
|
title='QotNews',
|
||||||
url='news.t0.vc',
|
url='news.t0.vc',
|
||||||
description='Hacker News, Reddit, Lobsters, and Tildes articles rendered in reader mode',
|
description='Hacker News, Reddit, Lobsters, and Tildes articles rendered in reader mode',
|
||||||
robots='index',
|
robots='index',
|
||||||
css_file=css_file,
|
css_file=css_file,
|
||||||
|
stories=stories,
|
||||||
)
|
)
|
||||||
|
|
||||||
@flask_app.route('/<sid>', strict_slashes=False)
|
@flask_app.route('/<sid>', strict_slashes=False)
|
||||||
|
|||||||
@@ -108,6 +108,30 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% elif stories %}
|
||||||
|
<div class="container">
|
||||||
|
{% for story in stories %}
|
||||||
|
<div class='item'>
|
||||||
|
<div class='title'>
|
||||||
|
<a class='link' href='/{{ story.id }}'>
|
||||||
|
<img class='source-logo' src='/logos/{{ story.source }}.png' alt='source logo' /> {{ story.title }}
|
||||||
|
</a>
|
||||||
|
<span class='source'>
|
||||||
|
(<a class='source' href='{{ story.url or story.link }}'>{{ story.hostname }}</a>)
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class='info'>
|
||||||
|
{{ story.score }} points
|
||||||
|
by <a href="{{ story.author_link }}">{{ story.author }}</a>
|
||||||
|
​ {{ story.date | fromnow }}
|
||||||
|
​ on <a href="{{ story.link }}">{{ story.source }}</a> | ​
|
||||||
|
<a class="{{ 'hot' if story.num_comments > 99 else '' }}" href="/{{ story.id }}/c">
|
||||||
|
{{ story.num_comments }} comment{{ 's' if story.num_comments != 1 }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
Reference in New Issue
Block a user