sinatra_social_share_button 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ceb9cfa80867d021c9866e3e7d0c75e20f27511371620175633999840d640170
4
+ data.tar.gz: 2b5715d848e4ba664baf92b82eef7f2470413ea5ffef755f5f5f1392cfd3da0f
5
+ SHA512:
6
+ metadata.gz: ed2c301f7a8c93f844a5c72f514b1c8773732cc5fe0fc9984dbd9c47c5b0eb23b357d8e77d70f12137ee53cd95b572e88d077ce1b1f9bf48a133b9cdd1ff0bdc
7
+ data.tar.gz: c824a21dde020bada0fe78c0140ae2e994b95ea0acb16dbaf9997ab6a2aacf452c2286c97e19377fefd53d730a9673db8e9f19ed8fad337d00aefd4aa093b0ab
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Daniel Calixto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ 1. The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ 2. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Sinatra Social Share Button
2
+
3
+ A Sinatra helper to generate social share buttons.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sinatra_social_share_button'
11
+ And then execute:
12
+
13
+ bash
14
+
15
+ $ bundle install
16
+ Usage
17
+ ruby
18
+
19
+ require 'sinatra'
20
+ require 'sinatra_social_share_button'
21
+
22
+ class MyApp < Sinatra::Base
23
+ helpers SinatraSocialShareButton::Helpers
24
+
25
+ get '/' do
26
+ social_share_button_tag("Check this out!", "http://example.com")
27
+ end
28
+ end
29
+ Contributing
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dcalixto/sinatra_social_share_button.
31
+ ```
@@ -0,0 +1,53 @@
1
+ # lib/sinatra_social_share_button.rb
2
+ require 'sinatra'
3
+
4
+ module SinatraSocialShareButton
5
+ class << self
6
+ attr_accessor :config
7
+
8
+ def configure
9
+ yield self.config ||= Config.new
10
+ end
11
+ end
12
+
13
+ class Config
14
+ attr_accessor :allow_sites
15
+
16
+ def initialize
17
+ @allow_sites = %w[twitter facebook weibo qq douban google_bookmark
18
+ pinterest email linkedin wechat vkontakte
19
+ xing reddit hacker_news telegram odnoklassniki
20
+ whatsapp_app whatsapp_web]
21
+ end
22
+ end
23
+
24
+ module Helpers
25
+ def social_share_button_tag(title, url, _options = {})
26
+ allowed_sites = SinatraSocialShareButton.config.allow_sites
27
+ html = "<div class='social-share-button'>"
28
+ allowed_sites.each do |site|
29
+ share_url = generate_share_url(site, url, title)
30
+ html += "<a href='#{share_url}' target='_blank' class='share-button #{site}'>Share on #{site.capitalize}</a>"
31
+ end
32
+ html += '</div>'
33
+ html
34
+ end
35
+
36
+ private
37
+
38
+ def generate_share_url(site, url, title)
39
+ case site
40
+ when 'twitter'
41
+ "https://twitter.com/share?url=#{url}&text=#{title}"
42
+ when 'facebook'
43
+ "https://www.facebook.com/sharer/sharer.php?u=#{url}"
44
+ when 'pinterest'
45
+ "https://pinterest.com/pin/create/button/?url=#{url}&description=#{title}"
46
+ when 'linkedin'
47
+ "https://www.linkedin.com/shareArticle?mini=true&url=#{url}&title=#{title}"
48
+ else
49
+ '#'
50
+ end
51
+ end
52
+ end
53
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module SinatraSocialShareButton
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinatra_social_share_button
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - dcalixto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sinatra
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ description: This gem provides helper methods to create social share buttons in a
28
+ Sinatra application.
29
+ email:
30
+ - calixtodaniel@example.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE.txt
36
+ - README.md
37
+ - lib/sinatra_social_share_button.rb
38
+ - lib/version.rb
39
+ homepage: https://github.com/yourusername/sinatra_social_share_button
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '3.0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.5.16
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A Sinatra helper to generate social share buttons.
62
+ test_files: []