From bc2d7b7d0fc92adf2285c828e7bdc66957fed61e Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 24 Jun 2013 17:05:23 -0400 Subject: [PATCH] added twitter intent, regarding issue #35 --- public/src/forum/category.js | 8 +++++++- public/templates/category.tpl | 6 ++---- src/categories.js | 9 ++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 99c4d300e0..83bea12460 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -1,9 +1,15 @@ (function() { var cid = templates.get('category_id'), - room = 'category_' + cid; + room = 'category_' + cid, + twitterEl = document.getElementById('twitter-intent'), + twitter_url = templates.get('twitter-intent-url'); app.enter_room(room); + twitterEl.addEventListener('click', function() { + window.open(twitter_url, '_blank', 'width=550,height=420,scrollbars=no,status=no'); + }, false); + var new_post = document.getElementById('new_post'); new_post.onclick = function() { require(['composer'], function(cmp) { diff --git a/public/templates/category.tpl b/public/templates/category.tpl index 12832d7ba1..681638d828 100644 --- a/public/templates/category.tpl +++ b/public/templates/category.tpl @@ -50,7 +50,7 @@
    -   +    
@@ -85,8 +85,6 @@ - - - + \ No newline at end of file diff --git a/src/categories.js b/src/categories.js index 69b1049e58..0b2082d88d 100644 --- a/src/categories.js +++ b/src/categories.js @@ -12,9 +12,11 @@ var RDB = require('./redis.js'), RDB.multi() .get('cid:' + category_id + ':name') .smembers('cid:' + category_id + ':active_users') + .get('cid:' + category_id + ':slug') .exec(function(err, replies) { - var category_name = replies[0]; - var active_users = replies[1]; + var category_name = replies[0], + active_users = replies[1], + category_slug = replies[2]; if (category_name === null) { callback(false); @@ -28,7 +30,8 @@ var RDB = require('./redis.js'), 'topic_row_size': 'span9', 'category_id': category_id, 'active_users': [], - 'topics' : [] + 'topics' : [], + 'twitter-intent-url': 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(global.config.url + 'category/' + category_id + '/' + category_slug) + '&text=' + encodeURIComponent(category_name) }; function getTopics(next) {