Move pdfjs error page to pdfjs.py
This commit is contained in:
parent
36b2f5e63f
commit
8f1690eff7
@ -24,7 +24,7 @@ import os
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
|
||||
from qutebrowser.utils import utils, javascript
|
||||
from qutebrowser.utils import utils, javascript, jinja
|
||||
|
||||
|
||||
class PDFJSNotFound(Exception):
|
||||
@ -49,6 +49,10 @@ def generate_pdfjs_page(url):
|
||||
Args:
|
||||
url: The url of the pdf as QUrl.
|
||||
"""
|
||||
if not is_available():
|
||||
return jinja.render('no_pdfjs.html',
|
||||
url=url.toDisplayString(),
|
||||
title="PDF.js not found")
|
||||
viewer = get_pdfjs_res('web/viewer.html').decode('utf-8')
|
||||
script = _generate_pdfjs_script(url)
|
||||
html_page = viewer.replace('</body>',
|
||||
|
@ -208,12 +208,7 @@ class BrowserPage(QWebPage):
|
||||
|
||||
def _show_pdfjs(self, reply):
|
||||
"""Show the reply with pdfjs."""
|
||||
try:
|
||||
page = pdfjs.generate_pdfjs_page(reply.url())
|
||||
except pdfjs.PDFJSNotFound:
|
||||
page = jinja.render('no_pdfjs.html',
|
||||
url=reply.url().toDisplayString(),
|
||||
title="PDF.js not found")
|
||||
page = pdfjs.generate_pdfjs_page(reply.url())
|
||||
self.mainFrame().setContent(page.encode('utf-8'), 'text/html',
|
||||
reply.url())
|
||||
reply.deleteLater()
|
||||
|
Loading…
Reference in New Issue
Block a user