show.html.erb
1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<% if params[:chan] == 'cultures' or params[:chan] == 'dynamics' %>
<div class="banner" style="background-image: url(/images/banner/<%= params[:chan] %>.jpg?v=1);"></div>
<% else %>
<div class="banner" style="background-image: url(/images/banner/banner.jpg?v=1);"></div>
<% end %>
<div class="inside wrapper">
<div class="inside-left">
<div class="top"><%= @chan_name %></div>
<ul>
<% @cates.each do |key, val| %>
<% if key.eql?(@cate) %>
<li class="active">
<%= link_to val, {controller: :home, action: :show, chan: params[:chan], cate: key} %>
</li>
<% else %>
<li>
<%= link_to val, {controller: :home, action: :show, chan: params[:chan], cate: key} %>
</li>
<% end %>
<% end %>
</ul>
</div>
<div class="inside-right">
<div class="detail">
<div class="title">
<h3><%= @post.try(:title) || @cate_name %></h3>
<small>
<%= link_to '首页', root_path %>
-
<%= link_to @chan_name, controller: :home, action: :show, chan: params[:chan] %>
-
<%= link_to @cate_name, controller: :home, action: :show, chan: params[:chan], cate: @cate %>
<% if params[:flag].present? %>
-
<%= link_to @post.title, 'javascript:void(0);' %>
<% end %>
</small>
</div>
<div class="preview">
<% if @post %>
<%= @post.detail.html_safe %>
<% else %>
<% @posts.each do |post| %>
<div class="item">
<% img_path = post.detail.scan(/<img[^>]+src\s*=\s*(['\"][^'\"]+['\"])[^>]*>/).flatten.first.gsub(/\"/, '') rescue '/images/default_200x150.jpg' %>
<img src="<%= img_path %>" alt="默认图片" class="pic">
<h4 class="posth4">
<%= link_to post.title, controller: :home, action: :show, chan: params[:chan], cate: @cate, flag: post.flag %>
</h4>
<div class="postdesc">
<%= truncate(post.detail.gsub(/<\/?.*?>/,""), length: 120) %>
</div>
</div>
<% end %>
<%= paginate @posts %>
<% end %>
</div>
</div>
</div>
</div>