Commit 9ed7cf94 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Revisited the helpers and documentation

parent 3fd1d168
......@@ -14,12 +14,49 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
=encoding utf8
=head1 NAME
Mojolicious::Plugin::AWIT::FontAwesome - FontAwesome fonts and helpers
=head1 SYNOPSIS
# Mojolicious
$self->plugin('Mojolicious::Plugin::AWIT::FontAwesome');
# Mojolicious::Lite
plugin 'Mojolicious::Plugin::AWIT::FontAwesome';
=head1 DESCRIPTION
L<Mojolicious::Plugin::AWIT::FontAwesome> is a L<Mojolicious> plugin.
=cut
package Mojolicious::Plugin::AWIT::FontAwesome;
use Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '5.6.3';
=head1 METHODS
L<Mojolicious::Plugin::AWIT::FontAwesome> inherits all methods from
L<Mojolicious::Plugin> and implements the following new ones.
=cut
=head2 register
$plugin->register(Mojolicious->new);
Register plugin in L<Mojolicious> application.
=cut
sub register
{
......@@ -28,17 +65,88 @@ sub register
push(@{$app->static->paths},"$FindBin::Bin/../../awit-mojolicious-fontawesome/public");
# Load helpers
$app->helper(stylesheet_fontawesome => sub {
my $self = shift;
# Fake the call
Mojolicious::Plugin::TagHelpers::_stylesheet($self,"/static/fontawesome/css/all.min.css");
});
$app->helper('stylesheet_fontawesome' => \&_stylesheet_fontawesome);
$app->helper('icon_fontawesome' => \&_icon);
return 1;
}
=head1 HELPERS
The below helpers are implemented.
=cut
=head2 stylesheet_fontawesome
stylesheet_fontawesome
Return the stylesheet for FontAwesome.
=cut
sub _stylesheet_fontawesome {
my $self = shift;
return Mojolicious::Plugin::TagHelpers::_stylesheet($self,"/static/fontawesome/css/all.min.css");
}
=head2 icon_fontawesome
icon_fontawesome($icon,...)
Return a list of available helpers.
=cut
# Create a nice icon
sub _icon {
my ($self, $icon, @params) = @_;
my $cb = ref $params[-1] eq 'CODE' ? pop(@params) : undef;
my %attrs = @params;
# Add form-group class
if (defined($attrs{'class'})) {
$attrs{'class'} .= " fas fa-fw $icon";
} else {
$attrs{'class'} = "fas fa-fw $icon";
}
return Mojolicious::Plugin::TagHelpers::_tag('i', %attrs, $cb);
}
1;
__END__
=head1 AUTHORS
Nigel Kukard E<lt>nkukard@lbsd.netE<gt>
=head1 BUGS
All bugs should be reported via the project issue tracker
L<http://gitlab.devlabs.linuxassist.net/awit-mojolicious-helpers/awit-mojolicious-fontawesome/issues/>.
=head1 LICENSE AND COPYRIGHT
Copyright (C) 2014-2019, AllWorldIT
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
=head1 SEE ALSO
L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicio.us>.
=cut
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment