Publicaciones sobre programming (publicaciones antiguas, página 16)
Son of Bartleblog III
A couple more hours of hacking, and the templates are all new, and more functional then ever.
![bartleblog2](http://farm1.static.flickr.com/148/435549883_2289c707a9_m.jpg)
I am making heavy use of Yahoo's UI library, which makes lots of things much simpler:
-
Layout using Yahoo Grids
I spent hours making the layout you see now, and the one with Grids works better and was done in minutes. Avoid reinventing the wheel works for webpages, too.
-
Calendar using Yahoo Calendar
Isn't it neat? And it works, too. Since the linking is handled by javascript I may make it so it loads the posts for a month without reloading the page.
-
Styling using their reset.css stylesheet.
That stylesheet removes all styling from your page. That way, if there's something there, you put it.
I used that, added a slightly simplified stylesheet based on Firefox's default, Restructured Text's and Silvercity's, and all the customizing I needed to do to achieve a simple but functional layout were 30 lines of CSS, compared to the rather monstrous pyds.css my blog currently uses.
-
Modular thingies.
I turned all Technorati/HaloScan/FeedBurner/Talkr thingies into macros that take as configuration your personal data (for example, HaloScan ID) and if necessary a post.
If the styling was a little more done and a few bugs were ironed, I may even start uploading the site using bartleblog instead of PyDS soon :-)
Son of Bartlebog II
After a few more hours hacking, it's got the following working:
CherryTemplate templates that do about the same as the Cheetah templates in PyDS
Generates the whole site and it looks just the same
Advogato import (my blog should go all the way back to 2000 when I switch!)
PyDS import
The main missing things are:
Do a decent templating system (right now they are embedded in the code)
Do a decent config system (right now, global variables)
Do uploading (or just trust lftp)
Do post/story creation
Port the RSS template
Flickr integration
Integration with all those neat little gadgets: feedburner flares, HaloScan comments which are currently kinda grafted (only work for my account ;-)
Look into Yahoo UI toolkit for things like the calendar and menus.
-
Add the extra stuff to Restructured Text so it:
Fixes automatically links to posts/stories in the blog
Pretty-prints code using SilverCity
Lots of UI stuff
All in all, not really a huge amount of work, but I am taking it easy.
When KDE4 is out, a version with a full-fledget KHTML in it will be a whole lot nicer.
A little project, son of BartleBlog
I have been posting this blog using PyDS for over 4 years now. Sadly, the PyDS author seems to have abandoned it. Which is sad, because it's nifty software.
However, keeping it working is getting harder every year, and I don't expect to be able to do it soon.
Also, the data is in a Metakit database, which is the most annoying DB ever (no real schema! columnar instead of record oriented! gouge my eyes with a breadstick!)
So, since I have all the data, and my blogging needs are modest, and no tool does exactly what I want, I decided to write my own.
I could make it a web app, maybe using TurboGears, but what the heck, I haven't done a decent GUI app in ... ok, arguably, I never have done a decent one, and my PyQt4 needs some work, and I am kinda in a groove for actually finishing things lately (I am rather proud of RaSPF).
And I have a neat name (BartleBlog) reserved from another aborted app.
So, here's the mandatory screenshot after a couple hours hacking:
![bartleblog](http://farm1.static.flickr.com/161/432277043_1ac57d4317_t.jpg)
And here are the goals:
Generate static pages, so it can be used by anyone with a little web space (I am a gipsy)
Simple templating (Using cherrytemplate right now, but should be modular)
Restructured Text as input mechanism (again, modular)
Good support for code snippets
Should support static pages (like the ones I have in the Stories link)
Integrate with Flickr for images
Integrate "chunks" in the templating, where you can do things like setting the right Haloscan comment/trackback links easily
Simple category mechanism, with a regexp-based autotagger without creating per-category copies of everything.
RSS feed generation, global and per-category.
A way to import all my PyDS blog (and maybe my older advogato things)
Use sqlite and SQLObject for sane storage.
So far, it's doing some things, I can import, edit, save (by instant application, there is no "save" here).
I can't yet generate the site, or create a new post, and it should take months to make it useful, 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 results are encouraging.
Thanks to valgrind and test suites, I am pretty confident it doesn't leak memory, or at least, that it doesn't leak except on very rare cases.
I think I found a neat way to simplify memory management, though, and that's what I wanted to mention.
This is probably trivial for everyone reading, but I am a limited C programmer, so whenever something works unexpectedly right, I am happy ;-)
One problem with C memory management is that if you have many exit points for your functions, releasing everything you allocate is rather annoying, since you may have to do it in several different locations.
I compounded this problem because I am using exceptions (yeah, C doesn't have them. I used this).
Now not only do I have my returns but also my throws and whatever uncaught throw something I called has!
Hell, right?
Nope: what exceptions complicated, exceptions fixed. Look at this function:
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 doesn't matter if spf_query_expand or spf_query_dns_txt throw an exception, this will not leak.
Nice, I think :-)