mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 03:39:15 +00:00
builds resource drafts
This commit is contained in:
parent
0650023ba3
commit
5ba3010015
23
app.js
Normal file
23
app.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
var http = require('http');
|
||||
var nodeStatic = require('node-static');
|
||||
|
||||
var staticServer = new nodeStatic.Server('./static');
|
||||
var app = http.createServer(function(req, res, next) {
|
||||
// serve index for all app pages
|
||||
if (req.url.indexOf('/builds') === 0) {
|
||||
staticServer.serveFile('/index.html', 200, {}, req, res);
|
||||
} else {
|
||||
if (req.url.indexOf('/data.io.js') === -1) {
|
||||
staticServer.serve(req, res);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var io = require('socket.io')(app);
|
||||
var data = require('data.io')(io);
|
||||
|
||||
require('./resources')(data);
|
||||
|
||||
app.listen(3000);
|
@ -26,11 +26,16 @@
|
||||
},
|
||||
"homepage": "https://github.com/okv/nci",
|
||||
"dependencies": {
|
||||
"data.io": "^0.3.0",
|
||||
"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"
|
||||
"mocha": "1.18.2",
|
||||
"nodemon": "^1.3.7"
|
||||
}
|
||||
}
|
||||
|
20
resources/builds.js
Normal file
20
resources/builds.js
Normal file
@ -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);
|
||||
});
|
||||
};
|
9
resources/index.js
Normal file
9
resources/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
module.exports = function(data) {
|
||||
_(['builds', 'projects']).each(function(resource) {
|
||||
require('./' + resource)(data);
|
||||
});
|
||||
};
|
7
resources/projects.js
Normal file
7
resources/projects.js
Normal file
@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(data) {
|
||||
var projects = [{
|
||||
name: 'foo'
|
||||
}];
|
||||
};
|
10
static/app.js
Normal file
10
static/app.js
Normal file
@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
var conn = data(io.connect());
|
||||
var builds = conn.resource('builds');
|
||||
|
||||
console.log(builds);
|
||||
|
||||
builds.sync('readAll', function(err, result) {
|
||||
console.log(result);
|
||||
});
|
20
static/index.html
Normal file
20
static/index.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="/data.io.js"></script>
|
||||
<script src="/app.js"></script>
|
||||
|
||||
<script>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello world</h1>
|
||||
<div id="builds">
|
||||
|
||||
</div>
|
||||
|
||||
<button onclick="createMessage()">Add</button>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user