github-to-canvas 0.0.50 → 0.0.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/github-to-canvas +9 -2
- 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
- data/lib/github-to-canvas.rb +4 -3
- 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: 4dd3ab1c6c19565bf5e03e674831589f0ab407f65afeb3cc6aadf14c28c2dfa7
|
4
|
+
data.tar.gz: ba9661ec0bc2824d6d42fecf0c904232a2cc323c1dedc4803dafc7347959e992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ababba4146ccb17bdd7779600697d964b13f7a86827fcb3b6ecb05fdcea8cb34b4ab6153f994bbce8dc4c6b42acb45793f3b2eabff787a5161b664ba2b183282
|
7
|
+
data.tar.gz: ed1939d585348330f4c7e39f66485093de9ef9f7af359ae55830e447a567040de97b4ad754d93a6a7a50ef910c181cf5933f0c0f48bbd02265ca8eea0df7961d
|
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("--fork",
|
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]
|
@@ -177,7 +182,8 @@ if options[:create_lesson]
|
|
177
182
|
save_to_github: !!options[:save_to_github],
|
178
183
|
fis_links: !!options[:fis],
|
179
184
|
remove_header_and_footer: !!options[:remove_header_and_footer],
|
180
|
-
only_update_content: !!options[:only_content])
|
185
|
+
only_update_content: !!options[:only_content]),
|
186
|
+
forkable: !!options[:forkable]
|
181
187
|
end
|
182
188
|
|
183
189
|
if options[:align]
|
@@ -192,5 +198,6 @@ if options[:align]
|
|
192
198
|
save_to_github: !!options[:save_to_github],
|
193
199
|
fis_links: !!options[:fis],
|
194
200
|
remove_header_and_footer: !!options[:remove_header_and_footer],
|
195
|
-
only_update_content: !!options[:only_content])
|
201
|
+
only_update_content: !!options[:only_content]),
|
202
|
+
forkable: !!options[:forkable]
|
196
203
|
end
|
@@ -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
|
+
}
|
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)
|
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
|
|