Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12865c7
commit c757cbb
Showing
8 changed files
with
107 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
# mdserv | ||
# mdserv | ||
static http server with markdown support | ||
|
||
##installation | ||
npm install mdserv | ||
|
||
if you want to use it from the cli install it with | ||
|
||
npm install mdserv -g | ||
|
||
## usage | ||
|
||
### cli | ||
|
||
mdserv init [directory] | ||
|
||
copies the .template.html to the directory. `directory` default to the current | ||
directory. the directory needs to exist, if the template exists, it will be | ||
overridden. | ||
|
||
mdserv serve [directory] [port] | ||
|
||
starts a http server, that serves files from the directory. | ||
`directory` defaults to the current directory, `port` defaults to 3340 | ||
|
||
### module | ||
var mdserv = require('mdserv'); | ||
|
||
mdserve.init(dir, [callback]) | ||
|
||
var handler = mdserve.handler(wwwRoot); | ||
http.createServer(handler).listen(3340); | ||
|
||
|
||
## customizing | ||
you can edit the `.template.html` and all not `.md` `.markdown` will be served | ||
like from a static webserver. | ||
|
||
##license | ||
public domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
init: require('./lib/init'), | ||
handler: require('./lib/handler') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
module.exports = function(directory, cb) { | ||
|
||
var callback = function() { | ||
if (cb) { | ||
cb = null; | ||
cb.apply(null, arguments); | ||
} | ||
}; | ||
|
||
var templateName = '.template.html'; | ||
var source = path.resolve(__dirname, '../template', templateName); | ||
var target = path.resolve(directory, templateName); | ||
|
||
fs.exists(target, function(exist) { | ||
var sourceStream = fs.createReadStream(source); | ||
var targetStream = fs.createWriteStream(target); | ||
targetStream.on('error', callback); | ||
|
||
sourceStream.pipe(targetStream); | ||
sourceStream.on('end', callback); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "mdserv", | ||
"version": "0.0.0", | ||
"description": "static http server with markdown support", | ||
"main": "index.js", | ||
"bin": { | ||
"mdserv": "cli.js" | ||
}, | ||
"dependencies": { | ||
"mime": "~1.2.7", | ||
"marked": "~0.2.5" | ||
}, | ||
"devDependencies": {}, | ||
"scripts": { | ||
"test": "node test/test.js" | ||
}, | ||
"repository": "", | ||
"keywords": [ | ||
"http", | ||
"server", | ||
"markdown" | ||
], | ||
"author": "Bonuspunkt", | ||
"license": "public domain" | ||
} |