GSoC: week 1

This year I was accepted into Google Summer of Code program, namely I will be integrating Transifex software localization platform with Mozilla addons. The complete proposal is available at GSoC site.

I had talks with Zbigniew, who will be my mentor for this project and Dimitris, leader of Transifex project. I am looking forward for working with both of them more deeply, but so far I am just diving into Transifex sources and rounding up my studies. The first and obvious thing to do it solving Transifex’s ticket #89, as other things go after that.

On a side note, I am amazed by how noisy GSoC mailing list is. Thank you, dear Google, for the Mute button! Update: Finally got my City card, tried to register it online, and lots of so-called “noise” on the list instantly started making sence. The main URL does not even open for non-US IPs, for starters.

Scheduled my next meeting with Zbigniew to June 7th, and we will probably have at least bi-weekly talks through the summer.

Posted in gsoc, mozilla | Comments Off on GSoC: week 1


Never, ever I will write plain old CSS, nesting rules over and over and renaming all the stack when the root element has to be changed.

Imagine this monstrosity

.featured_retailers {
    border: 2px solid #FFC77B;
    width: 626px;
    position: relative;
    .featured_retailers table { width: 626px; }
        .featured_retailers td {
            padding: 0;        
            border-top: 2px solid #FFC77B;
        .featured_retailers td table {
            width: 440px;
            .featured_retailers td table td {
                border: 0;
                padding: 1px 5px;
    .featured_retailers p {
        color: #333;
        position: absolute;
        top: -30px;
        right: 0;
        .featured_retailers p img {

turning into

    border: 2px solid $bgcolor
    width: 626px
    position: relative
    table: width: 626px 
            padding: 0        
            border-top: 2px solid $bgcolor
                width: 440px
                    border: 0
                    padding: 1px 5px
        color: #333
        position: absolute
        top: -30px
        right: 0

That magic is done by cleverCSS. It is written by maniacs (they added variable and expression support but went a bit too far: who would ever want to calculate sqrt of length?) but it gets the job done.

Original authors seem to have abandoned it, but it is supported by community. I added my two cents too:

  • its calculation feature was not aware of negative numbers, trying to calculate the sum , so margin: -2px -2px was transformed into margin:-4px
  • its support for /* multiline comments */ was not working, unless they were on the same line

And for integration of CleverCSS into your Django site there is django-css project. It is a CSS and JS compressor, but the compression is not what you would be after. The point is that django-css compiles CSS with external compilers, and caches the output in a clever way.

There were few things that could be improved there:

  1. It was relying on binary commands, while using Pythonic compiler in Python would be more logical.
  2. It was leaving compiled files not only in cache, but in my source tree, near the originals.

Also, I often use inline STYLE blocks for specific templates. Why have the hassle of separating them into files? The only reason can be that if page-specific CSS is large, the browser constantly redownloads it, and it is not nice.

So I added that feature to django-css too, and now it is almost perfect tool for complex Django CSSing. You can have extended CSS files compiled and cached, no matter where it is, in LINKS or in STYLE blocks.

All you have to do is surround your STYLE or LINK with {% compress css %} tag.

{% compress css %}
<style type="ccss">
{% compress css %}

Forked Repos:

PS: Github is a very nice collaborative tool, it is fun to work with. I just like BitBucket more 🙂

Posted in django | Tagged , | 3 Comments

Rebuilding the friendship between Firefox and eBooks

sony-reader-prs505 This is a story about the passion. One that changes life, and one that is obviously is going to change the world. It already does.

I loved books since I was a child. They allow you to travel to the places distant in time and space, to see the worlds that disappeared long ago or did not even exist. They tell stories that fascinate people all over the world and shape our common knowledge like Bible did thousands years ago. And of all modern ways to fill your mind with a fascinating reading the most prominent one is e-books.

History note

There was a time when monks used to rewrite them by hand, and by the mistakes they made in the process we can now get hints on what language did they actually speak besides canonical one. Later, mr. Gutenberg created his famous invention, pretty much killing that little monastery business.

I wonder if there were lawsuits then.

Six centuries later, hand rewriting and retyping made an interesting comeback, when in our country the ability to print was blocked not by technical shortcomings, but by political circumstances. It is known as Samizdat books, funny name coined by resemblance of official publishing houses names, but meaning “My own Publishing House”.

Authors and Publishers

Interestingly, but we are approaching the same destination just having taken other route. These days anyone can be his own publishing house and easly print his own book, or reprint someone else’s.

Of course, that gives traditional publishing houses a hard run for their money and may even eventually kill them. Who cares? In the brave new world we will have the ability to buy books directly from the Author, saving the cost on printing and saving the space on our bookshelves. Everybody wins, and, btw, publishers will have their niche anyway: print-on-demand, illustrated books, atlases, etc.

But the books that are “just text” will soon be arranged only inbetween the Author and the Reader. May be with a little help of some web-service, but soon to sell a book will be as easy as to sell a photo, font, drawing or some other work of art.

And even more. There are several books that I and many other people want written, and I see no reason why the community can not prepay their writing. We prepay opensource software, right? There were lots of cases, when people collected needed sum to pay the developer, funding his work for a promise to release the result into the world. This model will surely work for book developers too.

The modern reading

Ok, now you surely know how wonderful e-books are and how bright our future will be, 🙂 . Time for some gory details.

Whatever you use to read your library (I very very much recommend some eInk based device, your eyes will thank you a thousand times), standards matter.

And looks like the standard for e-books is finally settled, it is called ePub, and is based on open technologies. With Google promizing to release a million ePub books into the wild, and Sony commiting to that format there is no question on who the winner is.

I feel a little sad for other open XML-based e-book format, called FictionBook, because it was much stricter on ruling out the presentation details, caring only about the structure of the book, and leaving the style to the reader.

But, as it was for early HTML, presentational details won. Not as bad as it was for HTML3, through. ePub just lets creator to specify the look in CSS, and does not require the book text to have special DTD, allowing plain XTHML. Still there is special DTD, called DTBook, it is just not required for book chapters, only for TOC.

Not to mention that Fb2 format was our local, Eastern Europe only invention, and was not backed by any big worldwide player.

But hey, ePub is standartized and open: so when one would want to read it the way he wants, it is all up to the extending the reading application. Just like the approach we take to the Open Web.

The task

And here comes the task I chose myself for Mozilla technology course: to add ePub and Fb2 support as an extension to Firefox. That would make interaction with ePub books easier and provide readers with more viewing options.

The problems I have to solve to make the extension work like it should are:

  1. registering the extensions .epub and .fb2, handling their rendering
  2. unzipping the content (both are container formats)
  3. actual presentation
  4. TOC navigation
  5. book metainformation display
  6. some library features

The good news for me that there was an ePub extension once, that did handle points 1-3, called Openberg Lector. Unfortunately, it died two years ago, having never made it to Firefox 3.

Still, it provided me with lots of hints, and reviving it in some form is one of the goals of this project. I am sure it will be useful as people are still eagerly waiting for an update on its AMO page.

And for FB2 format (which is not going away soon in near future in our part of the world) there has not been an extension yet, despite it was asked for on forums several times.

Update Dec 2010:

FB2 reader app is done, available on its own page.

EPUB reader is done by other guys, see Lucifox.

Posted in mozilla | 2 Comments

Link widgets Greasemonkey script

There is such a great, but unfortunately underused accessibility feature, called navigational links.

They go into the HEAD of the page, and tell people that this page is part of the sequence, giving clues what previous, next, first, last, upper in hierarchy page is. Very helpful. Always present on documentation pages, like

Opera provides navigational buttons using those links, Seamonkey too. For Firefox to use it, one have to install Link Widgets addon

It understands the LINK elements, and tries to guess page sequences on URLs, but that does not always help, and this is where The Script comes in. It reads html A’s on a page, and then inserts Links to the head.

So. Walkthrough:

  1. Install Greasemonkey
  2. Install Link Widgets.
  3. Disable link guessing in its preferences.
  4. Install the script
  5. Go to the some comic, and enjoy unified always-present site navigation 🙂

Supported: Sinfest , Dilbert, XKCD, The Noob and couple of others.

Future plans: More sites, some way of site-schemes updating, integration with Link Widgets addon?

Posted in mozilla | Tagged , | Comments Off on Link widgets Greasemonkey script