diff --git a/boards/models/attachment/viewers.py b/boards/models/attachment/viewers.py
--- a/boards/models/attachment/viewers.py
+++ b/boards/models/attachment/viewers.py
@@ -52,6 +52,36 @@ URL_PROTOCOLS = {
CSS_CLASS_IMAGE = 'image'
CSS_CLASS_THUMB = 'thumb'
+ABSTRACT_VIEW = '
'
+URL_VIEW = '' \
+ '{}' \
+ '
{}
' \
+ '
'
+ABSTRACT_FORMAT_VIEW = ''\
+ ''\
+ ''
+VIDEO_FORMAT_VIEW = ''
+AUDIO_FORMAT_VIEW = ''
+IMAGE_FORMAT_VIEW = '' \
+ '' \
+ ''
+SVG_FORMAT_VIEW = ''\
+ ''\
+ ''
+URL_FORMAT_VIEW = '' \
+ '' \
+ ''
+
def get_viewers():
return AbstractViewer.__subclasses__()
@@ -87,13 +117,9 @@ class AbstractViewer:
else:
search_url = ''
- return ''.format(self.get_format_view(), self.file.url,
- self.file_type, filesizeformat(self.file.size),
- self.file_type, search_url, self.file.name)
+ return ABSTRACT_VIEW.format(self.get_format_view(), self.file.url,
+ self.file_type, filesizeformat(self.file.size),
+ self.file_type, search_url, self.file.name)
def get_format_view(self):
image_name = PLAIN_FILE_FORMATS.get(self.file_type, self.file_type)
@@ -106,9 +132,7 @@ class AbstractViewer:
w, h = get_static_dimensions(image)
- return ''\
- ''\
- ''.format(self.file.url, static(image), w, h)
+ return ABSTRACT_FORMAT_VIEW.format(self.file.url, static(image), w, h)
class VideoViewer(AbstractViewer):
@@ -117,8 +141,7 @@ class VideoViewer(AbstractViewer):
return file_type in FILE_TYPES_VIDEO
def get_format_view(self):
- return ''\
- .format(self.file.url)
+ return VIDEO_FORMAT_VIEW.format(self.file.url)
class AudioViewer(AbstractViewer):
@@ -127,7 +150,7 @@ class AudioViewer(AbstractViewer):
return file_type in FILE_TYPES_AUDIO
def get_format_view(self):
- return ''.format(self.file.url)
+ return AUDIO_FORMAT_VIEW.format(self.file.url)
class SvgViewer(AbstractViewer):
@@ -136,9 +159,7 @@ class SvgViewer(AbstractViewer):
return file_type == FILE_TYPE_SVG
def get_format_view(self):
- return ''\
- ''\
- ''.format(self.file.url, self.file.url)
+ return SVG_FORMAT_VIEW.format(self.file.url, self.file.url)
class ImageViewer(AbstractViewer):
@@ -164,21 +185,12 @@ class ImageViewer(AbstractViewer):
w, h = 200, 150
thumb_url = '%s.%sx%s.%s' % (split[0], w, h, split[1])
- return '' \
- '' \
- '' \
- .format(CSS_CLASS_THUMB,
- thumb_url,
- self.hash,
- str(pre_width),
- str(pre_height), str(width), str(height),
- full=self.file.url, image_meta=metadata)
+ return IMAGE_FORMAT_VIEW.format(CSS_CLASS_THUMB,
+ thumb_url,
+ self.hash,
+ str(pre_width),
+ str(pre_height), str(width), str(height),
+ full=self.file.url, image_meta=metadata)
class UrlViewer(AbstractViewer):
@@ -187,10 +199,7 @@ class UrlViewer(AbstractViewer):
return file_type is None
def get_view(self):
- return '' \
- '{}' \
- '
{}
' \
- '
'.format(self.get_format_view(), get_domain(self.url))
+ return URL_VIEW.format(self.get_format_view(), get_domain(self.url))
def get_format_view(self):
protocol = self.url.split(':')[0]
@@ -208,9 +217,7 @@ class UrlViewer(AbstractViewer):
image = static(image_path)
w, h = get_static_dimensions(image_path)
- return '' \
- '' \
- ''.format(self.url, image, w, h)
+ return URL_FORMAT_VIEW.format(self.url, image, w, h)
@cached_result()
def _find_image_for_domains(self, domain):