mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-10 23:35:09 +00:00
react through requirejs
This commit is contained in:
parent
5ba3010015
commit
9a499248df
5
.bowerrc
Normal file
5
.bowerrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"directory": "static/js/libs",
|
||||
"analytics": false,
|
||||
"timeout": 120000
|
||||
}
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
test/workspace
|
||||
static/js/libs
|
||||
|
13
app.js
13
app.js
@ -2,14 +2,19 @@
|
||||
|
||||
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('/builds') === 0) {
|
||||
staticServer.serveFile('/index.html', 200, {}, req, res);
|
||||
} else {
|
||||
if (req.url.indexOf('/data.io.js') === -1) {
|
||||
if (req.url.indexOf('/data.io.js') === -1) {
|
||||
if (req.url.indexOf('/js') === -1) {
|
||||
// Compile a function
|
||||
console.log(1234);
|
||||
var index = jade.compileFile(__dirname + '/views/index.jade');
|
||||
res.write(index());
|
||||
res.end();
|
||||
} else {
|
||||
staticServer.serve(req, res);
|
||||
}
|
||||
}
|
||||
|
24
bower.json
Normal file
24
bower.json
Normal file
@ -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"
|
||||
]
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
"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",
|
||||
@ -35,6 +36,7 @@
|
||||
"devDependencies": {
|
||||
"bower": "^1.4.1",
|
||||
"expect.js": "0.3.1",
|
||||
"gulp": "^3.8.11",
|
||||
"mocha": "1.18.2",
|
||||
"nodemon": "^1.3.7"
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var conn = data(io.connect());
|
||||
var builds = conn.resource('builds');
|
||||
|
||||
console.log(builds);
|
||||
|
||||
builds.sync('readAll', function(err, result) {
|
||||
console.log(result);
|
||||
});
|
5
static/js/app/app.js
Normal file
5
static/js/app/app.js
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
define(['react'], function(React) {
|
||||
console.log(React);
|
||||
});
|
8
static/js/main.js
Normal file
8
static/js/main.js
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
require.config({
|
||||
baseUrl: '/js/',
|
||||
paths: {
|
||||
'react': 'libs/react/react-with-addons',
|
||||
}
|
||||
});
|
10
views/index.jade
Normal file
10
views/index.jade
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user