. * * @file * @ingroup Skins */ declare( strict_types=1 ); namespace MediaWiki\Skins\Citizen\Partials; use Exception; use MediaWiki\MediaWikiServices; final class Metadata extends Partial { /** * Adds metadata to the output page */ public function addMetadata() { $out = $this->out; // Theme color $out->addMeta( 'theme-color', $this->getConfigValue( 'CitizenThemeColor' ) ?? '' ); // Generate webapp manifest $this->addManifest(); } /** * Adds the manifest if enabled in 'CitizenEnableManifest'. * Manifest link will be empty if wfExpandUrl throws an exception. */ private function addManifest() { if ( $this->getConfigValue( 'CitizenEnableManifest' ) !== true ) { return; } try { $href = MediaWikiServices::getInstance()->getUrlUtils() ->expand( wfAppendQuery( wfScript( 'api' ), [ 'action' => 'webapp-manifest' ] ), PROTO_RELATIVE ); } catch ( Exception $e ) { $href = ''; } $out = $this->out; $out->addLink( [ 'rel' => 'manifest', 'href' => $href, ] ); } }