Skip to content

Commit 817d8c4

Browse files
authored
Merge pull request #585 from massimoaria/develop
Develop
2 parents aafd151 + 8bf1fd3 commit 817d8c4

File tree

12 files changed

+762
-6755
lines changed

12 files changed

+762
-6755
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: bibliometrix
22
Type: Package
33
Title: Comprehensive Science Mapping Analysis
4-
Version: 5.2.0
4+
Version: 5.2.1.9000
55
Authors@R: c(
66
person(given = "Massimo",
77
family = "Aria",

NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
bibliometrix V.5.2.1 (Release date: 2025-12-11)
2+
3+
Changes:
4+
5+
* Removed old geemini models 1.5 and 2.0 from biblioAI
6+
* Solved issue with internet connection checking in MS Windows systems
7+
8+
19
bibliometrix V.5.2.0 (Release date: 2025-11-04)
210

311
Features:

NEWS.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# bibliometrix 5.2.0
1+
# bibliometrix (development version)
2+
3+
# bibliometrix 5.2.1
4+
5+
# bibliometrix V.5.2.1 (Release date: 2025-12-11)
6+
7+
Changes:
8+
9+
* Removed old geemini models 1.5 and 2.0 from biblioAI
10+
* Solved issue with internet connection checking in MS Windows systems
211

312
# bibliometrix V.5.2.0 (Release date: 2025-11-04)
413

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ dplyr::glimpse(authorInfo)
522522
#> $ affiliation_raw <chr> "Department of Economics and Statistics, Università degli Studi di Napoli Federico…
523523
#> $ source_doi <chr> "10.1016/j.joi.2017.08.007"
524524
#> $ source_title <chr> "bibliometrix : An R-tool for comprehensive science mapping analysis"
525-
#> $ query_timestamp <dttm> 2025-11-07 18:40:48
525+
#> $ query_timestamp <dttm> 2025-12-11 09:08:17
526526
```
527527

528528
This function provides comprehensive author profiles including:

inst/biblioshiny/biblioAI.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ gemini_ai <- function(
33
image = NULL,
44
docs = NULL,
55
prompt = "Explain these images",
6-
model = "2.0-flash",
6+
model = "2.5-flash",
77
image_type = "png",
88
retry_503 = 5,
99
api_key = NULL,
@@ -259,7 +259,7 @@ setGeminiAPI <- function(api_key) {
259259
apiCheck <- gemini_ai(
260260
image = NULL,
261261
prompt = "Hello",
262-
model = "2.0-flash",
262+
model = "2.5-flash",
263263
image_type = "png",
264264
retry_503 = 5,
265265
api_key = api_key
@@ -341,7 +341,7 @@ loadGeminiModel = function(file) {
341341
if (file.exists(file)) {
342342
model <- readLines(file, warn = FALSE)
343343
} else {
344-
model <- c("2.0-flash", "medium")
344+
model <- c("2.5-flash", "medium")
345345
}
346346
if (length(model == 1)) {
347347
model <- c(model, "medium")
@@ -801,7 +801,7 @@ geminiGenerate <- function(
801801
"collabWorldMap" = {
802802
values$WMGemini <- geminiPromptImage(
803803
obj = values$WMmap$g,
804-
type = "ggplot2",
804+
type = "plotly",
805805
prompt = prompt,
806806
key = values$geminiAPI,
807807
desc = desc,

inst/biblioshiny/biblioShot.R

Lines changed: 109 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Acknowledgment
2-
# This function is based on the source code of the webshot2 package.
3-
# We would like to acknowledge and express our gratitude to the authors
4-
# and contributors of webshot2 for their valuable work in developing tools
5-
# for web content capture.
2+
# This function is based on the source code of the webshot2 package.
3+
# We would like to acknowledge and express our gratitude to the authors
4+
# and contributors of webshot2 for their valuable work in developing tools
5+
# for web content capture.
66
#
7-
# In this implementation, we have adapted and modified parts of the original
8-
# webshot2 code to address an issue where PNG files were being generated as
9-
# empty images when used on Windows systems. Our modifications aim to improve
7+
# In this implementation, we have adapted and modified parts of the original
8+
# webshot2 code to address an issue where PNG files were being generated as
9+
# empty images when used on Windows systems. Our modifications aim to improve
1010
# compatibility and ensure reliable output across different platforms.
1111
#
1212
# Reference:
@@ -26,12 +26,12 @@ biblioShot <- function(
2626
max_concurrent = getOption("biblioShot.concurrent", default = 6),
2727
verbose = FALSE
2828
) {
29-
3029
if (length(url) == 0) {
3130
stop("Need url.")
3231
}
3332

34-
url <- vapply(url,
33+
url <- vapply(
34+
url,
3535
function(x) {
3636
if (!is_url(x)) {
3737
file_url(x)
@@ -42,9 +42,15 @@ biblioShot <- function(
4242
character(1)
4343
)
4444

45-
if (!is.null(cliprect) && !is.list(cliprect)) cliprect <- list(cliprect)
46-
if (!is.null(selector) && !is.list(selector)) selector <- list(selector)
47-
if (!is.null(expand) && !is.list(expand)) expand <- list(expand)
45+
if (!is.null(cliprect) && !is.list(cliprect)) {
46+
cliprect <- list(cliprect)
47+
}
48+
if (!is.null(selector) && !is.list(selector)) {
49+
selector <- list(selector)
50+
}
51+
if (!is.null(expand) && !is.list(expand)) {
52+
expand <- list(expand)
53+
}
4854

4955
if (is.null(selector)) {
5056
selector <- "html"
@@ -58,21 +64,23 @@ biblioShot <- function(
5864
}
5965

6066
args_all <- list(
61-
url = url,
62-
file = file,
63-
vwidth = vwidth,
64-
vheight = vheight,
65-
selector = selector,
66-
cliprect = cliprect,
67-
expand = expand,
68-
delay = delay,
69-
zoom = zoom,
67+
url = url,
68+
file = file,
69+
vwidth = vwidth,
70+
vheight = vheight,
71+
selector = selector,
72+
cliprect = cliprect,
73+
expand = expand,
74+
delay = delay,
75+
zoom = zoom,
7076
useragent = useragent,
7177
verbose = verbose
7278
)
7379

7480
n_urls <- length(url)
75-
args_all <- mapply(args_all, names(args_all),
81+
args_all <- mapply(
82+
args_all,
83+
names(args_all),
7684
FUN = function(arg, name) {
7785
if (length(arg) == 0) {
7886
return(vector(mode = "list", n_urls))
@@ -81,7 +89,11 @@ biblioShot <- function(
8189
} else if (length(arg) == n_urls) {
8290
return(arg)
8391
} else {
84-
stop("Argument `", name, "` should be NULL, length 1, or same length as `url`.")
92+
stop(
93+
"Argument `",
94+
name,
95+
"` should be NULL, length 1, or same length as `url`."
96+
)
8597
}
8698
},
8799
SIMPLIFY = FALSE
@@ -92,15 +104,22 @@ biblioShot <- function(
92104
cm <- default_chromote_object()
93105

94106
# A list of promises for the screenshots
95-
res <- lapply(args_all,
96-
function(args) {
97-
new_session_screenshot(cm,
98-
args$url, args$file, args$vwidth, args$vheight, args$selector,
99-
args$cliprect, args$expand, args$delay, args$zoom, args$useragent,
100-
verbose
101-
)
102-
}
103-
)
107+
res <- lapply(args_all, function(args) {
108+
new_session_screenshot(
109+
cm,
110+
args$url,
111+
args$file,
112+
args$vwidth,
113+
args$vheight,
114+
args$selector,
115+
args$cliprect,
116+
args$expand,
117+
args$delay,
118+
args$zoom,
119+
args$useragent,
120+
verbose
121+
)
122+
})
104123

105124
p <- promises::promise_all(.list = res)
106125
res <- cm$wait_for(p)
@@ -123,7 +142,6 @@ new_session_screenshot <- function(
123142
useragent,
124143
verbose = FALSE
125144
) {
126-
127145
filetype <- tolower(tools::file_ext(file))
128146
if (filetype != "png" && filetype != "pdf") {
129147
stop("File extension must be 'png' or 'pdf'")
@@ -140,60 +158,65 @@ new_session_screenshot <- function(
140158
stop("Invalid value for cliprect: ", cliprect)
141159
}
142160
} else {
143-
if (!is.null(cliprect) && !(is.numeric(cliprect) && length(cliprect) == 4)) {
144-
stop("`cliprect` must be a vector with four numbers, or a list of such vectors")
161+
if (
162+
!is.null(cliprect) && !(is.numeric(cliprect) && length(cliprect) == 4)
163+
) {
164+
stop(
165+
"`cliprect` must be a vector with four numbers, or a list of such vectors"
166+
)
145167
}
146168
}
147169

148170
s <- NULL
149171

150-
p <- chromote$new_session(wait_ = FALSE,
151-
width = vwidth,
152-
height = vheight
153-
)$
154-
then(function(session) {
155-
s <<- session
172+
p <- chromote$new_session(
173+
wait_ = FALSE,
174+
width = vwidth,
175+
height = vheight
176+
)$then(function(session) {
177+
s <<- session
156178

157-
if (!is.null(useragent)) {
158-
s$Network$setUserAgentOverride(userAgent = useragent)
159-
}
160-
res <- s$Page$loadEventFired(wait_ = FALSE)
161-
s$Page$navigate(url, wait_ = FALSE)
162-
res
163-
})$
164-
then(function(value) {
165-
if (delay > 0) {
166-
promises::promise(function(resolve, reject) {
167-
later::later(
168-
function() {
169-
resolve(value)
170-
},
171-
delay
172-
)
173-
})
174-
} else {
175-
value
176-
}
177-
})$
178-
then(function(value) {
179-
if (filetype == "png") {
180-
s$screenshot(
181-
filename = file, selector = selector, cliprect = cliprect,
182-
expand = expand, scale = zoom,
183-
show = FALSE, wait_ = FALSE
179+
if (!is.null(useragent)) {
180+
s$Network$setUserAgentOverride(userAgent = useragent)
181+
}
182+
res <- s$Page$loadEventFired(wait_ = FALSE)
183+
s$Page$navigate(url, wait_ = FALSE)
184+
res
185+
})$then(function(value) {
186+
if (delay > 0) {
187+
promises::promise(function(resolve, reject) {
188+
later::later(
189+
function() {
190+
resolve(value)
191+
},
192+
delay
184193
)
185-
186-
} else if (filetype == "pdf") {
187-
s$screenshot_pdf(filename = file, wait_ = FALSE)
188-
}
189-
})$
190-
then(function(value) {
191-
if (verbose) message(url, " screenshot completed")
192-
normalizePath(value)
193-
})$
194-
finally(function() {
195-
s$close()
196-
})
194+
})
195+
} else {
196+
value
197+
}
198+
})$then(function(value) {
199+
if (filetype == "png") {
200+
s$screenshot(
201+
filename = file,
202+
selector = selector,
203+
cliprect = cliprect,
204+
expand = expand,
205+
scale = zoom,
206+
show = FALSE,
207+
wait_ = FALSE
208+
)
209+
} else if (filetype == "pdf") {
210+
s$screenshot_pdf(filename = file, wait_ = FALSE)
211+
}
212+
})$then(function(value) {
213+
if (verbose) {
214+
message(url, " screenshot completed")
215+
}
216+
normalizePath(value)
217+
})$finally(function() {
218+
s$close()
219+
})
197220

198221
p
199222
}
@@ -207,7 +230,10 @@ file_url <- function(filename) {
207230
if (is_windows()) {
208231
paste0("file://", normalizePath(filename, mustWork = TRUE))
209232
} else {
210-
enc2utf8(paste0("file:///", normalizePath(filename, winslash = "/", mustWork = TRUE)))
233+
enc2utf8(paste0(
234+
"file:///",
235+
normalizePath(filename, winslash = "/", mustWork = TRUE)
236+
))
211237
}
212238
}
213239

@@ -218,13 +244,13 @@ is_mac <- function() Sys.info()[["sysname"]] == "Darwin"
218244
is_linux <- function() Sys.info()[["sysname"]] == "Linux"
219245

220246
long_to_wide <- function(x) {
221-
if (length(x) == 0)
247+
if (length(x) == 0) {
222248
return(x)
249+
}
223250

224251
lapply(seq_along(x[[1]]), function(n) {
225252
lapply(stats::setNames(names(x), names(x)), function(name) {
226253
x[[name]][[n]]
227254
})
228255
})
229256
}
230-

0 commit comments

Comments
 (0)