Category Archives: Mozilla

The Mozilla Add-Ons Workshop in Florence

(Note: this post is also available in Italian on xulit.)

Picture a Mozilla geek standing on the shoulders of another to reach an electric outlet in the ceiling, then expecting to be returned to firm floor and instead being shuttled elsewhere to the reason of “one more outlet to gooooo!”.

(Photo credits: William. Complete photoset here.)

Picture the chatty signora who serves drinks and panini at the bar, getting asked tens of chairs first, then an old knife to be used as a screwdriver to assemble fans (no, not the human variety), then rags to clean above said chairs retrieved from the basement from above said geeks. Picture her respond with more lively chatter instead of increasing threats to kick us out.

Picture two guys who never gave a presentation together bantering/negotiating on stage, much to the audience’s amusement, which slides to skip to make time for an unplanned but ubercool presentation. (Of course I was right most of the time but Luca was tougher. :P)

You might think by now that the Mozilla Add-On Workshop had more than a bit of adventure in it, but our men in Florence Giacomo and Iacopo (from Mozilla Italia) as well as the headquarter agents Paul and William (from Mozilla Europe) plowed through every obstacle and got us safely to the heart of the workshop: an introductory talk on Firefox extension development, a hands-on tutorial, and a short finale on the tricks of the trade.

Despite many rough edges and a wealth of non-obvious material to cover (we went from zero to a Twitter-search extension to interactive development in less than three hours), almost fifty people gave us full attention and support, which is a testament to the rising interest on the subject in this country (or to the seldom sung quality of Italian patience (or both)).

Courseware is available: slides, incremental examples on building an extension, samples of “unusual” (if you’ve only done web development so far) JavaScript.

If you were there and your questions went unasked or unanswered because of time or because you couldn’t hang out afterwards; or you want us to keep you in the loop about this Fall’s initiatives; or you just want to say hi, feel free to get in touch with us or leave a comment here or on the Italian version of this post.

Happy extension hacking!

Gecko in Emacs (sort of)

After providing a Lisp-like facility for interactive development to Firefox, it was only fair for the cute panda to return the favor and lend some rendering power to Emacs.

Four lines of Lisp, a little hack and a function theft from w3m.el later, something pops up in an Emacs buffer…

It is, of course, just a proof of concept. No, I don’t have the time to develop it further. Yes, I’ll treat you to several rounds of Belgian beer if you do.

Turning Firefox into a screenshot server with MozRepl

In October I introduced custom interactors and someone asked what can be done with them other than application inspection.

Here‘s a practical application that turns Firefox into a screenshot server. It lets you request e.g. http://localhost:4242/screenshot/ and receive a PNG screenshot of Wikipedia homepage. (Instructions to run it are at the bottom.)

Features and things to note:

  • Every page is loaded in a new tab, meaning that multiple screenshots can be requested concurrently.
  • You can have MozRepl listen to outside requests and thus have the server run on a machine (or machines) other than the one requesting screenshots.
  • Adding .../pdf/, .../postscript/, .../getmail/, and so on, shouldn’t be too hard.

This is no finished product but it should give a hint of the possibilities. Known issues: since it takes the screenshot upon DOM load event, pages that use the same event to build sizeable portions of the document (such as iGoogle) might turn out incomplete or just white. Also, Firefox 3.1 seems to hang when the same browser instance is both the requester and the receiver of the screenshot (ok, not the most useful scenario, but still).

To try it:

  1. Get MozRepl, whether devel or stable branch doesn’t matter.
  2. Copy the source of the screenshot server to a file (e.g. /home/foo/mozrepl-init.js)
  3. In about:config, set extensions.mozrepl.initUrl to the URL of that file, e.g. file:///home/foo/mozrepl-init.js. (This file gets read whenever a new MozRepl session is started.)
  4. In about:config, also set extensions.mozrepl.defaultInteractor to “screenshot”.
  5. Select Tools → MozRepl → Start from the menu to start MozRepl.
  6. Point wget (or curl, or another browser) to Firefox with:
     $ wget http://localhost:4242/screenshot/ 

Update 2009-06-16: Adam has an HTML-to-PNG server with an improved version of the interactor.

Metabrowsing! (Or, custom interactors for MozRepl)

First guy: “So how would an object inspector look like in MozRepl?”

(Flashback: MozRepl is an interactive shell for Firefox and other Mozilla apps. You connect to Firefox with telnet or similar, type some JavaScript code, and it gets executed on the fly.)

I patiently explained how a command line inspector would look like. More or less like:

First guy: “Well, and how do you get this in MozRepl?”

I (im)pantietly explained that there was no inspector yet.

First guy: “Why not?”

I (im)patiently…

Second guy, out of nowhere: “Yeah, why not?”

You know that you’re in trouble when even the nicest guy in the place teams up to nag you.

Then I spent some time not to write an inspector, but to make it possible (and easy) for third parties to write new interaction modes for MozRepl, so that the onus of writing the damn inspector would be on the above guys. :) (The best thing you can do with challenges isn’t winning them, it’s turning them upside down.)

However things quickly got fancier while I explored, because the same request/response pattern interactive interpreters are built around is common to a lot of applications. Object inspectors, sure. Even text adventures (“You’re in a dimly-lit browser, surrounded by menacing angled brackets and curly braces”).

But also HTTP.

One custom interactor later, there it was: Firefox understanding HTTP and browsing itself. :)

Where to go from here? Once there’s a halfway decent implementation of HTTP (hint: mine isn’t), you may be able to drive Firefox with XML-RPC, JSON-RPC, REST-style manipulation of resources, and who knows what else. (Oh, yeah, I guess server-side long-timers in the audience will know what-else very well.)

Support is available in the new stand-alone MozRepl package. To try out the http-inspect mode, just go to about:config and set the “extensions.mozrepl.defaultInteractor” pref to “http-inspect”, then point the browser to http://localhost:4242. Documentation on how to write custom interactors is on the wiki.

Credits to Sergi for coming up with the “metabrowsing” title!

SamePlace, the contest, and Italy

This blog used to be mostly about SamePlace. If you’ve been reading it long enough to remember that, you’re probably one of the early adopters, so please virtually celebrate with me this little bit of news. :-)

SamePlace won a grand prize together with Shareaholic and Minimap (the announcement lists them in alphabetic order with a numeric bullet and they look like first/second/third prize—they’re actually co-winners, just like the twelve runners up.)

And it seems it’s been a productive time for Italy: my friend Davide is there too with Table2Clipboard. Not bad for this old little country. :-)