From 84894944a752bc20da0c65bf00ace2947db90665 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 23 Feb 2016 15:46:48 +0100 Subject: [PATCH] Added html2text convert for desktop notifications. --- .../app/controllers/widget/online_notification.coffee | 2 +- public/assets/tests/html_utils.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index d3cbd8b90..0aead3db0 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -154,7 +154,7 @@ class App.OnlineNotificationWidget extends App.Controller title = item.objectNative.activityMessage(item) else title = "Need objectNative in item #{item.object}.find(#{item.o_id})" - title = title.replace(/<.+?>/g, '"') + title = App.Utils.html2text(title.replace(/<.+?>/g, '"')) @notifyDesktop( url: item.link title: title diff --git a/public/assets/tests/html_utils.js b/public/assets/tests/html_utils.js index 7aef1d5fb..85f3afb7e 100644 --- a/public/assets/tests/html_utils.js +++ b/public/assets/tests/html_utils.js @@ -84,6 +84,11 @@ test("html2text", function() { result = App.Utils.html2text(source) equal(result, should, source) + source = "
Some & <Value>
" + should = "Some & " + result = App.Utils.html2text(source) + equal(result, should, source) + source = "
Some
<b>Value</b>
" should = "Some\nValue" result = App.Utils.html2text(source)