Badge::Depot - A framework for badges
Version 0.0104, released 2016-02-19.
# Define a badge class
package Badge::Depot::Plugin::Example;
use Moose;
with 'Badge::Depot';
has user => (
is => 'ro',
isa => 'Str',
required => 1,
);
sub BUILD {
my $self = shift;
$self->link_url(sprintf 'https://example.com/users/%s', $self->user);
$self->image_url(sprintf 'https://example.com/users/%s.svg', $self->user);
$self->image_alt('Example text');
}
# Somewhere else
my $badge = Badge::Depot::Plugin::Example->new(user => 'my_username');
print $badge->to_html;
# prints '<a href="https://example.com/users/my_username"><img src="https://example.com/users/my_username.svg" alt="Example text" /></a>'
Badge::Depot
is a framework for documentation badges. Using badges in your documentation can give
end users of your distribution dynamic information without you having to update the documentation.
You only need use this distribution directly if you want to create a new badge in the Badge::Depot::Plugin
namespace. See Task::Badge::Depot for
a list of existing badges.
For use together with Pod::Weaver, see Pod::Weaver::Section::Badges.
Badge::Depot
is a Moose role that adds a few attributes and methods.
These attributes are expected to be set when the badge class returns from new
. See synopsis.
Required. Uri.
The url to the actual badge. The src attribute for the img tag when rendered to html.
Optional. Str.
The alternative text of the badge. The alt attribute for the img tag when rendered to html. No alternative text is created if this isn't set.
Optional (but recommended). Uri.
The url to link the badge to. The href attribute for the a tag when rendered to html. No link is created if this isn't set.
This is not a user setable attribute, but rather can be used by plugins that might need to look at distribution meta data. This is only usable when using Pod::Weaver::Section::Badges together with Dist::Zilla.
These methods are used when rendering the badge, and are not useful inside badge classes.
Returns a string with the badge rendered as html.
Returns a string with the badge rendered as markdown.
- Task::Badge::Depot - List of available badges
- Pod::Weaver::Section::Badges - Weave the badges
- WWW::StatusBadge - An alternative badge framework
https://github.com/Csson/p5-Badge-Depot
https://metacpan.org/release/Badge-Depot
Erik Carlsson info@code301.com
This software is copyright (c) 2016 by Erik Carlsson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.