✨ mirrors page
This commit is contained in:
parent
b5b52205c4
commit
9a12cfa491
3 changed files with 34 additions and 3 deletions
|
@ -10,4 +10,7 @@ The main configuration is in `config.json`. See [this](./config.json.md)
|
||||||
If you want to show a picture on the main page, place a file called `me.avif` in the config folder.
|
If you want to show a picture on the main page, place a file called `me.avif` in the config folder.
|
||||||
|
|
||||||
## PGP Key
|
## PGP Key
|
||||||
If you want to share your public key, put it inside `pub.key`.
|
If you want to share your public key, put it inside `pub.key`.
|
||||||
|
|
||||||
|
## Mirrors
|
||||||
|
Specify mirror urls inside of `mirrors.txt` and it will be served at `/mirrors.txt`
|
|
@ -18,3 +18,10 @@ def dynamic_link(
|
||||||
if is_i2p(req):
|
if is_i2p(req):
|
||||||
return Link(i2p, inner)
|
return Link(i2p, inner)
|
||||||
return Link(normal, inner)
|
return Link(normal, inner)
|
||||||
|
|
||||||
|
|
||||||
|
def is_browser(req: flask.globals.request) -> bool:
|
||||||
|
ua = req.user_agent.string.lower()
|
||||||
|
if "chrome" in ua or "safari" in ua or "firefox" in ua:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
25
src/index.py
25
src/index.py
|
@ -8,9 +8,31 @@ from config import CONFIG
|
||||||
from html_fn import buildSite
|
from html_fn import buildSite
|
||||||
from msg import encrypt, save_message
|
from msg import encrypt, save_message
|
||||||
from notification import notify
|
from notification import notify
|
||||||
|
from fn import is_browser
|
||||||
|
|
||||||
main_pages = Blueprint("main", __name__)
|
main_pages = Blueprint("main", __name__)
|
||||||
|
|
||||||
|
# Mirrors
|
||||||
|
@main_pages.route("/mirrors.txt", methods=["GET"])
|
||||||
|
def mirrors():
|
||||||
|
# TODO : Autogenerate GPG Sign Message
|
||||||
|
if exists("/config/mirrors.txt"):
|
||||||
|
txt = open("/config/mirrors.txt").read()
|
||||||
|
if is_browser(request):
|
||||||
|
site = buildSite(None, "Mirrors")
|
||||||
|
|
||||||
|
site.body = Body(
|
||||||
|
content=Div(
|
||||||
|
f"<pre>{txt}</pre>",
|
||||||
|
),
|
||||||
|
global_attr=GlobalAttributes(style="background: black; color: white"),
|
||||||
|
)
|
||||||
|
return site.to_code()
|
||||||
|
|
||||||
|
return txt
|
||||||
|
else:
|
||||||
|
return Response(response="", status=404)
|
||||||
|
|
||||||
|
|
||||||
# Message Sending Page
|
# Message Sending Page
|
||||||
@main_pages.route("/message", methods=["GET", "POST"])
|
@main_pages.route("/message", methods=["GET", "POST"])
|
||||||
|
@ -85,8 +107,7 @@ def public_key():
|
||||||
str(pgp.list_keys()[0]["uids"][0]).replace("<", "[ ").replace(">", " ]")
|
str(pgp.list_keys()[0]["uids"][0]).replace("<", "[ ").replace(">", " ]")
|
||||||
)
|
)
|
||||||
|
|
||||||
ua = request.user_agent.string.lower()
|
if is_browser(request):
|
||||||
if "chrome" in ua or "safari" in ua or "firefox" in ua:
|
|
||||||
# If request is from common browser return stylized html
|
# If request is from common browser return stylized html
|
||||||
return buildSite(
|
return buildSite(
|
||||||
[
|
[
|
||||||
|
|
Loading…
Add table
Reference in a new issue