From dbd704f3355c6dfbf43460d79e59ec9f2ab63280 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 3 Jan 2019 00:13:40 +0000 Subject: [PATCH] Provide dropdown menu which allows switching doc release Currently deprecation badge headers just point back to the root of the documentation for the latest stable release, so for example the badge at the top of https://docs.openstack.org/latest/user/index.html just points to https://docs.openstack.org/rocky/ It's useful to be able to quickly jump between different releases of the same documentation page, but currently this requires hand-editing URLs or many extra manual hops in the navigation trail. So automatically generate the links, but only display them if the link target exists. Since the main portal page for each release already had a "More Releases" dropdown, remove that to avoid two dropdowns on the portal pages. Change-Id: I2498f00a6c863d078a70289a655b0aa3958325ed --- .../source/doc-tools/template-generator.rst | 2 +- tools/www-generator.py | 14 ++++-- www/de/index.html | 2 +- www/fr/index.html | 2 +- www/id/index.html | 2 +- www/ja/index.html | 2 +- www/ko_KR/index.html | 2 +- www/mitaka/de/index.html | 2 +- www/newton/de/index.html | 2 +- www/ocata/de/index.html | 2 +- www/static/common/css/combined.css | 3 +- www/static/common/css/deprecated-badge.css | 23 ++++++++-- www/templates/deprecated_badge.tmpl | 44 +++++++++---------- ...languages.tmpl => dropdown_languages.tmpl} | 11 ----- www/templates/indexbase.tmpl | 2 +- www/templates/series_status.tmpl | 6 +-- www/templates/switch_releases.tmpl | 42 ++++++++++++++++++ www/tr_TR/index.html | 2 +- www/zh_CN/index.html | 2 +- 19 files changed, 111 insertions(+), 56 deletions(-) rename www/templates/{dropdown_releases_and_languages.tmpl => dropdown_languages.tmpl} (64%) create mode 100644 www/templates/switch_releases.tmpl diff --git a/doc/doc-contrib-guide/source/doc-tools/template-generator.rst b/doc/doc-contrib-guide/source/doc-tools/template-generator.rst index bf6e7ba393..65f9c6bd48 100644 --- a/doc/doc-contrib-guide/source/doc-tools/template-generator.rst +++ b/doc/doc-contrib-guide/source/doc-tools/template-generator.rst @@ -121,7 +121,7 @@ Here are a few representative files under ``www/``: * ``contributor_guides.tmpl`` * ``css.tmpl`` * ``default.tmpl`` - * ``dropdown_releases_and_languages.tmpl`` + * ``dropdown_languages.tmpl`` * ``footer.tmpl`` * ``google_analytics.tmpl`` * ``header.tmpl`` diff --git a/tools/www-generator.py b/tools/www-generator.py index 087d070013..85bc1a7286 100755 --- a/tools/www-generator.py +++ b/tools/www-generator.py @@ -474,7 +474,7 @@ def _get_official_repos(): def render_template(environment, project_data, regular_repos, infra_repos, - template_file, output_directory, extra={}): + template_files, template_file, output_directory, extra={}): logger = logging.getLogger() logger.info("generating %s", template_file) @@ -490,15 +490,18 @@ def render_template(environment, project_data, regular_repos, infra_repos, series_match = SERIES_PAT.match(template_file) if series_match: series = series_match.groups()[0] + series_path_prefix = series series_title = series.title() series_info = SERIES_INFO[series] if series == SERIES_IN_DEVELOPMENT: series = 'latest' else: series = None + series_path_prefix = None series_title = '' series_info = SeriesInfo('', '') - logger.info('series = %s', series) + logger.info('series = %s, path prefix = %s, title = %s', + series, series_path_prefix, series_title) try: template = environment.get_template(template_file) @@ -511,6 +514,7 @@ def render_template(environment, project_data, regular_repos, infra_repos, output = template.render( PROJECT_DATA=project_data, TEMPLATE_FILE=template_file, + TEMPLATE_FILES={f: True for f in template_files}, REGULAR_REPOS=regular_repos, INFRA_REPOS=infra_repos, ALL_SERIES=ALL_SERIES, @@ -523,6 +527,7 @@ def render_template(environment, project_data, regular_repos, infra_repos, CSSDIR=cssdir, IMAGEDIR=imagedir, SERIES=series, + SERIES_PATH_PREFIX=series_path_prefix, SERIES_TITLE=series_title, SERIES_INFO=series_info, **extra @@ -585,7 +590,8 @@ def main(): # Render the templates. output_pages = [] page_list_template = None - for template_file in environment.list_templates(): + template_files = environment.list_templates() + for template_file in template_files: if (template_file.startswith('static/') or template_file.startswith('templates/')): logger.info('ignoring %s', template_file) @@ -600,6 +606,7 @@ def main(): project_data, regular_repos, infra_repos, + template_files, template_file, args.output_directory, ) @@ -612,6 +619,7 @@ def main(): project_data, regular_repos, infra_repos, + template_files, page_list_template, args.output_directory, extra={ diff --git a/www/de/index.html b/www/de/index.html index daab784030..b9ba4ee18d 100644 --- a/www/de/index.html +++ b/www/de/index.html @@ -33,7 +33,7 @@

Auf dieser Seite finden Sie die auf Deutsch übersetzten OpenStack Dokumente. Bitte beachten Sie, dass noch nicht alle Dokumente auf Deutsch zur Verfügung stehen und Sie durch Verweise auf andere Dokumente auch in den englischsprachigen Originalen landen können. Weitere Sprachen und Releases finden Sie über den Button rechts.

Das Team hat sich darauf geeinigt, Fachbegriffe soweit möglich zu übersetzen. Nur Begriffe, deren Übersetzung nicht sinnvoll erscheint (z.B. Kommandos oder in der Gemeinschaft übliche Ausdrücke), bleiben unübersetzt. Hier finden Sie das vom Team gepflegte Wörterbuch.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/fr/index.html b/www/fr/index.html index 13e139047b..3038104ec6 100644 --- a/www/fr/index.html +++ b/www/fr/index.html @@ -32,7 +32,7 @@

Documentation en Français

Cette page contient la liste des documentations OpenStack disponibles en version française. Documents that have not been translated, translated into different languages, or English version of the previous releases can be found in the following menu.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/id/index.html b/www/id/index.html index 58796c11ce..575234c0db 100644 --- a/www/id/index.html +++ b/www/id/index.html @@ -32,7 +32,7 @@

Dokumen Indonesia

Ini adalah rilis Indonesian terbaru. Gunakan menu untuk memilih rilis sebelumnya atau bahasa yang berbeda jika diperlukan.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/ja/index.html b/www/ja/index.html index b059ef0edc..9b5371bc69 100644 --- a/www/ja/index.html +++ b/www/ja/index.html @@ -32,7 +32,7 @@

日本語ドキュメント

このページは最新版の日本語ドキュメントのみを掲載しています。すべての英語ドキュメントはドキュメントのホームページから参照できます。

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/ko_KR/index.html b/www/ko_KR/index.html index 5bfb0703b3..85155d1226 100644 --- a/www/ko_KR/index.html +++ b/www/ko_KR/index.html @@ -32,7 +32,7 @@

한국어 문서

한국어 문서는 최신 버전만 제공합니다. 번역되지 않았거나 이전 릴리즈의 영어 문서와 다른 언어로 된 문서는 다음 메뉴에서 확인할 수 있습니다.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/mitaka/de/index.html b/www/mitaka/de/index.html index 2246f400d7..9378617a4d 100644 --- a/www/mitaka/de/index.html +++ b/www/mitaka/de/index.html @@ -33,7 +33,7 @@

Auf dieser Seite finden Sie die auf Deutsch übersetzten OpenStack Dokumente. Bitte beachten Sie, dass noch nicht alle Dokumente auf Deutsch zur Verfügung stehen und Sie durch Verweise auf andere Dokumente auch in den englischsprachigen Originalen landen können. Weitere Sprachen und Releases finden Sie über den Button rechts.

Das Team hat sich darauf geeinigt, Fachbegriffe soweit möglich zu übersetzen. Nur Begriffe, deren Übersetzung nicht sinnvoll erscheint (z.B. Kommandos oder in der Gemeinschaft übliche Ausdrücke), bleiben unübersetzt. Hier finden Sie das vom Team gepflegte Wörterbuch.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/newton/de/index.html b/www/newton/de/index.html index 4d82c100bb..6077f823d0 100644 --- a/www/newton/de/index.html +++ b/www/newton/de/index.html @@ -33,7 +33,7 @@

Auf dieser Seite finden Sie die auf Deutsch übersetzten OpenStack Dokumente. Bitte beachten Sie, dass noch nicht alle Dokumente auf Deutsch zur Verfügung stehen und Sie durch Verweise auf andere Dokumente auch in den englischsprachigen Originalen landen können. Weitere Sprachen und Releases finden Sie über den Button rechts.

Das Team hat sich darauf geeinigt, Fachbegriffe soweit möglich zu übersetzen. Nur Begriffe, deren Übersetzung nicht sinnvoll erscheint (z.B. Kommandos oder in der Gemeinschaft übliche Ausdrücke), bleiben unübersetzt. Hier finden Sie das vom Team gepflegte Wörterbuch.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/ocata/de/index.html b/www/ocata/de/index.html index c187ad8216..bc55135058 100644 --- a/www/ocata/de/index.html +++ b/www/ocata/de/index.html @@ -33,7 +33,7 @@

Auf dieser Seite finden Sie die auf Deutsch übersetzten OpenStack Dokumente. Bitte beachten Sie, dass noch nicht alle Dokumente auf Deutsch zur Verfügung stehen und Sie durch Verweise auf andere Dokumente auch in den englischsprachigen Originalen landen können. Weitere Sprachen und Releases finden Sie über den Button rechts.

Das Team hat sich darauf geeinigt, Fachbegriffe soweit möglich zu übersetzen. Nur Begriffe, deren Übersetzung nicht sinnvoll erscheint (z.B. Kommandos oder in der Gemeinschaft übliche Ausdrücke), bleiben unübersetzt. Hier finden Sie das vom Team gepflegte Wörterbuch.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/static/common/css/combined.css b/www/static/common/css/combined.css index 0adf674936..03e565ce16 100644 --- a/www/static/common/css/combined.css +++ b/www/static/common/css/combined.css @@ -3528,7 +3528,6 @@ input.docs-main-search:-ms-input-placeholder { background: #2A4E68; padding: 20px 5px; text-align: center; - font-size: 13px; color: white; } .docs-dropdown a { @@ -3550,7 +3549,7 @@ input.docs-main-search:-ms-input-placeholder { font-size: 18px; } .docs-dropdown .dropdown-menu { - width: 150%; + width: 280%; margin-top: 10px; } .docs-dropdown > .dropdown-menu:after, .docs-dropdown > .dropdown-menu:before, .docs-sidebar-dropdown:before, .docs-sidebar-dropdown:after { diff --git a/www/static/common/css/deprecated-badge.css b/www/static/common/css/deprecated-badge.css index b36dcb48ec..7f370c9cff 100644 --- a/www/static/common/css/deprecated-badge.css +++ b/www/static/common/css/deprecated-badge.css @@ -13,6 +13,23 @@ margin-top: 8px; } +.deprecated-badge .docs-dropdown { + display: inline-block; +} + +.deprecated-badge .docs-dropdown > a { + padding: 5px 12px; + margin: 0px 4px 0px 4px; + width: inherit; } + +.deprecated-badge .docs-dropdown .dropdown-menu a { + padding: 5px 25px; + margin-top: 0px; } + +.deprecated-badge .docs-dropdown > .dropdown-menu > li.current { + padding: 5px 25px; + text-align: left; } + .deprecated-badge a:hover { text-decoration: underline; } @@ -25,8 +42,8 @@ z-index: 1000; } -p.deprecated-badge-left { - float: left; +.deprecated-badge p { + display: inline-block; } a.deprecated-badge-right { @@ -72,7 +89,7 @@ a.deprecated-badge-right { } .deprecated-badge-current a, .deprecated-badge-current p { - color: #edf2f7 !important; + color: #edf2f7; } .deprecated-badge .container diff --git a/www/templates/deprecated_badge.tmpl b/www/templates/deprecated_badge.tmpl index 1ad79e08aa..e60c075463 100644 --- a/www/templates/deprecated_badge.tmpl +++ b/www/templates/deprecated_badge.tmpl @@ -17,28 +17,28 @@ "> x
- {% if SERIES_INFO.status == 'obsolete' %} -

- This release is no longer supported by the community. The current supported release is {{RELEASED_SERIES.capitalize()}}. -

- {% elif SERIES_INFO.status == 'EOL' %} -

- This release is no longer supported by the community. The current supported release is {{RELEASED_SERIES.capitalize()}}. -

- {% elif SERIES == RELEASED_SERIES %} -

- This is the current supported release. -

- {% elif SERIES_INFO.status == 'maintained' %} -

- This is maintained, but not the current release. The current supported +

+ {% if SERIES_PATH_PREFIX %} +

Currently viewing

+ {% include 'templates/switch_releases.tmpl' %} +

+ {% if SERIES_INFO.status == 'obsolete' %} + which is no longer supported by the community. The current supported release is {{RELEASED_SERIES.capitalize()}}. +

+ {% elif SERIES_INFO.status == 'EOL' %} + which is no longer supported by the community. The current supported release is {{RELEASED_SERIES.capitalize()}}. + {% elif SERIES == RELEASED_SERIES %} + which is the current supported release. + {% elif SERIES_INFO.status == 'maintained' %} + which is maintained, but old. The current supported release is {{RELEASED_SERIES.capitalize()}}. + {% elif SERIES_INFO.status == 'development' %} + which is in development. The current supported release is + {{RELEASED_SERIES.capitalize()}}. + {% endif %}

- {% elif SERIES_INFO.status == 'development' %} -

- This release is under development. The current supported release is {{RELEASED_SERIES.capitalize()}}. -

- {% endif %} -  Back to Top + {% endif %} +  Back to Top +
- \ No newline at end of file + diff --git a/www/templates/dropdown_releases_and_languages.tmpl b/www/templates/dropdown_languages.tmpl similarity index 64% rename from www/templates/dropdown_releases_and_languages.tmpl rename to www/templates/dropdown_languages.tmpl index 7c2d1b471e..64f28cbd3a 100644 --- a/www/templates/dropdown_releases_and_languages.tmpl +++ b/www/templates/dropdown_languages.tmpl @@ -1,14 +1,3 @@ -
- -
- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %}
diff --git a/www/templates/series_status.tmpl b/www/templates/series_status.tmpl index 86e8e6d336..d923bf435d 100644 --- a/www/templates/series_status.tmpl +++ b/www/templates/series_status.tmpl @@ -30,15 +30,15 @@

{% elif SERIES == RELEASED_SERIES %} -

This is the latest release. Use the menu to select a prior release +

This is the latest release. Use the top menu to select a prior release if needed.

{% elif SERIES_INFO.status == 'maintained' %} -

This is not the latest release. Use the menu to select a different +

This is not the latest release. Use the top menu to select a different release if needed.

{% elif SERIES_INFO.status == 'development' %} -

This release is currently under development. Use the menu to select +

This release is currently under development. Use the top menu to select a different release if needed.

{% endif %} diff --git a/www/templates/switch_releases.tmpl b/www/templates/switch_releases.tmpl new file mode 100644 index 0000000000..1fb1dbca81 --- /dev/null +++ b/www/templates/switch_releases.tmpl @@ -0,0 +1,42 @@ + diff --git a/www/tr_TR/index.html b/www/tr_TR/index.html index 101674afcc..cc28a968d9 100644 --- a/www/tr_TR/index.html +++ b/www/tr_TR/index.html @@ -32,7 +32,7 @@

Türkçe Belgeler

Bu en son Türkçe belgeleri yayınıdır. Menüyü kullanarak önceki sürümleri veya farklı dilleri seçebilirsiniz.

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %} diff --git a/www/zh_CN/index.html b/www/zh_CN/index.html index c60d44ad94..30867cd962 100644 --- a/www/zh_CN/index.html +++ b/www/zh_CN/index.html @@ -32,7 +32,7 @@

中文

最新的中文文档。包括安装手册,API文档

- {% include 'templates/dropdown_releases_and_languages.tmpl' %} + {% include 'templates/dropdown_languages.tmpl' %}