social_linker 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc6408f41a1e641492c433391e3687782d8c83a3
4
- data.tar.gz: 10b8337604d14c7716bed6da38e90f93b95321d5
3
+ metadata.gz: 288dc63f2019995af9cc826b611f6833f38b4e2a
4
+ data.tar.gz: 929cb7b9986b851dc5474e51231b24a718c22075
5
5
  SHA512:
6
- metadata.gz: 294fea83d81de21684cb4478ee356640a818f3ccfd254224fcb216795c1d7a368612bf4b6972da67abfdd45768c45fd90924078d504ff81f64a4d741e29475f2
7
- data.tar.gz: b77e1978ba14e382a55ac4955a2d776e388da49501cc6fa4b6e181bc727460b888d9380bd323bf4d2f7583cb58fdf48738eeed5233c53928f752ea4c86bc99a5
6
+ metadata.gz: 8e0a9bd53da2b2b39ee8f23fd916919eadaab9d470def0b807278f27335f639693c0efee9d52ebbe893bdce9895b3a1f678923c48f6f5f54553596540083e914
7
+ data.tar.gz: 0d45542309ab9e6a830dfdd7b8f6653801a01c9b0fb608215daee1e8ba64bd259f29958772ea536efda50a8f9ce5c8eb5eb509a64da7346f052e7282dfadb594
data/README.md CHANGED
@@ -126,6 +126,32 @@ the following line to the head of your application.ccs file:
126
126
 
127
127
  *= require social_linker/icons
128
128
 
129
+ #### Reuse the SVG icons elsewhere
130
+
131
+ When integrating social icons into your site, you might also want to include login options
132
+ for these social networks, or access the icons for other reasons. Below is 'standard'
133
+ example code of how to access image-assets in the icon
134
+
135
+ <svg class="icon icon-facebook-official">
136
+ <use xlink:href="<%=image_path('social_linker/icons.svg')%>#icon-facebook"></use>
137
+ </svg>
138
+
139
+ Included layers:
140
+
141
+ * icon-email
142
+ * icon-google
143
+ * icon-sticky-note-o
144
+ * icon-share-square-o
145
+ * icon-search
146
+ * icon-heart-o
147
+ * icon-heart
148
+ * icon-twitter
149
+ * icon-pinterest
150
+ * icon-facebook
151
+ * icon-linkedin
152
+ * icon-whatsapp
153
+ * icon-tumblr
154
+
129
155
  #### Tip: SVG4Everyone
130
156
 
131
157
  When using SVG and serving your pages to older browsers, make sure you use something
@@ -1,3 +1,8 @@
1
+ $google-color: #E0492F;
2
+ $facebook-color: #395697;
3
+ $linkedin-color: #0077B5;
4
+ $twitter-color: #1DA1F2;
5
+
1
6
  .icon {
2
7
  display: inline-block;
3
8
  width: 1em;
@@ -34,6 +39,9 @@ Example showing how to change the color/size of the icons:
34
39
 
35
40
  .icon-twitter {
36
41
  width: 0.9287109375em;
42
+ .colored {
43
+ color: $twitter-color;
44
+ }
37
45
  }
38
46
 
39
47
  .icon-pinterest {
@@ -42,17 +50,63 @@ Example showing how to change the color/size of the icons:
42
50
 
43
51
  .icon-facebook {
44
52
  width: 0.857421875em;
53
+ .colored {
54
+ color: $facebook-color;
55
+ }
45
56
  }
46
57
 
47
58
  .icon-google {
48
59
  width: 0.83984375em;
60
+ .colored {
61
+ color: $google-color;
62
+ }
49
63
  }
50
64
  .icon-linkedin {
51
65
  width: 0.857421875em;
66
+ .colored {
67
+ color: $linkedin-color;
68
+ }
52
69
  }
53
70
  .icon-whatsapp {
54
71
  width: 0.857421875em;
55
72
  }
56
73
  .icon-tumblr {
57
74
  width: 0.609375em;
75
+
76
+ }
77
+
78
+ // Foundation/Bootstrap styles
79
+ .btn, .button {
80
+ svg.icon {
81
+ float: left;
82
+ font-size: 1.15em;
83
+ }
84
+ &.google {
85
+ background-color: $google-color;
86
+ color: #fff;
87
+ &:hover {
88
+ background-color: darken($google-color,10);
89
+ }
90
+ }
91
+ &.facebook {
92
+ background-color: $facebook-color;
93
+ color: #fff;
94
+ &:hover {
95
+ background-color: darken($facebook-color,10);
96
+ }
97
+ }
98
+ &.twitter {
99
+ background-color: $twitter-color;
100
+ color: #fff;
101
+ &:hover {
102
+ background-color: darken($twitter-color,10);
103
+ }
104
+ }
105
+ &.linkedin {
106
+ background-color: $linkedin-color;
107
+ color: #fff;
108
+ &:hover {
109
+ background-color: darken($linkedin-color,10);
110
+ }
111
+ }
58
112
  }
@@ -4,8 +4,10 @@ module ViewHelpers
4
4
  # param [String, Symbol] content (the value for the name or the property)
5
5
  # @returns [String, nil] nil is returned when the content is empty
6
6
  def meta_tag(name, content)
7
- name_or_property_section = name.start_with?("og:") ? "property=\"#{erb_sanitized(name)}\"" : "name=\"#{erb_sanitized(name)}\""
8
- "<meta #{name_or_property_section} content=\"#{erb_sanitized(content)}\" />" if content and content != ""
7
+ content = erb_sanitized(content)
8
+ name = erb_sanitized(name)
9
+ name_or_property_attribute = (name.start_with?("og:") or name.start_with?("fb:")) ? "property" : "name"
10
+ "<meta #{name_or_property_attribute}=\"#{name}\" content=\"#{content}\" />" if content and content.to_s.strip != ""
9
11
  end
10
12
 
11
13
  def erb_sanitized(value)
@@ -43,6 +45,8 @@ module ViewHelpers
43
45
  header_html << meta_tag("twitter:description", subject.summary(true))
44
46
  header_html << meta_tag("og:description", subject.summary(true))
45
47
 
48
+ header_html << meta_tag("fb:app_id", subject.options[:facebook_app_id])
49
+
46
50
  if subject.media
47
51
  header_html << meta_tag("twitter:image:src", subject.media)
48
52
  header_html << meta_tag("og:image", subject.media)
@@ -56,6 +60,7 @@ module ViewHelpers
56
60
  header_html << "<title>#{erb_sanitized(site_title)}</title>"
57
61
  header_html << meta_tag("twitter:title", title)
58
62
  header_html << meta_tag("og:title", title)
63
+ header_html << meta_tag("og:site_name", site_title_postfix)
59
64
 
60
65
  header_html.compact!
61
66
  header_html = header_html.join("\n") if header_html
@@ -82,7 +87,8 @@ module ViewHelpers
82
87
  raise ArgumentError, "network can't be nil" unless network
83
88
  options_with_defaults = {
84
89
  social_icons_image_path: 'social_linker/icons.svg',
85
- title: network.to_s.capitalize
90
+ title: network.to_s.capitalize,
91
+ target_blank: true
86
92
  }.merge(options)
87
93
 
88
94
  link_content = network
@@ -97,8 +103,8 @@ module ViewHelpers
97
103
  end
98
104
 
99
105
  title = options_with_defaults[:title]
100
-
101
- html = "<a href=\"#{erb_sanitized(subject.share_link(network))}\" class=\"#{network}\" title=\"#{title}\">#{link_content}</a>"
106
+ targetblank = options_with_defaults[:target_blank] ? " target=\"_blank\"" : ""
107
+ html = "<a href=\"#{erb_sanitized(subject.share_link(network))}\"#{targetblank} class=\"#{network}\" title=\"#{title}\">#{link_content}</a>"
102
108
  html = html.html_safe if html.methods.include?(:html_safe)
103
109
  html
104
110
  end
@@ -75,6 +75,10 @@ module SocialLinker
75
75
  @options[:url]
76
76
  end
77
77
 
78
+ def image_url
79
+ @options[:image_url]
80
+ end
81
+
78
82
  def utm_parameters
79
83
  [nil, true].include?(@options[:utm_parameters]) ? true : false
80
84
  end
@@ -140,6 +144,9 @@ module SocialLinker
140
144
  # * url
141
145
  # * title
142
146
  # * image_url & image_type(image/jpeg, image/png)
147
+ # * description
148
+ # * facebook_app_id
149
+ # * twitter_username
143
150
  # * ... and more often medium specific attributes...
144
151
  #
145
152
  # Note by default tracking parameters are added, turn this off by passing
@@ -149,6 +156,7 @@ module SocialLinker
149
156
  def initialize(options={})
150
157
  # basic option syncing
151
158
  @options = options
159
+ @options[:facebook_app_id] = @options[:facebook_app_id]
152
160
  @options[:u] = @options[:url] unless options[:u]
153
161
  @options[:media] = @options[:image_url] unless options[:media]
154
162
  @options[:description] = @options[:summary] unless options[:description]
@@ -189,6 +197,12 @@ module SocialLinker
189
197
  end
190
198
  @options[:message] = [@options[:tweet_text],@options[:url],@options[:hash_string]].compact.join(" ") unless @options[:message]
191
199
  @options[:status] = @options[:message] unless @options[:status]
200
+
201
+ # make sure urls are absolute
202
+ @options[:url] = prefix_domain(@options[:url],@options[:domain])
203
+ @options[:image_url] = prefix_domain(@options[:image_url],@options[:domain])
204
+ @options[:media] = prefix_domain(@options[:media],@options[:domain])
205
+
192
206
  unless @options[:body]
193
207
  @options[:body] = ""
194
208
  @options[:body] += "#{@options[:summary]}\n" if @options[:summary]
@@ -199,9 +213,6 @@ module SocialLinker
199
213
  @options[:body] = nil if @options[:body].strip == ""
200
214
  end
201
215
 
202
- @options[:image_url] = prefix_domain(@options[:image_url],@options[:domain])
203
- @options[:media] = prefix_domain(@options[:media],@options[:domain])
204
-
205
216
  @options.each do |k,v|
206
217
  @options[k] = v.strip if v and v.is_a? String
207
218
  end
@@ -1,3 +1,3 @@
1
1
  module SocialLinker
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_linker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - murb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-19 00:00:00.000000000 Z
11
+ date: 2017-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,4 +106,3 @@ specification_version: 4
106
106
  summary: Social linker generates share-links for the different social networks from
107
107
  a simple SocialLinker::Subject class
108
108
  test_files: []
109
- has_rdoc: