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):
return innerHTML(t)
def template_action (target, source, env):
tpath, tname = os.path.split((env.Dictionary().get("INDEX_TEMPLATE") or "templates/index.html"))
rootpath = os.path.abspath(env.Dictionary().get("SCONS_ROOT"))
index_scripts = (env.Dictionary().get("INDEX_SCRIPTS") or "").split(":")
index_stylesheets = (env.Dictionary().get("INDEX_STYLESHEETS") or "").split(":")
envd = env.Dictionary()
tpath, tname = os.path.split((envd.get("INDEX_TEMPLATE") or "templates/index.html"))
rootpath = os.path.abspath(envd.get("SCONS_ROOT"))
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}")
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(tpath))
......@@ -466,9 +469,13 @@ for folder, deps in depwalk("."):
depsmeta.append(file_meta)
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"), \
source=folder_meta_path, \
INDEX_TEMPLATE=os.environ.get("INDEX_TEMPLATE"), \
source=template_sources, \
INDEX_TEMPLATE=index_template, \
INDEX_SCRIPTS=os.environ.get("INDEX_SCRIPTS"), \
INDEX_STYLESHEETS=os.environ.get("INDEX_STYLESHEETS"), \
SCONS_ROOT=os.environ.get("SCONS_ROOT") or rootdir.abspath
......
......@@ -4,10 +4,10 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Index of {{filename|default("/", True)}}</title>
{% for stylesheet in stylesheets -%}
{%- for stylesheet in stylesheets %}
<link rel="stylesheet" type="text/css" href="{{stylesheet}}">
{%- endfor %}
{% for scripts in scripts -%}
{%- for script in scripts %}
<script src="{{script}}"></script>
{%- endfor %}
</head>
......
......@@ -12,6 +12,7 @@ def main (args):
else:
sconstruct_path = os.path.join(datapath, "templates", "Sconstruct.py")
env = os.environ.copy()
if 'INDEX_TEMPLATE' not in env:
env['INDEX_TEMPLATE'] = template_path
cmd = ["scons", "-f", sconstruct_path] + args.path
if not args.notquiet:
......
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