diff --git a/tools/www-generator.py b/tools/www-generator.py index 61d203b337..46be283fc7 100755 --- a/tools/www-generator.py +++ b/tools/www-generator.py @@ -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") diff --git a/www/admin/index.html b/www/admin/index.html index c017cab1a4..868dfa030e 100644 --- a/www/admin/index.html +++ b/www/admin/index.html @@ -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 %} diff --git a/www/api/index.html b/www/api/index.html index 56905693ba..9beb29ba96 100644 --- a/www/api/index.html +++ b/www/api/index.html @@ -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 %} diff --git a/www/configuration/index.html b/www/configuration/index.html index b0af2a29e8..1ed9bf4beb 100644 --- a/www/configuration/index.html +++ b/www/configuration/index.html @@ -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 %} diff --git a/www/de/index.html b/www/de/index.html index 46b4d56206..6be3c17549 100644 --- a/www/de/index.html +++ b/www/de/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}German{% endblock %} {% block title %}{% endblock %} diff --git a/www/draft/draft-index.html b/www/draft/draft-index.html index 5b50be55e7..c91a7ec0bd 100644 --- a/www/draft/draft-index.html +++ b/www/draft/draft-index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Draft{% endblock %} {% block title %}{% endblock %} diff --git a/www/errorpage.html b/www/errorpage.html index 51ef1bdcf1..d899b5c548 100644 --- a/www/errorpage.html +++ b/www/errorpage.html @@ -8,7 +8,6 @@ 404 Not Found -{% set cssdir = './common/css/' %} {% include 'templates/css.tmpl' %} {% block content %} diff --git a/www/fr/index.html b/www/fr/index.html index 871f99a0e0..270dc3ba00 100644 --- a/www/fr/index.html +++ b/www/fr/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}French{% endblock %} {% block title %}{% endblock %} diff --git a/www/id/index.html b/www/id/index.html index f253f220d7..bd6125a66c 100644 --- a/www/id/index.html +++ b/www/id/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Indonesian{% endblock %} {% block title %}{% endblock %} diff --git a/www/index.html b/www/index.html index beb1e048d7..d7006d4678 100644 --- a/www/index.html +++ b/www/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = './common/js/' %} -{% set cssdir = './common/css/' %} {% extends "templates/indexbase.tmpl" %} {% block pagetitle %}Ocata{% endblock %} {% block title %}{% endblock %} diff --git a/www/it/index.html b/www/it/index.html index 87f9ea0a51..32a795fade 100644 --- a/www/it/index.html +++ b/www/it/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Italiano{% endblock %} {% block title %} Documentazione{% endblock %} diff --git a/www/ja/index.html b/www/ja/index.html index a22b0fbff0..d287e5fba7 100644 --- a/www/ja/index.html +++ b/www/ja/index.html @@ -1,6 +1,3 @@ - -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Japanese{% endblock %} {% block title %}{% endblock %} diff --git a/www/kilo/index.html b/www/kilo/index.html index 6fcf6b7e53..4f149d6ce8 100644 --- a/www/kilo/index.html +++ b/www/kilo/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Kilo{% endblock %} {% block title %}{% endblock %} diff --git a/www/ko_KR/index.html b/www/ko_KR/index.html index c4f2a62907..4a8b3dc9b0 100644 --- a/www/ko_KR/index.html +++ b/www/ko_KR/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Korean{% endblock %} {% block title %}{% endblock %} diff --git a/www/language-bindings.html b/www/language-bindings.html index eb9bfdd09f..fa43a2d187 100644 --- a/www/language-bindings.html +++ b/www/language-bindings.html @@ -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 %} diff --git a/www/liberty/index.html b/www/liberty/index.html index 71741237b3..4ac5d83eab 100644 --- a/www/liberty/index.html +++ b/www/liberty/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Liberty{% endblock %} {% block title %}{% endblock %} diff --git a/www/mitaka/index.html b/www/mitaka/index.html index 467d217f68..70ae100be6 100644 --- a/www/mitaka/index.html +++ b/www/mitaka/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Mitaka{% endblock %} {% block title %}{% endblock %} diff --git a/www/newton/index.html b/www/newton/index.html index 1bda332939..cae58763eb 100644 --- a/www/newton/index.html +++ b/www/newton/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Newton{% endblock %} {% block title %}{% endblock %} diff --git a/www/ocata/index.html b/www/ocata/index.html index 2308ce71d0..9ec6ab0edd 100644 --- a/www/ocata/index.html +++ b/www/ocata/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Ocata{% endblock %} {% block title %}{% endblock %} diff --git a/www/openstack-projects.html b/www/openstack-projects.html index 0649ab7980..733a2f30f8 100644 --- a/www/openstack-projects.html +++ b/www/openstack-projects.html @@ -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 %} diff --git a/www/project-deploy-guide/draft/index.html b/www/project-deploy-guide/draft/index.html index 1c1e7fc5a1..b53a195dd6 100644 --- a/www/project-deploy-guide/draft/index.html +++ b/www/project-deploy-guide/draft/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../../common/js/' %} -{% set cssdir = '../../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Draft Deployment Guides{% endblock %} {% block title %} diff --git a/www/project-deploy-guide/newton/index.html b/www/project-deploy-guide/newton/index.html index b052ef6609..0604bde5fe 100644 --- a/www/project-deploy-guide/newton/index.html +++ b/www/project-deploy-guide/newton/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../../common/js/' %} -{% set cssdir = '../../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Newton Deployment Guides{% endblock %} {% block title %} diff --git a/www/project-deploy-guide/ocata/index.html b/www/project-deploy-guide/ocata/index.html index 93d8262ced..e1a0d9ff40 100644 --- a/www/project-deploy-guide/ocata/index.html +++ b/www/project-deploy-guide/ocata/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../../common/js/' %} -{% set cssdir = '../../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Ocata Deployment Guides{% endblock %} {% block title %} diff --git a/www/project-install-guide/draft/index.html b/www/project-install-guide/draft/index.html index 2dcd54871c..ff4e1b5e80 100644 --- a/www/project-install-guide/draft/index.html +++ b/www/project-install-guide/draft/index.html @@ -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 %} diff --git a/www/project-install-guide/newton/index.html b/www/project-install-guide/newton/index.html index 0357570aea..8aa0c26341 100644 --- a/www/project-install-guide/newton/index.html +++ b/www/project-install-guide/newton/index.html @@ -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 %} diff --git a/www/project-install-guide/ocata/index.html b/www/project-install-guide/ocata/index.html index aea79598ff..ced9939ca7 100644 --- a/www/project-install-guide/ocata/index.html +++ b/www/project-install-guide/ocata/index.html @@ -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 %} diff --git a/www/project-install-guide/ocata/obs-services.html b/www/project-install-guide/ocata/obs-services.html index cff5e54a90..13eb3b2ea9 100644 --- a/www/project-install-guide/ocata/obs-services.html +++ b/www/project-install-guide/ocata/obs-services.html @@ -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 %} diff --git a/www/project-install-guide/ocata/rdo-services.html b/www/project-install-guide/ocata/rdo-services.html index 620f6efe22..183c6263b7 100644 --- a/www/project-install-guide/ocata/rdo-services.html +++ b/www/project-install-guide/ocata/rdo-services.html @@ -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 %} diff --git a/www/project-install-guide/ocata/ubuntu-services.html b/www/project-install-guide/ocata/ubuntu-services.html index 63628691c0..e73113010e 100644 --- a/www/project-install-guide/ocata/ubuntu-services.html +++ b/www/project-install-guide/ocata/ubuntu-services.html @@ -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 %} diff --git a/www/pt_BR/index.html b/www/pt_BR/index.html index 6c70922093..cc589e3b25 100644 --- a/www/pt_BR/index.html +++ b/www/pt_BR/index.html @@ -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 %} diff --git a/www/training_labs/index.html b/www/training_labs/index.html index f9584d0dd6..1db208e439 100644 --- a/www/training_labs/index.html +++ b/www/training_labs/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Training Labs{% endblock %} {% block title %} diff --git a/www/zh_CN/index.html b/www/zh_CN/index.html index 6564c006bf..5bb0b5d233 100644 --- a/www/zh_CN/index.html +++ b/www/zh_CN/index.html @@ -1,5 +1,3 @@ -{% set scriptdir = '../common/js/' %} -{% set cssdir = '../common/css/' %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Chinese(Simplified){% endblock %} {% block title %}{% endblock %}