diff --git a/main/coverage-report/index.html b/main/coverage-report/index.html index 5a98788..63a56b9 100644 --- a/main/coverage-report/index.html +++ b/main/coverage-report/index.html @@ -107,8 +107,8 @@
#' Custom `examplesShinylive` tag.+
#' Custom `@examplesShinylive` tag.
#' This function generates a new "Examples in Shinylive" section in the documentation. This section contains URL to+
#' This function generates a new "Examples in Shinylive" section in the documentation.
#' the application in Shinylive as well as an iframe with the application.+
#' This section contains URL to the application in Shinylive and for HTML outputs: an iframe with the application.
$(\"iframe.iframe_shinylive\").css(\"width\", \"140\\%\");+
$(\"iframe.iframe_shinylive\").css(\"width\", \"150\\%\");
#' Creates Shinylive url for the app code.+
#' Creates Shinylive url based on app code.
#' @return (`character(1)`) Shinylive app url.+
#' @param mode (`character(1)`) A string with mode. One of "app" or "editor". Default is "app".
#'+
#' @param header (`logical(1)`) A logical value indicating whether to include header.
#' @export+
#' Ignored if `mode` is "editor".
#'+
#' @return (`character(1)`) Shinylive app url.
#' @examples+
#'
#' code <- "this is your app code as a string"+
#' @export
#' create_shinylive_url(code)+
#'
create_shinylive_url <- function(code) {+
#' @examples
#' code <- "this is your app code as a string"+
#' create_shinylive_url(code)+
#' create_shinylive_url(code, header = FALSE)+
#' create_shinylive_url(code, mode = "editor")+
create_shinylive_url <- function(code, mode = c("app", "editor"), header = TRUE) {+
stopifnot(is.character(code) && length(code) == 1)
mode <- match.arg(mode)+
stopifnot(is.logical(header) && length(header) == 1)+
# implementation based on "Create ShinyLive Link" feature of Shiny VSCode extension
# https://github.com/posit-dev/shiny-vscode/blob/80560bf36d516ff89dffe88bd9a28cee9edd4d43/src/shinylive.ts#L499
files <- list(
name = jsonlite::unbox("app.R"),
content = jsonlite::unbox(code)
)
files_json <- jsonlite::toJSON(list(files))
files_lz <- lzstring::compressToEncodedURIComponent(as.character(files_json))
files_lz <- gsub("/", "-", files_lz)
sprintf("https://shinylive.io/r/app/#code=%s", files_lz)+
header_param <- ifelse(mode == "app" && isFALSE(header), "h=0&", "")
sprintf("https://shinylive.io/r/%s/#%scode=%s", mode, header_param, files_lz)+
}