diff --git a/tools/www-generator.py b/tools/www-generator.py index be63f27f88..f2af9eb2ba 100755 --- a/tools/www-generator.py +++ b/tools/www-generator.py @@ -17,6 +17,7 @@ import glob import logging import os import os.path +import re import sys from bs4 import BeautifulSoup @@ -26,6 +27,10 @@ import requests import yaml +SERIES_PAT = re.compile('^(mitaka|newton|ocata|pike|queens|rocky)/') +LATEST_SERIES = 'pike' + + def initialize_logging(debug, verbose): """Initialize the Logger.""" @@ -257,6 +262,15 @@ def render_template(environment, project_data, regular_repos, infra_repos, cssdir = os.path.join(topdir, 'common', 'css').rstrip('/') + '/' imagedir = os.path.join(topdir, 'common', 'images').rstrip('/') + '/' + series_match = SERIES_PAT.match(template_file) + if series_match: + series = series_match.groups()[0] + if series == LATEST_SERIES: + series = 'latest' + else: + series = None + logger.info('series = %s', series) + try: template = environment.get_template(template_file) except Exception as e: @@ -274,6 +288,7 @@ def render_template(environment, project_data, regular_repos, infra_repos, scriptdir=scriptdir, cssdir=cssdir, imagedir=imagedir, + series=series, **extra ) if template_file.endswith('.html'): diff --git a/www/pike/admin/index.html b/www/pike/admin/index.html index 94a4d689f8..2f47d7791b 100644 --- a/www/pike/admin/index.html +++ b/www/pike/admin/index.html @@ -1,4 +1,3 @@ -{% set series = 'latest' %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Administrator Guides{% endblock %} diff --git a/www/pike/api/index.html b/www/pike/api/index.html index a1a4ca0c87..2ea66edbb4 100644 --- a/www/pike/api/index.html +++ b/www/pike/api/index.html @@ -1,4 +1,3 @@ -{% set series = 'latest' %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}API references{% endblock %} diff --git a/www/pike/configuration/index.html b/www/pike/configuration/index.html index 3fa990996a..05693a0fd5 100644 --- a/www/pike/configuration/index.html +++ b/www/pike/configuration/index.html @@ -1,4 +1,3 @@ -{% set series = 'latest' %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Configuration Guides{% endblock %} diff --git a/www/pike/install/index.html b/www/pike/install/index.html index bb6877ee5b..bf9e1fc81b 100644 --- a/www/pike/install/index.html +++ b/www/pike/install/index.html @@ -1,4 +1,3 @@ -{% set series = "latest" %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Draft Installation Tutorials and Guides{% endblock %} diff --git a/www/pike/language-bindings.html b/www/pike/language-bindings.html index c4cf78fd13..08636484eb 100644 --- a/www/pike/language-bindings.html +++ b/www/pike/language-bindings.html @@ -1,4 +1,3 @@ -{% set series = 'latest' %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Language bindings{% endblock %} diff --git a/www/pike/projects.html b/www/pike/projects.html index 733a2f30f8..018c4f5bef 100644 --- a/www/pike/projects.html +++ b/www/pike/projects.html @@ -1,4 +1,3 @@ -{% set series = 'latest' %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}Services and Libraries{% endblock %} diff --git a/www/pike/user/index.html b/www/pike/user/index.html index bef4d32ec6..0430b9940a 100644 --- a/www/pike/user/index.html +++ b/www/pike/user/index.html @@ -1,4 +1,3 @@ -{% set series = 'latest' %} {% set projects = PROJECT_DATA[series] %} {% extends "templates/base.tmpl" %} {% block pagetitle %}User Guides{% endblock %}