canvas_link_migrator 1.0.0 → 1.0.1
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: 7d147093c7e6b397c3eb184aba4af1595f782e14735a50e9d4986be628af75f3
|
4
|
+
data.tar.gz: cb48c35f35dd333b02ff7dcba5e3bd79d1a1a7b736b7bb14c56de11b6c91565e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4074cbb1bfa20b00f4843327d62ee0e1cf739f7450b46698ee1a6a240054f27acd34046605e2ae4f54bbdf02b529272ba165769352e10abff1f5950c08af6ad8
|
7
|
+
data.tar.gz: e1deecf7b1d6586c432234092e338c9d3059f26b744072eab1cb6e644c25dbcec9ffacfb53239b6c9ffc0610c210bf80399f097f2d7efa2265686caf314a8fee
|
@@ -182,11 +182,13 @@ module CanvasLinkMigrator
|
|
182
182
|
|
183
183
|
# returns a hash with resolution status and data to hold onto if unresolved
|
184
184
|
def parse_url(url, node, attr)
|
185
|
-
|
186
|
-
query_values =
|
187
|
-
media_attachment = query_values.delete
|
188
|
-
|
189
|
-
|
185
|
+
parsed_url = Addressable::URI.parse(url)
|
186
|
+
query_values = parsed_url.query_values
|
187
|
+
media_attachment = query_values.try(:delete, "media_attachment") == "true"
|
188
|
+
if media_attachment
|
189
|
+
parsed_url.query_values = query_values.present? ? query_values : nil
|
190
|
+
url = Addressable::URI.unencode(parsed_url)
|
191
|
+
end
|
190
192
|
|
191
193
|
if url =~ /wiki_page_migration_id=(.*)/
|
192
194
|
unresolved(:wiki_page, migration_id: $1)
|
@@ -122,15 +122,14 @@ module CanvasLinkMigrator
|
|
122
122
|
# context prepended to the URL. This prevents
|
123
123
|
# redirects to non cross-origin friendly urls
|
124
124
|
# during a file fetch
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
125
|
+
if rest.include?("icon_maker_icon=1")
|
126
|
+
link[:new_value] = "/files/#{file_id}#{rest}"
|
127
|
+
elsif link[:in_media_iframe] && link[:media_attachment]
|
128
|
+
link[:new_value] = "/media_attachments_iframe/#{file_id}#{rest}"
|
129
|
+
else
|
130
|
+
link[:new_value] = "#{context_path}/files/#{file_id}#{rest}"
|
131
|
+
link[:new_value] = "/media_objects_iframe?mediahref=#{link[:new_value]}" if link[:in_media_iframe]
|
132
|
+
end
|
134
133
|
end
|
135
134
|
else
|
136
135
|
raise "unrecognized link_type (#{link[:link_type]}) in unresolved link"
|
@@ -240,6 +240,12 @@ describe CanvasLinkMigrator::ImportedHtmlConverter do
|
|
240
240
|
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
241
241
|
end
|
242
242
|
|
243
|
+
it "converts mediahref iframes" do
|
244
|
+
test_string = %(<iframe data-media-type="video" src="/media_objects_iframe?mediahref=$CANVAS_COURSE_REFERENCE$/file_ref/I/download" data-media-id="m-yodawg"></iframe>)
|
245
|
+
converted_string = %(<iframe data-media-type="video" src="/media_objects_iframe?mediahref=/courses/2/files/9/download" data-media-id="m-yodawg"></iframe>)
|
246
|
+
expect(@converter.convert_exported_html(test_string)).to eq([converted_string, nil])
|
247
|
+
end
|
248
|
+
|
243
249
|
it "leaves source tags without data-media-id alone" do
|
244
250
|
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>)
|
245
251
|
expect(@converter.convert_exported_html(test_string)).to eq([test_string, nil])
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mysti Lilla
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-11-
|
13
|
+
date: 2023-11-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|