Add multiple/themed CSS

alt-html-css
Admin 2020-12-12 19:20:23 +00:00
parent c625043ebb
commit ccfcbe4ad4
2 changed files with 37 additions and 8 deletions

25
blog.py
View File

@ -10,11 +10,13 @@ import os
from datetime import datetime from datetime import datetime
from content import replaceEmojiFromTags from content import replaceEmojiFromTags
from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import getIconsWebPath
from webapp_utils import htmlHeaderWithExternalStyle, htmlHeaderWithExternalStyles
from webapp_utils import htmlFooter from webapp_utils import htmlFooter
from webapp_utils import getPostAttachmentsAsHtml from webapp_utils import getPostAttachmentsAsHtml
from webapp_media import addEmbeddedElements from webapp_media import addEmbeddedElements
from utils import getFullDomain from utils import getFullDomain
from utils import getConfigParam
from utils import getMediaFormats from utils import getMediaFormats
from utils import getNicknameFromActor from utils import getNicknameFromActor
from utils import getDomainFromActor from utils import getDomainFromActor
@ -383,10 +385,25 @@ def htmlBlogPost(authorized: bool,
""" """
blogStr = '' blogStr = ''
cssFilename = baseDir + '/epicyon-blog.css' cssFiles = []
# the css filename
cssFiles.append(baseDir + '/epicyon-blog.css')
if os.path.isfile(baseDir + '/blog.css'): if os.path.isfile(baseDir + '/blog.css'):
cssFilename = baseDir + '/blog.css' cssFiles[0] = baseDir + '/blog.css'
blogStr = htmlHeaderWithExternalStyle(cssFilename)
# TODO: Clean up and remove this override
cssFiles[0] = 'base.css'
# Get theme-specific css if exists - must be named '<theme-name>.css'
themeName = getConfigParam(baseDir, 'theme')
themePath = f'{baseDir}/theme/{themeName}.css'
if os.path.isfile(themePath):
cssFiles.append('theme/' + themeName + '.css')
blogStr = htmlHeaderWithExternalStyles(cssFiles)
_htmlBlogRemoveCwButton(blogStr, translate) _htmlBlogRemoveCwButton(blogStr, translate)
blogStr += _htmlBlogPostContent(authorized, baseDir, blogStr += _htmlBlogPostContent(authorized, baseDir,

View File

@ -11,7 +11,7 @@ import time
from shutil import copyfile from shutil import copyfile
from utils import getConfigParam from utils import getConfigParam
from utils import noOfAccounts from utils import noOfAccounts
from webapp_utils import htmlHeaderWithExternalStyle from webapp_utils import htmlHeaderWithExternalStyles
from webapp_utils import htmlFooter from webapp_utils import htmlFooter
@ -95,9 +95,21 @@ def htmlLogin(cssCache: {}, translate: {},
with open(baseDir + '/accounts/login.txt', 'r') as file: with open(baseDir + '/accounts/login.txt', 'r') as file:
loginText = '<p class="login-text">' + file.read() + '</p>' loginText = '<p class="login-text">' + file.read() + '</p>'
cssFilename = baseDir + '/epicyon-login.css' cssFiles = []
cssFiles.append(baseDir + '/epicyon-login.css')
if os.path.isfile(baseDir + '/login.css'): if os.path.isfile(baseDir + '/login.css'):
cssFilename = baseDir + '/login.css' cssFiles[0] = baseDir + '/login.css'
# TODO: Clean up and remove this override
cssFiles[0] = 'base.css'
# Get theme-specific css if exists - must be named '<theme-name>.css'
themeName = getConfigParam(baseDir, 'theme')
themePath = f'{baseDir}/theme/{themeName}.css'
if os.path.isfile(themePath):
cssFiles.append('theme/' + themeName + '.css')
# show the register button # show the register button
registerButtonStr = '' registerButtonStr = ''
@ -129,7 +141,7 @@ def htmlLogin(cssCache: {}, translate: {},
if not autocomplete: if not autocomplete:
autocompleteStr = 'autocomplete="off" value=""' autocompleteStr = 'autocomplete="off" value=""'
loginForm = htmlHeaderWithExternalStyle(cssFilename) loginForm = htmlHeaderWithExternalStyles(cssFiles)
loginForm += '<br>\n' loginForm += '<br>\n'
loginForm += '<form method="POST" action="/login">\n' loginForm += '<form method="POST" action="/login">\n'
loginForm += ' <div class="imgcontainer">\n' loginForm += ' <div class="imgcontainer">\n'