Hygiene: Remove and update references to MobileFrontend

Changes:
* Update docs
* Update browser test artifacts
* Update comments
* Update phpunit test groups
* Update phpunit test namespace
* Update `die` when MobileFrontend not installed
* Remove the migrate script which is no longer needed

Change-Id: I83432b3f7f0bcd07ed08259972b8ff89147104b6
This commit is contained in:
jdlrobson 2017-07-14 16:56:16 -07:00
parent 211a54b568
commit 47546207ad
10 changed files with 26 additions and 264 deletions

View File

@ -5,8 +5,6 @@
/** /**
* Hook handlers for Minerva skin. * Hook handlers for Minerva skin.
* Hooks specific to all skins running in mobile mode should belong in
* MobileFrontend.hooks.php
* *
* Hook handler method names should be in the form of: * Hook handler method names should be in the form of:
* on<HookName>() * on<HookName>()
@ -38,7 +36,7 @@ class MinervaHooks {
$wgResourceLoaderLESSImportPaths[] = dirname( __DIR__ ) . "/minerva.less/"; $wgResourceLoaderLESSImportPaths[] = dirname( __DIR__ ) . "/minerva.less/";
if ( !ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) { if ( !ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) ) {
die( 'This version of the MobileFrontend extension requires MediaWiki 1.25+' ); die( 'This version of the Minerva skin requires MobileFrontend' );
} }
// Setup alias for compatibility with SkinMinervaNeue. // Setup alias for compatibility with SkinMinervaNeue.
if ( !class_exists( 'SkinMinervaNeue' ) ) { if ( !class_exists( 'SkinMinervaNeue' ) ) {
@ -62,7 +60,7 @@ class MinervaHooks {
'skins.minerva.notifications.badge' 'skins.minerva.notifications.badge'
], ],
'localBasePath' => dirname( __DIR__ ), 'localBasePath' => dirname( __DIR__ ),
'remoteExtPath' => 'MobileFrontend', 'remoteExtPath' => 'MinervaNeue',
'targets' => [ 'mobile', 'desktop' ], 'targets' => [ 'mobile', 'desktop' ],
'scripts' => [ 'scripts' => [
'tests/qunit/skins.minerva.notifications.badge/test_NotificationBadge.js' 'tests/qunit/skins.minerva.notifications.badge/test_NotificationBadge.js'

View File

@ -1,6 +0,0 @@
Porting Minerva code from MobileFrontend to Minerva:
* Make sure this repository is in your MediaWiki skins directory
* Make sure MobileFrontend is installed in extensions/MobileFrontend in your MediaWiki install
* Create commits for both MobileFrontend and Minerva to handle the move.
* Run:
> python3 scripts/migrate.python

View File

@ -1,239 +0,0 @@
mfdir = '../../extensions/MobileFrontend'
import json, shutil, os, subprocess, time
from collections import OrderedDict
import sys
DRY_RUN = False
f = open(mfdir +'/extension.json', 'r')
mfExtensionData = json.load(f, object_pairs_hook=OrderedDict)
f.close()
f = open('skin.json', 'r')
minervaSkinData = json.load(f, object_pairs_hook=OrderedDict)
f.close()
messages = [ 'mobile-frontend-placeholder', 'skinname-minerva',
'mobile-frontend-talk-back-to-userpage',
'mobile-frontend-talk-back-to-projectpage',
'mobile-frontend-talk-back-to-filepage',
'mobile-frontend-talk-back-to-page',
'mobile-frontend-editor-edit',
'mobile-frontend-user-newmessages',
'mobile-frontend-main-menu-contributions',
'mobile-frontend-main-menu-watchlist',
'mobile-frontend-main-menu-settings',
'mobile-frontend-home-button',
'mobile-frontend-random-button',
'mobile-frontend-main-menu-nearby',
'mobile-frontend-main-menu-logout',
'mobile-frontend-main-menu-login',
'mobile-frontend-history',
'mobile-frontend-user-page-member-since',
'mobile-frontend-main-menu-button-tooltip',
'mobile-frontend-language-article-heading',
'mobile-frontend-pageaction-edit-tooltip',
'mobile-frontend-language-article-heading',
'mobile-frontend-user-page-talk',
'mobile-frontend-user-page-contributions',
'mobile-frontend-user-page-uploads'
]
def reset():
# Do cleanup in preparation for patchsets it will make.
subprocess.call(["git clean -fd"], shell=True)
subprocess.call(["git stash && git clean -fd"], shell=True, cwd=mfdir)
if not DRY_RUN:
subprocess.call(["rm -rf includes && rm -rf resources && rm -rf minerva.less && rm -rf i18n && rm -rf skinStyles && rm -rf tests/qunit && rm -rf tests/phpunit"], shell=True)
subprocess.call(["mkdir includes && mkdir includes/skins && mkdir includes/models && mkdir resources && mkdir minerva.less && mkdir i18n && mkdir skinStyles && mkdir tests/qunit && mkdir tests/qunit/skins.minerva.notifications.badge && mkdir tests/phpunit/ && mkdir tests/phpunit/skins"], shell=True)
time.sleep(1)
def saveJSON(path, data, sort_keys = False):
if not DRY_RUN:
with open(path, 'w') as outfile:
json.dump(data, outfile, indent = "\t", ensure_ascii=False, separators=(',', ': '), sort_keys=sort_keys)
def clean( keys_to_remove, data_key ):
# Remove the keys we added from MobileFrontend extension.json
for key in keys_to_remove:
try:
del mfExtensionData[data_key][key]
except KeyError:
pass
def steal_files_in_directory(dir):
if not DRY_RUN:
# steal templates etc from MobileFrontend
for root, dirs, files in os.walk(mfdir + '/' + dir):
for file in files:
steal(root + '/' + file)
def steal( path ):
dest = path.replace(mfdir + '/', '' )
origin = mfdir + '/' + path
print('\tstealing %s from %s'%(dest, origin))
try:
if not DRY_RUN:
shutil.move( origin, dest )
except ( FileNotFoundError, shutil.Error ) as e:
print (e)
# probably done in initial steal steps
pass
def copy( path ):
if not DRY_RUN:
print('copying %s'%path)
try:
# ../ because we are in scripts folder
shutil.copy( mfdir + '/' + path, path )
except ( FileNotFoundError, shutil.Error ) as e:
print (e)
# probably done in initial steal steps
pass
def isOwnedByMinerva(key, value=""):
return key.startswith("Minerva") or key.endswith("Minerva") or key.startswith( 'skins.minerva' ) or \
( type(value) == type('string') and "skins/" in value )
# modulename, ResourceModules
def migrateResourceModuleSkinStyles():
mf = {}
minerva = {}
for module, files in mfExtensionData["ResourceModuleSkinStyles"]["minerva"].items():
for f in files:
try:
os.makedirs('skinStyles/%s'%module)
except FileExistsError:
pass
steal(f)
minerva[module] = files
minervaSkinData["ResourceModuleSkinStyles"]["minerva"] = minerva
del mfExtensionData["ResourceModuleSkinStyles"]["minerva"]
def migrateObject(fromObj, toObj, key):
obj = fromObj[key]
keys_to_remove = []
files_to_steal = []
for subkey in obj:
val = obj[subkey]
if isOwnedByMinerva(subkey, val):
if key == "ResourceModules":
steal( 'resources/%s'% subkey )
if "messages" in obj[subkey]:
for msg in obj[subkey]["messages"]:
if type(obj[subkey]["messages"]) == type([]):
messages.append(msg)
else:
msgVal = obj[subkey]["messages"][msg]
if type(msgVal) == type([]):
messages.append(msg)
else:
messages.append(msgVal)
elif key == 'AutoloadClasses':
steal( val )
toObj[key][subkey] = val
keys_to_remove.append(subkey)
# cleanup
clean( keys_to_remove, key )
print('Moved keys from %s:\n\t\t%s'%(key, keys_to_remove))
def stealHooks():
for hookname in mfExtensionData['Hooks']:
mfHooks = mfExtensionData['Hooks'][hookname]
minervaHooks = []
newMfHooks = []
for hook in mfHooks:
if isOwnedByMinerva(hook, hook):
minervaHooks.extend([hook])
else:
newMfHooks.extend([hook])
if len(minervaHooks) > 0:
minervaSkinData['Hooks'][hookname] = minervaHooks
mfExtensionData['Hooks'][hookname] = newMfHooks
################################################################################################################################
######## SCRIPT BEGINS HERE
################################################################################################################################
reset()
minervaSkinData['ResourceModuleSkinStyles']['minerva'] = {}
migrateObject( mfExtensionData, minervaSkinData, "AutoloadClasses")
migrateObject( mfExtensionData, minervaSkinData, "ResourceModules")
migrateObject( mfExtensionData, minervaSkinData, "config")
migrateResourceModuleSkinStyles()
stealHooks()
steal_files_in_directory('includes/skins/')
steal_files_in_directory('minerva.less/')
steal_files_in_directory('tests/qunit/skins.minerva.notifications.badge')
steal_files_in_directory('tests/phpunit/skins')
# steal the service wirings
steal('includes/Minerva.ServiceWiring.php');
# remove
del mfExtensionData["ValidSkinNames"]
# for time being we do this. When code has been removed from MobileFrontend can switch to minerva-neue
minervaSkinData["ValidSkinNames"] = {
"minerva-neue": "MinervaNeue"
}
try:
del minervaSkinData["ServiceWiringFiles"]
except KeyError:
pass
# add onRegistration hook
minervaSkinData['callback'] = 'MinervaHooks::onRegistration';
# cleanup
minervaSkinData['namemsg'] = 'skinname-minerva'
minervaSkinData['descriptionmsg'] = "minerva-skin-desc"
minervaSkinData['ConfigRegistry']['minerva'] = 'GlobalVarConfig::newInstance'
del minervaSkinData['ResourceModuleSkinStyles']['minerva-neue']
del minervaSkinData['ConfigRegistry']['minerva-neue']
# setup registration
minervaSkinData["callback"] = "MinervaHooks::onRegistration";
saveJSON('skin.json', minervaSkinData)
saveJSON(mfdir + '/extension.json', mfExtensionData)
# migrate i18n
print('migrating i18n')
for root, dirs, files in os.walk(mfdir + '/i18n/'):
for language in files:
try:
f = open('/i18n/' + language, 'r')
newLanguageData = json.load(f, object_pairs_hook=OrderedDict)
except FileNotFoundError:
newLanguageData = {
"@metadata": {
"authors": []
}
}
f.close()
f = open(mfdir + '/i18n/' + language, 'r')
languageData = json.load(f, object_pairs_hook=OrderedDict)
f.close()
messages.sort()
if language == 'en.json':
print("Moving %s messages"%len(messages))
for msgKey in messages:
if language == 'en.json':
print("\t\tMap message %s"%(msgKey))
try:
newLanguageData[msgKey] = languageData[msgKey]
del languageData[msgKey]
except KeyError:
pass
# save to mf
saveJSON( mfdir + '/i18n/' + language, languageData )
# save to minerva
saveJSON( 'i18n/' + language, newLanguageData, True )

View File

@ -7,7 +7,7 @@ Include the LocalSettings.php in this folder into your MediaWiki LocalSettings.p
Note including this in a production instance is not advised given it fiddles with permissions. Note including this in a production instance is not advised given it fiddles with permissions.
<pre> <pre>
include_once "$IP/extensions/MobileFrontend/tests/browser/LocalSettings.php"; include_once "$IP/skins/MinervaNeue/tests/browser/LocalSettings.php";
</pre> </pre>
Further tweaks may be necessary to run tests that are not tagged @integration: Further tweaks may be necessary to run tests that are not tagged @integration:
@ -19,11 +19,6 @@ Further tweaks may be necessary to run tests that are not tagged @integration:
** an edit count of greater than 0 ** an edit count of greater than 0
** Ensure user has bureaucrat and admin rights (set via Special:UserRights) ** Ensure user has bureaucrat and admin rights (set via Special:UserRights)
= MobileFrontend Extension =
For general information about MobileFrontend Extension please see
README.mediawiki file in the root of the repository.
==== Selenium tests ==== ==== Selenium tests ====
To run the Selenium tests you will have to install Ruby (for the exact To run the Selenium tests you will have to install Ruby (for the exact
@ -58,9 +53,9 @@ Tests that use steps that create pages (create_page_api_steps.rb) need to set
the MEDIAWIKI_API_URL environment variable, e.g. the MEDIAWIKI_API_URL environment variable, e.g.
export MEDIAWIKI_API_URL=http://en.wikipedia.beta.wmflabs.org/w/api.php export MEDIAWIKI_API_URL=http://en.wikipedia.beta.wmflabs.org/w/api.php
Run the tests from the MobileFrontend directory with: Run the tests from the Minerva directory with:
make cucumber bundle exec cucumber tests/browser/features
If you want to run a single set of tests, go to the tests/browser directory and If you want to run a single set of tests, go to the tests/browser directory and
call 'bundle exec cucumber' with the path to the test file. For example, to run call 'bundle exec cucumber' with the path to the test file. For example, to run

View File

@ -62,7 +62,7 @@ Given(/^my browser doesn't support JavaScript$/) do
end end
Given(/^the "(.*?)" page is protected\.$/) do |page| Given(/^the "(.*?)" page is protected\.$/) do |page|
api.protect_page(page, 'MobileFrontend Selenium test protected this page') api.protect_page(page, 'MinervaNeue Selenium test protected this page')
end end
When(/^I click the browser back button$/) do When(/^I click the browser back button$/) do

View File

@ -1,6 +1,6 @@
# export MEDIAWIKI_API_URL = http://en.wikipedia.beta.wmflabs.org/w/api.php # export MEDIAWIKI_API_URL = http://en.wikipedia.beta.wmflabs.org/w/api.php
Given(/^I go to a page that has references$/) do Given(/^I go to a page that has references$/) do
wikitext = "MobileFrontend is a MediaWiki extension. wikitext = "MinervaNeue is a MediaWiki skin.
{{#tag:ref|This is a note.<ref>This is a nested ref.</ref>|group=note}} {{#tag:ref|This is a note.<ref>This is a nested ref.</ref>|group=note}}
==Notes== ==Notes==
<references group=note /> <references group=note />

View File

@ -6,7 +6,7 @@ use MediaWiki\Minerva\MenuBuilder;
use MediaWiki\Minerva\MenuEntry; use MediaWiki\Minerva\MenuEntry;
/** /**
* @group MobileFrontend * @group MinervaNeue
*/ */
class MenuTest extends \PHPUnit_Framework_TestCase { class MenuTest extends \PHPUnit_Framework_TestCase {
private $homeComponent = [ private $homeComponent = [

View File

@ -1,5 +1,13 @@
<?php <?php
namespace Tests\MediaWiki\Minerva;
use SkinMinerva;
use MediaWikiTestCase;
use Title;
use RequestContext;
use ContentHandler;
// FIXME: That this class exists is an indicator that at least SkinMinerva#isAllowedPageAction // FIXME: That this class exists is an indicator that at least SkinMinerva#isAllowedPageAction
// should be extracted from SkinMinerva. // should be extracted from SkinMinerva.
class TestSkinMinerva extends SkinMinerva { class TestSkinMinerva extends SkinMinerva {
@ -21,7 +29,7 @@ class TestSkinMinerva extends SkinMinerva {
} }
/** /**
* @group MobileFrontend * @group MinervaNeue
*/ */
class SkinMinervaPageActionsTest extends MediaWikiTestCase { class SkinMinervaPageActionsTest extends MediaWikiTestCase {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Tests\MobileFrontend\Skins; namespace Tests\MediaWiki\Minerva;
use MediaWikiTestCase; use MediaWikiTestCase;
use MobileUI; use MobileUI;
@ -34,7 +34,7 @@ class EchoNotifUser {
/** /**
* @coversDefaultClass SkinMinerva * @coversDefaultClass SkinMinerva
* @group MobileFrontend * @group MinervaNeue
*/ */
class SkinMinervaTest extends MediaWikiTestCase { class SkinMinervaTest extends MediaWikiTestCase {

View File

@ -1,8 +1,14 @@
<?php <?php
namespace Tests\MediaWiki\Minerva;
use MediaWiki\Minerva\SkinUserPageHelper; use MediaWiki\Minerva\SkinUserPageHelper;
use MediaWikiTestCase;
use Title;
use IContextSource;
/** /**
* @group MobileFrontend * @group MinervaNeue
* @coversDefaultClass MediaWiki\Minerva\SkinUserPageHelper * @coversDefaultClass MediaWiki\Minerva\SkinUserPageHelper
*/ */
class SkinUserPageHelperTest extends MediaWikiTestCase { class SkinUserPageHelperTest extends MediaWikiTestCase {