Merge remote-tracking branch 'refs/remotes/tryggvib/532-exif-creation-date'
Conflicts: mediagoblin/config_spec.ini mediagoblin/templates/mediagoblin/user_pages/media.html
This commit is contained in:
commit
058226d0d2
@ -61,6 +61,7 @@ csrf_cookie_name = string(default='mediagoblin_csrftoken')
|
|||||||
push_urls = string_list(default=list())
|
push_urls = string_list(default=list())
|
||||||
|
|
||||||
exif_visible = boolean(default=False)
|
exif_visible = boolean(default=False)
|
||||||
|
original_date_visible = boolean(default=False)
|
||||||
|
|
||||||
# Theming stuff
|
# Theming stuff
|
||||||
theme_install_dir = string(default="%(here)s/user_dev/themes/")
|
theme_install_dir = string(default="%(here)s/user_dev/themes/")
|
||||||
|
@ -44,6 +44,23 @@ class ImageData(Base):
|
|||||||
gps_altitude = Column(Float)
|
gps_altitude = Column(Float)
|
||||||
gps_direction = Column(Float)
|
gps_direction = Column(Float)
|
||||||
|
|
||||||
|
def get_original_date(self):
|
||||||
|
"""
|
||||||
|
Get the original date and time from the EXIF information. Returns
|
||||||
|
either a datetime object or None (if anything goes wrong)
|
||||||
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
try:
|
||||||
|
# Try wrapped around all since exif_all might be none,
|
||||||
|
# EXIF DateTimeOriginal or printable might not exist, or
|
||||||
|
# strptime might not be able to parse date correctly
|
||||||
|
exif_date = self.exif_all['EXIF DateTimeOriginal']['printable']
|
||||||
|
original_date = datetime.datetime.strptime(exif_date,
|
||||||
|
'%Y:%m:%d %H:%M:%S')
|
||||||
|
return original_date
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
DATA_MODEL = ImageData
|
DATA_MODEL = ImageData
|
||||||
MODELS = [ImageData]
|
MODELS = [ImageData]
|
||||||
|
@ -153,6 +153,17 @@
|
|||||||
{{ formatted_time }} ago
|
{{ formatted_time }} ago
|
||||||
{%- endtrans -%}
|
{%- endtrans -%}
|
||||||
</span></p>
|
</span></p>
|
||||||
|
|
||||||
|
{% if app_config['original_date_visible'] %}
|
||||||
|
{% set original_date = media.media_data.get_original_date() %}
|
||||||
|
{% if original_date -%}
|
||||||
|
{% trans date=original_date.strftime("%Y-%m-%d") -%}
|
||||||
|
<h3>Created on</h3>
|
||||||
|
<p>{{ date }}</p>
|
||||||
|
{%- endtrans %}
|
||||||
|
{%- endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if media.tags %}
|
{% if media.tags %}
|
||||||
{% include "mediagoblin/utils/tags.html" %}
|
{% include "mediagoblin/utils/tags.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user