mirror of https://gitlab.com/bashrc2/epicyon
				
				
				
			If a nsfw indication exists within post content then minimize any attached image
							parent
							
								
									fdfa3d4276
								
							
						
					
					
						commit
						d18b2acd9f
					
				
							
								
								
									
										21
									
								
								blog.py
								
								
								
								
							
							
						
						
									
										21
									
								
								blog.py
								
								
								
								
							|  | @ -260,16 +260,6 @@ def _html_blog_post_content(debug: bool, session, authorized: bool, | |||
|     delete_str = '' | ||||
|     mute_str = '' | ||||
|     is_muted = False | ||||
|     attachment_str, _ = \ | ||||
|         get_post_attachments_as_html(base_dir, nickname, domain, | ||||
|                                      domain_full, post_json_object, | ||||
|                                      'tlblogs', translate, | ||||
|                                      is_muted, avatar_link, | ||||
|                                      reply_str, announce_str, | ||||
|                                      like_str, bookmark_str, | ||||
|                                      delete_str, mute_str) | ||||
|     if attachment_str: | ||||
|         blog_str += '<br><center>' + attachment_str + '</center>' | ||||
| 
 | ||||
|     person_url = local_actor_url(http_prefix, nickname, domain_full) | ||||
|     actor_json = \ | ||||
|  | @ -279,6 +269,17 @@ def _html_blog_post_content(debug: bool, session, authorized: bool, | |||
|         languages_understood = get_actor_languages_list(actor_json) | ||||
|     json_content = get_content_from_post(post_json_object, system_language, | ||||
|                                          languages_understood) | ||||
|     attachment_str, _ = \ | ||||
|         get_post_attachments_as_html(base_dir, nickname, domain, | ||||
|                                      domain_full, post_json_object, | ||||
|                                      'tlblogs', translate, | ||||
|                                      is_muted, avatar_link, | ||||
|                                      reply_str, announce_str, | ||||
|                                      like_str, bookmark_str, | ||||
|                                      delete_str, mute_str, | ||||
|                                      json_content) | ||||
|     if attachment_str: | ||||
|         blog_str += '<br><center>' + attachment_str + '</center>' | ||||
|     if json_content: | ||||
|         content_str = add_embedded_elements(translate, json_content, | ||||
|                                             peertube_instances) | ||||
|  |  | |||
|  | @ -2041,6 +2041,15 @@ def individual_post_as_html(signing_priv_key_pem: str, | |||
| 
 | ||||
|     _log_post_timing(enable_timing_log, post_start_time, '14') | ||||
| 
 | ||||
|     person_url = local_actor_url(http_prefix, nickname, domain_full) | ||||
|     actor_json = \ | ||||
|         get_person_from_cache(base_dir, person_url, person_cache) | ||||
|     languages_understood = [] | ||||
|     if actor_json: | ||||
|         languages_understood = get_actor_languages_list(actor_json) | ||||
|     content_str = get_content_from_post(post_json_object, system_language, | ||||
|                                         languages_understood) | ||||
| 
 | ||||
|     attachment_str, gallery_str = \ | ||||
|         get_post_attachments_as_html(base_dir, nickname, domain, | ||||
|                                      domain_full, | ||||
|  | @ -2048,7 +2057,8 @@ def individual_post_as_html(signing_priv_key_pem: str, | |||
|                                      box_name, translate, | ||||
|                                      is_muted, avatar_link, | ||||
|                                      reply_str, announce_str, like_str, | ||||
|                                      bookmark_str, delete_str, mute_str) | ||||
|                                      bookmark_str, delete_str, mute_str, | ||||
|                                      content_str) | ||||
| 
 | ||||
|     published_str = \ | ||||
|         _get_published_date_str(post_json_object, show_published_date_only, | ||||
|  | @ -2119,14 +2129,9 @@ def individual_post_as_html(signing_priv_key_pem: str, | |||
|             post_json_object['object']['content'] | ||||
| 
 | ||||
|     domain_full = get_full_domain(domain, port) | ||||
|     person_url = local_actor_url(http_prefix, nickname, domain_full) | ||||
|     actor_json = \ | ||||
|         get_person_from_cache(base_dir, person_url, person_cache) | ||||
|     languages_understood = [] | ||||
|     if actor_json: | ||||
|         languages_understood = get_actor_languages_list(actor_json) | ||||
|     content_str = get_content_from_post(post_json_object, system_language, | ||||
|                                         languages_understood) | ||||
|     if not content_str: | ||||
|         content_str = get_content_from_post(post_json_object, system_language, | ||||
|                                             languages_understood) | ||||
|     if not content_str: | ||||
|         content_str = \ | ||||
|             auto_translate_post(base_dir, post_json_object, | ||||
|  |  | |||
|  | @ -1129,7 +1129,8 @@ def get_post_attachments_as_html(base_dir: str, | |||
|                                  reply_str: str, announce_str: str, | ||||
|                                  like_str: str, | ||||
|                                  bookmark_str: str, delete_str: str, | ||||
|                                  mute_str: str) -> (str, str): | ||||
|                                  mute_str: str, | ||||
|                                  content: str) -> (str, str): | ||||
|     """Returns a string representing any attachments | ||||
|     """ | ||||
|     attachment_str = '' | ||||
|  | @ -1232,6 +1233,11 @@ def get_post_attachments_as_html(base_dir: str, | |||
|                                                    following_nickname, | ||||
|                                                    following_domain) | ||||
| 
 | ||||
|                 # minimize any NSFW images | ||||
|                 if not minimize_images and content: | ||||
|                     if 'nsfw' in content.lower(): | ||||
|                         minimize_images = True | ||||
| 
 | ||||
|                 if minimize_images: | ||||
|                     show_img_str = 'SHOW MEDIA' | ||||
|                     if translate: | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue