主页去除影响性能的代码

This commit is contained in:
yanxd 2013-11-28 16:14:23 +08:00
parent 90b38cf5e8
commit 5d77f2031e
5 changed files with 98 additions and 185 deletions

View File

@ -19,8 +19,8 @@ class WelcomeController < ApplicationController
caches_action :robots
def index
@news = News.latest User.current
@projects = Project.latest User.current
# @news = News.latest User.current
# @projects = Project.latest User.current
#by young
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
if request.get?
@ -60,10 +60,10 @@ class WelcomeController < ApplicationController
end
#add by huang
@memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
# @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
@events_by_day = events.group_by(&:event_date)
# events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
# @events_by_day = events.group_by(&:event_date)
#
end

View File

@ -19,18 +19,18 @@
module WelcomeHelper
def newbieTopiclist
find_all_topic_by_board_id
end
# def newbieTopiclist
# find_all_topic_by_board_id
# end
def newbieTopicStickyList
find_all_topic_by_board_id 1
end
# def newbieTopicStickyList
# find_all_topic_by_board_id 1
# end
def find_project_by_topic topic
board = find_board_by_topic(topic)
find_project_by_board board
end
# def find_project_by_topic topic
# board = find_board_by_topic(topic)
# find_project_by_board board
# end
def find_all_hot_project
sort_project_by_hot
@ -48,30 +48,30 @@ module WelcomeHelper
sort_contest_by_hot
end
def time_tag_welcome(time)
text = distance_of_time_in_words(Time.now, time)
content_tag('span', text, :title => format_time(time))
end
text = distance_of_time_in_words(Time.now, time)
content_tag('span', text, :title => format_time(time))
end
private
def search_project
Project.find_by_identifier "newbie_faq"
end
# def search_project
# Project.find_by_identifier "newbie_faq"
# end
def find_all_topic_by_board_id sticky = 0, limit = 30
project = search_project
return [] if(project.nil? or project.boards.nil?)
board_id = project.boards.first.id
logger.debug "[WelcomeHelper] ===> find_all_topic_by_board_id=> project.id:#{project.id}, board_id:#{board_id}, sticky:#{sticky}"
Message.where("board_id = :board_id and sticky=:sticky", :board_id => board_id, :sticky => sticky ).limit(limit)
end
# def find_all_topic_by_board_id sticky = 0, limit = 30
# project = search_project
# return [] if(project.nil? or project.boards.nil?)
# board_id = project.boards.first.id
# logger.debug "[WelcomeHelper] ===> find_all_topic_by_board_id=> project.id:#{project.id}, board_id:#{board_id}, sticky:#{sticky}"
# Message.where("board_id = :board_id and sticky=:sticky", :board_id => board_id, :sticky => sticky ).limit(limit)
# end
def find_board_by_topic topic
Board.find_by_id(topic.board_id)
end
def find_project_by_board board
Project.find_by_id(board.project_id)
end
# def find_board_by_topic topic
# Board.find_by_id(topic.board_id)
# end
# def find_project_by_board board
# Project.find_by_id(board.project_id)
# end
def sort_project_by_hot
sort_project_by_hot_rails 0, 'grade DESC'

View File

@ -32,7 +32,7 @@
<th></th>
</tr>
<% @forums.each do |forum| %>
< % @forums.each do |forum| %>
<tr>
<td>< %= forum.name %></td>
<td>< %= forum.description %></td>
@ -41,7 +41,7 @@
<td>< %= link_to 'Edit', edit_forum_path(forum) %></td>
<td>< %= link_to 'Destroy', forum, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
< % end %>
</table>
<br /> -->

View File

@ -135,125 +135,77 @@
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h2>热门项目</h2>
<!-- <ul class="d-p-index-hdright d-p-project-bytime ks-switchable-nav">
<li class="current">
<a class="" href="javascript:void(0);">今日</a>
<h2>热门项目</h2>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_project.map do |project| break if(project == find_all_hot_project[15]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( project.name, project_path(project.project_id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{project.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro" ><%= project.description.truncate(50, omission: '...') %></span>
</p>
</li>
<li>
<a class="" href="javascript:void(0);">本周</a>
</li>
<li>
<a class="" href="javascript:void(0);">本月</a>
</li>
</ul> -->
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_project.map do |project| break if(project == find_all_hot_project[15]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( project.name, project_path(project.project_id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{project.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro" ><%= project.description.truncate(50, omission: '...') %></span>
</p>
<!-- <p class="layout">
<span><%= project.members.count%></span>
</p> -->
</li>
<% end %>
</ul>
</div>
<% end %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h2>热门竞赛</h2>
<!-- <ul class="d-p-index-hdright d-p-project-bytime ks-switchable-nav">
<li class="current">
<a class="" href="javascript:void(0);">今日</a>
</li>
<li>
<a class="" href="javascript:void(0);">本周</a>
</li>
<li>
<a class="" href="javascript:void(0);">本月</a>
</li>
</ul> -->
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{contest.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro"><%= contest.description.truncate(50, omission: '...') %></span>
</p>
<!-- <p style="margin-top: -10px;">
<span><%= contest.created_on %></span>
</p> -->
</li>
<% end %>
</ul>
</div>
<h2>热门竞赛</h2>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_contest.map do |contest| break if(contest == find_all_hot_contest[5]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( contest.name, respond_path(contest.id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{contest.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro"><%= contest.description.truncate(50, omission: '...') %></span>
</p>
</li>
<% end %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h2>热门众包</h2>
<!-- <ul class="d-p-index-hdright d-p-project-bytime ks-switchable-nav">
<li class="current">
<a class="" href="javascript:void(0);">今日</a>
</li>
<li>
<a class="" href="javascript:void(0);">本周</a>
</li>
<li>
<a class="" href="javascript:void(0);">本月</a>
</li>
</ul> -->
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( bid.name, respond_path(bid.id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{bid.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro"><%= bid.description.truncate(50, omission: '...') %></span>
</p>
</li>
<% end %>
</ul>
</div>
<h2>热门众包</h2>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_bid.map do |bid| break if(bid == find_all_hot_bid[5]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( bid.name, respond_path(bid.id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{bid.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro"><%= bid.description.truncate(50, omission: '...') %></span>
</p>
</li>
<% end %>
</ul>
</div>
</div>
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
<h2>热门课程</h2>
<!-- <ul class="d-p-index-hdright d-p-project-bytime ks-switchable-nav">
<li class="current">
<a class="" href="javascript:void(0);">今日</a>
</li>
<li>
<a class="" href="javascript:void(0);">本周</a>
</li>
<li>
<a class="" href="javascript:void(0);">本月</a>
</li>
</ul> -->
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_course.map do |project| break if(project == find_all_hot_course[5]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( project.name, project_path(project.project_id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{project.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro"><%= project.description.truncate(50, omission: '...') %></span>
</p>
</li>
<% end %>
</ul>
</div>
<h2>热门课程</h2>
<div class="d-p-projectlist-box">
<ul class="d-p-projectlist">
<% find_all_hot_course.map do |project| break if(project == find_all_hot_course[5]) %>
<li style="background-image:none;">
<p class="layout">
<%= link_to( project.name, project_path(project.project_id), :class => "d-g-blue d-p-project-name", :target => "_blank", :title => "#{project.name}")%>
</p>
<p class="layout-1" >
<span class="d-p-project-intro"><%= project.description.truncate(50, omission: '...') %></span>
</p>
</li>
<% end %>
</ul>
</div>
</div>
<div class="clr"></div>
@ -264,43 +216,4 @@
<!-- <div>
<table width="700" border="0" align="center" style="padding-top: 0px">
<tr>
<td colspan="5" align="center" style="padding-bottom: 10px; font-size: 18px; font-color: #5c5c5c ; font-family: 微软雅黑"><%= l(:label_welcome_leave_message) %> <strong><%= toggle_link l(:label_welcome_click_me), 'put-bid-form', {:focus => 'new_form_project_message'} %></strong>
</td>
</tr>
<tr><td colspan="5" align="center" ><div class="homepage_underline"></div></td></tr>
<tr>
<td colspan="5" align="center">
<div id="put-bid-form" style="display: none">
<%= form_for('new_form', :method => :post, :url => {:controller => 'words', :action => 'add_project_respond'}) do |f|%>
<table border="0" width="525px" align="center" >
<tr>
<td>
<%= f.text_area 'project_message',
:rows => 3,
:cols => 65,
:value => "#{l(:label_welcome_my_respond)}",
:onfocus => "clearInfo('new_form_project_message','#{l(:label_welcome_my_respond)}')",
:onblur => "showInfo('new_form_project_message','#{l(:label_welcome_my_respond)}')",
:style => "resize: none;",
:class => 'noline'%>
</td>
</tr>
</table>
<table border="0" width="525px" align="center">
<tr>
<td align="right"> <%= submit_tag l(:button_submit), :name => nil , :class => "bid_btn" %></td>
</tr>
</table>
<% end %>
</div>
</td>
</tr>
</table>
</div> -->

View File

@ -203,7 +203,7 @@ Redmine::MenuManager.map :top_menu do |menu|
menu.push :software_user, {:controller => 'users', :action => 'index'}
menu.push :contest_innovate, {:controller => 'bids', :action => 'contest', :project_type => 1}
menu.push :requirement_enterprise, {:controller => 'bids', :action => 'index'}
menu.push :project_module_forums, forums_path
menu.push :project_module_forums, :forums_path
# menu.push :investor, :home_path