~metalune/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
6 2

[PATCH 1/3] /search supports GET forms, as required by OpenSearch

southerntofu
Details
Message ID
<20210729003830.2625777-1-southerntofu@thunix.net>
DKIM signature
missing
Download raw message
Patch: +5 -0
---
 main.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/main.py b/main.py
index d326f0a..8fff89d 100644
--- a/main.py
+++ b/main.py
@@ -131,6 +131,11 @@ async def simpleer_search_redirect():
    query = (await request.form)["query"]
    return redirect("/search/" + query)

@app.route("/search", methods = ["GET"])
async def simpleer_search_get_redirect():
    query = request.args.get("query")
    return redirect("/search/" + query)

@app.route("/search/<string:query>", defaults = {"page": 1})
@app.route("/search/<string:query>/<int:page>")
async def simpleer_search(query, page):
-- 
2.30.2

[PATCH 2/3] Serve /opensearch.xml to add SimpleerTube as search engine to your webbrowser

southerntofu
Details
Message ID
<20210729003830.2625777-2-southerntofu@thunix.net>
In-Reply-To
<20210729003830.2625777-1-southerntofu@thunix.net> (view parent)
DKIM signature
missing
Download raw message
Patch: +27 -0
---
 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 8fff89d..05b608d 100644
--- a/main.py
+++ b/main.py
@@ -427,6 +427,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 @@
<?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>
diff --git a/static/peertube.png b/static/peertube.png
new file mode 100644
index 0000000000000000000000000000000000000000..a42fce3f113806ae9ea4ebae893d00b753726af0
GIT binary patch
literal 746
zcmV<G0u}v<P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800006VoOIv00000
z008+zyMF)x010qNS#tmY4c7nw4c7reD4Tcy000McNliru;sOW?1s1FruVerK0(VJ7
zK~z}7#g{=y6j2z*f4gf%#5k3CutT$(WgVi9T`H_YQAC+Vt7aZ7bIv`YV~2<i@#;{)
zU{Mij5>kj+9fF81f_03D4l@%ZVnMteiCm|)%SvLaJL~Sw{!fp`2mc@6d*AoH2lJFL
z;=KtYUPDNV=GZ$0j3tbCdl&$b92v-DmucV)&|$mIL?r-brLtLhX}iwvFpglpbl@3q
zJ7L7@D*-U8Zs1kIh<Am31iADAXtrJFSC|=?tAoI|ZS_V||KZwbB>>34&n?yd*8S_J
zZzxmS7&gGb)J$aay`8CnWzo!0;Jq@nt}p;5fKJ<WTECCmsX6<rfgWXQ50$Cal?$L3
zXtZ7D{vt7_fl*~@oyydrr2_Z?90AVQuJb8C{05*0c&<!sZ7~3uY%7l2t}|@APP%|>
z#ef6Aq%yUpr2sg<Ioov_ZP!T^QDrgUsWP=bWoiw90MhBS<@^3_+jZ`iu;H}<ua&7?
z$_voa*4l8gCFzx6@YMnzf*ip<;G+<tNeEF@0^>ix2oTpTZ!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>LGU<sstBxllWJZ8By5$WOY990sEI1iI#|*#Pn(8j5MwbfE16;W#uYW1FNfZj8
zfU{D{!LVP&Gr%ygy_DubGw>BSFQt53j-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 2332f2f..8985524 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -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 %}
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 @@
    <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>
-- 
2.30.2

[PATCH 3/3] Add a list of TODOs to the README

southerntofu
Details
Message ID
<20210729003830.2625777-3-southerntofu@thunix.net>
In-Reply-To
<20210729003830.2625777-1-southerntofu@thunix.net> (view parent)
DKIM signature
missing
Download raw message
Patch: +6 -0
---
 README.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/README.md b/README.md
index 4e8999d..008fcb2 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,12 @@ $ python3 main.py ::1 7171 # Also works with IPv6 addresses

It is strongly disrecommended to run the production using this command. Instead, please refer to the [Quart deployment docs](https://pgjones.gitlab.io/quart/tutorials/deployment.html).

## TODO

- Federation errors (eg. name not resolving) are not handled properly, producing bloaty tracebacks server side and unfriendly errors client side
- Expects to run in the webroot, not in a subdirectory
- Relies on search.joinpeertube.org API, while we should be able to configure a different SepiaSearch instance

## License

This software is distributed under the AGPLv3 license. You can find a copy in the [LICENSE](LICENSE) file.
-- 
2.30.2
Details
Message ID
<CD6NBLN1TR82.13MEHLYUGQA77@thinkpad>
In-Reply-To
<20210729003830.2625777-1-southerntofu@thunix.net> (view parent)
DKIM signature
pass
Download raw message
Thank you

Re: [PATCH 2/3] Serve /opensearch.xml to add SimpleerTube as search engine to your webbrowser

Details
Message ID
<CD6NC0WR1QVF.3TZTZZZAZY27K@thinkpad>
In-Reply-To
<20210729003830.2625777-2-southerntofu@thunix.net> (view parent)
DKIM signature
pass
Download raw message
This patch doesn't seem to apply correctly to the current HEAD

Re: [PATCH 3/3] Add a list of TODOs to the README

Details
Message ID
<CD6NCDFLUG5D.1TUL0X5MEC7KU@thinkpad>
In-Reply-To
<20210729003830.2625777-3-southerntofu@thunix.net> (view parent)
DKIM signature
pass
Download raw message
This is a well-intentioned patch, but I'll rather create a TODO list on
todo.sr.ht

Re: [PATCH 2/3] Serve /opensearch.xml to add SimpleerTube as search engine to your webbrowser

Details
Message ID
<CD77X0UVRR2G.3UTCNXFG4Z2RL@thinkpad>
In-Reply-To
<20210729003830.2625777-2-southerntofu@thunix.net> (view parent)
DKIM signature
pass
Download raw message
Thank you
Reply to thread Export thread (mbox)