diff --git a/changedetectionio/diff.py b/changedetectionio/diff.py
index 9cb4c9fe..3371ad4d 100644
--- a/changedetectionio/diff.py
+++ b/changedetectionio/diff.py
@@ -35,15 +35,19 @@ def customSequenceMatcher(before, after, include_equal=False, include_removed=Tr
# only_differences - only return info about the differences, no context
# line_feed_sep could be "
" or "
" or "\n" etc
-def render_diff(previous_version_file_contents, newest_version_file_contents, include_equal=False, include_removed=True, include_added=True, include_replaced=True, line_feed_sep="\n", include_change_type_prefix=True):
+def render_diff(previous_version_file_contents, newest_version_file_contents, include_equal=False, include_removed=True, include_added=True, include_replaced=True, line_feed_sep="\n", include_change_type_prefix=True, patch_format=False):
newest_version_file_contents = [line.rstrip() for line in newest_version_file_contents.splitlines()]
if previous_version_file_contents:
- previous_version_file_contents = [line.rstrip() for line in previous_version_file_contents.splitlines()]
+ previous_version_file_contents = [line.rstrip() for line in previous_version_file_contents.splitlines()]
else:
previous_version_file_contents = ""
+ if patch_format:
+ patch = difflib.unified_diff(previous_version_file_contents, newest_version_file_contents)
+ return line_feed_sep.join(patch)
+
rendered_diff = customSequenceMatcher(before=previous_version_file_contents,
after=newest_version_file_contents,
include_equal=include_equal,
diff --git a/changedetectionio/notification.py b/changedetectionio/notification.py
index d2beda01..27c7afa7 100644
--- a/changedetectionio/notification.py
+++ b/changedetectionio/notification.py
@@ -9,6 +9,7 @@ valid_tokens = {
'diff': '',
'diff_added': '',
'diff_full': '',
+ 'diff_patch': '',
'diff_removed': '',
'diff_url': '',
'preview_url': '',
@@ -98,7 +99,7 @@ def process_notification(n_object, datastore):
# Initially text or whatever
n_format = datastore.data['settings']['application'].get('notification_format', valid_notification_formats[default_notification_format])
-
+
# https://github.com/caronc/apprise/wiki/Development_LogCapture
# Anything higher than or equal to WARNING (which covers things like Connection errors)
# raise it as an exception
@@ -177,7 +178,7 @@ def process_notification(n_object, datastore):
log_value = logs.getvalue()
if log_value and 'WARNING' in log_value or 'ERROR' in log_value:
raise Exception(log_value)
-
+
sent_objs.append({'title': n_title,
'body': n_body,
'url' : url,
@@ -230,6 +231,7 @@ def create_notification_parameters(n_object, datastore):
'diff': n_object.get('diff', ''), # Null default in the case we use a test
'diff_added': n_object.get('diff_added', ''), # Null default in the case we use a test
'diff_full': n_object.get('diff_full', ''), # Null default in the case we use a test
+ 'diff_patch': n_object.get('diff_patch', ''), # Null default in the case we use a test
'diff_removed': n_object.get('diff_removed', ''), # Null default in the case we use a test
'diff_url': diff_url,
'preview_url': preview_url,
diff --git a/changedetectionio/templates/_common_fields.jinja b/changedetectionio/templates/_common_fields.jinja
index c8ffdb00..6b6f6e05 100644
--- a/changedetectionio/templates/_common_fields.jinja
+++ b/changedetectionio/templates/_common_fields.jinja
@@ -99,6 +99,10 @@
{{ '{{diff_full}}' }} |
The diff output - full difference output |
+
+ {{ '{{diff_patch}}' }} |
+ The diff output - patch in unified format |
+
{{ '{{current_snapshot}}' }} |
The current snapshot value, useful when combined with JSON or CSS filters
diff --git a/changedetectionio/tests/test_filter_exist_changes.py b/changedetectionio/tests/test_filter_exist_changes.py
index 24f84455..e57db579 100644
--- a/changedetectionio/tests/test_filter_exist_changes.py
+++ b/changedetectionio/tests/test_filter_exist_changes.py
@@ -15,7 +15,7 @@ def set_response_without_filter():
Which is across multiple lines
So let's see what happens.
- Some text thats the same
+ Some text thats the same
|