Last active
July 27, 2016 21:18
-
-
Save elchele/c1e22cd5784f68d2a8587579c3228a84 to your computer and use it in GitHub Desktop.
Adjustment to controller for News dashlet to switch from using Google API to Google News RSS feed. Google API was retired and no longer functional.
This file contains hidden or 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
({ | |
/* File: ./custom/clients/base/views/news/news.js | |
* | |
* Date: July 27, 2016 | |
* | |
* Author: Angel Magaña | |
* | |
* Description: Adjustment to News dashlet to use RSS instead of retired Google API | |
* | |
*/ | |
extendsFrom: 'NewsView', | |
loadData: function (options) { | |
var self = this; | |
if(_.isUndefined(this.model)){ | |
return; | |
} | |
var name = this.model.get("account_name") || this.model.get('name') || this.model.get('full_name'), | |
limit = parseInt(this.settings.get('limit') || 5, 10); | |
if (_.isEmpty(name)) { | |
return; | |
} | |
//Need to clean up spaces | |
name = name.replace(/ /g, '+'); | |
var url = encodeURIComponent('https://news.google.com/news/section?q=' + name + '&output=rss'); | |
app.api.call('GET', app.api.buildURL('rssfeed?feed_url=' + url), {}, { | |
success: function(data){ | |
_.extend(self, data); | |
self.render(); | |
} | |
}); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment