sh_button 0.1.1
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 +7 -0
- data/README.md +109 -0
- data/app/assets/images/sh_button/email.svg +1 -0
- data/app/assets/images/sh_button/facebook.svg +1 -0
- data/app/assets/images/sh_button/odnoklassniki.svg +1 -0
- data/app/assets/images/sh_button/sms.svg +1 -0
- data/app/assets/images/sh_button/twitter.svg +3 -0
- data/app/assets/images/sh_button/viber.svg +1 -0
- data/app/assets/images/sh_button/vkontakte.svg +1 -0
- data/app/assets/images/sh_button/whatsapp.svg +1 -0
- data/app/assets/javascripts/sh-button.coffee +8 -0
- data/app/assets/stylesheets/sh-button.css.erb +106 -0
- data/config/locales/sh-button.de.yml +11 -0
- data/config/locales/sh-button.en.yml +11 -0
- data/config/locales/sh-button.es.yml +11 -0
- data/config/locales/sh-button.fr.yml +11 -0
- data/config/locales/sh-button.ru.yml +11 -0
- data/config/locales/sh-button.uk.yml +11 -0
- data/config/locales/sh-button.zh-CN.yml +11 -0
- data/config/locales/sh-button.zh-TW.yml +11 -0
- data/lib/generators/sh_button/install_generator.rb +12 -0
- data/lib/generators/sh_button/templates/config/initializers/sh_button.rb +3 -0
- data/lib/sh_button.rb +13 -0
- data/lib/sh_button/config.rb +25 -0
- data/lib/sh_button/engine.rb +6 -0
- data/lib/sh_button/helper.rb +48 -0
- data/lib/sh_button/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 375e61e197f1a43445c36608fedb72fe4e57f44e1b54ff0d1c82d5b341ee4ccc
|
|
4
|
+
data.tar.gz: b124a5d80aab6ada950f98473fb69055f6a40c2d9389787e2acb98125ba45561
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ebd1ae936a6c205accf517c6da5436f42f6301ec30fad571efe40be1c0c1b5c45aab07d4020c8bf25871630158a81f75c093e66335b130917ac7cb3feecef710
|
|
7
|
+
data.tar.gz: 14e53fa97c061c5db75dc64adfd0cd46c5bccecbc9460a605dd6f2db74e8092a40e210e4681ca53ac8a486b3ae53edd11e8c3a669cc5908c043899960a56a5e0
|
data/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# SH_Button
|
|
2
|
+
|
|
3
|
+
This is a gem to helper you quick create a share feature in you Rails apps.
|
|
4
|
+
|
|
5
|
+
# Sites list
|
|
6
|
+
|
|
7
|
+
* Twitter
|
|
8
|
+
* Facebook
|
|
9
|
+
* Vkontakte
|
|
10
|
+
* Odnoklassniki
|
|
11
|
+
* Whatsapp
|
|
12
|
+
* Viber
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
In your `Gemfile`:
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
gem 'sh_button'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
And install it:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
$ bundle install
|
|
26
|
+
$ rails generate sh_button:install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configure
|
|
30
|
+
|
|
31
|
+
You can config `config/initializers/sh_button.rb` to choose which site do you want to use:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
SocialShareButton.configure do |config|
|
|
35
|
+
config.allow_sites = %w(twitter facebook vkontakte)
|
|
36
|
+
end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
You need add require css,js file in your app assets files:
|
|
42
|
+
|
|
43
|
+
`app/assets/javascripts/application.coffee`
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
#= require sh-button
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`app/assets/stylesheets/application.scss`
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
*= require sh-button
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
In Rails 4.1.6 , use `@import` to require files:
|
|
56
|
+
|
|
57
|
+
`app/assets/stylesheets/application.css.scss`
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
@import "sh-button";
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then you can use `social_share_button_tag` helper in views, for example `app/views/posts/show.html.erb`
|
|
64
|
+
|
|
65
|
+
```erb
|
|
66
|
+
<%= sh_button_tag(@post.title) %>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To specify sites at runtime:
|
|
70
|
+
|
|
71
|
+
```erb
|
|
72
|
+
<%= sh_button_tag(@post.title, :allow_sites => %w(twitter facebook)) %>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
And you can custom rel attribute:
|
|
76
|
+
|
|
77
|
+
```erb
|
|
78
|
+
<%= sh_button_tag(@post.title, :rel => "twipsy") %>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can also specify the URL that it links to:
|
|
82
|
+
|
|
83
|
+
```erb
|
|
84
|
+
<%= sh_button_tag(@post.title, :url => "http://myapp.com/foo/bar") %>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```erb
|
|
88
|
+
<%= sh_button_tag(@post.title, :url => "http://myapp.com/foo/bar", :image => "http://foo.bar/images/a.jpg") %>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Testing from localhost will not work
|
|
92
|
+
|
|
93
|
+
You will need to test from a live site or Facebook will reject it; localhost will not work.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## How to change icon size?
|
|
97
|
+
|
|
98
|
+
Yes, you can override social-share-button base css to change the icon size, margin, and form.
|
|
99
|
+
|
|
100
|
+
In you `app/assets/stylesheets/application.scss`:
|
|
101
|
+
|
|
102
|
+
```scss
|
|
103
|
+
.sh-button .sh-button-item {
|
|
104
|
+
border-radius: 10px;
|
|
105
|
+
height: 30px;
|
|
106
|
+
width: 30px;
|
|
107
|
+
margin-right: 6px;
|
|
108
|
+
}
|
|
109
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800"><g fill="#fff"><path d="M610.28 601.14c11.51 0 21.48-3.8 29.96-11.3L495.18 444.78c-3.48 2.49-6.85 4.91-10.04 7.22a669 669 0 0 1-26.43 18.7c-6.76 4.49-15.76 9.06-27 13.72-11.24 4.67-21.71 7-31.43 7H399.71c-9.71 0-20.19-2.33-31.43-7-11.24-4.66-20.24-9.23-27-13.71A672.9 672.9 0 0 1 314.85 452c-3.03-2.22-6.38-4.66-10.01-7.26l-145.09 145.1a43.77 43.77 0 0 0 29.97 11.3h420.56zM172.86 353.43A151.48 151.48 0 0 1 144 328.57v220.7l127.85-127.85a9884.15 9884.15 0 0 0-98.99-67.99zM627.43 353.43a8416.2 8416.2 0 0 0-99.23 68.04L656 549.27v-220.7a157.68 157.68 0 0 1-28.57 24.86z"/><path d="M610.28 198.86H189.72c-14.68 0-25.96 4.95-33.86 14.85-7.9 9.9-11.85 22.29-11.85 37.14 0 12 5.23 25 15.7 39 10.48 14 21.63 25 33.44 33 6.47 4.58 26 18.15 58.57 40.72 17.58 12.18 32.88 22.8 46.02 31.97 11.2 7.8 20.86 14.56 28.84 20.17l4.26 3.04 7.88 5.68c6.2 4.48 11.33 8.1 15.43 10.86 4.09 2.76 9.04 5.85 14.86 9.28 5.8 3.43 11.29 6 16.43 7.72a45.46 45.46 0 0 0 14.28 2.57H400.3c4.38 0 9.14-.86 14.29-2.57a86.49 86.49 0 0 0 16.43-7.72 304.5 304.5 0 0 0 14.86-9.28c4.1-2.77 9.23-6.38 15.43-10.86a1916.37 1916.37 0 0 1 12.14-8.72l28.91-20.1 104.8-72.76a135.9 135.9 0 0 0 34.86-35.14c9.32-13.7 13.99-28.09 13.99-43.14 0-12.57-4.53-23.33-13.57-32.29-9.05-8.95-19.77-13.42-32.15-13.42z"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 512 512"><path fill="#fff" d="M353.5 512V314h66.75l10-77.5H353.5v-49.36c0-22.39 6.22-37.64 38.32-37.64h40.68V80.37c-7.08-.94-31.37-3-59.62-3-59 0-99.38 36-99.38 102.14v57H207V314h66.5v198z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 389.404 387.417"><g fill="#FFF"><path d="M194.485 57.901c-38.593 0-69.878 31.286-69.878 69.878 0 38.593 31.285 69.881 69.878 69.881s69.878-31.288 69.878-69.881c0-38.592-31.285-69.878-69.878-69.878zm0 98.766c-15.953 0-28.886-12.934-28.886-28.887s12.933-28.886 28.886-28.886 28.886 12.933 28.886 28.886-12.933 28.887-28.886 28.887zM219.155 253.262c27.975-5.699 44.739-18.947 45.626-19.658 8.186-6.565 9.501-18.523 2.936-26.71-6.564-8.186-18.521-9.501-26.709-2.937-.173.14-18.053 13.856-47.472 13.876-29.418-.02-47.676-13.736-47.849-13.876-8.188-6.564-20.145-5.249-26.709 2.937-6.565 8.187-5.25 20.145 2.936 26.71.899.721 18.355 14.314 47.114 19.879l-40.081 41.888c-7.284 7.554-7.065 19.582.489 26.866 3.687 3.555 8.439 5.322 13.187 5.322 4.978 0 9.951-1.945 13.679-5.812l37.235-39.665 40.996 39.922c7.428 7.416 19.456 7.404 26.87-.021 7.414-7.426 7.405-19.456-.021-26.87l-42.227-41.851z"/><path d="M193.536 217.832c-.047 0 .046.001 0 .002-.046-.001.047-.002 0-.002z"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 75 75"><path fill="#fff" d="M37.5 17.440069c-11.5 0-20.9 8.1-20.9 18.2 0 5.8 3.1 11 8 14.3l-4.7 7.2c-.2.2.1.5.3.4 4.7-.6 8.9-2 12.5-4.3 1.5.3 3.1.5 4.8.5 11.5 0 20.9-8.1 20.9-18.2s-9.3-18.1-20.9-18.1z"/></svg>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">
|
|
2
|
+
<path fill="#fff" d="M153.6 301.6c94.3 0 145.9-78.2 145.9-145.9l-.1-6.6c10-7.2 18.7-16.3 25.6-26.6a104 104 0 0 1-29.5 8.1 51.6 51.6 0 0 0 22.6-28.4 102 102 0 0 1-32.6 12.4 51.2 51.2 0 0 0-87.4 46.8 145.6 145.6 0 0 1-105.7-53.6 51.3 51.3 0 0 0 15.9 68.5 51.9 51.9 0 0 1-23.2-6.4v.7a51.4 51.4 0 0 0 41.1 50.3 50 50 0 0 1-23.1.9 51.3 51.3 0 0 0 47.9 35.6 102.8 102.8 0 0 1-75.9 21.3 145.9 145.9 0 0 0 78.5 22.9"/>
|
|
3
|
+
</svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3200 3200"><g fill="#fff" fill-rule="evenodd"><path d="M2410.13359594 2036.80025781c-59.56054688-47.94921875-123.20800781-90.98632812-185.859375-134.95117187-124.95117188-87.75878906-239.23828125-94.58007813-332.47558594 46.61132812-52.35839844 79.26757813-125.65429688 82.73925781-202.29492188 47.96386719-211.27929687-95.80078125-374.42871093-243.40820313-469.99511718-458.15429688-42.27539063-95.00976562-41.71875-180.19042968 57.19238281-247.3876953 52.36816406-35.53710938 105.12695313-77.58789063 100.90820313-155.23925782-5.5078125-101.25-251.34277344-439.61425781-348.42285157-475.32714844-40.17089843-14.78027344-80.17578125-13.81835937-121.04492187-.08300781-227.63671875 76.55273437-321.92382813 263.76464844-231.62597656 485.43457031 269.38476562 661.33789063 743.45703125 1121.73828125 1396.04492187 1402.74414063 37.20703125 16.00097656 78.54003906 22.39746093 99.46777344 28.13964843 148.57421875 1.49414063 322.62207031-141.65039062 372.88574219-283.7109375 48.39355468-136.66992187-53.88183594-190.91796875-134.78027344-256.04003906zM1678.41972875 728.1186172c477.08496094 73.36425781 697.109375 300.21972656 757.86132813 780.73730468 5.63476562 44.38476563-10.8984375 111.171875 52.4267578 112.40234375 66.18164063 1.26464844 50.234375-64.5361328 50.79101563-108.96484375 5.59570313-452.55859375-389.00878906-872.09960937-847.28515625-887.56835937-34.57519531 4.97558594-106.11816406-23.84277344-110.58105468 53.65234375-2.97363282 52.24609375 57.26074218 43.66210937 96.78710937 49.74121094z"/><path d="M1771.74004125 859.87154687c-45.88867188-5.52734375-106.46972656-27.1484375-117.19238281 36.5234375-11.19628906 66.8310547 56.32324219 60.04394532 99.70703125 69.75585938 294.65820312 65.85449219 397.25585937 173.10058594 445.77148437 465.38574219 7.08496094 42.61230469-6.9921875 108.93554687 65.42480469 97.94433594 53.66699219-8.17382813 34.28222656-65.02441407 38.76953125-98.23242188 2.37792969-280.61523438-238.07617188-536.02539063-532.48046875-571.37695313z"/><path d="M1798.79570531 1089.3344375c-30.62988281.75683594-60.69335937 4.07226563-71.953125 36.80664063-16.90917968 48.92578124 18.66210938 60.5908203 54.86816407 66.40625 120.87402343 19.40429687 184.48730468 90.67871093 196.5625 211.2158203 3.26171875 32.71484376 24.0234375 59.22363282 55.625 55.49316407 43.7939453-5.22460938 47.75390625-44.20410156 46.4111328-81.22070313 2.16308595-135.41992187-150.8984375-291.94335937-281.51367187-288.70117187z"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256.00001"><path fill="#fff" fill-rule="evenodd" d="M204.3113005 86.93251c1.11125-3.7075 0-6.4325-5.2925-6.4325h-17.5c-4.45 0-6.50125 2.35375-7.61375 4.94875 0 0-8.89875 21.6925-21.50625 35.78275-4.07875 4.0785-5.9325 5.376375-8.1575 5.376375-1.1125 0-2.7225-1.297875-2.7225-5.005375v-34.67c0-4.45-1.29125-6.4325-5-6.4325h-27.50025c-2.78075 0-4.453125 2.065-4.453125 4.0225 0 4.21875 6.30325 5.19125 6.953125 17.05625v25.771375c0 5.649875-1.0205 6.67475-3.245 6.67475-5.932625 0-20.363875-21.789875-28.922375-46.721125-1.67775-4.84625-3.359875-6.80375-7.832625-6.80375h-17.5c-5 0-6 2.35375-6 4.94875 0 4.63625 5.933125 27.625 27.624625 58.03125 14.460875 20.763625 34.835375 32.02 53.375375 32.02 11.124 0 12.50025-2.5 12.50025-6.806125V153.00001c0-5 1.05375-5.9975 4.57625-5.9975 2.595 0 7.045 1.29725 17.4275 11.3085 11.86625 11.86675 13.8225 17.189 20.49625 17.189h17.5c5 0 7.5-2.5 6.0575-7.433625-1.5775-4.9175-7.24375-12.05125-14.76-20.50775-4.07875-4.821375-10.1975-10.01125-12.05125-12.6075-2.59625-3.337375-1.85375-4.82125 0-7.786625 0 0 21.32125-30.0345 23.54625-40.232"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 800"><defs><clipPath id="e"><path d="M0 1066.861h1280.244V0H0v1066.861z"/></clipPath><clipPath id="f"><path d="M392.927 773.982h496v-497h-496v497z"/></clipPath><clipPath id="a"><path d="M392.927 773.982h496v-497h-496v497z"/></clipPath><clipPath id="i"><path d="M420.927 746.982h438v-440h-438v440z"/></clipPath><clipPath id="b"><path d="M420.927 746.982h438v-440h-438v440z"/></clipPath><clipPath id="l"><path d="M0 1066.861h1280.244V0H0v1066.861z"/></clipPath><clipPath id="m"><path d="M417.927 752.982h444v-446h-444v446z"/></clipPath><clipPath id="c"><path d="M417.927 752.982h444v-446h-444v446z"/></clipPath><clipPath id="p"><path d="M432.555 532.885c-.013-36.747 9.588-72.618 27.838-104.237L430.804 320.61l110.564 28.991c30.462-16.613 64.76-25.368 99.664-25.381h.09c114.945 0 208.515 93.543 208.564 208.496.019 55.714-21.656 108.099-61.031 147.508-39.38 39.408-91.744 61.121-147.533 61.146-114.964 0-208.521-93.528-208.567-208.485m65.842-98.793l-4.127 6.555c-17.354 27.593-26.515 59.481-26.501 92.224.037 95.549 77.798 173.283 173.418 173.283 46.305-.019 89.824-18.068 122.557-50.822 32.729-32.753 50.74-76.295 50.726-122.602-.04-95.552-77.804-173.297-173.348-173.297h-.068c-31.111.016-61.621 8.369-88.231 24.16l-6.333 3.753-65.61-17.201 17.517 63.947zM641.122 324.22h0m0 0c-.002 0-.005 0 0 0"/></clipPath><linearGradient id="q" x2="1" gradientTransform="matrix(0 420.76019 420.76019 0 640.24524 320.60965)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#f9f9f9"/><stop offset="1" stop-color="#fff"/></linearGradient><clipPath id="r"><path d="M0 1066.861h1280.244V0H0v1066.861z"/></clipPath><clipPath id="s"><path d="M522.927 639.982h237v-222h-237v222z"/></clipPath><clipPath id="d"><path d="M522.927 639.982h237v-222h-237v222z"/></clipPath></defs><g clip-path="url(#e)" transform="matrix(1.25 0 0 -1.25 -401.15884 1056.85274)"><g><path fill="#fff" d="M546.4902 387.3468l6.333-3.754c26.611-15.791 57.12-24.143 88.231-24.16h.068c95.544 0 173.307 77.745 173.348 173.297.014 46.307-17.997 89.849-50.727 122.603-32.732 32.753-76.251 50.802-122.556 50.821-95.62 0-173.381-77.734-173.419-173.283-.013-32.743 9.148-64.631 26.502-92.224l4.126-6.555-17.517-63.947 65.611 17.202zm-115.686-66.737l29.589 108.039c-18.25 31.619-27.852 67.489-27.838 104.236.046 114.958 93.603 208.485 208.567 208.485 55.789-.024 108.153-21.738 147.533-61.145 39.374-39.41 61.05-91.795 61.031-147.509-.049-114.952-93.619-208.496-208.564-208.496-.008 0 .005 0 0 0h-.09c-34.903.014-69.202 8.768-99.664 25.381l-110.564-28.991z"/></g></g><g clip-path="url(#p)" transform="matrix(1.25 0 0 -1.25 -401.15884 1056.85274)"><path fill="url(#q)" d="M432.555 532.885c-.013-36.747 9.588-72.618 27.838-104.237L430.804 320.61l110.564 28.991c30.462-16.613 64.76-25.368 99.664-25.381h.09c114.945 0 208.515 93.543 208.564 208.496.019 55.714-21.656 108.099-61.031 147.508-39.38 39.408-91.744 61.121-147.533 61.146-114.964 0-208.521-93.528-208.567-208.485m65.842-98.793l-4.127 6.555c-17.354 27.593-26.515 59.481-26.501 92.224.037 95.549 77.798 173.283 173.418 173.283 46.305-.019 89.824-18.068 122.557-50.822 32.729-32.753 50.74-76.295 50.726-122.602-.04-95.552-77.804-173.297-173.348-173.297h-.068c-31.111.016-61.621 8.369-88.231 24.16l-6.333 3.753-65.61-17.201 17.517 63.947zM641.122 324.22h0m0 0c-.002 0-.005 0 0 0"/></g><g clip-path="url(#r)" transform="matrix(1.25 0 0 -1.25 -401.15884 1056.85274)"><g><path fill="#fff" fill-rule="evenodd" d="M588.9946 620.0432c-3.904 8.678-8.013 8.852-11.727 9.004-3.037.13-6.515.122-9.987.122-3.474 0-9.121-1.305-13.895-6.52-4.778-5.215-18.242-17.821-18.242-43.46 0-25.642 18.676-50.417 21.279-53.897 2.606-3.475 36.052-57.771 89.021-78.66 44.022-17.359 52.98-13.906 62.535-13.038 9.555.869 30.832 12.604 35.175 24.773 4.343 12.167 4.343 22.596 3.04 24.776-1.303 2.172-4.777 3.475-9.989 6.081-5.212 2.606-30.832 15.215-35.61 16.952-4.777 1.737-8.252 2.606-11.726-2.611-3.475-5.212-13.456-16.947-16.497-20.422-3.04-3.483-6.08-3.917-11.292-1.311-5.212 2.614-21.996 8.111-41.907 25.864-15.492 13.812-25.951 30.87-28.992 36.087-3.04 5.212-.325 8.035 2.289 10.633 2.34 2.335 5.212 6.083 7.818 9.126 2.6 3.043 3.469 5.215 5.206 8.69 1.737 3.48.869 6.523-.434 9.129s-11.431 28.378-16.065 38.682"/></g></g></svg>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$(".sh-button-popup").click ->
|
|
2
|
+
width = 640
|
|
3
|
+
height = 480
|
|
4
|
+
left = (screen.width / 2) - (width / 2)
|
|
5
|
+
top = (screen.height * 0.3) - (height / 2)
|
|
6
|
+
opt = "width=#{width},height=#{height},left=#{left},top=#{top},menubar=no,status=no,location=no"
|
|
7
|
+
window.open($(this).attr("href"), 'popup', opt)
|
|
8
|
+
false
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
.sh-button {
|
|
2
|
+
display: flex;
|
|
3
|
+
justify-content: flex-end;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sh-button .sh-button-item {
|
|
7
|
+
background-position: center center;
|
|
8
|
+
background-repeat: no-repeat;
|
|
9
|
+
border-radius: 10px;
|
|
10
|
+
display: block;
|
|
11
|
+
height: 30px;
|
|
12
|
+
width: 30px;
|
|
13
|
+
margin-right: 6px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.sh-button .sh-button-item:last-child {
|
|
17
|
+
margin-right: 0 !important;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.sh-button .sh-button-sms {
|
|
21
|
+
background-color: #db0108;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sh-button .sh-button-sms span {
|
|
25
|
+
display: inline-block;
|
|
26
|
+
background-image: url(<%= asset_path('sh_button/sms.svg') %>);
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sh-button .sh-button-email {
|
|
32
|
+
background-color: #68b030;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sh-button .sh-button-email span {
|
|
36
|
+
display: inline-block;
|
|
37
|
+
background-image: url(<%= asset_path('sh_button/email.svg') %>);
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sh-button .sh-button-twitter {
|
|
43
|
+
background-color: #1DA1F2;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sh-button .sh-button-twitter span {
|
|
47
|
+
display: inline-block;
|
|
48
|
+
background-image: url(<%= asset_path('sh_button/twitter.svg') %>);
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.sh-button .sh-button-facebook {
|
|
54
|
+
background-color: #4267b2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sh-button .sh-button-facebook span {
|
|
58
|
+
display: inline-block;
|
|
59
|
+
background-image: url(<%= asset_path('sh_button/facebook.svg') %>);
|
|
60
|
+
width: 100%;
|
|
61
|
+
height: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.sh-button .sh-button-vkontakte {
|
|
65
|
+
background-color: #5281b7;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.sh-button .sh-button-vkontakte span {
|
|
69
|
+
display: inline-block;
|
|
70
|
+
background-image: url(<%= asset_path('sh_button/vkontakte.svg') %>);
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sh-button .sh-button-odnoklassniki {
|
|
76
|
+
background-color: #f7931e;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.sh-button .sh-button-odnoklassniki span {
|
|
80
|
+
display: inline-block;
|
|
81
|
+
background-image: url(<%= asset_path('sh_button/odnoklassniki.svg') %>);
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.sh-button .sh-button-whatsapp {
|
|
87
|
+
background-color: #25d366;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.sh-button .sh-button-whatsapp span {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
background-image: url(<%= asset_path('sh_button/whatsapp.svg') %>);
|
|
93
|
+
width: 100%;
|
|
94
|
+
height: 100%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.sh-button .sh-button-viber {
|
|
98
|
+
background-color: #574e92;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.sh-button .sh-button-viber span {
|
|
102
|
+
display: inline-block;
|
|
103
|
+
background-image: url(<%= asset_path('sh_button/viber.svg') %>);
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: 100%;
|
|
106
|
+
}
|
data/lib/sh_button.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require "sh_button/version"
|
|
2
|
+
require "sh_button/config"
|
|
3
|
+
require "sh_button/helper"
|
|
4
|
+
require 'sh_button/engine'
|
|
5
|
+
|
|
6
|
+
I18n.load_path += Dir.glob( File.dirname(__FILE__) + "lib/locales/*.{rb,yml}" )
|
|
7
|
+
|
|
8
|
+
module ShButton
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ActiveSupport.on_load(:action_view) do
|
|
12
|
+
include ShButton::Helper
|
|
13
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module ShButton
|
|
2
|
+
class << self
|
|
3
|
+
attr_accessor :config
|
|
4
|
+
def configure
|
|
5
|
+
yield self.config ||= Config.new
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class Config
|
|
10
|
+
# enable social sites to share,
|
|
11
|
+
# * site support:
|
|
12
|
+
# - sms
|
|
13
|
+
# - email
|
|
14
|
+
# - twitter
|
|
15
|
+
# - facebook
|
|
16
|
+
# - vkontakte
|
|
17
|
+
# - odnoklassniki
|
|
18
|
+
# - whatsapp
|
|
19
|
+
# - viber
|
|
20
|
+
attr_accessor :allow_sites
|
|
21
|
+
|
|
22
|
+
def initialize
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module ShButton
|
|
2
|
+
module Helper
|
|
3
|
+
|
|
4
|
+
SH_BUTTON_NOT_POPUP = %w(email sms viber)
|
|
5
|
+
|
|
6
|
+
def sh_button_tag(title = "", opts = {})
|
|
7
|
+
opts[:allow_sites] ||= ShButton.config.allow_sites
|
|
8
|
+
|
|
9
|
+
html = []
|
|
10
|
+
html << "<div class='sh-button'>"
|
|
11
|
+
|
|
12
|
+
opts[:allow_sites].each do |site|
|
|
13
|
+
link_title = t "sh_button.share_to", name: t("sh_button.#{site.downcase}")
|
|
14
|
+
|
|
15
|
+
anchor_classes = "sh-button-item sh-button-#{site}"
|
|
16
|
+
anchor_classes << ' sh-button-popup' unless SH_BUTTON_NOT_POPUP.include? site
|
|
17
|
+
|
|
18
|
+
html << link_to(tag(:span, class: "sh-button-icon-#{site}"),share_link(site, title, opts[:url], opts[:image]),
|
|
19
|
+
class: anchor_classes, title: link_title,)
|
|
20
|
+
end
|
|
21
|
+
html << "</div>"
|
|
22
|
+
raw html.join("\n")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def share_link(site, title, url, img)
|
|
28
|
+
case site
|
|
29
|
+
when 'email'
|
|
30
|
+
"mailto:?to=&body=#{url},&subject=#{title}"
|
|
31
|
+
when 'twitter'
|
|
32
|
+
"https://twitter.com/intent/tweet?url=#{url}&text=#{title}"
|
|
33
|
+
when 'facebook'
|
|
34
|
+
"http://www.facebook.com/sharer/sharer.php?u=#{url}"
|
|
35
|
+
when 'vkontakte'
|
|
36
|
+
"https://vk.com/share.php?url=#{url}&title=#{title}&image=#{img}"
|
|
37
|
+
when 'odnoklassniki'
|
|
38
|
+
"https://connect.ok.ru/offer?url=#{url}&title=#{title}&imageUrl=#{img}"
|
|
39
|
+
when 'whatsapp'
|
|
40
|
+
"https://wa.me/?text=#{url}"
|
|
41
|
+
when 'viber'
|
|
42
|
+
"viber://forward?text=#{url}"
|
|
43
|
+
when 'sms'
|
|
44
|
+
"sms:?body=#{title + url}"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sh_button
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sergey Vershinin
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: coffee-rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
description: Helper for add social share feature in your Rails app. Twitter, Facebook,
|
|
42
|
+
Vkontakte, Odnoklassniki, WhatsApp, Viber
|
|
43
|
+
email:
|
|
44
|
+
- accountwm@gmail.com
|
|
45
|
+
executables: []
|
|
46
|
+
extensions: []
|
|
47
|
+
extra_rdoc_files: []
|
|
48
|
+
files:
|
|
49
|
+
- README.md
|
|
50
|
+
- app/assets/images/sh_button/email.svg
|
|
51
|
+
- app/assets/images/sh_button/facebook.svg
|
|
52
|
+
- app/assets/images/sh_button/odnoklassniki.svg
|
|
53
|
+
- app/assets/images/sh_button/sms.svg
|
|
54
|
+
- app/assets/images/sh_button/twitter.svg
|
|
55
|
+
- app/assets/images/sh_button/viber.svg
|
|
56
|
+
- app/assets/images/sh_button/vkontakte.svg
|
|
57
|
+
- app/assets/images/sh_button/whatsapp.svg
|
|
58
|
+
- app/assets/javascripts/sh-button.coffee
|
|
59
|
+
- app/assets/stylesheets/sh-button.css.erb
|
|
60
|
+
- config/locales/sh-button.de.yml
|
|
61
|
+
- config/locales/sh-button.en.yml
|
|
62
|
+
- config/locales/sh-button.es.yml
|
|
63
|
+
- config/locales/sh-button.fr.yml
|
|
64
|
+
- config/locales/sh-button.ru.yml
|
|
65
|
+
- config/locales/sh-button.uk.yml
|
|
66
|
+
- config/locales/sh-button.zh-CN.yml
|
|
67
|
+
- config/locales/sh-button.zh-TW.yml
|
|
68
|
+
- lib/generators/sh_button/install_generator.rb
|
|
69
|
+
- lib/generators/sh_button/templates/config/initializers/sh_button.rb
|
|
70
|
+
- lib/sh_button.rb
|
|
71
|
+
- lib/sh_button/config.rb
|
|
72
|
+
- lib/sh_button/engine.rb
|
|
73
|
+
- lib/sh_button/helper.rb
|
|
74
|
+
- lib/sh_button/version.rb
|
|
75
|
+
homepage: https://github.com/Yarroo/sh_button
|
|
76
|
+
licenses:
|
|
77
|
+
- MIT
|
|
78
|
+
metadata: {}
|
|
79
|
+
post_install_message:
|
|
80
|
+
rdoc_options: []
|
|
81
|
+
require_paths:
|
|
82
|
+
- lib
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
requirements: []
|
|
94
|
+
rubyforge_project:
|
|
95
|
+
rubygems_version: 2.7.7
|
|
96
|
+
signing_key:
|
|
97
|
+
specification_version: 4
|
|
98
|
+
summary: Helper for add social share feature in your Rails app. Twitter, Facebook,
|
|
99
|
+
Vkontakte, Odnoklassniki, WhatsApp, Viber
|
|
100
|
+
test_files: []
|