busk-ruby-readability 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/readability.rb +19 -1
- metadata +3 -3
data/lib/readability.rb
CHANGED
@@ -42,6 +42,8 @@ module Readability
|
|
42
42
|
article = get_article(candidates, best_candidate)
|
43
43
|
|
44
44
|
cleaned_article = sanitize(article, candidates, options)
|
45
|
+
cleaned_article = consider_special_cases(cleaned_article)
|
46
|
+
|
45
47
|
if remove_unlikely_candidates && article.text.strip.length < (options[:retry_length] || RETRY_LENGTH)
|
46
48
|
make_html
|
47
49
|
content(false)
|
@@ -49,7 +51,23 @@ module Readability
|
|
49
51
|
cleaned_article
|
50
52
|
end
|
51
53
|
end
|
52
|
-
|
54
|
+
|
55
|
+
def consider_special_cases(content)
|
56
|
+
if @input.base_uri.to_s =~ /^http:\/\/(www\.)?youtube.com/
|
57
|
+
if @input.base_uri.request_uri =~ /\?v=([_a-z0-9]+)&?/i
|
58
|
+
content = <<-HTML
|
59
|
+
<object width="480" height="385">
|
60
|
+
<param name="movie" value="http://www.youtube.com/v/#{$1}?fs=1&hl=en_US"></param>
|
61
|
+
<param name="allowFullScreen" value="true"></param>
|
62
|
+
<param name="allowscriptaccess" value="always"></param>
|
63
|
+
<embed src="http://www.youtube.com/v/#{$1}?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
|
64
|
+
</object>
|
65
|
+
HTML
|
66
|
+
end
|
67
|
+
end
|
68
|
+
content
|
69
|
+
end
|
70
|
+
|
53
71
|
def get_article(candidates, best_candidate)
|
54
72
|
# Now that we have the top candidate, look through its siblings for content that might also be related.
|
55
73
|
# Things like preambles, content split by ads that we removed, etc.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: busk-ruby-readability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors: []
|
13
13
|
|