Skip to content

Commit

Permalink
major update, moving towards es6 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
echenley committed Jun 20, 2015
1 parent 9c99ca9 commit 2774d5a
Show file tree
Hide file tree
Showing 38 changed files with 6,659 additions and 1,416 deletions.
47 changes: 32 additions & 15 deletions .eslintrc
Expand Up @@ -2,31 +2,48 @@
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
"node": true,
"es6": true
},
"ecmaFeatures": {
"jsx": true
"jsx": true,
"arrowFunctions": true
},
"globals": {
"jest": true,
"React": true,
"jQuery": true,
"$": true
"React": true
},
"plugins": [
"react"
],
"rules": {
"camelcase": true,
"camelcase": [2, {
"properties": "always"
}],
"comma-spacing": [2, {
"before": false,
"after": true
}],
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"no-use-before-define": "nofunc",
"quotes": [2, "single"]
"eqeqeq": [2, "smart"],
"indent": [2, 4],
"no-use-before-define": [2, "nofunc"],
"quotes": [2, "single"],
"semi": [2, "always"],

// eslint-plugin-react specific
"react/jsx-boolean-value": 1,
"react/jsx-no-undef": 1,
"react/jsx-quotes": 1,
"react/jsx-uses-react": 1,
"react/jsx-uses-vars": 1,
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/no-multi-comp": 1,
"react/no-unknown-property": 1,
"react/prop-types": 1,
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1,
"react/sort-comp": 1,
"react/wrap-multilines": 1
}
}
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
dist/
build/
node_modules/
.sass-cache/
.DS_Store
103 changes: 102 additions & 1 deletion README.md
Expand Up @@ -16,4 +16,105 @@ password: henleyedition1

## Development

After cloning, just `cd` in there, run `gulp watch` and have at the `src/` folder.
After cloning, just `cd` in there, run `npm install` and `gulp` and have at the `src/` folder.

## Firebase Security Rules

It was requested that I post my Firebase security rules. Hope this helps!

```javascript
{
"rules": {

"posts": {
// anyone can view posts
".read": true,
".indexOn": ["upvotes", "creatorUID", "commentCount", "time"],

"$id": {
// auth can't be null to make/edit post
// if the post exists, auth.uid must match creatorUID
".write": "(auth != null && !data.exists()) || data.child('creatorUID').val() === auth.uid",

// We want to make sure that all 5 fields are present before saving a new post
".validate": "newData.hasChildren(['title','url','creator','creatorUID', 'time'])",

// title must be a string with length>0
"title": {
".validate": "newData.isString() && newData.val().length > 0"
},
"url": {
".validate": "newData.isString()"
},
"creator": {
".validate": "newData.isString()"
},
"creatorUID": {
".validate": "auth.uid === newData.val() && root.child('users/' + newData.val()).exists()"
},
"commentCount": {
// commentCount must be writable by anyone logged in
// only alterable by 1
".write": "auth != null",
".validate": "(!data.exists() && newData.val() === 1) ||
(newData.val() - data.val() === 1 || newData.val() - data.val() === -1)"
},
"upvotes": {
// upvotes must be writable by anyone logged in
// only alterable by 1
// cannot go below 0
".write": "auth != null",
".validate": "(!data.exists() && newData.val() === 1) ||
(newData.val() > 0 && (newData.val() - data.val() === 1 || newData.val() - data.val() === -1))"
}
}
},

"comments": {
".read": true,
".indexOn": ["postId", "creatorUID", "time"],

"$comment_id": {
".write": "auth != null && (!data.exists() || data.child('creatorUID').val() === auth.uid)",
".validate": "newData.hasChildren(['postId','text','creator','creatorUID', 'time']) &&
(newData.child('text').isString() && newData.child('text').val() != '')",

"upvotes": {
// upvotes must be writable by anyone logged in
// only alterable by 1
".write": "auth != null",
".validate": "(!data.exists() && newData.val() === 1) ||
(newData.val() - data.val() === 1 || newData.val() - data.val() === -1)"
}
}
},

"users": {
".read": true,
".indexOn": ["username"],

"$uid": {
".write": "!data.exists() && auth.uid === $uid",
"upvoted": {
"$postId": {
".write": "auth.uid === $uid"
}
}
}
},

"user_history": {
".read": true,

"$uid": {
// only the user can write here
".write": "auth.uid === $uid"
}
},

// Don't let users post to other fields
"$other": { ".validate": false }

}
}
```

0 comments on commit 2774d5a

Please sign in to comment.