seo_cache 0.6.0 → 0.7.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
  SHA256:
3
- metadata.gz: 7b68a9e261105de94049e080b3c540006f8c15a670ea52e67d29fbf42b7c313d
4
- data.tar.gz: bcc550d139cdeac6869317cf6584b05190280ae6c9c06c3e68b612783e3d4a07
3
+ metadata.gz: 00ac90cae823df12ec7ff2d7dcea46232c5539082805ca603a9f368b59772269
4
+ data.tar.gz: 74888e92eaf846115a953c56aa5600afc9714a6d0df81a0e1b74d842a11ea916
5
5
  SHA512:
6
- metadata.gz: ec47a5da40deb9f1e7f97036fd3965c85f14434a2fd9f47a8220e6df7a93ed8bdb2e2b2c4207e5b5ae95ed7bd527e2875f3966701e796cf4fd42a055b34c1544
7
- data.tar.gz: bc91d63e5350de11de4f32a62dec2968e0bbf2f0cb6c1888def636af7982f6f6760552e31d584794b4b9c1978e6c7f2473c9d87118760cf813c0fd32e8d41932
6
+ metadata.gz: 4d50d063591d7f2d5666b09703d03859323cea404ac518d0b679661724989a5497d6b7d54cc691dc2222e367c5f1e10dc8bd84accfdac6b2d92fdfbe7f6fdf69
7
+ data.tar.gz: 1320e4d3162b29de954fb0b8c975c00afc01919b4775737f3ce2be0436bc4ded63fa0a3ade46967e8720e5d1746a945597b2809143b7ce79a923268942965a48
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
+ ---
1
2
  sudo: false
2
3
  language: ruby
4
+ cache: bundler
3
5
  rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.16.1
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 2.0.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7.0
2
+
3
+ - Add whitelist hosts domain option (authorize only these domains)
4
+
1
5
  ## 0.6.0
2
6
 
3
7
  - Update gems (webdrivers and selenium-webdriver)
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Flo
3
+ Copyright (c) 2019 floXcoder
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -82,6 +82,12 @@ Activate missed cache urls:
82
82
  SeoCache.log_missed_cache = true
83
83
  ```
84
84
 
85
+ Domains to whitelist (authorize only domains which contains these hosts):
86
+
87
+ ```ruby
88
+ SeoCache.whitelist_hosts = []
89
+ ```
90
+
85
91
  URLs to blacklist:
86
92
 
87
93
  ```ruby
@@ -49,17 +49,17 @@ module SeoCache
49
49
  @logger.level = severity
50
50
  else
51
51
  case severity.to_s.downcase
52
- when 'debug'.freeze
52
+ when 'debug'
53
53
  @logger.level = DEBUG
54
- when 'info'.freeze
54
+ when 'info'
55
55
  @logger.level = INFO
56
- when 'warn'.freeze
56
+ when 'warn'
57
57
  @logger.level = WARN
58
- when 'error'.freeze
58
+ when 'error'
59
59
  @logger.level = ERROR
60
- when 'fatal'.freeze
60
+ when 'fatal'
61
61
  @logger.level = FATAL
62
- when 'unknown'.freeze
62
+ when 'unknown'
63
63
  @logger.level = UNKNOWN
64
64
  else
65
65
  raise ArgumentError, "invalid log level: #{severity}"
@@ -56,15 +56,11 @@ module SeoCache
56
56
  # If it is the generated page...don't prerender
57
57
  return false if query_params.has_key?(SeoCache.prerender_url_param)
58
58
 
59
- return false if SeoCache.blacklist_params.present? && SeoCache.blacklist_params.any? { |param| query_params.has_key?(param) }
60
-
61
- is_requesting_prerendered_page = true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_') || Rack::Utils.parse_query(request.query_string).has_key?(SeoCache.force_cache_url_param)
59
+ # if it is a bot and host doesn't contain these domains...don't prerender
60
+ return false if SeoCache.whitelist_hosts.present? && SeoCache.whitelist_hosts.any? { |host| !request.host.include?(host) }
62
61
 
63
- # if it is a bot...show prerendered page
64
- is_requesting_prerendered_page = true if @crawler_user_agents.any? { |crawler_user_agent| user_agent.downcase.include?(crawler_user_agent.downcase) }
65
-
66
- # if it is BufferBot...show prerendered page
67
- is_requesting_prerendered_page = true if buffer_agent
62
+ # if it is a bot and urls contain these params...don't prerender
63
+ return false if SeoCache.blacklist_params.present? && SeoCache.blacklist_params.any? { |param| query_params.has_key?(param) }
68
64
 
69
65
  # if it is a bot and is requesting a resource...don't prerender
70
66
  return false if @extensions_to_ignore.any? { |extension| request.fullpath.include? extension }
@@ -83,6 +79,14 @@ module SeoCache
83
79
  end
84
80
  return false if blacklisted_url
85
81
 
82
+ is_requesting_prerendered_page = true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_') || Rack::Utils.parse_query(request.query_string).has_key?(SeoCache.force_cache_url_param)
83
+
84
+ # if it is a bot...show prerendered page
85
+ is_requesting_prerendered_page = true if @crawler_user_agents.any? { |crawler_user_agent| user_agent.downcase.include?(crawler_user_agent.downcase) }
86
+
87
+ # if it is BufferBot...show prerendered page
88
+ is_requesting_prerendered_page = true if buffer_agent
89
+
86
90
  SeoCache.log('force cache : ' + request.path) if Rack::Utils.parse_query(request.query_string).has_key?(SeoCache.force_cache_url_param) && SeoCache.log_missed_cache
87
91
 
88
92
  return is_requesting_prerendered_page
@@ -1,3 +1,3 @@
1
1
  module SeoCache
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
data/lib/seo_cache.rb CHANGED
@@ -32,6 +32,9 @@ module SeoCache
32
32
  mattr_accessor :redis_namespace
33
33
  self.redis_namespace = '_seo_cache:'
34
34
 
35
+ mattr_accessor :whitelist_hosts
36
+ self.whitelist_hosts = []
37
+
35
38
  mattr_accessor :blacklist_urls
36
39
  self.blacklist_urls = []
37
40
 
data/seo_cache.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency 'selenium-webdriver', '3.141.0' # 3.142 is bugged
30
30
  spec.add_dependency 'webdrivers', '~> 4'
31
31
 
32
- spec.add_development_dependency 'bundler', '~> 1'
32
+ spec.add_development_dependency 'bundler', '~> 2'
33
33
  spec.add_development_dependency 'rake', '~> 12'
34
34
  spec.add_development_dependency 'rspec', '~> 3'
35
35
  spec.add_development_dependency 'simplecov', '~> 0.16'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seo_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FloXcoder
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1'
131
+ version: '2'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1'
138
+ version: '2'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rake
141
141
  requirement: !ruby/object:Gem::Requirement