show.html.erb 1.99 KB
<% 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>