mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-03 14:59:18 +02:00
add basic dev, handle ../ in book path
This commit is contained in:
parent
932d9232c0
commit
e77818826b
5 changed files with 131 additions and 6 deletions
|
@ -112,6 +112,7 @@ EPUBJS.Book.prototype.open = function(bookPath, forceReload){
|
|||
|
||||
//-- Get a absolute URL from the book path
|
||||
this.bookUrl = this.urlFrom(bookPath);
|
||||
|
||||
// console.log("saved", saved, !forceReload)
|
||||
//-- Remove the previous settings and reload
|
||||
if(saved && !forceReload){
|
||||
|
@ -260,8 +261,6 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
//-- Get URL orgin, try for native or combine
|
||||
origin = location.origin || location.protocol + "//" + location.host;
|
||||
|
||||
|
||||
|
||||
// if(bookPath[bookPath.length - 1] != "/") bookPath += "/";
|
||||
|
||||
//-- 1. Check if url is absolute
|
||||
|
@ -276,6 +275,12 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
|
||||
//-- 3. Or find full path to url and add that
|
||||
if(!absolute && !fromRoot){
|
||||
|
||||
//-- go back
|
||||
if(bookPath.slice(0, 3) == "../"){
|
||||
return EPUBJS.core.resolveUrl(location.href, bookPath);
|
||||
}
|
||||
|
||||
return origin + EPUBJS.core.folder(location.pathname) + bookPath;
|
||||
}
|
||||
|
||||
|
|
2
build/epub.min.js
vendored
2
build/epub.min.js
vendored
File diff suppressed because one or more lines are too long
2
demo/js/epub.min.js
vendored
2
demo/js/epub.min.js
vendored
File diff suppressed because one or more lines are too long
115
examples/basic-dev.html
Normal file
115
examples/basic-dev.html
Normal file
|
@ -0,0 +1,115 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="no-js">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title>Basic ePubJS Example</title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
||||
|
||||
<!-- EPUBJS Renderer -->
|
||||
<!-- zip -->
|
||||
<script src="../libs/zip/zip.js"></script>
|
||||
<script src="../libs/zip/zip-fs.js"></script>
|
||||
<script src="../libs/zip/zip-ext.js"></script>
|
||||
<script src="../libs/zip/inflate.js"></script>
|
||||
<script src="../libs/zip/mime-types.js"></script>
|
||||
|
||||
|
||||
<!-- Render -->
|
||||
<script src="../libs/underscore/underscore.js"></script>
|
||||
<script src="../libs/rsvp/rsvp.js"></script>
|
||||
<script src="../libs/fileStorage/fileStorage.min.js"></script>
|
||||
|
||||
<script src="../src/base.js"></script>
|
||||
<script src="../src/core.js"></script>
|
||||
<script src="../src/unarchiver.js"></script>
|
||||
<script src="../src/parser.js"></script>
|
||||
<script src="../src/hooks.js"></script>
|
||||
<script src="../src/book.js"></script>
|
||||
<script src="../src/chapter.js"></script>
|
||||
<script src="../src/renderer.js"></script>
|
||||
<script src="../src/epubcfi.js"></script>
|
||||
|
||||
<!-- Plugins -->
|
||||
<script async src="../hooks/default/transculsions.js"></script>
|
||||
<script async src="../hooks/default/endnotes.js"></script>
|
||||
<script async src="../hooks/default/smartimages.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#main {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#area {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
margin: 5% auto;
|
||||
max-width: 1250px;
|
||||
}
|
||||
|
||||
#area iframe {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#prev {
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
#next {
|
||||
right: 40px;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
margin-top: -32px;
|
||||
font-size: 64px;
|
||||
color: #E2E2E2;
|
||||
font-family: arial, sans-serif;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.arrow:hover {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.arrow:active {
|
||||
color: #000;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
var Book = new EPUBJS.Book("../demo/moby-dick/");
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<div id="prev" onclick="Book.prevPage();" class="arrow">‹</div>
|
||||
<div id="area"></div>
|
||||
<div id="next" onclick="Book.nextPage();"class="arrow">›</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
Book.renderTo("area");
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -104,6 +104,7 @@ EPUBJS.Book.prototype.open = function(bookPath, forceReload){
|
|||
|
||||
//-- Get a absolute URL from the book path
|
||||
this.bookUrl = this.urlFrom(bookPath);
|
||||
|
||||
// console.log("saved", saved, !forceReload)
|
||||
//-- Remove the previous settings and reload
|
||||
if(saved && !forceReload){
|
||||
|
@ -252,8 +253,6 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
//-- Get URL orgin, try for native or combine
|
||||
origin = location.origin || location.protocol + "//" + location.host;
|
||||
|
||||
|
||||
|
||||
// if(bookPath[bookPath.length - 1] != "/") bookPath += "/";
|
||||
|
||||
//-- 1. Check if url is absolute
|
||||
|
@ -268,6 +267,12 @@ EPUBJS.Book.prototype.urlFrom = function(bookPath){
|
|||
|
||||
//-- 3. Or find full path to url and add that
|
||||
if(!absolute && !fromRoot){
|
||||
|
||||
//-- go back
|
||||
if(bookPath.slice(0, 3) == "../"){
|
||||
return EPUBJS.core.resolveUrl(location.href, bookPath);
|
||||
}
|
||||
|
||||
return origin + EPUBJS.core.folder(location.pathname) + bookPath;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue