WikiTask Tutorial/Temperature example

From BITPlan Wiki
Jump to navigation Jump to search

SiDIF input for temperature example

This is some SiDIF input. It has the id='temperature'

Temperature today cool
Temperature yesterday modest
Temperature tomorrow warm
Cloud today cloudy
Cloud yesterday partly
Cloud tommorrow sunny

Freemarker template for graphviz triplegraphs

The following template generates a graphviz representation of the triples defined by the SiDIF-input. This template is identified by the id='wikitasktemplate'.

<#assign rankdir="TB"/>
<#assign triples=tripleStore.getTriples()/>
== Triple graph ==
<graphviz format='svg'>
 digraph ${wikiTask.input} {
  rankdir="${rankdir}";
  <#list triples as triple>
    "${triple.subject}" -> "${triple.object}" [label="${triple.predicate}"];
  </#list>
  }
</graphviz>

WikiTask for temperature example

The wikitask uses the input with the id='temperature' and the template with the id='triplegraph' to create the given targetpage

{{wikitask|cmd=runtemplate|input=temperature|template=triplegraph|targetpage=WikiTask Tutorial/temperature}}

Just click on the green "run" button to try it out: runtemplate -> WikiTask Tutorial/temperature

expected result

First the wiki markup generated is shown and then the graph as it is rendered by the graphviz extension.

wiki markup
<graphviz format='svg'>
 digraph  temperature_expected_result {
  rankdir="TB";
    "Temperature" -> "cool" [label="today"];
    "Temperature" -> "modest" [label="yesterday"];
    "Temperature" -> "warm" [label="tomorrow"];
    "Cloud" -> "cloudy" [label="today"];
    "Cloud" -> "partly" [label="yesterday"];
    "Cloud" -> "sunny" [label="tomorrow"];
  }
</graphviz>
graph

0xf344c175.png