forked from ga-wdi-boston/api-token-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
194 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exclude: 'node_modules/*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
'use strict'; | ||
|
||
const config = { | ||
apiOrigins: { | ||
production: 'https://ga-wdi-boston.herokuapp.com', | ||
}, | ||
}; | ||
|
||
module.exports = config; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"tests": { | ||
"src": ["vendor.bundle.js", "bundle.js"], | ||
"src": ["public/vendor.js", "public/application.js"], | ||
"options": { | ||
"specs": "specs.js" | ||
"specs": "public/specs.js" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const ghPagesList = [ | ||
'index.html', | ||
'favicon.ico', | ||
'public', | ||
].join(' '); | ||
|
||
module.exports = { | ||
'git-is-clean': { | ||
// `$(git status --porcelain)` will evaluate to the empty string if the | ||
// working directory is clean. | ||
// `test -z` will exit 0 (true) if its argument is an empty string. | ||
// If it doesn't exit true, `(git status && false)` will show why the | ||
// repository isn't clean and exit false causing the grunt tasks to end. | ||
command: 'test -z "$(git status --porcelain)" || (git status && false)', | ||
}, | ||
'git-push-master': { | ||
command: 'git push origin master', | ||
}, | ||
'deploy-prepare': { | ||
command: [ | ||
'git checkout master', | ||
'git branch -D gh-pages || echo "so not removed"', | ||
'git checkout --orphan gh-pages', | ||
'git rm --cached \'*\'', | ||
].join(' && '), | ||
}, | ||
'deploy-publish': { | ||
command: [ | ||
'touch .nojekyll', | ||
`git add --force .nojekyll ${ghPagesList}`, | ||
'git commit -m "deploy task"', | ||
'git push origin gh-pages --force', | ||
'git clean -x -d --force --exclude=node_modules', | ||
'git checkout master', | ||
].join(' && '), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const addNestedValue = function (pojo, name, value) { | ||
const recurse = function recurse(pojo, keys, value) { | ||
value = decodeURIComponent(value); | ||
let key = decodeURIComponent(keys.shift()); | ||
let next = keys[0]; | ||
if (next === '') { // key is an array | ||
pojo[key] = pojo[key] || []; | ||
pojo[key].push(value); | ||
} else if (next) { // key is a parent key | ||
pojo[key] = pojo[key] || {}; | ||
recurse(pojo[key], keys, value); | ||
} else { // key is the key for value | ||
pojo[key] = value; | ||
} | ||
|
||
return pojo; | ||
}; | ||
|
||
let keys = name.split('[').map((k) => k.replace(/]$/, '')); | ||
return recurse(pojo, keys, value); | ||
}; | ||
|
||
module.exports = addNestedValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const addNestedValue = require('./add-nested-value'); | ||
|
||
const parseNestedQuery = queryString => | ||
queryString.split('&') | ||
.reduce((memo, element) => { | ||
if (element) { | ||
let keyValuePair = element.split('='); | ||
memo = addNestedValue(memo, keyValuePair[0], keyValuePair[1]); | ||
} | ||
|
||
return memo; | ||
}, {}); | ||
|
||
module.exports = parseNestedQuery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const parseNestedQuery = require('./parse-nested-query'); | ||
|
||
/* | ||
possibilites to handle and example URLs: | ||
client local, api local | ||
http://localhost:7165/ | ||
client local, api remote | ||
http://localhost:7165/?environment=production | ||
client remote, api local | ||
https://ga-wdi-boston.github.io/browser-template/?environment=development | ||
This will require allowing "unsafe scripts" in Chrome | ||
client remote, api remote | ||
https://ga-wdi-boston.github.io/browser-template/ | ||
*/ | ||
|
||
const setAPIOrigin = (location, config) => { | ||
// strip the leading `'?'` | ||
const search = parseNestedQuery(location.search.slice(1)); | ||
|
||
if (search.environment === 'development' || | ||
location.hostname === 'localhost' && | ||
search.environment !== 'production') { | ||
if (!(config.apiOrigin = config.apiOrigins.development)) { | ||
let port = +('GA'.split('').reduce((p, c) => | ||
p + c.charCodeAt().toString(16), '') | ||
); | ||
config.apiOrigin = `http://localhost:${port}`; | ||
} | ||
} else { | ||
config.apiOrigin = config.apiOrigins.production; | ||
} | ||
}; | ||
|
||
module.exports = setAPIOrigin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.