Skip to content

Commit dbce3c0

Browse files
committed
print-time html dependencies should use relative instead of absolute path, fixes #1376
1 parent 741ce17 commit dbce3c0

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

R/highlight.R

+10-4
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,26 @@ highlight_defaults <- function() {
206206

207207
selectizeLib <- function(bootstrap = TRUE) {
208208
htmltools::htmlDependency(
209-
"selectize", "0.12.0", depPath("selectize"),
209+
name = "selectize",
210+
version = "0.12.0",
211+
package = "plotly",
212+
src = dependency_dir("selectize"),
210213
stylesheet = if (bootstrap) "selectize.bootstrap3.css",
211214
script = "selectize.min.js"
212215
)
213216
}
214217

215218
colourPickerLib <- function() {
216219
htmltools::htmlDependency(
217-
"colourpicker", "1.1", depPath("colourpicker"),
220+
name = "colourpicker",
221+
version = "1.1",
222+
package = "plotly",
223+
src = dependency_dir("colourpicker"),
218224
stylesheet = "colourpicker.min.css",
219225
script = "colourpicker.min.js"
220226
)
221227
}
222228

223-
depPath <- function(...) {
224-
system.file('htmlwidgets', 'lib', ..., package = 'plotly')
229+
dependency_dir <- function(...) {
230+
file.path('htmlwidgets', 'lib', ...)
225231
}

R/mathjax.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ mathjax_cdn <- function() {
2929
htmltools::htmlDependency(
3030
name = "mathjax",
3131
version = "2.7.4",
32-
src = c(file = depPath("mathjax")),
32+
package = "plotly",
33+
src = dependency_dir("mathjax"),
3334
script = "cdn.js"
3435
)
3536
}

R/plotly.R

+13-8
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,10 @@ as_widget <- function(x, ...) {
434434

435435
typedArrayPolyfill <- function() {
436436
htmltools::htmlDependency(
437-
"typedarray", "0.1",
438-
src = depPath("typedarray"),
437+
name = "typedarray",
438+
version = "0.1",
439+
package = "plotly",
440+
src = dependency_dir("typedarray"),
439441
script = "typedarray.min.js",
440442
all_files = FALSE
441443
)
@@ -445,19 +447,21 @@ typedArrayPolyfill <- function() {
445447
# and bundle size at print time.
446448
plotlyMainBundle <- function() {
447449
htmltools::htmlDependency(
448-
"plotly-main",
450+
name = "plotly-main",
449451
version = "1.41.3",
450-
src = depPath("plotlyjs"),
452+
package = "plotly",
453+
src = dependency_dir("plotlyjs"),
451454
script = "plotly-latest.min.js",
452455
all_files = FALSE
453456
)
454457
}
455458

456459
plotlyHtmlwidgetsCSS <- function() {
457460
htmltools::htmlDependency(
458-
"plotly-htmlwidgets-css",
461+
name = "plotly-htmlwidgets-css",
459462
version = plotlyMainBundle()$version,
460-
src = depPath("plotlyjs"),
463+
package = "plotly",
464+
src = dependency_dir("plotlyjs"),
461465
stylesheet = "plotly-htmlwidgets.css",
462466
all_files = FALSE
463467
)
@@ -468,8 +472,8 @@ locale_dependency <- function(locale) {
468472
stop("locale must be a character string (vector of length 1)", call. = FALSE)
469473
}
470474

471-
locale_dir <- depPath("plotlyjs", "locales")
472-
locales_all <- sub("\\.js$", "", list.files(locale_dir))
475+
locale_dir <- dependency_dir("plotlyjs", "locales")
476+
locales_all <- sub("\\.js$", "", list.files(system.file(locale_dir, package = "plotly")))
473477
if (!tolower(locale) %in% locales_all) {
474478
stop(
475479
"Invalid locale: '", locale, "'.\n\n",
@@ -491,6 +495,7 @@ locale_dependency <- function(locale) {
491495
htmltools::htmlDependency(
492496
name = paste0("plotly-locale-", locale),
493497
version = plotlyMainBundle()$version,
498+
package = "plotly",
494499
src = list(file = locale_dir),
495500
script = tolower(scripts),
496501
all_files = FALSE

0 commit comments

Comments
 (0)