diff options
Diffstat (limited to 'apioforum/forum.py')
-rw-r--r-- | apioforum/forum.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py index 81674a8..92e981c 100644 --- a/apioforum/forum.py +++ b/apioforum/forum.py @@ -3,10 +3,11 @@ from flask import ( Blueprint, render_template, request, - g, redirect, url_for, flash + g, redirect, url_for, flash, Response ) from .db import get_db from .mdrender import render +from .thread import post_jump bp = Blueprint("forum", __name__, url_prefix="/") @@ -77,4 +78,12 @@ def search(): display_thread_id[ix] = False last_thread = result["thread"] rendered_posts = [render(q['content']) for q in results] - return render_template("search_results.html", results=results, query=query, rendered_posts=rendered_posts, display_thread_id=display_thread_id)
\ No newline at end of file + return render_template("search_results.html", results=results, query=query, rendered_posts=rendered_posts, display_thread_id=display_thread_id) + +@bp.route("/rss") +def rss_feed(): + db = get_db() + print(request.host_url) + items = db.execute("SELECT * FROM posts ORDER BY updated DESC LIMIT 50") + items = [ { **item, "rendered": render(item["content"]), "link": request.base_url + post_jump(item["thread"], item["id"]), "updated": item["updated"] or item["created"] } for item in items ] + return Response(render_template("rss.xml", title="New posts feed", description="The latest posts on the Apioforum", link=request.base_url, items=items), mimetype="text/xml")
\ No newline at end of file |