Fixes following rebase

This commit is contained in:
Simon Conseil
2018-10-04 22:25:38 +02:00
parent a212eb05b3
commit daa85c73fc
4 changed files with 17 additions and 10 deletions

View File

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

View File

@@ -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 %}
<a href="#{{ mhash }}" class="gallery" inline='yes' title="{{ media.filename }}"
{% endif %}
{% if media.big %} data-big="{{ media.big }}"{% endif %}>
{% if media.big %} data-big="{{ media.big_url }}"{% endif %}>
<img src="{{ media.thumbnail }}" alt="{{ media.filename }}"
title="{{ media.title }}" /></a>
</div>

View File

@@ -47,7 +47,7 @@
{% block late_js %}
{% macro img_description(media) -%}
{%- if media.big -%}<a href='{{ media.big }}'>Full size</a>{%- endif -%}
{%- if media.big -%}<a href='{{ media.big_url }}'>Full size</a>{%- endif -%}
{# clean up tags and whitespace, including newlines, in the description #}
{%- if media.description -%}<br>{{ 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 }}"

View File

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