article_json 0.3.8 → 0.4.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +53 -0
- data/README.md +127 -79
- data/bin/article_json_export_amp.rb +1 -0
- data/bin/{article_json_export_facebook.rb → article_json_export_apple_news.rb} +4 -4
- data/bin/article_json_export_html.rb +1 -0
- data/bin/article_json_export_plain_text.rb +1 -0
- data/bin/article_json_parse_google_doc.rb +1 -0
- data/bin/check_google_doc_export.rb +41 -0
- data/bin/update_oembed_request-stubs.sh +1 -3
- data/bin/update_reference_document.sh +3 -3
- data/lib/article_json/article.rb +17 -9
- data/lib/article_json/configuration.rb +6 -5
- data/lib/article_json/elements/base.rb +0 -1
- data/lib/article_json/elements/heading.rb +0 -1
- data/lib/article_json/elements/image.rb +0 -1
- data/lib/article_json/elements/list.rb +0 -1
- data/lib/article_json/elements/paragraph.rb +1 -1
- data/lib/article_json/elements/quote.rb +0 -1
- data/lib/article_json/elements/text.rb +1 -1
- data/lib/article_json/elements/text_box.rb +0 -1
- data/lib/article_json/export/amp/custom_element_library_resolver.rb +0 -1
- data/lib/article_json/export/amp/elements/embed.rb +43 -31
- data/lib/article_json/export/amp/elements/image.rb +7 -5
- data/lib/article_json/export/amp/exporter.rb +4 -2
- data/lib/article_json/export/apple_news/elements/base.rb +53 -0
- data/lib/article_json/export/apple_news/elements/embed.rb +130 -0
- data/lib/article_json/export/apple_news/elements/heading.rb +32 -0
- data/lib/article_json/export/apple_news/elements/image.rb +59 -0
- data/lib/article_json/export/apple_news/elements/list.rb +67 -0
- data/lib/article_json/export/apple_news/elements/paragraph.rb +36 -0
- data/lib/article_json/export/apple_news/elements/quote.rb +60 -0
- data/lib/article_json/export/apple_news/elements/text.rb +55 -0
- data/lib/article_json/export/apple_news/elements/text_box.rb +51 -0
- data/lib/article_json/export/apple_news/exporter.rb +37 -0
- data/lib/article_json/export/common/html/elements/embed.rb +2 -1
- data/lib/article_json/export/common/html/elements/image.rb +2 -1
- data/lib/article_json/export/common/html/elements/text.rb +2 -0
- data/lib/article_json/import/google_doc/html/embedded_parser.rb +1 -0
- data/lib/article_json/import/google_doc/html/heading_parser.rb +5 -5
- data/lib/article_json/import/google_doc/html/image_parser.rb +18 -2
- data/lib/article_json/import/google_doc/html/list_parser.rb +2 -2
- data/lib/article_json/import/google_doc/html/node_analyzer.rb +25 -3
- data/lib/article_json/import/google_doc/html/parser.rb +7 -1
- data/lib/article_json/import/google_doc/html/shared/caption.rb +1 -0
- data/lib/article_json/import/google_doc/html/shared/float.rb +2 -0
- data/lib/article_json/import/google_doc/html/text_box_parser.rb +2 -1
- data/lib/article_json/import/google_doc/html/text_parser.rb +2 -0
- data/lib/article_json/utils/additional_element_placer.rb +2 -0
- data/lib/article_json/utils/o_embed_resolver/base.rb +14 -4
- data/lib/article_json/utils/o_embed_resolver/facebook_video.rb +17 -1
- data/lib/article_json/utils/o_embed_resolver/slideshare.rb +2 -2
- data/lib/article_json/utils/o_embed_resolver/youtube_video.rb +14 -1
- data/lib/article_json/version.rb +1 -1
- data/lib/article_json.rb +11 -11
- metadata +29 -26
- data/lib/article_json/export/facebook_instant_article/elements/base.rb +0 -30
- data/lib/article_json/export/facebook_instant_article/elements/embed.rb +0 -44
- data/lib/article_json/export/facebook_instant_article/elements/heading.rb +0 -11
- data/lib/article_json/export/facebook_instant_article/elements/image.rb +0 -11
- data/lib/article_json/export/facebook_instant_article/elements/list.rb +0 -11
- data/lib/article_json/export/facebook_instant_article/elements/paragraph.rb +0 -11
- data/lib/article_json/export/facebook_instant_article/elements/quote.rb +0 -30
- data/lib/article_json/export/facebook_instant_article/elements/text.rb +0 -11
- data/lib/article_json/export/facebook_instant_article/elements/text_box.rb +0 -40
- data/lib/article_json/export/facebook_instant_article/exporter.rb +0 -17
|
@@ -11,8 +11,8 @@ module ArticleJSON
|
|
|
11
11
|
# The URL for the oembed API call
|
|
12
12
|
# @return [String]
|
|
13
13
|
def oembed_url
|
|
14
|
-
'https://www.slideshare.net/api/oembed/2?format=json&url='\
|
|
15
|
-
|
|
14
|
+
'https://www.slideshare.net/api/oembed/2?format=json&url=' \
|
|
15
|
+
"#{source_url}"
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# The URL of the slideshow
|
|
@@ -11,7 +11,7 @@ module ArticleJSON
|
|
|
11
11
|
# The URL for the oembed API call
|
|
12
12
|
# @return [String]
|
|
13
13
|
def oembed_url
|
|
14
|
-
"
|
|
14
|
+
"https://www.youtube.com/oembed?format=json&url=#{source_url}"
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# The video URL of the element
|
|
@@ -19,6 +19,19 @@ module ArticleJSON
|
|
|
19
19
|
def source_url
|
|
20
20
|
"https://www.youtube.com/watch?v=#{@element.embed_id}"
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
protected
|
|
24
|
+
|
|
25
|
+
# @param [Hash] data
|
|
26
|
+
# @return [Hash]
|
|
27
|
+
def transform_api_response(data)
|
|
28
|
+
return data unless data&.dig(:thumbnail_url)
|
|
29
|
+
|
|
30
|
+
# Replace the default YouTube thumbnail with the max resolution version
|
|
31
|
+
data.merge(
|
|
32
|
+
thumbnail_url: data[:thumbnail_url].sub(%r{hqdefault\.jpg$}, 'maxresdefault.jpg')
|
|
33
|
+
)
|
|
34
|
+
end
|
|
22
35
|
end
|
|
23
36
|
end
|
|
24
37
|
end
|
data/lib/article_json/version.rb
CHANGED
data/lib/article_json.rb
CHANGED
|
@@ -77,6 +77,17 @@ require_relative 'article_json/export/html/elements/quote'
|
|
|
77
77
|
require_relative 'article_json/export/html/elements/embed'
|
|
78
78
|
require_relative 'article_json/export/html/exporter'
|
|
79
79
|
|
|
80
|
+
require_relative 'article_json/export/apple_news/elements/base'
|
|
81
|
+
require_relative 'article_json/export/apple_news/elements/text'
|
|
82
|
+
require_relative 'article_json/export/apple_news/elements/heading'
|
|
83
|
+
require_relative 'article_json/export/apple_news/elements/paragraph'
|
|
84
|
+
require_relative 'article_json/export/apple_news/elements/list'
|
|
85
|
+
require_relative 'article_json/export/apple_news/elements/image'
|
|
86
|
+
require_relative 'article_json/export/apple_news/elements/embed'
|
|
87
|
+
require_relative 'article_json/export/apple_news/elements/quote'
|
|
88
|
+
require_relative 'article_json/export/apple_news/elements/text_box'
|
|
89
|
+
require_relative 'article_json/export/apple_news/exporter'
|
|
90
|
+
|
|
80
91
|
require_relative 'article_json/export/amp/elements/base'
|
|
81
92
|
require_relative 'article_json/export/amp/elements/text'
|
|
82
93
|
require_relative 'article_json/export/amp/elements/paragraph'
|
|
@@ -89,15 +100,4 @@ require_relative 'article_json/export/amp/elements/embed'
|
|
|
89
100
|
require_relative 'article_json/export/amp/custom_element_library_resolver'
|
|
90
101
|
require_relative 'article_json/export/amp/exporter'
|
|
91
102
|
|
|
92
|
-
require_relative 'article_json/export/facebook_instant_article/elements/base'
|
|
93
|
-
require_relative 'article_json/export/facebook_instant_article/elements/text'
|
|
94
|
-
require_relative 'article_json/export/facebook_instant_article/elements/paragraph'
|
|
95
|
-
require_relative 'article_json/export/facebook_instant_article/elements/list'
|
|
96
|
-
require_relative 'article_json/export/facebook_instant_article/elements/heading'
|
|
97
|
-
require_relative 'article_json/export/facebook_instant_article/elements/quote'
|
|
98
|
-
require_relative 'article_json/export/facebook_instant_article/elements/text_box'
|
|
99
|
-
require_relative 'article_json/export/facebook_instant_article/elements/image'
|
|
100
|
-
require_relative 'article_json/export/facebook_instant_article/elements/embed'
|
|
101
|
-
require_relative 'article_json/export/facebook_instant_article/exporter'
|
|
102
|
-
|
|
103
103
|
require_relative 'article_json/article'
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: article_json
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Sager
|
|
8
8
|
- Manu Campos
|
|
9
9
|
- Nicolas Fricke
|
|
10
|
-
|
|
10
|
+
- Damien Dillon
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: nokogiri
|
|
@@ -46,14 +46,14 @@ dependencies:
|
|
|
46
46
|
requirements:
|
|
47
47
|
- - "~>"
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '
|
|
49
|
+
version: '2.2'
|
|
50
50
|
type: :development
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
|
54
54
|
- - "~>"
|
|
55
55
|
- !ruby/object:Gem::Version
|
|
56
|
-
version: '
|
|
56
|
+
version: '2.2'
|
|
57
57
|
- !ruby/object:Gem::Dependency
|
|
58
58
|
name: rspec
|
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -96,12 +96,16 @@ dependencies:
|
|
|
96
96
|
- - "~>"
|
|
97
97
|
- !ruby/object:Gem::Version
|
|
98
98
|
version: '0.8'
|
|
99
|
-
description: |
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
description: |2
|
|
100
|
+
`article_json` is a format definition for news articles and a ruby gem that
|
|
101
|
+
offers conversions from and to different formats:
|
|
102
|
+
- Parser for Google Doc HTML exports
|
|
103
|
+
- Converter to:
|
|
104
|
+
- simple HTML format
|
|
105
|
+
- AMP format
|
|
106
|
+
- Apple News Format (ANF)
|
|
107
|
+
- plain text
|
|
108
|
+
- JSON
|
|
105
109
|
email: info@devex.com
|
|
106
110
|
executables: []
|
|
107
111
|
extensions: []
|
|
@@ -112,11 +116,12 @@ files:
|
|
|
112
116
|
- LICENSE
|
|
113
117
|
- README.md
|
|
114
118
|
- bin/article_json_export_amp.rb
|
|
115
|
-
- bin/
|
|
119
|
+
- bin/article_json_export_apple_news.rb
|
|
116
120
|
- bin/article_json_export_google_doc.rb
|
|
117
121
|
- bin/article_json_export_html.rb
|
|
118
122
|
- bin/article_json_export_plain_text.rb
|
|
119
123
|
- bin/article_json_parse_google_doc.rb
|
|
124
|
+
- bin/check_google_doc_export.rb
|
|
120
125
|
- bin/update_oembed_request-stubs.sh
|
|
121
126
|
- bin/update_reference_document.sh
|
|
122
127
|
- lib/article_json.rb
|
|
@@ -142,6 +147,16 @@ files:
|
|
|
142
147
|
- lib/article_json/export/amp/elements/text.rb
|
|
143
148
|
- lib/article_json/export/amp/elements/text_box.rb
|
|
144
149
|
- lib/article_json/export/amp/exporter.rb
|
|
150
|
+
- lib/article_json/export/apple_news/elements/base.rb
|
|
151
|
+
- lib/article_json/export/apple_news/elements/embed.rb
|
|
152
|
+
- lib/article_json/export/apple_news/elements/heading.rb
|
|
153
|
+
- lib/article_json/export/apple_news/elements/image.rb
|
|
154
|
+
- lib/article_json/export/apple_news/elements/list.rb
|
|
155
|
+
- lib/article_json/export/apple_news/elements/paragraph.rb
|
|
156
|
+
- lib/article_json/export/apple_news/elements/quote.rb
|
|
157
|
+
- lib/article_json/export/apple_news/elements/text.rb
|
|
158
|
+
- lib/article_json/export/apple_news/elements/text_box.rb
|
|
159
|
+
- lib/article_json/export/apple_news/exporter.rb
|
|
145
160
|
- lib/article_json/export/common/elements/base.rb
|
|
146
161
|
- lib/article_json/export/common/html/elements/base.rb
|
|
147
162
|
- lib/article_json/export/common/html/elements/embed.rb
|
|
@@ -155,16 +170,6 @@ files:
|
|
|
155
170
|
- lib/article_json/export/common/html/elements/text.rb
|
|
156
171
|
- lib/article_json/export/common/html/elements/text_box.rb
|
|
157
172
|
- lib/article_json/export/common/html/exporter.rb
|
|
158
|
-
- lib/article_json/export/facebook_instant_article/elements/base.rb
|
|
159
|
-
- lib/article_json/export/facebook_instant_article/elements/embed.rb
|
|
160
|
-
- lib/article_json/export/facebook_instant_article/elements/heading.rb
|
|
161
|
-
- lib/article_json/export/facebook_instant_article/elements/image.rb
|
|
162
|
-
- lib/article_json/export/facebook_instant_article/elements/list.rb
|
|
163
|
-
- lib/article_json/export/facebook_instant_article/elements/paragraph.rb
|
|
164
|
-
- lib/article_json/export/facebook_instant_article/elements/quote.rb
|
|
165
|
-
- lib/article_json/export/facebook_instant_article/elements/text.rb
|
|
166
|
-
- lib/article_json/export/facebook_instant_article/elements/text_box.rb
|
|
167
|
-
- lib/article_json/export/facebook_instant_article/exporter.rb
|
|
168
173
|
- lib/article_json/export/html/elements/base.rb
|
|
169
174
|
- lib/article_json/export/html/elements/embed.rb
|
|
170
175
|
- lib/article_json/export/html/elements/heading.rb
|
|
@@ -218,7 +223,6 @@ homepage: https://github.com/Devex/article_json
|
|
|
218
223
|
licenses:
|
|
219
224
|
- MIT
|
|
220
225
|
metadata: {}
|
|
221
|
-
post_install_message:
|
|
222
226
|
rdoc_options: []
|
|
223
227
|
require_paths:
|
|
224
228
|
- lib
|
|
@@ -226,15 +230,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
226
230
|
requirements:
|
|
227
231
|
- - ">="
|
|
228
232
|
- !ruby/object:Gem::Version
|
|
229
|
-
version: '2.
|
|
233
|
+
version: '2.5'
|
|
230
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
235
|
requirements:
|
|
232
236
|
- - ">="
|
|
233
237
|
- !ruby/object:Gem::Version
|
|
234
238
|
version: '0'
|
|
235
239
|
requirements: []
|
|
236
|
-
rubygems_version: 3.
|
|
237
|
-
signing_key:
|
|
240
|
+
rubygems_version: 3.6.9
|
|
238
241
|
specification_version: 4
|
|
239
242
|
summary: JSON Format for News Articles & Ruby Gem
|
|
240
243
|
test_files: []
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module ArticleJSON
|
|
2
|
-
module Export
|
|
3
|
-
module FacebookInstantArticle
|
|
4
|
-
module Elements
|
|
5
|
-
class Base
|
|
6
|
-
include ArticleJSON::Export::Common::HTML::Elements::Base
|
|
7
|
-
|
|
8
|
-
class << self
|
|
9
|
-
# Return the module namespace this class and its subclasses are
|
|
10
|
-
# nested in
|
|
11
|
-
# @return [Module]
|
|
12
|
-
def namespace
|
|
13
|
-
ArticleJSON::Export::FacebookInstantArticle::Elements
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
# The format this exporter is returning. This is used to determine
|
|
19
|
-
# which custom element exporters should be applied from the
|
|
20
|
-
# configuration.
|
|
21
|
-
# @return [Symbol]
|
|
22
|
-
def export_format
|
|
23
|
-
:facebook_instant_article
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
module ArticleJSON
|
|
2
|
-
module Export
|
|
3
|
-
module FacebookInstantArticle
|
|
4
|
-
module Elements
|
|
5
|
-
class Embed < Base
|
|
6
|
-
include ArticleJSON::Export::Common::HTML::Elements::Shared::Caption
|
|
7
|
-
|
|
8
|
-
# Generate the embedded element node
|
|
9
|
-
# @return [Nokogiri::XML::NodeSet]
|
|
10
|
-
def export
|
|
11
|
-
create_element(:figure, class: 'op-interactive') do |figure|
|
|
12
|
-
figure.add_child(embed_node)
|
|
13
|
-
if @element.caption&.any?
|
|
14
|
-
figure.add_child(caption_node(:figcaption))
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
# Type specific object that should be embedded
|
|
22
|
-
# @return [Nokogiri::XML::Element]
|
|
23
|
-
def embed_node
|
|
24
|
-
if %i(facebook_video tweet).include? @element.embed_type.to_sym
|
|
25
|
-
iframe_node
|
|
26
|
-
else
|
|
27
|
-
embedded_object
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def iframe_node
|
|
32
|
-
create_element(:iframe) do |div|
|
|
33
|
-
div.add_child(embedded_object)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def embedded_object
|
|
38
|
-
Nokogiri::HTML.fragment(@element.oembed_data[:html])
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
module ArticleJSON
|
|
2
|
-
module Export
|
|
3
|
-
module FacebookInstantArticle
|
|
4
|
-
module Elements
|
|
5
|
-
class Quote < Base
|
|
6
|
-
include ArticleJSON::Export::Common::HTML::Elements::Quote
|
|
7
|
-
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
# @return [Hash]
|
|
11
|
-
def node_opts
|
|
12
|
-
{}
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
# HTML tag for the wrapping node
|
|
16
|
-
# @return [Symbol]
|
|
17
|
-
def quote_tag
|
|
18
|
-
:aside
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# HTML tag for the node containing the caption
|
|
22
|
-
# @return [Symbol]
|
|
23
|
-
def caption_tag
|
|
24
|
-
:cite
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
module ArticleJSON
|
|
2
|
-
module Export
|
|
3
|
-
module FacebookInstantArticle
|
|
4
|
-
module Elements
|
|
5
|
-
class TextBox < Base
|
|
6
|
-
include ArticleJSON::Export::Common::HTML::Elements::TextBox
|
|
7
|
-
|
|
8
|
-
# Generate a `<div>` node containing all text box elements and
|
|
9
|
-
# surrounded by an ASCII-art line to the top and bottom
|
|
10
|
-
# @return [Nokogiri::XML::NodeSet]
|
|
11
|
-
def export
|
|
12
|
-
create_element(:div, class: 'text-box') do |div|
|
|
13
|
-
div.add_child(ascii_art_line_node)
|
|
14
|
-
@element.content.each do |child_element|
|
|
15
|
-
div.add_child(base_class.new(child_element).export)
|
|
16
|
-
end
|
|
17
|
-
div.add_child(ascii_art_line_node)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
# Returns a paragraph with the `ascii_art_line_text_element`. This
|
|
24
|
-
# gets inserted above and below the text box content
|
|
25
|
-
# @return [Nokogiri::XML::NodeSet]
|
|
26
|
-
def ascii_art_line_node
|
|
27
|
-
create_element(:p) { |p| p.add_child ascii_art_line_text_element }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Returns the delimiter of text boxes. Overwrite this method to have a
|
|
31
|
-
# custom text box delimiter
|
|
32
|
-
# @return [String]
|
|
33
|
-
def ascii_art_line_text_element
|
|
34
|
-
'────────'
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module ArticleJSON
|
|
2
|
-
module Export
|
|
3
|
-
module FacebookInstantArticle
|
|
4
|
-
class Exporter
|
|
5
|
-
include ArticleJSON::Export::Common::HTML::Exporter
|
|
6
|
-
|
|
7
|
-
class << self
|
|
8
|
-
# Return the module namespace this class is nested in
|
|
9
|
-
# @return [Module]
|
|
10
|
-
def namespace
|
|
11
|
-
ArticleJSON::Export::FacebookInstantArticle
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|