Skip to content

Commit

Permalink
disqus comments cofigurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wiggins committed Nov 4, 2008
1 parent 57f13f7 commit d96f5e4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
6 changes: 6 additions & 0 deletions README.rdoc
Expand Up @@ -54,6 +54,12 @@ Or, modify the Sequel.connect statement at the top of main.rb.

The database will be created automatically when the server is executed.

== Comments

There are no comments by default. If you wish to activate comments, create an
account and a website on Disqus (disqus.com) and enter the website shortname as
the :disqus_shortname value in the Blog config struct.

== Customize

There are no themes or settings beyond the basic ones in the Blog struct. Just
Expand Down
3 changes: 2 additions & 1 deletion main.rb
Expand Up @@ -12,7 +12,8 @@
:url_base => 'http://localhost:4567/',
:admin_password => 'pick_your_password',
:admin_cookie_key => 'scanty_admin',
:admin_cookie_value => '51d6d976913ace58'
:admin_cookie_value => '51d6d976913ace58',
:disqus_shortname => nil
)
end

Expand Down
35 changes: 21 additions & 14 deletions views/index.erb
Expand Up @@ -18,7 +18,12 @@
<div class="post">
<p class="date"><%= post[:created_at].strftime("%b") %><b><%= post[:created_at].strftime("%d") %></b></p>
<h2 class="title"><a href="<%= post.url %>"><%= post[:title] %></a></h2>
<p class="meta"><small><%= post.linked_tags %> | <a href="<%= post.url %>#disqus_thread">comments</a></small></p>
<p class="meta"><small>
<%= post.linked_tags %>
<% if Blog.disqus_shortname %>
| <a href="<%= post.url %>#disqus_thread">comments</a>
<% end %>
</small></p>
<div class="entry">
<%= post.summary %>
<% if post.more? %>
Expand All @@ -37,20 +42,22 @@
<% end %>
</div>

<script type="text/javascript">
//<[CDATA[
(function() {
var links = document.getElementsByTagName('a');
var query = '?';
for(var i = 0; i < links.length; i++) {
if(links[i].href.indexOf('#disqus_thread') >= 0) {
query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
<% if Blog.disqus_shortname %>
<script type="text/javascript">
//<[CDATA[
(function() {
var links = document.getElementsByTagName('a');
var query = '?';
for(var i = 0; i < links.length; i++) {
if(links[i].href.indexOf('#disqus_thread') >= 0) {
query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';
}
}
}
document.write('<script type="text/javascript" src="http://disqus.com/forums/adamheroku/get_num_replies.js' + query + '"></' + 'script>');
})();
//]]>
</script>
document.write('<script type="text/javascript" src="http://disqus.com/forums/<%= Blog.disqus_shortname %>/get_num_replies.js' + query + '"></' + 'script>');
})();
//]]>
</script>
<% end %>

<div id="footer">
<p id="legal">
Expand Down
4 changes: 3 additions & 1 deletion views/post.erb
Expand Up @@ -10,4 +10,6 @@
<% end %>
</div>

<div id="disqus_thread"></div><script type="text/javascript" src="http://disqus.com/forums/adamheroku/embed.js"></script><noscript><a href="http://adamheroku.disqus.com/?url=ref">View the discussion thread.</a></noscript><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
<% if Blog.disqus_shortname %>
<div id="disqus_thread"></div><script type="text/javascript" src="http://disqus.com/forums/<%= Blog.disqus_shortname %>/embed.js"></script><noscript><a href="http://<%= Blog.disqus_shortname %>.disqus.com/?url=ref">View the discussion thread.</a></noscript><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
<% end %>

0 comments on commit d96f5e4

Please sign in to comment.