github-to-canvas 0.0.50 → 0.0.55
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 +4 -4
- data/bin/github-to-canvas +10 -2
- data/lib/github-to-canvas.rb +4 -3
- data/lib/github-to-canvas/create_canvas_lesson.rb +4 -4
- data/lib/github-to-canvas/repository_converter.rb +10 -7
- data/lib/github-to-canvas/update_canvas_lesson.rb +4 -4
- data/lib/github-to-canvas/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 735438dfea3e2a7aebf8266ab9ad15959cb9a9355f1f1355f2ca421773355b2a
|
|
4
|
+
data.tar.gz: 27af813a14adfd81bc7591e99681d3da575d5245fb3d1bad6596c77a9159a5af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80675ba304508aa284fb025c13004e7dea0d9914b61473ac05ebb389246fa906449b08834b37801484bd8e3d222257bb82a36847d559a506125ea58a70bfa642
|
|
7
|
+
data.tar.gz: 9e4f51c226aebee9d762106639e5299a7ee6eb69b0307e77626bb0f8e1db23a37ed8b2eb69ee4ca4aafe35de07985c1a8979ff5e0fe07c9fa175f23397ef3c25
|
data/bin/github-to-canvas
CHANGED
|
@@ -84,6 +84,10 @@ OptionParser.new do |opts|
|
|
|
84
84
|
"Adds additional Flatiron School HTML after markdown conversion") do |f|
|
|
85
85
|
options[:fis] = true
|
|
86
86
|
end
|
|
87
|
+
opts.on("--forkable",
|
|
88
|
+
"Used with --fis-links, adds fork button to HTML header injected into Canvas lesson") do |remote|
|
|
89
|
+
options[:forkable] = true
|
|
90
|
+
end
|
|
87
91
|
opts.on("-r", "--remove-header-and-footer",
|
|
88
92
|
"Removes top lesson header and any Learn.co specific footer links before converting to HTML") do |r|
|
|
89
93
|
options[:remove_header_and_footer] = true
|
|
@@ -109,6 +113,7 @@ OptionParser.new do |opts|
|
|
|
109
113
|
options[:remote] = true
|
|
110
114
|
end
|
|
111
115
|
|
|
116
|
+
|
|
112
117
|
end.parse!
|
|
113
118
|
|
|
114
119
|
if options[:version]
|
|
@@ -130,6 +135,7 @@ end
|
|
|
130
135
|
if !options[:type]
|
|
131
136
|
if Dir.glob("**/*/").empty?
|
|
132
137
|
options[:type] = "page"
|
|
138
|
+
options[:forkable] = false
|
|
133
139
|
else
|
|
134
140
|
options[:type] = "assignment"
|
|
135
141
|
end
|
|
@@ -177,7 +183,8 @@ if options[:create_lesson]
|
|
|
177
183
|
save_to_github: !!options[:save_to_github],
|
|
178
184
|
fis_links: !!options[:fis],
|
|
179
185
|
remove_header_and_footer: !!options[:remove_header_and_footer],
|
|
180
|
-
only_update_content: !!options[:only_content]
|
|
186
|
+
only_update_content: !!options[:only_content],
|
|
187
|
+
forkable: !!options[:forkable])
|
|
181
188
|
end
|
|
182
189
|
|
|
183
190
|
if options[:align]
|
|
@@ -192,5 +199,6 @@ if options[:align]
|
|
|
192
199
|
save_to_github: !!options[:save_to_github],
|
|
193
200
|
fis_links: !!options[:fis],
|
|
194
201
|
remove_header_and_footer: !!options[:remove_header_and_footer],
|
|
195
|
-
only_update_content: !!options[:only_content]
|
|
202
|
+
only_update_content: !!options[:only_content],
|
|
203
|
+
forkable: !!options[:forkable])
|
|
196
204
|
end
|
data/lib/github-to-canvas.rb
CHANGED
|
@@ -19,7 +19,8 @@ class GithubToCanvas
|
|
|
19
19
|
save_to_github:false,
|
|
20
20
|
fis_links:false,
|
|
21
21
|
remove_header_and_footer:false,
|
|
22
|
-
only_update_content: false
|
|
22
|
+
only_update_content: false,
|
|
23
|
+
forkable: false)
|
|
23
24
|
|
|
24
25
|
if mode == 'version'
|
|
25
26
|
puts VERSION
|
|
@@ -43,12 +44,12 @@ class GithubToCanvas
|
|
|
43
44
|
|
|
44
45
|
if mode == 'create'
|
|
45
46
|
puts "github-to-canvas will now create a Canvas lesson based on the current repo"
|
|
46
|
-
CreateCanvasLesson.new(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer)
|
|
47
|
+
CreateCanvasLesson.new(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, forkable)
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
if mode == 'align'
|
|
50
51
|
puts "github-to-canvas will now align any existing Canvas lessons based on the current repo. NOTE: .canvas file must be present"
|
|
51
|
-
UpdateCanvasLesson.new(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id)
|
|
52
|
+
UpdateCanvasLesson.new(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id, forkable)
|
|
52
53
|
end
|
|
53
54
|
end
|
|
54
55
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class CreateCanvasLesson
|
|
2
2
|
|
|
3
|
-
def initialize(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer)
|
|
3
|
+
def initialize(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, forkable)
|
|
4
4
|
# name = name.split(/[- _]/).map(&:capitalize).join(' ')
|
|
5
5
|
begin
|
|
6
6
|
markdown = File.read("#{filepath}/#{file_to_convert}")
|
|
@@ -8,14 +8,14 @@ class CreateCanvasLesson
|
|
|
8
8
|
puts "#{file_to_convert} not found in current directory. Exiting..."
|
|
9
9
|
abort
|
|
10
10
|
end
|
|
11
|
-
create_canvas_lesson(markdown, course, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer)
|
|
11
|
+
create_canvas_lesson(markdown, course, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, forkable)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def create_canvas_lesson(markdown, course, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer)
|
|
14
|
+
def create_canvas_lesson(markdown, course, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, forkable)
|
|
15
15
|
GithubInterface.get_updated_repo(filepath, branch)
|
|
16
16
|
new_html = RepositoryConverter.convert(filepath, markdown, branch, remove_header_and_footer)
|
|
17
17
|
if fis_links
|
|
18
|
-
new_html = RepositoryConverter.add_fis_links(filepath, new_html)
|
|
18
|
+
new_html = RepositoryConverter.add_fis_links(filepath, new_html, forkable)
|
|
19
19
|
end
|
|
20
20
|
response = CanvasInterface.submit_to_canvas(course, type, name, new_html)
|
|
21
21
|
|
|
@@ -72,25 +72,28 @@ class RepositoryConverter
|
|
|
72
72
|
redcarpet.render(readme)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
def self.add_fis_links(filepath, readme)
|
|
75
|
+
def self.add_fis_links(filepath, readme, forkable)
|
|
76
76
|
repo_path = self.get_repo_url(filepath)
|
|
77
|
-
header = self.create_github_link_header(repo_path)
|
|
77
|
+
header = self.create_github_link_header(repo_path, forkable)
|
|
78
78
|
header + readme
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
def self.create_github_link_header(repo_path)
|
|
81
|
+
def self.create_github_link_header(repo_path, forkable)
|
|
82
82
|
repo_name = repo_path.split('/')[-1]
|
|
83
83
|
|
|
84
|
-
# add link to fork (forking handled by separate Flatiron server, generation of link handled via custom Canvas JS theme file)
|
|
85
|
-
github_fork_link = "<a class='fis-fork-link' id='fork-link' data-repo='#{repo_name}' href='#' target='_blank' rel='noopener'><img id='fork-img' title='Fork This Assignment' alt='Fork This Assignment' /></a>"
|
|
86
|
-
|
|
87
84
|
# add link to associated repository
|
|
88
85
|
# github_repo_link = "<a class='fis-git-link' href='#{repo_path}' target='_blank' rel='noopener'><img id='repo-img' title='Open GitHub Repo' alt='GitHub Repo' /></a>"
|
|
89
86
|
|
|
90
87
|
# add link to new issue form
|
|
91
88
|
github_issue_link = "<a class='fis-git-link' href='#{repo_path}/issues/new' target='_blank' rel='noopener'><img id='issue-img' title='Create New Issue' alt='Create New Issue' /></a>"
|
|
92
89
|
|
|
93
|
-
|
|
90
|
+
# add link to fork (forking handled by separate Flatiron server, generation of link handled via custom Canvas JS theme file)
|
|
91
|
+
if (forkable)
|
|
92
|
+
github_fork_link = "<a class='fis-fork-link' id='fork-link' data-repo='#{repo_name}' href='#' target='_blank' rel='noopener'><img id='fork-img' title='Fork This Assignment' alt='Fork This Assignment' /></a>"
|
|
93
|
+
"<header class='fis-header' style='visibility: hidden;'>#{github_fork_link}#{github_issue_link}</header>"
|
|
94
|
+
else
|
|
95
|
+
"<header class='fis-header' style='visibility: hidden;'>#{github_issue_link}</header>"
|
|
96
|
+
end
|
|
94
97
|
end
|
|
95
98
|
|
|
96
99
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class UpdateCanvasLesson
|
|
2
2
|
|
|
3
|
-
def initialize(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id)
|
|
3
|
+
def initialize(course, filepath, file_to_convert, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id, forkable)
|
|
4
4
|
# name = name.split(/[- _]/).map(&:capitalize).join(' ')
|
|
5
5
|
begin
|
|
6
6
|
markdown = File.read("#{filepath}/#{file_to_convert}")
|
|
@@ -8,10 +8,10 @@ class UpdateCanvasLesson
|
|
|
8
8
|
puts "#{file_to_convert} not found in current directory. Exiting..."
|
|
9
9
|
abort
|
|
10
10
|
end
|
|
11
|
-
update_canvas_lesson(course, markdown, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id)
|
|
11
|
+
update_canvas_lesson(course, markdown, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id, forkable)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def update_canvas_lesson(course, markdown, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id)
|
|
14
|
+
def update_canvas_lesson(course, markdown, filepath, branch, name, type, save_to_github, fis_links, remove_header_and_footer, only_update_content, id, forkable)
|
|
15
15
|
# Pulls any updates that exist on GitHub
|
|
16
16
|
GithubInterface.get_updated_repo(filepath, branch)
|
|
17
17
|
|
|
@@ -21,7 +21,7 @@ class UpdateCanvasLesson
|
|
|
21
21
|
|
|
22
22
|
# adds Flatiron School specific header and footer
|
|
23
23
|
if fis_links
|
|
24
|
-
new_html = RepositoryConverter.add_fis_links(filepath, new_html)
|
|
24
|
+
new_html = RepositoryConverter.add_fis_links(filepath, new_html, forkable)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# Read the local .canvas file if --id <ID> is not used. Otherwise, use provided ID (--course <COURSE> also required)
|