diff --git a/webapp_calendar.py b/webapp_calendar.py index 8dee4eb27..161cd63b1 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,11 +51,6 @@ 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') - deletePostStr = None cssFilename = baseDir + '/epicyon-profile.css' if os.path.isfile(baseDir + '/epicyon.css'): @@ -287,10 +282,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', 'calendar-background') months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', diff --git a/webapp_confirm.py b/webapp_confirm.py index a2b29250d..0d56fa1ac 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,11 +55,6 @@ 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') - deletePostStr = None cssFilename = baseDir + '/epicyon-profile.css' if os.path.isfile(baseDir + '/epicyon.css'): @@ -134,10 +130,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', 'follow-background') cssFilename = baseDir + '/epicyon-follow.css' if os.path.isfile(baseDir + '/follow.css'): @@ -278,10 +271,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', 'follow-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..6f4df63ed 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') + setCustomBackground(baseDir, 'search-background', 'follow-background') cssFilename = baseDir + '/epicyon-search.css' if os.path.isfile(baseDir + '/search.css'): diff --git a/webapp_login.py b/webapp_login.py index 97e54811c..67d9bca3f 100644 --- a/webapp_login.py +++ b/webapp_login.py @@ -13,6 +13,7 @@ from shutil import copyfile from utils import getConfigParam from utils import noOfAccounts from utils import getNicknameValidationPattern +from webapp_utils import setCustomBackground from webapp_utils import htmlHeaderWithWebsiteMarkup from webapp_utils import htmlFooter from webapp_utils import htmlKeyboardNavigation @@ -92,10 +93,7 @@ def htmlLogin(cssCache: {}, translate: {}, textModeLogo = getTextModeLogo(baseDir) textModeLogoHtml = htmlKeyboardNavigation(textModeLogo, {}, {}) - if os.path.isfile(baseDir + '/accounts/login-background-custom.jpg'): - if not os.path.isfile(baseDir + '/accounts/login-background.jpg'): - copyfile(baseDir + '/accounts/login-background-custom.jpg', - baseDir + '/accounts/login-background.jpg') + setCustomBackground(baseDir, 'login-background-custom', 'login-background') if accounts > 0: loginText = \ @@ -155,6 +153,7 @@ def htmlLogin(cssCache: {}, translate: {}, htmlHeaderWithWebsiteMarkup(cssFilename, instanceTitle, httpPrefix, domain, systemLanguage) + nicknamePattern = getNicknameValidationPattern() instanceTitle = getConfigParam(baseDir, 'instanceTitle') loginForm += \ diff --git a/webapp_search.py b/webapp_search.py index 7375d4f47..a6668c9b8 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') + setCustomBackground(baseDir, 'search-background', 'follow-background') cssFilename = baseDir + '/epicyon-follow.css' if os.path.isfile(baseDir + '/follow.css'): @@ -370,10 +368,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') + setCustomBackground(baseDir, 'search-background', 'follow-background') cssFilename = baseDir + '/epicyon-search.css' if os.path.isfile(baseDir + '/search.css'): diff --git a/webapp_timeline.py b/webapp_timeline.py index db89a95a8..52559d024 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -941,6 +941,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, if itemCtr > 0: tlStr += textModeSeparator tlStr += \ + '
\n' + \ '
\n' + \ ' str: + """Sets a custom background + Returns the extension, if found + """ + ext = 'jpg' + if os.path.isfile(baseDir + '/img/' + background + '.' + ext): + if not newBackground: + newBackground = background + if not os.path.isfile(baseDir + '/accounts/' + + newBackground + '.' + ext): + copyfile(baseDir + '/img/' + background + '.' + ext, + baseDir + '/accounts/' + newBackground + '.' + ext) + return ext + return None