Merge branch 'main' of gitlab.com:bashrc2/epicyon

merge-requests/30/head
Bob Mottram 2021-10-30 16:54:07 +01:00
commit a43f3f04dd
7 changed files with 32 additions and 40 deletions

View File

@ -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',

View File

@ -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'):

View File

@ -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'):

View File

@ -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 += \

View File

@ -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'):

View File

@ -941,6 +941,7 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
if itemCtr > 0:
tlStr += textModeSeparator
tlStr += \
' <br>\n' + \
' <center>\n' + \
' <a href="' + usersPath + '/' + boxName + '?page=' + \
str(pageNumber + 1) + \

View File

@ -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,20 @@ def htmlShowShare(baseDir: str, domain: str, nickname: str,
return htmlHeaderWithExternalStyle(cssFilename, instanceTitle) + \
shareStr + htmlFooter()
def setCustomBackground(baseDir: str, background: str,
newBackground: str) -> 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