Skip to content

Commit

Permalink
Added µf.org version of OverrideEntryTitle, and README describing usa…
Browse files Browse the repository at this point in the history
…ge and documenting known caching issues.
  • Loading branch information
Ben Ward committed Dec 27, 2008
0 parents commit 593d766
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
26 changes: 26 additions & 0 deletions OverrideEntryTitle.class.php
@@ -0,0 +1,26 @@
<?php
/** @class OverrideEntryTitle.
* This extension adds an <entry-title> element into MediaWiki mark-up
* allowing pages to have the displayed title overriden. For example:
*
* The page /wiki/hcard can have its displayed title overridden to 'hCard'
* The page /wiki/hcard-issues can have a title 'hCard Issue Tracking'
* The page /wiki/t can have an overridden title 'Tantek Çelik'
*
* @author Ben Ward
*/
class OverrideEntryTitle {

public static function parseEntryTitle($text, $attributes, $parser) {
global $wgOut;
$parser->disableCache(); // EPIC hack. Need to instead cache/restore this value
$wgOut->mPagetitle = $text;
return '';
}

public static function registerHooks() {
global $wgParser;
$wgParser->setHook('entry-title', array('OverrideEntryTitle', 'parseEntryTitle'));
}
}
?>
22 changes: 22 additions & 0 deletions OverrideEntryTitle.i18n.php
@@ -0,0 +1,22 @@
<?php
/** Extension: OverrideEntryTitle.
* This extension adds an <entry-title> element into MediaWiki mark-up
* allowing pages to have the displayed title overriden. For example:
*
* The page /wiki/hcard can have its displayed title overridden to 'hCard'
* The page /wiki/hcard-issues can have a title 'hCard Issue Tracking'
* The page /wiki/t can have an overridden title 'Tantek Çelik'
*
* English strings
* @lang English
* @author Ben Ward
*/


$messages = array();

$messages['en'] = array(
'overrideentrytitle-desc' => 'Allows you to override the title of a wiki entry by using an <entry-title> element in the entry.'
);

?>
41 changes: 41 additions & 0 deletions OverrideEntryTitle.php
@@ -0,0 +1,41 @@
<?php

/** Extension: OverrideEntryTitle.
* This extension adds an <entry-title> element into MediaWiki mark-up
* allowing pages to have the displayed title overriden. For example:
*
* The page /wiki/hcard can have its displayed title overridden to 'hCard'
* The page /wiki/hcard-issues can have a title 'hCard Issue Tracking'
* The page /wiki/t can have an overridden title 'Tantek Çelik'
*
* @author Ben Ward
*/

if( !defined( 'MEDIAWIKI' ) )
die();

$wgExtensionCredits['parserhook']['OverrideEntryTitle'] = array(
'name' => 'Override Entry Title',
'svn-date' => '$LastChangedDate: 2008-07-16 23:44:00 +0100 (Wed, 16 July 2008) $',
'svn-revision' => '$LastChangedRevision: $',
'author' => array( 'Ben Ward' ),
'description' => 'Allows you to override the title of a wiki entry by using an <entry-title> element in the entry.',
'descriptionmsg' => 'overrideentrytitle-desc',
'url' => 'http://www.mediawiki.org/wiki/Extension:OverrideEntryTitle',
);

$dir = dirname(__FILE__) . '/';
$wgExtensionMessagesFiles['OverrideEntryTitle'] = $dir . 'OverrideEntryTitle.i18n.php';
$wgAutoloadClasses['OverrideEntryTitle'] = $dir . 'OverrideEntryTitle.class.php';
$wgHooks['ParserFirstCallInit'][] = 'initOverrideEntryTitle';

/**
* Register parser hook
*/
function initOverrideEntryTitle() {
require_once('OverrideEntryTitle.class.php');
OverrideEntryTitle::registerHooks();
return true;
}

?>
32 changes: 32 additions & 0 deletions README
@@ -0,0 +1,32 @@
MediaWiki Extension — Override Entry Title

OverrideEntryTitle is a crude and rather hacky MediaWiki extension to allow
you to override a MediaWiki page name with someone more human legible, for
instance, the page `/wiki/hatom` may be overridden to ‘hAtom 0.3’.

Usage:
-----

This extension adds an `<entry-title>` element to the MediaWiki syntax (named
for its correspondence to marking up entries in hAtom). The content of that
element overrides the default title of the page at render time, and removes
that content from the document body.

Known Issues:
------------

1. This extension disables caching of rendered page content.

To Do:
-----

1. Add a more wiki-esque shorthand syntax (perhaps `!! Page Title !!`)
2. Support caching of the override title and apply the override on every page
load, not just when the content is parsed.



Originally written for microformats.org/wiki, by Ben Ward

* http://microformats.org/wiki/
* http://ben-ward.co.uk

0 comments on commit 593d766

Please sign in to comment.