LyricExtension

From PeacockWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:23, 18 May 2006 (edit)
Trevorp (Talk | contribs)
(Example)
← Previous diff
Current revision (06:08, 11 June 2006) (edit)
Trevorp (Talk | contribs)
(Installation)
 
Line 2: Line 2:
==Details== ==Details==
-*Version 0.1+*Version 0.2
-*Date 17 May 2006+*Date 1 June 2006
*Tested on MediaWiki 1.6devel, PHP 5.0.5 (apache2handler) *Tested on MediaWiki 1.6devel, PHP 5.0.5 (apache2handler)
Line 9: Line 9:
*Allows basic lyric notation *Allows basic lyric notation
*Optional CSS styling embedded in every page *Optional CSS styling embedded in every page
 +*Remove CSS from metadata. Replace with insert
 +*Allow extension script file to be run as a standalone php file, to generate CSS data.
 +
==Usage== ==Usage==
Once installed, simply surround lyrics with <nowiki><lyric></nowiki> tags. No indentation of lyrics is needed. Once installed, simply surround lyrics with <nowiki><lyric></nowiki> tags. No indentation of lyrics is needed.
===Example=== ===Example===
 +====Basic====
When the following wikitext is entered into mediawiki When the following wikitext is entered into mediawiki
<pre><lyric> <pre><lyric>
Line 21: Line 25:
Whatever my lot, Whatever my lot,
Thou hast taught me to say, Thou hast taught me to say,
-??It is well,+''??It is well,
-It is well, with my soul.?+It is well, with my soul.?''
- +
-[Very long line, should wrap] O, Lord haste the day When my faith shall be sight, The clouds be rolled back As a scroll; The trump shall resound And the Lord shall descend, ??Even so? it is well With my soul.+
</lyric></pre> </lyric></pre>
it appears formatted in html as it appears formatted in html as
Line 34: Line 36:
Whatever my lot, Whatever my lot,
Thou hast taught me to say, Thou hast taught me to say,
-??It is well,+''??It is well,
-It is well, with my soul.?+It is well, with my soul.?''
- +
-[Very long line, should wrap] O, Lord haste the day When my faith shall be sight, The clouds be rolled back As a scroll; The trump shall resound And the Lord shall descend, ??Even so? it is well With my soul.+
</lyric> </lyric>
Feel free to experiment in the [[SandBox]]. Feel free to experiment in the [[SandBox]].
 +
 +====[[LyricExtension_Wrapping_Example|Wrapping]]====
 +See [[LyricExtension_Wrapping_Example|LyricExtension Wrapping Example]]
==Installation== ==Installation==
Line 47: Line 50:
require("extensions/lyric.php"); require("extensions/lyric.php");
-==Source Code==+To check to see if it is installed properly, visit your Version page, eg [[Special:Version]].
-<pre>+
-<?php+
-#+You should see the following items:
-# Simple lyric parser extension for mediawiki.+*Extensions:
-# Written by Trevor Peacock, 17 May 2006+**Parser hooks:
-# version 0.1+***''[http://wiki.peacocktech.com/wiki/LyricExtension Lyric Extension (version 0.2)]'', Adds features allowing easy notation of lyrics in mediawiki, by [http://about.peacocktech.com/trevorp/ Trevor Peacock]
-# Tested on MediaWiki 1.6devel, PHP 5.0.5 (apache2handler)+**Extension functions:
-#+***LyricExtension
-# developed to support the notation of lyrics in mediawiki.+*Hooks:
-# see http://lyricwiki.org/User:TrevorP/Notation+**SkinTemplateSetupPageCss:LyricCss
-#+
-# Features:+
-# * Allows basic lyric notation+
-# * Optional CSS styling embedded in every page+
-#+
-# To install, copy this file into "extensions" directory, and add+
-# the following line to the end of LocalSettings.php+
-# (above the ? > )+
-#+
-# require("extensions/lyric.php");+
-#+
-################################################################################+The SkinTemplateSetupPageCss:LyricCss hook may be disabled, and if done so, will not appear.
-# Extension Credits Definition+
-#+
-# This section has no configuration, and can be ignored.+
-#+
-$wgExtensionCredits["LyricExtension"]=array(+==Releases==
- 'name' => 'Lyric Extension',+===Todo===
- 'version' => '0.1',+{{:LyricExtension/Todo}}
- 'url' => 'http://wiki.peacocktech.com/wiki/LyricExtension',+[[LyricExtension/Todo|Full Todo]]
- 'author' => '<a href="http://about.peacocktech.com/trevorp/">Trevor Peacock</a>',+===RoadMap===
- 'description' => 'Adds features allowing easy notation of lyrics in mediawiki' );+{{:LyricExtension/RoadMap}}
- +[[LyricExtension/RoadMap|Full RoadMap]]
- +===History===
-################################################################################+{{:LyricExtension/History}}
-# Lyric Render Section+[[LyricExtension/History|Full History]]
-#+==Source Code==
-# This section has no configuration, and can be ignored.+Authoritative version of source code available at [[LyricExtension/Source_Code]].
-#+{{:LyricExtension/Source_Code}}
-# This section renders <lyric> tags. It forces a html break on every line,+
-# and styles the section with a css id.+
-# this id can either be in the mediawiki css files, or defined by the extension+
-#+
- +
-#Instruct mediawiki to call LyricExtension to initialise new extension+
-$wgExtensionFunctions[] = "LyricExtension";+
- +
-#Install extension+
-function LyricExtension()+
-{+
- #install hook on the element <lyric>+
- global $wgParser;+
- $wgParser->setHook("lyric", "renderLyric");+
-}+
- +
-#render <lyric> text+
-function renderLyric($input, $argv)+
-{+
- #make new lines in wikitext new lines in html+
- $transform=str_replace(array("\r\n", "\r","\n"), "<br/>", trim($input));+
- +
- #define css lyric style+
- $transform="<div id=\"lyric\">".$transform."</div>";+
- +
- #parse embedded wikitext+
- global $wgOut;+
- return $wgOut->parse($transform, false);+
-}+
- +
-################################################################################+
-# CSS Styling Section+
-#+
-# This section may require configuration.+
-#+
-# This section adds a css style to all pages to style lyric sections+
-#+
- +
-# If you wish to manually define the style in the css templates,+
-# add a "#" at the start of this line:+
-$wgHooks['SkinTemplateSetupPageCss'][] = 'LyricCss';+
- +
-function LyricCss(&$css) {+
- $css = "/*<![CDATA[*/\n".+
- "#lyric {\n".+
- " padding: 1em;\n".+
- " border: 1px solid silver;\n".+
- " color: black;\n".+
- " background-color: #ffffcc;\n".+
- "}\n".+
- "\n/*]]>*/";+
- return true;+
-}+
-?>+[[LyricExtension/Source_Code_Dev|Development version]]
-</pre>+

Current revision

LyricExtension is an extension for Mediawiki that provides features facilitating the notation of song lyrics in the wiki.

Contents

Details

  • Version 0.2
  • Date 1 June 2006
  • Tested on MediaWiki 1.6devel, PHP 5.0.5 (apache2handler)

Features

  • Allows basic lyric notation
  • Optional CSS styling embedded in every page
  • Remove CSS from metadata. Replace with insert
  • Allow extension script file to be run as a standalone php file, to generate CSS data.

Usage

Once installed, simply surround lyrics with <lyric> tags. No indentation of lyrics is needed.

Example

Basic

When the following wikitext is entered into mediawiki

<lyric>
When peace like a river,
Attendeth my way,
When sorrows,
Like sea billows roll;
Whatever my lot,
Thou hast taught me to say,
''??It is well,
It is well, with my soul.?''
</lyric>

it appears formatted in html as <lyric> When peace like a river, Attendeth my way, When sorrows, Like sea billows roll; Whatever my lot, Thou hast taught me to say, ??It is well, It is well, with my soul.? </lyric> Feel free to experiment in the SandBox.

Wrapping

See LyricExtension Wrapping Example

Installation

Copy and paste the source code into a file named 'lyric.php', and place it in the 'extensions/' directory of your mediawiki installation.

Insert the following line into the end of 'LocalSettings.php' (before the '?>')

require("extensions/lyric.php");

To check to see if it is installed properly, visit your Version page, eg Special:Version.

You should see the following items:

The SkinTemplateSetupPageCss:LyricCss hook may be disabled, and if done so, will not appear.

Releases

Todo

  • linking songs on the same album (importnat for concept albums), and possibly albums by the same band

Facilitate notation of:

Full Todo

RoadMap

0.3 No Date

  • Add notation for speech and notes


Full RoadMap

History

0.2.2 - Date 2 August 2009

  • Attempt to fix "Undefined variable: wgScriptPath in /var/www/html/lyricwiki.org/extensions/lyric.php on line 109" error. found by Lorenzo at http://wiki.rockciclopedia.com/

0.2.1 - Date 28 August 2006

  • Change parsing method to fix rendering problem
  • Fix possible CSS styling conflict

0.2 - Date 1 June 2006

  • Remove CSS from metadata. Replace with insert
  • Allow extension script file to be run as a standalone php file, to generate CSS data.

0.1 - Date 18 May 2006

No Functional change.

  • Fixed wgExtensionCredits

0.1 - Date 17 May 2006

First release

  • Allows basic lyric notation
  • Optional CSS styling embedded in every page

Full History

Source Code

Authoritative version of source code available at LyricExtension/Source_Code.

<?php

#
# Simple lyric parser extension for mediawiki.
# Written by Trevor Peacock, 1 June 2006
# version 0.2.1
# Tested on MediaWiki 1.6devel, PHP 5.0.5 (apache2handler)
#
# developed to support the notation of lyrics in mediawiki.
# see http://lyricwiki.org/User:TrevorP/Notation
#
# Features:
#  * Allows basic lyric notation
#  * Optional CSS styling embedded in every page
#  * CSS styling not embedded in meta tage, rather @import-ed from extension file
#
# To install, copy this file into "extensions" directory, and add
# the following line to the end of LocalSettings.php
# (above the  ? >  )
#
#   require("extensions/lyric.php");
#

################################################################################
# Functions
#
# This section has no configuration, and can be ignored.
#

function filename($name)
{
  $name=explode('/', $name);
  $name=explode('\\', $name[count($name)-1]);
  return $name[count($name)-1];
}

################################################################################
# Extension Credits Definition
#
# This section has no configuration, and can be ignored.
#

if(isset($wgScriptPath))
{
$wgExtensionCredits["parserhook"][]=array(
  'name' => 'Lyric Extension',
  'version' => '0.2.2',
  'url' => 'http://wiki.peacocktech.com/wiki/LyricExtension',
  'author' => '[http://about.peacocktech.com/trevorp/ Trevor Peacock]',
  'description' => 'Adds features allowing easy notation of lyrics in mediawiki' );
}

################################################################################
# Lyric Render Section
#
# This section has no configuration, and can be ignored.
#
# This section renders <lyric> tags. It forces a html break on every line,
# and styles the section with a css id.
# this id can either be in the mediawiki css files, or defined by the extension
#

if(isset($wgScriptPath))
{
#Instruct mediawiki to call LyricExtension to initialise new extension
$wgExtensionFunctions[] = "LyricExtension";
}

#Install extension
function LyricExtension()
{
  #install hook on the element <lyric>
  global $wgParser;
  $wgParser->setHook("lyric", "renderLyric");
  $wgParser->setHook("lyrics", "renderLyric");
}

#render <lyric> text
function renderLyric($input, $argv, $parser)
{
  #make new lines in wikitext new lines in html
  $transform=str_replace(array("\r\n", "\r","\n"), "<br/>", trim($input));

  #define css lyric style
  $transform="<div id=\"lyric\">".$transform."</div>";

  #parse embedded wikitext
  return $parser->parse($transform, $parser->mTitle, $parser->mOptions, 
    false, false)->getText();
}

################################################################################
# CSS Styling Section
#
# This section may require configuration.
#
# This section adds a css style to all pages to style lyric sections
#

# If you wish to manually define the style in the css templates,
# add a "#" at the start of this line:
if(isset($wgScriptPath))
{
$wgHooks['SkinTemplateSetupPageCss'][] = 'LyricCss';
}

function LyricCss(&$css) {
  global $wgScriptPath;
  $css.= "/*<![CDATA[*/".
  " @import \"$wgScriptPath/extensions/".filename(__FILE__)."\"; ".
  "/*]]>*/\n";
  return true;
}

################################################################################
# CSS section
#
# This section has no configuration, and can be ignored.
#

if(!isset($wgScriptPath))
{
  header("Content-type: text/css");
  ?>#lyric {
	padding: 1em;
	border: 1px solid silver;
	color: black;
	background-color: #ffffcc;
}
<?php
}

?>

Development version

Personal tools