Merge pull request #2167 from imachug/merge-media

Add --merge_media config option
This commit is contained in:
ZeroNet 2019-08-20 12:10:39 +02:00 committed by GitHub
commit 0e236e53fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -206,6 +206,7 @@ class Config(object):
self.parser.add_argument('--debug', help='Debug mode', action='store_true') self.parser.add_argument('--debug', help='Debug mode', action='store_true')
self.parser.add_argument('--silent', help='Only log errors to terminal output', action='store_true') self.parser.add_argument('--silent', help='Only log errors to terminal output', action='store_true')
self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true') self.parser.add_argument('--debug_socket', help='Debug socket connections', action='store_true')
self.parser.add_argument('--merge_media', help='Merge all.js and all.css', action='store_true')
self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true') self.parser.add_argument('--batch', help="Batch mode (No interactive input for commands)", action='store_true')

View file

@ -551,7 +551,7 @@ class UiRequest(object):
address = path_parts["address"] address = path_parts["address"]
file_path = "%s/%s/%s" % (config.data_dir, address, path_parts["inner_path"]) file_path = "%s/%s/%s" % (config.data_dir, address, path_parts["inner_path"])
if config.debug and file_path.split("/")[-1].startswith("all."): if (config.debug or config.merge_media) and file_path.split("/")[-1].startswith("all."):
# If debugging merge *.css to all.css and *.js to all.js # If debugging merge *.css to all.css and *.js to all.js
site = self.server.sites.get(address) site = self.server.sites.get(address)
if site and site.settings["own"]: if site and site.settings["own"]:
@ -607,7 +607,7 @@ class UiRequest(object):
# File not in allowed path # File not in allowed path
return self.error403() return self.error403()
else: else:
if config.debug and match.group("inner_path").startswith("all."): if (config.debug or config.merge_media) and match.group("inner_path").startswith("all."):
# If debugging merge *.css to all.css and *.js to all.js # If debugging merge *.css to all.css and *.js to all.js
from Debug import DebugMedia from Debug import DebugMedia
DebugMedia.merge(file_path) DebugMedia.merge(file_path)