| 1 | =head1 NAME | ||||||||||
| 2 | |||||||||||
| 3 | App::LinkSite::Link | ||||||||||
| 4 | |||||||||||
| 5 | =head1 SYNOPSIS | ||||||||||
| 6 | |||||||||||
| 7 | (You probably want to just look at the L<linksite> application.) | ||||||||||
| 8 | |||||||||||
| 9 | =head1 DESCRIPTION | ||||||||||
| 10 | |||||||||||
| 11 | A class to model a link on a link site (part of App::LinkSite). | ||||||||||
| 12 | |||||||||||
| 13 | =cut | ||||||||||
| 14 | |||||||||||
| 15 | 3 | ▶ | use Feature::Compat::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 3 | class App::LinkSite::Link { | |||||||||
| 18 | 3 | our $VERSION = '0.1.3'; | |||||||||
| 19 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | ▶ | no if $] >= 5.038, 'warnings', 'experimental::class'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 3 | field $title :reader :param; | |||||||||
| 24 | 3 | field $subtitle :reader :param = ''; | |||||||||
| 25 | 3 | field $link :reader :param; | |||||||||
| 26 | 3 | field $new_link :reader(is_new) :param(new) = 0; | |||||||||
| 27 | |||||||||||
| 28 | =head1 METHODS | ||||||||||
| 29 | |||||||||||
| 30 | =head2 mk_link | ||||||||||
| 31 | |||||||||||
| 32 | Returns a fragment of HTML that is used to display this link on the site. | ||||||||||
| 33 | |||||||||||
| 34 | It's actually an `<li>` that wraps an `<a>`. So this method probably needs | ||||||||||
| 35 | to be renamed or refactored. Maybe it should just be called `render()`. | ||||||||||
| 36 | |||||||||||
| 37 | =cut | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | method mk_link { | ||||||||
|
Subroutine
mk_link: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 40 | 0 | my $a_tag = q[<a href="] . $self->link . q[" class="text-decoration-none">] . $self->title . q[</a>]; | |||||||||
| 41 | 0 | ▶ | my $subtitle = $self->subtitle ? q[<br><small class="text-muted">] . $self->subtitle . q[</small>] : ''; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | |||||||||||
| 43 | 0 | my @li_classes = qw[list-group-item list-group-item-action]; | |||||||||
| 44 | 0 | ▶ | push @li_classes, 'new-link' if $self->is_new; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | |||||||||||
| 46 | 0 | return qq[<li class='@li_classes'>$a_tag$subtitle</li>]; | |||||||||
| 47 | } | ||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | =head1 AUTHOR | ||||||||||
| 51 | |||||||||||
| 52 | Dave Cross <dave@davecross.co.uk> | ||||||||||
| 53 | |||||||||||
| 54 | =head1 COPYRIGHT AND LICENCE | ||||||||||
| 55 | |||||||||||
| 56 | Copyright (c) 2024, Magnum Solutions Ltd. All Rights Reserved. | ||||||||||
| 57 | |||||||||||
| 58 | This library is free software; you can redistribute it and/or modify it | ||||||||||
| 59 | under the same terms as Perl itself. | ||||||||||
| 60 | |||||||||||
| 61 | =cut | ||||||||||
| 62 | |||||||||||
| 63 | 3 | 1; | |||||||||