โ—index ๐ŸŒŽautoblob.md ๐Ÿท๏ธtags ๐Ÿ‘คabout

๐ŸŒŽ Uploading blog programmatically

I am a lazy person spending most of their time in a terminal ๐Ÿ’ป...

This is one of the reasons why lmno.lol really suites me.. I update my markdown locally, drag it on the edit page, click save, boom, done ๐Ÿ‘ˆ!

Since I don't want to move out of my terminal, I hacked a little script using curl to upload my blog programmatically.

lmno.lol is protected by a cookie based authentication system. The first thing to do is to login with the username and password. Luckily the login screen is a form I can submit with curl with roughly this command:

login curl

After storing the cookie session key, we can now move to the next step, which is uploading a new version of lmno.lol/crisidev!

Today I learned something wild!

I was inspecting the Firefox console during the blog upload phase, after clicking save on https://lmno.lol/crisidev/edit and I found the API POST call to https://lmno.lol/api that is responsible to update my blog.

I click on the request and ๐Ÿ”ฅ

copy as curl

I am crying of joy.

Update my blog

Mozilla produces a working curl command that I had to tweak a little to basically this:

api curl

Easy!

The result

script result

Auto publish anyone? ๐Ÿคฉ

The blog is a self-contained Github repo and is published to lmno.lol/crisidev using a Github action based on the learnings above so that every time I update it the repository and push on main, the CI kicks in and a new version is published automatically ๐Ÿš€

The code

Here is the full script, which is shared also as a gist.

lmno blog upload script

:discuss share / comment on Mastodon โ†’