Merge pull request #4069 from dokuwiki/debugbacktrace
[dokuwiki.git] / lib / exe / jquery.php
blob7b0fceb726dc0c2adeab1a30505751143d58d714
1 <?php
3 use dokuwiki\Cache\Cache;
5 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
6 if (!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching)
7 if (!defined('NL')) define('NL', "\n");
8 if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here
9 require_once(DOKU_INC . 'inc/init.php');
11 // MAIN
12 header('Content-Type: application/javascript; charset=utf-8');
13 jquery_out();
15 /**
16 * Delivers the jQuery JavaScript
18 * We do absolutely nothing fancy here but concatenating the different files
19 * and handling conditional and gzipped requests
21 * uses cache or fills it
23 function jquery_out()
25 $cache = new Cache('jquery', '.js');
26 $files = [
27 DOKU_INC . 'lib/scripts/jquery/jquery.min.js',
28 DOKU_INC . 'lib/scripts/jquery/jquery-ui.min.js'
30 $cache_files = $files;
31 $cache_files[] = __FILE__;
33 // check cache age & handle conditional request
34 // This may exit if a cache can be used
35 $cache_ok = $cache->useCache(['files' => $cache_files]);
36 http_cached($cache->cache, $cache_ok);
38 $js = '';
39 foreach ($files as $file) {
40 $js .= file_get_contents($file) . "\n";
42 stripsourcemaps($js);
44 http_cached_finish($cache->cache, $js);