Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Publicaciones sobre programming (publicaciones antiguas, página 16)

Son of Bartleblog IV

An­oth­er morn­ing, an­oth­er fea­ture: ar­chive

bartleblog3

Now I'm work­ing on the im­age tool, im­port­ing PyD­S's im­ages and up­load­ing to flick­r, etc.

Son of Bartleblog III

A cou­ple more hours of hack­ing, and the tem­plates are all new, and more func­tion­al then ev­er.

bartleblog2

I am mak­ing heavy use of Ya­hoo's UI li­brary, which makes lots of things much sim­pler:

  • Lay­out us­ing Ya­hoo Grids

    I spent hours mak­ing the lay­out you see now, and the one with Grids works bet­ter and was done in min­utes. Avoid rein­ven­t­ing the wheel works for we­b­­pages, too.

  • Cal­en­­dar us­ing Ya­hoo Cal­en­­dar

    Is­n't it neat? And it work­s, too. Since the link­ing is han­­dled by javascript I may make it so it loads the posts for a month with­­out reload­­ing the page.

  • Styling us­ing their re­set.c­ss stylesheet.

    That stylesheet re­­moves all styling from your page. That way, if there's some­thing there, you put it.

    I used that, added a slight­­ly sim­­pli­­fied stylesheet based on Fire­­fox's de­­fault, Re­struc­­tured Tex­t's and Sil­ver­ci­­ty's, and all the cus­­tomiz­ing I need­ed to do to achieve a sim­­ple but func­­tion­al lay­out were 30 lines of CSS, com­­pared to the rather mon­strous py­d­s.c­ss my blog cur­ren­t­­ly us­es.

  • Mod­­u­lar thin­­gies.

    I turned all Tech­no­rati/HaloScan/Feed­Burn­er/Talkr thin­­gies in­­­to macros that take as con­­fig­u­ra­­tion your per­­son­al da­­ta (for ex­am­­ple, HaloScan ID) and if nec­es­sary a post.

If the styling was a lit­tle more done and a few bugs were ironed, I may even start up­load­ing the site us­ing bartle­blog in­stead of PyDS soon :-)

Son of Bartlebog II

Af­ter a few more hours hack­ing, it's got the fol­low­ing work­ing:

  • Cher­ry­Tem­­plate tem­­plates that do about the same as the Chee­­tah tem­­plates in PyDS

  • Gen­er­ates the whole site and it looks just the same

  • Ad­vo­ga­­to im­­port (my blog should go all the way back to 2000 when I switch!)

  • PyDS im­­port

The main miss­ing things are:

  • Do a de­­cent tem­­plat­ing sys­tem (right now they are em­bed­d­ed in the code)

  • Do a de­­cent con­­fig sys­tem (right now, glob­al var­i­ables)

  • Do up­­load­­ing (or just trust lft­p)

  • Do post/s­­to­ry cre­a­tion

  • Port the RSS tem­­plate

  • Flickr in­­te­­gra­­tion

  • In­­te­­gra­­tion with all those neat lit­­tle gad­get­s: feed­burn­er flares, HaloScan com­­ments which are cur­ren­t­­ly kin­­da graft­ed (on­­ly work for my ac­­count ;-)

  • Look in­­­to Ya­hoo UI tool­k­it for things like the cal­en­­dar and menus.

  • Add the ex­­tra stuff to Re­struc­­tured Text so it:

    • Fix­es au­­­to­­­mat­i­­­cal­­­ly links to post­s/s­­­to­ries in the blog

    • Pret­­­ty-prints code us­ing Sil­ver­­Ci­­­ty

  • Lots of UI stuff

All in al­l, not re­al­ly a huge amount of work, but I am tak­ing it easy.

When KDE4 is out, a ver­sion with a ful­l-fled­get KHTML in it will be a whole lot nicer.

A little project, son of BartleBlog

I have been post­ing this blog us­ing PyDS for over 4 years now. Sad­ly, the PyDS au­thor seems to have aban­doned it. Which is sad, be­cause it's nifty soft­ware.

How­ev­er, keep­ing it work­ing is get­ting hard­er ev­ery year, and I don't ex­pect to be able to do it soon.

Al­so, the da­ta is in a Metak­it database, which is the most an­noy­ing DB ev­er (no re­al schema! colum­nar in­stead of record ori­ent­ed! gouge my eyes with a bread­stick­!)

So, since I have all the data, and my blog­ging needs are mod­est, and no tool does ex­act­ly what I wan­t, I de­cid­ed to write my own.

I could make it a web ap­p, maybe us­ing Tur­bo­Gears, but what the heck, I haven't done a de­cent GUI app in ... ok, ar­guably, I nev­er have done a de­cent one, and my PyQt4 needs some work, and I am kin­da in a groove for ac­tu­al­ly fin­ish­ing things late­ly (I am rather proud of RaSPF).

And I have a neat name (Bartle­Blog) re­served from an­oth­er abort­ed ap­p.

So, here's the manda­to­ry screen­shot af­ter a cou­ple hours hack­ing:

bartleblog

And here are the goal­s:

  • Gen­er­ate stat­ic pages, so it can be used by any­one with a lit­­tle web space (I am a gip­sy)

  • Sim­­ple tem­­plat­ing (Us­ing cher­ry­tem­­plate right now, but should be mod­­u­lar)

  • Re­struc­­tured Text as in­­put mech­a­nism (a­­gain, mod­­u­lar)

  • Good sup­­port for code snip­pets

  • Should sup­­port stat­ic pages (like the ones I have in the Sto­ries link)

  • In­­te­­grate with Flickr for im­ages

  • In­­te­­grate "chunks" in the tem­­plat­ing, where you can do things like set­t­ing the right Haloscan com­­men­t/­­track­­back links eas­i­­ly

  • Sim­­ple cat­e­­go­ry mech­a­nis­m, with a reg­ex­p-based au­­to­­tag­ger with­­out cre­at­ing per-­­cat­e­­go­ry copies of ev­ery­thing.

  • RSS feed gen­er­a­­tion, glob­al and per-­­cat­e­­go­ry.

  • A way to im­­port all my PyDS blog (and maybe my old­er ad­vo­ga­­to things)

  • Use sqlite and SQLOb­­ject for sane stor­age.

So far, it's do­ing some things, I can im­port, ed­it, save (by in­stant ap­pli­ca­tion, there is no "save" here).

I can't yet gen­er­ate the site, or cre­ate a new post, and it should take months to make it use­ful, but let's see how it goes.

RaSPF on its way to release

I have been able to work some more on RaSPF and the re­sults are en­cour­ag­ing.

Thanks to val­grind and test suites, I am pret­ty con­fi­dent it does­n't leak mem­o­ry, or at least, that it does­n't leak ex­cept on very rare cas­es.

I think I found a neat way to sim­pli­fy mem­o­ry man­age­men­t, though, and that's what I want­ed to men­tion.

This is prob­a­bly triv­ial for ev­ery­one read­ing, but I am a lim­it­ed C pro­gram­mer, so when­ev­er some­thing works un­ex­pect­ed­ly right, I am hap­py ;-)

One prob­lem with C mem­o­ry man­age­ment is that if you have many ex­it points for your func­tion­s, re­leas­ing ev­ery­thing you al­lo­cate is rather an­noy­ing, since you may have to do it in sev­er­al dif­fer­ent lo­ca­tion­s.

I com­pound­ed this prob­lem be­cause I am us­ing ex­cep­tions (yeah, C does­n't have them. I used this).

Now not on­ly do I have my re­turns but al­so my throws and what­ev­er un­caught throw some­thing I called has!

Hel­l, right?

Nope: what ex­cep­tions com­pli­cat­ed, ex­cep­tions fixed. Look at this func­tion:

bstring spf_query_get_explanation(spf_query *q, bstring spec)
{
    bstring txt=0;
    struct bstrList *l=0;
    bstring expanded=0;
    bstring result=0;
    struct tagbstring s=bsStatic("");

    try
    {
        // Expand an explanation
        if (spec && spec->slen)
        {
            expanded=spf_query_expand(q,spec,1);
            l=spf_query_dns_txt(q,expanded);

            if (l)
            {
                txt=bjoin(l,&s);
            }
            else
            {
                txt=bfromcstr("");
            }
            result=spf_query_expand(q,txt,0);
            throw(EXC_OK,0);
        }
        else
        {
            result=bfromcstr("explanation: Required option is missing");
            throw(EXC_OK,0);
        }
    }
    except
    {
        if(expanded) bdestroy(expanded);
        if(txt) bdestroy(txt);
        if(l) bstrListDestroy(l);
        on (EXC_OK)
        {
            return result;
        }
        if(result) bdestroy(result);
        throw(EXCEPTION.type,EXCEPTION.param1);
    }
}

It does­n't mat­ter if spf_­query_­ex­pand or spf_­query_dns_txt throw an ex­cep­tion, this will not leak.

Nice, I think :-)


Contents © 2000-2023 Roberto Alsina