├── .gitignore ├── LICENSE.md ├── README.md ├── components ├── counter.js └── counter.jsx ├── gulpfile.js ├── index.js ├── package.json ├── pagejs └── index.js ├── public └── js │ └── index.js └── views └── index.jade /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Example of a general react.js work flow/build process using koa to serve pages 2 | 3 | Jade is used as the templating engine, you can mix and match any engine that is compatible with `co-views` 4 | 5 | This is meant to serve as a more concrete real world type example where the jsx is rendered as part of a build process. 6 | 7 | ###Build: 8 | -- 9 | `gulp` 10 | 11 | ###Develop (watch): 12 | -- 13 | `gulp dev` 14 | 15 | ###Run: 16 | -- 17 | `node --harmony-generators index.js` 18 | You will need node 0.11.x to run this with either the `harmony` flag or `harmony-generators` flag enabled 19 | 20 | ##Directory structure: 21 | - components/ 22 | - counter.js 23 | - counter.jsx 24 | - pagejs/ 25 | - index.js 26 | - public/ 27 | - js/ 28 | - index.js 29 | - views/ 30 | - index.jade 31 | 32 | - components : houses the react components, these are shared between client and server. The *.jsx files are built to the corresponding .js file 33 | - public : these are the static files 34 | - pagejs : these modules are built with browserify to include react. All of the js files in this directory build into public/js/ 35 | - views : where we store our front end templates 36 | 37 | 38 | ###License 39 | --- 40 | MIT 41 | -------------------------------------------------------------------------------- /components/counter.js: -------------------------------------------------------------------------------- 1 | /** @jsx React.DOM */ 2 | 3 | var React = require("react"); 4 | 5 | module.exports = React.createClass({displayName: 'exports', 6 | getInitialState : function(){ 7 | return { 8 | count : this.props.count ? this.props.count : 0 9 | }; 10 | }, 11 | onClick : function(event){ 12 | this.setState({ 13 | count : this.state.count + 1 14 | }); 15 | }, 16 | render : function(){ 17 | return ( 18 | React.DOM.div( {onClick:this.onClick}, 19 | "Count (Click to increment): ", this.state.count 20 | ) 21 | ) 22 | } 23 | }); 24 | 25 | -------------------------------------------------------------------------------- /components/counter.jsx: -------------------------------------------------------------------------------- 1 | /** @jsx React.DOM */ 2 | 3 | var React = require("react"); 4 | 5 | module.exports = React.createClass({ 6 | getInitialState : function(){ 7 | return { 8 | count : this.props.count ? this.props.count : 0 9 | }; 10 | }, 11 | onClick : function(event){ 12 | this.setState({ 13 | count : this.state.count + 1 14 | }); 15 | }, 16 | render : function(){ 17 | return ( 18 |