summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/pyggle30
-rw-r--r--share/html_start15
2 files changed, 25 insertions, 20 deletions
diff --git a/bin/pyggle b/bin/pyggle
index a2e3348..6e01589 100755
--- a/bin/pyggle
+++ b/bin/pyggle
@@ -326,7 +326,7 @@ class Thumbnail:
self.thumbname = f"{sub_dirname}/.thumbnails/{sub_thumbname}"
have_subthumb = True
if os.path.exists(f"{sub_dirname}/.thumbnails/{sub_filename}.p.jpg"):
- self.jpegname = f"{sub_dirname}/.thumbnails/{sub_filename}"
+ self.jpegname = f"{sub_dirname}/.thumbnails/{sub_filename}.p.jpg"
if not have_subthumb:
thumb_filename = filename.replace("/", "-")
@@ -568,10 +568,12 @@ class Thumbnail:
global location_cache
global geocoder
- latlon = f"{lat:.3f}/{lon:.3f}"
+ latlon = f"{lat:.4f}/{lon:.4f}"
- if latlon in location_cache:
- self.gps = GPSData(lat, lon, location_cache[latlon])
+ if str(args.nominatim_zoom) in location_cache.get(latlon, dict()):
+ self.gps = GPSData(
+ lat, lon, location_cache[latlon][str(args.nominatim_zoom)]
+ )
self.html.set_gps(self.gps)
return
@@ -584,7 +586,9 @@ class Thumbnail:
try:
res = geocoder.reverse((lat, lon), zoom=args.nominatim_zoom)
location = res.address.split(",")[0]
- location_cache[latlon] = location
+ if latlon not in location_cache:
+ location_cache[latlon] = dict()
+ location_cache[latlon][str(args.nominatim_zoom)] = location
except TypeError as e:
location = latlon
@@ -761,6 +765,7 @@ if __name__ == "__main__":
default=16,
help="Zoom Level for reverse geocoding",
)
+ parser.add_argument("--quiet", action="store_true", help="Do not show progress bar")
parser.add_argument(
"--resize",
metavar="N",
@@ -816,6 +821,10 @@ if __name__ == "__main__":
if not args.cdn:
copy_files(f"{base_dir}/share")
+ if args.with_nominatim and os.path.exists(".thumbnails/location_cache.json"):
+ with open(".thumbnails/location_cache.json", "r") as f:
+ location_cache = json.load(f)
+
with open(f"{base_dir}/share/html_start", "r") as f:
html_buf = f.read().replace("<!-- $title -->", args.title)
@@ -831,7 +840,12 @@ if __name__ == "__main__":
filenames = args.images
thumbnails = list()
- for i, filename in enumerate(ProgressBar(max=len(filenames)).iter(filenames)):
+ if args.quiet:
+ file_iter = filenames
+ else:
+ file_iter = ProgressBar(max=len(filenames)).iter(filenames)
+
+ for i, filename in enumerate(file_iter):
try:
im = Image.open(filename)
except PIL.UnidentifiedImageError:
@@ -972,6 +986,10 @@ if __name__ == "__main__":
write_gallery(html_buf, "index.html", thumbnails, group=args.group)
+ if args.with_nominatim:
+ with open(".thumbnails/location_cache.json", "w") as f:
+ json.dump(location_cache, f)
+
if args.group_files != "none":
thumbnail_keys = list(sorted(set(map(lambda t: t.file_key, thumbnails))))
for i, thumbnail_key in enumerate(thumbnail_keys):
diff --git a/share/html_start b/share/html_start
index 68be715..c44b353 100644
--- a/share/html_start
+++ b/share/html_start
@@ -16,21 +16,8 @@
old.href = path;
}
}
- var otherTheme = {
- 'dark': 'light',
- 'light': 'dark',
- };
- var currentTheme = localStorage.getItem('theme');
- if (!otherTheme.hasOwnProperty(currentTheme)) {
- currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
- }
+ const currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
addStyleSheet(currentTheme, 'theme');
-
- function toggleTheme() {
- currentTheme = otherTheme[currentTheme] || 'light';
- localStorage.setItem('theme', currentTheme);
- addStyleSheet(currentTheme, 'theme');
- }
</script>
<script src=".data/js/glightbox.min.js"></script>
</head>