Refactor font repo compiler so it can be reused

Includes changes to the generated repository file
because the script had not been run for last update.

Change-Id: I6b5d1ce980c6e5b42e36c0044729536b6b0ae4dc
This commit is contained in:
Niklas Laxström
2016-04-14 10:04:40 +02:00
parent 4c5263e3f0
commit 651f8bc1c3
5 changed files with 198 additions and 119 deletions

View File

@@ -0,0 +1,50 @@
<?php
/**
*
* @author Niklas Laxström
* @license GPL-2.0+
* @file
*/
// 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->mDescription = 'Creates JavaScript font repository.';
}
public function execute() {
$base = dirname( __DIR__ );
$compiler = new FontRepoCompiler(
"$base/data/fontrepo/fonts",
'../data/fontrepo/fonts/'
);
$list = $compiler->getRepository();
$json = json_encode( $list );
$js = <<<JAVASCRIPT
// Do not edit! This file is generated from data/fontrepo by data/fontrepo/scripts/compile.php
( function ( $ ) {
$.webfonts = $.webfonts || {};
$.webfonts.repository = $json;
}( jQuery ) );
JAVASCRIPT;
file_put_contents( "$base/resources/js/ext.uls.webfonts.repository.js", $js );
$this->output( "Done.\n" );
}
}
$maintClass = 'CompileFontRepo';
require_once DO_MAINTENANCE;