Skip to content

Commit

Permalink
Gitbooks docs added. [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
prescottprue committed Feb 26, 2016
1 parent 2a1aaf6 commit 2a8f2fc
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"presets": ["es2015", "stage-0"],
"presets": ["es2015"],
"plugins": ["add-module-exports", "lodash"]
}
38 changes: 5 additions & 33 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
# Logs
logs
.DS_Store
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

node_modules
bower_components
tmp
docs

# Users Environment Variables
.lock-wscript

.DS_Store
**/.DS_Store
wiki
wiki/**

examples/**/node_modules
es
coverage
_book
uploads/
97 changes: 60 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,7 @@ Matter is Isomorphic, which means it will work well in both Browser and NodeJS e

## Quick Start

Using Matter requires having created an application on [Build](http://build.kyper.io), [Tessellate](http://tessellate.kyper.io) or on [your own Tessellate server](https://github.com/KyperTech/tessellate/wiki/Run-Your-Own).

### Browser
1. Include the Matter library using one of the following:

#### CDN

To use the CDN, add the following script tag to your `index.html`:

```html
<!-- Matter Library Bundle -->
<script src="http://cdn.kyper.io/js/matter/latest/matter.js"></script>
```
#### Bower
Run `bower install --save kyper-matter`

2. Start using Matter by providing the name of the app you created on [Build](http://build.kyper.io) or [Tessellate](http://tessellate.kyper.io):
```javascript
//New Matter object with the application name 'exampleApp'
var matter = new Matter('exampleApp');
```
3. Start using Matter:
```javascript
//Login to account with username "test" and password "test"
matter.login({username:"test", password:"test"}).then(function(user){
console.log('User logged into exampleApp:', user);
});
```
Using Matter requires having created an application on [devshare](http://devshare.io), [Tessellate](http://tessellate.kyper.io) or on [your own Tessellate server](https://github.com/KyperTech/tessellate/wiki/Run-Your-Own).

### ES6
1. Run `npm install --save kyper-matter`
Expand Down Expand Up @@ -82,6 +55,33 @@ matter.login({username:"test", password:"test"}).then((user) => {
});
```

### Browser
1. Include the Matter library using one of the following:

#### CDN

To use the CDN, add the following script tag to your `index.html`:

```html
<!-- Matter Library Bundle -->
<script src="http://cdn.kyper.io/js/matter/latest/matter.js"></script>
```
#### Bower
Run `bower install --save kyper-matter`

2. Start using Matter by providing the name of the app you created on [Build](http://build.kyper.io) or [Tessellate](http://tessellate.kyper.io):
```javascript
//New Matter object with the application name 'exampleApp'
var matter = new Matter('exampleApp');
```
3. Start using Matter:
```javascript
//Login to account with username "test" and password "test"
matter.login({username:"test", password:"test"}).then(function(user){
console.log('User logged into exampleApp:', user);
});
```

## Options
When creating a new matter object, you can provide an options object as the second argument:

Expand All @@ -100,20 +100,43 @@ Availble options:

## Docs

### [API Documentation](http://cdn.kyper.io/js/matter/latest/docs/index.html)

### [Examples](https://github.com/KyperTech/matter/tree/master/examples)
### [API Documentation](https://kypertech.github.com/matter)

## More Information
For more details please visit the [Matter Wiki](https://github.com/KyperTech/matter/wiki).

Matter is a javascript library that provides common web application functionality such as user authentication and local/session/token storage. In order to build applications quickly, Matter uses [Tessellate](https://github.com/kypertech/tessellate) to store and manage application data.

## Application Data
Matter communicates with [Tessellate](http://github.com/KyperTech/tesselate) for users, auth groups, and other application data. This means that you must have an application on Tessellate or on your own Tessellate server in order for you to be able to control the groups.

## Features

* Login/Logout/Signup
* Authentication Groups
* Secure Auth State Persistence (jwt token + cookies)
* Session Management/Storage
* Authenticated request utility
* Logger utility

*Diagram Coming Soon*

## Examples
### Browser/Javascript
* [Simple](https://github.com/KyperTech/matter/tree/master/examples/browser)

### React

* [Simple](https://github.com/KyperTech/matter/tree/master/examples/React)
* [React-Router and Redux](https://github.com/KyperTech/webpack-redux-react-matter-starter)

### Angular
* [Angular 1](https://github.com/KyperTech/matter/tree/master/examples/angular1)
* [Angular 2](https://github.com/KyperTech/matter/tree/master/examples/Angular2)



## Test

Tests are located in test folder and can be run via `gulp test` or `gulp coverage` commands.

`index.html` has been added as a bare bones test page similar to browser example (`/examples/browser/index.html).

## TODO
* Run tests git pre-push
* More local storage capabilities
* Version release gulp task
16 changes: 16 additions & 0 deletions book.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"gitbook": "2.4.3",
"structure": {
"summary": "docs/README.md"
},
"plugins": ["edit-link", "prism", "-highlight", "github"],
"pluginsConfig": {
"edit-link": {
"base": "https://github.com/kypertech/matter/tree/master",
"label": "Edit This Page"
},
"github": {
"url": "https://github.com/kypertech/matter/"
}
}
}
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

## Table of Contents

* [Read Me](/README.md)
* [API Reference](/docs/api/README.md)
4 changes: 4 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Table of Contents

* [Read Me](/README.md)
* [API Reference](/docs/api/README.md)
136 changes: 136 additions & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@

## signup

```javascript
//Signup a new user
var signupData = {username: 'testuser1', email:'test@email.com', password: 'testpassword'}
matter.signup(signupData).then(function(signupRes){
console.log('New user signed up successfully. New account: ', signupRes.account)
}, function(err){
console.error('Error signing up:', err)
})
```

## login

Log into application

```javascript
//Login as 'testuser1'
var loginData = {username: 'testuser1', password: 'testpassword'}
matter.login(loginData).then(function(loginRes){
console.log('New user logged in succesfully. Account: ', loginRes.user)
}, function(err){
console.error('Error logging in:', err)
})
```

## logout

Logout of currently logged in account

```javascript
//Logout of currently logged in account
matter.logout().then(function(loginRes){
console.log('Logged out successfully')
}, function(err){
console.error('Error logging out:', err)
})
```

## updateAccount

Update currently logged in user's account

```javascript
//Update current account's profile
matter.updateAccount().then(function(updatedAccount){
console.log('Currently logged in account:', updatedAccount)
}, function(err){
console.error('Error updating profile:', err)
})
```

## getCurrentUser

Get the account for the currently logged in user

```javascript
matter.getCurrentUser().then(function(currentAccount){
console.log('Currently logged in account:', currentAccount)
}, function(err){
console.error('Error logging out:', err)
})
```

## recover

Recover account by providing username

```javascript
matter.recover('testUser').then(function(updatedAccount){
console.log('Currently logged in account:', updatedAccount)
}, function(err){
console.error('Error updating profile:', err)
})
```

## isLoggedIn

Get current logged in status

```javascript
if(matter.isLoggedIn){
console.log('There is currently an account logged in.')
} else {
console.warn('There is no account currently logged in.')
}
```

## currentUser

Get currently logged in user

```javascript
//Save account response to current user
matter.currentUser = {username: 'testuser1', email: 'test@email.com'}
console.log('New current user set:', matter.currentUser)
```

## uploadAvatar

Upload an image file as an avatar

```javascript
matter.uploadAvatar(file).then(function(imgUrl){
console.log('Currently logged in account:', imgUrl)
}, function(err){
console.error('Error uploading image:', err)
})
```

## Utilities

```javascript
/* Utility to handle safley writing to localStorage, sessionStorage, and cookies
* @return {Object}
*/
get storage () {
return envStorage
}

/** Utility to handle token writing/deleting/decoding
* @return {Object}
*/
get token () {
return token
}

/** Utils placed in base library
* @return {Object}
*/
get utils () {
return { logger, request, storage: envStorage, dom }
}

```
1 change: 1 addition & 0 deletions docs/api/projects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Projects
1 change: 1 addition & 0 deletions docs/api/users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Users
2 changes: 1 addition & 1 deletion examples/browser/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var matter = new Matter('tessellate', {logLevel: 'trace', envName: 'local'});
var matter = new Matter('tessellate', {logLevel: 'trace', envName: 'prod'});
// console.log('matter:', matter);
//Set logged in status when dom is loaded
document.addEventListener("DOMContentLoaded", function(event) {
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
"watch": "npm run watch:umd",
"dev": "browser-sync start --server --port 5000",
"prepublish": "npm run clean && npm run build",
"upload": "node ./bin/upload"
"upload": "node ./bin/upload",
"docs:clean": "rimraf _book",
"docs:prepare": "gitbook install",
"docs:build": "npm run docs:prepare && gitbook build -g kypertech/matter",
"docs:watch": "npm run docs:prepare && gitbook serve",
"docs:publish": "npm run docs:clean && npm run docs:build && cd _book && git init && git commit --allow-empty -m 'update book' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'update book' && git push git@github.com:kypertech/matter gh-pages --force"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -64,10 +69,10 @@
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-lodash": "^2.0.1",
"babel-preset-es2015": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"chai": "^3.5.0",
"chai-as-promised": "^5.2.0",
"es6-promise": "^3.0.2",
"gitbook-cli": "^1.0.1",
"isparta": "^4.0.0",
"jsdom": "^8.0.4",
"legacy-loader": "0.0.2",
Expand Down

0 comments on commit 2a8f2fc

Please sign in to comment.