New logo's new sizes markdown stripper.py
@ -1,6 +1,6 @@
 | 
				
			|||||||
from snek.system.model import now
 | 
					from snek.system.model import now
 | 
				
			||||||
from snek.system.service import BaseService
 | 
					from snek.system.service import BaseService
 | 
				
			||||||
 | 
					from snek.system.markdown import strip_markdown
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NotificationService(BaseService):
 | 
					class NotificationService(BaseService):
 | 
				
			||||||
    mapper_name = "notification"
 | 
					    mapper_name = "notification"
 | 
				
			||||||
@ -64,11 +64,13 @@ class NotificationService(BaseService):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if channel_member["user_uid"] != user["uid"]:
 | 
					            if channel_member["user_uid"] != user["uid"]:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
 | 
					                    stripped_message = strip_markdown(channel_message["message"])
 | 
				
			||||||
 | 
					                    channel_name = channel_member.get_name()
 | 
				
			||||||
                    await self.app.services.push.notify_user(
 | 
					                    await self.app.services.push.notify_user(
 | 
				
			||||||
                        user_uid=channel_member["user_uid"],
 | 
					                        user_uid=channel_member["user_uid"],
 | 
				
			||||||
                        payload={
 | 
					                        payload={
 | 
				
			||||||
                            "title": f"New message in {channel_member['label']}",
 | 
					                            "title": f"New message in {channel_member}",
 | 
				
			||||||
                            "message": f"{user['nick']}: {channel_message['message']}",
 | 
					                            "message": f"{user['nick']}: {stripped_message}",
 | 
				
			||||||
                            "icon": "/image/snek192.png",
 | 
					                            "icon": "/image/snek192.png",
 | 
				
			||||||
                            "url": f"/channel/{channel_message['channel_uid']}.html",
 | 
					                            "url": f"/channel/{channel_message['channel_uid']}.html",
 | 
				
			||||||
                        },
 | 
					                        },
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.3 MiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_144x144.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 17 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_192x192.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 25 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_384x384.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 79 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_48x48.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.2 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_512x512.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 132 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_72x72.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 5.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_logo_96x96.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 9.0 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/snek/static/image/snek_original.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 1.3 MiB  | 
@ -17,12 +17,12 @@
 | 
				
			|||||||
    "start_url": "/web.html",
 | 
					    "start_url": "/web.html",
 | 
				
			||||||
    "icons": [
 | 
					    "icons": [
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        "src": "/image/snek192.png",
 | 
					        "src": "/image/snek_logo_192x192.png",
 | 
				
			||||||
        "type": "image/png",
 | 
					        "type": "image/png",
 | 
				
			||||||
        "sizes": "192x192"
 | 
					        "sizes": "192x192"
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
        "src": "/image/snek512.png",
 | 
					        "src": "/image/snek_logo_512x512.png",
 | 
				
			||||||
        "type": "image/png",
 | 
					        "type": "image/png",
 | 
				
			||||||
        "sizes": "512x512"
 | 
					        "sizes": "512x512"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
# Original source: https://brandonjay.dev/posts/2021/render-markdown-html-in-python-with-jinja2
 | 
					# Original source: https://brandonjay.dev/posts/2021/render-markdown-html-in-python-with-jinja2
 | 
				
			||||||
 | 
					import re 
 | 
				
			||||||
from types import SimpleNamespace
 | 
					from types import SimpleNamespace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from app.cache import time_cache_async
 | 
					from app.cache import time_cache_async
 | 
				
			||||||
@ -12,6 +12,20 @@ from pygments.formatters import html
 | 
				
			|||||||
from pygments.lexers import get_lexer_by_name
 | 
					from pygments.lexers import get_lexer_by_name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def strip_markdown(md_text):
 | 
				
			||||||
 | 
					    # Remove code blocks (  
 | 
				
			||||||
 | 
					    md_text = re.sub(r'[\s\S]?```', '', md_text)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'^\s{4,}.$', '', md_text, flags=re.MULTILINE)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'^\s{0,3}#{1,6}\s+', '', md_text, flags=re.MULTILINE)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'!\[.?\]\(.?\)', '', md_text)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'\[([^\]]+)\]\(.?\)', r'\1', md_text)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'(\*|_){1,3}(.+?)\1{1,3}', r'\2', md_text)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'^\s{0,3}>+\s?', '', md_text, flags=re.MULTILINE)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'^(\s)(\-{3,}|_{3,}|\{3,})\s$', '', md_text, flags=re.MULTILINE)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'[`~>#+\-=]', '', md_text)
 | 
				
			||||||
 | 
					    md_text = re.sub(r'\s+', ' ', md_text)
 | 
				
			||||||
 | 
					    return md_text.strip()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MarkdownRenderer(HTMLRenderer):
 | 
					class MarkdownRenderer(HTMLRenderer):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _allow_harmful_protocols = False
 | 
					    _allow_harmful_protocols = False
 | 
				
			||||||
 | 
				
			|||||||