Permalink
Browse files

update README.md, support init command

  • Loading branch information...
1 parent da0ddb4 commit 441ef1fe3e1b464ea1496b07c3582208eb157b25 @zmmbreeze committed Jan 13, 2013
Showing with 745 additions and 235 deletions.
  1. +20 −0 MIT-LICENTSE.txt
  2. +35 −9 README.md
  3. +2 −2 lib/command.coffee
  4. +1 −1 lib/command.js
  5. +1 −0 lib/deploy.coffee
  6. +1 −0 lib/deploy.js
  7. +20 −3 lib/file.coffee
  8. +25 −4 lib/file.js
  9. +58 −0 lib/init.coffee
  10. +69 −0 lib/init.js
  11. +14 −9 lib/usage.coffee
  12. +7 −7 lib/usage.js
  13. +5 −5 prototype/blogin.json
  14. +14 −2 prototype/data/info
  15. +0 −5 prototype/data/pages/hello-world.md
  16. +2 −1 prototype/data/pages/my-first-page.md
  17. BIN prototype/data/posts/2012/.DS_Store
  18. +0 −2 prototype/data/posts/2012/hello-worldd.md
  19. +5 −0 prototype/data/posts/2013/my-first-post.md
  20. +2 −0 prototype/public/google-code-prettify/lang-apollo.js
  21. +18 −0 prototype/public/google-code-prettify/lang-clj.js
  22. +2 −0 prototype/public/google-code-prettify/lang-css.js
  23. +1 −0 prototype/public/google-code-prettify/lang-go.js
  24. +2 −0 prototype/public/google-code-prettify/lang-hs.js
  25. +3 −0 prototype/public/google-code-prettify/lang-lisp.js
  26. +2 −0 prototype/public/google-code-prettify/lang-lua.js
  27. +2 −0 prototype/public/google-code-prettify/lang-ml.js
  28. +4 −0 prototype/public/google-code-prettify/lang-n.js
  29. +1 −0 prototype/public/google-code-prettify/lang-proto.js
  30. +2 −0 prototype/public/google-code-prettify/lang-scala.js
  31. +2 −0 prototype/public/google-code-prettify/lang-sql.js
  32. +1 −0 prototype/public/google-code-prettify/lang-tex.js
  33. +2 −0 prototype/public/google-code-prettify/lang-vb.js
  34. +3 −0 prototype/public/google-code-prettify/lang-vhdl.js
  35. +2 −0 prototype/public/google-code-prettify/lang-wiki.js
  36. +3 −0 prototype/public/google-code-prettify/lang-xq.js
  37. +2 −0 prototype/public/google-code-prettify/lang-yaml.js
  38. +1 −0 prototype/public/google-code-prettify/prettify.css
  39. +28 −0 prototype/public/google-code-prettify/prettify.js
  40. BIN prototype/public/stylesheet/bg.jpg
  41. BIN prototype/public/stylesheet/bg2.png
  42. +126 −131 prototype/public/stylesheet/markdown.css
  43. +178 −15 prototype/public/stylesheet/style.css
  44. +2 −5 prototype/public/template/archive.jade
  45. +0 −4 prototype/public/template/includes/foot.jade
  46. +1 −0 prototype/public/template/includes/ga.jade
  47. +8 −7 prototype/public/template/includes/head.jade
  48. +9 −2 prototype/public/template/includes/info.jade
  49. +13 −14 prototype/public/template/index.jade
  50. +12 −3 prototype/public/template/layout.jade
  51. +17 −2 prototype/public/template/page.jade
  52. +17 −2 prototype/public/template/post.jade
View
@@ -0,0 +1,20 @@
+Copyright (c) 2013 mzhou, http://mzhou.me/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,11 +1,37 @@
**blogin** is A simple static blog framework, powered by Node.js.
-Usage:
-
- deploy Generate static files and deploy to github.
- server Start a server on http://localhost:3000 .
- update Generate the static files.
- post New post.
- page New page.
- init Init the project directory.
- help Display help.
+How to install
+---
+1. Install [node.js](http://nodejs.org/) and [npm](https://npmjs.org/).
+2. `npm install -g blogin`
+3. `blogin init blogdir`
+4. `cd blogdir`
+4. `blogin update`
+5. `blogin server`
+6. Open `http://127.0.0.1:3000` in browser.
+
+Create post
+---
+1. `blogin post this is my first post`
+2. Then edit "blogindir/data/posts/2013/this-is-my-first-post.md". Blogin use markdown format to write blog.
+3. `blogin update`
+4. `blogin server`
+
+Usage
+---
+blogin command:
+
+ deploy Generate static files and deploy to git server, like github.
+ server Start a server on http://localhost:3000 .
+ update Generate the static files.
+ post Create post.
+ page Create page.
+ init Init the project directory.
+ help Display help.
+
+Custom theme
+---
+Edit the file at "blogindir/public/" to custom your own theme.
+
+
+Please feel free to use blogin.
View
@@ -19,5 +19,5 @@ module.exports =
page: (args) ->
require('./page.js')(args)
init: (args) ->
- util.puts('This methods was not implemented')
-
+ require('./init')(args)
+ #util.puts('This methods was not implemented')
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -21,6 +21,7 @@ module.exports = (args) ->
arg = parseArg(args)
projectDir = path.resolve(process.cwd(), arg.req[0] || './')
if not MyUtil.checkProjectDir(projectDir)
+ usage.puts('deploy')
return
exec 'git', ['add', '-A'], () =>
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -57,10 +57,27 @@ exports.writeIfNotExist = (src, content) ->
return true
else
return false
+###
+ src: '/home/user/a'
+ dest: '/home/user/b'
+ force: true
+###
+copy = exports.copy = (src, dest, force) ->
+ destExist = fs.existsSync(dest)
+ if not force and destExist
+ return false
-copy = exports.copy = (src, dest) ->
- content = read(src)
- write(dest, content)
+ if fs.statSync(src).isDirectory()
+ # mkdir
+ if not destExist
+ mkdir(dest)
+ # copy child
+ fs.readdirSync(src).forEach (filename, i) =>
+ copy(path.resolve(src, filename), path.resolve(dest, filename), force)
+ else
+ fs.createReadStream(src).pipe(fs.createWriteStream(dest))
+
+ return true
readJSON = exports.readJSON = (src) ->
content = read(src)
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,58 @@
+path = require('path')
+moment = require('moment')
+util = require('util')
+parseArg = require('./arg').parse
+MyUtil = require('./MyUtil')
+usage = require('./usage')
+file = require('./file')
+
+projectDir = './'
+
+module.exports = (args) ->
+ arg = parseArg(args)
+ projectDir = path.resolve(process.cwd(), arg.req[0] || './')
+
+ if file.copy(path.resolve(__dirname, '../prototype/'), projectDir)
+ util.puts('Blog created at "' + projectDir + '".')
+ else
+ util.puts('Directory "' + projectDir + '" existed!')
+ util.puts('Still create blog? (Y/N)')
+ process.stdin.resume();
+ process.stdin.setEncoding('utf8');
+
+ yesCallback = () ->
+ file.copy(path.resolve(__dirname, '../prototype/'), projectDir, true)
+ util.puts('Blog created at "' + projectDir + '".')
+ util.puts('Init complete.')
+ process.exit()
+
+ noCallback = () ->
+ process.exit()
+
+ callback = () ->
+ util.puts('Please input Y/N.')
+ process.exit()
+
+ process.stdin.on 'data', (chunk) =>
+ if chunk[chunk.length - 1] isnt '\n'
+ callback()
+ return
+ switch chunk.slice(0, -1)
+ when 'Y'
+ yesCallback()
+ when 'y'
+ yesCallback()
+ when 'yes'
+ yesCallback()
+ when 'YES'
+ yesCallback()
+ when 'N'
+ noCallback()
+ when 'n'
+ noCallback()
+ when 'no'
+ noCallback()
+ when 'NO'
+ noCallback()
+ else
+ callback()
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -2,23 +2,23 @@ util = require('util')
clc = require('cli-color')
# command description
commandsDesc =
- deploy: 'Generate static files and deploy to github.'
+ deploy: 'Deploy static files to git server, like github.'
server: 'Start a server on http://localhost:3000 .'
update: 'Generate the static files.'
- post: 'New post.'
- page: 'New page.'
- init: 'Init the project directory.'
+ post: 'Create post.'
+ page: 'Create page.'
+ init: 'Init the blog directory.'
help: 'Display help.'
#command usage
commandsUsage =
- deploy: 'Generate static files and deploy to github.'
+ deploy: ''
server: 'Start a server on http://localhost:3000 .'
update:
'''
- [-q] [project directory]
+ [-q] [blog directory]
- [-q] Use quiet mod, do not print log.
- [project directory] If not set directory then use current directory.
+ [-q] Use quiet mod, do not print log.
+ [blog directory] If not set directory then use current directory.
'''
post:
'''
@@ -33,7 +33,12 @@ commandsUsage =
-f Force to rewrite exist file.
'''
- init: 'Init the project directory.'
+ init:
+ '''
+ [blog directory]
+
+ [blog directory] If not set directory then use current directory.
+ '''
# create space to display
createSpace = (command, maxLength) ->
spaceLength = maxLength - command.length
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1,9 +1,9 @@
{
- "name": "Blogin's blog",
- "description": "A static blog base on blogin.",
- "keywords": "website,blog,framework,static,blogin",
- "author": "MZhou / @zhoumm",
- "email": "zmmbreeze0825@gmail.com",
+ "name": "[Blog name]",
+ "description": "[Blog description]",
+ "keywords": "[Blog keyowrds]",
+ "author": "[Your name]",
+ "email": "[Blog email]",
"siteUrl": "http://nodejs.in",
"favicon": "https://github.com//favicon.ico"
}
Oops, something went wrong.

0 comments on commit 441ef1f

Please sign in to comment.