mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 14:33:59 +00:00
edc5f38d4c
* CenterNode missing in ResourceLoader registry * UI classes and rangy not in static test/index.html * Transaction and TransactionProcessor listed twice Added a maintenance script that generates the <script> and <link> tags for all files in the same order everywhere. Change-Id: I5d22d33769b4e356e8065d295505f6f9a8b0bea8
108 lines
2.9 KiB
PHP
108 lines
2.9 KiB
PHP
<?php
|
|
|
|
$path = '../..';
|
|
|
|
if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
|
|
$path = getenv( 'MW_INSTALL_PATH' );
|
|
}
|
|
|
|
require_once( $path . '/maintenance/Maintenance.php' );
|
|
|
|
class MakeStaticLoader extends Maintenance {
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
|
|
$this->addOption( 'format', 'Custom format ("demo" or "test"), also sets ve-path', false, true );
|
|
$this->addOption( 'indent', 'Indentation prefix to use (number of tabs or a string)', false, true );
|
|
$this->addOption( 've-path', 'Path to "modules/"', false, true );
|
|
}
|
|
|
|
public function execute() {
|
|
global $wgResourceModules, $wgHtml5, $wgWellFormedXml;
|
|
|
|
$wgHtml5 = true;
|
|
$wgWellFormedXml = false;
|
|
|
|
$wgResourceModules['Dependencies'] = array(
|
|
'scripts' => array(
|
|
'jquery/jquery.js',
|
|
'jquery/jquery.json.js',
|
|
'jquery/jquery.multiSuggest.js',
|
|
'rangy/rangy-core.js',
|
|
'rangy/rangy-position.js',
|
|
),
|
|
);
|
|
|
|
$wgResourceModules['Standalone Init'] = array(
|
|
'styles' => array(
|
|
've/init/sa/styles/ve.init.sa.css',
|
|
),
|
|
'scripts' => array(
|
|
've/init/sa/ve.init.sa.js',
|
|
've/init/sa/ve.init.sa.Platform.js',
|
|
),
|
|
);
|
|
|
|
$format = $this->getOption( 'format', false );
|
|
$indent = $this->getOption( 'indent', 2 );
|
|
if ( is_numeric( $indent ) ) {
|
|
$indent = str_repeat( "\t", $indent );
|
|
}
|
|
$vePath = $this->getOption( 've-path',
|
|
$format === 'demo'
|
|
// From /demo/index.php
|
|
? '../../modules/'
|
|
// From /modules/ve/index.html
|
|
: '../../'
|
|
);
|
|
$self = isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['PHP_SELF'] : ( lcfirst( __CLASS__ ) . '.php' );
|
|
|
|
$head = $body = "";
|
|
|
|
$modules = array(
|
|
'Dependencies',
|
|
'ext.visualEditor.base',
|
|
'Standalone Init',
|
|
'ext.visualEditor.core',
|
|
);
|
|
foreach ( $modules as $module ) {
|
|
if ( !isset( $wgResourceModules[$module] ) ) {
|
|
continue;
|
|
}
|
|
$headAdd = $bodyAdd = '';
|
|
$registry = $wgResourceModules[$module];
|
|
if ( isset( $registry['styles'] ) && $format !== 'test' ){
|
|
foreach ($registry['styles'] as $style) {
|
|
$headAdd .= $indent . Html::element( 'link', array( 'rel' => 'stylesheet', 'href' => "$vePath$style" ) ) . "\n";
|
|
}
|
|
}
|
|
if ( isset( $registry['scripts'] ) ) {
|
|
foreach ($registry['scripts'] as $script) {
|
|
$bodyAdd .= $indent . Html::element( 'script', array( 'src' => "$vePath$script" ) ) . "\n";
|
|
}
|
|
}
|
|
if ( isset( $registry['debugScripts'] ) ) {
|
|
foreach ($registry['debugScripts'] as $script) {
|
|
$bodyAdd .= $indent . Html::element( 'script', array( 'src' => "$vePath$script" ) ) . "\n";
|
|
}
|
|
}
|
|
if ( $headAdd ) {
|
|
$head .= "$indent<!-- $module -->\n$headAdd";
|
|
}
|
|
if ( $bodyAdd ) {
|
|
$body .= "$indent<!-- $module -->\n$bodyAdd";
|
|
}
|
|
}
|
|
if ( $head ) {
|
|
echo "<head>\n\n$indent<!-- Generated by $self -->\n$head\n\n</head>";
|
|
}
|
|
if ( $body ) {
|
|
echo "<body>\n\n$indent<!-- Generated by $self -->\n$body\n\n</body>\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
$maintClass = 'MakeStaticLoader';
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|