154 |
155 | ${elements} 156 | 158 | ` 159 | } 160 | 161 | function loading (state) { 162 | return el` 163 |
164 | ` 165 | } 166 | 167 | function thanks (state) { 168 | console.log('thanks state', state) 169 | return el` 170 |
171 |

Thanks for your submission!

172 |

Your pull request: #${state.pullRequest.number} - ${state.pullRequest.title}

173 |

Your fork: ${state.fork.full_name}

174 |

More about this project: submit-data

175 |

More about EditData: about.editdata.org

176 |
177 | ` 178 | } 179 | 180 | function landing (state) { 181 | var url = 'https://github.com/login/oauth/authorize' + 182 | '?client_id=' + config.client_id + 183 | '&scope=' + config.scope + 184 | '&redirect_uri=' + config.redirect_uri 185 | 186 | return el` 187 |
188 |

Create a pull request via the GitHub API

189 |

Log in to add an item to a JSON file by filling out a form!

190 |

This site will create a fork of this repo on your account, create a branch for your submission, save your submission, then create a pull request on the source repository.

191 | 192 |
193 | ` 194 | } 195 | 196 | function header (state) { 197 | return el` 198 |
199 |
200 |

${state.site.title}

201 | ${authUI.render(state)} 202 |
203 |
204 | ` 205 | } 206 | 207 | function layout (state) { 208 | return el` 209 |
210 | ${header(state)} 211 | ${content(state)} 212 |
213 | ` 214 | } 215 | -------------------------------------------------------------------------------- /modal.js: -------------------------------------------------------------------------------- 1 | var el = require('yo-yo') 2 | 3 | function createModal (state) { 4 | return el` 5 | 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /modify-state.js: -------------------------------------------------------------------------------- 1 | var extend = require('xtend') 2 | 3 | var modifiers = { 4 | 'loading': function (action, state) { 5 | return extend(state, { loading: true }) 6 | }, 7 | 'loading:complete': function (action, state) { 8 | return extend(state, { loading: false }) 9 | }, 10 | 'user:login': function (action, state) { 11 | return extend(state, { 12 | user: { 13 | profile: action.profile, 14 | token: action.token 15 | } 16 | }) 17 | }, 18 | 'user:logout': function (action, state) { 19 | return extend(state, { user: null }) 20 | }, 21 | 'form:submit': function (action, state) { 22 | var item = action.fields 23 | var data = state.data 24 | data.push(item) 25 | return extend(state, { 26 | item: item, 27 | data: data 28 | }) 29 | }, 30 | 'submitted': function (action, state) { 31 | return extend(state, { 32 | submitted: true, 33 | fork: action.fork, 34 | branch: action.branch, 35 | pullRequest: action.pullRequest 36 | }) 37 | }, 38 | 'error': function (action, state) { 39 | return extend(state, { error: action.error }) 40 | } 41 | } 42 | 43 | module.exports = function modifier (action, state) { 44 | console.log('-------------------------------------') 45 | console.log('action:', action.type, action) 46 | var newState = modifiers[action.type](action, state) 47 | console.log('.....................................') 48 | console.log('new state:', newState) 49 | //console.log('-------------------------------------') 50 | return newState 51 | } 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "submit-data", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "standard && tape tests/*.js | tap-spec", 8 | "bundle": "browserify index.js -t yo-yoify -t [ envify --NODE_ENV production ] -o bundle.js", 9 | "start": "budo index.js:bundle.js --live --css style.css" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/editdata/submit-data.git" 14 | }, 15 | "keywords": [], 16 | "author": "", 17 | "license": "MIT", 18 | "bugs": { 19 | "url": "https://github.com/editdata/submit-data/issues" 20 | }, 21 | "homepage": "https://github.com/editdata/submit-data#readme", 22 | "devDependencies": { 23 | "browserify": "^13.0.0", 24 | "budo": "^8.1.0", 25 | "envify": "^3.4.0", 26 | "standard": "^6.0.8", 27 | "tap-spec": "^4.1.1", 28 | "tape": "^4.5.1", 29 | "testron": "^1.2.0" 30 | }, 31 | "dependencies": { 32 | "base-64": "^0.1.0", 33 | "cookie-cutter": "^0.1.1", 34 | "form-serialize": "^0.7.1", 35 | "github-static-auth": "^1.0.0", 36 | "json-schema-defaults": "^0.1.1", 37 | "moment": "^2.12.0", 38 | "sheet-router": "^2.0.1", 39 | "sheetify": "^5.0.0", 40 | "store-emitter": "^2.1.0", 41 | "utf8": "^2.1.1", 42 | "xhr": "^2.2.0", 43 | "xtend": "^4.0.1", 44 | "yo-yo": "^1.1.1", 45 | "yo-yoify": "^1.0.2" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /schema.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | required: true, 3 | type: 'object', 4 | properties: { 5 | title: { 6 | required: true, 7 | type: 'string', 8 | default: null 9 | }, 10 | description: { 11 | type: 'string', 12 | default: null 13 | }, 14 | url: { 15 | type: 'string', 16 | default: null 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: "Source Sans Pro"; 3 | width: 100%; 4 | height: 100%; 5 | padding: 0px; 6 | margin: 0px; 7 | } 8 | 9 | #app { 10 | width: 100%; 11 | height: 100%; 12 | } 13 | 14 | .app-header { 15 | background-color: #efefef; 16 | padding: 10px 0px; 17 | height: 40px; 18 | border-bottom: 1px solid #cecece; 19 | } 20 | 21 | .app-header .app-title { 22 | margin: 0px; 23 | display: inline-block; 24 | font-size: 20px; 25 | font-weight: 500; 26 | line-height: 40px; 27 | } 28 | 29 | .app-header .github-auth { 30 | float: right; 31 | } 32 | 33 | .app-header .profile { 34 | 35 | } 36 | 37 | .app-header .profile-avatar { 38 | height: 20px; 39 | width: 20px; 40 | vertical-align: middle; 41 | } 42 | 43 | .field { 44 | margin-bottom: 20px; 45 | } 46 | 47 | .field-text { 48 | width: 100%; 49 | font-size: 18px; 50 | padding: 5px; 51 | } 52 | 53 | 54 | .container { 55 | width: 80%; 56 | max-width: 800px; 57 | margin: 0px auto; 58 | } 59 | 60 | .button, 61 | .button:link, 62 | .button:visited, 63 | button, 64 | input[type="submit"], 65 | input[type="reset"], 66 | input[type="button"] { 67 | background-color: #fff; 68 | border: 1px solid #aaa; 69 | border-radius: 0.2em; 70 | box-sizing: border-box; 71 | color: #666; 72 | cursor: pointer; 73 | display: inline-block; 74 | font-family: sans-serif; 75 | font-size: 0.9em; 76 | font-weight: 500; 77 | height: 40px; 78 | letter-spacing: 0.05em; 79 | line-height: 38px; 80 | margin-bottom: 0em; 81 | padding: 0px 10px 0px 10px; 82 | text-align: center; 83 | text-decoration: none; 84 | vertical-align: top; 85 | white-space: nowrap; 86 | } 87 | 88 | .button:hover, 89 | .button:focus, 90 | button:hover, 91 | input[type="submit"]:hover, 92 | input[type="reset"]:hover, 93 | input[type="button"]:hover, 94 | button:focus, 95 | input[type="submit"]:focus, 96 | input[type="reset"]:focus, 97 | input[type="button"]:focus { 98 | border: 1px solid #444; 99 | color: #555; 100 | } 101 | 102 | .button:active, 103 | button:active, 104 | input[type="submit"]:active, 105 | input[type="reset"]:active, 106 | input[type="button"]:active { 107 | color: #000; 108 | border: 1px solid #000; 109 | } 110 | 111 | .loading { 112 | margin: 0px auto; 113 | } 114 | 115 |
--------------------------------------------------------------------------------