Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

New in Nikola v6 part I: Typography

I am plan­ning to do a ma­jor re­lea­se (ver­sion 6!) of Niko­la my sta­tic blog and si­te ge­ne­ra­tor the next weeken­d. It's a ma­jor ver­sion be­cau­se the­re has been a ton of fea­tu­re wo­rk do­ne. So, I wi­ll do a qui­ck se­ries hi­gh­li­gh­ting so­me of tho­se im­pro­ve­men­ts this week.

Today's Topic: Typography.

Niko­la us­ed to su­ck at this. It pro­du­ced si­tes like most web­si­tes: ab­so­lu­te gar­ba­ge when it ca­me to ty­po­gra­ph­y. So, we fixed it.

He­re is what a cer­tain sec­tion of A Study in Scar­let looked like when built using Niko­la 5.5.1 (the cu­rrent re­lea­se):

Leer más…

Six Earlier Days (Every Day, #0.5)

Cover for Six Earlier Days (Every Day, #0.5)

Review:

Ev­ery­thing good about Ev­ery Day is here, and ev­ery­thing bad is here too, both just small­er. So, 4 small stars.

You

Cover for You

Review:

Any­one who has ev­er been in­volved in a long-lived project knows the feel­ing this book de­scribes. It's fun, it's de­cent­ly writ­ten, and it has that feel­ing. I liked it.

The best reStructuredText directive ever. Really.

It all started quie­tly wi­th an Is­sue in the Niko­la bug tra­cke­r:

gustavodiazjaimes opened this issue 3 hours ago
oembed by micawber - feature sugestion

instead of using specific code for embed object (Youtube, Vimeo, Soundcloud) use a generic solution like https://github.com/coleifer/micawber

So, I looked at mi­caw­ber. And it's awe­so­me and I had ne­ver heard of it be­fo­re. What it does is, it looks at a UR­L, and if it kno­ws the si­te whe­re it's pointed at, it wi­ll then ga­ther in­for­ma­tion from it. And using that in­for­ma­tion it wi­ll crea­te for you a HT­ML frag­ment so you can em­bed it in your own HT­ML pa­ge.

And how hard is it to turn that in­to a reS­truc­tu­re­dText di­rec­ti­ve? NOT HARD AT ALL.

import micawber

class Media(Directive):
    """ Restructured text extension for inserting any sort of media using micawber."""
    has_content = False
    required_arguments = 1

    def run(self):
        providers = micawber.bootstrap_basic()
        return [nodes.raw('', micawber.parse_text(self.arguments[0], providers), format='html')]

So no­w, in Niko­la's gi­thub mas­ter you can do this:

Leer más…

My Solution For Bootstrap's Freaking Fixed Navigation Bar Hiding Things

This is a we­ll kno­wn pro­blem wi­th boots­tra­p:

If you use a fixed na­vi­ga­tion bar at the to­p, whe­ne­ver you fo­llow a li­nk to so­mewhe­re in­si­de the pa­ge, the ac­tual li­nk tar­get is going to be hi­dden be­low that freaking na­vi­ga­tion ba­r.

The­re are a ton of so­lu­tion­s, whi­ch ha­ve two tons of mi­nor is­sues. The­re see­ms to be no way to sol­ve this using CSS and JS wi­thout cau­sing other pro­ble­ms.

The­re are a bun­ch of JS so­lu­tions aroun­d. He­re's mi­ne:

<script type="text/javascript">
 $(window).on('hashchange', function(){
     if (location.hash) {
         $('body').animate({scrollTop: $(location.hash).offset().top - $('#navbar').outerHeight(true)*1.2 }, 1);
     }
 });
 $(document).ready(function(){$(window).trigger('hashchange')});
 </script>

It wo­rks we­ll, is short and has de­cent bro­w­ser co­ve­ra­ge. It on­ly fails in the cor­ner ca­se of cli­cking on the sa­me in­ter­nal li­nk twi­ce (whi­ch, who ca­res).


Contents © 2000-2023 Roberto Alsina