Переглянути джерело
added `wait` value range check for `render_` functions (min 0, max 10)
master
Не вдалося знайти GPG ключ що відповідає даному підпису
Ідентифікатор GPG ключа: 2A514A4997464560
9 змінених файлів з
26 додано та
1 видалено
-
DESCRIPTION
-
NEWS.md
-
R/aaa.r
-
R/render-har.r
-
R/render-html.r
-
R/render-jpg.r
-
R/render-json.r
-
R/render-png.r
-
R/render_file.R
|
|
@ -42,5 +42,5 @@ Imports: |
|
|
|
jsonlite, |
|
|
|
HARtools, |
|
|
|
lubridate |
|
|
|
RoxygenNote: 6.0.0 |
|
|
|
RoxygenNote: 6.0.1 |
|
|
|
Remotes: wch/harbor |
|
|
|
|
|
@ -6,6 +6,7 @@ |
|
|
|
* added HAR support |
|
|
|
* added `as_req()` |
|
|
|
* added `as_request()` |
|
|
|
* added `wait` value range check for `render_` functions (min 0, max 10) |
|
|
|
|
|
|
|
0.2.0 |
|
|
|
|
|
|
|
|
|
@ -13,4 +13,16 @@ parse_query <- function(query) { |
|
|
|
FUN.VALUE=character(2)) |
|
|
|
purrr::set_names(as.list(curl::curl_unescape(params[2,])), |
|
|
|
curl::curl_unescape(params[1,])) |
|
|
|
} |
|
|
|
|
|
|
|
check_wait <- function(wait) { |
|
|
|
if (wait<0) { |
|
|
|
message("The 'wait' parameter cannot be less than 0; auto-changing it to 0") |
|
|
|
wait <- 0 |
|
|
|
} else if (wait>10) { |
|
|
|
message("The 'wait' parameter cannot be greater than 10 in render_... calls; auto-changing it to 10") |
|
|
|
message("Use the direct lua interface or lua DSL wrapper functions to set higher 'wait' vales.") |
|
|
|
wait <- 10 |
|
|
|
} |
|
|
|
wait |
|
|
|
} |
|
|
@ -14,6 +14,8 @@ render_har <- function(splash_obj = splash_local, url, base_url, response_body=F |
|
|
|
forbidden_content_types, viewport="1024x768", images, headers, body, |
|
|
|
http_method, save_args, load_args) { |
|
|
|
|
|
|
|
wait <- check_wait(wait) |
|
|
|
|
|
|
|
params <- list(url=url, timeout=timeout, wait=wait, viewport=jsonlite::unbox(viewport), |
|
|
|
response_body=as.numeric(response_body)) |
|
|
|
|
|
|
|
|
|
@ -35,6 +35,8 @@ render_html <- function(splash_obj = splash_local, url, base_url, timeout=30, re |
|
|
|
forbidden_content_types, viewport="1024x768", images, headers, body, |
|
|
|
http_method, save_args, load_args, raw_html=FALSE) { |
|
|
|
|
|
|
|
wait <- check_wait(wait) |
|
|
|
|
|
|
|
params <- list(url=url, timeout=timeout, wait=wait, viewport=jsonlite::unbox(viewport)) |
|
|
|
|
|
|
|
if (!missing(base_url)) params$base_url <- jsonlite::unbox(base_url) |
|
|
|
|
|
@ -14,6 +14,8 @@ render_jpeg <- render_jpg <- function( |
|
|
|
forbidden_content_types, viewport="full", images, headers, body, |
|
|
|
http_method, save_args, load_args) { |
|
|
|
|
|
|
|
wait <- check_wait(wait) |
|
|
|
|
|
|
|
params <- list(url=url, timeout=timeout, |
|
|
|
wait=if (render_all & wait == 0) 0.5 else wait, |
|
|
|
viewport=viewport, |
|
|
|
|
|
@ -35,6 +35,8 @@ render_json <- function(splash_obj = splash_local, url, base_url=NULL, quality=7 |
|
|
|
iframes=TRUE, script=TRUE, console=TRUE, history=TRUE, har=TRUE, |
|
|
|
response_body=FALSE) { |
|
|
|
|
|
|
|
wait <- check_wait(wait) |
|
|
|
|
|
|
|
params <- list(url=url, timeout=timeout, wait=wait, viewport=jsonlite::unbox(viewport), |
|
|
|
quality=quality, render_all=as.numeric(render_all), |
|
|
|
html=as.numeric(html), png=as.numeric(png), jpeg=as.numeric(jpeg), |
|
|
|
|
|
@ -14,6 +14,8 @@ render_png <- function( |
|
|
|
forbidden_content_types, viewport="full", images, headers, body, |
|
|
|
http_method, save_args, load_args) { |
|
|
|
|
|
|
|
wait <- check_wait(wait) |
|
|
|
|
|
|
|
params <- list(url=url, timeout=timeout, |
|
|
|
wait=if (render_all & wait == 0) 0.5 else wait, |
|
|
|
viewport=jsonlite::unbox(viewport), |
|
|
|
|
|
@ -16,6 +16,8 @@ |
|
|
|
#' @export |
|
|
|
render_file <- function(splash_obj = splash_local, file_path, output=c("html", "png"), wait=0, viewport="1024x768", ...) { |
|
|
|
|
|
|
|
wait <- check_wait(wait) |
|
|
|
|
|
|
|
output <- match.arg(output, c("html", "png")) |
|
|
|
|
|
|
|
file.copy(file_path, .pkgenv$temp_dir) |
|
|
|