From 9b00600e5ca049ed8c8814356f2deda91064c10f Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Sat, 24 May 2025 17:32:46 +0300 Subject: [PATCH] Rename "social share buttons" to "share buttons" --- .../{social_share_button.js => share_buttons.js} | 0 ..._share_button_helper.rb => share_buttons_helper.rb} | 10 +++++----- app/views/diary_entries/show.html.erb | 4 ++-- ...ton_helper_test.rb => share_buttons_helper_test.rb} | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) rename app/assets/javascripts/{social_share_button.js => share_buttons.js} (100%) rename app/helpers/{social_share_button_helper.rb => share_buttons_helper.rb} (90%) rename test/helpers/{social_share_button_helper_test.rb => share_buttons_helper_test.rb} (69%) diff --git a/app/assets/javascripts/social_share_button.js b/app/assets/javascripts/share_buttons.js similarity index 100% rename from app/assets/javascripts/social_share_button.js rename to app/assets/javascripts/share_buttons.js diff --git a/app/helpers/social_share_button_helper.rb b/app/helpers/share_buttons_helper.rb similarity index 90% rename from app/helpers/social_share_button_helper.rb rename to app/helpers/share_buttons_helper.rb index 04f0729ab..5603462d2 100644 --- a/app/helpers/social_share_button_helper.rb +++ b/app/helpers/share_buttons_helper.rb @@ -1,7 +1,7 @@ -module SocialShareButtonHelper +module ShareButtonsHelper require "uri" - SOCIAL_SHARE_CONFIG = { + SHARE_BUTTONS_CONFIG = { :email => "social_icons/email.svg", :bluesky => "social_icons/bluesky.svg", :facebook => "social_icons/facebook.svg", @@ -11,8 +11,8 @@ module SocialShareButtonHelper :x => "social_icons/x.svg" }.freeze - # Generates a set of social share buttons based on the specified options. - def social_share_buttons(title:, url:) + # Generates a set of share buttons based on the specified options. + def share_buttons(title:, url:) tag.div( :class => "social-share-buttons d-flex gap-1 align-items-end flex-wrap mb-3" ) do @@ -28,7 +28,7 @@ module SocialShareButtonHelper end ] - buttons << SOCIAL_SHARE_CONFIG.map do |site, icon| + buttons << SHARE_BUTTONS_CONFIG.map do |site, icon| link_options = { :rel => "nofollow", :class => "rounded-circle focus-ring", diff --git a/app/views/diary_entries/show.html.erb b/app/views/diary_entries/show.html.erb index d92f77973..5afb9620c 100644 --- a/app/views/diary_entries/show.html.erb +++ b/app/views/diary_entries/show.html.erb @@ -1,5 +1,5 @@ <% content_for :head do %> - <%= javascript_include_tag "social_share_button" %> + <%= javascript_include_tag "share_buttons" %> <% end %> <% content_for :heading do %> @@ -15,7 +15,7 @@ <% end %> <%= render @diary_entry, :truncated => false %> -<%= social_share_buttons(:title => @diary_entry.title, :url => diary_entry_url(@diary_entry.user, @diary_entry)) %> +<%= share_buttons(:title => @diary_entry.title, :url => diary_entry_url(@diary_entry.user, @diary_entry)) %>
diff --git a/test/helpers/social_share_button_helper_test.rb b/test/helpers/share_buttons_helper_test.rb similarity index 69% rename from test/helpers/social_share_button_helper_test.rb rename to test/helpers/share_buttons_helper_test.rb index 0634632b8..20f9c3aa4 100644 --- a/test/helpers/social_share_button_helper_test.rb +++ b/test/helpers/share_buttons_helper_test.rb @@ -1,13 +1,13 @@ require "test_helper" -class SocialShareButtonHelperTest < ActionView::TestCase - include SocialShareButtonHelper +class ShareButtonsHelperTest < ActionView::TestCase + include ShareButtonsHelper - def test_social_share_buttons - buttons = social_share_buttons(:title => "Test Title", :url => "https://example.com") + def test_share_buttons + buttons = share_buttons(:title => "Test Title", :url => "https://example.com") buttons_dom = Rails::Dom::Testing.html_document_fragment.parse(buttons) - SOCIAL_SHARE_CONFIG.each_value do |icon| + SHARE_BUTTONS_CONFIG.each_value do |icon| assert_dom buttons_dom, "div:has(a img[src='/images/#{icon}'])", :count => 1 do assert_dom "a[href*='Test%20Title']" assert_dom "a[href*='https%3A%2F%2Fexample.com']" -- 2.39.5