mirror of
https://git.sr.ht/~metalune/simpleweb_peertube
synced 2024-12-21 15:23:54 +01:00
Serve /opensearch.xml to add SimpleerTube as search engine to your webbrowser
This commit is contained in:
parent
404b6e73f6
commit
0763e2a0bf
13
main.py
13
main.py
@ -434,6 +434,19 @@ async def favicon():
|
||||
error_reason = "We don't have a favicon yet. If you would like to contribute one, please send it to ~metalune/public-inbox@lists.sr.ht"
|
||||
), 404
|
||||
|
||||
# --- OpenSearch ---
|
||||
@app.route("/opensearch.xml")
|
||||
async def opensearch():
|
||||
try:
|
||||
with open('opensearch.xml', 'r') as f:
|
||||
return f.read().replace('$BASEURL', request.headers["Host"])
|
||||
except Exception as e:
|
||||
return await render_template(
|
||||
"error.html",
|
||||
error_number = "500",
|
||||
error_reason = e
|
||||
), 500
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) == 3:
|
||||
interface = sys.argv[1]
|
||||
|
12
opensearch.xml
Normal file
12
opensearch.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
|
||||
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>SimpleerTube</ShortName>
|
||||
<Description>Search Peertube with a lightweight, minimalist interface. Noscript-friendly, multi-instance Peertube client.</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Image width="16" height="16" type="image/png">https://$BASEURL/static/peertube.png</Image>
|
||||
<Url type="text/html" template="https://$BASEURL/search">
|
||||
<Param name="query" value="{searchTerms}"/>
|
||||
</Url>
|
||||
<moz:SearchForm>https://$BASEURL/</moz:SearchForm>
|
||||
</OpenSearchDescription>
|
BIN
static/peertube.png
Normal file
BIN
static/peertube.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 746 B |
@ -4,6 +4,7 @@
|
||||
<head>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="SimpleerTube"/>
|
||||
{% block head %}
|
||||
<title>{% block full_title %}{% block title %}{% endblock %} - SimpleerTube{% endblock %}</title>
|
||||
{% endblock %}
|
||||
|
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<title>SimpleerTube - Search</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="SimpleerTube"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user