<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>www.newsinapp.io - Latest entries</title><link>http://www.newsinapp.io/</link><description>The latest entries for the site www.newsinapp.io</description><atom:link href="http://www.newsinapp.io/feeds/latest/" rel="self"></atom:link><language>en-us</language><copyright>Zinnia</copyright><lastBuildDate>Wed, 12 Sep 2012 22:41:54 -0500</lastBuildDate><item><title>How to integrate your interests in Flipboard
</title><link>http://www.newsinapp.io/2012/09/12/how-integrate-your-interests-flipboard/</link><description>	&lt;p&gt;Flipboard is a magical tool which allows us to browse a virtual newspaper from an iPad, iPhone or even an Android tablet or smartphone. The design of the layout is beautiful, and probably the main reason for its success. However, despite the impressive variety of sources available, it may happen that it is not enough.&lt;/p&gt;

	&lt;p&gt;As an example, let&amp;#8217;s say we want to get news on &amp;#8220;Tim Burton&amp;#8221;. Here what Flipboard shows us:&lt;/p&gt;

	&lt;p style="text-align:center;"&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/flipboard/search_in_flipboard.png" style="margin:20px;" title="Search "Tim Burton" in Flipboard" alt="Search "Tim Burton" in Flipboard" /&gt;&lt;/p&gt;

	&lt;p&gt;Flipboard proposes us to follow news from a Tumblr blog,  a Facebook page or three Twitter accounts, whose @timburton_news where news are provided by newsinapp ;) &lt;/p&gt;

	&lt;p&gt;Flipboard does not directly provide latest news on this subject. One of these choices may be relevant and sufficient, but if it does not fit, then we need to follow several of these proposals. But, we would like to have a complete and unified  view on this topic in Flipboard.&lt;/p&gt;

	&lt;p&gt;Newsinapp can help us to fill this gap.&lt;/p&gt;

	&lt;p&gt;With Newsinapp, we aim to retrieve relevant news for our users, but also to publish them where they need it. It can be in their blog, in their virtual newspaper, in a web application, or to help draft an article &amp;#8230;&lt;/p&gt;

	&lt;p&gt;Below, the topic &amp;#8220;Tim Burton&amp;#8221; integrated into Flipboard&lt;/p&gt;

	&lt;p style="text-align:center;"&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/flipboard/TimBurton_Flipboard.png" style="margin:20px;" title="Newsinapp integrates in Flipboard" alt="Newsinapp integrates in Flipboard" /&gt;&lt;/p&gt;

	&lt;p&gt;We made ​​a video explaining how to integrate your interests in Flipboard&lt;/p&gt;

	&lt;p style="text-align:center;"&gt;&lt;iframe width="640" height="360" src="http://www.youtube.com/embed/tfvinK2_jRA?rel=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;/p&gt;

	&lt;p&gt;Finally, newsinapp can integrate with other virtuals newspapers such as Pulse News, Google Currents, Feedly &amp;#8230;&lt;/p&gt;

&lt;div class="wrap"&gt;&lt;div id="slider1" class="slider"&gt;&lt;ul&gt;&lt;li&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/flipboard/TimBurton_Feedly.png" alt=""&gt;&lt;/li&gt;&lt;li&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/flipboard/TimBurton_GoogleCurrents.png" alt=""&gt;&lt;/li&gt;&lt;li&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/flipboard/TimBurton_PulseNews.png" alt=""&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;

	&lt;script src="http://static.newsinapp.io/static/js/lemmon-slider.js"&gt;&lt;/script&gt;
	&lt;script&gt;
	function sliderAutoplay(){ $("#slider1").trigger("nextSlide"); setTimeout("sliderAutoplay()", 3000); }; 
	window.onload = function(){$("#slider1").lemmonSlider({"slideToLast" : true}); 
        sliderAutoplay();
	};

	&lt;/script&gt;
	&lt;style type="text/css" media="screen"&gt;
	.wrap { width:640px; margin:20px; }
	body div.slider    { overflow:hidden; position:relative; width:100%; height:450px !important; }
	body div.slider ul { margin:0; padding:0; height:160px; }
	body div.slider li { float:left; list-style:none; margin:0 50px 0 0;
	                     box-shadow: 5px 5px 5px #A0A0A0; 
	                     height:350px; }
	body div.slider li { text-align:center; line-height:160px; font-size:25px; }
	&lt;/style&gt;
</description><author>didier.rano@gmail.com (didier)</author><pubDate>Wed, 12 Sep 2012 22:41:54 -0500</pubDate><guid>http://www.newsinapp.io/2012/09/12/how-integrate-your-interests-flipboard/</guid><enclosure url="http://static.newsinapp.io/static/uploads/zinnia/flipboard/search_in_flipboard.png" length="100000" type="image/jpeg"></enclosure></item><item><title>Python and Redis: A mini search engine
</title><link>http://www.newsinapp.io/2012/05/22/python-and-redis-mini-search-engine/</link><description>	&lt;p&gt;How to use Redis/Django to build a mini search engine (Sorry only in french)&lt;/p&gt;

&lt;div style="width:425px" id="__ss_12780035"&gt; &lt;strong style="display:block;margin:12px 0 4px"&gt;&lt;a href="http://www.slideshare.net/didierrano/python-and-redis-a-mini-search-engine" title="Python and Redis: A mini search engine" target="_blank"&gt;Python and Redis: A mini search engine&lt;/a&gt;&lt;/strong&gt; &lt;iframe src="http://www.slideshare.net/slideshow/embed_code/12780035" width="425" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"&gt;&lt;/iframe&gt; &lt;div style="padding:5px 0 12px"&gt; View more &lt;a href="http://www.slideshare.net/" target="_blank"&gt;presentations&lt;/a&gt; from &lt;a href="http://www.slideshare.net/didierrano" target="_blank"&gt;Didier Rano&lt;/a&gt; &lt;/div&gt; &lt;/div&gt;
</description><author>didier.rano@gmail.com (didier)</author><pubDate>Tue, 22 May 2012 08:16:17 -0500</pubDate><guid>http://www.newsinapp.io/2012/05/22/python-and-redis-mini-search-engine/</guid><category>Technical</category></item><item><title>How to build a news aggregator with backbone.js - Part 2
</title><link>http://www.newsinapp.io/2012/05/01/how-build-news-aggregator-backbonejs-part-2/</link><description>	&lt;p&gt;In the previous &lt;a href="http://blog.newsinapp.io/2012/03/15/how-build-news-aggregator-backbonejs-part-1/"&gt;post&lt;/a&gt;, I have been using backbone.js to retrieve news provided by newsinapp.io. Now, I need to display them in an unique &lt;span class="caps"&gt;HTML&lt;/span&gt; page. By unique page, I mean that all user interactivities will be only in one &lt;span class="caps"&gt;HTML&lt;/span&gt; page, and backend server will provide only data and no &lt;span class="caps"&gt;HTML&lt;/span&gt; tags.&lt;/p&gt;

	&lt;p&gt;How will be the &lt;span class="caps"&gt;GUI&lt;/span&gt; of this application ? First, a list will display each latest news. When a news is selected, the content detail will be displayed on the side. In addition, an image or video will be shown if it is available.&lt;/p&gt;

	&lt;p&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/backbone2/ViewExplanation.jpg" title="Explanation view" alt="Explanation view" /&gt;&lt;/p&gt;

	&lt;h3&gt;NewsItemView or the news in tiny&lt;/h3&gt;

	&lt;p&gt;&lt;em&gt;NewsItemView&lt;/em&gt; is a backbone.js class. In the list of news, it displays the information of each news. In short, this class generates some &lt;span class="caps"&gt;HTML&lt;/span&gt; from information belonging to an instance of the class NewsItem, the model class defined in the previous post.&lt;/p&gt;

	&lt;p&gt;&lt;pre class="brush: js"&gt;
 window.NewsItemView = Backbone.View.extend({
         tagName: 'li&amp;#8217;,
         className: 'news-item-cell&amp;#8217;,&lt;/p&gt;

         initialize: function() {
             this.initializeTemplate();
         },

         initializeTemplate: function() {
             this.template = _.template($(&amp;#8221;#news-item-template&amp;#8221;).html());
         },

         render: function() {
             $(this.el).html(this.template(this.model.toJSON()));
             return this;
         }
     });
&lt;/pre&gt;

	&lt;p&gt;&lt;em&gt;tagName&lt;/em&gt; is the &lt;span class="caps"&gt;HTML&lt;/span&gt; element that will be generated for each call to the render method.&lt;br /&gt;And, &lt;em&gt;className&lt;/em&gt; is the &lt;span class="caps"&gt;CSS&lt;/span&gt; class of this tag.&lt;/p&gt;

	&lt;p&gt;Mainly, the code describes how using an &lt;span class="caps"&gt;HTML&lt;/span&gt; template. Then, the method &lt;em&gt;initializeTemplate&lt;/em&gt; loads this template in memory. And, &lt;em&gt;#news-item-template&lt;/em&gt; is a &lt;span class="caps"&gt;CSS&lt;/span&gt; selector&amp;#8230; Simply because the template is contained in the file index.html!&lt;/p&gt;

	&lt;p&gt;Below, this famous template:&lt;/p&gt;

&lt;pre class="brush: html"&gt;
    &lt;script id='news-item-template' type='text/template'&gt;
      &lt;div class='topic'&gt;
        &lt;%= topic.displayName %&gt;
      &lt;/div&gt;
      &lt;div class='title'&gt;
        &lt;%= title %&gt;
      &lt;/div&gt;
      &lt;div class='source'&gt;
        &lt;%= source %&gt;
      &lt;/div&gt;
    &lt;/script&gt;
&lt;/pre&gt;

	&lt;p&gt;Placeholders, such as &lt;em style="text-align:left;"&gt;%= topic.displayName %&gt;&lt;/em&gt;, will be evaluated with the contents of the news.&lt;br /&gt;Finally, when the method &lt;em&gt;render()&lt;/em&gt; is called, the template is executed to generate the &lt;span class="caps"&gt;HTML&lt;/span&gt; for one instance of news.&lt;/p&gt;

	&lt;p&gt;Next, I need to define the list of news.&lt;/p&gt;

	&lt;h3&gt;NewsCollectionView or the collection of tiny news&lt;/h3&gt;

	&lt;p&gt;&lt;pre class="brush: js"&gt;
     window.NewsCollectionView = Backbone.View.extend({  &lt;/p&gt;

       render: function() {
         var $newsItems;

         $newsItems = $('ul#news-items&amp;#8217;);

         this.collection.each(function(newsItem) {
           var newsItemView = new NewsItemView( { model: newsItem});
           $newsItems.append( newsItemView.render().el);
         });

         return this;
       };
     });
&lt;/pre&gt;

	&lt;p&gt;In the following paragraphs, &lt;em&gt;this.collection&lt;/em&gt; will be populated with the list of news. Then, when the method &lt;em&gt;render()&lt;/em&gt; is called, the &lt;span class="caps"&gt;HTML&lt;/span&gt; will be generated for all news in the list. In addition, these &lt;span class="caps"&gt;HTML&lt;/span&gt; elements will be contained in an ul element with the &lt;span class="caps"&gt;CSS&lt;/span&gt; class news-items (&lt;em&gt;ul#news-items&lt;/em&gt;)&lt;/p&gt;

	&lt;p&gt;It is time to test with the javascript console:&lt;/p&gt;

	&lt;p&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/backbone2/ConsoleList.jpg" title="View in javascript Console" alt="View in javascript Console" /&gt;&lt;/p&gt;

	&lt;p&gt;Yes ! I can see some news! And, Quentin Tarantino is preparing a western!&lt;/p&gt;

	&lt;h3&gt;Now, a real application&lt;/h3&gt;

	&lt;p&gt;One last step before taking a short break: Get rid of the console JavaScript. In short, the application will work without my intervention in the console.&lt;/p&gt;

	&lt;p&gt;To display this list of news when the page is loaded, I need to modify my favorite script: &lt;em&gt;news.js&lt;/em&gt;&lt;/p&gt;

	&lt;p&gt;&lt;pre class="brush: js"&gt;
     window.App = App = (function() {
       function App() {
         this.newsCollectionView = new NewsCollectionView({
             collection: news
         });&lt;/p&gt;

         this.newsCollectionView.render();

         news.fetch();
       }
       return App;
     })();
&lt;/pre&gt;

	&lt;p&gt;In the &lt;em&gt;index.html&lt;/em&gt; file, to execute this javascript code:&lt;/p&gt;

&lt;pre class="brush: js"&gt;
    &lt;script type='text/javascript'&gt;
      //&lt;![CDATA[
        jQuery(function() {
          new App();
        });
      //]]&gt;
    &lt;/script&gt;
&lt;/pre&gt;

	&lt;p&gt;Here, all the pieces are assembled to close this article.&lt;/p&gt;

	&lt;p&gt;Drum roll &amp;#8230; &lt;/p&gt;

	&lt;p&gt;But, nothing is displayed &amp;#8230; Probably the demonstration effect. However, I do not work with Windows. The problem must come from me …&lt;/p&gt;

	&lt;p&gt;&lt;em&gt;[A few grunts later]&lt;/em&gt;&lt;/p&gt;

	&lt;p&gt;I’VE &lt;span class="caps"&gt;FOUND&lt;/span&gt;.&lt;/p&gt;

	&lt;p&gt;Following the execution of &lt;em&gt;news.fetch()&lt;/em&gt;, the collection of news is filled with a list of news, but &lt;em&gt;newsCollectionView&lt;/em&gt; is not aware of that change. Then, it should be notified when this event occurs. So, I’ve added a constructor to &lt;em&gt;viewNewsCollectionView&lt;/em&gt;&lt;/p&gt;

&lt;pre class="brush: js"&gt;
      initialize: function() {
           _.bindAll(this, 'render');
           this.collection.bind('reset', this.render);
       },
&lt;/pre&gt;

	&lt;p&gt;A new test&amp;#8230;Yeesssss !&lt;/p&gt;

	&lt;p&gt;This strong emotion leads me to give you an appointment for a third part &amp;#8220;The power of the detail view&amp;#8221; &lt;/p&gt;
</description><author>didier.rano@gmail.com (didier)</author><pubDate>Tue, 01 May 2012 19:52:57 -0500</pubDate><guid>http://www.newsinapp.io/2012/05/01/how-build-news-aggregator-backbonejs-part-2/</guid><enclosure url="http://static.newsinapp.io/static/uploads/zinnia/backbone2/ViewExplanation.jpg" length="100000" type="image/jpeg"></enclosure><category>Tutorials</category></item><item><title>How to build a news aggregator with Dojo
</title><link>http://www.newsinapp.io/2012/04/04/how-build-news-aggregator-dojo/</link><description>	&lt;p&gt;Nowadays many websites display twitter widgets with good or bad moods of their authors. I told myself that it was not bad at all, but I think better things could be done.&lt;/p&gt;

	&lt;p&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/dojo/emmett-brown.png" style="zoom:0.55;float:right;margin-left:20px;" title="Emmett Brown" alt="Emmett Brown" /&gt; And this morning, I was standing on the edge of my toilet hanging a clock, the porcelain was wet, I slipped, hit my head on the sink, and when I came to I had a revelation! A vision! A picture in my head! A picture of this! &lt;del&gt;This is what makes time travel possible: the flux capacitor!&lt;/del&gt; This is what displays news on subjects I am interested in: a Dojo widget!&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;

	&lt;p&gt;This is what I needed to realize it:&lt;br /&gt;Dojo Toolkit, a modular JavaScript library for building cross-platform desktop and mobile web applications.&lt;br /&gt;And NewsinApp.io, a free service making possible to get aggregated news on subjects. It’s perfect to feed my widget.&lt;/p&gt;

	&lt;p&gt;Just before I start, here is what we will build:&lt;br /&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/dojo/widget2.png" title="news aggregator widget" alt="news aggregator widget" /&gt; &lt;img src="http://static.newsinapp.io/static/uploads/zinnia/dojo/widget1.png" title="news aggregator widget" alt="news aggregator widget" /&gt; &lt;/p&gt;

	&lt;p&gt;Two widgets displaying respectively the latest news about Johnny Depp and Tim Burton.&lt;br /&gt;&lt;a href="http://static.newsinapp.io/static/demo_dojo/" title="Live demo" target="_blank"&gt;Live demo&lt;/a&gt;&lt;br /&gt;&lt;a href="http://static.newsinapp.io/static/uploads/zinnia/dojo/dojo-widget.zip" title="The source code of the article"&gt;The source code of the article&lt;/a&gt;&lt;/p&gt;

	&lt;h1&gt;Newsinapp.io, huh ?&lt;/h1&gt;

	&lt;p&gt;&lt;a href="http://newsinapp.io" title="newsinapp.io website" target="_blank"&gt;Newsinapp.io&lt;/a&gt; is a &lt;span class="caps"&gt;REST&lt;/span&gt; &lt;span class="caps"&gt;API&lt;/span&gt; allowing us to get news from topics. Each topic is associated with a context (arts, games, health &amp;#8230;), so news provided are more relevant. &lt;br /&gt;For example, when I define the Tim Burton topic, I associate it to the arts/movies context (or entity as they call it). Same if I define a Dojo topic, I can use the computers entity.&lt;/p&gt;

	&lt;p&gt;To use this &lt;span class="caps"&gt;API&lt;/span&gt;, I have subscribed to their website, then I have received an access key. So I could define all topics I’m interested in. In my case: Tim Burton and Johnny Depp.&lt;/p&gt;

	&lt;h1&gt;Karate lesson with Dojo&lt;/h1&gt;

	&lt;p&gt;It’s time to get some news.&lt;br /&gt;To communicate with newsinapp.io, I use the Dojo &lt;span class="caps"&gt;XHR&lt;/span&gt; module which allows &lt;span class="caps"&gt;AJAX&lt;/span&gt; request.&lt;/p&gt;
&lt;pre class="brush: js"&gt;require([&amp;#34;dojo/_base/xhr&amp;#34;], function(xhr){
  var def = xhr.get({
    headers: {&amp;#39;X-Requested-With&amp;#39;: null},
    url: &amp;#34;http://api.newsinapp.io/topics/news/v1/&amp;#34;,
    handleAs: &amp;#34;json&amp;#34;,
    content : { page: &amp;#34;1&amp;#34;,   
                auth_api_key: &amp;#34;your_newsinapp_api_key&amp;#34;}
  });
  def.then(function(response){
    callback(response);
  });
});
&lt;/pre&gt;

	&lt;p&gt;&lt;code&gt;xhr.get&lt;/code&gt; makes a &lt;span class="caps"&gt;HTTP&lt;/span&gt; &lt;span class="caps"&gt;GET&lt;/span&gt; request. It takes some parameters:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;&lt;em&gt;url&lt;/em&gt;: resource to get.&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;content&lt;/em&gt;: parameters to pass to resource url&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;Example of response displayed in the Chrome console:&lt;br /&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/dojo/chrome-result.png" title="ajax request response in chrome" alt="ajax request response in chrome" /&gt;&lt;/p&gt;

	&lt;p&gt;Great Scott!!  20 news about Tim Burton and Johnny Depp!&lt;/p&gt;

	&lt;p&gt;But according to Dojo, &lt;span class="caps"&gt;XHR&lt;/span&gt;.get should not be able to do a cross-domain request. And yet it works! It’s because newsinapp.io is compatible &lt;span class="caps"&gt;CORS&lt;/span&gt; (Cross-Origin Resource Sharing). This is a web browser technology specification, which defines ways for a web server to allow its resources to be accessed by a web page from a different domain.&lt;br /&gt;However to be compatible with &lt;span class="caps"&gt;CORS&lt;/span&gt;, &lt;span class="caps"&gt;XHR&lt;/span&gt; request must have the following parameter: &lt;code&gt;headers: {'X-Requested-With': null}&lt;/code&gt; (&lt;a href="http://stackoverflow.com/questions/8300355/networkerror-405-method-not-allowed-to-get-user-info-via-google-api" title="CORS Dojo and X-Requested-With" target="_blank"&gt;More details on &lt;span class="caps"&gt;CORS&lt;/span&gt;, Dojo and X-Requested-With&lt;/a&gt;)&lt;/p&gt;

	&lt;h1&gt;And now … the widget!&lt;/h1&gt;

	&lt;p&gt;I put in a Dojo module all files that compose the widget:&lt;br /&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/dojo/files.png" title="dojo module organization" alt="dojo module organization" /&gt;&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;&lt;em&gt;Index.html&lt;/em&gt;: html page sample&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;Client.js&lt;/em&gt;: class which enables access to newsinApp.io&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;NewsListWidget.js&lt;/em&gt;: class of the widget&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;NewsListWidget.html&lt;/em&gt;: html template&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;I begin with the class that defines the widget:&lt;/p&gt;
&lt;pre class="brush: js"&gt;define([ &amp;#34;dijit/_WidgetBase&amp;#34;,
         &amp;#34;dojox/dtl/_Templated&amp;#34;,
         &amp;#34;dojo/_base/declare&amp;#34;,
         &amp;#34;dojo/text!./NewsListWidget.html&amp;#34;,
         &amp;#34;dojox/dtl/tag/logic&amp;#34;
          ],
  function(_WidgetBase, _Templated, declare, template){
    return declare([_WidgetBase, _Templated], {
      newsList: null,
...
      templateString: template,
...
    });
  });
&lt;/pre&gt;

	&lt;p&gt;Not so much code here, but some explanation is required.&lt;/p&gt;

	&lt;p&gt;The class inherits from:
	&lt;ul&gt;
		&lt;li&gt;dijit/_WidgetBase, to have the taste of a widget&lt;/li&gt;
		&lt;li&gt;dojox/dtl/_Templated, to have &lt;span class="caps"&gt;HTML&lt;/span&gt; rendering using a template&lt;/li&gt;
	&lt;/ul&gt;&lt;/p&gt;

	&lt;p&gt;The widget read the &lt;span class="caps"&gt;HTML&lt;/span&gt; template from &lt;code&gt;templateString&lt;/code&gt; variable. And &lt;code&gt;dojo/text!&lt;/code&gt; loads the content of the file NewsListWidget.html in &lt;code&gt;templateString&lt;/code&gt;. It allows to avoid having the template directly into the JavaScript code.&lt;/p&gt;

	&lt;p&gt;&lt;code&gt;newslist&lt;/code&gt; variable is important here because it contains the list of news coming from newsinapp.io.&lt;/p&gt;

	&lt;h1&gt;The template&amp;#8230; or how to dress our widget&lt;/h1&gt;

	&lt;p&gt;What I like with templates is the ability to separate code and presentation. On one side, I have my widget with data and logic, on the other I have my template for the design.&lt;br /&gt;To define &lt;span class="caps"&gt;HTML&lt;/span&gt; template, Dojo has it’s own implementation of the django template language (&lt;span class="caps"&gt;DTL&lt;/span&gt;).&lt;/p&gt;

	&lt;p&gt;The &lt;span class="caps"&gt;HTML&lt;/span&gt; template in NewsListWidget.html:&lt;/p&gt;
&lt;pre class="brush: xml"&gt;&amp;#60;div class=&amp;#34;feed-box&amp;#34;&amp;#62;
  &amp;#60;div class=&amp;#34;header&amp;#34;&amp;#62;
    &amp;#60;h3&amp;#62;{{ title }}&amp;#60;h3&amp;#62;
  &amp;#60;/div&amp;#62;

{% for news in newsList %}

  {% if news.image %}
  &amp;#60;div class=&amp;#34;media&amp;#34;&amp;#62;
    &amp;#60;div class=&amp;#34;img-container&amp;#34;&amp;#62;
      &amp;#60;img src=&amp;#34;{{ news.image }}&amp;#34; /&amp;#62;
    &amp;#60;/div&amp;#62;
  {% else %}
  &amp;#60;div class=&amp;#34;media no-image&amp;#34;&amp;#62;
  {% endif %}
    {% if news.title %}
    &amp;#60;a href=&amp;#34;{{ news.url }}&amp;#34; target=&amp;#34;_blank&amp;#34;&amp;#62;{{ news.title }}&amp;#60;/a&amp;#62;
    {% endif %}
    {% if news.source %}
    &amp;#60;p class=&amp;#34;source&amp;#34;&amp;#62;{{ news.source }}&amp;#60;/p&amp;#62;
    {% endif %}
    &amp;#60;div class=&amp;#34;footer&amp;#34;&amp;#62;&amp;#60;/div&amp;#62;
  &amp;#60;/div&amp;#62;

{% endfor %}

&amp;#60;/div&amp;#62;
&lt;/pre&gt;

	&lt;p&gt;The template can use variables defined in the widget class. So &lt;code&gt;{{ title }}&lt;/code&gt; displays the member title of the widget. And the loop &lt;code&gt;{% for news in newsList %}&lt;/code&gt; allows to display each news using member &lt;code&gt;newsList&lt;/code&gt;.&lt;/p&gt;

	&lt;p&gt;To use template tag if and for, I have to include a dependency to the module dojox/dtl/tag/logic. For tag such as &lt;code&gt;now&lt;/code&gt; or &lt;code&gt;extends&lt;/code&gt;, &lt;a href="http://dojotoolkit.org/reference-guide/1.7/releasenotes/1.7.html#limitations" title="DTL Dojo modules" target="_blank"&gt;other modules&lt;/a&gt; must be added.&lt;/p&gt;

	&lt;h1&gt;We approach 88 mph&lt;/h1&gt;

	&lt;p&gt;Last step, creating the widget:&lt;/p&gt;
&lt;pre class="brush: js"&gt;require([&amp;#34;newsinapp.io/Client&amp;#34;, &amp;#34;newsinapp.io/NewsListWidget&amp;#34;, 
         &amp;#34;dojo/dom&amp;#34;, &amp;#34;dojo/_base/array&amp;#34;, &amp;#34;dojo/domReady!&amp;#34;],
  function(NewsinappioClient, NewsListWidget, dom, arrayUtil){

    var newsinapp = new NewsinappioClient(&amp;#39;your_newsinapp_api_key&amp;#39;);

    newsinapp.getLastNews(function(response) { 
      var container;
      container = dom.byId(&amp;#34;newsListWidgetContainer&amp;#34;);

      new NewsListWidget({title: &amp;#34;Johnny Depp - Latest news&amp;#34;,
                          newsinappResponse: response,
                          topicFilter: &amp;#34;Johnny Depp&amp;#34;}).placeAt(container);;
    });
  });
&lt;/pre&gt;

	&lt;p&gt;Some explanations to understand this code:&lt;/p&gt;

	&lt;p&gt;First, NewsInAppioClient class retrieves the list of news to pass them to the Widget. Then, the Widget filters only news referring to Johnny Deep (topicFilter). And finally, the method placeAt renders the Widget where the &lt;span class="caps"&gt;HTML&lt;/span&gt; tag with ID &lt;code&gt;newsListWidgetContainer&lt;/code&gt; is located.&lt;/p&gt;

	&lt;h1&gt;Back to the future!&lt;/h1&gt;

	&lt;p&gt;And voila! It’s already finished for this article. Finally, it was not too hard: we have a widget that can be placed on any &lt;span class="caps"&gt;HTML&lt;/span&gt; page, with news on personalized topics!&lt;/p&gt;
</description><author>wesleyfr@gmail.com (wesley)</author><pubDate>Wed, 04 Apr 2012 23:31:00 -0500</pubDate><guid>http://www.newsinapp.io/2012/04/04/how-build-news-aggregator-dojo/</guid><enclosure url="http://static.newsinapp.io/static/uploads/zinnia/dojo/emmett-brown.png" length="100000" type="image/jpeg"></enclosure><category>Tutorials</category></item><item><title>Easy to change a domain name ?
</title><link>http://www.newsinapp.io/2012/04/04/easy-change-domain-name/</link><description>	&lt;p&gt;&lt;em&gt;Two domain names and a ruthless man meet together in the cloud. They are deliberating on an important change that affect all of three.&lt;/em&gt;&lt;/p&gt;

	&lt;p&gt;&lt;ins&gt;Topics.io&lt;/ins&gt;: So young, and already having to change your domain name, but why do you renounce me? You hate me so much? I am not good enough for you?&lt;/p&gt;

	&lt;p&gt;&lt;ins&gt;A ruthless man&lt;/ins&gt;: You must understand. You are a nice domain name. But, we had no choice. The web site retrieves news for our users to integrate them into their applications. In short, our users want news and not topics. So we do not need you anymore.&lt;/p&gt;

	&lt;p&gt;&lt;ins&gt;Newsinapp.io&lt;/ins&gt;: And, now, go to park somewhere else. You are disturbing me. I&amp;#8217;m important now.&lt;/p&gt;

	&lt;p&gt;&lt;em&gt;topics.io shrugs of the shoulders&lt;/em&gt;&lt;br /&gt;&lt;ins&gt;Topics.io&lt;/ins&gt;: Pfft, my ranking is better than yours.&lt;/p&gt;

	&lt;p&gt;&lt;ins&gt;Newsinapp.io&lt;/ins&gt;: I do not speak with old domain names.&lt;/p&gt;

	&lt;p&gt;Well, you have understood&amp;#8230; newsinapp.io is our new domain name. We quickly dried our little tear to go back to our labs. We are preparing some new posts. And, our mad scientists work on their machine learning, &lt;span class="caps"&gt;NLP&lt;/span&gt; and other spells.&lt;/p&gt;

	&lt;p&gt;See you later on &lt;a href="http://newsinapp.io"&gt;newsinapp.io&lt;/a&gt;&lt;/p&gt;
</description><author>didier.rano@gmail.com (didier)</author><pubDate>Wed, 04 Apr 2012 08:21:11 -0500</pubDate><guid>http://www.newsinapp.io/2012/04/04/easy-change-domain-name/</guid></item><item><title>How to build a news aggregator with backbone.js - Part 1
</title><link>http://www.newsinapp.io/2012/03/15/how-build-news-aggregator-backbonejs-part-1/</link><description>	&lt;p&gt;In this post and the following, we will build a news aggregator in an unique page using &lt;a href="http://documentcloud.github.com/backbone/"&gt;backbone.js&lt;/a&gt;. By unique page, I mean that all user interactivities will be only in one &lt;span class="caps"&gt;HTML&lt;/span&gt; page, and backend server will provide only data and no &lt;span class="caps"&gt;HTML&lt;/span&gt; tags. Finally, fed by news, this application will use an &lt;span class="caps"&gt;API&lt;/span&gt; RESTful, &lt;a href="http://newsinapp.io"&gt;http://newsinapp.io&lt;/a&gt;&lt;/p&gt;

	&lt;p&gt;backbone.js is a &lt;span class="caps"&gt;MVC&lt;/span&gt; framework in Javascript. A new quirk? A plaything for skilled developers? A fancy of a few gurus in javascript? I&amp;#8217;m probably not the only person who thinks it. So I decided to look at it in hope of acquiring new knowledge.  In fact, I&amp;#8217;m often surprised with Javascript. I had been impressed with jQuery &amp;#8230; Backbone.js is definitely another surprise. The kind of surprise that makes me say &amp;#8220;I am old with my Python&amp;#8221;. So the old man, he will keep his Python anyway, and he will get serious in Javascript.&lt;/p&gt;

	&lt;p&gt;Then, what is backbone.js ? This framework provides four features
	&lt;ul&gt;
		&lt;li&gt;&lt;strong&gt;Models&lt;/strong&gt; as a class and key-values properties&lt;/li&gt;
		&lt;li&gt;&lt;strong&gt;Collections&lt;/strong&gt; of models&lt;/li&gt;
		&lt;li&gt;&lt;strong&gt;Views&lt;/strong&gt; which are populated and updated via events raised by models&lt;/li&gt;
		&lt;li&gt;All data could be synchronized with RESTful &lt;span class="caps"&gt;JSON&lt;/span&gt; interface. And, for me, this last feature is the most important.&lt;/li&gt;
	&lt;/ul&gt;&lt;/p&gt;

	&lt;p&gt;To build this news aggregator, we are not going to implement a new &lt;span class="caps"&gt;RSS&lt;/span&gt; or &lt;span class="caps"&gt;ATOM&lt;/span&gt; parser, or implement a web crawler more efficient than Google (You have to wait the next post). In fact, we will use newsinapp.io &lt;span class="caps"&gt;API&lt;/span&gt;. It will provide news, and backbone.js will make life easier to display these news in a web page.&lt;/p&gt;

	&lt;p&gt;Actually in private alpha, &lt;a href="http://newsinapp.io"&gt;http://newsinapp.io&lt;/a&gt; allows to define custom topics, and retrieve news about them. A topic is associated with a context to improve the quality/relevance of news. So, the &amp;#8220;&lt;em&gt;backbone.js&lt;/em&gt;&amp;#8220; topic will be associated with the &amp;#8220;&lt;em&gt;computers&lt;/em&gt;&amp;#8220; entity. And, the &amp;#8220;&lt;em&gt;Tim Burton&lt;/em&gt;&amp;#8220; topic will be associated with the &amp;#8220;&lt;em&gt;arts/movies&lt;/em&gt;&amp;#8220; entity.&lt;/p&gt;

	&lt;p&gt;Here, an example to retrieve the latest news&lt;br /&gt;&lt;pre class="brush: bash"&gt;curl 'http://api.newsinapp.io/topics/news/v1/?auth_api_key=API Key'&lt;/pre&gt;&lt;/p&gt;

	&lt;p&gt;And the &lt;span class="caps"&gt;JSON&lt;/span&gt; response:&lt;/p&gt;

&lt;pre class="brush: js"&gt;
{
   'topic':
   {
     'entities': [ 'arts' ],
     'displayName': 'tim burton',
     'id': '3144'
   },
   'relevanceRate': 1,
   'subTitle': 'New pic of Johnny Depp and Eva Green...',
   'title': 'New pic of Johnny Depp and Eva Green from Tim Burton''s Dark Shadows',
   'source': 'joblo.com',
   ...
}
&lt;/pre&gt;

	&lt;p&gt;Now, to begin with the end, here the backbone news aggregator &lt;span class="caps"&gt;URL&lt;/span&gt; that we will build in this article (and follow by others parts): &lt;a href="http://static.newsinapp.io/static/demo_backbone/index.html"&gt;Demo with backbone&lt;/a&gt;&lt;/p&gt;

	&lt;p&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/johnny.png" title="Demonstration Screenshot" alt="Demonstration Screenshot" /&gt;&lt;/p&gt;

	&lt;p&gt;This web site contains an unique &lt;span class="caps"&gt;HTML&lt;/span&gt; page. Then, you don’t need to deploy a Django, node.js or others servers frameworks. You only need to put on your server: one web page and some &lt;span class="caps"&gt;CSS&lt;/span&gt;, javascripts files.&lt;/p&gt;

	&lt;p&gt;In short, everything starts with an index.html file. In this &lt;span class="caps"&gt;HTML&lt;/span&gt;, some javascripts have to be loaded:&lt;/p&gt;

&lt;pre class="brush: xml"&gt;
&amp;lt;script src="javascripts/vendor/jquery.js"/&amp;gt;
&amp;lt;script src="javascripts/vendor/underscore.js"/&amp;gt;
&amp;lt;script src="javascripts/vendor/backbone.js"/&amp;gt;
&amp;lt;script src="javascripts/news.js"/&amp;gt;
&lt;/pre&gt;

	&lt;ul&gt;
		&lt;li&gt;&lt;em&gt;jquery.js&lt;/em&gt;: If you want, you could avoid to use jquery, but it is inevitable for me !&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;underscore.js&lt;/em&gt;: A backbone.js dependency. I am too happy to re-discover map and filter functions as my old friend Python !&lt;/li&gt;
		&lt;li&gt;&lt;em&gt;news.js&lt;/em&gt;: We will write all our custom javascript codes in this separate file.&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;Then, in this new.js file, some magic incantations are needed. Now, we will focus only on javascript code:&lt;/p&gt;

&lt;pre class="brush: js"&gt;
(function() {
    jQuery(function($) {
    // Where is my javascript code ?
    }); 
}).call(this);
&lt;/pre&gt;

	&lt;p&gt;Phew ! &lt;/p&gt;

	&lt;p&gt;Now, we can write some lines of code using backbone.js. &lt;/p&gt;

	&lt;p&gt;First, we need to create the model to store each news:&lt;/p&gt;

&lt;pre class="brush: js"&gt;
window.NewsItem = Backbone.Model.extend({});
&lt;/pre&gt;

	&lt;p&gt;That&amp;#8217;s all ? Interesting things begin when create the collection:&lt;/p&gt;

	&lt;p&gt;&lt;pre class="brush: js"&gt;
    window.NewsCollection = Backbone.Collection.extend({
        model: NewsItem,&lt;/p&gt;

        public_api_key : 'A public api key from newsinapp.io&amp;#8217;,
        url_base : 'http://api.newsinapp.io/topics/news/v1/?page=1&amp;auth_api_key=&amp;#8217;,

        url: function() {
            return this.url_base + this.public_api_key
        },

        parse: function(response) {
            return response.response.news;
        }
    });
&lt;/pre&gt;

	&lt;p&gt;How can we test this collection and this model ? The javascript console integrated with Chrome, or Firebug inside the web browser Firefox.&lt;/p&gt;

	&lt;p&gt;In Chrome, load the &lt;span class="caps"&gt;HTML&lt;/span&gt; page just created. And, you could follow next operations:&lt;/p&gt;

	&lt;ul&gt;
		&lt;li&gt;Select the &lt;em&gt;Wrench&lt;/em&gt; menu &lt;em&gt;Tools -&gt; Developer tools&lt;/em&gt;.&lt;/li&gt;
		&lt;li&gt;Right-click on any page element and select &lt;em&gt;Inspect element&lt;/em&gt;.&lt;/li&gt;
		&lt;li&gt;Click on &lt;em&gt;Console&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;

	&lt;p&gt;Now, we are ready to create an instance of our new collection in the javascript console:&lt;/p&gt;

	&lt;p&gt;&lt;img src="http://static.newsinapp.io/static/uploads/zinnia/console.png" title="Console in Chrome" alt="Console in Chrome" /&gt;&lt;/p&gt;

	&lt;p&gt;And yes, the post is finished !! ;) Well, I&amp;#8217;ll provide some explanation. Collections make a link between the model News and information provided by the RESTful service newsinapp.io. The &lt;strong&gt;fetch()&lt;/strong&gt; method allows to update the list of news. Then, you can see that we have retrieved 20 news (&lt;em&gt;“length: 20”&lt;/em&gt;), and all news have some attributes as source, title or subtitle.&lt;/p&gt;

	&lt;p&gt;However, by default, Backbone.js does not know the &lt;span class="caps"&gt;API&lt;/span&gt; newsinapp.io. To solve this problem, we need to manage two steps. First, the &lt;strong&gt;url()&lt;/strong&gt; method provides the &lt;span class="caps"&gt;API&lt;/span&gt; location. Second, we need to implement parse() method. It is a mapping between &lt;span class="caps"&gt;JSON&lt;/span&gt; response and News model. In this case, from &lt;span class="caps"&gt;JSON&lt;/span&gt;, the news list can be found in path &amp;#8216;response/news&amp;#8217; (xpath syntax):&lt;/p&gt;

&lt;pre class="brush: js"&gt;
parse: function(response) {
    return response.response.news;
}
&lt;/pre&gt;

	&lt;p&gt;Magic ? But, wait a moment. I cannot call a &lt;span class="caps"&gt;JSON&lt;/span&gt; RESTful api on my web site, if this api is provided from an other web domain: “the &lt;span class="caps"&gt;URL&lt;/span&gt; replying to the request must reside within the same &lt;span class="caps"&gt;DNS&lt;/span&gt; domain as the server that hosts the page containing the request”. Usually, &lt;a href="http://en.wikipedia.org/wiki/JSONP"&gt;JSONP&lt;/a&gt; should be the solution for this problem. But, not really a beautiful solution ! &lt;/p&gt;

	&lt;p&gt;In this case, &lt;a href="http://newsinapp.io/"&gt;newsinapp.io&lt;/a&gt; is &lt;a href="http://en.wikipedia.org/wiki/Cross-origin_resource_sharing"&gt;CORS&lt;/a&gt; compatible . Then, nothing to do. It works.&lt;/p&gt;

	&lt;p&gt;That’s all for today ! Feel free to make your comments (at least constructively;)). This is my first post&amp;#8230;&lt;/p&gt;

	&lt;p&gt;&lt;strong&gt;Next part&lt;/strong&gt;: Using backbone views&lt;/p&gt;
</description><author>didier.rano@gmail.com (didier)</author><pubDate>Thu, 15 Mar 2012 20:21:46 -0500</pubDate><guid>http://www.newsinapp.io/2012/03/15/how-build-news-aggregator-backbonejs-part-1/</guid><enclosure url="http://static.newsinapp.io/static/uploads/zinnia/johnny.png" length="100000" type="image/jpeg"></enclosure><category>Tutorials</category></item></channel></rss>