| 1 | package Muster::LeafFile::EXIF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | $Muster::LeafFile::EXIF::VERSION = '0.96'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | #ABSTRACT: Muster::LeafFile::EXIF - an EXIF-containing file in a Muster content tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | Muster::LeafFile::EXIF - an EXIF-containing file in a Muster content tree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | version 0.96 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | File nodes represent files in a Muster::Content content tree. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | This is an EXIF-containing file. It is meant to be subclassed with specific files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use Mojo::Base 'Muster::LeafFile'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | ▶ | use Image::ExifTool qw(:Public); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | ▶ | use Text::Markdown::Discount 'markdown'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | use YAML::Any; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use List::MoreUtils qw(uniq); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub is_this_a_binary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_this_a_binary: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub build_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_meta: not called CC=53 SCAR=79.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $meta = $self->SUPER::build_meta(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # Fields found in the EXIF will replace the defaults (e.g. title) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $exif_options = {DateFormat => "%Y-%m-%d %H:%M:%S"}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $info = ImageInfo($self->filename,$exif_options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Check if this is a Gutenberg book; they have quirks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $is_gutenberg_book = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if (exists $info->{Identifier} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $info->{"Identifier"} and $info->{"Identifier"} =~ m[http://www.gutenberg.org/ebooks/\d+]u
MC/DC0%0/2
exists $info->{"Identifier"} and $info->{"Identifier"} =~ m[http://www.gutenberg.org/ebooks/\d+]u
exists $info->{"Identifier"}
$info->{"Identifier"} =~ m[http://www.gutenberg.org/ebooks/\d+]u
Truth table0%0/3
A and B
A= exists $info->{"Identifier"}B= $info->{"Identifier"} =~ m[http://www.gutenberg.org/ebooks/\d+]u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | and $info->{'Identifier'} =~ m!http://www.gutenberg.org/ebooks/\d+!) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $is_gutenberg_book = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # If this is a Gutenberg book, the Identifier holds the correct URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $meta->{'url'} = $info->{'Identifier'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # There are multiple fields which could be used as a file "description". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # Check through them until you find a non-empty one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $description = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach my $field (qw(Caption-Abstract Comment ImageDescription UserComment Description)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (exists $info->{$field} and $info->{$field} and !$description) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{$field} and $info->{$field} and not $description
exists $info->{$field} and $info->{$field}
MC/DC0%0/3
exists $info->{$field} and $info->{$field} and not $description
exists $info->{$field}
$info->{$field}
not $description
Truth table0%0/4
A and B and not(C)
A= exists $info->{$field}B= $info->{$field}C= not $description
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $description = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $description =~ s/\n$//; # remove trailing newlines | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $meta->{description} = $description if $description; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # There are multiple fields which could be used as a file content creator. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # Check through them until you find a non-empty one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $creator = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | foreach my $field (qw(Author Artist Creator MetadataCreator)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (exists $info->{$field} and $info->{$field} and !$creator) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{$field} and $info->{$field} and not $creator
exists $info->{$field} and $info->{$field}
MC/DC0%0/3
exists $info->{$field} and $info->{$field} and not $creator
exists $info->{$field}
$info->{$field}
not $creator
Truth table0%0/4
A and B and not(C)
A= exists $info->{$field}B= $info->{$field}C= not $creator
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $creator = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $meta->{creator} = $creator if $creator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # There are multiple fields which could be used as a copyright notice. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # Check through them until you find a non-empty one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $copyright = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | foreach my $field (qw(License Rights)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if (exists $info->{$field} and $info->{$field} and !$copyright) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{$field} and $info->{$field} and not $copyright
exists $info->{$field} and $info->{$field}
MC/DC0%0/3
exists $info->{$field} and $info->{$field} and not $copyright
exists $info->{$field}
$info->{$field}
not $copyright
Truth table0%0/4
A and B and not(C)
A= exists $info->{$field}B= $info->{$field}C= not $copyright
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $copyright = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $meta->{copyright} = $copyright if $copyright; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # Alt text! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $alt_text = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | foreach my $field (qw(AltTextAccessibility)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if (exists $info->{$field} and $info->{$field} and !$alt_text) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{$field} and $info->{$field} and not $alt_text
exists $info->{$field} and $info->{$field}
MC/DC0%0/3
exists $info->{$field} and $info->{$field} and not $alt_text
exists $info->{$field}
$info->{$field}
not $alt_text
Truth table0%0/4
A and B and not(C)
A= exists $info->{$field}B= $info->{$field}C= not $alt_text
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $alt_text = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $meta->{alt_text} = $alt_text if $alt_text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # The URL could be from the Source or the Identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # Check through them until you find a non-empty one which contains an actual URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | foreach my $field (qw(Source Identifier MetadataIdentifier)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if (exists $info->{$field} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
exists $info->{$field} and $info->{$field} and $info->{$field} =~ /^http/u and not exists $meta->{"url"}
exists $info->{$field} and $info->{$field} and $info->{$field} =~ /^http/u
exists $info->{$field} and $info->{$field}
MC/DC0%0/4
exists $info->{$field} and $info->{$field} and $info->{$field} =~ /^http/u and not exists $meta->{"url"}
exists $info->{$field}
$info->{$field}
$info->{$field} =~ /^http/u
not exists $meta->{"url"}
Truth table0%0/5
A and B and C and not(D)
A= exists $info->{$field}B= $info->{$field}C= $info->{$field} =~ /^http/uD= not exists $meta->{"url"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | and $info->{$field} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | and $info->{$field} =~ /^http/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | and !exists $meta->{url}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $meta->{url} = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # CreateDate is going to be treated as a separate field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $create_date = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | foreach my $field (qw(CreateDate)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (exists $info->{$field} and $info->{$field} and !$create_date) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{$field} and $info->{$field} and not $create_date
exists $info->{$field} and $info->{$field}
MC/DC0%0/3
exists $info->{$field} and $info->{$field} and not $create_date
exists $info->{$field}
$info->{$field}
not $create_date
Truth table0%0/4
A and B and not(C)
A= exists $info->{$field}B= $info->{$field}C= not $create_date
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $create_date = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $meta->{create_date} = $create_date if $create_date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # There are multiple fields which could be used as a file date. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # Check through them until you find a non-empty one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $date = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | foreach my $field (qw(DateTimeOriginal Date PublishedDate PublicationDate)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if (exists $info->{$field} and $info->{$field} and !$date) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{$field} and $info->{$field} and not $date
exists $info->{$field} and $info->{$field}
MC/DC0%0/3
exists $info->{$field} and $info->{$field} and not $date
exists $info->{$field}
$info->{$field}
not $date
Truth table0%0/4
A and B and not(C)
A= exists $info->{$field}B= $info->{$field}C= not $date
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $date = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $meta->{date} = $date if $date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # Use a consistent naming for tag fields. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Combine the tag-like fields together. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # Preserve the order and check for dupicates later with uniq | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my @tags = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | foreach my $field (qw(Keywords Subject)) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (exists $info->{$field} and $info->{$field}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $info->{$field} and $info->{$field}
MC/DC0%0/2
exists $info->{$field} and $info->{$field}
exists $info->{$field}
$info->{$field}
Truth table0%0/3
A and B
A= exists $info->{$field}B= $info->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $val = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my @these_tags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | if ($is_gutenberg_book) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # gutenberg tags are multi-word, separated by comma-space or ' -- ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # and can have parens in them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $val =~ s/\(//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $val =~ s/\)//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $val =~ s/\s--\s/,/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | @these_tags = split(/,\s?/, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | @these_tags = split(/,\s*/, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | foreach my $t (@these_tags) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $t =~ s/ - / /g; # remove isolated dashes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $t =~ s/[^\w\s,-]//g; # remove non-word characters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | push @tags, $t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # Are there any tags? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (@tags) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # remove duplicates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $meta->{tags} = [uniq @tags]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | else # remove empty tag-field | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | delete $meta->{tags}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # There are SOOOOOO many fields in EXIF data, just remember a subset of them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | foreach my $field (qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | Flash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | FileSize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ImageHeight | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ImageSize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ImageWidth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | Megapixels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | Location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | Title | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | )) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if (exists $info->{$field} and $info->{$field}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $info->{$field} and $info->{$field}
MC/DC0%0/2
exists $info->{$field} and $info->{$field}
exists $info->{$field}
$info->{$field}
Truth table0%0/3
A and B
A= exists $info->{$field}B= $info->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $meta->{lc($field)} = $info->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # ------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Freeform Fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # These are stored as YAML data in the Instructions field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # ------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if (exists $info->{Instructions} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $info->{"Instructions"} and $info->{"Instructions"} and $info->{"Instructions"} =~ /^---/u
exists $info->{"Instructions"} and $info->{"Instructions"}
MC/DC0%0/3
exists $info->{"Instructions"} and $info->{"Instructions"} and $info->{"Instructions"} =~ /^---/u
exists $info->{"Instructions"}
$info->{"Instructions"}
$info->{"Instructions"} =~ /^---/u
Truth table0%0/4
A and B and C
A= exists $info->{"Instructions"}B= $info->{"Instructions"}C= $info->{"Instructions"} =~ /^---/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | and $info->{Instructions} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | and $info->{Instructions} =~ /^---/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | eval {$data = Load($info->{Instructions});}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | warn __PACKAGE__, " Load of YAML data failed: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | elsif (!$data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | warn __PACKAGE__, " no legal YAML"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | else # okay | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | foreach my $field (sort keys %{$data}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $meta->{$field} = $data->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return $meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | =head2 build_raw | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | The raw content of the page. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | For binary files, the "page" content is empty; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | if you want to show the actual binary file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | do a source-file request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub build_raw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_raw: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | return ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | =head2 build_html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | Create the HTML for this binary-file page. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub build_html { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_html: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $content = $self->cooked(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # if the output is going to be text, don't process it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if (defined $self->meta->{render_format} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $self->meta->{"render_format"} and $self->meta->{"render_format"} eq "txt"
MC/DC0%0/2
defined $self->meta->{"render_format"} and $self->meta->{"render_format"} eq "txt"
defined $self->meta->{"render_format"}
$self->meta->{"render_format"} eq "txt"
Truth table0%0/3
A and B
A= defined $self->meta->{"render_format"}B= $self->meta->{"render_format"} eq "txt"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | and $self->meta->{render_format} eq 'txt') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | ▶ | elsif (defined $content | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
defined $content and $content and defined $self->meta->{"html_from"}
defined $content and $content
MC/DC0%0/3
defined $content and $content and defined $self->meta->{"html_from"}
defined $content
$content
defined $self->meta->{"html_from"}
Truth table0%0/4
A and B and C
A= defined $contentB= $contentC= defined $self->meta->{"html_from"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | and $content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | and defined $self->meta->{html_from}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # This probably needs to be done more generically | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # by using modules' own methods, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # but this will do for now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ($self->meta->{html_from} eq 'html') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # HTML doesn't need processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | elsif ($self->meta->{html_from} eq 'txt') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | return <<EOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | <pre> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | $content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | </pre> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | elsif ($self->meta->{html_from} eq 'mdwn') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return markdown($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | else # Don't know what this is, don't process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return $content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||