Skip to content

Commit

Permalink
small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Jan 10, 2016
1 parent de935e9 commit a7a8e1f
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Jonathan Hornung
Copyright (c) 2016 Jonathan Hornung

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var app = angular.module('app', ['jtt_aping', 'jtt_aping_codebird']);
```

### IV. Add the plugin
Add the plugin's directive `aping-codebird="[]"` to your apiNG directive and configure your requests [configure your requests](#ii-requests)
Add the plugin's directive `aping-codebird="[]"` to your apiNG directive and [configure your requests](#ii-requests)
```html
<aping
template-url="templates/social.html"
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"authors": [
"Jonathan Hornung <[email protected]>"
],
"version": "0.7.0",
"description": "twitter plugin for apiNG",
"version": "0.7.5",
"description": "Twitter plugin for apiNG",
"main": "dist/aping-plugin-codebird.min.js",
"moduleType": [],
"keywords": [
Expand Down
82 changes: 41 additions & 41 deletions dist/aping-plugin-codebird.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
@name: aping-plugin-codebird
@version: 0.7.0 (09-01-2016)
@author: Jonathan Hornung
@url: https://github.com/JohnnyTheTank/apiNG-plugin-codebird#readme
@version: 0.7.5 (10-01-2016)
@author: Jonathan Hornung <[email protected]>
@url: https://github.com/JohnnyTheTank/apiNG-plugin-codebird
@license: MIT
*/
"use strict";
Expand All @@ -28,46 +28,46 @@ var jjtApingCodebird = angular.module("jtt_aping_codebird", [])
//create helperObject for helper function call
var helperObject = {
model: appSettings.model,
showAvatar : request.showAvatar || false,
showAvatar: request.showAvatar || false,
};
if(typeof appSettings.getNativeData !== "undefined") {
if (typeof appSettings.getNativeData !== "undefined") {
helperObject.getNativeData = appSettings.getNativeData;
} else {
helperObject.getNativeData = false;
}

//create requestObject for api request call
var requestObject = {};
if(typeof request.items !== "undefined") {
if (typeof request.items !== "undefined") {
requestObject.count = request.items;
} else {
requestObject.count = appSettings.items;
}

if(requestObject.count == 0) {
if (requestObject.count == 0) {
return false;
}

// -1 is "no explicit limit". same for NaN value
if(requestObject.count < 0 || isNaN(requestObject.count)) {
if (requestObject.count < 0 || isNaN(requestObject.count)) {
requestObject.count = undefined;
}

// the api has a limit of 100 items per request
if(requestObject.count > 100) {
if (requestObject.count > 100) {
requestObject.count = 100;
}

if(request.search) {
if (request.search) {
// https://dev.twitter.com/rest/reference/get/search/tweets
requestObject.q = request.search;
requestObject.result_type = request.result_type || "mixed";

if(typeof request.lat !== "undefined" && typeof request.lng !== "undefined") {
requestObject.geocode = request.lat+","+request.lng+","+(request.distance || "1" )+"km";
if (typeof request.lat !== "undefined" && typeof request.lng !== "undefined") {
requestObject.geocode = request.lat + "," + request.lng + "," + (request.distance || "1" ) + "km";
}

if(typeof request.language !== "undefined") {
if (typeof request.language !== "undefined") {
requestObject.lang = request.language;
}

Expand All @@ -81,17 +81,17 @@ var jjtApingCodebird = angular.module("jtt_aping_codebird", [])
true
);

} else if(request.user) {
} else if (request.user) {
// https://dev.twitter.com/rest/reference/get/statuses/user_timeline

requestObject.screen_name = request.user;
requestObject.contributor_details = true;

if(request.exclude_replies === true || request.exclude_replies === "true"){
if (request.exclude_replies === true || request.exclude_replies === "true") {
requestObject.exclude_replies = true;
}

if(request.include_rts === false || request.include_rts === "false"){
if (request.include_rts === false || request.include_rts === "false") {
requestObject.include_rts = false;
}

Expand Down Expand Up @@ -124,22 +124,22 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper
return _smallImageUrl.replace("_normal", "");
};
this.getImageUrlFromMediaObject = function (_item) {
if(_item) {
if(_item.media_url_https) {
if (_item) {
if (_item.media_url_https) {
return this.getBigImageUrlFromSmallImageUrl(_item.media_url_https);
}
if(_item.media_url) {
if (_item.media_url) {
return this.getBigImageUrlFromSmallImageUrl(_item.media_url);
}
}
return undefined;
};
this.getImageUrlFromUserObject = function (_item) {
if(_item) {
if(_item.profile_image_url_https) {
if (_item) {
if (_item.profile_image_url_https) {
return this.getBigImageUrlFromSmallImageUrl(_item.profile_image_url_https);
}
if(_item.profile_image_url) {
if (_item.profile_image_url) {
return this.getBigImageUrlFromSmallImageUrl(_item.profile_image_url);
}
}
Expand All @@ -161,25 +161,25 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper

var baseUrl = this.getImageUrlFromMediaObject(_item);

if(_item.sizes) {
if(typeof _item.sizes['small'] !== "undefined") {
returnObject.thumb_url = baseUrl+":small";
if (_item.sizes) {
if (typeof _item.sizes['small'] !== "undefined") {
returnObject.thumb_url = baseUrl + ":small";
returnObject.thumb_width = _item.sizes['small'].w || undefined;
returnObject.thumb_height = _item.sizes['small'].h || undefined;
} else {
returnObject.thumb_url = baseUrl;
}

if(typeof _item.sizes['medium'] !== "undefined") {
returnObject.img_url = baseUrl+":medium";
if (typeof _item.sizes['medium'] !== "undefined") {
returnObject.img_url = baseUrl + ":medium";
returnObject.img_width = _item.sizes['medium'].w || undefined;
returnObject.img_height = _item.sizes['medium'].h || undefined;
} else {
returnObject.img_url = baseUrl;
}

if(typeof _item.sizes['large'] !== "undefined") {
returnObject.native_url = baseUrl+":large";
if (typeof _item.sizes['large'] !== "undefined") {
returnObject.native_url = baseUrl + ":large";
returnObject.native_width = _item.sizes['large'].w || undefined;
returnObject.native_height = _item.sizes['large'].h || undefined;
} else {
Expand All @@ -200,14 +200,14 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper

angular.forEach(_data.statuses, function (value, key) {
var tempResult = _this.getItemByJsonData(value, _helperObject);
if(tempResult) {
if (tempResult) {
requestResults.push(tempResult);
}
});
} else if (_data.length > 0) {
angular.forEach(_data, function (value, key) {
var tempResult = _this.getItemByJsonData(value, _helperObject);
if(tempResult) {
if (tempResult) {
requestResults.push(tempResult);
}
});
Expand All @@ -222,7 +222,7 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper
var returnObject = {};
if (_item && _helperObject.model) {

if(_helperObject.getNativeData === true || _helperObject.getNativeData === "true") {
if (_helperObject.getNativeData === true || _helperObject.getNativeData === "true") {
returnObject = this.getNativeItemByJsonData(_item, _helperObject.model);
} else {
switch (_helperObject.model) {
Expand Down Expand Up @@ -258,21 +258,21 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper

socialObject.date_time = new Date(socialObject.timestamp);

if(_item.entities && _item.entities.media && _item.entities.media.length>0) {
if (_item.entities && _item.entities.media && _item.entities.media.length > 0) {
socialObject.source = _item.entities.media;
socialObject.img_url = this.getImageUrlFromMediaObject(_item.entities.media[0]);
}

if(socialObject.img_url) {
if (socialObject.img_url) {
socialObject.type = "image";
} else {
socialObject.type = "tweet";
if(_item.user && (_helperObject.showAvatar === true || _helperObject.showAvatar === 'true' ) ) {
if (_item.user && (_helperObject.showAvatar === true || _helperObject.showAvatar === 'true' )) {
socialObject.img_url = this.getImageUrlFromUserObject(_item.user);
}
}

socialObject.post_url = socialObject.blog_link+"status/"+socialObject.intern_id;
socialObject.post_url = socialObject.blog_link + "status/" + socialObject.intern_id;

return socialObject;
};
Expand All @@ -293,23 +293,23 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper

imageObject.date_time = new Date(imageObject.timestamp);

if(_item.entities && _item.entities.media && _item.entities.media.length>0) {
if (_item.entities && _item.entities.media && _item.entities.media.length > 0) {

imageObject.source = _item.entities.media;

var tempImageArray = this.getImagesObjectFromMediaObject(_item.entities.media[0]);
$.extend(true, imageObject, tempImageArray);

if(!imageObject.img_url) {
if (!imageObject.img_url) {
imageObject.img_url = this.getImageUrlFromMediaObject(_item.entities.media[0]);
}
}

if(!imageObject.img_url) {
if (!imageObject.img_url) {
return false;
}

imageObject.post_url = imageObject.blog_link+"status/"+imageObject.intern_id;
imageObject.post_url = imageObject.blog_link + "status/" + imageObject.intern_id;

return imageObject;
};
Expand All @@ -320,7 +320,7 @@ jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper

switch (_model) {
case "image":
if(!_item.entities || !_item.entities.media || !_item.entities.media.length>0 || !this.getImageUrlFromMediaObject(_item.entities.media[0])) {
if (!_item.entities || !_item.entities.media || !_item.entities.media.length > 0 || !this.getImageUrlFromMediaObject(_item.entities.media[0])) {
return false;
} else {
nativeItem = _item;
Expand Down
6 changes: 3 additions & 3 deletions dist/aping-plugin-codebird.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aping-plugin-codebird",
"version": "0.7.0",
"description": "twitter plugin for apiNG",
"version": "0.7.5",
"description": "Twitter plugin for apiNG",
"main": "dist/aping-plugin-codebird.min.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -19,12 +19,12 @@
"json",
"angular"
],
"author": "Jonathan Hornung",
"author": "Jonathan Hornung <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/JohnnyTheTank/apiNG-plugin-codebird/issues"
},
"homepage": "https://github.com/JohnnyTheTank/apiNG-plugin-codebird#readme",
"homepage": "https://github.com/JohnnyTheTank/apiNG-plugin-codebird",
"devDependencies": {
"codebird": "*",
"grunt": "^0.4.5",
Expand Down
26 changes: 13 additions & 13 deletions src/aping-codebird-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,46 +21,46 @@ var jjtApingCodebird = angular.module("jtt_aping_codebird", [])
//create helperObject for helper function call
var helperObject = {
model: appSettings.model,
showAvatar : request.showAvatar || false,
showAvatar: request.showAvatar || false,
};
if(typeof appSettings.getNativeData !== "undefined") {
if (typeof appSettings.getNativeData !== "undefined") {
helperObject.getNativeData = appSettings.getNativeData;
} else {
helperObject.getNativeData = false;
}

//create requestObject for api request call
var requestObject = {};
if(typeof request.items !== "undefined") {
if (typeof request.items !== "undefined") {
requestObject.count = request.items;
} else {
requestObject.count = appSettings.items;
}

if(requestObject.count == 0) {
if (requestObject.count == 0) {
return false;
}

// -1 is "no explicit limit". same for NaN value
if(requestObject.count < 0 || isNaN(requestObject.count)) {
if (requestObject.count < 0 || isNaN(requestObject.count)) {
requestObject.count = undefined;
}

// the api has a limit of 100 items per request
if(requestObject.count > 100) {
if (requestObject.count > 100) {
requestObject.count = 100;
}

if(request.search) {
if (request.search) {
// https://dev.twitter.com/rest/reference/get/search/tweets
requestObject.q = request.search;
requestObject.result_type = request.result_type || "mixed";

if(typeof request.lat !== "undefined" && typeof request.lng !== "undefined") {
requestObject.geocode = request.lat+","+request.lng+","+(request.distance || "1" )+"km";
if (typeof request.lat !== "undefined" && typeof request.lng !== "undefined") {
requestObject.geocode = request.lat + "," + request.lng + "," + (request.distance || "1" ) + "km";
}

if(typeof request.language !== "undefined") {
if (typeof request.language !== "undefined") {
requestObject.lang = request.language;
}

Expand All @@ -74,17 +74,17 @@ var jjtApingCodebird = angular.module("jtt_aping_codebird", [])
true
);

} else if(request.user) {
} else if (request.user) {
// https://dev.twitter.com/rest/reference/get/statuses/user_timeline

requestObject.screen_name = request.user;
requestObject.contributor_details = true;

if(request.exclude_replies === true || request.exclude_replies === "true"){
if (request.exclude_replies === true || request.exclude_replies === "true") {
requestObject.exclude_replies = true;
}

if(request.include_rts === false || request.include_rts === "false"){
if (request.include_rts === false || request.include_rts === "false") {
requestObject.include_rts = false;
}

Expand Down
Loading

0 comments on commit a7a8e1f

Please sign in to comment.