Be more clever about missing qute://help pages
This commit is contained in:
parent
c8f3743008
commit
337d57b940
@ -29,6 +29,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import datetime
|
import datetime
|
||||||
|
import textwrap
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from PyQt5.QtCore import QUrlQuery, QUrl
|
from PyQt5.QtCore import QUrlQuery, QUrl
|
||||||
@ -358,24 +359,45 @@ def qute_help(url):
|
|||||||
if not docutils.docs_up_to_date(urlpath):
|
if not docutils.docs_up_to_date(urlpath):
|
||||||
message.error("Your documentation is outdated! Please re-run "
|
message.error("Your documentation is outdated! Please re-run "
|
||||||
"scripts/asciidoc2html.py.")
|
"scripts/asciidoc2html.py.")
|
||||||
|
|
||||||
path = 'html/doc/{}'.format(urlpath)
|
path = 'html/doc/{}'.format(urlpath)
|
||||||
if urlpath.endswith('.png'):
|
if urlpath.endswith('.png'):
|
||||||
return 'image/png', utils.read_file(path, binary=True)
|
return 'image/png', utils.read_file(path, binary=True)
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
data = utils.read_file(path)
|
data = utils.read_file(path)
|
||||||
except OSError:
|
except OSError:
|
||||||
html = jinja.render(
|
# No .html around, let's see if we find the asciidoc
|
||||||
'error.html',
|
asciidoc_path = path.replace('.html', '.asciidoc')
|
||||||
title="Error while loading documentation",
|
if asciidoc_path.startswith('html/doc/'):
|
||||||
url=url.toDisplayString(),
|
asciidoc_path = asciidoc_path.replace('html/doc/', '../doc/help/')
|
||||||
error="This most likely means the documentation was not "
|
|
||||||
"generated properly. If you are running qutebrowser "
|
try:
|
||||||
"from the git repository, please run "
|
asciidoc = utils.read_file(asciidoc_path)
|
||||||
"scripts/asciidoc2html.py. If you're running a released "
|
except OSError:
|
||||||
"version this is a bug, please use :report to report "
|
asciidoc = None
|
||||||
"it.")
|
|
||||||
return 'text/html', html
|
if asciidoc is None:
|
||||||
|
raise
|
||||||
|
|
||||||
|
preamble = textwrap.dedent("""
|
||||||
|
There was an error loading the documentation!
|
||||||
|
|
||||||
|
This most likely means the documentation was not generated
|
||||||
|
properly. If you are running qutebrowser from the git repository,
|
||||||
|
please (re)run scripts/asciidoc2html.py and reload this page.
|
||||||
|
|
||||||
|
If you're running a released version this is a bug, please use
|
||||||
|
:report to report it.
|
||||||
|
|
||||||
|
Falling back to the plaintext version.
|
||||||
|
|
||||||
|
---------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
""")
|
||||||
|
return 'text/plain', (preamble + asciidoc).encode('utf-8')
|
||||||
|
else:
|
||||||
return 'text/html', data
|
return 'text/html', data
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user