✨ color scheme
This commit is contained in:
parent
c3d63a25fc
commit
6d158832e9
6 changed files with 81 additions and 12 deletions
|
@ -9,3 +9,6 @@
|
|||
- - `gotify`: Gotify Object
|
||||
- - - `token` : Gotify Token
|
||||
- - - `host` : Gotify Host/Domain name
|
||||
- `colors`
|
||||
- - - `fg` : Color Number in colors.json
|
||||
- - - `bg` : Color Number in colors.json
|
|
@ -14,3 +14,9 @@ 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`
|
||||
|
||||
## Color Scheme
|
||||
The site colors can be configured with pywal. Place pywal's colors.json in the config folder.
|
||||
|
||||
## Background
|
||||
To set a background picture place it at `config/wall.png`
|
|
@ -16,3 +16,8 @@ def filesend(path):
|
|||
@asset_pages.route("/me", methods=["GET"])
|
||||
def me_picture():
|
||||
return filesend("/config/me.avif")
|
||||
|
||||
|
||||
@asset_pages.route("/wall")
|
||||
def wall_bg():
|
||||
return filesend("/config/wall.png")
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
import json
|
||||
|
||||
CONFIG = json.loads(open("/config/config.json").read())
|
||||
|
||||
|
||||
def colors():
|
||||
try:
|
||||
return json.loads(open("/config/colors.json").read())
|
||||
except:
|
||||
return None
|
||||
|
|
|
@ -1,9 +1,29 @@
|
|||
import requests
|
||||
import os
|
||||
from htmlpy import *
|
||||
from config import colors, CONFIG
|
||||
|
||||
# Wrapper for Base HTML
|
||||
def buildSite(content, title=None):
|
||||
def buildSite(content, title=None, disable_color=False):
|
||||
c_class = "bg-dark text-white justify-content-center text-center"
|
||||
c_style = ""
|
||||
if not disable_color:
|
||||
if colors() is not None:
|
||||
c_class = "justify-content-center text-center"
|
||||
fg = colors()["special"]["foreground"]
|
||||
bg = colors()["special"]["background"]
|
||||
if "colors" in CONFIG:
|
||||
if "fg" in CONFIG["colors"]:
|
||||
i = CONFIG["colors"]["fg"] - 1
|
||||
fg = colors()["colors"][f"color{i}"]
|
||||
if "bg" in CONFIG["colors"]:
|
||||
i = CONFIG["colors"]["bg"] - 1
|
||||
bg = colors()["colors"][f"color{i}"]
|
||||
c_style = f"background: {bg}; color: {fg};"
|
||||
|
||||
if os.path.exists("/config/wall.png"):
|
||||
c_style += "background-image: url('assets/wall');"
|
||||
|
||||
return Document(
|
||||
head=Head(
|
||||
[
|
||||
|
@ -17,9 +37,7 @@ def buildSite(content, title=None):
|
|||
),
|
||||
body=Body(
|
||||
content,
|
||||
global_attr=GlobalAttributes(
|
||||
css_class="bg-dark text-white justify-content-center text-center"
|
||||
),
|
||||
global_attr=GlobalAttributes(css_class=c_class, style=c_style),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
42
src/index.py
42
src/index.py
|
@ -4,7 +4,7 @@ import gnupg
|
|||
from flask import request, Blueprint, Response, redirect
|
||||
from htmlpy import *
|
||||
|
||||
from config import CONFIG
|
||||
from config import CONFIG, colors
|
||||
from html_fn import buildSite
|
||||
from msg import encrypt, save_message
|
||||
from notification import notify
|
||||
|
@ -12,6 +12,35 @@ from fn import is_browser
|
|||
|
||||
main_pages = Blueprint("main", __name__)
|
||||
|
||||
# Color Scheme
|
||||
@main_pages.route("/color")
|
||||
def color():
|
||||
if colors() is None:
|
||||
return ""
|
||||
colors_p = [Heading(1, "Color 0")]
|
||||
for i in range(0, 16):
|
||||
c = colors()["colors"][f"color{i}"]
|
||||
colors_p.append(
|
||||
Heading(
|
||||
1, f"Color {i+1}", global_attr=GlobalAttributes(style=f"color: {c}")
|
||||
)
|
||||
)
|
||||
site = buildSite([], "Colors")
|
||||
|
||||
bg = colors()["special"]["background"]
|
||||
fg = colors()["special"]["foreground"]
|
||||
cur = colors()["special"]["cursor"]
|
||||
site.body = Body(
|
||||
[Div([colors_p], global_attr=GlobalAttributes(css_class="container"))],
|
||||
global_attr=GlobalAttributes(
|
||||
style=f"background: {bg}; color: {fg}",
|
||||
css_class="justify-content-center text-center",
|
||||
),
|
||||
)
|
||||
|
||||
return site.to_code()
|
||||
|
||||
|
||||
# Mirrors
|
||||
@main_pages.route("/mirrors.txt", methods=["GET"])
|
||||
def mirrors():
|
||||
|
@ -19,14 +48,14 @@ def mirrors():
|
|||
if exists("/config/mirrors.txt"):
|
||||
txt = open("/config/mirrors.txt").read()
|
||||
if is_browser(request):
|
||||
site = buildSite(None, "Mirrors")
|
||||
|
||||
site.body = Body(
|
||||
content=Div(
|
||||
site = buildSite(
|
||||
Div(
|
||||
f"<pre>{txt}</pre>",
|
||||
global_attr=GlobalAttributes(style="margin: 25px;"),
|
||||
),
|
||||
global_attr=GlobalAttributes(style="background: black; color: white"),
|
||||
"Mirrors",
|
||||
)
|
||||
|
||||
return site.to_code()
|
||||
|
||||
return txt
|
||||
|
@ -144,6 +173,7 @@ def public_key():
|
|||
),
|
||||
],
|
||||
"Public Key",
|
||||
disable_color=True,
|
||||
).to_code()
|
||||
|
||||
# Return raw key
|
||||
|
|
Loading…
Add table
Reference in a new issue