-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abe1f84
commit 34128ac
Showing
11 changed files
with
344 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/config.codekit | ||
/bower_components | ||
/.idea/ | ||
/.codekit-cache/ | ||
/node_modules |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module.exports = function(grunt) { | ||
|
||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
uglify: { | ||
js: { | ||
files : { | ||
'dist/aping-plugin-codebird.min.js' : [ | ||
'src/aping-codebird-directive.js', | ||
'src/aping-codebird-helper.js', | ||
'bower_components/codebird-js/codebird.js' | ||
] | ||
} | ||
}, | ||
options: { | ||
banner: '\n/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n', | ||
} | ||
}, | ||
watch: { | ||
minifiyJs: { | ||
files: [ | ||
'src/aping-codebird-directive.js', | ||
'src/aping-codebird-helper.js', | ||
'bower_components/codebird-js/codebird.js' | ||
], | ||
tasks: ['uglify'], | ||
options: { | ||
spawn: true, | ||
} | ||
} | ||
} | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
|
||
grunt.registerTask('default', ['watch']); | ||
|
||
}; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "apiNG-plugin-codebird", | ||
"homepage": "https://github.com/JohnnyTheTank/apiNG-plugin-codebird", | ||
"authors": [ | ||
"Jonathan Hornung <[email protected]>" | ||
], | ||
"version": "0.1.0", | ||
"description": "twitter plugin for apiNG", | ||
"main": "dist/apiNG-plugin-codebird.min.js", | ||
"moduleType": [], | ||
"keywords": [ | ||
"aping", | ||
"twitter", | ||
"codebird", | ||
"angularjs", | ||
"rest", | ||
"api", | ||
"json" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"apiNG": "*", | ||
"codebird-js": "*" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
apingApp.config(['$provide', function ($provide) { | ||
|
||
$provide.constant("apingApiKeys", { | ||
twitter : "AAAAAAAAAAAAAAAAAAAAACs3iwAAAAAA%2BH8LdT7YfKIzk8fvQvqKvoePuxo%3DMKfXX2ojtacGL8aOLAhlBDUrEFpy0DUuiyebet22Wa2YVrX7cc", | ||
}); | ||
|
||
$provide.constant("apingDefaultSettings", { | ||
templateUrl : "aping_design_sample.html", | ||
items : 20, //items per request | ||
maxItems: 100, //max items per aping | ||
orderBy : "timestamp", | ||
orderReverse : "true", | ||
type: "social", | ||
}); | ||
|
||
}]); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="aping-design-sample"> | ||
<div> | ||
<div ng-repeat="item in results"> | ||
<pre>{{item | json}}</pre> | ||
</div> | ||
</div> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
angular.module('app', ['jtt_aping', 'jtt_aping_codebird']); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Codebird Demo</title> | ||
|
||
<script src="../bower_components/jquery/dist/jquery.min.js"></script> | ||
<script src="../bower_components/angular/angular.min.js"></script> | ||
<script src="../bower_components/angular-sanitize/angular-sanitize.min.js"></script> | ||
<!-- | ||
<script src="../bower_components/apiNG/dist/aping.min.js"></script> | ||
--> | ||
<script src="../bower_components/apiNG/src/aping-directive.js"></script> | ||
<script src="../bower_components/apiNG/src/aping-helpers.js"></script> | ||
<script src="../bower_components/apiNG/src/aping-inputObjects.js"></script> | ||
<script src="../bower_components/apiNG/src/aping-models.js"></script> | ||
<script src="aping-config.js"></script> | ||
<script src="app.js"></script> | ||
<script src="../bower_components/codebird-js/codebird.js"></script> | ||
<script src="../src/aping-codebird-directive.js"></script> | ||
<script src="../src/aping-codebird-helper.js"></script> | ||
</head> | ||
<body ng-app="app"> | ||
<aping type="social" aping-codebird="[{'user':'ARD_Presse', 'result_type':'recent'}]"></aping> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "aping-plugin-codebird", | ||
"version": "0.1.0", | ||
"description": "twitter plugin for apiNG", | ||
"main": "Gruntfile.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/JohnnyTheTank/apiNG-plugin-codebird.git" | ||
}, | ||
"keywords": [ | ||
"aping", | ||
"twitter", | ||
"angularjs", | ||
"rest", | ||
"api", | ||
"json", | ||
"angular" | ||
], | ||
"author": "Jonathan Hornung", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/JohnnyTheTank/apiNG-plugin-codebird/issues" | ||
}, | ||
"homepage": "https://github.com/JohnnyTheTank/apiNG-plugin-codebird#readme", | ||
"devDependencies": { | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-uglify": "^0.10.1", | ||
"grunt-contrib-watch": "^0.6.1" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use strict"; | ||
|
||
/** | ||
@author Jonathan Hornung (https://github.com/JohnnyTheTank) | ||
@url https://github.com/JohnnyTheTank/apiNG-plugin-codebird | ||
@licence MIT | ||
*/ | ||
|
||
var jjtApingCodebird = angular.module("jtt_aping_codebird", []) | ||
.directive('apingCodebird', ['apingApiKeys', 'apingCodebirdHelper', 'apingUtilityHelper', function (apingApiKeys, apingCodebirdHelper, apingUtilityHelper) { | ||
return { | ||
require: '?aping', | ||
restrict: 'A', | ||
replace: 'false', | ||
link: function (scope, element, attrs, apingController, interval) { | ||
|
||
var appSettings = apingController.getAppSettings(); | ||
|
||
var requests = apingUtilityHelper.parseJsonFromAttributes(attrs.apingCodebird, apingCodebirdHelper.getThisPlattformString()); | ||
|
||
var cb = new Codebird; | ||
cb.setBearerToken(apingApiKeys.twitter); | ||
|
||
requests.forEach(function (request) { | ||
|
||
if(request.search) { | ||
|
||
//https://dev.twitter.com/rest/reference/get/search/tweets | ||
var params = { | ||
q: request.search, | ||
result_type: request.result_type || "mixed", | ||
count:request.items || appSettings.items, | ||
}; | ||
|
||
cb.__call( | ||
"search_tweets", | ||
params, | ||
function (_data) { | ||
apingController.concatToResults(apingCodebirdHelper.getObjectByJsonData(_data, request.type)); | ||
apingController.apply(); | ||
}, | ||
true | ||
); | ||
|
||
|
||
|
||
} else if(request.user) { | ||
//https://dev.twitter.com/rest/reference/get/statuses/user_timeline | ||
var params = { | ||
screen_name: request.user, | ||
contributor_details: true, | ||
count: request.items || appSettings.items | ||
}; | ||
cb.__call( | ||
"statuses_userTimeline", | ||
params, | ||
function (_data, rate, err) { | ||
apingController.concatToResults(apingCodebirdHelper.getObjectByJsonData(_data, request.type)); | ||
apingController.apply(); | ||
}, | ||
true | ||
); | ||
} else { | ||
return false; | ||
} | ||
|
||
}); | ||
} | ||
} | ||
}]); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
"use strict"; | ||
|
||
/** | ||
@author Jonathan Hornung (https://github.com/JohnnyTheTank) | ||
@url https://github.com/JohnnyTheTank/apiNG-plugin-codebird | ||
@licence MIT | ||
*/ | ||
|
||
jjtApingCodebird.service('apingCodebirdHelper', ['apingModels', 'apingTimeHelper', 'apingUtilityHelper', function (apingModels, apingTimeHelper, apingUtilityHelper) { | ||
this.getThisPlattformString = function () { | ||
return "twitter"; | ||
}; | ||
|
||
this.getThisPlattformLink = function () { | ||
return "https://twitter.com/"; | ||
}; | ||
this.getBigImageUrlFromSmallImageUrl = function (_smallImageUrl) { | ||
return _smallImageUrl.replace("_normal", ""); | ||
}; | ||
this.getImageUrlFromMediaObject = function (_item) { | ||
if(_item) { | ||
if(_item.media_url_https) { | ||
return this.getBigImageUrlFromSmallImageUrl(_item.media_url_https); | ||
} | ||
if(_item.media_url) { | ||
return this.getBigImageUrlFromSmallImageUrl(_item.media_url); | ||
} | ||
} | ||
return false; | ||
}; | ||
this.getImageUrlFromUserObject = function (_item) { | ||
if(_item) { | ||
if(_item.profile_image_url_https) { | ||
return this.getBigImageUrlFromSmallImageUrl(_item.profile_image_url_https); | ||
} | ||
if(_item.profile_image_url) { | ||
return this.getBigImageUrlFromSmallImageUrl(_item.profile_image_url); | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
this.getObjectByJsonData = function (_data, _type) { | ||
|
||
var requestResults = []; | ||
if (_data) { | ||
var _this = this; | ||
|
||
if (_data.statuses) { | ||
|
||
angular.forEach(_data.statuses, function (value, key) { | ||
requestResults.push(_this.getItemByJsonData(value, _type)); | ||
}); | ||
} else if (_data.length > 0) { | ||
angular.forEach(_data, function (value, key) { | ||
requestResults.push(_this.getItemByJsonData(value, _type)); | ||
}); | ||
} | ||
|
||
} | ||
|
||
return requestResults; | ||
}; | ||
|
||
this.getItemByJsonData = function (_item, _type) { | ||
var returnObject = {}; | ||
if (_item && _type) { | ||
switch (_type) { | ||
case "social": | ||
returnObject = this.getSocialItemByJsonData(_item); | ||
break; | ||
} | ||
} | ||
return returnObject; | ||
}; | ||
|
||
this.getSocialItemByJsonData = function (_item) { | ||
var socialObject = apingModels.getNew("social", this.getThisPlattformString()); | ||
|
||
$.extend(true, socialObject, { | ||
blog_name: _item.user.screen_name, | ||
blog_id: _item.user.id_str, | ||
blog_link: this.getThisPlattformLink() + _item.user.screen_name + "/", | ||
intern_id: _item.id_str, | ||
timestamp: new Date(Date.parse(_item.created_at.replace(/( \+)/, ' UTC$1'))).getTime(), | ||
text: _item.text, | ||
shares: _item.retweet_count, | ||
likes: _item.favorite_count, | ||
}); | ||
|
||
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) { | ||
socialObject.type = "image"; | ||
} else { | ||
socialObject.type = "tweet"; | ||
if(_item.user) { | ||
socialObject.img_url = this.getImageUrlFromUserObject(_item.user); | ||
} | ||
} | ||
|
||
socialObject.post_url = socialObject.blog_link+"status/"+socialObject.intern_id; | ||
|
||
return socialObject; | ||
}; | ||
|
||
}]); |