mirror of https://gitlab.com/bashrc2/epicyon
Website field in profile
parent
71beafd1a6
commit
39ab8ecd53
18
daemon.py
18
daemon.py
|
@ -50,6 +50,8 @@ from matrix import getMatrixAddress
|
|||
from matrix import setMatrixAddress
|
||||
from donate import getDonationUrl
|
||||
from donate import setDonationUrl
|
||||
from donate import getWebsite
|
||||
from donate import setWebsite
|
||||
from person import setPersonNotes
|
||||
from person import getDefaultPersonContext
|
||||
from person import savePersonQrcode
|
||||
|
@ -4834,6 +4836,18 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
setDonationUrl(actorJson, '')
|
||||
actorChanged = True
|
||||
|
||||
# change website
|
||||
currentWebsite = getWebsite(actorJson)
|
||||
if fields.get('websiteUrl'):
|
||||
if fields['websiteUrl'] != currentWebsite:
|
||||
setWebsite(actorJson,
|
||||
fields['websiteUrl'])
|
||||
actorChanged = True
|
||||
else:
|
||||
if currentWebsite:
|
||||
setWebsite(actorJson, '')
|
||||
actorChanged = True
|
||||
|
||||
# account moved to new address
|
||||
movedTo = ''
|
||||
if actorJson.get('movedTo'):
|
||||
|
@ -6146,6 +6160,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if len(optionsList) > 3:
|
||||
optionsLink = optionsList[3]
|
||||
donateUrl = None
|
||||
websiteUrl = None
|
||||
PGPpubKey = None
|
||||
PGPfingerprint = None
|
||||
xmppAddress = None
|
||||
|
@ -6169,6 +6184,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
movedTo = actorJson['movedTo']
|
||||
lockedAccount = getLockedAccount(actorJson)
|
||||
donateUrl = getDonationUrl(actorJson)
|
||||
websiteUrl = getWebsite(actorJson)
|
||||
xmppAddress = getXmppAddress(actorJson)
|
||||
matrixAddress = getMatrixAddress(actorJson)
|
||||
ssbAddress = getSSBAddress(actorJson)
|
||||
|
@ -6207,7 +6223,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
optionsActor,
|
||||
optionsProfileUrl,
|
||||
optionsLink,
|
||||
pageNumber, donateUrl,
|
||||
pageNumber, donateUrl, websiteUrl,
|
||||
xmppAddress, matrixAddress,
|
||||
ssbAddress, blogAddress,
|
||||
toxAddress, briarAddress,
|
||||
|
|
79
donate.py
79
donate.py
|
@ -14,6 +14,10 @@ def _getDonationTypes() -> str:
|
|||
'subscribestar')
|
||||
|
||||
|
||||
def _getWebsiteStrings() -> str:
|
||||
return ('www', 'website', 'web', 'homepage')
|
||||
|
||||
|
||||
def getDonationUrl(actorJson: {}) -> str:
|
||||
"""Returns a link used for donations
|
||||
"""
|
||||
|
@ -39,6 +43,27 @@ def getDonationUrl(actorJson: {}) -> str:
|
|||
return ''
|
||||
|
||||
|
||||
def getWebsite(actorJson: {}) -> str:
|
||||
"""Returns a web address link
|
||||
"""
|
||||
if not actorJson.get('attachment'):
|
||||
return ''
|
||||
matchStrings = _getWebsiteStrings()
|
||||
for propertyValue in actorJson['attachment']:
|
||||
if not propertyValue.get('name'):
|
||||
continue
|
||||
if propertyValue['name'].lower() not in matchStrings:
|
||||
continue
|
||||
if not propertyValue.get('type'):
|
||||
continue
|
||||
if not propertyValue.get('value'):
|
||||
continue
|
||||
if propertyValue['type'] != 'PropertyValue':
|
||||
continue
|
||||
return propertyValue['value']
|
||||
return ''
|
||||
|
||||
|
||||
def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
||||
"""Sets a link used for donations
|
||||
"""
|
||||
|
@ -102,3 +127,57 @@ def setDonationUrl(actorJson: {}, donateUrl: str) -> None:
|
|||
"value": donateValue
|
||||
}
|
||||
actorJson['attachment'].append(newDonate)
|
||||
|
||||
|
||||
def setWebsite(actorJson: {}, websiteUrl: str) -> None:
|
||||
"""Sets a web address
|
||||
"""
|
||||
notUrl = False
|
||||
if '.' not in websiteUrl:
|
||||
notUrl = True
|
||||
if '://' not in websiteUrl:
|
||||
notUrl = True
|
||||
if ' ' in websiteUrl:
|
||||
notUrl = True
|
||||
if '<' in websiteUrl:
|
||||
notUrl = True
|
||||
|
||||
if not actorJson.get('attachment'):
|
||||
actorJson['attachment'] = []
|
||||
|
||||
matchStrings = _getWebsiteStrings()
|
||||
|
||||
# remove any existing value
|
||||
propertyFound = None
|
||||
for propertyValue in actorJson['attachment']:
|
||||
if not propertyValue.get('name'):
|
||||
continue
|
||||
if not propertyValue.get('type'):
|
||||
continue
|
||||
if not propertyValue['name'].lower() not in matchStrings:
|
||||
continue
|
||||
propertyFound = propertyValue
|
||||
break
|
||||
if propertyFound:
|
||||
actorJson['attachment'].remove(propertyFound)
|
||||
if notUrl:
|
||||
return
|
||||
|
||||
for propertyValue in actorJson['attachment']:
|
||||
if not propertyValue.get('name'):
|
||||
continue
|
||||
if not propertyValue.get('type'):
|
||||
continue
|
||||
if not propertyValue['name'].lower() not in matchStrings:
|
||||
continue
|
||||
if propertyValue['type'] != 'PropertyValue':
|
||||
continue
|
||||
propertyValue['value'] = websiteUrl
|
||||
return
|
||||
|
||||
newEntry = {
|
||||
"name": 'Website',
|
||||
"type": "PropertyValue",
|
||||
"value": websiteUrl
|
||||
}
|
||||
actorJson['attachment'].append(newEntry)
|
||||
|
|
|
@ -40,6 +40,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
|||
optionsLink: str,
|
||||
pageNumber: int,
|
||||
donateUrl: str,
|
||||
webAddress: str,
|
||||
xmppAddress: str,
|
||||
matrixAddress: str,
|
||||
ssbAddress: str,
|
||||
|
|
|
@ -34,6 +34,7 @@ from webfinger import webfingerHandle
|
|||
from posts import parseUserFeed
|
||||
from posts import getPersonBox
|
||||
from donate import getDonationUrl
|
||||
from donate import getWebsite
|
||||
from xmpp import getXmppAddress
|
||||
from matrix import getMatrixAddress
|
||||
from ssb import getSSBAddress
|
||||
|
@ -547,6 +548,7 @@ def htmlProfile(rssIconAtTop: bool,
|
|||
|
||||
donateSection = ''
|
||||
donateUrl = getDonationUrl(profileJson)
|
||||
websiteUrl = getWebsite(profileJson)
|
||||
PGPpubKey = getPGPpubKey(profileJson)
|
||||
PGPfingerprint = getPGPfingerprint(profileJson)
|
||||
emailAddress = getEmailAddress(profileJson)
|
||||
|
@ -1719,7 +1721,7 @@ def _getSupportedLanguagesSorted(baseDir: str) -> str:
|
|||
|
||||
|
||||
def _htmlEditProfileMain(baseDir: str, displayNickname: str, bioStr: str,
|
||||
movedTo: str, donateUrl: str,
|
||||
movedTo: str, donateUrl: str, websiteUrl: str,
|
||||
blogAddress: str, actorJson: {},
|
||||
translate: {}) -> str:
|
||||
"""main info on edit profile screen
|
||||
|
@ -1771,6 +1773,9 @@ def _htmlEditProfileMain(baseDir: str, displayNickname: str, bioStr: str,
|
|||
editTextField(translate['Donations link'], 'donateUrl',
|
||||
donateUrl, 'https://...')
|
||||
|
||||
editProfileForm += \
|
||||
editTextField('Website', 'websiteUrl', websiteUrl, 'https://...')
|
||||
|
||||
editProfileForm += \
|
||||
editTextField('Blog', 'blogAddress', blogAddress, 'https://...')
|
||||
|
||||
|
@ -1858,6 +1863,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
if actorJson.get('movedTo'):
|
||||
movedTo = actorJson['movedTo']
|
||||
donateUrl = getDonationUrl(actorJson)
|
||||
websiteUrl = getWebsite(actorJson)
|
||||
xmppAddress = getXmppAddress(actorJson)
|
||||
matrixAddress = getMatrixAddress(actorJson)
|
||||
ssbAddress = getSSBAddress(actorJson)
|
||||
|
@ -1981,7 +1987,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
|||
# main info
|
||||
editProfileForm += \
|
||||
_htmlEditProfileMain(baseDir, displayNickname, bioStr,
|
||||
movedTo, donateUrl,
|
||||
movedTo, donateUrl, websiteUrl,
|
||||
blogAddress, actorJson, translate)
|
||||
|
||||
# Option checkboxes
|
||||
|
|
Loading…
Reference in New Issue