From: Jonathan S. Katz <jkatz@postgresql.org>
To: pgsql-www@lists.postgresql.org <pgsql-www@lists.postgresql.org>
Subject: Release Notes Archive Patch
Date: Tue, 12 Feb 2019 20:12:19 -0500
Message-ID: <e0f09c9a-bd2b-862a-d379-601dfabc8969@postgresql.org> (raw)
Hi,
Attached is a proposed patch for archiving the release notes on the
website. The patch builds the release note archive without modifying the
schema and works with old and new releases.
It works as such:
- Find all release notes that have been loaded into pgweb (a process
that occurs each release when we load the documentation)
- Find the last modified release notes for each version. This accounts
for the old docs, e.g. there is a copy of the 9.2.8 notes in the 9.3.9
release, so we will render those
- There is a list of all release notes. If you click into it, you will
see the version specific release notes
Known adjustments to be made:
- The URLs on each release note page are broken. I have to figure out
how the best way to change the relative path in the URLs that are on the
page as it is going from the page root (/docs/release) instead of the
site root. This _should_ be easy
- Even with above fix, some URLs will be broken in them, i.e. references
to other release notes
- PostgreSQL v1 + v0: I need to relabel this for Postgres95
- Also, some of the earlier versions do not have the proper release
numbering (e.g. 1.03)
I'm hoping we can put this out with the upcoming release, but am ok with
doing this shortly thereafter.
Comments on patch and approach welcome.
Thanks,
Jonathan
From d91204225b16c2636e57161c08cad112a8ce333d Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <jonathan.katz@excoventures.com>
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.cssindex 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.pyindex 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.pyindex 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<major_version>(\d+\.\d+)|\d+)\.(?P<minor_version>\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.pyindex 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.htmlnew file mode 100644index 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 %}++<div id="release-notes" class="row">+ {% if d %}+ <div class="col-md-10">+ <section>+ <h1>Release Notes <i class="far fa-file-alt"></i></h1>+ <h2>PostgreSQL {{ d.major_version }}.{{ d.minor_version }}</h2>+ </section>+ <div id="docContent">+ {{ d.content|safe }}+ </div>+ </div>+ {% else %}+ <div class="col-md-9">+ <section>+ <h1>Release Notes <i class="far fa-file-alt"></i></h1>+ </section>+ <p>Below is the complete archive of release notes for every version of PostgreSQL.</p>+ {% for version_group in version_groups %}+ <h2 id="release-{{ version_group.grouper }}">PostgreSQL {{ version_group.grouper }}</h2>+ <ul>+ {% for d in version_group.list %}+ <li>+ <a href="/docs/release/{{ version_group.grouper }}.{{ d.minor_version }}/">+ {{ version_group.grouper }}.{{ d.minor_version }}+ </a>+ </li>+ {% endfor %}+ </ul>+ {% endfor %}+ </div>+ <div class="col-md-3">+ <section>+ <h2>Jump to...</h2>+ </section>+ <ul>+ {% for version_group in version_groups %}+ <li>+ <a href="#release-{{ version_group.grouper }}">PostgreSQL {{ version_group.grouper }}</a>+ </li>+ {% endfor %}+ </ul>+ </div>+ {% endif %}+</div>++{% endblock %}
--
2.14.3 (Apple Git-98)
Attachments:
[text/plain] 0001-Create-Release-Notes-archive-in-the-Documentation-se.patch (7.8K, ../e0f09c9a-bd2b-862a-d379-601dfabc8969@postgresql.org/2-0001-Create-Release-Notes-archive-in-the-Documentation-se.patch)
download | inline diff:
From d91204225b16c2636e57161c08cad112a8ce333d Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <jonathan.katz@excoventures.com>
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.cssindex 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.pyindex 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.pyindex 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<major_version>(\d+\.\d+)|\d+)\.(?P<minor_version>\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.pyindex 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.htmlnew file mode 100644index 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 %}++<div id="release-notes" class="row">+ {% if d %}+ <div class="col-md-10">+ <section>+ <h1>Release Notes <i class="far fa-file-alt"></i></h1>+ <h2>PostgreSQL {{ d.major_version }}.{{ d.minor_version }}</h2>+ </section>+ <div id="docContent">+ {{ d.content|safe }}+ </div>+ </div>+ {% else %}+ <div class="col-md-9">+ <section>+ <h1>Release Notes <i class="far fa-file-alt"></i></h1>+ </section>+ <p>Below is the complete archive of release notes for every version of PostgreSQL.</p>+ {% for version_group in version_groups %}+ <h2 id="release-{{ version_group.grouper }}">PostgreSQL {{ version_group.grouper }}</h2>+ <ul>+ {% for d in version_group.list %}+ <li>+ <a href="/docs/release/{{ version_group.grouper }}.{{ d.minor_version }}/">+ {{ version_group.grouper }}.{{ d.minor_version }}+ </a>+ </li>+ {% endfor %}+ </ul>+ {% endfor %}+ </div>+ <div class="col-md-3">+ <section>+ <h2>Jump to...</h2>+ </section>+ <ul>+ {% for version_group in version_groups %}+ <li>+ <a href="#release-{{ version_group.grouper }}">PostgreSQL {{ version_group.grouper }}</a>+ </li>+ {% endfor %}+ </ul>+ </div>+ {% endif %}+</div>++{% endblock %}--
2.14.3 (Apple Git-98)
[application/pgp-signature] signature.asc (832B, ../e0f09c9a-bd2b-862a-d379-601dfabc8969@postgresql.org/3-signature.asc)
download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-www@postgresql.org
Cc: jkatz@postgresql.org, pgsql-www@lists.postgresql.org
Subject: Re: Release Notes Archive Patch
In-Reply-To: <e0f09c9a-bd2b-862a-d379-601dfabc8969@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox