Index: openacs-4/packages/acs-templating/acs-templating.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/acs-templating.info,v
diff -u -N -r1.62 -r1.63
--- openacs-4/packages/acs-templating/acs-templating.info 29 Jan 2018 11:03:25 -0000 1.62
+++ openacs-4/packages/acs-templating/acs-templating.info 10 Mar 2018 18:59:33 -0000 1.63
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
Templating library.
2017-08-06
@@ -27,7 +27,7 @@
GPL version 2
3
-
+
Index: openacs-4/packages/acs-templating/tcl/head-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/head-procs.tcl,v
diff -u -N -r1.24 -r1.25
--- openacs-4/packages/acs-templating/tcl/head-procs.tcl 9 Mar 2018 10:22:29 -0000 1.24
+++ openacs-4/packages/acs-templating/tcl/head-procs.tcl 10 Mar 2018 18:59:33 -0000 1.25
@@ -14,7 +14,7 @@
namespace eval template::head {}
ad_proc -private template::reset_request_vars {} {
- Resets all global datastructures used to manage the head section of the
+ Resets all global data structures used to manage the head section of the
returned document. This should be called at the beginning of any request
handled by the templating system.
} {
@@ -28,6 +28,20 @@
set ::template::footers [list]
}
+ad_proc -public template::register_urn {
+ -urn:required
+ -resource:required
+} {
+
+ Register an urn for a resource. These urns provide a single place
+ for e.g updating references to external resources when switching
+ between a CDN and a local resource, or when a resource should be
+ updated.
+
+} {
+ set ::template::head::urn($urn) $resource
+}
+
ad_proc -public template::add_script {
{-async:boolean}
{-charset ""}
@@ -121,6 +135,14 @@
set async ""
}
+ #
+ # Replace potential urn in src with resolved value
+ #
+ set key ::template::head::urn($src)
+ if {[info exists $key]} {
+ set src [set $key]
+ }
+
if {$src eq ""} {
if {$script eq ""} {
error "You must supply either -src or -script."
@@ -545,6 +567,8 @@
if {$script ne ""} {
#
+ # We have an inline script.
+ #
# For the time being, not all browsers support
# nonces. According to the specs the added 'unsafe-inline',
# is ignored on browsers supporting nonces.
@@ -649,6 +673,19 @@
}
}
+ad_proc -private template::head::resolve_urn {
+ resource
+} {
+ Replace potential urn in provided resource name with resolved
+ value
+} {
+ set key ::template::head::urn($resource)
+ if {[info exists $key]} {
+ set resource [set $key]
+ }
+ return $resource
+}
+
ad_proc template::head::prepare_multirows {} {
Generate multirows for meta, css, scripts
Called only from blank-master.tcl
@@ -693,7 +730,7 @@
template::multirow append link \
$rel \
$type \
- $href \
+ [resolve_urn $href] \
$title \
$lang \
$media \
@@ -712,7 +749,7 @@
template::multirow append link \
$rel \
$type \
- $href \
+ [resolve_urn $href] \
$title \
$lang \
$media \
@@ -754,9 +791,10 @@
}
foreach {type src charset defer async content order crossorigin integrity} $scripts($name) {
+ ns_log notice "ADD order $order src $src"
template::multirow append headscript \
$type \
- $src \
+ [resolve_urn $src] \
$charset \
$defer \
$async \