From 777eb90fa577d74b642277d0c5517227d51da0b5 Mon Sep 17 00:00:00 2001 From: Kevin Hendricks Date: Tue, 8 Jun 2021 13:58:03 -0400 Subject: [PATCH] a better fix that uses internal resolveUrl routine --- ChangeLog.txt | 3 +++ README.md | 2 +- ..._fixes.patch => epubjs_reader_better_bug_fix.patch | 11 +++++------ plugin.xml | 2 +- reader/js/reader.js | 3 +-- 5 files changed, 11 insertions(+), 10 deletions(-) rename epubjs_reader_bug_fixes.patch => epubjs_reader_better_bug_fix.patch (60%) diff --git a/ChangeLog.txt b/ChangeLog.txt index fb63cac..3e81c44 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,6 @@ +v031 + - simplify bug fix to use existing functions in reader.js + v030 - bug fix to correct Toc navigation error as it needs opf relative paths diff --git a/README.md b/README.md index 3d4357b..6079ae7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Updated: June 8, 2021 -Current Version: "0.3.0" +Current Version: "0.3.1" This plugin implements an epub3 reader for the epub currently being edited in Sigil. It uses PyQt5 and PyQtWebengine to create a browser like main window and then loads diff --git a/epubjs_reader_bug_fixes.patch b/epubjs_reader_better_bug_fix.patch similarity index 60% rename from epubjs_reader_bug_fixes.patch rename to epubjs_reader_better_bug_fix.patch index ffe5d4b..55fdca5 100644 --- a/epubjs_reader_bug_fixes.patch +++ b/epubjs_reader_better_bug_fix.patch @@ -1,6 +1,6 @@ ---- reader/js/reader.js.orig 2021-06-08 09:45:16.000000000 -0400 -+++ reader/js/reader.js 2021-06-08 09:51:48.000000000 -0400 -@@ -4310,7 +4310,11 @@ +--- reader.js.orig 2021-06-08 10:17:52.000000000 -0400 ++++ reader.js 2021-06-08 13:47:16.000000000 -0400 +@@ -4310,7 +4310,10 @@ $list.append(docfrag); $list.find(".toc_link").on("click", function(event){ @@ -8,12 +8,11 @@ + // convert href to be relative to the opf not ncx or nav + var ahref = this.getAttribute('href'); + var basePath = book.packaging.navPath || book.packaging.ncxPath -+ var base = 'https://example.invalid/' -+ var url = new URL(ahref, base + basePath).href.replace(base, '') ++ var url = EPUBJS.core.resolveUrl(basePath, ahref) event.preventDefault(); -@@ -4344,4 +4348,4 @@ +@@ -4344,4 +4347,4 @@ }; }; diff --git a/plugin.xml b/plugin.xml index 3445695..8f0af18 100755 --- a/plugin.xml +++ b/plugin.xml @@ -5,7 +5,7 @@ Sigil Provide a FuturePress EpubJS Reader to view the current epub being edited python3.4 -0.3.0 +0.3.1 true true osx,win,unx diff --git a/reader/js/reader.js b/reader/js/reader.js index b83808c..f0eec67 100644 --- a/reader/js/reader.js +++ b/reader/js/reader.js @@ -4313,8 +4313,7 @@ EPUBJS.reader.TocController = function(toc) { // convert href to be relative to the opf not ncx or nav var ahref = this.getAttribute('href'); var basePath = book.packaging.navPath || book.packaging.ncxPath - var base = 'https://example.invalid/' - var url = new URL(ahref, base + basePath).href.replace(base, '') + var url = EPUBJS.core.resolveUrl(basePath, ahref) event.preventDefault();