From a14d6a014e8db75dfdbeea8dc2232b9e14709bd1 Mon Sep 17 00:00:00 2001
From: Bob Mottram
Date: Wed, 5 Aug 2020 22:12:09 +0100
Subject: [PATCH] Add notes about people
---
daemon.py | 24 ++++++++++++++++++++++++
person.py | 15 +++++++++++++++
translations/ar.json | 3 ++-
translations/ca.json | 3 ++-
translations/cy.json | 3 ++-
translations/de.json | 3 ++-
translations/en.json | 3 ++-
translations/es.json | 3 ++-
translations/fr.json | 3 ++-
translations/ga.json | 3 ++-
translations/hi.json | 3 ++-
translations/it.json | 3 ++-
translations/ja.json | 3 ++-
translations/oc.json | 3 ++-
translations/pt.json | 3 ++-
translations/ru.json | 3 ++-
translations/zh.json | 3 ++-
webinterface.py | 22 ++++++++++++++++++++--
18 files changed, 89 insertions(+), 17 deletions(-)
diff --git a/daemon.py b/daemon.py
index f77403c0..c7f720af 100644
--- a/daemon.py
+++ b/daemon.py
@@ -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:
diff --git a/person.py b/person.py
index 09fe2657..c22487e3 100644
--- a/person.py
+++ b/person.py
@@ -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
diff --git a/translations/ar.json b/translations/ar.json
index b54e8e45..b6762b3d 100644
--- a/translations/ar.json
+++ b/translations/ar.json
@@ -254,5 +254,6 @@
"Grayscale": "درجات الرمادي",
"Liked by": "نال إعجاب",
"Solidaric": "تضامن",
- "YouTube Replacement Domain": "استبدال نطاق يوتيوب"
+ "YouTube Replacement Domain": "استبدال نطاق يوتيوب",
+ "Notes": "ملاحظات"
}
diff --git a/translations/ca.json b/translations/ca.json
index a9b786b2..c4850e8e 100644
--- a/translations/ca.json
+++ b/translations/ca.json
@@ -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"
}
diff --git a/translations/cy.json b/translations/cy.json
index 0edecbda..afddb9c9 100644
--- a/translations/cy.json
+++ b/translations/cy.json
@@ -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"
}
diff --git a/translations/de.json b/translations/de.json
index bc526301..232e65d8 100644
--- a/translations/de.json
+++ b/translations/de.json
@@ -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"
}
diff --git a/translations/en.json b/translations/en.json
index a472dffa..1261381b 100644
--- a/translations/en.json
+++ b/translations/en.json
@@ -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"
}
diff --git a/translations/es.json b/translations/es.json
index 04a95dfb..33348076 100644
--- a/translations/es.json
+++ b/translations/es.json
@@ -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"
}
diff --git a/translations/fr.json b/translations/fr.json
index 3f9a8d36..f4b9dd0f 100644
--- a/translations/fr.json
+++ b/translations/fr.json
@@ -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"
}
diff --git a/translations/ga.json b/translations/ga.json
index cf69648d..a812ff8e 100644
--- a/translations/ga.json
+++ b/translations/ga.json
@@ -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í"
}
diff --git a/translations/hi.json b/translations/hi.json
index b90225ec..1b961804 100644
--- a/translations/hi.json
+++ b/translations/hi.json
@@ -254,5 +254,6 @@
"Grayscale": "ग्रेस्केल",
"Liked by": "द्वारा पसंद किया गया",
"Solidaric": "एकजुटता",
- "YouTube Replacement Domain": "YouTube रिप्लेसमेंट डोमेन"
+ "YouTube Replacement Domain": "YouTube रिप्लेसमेंट डोमेन",
+ "Notes": "टिप्पणियाँ"
}
diff --git a/translations/it.json b/translations/it.json
index 2cecaa66..b7c9c050 100644
--- a/translations/it.json
+++ b/translations/it.json
@@ -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"
}
diff --git a/translations/ja.json b/translations/ja.json
index 02a24543..562118dd 100644
--- a/translations/ja.json
+++ b/translations/ja.json
@@ -254,5 +254,6 @@
"Grayscale": "グレースケール",
"Liked by": "好き",
"Solidaric": "連帯",
- "YouTube Replacement Domain": "YouTube交換ドメイン"
+ "YouTube Replacement Domain": "YouTube交換ドメイン",
+ "Notes": "ノート"
}
diff --git a/translations/oc.json b/translations/oc.json
index 6203b272..42ca4e07 100644
--- a/translations/oc.json
+++ b/translations/oc.json
@@ -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"
}
diff --git a/translations/pt.json b/translations/pt.json
index 19c0f414..279e6c9c 100644
--- a/translations/pt.json
+++ b/translations/pt.json
@@ -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"
}
diff --git a/translations/ru.json b/translations/ru.json
index bc322bf0..a5471654 100644
--- a/translations/ru.json
+++ b/translations/ru.json
@@ -254,5 +254,6 @@
"Grayscale": "Оттенки серого",
"Liked by": "Понравилось",
"Solidaric": "солидарность",
- "YouTube Replacement Domain": "Запасной домен YouTube"
+ "YouTube Replacement Domain": "Запасной домен YouTube",
+ "Notes": "Ноты"
}
diff --git a/translations/zh.json b/translations/zh.json
index 16f29b92..99f98215 100644
--- a/translations/zh.json
+++ b/translations/zh.json
@@ -253,5 +253,6 @@
"Grayscale": "灰阶",
"Liked by": "喜欢的人",
"Solidaric": "团结互助",
- "YouTube Replacement Domain": "YouTube替换域"
+ "YouTube Replacement Domain": "YouTube替换域",
+ "Notes": "笔记"
}
diff --git a/webinterface.py b/webinterface.py
index 45df3d27..0dafb555 100644
--- a/webinterface.py
+++ b/webinterface.py
@@ -5566,10 +5566,10 @@ def htmlPersonOptions(translate: {}, baseDir: str,
optionsStr += ' \n'
optionsStr += '
\n'
+ handle = getNicknameFromActor(optionsActor) + '@' + optionsDomain
optionsStr += \
' ' + translate['Options for'] + \
- ' @' + getNicknameFromActor(optionsActor) + '@' + \
- optionsDomain + '
\n'
+ ' @' + handle + '
\n'
if emailAddress:
optionsStr += \
'' + translate['Email'] + \
@@ -5658,6 +5658,24 @@ def htmlPersonOptions(translate: {}, baseDir: str,
' \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 += \
+ '
' + translate['Notes'] + ': \n'
+ optionsStr += '
\n'
+ optionsStr += \
+ ' \n'
+
optionsStr += ' \n'
optionsStr += '\n'
optionsStr += '\n'