re-add rss feeds

This commit is contained in:
2026-06-10 22:30:53 +03:00
parent 50c61da8b6
commit bf3028e7d6
9 changed files with 113 additions and 12 deletions

View File

@@ -1,8 +1,10 @@
from flask import Blueprint, redirect, url_for, render_template, request, abort
from flask import Blueprint, redirect, url_for, render_template, request, abort, current_app
from functools import wraps
from app import cache
from ..auth import login_required, get_active_user, is_logged_in
from ..db import db
from ..models import Threads, Posts, Topics, Users, Reactions, Subscriptions
from ..lib.render_atom import render_atom_template
from ..util import get_form_checkbox, time_now
import math
@@ -70,9 +72,23 @@ def thread(thread_id, slug):
posts=posts, page=page,
page_count=page_count, topic=topic,
started_by=started_by, topics=Topics.get_list(),
Reactions=Reactions, last_post=last_post
Reactions=Reactions, last_post=last_post,
__feedlink=url_for('.feed', thread_id=thread_id, _external=True),
__feedtitle=f'replies to {thread.title}',
)
@bp.get('/<int:thread_id>/feed.atom/')
@cache.cached(timeout=5 * 60, unless=lambda: current_app.config['DEBUG'])
def feed(thread_id):
thread = Threads.find({'id': thread_id})
if not thread:
abort(404)
topic = Topics.find({'id': thread.topic_id})
posts = thread.get_posts_rss()
return render_atom_template('threads/thread.atom', thread=thread, topic=topic, posts=posts)
@bp.post('/<int:thread_id>/')
@login_required
def reply(thread_id):
@@ -195,10 +211,6 @@ def mark_read():
return redirect(url_for('users.inbox', username=user.username))
@bp.get('/<int:thread_id>/feed.atom/')
def feed(thread_id):
return 'stub'
@bp.get('/new/')
@login_required
def new():