let the template generator compute relative paths
Instead of hard-coding paths to the css, js, and images directories let the template generator compute those and pass them to the template context. Change-Id: I27a55deeb68136fa826496ec3d0223a303346724 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
f7b5b56b34
commit
4017c3e019
@ -16,6 +16,7 @@ import argparse
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
@ -239,6 +240,7 @@ def main():
|
||||
|
||||
# Set up jinja to discover the templates.
|
||||
try:
|
||||
logger.info('looking for templates in %s', args.source_directory)
|
||||
loader = jinja2.FileSystemLoader(args.source_directory)
|
||||
environment = jinja2.Environment(loader=loader)
|
||||
except Exception as e:
|
||||
@ -254,6 +256,15 @@ def main():
|
||||
|
||||
logger.info("generating %s", templateFile)
|
||||
|
||||
# Determine the relative path to a few common directories so
|
||||
# we don't need to set them in the templates.
|
||||
topdir = os.path.relpath(
|
||||
'.', os.path.dirname(templateFile),
|
||||
).rstrip('/') + '/'
|
||||
scriptdir = os.path.join(topdir, 'common', 'js').rstrip('/') + '/'
|
||||
cssdir = os.path.join(topdir, 'common', 'css').rstrip('/') + '/'
|
||||
imagedir = os.path.join(topdir, 'common', 'images').rstrip('/') + '/'
|
||||
|
||||
try:
|
||||
template = environment.get_template(templateFile)
|
||||
except Exception as e:
|
||||
@ -267,6 +278,10 @@ def main():
|
||||
TEMPLATE_FILE=templateFile,
|
||||
REGULAR_REPOS=regular_repos,
|
||||
INFRA_REPOS=infra_repos,
|
||||
topdir=topdir,
|
||||
scriptdir=scriptdir,
|
||||
cssdir=cssdir,
|
||||
imagedir=imagedir,
|
||||
)
|
||||
if templateFile.endswith('.html'):
|
||||
soup = BeautifulSoup(output, "lxml")
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Administrator Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,8 +1,5 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}API references{% endblock %}
|
||||
{% block title %}API references{% endblock %}
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Configuration Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}German{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Draft{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -8,7 +8,6 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>404 Not Found</title>
|
||||
<!-- CSS in: {{ cssdir }}-->
|
||||
{% set cssdir = './common/css/' %}
|
||||
{% include 'templates/css.tmpl' %}
|
||||
{% block content %}
|
||||
<!-- Begin Page Content -->
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}French{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Indonesian{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = './common/js/' %}
|
||||
{% set cssdir = './common/css/' %}
|
||||
{% extends "templates/indexbase.tmpl" %}
|
||||
{% block pagetitle %}Ocata{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Italiano{% endblock %}
|
||||
{% block title %} Documentazione{% endblock %}
|
||||
|
@ -1,6 +1,3 @@
|
||||
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Japanese{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Kilo{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Korean{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% set scriptdir = './common/js/' %}
|
||||
{% set cssdir = './common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Language bindings{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Liberty{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Mitaka{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Newton{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Ocata{% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% set scriptdir = './common/js/' %}
|
||||
{% set cssdir = './common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Services and Libraries{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Draft Deployment Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Newton Deployment Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Ocata Deployment Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,10 +1,5 @@
|
||||
{% set series = "latest" %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% set imagedir = '../../common/images/' %}
|
||||
|
||||
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Draft Installation Tutorials and Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,6 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% set imagedir = '../../common/images/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Newton Installation Tutorials and Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,6 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% set imagedir = '../../common/images/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Ocata Installation Tutorials and Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,6 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% set imagedir = '../../common/images/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Ocata Installation Tutorials and Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,6 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% set imagedir = '../../common/images/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Ocata Installation Tutorials and Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,6 +1,3 @@
|
||||
{% set scriptdir = '../../common/js/' %}
|
||||
{% set cssdir = '../../common/css/' %}
|
||||
{% set imagedir = '../../common/images/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Ocata Installation Tutorials and Guides{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Portuguese{% endblock %}
|
||||
{% block title %} Documentação{% endblock %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Training Labs{% endblock %}
|
||||
{% block title %}
|
||||
|
@ -1,5 +1,3 @@
|
||||
{% set scriptdir = '../common/js/' %}
|
||||
{% set cssdir = '../common/css/' %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Chinese(Simplified){% endblock %}
|
||||
{% block title %}{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user