From 654d7cf94f41e6b6c01fe021a977d3898e6829a9 Mon Sep 17 00:00:00 2001 From: Boris Bobrov Date: Sat, 16 Aug 2014 02:18:12 +0300 Subject: [PATCH] Display type icon in thumbnails --- mediagoblin/db/mixin.py | 17 +++++++++++++---- mediagoblin/media_types/video/__init__.py | 1 + mediagoblin/static/css/base.css | 12 ++++++------ .../mediagoblin/utils/object_gallery.html | 6 +++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index ecd04874..083617d3 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -301,6 +301,15 @@ class MediaEntryMixin(GenerateSlugMixin, GeneratePublicIDMixin): self.media_files[u"original"] ) + @property + def icon_url(self): + '''Return the icon URL (for usage in templates) if it exists''' + try: + return self._app.staticdirector( + self.media_manager['type_icon']) + except AttributeError: + return None + @cached_property def media_manager(self): """Returns the MEDIA_MANAGER of the media's media_type @@ -449,7 +458,7 @@ class CollectionMixin(GenerateSlugMixin, GeneratePublicIDMixin): """ Adds an object to the collection """ # It's here to prevent cyclic imports from mediagoblin.db.models import CollectionItem - + # Need the ID of this collection for this so check we've got one. self.save(commit=False) @@ -457,16 +466,16 @@ class CollectionMixin(GenerateSlugMixin, GeneratePublicIDMixin): item = CollectionItem() item.collection = self.id item.get_object = obj - + if content is not None: item.note = content self.num_items = self.num_items + 1 - + # Save both! self.save(commit=commit) item.save(commit=commit) - return item + return item class CollectionItemMixin(object): @property diff --git a/mediagoblin/media_types/video/__init__.py b/mediagoblin/media_types/video/__init__.py index f636f1ab..0b460d29 100644 --- a/mediagoblin/media_types/video/__init__.py +++ b/mediagoblin/media_types/video/__init__.py @@ -28,6 +28,7 @@ class VideoMediaManager(MediaManagerBase): human_readable = "Video" display_template = "mediagoblin/media_displays/video.html" default_thumb = "images/media_thumbs/video.jpg" + type_icon = "images/type_icons/video.jpg" # Used by the media_entry.get_display_media method media_fetch_order = [u'webm_video', u'original'] diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index 52c1f2dc..5bbc1f74 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -590,6 +590,7 @@ ul#action_to_resolve {list-style:none; margin-left:10px;} border-color: #0D0D0D; border-style: solid; border-width: 1px 1px 2px; + position: relative; } .media_thumbnail a { @@ -607,12 +608,11 @@ a.thumb_entry_title { padding: 8px; } -/* For now, this is commented out since our thumbnails are actually 180px high. - * - * .media_thumbnail img { - * max-height: 135px; - * } - */ +.entry_type_icon { + position: absolute; + top: 0; + right: 0; +} .thumb_entry_last { margin-right: 0px; diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html index 1f05eed2..396d2997 100644 --- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html +++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html @@ -30,10 +30,14 @@ {%- if loop.first %} thumb_entry_first {%- elif loop.last %} thumb_entry_last{% endif %}"> + {% if entry.icon_url %} + + {% endif %} {% if entry.title %} - {{ entry.title }} + {{ entry.title }} + {{ entry.icon_url }} {% endif %} {% endfor %} -- 2.25.1