new welcome index.
This commit is contained in:
parent
0f652b4955
commit
5de8e1c2f2
|
@ -243,4 +243,26 @@ module ProjectsHelper
|
|||
end
|
||||
end
|
||||
|
||||
def sort_project_by_hot
|
||||
return sort_project_by_hot_rails
|
||||
@projects_status = ProjectStatus.visible.where("project_statuses.project_type <> ? or project_statuses.project_type is null", 1)
|
||||
@projects_status = @projects_status.reorder('grade').all.reverse
|
||||
@projects = []
|
||||
@projects_status.each do |obj|
|
||||
break if(@projects_status[10] == obj)
|
||||
@projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id)
|
||||
end
|
||||
@projects
|
||||
rescue NoMethodError
|
||||
[]
|
||||
end
|
||||
|
||||
def sort_project_by_hot_rails
|
||||
# @projects_status = ProjectStatus.visible.where("project_statuses.project_type <> ? or project_statuses.project_type is null", 1)
|
||||
# @projects_status = @projects_status.reorder('grade').all.reverse
|
||||
# Project.joins(@projects_status).limit(10)
|
||||
limit = 10
|
||||
Project.find_by_sql("SELECT * FROM projects RIGHT OUTER JOIN (SELECT * FROM project_statuses ORDER BY grade DESC LIMIT #{limit} ) AS t ON projects.id = t.project_id ")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,4 +18,43 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
module WelcomeHelper
|
||||
include ProjectsHelper
|
||||
|
||||
def newbieTopiclist
|
||||
find_all_topic_by_board_id
|
||||
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_all_hot_project
|
||||
sort_project_by_hot
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
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_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
|
||||
end
|
||||
|
|
|
@ -103,26 +103,30 @@
|
|||
<%= stylesheet_link_tag 'welcome' %>
|
||||
<div class="body_resize">
|
||||
<div class="right">
|
||||
<div class="home">热门项目</div>
|
||||
<div>
|
||||
<table><tr><td><p class="welcome-index"><a>Trustie1balabalbalabalbalabalbalabalbalabalbalabalbbalabalbalabalbalabalbalabalbalabalbalabal</a></p></td>
|
||||
<td><p class="welcome-index"><a>This is a project!balabalabalabala...</a></p></td>
|
||||
</tr></table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="home"><%= l :label_hot_project%></div>
|
||||
<% find_all_hot_project.map do |project| break if(project == find_all_hot_project[5]) %>
|
||||
<div class="project">
|
||||
<%=link_to( project.name, project_path(project), :class => "nowrap" )%>
|
||||
<p><%= project.description %></p>
|
||||
<!-- span class="grey"><strong><em> </em></strong></span -->
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<!-- p class="grey">Fusce vehicula dignissim ligula. Vestibulum sit amet neque eu neque suscipit consequat quis vel risus. </p>
|
||||
<p><strong>Vestibulum vehicula purus nec dui accumsan fermentum.</strong> Suspendisse potenti. Ut dapibus est id odio pretium blandit in eget leo. Aliquam erat volutpat. Curabitur blandit </p>
|
||||
|
||||
<p class="grey"> </p -->
|
||||
|
||||
</div>
|
||||
<div class="left">
|
||||
<div class="home" >新手指引 & 问答</div>
|
||||
|
||||
<!-- p><strong><em> 5th / April / 2009 </em></strong></p>
|
||||
<p>Integer mauris. Cras iaculis viverra dolorqw. Nulla suscipit. </p -->
|
||||
<div class="project"> <a href="#" ><span >新手入门指引帖 && FAQ bala...</span></a> <span class="grey"><strong><em>[ Trustie ]</em></strong></span></div>
|
||||
<div class="home" ><%= l :label_newbie_faq %><!-- 新手指引 & 问答 --></div>
|
||||
<% newbieTopicStickyList.each do |topic| break if(topic == newbieTopicStickyList[6])%>
|
||||
<div class="project">
|
||||
<%=link_to( topic.subject, board_message_path(find_board_by_topic(topic),topic), :class => "nowrap" )%>
|
||||
<span class="grey"><strong><em>[ <%=find_project_by_topic(topic) %> ]</em></strong></span>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- div class="project"> <a href="#" ><span >新手入门指引帖 && FAQ bala...</span></a> <span class="grey"><strong><em>[ Trustie ]</em></strong></span></div -->
|
||||
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
|
|
|
@ -1563,6 +1563,8 @@ en:
|
|||
label_user_home: User Space
|
||||
|
||||
field_hidden_repo: code protected
|
||||
label_newbie_faq: newbie FAQ
|
||||
label_hot_project: 'HOT Projects'
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1723,3 +1723,6 @@ zh:
|
|||
field_teacher_name: 教 师
|
||||
|
||||
field_hidden_repo: 隐藏代码库
|
||||
|
||||
label_newbie_faq: '新手指引 & 问答'
|
||||
label_hot_project: '热门项目'
|
||||
|
|
|
@ -37,12 +37,19 @@ div.project {
|
|||
div.project a{
|
||||
color: #5B5B5B;
|
||||
}
|
||||
/*div.project{
|
||||
|
||||
div.project {
|
||||
overflow: hidden;
|
||||
/*white-space: nowrap;*/
|
||||
text-overflow: ellipsis;
|
||||
-o-text-overflow: ellipsis;
|
||||
}
|
||||
div.project>.nowrap {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
-o-text-overflow: ellipsis;
|
||||
}*/
|
||||
}
|
||||
|
||||
span.grey {
|
||||
float: right;
|
||||
|
|
Loading…
Reference in New Issue