views:

884

answers:

4

I've been searching around and haven't found any reference to tools that can create Safari's webarchive format.

Does anyone have pointers to code for creating this format, or at least a format reference documentation?

Ideally I'd like to build a tool that takes a directory and splits out a webarchive, for loading into a iPhone.

+2  A: 

I believe the format for .webarchives is officially undocumented, but it's just a plist. You can open it in the Property List Editor and examine its contents. Shouldn't be to hard to replicate most, if not all, of what's in there.

Ben Gottlieb
+1  A: 

To expand on what Ben said: CFLite (the cross-platform open-source subset of Core Foundation) ships with a plist parser. If you can link against that, it should be quite simple to work with .webarchive files, which are simply property lists that concatenate all files (HTML, CSS, etc.) into one.

There are other libraries as well, such as Mac-PropertyList on CPAN for Perl.

Sören Kuklau
A: 

Webarchive creation is part of Webkit luckily, as such you can use the following for working with them on the Mac:

http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/WebKit/Classes/WebArchive_Class/Reference/Reference.html

Or, use this sourcecode to understand the format in usage:

http://trac.webkit.org/browser/trunk/WebKit/mac/WebView/WebArchive.mm

Alexander Kellett
A: 

It's not cross-plattform, but on the Mac

textutil -convert webarchive whatever.html

does the job. Not sure whether you can easily include images etc. though.

Ortwin Gentz