From: Timo Tijhof Date: Tue, 30 Jul 2019 00:17:35 +0000 (+0100) Subject: API: Create a module bundle for 'apipretty' and 'apihelp' X-Git-Tag: 1.34.0-rc.0~814^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=30565e249175ef4cf1a3fa75cecfac6b4dedfb63 API: Create a module bundle for 'apipretty' and 'apihelp' These are both fairly small modules used in related low-traffic scenarios. The cost of registering both globally on all page views as a top-level entry point does not seem worth the marginal gain of loading only one of these two in the contexts where they are needed. Change-Id: I42458ebec3f8d6e14e52e44d62fb914fcbeda5db --- diff --git a/includes/api/ApiHelp.php b/includes/api/ApiHelp.php index cc96f907a3..988957b6d8 100644 --- a/includes/api/ApiHelp.php +++ b/includes/api/ApiHelp.php @@ -100,7 +100,7 @@ class ApiHelp extends ApiBase { $out = $context->getOutput(); $out->addModuleStyles( [ 'mediawiki.hlist', - 'mediawiki.apihelp', + 'mediawiki.apipretty', ] ); if ( !empty( $options['toc'] ) ) { $out->addModuleStyles( 'mediawiki.toc.styles' ); diff --git a/resources/Resources.php b/resources/Resources.php index 9a7b9e8362..77d7d88bac 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -768,10 +768,6 @@ return [ ], /* MediaWiki */ - 'mediawiki.apihelp' => [ - 'styles' => 'resources/src/mediawiki.apihelp.css', - 'targets' => [ 'desktop' ], - ], 'mediawiki.template' => [ 'scripts' => 'resources/src/mediawiki.template.js', 'targets' => [ 'desktop', 'mobile' ], @@ -790,7 +786,10 @@ return [ 'dependencies' => 'mediawiki.template', ], 'mediawiki.apipretty' => [ - 'styles' => 'resources/src/mediawiki.apipretty.css', + 'styles' => [ + 'resources/src/mediawiki.apipretty/apipretty.css', + 'resources/src/mediawiki.apipretty/apihelp.css', + ], 'targets' => [ 'desktop', 'mobile' ], ], 'mediawiki.api' => [ diff --git a/resources/src/mediawiki.apihelp.css b/resources/src/mediawiki.apihelp.css deleted file mode 100644 index d1f32ab3b7..0000000000 --- a/resources/src/mediawiki.apihelp.css +++ /dev/null @@ -1,109 +0,0 @@ -/* stylelint-disable selector-class-pattern */ - -.apihelp-header { - clear: both; - margin-bottom: 0.1em; -} - -.apihelp-header.apihelp-module-name { - /* - * This element is explicitly set to dir="ltr" in HTML. - * Set explicit alignment so that CSSJanus will flip it to "right"; - * otherwise the alignment will be automatically set to "left" according - * to the element's direction, and this will have an inconsistent look. - */ - text-align: left; -} - -div.apihelp-linktrail { - font-size: smaller; -} - -.apihelp-block { - margin-top: 0.5em; -} - -.apihelp-block-head { - font-weight: bold; -} - -.apihelp-flags { - font-size: smaller; - float: right; - border: 1px solid #000; - padding: 0.25em; - width: 20em; -} - -.apihelp-deprecated, -.apihelp-flag-deprecated, -.apihelp-flag-internal strong { - font-weight: bold; - color: #d33; -} - -.apihelp-deprecated-value { - text-decoration: line-through; -} - -.apihelp-unknown { - color: #72777d; -} - -.apihelp-empty { - color: #72777d; -} - -.apihelp-help-urls ul { - list-style-image: none; - list-style-type: none; - margin-left: 0; -} - -.apihelp-parameters dl, -.apihelp-examples dl, -.apihelp-permissions dl { - margin-left: 2em; -} - -.apihelp-parameters dt { - float: left; - clear: left; - min-width: 10em; - white-space: nowrap; - line-height: 1.5em; -} - -.apihelp-parameters dt:after { - content: ':\A0'; -} - -.apihelp-parameters dd { - margin: 0 0 0.5em 10em; - line-height: 1.5em; -} - -.apihelp-parameters dd p:first-child { - margin-top: 0; -} - -.apihelp-parameters dd.info { - margin-left: 12em; - text-indent: -2em; -} - -.apihelp-examples dt { - font-weight: normal; -} - -.api-main-links { - text-align: center; -} - -.api-main-links ul:before { - content: '['; -} - -.api-main-links ul:after { - content: ']'; -} diff --git a/resources/src/mediawiki.apipretty.css b/resources/src/mediawiki.apipretty.css deleted file mode 100644 index 3e921f419f..0000000000 --- a/resources/src/mediawiki.apipretty.css +++ /dev/null @@ -1,13 +0,0 @@ -/* stylelint-disable selector-class-pattern */ - -.mw-special-ApiHelp h1.firstHeading { - display: none; -} - -.api-pretty-header { - font-size: small; -} - -.api-pretty-content { - white-space: pre-wrap; -} diff --git a/resources/src/mediawiki.apipretty/apihelp.css b/resources/src/mediawiki.apipretty/apihelp.css new file mode 100644 index 0000000000..d1f32ab3b7 --- /dev/null +++ b/resources/src/mediawiki.apipretty/apihelp.css @@ -0,0 +1,109 @@ +/* stylelint-disable selector-class-pattern */ + +.apihelp-header { + clear: both; + margin-bottom: 0.1em; +} + +.apihelp-header.apihelp-module-name { + /* + * This element is explicitly set to dir="ltr" in HTML. + * Set explicit alignment so that CSSJanus will flip it to "right"; + * otherwise the alignment will be automatically set to "left" according + * to the element's direction, and this will have an inconsistent look. + */ + text-align: left; +} + +div.apihelp-linktrail { + font-size: smaller; +} + +.apihelp-block { + margin-top: 0.5em; +} + +.apihelp-block-head { + font-weight: bold; +} + +.apihelp-flags { + font-size: smaller; + float: right; + border: 1px solid #000; + padding: 0.25em; + width: 20em; +} + +.apihelp-deprecated, +.apihelp-flag-deprecated, +.apihelp-flag-internal strong { + font-weight: bold; + color: #d33; +} + +.apihelp-deprecated-value { + text-decoration: line-through; +} + +.apihelp-unknown { + color: #72777d; +} + +.apihelp-empty { + color: #72777d; +} + +.apihelp-help-urls ul { + list-style-image: none; + list-style-type: none; + margin-left: 0; +} + +.apihelp-parameters dl, +.apihelp-examples dl, +.apihelp-permissions dl { + margin-left: 2em; +} + +.apihelp-parameters dt { + float: left; + clear: left; + min-width: 10em; + white-space: nowrap; + line-height: 1.5em; +} + +.apihelp-parameters dt:after { + content: ':\A0'; +} + +.apihelp-parameters dd { + margin: 0 0 0.5em 10em; + line-height: 1.5em; +} + +.apihelp-parameters dd p:first-child { + margin-top: 0; +} + +.apihelp-parameters dd.info { + margin-left: 12em; + text-indent: -2em; +} + +.apihelp-examples dt { + font-weight: normal; +} + +.api-main-links { + text-align: center; +} + +.api-main-links ul:before { + content: '['; +} + +.api-main-links ul:after { + content: ']'; +} diff --git a/resources/src/mediawiki.apipretty/apipretty.css b/resources/src/mediawiki.apipretty/apipretty.css new file mode 100644 index 0000000000..3e921f419f --- /dev/null +++ b/resources/src/mediawiki.apipretty/apipretty.css @@ -0,0 +1,13 @@ +/* stylelint-disable selector-class-pattern */ + +.mw-special-ApiHelp h1.firstHeading { + display: none; +} + +.api-pretty-header { + font-size: small; +} + +.api-pretty-content { + white-space: pre-wrap; +}