Show More
@@ -7,7 +7,7 b' from random import random' | |||
|
7 | 7 | from django.db import models |
|
8 | 8 | |
|
9 | 9 | from boards.models.attachment.viewers import AbstractViewer, WebmViewer, \ |
|
10 | AudioViewer | |
|
10 | AudioViewer, SvgViewer | |
|
11 | 11 | |
|
12 | 12 | FILES_DIRECTORY = 'files/' |
|
13 | 13 | FILE_EXTENSION_DELIMITER = '.' |
@@ -15,6 +15,7 b" FILE_EXTENSION_DELIMITER = '.'" | |||
|
15 | 15 | VIEWERS = ( |
|
16 | 16 | WebmViewer, |
|
17 | 17 | AudioViewer, |
|
18 | SvgViewer, | |
|
18 | 19 | ) |
|
19 | 20 | |
|
20 | 21 |
@@ -4,6 +4,7 b' from django.templatetags.static import s' | |||
|
4 | 4 | FILE_STUB_IMAGE = 'images/file.png' |
|
5 | 5 | |
|
6 | 6 | FILE_TYPE_WEBM = 'webm' |
|
7 | FILE_TYPE_SVG = 'svg' | |
|
7 | 8 | FILE_TYPES_AUDIO = ( |
|
8 | 9 | 'ogg', |
|
9 | 10 | 'mp3', |
@@ -48,3 +49,14 b' class AudioViewer(AbstractViewer):' | |||
|
48 | 49 | return '<div class="image">' \ |
|
49 | 50 | '<audio controls src="{}"/>' \ |
|
50 | 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