From: Jonathan S. Katz <jkatz@postgresql.org>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-www@lists.postgresql.org <pgsql-www@lists.postgresql.org>
Subject: Re: Release Notes Archive Patch
Date: Wed, 13 Feb 2019 15:33:58 -0500
Message-ID: <364b776c-db88-c618-8d77-9a8bfd07d08e@postgresql.org> (raw)
In-Reply-To: <5ff7e3c8-a6bd-100c-942a-c02a19208735@postgresql.org>
References: <e0f09c9a-bd2b-862a-d379-601dfabc8969@postgresql.org>
<751cae66-4d83-5012-94c6-b915bfa03f9e@postgresql.org>
<23227.1550070811@sss.pgh.pa.us>
<81313189-2e85-062a-f6d9-620298b4b00e@postgresql.org>
<25885.1550074702@sss.pgh.pa.us>
<5ab20e2d-f291-51db-6761-07daeed5a87a@postgresql.org>
<20190213184430.w4uyarc2vsgcvhue@alap3.anarazel.de>
<475f78b3-a4e5-6cb7-90d5-c5faf116ba31@postgresql.org>
<C156A99D-E75A-4B93-80EA-0556FBAD8B3C@anarazel.de>
<5ff7e3c8-a6bd-100c-942a-c02a19208735@postgresql.org>
On 2/13/19 2:34 PM, Jonathan S. Katz wrote:
> On 2/13/19 2:10 PM, Andres Freund wrote:
>> Hi,
>>
>> On February 13, 2019 8:03:03 PM GMT+01:00, "Jonathan S. Katz" <jkatz@postgresql.org> wrote:
>>>> I'm quite pissed at how haphazardly this was done.
>>>
>>> We had discussion on this for months, and after some idling, we
>>> proposed
>>> a solution and worked through it quickly. Sometimes you just need to
>>> rip
>>> the band-aid off.
>>
>> But even leaving that aside, nothing, absolutely nothing, prevented putting the web piece into place before breaking things.
>
> I don't disagree with the above point. With that said, we are working to
> get the web piece up prior to the majority of the links going 404.
>
> I will go to work on a patch for current (which could be similar to
> "devel") and see if I can have that ready. I will do it as a separate
> patch from the one upthread.
This turned out to be not so bad, please see attached.
Here's the way it works:
- If you are viewing release notes in documentation prior to 9.4, do nothing
- If you are viewing the release notes in documentation for 9.4 and
above and you are viewing the release notes in your version (e.g. 9.4.8
in 9.4), do nothing
- If you are viewing the release notes in docs for 9.4+ and you are
viewing a "mismatched" version (e.g. /docs/10/release-9-6-4.html),
permanent redirect (301) to the proper version (e.g.
/docs/9.6/release-6-4.html)
It accounts for version numbering changes and all the fun
Notes:
- Tested in multiple scenarios, also dealing with different versioning
number permutations as well (e.g. release-10.html, release-10-1.html,
release-9-6.html, release-9-6-1.html)
- Tested with current. I did not test with devel as I do not have
"devel" docs set up on my local. However, I am going to work on setting
that up
- Given docs on the site go back to 7.2, there is a stop that says if
you are viewing a release note older than 7.2, then view the releases
notes in 7.2
This can be pushed independently of the previous patch as it redirects
users to existing documentation.
Feedback welcome. Thanks,
Jonathan
From e029d8ec99f18a46e6940746abe3e0fd0f65f122 Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <jonathan.katz@excoventures.com>
Date: Wed, 13 Feb 2019 15:22:49 -0500
Subject: [PATCH 2/2] Ensure release notes from older version still load with
404 errors.
An upcoming change in PostgreSQL keeps only release notes in their
current versions. So e.g., PostgreSQL 11 only has the release notes
for 11.0, 11.1, 11.2 etc.
Thus, for PostgreSQL 9.4 on up, any URLs such as /docs/10/release-9-6-8.html
would return a 404. Additonal, URLs with /current/ and /devel/ would break
as well.
This patch prevents these 404s from occuring by redirecting users accessing
release notes in the 9.4 and above documentation to the older versions
of the release notes by redirecting them to the notes in the specific
version. So in the above example, a user would be redirect to
/docs/9.6/release-9-6-8.html
As we do not have documentation on the website past 7.2, any release
notes from an older version are redirected to the release notes tree
in 7.2
---
pgweb/docs/views.py | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/pgweb/docs/views.py b/pgweb/docs/views.pyindex 1da162fd..14fce173 100644--- a/pgweb/docs/views.py+++ b/pgweb/docs/views.py@@ -5,8 +5,9 @@ from pgweb.util.decorators import login_required, allow_frames, content_sources
from django.db.models import Q
from django.conf import settings
-from decimal import Decimal+from decimal import Decimal, ROUND_DOWN
import os
+import re
from pgweb.util.contexts import render_pgweb
from pgweb.util.helpers import template_to_string
@@ -53,6 +54,34 @@ def docpage(request, version, filename):
return HttpResponsePermanentRedirect("/docs/{0}/{1}.html".format(int(ver), filename))
fullname = "%s.%s" % (filename, extension)
++ # Before looking up the documentation, we need to make a check for release+ # notes. Based on a change, from PostgreSQL 9.4 and up, release notes are+ # only available for the current version (e.g. 11 only has 11.0, 11.1, 11.2)+ # This checks to see if there is a mismatch (e.g. ver = 9.4, fullname = release-9-3-2.html)+ # and perform a redirect to the older version+ if fullname.startswith('release-') and ver >= Decimal("9.4"):+ # figure out which version to redirect to. Note that the oldest version+ # of the docs loaded is 7.2+ release_version = re.sub(r'release-((\d+)(-\d+)?)(-\d+)?.html',+ r'\1', fullname).replace('-', '.')+ # convert to Decimal for ease of manipulation+ release_version = Decimal(release_version)+ # if the version is greater than 10, truncate the number+ if release_version >= Decimal('10'):+ release_version = release_version.quantize(Decimal('1'), rounding=ROUND_DOWN)+ # only proceed if the release version of the documents does not match+ # the calculated release version+ if release_version != ver:+ url = "/docs/"+ if release_version >= Decimal('10'):+ url += "{}/{}".format(int(release_version), fullname)+ elif release_version < Decimal('7.2'):+ url += "7.2/{}".format(fullname)+ else:+ url += "{}/{}".format(release_version, fullname)+ return HttpResponsePermanentRedirect(url)+
page = get_object_or_404(DocPage, version=ver, file=fullname)
versions = DocPage.objects.extra(
where=["file=%s OR file IN (SELECT file2 FROM docsalias WHERE file1=%s) OR file IN (SELECT file1 FROM docsalias WHERE file2=%s)"],
--
2.14.3 (Apple Git-98)
Attachments:
[text/plain] 0002-Ensure-release-notes-from-older-version-still-load-w.patch (3.6K, ../364b776c-db88-c618-8d77-9a8bfd07d08e@postgresql.org/2-0002-Ensure-release-notes-from-older-version-still-load-w.patch)
download | inline diff:
From e029d8ec99f18a46e6940746abe3e0fd0f65f122 Mon Sep 17 00:00:00 2001
From: "Jonathan S. Katz" <jonathan.katz@excoventures.com>
Date: Wed, 13 Feb 2019 15:22:49 -0500
Subject: [PATCH 2/2] Ensure release notes from older version still load with
404 errors.
An upcoming change in PostgreSQL keeps only release notes in their
current versions. So e.g., PostgreSQL 11 only has the release notes
for 11.0, 11.1, 11.2 etc.
Thus, for PostgreSQL 9.4 on up, any URLs such as /docs/10/release-9-6-8.html
would return a 404. Additonal, URLs with /current/ and /devel/ would break
as well.
This patch prevents these 404s from occuring by redirecting users accessing
release notes in the 9.4 and above documentation to the older versions
of the release notes by redirecting them to the notes in the specific
version. So in the above example, a user would be redirect to
/docs/9.6/release-9-6-8.html
As we do not have documentation on the website past 7.2, any release
notes from an older version are redirected to the release notes tree
in 7.2
---
pgweb/docs/views.py | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/pgweb/docs/views.py b/pgweb/docs/views.pyindex 1da162fd..14fce173 100644--- a/pgweb/docs/views.py+++ b/pgweb/docs/views.py@@ -5,8 +5,9 @@ from pgweb.util.decorators import login_required, allow_frames, content_sources
from django.db.models import Q
from django.conf import settings
-from decimal import Decimal+from decimal import Decimal, ROUND_DOWN
import os
+import re
from pgweb.util.contexts import render_pgweb
from pgweb.util.helpers import template_to_string
@@ -53,6 +54,34 @@ def docpage(request, version, filename):
return HttpResponsePermanentRedirect("/docs/{0}/{1}.html".format(int(ver), filename))
fullname = "%s.%s" % (filename, extension)
++ # Before looking up the documentation, we need to make a check for release+ # notes. Based on a change, from PostgreSQL 9.4 and up, release notes are+ # only available for the current version (e.g. 11 only has 11.0, 11.1, 11.2)+ # This checks to see if there is a mismatch (e.g. ver = 9.4, fullname = release-9-3-2.html)+ # and perform a redirect to the older version+ if fullname.startswith('release-') and ver >= Decimal("9.4"):+ # figure out which version to redirect to. Note that the oldest version+ # of the docs loaded is 7.2+ release_version = re.sub(r'release-((\d+)(-\d+)?)(-\d+)?.html',+ r'\1', fullname).replace('-', '.')+ # convert to Decimal for ease of manipulation+ release_version = Decimal(release_version)+ # if the version is greater than 10, truncate the number+ if release_version >= Decimal('10'):+ release_version = release_version.quantize(Decimal('1'), rounding=ROUND_DOWN)+ # only proceed if the release version of the documents does not match+ # the calculated release version+ if release_version != ver:+ url = "/docs/"+ if release_version >= Decimal('10'):+ url += "{}/{}".format(int(release_version), fullname)+ elif release_version < Decimal('7.2'):+ url += "7.2/{}".format(fullname)+ else:+ url += "{}/{}".format(release_version, fullname)+ return HttpResponsePermanentRedirect(url)+
page = get_object_or_404(DocPage, version=ver, file=fullname)
versions = DocPage.objects.extra(
where=["file=%s OR file IN (SELECT file2 FROM docsalias WHERE file1=%s) OR file IN (SELECT file1 FROM docsalias WHERE file2=%s)"],
--
2.14.3 (Apple Git-98)
[application/pgp-signature] signature.asc (832B, ../364b776c-db88-c618-8d77-9a8bfd07d08e@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, andres@anarazel.de, tgl@sss.pgh.pa.us, pgsql-www@lists.postgresql.org
Subject: Re: Release Notes Archive Patch
In-Reply-To: <364b776c-db88-c618-8d77-9a8bfd07d08e@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