增加评论功能,整合 disqus

This commit is contained in:
yafei Lee 2012-07-01 12:08:48 +08:00
parent 8b0729b4ce
commit 1463dee352
7 changed files with 56 additions and 1 deletions

View File

@ -9,10 +9,16 @@ div.blogs {
div.blog {
background: url('bg_fn_blog_corner.png') no-repeat;
padding: 2em 19px;
padding: 2em 19px 1em;
width: 641px;
border-radius: 5px;
border: 1px solid #E6E6E6;
.cc {
color: #CCC;
a {
color: #CCC;
}
}
h2 {
font-size: 40px;
margin-bottom: 19px;
@ -36,3 +42,9 @@ div.bottom {
height: 40px;
width: 679px;
}
div#disqus_thread {
margin: 20px 20px 0 0;
border-top: 1px solid #CCC;
padding-top: 20px;
}

View File

@ -1,2 +1,5 @@
module BlogsHelper
def format_time(time)
time.strftime("%Y-%m-%d %H:%M")
end
end

View File

@ -21,4 +21,10 @@ class Post
md = Redcarpet::Markdown.new(rd, :autolink=>true)
md.render(self.content)
end
def visited
self.visited_count += 1
self.save
self.visited_count
end
end

View File

@ -1,5 +1,11 @@
<div class="blog">
<h2><%= link_to (post.title + "<strong> >></strong>").html_safe, blog_path(post) %></h2>
<div class="content wikistyle"><%= post.content_html.html_safe %></div>
<div class="cc">
<%= t(:announce_at) %>
<%= format_time(post.created_at) %> |
<%= "浏览数 " + post.visited.to_s %> |
<%= link_to t('comment'), blog_path(post) + "#disqus_thread" %>
</div>
</div>
<div class="bottom"></div>

View File

@ -1,3 +1,17 @@
<div class="blogs">
<%= render :partial=> "post", :collection=> @posts %>
</div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yafeilee'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>

View File

@ -1,3 +1,15 @@
<div class="blogs">
<%= render :partial=> "post", :locals=> { :post=> @post } %>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yafeilee'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
</div>

View File

@ -4,3 +4,5 @@
en:
hello: "Hello world"
upload_photo: "上传图片"
comment: "查看评论"
announce_at: "发表在 "