
Improved Installation Script
I wrote all day on an improved installation script for xpi packages, so I'll share the result with you.
If you want to offer Mozilla add-ons from your website in a user-friendly way, you may want to offer 2 options:
- A "smart" button, which automatically detects the user's platform and presents success/failure reports after the installation
- A direct download link, so users can save the file on disk for later installation or download with an advanced FTP client.
I took the script from the iPlanet PSM installation page, stole a few ideas from other sites (I hope, they don't object), improved that and added several functions of my own.
Basic features (startInstall):
- Separate generic script file for easy maintainance
- Nice results dialog or optionally HTML page
- Different levels of strictness for browser check (any Mozilla, same Mozilla release, exact "vendor" release)
- Graceful failure (offering browser download), if browser incompatible
- Helper functions for platform detection
Advanced features (genLaunch):
- Autodetection of platform and corresponding package
- Sniffing of package URIs from page
Usage of the "Advanced features" is optional. Use |genLaunch|, if you want to provide an additional, direct download link on the page and |startInstall| otherwise.
Using |startInstall(xpi, exclusive)|
This mode is similar to the scripts commonly used at the moment. You have to populate an array with the URIs and names of the to-be-installed packages, the format is the same as for InstallTrigger itself. The second parameter specifies the strictness of the browser check:
// for exclusive const anymozilla = 0; // any Mozilla const sameversion = 1; // this Mozilla release only, e.g. Mozilla 0.6/Netscape 6.0/Beonex Comm. 0.6 const samevendorrelease = 2; // this vendor release only, e.g. Beonex Comm. 0.6
You have to modify the script, if you want to detect another release (see todo below).
The functions isWindows(), isLinux() and isMac() may help you with determining the correct URIs, badPlatform() with handling platforms you don't support.
An example page is attached.
Using |genLaunch(idClass, exclusive)|
This is a very specialized function which does most of the above automatically.
It does this by looking at the page from which is has been invoked and searching for specifically marked URIs, with which it will populate the packages array.
The URIs for the XPIs have to be in a href of an tag.
The name attribute of the tag will be used for the package name
(shown in the installation confirmation dialog).
The class of the tag *has* to include one of the following strings:
"dlWin32", "dlLinux", "dlMac", "dlAll". If the package is for Win32
only, you have to use "dlWin32". If the package is platform-independant,
use "dlAll".
If there are different packages on the same page (e.g. PSM and
Spellchecker), you can also add an additional class for the package,
e.g. "psm". You can then specify the same string as |idClass| parameter
for |genLaunch|, and it will select only those packages that have this
class. If there is only one type of package at the page or you want to
install all packages at once, just pass an empty string as |idClass
parameter.
The second parameter for |genLaunch| is like that for |startInstall|.
Examples attached:
You can see them live at Note: The examples don't work for me locally - they don't draw in the external script. But they do work on www.beonex.com.
Todo:
If you make good enhancements to the script, please post them too, so we
can all take advantage of them.
Happy hacking
Ben Bucksch If you do not get a response to a question posted in this forum, please try sending a message to the project's mailing list or to the project owner directly. Updated the script to check for Software Installation being enabled in the browser. Get it at <http://smserver.home.local/beonex/com/communicator/version/0.6/add-ons/install.js>. And a bug in mozdev.org... *sigh*. Try this one: http://www.beonex.com/communicator/version/0.6/add-ons/install.js . great work! - dl / good idea! marius - Hi from Spain!! thanks for the link Ben you'r welcome!! This is a very nice site, pleasant layout and design. My compliments to your designer. Thanks you for the web, it is what I needed to complete my work.
good site hi from spain congratulations your site is very good mozdev.org is a great site ;-) great work! Yep, great work.
Congratulations for your site Hector gomis diseño web Very, very funny. I'd like to thank you on behalf of all of the people who expects Mozilla to keep being developed.
A great project. Thanks. Greetings Kalle Nice project! Very nice project. Gloryhole nice project /comex
Congrats for the work
Great Help
Hi, I like the contents of your site,
Hi, thanks a lot for this site...
great site! Just surfed in to look around.
Thanks Very interesting information.
Hello, I just wanted to say you have a very informative site which really made me think, Thanks ! I just surfed in and found your site, I really enjoyed the visit and hope to come back soon. nice Site! Thank you for the wonderful website and information I will be back soon. Greetings Congratulations for your site! This site is interesting as well as informative. Enjoyed browsing through the site. Keep up the good work. Greetings.. Nice Tool. Keep it alive. Greets Kalle Congratulations to your fantastic Site. Thanks Great Site! There was some interesting Informations on this Page! Really nice! Thank you! Great Site! There was some interesting Informations on this Page! Really nice! Thank you! http://www.freizeittip.de
A great project. Thanks. hosting uruguay
paso de los toros
www.visa-kreditkarte.de Your work is very interesting. Hello, a really interesting experience to visit your website. For sure i will come back soon. greets to all ! Very useful site Germany
(http://www.beonex.com/communicator/version/0.6/add-ons/security/jsj.html),
(http://www.beonex.com/communicator/version/0.6/add-ons/binaries/java) and
(http://www.beonex.com/communicator/version/0.6/add-ons/l10n).
Beonex
You do a very good work and you must feel proud of it.
http://members.lycos.nl/pierre141/tz_096/
/
/hechoamano
consultoria
artesanias
/host
diseño web hosting
-----
enjoying to surf within your site.
til then
Go on like this and enjoy !
Gratulation to this really nice site!
/
http://www.beauty-bedarf.de
http://www.lr-zielinski.de
http://www.gesundes-abnehmen.com
dominios uruguay
reseller hosting
santa isabel
ciudad de paso de los toros