New logo's new sizes markdown stripper.py
This commit is contained in:
parent
66b36509d2
commit
ae26181cf8
@ -1,6 +1,6 @@
|
||||
from snek.system.model import now
|
||||
from snek.system.service import BaseService
|
||||
|
||||
from snek.system.markdown import strip_markdown
|
||||
|
||||
class NotificationService(BaseService):
|
||||
mapper_name = "notification"
|
||||
@ -64,11 +64,13 @@ class NotificationService(BaseService):
|
||||
|
||||
if channel_member["user_uid"] != user["uid"]:
|
||||
try:
|
||||
stripped_message = strip_markdown(channel_message["message"])
|
||||
channel_name = channel_member.get_name()
|
||||
await self.app.services.push.notify_user(
|
||||
user_uid=channel_member["user_uid"],
|
||||
payload={
|
||||
"title": f"New message in {channel_member['label']}",
|
||||
"message": f"{user['nick']}: {channel_message['message']}",
|
||||
"title": f"New message in {channel_member}",
|
||||
"message": f"{user['nick']}: {stripped_message}",
|
||||
"icon": "/image/snek192.png",
|
||||
"url": f"/channel/{channel_message['channel_uid']}.html",
|
||||
},
|
||||
|
BIN
src/snek/static/image/snek_logo.png
Normal file
BIN
src/snek/static/image/snek_logo.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.3 MiB |
BIN
src/snek/static/image/snek_logo_144x144.png
Normal file
BIN
src/snek/static/image/snek_logo_144x144.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 17 KiB |
BIN
src/snek/static/image/snek_logo_192x192.png
Normal file
BIN
src/snek/static/image/snek_logo_192x192.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 25 KiB |
BIN
src/snek/static/image/snek_logo_384x384.png
Normal file
BIN
src/snek/static/image/snek_logo_384x384.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 79 KiB |
BIN
src/snek/static/image/snek_logo_48x48.png
Normal file
BIN
src/snek/static/image/snek_logo_48x48.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 3.2 KiB |
BIN
src/snek/static/image/snek_logo_512x512.png
Normal file
BIN
src/snek/static/image/snek_logo_512x512.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 132 KiB |
BIN
src/snek/static/image/snek_logo_72x72.png
Normal file
BIN
src/snek/static/image/snek_logo_72x72.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 5.9 KiB |
BIN
src/snek/static/image/snek_logo_96x96.png
Normal file
BIN
src/snek/static/image/snek_logo_96x96.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 9.0 KiB |
BIN
src/snek/static/image/snek_original.png
Normal file
BIN
src/snek/static/image/snek_original.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 1.3 MiB |
@ -17,12 +17,12 @@
|
||||
"start_url": "/web.html",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/image/snek192.png",
|
||||
"src": "/image/snek_logo_192x192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "/image/snek512.png",
|
||||
"src": "/image/snek_logo_512x512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Original source: https://brandonjay.dev/posts/2021/render-markdown-html-in-python-with-jinja2
|
||||
|
||||
import re
|
||||
from types import SimpleNamespace
|
||||
|
||||
from app.cache import time_cache_async
|
||||
@ -12,6 +12,20 @@ from pygments.formatters import html
|
||||
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):
|
||||
|
||||
_allow_harmful_protocols = False
|
||||
|
Loading…
Reference in New Issue
Block a user