Browse code

udpated thirdparty integration, it is now conditionally added, updated readme

B Mathis authored on 07/11/2009 at 18:05:10
Showing 5 changed files
... ...
@@ -51,11 +51,12 @@ Kills the local web server process.
51 51
 
52 52
 ## Third Party Integration
53 53
 ### Twitter
54
-To configure your twitter feed, edit twitter.js where you can set:
54
+Twitter settings are at the top of _layouts/default.haml
55
+You can also change:
55 56
 
56
-- Account for the feed
57
-- Number of tweets to show
58
-- Show Mentions (true/false)
57
+    twitter_user: your_twitter_name
58
+    show_replies: false
59
+    tweet_count: 3
59 60
 
60 61
 ### Disqus Comments
61 62
 Octopress has built in support for the Disqus commenting system, using the "universal code" installation method. First register your site at [http://disqus.com/comments/register/](http://disqus.com/comments/register/) Then, to enable Disqus comments on your blog, edit the YAML block at the top of the default layout:
... ...
@@ -69,6 +70,9 @@ First setup sitesearch for your site at [http://google.com/sitesearch/](http://g
69 69
 ### Google Analytics
70 70
 The analytics tracking scripts are already integrated into Octopress, all you have to do is register your site at [http://google.com/analytics/](http://google.com/analytics/).
71 71
 
72
+### Removing Third party integrations
73
+All third party integration is conditionally included. All you have to do is remove the variable from the layout and you're done. If you like, you can also remove the include blocks from the default layout.
74
+
72 75
 ## Style Configuration
73 76
 ### What you need to know
74 77
 Octopress's stylesheets are written in [SASS](http://sass-lang.com). If you haven't learned SASS, you should. It's the future. Octopress also uses [Compass](http://compass-style.org) which is a framework for SASS and contains a great library of SASS mixins which make it trivial to write complicated CSS. This is also the future.
... ...
@@ -20,7 +20,7 @@ end
20 20
 
21 21
 desc "generate website in output directory"
22 22
 task :default => [:generate_site, :generate_style] do
23
-  puts ">>> Site Generating Complete! <<<"
23
+  puts ">>> Site Generating Complete! <<<\n\n"
24 24
 end
25 25
 
26 26
 desc "list tasks"
... ...
@@ -48,19 +48,20 @@ end
48 48
 
49 49
 desc "Generate site files only"
50 50
 task :generate_site => [:clean, :generate_style] do
51
-  puts ">>> Generating site files <<<"
51
+  puts "\n\n>>> Generating site files <<<"
52 52
   system "jekyll"
53 53
   system "mv #{site}/atom.html #{site}/atom.xml"
54 54
 end
55 55
 
56 56
 def rebuild_site(relative)
57
+  puts "\n"
57 58
   puts ">>> Change Detected to: #{relative} <<<"
58 59
   IO.popen('rake generate_site'){|io| print(io.readpartial(512)) until io.eof?}
59 60
   puts '>>> Update Complete <<<'
60 61
 end
61 62
 
62 63
 def rebuild_style(relative)
63
-  puts ">>> Change Detected to: #{relative} <<<"
64
+  puts "\n\n>>> Change Detected to: #{relative} <<<"
64 65
   IO.popen('rake generate_style'){|io| print(io.readpartial(512)) until io.eof?}
65 66
   puts '>>> Update Complete <<<'
66 67
 end
... ...
@@ -1,8 +1,15 @@
1 1
 ---
2 2
 blog_title: My Octopress Blog
3 3
 full_url:
4
+twitter_user: imathis
5
+tweet_count: 4
6
+show_replies: false
7
+
8
+disqus_short_name: 
9
+
4 10
 google_site_search_id: 
5
-disqus_short_name: designenthusiast
11
+google_analytics: true
12
+
6 13
 ---
7 14
 
8 15
 !!! 1.1 Transitional
... ...
@@ -15,19 +22,26 @@ disqus_short_name: designenthusiast
15 15
       %meta(name="keywords" content="#{page.keywords}")/
16 16
     %link(href="/stylesheets/screen.css" rel="stylesheet" media="screen projection" type="text/css")
17 17
     %link(href="/atom.xml" rel="alternate" title="#{page.blog_title}" type="application/atom+xml")
18
-    %script(src="/javascripts/mootools-yui-compressed.js" type="text/javascript")
19
-    %script(src="/javascripts/mootools-1.2.4.2-more.js" type="text/javascript")
20
-    %script(src="/javascripts/twitter.js" type="text/javascript")
21
-    %script(src="http://www.google-analytics.com/ga.js" type="text/javascript")
18
+    - if page.respond_to? :twitter_user
19
+      :javascript
20
+        var twitter_user = "#{page.twitter_user}"
21
+        var show_replies = #{page.show_replies};
22
+        var tweet_count = #{page.tweet_count};
23
+      %script(src="/javascripts/mootools-yui-compressed.js" type="text/javascript")
24
+      %script(src="/javascripts/mootools-1.2.4.2-more.js" type="text/javascript")
25
+      %script(src="/javascripts/twitter.js" type="text/javascript")
26
+    - if page.respond_to? :google_analytics
27
+      %script(src="http://www.google-analytics.com/ga.js" type="text/javascript")
22 28
   %body
23 29
     #header
24 30
       .page_width
25 31
         %a.title(href="/")=page.blog_title
26
-        #search
27
-          %form(action="http://www.google.com/cse" id="cse-search-box")
28
-            %input(type="hidden" name="cx" value="#{page.google_site_search_id}")
29
-            %input(type="hidden" name="ie" value="UTF-8")
30
-            %input#q(type="text" name="q")
32
+        - if page.respond_to? :google_site_search_id
33
+          #search
34
+            %form(action="http://www.google.com/cse" id="cse-search-box")
35
+              %input(type="hidden" name="cx" value="#{page.google_site_search_id}")
36
+              %input(type="hidden" name="ie" value="UTF-8")
37
+              %input#q(type="text" name="q")
31 38
     #nav
32 39
       .page_width
33 40
         %ul
... ...
@@ -46,38 +60,43 @@ disqus_short_name: designenthusiast
46 46
             %p.pubdate
47 47
               Published:
48 48
               =page.date.strftime("%d %b, %Y")
49
-              #disqus_thread
50
-              :javascript
51
-                var disqus_developer = true;
52
-                var disqus_url = "#{page.full_url}/#{page.url}";
53
-              %noscript
54
-                %a(href="http://designenthusiast.disqus.com/?url=ref") View the discussion thread
55
-              %script(type="text/javascript" src="http://disqus.com/forums/#{page.disqus_short_name}/embed.js")
49
+              - if page.respond_to? :disqus_short_name
50
+                #disqus_thread
51
+                :javascript
52
+                  var disqus_developer = true;
53
+                  var disqus_url = "#{page.full_url}/#{page.url}";
54
+                %noscript
55
+                  %a(href="http://designenthusiast.disqus.com/?url=ref") View the discussion thread
56
+                %script(type="text/javascript" src="http://disqus.com/forums/#{page.disqus_short_name}/embed.js")
56 57
           - else
57 58
             = content
58 59
         #sidebar
59
-          #twitter
60
-            #twitter_status
61
-              Status updating...
60
+          - if page.respond_to? :twitter_user
61
+            %h4 @#{page.twitter_user}
62
+            #twitter
63
+              #twitter_status
64
+                Status updating...
62 65
     #footer
63 66
       .page_width
64 67
         = "Copyright &copy; #{Time.now.strftime('%Y')} - #{page.blog_title} | "
65 68
         %span.credit Powered by <a href="http://github.com/imathis/octopress/">Octopress</a>
66
-    //Disqus Commens code
67
-    :javascript
68
-      /*(function() {
69
-          var links = document.getElementsByTagName('a');
70
-          var query = '?';
71
-          for(var i = 0; i < links.length; i++) {
72
-            if(links[i].href.indexOf('#disqus_thread') >= 0) {
73
-              query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
69
+    - if page.respond_to? :disqus_short_name
70
+      //Disqus Commens code
71
+      :javascript
72
+        (function() {
73
+            var links = document.getElementsByTagName('a');
74
+            var query = '?';
75
+            for(var i = 0; i < links.length; i++) {
76
+              if(links[i].href.indexOf('#disqus_thread') >= 0) {
77
+                query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
78
+              }
74 79
             }
75
-          }
76
-          document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/#{page.disqus_short_name}/get_num_replies.js' + query + '"></' + 'script>');
77
-        })();*/
78
-    //Google Analytics code
79
-    :javascript
80
-      try {
81
-      var pageTracker = _gat._getTracker("UA-10876422-1");
82
-      pageTracker._trackPageview();
83
-      } catch(err) {}
84 80
\ No newline at end of file
81
+            document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/#{page.disqus_short_name}/get_num_replies.js' + query + '"></' + 'script>');
82
+          })();
83
+    - if page.respond_to? :google_analytics
84
+      //Google Analytics code
85
+      :javascript
86
+        try {
87
+        var pageTracker = _gat._getTracker("UA-10876422-1");
88
+        pageTracker._trackPageview();
89
+        } catch(err) {}
85 90
\ No newline at end of file
... ...
@@ -8,9 +8,10 @@ title: Blog
8 8
       %h2= link_to(post.title, post.url, {:class=>"title"})
9 9
       = post.content
10 10
       .footer
11
-        - if post.data["comments_off"]
12
-          %em.comments_off Comments disabled
13
-        - else
14
-          %a(href="#{post.url}/#disqus_thread")Comments
11
+        - if page.respond_to? :disqus_short_name
12
+          - if post.data["comments_off"]
13
+            %em.comments_off Comments disabled
14
+          - else
15
+            %a(href="#{post.url}/#disqus_thread")Comments
15 16
   .footer
16 17
     %a(href="/archives.html" title="archives") &laquo; Blog Archives
17 18
\ No newline at end of file
... ...
@@ -6,13 +6,11 @@
6 6
 // PrettyDate by John Resig at http://ejohn.org/files/pretty.js
7 7
 //
8 8
 
9
-var filter_mentions = true;
10
-var tweet_count = 5;
11 9
 var tweet_tag = 'p';
12 10
 var twitter_div = 'twitter_status';
13 11
 
14 12
 window.addEvent('domready',function() {
15
-	getTwitterStatus('imathis');
13
+	getTwitterStatus(twitter_user);
16 14
 });
17 15
 
18 16
 function showTweets(the_tweets, from_cookie){
... ...
@@ -53,15 +51,15 @@ function prettyDate(time){
53 53
 }
54 54
 
55 55
 function getTwitterStatus(twitter_name){
56
-  var tweet_cookie = 'tweets_by_' + twitter_name;
56
+  var tweet_cookie = 'tweets_by_' + twitter_name + tweet_count;
57 57
   $(twitter_div).set('html', 'Fetching tweets...');
58 58
   if(!Cookie.read(tweet_cookie)) {
59 59
   	var myTwitterGitter = new TwitterGitter(twitter_name,{
60
-  	  count: ((!filter_mentions) ? tweet_count : 15 + tweet_count),
60
+  	  count: ((show_replies) ? tweet_count : 15 + tweet_count),
61 61
   		onComplete: function(tweets,user) {
62 62
         the_tweets = Array();
63 63
   			tweets.each(function(tweet,i) {
64
-  			  if((tweet.in_reply_to_status_id && !filter_mentions) || !tweet.in_reply_to_status_id){
64
+  			  if((tweet.in_reply_to_status_id && show_replies) || !tweet.in_reply_to_status_id){
65 65
   			    if(the_tweets.length == tweet_count) return;
66 66
   			    tweet.text = tweet.text.replace(/\n/gi, '<br/>');
67 67
   			    console.log(tweet);