jekyll-theme-open-course 0.0.1 → 1.3.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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -6
  3. data/_config.yml +35 -2
  4. data/_data/utility.yml +1 -1
  5. data/_layouts/calendar.html +68 -17
  6. data/_layouts/default.html +39 -22
  7. data/_layouts/error.html +10 -0
  8. data/_layouts/policies.html +17 -0
  9. data/_layouts/projects.html +71 -0
  10. data/_sass/_base.scss +108 -0
  11. data/_sass/_colors.scss +190 -0
  12. data/_sass/_fonts.scss +10 -0
  13. data/_sass/_typography.scss +358 -0
  14. data/assets/css/print.css +26 -24
  15. data/assets/css/screen.scss +22 -0
  16. data/assets/js/site.js +289 -0
  17. data/assets/js/sw.js +220 -0
  18. data/exe/jtoc +76 -0
  19. data/lib/jtoc.rb +177 -0
  20. data/lib/starter_files/_config.yml.erb +84 -0
  21. data/lib/starter_files/_data/calendar.yml.erb +6 -0
  22. data/lib/starter_files/_data/utility.yml +35 -0
  23. data/lib/starter_files/index.md.erb +5 -0
  24. data/lib/starter_files/offline/index.md +7 -0
  25. data/lib/starter_files/syllabus/_policies/academic-integrity.md +3 -0
  26. data/lib/starter_files/syllabus/_policies/assignment-submission.md +3 -0
  27. data/lib/starter_files/syllabus/_policies/books.md +17 -0
  28. data/lib/starter_files/syllabus/_policies/description.md +3 -0
  29. data/lib/starter_files/syllabus/_policies/goals.md +3 -0
  30. data/lib/starter_files/syllabus/_policies/grading-criteria.md +3 -0
  31. data/lib/starter_files/syllabus/_policies/grading-policy.md +3 -0
  32. data/lib/starter_files/syllabus/_policies/late-work.md +3 -0
  33. data/lib/starter_files/syllabus/_policies/materials.md +17 -0
  34. data/lib/starter_files/syllabus/_policies/objectives.md +3 -0
  35. data/lib/starter_files/syllabus/_policies/outcomes.md +3 -0
  36. data/lib/starter_files/syllabus/_policies/participation.md +3 -0
  37. data/lib/starter_files/syllabus/_policies/special-needs.md +3 -0
  38. data/lib/starter_files/syllabus/_policies/technology-policy.md +3 -0
  39. data/lib/starter_files/syllabus/_projects/project-00.md.erb +23 -0
  40. data/lib/starter_files/syllabus/_weeks/week-00.md.erb +11 -0
  41. data/projects/index.md +1 -30
  42. metadata +39 -26
  43. data/_data/weeks/01.yml +0 -21
  44. data/_data/weeks/02.yml +0 -1
  45. data/_data/weeks/03.yml +0 -1
  46. data/_data/weeks/04.yml +0 -1
  47. data/_data/weeks/05.yml +0 -1
  48. data/_data/weeks/06.yml +0 -1
  49. data/_data/weeks/07.yml +0 -1
  50. data/_data/weeks/08.yml +0 -1
  51. data/_data/weeks/09.yml +0 -1
  52. data/_data/weeks/10.yml +0 -1
  53. data/_data/weeks/11.yml +0 -1
  54. data/_data/weeks/12.yml +0 -1
  55. data/_data/weeks/13.yml +0 -1
  56. data/_data/weeks/14.yml +0 -1
  57. data/_data/weeks/15.yml +0 -1
  58. data/_data/weeks/16.yml +0 -1
  59. data/_projects/project-01.md +0 -25
  60. data/_projects/project-02.md +0 -25
  61. data/_projects/project-03.md +0 -25
  62. data/assets/.keep +0 -0
  63. data/assets/css/screen.css +0 -408
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+
5
+ require 'mercenary'
6
+ require 'jtoc'
7
+
8
+ Mercenary.program(:jtoc) do |p|
9
+ p.version JTOpenCourse::VERSION
10
+ p.description "A generator for the Open Course Jekyll theme"
11
+ p.syntax "jtoc <subcommand> [options]"
12
+
13
+ p.command(:version) do |c|
14
+ c.description "Ouput the version number"
15
+ c.syntax "version"
16
+ c.action do |_,_|
17
+ puts JTOpenCourse::VERSION
18
+ end
19
+ end
20
+
21
+ p.command(:setup) do |c|
22
+ c.syntax "setup"
23
+ c.description <<~DESC
24
+ Interactively set up a new course site.
25
+ DESC
26
+ c.action do |_,_|
27
+ puts "Enter the short identifier for this course:"
28
+ while true
29
+ path = gets.chomp
30
+ if JTOpenCourse::SiteBuilder.path_check(path)
31
+ puts "A course with that identifier already exists. Try another:"
32
+ else
33
+ break
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ p.command(:new) do |c|
40
+ c.syntax "new PATH [options]"
41
+ c.description <<~DESC
42
+ Create a new course site at PATH. By design, the PATH value is used for the
43
+ directory value as well as the GitHub repo name, and the base URL for the
44
+ course site (e.g., https://example.com/PATH/)
45
+ DESC
46
+ c.option 'monday', '-m DATE', '--monday DATE', 'Set the first Monday of the term (e.g., 2020-01-13)'
47
+ c.option 'weeks', '-w NUM', '--weeks NUM', 'Set the number of weeks in the term'
48
+ c.option 'projects', '-p NUM', '--projects NUM', 'Set the number of major projects in the course'
49
+ c.option 'days', '-d DAYS', '--days DAYS', 'Set the course meeting days (e.g., "Monday, Wednesday")'
50
+ c.option 'url', '-u URL', '--url URL', 'Set the course URL (e.g., https://example.com).'
51
+ c.option 'number', '-n COURSE', '--number COURSE', 'Set the course number (e.g., "COM 101")'
52
+ c.option 'title', '-l TITLE', '--title TITLE', 'Set the course title (e.g., "Intro to Communication")'
53
+ c.option 'instructor', '-i NAME', '--instructor NAME', 'Set the instructor name (e.g., "Marcus Cicero")'
54
+ c.option 'cc', '-c', '--creative-commons', 'Add a Creative Commons license'
55
+ c.action do |args, options|
56
+ course = JTOpenCourse::SiteBuilder.new(args, options)
57
+ if course.path.exist?
58
+ puts "A directory named '#{course.name}' already exists. Aborting."
59
+ abort
60
+ end
61
+ course.create!
62
+ end
63
+ end
64
+
65
+ p.action do |args, _|
66
+ if args.empty?
67
+ puts p
68
+ else
69
+ subcommand = args.first
70
+ unless p.has_command? subcommand
71
+ puts "Sorry, I don't know how to '#{args.first}'."
72
+ puts "Try running `jtgen --help` for help."
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,177 @@
1
+ module JTOpenCourse
2
+
3
+ require 'erb'
4
+ require 'date'
5
+
6
+ VERSION = "1.3.0"
7
+
8
+ SPELLED_NUMS = %w(
9
+ Zero One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen
10
+ Sixteen Seventeen Eighteen Nineteen Twenty Twenty-One Twenty-Two Twenty-Three Twenty-Four
11
+ Twenty-Five
12
+ )
13
+
14
+ # No small amount of this code has been either inspired or just about lifted from Jekyll's
15
+ # ThemeBuilder class at https://github.com/jekyll/jekyll/blob/master/lib/jekyll/theme_builder.rb
16
+
17
+ class SiteBuilder
18
+ SCAFFOLD_DIRECTORIES = %w(
19
+ _data policies projects syllabus/_policies syllabus/_projects syllabus/_weeks
20
+ ).freeze
21
+
22
+ SCAFFOLD_PAGE_STUBS = %w(
23
+ index.md projects/index.md policies/index.md
24
+ ).freeze
25
+
26
+ DEFAULT_VALUES = {
27
+ weeks: 16,
28
+ projects: 3,
29
+ days: "Monday, Wednesday",
30
+ url: "http://example.com/",
31
+ number: "COM 101",
32
+ title: "Introduction to Communication",
33
+ instructor: "Horatio Q. Birdbath",
34
+ email: "instructor@example.com",
35
+ cc: false
36
+ }
37
+
38
+ attr_reader :counter, :name, :path, :anchor_date, :week_count, :project_count, :days, :url, :number, :title, :instructor, :cc, :email
39
+
40
+ def initialize(args, options)
41
+ @counter = 0
42
+ @name = args.first.chomp
43
+ @path = Pathname.new(File.expand_path(name, Dir.pwd))
44
+
45
+ @anchor_date = set_value(find_next_monday(options['monday']),find_next_monday)
46
+ @week_count = set_value(options['weeks'], DEFAULT_VALUES[:weeks]).to_i
47
+ @project_count = set_value(options['projects'], DEFAULT_VALUES[:projects]).to_i
48
+ @days = set_value(options['days'], DEFAULT_VALUES[:days]).split(/\W+/)
49
+
50
+ @url = set_value(options['url'],DEFAULT_VALUES[:url]).chomp('/')
51
+ @number = set_value(options['number'],DEFAULT_VALUES[:number])
52
+ @title = set_value(options['title'],DEFAULT_VALUES[:title])
53
+ @instructor = set_value(options['instructor'], set_value(query_git_config('user.name'),DEFAULT_VALUES[:instructor]))
54
+ @cc = set_value(options['cc'], DEFAULT_VALUES[:cc])
55
+
56
+ @email = set_value(query_git_config('user.email'),DEFAULT_VALUES[:email])
57
+ end
58
+
59
+ def self.path_check(name)
60
+ Pathname.new(File.expand_path(name, Dir.pwd)).exist?
61
+ end
62
+
63
+ def set_value(custom,default)
64
+ if custom.to_s.empty?
65
+ custom = default
66
+ end
67
+ custom
68
+ end
69
+
70
+ def query_git_config(val)
71
+ begin
72
+ val = `git config --global #{val}`.chomp
73
+ val.empty? ? false : val
74
+ rescue
75
+ false
76
+ end
77
+ end
78
+
79
+ def find_next_monday(date=Date.today.to_s)
80
+ date = Date.parse(date)
81
+ while date.cwday > 1
82
+ date += 1
83
+ end
84
+ date
85
+ end
86
+
87
+ def create!
88
+ create_directories
89
+ create_config_yml
90
+ create_utility_data
91
+ create_calendar_data
92
+ create_projects
93
+ create_weeks
94
+ create_policies
95
+ create_page_stubs
96
+ end
97
+
98
+ def starter_path
99
+ @starter_path ||= Pathname.new(File.expand_path("starter_files", __dir__))
100
+ end
101
+
102
+ def create_directories
103
+ mkdir_p(SCAFFOLD_DIRECTORIES)
104
+ end
105
+
106
+ def create_projects
107
+ for @counter in 1..@project_count do
108
+ process_file("syllabus/_projects/project-#{@counter.to_s.rjust(2,"0")}.md", "syllabus/_projects/project-00.md")
109
+ end
110
+ end
111
+
112
+ def create_weeks
113
+ for @counter in 1..@week_count do
114
+ process_file("syllabus/_weeks/week-#{@counter.to_s.rjust(2,"0")}.md", "syllabus/_weeks/week-00.md")
115
+ end
116
+ end
117
+
118
+ def create_policies
119
+ Dir.chdir(starter_path) do
120
+ Dir.glob("syllabus/_policies/*.md").each do |f|
121
+ process_file(f)
122
+ end
123
+ end
124
+ end
125
+
126
+ def create_config_yml
127
+ process_file("_config.yml")
128
+ end
129
+
130
+ def create_calendar_data
131
+ process_file("_data/calendar.yml")
132
+ end
133
+
134
+ def create_utility_data
135
+ process_file("_data/utility.yml")
136
+ end
137
+
138
+ def create_page_stubs
139
+ SCAFFOLD_PAGE_STUBS.each_with_index do |stub,c|
140
+ @counter = c
141
+ process_file(stub,"index.md")
142
+ end
143
+ end
144
+
145
+ def mkdir_p(directories)
146
+ Array(directories).each do |d|
147
+ FileUtils.mkdir_p(path.join(d))
148
+ end
149
+ end
150
+
151
+ def render_erb(contents)
152
+ ERB.new(contents, trim_mode: "<>").result binding
153
+ end
154
+
155
+ def process_file(output,input=output)
156
+ write_file(output,process_template(input))
157
+ end
158
+
159
+ def process_template(filename)
160
+ render_erb(find_template_file(filename).read)
161
+ end
162
+
163
+ def find_template_file(filename)
164
+ [
165
+ starter_path.join("#{filename}.erb"),
166
+ starter_path.join(filename.to_s)
167
+ ].find(&:exist?)
168
+ end
169
+
170
+ def write_file(filename, contents)
171
+ full_path = path.join(filename)
172
+ File.write(full_path, contents)
173
+ end
174
+
175
+ end
176
+
177
+ end
@@ -0,0 +1,84 @@
1
+ url: <%= url %>
2
+ baseurl: /<%= name %>/
3
+
4
+ timezone: America/Chicago
5
+
6
+ course:
7
+ number: <%= number %>
8
+ title: <%= title %>
9
+ uid: <%= name %>
10
+ tagline: >
11
+ Write a course tagline in `_config.yml`
12
+ term: <%= anchor_date.year %>
13
+ # Set `days: ""` (empty string) for weekly/asynchronous classes
14
+ days: <%= '""' unless days.length > 0 %>
15
+ <% days.each do |d| %>- <%= d %>
16
+ <% end %>
17
+ <% if cc %>
18
+ license:
19
+ name: Creative Commons
20
+ url: https://creativecommons.org/licenses/by/4.0/
21
+ <% end %>
22
+ instructor:
23
+ honorific: Dr.
24
+ name: <%= instructor %>
25
+ title: Professor
26
+ full_title: Enter a full professional title in `_config.yml`
27
+ url: https://example.com/instructor/
28
+ github: https://github.com/example/
29
+ email: <%= email %>
30
+ office_hours: >
31
+ Detail your office hours in `_config.yml`
32
+ navigation:
33
+ - label: Calendar
34
+ href: "#this-week"
35
+ id: cal
36
+ - label: Projects
37
+ href: "projects/#current"
38
+ id: pro
39
+ - label: Policies
40
+ href: "policies/"
41
+ id: pol
42
+ css:
43
+ font-url: "https://use.typekit.net/pig5ein.css"
44
+
45
+ collections_dir: syllabus
46
+
47
+ collections:
48
+ weeks:
49
+ projects:
50
+ policies:
51
+ # Rearrange the files listed here to change their order on the policies page.
52
+ # To remove a section from the policies page, you *must* delete the file in the
53
+ # /syllabus/_policies/ directory
54
+ order:
55
+ - description.md
56
+ - goals.md
57
+ - outcomes.md
58
+ - objectives.md
59
+ - books.md
60
+ - materials.md
61
+ - special-needs.md
62
+ - participation.md
63
+ - assignment-submission.md
64
+ - late-work.md
65
+ - grading-policy.md
66
+ - grading-criteria.md
67
+ - technology-policy.md
68
+ - academic-integrity.md
69
+
70
+ defaults:
71
+ - scope:
72
+ path: ""
73
+ values:
74
+ layout: "default"
75
+
76
+ theme: jekyll-theme-open-course
77
+
78
+ exclude:
79
+ - backstop_data
80
+ - backstop.json
81
+ - exe
82
+ - lib
83
+ - Rakefile
84
+ - "*.gemspec"
@@ -0,0 +1,6 @@
1
+ - begins: <%= anchor_date %>T00:00
2
+ expires: &two <%= anchor_date + 7 %>T00:00
3
+ <% week_num = 2; while week_num <= week_count %>
4
+ - begins: *<%= SPELLED_NUMS[week_num].downcase %>
5
+ expires: &<%= SPELLED_NUMS[week_num + 1].downcase %> <%= anchor_date + (week_num * 7) %>T00:00<% week_num += 1 %>
6
+ <% end %>
@@ -0,0 +1,35 @@
1
+ day_offsets:
2
+ monday: 0
3
+ tuesday: 86400
4
+ wednesday: 172800
5
+ thursday: 259200
6
+ friday: 345600
7
+ saturday: 432000
8
+ sunday: 518400
9
+ spelled_nums:
10
+ - Zero
11
+ - One
12
+ - Two
13
+ - Three
14
+ - Four
15
+ - Five
16
+ - Six
17
+ - Seven
18
+ - Eight
19
+ - Nine
20
+ - Ten
21
+ - Eleven
22
+ - Twelve
23
+ - Thirteen
24
+ - Fourteen
25
+ - Fifteen
26
+ - Sixteen
27
+ - Seventeen
28
+ - Eighteen
29
+ - Nineteen
30
+ - Twenty
31
+ - Twenty-One
32
+ - Twenty-Two
33
+ - Twenty-Three
34
+ - Twenty-Four
35
+ - Twenty-Five
@@ -0,0 +1,5 @@
1
+ ---<% page_fragment = SCAFFOLD_PAGE_STUBS[counter].split('/').first; page_title = page_fragment == 'index.md' ? "Calendar" : page_fragment %>
2
+ title: Course <%= page_title.capitalize %>
3
+ id: <%= page_title.downcase %>
4
+ layout: <%= page_title.downcase %>
5
+ ---
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: Site Offline
3
+ layout: error
4
+ ---
5
+
6
+ Well this is embarrassing. Either there’s something the matter with your internet connection, or the
7
+ server where this course site is hosted. Best to just try again later.
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Academic Integrity
3
+ ---
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Assignment Submission
3
+ ---
@@ -0,0 +1,17 @@
1
+ ---
2
+ title: Books
3
+ ---
4
+
5
+ <section class="required" markdown="1">
6
+ <h3>Required</h3>
7
+
8
+ - Required book one
9
+ - Required book two
10
+ </section>
11
+
12
+ <section class="recommended" markdown="1">
13
+ <h3>Recommended</h3>
14
+
15
+ - Recommended book one
16
+ - Recommended book two
17
+ </section>
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Course Description
3
+ ---
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Course Goals
3
+ ---
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Grading Criteria
3
+ ---
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Grading Policy
3
+ ---
@@ -0,0 +1,3 @@
1
+ ---
2
+ title: Late Work
3
+ ---