Permalink
Browse files

Merge pull request #146 from arminrosu/service/fancy

Added Fancy support
  • Loading branch information...
2 parents f7bc734 + b66edee commit 7023580995ea34ba43789edeefec7a32d996d329 @christianvuerings committed Sep 16, 2013
Showing with 63 additions and 10 deletions.
  1. +1 −0 README.md
  2. +14 −9 build/compile-css.js
  3. BIN src/favicons/fancy.png
  4. +47 −0 src/services/fancy.js
  5. +1 −1 src/services/youtube.js
View
@@ -24,6 +24,7 @@ Currently supports the following feeds:
* [Disqus](http://disqus.com)
* [Dribbble](http://dribbble.com)
* [Facebook Pages](http://www.facebook.com/pages)
+* [Fancy](http://www.fancy.com)
* [Flickr](http://flickr.com)
* [Foomark](http://foomark.com)
* [Formspring](http://formspring.com)
View
@@ -3,21 +3,21 @@ var fs = require('fs'),
path = require('path'),
baseDir = process.argv[2],
files = [],
- styles = '';
-
-// get the mime type base on extension
-// easier than installing modules, but more accident-prone
-var getMimeType = function(filepath) {
- var types = {
+ mimeTypes = {
'gif': 'image/gif',
'jpe': 'image/jpeg',
'jpg': 'image/jpeg',
'jpeg': 'image/jpeg',
'png': 'image/png'
},
- extension = path.extname(filepath).replace('.', '');
+ styles = '';
+
+// get the mime type based on extension
+// easier than installing modules, but more accident-prone
+var getMimeType = function(filepath) {
+ var extension = path.extname(filepath).replace('.', '');
- return types[extension];
+ return mimeTypes[extension];
};
// gets an image and gives you the full css class
@@ -30,7 +30,12 @@ var base64Encode = function(filepath) {
files = fs.readdirSync(baseDir);
files.sort().forEach(function(filename){
- styles += base64Encode( baseDir + '/' + filename ) + "\n";
+ var allowedExtensions = Object.keys(mimeTypes),
+ fileExtension = path.extname(filename).replace('.', '');
+ // make sure only allowed files are parse
+ if ( allowedExtensions.indexOf(fileExtension) >= 0 ) {
+ styles += base64Encode( baseDir + '/' + filename ) + "\n";
+ }
});
process.stdout.write(styles);
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,47 @@
+(function($) {
+ 'use strict';
+
+ $.fn.lifestream.feeds.fancy = function( config, callback ) {
+
+ var template = $.extend({},
+ {
+ fancied: 'fancy\'d <a href="${link}">${title}</a>'
+ },
+ config.template),
+
+ parseFancy = function( input ) {
+ var output = [], i = 0, j;
+
+ if(input.query && input.query.count && input.query.count > 0) {
+ j = input.query.count;
+ for( ; i<j; i++) {
+ var item = input.query.results.item[i];
+ output.push({
+ date: new Date(item.pubDate),
+ config: config,
+ html: $.tmpl( template.fancied, item )
+ });
+ }
+ }
+
+ return output;
+ };
+
+ $.ajax({
+ url: $.fn.lifestream.createYqlUrl('SELECT * FROM xml ' +
+ 'WHERE url="http://www.fancy.com/rss/' + config.user +
+ '" AND itemPath="/rss/channel/item"'),
+ dataType: 'jsonp',
+ success: function( data ) {
+ callback(parseFancy(data));
+ }
+ });
+
+ // Expose the template.
+ // We use this to check which templates are available
+ return {
+ "template" : template
+ };
+
+ };
+})(jQuery);
View
@@ -32,7 +32,7 @@ $.fn.lifestream.feeds.youtube = function( config, callback ) {
}
// Don't add unavailable items (private, rejected, failed)
- if (!video.player && !video.player['default']) {
+ if (!video.player || !video.player['default']) {
continue;
}

0 comments on commit 7023580

Please sign in to comment.