From 1463dee352bbcac11cf01013804f71c4b4a379fd Mon Sep 17 00:00:00 2001 From: yafei Lee Date: Sun, 1 Jul 2012 12:08:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=84=E8=AE=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD,=E6=95=B4=E5=90=88=20disqus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/blogs.css.scss | 14 +++++++++++++- app/helpers/blogs_helper.rb | 3 +++ app/models/post.rb | 6 ++++++ app/views/blogs/_post.html.erb | 6 ++++++ app/views/blogs/index.html.erb | 14 ++++++++++++++ app/views/blogs/show.html.erb | 12 ++++++++++++ config/locales/en.yml | 2 ++ 7 files changed, 56 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/blogs.css.scss b/app/assets/stylesheets/blogs.css.scss index e0e078d..4c28624 100644 --- a/app/assets/stylesheets/blogs.css.scss +++ b/app/assets/stylesheets/blogs.css.scss @@ -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; +} diff --git a/app/helpers/blogs_helper.rb b/app/helpers/blogs_helper.rb index cc0dbd2..2dff537 100644 --- a/app/helpers/blogs_helper.rb +++ b/app/helpers/blogs_helper.rb @@ -1,2 +1,5 @@ module BlogsHelper + def format_time(time) + time.strftime("%Y-%m-%d %H:%M") + end end diff --git a/app/models/post.rb b/app/models/post.rb index 9889dd6..81afaa7 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/views/blogs/_post.html.erb b/app/views/blogs/_post.html.erb index 1230b9a..60bbf93 100644 --- a/app/views/blogs/_post.html.erb +++ b/app/views/blogs/_post.html.erb @@ -1,5 +1,11 @@

<%= link_to (post.title + " >>").html_safe, blog_path(post) %>

<%= post.content_html.html_safe %>
+
+ <%= t(:announce_at) %> + <%= format_time(post.created_at) %> | + <%= "浏览数 " + post.visited.to_s %> | + <%= link_to t('comment'), blog_path(post) + "#disqus_thread" %> +
diff --git a/app/views/blogs/index.html.erb b/app/views/blogs/index.html.erb index 2993306..303741d 100644 --- a/app/views/blogs/index.html.erb +++ b/app/views/blogs/index.html.erb @@ -1,3 +1,17 @@
<%= render :partial=> "post", :collection=> @posts %>
+ + + diff --git a/app/views/blogs/show.html.erb b/app/views/blogs/show.html.erb index fcfabfb..15b2ea1 100644 --- a/app/views/blogs/show.html.erb +++ b/app/views/blogs/show.html.erb @@ -1,3 +1,15 @@
<%= render :partial=> "post", :locals=> { :post=> @post } %> +
+
diff --git a/config/locales/en.yml b/config/locales/en.yml index 82bdde0..1757138 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4,3 +4,5 @@ en: hello: "Hello world" upload_photo: "上传图片" + comment: "查看评论" + announce_at: "发表在 "