Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding redirects to evolution proposals that only require the proposal identifier #367

Open
dempseyatgithub opened this issue Aug 23, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@dempseyatgithub
Copy link
Collaborator

A request came up in the forums for a way to link to swift evolution proposals that uses only the proposal identifier and not the full title slug that is used in the GitHub repository:
https://forums.swift.org/t/se-code-only-links-to-swift-evolution-proposal-files/66843

@xwu reached out from the language steering group to see if it would be possible to add redirects on swift.org that would do this.

For example, to reach the URL:
https://github.com/apple/swift-evolution/blob/main/proposals/0406-async-stream-backpressure.md

which requires knowledge of the exact title slug 0406-async-stream-backpressure of the proposal filename,

a redirect would be hosted by swift.org, something like:

https://swift.org/proposals/0406.html

or

https://swift.org/proposals/SE-0406.html

which would redirect to the proposal on GitHub

Adding this would allow easier construction or automation of URLs to proposals.

@dempseyatgithub dempseyatgithub added the enhancement New feature or request label Aug 23, 2023
@dempseyatgithub
Copy link
Collaborator Author

dempseyatgithub commented Aug 23, 2023

A few initial thoughts about this:

Currently the Swift Evolution dashboard page gets the parsed data as a JSON file and dynamically generates the bulk of the page in a client-side JavaScript, which also handles all the searching and filtering on the page.

For a set of redirects, it would make more sense to process the JSON file and create the redirects while the site itself was being statically generated. (Alternately, it may be easier to query GitHub directly to get the contents of the proposals directly, which has all the necessary info)

Since this would happen at site generation we may need to create a custom jekyll plug-in or run some kind of preprocessing script. I believe all redirects in vanilla jekyll are handled as client-side meta refreshes, so we would need one actual html file per proposal. I think it would be preferable to have a server-side redirect, so that would require some investigation.

// @alexandersandberg

@alexhunsley
Copy link

Thanks for filing this @dempseyatgithub. I can help implement this if possible. I guess before anything is done, a decision about the best implementation strategy needs making.

@alexhunsley
Copy link

alexhunsley commented Aug 25, 2023

I've just had a look inside the js for the proposals search screen at https://www.swift.org/swift-evolution. Could SE proposal code redirects be handled upon loading a dashboard URL like https://www.swift.org/swift-evolution/#?redirect-se=0401?

I can see in the init() inside https://www.swift.org/assets/javascripts/swift-evolution.js that we load proposals JSON from https://download.swift.org/swift-evolution/proposals.json. Is there an opportunity to do a redirect upon ?redirect-proposal=XXXX at that point?

@alexandersandberg
Copy link
Collaborator

I've just had a look inside the js for the proposals search screen at https://www.swift.org/swift-evolution. Could SE proposal code redirects be handled upon loading a dashboard URL like https://www.swift.org/swift-evolution/#?redirect-se=0401?

I can see in the init() inside https://www.swift.org/assets/javascripts/swift-evolution.js that we load proposals JSON from https://download.swift.org/swift-evolution/proposals.json. Is there an opportunity to do a redirect upon ?redirect-proposal=XXXX at that point?

It's a good idea! The problem with that is that the data is loaded dynamically on page load which can take a while if your internet connection is slow.

Instead of a client-side redirect like this, it would be ideal to have the redirects server-side. Then you would be redirected immediately to the proposal, without having to stop by Swift.org first.

@alexhunsley
Copy link

It's a good idea! The problem with that is that the data is loaded dynamically on page load which can take a while if your internet connection is slow.

Instead of a client-side redirect like this, it would be ideal to have the redirects server-side. Then you would be redirected immediately to the proposal, without having to stop by Swift.org first.

Good point, yeah!

@dempseyatgithub
Copy link
Collaborator Author

Yes, I think server-side redirects are the desired approach.

I think we should consider generating the redirects from the JSON provided by https://api.github.com/repos/apple/swift-evolution/contents/proposals.

At present I don’t know how often proposals.json is generated, but getting the values from GitHub directly would ensure we don’t have situations where the site and redirects are generated shortly before proposals.json is generated, leading to the site redirects being out of date for a period of time.

@alexhunsley I took a look at the script you have implemented on your GitHub pages page and that was cleverly done.

// @alexandersandberg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants