diff --git a/.Rbuildignore b/.Rbuildignore index ffb5d8c..77a707c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -3,7 +3,6 @@ ^\.Rproj\.user$ ^\.github$ ^\.lintr$ -^\.pre-commit-config\.yaml$ ^_pkgdown\.yml$ ^data-raw$ ^docs$ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 2df8125..0000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# All available hooks: https://pre-commit.com/hooks.html -# R specific hooks: https://github.com/lorenzwalthert/precommit -repos: -- repo: https://github.com/lorenzwalthert/precommit - rev: v0.4.2 - hooks: - - id: style-files - args: [--style_pkg=styler, --style_fun=tidyverse_style] - - id: roxygenize - - id: use-tidy-description - - id: lintr - - id: parsable-R - - id: no-browser-statement - - id: no-print-statement - - id: no-debug-statement - - id: deps-in-desc - - id: pkgdown -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 - hooks: - - id: check-added-large-files - args: ['--maxkb=200'] - - id: file-contents-sorter - files: '^\.Rbuildignore$' - - id: end-of-file-fixer - exclude: '\.Rd' -- repo: local - hooks: - - id: forbid-to-commit - name: Don't commit common R artifacts - entry: Cannot commit .Rhistory, .RData, .Rds or .rds. - language: fail - files: '\.(Rhistory|RData|Rds|rds)$' - # `exclude: ` to allow committing specific files diff --git a/DESCRIPTION b/DESCRIPTION index fbf3075..f2fe468 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -21,6 +21,7 @@ Imports: glue, here, janitor, + jsonlite, knitr, lifecycle, magrittr, @@ -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 diff --git a/NAMESPACE b/NAMESPACE index 4987c81..ba6c7da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/quarto_utils.R b/R/quarto_utils.R index 031560c..a3dc1a4 100644 --- a/R/quarto_utils.R +++ b/R/quarto_utils.R @@ -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") + ) +} diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..c287c15 --- /dev/null +++ b/inst/WORDLIST @@ -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 diff --git a/man/gvz_quarto_get_presentation_yaml.Rd b/man/gvz_quarto_get_presentation_yaml.Rd new file mode 100644 index 0000000..385a70b --- /dev/null +++ b/man/gvz_quarto_get_presentation_yaml.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/quarto_utils.R +\name{gvz_quarto_get_presentation_yaml} +\alias{gvz_quarto_get_presentation_yaml} +\title{Gets presentation yaml file from GeoKey} +\usage{ +gvz_quarto_get_presentation_yaml(path, prefix) +} +\arguments{ +\item{path}{Path where the yaml file gets downloaded to} + +\item{prefix}{Prefix for the path on GeoKey} +} +\description{ +Gets presentation yaml file from GeoKey +} +\examples{ +\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# Not run: only work in quarto projects + +gvz_quarto_get_presentation_yaml("Presentations/", "DF") +\dontshow{\}) # examplesIf} +} diff --git a/man/gvz_quarto_make_presentation_yaml.Rd b/man/gvz_quarto_make_presentation_yaml.Rd new file mode 100644 index 0000000..cf7dc00 --- /dev/null +++ b/man/gvz_quarto_make_presentation_yaml.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/quarto_utils.R +\name{gvz_quarto_make_presentation_yaml} +\alias{gvz_quarto_make_presentation_yaml} +\title{Make a simple yaml file for all presentations} +\usage{ +gvz_quarto_make_presentation_yaml() +} +\description{ +Make a simple yaml file for all presentations +} +\examples{ +\dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# Not run: only work in quarto projects + +gvz_quarto_make_presentation_yaml() +\dontshow{\}) # examplesIf} +}