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

Add past events to the website #40

Merged
merged 8 commits into from
Aug 7, 2023
Merged

Conversation

stuartlangridge
Copy link
Contributor

This PR adds past versions of the conf.techmids.io website to the current website, so that people can get access to the pages for past events to see who spoke at them, what they spoke about, and so on. Most conferences have this, and it's a very useful historical record. The goal here is that making sure that past versions of the conference are made available with close to zero burden on the website maintainers. The PR comes in three parts.

Part 1

(The two "add past version of website" commits)

The websites for the October 2022 and June 2023 events. These websites are pure static HTML with no outside dependencies and no build process; each is an independent folder of static HTML/CSS/JS stored in public/past. This is done so that they are self-contained; changes to the build process of the current website will not affect these past websites at all, because they've already been built to static HTML; they are not rebuilt on each change. This means that changing the version of next.js (or changing away from next.js entirely) and the like will not stop these past versions from working.

Part 2

(The "link-to-the-past" commit)

A script which generates these static versions of the website, which is called link-to-the-past. It is documented in detail in link-to-the-past/README.md, but the basic idea is this: there will be a day when the October 2023 event (for example) is over and you want to start changing the website for a 2024 event. On that day, before you make any changes to refer to the 2024 website, run npm run link-to-the-past 2023-10. This will bundle up the website as it currently looks into a static version of itself at past/2023-10. Then go ahead and make whatever changes are deemed necessary. This script is all inside the link-to-the-past folder, and is pure command-line nodejs; it doesn't run servers or anything like that, and you only run it once to create the static version, not every time.

Part 3

(The "Simple past-events page" commit)

A /past-events page on the website itself, linked from the footer. This page is built at build-time and adds a simple link to each of the past events by inspecting the filesystem. This is next.js stuff, and it is entirely possible that someone more expert with next.js itself could do this a more efficient or elegant way, and if that person exists and has the time then I would be happy to have them do this instead.

A simple page, created at build time, which inspects the contents of public/past and generates a page with a link to each.
Also, add a link to that newly created page to the footer.
@vercel
Copy link

vercel bot commented Aug 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
conf-techmids-io ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2023 8:25am

@stuartlangridge
Copy link
Contributor Author

(note that the Past Events page could do with attention from a designer of some kind, which is not me. But that probably isn't a blocker.)

@Waterdrips
Copy link
Contributor

Lots of the images are not loading (looking at the preview link)

Could we bundle the images from the site at build time into the same folder and change any img links to be a child of the folder?

Screenshot_20230807-082543.png

I'll take a look at a design for the past events page once this goes live

@mattandrews
Copy link

mattandrews commented Aug 7, 2023

I get this locally when trying to run npm run link-to-the-past 2023-10 (and node link-to-the-past/link-to-the-past.mjs too):

> node link-to-the-past/link-to-the-past.mjs
file:///Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/paths.mjs:13
        throw new Error(
              ^

Error: Expected to find the next config in /Users/matt/Dev/sil/conf.techmids.io/next.config.js, but we didn't.
This isn't supposed to happen, and is a bug in this script.
    at get_paths (file:///Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/paths.mjs:13:15)
    at main (file:///Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/link-to-the-past.mjs:16:25)
    at file:///Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/link-to-the-past.mjs:36:1

The next.config.js file it references does exist...

@stuartlangridge
Copy link
Contributor Author

stuartlangridge commented Aug 7, 2023

Lots of the images are not loading (looking at the preview link)

Could we bundle the images from the site at build time into the same folder and change any img links to be a child of the folder?

Huh, I hadn't noticed the logo images, good catch @Waterdrips. The issue there is that the images are bundled into the folder (https://conf-techmids-io-git-fork-stuartlangridge-main-tech-mids.vercel.app/past/2022-10/fusion-events.png exists, for example), but that the img link in the page wasn't updated to make it a relative link when next made the static build. What I think is best to do there is to manually patch the image links in the static build for that bundled static site, and I have now added this to the PR.

@stuartlangridge
Copy link
Contributor Author

The next.config.js file it references does exist...

Well, that's not supposed to happen (just like it says :)) Sorry about that @mattandrews -- I don't know what's causing the problem, but I have at least poked the script to relate what the error actually is when that happens so at least we can see what's up. Can you run it again?

@mattandrews
Copy link

Done! Got this:

(The actual error we got was this: TypeError: Cannot read properties of undefined (reading 'R_OK'))

@Waterdrips
Copy link
Contributor

Lots of the images are not loading (looking at the preview link)

Could we bundle the images from the site at build time into the same folder and change any img links to be a child of the folder?

Huh, I hadn't noticed the logo images, good catch @Waterdrips. The issue there is that the images are bundled into the folder (https://conf-techmids-io-git-fork-stuartlangridge-main-tech-mids.vercel.app/past/2022-10/fusion-events.png exists, for example), but that the img link in the page wasn't updated to make it a relative link when next made the static build. What I think is best to do there is to manually patch the image links in the static build for that bundled static site, and I have now added this to the PR.

You may be able to specify a base path on build?

@stuartlangridge
Copy link
Contributor Author

@mattandrews what? how can that not work? What does node -e 'console.log(require("node:fs/promises").constants.R_OK)' say?

@mattandrews
Copy link

Same thing: TypeError: Cannot read properties of undefined (reading 'R_OK') – some random comment here suggests it got deprecated? nodejs/node#8044

I'm on Mac in case that adds anything...

@mattandrews
Copy link

> node -e 'console.log(require("node:fs").constants.R_OK)'
4

... promises might be your issue here

@stuartlangridge
Copy link
Contributor Author

You may be able to specify a base path on build?

I do specify a base path on build :-) Most of the links to things do indeed get patched up, but those image links don't. I don't know why; someone who knows more about next.js may do. However, the advantage with dumping the sites to static is that we don't actually have to work this out immediately; it's OK to patch up the static HTML to make it work like I did, because then it stays fixed. A patch to make next.js better about fixing up such image links in the future when it exports to static would be a useful thing for someone to work on at some point if it becomes annoying, though. It looks like the image links are fixed in the vercel preview now, anyway, as expected, so that's good.

@stuartlangridge
Copy link
Contributor Author

... promises might be your issue here

weird, I don't get why it still works here, since it seems to have been dropped yonks ago. Anyway, PR updated to get the stuff from just fs and that should work now, I think. Thank you!

@mattandrews
Copy link

Backing up the next.config.js before we fiddle with it...
Written our custom link-to-the-past config
Moving the 'past' folder out of the way, from /Users/matt/Dev/sil/conf.techmids.io/public/past to /Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/temp_past
Confirming that we can write to the output directory /Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/export
There was an error, sorry.
I am attempting to restore things after the error.
Moving the 'past' folder back, from /Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/temp_past back to /Users/matt/Dev/sil/conf.techmids.io/public/past
I shall now abort. The error in the script was this:
Error: We cannot write to /Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/export. This is not supposed to happen, and is a bug in this script.
    at assure_output_dir (file:///Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/make-changes.mjs:38:19)
    at main (file:///Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/link-to-the-past.mjs:23:15)

Export directory exists and I just made it 777 (and tried running the script as sudo), same error... sorry!

(LOVED the ascii art!)

@stuartlangridge
Copy link
Contributor Author

same error... sorry!

...for the same reason. I have, this time, checked that there's nowhere else I'm using fs.constants too :)

@mattandrews
Copy link

It did things for a while, then:

Error occurred prerendering page "/past-events". Read more: https://nextjs.org/docs/messages/prerender-error
Error: ENOENT: no such file or directory, scandir '/Users/matt/Dev/sil/conf.techmids.io/public/past'
info  - Generating static pages (11/11)

> Export encountered errors on following paths:
	/past-events
There was an error, sorry.
I am attempting to restore things after the error.
Moving the 'past' folder back, from /Users/matt/Dev/sil/conf.techmids.io/link-to-the-past/temp_past back to /Users/matt/Dev/sil/conf.techmids.io/public/past
I shall now abort. The error in the script was this:
undefined

@stuartlangridge
Copy link
Contributor Author

Ok, sigh. I know what that is and I know how to fix it, but I'll have to come back to it in a bit. This is my fault for not properly testing exports after I built the Past Events page, which needs to be cleverer than it currently is. (The problem is that a static export should not, itself, contain other past exports).

@mattandrews
Copy link

Haha thanks for all the effort, I can see how much work's gone into this. Thank you!

@Waterdrips
Copy link
Contributor

image

https://conf-techmids-maxlckqug-tech-mids.vercel.app/past/2022-10/speakers/mark-perkin.html

each user page has a set of sponsors too.

We can probably get away with merging this and fixing up if it becomes an issue later?

@Waterdrips Waterdrips merged commit 5017f07 into techmids:main Aug 7, 2023
stuartlangridge added a commit to stuartlangridge/conf.techmids.io that referenced this pull request Aug 7, 2023
The past-events page automatically discovers all past events, and now decorates them with the metadata found in PastEventsList.
This means that when a new past event is added with link-to-the-past, it will automatically appear on the past-events page with default metadata, and can then be given its own nice picture and the like when desired by editing PastEventsList.
This is relevant to an issue brought up by @mattandrews in PR techmids#40.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants