New UI control to toggle signposts on/off based on their content.
Pretty substantial javascript refactoring: * All javascript is now in funtions.js. There is no javascript at all in index.html * Configuration options moved from template.html to config.js template.html moved to web_assets/index.html config.js allows you to specify pattern-label pairs. Each label will be added to an on-screen "signposts" control. Clicking the checkbox by each label will show/hide any signposts that match the pattern attached to that label. config.js has some examples. TODO: * The signposts control needs better styling. * The new javascript needs testing in IE. Seems ok in Chome and FF. These large changes may be hard to merge if you have non-trivial JS changes to template.html locally. Apologies in advance
This commit is contained in:
21
quadtree.py
21
quadtree.py
@@ -125,19 +125,20 @@ class QuadtreeGen(object):
|
||||
complete, total, level, self.p))
|
||||
|
||||
def write_html(self, skipjs=False):
|
||||
"""Writes out index.html, marker.js, and region.js"""
|
||||
"""Writes out config.js, marker.js, and region.js
|
||||
Copies web assets into the destdir"""
|
||||
zoomlevel = self.p
|
||||
imgformat = self.imgformat
|
||||
templatepath = os.path.join(util.get_program_path(), "template.html")
|
||||
configpath = os.path.join(util.get_program_path(), "config.js")
|
||||
|
||||
html = open(templatepath, 'r').read()
|
||||
html = html.replace(
|
||||
config = open(configpath, 'r').read()
|
||||
config = config.replace(
|
||||
"{maxzoom}", str(zoomlevel))
|
||||
html = html.replace(
|
||||
config = config.replace(
|
||||
"{imgformat}", str(imgformat))
|
||||
|
||||
with open(os.path.join(self.destdir, "index.html"), 'w') as output:
|
||||
output.write(html)
|
||||
with open(os.path.join(self.destdir, "config.js"), 'w') as output:
|
||||
output.write(config)
|
||||
|
||||
# Write a blank image
|
||||
blank = Image.new("RGBA", (1,1))
|
||||
@@ -181,11 +182,11 @@ class QuadtreeGen(object):
|
||||
|
||||
def _get_cur_depth(self):
|
||||
"""How deep is the quadtree currently in the destdir? This glances in
|
||||
index.html to see what maxZoom is set to.
|
||||
config.js to see what maxZoom is set to.
|
||||
returns -1 if it couldn't be detected, file not found, or nothing in
|
||||
index.html matched
|
||||
config.js matched
|
||||
"""
|
||||
indexfile = os.path.join(self.destdir, "index.html")
|
||||
indexfile = os.path.join(self.destdir, "config.js")
|
||||
if not os.path.exists(indexfile):
|
||||
return -1
|
||||
matcher = re.compile(r"maxZoom:\s*(\d+)")
|
||||
|
||||
Reference in New Issue
Block a user