social_share_rails 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdbe9722f79730e27ae5141a4494fdac952396a45681d47c651990531075c1a8
4
- data.tar.gz: 4b2a78f7dc02e9eeaf3d2c68c52e7355bf2fb43defeabe0e651fb75af38fde33
3
+ metadata.gz: 6a0ff64263ad9a668671c19b361a3645434b6304d3e0de2387b45739a8f93937
4
+ data.tar.gz: efc9a4e5f8439383ca8ddbf1ec12b5478b1739bc8f47665aadbd5e711b436e20
5
5
  SHA512:
6
- metadata.gz: f5bf4c96150f0e39e013999303bd72fdf63744b4c7e8a5626547024bf278671d8d0b811bff0568c39f203798b97a1f95b3b3fa6a12d5d8b15c35c7ac0c0505b4
7
- data.tar.gz: 28d30e12679f0f3c3f9103abe0e1f685187ea81e1af354ab2f2cdf58847afac98f280e17bc35a7a96ff653fe59ad05ac962e38775bfc3a1d9135560ab82b2617
6
+ metadata.gz: b876b4ec6d3a498c449dfa8fae77027efbc2c22462aadc0e3cc1927617c284f8ae8169d18d3ded71b6a255a9b5c1b99941ae896d67315bd42a1a4b85bdb02827
7
+ data.tar.gz: d259c5ea008f45177ebf1d00a8ea6fa2c1c289c77d986bc7427fc7465d0e696792483518639bf98d4c8dbb8c0c96d0592938731ee15a075ec8cf528295ef7647
data/README.md CHANGED
@@ -71,10 +71,23 @@ Add the `social_share` helper to your views:
71
71
  }) %>
72
72
  ```
73
73
 
74
+ #### Fallback to Current Page URL
75
+
76
+ If no url is provided, the helper will automatically use the current page URL (window.location.href) as the fallback. For example:
77
+
78
+ ```erb
79
+ <%= social_share("Share this post", {
80
+ allow_sites: %w[twitter facebook linkedin],
81
+ rounded: true
82
+ }) %>
83
+ ```
84
+ In this case, the current page URL will be shared.
85
+
86
+
74
87
  ### Options
75
88
 
76
89
  - **title** (String): The title of the post to share.
77
- - **url** (String): The URL to share.
90
+ - **url** (String): The URL to share (falls back to the current page URL if not provided).
78
91
  - **desc** (String): Optional description of the content.
79
92
  - **allow_sites** (Array): List of social platforms to include.
80
93
  - **rounded** (Boolean): If `true`, uses rounded icon styles.
@@ -24,7 +24,7 @@ window.SocialShare = {
24
24
  var parent = el.parentNode;
25
25
  var attributes = this.getEncodedAttributes(el, site, parent, ["title", "url", "desc"]);
26
26
  var title = attributes.title;
27
- var url = attributes.url;
27
+ var url = attributes.url || encodeURIComponent(window.location.href); // Use current URL if none provided
28
28
  var desc = attributes.desc;
29
29
  var img = encodeURIComponent(parent.getAttribute("data-img") || "");
30
30
  var via = encodeURIComponent(parent.getAttribute("data-via") || "");
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SocialShareRails
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_share_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleydson Tavares