Ben, i can add this to jslib if you want.

--pete


Ben Bucksch wrote:
> 
> 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 <a> tag.
> 
> The name attribute of the <a> tag will be used for the package name
> (shown in the installation confirmation dialog).
> 
> The class of the <a> 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:
> - Simple
> - Installing 2 different packages at once
> - Platform-Independant
> You can see them live at
> <
> 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>.
> 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:
> - The restart detection doesn't seem to work at all. As a workaround,
> I
> am currently *always* suggesting a restart after a successful
> installation, see the "XXX" in the code. YMMV.
> - Make browser check more customizable / flexible
> 
> If you make good enhancements to the script, please post them too, so
> we
> can all take advantage of them.
> 
> Happy hacking
> 
> Ben Bucksch
> Beonex
> 
>     ---------------------------------------------------------------
>                  Name: install.js
>    install.js    Type: JavaScript Program (application/x-javascript)
>              Encoding: 7bit
> 
> 
> 
> 
> 
> Alternative download: Win32 (30K), Linux (40K)
> 
> 
> 
> 
> 
> Alternative download: Java Win32 (7.5M), Java Linux (15M), Security
> fix Win32 (30K), Security fix Linux (40K)
> 
> 
> 
> Alternative download: German (220K)

Reply via email to