Readium Streamer aims at simplifying the usage of numeric publication by parsing and serving them. It takes the publication as input, and generates an accessible WebPubManifest/object as output.
Changes and releases are documented in the Changelog
Note: requires Swift 4.2 (and Xcode 10.1).
Carthage is a simple, decentralized dependency manager for Cocoa. To install R2Streamer with Carthage:
-
Make sure Carthage is installed.
-
Update your Cartfile to include the following:
github "readium/r2-streamer-swift" "develop"
-
Run:
mkdir -p Carthage/Build/iOS
carthage update --use-xcframeworks
In your Swift files :
// Swift source file
import R2Streamer
let parser = EpubParser()
let parser = CbzParser()
...
var parseResult: PubBox
do {
parseResult = try parser.parse(fileAtPath: path)
} catch {
// `{Type}ParserError` exception handling
}
/// Get `Publication` from the `parseResult`
let publication = parseResult.publication
/// Access `Publication` content
let metadata = publication.metadata
let tableOfContent = publication.tableOfContent
let spineItems = publication.spine
//...
You can now access your publications content programmatically. The Publication
object is described in details here.
R2Streamer provides a local HTTP server called PublicationSever
, this allow access to the resources of the Publication
.
/// Instantiation of the HTTP server
guard let publicationServer = PublicationServer() else {
// Error
}
You can add your parsed publication to the server at the desired endpoints. (The endpoint parameter is optional, an UUID
will be generated if let empty as below)
/// Adding a publication to the server (Using the above section variables)
do {
try publicationServer.add(publication, with: container/* ,"customEndpoint" */)
} catch {
// `PublicationServerError` exception handling
}
When a Publication is added to the server, a new 'self' Link
is added to the Publication
's links
property.
The Publication
now know how to locate its resources over HTTP. See below for an example.
The Publication
is described using Link
s. Each link describe a resource from the publication in a Publication-relative way.
/// Accessing any `Link` resource over HTTP
let cover = publication.coverLink // Or `spineItems[x]`...
let coverUri = publication.uri(forLink: cover)
print(coverUri) // "http://{serverip}:{serverport}/{endpoint}/{`cover.href`}"
Using the Publication
itself:
publicationServer.remove(publication)
Or it's endpoint:
publicationServer.remove(at: "endpoint")
For further informations see readium/webpub-manifest.
publication.manifest()
publication.manifestCanonical()
Supported formats:
EPUB 2/3/3.1- OEBPS - CBZ
- R2Shared : Contains the definitions of shared custom types used across the readium-2 Swift projects.
- GCDWebServer A modern and lightweight GCD based HTTP 1.1 server designed to be embedded in OS X & iOS apps.
- CryptoSwift Crypto related functions and helpers for Swift implemented in Swift.
- Fuzi A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
- Minizip Minizip framework wrapper for iOS, OSX, tvOS, and watchOS.
Jazzy is used to generate the project documentation. There are two script for building either the Public API documentation of the full documentation.
./generate_doc_public.sh
./generate_doc_full.sh
The project documentation is available here