canvas-workflow 0.5.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4776993ecddc6700c7ada9b4219877137866df237762eafc2d1c32d0e1320cd2
4
+ data.tar.gz: 59a259dfbba4cd751c62b3df9c8422e17dab2a2af8f76ad130f78bf0548474b4
5
+ SHA512:
6
+ metadata.gz: 80fa795db4d8087402688e6ecefb6b38faa04e278d8ed0180674f40d81142d9256c44e2715814128f3bbd4fb271eb7026d98ce49302dd78ddb9f5c5442b3dcc6
7
+ data.tar.gz: 90bc64fdb497861414f74318832e31dc114e508f1d43fa9cb65d9b37540924c57218f77badbe368af9585881fb80166c29730bf38ccc6b3e15e256822ba7fcd1
data/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ ## [0.5.0](https://github.com/jiverson002/canvas-workflow/releases/tag/0.5.0)
2
+ * Renamed project to canvas-workflow.
3
+ * Incorporated canvas-workflow-travis into this project.
4
+
5
+ ## [0.4.0](https://github.com/jiverson002/canvas-workflow/releases/tag/0.4.0)
6
+ * Pre-release.
7
+
8
+ ### Enhancements
9
+ * Moved 'development' dependencies to Gemfile and listed bundler as only
10
+ development dependency in gemspec.
11
+ * Made gist iframe width 100%.
12
+ * Refactored monkey-patch of resolve\_path\_courses in
13
+ Canvas::Workflow::Jekyll::FileTag out of FileTag class into pandarus.rb.
14
+ * Upgraded to canvas-workflow-travis v0.12.0.
15
+ * Added the assignment tag, which is used internally to dynamically lookup
16
+ assignment ids.
17
+
18
+ ## [0.3.0](https://github.com/jiverson002/canvas-workflow/releases/tag/0.3.0)
19
+ * Pre-release.
20
+ * Renamed project to canvas-workflow-jekyll.
21
+ * Incorporated the former standalone gem jekyll-canvas-tags into this project.
22
+
23
+ ## 0.2.0
24
+ * Pre-release.
25
+
26
+ ## [0.1.0](https://github.com/jiverson002/canvas-workflow/releases/tag/0.1.0)
27
+ * Pre-release.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jeremy Iverson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ ---
2
+ ---
3
+
4
+ # Canvas Workflow
5
+
6
+ Welcome to your new Canvas Workflow! In this directory, you'll find the files
7
+ you need to be able to package up your theme into a gem. Put your layouts in `_layouts`, your includes in `_includes`, your sass files in `_sass` and any
8
+ other assets in `assets`.
9
+
10
+ To experiment with this code, add some sample content and run `bundle exec
11
+ jekyll serve` – this directory is setup just like a Jekyll site!
12
+
13
+ TODO: Delete this and the text above, and describe your gem
14
+
15
+ ## Installation
16
+
17
+ Add this line to your Jekyll site's `Gemfile`:
18
+
19
+ ```ruby
20
+ gem "canvas-workflow-jekyll", "=0.1.0"
21
+ ```
22
+
23
+ And add this line to your Jekyll site's `_config.yml`:
24
+
25
+ ```yaml
26
+ theme: canvas-workflow-jekyll
27
+ ```
28
+
29
+ And then execute:
30
+
31
+ $ bundle
32
+
33
+ Or install it yourself as:
34
+
35
+ $ gem install canvas-workflow-jekyll
36
+
37
+ ## Usage
38
+
39
+ TODO: Write usage instructions here. Describe your available layouts, includes,
40
+ sass and/or assets.
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at
45
+ [https://github.com/jiverson002/canvas-workflow-jekyll](https://github.com/jiverson002/canvas-workflow-jekyll).
46
+ This project is intended to be a safe, welcoming space for collaboration, and
47
+ contributors are expected to adhere to the [Contributor
48
+ Covenant](http://contributor-covenant.org) code of conduct.
49
+
50
+ ## Development
51
+
52
+ To set up your environment to develop this theme, run `bundle install`.
53
+
54
+ Your theme is setup just like a normal Jekyll site! To test your theme, run
55
+ `bundle exec jekyll serve` and open your browser at `http://localhost:4000`.
56
+ This starts a Jekyll server using your theme. Add pages, documents, data, etc.
57
+ like normal to test your theme's contents. As you make modifications to your
58
+ theme and to your content, your site will regenerate and you should see the
59
+ changes in the browser after a refresh, just like normal.
60
+
61
+ When your theme is released, only the files in `_layouts`, `_includes`, `_sass`
62
+ and `assets` tracked with Git will be bundled. To add a custom directory to your
63
+ theme-gem, please edit the regexp in `canvas-workflow-jekyll.gemspec`
64
+ accordingly.
65
+
66
+ ## License
67
+
68
+ The theme is available as open source under the terms of the [MIT
69
+ License](https://opensource.org/licenses/MIT).
data/_includes/newline ADDED
@@ -0,0 +1,4 @@
1
+ {%- capture newLine %}
2
+ {% endcapture -%}
3
+ {%- capture blockNewLine %}
4
+ {% endcapture -%}
@@ -0,0 +1,20 @@
1
+ {%- include newline -%}
2
+
3
+ assignment:
4
+ # id
5
+ id: {% assignment %}
6
+
7
+ # assignment[name]
8
+ name: |
9
+ {{ page.title }}
10
+
11
+ # assignment[description]
12
+ description: |-
13
+ {{ content | replace: newLine, blockNewLine }}
14
+
15
+ # assignment[due_at]
16
+ due_at: |
17
+ {{ page.due_at }}
18
+
19
+ # assignment[notify_of_update]
20
+ notify_of_update: {{ page.notify_of_update }}
@@ -0,0 +1,23 @@
1
+ {%- include newline -%}
2
+
3
+ wiki_page:
4
+ # wiki_page[title]
5
+ title: |
6
+ {{ page.title }}
7
+
8
+ # wiki_page[body]
9
+ body: |-
10
+ {{ content | replace: newLine, blockNewLine }}
11
+
12
+ # wiki_page[editing_roles]
13
+ editing_roles: {{ page.editing_roles }}
14
+
15
+ # wiki_page[notify_of_update]
16
+ notify_of_update: {{ page.notify_of_update }}
17
+
18
+ # wiki_page[published]
19
+ published: {{ page.published }}
20
+
21
+ # wiki_page[front_page]
22
+ front_page: {{ page.front_page }}
23
+
@@ -0,0 +1,6 @@
1
+ {%- include newline -%}
2
+
3
+ course:
4
+ # course[syllabus_body]
5
+ syllabus_body: |-
6
+ {{ content | replace: newLine, blockNewLine }}
@@ -0,0 +1,41 @@
1
+ ################################################################################
2
+ ################################################################################
3
+
4
+ # Use the canvas-workflow theme to produce correctly formatted yaml files for
5
+ # use with the canvas-workflow cli.
6
+ theme: canvas-workflow
7
+
8
+ # Disable any plugins that are not explicitly enabled (whitelisted) below.
9
+ safe: true
10
+ # Allow the set of plugins included with the canvas-workflow gem to provide
11
+ # useful tags for the Canvas LMS.
12
+ whitelist:
13
+ - canvas-workflow
14
+ plugins:
15
+ - canvas-workflow
16
+
17
+ # Render pages, even those marked unpublished --- this allows a page to be
18
+ # rendered and uploaded, but marked as not published on Canvas, if
19
+ # [published: false] appears in the yaml front matter.
20
+ unpublished: true
21
+
22
+ # Disable syntax highlighting.
23
+ highlighter: none
24
+
25
+ # Fail build if there is incorrect yaml front matter.
26
+ strict_front_matter: true
27
+
28
+ # Set the default layouts for certain types of files.
29
+ defaults:
30
+ - scope:
31
+ path: "README.md"
32
+ values:
33
+ layout: syllabus
34
+ - scope:
35
+ path: "assignments"
36
+ values:
37
+ layout: assignment
38
+ - scope:
39
+ path: "pages"
40
+ values:
41
+ layout: page
data/bin/canvas ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'canvas-workflow'
4
+
5
+ Canvas::Workflow::CLI.start(ARGV)
@@ -0,0 +1,6 @@
1
+ require 'canvas/workflow'
2
+
3
+ module Canvas
4
+ module Workflow
5
+ end
6
+ end
@@ -0,0 +1,78 @@
1
+ require 'time' # needed to fix dtao/safe_yaml#80
2
+ require 'safe_yaml' # yaml parser
3
+
4
+ require 'canvas/workflow/cli'
5
+ require 'canvas/workflow/client'
6
+ require 'canvas/workflow/pandarus'
7
+ require 'canvas/workflow/tags'
8
+ require 'canvas/workflow/travis'
9
+ require 'canvas/workflow/version'
10
+
11
+ SafeYAML::OPTIONS[:default_mode] = :safe
12
+
13
+ module Canvas
14
+ module Workflow
15
+ # Access the configuration object for this Canvas Workflow site.
16
+ #
17
+ # @return the configuration object for this Canvas Workflow site
18
+ def self.config
19
+ # load user configuration
20
+ @config ||= YAML.load_file('_config.yml')['canvas']
21
+ end
22
+
23
+ # Access the Canvas client for this Canvas Workflow site.
24
+ #
25
+ # @return [Canvas::Client] the Canvas client for this Canvas Workflow site
26
+ def self.client
27
+ @client ||= Client.new(config)
28
+ end
29
+
30
+ # Is +file+ excluded from upload?
31
+ #
32
+ # @param file [String] a file name
33
+ # @return [Boolean] true if the file has been excluded from upload.
34
+ def self.excluded?(file)
35
+ return false if config['exclude'].nil?
36
+
37
+ # get the list of files that has been explicitly excluded
38
+ @excluded ||= Dir.glob(config['exclude'].map do |f|
39
+ if File.directory?(f)
40
+ if f.end_with?("/")
41
+ f + "**/*"
42
+ else
43
+ f + "/**/*"
44
+ end
45
+ else
46
+ f
47
+ end
48
+ end)
49
+
50
+ # check if the param file has been excluded
51
+ @excluded.include?(file)
52
+ end
53
+
54
+ # Is +file+ included for upload?
55
+ #
56
+ # @param file [String] a file name
57
+ # @return [Boolean] true if the file has been included for upload.
58
+ def self.included?(file)
59
+ return false if config['include'].nil?
60
+
61
+ # get the list of files that has been explicitly included
62
+ @included ||= Dir.glob(config['include'].map do |f|
63
+ if File.directory?(f)
64
+ if f.end_with?("/")
65
+ f + "**/*"
66
+ else
67
+ f + "/**/*"
68
+ end
69
+ else
70
+ f
71
+ end
72
+ end)
73
+
74
+ # check if the param file has been included
75
+ @included.include?(file)
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,24 @@
1
+ require 'thor'
2
+
3
+ module Canvas
4
+ module Workflow
5
+ module CLI
6
+ class Main < Thor
7
+ end
8
+
9
+ def self.desc(*args)
10
+ Main.send(:desc, *args)
11
+ end
12
+
13
+ def self.subcommand(*args)
14
+ Main.send(:subcommand, *args)
15
+ end
16
+
17
+ def self.start(*args)
18
+ Main.send(:start, *args)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ Dir[File.dirname(__FILE__) + '/cli/*.rb'].each { |file| require file }
@@ -0,0 +1,79 @@
1
+ require 'time' # needed to fix dtao/safe_yaml#80
2
+ require 'safe_yaml' # yaml parser
3
+
4
+ SafeYAML::OPTIONS[:default_mode] = :safe
5
+
6
+ module Canvas
7
+ module Workflow
8
+ module CLI
9
+ class Deploy < Thor
10
+ desc "deploy", "Deploy the Canvas Workflow project to a Canvas LMS"
11
+ def deploy
12
+ # upload syllabus
13
+ # FIXME this only compacts one level
14
+ Dir.glob('README.md').select do |md_file|
15
+ upload?(md_file)
16
+ end.each do |md_file|
17
+ html_file = File.join('_site', File.basename(md_file, '.md') + '.html')
18
+
19
+ puts "=> uploading #{html_file}"
20
+
21
+ content = YAML.load_file(html_file)
22
+
23
+ content.each { |k,v| v.compact! }.compact!
24
+
25
+ Workflow.client.update_course(course, content)
26
+ end
27
+
28
+ # upload pages
29
+ # FIXME see upload syllabus
30
+ Dir.glob('pages/*.md').select do |md_file|
31
+ upload?(md_file)
32
+ end.each do |md_file|
33
+ url = File.basename(md_file, '.md')
34
+ html_file = File.join('_site', 'pages', url + '.html')
35
+
36
+ puts "=> uploading #{html_file}"
37
+
38
+ content = YAML.load_file(html_file)
39
+
40
+ content.each { |k,v| v.compact! }.compact!
41
+
42
+ Workflow.client.update_create_page_courses(course, url, content)
43
+ end
44
+
45
+ # upload assignments
46
+ # FIXME see upload syllabus
47
+ Dir.glob('assignments/*.md').select do |md_file|
48
+ upload?(md_file)
49
+ end.each do |md_file|
50
+ html_file = File.join('_site', 'assignments', File.basename(md_file, '.md') + '.html')
51
+
52
+ puts "=> uploading #{html_file}"
53
+
54
+ content = YAML.load_file(html_file)
55
+
56
+ content.each { |k,v| v.compact! }.compact!
57
+
58
+ Workflow.client.edit_assignment(course, content['assignment']['id'], content)
59
+ end
60
+ end
61
+
62
+ default_task :deploy
63
+
64
+ private
65
+
66
+ def course
67
+ @course ||= Workflow.config['course']
68
+ end
69
+
70
+ def upload?(file)
71
+ Travis.created?(file) || Travis.modified?(file)
72
+ end
73
+ end
74
+
75
+ desc "deploy", "Deploy a Canvas Workflow project to a Canvas LMS"
76
+ subcommand "deploy", Deploy
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,28 @@
1
+ module Canvas
2
+ module Workflow
3
+ module CLI
4
+ class Jekyll < Thor
5
+ desc "build", "Build the Canvas Workflow project"
6
+ option :with_bundler, :aliases => :b,
7
+ :type => :boolean, :default => false,
8
+ :desc => "build using bundler?"
9
+ def build
10
+ assets = File.expand_path("../../../../../assets", __FILE__)
11
+ asset = File.join(assets, "_config.yml")
12
+
13
+ cmd = ""
14
+ cmd << "bundle exec " if options[:with_bundler]
15
+ cmd << "jekyll build --config #{asset},_config.yml --verbose"
16
+ #puts "#{cmd}"
17
+ exec("#{cmd}")
18
+ end
19
+ end
20
+
21
+ desc "jekyll SUBCOMMAND ...ARGS", "Manage static site generator"
22
+ subcommand "jekyll", Jekyll
23
+ end
24
+ end
25
+ end
26
+
27
+ # Canvas::Workflow::CLI.desc "jekyll SUBCOMMAND ...ARGS", "Manage static site generator"
28
+ # Canvas::Workflow::CLI.subcommand "jekyll", Canvas::Workflow::CLI::Jekyll