diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..965c4a2 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,5 @@ +{ + "directory": "static/js/libs", + "analytics": false, + "timeout": 120000 +} diff --git a/.gitignore b/.gitignore index c9e0386..a188c9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules test/workspace +static/js/libs diff --git a/app.js b/app.js new file mode 100644 index 0000000..1eaaa9f --- /dev/null +++ b/app.js @@ -0,0 +1,27 @@ +'use strict'; + +var http = require('http'); +var nodeStatic = require('node-static'); +var jade = require('jade'); + +var staticServer = new nodeStatic.Server('./static'); +var app = http.createServer(function(req, res, next) { + // serve index for all app pages + if (req.url.indexOf('/data.io.js') === -1) { + if (req.url.indexOf('/js') === -1) { + // Compile a function + var index = jade.compileFile(__dirname + '/views/index.jade'); + res.write(index()); + res.end(); + } else { + staticServer.serve(req, res); + } + } +}); + +var io = require('socket.io')(app); +var data = require('data.io')(io); + +require('./resources')(data); + +app.listen(3000); diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..b697a95 --- /dev/null +++ b/bower.json @@ -0,0 +1,24 @@ +{ + "name": "nci", + "version": "0.0.0", + "homepage": "https://github.com/okv/nci", + "authors": [], + "dependencies": { + "underscore": "1.8.2", + "moment": "2.9.0", + "react": "~0.13.1", + "requirejs": "~2.1.17" + }, + "moduleType": [ + "amd" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "app/components/", + "test", + "tests" + ] +} diff --git a/package.json b/package.json index fb3833a..efd8f8d 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,18 @@ }, "homepage": "https://github.com/okv/nci", "dependencies": { + "data.io": "^0.3.0", + "jade": "^1.9.2", + "node-static": "^0.7.6", + "socket.io": "^1.3.5", "twostep": "0.4.1", "underscore": "1.8.2" }, "devDependencies": { + "bower": "^1.4.1", "expect.js": "0.3.1", - "mocha": "1.18.2" + "gulp": "^3.8.11", + "mocha": "1.18.2", + "nodemon": "^1.3.7" } } diff --git a/resources/builds.js b/resources/builds.js new file mode 100644 index 0000000..9fa8e03 --- /dev/null +++ b/resources/builds.js @@ -0,0 +1,20 @@ +'use strict'; + +module.exports = function(data) { + var builds = [{ + project: { + name: 'foo' + }, + start: Date.now(), + step: 1, + completed: false, + status: 'inprogress' + }]; + + var resource = data.resource('builds'); + + resource.use('readAll', function(req, res) { + console.log('readAll'); + res.send(builds); + }); +}; diff --git a/resources/index.js b/resources/index.js new file mode 100644 index 0000000..332f4eb --- /dev/null +++ b/resources/index.js @@ -0,0 +1,9 @@ +'use strict'; + +var _ = require('underscore'); + +module.exports = function(data) { + _(['builds', 'projects']).each(function(resource) { + require('./' + resource)(data); + }); +}; diff --git a/resources/projects.js b/resources/projects.js new file mode 100644 index 0000000..ebe3e24 --- /dev/null +++ b/resources/projects.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = function(data) { + var projects = [{ + name: 'foo' + }]; +}; diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..36c1e4c --- /dev/null +++ b/static/index.html @@ -0,0 +1,20 @@ + + + + + + + + + + +

Hello world

+
+ +
+ + + + + diff --git a/static/js/app/app.js b/static/js/app/app.js new file mode 100644 index 0000000..31d9354 --- /dev/null +++ b/static/js/app/app.js @@ -0,0 +1,5 @@ +'use strict'; + +define(['react'], function(React) { + console.log(React); +}); diff --git a/static/js/main.js b/static/js/main.js new file mode 100644 index 0000000..74d68ae --- /dev/null +++ b/static/js/main.js @@ -0,0 +1,8 @@ +'use strict'; + +require.config({ + baseUrl: '/js/', + paths: { + 'react': 'libs/react/react-with-addons', + } +}); diff --git a/views/index.jade b/views/index.jade new file mode 100644 index 0000000..7f4c9cc --- /dev/null +++ b/views/index.jade @@ -0,0 +1,10 @@ +doctype html +html + head + title test + script(data-main="/js/main" src="/js/libs/requirejs/require.js") + script(type="text/javascript"). + require(['app/app']); + + body + h1 hello world