sape 0.1.6 → 0.1.7

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: 32375f833f6695fe42316ad9bc8588222d986294
4
- data.tar.gz: e9d69ad7470915fa431ebbea8d95d7b0aff464ed
3
+ metadata.gz: 7c2e3d6a413fd885c2e7b07e3586b12e766f6d09
4
+ data.tar.gz: d56a3e37b0c91600f3b6809a71a349657d213671
5
5
  SHA512:
6
- metadata.gz: 2e5eed516e19f9938677740bd824ceee03102d89657aa800010de39cff0f3642cec623c3a5d5642ab2b5a6d74bd8a6c9be29fb82aa3a3ab43578178515877b1e
7
- data.tar.gz: 3441f604c712fe027455d1b2e211286cb61c8041e0da30342ab4e335811aa8c5448d175e8ab44faaaa33f22eb058404323c50c53a832ecc33781f986997e506e
6
+ metadata.gz: ea0e5439ff1fdff78682c156d36b9e277359424bb7e84169ec98c2f8a6ef735c872b7b555643b2da6c447766f4492f465be400d9cae5f788f6b4ba9fc4b891a6
7
+ data.tar.gz: 74463b54fb74fa34083dd17fdfb381ba6cbdc56c59582bd1371d29b18b29f271232311457d3bb32cb5abe2dbe2f44e4e481c30847a7ab32a0840acf18d3ecce9
@@ -2,8 +2,8 @@ module SapeHelper
2
2
  def sape_links_block(site_host = request.host)
3
3
  request.original_fullpath.chomp!("/") if request.original_fullpath.last == "/" && request.original_fullpath != '/'
4
4
  options = { links: SapeLink.where(page: request.original_fullpath, link_type: "simple", site_host: site_host) }
5
- if SapeConfig.bot_ips.include?(request.remote_addr)
6
- options.merge!(check_code: SapeConfig.check_code)
5
+ if SapeConfig.bot_ips(site_host).include?(request.remote_addr)
6
+ options.merge!(check_code: SapeConfig.check_code(site_host))
7
7
  end
8
8
 
9
9
  render template: 'sape/links', locals: options
@@ -15,9 +15,9 @@ module SapeHelper
15
15
  request.original_fullpath.chomp!("/") if request.original_fullpath.last == "/" && request.original_fullpath != '/'
16
16
  links = SapeLink.where(page: request.original_fullpath, link_type: "simple", site_host: site_host).
17
17
  pluck(:raw_link).
18
- join(SapeConfig.delimiter)
18
+ join(SapeConfig.delimiter(site_host))
19
19
 
20
- (SapeConfig.bot_ips.include?(request.remote_addr) ? (links + SapeConfig.check_code) : links).html_safe
20
+ (SapeConfig.bot_ips(site_host).include?(request.remote_addr) ? (links + SapeConfig.check_code(site_host)) : links).html_safe
21
21
  rescue Exception => e
22
22
  "<!-- ERROR: #{e.message} -->".html_safe
23
23
  end
@@ -28,8 +28,8 @@ module SapeHelper
28
28
  text.sub!(link.anchor, link.raw_link)
29
29
  end
30
30
 
31
- if SapeConfig.bot_ips.include?(request.remote_addr)
32
- "<sape_index>" + text + "</sape_index>" + SapeConfig.check_code
31
+ if SapeConfig.bot_ips(site_host).include?(request.remote_addr)
32
+ "<sape_index>" + text + "</sape_index>" + SapeConfig.check_code(site_host)
33
33
  else
34
34
  text
35
35
  end.html_safe
@@ -1,15 +1,15 @@
1
1
  class SapeConfig < ActiveRecord::Base
2
2
  class << self
3
- def bot_ips
4
- where(name: 'ip', site_host: request.host).pluck(:value)
3
+ def bot_ips(site_host)
4
+ where(name: 'ip', site_host: site_host.host).pluck(:value)
5
5
  end
6
6
 
7
- def check_code
8
- where(name: 'sape_new_url', site_host: request.host).first.try(:value) || " "
7
+ def check_code(site_host)
8
+ where(name: 'sape_new_url', site_host: site_host).first.try(:value) || " "
9
9
  end
10
10
 
11
- def delimiter
12
- where(name: 'sape_delimiter', site_host: request.host).first.try(:value) || " "
11
+ def delimiter(site_host)
12
+ where(name: 'sape_delimiter', site_host: site_host).first.try(:value) || " "
13
13
  end
14
14
  end
15
15
  end
data/lib/sape/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sape
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Rodionov