Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Last active December 31, 2015 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdlrobson/7921828 to your computer and use it in GitHub Desktop.
Save jdlrobson/7921828 to your computer and use it in GitHub Desktop.
manifest
<?php
/**
* This file is the entry point for all API queries.
*
* It begins by checking whether the API is enabled on this wiki; if not,
* it informs the user that s/he should set $wgEnableAPI to true and exits.
* Otherwise, it constructs a new ApiMain using the parameter passed to it
* as an argument in the URL ('?action=') and with write-enabled set to the
* value of $wgEnableWriteAPI as specified in LocalSettings.php.
* It then invokes "execute()" on the ApiMain object instance, which
* produces output in the format specified in the URL.
*
* Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
// So extensions (and other code) can check whether they're running in API mode
define( 'MW_API', true );
// Bail if PHP is too low
if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.3.2' ) < 0 ) {
// We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+
require dirname( __FILE__ ) . '/includes/PHPVersionError.php';
wfPHPVersionError( 'api.php' );
}
// Initialise common code.
require __DIR__ . '/includes/WebStart.php';
wfProfileIn( 'manifest.php' );
$ctx = RequestContext::getMain();
$skin = new SkinMobileAlpha( $ctx );
$req = $ctx->getRequest();
$response = $req->response();
$styleModules = explode( '|', $req->getText( 'style' ) );
$scriptModules = array( 'startup' );
$skinName = $req->getText( 'skin' );
$target = $req->getText( 'target' );
$lang = $req->getText( 'lang' );
$user = null;
$version = null;
$debug = false;
$printable = false;
$handheld = false;
$extraQuery = array( 'target' => $target );
$jsUrl = ResourceLoader::makeLoaderURL( $scriptModules, $lang, $skinName,
$user, $version, $debug, 'scripts', $printable, $handheld, $extraQuery );
$styleUrl = ResourceLoader::makeLoaderURL( $styleModules, $lang, $skinName,
$user, $version, $debug, 'styles', $printable, $handheld, $extraQuery );
// FIXME: This should be tied to the last time SkinMobileApp, startup and styles file were changed.
$version = 3;//time();
// Make all the modules and getModifiedTime
// Get last modified time of Skin.
// FIXME: Need to cache jquery and mediawiki to make this work offline
$response->header( 'Content-type: text/cache-manifest; charset=UTF-8' );
$response->header( 'Cache-Control: no-cache' );
echo <<<HTML
CACHE MANIFEST
NETWORK:
*
HTML;
echo <<<HTML
CACHE:
{$jsUrl}
{$styleUrl}
# {$version}
HTML;
wfProfileOut( 'manifest.php' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment