mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-10-30 14:17:40 +00:00
Changes to colors HTML notification (small contrast between 'changed' and 'removed' etc) (#3540)
This commit is contained in:
@@ -2,9 +2,10 @@ import difflib
|
|||||||
from typing import List, Iterator, Union
|
from typing import List, Iterator, Union
|
||||||
|
|
||||||
# https://github.com/dgtlmoon/changedetection.io/issues/821#issuecomment-1241837050
|
# https://github.com/dgtlmoon/changedetection.io/issues/821#issuecomment-1241837050
|
||||||
HTML_REMOVED_STYLE = "background-color: #ffebe9; color: #82071e"
|
HTML_ADDED_STYLE = "background-color: #d2f7c2; color: #255d00;"
|
||||||
HTML_ADDED_STYLE = "background-color: #dafbe1; color: #116329;"
|
HTML_CHANGED_INTO_STYLE = "background-color: #dafbe1; color: #116329;"
|
||||||
HTML_CHANGED_STYLE = "background-color: #ffd8b5; color: #953800;"
|
HTML_CHANGED_STYLE = "background-color: #ffd6cc; color: #7a2000;"
|
||||||
|
HTML_REMOVED_STYLE = "background-color: #ffebe9; color: #82071e;"
|
||||||
|
|
||||||
# These get set to html or telegram type or discord compatible or whatever in handler.py
|
# These get set to html or telegram type or discord compatible or whatever in handler.py
|
||||||
# Something that cant get escaped to HTML by accident
|
# Something that cant get escaped to HTML by accident
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ from .apprise_plugin.assets import apprise_asset, APPRISE_AVATAR_URL
|
|||||||
from .apprise_plugin.custom_handlers import SUPPORTED_HTTP_METHODS
|
from .apprise_plugin.custom_handlers import SUPPORTED_HTTP_METHODS
|
||||||
from ..diff import HTML_REMOVED_STYLE, REMOVED_PLACEMARKER_OPEN, REMOVED_PLACEMARKER_CLOSED, ADDED_PLACEMARKER_OPEN, HTML_ADDED_STYLE, \
|
from ..diff import HTML_REMOVED_STYLE, REMOVED_PLACEMARKER_OPEN, REMOVED_PLACEMARKER_CLOSED, ADDED_PLACEMARKER_OPEN, HTML_ADDED_STYLE, \
|
||||||
ADDED_PLACEMARKER_CLOSED, CHANGED_INTO_PLACEMARKER_OPEN, CHANGED_INTO_PLACEMARKER_CLOSED, CHANGED_PLACEMARKER_OPEN, \
|
ADDED_PLACEMARKER_CLOSED, CHANGED_INTO_PLACEMARKER_OPEN, CHANGED_INTO_PLACEMARKER_CLOSED, CHANGED_PLACEMARKER_OPEN, \
|
||||||
CHANGED_PLACEMARKER_CLOSED, HTML_CHANGED_STYLE
|
CHANGED_PLACEMARKER_CLOSED, HTML_CHANGED_STYLE, HTML_CHANGED_INTO_STYLE
|
||||||
from ..notification_service import NotificationContextData, CUSTOM_LINEBREAK_PLACEHOLDER
|
from ..notification_service import NotificationContextData, CUSTOM_LINEBREAK_PLACEHOLDER
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def markup_text_links_to_html(body):
|
def markup_text_links_to_html(body):
|
||||||
"""
|
"""
|
||||||
Convert plaintext to HTML with clickable links.
|
Convert plaintext to HTML with clickable links.
|
||||||
@@ -166,7 +167,7 @@ def apply_service_tweaks(url, n_body, n_title, requested_output_format):
|
|||||||
# Handle changed/replaced lines (old → new)
|
# Handle changed/replaced lines (old → new)
|
||||||
n_body = n_body.replace(CHANGED_PLACEMARKER_OPEN, f'<span style="{HTML_CHANGED_STYLE}" role="note" aria-label="Changed text" title="Changed text">')
|
n_body = n_body.replace(CHANGED_PLACEMARKER_OPEN, f'<span style="{HTML_CHANGED_STYLE}" role="note" aria-label="Changed text" title="Changed text">')
|
||||||
n_body = n_body.replace(CHANGED_PLACEMARKER_CLOSED, f'</span>')
|
n_body = n_body.replace(CHANGED_PLACEMARKER_CLOSED, f'</span>')
|
||||||
n_body = n_body.replace(CHANGED_INTO_PLACEMARKER_OPEN, f'<span style="{HTML_CHANGED_STYLE}" role="note" aria-label="Changed into" title="Changed into">')
|
n_body = n_body.replace(CHANGED_INTO_PLACEMARKER_OPEN, f'<span style="{HTML_CHANGED_INTO_STYLE}" role="note" aria-label="Changed into" title="Changed into">')
|
||||||
n_body = n_body.replace(CHANGED_INTO_PLACEMARKER_CLOSED, f'</span>')
|
n_body = n_body.replace(CHANGED_INTO_PLACEMARKER_CLOSED, f'</span>')
|
||||||
n_body = n_body.replace('\n', f'{CUSTOM_LINEBREAK_PLACEHOLDER}\n')
|
n_body = n_body.replace('\n', f'{CUSTOM_LINEBREAK_PLACEHOLDER}\n')
|
||||||
elif requested_output_format == 'html':
|
elif requested_output_format == 'html':
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import threading
|
|||||||
import time
|
import time
|
||||||
from aiosmtpd.controller import Controller
|
from aiosmtpd.controller import Controller
|
||||||
from flask import Flask, Response
|
from flask import Flask, Response
|
||||||
|
from email import message_from_bytes
|
||||||
|
from email.policy import default
|
||||||
|
|
||||||
# Accept a SMTP message and offer a way to retrieve the last message via HTTP
|
# Accept a SMTP message and offer a way to retrieve the last message via HTTP
|
||||||
|
|
||||||
@@ -27,6 +29,36 @@ class CustomSMTPHandler:
|
|||||||
print('*******************************')
|
print('*******************************')
|
||||||
print(envelope.content.decode('utf8'))
|
print(envelope.content.decode('utf8'))
|
||||||
print('*******************************')
|
print('*******************************')
|
||||||
|
|
||||||
|
# Parse the email message
|
||||||
|
msg = message_from_bytes(envelope.content, policy=default)
|
||||||
|
|
||||||
|
# Write parts to files based on content type
|
||||||
|
if msg.is_multipart():
|
||||||
|
for part in msg.walk():
|
||||||
|
content_type = part.get_content_type()
|
||||||
|
payload = part.get_payload(decode=True)
|
||||||
|
|
||||||
|
if payload:
|
||||||
|
if content_type == 'text/plain':
|
||||||
|
with open('/tmp/last.txt', 'wb') as f:
|
||||||
|
f.write(payload)
|
||||||
|
print(f'Written text/plain part to /tmp/last.txt')
|
||||||
|
elif content_type == 'text/html':
|
||||||
|
with open('/tmp/last.html', 'wb') as f:
|
||||||
|
f.write(payload)
|
||||||
|
print(f'Written text/html part to /tmp/last.html')
|
||||||
|
else:
|
||||||
|
# Single part message
|
||||||
|
content_type = msg.get_content_type()
|
||||||
|
payload = msg.get_payload(decode=True)
|
||||||
|
|
||||||
|
if payload:
|
||||||
|
if content_type == 'text/plain' or content_type.startswith('text/'):
|
||||||
|
with open('/tmp/last.txt', 'wb') as f:
|
||||||
|
f.write(payload)
|
||||||
|
print(f'Written single part message to /tmp/last.txt')
|
||||||
|
|
||||||
return '250 Message accepted for delivery'
|
return '250 Message accepted for delivery'
|
||||||
finally:
|
finally:
|
||||||
with smtp_lock:
|
with smtp_lock:
|
||||||
|
|||||||
Reference in New Issue
Block a user