Extension:MobileMeta

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
MobilaMeta

Release status: beta

Implementation Tag
Description Adds <meta name="viewport" content="width=device-width, initial-scale=1.0" /> tag into the page header.
Author(s) Andy Chow
Latest version 0.1 (2013-04-25)
MediaWiki 1.19+
Database changes No
License The MIT License
Download No link
Example http://m.transitunlimited.org/
Tags
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Hooks used
OutputPageBeforeHTML

Translate the MobileMeta extension if possible

Check usage and version matrix; code metrics

The MobileMeta extension adds <meta name="viewport" content="width=device-width, initial-scale=1.0" /> tag into the page header. Because of the new skinning method beginning Mediawiki version 1.18, it is no longer preferable to add include the tag in the skin itself. This would be suitable if the mobile version of the site is operated on a separate Mediawiki installation.

Installation[edit | edit source]

Install this file MobileMeta.php in the extension directory:

<?php
/*
 * MobileMeta.php - A MediaWiki tag extension for adding <meta> description to a page.
 * @author Andy Chow
 * @version 0.1
 * @copyright Copyright (C) 2013 Transit Unlimited Services LLC
 * @license The MIT License - http://www.opensource.org/licenses/mit-license.php
 * -----------------------------------------------------------------------
 * Description:
 *     This is a MediaWiki extension which adds <meta name="viewport" content="width=device-width, initial-scale=1.0" /> tag
 *     into the page header.
 * Requirements:
 *     MediaWiki 1.19.x
 *     PHP 4.x, 5.x or higher
  * Installation:
 *     1. Drop this script (MobileMeta.php) in $IP/extensions
 *         Note: $IP is your MediaWiki install dir.
 *     2. Enable the extension by adding this line to your LocalSettings.php:
 *         require_once('extensions/MobileMeta.php');
 * Version Notes:
 *     version 0.1:
 *         Initial release.
 *
 * -----------------------------------------------------------------------
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * -----------------------------------------------------------------------
 */

 
if( !defined( 'MEDIAWIKI' ) ) {
        echo "This file is part of MediaWiki, it is not a valid entry point.\n";
        exit( 1 );
}
 
# Credits
$wgExtensionCredits['parserhook'][] = array(
        'name' => 'MobileMeta',
        'author' => 'Andy Chow',
        'url' => 'https://www.mediawiki.org/wiki/Extension:MobileMeta',
        'description' => 'Adds the <code><meta name="viewport" content="width=device-width, initial-scale=1.0" /></code> tag to the page header',
        'version'=> '0.1'
);

# $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR;
$wgHooks['OutputPageBeforeHTML'][] = 'insertMetaDescription';
 
function insertMetaDescription( $out ) {
    $out->addMeta( 'viewport', 'width=device-width, initial-scale=1.0' );
        return true;
}

Configuration parameters[edit | edit source]

None.