Permalink
Browse files

project init

  • Loading branch information...
1 parent 0451920 commit e524b2f9b541212dd2a25560bcaa5d4c419cfd62 @muyuan muyuan committed Feb 15, 2012
Showing with 33,160 additions and 0 deletions.
  1. +21 −0 README
  2. +107 −0 app.js
  3. +32 −0 config.default.js
  4. +69 −0 controllers/at.js
  5. +63 −0 controllers/mail.js
  6. +190 −0 controllers/message.js
  7. +228 −0 controllers/reply.js
  8. +268 −0 controllers/sign.js
  9. +73 −0 controllers/site.js
  10. +8 −0 controllers/static.js
  11. +319 −0 controllers/tag.js
  12. +12 −0 controllers/tools.js
  13. +568 −0 controllers/topic.js
  14. +34 −0 controllers/upload.js
  15. +505 −0 controllers/user.js
  16. +33 −0 libs/util.js
  17. +30 −0 models/index.js
  18. +22 −0 models/message.js
  19. +11 −0 models/relation.js
  20. +16 −0 models/reply.js
  21. +13 −0 models/tag.js
  22. +11 −0 models/tag_collect.js
  23. +20 −0 models/topic.js
  24. +11 −0 models/topic_collect.js
  25. +11 −0 models/topic_tag.js
  26. +30 −0 models/user.js
  27. +15 −0 package.json
  28. BIN public/favicon.ico
  29. BIN public/images/cert_icon&16.png
  30. BIN public/images/checkmark_icon&16.png
  31. BIN public/images/cog_icon&16.png
  32. BIN public/images/compass_icon&16.png
  33. BIN public/images/delete_icon&16.png
  34. BIN public/images/doc_edit_icon&16.png
  35. BIN public/images/home_icon&16.png
  36. BIN public/images/logo.png
  37. BIN public/images/mail_icon&16.png
  38. BIN public/images/node_icon&16.png
  39. BIN public/images/nodejs_black.png
  40. BIN public/images/on-off_icon&16.png
  41. BIN public/images/paper_airplane_icon&16.png
  42. BIN public/images/search.png
  43. BIN public/images/spechbubble_2_icon&16.png
  44. BIN public/images/star_fav_empty_icon&16.png
  45. BIN public/images/star_fav_icon&16.png
  46. BIN public/images/tagL.png
  47. BIN public/images/tag_icon&16.png
  48. BIN public/images/trash_icon&16.png
  49. BIN public/images/twitter_2_icon&16.png
  50. BIN public/images/user_icon&16.png
  51. BIN public/images/user_icon&48.png
  52. BIN public/images/users_icon&16.png
  53. BIN public/images/wp_logo.png
  54. BIN public/images/wrench_icon&16.png
  55. +35 −0 public/javascripts/main.js
  56. +682 −0 public/libs/ajax-upload/ajaxupload.js
  57. +4 −0 public/libs/bootstrap/.gitignore
  58. +176 −0 public/libs/bootstrap/LICENSE
  59. +47 −0 public/libs/bootstrap/Makefile
  60. +105 −0 public/libs/bootstrap/README.md
  61. +2,467 −0 public/libs/bootstrap/bootstrap.css
  62. +356 −0 public/libs/bootstrap/bootstrap.min.css
  63. +567 −0 public/libs/bootstrap/css/bootstrap-responsive.css
  64. +3 −0 public/libs/bootstrap/css/bootstrap-responsive.min.css
  65. +3,365 −0 public/libs/bootstrap/css/bootstrap.css
  66. +610 −0 public/libs/bootstrap/css/bootstrap.min.css
  67. +317 −0 public/libs/bootstrap/docs/assets/css/docs.css
  68. BIN public/libs/bootstrap/docs/assets/ico/bootstrap-apple-114x114.png
  69. BIN public/libs/bootstrap/docs/assets/ico/bootstrap-apple-57x57.png
  70. BIN public/libs/bootstrap/docs/assets/ico/bootstrap-apple-72x72.png
  71. BIN public/libs/bootstrap/docs/assets/ico/favicon.ico
  72. BIN public/libs/bootstrap/docs/assets/img/bird.png
  73. BIN public/libs/bootstrap/docs/assets/img/browsers.png
  74. BIN public/libs/bootstrap/docs/assets/img/example-diagram-01.png
  75. BIN public/libs/bootstrap/docs/assets/img/example-diagram-02.png
  76. BIN public/libs/bootstrap/docs/assets/img/example-diagram-03.png
  77. BIN public/libs/bootstrap/docs/assets/img/grid-18px.png
  78. BIN public/libs/bootstrap/docs/assets/img/twitter-logo-no-bird.png
  79. +52 −0 public/libs/bootstrap/docs/assets/js/application.js
  80. +94 −0 public/libs/bootstrap/docs/assets/js/google-code-prettify/prettify.css
  81. +28 −0 public/libs/bootstrap/docs/assets/js/google-code-prettify/prettify.js
  82. +2,037 −0 public/libs/bootstrap/docs/index.html
  83. +798 −0 public/libs/bootstrap/docs/javascript.html
  84. +119 −0 public/libs/bootstrap/examples/container-app.html
  85. +122 −0 public/libs/bootstrap/examples/fluid.html
  86. +79 −0 public/libs/bootstrap/examples/hero.html
  87. BIN public/libs/bootstrap/img/glyphicons-halflings-white.png
  88. BIN public/libs/bootstrap/img/glyphicons-halflings.png
  89. +124 −0 public/libs/bootstrap/js/bootstrap-alerts.js
  90. +64 −0 public/libs/bootstrap/js/bootstrap-buttons.js
  91. +55 −0 public/libs/bootstrap/js/bootstrap-dropdown.js
  92. +260 −0 public/libs/bootstrap/js/bootstrap-modal.js
  93. +90 −0 public/libs/bootstrap/js/bootstrap-popover.js
  94. +107 −0 public/libs/bootstrap/js/bootstrap-scrollspy.js
  95. +80 −0 public/libs/bootstrap/js/bootstrap-tabs.js
  96. +321 −0 public/libs/bootstrap/js/bootstrap-twipsy.js
  97. +1,722 −0 public/libs/bootstrap/js/bootstrap.js
  98. +1 −0 public/libs/bootstrap/js/bootstrap.min.js
  99. +40 −0 public/libs/bootstrap/js/tests/index.html
  100. +41 −0 public/libs/bootstrap/js/tests/unit/bootstrap-alerts.js
  101. +42 −0 public/libs/bootstrap/js/tests/unit/bootstrap-buttons.js
  102. +52 −0 public/libs/bootstrap/js/tests/unit/bootstrap-dropdown.js
  103. +151 −0 public/libs/bootstrap/js/tests/unit/bootstrap-modal.js
  104. +76 −0 public/libs/bootstrap/js/tests/unit/bootstrap-popover.js
  105. +31 −0 public/libs/bootstrap/js/tests/unit/bootstrap-scrollspy.js
  106. +77 −0 public/libs/bootstrap/js/tests/unit/bootstrap-tabs.js
  107. +81 −0 public/libs/bootstrap/js/tests/unit/bootstrap-twipsy.js
  108. +232 −0 public/libs/bootstrap/js/tests/vendor/qunit.css
  109. +1,510 −0 public/libs/bootstrap/js/tests/vendor/qunit.js
  110. +26 −0 public/libs/bootstrap/lib/bootstrap.less
  111. +479 −0 public/libs/bootstrap/lib/forms.less
  112. +222 −0 public/libs/bootstrap/lib/mixins.less
  113. +1,060 −0 public/libs/bootstrap/lib/patterns.less
  114. +141 −0 public/libs/bootstrap/lib/reset.less
  115. +139 −0 public/libs/bootstrap/lib/scaffolding.less
  116. +224 −0 public/libs/bootstrap/lib/tables.less
  117. +187 −0 public/libs/bootstrap/lib/type.less
  118. +60 −0 public/libs/bootstrap/lib/variables.less
  119. +2 −0 public/libs/code-prettify/lang-apollo.js
  120. +18 −0 public/libs/code-prettify/lang-clj.js
  121. +2 −0 public/libs/code-prettify/lang-css.js
  122. +1 −0 public/libs/code-prettify/lang-go.js
  123. +2 −0 public/libs/code-prettify/lang-hs.js
  124. +3 −0 public/libs/code-prettify/lang-lisp.js
  125. +2 −0 public/libs/code-prettify/lang-lua.js
  126. +2 −0 public/libs/code-prettify/lang-ml.js
  127. +4 −0 public/libs/code-prettify/lang-n.js
  128. +1 −0 public/libs/code-prettify/lang-proto.js
  129. +2 −0 public/libs/code-prettify/lang-scala.js
  130. +2 −0 public/libs/code-prettify/lang-sql.js
  131. +1 −0 public/libs/code-prettify/lang-tex.js
  132. +2 −0 public/libs/code-prettify/lang-vb.js
  133. +3 −0 public/libs/code-prettify/lang-vhdl.js
  134. +2 −0 public/libs/code-prettify/lang-wiki.js
  135. +3 −0 public/libs/code-prettify/lang-xq.js
  136. +2 −0 public/libs/code-prettify/lang-yaml.js
  137. +1 −0 public/libs/code-prettify/prettify.css
  138. +28 −0 public/libs/code-prettify/prettify.js
  139. BIN public/libs/fancybox/blank.gif
  140. BIN public/libs/fancybox/fancy_close.png
  141. BIN public/libs/fancybox/fancy_loading.png
  142. BIN public/libs/fancybox/fancy_nav_left.png
  143. BIN public/libs/fancybox/fancy_nav_right.png
  144. BIN public/libs/fancybox/fancy_shadow_e.png
  145. BIN public/libs/fancybox/fancy_shadow_n.png
  146. BIN public/libs/fancybox/fancy_shadow_ne.png
  147. BIN public/libs/fancybox/fancy_shadow_nw.png
  148. BIN public/libs/fancybox/fancy_shadow_s.png
  149. BIN public/libs/fancybox/fancy_shadow_se.png
  150. BIN public/libs/fancybox/fancy_shadow_sw.png
  151. BIN public/libs/fancybox/fancy_shadow_w.png
  152. BIN public/libs/fancybox/fancy_title_left.png
  153. BIN public/libs/fancybox/fancy_title_main.png
  154. BIN public/libs/fancybox/fancy_title_over.png
  155. BIN public/libs/fancybox/fancy_title_right.png
  156. BIN public/libs/fancybox/fancybox-x.png
  157. BIN public/libs/fancybox/fancybox-y.png
  158. BIN public/libs/fancybox/fancybox.png
  159. +72 −0 public/libs/fancybox/jquery.easing-1.3.pack.js
  160. +359 −0 public/libs/fancybox/jquery.fancybox-1.3.4.css
  161. +1,156 −0 public/libs/fancybox/jquery.fancybox-1.3.4.js
  162. +46 −0 public/libs/fancybox/jquery.fancybox-1.3.4.pack.js
  163. +14 −0 public/libs/fancybox/jquery.mousewheel-3.0.4.pack.js
  164. +5 −0 public/libs/jquery/jquery.js
  165. +32 −0 public/libs/pagedown/LICENSE.txt
  166. +1,332 −0 public/libs/pagedown/Markdown.Converter.js
  167. +2,174 −0 public/libs/pagedown/Markdown.Editor.js
  168. +2,136 −0 public/libs/pagedown/Markdown.Editor.js_bak
  169. +108 −0 public/libs/pagedown/Markdown.Sanitizer.js
  170. 0 public/libs/pagedown/README.txt
  171. +120 −0 public/libs/pagedown/demo/browser/demo.css
  172. +77 −0 public/libs/pagedown/demo/browser/demo.html
  173. +44 −0 public/libs/pagedown/demo/node/demo.js
  174. BIN public/libs/pagedown/resources/wmd-buttons.psd
  175. BIN public/libs/pagedown/wmd-buttons.png
  176. +570 −0 public/stylesheets/style.css
  177. +66 −0 routes/index.js
  178. +140 −0 views/index.html
  179. +71 −0 views/layout.html
  180. +83 −0 views/message/index.html
  181. +43 −0 views/message/message.html
  182. +25 −0 views/notify/notify.html
  183. +59 −0 views/reply/reply.html
  184. +28 −0 views/reply/reply2.html
  185. +55 −0 views/sign/search_pass.html
  186. +57 −0 views/sign/signin.html
  187. +82 −0 views/sign/signup.html
  188. +17 −0 views/static/about.html
  189. +17 −0 views/static/faq.html
  190. BIN views/tag/.edit_all.html.swp
  191. +56 −0 views/tag/edit.html
  192. +92 −0 views/tag/edit_all.html
  193. +120 −0 views/tag/list_topic.html
  194. +3 −0 views/tag/tag.html
  195. +10 −0 views/tag/tag_can_edit.html
  196. +7 −0 views/tag/tag_in_abstract.html
  197. +9 −0 views/tag/tag_in_topic.html
  198. +9 −0 views/tag/tag_selectable.html
  199. +6 −0 views/tag/tag_with_count.html
  200. +25 −0 views/topic/abstract.html
  201. +162 −0 views/topic/edit.html
  202. +319 −0 views/topic/index.html
  203. +62 −0 views/topic/list.html
  204. +4 −0 views/topic/small.html
  205. +22 −0 views/user/card.html
  206. +21 −0 views/user/collect_tags.html
  207. +21 −0 views/user/collect_topics.html
  208. +21 −0 views/user/followers.html
  209. +21 −0 views/user/followings.html
  210. +142 −0 views/user/index.html
  211. +123 −0 views/user/replies.html
  212. +139 −0 views/user/setting.html
  213. +10 −0 views/user/star.html
  214. +21 −0 views/user/stars.html
  215. +4 −0 views/user/top.html
  216. +30 −0 views/user/top100.html
  217. +5 −0 views/user/top100_user.html
  218. +123 −0 views/user/topics.html
  219. +24 −0 views/user/user.html
View
21 README
@@ -0,0 +1,21 @@
+##Node Club
+
+###### 介绍
+Node Club 是用 **Node.js** 和 **MongoDb** 开发的新型社区软件,界面优雅,功能丰富,已在Node.js 中文技术社区 [CNode](http://cnodejs.org) 得到应用,但你完全可以用它搭建自己的社区。
+
+###### 安装部署
+ // install node npm mongodb
+ // run mongod
+ cd Node-Club
+ nmp install ./
+ cp config.default.js config.js
+ // modify the config file as yours
+ node app.js
+
+###### 其它
+小量修改了两个依赖模块:node-markdown,express
+
+ 1.node-markdown/lib/markdown.js allowedTags 添加 `embed` 标签以支持 flash 视频,allowedAttributes 添加 `embed:'src|quality|width|height|align|allowScriptAccess|allowFullScreen|mode|type'`
+ 2.express/node_modules/connect/lib/middleware/csrf.js 添加 `if (req.xhr === true) return next();if (req.body.user_action && req.body.user_action == 'upload_image') return next();`
+
+
View
107 app.js
@@ -0,0 +1,107 @@
+var express = require('express'),
+ routes = require('./routes'),
+ config = require('./config').config;
+
+var app = express.createServer();
+
+var static_dir = __dirname+'/public';
+
+// configuration in all env
+app.configure(function(){
+ app.set('view engine', 'html');
+ app.set('views', __dirname + '/views');
+ app.register('.html',require('ejs'));
+ app.use(express.bodyParser());
+ app.use(express.cookieParser());
+ app.use(express.session({
+ secret:config.session_secret,
+ }));
+ // custom middleware
+ app.use(routes.auth_user);
+ app.use(express.csrf());
+});
+
+//set static,dynamic helpers
+app.helpers({
+ config:config
+});
+app.dynamicHelpers({
+ csrf: function(req,res){
+ return req.session ? req.session._csrf : '';
+ },
+});
+
+app.configure('development', function(){
+ app.use(express.static(static_dir));
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+});
+
+app.configure('production', function(){
+ var one_year=1000*60*60*24*365;
+ app.use(express.static(static_dir,{maxAge:one_year}));
+ app.use(express.errorHandler());
+ app.set('view cache',true);
+});
+
+// routes
+app.get('/signup', routes.signup);
+app.get('/signin', routes.signin);
+app.get('/signout', routes.signout);
+app.post('/signup', routes.signup);
+app.post('/signin', routes.signin);
+
+app.get('/user/:name', routes.user_index);
+app.get('/setting', routes.user_setting);
+app.get('/stars', routes.show_stars);
+app.get('/users/top100', routes.users_top100);
+app.get('/my/tags', routes.get_collect_tags);
+app.get('/my/topics', routes.get_collect_topics);
+app.get('/my/messages', routes.get_messages);
+app.get('/my/follower', routes.get_followers);
+app.get('/my/following', routes.get_followings);
+app.get('/user/:name/topics', routes.list_user_topics);
+app.get('/user/:name/replies', routes.list_user_replies);
+app.post('/setting', routes.user_setting);
+app.post('/user/follow', routes.follow_user);
+app.post('/user/un_follow', routes.un_follow_user);
+app.post('/user/set_star', routes.set_star);
+app.post('/user/cancel_star', routes.cancel_star);
+app.post('/messages/mark_read', routes.mark_message_read);
+app.post('/messages/mark_all_read', routes.mark_all_messages_read);
+
+app.get('/tags/edit', routes.edit_tags);
+app.get('/tag/:name', routes.list_topic_by_tag);
+app.get('/tag/:name/edit', routes.edit_tag);
+app.get('/tag/:name/delete', routes.delete_tag);
+app.post('/tag/add', routes.add_tag);
+app.post('/tag/:name/edit', routes.edit_tag);
+app.post('/tag/collect', routes.collect_tag);
+app.post('/tag/de_collect', routes.de_collect_tag);
+
+app.get('/topic/create', routes.create_topic);
+app.get('/topic/:tid', routes.topic_index);
+app.get('/topic/:tid/edit', routes.edit_topic);
+app.get('/topic/:tid/delete', routes.delete_topic);
+app.post('/topic/create', routes.create_topic);
+app.post('/topic/:tid/edit', routes.edit_topic);
+app.post('/topic/collect', routes.collect_topic);
+app.post('/topic/de_collect', routes.de_collect_topic);
+
+app.post('/:topic_id/reply',routes.reply_topic);
+app.post('/:topic_id/reply2',routes.reply2_topic);
+app.post('/reply/:reply_id/delete', routes.delete_reply);
+
+app.get('/', routes.index);
+
+app.post('/upload/image', routes.upload_image);
+app.post('/search_pass', routes.search_pass);
+app.get('/active_account', routes.active_account);
+app.get('/search_pass', routes.search_pass);
+app.get('/reset_pass',routes.reset_pass);
+app.get('/site_tools', routes.site_tools);
+app.get('/about', routes.about);
+app.get('/faq', routes.faq);
+
+app.listen(config.port);
+console.log("NodeClub listening on port %d in %s mode", app.address().port, app.settings.env);
+console.log("God bless love....");
View
@@ -0,0 +1,32 @@
+/**
+ * config
+ */
+
+exports.config = {
+ name: 'Node Club',
+ description: 'Node Club 是用Node.js开发的社区软件',
+ host: 'http://127.0.0.1/',
+ db: 'mongodb://127.0.0.1/node_club',
+ session_secret: 'node_club',
+ auth_cookie_name: 'node_club',
+ port: 80,
+ version: '0.0.1',
+
+ // topics list count
+ list_topic_count: 20,
+
+ // mail SMTP
+ mail_port: 25,
+ mail_user: 'club',
+ mail_pass: 'club',
+ mail_host: 'smtp.126.com',
+ mail_sender: 'club@126.com',
+ mail_use_authentication: true,
+
+ //weibo app key
+ weibo_key: 10000000,
+
+ // admins
+ admins: {admin:true}
+};
+
View
@@ -0,0 +1,69 @@
+var models = require('../models'),
+ User = models.User,
+ Message = models.Message;
+
+var user_ctrl = require('./user');
+var message_ctrl = require('./message');
+var EventProxy = require('eventproxy').EventProxy;
+
+function search_at_who(str,cb){
+ var pattern = /@[a-zA-Z0-9]+/ig;
+ var results = str.match(pattern);
+ var names = [];
+
+ if(results){
+ for(var i=0; i<results.length; i++){
+ var s = results[i];
+ //remove char @
+ s = s.slice(1);
+ names.push(s);
+ }
+ }
+
+ if(names.length == 0){
+ return cb(null,names);
+ }
+
+ var users = [];
+ var proxy = new EventProxy();
+ var done = function(){
+ return cb(null,users);
+ }
+ proxy.after('user_found',names.length,done);
+ for(var i=0; i<names.length; i++){
+ var name = names[i];
+ var loginname = name.toLowerCase();
+ user_ctrl.get_user_by_loginname(loginname,function(err,user){
+ if(err) return cb(err);
+ if(user){
+ users.push(user);
+ proxy.trigger('user_found');
+ }else{
+ proxy.trigger('user_found');
+ }
+ });
+ }
+}
+
+function send_at_message(str,topic_id,author_id){
+ search_at_who(str,function(err,users){
+ for(var i=0; i<users.length; i++){
+ var user = users[i];
+ message_ctrl.send_at_message(user._id,author_id,topic_id);
+ }
+ });
+}
+
+function link_at_who(str,cb){
+ search_at_who(str,function(err,users){
+ if(err) return cb(err);
+ for(var i=0; i<users.length; i++){
+ var name = users[i].name;
+ str = str.replace(new RegExp('@'+name,'gmi'),'@<a href="/user/'+name+'">'+name+'</a>');
+ }
+ return cb(err,str);
+ });
+}
+
+exports.send_at_message = send_at_message;
+exports.link_at_who = link_at_who;
View
@@ -0,0 +1,63 @@
+var mailer = require('nodemailer');
+var config = require('../config').config;
+
+mailer.SMTP = {
+ host: config.mail_host,
+ port: config.mail_port,
+ use_authentication: config.mail_use_authentication,
+ user: config.mail_user,
+ pass: config.mail_pass
+};
+
+function send_mail(data,cb){
+ mailer.send_mail(data,function(err,success){
+ return cb(err,success);
+ });
+}
+
+function send_active_mail(who,token,name,email,cb){
+ var sender = config.mail_sender;
+ var to = who;
+ var subject = config.name + '社区帐号激活';
+ var html = '<p>您好:<p/>' +
+ '<p>我们收到您在' + config.name + '社区的注册信息,请点击下面的链接来激活帐户:</p>' +
+ '<a href="' + config.host + '/active_account?key=' + token + '&name=' + name + '&email=' + email + '">激活链接</a>' +
+ '<p>若您没有在' + config.name + '社区填写过注册信息,说明有人滥用了您的电子邮箱,请删除此邮件,我们对给您造成的打扰感到抱歉。</p>' +
+ '<p>' +config.name +'社区 谨上。</p>'
+
+ var data = {
+ sender: sender,
+ to: to,
+ subject: subject,
+ html: html
+ }
+
+ send_mail(data,function(err,success){
+ return cb(err,success);
+ });
+}
+function send_reset_pass_mail(who,token,name,cb){
+ var sender = config.mail_sender;
+ var to = who;
+ var subject = config.name + '社区密码重置';
+ var html = '<p>您好:<p/>' +
+ '<p>我们收到您在' + config.name + '社区重置密码的请求,请单击下面的链接来重置密码:</p>' +
+ '<a href="' + config.host + '/reset_pass?key=' + token + '&name=' + name + '">重置密码链接</a>' +
+ '<p>若您没有在' + config.name + '社区填写过注册信息,说明有人滥用了您的电子邮箱,请删除此邮件,我们对给您造成的打扰感到抱歉。</p>' +
+ '<p>' + config.name +'社区 谨上。</p>'
+
+ var data = {
+ sender: sender,
+ to: to,
+ subject: subject,
+ html: html
+ }
+
+ send_mail(data,function(err,success){
+ return cb(err,success);
+ });
+
+}
+
+exports.send_active_mail = send_active_mail;
+exports.send_reset_pass_mail = send_reset_pass_mail;
Oops, something went wrong.

0 comments on commit e524b2f

Please sign in to comment.