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 return sprintf('<%s class="%s">%s</%s>',
52 $self->wrapper_css_class,
58 croak "Cannot find help text '$help_key' in $file";
61 __PACKAGE__->meta->make_immutable;
66 CatalystX::HelpText::Model - Model to provide snippets of help text
70 package MyApp::Model::Help;
72 use namespace::autoclean;
74 extends 'CatalystX::HelpText::Model';
80 A very simple file system based help text finder.
82 Expects each piece of help text to be in an individual file, and provides a
83 C<get_help_text_for> method as used by L<CatalaystX::HelpText::ViewRole> which
84 just slurps in this file verbatim.
86 Users are expected (and encouraged) to replace the simple logic in this
87 model with a more complicated method of help text resolution if needed.
91 =head1 get_help_text_for ($help_key)
93 Returns a snippet of help text.
95 Will throw an exception if the requested help key is not found.
97 =head1 CONFIGURATION ATTRIBUTES
99 XXX - FIXME - document these
101 =head2 help_files_path
103 =head2 help_files_ext
105 =head2 wrapper_css_class
111 =head2 File system only.
113 Currently we only support getting help texts from the file system (as individual files).
115 A model to get help from a database table, or YAML file or similar could (and should)
116 be provided as part of this distribution. Patches are welcome!
122 =item L<CatalystX::HelpText>
128 Toomas Doran, C<< t0m at state51.co.uk >>
130 Cinxgler Mariaca Minda, C<< cinxgler at ci-info.com >>
134 Copyright Oscar Music and Media 2011.
138 This sofware is free software, and is licensed under the same terms as perl itself.