spree_core 5.4.0.beta4 → 5.4.0.beta5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,72 +0,0 @@
1
- module Spree
2
- module Stores
3
- module Socials
4
- extend ActiveSupport::Concern
5
-
6
- SUPPORTED_SOCIAL_NETWORKS = %w[instagram facebook twitter pinterest tiktok youtube spotify discord].freeze
7
-
8
- SOCIAL_NETWORKS_CONFIG = {
9
- twitter: {
10
- input_placeholder: 'https://twitter.com/your_handle',
11
- profile_link: 'https://twitter.com/your_handle'
12
- },
13
- instagram: {
14
- input_placeholder: 'https://www.instagram.com/your_handle',
15
- profile_link: 'https://www.instagram.com/your_handle'
16
- },
17
- facebook: {
18
- input_placeholder: 'https://www.facebook.com/your_page',
19
- profile_link: 'https://www.facebook.com/your_page'
20
- },
21
- youtube: {
22
- input_placeholder: 'https://www.youtube.com/@your_channel',
23
- profile_link: 'https://www.youtube.com/@your_channel'
24
- },
25
- pinterest: {
26
- input_placeholder: 'https://pinterest.com/your_handle',
27
- profile_link: 'https://pinterest.com/your_handle'
28
- },
29
- tiktok: {
30
- input_placeholder: 'your_handle',
31
- profile_link: 'https://www.tiktok.com/@your_handle'
32
- },
33
- spotify: {
34
- input_placeholder: 'https://open.spotify.com/user/your_handle',
35
- profile_link: 'https://open.spotify.com/user/your_handle'
36
- },
37
- discord: {
38
- input_placeholder: 'https://discord.com/invite/your_handle',
39
- profile_link: 'https://discord.com/invite/your_handle'
40
- }
41
- }.freeze
42
-
43
- included do
44
- # generate methods for social links
45
- SUPPORTED_SOCIAL_NETWORKS.each do |social|
46
- # store the social handle in the public metadata
47
- store_accessor :public_metadata, social
48
-
49
- define_method "#{social}_link" do
50
- return if send(social).blank?
51
-
52
- send(social).match(/http/) ? send(social) : SOCIAL_NETWORKS_CONFIG[social.to_sym][:profile_link].gsub(/your_handle|your_page|your_channel/, send(social).sub(/^\//, '').sub(/^@/, ''))
53
- end
54
-
55
- define_method "#{social}_handle" do
56
- return if send(social).blank?
57
-
58
- (send(social).match(/http/) ? send(social).split('/').last : send(social)).sub(/^\//, '').gsub('@', '').split('?').first
59
- end
60
- end
61
- end
62
-
63
- def social_handle
64
- @social_handle ||= instagram_handle || youtube_handle || tiktok_handle
65
- end
66
-
67
- def social_links
68
- @social_links ||= [instagram_link, facebook_link, twitter_link, pinterest_link, youtube_link, tiktok_link, spotify_link, discord_link].compact_blank
69
- end
70
- end
71
- end
72
- end