Google Books and Mediawiki
Following on from the previous post, I wrote a simpe Mediawiki extension to insert a Google Book into a wiki page. Written in a few minutes, not tested much, etc.
To use this, copy the code below and save in a file googlebook.php in the extensions directory of your Mediawiki installation.
# rdmp
# Google Book extension
# Embed a Google Book into Mediawiki
#
# Usage:
#
#
# To install it put this file in the extensions directory
# To activate the extension, include it from your LocalSettings.php
# with: require("extensions/googlebook.php");
$wgExtensionFunctions[] = "wfGoogleBook";
function wfGoogleBook() {
global $wgParser;
# registers the extension with the WikiText parser
$wgParser->setHook( "googlebook", "renderGoogleBook" );
}
# The callback function for converting the input text to HTML output
function renderGoogleBook( $input, $argv )
{
$width = 425;
$height = 400;
if (isset($argv["width"]))
{
$width = $argv["width"];
}
if (isset($argv["height"]))
{
$width = $argv["height"];
}
$output = ' src="http://books.google.com/books/previewlib.js">
';
$output .= ' <br /> GBS_insertEmbeddedViewer(\'' <br /> . $argv["id"] . '\','. $width . ',' . $height . ');<br /> ';
return $output;
}
?>
In your LocalSettings.php file add the line
require("extensions/googlebook.php");
Now you can add a Google book to a wiki page by adding a tag. For example:
The id gives the book identifier (such as an OCLC number or a ISBN (you need to include the identifier prefix). By defaulot, the book will appear in a box 425 × 400 pixels in size. You can add optional width and height parameters to adjust this.
Additional details
Description
Following on from the previous post, I wrote a simpe Mediawiki extension to insert a Google Book into a wiki page. Written in a few minutes, not tested much, etc. To use this, copy the code below and save in a file googlebook.php in the extensions directory of your Mediawiki installation.
Identifiers
- UUID
- 17be1514-b983-49b5-b3f2-906afb6e2f4b
- GUID
- tag:blogger.com,1999:blog-16081779.post-3732044728746632904
- URL
- https://iphylo.blogspot.com/2008/10/google-books-and-wikipedia.html
Dates
- Issued
-
2008-10-24T15:54:00
- Updated
-
2008-10-24T16:08:37