Monday, September 5, 2011

Spatial Wiki 11 - MediaWiki Markup and Templates

This is part 11 of a series of blog posts on building a Spatial Wiki.  At this point we have the wiki and parts of the spatial backend in-place, but before we continue it would be good to go through some of the markup and templating capabilities in MediaWiki.  Amongst other things templates allow you to collect and display information in a consistent manner so we'll setup and use a template to manage the geographic reference for an article.  We won't use the official Wikipedia templates, but what we'll do will be based on the standard Coord template in Wikipedia so our information and procedures will be compatible with Wikipedia.  The notes below include some brief (very brief) information on MediaWiki markup, and walk through setting up a Coord template for our use.

A great overall reference for MediaWiki that is great to get started with is MediaWiki (Wikipedia and Beyond) by Daniel Barrett.

Editing in MediaWiki

To edit in MediaWiki just select the "edit" option at the top of the page.  Each page should be thought of as an article in the Wiki and you will be editing the contents of that article.  Editing is typically via a straight-forward text editing window, and you can enter straight text or use special characters for markup to get bold, underlines, larger titles, etc.  There are loads of on-line references for the MediaWiki markup syntax, for example see the MediaWiki article in Text Formatting.  Another great reference is to view the source for an article in Wikipedia, it's all there, and since Wikipedia is powered by MediaWiki the markup is the same.








Note also the "history" tab at the top of each article.  Wiki articles are stored in a database along with a complete version history so you can use the History tab to track changes and go back to previous versions if needed.

Creating a New Article

There are various ways to create a new article, but one of the easiest and best ways is to start with a reference to the new article on an existing page.  A lot of the value in a Wiki is the internal links to related articles so it's a good idea to "ground" anything new with something existing.  References (links) to other articles are enclosed in double square brackets so you might have something like [[Great New Article]] that would be a link to an article titled "Great New Article."  For demonstration purposes I'll create a reference to an article about the Etta Pegmatite which is a somewhat famous (limited circles) mine near Mt. Rushmore in South Dakota.  The article link on the main page is [[Etta Pegmatite]].  It will be displayed in red indicating that it doesn't exist and when I click on it I will be able to create the new article.

Creating a Template

Templates are a special type of page that can be used to display the same information in multiple locations, or to enforce formatting standards for specific information.  In our case we'll create a template called Coord that will manage the spatial reference in a wiki page.  To create the template type Template:Coord in the search box and hit Go.  Since the page doesn't exist MediaWiki will ask it you want to create it ... yes.  This is another way to create new wiki pages.  On the new Template:Coord page add the text/markup:
{| border="0" cellpadding="4" cellspacing="0" style="border:0px solid darkgray;"
! width="600px"|
|- 
| valign="top" style="background:#e4f7dd; border-style: solid; border-width: 1px 0 1px 0; border-color:darkgray"| Latitude {{{1}}} Longitude {{{2}}}, Type {{{3|Undefined}}}
|}

This is markup to create a table that is 600 pixels wide with a green background and a horizontal like along the top and the bottom. The table will contain text for the latitude, longitude, and point type. These are referenced as parameters that are passed into the template, for example {{{2}}} is the second parameter and refers to the longitude.  When you save the template it will look like this:






Using the Coord Template

To use the new Coord template specify the template name and include the parameters latitude, longitude, and point type separated by a | character.  For example in the article on the Etta Pegmatite I have:
The Etta Pegmatite is near Keystone, South Dakota.

{{Coord|43.8810|-103.4165|Pegmatite}}

This will then be displayed as shown on the article:








So far the template is "dumb" and other than display the coordinate reference nicely formatted it doesn't do anything.  In the next article we'll install an extension to extract the geographic reference and add it to the spatial database.

See next article on Installing the SpatialWiki Extension.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home