diff --git a/webapp_calendar.py b/webapp_calendar.py index 8dee4eb27..2fa9cdcb3 100644 --- a/webapp_calendar.py +++ b/webapp_calendar.py @@ -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', diff --git a/webapp_confirm.py b/webapp_confirm.py index a2b29250d..a483726cd 100644 --- a/webapp_confirm.py +++ b/webapp_confirm.py @@ -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'): diff --git a/webapp_hashtagswarm.py b/webapp_hashtagswarm.py index 6eca2a7d7..abf0996d5 100644 --- a/webapp_hashtagswarm.py +++ b/webapp_hashtagswarm.py @@ -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 = \ diff --git a/webapp_search.py b/webapp_search.py index 7375d4f47..94b820ec5 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -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 += '