Posts Tagged ‘documentation’

Add-on development just got easier

Tuesday, September 29th, 2009

We’re very excited to announce that we’ve just launched the Add-on Developer Hub (beta), the one-stop-shop for add-on developers to find out why they’d want to make an add-on, how to make an add-on, and manage their add-on listings.

Developer Hub Logo

Developer Hub

Back in May, we posted about our plans for a developer-focused website in response to feedback we received from add-on developers. The new Developer Hub has something for everyone — whether you’re just getting started or have already made twenty add-ons.

New documentation features of the Hub include:

  • Getting Started – an introduction to add-on development with links to important resources
  • How-to Library – tutorials, articles, videos, and walk-throughs on add-on development topics
  • API & Language Reference – official API and language references
  • Case Studies – stories of successful Firefox add-ons
  • Add-on Policies – all of our add-on policies in one up-to-date location
  • Search – search the best add-on development resources in one place: documentation, forums, newsgroups, reputable blog posts, and more

We’ve also introduced some new tools, with more planned for the coming months:

  • Add-on Builder – auto-generate add-on packaging by entering basic information and picking UI parts
  • Add-on Validator – add-ons can now be validated even if they’re not hosted on AMO

One of the most important goals of the new Hub is to bring the add-ons community closer together. With that in mind, the Hub features:

  • Add-ons Forum – interact with other add-on developers and get help
  • Newsletter – about:addons is our monthly newsletter
  • Developer News & Promos – relevant news and important information is now prominent throughout the Hub
  • Upcoming Events – find out when an add-on event is coming to your area

Developer Tools & News Feed

The tools developers use to submit and manage their add-ons on addons.mozilla.org are now part of the Developer Hub, and we’ve added a cool new way to stay up to date with what’s happening with your add-ons: the add-on news feed.

Any time something of note happens to an add-on, it is recorded in the news feed for the developer to see. This includes developer and editor actions like editing an add-on, submitting a new version, and approving a new version, but also includes user actions such as reviews and collections.

The news feed is available via RSS for one or all of your add-ons.

News feed screenshot

Search Revamp

As part of this release, we’ve also re-worked our AMO search engine from scratch to provide much more accurate results. This is a huge and much anticipated improvement, and will be covered in detail in a separate blog post.

A big thanks goes to everyone who made this release possible, from the developers, testers, and designers to those who helped review documentation and content.

Hello, add-on developers!

Sunday, May 10th, 2009

In our recent developer survey, one of the largest pain points identified by respondents was a lack of documentation and resources for extension developers. A contributing factor to this problem is that much of the available documentation and tutorials are spread across the Internet and that there’s no easy way to start developing an add-on from the add-ons website. Here’s our plan to change that.

developer.amo will be a site dedicated to add-on developers, rich with documentation, tutorials, and community involvement. With this site, we hope to:

  • Give new developers a starting point for creating an add-on
  • Give existing developers a place to stay up-to-date on add-on development news, plans, and features
  • Make development easier with documentation, tutorials, and examples all in one place
  • Build a community of add-on developers to promote an exchange of ideas

From this one site, it should be possible for someone brand new to Mozilla add-on development to:

  • find out why they would want to build a Firefox extension by reading case studies
  • see examples of how add-ons work
  • learn how to make a basic extension, and how to build that extension out into what they want
  • get support when they have questions
  • upload their add-on to AMO and have it accepted the first time (because policies will be readily accessible and easy to understand)

We’ve come up with an initial featureset we think will go a long way towards improving the developer experience, but would like input from the community before we get started. You can see our list of initial ideas on our wiki.

If you have thoughts on these features or other ideas, please let us know on the AMO newsgroup.

Edit: There seems to be some confusion about the relationship of this proposed site to MDC. As described in the wiki page above, there will be no new documentation hosted on this site. Rather, it will aggregate/link to existing documentation available on MDC and other resources. Any new documentation written as part of this site will still be hosted on MDC. developer.AMO will serve as a portal between AMO and add-on documentation, of which many articles are available on MDC.

Video Tutorial – Extensions Bootcamp: Zero to “Hello World” in 45 Minutes

Wednesday, March 18th, 2009

Mozilla’s Myk Melez created a great video introduction to add-on development for Mozilla’s Design Challenge Spring 09. If you’ve be looking for a video walk-through, Myk just served it up for you.

Grok extensions, set up your development environment, and make your first one. We’ll explain how extensions integrate into Firefox and what they can do, show you how to set up an environment to ease their development, and walk you through the making of a simple “Hello World!” extension. Bring your laptop and prepare to follow along. By the end of this session, you’ll be an extension developer.


Extension Bootcamp (Mozilla Labs Design Challenge: Spring 09) from Mozilla Labs – Concept Series on Vimeo.

Now combine the video with Robert Nyman’s step-by-step add-on tutorial and the newly released Firefox Add-ons Developer Guide and you’ll be well on your way to honing your add-on development skills.

Firefox Add-ons Developer Guide (beta release) – Calling all Add-on Developers!

Wednesday, March 11th, 2009

Summary: The Firefox Add-ons Developer Guide is  now released in beta.  We are now  searching  for  contributors,  if  you want  to  help,  please  see instructions below.

Firefox Add-ons Developer Guide – beta release

It’s with  great excitement that we  announce today the beta  release of the Firefox Add-ons Developer Guide. This  guide, is based on an earlier tutorial written and printed for  an Add-ons conference organized by our colleagues in Japan back in June 2007,  and has now been updated for the Firefox  3.5  release.  The  document  will  guide  and  assist  add-ons aficionados around the world, eager to develop their own Firefox add-on. Its catered  to all types  of user,  from the experienced  developer who needs a little push in the right  direction, to the new beginner keen to get his hands dirty, but not sure where to begin.

The content of the guide

The guide is divided into 6 chapters and one appendix:

Top page

  1. Introduction to extensions
  2. Technologies used in developing extensions
  3. Introduction to XUL: How to build a more intuitive UI
  4. Using XPCOM: Implementing advanced processes
  5. Let’s build a Firefox extension
  6. Firefox extensions and XUL applications
  7. Appendix: What you should know about open-source software licenses

State of the document

As  described, this  is a  beta  version of  the document.  The text  of the  guide has  been  thoroughly revised,  and is  now  open to  further contributions, corrections  and modifications. Paul Rouget  of Mozilla’s evangelism  team  is coordinating  the  project  and will  be  regularly reviewing  and integrating  contributions from  the community.  Feedback will be incorporated, ready for final release a few weeks before Firefox 3.5.

How to contribute

If you  would like to  help, first, please  read through the  task list. The guide is hosted on MDC, which is a wiki, so feel free to add content and fix mistakes. If you would  like to provide comments and suggestion, or if you want to ask questions, please do so through the MDC forum.

If you would like to propose a deep modification, please, first, discuss it via the forum.

Thanks

Thanks a lot to the original authors:

  • Hideyuki Emura
  • Hiroshi “Piro” Shimoda
  • Taiga Gomibuchi
  • Taro Matsuzawa
  • Yutaka Kachi

… and Erwan Loisant, Andrew Williamson and Brian King for their useful reviews.

The license of the guide is Attribution-Share Alike 2.1 Japan.

Calling all Add-on Developers!

Mozilla Add-ons developers out there, if  you would like to help improve

this guide  and make it become  “the” reference for those  interested in developing a Firefox  add-on, take a peek  at the guide, drop  us a line and tell us  what you would change, add, delete  or improve. The Firefox Add-on Developer Guide will always be a work in progress, so please help

improve it today !

How to develop a Firefox extension

Wednesday, January 28th, 2009

Reposted with permission from Robert Nyman:

Admit that you have always wanted to know how to develop a Firefox extension but never had the time to learn. :-) Here I will walk you through and at the end of the article we will have created a fully functional Firefox extension!

Our objective

We will create a Firefox extension to find all links in the current web page, highlight those which have a target attribute and alert you how many links it found. The good part is that once you have done this, you have both an understanding of Firefox extension development as well as a blueprint for any extension you would want to develop in the future.

(more…)

Firefox Extensions: Global Namespace Pollution

Friday, January 16th, 2009

Reposted with permission from Jan Odvarko (AKA Honza):

I have been recently asked by couple of developers how to properly design architecture of a Firefox extension. The first thing that immediately came to my mind at that point was a problem with global variables defined by extensions in ChromeWindow scope.

This problem can easily cause collisions among various extensions. Something that should be always avoided (and is also part of AMO review process) since this kind of issues is very hard to find. Yes, global variables are still evil, especially in OOP world.

I don’t want to describe how to develop a new extension from scratch. For this there is already bunch of detailed articles. I am rather concentrating on effective tactics how to make Firefox extension architecture maintainable and well designed.

So, read more if you are interested…

Namespace Architecture

Defining global variables is a way how to risk collisions with other extensions. I think that creating just one global variable per extension that is unique enough (composed e.g. from the name of the extension, domain URL, etc.) is sufficient strategy how to avoid undesirable collisions.

The architecture for namespaces used in Firebug, is based (more or less) on well known module pattern (originally described by Douglas Crockford). It’s really simple and transparent so, I hadn’t understand how it actually works for a long time. I believe other extension developers can utilize this approach as well.

The basic idea is to wrap content of every JS file into its own scope that is represented by a function so, there are no global objects. See following snippet.

function() {

// TODO: entire JS code in this file is here
}

This is what I am going to call a namespace.

The first question is how to ensure that the function is actually called and the code executed at the right time. The second question is how to share objects among more files (see Sharing among namespaces chapter below). Firebug solves this by registering every namespace and executing all when Firefox chrome UI is ready. See modified example.

myExtension.ns(function() {

// TODO: entire JS code in this file is here
});

The namespace (regular function) is passed as a parameter to myExtension.ns function. The myExtension object is the only global object that is defined by the extension. This is the singleton object that represents entire extension. Don’t worry if the name is long, there’ll be a shortcut for it (in real application it could be e.g. comSoftwareIsHardMyExtension).

The ns function is simple. Every function is pushed into an array.

var namespaces = [];

this.ns = function(fn) {
    var ns = {};

    namespaces.push(fn, ns);
    return ns;
};

Actual execution of registered namespaces (functions) is only matter of calling apply on them.

this.initialize = function() {
    for (var i=0; i<namespaces.length; i+=2) {

        var fn = namespaces[i];
        var ns = namespaces[i+1];

        fn.apply(ns);
    }
};

Now, let’s put all together and see how the global extension (singleton) object is defined and initialized.

The following source code snippet represents a browserOverlay.js file that is included into an overlay (browserOverlay.xul)

// The only global object for this extension.
var myExtension = {};

(function() {
// Registration
var namespaces = [];

this.ns = function(fn) {
    var ns = {};
    namespaces.push(fn, ns);

    return ns;
};
// Initialization
this.initialize = function() {

    for (var i=0; i<namespaces.length; i+=2) {
        var fn = namespaces[i];

        var ns = namespaces[i+1];
        fn.apply(ns);

    }

};
// Clean up
this.shutdown = function() {
    window.removeEventListener("load", myExtension.initialize, false);

    window.removeEventListener("unload", myExtension.shutdown, false);
};
// Register handlers to maintain extension life cycle.
window.addEventListener("load", myExtension.initialize, false);

window.addEventListener("unload", myExtension.shutdown, false);
}).apply(myExtension);

As I mentioned above, there is just one global object myExtension.

To summarize, the object implements following methods:

  • ns – register a new namespace.
  • initialize – initialize all namespaces.
  • shutdown – clean up.

And also, the code makes sure that initialize and shutdown methods are called at the right time. This is why event handlers are registered.

The browserOverlay.xul looks as follows now.

<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <script src="chrome://namespace/content/browserOverlay.js" type="application/x-javascript"/>
    <script src="chrome://namespace/content/Module1.js" type="application/x-javascript"/>

    <script src="chrome://namespace/content/Module2.js" type="application/x-javascript"/>
</overlay>

And the Module1.js and Module2.js files are both the same.

myExtension.ns(function() {
// TODO: entire JS code in this file is here
});

Sharing among namespaces

Now, when we have our script within a local scope(s), let’s answer the question how to share functionality and data among individual namespaces. The general idea is to use the one global object we have – myExtension.

First of all, see the following source code (lib.js file).

myExtension.LIB = {

    // Shared APIs
    getCurrentURI: function() {
        return window.location.href;

    },

    // Extension singleton shortcut
    theApp: myExtension,

    // XPCOM shortcuts
    Cc: Components.classes,

    Ci: Components.interfaces,

    // Etc.
};

You can see that a new LIB property is created within our global myExtension singleton. This objects represents a library of functions that should be shared among all modules in our extension. At this point, you can also get inspiration from Java Packaging and create whole tree of namespaces within the global singleton (just like e.g. YUI does)

The lib.js file is included in browserOvelay.xul (just after browserOverlay.js)

<?xml version="1.0"?>

<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <script src="chrome://myextension/content/browserOverlay.js" type="application/x-javascript"/>

    <script src="chrome://myextension/content/lib.js" type="application/x-javascript"/>
    <script src="chrome://myextension/content/Module1.js" type="application/x-javascript"/>

    <script src="chrome://myextension/content/Module2.js" type="application/x-javascript"/>
</overlay>

Let’s also improve our module script a bit.

myExtension.ns(function() { with (myExtension.LIB) {
// TODO: entire JS code in this file is here

var moduleVariable = "Accessible only from withing this module";

dump("myExtension.Module initialization " + getCurrentURI() + "\n");

}});

By utilizing with statement we can simply access all library functions as if they would be a global functions.

In case we want to access our singleton global object we can also utilize theApp shortcut (useful especially if the name is long) as follows:

myExtension.ns(function() { with (myExtension.LIB) {
// TODO: entire JS code in this file is here

theApp.sharedValue = "A new shared property";

}});

Here is how the architecture look like from UML perspective.

Namespaces within a Firefox extension.

Download example extension here.