mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-14 10:04:52 +00:00
4fa57b469a
Although $.toJSON optimises heavily for modern browsers (it becomes a direct reference to JSON.stringify), we still load the extra plugin. JSON is specified as part of ECMAScript 5, but most browsers supported this one before they supported the rest of ES5. http://caniuse.com/#search=JSON Cut off for native JSON is IE7, Firefox 3.0 (3.6 supports it) and Safari 3. Not any of our concern as VE will most likely never support those (certainly not at this point in time, and less likely as time goes on). Change-Id: I4e8f26ac94763fa38d29e41264de0247f53a21e5
126 lines
3.5 KiB
PHP
126 lines
3.5 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( 'target', 'Which target to use ("demo" or "test"). Default: false', false, true );
|
|
$this->addOption( 'indent', 'Indentation prefix to use (number of tabs or a string)', false, true );
|
|
$this->addOption( 've-path', 'Override path to "/modules/". Default by --target', false, true );
|
|
}
|
|
|
|
public function execute() {
|
|
global $wgResourceModules, $wgHtml5, $wgWellFormedXml;
|
|
|
|
$wgHtml5 = true;
|
|
$wgWellFormedXml = false;
|
|
|
|
$target = $this->getOption( 'target', 'demo' );
|
|
$indent = $this->getOption( 'indent', 2 );
|
|
if ( is_numeric( $indent ) ) {
|
|
$indent = str_repeat( "\t", $indent );
|
|
}
|
|
// Path to /modules/
|
|
$vePath = $this->getOption( 've-path',
|
|
$target === 'demo'
|
|
// From /demos/ve/index.php
|
|
? '../../modules/'
|
|
// From /modules/ve/test/index.html
|
|
: '../../'
|
|
);
|
|
|
|
$wgResourceModules['Dependencies'] = array(
|
|
'scripts' => array(
|
|
'jquery/jquery.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',
|
|
),
|
|
'bodyAdd' => '<script>
|
|
<?php
|
|
require( \'' . $vePath . '../VisualEditor.i18n.php\' );
|
|
echo \'ve.init.platform.addMessages( \' . json_encode( $messages[\'en\'] ) . \');\';
|
|
?>
|
|
ve.init.platform.setModulesUrl( \'' . $vePath . '\' );
|
|
</script>'
|
|
);
|
|
|
|
$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] ) ) {
|
|
echo "\nError: File group $module\n not found!\n";
|
|
exit( 1 );
|
|
}
|
|
$registry = $wgResourceModules[$module];
|
|
|
|
$headAdd = $bodyAdd = '';
|
|
|
|
if ( isset( $registry['styles'] ) && $target !== '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 ( isset( $registry['headAdd'] ) ) {
|
|
$headAdd .= $indent . implode( "\n$indent", explode( "\n", $registry['headAdd'] ) ) . "\n";
|
|
}
|
|
if ( isset( $registry['bodyAdd'] ) ) {
|
|
$bodyAdd .= $indent . implode( "\n$indent", explode( "\n", $registry['bodyAdd'] ) ) . "\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 );
|