added twitter intent, regarding issue #35

v1.18.x
Julian Lam 12 years ago
parent d0e5c0dcf1
commit bc2d7b7d0f

@ -1,9 +1,15 @@
(function() { (function() {
var cid = templates.get('category_id'), 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); 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'); var new_post = document.getElementById('new_post');
new_post.onclick = function() { new_post.onclick = function() {
require(['composer'], function(cmp) { require(['composer'], function(cmp) {

@ -50,7 +50,7 @@
<div class="block-header"> <div class="block-header">
<a target="_blank" href="../{category_id}.rss"><i class="icon-rss-sign icon-2x"></i></a>&nbsp; <a target="_blank" href="../{category_id}.rss"><i class="icon-rss-sign icon-2x"></i></a>&nbsp;
<i class="icon-facebook-sign icon-2x"></i>&nbsp; <i class="icon-facebook-sign icon-2x"></i>&nbsp;
<i class="icon-twitter-sign icon-2x"></i>&nbsp; <a href="#" id="twitter-intent"><i class="icon-twitter-sign icon-2x"></i></a>&nbsp;
<i class="icon-google-plus-sign icon-2x"></i>&nbsp; <i class="icon-google-plus-sign icon-2x"></i>&nbsp;
</div> </div>
</div> </div>
@ -85,8 +85,6 @@
</div> </div>
</div> </div>
<input type="hidden" template-variable="category_id" value="{category_id}" /> <input type="hidden" template-variable="category_id" value="{category_id}" />
<input type="hidden" template-variable="twitter-intent-url" value="{twitter-intent-url}" />
<script type="text/javascript" src="/src/forum/category.js"></script> <script type="text/javascript" src="/src/forum/category.js"></script>

@ -12,9 +12,11 @@ var RDB = require('./redis.js'),
RDB.multi() RDB.multi()
.get('cid:' + category_id + ':name') .get('cid:' + category_id + ':name')
.smembers('cid:' + category_id + ':active_users') .smembers('cid:' + category_id + ':active_users')
.get('cid:' + category_id + ':slug')
.exec(function(err, replies) { .exec(function(err, replies) {
var category_name = replies[0]; var category_name = replies[0],
var active_users = replies[1]; active_users = replies[1],
category_slug = replies[2];
if (category_name === null) { if (category_name === null) {
callback(false); callback(false);
@ -28,7 +30,8 @@ var RDB = require('./redis.js'),
'topic_row_size': 'span9', 'topic_row_size': 'span9',
'category_id': category_id, 'category_id': category_id,
'active_users': [], '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) { function getTopics(next) {

Loading…
Cancel
Save