Closed guerda closed 9 years ago
Yep I understand the implication of connecting to a Russian server in the US, so we will definitely change this :)
@yulijia In the long run, I think it will be a good idea to make use of the htmltools package to handle such dependencies on JS libraries. You may take a look at the functions attachDependencies()
and htmlDependency()
in that package. There are some examples in shiny: https://github.com/rstudio/shiny/blob/master/R/bootstrap.R
The advantage of composing the HTML page for the animations using htmltools is that it will also work for R Markdown, and the rmarkdown package will handle the JS libraries in the HTML head. Let me know if you have any questions. Thanks!
Also see https://github.com/yihui/knitr/issues/883#issuecomment-62015248
Hi @yihui , I wrote a script to handle the highligh JS libraries problem using htmltools, https://github.com/yulijia/animation/blob/issue54/R/saveHTML.R This script only used to generate htmlfile with HighlightJS/CSS libraries, if user want to use their own libraries, they need input an htmlDependency object (highlight).
library(htmltools)
library(animation)
##use your own JS/CSS highlight libraries
highlight1 <- htmlDependency(
"highlightjs", "7.3",c(href="http://yandex.st"),
stylesheet = c("/highlightjs/7.3/styles/github.min.css"),
script = c("/highlightjs/7.3/highlight.min.js","/highlightjs/7.3/languages/r.min.js")
)
## use the function brownian.motion() in this package; this page
## is created in 'index.html' under the current working directory
des = c("Random walk of 10 points on the 2D plane:", "for each point (x, y),",
"x = x + rnorm(1) and y = y + rnorm(1).")
saveHTML({
par(mar = c(3, 3, 1, 0.5), mgp = c(2, 0.5, 0), tcl = -0.3, cex.axis = 0.8,
cex.lab = 0.8, cex.main = 1)
ani.options(interval = 0.05, nmax = ifelse(interactive(), 150,
2))
brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow")
}, img.name = "brownian_motion_a", htmlfile = "index.html", description = des, highlight=highlight1)
I am not familiar with htmltools package and those default JS/CSS files in the animation package, could you help me to see if my script can used with a individually hosted HighlightJS library? or provide some individually hosted HighlightJS libraries could used in demo test.
Thanks.
@guerda I have replace the yandex.st links in this package. Thanks!
@yulijia Nice work! I was thinking of a version of saveHTML() using the htmlwidgets package: http://www.htmlwidgets.org You may consider writing a new function instead of patching saveHTML().
Per default, this package uses the CDN from Yandex.st to embed the HighlightJS library including the CSS file. I would like to use the animation package in a sensitive environment and would like to prevent internet servers for these requests. It would be great, if this package had an option to define a individually hosted HighlightJS library. This would avoid contacting internet servers completely.