File: jquery.php

package info (click to toggle)
dokuwiki 2025-05-14.a%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,920 kB
  • sloc: php: 99,723; javascript: 3,741; sh: 599; makefile: 70; xml: 34
file content (45 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php

use dokuwiki\Cache\Cache;

if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
if (!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching)
if (!defined('NL')) define('NL', "\n");
if (!defined('DOKU_DISABLE_GZIP_OUTPUT')) define('DOKU_DISABLE_GZIP_OUTPUT', 1); // we gzip ourself here
require_once(DOKU_INC . 'inc/init.php');

// MAIN
header('Content-Type: application/javascript; charset=utf-8');
jquery_out();

/**
 * Delivers the jQuery JavaScript
 *
 * We do absolutely nothing fancy here but concatenating the different files
 * and handling conditional and gzipped requests
 *
 * uses cache or fills it
 */
function jquery_out()
{
    $cache = new Cache('jquery', '.js');
    $files = [
        '/usr/share/javascript/jquery/jquery.min.js',
        '/usr/share/javascript/jquery-ui/jquery-ui.min.js',
    ];
    $cache_files = $files;
    $cache_files[] = __FILE__;

    // check cache age & handle conditional request
    // This may exit if a cache can be used
    $cache_ok = $cache->useCache(['files' => $cache_files]);
    http_cached($cache->cache, $cache_ok);

    $js = '';
    foreach ($files as $file) {
        $js .= file_get_contents($file) . "\n";
    }
    stripsourcemaps($js);

    http_cached_finish($cache->cache, $js);
}