onion/README.md

82 lines
3.3 KiB
Markdown
Raw Normal View History

2015-05-12 14:59:58 +02:00
Introduction
============
Onion is the web client for Ascribe. The idea is to have a well documented,
2015-05-13 15:42:55 +02:00
easy to test, easy to hack, JavaScript application.
2015-05-12 14:59:58 +02:00
2015-05-13 14:44:44 +02:00
The code is JavaScript ECMA 6.
2015-05-12 14:59:58 +02:00
Getting started
===============
2015-05-26 11:12:17 +02:00
Install some nice extensions for Chrom(e|ium):
- [Allow-Control-Allow-Origin](https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi):
we need this to open connection to external hosts ([staging.ascribe.io](http://staging.ascribe.io/) in our case).
Please note that there is an [open issue](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22) that prevents the extension to save the changes in the "intercepted URL or URL pattern". You can follow [this workaround](https://github.com/vitvad/Access-Control-Allow-Origin/issues/22#issuecomment-109898052) to fix the problem.
2015-05-26 11:12:17 +02:00
- [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi)
2015-05-12 15:28:59 +02:00
```bash
git clone git@bitbucket.org:ascribe/onion.git
cd onion
npm install
gulp serve
2015-05-12 15:28:59 +02:00
```
2015-05-26 11:12:17 +02:00
Code Conventions
2015-05-26 10:52:30 +02:00
================
For this project, we're using:
* 4 Spaces
* We use ES6
* We don't use ES6's class declaration for React components because it does not support Mixins as well as Autobinding ([Blog post about it](http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding))
* We don't use camel case for file naming but in everything Javascript related
2015-05-19 17:16:01 +02:00
* We use `let` instead of `var`: [SA Post](http://stackoverflow.com/questions/762011/javascript-let-keyword-vs-var-keyword)
2015-05-12 15:28:59 +02:00
2015-06-08 11:19:18 +02:00
Testing
===============
We're using Facebook's jest to do testing as it integrates nicely with react.js as well.
Tests are always created per directory by creating a `__tests__` folder. To test a specific file, a `<file_name>_tests.js` file needs to be created.
Since we're using mixed syntax, test files are not linted using ES6Lint.
This is due to the fact that jest's function mocking and ES6 module syntax are [fundamentally incompatible](https://github.com/babel/babel-jest/issues/16).
Therefore, to require a module in your test file, you need to use CommonJS's `require` syntax. Except for this, all tests can be written in ES6 syntax.
## Workflow
Generally, when you're runing `gulp serve`, all tests are being run.
If you want to test exclusively (without having the obnoxious ES6Linter warnings), you can just run `gulp jest:watch`.
2015-05-12 15:28:59 +02:00
2015-05-26 10:52:30 +02:00
Troubleshooting
===============
Q: OMG nothing works
2015-06-08 11:50:40 +02:00
2015-05-26 10:52:30 +02:00
A: try `npm install`. Someone may have updated some dependencies
2015-05-12 15:28:59 +02:00
Reading list
============
2015-05-21 10:46:22 +02:00
Start here
----------
- [ReactJS for stupid people](http://blog.andrewray.me/reactjs-for-stupid-people/)
- [Flux for stupid people](http://blog.andrewray.me/flux-for-stupid-people/)
- [ReactJS](https://facebook.github.io/react/)
2015-05-12 15:28:59 +02:00
- [alt.js](http://alt.js.org/)
2015-05-13 14:44:44 +02:00
- [alt.js readme](https://github.com/goatslacker/alt)
2015-05-21 10:46:22 +02:00
Moar stuff
----------
- [ReactJS: Reusable Components](https://facebook.github.io/react/docs/reusable-components.html#es6-classes)
2015-05-20 21:21:33 +02:00
- [24ways.org: JavaScript Modules the ES6 Way](http://24ways.org/2014/javascript-modules-the-es6-way/)
- [Babel: Learn ES6](https://babeljs.io/docs/learn-es6/)
2015-05-20 21:39:47 +02:00
- [egghead's awesome reactjs and flux tutorials](https://egghead.io/)
2015-05-21 10:46:22 +02:00
- [Crockford's genious Javascript: The Good Parts (Tim has a copy)](http://www.amazon.de/JavaScript-Parts-Working-Shallow-Grain/dp/0596517742)