changedetection.io icon indicating copy to clipboard operation
changedetection.io copied to clipboard

[feature] Use same diff format in notification and in diff page.

Open petersg83 opened this issue 1 year ago • 5 comments

Describe the bug Often I see that the diff in the notification is different than on the diff page. Sometimes there is a tiny change (like one red line and one green line) on the diff page but the notification diff is enormous (tens of lines of changed, into, added, removed).

Version Exact version in the top right area: 0.46.02

Expected behavior I expect the diff to be the same

Screenshots Here is a small example where the lines "removed" are not the same in notification and in diff page

notification Capture d’écran 2024-08-08 à 00 03 48

diff page Capture d’écran 2024-08-08 à 00 03 54

petersg83 avatar Aug 07 '24 22:08 petersg83

Another example:

Capture d’écran 2024-08-12 à 00 56 01 Capture d’écran 2024-08-12 à 00 56 18

petersg83 avatar Aug 11 '24 22:08 petersg83

Hmm it's not a bug, more a "feature", because they use different ways to present the data

the coloured version is actually rendered by JavaScript which CANNOT be used in emails, discord, slack etc

dgtlmoon avatar Aug 19 '24 08:08 dgtlmoon

Yes I understand, so maybe the issue I have is more the "diff notification is complex whereas it seems it could be not"? Here is an example of this morning.

Diff in notification:

(changed)       * Project Controls, Planner
(into)       * Project Manager
(changed)       * Project Manager
(into)     Operations - Plant Engineering
(into)
(into)       * Senior Mechanical Engineer
(changed)     Operations - Plant Engineering
(changed)
(changed)       * Senior Mechanical Engineer
(into)       * Lead Electrical Engineer
(changed)       * Lead Electrical Engineer
(into)     Operations - Plant Operations
(into)
(into)       * Maintenance Engineer - Electrical
(into)
(into)           Reykjavik, Iceland
(into)
(into)       * Senior Process Engineer
(into)
(into)           Reykjavik, Iceland
(into)
(into)       * Maintenance Manager
(into)
(into)           Reykjavik, Iceland
(into)
(into)     Operations - Purchasing & Logistics
(into)
(into)       * Senior Manager Supply Chain
(changed)     Operations - Plant Operations
(changed)
(changed)       * Maintenance Engineer - Electrical
(changed)
(changed)           Reykjavik, Iceland
(changed)
(changed)       * Senior Process Engineer
(changed)
(changed)           Reykjavik, Iceland
(changed)
(changed)       * Maintenance Manager
(changed)
(changed)           Reykjavik, Iceland
(changed)
(changed)     Operations - Purchasing & Logistics
(changed)
(changed)       * Senior Manager Supply Chain
(into)       * Senior Manager Supply Chain (80-100%)
(into)
(into)           Zurich, Switzerland
(into)
(into)     Product
(into)
(into)       * Senior Design Engineer (80-100%)
(into)
(into)           Zurich, Switzerland
(into)
(into)       * Calculation Engineer (80-100%)
(into)
(into)           Zurich, Switzerland
(into)
(into)     Project Development
(into)
(into)       * Lead CCS Specialist
(changed)       * Senior Manager Supply Chain (80-100%)
(into)       * Lead CCS Specialist (80 - 100%)
(into)
(into)           Cologne, Germany
(into)
(into)       * Lead CCS Specialist (80 - 100%)
(changed)     Product
(changed)
(changed)       * Senior Design Engineer (80-100%)
(into)     Technology
(into)
(into)       * Senior Development Specialist in Adsorption (80-100%)
(changed)       * Calculation Engineer (80-100%)
(into)       * Performance Engineer Lead (80-100%)
(changed)     Project Development
(changed)
(changed)       * Lead CCS Specialist
(changed)
(changed)           Austin, United States
(changed)
(changed)       * Lead CCS Specialist (80 - 100%)
(changed)
(changed)           Cologne, Germany
(changed)
(changed)       * Lead CCS Specialist (80 - 100%)
(into)       * Senior Manager Sorbent Structures Industrialization (80-100%)
(changed)     Technology
(changed)
(changed)       * Senior Development Specialist in Adsorption (80-100%)
(into)       * Senior Research Engineer - Energy (80-100%)
(changed)       * Performance Engineer Lead (80-100%)
(into)       * Senior Process Engineer - Energy (80-100%)
(changed)       * Senior Manager Sorbent Structures Industrialization (80-100%)
(into)       * Lead Development Specialist in Adsorption (80-100%)
(changed)       * Senior Research Engineer - Energy (80-100%)
(into)     Testing
(into)
(into)       * Stellvertretung Werkstättenleiter/in Prototypenbau (100%)
(into)
(into)           Zurich (Seebach), Switzerland
(into)
(into)       * Senior Test Engineer (80-100%)
(into)
(into)           Basel, Switzerland
(into)
(into)       * Director of Testing Operations (100%)
(changed)       * Senior Process Engineer - Energy (80-100%)
(changed)
(changed)           Zurich, Switzerland
(changed)
(changed)       * Lead Development Specialist in Adsorption (80-100%)
(changed)
(changed)           Zurich, Switzerland
(changed)
(changed)     Testing
(changed)
(changed)       * Stellvertretung Werkstättenleiter/in Prototypenbau (100%)
(into)       * Anlagen- und Apparatebauer/in (80-100%)
(removed)
(removed)       * Intern in Testing (100%)
(removed)
(removed)           Zurich, Switzerland
(removed)
(removed)       * Senior Test Engineer (80-100%)
(removed)
(removed)           Basel, Switzerland
(removed)
(removed)       * Director of Testing Operations (100%)
(removed)
(removed)           Zurich, Switzerland
(removed)
(removed)       * Anlagen- und Apparatebauer/in (80-100%)
(removed)
(removed)           Zurich (Seebach), Switzerland

Diff in changedetection.io: Capture d’écran 2024-08-20 à 10 21 07 Capture d’écran 2024-08-20 à 10 21 18

As you can see, there are just some lines removed but the diff algorithm thought it was way more than that :P What do you think?

petersg83 avatar Aug 20 '24 08:08 petersg83

I think I'm running into this as well, I only want my notifications to show the additions, so the "(added)" text.

All the extra text is unimportant and noise to me. I played around with {{triggered_text}}, {{diff_added}} and the Text filtering checkboxes on the and nothing produced what I am looking for.

nota3k avatar Nov 08 '24 06:11 nota3k

Struggling with this as well. I'm either missing something obvious or it's just not possible. A lot of this stuff is well over my head, so probably just missing something.

geezfools avatar Nov 12 '24 18:11 geezfools

the coloured version is actually rendered by JavaScript which CANNOT be used in emails, discord, slack etc

While agreeing that discord, slack etc may not be able to represent HTML, emails are capable of that. Wouldn't it be possible to have a tag that can be used for email or have a tag that behaves differently for only for emails (I and probably others are using emails only)?

Rendering of javascript could happen on serverside using something like js2py

    import js2py
    # diff implementation
    with open("diffmin.js", "r") as file:
        diff_js = file.read()

    text1_js = 'This is the first text. It has some content.'
    text2_js = 'This is the second text. It has additional content.'

    js = f"""
    {diff_js}

    function execute_main() {{
        var a = "{text1_js}";
        var b = "{text2_js}";
        var options = {{}};
        var diff = Diff.diffLines(a, b, options);
        return JSON.stringify(diff);
    }}

    execute_main();
    """
    result = js2py.eval_js(js)
    print(result)

ASSUMING the output of the javascript is the same as on the website (which i couldn't confirm as there seems to be more layers/custom implementations on processing) it should look like this:

<td id="diff-col">
                     <span id="result" class="highlightable-filter">  Hacker News new | past | comments | ask | show | jobs | submit  login


 1.                                                                  I algorithmically donated $5000 to Open Source ( kvinogradov.com )
<del class="change" title="Removed 1733587783"><span>     112 points by lorey 4 hours ago | hide | 26 comments
</span></del><ins class="change" title="Inserted 1733588023"><span>     113 points by lorey 4 hours ago | hide | 28 comments
</span></ins>
 2.                                                                  Show HN: Countless.dev – A website to compare every AI model: LLMs, TTSs, STTs ( countless.dev )
<del class="change" title="Removed 1733587783"><span>     113 points by ahmetd 6 hours ago | hide | 30 comments
</span></del><ins class="change" title="Inserted 1733588023"><span>     114 points by ahmetd 6 hours ago | hide | 30 comments
</span></ins>
 3.                                                                  Every V4 UUID ( everyuuid.com )
<del class="change" title="Removed 1733587783"><span>     1157 points by LorenDB 21 hours ago | hide | 325 comments
</span></del><ins class="change" title="Inserted 1733588023"><span>     1157 points by LorenDB 22 hours ago | hide | 325 comments
</span></ins>

While this will have no style elements, emails support style elements if they are inline. So if you send an email instead of using if should work if it looks like this:

<td id="diff-col" style="text-align: justify; white-space: pre-wrap;">
  <span id="result" class="highlightable-filter" style="white-space: pre-wrap; word-break: break-word; overflow-wrap: break-word;">
    Hacker News new | past | comments | ask | show | jobs | submit login

    1. I algorithmically donated $5000 to Open Source (kvinogradov.com)
    <del class="change" title="Removed 1733587783" style="text-decoration: none; color: #b30000; background: #fadad7;">
      <span> 112 points by lorey 4 hours ago | hide | 26 comments </span>
    </del>
    <ins class="change" title="Inserted 1733588023" style="background: #eaf2c2; color: #406619; text-decoration: none;">
      <span> 113 points by lorey 4 hours ago | hide | 28 comments </span>
    </ins>
    2. Show HN: Countless.dev – A website to compare every AI model: LLMs, TTSs, STTs (countless.dev)
    <del class="change" title="Removed 1733587783" style="text-decoration: none; color: #b30000; background: #fadad7;">
      <span> 113 points by ahmetd 6 hours ago | hide | 30 comments </span>
    </del>
    <ins class="change" title="Inserted 1733588023" style="background: #eaf2c2; color: #406619; text-decoration: none;">
      <span> 114 points by ahmetd 6 hours ago | hide | 30 comments </span>
    </ins>
    3. Every V4 UUID (everyuuid.com)
    <del class="change" title="Removed 1733587783" style="text-decoration: none; color: #b30000; background: #fadad7;">
      <span> 1157 points by LorenDB 21 hours ago | hide | 325 comments </span>
    </del>
    <ins class="change" title="Inserted 1733588023" style="background: #eaf2c2; color: #406619; text-decoration: none;">
      <span> 1157 points by LorenDB 22 hours ago | hide | 325 comments </span>
    </ins>
  </span>
</td>

So when sending an email from one account to another it looks like this: image (Darkmode, did not care for linebreaks etc.)

Any chance this is doable?

radomizer avatar Dec 13 '24 00:12 radomizer

See https://github.com/dgtlmoon/changedetection.io/pull/2837 :)

dgtlmoon avatar Dec 13 '24 08:12 dgtlmoon

please try the :dev docker image once its shipped in a few minutes and report back if this solves it :)

dgtlmoon avatar Dec 13 '24 10:12 dgtlmoon

Huuuge improvement for me! Seems to work for me. Emails received are using colors, but i am waiting for more websitechanges. Thank you verymuch! :) Awesome!

radomizer avatar Dec 14 '24 11:12 radomizer

ahh great to hear!!

dgtlmoon avatar Dec 14 '24 17:12 dgtlmoon