Jackblog 是使用 Node.js + MongoDB + 其它客户端框架开发的个人博客系统,前后端分离,仿简书模板,自适应布局.
服务端和客户端搭配使用.
服务端有:
express版 https://github.com/jackhutu/jackblog-api-express
koa版 https://github.com/jackhutu/jackblog-api-koa
web客户端有:
angular1.x版:https://github.com/jackhutu/jackblog-angular1 demo地址:angular1.jackhu.top
angular2.x版:https://github.com/jackhutu/jackblog-angular2 demo地址:angular2.jackhu.top
react redux 版: https://github.com/jackhutu/jackblog-react-redux demo地址:redux.jackhu.top
vue 版: https://github.com/jackhutu/jackblog-vue demo地址:vue.jackhu.top
移动端有:
react native 版: https://github.com/jackhutu/jackblog-react-native-redux
希望对新手有帮助,别忘了++star哦.
@winky 您好,回去看了您的代码;不明白markdown-it是如何把一段String类型的markdown 转成多条html标签的; 如上,我想把“# markdown hirst h1 ! # second h1 sigin” 转换成
markdown hirst h1 !和 second h1 sigin两个标签,但是实际结果是一个标签markdown hirst h1 ! # second h1 sigin
;
markdown hirst h1 ! # second h1 sigin
;新手,问题有点多了,烦您不弃,谢谢~
@winky 是因为我看您article里面的 schema content类型是String的,最后接口读出来的时候也是用的md.render(result.content);就想知道这样能把一整段markdown都转换成各个语义化的html标签吗?
@winky 我在webstorm下面 npm install .下载了好多插件 还有好多错误
“C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\bin\runnerw.exe” D:\nodejs\npm.cmd update npm WARN install Couldn’t install optional dependency: Unsupported npm WARN addRemoteGit Error: Command failed: git -c core.longpaths=true config --get remote.origin.url npm WARN addRemoteGit npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:213:12) npm WARN addRemoteGit at emitTwo (events.js:87:13) npm WARN addRemoteGit at ChildProcess.emit (events.js:172:7) npm WARN addRemoteGit at maybeClose (internal/child_process.js:818:16) npm WARN addRemoteGit at Socket.<anonymous> (internal/child_process.js:319:11) npm WARN addRemoteGit at emitOne (events.js:77:13) npm WARN addRemoteGit at Socket.emit (events.js:169:7) npm WARN addRemoteGit at Pipe._onclose (net.js:469:12) npm WARN addRemoteGit git+http://ikt.pm2.io/ikt.git#master resetting remote C:\Users\wangbin\AppData\Roaming\npm-cache_git-remotes\git-http-ikt-pm2-io-ikt-git-master-098735ff3c4481296d11bc2fc98a470a because of error: { [Error: Command failed: git -c core.longpaths=true config --get remote.origin.url npm WARN addRemoteGit ] npm WARN addRemoteGit killed: false, npm WARN addRemoteGit code: 1, npm WARN addRemoteGit signal: null, npm WARN addRemoteGit cmd: ‘git -c core.longpaths=true config --get remote.origin.url’ }
[email protected] preinstall E:\nodeworkspace\jackblog\node_modules.staging\ccap-d40a8ced8d860dc734abe5e4cf7091d3 node make.js
I’m glad you to select ccap, enjoy it!
ccap is a cross plat form and portable nodejs simple captcha module, simple api and lightweight.
starting compile ccap! good luck!
[email protected] install E:\nodeworkspace\jackblog\node_modules\ccap node-gyp rebuild
E:\nodeworkspace\jackblog\node_modules\ccap>if not defined npm_config_node_gyp (node “D:\nodejs\node_modules\npm\bin\node-gyp-bin\…\node_modules\node-gyp\bin\node-gyp.js” rebuild ) else (node rebuild ) gyp ERR! configure error gyp ERR! stack Error: Can’t find Python executable “python”, you can set the PYTHON env variable. gyp ERR! stack at failNoPython (D:\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:116:14) gyp ERR! stack at D:\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:71:11 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:82:15) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command “D:\nodejs\node.exe” “D:\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” "rebuild" gyp ERR! cwd E:\nodeworkspace\jackblog\node_modules\ccap gyp ERR! node -v v5.3.0 gyp ERR! node-gyp -v v3.0.3 gyp ERR! not ok npm WARN EPEERINVALID [email protected] requires a peer of kerberos@~0.0 but none was installed. [email protected] E:\nodeworkspace\jackblog npm WARN EPEERINVALID [email protected] requires a peer of kerberos@~0.0 but none was installed. └── [email protected] npm ERR! Windows_NT 6.1.7601
npm ERR! argv “D:\nodejs\node.exe” “D:\nodejs\node_modules\npm\bin\npm-cli.js” "update" npm ERR! node v5.3.0 npm ERR! npm v3.3.12 npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script ‘node-gyp rebuild’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ccap package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls ccap
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request: npm ERR! E:\nodeworkspace\jackblog\npm-debug.log
进程已结束,退出代码1
@winky node用的5.3
“C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\bin\runnerw.exe” D:\nodejs\npm.cmd update npm WARN install Couldn’t install optional dependency: Unsupported
[email protected] preinstall E:\nodeworkspace\jackblog\node_modules.staging\ccap-d40a8ced8d860dc734abe5e4cf7091d3 node make.js
I’m glad you to select ccap, enjoy it!
ccap is a cross plat form and portable nodejs simple captcha module, simple api and lightweight.
starting compile ccap! good luck!
[email protected] install E:\nodeworkspace\jackblog\node_modules\ccap node-gyp rebuild
E:\nodeworkspace\jackblog\node_modules\ccap>if not defined npm_config_node_gyp (node “D:\nodejs\node_modules\npm\bin\node-gyp-bin\…\node_modules\node-gyp\bin\node-gyp.js” rebuild ) else (node rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the “/m” switch.
MSBUILD : error MSB3428: δ�ܼ��� Visual C++ �����VCBuild.exe����Ҫ��������⣬1) ��װ .NET Framework 2.0 SDK��2) ��װ Microsoft Visual Studio 2005���� 3) ������������װ��������λ�ã��뽫��λ����ӵ�ϵͳ·���С� [E:\nodeworkspace\jackblog\node_modules\ccap\build\binding.sln]
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 (D:\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command “D:\nodejs\node.exe” “D:\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” "rebuild"
gyp ERR! cwd E:\nodeworkspace\jackblog\node_modules\ccap
gyp ERR! node -v v5.3.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm WARN EPEERINVALID [email protected] requires a peer of kerberos@~0.0 but none was installed.
npm WARN EPEERINVALID [email protected] requires a peer of kerberos@~0.0 but none was installed.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv “D:\nodejs\node.exe” “D:\nodejs\node_modules\npm\bin\npm-cli.js” "update"
npm ERR! node v5.3.0
npm ERR! npm v3.3.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script ‘node-gyp rebuild’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ccap package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls ccap
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request: npm ERR! E:\nodeworkspace\jackblog\npm-debug.log
进程已结束,退出代码1
@winky 貌似 安装Microsoft Visual Studio Express 2013 for Windows Desktop 了。 运行在端口9000. 然后 你这个程序和 angular1.x版 react redux 版是什么关系 ,运行express版本 ,不能再浏览器直接运行吗?
@winky Listening on port 8200. Open up http://localhost:8200/ in your browser.
Error: ENOENT: no such file or directory, stat 'e:\nodeworkspace\jackblog-angular1\dist\index.html’
怎么运行你的样例呀。我看你的index 放在src 下面了。
@winky "C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\bin\runnerw.exe" D:\nodejs\node.exe C:\Users\wangbin\AppData\Roaming\npm\node_modules\gulp\bin\gulp.js --color --gulpfile e:\nodeworkspace\jackblog-angular1\gulpfile.js build [13:21:46] Using gulpfile e:\nodeworkspace\jackblog-angular1\gulpfile.js [13:21:46] Starting ‘build’… [13:21:46] Starting ‘prod-config’… [13:21:46] Finished ‘prod-config’ after 58 ms [13:21:46] Starting ‘scripts’… [13:21:49] Starting ‘inject_sass’… [13:21:49] Starting ‘partials’… [13:21:51] gulp-inject 6 files into index.scss. stream.js:74 throw er; // Unhandled stream error in pipe. ^
Error: Error: angular is not installed. Try running bower install
.
at e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\wiredep.js:30:56
at e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\lib\detect-dependencies.js:145:29
at forOwn (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\lodash\dist\lodash.js:2106:15)
at Function.forEach (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\lodash\dist\lodash.js:3303:9)
at detectDependencies (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\lib\detect-dependencies.js:34:7)
at wiredep (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\wiredep.js:70:39)
at DestroyableTransform._transform (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\wiredep.js:135:34)
at DestroyableTransform.Transform._read (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\readable-stream\lib_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\readable-stream\lib_stream_transform.js:172:12)
at doWrite (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\readable-stream\lib_stream_writable.js:237:10)
at writeOrBuffer (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\readable-stream\lib_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (e:\nodeworkspace\jackblog-angular1\node_modules\wiredep\node_modules\readable-stream\lib_stream_writable.js:194:11)
at Stream.ondata (stream.js:31:26)
at emitOne (events.js:77:13)
at Stream.emit (events.js:169:7)
at queueData (e:\nodeworkspace\jackblog-angular1\node_modules\map-stream\index.js:43:21)
at next (e:\nodeworkspace\jackblog-angular1\node_modules\map-stream\index.js:71:7)
at e:\nodeworkspace\jackblog-angular1\node_modules\map-stream\index.js:85:7
at e:\nodeworkspace\jackblog-angular1\node_modules\gulp-inject\src\inject\index.js:87:7
at Immediate._onImmediate (e:\nodeworkspace\jackblog-angular1\node_modules\gulp-inject\src\inject\index.js:115:7)
at processImmediate [as _immediateCallback] (timers.js:383:17)
[09:45:27] Error in plugin 'gulp-compass’ Message: You need to have Ruby and Compass installed and in your system PATH for this task to work.
不是吧 。还要ruby?node开发一个东东,要 c++ Python ruby ?
[14:11:10] Finished ‘scripts’ after 1.25 s error src/app/index.scss (Line 2: Invalid GBK character “\xE5”)
Compilation failed in 1 files.
[14:11:11] Error in plugin 'gulp-compass’ Message: error src/app/index.scss (Line 2: Invalid GBK character “\xE5”) Compilation failed in 1 files.
这个 错误不断呀
@winky 你这个博客用到的第三方东西太多。依赖的 东西 包括 c++ ruby Python 。。。 还有很多node的依赖库。。。导致我这样的想来看看 node 写web怎么样的,不熟悉node的人 很困难。 没时间去一个个研究这些东西。 希望能提供一个文档说明呀,安装步骤 依赖什么东西。。。 上面的错误怎么解决,怎么还有字符集的错误。。。。
@wdragon1983 这个错误我没有遇到过, 唯一用到的工具就是sass,compass. 其它没什么特别的. 你先确定gulp-compass插件安装好了没, 以及 compass是否能正常编译.
@winky 上个问题解决了 又有新问题了
[17:48:07] Finished ‘scripts’ after 2.42 s unchanged src/assets/images/sort-s0f57be200a.png
write .tmp/serve/app/index.css
write .tmp/serve/app/index.css.map
[17:48:17] Finished ‘styles:compass’ after 12 s [17:48:17] Starting ‘inject’… [17:48:18] gulp-inject 33 files into index.html. [17:48:18] Finished ‘inject’ after 828 ms [17:48:18] Starting ‘html’… [17:48:23] gulp-inject 1 files into index.html. [17:48:46] dist\ styles\app-7295cf39ad.css 139.75 kB [17:48:46] dist\ styles\vendor-4e7c68a81d.css 89.04 kB [17:48:46] dist\ scripts\app-f7f9379358.js 30.11 kB [17:48:46] dist\ scripts\vendor-b92c80fd1b.js 619.31 kB [17:48:46] dist\ index.html 995 B [17:48:46] dist\ all files 879.21 kB [17:48:46] Finished ‘html’ after 28 s [17:48:46] Starting ‘fonts’… [17:48:46] Starting ‘images’…
events.js:141 throw er; // Unhandled ‘error’ event ^ Error: spawn e:\nodeworkspace\jackblog-angular1\node_modules\optipng-bin\vendor\optipng.exe ENOENT at exports._errnoException (util.js:855:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at nextTickCallbackWith2Args (node.js:455:9) at process._tickCallback (node.js:369:17)
进程已结束,退出代码1
@winky 搞了这么多天还是不行,看来只有放弃了。这oily_png 玩意 还不是一般的安装,还要装什么devkit,装了之后还是报错。。。楼主你这个开发一个东西,用的东西太多。不是我这种 尝鲜用户能玩的了。 装了 c++ python ruby…一堆环境 还是不行。。。
@winky 使用bootstrap那个markdown编辑器只能添加图片地址;如果添加本地图片的话是需要在markdown编辑器外面在上传本地图片;上传成功后返回图片url,最后在markdown编辑器里面写入图片链接?
终于在Windows环境把你的Blog给部署起来了。 部署jackblog-api-es5服务器端代码会出现如下错误: ‘node-gyp rebuild’的问题,跟楼上同学遇到的问题一样,我把user.controller.js中把此处代码注释掉 //var ccap = require(‘ccap’)();同样也需要删除package.jason中ccap引用。 部署jackblog-angular1也遇到如下错误: error src/app/index.scss (Line 26 of src/app/!base.scss: Invalid GBK character “\xE5”) 需修改%rubygems%gems\sass-3.4.9\lib\sass目录下的修改 engine.rb 文件 在require 最下面 加入以下代码 即可解决 Encoding.default_external = Encoding.find(‘utf-8’) 由于后代把ccap功能注释掉,前台还需要对应的把验证码功能给注释掉。代码省略不表。 Anyway,楼主的代码写得非常清晰,很值得学习!
@winky 嗯 搞定了,还想请教一个问题哈,是不使用 passport-qq和passport-weibo就不需要再前端配置访问授权地址了?而是直接跳转自己的路由;我看了passport-qq的API然后又去看腾讯开放平台的author授权机制,看混了。。。;谢谢哈
@winky jsonwebtoken 那个secret有要求吗? 普通的字符串可以不?用jsonwebtoken生成的token然后用express-jwt去解码;老是报invalid token错误;但是对比发出的token和获取到的token是一模一样的
@shimaomao 数据库配置在服务端config文件. 我之前做的第一版 jackblog-express-angular是集成了后台管理的, 可以参考一下. 后来在做其它版本的客户端时, 我就没有做后台管理的功能了.我自己也是用的第一版来管理后台的. 以后我会将后台单独提出来放到jackblog-admin中.
[06:46:18] Starting ‘serve’… [06:46:18] [webpack-dev-server] ==> � http://localhost:5000 events.js:141 throw er; // Unhandled ‘error’ event ^
Error: write EPIPE
at exports._errnoException (util.js:874:11)
at Socket._writeGeneric (net.js:675:26)
at Socket._write (net.js:694:8)
at doWrite (_stream_writable.js:292:12)
at writeOrBuffer (_stream_writable.js:278:5)
at Socket.Writable.write (_stream_writable.js:207:11)
at Socket.write (net.js:618:40)
at Socket.Writable.end (_stream_writable.js:433:10)
at Socket.end (net.js:400:31)
at Through2._transform (D:\nodejs\jackblog-react-redux-master\node_modules\i
mage-webpack-loader\node_modules\imagemin-pngquant\index.js:92:12)
at Through2.Transform._read (D:\nodejs\jackblog-react-redux-master\node_modu
les\image-webpack-loader\node_modules\imagemin-pngquant\node_modules\through2\no
de_modules\readable-stream\lib_stream_transform.js:172:10)
at Through2.Transform._write (D:\nodejs\jackblog-react-redux-master\node_mod
ules\image-webpack-loader\node_modules\imagemin-pngquant\node_modules\through2\n
ode_modules\readable-stream\lib_stream_transform.js:160:12)
at doWrite (D:\nodejs\jackblog-react-redux-master\node_modules\image-webpack
-loader\node_modules\imagemin-pngquant\node_modules\through2\node_modules\readab
le-stream\lib_stream_writable.js:335:12)
at writeOrBuffer (D:\nodejs\jackblog-react-redux-master\node_modules\image-w
ebpack-loader\node_modules\imagemin-pngquant\node_modules\through2\node_modules
readable-stream\lib_stream_writable.js:321:5)
at Through2.Writable.write (D:\nodejs\jackblog-react-redux-master\node_modul
es\image-webpack-loader\node_modules\imagemin-pngquant\node_modules\through2\nod
e_modules\readable-stream\lib_stream_writable.js:248:11)
at Through2.ondata (D:\nodejs\jackblog-react-redux-master\node_modules\image
-webpack-loader\node_modules\imagemin\node_modules\readable-stream\lib_stream_r
eadable.js:583:20)
为什么每次wiredep注入bower_components中的文件总是少了ngprogress.js 导致 Module ‘ngProgress’ is not available! 求大家解答下啊 @winky
有呢 而且在bower_components里面也生成了ngprogress文件夹 但就是 每次wriedep不会导入ngprogress.js到index.html ngprogress.js在bower_components/ngprogress/build/里面 前辈知道什么原因嘛 gulp文件我没改动过呢 @winky
@gaoyangxiaozhu 它主要是有两个判断条件,一个是bower.json文件里面有, 再一个就是ngprogress的package.json里面的mian项有js入口文件 . 你看一下是不是第二个条件不满足.
在blog.controller.js中不是有一段链式查询获取博客列表的函数嘛
Blog.find(condition)
.select('title content images visit_count comment_count like_count publish_time')
.skip(startRow)
.limit(itemsPerPage)
.sort(sort)
.exec().then(function(list){
//函数体
list.forEach(function(item){
//增加一些新的操作 比如delete item.images
delete item.images; //返回true了
console.log(item.images); //仍旧输出images内容
item.abstract = 'hah'; //增加abstract属性
console.log(item); //不显示abstract属性
})
console.log(list);
//list中元素没有改变
}
如上,我在promise执行成功的函数内部对获取的list进行forEach操作,对每一个item进行一定的更改,删除一些属性(或增加一些属性),但是不论怎样的操作,最终显示的list的每一个对象元素还是没有更改。 从昨天纠结到今天了 ,不知道怎么回事。我在其他地方测试(比如文件读取成功的promise回调中执行响应操作)就可以额 @winky
好像是要通过toObject方法转为js Object, 但是ref部分怎么处理呢 比如Article document中的author_id指向User , 那么怎么获取实际的author的nickname怎么获取呢,我将代码改为
Blog.find(condition)
.populate('author_id')
.select('author_id title content images visit_count comment_count like_count publish_time')
.skip(startRow)
.limit(itemsPerPage)
.sort(sort)
.exec().then(function(list){
//函数体
list.forEach(function(item){
item = item.toObject(); //转换为toObject;
//增加一些新的操作 比如delete item.images
item.author_id; //输出author相关信息
item.author_id.nickname; //出错, 访问不了
)}
将article转换为plain Object, 但是还是无法通过item.author_id.nickename获取author的name