Showing posts with label genshi. Show all posts
Showing posts with label genshi. Show all posts

Thursday, July 12, 2007

Website finally updated, hooray!

After years of malnourishment and two weeks of development, my little old static website (now using a smaller domain name!) is live. The old website, like the new website, was created via a templating system. However, the former website's templating system was homegrown using PHP4 classes (disgusting, I know...but that's all I could use at the time). Even more disgusting about my system was that it was HTML comment directives plus a regular expression parser. I was so young and naïve, and I hadn't taken a compilers class yet. So this time around, I said "screw it" and went with a) my favorite language, Python, and b) the template software that I had been using for my Trac-AtomPub plugin (yes, not -atompp anymore, per the lengthy discussion on the atom-protocol mailing list).

The Journey

As the new website was a chance to experiment with new things, I decided to take the plunge and use HTML5 to markup my website. And with any sort of experimental technology, there were many problems.

First, I tried to use the genshihtml5 plugin, but strangely enough the code was a bit buggy (e.g., it was missing an import), and I could never figure out how to get it to output proper HTML5 while still removing end tags from tags which don't need them, e.g. <link/>, while retaining them for tags which require one, e.g., <script/>.

Next, I tried to use html5lib's Genshi-Stream-based tree walker. For some reason, it simply would not output any data. I don't remember all of the details, but I do remember inserting a lot of print statements in html5lib to see if I could find the bad piece.

Finally, I gave up and made Genshi just output XHTML plus the extra HTML5 tags. I figured that all of the debugging trouble simply wasn't worth it for the timeframe I had envisioned.

(As an aside, I do plan on submitting the patches that I've made as a result of this...exercise (for lack of a better word) so that they can be integrated in future releases of the respective software.)

Actual usage of new HTML5 tags was...interesting to debug. If you're writing HTML5 and not XHTML5, and you're viewing the page in Firefox, this is what the DOM tree looks like (according to Firebug):

<figure _moz-userdefined="" />
<img src="..." alt="..." />
<legend>...</legend>

For comparison, this is what it looks like when rendered as XHTML5:

<figure>
<img src="..." alt="..." />
<legend>...</legend>
</figure>

That completely broke my CSS files, as I was using child/descendant rules utilizing the new tags. This sort of thing is why I love using Firebug.

Testing

I've really only thoroughly tested this website on Firefox 2.x (Windows & Linux). I just checked it on Opera 9.20 (Linux) and a relatively old development version of Gtk-Webcore (AKA WebKit), and the only bug that I see (in both of them, strangely) is some sort of CSS error in calculating the spacing for the <dd/> box for "Special Skills" in my CV.

Future

Future plans include packing both the CSS and the JavaScript, via csstidy and packer, respectively. Right now there are several bugs with regards to integrating the two applications with my build system. csstidy interprets white-space values incorrectly, particularly the vendor-specific values. I'm currently trying to integrate packer via this nifty little python module that uses ctypes to create an interface with Mozilla's Spidermonkey JavaScript engine. Unfortunately, there's a recursive reference somewhere in base2, and the module is choking on it, so I have to figure out how to resolve that (if possible). Another future plan involves making the site fully dynamic in that the page layout stays the same, while background XMLHttpRequests retrieve the page contents when internal links are clicked. Obviously the current behavior would be retained as a fallback.

Anyhow, there are more details about how I made my website on the colophon. Bug reports, suggestions and feature requests are welcome!

Tuesday, April 17, 2007

Re: Genshi Filters for Venus; Genshi + Trac-AtomPP

This news is excellent. One of my side projects (although, it was pretty low on my list) was to figure out how to use Genshi templates in Venus. I started out by copying the Django template code/unit tests and adapted them for Genshi. However, I got stuck getting some of the unit tests to pass (_item_title and _config_context). Perhaps sometime this weekend I can see how this particular implementation works.

Speaking of Genshi, I just noticed that they had released version 0.4. Hopefully, this will help me resolve the last APE error in my Trac-AtomPP plugin — adding app:edited elements to relevant entries and sorting by that property.

While I'm thinking about it (this really seems to be turning into a stream of consciousness post), I'm not exactly sure how to page the collection efficiently, considering that Trac creates the wiki page list via a generator. Right now I'm just putting everything into one feed, but obviously that doesn't scale very well.

Saturday, January 13, 2007

Several items

The last post was 1.5 months ago, awesome. Anyhow, here are some thoughts on stuff I've done/explored in the computer realm during that time:

  • Beryl is awesome. Too bad it doesn't play well with tvtime, or else I'd permanently enable it and all the associated settings. Also, my video card is one of those crippled ones (ATI Radeon 9250SE), so it's a bit slow as well.
  • My capstone project is in full swing. I've mostly stopped using my hand-rolled Atom parser/generator, since I got stuck on how to implement extensions. For generation, I've switched to using Genshi templates. Genshi has a pretty nice templating language for both XML and text based documents. For parsing, I think I'm going to use lxml or ElementTree, depending on how well XPath is supported.
  • Given the amount of attention that OpenID has been given in the blogosphere lately, I was thinking about how it could be used to integrate with the UWNetID system. Unfortunately, I found that it was rather difficult to modify the current implementations in order to add such support. So, I'm currently writing a PHP5 class + mini-application to be an OpenID server. So far, I have the association mode completed, and the checkid modes are in progress. I am proud of myself for actually implementing the Diffie-Hellman key exchange, since while I am fascinated with cryptography, my math skills in that area are...lacking. It's also nice to refresh my PHP skills, as I haven't programmed in PHP5 (which gives you some idea as to the last time that I coded in PHP).
  • Over winter break, I attempted to port modular X to MinGW, as the Xming project (which is awesome) uses the old, monolithic build process. I've built all the Xorg server (and its dependencies) successfully, except that the OpenGL code for Windows has not been updated with the rest of the server's codebase. That sort of modifications are pretty far out of my porting abilities, unfortunately. This project also gave me some experience with git. My take: it's extremely annoying to use git directly — use a frontend to it such as cogito instead. My personal preference is still Bazaar, though.
  • I wrote a Python module in C for my on-again, off-again, DC client project. I have a post on that sitting in my queue and will post it at some point when I finish and/or remember it.
  • I eagerly await the day when Deepest Sender supports the GData Blogger API. Maybe in the spring, if it's not there, I'll write it.
  • Oh right, the new URL for this weblog is http://blogger.malept.com/.