readium / r2-shared-js Goto Github PK
View Code? Open in Web Editor NEWShared models for Readium Desktop
License: BSD 3-Clause "New" or "Revised" License
Shared models for Readium Desktop
License: BSD 3-Clause "New" or "Revised" License
Via new JSON-LD contexts
Via properties defined by full URIs
Implementation: currently unknown metadata are lost. To make them available would let users of the SDK (i.e. apps, e.g. education) to get them easily without modifying the SDK.
Example: Calibre metadata -> https://readium.org/readium-css/docs/CSS21-epub_compat.html#metadata
An "otherMetadata" array will contain items with property name + value, extracted from the EPUB meta element.
Expressed as new roles.
If part of our extensions, they are in registries
If not they are full URIs.
An "otherCollections" array will contain items with a role + subCollection.
Extensibility for properties, should be similar to metadata
children and alternate should be part of the core model, not generic extension point
r2-shared-js/src/models/metadata.ts
Lines 453 to 459 in 1aa1a1c
r2-shared-js/src/_utils/zipHasEntry.ts
Line 20 in 66313d6
See description of the problem here:
readium/webpub-manifest#26 (comment)
Hi there! We have been employing the EPUB parser Type definition in our project and it's been a splendid experience so far! However, we've come across a scenario that piqued our curiosity and hoped to gain some insight into the underlying decisions.
In our use case, we've come across multiple instances where certain elements from the Encryption XML and OPF could potentially be optional. Our expectation was that the type check would indicate this to us, but it appears that these elements are always expected to have a value as per the parser's definition. For instance, it's our understanding that the title, language, and identifier are Required elements in publication metadata, while others could be optional, and similarly, the Keyinfo from the encryption format could be optional as well.
While we do perform our own type checks, there are times when we rely on the parser's type definition as a source of truth, which has led to some discrepancies. Any insights into this would be greatly appreciated. Thank you!
r2-shared-js/src/parser/audiobook.ts
Line 329 in 9371e14
I see that you can get the version from the OPF, but that requires passing in a zip. We are currently using r2-shared-js and already have the publicationParser working (it works great! So thanks for that!). But we would like to be able to tell if it's an EPUB 2 or EPUB 3 or higher, just from the publicationParser.
Here is an excerpt of what we are doing:
const pub = await publicationParser.PublicationParsePromise(path);
if (typeof pub.Metadata.Title === "string") {
bookTitle = pub.Metadata.Title;
coverUrl = pub.GetCover()?.Href || '';
manifest = serializable.TaJsonSerialize(pub);
const zipInternal = pub.findFromInternal("zip");
if (!zipInternal) {
throw new Error("There is no publication zip!");
}
It would be nice if we could check, for instance. pub.Version and be able to tell the EPUB version. Is there another way to do this?
Thanks!
Jonah
r2-shared-js/src/models/publication.ts
Line 44 in 44ebead
For example:
https://github.com/IDPF/epub3-samples/blob/master/30/wasteland/EPUB/wasteland.opf
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid" xml:lang="en-US" prefix="cc: http://creativecommons.org/ns#">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="uid">code.google.com.epub-samples.wasteland-basic</dc:identifier>
<dc:title>The Waste Land</dc:title>
<dc:creator>T.S. Eliot</dc:creator>
<dc:language>en-US</dc:language>
<dc:date>2011-09-01</dc:date>
<meta property="dcterms:modified">2012-01-18T12:47:00Z</meta>
<!-- rights expressions for the work as a whole -->
<dc:rights>This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.</dc:rights>
<link rel="cc:license" href="http://creativecommons.org/licenses/by-sa/3.0/"/>
<meta property="cc:attributionURL">http://code.google.com/p/epub-samples/</meta>
<!-- rights expression for the cover image -->
<link rel="cc:license" refines="#cover" href="http://creativecommons.org/licenses/by-sa/3.0/" />
<link rel="cc:attributionURL" refines="#cover" href="http://en.wikipedia.org/wiki/Simon_Fieldhouse" />
<!-- cover meta element included for 2.0 reading system compatibility: -->
<meta name="cover" content="cover"/>
</metadata>
<manifest>
<item id="t1" href="wasteland-content.xhtml" media-type="application/xhtml+xml" />
<item id="nav" href="wasteland-nav.xhtml" properties="nav" media-type="application/xhtml+xml" />
<item id="cover" href="wasteland-cover.jpg" media-type="image/jpeg" properties="cover-image" />
<item id="css" href="wasteland.css" media-type="text/css" />
<item id="css-night" href="wasteland-night.css" media-type="text/css" />
<!-- ncx included for 2.0 reading system compatibility: -->
<item id="ncx" href="wasteland.ncx" media-type="application/x-dtbncx+xml" />
</manifest>
<spine toc="ncx">
<itemref idref="t1" />
</spine>
</package>
EDIT: see comment below #16 (comment)
Note how <meta property="cc:attributionURL">http://code.google.com/p/epub-samples/</meta>
is missing in the ReadiumWebPubManifest:
http://readium2.herokuapp.com/pub/L2FwcC9taXNjL2VwdWJzL3dhc3RlbGFuZC1vdGYtb2JmLmVwdWI%3D/manifest.json/show/all
(or https://readium2.now.sh/pub/L2hvbWUvbm93dXNlci9zcmMvbWlzYy9lcHVicy93YXN0ZWxhbmQtb3RmLW9iZi5lcHVi/manifest.json/show/all )
{
"@context": "https://readium.org/webpub-manifest/context.jsonld",
"metadata": {
"@type": "http://schema.org/Book",
"title": "The Waste Land",
"identifier": "code.google.com.epub-samples.wasteland-otf-obfuscated",
"author": "T.S. Eliot",
"language": "en-US",
"modified": "2019-04-24T16:58:39.677Z",
"published": "2011-09-01T00:00:00.000Z",
"description": "OTF font obfuscated using algorithm defined in OCF 3.0, fallback to sans-serif system font",
"rights": "This work is shared with the public using the Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license."
}
}
See: readium/webpub-manifest#66 (comment)
This code should be disabled (this will trigger the AdditionalJSON
property and dc:source
will be preserved "as is"):
r2-shared-js/src/models/metadata.ts
Lines 447 to 451 in 1aa1a1c
r2-shared-js/src/models/metadata.ts
Lines 436 to 440 in 1aa1a1c
r2-shared-js/src/parser/epub.ts
Lines 485 to 487 in 1aa1a1c
This code remains:
r2-shared-js/src/parser/epub/opf-metadata.ts
Lines 74 to 76 in 1aa1a1c
r2-shared-js/src/models/metadata.ts
Line 117 in 44ebead
Same issue as readium/r2-streamer-js#44
My use case here is to batch process EPUB publication files from within the NPM package.json scripting mechanism.
Example:
{
"name": "rwpm-batch-convert",
"version": "1.0.0",
"description": "Convert publications to include Readium Web Publication Manifest files.",
"main": "index.js",
"scripts": {
"test": "r2-shared-js-cli [some input here]"
},
"author": "Juan Corona <[email protected]>",
"license": "MIT",
"dependencies": {
"r2-shared-js": "^1.0.13"
}
}
...also make sure that parsed values (e.g. from XML source) are filtered as per the allowed enumerated values. Avoid boilerplate code by automating the "enum" checks (which is not a native Javascript type, just a TypeScript constructs that transpiles to plain string definitions)
This commit introduced a postinstall
command. That command depends on rimraf
which is listed as a devDependency
. This causes an install failure when attempting to install this package without the devDependencies
which would be traditional in a production build.
r2-shared-js/src/models/publication-link.ts
Line 152 in 2141370
This issue is similar to spine
vs. readingOrder
.
In publication metadata, direction
should be renamed to readingProgression
:
r2-shared-js/src/models/metadata.ts
Line 108 in 70f65cb
JSON Schema:
https://github.com/readium/webpub-manifest/blob/d0b5694e662faf88262a3dc6a50ca32220fc825a/schema/metadata.schema.json#L120
( https://github.com/readium/webpub-manifest/blob/master/schema/metadata.schema.json#L120 )
Existing client implementations that parse the JSON property name directly (rather than using the in-memory data model) will need to update their code to support both the legacy direction
term, as well as readingProgression
(as we did when switching from spine
to readingOrder
).
See:
https://github.com/readium/architecture/blob/master/streamer/parser/metadata.md#identifier
r2-shared-js/src/parser/epub.ts
Lines 1144 to 1156 in a01efc9
r2-shared-js/src/parser/epub/opf-identifier.ts
Lines 28 to 29 in a01efc9
r2-shared-js/src/parser/epub/opf-metadata.ts
Lines 36 to 38 in a01efc9
r2-shared-js/src/parser/epub/opf-metafield.ts
Lines 31 to 38 in a01efc9
Related issue:
https://github.com/readium/r2-streamer-swift/issues/113
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.