Browse code

added sidebar partial, updated twitter style, handling linebreaks with paragraphs

B Mathis authored on 08/11/2009 at 01:24:09
Showing 4 changed files
... ...
@@ -73,9 +73,9 @@ google_analytics: true
73 73
             = content
74 74
         #sidebar
75 75
           - if page.respond_to? :twitter_user
76
-            %h4 @#{page.twitter_user}
76
+            %h4 Twitter <a class="small" href="http://twitter.com/#{page.twitter_user}">@#{page.twitter_user}</a>
77 77
             #twitter
78
-              #twitter_status
78
+              %ul#twitter_status
79 79
                 Status updating...
80 80
     #footer
81 81
       .page_width
... ...
@@ -6,8 +6,15 @@
6 6
 // PrettyDate by John Resig at http://ejohn.org/files/pretty.js
7 7
 //
8 8
 
9
-var tweet_tag = 'p';
10
-var twitter_div = 'twitter_status';
9
+/*
10
+	Plugin:   	Octopress Twitter Feed
11
+	Author:   	Brandon Mathis
12
+	Website:    http://brandonmathis.com
13
+	Date:     	11/07/2009
14
+*/
15
+
16
+var tweet_container = 'li';
17
+var twitter_container = 'twitter_status';
11 18
 
12 19
 window.addEvent('domready',function() {
13 20
 	getTwitterStatus(twitter_user);
... ...
@@ -17,11 +24,13 @@ function showTweets(the_tweets, from_cookie){
17 17
   if(from_cookie){
18 18
     the_tweets = the_tweets.split('^!^!^!^!^');
19 19
   }
20
-  $(twitter_div).set('html', '');
20
+  $(twitter_container).set('html', '');
21 21
   the_tweets.each(function(tweet){
22
-    new Element(tweet_tag,{
23
-  		html: parseTweetDate(tweet)
24
-  	}).inject(twitter_div);
22
+    tweet = parseTweetDate(tweet)
23
+    tweet = '<p>' + tweet.replace(/\n\n/gi,'</p><p>') + '</p>';
24
+    new Element(tweet_container,{
25
+  		html: tweet
26
+  	}).inject(twitter_container);
25 27
   });
26 28
 }
27 29
 
... ...
@@ -52,7 +61,7 @@ function prettyDate(time){
52 52
 
53 53
 function getTwitterStatus(twitter_name){
54 54
   var tweet_cookie = 'tweets_by_' + twitter_name + tweet_count;
55
-  $(twitter_div).set('html', 'Fetching tweets...');
55
+  $(twitter_container).set('html', 'Fetching tweets...');
56 56
   if(!Cookie.read(tweet_cookie)) {
57 57
   	var myTwitterGitter = new TwitterGitter(twitter_name,{
58 58
   	  count: ((show_replies) ? tweet_count : 15 + tweet_count),
... ...
@@ -61,8 +70,6 @@ function getTwitterStatus(twitter_name){
61 61
   			tweets.each(function(tweet,i) {
62 62
   			  if((tweet.in_reply_to_status_id && show_replies) || !tweet.in_reply_to_status_id){
63 63
   			    if(the_tweets.length == tweet_count) return;
64
-  			    tweet.text = tweet.text.replace(/\n/gi, '<br/>');
65
-  			    console.log(tweet);
66 64
     			  the_tweets.push(tweet.text + '-!-!-!-' + tweet.created_at);
67 65
   				}
68 66
   			});
... ...
@@ -1,2 +1,3 @@
1 1
 @import partials/twitter.sass
2
-@import partials/search.sass
3 2
\ No newline at end of file
3
+@import partials/search.sass
4
+@import partials/sidebar.sass
4 5
\ No newline at end of file
... ...
@@ -4,13 +4,18 @@
4 4
   background: #f8f8f8
5 5
   border: 1px solid #eee
6 6
   padding: 5px 0
7
-  p
7
+  ul
8
+    list-style-type: none
9
+    margin: 0
10
+  li
8 11
     margin: 0 15px
9
-    padding: 12px 0
12
+    padding: 10px 0 0
10 13
     border-bottom: #ddd 1px dashed
11 14
     line-height: 1.625em
12 15
     &:last-child
13 16
       border-bottom: 0
17
+    p
18
+      padding-bottom: 10px
14 19
     .pubdate
15 20
       color= !light_text
16 21
       font-size: 80%