diff --git a/package.json b/package.json index ce5321665..823d29e8e 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "redis": "~0.8.3", "request": "~2.33.0", "restify": "~2.5.1", - "restify-oauth2-oauthd": "~2.2.0", "rewire": "^2.1.0", "rimraf": "^2.2.8", "sugar": "^1.4.1", diff --git a/providers/23andme/settings.json b/providers/23andme/settings.json index eee2ca4d8..cd8a235a1 100644 --- a/providers/23andme/settings.json +++ b/providers/23andme/settings.json @@ -11,7 +11,8 @@ "install": { "href": { "provider": "https://23andme.com/", - "docs": "https://api.23andme.com/docs" + "docs": "https://api.23andme.com/docs", + "apps": "https://api.23andme.com/dev" } }, "sample": { diff --git a/providers/500px/settings.json b/providers/500px/settings.json index 71c28c768..3846b236d 100644 --- a/providers/500px/settings.json +++ b/providers/500px/settings.json @@ -11,7 +11,8 @@ "install": { "href": { "provider": "http://500px.com/", - "docs": "https://github.com/500px/api-documentation" + "docs": "https://github.com/500px/api-documentation", + "apps": "http://500px.com/settings/applications" } }, "sample": { diff --git a/providers/angel_list/conf.json b/providers/angel_list/conf.json new file mode 100644 index 000000000..c49afdcb6 --- /dev/null +++ b/providers/angel_list/conf.json @@ -0,0 +1,53 @@ +{ + "name": "AngelList", + "desc": "AngelList is a US website for startups, angel investors, and job-seekers looking to work at startups.", + "url": "https://api.angel.co/", + "oauth2": { + "authorize": { + "url": "https://angel.co/api/oauth/authorize", + "query": { + "response_type": "code", + "client_id": "{client_id}", + "state": "{{state}}", + "scope": "{scope}" + }, + "format": "url" + }, + "access_token": { + "url": "https://angel.co/api/oauth/token", + "query": { + "client_id": "{client_id}", + "client_secret": "{client_secret}", + "grant_type": "authorization_code", + "code": "{{code}}" + }, + "format": "json" + }, + "request": { + "url": "https://api.angel.co/" + }, + "refresh": { + "url": "https://angel.co/api/oauth/token", + "method": "post", + "query": { + "client_id": "{client_id}", + "client_secret": "{client_secret}", + "grant_type": "refresh_token", + "refresh_token": "{{refresh_token}}" + } + }, + "parameters": { + "client_id": "string", + "client_secret": "string", + "scope": { + "values": { + "comment": "gives your application permission to create and destroy likes and comments.", + "email": "gives your application access to the user's email address.", + "message": "gives your application access to the user's private messages, for reading and writing.", + "talent": "gives your application access to the user's presence on AngelList Talent." + }, + "separator": " " + } + } + } +} \ No newline at end of file diff --git a/providers/angel_list/config.png b/providers/angel_list/config.png new file mode 100644 index 000000000..c7866f4fc Binary files /dev/null and b/providers/angel_list/config.png differ diff --git a/providers/angel_list/keys.png b/providers/angel_list/keys.png new file mode 100644 index 000000000..0f9128735 Binary files /dev/null and b/providers/angel_list/keys.png differ diff --git a/providers/angel_list/logo.png b/providers/angel_list/logo.png new file mode 100644 index 000000000..86e214c53 Binary files /dev/null and b/providers/angel_list/logo.png differ diff --git a/providers/angel_list/me.js b/providers/angel_list/me.js new file mode 100644 index 000000000..889ba3324 --- /dev/null +++ b/providers/angel_list/me.js @@ -0,0 +1,20 @@ +var me = { + fetch: [ + + function(fetched_elts) { + return '/1/me'; + } + + ], + params: {}, + fields: { + id: "=", + email: "=", + location: "country", + name: "=", + avatar: function(me) { + return me.image; + } + } +}; +module.exports = me; diff --git a/providers/angel_list/settings.json b/providers/angel_list/settings.json new file mode 100644 index 000000000..19fc07b09 --- /dev/null +++ b/providers/angel_list/settings.json @@ -0,0 +1,23 @@ +{ + "settings": { + "createApp": { + "url": "https://angel.co/api/oauth/clients", + "image": "config.png" + }, + "copyingKey": { + "url": "https://angel.co/api/oauth/clients", + "image": "keys.png" + }, + "install": { + "href": { + "provider": "https://angel.co/", + "docs": "https://angel.co/api", + "apps": "https://angel.co/api/oauth/clients" + } + }, + "sample": { + "method": "get", + "url": "/1/me" + } + } +} diff --git a/providers/app_net/config.png b/providers/app_net/config.png new file mode 100644 index 000000000..80402af4a Binary files /dev/null and b/providers/app_net/config.png differ diff --git a/providers/app_net/keys.png b/providers/app_net/keys.png new file mode 100644 index 000000000..2f392b467 Binary files /dev/null and b/providers/app_net/keys.png differ diff --git a/providers/app_net/logo.png b/providers/app_net/logo.png new file mode 100644 index 000000000..93a17aa2f Binary files /dev/null and b/providers/app_net/logo.png differ diff --git a/providers/app_net/me.js b/providers/app_net/me.js new file mode 100644 index 000000000..bcdf4d191 --- /dev/null +++ b/providers/app_net/me.js @@ -0,0 +1,28 @@ +var me = { + fetch: [ + + function(fetched_elts) { + return '/users/me'; + } + + ], + params: {}, + fields: { + id: function(me) { + return me.data.id; + }, + location: function(me) { + return me.data.locale; + }, + name: function(me) { + return me.data.username; + }, + avatar: function(me) { + return me.data.avatar_image.url; + }, + alias: function(me) { + return me.data.username; + } + } +}; +module.exports = me; diff --git a/providers/app_net/settings.json b/providers/app_net/settings.json new file mode 100644 index 000000000..839461ffd --- /dev/null +++ b/providers/app_net/settings.json @@ -0,0 +1,23 @@ +{ + "settings": { + "createApp": { + "url": "https://developers.app.net/docs/guides/create-an-app/", + "image": "config.png" + }, + "copyingKey": { + "url": "https://account.app.net/developer/apps/", + "image": "keys.png" + }, + "install": { + "href": { + "provider": "https://app.net/", + "docs": "https://developers.app.net/reference/resources/", + "apps": "https://account.app.net/developer/apps/" + } + }, + "sample": { + "method": "get", + "url": "/users/me" + } + } +} diff --git a/providers/asana/settings.json b/providers/asana/settings.json index a45f74acc..9b1283069 100644 --- a/providers/asana/settings.json +++ b/providers/asana/settings.json @@ -11,7 +11,8 @@ "install": { "href": { "provider": "https://asana.com", - "docs": "http://developer.asana.com/documentation" + "docs": "http://developer.asana.com/documentation", + "apps": "http://app.asana.com/-/account_api" } }, "sample": { diff --git a/providers/bitbucket/settings.json b/providers/bitbucket/settings.json index cc16b738f..5ad0a71b4 100644 --- a/providers/bitbucket/settings.json +++ b/providers/bitbucket/settings.json @@ -1,17 +1,17 @@ { "settings": { "createApp": { - "url": "https://bitbucket.org/account", + "url": "https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket#OAuthonBitbucket-Step1.CreateanOAuthkeyandsecret", "image": "config.png" }, "copyingKey": { - "url": "https://bitbucket.org/account", + "url": "https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket#OAuthonBitbucket-Step1.CreateanOAuthkeyandsecret", "image": "keys.png" }, "install": { "href": { "provider": "https://bitbucket.org/", - "docs": "http://confluence.atlassian.com/display/BITBUCKET/Using+the+Bitbucket+REST+APIs" + "docs": "https://confluence.atlassian.com/display/BITBUCKET/Use+the+Bitbucket+REST+APIs" } }, "sample": { diff --git a/providers/github/me.js b/providers/github/me.js index 04735fcd5..2fa8723f7 100644 --- a/providers/github/me.js +++ b/providers/github/me.js @@ -3,6 +3,9 @@ var me = { url: '/user', params: {}, fields: { + id: function(me) { + return "" + me.id; + }, name: '=', company: '=', alias: 'login', diff --git a/providers/spotify/conf.json b/providers/spotify/conf.json index 2a19268ee..2028fd723 100644 --- a/providers/spotify/conf.json +++ b/providers/spotify/conf.json @@ -56,7 +56,7 @@ "user-read-private": "Access your profile name, image and subscription details", "user-read-email": "Get your real email address" }, - "separator": "," + "separator": " " } } }, diff --git a/providers/spotify/settings.json b/providers/spotify/settings.json index ba83b2979..63b5cee3b 100644 --- a/providers/spotify/settings.json +++ b/providers/spotify/settings.json @@ -11,7 +11,8 @@ "install": { "href": { "provider": "https://www.spotify.com/", - "docs": "https://developer.spotify.com/web-api/" + "docs": "https://developer.spotify.com/web-api/", + "apps": "https://developer.spotify.com/my-applications" } }, "sample": { diff --git a/providers/uber/settings.json b/providers/uber/settings.json index ab7b2d390..9113166b3 100644 --- a/providers/uber/settings.json +++ b/providers/uber/settings.json @@ -2,14 +2,17 @@ "settings": { "createApp": { "url": "https://login.uber.com/applications/new", + "image": "config.png" }, "copyingKey": { "url": "https://login.uber.com/applications", + "image": "keys.png" }, "install": { "href": { "provider": "https://uber.com/", - "docs": "https://developer.uber.com/v1/api-reference/" + "docs": "https://developer.uber.com/v1/api-reference/", + "apps": "https://login.uber.com/applications" } }, "sample": { @@ -21,7 +24,6 @@ "method": "get", "url": "/v1/me" } - }, - "jsfiddle": "http://jsfiddle.net/willjcksn/2hb6B/embedded/" + } } } \ No newline at end of file diff --git a/src/core/pluginsEngine/plugins.coffee b/src/core/pluginsEngine/plugins.coffee index 9eab55b65..a23d8682e 100644 --- a/src/core/pluginsEngine/plugins.coffee +++ b/src/core/pluginsEngine/plugins.coffee @@ -82,6 +82,7 @@ module.exports = (env) -> pluginsEngine.init = (cwd, callback) -> env.pluginsEngine.cwd = cwd + env.scaffolding.plugins.info.getPluginsJson({ activeOnly: true }) .then (obj) -> if not obj? @@ -94,6 +95,7 @@ module.exports = (env) -> loadPlugin(global_interface) return callback null .fail (e) -> + console.log e return callback e pluginsEngine.list = (callback) -> diff --git a/src/data/base-entity.coffee b/src/data/base-entity.coffee index b6f00d196..deef4cebd 100644 --- a/src/data/base-entity.coffee +++ b/src/data/base-entity.coffee @@ -107,26 +107,45 @@ module.exports = (env) -> defer.promise - save: () -> + save: (overwrite, delete_unknown_keys) -> + overwrite ?= true + delete_unknown_keys ?= false defer = Q.defer() # hat function that actually saves _save = (done) => multi = env.data.redis.multi() - for key, value of @props - if typeof value == 'string' - multi.set @prefix() + key, value - if typeof value == 'object' and not value?.length? - multi.hmset @prefix() + key, value - if typeof value == 'object' and value?.length? - multi.del @prefix() + key - for k, v of value - multi.sadd @prefix() + key, v - - # actual save - multi.exec (e, res) => - return done e if e - done() + + @keys() + .then (keys) => + if delete_unknown_keys + prefixedProps = [] + for key in Object.keys(@props) + prefixedProps.push @prefix() + key + for key in keys + if key not in prefixedProps + multi.del key + for key, value of @props + if typeof value == 'string' or typeof value == 'number' + multi.set @prefix() + key, value + else if typeof value == 'object' and Array.isArray(value) + multi.del @prefix() + key + for k, v of value + multi.sadd @prefix() + key, v + else if value? and typeof value == 'object' + if overwrite + multi.del @prefix() + key + multi.hmset @prefix() + key, value + else + # TODO (value instanceof Boolean || typeof value == 'boolean') + console.log "not saved: type not found" + + # actual save + multi.exec (e, res) => + return done e if e + done() + .fail (e) => + return done e if e # checks if new entity or not. If no id found, increments ids if not @id? diff --git a/src/scaffolding/plugins/git.coffee b/src/scaffolding/plugins/git.coffee index 0cfa43ef2..c109737f3 100644 --- a/src/scaffolding/plugins/git.coffee +++ b/src/scaffolding/plugins/git.coffee @@ -27,7 +27,6 @@ module.exports = (env, plugin_name, fetch, cwd) -> git = getCurrentVersion: () -> defer = Q.defer() - execGit ['branch -v'], (error, stdout, stderr) -> return defer.reject error if error diff --git a/src/scaffolding/plugins/info.coffee b/src/scaffolding/plugins/info.coffee index 84f89af68..4ce77e447 100644 --- a/src/scaffolding/plugins/info.coffee +++ b/src/scaffolding/plugins/info.coffee @@ -13,6 +13,7 @@ module.exports = (env) -> getPluginsJson: (opts) -> defer = Q.defer() opts ?= {} + fs.readFile process.cwd() + '/plugins.json', {encoding: 'UTF-8'}, (err, data) -> return defer.reject err if err try @@ -50,6 +51,7 @@ module.exports = (env) -> plugins_json[plugin_name] = value next() .fail (e) -> + plugins_json[plugin_name] = { name: plugin_name, active: true @@ -133,6 +135,8 @@ module.exports = (env) -> .then (v) -> plugin_data.version = v.version defer.resolve plugin_data + .fail () -> + defer.resolve plugin_data catch err defer.reject err diff --git a/src/server.coffee b/src/server.coffee index 690abac58..3c6e42da2 100644 --- a/src/server.coffee +++ b/src/server.coffee @@ -8,13 +8,13 @@ module.exports = (env) -> #libs fs = require 'fs' restify = require 'restify' - bodyParser = require "body-parser" + bodyParser = require "body-parser" cookieParser = require "cookie-parser" session = require "express-session" https = require 'https' Path = require 'path' - + PLModule = require './presentationLayer' # Server config and launch @@ -32,9 +32,9 @@ module.exports = (env) -> env.server = server = restify.createServer server_options env.pluginsEngine.runSync 'raw' - server.use restify.authorizationParser() server.use restify.queryParser() server.use restify.bodyParser mapParams:false + server.use restify.authorizationParser() # Adds the 'always' middleware for each request for k, middleware of env.middlewares.always @@ -58,6 +58,6 @@ module.exports = (env) -> env.debug '%s listening at %s for %s', server.name, server.url, env.config.host_url env.events.emit 'server', null callback null, server - + server.listen.apply server, listen_args }