Extension:Semantic Expressiveness

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
Semantic Expressiveness

Release status: experimental

Implementation Extended syntax, Parser function
Description Adds a new syntax for short inline queries with the purpose of reducing redundant declaration of information within the wiki.
Author(s) Daniel Werner (Danwetalk)
Latest version 0.1 alpha (2012-03-16)
MediaWiki MW 1.20+, SMW (tested with 1.7alpha and 1.8 alpha)
PHP 5.3+
Database changes No
License GNU GPL v3
Download
README
RELEASE-NOTES
Example RPG-Dev-Wiki
Hooks used
OutputPageParserOutput

InternalParseBeforeSanitize

Translate the Semantic Expressiveness extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

Semantic Expressiveness is an enhancement for Semantic MediaWiki. Its main feature is to introduce a new syntax for inline short queries. The purpose of this simplest form of inline query is to provide a powerful tool for fighting redundancies within the wiki. Without Semantic Expressiveness it is customary to declare properties in one place but using the same information again all over the same article or on other pages as simple text representation. With Semantic Expressiveness it is possible to use simple references in form of a new syntax to place the same information in various places without writing redundant information. This way if the property changes, the information will update itself all over the wiki wherever the new syntax is in place.

There are also further features like parser functions for template developers and a JavaScript context popup using AJAX to display further information on cross-article inline queries.

Inline Short Query Syntax[edit | edit source]

The inline short query syntax is quite similar to Semantic MediaWikis show parser function. It displays one property value of the article its defined on or of another article. The simplest variant of it would be just <?Name> which would simple print the value of the property called Name defined on the same page. To print the property of another page <?Name::Page> can be used. In case the property is not declared on the target page, this syntax will print an abstract text communicating what information it represents.

Nested Syntax[edit | edit source]

It is possible to use the syntax in a nested way like <?Name::Father::Father::Little Boy> or alternatively <?Name::<?Father::<?Father::Little Boy>>>. Considering Little Boy is a page representing a human and it has a property Father of type Page which refers to another page which also represents a human and has the same property, this will print the name of the Little Boys grandfather.

By Reference[edit | edit source]

It will be possible to query the property of a page referred to by a property of the type Page defined on the current page.

Usage Within Template Parameters[edit | edit source]

The syntax is being parsed after parser functions and templates. It respects special MediaWiki constructs such as comments, nowiki, includeonly, noinclude and pre. Therefore when used as template parameter provided data, the template will not receive the short queries result but the syntax itself. If the template doesn't intend to further process the value and the author would not expect the template to process the result, the template can still return text with the original parameter input holding the short query syntax and at a later state of the parser process it will be replaced with its actual result.

If on the other hand it is expected that the template should work with the short queries result, this will only work by using the Semantic Expressiveness parser function ?to?! on the provided parameter value. The parser function will then trigger an early parsing of the syntax and can return the result in various different formats, most notably as plain text without any abstract value in case of failure, so the template can carry on with processing the information.

?to?! Parser Function[edit | edit source]

TBD - The name of this function will probably change

Parameter Description Allowed values Default
First parameter has to be the input text. any string
format The actual output format. if this is set to raw, all the additional output parameters will have no effect. By default output will be print as wikitext. wiki, raw wiki
detect Explicitly defines which expressive string pieces should be recognizedby the function wikilink, shortquery, shortqueryresult all values
ignore Explicitly defines which expressive string pieces should not be recognized by the function
info This is the group option for the following ones. If it is set to yes the output will contain all possible sort of informational output such as links, error messages and additional markup. The following parameter values can overwrite this behavior in detail if they aren't set to auto. yes, no yes
link Whether or not to link some information within the found pieces in the output all, none, auto auto
error Whether or not to display error messages if there are any available for some piece. show, hide, auto auto
abstract Whether or not to display abstract information for expressive piece which can't be resolved. show, hide, auto auto

Early Extension State[edit | edit source]

Although this is just an early release, the very concept of this has proven helpful for quite some time already. This has started as part of Daniel Werners RPG-Dev-Wiki project until he decided to release some of the features in a proper extension.

Although the main functionality works, there is still a lot of polishing and bug fixing to do until this can be used in a productive environment. Also, parts of the concept and syntax might change, if anyone has thoughts on this, don't hesitate to use the talk page or contact the author.

Installation[edit | edit source]

This extension will require PHP 5.3 or higher. It also depends on a bugfix for Task T36678 which has to be deployed manually for the time-being.

Once you have downloaded the code, place the SemanticExpressiveness directory within your MediaWiki extensions directory. Then add the following code near the bottom of your LocalSettings.php file:

# Semantic Expressiveness
require_once( "$IP/extensions/SemanticExpressiveness/SemanticExpressiveness.php" );

Configuration[edit | edit source]

TBD