From 3e26f5f7459d220eb3ce68a938a320484b9d796e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 1 Oct 2020 18:26:21 +0100 Subject: [PATCH] Edit links button --- epicyon-profile.css | 17 ++++++++ translations/ar.json | 4 +- translations/ca.json | 4 +- translations/cy.json | 4 +- translations/de.json | 4 +- translations/en.json | 4 +- translations/es.json | 4 +- translations/fr.json | 4 +- translations/ga.json | 4 +- translations/hi.json | 4 +- translations/it.json | 4 +- translations/ja.json | 4 +- translations/oc.json | 4 +- translations/pt.json | 4 +- translations/ru.json | 4 +- translations/zh.json | 4 +- webinterface.py | 101 ++++++++++++++++++++++++++++++++++++++++--- 17 files changed, 157 insertions(+), 21 deletions(-) diff --git a/epicyon-profile.css b/epicyon-profile.css index 14ca13dd..5ae53f19 100644 --- a/epicyon-profile.css +++ b/epicyon-profile.css @@ -131,6 +131,23 @@ a, u { color: var(--main-fg-color); } +.editLinksBtn { + border-radius: var(--button-corner-radius); + background-color: var(--button-background); + border: none; + color: var(--button-text); + text-align: center; + font-size: var(--font-size-header); + font-family: Arial, Helvetica, sans-serif; + padding: var(--button-height-padding); + width: 90%; + max-width: 200px; + min-width: 10ch; + transition: all 0.5s; + cursor: pointer; + margin: 5px; +} + a:visited{ color: var(--main-visited-color); background: var(--link-bg-color); diff --git a/translations/ar.json b/translations/ar.json index 3dca12e1..4e69f628 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "تحذيرات المحتوى المُنشأ تلقائيًا", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag محظور", - "This is a blogging instance": "هذا مثال على المدونات" + "This is a blogging instance": "هذا مثال على المدونات", + "Edit Links": "تحرير الارتباطات", + "One link per line. Description followed by the link.": "رابط واحد في كل سطر. الوصف متبوع بالرابط." } diff --git a/translations/ca.json b/translations/ca.json index 01717603..11d3b6d2 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Advertiments de contingut autogenerats", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag bloquejat", - "This is a blogging instance": "Aquesta és una instància de blocs" + "This is a blogging instance": "Aquesta és una instància de blocs", + "Edit Links": "Edita els enllaços", + "One link per line. Description followed by the link.": "Un enllaç per línia. Descripció seguida de l'enllaç." } diff --git a/translations/cy.json b/translations/cy.json index 65052098..af176ce0 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Rhybuddion Cynnwys Autogenerated", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag wedi'i Blocio", - "This is a blogging instance": "Dyma enghraifft blogio" + "This is a blogging instance": "Dyma enghraifft blogio", + "Edit Links": "Golygu Dolenni", + "One link per line. Description followed by the link.": "Un dolen y llinell. Disgrifiad wedi'i ddilyn gan y ddolen." } diff --git a/translations/de.json b/translations/de.json index 619f00cf..2ba4f527 100644 --- a/translations/de.json +++ b/translations/de.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Warnungen vor automatisch generierten Inhalten", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag blockiert", - "This is a blogging instance": "Dies ist eine Blogging-Instanz" + "This is a blogging instance": "Dies ist eine Blogging-Instanz", + "Edit Links": "Links bearbeiten", + "One link per line. Description followed by the link.": "Ein Link pro Zeile. Beschreibung gefolgt vom Link." } diff --git a/translations/en.json b/translations/en.json index ff911e7d..6beb40bb 100644 --- a/translations/en.json +++ b/translations/en.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Autogenerated Content Warnings", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag Blocked", - "This is a blogging instance": "This is a blogging instance" + "This is a blogging instance": "This is a blogging instance", + "Edit Links": "Edit Links", + "One link per line. Description followed by the link.": "One link per line. Description followed by the link." } diff --git a/translations/es.json b/translations/es.json index 00dc1ab3..937b3e01 100644 --- a/translations/es.json +++ b/translations/es.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Advertencias de contenido generado automáticamente", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag bloqueada", - "This is a blogging instance": "Esta es una instancia de blogs" + "This is a blogging instance": "Esta es una instancia de blogs", + "Edit Links": "Editar enlaces", + "One link per line. Description followed by the link.": "Un enlace por línea. Descripción seguida del enlace." } diff --git a/translations/fr.json b/translations/fr.json index 8318d3a3..c3a82bdf 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Avertissements de contenu générés automatiquement", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag bloqué", - "This is a blogging instance": "Ceci est une instance de blog" + "This is a blogging instance": "Ceci est une instance de blog", + "Edit Links": "Modifier les liens", + "One link per line. Description followed by the link.": "Un lien par ligne. Description suivie du lien." } diff --git a/translations/ga.json b/translations/ga.json index 96c8f197..8bcab8a6 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Rabhaidh Ábhar Uathghinte", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag Blocáilte", - "This is a blogging instance": "Seo sampla blagála" + "This is a blogging instance": "Seo sampla blagála", + "Edit Links": "Cuir Naisc in eagar", + "One link per line. Description followed by the link.": "Nasc amháin in aghaidh an líne. Cur síos agus an nasc ina dhiaidh sin." } diff --git a/translations/hi.json b/translations/hi.json index 6a6c7a6a..d8366327 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "स्वतः प्राप्त सामग्री चेतावनी", "Indymedia": "Indymedia", "Hashtag Blocked": "हैशटैग अवरुद्ध", - "This is a blogging instance": "यह एक ब्लॉगिंग उदाहरण है" + "This is a blogging instance": "यह एक ब्लॉगिंग उदाहरण है", + "Edit Links": "लिंक संपादित करें", + "One link per line. Description followed by the link.": "प्रति पंक्ति एक लिंक। लिंक के बाद विवरण।" } diff --git a/translations/it.json b/translations/it.json index 63c0d3c8..788f2eef 100644 --- a/translations/it.json +++ b/translations/it.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Avvisi sui contenuti generati automaticamente", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag bloccato", - "This is a blogging instance": "Questa è un'istanza di blog" + "This is a blogging instance": "Questa è un'istanza di blog", + "Edit Links": "Modifica collegamenti", + "One link per line. Description followed by the link.": "Un collegamento per riga. Descrizione seguita dal collegamento." } diff --git a/translations/ja.json b/translations/ja.json index 9849e09b..7e1aa4a0 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "自動生成されたコンテンツの警告", "Indymedia": "Indymedia", "Hashtag Blocked": "ハッシュタグがブロックされました", - "This is a blogging instance": "これはブログのインスタンスです" + "This is a blogging instance": "これはブログのインスタンスです", + "Edit Links": "リンクの編集", + "One link per line. Description followed by the link.": "1行に1つのリンク。 説明の後にリンクが続きます。" } diff --git a/translations/oc.json b/translations/oc.json index 196cfb82..76d2807c 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -284,5 +284,7 @@ "Autogenerated Content Warnings": "Autogenerated Content Warnings", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag Blocked", - "This is a blogging instance": "This is a blogging instance" + "This is a blogging instance": "This is a blogging instance", + "Edit Links": "Edit Links", + "One link per line. Description followed by the link.": "One link per line. Description followed by the link." } diff --git a/translations/pt.json b/translations/pt.json index 8c7535c9..6b5c23bd 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Avisos de conteúdo gerado automaticamente", "Indymedia": "Indymedia", "Hashtag Blocked": "Hashtag bloqueada", - "This is a blogging instance": "Esta é uma instância de blog" + "This is a blogging instance": "Esta é uma instância de blog", + "Edit Links": "Editar Links", + "One link per line. Description followed by the link.": "Um link por linha. Descrição seguida pelo link." } diff --git a/translations/ru.json b/translations/ru.json index acacc35f..16ff6436 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "Автоматические предупреждения о содержании", "Indymedia": "Indymedia", "Hashtag Blocked": "Хештег заблокирован", - "This is a blogging instance": "Это экземпляр блога" + "This is a blogging instance": "Это экземпляр блога", + "Edit Links": "Редактировать ссылки", + "One link per line. Description followed by the link.": "По одной ссылке в строке. Описание с последующей ссылкой." } diff --git a/translations/zh.json b/translations/zh.json index 606ade75..b09145a6 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -288,5 +288,7 @@ "Autogenerated Content Warnings": "自动生成的内容警告", "Indymedia": "Indymedia", "Hashtag Blocked": "标签被阻止", - "This is a blogging instance": "这是一个博客实例" + "This is a blogging instance": "这是一个博客实例", + "Edit Links": "编辑连结", + "One link per line. Description followed by the link.": "每行一个链接。 描述,然后是链接。" } diff --git a/webinterface.py b/webinterface.py index fba7e676..59706b6c 100644 --- a/webinterface.py +++ b/webinterface.py @@ -1206,6 +1206,79 @@ def scheduledPostsExist(baseDir: str, nickname: str, domain: str) -> bool: return False +def htmlEditLinks(translate: {}, baseDir: str, path: str, + domain: str, port: int, httpPrefix: str) -> str: + """Shows the edit links screen + """ + if '/users/' not in path: + return '' + pathOriginal = path + path = path.replace('/inbox', '').replace('/outbox', '') + path = path.replace('/shares', '') + + nickname = getNicknameFromActor(path) + if not nickname: + return '' + + domainFull = domain + if port: + if port != 80 and port != 443: + if ':' not in domain: + domainFull = domain + ':' + str(port) + + # is the user a moderator? + if not isModerator(baseDir, nickname): + return '' + + cssFilename = baseDir + '/epicyon-links.css' + if os.path.isfile(baseDir + '/links.css'): + cssFilename = baseDir + '/links.css' + with open(cssFilename, 'r') as cssFile: + editCSS = cssFile.read() + if httpPrefix != 'https': + editCSS = \ + editCSS.replace('https://', httpPrefix + '://') + + editLinksForm = htmlHeader(cssFilename, editCSS) + editLinksForm += \ + '
\n' + editLinksForm += \ + '
\n' + editLinksForm += \ + '

' + translate['Edit Links'] + '

' + editLinksForm += \ + '
\n' + editLinksForm += \ + ' \n' + editLinksForm += \ + ' \n' + editLinksForm += \ + '
\n' + + linksFilename = baseDir + '/accounts/links.txt' + linksStr = '' + if os.path.isfile(linksFilename): + with open(linksFilename, 'r') as fp: + linksStr = fp.read() + + editLinksForm = \ + '
' + editLinksForm += \ + ' ' + \ + translate['One link per line. Description followed by the link.'] + editLinksForm += \ + ' ' + editLinksForm += \ + '
' + + editLinksForm += htmlFooter() + return editLinksForm + + def htmlEditProfile(translate: {}, baseDir: str, path: str, domain: str, port: int, httpPrefix: str) -> str: """Shows the edit profile screen @@ -5077,15 +5150,23 @@ def htmlHighlightLabel(label: str, highlight: bool) -> str: return '*' + label + '*' -def getLeftColumContent(baseDir: str, nickname: str, domain: str) -> str: +def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str, + httpPrefix: str, translate: {}) -> str: """Returns html content for the left column """ - htmlStr = '' - # TODO + htmlStr = \ + '
\n' + \ + ' ' + \ + '\n' + \ + '
\n' + return htmlStr -def getRightColumContent(baseDir: str, nickname: str, domain: str) -> str: +def getRightColumnContent(baseDir: str, nickname: str, domain: str) -> str: """Returns html content for the right column """ htmlStr = '' @@ -5393,8 +5474,16 @@ def htmlTimeline(defaultTimeline: str, tlStr += ' \n' tlStr += ' \n' tlStr += ' \n' + + domainFull = domain + if port: + if port != 80 and port != 443: + domainFull = domain + ':' + str(port) + # left column - leftColumnStr = getLeftColumContent(baseDir, nickname, domain) + leftColumnStr = \ + getLeftColumnContent(baseDir, nickname, domainFull, + httpPrefix, translate) tlStr += ' ' + leftColumnStr + '\n' # center column containing posts tlStr += ' \n' @@ -5702,7 +5791,7 @@ def htmlTimeline(defaultTimeline: str, tlStr += ' \n' # right column - rightColumnStr = getRightColumContent(baseDir, nickname, domain) + rightColumnStr = getRightColumnContent(baseDir, nickname, domain) tlStr += ' ' + rightColumnStr + '\n' # benchmark 9