diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 98c9ba961..3c426c232 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -24,7 +24,6 @@ Module attributes: _HANDLERS: The handlers registered via decorators. """ -import mimetypes import urllib.parse import qutebrowser @@ -103,7 +102,7 @@ class add_handler: # pylint: disable=invalid-name url=url.toDisplayString(), error='{} is not available with this ' 'backend'.format(url.toDisplayString()), - icon='', qutescheme=True) + icon='') return 'text/html', html @@ -238,8 +237,7 @@ def qute_help(url): "repository, please run scripts/asciidoc2html.py. " "If you're running a released version this is a bug, please " "use :report to report it.", - icon='', - qutescheme=True) + icon='') return 'text/html', html urlpath = url.path() if not urlpath or urlpath == '/': @@ -255,12 +253,3 @@ def qute_help(url): else: data = utils.read_file(path) return 'text/html', data - - -@add_handler('resource') -def qute_resource(url): - """Serve resources via a qute://resource/... URL.""" - data = utils.read_file(url.path(), binary=True) - mimetype, _encoding = mimetypes.guess_type(url.fileName()) - assert mimetype is not None, url - return mimetype, data diff --git a/qutebrowser/browser/webkit/network/filescheme.py b/qutebrowser/browser/webkit/network/filescheme.py index 5787b0a34..cd0a6d489 100644 --- a/qutebrowser/browser/webkit/network/filescheme.py +++ b/qutebrowser/browser/webkit/network/filescheme.py @@ -102,7 +102,7 @@ def dirbrowser_html(path): html = jinja.render('error.html', title="Error while reading directory", url='file:///{}'.format(path), error=str(e), - icon='', qutescheme=False) + icon='') return html.encode('UTF-8', errors='xmlcharrefreplace') files = get_file_list(path, all_files, os.path.isfile) diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py index 47adc0aa3..09feed3d5 100644 --- a/qutebrowser/browser/webkit/webpage.py +++ b/qutebrowser/browser/webkit/webpage.py @@ -178,8 +178,7 @@ class BrowserPage(QWebPage): title = "Error loading page: {}".format(urlstr) error_html = jinja.render( 'error.html', - title=title, url=urlstr, error=error_str, icon='', - qutescheme=False) + title=title, url=urlstr, error=error_str, icon='') errpage.content = error_html.encode('utf-8') errpage.encoding = 'utf-8' return True diff --git a/qutebrowser/html/error.html b/qutebrowser/html/error.html index b903f39b0..80bd0cf61 100644 --- a/qutebrowser/html/error.html +++ b/qutebrowser/html/error.html @@ -73,7 +73,7 @@ function searchFor(uri) {
- ![]() ![]() |
Unable to load pagediff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py index afaa8caa3..f12184290 100644 --- a/qutebrowser/utils/jinja.py +++ b/qutebrowser/utils/jinja.py @@ -26,7 +26,7 @@ import traceback import jinja2 import jinja2.exceptions -from qutebrowser.utils import utils, urlutils, log, qtutils +from qutebrowser.utils import utils, urlutils, log from PyQt5.QtCore import QUrl @@ -64,25 +64,14 @@ def _guess_autoescape(template_name): return ext in ['html', 'htm', 'xml'] -def resource_url(path, qutescheme=False): +def resource_url(path): """Load images from a relative path (to qutebrowser). Arguments: path: The relative path to the image - qutescheme: If the logo needs to be served via a qute:// scheme. - This is the case when we want to show an error page from - there. """ - if qutescheme: - url = QUrl() - url.setScheme('qute') - url.setHost('resource') - url.setPath('/' + path) - qtutils.ensure_valid(url) - return url.toString(QUrl.FullyEncoded) - else: - full_path = utils.resource_filename(path) - return QUrl.fromLocalFile(full_path).toString(QUrl.FullyEncoded) + image = utils.resource_filename(path) + return QUrl.fromLocalFile(image).toString(QUrl.FullyEncoded) def render(template, **kwargs): diff --git a/tests/unit/utils/test_jinja.py b/tests/unit/utils/test_jinja.py index 28640ca07..cea237d22 100644 --- a/tests/unit/utils/test_jinja.py +++ b/tests/unit/utils/test_jinja.py @@ -39,10 +39,8 @@ def patch_read_file(monkeypatch): """A read_file which returns a simple template if the path is right.""" if path == os.path.join('html', 'test.html'): return """Hello {{var}}""" - elif path == os.path.join('html', 'resource_url.html'): - return """{{ resource_url('utils/testfile', False) }}""" - elif path == os.path.join('html', 'resource_url_qute.html'): - return """{{ resource_url('utils/testfile', True) }}""" + elif path == os.path.join('html', 'test2.html'): + return """{{ resource_url('utils/testfile') }}""" elif path == os.path.join('html', 'undef.html'): return """{{ does_not_exist() }}""" elif path == os.path.join('html', 'undef_error.html'): @@ -61,7 +59,7 @@ def test_simple_template(): def test_resource_url(): """Test resource_url() which can be used from templates.""" - data = jinja.render('resource_url.html') + data = jinja.render('test2.html') print(data) url = QUrl(data) assert url.isValid() @@ -77,14 +75,6 @@ def test_resource_url(): assert f.read().splitlines()[0] == "Hello World!" -def test_resource_url_qutescheme(): - """Test resource_url() which can be used from templates.""" - data = jinja.render('resource_url_qute.html') - print(data) - url = QUrl(data) - assert url == QUrl('qute://resource/utils/testfile') - - def test_not_found(): """Test with a template which does not exist.""" with pytest.raises(jinja2.TemplateNotFound) as excinfo: |