In light of religious terrorist attacks in Paris, please see Category:blasphemy!

Freedom Porn:free technology/RHINO

From Freedom Porn
Jump to: navigation, search

RHINO (Rhino Html5 Is Not Oggplayer) adds a special page as well as <video> tag that can play any external Ogg video by generating valid HTML5 code.

Licence

Available under the terms of GNU General Public License 3.0

Produced in the year 2013.
GPLv3
For more information please see Freedom Porn:copyrights.


Features

  • Special:VideoPlayer page which takes a src, width, and height as parameters
    • see how the link is done here.
  • <video> tag, which has src, poster, style, width, and height parameters, their meaning is exactly equivalent to the HTML5 tag, all other parameters are ignored (but some can be specified with settings site-wide).
  • Settings: $wgRhinoAutoplay, $wgRhinoControls, $wgRhinoLoop, $wgRhynoPreload, $wgRhynoMuted;
    • their meaning is self-explanatory.


Installation

Please place the #Code into your $IP/extensions/RHINO directory and add require_once("$IP/extensions/RHINO/RhinoHtml5IsNotOggplayer.php"); to your LocalSettings.php file.

Known issues

  • Need a way to generate cleaner URLs for the special page.
  • Poster cannot be secified for the special page.
  • No way to specify several source files.

Code

RhinoHtml5IsNotOggplayer.php

<?php
#author: VolodyA! V Anarhist
#licence: GPL 3.0

// Defaults (can be changed in LocalSettings.php
global $wgRhinoAutoplay, $wgRhinoControls, $wgRhinoLoop, $wgRhinoPreload, $wgRhinoMuted;
$wgRhinoAutoplay=false;
$wgRhinoControls=true;
$wgRhinoLoop=false;
$wgRhinoMuted=false;
$wgRhinoPreload=false;
 
 
//Avoid unstubbing $wgParser on setHook() too early on modern (1.12+) MW versions, as per r35980
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
        $wgHooks['ParserFirstCallInit'][] = 'wfRhino';
} else {
        $wgExtensionFunctions[] = 'wfRhino';
}
 
if (!defined('MEDIAWIKI')) die();
 
$credits = array(
        'name' => 'Rhino Html5 Is Not Oggplayer',
        'version' => '0.1',
        'author' => 'VolodyA! V Anarhist',
        'description' => 'Allows to use <tt>&lt;video&gt;</tt> tag to play external Ogg files as well as [[Special:VideoPlayer]] as a separate page for that.',
        'url' => 'http://www.freedomporn.org/smut/Freedom_Porn:free_technology/RHINO'
);
  $wgExtensionCredits['parserhook'][] = $credits;
  $wgExtensionCredits['specialpage'][] = $credits;
 
$wgSpecialPageGroups['VideoPlayer'] = 'mediapresentation';
 
function wfRhino()
{
        global $wgParser;
        $wgParser->setHook( 'video', 'rhinoVideo' );
        return true;
}
 
$dir = dirname(__FILE__) . '/';
 
require_once($dir.'TagVideo.php');
 
$wgAutoloadClasses['SpecialVideoPlayer'] = $dir . 'SpecialVideoPlayer.php'; # Location of the SpecialMyExtension class (Tell MediaWiki to load this file)
$wgExtensionMessagesFiles['VideoPlayer'] = $dir . 'RhinoHtml5IsNotOggplayer.i18n.php'; # Location of a messages file (Tell MediaWiki to load this file)
$wgExtensionMessagesFiles['VideoPlayerAlias'] = $dir . 'RhinoHtml5IsNotOggplayer.alias.php'; # Location of an aliases file (Tell MediaWiki to load this file)
$wgSpecialPages['VideoPlayer'] = 'SpecialVideoPlayer'; # Tell MediaWiki about the new special page and its class name

RhinoHtml5IsNotOggplayer.alias.php

<?php
/**
 * Aliases for RHINO
 *
 * @file
 * @ingroup Extensions
 */
 
$specialPageAliases = array();
 
/** English
 * @author VolodyA! V Anarhist
 */
$specialPageAliases['en'] = array(
        'VideoPlayer' => array( 'VideoPlayer', 'Video Player' ),
);
 
/** Russian
 * @author VolodyA! V Anarhist
 */
$specialPageAliases['de'] = array(
        'MyExtension' => array( 'ВидеоПлеер', 'Видео Плеер' ),
);

RhinoHtml5IsNotOggplayer.i18n.php

<?php
/**
 * Internationalisation for RHINO
 *
 * @file
 * @ingroup Extensions
 */
$messages = array();
 
/** English
 * @author VolodyA! V Anarhist
 */
$messages['en'] = array(
  'videoplayer' => 'Rhino HTML5 Is Not Oggplayer', // Ignore
  'videoplayer-desc' => "Allows to output the page to play the HTML5-compatible video.",
  'specialpages-group-mediapresentation' => 'Non-standard media presentation',
);
 
/** Message documentation
 * @author VolodyA! V Anarhist
 */
$messages['qqq'] = array(
  'videoplayer-desc' => "{{desc}}",
  'specialpages-group-mediapresentation' => 'Non-standard media presentation',
);

SpecialVideoPlayer.php

<?php
class SpecialVideoPlayer extends SpecialPage
{
  function __construct()
  {
    parent::__construct( 'VideoPlayer' );
  }
 
  function execute( $par )
  {
    global $wgRequest, $wgOut, $wgLogo;
    $this->setHeaders();
 
    # Get request data from, e.g.
    $width = $wgRequest->getText('width');
    $height = $wgRequest->getText('height');
    $src=$wgRequest->getText('src');
    $src=str_replace('\'', '%27', $src); // urlencode breaks slashes and collons
 
    if($src)
    {
	  global $wgRhinoAutoplay, $wgRhinoControls, $wgRhinoLoop, $wgRhinoPreload, $wgRhinoMuted;
 
      $settings =" src='{$src}' ";
      $settings.=" poster='${wgLogo}'";
      if($wgRhinoAutoplay) $settings.=" autoplay='autoplay' ";
      if($wgRhinoControls) $settings.=" controls='controls' ";
      if($wgRhinoLoop)     $settings.=" loop='loop' ";
      if($wgRhinoPreload)  $settings.=" preload='auto' ";
      else     $settings.=" preload='none' ";
      if($wgRhinoMuted)    $settings.=" muted='muted' ";
      $settings.=" height='{$height}' ";
      $settings.=" width='{$width}' ";
 
      $output = "<div align='center'><video {$settings} /></div>";
    }
    else
    {
	  $output = wfMsg('videoplayer-desc');
	}
    $wgOut->addWikiText( $output );
  }
}

TagVideo.php

<?php
function rhinoVideo($input, $argv, $parser)
{
  global $wgRhinoAutoplay, $wgRhinoControls, $wgRhinoLoop, $wgRhynoPreload, $wgRhynoMuted;
  //$parser->disableCache();
  $settings =" src='{$argv['src']}' ";
  $settings.=" poster='{$argv['poster']}' ";
  $settings.=" style='{$argv['style']}' ";
  if($wgRhinoAutoplay) $settings.=" autoplay='autoplay' ";
  if($wgRhinoControls) $settings.=" controls='controls' ";
  if($wgRhinoLoop)     $settings.=" loop='loop' ";
  if($wgRhinoPreload)  $settings.=" preload='auto' ";
  else                 $settings.=" preload='none' ";
  if($wgRhinoMuted)    $settings.=" muted='' ";
  $settings.=" height='{$argv['height']}' ";
  $settings.=" width='{$argv['width']}' ";
  return "<video {$settings} /><big>Your browser doesn't support HTML5, please upgrade.</big></video>";
}