Get PDF.js to work

We need to use the /web/viewer.html path so relative references are correct.
This commit is contained in:
Florian Bruhin 2018-09-06 00:57:14 +02:00
parent 7206dde19c
commit bbcb87e434
3 changed files with 5 additions and 2 deletions

View File

@ -214,7 +214,7 @@ def should_use_pdfjs(mimetype):
def get_main_url(filename):
"""Get the URL to be opened to view a local PDF."""
url = QUrl('qute://pdfjs/')
url = QUrl('qute://pdfjs/web/viewer.html')
file_url = QUrl('qute://pdfjs/file')
file_url_query = QUrlQuery()

View File

@ -533,7 +533,7 @@ def qute_pdfjs(url):
mimetype = 'application/octet-stream'
return mimetype, data
if url.path() == '/':
if url.path() == '/web/viewer.html':
filepath = QUrlQuery(url).queryItemValue("file")
data = pdfjs.generate_pdfjs_page(QUrl.fromLocalFile(filepath))
return 'text/html', data

View File

@ -17,7 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
import textwrap
import pytest
from PyQt5.QtCore import QUrl
from qutebrowser.browser import pdfjs