Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed library book detail in Internet Explorer (XPath lib), see #70 #285

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build-config/RequireJS_config_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ require.config({
'hogan':
process._RJS_rootDir(3) + '/node_modules/hogan.js/dist/hogan-3.0.2.amd',// version number in file name! :(

'jath':
process._RJS_rootDir(3) + '/node_modules/jath/jath',
'jxpath':
process._RJS_rootDir(3) + '/node_modules/jquery-xpath/jquery.xpath',

'spin':
process._RJS_rootDir(3) + '/node_modules/spin.js/spin',
Expand Down Expand Up @@ -103,8 +103,8 @@ require.config({
keymaster : {
exports: 'key'
},
jath : {
exports: 'Jath'
jxpath : {
exports: 'JXPath'
},
spin : {
exports: 'Spinner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require.config({
{
name: "readium-external-libs",
create: true,
include: ["jath", "bootstrap", "bootstrapA11y", "hammerjs", "hogan", "jquery_hammer", "keymaster", "screenfull", "spin",
include: ["jxpath", "bootstrap", "bootstrapA11y", "hammerjs", "hogan", "jquery_hammer", "keymaster", "screenfull", "spin",
"mime-types", "zip", "zip-ext", "zip-fs", "cryptoJs/sha1", "cryptoJs/core",
'jquery',
'underscore', 'URIjs', 'punycode', 'SecondLevelDomains', 'IPv6',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
"devDependencies": {
"keymaster": "danielweck/keymaster",
"jath": "danielweck/jath",
"jquery-xpath": "latest",
"mathjax-single-file": "danielweck/MathJax-single-file",
"bootstrap": "3.x",
"bootstrap-accessibility-plugin": "paypal/bootstrap-accessibility-plugin",
Expand Down
7 changes: 5 additions & 2 deletions package/package_base.cson
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ devDependencies:
"keymaster": 'danielweck/keymaster'

#"jath": 'latest'
"jath": 'danielweck/jath'
#"jath": 'danielweck/jath'

# "libxmljs" node-gyp python < v3 :(
#"jquery-xpath": 'latest'

"jquery-xpath": 'latest'
#"jquery-xpath": 'ilinsky/jquery-xpath'

"mathjax-single-file": 'danielweck/MathJax-single-file'

Expand Down
111 changes: 70 additions & 41 deletions src/js/PackageParser.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,83 @@
define(['jath'], function(Jath){
Jath.resolver = function( prefix ) {

define(['jquery', 'jxpath'], function($, JXPath){
var resolver = function( prefix ) {
var mappings = {
def: "http://www.idpf.org/2007/opf",
dc: "http://purl.org/dc/elements/1.1/"
};
return mappings[ prefix ];
}

var jathTemplate = {

metadata: {
id: "//def:metadata/dc:identifier",
epub_version: "//def:package/@version",
title: "//def:metadata/dc:title",
author: "//def:metadata/dc:creator",
publisher: "//def:metadata/dc:publisher",
description: "//def:metadata/dc:description",
rights: "//def:metadata/dc:rights",
language: "//def:metadata/dc:language",
pubdate: "//def:metadata/dc:date",
modified_date: "//def:metadata/def:meta[@property='dcterms:modified']",
layout: "//def:metadata/def:meta[@property='rendition:layout']",
spread: "//def:metadata/def:meta[@property='rendition:spread']",
orientation: "//def:metadata/def:meta[@property='rendition:orientation']",
ncx: "//def:spine/@toc",
page_prog_dir: "//def:spine/@page-progression-direction",
active_class: "//def:metadata/def:meta[@property='media:active-class']"
},

manifest: [ "//def:item", {
id: "@id",
href: "@href",
media_type: "@media-type",
properties: "@properties",
media_overlay: "@media-overlay"
} ],

spine: [ "//def:itemref", { idref: "@idref", properties: "@properties", linear: "@linear" } ],

bindings: ["//def:bindings/def:mediaType", {
handler: "@handler",
media_type: "@media-type"
} ]

};

PackageParser = {
parsePackageDom : function(data){
var jsonObj = Jath.parse(jathTemplate, data);

var jsonObj = {

metadata: {
id: $.xpath(data, "//def:metadata/dc:identifier", resolver).text(),
epub_version: $.xpath(data, "//def:package/@version", resolver).val(),
title: $.xpath(data, "//def:metadata/dc:title", resolver).text(),
author: $.xpath(data, "//def:metadata/dc:creator", resolver).text(),
publisher: $.xpath(data, "//def:metadata/dc:publisher", resolver).text(),
description: $.xpath(data, "//def:metadata/dc:description", resolver).text(),
rights: $.xpath(data, "//def:metadata/dc:rights", resolver).text(),
language: $.xpath(data, "//def:metadata/dc:language", resolver).text(),
pubdate: $.xpath(data, "//def:metadata/dc:date", resolver).text(),
modified_date: $.xpath(data, "//def:metadata/def:meta[@property='dcterms:modified']", resolver).text(),
layout: $.xpath(data, "//def:metadata/def:meta[@property='rendition:layout']", resolver).text(),
spread: $.xpath(data, "//def:metadata/def:meta[@property='rendition:spread']", resolver).text(),
orientation: $.xpath(data, "//def:metadata/def:meta[@property='rendition:orientation']", resolver).text(),
ncx: $.xpath(data, "//def:spine/@toc", resolver).val(),
page_prog_dir: $.xpath(data, "//def:spine/@page-progression-direction", resolver).val(),
active_class: $.xpath(data, "//def:metadata/def:meta[@property='media:active-class']", resolver).text()
}
/* UNUSED
manifest:
(function() {
var array = [];
$.xpath(data, "//def:item", resolver).each(function(item) {
array.push({
id: $.xpath(item, "@id", resolver).val(),
href: $.xpath(item, "@href", resolver).val(),
media_type: $.xpath(item, "@media-type", resolver).val(),
properties: $.xpath(item, "@properties", resolver).val(),
media_overlay: $.xpath(item, "@media-overlay", resolver).val()
});
});
return array;
})(),

spine:
(function() {
var array = [];
$.xpath(data, "//def:itemref", resolver).each(function(item) {
array.push({
idref: $.xpath(item, "@idref", resolver).val(),
properties: $.xpath(item, "@properties", resolver).val(),
linear: $.xpath(item, "@linear", resolver).val()
});
});
return array;
})(),

bindings:
(function() {
var array = [];
$.xpath(data, "//def:bindings/def:mediaType", resolver).each(function(item) {
array.push({
handler: $.xpath(item, "@handler", resolver).val(),
media_type: $.xpath(item, "@media-type", resolver).val()
});
});
return array;
})()
*/
};

jsonObj = jsonObj.metadata;

//console.debug(JSON.stringify(jsonObj));

jsonObj.coverHref = PackageParser.getCoverHref(data);
return jsonObj;
},
Expand Down