[OLPC library] Viewing compressed content using jar: protocol in Browse !

S Page skierpage at gmail.com
Tue Jun 30 04:25:19 EDT 2009


(There's probably a better mailing list for this on the sugarlabs side...)

I was reading a Mozilla bug #312156 that casually used a jar: URL to
refer to a file in a ZIP archive.  Firefox implements the jar:
"wrapper" protocol,
http://docs.sun.com/source/819-0913/author/jar.html#jarprotocol , that
lets you access any file within a .zip file.
  jar:<URL of zip>!</path/in/zip

This means you don't have to unpack a .xol (library content as in a
"collection") file to view its contents in Browse!  I copied the NET
Bible collection's Bible-en.xol to my OLPC 8.2.1 home directory
(without installing it), and URLs like
   jar:file:///home/olpc/Bible-en.xol!/bible-en/files/lev5.html
work fine.  If you go into about:config for Browse or Firefox and
change network.jar.open-unsafe-types to true, you can even view files
in a .xol (or .xo, or .zip) across the web. so that
  jar:http://wiki.laptop.org/images/d/df/Bible-en.xol!/bible-en/files/index.htm
works and relative hyperlinks seem to work.  So you can read a
compressed collection without ever unpacking it, or even downloading
it!  (If you want to serve content across the web using this trick,
<http://hype-free.blogspot.com/2009/01/using-single-file-to-serve-up-multiple.html>
indicates that you can change the mime type for to avoid having to
tweak the browser settings.)

I think this is significant for HTML content, especially on non-JFFS
partitions that don't use a compressed file system.  Sure, ship a .xol
or .zip, but if it's just got HTML content in it (and face it, any
other form for content suffers by comparison), don't bother unpacking
it.  Just open the start page within the ZIP file using this jar:
protocol.  This could work for the Help activity, and it allows people
to ship huge collections such as wiki slices without taking a lot of
disk (though the http://wiki.laptop.org/go/WikiBrowse local server for
compressed data still has some unique features).  It also lets you
look inside .xo and other .zip files in the browser --
jar:file:///home/olpc/SomeArchive.xo!/ shows a "directory listing" of
the ZIP file's contents.

Never bet against the browser,
--
=S Page

P.S.  If you tried the remote jar: hack, don't forget to go into
about:config and reset network.jar.open-unsafe-types to its "false"
default, or/and be careful what you click.


More information about the Library mailing list