jenkins-bot has submitted this change and it was merged.

Change subject: Drop ResourceLoaderTemplateModule and mw.mantle.template
......................................................................


Drop ResourceLoaderTemplateModule and mw.mantle.template

* Nothing is using it any more.
* Drop dependency on ext.mantle.templates
* Remove ResourceLoaderTemplateModule
* Remove mw.mantle.template interface

Dependency: I2c2db7fe162d001b223ac10f9ed493669abb81d7
Change-Id: I69f993f7ca0a98acb592499a002d4f678c4ff0f9
---
M Mantle.php
M includes/Hooks.php
D includes/ResourceLoaderTemplateModule.php
M includes/Resources.php
D javascripts/common/templates.js
M javascripts/common/templates/hogan.js
D tests/ResourceLoaderTemplateModuleTest.php
D tests/javascripts/common/test_templates.js
D tests/templates/template.html
D tests/templates/template2.html
D tests/templates/template_awesome.handlebars
11 files changed, 3 insertions(+), 409 deletions(-)

Approvals:
  Phuedx: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Mantle.php b/Mantle.php
index d60a716..6fd764c 100644
--- a/Mantle.php
+++ b/Mantle.php
@@ -22,7 +22,6 @@
 $autoloadClasses = array (
        'MantleHooks' => 'Hooks',
        'ResourceLoaderParsedMessageModule' => 
'ResourceLoaderParsedMessageModule',
-       'ResourceLoaderTemplateModule' => 'ResourceLoaderTemplateModule',
 );
 
 foreach ( $autoloadClasses as $className => $classFilename ) {
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 6702992..3e44abe 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -25,7 +25,6 @@
                $files = array_merge( $files,
                        array_map( $callback,
                                array(
-                                       'ResourceLoaderTemplateModuleTest.php',
                                        
'ResourceLoaderParsedMessageModuleTest.php',
                                )
                        )
diff --git a/includes/ResourceLoaderTemplateModule.php 
b/includes/ResourceLoaderTemplateModule.php
deleted file mode 100644
index 75a16c7..0000000
--- a/includes/ResourceLoaderTemplateModule.php
+++ /dev/null
@@ -1,149 +0,0 @@
-<?php
-/**
- * ResourceLoaderModule subclass which supports templates
- */
-
-/**
- * ResourceLoaderTemplateModule subclass
- * A deprecated module for hacking templates into ResourceLoader.
- * Use ResourceLoaderFileModule or ResourceLoaderParsedMessageModule instead.
- * @deprecated
- */
-class ResourceLoaderTemplateModule extends ResourceLoaderParsedMessageModule {
-       /** @var array Saves a list of the templates named by the modules. */
-       protected $legacyTemplates = array();
-       /** @var string The local path to where templates are located, see 
__construct() */
-       protected $localTemplateBasePath = '';
-
-       /**
-        * @var array Cache for mtime of templates
-        * @example array( [hash] => [mtime], [hash] => [mtime], ... )
-        */
-       protected $templateModifiedTime = array();
-
-       /**
-        * Registers core modules and runs registration hooks.
-        * @param $options List of options; if not given or empty, an empty 
module will be constructed
-        */
-       public function __construct( $options ) {
-               foreach ( $options as $member => $option ) {
-                       switch ( $member ) {
-                               case 'localTemplateBasePath':
-                                       $this->{$member} = (string) $option;
-                                       break;
-                               case 'templates':
-                                       $this->hasHackedScriptMode = true;
-                                       $this->legacyTemplates = (array)$option;
-                                       break;
-                       }
-               }
-
-               parent::__construct( $options );
-       }
-
-       /**
-        * This prevents Mantle from exploding when templates land in core.
-        * @return array List of template names
-        */
-       function getTemplates() {
-               return array();
-       }
-
-       /**
-        * Returns the templates named by the modules
-        * Each template has a corresponding html file in includes/templates/
-        * @return array List of template names
-        */
-       function getTemplateNames() {
-               return $this->legacyTemplates;
-       }
-
-       /**
-        * Get the path to load templates from.
-        * @param string $name name of template including file extension
-        * @return string
-        */
-       protected function getLocalTemplatePath( $name ) {
-               // @FIXME: Deprecate usage of template without file extension.
-               return "{$this->localTemplateBasePath}/$name";
-       }
-
-       /**
-        * Takes named templates by the module and adds them to the JavaScript 
output
-        *
-        * @return string JavaScript code
-        */
-       function getTemplateScript() {
-               $js = '';
-               $templates = $this->getTemplateNames();
-
-               foreach( $templates as $templateName ) {
-                       $localPath = $this->getLocalTemplatePath( $templateName 
);
-                       if ( file_exists( $localPath ) ) {
-                               $content = file_get_contents( $localPath );
-                               $js .= Xml::encodeJsCall( 
'mw.mantle.template.add', array( $templateName, $content ) );
-                       } else {
-                               $msg = __METHOD__.": template not found: 
\"$templateName\"";
-                               $js .= Xml::encodeJsCall( 'throw', array( $msg 
) );
-                       }
-               }
-               return $js;
-       }
-
-       /**
-        * Gets all scripts for a given context concatenated together including 
processed messages
-        *
-        * @param ResourceLoaderContext $context Context in which to generate 
script
-        * @return string JavaScript code for $context
-        */
-       public function getScript( ResourceLoaderContext $context ) {
-               $deprecationWarning .= Xml::encodeJsCall( 'mw.log.warn',
-                       array( 'ResourceLoaderTemplateModule is deprecated 
please use ResourceLoaderFileModule for ' . $this->getName() )
-               );
-               $script = parent::getScript( $context );
-               return $deprecationWarning . $this->getTemplateScript() . 
$script;
-       }
-
-       /**
-        * Checks whether any templates used by module have changed
-        *
-        * @param ResourceLoaderContext $context Context in which to generate 
script
-        * @return int UNIX timestamp
-        */
-       public function getModifiedTimeTemplates( ResourceLoaderContext 
$context ) {
-               $hash = $context->getHash();
-               if ( isset( $this->templateModifiedTime[$hash] ) ) {
-                       $tlm = $this->templateModifiedTime[$hash];
-               } else {
-                       // Get local paths to all templates
-                       $files = array_map(
-                               array( $this, 'getLocalTemplatePath' ),
-                               $this->getTemplateNames()
-                       );
-
-                       // Store for quicker future lookup
-                       if ( count( $files ) === 0 ) {
-                               $tlm = 1;
-                       } else {
-                               // check the last modified time of them
-                               wfProfileIn( __METHOD__ . '-filemtime' );
-                               $tlm = max( array_map( array( __CLASS__, 
'safeFilemtime' ), $files ) );
-                               wfProfileOut( __METHOD__ . '-filemtime' );
-                       }
-                       // store for future lookup
-                       $this->templateModifiedTime[$hash] = $tlm;
-               }
-               return $tlm;
-       }
-
-       /**
-        * Checks whether any resources used by module have changed
-        *
-        * @param ResourceLoaderContext $context in which to generate script
-        * @return int UNIX timestamp
-        */
-       public function getModifiedTime( ResourceLoaderContext $context ) {
-               return max( parent::getModifiedTime( $context ),
-                       $this->getModifiedTimeTemplates( $context ) );
-       }
-}
diff --git a/includes/Resources.php b/includes/Resources.php
index c1c14fb..7eed30f 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -38,18 +38,9 @@
                        'ext.mantle',
                ),
        ),
-       'ext.mantle.templates' => $wgMantleResourceBoilerplate + array(
-               'dependencies' => array(
-                       'ext.mantle',
-               ),
-               'scripts' => array(
-                       'javascripts/common/templates.js',
-               ),
-       ),
        'ext.mantle.hogan' => $wgMantleResourceBoilerplate + array(
                'dependencies' => array(
                        'mediawiki.template',
-                       'ext.mantle.templates',
                ),
                'scripts' => array(
                        'javascripts/externals/hogan.js',
@@ -78,7 +69,7 @@
        'ext.mantle.views' => $wgMantleResourceBoilerplate + array(
                'dependencies' => array(
                        'ext.mantle.oo',
-                       'ext.mantle.templates',
+                       'mediawiki.template',
                ),
                'scripts' => array(
                        'javascripts/common/View.js',
diff --git a/javascripts/common/templates.js b/javascripts/common/templates.js
deleted file mode 100644
index dfe2954..0000000
--- a/javascripts/common/templates.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * A wrapper for templates. No longer supported use mw.template instead.
- * @singleton
- * @class mw.mantle.template
- * @deprecated
- */
-( function( $ ) {
-var
-       templates = {}, template;
-       template = {
-               _compilers: {},
-               /**
-                * Register a compiler for a given template language
-                *
-                * @method
-                * @param {String} name the name of the compiler
-                * @param {Object} a compiler to associate with the name. Must 
implement a compile and registerPartial function.
-                */
-               registerCompiler: function( name, obj ) {
-                       if ( obj.compile ) {
-                               this._compilers[name] = obj;
-                       } else {
-                               throw new Error( 'Template compiler must 
implement compile function.' );
-                       }
-               },
-               /**
-                * Define a template. Compiles newly added templates based on
-                * the file extension of name and the available compilers.
-                * @method
-                * @param {String} name Name of template to add including file 
extension
-                * @param {String} markup Associated markup (html)
-                */
-               add: function( name, markup ) {
-                       var templateParts = name.split( '.' ), ext,
-                               compiler;
-
-                       if ( templateParts.length > 1 ) {
-                               ext = templateParts[ templateParts.length - 1 ];
-                               if ( this._compilers[ ext ] ) {
-                                       compiler = this._compilers[ ext ];
-                               } else {
-                                       throw new Error( 'Template compiler not 
found for: ' + ext );
-                               }
-                       } else {
-                               throw new Error( 'Template has no suffix. 
Unable to identify compiler.' );
-                       }
-                       templates[ name ] = compiler.compile( markup );
-                       compiler.registerPartial( templateParts[0], templates[ 
name ] );
-               },
-               /**
-                * Retrieve defined template
-                *
-                * @method
-                * @param {String} name Name of template to be retrieved
-                * @return {Object} Compiled template
-                */
-               get: function( name ) {
-                       if ( !templates[ name ] ) {
-                               throw new Error( 'Template not found: ' + name 
);
-                       }
-                       return templates[ name ];
-               },
-               /**
-                * Wraps our template engine of choice
-                * @method
-                * @param {string} templateBody Template body.
-                * @param {string} compilerName The name of a registered 
compiler
-                * @return {Object} template interface
-                * accepts template data object as its argument.
-                */
-               compile: function( templateBody, compilerName ) {
-                       var compiler = this._compilers[ compilerName ];
-                       if ( !compiler ) {
-                               throw new Error( 'Unknown compiler ' + 
compilerName );
-                       }
-                       return compiler.compile( templateBody );
-               }
-       };
-
-       $.extend( mw.mantle, {
-               template: template
-       } );
-
-       // Some deprecation notices
-       mw.log.deprecate( mw.mantle.template, 'compile', 
mw.mantle.template.compile,
-               'mw.mantle.template.compile is deprecated use 
mw.template.compile instead.' );
-
-       mw.log.deprecate( mw.mantle.template, 'get', mw.mantle.template.get,
-               'mw.mantle.template.get is deprecated use mw.template.get 
instead.' );
-
-}( jQuery ) );
diff --git a/javascripts/common/templates/hogan.js 
b/javascripts/common/templates/hogan.js
index 5751df5..74a9f2a 100644
--- a/javascripts/common/templates/hogan.js
+++ b/javascripts/common/templates/hogan.js
@@ -1,5 +1,5 @@
 // Register the Hogan compiler with MediaWiki.
-( function( M ) {
+( function() {
        /*
         * Hogan template compiler
         */
@@ -26,6 +26,4 @@
        };
        // register hogan compiler with core
        mw.template.registerCompiler( 'hogan', hogan );
-       // @deprecate
-       M.template.registerCompiler( 'hogan', hogan );
-}( mw.mantle ) );
+}() );
diff --git a/tests/ResourceLoaderTemplateModuleTest.php 
b/tests/ResourceLoaderTemplateModuleTest.php
deleted file mode 100644
index f59b515..0000000
--- a/tests/ResourceLoaderTemplateModuleTest.php
+++ /dev/null
@@ -1,117 +0,0 @@
-<?php
-
-/**
- * @group Mantle
- */
-class ResourceLoaderTemplateModuleTest extends MediaWikiTestCase {
-       private $modules = array(
-               array(
-                       'messages' => array( 'foo', 'bar' ),
-               ),
-
-               'templateModule' => array(
-                       'templates' => array(
-                               'template.html', 'template2.html',
-                       )
-               ),
-
-               'dependenciesTemplatesModule' => array(
-                       'templates' => array( 'foo' ),
-                       'dependencies' => array( 'dependency1', 'dependency2' )
-               ),
-
-               'dependenciesModule' => array(
-                       'dependencies' => array( 'dependency1', 'dependency2' )
-               ),
-
-               'templateModuleHandlebars' => array(
-                       'templates' => array(
-                               'template_awesome.handlebars',
-                       ),
-               ),
-       );
-
-       // providers
-       public function providerGetTemplateNames() {
-               return array(
-                       array(
-                               $this->modules[0], array(),
-                       ),
-                       array(
-                               $this->modules['templateModule'],
-                               array(
-                                       'template.html',
-                                       'template2.html',
-                               ),
-                       )
-               );
-       }
-
-       /**
-        * @FIXME update template tests
-        */
-       public function providerGetTemplateScript() {
-               $module = $this->modules['templateModule'];
-               $moduleHandlebars = $this->modules['templateModuleHandlebars'];
-               $dir = realpath( dirname( __FILE__ ) . '/templates/' );
-               $module['localTemplateBasePath'] = $dir;
-               $moduleHandlebars['localTemplateBasePath'] = $dir;
-
-               return array(
-                       array(
-                               $this->modules[0], ''
-                       ),
-                       array(
-                               $moduleHandlebars,
-                               
'mw.mantle.template.add("template_awesome.handlebars","wow\n");',
-                       ),
-                       array(
-                               $module,
-                               
'mw.mantle.template.add("template.html","hello\n");' .
-                               
'mw.mantle.template.add("template2.html","goodbye\n");'
-                       )
-               );
-       }
-
-       public function providerGetModifiedTimeTemplates() {
-               $module = $this->modules['templateModule'];
-               $module['localTemplateBasePath'] = '/tmp/templates';
-
-               return array(
-                       // Check the default value when no templates present in 
module is 1
-                       array( $module, 1 ),
-               );
-       }
-
-       // tests
-
-       /**
-        * @dataProvider providerGetTemplateNames
-        */
-       public function testGetTemplateNames( $module, $expected ) {
-               $rl = new ResourceLoaderTemplateModule( $module );
-               $names = $rl->getTemplateNames();
-
-               $this->assertEquals( $names, $expected );
-       }
-
-       /**
-        * @dataProvider providerGetTemplateScript
-        */
-       public function testGetTemplateScript( $module, $expected ) {
-               $rl = new ResourceLoaderTemplateModule( $module );
-               $js = $rl->getTemplateScript();
-
-               $this->assertEquals( $js, $expected );
-       }
-
-       /**
-        * @dataProvider providerGetModifiedTimeTemplates
-        */
-       public function testGetModifiedTimeTemplates( $module, $expected ) {
-               $rl = new ResourceLoaderTemplateModule( $module );
-               $ts = $rl->getModifiedTimeTemplates( new ResourceLoaderContext(
-                       new ResourceLoader, new WebRequest() ) );
-               $this->assertEquals( $ts, $expected );
-       }
-}
diff --git a/tests/javascripts/common/test_templates.js 
b/tests/javascripts/common/test_templates.js
deleted file mode 100644
index e46e26c..0000000
--- a/tests/javascripts/common/test_templates.js
+++ /dev/null
@@ -1,33 +0,0 @@
-( function( M, $ ) {
-
-QUnit.module( 'Mantle templates', {
-       setup: function() {
-               var abcCompiler = {
-                       registerPartial: $.noop,
-                       compile: function() { return 'abc default compiler'; }
-               };
-               // Register some template compiler languages
-               M.template.registerCompiler( 'abc', abcCompiler );
-               M.template.registerCompiler( 'xyz', {
-                       registerPartial: $.noop,
-                       compile: function() { return 'xyz compiler'; }
-               } );
-
-               // register some templates
-               M.template.add( 'test_templates_foo.xyz', 'goodbye' );
-               M.template.add( 'test_templates_foo.abc', 'thankyou' );
-       }
-} );
-
-QUnit.test( 'Template, getCompiler - default case', 4, function( assert ) {
-       assert.throws( function() {
-                       M.template.add( 'test_templates_foo', 'hello' );
-               }, 'When no prefix throw exception.' );
-       assert.throws( function() {
-                       M.template.compile( '{{foo}}', 'rainbow' );
-               }, 'Unknown compiler names throw exceptions.' );
-       assert.strictEqual( M.template.get( 'test_templates_foo.xyz' ), 'xyz 
compiler' );
-       assert.strictEqual( M.template.get( 'test_templates_foo.abc' ), 'abc 
default compiler' );
-} );
-
-}( mw.mantle, jQuery ) );
diff --git a/tests/templates/template.html b/tests/templates/template.html
deleted file mode 100644
index ce01362..0000000
--- a/tests/templates/template.html
+++ /dev/null
@@ -1 +0,0 @@
-hello
diff --git a/tests/templates/template2.html b/tests/templates/template2.html
deleted file mode 100644
index dd7e1c6..0000000
--- a/tests/templates/template2.html
+++ /dev/null
@@ -1 +0,0 @@
-goodbye
diff --git a/tests/templates/template_awesome.handlebars 
b/tests/templates/template_awesome.handlebars
deleted file mode 100644
index 5f5c07d..0000000
--- a/tests/templates/template_awesome.handlebars
+++ /dev/null
@@ -1 +0,0 @@
-wow

-- 
To view, visit https://gerrit.wikimedia.org/r/168233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I69f993f7ca0a98acb592499a002d4f678c4ff0f9
Gerrit-PatchSet: 12
Gerrit-Project: mediawiki/extensions/Mantle
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to