| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
App::LinkSite::Site |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
(You probably want to just look at the L application.) |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
A class to model a link site (part of App::LinkSite). |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
|
14
|
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
98671
|
use Feature::Compat::Class; |
|
|
2
|
|
|
|
|
462
|
|
|
|
2
|
|
|
|
|
11
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
class App::LinkSite::Site { |
|
18
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; |
|
19
|
2
|
|
|
2
|
|
355
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
53
|
|
|
20
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
89
|
|
|
21
|
2
|
|
|
2
|
|
9
|
no if $] >= 5.038, 'warnings', 'experimental::class'; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
174
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
602
|
use JSON; |
|
|
2
|
|
|
|
|
12741
|
|
|
|
2
|
|
|
|
|
11
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
field $name :reader :param; |
|
26
|
|
|
|
|
|
|
field $handle :reader :param; |
|
27
|
|
|
|
|
|
|
field $image :reader :param; |
|
28
|
|
|
|
|
|
|
field $desc :reader :param; |
|
29
|
|
|
|
|
|
|
field $og_image :reader :param; |
|
30
|
|
|
|
|
|
|
field $site_url :reader :param; |
|
31
|
|
|
|
|
|
|
field $text_color :reader :param = undef; |
|
32
|
|
|
|
|
|
|
field $background_color :reader :param = undef; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
field $socials :reader :param = []; |
|
35
|
|
|
|
|
|
|
field $links :reader :param = []; |
|
36
|
|
|
|
|
|
|
field $sections :reader :param = []; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 has_sections |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Returns true if the site has any non-empty sections. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
method has_sections { |
|
47
|
|
|
|
|
|
|
return scalar(grep { $_->has_links } $self->sections->@*) > 0; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 all_links |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Returns all links from both the links array and all sections. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
method all_links { |
|
57
|
|
|
|
|
|
|
my @all_links = $self->links->@*; |
|
58
|
|
|
|
|
|
|
for my $section ($self->sections->@*) { |
|
59
|
|
|
|
|
|
|
push @all_links, $section->links->@*; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
return @all_links; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 json_ld |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns a JSON/LD fragment for this web site. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
method json_ld { |
|
71
|
|
|
|
|
|
|
my $json = { |
|
72
|
|
|
|
|
|
|
'@context' => 'https://schema.org', |
|
73
|
|
|
|
|
|
|
'@type' => 'WebPage', |
|
74
|
|
|
|
|
|
|
name => "Links page for $name ($handle)", |
|
75
|
|
|
|
|
|
|
mainEntity => { |
|
76
|
|
|
|
|
|
|
'@context' => 'https://schema.org', |
|
77
|
|
|
|
|
|
|
'@type' => 'Person', |
|
78
|
|
|
|
|
|
|
name => $self->name, |
|
79
|
|
|
|
|
|
|
image => $self->image, |
|
80
|
|
|
|
|
|
|
sameAs => [ map { $_->mk_social_link } $self->socials->@* ], |
|
81
|
|
|
|
|
|
|
}, |
|
82
|
|
|
|
|
|
|
relatedLink => [ map { $_->link } $self->all_links ], |
|
83
|
|
|
|
|
|
|
}; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return JSON->new->pretty->encode($json); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Dave Cross |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright (c) 2024, Magnum Solutions Ltd. All Rights Reserved. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
|
100
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |