Permalink
Browse files

v0.2.9 - Hypem support by @blakeembrey

  • Loading branch information...
2 parents 5541bb2 + 8ca1b71 commit 4396c0aa30e236565f79e00812ec81d135ffc89e @christianvuerings committed Jan 18, 2012
Showing with 138 additions and 20 deletions.
  1. +2 −0 README.md
  2. +1 −1 download/services.json
  3. +69 −5 jquery.lifestream.js
  4. +2 −2 jquery.lifestream.min.js
  5. +20 −12 src/core.js
  6. +44 −0 src/services/hypem.js
View
@@ -217,6 +217,7 @@ Places on the web where this plug-in got mentioned:
* [Erik Ostrom Blog](http://slapdash.erikostrom.com/post/9797738423/just-finally-added-something-to-my-ostensible-web)
* [doejo](http://doejo.com/blog/jquery-lifestream-a-simple-way-to-track-your-online-activity-in-one-spot)
* [HTML.it](http://javascript.html.it/script/vedi/6468/le-nostre-attivita-su-internet-con-il-plugin-jquery-lifestream/) - Italian
+* [Hypem](http://hypem.com/)
* [jQuery Rain](http://www.jqueryrain.com/2011/06/jquery-lifestream/)
* [jqueryitalia](http://twitter.com/jqueryitalia/status/77999618046169088)
* [Lifestream Blog](http://lifestreamblog.com/create-a-dynamic-activity-stream-with-the-jquery-lifestream-script/)
@@ -255,6 +256,7 @@ Special thanks all the [committers](https://raw.github.com/christianv/jquery-lif
## Version log
+* 0.2.9 Hypem support
* 0.2.8 Gimmebar support
* 0.2.7 Zotero support
* 0.2.6 Google+ support
View
@@ -1 +1 @@
-["bitbucket","bitly","blogger","dailymotion","delicious","deviantart","digg","dribbble","facebook_page","flickr","foomark","formspring","forrst","foursquare","gimmebar","github","googleplus","googlereader","instapaper","iusethis","lastfm","librarything","mlkshk","picplz","pinboard","posterous","reddit","slideshare","snipplr","stackoverflow","tumblr","twitter","vimeo","wikipedia","wordpress","youtube","zotero"]
+["bitbucket","bitly","blogger","dailymotion","delicious","deviantart","digg","dribbble","facebook_page","flickr","foomark","formspring","forrst","foursquare","gimmebar","github","googleplus","googlereader","hypem","instapaper","iusethis","lastfm","librarything","mlkshk","picplz","pinboard","posterous","reddit","slideshare","snipplr","stackoverflow","tumblr","twitter","vimeo","wikipedia","wordpress","youtube","zotero"]
View
@@ -1,13 +1,15 @@
/*!
* jQuery Lifestream Plug-in
- * @version 0.2.8
+ * @version 0.2.9
* Show a stream of your online activity
*
* Copyright 2011, Christian Vuerings - http://denbuzze.com
*/
/*globals jQuery, $ */
;(function( $ ){
+ "use strict";
+
/**
* Initialize the lifestream plug-in
* @param {Object} config Configuration object
@@ -83,8 +85,8 @@
for ( ; i < length; i++ ) {
item = items[i];
if ( item.html ) {
- $('<li class="'+ settings.classname + '-'
- + item.config.service + '">').data( "name", item.config.service )
+ $('<li class="'+ settings.classname + '-' +
+ item.config.service + '">').data( "name", item.config.service )
.data( "url", item.url || "#" )
.data( "time", item.date )
.append( item.html )
@@ -123,8 +125,8 @@
// Check whether the feed exists, if the feed is a function and if a
// user has been filled in
if ( $.fn.lifestream.feeds[config.service] &&
- $.isFunction( $.fn.lifestream.feeds[config.service] )
- && config.user) {
+ $.isFunction( $.fn.lifestream.feeds[config.service] ) &&
+ config.user) {
// You'll be able to get the global settings by using
// config._settings in your feed
@@ -168,6 +170,25 @@
*/
$.fn.lifestream.feeds = $.fn.lifestream.feeds || {};
+ /**
+ * Add compatible Object.keys support in older environments that do not natively support it
+ * https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys#section_6
+ */
+ if(!Object.keys) {
+ Object.keys = function(o){
+ if (o !== Object(o)){
+ throw new TypeError('Object.keys called on non-object');
+ }
+ var ret=[],p;
+ for(p in o) {
+ if(Object.prototype.hasOwnProperty.call(o,p)) {
+ ret.push(p);
+ }
+ }
+ return ret;
+ };
+ }
+
}( jQuery ));
(function($) {
$.fn.lifestream.feeds.bitbucket = function( config, callback ) {
@@ -1122,6 +1143,49 @@ $.fn.lifestream.feeds.googlereader = function( config, callback ) {
};
})(jQuery);
(function($) {
+$.fn.lifestream.feeds.hypem = function( config, callback ) {
+
+ if( !config.type || config.type !== "history" || config.type !== "loved" ) { config.type = "loved"; }
+
+ var template = $.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>'
+ },
+ config.template);
+
+ $.ajax({
+ url: "http://hypem.com/playlist/" + config.type + "/" + config.user + "/json/1/data.js",
+ dataType: "json",
+ success: function( data ) {
+ var output = [], i = 0, j = -1;
+ for (var k in data) {
+ if (data.hasOwnProperty(k)) {
+ j++;
+ }
+ }
+ if (data && j > 0) {
+ for( ; i < j; i++) {
+ var item = data[i];
+ output.push({
+ date: new Date( (config.type === "history" ? item.dateplayed : item.dateloved) * 1000 ),
+ config: config,
+ html: $.tmpl( (config.type === "history" ? template.history : template.loved) , item )
+ });
+ }
+ }
+ callback(output);
+ }
+ });
+
+ // Expose the template.
+ // We use this to check which templates are available
+ return {
+ "template" : template
+ };
+
+};
+})(jQuery);(function($) {
$.fn.lifestream.feeds.instapaper = function( config, callback ) {
var template = $.extend({},
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,13 +1,15 @@
/*!
* jQuery Lifestream Plug-in
- * @version 0.2.8
+ * @version 0.2.9
* Show a stream of your online activity
*
* Copyright 2011, Christian Vuerings - http://denbuzze.com
*/
/*globals jQuery, $ */
;(function( $ ){
+ "use strict";
+
/**
* Initialize the lifestream plug-in
* @param {Object} config Configuration object
@@ -83,8 +85,8 @@
for ( ; i < length; i++ ) {
item = items[i];
if ( item.html ) {
- $('<li class="'+ settings.classname + '-'
- + item.config.service + '">').data( "name", item.config.service )
+ $('<li class="'+ settings.classname + '-' +
+ item.config.service + '">').data( "name", item.config.service )
.data( "url", item.url || "#" )
.data( "time", item.date )
.append( item.html )
@@ -123,8 +125,8 @@
// Check whether the feed exists, if the feed is a function and if a
// user has been filled in
if ( $.fn.lifestream.feeds[config.service] &&
- $.isFunction( $.fn.lifestream.feeds[config.service] )
- && config.user) {
+ $.isFunction( $.fn.lifestream.feeds[config.service] ) &&
+ config.user) {
// You'll be able to get the global settings by using
// config._settings in your feed
@@ -172,13 +174,19 @@
* Add compatible Object.keys support in older environments that do not natively support it
* https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys#section_6
*/
- if(!Object.keys) Object.keys = function(o){
- if (o !== Object(o)){
- throw new TypeError('Object.keys called on non-object');
- }
- var ret=[],p;
- for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
- return ret;
+ if(!Object.keys) {
+ Object.keys = function(o){
+ if (o !== Object(o)){
+ throw new TypeError('Object.keys called on non-object');
+ }
+ var ret=[],p;
+ for(p in o) {
+ if(Object.prototype.hasOwnProperty.call(o,p)) {
+ ret.push(p);
+ }
+ }
+ return ret;
+ };
}
}( jQuery ));
View
@@ -0,0 +1,44 @@
+(function($) {
+$.fn.lifestream.feeds.hypem = function( config, callback ) {
+
+ if( !config.type || config.type !== "history" || config.type !== "loved" ) { config.type = "loved"; }
+
+ var template = $.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>'
+ },
+ config.template);
+
+ $.ajax({
+ url: "http://hypem.com/playlist/" + config.type + "/" + config.user + "/json/1/data.js",
+ dataType: "json",
+ success: function( data ) {
+ var output = [], i = 0, j = -1;
+ for (var k in data) {
+ if (data.hasOwnProperty(k)) {
+ j++;
+ }
+ }
+ if (data && j > 0) {
+ for( ; i < j; i++) {
+ var item = data[i];
+ output.push({
+ date: new Date( (config.type === "history" ? item.dateplayed : item.dateloved) * 1000 ),
+ config: config,
+ html: $.tmpl( (config.type === "history" ? template.history : template.loved) , item )
+ });
+ }
+ }
+ callback(output);
+ }
+ });
+
+ // Expose the template.
+ // We use this to check which templates are available
+ return {
+ "template" : template
+ };
+
+};
+})(jQuery);

0 comments on commit 4396c0a

Please sign in to comment.