idk if this cancels preload...

This commit is contained in:
2024-10-20 11:43:35 +02:00
parent c429cd06c8
commit cc783ee30e
5 changed files with 23 additions and 10 deletions

View File

@@ -1 +1 @@
2.4.0
2.4.1

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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>