Skip to content

Commit

Permalink
DEV-1052 Add marc 008 field values to CRMS (#134)
Browse files Browse the repository at this point in the history
- 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
moseshll authored Feb 19, 2024
1 parent 8ef730d commit fd7f9ca
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ A web app and suite of tools for performing copyright review projects.
```
git submodule init
git submodule update
docker-compose build
docker-compose up -d mariadb
docker-compose run --rm test
docker compose build
docker compose up -d mariadb
docker compose run --rm test
```

## Running Tests with Coverage
Expand Down
1 change: 1 addition & 0 deletions cgi/BibRights.pm
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ sub query {
my $bib_info = $br->get_bib_info($marc, $cid);
$data->{cid} = $cid;
$data->{title} = $marc->title();
$data->{record} = $metadata;
$data->{entries} = [];
foreach my $htid (@{$htids}) {
my $enumcron = $metadata->enumcron($htid) || '';
Expand Down
21 changes: 15 additions & 6 deletions cgi/CRMS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sub new
return $self;
}

our $VERSION = '8.5.23';
our $VERSION = '8.5.24';
sub Version
{
return $VERSION;
Expand Down Expand Up @@ -6305,6 +6305,7 @@ sub TrackingQuery
}
}
$data->{'data'} = \@ids;
$data->{'record'} = $record;
return $data;
}

Expand Down Expand Up @@ -8149,16 +8150,17 @@ sub Commify
return $n;
}

sub Keio
{
# The following module hooks exist so that templates
# (which typically have only a CRMS object among their locals)
# can call various modules of interest.
sub Keio {
my $self = shift;

use Keio;
Keio->new('crms' => $self);
}

sub Licensing
{
sub Licensing {
my $self = shift;

use Licensing;
Expand All @@ -8169,7 +8171,14 @@ sub BibRights {
my $self = shift;

use BibRights;
return BibRights->new;
BibRights->new;
}

sub Field008Formatter {
my $self = shift;

use CRMS::Field008Formatter;
CRMS::Field008Formatter->new;
}

1;
15 changes: 13 additions & 2 deletions cgi/bib_rights.tt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
[% END %]
<br/><br/>
<table class="exportStats">
<tr class="nowrap"><th colspan="15" class="major" scope="colgroup" id="topTH">
<tr class="nowrap">
<th colspan="15" class="major" scope="colgroup" id="topTH">
[% IF data.cid %]
<span style="color:white;">[% data.cid %]</span>
&nbsp;&nbsp;&nbsp;&nbsp;
Expand All @@ -43,7 +44,17 @@
[% ELSE %]
[% crms.EchoInput(id) %]&nbsp;&nbsp;&nbsp;&nbsp;(not in catalog)
[% END %]
</th></tr>
</th>
</tr>

[% IF data.cid %]
<tr class="nowrap">
<td colspan="15">
[% f008 = data.record.GetControlfield('008') %]
[% crms.Field008Formatter.format(f008) %]
</td>
</tr>
[% END %]

<tr class="nowrap">
<th class="nowrap" scope="col" id="volumeTH">HTID</th>
Expand Down
12 changes: 10 additions & 2 deletions cgi/track.tt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
<a href="[% url %]" target="_blank">Download</a>
[% END %]
<table class="exportStats">
<tr class="nowrap"><th colspan="12" class="major" scope="colgroup" id="topTH">
<tr class="nowrap">
<th colspan="12" class="major" scope="colgroup" id="topTH">
[% IF sysid %]
<span style="color:white;">[% sysid %]</span>
&nbsp;&nbsp;&nbsp;&nbsp;
Expand All @@ -43,8 +44,15 @@
[% ELSE %]
[% crms.EchoInput(id) %]&nbsp;&nbsp;&nbsp;&nbsp;(not in catalog)
[% END %]
</th></tr>
</th>
</tr>
[% IF sysid %]
<tr class="nowrap">
<td colspan="12">
[% f008 = data.record.GetControlfield('008') %]
[% crms.Field008Formatter.format(f008) %]
</td>
</tr>
<tr class="nowrap">
<th class="nowrap" scope="col" id="volumeTH">Volume</th>
<th class="nowrap" scope="col" id="enumchronTH">Enum/Chron</th>
Expand Down
68 changes: 68 additions & 0 deletions lib/CRMS/Field008Formatter.pm
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;
2 changes: 1 addition & 1 deletion scripts/cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# This script doesn't do the wait-for song and dance so if there are sporadic database errors,
# try making sure the databases are fully up and running again.
docker-compose run --rm test cover -ignore_re '^t/' +ignore_re '^post' -test -make 'prove -r t/; exit $?'
docker compose run --rm test cover -ignore_re '^t/' +ignore_re '^post' -test -make 'prove -r t/; exit $?'
4 changes: 4 additions & 0 deletions t/CRMS.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ subtest '#LinkToJira' => sub {
'<a href="https://hathitrust.atlassian.net/browse/DEV-000" target="_blank">DEV-000</a>');
};

subtest '#Field008Formatter' => sub {
isa_ok $crms->Field008Formatter, "CRMS::Field008Formatter";
};

done_testing();
2 changes: 0 additions & 2 deletions t/lib/CRMS/CollectionBuilder.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,3 @@ subtest '::set_visibility_cmd' => sub {
};

done_testing();

1;
49 changes: 49 additions & 0 deletions t/lib/CRMS/Field008Formatter.t
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();
1 change: 0 additions & 1 deletion t/lib/CRMS/RightsPredictor.t
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,3 @@ subtest 'RightsPredictor::rights' => sub {

done_testing();

1;
27 changes: 24 additions & 3 deletions web/css/review.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ code {
font-family:Courier, 'Courier New', Monaco, monospace;
}

.f008 {
font-family:Courier, 'Courier New', Monaco, monospace;
border: 1px solid #000;
padding: 3px;
margin: 4px;
letter-spacing: .2rem;
text-align: center;
display: inline-flex;
flex-direction: column;
align-items: center;
}

.f008 .f008-annotation {
margin-block-end: 0.1em;
font-size: 0.65em;
white-space: nowrap;
text-align: left;
letter-spacing: -0.02rem;
}


.pages {
margin: 10px;
padding: 10px;
Expand Down Expand Up @@ -191,11 +212,11 @@ table.ReviewError {
}

#Notes textarea {
margin-top: 5px;
margin-block-start: 5px;
}

#SubmitForm {
margin-top: 8px;
margin-block-start: 8px;
}

.reviewPartial {
Expand Down Expand Up @@ -411,7 +432,7 @@ hr {
}

#select * {
margin-bottom:.5em;
margin-block-end: 0.5em;
}

select.review {
Expand Down

0 comments on commit fd7f9ca

Please sign in to comment.