1 package CatalystX::HelpText::Model;
3 use MooseX::Types::Moose qw/Str Undef/;
4 use MooseX::Types::Path::Class qw/ Dir /;
6 use Carp qw/ croak confess/;
7 use namespace::autoclean;
9 extends 'Catalyst::Model';
11 has help_files_path => (
21 has help_files_ext => (
27 has wrapper_css_class => (
30 default => 'help_text',
40 sub get_help_text_for {
41 my ($self, $help_key) = @_;
42 confess('No $help_key provided') unless $help_key;
45 $fn .= "." . $self->help_files_ext if defined($self->help_files_ext);
47 my $file = $self->_get_file($fn);
50 my $content = $file->slurp;
51 return sprintf('<%s class="%s">%s</%s>',
53 $self->wrapper_css_class,
59 croak "Cannot find help text '$help_key' in $file";
62 __PACKAGE__->meta->make_immutable;
67 CatalystX::HelpText::Model - Model to provide snippets of help text
71 package MyApp::Model::Help;
73 use namespace::autoclean;
75 extends 'CatalystX::HelpText::Model';
81 A very simple file system based help text finder.
83 Expects each piece of help text to be in an individual file, and provides a
84 C<get_help_text_for> method as used by L<CatalaystX::HelpText::ViewRole> which
85 just slurps in this file verbatim.
87 Users are expected (and encouraged) to replace the simple logic in this
88 model with a more complicated method of help text resolution if needed.
92 =head1 get_help_text_for ($help_key)
94 Returns a snippet of help text.
96 Will throw an exception if the requested help key is not found.
98 =head1 CONFIGURATION ATTRIBUTES
100 XXX - FIXME - document these
102 =head2 help_files_path
104 =head2 help_files_ext
106 =head2 wrapper_css_class
112 =head2 File system only.
114 Currently we only support getting help texts from the file system (as individual files).
116 A model to get help from a database table, or YAML file or similar could (and should)
117 be provided as part of this distribution. Patches are welcome!
123 =item L<CatalystX::HelpText>
129 Toomas Doran, C<< t0m at state51.co.uk >>
131 Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>
135 Copyright Oscar Music and Media 2011.
139 This sofware is free software, and is licensed under the same terms as perl itself.