Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

Tried textutil, but that only uses the Cocoa text system and as such fails at css, js and such.

There's a nice GitHub project: https://github.com/takebayashi/STWebArchiver

It uses Webkit to write .webarchive files. Needs some customization for your needs…

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top