From afad5dddfb36cff4ae3c4cced5fff130e2d7d345 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Mon, 14 Oct 2013 19:49:03 +0530 Subject: [PATCH 01/13] Fix for avatar image not being saved in disk cache on GTK version == Symptom Avatar icon in the desktop notification (libnotify) of GTK version was missing. == Cause Save to disk operation was aborted due to an exception in the `get_prefs` function on agent.py, as it was trying to fetch a non-existing element (proxy_type) from config.settings dictionary. == Solution Check if the key exists in the dictrionary before using it, and return an empty string if not. --- hotot-gir/agent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotot-gir/agent.py b/hotot-gir/agent.py index 5b59d88a..701e1bf6 100644 --- a/hotot-gir/agent.py +++ b/hotot-gir/agent.py @@ -158,6 +158,9 @@ def set_style_scheme(): ''' % str(bg[Gtk.StateType.NORMAL])); def get_prefs(name): + if name not in config.settings: + return '' + return config.settings[name] def set_prefs(name, value): From 27e37f7f7b031029dfd5bc077e8aa42f5c934a91 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Mon, 4 Nov 2013 04:40:01 +0530 Subject: [PATCH 02/13] Use systems desktop notification in i3wm --- hotot/agent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotot/agent.py b/hotot/agent.py index b125109b..77bbb512 100644 --- a/hotot/agent.py +++ b/hotot/agent.py @@ -26,7 +26,7 @@ ## Disable GtkNotification on Gnome3 screen = gtk.gdk.screen_get_default() window_manager_name = screen.get_window_manager_name().lower() if screen else '' -if 'mutter' in window_manager_name: +if 'mutter' in window_manager_name or 'i3' in window_manager_name: USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM = False if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM: From efd8fac6c6c594618ec357bd6ddcee14dff86477 Mon Sep 17 00:00:00 2001 From: Jiahua Huang Date: Mon, 30 Dec 2013 00:20:05 +0800 Subject: [PATCH 03/13] fixed: search api --- data/index.html | 4 ++-- data/js/conf.js | 7 ++++--- data/js/lib.twitter.js | 9 +++++---- data/js/ui.prefs_dlg.js | 6 +++--- data/js/ui.template.js | 4 ++-- data/manifest.json | 5 +---- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/data/index.html b/data/index.html index 25650305..37f564cb 100644 --- a/data/index.html +++ b/data/index.html @@ -905,11 +905,11 @@

API Settings

  • -
  • 1) { - time_str = mobj.format('MM-DD-YYYY HH:mm:ss'); + time_str = mobj.format('YYYY-MM-DD HH:mm:ss'); } else { - time_str = mobj.format('HH:mm:ss'); + time_str = mobj.format('YYYY-MM-DD HH:mm:ss'); } } diff --git a/data/manifest.json b/data/manifest.json index c4196e0a..65109325 100644 --- a/data/manifest.json +++ b/data/manifest.json @@ -2,12 +2,9 @@ "manifest_version": 2, "name": "Hotot", "description": "Hotot Twitter client for Chrome", - "version": "0.9.8.14", + "version": "0.9.8.15", "default_locale": "en", "content_security_policy": "script-src 'self' 'unsafe-eval' https://maps.google.com; object-src 'self'", - "background": { - "page": "background.html" - }, "app": { "launch": { "local_path": "index.html" From 7213e649f7a02833b0b673e6e8cb5216c5d7fe45 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Tue, 19 Aug 2014 23:15:26 +0530 Subject: [PATCH 04/13] Changed default notification timeout to 30s --- hotot/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotot/agent.py b/hotot/agent.py index 77bbb512..eea03ba8 100644 --- a/hotot/agent.py +++ b/hotot/agent.py @@ -63,7 +63,7 @@ def init_notify(): notify.set_icon_from_pixbuf( gtk.gdk.pixbuf_new_from_file( utils.get_ui_object(os.path.join('image','ic64_hotot.png')))) - notify.set_timeout(5000) + notify.set_timeout(30000) def do_notify(summary, body, icon_file = None): if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM: @@ -72,7 +72,7 @@ def do_notify(summary, body, icon_file = None): if (icon_file == None or not os.path.isfile(icon_file) or os.path.getsize(icon_file) == 0): icon_file = utils.get_ui_object(os.path.join('image','ic64_hotot.png')); n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file)) - n.set_timeout(5000) + n.set_timeout(30000) n.show() def crack_hotot(uri): From fdc771cee36221927acbd27cf4ba394aa296d637 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Tue, 19 Aug 2014 23:17:39 +0530 Subject: [PATCH 05/13] Pass image URI to pynotify instead of the raw image --- hotot/agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotot/agent.py b/hotot/agent.py index eea03ba8..d67911b5 100644 --- a/hotot/agent.py +++ b/hotot/agent.py @@ -68,10 +68,10 @@ def init_notify(): def do_notify(summary, body, icon_file = None): if USE_GTKNOTIFICATION_IN_NATIVE_PLATFORM: return notify.do_notify(summary, body, icon_file) - n = pynotify.Notification(summary, body) if (icon_file == None or not os.path.isfile(icon_file) or os.path.getsize(icon_file) == 0): icon_file = utils.get_ui_object(os.path.join('image','ic64_hotot.png')); - n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file)) + n = pynotify.Notification(summary, body, 'file://' + icon_file) + #n.set_icon_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_file)) n.set_timeout(30000) n.show() From 6629ae15327634841dd5415e7ea4f3fff7c6c4a7 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Tue, 2 Sep 2014 01:37:21 +0530 Subject: [PATCH 06/13] Fix for avatar image not being saved in disk cache on GTK2 version --- hotot/agent.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotot/agent.py b/hotot/agent.py index d67911b5..fe584dc6 100644 --- a/hotot/agent.py +++ b/hotot/agent.py @@ -203,6 +203,9 @@ def set_style_scheme(): ''' % str(bg[gtk.STATE_NORMAL])); def get_prefs(name): + if name not in config.settings: + return '' + return config.settings[name] def set_prefs(name, value): From 5951a8a19cccf20dacc05a1b26fa2eeb3074e9d9 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 12:23:02 +0530 Subject: [PATCH 07/13] Fix: undefined variable error on startup --- data/js/lib.twitter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/data/js/lib.twitter.js b/data/js/lib.twitter.js index 82735b3a..3096cc18 100644 --- a/data/js/lib.twitter.js +++ b/data/js/lib.twitter.js @@ -893,10 +893,13 @@ function TwitterClient() { newText = interrupted_response + newText; interrupted_response = '' - var lines = newText.split(/[\n\r]/g); + var lines = newText.split(/[\n\r]/g), + ret for (var i = 0; i < lines.length; i += 1) { var line = lines[i].split(/({[^\0]+})/gm); for (var j = 0; j < line.length; j += 1) { + ret = null + if (!empty_tester.test(line[j])) { try { ret = JSON.parse(line[j]); @@ -911,7 +914,9 @@ function TwitterClient() { //return; } try { - callback(ret); + if(ret) { + callback(ret) + } } catch(e) { console.log('Streams callback: ' + e.message + '\n' + line); return; From 94656a9a69b8f0e7a85b6135725ea5a9d8d68fb8 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 12:24:06 +0530 Subject: [PATCH 08/13] Show both name and Twitter handle on desktop notification --- data/js/ui.main.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/data/js/ui.main.js b/data/js/ui.main.js index 5316a8dc..51946d6b 100644 --- a/data/js/ui.main.js +++ b/data/js/ui.main.js @@ -182,13 +182,20 @@ function load_tweet_success(self, json) { // notify if (ui.Main.views[self.name].use_notify) { var user = ''; var text = ''; - var notify_count = 0 + var notify_count = 0, displayName = '' for (var i = 0; i < self.incoming_num && i <= 3; i += 1) { user = json[i].hasOwnProperty('user') ? json[i].user : json[i].sender; if (user.screen_name == globals.myself.screen_name) continue; text = json[i].text; - hotot_notify(user.screen_name, text, user.profile_image_url , 'content'); + + displayName = '@' + user.screen_name + + if(user.hasOwnProperty('name')) { + displayName = user.name + ' (' + displayName + ')' + } + + hotot_notify(displayName, text, user.profile_image_url , 'content'); notify_count += 1; } if (3 < notify_count) { From 6bfa07cfce98918594022c122764fc241d093824 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 19:04:29 +0530 Subject: [PATCH 09/13] build.sh: quick build and run script to help development --- build.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..6e546c13 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +ROOT=$(realpath $(dirname $0)); + + +# Uninstall +sudo find /{usr,etc,var} -type d -name '*hotot*' -exec rm -fr {} \; +sudo find /{usr,etc,var} -type f -name '*hotot*' -exec rm -f {} \; + +rm -fr build && mkdir build && cd build + +cmake -DPYTHON_EXECUTABLE=/usr/bin/python2 -DWITH_GIR=off -DWITH_QT=off -DWITH_KDE=off -DWITH_CHROME=off -DWITH_GTK3=off -DWITH_GTK2=on -DWITH_GTK=off .. +make +sudo make install + +hotot From 8b2548ce3dba45183884bcb8e1b0c95f3f970b8b Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 19:08:41 +0530 Subject: [PATCH 10/13] Refactored the display name building into separate function --- data/js/ui.main.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/data/js/ui.main.js b/data/js/ui.main.js index 51946d6b..e432caee 100644 --- a/data/js/ui.main.js +++ b/data/js/ui.main.js @@ -165,6 +165,18 @@ function loadmore_messages(self, success, fail) { success); }, +getDisplayName: +function getDisplayName(user) { + const + displayName = '@' + user.screen_name + + if(user.hasOwnProperty('name')) { + return user.name + ' (' + displayName + ')' + } + + return displayName +}, + load_tweet_success: function load_tweet_success(self, json) { var ret = ui.Main.add_tweets(self, json, false); @@ -182,20 +194,14 @@ function load_tweet_success(self, json) { // notify if (ui.Main.views[self.name].use_notify) { var user = ''; var text = ''; - var notify_count = 0, displayName = '' + var notify_count = 0 for (var i = 0; i < self.incoming_num && i <= 3; i += 1) { user = json[i].hasOwnProperty('user') ? json[i].user : json[i].sender; if (user.screen_name == globals.myself.screen_name) continue; text = json[i].text; - displayName = '@' + user.screen_name - - if(user.hasOwnProperty('name')) { - displayName = user.name + ' (' + displayName + ')' - } - - hotot_notify(displayName, text, user.profile_image_url , 'content'); + hotot_notify(ui.Main.getDisplayName(user), text, user.profile_image_url , 'content'); notify_count += 1; } if (3 < notify_count) { From eb625138ab2bbadf31e86e21d7b9fc17c3c2b6e9 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 19:10:14 +0530 Subject: [PATCH 11/13] Show name only when name and twitter handle are same Note: ignoring white spaces --- data/js/ui.main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/data/js/ui.main.js b/data/js/ui.main.js index e432caee..758069a6 100644 --- a/data/js/ui.main.js +++ b/data/js/ui.main.js @@ -168,9 +168,17 @@ function loadmore_messages(self, success, fail) { getDisplayName: function getDisplayName(user) { const - displayName = '@' + user.screen_name + displayName = '@' + user.screen_name, + + sanitize = function(text) { + return text.replace(/\s/, '').toLowerCase() + } if(user.hasOwnProperty('name')) { + if(sanitize(user.name) === sanitize(user.screen_name)) { + return user.name + } + return user.name + ' (' + displayName + ')' } From 3e6d5a955d729eb1afe1097b76aa1b90a02da85d Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 19:14:00 +0530 Subject: [PATCH 12/13] Show both name and/or Twitter handle in tweets, search and people lists --- data/js/ui.template.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/data/js/ui.template.js b/data/js/ui.template.js index f04cc347..22736e52 100644 --- a/data/js/ui.template.js +++ b/data/js/ui.template.js @@ -44,7 +44,7 @@ tweet_t:
    \ \
    {%TEXT%}
    \ @@ -150,7 +150,7 @@ message_t:
    \ \ \ @@ -185,7 +185,7 @@ search_t:
    \ \
    {%TEXT%}
    \ @@ -219,7 +219,7 @@ people_t:
    \ \
    {%DESCRIPTION%}
    \ @@ -747,6 +747,7 @@ function form_dm(dm_obj, pagename) { m.ID = pagename + '-' + dm_obj.id_str; m.TWEET_ID = dm_obj.id_str; m.SCREEN_NAME = dm_obj.sender.screen_name; + m.DISPLAY_NAME = ui.Main.getDisplayName(dm_obj.sender) m.RECIPIENT_SCREEN_NAME = dm_obj.recipient.screen_name; m.USER_NAME = dm_obj.sender.name; m.DESCRIPTION = dm_obj.sender.description; @@ -870,7 +871,8 @@ function form_tweet (tweet_obj, pagename, in_thread) { m.RETWEET_ID = retweet_id; m.REPLY_ID = reply_id != null? reply_id:''; m.IN_THREAD = in_thread; - m.SCREEN_NAME = tweet_obj.user.screen_name; + m.SCREEN_NAME = tweet_obj.user.screen_name + m.DISPLAY_NAME = ui.Main.getDisplayName(tweet_obj.user) m.REPLY_NAME = reply_id != null? reply_name: ''; m.USER_NAME = tweet_obj.user.name; m.DESCRIPTION = tweet_obj.user.description; @@ -1037,6 +1039,7 @@ function form_search(tweet_obj, pagename) { m.ID = pagename + '-' + id; m.TWEET_ID = id; m.SCREEN_NAME = tweet_obj.from_user; + m.DISPLAY_NAME = ui.Main.getDisplayName({ 'screen_name': tweet_obj.from_user, 'name': tweet_obj.from_user_name }) m.USER_NAME = tweet_obj.from_user_name; m.PROFILE_IMG = tweet_obj.profile_image_url; m.TEXT = text; @@ -1058,6 +1061,7 @@ function form_people(user_obj, pagename) { var m = ui.Template.people_m; m.USER_ID = pagename + '-' + user_obj.id_str; m.SCREEN_NAME = user_obj.screen_name; + m.DISPLAY_NAME = ui.Main.getDisplayName(user_obj) m.USER_NAME = user_obj.name; m.DESCRIPTION = user_obj.description; m.PROFILE_IMG = user_obj.profile_image_url; From c140d5a942ab1cf75246d6d1609c1981aeacf5f3 Mon Sep 17 00:00:00 2001 From: Sudaraka Wijesinghe Date: Sun, 17 Apr 2016 20:13:44 +0530 Subject: [PATCH 13/13] Ignore all character not supported in Twitter handles when comparing names As of today, Twitter only allow letters, numbers and _ (undescore) in the handle. --- data/js/ui.main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/js/ui.main.js b/data/js/ui.main.js index 758069a6..ee9b68bd 100644 --- a/data/js/ui.main.js +++ b/data/js/ui.main.js @@ -171,7 +171,7 @@ function getDisplayName(user) { displayName = '@' + user.screen_name, sanitize = function(text) { - return text.replace(/\s/, '').toLowerCase() + return text.replace(/[^a-z0-9_]/i, '').toLowerCase() } if(user.hasOwnProperty('name')) {