forked from indymedia/epicyon
				
			Separate function for citations
							parent
							
								
									fb7c633851
								
							
						
					
					
						commit
						95042c3d1d
					
				|  | @ -602,6 +602,36 @@ def getPublishedDateStr(postJsonObject: {}, | ||||||
|     return publishedStr |     return publishedStr | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def getBlogCitationsHtml(boxName: str, | ||||||
|  |                          postJsonObject: {}, | ||||||
|  |                          translate: {}) -> str: | ||||||
|  |     """Returns blog citations as html | ||||||
|  |     """ | ||||||
|  |     # show blog citations | ||||||
|  |     citationsStr = '' | ||||||
|  |     if boxName == 'tlblogs' or boxName == 'tlfeatures': | ||||||
|  |         if postJsonObject['object'].get('tag'): | ||||||
|  |             for tagJson in postJsonObject['object']['tag']: | ||||||
|  |                 if not isinstance(tagJson, dict): | ||||||
|  |                     continue | ||||||
|  |                 if not tagJson.get('type'): | ||||||
|  |                     continue | ||||||
|  |                 if tagJson['type'] != 'Article': | ||||||
|  |                     continue | ||||||
|  |                 if not tagJson.get('name'): | ||||||
|  |                     continue | ||||||
|  |                 if not tagJson.get('url'): | ||||||
|  |                     continue | ||||||
|  |                 citationsStr += \ | ||||||
|  |                     '<li><a href="' + tagJson['url'] + '">' + \ | ||||||
|  |                     '<cite>' + tagJson['name'] + '</cite></a></li>\n' | ||||||
|  |             if citationsStr: | ||||||
|  |                 citationsStr = '<p><b>' + translate['Citations'] + \ | ||||||
|  |                     ':</b></p>' + \ | ||||||
|  |                     '<ul>\n' + citationsStr + '</ul>\n' | ||||||
|  |     return citationsStr | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def individualPostAsHtml(allowDownloads: bool, | def individualPostAsHtml(allowDownloads: bool, | ||||||
|                          recentPostsCache: {}, maxRecentPosts: int, |                          recentPostsCache: {}, maxRecentPosts: int, | ||||||
|                          iconsPath: str, translate: {}, |                          iconsPath: str, translate: {}, | ||||||
|  | @ -874,15 +904,16 @@ def individualPostAsHtml(allowDownloads: bool, | ||||||
|                               postJsonObject, actorNickname, |                               postJsonObject, actorNickname, | ||||||
|                               translate, iconsPath, isEvent) |                               translate, iconsPath, isEvent) | ||||||
| 
 | 
 | ||||||
|     announceStr = getAnnounceIconHtml(nickname, domainFull, |     announceStr = \ | ||||||
|                                       postJsonObject, |         getAnnounceIconHtml(nickname, domainFull, | ||||||
|                                       isPublicRepeat, |                             postJsonObject, | ||||||
|                                       isModerationPost, |                             isPublicRepeat, | ||||||
|                                       showRepeatIcon, |                             isModerationPost, | ||||||
|                                       translate, |                             showRepeatIcon, | ||||||
|                                       pageNumberParam, |                             translate, | ||||||
|                                       timelinePostBookmark, |                             pageNumberParam, | ||||||
|                                       boxName, iconsPath) |                             timelinePostBookmark, | ||||||
|  |                             boxName, iconsPath) | ||||||
| 
 | 
 | ||||||
|     # benchmark 12 |     # benchmark 12 | ||||||
|     if enableTimingLog: |     if enableTimingLog: | ||||||
|  | @ -1426,27 +1457,8 @@ def individualPostAsHtml(allowDownloads: bool, | ||||||
|                 '</code></pre></div>\n' |                 '</code></pre></div>\n' | ||||||
| 
 | 
 | ||||||
|     # show blog citations |     # show blog citations | ||||||
|     citationsStr = '' |     citationsStr = \ | ||||||
|     if boxName == 'tlblogs' or boxName == 'tlfeatures': |         getBlogCitationsHtml(boxName, postJsonObject, translate) | ||||||
|         if postJsonObject['object'].get('tag'): |  | ||||||
|             for tagJson in postJsonObject['object']['tag']: |  | ||||||
|                 if not isinstance(tagJson, dict): |  | ||||||
|                     continue |  | ||||||
|                 if not tagJson.get('type'): |  | ||||||
|                     continue |  | ||||||
|                 if tagJson['type'] != 'Article': |  | ||||||
|                     continue |  | ||||||
|                 if not tagJson.get('name'): |  | ||||||
|                     continue |  | ||||||
|                 if not tagJson.get('url'): |  | ||||||
|                     continue |  | ||||||
|                 citationsStr += \ |  | ||||||
|                     '<li><a href="' + tagJson['url'] + '">' + \ |  | ||||||
|                     '<cite>' + tagJson['name'] + '</cite></a></li>\n' |  | ||||||
|             if citationsStr: |  | ||||||
|                 citationsStr = '<p><b>' + translate['Citations'] + \ |  | ||||||
|                     ':</b></p>' + \ |  | ||||||
|                     '<ul>\n' + citationsStr + '</ul>\n' |  | ||||||
| 
 | 
 | ||||||
|     postHtml = '' |     postHtml = '' | ||||||
|     if boxName != 'tlmedia': |     if boxName != 'tlmedia': | ||||||
|  | @ -1467,6 +1479,7 @@ def individualPostAsHtml(allowDownloads: bool, | ||||||
|         if timeDiff > 100: |         if timeDiff > 100: | ||||||
|             print('TIMING INDIV ' + boxName + ' 18 = ' + str(timeDiff)) |             print('TIMING INDIV ' + boxName + ' 18 = ' + str(timeDiff)) | ||||||
| 
 | 
 | ||||||
|  |     # save the created html to the recent posts cache | ||||||
|     if not showPublicOnly and storeToCache and \ |     if not showPublicOnly and storeToCache and \ | ||||||
|        boxName != 'tlmedia' and boxName != 'tlbookmarks' and \ |        boxName != 'tlmedia' and boxName != 'tlbookmarks' and \ | ||||||
|        boxName != 'bookmarks': |        boxName != 'bookmarks': | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue