Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Using scripts to update my personal site.

These last few days I have been adding code in Niko­la to give it a more use­ful Python API. I added scripts then I start­ed a PR that lets you mod­i­fy posts pro­gram­mat­i­cal­ly.


Be­cause my site has 20 years of bag­gage. Which means ev­ery bad idea in the my 20 year his­to­ry of do­ing my own blog soft­ware is lurk­ing in it some­where.

For ex­am­ple, when Niko­la got start­ed, it had (it still has it!) sup­port for what I called "meta files". Ba­si­cal­ly, you put your post's con­tent in a file, say "my­post.tx­t" and you added things like the date, the ti­tle, tags and so on in "my­post.meta", which was the metafile.

That was good in that it was a way to quick­ly get it work­ing with­out wor­ry­ing about how to ex­tract meta­da­ta from source files, and to keep source files com­pat­i­ble with oth­er toolchain­s, like do­cu­til­s' or nor­mal mark­down.

BUT, then we added ways to have metadata in the files and keep them compatible. But I still had 1500 metafiles in my site. And getting rid of them would involve some sed some python and some pain, so I never upgraded the posts to the newer format.

Un­til now.

two_post_files = [p for p in site.timeline if p.is_two_file]

for p in two_post_files:
    p.is_two_file = False

What is that? Well, it filters the site.timeline and finds all the things that are in two files using the is_two_file property, and then makes them not be two files.

What is the re­sult?

$ git diff --stat 766d8e1c5dd495d4aa7e27bb0b7f6b2c62c6aa63 | tail -1
 3739 files changed, 20521 insertions(+), 7381 deletions(-)

Of course my site is under git, I would not dare do this without it. And hey, no more .meta files!

Hoy: Mosaicos

Tiling Win­dow Man­ager­s: cosa de nerds o cosa de su­per ul­tra re­con­tra ren­erd­s? De­bería sen­tirme mal porque me pare­cen in­có­mo­d­os y pre­fiero mi win­dow man­ag­er tradi­cional?

No te pre­ocu­pes, acá te mue­stro la ter­cera posi­ción, casi un per­o­nis­mo del mane­jo de ven­tanas: KWin + Kröhnkite, o "co­mo un tiling wm, pero lin­do"

No sé que miér­coles le pasa al sonido a los 2:58, pero no lo pien­so volver a grabar por es­o.

Server Architecture

Just for the record, I saw this hi­lar­i­ous tweet about what you need to "prop­er­ly" de­ploy Word­press in AWS:

So I quick­ly got my Leno­vo Pen out of its hold­er and pro­ceed­ed to do the equiv­a­lent for Niko­la:


Yes, that is my hand­writ­ing.

New Nikola Thing: scripts

Niko­la is a stat­ic site gen­er­a­tor, and it knows its au­di­ence: Nerd­s, pro­gram­mer­s, sci­ence peo­ple, and the like. Oh, and me. I most­ly de­vel­op it for me.

One im­por­tant thing for this cat­e­go­ry of tools is that they should cater to what the users want to do, and al­so to how they want to do it.

So, faced with the need to do things like "set this spe­cif­ic meta­da­ta field in these 490 posts out of the 1450 you have" ... edit­ing them man­u­al­ly is not go­ing to hap­pen.

Sure, I could sed/python/what­ev­er my way to do it "au­to­mat­i­cal­ly". But that is go­ing to be aw­ful­ly er­ror prone.

So, I have start­ed a cam­paign to fix it. I want to make Niko­la be the API to its da­ta. This has two sides.

I need to be able to run one-off things

This needs to be easier than creating a Nikola command plugin but less annoying than typing them in nikola console

[ralsina@salma static]$ nikola console
Scanning posts..........done!
Python 3.8.2 (default, Feb 26 2020, 22:21:03) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

Nikola v8.0.4 -- IPython Console (conf = configuration file, site, nikola_site = site engine, commands = nikola commands)

In [1]:  

The good news is: this is done in git mas­ter!

Now you can create a python script and run it as nikola console -s and the script runs in the same context as the console, so you magically have the site itself and the timeline and the configuration and all the good stuff ready to use.

I need the API to be useful

And this is where Niko­la has ... not been a good boy. Since it was meant to gen­er­ate stat­ic sites, it's pret­ty good about of­fer­ing you ways to know things about your da­ta.

Want to know what is the de­scrip­tion of the tags ap­plied to the post in slovene? it to­tal­ly can do that in two lines.

Want to add a tag to a post? Sor­ry dude, that's im­pos­si­ble.

So, I am adding these things, slow­ly.

And that's the cur­rent sta­tus.

Tribu Greenwich 0

Ha­ce una se­ma­na mas o me­nos cam­bié de tra­ba­jo re­pen­ti­na­men­te. Me des­pi­die­ron1 al me­dio­día y me lle­vó has­ta tar­de esa mis­ma tar­de en­con­trar un nue­vo la­bu­ro.2

Per­dí una pro­me­sa de vi­si­ta a las ofi­ci­nas en Lju­bl­ja­na, ga­né una pro­me­sa de vi­si­ta a ofi­ci­nas en Lon­dres, el di­ne­ro ven­drá de un lu­gar di­fe­ren­te, Se va el clon as­ync de Fla­sk, en­tra Djan­go, co­sas así.

No pen­sé en ese mo­men­to que acon­te­ce­ría un cam­bio mu­cho más fun­da­men­ta­l, un cam­bio de tri­bus.3 Aban­do­né la tri­bu en que vi­ví mi vi­da, la ha­bi­tual­men­te GM­T-3 de mi na­ci­mien­to y me uní a Greenwi­ch 0.

Aho­ra me le­van­to a lo que es­tos ex­tran­je­ros a mi al­re­de­dor afir­man que son las 4:45 AM, así lle­go có­mo­do a mi stan­dup dia­rio, que es a mis 9:15. Es­to tie­ne efec­tos in­te­re­san­tes en mis ... to­do.

¿Mi hi­jo no la­vó los pla­tos co­mo se su­po­ne que ha­ce, y pro­me­tió ha­cer­lo "des­pué­s"? Bue­no, si me des­pier­to y los pla­tos no es­tán la­va­do­s, lo des­pier­to a él, y los pla­tos es­tán lim­pios an­tes del ama­ne­ce­r.

Ten­go ~4 ho­ras de tra­ba­jo tran­qui­lo con la ca­sa en si­len­cio, que en es­ta era en­cua­ren­te­na­da es un mon­tón.

Ter­mino de tra­ba­jar pa­ra las 5:30, cuan­do mi fa­mi­lia ju­ra que son las 13:30, así que pue­do al­mor­zar con ellos sin cor­tar el tra­ba­jo que ya ter­mi­né, y des­pués duer­mo la sies­ta, co­mo un gran­je­ro.

Pue­do des­ayu­nar dos ve­ces al día, tres si le pon­go ga­rra.

Me voy a la ca­ma a las 3A­M/11­PM, así que me sien­to un tras­no­cha­do­r, duer­mo 7 u 8 ho­ras al día pe­ro no to­das jun­ta­s. Es­toy con un li­ge­ro je­tlag en es­te mo­men­to, o tal vez en to­do mo­men­to, sin via­jar en el es­pa­cio, so­lo en el tiem­po.

Veo el ama­ne­cer to­dos los día­s.

Los días son lar­gos, co­mo es lar­go el día más lar­go del ve­ra­no, pe­ro en oto­ño. En ve­rano se­rán más lar­go­s, eter­no­s, días no­rue­go­s, 16 ho­ras de lu­z.

¿Có­mo me sien­to al res­pec­to? No sé. Es co­mo una mó­di­ca aven­tu­ra sin de­jar la ca­sa. Es co­mo vi­vir una se­ma­na sin usar la le­tra "M", co­mo co­mer en­sa­la­da ru­sa y no to­car las za­naho­ria­s, co­mo ir a tra­ba­jar a un ba­rrio dis­tin­to don­de to­do el mun­do es­tá dor­mi­do y no hay au­tos y los pá­ja­ros can­tan fuer­te y es de día en la pan­ta­lla de to­dos los otros y ...

Bue­no, no tan Lo­ve­cra­ft, che.

  1. No rea­l­­men­­te, soy co­n­­tra­­tis­­ta, pe­­ro bue­­­no, ya sa­­be­­n. 

  2. No rea­l­­men­­te, soy co­n­­tra­­tis­­ta, pe­­ro bue­­­no, ya sa­­be­­n. 

  3. Ver http­s://­­pe­­dia.o­r­­g/wiki/Ea­s­­te­r­n_S­­tan­­da­r­­d_­­Tri­­be  

Contents © 2000-2022 Roberto Alsina