canvas_link_migrator 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b5936b2c0b84390589696838b2f7409d71467a11b20f81c63176e8e99a54caa
|
4
|
+
data.tar.gz: 49c4a0df338db02c8b658c49249f2fb8c3f9a75d60790f6fd72a405242682fca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c0f69c22fd75d7f783fa017993c7803f7504aa2e4b353917b33ec730a2cf0577e3f8941b58472a6ab694ab92bd667be12c5d65300119d7febea6cca0b9d45f
|
7
|
+
data.tar.gz: 3e6158123ea5ad27bd55033865474133d9bdc7e663006c05eb3d8efb76bf7fe49a6041e0b37d19d1d0ca606aba4bbb329caa9cd4b92e13db8b97fc65dace5d24
|
@@ -84,7 +84,7 @@ module CanvasLinkMigrator
|
|
84
84
|
doc = Nokogiri::HTML5.fragment(html || "")
|
85
85
|
|
86
86
|
# Replace source tags with iframes
|
87
|
-
doc.search("source[data-media-id]").each do |source|
|
87
|
+
doc.search("source[data-media-type],source[data-media-id]").each do |source|
|
88
88
|
next unless RCE_MEDIA_TYPES.include?(source.parent.name)
|
89
89
|
|
90
90
|
media_node = source.parent
|
@@ -232,12 +232,12 @@ module CanvasLinkMigrator
|
|
232
232
|
elsif url =~ %r{\$IMS(?:-|_)CC(?:-|_)FILEBASE\$/(.*)}
|
233
233
|
rel_path = URI::DEFAULT_PARSER.unescape($1)
|
234
234
|
if (attr == "href" && node["class"]&.include?("instructure_inline_media_comment")) ||
|
235
|
-
(attr == "src" && ["iframe", "source"].include?(node.name) && node["data-media-id"])
|
235
|
+
(attr == "src" && ["iframe", "source"].include?(node.name) && (node["data-media-id"] || node["data-media-type"]))
|
236
236
|
unresolved(:media_object, rel_path: rel_path)
|
237
237
|
else
|
238
238
|
unresolved(:file, rel_path: rel_path)
|
239
239
|
end
|
240
|
-
elsif (attr == "src" && ["iframe", "source"].include?(node.name) && node["data-media-id"])
|
240
|
+
elsif (attr == "src" && ["iframe", "source"].include?(node.name) && (node["data-media-id"] || node["data-media-type"]))
|
241
241
|
# media_objects_iframe course copy reference without an attachment id, change to media_attachments_iframe
|
242
242
|
unresolved(:media_object, rel_path: node["src"])
|
243
243
|
elsif @migration_query_service.supports_embedded_images && attr == "src" && (info_match = url.match(%r{\Adata:(?<mime_type>[-\w]+/[-\w+.]+)?;base64,(?<image>.*)}m))
|
@@ -248,8 +248,9 @@ module CanvasLinkMigrator
|
|
248
248
|
elsif rel_path&.match(/\/media_attachments_iframe\/\d+/)
|
249
249
|
# media attachment from another course or something
|
250
250
|
rel_path
|
251
|
-
elsif node["data-media-id"]
|
252
|
-
file_id, uuid
|
251
|
+
elsif (file_id, uuid = @migration_id_converter.convert_attachment_media_id(node["data-media-id"]))
|
252
|
+
file_id ? media_attachment_iframe_url(file_id, uuid, node["data-media-type"]) : nil
|
253
|
+
elsif (file_id, uuid = @migration_id_converter.convert_attachment_media_id(rel_path.match(/media_objects(?:_iframe)?\/([^?.]+)/)&.[](1)))
|
253
254
|
file_id ? media_attachment_iframe_url(file_id, uuid, node["data-media-type"]) : nil
|
254
255
|
else
|
255
256
|
node.delete("class")
|
@@ -210,130 +210,164 @@ describe CanvasLinkMigrator::ImportedHtmlConverter do
|
|
210
210
|
expect(bad_links[0]).to include({ link_type: :file, missing_url: "/courses/2/file_contents/course%20files/relative/path/to/file%20with%20space.html" })
|
211
211
|
end
|
212
212
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
213
|
+
context "with media links" do
|
214
|
+
it "changes old media URL types into media_attachments_iframe" do
|
215
|
+
test_string = <<~HTML.strip
|
216
|
+
<p>
|
217
|
+
with media object url: <a id="media_comment_m-stuff" class="instructure_inline_media_comment video_comment" href="/media_objects/m-stuff">this is a media comment</a>
|
218
|
+
with file content url: <a id="media_comment_0_bq09qam2" class="instructure_inline_media_comment video_comment" href="/courses/2/file_contents/course%20files/media_objects/0_bq09qam2">this is a media comment</a>
|
219
|
+
with mediahref url: <iframe data-media-type="video" src="/media_objects_iframe?mediahref=$CANVAS_COURSE_REFERENCE$/file_ref/I/download" data-media-id="m-yodawg"></iframe>
|
220
|
+
</p>
|
221
|
+
HTML
|
222
|
+
|
223
|
+
expected_string = <<~HTML.strip
|
224
|
+
<p>
|
225
|
+
with media object url: <iframe id="media_comment_m-stuff" class="instructure_inline_media_comment video_comment" style="width: 320px; height: 240px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_attachments_iframe/5?embedded=true&type=video&verifier=u5" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff"></iframe>
|
226
|
+
with file content url: <iframe id="media_comment_0_bq09qam2" class="instructure_inline_media_comment video_comment" style="width: 320px; height: 240px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_attachments_iframe/6?embedded=true&type=video&verifier=u6" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="0_bq09qam2"></iframe>
|
227
|
+
with mediahref url: <iframe data-media-type="video" src="/media_attachments_iframe/9?embedded=true&type=video&verifier=u9" data-media-id="m-yodawg"></iframe>
|
228
|
+
</p>
|
229
|
+
HTML
|
230
|
+
|
231
|
+
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, nil])
|
232
|
+
end
|
221
233
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
HTML
|
234
|
+
it "finds attachments for media_object_iframes that don't have valid data-media-ids" do
|
235
|
+
test_string = <<~HTML.strip
|
236
|
+
<p>
|
237
|
+
in video format: <video style="width: 599px; height: 337px; display: inline-block;" title="0_bq09qam2" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="undefined"><source src="/media_objects_iframe/0_bq09qam2?type=video?type=video" data-media-id="undefined" data-media-type="video"></video>
|
238
|
+
</p>
|
239
|
+
HTML
|
229
240
|
|
230
|
-
|
231
|
-
|
241
|
+
expected_string = <<~HTML.strip
|
242
|
+
<p>
|
243
|
+
in video format: <iframe style="width: 599px; height: 337px; display: inline-block;" title="0_bq09qam2" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="undefined" src="/media_attachments_iframe/6?embedded=true&type=video&verifier=u6"></iframe>
|
244
|
+
</p>
|
245
|
+
HTML
|
232
246
|
|
233
|
-
|
234
|
-
|
235
|
-
<p>
|
236
|
-
with media object url: <a id="media_comment_m-stuff1" class="instructure_inline_media_comment video_comment" href="/media_objects/m-stuff1">this is a media comment</a>
|
237
|
-
with file content url: <a id="media_comment_0_bq09qam3" class="instructure_inline_media_comment video_comment" href="/courses/2/file_contents/course%20files/media_objects/0_bq09qam3">this is a media comment</a>
|
238
|
-
with mediahref url: <iframe data-media-type="video" src="/media_objects_iframe?mediahref=$CANVAS_COURSE_REFERENCE$/file_ref/yarg/download" data-media-id="m-yodawg"></iframe>
|
239
|
-
</p>
|
240
|
-
HTML
|
247
|
+
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, nil])
|
248
|
+
end
|
241
249
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
HTML
|
250
|
+
it "finds attachments for media_object_iframes that don't have data-media-ids" do
|
251
|
+
test_string = <<~HTML.strip
|
252
|
+
<p>
|
253
|
+
in video format: <video style="width: 599px; height: 337px; display: inline-block;" title="0_bq09qam2" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen"><source src="/media_objects_iframe/0_bq09qam2?type=video?type=video" data-media-id="undefined" data-media-type="video"></video>
|
254
|
+
</p>
|
255
|
+
HTML
|
249
256
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
{
|
256
|
-
link_type: :media_object,
|
257
|
-
missing_url: "/courses/2/file_contents/course%20files/media_objects/0_bq09qam3"
|
258
|
-
},
|
259
|
-
{
|
260
|
-
link_type: :file_ref, missing_url: "/file_ref/yarg/download"
|
261
|
-
}
|
262
|
-
]
|
263
|
-
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, expected_errors])
|
264
|
-
end
|
257
|
+
expected_string = <<~HTML.strip
|
258
|
+
<p>
|
259
|
+
in video format: <iframe style="width: 599px; height: 337px; display: inline-block;" title="0_bq09qam2" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" src="/media_attachments_iframe/6?embedded=true&type=video&verifier=u6"></iframe>
|
260
|
+
</p>
|
261
|
+
HTML
|
265
262
|
|
266
|
-
|
267
|
-
|
268
|
-
<p>
|
269
|
-
with wrong file in href: <a href="/courses/2/file_contents/%24IMS_CC_FILEBASE%24/#" class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff">this is a media comment</a><br><br>
|
270
|
-
with no href: <a class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff" href="#"></a><br><br>
|
271
|
-
</p>
|
272
|
-
HTML
|
273
|
-
expected_string = <<~HTML.strip
|
274
|
-
<p>
|
275
|
-
with wrong file in href: <iframe class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff" style="width: 320px; height: 240px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_attachments_iframe/5?embedded=true&type=video&verifier=u5" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff"></iframe><br><br>
|
276
|
-
with no href: <iframe class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff" style="width: 320px; height: 240px; display: inline-block;" title="" data-media-type="video" src="/media_attachments_iframe/5?embedded=true&type=video&verifier=u5" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff"></iframe><br><br>
|
277
|
-
</p>
|
278
|
-
HTML
|
279
|
-
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, nil])
|
280
|
-
end
|
263
|
+
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, nil])
|
264
|
+
end
|
281
265
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
266
|
+
it "handles old media types where we can't find the file" do
|
267
|
+
test_string = <<~HTML.strip
|
268
|
+
<p>
|
269
|
+
with media object url: <a id="media_comment_m-stuff1" class="instructure_inline_media_comment video_comment" href="/media_objects/m-stuff1">this is a media comment</a>
|
270
|
+
with file content url: <a id="media_comment_0_bq09qam3" class="instructure_inline_media_comment video_comment" href="/courses/2/file_contents/course%20files/media_objects/0_bq09qam3">this is a media comment</a>
|
271
|
+
with mediahref url: <iframe data-media-type="video" src="/media_objects_iframe?mediahref=$CANVAS_COURSE_REFERENCE$/file_ref/yarg/download" data-media-id="m-yodawg"></iframe>
|
272
|
+
</p>
|
273
|
+
HTML
|
274
|
+
|
275
|
+
expected_string = <<~HTML.strip
|
276
|
+
<p>
|
277
|
+
with media object url: <iframe title="this is a media comment" data-media-type="video" src="/courses/2/file_contents/course%20files/media_objects/m-stuff1" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff1"></iframe>
|
278
|
+
with file content url: <iframe title="this is a media comment" data-media-type="video" src="/courses/2/file_contents/course%20files/media_objects/0_bq09qam3" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="0_bq09qam3"></iframe>
|
279
|
+
with mediahref url: <iframe data-media-type="video" src="/media_objects_iframe?mediahref=$CANVAS_COURSE_REFERENCE$/file_ref/yarg/download" data-media-id="m-yodawg"></iframe>
|
280
|
+
</p>
|
281
|
+
HTML
|
282
|
+
|
283
|
+
expected_errors = [
|
284
|
+
{
|
285
|
+
link_type: :media_object,
|
286
|
+
missing_url: "/courses/2/file_contents/course%20files/media_objects/m-stuff1"
|
287
|
+
},
|
288
|
+
{
|
289
|
+
link_type: :media_object,
|
290
|
+
missing_url: "/courses/2/file_contents/course%20files/media_objects/0_bq09qam3"
|
291
|
+
},
|
292
|
+
{
|
293
|
+
link_type: :file_ref, missing_url: "/file_ref/yarg/download"
|
294
|
+
}
|
295
|
+
]
|
296
|
+
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, expected_errors])
|
297
|
+
end
|
287
298
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
299
|
+
it "handles and repair half broken media links" do
|
300
|
+
test_string = <<~HTML.strip
|
301
|
+
<p>
|
302
|
+
with wrong file in href: <a href="/courses/2/file_contents/%24IMS_CC_FILEBASE%24/#" class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff">this is a media comment</a><br><br>
|
303
|
+
with no href: <a class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff" href="#"></a><br><br>
|
304
|
+
</p>
|
305
|
+
HTML
|
306
|
+
expected_string = <<~HTML.strip
|
307
|
+
<p>
|
308
|
+
with wrong file in href: <iframe class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff" style="width: 320px; height: 240px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_attachments_iframe/5?embedded=true&type=video&verifier=u5" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff"></iframe><br><br>
|
309
|
+
with no href: <iframe class="instructure_inline_media_comment video_comment" id="media_comment_m-stuff" style="width: 320px; height: 240px; display: inline-block;" title="" data-media-type="video" src="/media_attachments_iframe/5?embedded=true&type=video&verifier=u5" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff"></iframe><br><br>
|
310
|
+
</p>
|
311
|
+
HTML
|
312
|
+
expect(@converter.convert_exported_html(test_string)).to eq([expected_string, nil])
|
313
|
+
end
|
293
314
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
315
|
+
it "converts old RCE media object iframes" do
|
316
|
+
test_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_objects_iframe/m-lolcat?type=video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-lolcat"></iframe>)
|
317
|
+
replacement_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_attachments_iframe/8?embedded=true&type=video&verifier=u8" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-lolcat"></iframe>)
|
318
|
+
expect(@converter.convert_exported_html(test_string)).to eq([replacement_string, nil])
|
319
|
+
end
|
298
320
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
321
|
+
it "handles and repair half broken new RCE media iframes" do
|
322
|
+
test_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" src="%24IMS_CC_FILEBASE%24/#" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-lolcat"></iframe>)
|
323
|
+
repaired_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" src="/media_attachments_iframe/8?embedded=true&type=video&verifier=u8" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-lolcat"></iframe>)
|
324
|
+
expect(@converter.convert_exported_html(test_string)).to eq([repaired_string, nil])
|
325
|
+
end
|
303
326
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
327
|
+
it "converts source tags to RCE media iframes" do
|
328
|
+
test_string = %(<video style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-lolcat"><source src="/media_objects_iframe/m-lolcat?type=video" data-media-id="m-lolcat" data-media-type="video"></video>)
|
329
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-lolcat" src="/media_attachments_iframe/8?embedded=true&type=video&verifier=u8"></iframe>)
|
330
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
308
331
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
332
|
+
test_string = %(<audio style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="m-yodawg"><source src="/media_objects_iframe/m-yodawg?type=audio" data-media-id="m-yodawg" data-media-type="audio"></audio>)
|
333
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="m-yodawg" src="/media_attachments_iframe/9?embedded=true&type=audio&verifier=u9"></iframe>)
|
334
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
335
|
+
end
|
313
336
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
337
|
+
it "converts source tags to RCE media attachment iframes" do
|
338
|
+
test_string = %(<video style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-stuff"><source src="$IMS-CC-FILEBASE$/subfolder/with a space/yodawg.mov?canvas_=1&canvas_qs_type=video&canvas_qs_amp=&canvas_qs_embedded=true&media_attachment=true" data-media-id="m-stuff" data-media-type="video"></video>)
|
339
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-yodawg" src="/media_attachments_iframe/9?embedded=true&type=video&verifier=u9"></iframe>)
|
340
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
318
341
|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
342
|
+
test_string = %(<audio style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="m-stuff"><source src="$IMS-CC-FILEBASE$/lolcat.mp3?canvas_=1&canvas_qs_type=audio&canvas_qs_amp=&canvas_qs_embedded=true&media_attachment=true" data-media-id="m-stuff" data-media-type="audio"></video>)
|
343
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="m-lolcat" src="/media_attachments_iframe/8?embedded=true&type=audio&verifier=u8"></iframe>)
|
344
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
345
|
+
end
|
323
346
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
347
|
+
it "converts source tags to RCE media attachment iframes when link is an unknown media attachment reference (link from a public file in another course)" do
|
348
|
+
test_string = %(<video style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="0_l4l5n0wt"><source src="/media_attachments_iframe/18?type=video" data-media-id="0_l4l5n0wt" data-media-type="video"></video>)
|
349
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="0_l4l5n0wt" src="/media_attachments_iframe/18?type=video"></iframe>)
|
350
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
328
351
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
352
|
+
test_string = %(<audio style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="0_l4l5n0wu"><source src="/media_attachments_iframe/19?type=audio" data-media-id="0_l4l5n0wu" data-media-type="audio"></video>)
|
353
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="0_l4l5n0wu" src="/media_attachments_iframe/19?type=audio"></iframe>)
|
354
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
355
|
+
end
|
333
356
|
|
334
|
-
|
335
|
-
|
336
|
-
|
357
|
+
it "converts course copy style media attachmet iframe links" do
|
358
|
+
test_string = %(<video style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-yodawg"><source src="$CANVAS_COURSE_REFERENCE$/file_ref/I?media_attachment=true&type=video" data-media-id="m-yodawg" data-media-type="video"></video>)
|
359
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="video" allowfullscreen="allowfullscreen" allow="fullscreen" data-media-id="m-yodawg" src="/media_attachments_iframe/9?embedded=true&type=video&verifier=u9"></iframe>)
|
360
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
361
|
+
|
362
|
+
test_string = %(<audio style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="m-lolcat"><source src="$CANVAS_COURSE_REFERENCE$/file_ref/H?media_attachment=true&type=audio" data-media-id="m-lolcat" data-media-type="audio"></audio>)
|
363
|
+
converted_string = %(<iframe style="width: 400px; height: 225px; display: inline-block;" title="this is a media comment" data-media-type="audio" data-media-id="m-lolcat" src="/media_attachments_iframe/8?embedded=true&type=audio&verifier=u8"></iframe>)
|
364
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
365
|
+
end
|
366
|
+
|
367
|
+
it "leaves source tags without data-media-id alone" do
|
368
|
+
test_string = %(<video style="width: 400px; height: 225px; display: inline-block;" title="this is a non-canvas video" allowfullscreen="allowfullscreen" allow="fullscreen"><source src="http://www.example.com/video.mov"></video>)
|
369
|
+
expect(@converter.convert_exported_html(test_string)).to eq([test_string, nil])
|
370
|
+
end
|
337
371
|
end
|
338
372
|
|
339
373
|
it "only converts url params" do
|
@@ -366,5 +400,16 @@ describe CanvasLinkMigrator::ImportedHtmlConverter do
|
|
366
400
|
test_string = '<p><a href="#anchor_ref">ref</a></p>'
|
367
401
|
expect(@converter.convert_exported_html(test_string)).to eq([test_string, nil])
|
368
402
|
end
|
403
|
+
|
404
|
+
it "converts iframe srcs that point to non-media files" do
|
405
|
+
test_string = <<~HTML
|
406
|
+
<p><iframe style="width: 100%; height: 100vh; border: none;" src="$IMS-CC-FILEBASE$/subfolder/test.png?canvas_download=1"></iframe></p>
|
407
|
+
HTML
|
408
|
+
converted_string = <<~HTML
|
409
|
+
<p><iframe style="width: 100%; height: 100vh; border: none;" src="/courses/2/files/7/download?verifier=u7"></iframe></p>
|
410
|
+
HTML
|
411
|
+
html = @converter.convert_exported_html(test_string)
|
412
|
+
expect(html[0]).to eq converted_string
|
413
|
+
end
|
369
414
|
end
|
370
415
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_link_migrator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mysti Lilla
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2024-
|
14
|
+
date: 2024-07-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|