forked from jepusto/jepusto.com
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvert-presentations.R
More file actions
58 lines (50 loc) · 1.48 KB
/
convert-presentations.R
File metadata and controls
58 lines (50 loc) · 1.48 KB
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
library(tidyverse)
talk_md <- "content/talks-old/ABAI-2013-effect-sizes.md"
talks <-
list.files("content/talks-old/", full.names = TRUE) %>%
keep(~ .x != "content/talks-old/_index.md")
read_talk_data <- function(talk_md) {
tibble(line = read_lines(talk_md)) %>%
filter(!str_detect(line, "^#")) %>%
filter(str_detect(line, " = ")) %>%
mutate(
talk = talk_md,
line = str_split(line, " = ", n = 2),
key = map_chr(line, ~ .[[1]]),
val = map_chr(line, ~ .[[2]]),
) %>%
select(-line) %>%
pivot_wider(names_from = key, values_from = val)
}
talk_data <-
map_dfr(talks, read_talk_data) %>%
select(-abstract_short) %>%
rename(publishDate = date, date = time_start, featured = selected) %>%
mutate_at(vars(abstract, event_url, url_video), ~ "") %>%
mutate(
url_custom = str_sub(str_extract(url_custom, "url = .+\\}"), 7, -2),
url_pdf = if_else(!is.na(url_custom), url_custom, url_pdf),
authors = "[]",
projects = "",
summary = "",
tags = "[]"
) %>%
mutate_at(vars(everything()), ~ if_else(is.na(.), "", .))
talk_lines <-
talk_data %>%
select(-url_custom) %>%
mutate(
talk = str_replace(talk, "talks-old", "talk")
) %>%
pivot_longer(-talk, names_to = "key", values_to = "val") %>%
mutate(
string = paste(key, val, sep = ": ")
) %>%
group_by(talk) %>%
summarise(
string = list(c("---",string,"---"))
)
talk_lines %>%
mutate(
out = walk2(string, talk, ~ write_lines(.x, path = .y))
)