tweetWidget : display better information, if available popcorn-port
authorhamidouk
Mon, 21 Nov 2011 15:17:11 +0100
branchpopcorn-port
changeset 293 314e6a13f841
parent 292 31773b5deb26
child 294 c553ce4d9d6b
tweetWidget : display better information, if available
src/js/widgets/tweetsWidget.js
src/templates/rich_tweet.html
--- a/src/js/widgets/tweetsWidget.js	Mon Nov 21 15:15:39 2011 +0100
+++ b/src/js/widgets/tweetsWidget.js	Mon Nov 21 15:17:11 2011 +0100
@@ -18,9 +18,20 @@
     if (typeof(img) === "undefined" || img === "" || img === "None") {
       img = IriSP.widgetsDefaults.TweetsWidget.default_profile_picture;
     }
+
+    var imageMarkup = Mustache.to_html("<img src='{{src}}' alt='user image'></img>", 
+                                       {src : img});
     
-    var imageMarkup = Mustache.to_html("<img src='{{src}}' alt='avatar'></img>", 
-                                       {src : img});
+    if (typeof(annotation.meta["dc:source"].content) !== "undefined") {
+      var tweetContents = JSON.parse(annotation.meta["dc:source"].content);
+      var creator = tweetContents.user.screen_name;
+      
+      imageMarkup = Mustache.to_html("<a href='http://twitter.com/{{creator}}'><img src='{{src}}' alt='user image'></img></a>", 
+                                       {src : img, creator: creator});
+            
+      title = Mustache.to_html(IriSP.rich_tweet_template, {contents : title, date : tweetContents.created_at});
+      console.log(title);
+    }
 
     this.selector.find(".Ldt-tweetContents").html(title);
     this.selector.find(".Ldt-tweetAvatar").html(imageMarkup);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/templates/rich_tweet.html	Mon Nov 21 15:17:11 2011 +0100
@@ -0,0 +1,7 @@
+{{! template of a "rich" tweet displayed by the tweetsWidget 
+    It's used only when we have access to the twitter api data (normally stored into
+    dc:source.content)
+}}
+
+<div class='Ldt-tweet_tweetContents'>{{ contents }}</div>
+<div class='Ldt-tweet_date'>{{ date }}</div>
\ No newline at end of file