1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
%%%%%%%%%%%%%%%%%%%%%%%%%%
% via dokuwiki
%%%%%%%%%%%%%%%%%%%%%%%%%%
wikiconsult(Scope) :-
shell('rm -f lib/plugins/loki/tmp/tempfile.pl'),
string_concat('lib/plugins/loki/tmp/loki/',Scope, Res),
string_concat('grep ".*" -rh $(grep ".*" -rl lib/plugins/loki/tmp/loki | grep ', Res,Res2),
string_concat(Res2, ') > lib/plugins/loki/tmp/tempfile.pl',Res3),
shell(Res3),true,
consult('lib/plugins/loki/tmp/tempfile.pl').
list :-
shell('swipl -q -f lib/plugins/loki/tmp/tempfile.pl -t \'listing.\' | grep "[^ ]*(.*)" | cut -f1 -d "(" | tr -d "[:blank:]" | sort -u ').
list(Pred) :-
string_concat('swipl -q -f lib/plugins/loki/tmp/tempfile.pl -t \'listing(', Pred , Res),
string_concat(Res, ')\' ' , Res2),
shell(Res2).
%%%%%%%%%%%%%%%%%%%%%%%%%%
% via shell
%%%%%%%%%%%%%%%%%%%%%%%%%%
shell_wikiconsult(Path,Scope) :-
write('PlWiki system.'),nl,
shell('rm -f tmp/tempfile.pl'),
write('Scope set to: '), write(Scope),nl,
string_concat('lib/plugins/loki/tmp/loki/',Scope, Res),
string_concat('grep ".*" -rh $(grep ".*" -rl ',Path,Res2),
string_concat(Res2,'/lib/plugins/loki/tmp/loki | grep ', Res3),
string_concat(Res3, Res, Res4),
string_concat(Res4, ') > ', Res5),
string_concat(Res5, Path, Res6),
string_concat(Res6, '/lib/plugins/loki/tmp/tempfile.pl', Res7),
write('Consulting... '), write(Res),nl,
shell(Res7),
string_concat(Path, '/lib/plugins/loki/tmp/tempfile.pl', Res8),
consult(Res8),
write('Consulted.'),nl.
shell_wikiconsult :-
write('Specify Loki absolute path [Ex. \' /var/www/wiki \']'),nl,
read(Path),
write('Specify Loki scope [Ex. \' loki/dev \']'),nl,
read(Scope),
shell_wikiconsult(Path, Scope).
shell_list :-
shell('swipl -q -f tmp/tempfile.pl -t \'listing.\' | grep "[^ ]*(.*)" | cut -f1 -d "(" | tr -d "[:blank:]" | sort -u ').
shell_list(Pred) :-
string_concat('swipl -q -f tmp/tempfile.pl -t \'listing(', Pred , Res),
string_concat(Res, ')\' ' , Res2),
shell(Res2).