rgabo-readability 0.1.2 → 0.1.3
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/VERSION +1 -1
- data/lib/readability/js/readability.js +2 -2
- data/lib/readability/readable.rb +6 -2
- data/rgabo-readability.gemspec +1 -1
- data/spec/readability/readable_spec.rb +11 -20
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
@@ -575,7 +575,7 @@ var readability = {
|
|
575
575
|
dbg("replacing text node with a p tag with the same content.");
|
576
576
|
var p = document.createElement('p');
|
577
577
|
p.innerHTML = childNode.nodeValue;
|
578
|
-
|
578
|
+
p.setAttribute('style', 'display: inline;')
|
579
579
|
p.className = 'readability-styled';
|
580
580
|
childNode.parentNode.replaceChild(p, childNode);
|
581
581
|
}
|
@@ -962,7 +962,7 @@ var readability = {
|
|
962
962
|
var embedCount = 0;
|
963
963
|
var embeds = tagsList[i].getElementsByTagName("embed");
|
964
964
|
for(var ei=0,il=embeds.length; ei < il; ei++) {
|
965
|
-
if (embeds[ei].src.search(readability.regexps.videoRe) == -1) {
|
965
|
+
if (embeds[ei].src == null || embeds[ei].src.search(readability.regexps.videoRe) == -1) {
|
966
966
|
embedCount++;
|
967
967
|
}
|
968
968
|
}
|
data/lib/readability/readable.rb
CHANGED
@@ -23,8 +23,6 @@ module Readability
|
|
23
23
|
alias :remove :unlink
|
24
24
|
|
25
25
|
def to_readable(args = {})
|
26
|
-
args[:content_only] ||= false
|
27
|
-
|
28
26
|
# dup document
|
29
27
|
readable_doc = self.dup
|
30
28
|
|
@@ -42,6 +40,12 @@ module Readability
|
|
42
40
|
page.load(File.join(File.dirname(__FILE__), 'js', 'readability.js'))
|
43
41
|
end
|
44
42
|
|
43
|
+
# remove all linebreaks if needed
|
44
|
+
readable_doc.remove('br') if args[:remove_br]
|
45
|
+
|
46
|
+
# remove footer if needed
|
47
|
+
readable_doc.remove('#readFooter') if args[:remove_footer]
|
48
|
+
|
45
49
|
# return <div id="readInner">...</div> if content_only
|
46
50
|
if args[:content_only]
|
47
51
|
return readable_doc.at_css("#readInner")
|
data/rgabo-readability.gemspec
CHANGED
@@ -50,27 +50,16 @@ describe Readability::Readable do
|
|
50
50
|
content = @doc.to_readable(:content_only => true)
|
51
51
|
content.to_html.should_not include "Original Page"
|
52
52
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
# load webpage
|
61
|
-
@doc = Nokogiri::HTML(open("#{url}"))
|
62
|
-
|
63
|
-
# run readability in place
|
64
|
-
@doc.to_readable!
|
65
|
-
|
66
|
-
@doc.to_html.should include('Readability version 1.5.0')
|
67
|
-
end
|
68
|
-
EOF
|
69
|
-
end
|
70
|
-
end
|
53
|
+
|
54
|
+
it "can remove the footer" do
|
55
|
+
content = @doc.to_readable
|
56
|
+
content.to_html.should include "An Arc90 Laboratory Experiment"
|
57
|
+
|
58
|
+
content = @doc.to_readable(:remove_footer => true)
|
59
|
+
content.to_html.should_not include "An Arc90 Laboratory Experiment"
|
71
60
|
end
|
72
61
|
|
73
|
-
it "should not execute any Javascript" do
|
62
|
+
it "should not execute any Javascript in the document" do
|
74
63
|
# load modified version of the tomdoc post
|
75
64
|
@doc = Nokogiri::HTML(open(File.dirname(__FILE__) + '/../files/tomdoc-script_test.html'))
|
76
65
|
|
@@ -80,7 +69,9 @@ describe "Readability.js" do
|
|
80
69
|
# check whether any script could change the title of the document
|
81
70
|
@doc.window.document.title.should_not == "failed"
|
82
71
|
end
|
83
|
-
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "Readability.js" do
|
84
75
|
it "should not fail on any article" do
|
85
76
|
urls = YAML.load(File.open(File.join(File.dirname(__FILE__), 'urls.yaml')))
|
86
77
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgabo-readability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gabor Ratky
|