User Tools

Site Tools


docs:plwiki1api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

docs:plwiki1api [2017/09/19 16:31] (current)
Line 1: Line 1:
 +~~NOCACHE~~
 +====== PlWiki 1.0 - Plugin API ======
 +
 +[[.:​plwiki1ex|Examples available here]]
 +
 +
 +**IMPORTANT:​**
 +
 +This code should be placed on every page using PlWiki plugin:
 +<​code>​ ~~NOCACHE~~ </​code>​
 + 
 +===== Prolog Code in Loki =====
 +
 +The simplest use case. Without cache. Only process knowledge between "​pl"​ tags. 
 +
 +<code loki>
 +<pl goal="​woman(X),​write(X),​nl,​fail">​
 +woman(kate).
 +man(john).
 +</pl>
 +</​code>​
 +
 +__Result__:​\\
 +<pl goal="​woman(X),​write(X),​nl,​fail">​
 +woman(kate).
 +man(john).
 +</pl>
 +
 +
 +More interesting use case: adding knowledge to the page: 
 +
 +<code loki>
 +<pl cache="​true">​
 +man(jack).
 +man(jim).
 +</pl>
 +</​code>​
 +
 +<pl cache="​true">​
 +man(jack).
 +man(jim).
 +</pl>
 +
 +
 +Now when we have prolog code associated with DokuWiki page, we can "​query"​ selected scope or Wiki page. Scope accepts POSIX Regular Expressions.
 +
 +<code loki>
 +<pl goal="​man(X),​write(X),​nl,​fail" ​ scope="​docs:​plwiki1ex"​ >
 +%
 +% Prolog code may be placed here but it is not necessairly.
 +%
 +</pl>
 +</​code>​
 +
 +__Result__:​\\
 +<pl goal="​man(X),​write(X),​nl,​fail" ​ scope="​docs:​plwiki1ex"​ >
 +%
 +% Prolog code may be placed here but it is not necessarily.
 +%
 +</pl>
 +
 +===== Prolog interface =====
 +
 +Loki plugin also contains loki.pl prolog script, which allows to query knowledge gathered in Loki from Prolog.
 +
 +We can list all predicates in selected scope:
 +<code loki>
 +<pl goal="​consult('​lib/​plugins/​loki/​loki.pl'​),​wikiconsult('​docs/​plwiki1api'​),​list."></​pl>​
 +</​code>​
 +
 +__Result__:​\\
 +<pl goal="​consult('​lib/​plugins/​loki/​loki.pl'​),​wikiconsult('​docs/​plwiki1api'​),​list."></​pl>​
 +
 +
 +We can also list informations about selected predicate.
 +
 +<code loki>
 +<pl goal="​consult('​lib/​plugins/​loki/​loki.pl'​),​wikiconsult('​docs/​plwiki1api'​),​list(man)."></​pl>​
 +</​code>​
 +
 +__Result__:​\\
 +<pl goal="​consult('​lib/​plugins/​loki/​loki.pl'​),​wikiconsult('​docs/​plwiki1api'​),​list(man)."></​pl>​
 +
 +
 +===== Categories, Relations, Attributes =====
 +[[http://​semantic-mediawiki.org/​wiki/​Semantic_MediaWiki|Semantic MediaWiki]] syntax is also supported, there are some methods of semantic annotation:
 +
 +  * categories - a simple form of annotation that allows users to classify pages. To state that article (Wiki page) belongs to the category "​category1"​ we have to write <code smw>​[[category:​category1]]</​code> ​
 +
 +  * relations - there is a possibility to describe relationships between two Wiki pages. For example there is a relation "​capital_of"​ between "​cities:​warsaw"​ and "​coutries:​poland"​. To express this we have to just edit the page "​countries:​warsaw"​ and add <code smw>​[[capital of::​countries:​poland]]</​code> ​
 +
 +  * attributes - allows to specify relationships of Wiki pages to things that are not Wiki pages. For example, one can state that Wiki page "​namespace:​page"​ was created at April 22 2009 by writing <code smw>​[[created:​=April 22 2009]]</​code>​
 +
 +  * In addition to this users can search for articles using a simple query language that was developed based on the known syntax of the Wiki. For example: <code smw>​{{#​ask:​ [[category:​cities]] [[capital_of::​countries:​poland]]}}</​code>​
  
docs/plwiki1api.txt ยท Last modified: 2017/09/19 16:31 (external edit)