Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Refreshed rst-cheatsheet

A whi­le ago, I created a 2-­pa­ge PDF ver­sion of the res­truc­tu­red text qui­cks­tart meant to be printe­d, fol­ded in half and kept handy un­til you fi­na­lly re­mem­ber how to do footno­tes (10 years and sti­ll wai­tin­g, in my ca­se).

It was brou­ght to my atten­tion that the gi­thub pro­ject did not men­tion how to build it. Then I no­ti­ced that not on­ly it did­n't ex­plain tha­t, it was al­so mis­sing cri­ti­cal fi­le­s.

So, I added the fi­le­s, fixed a cou­ple of things that we­re not wo­rking per­fec­tly wi­th the la­test rs­t2­pdf and the­re is now a fresh PDF ready for you!

Nikola Can Parse That

Just for com­ple­te­ness' sake I ha­ve go­ne over Wiki­pe­dia's list of li­gh­twe­ight ma­rkup lan­gua­ges and added su­pport in Niko­la (a sta­tic si­te and blog ge­ne­ra­to­r) for a cou­ple of the­m: BB­Co­de and tx­t2­tags, whi­ch brings the num­ber of su­pported ma­rkup for­ma­ts to 7 (the others are reS­truc­tu­red tex­t, ma­rk­do­wn, HT­M­L, tex­ti­le and Wiki).

Of the list of ma­rkup lan­gua­ges, the on­ly mis­sing ones wi­th a Py­thon im­ple­men­ta­tion are As­ci­i­Doc and Ma­rk­do­wn Ex­tra.

Why bo­ther wi­th this? It's not as if the­re was so­meo­ne asking for BB­Co­de su­ppor­t. Ho­we­ve­r, one of the uses I want to su­pport is ar­chi­ving si­tes. Su­ppo­se you ha­ve a fo­rum you want to shut do­wn? I want you to be able to ar­chi­ve it (e­ven if it's so­me wo­rk) and keep the da­ta out the­re. A wiki? Sa­me thin­g.

This is a first step in that di­rec­tio­n.

Haceme Hablar

Una co­sa que me ha ayu­da­do a ser me­nos tí­mi­do, y po­der pro­gre­sar en la vi­da, es ha­blar en pú­bli­co. Pe­ro es­te úl­ti­mo par de años lo ven­go ha­cien­do po­co.

Así que, há­gan­me ha­blar má­s. Me gus­ta­ria ha­cer­lo en lu­ga­res en los que nun­ca es­tu­ve. Si no es ho­rri­ble­men­te le­jos de Bue­nos Ai­res ca­paz que ni te pi­do que pa­gues via­je y/o es­ta­dia, si el even­to es in­te­re­san­te o el lu­gar es co­pa­do, lo pa­go yo.

Pue­do ha­blar de py­tho­n, so­ftwa­re li­bre en ge­ne­ra­l, o de otras co­sas que me su­gie­ran, en in­glés o ar­gen­tino.

Mardel->Retiro->San Isidro->Ezeiza->Dallas->San Francisco

Es­toy en un even­to de Ca­no­ni­cal en San Ma­teo (al la­di­to de San Fran­cis­co­). Lle­gué aye­r, y hoy es el úl­ti­mo día li­bre, así que hay que pa­sea­r.

Pa­ra em­pe­za­r, acá es­tán las fo­tos del via­je no hay mu­cho to­da­vía pe­ro las voy a ir agre­gan­do.

El via­je...

Es­ta­ba en Mar del Pla­ta vi­si­tan­do a la fa­mi­lia el jue­ve­s, y te­nía pa­sa­jes pa­ra Bue­nos Ai­res pa­ra la me­di­ano­che. A las 9PM ... pa­ro de mi­cros de lar­ga dis­tan­cia. Co­rro a la es­ta­ción pa­ra ver que se po­día ha­ce­r, no hay pa­sa­jes has­ta la se­ma­na si­guien­te. Em­pez­mos a con­si­de­rar ha­cer 500KM en ta­xi.

A las 11... se le­van­ta el pa­ro! Aga­rro a la fa­mi­lia, las va­li­ja­s, me sub al co­lec­ti­vo­... no, no su­bo por­que soy un pa­pa­ru­lo y com­pré pa­ra las 00:05 del jue­ves en vez de las 00:05 de vier­nes.

En Mar del Pla­ta a la me­di­ano­che sin bo­le­to­s... bue­no, com­pra­mos bo­le­tos pa­ra 15 mi­nu­tos des­pué­s. Si se pue­de arre­glar con pla­ta, lo bue­no es que te da una mé­tri­ca. Soy $780 pe­lo­tu­do.

Así que ten­go pa­sa­je­s, pe­ro no son pa­ra San Isi­dro, son pa­ra Re­ti­ro, que es­tá a 25k­m.

A las 00:30 es­ta­mos en el bon­di, a las 5:45 es­ta­mos en re­ti­ro, a las 6:00 es­ta­mos en un re­mi­se, a las 6:45 es­toy en ca­sa, a las 7:00 es­toy dor­mi­do, a las 9:00 es­toy la­bu­ran­do.

Tra­ba­jo en­tre­cor­ta­do ha­cien­do las va­li­jas y esas co­sas, a las 5:30­PM es­toy en un au­to a Ezei­za (35K­M). Cuan­do es­ta­mos en­tran­do al aero­puer­to em­pie­za a salir hu­mo del ai­re acon­di­cio­na­do. De­be­ría men­cio­nar que no fun­cio­na­ba y lle­vá­ba­mos 1:30 ho­ras a pa­so de hom­bre ba­jo el so­l.

En­ton­ce­s, el au­to es­tá pren­di­do fue­go, pe­ro po­qui­to, se apa­ga, me ba­jo, lo en­cuen­tro a Lu­cio, che­cki­n, ca­fé, a las 10:00­PM es­toy en el avió­n.

Pe­ro hay que es­pe­rar 30 mi­nu­tos en la pis­ta por el trá­fi­co. Ade­más el ca­pi­tán nos di­ce que es­te es el úl­ti­mo vue­lo del avión por­que es muy vie­jo y lo van a ven­der co­mo cha­ta­rra. Así que es­ta­mos vo­lan­do en cha­ta­rra. Ade­más la mi­tad de las pan­ta­llas no an­da, hay 6 pe­lícu­las pa­ra ver y ... tie­nen fun­cio­nes. Po­ne­le que que­rés ver "Taken 2"? Bue­no, o la aga­rrás 45 min­tuos em­pe­za­da o es­pe­rás una ho­ra.

Es mi pri­mer vue­lo en Ame­ri­can Air­li­nes, es siem­pre así?

Lle­ga­mos a Da­lla­s, pa­sa­mos los ven­ti­trés che­c­queos de se­gu­ri­da­d, adua­na, etc, y es­ta­mos en USA! Ahí Lu­cio di­ce que no es­ta­mos en el mis­mo vue­lo a SF pe­ro es que es­tá mi­ran­do el boar­ding pa­ss equi­vo­ca­do.

Nos to­ma­mos el mo­no­rrie­l, cru­za­mos to­do el aero­puer­to, y lle­ga­mos al avión con 5 mi­nu­tos de so­bra. Co­mo me per­dí la ce­na en el otro vue­lo, el des­ayuno fué pa­té­ti­co, y es­te vue­lo de 3:50 ho­ras no in­clu­ye co­mi­da me pi­do un apple fri­tter de Dunkin Do­nu­ts.

Oh, apple fri­tte­r, no sé si real­men­te sos así de de­li­cio­so, o si ten­go tan­ta ham­bre, pe­ro te amé. Eras tan dul­ce y sua­ve, tan azu­ca­ro­so y man­zá­ni­co, tu tex­tu­ra tan lin­da y tu ta­ma­ño tan enor­me. Aún si vos fuis­te la cau­sa de mi des­com­pos­tu­ra in­tes­ti­na­l, va­lió la pe­na, apple fri­tte­r, siem­pre te re­cor­da­ré.

Nos su­bi­mos a un 757 que es­ta­ba com­ple­ta­men­te mu­grien­to. Sos­pe­cho que la fuer­za que lo man­te­nía uni­do es la fuer­za de vo­lun­tad de los áca­ros de sus as­que­ro­sos asien­to­s. Tie­ne pan­ta­llas CRT de 14" ca­da tan­tas fi­la­s, pe­ro la vis­ta por la ven­ta­ni­lla es bue­ní­si­ma, así que mi­ro pa­ra afue­ra y lis­to.

Lle­ga­mos al aero­puer­to, otro mo­no­rriel (dos en un día!) y bus­ca­mos el au­to. Da­dos la op­ció­n, por su­pues­to que eli­jo el Blue Nissan Ver­sa! Good Ca­r!

http://heroeswiki.com/images/thumb/b/b2/Nissan_versa.jpg/250px-Nissan_versa.jpg

Ya sé que na­die se acuer­da, pe­ro la 1ra tem­po­ra­da de Hé­roes es­ta­ba bue­na.

Te­ne­mos 2.5 ho­ras pa­ra lle­gar al tour en Se­gwa­y, así que no va­mos al ho­te­l, me­te­mos to­do en el baúl y nos di­ver­ti­mos tres ho­ra­s.

//ralsina.me/galleries/san_francisco_2013/P1010162.JPG

De fon­do, Al­ca­tra­z. En pri­mer pla­no, dos ner­ds di­vir­tién­do­se.

Ter­mi­na­mo­s, vi­mos los leo­nes ma­ri­no­s, to­ma­mos un ca­fé, san­gu­che de que­so, vol­vi­mos al au­to no te­ne­mos GPS ni te­lé­fo­nos que an­den, pe­ro te­ne­mos ma­pas ca­chea­dos y 3% de ba­te­ría! Y una va­ga idea de adon­de es­ta­ba el ho­te­l! Lle­ga­mo­s, lla­mo a la ar­gen­ti­na y me des­ma­yo al­re­de­dor de la me­di­ano­che ho­ra ar­gen­ti­na, unos dos días des­pués de su­bir al co­lec­ti­vo en Mar del Pla­ta.

Y me des­per­té y es­cri­bí es­to.

Adding Support for a Markup to Nikola

One of the goals for Niko­la, my sta­tic si­te/­blog ge­ne­ra­tor is that it should be ea­sy to ex­ten­d. For exam­ple, to­day I added su­pport for two ma­rkup­s: tex­ti­le and Creo­leWiki.

Sin­ce Niko­la al­ready su­pported HT­M­L, reS­truc­tu­re­dText and Ma­rk­do­wn, adding a cou­ple mo­re is not ve­ry di­ffi­cul­t. He­re's ho­w:

  1. Crea­­te a .plu­­gin fi­­le like this one:

[Core]
Name = textile
Module = compile_textile

[Documentation]
Author = Roberto Alsina
Version = 0.1
Website = http://nikola.ralsina.me
Description = Compile Textile into HTML

Then you need to crea­te a py­thon mo­du­le ca­lled (in this ca­se) com­pi­le_­tex­ti­le.­py

That fi­le is boi­ler­pla­te plus two me­tho­d­s, com­pi­le_ht­ml and crea­te_­post

The com­pi­le_ht­ml me­thod takes two ar­gu­men­ts, one fi­le from whi­ch it rea­ds the ma­rku­p, and one to wri­te HT­M­L. Exam­ple:

def compile_html(self, source, dest):
    if textile is None:
        raise Exception('To build this site, you need to install the "textile" package.')
    try:
        os.makedirs(os.path.dirname(dest))
    except:
        pass
    with codecs.open(dest, "w+", "utf8") as out_file:
        with codecs.open(source, "r", "utf8") as in_file:
            data = in_file.read()
        output = textile(data, head_offset=1)
        out_file.write(output)

Make su­re to use utf8 eve­r­yhe­re.

The crea­te_­post func­tion is us­ed to crea­te a new, emp­ty, post wi­th so­me me­ta­da­ta in it. Exam­ple:

def create_post(self, path, onefile=False, title="", slug="", date="", tags=""):
    with codecs.open(path, "wb+", "utf8") as fd:
        if onefile:
            fd.write('<notextile>  <!--\n')
            fd.write('.. title: %s\n' % title)
            fd.write('.. slug: %s\n' % slug)
            fd.write('.. date: %s\n' % date)
            fd.write('.. tags: %s\n' % tags)
            fd.write('.. link: \n')
            fd.write('.. description: \n')
            fd.write('--></notextile>\n\n')
        fd.write("\nWrite your post here.")

The me­ta­da­ta has to be in the form ".. field­na­me: fiel­d­va­lue" and usua­lly nee­ds to be wra­pped in a co­m­ment so that it's not sho­wn in the ou­tpu­t.

The one­fi­le pa­ra­me­ter means you ha­ve to wri­te that me­ta­da­ta in the pos­t. If it's Fal­se, you do­n'­t.

In so­me ra­re ca­ses (Creo­le, I am looking at you) co­m­men­ts are not su­pported and you should rai­se an ex­cep­tion if one­fi­le is True.

And tha­t's it, ma­rkup su­pport is fair­ly ea­sy to add as long as the­re is a py­thon im­ple­men­ta­tion of a func­tion to con­vert ma­rkup in­to ht­m­l.


Contents © 2000-2023 Roberto Alsina