[polari/wip/fmuellner/paste-confirmation: 1/16] pasteManager: Move title workaround into gpaste()



commit da7075aa3ca2bdd76a815e56622031e6a84be660
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Feb 11 20:28:12 2016 +0100

    pasteManager: Move title workaround into gpaste()
    
    It's a limitation of the particular service we are using, not of
    text pasting in general.

 src/pasteManager.js |    8 --------
 src/utils.js        |    8 ++++++++
 2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/pasteManager.js b/src/pasteManager.js
index 2b02080..c3b2339 100644
--- a/src/pasteManager.js
+++ b/src/pasteManager.js
@@ -18,11 +18,6 @@ const DndTargetType = {
     IMAGE: 3,
 };
 
-// Silly paste.gnome.org limitation:
-// http://sayakb.github.io/sticky-notes/pages/api/#create-return-values-on-error
-// The visible title is even more limited than the 30-character hard limit ...
-const MAX_PASTE_TITLE_LENGTH = 25;
-
 const PasteManager = new Lang.Class({
     Name: 'PasteManager',
 
@@ -104,9 +99,6 @@ const PasteManager = new Lang.Class({
         else
             title = _("Paste from %s").format(nick);
 
-        if (title.length > MAX_PASTE_TITLE_LENGTH)
-            title = title.substr(0, MAX_PASTE_TITLE_LENGTH - 1) + '…';
-
         Utils.gpaste(text, title, Lang.bind(this,
             function(url) {
                 if (!url) {
diff --git a/src/utils.js b/src/utils.js
index 6d8dea7..bdb1526 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -38,6 +38,11 @@ const SECRET_SCHEMA = new Secret.Schema(
 
 const GPASTE_BASEURL = 'https://paste.gnome.org/';
 
+// Silly paste.gnome.org limitation:
+// http://sayakb.github.io/sticky-notes/pages/api/#create-return-values-on-error
+// The visible title is even more limited than the 30-character hard limit ...
+const MAX_PASTE_TITLE_LENGTH = 25;
+
 const IMGUR_CLIENT_ID = '4109e59177ec95e';
 
 // http://daringfireball.net/2010/07/improved_regex_for_matching_urls
@@ -178,6 +183,9 @@ function openURL(url, timestamp) {
 }
 
 function gpaste(text, title, callback) {
+    if (title.length > MAX_PASTE_TITLE_LENGTH)
+        title = title.substr(0, MAX_PASTE_TITLE_LENGTH - 1) + '…';
+
     let params = {
         title: title,
         data: text,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]