From d91204225b16c2636e57161c08cad112a8ce333d Mon Sep 17 00:00:00 2001 From: "Jonathan S. Katz" Date: Tue, 12 Feb 2019 20:50:48 +0100 Subject: [PATCH] Create Release Notes archive in the Documentation section. This creates a consolidated area to reference all of the notes from previous releases of PostgreSQL, as current releases only keep the the notes for that specific major release of PostgreSQL. --- media/css/main.css | 7 ++++ pgweb/docs/views.py | 84 +++++++++++++++++++++++++++++++++++++++ pgweb/urls.py | 2 + pgweb/util/contexts.py | 1 + templates/docs/release_notes.html | 51 ++++++++++++++++++++++++ 5 files changed, 145 insertions(+) create mode 100644 templates/docs/release_notes.html diff --git a/media/css/main.css b/media/css/main.css index 6c93c8b7..915c4a29 100644 --- a/media/css/main.css +++ b/media/css/main.css @@ -1293,6 +1293,13 @@ table.sponsor-table tbody tr td:nth-child(3) { width: 30%; } +/** Release Notes */ +#release-notes .navheader, +#release-notes .navfooter, +#release-notes .titlepage, +#release-notes .toc { + display: none; +} /** ALL RESPONSIVE QUERIES HERE */ /* Small devices (landscape phones, 576px and up)*/ diff --git a/pgweb/docs/views.py b/pgweb/docs/views.py index 4577f0ce..1da162fd 100644 --- a/pgweb/docs/views.py +++ b/pgweb/docs/views.py @@ -140,6 +140,90 @@ def manualarchive(request): 'versions': [_VersionPdfWrapper(v) for v in versions], }) +def release_notes(request, major_version=None, minor_version=None): + """Contains the main archive of release notes.""" + sql = """ + SELECT + docs.*, + r.major_version, + r.minor_version + FROM ( + SELECT DISTINCT + r.major_version, + r.minor_version, + first_value(r.id) OVER ( + PARTITION BY (r.major_version, r.minor_version) + ORDER BY r.tree DESC + ) AS id + FROM ( + SELECT + r.id, + r.tree, + CASE array_length(versions, 1) + WHEN 1 THEN versions[1] + WHEN 2 THEN ( + CASE + WHEN versions[1]::int >= 10 OR versions[1]::int < 6 + THEN versions[1] + ELSE (versions[1] || '.' || versions[2]) + END + ) + ELSE (versions[1] || '.' || versions[2]) + END::numeric AS major_version, + CASE array_length(versions, 1) + WHEN 1 THEN '0' + WHEN 2 THEN ( + CASE + WHEN versions[1]::int >= 10 OR versions[1]::int < 6 + THEN versions[2] + ELSE '0' + END + ) + ELSE versions[3] + END::int AS minor_version + FROM ( + SELECT + d.id, + v.tree, + regexp_split_to_array( + regexp_replace(d.file, 'release-|.html?', '', 'g'), + '-') AS versions + FROM docs d + JOIN core_version v ON + v.tree = d.version AND + v.testing = 0 + WHERE file ~ '^release-' + ) r + ) r + ) r + JOIN docs ON docs.id = r.id + """ + params = [] + # if the major + minor version are provided, then we want to narrow down + # the results to the exact release notes + # otherwise ensure the release notes are returned in order + if major_version and minor_version: + sql += """ + WHERE major_version = %s AND minor_version = %s; + """ + params += [major_version, minor_version] + else: + sql += """ + ORDER BY r.major_version DESC, r.minor_version DESC; + """ + # execute the query to get the full queryset + queryset = DocPage.objects.raw(sql, params) + # if major + minor version are provided, we want to render something similar + # to the docs page + # otherwise, load the page that lists all of the versions + if major_version and minor_version: + docs = [d for d in queryset] + if not docs: + raise Http404() + context = { 'd': docs[0] } + else: + context = { 'versions': [d for d in queryset], } + return render_pgweb(request, 'docs', 'docs/release_notes.html', context) @login_required def commentform(request, itemid, version, filename): diff --git a/pgweb/urls.py b/pgweb/urls.py index d40673fc..9382975a 100644 --- a/pgweb/urls.py +++ b/pgweb/urls.py @@ -57,6 +57,8 @@ urlpatterns = [ url(r'^docs/$', pgweb.docs.views.root), url(r'^docs/manuals/$', pgweb.docs.views.manuals), url(r'^docs/manuals/archive/$', pgweb.docs.views.manualarchive), + url(r'^docs/release/$', pgweb.docs.views.release_notes), + url(r'^docs/release/((?P(\d+\.\d+)|\d+)\.(?P\d+))/$', pgweb.docs.views.release_notes), # Legacy URLs for accessing the docs page; provides a permanent redirect url(r'^docs/(current|devel|\d+(?:\.\d)?)/(static|interactive)/((.*).html?)?$', pgweb.docs.views.docspermanentredirect), url(r'^docs/(current|devel|\d+(?:\.\d)?)/(.*).html?$', pgweb.docs.views.docpage), diff --git a/pgweb/util/contexts.py b/pgweb/util/contexts.py index 43f6c3e2..8f0b047b 100644 --- a/pgweb/util/contexts.py +++ b/pgweb/util/contexts.py @@ -36,6 +36,7 @@ sitenav = { {'title': 'Japanese', 'link': 'http://www.postgresql.jp/document/'}, {'title': 'Russian', 'link': 'https://postgrespro.ru/docs/postgresql'}, ]}, + {'title': 'Release Notes', 'link': '/docs/release/'}, {'title': 'Books', 'link': '/docs/books/'}, {'title': 'Online Resources', 'link': '/docs/online-resources/'}, {'title': 'Wiki', 'link': 'https://wiki.postgresql.org'}, diff --git a/templates/docs/release_notes.html b/templates/docs/release_notes.html new file mode 100644 index 00000000..c9a9bfd1 --- /dev/null +++ b/templates/docs/release_notes.html @@ -0,0 +1,51 @@ +{% extends "base/page.html" %} +{%block title%}Release Notes{%endblock%} +{% block contents %} +{% regroup versions by major_version as version_groups %} + +
+ {% if d %} +
+
+

Release Notes

+

PostgreSQL {{ d.major_version }}.{{ d.minor_version }}

+
+
+ {{ d.content|safe }} +
+
+ {% else %} +
+
+

Release Notes

+
+

Below is the complete archive of release notes for every version of PostgreSQL.

+ {% for version_group in version_groups %} +

PostgreSQL {{ version_group.grouper }}

+ + {% endfor %} +
+
+
+

Jump to...

+
+ +
+ {% endif %} +
+ +{% endblock %} -- 2.14.3 (Apple Git-98)