Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf5a9c9f

Browse files
committed
did some refactoring
commit e0d8f1288bec46d6bfd1468b0fa040f8eb363790Author: Tobias Oetterer <oetterer@uni-paderborn.de>Date: Sat Jul 13 08:33:57 2024 +0200 finished overhault - switched to suggested mw hook handling system - moved skin and module handling in new class BootstrapComponentsService - moved to MediaWikiServices for three "main classes" - ParserOutputHelper still crude construct. stays in for nowcommit 39d171692b8d7e7517e3a2ddad252d026a276e78Author: Tobias Oetterer <oetterer@uni-paderborn.de>Date: Tue Jul 9 18:09:51 2024 +0200 starting refactoring * moved extension classes to proper MediaWiki namespace schema * started switching to ServiceWiring * started moving hook registration to mw default using extension.json * abandoning registration via onExtensionFunction * new HooksHandler class taking over (and incorporating DefaultHooksHandler) * obsoleting class HookRegisty * augmenting method signatures with type declarations
1 parent9ec2e30 commitf5a9c9f

File tree

82 files changed

+1576
-2050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1576
-2050
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,8 @@ jobs:
1313
strategy:
1414
matrix:
1515
include:
16-
-mw:'REL1_35'
17-
php:7.4
18-
type:normal
19-
experimental:false
20-
-mw:'REL1_37'
21-
php:7.4
22-
type:normal
23-
experimental:false
2416
-mw:'REL1_39'
25-
php:7.4
17+
php:8.0
2618
type:coverage
2719
experimental:false
2820
-mw:'REL1_39'

‎BootstrapComponents.magic.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
* @author Tobias Oetterer
2525
*/
2626

27+
useMediaWiki\MediaWikiServices;
28+
2729
$magicWords = [];
2830

29-
$componentLibrary = \BootstrapComponents\ApplicationFactory::getInstance()->getComponentLibrary();
31+
/** @var \MediaWiki\Extension\BootstrapComponents\ComponentLibrary $componentLibrary */
32+
$componentLibrary = MediaWikiServices::getInstance()->getService('BootstrapComponents.ComponentLibrary' );
3033

3134
// English
3235
$magicWords['en'] =$componentLibrary->compileMagicWordsArray();

‎composer.json‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,15 @@
2525
"source":"https://github.com/oetterer/BootstrapComponents"
2626
},
2727
"require": {
28-
"php":">=7.4",
29-
"composer/installers":"^2|^1.0.1",
30-
"mediawiki/mw-extension-registry-helper":"^1.0",
31-
"mediawiki/bootstrap":"^5.0|^4.0"
28+
"php":">=8.0",
29+
"composer/installers":"^2",
30+
"mediawiki/bootstrap":"^5.0"
3231
},
3332
"require-dev": {
3433
"mediawiki/mediawiki-codesniffer":"43.0.0",
3534
"mediawiki/mediawiki-phan-config":"0.14.0",
3635
"phpmd/phpmd":"~2.1",
37-
"php":">=7.4"
36+
"php":">=8.0"
3837
},
3938
"suggest": {
4039
"mediawiki/scribunto":"Framework for embedding scripting languages into MediaWiki pages"

‎docs/release-notes.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44

55
Released on_not yet_
66

7+
Changes:
8+
* dropping support of mediawiki < 1.39
9+
* removed auto-loading of Extension:Bootstrap.
10+
* add translations via translatewiki
11+
*
12+
Fixes:
13+
* fixed php 8 deprecation notice indicating missing logic encapsulation
14+
in class AbstractComponent
15+
16+
Refactoring:
17+
* modified extension namespace to be compatible with mediawiki
18+
extension namespace schema
19+
20+
21+
###BootstrapComponents 5.1.2
22+
23+
Released on 12-May-2024
24+
725
Changes:
826
* add css classes to restore the usual infobox layout
927
* add more style control to card component

‎extension.json‎

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,60 @@
11
{
22
"name":"BootstrapComponents",
3-
"version":"5.1.2-dev",
3+
"version":"5.2.0-dev",
44
"author": ["Tobias Oetterer" ],
55
"url":"https://www.mediawiki.org/wiki/Extension:BootstrapComponents",
66
"descriptionmsg":"bootstrap-components-desc",
77
"license-name":"GPL-3.0-or-later",
88
"type":"parserhook",
99
"requires": {
10-
"MediaWiki":">= 1.35.0"
10+
"MediaWiki":">= 1.39.0"
1111
},
1212
"ConfigRegistry": {
1313
"BootstrapComponents":"GlobalVarConfig::newInstance"
1414
},
1515
"AutoloadNamespaces": {
16-
"BootstrapComponents\\":"src/"
16+
"MediaWiki\\Extension\\BootstrapComponents\\":"src/"
1717
},
1818
"TestAutoloadNamespaces": {
19-
"BootstrapComponents\\Tests\\":"tests/phpunit/"
19+
"MediaWiki\\Extension\\BootstrapComponents\\Tests\\":"tests/phpunit/"
2020
},
21+
"ServiceWiringFiles": [
22+
"src/ServiceWiring.php"
23+
],
2124
"@note":"the extension's main hooks are registered in BootstrapComponents\\HookRegistry",
2225
"HookHandlers": {
2326
"BootStrapHooks": {
24-
"class":"BootstrapComponents\\Hooks\\DefaultHooksHandler"
27+
"class":"MediaWiki\\Extension\\BootstrapComponents\\HooksHandler",
28+
"services": [
29+
"BootstrapComponentsService",
30+
"BootstrapComponents.ComponentLibrary",
31+
"BootstrapComponents.NestingController"
32+
]
2533
}
2634
},
2735
"Hooks": {
28-
"SetupAfterCache": {
36+
"GalleryGetModes": {
37+
"handler":"BootStrapHooks"
38+
},
39+
"ImageBeforeProduceHTML": {
40+
"handler":"BootStrapHooks"
41+
},
42+
"InternalParseBeforeLinks": {
43+
"handler":"BootStrapHooks"
44+
},
45+
"OutputPageParserOutput": {
2946
"handler":"BootStrapHooks"
3047
},
3148
"ParserAfterParse": {
3249
"handler":"BootStrapHooks"
3350
},
34-
"ScribuntoExternalLibraries":"BootstrapComponents\\Hooks\\DefaultHooksHandler::onScribuntoExternalLibraries"
51+
"ParserFirstCallInit": {
52+
"handler":"BootStrapHooks"
53+
},
54+
"SetupAfterCache": {
55+
"handler":"BootStrapHooks"
56+
},
57+
"ScribuntoExternalLibraries":"MediaWiki\\Extension\\BootstrapComponents\\HooksHandler::onScribuntoExternalLibraries"
3558
},
3659
"config": {
3760
"BootstrapComponentsDisableSourceLinkOnImageModal": {
@@ -55,10 +78,7 @@
5578
"public":true
5679
}
5780
},
58-
"callback":"BootstrapComponents\\BootstrapComponents::init",
59-
"ExtensionFunctions": [
60-
"BootstrapComponents\\BootstrapComponents::onExtensionFunction"
61-
],
81+
"callback":"MediaWiki\\Extension\\BootstrapComponents\\BootstrapComponents::init",
6282
"MessagesDirs": {
6383
"BootstrapComponents": [
6484
"i18n"

‎phpunit.xml.dist‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
verbose="true">
1515
<listeners>
1616
<listenerfile="tests/phpunit/ExecutionTimeTestListener.php"
17-
class="BootstrapComponents\Tests\ExecutionTimeTestListener">
17+
class="Mediawiki\Extension\BootstrapComponents\Tests\ExecutionTimeTestListener">
1818
<arguments>
1919
<boolean>true</boolean>
2020
<integer>10</integer>

‎src/AbstractComponent.php‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Tobias Oetterer
2525
*/
2626

27-
namespaceBootstrapComponents;
27+
namespaceMediaWiki\Extension\BootstrapComponents;
2828

2929
use \MWException;
3030

@@ -283,7 +283,7 @@ protected function prepareInput( $parserRequest, $fullParse = false ) {
283283
$parserRequest->getFrame()
284284
);
285285
}
286-
if ($input &&preg_match('/\n\n/',$input ) ||preg_match('/<p/',$input ) ) {
286+
if ($input &&(preg_match('/\n\n/',$input ) ||preg_match('/<p/',$input)) ) {
287287
// if there are paragraph marker we prefix input with a new line so the parser recognizes two paragraphs.
288288
$input ="\n" .$input ."\n";
289289
}
@@ -316,10 +316,9 @@ protected function processCss( $class, $style ) {
316316
*/
317317
privatefunctionaugmentParserOutput() {
318318
$this->getParserOutputHelper()->addTrackingCategory();
319-
$this->getParserOutputHelper()->loadBootstrapModules();
320319
$modules =$this->getComponentLibrary()->getModulesFor(
321320
$this->getComponentName(),
322-
$this->getParserOutputHelper()->getNameOfActiveSkin()
321+
'vector'
323322
);
324323
$this->getParserOutputHelper()->addModules($modules );
325324
}

‎src/ApplicationFactory.php‎

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Tobias Oetterer
2525
*/
2626

27-
namespaceBootstrapComponents;
27+
namespaceMediaWiki\Extension\BootstrapComponents;
2828

2929
useMediaWiki\Logger\LoggerFactory;
3030
useMediaWiki\MediaWikiServices;
@@ -88,27 +88,7 @@ public static function getInstance() {
8888
publicfunction__construct() {
8989
$this->applicationStore = [];
9090
$this->applicationClassRegister =$this->getApplicationClassRegister();
91-
$this->getLogger()->info('ApplicationFactory was build!' );
92-
}
93-
94-
/**
95-
* @param null|bool|array $componentWhiteList
96-
*
97-
* @throws MWException cascading {@see \BootstrapComponents\ApplicationFactory::getApplication}
98-
*
99-
* @return ComponentLibrary
100-
*/
101-
publicfunctiongetComponentLibrary($componentWhiteList =null ) {
102-
return$this->getApplication('ComponentLibrary',$componentWhiteList );
103-
}
104-
105-
/**
106-
* @throws MWException cascading {@see \BootstrapComponents\ApplicationFactory::getApplication}
107-
*
108-
* @return NestingController
109-
*/
110-
publicfunctiongetNestingController() {
111-
return$this->getApplication('NestingController' );
91+
$this->getLogger()->debug('ApplicationFactory was build!' );
11292
}
11393

11494
/**
@@ -119,7 +99,7 @@ public function getNestingController() {
11999
*
120100
* @return AttributeManager
121101
*/
122-
publicfunctiongetNewAttributeManager($validAttributes,$aliases ) {
102+
publicfunctiongetNewAttributeManager(array$validAttributes,array$aliases ):AttributeManager {
123103
returnnewAttributeManager($validAttributes,$aliases );
124104
}
125105

@@ -133,7 +113,9 @@ public function getNewAttributeManager( $validAttributes, $aliases ) {
133113
*
134114
* @return ModalBuilder
135115
*/
136-
publicfunctiongetNewModalBuilder($id,$trigger,$content,$parserOutputHelper ) {
116+
publicfunctiongetNewModalBuilder(
117+
string$id,string$trigger,string$content,ParserOutputHelper$parserOutputHelper
118+
):ModalBuilder {
137119
returnnewModalBuilder($id,$trigger,$content,$parserOutputHelper );
138120
}
139121

@@ -148,7 +130,9 @@ public function getNewModalBuilder( $id, $trigger, $content, $parserOutputHelper
148130
*
149131
* @return ParserRequest
150132
*/
151-
publicfunctiongetNewParserRequest($argumentsPassedByParser,$isParserFunction,$componentName ='unknown' ) {
133+
publicfunctiongetNewParserRequest(
134+
array$argumentsPassedByParser,bool$isParserFunction,string$componentName ='unknown'
135+
):ParserRequest {
152136
returnnewParserRequest($argumentsPassedByParser,$isParserFunction,$componentName );
153137
}
154138

@@ -178,7 +162,7 @@ public function getParserOutputHelper( $parser = null ) {
178162
*
179163
* @return bool
180164
*/
181-
publicfunctionregisterApplication($name,$class ) {
165+
publicfunctionregisterApplication(string$name,string$class ):bool {
182166
$application =trim($name );
183167
$applicationClass =trim($class );
184168
if ($application !='' &&class_exists($applicationClass ) ) {
@@ -199,7 +183,7 @@ public function registerApplication( $name, $class ) {
199183
*
200184
* @return bool
201185
*/
202-
publicfunctionresetLookup($application =null ) {
186+
publicfunctionresetLookup(?string$application =null ):bool {
203187
if (is_null($application ) ) {
204188
$this->applicationStore = [];
205189
returntrue;
@@ -218,9 +202,9 @@ public function resetLookup( $application = null ) {
218202
*
219203
* @throws MWException when no class is registered for the requested application or the creation of the object fails.
220204
*
221-
* @returnmixed|object
205+
* @return object
222206
*/
223-
protectedfunctiongetApplication($name ) {
207+
protectedfunctiongetApplication($name ):object {
224208
if (isset($this->applicationStore[$name] ) ) {
225209
return$this->applicationStore[$name];
226210
}
@@ -233,9 +217,11 @@ protected function getApplication( $name ) {
233217
try {
234218
$objectReflection =newReflectionClass($this->applicationClassRegister[$name] );
235219
}catch (\ReflectionException$e ) {
236-
thrownewMWException('Error while trying to build application "' .$name .'" with class' .$this->applicationClassRegister[$name] );
220+
thrownewMWException(
221+
'Error while trying to build application "' .$name .'" with class' .$this->applicationClassRegister[$name]
222+
);
237223
}
238-
$this->getLogger()->info('ApplicationFactory successfully build application' .$name );
224+
$this->getLogger()->debug('ApplicationFactory successfully build application' .$name );
239225
return$this->applicationStore[$name] =$objectReflection->newInstanceArgs($args );
240226
}
241227

@@ -244,9 +230,8 @@ protected function getApplication( $name ) {
244230
*/
245231
protectedfunctiongetApplicationClassRegister() {
246232
return [
247-
'ComponentLibrary' =>'BootstrapComponents\\ComponentLibrary',
248-
'NestingController' =>'BootstrapComponents\\NestingController',
249-
'ParserOutputHelper' =>'BootstrapComponents\\ParserOutputHelper',
233+
'NestingController' =>'MediaWiki\\Extension\\BootstrapComponents\\NestingController',
234+
'ParserOutputHelper' =>'MediaWiki\\Extension\\BootstrapComponents\\ParserOutputHelper',
250235
];
251236
}
252237

‎src/AttributeManager.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Tobias Oetterer
2525
*/
2626

27-
namespaceBootstrapComponents;
27+
namespaceMediaWiki\Extension\BootstrapComponents;
2828

2929
/**
3030
* Class AttributeManager

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp