You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: R/dash.R
+71-42Lines changed: 71 additions & 42 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@
23
23
#'
24
24
#' @section Arguments:
25
25
#' \tabular{lll}{
26
-
#' `name` \tab \tab Character. The name of the Dash application (placed in the `<title>`
26
+
#' `name` \tab \tab Character. The name of the Dash application (placed in the title
27
27
#' of the HTML page). DEPRECATED; please use `index_string()` or `interpolate_index()` instead.\cr
28
28
#' `server` \tab \tab The web server used to power the application.
29
29
#' Must be a [fiery::Fire] object.\cr
@@ -87,18 +87,21 @@
87
87
#' \describe{
88
88
#' \item{output}{a named list including a component `id` and `property`}
89
89
#' \item{params}{an unnamed list of [input] and [state] statements, each with defined `id` and `property`}
90
-
#' \item{func}{any valid R function which generates [output] provided [input] and/or [state] arguments, or a call to [clientsideFunction] including `namespace` and `function_name` arguments for a locally served JavaScript function}
90
+
#' \item{func}{any valid R function which generates [output] provided [input] and/or [state] arguments,
91
+
#' a character string containing valid JavaScript, or a call to [clientsideFunction] including `namespace`
92
+
#' and `function_name` arguments for a locally served JavaScript function}
91
93
#' }
92
94
#' The `output` argument defines which layout component property should
93
95
#' receive the results (via the [output] object). The events that
94
96
#' trigger the callback are then described by the [input] (and/or [state])
95
97
#' object(s) (which should reference layout components), which become
96
98
#' argument values for R callback handlers defined in `func`. Here `func` may
97
-
#' either be an anonymous R function, or a call to `clientsideFunction()`, which
98
-
#' describes a locally served JavaScript function instead. The latter defines a
99
-
#' "clientside callback", which updates components without passing data to and
99
+
#' either be an anonymous R function, a JavaScript function provided as a
100
+
#' character string, or a call to `clientsideFunction()`, which describes a
101
+
#' locally served JavaScript function instead. The latter two methods define
102
+
#' a "clientside callback", which updates components without passing data to and
100
103
#' from the Dash backend. The latter may offer improved performance relative
101
-
#' to callbacks written in R.
104
+
#' to callbacks written purely in R.
102
105
#' }
103
106
#' \item{`title("dash")`}{
104
107
#' The title of the app. If no title is supplied, Dash for R will use 'dash'.
#' The `get_relative_path` method simplifies the handling of URLs and pathnames for apps
122
-
#' running locally and on a deployment server such as Dash Enterprise. It handles the prefix
123
-
#' for requesting assets similar to the `get_asset_url` method, but can also be used for URL handling
125
+
#' running locally and on a deployment server such as Dash Enterprise. It handles the prefix
126
+
#' for requesting assets similar to the `get_asset_url` method, but can also be used for URL handling
124
127
#' in components such as `dccLink` or `dccLocation`. For example, `app$get_relative_url("/page/")`
125
128
#' would return `/app/page/` for an app running on a deployment server. The path must be prefixed with
126
129
#' a `/`.
@@ -132,8 +135,8 @@
132
135
#' The `strip_relative_path` method simplifies the handling of URLs and pathnames for apps
133
136
#' running locally and on a deployment server such as Dash Enterprise. It acts almost opposite the `get_relative_path`
134
137
#' method, by taking a `relative path` as an input, and returning the `path` stripped of the `requests_pathname_prefix`,
135
-
#' and any leading or trailing `/`. For example, a path string `/app/homepage/`, would be returned as
136
-
#' `homepage`. This is particularly useful for `dccLocation` URL routing.
138
+
#' and any leading or trailing `/`. For example, a path string `/app/homepage/`, would be returned as
139
+
#' `homepage`. This is particularly useful for `dccLocation` URL routing.
137
140
#' \describe{
138
141
#' \item{path}{Character. A path string prefixed with a leading `/` and `requests_pathname_prefix` which directs at a path or asset directory.}
139
142
#' \item{requests_pathname_prefix}{Character. The pathname prefix for the app on a deployed application. Defaults to the environment variable set by the server, or `""` if run locally.}
@@ -183,17 +186,17 @@
183
186
#' but offers the ability to change the default components of the Dash index as seen in the example below:
184
187
#' \preformatted{
185
188
#' app$interpolate_index(
186
-
#' template_index,
187
-
#' metas = "<meta_charset='UTF-8'/>",
188
-
#' renderer = renderer,
189
+
#' template_index,
190
+
#' metas = "<meta_charset='UTF-8'/>",
191
+
#' renderer = renderer,
189
192
#' config = config)
190
193
#' }
191
194
#' \describe{
192
195
#' \item{template_index}{Character. A formatted string with the HTML index string. Defaults to the initial template}
193
196
#' \item{...}{Named List. The unnamed arguments can be passed as individual named lists corresponding to the components
194
197
#' of the Dash html index. These include the same arguments as those found in the `index_string()` template.}
warning("application not started via source(), and DASH_APP_PATH environment variable is undefined. get_asset_url returns NULL since root path cannot be reliably identified.")
817
839
return(NULL)
818
840
}
819
-
820
-
asset<- lapply(private$asset_map,
841
+
842
+
asset<- lapply(private$asset_map,
821
843
function(x) {
822
844
# asset_path should be prepended with the full app root & assets path
823
845
# if leading slash(es) present in asset_path, remove them before
824
846
# assembling full asset path
825
847
asset_path<- file.path(app_root_path,
826
-
private$assets_folder,
848
+
private$assets_folder,
827
849
sub(pattern="^/+",
828
850
replacement="",
829
851
asset_path))
830
852
return(names(x[x==asset_path]))
831
853
}
832
854
)
833
855
asset<- unlist(asset, use.names=FALSE)
834
-
856
+
835
857
if (length(asset) ==0)
836
858
stop(sprintf("the asset path '%s' is not valid; please verify that this path exists within the '%s' directory.",
837
859
asset_path,
838
860
private$assets_folder))
839
-
861
+
840
862
# strip multiple slashes if present, since we'll
841
863
# introduce one when we concatenate the prefix and
842
864
# asset path & prepend the asset name with route prefix
0 commit comments