Serve files without wrapper if requested using /raw/ prefix
This commit is contained in:
parent
6c0062dbc1
commit
febdea6c64
4 changed files with 33 additions and 13 deletions
|
@ -38,7 +38,7 @@ def openArchive(archive_path, path_within):
|
|||
|
||||
@PluginManager.registerTo("UiRequest")
|
||||
class UiRequestPlugin(object):
|
||||
def actionSiteMedia(self, path, header_length=True):
|
||||
def actionSiteMedia(self, path, **kwargs):
|
||||
if ".zip/" in path or ".tar.gz/" in path:
|
||||
path_parts = self.parsePath(path)
|
||||
file_path = u"%s/%s/%s" % (config.data_dir, path_parts["address"], path_parts["inner_path"].decode("utf8"))
|
||||
|
@ -63,7 +63,7 @@ class UiRequestPlugin(object):
|
|||
self.log.debug("Error opening archive file: %s" % err)
|
||||
return self.error404(path)
|
||||
|
||||
return super(UiRequestPlugin, self).actionSiteMedia(path, header_length=header_length)
|
||||
return super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs)
|
||||
|
||||
def streamFile(self, file):
|
||||
while 1:
|
||||
|
|
|
@ -6,14 +6,15 @@ from Translate import translate
|
|||
|
||||
@PluginManager.registerTo("UiRequest")
|
||||
class UiRequestPlugin(object):
|
||||
def actionSiteMedia(self, path, header_length=True):
|
||||
def actionSiteMedia(self, path, **kwargs):
|
||||
file_name = path.split("/")[-1]
|
||||
if not file_name: # Path ends with /
|
||||
file_name = "index.html"
|
||||
extension = file_name.split(".")[-1]
|
||||
if translate.lang != "en" and extension in ["js", "html"]:
|
||||
path_parts = self.parsePath(path)
|
||||
file_generator = super(UiRequestPlugin, self).actionSiteMedia(path, header_length=False)
|
||||
kwargs["header_length"] = False
|
||||
file_generator = super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs)
|
||||
if "next" in dir(file_generator): # File found and generator returned
|
||||
site = self.server.sites.get(path_parts["address"])
|
||||
return self.actionPatchFile(site, path_parts["inner_path"], file_generator)
|
||||
|
@ -21,7 +22,7 @@ class UiRequestPlugin(object):
|
|||
return file_generator
|
||||
|
||||
else:
|
||||
return super(UiRequestPlugin, self).actionSiteMedia(path)
|
||||
return super(UiRequestPlugin, self).actionSiteMedia(path, **kwargs)
|
||||
|
||||
def actionUiMedia(self, path):
|
||||
file_generator = super(UiRequestPlugin, self).actionUiMedia(path)
|
||||
|
|
|
@ -12,7 +12,7 @@ class UiRequestPlugin(object):
|
|||
super(UiRequestPlugin, self).__init__(*args, **kwargs)
|
||||
|
||||
# Media request
|
||||
def actionSiteMedia(self, path, header_length=True):
|
||||
def actionSiteMedia(self, path, **kwargs):
|
||||
match = re.match("/media/(?P<address>[A-Za-z0-9-]+\.[A-Za-z0-9\.-]+)(?P<inner_path>/.*|$)", path)
|
||||
if match: # Its a valid domain, resolve first
|
||||
domain = match.group("address")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue