mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			Tidying
							parent
							
								
									8eb6dbd4c9
								
							
						
					
					
						commit
						7058b6e2db
					
				
							
								
								
									
										8
									
								
								utils.py
								
								
								
								
							
							
						
						
									
										8
									
								
								utils.py
								
								
								
								
							|  | @ -600,6 +600,14 @@ def removeIdEnding(idStr: str) -> str: | ||||||
|     return idStr |     return idStr | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def removeHashFromPostId(postId: str) -> str: | ||||||
|  |     """Removes any has from a post id | ||||||
|  |     """ | ||||||
|  |     if '#' not in postId: | ||||||
|  |         return postId | ||||||
|  |     return postId.split('#')[0] | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def getProtocolPrefixes() -> []: | def getProtocolPrefixes() -> []: | ||||||
|     """Returns a list of valid prefixes |     """Returns a list of valid prefixes | ||||||
|     """ |     """ | ||||||
|  |  | ||||||
|  | @ -23,6 +23,7 @@ from posts import postIsMuted | ||||||
| from posts import getPersonBox | from posts import getPersonBox | ||||||
| from posts import downloadAnnounce | from posts import downloadAnnounce | ||||||
| from posts import populateRepliesJson | from posts import populateRepliesJson | ||||||
|  | from utils import removeHashFromPostId | ||||||
| from utils import removeHtml | from utils import removeHtml | ||||||
| from utils import getActorLanguagesList | from utils import getActorLanguagesList | ||||||
| from utils import getBaseContentFromPost | from utils import getBaseContentFromPost | ||||||
|  | @ -390,11 +391,8 @@ def _getReplyIconHtml(baseDir: str, nickname: str, domain: str, | ||||||
|         return replyStr |         return replyStr | ||||||
| 
 | 
 | ||||||
|     # reply is permitted - create reply icon |     # reply is permitted - create reply icon | ||||||
|     if '#' not in postJsonObject['object']['id']: |     replyToLink = removeHashFromPostId(postJsonObject['object']['id']) | ||||||
|         replyToLink = removeIdEnding(postJsonObject['object']['id']) |     replyToLink = removeIdEnding(replyToLink) | ||||||
|     else: |  | ||||||
|         replyToLink = \ |  | ||||||
|             removeIdEnding(postJsonObject['object']['id'].split('#')[0]) |  | ||||||
| 
 | 
 | ||||||
|     # see Mike MacGirvin's replyTo suggestion |     # see Mike MacGirvin's replyTo suggestion | ||||||
|     if postJsonObject['object'].get('replyTo'): |     if postJsonObject['object'].get('replyTo'): | ||||||
|  | @ -575,11 +573,8 @@ def _getAnnounceIconHtml(isAnnounced: bool, | ||||||
|             unannounceLinkStr = '?unannounce=' + \ |             unannounceLinkStr = '?unannounce=' + \ | ||||||
|                 removeIdEnding(announceJsonObject['id']) |                 removeIdEnding(announceJsonObject['id']) | ||||||
| 
 | 
 | ||||||
|     if '#' not in postJsonObject['object']['id']: |     announcePostId = removeHashFromPostId(postJsonObject['object']['id']) | ||||||
|         announcePostId = removeIdEnding(postJsonObject['object']['id']) |     announcePostId = removeIdEnding(announcePostId) | ||||||
|     else: |  | ||||||
|         announcePostId = \ |  | ||||||
|             removeIdEnding(postJsonObject['object']['id'].split('#')[0]) |  | ||||||
|     announceLinkStr = '?' + \ |     announceLinkStr = '?' + \ | ||||||
|         announceLink + '=' + announcePostId + pageNumberParam |         announceLink + '=' + announcePostId + pageNumberParam | ||||||
|     announceStr = \ |     announceStr = \ | ||||||
|  | @ -647,10 +642,8 @@ def _getLikeIconHtml(nickname: str, domainFull: str, | ||||||
|         likeStr += '<label class="likesCount">' |         likeStr += '<label class="likesCount">' | ||||||
|         likeStr += likeCountStr.replace('(', '').replace(')', '').strip() |         likeStr += likeCountStr.replace('(', '').replace(')', '').strip() | ||||||
|         likeStr += '</label>\n' |         likeStr += '</label>\n' | ||||||
|     if '#' not in postJsonObject['id']: |     likePostId = removeHashFromPostId(postJsonObject['id']) | ||||||
|         likePostId = removeIdEnding(postJsonObject['id']) |     likePostId = removeIdEnding(likePostId) | ||||||
|     else: |  | ||||||
|         likePostId = removeIdEnding(postJsonObject['id'].split('#')[0]) |  | ||||||
|     likeStr += \ |     likeStr += \ | ||||||
|         '        <a class="imageAnchor" href="/users/' + nickname + '?' + \ |         '        <a class="imageAnchor" href="/users/' + nickname + '?' + \ | ||||||
|         likeLink + '=' + likePostId + \ |         likeLink + '=' + likePostId + \ | ||||||
|  | @ -696,11 +689,8 @@ def _getBookmarkIconHtml(nickname: str, domainFull: str, | ||||||
|         if translate.get(bookmarkTitle): |         if translate.get(bookmarkTitle): | ||||||
|             bookmarkTitle = translate[bookmarkTitle] |             bookmarkTitle = translate[bookmarkTitle] | ||||||
|     _logPostTiming(enableTimingLog, postStartTime, '12.6') |     _logPostTiming(enableTimingLog, postStartTime, '12.6') | ||||||
|     if '#' not in postJsonObject['object']['id']: |     bookmarkPostId = removeHashFromPostId(postJsonObject['object']['id']) | ||||||
|         bookmarkPostId = removeIdEnding(postJsonObject['object']['id']) |     bookmarkPostId = removeIdEnding(bookmarkPostId) | ||||||
|     else: |  | ||||||
|         bookmarkPostId = \ |  | ||||||
|             removeIdEnding(postJsonObject['object']['id'].split('#')[0]) |  | ||||||
|     bookmarkStr = \ |     bookmarkStr = \ | ||||||
|         '        <a class="imageAnchor" href="/users/' + nickname + '?' + \ |         '        <a class="imageAnchor" href="/users/' + nickname + '?' + \ | ||||||
|         bookmarkLink + '=' + bookmarkPostId + \ |         bookmarkLink + '=' + bookmarkPostId + \ | ||||||
|  | @ -737,11 +727,8 @@ def _getReactionIconHtml(nickname: str, domainFull: str, | ||||||
|     if translate.get(reactionTitle): |     if translate.get(reactionTitle): | ||||||
|         reactionTitle = translate[reactionTitle] |         reactionTitle = translate[reactionTitle] | ||||||
|     _logPostTiming(enableTimingLog, postStartTime, '12.65') |     _logPostTiming(enableTimingLog, postStartTime, '12.65') | ||||||
|     if '#' not in postJsonObject['object']['id']: |     reactionPostId = removeHashFromPostId(postJsonObject['object']['id']) | ||||||
|         reactionPostId = removeIdEnding(postJsonObject['object']['id']) |     reactionPostId = removeIdEnding(reactionPostId) | ||||||
|     else: |  | ||||||
|         reactionPostId = \ |  | ||||||
|             removeIdEnding(postJsonObject['object']['id'].split('#')[0]) |  | ||||||
|     reactionStr = \ |     reactionStr = \ | ||||||
|         '        <a class="imageAnchor" href="/users/' + nickname + \ |         '        <a class="imageAnchor" href="/users/' + nickname + \ | ||||||
|         '?selreact=' + reactionPostId + pageNumberParam + \ |         '?selreact=' + reactionPostId + pageNumberParam + \ | ||||||
|  | @ -1383,10 +1370,8 @@ def individualPostAsHtml(signingPrivateKeyPem: str, | ||||||
|     avatarPosition = '' |     avatarPosition = '' | ||||||
|     messageId = '' |     messageId = '' | ||||||
|     if postJsonObject.get('id'): |     if postJsonObject.get('id'): | ||||||
|         if '#' not in postJsonObject['id']: |         messageId = removeHashFromPostId(postJsonObject['id']) | ||||||
|             messageId = removeIdEnding(postJsonObject['id']) |         messageId = removeIdEnding(messageId) | ||||||
|         else: |  | ||||||
|             messageId = removeIdEnding(postJsonObject['id'].split('#')[0]) |  | ||||||
| 
 | 
 | ||||||
|     _logPostTiming(enableTimingLog, postStartTime, '2') |     _logPostTiming(enableTimingLog, postStartTime, '2') | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue