summaryrefslogtreecommitdiff
path: root/itjs.class
diff options
context:
space:
mode:
authorUrban Müller2014-08-29 14:06:45 +0200
committerUrban Müller2014-08-29 14:06:45 +0200
commit02389eb2bdc9ffaf232039a766e274c1ac4e9d91 (patch)
tree996ec2c56908d364ca3ec47e99da7a86ed94752a /itjs.class
parent4aa2127d920aa3eb2d56faf8b96d599c088e72b4 (diff)
downloaditools-02389eb2bdc9ffaf232039a766e274c1ac4e9d91.tar.gz
itools-02389eb2bdc9ffaf232039a766e274c1ac4e9d91.tar.bz2
itools-02389eb2bdc9ffaf232039a766e274c1ac4e9d91.zip
support appending checksum to url
Diffstat (limited to 'itjs.class')
-rw-r--r--itjs.class12
1 files changed, 11 insertions, 1 deletions
diff --git a/itjs.class b/itjs.class
index 207fc6c..4ce0616 100644
--- a/itjs.class
+++ b/itjs.class
@@ -188,12 +188,22 @@ static function strip($code)
*/
static function checksum($fnlist)
{
- $filenames = array_merge(is_array($fnlist) ? $fnlist : itjs::filenames($fnlist), array("/www/lib.search.ch/var/jquery-ui/dist/minified/jquery.ui.core.min.js", "/www/lib.search.ch/var/jquery/dist/jquery.min.js"));
+ $filenames = array_merge(is_array($fnlist) ? $fnlist : itjs::filenames($fnlist), array("/www/lib.search.ch/var/jquery-ui/dist/minified/jquery.ui.core.min.js", "/www/lib.search.ch/var/jquery/dist/jquery.min.js")); # jquery files included by lib/jquery.js
$key = "itjs_" . md5(join("", it::map('"$v" . @filemtime("$v")', $filenames)));
return it_cache::get($key) ?: it_cache::put($key, substr(md5(self::filecontents($filenames, false)), 0, 8));
}
+function crcurl($url)
+{
+ if (it::match('^http', $url)) # remote url, must fetch to crc
+ $fn = it_url::get_cache(array('url' => $url, 'maxage' => 3600));
+ else
+ $fn = ($path = it::match("^//lib(/.*)", $url)) ? "/www/lib.search.ch" . $path : $GLOBALS['ULTRAHOME'] . $url;
+
+ return it::match('#', $url) ? U(trim($url, "#")) : U($url, array('c' => self::checksum([$fn])));
+}
+
}
?>