From 0763e2a0bf7ff885e52c1f9915b95c3da88da435 Mon Sep 17 00:00:00 2001 From: southerntofu Date: Wed, 28 Jul 2021 20:38:29 -0400 Subject: [PATCH] Serve /opensearch.xml to add SimpleerTube as search engine to your webbrowser --- main.py | 13 +++++++++++++ opensearch.xml | 12 ++++++++++++ static/peertube.png | Bin 0 -> 746 bytes templates/base.html | 1 + templates/index.html | 1 + 5 files changed, 27 insertions(+) create mode 100644 opensearch.xml create mode 100644 static/peertube.png diff --git a/main.py b/main.py index ac3fa1e..7ca91f8 100644 --- a/main.py +++ b/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] diff --git a/opensearch.xml b/opensearch.xml new file mode 100644 index 0000000..85cc890 --- /dev/null +++ b/opensearch.xml @@ -0,0 +1,12 @@ + + + SimpleerTube + Search Peertube with a lightweight, minimalist interface. Noscript-friendly, multi-instance Peertube client. + UTF-8 + https://$BASEURL/static/peertube.png + + + + https://$BASEURL/ + diff --git a/static/peertube.png b/static/peertube.png new file mode 100644 index 0000000000000000000000000000000000000000..a42fce3f113806ae9ea4ebae893d00b753726af0 GIT binary patch literal 746 zcmVkj+9fF81f_03D4l@%ZVnMteiCm|)%SvLaJL~Sw{!fp`2mc@6d*AoH2lJFL z;=KtYUPDNV=GZ$0j3tbCdl&$b92v-DmucV)&|$mIL?r-brLtLhX}iwvFpglpbl@3q zJ7L7@D*-U8Zs1kIh>34&n?yd*8S_J zZzxmS7&gGb)J$aay`8CnWzo!0;Jq@nt}p;5fKJ z#ef6Aq%yUpr2sgix2oTpTZ!qW`r~{q=kAx7LiZCC~ zmgX_t^2Q6Tf(UQ|7!^V!mtZ~!?9eT*U$?xOg@S^lxCR&yLL34vNGT`t#7_d3b<4X| z>Q2}Jyc0rn{%aKfP4hlrS5Whu?*So1zW0C+yq%6LZ@#Inu1v+WF<>2#1V(hr^UFOA ztAM>LGUBSFQt53j-OFJfFYn=N;y@ouUXY1J^Z4SvbPey;|IW= cFw6n|0{(K*&Gl=6t^fc407*qoM6N<$f>ZuT00000 literal 0 HcmV?d00001 diff --git a/templates/base.html b/templates/base.html index f9a413a..dffb328 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,6 +4,7 @@ + {% block head %} {% block full_title %}{% block title %}{% endblock %} - SimpleerTube{% endblock %} {% endblock %} diff --git a/templates/index.html b/templates/index.html index 8d2a216..8a64d92 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,6 +3,7 @@ SimpleerTube - Search +