Index: openacs-4/packages/acs-tcl/lib/check-installed.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/lib/check-installed.adp,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/acs-tcl/lib/check-installed.adp 3 Sep 2024 15:37:34 -0000 1.2
+++ openacs-4/packages/acs-tcl/lib/check-installed.adp 5 Jun 2025 13:42:52 -0000 1.3
@@ -1,7 +1,7 @@
The configured version of @resource_name@ is
@version@
-(newest version on cdnjs: @newest_version@).
+ (newest version on @cdn@: @newest_version@).
- You might modify the parameter value or
Index: openacs-4/packages/acs-tcl/lib/check-installed.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/lib/check-installed.tcl,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/acs-tcl/lib/check-installed.tcl 3 Sep 2024 15:37:34 -0000 1.4
+++ openacs-4/packages/acs-tcl/lib/check-installed.tcl 5 Jun 2025 13:42:52 -0000 1.5
@@ -93,7 +93,6 @@
set version_segment [::util::resources::version_segment -resource_info $resource_info]
set newest_version [::util::resources::cdnjs_get_newest_version -resource_info $resource_info]
-
#
# In case, we have an explicit versionCheckURL, use this.
# Otherwise, try to derive it from the versionCheckAPI
@@ -103,8 +102,9 @@
} elseif {[dict exists $resource_info versionCheckAPI]} {
set versionCheckAPI [dict get $resource_info versionCheckAPI]
dict with versionCheckAPI {
- if {$cdn eq "cdnjs"} {
- set versionCheckURL https://cdnjs.com/libraries/$library
+ switch $cdn {
+ cdnjs {set versionCheckURL https://cdnjs.com/libraries/$library}
+ jsdelivr {set versionCheckURL https://cdn.jsdelivr.net/npm/$library}
}
}
}
Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v
diff -u -r1.204 -r1.205
--- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 24 Apr 2025 15:56:15 -0000 1.204
+++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 5 Jun 2025 13:42:52 -0000 1.205
@@ -4287,8 +4287,10 @@
#set result [util::http::get -url $location -spool]
set host [dict get [ns_parseurl $url] host]
set result [ns_http run -hostname $host -spoolsize 1 $location]
+ ns_log notice ... redirected download results in with status code [dict get $result status]
if {[dict get $result status] == 200} {
set fn [dict get $result file]
+ ns_log notice ... redirected download is: $fn size [file size $fn]
}
}
default {
@@ -4299,6 +4301,7 @@
if {$fn eq ""} {
error "download from $url failed: $result"
}
+ #ns_log notice download_helper returns $result
return $result
}
@@ -4345,9 +4348,12 @@
set download_prefix https:[dict get $resource_info cdn]
set local_path $resource_dir
+ #ns_log notice UTILITY uses resource_dir '$local_path'
+
if {$version_segment ne ""} {
append local_path /$version_segment
append download_prefix /$version_segment
+ #ns_log notice UTILITY adds to local_path '/$version_segment'
}
if {![ad_file writable $local_path]} {
file mkdir $local_path
@@ -4371,18 +4377,21 @@
set result [download_helper -url $download_prefix/$file]
#ns_log notice "... returned status code [dict get $result status]"
set fn [dict get $result file]
+ #ns_log notice "... returned file $fn"
set local_root [ad_file dirname $local_path/$file]
if {![ad_file isdirectory $local_root]} {
file mkdir $local_root
}
file rename -force -- $fn $local_path/$file
+ ns_log notice "... renamed $fn to $local_path/$file"
#
# Remove potentially stale gzip file.
#
if {[ad_file exists $local_path/$file.gz]} {
file delete -- $local_path/$file.gz
+ ns_log notice "... removed stale file $local_path/$file.gz"
}
#
@@ -4410,10 +4419,11 @@
# downloaders, which might call this function.
#
foreach url [dict get $resource_info downloadURLs] {
- ns_log notice "... downloading from URL: $url"
+ ns_log notice "... download via downloadURL: $url"
set result [download_helper -url $url]
set fn [dict get $result file]
set file [ad_file tail $url]
+ ns_log notice "... downloadURL rename file $fn to $local_path/$file"
file rename -force -- $fn $local_path/$file
}
}
@@ -4533,29 +4543,46 @@
dict with resource_info {
set library [dict get $versionCheckAPI library]
#ns_log notice ... versionCheckAPI $versionCheckAPI configuredVersion $configuredVersion
- if {[dict get $versionCheckAPI cdn] eq "cdnjs"} {
- set url [::util::resources::cdnjs_version_API \
- -library $library \
- -count [dict get $versionCheckAPI count]]
- set json [http_get_with_default \
- -url $url \
- -key versionCheck-$library \
- -default {{"results": ""}}]
- set jsonDict [util::json2dict $json]
- #ns_log notice "=== jsonDict $library: $jsonDict"
- foreach entry [dict get $jsonDict results] {
- #ns_log notice "... $library compare with '[dict get $entry name]' -> [expr {[dict get $entry name] eq $library}]"
- if {[dict get $entry name] eq $library} {
- set version [dict get $entry version]
- break
+ set jsonURL [::util::resources::cdnjs_version_API \
+ -source [dict get $versionCheckAPI cdn] \
+ -library $library \
+ -count [dict get $versionCheckAPI count]]
+
+ switch [dict get $versionCheckAPI cdn] {
+ cdnjs {
+ set json [http_get_with_default \
+ -url $jsonURL \
+ -key versionCheck-$library \
+ -default {{"results": ""}}]
+ set jsonDict [util::json2dict $json]
+ #ns_log notice "=== jsonDict $library: $jsonDict"
+ foreach entry [dict get $jsonDict results] {
+ #ns_log notice "... $library compare with '[dict get $entry name]' -> [expr {[dict get $entry name] eq $library}]"
+ if {[dict get $entry name] eq $library} {
+ set version [dict get $entry version]
+ break
+ }
}
}
+ jsdelivr {
+ set json [http_get_with_default \
+ -url $jsonURL \
+ -key versionCheck-$library \
+ -default {{"tags": {"latest": "unknown"}}}]
+ set jsonDict [util::json2dict $json]
+ #ns_log notice "=== jsonDict $library: $jsonDict"
+ set version [lindex [dict get $jsonDict tags] 1]
+ }
+ default {
+ error "unknown versionCheckAPI: '[dict get $versionCheckAPI cdn]'"
+ }
}
}
return $version
}
ad_proc -public ::util::resources::cdnjs_version_API {
+ {-source:required}
{-library:required}
{-count:int 1}
} {
@@ -4564,7 +4591,14 @@
the name under which the package is available from cdnjs.
} {
- return https://api.cdnjs.com/libraries?search=$library&search_fields=name&fields=filename,description,version&limit=$count
+ switch $source {
+ cdnjs {
+ return https://api.cdnjs.com/libraries?search=$library&search_fields=name&fields=filename,description,version&limit=$count
+ }
+ jsdelivr {
+ return https://data.jsdelivr.com/v1/packages/npm/$library
+ }
+ }
}