User Tools

Site Tools


docs:plwiki1api

PlWiki 1.0 - Plugin API

Examples available here

IMPORTANT:

This code should be placed on every page using PlWiki plugin:

 ~~NOCACHE~~ 

Prolog Code in Loki

The simplest use case. Without cache. Only process knowledge between “pl” tags.

<pl goal="woman(X),write(X),nl,fail">
woman(kate).
man(john).
</pl>

Result:
kate

More interesting use case: adding knowledge to the page:

<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.

<pl goal="man(X),write(X),nl,fail"  scope="docs:plwiki1ex" >
%
% Prolog code may be placed here but it is not necessairly.
%
</pl>

Result:
jack
jim

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:

<pl goal="consult('lib/plugins/loki/loki.pl'),wikiconsult('docs/plwiki1api'),list."></pl>

Result:

'$member'
'$no-null-bytes'
'$pack':pack_dir
'$toplevel':catch
->atomic_list_concat
;atomic_list_concat
absolute_file_name
atom_concat
expand_answer
expand_file_name
expand_query
file_search_path
library_directory
link_xpce:pcehome_
man
prolog_file_type
system:current_prolog_flag
toplevel_variables:expand_answer
toplevel_variables:expand_query
wiki_header
wiki_internallink
woman

We can also list informations about selected predicate.

<pl goal="consult('lib/plugins/loki/loki.pl'),wikiconsult('docs/plwiki1api'),list(man)."></pl>

Result:
man(john).
man(jack).
man(jim).

Categories, Relations, Attributes

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
    [[category:category1]]
  • 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
    [[capital of::countries:poland]]
  • 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
    [[created:=April 22 2009]]
  • 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:
    {{#ask: [[category:cities]] [[capital_of::countries:poland]]}}


docs/plwiki1api.txt · Last modified: 2017/09/19 16:31 (external edit)