link_thumbnailer 2.2.3 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/CHANGELOG.md +18 -0
- data/README.md +4 -1
- data/lib/generators/templates/initializer.rb +1 -1
- data/lib/link_thumbnailer/configuration.rb +1 -1
- data/lib/link_thumbnailer/models/favicon.rb +25 -0
- data/lib/link_thumbnailer/models/website.rb +2 -1
- data/lib/link_thumbnailer/scraper.rb +2 -0
- data/lib/link_thumbnailer/scrapers/default/favicon.rb +36 -0
- data/lib/link_thumbnailer/scrapers/opengraph/favicon.rb +15 -0
- data/lib/link_thumbnailer/version.rb +1 -1
- data/spec/configuration_spec.rb +1 -1
- data/spec/fixture_spec.rb +6 -0
- data/spec/fixtures/default_from_body.html +1 -0
- data/spec/fixtures/default_from_meta.html +1 -0
- data/spec/fixtures/og_valid_example.html +1 -0
- data/spec/models/favicon_spec.rb +10 -0
- metadata +15 -14
- data/spec/examples/empty_og_image_example.html +0 -9
- data/spec/fixtures/example.html +0 -363
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZTlmNDRkNWViMjFlMjY3NzQwNTg5MzYwMWJmN2Q4M2QxMjdjMDJkNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2RlMmRlM2UxYmY3YTEyOGJiNWI2MzJjZWY1MDEzYTEzMzc5ZWNiMQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWM4NjJmZWM5YjAyZDdiYWIzMmQ4YjU5NTcxNmNkNzczNmJjMzhiMzFlZTFm
|
10
|
+
YzYzNzk3YzRlZjE3MWM4NzQ0ODYyNjU0ZTk3ODBhNmEwYmFlYjM5N2E0MTMz
|
11
|
+
YzNhNjI4ZjY5MzNiNTI4OGQ1NDVmYjEzMzI3OTkxOTUzNzY3ZjA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTE0MThjNzhkNDIwY2UxYmYwMTIwNDE5Y2ZmYWMyMWVmMGI4NjBhODZkMjNi
|
14
|
+
YjBhN2RmN2ExMDQ2YTMzMTYyNWE1NDg1MGM3Zjg1NTFhMGYyZjRlZmM0YWI2
|
15
|
+
OWI4NDE3M2Q3MjY2ODgyOWRlYzM2ZTZkMzQwZjEyNzEzM2VhOWE=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# 2.3.0
|
2
|
+
|
3
|
+
- Add requested favicon scraper [#40](https://github.com/gottfrois/link_thumbnailer/issues/40)
|
4
|
+
|
5
|
+
Add `:favicon` to `config.attributes` in LinkThumbnailer initializer:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
config.attributes = [:title, :images, :description, :videos, :favicon]
|
9
|
+
```
|
10
|
+
|
11
|
+
Then
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
o = LinkThumbnailer.generate('https://github.com')
|
15
|
+
o.favicon
|
16
|
+
=> "https://github.com/fluidicon.png"
|
17
|
+
```
|
18
|
+
|
1
19
|
# 2.2.3
|
2
20
|
|
3
21
|
- Fixes [#41](https://github.com/gottfrois/link_thumbnailer/issues/41)
|
data/README.md
CHANGED
@@ -58,6 +58,9 @@ The gem handle regular website but also website that use the [Opengraph](http://
|
|
58
58
|
object.title
|
59
59
|
=> "Stack Overflow"
|
60
60
|
|
61
|
+
object.favicon
|
62
|
+
=> "//cdn.sstatic.net/stackoverflow/img/favicon.ico?v=038622610830"
|
63
|
+
|
61
64
|
object.description
|
62
65
|
=> "Q&A for professional and enthusiast programmers"
|
63
66
|
|
@@ -108,7 +111,7 @@ In `config/initializers/link_thumbnailer.rb`
|
|
108
111
|
|
109
112
|
# List of attributes you want LinkThumbnailer to fetch on a website.
|
110
113
|
#
|
111
|
-
# config.attributes = [:title, :images, :description, :videos]
|
114
|
+
# config.attributes = [:title, :images, :description, :videos, :favicon]
|
112
115
|
|
113
116
|
# List of procedures used to rate the website description. Add you custom class
|
114
117
|
# here. Note that the order matter to compute the score. See wiki for more details
|
@@ -31,7 +31,7 @@ LinkThumbnailer.configure do |config|
|
|
31
31
|
|
32
32
|
# List of attributes you want LinkThumbnailer to fetch on a website.
|
33
33
|
#
|
34
|
-
# config.attributes = [:title, :images, :description, :videos]
|
34
|
+
# config.attributes = [:title, :images, :description, :videos, :favicon]
|
35
35
|
|
36
36
|
# List of procedures used to rate the website description. Add you custom class
|
37
37
|
# here. Note that the order matter to compute the score. See wiki for more details
|
@@ -41,7 +41,7 @@ module LinkThumbnailer
|
|
41
41
|
%r{^http://pixel\.quantserve\.com/},
|
42
42
|
%r{^http://s7\.addthis\.com/}
|
43
43
|
]
|
44
|
-
@attributes = [:title, :images, :description, :videos]
|
44
|
+
@attributes = [:title, :images, :description, :videos, :favicon]
|
45
45
|
@graders = [
|
46
46
|
->(description) { ::LinkThumbnailer::Graders::Length.new(description) },
|
47
47
|
->(description) { ::LinkThumbnailer::Graders::HtmlAttribute.new(description, :class) },
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'link_thumbnailer/model'
|
2
|
+
|
3
|
+
module LinkThumbnailer
|
4
|
+
module Models
|
5
|
+
class Favicon < ::LinkThumbnailer::Model
|
6
|
+
|
7
|
+
attr_reader :uri
|
8
|
+
|
9
|
+
def initialize(uri)
|
10
|
+
@uri = uri
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
uri.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def as_json(*)
|
18
|
+
{
|
19
|
+
src: to_s
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -4,7 +4,7 @@ module LinkThumbnailer
|
|
4
4
|
module Models
|
5
5
|
class Website < ::LinkThumbnailer::Model
|
6
6
|
|
7
|
-
attr_accessor :url, :title, :description, :images, :videos
|
7
|
+
attr_accessor :url, :title, :description, :images, :videos, :favicon
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@images = []
|
@@ -39,6 +39,7 @@ module LinkThumbnailer
|
|
39
39
|
def as_json(*)
|
40
40
|
{
|
41
41
|
url: url.to_s,
|
42
|
+
favicon: favicon,
|
42
43
|
title: title,
|
43
44
|
description: description,
|
44
45
|
images: images,
|
@@ -12,6 +12,8 @@ require 'link_thumbnailer/scrapers/default/images'
|
|
12
12
|
require 'link_thumbnailer/scrapers/opengraph/images'
|
13
13
|
require 'link_thumbnailer/scrapers/default/videos'
|
14
14
|
require 'link_thumbnailer/scrapers/opengraph/videos'
|
15
|
+
require 'link_thumbnailer/scrapers/default/favicon'
|
16
|
+
require 'link_thumbnailer/scrapers/opengraph/favicon'
|
15
17
|
|
16
18
|
module LinkThumbnailer
|
17
19
|
class Scraper < ::SimpleDelegator
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'link_thumbnailer/scrapers/default/base'
|
2
|
+
require 'link_thumbnailer/models/favicon'
|
3
|
+
|
4
|
+
module LinkThumbnailer
|
5
|
+
module Scrapers
|
6
|
+
module Default
|
7
|
+
class Favicon < ::LinkThumbnailer::Scrapers::Default::Base
|
8
|
+
|
9
|
+
def value
|
10
|
+
modelize(to_uri(href)).to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def to_uri(href)
|
16
|
+
::URI.parse(href)
|
17
|
+
rescue ::URI::InvalidURIError
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def href
|
22
|
+
node.attributes['href'].value.to_s if node
|
23
|
+
end
|
24
|
+
|
25
|
+
def node
|
26
|
+
document.xpath("//link[contains(@rel, 'icon')]").first
|
27
|
+
end
|
28
|
+
|
29
|
+
def modelize(uri)
|
30
|
+
model_class.new(uri)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe LinkThumbnailer::Configuration do
|
|
9
9
|
it { expect(instance.verify_ssl).to eq(true) }
|
10
10
|
it { expect(instance.http_timeout).to eq(5) }
|
11
11
|
it { expect(instance.blacklist_urls).to_not be_empty }
|
12
|
-
it { expect(instance.attributes).to eq([:title, :images, :description, :videos]) }
|
12
|
+
it { expect(instance.attributes).to eq([:title, :images, :description, :videos, :favicon]) }
|
13
13
|
it { expect(instance.graders).to_not be_empty }
|
14
14
|
it { expect(instance.description_min_length).to eq(25) }
|
15
15
|
it { expect(instance.positive_regex).to_not be_nil }
|
data/spec/fixture_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe 'Fixture' do
|
|
5
5
|
let(:url) { 'http://foo.com' }
|
6
6
|
let(:png_url) { 'http://foo.com/foo.png' }
|
7
7
|
let(:video_url) { 'http://foo.com/foo.swf' }
|
8
|
+
let(:favicon) { 'http://foo.com/foo.ico' }
|
8
9
|
let(:png) { File.open(File.dirname(__FILE__) + '/fixtures/foo.png') }
|
9
10
|
let(:action) { LinkThumbnailer.generate(url) }
|
10
11
|
|
@@ -22,6 +23,7 @@ describe 'Fixture' do
|
|
22
23
|
|
23
24
|
let(:html) { File.open(File.dirname(__FILE__) + '/fixtures/og_valid_example.html').read() }
|
24
25
|
|
26
|
+
it { expect(action.favicon).to eq(favicon) }
|
25
27
|
it { expect(action.title).to eq(title) }
|
26
28
|
it { expect(action.description).to eq(description) }
|
27
29
|
it { expect(action.images.count).to eq(1) }
|
@@ -42,6 +44,7 @@ describe 'Fixture' do
|
|
42
44
|
stub_request(:get, png_url_2).to_return(status: 200, body: png_2, headers: {})
|
43
45
|
end
|
44
46
|
|
47
|
+
it { expect(action.favicon).to eq('') }
|
45
48
|
it { expect(action.title).to eq(title) }
|
46
49
|
it { expect(action.description).to eq(description) }
|
47
50
|
it { expect(action.images.count).to eq(2) }
|
@@ -55,6 +58,7 @@ describe 'Fixture' do
|
|
55
58
|
let(:video_url_2) { 'http://foo.com/bar.swf' }
|
56
59
|
let(:html) { File.open(File.dirname(__FILE__) + '/fixtures/og_valid_multi_video_example.html').read() }
|
57
60
|
|
61
|
+
it { expect(action.favicon).to eq('') }
|
58
62
|
it { expect(action.title).to eq(title) }
|
59
63
|
it { expect(action.description).to eq(description) }
|
60
64
|
it { expect(action.videos.count).to eq(2) }
|
@@ -84,6 +88,7 @@ describe 'Fixture' do
|
|
84
88
|
let(:title) { 'Title from meta' }
|
85
89
|
let(:description) { 'Description from meta' }
|
86
90
|
|
91
|
+
it { expect(action.favicon).to eq(favicon) }
|
87
92
|
it { expect(action.title).to eq(title) }
|
88
93
|
it { expect(action.description).to eq(description) }
|
89
94
|
|
@@ -94,6 +99,7 @@ describe 'Fixture' do
|
|
94
99
|
let(:html) { File.open(File.dirname(__FILE__) + '/fixtures/default_from_body.html').read() }
|
95
100
|
let(:description) { 'Description from body' }
|
96
101
|
|
102
|
+
it { expect(action.favicon).to eq(favicon) }
|
97
103
|
it { expect(action.description).to eq(description) }
|
98
104
|
it { expect(action.images.count).to eq(1) }
|
99
105
|
it { expect(action.images.first.src.to_s).to eq(png_url) }
|
metadata
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_thumbnailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre-Louis Gottfrois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - '>='
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.7.7
|
34
34
|
- - ~>
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
|
-
- - '>='
|
41
|
+
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 1.7.7
|
44
44
|
- - ~>
|
@@ -48,14 +48,14 @@ dependencies:
|
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - '>='
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0.9'
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- - '>='
|
58
|
+
- - ! '>='
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0.9'
|
61
61
|
- !ruby/object:Gem::Dependency
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- lib/link_thumbnailer/image_validator.rb
|
150
150
|
- lib/link_thumbnailer/model.rb
|
151
151
|
- lib/link_thumbnailer/models/description.rb
|
152
|
+
- lib/link_thumbnailer/models/favicon.rb
|
152
153
|
- lib/link_thumbnailer/models/image.rb
|
153
154
|
- lib/link_thumbnailer/models/title.rb
|
154
155
|
- lib/link_thumbnailer/models/video.rb
|
@@ -161,11 +162,13 @@ files:
|
|
161
162
|
- lib/link_thumbnailer/scrapers/base.rb
|
162
163
|
- lib/link_thumbnailer/scrapers/default/base.rb
|
163
164
|
- lib/link_thumbnailer/scrapers/default/description.rb
|
165
|
+
- lib/link_thumbnailer/scrapers/default/favicon.rb
|
164
166
|
- lib/link_thumbnailer/scrapers/default/images.rb
|
165
167
|
- lib/link_thumbnailer/scrapers/default/title.rb
|
166
168
|
- lib/link_thumbnailer/scrapers/default/videos.rb
|
167
169
|
- lib/link_thumbnailer/scrapers/opengraph/base.rb
|
168
170
|
- lib/link_thumbnailer/scrapers/opengraph/description.rb
|
171
|
+
- lib/link_thumbnailer/scrapers/opengraph/favicon.rb
|
169
172
|
- lib/link_thumbnailer/scrapers/opengraph/image.rb
|
170
173
|
- lib/link_thumbnailer/scrapers/opengraph/images.rb
|
171
174
|
- lib/link_thumbnailer/scrapers/opengraph/title.rb
|
@@ -175,12 +178,10 @@ files:
|
|
175
178
|
- lib/link_thumbnailer/video_parser.rb
|
176
179
|
- link_thumbnailer.gemspec
|
177
180
|
- spec/configuration_spec.rb
|
178
|
-
- spec/examples/empty_og_image_example.html
|
179
181
|
- spec/fixture_spec.rb
|
180
182
|
- spec/fixtures/bar.png
|
181
183
|
- spec/fixtures/default_from_body.html
|
182
184
|
- spec/fixtures/default_from_meta.html
|
183
|
-
- spec/fixtures/example.html
|
184
185
|
- spec/fixtures/foo.png
|
185
186
|
- spec/fixtures/og_not_valid_example.html
|
186
187
|
- spec/fixtures/og_valid_example.html
|
@@ -197,6 +198,7 @@ files:
|
|
197
198
|
- spec/image_validator_spec.rb
|
198
199
|
- spec/model_spec.rb
|
199
200
|
- spec/models/description_spec.rb
|
201
|
+
- spec/models/favicon_spec.rb
|
200
202
|
- spec/models/image_spec.rb
|
201
203
|
- spec/models/title_spec.rb
|
202
204
|
- spec/models/video_spec.rb
|
@@ -217,12 +219,12 @@ require_paths:
|
|
217
219
|
- lib
|
218
220
|
required_ruby_version: !ruby/object:Gem::Requirement
|
219
221
|
requirements:
|
220
|
-
- - '>='
|
222
|
+
- - ! '>='
|
221
223
|
- !ruby/object:Gem::Version
|
222
224
|
version: '0'
|
223
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
226
|
requirements:
|
225
|
-
- - '>='
|
227
|
+
- - ! '>='
|
226
228
|
- !ruby/object:Gem::Version
|
227
229
|
version: '0'
|
228
230
|
requirements: []
|
@@ -234,12 +236,10 @@ summary: Ruby gem ranking images from a given URL returning an object containing
|
|
234
236
|
and website informations.
|
235
237
|
test_files:
|
236
238
|
- spec/configuration_spec.rb
|
237
|
-
- spec/examples/empty_og_image_example.html
|
238
239
|
- spec/fixture_spec.rb
|
239
240
|
- spec/fixtures/bar.png
|
240
241
|
- spec/fixtures/default_from_body.html
|
241
242
|
- spec/fixtures/default_from_meta.html
|
242
|
-
- spec/fixtures/example.html
|
243
243
|
- spec/fixtures/foo.png
|
244
244
|
- spec/fixtures/og_not_valid_example.html
|
245
245
|
- spec/fixtures/og_valid_example.html
|
@@ -256,6 +256,7 @@ test_files:
|
|
256
256
|
- spec/image_validator_spec.rb
|
257
257
|
- spec/model_spec.rb
|
258
258
|
- spec/models/description_spec.rb
|
259
|
+
- spec/models/favicon_spec.rb
|
259
260
|
- spec/models/image_spec.rb
|
260
261
|
- spec/models/title_spec.rb
|
261
262
|
- spec/models/video_spec.rb
|
data/spec/fixtures/example.html
DELETED
@@ -1,363 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<!-- saved from url=(0019)http://www.foo.com/ -->
|
3
|
-
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
4
|
-
<meta charset="UTF-8">
|
5
|
-
<title>Title</title>
|
6
|
-
<link href="./example_files/style-3706572431311a3a4cf5c6f3266c9bce.css" media="all" rel="stylesheet" type="text/css">
|
7
|
-
<link href="./example_files/belt_layout1_google-1c8ee8bd905a6121e7a7ac73b7ffb888.css" media="all" rel="stylesheet" type="text/css">
|
8
|
-
<script src="./example_files/application-e8b3208729190cb9cc8a800ff3283fd8.js" type="text/javascript"></script>
|
9
|
-
<link href="./example_files/load_style.css" media="all" rel="stylesheet" type="text/css">
|
10
|
-
<meta content="authenticity_token" name="csrf-param">
|
11
|
-
<meta content="Mh9Ervhd7HlDNhhJdZ+nKec9RE0sn2FO8nyJXUrKUng=" name="csrf-token">
|
12
|
-
</head>
|
13
|
-
<body>
|
14
|
-
|
15
|
-
|
16
|
-
<style>
|
17
|
-
.listing .sitelinks{
|
18
|
-
padding:5px 15px;
|
19
|
-
}
|
20
|
-
|
21
|
-
.listing .sitelinks td{
|
22
|
-
padding-right:16px;
|
23
|
-
|
24
|
-
}
|
25
|
-
.listing .sitelinks a, .listing .ratings a{
|
26
|
-
color:#0000DE;
|
27
|
-
}
|
28
|
-
.listing .url a:hover{
|
29
|
-
color:#a02934;
|
30
|
-
}
|
31
|
-
.ratings{
|
32
|
-
color: #666666;
|
33
|
-
}
|
34
|
-
.listing{
|
35
|
-
margin-bottom:15px;
|
36
|
-
}
|
37
|
-
.listing .url {
|
38
|
-
font-size:16px;
|
39
|
-
}
|
40
|
-
.listing .host {
|
41
|
-
color:#a02934;
|
42
|
-
display:block;
|
43
|
-
font-size:16px;
|
44
|
-
text-decoration:none;
|
45
|
-
}
|
46
|
-
|
47
|
-
.listing .url a{
|
48
|
-
color:#0000DE;
|
49
|
-
line-height:auto;
|
50
|
-
}
|
51
|
-
.listing .description a{
|
52
|
-
text-decoration:none;
|
53
|
-
color:black;
|
54
|
-
font-size:16px;
|
55
|
-
line-height:12pt;
|
56
|
-
}
|
57
|
-
.listing .host a{
|
58
|
-
text-decoration:none;
|
59
|
-
color:#008000;
|
60
|
-
font-size:16px;
|
61
|
-
line-height:12pt;
|
62
|
-
}
|
63
|
-
</style>
|
64
|
-
<script src="./example_files/jquery-1.5.js"></script>
|
65
|
-
<script>
|
66
|
-
var google_about_url = '';
|
67
|
-
var ads_array = new Array();
|
68
|
-
var bottom_ads_array = new Array();
|
69
|
-
var webSearch = "";
|
70
|
-
var google_tag = "";
|
71
|
-
|
72
|
-
var genCatSearches_array=new Array();
|
73
|
-
var relatedSearches_array=new Array();
|
74
|
-
var popularCategories_array = new Array();
|
75
|
-
var digi_keyword_links_array = new Array();
|
76
|
-
var global_afd_response = "";
|
77
|
-
|
78
|
-
var call_num = 1;
|
79
|
-
function redirect(){
|
80
|
-
document.getElementById('results').innerHTML = "No results found";
|
81
|
-
}
|
82
|
-
|
83
|
-
function jscript_log(name, severity, message, page){
|
84
|
-
$.ajax({
|
85
|
-
type: "POST",
|
86
|
-
url: "/log_error",
|
87
|
-
data: {
|
88
|
-
name: name,
|
89
|
-
severity: severity,
|
90
|
-
domain: window.location.hostname,
|
91
|
-
message: message,
|
92
|
-
tag: google_tag,
|
93
|
-
page: page
|
94
|
-
},
|
95
|
-
context: document.body
|
96
|
-
})
|
97
|
-
}
|
98
|
-
|
99
|
-
function token_link(keyword){
|
100
|
-
window.location = '/results' + '?q=' + encodeURIComponent(keyword) + '&token=' + global_afd_response.token;
|
101
|
-
return false;
|
102
|
-
}
|
103
|
-
|
104
|
-
function link_to_google(){
|
105
|
-
if(google_about_url!=''){
|
106
|
-
window.open(google_about_url,'_blank');
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
function gadlink(ga, inner_text, visible_url){
|
111
|
-
visible_url = visible_url.replace(/<b>/gi,'')
|
112
|
-
visible_url = visible_url.replace(/<\/b>/gi,'')
|
113
|
-
return '<a ' +
|
114
|
-
'href="http://' + visible_url + '"' +
|
115
|
-
' onclick="window.open(\'' + ga.url + '\');return false;"' +
|
116
|
-
' target="_blank" ' +
|
117
|
-
'>' +
|
118
|
-
inner_text + '</a>';
|
119
|
-
|
120
|
-
}
|
121
|
-
|
122
|
-
function google_afd_ad_request_done(google_afd_response) {
|
123
|
-
if(google_afd_response.faillisted==true){
|
124
|
-
jscript_log('faillisted', 10, JSON.stringify(google_afd_response), "/")
|
125
|
-
}
|
126
|
-
if(google_afd_response.token || google_afd_response.ads){
|
127
|
-
|
128
|
-
global_afd_response = google_afd_response;
|
129
|
-
if(google_afd_response.feedback_url){
|
130
|
-
google_about_url = google_afd_response.feedback_url;
|
131
|
-
}
|
132
|
-
|
133
|
-
if (google_afd_response.ads && google_afd_response.ads.length > 0) {
|
134
|
-
var google_ads = google_afd_response.ads;
|
135
|
-
for (var i = 0; i < google_ads.length; i++) {
|
136
|
-
seller_ratings = google_ads[i].seller_ratings;
|
137
|
-
site_links = google_ads[i].sitelinks;
|
138
|
-
ads="";
|
139
|
-
ads +=
|
140
|
-
'<div class="listing"><div class="url">' +
|
141
|
-
gadlink(google_ads[i], google_ads[i].line1, google_ads[i].visible_url) +
|
142
|
-
'</div>';
|
143
|
-
if (seller_ratings) {
|
144
|
-
ads += '<div class="ratings">'+seller_ratings.advertiser_info+' <img src="/assets/'+seller_ratings.rating+'star.gif" border="0"> <a href="'+seller_ratings.source_url+'" target="_blank">('+seller_ratings.review_count+')</a></div>';
|
145
|
-
}
|
146
|
-
ads +=
|
147
|
-
'<div class="description">' + google_ads[i].line2 + ' ' +
|
148
|
-
(google_ads[i].line3 != undefined ? google_ads[i].line3 + '' : '') +
|
149
|
-
'</div>' +
|
150
|
-
'<div class="host">' +
|
151
|
-
gadlink(google_ads[i], google_ads[i].visible_url, google_ads[i].visible_url) +
|
152
|
-
'</div>';
|
153
|
-
if (site_links && site_links.length > 0) {
|
154
|
-
ads += '<table class="sitelinks" cellpadding=0 cellspacing=0 border=0>';
|
155
|
-
for (var x = 0; x < site_links.length; x++) {
|
156
|
-
if(x % 2 == 0){
|
157
|
-
ads += '<tr>';
|
158
|
-
}
|
159
|
-
ads +=
|
160
|
-
'<td class="sitelink">' +
|
161
|
-
gadlink(site_links[x], site_links[x].link_text, google_ads[i].visible_url) +
|
162
|
-
'</td>';
|
163
|
-
if(x % 2 == 1){
|
164
|
-
ads += '</tr>';
|
165
|
-
}
|
166
|
-
}
|
167
|
-
if(x % 2 == 0){
|
168
|
-
ads += '</tr>';
|
169
|
-
}
|
170
|
-
ads += '</table>';
|
171
|
-
}
|
172
|
-
|
173
|
-
ads += '</div>';
|
174
|
-
if(google_ads[i].position=="Top"){
|
175
|
-
ads_array.push(ads);
|
176
|
-
}else{
|
177
|
-
bottom_ads_array.push(ads);
|
178
|
-
}
|
179
|
-
}
|
180
|
-
}
|
181
|
-
|
182
|
-
if (google_afd_response.categories && google_afd_response.categories.length > 0) {
|
183
|
-
var google_categories = google_afd_response.categories;
|
184
|
-
for (var i = 0; i < google_categories.length; i++) {
|
185
|
-
subcats = google_categories[i].subcategories;
|
186
|
-
popularCategories =
|
187
|
-
'<div class="termgroup">' +
|
188
|
-
'<h3><a class="popular_category" ' +
|
189
|
-
'href="/#' + google_categories[i].term + '"' +
|
190
|
-
' onclick="window.location=\'/results' +
|
191
|
-
'?q=' + encodeURIComponent(google_categories[i].term) +
|
192
|
-
'&token=' + google_categories[i].token + '\';return false;"' +
|
193
|
-
'>' +
|
194
|
-
google_categories[i].term +
|
195
|
-
'</a></h3>';
|
196
|
-
for(var gci =0; gci < subcats.length; gci++){
|
197
|
-
popularCategories = popularCategories +
|
198
|
-
'<div class="term">' +
|
199
|
-
'<a class="popular_category" ' +
|
200
|
-
'href="/#' + subcats[gci].term + '"' +
|
201
|
-
' onclick="window.location=\'/results' +
|
202
|
-
'?q=' + encodeURIComponent(subcats[gci].term) +
|
203
|
-
'&token=' + subcats[gci].token + '\';return false;"' +
|
204
|
-
'>' +
|
205
|
-
subcats[gci].term +
|
206
|
-
'</a></div>';
|
207
|
-
}
|
208
|
-
popularCategories = popularCategories + '</div>';
|
209
|
-
popularCategories_array.push(popularCategories);
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
|
-
if (google_afd_response.link_units && google_afd_response.link_units.length > 0) {
|
214
|
-
var google_link_units = google_afd_response.link_units;
|
215
|
-
for (var i = 0; i < google_link_units.length; i++) {
|
216
|
-
relatedSearches =
|
217
|
-
'<div class="term">' +
|
218
|
-
'<a class="related_searches" ' +
|
219
|
-
'href="/#' + google_link_units[i].term + '"' +
|
220
|
-
' onclick="window.location=\'/results' +
|
221
|
-
'?q=' + encodeURIComponent(google_link_units[i].term) +
|
222
|
-
'&token=' + google_link_units[i].token + '\';return false;"' +
|
223
|
-
'>' +
|
224
|
-
google_link_units[i].term +
|
225
|
-
'</a>' +
|
226
|
-
'</div>';
|
227
|
-
relatedSearches_array.push(relatedSearches);
|
228
|
-
}
|
229
|
-
|
230
|
-
}
|
231
|
-
if (google_afd_response.link_units && google_afd_response.link_units.length > 0) {
|
232
|
-
var google_link_units = google_afd_response.link_units;
|
233
|
-
for (var i = 0; i < google_link_units.length; i++) {
|
234
|
-
relatedSearches = "";
|
235
|
-
if(i % 5 == 0){
|
236
|
-
relatedSearches += "<div class='termgroup'>";
|
237
|
-
}
|
238
|
-
relatedSearches +=
|
239
|
-
'<div class="term">' +
|
240
|
-
'<a class="related_searches" ' +
|
241
|
-
'href="/#' + google_link_units[i].term + '"' +
|
242
|
-
' onclick="window.location=\'/results' +
|
243
|
-
'?q=' + encodeURIComponent(google_link_units[i].term) +
|
244
|
-
'&token=' + google_link_units[i].token + '\';return false;"' +
|
245
|
-
'>' +
|
246
|
-
google_link_units[i].term +
|
247
|
-
'</a>' +
|
248
|
-
'</div>';
|
249
|
-
if(((i % 5) == 4) || ((i-1)==google_link_units.length)){
|
250
|
-
relatedSearches += "</div>";
|
251
|
-
}
|
252
|
-
if(((i+1) % 10 == 0)){
|
253
|
-
relatedSearches += "<div class='clear'> </div>";
|
254
|
-
}
|
255
|
-
genCatSearches_array.push(relatedSearches);
|
256
|
-
}
|
257
|
-
|
258
|
-
}
|
259
|
-
try{document.getElementById('results').innerHTML = ads_array.join("\n");}catch(error){}
|
260
|
-
try{document.getElementById('bottomresults').innerHTML = bottom_ads_array.join("\n");}catch(error){}
|
261
|
-
|
262
|
-
if(ads_array.length>1){
|
263
|
-
document.getElementById('sponsoredresults').style.display='block';
|
264
|
-
}
|
265
|
-
if(bottom_ads_array.length>1){
|
266
|
-
document.getElementById('bottomsponsoredresults').style.display='block';
|
267
|
-
}
|
268
|
-
|
269
|
-
try{document.getElementById('keywords').innerHTML = relatedSearches_array.join("\n");}catch(error){}
|
270
|
-
try{document.getElementById('gencats').innerHTML = genCatSearches_array.join("\n");}catch(error){}
|
271
|
-
// if(genCatSearches_array.length==0){
|
272
|
-
// try{
|
273
|
-
// document.getElementById('gencats').innerHTML = popularCategories_array.join("\n");
|
274
|
-
// }catch(error){}
|
275
|
-
// }
|
276
|
-
try{document.getElementById('popcats').innerHTML = popularCategories_array.join("\n");}catch(error){}
|
277
|
-
try{document.getElementById('token').value = google_afd_response.search_token;}catch(error){}
|
278
|
-
console.log(google_afd_response);
|
279
|
-
try{document.getElementById('token2').value = google_afd_response.search_token;}catch(error){}
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
|
-
function getParam(name) {
|
284
|
-
var match = new RegExp('[\?&]' + name + "=([^&]+)","i").exec(location.search);
|
285
|
-
if (match==null) return null;
|
286
|
-
else return decodeURIComponent(match[1]).replace(/\+/g,' ');
|
287
|
-
}
|
288
|
-
</script>
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
<center>
|
293
|
-
<div id="container">
|
294
|
-
<div id="header">
|
295
|
-
<div class="logo">
|
296
|
-
<a href="./example_files/example.html">Foo.com</a>
|
297
|
-
</div>
|
298
|
-
</div>
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
<div id="main">
|
307
|
-
<div class="image">
|
308
|
-
<img alt="Cordovabeach" border="0" src="./example_files/cordovabeach.jpg">
|
309
|
-
</div>
|
310
|
-
<div class="search">
|
311
|
-
<div class="catch_phrase">
|
312
|
-
<div id="wysiwyg_id_322" class="mercury-region" data-type="editable">Search FOO.com
|
313
|
-
</div>
|
314
|
-
</div>
|
315
|
-
<div id="search">
|
316
|
-
<form action="http://www.foo.com/results" method="/get">
|
317
|
-
<input class="search_field" name="q" type="text">
|
318
|
-
<input id="token" name="token" type="hidden" value="AG06ipADDhq1IogUPtnbN7KiSVdr6HlXngoTCITm8PO41bICFSENtAodnwEA0RgDIAA4AUCwAlCUjqIBUIO6sAhQ4a65DlDN_pgPUOK53A9Qqo3jD1C1q_YPUM3B_g9QivCIEVCU-qcTUIfrhBtQx4yNHVCsxv8eUPD02SBQ1PXZIFDd2ZEhUIOcrSlQu5ytKVDSsa0pUPKxrSlQ3KCvKVCTnKYtULKU5y1QsKX8U1CTtJSVAVDL74OWAVDqp6KyAVCslfPAAVC6lfPAAVCOl_PAAVCYrMGbA1DlhNOdA2iUjqIBcQL5qk1K1hZJggETCOW09_O41bICFfILtAodzTkAq5EBp8Lq2utL_VI">
|
319
|
-
<input class="search_button" type="submit" value="Search">
|
320
|
-
</form>
|
321
|
-
</div>
|
322
|
-
|
323
|
-
</div>
|
324
|
-
</div>
|
325
|
-
|
326
|
-
<div id="footer">
|
327
|
-
<a href="http://www.foo.com/digimedia_privacy_policy.html" target="_blank">Privacy Policy</a>
|
328
|
-
-
|
329
|
-
© 2012 Digimedia.com, L.P.
|
330
|
-
</div>
|
331
|
-
|
332
|
-
</div>
|
333
|
-
</center>
|
334
|
-
<script type="text/javascript">
|
335
|
-
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
336
|
-
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
337
|
-
</script><script src="./example_files/ga.js" type="text/javascript"></script>
|
338
|
-
<script type="text/javascript">
|
339
|
-
var pageTracker = _gat._getTracker('UA-1726084-83');
|
340
|
-
pageTracker._initData();
|
341
|
-
pageTracker._setDomainName('foo.com');
|
342
|
-
pageTracker._trackPageview('/');
|
343
|
-
</script>
|
344
|
-
|
345
|
-
<script>
|
346
|
-
google_tag = 'dp-digimedia_js';
|
347
|
-
var google_afd_request = {
|
348
|
-
client: 'ca-dp-digimedia-rs_js',
|
349
|
-
domain_name: 'www.foo.com',
|
350
|
-
num_ads: 0,
|
351
|
-
num_radlinks: 10,
|
352
|
-
token: getParam('token'),
|
353
|
-
q: getParam('q'),
|
354
|
-
kw: 'foo',
|
355
|
-
channel: 'afsonly'
|
356
|
-
}
|
357
|
-
</script>
|
358
|
-
<script language="JavaScript" src="./example_files/show_afd_ads.js" type="text/javascript"></script><script src="./example_files/domainpark.cgi"></script>
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
</body></html>
|