Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2022-02-27 12:47:30 +00:00
commit 3d5597fbcc
19 changed files with 70 additions and 34 deletions

View File

@ -167,6 +167,7 @@ from webapp_utils import html_hashtag_blocked
from webapp_utils import html_following_list
from webapp_utils import set_blog_address
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
from webapp_about import html_about
@ -6878,24 +6879,10 @@ class PubServer(BaseHTTPRequestHandler):
getreq_start_time) -> None:
"""gets the PWA manifest
"""
pwa_theme_color = 'grey'
pwa_theme_background_color = 'black'
css_filename = base_dir + '/epicyon.css'
if os.path.isfile(css_filename):
css_str = ''
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()
pwa_theme_color, pwa_theme_background_color = \
get_pwa_theme_colors(css_filename)
app1 = "https://f-droid.org/en/packages/eu.siacs.conversations"
app2 = "https://staging.f-droid.org/en/packages/im.vector.app"
app3 = \

View File

@ -1,7 +1,7 @@
@charset "UTF-8";
:root {
--pwa-theme-color: apple-mobile-statusbar-color;
--pwa-theme-color: apple-mobile-web-app-status-bar-style;
--pwa-theme-background-color: black-translucent;
--avatar-rounding: 10%;
--timeline-icon-width: 50px;

View File

@ -16,6 +16,7 @@ from utils import copytree
from utils import acct_dir
from utils import dangerous_svg
from utils import local_actor_url
from utils import remove_html
from shutil import copyfile
from shutil import make_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:
"""Sets a CSS parameter to a given value
"""
value = remove_html(value)
# is this just a simple string replacement?
if ';' in param:
return css.replace(param, value)

View File

@ -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",
"newswire-publish-icon": "True",
"full-width-timeline-buttons": "False",

View File

@ -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",
"dropdown-fg-color": "#222",
"dropdown-bg-color": "white",

View File

@ -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",
"dropdown-fg-color": "#9ad791",
"dropdown-bg-color": "#222",

View File

@ -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",
"dropdown-fg-color": "white",
"dropdown-bg-color": "#483335",

View File

@ -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",
"dropdown-fg-color": "white",
"dropdown-bg-color": "#222",

View File

@ -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",
"dropdown-fg-color": "black",
"dropdown-bg-color": "#dedede",

View File

@ -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",
"dropdown-fg-color": "#33390d",
"dropdown-bg-color": "#9fb42b",

View File

@ -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",
"dropdown-fg-color": "#2d2c37",
"dropdown-bg-color": "#d6dbf0",

View File

@ -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",
"dropdown-fg-color": "#0481f5",
"dropdown-bg-color": "#0d0d10",

View File

@ -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",
"dropdown-fg-color": "black",
"dropdown-bg-color": "#aba0d4",

View File

@ -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",
"dropdown-fg-color": "#f98bb0",
"dropdown-bg-color": "#2f152d",

View File

@ -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",
"dropdown-fg-color": "white",
"dropdown-bg-color": "#002a3a",

View File

@ -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",
"dropdown-fg-color": "#2d2c37",
"dropdown-bg-color": "#ddd",

View File

@ -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",
"dropdown-fg-color": "#ffc4bc",
"dropdown-bg-color": "#1f0d10",

View File

@ -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",
"dropdown-fg-color": "#d5c7b7",
"dropdown-bg-color": "#4c4e41",

View File

@ -538,11 +538,56 @@ def get_right_image_file(base_dir: str,
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,
metadata: str, lang='en') -> str:
if metadata is None:
metadata = ''
css_file = '/' + css_filename.split('/')[-1]
pwa_theme_color, pwa_theme_background_color = \
get_pwa_theme_colors(css_filename)
html_str = \
'<!DOCTYPE html>\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' + \
' <link href="/apple-touch-icon.png" rel="apple-touch-icon" ' + \
'sizes="180x180">\n' + \
' <meta name="theme-color" content="grey">\n' + \
' <meta name="theme-color" content="' + pwa_theme_color + '">\n' + \
metadata + \
' <meta name="apple-mobile-web-app-status-bar-style" ' + \
'content="' + pwa_theme_background_color + '">\n' + \
' <title>' + instance_title + '</title>\n' + \
' </head>\n' + \
' <body>\n'