-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
2 changed files
with
36 additions
and
36 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,57 +1,57 @@ | ||
var gather = require('../lib/gather') | ||
, structure = require('../lib/structure') | ||
, viewParams = require('../lib/view-params') | ||
, Doclet = require('../lib/models/doclet') | ||
, _ = require('underscore') | ||
, jade = require('jade') | ||
, chokidar = require('chokidar') | ||
, path = require('path') | ||
, branch = require('git-branch') | ||
, express = require('express') | ||
, io = require('socket.io') | ||
, http = require('http') | ||
, argv = require('optimist').argv; | ||
var structure = require('../lib/structure') | ||
var viewParams = require('../lib/view-params') | ||
var Doclet = require('../lib/models/doclet') | ||
var _ = require('underscore') | ||
var jade = require('jade') | ||
var chokidar = require('chokidar') | ||
var path = require('path') | ||
var branch = require('git-branch') | ||
var express = require('express') | ||
var io = require('socket.io') | ||
var sys = require('sys') | ||
var http = require('http') | ||
var argv = require('optimist').argv | ||
|
||
if (argv.h) { | ||
console.log('-p 3000 -d [dir]'); | ||
return; | ||
console.log('-p 3000 -d [dir]') | ||
sys.exit(0) | ||
} | ||
|
||
var app = express() | ||
, server = http.Server(app) | ||
, socket = io(server); | ||
|
||
server.listen(argv.p || 3000); | ||
|
||
var repoPath = path.resolve(argv.d); | ||
var dbEntry = gather.gatherDocletsAndMeta(repoPath, false, branch.sync(repoPath)); | ||
var server = http.Server(app) | ||
var socket = io(server) | ||
var port = argv.p || 3000 | ||
var repoPath = path.resolve(argv.d) | ||
var dbEntry = gather.gatherDocletsAndMeta(repoPath, false, branch.sync(repoPath)) | ||
|
||
if (dbEntry.error) { | ||
console.log(dbEntry); | ||
return; | ||
console.log(dbEntry) | ||
sys.exit(0) | ||
} | ||
|
||
var template = jade.compileFile('./views/api.jade'); | ||
server.listen(port) | ||
|
||
var template = jade.compileFile('./views/api.jade') | ||
|
||
app.get('/', function (req, res) { | ||
doclet = new Doclet({ | ||
var doclet = new Doclet({ | ||
data: { | ||
hot: true, | ||
hot: 'http://localhost:' + port, | ||
doclets: gather.createDoclets(dbEntry.config, repoPath), | ||
articles: dbEntry.articles | ||
} | ||
}); | ||
|
||
}) | ||
|
||
res.send(template(_.extend({ | ||
moment: require('moment') | ||
}, viewParams.getApiParams(doclet), dbEntry, structure, viewParams))); | ||
}); | ||
}, viewParams.getApiParams(doclet), dbEntry, structure, viewParams))) | ||
}) | ||
|
||
app.use(express.static('assets')); | ||
app.use(express.static('assets')) | ||
|
||
var watch = path.join(repoPath, dbEntry.config.dir); | ||
console.log('Watching ', watch); | ||
var watch = path.join(repoPath, dbEntry.config.dir) | ||
console.log('Watching ', watch) | ||
chokidar.watch(watch).on('all', function () { | ||
socket.emit('change'); | ||
}); | ||
socket.emit('change') | ||
}) |
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