#! perl # mandatory # implements the doclet exti request, to serve cfhtml strings our %DOCLET; # $DOCLET{category} = $cb sub register($$) { my ($category, $cb) = @_; $DOCLET{$category} = $cb; Guard::guard { delete $DOCLET{$category} } } sub doclet($$$) { my ($pl, $category, $item) = @_; if (my $cb = $DOCLET{$category}) { $cb->($pl, $category, $item) } else { "No documentation found for $category/$item." } } our $SKILL_HANDLER = ext::doclet::register skill => sub { my ($pl, $category, $name) = @_; my $skill = $pl->find_skill ($name); "B<$name>\n\n" . ($skill ? $skill->msg : "You don't know anything about this skill.") }; our $SPELL_HANDLER = ext::doclet::register spell => sub { my ($pl, $category, $name) = @_; my $skill = $pl->ob->find_spell ($name); "B<$name>\n\n" . ($skill ? $skill->msg : "You don't know anything about this spell.") }; cf::register_async_exticmd doclet => sub { my ($ns, $reply, $category, $item) = @_; $ns->async (sub { my $cfpod; if (my $pl = $ns->pl) { $cfpod = $pl->expand_cfpod (doclet $pl, $category, $item); } else { $cfpod = "(documentation not available before login)"; } $reply->($cfpod); }); };