aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app.py19
-rw-r--r--compose.yml3
-rw-r--r--templates/gallery.html25
3 files changed, 38 insertions, 9 deletions
diff --git a/app.py b/app.py
index 6f0e7cc..0de55f2 100644
--- a/app.py
+++ b/app.py
@@ -1,6 +1,7 @@
import os
import threading
import time
+from flask.helpers import url_for
import requests
import re
import sqlite3
@@ -21,8 +22,9 @@ PORT = int(os.environ.get("PORT", 5000))
THUMBNAIL_DIR = "thumbnails"
DB_FILE = "data/sqlite.db"
ISO_DATE_REGEX = re.compile(r"^\d{4}-\d{2}-\d{2}")
-TITLE = os.environ.get("TITLE", "Gallery")
+AUTHOR = os.environ["AUTHOR"]
IG_LINK = os.environ.get("IG_LINK", None)
+BASE_URL = os.environ["BASE_URL"]
# Setup
os.makedirs(THUMBNAIL_DIR, exist_ok=True)
@@ -148,8 +150,21 @@ def gallery():
})
sorted_dates = sorted(grouped.keys(), reverse=True)
+
+ if len(files) > 0:
+ cover_img_path = url_for("serve_thumbnail", filename=files[0][4].split('/')[-1])
+ cover_img_url = BASE_URL + cover_img_path
+ else:
+ cover_img_url = None
+
return render_template("gallery.html",
- grouped=grouped, dates=sorted_dates, title=TITLE, ig_link=IG_LINK)
+ grouped=grouped,
+ dates=sorted_dates,
+ author=AUTHOR,
+ ig_link=IG_LINK,
+ cover_img_url=cover_img_url,
+ base_url=BASE_URL,
+ )
@app.route("/thumbnails/<filename>")
def serve_thumbnail(filename):
diff --git a/compose.yml b/compose.yml
index 7480e9b..f8cc5a2 100644
--- a/compose.yml
+++ b/compose.yml
@@ -7,7 +7,8 @@ services:
PYTHONUNBUFFERED: 1
GDRIVE_FOLDER: ${GDRIVE_FOLDER}
GAPI_KEY: ${GAPI_KEY}
- TITLE: ${TITLE}
+ AUTHOR: ${AUTHOR}
+ BASE_URL: ${BASE_URL}
volumes:
- ./data:/app/data
- ./thumbnails:/app/thumbnails
diff --git a/templates/gallery.html b/templates/gallery.html
index 70f5d25..b5447e2 100644
--- a/templates/gallery.html
+++ b/templates/gallery.html
@@ -1,14 +1,26 @@
<!doctype html>
-<html>
+<html lang="en">
<head>
- <title>{{ title }}</title>
+ <meta charset="UTF-8" />
<link
rel="stylesheet"
href="{{ url_for('static', filename='style.css') }}"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
- </head>
- <body>
+ <meta
+ name="description"
+ content="A photography portfolio by {{ author }}."
+ />
+ <meta name="keywords" content="photography, portfolio, gallery" />
+ <meta name="author" content="{{ author }}" />
+ <meta property="og:title" content="{{ author }}" />
+ <meta
+ property="og:description"
+ content="A photography portfolio by {{ author }}."
+ />
+ <meta property="og:image" content="{{ cover_img_url }}" />
+ <meta property="og:url" content="{{ base_url }}" />
+ <meta property="og:type" content="website" />
<script>
function layout() {
const isMobile =
@@ -39,9 +51,10 @@
document.addEventListener("DOMContentLoaded", layout);
window.addEventListener("resize", layout);
</script>
-
+ </head>
+ <body>
<h1>
- {{ title }} {% if ig_link %}
+ {{ author }} {% if ig_link %}
<a href="{{ ig_link }}" target="_blank" class="ig-link">
<img
src="{{ url_for('static', filename='ig.svg') }}"