Browse code

added disqus comment support

B Mathis authored on 06/11/2009 at 04:36:37
Showing 3 changed files
... ...
@@ -47,7 +47,7 @@ task :generate_style do
47 47
 end
48 48
 
49 49
 desc "Generate site files only"
50
-task :generate_site => :clean do
50
+task :generate_site => [:clean, :generate_style] do
51 51
   puts ">>> Generating site files <<<"
52 52
   system "jekyll"
53 53
   system "mv #{site}/atom.html #{site}/atom.xml"
... ...
@@ -1,6 +1,8 @@
1 1
 ---
2 2
 blog_title: My Octopress Blog
3
+full_url:
3 4
 google_site_search_id: 
5
+disqus_site: designenthusiast
4 6
 ---
5 7
 
6 8
 !!! 1.1 Transitional
... ...
@@ -45,6 +47,13 @@ google_site_search_id:
45 45
             %p.pubdate
46 46
               Published:
47 47
               =page.date.strftime("%d %b, %Y")
48
+              #disqus_thread
49
+              :javascript
50
+                var disqus_developer = true;
51
+                var disqus_url = "#{page.full_url}/#{page.url}";
52
+              %noscript
53
+                %a(href="http://designenthusiast.disqus.com/?url=ref") View the discussion thread
54
+              %script(type="text/javascript" src="http://disqus.com/forums/#{page.disqus_site}/embed.js")
48 55
           - else
49 56
             = content
50 57
         #sidebar
... ...
@@ -55,7 +64,18 @@ google_site_search_id:
55 55
       .page_width
56 56
         = "Copyright &copy; #{Time.now.strftime('%Y')} - #{page.blog_title} | "
57 57
         %span.credit Powered by <a href="http://github.com/imathis/octopress/">Octopress</a>
58
-  
58
+    //Disqus Commens code
59
+    :javascript
60
+      (function() {
61
+          var links = document.getElementsByTagName('a');
62
+          var query = '?';
63
+          for(var i = 0; i < links.length; i++) {
64
+            if(links[i].href.indexOf('#disqus_thread') >= 0) {
65
+              query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
66
+            }
67
+          }
68
+          document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/#{page.disqus_site}/get_num_replies.js' + query + '"></' + 'script>');
69
+        })();
59 70
     //Google Analytics code
60 71
     :javascript
61 72
       try {
... ...
@@ -7,5 +7,10 @@ title: Blog
7 7
     .article
8 8
       %h2= link_to(post.title, post.url, {:class=>"title"})
9 9
       = post.content
10
+      .footer
11
+        - if post.data["comments_off"]
12
+          %em.comments_off Comments disabled
13
+        - else
14
+          %a(href="#{post.url}/#disqus_thread")Comments
10 15
   .footer
11 16
     %a(href="/archives.html" title="archives") &laquo; Blog Archives
12 17
\ No newline at end of file