-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathUiRequestPlugin.py
More file actions
23 lines (16 loc) · 768 Bytes
/
UiRequestPlugin.py
File metadata and controls
23 lines (16 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from Plugin import PluginManager
import re
@PluginManager.registerTo('UiRequest')
class UiRequestPlugin:
def __init__(self, *args, **kwargs):
from Site import SiteManager
self.site_manager = SiteManager.site_manager
super(UiRequestPlugin, self).__init__(*args, **kwargs)
def actionSiteMedia(self, path, **kwargs):
match = re.match(r'/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)', path)
if match:
domain = match.group('address')
address = self.site_manager.dns_resolver.resolveDomain(domain)
if address:
path = '/media/' + address + match.group('inner_path')
return super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs)