Overview
ApiWebappManifest provides a MediaWiki API action (action=appmanifest) that generates a Web App Manifest for Progressive Web App (PWA) support.
Namespace: MediaWiki\Skins\Citizen\Api
Location: includes/Api/ApiWebappManifest.php
Based on: MobileFrontend extension implementation
Task: T282500 - This should eventually be merged to MediaWiki core
Constructor
The API module uses dependency injection for required services.Main API object
Name of this API module (typically ‘appmanifest’)
Site content language
Factory for making HTTP requests
URL manipulation utilities
Configuration
The manifest is configured via$wgCitizenManifestOptions in LocalSettings.php:
Short name for the app (shown on home screen)
Description of the wiki
Theme color for browser UI (hex color)
Background color for splash screen (hex color)
Array of icon objects. If empty, icons are auto-detected from
$wgLogosMethods
execute
Executes the API action and builds the manifest response.- Adds manifest fields to API result
- Sets cache to 1 week (
CACHE_MAX_AGE = 604800) - Sets cache mode to
public
Text direction (
ltr or rtl) from content languageLanguage code (e.g.,
en, de, ja)Site name from
$wgSitenameScope URL - set to server root (e.g.,
https://wiki.example.com/)Array of icon objects with
src, sizes, type, and optionally purposeDisplay mode - always
standaloneOrientation preference - always
naturalStart URL - main page URL from
Title::newMainPage()->getLocalURL()Theme color from config
Background color from config
Array of shortcut objects linking to Special:Search, Special:Randompage, and Special:RecentChanges
Short name (only if configured)
Description (only if configured)
getIcons (private)
Gets icons from config or falls back to$wgLogos.
Array of icon objects with allowed keys:
src, sizes, type, purpose- If
$wgCitizenManifestOptions['icons']is set, use those - Otherwise, call
getIconsFromLogos()to auto-detect from$wgLogos
getIconsFromLogos (private)
Auto-detects icons from$wgLogos configuration.
Array of icon objects detected from logo files
1x- Standard resolution logo1.5x- 1.5x resolution logo2x- 2x resolution logoicon- Icon logosvg- SVG logo
- Fetches logo files via HTTP to detect dimensions and MIME type
- SVG logos get
sizes="any"andtype="image/svg+xml" - Skips logos where dimensions cannot be detected
getShortcuts (private)
Generates PWA shortcuts for common special pages.Array of shortcut objects with
name and url keys- Search -
Special:Search - Random page -
Special:Randompage - Recent changes -
Special:RecentChanges
getCustomPrinter
Returns custom JSON formatter for the manifest.Custom printer that outputs proper JSON manifest format
API Usage
Endpoint
Example Request
Example Response
Enabling the Manifest
The manifest is enabled via configuration:SkinCitizen::addMetadata() automatically adds:
Caching
The API response is cached for 1 week (604,800 seconds) withpublic cache mode, making it suitable for CDN caching.
Security Considerations
The manifest is only linked when:$wgCitizenEnableManifestistrue- Anonymous users have read permission (
$wgGroupPermissions['*']['read'] === true)
Related
- SkinCitizen - Main skin class that links to the manifest
- Progressive Web Apps on MDN
- Web App Manifest Spec