summaryrefslogtreecommitdiffhomepage
path: root/apioforum/forum.py
diff options
context:
space:
mode:
Diffstat (limited to 'apioforum/forum.py')
-rw-r--r--apioforum/forum.py27
1 files changed, 25 insertions, 2 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index 98c71f7..a7f4719 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -3,11 +3,12 @@
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="/")
@@ -87,4 +88,26 @@ 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)
+ 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")