2012-10-16 14:03:26 +00:00
|
|
|
<?php
|
2013-02-26 15:06:16 +00:00
|
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
|
|
if ( $IP === false ) {
|
|
|
|
$IP = __DIR__ . '/../../..';
|
2012-10-16 14:03:26 +00:00
|
|
|
}
|
2013-02-26 15:06:16 +00:00
|
|
|
require_once( $IP . '/maintenance/Maintenance.php' );
|
2012-10-16 14:03:26 +00:00
|
|
|
|
|
|
|
class MakeStaticLoader extends Maintenance {
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
parent::__construct();
|
|
|
|
|
2012-12-04 07:54:49 +00:00
|
|
|
$this->addOption( 'target', 'Which target to use ("demo" or "test"). Default: false', false, true );
|
2012-10-16 14:03:26 +00:00
|
|
|
$this->addOption( 'indent', 'Indentation prefix to use (number of tabs or a string)', false, true );
|
2012-12-04 07:54:49 +00:00
|
|
|
$this->addOption( 've-path', 'Override path to "/modules/". Default by --target', false, true );
|
2013-02-09 01:33:48 +00:00
|
|
|
$this->addOption( 'section', 'head, body or both', false, true );
|
2012-10-16 14:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
global $wgResourceModules, $wgHtml5, $wgWellFormedXml;
|
|
|
|
|
|
|
|
$wgHtml5 = true;
|
|
|
|
$wgWellFormedXml = false;
|
|
|
|
|
2013-02-09 01:33:48 +00:00
|
|
|
$section = $this->getOption( 'section', 'both' );
|
2012-12-04 07:54:49 +00:00
|
|
|
$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
|
|
|
|
: '../../'
|
|
|
|
);
|
|
|
|
|
2012-10-16 14:03:26 +00:00
|
|
|
$wgResourceModules['Dependencies'] = array(
|
|
|
|
'scripts' => array(
|
|
|
|
'jquery/jquery.js',
|
|
|
|
'rangy/rangy-core.js',
|
|
|
|
'rangy/rangy-position.js',
|
2013-03-18 11:31:14 +00:00
|
|
|
'unicodejs/unicodejs.js',
|
|
|
|
'unicodejs/unicodejs.textstring.js',
|
|
|
|
'unicodejs/unicodejs.wordbreak.groups.js',
|
|
|
|
'unicodejs/unicodejs.wordbreak.js',
|
2012-10-16 14:03:26 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$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',
|
2013-03-15 00:01:01 +00:00
|
|
|
've/init/sa/ve.init.sa.Target.js',
|
2012-10-16 14:03:26 +00:00
|
|
|
),
|
2013-02-09 01:33:48 +00:00
|
|
|
'headAdd' => '
|
|
|
|
<script>
|
|
|
|
if ( window.devicePixelRatio > 1 ) {
|
|
|
|
document.write( \'<link rel="stylesheet" href="' . $vePath . 've/ui/styles/ve.ui.Icons-vector.css">\' );
|
|
|
|
} else {
|
|
|
|
document.write( \'<link rel="stylesheet" href="' . $vePath . 've/ui/styles/ve.ui.Icons-raster.css">\' );
|
|
|
|
}
|
|
|
|
</script>',
|
2012-12-04 07:54:49 +00:00
|
|
|
'bodyAdd' => '<script>
|
|
|
|
<?php
|
|
|
|
require( \'' . $vePath . '../VisualEditor.i18n.php\' );
|
2013-02-09 01:33:48 +00:00
|
|
|
echo \'ve.init.platform.addMessages( \' . json_encode( $messages[\'en\'] ) . \');\' . "\n";
|
2012-12-04 07:54:49 +00:00
|
|
|
?>
|
|
|
|
ve.init.platform.setModulesUrl( \'' . $vePath . '\' );
|
|
|
|
</script>'
|
2012-10-16 14:03:26 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$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] ) ) {
|
2012-12-04 07:54:49 +00:00
|
|
|
echo "\nError: File group $module\n not found!\n";
|
|
|
|
exit( 1 );
|
2012-10-16 14:03:26 +00:00
|
|
|
}
|
|
|
|
$registry = $wgResourceModules[$module];
|
2012-12-04 07:54:49 +00:00
|
|
|
|
|
|
|
$headAdd = $bodyAdd = '';
|
|
|
|
|
|
|
|
if ( isset( $registry['styles'] ) && $target !== 'test' ){
|
2012-10-16 14:03:26 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
2012-12-04 07:54:49 +00:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2012-10-16 14:03:26 +00:00
|
|
|
if ( $headAdd ) {
|
|
|
|
$head .= "$indent<!-- $module -->\n$headAdd";
|
|
|
|
}
|
|
|
|
if ( $bodyAdd ) {
|
|
|
|
$body .= "$indent<!-- $module -->\n$bodyAdd";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( $head ) {
|
2013-02-09 01:33:48 +00:00
|
|
|
if ( $section === 'both' ) {
|
|
|
|
echo "<head>\n\n$indent<!-- Generated by $self -->\n$head\n\n</head>";
|
|
|
|
} elseif ( $section === 'head' ) {
|
|
|
|
echo $head;
|
|
|
|
}
|
2012-10-16 14:03:26 +00:00
|
|
|
}
|
|
|
|
if ( $body ) {
|
2013-02-09 01:33:48 +00:00
|
|
|
if ( $section === 'both' ) {
|
|
|
|
echo "<body>\n\n$indent<!-- Generated by $self -->\n$body\n\n</body>\n";
|
|
|
|
} elseif ( $section === 'body' ) {
|
|
|
|
echo $body;
|
|
|
|
}
|
2012-10-16 14:03:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$maintClass = 'MakeStaticLoader';
|
|
|
|
require_once( RUN_MAINTENANCE_IF_MAIN );
|