Use man2html to generate man pages in the Web UI (#887)

* Use man2html to generate man pages in the web UI

* Fix tests
This commit is contained in:
Daniel Markstedt
2022-10-04 06:38:15 -07:00
committed by GitHub
parent 402a1ba380
commit 0e4d42f04c
9 changed files with 47 additions and 20 deletions
+1 -1
View File
@@ -89,7 +89,7 @@
{% block content %}{% endblock content %}
</div>
<div class="footer">
<center><tt><a href="/sys/manpage?app=rascsi">{{ _("RaSCSI Reloaded version: ") }}</a><strong>{{ version }} <a href="https://github.com/akuker/RASCSI/commit/{{ env["running_env"]["git"] }}" target="_blank">{{ env["running_env"]["git"][:7] }}</a></strong></tt></center>
<center><tt>{{ _("RaSCSI Reloaded version: ") }}<strong>{{ version }} <a href="https://github.com/akuker/RASCSI/commit/{{ env["running_env"]["git"] }}" target="_blank">{{ env["running_env"]["git"][:7] }}</a></strong></tt></center>
<center><tt>{{ _("Pi environment: ") }}{{ env["running_env"]["env"] }}</tt></center>
</div>
</div>
+4
View File
@@ -751,6 +751,10 @@
</tr>
</table>
<hr/>
<a href="/sys/manpage?app=rascsi"><p>{{ _("Read the RaSCSI Manual") }}</p></a>
<center><tt>
{% if netatalk_configured == 1 %}
{{ _("The AppleShare server is running. No active connections.") }}
+2 -2
View File
@@ -1,8 +1,8 @@
{% extends "base.html" %}
{% block content %}
<h3>{{ _("Manual for %(app)s:", app=app) }}</h3>
<p><pre>{{ manpage }}</pre></p>
<h1>{{ _("Manual for %(app)s:", app=app) }}</h1>
{{ manpage | safe }}
<p><a href="/">{{ _("Go to Home") }}</a></p>
{% endblock content %}
+22 -5
View File
@@ -504,14 +504,27 @@ def show_manpage():
)
server_info = ractl_cmd.get_server_info()
file_path = f"{WEB_DIR}/../../../doc/{app}_man_page.txt"
file_path = f"{WEB_DIR}/../../../doc/{app}.1"
html_to_strip = [
"Content-type",
"!DOCTYPE",
"<HTML>",
"<HEAD>",
"<BODY>",
"<H1>",
]
returncode, manpage = sys_cmd.get_filecontents(file_path)
returncode, manpage = sys_cmd.get_manpage(file_path)
if returncode == 0:
formatted_manpage = ""
for line in manpage.splitlines(True):
# Strip out irrelevant header
if not line.startswith("!!"):
# Make URIs compatible with the Flask webapp
if "/?1+" in line:
line = line.replace("/?1+", "manpage?app=")
# Strip out useless hyperlink
elif "man2html" in line:
line = line.replace("<A HREF=\"/\">man2html</A>", "man2html")
if not any(ele in line for ele in html_to_strip):
formatted_manpage += line
return response(
@@ -945,7 +958,11 @@ def create_file():
if not process["status"]:
return response(error=True, message=process["msg"])
return response(message=_("Image file created: %(file_name)s", file_name=full_file_name))
return response(
status_code=201,
message=_("Image file created: %(file_name)s", file_name=full_file_name),
image=full_file_name,
)
@APP.route("/files/download", methods=["POST"])
+1 -1
View File
@@ -74,7 +74,7 @@ def test_attach_image(http_client, create_test_image, detach_devices):
},
),
("Host Bridge", {"type": "SCBR", "interface": "eth0", "inet": "10.10.20.1/24"}),
("DaynaPORT SCSI/Link", {"type": "SCDP", "interface": "eth0", "inet": "10.10.20.1/24"}),
("Ethernet Adapter", {"type": "SCDP", "interface": "eth0", "inet": "10.10.20.1/24"}),
("Host Services", {"type": "SCHS"}),
("Printer", {"type": "SCLP", "timeout": 30, "cmd": "lp -oraw %f"}),
],
+1
View File
@@ -21,6 +21,7 @@ def test_create_file(http_client, list_files, delete_file):
"file_name": file_prefix,
"type": "hds",
"size": 1,
"drive_name": "DEC RZ22",
},
)