diff --git a/daemon.py b/daemon.py index 3a744a62d..748006a4f 100644 --- a/daemon.py +++ b/daemon.py @@ -2865,7 +2865,8 @@ class PubServer(BaseHTTPRequestHandler): actorChanged = True profileMediaTypes = ('avatar', 'image', 'banner', 'search_banner', - 'instanceLogo') + 'instanceLogo', + 'left_col_image', 'right_col_image') profileMediaTypesUploaded = {} for mType in profileMediaTypes: if debug: @@ -7154,6 +7155,44 @@ class PubServer(BaseHTTPRequestHandler): self._404() return True + def _columImage(self, side: str, callingDomain: str, path: str, + baseDir: str, domain: str, port: int, + GETstartTime, GETtimings: {}) -> bool: + """Shows an image at the top of the left/right column + """ + nickname = getNicknameFromActor(path) + bannerFilename = \ + baseDir + '/accounts/' + \ + nickname + '@' + domain + '/' + side + '_col_image.png' + if os.path.isfile(bannerFilename): + if self._etag_exists(bannerFilename): + # The file has not changed + self._304() + return True + + tries = 0 + mediaBinary = None + while tries < 5: + try: + with open(bannerFilename, 'rb') as avFile: + mediaBinary = avFile.read() + break + except Exception as e: + print(e) + time.sleep(1) + tries += 1 + if mediaBinary: + self._set_headers_etag(bannerFilename, 'image/png', + mediaBinary, None, + callingDomain) + self._write(mediaBinary) + self._benchmarkGETtimings(GETstartTime, GETtimings, + 'account qrcode done', + side + ' col image') + return True + self._404() + return True + def _showBackgroundImage(self, callingDomain: str, path: str, baseDir: str, GETstartTime, GETtimings: {}) -> bool: @@ -8094,13 +8133,29 @@ class PubServer(BaseHTTPRequestHandler): 'account qrcode done') # search screen banner image - if '/users/' in self.path and \ - self.path.endswith('/search_banner.png'): - if self._searchScreenBanner(callingDomain, self.path, - self.server.baseDir, - self.server.domain, - self.server.port, - GETstartTime, GETtimings): + if '/users/' in self.path: + if self.path.endswith('/search_banner.png'): + if self._searchScreenBanner(callingDomain, self.path, + self.server.baseDir, + self.server.domain, + self.server.port, + GETstartTime, GETtimings): + return + + if self.path.endswith('/left_col_image.png'): + if self._columImage('left', callingDomain, self.path, + self.server.baseDir, + self.server.domain, + self.server.port, + GETstartTime, GETtimings): + return + + if self.path.endswith('/right_col_image.png'): + if self._columImage('right', callingDomain, self.path, + self.server.baseDir, + self.server.domain, + self.server.port, + GETstartTime, GETtimings): return self._benchmarkGETtimings(GETstartTime, GETtimings, diff --git a/img/left_col_image_indymedia.png b/img/left_col_image_indymedia.png new file mode 100644 index 000000000..173e847ab Binary files /dev/null and b/img/left_col_image_indymedia.png differ diff --git a/translations/ar.json b/translations/ar.json index 4e69f6281..35634ece0 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag محظور", "This is a blogging instance": "هذا مثال على المدونات", "Edit Links": "تحرير الارتباطات", - "One link per line. Description followed by the link.": "رابط واحد في كل سطر. الوصف متبوع بالرابط." + "One link per line. Description followed by the link.": "رابط واحد في كل سطر. الوصف متبوع بالرابط.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/ca.json b/translations/ca.json index 11d3b6d20..7077f8b88 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag bloquejat", "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ç." + "One link per line. Description followed by the link.": "Un enllaç per línia. Descripció seguida de l'enllaç.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/cy.json b/translations/cy.json index af176ce07..b77018368 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag wedi'i Blocio", "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." + "One link per line. Description followed by the link.": "Un dolen y llinell. Disgrifiad wedi'i ddilyn gan y ddolen.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/de.json b/translations/de.json index 2ba4f5272..c7e6ff49a 100644 --- a/translations/de.json +++ b/translations/de.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag blockiert", "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." + "One link per line. Description followed by the link.": "Ein Link pro Zeile. Beschreibung gefolgt vom Link.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/en.json b/translations/en.json index 812b1a09b..8f2228f73 100644 --- a/translations/en.json +++ b/translations/en.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag Blocked", "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. Titles should begin with #" + "One link per line. Description followed by the link.": "One link per line. Description followed by the link. Titles should begin with #", + "Left column image": "Left column image", + "Right column image": "Right column image" } diff --git a/translations/es.json b/translations/es.json index 937b3e01d..ae479ee3f 100644 --- a/translations/es.json +++ b/translations/es.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag bloqueada", "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." + "One link per line. Description followed by the link.": "Un enlace por línea. Descripción seguida del enlace.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/fr.json b/translations/fr.json index c3a82bdfd..72bd25fd4 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag bloqué", "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." + "One link per line. Description followed by the link.": "Un lien par ligne. Description suivie du lien.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/ga.json b/translations/ga.json index 8bcab8a68..a8ed8e162 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag Blocáilte", "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." + "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.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/hi.json b/translations/hi.json index d8366327a..540284df4 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "हैशटैग अवरुद्ध", "This is a blogging instance": "यह एक ब्लॉगिंग उदाहरण है", "Edit Links": "लिंक संपादित करें", - "One link per line. Description followed by the link.": "प्रति पंक्ति एक लिंक। लिंक के बाद विवरण।" + "One link per line. Description followed by the link.": "प्रति पंक्ति एक लिंक। लिंक के बाद विवरण।", + "Left column image": "", + "Right column image": "" } diff --git a/translations/it.json b/translations/it.json index 788f2eef2..f37e2df3c 100644 --- a/translations/it.json +++ b/translations/it.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag bloccato", "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." + "One link per line. Description followed by the link.": "Un collegamento per riga. Descrizione seguita dal collegamento.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/ja.json b/translations/ja.json index 7e1aa4a08..c11c56383 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "ハッシュタグがブロックされました", "This is a blogging instance": "これはブログのインスタンスです", "Edit Links": "リンクの編集", - "One link per line. Description followed by the link.": "1行に1つのリンク。 説明の後にリンクが続きます。" + "One link per line. Description followed by the link.": "1行に1つのリンク。 説明の後にリンクが続きます。", + "Left column image": "", + "Right column image": "" } diff --git a/translations/oc.json b/translations/oc.json index 82f4ed3be..fd8656071 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -286,5 +286,7 @@ "Hashtag Blocked": "Hashtag Blocked", "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. Titles should begin with #" + "One link per line. Description followed by the link.": "One link per line. Description followed by the link. Titles should begin with #", + "Left column image": "Left column image", + "Right column image": "Right column image" } diff --git a/translations/pt.json b/translations/pt.json index 6b5c23bdd..a2e2280b4 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Hashtag bloqueada", "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." + "One link per line. Description followed by the link.": "Um link por linha. Descrição seguida pelo link.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/ru.json b/translations/ru.json index 16ff64360..7ea8d1306 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "Хештег заблокирован", "This is a blogging instance": "Это экземпляр блога", "Edit Links": "Редактировать ссылки", - "One link per line. Description followed by the link.": "По одной ссылке в строке. Описание с последующей ссылкой." + "One link per line. Description followed by the link.": "По одной ссылке в строке. Описание с последующей ссылкой.", + "Left column image": "", + "Right column image": "" } diff --git a/translations/zh.json b/translations/zh.json index b09145a61..435e95ce1 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -290,5 +290,7 @@ "Hashtag Blocked": "标签被阻止", "This is a blogging instance": "这是一个博客实例", "Edit Links": "编辑连结", - "One link per line. Description followed by the link.": "每行一个链接。 描述,然后是链接。" + "One link per line. Description followed by the link.": "每行一个链接。 描述,然后是链接。", + "Left column image": "", + "Right column image": "" } diff --git a/webinterface.py b/webinterface.py index 06faeb502..4137b1734 100644 --- a/webinterface.py +++ b/webinterface.py @@ -1675,6 +1675,18 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str, editProfileForm += 'name="search_banner"' editProfileForm += ' accept="' + imageFormats + '">\n' + editProfileForm += '
\n' + editProfileForm += ' \n' + + editProfileForm += '
\n' + editProfileForm += ' \n' + editProfileForm += ' \n' editProfileForm += '
\n' editProfileForm += \ @@ -5151,6 +5163,31 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str, """Returns html content for the left column """ htmlStr = '' + + domain = domainFull + if ':' in domain: + domain = domain.split(':') + + leftColumnImageFilename = \ + baseDir + '/accounts/' + nickname + '@' + domain + \ + '/left_col_image.png' + if not os.path.isfile(leftColumnImageFilename): + theme = getConfigParam(baseDir, 'theme').lower() + if theme == 'default': + theme = '' + else: + theme = '_' + theme + themeLeftColumnImageFilename = \ + baseDir + '/img/left_col_image' + theme + '.png' + if os.path.isfile(themeLeftColumnImageFilename): + copyfile(themeLeftColumnImageFilename, leftColumnImageFilename) + + if os.path.isfile(leftColumnImageFilename): + htmlStr += \ + '
\n' + \ + ' \n' + \ + '
\n' + if moderator: htmlStr += \ '
\n' + \