Browse Source

Merge 664fd0a994 into f04d90c695

pull/525/merge
Stasinos Konstantopoulos 3 months ago committed by GitHub
parent
commit
630a08d556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      AUTHORS
  2. 4
      docs/image_information.rst
  3. 13
      src/sigal/gallery.py
  4. 10
      src/sigal/themes/default/templates/map.html
  5. 11
      src/sigal/utils.py

1
AUTHORS

@ -59,6 +59,7 @@ alphabetical order):
- Sébastien Maccagnoni-Munch - Sébastien Maccagnoni-Munch
- Sean Grider (@kaibutsux) - Sean Grider (@kaibutsux)
- Simon Conseil - Simon Conseil
- @stasinos
- Stefano Zacchiroli - Stefano Zacchiroli
- @subwarpspeed - @subwarpspeed
- @t-animal - @t-animal

4
docs/image_information.rst

@ -16,6 +16,10 @@ keys are used by Sigal to get the useful informations on the gallery:
- *Title*: the image title. - *Title*: the image title.
- *Date*: the file date, useful when it cannot be read from the EXIF metadata, - *Date*: the file date, useful when it cannot be read from the EXIF metadata,
e.g. for videos and some image formats. e.g. for videos and some image formats.
- *Lat* and *Lon*: geo-location for positioning the image on map galleries.
Note that this overrides EXIF coordinates, so except for localizing when
EXIF coordinates are missing it can also be used to localize the image
based on what is depicted instead of where the camera was standing.
Any additional meta-data is available in the templates. For instance:: Any additional meta-data is available in the templates. For instance::

13
src/sigal/gallery.py

@ -5,6 +5,7 @@
# Copyright (c) 2017 - Mate Lakat # Copyright (c) 2017 - Mate Lakat
# Copyright (c) 2018 - Edwin Steele # Copyright (c) 2018 - Edwin Steele
# Copyright (c) 2021 - Tim AtLee # Copyright (c) 2021 - Tim AtLee
# Copyright (c) 2024 - Stasinos Konstantopoulos
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to # of this software and associated documentation files (the "Software"), to
@ -223,7 +224,7 @@ class Media:
def _get_markdown_metadata(self): def _get_markdown_metadata(self):
"""Get metadata from filename.md.""" """Get metadata from filename.md."""
meta = {"title": "", "description": "", "meta": {}} meta = {"title": "", "description": "", "lat": "", "lon": "", "meta": {}}
if isfile(self.markdown_metadata_filepath): if isfile(self.markdown_metadata_filepath):
meta.update(read_markdown(self.markdown_metadata_filepath)) meta.update(read_markdown(self.markdown_metadata_filepath))
return meta return meta
@ -287,6 +288,16 @@ class Image(Media):
return meta return meta
@cached_property
def lat(self):
"""If not `None`, latitude extracted from the Markdown index.md file."""
return self.markdown_metadata.get("lat")
@cached_property
def lon(self):
"""If not `None`, longitude extracted from the Markdown index.md file."""
return self.markdown_metadata.get("lon")
@cached_property @cached_property
def raw_exif(self): def raw_exif(self):
"""If not `None`, contains the raw EXIF tags.""" """If not `None`, contains the raw EXIF tags."""

10
src/sigal/themes/default/templates/map.html

@ -19,7 +19,15 @@
var photos = []; var photos = [];
{% for media in album.medias %} {% for media in album.medias %}
{% if media.exif and media.exif.gps %} {% if media.lat and media.lon %}
photos.push({
lat: {{ media.lat }},
lng: {{ media.lon }},
url: "{{ media.thumbnail }}",
caption: "{{ media.title }}",
thumbnail: "{{ media.thumbnail }}",
});
{% elif media.exif and media.exif.gps %}
photos.push({ photos.push({
lat: {{ media.exif.gps.lat }}, lat: {{ media.exif.gps.lat }},
lng: {{ media.exif.gps.lon }}, lng: {{ media.exif.gps.lon }},

11
src/sigal/utils.py

@ -1,4 +1,5 @@
# Copyright (c) 2011-2023 - Simon Conseil # Copyright (c) 2011-2023 - Simon Conseil
# Copyright (c) 2024 - Stasinos Konstantopoulos
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to # of this software and associated documentation files (the "Software"), to
@ -136,10 +137,12 @@ def read_markdown(filename):
pass pass
else: else:
output["meta"] = meta output["meta"] = meta
try: l = MD.Meta.get("title", [])
output["title"] = MD.Meta["title"][0] if l: output["title"] = l[0]
except KeyError: l = MD.Meta.get("lat", [])
pass if l: output["lat"] = l[0]
l = MD.Meta.get("lon", [])
if l: output["lon"] = l[0]
return output return output

Loading…
Cancel
Save