wagtail / guide

A website to teach Wagtail CMS to content editors, moderators and administrators.
https://guide.wagtail.org
BSD 3-Clause "New" or "Revised" License
32 stars 26 forks source link

Create a redirect view for future releases not set up on the site yet #306

Closed thibaudcolas closed 1 year ago

thibaudcolas commented 1 year ago

There are two links from the CMS to this website that it would be nice to future-proof with a view / middleware that automates redirects, or a custom 404 page set up accordingly.

Release notes links

For links to "New in Wagtail x.y" - https://guide.wagtail.org/en-4.2.x/releases/new-in-wagtail-4-2/. Currently the CMS defaults to targeting a manually created redirect, https://guide.wagtail.org/en-latest/releases/latest/, which we then update in the guide.wagtail.org admin.

Instead, we could set up links like for docs.wagtail.org:

"https://docs.wagtail.org/en/v%s" % __version__

and make sure any version of the guide that doesn’t yet exist is handled gracefully.

Guide homepage links

We currently link to https://guide.wagtail.org/ which redirects to latest. It’d again be nicer if we linked straight to a specific version based on the version of the CMS, and gracefully handled versions that don’t exist yet.


I expect as part of changing this we will also be able to fix https://github.com/wagtail/wagtail/issues/10105. Edit: done

sheepman4267 commented 1 year ago

The existence of this issue makes sense of what I just noticed, which is that the "latest" redirect is still going to "what's new in Wagtail 4.2", while the link text in the CMS now reads "what's new in Wagtail 5.0" now that I've updated my project :)

thibaudcolas commented 1 year ago

Thanks for reporting @sheepman4267! I thought I had updated the redirects but I had missed this one. All the more reason to automate this even if this is simple to do manually.

thibaudcolas commented 1 year ago

(Possibly to consider in the future always-on redirect view that takes people to the latest release’s release notes (/latest-release)


In the CMS: https://github.com/wagtail/wagtail/blob/568e7ae2f28a72a792ea23892ea02f1ac5c54b5e/wagtail/templatetags/wagtailcore_tags.py#L85-L101

Release notes link

@register.simple_tag
def wagtail_feature_release_whats_new_link():
    major, minor, patch, release, num = VERSION
    if release == "final":
        return f"https://guide.wagtail.org/en-{major}.{minor}.x/releases/new-in-wagtail-{major}-{minor}/"
    return "magic view that always links to the latest release or existing Wagtail redirect https://guide.wagtail.org/en-latest/releases/latest/"

Homepage link

https://github.com/wagtail/wagtail/blob/568e7ae2f28a72a792ea23892ea02f1ac5c54b5e/wagtail/templatetags/wagtailcore_tags.py#L104-L106

@register.simple_tag
def wagtail_feature_release_editor_guide_link():
    major, minor, patch, release, num = VERSION
    if release == "final":
        return f"https://guide.wagtail.org/en-{major}.{minor}.x/"
    return "https://guide.wagtail.org/"
thibaudcolas commented 1 year ago

Fixed in #375. See also https://github.com/wagtail/wagtail/pull/11182.