mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Left column image
							parent
							
								
									e43c94b8c7
								
							
						
					
					
						commit
						0842ba713c
					
				
							
								
								
									
										71
									
								
								daemon.py
								
								
								
								
							
							
						
						
									
										71
									
								
								daemon.py
								
								
								
								
							|  | @ -2865,7 +2865,8 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|             actorChanged = True |             actorChanged = True | ||||||
|             profileMediaTypes = ('avatar', 'image', |             profileMediaTypes = ('avatar', 'image', | ||||||
|                                  'banner', 'search_banner', |                                  'banner', 'search_banner', | ||||||
|                                  'instanceLogo') |                                  'instanceLogo', | ||||||
|  |                                  'left_col_image', 'right_col_image') | ||||||
|             profileMediaTypesUploaded = {} |             profileMediaTypesUploaded = {} | ||||||
|             for mType in profileMediaTypes: |             for mType in profileMediaTypes: | ||||||
|                 if debug: |                 if debug: | ||||||
|  | @ -7154,6 +7155,44 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|         self._404() |         self._404() | ||||||
|         return True |         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, |     def _showBackgroundImage(self, callingDomain: str, path: str, | ||||||
|                              baseDir: str, |                              baseDir: str, | ||||||
|                              GETstartTime, GETtimings: {}) -> bool: |                              GETstartTime, GETtimings: {}) -> bool: | ||||||
|  | @ -8094,13 +8133,29 @@ class PubServer(BaseHTTPRequestHandler): | ||||||
|                                   'account qrcode done') |                                   'account qrcode done') | ||||||
| 
 | 
 | ||||||
|         # search screen banner image |         # search screen banner image | ||||||
|         if '/users/' in self.path and \ |         if '/users/' in self.path: | ||||||
|            self.path.endswith('/search_banner.png'): |             if self.path.endswith('/search_banner.png'): | ||||||
|             if self._searchScreenBanner(callingDomain, self.path, |                 if self._searchScreenBanner(callingDomain, self.path, | ||||||
|                                         self.server.baseDir, |                                             self.server.baseDir, | ||||||
|                                         self.server.domain, |                                             self.server.domain, | ||||||
|                                         self.server.port, |                                             self.server.port, | ||||||
|                                         GETstartTime, GETtimings): |                                             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 |                 return | ||||||
| 
 | 
 | ||||||
|         self._benchmarkGETtimings(GETstartTime, GETtimings, |         self._benchmarkGETtimings(GETstartTime, GETtimings, | ||||||
|  |  | ||||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 3.6 KiB | 
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag محظور", |     "Hashtag Blocked": "Hashtag محظور", | ||||||
|     "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.": "رابط واحد في كل سطر. الوصف متبوع بالرابط.", | ||||||
|  |     "Left column image": "", | ||||||
|  |     "Right column image": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag bloquejat", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag wedi'i Blocio", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag blockiert", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag Blocked", |     "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", |     "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" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag bloqueada", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag bloqué", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag Blocáilte", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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.": "प्रति पंक्ति एक लिंक। लिंक के बाद विवरण।", | ||||||
|  |     "Left column image": "", | ||||||
|  |     "Right column image": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag bloccato", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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.": "1行に1つのリンク。 説明の後にリンクが続きます。" |     "One link per line. Description followed by the link.": "1行に1つのリンク。 説明の後にリンクが続きます。", | ||||||
|  |     "Left column image": "", | ||||||
|  |     "Right column image": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -286,5 +286,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag Blocked", |     "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", |     "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" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -290,5 +290,7 @@ | ||||||
|     "Hashtag Blocked": "Hashtag bloqueada", |     "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", |     "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": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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.": "По одной ссылке в строке. Описание с последующей ссылкой.", | ||||||
|  |     "Left column image": "", | ||||||
|  |     "Right column image": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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.": "每行一个链接。 描述,然后是链接。", | ||||||
|  |     "Left column image": "", | ||||||
|  |     "Right column image": "" | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1675,6 +1675,18 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str, | ||||||
|     editProfileForm += 'name="search_banner"' |     editProfileForm += 'name="search_banner"' | ||||||
|     editProfileForm += '            accept="' + imageFormats + '">\n' |     editProfileForm += '            accept="' + imageFormats + '">\n' | ||||||
| 
 | 
 | ||||||
|  |     editProfileForm += '      <br><label class="labels">' + \ | ||||||
|  |         translate['Left column image'] + '</label>\n' | ||||||
|  |     editProfileForm += '      <input type="file" id="left_col_image" ' | ||||||
|  |     editProfileForm += 'name="left_col_image"' | ||||||
|  |     editProfileForm += '            accept="' + imageFormats + '">\n' | ||||||
|  | 
 | ||||||
|  |     editProfileForm += '      <br><label class="labels">' + \ | ||||||
|  |         translate['Right column image'] + '</label>\n' | ||||||
|  |     editProfileForm += '      <input type="file" id="right_col_image" ' | ||||||
|  |     editProfileForm += 'name="right_col_image"' | ||||||
|  |     editProfileForm += '            accept="' + imageFormats + '">\n' | ||||||
|  | 
 | ||||||
|     editProfileForm += '    </div>\n' |     editProfileForm += '    </div>\n' | ||||||
|     editProfileForm += '    <div class="container">\n' |     editProfileForm += '    <div class="container">\n' | ||||||
|     editProfileForm += \ |     editProfileForm += \ | ||||||
|  | @ -5151,6 +5163,31 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str, | ||||||
|     """Returns html content for the left column |     """Returns html content for the left column | ||||||
|     """ |     """ | ||||||
|     htmlStr = '' |     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 += \ | ||||||
|  |             '      <center>\n' + \ | ||||||
|  |             '        <img loading="lazy" src="/left_col_image.png" />\n' + \ | ||||||
|  |             '      </center>\n' | ||||||
|  | 
 | ||||||
|     if moderator: |     if moderator: | ||||||
|         htmlStr += \ |         htmlStr += \ | ||||||
|             '      <center>\n' + \ |             '      <center>\n' + \ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue