marlens-jira-api 0.5.0 → 0.5.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d03091de06691a2493443796b27c4c7205067ba92eb3503cdf0ccb2771b86a6
|
|
4
|
+
data.tar.gz: 0f1c94a08e018b97a171a25a888baabebb301a9427f9f6eccc915e8b222fad7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a47ff4083694ad1406d0248b4ac86afead42c425464c2cfeb0fb61f9d344aed3c8a78172fae723095d02f09ea0cdc9343cfac0d9394388cfa490a646449900bc
|
|
7
|
+
data.tar.gz: 51e132f5fa0b5f3e59fb6ebb35c37d8fd9ec468bab881dbca2fb7bc191cd210a9adc1055ac9173fc1200ab27b05ec49824c1468a9786414a7db6e64b2f8e8c2d
|
|
@@ -31,6 +31,25 @@ module Marlens
|
|
|
31
31
|
}
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def self.external_media_single(url:, alt:, width:, height:)
|
|
35
|
+
{
|
|
36
|
+
"type" => "mediaSingle",
|
|
37
|
+
"attrs" => { "layout" => "center" },
|
|
38
|
+
"content" => [
|
|
39
|
+
{
|
|
40
|
+
"type" => "media",
|
|
41
|
+
"attrs" => {
|
|
42
|
+
"type" => "external",
|
|
43
|
+
"url" => url,
|
|
44
|
+
"alt" => alt,
|
|
45
|
+
"width" => width,
|
|
46
|
+
"height" => height,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
|
|
34
53
|
def self.paragraph(text)
|
|
35
54
|
new("").send(:paragraph_from_text, text)
|
|
36
55
|
end
|
|
@@ -79,7 +98,7 @@ module Marlens
|
|
|
79
98
|
when :heading
|
|
80
99
|
heading(node)
|
|
81
100
|
when :paragraph
|
|
82
|
-
|
|
101
|
+
paragraph_blocks(node)
|
|
83
102
|
when :code_block
|
|
84
103
|
code_block(node)
|
|
85
104
|
when :list
|
|
@@ -105,19 +124,23 @@ module Marlens
|
|
|
105
124
|
}
|
|
106
125
|
end
|
|
107
126
|
|
|
108
|
-
def
|
|
109
|
-
return image_block_for(children(node).first) if single_image_node?(node)
|
|
127
|
+
def paragraph_blocks(node)
|
|
128
|
+
return [image_block_for(children(node).first)] if single_image_node?(node)
|
|
129
|
+
|
|
130
|
+
split_paragraph_around_html_images(node) || [paragraph_from_inline_content(inline_content(node))]
|
|
131
|
+
end
|
|
110
132
|
|
|
133
|
+
def paragraph_from_text(text)
|
|
111
134
|
{
|
|
112
135
|
"type" => "paragraph",
|
|
113
|
-
"content" =>
|
|
136
|
+
"content" => [text_node(text)],
|
|
114
137
|
}
|
|
115
138
|
end
|
|
116
139
|
|
|
117
|
-
def
|
|
140
|
+
def paragraph_from_inline_content(content)
|
|
118
141
|
{
|
|
119
142
|
"type" => "paragraph",
|
|
120
|
-
"content" =>
|
|
143
|
+
"content" => content,
|
|
121
144
|
}
|
|
122
145
|
end
|
|
123
146
|
|
|
@@ -210,6 +233,43 @@ module Marlens
|
|
|
210
233
|
)
|
|
211
234
|
end
|
|
212
235
|
|
|
236
|
+
def split_paragraph_around_html_images(node)
|
|
237
|
+
blocks = []
|
|
238
|
+
pending_content = []
|
|
239
|
+
|
|
240
|
+
children(node).each do |child|
|
|
241
|
+
image_block = inline_html_image_block(child)
|
|
242
|
+
|
|
243
|
+
if image_block.nil?
|
|
244
|
+
append_inline_content(pending_content, render_inline(child, []))
|
|
245
|
+
else
|
|
246
|
+
append_paragraph_block(blocks, pending_content)
|
|
247
|
+
pending_content = []
|
|
248
|
+
blocks << image_block
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
return nil if blocks.empty?
|
|
252
|
+
|
|
253
|
+
append_paragraph_block(blocks, pending_content)
|
|
254
|
+
blocks
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def inline_html_image_block(node)
|
|
258
|
+
return nil unless node.type == :html_inline
|
|
259
|
+
|
|
260
|
+
html_image_block(node)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def append_paragraph_block(blocks, content)
|
|
264
|
+
blocks << paragraph_from_inline_content(content) unless content.empty?
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def append_inline_content(content, inline)
|
|
268
|
+
return if inline.nil?
|
|
269
|
+
|
|
270
|
+
inline.is_a?(Array) ? content.concat(inline.compact) : content << inline
|
|
271
|
+
end
|
|
272
|
+
|
|
213
273
|
def resolved_image_block(url:, alt: nil, width: nil, height: nil)
|
|
214
274
|
return nil if url.nil? || url.strip.empty?
|
|
215
275
|
return fallback_image_paragraph(url, alt) if @image_resolver.nil?
|
|
@@ -20,8 +20,8 @@ module Marlens
|
|
|
20
20
|
attachment = upload_image_attachment(image.fetch(:url))
|
|
21
21
|
dimensions = attachment.fetch("dimensions")
|
|
22
22
|
|
|
23
|
-
MarkdownToAdf.
|
|
24
|
-
|
|
23
|
+
MarkdownToAdf.external_media_single(
|
|
24
|
+
url: attachment.fetch("content"),
|
|
25
25
|
alt: image[:alt].to_s.strip.empty? ? attachment.fetch("filename") : image[:alt],
|
|
26
26
|
width: image_dimension_value(image[:width], dimensions.fetch("width")),
|
|
27
27
|
height: image_dimension_value(image[:height], dimensions.fetch("height"))
|
|
@@ -55,7 +55,7 @@ module Marlens
|
|
|
55
55
|
)
|
|
56
56
|
|
|
57
57
|
return {
|
|
58
|
-
"
|
|
58
|
+
"content" => attachment.fetch("content").to_s,
|
|
59
59
|
"filename" => attachment.fetch("filename", filename),
|
|
60
60
|
"dimensions" => dimensions,
|
|
61
61
|
}
|