Create JSON element to send to ODS platform.
create_json.RdCombine information coming from the Opendatasoft page (with get_ods_page()) and the Rmarkdown document (with get_body_and_style()) into a JSON object ready to be sent back to the Opendatasoft platform.
Usage
create_json(
page_elements,
body_and_style,
title = NULL,
description = NULL,
chosen_languages = "all",
tags = NULL,
restricted = NULL
)Arguments
- page_elements
List object from get_page(). Contains the title, description, template, language, content, tags and level of restriction of the page. By default in create_json(), if no value is provided to title, description, tags and restricted, create_json() takes the values available in page_elements.
- body_and_style
List object containing body and style of knitted Rmd document coming from get_body_and_style().
- title
A character string specifying the title of the page. If not null, overwrites title from page_elements.
- description
A character string containing the description of the page. If not null, overwrites description from page_elements.
- chosen_languages
A character vector of languages in which the page should be updated. Default to "all", meaning all languages available on the platform.
- tags
A list object of character strings containing the tags describing the page. If not null, overwrites tags from page_elements.
- restricted
A logical TRUE/FALSE indicating the reading status of the page. TRUE will make the page "public" whereas FALSE will keep its access restricted to users who where granted the permission. If not null, overwrites reading status from page_elements.
Examples
# Temporary directory for reproducible example
dir_tmp <- tempfile(pattern = "proj-")
dir.create(dir_tmp)
file.copy(from = system.file("examples/example_rmd.Rmd", package = "odsrmd"), to = dir_tmp)
#> [1] TRUE
file.copy(from = system.file("examples/style.css", package = "odsrmd"), to=dir_tmp)
#> [1] TRUE
# browseURL(dir_tmp)
path <- paste0(dir_tmp, "/example_rmd.Rmd")
body_and_style <- get_body_and_style(path, add_extra_css = "no")
file.copy(from = system.file("examples/page_elements_example", package = "odsrmd"), to = dir_tmp)
#> [1] TRUE
page_elements <- readRDS(paste0(dir_tmp, "/page_elements_example"))
json_to_send <- create_json(page_elements, body_and_style,
chosen_languages = "all",
title = NULL, description = NULL,
tags = NULL, restricted = NULL
)
#> Languages available on the platform: EN, FR.
#> Chosen languages: ALL.