diff options
| author | Yuval Adam <yuval@y3xz.com> | 2015-06-13 00:41:53 +0300 |
|---|---|---|
| committer | Yuval Adam <yuval@y3xz.com> | 2015-06-13 00:41:53 +0300 |
| commit | 9ae25440f70d97ce33dc2b139b381a098f761349 (patch) | |
| tree | b18edc4b6b7b0e1fa4b2622e34ef5e5124df152b | |
| parent | 25206e29512d99b059bc48e0718e88205d07ae4a (diff) | |
Image proxy is WORKING
| -rw-r--r-- | .meteor/packages | 1 | ||||
| -rw-r--r-- | .meteor/versions | 1 | ||||
| -rw-r--r-- | client/button.js | 3 | ||||
| -rw-r--r-- | client/templates/photos.html | 2 | ||||
| -rw-r--r-- | lib/router.js | 9 | ||||
| -rw-r--r-- | server/methods.js | 2 |
6 files changed, 16 insertions, 2 deletions
diff --git a/.meteor/packages b/.meteor/packages index c42999a..9d1fb01 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -14,3 +14,4 @@ iron:router http nemo64:bootstrap less +aldeed:http diff --git a/.meteor/versions b/.meteor/versions index 0236d4e..3f447c8 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,6 +1,7 @@ accounts-base@1.2.0 accounts-oauth@1.1.5 accounts-ui-unstyled@1.1.7 +aldeed:http@0.2.2 autopublish@1.0.3 autoupdate@1.2.1 base64@1.0.3 diff --git a/client/button.js b/client/button.js index 420224d..2fabf31 100644 --- a/client/button.js +++ b/client/button.js @@ -60,6 +60,9 @@ Template.photo.helpers({ date: function () { var d = new Date(parseInt(this.created_time) * 1000); return d.getDate() + '/' + (d.getMonth() + 1) + '/' + d.getFullYear(); + }, + proxy: function (url) { + return url.replace('https://scontent.cdninstagram.com', '/imgproxy?url=') } }) diff --git a/client/templates/photos.html b/client/templates/photos.html index c87b225..41873bc 100644 --- a/client/templates/photos.html +++ b/client/templates/photos.html @@ -14,7 +14,7 @@ <template name="photo"> <div class="photo"> <div class="title">{{date}}</div> - <img id="img-{{id}}" src="{{images.thumbnail.url}}" crossorigin="anonymous"> + <img id="img-{{id}}" src="{{proxy images.thumbnail.url}}" crossorigin="anonymous"> <canvas id="canvas-{{id}}" style="display: none;"></canvas> </div> </template> diff --git a/lib/router.js b/lib/router.js index 67be61d..ed4e2ef 100644 --- a/lib/router.js +++ b/lib/router.js @@ -5,3 +5,12 @@ Router.configure({ Router.route('/', {name: 'login'}); Router.route('/dates', {name: 'dates'}); Router.route('/photos', {name: 'photos'}); + +Router.route('/imgproxy', function () { + var self = this; + var url = 'http://scontent.cdninstagram.com' + this.request._parsedUrl.search.match(/url\=[^\&]+/)[0].split('=')[1]; + self.response.setHeader('Content-Type', 'image/jpeg'); + var res = HTTP.call('GET', url, { responseType: 'buffer' }); + self.response.write(res.content); + self.response.end(); +}, { where: 'server' }); diff --git a/server/methods.js b/server/methods.js index a177eff..d4cbaec 100644 --- a/server/methods.js +++ b/server/methods.js @@ -1,7 +1,7 @@ Meteor.methods({ getInstagramMedia: function (year, month) { this.unblock(); - return Meteor.http.call('GET', 'https://api.instagram.com/v1/users/self/media/recent', { + return HTTP.get('https://api.instagram.com/v1/users/self/media/recent', { 'params': { 'access_token': Meteor.user().services.instagram.accessToken, 'min_timestamp': Math.round(Date.UTC(month==1?year-1:year, month==1?12:month-1) / 1000), |
