Add notes about people

merge-requests/30/head
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 matrix import setMatrixAddress
from donate import getDonationUrl from donate import getDonationUrl
from donate import setDonationUrl from donate import setDonationUrl
from person import setPersonNotes
from person import getDefaultPersonContext from person import getDefaultPersonContext
from person import savePersonQrcode from person import savePersonQrcode
from person import randomizeActorImages from person import randomizeActorImages
@ -7757,6 +7758,15 @@ class PubServer(BaseHTTPRequestHandler):
'?' in petname or '#' in petname: '?' in petname or '#' in petname:
petname = None 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) optionsNickname = getNicknameFromActor(optionsActor)
if not optionsNickname: if not optionsNickname:
if callingDomain.endswith('.onion') and \ if callingDomain.endswith('.onion') and \
@ -7805,6 +7815,20 @@ class PubServer(BaseHTTPRequestHandler):
callingDomain) callingDomain)
self.server.POSTbusy = False self.server.POSTbusy = False
return 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: if '&submitOnCalendar=' in optionsConfirmParams:
onCalendar = None onCalendar = None
if 'onCalendar=' in optionsConfirmParams: if 'onCalendar=' in optionsConfirmParams:

View File

@ -1075,3 +1075,18 @@ def personUnsnooze(baseDir: str, nickname: str, domain: str,
if writeSnoozedFile: if writeSnoozedFile:
writeSnoozedFile.write(content) writeSnoozedFile.write(content)
writeSnoozedFile.close() 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": "درجات الرمادي", "Grayscale": "درجات الرمادي",
"Liked by": "نال إعجاب", "Liked by": "نال إعجاب",
"Solidaric": "تضامن", "Solidaric": "تضامن",
"YouTube Replacement Domain": "استبدال نطاق يوتيوب" "YouTube Replacement Domain": "استبدال نطاق يوتيوب",
"Notes": "ملاحظات"
} }

View File

@ -254,5 +254,6 @@
"Grayscale": "Escala de grisos", "Grayscale": "Escala de grisos",
"Liked by": "M'agrada", "Liked by": "M'agrada",
"Solidaric": "Solidaritat", "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", "Grayscale": "Graddlwyd",
"Liked by": "Hoffi", "Liked by": "Hoffi",
"Solidaric": "Undod", "Solidaric": "Undod",
"YouTube Replacement Domain": "Parth Amnewid YouTube" "YouTube Replacement Domain": "Parth Amnewid YouTube",
"Notes": "Nodiadau"
} }

View File

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

View File

@ -254,5 +254,6 @@
"Grayscale": "Grayscale", "Grayscale": "Grayscale",
"Liked by": "Liked by", "Liked by": "Liked by",
"Solidaric": "Solidaric", "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", "Grayscale": "Escala de grises",
"Liked by": "Apreciado por", "Liked by": "Apreciado por",
"Solidaric": "Solidaridad", "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", "Grayscale": "Niveaux de gris",
"Liked by": "Aimé par", "Liked by": "Aimé par",
"Solidaric": "Solidarité", "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", "Grayscale": "Liathscála",
"Liked by": "Thaitin", "Liked by": "Thaitin",
"Solidaric": "Dlúthpháirtíocht", "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": "ग्रेस्केल", "Grayscale": "ग्रेस्केल",
"Liked by": "द्वारा पसंद किया गया", "Liked by": "द्वारा पसंद किया गया",
"Solidaric": "एकजुटता", "Solidaric": "एकजुटता",
"YouTube Replacement Domain": "YouTube रिप्लेसमेंट डोमेन" "YouTube Replacement Domain": "YouTube रिप्लेसमेंट डोमेन",
"Notes": "टिप्पणियाँ"
} }

View File

@ -254,5 +254,6 @@
"Grayscale": "Scala di grigi", "Grayscale": "Scala di grigi",
"Liked by": "Mi è piaciuto", "Liked by": "Mi è piaciuto",
"Solidaric": "Solidarietà", "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": "グレースケール", "Grayscale": "グレースケール",
"Liked by": "好き", "Liked by": "好き",
"Solidaric": "連帯", "Solidaric": "連帯",
"YouTube Replacement Domain": "YouTube交換ドメイン" "YouTube Replacement Domain": "YouTube交換ドメイン",
"Notes": "ノート"
} }

View File

@ -250,5 +250,6 @@
"Grayscale": "Grayscale", "Grayscale": "Grayscale",
"Liked by": "Liked by", "Liked by": "Liked by",
"Solidaric": "Solidaric", "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", "Grayscale": "Escala de cinza",
"Liked by": "Curtida por", "Liked by": "Curtida por",
"Solidaric": "Solidariedade", "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": "Оттенки серого", "Grayscale": "Оттенки серого",
"Liked by": "Понравилось", "Liked by": "Понравилось",
"Solidaric": "солидарность", "Solidaric": "солидарность",
"YouTube Replacement Domain": "Запасной домен YouTube" "YouTube Replacement Domain": "Запасной домен YouTube",
"Notes": "Ноты"
} }

View File

@ -253,5 +253,6 @@
"Grayscale": "灰阶", "Grayscale": "灰阶",
"Liked by": "喜欢的人", "Liked by": "喜欢的人",
"Solidaric": "团结互助", "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 += ' <a href="' + optionsActor + '">\n'
optionsStr += ' <img loading="lazy" src="' + optionsProfileUrl + \ optionsStr += ' <img loading="lazy" src="' + optionsProfileUrl + \
'"/></a>\n' '"/></a>\n'
handle = getNicknameFromActor(optionsActor) + '@' + optionsDomain
optionsStr += \ optionsStr += \
' <p class="optionsText">' + translate['Options for'] + \ ' <p class="optionsText">' + translate['Options for'] + \
' @' + getNicknameFromActor(optionsActor) + '@' + \ ' @' + handle + '</p>\n'
optionsDomain + '</p>\n'
if emailAddress: if emailAddress:
optionsStr += \ optionsStr += \
'<p class="imText">' + translate['Email'] + \ '<p class="imText">' + translate['Email'] + \
@ -5658,6 +5658,24 @@ def htmlPersonOptions(translate: {}, baseDir: str,
' <button type="submit" class="button" name="submitReport">' + \ ' <button type="submit" class="button" name="submitReport">' + \
translate['Report'] + '</button>\n' 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 += ' </form>\n'
optionsStr += '</center>\n' optionsStr += '</center>\n'
optionsStr += '</div>\n' optionsStr += '</div>\n'