版本: <%= config.version %>
+ © 2012
本社区为开源系统,版本: <%= config.version %> ,欢迎贡献代码
由 NAE 为 <%= config.name %> 提供动力
diff --git a/.gitignore b/.gitignore index 8f7a411..94a5da4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ config.js node_modules .naeindex public/user_data + +.monitor diff --git a/History.md b/History.md index 7bb9a25..5af9a34 100644 Binary files a/History.md and b/History.md differ diff --git a/app.js b/app.js index 2ab1880..59fa68f 100644 --- a/app.js +++ b/app.js @@ -63,5 +63,6 @@ app.configure('production', function(){ routes(app); app.listen(config.port); -//console.log("NodeClub listening on port %d in %s mode", app.address().port, app.settings.env); +console.log("NodeClub listening on port %d in %s mode", app.address().port, app.settings.env); console.log("God bless love...."); +console.log("You can debug your app with http://localhost:"+app.address().port); diff --git a/config.default.js b/config.default.js index fb605e9..18677bf 100644 --- a/config.default.js +++ b/config.default.js @@ -9,7 +9,7 @@ exports.config = { // site settings site_headers: [ - '', + '', ], host: 'http://127.0.0.1', // host 结尾不要添加'/' site_logo: '', // default is `name` diff --git a/controllers/site.js b/controllers/site.js index 103137a..7d97f23 100644 --- a/controllers/site.js +++ b/controllers/site.js @@ -28,7 +28,8 @@ exports.index = function(req,res,next){ }); var recent_tags = tags.slice(0,5); - res.render('index',{tags:all_tags,topics:topics,current_page:page,list_topic_count:limit,hot_tags:hot_tags,recent_tags:recent_tags, + //res.render('index',{tags:all_tags,topics:topics,current_page:page,list_topic_count:limit,hot_tags:hot_tags,recent_tags:recent_tags, + res.render('index',{tags:all_tags,topics:topics,current_page:page,list_topic_count:limit,recent_tags:recent_tags, hot_topics:hot_topics,stars:stars,tops:tops,no_reply_topics:no_reply_topics,pages:pages}); }; diff --git a/controllers/topic.js b/controllers/topic.js index 76050fd..a08c4b7 100644 --- a/controllers/topic.js +++ b/controllers/topic.js @@ -11,6 +11,7 @@ var Tag = models.Tag; var Topic = models.Topic; var TopicTag = models.TopicTag; var TopicCollect = models.TopicCollect; +var Relation = models.Relation; var check = require('validator').check; var sanitize = require('validator').sanitize; var at_ctrl = require('./at'); @@ -33,12 +34,13 @@ exports.index = function(req, res, next) { if (topic_id.length !== 24) { return res.render('notify/notify', { error: '此话题不存在或已被删除。' }); } - var events = [ 'topic', 'other_topics', 'no_reply_topics', '@user' ]; - var ep = EventProxy.create(events, function(topic, other_topics, no_reply_topics) { + var events = [ 'topic', 'other_topics', 'no_reply_topics', 'get_relation', '@user' ]; + var ep = EventProxy.create(events, function(topic, other_topics, no_reply_topics, relation) { res.render('topic/index', { topic: topic, author_other_topics: other_topics, - no_reply_topics: no_reply_topics + no_reply_topics: no_reply_topics, + relation : relation }); }); ep.on('error', function(err) { @@ -59,6 +61,7 @@ exports.index = function(req, res, next) { return res.render('notify/notify', { error: message }); } + at_ctrl.link_at_who(topic.content, function(err, content) { if (err) return ep.emit('error', err); topic.content = content; @@ -91,12 +94,23 @@ exports.index = function(req, res, next) { } }); + //get author's relationship + if(!req.session.user._id){ + ep.emit('get_relation',null); + }else{ + + Relation.findOne({user_id:req.session.user._id, follow_id: topic.author_id},function(err,relation){ + if (err) return ep.emit('error', err); + ep.emit('get_relation',relation); + }); + } + // get author other topics var options = { limit: 5, sort: [ [ 'last_reply_at', 'desc' ] ]}; var query = { author_id: topic.author_id, _id: { '$nin': [ topic._id ] } }; get_topics_by_query(query, options, function(err,topics){ if (err) return ep.emit('error', err); - ep.emit('other_topics', topics); + ep.emit('other_topics', topics); }); // get no reply topics @@ -545,12 +559,13 @@ function get_full_topic(id,cb){ return cb(null, '话题的作者丢了。'); } proxy.trigger('author',author); - }); + }); reply_ctrl.get_replies_by_topic_id(topic._id,function(err,replies){ if(err) return cb(err); proxy.trigger('replies',replies); }); + }); } diff --git a/controllers/user.js b/controllers/user.js index 42a611e..151a6b6 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -16,7 +16,7 @@ var EventProxy = require('eventproxy').EventProxy; var check = require('validator').check, sanitize = require('validator').sanitize; - + var crypto = require('crypto'); exports.index = function(req,res,next){ @@ -63,6 +63,7 @@ exports.index = function(req,res,next){ }else{ Relation.findOne({user_id:req.session.user._id,follow_id:user._id},function(err,doc){ if(err) return next(err); + proxy.trigger('relation',doc); }); } diff --git a/views/index.html b/views/index.html index 4c83160..b6e1d3b 100644 --- a/views/index.html +++ b/views/index.html @@ -2,9 +2,9 @@
无
+ <% } %> +无
- <% } %> -