coursegen 0.3.1 → 0.4.2
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 +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +50 -46
- data/coursegen.gemspec +2 -3
- data/deleteme.rb +2 -0
- data/lib/coursegen/cli.rb +5 -3
- data/lib/coursegen/course/data/citem.rb +26 -27
- data/lib/coursegen/course/data/data_adaptor.rb +5 -1
- data/lib/coursegen/course/data/lectures.rb +84 -72
- data/lib/coursegen/course/data/section.rb +53 -53
- data/lib/coursegen/course/data/section_def.rb +6 -6
- data/lib/coursegen/course/data/toc.rb +1 -2
- data/lib/coursegen/course/helpers/bootstrap_markup.rb +3 -2
- data/lib/coursegen/course/helpers/content_helpers.rb +121 -75
- data/lib/coursegen/course/helpers/ical_feed_helpers.rb +1 -1
- data/lib/coursegen/course/helpers/list_of.rb +12 -12
- data/lib/coursegen/course/helpers/list_of_helpers.rb +2 -2
- data/lib/coursegen/course/helpers/navigation_helpers.rb +35 -26
- data/lib/coursegen/course/helpers/sidebar_helpers.rb +12 -16
- data/lib/coursegen/course/lib/ical_adaptor.rb +3 -5
- data/lib/coursegen/course/lib/search_data_generator.rb +3 -4
- data/lib/coursegen/course/schedule/schedule_def.rb +12 -11
- data/lib/coursegen/course/schedule/schedule_feed.rb +3 -1
- data/lib/coursegen/course/schedule/scheduler.rb +20 -13
- data/lib/coursegen/version.rb +1 -1
- data/lib/coursegen.rb +10 -9
- data/spec/play_spec.rb +15 -19
- data/spec/scheduler_spec.rb +59 -63
- data/spec/spec_helper.rb +1 -1
- data/spec/toc_spec.rb +69 -71
- data/tech_debt.md +0 -3
- data/templates/Guardfile +2 -2
- data/templates/body_footer.html +8 -0
- data/templates/body_header.html.erb +6 -0
- data/templates/cg_config.rb +8 -7
- data/templates/content/bootstrap/css/custom.css +25 -8
- data/templates/content/content/intro/course_toc.md.erb +1 -1
- data/templates/course.html +59 -0
- data/templates/helpful_box.html +3 -0
- data/templates/layouts/body_header.html.erb +1 -1
- data/templates/layouts/course.html +3 -2
- data/templates/layouts/main_navbar.html.erb +1 -1
- data/templates/main_navbar.html.erb +21 -0
- metadata +22 -16
@@ -1,10 +1,10 @@
|
|
1
1
|
# Sidebar configuration
|
2
2
|
|
3
3
|
class SectionDef
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
attr_accessor :title, :selector, :options
|
5
|
+
def initialize(title, selector, options = {})
|
6
|
+
@title = title
|
7
|
+
@selector = selector
|
8
|
+
@options = options
|
9
|
+
end
|
10
10
|
end
|
@@ -2,6 +2,7 @@ class BootstrapMarkup
|
|
2
2
|
def initialize
|
3
3
|
@str = ""
|
4
4
|
end
|
5
|
+
|
5
6
|
def table_begin(css_class="table-condensed")
|
6
7
|
@str << "<table class=\"table #{css_class}\">"
|
7
8
|
end
|
@@ -27,7 +28,7 @@ class BootstrapMarkup
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def header_content(str)
|
30
|
-
@str << str
|
31
|
+
@str << str unless str.nil?
|
31
32
|
end
|
32
33
|
|
33
34
|
def row_begin
|
@@ -61,4 +62,4 @@ class BootstrapMarkup
|
|
61
62
|
def render
|
62
63
|
@str
|
63
64
|
end
|
64
|
-
end
|
65
|
+
end
|
@@ -1,9 +1,23 @@
|
|
1
|
+
# Helpers to be used to annotate content
|
1
2
|
module ContentHelpers
|
2
|
-
|
3
3
|
def include_topic item_symbol
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
incorporated_topic = lookup_nitem("topics", item_symbol.to_s)
|
5
|
+
items[incorporated_topic.identifier.to_s].compiled_content
|
6
|
+
end
|
7
|
+
|
8
|
+
def include_page item_symbol
|
9
|
+
incorporated_topic = lookup_nitem("pages", item_symbol.to_s)
|
10
|
+
items[incorporated_topic.identifier.to_s].compiled_content
|
11
|
+
end
|
12
|
+
|
13
|
+
def include_background item_symbol
|
14
|
+
incorporated_topic = lookup_nitem("background", item_symbol.to_s)
|
15
|
+
items[incorporated_topic.identifier.to_s].compiled_content
|
16
|
+
end
|
17
|
+
|
18
|
+
def include_intro item_symbol
|
19
|
+
incorporated_topic = lookup_nitem("intro", item_symbol.to_s)
|
20
|
+
items[incorporated_topic.identifier.to_s].compiled_content
|
7
21
|
end
|
8
22
|
|
9
23
|
def include_from_section sect_symbol, item_symbol
|
@@ -13,44 +27,76 @@ module ContentHelpers
|
|
13
27
|
end
|
14
28
|
|
15
29
|
def lookup_nitem the_sect, short_name
|
16
|
-
|
30
|
+
Toc.instance.lookup_citem(the_sect, short_name).nitem
|
17
31
|
end
|
18
32
|
|
19
33
|
def link_to_doc label, file_name
|
20
|
-
|
34
|
+
"<a href=\"/docs/#{file_name}\">#{label}</a>"
|
21
35
|
end
|
22
36
|
|
23
37
|
def toc_link_to item
|
24
|
-
|
38
|
+
link_to_unless_current item[:title], item
|
25
39
|
end
|
26
40
|
|
27
41
|
def bold_red string
|
28
|
-
|
42
|
+
"<span style=\"color: red; font-style: italic;\">#{string}</span>"
|
29
43
|
end
|
30
44
|
|
31
45
|
def italic_red string
|
32
|
-
|
46
|
+
" *#{string}*{: style=\"color: red\"} "
|
33
47
|
end
|
34
48
|
|
35
49
|
def ir string; italic_red(string); end
|
36
50
|
|
37
|
-
def callout title, body
|
38
|
-
|
51
|
+
def callout title, body
|
52
|
+
<<-HTMLSTRING
|
39
53
|
<div class="well well-sm">
|
40
|
-
<span class="label label-primary">#{title}</span>#{body}
|
54
|
+
<span class="themebg label label-primary">#{title}</span>#{body}
|
41
55
|
</div>
|
42
56
|
HTMLSTRING
|
43
57
|
end
|
44
58
|
|
59
|
+
def textbadge text, tooltip
|
60
|
+
%(<span class="label label-info" data-toggle="tooltip" data-placement="top" title="#{tooltip}">#{text}</span>)
|
61
|
+
end
|
62
|
+
|
63
|
+
def iconbadge icon, tooltip
|
64
|
+
%(<span class="glyphicon glyphicon-#{icon} themefg" data-toggle="tooltip" data-placement="top" title="#{tooltip}"></span>)
|
65
|
+
end
|
66
|
+
|
67
|
+
def pdfbadge
|
68
|
+
iconbadge("file", "Submit as 1 page pdf, include name and homework #")
|
69
|
+
end
|
70
|
+
|
71
|
+
def codebadge
|
72
|
+
iconbadge("cloud", "Work on code in your portfolio")
|
73
|
+
end
|
74
|
+
|
75
|
+
def cloudbadge
|
76
|
+
codebadge
|
77
|
+
end
|
78
|
+
|
79
|
+
def zipbadge
|
80
|
+
iconbadge("briefcase", "Submit code as a .zip file")
|
81
|
+
end
|
82
|
+
|
83
|
+
def partbadge
|
84
|
+
iconbadge("check", "Graded for participation only")
|
85
|
+
end
|
86
|
+
|
87
|
+
def timebadge
|
88
|
+
iconbadge("time", "Must be submitted first thing on day of class")
|
89
|
+
end
|
90
|
+
|
45
91
|
def include_image_old string, extra_class: nil
|
46
92
|
css_class = "img-responsive"
|
47
|
-
css_class += " img-"+extra_class unless extra_class.nil?
|
93
|
+
css_class += " img-" + extra_class unless extra_class.nil?
|
48
94
|
|
49
|
-
"<img src=\"/content/images/#{string}\" class=\"%s\" />"
|
95
|
+
"<img src=\"/content/images/#{string}\" class=\"%s\" />" % css_class
|
50
96
|
end
|
51
97
|
|
52
98
|
def include_image filename_string, width: 8
|
53
|
-
|
99
|
+
<<-HTMLSTRING
|
54
100
|
<div class="row">
|
55
101
|
<div class="col-md-offset-2 col-md-#{width}">
|
56
102
|
<img src="#{filename_string}" class="img-responsive img-thumbnail" />
|
@@ -59,28 +105,36 @@ HTMLSTRING
|
|
59
105
|
HTMLSTRING
|
60
106
|
end
|
61
107
|
|
62
|
-
def important string=":"
|
63
|
-
|
108
|
+
def important string = ":"
|
109
|
+
"**Important#{string}**{: style=\"color: red\"}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def nb string = ""
|
113
|
+
"*NB: #{string}*{: style=\"color: green\"}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def tbd string = ""
|
117
|
+
"*[TO BE DETERMINED#{string}]*{: style=\"color: red\"}"
|
64
118
|
end
|
65
119
|
|
66
|
-
def
|
67
|
-
|
120
|
+
def deliverable string, append=""
|
121
|
+
"*Deliverable:*{: style=\"color: red\"} #{string + append} "
|
68
122
|
end
|
69
123
|
|
70
|
-
def
|
71
|
-
|
124
|
+
def deliverable_po(string)
|
125
|
+
deliverable(string, " *(graded for participation only)*")
|
72
126
|
end
|
73
127
|
|
74
|
-
def
|
75
|
-
|
128
|
+
def deliverable_popdf(string)
|
129
|
+
deliverable(string, " *(pdf with name and hw number, graded for participation only)*")
|
76
130
|
end
|
77
131
|
|
78
132
|
def team_deliverable string
|
79
|
-
|
133
|
+
"*Team Deliverable:*{: style=\"color: red\"} *#{string}*"
|
80
134
|
end
|
81
135
|
|
82
136
|
def discussion string
|
83
|
-
|
137
|
+
"*Discussion:*{: style=\"color: blue\"} *#{string}*"
|
84
138
|
end
|
85
139
|
|
86
140
|
def homework_hdr
|
@@ -88,90 +142,82 @@ HTMLSTRING
|
|
88
142
|
end
|
89
143
|
|
90
144
|
def carousel(filenames)
|
91
|
-
body =
|
92
|
-
<div class="carousel-inner" style="margin: 20px; "
|
145
|
+
body = %(<div id="myCarousel" class="carousel slide" style="width: 500px; margin: 0 auto;">
|
146
|
+
<div class="carousel-inner" style="margin: 20px; ">)
|
93
147
|
counter = 0
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
148
|
+
filenames.each do |nam|
|
149
|
+
body << counter == 0 ? %(div class="item active">) : body << %(<div class="item">~
|
150
|
+
body << %~<img src=")
|
151
|
+
body << "/content/images/#{nam}"
|
152
|
+
body << %(" class="img-polaroid" alt=""></div>)
|
153
|
+
counter += 1
|
100
154
|
end
|
101
|
-
body <<
|
102
|
-
body << "/content/images/#{nam}"
|
103
|
-
body << %~" class="img-polaroid" alt=""></div>~
|
104
|
-
counter += 1
|
105
|
-
end
|
106
|
-
body << %~</div> <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
|
155
|
+
body << %(</div> <a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
|
107
156
|
<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
|
108
|
-
</div
|
157
|
+
</div>)
|
109
158
|
body
|
110
159
|
end
|
111
160
|
|
112
161
|
def carousel_new(filenames)
|
113
|
-
carousel_work(filenames.map {|filename| "/content/topics/images/"+filename })
|
114
|
-
end
|
115
|
-
|
116
|
-
def carousel_work(filenames)
|
117
|
-
body = %~<div id="myCarousel" class="carousel slide" style="width: 500px; margin: 0 auto;">
|
118
|
-
<div class="carousel-inner" style="margin: 20px; ">~
|
119
|
-
counter = 0
|
120
|
-
filenames.each do
|
121
|
-
|nam|
|
122
|
-
if counter == 0
|
123
|
-
body << %~<div class="item active">~
|
124
|
-
else
|
125
|
-
body << %~<div class="item">~
|
126
|
-
end
|
127
|
-
body << %~<img src="~
|
128
|
-
body << nam
|
129
|
-
body << %~" class="img-polaroid" alt=""></div>~
|
130
|
-
counter += 1
|
162
|
+
carousel_work(filenames.map {|filename| "/content/topics/images/" + filename })
|
131
163
|
end
|
132
|
-
|
133
|
-
|
134
|
-
|
164
|
+
|
165
|
+
def carousel_work(filenames)
|
166
|
+
body = %(<div id="myCarousel" class="carousel slide" data-ride="carousel" style="width: 500px; margin: 0 auto;">
|
167
|
+
<div class="carousel-inner" role="listbox" style="margin: 20px; ">)
|
168
|
+
counter = 0
|
169
|
+
filenames.each do |nam|
|
170
|
+
ci = counter == 0 ? %(<div class="carousel-item active">) : %(<div class="carousel-item">)
|
171
|
+
puts "****** #{ci}"
|
172
|
+
body << ci
|
173
|
+
body << %(<img src=")
|
174
|
+
body << nam
|
175
|
+
body << %(" class="d-block img-fluid"></div>)
|
176
|
+
counter += 1
|
177
|
+
end
|
178
|
+
body << %(</div> <a class="carousel-control-prev" role="button" href="#myCarousel" data-slide="prev">‹</a>
|
179
|
+
<a class="carousel-control-next" role="button" href="#myCarousel" data-slide="next">›</a>
|
180
|
+
</div>)
|
135
181
|
body
|
136
182
|
end
|
137
183
|
|
138
|
-
|
139
184
|
def ruby_begin
|
140
|
-
|
185
|
+
"\n~~~~~~"
|
141
186
|
end
|
142
187
|
|
143
188
|
def ruby_end
|
144
|
-
|
189
|
+
"~~~~~~\n {: .language-ruby}"
|
145
190
|
end
|
146
191
|
|
147
|
-
def ruby_string
|
148
|
-
|
192
|
+
def ruby_string str
|
193
|
+
ruby_begin + "\n" + str + "\n" + ruby_end
|
149
194
|
end
|
150
195
|
|
151
196
|
def include_ruby name
|
152
|
-
filename = Dir.pwd+"/content/content/topics/scripts/"+name.to_s+".rb"
|
197
|
+
filename = Dir.pwd + "/content/content/topics/scripts/" + name.to_s + ".rb"
|
153
198
|
filecontents = File.new(filename).read
|
154
199
|
ruby_string filecontents
|
155
200
|
end
|
156
201
|
|
157
202
|
def code_begin
|
158
|
-
|
203
|
+
"\n~~~~~~"
|
159
204
|
end
|
160
205
|
|
161
|
-
def code_end
|
162
|
-
|
206
|
+
def code_end lang=""
|
207
|
+
str = "~~~~~~\n"
|
208
|
+
if ["ruby", "css", "java", "html"].include? lang
|
209
|
+
str += "{: .language-#{lang}}"
|
210
|
+
end
|
211
|
+
str
|
163
212
|
end
|
164
213
|
|
165
|
-
def code_string
|
214
|
+
def code_string str
|
166
215
|
code_begin + "\n" + str + code_end
|
167
216
|
end
|
168
217
|
|
169
218
|
def include_code name
|
170
|
-
filename = Dir.pwd+"/content/content/topics/scripts/"+name
|
219
|
+
filename = Dir.pwd + "/content/content/topics/scripts/" + name
|
171
220
|
filecontents = File.new(filename).read
|
172
221
|
code_string filecontents
|
173
222
|
end
|
174
|
-
|
175
|
-
|
176
|
-
|
177
223
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class ListOf
|
2
|
-
|
3
2
|
# source: name of a section as a string
|
4
3
|
# rows: array with one or more of:
|
5
4
|
# "pages"
|
@@ -11,13 +10,15 @@ class ListOf
|
|
11
10
|
# :number
|
12
11
|
# :title
|
13
12
|
# :homeworks
|
13
|
+
# items: refers to nanoc's @items (temp hack!)
|
14
14
|
|
15
|
-
def initialize(markup_adaptor, data_adaptor, rows, cols, subsections)
|
15
|
+
def initialize(markup_adaptor, data_adaptor, rows, cols, subsections, items)
|
16
16
|
@mark = markup_adaptor
|
17
17
|
@rows = rows
|
18
18
|
@cols = cols
|
19
19
|
@data = data_adaptor
|
20
20
|
@subsections = subsections
|
21
|
+
@items = items
|
21
22
|
end
|
22
23
|
|
23
24
|
def render
|
@@ -54,13 +55,13 @@ class ListOf
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def generate_detail_row(row_id)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
@mark.row_begin
|
59
|
+
@cols.each do |col_selector|
|
60
|
+
@mark.cell_begin
|
61
|
+
@mark.cell_content(cell_content_string(row_id, col_selector, detail: true))
|
62
|
+
@mark.cell_end
|
63
|
+
end
|
64
|
+
@mark.row_end
|
64
65
|
end
|
65
66
|
|
66
67
|
def generate_summary_row(row_id)
|
@@ -73,8 +74,8 @@ class ListOf
|
|
73
74
|
|
74
75
|
def cell_content_string(row_id, col_selector, detail:)
|
75
76
|
if (col_selector == :title && detail)
|
76
|
-
|
77
|
-
link_to_unless_current(
|
77
|
+
nitem = @items[row_id.identifier]
|
78
|
+
link_to_unless_current(nitem[:title], nitem)
|
78
79
|
elsif (col_selector == :date)
|
79
80
|
@data.cell_value(row_id, col_selector).strftime("%b %-d")
|
80
81
|
else
|
@@ -97,5 +98,4 @@ class ListOf
|
|
97
98
|
def subsection_hdr?(row_id)
|
98
99
|
row_id.type == "subsection"
|
99
100
|
end
|
100
|
-
|
101
101
|
end
|
@@ -10,10 +10,10 @@ module ListOfHelpers
|
|
10
10
|
# :title
|
11
11
|
# :homeworks
|
12
12
|
|
13
|
-
def list_of(source:, rows:, cols:, subsections: [])
|
13
|
+
def list_of(source:, rows:, cols:, subsections: [], items:)
|
14
14
|
markup_adaptor = BootstrapMarkup.new
|
15
15
|
data_adaptor = DataAdaptor.new(source)
|
16
|
-
lecture_table_builder = ListOf.new(markup_adaptor, data_adaptor, rows, cols, subsections)
|
16
|
+
lecture_table_builder = ListOf.new(markup_adaptor, data_adaptor, rows, cols, subsections, items)
|
17
17
|
lecture_table_builder.render
|
18
18
|
end
|
19
19
|
end
|
@@ -1,12 +1,13 @@
|
|
1
|
+
# Used in the nav bar along the top of the page. Called by main_navbar.html.erb
|
1
2
|
module NavigationHelpers
|
2
|
-
|
3
3
|
def link_to_lecture item_symbol
|
4
4
|
link_to_section :lectures, item_symbol
|
5
5
|
end
|
6
6
|
|
7
7
|
def link_to_next_lecture
|
8
|
-
|
9
|
-
|
8
|
+
the_citem = Toc.instance.find_next_forn(@item)
|
9
|
+
the_item = @items[the_citem.identifier]
|
10
|
+
link_to(the_citem.title, the_item)
|
10
11
|
end
|
11
12
|
|
12
13
|
def link_to_topic item_symbol
|
@@ -33,37 +34,45 @@ module NavigationHelpers
|
|
33
34
|
link_to_section :lab, item_symbol
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
+
def link_to_pa item_symbol
|
37
38
|
link_to_section :pa, item_symbol
|
38
39
|
end
|
39
40
|
|
41
|
+
def link_to_page item_symbol
|
42
|
+
link_to_section :pages, item_symbol
|
43
|
+
end
|
44
|
+
|
45
|
+
def link_to_project item_symbol
|
46
|
+
link_to_section :projects, item_symbol
|
47
|
+
end
|
48
|
+
|
40
49
|
def link_to_section section_symbol, item_symbol
|
41
|
-
|
42
|
-
#link_to_unless_current(the_item[:title], the_item.identifier)
|
50
|
+
the_item = @items[lookup_nitem(section_symbol.to_s, item_symbol.to_s).identifier]
|
43
51
|
link_to(the_item[:title], the_item)
|
44
|
-
|
45
|
-
|
46
|
-
def link_to_next toc, item
|
47
|
-
nav_markup "", toc.find_next_forn(item).nitem.path, "glyphicon glyphicon-chevron-right", "next page"
|
48
|
-
end
|
52
|
+
end
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
def link_to_next toc, item
|
55
|
+
next_nitem = toc.find_next_forn(item).identifier
|
56
|
+
nav_markup "", @items[next_nitem].path, "glyphicon glyphicon-arrow-right", "next page"
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
else
|
59
|
-
" (#{inclusion.identifier})"
|
60
|
-
end
|
61
|
-
end
|
59
|
+
def link_to_prev toc, item
|
60
|
+
prev_nitem = toc.find_previous_forn(item).identifier
|
61
|
+
nav_markup "", @items[prev_nitem].path, "glyphicon glyphicon-arrow-left", "previous page"
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
+
def link_to_inclusion item
|
65
|
+
inclusion = Toc.instance.lookup_inclusion(item)
|
66
|
+
if inclusion.nil?
|
67
|
+
"(never included)"
|
68
|
+
else
|
69
|
+
" (#{inclusion.identifier})"
|
70
|
+
end
|
71
|
+
end
|
64
72
|
|
65
|
-
|
66
|
-
"<a class=\"btn btn-mini\" href=\"#{path}\"><i class=\"#{icon}\" rel=\"tooltip\" title=\"#{tooltip}\"></i>#{text}</a>"
|
67
|
-
end
|
73
|
+
private
|
68
74
|
|
75
|
+
def nav_markup text, path, icon, tooltip=""
|
76
|
+
"<a class=\"nav-btn btn btn-mini\" href=\"#{path}\"><i class=\"#{icon}\" rel=\"tooltip\" title=\"#{tooltip}\"></i>#{text}</a>"
|
77
|
+
end
|
69
78
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
+
# Set of helpers to display the navigation sidebar
|
1
2
|
module SidebarHelpers
|
2
|
-
|
3
|
-
def section_helper title:nil, selector:nil
|
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>
|
@@ -8,12 +8,8 @@ module SidebarHelpers
|
|
8
8
|
#{collapsed_indicator(sect.collapsed?)}
|
9
9
|
#{title}
|
10
10
|
</label>"
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
str += flat_section(sect)
|
15
|
-
end
|
16
|
-
str += "</li>"
|
11
|
+
str += sect.has_subsections? ? nested_section(sect) : flat_section(sect)
|
12
|
+
str + "</li>"
|
17
13
|
end
|
18
14
|
|
19
15
|
def nested_section sect
|
@@ -36,28 +32,30 @@ module SidebarHelpers
|
|
36
32
|
icon_markup(coll ? :plus : :minus)
|
37
33
|
end
|
38
34
|
|
39
|
-
def subsection
|
35
|
+
def subsection(subsect, collapsed)
|
40
36
|
disp_clause = collapsed ? "display: none" : "display: block"
|
41
37
|
str = "<ul class=\"tree\" style=\"#{disp_clause}\">"
|
42
38
|
str = subsect.children.reduce(str) { |acc, item| acc + subsection_item_link(item) }
|
43
|
-
str
|
39
|
+
str + "</ul>"
|
44
40
|
end
|
45
41
|
|
46
42
|
def subsection_item_link tree_node
|
47
|
-
|
48
|
-
|
43
|
+
bullet = @sect_def.options[:bullet]
|
44
|
+
link_path = @items[tree_node.content.identifier].path
|
45
|
+
"<li class=\"#{tree_node.content.css_class}\">#{icon_markup(bullet)}<a href=\"#{link_path}\">#{tree_node.content.title}</a></li>"
|
49
46
|
end
|
50
47
|
|
51
48
|
def flat_section sect
|
52
49
|
disp_clause = sect.collapsed? ? "display: none" : "display: block"
|
53
50
|
str = "<ul class=\"tree\" style=\"#{disp_clause}\">"
|
54
51
|
str = sect.reduce(str) { |acc, item| acc + flat_section_item_link(item) }
|
55
|
-
str
|
52
|
+
str + "</ul>"
|
56
53
|
end
|
57
54
|
|
58
55
|
def flat_section_item_link citem
|
59
56
|
bullet = @sect_def.options[:bullet]
|
60
|
-
|
57
|
+
path = @items[citem.identifier].path
|
58
|
+
"<li class=\"#{citem.css_class}\">#{icon_markup(bullet)}<a href=\"#{path}\">#{citem.title}</a></li>"
|
61
59
|
end
|
62
60
|
|
63
61
|
def icon_markup icon_type
|
@@ -65,6 +63,4 @@ module SidebarHelpers
|
|
65
63
|
css_class = {dash: "glyphicon-minus", star: "glyphicon-star", plus: "glyphicon-plus-sign", minus: "glyphicon-minus-sign"}.fetch(icon_type)
|
66
64
|
"<span class=\"glyphicon #{css_class}\" style=#{STYLING_CONFIG[:bullet_style]}></span>"
|
67
65
|
end
|
68
|
-
|
69
|
-
|
70
66
|
end
|
@@ -10,13 +10,11 @@ class ICalAdaptor
|
|
10
10
|
@cal.add_timezone tz.ical_timezone(Time.now)
|
11
11
|
end
|
12
12
|
|
13
|
-
def feed_begin
|
14
|
-
end
|
13
|
+
def feed_begin; end
|
15
14
|
|
16
|
-
def feed_end
|
17
|
-
end
|
15
|
+
def feed_end; end
|
18
16
|
|
19
|
-
def feed_event(title, dt_start, dt_end, desc,
|
17
|
+
def feed_event(title, dt_start, dt_end, desc, _url)
|
20
18
|
event = Icalendar::Event.new
|
21
19
|
event.dtstart = dt_start
|
22
20
|
# event.dtstart = Icalendar::Values::DateOrDateTime.new(dt_start, tzid: 'UTC').call
|
@@ -4,12 +4,12 @@ class SearchIndex
|
|
4
4
|
all_citems = all_items.map { |itm| Toc.instance.n2c(itm) }
|
5
5
|
@index = all_citems.select { |citem| include_in_index? (citem)}.map do
|
6
6
|
|item|
|
7
|
-
nok_parse = Nokogiri::HTML(item.
|
7
|
+
nok_parse = Nokogiri::HTML(all_items[item.identifier].compiled_content).at('body')
|
8
8
|
nok_parse_inner_text = nok_parse.nil? ? "" : nok_parse.inner_text
|
9
9
|
{ title: clean_string(item.title),
|
10
10
|
text: clean_string(nok_parse_inner_text),
|
11
11
|
tags: "",
|
12
|
-
loc: item.
|
12
|
+
loc: all_items[item.identifier].reps[:default].path }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -18,10 +18,9 @@ class SearchIndex
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def include_in_index?(citem)
|
21
|
-
skiplist = Regexp.union([/\/
|
21
|
+
skiplist = Regexp.union([/\/tipuesearch\/.*/, /\/bootstrap\/.*/, /\/config\/.*/, /\/tipuesearch\/.*/])
|
22
22
|
citem.type == "page" &&
|
23
23
|
!citem.nitem.binary? &&
|
24
24
|
!citem.identifier.to_s.match(skiplist)
|
25
25
|
end
|
26
|
-
|
27
26
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
# Define schedule scheme for a lecture series
|
2
2
|
|
3
3
|
class ScheduleDef
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(first_day: nil, weekdays: nil, number: nil,
|
7
|
-
skips: [], start_time: "12:15", end_time: "13:15")
|
8
|
-
@first_day = first_day
|
9
|
-
@weekdays = weekdays
|
10
|
-
@number = number
|
11
|
-
@skips = skips
|
12
|
-
@start_time = start_time
|
13
|
-
@end_time = end_time
|
14
|
-
end
|
4
|
+
attr_reader :first_day, :weekdays, :number, :skips, :start_time, :end_time, :start_times, :end_times
|
15
5
|
|
6
|
+
def initialize(first_day: nil, weekdays: nil, number: nil,
|
7
|
+
skips: [], start_time: nil, end_time: nil, start_times: [], end_times: [])
|
8
|
+
@first_day = first_day
|
9
|
+
@weekdays = weekdays
|
10
|
+
@number = number
|
11
|
+
@skips = skips
|
12
|
+
@start_time = start_time
|
13
|
+
@end_time = end_time
|
14
|
+
@start_times = start_times
|
15
|
+
@end_times = end_times
|
16
|
+
end
|
16
17
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
# Used in generating iCal feed. Given a data_adapter (who knows how to get data out and iterate across things) and a
|
1
|
+
# Used in generating iCal feed. Given a data_adapter (who knows how to get data out and iterate across things) and a
|
2
|
+
# feed_builder (who knows how to turn that data into some kind of feed), produce the feed. This same class could also
|
3
|
+
# generate, for example, an RSs feed.
|
2
4
|
|
3
5
|
class ScheduleFeed
|
4
6
|
def initialize feed_builder, data_adapter
|