Loading comments/app.js +2 −1 Original line number Diff line number Diff line Loading @@ -99,7 +99,8 @@ app.get('/auth/:sdk/:version/comments_recent', function(req, res) { limit: parseInt(req.query.limit, 10), orderBy: req.query.sortByScore ? "vote" : "created_at", hideCurrentUser: req.query.hideCurrentUser, hideRead: req.query.hideRead hideRead: req.query.hideRead, username: req.query.username }; new Request(req).getRecentComments(query, function(comments) { res.json(comments); Loading comments/lib/comments.js +5 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ Comments.prototype = { * Two possible options here: "created_at" and "vote". * @param {Number} [opts.hideUser=undefined] A user_id to hide. * @param {Number} [opts.hideRead=false] True to hide comments marked as read. * @param {Number} [opts.username=undefined] The name of the user who's comments to show. * * @param {Function} callback Called with the result. * @param {Error} callback.err The error object. Loading @@ -138,6 +139,7 @@ Comments.prototype = { * * @param {Object} opts Options for the query: * @param {Number} [opts.hideUser=undefined] A user_id to hide. * @param {Number} [opts.username=undefined] The name of the user who's comments to show. * * @param {Function} callback Called with the result. * @param {Error} callback.err The error object. Loading @@ -164,6 +166,9 @@ Comments.prototype = { if (opts.hideRead) { where.push(this.getReadExpression() + " = 0"); } if (opts.username) { where.push(this.db.format("username = ?", [opts.username])); } return where.join(" AND "); }, Loading comments/spec/comments.spec.js +14 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,13 @@ describe("Comments", function() { }); }); it("#findRecent with username:renku includes only comments by that user", function(done) { comments.findRecent({username: "renku"}, function(err, rows) { expect(rows.every(function(r){return r.username === "renku";})).toEqual(true); done(); }); }); it("#count gets total number of comments in current domain", function(done) { comments.count({}, function(err, cnt) { expect(cnt).toEqual(24); Loading Loading @@ -206,6 +213,13 @@ describe("Comments", function() { }); }); it("#count with username:renku includes only comments of that user", function(done) { comments.count({username: "renku"}, function(err, cnt) { expect(cnt).toEqual(5); done(); }); }); it("#countPerTarget gets number of comments for each target", function(done) { comments.countsPerTarget(function(err, counts) { var line = counts.filter(function(row) { return row._id === "class__Ext__"; })[0]; Loading template/app/controller/Comments.js +12 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ Ext.define('Docs.controller.Comments', { } ], // Recent comments query parameters that aren't saved into cookies. recentCommentsSettings: {}, init: function() { this.addEvents( /** Loading Loading @@ -145,6 +148,13 @@ Ext.define('Docs.controller.Comments', { } }, 'topusers': { select: function(username) { this.recentCommentsSettings.username = username; this.fetchRecentComments(); } }, 'classoverview toolbar': { commentcountclick: function(cmp) { var commentsDiv = Ext.get(Ext.query('.comments-section .comments-div')[0]); Loading Loading @@ -287,7 +297,8 @@ Ext.define('Docs.controller.Comments', { limit: 100, hideRead: settings.hideRead ? 1 : undefined, hideCurrentUser: settings.hideCurrentUser ? 1 : undefined, sortByScore: settings.sortByScore ? 1 : undefined sortByScore: settings.sortByScore ? 1 : undefined, username: this.recentCommentsSettings.username }; this.getCommentsList().setMasked(true); Loading template/app/view/comments/TopUsers.js +26 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,31 @@ Ext.define('Docs.view.comments.TopUsers', { afterRender: function() { this.callParent(arguments); this.fetchUsers("votes"); this.initClickHandlers(); }, initClickHandlers: function() { this.usersList.getEl().on("click", function(event, target) { var username = target.innerHTML; var li = Ext.get(target).up("li"); // remove "selected" class from all other items and add it // to the current item unless it was already selected // before, in which case all items become unselected. var wasSelected = li.hasCls("selected"); this.usersList.getEl().select("li").removeCls("selected"); if (!wasSelected) { li.addCls("selected"); } /** * @event select * Fired when user is selected from users list. * @param {String} username The name of the user * or undefined when all users were deselected. */ this.fireEvent("select", wasSelected ? undefined : username); }, this, {preventDefault: true, delegate: "a"}); }, fetchUsers: function(sortBy) { Loading @@ -84,7 +109,7 @@ Ext.define('Docs.view.comments.TopUsers', { '<span class="score">{score}</span>', '<img class="avatar" width="25" height="25" src="http://www.gravatar.com/avatar/{emailHash}', '?s=25&r=PG&d=http://www.sencha.com/img/avatar.png">', '<span class="username <tpl if="moderator">moderator</tpl>">{username}</span>', '<a href="#" class="username <tpl if="moderator">moderator</tpl>">{username}</a>', '</li>', '</tpl>', '</ul>' Loading Loading
comments/app.js +2 −1 Original line number Diff line number Diff line Loading @@ -99,7 +99,8 @@ app.get('/auth/:sdk/:version/comments_recent', function(req, res) { limit: parseInt(req.query.limit, 10), orderBy: req.query.sortByScore ? "vote" : "created_at", hideCurrentUser: req.query.hideCurrentUser, hideRead: req.query.hideRead hideRead: req.query.hideRead, username: req.query.username }; new Request(req).getRecentComments(query, function(comments) { res.json(comments); Loading
comments/lib/comments.js +5 −0 Original line number Diff line number Diff line Loading @@ -114,6 +114,7 @@ Comments.prototype = { * Two possible options here: "created_at" and "vote". * @param {Number} [opts.hideUser=undefined] A user_id to hide. * @param {Number} [opts.hideRead=false] True to hide comments marked as read. * @param {Number} [opts.username=undefined] The name of the user who's comments to show. * * @param {Function} callback Called with the result. * @param {Error} callback.err The error object. Loading @@ -138,6 +139,7 @@ Comments.prototype = { * * @param {Object} opts Options for the query: * @param {Number} [opts.hideUser=undefined] A user_id to hide. * @param {Number} [opts.username=undefined] The name of the user who's comments to show. * * @param {Function} callback Called with the result. * @param {Error} callback.err The error object. Loading @@ -164,6 +166,9 @@ Comments.prototype = { if (opts.hideRead) { where.push(this.getReadExpression() + " = 0"); } if (opts.username) { where.push(this.db.format("username = ?", [opts.username])); } return where.join(" AND "); }, Loading
comments/spec/comments.spec.js +14 −0 Original line number Diff line number Diff line Loading @@ -163,6 +163,13 @@ describe("Comments", function() { }); }); it("#findRecent with username:renku includes only comments by that user", function(done) { comments.findRecent({username: "renku"}, function(err, rows) { expect(rows.every(function(r){return r.username === "renku";})).toEqual(true); done(); }); }); it("#count gets total number of comments in current domain", function(done) { comments.count({}, function(err, cnt) { expect(cnt).toEqual(24); Loading Loading @@ -206,6 +213,13 @@ describe("Comments", function() { }); }); it("#count with username:renku includes only comments of that user", function(done) { comments.count({username: "renku"}, function(err, cnt) { expect(cnt).toEqual(5); done(); }); }); it("#countPerTarget gets number of comments for each target", function(done) { comments.countsPerTarget(function(err, counts) { var line = counts.filter(function(row) { return row._id === "class__Ext__"; })[0]; Loading
template/app/controller/Comments.js +12 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,9 @@ Ext.define('Docs.controller.Comments', { } ], // Recent comments query parameters that aren't saved into cookies. recentCommentsSettings: {}, init: function() { this.addEvents( /** Loading Loading @@ -145,6 +148,13 @@ Ext.define('Docs.controller.Comments', { } }, 'topusers': { select: function(username) { this.recentCommentsSettings.username = username; this.fetchRecentComments(); } }, 'classoverview toolbar': { commentcountclick: function(cmp) { var commentsDiv = Ext.get(Ext.query('.comments-section .comments-div')[0]); Loading Loading @@ -287,7 +297,8 @@ Ext.define('Docs.controller.Comments', { limit: 100, hideRead: settings.hideRead ? 1 : undefined, hideCurrentUser: settings.hideCurrentUser ? 1 : undefined, sortByScore: settings.sortByScore ? 1 : undefined sortByScore: settings.sortByScore ? 1 : undefined, username: this.recentCommentsSettings.username }; this.getCommentsList().setMasked(true); Loading
template/app/view/comments/TopUsers.js +26 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,31 @@ Ext.define('Docs.view.comments.TopUsers', { afterRender: function() { this.callParent(arguments); this.fetchUsers("votes"); this.initClickHandlers(); }, initClickHandlers: function() { this.usersList.getEl().on("click", function(event, target) { var username = target.innerHTML; var li = Ext.get(target).up("li"); // remove "selected" class from all other items and add it // to the current item unless it was already selected // before, in which case all items become unselected. var wasSelected = li.hasCls("selected"); this.usersList.getEl().select("li").removeCls("selected"); if (!wasSelected) { li.addCls("selected"); } /** * @event select * Fired when user is selected from users list. * @param {String} username The name of the user * or undefined when all users were deselected. */ this.fireEvent("select", wasSelected ? undefined : username); }, this, {preventDefault: true, delegate: "a"}); }, fetchUsers: function(sortBy) { Loading @@ -84,7 +109,7 @@ Ext.define('Docs.view.comments.TopUsers', { '<span class="score">{score}</span>', '<img class="avatar" width="25" height="25" src="http://www.gravatar.com/avatar/{emailHash}', '?s=25&r=PG&d=http://www.sencha.com/img/avatar.png">', '<span class="username <tpl if="moderator">moderator</tpl>">{username}</span>', '<a href="#" class="username <tpl if="moderator">moderator</tpl>">{username}</a>', '</li>', '</tpl>', '</ul>' Loading