From b4609b88c67b4eb5f1d5f31bd5b3bfe2d36c1399 Mon Sep 17 00:00:00 2001 From: tiyn Date: Mon, 1 Aug 2022 00:15:27 +0200 Subject: [PATCH] src: star rating added, links are now with url_for --- README.md | 1 + src/app.py | 6 ++-- src/content.py | 78 +++++++++++++++++++++++++------------------ src/templates/rss.xml | 6 ++-- 4 files changed, 52 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index be9ca65..d258385 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The blog is intended to be used to review and critique things. - [x] Login - [x] Logout - [x] Register + - [ ] User Page - [ ] Review blog entries - [x] Writing entries - [ ] Editing entries diff --git a/src/app.py b/src/app.py index 58e951e..24901fc 100644 --- a/src/app.py +++ b/src/app.py @@ -64,10 +64,8 @@ def entry(ident): def feed(): content = con_gen.get_rss_string() rss_xml = render_template("rss.xml", content_string=content, title=TITLE, - description=DESCRIPTION, website=WEBSITE) - response = make_response(rss_xml) - response.headers["Content-Type"] = "application/rss+xml" - return response + description=DESCRIPTION) + return rss_xml @login.user_loader diff --git a/src/content.py b/src/content.py index 89552ee..6adef1a 100644 --- a/src/content.py +++ b/src/content.py @@ -1,15 +1,33 @@ +from flask import url_for + import config from database import Database db = Database() +def rating_to_star(rating): + """ + Creates a string with stars based on the rating. + + Parameters: + rating: rating with minimum of 0 and maximum of 100. + + Returns: + string: unicode-formatted star-rating string. + """ + res = u"\u272D"*int(rating/20) + if rating/20 % 1 >= 0.5: + res += u"\u00BD" + return res + + def gen_arch_string(): """ Creates and returns a archive string of every file in ENTRY_DIR. Returns: - string: html-formatted archive-string + string: html-formatted archive-string. """ content_string = "" last_year = "" @@ -29,11 +47,11 @@ def gen_arch_string(): content_string += "