From 076f1ff87c35970b3a4f0f4f5a1a35fe49474d43 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 19 Sep 2021 16:54:51 +0100 Subject: [PATCH] Profile button on shared item --- daemon.py | 14 ++++++++++++-- translations/ar.json | 5 ++++- translations/ca.json | 5 ++++- translations/cy.json | 5 ++++- translations/de.json | 5 ++++- translations/en.json | 5 ++++- translations/es.json | 5 ++++- translations/fr.json | 5 ++++- translations/ga.json | 5 ++++- translations/hi.json | 5 ++++- translations/it.json | 5 ++++- translations/ja.json | 5 ++++- translations/ku.json | 5 ++++- translations/oc.json | 5 ++++- translations/pt.json | 5 ++++- translations/ru.json | 5 ++++- translations/sw.json | 5 ++++- translations/zh.json | 5 ++++- utils.py | 2 +- webapp_search.py | 3 ++- webapp_utils.py | 16 +++++++++++----- 21 files changed, 94 insertions(+), 26 deletions(-) diff --git a/daemon.py b/daemon.py index 07a33e571..71658b2db 100644 --- a/daemon.py +++ b/daemon.py @@ -12589,6 +12589,11 @@ class PubServer(BaseHTTPRequestHandler): itemID = self.path.split('?showshare=')[1] if ';' in itemID: itemID = itemID.split(';')[0] + category = '' + if ';category=' in self.path: + category = self.path.split(';category=')[1] + if ';' in category: + category = category.split(';')[0] usersPath = self.path.split('?showshare=')[0] nickname = usersPath.replace('/users/', '') itemID = urllib.parse.unquote_plus(itemID.strip()) @@ -12599,7 +12604,7 @@ class PubServer(BaseHTTPRequestHandler): itemID, self.server.translate, self.server.sharedItemsFederatedDomains, self.server.defaultTimeline, - self.server.themeName, 'shares') + self.server.themeName, 'shares', category) if not msg: if callingDomain.endswith('.onion') and \ self.server.onionDomain: @@ -12623,6 +12628,11 @@ class PubServer(BaseHTTPRequestHandler): # after selecting a wanted item from the left column then show it if htmlGET and '?showwanted=' in self.path and '/users/' in self.path: itemID = self.path.split('?showwanted=')[1] + if ';' in itemID: + itemID = itemID.split(';')[0] + category = self.path.split('?category=')[1] + if ';' in category: + category = category.split(';')[0] usersPath = self.path.split('?showwanted=')[0] nickname = usersPath.replace('/users/', '') itemID = urllib.parse.unquote_plus(itemID.strip()) @@ -12633,7 +12643,7 @@ class PubServer(BaseHTTPRequestHandler): itemID, self.server.translate, self.server.sharedItemsFederatedDomains, self.server.defaultTimeline, - self.server.themeName, 'wanted') + self.server.themeName, 'wanted', category) if not msg: if callingDomain.endswith('.onion') and \ self.server.onionDomain: diff --git a/translations/ar.json b/translations/ar.json index d34473dbc..69f840410 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -480,5 +480,8 @@ "You're not allowed": "كنت لا يسمح", "Hours after posting during which replies are allowed": "ساعات بعد النشر المسموح بها خلال الردود", "Twitter": "Twitter", - "Twitter Replacement Domain": "مجال استبدال تويتر" + "Twitter Replacement Domain": "مجال استبدال تويتر", + "Buy": "يشتري", + "Request to stay": "طلب البقاء", + "Profile": "الملف الشخصي" } diff --git a/translations/ca.json b/translations/ca.json index 843a98575..d0197c2e1 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -480,5 +480,8 @@ "You're not allowed": "No està permès", "Hours after posting during which replies are allowed": "Hores després de la publicació durant les respostes", "Twitter": "Twitter", - "Twitter Replacement Domain": "Domini de substitució de Twitter" + "Twitter Replacement Domain": "Domini de substitució de Twitter", + "Buy": "Comprar", + "Request to stay": "Sol·licitud de permanència", + "Profile": "Perfil" } diff --git a/translations/cy.json b/translations/cy.json index 1a994aa59..0d7bb1066 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -480,5 +480,8 @@ "You're not allowed": "Ni chaniateir i chi", "Hours after posting during which replies are allowed": "Oriau ar ôl postio pan ganiateir atebion", "Twitter": "Twitter", - "Twitter Replacement Domain": "Parth Amnewid Twitter" + "Twitter Replacement Domain": "Parth Amnewid Twitter", + "Buy": "Prynu", + "Request to stay": "Cais i aros", + "Profile": "Proffil" } diff --git a/translations/de.json b/translations/de.json index 96a3ed02e..e6a4d765d 100644 --- a/translations/de.json +++ b/translations/de.json @@ -480,5 +480,8 @@ "You're not allowed": "Du darfst nicht", "Hours after posting during which replies are allowed": "Stunden nach dem Posten, während denen Antworten erlaubt sind", "Twitter": "Twitter", - "Twitter Replacement Domain": "Twitter-Ersatzdomain" + "Twitter Replacement Domain": "Twitter-Ersatzdomain", + "Buy": "Besorgen", + "Request to stay": "Bitte um bleiben", + "Profile": "Profil" } diff --git a/translations/en.json b/translations/en.json index bda521e24..f22d47c1a 100644 --- a/translations/en.json +++ b/translations/en.json @@ -480,5 +480,8 @@ "You're not allowed": "You're not allowed", "Hours after posting during which replies are allowed": "Hours after posting during which replies are allowed", "Twitter": "Twitter", - "Twitter Replacement Domain": "Twitter Replacement Domain" + "Twitter Replacement Domain": "Twitter Replacement Domain", + "Buy": "Buy", + "Request to stay": "Request to stay", + "Profile": "Profile" } diff --git a/translations/es.json b/translations/es.json index 6289d706d..342f1b87f 100644 --- a/translations/es.json +++ b/translations/es.json @@ -480,5 +480,8 @@ "You're not allowed": "No tienes permiso", "Hours after posting during which replies are allowed": "Horas después de la publicación durante las cuales se permiten las respuestas", "Twitter": "Twitter", - "Twitter Replacement Domain": "Dominio de reemplazo de Twitter" + "Twitter Replacement Domain": "Dominio de reemplazo de Twitter", + "Buy": "Comprar", + "Request to stay": "Solicitud para quedarse", + "Profile": "Perfil" } diff --git a/translations/fr.json b/translations/fr.json index bc0740aa5..6484a2047 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -480,5 +480,8 @@ "You're not allowed": "Tu n'as pas le droit", "Hours after posting during which replies are allowed": "Heures après la publication pendant laquelle les réponses sont autorisées", "Twitter": "Twitter", - "Twitter Replacement Domain": "Domaine de remplacement Twitter" + "Twitter Replacement Domain": "Domaine de remplacement Twitter", + "Buy": "Acheter", + "Request to stay": "Demande de séjour", + "Profile": "Profil" } diff --git a/translations/ga.json b/translations/ga.json index 04523a53d..27a9e824c 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -480,5 +480,8 @@ "You're not allowed": "Níl cead agat", "Hours after posting during which replies are allowed": "Uair an chloig tar éis an phostála ina gceadaítear freagraí", "Twitter": "Twitter", - "Twitter Replacement Domain": "Fearann Athsholáthair Twitter" + "Twitter Replacement Domain": "Fearann Athsholáthair Twitter", + "Buy": "Ceannaigh", + "Request to stay": "Iarraidh fanacht", + "Profile": "Próifíl" } diff --git a/translations/hi.json b/translations/hi.json index 2a4b1fa90..cc199ea53 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -480,5 +480,8 @@ "You're not allowed": "आपको अनुमति नहीं है", "Hours after posting during which replies are allowed": "पोस्ट करने के कुछ घंटे जिसके बाद जवाब देने की अनुमति है", "Twitter": "Twitter", - "Twitter Replacement Domain": "ट्विटर रिप्लेसमेंट डोमेन" + "Twitter Replacement Domain": "ट्विटर रिप्लेसमेंट डोमेन", + "Buy": "खरीदना", + "Request to stay": "रहने का अनुरोध", + "Profile": "प्रोफ़ाइल" } diff --git a/translations/it.json b/translations/it.json index 3b49e61ff..993eb1a7a 100644 --- a/translations/it.json +++ b/translations/it.json @@ -480,5 +480,8 @@ "You're not allowed": "Non ti è permesso", "Hours after posting during which replies are allowed": "Ore dopo la pubblicazione durante le quali le risposte sono consentite", "Twitter": "Twitter", - "Twitter Replacement Domain": "Dominio sostitutivo di Twitter" + "Twitter Replacement Domain": "Dominio sostitutivo di Twitter", + "Buy": "Acquistare", + "Request to stay": "Richiesta di soggiorno", + "Profile": "Profilo" } diff --git a/translations/ja.json b/translations/ja.json index 6e9fe1871..bb4ee4ecf 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -480,5 +480,8 @@ "You're not allowed": "あなたは許可されていません", "Hours after posting during which replies are allowed": "転記後の時間返信が許可されています", "Twitter": "Twitter", - "Twitter Replacement Domain": "Twitterの代替ドメイン" + "Twitter Replacement Domain": "Twitterの代替ドメイン", + "Buy": "買う", + "Request to stay": "滞在リクエスト", + "Profile": "プロフィール" } diff --git a/translations/ku.json b/translations/ku.json index 423435821..64f741abc 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -480,5 +480,8 @@ "You're not allowed": "Destûrê nadin te", "Hours after posting during which replies are allowed": "Demjimêran piştî şandina di dema bersivê de destûr tê dayîn", "Twitter": "Twitter", - "Twitter Replacement Domain": "Domaina Veguheztina Twitter" + "Twitter Replacement Domain": "Domaina Veguheztina Twitter", + "Buy": "Kirrîn", + "Request to stay": "Daxwaza mayînê bikin", + "Profile": "Tengal" } diff --git a/translations/oc.json b/translations/oc.json index 4e7f888d7..40f496a6c 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -476,5 +476,8 @@ "You're not allowed": "You're not allowed", "Hours after posting during which replies are allowed": "Hours after posting during which replies are allowed", "Twitter": "Twitter", - "Twitter Replacement Domain": "Twitter Replacement Domain" + "Twitter Replacement Domain": "Twitter Replacement Domain", + "Buy": "Buy", + "Request to stay": "Request to stay", + "Profile": "Profile" } diff --git a/translations/pt.json b/translations/pt.json index 4901b4f2c..42e854ed6 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -480,5 +480,8 @@ "You're not allowed": "Você não tem permissão", "Hours after posting during which replies are allowed": "Horas após a postagem durante as quais as respostas são permitidas", "Twitter": "Twitter", - "Twitter Replacement Domain": "Domínio de substituição do Twitter" + "Twitter Replacement Domain": "Domínio de substituição do Twitter", + "Buy": "Comprar", + "Request to stay": "Pedido para ficar", + "Profile": "Perfil" } diff --git a/translations/ru.json b/translations/ru.json index 98b0d3516..58601e6f3 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -480,5 +480,8 @@ "You're not allowed": "Вам не разрешено", "Hours after posting during which replies are allowed": "Часы после размещения, в течение которых разрешены ответы", "Twitter": "Twitter", - "Twitter Replacement Domain": "Замещающий домен Twitter" + "Twitter Replacement Domain": "Замещающий домен Twitter", + "Buy": "Купить", + "Request to stay": "Просьба остаться", + "Profile": "Профиль" } diff --git a/translations/sw.json b/translations/sw.json index 899b4bd16..4c374889a 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -480,5 +480,8 @@ "You're not allowed": "Hauruhusiwi", "Hours after posting during which replies are allowed": "Masaa baada ya kuchapisha wakati majibu yanaruhusiwa.", "Twitter": "Twitter", - "Twitter Replacement Domain": "Kikoa cha Uingizwaji wa Twitter" + "Twitter Replacement Domain": "Kikoa cha Uingizwaji wa Twitter", + "Buy": "Nunua", + "Request to stay": "Omba kukaa", + "Profile": "Profaili" } diff --git a/translations/zh.json b/translations/zh.json index 42f544401..da72e3fb0 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -480,5 +480,8 @@ "You're not allowed": "你不被允许", "Hours after posting during which replies are allowed": "发布后的时间允许答复", "Twitter": "Twitter", - "Twitter Replacement Domain": "Twitter 替换域" + "Twitter Replacement Domain": "Twitter 替换域", + "Buy": "买", + "Request to stay": "要求留下", + "Profile": "轮廓" } diff --git a/utils.py b/utils.py index 4d969d530..e5253f60a 100644 --- a/utils.py +++ b/utils.py @@ -859,7 +859,7 @@ def dangerousMarkup(content: str, allowLocalNetworkAccess: bool) -> bool: """ separators = [['<', '>'], ['<', '>']] invalidStrings = [ - 'script', 'noscript', 'code', + 'script', 'noscript', 'code', 'pre', 'canvas', 'style', 'abbr', 'frame', 'iframe', 'html', 'body', 'hr', 'allow-popups', 'allow-scripts' diff --git a/webapp_search.py b/webapp_search.py index e29a0eee4..48cb02096 100644 --- a/webapp_search.py +++ b/webapp_search.py @@ -178,7 +178,8 @@ def _htmlSharesResult(baseDir: str, htmlSearchResultShare(baseDir, sharedItem, translate, httpPrefix, domainFull, contactNickname, - name, actor, sharesFileType) + name, actor, sharesFileType, + sharedItem['category']) if not resultsExist and currPage > 1: # show the previous page button sharedItemsForm += \ diff --git a/webapp_utils.py b/webapp_utils.py index 307f95fbd..a72615322 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1292,7 +1292,8 @@ def editTextArea(label: str, name: str, value: str = "", def htmlSearchResultShare(baseDir: str, sharedItem: {}, translate: {}, httpPrefix: str, domainFull: str, contactNickname: str, itemID: str, - actor: str, sharesFileType: str) -> str: + actor: str, sharesFileType: str, + category: str) -> str: """Returns the html for an individual shared item """ sharedItemsForm = '
\n' @@ -1319,6 +1320,7 @@ def htmlSearchResultShare(baseDir: str, sharedItem: {}, translate: {}, sharedItemsForm += \ '' + translate['Location'] + ': ' + \ sharedItem['location'] + '
' + contactTitleStr = translate['Contact'] if sharedItem.get('itemPrice') and \ sharedItem.get('itemCurrency'): if isfloat(sharedItem['itemPrice']): @@ -1327,17 +1329,21 @@ def htmlSearchResultShare(baseDir: str, sharedItem: {}, translate: {}, ' ' + translate['Price'] + \ ': ' + sharedItem['itemPrice'] + \ ' ' + sharedItem['itemCurrency'] + contactTitleStr = translate['Buy'] sharedItemsForm += '

\n' contactActor = \ localActorUrl(httpPrefix, contactNickname, domainFull) + if category == 'accommodation': + contactTitleStr = translate['Request to stay'] + sharedItemsForm += \ '

' + \ '\n' + \ '\n' + translate['Profile'] + '\n' # should the remove button be shown? showRemoveButton = False @@ -1372,7 +1378,7 @@ def htmlShowShare(baseDir: str, domain: str, nickname: str, itemID: str, translate: {}, sharedItemsFederatedDomains: [], defaultTimeline: str, theme: str, - sharesFileType: str) -> str: + sharesFileType: str, category: str) -> str: """Shows an individual shared item after selecting it from the left column """ sharesJson = None @@ -1437,7 +1443,7 @@ def htmlShowShare(baseDir: str, domain: str, nickname: str, shareStr += \ htmlSearchResultShare(baseDir, sharedItem, translate, httpPrefix, domainFull, contactNickname, itemID, - actor, sharesFileType) + actor, sharesFileType, category) cssFilename = baseDir + '/epicyon-profile.css' if os.path.isfile(baseDir + '/epicyon.css'):