have the page generator set the series for each page
Instead of setting the series for each page within the page by hand, have the template rendering code derive the value based on the path to the template. Change-Id: I366e809b710e5766c6345d817afc2717eff5e0a8 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
ead734f5c5
commit
fed641fe66
@ -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'):
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Administrator Guides{% endblock %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}API references{% endblock %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Configuration Guides{% endblock %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = "latest" %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Draft Installation Tutorials and Guides{% endblock %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Language bindings{% endblock %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}Services and Libraries{% endblock %}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% set series = 'latest' %}
|
||||
{% set projects = PROJECT_DATA[series] %}
|
||||
{% extends "templates/base.tmpl" %}
|
||||
{% block pagetitle %}User Guides{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user