Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

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

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);

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).

Am I a Dickhead? You be the judge.

For so­me rea­son to­day I got in­to a li­ttle spat wi­th Zed Shaw whi­ch en­ded wi­th me blo­cked after a ba­rra­ge of ver­bal abu­se.

So, he sa­ys I am a di­ckhea­d. Is it so? He­re's the ex­chan­ge in an ima­ge, and he­re it is on twi­tter:


It see­ms to me it's mos­tly a ca­se of so­meo­ne being qui­ck to dish abu­se but slow to ac­cept di­sa­gree­men­t. But he­y, ma­y­be I am a di­ckhead for sa­ying tha­t. That con­ver­sation had a few other bran­che­s, but tho­se we­re di­sa­gree­men­ts about the to­pic (in whi­ch, I ha­ve to sa­y, Zed is com­ple­te­ly clue­le­ss, and wron­g, al­thou­gh IA­NA­L) Fin­ding them all may be too mu­ch effort but he­re's one

New Nikola Galleries

One of the re­qui­re­men­ts I had for Niko­la my sta­tic si­te/­blog ge­ne­ra­to­r, was that it should build ima­ge ga­lle­rie­s. And that it should show the ima­ges sorted by da­te, and that it should be func­tio­nal and ni­ce.

We­ll, the ni­ce part has been la­cking for a long ti­me. But I thi­nk I ha­ve a grasp on it no­w.

He­re's be­fo­re:

Leer más…

Contents © 2000-2024 Roberto Alsina