GithubHelp home page GithubHelp logo

readium / r2-shared-js Goto Github PK

View Code? Open in Web Editor NEW
11.0 12.0 11.0 24.6 MB

Shared models for Readium Desktop

License: BSD 3-Clause "New" or "Revised" License

TypeScript 96.59% JavaScript 3.41%
readium

r2-shared-js's People

Contributors

danielweck avatar monasharma1991 avatar punchouty avatar roberthodan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r2-shared-js's Issues

extensibility

Metadata

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.

Collections

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.

Links

Extensibility for properties, should be similar to metadata
children and alternate should be part of the core model, not generic extension point

subject metadata was fixed in JSON Schema, comment can be removed

// TODO: not in JSON Schema?? https://github.com/readium/webpub-manifest/issues/13
// tslint:disable-next-line:max-line-length
// https://github.com/readium/webpub-manifest/blob/0976680e25852b8a4c4802a052ba750ab3e89284/schema/metadata.schema.json
@JsonProperty(SUBJECT_JSON_PROP)
@JsonConverter(JsonSubjectConverter)
@JsonElementType(Subject)
public Subject!: Subject[];

A quick question regarding the Type definition in the parser untilties.

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!

metadata check: extended list of contributors

@JsonProperty("author")
@JsonElementType(Contributor)
public Author!: Contributor[];
@JsonProperty("translator")
@JsonElementType(Contributor)
public Translator!: Contributor[];
@JsonProperty("editor")
@JsonElementType(Contributor)
public Editor!: Contributor[];
@JsonProperty("artist")
@JsonElementType(Contributor)
public Artist!: Contributor[];
@JsonProperty("illustrator")
@JsonElementType(Contributor)
public Illustrator!: Contributor[];
@JsonProperty("letterer")
@JsonElementType(Contributor)
public Letterer!: Contributor[];
@JsonProperty("penciler")
@JsonElementType(Contributor)
public Penciler!: Contributor[];
@JsonProperty("colorist")
@JsonElementType(Contributor)
public Colorist!: Contributor[];
@JsonProperty("inker")
@JsonElementType(Contributor)
public Inker!: Contributor[];
@JsonProperty("narrator")
@JsonElementType(Contributor)
public Narrator!: Contributor[];
@JsonProperty("contributor")
@JsonElementType(Contributor)
public Contributor!: Contributor[];
@JsonProperty("publisher")
@JsonElementType(Contributor)
public Publisher!: Contributor[];
@JsonProperty("imprint")
@JsonElementType(Contributor)
public Imprint!: Contributor[];

CHECK:

https://github.com/readium/webpub-manifest/blob/ffb350ca09c85d5f15cb4ae0453bd0b3dcb15440/schema/metadata.schema.json#L81-L119

How can I tell the version using the publicationParser (e.g. EPUB 2 vs. EPUB 3)?

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

OPF package metadata link element + prefix (support is missing)

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."
    }
}

dc:source and dc:rights not in RWPM JSON Schema / JSON-LD context, not in EPUB parsing rules

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"):

// TODO: not in JSON Schema?? https://github.com/readium/webpub-manifest/issues/14
// tslint:disable-next-line:max-line-length
// https://github.com/readium/webpub-manifest/blob/0976680e25852b8a4c4802a052ba750ab3e89284/schema/metadata.schema.json
@JsonProperty("source")
public Source!: string;

// TODO: not in JSON Schema??
// tslint:disable-next-line:max-line-length
// https://github.com/readium/webpub-manifest/blob/0976680e25852b8a4c4802a052ba750ab3e89284/schema/metadata.schema.json
@JsonProperty("rights")
public Rights!: string;

if (opf.Metadata.Source && opf.Metadata.Source.length) {
publication.Metadata.Source = opf.Metadata.Source[0];
}

This code remains:

@XmlXPathSelector("dc:source/text()")
@XmlItemType(String)
public Source!: string[];

Can't run as binary

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"
  }
}

direction vs. readingProgression

CC @jccr @HadrienGardeur

This issue is similar to spine vs. readingOrder.

In publication metadata, direction should be renamed to readingProgression:

@JsonProperty("direction")

( https://github.com/readium/r2-shared-js/blob/develop/src/models/metadata.ts#L108 )

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).

EPUB parse dc:identifier as URI, infer from opf:scheme or the refine pattern

See:
https://github.com/readium/architecture/blob/master/streamer/parser/metadata.md#identifier

const addIdentifier = (publication: Publication, _rootfile: Rootfile, opf: OPF) => {
if (opf.Metadata && opf.Metadata.Identifier) {
if (opf.UniqueIdentifier && opf.Metadata.Identifier.length > 1) {
opf.Metadata.Identifier.forEach((iden) => {
if (iden.ID === opf.UniqueIdentifier) {
publication.Metadata.Identifier = iden.Data;
}
});
} else if (opf.Metadata.Identifier.length > 0) {
publication.Metadata.Identifier = opf.Metadata.Identifier[0].Data;
}
}
};

@XmlXPathSelector("@scheme")
public Scheme!: string;

@XmlXPathSelector("dc:identifier")
@XmlItemType(Identifier)
public Identifier!: Identifier[];

@XmlXPathSelector("@refines")
public Refine!: string;
@XmlXPathSelector("@scheme")
public Scheme!: string;
@XmlXPathSelector("@property")
public Property!: string;

Related issue:
https://github.com/readium/r2-streamer-swift/issues/113

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.