Extension:Semantic Glossary/Example

From mediawiki.org
Example using Semantic Glossary

For this example we will create a page about 'Hypertext Markup Language' (text taken from Wikipedia). Certain terms and abbreviations appearing on that page (CSS, CERN, etc.) will have additional glossary definitions available, but instead of leaving the original page about HTML to check those definitions, we would like them to be underlined and when one hovers over them the definition should appear.

Create a page 'Hypertext Markup Language'[edit]

Insert the following text (taken from Wikipedia):

HTML is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages. Web browsers can refer to CSS to define the appearance and layout of text and other material. The W3C, maintainer of both the HTML and the CSS standards, encourages the use of CSS over explicitly presentational HTML markup. In 1980, physicist Tim Berners-Lee, who was a contractor at CERN, proposed and prototyped ENQUIRE, a system for CERN researchers to use and share documents. Berners-Lee considered HTML to be an application of SGML. It was formally defined as such by the IETF with the mid-1993 publication of the first proposal for an HTML specification.

Create another page 'Cascading Style Sheet'[edit]

Insert the following text:

Glossary definition using Semantic MediaWiki
[[Glossary-Definition::Cascading Style Sheet]]s ([[Glossary-Term::CSS]]) is a style sheet language used to describe the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML.

Observe the definition of the glossary term and the glosary definition at the beginning of the text.

Create similar pages for 'CERN', 'ENQUIRE', 'SGML', and 'IETF'[edit]

Check the page 'Hypertext Markup Language'[edit]

The abbreviations should be underlined now and when you hover over them the respective definition should appear.

Provide links with the tooltips[edit]

For example go to the page 'Cascading Style Sheet' and add the following:

[[Glossary-Link::Cascading Style Sheet]]

This will add a link to the tooltip for CSS that links back to the 'Cascading Style Sheet' page. Check that it worked on the 'Hypertext Markup Language' page.

You can also provide interwiki links, e.g. on the 'Cascading Style Sheet' try replacing the definition of the link by

[[Glossary-Link::w:Cascading Style Sheet]]

Create a list of glossary terms and definitions[edit]

Query page

To do so, create a page 'Glossary' and put the following query in it:

{{#ask:[[Glossary-Term::+]]
|?Glossary-Term
|?Glossary-Definition
|?Glossary-Link
|mainlabel=-
|format=table
}}

Using internal objects[edit]

Glossary terms can also be described by using internal object declarations.

SMW 1.7+ Subobject[edit]

{{#subobject:HTML
|Glossary-Term=HTML
|Glossary-Definition=HyperText Markup Language
|Glossary-Link=wp:HTML}}

Semantic Internal Objects[edit]

{{#set internal:Glossary
|Glossary-Term=HTML
|Glossary-Definition=HyperText Markup Language
|Glossary-Link=wp:HTML}}