1.新增osp项目所有帖子的显示页面(待改进)

2.修改osp社区主页的[全球热帖]显示数量,默认25条->10条
This commit is contained in:
ganyiang 2014-05-14 12:03:50 +08:00
parent 27ade53af3
commit eda5121195
4 changed files with 168 additions and 9 deletions

View File

@ -57,7 +57,7 @@ class OpenSourceProjectsController < ApplicationController
@memo = RelativeMemo.new(:open_source_project => @open_source_project)
@topic_count = @open_source_project.topics.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@topic_pages = Paginator.new @topic_count, 10, params['page']
@memos = @open_source_project.topics.
reorder("#{RelativeMemo.table_name}.sticky DESC").
includes(:last_reply).
@ -73,11 +73,40 @@ class OpenSourceProjectsController < ApplicationController
format.json { render json: @open_source_project }
end
end
def search
def search
end
# added by yiang 暴力添加,请绕道
def showmemo
@open_source_project = OpenSourceProject.find(params[:id])
sort_init 'updated_at', 'desc'
sort_update 'created_at' => "#{RelativeMemo.table_name}.created_at",
'replies' => "#{RelativeMemo.table_name}.replies_count",
'updated_at' => "COALESCE (last_replies_relative_memos.created_at, #{RelativeMemo.table_name}.created_at)"
@memo = RelativeMemo.new(:open_source_project => @open_source_project)
@topic_count = @open_source_project.topics.count
@topic_pages = Paginator.new @topic_count, per_page_option, params['page']
@memos = @open_source_project.topics.
reorder("#{RelativeMemo.table_name}.sticky DESC").
includes(:last_reply).
limit(@topic_pages.per_page).
offset(@topic_pages.offset).
order(sort_clause).
all
respond_to do |format|
format.html {
render :layout => "base_opensource_p"
}
format.json { render json: @open_source_project }
end
end
# GET /open_source_projects/new
# GET /open_source_projects/new.json
def new

View File

@ -0,0 +1,77 @@
<!--added by yiang -->
<!--display the board-->
<div class="borad-topic-count" style="margin-top:10px">
<span>共有 <%= link_to memos.count %> 个贴子 </span
</div>
<div style="padding-top: 10px">
<% if memos.any? %>
<% memos.each do |topic| %>
<table class="content-text-list">
<tr>
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) if topic.author%>
<%= image_tag('../images/avatars/User/0', :class => "avatar") unless topic.author%> </td>
<td>
<table width="630px" border="0">
<tr>
<td valign="top" width="500px" class="<%= topic.sticky ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
<td align="right" rowspan="3">
<table class="borad-count">
<tr>
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
</tr>
<tr>
<td align="center">回帖</td>
</tr>
</table></td>
<td align="right" rowspan="3">
<table class="borad-count">
<tr>
<td align="center" class="borad-count-digit"><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
</tr>
<tr>
<td align="center">关注</td>
</tr>
</table></td>
<td align="right" rowspan="3">
<table class="borad-count">
<tr>
<td align="center" class="borad-count-digit"><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
</tr>
<tr>
<td align="center">浏览</td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2" ><span class="font_description"> </span></td>
</tr>
<!-- <tr>
<td align="left" colspan="2" ><span class="font_lighter"><%#= authoring topic.created_at, topic.author %>
<br />
</span></td>
</tr> -->
<tr>
<td align="left" colspan="2" >帖子来源:<span class="font_lighter" style="color: #068d9c"><%=link_to 'OSChina', topic.url %>
</span></td>
<td align="left"><%= no_use_link(topic, User.current) %> </td>
</tr>
</table></td>
</tr>
</table>
<% end %>
<div class="pagination">
<%= pagination_links_full @topic_pages, @topic_count %>
</div>
<% else %>
<p class="nodata">
<%= l(:label_no_data) %>
</p>
<% end %>
</div>

View File

@ -20,7 +20,7 @@
</div>
<div class="col2" style="margin-left:0px">
<div style="margin-left:0px" > <span> <h1 style="fontsize:19px;color:orange;font-weight:900">项目安全态势 </h1></span><span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><a href="#" hover="text-decoration: underline;" >More >></span></a></div>
<div style="margin-left:0px" > <span> <h1 style="fontsize:19px;color:orange;font-weight:900">项目安全态势 </h1></span><span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><%= link_to "More >>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %></span></div>
<div class="fixed"></div>
<div class="li_list" style="margin-top:10px;margin-left:10px">
<ul style="list-style-type: square;">
@ -211,7 +211,8 @@
</div>
<div class="col2" style="margin-left:0px">
<div style="margin-left:0px" > <span> <h1 style="fontsize:19px;color:green;font-weight:900">技术创新趋势 </h1></span><span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><a href="#" hover="text-decoration: underline;" >More >></span></a></div>
<div style="margin-left:0px" > <span> <h1 style="fontsize:19px;color:green;font-weight:900">技术创新趋势 </h1></span><span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><%= link_to "More >>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %>
</span></div>
<div class="fixed"></div>
<div class="li_list" style="margin-top:10px;margin-left:10px">
<ul style="list-style-type: square;">
@ -352,7 +353,8 @@
<!--我是分割线2===================================================================================================-->
<div class="borad-topic-count" style="margin-top:10px">
<!-- 共有 <%= link_to memos.count %> 个贴子 -->
<span><h1 style="color:blue;font-weight:900">全球热帖</h1></span><span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><a href="#" hover="text-decoration: underline;" >更多>></span></a>
<span><h1 style="color:blue;font-weight:900">全球热帖</h1></span>
<span style="margin-top: -30px; margin-right:70px;float: right; display: block;"><%= link_to "更多>>", :controller => "open_source_projects",:action => "showmemo", :id => @open_source_project.id %></span>
</div>
<div style="padding-top: 10px">
<% if memos.any? %>
@ -408,13 +410,10 @@
</span></td>
<td align="left"><%= no_use_link(topic, User.current) %> </td>
</tr>
</table></td>
</tr>
</table>
<% end %>
<div class="pagination">
<%= pagination_links_full @topic_pages, @topic_count %>

View File

@ -0,0 +1,54 @@
<!-- added by fq -->
<div id="add-memo" class='lz' style="display: none; padding: 20px;">
<h3><%=l(:label_memo_new)%></h3>
<% if User.current.logged? %>
<%= labelled_form_for(@memo, :url => open_source_project_relative_memos_path(@open_source_project), :html => {:multipart => true} ) do |f| %>
<% if @memo.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:</h2>
<ul>
<% @memo.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions" style="max-width:680px">
<p><%= f.text_field :subject, :required => true%></p>
<p style="max-width:680px"><%= f.text_area :content, :required => true, :id => 'editor02' %></p>
<script type="text/javascript">var ckeditor=CKEDITOR.replace('editor02');</script>
<br/>
<p>
<%#= l(:label_attachment_plural) %><br />
<%#= render :partial => 'attachments/form', :locals => {:container => @memo} %>
</p>
<%= f.submit :value => l(:label_memo_create) %>
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %>
</div>
<% end %>
<% end %>
</div>
<!--modified by huang-->
<% #= link_to '发布帖子', new_forum_memo_path(@forum), :class => 'icon icon-add' %>
<span>
<%= link_to l(:label_memo_new_from_forum), new_open_source_project_relative_memo_path(@open_source_project), :class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-memo", "memo_subject"); return false;' if User.current.logged? %>
</span>
<div class="contextual-borad">
<%#= link_to(
image_tag('edit.png')+l(:label_forum_edit),
{:action => 'edit', :id => @forum},
:method => 'get',
:title => l(:button_edit)
) if @forum.editable_by?(User.current) %>
<%#= link_to(
image_tag('delete.png')+'删除讨论区',
{:action => 'destroy', :id => @forum},
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if @forum.destroyable_by?(User.current) %>
</div>
<%= render :partial => 'open_source_projects/show_memo', :locals => {:memos => @memos} %>