From 079714fe215cbc1da75250c1c75176d9b8f9a4ed Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 31 Jul 2017 17:21:01 -0400 Subject: [PATCH] add has_in_tree_htaccess flag to template generator Add a flag to tell us which projects have a .htaccess file in their doc build output. Change-Id: I0af0e32d9c646d61f4c72599cdc4613299aa5ec9 Depends-On: I236b7b0a9aae065167bd0aef316603d258e4c3c6 Signed-off-by: Doug Hellmann --- .../source/doc-tools/template-generator.rst | 4 ++++ www/.htaccess | 14 +++++++++++--- www/project-data/schema.yaml | 2 ++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/contributor-guide/source/doc-tools/template-generator.rst b/doc/contributor-guide/source/doc-tools/template-generator.rst index a75dde1f96..d8fe87265b 100644 --- a/doc/contributor-guide/source/doc-tools/template-generator.rst +++ b/doc/contributor-guide/source/doc-tools/template-generator.rst @@ -142,6 +142,10 @@ include a link to that documentation on the templated landing pages. ``has_admin_guide`` produces a link to docs.o.o/name/latest/admin/ +``has_in_tree_htaccess`` + enables full redirects to old paths, not just to the top of + /name/latest/ + .. note:: The documentation associated with the flags must exist before the diff --git a/www/.htaccess b/www/.htaccess index b981defb59..3c408fc1e6 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -60,9 +60,17 @@ redirectmatch 301 "^/project-install-guide/ocata/(.*)$" /ocata/install/$1 # Redirecting infra docs links to new developer location redirectmatch 301 "^/infra/shade(.*)$" /developer/shade$1 -# Redirecting old project developer docs to the new project home pages -# while leaving the index / project list page as it is. -redirectmatch 301 "^/developer/([^/]+)/.*$" /$1/latest/ +# Redirecting old project developer docs to the new layout. If a +# project has an in-tree .htaccess file, assume it can handle the full +# path in the redirect. Otherwise, redirect everything to the new +# latest index.html. +{% for project in projects|sort(attribute='name') -%} +{%- if project.has_in_tree_htaccess %} +redirectmatch 301 "^/developer/{{project.name}}/(.*)$" /{{project.name}}/latest/$1 +{%- else %} +redirectmatch 301 "^/developer/{{project.name}}/.*$" /{{project.name}}/latest/ +{%- endif %} +{%- endfor %} # Redirect old cli-reference to the OSC latest docs redirectmatch 301 "^/cli-reference/.*$" /python-openstackclient/latest/ diff --git a/www/project-data/schema.yaml b/www/project-data/schema.yaml index c7a599a772..b37a7f9f03 100644 --- a/www/project-data/schema.yaml +++ b/www/project-data/schema.yaml @@ -41,3 +41,5 @@ items: type: boolean has_user_guide: type: boolean + has_in_tree_htaccess: + type: boolean