Commit 935b356a by tady

flow view

parent 61e8e6be
...@@ -14,3 +14,6 @@ ...@@ -14,3 +14,6 @@
*= require_self *= require_self
*/ */
.text-shadow {
color: #999999;
}
.mod-hover-hidden:hover {
.mod-hover-hidden-item {
display: initial;
}
}
.mod-hover-hidden {
.mod-hover-hidden-item {
display: none;
}
}
...@@ -2,6 +2,6 @@ class FlowController < ApplicationController ...@@ -2,6 +2,6 @@ class FlowController < ApplicationController
before_action :require_login before_action :require_login
def show def show
@posts = Post.order(updated_at: :desc).limit(20) @posts = Post.order(updated_at: :desc).limit(20).decorate
end end
end end
...@@ -5,4 +5,18 @@ class PostDecorator < Draper::Decorator ...@@ -5,4 +5,18 @@ class PostDecorator < Draper::Decorator
h.post_path(model) h.post_path(model)
end end
# 読了時間
# 500文字/1分換算
def read_time
_time_min = model.body.length / 500
case _time_min
when 0
'< 1 min.'
when 1..10
"#{_time_min} min."
else
'> 10 min.'
end
end
end end
class PostsDecorator < Draper::CollectionDecorator
end
/ locals: / locals:
/ post {Post} / post {Post}
a.list-group-item.post-list data-post-id=post.id href=post_path(post) a.list-group-item.post-list.mod-hover-hidden data-post-id=post.id href=post_path(post)
.container-fluid .container-fluid
.row .row
.col-xs-10 .col-xs-10
.text-primary #{post.title} .text-primary #{post.title}
.col-xs-2 .col-xs-2
small.pull-right small.pull-right
= post.id ##{post.id}
.row .row
.col-xs-10 .col-xs-8
small small.text-success
| #{post.author.name} posted&nbsp; | #{post.author.name} posted&nbsp;
abbr.js-time-ago data-time-ago-at=post.updated_at abbr.js-time-ago data-time-ago-at=post.updated_at
|.&nbsp;&nbsp; |.&nbsp;&nbsp;
- post.tags.each do |tag| - post.tags.each do |tag|
span.label.label-success ##{tag.name} span.label.label-success ##{tag.name}
| &nbsp; | &nbsp;
.col-xs-2 .col-xs-4
small.pull-right small.pull-right
span.glyphicon.glyphicon-paperclip 1 span.glyphicon.glyphicon-time
| &nbsp; span.mod-hover-hidden-item
span.glyphicon.glyphicon-eye-open 2 | 読了時間
| &nbsp; | &nbsp;#{post.read_time}&nbsp;&nbsp;
span.glyphicon.glyphicon-edit 3 span.glyphicon.glyphicon-edit
| &nbsp; span.mod-hover-hidden-item
| コメント
| &nbsp;#{post.comments.count}&nbsp;&nbsp;
.row
.col-xs-12
small.text-shadow
= truncate post.body, length: 240
...@@ -2,6 +2,10 @@ require 'spec_helper' ...@@ -2,6 +2,10 @@ require 'spec_helper'
describe FlowController do describe FlowController do
before :each do
@post = create(:post)
end
describe "GET 'show'" do describe "GET 'show'" do
it "returns http success" do it "returns http success" do
get 'show' get 'show'
......
require 'spec_helper' # require 'spec_helper'
describe StockController do # describe StockController do
describe "GET 'show'" do # describe "GET 'show'" do
it "returns http success" do # it "returns http success" do
get 'show' # get 'show'
response.should be_success # response.should be_success
end # end
end # end
end # end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment