-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.R
More file actions
32 lines (30 loc) · 750 Bytes
/
utils.R
File metadata and controls
32 lines (30 loc) · 750 Bytes
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
listar_fotos <- function(padrao, padrao_desc = NULL) {
arquivos <- list.files(
"static/images/fotos/",
pattern = padrao
)
for (arq in arquivos) {
data <- stringr::str_extract(arq, "[0-9]{4}-[0-9]{2}-[0-9]{2}")
if (!is.na(data)) {
data <- format(lubridate::ymd(data), "%d de %B")
} else {
data <- ""
}
if (!is.null(padrao_desc)) {
desc <- stringr::str_remove_all(arq, padrao_desc)
desc <- stringr::str_to_title(desc)
} else {
desc <- ""
}
data <- tidyr::replace_na(data, "")
id <- stringr::str_remove(arq, "\\..*$")
print(glue::glue(
'
- id: "{id}"
date: "{data}"
fotos: ["{arq}"]
descricao: "{desc}" \n
'
))
}
}