From 55998085e3d6409908eec59ede031e4d5a44f2dd Mon Sep 17 00:00:00 2001 From: Nick Gordon Date: Sat, 16 Nov 2013 09:24:01 -0800 Subject: [PATCH 1/9] fixed the issue with case insensitive highlighting highlighting short usernames how this works: * rather than throw an expensive regular expression at each chat message, we start by checking to see if the users name exists. * then, by simple string manipulation we verify that the preceeding character before the alleged username is whitespace, the start of a line, or an '@' character. * FINALLY, we verify the following character is a non-word character using a regular expression. * then we cache the highlight status on the local `message` object, because for some reason, this function is called **every time a character is typed in the chatbox.** this seems like a hugh performance problem to me, need to see if there is a way to disable that or something --- public/js/controllers/groupsCtrl.js | 18 ++++++++++++++++++ views/options/social/chat-message.jade | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/js/controllers/groupsCtrl.js b/public/js/controllers/groupsCtrl.js index ab7c90e1c0..61266721df 100644 --- a/public/js/controllers/groupsCtrl.js +++ b/public/js/controllers/groupsCtrl.js @@ -128,6 +128,24 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A .controller('ChatCtrl', ['$scope', 'Groups', 'User', function($scope, Groups, User){ $scope.message = {content:''}; $scope._sending = false; + + $scope.isUserMentioned = function(user, message) { + if(message.hasOwnProperty("highlight")) + return message.highlight; + message.highlight = false; + var messagetext = message.text.toLowerCase(); + var username = user.profile.name; + var mentioned = messagetext.indexOf(username.toLowerCase()); + var pattern = "(\s|@|^){1}"+username+"([^\w]|$){1}"; + if(mentioned > -1) { + var preceedingchar = messagetext.substring(mentioned-1,mentioned); + if(mentioned == 0 || preceedingchar.trim() == '' || preceedingchar == '@'){ + var regex = new RegExp(pattern,'i'); + message.highlight = regex.test(messagetext); + } + } + return message.highlight; + } $scope.postChat = function(group, message){ if (_.isEmpty(message) || $scope._sending) return; diff --git a/views/options/social/chat-message.jade b/views/options/social/chat-message.jade index 95f94a8678..cb9bde9188 100644 --- a/views/options/social/chat-message.jade +++ b/views/options/social/chat-message.jade @@ -1,4 +1,4 @@ -li(ng-repeat='message in group.chat', ng-class='{highlight: indexOf(message.text.toLowerCase(), user.profile.name.toLowerCase()), "own-message": user._id == message.uuid}') +li(ng-repeat='message in group.chat', ng-class='{highlight: isUserMentioned(user,message), "own-message": user._id == message.uuid}') a.label.chat-message(class='label-contributor-{{message.contributor.level}}', ng-class='{"label-npc": message.backer.npc}', ng-click='clickMember(message.uuid, true)') span(tooltip='{{contribText(message.contributor, message.backer)}}') {{message.user}}  |   From 34d5eda7361fb13698c8aa169f4919a227d2ec38 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 17 Nov 2013 13:21:21 +0100 Subject: [PATCH 2/9] [#1832] remove relative-date, use moment instead --- package.json | 1 - public/js/controllers/rootCtrl.js | 1 + views/options/social/chat-message.jade | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f1f5636c67..a91d8b5289 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "superagent": "~0.12.4", "resolve": "~0.2.3", "expect.js": "~0.2.0", - "relative-date": "~1.1.1", "lodash": "~2.2.1", "async": "~0.2.9", "optimist": "~0.5.2", diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index 607bd333e7..a241e83656 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -41,6 +41,7 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ */ _.defaults($rootScope, window.habitrpgShared.algos); _.defaults($rootScope, window.habitrpgShared.helpers); + $rootScope.moment = window.moment; $rootScope.set = User.set; $rootScope.authenticated = User.authenticated; diff --git a/views/options/social/chat-message.jade b/views/options/social/chat-message.jade index cb9bde9188..f94d2820ea 100644 --- a/views/options/social/chat-message.jade +++ b/views/options/social/chat-message.jade @@ -5,6 +5,6 @@ li(ng-repeat='message in group.chat', ng-class='{highlight: isUserMentioned(user span(ng-bind-html="message.text | linky:'_blank'") |  -  span.muted.time - | {{relativeDate(message.timestamp, _currentTime) + ' '}} + | {{moment(message.timestamp).fromNow() + ' '}} a(ng-show='user.contributor.admin || message.uuid == user.id', ng-click='deleteChatMessage(group, message)') i.icon-remove(tooltip='Delete') From b83eb0ee28308ecf08e8a00d7150621d2dae1ac9 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 17 Nov 2013 13:28:57 +0100 Subject: [PATCH 3/9] moment is exported as an helper by habitrpg-shared --- public/js/controllers/rootCtrl.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index a241e83656..607bd333e7 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -41,7 +41,6 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ */ _.defaults($rootScope, window.habitrpgShared.algos); _.defaults($rootScope, window.habitrpgShared.helpers); - $rootScope.moment = window.moment; $rootScope.set = User.set; $rootScope.authenticated = User.authenticated; From f448f4b71b29cc385cc9dd06d2eff9ade7157242 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 17 Nov 2013 13:32:44 +0100 Subject: [PATCH 4/9] bower.json auto update --- bower.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 314e9d0456..51760dbeda 100644 --- a/bower.json +++ b/bower.json @@ -38,8 +38,7 @@ }, "resolutions": { "jquery": "~2.0.3", - "bootstrap": "v2.3.2", - "angular": "~1.2.1" + "bootstrap": "v2.3.2" }, "devDependencies": { "angular-mocks": "~1.2.1" From 44a82c71e21bee8c3668b41edb6231f8791a525e Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Sun, 17 Nov 2013 07:40:19 -0600 Subject: [PATCH 5/9] Remove bland/harsh border styling on eggs and avatar options. Falls back to a button look that's much nicer. --- public/css/customizer.styl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/customizer.styl b/public/css/customizer.styl index fd9391fa9d..1bb04b43ba 100644 --- a/public/css/customizer.styl +++ b/public/css/customizer.styl @@ -22,7 +22,7 @@ menu line-height: 2 .customize-option - border: 1px solid grey; +// border: 1px solid grey; background-color: hsl(0, 0%, 93%); margin-bottom: 10px From cb64ab5a7d5a605dbd6c91d53ea4c7b0ae4d6dfe Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Sun, 17 Nov 2013 08:09:23 -0600 Subject: [PATCH 6/9] Make it easier for people to find "how to contribute" wiki page --- views/options/social/tavern.jade | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/views/options/social/tavern.jade b/views/options/social/tavern.jade index 0fad9b0fe0..eded297e3a 100644 --- a/views/options/social/tavern.jade +++ b/views/options/social/tavern.jade @@ -47,10 +47,12 @@ // Player Tiers .modal(style='position: relative;top: auto;left: auto;right: auto;margin: 0 auto 20px;z-index: 1;max-width: 100%;') .modal-header - h3 Player Tier Legend + h3 Player Tiers .modal-body small. - Click labels to expand. See contribution details. + Click tier labels below for more information.
+ Learn more about contributor rewards
+ Learn how to contribute to HabitRPG table.table.table-striped tr td From 75ce46d4af2c0b5bf5ca8dd9006adbbb96626378 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Sun, 17 Nov 2013 16:12:25 +0100 Subject: [PATCH 7/9] moment version consistent with habitrpg-shared --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a91d8b5289..e1c1945076 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "express": "*", "gzippo": "*", "guid": "*", - "moment": "*", + "moment": "~2.4.0", "stripe": "*", "coffee-script": "*", "nconf": "*", From b701e2b24af00ff1cd78fc7cf516b635a040ae7d Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Sun, 17 Nov 2013 10:21:43 -0600 Subject: [PATCH 8/9] Go with the borderless option --- public/css/customizer.styl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/css/customizer.styl b/public/css/customizer.styl index 1bb04b43ba..021048869c 100644 --- a/public/css/customizer.styl +++ b/public/css/customizer.styl @@ -22,7 +22,7 @@ menu line-height: 2 .customize-option -// border: 1px solid grey; + border: 0px solid grey; background-color: hsl(0, 0%, 93%); margin-bottom: 10px From 5fffc32ad330f692c1b1c92b671d2328aa5929cb Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 17 Nov 2013 11:09:31 -0800 Subject: [PATCH 9/9] [#1844] some tasks have their "type" incorrectly set. I need to find out what's causing this, for now fix in database --- migrations/20131117_fix_task_types.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 migrations/20131117_fix_task_types.js diff --git a/migrations/20131117_fix_task_types.js b/migrations/20131117_fix_task_types.js new file mode 100644 index 0000000000..14d86cb55f --- /dev/null +++ b/migrations/20131117_fix_task_types.js @@ -0,0 +1,18 @@ +// TODO figure out why this is happening in the first place + +db.users.find({},{habits:1, dailys:1, todos:1, rewards:1}).forEach(function(user){ + _.each(user.habits, function(task){ + task.type = 'habit'; + }) + _.each(user.dailys, function(task){ + task.type = 'daily'; + }) + _.each(user.todos, function(task){ + task.type = 'todo'; + }) + _.each(user.rewards, function(task){ + task.type = 'reward'; + }) + + db.users.update({_id:user._id}, {$set:{habits: user.habits, dailys: user.dailys, todos: user.todos, rewards: user.rewards}}); +});