Skip to content

Commit

Permalink
feat: added new functionality to parse first image in content to soci…
Browse files Browse the repository at this point in the history
…al models' img_url (close #2)
  • Loading branch information
JohnnyTheTank committed Jan 3, 2016
1 parent 2591668 commit ee3cfeb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Jonathan Hornung <jonathan.hornung@gmail.com>"
],
"version": "0.6.0",
"version": "0.6.1",
"description": "rss plugin for apiNG",
"main": "dist/apiNG-plugin-rss.min.js",
"moduleType": [],
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
items="5"
order-by="caption"
order-reverse="false"
aping-rss="[{'path':'http://rss.nytimes.com/services/xml/rss/nyt/Science.xml'}]">
aping-rss="[{'path':'http://feeds.feedburner.com/Angular-jsDirectives?utm_source=angular-js.in&utm_medium=website&utm_campaign=content-curation'}]">
</aping>
<hr>
<aping
Expand Down
4 changes: 2 additions & 2 deletions dist/aping-plugin-rss.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aping-plugin-rss",
"version": "0.6.0",
"version": "0.6.1",
"description": "RSS plugin for apiNG",
"main": "Gruntfile.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/aping-rss-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var jjtApingRss = angular.module("jtt_aping_rss", [])

var appSettings = apingController.getAppSettings();

var requests = apingUtilityHelper.parseJsonFromAttributes(attrs.apingRss, apingRssHelper.getThisPlattformString(), appSettings);
var requests = apingUtilityHelper.parseJsonFromAttributes(attrs.apingRss, apingRssHelper.getThisPlatformString(), appSettings);

requests.forEach(function (request) {

Expand Down
10 changes: 8 additions & 2 deletions src/aping-rss-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

jjtApingRss.service('apingRssHelper', ['apingModels', 'apingTimeHelper', 'apingUtilityHelper', function (apingModels, apingTimeHelper, apingUtilityHelper) {
this.getThisPlattformString = function () {
this.getThisPlatformString = function () {
return "rss";
};

Expand Down Expand Up @@ -59,7 +59,7 @@ jjtApingRss.service('apingRssHelper', ['apingModels', 'apingTimeHelper', 'apingU
};

this.getSocialItemByJsonData = function (_item) {
var socialObject = apingModels.getNew("social", this.getThisPlattformString());
var socialObject = apingModels.getNew("social", this.getThisPlatformString());

//fill _item in socialObject
$.extend(true, socialObject, {
Expand All @@ -76,6 +76,12 @@ jjtApingRss.service('apingRssHelper', ['apingModels', 'apingTimeHelper', 'apingU
socialObject.text = _item.title || undefined;
}

if(_item.content) {
var imagesArray = apingUtilityHelper.getFirstImageFromHtml(_item.content);
if(imagesArray.length>1) {
socialObject.img_url = imagesArray[1];
}
}

socialObject.date_time = _item.publishedDate ? new Date(_item.publishedDate) : undefined;
socialObject.timestamp = socialObject.date_time ? socialObject.date_time.getTime() : undefined;
Expand Down

0 comments on commit ee3cfeb

Please sign in to comment.