diff --git a/freepost/__init__.py b/freepost/__init__.py index 27ab976..9aeb8f8 100755 --- a/freepost/__init__.py +++ b/freepost/__init__.py @@ -851,6 +851,23 @@ def rss (sorting): return template ('rss.xml', base_url=base_url, posts=posts) +@get ('/rss_comments', name='rss_comments') +def rss_comments (): + """ + Output an RSS feed of the latest comments. + """ + + # Retrieve the hostname from the HTTP request. + # This is used to build absolute URLs in the RSS feed. + base_url = request.urlparts.scheme + '://' + request.urlparts.netloc + + comments = database.get_latest_comments () + + # Set correct Content-Type header for this RSS feed + response.content_type = 'application/rss+xml; charset=UTF-8' + + return template ('rss_comments.xml', base_url=base_url, comments=comments) + @get ('/', name='static') def static (filename): """ diff --git a/freepost/database.py b/freepost/database.py index 74b5759..426fa11 100644 --- a/freepost/database.py +++ b/freepost/database.py @@ -508,6 +508,29 @@ def get_comment (hash_id, session_user_id = None): return cursor.fetchone () +# Retrieve last N newest comments +def get_latest_comments (): + cursor = db.cursor (MySQLdb.cursors.DictCursor) + + cursor.execute ( + """ + SELECT + C.*, + P.hashId AS postHashId, + P.title AS postTitle, + U.username + FROM comment AS C + JOIN user AS U ON C.userId = U.id + JOIN post AS P ON P.id = C.postId + ORDER BY C.id DESC + LIMIT 50 + """, + { + } + ) + + return cursor.fetchall () + # Update a comment def update_comment (text, comment_hash_id, user_id): cursor = db.cursor (MySQLdb.cursors.DictCursor) diff --git a/freepost/templates/banner.html b/freepost/templates/banner.html index 1008ce4..b18df14 100644 --- a/freepost/templates/banner.html +++ b/freepost/templates/banner.html @@ -30,3 +30,19 @@ |_____|\___/|_| /_/ #} + +{# Peers Jam #} +{% set datetime = now() %} +{% if datetime.isoweekday() == 5 and datetime['hour'] >= 19 and datetime['hour'] <= 21 %} +
+ + Peers Jam +
+{% endif %} + + + + + + + diff --git a/freepost/templates/layout.html b/freepost/templates/layout.html index ee15dee..163382b 100644 --- a/freepost/templates/layout.html +++ b/freepost/templates/layout.html @@ -113,7 +113,8 @@
  • RSS Hot • - New + New • + Comments
  • Source diff --git a/freepost/templates/login.html b/freepost/templates/login.html index 905f0a2..0823f82 100755 --- a/freepost/templates/login.html +++ b/freepost/templates/login.html @@ -16,7 +16,7 @@
    - +
    diff --git a/freepost/templates/posts.html b/freepost/templates/posts.html index ae714d7..5871745 100644 --- a/freepost/templates/posts.html +++ b/freepost/templates/posts.html @@ -87,6 +87,15 @@ class="button button_default1"> Previous + + {% if page_number > 4 %} + + {% endif %} {% endif %} @@ -106,6 +115,12 @@ +