Skip to content

Commit 7033379

Browse files
author
Michael Williams
committedFeb 11, 2014
initial commit. got simple router + react working
0 parents  commit 7033379

13 files changed

+205
-0
lines changed
 

‎.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
db.sqlite
2+
db.test.sqlite
3+
/static/index.js
4+
/static/.index.js*
5+
/static/index.css
6+
/static/.index.css*
7+
/node_modules
8+
npm-debug.log
9+
*.swp
10+
/target

‎.jshintrc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"browser": true,
3+
"devel": true,
4+
"node": true,
5+
"globals": {
6+
"describe": false,
7+
"it": false,
8+
"before": false,
9+
"after": false,
10+
"beforeEach": false,
11+
"afterEach": false
12+
},
13+
"passfail": false,
14+
"curly": true,
15+
"eqeqeq": true,
16+
"indent": 2,
17+
"latedef": true,
18+
"newcap": true,
19+
"noarg": true,
20+
"undef": true,
21+
"strict": true,
22+
"trailing": true,
23+
"multistr": true,
24+
"expr": true
25+
}

‎.nodemonignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/static/*
2+
db.sqlite*
3+
/.git/*
4+
/README.md
5+
*.less
6+
*.swp

‎.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
language: node_js
2+
node_js:
3+
- "0.10"
4+
- "0.8"
5+
notifications:
6+
email: false

‎index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
module.exports = require('./src');

‎package.json

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "action-delegation",
3+
"version": "0.0.0",
4+
"description": "a holonic action delegation system",
5+
"main": "./index.js",
6+
"browser": "./src/client.js",
7+
"repository": {
8+
"type": "git",
9+
"url": "http://github.com/holonomy/action-delegation"
10+
},
11+
"author": "",
12+
"license": "AGPLv3",
13+
"bugs": {
14+
"url": "https://github.com/holonomy/action-delegation/issues"
15+
},
16+
"dependencies": {
17+
"ecstatic": "~0.4.12",
18+
"less": "~1.5.1",
19+
"browserify": "~3.14.0",
20+
"cssmin": "~0.4.1",
21+
"uglify-js": "~2.4.7",
22+
"reactify": "~0.7.0",
23+
"envify": "~0.2.0",
24+
"react": "~0.8.0",
25+
"semantic-ui": "git+https://github.com/Semantic-Org/Semantic-UI.git",
26+
"underscore": "~1.6.0",
27+
"react-router-component": "~0.2.1",
28+
"domready": "~0.2.13"
29+
},
30+
"devDependencies": {
31+
"mocha": "~1.16.0",
32+
"catw": "~0.2.0",
33+
"watchify": "~0.6.1",
34+
"nodemon": "~0.7.10",
35+
"jshint": "~2.4.0",
36+
"testling": "~1.5.3",
37+
"npm-release": "~0.0.4",
38+
"sinon": "~1.7.3",
39+
"chai": "~1.8.1",
40+
"chai-as-promised": "~4.1.0",
41+
"mocha-as-promised": "~2.0.0"
42+
},
43+
"browserify": {
44+
"transform": [
45+
"reactify"
46+
]
47+
},
48+
"scripts": {
49+
"build-js": "browserify src/client.js | uglifyjs -mc > static/index.js",
50+
"build-css": "catw -c 'lessc --include-path=src:node_modules/semantic-ui/src -' 'src/index.less' | cssmin > static/index.css",
51+
"build": "npm run build-css && npm run build-js",
52+
"watch-js": "watchify src/client.js -o static/index.js -dv",
53+
"watch-css": "catw -c 'lessc --include-path=src:node_modules/semantic-ui/src -' 'src/index.less' -o static/index.css -v",
54+
"watch": "npm run watch-css & npm run watch-js",
55+
"lint": "jshint src ;true",
56+
"develop": "npm run watch & nodemon index.js",
57+
"start": "npm run build && node .",
58+
"release": "npm-release patch -m \"version++\""
59+
}
60+
}

‎src/app.jsx

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var React = require('react');
2+
var Router = require('react-router-component');
3+
4+
var Locations = Router.Locations;
5+
var Location = Router.Location;
6+
7+
var WriteView = require('./write-view.jsx');
8+
var ReadView = require('./read-view.jsx');
9+
10+
module.exports = React.createClass({
11+
render: function () {
12+
return (
13+
<Locations onClick={this.onClick} ref="router">
14+
<Location path="/" handler={WriteView} />
15+
<Location path="/write" handler={WriteView} />
16+
<Location path="/read" handler={ReadView} />
17+
</Locations>
18+
);
19+
},
20+
onClick: function (e) {
21+
if (e.target.tagName === 'A' && e.target.attributes.href) {
22+
e.preventDefault();
23+
this.refs.router.navigate(e.target.attributes.href.value);
24+
}
25+
},
26+
});

‎src/client.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var React = require('react');
2+
var domready = require('domready');
3+
4+
var App = require('./app.jsx');
5+
var app = App(null);
6+
7+
domready(function () {
8+
React.renderComponent(app, document.body);
9+
});

‎src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./server');

‎src/read-view.jsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var React = require('react');
2+
3+
module.exports = React.createClass({
4+
render: function () {
5+
return (
6+
<div>
7+
<nav>
8+
<a href="write">write</a>
9+
</nav>
10+
<main>
11+
read
12+
</main>
13+
</div>
14+
);
15+
},
16+
});

‎src/server.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
3+
var http = require('http');
4+
var ecstatic = require('ecstatic');
5+
6+
var isProd = (process.env.NODE_ENV === "production");
7+
8+
var server = http.createServer(
9+
ecstatic({
10+
root: __dirname + "/../static",
11+
cache: (isProd ? 3600 : 0),
12+
})
13+
).listen(isProd ? 80 : 5000);
14+
15+
module.exports = server;

‎src/write-view.jsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var React = require('react');
2+
3+
module.exports = React.createClass({
4+
render: function () {
5+
return (
6+
<div>
7+
<nav>
8+
<a href="read">read</a>
9+
</nav>
10+
<main>
11+
write
12+
</main>
13+
</div>
14+
);
15+
},
16+
});

‎static/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<title>workshift</title>
7+
<link rel="stylesheet" href="index.css">
8+
<script src="index.js"></script>
9+
</head>
10+
<body>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)
Please sign in to comment.