github-to-canvas 0.0.11 → 0.0.16

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: 732a757e941548fa67c1ede523fe03575dc22e8890d87300ce8e41732a2f01e3
4
- data.tar.gz: 9966442368051e67fea9e6b7ce44ebb1555c645bd61f0512feea8e9ca3486995
3
+ metadata.gz: 3152fc876a1490ceeb473de2839518c2ced04e535ea246de7fd49c0a07003ff6
4
+ data.tar.gz: d13329c8279a5b6cc971b6d3ef75a34bec6c4a4f329aba35f34a1bb7eb59a337
5
5
  SHA512:
6
- metadata.gz: 6f67897ee3991f5e914524e04a7b90fb0985092c106ce57b16d64cb8afa74ec1555dbd8dbd57ad0a4be780595b6c8a02af9d914d5e6a63dbc9f5fac662418285
7
- data.tar.gz: 8e2793cc5b58f7ad2e0a1e2e9a4244d34172736e0d69f34940f87b0603432287ddb088876392905c36adaef4809298791a1164118e6ab8dec95a06469bb6cc24
6
+ metadata.gz: 208aa644d3bcdec1c7f393c12cacaee4ad80b16ec818603cca5ff97f75d1414d7743219430e28d00a49b66d27caa9afbed49e00ecca31f1ae1df6442006866bc
7
+ data.tar.gz: e7539b042e5650952e1880da35a8b16b50da481eb59902e9012c2e3f964e2aacb8c3ec06f180c321bf256a8744e30c367e4f14566f62312cbb4c5006c08e5963
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # GitHub to Canvas Gem
2
- hello
2
+
3
3
  ## Introduction
4
4
 
5
5
  The `github-to-canvas` gem is designed to enable GitHub to Canvas LMS
@@ -8,11 +8,13 @@ file, convert it to HTML, and push it to Canvas. The gem also updates the
8
8
  repository to include a `.canvas` file containing Canvas specific information.
9
9
 
10
10
  With the `.canvas` file in place, this gem can be used to continuously align
11
- content between GitHub and Canvas.
11
+ content between GitHub and Canvas using the GitHub repository as the single
12
+ source of truth.
12
13
 
13
14
  This gem is built for use internally at [Flatiron School][]. Access to the
14
15
  [Canvas LMS API][] and the ability to add pages and assignments to a Canvas
15
- course are required.
16
+ course are required. Write access to the GitHub repository being converted is
17
+ also required.
16
18
 
17
19
  ## Installation
18
20
 
@@ -29,7 +31,7 @@ called `CANVAS_API_KEY`. Use the following command to add your new key to
29
31
  `~/.zshrc`:
30
32
 
31
33
  ```sh
32
- echo "$(echo 'CANVAS_API_KEY=<your-new-API-key-here>' | cat - ~/.zshrc)" > ~/.zshrc
34
+ echo "$(export 'CANVAS_API_KEY=<your-new-API-key-here>' | cat - ~/.zshrc)" > ~/.zshrc
33
35
  ```
34
36
 
35
37
  > **Note:** The command above assumes you are using Zsh. Change the dotfile if
@@ -42,7 +44,7 @@ Flatiron School's base path is `https://learning.flatironschool.com/api/v1`. Add
42
44
  as an `ENV` variable like the API key. **Do not add a `/` at the end after `/api/v1`.**
43
45
 
44
46
  ```sh
45
- echo "$(echo 'CANVAS_API_PATH=<your-base-api-path>' | cat - ~/.zshrc)" > ~/.zshrc
47
+ echo "$(export 'CANVAS_API_PATH=<your-base-api-path>' | cat - ~/.zshrc)" > ~/.zshrc
46
48
  ```
47
49
 
48
50
  After both the API key and path are added to `~/.zshrc`, run `source ~/.zshrc`
@@ -51,11 +53,17 @@ are present by running `ENV`.
51
53
 
52
54
  ## Usage
53
55
 
54
- To migrate a GitHub `README.md` file to Canvas, at minimum, you will need to know the
55
- Canvas course id you are going to add to. This id can be found in the URL of the course.
56
+ ### Create a Canvas Lesson
57
+
58
+ To create a Canvas lesson from a GitHub `README.md` file, at minimum, you will
59
+ need to know the Canvas course id you are going to add to. This id can be found
60
+ in the URL of the course.
56
61
 
57
- 1. clone down the repository to a local folder and change directory into it.
58
- 2. Run `github-to-canvas --create <your-course-id>`
62
+ Once you have the course id, you will need to do the following:
63
+
64
+ 1. Clone down the repository you'd like to push to Canvas.
65
+ 2. Change directory into the new local repository
66
+ 3. Run `github-to-canvas --create <your-course-id>` from inside the local repo
59
67
 
60
68
  If everything is set up properly, `github-to-canvas` will create a Canvas lesson
61
69
  using `master` branch `README.md` and the name of the current folder. By
@@ -63,8 +71,30 @@ default, if the repository contains folders, an **assignment** will be created.
63
71
  Otherwise, a **page** will be created.
64
72
 
65
73
  After a successful lesson creation, `github-to-canvas` will use the API response
66
- to build a `.canvas` YAML file. This file contains the course id, the newly created
67
- page id, and the Canvas URL to the lesson for future reference.
74
+ to build a `.canvas` YAML file. This file contains the course id, the newly
75
+ created page id, and the Canvas URL to the lesson for future reference. With the
76
+ newly created `.canvas` file, `github-to-canvas` will attempt to commit and push the
77
+ file up to the remote GitHub repository.
78
+
79
+ If you create multiple Canvas lessons from the same repository, each lesson's
80
+ Canvas data will be stored in the `.canvas` file.
81
+
82
+ > **Note:** If you don't have write access to the repository, the `.canvas` file
83
+ > will still be created locally.
84
+
85
+ ### Update an existing Canvas Lesson
86
+
87
+ To update an existing Canvas lesson using a local repository, **a `.canvas` file
88
+ must be present in the repo**, as it contains the lesson information for the
89
+ Canvas API.
90
+
91
+ 1. Clone down and/or change directory into the repository you'd like to update
92
+ 2. Run `github-to-canvas --align <your-course-id>` from inside the local repo
93
+
94
+ `github-to-canvas` will get the course id and page/assignment id from the
95
+ `.canvas` file and update the associated Canvas lesson. If there are multiple
96
+ Canvas lessons included in the `.canvas` file, each lesson will be updated (i.e.
97
+ you have the same lesson in two courses created from one repository).
68
98
 
69
99
  ### Options
70
100
 
@@ -76,5 +106,17 @@ You can override the default behaviors with the following arguments:
76
106
  appropriate Canvas lesson type instead of relying on the repository's
77
107
  directory structure
78
108
 
109
+ ## Examples of Valid Images This Gem Can Convert
110
+
111
+ Inline Markdown:
112
+
113
+ ![example in-line image](https://curriculum-content.s3.amazonaws.com/fewpjs/fewpjs-fetch-lab/Image_25_AsynchronousJavaScript.png)
114
+
115
+ HTML:
116
+
117
+ <p align="center">
118
+ <img src="https://curriculum-content.s3.amazonaws.com/fewpjs/fewpjs-fetch-lab/Image_25_AsynchronousJavaScript.png" width="500">
119
+ </p>
120
+
79
121
  [Canvas LMS API]: https://canvas.instructure.com/doc/api/index.html
80
122
  [Flatiron School]: https://flatironschool.com/
@@ -1,5 +1,5 @@
1
1
  require 'yaml'
2
- require 'byebug'
2
+
3
3
  class CanvasDotfile
4
4
 
5
5
  def self.update_or_create(filepath, response, course, type)
@@ -1,6 +1,6 @@
1
1
  require 'json'
2
2
  require 'rest-client'
3
- require 'byebug'
3
+
4
4
  class CanvasInterface
5
5
 
6
6
  def self.submit_to_canvas(course_id, type, name, readme, dry_run = false)
@@ -25,8 +25,8 @@ class CanvasInterface
25
25
  })
26
26
  end
27
27
 
28
- def self.update_existing_lesson(course_id, page_id, type, name, new_readme, dry_run)
29
- url = "#{ENV['CANVAS_API_PATH']}/courses/#{course_id}/#{type}s/#{page_id}"
28
+ def self.update_existing_lesson(course_id, id, type, name, new_readme, dry_run)
29
+ url = "#{ENV['CANVAS_API_PATH']}/courses/#{course_id}/#{type}s/#{id}"
30
30
  payload = self.build_payload(type, name, new_readme)
31
31
  RestClient.put(url, payload, headers={
32
32
  "Authorization" => "Bearer #{ENV['CANVAS_API_KEY']}"
@@ -13,7 +13,7 @@ class GithubInterface
13
13
  end
14
14
 
15
15
  def self.git_co_branch(filepath, branch)
16
- branch = self.cd_into_and(filepath, "git co #{branch}")
16
+ branch = self.cd_into_and(filepath, "git checkout #{branch}")
17
17
  if branch.to_s.strip.empty?
18
18
  puts "#{branch} branch not found. Exiting..."
19
19
  abort
@@ -26,7 +26,7 @@ class RepositoryConverter
26
26
  image.gsub!(/\(.+\)/) { |path|
27
27
  path.delete_prefix!("(")
28
28
  path.delete_suffix!(")")
29
- "(" + remote + "/#{branch}/" + path + ")"
29
+ "(" + raw_remote_url + "/#{branch}/" + path + ")"
30
30
  }
31
31
  end
32
32
  image
@@ -35,12 +35,14 @@ class RepositoryConverter
35
35
 
36
36
  def self.adjust_local_html_images(readme, raw_remote_url)
37
37
  readme.gsub!(/src=\"[\s\S]*?" /) { |img|
38
- if !image.match('amazonaws.com') && !image.match('https://') && !image.match('youtube')
38
+ if !img.match('amazonaws.com') && !img.match('https://') && !img.match('youtube')
39
39
  img.gsub!(/\"/, "")
40
40
  img.gsub!(/src=/, '')
41
41
  img.strip!
42
+ 'src="' + raw_remote_url + '/master/' + img + '"'
43
+ else
44
+ img
42
45
  end
43
- 'src="' + raw_remote_url + '/master/' + img + '"'
44
46
  }
45
47
  end
46
48
 
@@ -1,3 +1,3 @@
1
- class LearnTool
2
- VERSION = "0.0.9"
1
+ class GithubToCanvas
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-to-canvas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - maxwellbenton