epicyon/theme.py

1101 lines
37 KiB
Python
Raw Normal View History

2020-04-04 12:03:28 +00:00
__filename__ = "theme.py"
__author__ = "Bob Mottram"
__license__ = "AGPL3+"
__version__ = "1.1.0"
__maintainer__ = "Bob Mottram"
__email__ = "bob@freedombone.net"
__status__ = "Production"
2019-11-23 13:04:11 +00:00
import os
from utils import loadJson
from utils import saveJson
2020-05-28 21:30:40 +00:00
from shutil import copyfile
2019-11-23 13:04:11 +00:00
2020-04-04 12:03:28 +00:00
2020-07-11 09:30:07 +00:00
def getThemeFiles() -> []:
return ('epicyon.css', 'login.css', 'follow.css',
2020-07-25 22:12:59 +00:00
'suspended.css', 'calendar.css', 'blog.css',
2020-10-01 19:51:10 +00:00
'options.css', 'search.css', 'links.css')
2020-07-11 09:30:07 +00:00
2020-05-28 09:11:21 +00:00
def getThemesList() -> []:
"""Returns the list of available themes
Note that these should be capitalized, since they're
also used to create the web interface dropdown list
and to lookup function names
"""
2020-06-12 19:44:23 +00:00
return ('Default', 'Blue', 'Hacker', 'Henge', 'HighVis',
2020-10-22 16:18:56 +00:00
'IndymediaClassic',
'LCD', 'Light', 'Night', 'Purple', 'Solidaric',
'Starlight', 'Zen')
2020-05-28 09:11:21 +00:00
2020-04-04 12:03:28 +00:00
def setThemeInConfig(baseDir: str, name: str) -> bool:
configFilename = baseDir + '/config.json'
2019-11-23 13:04:11 +00:00
if not os.path.isfile(configFilename):
return False
2020-04-04 12:03:28 +00:00
configJson = loadJson(configFilename, 0)
2019-11-23 13:04:11 +00:00
if not configJson:
return False
2020-04-04 12:03:28 +00:00
configJson['theme'] = name
return saveJson(configJson, configFilename)
2019-11-23 13:04:11 +00:00
2020-05-26 20:17:16 +00:00
def getTheme(baseDir: str) -> str:
configFilename = baseDir + '/config.json'
2020-05-27 13:05:23 +00:00
if os.path.isfile(configFilename):
configJson = loadJson(configFilename, 0)
if configJson:
if configJson.get('theme'):
return configJson['theme']
2020-05-26 20:17:16 +00:00
return 'default'
2019-11-23 13:04:11 +00:00
def removeTheme(baseDir: str):
2020-07-11 09:30:07 +00:00
themeFiles = getThemeFiles()
2019-11-23 13:04:11 +00:00
for filename in themeFiles:
2020-04-04 12:03:28 +00:00
if os.path.isfile(baseDir + '/' + filename):
os.remove(baseDir + '/' + filename)
2019-11-23 13:04:11 +00:00
2020-04-04 12:03:28 +00:00
def setCSSparam(css: str, param: str, value: str) -> str:
2019-11-23 13:04:11 +00:00
"""Sets a CSS parameter to a given value
"""
# is this just a simple string replacement?
if ';' in param:
2020-04-04 12:03:28 +00:00
return css.replace(param, value)
2019-11-23 13:04:11 +00:00
# color replacement
if param.startswith('rgba('):
2020-04-04 12:03:28 +00:00
return css.replace(param, value)
2019-11-23 13:04:11 +00:00
# if the parameter begins with * then don't prepend --
2020-09-14 12:58:24 +00:00
onceOnly = False
2019-11-23 13:04:11 +00:00
if param.startswith('*'):
2020-09-14 12:52:22 +00:00
if param.startswith('**'):
2020-09-14 12:58:24 +00:00
onceOnly = True
searchStr = param.replace('**', '') + ':'
2020-09-14 12:52:22 +00:00
else:
searchStr = param.replace('*', '') + ':'
2019-11-23 13:04:11 +00:00
else:
2020-04-04 12:03:28 +00:00
searchStr = '--' + param + ':'
2019-11-23 13:04:11 +00:00
if searchStr not in css:
return css
2020-09-14 13:05:12 +00:00
if onceOnly:
s = css.split(searchStr, 1)
else:
s = css.split(searchStr)
2020-04-04 12:03:28 +00:00
newcss = ''
2019-11-23 13:04:11 +00:00
for sectionStr in s:
if not newcss:
if sectionStr:
2020-04-04 12:03:28 +00:00
newcss = sectionStr
2019-11-23 13:04:11 +00:00
else:
2020-04-04 12:03:28 +00:00
newcss = ' '
2019-11-23 13:04:11 +00:00
else:
if ';' in sectionStr:
2020-04-04 12:03:28 +00:00
newcss += \
searchStr + ' ' + value + ';' + sectionStr.split(';', 1)[1]
2019-11-23 13:04:11 +00:00
else:
2020-04-04 12:03:28 +00:00
newcss += searchStr + ' ' + sectionStr
2019-11-23 13:04:11 +00:00
return newcss.strip()
2020-03-22 21:16:02 +00:00
2020-04-04 12:03:28 +00:00
def setThemeFromDict(baseDir: str, name: str,
themeParams: {}, bgParams: {}) -> None:
2019-11-23 13:04:11 +00:00
"""Uses a dictionary to set a theme
"""
2020-07-10 18:08:45 +00:00
if name:
setThemeInConfig(baseDir, name)
2020-07-11 09:30:07 +00:00
themeFiles = getThemeFiles()
2019-11-23 13:04:11 +00:00
for filename in themeFiles:
2020-04-04 12:03:28 +00:00
templateFilename = baseDir + '/epicyon-' + filename
if filename == 'epicyon.css':
templateFilename = baseDir + '/epicyon-profile.css'
2019-11-23 13:04:11 +00:00
if not os.path.isfile(templateFilename):
continue
with open(templateFilename, 'r') as cssfile:
2020-04-04 12:03:28 +00:00
css = cssfile.read()
for paramName, paramValue in themeParams.items():
css = setCSSparam(css, paramName, paramValue)
filename = baseDir + '/' + filename
2020-07-12 20:04:58 +00:00
with open(filename, 'w+') as cssfile:
2019-11-23 13:04:11 +00:00
cssfile.write(css)
if bgParams.get('login'):
setBackgroundFormat(baseDir, name, 'login', bgParams['login'])
if bgParams.get('follow'):
setBackgroundFormat(baseDir, name, 'follow', bgParams['follow'])
if bgParams.get('options'):
setBackgroundFormat(baseDir, name, 'options', bgParams['options'])
if bgParams.get('search'):
setBackgroundFormat(baseDir, name, 'search', bgParams['search'])
2020-04-04 12:03:28 +00:00
def setBackgroundFormat(baseDir: str, name: str,
backgroundType: str, extension: str) -> None:
2020-07-25 16:25:04 +00:00
"""Sets the background file extension
"""
2020-07-25 19:07:06 +00:00
if extension == 'jpg':
2020-07-25 16:25:04 +00:00
return
cssFilename = baseDir + '/' + backgroundType + '.css'
if not os.path.isfile(cssFilename):
return
with open(cssFilename, 'r') as cssfile:
css = cssfile.read()
css = css.replace('background.jpg', 'background.' + extension)
with open(cssFilename, 'w+') as cssfile2:
cssfile2.write(css)
2020-07-25 16:25:04 +00:00
2020-07-11 09:22:06 +00:00
def enableGrayscale(baseDir: str) -> None:
"""Enables grayscale for the current theme
"""
2020-07-11 09:30:07 +00:00
themeFiles = getThemeFiles()
for filename in themeFiles:
templateFilename = baseDir + '/' + filename
if not os.path.isfile(templateFilename):
continue
with open(templateFilename, 'r') as cssfile:
css = cssfile.read()
2020-07-11 09:22:06 +00:00
if 'grayscale' not in css:
css = \
css.replace('body, html {',
'body, html {\n filter: grayscale(100%);')
filename = baseDir + '/' + filename
2020-07-12 20:04:58 +00:00
with open(filename, 'w+') as cssfile:
2020-07-11 09:22:06 +00:00
cssfile.write(css)
grayscaleFilename = baseDir + '/accounts/.grayscale'
if not os.path.isfile(grayscaleFilename):
2020-07-12 20:04:58 +00:00
with open(grayscaleFilename, 'w+') as grayfile:
2020-07-11 09:22:06 +00:00
grayfile.write(' ')
def disableGrayscale(baseDir: str) -> None:
"""Disables grayscale for the current theme
"""
2020-07-11 09:30:07 +00:00
themeFiles = getThemeFiles()
2020-07-11 09:22:06 +00:00
for filename in themeFiles:
templateFilename = baseDir + '/' + filename
if not os.path.isfile(templateFilename):
continue
with open(templateFilename, 'r') as cssfile:
css = cssfile.read()
if 'grayscale' in css:
css = \
css.replace('\n filter: grayscale(100%);', '')
filename = baseDir + '/' + filename
2020-07-12 20:04:58 +00:00
with open(filename, 'w+') as cssfile:
2020-07-11 09:22:06 +00:00
cssfile.write(css)
grayscaleFilename = baseDir + '/accounts/.grayscale'
if os.path.isfile(grayscaleFilename):
os.remove(grayscaleFilename)
2020-05-26 20:17:16 +00:00
def setCustomFont(baseDir: str):
"""Uses a dictionary to set a theme
"""
customFontExt = None
customFontType = None
fontExtension = {
'woff': 'woff',
'woff2': 'woff2',
'otf': 'opentype',
'ttf': 'truetype'
}
for ext, extType in fontExtension.items():
filename = baseDir + '/fonts/custom.' + ext
if os.path.isfile(filename):
customFontExt = ext
customFontType = extType
if not customFontExt:
return
2020-07-11 09:30:07 +00:00
themeFiles = getThemeFiles()
2020-05-26 20:17:16 +00:00
for filename in themeFiles:
templateFilename = baseDir + '/' + filename
2020-05-26 20:17:16 +00:00
if not os.path.isfile(templateFilename):
continue
with open(templateFilename, 'r') as cssfile:
css = cssfile.read()
css = \
setCSSparam(css, "*src",
"url('./fonts/custom." +
customFontExt +
"') format('" +
customFontType + "')")
css = setCSSparam(css, "*font-family", "'CustomFont'")
2020-05-26 20:17:16 +00:00
filename = baseDir + '/' + filename
2020-07-12 20:04:58 +00:00
with open(filename, 'w+') as cssfile:
2020-05-26 20:17:16 +00:00
cssfile.write(css)
2020-05-29 10:00:05 +00:00
def setThemeDefault(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'default'
2020-05-29 10:00:05 +00:00
removeTheme(baseDir)
2020-07-26 11:45:09 +00:00
setThemeInConfig(baseDir, name)
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
2020-08-31 11:51:31 +00:00
themeParams = {
2020-08-31 12:17:25 +00:00
"dummy": "1234"
2020-08-31 11:51:31 +00:00
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-05-29 10:00:05 +00:00
2020-10-22 16:18:56 +00:00
def setThemeIndymediaClassic(baseDir: str):
2020-10-22 16:39:32 +00:00
name = 'indymediaclassic'
2020-09-15 16:57:00 +00:00
removeTheme(baseDir)
setThemeInConfig(baseDir, name)
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
themeParams = {
2020-10-23 17:13:02 +00:00
"hashtag-background-color": "darkred",
2020-10-09 13:51:25 +00:00
"font-size-newswire": "18px",
"font-size-newswire-mobile": "48px",
2020-10-09 13:51:25 +00:00
"line-spacing-newswire": "100%",
2020-10-09 18:05:47 +00:00
"newswire-item-moderated-color": "white",
"newswire-date-moderated-color": "white",
2020-10-09 13:51:25 +00:00
"newswire-date-color": "white",
"newswire-voted-background-color": "black",
2020-10-12 20:00:39 +00:00
"column-left-image-width-mobile": "40vw",
2020-10-09 13:51:25 +00:00
"column-right-fg-color": "#ff9900",
"column-right-fg-color-voted-on": "red",
2020-09-15 18:07:33 +00:00
"button-corner-radius": "5px",
"timeline-border-radius": "5px",
2020-09-15 16:57:00 +00:00
"focus-color": "blue",
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-09-15 16:57:00 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
"main-bg-color": "black",
2020-10-02 09:47:25 +00:00
"column-left-header-color": "#fff",
"column-left-header-background": "#555",
2020-10-02 09:50:24 +00:00
"column-left-header-size": "20px",
2020-10-01 21:02:38 +00:00
"column-left-color": "#003366",
2020-09-15 16:57:00 +00:00
"text-entry-background": "#0f0d10",
2020-09-15 17:08:11 +00:00
"link-bg-color": "black",
2020-09-15 18:01:20 +00:00
"main-link-color": "#ff9900",
2020-09-15 17:08:11 +00:00
"main-link-color-hover": "#d09338",
"main-visited-color": "#ffb900",
2020-09-15 16:57:00 +00:00
"main-fg-color": "white",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "white",
2020-09-15 16:57:00 +00:00
"main-bg-color-dm": "#0b0a0a",
"border-color": "#003366",
2020-09-15 17:20:40 +00:00
"border-width": "0",
2020-09-15 16:57:00 +00:00
"main-bg-color-reply": "#0f0d10",
"main-bg-color-report": "#0f0d10",
"hashtag-vertical-spacing3": "100px",
"hashtag-vertical-spacing4": "150px",
2020-09-18 19:53:12 +00:00
"button-background-hover": "darkblue",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#ff9900",
"publish-button-text": "#003366",
2020-09-15 16:57:00 +00:00
"button-background": "#003366",
2020-09-16 08:39:11 +00:00
"button-selected": "blue",
2020-09-15 16:57:00 +00:00
"calendar-bg-color": "#0f0d10",
2020-09-15 18:21:55 +00:00
"event-background": "#555",
"border-color": "#003366",
2020-09-19 11:19:02 +00:00
"lines-color": "#ff9900",
"day-number": "lightblue",
"day-number2": "white",
2020-09-15 18:21:55 +00:00
"time-color": "#003366",
"place-color": "#003366",
"event-color": "#003366",
"title-text": "white",
2020-09-16 08:35:45 +00:00
"title-background": "#003366",
2020-09-16 10:25:07 +00:00
"quote-right-margin": "0.1em",
2020-10-03 19:15:09 +00:00
"column-left-width": "10vw",
"column-center-width": "70vw",
"column-right-width": "20vw",
2020-10-13 17:24:09 +00:00
"column-right-icon-size": "11%",
2020-10-13 17:25:47 +00:00
"login-button-color": "red",
2020-10-13 17:24:09 +00:00
"login-button-fg-color": "white"
2020-09-15 16:57:00 +00:00
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-05-29 10:00:05 +00:00
def setThemeBlue(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'blue'
2020-05-29 10:00:05 +00:00
removeTheme(baseDir)
2020-07-26 11:45:09 +00:00
setThemeInConfig(baseDir, name)
2020-05-29 10:00:05 +00:00
themeParams = {
2020-10-15 13:03:26 +00:00
"newswire-date-color": "blue",
2020-05-29 10:11:02 +00:00
"font-size-header": "22px",
"font-size-header-mobile": "32px",
2020-05-29 10:11:02 +00:00
"font-size": "45px",
"font-size2": "45px",
"font-size3": "45px",
"font-size4": "35px",
"font-size5": "29px",
"gallery-font-size": "35px",
"gallery-font-size-mobile": "55px",
2020-05-29 10:00:05 +00:00
"main-bg-color": "#002365",
2020-10-01 21:02:38 +00:00
"column-left-color": "#002365",
2020-05-29 10:00:05 +00:00
"text-entry-background": "#002365",
2020-05-29 10:08:56 +00:00
"link-bg-color": "#002365",
2020-05-29 10:00:05 +00:00
"main-bg-color-reply": "#002365",
"main-bg-color-report": "#002365",
"day-number2": "#002365",
2020-05-31 10:10:49 +00:00
"hashtag-vertical-spacing3": "100px",
"hashtag-vertical-spacing4": "150px",
"time-vertical-align": "-10px",
2020-05-29 10:00:05 +00:00
"*font-family": "'Domestic_Manners'",
2020-06-27 13:19:55 +00:00
"*src": "url('./fonts/Domestic_Manners.woff2') format('woff2')"
2020-05-29 10:00:05 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-05-29 10:00:05 +00:00
2020-06-05 20:27:44 +00:00
def setThemeNight(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'night'
2020-06-05 20:27:44 +00:00
removeTheme(baseDir)
2020-07-26 11:45:09 +00:00
setThemeInConfig(baseDir, name)
2020-06-05 20:38:55 +00:00
fontStr = \
2020-07-29 21:45:56 +00:00
"url('./fonts/solidaric.woff2') format('woff2')"
2020-09-14 12:52:22 +00:00
fontStrItalic = \
"url('./fonts/solidaric-italic.woff2') format('woff2')"
2020-06-05 20:27:44 +00:00
themeParams = {
2020-08-14 20:00:09 +00:00
"focus-color": "blue",
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-06-08 09:54:17 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
2020-06-05 20:27:44 +00:00
"main-bg-color": "#0f0d10",
2020-10-01 21:02:38 +00:00
"column-left-color": "#0f0d10",
2020-06-05 20:27:44 +00:00
"text-entry-background": "#0f0d10",
2020-09-15 17:08:11 +00:00
"link-bg-color": "#0f0d10",
2020-09-15 16:57:00 +00:00
"main-link-color": "ff9900",
2020-09-15 16:58:16 +00:00
"main-link-color-hover": "#d09338",
2020-10-14 19:11:43 +00:00
"main-fg-color": "#0481f5",
"column-left-fg-color": "#0481f5",
2020-06-05 21:41:11 +00:00
"main-bg-color-dm": "#0b0a0a",
2020-09-14 13:51:00 +00:00
"border-color": "#606984",
2020-06-05 20:27:44 +00:00
"main-bg-color-reply": "#0f0d10",
"main-bg-color-report": "#0f0d10",
"hashtag-vertical-spacing3": "100px",
"hashtag-vertical-spacing4": "150px",
2020-10-14 19:11:43 +00:00
"button-background-hover": "#0481f5",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#07447c",
2020-10-14 19:11:43 +00:00
"button-background": "#07447c",
"button-selected": "#0481f5",
2020-06-06 11:25:11 +00:00
"calendar-bg-color": "#0f0d10",
2020-09-14 13:38:30 +00:00
"lines-color": "#a961ab",
"day-number": "#a961ab",
2020-06-06 11:25:11 +00:00
"day-number2": "#555",
2020-09-14 13:38:30 +00:00
"time-color": "#a961ab",
"place-color": "#a961ab",
"event-color": "#a961ab",
2020-06-20 13:20:37 +00:00
"event-background": "#333",
2020-09-14 13:16:55 +00:00
"quote-right-margin": "0",
2020-09-15 09:30:38 +00:00
"line-spacing": "150%",
2020-07-30 16:47:05 +00:00
"*font-family": "'solidaric'",
2020-09-14 12:52:22 +00:00
"*src": fontStr,
"**src": fontStrItalic
2020-06-05 20:27:44 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-06-05 20:27:44 +00:00
2020-06-07 19:36:17 +00:00
def setThemeStarlight(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'starlight'
2020-06-07 19:36:17 +00:00
removeTheme(baseDir)
2020-07-26 11:45:09 +00:00
setThemeInConfig(baseDir, name)
2020-06-07 19:36:17 +00:00
themeParams = {
"column-left-image-width-mobile": "40vw",
2020-10-14 14:24:35 +00:00
"line-spacing-newswire": "120%",
2020-08-16 14:22:48 +00:00
"focus-color": "darkred",
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-06-08 09:44:19 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
2020-06-07 19:36:17 +00:00
"main-bg-color": "#0f0d10",
2020-10-01 21:02:38 +00:00
"column-left-color": "#0f0d10",
2020-06-07 19:36:17 +00:00
"text-entry-background": "#0f0d10",
"link-bg-color": "#0f0d10",
2020-06-07 22:31:48 +00:00
"main-link-color": "#ffc4bc",
2020-09-04 10:23:50 +00:00
"main-link-color-hover": "white",
2020-07-28 12:20:43 +00:00
"title-color": "#ffc4bc",
2020-06-07 22:31:48 +00:00
"main-visited-color": "#e1c4bc",
2020-06-07 19:36:17 +00:00
"main-fg-color": "#ffc4bc",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "#ffc4bc",
2020-06-07 19:36:17 +00:00
"main-bg-color-dm": "#0b0a0a",
2020-06-08 09:44:19 +00:00
"border-color": "#69282c",
2020-06-08 09:36:50 +00:00
"border-width": "3px",
2020-06-07 19:36:17 +00:00
"main-bg-color-reply": "#0f0d10",
"main-bg-color-report": "#0f0d10",
"hashtag-vertical-spacing3": "100px",
"hashtag-vertical-spacing4": "150px",
2020-09-03 21:18:10 +00:00
"button-background-hover": "#a9282c",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#69282c",
2020-06-07 21:33:46 +00:00
"button-background": "#69282c",
2020-08-12 10:28:29 +00:00
"button-small-background": "darkblue",
2020-06-07 19:36:17 +00:00
"button-selected": "#a34046",
2020-06-20 13:04:03 +00:00
"button-highlighted": "#12435f",
"button-fg-highlighted": "white",
"button-selected-highlighted": "#12435f",
"button-approve": "#12435f",
2020-06-07 19:36:17 +00:00
"calendar-bg-color": "#0f0d10",
2020-06-09 14:21:33 +00:00
"title-text": "#ffc4bc",
"title-background": "#69282c",
2020-06-07 19:36:17 +00:00
"lines-color": "#ffc4bc",
"day-number": "#ffc4bc",
2020-06-09 14:21:33 +00:00
"day-number2": "#aaa",
2020-06-20 13:20:37 +00:00
"event-background": "#12435f",
2020-06-08 09:44:19 +00:00
"timeline-border-radius": "20px",
2020-06-20 12:32:30 +00:00
"time-color": "#ffc4bc",
"place-color": "#ffc4bc",
"event-color": "#ffc4bc",
2020-06-11 13:17:30 +00:00
"image-corners": "2%",
2020-09-16 10:25:07 +00:00
"quote-right-margin": "0.1em",
2020-06-07 21:26:31 +00:00
"*font-family": "'bgrove'",
2020-06-27 13:19:55 +00:00
"*src": "url('fonts/bgrove.woff2') format('woff2')"
2020-06-07 19:36:17 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-06-07 19:36:17 +00:00
2020-06-12 19:44:23 +00:00
def setThemeHenge(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'henge'
2020-06-12 19:44:23 +00:00
removeTheme(baseDir)
2020-07-26 11:45:09 +00:00
setThemeInConfig(baseDir, name)
2020-06-12 19:44:23 +00:00
themeParams = {
2020-10-15 09:50:48 +00:00
"column-left-image-width-mobile": "40vw",
"column-right-image-width-mobile": "40vw",
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-06-12 19:44:23 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
2020-06-12 20:35:59 +00:00
"main-bg-color": "#383335",
2020-10-01 21:02:38 +00:00
"column-left-color": "#383335",
2020-06-12 20:35:59 +00:00
"text-entry-background": "#383335",
"link-bg-color": "#383335",
"main-link-color": "white",
"main-link-color-hover": "#ddd",
2020-07-28 12:20:43 +00:00
"title-color": "white",
2020-06-12 19:44:23 +00:00
"main-visited-color": "#e1c4bc",
2020-06-12 20:35:59 +00:00
"main-fg-color": "white",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "white",
2020-06-12 21:49:38 +00:00
"main-bg-color-dm": "#343335",
2020-06-12 20:35:59 +00:00
"border-color": "#222",
"border-width": "5px",
"main-bg-color-reply": "#383335",
"main-bg-color-report": "#383335",
2020-06-12 19:44:23 +00:00
"hashtag-vertical-spacing3": "100px",
"hashtag-vertical-spacing4": "150px",
2020-09-03 21:18:10 +00:00
"button-background-hover": "#444",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#222",
2020-06-12 20:35:59 +00:00
"button-background": "#222",
"button-selected": "black",
2020-06-12 21:40:17 +00:00
"dropdown-fg-color": "#dddddd",
2020-06-12 21:47:05 +00:00
"dropdown-bg-color": "#444",
"dropdown-bg-color-hover": "#555",
2020-06-12 21:40:17 +00:00
"dropdown-fg-color-hover": "#dddddd",
2020-06-12 20:35:59 +00:00
"calendar-bg-color": "#383335",
2020-06-12 20:09:43 +00:00
"title-text": "#c5d2b9",
2020-06-12 21:47:05 +00:00
"title-background": "#444",
2020-06-12 20:09:43 +00:00
"lines-color": "#c5d2b9",
"day-number": "#c5d2b9",
"day-number2": "#ccc",
2020-06-20 13:20:37 +00:00
"event-background": "#333",
2020-06-12 19:44:23 +00:00
"timeline-border-radius": "20px",
"image-corners": "8%",
2020-09-16 10:25:07 +00:00
"quote-right-margin": "0.1em",
2020-06-12 19:44:23 +00:00
"*font-family": "'bgrove'",
2020-06-27 13:19:55 +00:00
"*src": "url('fonts/bgrove.woff2') format('woff2')"
2020-06-12 19:44:23 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-06-12 19:44:23 +00:00
2020-05-29 16:20:41 +00:00
def setThemeZen(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'zen'
2020-05-29 16:20:41 +00:00
removeTheme(baseDir)
2020-07-26 11:45:09 +00:00
setThemeInConfig(baseDir, name)
2020-05-29 16:20:41 +00:00
themeParams = {
"main-bg-color": "#5c4e41",
2020-10-01 21:02:38 +00:00
"column-left-color": "#5c4e41",
2020-05-29 16:20:41 +00:00
"text-entry-background": "#5c4e41",
"link-bg-color": "#5c4e41",
"main-bg-color-reply": "#5c4e41",
"main-bg-color-report": "#5c4e41",
2020-05-29 16:52:53 +00:00
"day-number2": "#5c4e41",
"border-color": "#463b35",
"border-width": "7px",
"main-link-color": "#dddddd",
"main-link-color-hover": "white",
2020-07-28 12:20:43 +00:00
"title-color": "#dddddd",
2020-05-29 17:53:51 +00:00
"main-visited-color": "#dddddd",
2020-09-03 21:18:10 +00:00
"button-background-hover": "#a63b35",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#463b35",
2020-05-29 17:53:51 +00:00
"button-background": "#463b35",
"button-selected": "#26201d",
"main-bg-color-dm": "#5c4a40",
"main-header-color-roles": "#5c4e41",
2020-06-12 21:40:17 +00:00
"dropdown-bg-color": "#504e41",
2020-05-30 12:03:33 +00:00
"dropdown-bg-color-hover": "#444"
2020-05-29 16:20:41 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-05-29 16:20:41 +00:00
2019-11-23 13:04:11 +00:00
def setThemeHighVis(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'highvis'
2020-04-04 12:03:28 +00:00
themeParams = {
2019-11-23 13:04:11 +00:00
"font-size-header": "22px",
"font-size-header-mobile": "32px",
2019-11-23 13:04:11 +00:00
"font-size": "45px",
"font-size2": "45px",
"font-size3": "45px",
"font-size4": "35px",
2019-11-28 11:02:59 +00:00
"font-size5": "29px",
"gallery-font-size": "35px",
2020-05-28 12:00:19 +00:00
"gallery-font-size-mobile": "55px",
2020-05-31 10:10:49 +00:00
"hashtag-vertical-spacing3": "100px",
"hashtag-vertical-spacing4": "150px",
"time-vertical-align": "-10px",
2020-05-28 12:05:20 +00:00
"*font-family": "'LinBiolinum_Rah'",
2020-06-27 13:19:55 +00:00
"*src": "url('./fonts/LinBiolinum_Rah.woff2') format('woff2')"
2019-11-23 13:04:11 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-04-04 12:03:28 +00:00
2019-11-23 13:04:11 +00:00
2020-05-28 12:25:56 +00:00
def setThemeLCD(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'lcd'
2020-05-28 12:25:56 +00:00
themeParams = {
2020-10-15 10:49:33 +00:00
"newswire-date-color": "#cfb42b",
"column-left-header-background": "#9fb42b",
"column-left-header-color": "#33390d",
2020-05-28 12:25:56 +00:00
"main-bg-color": "#9fb42b",
2020-10-15 10:36:45 +00:00
"column-left-color": "#33390d",
"column-left-fg-color": "#9fb42b",
2020-05-28 13:06:07 +00:00
"link-bg-color": "#33390d",
2020-05-28 14:39:26 +00:00
"text-entry-foreground": "#33390d",
"text-entry-background": "#9fb42b",
2020-05-28 13:27:25 +00:00
"main-bg-color-reply": "#9fb42b",
2020-05-28 20:04:37 +00:00
"main-bg-color-report": "#9fb42b",
2020-05-28 14:39:26 +00:00
"main-bg-color-dm": "#5fb42b",
2020-05-28 20:04:37 +00:00
"main-header-color-roles": "#9fb42b",
2020-05-28 12:25:56 +00:00
"main-fg-color": "#33390d",
"border-color": "#33390d",
2020-05-28 13:27:25 +00:00
"border-width": "5px",
2020-05-28 13:06:07 +00:00
"main-link-color": "#9fb42b",
"main-link-color-hover": "#cfb42b",
2020-07-28 12:20:43 +00:00
"title-color": "#9fb42b",
2020-05-28 13:06:07 +00:00
"main-visited-color": "#9fb42b",
2020-05-28 17:27:16 +00:00
"button-selected": "black",
"button-highlighted": "green",
2020-09-03 21:18:10 +00:00
"button-background-hover": "#a3390d",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#33390d",
2020-05-28 17:27:16 +00:00
"button-background": "#33390d",
2020-08-12 10:28:29 +00:00
"button-small-background": "#33390d",
2020-05-28 17:27:16 +00:00
"button-text": "#9fb42b",
2020-10-16 13:25:26 +00:00
"publish-button-text": "#9fb42b",
2020-08-12 10:28:29 +00:00
"button-small-text": "#9fb42b",
2020-05-28 12:25:56 +00:00
"color: #FFFFFE;": "color: #9fb42b;",
"calendar-bg-color": "#eee",
"day-number": "#3f2145",
"day-number2": "#9fb42b",
"today-foreground": "white",
"today-circle": "red",
"event-background": "yellow",
"event-foreground": "white",
"title-text": "white",
2020-05-28 21:30:40 +00:00
"gallery-text-color": "#33390d",
2020-05-28 12:25:56 +00:00
"font-size-header": "22px",
"font-size-header-mobile": "32px",
2020-05-28 12:25:56 +00:00
"font-size": "45px",
"font-size2": "45px",
"font-size3": "45px",
"font-size4": "35px",
"font-size5": "29px",
"gallery-font-size": "35px",
"gallery-font-size-mobile": "55px",
2020-05-28 13:06:07 +00:00
"button-corner-radius": "1px",
"timeline-border-radius": "1px",
2020-05-28 16:16:11 +00:00
"dropdown-bg-color": "#33390d",
2020-05-28 16:26:53 +00:00
"dropdown-bg-color-hover": "#7fb42b",
"dropdown-fg-color-hover": "black",
2020-05-28 16:16:11 +00:00
"dropdown-fg-color": "#9fb42b",
2020-05-28 20:04:37 +00:00
"font-color-header": "#9fb42b",
"lines-color": "#33390d",
"title-background": "#33390d",
2020-06-20 12:32:30 +00:00
"time-color": "#33390d",
"place-color": "#33390d",
"event-color": "#33390d",
2020-05-28 12:25:56 +00:00
"*font-family": "'LcdSolid'",
2020-06-27 13:19:55 +00:00
"*src": "url('./fonts/LcdSolid.woff2') format('woff2')"
2020-05-28 12:25:56 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-05-28 12:25:56 +00:00
2019-11-23 13:04:11 +00:00
def setThemePurple(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'purple'
2020-05-28 21:30:40 +00:00
fontStr = \
2020-06-27 13:19:55 +00:00
"url('./fonts/CheGuevaraTextSans-Regular.woff2') format('woff2')"
2020-04-04 12:03:28 +00:00
themeParams = {
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-06-08 09:54:17 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
2019-11-23 13:04:11 +00:00
"main-bg-color": "#1f152d",
2020-10-01 21:02:38 +00:00
"column-left-color": "#1f152d",
2020-05-28 13:06:07 +00:00
"link-bg-color": "#1f152d",
2019-11-23 13:04:11 +00:00
"main-bg-color-reply": "#1a142d",
"main-bg-color-report": "#12152d",
"main-header-color-roles": "#1f192d",
"main-fg-color": "#f98bb0",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "#f98bb0",
2019-11-23 13:04:11 +00:00
"border-color": "#3f2145",
"main-link-color": "#ff42a0",
"main-link-color-hover": "white",
2020-07-28 12:20:43 +00:00
"title-color": "white",
2019-11-23 13:04:11 +00:00
"main-visited-color": "#f93bb0",
"button-selected": "#c042a0",
2020-09-03 21:18:10 +00:00
"button-background-hover": "#af42a0",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#ff42a0",
2019-11-23 13:04:11 +00:00
"button-background": "#ff42a0",
2020-08-12 10:28:29 +00:00
"button-small-background": "#ff42a0",
2019-11-23 13:04:11 +00:00
"button-text": "white",
2020-10-16 13:25:26 +00:00
"publish-button-text": "white",
2020-08-12 10:28:29 +00:00
"button-small-text": "white",
2019-11-23 13:04:11 +00:00
"color: #FFFFFE;": "color: #1f152d;",
"calendar-bg-color": "#eee",
"lines-color": "#ff42a0",
"day-number": "#3f2145",
"day-number2": "#1f152d",
"today-foreground": "white",
"today-circle": "red",
"event-background": "yellow",
"event-foreground": "white",
"title-text": "white",
2019-11-28 11:02:59 +00:00
"title-background": "#ff42a0",
2020-05-28 10:14:57 +00:00
"gallery-text-color": "#ccc",
2020-06-20 12:32:30 +00:00
"time-color": "#f98bb0",
"place-color": "#f98bb0",
"event-color": "#f98bb0",
2020-05-28 10:14:57 +00:00
"*font-family": "'CheGuevaraTextSans-Regular'",
2020-05-28 21:30:40 +00:00
"*src": fontStr
2019-11-23 13:04:11 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-04-04 12:03:28 +00:00
2019-11-23 13:04:11 +00:00
def setThemeHacker(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'hacker'
2020-04-04 12:03:28 +00:00
themeParams = {
2020-08-14 20:00:09 +00:00
"focus-color": "green",
2019-11-23 13:04:11 +00:00
"main-bg-color": "black",
2020-10-01 21:02:38 +00:00
"column-left-color": "black",
2020-05-28 13:06:07 +00:00
"link-bg-color": "black",
2020-05-29 21:34:25 +00:00
"main-bg-color-dm": "#0b0a0a",
2019-11-23 13:04:11 +00:00
"main-bg-color-reply": "#030202",
"main-bg-color-report": "#050202",
"main-header-color-roles": "#1f192d",
2020-05-25 18:27:45 +00:00
"main-fg-color": "#00ff00",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "#00ff00",
2020-05-25 17:38:09 +00:00
"border-color": "#035103",
2020-05-25 18:27:45 +00:00
"main-link-color": "#2fff2f",
"main-link-color-hover": "#afff2f",
2020-07-28 12:20:43 +00:00
"title-color": "#2fff2f",
2019-11-23 13:04:11 +00:00
"main-visited-color": "#3c8234",
"button-selected": "#063200",
2020-09-03 21:18:10 +00:00
"button-background-hover": "#a62200",
2020-10-16 13:25:26 +00:00
"publish-button-background": "#062200",
2019-11-23 13:04:11 +00:00
"button-background": "#062200",
2020-08-12 10:28:29 +00:00
"button-small-background": "#062200",
2020-05-25 18:27:45 +00:00
"button-text": "#00ff00",
2020-10-16 13:25:26 +00:00
"publish-button-text": "#00ff00",
2020-08-12 10:28:29 +00:00
"button-small-text": "#00ff00",
2019-11-23 13:04:11 +00:00
"button-corner-radius": "4px",
"timeline-border-radius": "4px",
2020-05-25 11:33:37 +00:00
"*font-family": "'Bedstead'",
2020-05-25 19:49:02 +00:00
"*src": "url('./fonts/bedstead.otf') format('opentype')",
2019-11-23 13:04:11 +00:00
"color: #FFFFFE;": "color: green;",
"calendar-bg-color": "black",
"lines-color": "green",
"day-number": "green",
"day-number2": "darkgreen",
"today-foreground": "white",
"today-circle": "red",
"event-background": "lightgreen",
"event-foreground": "black",
"title-text": "black",
2019-11-28 11:02:59 +00:00
"title-background": "darkgreen",
2020-06-11 13:12:59 +00:00
"gallery-text-color": "green",
2020-06-20 12:32:30 +00:00
"time-color": "#00ff00",
"place-color": "#00ff00",
"event-color": "#00ff00",
2020-06-11 13:12:59 +00:00
"image-corners": "0%"
2019-11-23 13:04:11 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-04-04 12:03:28 +00:00
2019-11-23 13:04:11 +00:00
def setThemeLight(baseDir: str):
2020-07-26 11:45:09 +00:00
name = 'light'
2020-04-04 12:03:28 +00:00
themeParams = {
2020-10-23 17:13:02 +00:00
"hashtag-background-color": "lightblue",
2020-08-14 20:00:09 +00:00
"focus-color": "grey",
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-06-10 19:02:35 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
2019-11-23 13:04:11 +00:00
"rgba(0, 0, 0, 0.5)": "rgba(0, 0, 0, 0.0)",
2020-10-01 21:02:38 +00:00
"column-left-color": "#e6ebf0",
2019-11-23 13:04:11 +00:00
"main-bg-color": "#e6ebf0",
2020-05-29 21:15:11 +00:00
"main-bg-color-dm": "#e3dbf0",
2020-05-28 13:06:07 +00:00
"link-bg-color": "#e6ebf0",
2019-11-23 13:04:11 +00:00
"main-bg-color-reply": "#e0dbf0",
"main-bg-color-report": "#e3dbf0",
"main-header-color-roles": "#ebebf0",
"main-fg-color": "#2d2c37",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "#2d2c37",
2019-11-23 13:04:11 +00:00
"border-color": "#c0cdd9",
"main-link-color": "#2a2c37",
"main-link-color-hover": "#aa2c37",
2020-07-28 12:20:43 +00:00
"title-color": "#2a2c37",
2019-11-23 13:04:11 +00:00
"main-visited-color": "#232c37",
"text-entry-foreground": "#111",
"text-entry-background": "white",
"font-color-header": "black",
2020-05-29 21:08:24 +00:00
"dropdown-fg-color": "#222",
"dropdown-fg-color-hover": "#222",
2019-11-23 13:04:11 +00:00
"dropdown-bg-color": "white",
"dropdown-bg-color-hover": "lightgrey",
"color: #FFFFFE;": "color: black;",
"calendar-bg-color": "#e6ebf0",
"lines-color": "darkblue",
"day-number": "black",
"day-number2": "#282c37",
"place-color": "black",
"event-color": "#282c37",
"today-foreground": "white",
"today-circle": "red",
"event-background": "lightblue",
"event-foreground": "white",
"title-text": "#282c37",
2019-11-28 11:02:59 +00:00
"title-background": "#ccc",
2020-05-28 10:33:22 +00:00
"gallery-text-color": "black",
"*font-family": "'ElectrumADFExp-Regular'",
"*src": "url('./fonts/ElectrumADFExp-Regular.otf') format('opentype')"
2019-11-23 13:04:11 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-04-04 12:03:28 +00:00
2020-03-22 21:16:02 +00:00
2020-07-30 16:47:05 +00:00
def setThemeSolidaric(baseDir: str):
name = 'solidaric'
themeParams = {
2020-10-23 17:13:02 +00:00
"hashtag-background-color": "lightred",
2020-10-15 14:42:49 +00:00
"button-highlighted": "darkred",
"button-selected-highlighted": "darkred",
2020-10-15 14:08:42 +00:00
"newswire-date-color": "grey",
2020-08-14 20:00:09 +00:00
"focus-color": "grey",
2020-10-19 11:50:16 +00:00
"font-size-button-mobile": "26px",
2020-07-30 16:47:05 +00:00
"font-size": "32px",
"font-size2": "26px",
"font-size3": "40px",
"font-size4": "24px",
"font-size5": "22px",
"rgba(0, 0, 0, 0.5)": "rgba(0, 0, 0, 0.0)",
"main-bg-color": "white",
2020-10-01 21:02:38 +00:00
"column-left-color": "white",
2020-07-30 17:07:11 +00:00
"main-bg-color-dm": "white",
2020-07-30 17:33:48 +00:00
"link-bg-color": "white",
2020-07-30 17:07:11 +00:00
"main-bg-color-reply": "white",
"main-bg-color-report": "white",
2020-07-30 16:47:05 +00:00
"main-header-color-roles": "#ebebf0",
"main-fg-color": "#2d2c37",
2020-10-01 21:14:44 +00:00
"column-left-fg-color": "#2d2c37",
2020-07-30 16:47:05 +00:00
"border-color": "#c0cdd9",
"main-link-color": "#2a2c37",
"main-link-color-hover": "#aa2c37",
2020-07-30 16:47:05 +00:00
"title-color": "#2a2c37",
"main-visited-color": "#232c37",
"text-entry-foreground": "#111",
"text-entry-background": "white",
"font-color-header": "black",
"dropdown-fg-color": "#222",
"dropdown-fg-color-hover": "#222",
"dropdown-bg-color": "white",
"dropdown-bg-color-hover": "lightgrey",
"color: #FFFFFE;": "color: black;",
2020-07-30 17:41:50 +00:00
"calendar-bg-color": "white",
"lines-color": "black",
2020-07-30 16:47:05 +00:00
"day-number": "black",
"day-number2": "#282c37",
"place-color": "black",
"event-color": "#282c37",
"today-foreground": "white",
"today-circle": "red",
"event-background": "lightblue",
"event-foreground": "white",
"title-text": "#282c37",
"title-background": "#ccc",
"gallery-text-color": "black",
2020-09-14 13:14:09 +00:00
"quote-right-margin": "0",
2020-09-15 09:30:38 +00:00
"line-spacing": "150%",
2020-07-30 16:47:05 +00:00
"*font-family": "'solidaric'",
2020-09-14 12:52:22 +00:00
"*src": "url('./fonts/solidaric.woff2') format('woff2')",
"**src": "url('./fonts/solidaric-italic.woff2') format('woff2')"
2020-07-30 16:47:05 +00:00
}
bgParams = {
"login": "jpg",
"follow": "jpg",
"options": "jpg",
"search": "jpg"
}
setThemeFromDict(baseDir, name, themeParams, bgParams)
2020-05-28 21:39:41 +00:00
def setThemeImages(baseDir: str, name: str) -> None:
"""Changes the profile background image
and banner to the defaults
"""
themeNameLower = name.lower()
if themeNameLower == 'default':
profileImageFilename = \
baseDir + '/img/image.png'
bannerFilename = \
baseDir + '/img/banner.png'
2020-06-10 15:09:14 +00:00
searchBannerFilename = \
baseDir + '/img/search_banner.png'
leftColImageFilename = \
baseDir + '/img/left_col_image.png'
rightColImageFilename = \
baseDir + '/img/right_col_image.png'
2020-05-28 21:39:41 +00:00
else:
profileImageFilename = \
baseDir + '/img/image_' + themeNameLower + '.png'
bannerFilename = \
baseDir + '/img/banner_' + themeNameLower + '.png'
2020-06-10 15:09:14 +00:00
searchBannerFilename = \
baseDir + '/img/search_banner_' + themeNameLower + '.png'
leftColImageFilename = \
baseDir + '/img/left_col_image_' + themeNameLower + '.png'
rightColImageFilename = \
baseDir + '/img/right_col_image_' + themeNameLower + '.png'
2020-06-10 15:09:14 +00:00
2020-07-25 14:03:09 +00:00
backgroundNames = ('login', 'shares', 'delete', 'follow',
'options', 'block', 'search', 'calendar')
extensions = ('webp', 'gif', 'jpg', 'png', 'avif')
2020-07-25 14:03:09 +00:00
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
2020-07-25 09:55:11 +00:00
for acct in dirs:
if '@' not in acct:
continue
if 'inbox@' in acct:
continue
accountDir = \
os.path.join(baseDir + '/accounts', acct)
2020-07-25 10:13:24 +00:00
for backgroundType in backgroundNames:
for ext in extensions:
if themeNameLower == 'default':
backgroundImageFilename = \
baseDir + '/img/' + backgroundType + \
'-background.' + ext
else:
backgroundImageFilename = \
baseDir + '/img/' + backgroundType + \
2020-07-25 17:07:22 +00:00
'_background_' + themeNameLower + '.' + ext
if os.path.isfile(backgroundImageFilename):
try:
copyfile(backgroundImageFilename,
baseDir + '/accounts/' + backgroundType +
'-background.' + ext)
2020-07-25 17:56:06 +00:00
continue
except BaseException:
pass
# background image was not found
# so remove any existing file
if os.path.isfile(baseDir + '/accounts/' +
backgroundType +
'-background.' + ext):
try:
os.remove(baseDir + '/accounts/' +
backgroundType +
'-background.' + ext)
except BaseException:
pass
2020-07-25 10:03:03 +00:00
2020-07-25 09:55:11 +00:00
if os.path.isfile(profileImageFilename) and \
os.path.isfile(bannerFilename):
2020-05-28 21:39:41 +00:00
try:
copyfile(profileImageFilename,
accountDir + '/image.png')
2020-06-10 15:09:14 +00:00
except BaseException:
pass
try:
2020-05-28 21:39:41 +00:00
copyfile(bannerFilename,
accountDir + '/banner.png')
except BaseException:
pass
2020-06-10 15:09:14 +00:00
try:
if os.path.isfile(searchBannerFilename):
copyfile(searchBannerFilename,
accountDir + '/search_banner.png')
except BaseException:
pass
try:
if os.path.isfile(leftColImageFilename):
copyfile(leftColImageFilename,
accountDir + '/left_col_image.png')
else:
if os.path.isfile(accountDir +
'/left_col_image.png'):
os.remove(accountDir + '/left_col_image.png')
except BaseException:
pass
try:
if os.path.isfile(rightColImageFilename):
copyfile(rightColImageFilename,
accountDir + '/right_col_image.png')
else:
if os.path.isfile(accountDir +
'/right_col_image.png'):
os.remove(accountDir + '/right_col_image.png')
except BaseException:
pass
2020-05-28 21:39:41 +00:00
2020-10-13 21:38:19 +00:00
def setNewsAvatar(baseDir: str, name: str,
httpPrefix: str,
domain: str, domainFull: str) -> None:
"""Sets the avatar for the news account
"""
nickname = 'news'
2020-10-15 18:21:05 +00:00
newFilename = baseDir + '/img/icons/' + name + '/avatar_news.png'
if not os.path.isfile(newFilename):
2020-10-15 18:15:51 +00:00
newFilename = baseDir + '/img/icons/avatar_news.png'
2020-10-13 21:38:19 +00:00
if not os.path.isfile(newFilename):
return
2020-10-13 21:45:53 +00:00
avatarFilename = \
httpPrefix + '://' + domainFull + '/users/' + nickname + '.png'
avatarFilename = avatarFilename.replace('/', '-')
2020-10-13 21:51:06 +00:00
filename = baseDir + '/cache/avatars/' + avatarFilename
2020-10-13 21:45:53 +00:00
2020-10-13 21:38:19 +00:00
if os.path.isfile(filename):
os.remove(filename)
2020-10-13 21:55:52 +00:00
if os.path.isdir(baseDir + '/cache/avatars'):
2020-10-13 21:38:19 +00:00
copyfile(newFilename, filename)
copyfile(newFilename,
baseDir + '/accounts/' +
nickname + '@' + domain + '/avatar.png')
2020-10-09 19:28:09 +00:00
def setTheme(baseDir: str, name: str, domain: str) -> bool:
2020-05-26 20:17:16 +00:00
result = False
2020-05-28 09:11:21 +00:00
2020-05-28 21:30:40 +00:00
prevThemeName = getTheme(baseDir)
2020-05-28 09:11:21 +00:00
themes = getThemesList()
for themeName in themes:
2020-05-28 21:30:40 +00:00
themeNameLower = themeName.lower()
if name == themeNameLower:
2020-05-28 09:26:30 +00:00
globals()['setTheme' + themeName](baseDir)
2020-05-28 21:30:40 +00:00
if prevThemeName:
if prevThemeName.lower() != themeNameLower:
# change the banner and profile image
# to the default for the theme
2020-05-28 21:39:41 +00:00
setThemeImages(baseDir, name)
2020-05-28 09:11:21 +00:00
result = True
if not result:
2020-05-27 11:02:51 +00:00
# default
setThemeDefault(baseDir)
result = True
2020-05-28 09:11:21 +00:00
2020-05-26 20:17:16 +00:00
setCustomFont(baseDir)
2020-10-09 19:28:09 +00:00
# set the news avatar
newsAvatarThemeFilename = \
baseDir + '/img/icons/' + name + '/avatar_news.png'
if os.path.isfile(newsAvatarThemeFilename):
newsAvatarFilename = \
baseDir + '/accounts/news@' + domain + '/avatar.png'
copyfile(newsAvatarThemeFilename, newsAvatarFilename)
2020-07-10 18:08:45 +00:00
grayscaleFilename = baseDir + '/accounts/.grayscale'
if os.path.isfile(grayscaleFilename):
enableGrayscale(baseDir)
else:
disableGrayscale(baseDir)
2020-05-26 20:17:16 +00:00
return result