diff options
-rwxr-xr-x | app.py | 16 | ||||
-rwxr-xr-x | database.py | 9 | ||||
-rwxr-xr-x | requirements.txt | 2 | ||||
-rw-r--r-- | static/images/1544552064683.jpg (renamed from static/sidebar_images/1544552064683.jpg) | bin | 171824 -> 171824 bytes | |||
-rw-r--r-- | static/images/1549844950404.jpg (renamed from static/sidebar_images/1549844950404.jpg) | bin | 112071 -> 112071 bytes | |||
-rw-r--r-- | static/images/1555824429083.png (renamed from static/sidebar_images/1555824429083.png) | bin | 170252 -> 170252 bytes | |||
-rw-r--r-- | static/images/1555824491105.png (renamed from static/sidebar_images/1555824491105.png) | bin | 177365 -> 177365 bytes | |||
-rw-r--r-- | static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg (renamed from static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg) | bin | 531668 -> 531668 bytes | |||
-rw-r--r-- | static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg (renamed from static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg) | bin | 185850 -> 185850 bytes | |||
-rwxr-xr-x | static/index.md | 2 | ||||
-rwxr-xr-x | templates/index.html.j2 | 1 |
11 files changed, 25 insertions, 5 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') 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/sidebar_images/1544552064683.jpg b/static/images/1544552064683.jpg Binary files differindex 20a6527..20a6527 100644 --- a/static/sidebar_images/1544552064683.jpg +++ b/static/images/1544552064683.jpg diff --git a/static/sidebar_images/1549844950404.jpg b/static/images/1549844950404.jpg Binary files differindex 5197c11..5197c11 100644 --- a/static/sidebar_images/1549844950404.jpg +++ b/static/images/1549844950404.jpg diff --git a/static/sidebar_images/1555824429083.png b/static/images/1555824429083.png Binary files differindex 5b2fd0b..5b2fd0b 100644 --- a/static/sidebar_images/1555824429083.png +++ b/static/images/1555824429083.png diff --git a/static/sidebar_images/1555824491105.png b/static/images/1555824491105.png Binary files differindex 2e20fca..2e20fca 100644 --- a/static/sidebar_images/1555824491105.png +++ b/static/images/1555824491105.png diff --git a/static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg b/static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg Binary files differindex cede48f..cede48f 100644 --- a/static/sidebar_images/324162a23865a6a7e75761871d29935314cbc2b3.jpg +++ b/static/images/324162a23865a6a7e75761871d29935314cbc2b3.jpg diff --git a/static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg b/static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg Binary files differindex b146bc4..b146bc4 100644 --- a/static/sidebar_images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg +++ b/static/images/sample_ede336afca555579dd78f051e4a23feaa838716d.jpg 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/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 %} </ul> </section> + <img id="sidebar_img" alt="{{sidebar_img[0]}}" src="{{sidebar_img[1]}}"> </aside> {{markdown|safe}} {% if tweets != None %} |