Browse Source

added `wait` value range check for `render_` functions (min 0, max 10)

master
boB Rudis 7 years ago
parent
commit
be24f2e45f
No known key found for this signature in database GPG Key ID: 2A514A4997464560
  1. 2
      DESCRIPTION
  2. 1
      NEWS.md
  3. 12
      R/aaa.r
  4. 2
      R/render-har.r
  5. 2
      R/render-html.r
  6. 2
      R/render-jpg.r
  7. 2
      R/render-json.r
  8. 2
      R/render-png.r
  9. 2
      R/render_file.R

2
DESCRIPTION

@ -42,5 +42,5 @@ Imports:
jsonlite,
HARtools,
lubridate
RoxygenNote: 6.0.0
RoxygenNote: 6.0.1
Remotes: wch/harbor

1
NEWS.md

@ -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

12
R/aaa.r

@ -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
}

2
R/render-har.r

@ -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))

2
R/render-html.r

@ -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)

2
R/render-jpg.r

@ -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,

2
R/render-json.r

@ -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),

2
R/render-png.r

@ -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),

2
R/render_file.R

@ -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)

Loading…
Cancel
Save