Show More
@@ -7,7 +7,7 b' from random import random' | |||||
7 | from django.db import models |
|
7 | from django.db import models | |
8 |
|
8 | |||
9 | from boards.models.attachment.viewers import AbstractViewer, WebmViewer, \ |
|
9 | from boards.models.attachment.viewers import AbstractViewer, WebmViewer, \ | |
10 | AudioViewer |
|
10 | AudioViewer, SvgViewer | |
11 |
|
11 | |||
12 | FILES_DIRECTORY = 'files/' |
|
12 | FILES_DIRECTORY = 'files/' | |
13 | FILE_EXTENSION_DELIMITER = '.' |
|
13 | FILE_EXTENSION_DELIMITER = '.' | |
@@ -15,6 +15,7 b" FILE_EXTENSION_DELIMITER = '.'" | |||||
15 | VIEWERS = ( |
|
15 | VIEWERS = ( | |
16 | WebmViewer, |
|
16 | WebmViewer, | |
17 | AudioViewer, |
|
17 | AudioViewer, | |
|
18 | SvgViewer, | |||
18 | ) |
|
19 | ) | |
19 |
|
20 | |||
20 |
|
21 |
@@ -4,6 +4,7 b' from django.templatetags.static import s' | |||||
4 | FILE_STUB_IMAGE = 'images/file.png' |
|
4 | FILE_STUB_IMAGE = 'images/file.png' | |
5 |
|
5 | |||
6 | FILE_TYPE_WEBM = 'webm' |
|
6 | FILE_TYPE_WEBM = 'webm' | |
|
7 | FILE_TYPE_SVG = 'svg' | |||
7 | FILE_TYPES_AUDIO = ( |
|
8 | FILE_TYPES_AUDIO = ( | |
8 | 'ogg', |
|
9 | 'ogg', | |
9 | 'mp3', |
|
10 | 'mp3', | |
@@ -48,3 +49,14 b' class AudioViewer(AbstractViewer):' | |||||
48 | return '<div class="image">' \ |
|
49 | return '<div class="image">' \ | |
49 | '<audio controls src="{}"/>' \ |
|
50 | '<audio controls src="{}"/>' \ | |
50 | '</div>'.format(self.file.url) |
|
51 | '</div>'.format(self.file.url) | |
|
52 | ||||
|
53 | ||||
|
54 | class SvgViewer(AbstractViewer): | |||
|
55 | @staticmethod | |||
|
56 | def supports(file_type): | |||
|
57 | return file_type == FILE_TYPE_SVG | |||
|
58 | ||||
|
59 | def get_view(self): | |||
|
60 | return '<div class="image">'\ | |||
|
61 | '<img width="200" height="150" src="{}"/>'\ | |||
|
62 | '</div>'.format(self.file.url) |
General Comments 0
You need to be logged in to leave comments.
Login now