From 544d6c866c21aa25dafdae0c21ca6579743bce6a Mon Sep 17 00:00:00 2001 From: Yannis4444 Date: Mon, 22 Jun 2026 23:36:20 +0200 Subject: [PATCH] added video support --- .gitmodules | 3 + Dockerfile | 21 ++++-- assets/css/custom.css | 24 +++++++ content/standesamt/index.md | 4 ++ hugo.toml | 2 +- scripts/add-video-posters.py | 128 +++++++++++++++++++++++++++++++++++ themes/hugo-video | 1 + 7 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 scripts/add-video-posters.py create mode 160000 themes/hugo-video diff --git a/.gitmodules b/.gitmodules index 9b68069..667dd9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "themes/gallery"] path = themes/gallery url = https://github.com/nicokaiser/hugo-theme-gallery.git +[submodule "themes/hugo-video"] + path = themes/hugo-video + url = https://github.com/martignoni/hugo-video.git diff --git a/Dockerfile b/Dockerfile index bc5ce58..cb01dc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,32 @@ FROM hugomods/hugo:exts AS builder WORKDIR /src + COPY archetypes/ archetypes/ -COPY assets/ assets/ -COPY content/ content/ +COPY themes/ themes/ COPY layouts/ layouts/ COPY static/ static/ -COPY themes/ themes/ +COPY assets/ assets/ +COPY content/ content/ COPY hugo.toml . + RUN hugo --gc --minify +FROM alpine:3.20 AS video-posters + +RUN apk add --no-cache python3 ffmpeg + +WORKDIR /src + +COPY --from=builder /src/public /src/public +COPY scripts/add-video-posters.py /add-video-posters.py + +RUN python3 /add-video-posters.py /src/public + FROM nginx:alpine RUN apk add --no-cache openssl -COPY --from=builder /src/public /usr/share/nginx/html +COPY --from=video-posters /src/public /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf COPY docker-entrypoint.sh /docker-entrypoint.sh diff --git a/assets/css/custom.css b/assets/css/custom.css index 26a191f..d659a54 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -278,6 +278,30 @@ section.galleries .card img:hover { opacity: 0.75; } +/* ── Videos ────────────────────────────────── */ + +.prose { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(500px, 1fr)); + border-top: 1px solid var(--border); + margin-left: 0; + margin-right: 0; + padding: 0; + padding-top: 4rem; + gap: 0.5rem; + max-width: unset !important; +} + +@media only screen and (max-width: 500px) { + .prose { + grid-template-columns: 1fr; + } +} + +.prose video { + background: #000; +} + /* ── Gallery back link ────────────────────────────────── */ .gallery-back { diff --git a/content/standesamt/index.md b/content/standesamt/index.md index 4f576c2..22b6d1c 100644 --- a/content/standesamt/index.md +++ b/content/standesamt/index.md @@ -7,3 +7,7 @@ resources: params: cover: true --- + +{{< video src="test.mp4" >}} + +{{< video src="test2.mp4" >}} diff --git a/hugo.toml b/hugo.toml index 5280008..8158363 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1,6 +1,6 @@ baseURL = "https://plassonke.de/" title = "Hochzeit" -theme = "gallery" +theme = ["hugo-video", "gallery"] defaultContentLanguage = "de" disableKinds = ["taxonomy"] enableRobotsTXT = true diff --git a/scripts/add-video-posters.py b/scripts/add-video-posters.py new file mode 100644 index 0000000..9756806 --- /dev/null +++ b/scripts/add-video-posters.py @@ -0,0 +1,128 @@ +from __future__ import annotations + +import re +import subprocess +import sys +from pathlib import Path +from urllib.parse import unquote + + +VIDEO_TAG_RE = re.compile( + r"[^>]*)>(?P.*?)", + re.IGNORECASE | re.DOTALL, + ) + +SOURCE_RE = re.compile( + r']+src=["\'](?P[^"\']+)["\'][^>]*>', + re.IGNORECASE, +) + + +def extract_src(video_attrs: str, video_body: str) -> str | None: + """Extract video path from either " + + new_content = VIDEO_TAG_RE.sub(replace_video, content) + + if changed: + html_file.write_text(new_content, encoding="utf-8") + print(f"Updated: {html_file}") + + +def main() -> None: + """Process all HTML files below the given root directory.""" + + root = Path(sys.argv[1]).resolve() + + for html_file in root.rglob("*.html"): + process_file(html_file, root) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/themes/hugo-video b/themes/hugo-video new file mode 160000 index 0000000..fb3686a --- /dev/null +++ b/themes/hugo-video @@ -0,0 +1 @@ +Subproject commit fb3686a0156541bd21196fdfb185fe2ebc5f189f