-
Notifications
You must be signed in to change notification settings - Fork 1
/
schedule.Rmd
77 lines (68 loc) · 1.86 KB
/
schedule.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: "POLS/CS&SS 503 Schedule"
---
```{r include=FALSE}
library("yaml")
library("htmltools")
library("purrr")
library("stringr")
library("lubridate")
localdata <- yaml.load_file("data.yml")
render_week <- function(x) {
w <- x[["week"]]
classes <- map(x[["meetings"]], render_class)
hdr <- tagList(tags$hr(), tags$h2(str_c("Week ", w)))
div(id = str_c("week-", w), hdr, classes)
}
render_reading <- function(x) {
tags$li(HTML(commonmark::markdown_html(x)))
}
render_readings_before <- function(x) {
readings <- x[["reading_before"]]
if (length(readings) > 0) {
tags$p(
str_c("Readings before class:"),
tags$ul(map(readings, render_reading))
)
} else ""
}
render_readings_after <- function(x) {
readings <- x[["reading_after"]]
if (length(readings) > 0) {
tags$p(
str_c("Optional readings after class:"),
tags$ul(map(readings, render_reading))
)
} else ""
}
render_topics <- function(x) {
topics <- x[["topics"]]
if (length(topics)) {
tags$p(tags$strong("Topics:"), HTML(commonmark::markdown_html(topics)))
}
}
render_notes <- function(x) {
tags$p(HTML(commonmark::markdown_html(x[["notes"]])))
}
render_class <- function(x) {
start <- ymd_hm(x[["start"]])
end <- ymd_hm(x[["end"]])
.header <- h3(str_c(str_to_title(x[["type"]]), ": "),
tags$time(format(start, "%A, %B %d, %Y"),
tags$small(format(start, "%H:%M"),
HTML("–"),
format(end, "%H:%M")),
datetime = format(start, "%Y-%m-%d %H:%M")))
div(
id = str_c(x[["type"]], "-", format(start, "%Y-%m-%d")),
.header,
render_topics(x),
render_notes(x),
render_readings_before(x),
render_readings_after(x)
)
}
```
```{r echo = FALSE}
tagList(map(localdata[["classes"]], render_week))
```