Skip to content

Commit

Permalink
Merge pull request #357 from GeoscienceAustralia/feature/fix-version-…
Browse files Browse the repository at this point in the history
…history-string-format

Fix version number formatting in edge cases
  • Loading branch information
benji-glitsos-ga authored Dec 17, 2024
2 parents 6fcca02 + 0a501af commit b969db1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions docs/_templates/product-v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
"EPSG:3577": "GDA94 / Australian Albers (EPSG:3577)",
} %}

{# Macros #}

{% macro format_version_number(version_number) -%} {# If the version number starts with a number, add a 'v' to it e.g. "v1.0.0". #}
{%- if (version_number|string)[0].isdigit() -%}
{{ "v" ~ version_number }}
{%- else -%}
{{ version_number }}
{%- endif -%}
{%- endmacro %}

{# Computed values #}

{% set access_links_maps_list = page.data.access_links_maps | selectattr("link", "!=", None) | list %}
Expand Down Expand Up @@ -90,17 +100,17 @@

{% set bands_table_list = page.tables.bands_table | selectattr("name", "!=", None) | list %}

{% set page_title = page.data.short_name if page.data.is_latest_version else "v{}. {}".format(page.data.version_number, page.data.short_name) %}
{% set page_title = page.data.short_name if page.data.is_latest_version else format_version_number(page.data.version_number) ~ ". " ~ page.data.short_name %}

{% set display_title = page.data.short_name if page.data.is_latest_version else "{} v{}".format(page.data.short_name, page.data.version_number) %}
{% set display_title = page.data.short_name if page.data.is_latest_version else page.data.short_name ~ " " ~ format_version_number(page.data.version_number) %}

{% set product_ids_label = "Product IDs" if product_ids_list | length > 1 else "Product ID" %}

{% set parent_products_label = "Parent products" if parent_products_list | length > 1 else "Parent product" %}

{% set collections_label = "Collections" if collections_list | length > 1 else "Collection" %}

{% set currency_report_url = "https://mgmt.sandbox.dea.ga.gov.au/public-dashboards/d22241dbfca54b1fa9f73938ef26e645?orgId=1#:~:text={}".format(page.data.short_name | urlencode) %}
{% set currency_report_url = "https://mgmt.sandbox.dea.ga.gov.au/public-dashboards/d22241dbfca54b1fa9f73938ef26e645?orgId=1#:~:text=" ~ (page.data.short_name | urlencode) %}

{% set lineage_type = lineage_type_terms.get(page.data.lineage_type, page.data.lineage_type) %}

Expand Down Expand Up @@ -771,11 +781,11 @@

.. list-table::

* - v{{ page.data.version_number }}
* - {{ format_version_number(page.data.version_number) }}
- \-
- Current version
{% for item in previous_versions_list %}
* - v{{ item.version_number }}
* - {{ format_version_number(item.version_number) }}
- of
- `{{ item.title }} </data/version-history/{{ item.slug }}/>`_
{% endfor %}
Expand Down

0 comments on commit b969db1

Please sign in to comment.