Add custom web assets support
This commit is contained in:
@@ -352,7 +352,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
# Now we start the actual processing, now that all the configuration has
|
||||
# been gathered and validated
|
||||
# create our asset manager... ASSMAN
|
||||
assetMrg = assetmanager.AssetManager(destdir)
|
||||
assetMrg = assetmanager.AssetManager(destdir, config.get('customwebassets', None))
|
||||
|
||||
tilesets = []
|
||||
|
||||
|
||||
@@ -33,13 +33,14 @@ same time, controls the generated javascript files in the output directory.
|
||||
There should only be one instances of these per execution.
|
||||
"""
|
||||
|
||||
def __init__(self, outputdir):
|
||||
def __init__(self, outputdir, custom_assets_dir=None):
|
||||
"""\
|
||||
Initializes the AssetManager with the top-level output directory.
|
||||
It can read/parse and write/dump the overviewerConfig.js file into this top-level
|
||||
directory.
|
||||
"""
|
||||
self.outputdir = outputdir
|
||||
self.custom_assets_dir = custom_assets_dir
|
||||
self.renders = dict()
|
||||
|
||||
# look for overviewerConfig in self.outputdir
|
||||
@@ -141,7 +142,12 @@ directory.
|
||||
global_assets = os.path.join(util.get_program_path(), "web_assets")
|
||||
mirror_dir(global_assets, self.outputdir)
|
||||
|
||||
# write a dummy baseMarkers.js if none exists
|
||||
if self.custom_assets_dir:
|
||||
# Could have done something fancy here rather than just overwriting
|
||||
# the global files, but apparently this what we used to do pre-rewrite.
|
||||
mirror_dir(self.custom_assets_dir, self.outputdir)
|
||||
|
||||
# write a dummy baseMarkers.js if none exists
|
||||
if not os.path.exists(os.path.join(self.outputdir, "baseMarkers.js")):
|
||||
with open(os.path.join(self.outputdir, "baseMarkers.js"), "w") as f:
|
||||
f.write("// if you wants signs, please see genPOI.py\n");
|
||||
|
||||
@@ -84,7 +84,7 @@ renders = Setting(required=True, default=util.OrderedDict(),
|
||||
"showspawn": Setting(required=False, validator=validateBool, default=True),
|
||||
"base": Setting(required=False, validator=validateStr, default=""),
|
||||
"poititle": Setting(required=False, validator=validateStr, default="Signs"),
|
||||
|
||||
"customwebassets": Setting(required=False, validator=validateWebAssetsPath, default=None),
|
||||
# Remove this eventually (once people update their configs)
|
||||
"worldname": Setting(required=False, default=None,
|
||||
validator=error("The option 'worldname' is now called 'world'. Please update your config files")),
|
||||
|
||||
@@ -214,6 +214,18 @@ def validateDefaultZoom(z):
|
||||
else:
|
||||
raise ValidationException("The default zoom is set below 1")
|
||||
|
||||
def validateWebAssetsPath(p):
|
||||
try:
|
||||
validatePath(p)
|
||||
except ValidationException as e:
|
||||
raise ValidationException("Bad custom web assets path: %s" % e.message)
|
||||
|
||||
def validatePath(p):
|
||||
_, path = checkBadEscape(p)
|
||||
abs_path = expand_path(path)
|
||||
if not os.path.exists(abs_path):
|
||||
raise ValidationException("'%s' does not exist. Path initially given as '%s'" % (abs_path,p))
|
||||
|
||||
def make_dictValidator(keyvalidator, valuevalidator):
|
||||
"""Compose and return a dict validator -- a validator that validates each
|
||||
key and value in a dictionary.
|
||||
|
||||
Reference in New Issue
Block a user