##// END OF EJS Templates
Added images for different file formats
neko259 -
r1326:f6b7deb9 default
parent child Browse files
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -13,6 +13,12 b' FILE_TYPES_AUDIO = ('
13 'mp3',
13 'mp3',
14 )
14 )
15
15
16 PLAIN_FILE_FORMATS = {
17 'pdf': 'pdf',
18 'djvu': 'djvu',
19 'txt': 'txt',
20 }
21
16
22
17 def get_viewers():
23 def get_viewers():
18 return AbstractViewer.__subclasses__()
24 return AbstractViewer.__subclasses__()
@@ -35,9 +41,15 b' class AbstractViewer:'
35 self.file_type, filesizeformat(self.file.size))
41 self.file_type, filesizeformat(self.file.size))
36
42
37 def get_format_view(self):
43 def get_format_view(self):
44 if self.file_type in PLAIN_FILE_FORMATS:
45 image = 'images/fileformats/{}.png'.format(
46 PLAIN_FILE_FORMATS[self.file_type])
47 else:
48 image = FILE_STUB_IMAGE
49
38 return '<a href="{}">'\
50 return '<a href="{}">'\
39 '<img src="{}" width="200" height="150"/>'\
51 '<img src="{}" width="200" height="150"/>'\
40 '</a>'.format(self.file.url, static(FILE_STUB_IMAGE))
52 '</a>'.format(self.file.url, static(image))
41
53
42
54
43 class VideoViewer(AbstractViewer):
55 class VideoViewer(AbstractViewer):
General Comments 0
You need to be logged in to leave comments. Login now