Skip to content

Commit

Permalink
Release v1.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSwitch committed Nov 30, 2017
1 parent 3143361 commit a1d0d31
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 15 deletions.
108 changes: 104 additions & 4 deletions dist/hello.all.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! hellojs v1.15.1 | (c) 2012-2017 Andrew Dodson | MIT https://adodson.com/hello.js/LICENSE */
/*! hellojs v1.16.0 | (c) 2012-2017 Andrew Dodson | MIT https://adodson.com/hello.js/LICENSE */
// ES5 Object.create
if (!Object.create) {

Expand Down Expand Up @@ -1394,13 +1394,13 @@ hello.utils.extend(hello.utils, {
if (options.height) {
var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
var height = screen.height || window.innerHeight || documentElement.clientHeight;
options.top = parseInt((height - options.height) / 2, 10) + dualScreenTop;
options.top = (options.top) ? options.top : parseInt((height - options.height) / 2, 10) + dualScreenTop;
}

if (options.width) {
var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
var width = screen.width || window.innerWidth || documentElement.clientWidth;
options.left = parseInt((width - options.width) / 2, 10) + dualScreenLeft;
options.left = (options.left) ? options.left : parseInt((width - options.width) / 2, 10) + dualScreenLeft;
}

// Convert options into an array
Expand Down Expand Up @@ -1455,7 +1455,7 @@ hello.utils.extend(hello.utils, {
p.redirect_uri = state.redirect_uri || location.href.replace(/[\?\#].*$/, '');

// Redirect to the host
var path = state.oauth_proxy + '?' + _this.param(p);
var path = _this.qs(state.oauth_proxy, p);

location.assign(path);

Expand Down Expand Up @@ -5163,6 +5163,106 @@ if (typeof chrome === 'object' && typeof chrome.identity === 'object' && chrome.

})(hello);

// See: https://developer.spotify.com/web-api/
(function(hello) {

hello.init({

spotify: {
name: 'Spotify',

oauth: {
version: 2,
auth: 'https://accounts.spotify.com/authorize',
grant: 'https://accounts.spotify.com/api/token'
},

// See: https://developer.spotify.com/web-api/using-scopes/
scope_delim: ' ',
scope: {
basic: '',
photos: '',
friends: 'user-follow-read',
publish: 'user-library-read',
email: 'user-read-email',
share: '',
publish_files: '',
files: '',
videos: '',
offline_access: ''
},

// Request path translated
base: 'https://api.spotify.com',

// See: https://developer.spotify.com/web-api/endpoint-reference/
get: {
me: '/v1/me',
'me/following': '/v1/me/following?type=artist', // Only 'artist' is supported

// Because tracks, albums and playlist exist on spotify, the tracks are considered
// the resource for the 'me/likes' endpoint
'me/like': '/v1/me/tracks'
},

// Response handlers
wrap: {
me: formatUser,
'me/following': formatFollowees,
'me/like': formatTracks
},

xhr: formatRequest,
jsonp: false
}
});

// Move the access token from the request body to the request header
function formatRequest(p, qs) {
var token = qs.access_token;
delete qs.access_token;
p.headers.Authorization = 'Bearer ' + token;

return true;
}

function formatUser(o) {
if (o.id) {
o.name = o.display_name;
o.thumbnail = o.images.length ? o.images[0].url : null;
o.picture = o.thumbnail;
}

return o;
}

function formatFollowees(o) {
paging(o);
if (o && 'artists' in o) {
o.data = o.artists.items.forEach(formatUser);
}

return o;
}

function formatTracks(o) {
paging(o);
o.data = o.items;

return o;
}

function paging(res) {
if (res && 'next' in res) {
res.paging = {
next: res.next
};
delete res.next;
}
}

})(hello);

(function(hello) {

var base = 'https://api.twitter.com/';
Expand Down
5 changes: 2 additions & 3 deletions dist/hello.all.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/hello.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! hellojs v1.15.1 | (c) 2012-2017 Andrew Dodson | MIT https://adodson.com/hello.js/LICENSE */
/*! hellojs v1.16.0 | (c) 2012-2017 Andrew Dodson | MIT https://adodson.com/hello.js/LICENSE */
// ES5 Object.create
if (!Object.create) {

Expand Down Expand Up @@ -1394,13 +1394,13 @@ hello.utils.extend(hello.utils, {
if (options.height) {
var dualScreenTop = window.screenTop !== undefined ? window.screenTop : screen.top;
var height = screen.height || window.innerHeight || documentElement.clientHeight;
options.top = parseInt((height - options.height) / 2, 10) + dualScreenTop;
options.top = (options.top) ? options.top : parseInt((height - options.height) / 2, 10) + dualScreenTop;
}

if (options.width) {
var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left;
var width = screen.width || window.innerWidth || documentElement.clientWidth;
options.left = parseInt((width - options.width) / 2, 10) + dualScreenLeft;
options.left = (options.left) ? options.left : parseInt((width - options.width) / 2, 10) + dualScreenLeft;
}

// Convert options into an array
Expand Down Expand Up @@ -1455,7 +1455,7 @@ hello.utils.extend(hello.utils, {
p.redirect_uri = state.redirect_uri || location.href.replace(/[\?\#].*$/, '');

// Redirect to the host
var path = state.oauth_proxy + '?' + _this.param(p);
var path = _this.qs(state.oauth_proxy, p);

location.assign(path);

Expand Down
4 changes: 2 additions & 2 deletions dist/hello.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hellojs",
"version": "1.15.1",
"version": "1.16.0",
"description": "A clientside Javascript library for standardizing requests to OAuth2 web services (and OAuth1 - with a shim)",
"homepage": "https://adodson.com/hello.js",
"main": "dist/hello.all.js",
Expand Down Expand Up @@ -45,4 +45,4 @@
"shunt": "^0.1.4",
"sinon": "~1.7.3"
}
}
}

0 comments on commit a1d0d31

Please sign in to comment.