mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-23 22:13:38 +00:00
feat(PWA): ✨ merge all PWA config into wgCitizenManifestOptions
This commit is contained in:
parent
6690263d7e
commit
586cf2c002
12
README.md
12
README.md
|
@ -69,9 +69,15 @@ Name | Description | Values | Default
|
|||
Name | Description | Values | Default
|
||||
:--- | :--- | :--- | :---
|
||||
`$wgCitizenEnableManifest` | Enable or disable [web app manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) | `true` - enable; `false` - disable | `true`
|
||||
`$wgCitizenManifestThemeColor` | [Theme color](https://developer.mozilla.org/en-US/docs/Web/Manifest/theme_color) of the web app manifest | Hex color code | `#0d0e12`
|
||||
`$wgCitizenManifestBackgroundColor` | [Background color](https://developer.mozilla.org/en-US/docs/Web/Manifest/background_color) of the web app manifest | Hex color code | `#0d0e12`
|
||||
`$wgCitizenManifestIcons` | [Icons](https://developer.mozilla.org/en-US/docs/Web/Manifest/icons) of the web app manifest | [Array](https://developer.mozilla.org/en-US/docs/Web/Manifest/icons#syntax) | []
|
||||
`$wgCitizenManifestOptions` | Options of the web app manifest | - | See below
|
||||
|
||||
```php
|
||||
$wgCitizenManifestOptions = [
|
||||
'background_color' => '#0d0e12',
|
||||
'theme_color' => "#0d0e12",
|
||||
'icons' => [],
|
||||
];
|
||||
```
|
||||
|
||||
## Requirements
|
||||
* [MediaWiki](https://www.mediawiki.org) 1.39.4 or later
|
||||
|
|
|
@ -50,6 +50,9 @@ class ApiWebappManifest extends ApiBase {
|
|||
/** @var MediaWikiServices */
|
||||
private $services;
|
||||
|
||||
/** @var array */
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
@ -61,6 +64,7 @@ class ApiWebappManifest extends ApiBase {
|
|||
$this->main = $main;
|
||||
$this->config = $this->getConfig();
|
||||
$this->services = MediaWikiServices::getInstance();
|
||||
$this->options = $this->config->get( 'CitizenManifestOptions' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,6 +75,7 @@ class ApiWebappManifest extends ApiBase {
|
|||
$services = $this->services;
|
||||
$resultObj = $this->getResult();
|
||||
$main = $this->main;
|
||||
$options = $this->options;
|
||||
|
||||
$resultObj->addValue( null, 'dir', $services->getContentLanguage()->getDir() );
|
||||
$resultObj->addValue( null, 'lang', $config->get( MainConfigNames::LanguageCode ) );
|
||||
|
@ -78,12 +83,12 @@ class ApiWebappManifest extends ApiBase {
|
|||
// Need to set it manually because the default from start_url does not include script namespace
|
||||
// E.g. index.php URLs will be thrown out of the PWA
|
||||
$resultObj->addValue( null, 'scope', $config->get( MainConfigNames::Server ) . '/' );
|
||||
$resultObj->addValue( null, 'icons', $this->getIcons( $config, $services ) );
|
||||
$resultObj->addValue( null, 'icons', $this->getIcons() );
|
||||
$resultObj->addValue( null, 'display', 'standalone' );
|
||||
$resultObj->addValue( null, 'orientation', 'natural' );
|
||||
$resultObj->addValue( null, 'start_url', Title::newMainPage()->getLocalURL() );
|
||||
$resultObj->addValue( null, 'theme_color', $config->get( 'CitizenManifestThemeColor' ) );
|
||||
$resultObj->addValue( null, 'background_color', $config->get( 'CitizenManifestBackgroundColor' ) );
|
||||
$resultObj->addValue( null, 'theme_color', $options['theme_color'] );
|
||||
$resultObj->addValue( null, 'background_color', $options['background_color'] );
|
||||
$resultObj->addValue( null, 'shortcuts', $this->getShortcuts() );
|
||||
|
||||
$main->setCacheMaxAge( self::CACHE_MAX_AGE );
|
||||
|
@ -95,10 +100,10 @@ class ApiWebappManifest extends ApiBase {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getIcons( $config, $services ): array {
|
||||
$iconsConfig = $this->config->get( 'CitizenManifestIcons' );
|
||||
private function getIcons(): array {
|
||||
$iconsConfig = $this->options['icons'];
|
||||
if ( !$iconsConfig || $iconsConfig === [] ) {
|
||||
return $this->getIconsFromLogos( $config, $services );
|
||||
return $this->getIconsFromLogos();
|
||||
}
|
||||
$icons = [];
|
||||
$allowedKeys = [ 'src', 'sizes', 'type', 'purpose' ];
|
||||
|
|
24
skin.json
24
skin.json
|
@ -674,22 +674,14 @@
|
|||
"descriptionmsg": "citizen-config-enablemanifest",
|
||||
"public": true
|
||||
},
|
||||
"ManifestThemeColor": {
|
||||
"value": "#0d0e12",
|
||||
"description": "The theme color defined in the web app manifest",
|
||||
"descriptionmsg": "citizen-config-manfiestthemecolor",
|
||||
"public": true
|
||||
},
|
||||
"ManifestBackgroundColor": {
|
||||
"value": "#0d0e12",
|
||||
"description": "The background color defined in the web app manifest",
|
||||
"descriptionmsg": "citizen-config-manifestbackgroundcolor",
|
||||
"public": true
|
||||
},
|
||||
"ManifestIcons": {
|
||||
"value": [],
|
||||
"description": "The icons defined in the web app manifest",
|
||||
"descriptionmsg": "citizen-config-manifesticons",
|
||||
"ManifestOptions": {
|
||||
"value": {
|
||||
"background_color": "#0d0e12",
|
||||
"theme_color": "#0d0e12",
|
||||
"icons": []
|
||||
},
|
||||
"description": "Configuration for web app manifest",
|
||||
"descriptionmsg": "citizen-config-manifestoptions",
|
||||
"public": true
|
||||
},
|
||||
"SearchModule": {
|
||||
|
|
Loading…
Reference in a new issue