commits
It takes significantly longer than the rest of the script so it's
getting relegated to the lint script/checking via LSP.
This allows us to apply prettier formatting on the HTML templates in the
server code, including the Tailwind plugin to sort its classes
correctly.
This makes it easy to spin up a development server that will rebuild on
file changes.
Let's use Tailwind this time to quickly prototype styling. Might rip it
out later once things have settled down.
Recommended to do so in case any have released fixes to support the 2024
edition.
I was trying to reduce the number of clones before by moving into the
Vec fields of the Scrobble, but into_iter().next() still calls
ptr::read() under the hood which does a bitwise copy so you're still
beholden to the compiler as to whether it's optimised away or not and
you get more unreadable code.
RwLock uses interior mutability magic to ensure that you don't need a
&mut reference for write() to work.
This allows us to immediately return cached scrobbles in the rendered
HTML if available, but never waste any time waiting for the last.fm API
to give us new data if the cache is stale. The 200ms timeout that was
previously in place was never long enough for the last.fm API to return
so it was just an unnecessary delay on response times.
I guess the limit parameter I'm passing isn't good enough!!
The normalize.css package hasn't been updated in 7 years and I suspect
many of its changes are no longer necessary. modern-normalize is
slightly more opinionated, and resulted in some layout shifts due to it
defaulting to `box-sizing: border-box;`. But that's meant I've now gone
back and improved my CSS to rely less on padding when margins are more
appropriate, and made more use of flexbox to centre elements rather than
auto margins.
New HSTS preload guidelines suggest to me that any further changes
(including enabling preloading) are unnecessary these days as browsers
will automatically try to upgrade to HTTPS anyway.
We don't need any of the dynamic properties of the Extension extractor
so let's make use of the type checking provided by the State extractor.
The last.fm API can take upwards of 5 seconds to respond and we only
call it on-demand, and the website is not getting called every 30
seconds so the cache will reliably get cold and cause it to take
responses 5 seconds to be returned too.
It doesn't seem to like nesting a block inside a match, so let's use the
older approach of including the block from a separate file for now
instead.
Much nicer having all the HTML in a template file rather than having
some in a file, some in maud's DSL, and smushing them together in a
pseudo-template DSL.
This means the scrobble data will show on page load rather than waiting
for a JS fetch.
Let's not overthink it rn but it would be nice if the ScrobbleMonitor
struct could be more generic and support fetching arbitrary types in the
future.
This makes local testing much easier as you can get all requests via the
same port
This allows us to actually use top-level await if we want, and
modernises the output too I guess. Not sure if this is really necessary,
I mostly did it as part of silencing some ESLint errors that were
ultimately resolved differently anyway.
We barely have any JS (and hope to have even less soon) but might as
well take the opportunity to get my head around the new flat config
format. It's fine.
esbuild already bundles all the code together into a single file so this
won't affect code generation, but it does affect the esbuild API script,
which can now make us of top-level await.
Almost all the Sass features I was using can now be written in native
CSS. Some required restructuring the HTML a little bit to make the most
of the cascade but I think it's resulted in a more semantically correct
document. Especially happy with how I have replaced explicit 'left' and
'right' project IDs with a declarative approach using nth-child.
Getting rid of Sass (and autoprefixer/postcss which isn't really needed
these days) has massively improved build times as we no longer need to
shell out to JS.
I needed to bump esbuild to a newer version in order to support CSS
nesting, so also had to update its config file to accomodate API
changes.
Need to install root certificates to authenticate their cert now.
I'll bump the max time and get it preloading when I summon the courage.
I bumped the Rust dependencies late last year, but I didn't realise that
an increase in MSRV is not considered a breaking change, so the Docker
build started failing because it was tagged to an old Rust compiler.
Bumping the compiler also broke as it will default to latest stable
version of Debian when it was cut, so the new image was using a newer
version of Debian with OpenSSL 3, which the old buster image doesn't
support. I should specify the Debian version in the builder image in the
future to avoid this compatibility issue. (I should also actually use
OpenSSL for reqwest as at the moment we aren't using TLS when connecting
to Last.fm...)
Clamp the rotation value to less than 2*pi so that it doesn't start
getting less precise (and eventually overflowing!) as the rotation is
increased during the session.
Not sure whether this was ever intentionally the style but it looks
awful in modern browsers.
Thought the now playing part of the code was malformed but now that I've
written out the minimal structure and checked it against what the API
returns I can see it's all good.
The API is all horribly converted from XML to JSON.
If multiple tasks see that the scrobble cache is out of date
simultaneously, they will all requests write access concurrently. If
there is no check after they have been given the lock that another task
hasn't already got there first then multiple tasks could make the same
call to the last.fm API, writing and re-writing over a perfectly fresh
value.
All this logic is now split between the axum server and fly.io services.
This allows us to immediately return cached scrobbles in the rendered
HTML if available, but never waste any time waiting for the last.fm API
to give us new data if the cache is stale. The 200ms timeout that was
previously in place was never long enough for the last.fm API to return
so it was just an unnecessary delay on response times.
The normalize.css package hasn't been updated in 7 years and I suspect
many of its changes are no longer necessary. modern-normalize is
slightly more opinionated, and resulted in some layout shifts due to it
defaulting to `box-sizing: border-box;`. But that's meant I've now gone
back and improved my CSS to rely less on padding when margins are more
appropriate, and made more use of flexbox to centre elements rather than
auto margins.
Almost all the Sass features I was using can now be written in native
CSS. Some required restructuring the HTML a little bit to make the most
of the cascade but I think it's resulted in a more semantically correct
document. Especially happy with how I have replaced explicit 'left' and
'right' project IDs with a declarative approach using nth-child.
Getting rid of Sass (and autoprefixer/postcss which isn't really needed
these days) has massively improved build times as we no longer need to
shell out to JS.
I needed to bump esbuild to a newer version in order to support CSS
nesting, so also had to update its config file to accomodate API
changes.
I bumped the Rust dependencies late last year, but I didn't realise that
an increase in MSRV is not considered a breaking change, so the Docker
build started failing because it was tagged to an old Rust compiler.
Bumping the compiler also broke as it will default to latest stable
version of Debian when it was cut, so the new image was using a newer
version of Debian with OpenSSL 3, which the old buster image doesn't
support. I should specify the Debian version in the builder image in the
future to avoid this compatibility issue. (I should also actually use
OpenSSL for reqwest as at the moment we aren't using TLS when connecting
to Last.fm...)
If multiple tasks see that the scrobble cache is out of date
simultaneously, they will all requests write access concurrently. If
there is no check after they have been given the lock that another task
hasn't already got there first then multiple tasks could make the same
call to the last.fm API, writing and re-writing over a perfectly fresh
value.