Show More
1 | NO CONTENT: new file 100644, binary diff hidden |
|
NO CONTENT: new file 100644, binary diff hidden |
@@ -1,10 +1,13 b'' | |||||
1 | import os |
|
1 | import os | |
|
2 | import re | |||
2 |
|
3 | |||
3 | from django.core.files.images import get_image_dimensions |
|
4 | from django.core.files.images import get_image_dimensions | |
4 | from django.template.defaultfilters import filesizeformat |
|
5 | from django.template.defaultfilters import filesizeformat | |
5 | from django.contrib.staticfiles.templatetags.staticfiles import static |
|
6 | from django.contrib.staticfiles.templatetags.staticfiles import static | |
6 | from django.contrib.staticfiles import finders |
|
7 | from django.contrib.staticfiles import finders | |
7 |
|
8 | |||
|
9 | REGEX_DOMAIN = re.compile(r'(\w+\.)*(\w+\.\w+)') | |||
|
10 | ||||
8 | FILE_STUB_IMAGE = 'images/file.png' |
|
11 | FILE_STUB_IMAGE = 'images/file.png' | |
9 | FILE_STUB_URL = 'url' |
|
12 | FILE_STUB_URL = 'url' | |
10 |
|
13 | |||
@@ -45,8 +48,9 b' URL_PROTOCOLS = {' | |||||
45 |
|
48 | |||
46 | URL_DOMAINS = { |
|
49 | URL_DOMAINS = { | |
47 | 'meduza.io': 'meduza', |
|
50 | 'meduza.io': 'meduza', | |
48 |
' |
|
51 | 'youtube.com': 'youtube', | |
49 | 'youtu.be': 'youtube', |
|
52 | 'youtu.be': 'youtube', | |
|
53 | 'wikipedia.org': 'wikipedia', | |||
50 | } |
|
54 | } | |
51 |
|
55 | |||
52 | CSS_CLASS_IMAGE = 'image' |
|
56 | CSS_CLASS_IMAGE = 'image' | |
@@ -169,7 +173,8 b' class UrlViewer(AbstractViewer):' | |||||
169 |
|
173 | |||
170 | def get_format_view(self): |
|
174 | def get_format_view(self): | |
171 | protocol = self.url.split('://')[0] |
|
175 | protocol = self.url.split('://')[0] | |
172 | domain = self.url.split('/')[2] |
|
176 | full_domain = self.url.split('/')[2] | |
|
177 | domain = REGEX_DOMAIN.search(full_domain).group(2) | |||
173 |
|
178 | |||
174 | if protocol in URL_PROTOCOLS: |
|
179 | if protocol in URL_PROTOCOLS: | |
175 | url_image_name = URL_PROTOCOLS.get(protocol) |
|
180 | url_image_name = URL_PROTOCOLS.get(protocol) |
General Comments 0
You need to be logged in to leave comments.
Login now