From 6dd37ae1d3bb4666567f1ab36f6198a36174161a Mon Sep 17 00:00:00 2001 From: stacytalbot Date: Tue, 17 Dec 2019 18:07:54 +0000 Subject: [PATCH] add basic layout for list of PAs --- Gemfile | 1 + Gemfile.lock | 2 ++ app/controllers/home_controller.rb | 10 ++++++---- app/views/home/index.html.erb | 9 ++++++++- app/views/partials/cards/_sites.html.erb | 25 ++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 app/views/partials/cards/_sites.html.erb diff --git a/Gemfile b/Gemfile index 17f99bd82..5c16cf746 100644 --- a/Gemfile +++ b/Gemfile @@ -46,6 +46,7 @@ group :development do gem 'capistrano-sidekiq','1.0.2' gem 'capistrano-git-with-submodules', '2.0.3' gem 'capistrano-service' + gem 'awesome_print' # gem 'listen', '~> 3.1.5' # gem 'spring-watcher-listen', '~> 2.0.0' # diff --git a/Gemfile.lock b/Gemfile.lock index c84e0b664..10a39d1d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,6 +61,7 @@ GEM arel (7.1.4) autoprefixer-rails (9.7.2) execjs + awesome_print (1.8.0) aws-eventstream (1.0.3) aws-partitions (1.246.0) aws-sdk (3.0.1) @@ -1248,6 +1249,7 @@ DEPENDENCIES activerecord-postgis-adapter (= 4.1.0) appsignal (~> 1.3.6) autoprefixer-rails + awesome_print aws-sdk (= 3.0.1) best_in_place (~> 3.0.1) byebug (~> 9.0, >= 9.0.5) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 169270c32..6b0b786d9 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -15,10 +15,12 @@ def index @news_articles_url = comfy_news.full_path @news_articles = comfy_news.children.published.order(created_at: :desc).limit(2) #TODO replace with correct pages #TODO get ordering to work - comfy_news = Comfy::Cms::Page.find_by_slug("resources") - @resources_title = comfy_news.label - @resources_url = comfy_news.full_path - @resources = comfy_news.children.published.order(created_at: :desc).limit(4) #TODO replace with correct pages #TODO get ordering to work + comfy_resources = Comfy::Cms::Page.find_by_slug("resources") + @resources_title = comfy_resources.label + @resources_url = comfy_resources.full_path + @resources = comfy_resources.children.published.order(created_at: :desc).limit(4) #TODO replace with correct pages #TODO get ordering to work + + @temp_pas = ProtectedArea.first(4) @regions_page = Comfy::Cms::Page.find_by_slug("unep-regions") diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index e4902f17f..87452399d 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -55,4 +55,11 @@ %> -<%= render "partials/ctas/live-report" %> \ No newline at end of file +<%= render "partials/ctas/live-report" %> + +<%= render partial: "partials/cards/sites", locals: + { + title: 'title', + cards: @temp_pas + } +%> \ No newline at end of file diff --git a/app/views/partials/cards/_sites.html.erb b/app/views/partials/cards/_sites.html.erb new file mode 100644 index 000000000..0cccc1c5c --- /dev/null +++ b/app/views/partials/cards/_sites.html.erb @@ -0,0 +1,25 @@ +
+ +

<%#= title %>

+ + <%#= link_to t('global.view_all'), url, target: '_blank', title: t('global.view_all') %> + +
+ <% cards.each do |card| %> + <%= link_to protected_area_path(card.wdpa_id), title: "View more about the site: #{card.name}", class: "card" do %> + <%= cover card %> + +

<%= card.name %>

+
+

+ <% card.countries_for_index.each do |country| %> + <%= country.iso_3 %> + <%= country.name %> + <% end %> +

+
+
+ <% end %> + <% end %> +
+ \ No newline at end of file