blob: 6df2cf4a294f3078dc3ac457db6234c5694240d1 (
plain)
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
46
47
48
49
50
51
52
53
54
|
<?php
/**
* @author Niklas Laxström
* @license GPL-2.0-or-later
* @file
*/
namespace UniversalLanguageSelector;
use FormatJson;
use Maintenance;
// Standard boilerplate to define $IP
if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
$IP = getenv( 'MW_INSTALL_PATH' );
} else {
$dir = __DIR__;
$IP = "$dir/../../..";
}
require_once "$IP/maintenance/Maintenance.php";
class CompileFontRepo extends Maintenance {
public function __construct() {
parent::__construct();
$this->addDescription( 'Creates JavaScript font repository.' );
}
public function execute() {
$base = dirname( __DIR__ );
$compiler = new FontRepoCompiler(
"$base/data/fontrepo/fonts",
'../data/fontrepo/fonts/'
);
$list = $compiler->getRepository();
$json = FormatJson::encode( $list, "\t" );
$js = <<<JAVASCRIPT
// Do not edit! This file is generated from data/fontrepo by scripts/compile-font-repo.php
( function () {
$.webfonts = $.webfonts || {};
$.webfonts.repository = $json;
}() );
JAVASCRIPT;
file_put_contents( "$base/resources/js/ext.uls.webfonts.repository.js", $js );
$this->output( "Done.\n" );
}
}
$maintClass = CompileFontRepo::class;
require_once RUN_MAINTENANCE_IF_MAIN;
|