Extension:Semantic Expressiveness

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
Semantic Expressiveness

Release status:Extension status experimental

ImplementationTemplate:Extension#type Extended syntax, Parser function
DescriptionTemplate:Extension#description Adds a new syntax for short inline queries with the purpose of reducing redundant declaration of information within the wiki.
Author(s)Template:Extension#username Daniel Werner (Danwetalk)
Latest versionTemplate:Extension#version 0.3.0-alpha (2017-07-28)
MediaWikiTemplate:Extension#mediawiki MW 1.23+, SMW (tested with 1.7alpha and 1.8 alpha)
PHPTemplate:Extension#php 5.3+
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 3.0 or later
ExampleTemplate:Extension#example RPG-Dev-Wiki
Hooks usedTemplate:Extension#hook

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

Check usage and version matrix.

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]

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]

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]

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]

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]

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]

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.


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" );