zen_seo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zen_seo (0.0.2)
4
+ zen_seo (0.0.3)
5
5
  meta-tags
6
6
  rails (~> 3.2.13)
7
7
 
@@ -46,13 +46,12 @@ GEM
46
46
  railties (>= 3.0, < 5.0)
47
47
  thor (>= 0.14, < 2.0)
48
48
  json (1.7.7)
49
- mail (2.5.3)
50
- i18n (>= 0.4.0)
49
+ mail (2.5.4)
51
50
  mime-types (~> 1.16)
52
51
  treetop (~> 1.4.8)
53
52
  meta-tags (1.4.1)
54
53
  actionpack
55
- mime-types (1.21)
54
+ mime-types (1.23)
56
55
  multi_json (1.7.2)
57
56
  polyglot (0.3.3)
58
57
  quiet_assets (1.0.2)
@@ -98,7 +97,7 @@ GEM
98
97
  sqlite3 (1.3.7)
99
98
  thor (0.18.0)
100
99
  tilt (1.3.6)
101
- treetop (1.4.12)
100
+ treetop (1.4.14)
102
101
  polyglot
103
102
  polyglot (>= 0.3.1)
104
103
  tzinfo (0.3.37)
data/README.md CHANGED
@@ -33,6 +33,23 @@ This will try to call `title`, `description`, `keywords` on your model to fill i
33
33
  end
34
34
  end
35
35
  ```
36
+ #### Excessive options
37
+ Note that you can pass excessive options that meta_tags support through :options key like so:
38
+ ```ruby
39
+ #app/models/post.rb
40
+ class Post < ActiveRecord::Base
41
+ attr_accessible :body, :tags, :title
42
+ has_seo :description=>:body,
43
+ :options=>{
44
+ :og => {
45
+ :title => :title,
46
+ :type => 'website',
47
+ :image => 'http://now.com/you_rock.jpg'
48
+ }
49
+ }
50
+ end
51
+ ```
52
+
36
53
 
37
54
  ###Controller
38
55
 
@@ -85,4 +102,4 @@ To set meta tags for your resource just put `fields_for :seo` in your form. Like
85
102
 
86
103
  ## Copyright
87
104
 
88
- Sergey Prikhodko originally developed by Jared Pace Copyright (c) 2010. See LICENSE for details.
105
+ Developed by Sergey Prikhodko Copyright (c) 2013. See LICENSE for details.
data/lib/zen_seo/base.rb CHANGED
@@ -31,15 +31,43 @@ module ZenSeo
31
31
  self.class.has_seo_config
32
32
  end
33
33
 
34
+ def to_meta
35
+ options_hash=fill_in(excessive_options)
36
+ options_hash.merge(seo_hash)
37
+ end
38
+
34
39
  private
40
+ def excessive_options
41
+ has_seo_config[:options] || {}
42
+ end
43
+
35
44
  def ensure_has_seo
36
45
  seo || self.build_seo
37
46
  end
38
47
 
39
48
  def generate_seo_fields
40
- seo.title= self.send (has_seo_config[:title]) if seo.title.blank?
41
- seo.description= self.send (has_seo_config[:description]) if seo.description.blank?
42
- seo.keywords= self.send (has_seo_config[:keywords]) if seo.keywords.blank?
49
+ seo.title= self.send(has_seo_config[:title]) if seo.title.blank?
50
+ seo.description= self.send(has_seo_config[:description]) if seo.description.blank?
51
+ seo.keywords= self.send(has_seo_config[:keywords]) if seo.keywords.blank?
52
+ end
53
+
54
+ def seo_hash
55
+ keys=[:title, :description, :keywords]
56
+ base_hash={}
57
+ keys.each do |key|
58
+ base_hash[key] = seo.send(key) || self.send(has_seo_config[key])
59
+ end
60
+ base_hash
61
+ end
62
+
63
+ def fill_in(hash)
64
+ hash.each do |k,v|
65
+ if v.is_a? Symbol
66
+ hash[k]=self.send(v)
67
+ elsif v.is_a? Hash
68
+ fill_in(v)
69
+ end
70
+ end
43
71
  end
44
72
 
45
73
  end
@@ -6,9 +6,7 @@ module ZenSeo
6
6
 
7
7
  module InstanceMethods
8
8
  def meta_tags_for(model)
9
- set_meta_tags :title=>model.seo.title,
10
- :description=>model.seo.description,
11
- :keywords=>model.seo.keywords
9
+ set_meta_tags model.to_meta
12
10
  end
13
11
  alias :meta_for :meta_tags_for
14
12
  protected :meta_tags_for
@@ -1,3 +1,3 @@
1
1
  module ZenSeo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,6 +1,14 @@
1
1
  class Post < ActiveRecord::Base
2
2
  attr_accessible :body, :tags, :title
3
- has_seo :description=>:body, :keywords=>:make_keywords
3
+ has_seo :description=>:body,
4
+ :keywords=>:make_keywords,
5
+ :options=>{
6
+ :og => {
7
+ :title => :title,
8
+ :type => 'website',
9
+ :image => 'http://now.com/you_rock.jpg'
10
+ }
11
+ }
4
12
  private
5
13
  def make_keywords
6
14
  self.tags.gsub(/:/, ', ')
data/spec/zen_seo_spec.rb CHANGED
@@ -3,13 +3,21 @@ require 'spec_helper'
3
3
  describe Post do
4
4
  before(:each) do
5
5
  @post = Post.new
6
+ @valid_post = Post.new(
7
+ :title => 'Title',
8
+ :body => 'Body',
9
+ :tags => 'keywords',
10
+ :seo_attributes=>{
11
+ :title => 'seo_title',
12
+ :description=> 'seo_description',
13
+ :keywords => 'key, word'})
6
14
  end
7
15
 
8
16
  it 'zen_seo should be bootstrapped' do
9
17
  Post.respond_to?(:has_seo).should be_true
10
18
  end
11
19
 
12
- it "should have seo association" do
20
+ it 'should have seo association' do
13
21
  @post.respond_to?(:seo).should be_true
14
22
  end
15
23
 
@@ -33,11 +41,21 @@ describe Post do
33
41
  @post.should be_valid
34
42
  end
35
43
 
36
- it 'should generate seo fields if no value given' do
44
+ it 'should generate seo fields if no value given' do
37
45
  @post= Post.new(
38
46
  :title => nil,
39
47
  :body => 'Body',
40
48
  :tags => 'keywords')
41
49
  @post.should_not be_valid
42
50
  end
51
+
52
+ it 'should respond to to_meta call' do
53
+ @valid_post.should respond_to :to_meta
54
+ end
55
+
56
+ it 'should compile to a hash of meta_tags options' do
57
+ meta_hash=@valid_post.to_meta
58
+ meta_hash.should be_a Hash
59
+ meta_hash[:og].should be_a Hash
60
+ end
43
61
  end
metadata CHANGED
@@ -2,25 +2,25 @@
2
2
  name: zen_seo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Serj Prikhodko
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-29 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- type: :runtime
16
- prerelease: false
17
- name: rails
18
15
  version_requirements: !ruby/object:Gem::Requirement
19
16
  requirements:
20
17
  - - ~>
21
18
  - !ruby/object:Gem::Version
22
19
  version: 3.2.13
23
20
  none: false
21
+ prerelease: false
22
+ name: rails
23
+ type: :runtime
24
24
  requirement: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ~>
@@ -28,15 +28,15 @@ dependencies:
28
28
  version: 3.2.13
29
29
  none: false
30
30
  - !ruby/object:Gem::Dependency
31
- type: :runtime
32
- prerelease: false
33
- name: meta-tags
34
31
  version_requirements: !ruby/object:Gem::Requirement
35
32
  requirements:
36
33
  - - ! '>='
37
34
  - !ruby/object:Gem::Version
38
35
  version: '0'
39
36
  none: false
37
+ prerelease: false
38
+ name: meta-tags
39
+ type: :runtime
40
40
  requirement: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ! '>='
@@ -127,23 +127,8 @@ files:
127
127
  - zen_seo.gemspec
128
128
  - zen_seo.gemspec~
129
129
  - spec/dummy/log/development.log
130
+ - spec/dummy/db/test.sqlite3
130
131
  - spec/dummy/db/development.sqlite3
131
- - spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
132
- - spec/dummy/tmp/cache/assets/E1C/CF0/sprockets%2Fa1bfe0c8cb9c6a2d3b00a914dcdfb494
133
- - spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994
134
- - spec/dummy/tmp/cache/assets/CC7/220/sprockets%2Fd066c004d1fd26ae76a61303a7a18145
135
- - spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705
136
- - spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6
137
- - spec/dummy/tmp/cache/assets/CAB/2B0/sprockets%2F7f42b56265da60e2e55070da5209187e
138
- - spec/dummy/tmp/cache/assets/D4C/0A0/sprockets%2F128b787007ed7bcc496f2cfe954054df
139
- - spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953
140
- - spec/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2
141
- - spec/dummy/tmp/cache/assets/DA0/4D0/sprockets%2F621e6ac32f63ecb1fcd158c408cd877f
142
- - spec/dummy/tmp/cache/assets/D1A/310/sprockets%2F5384ad85f52d3272dbc64d46ef3876a4
143
- - spec/dummy/tmp/cache/assets/CD5/B70/sprockets%2F416150dc3ac35079c94273cc46e90aa6
144
- - spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655
145
- - spec/dummy/tmp/cache/assets/D9C/CD0/sprockets%2Fc85016e7bbd4f3adbb7635d01f85d39b
146
- - spec/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212
147
132
  homepage: http://github.com/zengile/zen_seo
148
133
  licenses: []
149
134
  post_install_message: ! 'You are now on Zen promotion of zen_seo. Enjoy!
@@ -156,18 +141,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
141
  requirements:
157
142
  - - ! '>='
158
143
  - !ruby/object:Gem::Version
159
- hash: -493029168251905467
160
144
  segments:
161
145
  - 0
146
+ hash: -2531837570401268784
162
147
  version: '0'
163
148
  none: false
164
149
  required_rubygems_version: !ruby/object:Gem::Requirement
165
150
  requirements:
166
151
  - - ! '>='
167
152
  - !ruby/object:Gem::Version
168
- hash: -493029168251905467
169
153
  segments:
170
154
  - 0
155
+ hash: -2531837570401268784
171
156
  version: '0'
172
157
  none: false
173
158
  requirements: []
@@ -177,69 +162,54 @@ signing_key:
177
162
  specification_version: 3
178
163
  summary: Fancy way of forgetting about SEO issues.
179
164
  test_files:
180
- - spec/spec_helper.rb
181
- - spec/zen_seo_spec.rb
182
- - spec/dummy/log/development.log
183
- - spec/dummy/public/favicon.ico
184
- - spec/dummy/public/404.html
185
- - spec/dummy/public/422.html
186
- - spec/dummy/public/500.html
187
- - spec/dummy/config.ru
188
- - spec/dummy/README.rdoc
189
- - spec/dummy/test/fixtures/posts.yml
190
- - spec/dummy/test/functional/posts_controller_test.rb
191
- - spec/dummy/test/unit/helpers/posts_helper_test.rb
192
- - spec/dummy/test/unit/post_test.rb
193
- - spec/dummy/db/development.sqlite3
194
- - spec/dummy/db/migrate/20130329073248_create_posts.rb
195
- - spec/dummy/db/migrate/20130329073304_create_seos.rb
196
- - spec/dummy/db/schema.rb
197
- - spec/dummy/Rakefile
198
165
  - spec/dummy/script/rails
199
- - spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af
200
- - spec/dummy/tmp/cache/assets/E1C/CF0/sprockets%2Fa1bfe0c8cb9c6a2d3b00a914dcdfb494
201
- - spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994
202
- - spec/dummy/tmp/cache/assets/CC7/220/sprockets%2Fd066c004d1fd26ae76a61303a7a18145
203
- - spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705
204
- - spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6
205
- - spec/dummy/tmp/cache/assets/CAB/2B0/sprockets%2F7f42b56265da60e2e55070da5209187e
206
- - spec/dummy/tmp/cache/assets/D4C/0A0/sprockets%2F128b787007ed7bcc496f2cfe954054df
207
- - spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953
208
- - spec/dummy/tmp/cache/assets/CF0/1D0/sprockets%2F6fc757c2c8329244ca95d6909865bbc2
209
- - spec/dummy/tmp/cache/assets/DA0/4D0/sprockets%2F621e6ac32f63ecb1fcd158c408cd877f
210
- - spec/dummy/tmp/cache/assets/D1A/310/sprockets%2F5384ad85f52d3272dbc64d46ef3876a4
211
- - spec/dummy/tmp/cache/assets/CD5/B70/sprockets%2F416150dc3ac35079c94273cc46e90aa6
212
- - spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655
213
- - spec/dummy/tmp/cache/assets/D9C/CD0/sprockets%2Fc85016e7bbd4f3adbb7635d01f85d39b
214
- - spec/dummy/tmp/cache/assets/C8C/B80/sprockets%2F371bf96e99717688ed7313a0c53f4212
215
- - spec/dummy/config/boot.rb
216
166
  - spec/dummy/config/locales/en.yml
217
- - spec/dummy/config/initializers/wrap_parameters.rb
218
- - spec/dummy/config/initializers/backtrace_silencers.rb
219
- - spec/dummy/config/initializers/inflections.rb
220
- - spec/dummy/config/initializers/secret_token.rb
221
- - spec/dummy/config/initializers/session_store.rb
222
- - spec/dummy/config/initializers/mime_types.rb
223
- - spec/dummy/config/environments/test.rb
224
167
  - spec/dummy/config/environments/production.rb
168
+ - spec/dummy/config/environments/test.rb
225
169
  - spec/dummy/config/environments/development.rb
226
- - spec/dummy/config/environment.rb
227
- - spec/dummy/config/routes.rb
228
170
  - spec/dummy/config/application.rb
171
+ - spec/dummy/config/boot.rb
172
+ - spec/dummy/config/routes.rb
173
+ - spec/dummy/config/initializers/wrap_parameters.rb
174
+ - spec/dummy/config/initializers/session_store.rb
175
+ - spec/dummy/config/initializers/inflections.rb
176
+ - spec/dummy/config/initializers/mime_types.rb
177
+ - spec/dummy/config/initializers/backtrace_silencers.rb
178
+ - spec/dummy/config/initializers/secret_token.rb
229
179
  - spec/dummy/config/database.yml
230
- - spec/dummy/app/helpers/posts_helper.rb
180
+ - spec/dummy/config/environment.rb
181
+ - spec/dummy/log/development.log
231
182
  - spec/dummy/app/helpers/application_helper.rb
232
- - spec/dummy/app/models/post.rb
233
- - spec/dummy/app/views/posts/index.html.erb
234
- - spec/dummy/app/views/posts/new.html.erb
235
- - spec/dummy/app/views/posts/show.html.erb
236
- - spec/dummy/app/views/posts/edit.html.erb
237
- - spec/dummy/app/views/posts/_form.html.erb
238
- - spec/dummy/app/views/layouts/application.html.erb
183
+ - spec/dummy/app/helpers/posts_helper.rb
239
184
  - spec/dummy/app/controllers/posts_controller.rb
240
185
  - spec/dummy/app/controllers/application_controller.rb
241
- - spec/dummy/app/assets/stylesheets/application.css
242
- - spec/dummy/app/assets/stylesheets/scaffold.css
243
- - spec/dummy/app/assets/stylesheets/posts.css
244
186
  - spec/dummy/app/assets/javascripts/application.js
245
187
  - spec/dummy/app/assets/javascripts/posts.js
188
+ - spec/dummy/app/assets/stylesheets/scaffold.css
189
+ - spec/dummy/app/assets/stylesheets/posts.css
190
+ - spec/dummy/app/assets/stylesheets/application.css
191
+ - spec/dummy/app/views/layouts/application.html.erb
192
+ - spec/dummy/app/views/posts/index.html.erb
193
+ - spec/dummy/app/views/posts/_form.html.erb
194
+ - spec/dummy/app/views/posts/new.html.erb
195
+ - spec/dummy/app/views/posts/show.html.erb
196
+ - spec/dummy/app/views/posts/edit.html.erb
197
+ - spec/dummy/app/models/post.rb
198
+ - spec/dummy/Rakefile
199
+ - spec/dummy/db/migrate/20130329073248_create_posts.rb
200
+ - spec/dummy/db/migrate/20130329073304_create_seos.rb
201
+ - spec/dummy/db/test.sqlite3
202
+ - spec/dummy/db/schema.rb
203
+ - spec/dummy/db/development.sqlite3
204
+ - spec/dummy/test/functional/posts_controller_test.rb
205
+ - spec/dummy/test/unit/helpers/posts_helper_test.rb
206
+ - spec/dummy/test/unit/post_test.rb
207
+ - spec/dummy/test/fixtures/posts.yml
208
+ - spec/dummy/config.ru
209
+ - spec/dummy/README.rdoc
210
+ - spec/dummy/public/404.html
211
+ - spec/dummy/public/422.html
212
+ - spec/dummy/public/favicon.ico
213
+ - spec/dummy/public/500.html
214
+ - spec/zen_seo_spec.rb
215
+ - spec/spec_helper.rb