coursegen 0.8.3 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/pr.yml +19 -0
- data/.gitignore +3 -0
- data/Gemfile.lock +60 -35
- data/README.md +285 -69
- data/Rakefile +10 -1
- data/coursegen.gemspec +26 -26
- data/lib/coursegen.rb +5 -2
- data/lib/coursegen/cli.rb +49 -14
- data/lib/coursegen/course/data/citem.rb +10 -1
- data/lib/coursegen/course/data/data_adaptor.rb +16 -6
- data/lib/coursegen/course/data/section.rb +1 -1
- data/lib/coursegen/course/helpers/bootstrap_markup.rb +15 -15
- data/lib/coursegen/course/helpers/content_helpers.rb +86 -71
- data/lib/coursegen/course/helpers/formatting_helpers.rb +6 -10
- data/lib/coursegen/course/helpers/ical_feed_helpers.rb +2 -1
- data/lib/coursegen/course/helpers/lecture_helpers.rb +3 -2
- data/lib/coursegen/course/helpers/list_of.rb +40 -20
- data/lib/coursegen/course/helpers/list_of_helpers.rb +20 -14
- data/lib/coursegen/course/helpers/logging_helpers.rb +13 -12
- data/lib/coursegen/course/helpers/navigation_helpers.rb +62 -23
- data/lib/coursegen/course/helpers/sidebar_helpers.rb +19 -18
- data/lib/coursegen/course/helpers/table_helpers.rb +5 -4
- data/lib/coursegen/course/schedule/scheduler.rb +52 -19
- data/lib/coursegen/templates.rb +30 -23
- data/lib/coursegen/version.rb +3 -1
- data/spec/lectures_spec.rb +60 -50
- data/spec/play_spec.rb +24 -12
- data/spec/scheduler_spec.rb +87 -27
- data/tech_debt.md +5 -0
- data/templates/Rules +14 -19
- data/templates/cg_config.rb +105 -21
- data/templates/content/bootstrap/css/custom.css +87 -151
- data/templates/content/bootstrap/css/full-width-pics.css +8 -64
- data/templates/content/bootstrap/css/postit.css +7 -0
- data/templates/content/bootstrap/css/toasty.css +3 -0
- data/templates/content/content/index.md.erb +1 -1
- data/templates/content/content/intro/course_toc.md.erb +0 -1
- data/templates/content/content/intro/welcome.md.erb +1 -3
- data/templates/content/content/lectures/part1/02_here_we_go.md.erb +22 -1
- data/templates/content/content/lectures/part2/01_start_part2.md.erb +2 -1
- data/templates/content/content/lectures/part2/02_continue_part2.md.erb +3 -2
- data/templates/layouts/banner.html.erb +4 -4
- data/templates/layouts/body_footer.html +3 -4
- data/templates/layouts/body_header.html.erb +25 -7
- data/templates/layouts/bottom_includes.html.erb +21 -10
- data/templates/layouts/course.html.erb +7 -21
- data/templates/layouts/helpful_box.html +1 -1
- data/templates/layouts/nav-menus.html.erb +16 -36
- data/templates/layouts/sidebar.html.erb +9 -8
- data/templates/layouts/slides.html.erb +69 -0
- data/templates/layouts/top_includes.html.erb +24 -23
- metadata +32 -24
- data/.DS_Store +0 -0
- data/.vscode/settings.json +0 -2
- data/templates/.DS_Store +0 -0
- data/templates/Guardfile +0 -9
- data/templates/content/bootstrap/css/tipuesearch.css +0 -163
- data/templates/content/bootstrap/js/tipuesearch.js +0 -379
- data/templates/content/bootstrap/js/tipuesearch.min.js +0 -12
- data/templates/content/bootstrap/js/tipuesearch_content.js +0 -13
- data/templates/content/bootstrap/js/tipuesearch_set.js +0 -23
- data/templates/layouts/main_navbar.html.erb +0 -21
@@ -1,21 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# FormattingHelpers is used to format content.
|
2
2
|
module FormattingHelpers
|
3
|
-
|
4
3
|
def list_begin
|
5
|
-
|
4
|
+
'<dl class="dl-horizontal" style="font-size: 125%;">'
|
6
5
|
end
|
7
6
|
|
8
7
|
def list_end
|
9
|
-
|
8
|
+
'</dd></dl>'
|
10
9
|
end
|
11
10
|
|
12
|
-
def le
|
13
|
-
str =
|
14
|
-
|
15
|
-
str += "</dd><br/>"
|
16
|
-
end
|
11
|
+
def le(name, first_entry = false)
|
12
|
+
str = ''
|
13
|
+
str += '</dd><br/>' unless first_entry
|
17
14
|
str += "<dt>#{name}</dt><dd>"
|
18
15
|
str
|
19
16
|
end
|
20
|
-
|
21
17
|
end
|
@@ -1,26 +1,33 @@
|
|
1
|
+
# Class ListOf represents a lecture table.
|
1
2
|
class ListOf
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
|
15
|
-
|
3
|
+
# Initialize creates an instance of ListOf.
|
4
|
+
#
|
5
|
+
# source: name of a section as a string
|
6
|
+
# rows: array with one or more of:
|
7
|
+
# "pages"
|
8
|
+
# "subsections"
|
9
|
+
# subsections: array with one or more strings corresponding to subsection
|
10
|
+
# string in an item
|
11
|
+
# e.g. "/content/topics/arch/"
|
12
|
+
# cols: array with one or more of:
|
13
|
+
# :date
|
14
|
+
# :number
|
15
|
+
# :title
|
16
|
+
# :homeworks
|
17
|
+
# :lectref
|
18
|
+
# :readings
|
19
|
+
# items: refers to nanoc's @items (temp hack!)
|
20
|
+
def initialize(markup_adaptor, data_adaptor, rows, cols, subsections, items, headers)
|
16
21
|
@mark = markup_adaptor
|
17
22
|
@rows = rows
|
18
23
|
@cols = cols
|
19
24
|
@data = data_adaptor
|
20
25
|
@subsections = subsections
|
21
26
|
@items = items
|
27
|
+
@headers = headers
|
22
28
|
end
|
23
29
|
|
30
|
+
# Render renders the underlying lecture table.
|
24
31
|
def render
|
25
32
|
@mark.table_begin
|
26
33
|
generate_headers
|
@@ -36,7 +43,7 @@ class ListOf
|
|
36
43
|
|
37
44
|
@cols.each do |col|
|
38
45
|
@mark.header_begin
|
39
|
-
@mark.header_content(@data.column_name(col))
|
46
|
+
@mark.header_content(@headers[col] || @data.column_name(col))
|
40
47
|
@mark.header_end
|
41
48
|
end
|
42
49
|
|
@@ -46,6 +53,7 @@ class ListOf
|
|
46
53
|
def generate_rows
|
47
54
|
@data.rows do |row_id|
|
48
55
|
next unless include_row?(row_id)
|
56
|
+
|
49
57
|
if subsection_hdr?(row_id)
|
50
58
|
generate_summary_row(row_id)
|
51
59
|
else
|
@@ -73,11 +81,23 @@ class ListOf
|
|
73
81
|
end
|
74
82
|
|
75
83
|
def cell_content_string(row_id, col_selector, detail:)
|
76
|
-
if
|
84
|
+
if col_selector == :title && detail
|
77
85
|
nitem = @items[row_id.identifier]
|
78
86
|
link_to_unless_current(nitem[:title], nitem)
|
79
|
-
elsif
|
80
|
-
@data.cell_value(row_id,
|
87
|
+
elsif col_selector == :hwref
|
88
|
+
tag_value = @data.cell_value(row_id, :hwref)
|
89
|
+
tag_value.nil? ? "n/a" : link_to_section(:homework, tag_value.to_sym)
|
90
|
+
elsif col_selector == :lectref
|
91
|
+
tag_value = @data.cell_value(row_id, :lectref)
|
92
|
+
if tag_value.nil?
|
93
|
+
"n/a"
|
94
|
+
else
|
95
|
+
atag_values = tag_value.split(" ")
|
96
|
+
atag_links = atag_values.map {|tv| link_to_lecture(tv.to_sym)}
|
97
|
+
atag_links.join(", ")
|
98
|
+
end
|
99
|
+
elsif col_selector == :date
|
100
|
+
@data.cell_value(row_id, col_selector).strftime('%b %-d')
|
81
101
|
else
|
82
102
|
@data.cell_value(row_id, col_selector).to_s
|
83
103
|
end
|
@@ -92,10 +112,10 @@ class ListOf
|
|
92
112
|
end
|
93
113
|
|
94
114
|
def include_by_subsection_path?(row_id)
|
95
|
-
@subsections.
|
115
|
+
@subsections.empty? || @subsections.include?(row_id.subsection)
|
96
116
|
end
|
97
117
|
|
98
118
|
def subsection_hdr?(row_id)
|
99
|
-
row_id.type ==
|
119
|
+
row_id.type == 'subsection'
|
100
120
|
end
|
101
121
|
end
|
@@ -1,20 +1,26 @@
|
|
1
|
+
# ListOfHelpers is used to create a lecture table.
|
1
2
|
module ListOfHelpers
|
2
|
-
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
|
14
|
-
|
3
|
+
# List_of creates and renders a lecture table based on the given info.
|
4
|
+
#
|
5
|
+
# source: name of a section as a string
|
6
|
+
# rows: array with one or more of:
|
7
|
+
# "pages"
|
8
|
+
# "subsections"
|
9
|
+
# cols: array with one or more of:
|
10
|
+
# :date
|
11
|
+
# :number
|
12
|
+
# :title
|
13
|
+
# :homeworks
|
14
|
+
# :assigned
|
15
|
+
# :lectref
|
16
|
+
# subsections: array with one or more strings corresponding to subsection
|
17
|
+
# string in an item
|
18
|
+
# e.g. "/content/topics/arch/"
|
19
|
+
# items: refers to nanoc's @items (temp hack!)
|
20
|
+
def list_of(source:, rows:, cols:, headers: {}, subsections: [], items:)
|
15
21
|
markup_adaptor = BootstrapMarkup.new
|
16
22
|
data_adaptor = DataAdaptor.new(source)
|
17
|
-
lecture_table_builder = ListOf.new(markup_adaptor, data_adaptor, rows, cols, subsections, items)
|
23
|
+
lecture_table_builder = ListOf.new(markup_adaptor, data_adaptor, rows, cols, subsections, items, headers)
|
18
24
|
lecture_table_builder.render
|
19
25
|
end
|
20
26
|
end
|
@@ -1,14 +1,15 @@
|
|
1
|
+
# LoggingHelpers is used to debug log items.
|
1
2
|
module LoggingHelpers
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
def log_item_info
|
4
|
+
puts
|
5
|
+
puts "*** ITEM Info: #{item.identifier}"
|
6
|
+
puts "Parent = #{item.parent}"
|
7
|
+
puts "Children = #{item.children}"
|
8
|
+
puts "Reps = #{item.reps}"
|
9
|
+
pp item.attributes
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
12
|
+
def compiling(item)
|
13
|
+
# puts "* compiling #{item[:title]}"
|
14
|
+
end
|
15
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# NavigationHelpers provides methods for navigating the course.
|
2
|
+
# This is used in the nav bar along the top of the page.
|
3
|
+
# Called by main_navbar.html.erb
|
2
4
|
module NavigationHelpers
|
3
|
-
def link_to_lecture
|
5
|
+
def link_to_lecture(item_symbol)
|
4
6
|
link_to_section :lectures, item_symbol
|
5
7
|
end
|
6
8
|
|
@@ -10,73 +12,110 @@ module NavigationHelpers
|
|
10
12
|
link_to(the_citem.title, the_item)
|
11
13
|
end
|
12
14
|
|
13
|
-
def link_to_topic
|
15
|
+
def link_to_topic(item_symbol)
|
14
16
|
link_to_section :topics, item_symbol
|
15
17
|
end
|
16
18
|
|
17
|
-
def link_to_background
|
19
|
+
def link_to_background(item_symbol)
|
18
20
|
link_to_section :background, item_symbol
|
19
21
|
end
|
20
22
|
|
21
|
-
def link_to_cribsheet
|
23
|
+
def link_to_cribsheet(item_symbol)
|
22
24
|
link_to_section :cribsheets, item_symbol
|
23
25
|
end
|
24
26
|
|
25
|
-
def link_to_intro
|
27
|
+
def link_to_intro(item_symbol)
|
26
28
|
link_to_section :intro, item_symbol
|
27
29
|
end
|
28
30
|
|
29
|
-
def link_to_incubator
|
31
|
+
def link_to_incubator(item_symbol)
|
30
32
|
link_to_section :incubator, item_symbol
|
31
33
|
end
|
32
34
|
|
33
|
-
def link_to_lab
|
35
|
+
def link_to_lab(item_symbol)
|
34
36
|
link_to_section :lab, item_symbol
|
35
37
|
end
|
36
38
|
|
37
|
-
def link_to_pa
|
39
|
+
def link_to_pa(item_symbol)
|
38
40
|
link_to_section :pa, item_symbol
|
39
41
|
end
|
40
42
|
|
41
|
-
def link_to_page
|
43
|
+
def link_to_page(item_symbol)
|
42
44
|
link_to_section :pages, item_symbol
|
43
45
|
end
|
44
46
|
|
45
|
-
def link_to_project
|
47
|
+
def link_to_project(item_symbol)
|
46
48
|
link_to_section :projects, item_symbol
|
47
49
|
end
|
48
50
|
|
49
|
-
def link_to_section
|
51
|
+
def link_to_section(section_symbol, item_symbol)
|
50
52
|
the_item = @items[lookup_nitem(section_symbol.to_s, item_symbol.to_s).identifier]
|
51
53
|
link_to(the_item[:title], the_item)
|
52
54
|
end
|
53
55
|
|
54
|
-
def link_to_next
|
56
|
+
def link_to_next(toc, item, attrs = {})
|
55
57
|
next_nitem = toc.find_next_forn(item).identifier
|
56
|
-
|
58
|
+
link_to 'next', @items[next_nitem].path, attrs
|
57
59
|
end
|
58
60
|
|
59
|
-
def link_to_prev
|
61
|
+
def link_to_prev(toc, item, attrs = {})
|
60
62
|
prev_nitem = toc.find_previous_forn(item).identifier
|
61
|
-
|
63
|
+
link_to 'previous', @items[prev_nitem].path, attrs
|
62
64
|
end
|
63
65
|
|
64
|
-
def link_to_inclusion
|
66
|
+
def link_to_inclusion(item)
|
65
67
|
inclusion = Toc.instance.lookup_inclusion(item)
|
66
68
|
if inclusion.nil?
|
67
|
-
|
69
|
+
'(never included)'
|
68
70
|
else
|
69
71
|
" (#{inclusion.identifier})"
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
|
75
|
+
# def link_to_slides_2
|
76
|
+
# '<a
|
77
|
+
# class="btn btn-sm btn-primary"
|
78
|
+
# href="./slides.html"
|
79
|
+
# title="slides">
|
80
|
+
# <i class="fas fa-chalkboard-teacher"></i> Slides
|
81
|
+
# </a>'
|
82
|
+
# end
|
74
83
|
|
75
|
-
def
|
76
|
-
"
|
84
|
+
def link_to_slides(attrs = {})
|
85
|
+
link_to("slides", "./slides.html", attrs)
|
77
86
|
end
|
78
87
|
|
79
|
-
def
|
80
|
-
|
88
|
+
# def link_to_homework_2(citem)
|
89
|
+
# unless citem.hwref.nil?
|
90
|
+
# "<div class=\"btn btn-sm btn-primary\">" +
|
91
|
+
# "<i class=\"fad fa-backpack\"></i>" +
|
92
|
+
# link_to_section(:homework, citem.hwref.to_sym) +
|
93
|
+
# "</div>"
|
94
|
+
# end
|
95
|
+
# end
|
96
|
+
|
97
|
+
def link_to_homework(citem, attrs = {})
|
98
|
+
return "" if citem.hwref.nil?
|
99
|
+
|
100
|
+
the_item = @items[lookup_nitem("homework", citem.hwref).identifier]
|
101
|
+
# link_to(the_item[:title], the_item, attrs)
|
102
|
+
link_to("homework", the_item, attrs)
|
81
103
|
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
# def nav_markup2(text, path, icon, tooltip = '')
|
108
|
+
# "<a class=\"nav-btn btn btn-mini\" href=\"#{path}\">
|
109
|
+
# <i class=\"#{icon}\" rel=\"tooltip\" title=\"#{tooltip}\"></i>#{text}</a>"
|
110
|
+
# end
|
111
|
+
|
112
|
+
def nav_markup(path, text)
|
113
|
+
"<a class=\"btn btn-sm btn-primary\" href=\"#{path}\">#{text}</a>"
|
114
|
+
end
|
115
|
+
|
116
|
+
# def nav_markup_3(path, text, fontawesome, tooltip = '')
|
117
|
+
# "<a class=\"btn btn-sm btn-primary\" href=\"#{path}\">" +
|
118
|
+
# "<i class=\"#{fontawesome}\"></i>" +
|
119
|
+
# "#{text}</a>"
|
120
|
+
# end
|
82
121
|
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
#
|
1
|
+
# SidebarHelpers is a set of helpers to display the navigation sidebar.
|
2
2
|
module SidebarHelpers
|
3
|
-
def section_helper
|
3
|
+
def section_helper(title: nil, selector: nil)
|
4
4
|
sect = Toc.instance.section(selector)
|
5
5
|
@sect_def = Toc.instance.section_def(selector)
|
6
6
|
str = "<li>
|
7
7
|
<label class=\"tree-toggler level1\">
|
8
8
|
#{collapsed_indicator(sect.collapsed?)}
|
9
9
|
#{title}
|
10
|
-
</label>
|
11
|
-
|
12
|
-
|
10
|
+
</label>
|
11
|
+
#{sect.has_subsections? ? nested_section(sect) : flat_section(sect)}
|
12
|
+
</li>"
|
13
13
|
end
|
14
14
|
|
15
|
-
def nested_section
|
16
|
-
sect.subsections.reduce(
|
15
|
+
def nested_section(sect)
|
16
|
+
sect.subsections.reduce('') { |acc, subs| acc + subsection_body(subs) }
|
17
17
|
end
|
18
18
|
|
19
|
-
def subsection_body
|
19
|
+
def subsection_body(sect)
|
20
20
|
"<ul class=\"tree\">
|
21
21
|
<li>
|
22
22
|
<label class=\"tree-toggler level2\">
|
@@ -33,34 +33,35 @@ module SidebarHelpers
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def subsection(subsect, collapsed)
|
36
|
-
disp_clause = collapsed ?
|
36
|
+
disp_clause = collapsed ? 'display: none' : 'display: block'
|
37
37
|
str = "<ul class=\"tree\" style=\"#{disp_clause}\">"
|
38
38
|
str = subsect.children.reduce(str) { |acc, item| acc + subsection_item_link(item) }
|
39
|
-
str +
|
39
|
+
str + '</ul>'
|
40
40
|
end
|
41
41
|
|
42
|
-
def subsection_item_link
|
42
|
+
def subsection_item_link(tree_node)
|
43
43
|
bullet = @sect_def.options[:bullet]
|
44
44
|
link_path = @items[tree_node.content.identifier].path
|
45
45
|
"<li class=\"#{tree_node.content.css_class}\">#{icon_markup(bullet)}<a href=\"#{link_path}\">#{tree_node.content.title}</a></li>"
|
46
46
|
end
|
47
47
|
|
48
|
-
def flat_section
|
49
|
-
disp_clause = sect.collapsed? ?
|
48
|
+
def flat_section(sect)
|
49
|
+
disp_clause = sect.collapsed? ? 'display: none' : 'display: block'
|
50
50
|
str = "<ul class=\"tree\" style=\"#{disp_clause}\">"
|
51
51
|
str = sect.reduce(str) { |acc, item| acc + flat_section_item_link(item) }
|
52
|
-
str +
|
52
|
+
str + '</ul>'
|
53
53
|
end
|
54
54
|
|
55
|
-
def flat_section_item_link
|
55
|
+
def flat_section_item_link(citem)
|
56
56
|
bullet = @sect_def.options[:bullet]
|
57
57
|
path = @items[citem.identifier].path
|
58
58
|
"<li class=\"#{citem.css_class}\">#{icon_markup(bullet)}<a href=\"#{path}\">#{citem.title}</a></li>"
|
59
59
|
end
|
60
60
|
|
61
|
-
def icon_markup
|
62
|
-
return
|
63
|
-
|
61
|
+
def icon_markup(icon_type)
|
62
|
+
return '' if icon_type.nil?
|
63
|
+
|
64
|
+
css_class = { dash: 'glyphicon-minus', star: 'glyphicon-star', plus: 'glyphicon-plus-sign', minus: 'glyphicon-minus-sign' }.fetch(icon_type)
|
64
65
|
"<span class=\"glyphicon #{css_class}\" style=#{STYLING_CONFIG[:bullet_style]}></span>"
|
65
66
|
end
|
66
67
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# Class TableHelper provides methods for creating a table.
|
1
2
|
class TableHelper
|
2
3
|
def initialize(*property)
|
3
4
|
@prop = property
|
@@ -5,9 +6,9 @@ class TableHelper
|
|
5
6
|
end
|
6
7
|
|
7
8
|
def headers(*labels)
|
8
|
-
css_style =
|
9
|
-
css_style +=
|
10
|
-
css_style +=
|
9
|
+
css_style = ''
|
10
|
+
css_style += ' table-condensed' if @prop.include? :normal
|
11
|
+
css_style += ' table-bordered' if @prop.include? :bordered
|
11
12
|
@bm.table_begin(css_style)
|
12
13
|
@bm.headers_begin
|
13
14
|
labels.each do |h|
|
@@ -28,7 +29,7 @@ class TableHelper
|
|
28
29
|
@bm.row_end
|
29
30
|
end
|
30
31
|
|
31
|
-
def render
|
32
|
+
def render
|
32
33
|
@bm.table_end
|
33
34
|
@bm.render
|
34
35
|
end
|