Help:Semantic service links

Semantic MediaWiki can provide links to online services when printing certain data in the factbox. For example, when a geographic coordinate is entered into an article, it makes sense to provide links to online mapping services, so that users can retrieve a map of the specified area with one click. This page explains how such features can be added to the semantic wiki.

Note: To suggest new service links for this wiki, please use the discussion page of this article.

Service links for properties
When an editor annotates text with a property that provides service links, this will not transform the annotated text into a link to any particular service or set of services. Instead, the question-mark icon will appear in the factbox, next to the search icon, like this:. When the reader moves his mouse cursor over the question mark, a tooltip appears with links to the outside online services. The particular linked services will depend upon the properties used and annotated, and how they are defined.

For example, the Property:Coordinates will show various links to online maps when printed in the factbox, whereas other properties that also use Type:Geographic coordinate might not show this. This is crucial in many applications, since the datatype alone usually does not say much about the type of link. For example a property "IMDb number" might be used for a movie's id number at IMDb, but not every property of Type:Number should display a link to IMDb.

In order to attach some services to a property, use the special property provides service on its page. For example, the article Property:Coordinates includes the annotation

provides service::online maps

Here, "online maps" is the name of a set of service links provided by the wiki. The next section explains how such services can be provided. In the above case, the service "online maps" is already known to the wiki, and every appearance of the attribute "Coordinates" within the factbox will now show the according set of links.

Providing services
Attributes can only use services that are available in the wiki. Since service links may appear in thousands of factboxes, it should be ensured that they can be trusted. For this reason, only administrators can add or modify services. All other users, however, are free to use or not use those services in the properties they create and define as described above. To recommend the addition or modification of on-line services, address your comments and suggestions to the talk page of this help article, or to the Coffeehouse.

Typically, an editor defines a property that adds a service with the special property "provides service", and then annotates appropriate text with that property. The factbox of any article so annotated will display a link labeled like the given service. For example, the factbox of the property "Coordinates" would display the link "online maps." Following this link leads you to a message article, in this case MediaWiki:Smw service online maps, that lists the links that are provided by this service. Though the message might be hard to read due to the long lines, its format essentially is as follows:

label|http://someurl.org label2|http://anotherurl.org ...

Every line contains one link that should be shown in the factbox. The label is the text that users will see in the factbox (e.g. "Mapquest"). After the "|" it is followed by a URL that the link will lead to. In most cases, the URL will need to contain certain information about the attribute value for which the service eventually is provided. For example, a link to an online map will include the coordinates that the map will show.

Since the exact data values are not known in advance, the URLs in the above messages contain place holders of the form $1, $2, $3, &hellip; For example, the link to MapQuest looks like this:

Mapquest|http://www.mapquest.com/maps/map.adp?searchtype=address&formtype=latlong&latlongtype=degrees&latdeg=$11$1&latmin=$3&latsec=$5&longdeg=$12$2&longmin=$4&longsec=$6&zoom=6

The placeholder "$1" indicates the position that the attribute should later insert its value into in order to create the actual link in the factbox. The number and contents of the parameters depends on the attribute that uses the service, and especially on its datatype. For instance, a simple integer attribute might merely replace $1 by its value, whereas a geographic coordinate provides much more parameters for latitude, longitude, direction, and much more. In most cases, $1 will be the most relevant parameter that just provides a URL-save string version of the attribute value.

Since service links are typically perceived as "trusted resources," administrators must take some care when formulating links, keeping in mind that users might insert almost arbitrary URL-encoded strings for the place holders.