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 |
cf::register_async_exticmd doclet => sub { |
14 |
my ($ns, $reply, $category, $entry) = @_; |
15 |
|
16 |
cf::async { |
17 |
my $cfpod; |
18 |
|
19 |
if (my $pl = $ns->pl) { |
20 |
|
21 |
if (my $cb = $DOCLET{$category}) { |
22 |
$cfpod = $cb->($pl, $category, $entry); |
23 |
} else { |
24 |
$cfpod = "No documentation found for $category/$entry."; |
25 |
} |
26 |
|
27 |
$cfpod = $pl->expand_cfpod ($cfpod); |
28 |
} else { |
29 |
$cfpod = "(Documentation not available before login.)"; |
30 |
} |
31 |
|
32 |
$reply->($cfpod); |
33 |
}; |
34 |
}; |
35 |
|