-
byThe problem with having two fun side projects:Do I write the Strava integration for Tanzawa so I can get all of my running data (or lack thereof tbh) just so.ΒOr do I write some billing/electricity tariff calculations / #OctopusEnergy API integrations, so I can show just how much my solar / battery is saving me each month....I reckon Strava is more important/less like work code... We show estimated costs on our graphs...I bet I can use that instead of calculating things meself to start?
-
byRemember how places like LiveJournal used to have "post flair"? They were effectively different emojis for your moodΒ or the weather. I think there were even some music integrations so show the song you're listening to...I think I need that on my blog.Β Weather could be done free with OpenWeatherMap/weather-icons. Music might be trickier...
-
Editing Bookmark / Reply Titles with HTMX
byThis post is a followup to Allow editing of replies/titles and describes some of the changes made to enable this functionality (#265) and my thoughts after my first steps with HTMX.Unable to change bookmark / reply titles βΉοΈ
Above is the before state, which is a static view of title/url of a bookmark/reply. Below is aΒ gif of what I built and the finished state. There's a new change button, which you can click to reveal a form that allows you to edit the record. This form allows you to save or cancel. Save updates the record and changes the screen back to the "read only" view, while cancel just loads the current "read only" view. Zero custom Javascript.Editing a bookmark url / title in Tanzawa
Powering this is two new simple views in the admin site. One loads the entry's bookmark/reply and returns the read only view. The other loads the same record and displays a form on get, updates it on post.
The htmx and these two small views were the simple part of this feature. The heavier lift was decoupling the Tanzawa micropub endpoint from the admin views/forms, and then updating the admin views to no longer expect IndieWeb extension data (reply/bookmark url/titles etc...) on update (it's still required on create).
Thankfully I had functional tests for my micropub endpoint, so I could be confident that my refactoring didn't break existing functionality. Those tests allowed me to extract the logic from the admin forms and put them into a application function. This new application functions are reused by all interfaces creating/updating entries.
The next phase was adding tests to the admin views and then updating them to use the common application functions. This work was mostly a slog because I needed to add tests and better factories for my tests before doing the actual refactor. There's still more improvement that can be made in the test factories to make them a bit more DRY, but they're good enough for now.
Working with HTMX has been a dream. Rather than usingΒ Javascript to tweak DOM, I can simply make calls to the backend to get html from the backend by adding just a couple of attributes to my template dom. All of this using the same django templates.
My next steps with HTMX are going to be to look into integrating django-components, so I can wrap up the Javascript I do need with the their templates/css and do some more refactoring. For example, right now reply/bookmarks have effectively the same templates / views duplicated. Using components, I should be able to have a single logical component to power both.
If the components strategy works, I will look at breaking out various parts of Tanzawa into htmx/django-components for easier maintenance e.g. the location selector or location view on the bottom of checkins. -
Response to
byThis PR started as an experiment with HTMX to allow Tanzawa to edit reply/bookmark titles. As all of the entry creation forms/views are inherited from similar base-classes for easy/speed of initial...
I've re-worked all of the create/update views for each post type to use application functions and added functional tests. Editing the url/title for reply posts, works really well. HTMX is allowing me to create the simple interactions I want without Javascript.
The biggest change is reply data is no longer updated all at once with the rest of the post, but rather when you finish editing the title/url, similar to how editing a GitHub PR title works.
The last bit that I think needs some more work, unrelated to the rest main objective of his issue, is the first step when creating a reply where I request the URL to, and it uses Turbo to fetch the meta-data / return a page that can create a reply.
This flow may need a bit more yak shaving so it doesn't use Turbo at all. Will give it a fiddle to see if I can refactor and simplify the flow using HTMX. -
The Week #129
by- After years of regularly and then sporadically saving for retirement, I've finally automated it again...kinda. If I were in the US, I'd have access to regular retirement accounts and things could be deducted in a tax efficient way from my pay check. As an American, I also can't take advantage of any non-US retirement savings schemes (π€ͺ). So what I'm basically left with is depositing some amount into into a regular taxed brokerage account.
What I've setup is: an automatic from Wise to my US bank account, and a few days after an automatic withdrawal from my US bank account to Vanguard. The two bits I can't automate are: the wire/furikomi from my Japanese bank account to Wise and once the money is actually in Vanguard, purchasing of ETFs (VOO index funds, mostly). My hope is that Wise will send me an email with the amount I need to send in yen each month (because exchange rates change). - Setting this up makes really happy. It's been one of those tasks in the back of my head for quite a while and the crap exchange rate made it even less attractive. The exchange rate is still horrible (but less so). I reckon it will all even out in the end. But perhaps the best bit is I discovered I can now purchase fractional ETFs.
I'll explain. Let's say I have $200, and I want to buy 1 share of VOO (a S&P 500 index fund) that I'll sell off when I rewrite, and it costs $350. Normally,I have to hold my $200, not earning anything, wait until I had $350 and hope that by the time I did the cost hasn't risen to $400 and make my purchase. Now I can just buy $200 worth of the stock, which makes it much easier to invest the same amount each month, no matter the price of the stock. - There was a bunch of noise on the bird site with the owner doing stupid, stupid shit. Like blocking linking the other sites stupid. ON THE INTERNET. :facepalm: Good riddance. So glad I've made my home on the internet my own domain / IndieWeb enabled.
- I've been making really good progress on my major refactoring of the Tanzawa. This has me mostly pulling logic out of ModelForms and moving them into application/domain functions that I can reuse throughout my site. The create methods have been refactored and the update methods are mostly so. I reckon I'll need another pass at views themselves as they're a bit crufty, still.Β
- We had a Christmas social at work to celebrate the year and it was a lot of fun. We've grown so much in the past year. We went to Soul Food House in Tokyo. I've been wanting to try that place for years, but it's in central Tokyo β some place I'm not going to go unless I'm in the area. Maybe it was the classic American cooking, or maybe it wasΒ the Christmas poem read in an English accent, but it finally felt like Christmas is starting.
- Friday was Leo's Christmas pageant where the school puts on a play about the birth of Jesus andΒ then they sing some Christmas songs. When thinking about the amount of chaos you'd expect at a pre-school production of...anything, and then reflecting on the various happenings (kids crying, kids running around, props falling over) that happened during the production...I came to the conclusion that there was just the right amount of chaos this year that it kept things interesting. Not enough and it gets kinda boring, "what are these kids? professionals?" you think to yourself. But they really hit the mark so well, I even heard one of the moms mention the chaos during the show. I'm looking forward to next year when it's Leo's grade's turn to have speaking roles...and maybe a bit less chaos.
- After years of regularly and then sporadically saving for retirement, I've finally automated it again...kinda. If I were in the US, I'd have access to regular retirement accounts and things could be deducted in a tax efficient way from my pay check. As an American, I also can't take advantage of any non-US retirement savings schemes (π€ͺ). So what I'm basically left with is depositing some amount into into a regular taxed brokerage account.