Skip to content

Commit

Permalink
Merge pull request christianvuerings#148 from arminrosu/service/linkedin
Browse files Browse the repository at this point in the history
LinkedIn Support
  • Loading branch information
christianvuerings committed Sep 16, 2013
2 parents 2d8f398 + 2ee2657 commit b4dd48d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Currently supports the following feeds:
* [Iusethis](http://osx.iusethis.com/)
* [Last.fm](http://last.fm)
* [LibraryThing.com](http://librarything.com)
* [Linkedin.com](http://linkedin.com) (via [Network Updates RSS feed](http://www.linkedin.com/rssAdmin?display=&trk=uscp_rss))
* [Mendeley](http://mendeley.com)
* [Miso](http://gomiso.com)
* [Mlkshk](http://mlkshk.com)
Expand Down Expand Up @@ -203,13 +204,14 @@ Have a look at [this commit](https://github.com/christianv/jquery-lifestream/com
* Put all `var` statements in the beginning of a function
* Use === & !== for comparing variables
* Use the following spacing rules:

``` javascript
for (var i = 0, j = length; i < j; i++) {
```
* Use jshint on you files. `.jshintrc` contains the necessary configuration
* Use jshint on your files. `.jshintrc` contains the necessary configuration
## Ideas
Stuff that isn"t implemented yet, but would be nice to have:
Stuff that isn't implemented yet, but would be nice to have:
* Add support for [Twitter Web Intents](http://dev.twitter.com/pages/intents)
Expand Down
Binary file added src/favicons/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions src/services/linkedin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
(function($) {
'use strict';

$.fn.lifestream.feeds.linkedin = function( config, callback ) {

var template = $.extend({},
{
'posted': '<a href="${link}">${title}</a>'
}, config.template),
jsonpCallbackName = 'jlsLinkedinCallback' + config.user,

createYql = function(){
var query = 'SELECT * FROM feed WHERE url="' + config.url + '"';

// I bet some will not read the instructions
if(config.user) {
query += ' AND link LIKE "%' + config.user + '%"';
}

return query;
},

parseLinkedinItem = function(item) {
return {
'date': new Date(item.pubDate),
'config': config,
'html': $.tmpl(template.posted, item)
};
};

// !!! Global function for jsonp callback
window[jsonpCallbackName] = function(input) {
var output = [], i = 0;

if(input.query && input.query.count && input.query.count > 0) {
if (input.query.count === 1) {
output.push(parseLinkedinItem(input.query.results.item));
} else {
for(i; i < input.query.count; i++) {
var item = input.query.results.item[i];
output.push(parseLinkedinItem(item));
}
}
}

callback(output);
};

$.ajax({
'url': $.fn.lifestream.createYqlUrl(createYql()),
'cache': true,
'data': {
// YQL will cache this for 5 minutes
'_maxage': 300
},
'dataType': 'jsonp',
// let YQL cache
'jsonpCallback': jsonpCallbackName
});

// Expose the template.
// We use this to check which templates are available
return {
'template': template
};
};
})(jQuery);

0 comments on commit b4dd48d

Please sign in to comment.