Permalink
Browse files

added latest tweets on the home page

  • Loading branch information...
mattetti committed Apr 19, 2011
1 parent 4acf5f9 commit 9b09c562698f00a10fb6978d937494f590d57fd4
Showing with 57 additions and 15 deletions.
  1. +1 −1 content/_standard-head.txt
  2. +17 −14 content/index.txt
  3. +39 −0 content/javascripts/blogger.js
@@ -5,7 +5,7 @@ filter: erb
<script type="text/javascript" src="/javascripts/jquery-1.5.2.js"></script>
<script type="text/javascript" src="/javascripts/scripts.js"></script>
-<script>
+<script type='text/javascript'>
$(document).ready(function() {
$(".equalHeights1").equalHeights(200,600);
$(".equalHeights2").equalHeights(200,600);
View
@@ -49,28 +49,31 @@ filter:
<h2 class="headerText1 lobsterFont"><img class="gridIcon3" src="../images/icon_notebook.png" alt="#" />The Definitive Guide</h2>
<div class="gridContent boxed equalHeights2">
<div class="padding15">
- Matt Aimonetti is currently working on a MacRuby book for O'Reilly. It is under development and the book is being published as it is being written. The work is released under a <a href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative Commons</a> license, with the idea of getting early feedback from the community.
- <br/><a href="http://macruby.labs.oreilly.com/">Check it out!</a>
+<!-- <img src="http://covers.oreilly.com/images/0636920000723/rc_s.gif" alt="MacRuby Book by Matt Aimonetti" style="float:left; padding:0.5em 1em 0 0"> -->
+<a href="http://merbist.com">Matt Aimonetti</a> is currently working on
+a <a href="http://oreilly.com/catalog/0636920000723/">MacRuby book for
+O'Reilly</a>. It is under development and the book is being published as
+it is being written. The work is released under a <a
+href="http://creativecommons.org/licenses/by-nc-nd/3.0/us/">Creative
+Commons</a> license, with the idea of getting early feedback from the
+community.<br/>
+<a href="http://oreilly.com/catalog/0636920000723/">Check it out!</a>
</div>
</div>
</aside>
<aside>
- <h2 class="headerText1 lobsterFont"><img class="gridIcon4" src="../images/icon_cloud.png" alt="#" />MacRuby Blogs</h2>
- <div class="gridContent boxed equalHeights2">
- <div class="abstract padding15">
- <h3 class="headerText1"><a href="#">Blog Item 1</a><span class="date">2010-10-08</span></h3>
- A new development version of the <a href="http://bridgesupport.macosforge.org/trac/wiki">BridgeSupport</a> project, now based on the clang/<span class="caps">LLVM</span> compiler framework, is available for testing!<br />
- <a href='/blog/2010/10/08/bridgesupport-preview.html'>Read more&#8230;</a>
- </div>
- <div class="abstract padding15">
- <h3 class="headerText1"><a href="#">Blog Item 2</a><span class="date">2010-10-08</span></h3>
- A new development version of the <a href="http://bridgesupport.macosforge.org/trac/wiki">BridgeSupport</a> project, now based on the clang/<span class="caps">LLVM</span> compiler framework, is available for testing!<br />
- <a href='/blog/2010/10/08/bridgesupport-preview.html'>Read more&#8230;</a>
- </div>
+ <h2 class="headerText1 lobsterFont"><img class="gridIcon4"
+src="../images/icon_cloud.png" alt="#" />Latest Tweets</h2>
+ <div class="gridContent boxed equalHeights2" >
+ <ul id='twitter_update_list'></ul>
</div>
</aside>
</div>
</div>
+
+<script type="text/javascript" src="/javascripts/blogger.js"</script>
+<script type="text/javascript"
+src="http://twitter.com/statuses/user_timeline/macruby.json?callback=twitterCallback2&count=5"></script>
@@ -0,0 +1,39 @@
+function twitterCallback2(twitters) {
+ var statusHTML = [];
+ for (var i=0; i<twitters.length; i++){
+ var username = twitters[i].user.screen_name;
+ console.log(username)
+ var status = twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g, function(url) {
+ return '<a href="'+url+'">'+url+'</a>';
+ }).replace(/\B@([_a-z0-9]+)/ig, function(reply) {
+ return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
+ });
+ statusHTML.push('<li class="abstract padding15"><span>'+status+'</span> <a style="font-size:85%" href="http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'">'+relative_time(twitters[i].created_at)+'</a></li>');
+ }
+ document.getElementById('twitter_update_list').innerHTML = statusHTML.join('');
+}
+
+function relative_time(time_value) {
+ var values = time_value.split(" ");
+ time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
+ var parsed_date = Date.parse(time_value);
+ var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
+ var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
+ delta = delta + (relative_to.getTimezoneOffset() * 60);
+
+ if (delta < 60) {
+ return 'less than a minute ago';
+ } else if(delta < 120) {
+ return 'about a minute ago';
+ } else if(delta < (60*60)) {
+ return (parseInt(delta / 60)).toString() + ' minutes ago';
+ } else if(delta < (120*60)) {
+ return 'about an hour ago';
+ } else if(delta < (24*60*60)) {
+ return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
+ } else if(delta < (48*60*60)) {
+ return '1 day ago';
+ } else {
+ return (parseInt(delta / 86400)).toString() + ' days ago';
+ }
+}

0 comments on commit 9b09c56

Please sign in to comment.