canvas_link_migrator 1.0.8 → 1.0.9

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: a329fcce5ac60d34c29e9e09005e8bb5c6ced87ff0ca2b7529821ff70d280045
4
- data.tar.gz: 4b05fe6dae29056eedba8384b00549942eb0d1f5dc72c2ec6310ea7b353e07af
3
+ metadata.gz: db94154546720e46dbc316e28fd6b42ee03c51ee13df32d1601924fd78d158d6
4
+ data.tar.gz: f4a71b858889356c765fcce8360d6266b1b4cd43648cd99eed291287a5229dcb
5
5
  SHA512:
6
- metadata.gz: 37f76536082684d4f2c40c72a68f885921cd1a5570f1bfd5d0424b2a859933ead7dac479ae0c4fde8968d799eb3f233cf696602a5d4ac962f9e8257e80f781b8
7
- data.tar.gz: eb9be3e0f256c16b6c4059f24b76d21d50d7c71ac40f73deb00ba737f2b32e3a4593ae86630ca5a364822839908328463741bafc42df27ddc95bfd3f2a97f01d
6
+ metadata.gz: f2499b2e3764c0bf76ae4f840345104cae6187e970c4bd8f8965254836387221ae84c96041527824fd27edeff602587afb21f629b062c6e83b74e80defd14997
7
+ data.tar.gz: 49c3e7eb354ea51183ad44706002bb3c92dbc2c98db12371fc420f00eb2616e19fd4b6a8c3e01345d69c7d8b2b81ba71b79341f7ea2802ee8b738b3c56c3a349
@@ -96,12 +96,15 @@ module CanvasLinkMigrator
96
96
 
97
97
  # Replace old style media anchor tags with iframes
98
98
  doc.search("a[id*='media_comment_']").each do |media_node|
99
+ next unless media_node["class"].match('instructure_inline_media_comment')
100
+
99
101
  media_node.name = "iframe"
100
102
  # smallest accepted size for iframe since we don't have the size available for these
101
103
  media_node["style"] = "width: 320px; height: 240px; display: inline-block;"
102
104
  media_node["title"] = media_node.text
103
105
  media_node.child&.remove
104
- media_node["data-media-type"] = media_node["class"].match(/(audio|video)_comment/)[1]
106
+ media_type = media_node["class"].match(/(audio|video)/)&.[](1)
107
+ media_node["data-media-type"] = media_type if media_type
105
108
  media_node["src"] = media_node["href"]
106
109
  media_node.delete("href")
107
110
  media_node["allowfullscreen"] = "allowfullscreen"
@@ -1,3 +1,3 @@
1
1
  module CanvasLinkMigrator
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
@@ -51,4 +51,17 @@ describe CanvasLinkMigrator::LinkParser do
51
51
  expect{ parser.convert_link(doc.at_css('a'), "href", "wiki_page", "migrationid", "") }.not_to raise_error
52
52
  end
53
53
  end
54
+
55
+ describe "convert" do
56
+ it "does not change media anchor tags into iframes if they don't have inline_media_comment in the class" do
57
+ doc = Nokogiri::HTML5.fragment(%Q(<p><a id="media_comment_m-5HHT5LqZqPf7qhEJ7PbKtehCiunxM4BB" class=" instructure_video_link instructure_file_link" title="00-Personal Intro.m4v" href="https://xu.instructure.com/courses/83206/files/12176377/download?wrap=1" target="" data-api-endpoint="https://xu.instructure.com/api/v1/courses/83206/files/12176377" data-api-returntype="File">Click here to watch personal introduction</a></p>))
58
+ parser.convert(doc.to_html, "type", "lookup_id", "field")
59
+ expect(doc.to_html).to match(%Q(<p><a id="media_comment_m-5HHT5LqZqPf7qhEJ7PbKtehCiunxM4BB" class=" instructure_video_link instructure_file_link" title="00-Personal Intro.m4v" href="https://xu.instructure.com/courses/83206/files/12176377/download?wrap=1" target="" data-api-endpoint="https://xu.instructure.com/api/v1/courses/83206/files/12176377" data-api-returntype="File">Click here to watch personal introduction</a></p>))
60
+ end
61
+
62
+ it "does not crash if it can't find a video/audio_comment class name" do
63
+ doc = Nokogiri::HTML5.fragment(%Q(<a id="media_comment_m-4uoGqVdEqXhpqu2ZMytHSy9XMV73aQ7E" class="instructure_inline_media_comment" data-media_comment_type="video" data-alt=""></a>))
64
+ expect{ parser.convert(doc.to_html, "type", "lookup_id", "field") }.not_to raise_error
65
+ end
66
+ end
54
67
  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.8
4
+ version: 1.0.9
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-04-02 00:00:00.000000000 Z
14
+ date: 2024-05-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport