optimize the show of forge

This commit is contained in:
xianbo 2014-03-24 10:18:42 +08:00
parent 2e3b44c830
commit 8db09739a1
4 changed files with 60 additions and 5 deletions

View File

@ -9,8 +9,13 @@ module CoursesHelper
=end
TeacherRoles = [3, 4, 7, 9]
StudentRoles = [5, 10]
AllPeople = StudentRoles+TeacherRoles
## return people count
# 返回x项目成员数量即roles表中定义的所有成员
def projectCount project
searchCountByRoles project, AllPeople
end
# 返回教师数量即roles表中定义的Manager
def teacherCount project

View File

@ -285,6 +285,7 @@ module ProjectsHelper
SELECT project_id,grade FROM project_statuses
WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
end
# 判断课程是否结束,快别用,这个定日子的方法有问题
def course_timeout? project

View File

@ -39,6 +39,13 @@ module WelcomeHelper
end
end
def get_project_avatar project
if get_avatar?(project)
url_to_avatar(project)
else
'../images/avatars/Project/project.jpg'
end
end
# 前略·天国の首页君/Earth has been unable stop to welcomePage's.
# sum - 要搜索的项目数量
# max_rate - 新项目所占所有项目的比重10分制
@ -56,10 +63,23 @@ module WelcomeHelper
c2 = c2 - c1
(c1.take(max)+c2).take(sum)
end
def find_miracle_project(sum=10, max_rate=7)
max = sum*(max_rate.to_f/10)
c1 = find_new_project(sum).to_a.dup
c2 = find_all_hot_project(sum).to_a.dup
c2 = c2 - c1
(c1.take(max)+c2).take(sum)
end
def find_new_course limit=15
Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 1).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all
end
def find_new_project limit=15
Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 0).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all
end
def find_all_hot_project limit=15
sort_project_by_hot limit

View File

@ -105,10 +105,8 @@
<%= stylesheet_link_tag 'welcome' %>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<!-- <div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>热门项目</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
@ -135,6 +133,37 @@
<% end %>
</ul>
</div>
</div> -->
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3 style="margin-left: 5px; color: #e8770d;"><strong>热门项目</strong></h3>
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1}, :target => "_blank" %></span>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_miracle_project(11, 7).map do |project| %>
<li style="position:relative;height:5em;" class='<%= cycle("odd", "even") %>'>
<div style="float: left;">
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
</div>
<!-- 上左下右 -->
<div style="float: left; margin-left: 10px; width: 380px;">
<%= link_to( project.name, project_path(project.id), :class => "d-g-blue d-p-project-name",:title => "#{project.name}" )%>
(<%= link_to "#{projectCount(project)}人", project_member_path(project) ,:course =>'0' %>)
</div>
<div style="float: left;margin:5px; margin-left: 10px; width: 380px;">
<span class='font_lighter' title =<%=project.description.to_s%>><%=project.description.truncate(35, omission: '...')%></span>
</div>
<div style="position:absolute; bottom:0;right:0;margin:5px 10px 5px 5px ;">
<%= content_tag "span", show_grade(project),
:style => "cursor: pointer; display: inline-block; float: right; color: #ec6300; ",
:title => "项目得分,综合考虑了项目的各项活动,反映了该项目的活跃程度",
:class => "tooltip",
:id => "tooltip-#{project.id}" %>
</p>
</div>
</li>
<% end; reset_cycle %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">