├── .gitignore ├── package.json ├── server.js └── static └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "documentor-homepage", 3 | "description": "Documentation parsing homepage", 4 | "version": "0.1.0", 5 | "author" : "Andris Reinman", 6 | "maintainers":[ 7 | { 8 | "name":"andris", 9 | "email":"andris@node.ee" 10 | } 11 | ], 12 | "homepage": "http://github.com/andris9/documentor-homepage", 13 | "repository" : { 14 | "type" : "git", 15 | "url" : "http://github.com/andris9/documentor-homepage.git" 16 | }, 17 | "scripts":{ 18 | "test": "nodeunit test/" 19 | }, 20 | "main" : "./lib/documentor-homepage", 21 | "licenses" : [ 22 | { 23 | "type": "MIT", 24 | "url": "http://github.com/andris9/documentor-homepage/blob/master/LICENSE" 25 | } 26 | ], 27 | "dependencies": { 28 | "node-gearman": "*", 29 | "express": "*", 30 | "socket.io": "*" 31 | }, 32 | "devDependencies": { 33 | "nodeunit": "*" 34 | }, 35 | "engine": { 36 | "node": ">=0.6" 37 | }, 38 | "keywords": ["documentation"] 39 | } -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | var app = require('express').createServer(), 2 | io = require('socket.io').listen(app), 3 | Gearman = require("node-gearman"), 4 | gearman = new Gearman(); 5 | 6 | app.listen(80); 7 | 8 | app.get('/', function (req, res) { 9 | res.sendfile(__dirname + '/static/index.html'); 10 | }); 11 | 12 | io.sockets.on('connection', function (socket) { 13 | socket.emit('news', { hello: 'world' }); 14 | socket.on('documentor', function (data) { 15 | console.log(data); 16 | 17 | var job = gearman.submitJob("documentor", JSON.stringify(data)); 18 | 19 | job.on("data", function(data){ 20 | socket.emit('log', { html: data.toString("utf-8") }); 21 | }); 22 | 23 | job.on("end", function(){ 24 | socket.emit('log', { ready: true }); 25 | }); 26 | 27 | job.on("error", function(error){ 28 | socket.emit('log', { error: error.message }); 29 | }); 30 | 31 | job.setTimeout(16*60*1000, function(){ 32 | socket.emit('log', { error: "Timeout exceeded" }); 33 | }); 34 | 35 | }); 36 | }); -------------------------------------------------------------------------------- /static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |