@@ -50,7 +50,7 @@ Dash <- R6::R6Class(
5050 # ' as `integrity` and `crossorigin`.
5151 # ' @param external_stylesheets List. An optional list of valid URLs from which
5252 # ' to serve CSS for rendered pages. Each entry can be a string (the URL) or a list
53- # ' with `href` (the URL) and optionally other `<link>` tag attributes such as
53+ # ' with `href` (the URL) and optionally other `<link>` tag attributes such as
5454 # ' `rel`, `integrity` and `crossorigin`.
5555 # ' @param compress Logical. Whether to try to compress files and data served by Fiery.
5656 # ' By default, `brotli` is attempted first, then `gzip`, then the `deflate` algorithm,
@@ -116,9 +116,9 @@ Dash <- R6::R6Class(
116116 # ------------------------------------------------------------
117117 router <- routr :: RouteStack $ new()
118118 server $ set_data(" user-routes" , list ()) # placeholder for custom routes
119-
119+
120120 # ensure that assets_folder is neither NULL nor character(0)
121- if (! (is.null(private $ assets_folder )) && length(private $ assets_folder ) != 0 ) {
121+ if (! (is.null(private $ assets_folder )) & length(private $ assets_folder ) != 0 ) {
122122 if (! (dir.exists(private $ assets_folder )) && gsub(" /+" , " " , assets_folder ) != " assets" ) {
123123 warning(sprintf(
124124 " The supplied assets folder, '%s', could not be found in the project directory." ,
@@ -618,9 +618,9 @@ Dash <- R6::R6Class(
618618 # ' library(dash)
619619 # ' app <- Dash$new()
620620 # '
621- # ' # A handler to redirect requests with `307` status code (temporary redirects);
621+ # ' # A handler to redirect requests with `307` status code (temporary redirects);
622622 # ' # for permanent redirects (`301`), see the `redirect` method described below
623- # ' #
623+ # ' #
624624 # ' # A simple single path-to-path redirect
625625 # ' app$server_route('/getting-started', function(request, response, keys, ...) {
626626 # ' response$status <- 307L
@@ -653,11 +653,11 @@ Dash <- R6::R6Class(
653653 " methods" = methods )
654654
655655 self $ server $ set_data(" user-routes" , user_routes )
656- },
656+ },
657657
658658 # ' @description
659659 # ' Redirect a Dash application URL path
660- # ' @details
660+ # ' @details
661661 # ' This is a convenience method to simplify adding redirects
662662 # ' for your Dash application which automatically return a `301`
663663 # ' HTTP status code and direct the client to load an alternate URL.
@@ -705,7 +705,7 @@ Dash <- R6::R6Class(
705705 TRUE
706706 }
707707 }
708-
708+
709709 self $ server_route(old_path , handler )
710710 },
711711
@@ -714,13 +714,13 @@ Dash <- R6::R6Class(
714714 # ------------------------------------------------------------------------
715715 # ' @description
716716 # ' Retrieves the Dash application layout.
717- # ' @details
717+ # ' @details
718718 # ' If render is `TRUE`, and the layout is a function,
719719 # ' the result of the function (rather than the function itself) is returned.
720720 # ' @param render Logical. If the layout is a function, should the function be
721721 # ' executed to return the layout? If `FALSE`, the function is returned as-is.
722- # ' @return List or function, depending on the value of `render` (see above).
723- # ' When returning an object of class `dash_component`, the default `print`
722+ # ' @return List or function, depending on the value of `render` (see above).
723+ # ' When returning an object of class `dash_component`, the default `print`
724724 # ' method for this class will display the corresponding pretty-printed JSON
725725 # ' representation of the object to the console.
726726 layout_get = function (render = TRUE ) {
@@ -739,7 +739,7 @@ Dash <- R6::R6Class(
739739 # ' class.
740740 # ' @param value An object of the `dash_component` class, which provides
741741 # ' a component or collection of components, specified either as a Dash
742- # ' component or a function that returns a Dash component.
742+ # ' component or a function that returns a Dash component.
743743 layout = function (value ) {
744744 # private$layout_ <- if (is.function(..1)) ..1 else list(...)
745745 private $ layout_ <- value
@@ -769,9 +769,9 @@ Dash <- R6::R6Class(
769769 # ' @description
770770 # ' Define a Dash callback.
771771 # ' @details
772- # ' Describes a server or clientside callback relating the values of one or more
772+ # ' Describes a server or clientside callback relating the values of one or more
773773 # ' `output` items to one or more `input` items which will trigger the callback
774- # ' when they change, and optionally `state` items which provide additional
774+ # ' when they change, and optionally `state` items which provide additional
775775 # ' information but do not trigger the callback directly.
776776 # '
777777 # ' For detailed examples of how to use pattern-matching callbacks, see the
@@ -784,13 +784,13 @@ Dash <- R6::R6Class(
784784 # ' object(s) (which should reference layout components), which become
785785 # ' argument values for R callback handlers defined in `func`.
786786 # '
787- # ' Here `func` may either be an anonymous R function, a JavaScript function
787+ # ' Here `func` may either be an anonymous R function, a JavaScript function
788788 # ' provided as a character string, or a call to `clientsideFunction()`, which
789789 # ' describes a locally served JavaScript function instead. The latter
790790 # ' two methods define a "clientside callback", which updates components
791791 # ' without passing data to and from the Dash backend. The latter may offer
792792 # ' improved performance relative to callbacks written purely in R.
793- # ' @param output Named list. The `output` argument provides the component `id`
793+ # ' @param output Named list. The `output` argument provides the component `id`
794794 # ' and `property` which will be updated by the callback; a callback can
795795 # ' target one or more outputs (i.e. multiple outputs).
796796 # ' @param params Unnamed list; provides [input] and [state] statements, each
@@ -852,12 +852,12 @@ Dash <- R6::R6Class(
852852 # ' the firing of a given callback, and allows introspection of the input/state
853853 # ' values given their names. It is only available from within a callback;
854854 # ' attempting to use this method outside of a callback will result in a warning.
855- # '
855+ # '
856856 # ' The `callback_context` method returns a list containing three elements:
857857 # ' `states`, `triggered`, `inputs`. The first and last of these correspond to
858858 # ' the values of `states` and `inputs` for the current invocation of the
859859 # ' callback, and `triggered` provides a list of changed properties.
860- # '
860+ # '
861861 # ' @return List comprising elements `states`, `triggered`, `inputs`.
862862 callback_context = function () {
863863 if (is.null(private $ callback_context_ )) {
@@ -877,14 +877,14 @@ Dash <- R6::R6Class(
877877 # ' duration required to execute a given callback. It may only be called
878878 # ' from within a callback; a warning will be thrown and the method will
879879 # ' otherwise return `NULL` if invoked outside of a callback.
880- # '
880+ # '
881881 # ' @param name Character. The name of the resource.
882882 # ' @param duration Numeric. The time in seconds to report. Internally, this is
883883 # ' rounded to the nearest millisecond.
884884 # ' @param description Character. A description of the resource.
885885 # '
886886 callback_context.record_timing = function (name ,
887- duration = NULL ,
887+ duration = NULL ,
888888 description = NULL ) {
889889 if (is.null(private $ callback_context_ )) {
890890 warning(" callback_context is undefined; callback_context.record_timing may only be accessed within a callback." )
@@ -897,7 +897,7 @@ Dash <- R6::R6Class(
897897 stop(paste0(" Duplicate resource name " , name , " found." ), call. = FALSE )
898898 }
899899
900- timing_information [[name ]] <- list (" dur" = round(duration * 1000 ),
900+ timing_information [[name ]] <- list (" dur" = round(duration * 1000 ),
901901 " desc" = description )
902902
903903 self $ server $ set_data(" timing-information" , timing_information )
@@ -906,9 +906,9 @@ Dash <- R6::R6Class(
906906 # ------------------------------------------------------------------------
907907 # return asset URLs
908908 # ------------------------------------------------------------------------
909- # ' @description
909+ # ' @description
910910 # ' Return a URL for a Dash asset.
911- # ' @details
911+ # ' @details
912912 # ' The `get_asset_url` method permits retrieval of an asset's URL given its filename.
913913 # ' For example, `app$get_asset_url('style.css')` should return `/assets/style.css` when
914914 # ' `assets_folder = 'assets'`. By default, the prefix is the value of `requests_pathname_prefix`,
@@ -973,7 +973,7 @@ Dash <- R6::R6Class(
973973 # ' in components such as `dccLink` or `dccLocation`. For example, `app$get_relative_url("/page/")`
974974 # ' would return `/app/page/` for an app running on a deployment server. The path must be prefixed with
975975 # ' a `/`.
976- # ' @param path Character. A path string prefixed with a leading `/` which directs
976+ # ' @param path Character. A path string prefixed with a leading `/` which directs
977977 # ' at a path or asset directory.
978978 # ' @param requests_pathname_prefix Character. The pathname prefix for the application when
979979 # ' deployed. Defaults to the environment variable set by the server,
@@ -984,12 +984,12 @@ Dash <- R6::R6Class(
984984 asset = get_relative_path(requests_pathname = requests_pathname_prefix , path = path )
985985 return (asset )
986986 },
987-
988-
987+
988+
989989 # ------------------------------------------------------------------------
990990 # return relative asset URLs
991991 # ------------------------------------------------------------------------
992-
992+
993993 # ' @description
994994 # ' Return a Dash asset path without its prefix.
995995 # ' @details
@@ -998,7 +998,7 @@ Dash <- R6::R6Class(
998998 # ' method, by taking a `relative path` as an input, and returning the `path` stripped of the `requests_pathname_prefix`,
999999 # ' and any leading or trailing `/`. For example, a path string `/app/homepage/`, would be returned as
10001000 # ' `homepage`. This is particularly useful for `dccLocation` URL routing.
1001- # ' @param path Character. A path string prefixed with a leading `/` which directs
1001+ # ' @param path Character. A path string prefixed with a leading `/` which directs
10021002 # ' at a path or asset directory.
10031003 # ' @param requests_pathname_prefix Character. The pathname prefix for the app on
10041004 # ' a deployed application. Defaults to the environment variable set by the server,
@@ -1014,7 +1014,7 @@ Dash <- R6::R6Class(
10141014 # ' Specify a custom index string for a Dash application.
10151015 # ' @details
10161016 # ' The `index_string` method allows the specification of a custom index by changing
1017- # ' the default `HTML` template that is generated by the Dash UI. #' Meta tags, CSS, and JavaScript are some examples of features
1017+ # ' the default `HTML` template that is generated by the Dash UI. #' Meta tags, CSS, and JavaScript are some examples of features
10181018 # ' that can be modified. This method will present a warning if your
10191019 # ' HTML template is missing any necessary elements
10201020 # ' and return an error if a valid index is not defined. The following interpolation keys are
@@ -1054,11 +1054,11 @@ Dash <- R6::R6Class(
10541054 assertthat :: assert_that(is.character(string ))
10551055 private $ custom_index <- validate_keys(string , is_template = TRUE )
10561056 },
1057-
1057+
10581058 # ------------------------------------------------------------------------
1059- # modify the templated variables by using the `interpolate_index` method.
1059+ # modify the templated variables by using the `interpolate_index` method.
10601060 # ------------------------------------------------------------------------
1061- # ' @description
1061+ # ' @description
10621062 # ' Modify index template variables for a Dash application.
10631063 # ' @details
10641064 # ' With the `interpolate_index` method, one can pass a custom index with template string
@@ -1087,14 +1087,14 @@ Dash <- R6::R6Class(
10871087 # ' </footer>
10881088 # ' </body>
10891089 # ' </html>"
1090- # '
1090+ # '
10911091
10921092 # ' # this is the default configuration, but custom configurations
10931093 # ' # are possible -- the structure of the "config" argument is
10941094 # ' # a list, in which each element is a JSON key/value pair, when
10951095 # ' # reformatted as JSON from the list:
10961096 # ' # e.g. {"routes_pathname_prefix":"/", "ui":false}
1097- # ' config <- sprintf("<script id='_dash-config' type='application/json'> %s </script>",
1097+ # ' config <- sprintf("<script id='_dash-config' type='application/json'> %s </script>",
10981098 # ' jsonlite::toJSON(app$config, auto_unbox=TRUE))
10991099 # '
11001100 # ' app$interpolate_index(
@@ -1107,17 +1107,17 @@ Dash <- R6::R6Class(
11071107 assertthat :: assert_that(is.character(template_index ))
11081108 template <- template_index
11091109 kwargs <- list (... )
1110-
1110+
11111111 for (name in names(kwargs )) {
11121112 key = paste0(' \\ {\\ %' , name , ' \\ %\\ }' )
11131113 template = sub(key , kwargs [[name ]], template )
1114- }
1115-
1114+ }
1115+
11161116 invisible (validate_keys(names(kwargs ), is_template = FALSE ))
1117-
1117+
11181118 private $ template_index <- template
11191119 },
1120-
1120+
11211121 # ------------------------------------------------------------------------
11221122 # specify a custom title
11231123 # ------------------------------------------------------------------------
@@ -1130,7 +1130,7 @@ Dash <- R6::R6Class(
11301130 assertthat :: assert_that(is.character(string ))
11311131 private $ name <- string
11321132 },
1133-
1133+
11341134 # ------------------------------------------------------------------------
11351135 # convenient fiery wrappers
11361136 # ------------------------------------------------------------------------
@@ -1155,7 +1155,7 @@ Dash <- R6::R6Class(
11551155 # ' @param dev_tools_prune_errors Logical. Reduce tracebacks such that only lines relevant to user code remain, stripping out Fiery and Dash references? Only available with debugging. `TRUE` by default, set to `FALSE` to see the complete traceback. Environment variable: `DASH_PRUNE_ERRORS`.
11561156 # ' @param dev_tools_silence_routes_logging Logical. Replace Fiery's default logger with `dashLogger` instead (will remove all routes logging)? Enabled with debugging by default because hot reload hash checks generate a lot of requests.
11571157 # ' @param ... Additional arguments to pass to the `start` handler; see the [fiery] documentation for relevant examples.
1158- # ' @examples
1158+ # ' @examples
11591159 # ' if (interactive() && require(dash)) {
11601160 # ' library(dashCoreComponents)
11611161 # ' library(dashHtmlComponents)
@@ -1232,7 +1232,7 @@ Dash <- R6::R6Class(
12321232
12331233 # attach user-defined routes, if they exist
12341234 if (length(self $ server $ get_data(" user-routes" )) > 0 ) {
1235-
1235+
12361236 plugin <- list (
12371237 on_attach = function (server ) {
12381238 user_routes <- server $ get_data(" user-routes" )
@@ -1243,26 +1243,26 @@ Dash <- R6::R6Class(
12431243 # have all the relevant routes in place anyhow
12441244 if (server $ plugins $ request_routr $ has_route(" user-routes" ))
12451245 server $ plugins $ request_routr $ remove_route(" user-routes" )
1246-
1246+
12471247 router <- server $ plugins $ request_routr
12481248
12491249 route <- routr :: Route $ new()
1250-
1250+
12511251 for (routing in user_routes ) {
12521252 route $ add_handler(method = routing $ methods ,
12531253 path = routing $ path ,
12541254 handler = routing $ handler )
12551255 }
1256-
1256+
12571257 router $ add_route(route , " user-routes" )
12581258 },
12591259 name = " user_routes" ,
12601260 require = " request_routr"
12611261 )
1262-
1262+
12631263 self $ server $ attach(plugin , force = TRUE )
12641264 }
1265-
1265+
12661266 if (getAppPath() != FALSE ) {
12671267 source_dir <- dirname(getAppPath())
12681268 private $ app_root_modtime <- modtimeFromPath(source_dir , recursive = TRUE , asset_path = private $ assets_folder )
@@ -1304,7 +1304,7 @@ Dash <- R6::R6Class(
13041304 timing_information <- self $ server $ get_data(' timing-information' )
13051305 dash_total <- timing_information [[' __dash_server' ]]
13061306 timing_information [[' __dash_server' ]][[' dur' ]] <- round((as.numeric(Sys.time()) - dash_total [[' dur' ]]) * 1000 )
1307-
1307+
13081308 header_as_string <- list ()
13091309
13101310 for (item in seq_along(timing_information )) {
@@ -1317,11 +1317,11 @@ Dash <- R6::R6Class(
13171317 if (! is.null(timing_information [[item ]]$ dur )) {
13181318 header_content <- paste0(header_content , ' ;dur=' , timing_information [[item ]]$ dur )
13191319 }
1320-
1320+
13211321 header_as_string [[item ]] <- header_content
13221322 }
13231323
1324- request $ response $ append_header(' Server-Timing' ,
1324+ request $ response $ append_header(' Server-Timing' ,
13251325 paste0(unlist(header_as_string ), collapse = " , " ))
13261326 })
13271327 }
@@ -1443,7 +1443,7 @@ Dash <- R6::R6Class(
14431443 # flush the context to prepare for the next request cycle
14441444 self $ server $ set_data(" timing-information" , list ())
14451445 })
1446- }
1446+ }
14471447
14481448 self $ server $ ignite(block = block , showcase = showcase , ... )
14491449 }
@@ -1501,10 +1501,10 @@ Dash <- R6::R6Class(
15011501 layout_ids = NULL ,
15021502 layout_render = function () {
15031503 layout_ <- if (is.function(private $ layout_ )) private $ layout_() else private $ layout_
1504-
1504+
15051505 # ensure that the layout is a component, or a collection of components
15061506 layout_ <- private $ componentify(layout_ )
1507-
1507+
15081508 # store the layout as a (flattened) vector form since we query the
15091509 # vector names several times to verify ID naming (among other things)
15101510 layout_flat <- rapply(layout_ , I )
@@ -1518,7 +1518,7 @@ Dash <- R6::R6Class(
15181518
15191519 if (duped ) {
15201520 duped_ids <- paste(layout_ids [duplicated(layout_ids )], collapse = " , " )
1521-
1521+
15221522 stop(
15231523 sprintf(" layout ids must be unique -- please check the following list of duplicated ids: '%s'" , duped_ids ),
15241524 call. = FALSE
@@ -1942,21 +1942,21 @@ Dash <- R6::R6Class(
19421942
19431943 # insert meta tags if present
19441944 meta_tags <- all_tags [[" meta_tags" ]]
1945-
1945+
19461946 # define the react-entry-point
19471947 app_entry <- " <div id='react-entry-point'><div class='_dash-loading'>Loading...</div></div>"
19481948 # define the dash default config key
19491949 config <- sprintf(" <script id='_dash-config' type='application/json'> %s </script>" , to_JSON(self $ config ))
19501950
19511951 if (is.null(private $ name ))
19521952 private $ name <- ' Dash'
1953-
1953+
19541954 if (! is.null(private $ custom_index )) {
19551955 string_index <- glue :: glue(private $ custom_index , .open = " {%" , .close = " %}" )
1956-
1956+
19571957 private $ .index <- string_index
19581958 }
1959-
1959+
19601960 else if (length(private $ template_index ) == 1 ) {
19611961 private $ .index <- private $ template_index
19621962 }
0 commit comments