Permalink
Browse files

reformat 所有代码

  • Loading branch information...
1 parent 4b4b63d commit 7e030b5d9ffc8330273ab1c9990612748df1419e @alsotang alsotang committed Aug 12, 2014
Showing with 27,006 additions and 17,659 deletions.
  1. +1 −1 .jshintrc
  2. +2 −2 common/render_helpers.js
  3. +1 −1 config.default.js
  4. +7 −6 controllers/reply.js
  5. +3 −1 controllers/rss.js
  6. +8 −5 controllers/sign.js
  7. +18 −5 controllers/site.js
  8. +9 −3 controllers/tag.js
  9. +7 −3 controllers/topic.js
  10. +22 −8 controllers/user.js
  11. +47 −47 libs/util.js
  12. +7 −7 models/reply.js
  13. +2 −2 models/user.js
  14. +4 −4 newrelic.js
  15. +908 −1 plugins/wordpress_redirect/cnodeblog.posts.json
  16. +1 −1 plugins/wordpress_redirect/model.js
  17. +6 −2 proxy/message.js
  18. +3 −1 proxy/reply.js
  19. +3 −1 proxy/tag.js
  20. +4 −4 proxy/topic.js
  21. +1 −1 public/javascripts/google_search_preview.js
  22. +6 −4 public/javascripts/main.js
  23. +5 −5 public/javascripts/markdown_editor.js
  24. +59 −59 public/javascripts/responsive.js
  25. +1,272 −1,036 public/libs/bootstrap/css/bootstrap-responsive.css
  26. +1,241 −1 public/libs/bootstrap/css/bootstrap-responsive.min.css
  27. +2,636 −2,625 public/libs/bootstrap/css/bootstrap.css
  28. +5,461 −1 public/libs/bootstrap/css/bootstrap.min.css
  29. +389 −548 public/libs/bootstrap/js/bootstrap.js
  30. +643 −5 public/libs/bootstrap/js/bootstrap.min.js
  31. +12 −2 public/libs/code-prettify/lang-apollo.js
  32. +12 −4 public/libs/code-prettify/lang-clj.js
  33. +22 −2 public/libs/code-prettify/lang-css.js
  34. +7 −1 public/libs/code-prettify/lang-go.js
  35. +12 −2 public/libs/code-prettify/lang-hs.js
  36. +14 −3 public/libs/code-prettify/lang-lisp.js
  37. +11 −2 public/libs/code-prettify/lang-lua.js
  38. +11 −2 public/libs/code-prettify/lang-ml.js
  39. +21 −4 public/libs/code-prettify/lang-n.js
  40. +1 −1 public/libs/code-prettify/lang-proto.js
  41. +16 −2 public/libs/code-prettify/lang-scala.js
  42. +11 −2 public/libs/code-prettify/lang-sql.js
  43. +10 −1 public/libs/code-prettify/lang-tex.js
  44. +13 −2 public/libs/code-prettify/lang-vb.js
  45. +13 −3 public/libs/code-prettify/lang-vhdl.js
  46. +14 −2 public/libs/code-prettify/lang-wiki.js
  47. +15 −3 public/libs/code-prettify/lang-xq.js
  48. +16 −2 public/libs/code-prettify/lang-yaml.js
  49. +116 −26 public/libs/code-prettify/prettify.css
  50. +376 −28 public/libs/code-prettify/prettify.js
  51. +8,790 −8,818 public/libs/jquery-2.1.0.js
  52. +99 −77 public/libs/jquery-ujs.js
  53. +764 −764 public/libs/jquery.atwho.js
  54. +42 −42 public/libs/jquery.caret.js
  55. +486 −457 public/libs/lodash.compat.js
  56. +1,024 −1,007 public/libs/marked.js
  57. +32 −25 public/stylesheets/common.css
  58. +12 −6 public/stylesheets/jquery.atwho.css
  59. +143 −123 public/stylesheets/responsive.css
  60. +277 −130 public/stylesheets/style.less
  61. +2 −1 services/at.js
  62. +20 −18 test/controllers/github.test.js
  63. +4 −4 test/controllers/message.js
  64. +16 −16 test/controllers/rss.test.js
  65. +6 −6 test/controllers/sign.test.js
  66. +8 −8 test/controllers/topic.js
  67. +4 −4 test/controllers/upload.js
  68. +9 −9 test/controllers/user.js
  69. +7 −7 test/libs/util.js
  70. +1 −1 test/proxy/message.js
  71. +13 −13 test/services/at.js
  72. +26 −26 views/editor_sidebar.html
  73. +19 −19 views/index.html
  74. +106 −95 views/layout.html
  75. +27 −27 views/message/index.html
  76. +27 −23 views/message/message.html
  77. +20 −20 views/notify/notify.html
  78. +49 −46 views/reply/edit.html
  79. +61 −56 views/reply/reply.html
  80. +28 −24 views/reply/reply2.html
  81. +78 −77 views/sidebar.html
  82. +45 −38 views/sign/new_oauth.html
  83. +6 −5 views/sign/no_github_email.html
  84. +39 −36 views/sign/reset.html
  85. +34 −33 views/sign/search_pass.html
  86. +15 −14 views/sign/sidebar.html
  87. +39 −36 views/sign/signin.html
  88. +65 −60 views/sign/signup.html
  89. +19 −16 views/static/about.html
  90. +17 −16 views/static/faq.html
  91. +69 −55 views/tag/edit.html
  92. +92 −82 views/tag/edit_all.html
  93. +117 −112 views/tag/list_topic.html
  94. +3 −3 views/tag/tag.html
  95. +12 −8 views/tag/tag_can_edit.html
  96. +19 −19 views/topic/abstract.html
  97. +61 −58 views/topic/edit.html
  98. +230 −228 views/topic/index.html
  99. +45 −45 views/topic/list.html
  100. +2 −1 views/topic/small.html
  101. +52 −48 views/user/card.html
  102. +15 −15 views/user/collect_tags.html
  103. +16 −15 views/user/collect_topics.html
  104. +15 −15 views/user/followers.html
  105. +15 −15 views/user/followings.html
  106. +139 −134 views/user/index.html
  107. +17 −16 views/user/replies.html
  108. +2 −1 views/user/setting.html
  109. +6 −6 views/user/star.html
  110. +15 −15 views/user/stars.html
  111. +2 −2 views/user/top.html
  112. +26 −26 views/user/top100.html
  113. +15 −15 views/user/top100_user.html
  114. +17 −16 views/user/topics.html
  115. +26 −22 views/user/user.html
View
@@ -17,7 +17,7 @@
],
"browser": true,
- "node" : true,
+ "node": true,
"es5": true,
"bitwise": true,
"curly": true,
@@ -17,7 +17,7 @@ var _ = require('lodash');
// Set default options
var renderer = new marked.Renderer();
-renderer.code = function(code, lang) {
+renderer.code = function (code, lang) {
var language = lang && (' language-' + lang) || '';
return '<pre class="prettyprint' + language + '">'
+ '<code>' + code.replace(/</g, '&lt;').replace(/>/g, '&gt;') + '</code>'
@@ -34,7 +34,7 @@ marked.setOptions({
smartLists: true
});
-exports.markdown = function(text) {
+exports.markdown = function (text) {
return '<div class="markdown-text">' + utils.xss(marked(text || '')) + '</div>';
};
View
@@ -27,7 +27,7 @@ var config = {
site_static_host: '', // 静态文件存储域名
mini_assets: false, // 静态文件的合并压缩,详见视图中的Loader
site_enable_search_preview: false, // 开启google search preview
- site_google_search_domain: 'cnodejs.org', // google search preview中要搜索的域名
+ site_google_search_domain: 'cnodejs.org', // google search preview中要搜索的域名
upload_dir: path.join(__dirname, 'public', 'user_data', 'images'),
View
@@ -131,12 +131,13 @@ exports.delete = function (req, res, next) {
return;
}
- Topic.reduceCount(reply.topic_id, function () {});
+ Topic.reduceCount(reply.topic_id, function () {
+ });
});
};
/*
- 打开回复编辑器
-*/
+ 打开回复编辑器
+ */
exports.showEdit = function (req, res, next) {
if (!req.session.user) {
res.redirect('/');
@@ -164,8 +165,8 @@ exports.showEdit = function (req, res, next) {
});
};
/*
- 提交编辑回复
-*/
+ 提交编辑回复
+ */
exports.update = function (req, res, next) {
if (!req.session.user) {
res.redirect('/');
@@ -188,7 +189,7 @@ exports.update = function (req, res, next) {
reply.content = content.trim();
if (content.length > 0) {
- reply.save(function(err) {
+ reply.save(function (err) {
if (err) {
return next(err);
}
View
@@ -13,7 +13,9 @@ exports.index = function (req, res, next) {
if (!config.debug && mcache.get('rss')) {
res.send(mcache.get('rss'));
} else {
- var opt = { limit: config.rss.max_rss_items, sort: [ [ 'create_at', 'desc' ] ] };
+ var opt = { limit: config.rss.max_rss_items, sort: [
+ [ 'create_at', 'desc' ]
+ ] };
Topic.getTopicsByQuery({}, opt, function (err, topics) {
if (err) {
return next(err);
View
@@ -55,7 +55,10 @@ exports.signup = function (req, res, next) {
return;
}
- User.getUsersByQuery({'$or': [{'loginname': loginname}, {'email': email}]}, {}, function (err, users) {
+ User.getUsersByQuery({'$or': [
+ {'loginname': loginname},
+ {'email': email}
+ ]}, {}, function (err, users) {
if (err) {
return next(err);
}
@@ -234,9 +237,9 @@ exports.reset_pass = function (req, res, next) {
var now = new Date().getTime();
var oneDay = 1000 * 60 * 60 * 24;
if (!user.retrieve_time || now - user.retrieve_time > oneDay) {
- return res.render('notify/notify', {error : '该链接已过期,请重新申请。'});
+ return res.render('notify/notify', {error: '该链接已过期,请重新申请。'});
}
- return res.render('sign/reset', {name : name, key : key});
+ return res.render('sign/reset', {name: name, key: key});
});
};
@@ -246,14 +249,14 @@ exports.update_pass = function (req, res, next) {
var key = req.body.key || '';
var name = req.body.name || '';
if (psw !== repsw) {
- return res.render('sign/reset', {name : name, key : key, error : '两次密码输入不一致。'});
+ return res.render('sign/reset', {name: name, key: key, error: '两次密码输入不一致。'});
}
User.getUserByQuery(name, key, function (err, user) {
if (err) {
return next(err);
}
if (!user) {
- return res.render('notify/notify', {error : '错误的激活链接'});
+ return res.render('notify/notify', {error: '错误的激活链接'});
}
user.pass = md5(psw);
user.retrieve_key = null;
View
@@ -19,7 +19,10 @@ var mcache = require('memory-cache');
setInterval(function () {
var limit = config.list_topic_count;
// 只缓存第一页, page = 1
- var options = { skip: (1 - 1) * limit, limit: limit, sort: [ ['top', 'desc' ], [ 'last_reply_at', 'desc' ] ] };
+ var options = { skip: (1 - 1) * limit, limit: limit, sort: [
+ ['top', 'desc' ],
+ [ 'last_reply_at', 'desc' ]
+ ] };
var optionsStr = JSON.stringify(options);
Topic.getTopicsByQuery({}, options, function (err, topics) {
mcache.put(optionsStr, topics);
@@ -48,7 +51,10 @@ exports.index = function (req, res, next) {
proxy.fail(next);
// 取主题
- var options = { skip: (page - 1) * limit, limit: limit, sort: [ ['top', 'desc' ], [ 'last_reply_at', 'desc' ] ] };
+ var options = { skip: (page - 1) * limit, limit: limit, sort: [
+ ['top', 'desc' ],
+ [ 'last_reply_at', 'desc' ]
+ ] };
var optionsStr = JSON.stringify(options);
if (mcache.get(optionsStr)) {
proxy.emit('topics', mcache.get(optionsStr));
@@ -62,8 +68,13 @@ exports.index = function (req, res, next) {
proxy.emit('tops', mcache.get('tops'));
} else {
User.getUsersByQuery(
- {'$or': [{is_block: {'$exists': false}}, {is_block: false}]},
- { limit: 10, sort: [ [ 'score', 'desc' ] ] },
+ {'$or': [
+ {is_block: {'$exists': false}},
+ {is_block: false}
+ ]},
+ { limit: 10, sort: [
+ [ 'score', 'desc' ]
+ ] },
proxy.done('tops', function (tops) {
mcache.put('tops', tops, 1000 * 60 * 1);
return tops;
@@ -76,7 +87,9 @@ exports.index = function (req, res, next) {
} else {
Topic.getTopicsByQuery(
{ reply_count: 0 },
- { limit: 5, sort: [ [ 'create_at', 'desc' ] ] },
+ { limit: 5, sort: [
+ [ 'create_at', 'desc' ]
+ ] },
proxy.done('no_reply_topics', function (no_reply_topics) {
mcache.put('no_reply_topics', no_reply_topics, 1000 * 60 * 1);
return no_reply_topics;
View
@@ -23,7 +23,9 @@ exports.list_topic = function (req, res, next) {
}
var done = function (topic_ids, collection, hot_topics, no_reply_topics, pages) {
var query = {'_id': {'$in': topic_ids}};
- var opt = {skip: (page - 1) * limit, limit: limit, sort: [['create_at', 'desc']]};
+ var opt = {skip: (page - 1) * limit, limit: limit, sort: [
+ ['create_at', 'desc']
+ ]};
Topic.getTopicsByQuery(query, opt, function (err, topics) {
for (var i = 0; i < topics.length; i++) {
@@ -74,10 +76,14 @@ exports.list_topic = function (req, res, next) {
TagCollect.getTagCollect(req.session.user._id, tag._id, proxy.done('collection'));
}
- var opt = {limit: 5, sort: [['visit_count', 'desc']]};
+ var opt = {limit: 5, sort: [
+ ['visit_count', 'desc']
+ ]};
Topic.getTopicsByQuery({}, opt, proxy.done('hot_topics'));
- opt = {limit: 5, sort: [['create_at', 'desc']]};
+ opt = {limit: 5, sort: [
+ ['create_at', 'desc']
+ ]};
Topic.getTopicsByQuery({reply_count: 0}, opt, proxy.done('no_reply_topics'));
});
};
View
@@ -72,12 +72,16 @@ exports.index = function (req, res, next) {
}
// get author other topics
- var options = { limit: 5, sort: [ [ 'last_reply_at', 'desc' ] ]};
+ var options = { limit: 5, sort: [
+ [ 'last_reply_at', 'desc' ]
+ ]};
var query = { author_id: topic.author_id, _id: { '$nin': [ topic._id ] } };
Topic.getTopicsByQuery(query, options, ep.done('other_topics'));
// get no reply topics
- var options2 = { limit: 5, sort: [ ['create_at', 'desc'] ] };
+ var options2 = { limit: 5, sort: [
+ ['create_at', 'desc']
+ ] };
Topic.getTopicsByQuery({reply_count: 0}, options2, ep.done('no_reply_topics'));
}));
};
@@ -96,7 +100,7 @@ exports.put = function (req, res, next) {
}
var edit_error =
- title === '' ?
+ title === '' ?
'标题不能是空的。' :
(title.length >= 10 && title.length <= 100 ? '' : '标题字数太多或太少。');
if (edit_error) {
View
@@ -50,10 +50,14 @@ exports.index = function (req, res, next) {
proxy.fail(next);
var query = {author_id: user._id};
- var opt = {limit: 5, sort: [['create_at', 'desc']]};
+ var opt = {limit: 5, sort: [
+ ['create_at', 'desc']
+ ]};
Topic.getTopicsByQuery(query, opt, proxy.done('recent_topics'));
- Reply.getRepliesByAuthorId(user._id, {limit: 20, sort: [['create_at', 'desc']]},
+ Reply.getRepliesByAuthorId(user._id, {limit: 20, sort: [
+ ['create_at', 'desc']
+ ]},
proxy.done(function (replies) {
var topic_ids = [];
for (var i = 0; i < replies.length; i++) {
@@ -62,7 +66,9 @@ exports.index = function (req, res, next) {
}
}
var query = {_id: {'$in': topic_ids}};
- var opt = {limit: 5, sort: [['create_at', 'desc']]};
+ var opt = {limit: 5, sort: [
+ ['create_at', 'desc']
+ ]};
Topic.getTopicsByQuery(query, opt, proxy.done('recent_replies'));
}));
@@ -108,7 +114,7 @@ exports.setting = function (req, res, next) {
}
// 显示出错或成功信息
- function showMessage (msg, data, isSuccess) {
+ function showMessage(msg, data, isSuccess) {
var data = data || req.body;
var data2 = {
name: data.name,
@@ -364,7 +370,9 @@ exports.get_collect_topics = function (req, res, next) {
var opt = {
skip: (page - 1) * limit,
limit: limit,
- sort: [ [ 'create_at', 'desc' ] ]
+ sort: [
+ [ 'create_at', 'desc' ]
+ ]
};
Topic.getTopicsByQuery(query, opt, proxy.done('topics'));
Topic.getCountByQuery(query, proxy.done(function (all_topics_count) {
@@ -420,7 +428,9 @@ exports.get_followers = function (req, res, next) {
};
exports.top100 = function (req, res, next) {
- var opt = {limit: 100, sort: [['score', 'desc']]};
+ var opt = {limit: 100, sort: [
+ ['score', 'desc']
+ ]};
User.getUsersByQuery({'$or': [
{is_block: {'$exists': false}},
{is_block: false},
@@ -459,7 +469,9 @@ exports.list_topics = function (req, res, next) {
proxy.fail(next);
var query = {'author_id': user._id};
- var opt = {skip: (page - 1) * limit, limit: limit, sort: [['create_at', 'desc']]};
+ var opt = {skip: (page - 1) * limit, limit: limit, sort: [
+ ['create_at', 'desc']
+ ]};
Topic.getTopicsByQuery(query, opt, proxy.done('topics'));
if (!req.session.user) {
@@ -510,7 +522,9 @@ exports.list_replies = function (req, res, next) {
}
}
var query = {'_id': {'$in': topic_ids}};
- var opt = {skip: (page - 1) * limit, limit: limit, sort: [['create_at', 'desc']]};
+ var opt = {skip: (page - 1) * limit, limit: limit, sort: [
+ ['create_at', 'desc']
+ ]};
Topic.getTopicsByQuery(query, opt, proxy.done('topics'));
Topic.getCountByQuery(query, proxy.done(function (all_topics_count) {
Oops, something went wrong.

0 comments on commit 7e030b5

Please sign in to comment.