1 |
root |
1.1 |
#! perl # mandatory |
2 |
|
|
|
3 |
|
|
# implements the doclet exti request, to serve cfhtml strings |
4 |
|
|
|
5 |
|
|
our %DOCLET; # $DOCLET{category} = $cb |
6 |
|
|
|
7 |
|
|
sub register($$) { |
8 |
|
|
my ($category, $cb) = @_; |
9 |
|
|
$DOCLET{$category} = $cb; |
10 |
|
|
Guard::guard { delete $DOCLET{$category} } |
11 |
|
|
} |
12 |
|
|
|
13 |
root |
1.3 |
sub doclet($$$) { |
14 |
|
|
my ($pl, $category, $item) = @_; |
15 |
|
|
|
16 |
|
|
if (my $cb = $DOCLET{$category}) { |
17 |
|
|
$cb->($pl, $category, $item) |
18 |
|
|
} else { |
19 |
|
|
"No documentation found for $category/$item." |
20 |
|
|
} |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
our $SKILL_HANDLER = ext::doclet::register skill => sub { |
24 |
|
|
my ($pl, $category, $name) = @_; |
25 |
|
|
|
26 |
|
|
my $skill = $pl->find_skill ($name); |
27 |
|
|
|
28 |
|
|
"B<$name>\n\n" |
29 |
|
|
. ($skill ? $skill->msg : "You don't know anything about this skill.") |
30 |
|
|
}; |
31 |
|
|
|
32 |
root |
1.1 |
cf::register_async_exticmd doclet => sub { |
33 |
root |
1.3 |
my ($ns, $reply, $category, $item) = @_; |
34 |
root |
1.1 |
|
35 |
root |
1.3 |
$ns->async (sub { |
36 |
root |
1.1 |
my $cfpod; |
37 |
|
|
|
38 |
|
|
if (my $pl = $ns->pl) { |
39 |
root |
1.3 |
$cfpod = $pl->expand_cfpod (doclet $pl, $category, $item); |
40 |
root |
1.1 |
} else { |
41 |
root |
1.2 |
$cfpod = "(documentation not available before login)"; |
42 |
root |
1.1 |
} |
43 |
|
|
|
44 |
|
|
$reply->($cfpod); |
45 |
root |
1.3 |
}); |
46 |
root |
1.1 |
}; |
47 |
|
|
|