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 +4 -4
- data/lib/app/helpers/sape_helper.rb +6 -6
- data/lib/app/models/sape_config.rb +6 -6
- data/lib/sape/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c2e3d6a413fd885c2e7b07e3586b12e766f6d09
|
4
|
+
data.tar.gz: d56a3e37b0c91600f3b6809a71a349657d213671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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:
|
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:
|
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