Compare commits
4 Commits
66b36509d2
...
57ac8e772b
| Author | SHA1 | Date | |
|---|---|---|---|
| 57ac8e772b | |||
| 3589f42651 | |||
| 1052010dd5 | |||
| ae26181cf8 |
@ -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_1024x1024.png
Normal file
|
After Width: | Height: | Size: 1.2 MiB |
BIN
src/snek/static/image/snek_logo_128x128.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
src/snek/static/image/snek_logo_144x144.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src/snek/static/image/snek_logo_16x16.png
Normal file
|
After Width: | Height: | Size: 1.0 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_256x256.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
BIN
src/snek/static/image/snek_logo_32x32.png
Normal file
|
After Width: | Height: | Size: 1.8 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_640x480.png
Normal file
|
After Width: | Height: | Size: 117 KiB |
BIN
src/snek/static/image/snek_logo_64x64.png
Normal file
|
After Width: | Height: | Size: 5.0 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_800x600.png
Normal file
|
After Width: | Height: | Size: 177 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 |
@ -1,30 +1,58 @@
|
|||||||
{
|
{
|
||||||
"id": "snek",
|
"id": "snek",
|
||||||
"name": "Snek",
|
"name": "Snek",
|
||||||
"description": "Danger noodle",
|
"short_name": "Snek",
|
||||||
"display": "standalone",
|
"description": "Snek Software Development Community",
|
||||||
"orientation": "portrait",
|
"display": "standalone",
|
||||||
"scope": "/",
|
"orientation": "portrait",
|
||||||
"theme_color": "#000000",
|
"scope": "/",
|
||||||
"background_color": "#000000",
|
"start_url": "/web.html",
|
||||||
"related_applications": [],
|
"theme_color": "#000000",
|
||||||
"prefer_related_applications": false,
|
"background_color": "#000000",
|
||||||
"screenshots": [],
|
"dir": "ltr",
|
||||||
"dir": "ltr",
|
"lang": "en-US",
|
||||||
"lang": "en-US",
|
"icons": [
|
||||||
"launch_path": "/web.html",
|
{
|
||||||
"short_name": "Snek",
|
"src": "/image/snek_logo_32x32.png",
|
||||||
"start_url": "/web.html",
|
"type": "image/png",
|
||||||
"icons": [
|
"sizes": "32x32"
|
||||||
{
|
},
|
||||||
"src": "/image/snek192.png",
|
{
|
||||||
"type": "image/png",
|
"src": "/image/snek_logo_64x64.png",
|
||||||
"sizes": "192x192"
|
"type": "image/png",
|
||||||
},
|
"sizes": "64x64"
|
||||||
{
|
},
|
||||||
"src": "/image/snek512.png",
|
{
|
||||||
"type": "image/png",
|
"src": "/image/snek_logo_128x128.png",
|
||||||
"sizes": "512x512"
|
"type": "image/png",
|
||||||
}
|
"sizes": "128x128"
|
||||||
]
|
},
|
||||||
}
|
{
|
||||||
|
"src": "/image/snek_logo_144x144.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "144x144"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/image/snek_logo_192x192.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "192x192"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/image/snek_logo_256x256.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "256x256"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/image/snek_logo_512x512.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "512x512"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "/image/snek_logo_1024x1024.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "1024x1024"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"related_applications": [],
|
||||||
|
"prefer_related_applications": false
|
||||||
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -21,14 +21,8 @@
|
|||||||
<link rel="stylesheet" href="/user-list.css">
|
<link rel="stylesheet" href="/user-list.css">
|
||||||
<link rel="stylesheet" href="/fa640.all.min.css">
|
<link rel="stylesheet" href="/fa640.all.min.css">
|
||||||
<link rel="stylesheet" href="/base.css">
|
<link rel="stylesheet" href="/base.css">
|
||||||
<link
|
<link rel="icon" type="image/png" href="/image/snek_logo_32x32.png" sizes="32x32">
|
||||||
rel="stylesheet"
|
<link rel="icon" type="image/png" href="/image/snek_logo_64x64.png" sizes="64x64">
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
|
|
||||||
integrity="sha512-pBMV+3tn6+5xAZuhI6tyCmQkXh15riZDqGPxAx/U+FuiI5Dh3ZTjM23cZqQ25jJCfi8+ka9gzC2ukNkGkP/Aw=="
|
|
||||||
crossorigin="anonymous"
|
|
||||||
referrerpolicy="no-referrer"
|
|
||||||
/>
|
|
||||||
<link rel="icon" type="image/png" href="/image/snek1.png" sizes="32x32">
|
|
||||||
<script defer src="https://umami.molodetz.nl/script.js" data-website-id="d127c3e4-dc70-4041-a1c8-bcc32c2492ea"></script>
|
<script defer src="https://umami.molodetz.nl/script.js" data-website-id="d127c3e4-dc70-4041-a1c8-bcc32c2492ea"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||