From 52d83fafa68d2ea0b20d414af252d9b368e978d4 Mon Sep 17 00:00:00 2001 From: Flo Greistorfer Date: Wed, 10 Jul 2024 08:12:37 +0200 Subject: [PATCH] now checking url with regex --- builder.py | 6 ++- files/pswp/photoswipe.css | 84 ++++++++++++++++++++++++++------------- templates/index.html.j2 | 7 +++- 3 files changed, 67 insertions(+), 30 deletions(-) diff --git a/builder.py b/builder.py index e113d4a..a2f9b93 100755 --- a/builder.py +++ b/builder.py @@ -31,7 +31,7 @@ FAVICON_PATH = ".static/favicon.ico" GLOBAL_CSS_PATH = ".static/global.css" DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "themes", "default.css") DEFAULT_AUTHOR = "Author" -VERSION = "1.9.12" +VERSION = "1.9.13" RAW_EXTENSIONS = [".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"] IMG_EXTENSIONS = [".jpg", ".jpeg"] EXCLUDES = [".lock", "index.html", "manifest.json", ".sizelist.json", ".thumbnails", ".static"] @@ -321,6 +321,8 @@ def list_folder(folder: str, title: str, _args: Args, raw: list[str]) -> None: sizelistfile.seek(0) sizelistfile.write(json.dumps(sizelist, indent=4)) sizelistfile.truncate() + if os.path.exists(os.path.join(folder, ".sizelist.json")) and sizelist == {}: + os.remove(os.path.join(folder, ".sizelist.json")) if not contains_files and not _args.use_fancy_folders: return if images or (_args.use_fancy_folders and not contains_files) or (_args.use_fancy_folders and _args.ignore_other_files): @@ -370,6 +372,8 @@ def list_folder(folder: str, title: str, _args: Args, raw: list[str]) -> None: else: if os.path.exists(os.path.join(folder, "index.html")): os.remove(os.path.join(folder, "index.html")) + if os.path.exists(os.path.join(folder, ".sizelist.json")): + os.remove(os.path.join(folder, ".sizelist.json")) if not _args.non_interactive_mode: pbardict["htmlbar"].update(1) diff --git a/files/pswp/photoswipe.css b/files/pswp/photoswipe.css index 3bf3b40..e83dc3e 100644 --- a/files/pswp/photoswipe.css +++ b/files/pswp/photoswipe.css @@ -15,14 +15,21 @@ touch-action: none; z-index: 1500; -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; /* create separate layer, to avoid paint on window.onscroll in webkit/blink */ -webkit-backface-visibility: hidden; - outline: none; } - .pswp * { - -webkit-box-sizing: border-box; - box-sizing: border-box; } - .pswp img { - max-width: none; } + backface-visibility: hidden; + outline: none; +} + +.pswp * { + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.pswp img { + max-width: none; +} /* style is added when JS option showHideOpacity is set to true */ .pswp--animate_opacity { @@ -31,28 +38,33 @@ will-change: opacity; /* for open/close transition */ -webkit-transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); - transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); } + transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); +} .pswp--open { - display: block; } + display: block; +} .pswp--zoom-allowed .pswp__img { /* autoprefixer: off */ cursor: -webkit-zoom-in; cursor: -moz-zoom-in; - cursor: zoom-in; } + cursor: zoom-in; +} .pswp--zoomed-in .pswp__img { /* autoprefixer: off */ cursor: -webkit-grab; cursor: -moz-grab; - cursor: grab; } + cursor: grab; +} .pswp--dragging .pswp__img { /* autoprefixer: off */ cursor: -webkit-grabbing; cursor: -moz-grabbing; - cursor: grabbing; } + cursor: grabbing; +} /* Background is added as a separate element. @@ -67,7 +79,9 @@ background: #000; opacity: 0; -webkit-backface-visibility: hidden; - will-change: opacity; } + backface-visibility: hidden; + will-change: opacity; +} .pswp__scroll-wrap { position: absolute; @@ -75,7 +89,8 @@ top: 0; width: 100%; height: 100%; - overflow: hidden; } + overflow: hidden; +} .pswp__container, .pswp__zoom-wrap { @@ -85,7 +100,8 @@ left: 0; right: 0; top: 0; - bottom: 0; } + bottom: 0; +} /* Prevent selection and tap highlights */ .pswp__container, @@ -93,9 +109,10 @@ -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; - user-select: none; + user-select: none; -webkit-tap-highlight-color: transparent; - -webkit-touch-callout: none; } + -webkit-touch-callout: none; +} .pswp__zoom-wrap { position: absolute; @@ -105,22 +122,27 @@ transform-origin: left top; /* for open/close transition */ -webkit-transition: -webkit-transform 333ms cubic-bezier(0.4, 0, 0.22, 1); - transition: transform 333ms cubic-bezier(0.4, 0, 0.22, 1); } + transition: transform 333ms cubic-bezier(0.4, 0, 0.22, 1); +} .pswp__bg { will-change: opacity; /* for open/close transition */ -webkit-transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); - transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); } + transition: opacity 333ms cubic-bezier(0.4, 0, 0.22, 1); +} .pswp--animated-in .pswp__bg, .pswp--animated-in .pswp__zoom-wrap { -webkit-transition: none; - transition: none; } + transition: none; +} .pswp__container, .pswp__zoom-wrap { - -webkit-backface-visibility: hidden; } + -webkit-backface-visibility: hidden; + backface-visibility: hidden; +} .pswp__item { position: absolute; @@ -128,34 +150,40 @@ right: 0; top: 0; bottom: 0; - overflow: hidden; } + overflow: hidden; +} .pswp__img { position: absolute; width: auto; height: auto; top: 0; - left: 0; } + left: 0; +} /* stretched thumbnail or div placeholder element (see below) style is added to avoid flickering in webkit/blink when layers overlap */ .pswp__img--placeholder { - -webkit-backface-visibility: hidden; } + -webkit-backface-visibility: hidden; + backface-visibility: hidden; +} /* div element that matches size of large image large image loads on top of it */ .pswp__img--placeholder--blank { - background: #222; } + background: #222; +} .pswp--ie .pswp__img { width: 100% !important; height: auto !important; left: 0; - top: 0; } + top: 0; +} /* Error message appears when image is not loaded @@ -170,8 +198,10 @@ font-size: 14px; line-height: 16px; margin-top: -8px; - color: #CCC; } + color: #CCC; +} .pswp__error-msg a { color: #CCC; - text-decoration: underline; } + text-decoration: underline; +} \ No newline at end of file diff --git a/templates/index.html.j2 b/templates/index.html.j2 index 71a585b..380db23 100644 --- a/templates/index.html.j2 +++ b/templates/index.html.j2 @@ -146,6 +146,8 @@ { src: "{{ image.url }}", w: {{ image.width }}, h: {{ image.height }}, msrc: "{{ image.thumbnail }}" }, {%- endfor %} ]; + var re = /pid=(\d+)/; + function openSwipe(img) { // define options (if needed) var options = { @@ -155,8 +157,9 @@ var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); gallery.init(); } - if (window.location.href.indexOf("pid=") > -1) { - var pid = window.location.href.split('pid=')[1].split('#')[0]; + + if (re.test(window.location.href)) { + var pid = window.location.href.match(re)[1]; openSwipe(parseInt(pid)); }