From 9e05ecf5b40817d389d5c5fbe39cee7d370145b6 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Thu, 29 May 2014 21:42:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BB=E9=A1=B5=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../open_source_projects_controller.rb | 13 +++ app/models/bug_to_osp.rb | 4 + .../open_source_projects/_show_bug.html.erb | 4 +- .../open_source_projects/_show_memo.html.erb | 2 +- .../open_source_projects/allbug.html.erb | 89 +++++++++++++++++++ app/views/open_source_projects/index.html.erb | 2 +- .../open_source_projects/showbug.html.erb | 6 -- config/routes.rb | 1 + 8 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 app/views/open_source_projects/allbug.html.erb diff --git a/app/controllers/open_source_projects_controller.rb b/app/controllers/open_source_projects_controller.rb index 43a5e3d9a..ee3af10ce 100644 --- a/app/controllers/open_source_projects_controller.rb +++ b/app/controllers/open_source_projects_controller.rb @@ -78,6 +78,19 @@ class OpenSourceProjectsController < ApplicationController format.json { render json: @open_source_project } end end + + def allbug + @bugs = BugToOsp.visible + + @bug_count = @bugs.count + @bug_pages = Paginator.new @bug_count, per_page_option, params['page'] + @bugs = @bugs.includes(:bug).reorder("#{RelativeMemo.table_name}.created_at DESC").limit(@bug_pages.per_page).offset(@bug_pages.offset).all + + respond_to do |format| + format.html + format.json { render json: @open_source_project } + end + end def search diff --git a/app/models/bug_to_osp.rb b/app/models/bug_to_osp.rb index 5471bd3f9..9cd1d7359 100644 --- a/app/models/bug_to_osp.rb +++ b/app/models/bug_to_osp.rb @@ -5,4 +5,8 @@ class BugToOsp < ActiveRecord::Base validates_presence_of :osp_id, :relative_memo_id + scope :visible, lambda {|*args| + nil + } + end diff --git a/app/views/open_source_projects/_show_bug.html.erb b/app/views/open_source_projects/_show_bug.html.erb index adccff837..43ea2eac7 100644 --- a/app/views/open_source_projects/_show_bug.html.erb +++ b/app/views/open_source_projects/_show_bug.html.erb @@ -1,4 +1,4 @@ - +
@@ -59,7 +59,7 @@ - 帖子来源:<%=link_to topic.topic_resource, topic.url %> + 帖子来源:<%=link_to topic.topic_resource, topic.url, :target => '_blank' %> <%= no_use_link(topic, User.current) %> diff --git a/app/views/open_source_projects/_show_memo.html.erb b/app/views/open_source_projects/_show_memo.html.erb index 616ff9bf3..c5448a595 100644 --- a/app/views/open_source_projects/_show_memo.html.erb +++ b/app/views/open_source_projects/_show_memo.html.erb @@ -18,7 +18,7 @@ <% if topic.url.nil? || topic.url == '' %> <%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %> <% else %> - <%= link_to h(topic.subject), topic.url %> + <%= link_to h(topic.subject), topic.url, :target => '_blank' %> <% end %> diff --git a/app/views/open_source_projects/allbug.html.erb b/app/views/open_source_projects/allbug.html.erb new file mode 100644 index 000000000..1f7142866 --- /dev/null +++ b/app/views/open_source_projects/allbug.html.erb @@ -0,0 +1,89 @@ + + + + +
+ +
+ 共有 <%= link_to @bug_count %> 个安全贴子 +
+
+ <% if @bugs.any? %> + <% @bugs.each do |bug| %> + <% topic = bug.bug %> +
+ + + + + +
<%= 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%> + + + + + + + + + + + + + + + + + + + + + +
+ <% if topic.url.nil? || topic.url == '' %> + <%= link_to h(topic.subject), open_source_project_relative_memo_path(bug.open_source_project, topic) %> + <% else %> + <%= link_to h(topic.subject), topic.url, :target => '_blank' %> + <% end %> + + + + + + + +
<%= link_to (topic.replies_count), topic.url, :target => '_blank' %>
回帖
+ + + + + + + +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
关注
+ + + + + + + +
<%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), topic.url, :target => '_blank' %>
浏览
<%= topic.short_content(100) %>
<%= user_url_and_time topic.username, topic.userhomeurl, topic.created_at %> +
+
帖子来源:<%=link_to topic.topic_resource, topic.url, :target => '_blank' %> +
+ + <% end %> + + <% else %> +

+ <%= l(:label_no_data) %> +

+ <% end %> +
+ +<%#= render :partial => 'open_source_projects/show_memo', :locals => {:memos => @memos, :open_source_project => @open_source_project} %> + \ No newline at end of file diff --git a/app/views/open_source_projects/index.html.erb b/app/views/open_source_projects/index.html.erb index f0b69bd47..04df580b2 100644 --- a/app/views/open_source_projects/index.html.erb +++ b/app/views/open_source_projects/index.html.erb @@ -144,7 +144,7 @@ li {
-

软件安全态势

More >>
+

软件安全态势

<%= link_to '更多 >>', allbug_open_source_projects_path %>
- -<% #= link_to '发布帖子', new_forum_memo_path(@forum), :class => 'icon icon-add' %> - - <%#= 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? %> -
<%#= link_to( diff --git a/config/routes.rb b/config/routes.rb index 5206dfd53..bbb95d360 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,6 +35,7 @@ RedmineApp::Application.routes.draw do collection do match 'search', via: [:get, :post] match 'remove_condition', via: [:get, :post] + match 'allbug', via: [:get, :post] end resources :relative_memos member do