From c9c6db89a10e331d3df9f1a60b5c3ea89b1e7c59 Mon Sep 17 00:00:00 2001 From: jwansek Date: Wed, 25 Jan 2023 16:56:29 +0000 Subject: Added yaoi on sidebar --- app.py | 16 ++++++++++++++-- database.py | 9 ++++++++- requirements.txt | 2 +- static/images/1544552064683.jpg | Bin 0 -> 171824 bytes static/images/1549844950404.jpg | Bin 0 -> 112071 bytes static/images/1555824429083.png | Bin 0 -> 170252 bytes static/images/1555824491105.png | Bin 0 -> 177365 bytes .../324162a23865a6a7e75761871d29935314cbc2b3.jpg | Bin 0 -> 531668 bytes ...sample_ede336afca555579dd78f051e4a23feaa838716d.jpg | Bin 0 -> 185850 bytes static/index.md | 2 +- static/sidebar_images/1544552064683.jpg | Bin 171824 -> 0 bytes static/sidebar_images/1549844950404.jpg | Bin 112071 -> 0 bytes static/sidebar_images/1555824429083.png | Bin 170252 -> 0 bytes static/sidebar_images/1555824491105.png | Bin 177365 -> 0 bytes .../324162a23865a6a7e75761871d29935314cbc2b3.jpg | Bin 531668 -> 0 bytes ...sample_ede336afca555579dd78f051e4a23feaa838716d.jpg | Bin 185850 -> 0 bytes templates/index.html.j2 | 1 + 17 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 static/images/1544552064683.jpg create mode 100644 static/images/1549844950404.jpg create mode 100644 static/images/1555824429083.png create mode 100644 static/images/1555824491105.png create mode 100644 static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg create mode 100644 static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg delete mode 100644 static/sidebar_images/1544552064683.jpg delete mode 100644 static/sidebar_images/1549844950404.jpg delete mode 100644 static/sidebar_images/1555824429083.png delete mode 100644 static/sidebar_images/1555824491105.png delete mode 100644 static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg delete mode 100644 static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg diff --git a/app.py b/app.py index 66d7f55..75558f8 100755 --- a/app.py +++ b/app.py @@ -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') diff --git a/database.py b/database.py index 272e39e..cf51922 100755 --- a/database.py +++ b/database.py @@ -55,6 +55,11 @@ class Database: cursor.execute("SELECT alt, url FROM images WHERE pfp_img = 1;") return cursor.fetchall() + def get_sidebar_images(self): + with self.__connection.cursor() as cursor: + cursor.execute("SELECT alt, url FROM images WHERE sidebar_image = 1;") + return cursor.fetchall() + def get_header_articles(self): with self.__connection.cursor() as cursor: cursor.execute("SELECT articleName, link FROM headerArticles;") @@ -350,5 +355,7 @@ def request_recent_commits(since = datetime.datetime.now() - datetime.timedelta( if __name__ == "__main__": + import app with Database() as db: - print(db.fetch_diary()) + print(app.get_sidebar_img(db)) + # print(db.get_sidebar_images()) diff --git a/requirements.txt b/requirements.txt index 7aee926..2f0d2db 100755 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ transmission-clutch dataclasses docker PiHole-api -Pillow==8.1.0 +Pillow==9.4.0 python-qbittorrent==0.4.2 PyGithub lxml diff --git a/static/images/1544552064683.jpg b/static/images/1544552064683.jpg new file mode 100644 index 0000000..20a6527 Binary files /dev/null and b/static/images/1544552064683.jpg differ diff --git a/static/images/1549844950404.jpg b/static/images/1549844950404.jpg new file mode 100644 index 0000000..5197c11 Binary files /dev/null and b/static/images/1549844950404.jpg differ diff --git a/static/images/1555824429083.png b/static/images/1555824429083.png new file mode 100644 index 0000000..5b2fd0b Binary files /dev/null and b/static/images/1555824429083.png differ diff --git a/static/images/1555824491105.png b/static/images/1555824491105.png new file mode 100644 index 0000000..2e20fca Binary files /dev/null and b/static/images/1555824491105.png differ diff --git a/static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg b/static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg new file mode 100644 index 0000000..cede48f Binary files /dev/null and b/static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg differ diff --git a/static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg b/static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg new file mode 100644 index 0000000..b146bc4 Binary files /dev/null and b/static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg differ diff --git a/static/index.md b/static/index.md index 945beff..6e8a1db 100755 --- a/static/index.md +++ b/static/index.md @@ -2,7 +2,7 @@ ## haiiiiiii my name is eden and im a 21yo (boymoder) computer science undergraduate. i made my own website to encourage others to do so too. -i'll post my thoughts on here sometimes, and use this site to link to other stuff i host. +i'll post my thoughts on here sometimes, and use this site to link to other stuff i host [more about me](/thought?id=2). [click here for a random image of lio fotia](https://eda.gay/random?tags=lio_fotia) diff --git a/static/sidebar_images/1544552064683.jpg b/static/sidebar_images/1544552064683.jpg deleted file mode 100644 index 20a6527..0000000 Binary files a/static/sidebar_images/1544552064683.jpg and /dev/null differ diff --git a/static/sidebar_images/1549844950404.jpg b/static/sidebar_images/1549844950404.jpg deleted file mode 100644 index 5197c11..0000000 Binary files a/static/sidebar_images/1549844950404.jpg and /dev/null differ diff --git a/static/sidebar_images/1555824429083.png b/static/sidebar_images/1555824429083.png deleted file mode 100644 index 5b2fd0b..0000000 Binary files a/static/sidebar_images/1555824429083.png and /dev/null differ diff --git a/static/sidebar_images/1555824491105.png b/static/sidebar_images/1555824491105.png deleted file mode 100644 index 2e20fca..0000000 Binary files a/static/sidebar_images/1555824491105.png and /dev/null differ diff --git a/static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg b/static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg deleted file mode 100644 index cede48f..0000000 Binary files a/static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg and /dev/null differ diff --git a/static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg b/static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg deleted file mode 100644 index b146bc4..0000000 Binary files a/static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg and /dev/null differ diff --git a/templates/index.html.j2 b/templates/index.html.j2 index 72bff7b..e0aede9 100755 --- a/templates/index.html.j2 +++ b/templates/index.html.j2 @@ -9,6 +9,7 @@ {% endfor %} + {{sidebar_img[0]}} {{markdown|safe}} {% if tweets != None %} -- cgit v1.2.3