From 0bc4ba2ac2bda72c98c7082ea4a68d86485f6bab Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Fri, 18 Oct 2019 11:05:53 +0800 Subject: [PATCH] ADD more companies page --- app/controllers/homes_controller.rb | 19 +++++------- app/helpers/homes_helper.rb | 7 +++++ app/views/homes/_companies.html.erb | 2 +- app/views/homes/_home_partner.html.erb | 42 -------------------------- app/views/homes/index.html.erb | 2 +- app/views/homes/partners.html.erb | 16 ++++++++++ config/routes.rb | 4 ++- 7 files changed, 35 insertions(+), 57 deletions(-) delete mode 100644 app/views/homes/_home_partner.html.erb create mode 100644 app/views/homes/partners.html.erb diff --git a/app/controllers/homes_controller.rb b/app/controllers/homes_controller.rb index 7a882192b..7c06005f5 100644 --- a/app/controllers/homes_controller.rb +++ b/app/controllers/homes_controller.rb @@ -1,25 +1,20 @@ class HomesController < ApplicationController layout 'base_introduce' - before_filter :find_home, :except => [:index, :new, :create] + before_filter :find_home, :except => [:index, :new, :create, :partners] - # GET /homes - # GET /homes.json def index @home = Home.includes(:banners, :cover => [:file]).first -<<<<<<< HEAD - @dynamic_news = DynamicNew.limit(4) + @dynamic_news = DynamicNew.desc.limit(4) + @companies = WebFooterCompany.dedicators @first_companies_group = Array(@companies.slice(0, 5)) @second_companies_group = Array(@companies.slice(5, 8)) @third_companies_group = Array(@companies.slice(13, 4)) -======= - @dynamic_news = DynamicNew.desc.limit(4) - @companies = WebFooterCompany.dedicators.limit(26) - @first_companies_group = Array(@companies.slice(0, 8)) - @second_companies_group = Array(@companies.slice(8, 10)) - @third_companies_group = Array(@companies.slice(18, 8)) ->>>>>>> 849b928baec73ad593eddd55d1ca697c6baad78b + end + + def partners + @companies = WebFooterCompany.all.group_by {|company| company.key } end # GET /homes/1 diff --git a/app/helpers/homes_helper.rb b/app/helpers/homes_helper.rb index 7d2e7d6aa..52a80a228 100644 --- a/app/helpers/homes_helper.rb +++ b/app/helpers/homes_helper.rb @@ -21,4 +21,11 @@ module HomesHelper File.join("/files/uploads/image", file.disk_directory, file.disk_filename) end + def render_pool_name poll + case poll + when 'partner' then '合作机构' + when 'dedicator' then '合作共建平台' + else '合作机构' + end + end end diff --git a/app/views/homes/_companies.html.erb b/app/views/homes/_companies.html.erb index f73eddf97..dc9c210e3 100644 --- a/app/views/homes/_companies.html.erb +++ b/app/views/homes/_companies.html.erb @@ -25,7 +25,7 @@ <%= link_to image_tag(url_to_avatar(company),:alt=> company.name ), company.url, :target => "_blank" %> <% end %> <% if @companies.length > 17 %> - + <% end %> diff --git a/app/views/homes/_home_partner.html.erb b/app/views/homes/_home_partner.html.erb deleted file mode 100644 index ddc3d0872..000000000 --- a/app/views/homes/_home_partner.html.erb +++ /dev/null @@ -1,42 +0,0 @@ -
\ No newline at end of file diff --git a/app/views/homes/index.html.erb b/app/views/homes/index.html.erb index f0bce0212..414797ce7 100644 --- a/app/views/homes/index.html.erb +++ b/app/views/homes/index.html.erb @@ -48,4 +48,4 @@ <%= render :partial => 'companies' %> - \ No newline at end of file + diff --git a/app/views/homes/partners.html.erb b/app/views/homes/partners.html.erb new file mode 100644 index 000000000..61cc5b42c --- /dev/null +++ b/app/views/homes/partners.html.erb @@ -0,0 +1,16 @@ ++ 首页> + 开源生态 +
+ <% @companies.each do |pool, coms| %> +<%= render_pool_name(pool) %>
+