Add notes about people

main
Bob Mottram 2020-08-05 22:12:09 +01:00
parent 33bbe71940
commit a14d6a014e
18 changed files with 89 additions and 17 deletions

View File

@ -43,6 +43,7 @@ from matrix import getMatrixAddress
from matrix import setMatrixAddress
from donate import getDonationUrl
from donate import setDonationUrl
from person import setPersonNotes
from person import getDefaultPersonContext
from person import savePersonQrcode
from person import randomizeActorImages
@ -7757,6 +7758,15 @@ class PubServer(BaseHTTPRequestHandler):
'?' in petname or '#' in petname:
petname = None
personNotes = None
if 'optionnotes' in optionsConfirmParams:
personNotes = optionsConfirmParams.split('optionnotes=')[1]
if '&' in personNotes:
personNotes = personNotes.split('&')[0]
# Limit the length of the notes
if len(personNotes) > 64000:
personNotes = None
optionsNickname = getNicknameFromActor(optionsActor)
if not optionsNickname:
if callingDomain.endswith('.onion') and \
@ -7805,6 +7815,20 @@ class PubServer(BaseHTTPRequestHandler):
callingDomain)
self.server.POSTbusy = False
return
if '&submitPersonNotes=' in optionsConfirmParams and personNotes:
if self.server.debug:
print('Change person notes')
handle = optionsNickname + '@' + optionsDomainFull
setPersonNotes(self.server.baseDir,
chooserNickname,
self.server.domain,
handle, personNotes)
self._redirect_headers(originPathStr + '/' +
self.server.defaultTimeline +
'?page='+str(pageNumber), cookie,
callingDomain)
self.server.POSTbusy = False
return
if '&submitOnCalendar=' in optionsConfirmParams:
onCalendar = None
if 'onCalendar=' in optionsConfirmParams:

View File

@ -1075,3 +1075,18 @@ def personUnsnooze(baseDir: str, nickname: str, domain: str,
if writeSnoozedFile:
writeSnoozedFile.write(content)
writeSnoozedFile.close()
def setPersonNotes(baseDir: str, nickname: str, domain: str,
handle: str, notes: str) -> bool:
"""Adds notes about a person
"""
if '@' not in handle:
return False
if handle.startswith('@'):
handle = handle[1:]
notesFilename = baseDir + '/accounts/' + \
nickname + '@' + domain + '/notes/' + handle + '.txt'
with open(notesFilename, 'w+') as notesFile:
notesFile.write(notes)
return True

View File

@ -254,5 +254,6 @@
"Grayscale": "درجات الرمادي",
"Liked by": "نال إعجاب",
"Solidaric": "تضامن",
"YouTube Replacement Domain": "استبدال نطاق يوتيوب"
"YouTube Replacement Domain": "استبدال نطاق يوتيوب",
"Notes": "ملاحظات"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Escala de grisos",
"Liked by": "M'agrada",
"Solidaric": "Solidaritat",
"YouTube Replacement Domain": "Domini de substitució de YouTube"
"YouTube Replacement Domain": "Domini de substitució de YouTube",
"Notes": "Notes"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Graddlwyd",
"Liked by": "Hoffi",
"Solidaric": "Undod",
"YouTube Replacement Domain": "Parth Amnewid YouTube"
"YouTube Replacement Domain": "Parth Amnewid YouTube",
"Notes": "Nodiadau"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Graustufen",
"Liked by": "Gefallen von",
"Solidaric": "Solidarität",
"YouTube Replacement Domain": "YouTube-Ersatzdomain"
"YouTube Replacement Domain": "YouTube-Ersatzdomain",
"Notes": "Anmerkungen"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Grayscale",
"Liked by": "Liked by",
"Solidaric": "Solidaric",
"YouTube Replacement Domain": "YouTube Replacement Domain"
"YouTube Replacement Domain": "YouTube Replacement Domain",
"Notes": "Notes"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Escala de grises",
"Liked by": "Apreciado por",
"Solidaric": "Solidaridad",
"YouTube Replacement Domain": "Dominio de reemplazo de YouTube"
"YouTube Replacement Domain": "Dominio de reemplazo de YouTube",
"Notes": "Notas"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Niveaux de gris",
"Liked by": "Aimé par",
"Solidaric": "Solidarité",
"YouTube Replacement Domain": "Domaine de remplacement YouTube"
"YouTube Replacement Domain": "Domaine de remplacement YouTube",
"Notes": "Remarques"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Liathscála",
"Liked by": "Thaitin",
"Solidaric": "Dlúthpháirtíocht",
"YouTube Replacement Domain": "Fearann Athsholáthair YouTube"
"YouTube Replacement Domain": "Fearann Athsholáthair YouTube",
"Notes": "Nótaí"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "ग्रेस्केल",
"Liked by": "द्वारा पसंद किया गया",
"Solidaric": "एकजुटता",
"YouTube Replacement Domain": "YouTube रिप्लेसमेंट डोमेन"
"YouTube Replacement Domain": "YouTube रिप्लेसमेंट डोमेन",
"Notes": "टिप्पणियाँ"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Scala di grigi",
"Liked by": "Mi è piaciuto",
"Solidaric": "Solidarietà",
"YouTube Replacement Domain": "Dominio sostitutivo di YouTube"
"YouTube Replacement Domain": "Dominio sostitutivo di YouTube",
"Notes": "Appunti"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "グレースケール",
"Liked by": "好き",
"Solidaric": "連帯",
"YouTube Replacement Domain": "YouTube交換ドメイン"
"YouTube Replacement Domain": "YouTube交換ドメイン",
"Notes": "ノート"
}

View File

@ -250,5 +250,6 @@
"Grayscale": "Grayscale",
"Liked by": "Liked by",
"Solidaric": "Solidaric",
"YouTube Replacement Domain": "YouTube Replacement Domain"
"YouTube Replacement Domain": "YouTube Replacement Domain",
"Notes": "Notes"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Escala de cinza",
"Liked by": "Curtida por",
"Solidaric": "Solidariedade",
"YouTube Replacement Domain": "Domínio de substituição do YouTube"
"YouTube Replacement Domain": "Domínio de substituição do YouTube",
"Notes": "Notas"
}

View File

@ -254,5 +254,6 @@
"Grayscale": "Оттенки серого",
"Liked by": "Понравилось",
"Solidaric": "солидарность",
"YouTube Replacement Domain": "Запасной домен YouTube"
"YouTube Replacement Domain": "Запасной домен YouTube",
"Notes": "Ноты"
}

View File

@ -253,5 +253,6 @@
"Grayscale": "灰阶",
"Liked by": "喜欢的人",
"Solidaric": "团结互助",
"YouTube Replacement Domain": "YouTube替换域"
"YouTube Replacement Domain": "YouTube替换域",
"Notes": "笔记"
}

View File

@ -5566,10 +5566,10 @@ def htmlPersonOptions(translate: {}, baseDir: str,
optionsStr += ' <a href="' + optionsActor + '">\n'
optionsStr += ' <img loading="lazy" src="' + optionsProfileUrl + \
'"/></a>\n'
handle = getNicknameFromActor(optionsActor) + '@' + optionsDomain
optionsStr += \
' <p class="optionsText">' + translate['Options for'] + \
' @' + getNicknameFromActor(optionsActor) + '@' + \
optionsDomain + '</p>\n'
' @' + handle + '</p>\n'
if emailAddress:
optionsStr += \
'<p class="imText">' + translate['Email'] + \
@ -5658,6 +5658,24 @@ def htmlPersonOptions(translate: {}, baseDir: str,
' <button type="submit" class="button" name="submitReport">' + \
translate['Report'] + '</button>\n'
personNotes = ''
personNotesFilename = \
baseDir + '/accounts/' + nickname + '@' + domain + \
'/notes/' + handle + '.txt'
if os.path.isfile(personNotesFilename):
with open(personNotesFilename, 'r') as fp:
personNotes = fp.read()
optionsStr += \
' <br><br>' + translate['Notes'] + ': \n'
optionsStr += '<button type="submit" class="button" ' + \
'name="submitPersonNotes">' + \
translate['Submit'] + '</button><br>\n'
optionsStr += \
' <textarea id="message" ' + \
'name="optionnotes" style="height:200px">' + \
personNotes + '</textarea>\n'
optionsStr += ' </form>\n'
optionsStr += '</center>\n'
optionsStr += '</div>\n'