mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
3d5597fbcc
21
daemon.py
21
daemon.py
|
|
@ -167,6 +167,7 @@ from webapp_utils import html_hashtag_blocked
|
||||||
from webapp_utils import html_following_list
|
from webapp_utils import html_following_list
|
||||||
from webapp_utils import set_blog_address
|
from webapp_utils import set_blog_address
|
||||||
from webapp_utils import html_show_share
|
from webapp_utils import html_show_share
|
||||||
|
from webapp_utils import get_pwa_theme_colors
|
||||||
from webapp_calendar import html_calendar_delete_confirm
|
from webapp_calendar import html_calendar_delete_confirm
|
||||||
from webapp_calendar import html_calendar
|
from webapp_calendar import html_calendar
|
||||||
from webapp_about import html_about
|
from webapp_about import html_about
|
||||||
|
|
@ -6878,24 +6879,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
getreq_start_time) -> None:
|
getreq_start_time) -> None:
|
||||||
"""gets the PWA manifest
|
"""gets the PWA manifest
|
||||||
"""
|
"""
|
||||||
pwa_theme_color = 'grey'
|
|
||||||
pwa_theme_background_color = 'black'
|
|
||||||
|
|
||||||
css_filename = base_dir + '/epicyon.css'
|
css_filename = base_dir + '/epicyon.css'
|
||||||
if os.path.isfile(css_filename):
|
pwa_theme_color, pwa_theme_background_color = \
|
||||||
css_str = ''
|
get_pwa_theme_colors(css_filename)
|
||||||
with open(css_filename, 'r') as fp_css:
|
|
||||||
css_str = fp_css.read()
|
|
||||||
if '--pwa-theme-color:' in css_str:
|
|
||||||
pwa_theme_color = css_str.split('--pwa-theme-color:')[1]
|
|
||||||
if ';' in pwa_theme_color:
|
|
||||||
pwa_theme_color = pwa_theme_color.split(';')[0].strip()
|
|
||||||
if '--pwa-theme-background-color:' in css_str:
|
|
||||||
pwa_theme_background_color = \
|
|
||||||
css_str.split('--pwa-theme-background-color:')[1]
|
|
||||||
if ';' in pwa_theme_background_color:
|
|
||||||
pwa_theme_background_color = \
|
|
||||||
pwa_theme_background_color.split(';')[0].strip()
|
|
||||||
app1 = "https://f-droid.org/en/packages/eu.siacs.conversations"
|
app1 = "https://f-droid.org/en/packages/eu.siacs.conversations"
|
||||||
app2 = "https://staging.f-droid.org/en/packages/im.vector.app"
|
app2 = "https://staging.f-droid.org/en/packages/im.vector.app"
|
||||||
app3 = \
|
app3 = \
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
@charset "UTF-8";
|
@charset "UTF-8";
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--pwa-theme-color: apple-mobile-statusbar-color;
|
--pwa-theme-color: apple-mobile-web-app-status-bar-style;
|
||||||
--pwa-theme-background-color: black-translucent;
|
--pwa-theme-background-color: black-translucent;
|
||||||
--avatar-rounding: 10%;
|
--avatar-rounding: 10%;
|
||||||
--timeline-icon-width: 50px;
|
--timeline-icon-width: 50px;
|
||||||
|
|
|
||||||
2
theme.py
2
theme.py
|
|
@ -16,6 +16,7 @@ from utils import copytree
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from utils import dangerous_svg
|
from utils import dangerous_svg
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
|
from utils import remove_html
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from shutil import make_archive
|
from shutil import make_archive
|
||||||
from shutil import unpack_archive
|
from shutil import unpack_archive
|
||||||
|
|
@ -272,6 +273,7 @@ def _remove_theme(base_dir: str):
|
||||||
def set_css_param(css: str, param: str, value: str) -> str:
|
def set_css_param(css: str, param: str, value: str) -> str:
|
||||||
"""Sets a CSS parameter to a given value
|
"""Sets a CSS parameter to a given value
|
||||||
"""
|
"""
|
||||||
|
value = remove_html(value)
|
||||||
# is this just a simple string replacement?
|
# is this just a simple string replacement?
|
||||||
if ';' in param:
|
if ';' in param:
|
||||||
return css.replace(param, value)
|
return css.replace(param, value)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"newswire-publish-icon": "True",
|
"newswire-publish-icon": "True",
|
||||||
"full-width-timeline-buttons": "False",
|
"full-width-timeline-buttons": "False",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#222",
|
"dropdown-fg-color": "#222",
|
||||||
"dropdown-bg-color": "white",
|
"dropdown-bg-color": "white",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#9ad791",
|
"dropdown-fg-color": "#9ad791",
|
||||||
"dropdown-bg-color": "#222",
|
"dropdown-bg-color": "#222",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "white",
|
"dropdown-fg-color": "white",
|
||||||
"dropdown-bg-color": "#483335",
|
"dropdown-bg-color": "#483335",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "white",
|
"dropdown-fg-color": "white",
|
||||||
"dropdown-bg-color": "#222",
|
"dropdown-bg-color": "#222",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "black",
|
"dropdown-fg-color": "black",
|
||||||
"dropdown-bg-color": "#dedede",
|
"dropdown-bg-color": "#dedede",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#33390d",
|
"dropdown-fg-color": "#33390d",
|
||||||
"dropdown-bg-color": "#9fb42b",
|
"dropdown-bg-color": "#9fb42b",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#2d2c37",
|
"dropdown-fg-color": "#2d2c37",
|
||||||
"dropdown-bg-color": "#d6dbf0",
|
"dropdown-bg-color": "#d6dbf0",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#0481f5",
|
"dropdown-fg-color": "#0481f5",
|
||||||
"dropdown-bg-color": "#0d0d10",
|
"dropdown-bg-color": "#0d0d10",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "black",
|
"dropdown-fg-color": "black",
|
||||||
"dropdown-bg-color": "#aba0d4",
|
"dropdown-bg-color": "#aba0d4",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#f98bb0",
|
"dropdown-fg-color": "#f98bb0",
|
||||||
"dropdown-bg-color": "#2f152d",
|
"dropdown-bg-color": "#2f152d",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "white",
|
"dropdown-fg-color": "white",
|
||||||
"dropdown-bg-color": "#002a3a",
|
"dropdown-bg-color": "#002a3a",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#2d2c37",
|
"dropdown-fg-color": "#2d2c37",
|
||||||
"dropdown-bg-color": "#ddd",
|
"dropdown-bg-color": "#ddd",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#ffc4bc",
|
"dropdown-fg-color": "#ffc4bc",
|
||||||
"dropdown-bg-color": "#1f0d10",
|
"dropdown-bg-color": "#1f0d10",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"pwa-theme-color": "apple-mobile-statusbar-color",
|
"pwa-theme-color": "apple-mobile-web-app-status-bar-style",
|
||||||
"pwa-theme-background-color": "black-translucent",
|
"pwa-theme-background-color": "black-translucent",
|
||||||
"dropdown-fg-color": "#d5c7b7",
|
"dropdown-fg-color": "#d5c7b7",
|
||||||
"dropdown-bg-color": "#4c4e41",
|
"dropdown-bg-color": "#4c4e41",
|
||||||
|
|
|
||||||
|
|
@ -538,11 +538,56 @@ def get_right_image_file(base_dir: str,
|
||||||
account_dir, nickname, domain, theme)
|
account_dir, nickname, domain, theme)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_variable_from_css(css_str: str, variable: str) -> str:
|
||||||
|
"""Gets a variable value from the css file text
|
||||||
|
"""
|
||||||
|
if '--' + variable + ':' not in css_str:
|
||||||
|
return None
|
||||||
|
value = css_str.split('--' + variable + ':')[1]
|
||||||
|
if ';' in value:
|
||||||
|
value = value.split(';')[0].strip()
|
||||||
|
value = remove_html(value)
|
||||||
|
if ' ' in value:
|
||||||
|
value = None
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def get_pwa_theme_colors(css_filename: str) -> (str, str):
|
||||||
|
"""Gets the theme/statusbar color for progressive web apps
|
||||||
|
"""
|
||||||
|
default_pwa_theme_color = 'apple-mobile-web-app-status-bar-style'
|
||||||
|
pwa_theme_color = default_pwa_theme_color
|
||||||
|
|
||||||
|
default_pwa_theme_background_color = 'black-translucent'
|
||||||
|
pwa_theme_background_color = default_pwa_theme_background_color
|
||||||
|
|
||||||
|
if not os.path.isfile(css_filename):
|
||||||
|
return pwa_theme_color, pwa_theme_background_color
|
||||||
|
|
||||||
|
css_str = ''
|
||||||
|
with open(css_filename, 'r') as fp_css:
|
||||||
|
css_str = fp_css.read()
|
||||||
|
|
||||||
|
pwa_theme_color = \
|
||||||
|
_get_variable_from_css(css_str, 'pwa-theme-color')
|
||||||
|
if not pwa_theme_color:
|
||||||
|
pwa_theme_color = default_pwa_theme_color
|
||||||
|
|
||||||
|
pwa_theme_background_color = \
|
||||||
|
_get_variable_from_css(css_str, 'pwa-theme-background-color')
|
||||||
|
if not pwa_theme_background_color:
|
||||||
|
pwa_theme_background_color = default_pwa_theme_background_color
|
||||||
|
|
||||||
|
return pwa_theme_color, pwa_theme_background_color
|
||||||
|
|
||||||
|
|
||||||
def html_header_with_external_style(css_filename: str, instance_title: str,
|
def html_header_with_external_style(css_filename: str, instance_title: str,
|
||||||
metadata: str, lang='en') -> str:
|
metadata: str, lang='en') -> str:
|
||||||
if metadata is None:
|
if metadata is None:
|
||||||
metadata = ''
|
metadata = ''
|
||||||
css_file = '/' + css_filename.split('/')[-1]
|
css_file = '/' + css_filename.split('/')[-1]
|
||||||
|
pwa_theme_color, pwa_theme_background_color = \
|
||||||
|
get_pwa_theme_colors(css_filename)
|
||||||
html_str = \
|
html_str = \
|
||||||
'<!DOCTYPE html>\n' + \
|
'<!DOCTYPE html>\n' + \
|
||||||
'<html lang="' + lang + '">\n' + \
|
'<html lang="' + lang + '">\n' + \
|
||||||
|
|
@ -557,8 +602,10 @@ def html_header_with_external_style(css_filename: str, instance_title: str,
|
||||||
' <meta content="yes" name="apple-mobile-web-app-capable">\n' + \
|
' <meta content="yes" name="apple-mobile-web-app-capable">\n' + \
|
||||||
' <link href="/apple-touch-icon.png" rel="apple-touch-icon" ' + \
|
' <link href="/apple-touch-icon.png" rel="apple-touch-icon" ' + \
|
||||||
'sizes="180x180">\n' + \
|
'sizes="180x180">\n' + \
|
||||||
' <meta name="theme-color" content="grey">\n' + \
|
' <meta name="theme-color" content="' + pwa_theme_color + '">\n' + \
|
||||||
metadata + \
|
metadata + \
|
||||||
|
' <meta name="apple-mobile-web-app-status-bar-style" ' + \
|
||||||
|
'content="' + pwa_theme_background_color + '">\n' + \
|
||||||
' <title>' + instance_title + '</title>\n' + \
|
' <title>' + instance_title + '</title>\n' + \
|
||||||
' </head>\n' + \
|
' </head>\n' + \
|
||||||
' <body>\n'
|
' <body>\n'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue