Merge pull request #921 from taigaio/psd-and-svg-preview

Adding support for preview svg and psd images
remotes/origin/github-import
David Barragán Merino 2017-01-17 19:19:21 +01:00 committed by GitHub
commit fbf6340d30
4 changed files with 16 additions and 2 deletions

View File

@ -8,8 +8,8 @@
- Ability to create rich text custom fields in Epics, User Stories, Tasks and Isues. - Ability to create rich text custom fields in Epics, User Stories, Tasks and Isues.
- Full text search now use simple as tokenizer so search with non-english text are allowed. - Full text search now use simple as tokenizer so search with non-english text are allowed.
- Duplicate project: allows creating a new project based on the structure of another (status, tags, colors, default values...) - Duplicate project: allows creating a new project based on the structure of another (status, tags, colors, default values...)
- Add thumbnails for PSD files. - Add thumbnails and preview for PSD files.
- Add thumbnails for SVG files (Cario lib is needed). - Add thumbnails and preview for SVG files (Cario lib is needed).
- i18n: - i18n:
- Add japanese (ja) translation. - Add japanese (ja) translation.
- Add korean (ko) translation. - Add korean (ko) translation.

View File

@ -483,6 +483,7 @@ THN_LOGO_BIG_SIZE = 300 # 300x300 pixels
THN_TIMELINE_IMAGE_SIZE = 640 # 640x??? pixels THN_TIMELINE_IMAGE_SIZE = 640 # 640x??? pixels
THN_CARD_IMAGE_WIDTH = 300 # 300 pixels THN_CARD_IMAGE_WIDTH = 300 # 300 pixels
THN_CARD_IMAGE_HEIGHT = 200 # 200 pixels THN_CARD_IMAGE_HEIGHT = 200 # 200 pixels
THN_PREVIEW_IMAGE_WIDTH = 800 # 800 pixels
THN_AVATAR_SMALL = "avatar" THN_AVATAR_SMALL = "avatar"
THN_AVATAR_BIG = "big-avatar" THN_AVATAR_BIG = "big-avatar"
@ -490,6 +491,7 @@ THN_LOGO_SMALL = "logo-small"
THN_LOGO_BIG = "logo-big" THN_LOGO_BIG = "logo-big"
THN_ATTACHMENT_TIMELINE = "timeline-image" THN_ATTACHMENT_TIMELINE = "timeline-image"
THN_ATTACHMENT_CARD = "card-image" THN_ATTACHMENT_CARD = "card-image"
THN_ATTACHMENT_PREVIEW = "preview-image"
THUMBNAIL_ALIASES = { THUMBNAIL_ALIASES = {
"": { "": {
@ -499,6 +501,7 @@ THUMBNAIL_ALIASES = {
THN_LOGO_BIG: {"size": (THN_LOGO_BIG_SIZE, THN_LOGO_BIG_SIZE), "crop": True}, THN_LOGO_BIG: {"size": (THN_LOGO_BIG_SIZE, THN_LOGO_BIG_SIZE), "crop": True},
THN_ATTACHMENT_TIMELINE: {"size": (THN_TIMELINE_IMAGE_SIZE, 0), "crop": True}, THN_ATTACHMENT_TIMELINE: {"size": (THN_TIMELINE_IMAGE_SIZE, 0), "crop": True},
THN_ATTACHMENT_CARD: {"size": (THN_CARD_IMAGE_WIDTH, THN_CARD_IMAGE_HEIGHT), "crop": True}, THN_ATTACHMENT_CARD: {"size": (THN_CARD_IMAGE_WIDTH, THN_CARD_IMAGE_HEIGHT), "crop": True},
THN_ATTACHMENT_PREVIEW: {"size": (THN_PREVIEW_IMAGE_WIDTH, 0), "crop": False},
}, },
} }

View File

@ -42,6 +42,7 @@ class AttachmentSerializer(serializers.LightSerializer):
sha1 = Field() sha1 = Field()
url = MethodField("get_url") url = MethodField("get_url")
thumbnail_card_url = MethodField("get_thumbnail_card_url") thumbnail_card_url = MethodField("get_thumbnail_card_url")
preview_url = MethodField("get_preview_url")
def get_url(self, obj): def get_url(self, obj):
return obj.attached_file.url return obj.attached_file.url
@ -49,6 +50,11 @@ class AttachmentSerializer(serializers.LightSerializer):
def get_thumbnail_card_url(self, obj): def get_thumbnail_card_url(self, obj):
return services.get_card_image_thumbnail_url(obj) return services.get_card_image_thumbnail_url(obj)
def get_preview_url(self, obj):
if obj.name.endswith(".psd"):
return services.get_attachment_image_preview_url(obj)
return self.get_url(obj)
class BasicAttachmentsInfoSerializerMixin(serializers.LightSerializer): class BasicAttachmentsInfoSerializerMixin(serializers.LightSerializer):
""" """

View File

@ -28,3 +28,8 @@ def get_card_image_thumbnail_url(attachment):
if attachment.attached_file: if attachment.attached_file:
return get_thumbnail_url(attachment.attached_file, settings.THN_ATTACHMENT_CARD) return get_thumbnail_url(attachment.attached_file, settings.THN_ATTACHMENT_CARD)
return None return None
def get_attachment_image_preview_url(attachment):
if attachment.attached_file:
return get_thumbnail_url(attachment.attached_file, settings.THN_ATTACHMENT_PREVIEW)
return None