Skip to content

Commit

Permalink
flow view
Browse files Browse the repository at this point in the history
  • Loading branch information
tadyjp committed Mar 12, 2014
1 parent 61e8e6b commit 935b356
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 21 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/application.css
Expand Up @@ -14,3 +14,6 @@
*= require_self
*/

.text-shadow {
color: #999999;
}
11 changes: 11 additions & 0 deletions app/assets/stylesheets/lib/mod-hover-hidden.css.scss
@@ -0,0 +1,11 @@
.mod-hover-hidden:hover {
.mod-hover-hidden-item {
display: initial;
}
}

.mod-hover-hidden {
.mod-hover-hidden-item {
display: none;
}
}
2 changes: 1 addition & 1 deletion app/controllers/flow_controller.rb
Expand Up @@ -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
14 changes: 14 additions & 0 deletions app/decorators/post_decorator.rb
Expand Up @@ -5,4 +5,18 @@ def show_path
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
2 changes: 2 additions & 0 deletions app/decorators/posts_decorator.rb
@@ -0,0 +1,2 @@
class PostsDecorator < Draper::CollectionDecorator
end
28 changes: 17 additions & 11 deletions app/views/posts/_large_item.html.slim
@@ -1,28 +1,34 @@
/ 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
4 changes: 4 additions & 0 deletions spec/controllers/flow_controller_spec.rb
Expand Up @@ -2,6 +2,10 @@

describe FlowController do

before :each do
@post = create(:post)
end

describe "GET 'show'" do
it "returns http success" do
get 'show'
Expand Down
18 changes: 9 additions & 9 deletions spec/controllers/stock_controller_spec.rb
@@ -1,12 +1,12 @@
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

0 comments on commit 935b356

Please sign in to comment.