FeedMagickInfotron

Sample Declaration

<div id="bulletlist"      
      script="http://localhost/BulletList.js">
</div>

Dependencies

Input Terminals

Output Terminals

Properties

Demos that use it

How does it work?

If you use another infotron (HttpProxy, for instance) to get the feed off feedmagik, you'll receive a json object as described below. This blueprint will convert the feed to a generic textscrap array which is used by several other blueprints.


/*
  FeedMagick JSON RSS format
  
  { feed_type: 'RSS',
    feed_version: '2.0',
    channel : 
    {
      title: 'Everyone\'s Photos',
      link: 'http://www.flickr.com/photos/',
      description: '',
      language:'en-US',
      category:'Events',
      generator:'RSS Generator',
      docs:'',
      ttl:60,
      opensearch:{},
      tagline:'',
      author: 'Penut768',
      modified: new Date('2006-05-12 02:46:59'),
      items: 
        [
          {
  	    title: 'P1010056',
 	    link: 'http://www.flickr.com/photos/12852817@N00/144865167/',
	    content: '<p><a href="http://www.flickr.com/people/12852817@N00/">Penut768</a> posted a photo:</p>  <p><a href="http://www.flickr.com/photos/12852817@N00/144865167/" title="P1010056"><img src="http://static.flickr.com/56/144865167_ee280ddf5a_m.jpg" width="240" height="180" alt="P1010056" style="border: 1px solid #ddd;" /></a></p>  ',
	    author: 'Penut768',
	    category: [],
	    issued: new Date('2006-05-12 02:46:59'),
	    modified: new Date('2006-05-12 02:46:59'),
	    id: 'tag:flickr.com,2004:/photo/144865167'
	  }
        ]
    }
  }

 */
BLUEPRINT(
"~01067126C6D0CF47bdBB14409B900AE9BC",
[
 ["json_rss_in", "onJsonRss", 10]
],
[
 "textscrap_collection_out"
],
function (Class) 
{

    Class.prototype.onJsonRss = function(msg)
    {
	var coll = [];	
	var n, item, result, results, issued, modified;

	try {
	    results = msg.items;
	    n = results.length;
	} catch (ex) {
	  this.error(ex, "malformed JSON RSS output");

	    return;
	    /*****************************************************************/
	}
	
	
	for (i = 0; i < n; i++) {
	    result = results[i];
	    item = {name:result.title,
		    text_content:result.content,
		    uri:result.link,
		    date:[]};

	    issued = result.pubdate || ((result.dc) ? result.dc.date : null);

	    if (issued) {
		if (typeof(issued) == "object" && 
		    issued.constructor == Date) {	        
		} else {
		    issued = new Date(issued);
		}

		item.date.push(issued); 
	    }

	    coll.push(item)
	}
	
	this.postMessage("textscrap_collection_out", coll);
    };
}, "JSON RSS to Textscrap collection");