From 19160564055f092afb00134078c5a59e2e0f883d Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 30 Aug 2018 09:13:34 -0400 Subject: [PATCH] build the redirects for the project-deploy-guide dynamically Pass the list of maintained series to the template environment so we can use that list to generate all of the redirects to the project deploy guide pages instead of having to update the list of series in two places. The newton series is handled as a special case because it exists but is not considered maintained. Change-Id: I10794819260f1edd54e3711258ab715910ccf20f Signed-off-by: Doug Hellmann --- tools/www-generator.py | 10 +++++++--- www/.htaccess | 6 +++++- www/redirect-tests.txt | 8 ++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tools/www-generator.py b/tools/www-generator.py index 94a62ac9c9..99cc1ee643 100755 --- a/tools/www-generator.py +++ b/tools/www-generator.py @@ -70,12 +70,15 @@ PAST_SERIES = [ if info.status != 'development' ] -# Find the most recently released series. -RELEASED_SERIES = [ +# Find the currently maintained series. +MAINTAINED_SERIES = [ name for name, info in sorted(SERIES_INFO.items()) if info.status == 'maintained' -][-1] +] + +# Find the most recently released series. +RELEASED_SERIES = MAINTAINED_SERIES[-1] # Find the series being developed. SERIES_IN_DEVELOPMENT = [ @@ -436,6 +439,7 @@ def render_template(environment, project_data, regular_repos, infra_repos, ALL_SERIES=ALL_SERIES, PAST_SERIES=PAST_SERIES, RELEASED_SERIES=RELEASED_SERIES, + MAINTAINED_SERIES=MAINTAINED_SERIES, SERIES_IN_DEVELOPMENT=SERIES_IN_DEVELOPMENT, TOPDIR=topdir, SCRIPTDIR=scriptdir, diff --git a/www/.htaccess b/www/.htaccess index de6e335c56..8d399f0122 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -151,7 +151,11 @@ redirect 301 /doc-contrib-guide/ui-text-guidelines.html /doc-contrib-guide/ux-ui redirect 301 /doc-contrib-guide/ui-text-guidelines /doc-contrib-guide/ux-ui-guidelines # Redirect deploy guides to their branch index. -{{ dir_to_page('/project-deploy-guide/(newton|ocata|pike|queens|rocky)', '/$1/deploy/') }} +{# newton is a special case because it exists but is not maintained #} +{{ dir_to_page('/project-deploy-guide/(newton)', '/$1/deploy/') }} +{% for series in MAINTAINED_SERIES %} +{{ dir_to_page('/project-deploy-guide/(' + series + ')', '/$1/deploy/') }} +{% endfor %} # Redirect any deploy guide project directory back to the current stable index {{ path_to_released_series('/project-deploy-guide/?$', '/deploy/') }} diff --git a/www/redirect-tests.txt b/www/redirect-tests.txt index 829ec82d15..697f5417e6 100644 --- a/www/redirect-tests.txt +++ b/www/redirect-tests.txt @@ -170,11 +170,11 @@ # Redirect any deploy guide project directory back to the current stable index {{ dir_to_page('/project-deploy-guide', '/' + RELEASED_SERIES + '/deploy/') }} # Redirect all the project deploy folders to their appropriate branch +{# newton is a special case because it exists but is not maintained #} {{ dir_to_page('/project-deploy-guide/newton', '/newton/deploy/') }} -{{ dir_to_page('/project-deploy-guide/ocata', '/ocata/deploy/') }} -{{ dir_to_page('/project-deploy-guide/pike', '/pike/deploy/') }} -{{ dir_to_page('/project-deploy-guide/queens', '/queens/deploy/') }} -{{ dir_to_page('/project-deploy-guide/rocky', '/rocky/deploy/') }} +{% for series in MAINTAINED_SERIES %} +{{ dir_to_page('/project-deploy-guide/' + series, '/' + series + '/deploy/') }} +{% endfor %} # Ensure each project's deloy guide is reachable. /project-deploy-guide/openstack-ansible/latest/ 200 /project-deploy-guide/openstack-ansible/pike/ 200