Commit 935b356a by tady

flow view

parent 61e8e6be
......@@ -14,3 +14,6 @@
*= 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
before_action :require_login
def show
@posts = Post.order(updated_at: :desc).limit(20)
@posts = Post.order(updated_at: :desc).limit(20).decorate
end
end
......@@ -5,4 +5,18 @@ class PostDecorator < Draper::Decorator
h.post_path(model)
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
class PostsDecorator < Draper::CollectionDecorator
end
/ locals:
/ 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
.row
.col-xs-10
.text-primary #{post.title}
.col-xs-2
small.pull-right
= post.id
##{post.id}
.row
.col-xs-10
small
.col-xs-8
small.text-success
| #{post.author.name} posted&nbsp;
abbr.js-time-ago data-time-ago-at=post.updated_at
|.&nbsp;&nbsp;
- post.tags.each do |tag|
span.label.label-success ##{tag.name}
| &nbsp;
.col-xs-2
.col-xs-4
small.pull-right
span.glyphicon.glyphicon-paperclip 1
| &nbsp;
span.glyphicon.glyphicon-eye-open 2
| &nbsp;
span.glyphicon.glyphicon-edit 3
| &nbsp;
span.glyphicon.glyphicon-time
span.mod-hover-hidden-item
| 読了時間
| &nbsp;#{post.read_time}&nbsp;&nbsp;
span.glyphicon.glyphicon-edit
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'
describe FlowController do
before :each do
@post = create(:post)
end
describe "GET 'show'" do
it "returns http success" do
get 'show'
......
require 'spec_helper'
# require 'spec_helper'
describe StockController do
# describe StockController do
describe "GET 'show'" do
it "returns http success" do
get 'show'
response.should be_success
end
end
# describe "GET 'show'" do
# it "returns http success" do
# get 'show'
# response.should be_success
# 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