Permalink
Browse files

Adds Twitter status under header

  • Loading branch information...
1 parent 2f01112 commit 165e9c1633545574fb61f6844f03a5173d7d09d4 @jschementi committed Jul 2, 2010
Showing with 66 additions and 6 deletions.
  1. +0 −1 TODO
  2. +14 −4 app.rb
  3. +26 −0 public/app.js
  4. +6 −0 public/index.html
  5. +20 −1 public/style.css
View
1 TODO
@@ -1,4 +1,3 @@
-URGENT Twitter feed (last thing I said right under my name?)
URGENT About page
URGENT more thought-through sitemap
URGENT footer
View
18 app.rb
@@ -9,10 +9,20 @@
File.open('public/index.html'){ |f| f.read }
end
-get '/blog.rss' do
- content_type 'application/xml', :charset => 'utf-8'
- res = Net::HTTP.start("feeds.feedburner.com", 80) { |http|
- http.get('/jimmy-thinking')
+def get_feed(url)
+ url = URI.parse(url)
+ res = Net::HTTP.start(url.host, url.port) { |http|
+ http.get(url.path)
}
res.body
+end
+
+get '/blog.rss' do
+ content_type 'application/xml', :charset => 'utf-8'
+ get_feed 'http://feeds.feedburner.com/jimmy-thinking'
+end
+
+get '/twitter.rss' do
+ content_type 'application/xml', :charset => 'utf-8'
+ get_feed 'http://twitter.com/statuses/user_timeline/8007442.rss'
end
View
@@ -30,8 +30,10 @@ var navigateTo = function(topic) {
if (!isHome()) {
hideBackground();
+ $("#twitter-status").hide();
} else {
showBackground();
+ $("#twitter-status").show();
}
actualTopic = topic.replace(/^\//, '++')
@@ -112,6 +114,30 @@ var generateBlogFeed = function() {
});
}
+var noAtMsgs = true;
+
+var generateTwitterMsg = function() {
+ $(document).ready(function() {
+ jQuery.getFeed({ url: '/twitter.rss', success: function(feed) {
+ for (i = 0; i < feed.items.length; i++) {
+ item = feed.items[i];
+ msg = item.title.split("jschementi: ")[1];
+ if (!noAtMsgs || msg[0] != "@") {
+ status = $(document.createElement('span')).html("&ldquo;" + msg + "&rdquo;&nbsp;");
+ link = $(document.createElement('a')).
+ attr('href', 'http://twitter.com/jschementi').
+ attr('target', "_blank").
+ attr('title', 'follow jschementi on Twitter').
+ html("follow me on Twitter &raquo;");
+ $('#twitter-status').html(status);
+ $('#twitter-status').append(link);
+ break;
+ }
+ }
+ }});
+ });
+}
+
var renderBlogPost = function(post) {
post_div = $('#blog_post_template li').clone();
post_div.find('a.rss_item').html(post.title);
View
@@ -52,6 +52,12 @@
</div>
</div>
+ <div id="twitter-status">
+ <script type="text/javascript">
+ generateTwitterMsg();
+ </script>
+ </div>
+
<div id="body">
<div id='home' class='topic' style="display: none">
View
@@ -92,7 +92,11 @@ a:hover {
#sanfran div.island p.islandMouseOver {
color: white;
}
-
+
+ #sanfran #twitter-status {
+ background-image:url(images/black-transparent.png);
+ }
+
/* formal theme */
body#formal {
@@ -138,6 +142,10 @@ a:hover {
#formal div.island p.islandMouseOver {
color: white;
}
+
+ #formal #twitter-status {
+ background-image:url(images/black-transparent.png);
+ }
/* guitar theme */
@@ -160,6 +168,10 @@ a:hover {
color: black;
}
+ #guitar #twitter-status {
+ background-image:url(images/white-transparent.png);
+ }
+
/* header styles */
body li.rss_item.islandMouseOver,
@@ -191,6 +203,13 @@ a:hover {
color: #444;
}*/
+ #page #twitter-status {
+ font-size:1.3em;
+ margin-left:1.2em;
+ margin-top:0.3em;
+ padding:0.3em;
+ }
+
/* site main menu */
ul#main-menu {

0 comments on commit 165e9c1

Please sign in to comment.