Created
April 4, 2017 22:48
-
-
Save elchele/82cf5708d8f89eef66fea31ff7f9824d to your computer and use it in GitHub Desktop.
Google News dashlet for Sugar 7.8+
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
<?php | |
/* File: ./custom/Extension/application/Ext/Language/en_us.news.lang.ext.php */ | |
$app_strings['LBL_DASHLET_NEWS_NAME'] = 'Google News'; | |
$app_strings['LBL_DASHLET_NEWS_DESC'] = 'Google News search results for the current Account record.'; | |
?> |
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
({ | |
/* File: ./custom/clients/base/views/news/news.js | |
* | |
* Date: April 4, 2017 | |
* | |
* Author: Angel Magaña | |
* | |
* Description: Adjustment to News dashlet to use RSS instead of retired Google API | |
* | |
*/ | |
plugins: ['Dashlet'], | |
initDashlet: function() { | |
this.model.on("change:name", this.loadData, this); | |
}, | |
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(); | |
} | |
}); | |
} | |
}) |
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
<?php | |
/* File: ./custom/clients/base/views/news/news.php */ | |
$viewdefs['base']['view']['news'] = array( | |
'dashlets' => array( | |
array( | |
'label' => 'LBL_DASHLET_NEWS_NAME', | |
'description' => 'LBL_DASHLET_NEWS_DESC', | |
'config' => array( | |
), | |
'preview' => array( | |
), | |
'filter' => array( | |
'module' => array( | |
'Accounts', | |
), | |
'view' => 'record' | |
), | |
), | |
), | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment