-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV-1052 Add marc 008 field values to CRMS (#134)
- Display 008 breakdown and position numbers in Track Volumes and Bib Rights - Replace `margin-top` and `margin-bottom` with `margin-block-start` and `margin-block-end` in main CSS file. - Expunge deprecated `docker-compose` in favor of `docker compose`. - Move `ci.yml` to `tests.yml`
- Loading branch information
Showing
12 changed files
with
188 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package CRMS::Field008Formatter; | ||
|
||
# Displays a 008 field with subparts separated out and bit positions numbered. | ||
|
||
use strict; | ||
use warnings; | ||
use utf8; | ||
|
||
sub new { | ||
my ($class, %args) = @_; | ||
my $self = bless {}, $class; | ||
return $self; | ||
} | ||
|
||
# Pad a truncated or undefined 008 to the full 40 characters. | ||
sub pad { | ||
my $self = shift; | ||
my $f008 = shift || ''; | ||
|
||
if (length $f008 < 40) { | ||
$f008 .= (' ' x (40 - length $f008)); | ||
} | ||
return $f008; | ||
} | ||
|
||
sub format { | ||
my $self = shift; | ||
my $f008 = shift; | ||
|
||
# Pad to length if truncated | ||
$f008 = $self->pad($f008); | ||
# Replace spaces with U+2294 square cup for display | ||
$f008 =~ s/\s/⊔/g; | ||
my $f008_1 = substr $f008, 0, 6; | ||
my $f008_2 = substr $f008, 6, 9; | ||
my $f008_3 = substr $f008, 15, 3; | ||
my $f008_4 = substr $f008, 18, 17; | ||
my $f008_5 = substr $f008, 35, 3; | ||
my $f008_6 = substr $f008, 38, 1; | ||
my $f008_7 = substr $f008, 39, 1; | ||
|
||
my $format = <<END; | ||
<span class="f008">$f008_1 | ||
<span class="f008-annotation">00 01 02 03 04 05</span> | ||
</span> | ||
<span class="f008">$f008_2 | ||
<span class="f008-annotation">06 07 08 09 10 11 12 13 14</span> | ||
</span> | ||
<span class="f008">$f008_3 | ||
<span class="f008-annotation">15 16 17</span> | ||
</span> | ||
<span class="f008">$f008_4 | ||
<span class="f008-annotation">18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34</span> | ||
</span> | ||
<span class="f008">$f008_5 | ||
<span class="f008-annotation">35 36 37</span> | ||
</span> | ||
<span class="f008">$f008_6 | ||
<span class="f008-annotation">38</span> | ||
</span> | ||
<span class="f008">$f008_7 | ||
<span class="f008-annotation">39</span> | ||
</span> | ||
END | ||
return $format; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,5 +52,3 @@ subtest '::set_visibility_cmd' => sub { | |
}; | ||
|
||
done_testing(); | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
|
||
use lib $ENV{'SDRROOT'} . '/crms/lib'; | ||
use CRMS::Field008Formatter; | ||
|
||
my $FAKE_008 = '850423s1940 uk a 000 0 eng d'; | ||
|
||
subtest '::new' => sub { | ||
my $formatter = CRMS::Field008Formatter->new; | ||
isa_ok($formatter, 'CRMS::Field008Formatter'); | ||
}; | ||
|
||
subtest '#pad' => sub { | ||
# Make sure we always get back 40 characters. | ||
subtest 'with a normal 008' => sub { | ||
my $formatter = CRMS::Field008Formatter->new; | ||
is(length($formatter->pad($FAKE_008)), 40); | ||
}; | ||
|
||
subtest 'with a truncated 008' => sub { | ||
my $formatter = CRMS::Field008Formatter->new; | ||
is(length($formatter->pad('850423')), 40); | ||
}; | ||
|
||
subtest 'with an undefined 008' => sub { | ||
my $formatter = CRMS::Field008Formatter->new; | ||
is(length($formatter->pad()), 40); | ||
}; | ||
}; | ||
|
||
subtest '#format' => sub { | ||
# Make sure we get back a string. | ||
subtest 'with a well-formed 008' => sub { | ||
my $formatter = CRMS::Field008Formatter->new; | ||
is(ref $formatter->format($FAKE_008), ''); | ||
}; | ||
|
||
subtest 'with a truncated 008' => sub { | ||
my $formatter = CRMS::Field008Formatter->new; | ||
is(ref $formatter->format(''), ''); | ||
}; | ||
}; | ||
|
||
done_testing(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,4 +244,3 @@ subtest 'RightsPredictor::rights' => sub { | |
|
||
done_testing(); | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters