Index: openacs-4/packages/acs-tcl/acs-tcl.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/acs-tcl.info,v diff -u -N -r1.89 -r1.90 --- openacs-4/packages/acs-tcl/acs-tcl.info 2 Aug 2018 11:20:04 -0000 1.89 +++ openacs-4/packages/acs-tcl/acs-tcl.info 3 Aug 2018 09:46:35 -0000 1.90 @@ -9,7 +9,7 @@ f t - + OpenACS The Kernel Tcl API library. 2017-08-06 @@ -18,7 +18,7 @@ GPL version 2 3 - + 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-tcl/lib/check-installed.adp 3 Aug 2018 09:46:35 -0000 1.1 @@ -0,0 +1,15 @@ +

+The current version of the @resource_name@ is @version@. +

This version of the @resource_name@ is installed locally +under @resources@. +

In the current installation the @resource_name@ is used via CDN @cdn@. + +

Do you want to download + version @version@ of @resource_name@ to your file system?

+ + +

The directory @path@ is NOT writable for the server. In + order to be able to download the @resource_name@ via this web interface, + please change the permissions so that OpenACS can write to it.

+
+ 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 -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-tcl/lib/check-installed.tcl 3 Aug 2018 09:46:35 -0000 1.1 @@ -0,0 +1,46 @@ +ad_include_contract { + + ADP include for checking if some resources are installed locally, + and if not to provide the option to download these resources. + + @param resource_info dict containing at least resourceDir and cdn + @param version version of the package + + @author Gustaf Neumann +} { + {resource_info} + {version ""} + {download_url "download"} +} + +set resource_dir [dict get $resource_info resourceDir] +set cdn [dict get $resource_info cdn] +set resource_name [dict get $resource_info resourceName] + +# +# Check, if the resources are already installed. +# +set is_installed [::util::resources::is_installed_locally \ + -resource_info $resource_info \ + -version_dir $version ] +if {$is_installed} { + # + # Tell the users, where the resources are installed. + # + set resources $resource_dir/$version + +} else { + # + # Check, if we can install the resources locally. + # + set writable [util::resources::can_install_locally \ + -resource_info $resource_info \ + -version_dir $version] + if {!$writable} { + # + # If we cannot install locally, tell the user were we want to + # install. + # + set path $resource_dir/$version + } +} Index: openacs-4/packages/acs-tcl/lib/page-error.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/lib/page-error.tcl,v diff -u -N -r1.18 -r1.19 --- openacs-4/packages/acs-tcl/lib/page-error.tcl 28 Jun 2018 15:48:37 -0000 1.18 +++ openacs-4/packages/acs-tcl/lib/page-error.tcl 3 Aug 2018 09:46:35 -0000 1.19 @@ -1,10 +1,7 @@ -# /packages/acs-tcl/lib/page-error.tcl - ad_page_contract { @author Victor Guerra (guerra@galileo.edu) @creation-date 2005-02-03 - @arch-tag: 983f3d87-40c8-4327-8873-c6a01ba7d875 @cvs-id $Id$ } { {bug_number ""} 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 -N -r1.172 -r1.173 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 2 Aug 2018 13:11:39 -0000 1.172 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 3 Aug 2018 09:46:35 -0000 1.173 @@ -26,7 +26,7 @@ set pdfinfo [util::which pdfinfo] if {$pdfinfo eq ""} { - error "pdfinfo command not found on the system" + error "the command 'pdfinfo' is not found on the system" } set retval [dict create] @@ -1546,7 +1546,7 @@ @param message A message to display to the user. See util_user_message. @param html Set this flag if your message contains HTML. If specified, you're responsible for proper quoting of everything in your message. Otherwise, we quote it for you. - @param allow_complete_url By default we disallow redirecting to urls outside the current host. This is based on the currently set host header or the host name in the config file if there is no host header. Set allow_complete_url if you are redirecting to a known safe external web site. This prevents redirecting to a site by URL query hacking. + @param allow_complete_url By default we disallow redirecting to URLs outside the current host. This is based on the currently set host header or the host name in the config file if there is no host header. Set allow_complete_url if you are redirecting to a known safe external web site. This prevents redirecting to a site by URL query hacking. @see util_user_message @see ad_script_abort @@ -2506,7 +2506,7 @@ {_text ""} } { Modify a string so that it is suited as a well formatted URL path element. - Also, if given a list of existing urls it can catch duplicate or optionally + Also, if given a list of existing URLs it can catch duplicate or optionally create an unambiguous url by appending a dash and a digit.

@@ -4024,8 +4024,10 @@ # decide between CDN installations an local installations. # # The configuration information is provided via dict named resource_info, -# containing typically the following fields: +# containing typically the following fields (all in Camel case style): # +# - resourceName: Name for the resources +# where the resource are to be stored # - resourceDir: the top-level directory on the local disk, # where the resource are to be stored # - cdn: the CDN URL prefix for obtaining the content (e.g. //maxcdn.bootstrapcdn.com/bootstrap) @@ -4036,8 +4038,9 @@ # - prefix: used for resolving the files on the server; might either point # to the CDN or to locally installed files (typically /resources/...) # -# Optionally, the dict can contain more fields, like e.g. an urnMap for mapping -# urls to resources (see e.g. openacs-bootstrap4-theme) +# Optionally, the dict can contain more fields, like e.g. a "urnMap" +# for mapping URLs to resources (see e.g. openacs-bootstrap4-theme) or +# "downloadURLs" for downloading full packages. # namespace eval util::resources { @@ -4057,11 +4060,21 @@ } { set installed 1 set resource_dir [dict get $resource_info resourceDir] + set downloadFiles {} + ns_log notice "check downloadURLs <[dict exists $resource_info downloadURLs]> // [lsort [dict keys $resource_info]]" + if {[dict exists $resource_info downloadURLs]} { + ns_log notice "we have downloadURLs <[dict get $resource_info downloadURLs]>" + foreach url [dict get $resource_info downloadURLs] { + lappend downloadFiles [file tail $url] + } + } set files [concat \ [dict get $resource_info cssFiles] \ [dict get $resource_info jsFiles] \ [dict get $resource_info extraFiles] \ + $downloadFiles \ ] + ns_log notice "check files <$files>" foreach file $files { if {$version_dir eq ""} { set path $resource_dir/$file @@ -4192,6 +4205,25 @@ exec $gzip -9 -k $local_path/$file } } + + if {[dict exists $resource_info downloadURLs]} { + # + # For downloadURLs, just handle here the download. How to + # decompress these archives and what to do with these to + # install it properly is handled by package-speficic + # downloaders, which might call this function. + # + foreach url [dict get $resource_info downloadURLs] { + set result [util::http::get -url $url -spool] + if {[dict get $result status] == 200} { + set fn [dict get $result file] + } else { + error "download from $url failed: $result" + } + } + set file [file tail $url] + file rename -force -- $fn $local_path/$file + } } }