From f23966ef876f923b244bf0fe40bd3e1c0ba058b2 Mon Sep 17 00:00:00 2001
From: Benjamin Neff <benjamin@coding4coffee.ch>
Date: Sat, 20 Jan 2018 02:52:27 +0100
Subject: [PATCH] Make mobile bookmarklet work the same way as with desktop UI

This fixes that it fails when you call it without notes parameter.

closes #7698
---
 Changelog.md                                 |  1 +
 app/assets/javascripts/mobile/bookmarklet.js | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index 1dd215e90d..1b5f7cce37 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -7,6 +7,7 @@
 
 ## Bug fixes
 * Fix invite link on the contacts page when the user has no contacts [#7690](https://github.com/diaspora/diaspora/pull/7690)
+* Fixed the mobile bookmarklet when called without parameters [#7698](https://github.com/diaspora/diaspora/pull/7698)
 
 ## Features
 * Check if redis is running in script/server [#7685](https://github.com/diaspora/diaspora/pull/7685)
diff --git a/app/assets/javascripts/mobile/bookmarklet.js b/app/assets/javascripts/mobile/bookmarklet.js
index 94822c2efa..f8a3ba12de 100644
--- a/app/assets/javascripts/mobile/bookmarklet.js
+++ b/app/assets/javascripts/mobile/bookmarklet.js
@@ -6,16 +6,21 @@ $(document).ready(function() {
       return params.content;
     }
 
-    var content = params.title + " - " + params.url;
-    if (params.notes.length > 0) {
-      content += " - " + params.notes;
+    var separator = "\n\n";
+    var contents = "### " + params.title + separator;
+    if (params.notes) {
+      var notes = params.notes.toString().replace(/(?:\r\n|\r|\n)/g, "\n> ");
+      contents += "> " + notes + separator;
     }
-    return content;
+    contents += params.url;
+    return contents;
   }
 
   var content = publisherContent(gon.preloads.bookmarklet);
   if (content.length > 0) {
-    $("#status_message_text").val(content);
+    var textarea = $("#status_message_text");
+    textarea.val(content);
+    autosize.update(textarea);
   }
 });
 // @license-end
-- 
GitLab