Skip to content

Commit

Permalink
add waterfall
Browse files Browse the repository at this point in the history
  • Loading branch information
IceskYsl committed Nov 9, 2013
1 parent f825fa4 commit c07aff9
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/imagesloaded.pkgd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/assets/javascripts/masonry.pkgd.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions app/assets/stylesheets/waterfall.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.item { width: 290px; }

#container .item {
margin-bottom: 4px;
}

#container img{
max-width:100%;
}
6 changes: 6 additions & 0 deletions app/controllers/chats_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def index
@items = scoped_items.recent.hot.paginate(:page => page, :per_page => 100)
end

def waterfall
page = params[:page] || 1
scoped_items = Account.can_chat
@items = scoped_items.recent.hot.paginate(:page => page, :per_page => 100)
end


def create
params.permit!
Expand Down
44 changes: 44 additions & 0 deletions app/views/chats/waterfall.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<%= stylesheet_link_tag "waterfall", media: "all", "data-turbolinks-track" => true %>

<div class="span12 well">
<h2>约聊天..</h2>
<p>欢迎你来到这里约我们聊天, 选择你感兴趣的人开始精彩的聊天之旅吧...</p>
<hr />

<div id="container">
<%@items.each do |i|%>
<div class="item">
<h3><%=i.username%></h3>
<p>
<%=image_tag i.image,:width=>"290",:alt=>"#{i.username}" unless i.image.blank?%>
</p>
<div class="tags">
<p>
<%unless i.city.blank?%>
<button type="button" class="btn btn-info btn-xs"><%=i.city%></button>
<%end%>
<%i.tags.each do |tag|%>
<button type="button" class="btn btn-primary btn-xs"><%=tag%></button>
<%end%>
</p>
</div>
<p>
<%=simple_format i.bio%>
</p>
<p class="pull-left">
<%=link_to image_tag("website.png",:size=>"16x16",:alt=>"我的网站"),i.website,:target=>"_blank" unless i.website.blank?%>
<%=link_to image_tag("weibo.png",:size=>"16x16",:alt=>"微博"),i.weibo_url,:target=>"_blank" unless i.weibo.blank? %>
<%=link_to image_tag("zhihu.png",:size=>"16x16",:alt=>"知乎"),i.zhihu_url,:target=>"_blank" unless i.zhihu.blank? %>
<%=link_to image_tag("douban.png",:size=>"16x16",:alt=>"豆瓣"),i.douban_url,:target=>"_blank" unless i.douban.blank?%>

</p>
</div>
<%end%>
</div>

<div class="container chats">
<%= will_paginate @items %>
</div>

</div>

13 changes: 13 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
autoclose: true,
todayHighlight: true
});


var $container = $('#container');
// initialize
$container.masonry({
columnWidth: 300,
gutter: 8,
itemSelector: '.item'
});

$container.imagesLoaded( function() {
$container.masonry();
});
</script>

</body>
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

resources :chats do
collection do
get :waterfall
get :list
get :apply
get :confirm
Expand Down

0 comments on commit c07aff9

Please sign in to comment.