diff --git a/pgweb/docs/views.py b/pgweb/docs/views.py index c2d00c8..162776f 100644 --- a/pgweb/docs/views.py +++ b/pgweb/docs/views.py @@ -120,11 +120,30 @@ def docpage(request, version, filename): else: contentpreview = '' + # determine the canonical version of the page + # if the doc page is in the current version, then we set it to current + # otherwise, check the supported and unsupported versions and find the + # last version that the page appeared + # we exclude "devel" as development docs are disallowed in robots.txt + canonical_version = "" + if len(list(filter(lambda v: v.version.current, versions))): + canonical_version = "current" + else: + version_max = None + for v in versions: + if version_max is None: + version_max = v + elif v.version.tree > version_max.version.tree: + version_max = v + if version_max.version.tree > Decimal(0): + canonical_version = version_max.display_version() + r = render(request, 'docs/docspage.html', { 'page': page, 'supported_versions': [v for v in versions if v.version.supported], 'devel_versions': [v for v in versions if not v.version.supported and v.version.testing], 'unsupported_versions': [v for v in versions if not v.version.supported and not v.version.testing], + 'canonical_version': canonical_version, 'title': page.title, 'doc_index_filename': indexname, 'loaddate': loaddate, diff --git a/templates/docs/docspage.html b/templates/docs/docspage.html index f5f3e3b..7a4e2fc 100644 --- a/templates/docs/docspage.html +++ b/templates/docs/docspage.html @@ -27,6 +27,9 @@ {%endif%} {%block extrahead%}{%endblock%} + {% if canonical_version %} + + {% endif %}
diff --git a/templates/docs/index.html b/templates/docs/index.html index cfcc2f8..63e4559 100644 --- a/templates/docs/index.html +++ b/templates/docs/index.html @@ -27,6 +27,9 @@ {{v.treestring}} + {% if v.current %} + (Current) + {% endif %} {%if v.a4pdf or v.uspdf%}