forked from christianvuerings/jquery-lifestream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.lifestream.min.js
2 lines (2 loc) · 33.8 KB
/
jquery.lifestream.min.js
1
2
(function(e){"use strict";e.fn.lifestream=function(t){return this.each(function(){var r=e(this),a=jQuery.extend({classname:"lifestream",feedloaded:null,limit:10,list:[]},t),n={count:a.list.length,items:[]},s=jQuery.extend(!0,{},a),o=function(t){e.merge(n.items,t),n.items.sort(function(e,t){return t.date-e.date});for(var s,o=n.items,u=o.length<a.limit?o.length:a.limit,l=0,i=e('<ul class="'+a.classname+'"/>');u>l;l++)s=o[l],s.html&&e('<li class="'+a.classname+"-"+s.config.service+'">').data("name",s.config.service).data("url",s.url||"#").data("time",s.date).append(s.html).appendTo(i);r.html(i),e.isFunction(a.feedloaded)&&a.feedloaded()},u=function(){var t=0,r=a.list.length;for(delete s.list;r>t;t++){var n=a.list[t];e.fn.lifestream.feeds[n.service]&&e.isFunction(e.fn.lifestream.feeds[n.service])&&n.user&&(n._settings=s,e.fn.lifestream.feeds[n.service](n,o))}};jQuery.tmpl?u():jQuery.getScript("//ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js",u)})},e.fn.lifestream.createYqlUrl=function(e){return"//query.yahooapis.com/v1/public/yql?q=__QUERY__&env=store://datatables.org/alltableswithkeys&format=json".replace("__QUERY__",encodeURIComponent(e))},e.fn.lifestream.feeds=e.fn.lifestream.feeds||{},Object.keys||(Object.keys=function(e){if(e!==Object(e))throw new TypeError("Object.keys called on non-object");var t,r=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.push(t);return r})})(jQuery),function(e){e.fn.lifestream.feeds.bitbucket=function(t,r){var a=e.extend({},{commit:'<a href="http://bitbucket.org/${owner}/${name}/changeset/${node}/">committed</a> at <a href="http://bitbucket.org/${owner}/${name}/">${owner}/${name}</a>',pullrequest_fulfilled:'fulfilled a pull request at <a href="http://bitbucket.org/${owner}/${name}/">${owner}/${name}</a>',pullrequest_rejected:'rejected a pull request at <a href="http://bitbucket.org/${owner}/${name}/">${owner}/${name}</a>',pullrequest_created:'created a pull request at <a href="http://bitbucket.org/${owner}/${name}/">${owner}/${name}</a>',create:'created a new project at <a href="http://bitbucket.org/${owner}/${name}/">${owner}/${name}</a>',fork:'forked <a href="http://bitbucket.org/${owner}/${name}/">${owner}/${name}</a>'},t.template),n=["commit","pullrequest_fulfilled","pullrequest_rejected","pullrequest_created","create","fork"],s=function(t){return-1!==e.inArray(t.event,n)&&t.repository?"commit"===t.event?e.tmpl(a.commit,{owner:t.repository.owner,name:t.repository.name,node:t.node}):e.tmpl(a[t.event],{owner:t.repository.owner,name:t.repository.name}):void 0},o=function(r){var a=[];return r.query&&r.query.count&&r.query.count>0&&e.each(r.query.results.json,function(){a.push({date:new Date(this.events.created_on.replace(/-/g,"/")),config:t,html:s(this.events)})}),a};return e.ajax({url:e.fn.lifestream.createYqlUrl('select events.event,events.node, events.created_on,events.repository.name, events.repository.owner from json where url = "https://api.bitbucket.org/1.0/users/'+t.user+'/events/"'),dataType:"jsonp",success:function(e){r(o(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.bitly=function(t,r){var a=e.extend({},{created:'created URL <a href="${short_url}" title="${title}">${short_url}</a>'},t.template);return e.ajax({url:e.fn.lifestream.createYqlUrl('select data.short_url, data.created, data.title from json where url="//bitly.com/u/'+t.user+'.json"'),dataType:"jsonp",success:function(n){var s,o=[],u=0;if(n.query&&n.query.count&&n.query.results.json)for(list=n.query.results.json,s=list.length;s>u;u++){var l=list[u].data;o.push({date:new Date(1e3*l.created),config:t,html:e.tmpl(a.created,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.blogger=function(t,r){var a=e.extend({},{posted:'posted <a href="${origLink}">${title}</a>'},t.template),n=function(r){var n,s,o,u,l,i=[],c=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.feed.entry)for(n=r.query.results.feed.entry,s=n.length;s>c;c++){if(o=n[c],!o.origLink)for(u=0,l=o.link.length;l>u;u++)"alternate"===o.link[u].rel&&(o.origLink=o.link[u].href);o.origLink&&(o.title.content&&(o.title=o.title.content),i.push({date:new Date(o.published),config:t,html:e.tmpl(a.posted,o)}))}return i};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//'+t.user+'.blogspot.com/feeds/posts/default"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.citeulike=function(t,r){var a=e.extend({},{saved:'saved <a href="${href}">${title}</a> by ${authors}'},t.template),n=function(r){var n,s=[],o=0;if(r&&r.length&&r.length>0)for(n=r.length;n>o;o++){var u=r[o];s.push({date:new Date(u.date),config:t,url:"//www.citeulike.org/user/"+t.user,html:e.tmpl(a.saved,u)})}return s};return e.ajax({url:"//www.citeulike.org/json/user/"+t.user,dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.dailymotion=function(t,r){var a=e.extend({},{uploaded:'uploaded a video <a href="${link}">${title[0]}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.uploaded,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.dailymotion.com/rss/user/'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.delicious=function(t,r){var a=e.extend({},{bookmarked:'bookmarked <a href="${u}">${d}</a>'},t.template);return e.ajax({url:"//feeds.delicious.com/v2/json/"+t.user,dataType:"jsonp",success:function(n){var s,o=[],u=0;if(n&&n.length&&n.length>0)for(s=n.length;s>u;u++){var l=n[u];o.push({date:new Date(l.dt),config:t,html:e.tmpl(a.bookmarked,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.deviantart=function(t,r){var a=e.extend({},{posted:'posted <a href="${link}">${title}</a>'},t.template);return e.ajax({url:e.fn.lifestream.createYqlUrl('select title,link,pubDate from rss where url="//backend.deviantart.com/rss.xml?q=gallery%3A'+encodeURIComponent(t.user)+"&type=deviation"+'" | unique(field="title")'),dataType:"jsonp",success:function(n){var s,o,u,l=[],i=0;if(n.query&&n.query.count>0)for(s=n.query.results.item,u=s.length;u>i;i++)o=s[i],l.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.posted,o)});r(l)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.disqus=function(t,r){var a=e.extend({},{post:'commented on <a href="${url}">${thread.title}</a>',thread_like:'liked <a href="${url}">${thread.title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r)for(n=r.length;n>u;u++)s=r[u],"reply"!==s.type&&o.push({date:new Date(s.createdAt),config:t,html:e.tmpl(a[s.type],s.object)});return o};return e.ajax({url:"https://disqus.com/api/3.0/users/listActivity.json",data:{user:t.user,api_key:t.key},dataType:"jsonp",success:function(e){return 2===e.code?(r([]),console&&console.error&&console.error("Error loading Disqus stream.",e.response),void 0):(r(n(e.response)),void 0)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.dribbble=function(t,r){var a=e.extend({},{posted:'posted a shot <a href="${url}">${title}</a>'},t.template);return e.ajax({url:"//api.dribbble.com/players/"+t.user+"/shots",dataType:"jsonp",success:function(n){var s,o=[],u=0;if(n&&n.total)for(s=n.shots.length;s>u;u++){var l=n.shots[u];o.push({date:new Date(l.created_at),config:t,html:e.tmpl(a.posted,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.facebook_page=function(t,r){var a=e.extend({},{wall_post:'post on wall <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.rss.channel.item,s=n.length;s>u;u++){var l=n[u];e.trim(l.title)&&o.push({date:new Date(l.pubDate),config:t,html:e.tmpl(a.wall_post,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="www.facebook.com/feeds/page.php?id='+t.user+'&format=rss20"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.flickr=function(t,r){var a=e.extend({},{posted:'posted a photo <a href="${link}">${title}</a>'},t.template);return e.ajax({url:"//api.flickr.com/services/feeds/photos_public.gne?id="+t.user+"&lang=en-us&format=json",dataType:"jsonp",jsonp:"jsoncallback",success:function(n){var s,o=[],u=0;if(n&&n.items&&n.items.length>0)for(s=n.items.length;s>u;u++){var l=n.items[u];o.push({date:new Date(l.published),config:t,html:e.tmpl(a.posted,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.foomark=function(t,r){var a=e.extend({},{bookmarked:'bookmarked <a href="${url}">${url}</a>'},t.template);return e.ajax({url:"//api.foomark.com/urls/list/",data:{format:"jsonp",username:t.user},dataType:"jsonp",success:function(n){var s,o=[],u=0;if(n&&n.length&&n.length>0)for(s=n.length;s>u;u++){var l=n[u];o.push({date:new Date(l.created_at.replace(/-/g,"/")),config:t,html:e.tmpl(a.bookmarked,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.formspring=function(t,r){var a=e.extend({},{answered:'answered a question <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.answered,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.formspring.me/profile/'+t.user+'.rss"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.forrst=function(t,r){var a=e.extend({},{posted:'posted a ${post_type} <a href="${post_url}">${title}</a>'},t.template);return e.ajax({url:"//forrst.com/api/v2/users/posts?username="+t.user,dataType:"jsonp",success:function(n){var s,o=[],u=0;if(n&&n.resp.length&&n.resp.length>0)for(s=n.resp.length;s>u;u++){var l=n.resp[u];o.push({date:new Date(l.created_at.replace(" ","T")),config:t,html:e.tmpl(a.posted,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.foursquare=function(t,r){var a=e.extend({},{checkedin:'checked in @ <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s=[],o=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.count;n>o;o++){var u=r.query.results.item[o];s.push({date:new Date(u.pubDate),config:t,html:e.tmpl(a.checkedin,u)})}return s};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from rss where url="https://feeds.foursquare.com/history/'+t.user+'.rss"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.gimmebar=function(t,r){var a=e.extend({},{bookmarked:'bookmarked <a href="${short_url}">${title}</a>'},t.template);return e.ajax({url:"https://gimmebar.com/api/v0/public/assets/"+t.user+".json?jsonp_callback=?",dataType:"json",success:function(n){n=n.records;var s,o=[],u=0;if(n&&n.length&&n.length>0)for(s=n.length;s>u;u++){var l=n[u];o.push({date:new Date(1e3*l.date),config:t,html:e.tmpl(a.bookmarked,l)})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.github=function(t,r){var a=e.extend({},{commitCommentEvent:'commented on <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',createBranchEvent:'created branch <a href="http://github.com/${status.repo.name}/tree/${status.payload.ref}">${status.payload.ref}</a> at <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',createRepositoryEvent:'created repository <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',createTagEvent:'created tag <a href="http://github.com/${status.repo.name}/tree/${status.payload.ref}">${status.payload.ref}</a> at <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',deleteBranchEvent:'deleted branch ${status.payload.ref} at <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',deleteTagEvent:'deleted tag ${status.payload.ref} at <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',followEvent:'started following <a href="http://github.com/${status.payload.target.login}">${status.payload.target.login}</a>',forkEvent:'forked <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',gistEvent:'${status.payload.action} gist <a href="http://gist.github.com/${status.payload.gist.id}">${status.payload.gist.id}</a>',issueCommentEvent:'commented on issue <a href="http://github.com/${status.repo.name}/issues/${status.payload.issue.number}">${status.payload.issue.number}</a> on <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',issuesEvent:'${status.payload.action} issue <a href="http://github.com/${status.repo.name}/issues/${status.payload.issue.number}">${status.payload.issue.number}</a> on <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',pullRequestEvent:'${status.payload.action} pull request <a href="http://github.com/${status.repo.name}/pull/${status.payload.number}">${status.payload.number}</a> on <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',pushEvent:'pushed to <a href="http://github.com/${status.repo.name}/tree/${status.payload.ref}">${status.payload.ref}</a> at <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>',watchEvent:'started watching <a href="http://github.com/${status.repo.name}">${status.repo.name}</a>'},t.template),n=function(t){return"CommitCommentEvent"===t.type?e.tmpl(a.commitCommentEvent,{status:t}):"CreateEvent"===t.type&&"branch"===t.payload.ref_type?e.tmpl(a.createBranchEvent,{status:t}):"CreateEvent"===t.type&&"repository"===t.payload.ref_type?e.tmpl(a.createRepositoryEvent,{status:t}):"CreateEvent"===t.type&&"tag"===t.payload.ref_type?e.tmpl(a.createTagEvent,{status:t}):"DeleteEvent"===t.type&&"branch"===t.payload.ref_type?e.tmpl(a.deleteBranchEvent,{status:t}):"DeleteEvent"===t.type&&"tag"===t.payload.ref_type?e.tmpl(a.deleteTagEvent,{status:t}):"FollowEvent"===t.type?e.tmpl(a.followEvent,{status:t}):"ForkEvent"===t.type?e.tmpl(a.forkEvent,{status:t}):"GistEvent"===t.type?("create"===t.payload.action?t.payload.action="created":"update"===t.payload.action&&(t.payload.action="updated"),e.tmpl(a.gistEvent,{status:t})):"IssueCommentEvent"===t.type?e.tmpl(a.issueCommentEvent,{status:t}):"IssuesEvent"===t.type?e.tmpl(a.issuesEvent,{status:t}):"PullRequestEvent"===t.type?e.tmpl(a.pullRequestEvent,{status:t}):"PushEvent"===t.type?(t.payload.ref=t.payload.ref.split("/")[2],e.tmpl(a.pushEvent,{status:t})):"WatchEvent"===t.type?e.tmpl(a.watchEvent,{status:t}):void 0},s=function(e){var r,a=[],s=0;if(e.query&&e.query.count&&e.query.count>0)for(r=e.query.count;r>s;s++){var o=e.query.results.json[s].json;a.push({date:new Date(o.created_at),config:t,html:n(o),url:"https://github.com/"+t.user})}return a};return e.ajax({url:e.fn.lifestream.createYqlUrl('select json.type, json.actor, json.repo, json.payload, json.created_at from json where url="https://api.github.com/users/'+t.user+'/events/public?per_page=100"'),dataType:"jsonp",success:function(e){r(s(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.googleplus=function(t,r){var a=e.extend({},{posted:'<a href="${actor.url}">${actor.displayName}</a> has posted a new entry <a href="${url}" title="${id}">${title}</a> <!--With--> ${object.replies.totalItems} replies, ${object.plusoners.totalItems} +1s, ${object.resharers.totalItems} Reshares'},t.template),n=function(r){var n,s,o=[],u=0;if(r&&r.items)for(n=r.items.length;n>u;u++)s=r.items[u],o.push({date:new Date(s.published),config:t,html:e.tmpl(a.posted,s)});return o};return e.ajax({url:"https://www.googleapis.com/plus/v1/people/"+t.user+"/activities/public",data:{key:t.key},dataType:"jsonp",success:function(e){return e.error?(r([]),console&&console.error&&console.error("Error loading Google+ stream.",e.error),void 0):(r(n(e)),void 0)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.googlereader=function(t,r){var a=e.extend({},{starred:'shared <a href="{{if link.href}}${link.href}{{else}}${source.link.href}{{/if}}">${title.content}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.feed.entry,s=n.length;s>u;u++){var l=n[u];o.push({url:"//www.google.com/reader/shared"+t.user,date:new Date(parseInt(l["crawl-timestamp-msec"],10)),config:t,html:e.tmpl(a.starred,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="www.google.com/reader/public/atom/user%2F'+t.user+'%2Fstate%2Fcom.google%2Fbroadcast"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.hypem=function(t,r){t.type&&"history"===t.type&&"loved"===t.type||(t.type="loved");var a=e.extend({},{loved:'loved <a href="http://hypem.com/item/${mediaid}">${title}</a> by <a href="http://hypem.com/artist/${artist}">${artist}</a>',history:'listened to <a href="http://hypem.com/item/${mediaid}">${title}</a> by <a href="http://hypem.com/artist/${artist}">${artist}</a>'},t.template);return e.ajax({url:"//hypem.com/playlist/"+t.type+"/"+t.user+"/json/1/data.js",dataType:"json",success:function(n){var s=[],o=0,u=-1;for(var l in n)n.hasOwnProperty(l)&&u++;if(n&&u>0)for(;u>o;o++){var i=n[o];s.push({date:new Date(1e3*("history"===t.type?i.dateplayed:i.dateloved)),config:t,html:e.tmpl("history"===t.type?a.history:a.loved,i)})}r(s)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.instapaper=function(t,r){var a=e.extend({},{loved:'loved <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.loved,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.instapaper.com/starred/rss/'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.iusethis=function(t,r){var a=e.extend({},{global:'${action} <a href="${link}">${what}</a> on (${os})'},t.template),n=function(r){var n,s,o,u,l,i,c,f,p,m,d,h,y=[],g=0,v=["iPhone","OS X","Windows"];if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss)for(i=r.query.results.rss.length,p=["started using","stopped using","stopped loving","Downloaded","commented on","updated entry for","started loving","registered"],l=p.length;i>g;g++)for(h=v[g],n=r.query.results.rss[g].channel.item,s=0,o=n.length;o>s;s++){for(c=n[s],f=c.title.replace(t.user+" ",""),u=0;l>u;u++)if(f.indexOf(p[u])>-1){m=p[u];break}d=f.split(m),y.push({date:new Date(c.pubDate),config:t,html:e.tmpl(a.global,{action:m.toLowerCase(),link:c.link,what:d[1],os:h})})}return y};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//iphone.iusethis.com/user/feed.rss/'+t.user+'" or '+'url="//osx.iusethis.com/user/feed.rss/'+t.user+'" or '+'url="//win.iusethis.com/user/feed.rss/'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.lastfm=function(t,r){var a=e.extend({},{loved:'loved <a href="${url}">${name}</a> by <a href="${artist.url}">${artist.name}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.lovedtracks&&r.query.results.lovedtracks.track)for(n=r.query.results.lovedtracks.track,s=n.length;s>u;u++){var l=n[u],i=l.nowplaying?new Date:l.date.uts;o.push({date:new Date(parseInt(1e3*i,10)),config:t,html:e.tmpl(a.loved,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//ws.audioscrobbler.com/2.0/user/'+t.user+'/lovedtracks.xml"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.librarything=function(t,r){var a=e.extend({},{book:'added <a href="http://www.librarything.com/work/book/${book.book_id}" title="${book.title} by ${book.author_fl}">${book.title} by ${book.author_fl}</a> to my library'},t.template),n=function(r){var n=[],s="";if(r.books)for(s in r.books)if(r.books.hasOwnProperty(s)){var o=r.books[s];n.push({date:new Date(1e3*o.entry_stamp),config:t,html:e.tmpl(a.book,{book:o}),url:"//www.librarything.com/profile/"+t.user})}return n};return e.ajax({url:"//www.librarything.com/api_getdata.php?booksort=entry_REV&userid="+t.user,dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.mendeley=function(t,r){var a=e.extend({},{flagged1:'flagged <a href="http://www.mendeley.com${link}">${title}</a>',flagged2:'flagged <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.rss.channel.item,s=n.length;s>u;u++){var l=n[u],i="/"===l.link.charAt(0)?a.flagged1:a.flagged2;o.push({date:new Date(l.pubDate),config:t,url:"//mendeley.com/groups/"+t.user,html:e.tmpl(i,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.mendeley.com/groups/'+t.user+'/feed/rss/"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.miso=function(t,r){var a=e.extend({},{watched:'checked in to <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.rss.channel.item,s=n.length;s>u;u++){var l=n[u];o.push({url:"//www.gomiso.com/feeds/user/"+t.user+"/checkins.rss",date:new Date(l.pubDate),config:t,html:e.tmpl(a.watched,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.gomiso.com/feeds/user/'+t.user+'/checkins.rss"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.mlkshk=function(t,r){var a=e.extend({},{posted:'posted <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.posted,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//mlkshk.com/user/'+t.user+'/rss"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.pinboard=function(t,r){var a=e.extend({},{bookmarked:'bookmarked <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.RDF.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.date),config:t,html:e.tmpl(a.bookmarked,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//feeds.pinboard.in/rss/u:'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.posterous=function(t,r){var a=e.extend({},{posted:'posted <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.posted,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//'+t.user+'.posterous.com/rss.xml"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.quora=function(t,r){var a=e.extend({},{posted:'<a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.rss.channel.item,s=n.length;s>u;u++){var l=n[u];o.push({url:"//www.google.com/reader/shared"+t.user,date:new Date(l.pubDate),config:t,html:e.tmpl(a.posted,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.quora.com/'+t.user+'/rss"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.reddit=function(t,r){var a=e.extend({},{commented:'<a href="http://www.reddit.com/r/${item.data.subreddit}/comments/${item.data.link_id.substring(3)}/u/${item.data.name.substring(3)}?context=3">commented (${score})</a> in <a href="http://www.reddit.com/r/${item.data.subreddit}">${item.data.subreddit}</a>',created:'<a href="http://www.reddit.com${item.data.permalink}">created new thread (${score})</a> in <a href="http://www.reddit.com/r/${item.data.subreddit}">${item.data.subreddit}</a>'},t.template),n=function(t){var r=t.data.ups-t.data.downs,n={item:t,score:r>0?"+"+r:r};return"t1"===t.kind?e.tmpl(a.commented,n):"t3"===t.kind?e.tmpl(a.created,n):void 0},s=function(e){return new Date(1e3*e)};return e.ajax({url:"//www.reddit.com/user/"+t.user+".json",dataType:"jsonp",jsonp:"jsonp",success:function(e){var a,o=[],u=0;if(e&&e.data&&e.data.children&&e.data.children.length>0)for(a=e.data.children.length;a>u;u++){var l=e.data.children[u];o.push({date:s(l.data.created_utc),config:t,html:n(l),url:"//reddit.com/user/"+t.user})}r(o)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.rss=function(t,r){var a=e.extend({},{posted:'posted <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.rss.channel.item,s=n.length;s>u;u++){var l=n[u];o.push({url:"//www.google.com/reader/shared"+t.user,date:new Date(l.pubDate),config:t,html:e.tmpl(a.posted,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.slideshare=function(t,r){var a=e.extend({},{uploaded:'uploaded a presentation <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.uploaded,o)});return u};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//www.slideshare.net/rss/user/'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.snipplr=function(t,r){var a=e.extend({},{posted:'posted a snippet <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.posted,o)});return u};e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="//snipplr.com/rss/users/'+t.user+'"'),dataType:"jsonp",success:function(e){r(n(e))}})}}(jQuery),function(e){e.fn.lifestream.feeds.stackoverflow=function(t,r){var a=e.extend({},{global:'<a href="${link}">${text}</a> - ${title}'},t.template),n=function(e){var r="",a="",n="",s="//stackoverflow.com/users/"+t.user,o="//stackoverflow.com/questions/";return"badge"===e.timeline_type?(r="was "+e.action+" the '"+e.description+"' badge",a=e.detail,n=s+"?tab=reputation"):"comment"===e.timeline_type?(r="commented on",a=e.description,n=o+e.post_id):("revision"===e.timeline_type||"accepted"===e.timeline_type||"askoranswered"===e.timeline_type)&&(r="askoranswered"===e.timeline_type?e.action:e.action+" "+e.post_type,a=e.detail||e.description||"",n=o+e.post_id),{link:n,title:a,text:r}},s=function(e){return new Date(1e3*e)};return e.ajax({url:"//api.stackoverflow.com/1.1/users/"+t.user+"/timeline?"+"jsonp",dataType:"jsonp",jsonp:"jsonp",success:function(o){var u,l=[],i=0;if(o&&o.total&&o.total>0&&o.user_timelines)for(u=o.user_timelines.length;u>i;i++){var c=o.user_timelines[i];l.push({date:s(c.creation_date),config:t,html:e.tmpl(a.global,n(c))})}r(l)}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.tumblr=function(t,r){var a=e.extend({},{posted:'posted a ${type} <a href="${url}">${title}</a>'},t.template),n=t.limit||20,s=function(t){switch(t.type){case"photo":var r=t["photo-url"];return e('<img width="75" height="75"/>').attr({src:r[r.length-1].content,title:l(t),alt:l(t)}).wrap("<div/>").parent().html();case"video":var a=t["video-player"],n=a[a.length-1].content;return n.match(/<\s*script/)?null:n;case"audio":return t["audio-player"]+" "+e("<div/>").text(l(t)).html();default:return null}},o=function(t,r){return e(t[r]).filter(":not(:empty):first").text()},u=function(e){var t;switch(e.type){case"regular":return e["regular-title"]||o(e,"regular-body");case"link":return t=e["link-text"]||o(e,"link-description"),""===t&&(t=e["link-url"]),t;case"video":return o(e,"video-caption");case"audio":return o(e,"audio-caption");case"photo":return o(e,"photo-caption");case"quote":return'"'+e["quote-text"].replace(/<.+?>/g," ").trim()+'"';case"conversation":return t=e["conversation-title"],t||(t=e.conversation.line,"string"!=typeof t&&(t=line[0].label+" "+line[0].content+" ....")),t;case"answer":return e.question;default:return e.type}},l=function(e){var t=u(e)||"";return t.replace(/<.+?>/gi," ")},i=function(t,r){return{date:new Date(r.date),config:t,html:e.tmpl(a.posted,{type:r.type.replace("regular","blog entry"),url:r.url,image:s(r),title:l(r)})}},c=function(r){var a,n,s=[],o=0;if(r.query&&r.query.count&&r.query.count>0)if(e.isArray(r.query.results.posts.post))for(a=r.query.results.posts.post.length;a>o;o++)n=r.query.results.posts.post[o],s.push(i(t,n));else e.isPlainObject(r.query.results.posts.post)&&s.push(i(t,r.query.results.posts.post));return s};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from tumblr.posts where username="'+t.user+'" and num="'+n+'"'),dataType:"jsonp",success:function(e){r(c(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.twitter=function(t,r){var a=e.extend({},{posted:"{{html tweet}}"},t.template),n=function(e){var t=function(e){return e.replace(/[a-z]+:\/\/[a-z0-9\-_]+\.[a-z0-9\-_:~%&\?\/.=]+[^:\.,\)\s*$]/gi,function(e){return'<a href="'+e+'">'+(e.length>25?e.substr(0,24)+"...":e)+"</a>"})},r=function(e){return e.replace(/(^|[^\w]+)\@([a-zA-Z0-9_]{1,15})/g,function(e,t,r){return t+'<a href="http://twitter.com/'+r+'">@'+r+"</a>"})},a=function(e){return e.replace(/(^|[^\w'"]+)\#([a-zA-Z0-9ÅåÄäÖöØøÆæÉéÈèÜüÊêÛûÎî_]+)/g,function(e,t,r){return t+'<a href="http://search.twitter.com/search?q=%23'+r+'">#'+r+"</a>"})};return a(r(t(e)))},s=function(r){var s,o,u=[],l=0;if(r&&r.length>0)for(s=r.length;s>l;l++)o=r[l],u.push({date:new Date(o.created_at),config:t,html:e.tmpl(a.posted,{tweet:n(o.text),complete_url:"//twitter.com/#!/"+t.user+"/status/"+o.id_str}),url:"//twitter.com/#!/"+t.user});return u};return e.ajax({url:"https://api.twitter.com/1/statuses/user_timeline.json",data:{screen_name:t.user,include_rts:1},dataType:"jsonp",success:function(e){r(s(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.vimeo=function(t,r){var a=e.extend({},{liked:'liked <a href="${url}" title="${description}">${title}</a>',posted:'posted <a href="${url}" title="${description}">${title}</a>'},t.template),n=function(r,n){var s,o,u,l=[],i=0,c=n||"liked";if(r)for(s=r.length;s>i;i++)o=r[i],u="posted"===c?new Date(o.upload_date.replace(" ","T")):new Date(o.liked_on.replace(" ","T")),l.push({date:u,config:t,html:e.tmpl(a[c],{url:o.url,description:o.description.replace(/"/g,"'").replace(/<.+?>/gi,""),title:o.title})});return l};return e.ajax({url:e.fn.lifestream.createYqlUrl('SELECT * FROM xml WHERE url="http://vimeo.com/api/v2/'+t.user+'/likes.xml" OR '+'url="http://vimeo.com/api/v2/'+t.user+'/videos.xml"'),dataType:"jsonp",success:function(e){var t=[];e.query.results.videos[0].video.length>0&&(t=t.concat(n(e.query.results.videos[0].video))),e.query.results.videos[1].video.length>0&&(t=t.concat(n(e.query.results.videos[1].video,"posted"))),r(t)
}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.wikipedia=function(t,r){var a=t.language||"en",n=e.extend({},{contribution:'contributed to <a href="${url}">${title}</a>'},t.template);return e.ajax({url:"//"+a+".wikipedia.org/w/api.php?action=query&ucuser="+t.user+"&list=usercontribs&ucdir=older&format=json",dataType:"jsonp",success:function(s){var o,u=[],l=0;if(s&&s.query.usercontribs)for(o=s.query.usercontribs.length;o>l;l++){var i=s.query.usercontribs[l];i.url="http://"+a+".wikipedia.org/wiki/"+i.title.replace(" ","_"),u.push({date:new Date(i.timestamp),config:t,html:e.tmpl(n.contribution,i)})}r(u)}}),{template:n}}}(jQuery),function(e){e.fn.lifestream.feeds.wordpress=function(t,r){var a=e.extend({},{posted:'posted <a href="${link}">${title}</a>'},t.template),n=function(r){var n,s,o,u=[],l=0;if(r.query&&r.query.count&&r.query.count>0&&r.query.results.rss.channel.item)for(n=r.query.results.rss.channel.item,s=n.length;s>l;l++)o=n[l],u.push({date:new Date(o.pubDate),config:t,html:e.tmpl(a.posted,o)});return u},s="";return t.user&&(s=0===t.user.indexOf("http://")?t.user+"/feed":"//"+t.user+".wordpress.com/feed",e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="'+s+'"'),dataType:"jsonp",success:function(e){r(n(e))}})),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.youtube=function(t,r){var a=e.extend({},{favorited:'favorited <a href="${video.player.default}" title="${video.description}">${video.title}</a>'},t.template),n=function(r){var n,s,o=[],u=0;if(r.data&&r.data.items)for(n=r.data.items.length;n>u;u++)s=r.data.items[u],o.push({date:new Date(s.created),config:t,html:e.tmpl(a.favorited,s)});return o};return e.ajax({url:"//gdata.youtube.com/feeds/api/users/"+t.user+"/favorites?v=2&alt=jsonc",dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery),function(e){e.fn.lifestream.feeds.zotero=function(t,r){var a=e.extend({},{flagged:'flagged <a href="${id}">${title}</a> by ${creatorSummary}'},t.template),n=function(r){var n,s,o=[],u=0;if(r.query&&r.query.count&&r.query.count>0)for(n=r.query.results.feed.entry,s=n.length;s>u;u++){var l=n[u];o.push({date:new Date(l.updated),config:t,url:"//zotero.com/users/"+t.user,html:e.tmpl(a.flagged,l)})}return o};return e.ajax({url:e.fn.lifestream.createYqlUrl('select * from xml where url="https://api.zotero.org/users/'+t.user+'/items"'),dataType:"jsonp",success:function(e){r(n(e))}}),{template:a}}}(jQuery);