Use jinja for most qute:... pages.

This commit is contained in:
Florian Bruhin 2014-08-29 06:41:18 +02:00
parent c9ea83ca7b
commit 0f0929ac78
3 changed files with 46 additions and 13 deletions

View File

@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block content %}
{{ super() }}
<pre>
{{ content }}
</pre>
{% endblock %}

View File

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% block content %}
{{ super() }}
<h1>Version info</h1>
<pre>{{ version }}</pre>
<h1>Copyright info</h1>
<p>{{ copyright }}</p>
<p>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
</p>
<p>
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
</p>
<p>
You should have received a copy of the GNU General Public License
along with this program. If not, see <a href="http://www.gnu.org/licenses/">
http://www.gnu.org/licenses/</a> or open <a href="qute:gpl">qute:gpl</a>.
</p>
{% endblock %}

View File

@ -30,7 +30,7 @@ from PyQt5.QtNetwork import QNetworkReply
import qutebrowser
from qutebrowser.network import schemehandler
from qutebrowser.utils import version, utils
from qutebrowser.utils import version, utils, jinja
from qutebrowser.utils import log as logutils
@ -110,28 +110,28 @@ class QuteHandlers:
@classmethod
def pyeval(cls):
"""Handler for qute:pyeval. Return HTML content as bytes."""
text = pyhtml.escape(pyeval_output)
return _get_html('pyeval', '<pre>{}</pre>'.format(text))
html = jinja.env.get_template('pre.html').render(
title='pyeval', content=pyeval_output)
return html.encode('UTF-8', errors='xmlcharrefreplace')
@classmethod
def version(cls):
"""Handler for qute:version. Return HTML content as bytes."""
text = pyhtml.escape(version.version())
html = '<h1>Version info</h1>'
html += '<p>{}</p>'.format(text.replace('\n', '<br/>'))
html += '<h1>Copyright info</h1>'
html += '<p>{}</p>'.format(qutebrowser.__copyright__)
html += version.GPL_BOILERPLATE_HTML
return _get_html('Version', html)
html = jinja.env.get_template('version.html').render(
title='Version info', version=version.version(),
copyright=qutebrowser.__copyright__)
return html.encode('UTF-8', errors='xmlcharrefreplace')
@classmethod
def plainlog(cls):
"""Handler for qute:log. Return HTML content as bytes."""
"""Handler for qute:plainlog. Return HTML content as bytes."""
if logutils.ram_handler is None:
text = "Log output was disabled."
else:
text = pyhtml.escape(logutils.ram_handler.dump_log())
return _get_html('log', '<pre>{}</pre>'.format(text))
text = logutils.ram_handler.dump_log()
html = jinja.env.get_template('pre.html').render(
title='log', content=text)
return html.encode('UTF-8', errors='xmlcharrefreplace')
@classmethod
def log(cls):