diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2023-01-25 16:56:29 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2023-01-25 16:56:29 +0000 |
commit | c9c6db89a10e331d3df9f1a60b5c3ea89b1e7c59 (patch) | |
tree | abb16b2853f843b8f62050bc673a2e31afd94567 /app.py | |
parent | e0580829876fb40855c2500135127c9970ba7769 (diff) | |
download | eda.gay-c9c6db89a10e331d3df9f1a60b5c3ea89b1e7c59.tar.gz eda.gay-c9c6db89a10e331d3df9f1a60b5c3ea89b1e7c59.zip |
Added yaoi on sidebar
Diffstat (limited to 'app.py')
-rwxr-xr-x | app.py | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -19,6 +19,7 @@ app = flask.Flask(__name__) CONFIG = configparser.ConfigParser(interpolation = None) CONFIG.read("edaweb.conf") shown_images = set() +shown_sidebar_images = set() def get_pfp_img(db:database.Database): global shown_images @@ -30,6 +31,16 @@ def get_pfp_img(db:database.Database): shown_images.add(choice) return choice +def get_sidebar_img(db:database.Database): + global shown_sidebar_images + dbimg = db.get_sidebar_images() + if len(shown_sidebar_images) == len(dbimg): + shown_sidebar_images = set() + folder = set(dbimg).difference(shown_sidebar_images) + choice = random.choice(list(folder)) + shown_sidebar_images.add(choice) + return choice + def get_correct_article_headers(db:database.Database, title): db_headers = list(db.get_header_articles()) if title in [i[0] for i in db_headers]: @@ -60,7 +71,8 @@ def index(): markdown = parser.parse_text(f.read())[0], featured_thoughts = db.get_featured_thoughts(), tweets = db.get_cached_tweets(7) + [("view all tweets...", db.get_my_twitter())], - commits = db.get_cached_commits(since = datetime.datetime.now() - datetime.timedelta(days = 7)) + commits = db.get_cached_commits(since = datetime.datetime.now() - datetime.timedelta(days = 7)), + sidebar_img = get_sidebar_img(db) ) @app.route("/robots.txt") @@ -145,7 +157,7 @@ def serve_image(filename): return flask.send_from_directory(imdirpath, filename) img = Image.open(os.path.join(imdirpath, filename)) - img.thumbnail((w, h), Image.ANTIALIAS) + img.thumbnail((w, h), Image.LANCZOS) io_ = io.BytesIO() img.save(io_, format='JPEG') return flask.Response(io_.getvalue(), mimetype='image/jpeg') |