Wiki on a Stick Interchange Format is the preferred format for exporting full WoaS data into a single file and share it with whoever you like.
WSIF format is similar to MIME email attachments format; each line comes like an email header
definition, as in following example:header.name: header-value
All WSIF content must be ASCII, so header-value
must be ECMA-escaped when necessary; this corresponds to escaping slashes "\" to "\\" and any UTF-8 sequence to the corresponding "\u0000" string, where 0000
is the lowercase hexadecimal value of the UTF-8 character (like in ECMAScript).
WSIF files can contain custom headers, given that the following namespaces are currently reserved for official WSIF format support:
For example you could define a new namespace for header definitions called custom
custom.content: Hello world!
It is up to you then to parse such header-value couples and give them proper representation.
A line starting with two dashes (--
) introduces an inline boundary
, which is a properly encoded snippet.
this is the inline snippet
must be a (usually random) string unique inside the boundary content
, but it does not need to be unique inside the whole WSIF file, which must be read sequentially (like in a state machine).
namespace currently defines only an information header:
- wsif.version - WSIF format version into which content is offered
- wsif.generator - program/library used to generate WSIF content
Version 1.1.0 and above are currently supported.
namespace defines general WoaS content properties and specific WoaS pages; the following headers are defined for general context:
- woas.version - version of WoaS used to produce the WSIF file
- woas.pages - total count of WoaS pages stored inside WSIF file
The following are header definitions specific for WoaS pages:
- woas.page.title - ECMA-escaped page title; this header has a special meaning because it is the page start marker inside the state machine; it is suggested that WSIF implementations write it as first header for page definition stanzas;
- woas.page.attributes - a positive integer value in decimal format specifying the page attributes;
- woas.page.last_modified - a positive integer value in decimal format representing seconds lasted from the UTC epoch up to last modified time; this header is defined only if data is available from WoaS;
- woas.page.length - content length of the inline snippet; only inline files define it; this is not the decoded page length but the length of the content inside the inline boundaries;
- woas.page.original_length - real page length as seen by WoaS; it is currently defined only for encrypted pages;
- woas.page.encoding - snippet encoding format, see the Encoding section below;
- woas.page.disposition - tells whether page is inline or external;
- woas.page.boundary - string used for inline boundary recognition (without leading dashes); this header is specified only for inline snippets;
- woas.page.disposition.filename - filename used for external page content, not ECMA-escaped; defined only with external pages;
- woas.page.mime - mime type of external pages which have a defined mime type, like images for example;
All headers are mandatory (under their specific state definition branch), except last_modified
header can contain one of the following values:
- 8bit/plain - data is ASCII text which can use 8bits to represent characters; only ASCII text should be used and not UTF-8;
- ecma/plain - data is ECMA-escaped UTF-8 text;
- 8bit/base64 - data is base64-encoded binary data;
- text/wsif - data is WSIF (currently used only for external WSIF pages)
Pages or header values are encoded in ecma/plain
format when UTF-8 sequences are found inside the value string, otherwise 8bit/plain
is used; 8bit/base64
is instead used for binary files or encrypted pages.
WSIF format is pretty straightforward to produce or interpret, however please consider the following facts:
- woas.page.disposition.filename must be plain ASCII (this limitation might be removed in future versions of the format) and should be a relative filename;
- it is safe to embed a WSIF file inside another, given that boundaries are properly implemented
WoaS project offers an official PHP library (libwsif) for reading/writing WSIF files, as well as a documented example.