Skip to content

Commit

Permalink
Add support functions for GeoKey/GeoDoc (and remove precommit…)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nenuial committed Jul 22, 2024
1 parent e3d4b1c commit 509b838
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 36 deletions.
1 change: 0 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
^\.Rproj\.user$
^\.github$
^\.lintr$
^\.pre-commit-config\.yaml$
^_pkgdown\.yml$
^data-raw$
^docs$
Expand Down
34 changes: 0 additions & 34 deletions .pre-commit-config.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imports:
glue,
here,
janitor,
jsonlite,
knitr,
lifecycle,
magrittr,
Expand Down Expand Up @@ -53,4 +54,4 @@ Config/Needs/website: nenuial/geopkg
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2.9000
RoxygenNote: 7.3.1
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export(gvz_matu)
export(gvz_matu_data)
export(gvz_matu_oraux)
export(gvz_md_to_latex)
export(gvz_quarto_get_presentation_yaml)
export(gvz_quarto_make_presentation_yaml)
export(gvz_quarto_setup)
export(gvz_render_diagrams)
export(gvz_render_multiple)
Expand Down
46 changes: 46 additions & 0 deletions R/quarto_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,49 @@ gvz_walk_multiple <- function(template, output_dir, ...) {
gvz_quarto_setup <- function() {
knitr::opts_chunk$set(dev.args = c(bg = "transparent"))
}


#' Make a simple yaml file for all presentations
#'
#' @returns NULL
#' @export
#'
#' @examplesIf interactive()
#' # Not run: only work in quarto projects
#'
#' gvz_quarto_make_presentation_yaml()
#'
gvz_quarto_make_presentation_yaml <- function() {
get_title <- function(path) {
title <- rmarkdown::yaml_front_matter(path)$title
url <- fs::path(fs::path_ext_remove(path), ext = "html")
tibble::tibble(url = url, title = title)
}

fs::dir_ls(".", recurse = TRUE, regexp = "\\d{1,2}-.*?/index.qmd") |>
purrr::map(get_title) |>
purrr::list_rbind() |>
jsonlite::toJSON() |>
jsonlite::parse_json() |>
yaml::as.yaml() |>
readr::write_file("presentations.yml")
}

#' Gets presentation yaml file from GeoKey
#'
#' @param path Path where the yaml file gets downloaded to
#' @param prefix Prefix for the path on GeoKey
#'
#' @returns NULL
#' @export
#'
#' @examplesIf interactive()
#' # Not run: only work in quarto projects
#'
#' gvz_quarto_get_presentation_yaml("Presentations/", "DF")
gvz_quarto_get_presentation_yaml <- function(path, prefix) {
download.file(
paste0("http://key.geoviews.ch/", prefix, "-", path, "/presentations.yml"),
paste0(path, "/Presentations/presentations.yml")
)
}
50 changes: 50 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
aut
bookdown
BugReports
burkhard
Burkhard
chunkhooks
Config
cre
downlit
dplyr
fs
geodata
GeoKey
geopkg
geotools
geovizr
ggeo
ggplot
github
gmail
http
https
jsonlite
kableExtra
knitr
Knitr
LazyData
lifecycle
magick
magrittr
nenuial
Nenuial
ORCID
pdftools
purrr
ragg
readr
rlang
rmarkdown
Rmd
rnotion
Roxygen
RoxygenNote
stringr
tibble
tidyr
tinytex
tufte
xfun
yaml
23 changes: 23 additions & 0 deletions man/gvz_quarto_get_presentation_yaml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/gvz_quarto_make_presentation_yaml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 509b838

Please sign in to comment.