mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
idk if this cancels preload...
This commit is contained in:
@@ -187,7 +187,6 @@ def main() -> None:
|
||||
"""
|
||||
Main function to process images and generate a static image hosting website.
|
||||
"""
|
||||
logger.info("starting builder", extra={"version": VERSION})
|
||||
thumbnails: List[Tuple[str, str, str, bool]] = []
|
||||
|
||||
args = parse_arguments(VERSION)
|
||||
@@ -196,11 +195,11 @@ def main() -> None:
|
||||
lock_file = os.path.join(args.root_directory, ".lock")
|
||||
if os.path.exists(lock_file):
|
||||
print("Another instance of this program is running.")
|
||||
logger.error("another instance of this program is running")
|
||||
exit()
|
||||
|
||||
try:
|
||||
Path(lock_file).touch()
|
||||
logger.info("starting builder", extra={"version": VERSION})
|
||||
if args.reread_metadata:
|
||||
logger.warning("reread metadata flag is set to true, all image metadata will be reread")
|
||||
if args.regenerate_thumbnails:
|
||||
|
||||
@@ -11,8 +11,6 @@ except ModuleNotFoundError:
|
||||
RICH = False
|
||||
|
||||
|
||||
from modules.logger import logger
|
||||
|
||||
if __package__ is None:
|
||||
PACKAGE = ""
|
||||
else:
|
||||
@@ -146,5 +144,4 @@ def parse_arguments(version: str) -> Args:
|
||||
use_fancy_folders=parsed_args.use_fancy_folders,
|
||||
web_root_url=parsed_args.web_root_url,
|
||||
)
|
||||
logger.debug("parsed arguments", extra={"args": _args.to_dict()})
|
||||
return _args
|
||||
|
||||
@@ -117,7 +117,10 @@ def get_image_info(item: str, folder: str) -> Dict[str, Any]:
|
||||
if tag in ["DateTime", "DateTimeOriginal", "DateTimeDigitized"]:
|
||||
epr = r'\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}'
|
||||
if re.match(epr, content):
|
||||
content = datetime.strptime(content, "%Y:%m:%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
|
||||
try:
|
||||
content = datetime.strptime(content, "%Y:%m:%d %H:%M:%S").strftime("%Y-%m-%d %H:%M:%S")
|
||||
except ValueError:
|
||||
content = None
|
||||
else:
|
||||
content = None
|
||||
exifdata[tag] = content
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
{%- for image in images %}
|
||||
<div class="column">
|
||||
<figure>
|
||||
<img src="{{ image.thumbnail }}" alt="{{ image.name }}" onclick="openSwipe({{ ns.count }})" onmouseover="prefetch('{{ image.url }}')"/>
|
||||
<img src="{{ image.thumbnail }}" alt="{{ image.name }}" onclick="openSwipe({{ ns.count }})" onmouseover="prefetch({{ ns.count }})" onmouseleave="cancel({{ ns.count }})"/>
|
||||
{%- set ns.count = ns.count + 1 %}
|
||||
<figcaption class="caption">{{ image.name }}
|
||||
{%- if image.tiff %}
|
||||
@@ -195,12 +195,26 @@
|
||||
}
|
||||
|
||||
function prefetch(img) {
|
||||
var link = document.createElement("link");
|
||||
let link = document.createElement("link");
|
||||
link.rel = "preload";
|
||||
link.as = "image";
|
||||
link.href = img;
|
||||
link.href = items[img].src;
|
||||
document.body.appendChild(link);
|
||||
}
|
||||
|
||||
function cancel(img) {
|
||||
let links = document.body.getElementsByTagName("link");
|
||||
for (let link in links) {
|
||||
let ling = links[link]
|
||||
try {
|
||||
if (ling.getAttribute("rel") == "preload" && ling.getAttribute("href") == items[img].src) {
|
||||
document.body.removeChild(ling);
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{%- endif %}
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user