angular_rails_seo 1.0.6 → 1.1.0

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: ae62160999d4faf93f64a4cb5ed3f7df5b644997
4
- data.tar.gz: 8b49bb808e37d281248643b54b7d0c721807238c
3
+ metadata.gz: 0b6ef66e28473ee46f95eb848316c3a7b19dcca1
4
+ data.tar.gz: 42be14f0827ea58796788122fea5d98e86facf88
5
5
  SHA512:
6
- metadata.gz: 6b052334c586bf2b2f70eb2b96bea58dfcdaf2651471d851be88509ec13d0862ab291b8978e158284d66d1b4cf53796ac0ca7659246d29a0cb34b53fa4d17f19
7
- data.tar.gz: 0b68b3578060104a6626b1e255666181796f9d5c5c14c2461b89df0dc047e0befe354942b2191934a61307a4d69824199aa1b3c1404230de08ef361255fecb4a
6
+ metadata.gz: 2b064d5da97630dd942c915db3e769fdf18a94880a358356f7763c034db9ff3e30b0404fe0979efed76ff67ce4522d5365b8a0926cc76c9df82980709757753b
7
+ data.tar.gz: cb8c6e37088dfc990a8e4138fc3e5aea1d98f096d435dd7db00af1276e21c5bbb8621c2d4489ec98224ca8357bc8a10ca36cd31a7b4b17054c5c3df4d5fb7be0
@@ -12,7 +12,7 @@ angular.module('angular-rails-seo', [])
12
12
 
13
13
  // Applies the passed SEO hash to the current page
14
14
  $seo.applyData = function(data) {
15
- if (!data.exclude) {
15
+ if (!data.exclude && data.title != null) {
16
16
  $seo.setTitle(data.title);
17
17
  }
18
18
  };
@@ -1,3 +1,3 @@
1
1
  module AngularRailsSeo
2
- VERSION = "1.0.6"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -2,21 +2,51 @@ module AngularRailsSeo
2
2
  module ViewHelpers
3
3
 
4
4
  ##
5
- # Returns SEO data as defined in initializes/seo.rb
5
+ # Returns SEO data as defined in in seo.json
6
6
  def seo_data
7
- Rails.configuration.seo.each do |key, value|
8
- unless Regexp.new(value["regex"]).match(request.path).nil?
9
- return seo_default.merge(Rails.configuration.seo[key])
7
+ if @seo_data.nil?
8
+ Rails.configuration.seo.each do |key, value|
9
+ regex = Regexp.new(value["regex"]).match(request.path)
10
+
11
+ unless regex.nil?
12
+ data = Rails.configuration.seo[key]
13
+ fallback = data["parent"].blank? ? seo_default : seo_default.merge(Rails.configuration.seo[data["parent"]])
14
+
15
+ unless data["model"].blank?
16
+ response = seo_dynamic(data["model"])
17
+ data = response.nil? ? {} : response
18
+ end
19
+
20
+ @seo_data = fallback.merge(data)
21
+ end
10
22
  end
11
23
  end
12
24
 
13
- seo_default
25
+ @seo_data ||= seo_default
14
26
  end
15
27
 
16
28
  def seo_default
17
29
  Rails.configuration.seo["default"]
18
30
  end
19
31
 
32
+ def seo_dynamic(class_name)
33
+ begin
34
+ klass = class_name.constantize
35
+ rescue
36
+ logger.warn "SEO: unable to retrieve SEO data for #{class_name}"
37
+ return nil
38
+ end
39
+
40
+ begin
41
+ response = klass.send_method(:seo_match, regex[1..(regex.size - 1)])
42
+ rescue
43
+ logger.warn "SEO: couldn't call seo_match method of #{class_name}"
44
+ return nil
45
+ end
46
+
47
+ return response
48
+ end
49
+
20
50
  ##
21
51
  # Author meta tags
22
52
  def seo_meta_author
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular_rails_seo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ellis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement