mirror of https://gitlab.com/bashrc2/epicyon
Function to set custom backgrounds
parent
15e2f28bb2
commit
105fe03426
|
@ -10,7 +10,6 @@ __module_group__ = "Calendar"
|
|||
import os
|
||||
from datetime import datetime
|
||||
from datetime import date
|
||||
from shutil import copyfile
|
||||
from utils import getDisplayName
|
||||
from utils import getConfigParam
|
||||
from utils import getNicknameFromActor
|
||||
|
@ -25,6 +24,7 @@ from utils import localActorUrl
|
|||
from utils import replaceUsersWithAt
|
||||
from happening import getTodaysEvents
|
||||
from happening import getCalendarEvents
|
||||
from webapp_utils import setCustomBackground
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
from webapp_utils import htmlFooter
|
||||
from webapp_utils import htmlHideFromScreenReader
|
||||
|
@ -51,10 +51,7 @@ def htmlCalendarDeleteConfirm(cssCache: {}, translate: {}, baseDir: str,
|
|||
if not postJsonObject:
|
||||
return None
|
||||
|
||||
if os.path.isfile(baseDir + '/img/delete-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/delete-background.png'):
|
||||
copyfile(baseDir + '/img/delete-background.png',
|
||||
baseDir + '/accounts/delete-background.png')
|
||||
setCustomBackground(baseDir, 'delete-background')
|
||||
|
||||
deletePostStr = None
|
||||
cssFilename = baseDir + '/epicyon-profile.css'
|
||||
|
@ -287,10 +284,7 @@ def htmlCalendar(personCache: {}, cssCache: {}, translate: {},
|
|||
|
||||
nickname = getNicknameFromActor(actor)
|
||||
|
||||
if os.path.isfile(baseDir + '/img/calendar-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/calendar-background.png'):
|
||||
copyfile(baseDir + '/img/calendar-background.png',
|
||||
baseDir + '/accounts/calendar-background.png')
|
||||
setCustomBackground(baseDir, 'calendar-background')
|
||||
|
||||
months = ('January', 'February', 'March', 'April',
|
||||
'May', 'June', 'July', 'August', 'September',
|
||||
|
|
|
@ -17,6 +17,7 @@ from utils import loadJson
|
|||
from utils import getConfigParam
|
||||
from utils import getAltPath
|
||||
from utils import acctDir
|
||||
from webapp_utils import setCustomBackground
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
from webapp_utils import htmlFooter
|
||||
from webapp_post import individualPostAsHtml
|
||||
|
@ -54,10 +55,7 @@ def htmlConfirmDelete(cssCache: {},
|
|||
if not postJsonObject:
|
||||
return None
|
||||
|
||||
if os.path.isfile(baseDir + '/img/delete-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/delete-background.png'):
|
||||
copyfile(baseDir + '/img/delete-background.png',
|
||||
baseDir + '/accounts/delete-background.png')
|
||||
setCustomBackground(baseDir, 'delete-background')
|
||||
|
||||
deletePostStr = None
|
||||
cssFilename = baseDir + '/epicyon-profile.css'
|
||||
|
@ -134,10 +132,7 @@ def htmlConfirmRemoveSharedItem(cssCache: {}, translate: {}, baseDir: str,
|
|||
if sharesJson[itemID].get('imageUrl'):
|
||||
sharedItemImageUrl = sharesJson[itemID]['imageUrl']
|
||||
|
||||
if os.path.isfile(baseDir + '/img/shares-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/shares-background.png'):
|
||||
copyfile(baseDir + '/img/shares-background.png',
|
||||
baseDir + '/accounts/shares-background.png')
|
||||
setCustomBackground(baseDir, 'shares-background')
|
||||
|
||||
cssFilename = baseDir + '/epicyon-follow.css'
|
||||
if os.path.isfile(baseDir + '/follow.css'):
|
||||
|
@ -278,10 +273,7 @@ def htmlConfirmUnblock(cssCache: {}, translate: {}, baseDir: str,
|
|||
"""
|
||||
blockDomain, port = getDomainFromActor(blockActor)
|
||||
|
||||
if os.path.isfile(baseDir + '/img/block-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/block-background.png'):
|
||||
copyfile(baseDir + '/img/block-background.png',
|
||||
baseDir + '/accounts/block-background.png')
|
||||
setCustomBackground(baseDir, 'block-background')
|
||||
|
||||
cssFilename = baseDir + '/epicyon-follow.css'
|
||||
if os.path.isfile(baseDir + '/follow.css'):
|
||||
|
|
|
@ -8,12 +8,12 @@ __status__ = "Production"
|
|||
__module_group__ = "Web Interface"
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from datetime import datetime
|
||||
from utils import getNicknameFromActor
|
||||
from utils import getConfigParam
|
||||
from categories import getHashtagCategories
|
||||
from categories import getHashtagCategory
|
||||
from webapp_utils import setCustomBackground
|
||||
from webapp_utils import getSearchBannerFile
|
||||
from webapp_utils import getContentWarningButton
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
|
@ -201,10 +201,7 @@ def htmlSearchHashtagCategory(cssCache: {}, translate: {},
|
|||
categoryStr = path.split('/category/')[1].strip()
|
||||
searchNickname = getNicknameFromActor(actor)
|
||||
|
||||
if os.path.isfile(baseDir + '/img/search-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/search-background.png'):
|
||||
copyfile(baseDir + '/img/search-background.png',
|
||||
baseDir + '/accounts/search-background.png')
|
||||
backgroundExt = setCustomBackground(baseDir, 'search-background')
|
||||
|
||||
cssFilename = baseDir + '/epicyon-search.css'
|
||||
if os.path.isfile(baseDir + '/search.css'):
|
||||
|
@ -213,6 +210,11 @@ def htmlSearchHashtagCategory(cssCache: {}, translate: {},
|
|||
instanceTitle = \
|
||||
getConfigParam(baseDir, 'instanceTitle')
|
||||
htmlStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
|
||||
if backgroundExt:
|
||||
if backgroundExt != 'jpg':
|
||||
htmlStr = htmlStr.replace('"follow-background.jpg"',
|
||||
'"follow-background.' +
|
||||
backgroundExt + '"')
|
||||
|
||||
# show a banner above the search box
|
||||
searchBannerFile, searchBannerFilename = \
|
||||
|
|
|
@ -31,6 +31,7 @@ from skills import getSkillsFromList
|
|||
from categories import getHashtagCategory
|
||||
from feeds import rss2TagHeader
|
||||
from feeds import rss2TagFooter
|
||||
from webapp_utils import setCustomBackground
|
||||
from webapp_utils import htmlKeyboardNavigation
|
||||
from webapp_utils import htmlHeaderWithExternalStyle
|
||||
from webapp_utils import htmlFooter
|
||||
|
@ -327,10 +328,7 @@ def htmlSearchEmojiTextEntry(cssCache: {}, translate: {},
|
|||
actor = path.replace('/search', '')
|
||||
domain, port = getDomainFromActor(actor)
|
||||
|
||||
if os.path.isfile(baseDir + '/img/search-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/search-background.png'):
|
||||
copyfile(baseDir + '/img/search-background.png',
|
||||
baseDir + '/accounts/search-background.png')
|
||||
backgroundExt = setCustomBackground(baseDir, 'search-background')
|
||||
|
||||
cssFilename = baseDir + '/epicyon-follow.css'
|
||||
if os.path.isfile(baseDir + '/follow.css'):
|
||||
|
@ -339,6 +337,11 @@ def htmlSearchEmojiTextEntry(cssCache: {}, translate: {},
|
|||
instanceTitle = \
|
||||
getConfigParam(baseDir, 'instanceTitle')
|
||||
emojiStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
|
||||
if backgroundExt:
|
||||
if backgroundExt != 'jpg':
|
||||
emojiStr = emojiStr.replace('"follow-background.jpg"',
|
||||
'"follow-background.' +
|
||||
backgroundExt + '"')
|
||||
emojiStr += '<div class="follow">\n'
|
||||
emojiStr += ' <div class="followAvatar">\n'
|
||||
emojiStr += ' <center>\n'
|
||||
|
@ -370,10 +373,7 @@ def htmlSearch(cssCache: {}, translate: {},
|
|||
actor = path.replace('/search', '')
|
||||
searchNickname = getNicknameFromActor(actor)
|
||||
|
||||
if os.path.isfile(baseDir + '/img/search-background.png'):
|
||||
if not os.path.isfile(baseDir + '/accounts/search-background.png'):
|
||||
copyfile(baseDir + '/img/search-background.png',
|
||||
baseDir + '/accounts/search-background.png')
|
||||
backgroundExt = setCustomBackground(baseDir, 'search-background')
|
||||
|
||||
cssFilename = baseDir + '/epicyon-search.css'
|
||||
if os.path.isfile(baseDir + '/search.css'):
|
||||
|
@ -381,6 +381,11 @@ def htmlSearch(cssCache: {}, translate: {},
|
|||
|
||||
instanceTitle = getConfigParam(baseDir, 'instanceTitle')
|
||||
followStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
|
||||
if backgroundExt:
|
||||
if backgroundExt != 'jpg':
|
||||
followStr = followStr.replace('"follow-background.jpg"',
|
||||
'"follow-background.' +
|
||||
backgroundExt + '"')
|
||||
|
||||
# show a banner above the search box
|
||||
searchBannerFile, searchBannerFilename = \
|
||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
|||
__module_group__ = "Web Interface"
|
||||
|
||||
import os
|
||||
from shutil import copyfile
|
||||
from collections import OrderedDict
|
||||
from session import getJson
|
||||
from utils import isAccountDir
|
||||
|
@ -1455,3 +1456,18 @@ def htmlShowShare(baseDir: str, domain: str, nickname: str,
|
|||
|
||||
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \
|
||||
shareStr + htmlFooter()
|
||||
|
||||
|
||||
def setCustomBackground(baseDir: str, background: str) -> str:
|
||||
"""Sets a custom background
|
||||
Returns the extension, if found
|
||||
"""
|
||||
extensions = getImageExtensions()
|
||||
for ext in extensions:
|
||||
if os.path.isfile(baseDir + '/img/' + background + '.' + ext):
|
||||
if not os.path.isfile(baseDir + '/accounts/' +
|
||||
background + '.' + ext):
|
||||
copyfile(baseDir + '/img/' + background + '.' + ext,
|
||||
baseDir + '/accounts/' + background + '.' + ext)
|
||||
return ext
|
||||
return None
|
||||
|
|
Loading…
Reference in New Issue