From 3b00f3c1415e6f4ac0326f5984b3311856613f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 6 May 2021 19:24:43 +0200 Subject: [PATCH] Remove duplication in social icons in footer --- .../layout/social_component.html.erb | 55 ++++--------------- app/components/layout/social_component.rb | 12 ++++ 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/app/components/layout/social_component.html.erb b/app/components/layout/social_component.html.erb index 147937371..447a7d3c6 100644 --- a/app/components/layout/social_component.html.erb +++ b/app/components/layout/social_component.html.erb @@ -1,51 +1,18 @@
    - <% if setting["twitter_handle"] %> -
  • - <%= link_to "https://twitter.com/#{setting["twitter_handle"]}", target: "_blank", - title: t("shared.go_to_page") + t("social.twitter", org: setting["org_name"]) + t("shared.target_blank") do %> - <%= t("social.twitter", org: setting["org_name"]) %> - - <% end %> -
  • - <% end %> - <% if setting["facebook_handle"] %> -
  • - <%= link_to "https://www.facebook.com/#{setting["facebook_handle"]}/", target: "_blank", - title: t("shared.go_to_page") + t("social.facebook", org: setting["org_name"]) + t("shared.target_blank") do %> - <%= t("social.facebook", org: setting["org_name"]) %> - - <% end %> -
  • - <% end %> - <% if setting["youtube_handle"] %> -
  • - <%= link_to "https://www.youtube.com/#{setting["youtube_handle"]}", target: "_blank", - title: t("shared.go_to_page") + t("social.youtube", org: setting["org_name"]) + t("shared.target_blank") do %> - <%= t("social.youtube", org: setting["org_name"]) %> - - <% end %> -
  • - <% end %> - <% if setting["telegram_handle"] %> -
  • - <%= link_to "https://www.telegram.me/#{setting["telegram_handle"]}", target: "_blank", - title: t("shared.go_to_page") + t("social.telegram", org: setting["org_name"]) + t("shared.target_blank") do %> - <%= t("social.telegram", org: setting["org_name"]) %> - - <% end %> -
  • - <% end %> - <% if setting["instagram_handle"] %> -
  • - <%= link_to "https://www.instagram.com/#{setting["instagram_handle"]}", target: "_blank", - title: t("shared.go_to_page") + t("social.instagram", org: setting["org_name"]) + t("shared.target_blank") do %> - <%= t("social.instagram", org: setting["org_name"]) %> - - <% end %> -
  • + <% sites.each do |name, url| %> + <% if setting["#{name}_handle"] %> +
  • + <%= link_to "#{url}/#{setting["#{name}_handle"]}", target: "_blank", + title: t("shared.go_to_page") + t("social.#{name}", org: setting["org_name"]) + t("shared.target_blank") do %> + <%= t("social.#{name}", org: setting["org_name"]) %> + + <% end %> +
  • + <% end %> <% end %> + <%= raw content_block("footer", I18n.locale) %>
diff --git a/app/components/layout/social_component.rb b/app/components/layout/social_component.rb index 101c1c165..accd15bc5 100644 --- a/app/components/layout/social_component.rb +++ b/app/components/layout/social_component.rb @@ -1,3 +1,15 @@ class Layout::SocialComponent < ApplicationComponent delegate :content_block, to: :helpers + + private + + def sites + { + twitter: "https://twitter.com", + facebook: "https://www.facebook.com", + youtube: "https://www.youtube.com", + telegram: "https://www.telegram.me", + instragram: "https://www.instagram.com" + } + end end