Commit a4b82914 authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

index properly working with INDEX_SCRIPTS and INDEX_STYLESHEETS

parent 706ec871
...@@ -258,10 +258,13 @@ def add_attribute_to_links (src, attrname, attrvalue): ...@@ -258,10 +258,13 @@ def add_attribute_to_links (src, attrname, attrvalue):
return innerHTML(t) return innerHTML(t)
def template_action (target, source, env): def template_action (target, source, env):
tpath, tname = os.path.split((env.Dictionary().get("INDEX_TEMPLATE") or "templates/index.html")) envd = env.Dictionary()
rootpath = os.path.abspath(env.Dictionary().get("SCONS_ROOT")) tpath, tname = os.path.split((envd.get("INDEX_TEMPLATE") or "templates/index.html"))
index_scripts = (env.Dictionary().get("INDEX_SCRIPTS") or "").split(":") rootpath = os.path.abspath(envd.get("SCONS_ROOT"))
index_stylesheets = (env.Dictionary().get("INDEX_STYLESHEETS") or "").split(":") index_scripts = (envd.get("INDEX_SCRIPTS") or "").split(":")
index_stylesheets = (envd.get("INDEX_STYLESHEETS") or "").split(":")
index_scripts = [x for x in index_scripts if x] # eliminate blank elements
index_stylesheets = [x for x in index_stylesheets if x]
# print (f"template_action, rootpath: {rootpath}") # print (f"template_action, rootpath: {rootpath}")
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(tpath)) jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(tpath))
...@@ -466,9 +469,13 @@ for folder, deps in depwalk("."): ...@@ -466,9 +469,13 @@ for folder, deps in depwalk("."):
depsmeta.append(file_meta) depsmeta.append(file_meta)
env.FolderMeta(target=folder_meta_path, source=deps+depsmeta) env.FolderMeta(target=folder_meta_path, source=deps+depsmeta)
index_template = os.environ.get("INDEX_TEMPLATE")
template_sources = [folder_meta_path]
if index_template:
template_sources.append(index_template)
env.Template(target=os.path.join(folder, "index.html"), \ env.Template(target=os.path.join(folder, "index.html"), \
source=folder_meta_path, \ source=template_sources, \
INDEX_TEMPLATE=os.environ.get("INDEX_TEMPLATE"), \ INDEX_TEMPLATE=index_template, \
INDEX_SCRIPTS=os.environ.get("INDEX_SCRIPTS"), \ INDEX_SCRIPTS=os.environ.get("INDEX_SCRIPTS"), \
INDEX_STYLESHEETS=os.environ.get("INDEX_STYLESHEETS"), \ INDEX_STYLESHEETS=os.environ.get("INDEX_STYLESHEETS"), \
SCONS_ROOT=os.environ.get("SCONS_ROOT") or rootdir.abspath SCONS_ROOT=os.environ.get("SCONS_ROOT") or rootdir.abspath
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Index of {{filename|default("/", True)}}</title> <title>Index of {{filename|default("/", True)}}</title>
{% for stylesheet in stylesheets -%} {%- for stylesheet in stylesheets %}
<link rel="stylesheet" type="text/css" href="{{stylesheet}}"> <link rel="stylesheet" type="text/css" href="{{stylesheet}}">
{%- endfor %} {%- endfor %}
{% for scripts in scripts -%} {%- for script in scripts %}
<script src="{{script}}"></script> <script src="{{script}}"></script>
{%- endfor %} {%- endfor %}
</head> </head>
......
...@@ -12,7 +12,8 @@ def main (args): ...@@ -12,7 +12,8 @@ def main (args):
else: else:
sconstruct_path = os.path.join(datapath, "templates", "Sconstruct.py") sconstruct_path = os.path.join(datapath, "templates", "Sconstruct.py")
env = os.environ.copy() env = os.environ.copy()
env['INDEX_TEMPLATE'] = template_path if 'INDEX_TEMPLATE' not in env:
env['INDEX_TEMPLATE'] = template_path
cmd = ["scons", "-f", sconstruct_path] + args.path cmd = ["scons", "-f", sconstruct_path] + args.path
if not args.notquiet: if not args.notquiet:
cmd.append("--quiet") cmd.append("--quiet")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment