基于Node.js、mongoDB和AngularJS的社区网站系统jsGen正式发布
发布于 12 年前 作者 zensh 30536 次浏览 最后一次编辑是 8 年前

demo:AngularJS中文社区

Github:https://github.com/zensh/jsgen

简介:

jsGen是用纯JavaScript编写的新一代开源社区网站系统,主要用于搭建SNS类型的专业社区,对客户端AngularJS应用稍作修改也可变成多用户博客系统、论坛或者CMS内容管理系统。

jsGen基于NodeJS编写服务器端程序,提供静态文件响应和REST API接口服务;基于AngularJS编写浏览器端应用,构建交互式网页UI视图;基于MongoDB编写数据存储系统。

jsGen基本原理:客户端浏览器发起访问请求后,NodeJS服务器先响应由AngularJS编写的Web应用,这个应用是由html模板、js和css静态文件组成。客户端获取到AngularJS应用后,再由AngularJS与后台的NodeJS服务器API接口通信,根据用户请求交换数据,这些数据是纯粹json数据包,AngularJS获取到json数据包后再编译成相关页面展现给用户。因此,用户进入网站时,只需在首次载入视图模板(html、js、css),其后的所有请求都是纯json数据交换,不再包含html代码,大大减少了数据流量。

特点:

  1. 前沿的WEB技术,前所未有的网站构架形态,前端与后端完全分离,前端由 AngularJS 生成视图,后端由Node.js 提供REST API数据接口和静态文件服务。只需改动前端AngularJS应用形态,即可变成论坛、多用户博客、内容管理系统等。

  2. 用户数据、文章评论数据、标签数据、分页缓存数据、用户操作间隔限时等都使用 LRU缓存 ,降低数据库IO操作,同时保证同步更新数据。

  3. 前后端利用 json 数据包进行数据通信。文章、评论采用 Markdown 格式编辑、存储,支持GitHub的GFM(GitHub Flavored Markdown),Markdown解析成HTML DOM并进行 XSS攻击 过滤由前端AngularJS应用完成。

  4. 用户帐号系统,关注(follow)用户/粉丝、邮箱验证激活、邮箱重置密码、SHA256加密安全登录、登录失败5次锁定/邮箱解锁、用户标签、用户积分、用户权限等级、用户阅读时间线等功能。用户首页展现用户关注标签、关注作者的相关的文章(即用户感兴趣的文章)。

  5. 文章/评论系统,文章、评论使用统一数据结构,均可被评论、支持、反对、标记(mark,即收藏),当评论达到一定条件(精彩评论)可自动提升为文章(独立出来,类branch功能),同样文章达到一定条件即可自动推荐。自动实时统计文章、评论热度,自动生成最新文章列表、一周内最热文章列表、一周内最热评论列表、最近更新文章列表。强大的文章、评论列表分页导航功能,缓存每个用户的分页导航浏览记录。

  6. 标签系统,文章和用户均可加标签,可设置文章、用户标签数量上限。用户通过标签设置自己关注话题,文章通过标签形成分类。标签在用户编辑个人信息或编辑文章时自动生成,自动管理,也可管理员后台管理。自动展现热门标签。

  7. 文章合集系统,作者、编辑、管理员可将一系列相关文章组成合集,形成有章节大纲目录的电子书形态。教程文档、主题合集甚至小说连载等均可由合集系统形成。(待完成)

  8. 站内短信系统,提供在文章、评论中 @用户的功能,重要短信发送邮件通知功能等。(待完成)

  9. 后台管理系统,网站参数设置、缓存设置、网站运行信息、文章、评论、用户、标签、合集、站内短信等管理。

  10. Robot SEO系统,由于AngularJS网页内容在客户端动态生成,对搜索引擎robot天生免疫。jsGen针对robot访问,在服务器端动态生成robot专属html页面。搜索引擎Robot名称可在管理后台添加。EndFragment

20 回复

不错啊,上线了啊,哈哈

中文社区打不开。。。

测试中,有时候会因为修复bug终端一下

这个是基于 /rrestjs 的吗?

npm install 报错

e:\dev\nodejs\jsgen\node_modules\rrestjs\node_modules\now\node_modules\node-proxy\build\nodeproxy.vcxproj(18,3): error MSB4019: 未找到导入的项目“e:\Microsoft.Cpp.Default.props”。请确认 <
Import> 声明中的路
径正确,且磁盘上存在该文件。
gyp ERR! build error
gyp ERR! stack Error: `C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:236:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "build"
gyp ERR! cwd e:\dev\nodejs\jsgen\node_modules\rrestjs\node_modules\now\node_modules\node-proxy
gyp ERR! node -v v0.8.14
gyp ERR! node-gyp -v v0.7.1
gyp ERR! not ok
npm ERR! node-proxy@0.6.0 install: `node-gyp configure build`
npm ERR! `cmd "/c" "node-gyp configure build"` failed with 1
npm ERR!
npm ERR! Failed at the node-proxy@0.6.0 install script.
npm ERR! This is most likely a problem with the node-proxy package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-proxy
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd e:\dev\nodejs\jsgen
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65

使用rrestjs,我是在linux环境下使用的

貌似是安装 node-proxy 模块时出错的,你使用 npm install node-proxy 单独安装 node-proxy 看看。

@leizongmin

npm http GET https://registry.npmjs.org/node-proxy
npm http 304 https://registry.npmjs.org/node-proxy

> node-proxy@0.6.0 install e:\dev\nodejs\node_modules\node-proxy
> node-gyp configure build


e:\dev\nodejs\node_modules\node-proxy>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure build
e:\dev\nodejs\node_modules\node-proxy\build\nodeproxy.vcxproj(18,3): error MSB4019: 未找到导入的项目“e:\Microsoft.Cpp.Default.props”。请确认 <Import> 声明中的路径正确,
。
gyp ERR! build error
gyp ERR! stack Error: `C:\windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:236:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack     at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "build"
gyp ERR! cwd e:\dev\nodejs\node_modules\node-proxy
gyp ERR! node -v v0.8.14
gyp ERR! node-gyp -v v0.7.1
gyp ERR! not ok
npm ERR! node-proxy@0.6.0 install: `node-gyp configure build`
npm ERR! `cmd "/c" "node-gyp configure build"` failed with 1
npm ERR!
npm ERR! Failed at the node-proxy@0.6.0 install script.
npm ERR! This is most likely a problem with the node-proxy package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-proxy
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "node-proxy"
npm ERR! cwd e:\dev\nodejs
npm ERR! node -v v0.8.14
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     e:\dev\nodejs\npm-debug.log
npm ERR! not ok code 0

之前在网站注册了,一直处于验证状态无法发帖。感觉AngularJS中文社区颜色太乱了,视觉上比较分散影响阅读效果。

验证链接发到注册邮箱了,请点击注册邮箱的链接

换到liux安装,也是报错

...
npm http 200 https://registry.npmjs.org/node-proxy/-/node-proxy-0.6.0.tgz
npm http 200 https://registry.npmjs.org/sax/-/sax-0.5.2.tgz

> node-proxy@0.6.0 install /srv/node/jsgen/node_modules/rrestjs/node_modules/now/node_modules/node-proxy
> node-gyp configure build

gyp ERR! configure error Error: Command failed: Unknown option: --
gyp ERR! configure error usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
gyp ERR! configure error Try `python -h' for more information.
gyp ERR! configure error 
gyp ERR! configure error     at ChildProcess.exithandler (child_process.js:536:15)
gyp ERR! configure error     at ChildProcess.EventEmitter.emit (events.js:91:17)
gyp ERR! configure error     at maybeClose (child_process.js:634:16)
gyp ERR! configure error     at Process._handle.onexit (child_process.js:676:5)
gyp ERR! configure error     at process.startup.processMakeCallback.process._makeCallback (node.js:238:20)
gyp ERR! not ok 
npm ERR! node-proxy@0.6.0 install: `node-gyp configure build`
npm ERR! `sh "-c" "node-gyp configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the node-proxy@0.6.0 install script.
npm ERR! This is most likely a problem with the node-proxy package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls node-proxy
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 2.6.18-308.el5
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /srv/node/jsgen
npm ERR! node -v v0.9.0
npm ERR! npm -v 1.1.44
npm ERR! code ELIFECYCLE
npm ERR! stack Error: node-proxy@0.6.0 install: `node-gyp configure build`
npm ERR! stack `sh "-c" "node-gyp configure build"` failed with 1
npm ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:56:20)
npm ERR! stack     at ChildProcess.EventEmitter.emit (events.js:91:17)
npm ERR! stack     at Process._handle.onexit (child_process.js:674:10)
npm ERR! stack     at process.startup.processMakeCallback.process._makeCallback (node.js:238:20)
npm http 200 https://registry.npmjs.org/mimelib/-/mimelib-0.2.12.tgz
npm http 200 https://registry.npmjs.org/wordwrap
npm WARN package.json bson@0.1.3 No README.md file found!
npm http 200 https://registry.npmjs.org/commander/-/commander-0.2.1.tgz
npm WARN engine commander@0.2.1: wanted: {"node":">= 0.4.x < 0.7.0"} (current: {"node":"0.9.0","npm":"1.1.44"})

> bson@0.1.3 install /srv/node/jsgen/node_modules/rrestjs/node_modules/mongodb/node_modules/bson
> node install.js

================================================================================
=                                                                              =
=  To install with C++ bson parser do <npm install mongodb --mongodb:native>   =
=                                                                              =
================================================================================

> bson@0.1.8 install /srv/node/jsgen/node_modules/mongoskin/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

npm http GET https://registry.npmjs.org/encoding
npm http GET https://registry.npmjs.org/addressparser
npm WARN excluding symbolic link lib/socket.io-client.js -> io.js
npm http GET https://registry.npmjs.org/uglify-js/1.0.6
npm http GET https://registry.npmjs.org/websocket-client/1.0.0
npm http GET https://registry.npmjs.org/xmlhttprequest/1.2.2
npm http 200 https://registry.npmjs.org/encoding
npm http 200 https://registry.npmjs.org/addressparser
npm http GET https://registry.npmjs.org/encoding/-/encoding-0.1.6.tgz
npm http GET https://registry.npmjs.org/addressparser/-/addressparser-0.1.3.tgz
npm http 200 https://registry.npmjs.org/websocket-client/1.0.0
npm http GET https://registry.npmjs.org/websocket-client/-/websocket-client-1.0.0.tgz
npm http 200 https://registry.npmjs.org/uglify-js/1.0.6
npm http GET https://registry.npmjs.org/uglify-js/-/uglify-js-1.0.6.tgz
npm http 200 https://registry.npmjs.org/xmlhttprequest/1.2.2
npm http GET https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.2.2.tgz
npm http 200 https://registry.npmjs.org/addressparser/-/addressparser-0.1.3.tgz
npm http 200 https://registry.npmjs.org/encoding/-/encoding-0.1.6.tgz
npm http GET https://registry.npmjs.org/iconv-lite/0.2.7
npm http 200 https://registry.npmjs.org/websocket-client/-/websocket-client-1.0.0.tgz
npm http 200 https://registry.npmjs.org/uglify-js/-/uglify-js-1.0.6.tgz
npm http 200 https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.2.2.tgz
npm http 200 https://registry.npmjs.org/iconv-lite/0.2.7
npm http GET https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.7.tgz
npm http 200 https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.7.tgz
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /srv/node/jsgen/npm-debug.log
npm ERR! not ok code 0

先手动安装

npm install -g node-gyp

另外,确保安装了python

先手动安装

npm install -g node-gyp

另外,确保安装了python

node-gyp Node.js native addon build tool

node-gyp is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js, which takes away the pain of dealing with the various differences in build platforms. It is the replacement to the node-waf program which is removed for node v0.8. If you have a native addon for node that still has a wscript file, then you should definitely add a binding.gyp file to support the latest versions of node.

Multiple target versions of node are supported (i.e. 0.6, 0.7,…, 1.0, etc.), regardless of what version of node is actually installed on your system (node-gyp downloads the necessary development files for the target version).

这个模块是把nodejs写的模板编译成二进制版本的吗? 如果我写了一个app.js是不是也可以编译成二进制?

node app.js 报错 这是配置文件的问题吗?

node app
rrestjs process 1354 Checking config file starting...
rrestjs process 1354 Config file checking complete, errors:0/72, warns:0/72

/srv/jsgen/app.js:11
    jsGen.errlog.error(err);
                 ^
TypeError: Cannot call method 'error' of undefined
    at Domain.<anonymous> (/srv/jsgen/app.js:11:18)
    at Domain.EventEmitter.emit (events.js:96:17)
    at process.uncaughtHandler (domain.js:61:20)
    at process.EventEmitter.emit (events.js:126:20)

node-gyp是制作C++插件用的。

先把这行注释掉

jsGen.errlog.error(err);

rrestjs框架更新了log4js模块到0.6.0,此模块必须使用0.10.x的nodejs引擎,如果想用node 0.8.x 请手动更新rrestjs模块下的log4js到0.5.6即可

github上提交了个bug 以下代码引起的: process.nextTick(function () { dm.dispose(); });

研究了半天,发现这个是纯js的,纯JS的,维护成本太高、灵活扩展也成问题,官方应该考虑JS+PHP的方式来做

回到顶部