创建Safari Webarchives的跨平台方式

时间:2022-10-31 12:09:48

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

我一直在寻找并且没有找到任何可以创建Safari的webarchive格式的工具的参考。

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.

理想情况下,我想构建一个工具来获取目录并拆分webarchive,以便加载到iPhone中。

5 个解决方案

#1


5  

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.

为了扩展Ben所说的内容:CFLite(Core Foundation的跨平台开源子集)附带了一个plist解析器。如果您可以链接它,那么使用.webarchive文件应该非常简单,它们只是将所有文件(HTML,CSS等)连接成一个的属性列表。

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

还有其他库,例如CPAN for Perl上的Mac-PropertyList。

#2


4  

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.

我相信.webarchives的格式是官方没有文档的,但它只是一个plist。您可以在属性列表编辑器中打开它并检查其内容。不应该很难复制大部分内容,如果不是全部内容的话。

#3


3  

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

试过textutil,但只使用Cocoa文本系统,因此在css,js等处失败。

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

有一个很好的GitHub项目:https://github.com/takebayashi/STWebArchiver

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

它使用Webkit编写.webarchive文件。需要一些定制来满足您的需求......

#4


1  

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

Webarchive创建是Webkit的一部分幸运,因此您可以使用以下方法在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

#5


1  

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

它不是跨平台,而是在Mac上

textutil -convert webarchive whatever.html

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

做的工作。不知道你是否可以轻松地包含图像等。

#1


5  

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.

为了扩展Ben所说的内容:CFLite(Core Foundation的跨平台开源子集)附带了一个plist解析器。如果您可以链接它,那么使用.webarchive文件应该非常简单,它们只是将所有文件(HTML,CSS等)连接成一个的属性列表。

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

还有其他库,例如CPAN for Perl上的Mac-PropertyList。

#2


4  

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.

我相信.webarchives的格式是官方没有文档的,但它只是一个plist。您可以在属性列表编辑器中打开它并检查其内容。不应该很难复制大部分内容,如果不是全部内容的话。

#3


3  

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

试过textutil,但只使用Cocoa文本系统,因此在css,js等处失败。

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

有一个很好的GitHub项目:https://github.com/takebayashi/STWebArchiver

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

它使用Webkit编写.webarchive文件。需要一些定制来满足您的需求......

#4


1  

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

Webarchive创建是Webkit的一部分幸运,因此您可以使用以下方法在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

#5


1  

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

它不是跨平台,而是在Mac上

textutil -convert webarchive whatever.html

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

做的工作。不知道你是否可以轻松地包含图像等。