Published on: Nov 05, 2024
Wow, work’s been real slow. As such, work on the site has been big and plentiful. A few new features have been added to the site mainly..
In the spirit of wild west internet ala spacejam.com, the site now has a guestbook, Link Here to sign if you like. Setting it up was a bit of a journey. I had never played around with databases in a production setting, or integrating one into a website before. Its alll about them API keys. Putting them in special spots so that Netlify can see and use them.
The database behind it is running on Xata, mainly because it had a setup guide for Astro, which suggested compatability. Very easy to setup! A few npm installs and tweaking of an HTML form and it was good to go. The calls seem to be quick and the back-end UI is very simple as well. It’s really nice not having to use a command line for database management. Using a purple themed Excel sheet is much easier.
The form has some basic text validation, and otherwise, uses Akismet as spam protection. It seems to block links and a few other things. I am a mega-amateur, so was following Ryan Trimble’s guestbook guide which suggested to use it. From what I’ve gathered from other sites, there be web-crawlers out there trying to spam and advertise any available text box. This looks to be a good way to filter that crud out.
It seems to function well enough, could do with a CSS pass to make it look a bit prettier, but not sure what I’d do for that. Rip off the styling of Bootstrap components maybe.
At Long Last. Images have a placeholder before loading in. Many thanks to blurhash for this one. Blurhash is a fun algorithm that encodes an image in a very lightweight way to display it as a block of gradient colours. This way, it can transition into the loaded image a lot cleaner. It’s a way of making the first second or so of a page loading to look nicer. It was difficult to setup, as the images are locally hosted, which many libraries don’t interact with well. Unpic has a library that can create placeholders for Astro images, but explicitly on external hosts only. However, they have a library that lets you convert any image into a blurhash string, and then that string into a CSS background Unpic Placeholder. It comes out as a nice, blurry image that loads instantly because the string being displayed is less than a kilobyte big.
The code behind the image loading it is quite fun (and stolen from stackOverflow). The placeholder background is put on the background of the <div> element which loads instantly. The main image is set as opacity 0 initially fading in the main image once loaded. There is an onload property on images that triggers a class change to make the opacity 1. A webkit transformation effect makes it so it loads in somewhat gradually, so as to not be as jarring.
Still some work to be done in giving all images a relevant placeholder, but that mainly falls down to running the images through a python script that generates a hash, and then plopping that in front matter.
After a week taking care of my sister’s dog, I can, unfortunately, confirm I am not a dog person. I have been terrified of dogs for a while. Growing up, my experience with dogs boiled down to being yelled at by dogs behind fences, dogs jumping on my leg, and parents who were stressed whenever we asked about getting one. In Year 7, visiting my friends house was skydive-scary, as he had two, calf-height, west-highland terriers. My friend and his mum were cracking up as I’d sit on the couch with the dogs jumping around, while I acted like I was being held up in a bank. Enough exposure with dogs later, I came to tolerate, and somewhat enjoy dogs. They are cute little guys who just wanna have fun.
That said, living with a dog is a little different. A large black greyhound is a pretty decent starter dog. They like to run for 2 hours of the day and then sleep for the remaining 22. For someone who works full time, a dog that sleeps most of the day is pretty great. My sister’s dog, lets call them Ernie, had a lot of energy. Walking was stressful as I would often be playing catch up to Ernie’s long legs. Sudden jerks as Ernie would stop to sniff the neighbourhood. And more often than I’d like (more than 0) Ernie would freeze and start growling at a cat, shortly before trying to lunge at it and then bite through the lead when I tried to stop him. Fucking stressful for my first walk ever. In a moment, a decade of getting used to dogs vanished, and I was back to being terrified.
Taking care of him at home was a little easier, he was a very snuggly dog and just wanted to be in the same room (and bed!) as me wherever we went. As a very introverted person though, it was a little suffocating. Something alive wouldn’t leave me alone. It made me realize how much I value some time to myself after work/school. Time where I don’t have to worry about anything is very soothing when I spend most of the day stressing out at work.
Overall, it was an experience that was very good for me, in the same way that unsweetened medicine is good for someone. Will definetly not be saying yes to that experience again.
Back to Blog