github-to-canvas 0.1.4 → 0.1.5
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: b18946099c8b4fd23e1c2230f71fac458f932079fd22ada5297732358fec4d0e
|
4
|
+
data.tar.gz: '092e1b7854f2b4c4026f0713599d423d8eac6431ae16e4f9372c1a00ebb9775c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d11be9f366fc3a457a671669a57802d6a1a8cc8ff3b0a7e9fa3ee10b4b8b91334cbaa336d39c1e3057c41e787619716d76df3e8523d918393cbb1b6fa9737549
|
7
|
+
data.tar.gz: 85d91f81000c82d55cb45e02f31c9aa3b2e241c785cb58366f5fbef99b72c7ce76e7e9d70f101cedb7f54c5082b2061926e0453cd8a162227cdba78f96c54e71
|
@@ -193,6 +193,7 @@ class CanvasInterface
|
|
193
193
|
while !!index
|
194
194
|
url = "#{ENV['CANVAS_API_PATH']}/courses/#{course}/modules?page=#{index}&per_page=20"
|
195
195
|
index += 1
|
196
|
+
|
196
197
|
response = RestClient.get(url, self.headers)
|
197
198
|
modules = JSON.parse(response.body)
|
198
199
|
|
@@ -200,7 +201,7 @@ class CanvasInterface
|
|
200
201
|
course_info[:modules] = course_info[:modules] + modules
|
201
202
|
else
|
202
203
|
index = nil
|
203
|
-
end
|
204
|
+
end
|
204
205
|
end
|
205
206
|
|
206
207
|
course_info[:modules] = course_info[:modules].map do |mod|
|
@@ -213,11 +214,12 @@ class CanvasInterface
|
|
213
214
|
while !!index
|
214
215
|
url = "#{ENV['CANVAS_API_PATH']}/courses/#{course}/modules/#{mod['id']}/items?page=#{index}&per_page=20"
|
215
216
|
index += 1
|
216
|
-
response = RestClient.get(url, headers
|
217
|
-
"Authorization" => "Bearer #{ENV['CANVAS_API_KEY']}"
|
218
|
-
})
|
217
|
+
response = RestClient.get(url, self.headers)
|
219
218
|
lessons = JSON.parse(response.body)
|
220
219
|
lessons = lessons.map do |lesson|
|
220
|
+
if lesson["type"] == "ExternalUrl"
|
221
|
+
next
|
222
|
+
end
|
221
223
|
lesson = lesson.slice("id","title","name","indent","type","html_url","page_url","url","completion_requirement", "published")
|
222
224
|
lesson["repository"] = ""
|
223
225
|
lesson['id'] = lesson['url'].gsub(/^(.*[\\\/])/,'')
|
@@ -232,10 +234,11 @@ class CanvasInterface
|
|
232
234
|
end
|
233
235
|
new_mod
|
234
236
|
end
|
235
|
-
|
237
|
+
|
236
238
|
puts course_info.to_yaml
|
237
239
|
|
238
240
|
rescue
|
241
|
+
byebug
|
239
242
|
puts "Something went wrong while getting info about course #{course}"
|
240
243
|
abort
|
241
244
|
end
|
@@ -136,7 +136,7 @@ class RepositoryConverter
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def self.adjust_local_markdown_images(readme, raw_remote_url, branch)
|
139
|
-
readme.gsub
|
139
|
+
readme.gsub(/\!\[.+\]\(.+\)/) {|image_markdown|
|
140
140
|
if !image_markdown.match?('amazonaws.com') && !image_markdown.match?('https://') && !image_markdown.match?('http://') && !image_markdown.match?('youtube')
|
141
141
|
image_markdown.gsub!(/\(.+\)/) { |path|
|
142
142
|
path.delete_prefix!("(")
|
@@ -149,11 +149,12 @@ class RepositoryConverter
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def self.adjust_local_html_images(readme, raw_remote_url, branch)
|
152
|
-
readme.gsub
|
153
|
-
|
154
|
-
|
155
|
-
image_source.gsub
|
156
|
-
image_source.
|
152
|
+
readme.gsub(/src=(\'|\")[\s\S]*?(\'|\")/) { |image_source|
|
153
|
+
|
154
|
+
if !image_source.match?('amazonaws.com') && !image_source.match?('https://') && !image_source.match?('http://') && !image_source.match?('youtube') && !image_source.match(/src=(\'|\")(?=<%)/)
|
155
|
+
image_source = image_source.gsub(/(\'|\")/, "")
|
156
|
+
image_source = image_source.gsub(/src=/, '')
|
157
|
+
image_source = image_source.strip
|
157
158
|
'src="' + raw_remote_url + '/' + branch + '/' + image_source + '"'
|
158
159
|
else
|
159
160
|
image_source
|