Skip to content

Commit 26bc46c

Browse files
authored
Merge pull request #401 from massimoaria/develop
Workaround for webshot2 bug on Windows machines
2 parents 9249e28 + 3468e71 commit 26bc46c

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

inst/biblioshiny/libraries.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ libraries <- function(){
2020
if (!require(RCurl, quietly=TRUE)){install.packages("RCurl")}
2121
if (!require(openxlsx, quietly=TRUE)){install.packages("openxlsx"); require(openxlsx, quietly=TRUE)}
2222
if (!require(shinyWidgets, quietly=TRUE)){install.packages("shinyWidgets"); require(shinyWidgets, quietly=TRUE)}
23-
if (!require(webshot2,quietly=TRUE)){install.packages("webshot2")}
23+
if (!require(webshot2,quietly=TRUE)){
24+
install.packages("https://cran.r-project.org/src/contrib/Archive/webshot2/webshot2_0.1.0.tar.gz", repos = NULL, type = "source")
25+
}else{
26+
pkgs <- installed.packages()[, "Version"]
27+
vers <- pkgs["webshot2"]
28+
if (vers!="0.1.0"){
29+
detach("package:webshot2", unload = TRUE, force=TRUE)
30+
install.packages("https://cran.r-project.org/src/contrib/Archive/webshot2/webshot2_0.1.0.tar.gz", repos = NULL, type = "source")
31+
}
32+
}
2433
if (!(require(chromote, quietly=TRUE))){install.packages("chromote"); require(chromote, quietly=TRUE)}
2534

2635
### workaround for webshot2 on shinyapps.io

inst/biblioshiny/server.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3372,7 +3372,7 @@ To ensure the functionality of Biblioshiny,
33723372
output$wordTable <- DT::renderDT({
33733373
WordCloud()
33743374

3375-
DT::datatable(values$Words, rownames = FALSE,
3375+
DT::datatable(values$Words, rownames = FALSE, extensions = c("Buttons"),
33763376
options = list(pageLength = 10, dom = 'Bfrtip',
33773377
buttons = list('pageLength',
33783378
list(extend = 'copy'),
@@ -3398,7 +3398,7 @@ To ensure the functionality of Biblioshiny,
33983398
output$treeTable <- DT::renderDT({
33993399
WordsT <- TreeMap()
34003400

3401-
DT::datatable(values$WordsT, rownames = FALSE,
3401+
DT::datatable(values$WordsT, rownames = FALSE, extensions = c("Buttons"),
34023402
options = list(pageLength = 10, dom = 'Bfrtip',
34033403
buttons = list('pageLength',
34043404
list(extend = 'copy'),

inst/biblioshiny/utils.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,13 +1915,15 @@ screenSh <- function(p, zoom = 2, type="vis"){
19151915

19161916
screenShot <- function(p, filename, type){
19171917
switch(Sys.info()[['sysname']],
1918-
Windows= {home <- Sys.getenv('R_USER')},
1918+
Windows= {home <- Sys.getenv('R_USER')
1919+
home <- gsub("/Documents","",home)
1920+
},
19191921
Linux = {home <- Sys.getenv('HOME')},
19201922
Darwin = {home <- Sys.getenv('HOME')})
19211923

19221924
# setting up the main directory
1923-
filename <- paste0(file.path(home,"downloads/"),filename)
1924-
1925+
#filename <- paste0(file.path(home,"downloads/"),filename)
1926+
filename <- paste0(file.path(home,"downloads"),"/",filename)
19251927
plot2png(p, filename, zoom = 2, type=type, tmpdir = tempdir())
19261928

19271929
}

0 commit comments

Comments
 (0)