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