diff --git a/sigal/gallery.py b/sigal/gallery.py index e3da1e5..8947ffb 100644 --- a/sigal/gallery.py +++ b/sigal/gallery.py @@ -82,6 +82,9 @@ class Media: self.logger = logging.getLogger(__name__) self._get_metadata() + # default: title is the filename + if not self.title: + self.title = self.filename signals.media_initialized.send(self) def __repr__(self): @@ -111,7 +114,12 @@ class Media: if not isfile(big_path): copy(self.src_path, big_path, symlink=s['orig_link']) - return url_from_path(join(s['orig_dir'], self.src_filename)) + return join(s['orig_dir'], self.src_filename) + + @property + def big_url(self): + """URL of the original media.""" + return url_from_path(self.big) @property def thumbnail(self): @@ -142,8 +150,7 @@ class Media: """ Get image metadata from filename.md: title, description, meta.""" self.description = '' self.meta = {} - # default: title is the filename - self.title = self.filename + self.title = '' descfile = splitext(self.src_path)[0] + '.md' if isfile(descfile): diff --git a/sigal/themes/colorbox/templates/album_list.html b/sigal/themes/colorbox/templates/album_list.html index c408a47..7e67953 100644 --- a/sigal/themes/colorbox/templates/album_list.html +++ b/sigal/themes/colorbox/templates/album_list.html @@ -35,7 +35,7 @@ {% if album.medias %} {% macro img_description(media) -%} - {% if media.big %} data-big="{{ media.big }}"{% endif %} + {% if media.big %} data-big="{{ media.big_url }}"{% endif %} {% if media.exif %} {% if media.exif.datetime %} data-date=", {{ media.exif.datetime }}" @@ -70,7 +70,7 @@ {% else %} + {% if media.big %} data-big="{{ media.big_url }}"{% endif %}> {{ media.filename }} diff --git a/sigal/themes/galleria/templates/album.html b/sigal/themes/galleria/templates/album.html index bd8f320..d093e16 100644 --- a/sigal/themes/galleria/templates/album.html +++ b/sigal/themes/galleria/templates/album.html @@ -47,7 +47,7 @@ {% block late_js %} {% macro img_description(media) -%} - {%- if media.big -%}Full size{%- endif -%} + {%- if media.big -%}Full size{%- endif -%} {# clean up tags and whitespace, including newlines, in the description #} {%- if media.description -%}
{{ media.description | striptags }}{%- endif -%} {%- if media.exif -%} @@ -85,7 +85,7 @@ description: "{{ img_description(media) | e }}", thumb: "{{ media.thumbnail }}", {% if media.big %} - big: "{{ media.big }}", + big: "{{ media.big_url }}", {% endif %} {% if media.type == "image" %} image: "{{ media.filename }}" diff --git a/tests/test_gallery.py b/tests/test_gallery.py index e580ac7..2f58cf5 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -62,7 +62,7 @@ REF = { 'title': 'video', 'name': 'video', 'thumbnail': ('video/thumbnails/' - 'example video.tn.jpg'), + 'example%20video.tn.jpg'), 'subdirs': [], 'medias': ['example video.ogv'] } @@ -100,7 +100,7 @@ def test_media_orig(settings, tmpdir): m = Video('example video.ogv', 'video', settings) assert m.filename == 'example video.webm' - assert m.big == 'original/example video.ogv' + assert m.big_url == 'original/example%20video.ogv' assert os.path.isfile(join(settings['destination'], m.path, m.big)) settings['use_orig'] = True @@ -145,7 +145,7 @@ def test_video(settings, tmpdir): assert m.dst_path == join(settings['destination'], file_path) os.makedirs(join(settings['destination'], 'video', 'thumbnails')) - assert m.thumbnail == join('thumbnails', 'example video.tn.jpg') + assert m.thumbnail == join('thumbnails', 'example%20video.tn.jpg') assert os.path.isfile(m.thumb_path)