Skip to content

Commit 8f1c270

Browse files
authored
Disable epub download. (#226)
* Disable epub download. * Pin to old version of solr-sdr-sample image * Incorporate UI changes from #227
1 parent deed174 commit 8f1c270

9 files changed

Lines changed: 71 additions & 91 deletions

File tree

common/docker/core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ x-healthcheck-defaults: &healthcheck-defaults
99
services:
1010
solr-sdr-catalog:
1111
# This is a core service
12-
image: ghcr.io/hathitrust/catalog-solr-sample
12+
image: ghcr.io/hathitrust/catalog-solr-sample:399beb50c4ab83d963abde50c349029c95182132
1313
ports:
1414
- "9033:9033"
1515
volumes:

imgsrv/apps/download.psgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ builder {
8888
mount "/" => $app;
8989
mount "/volume" => builder {
9090
mount "/pdf" => $loader->('SRV::Volume::PDF');
91-
mount "/epub" => $loader->('SRV::Volume::EPUB');
91+
#mount "/epub" => $loader->('SRV::Volume::EPUB');
9292
mount "/plaintext" => $loader->('SRV::Volume::Text::Bundle');
9393
mount "/image" => $loader->('SRV::Volume::Image::Bundle');
9494
mount "/remediated" => $loader->('SRV::Volume::Remediated::Bundle');

imgsrv/lib/SRV/Utils.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ sub parse_env {
475475
$path_info =~ s,.*/$id/,,;
476476

477477
my $format;
478-
if ( $path_info =~ m,\.jpg$|\.tif$|\.png|\.pdf|\.epub$, ) {
478+
if ( $path_info =~ m,\.jpg$|\.tif$|\.png|\.pdf$, ) {
479479
my $ridx = rindex($path_info, '.');
480480
$format = substr($path_info, $ridx + 1);
481481
$path_info = substr($path_info, 0, $ridx) . "/$format";

imgsrv/lib/SRV/Volume/EPUB.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ sub new {
8282

8383
sub call {
8484
my ( $self, $env ) = @_;
85+
die('epub disabled');
8586
my $req = Plack::Request->new($env);
8687

8788
if ( my $num_attempts = $req->param('num_attempts') ) {

imgsrv/t/plack.t

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,19 @@ subtest "download.psgi" => sub {
109109
};
110110
};
111111

112-
subtest "volume/epub" => sub {
113-
subtest "with callback" => sub {
114-
my $res = $test->request(GET "/epub?id=test.pd_open&callback=1");
115-
is $res->message, 'OK';
116-
is $res->header('Content-Type'), 'application/javascript';
117-
};
118-
119-
subtest "without callback" => sub {
120-
my $res = $test->request(GET "/epub?id=test.pd_open");
121-
is $res->message, 'OK';
122-
is $res->header('Content-Type'), 'application/epub+zip';
123-
};
124-
};
112+
#subtest "volume/epub" => sub {
113+
# subtest "with callback" => sub {
114+
# my $res = $test->request(GET "/epub?id=test.pd_open&callback=1");
115+
# is $res->message, 'OK';
116+
# is $res->header('Content-Type'), 'application/javascript';
117+
# };
118+
119+
# subtest "without callback" => sub {
120+
# my $res = $test->request(GET "/epub?id=test.pd_open");
121+
# is $res->message, 'OK';
122+
# is $res->header('Content-Type'), 'application/epub+zip';
123+
# };
124+
#};
125125

126126
subtest "volume/plaintext" => sub {
127127
my $res = $test->request(GET "/plaintext?id=test.pd_open");

pt/lib/PT/PIFiller/Common.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ sub BuildViewTypeUrl
6464

6565
if ( $view eq 'fpdf' || $view eq 'pdf' ) {
6666
return BuildImageServerPDFUrl($cgi, $view);
67-
} elsif ( $view eq 'epub' ) {
68-
return BuildImageServerPDFUrl($cgi, $view);
67+
#} elsif ( $view eq 'epub' ) {
68+
# return BuildImageServerPDFUrl($cgi, $view);
6969
}
7070

7171
$tempCgi->delete('ui'); # clear ui=embed
@@ -96,8 +96,8 @@ sub BuildImageServerPDFUrl
9696
$tempCgi->param('num', scalar $cgi->param('num'));
9797
$tempCgi->param('attachment', 0);
9898
$action = "download/pdf";
99-
} elsif ( $view eq 'epub' ) {
100-
$action = 'download/epub';
99+
#} elsif ( $view eq 'epub' ) {
100+
# $action = 'download/epub';
101101
}
102102

103103
if ( $cgi->param('debug') ) {

pt/web/2021/common.xsl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,13 +1257,6 @@
12571257
<label for="format-pdf">Ebook (PDF)</label>
12581258
</div>
12591259

1260-
<xsl:if test="$gFullPdfAccess = 'allow'">
1261-
<div class="form-control">
1262-
<input name="download_format" type="radio" id="format-epub" value="epub" />
1263-
<label for="format-epub">Ebook (EPUB)</label>
1264-
</div>
1265-
</xsl:if>
1266-
12671260
<xsl:if test="$gHasOcr = 'YES'">
12681261
<div class="form-control">
12691262
<input name="download_format" type="radio" id="format-plaintext" value="plaintext" />

pt/web/firebird/src/js/components/DownloadPanel/index.svelte

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
const formatTitle = $state({});
1414
formatTitle['pdf'] = 'PDF';
15-
formatTitle['epub'] = 'EPUB';
1615
formatTitle['plaintext'] = 'Text (.txt)';
1716
formatTitle['plaintext-zip'] = 'Text (.zip)';
1817
formatTitle['image-jpeg'] = 'Image (JPEG)';
@@ -423,7 +422,7 @@
423422
}
424423
425424
$effect(() => {
426-
if ((format == 'plaintext-zip' || format == 'epub') && range != 'volume') {
425+
if (format == 'plaintext-zip' && range != 'volume') {
427426
range = 'volume';
428427
}
429428
});
@@ -526,19 +525,6 @@
526525
/>
527526
<label class="form-check-label" for="format-pdf"> Ebook (PDF) </label>
528527
</div>
529-
{#if manifest.allowFullDownload}
530-
<div class="form-check">
531-
<input
532-
name="format"
533-
class="form-check-input"
534-
type="radio"
535-
value="epub"
536-
id="format-epub"
537-
bind:group={format}
538-
/>
539-
<label class="form-check-label" for="format-epub"> Ebook (EPUB) </label>
540-
</div>
541-
{/if}
542528
<div class="form-check">
543529
<input
544530
name="format"
@@ -636,7 +622,7 @@
636622
type="radio"
637623
value="current-page"
638624
id="range-current-page"
639-
disabled={format == 'epub' || format == 'plaintext-zip'}
625+
disabled={format == 'plaintext-zip'}
640626
bind:group={range}
641627
/>
642628
<label class="form-check-label" for="range-current-page">
@@ -652,7 +638,7 @@
652638
type="radio"
653639
value="current-page-verso"
654640
id="range-current-verso-page"
655-
disabled={format == 'epub' || format == 'plaintext-zip'}
641+
disabled={format == 'plaintext-zip'}
656642
bind:group={range}
657643
/>
658644
<label class="form-check-label" for="range-current-verso-page">
@@ -668,7 +654,7 @@
668654
type="radio"
669655
value="current-page-recto"
670656
id="range-current-recto-page"
671-
disabled={format == 'epub' || format == 'plaintext-zip'}
657+
disabled={format == 'plaintext-zip'}
672658
bind:group={range}
673659
/>
674660
<label class="form-check-label" for="range-current-recto-page">
@@ -697,7 +683,7 @@
697683
type="radio"
698684
value="selected-pages"
699685
id="range-selected-pages"
700-
disabled={format == 'epub' || format == 'plaintext-zip'}
686+
disabled={format == 'plaintext-zip'}
701687
bind:group={range}
702688
/>
703689
<label class="form-check-label" for="range-selected-pages"> Selected page scans </label>

pt/web/firebird/tests/imgsrv_download.spec.js

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -57,51 +57,51 @@ test.describe('imgsrv download', () => {
5757
expect(downloadBody.length).toBeGreaterThan(512 * 1024);
5858
});
5959

60-
test('download epub', async ({ request, page }) => {
61-
var currentTime = new Date().getTime();
62-
63-
const initialResponse = await request.get(
64-
'http://apache:8080/cgi/imgsrv/download/epub?id=test.pd_open&callback=tunnelCallback&_=' + currentTime
65-
);
66-
const initialBody = await initialResponse.text();
67-
68-
const callbackParams = JSON.parse(
69-
initialBody
70-
.replace(/^tunnelCallback\(/, '[')
71-
.replace(/\);$/, ']')
72-
.replaceAll("'", '"')
73-
);
74-
75-
const callbackUrl = callbackParams[0];
76-
const downloadUrl = callbackParams[1];
77-
78-
// wait until status is done
79-
let done = false;
80-
81-
while (done == false) {
82-
const callbackResponse = await request.get('http://apache:8080' + callbackUrl);
83-
const callbackJson = await callbackResponse.json();
84-
85-
if (callbackJson.status == 'DONE') {
86-
done = true;
87-
} else {
88-
// wait for 1 second
89-
// await page.waitForTimeout(1000);
90-
// yes it's polling and polling is bad but that's the way imgsrv works 😿
91-
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
92-
await delay(1000);
93-
}
94-
}
95-
96-
const downloadResponse = await request.get('http://apache:8080' + downloadUrl);
97-
const downloadHeaders = downloadResponse.headers();
98-
const downloadBody = await downloadResponse.text();
99-
100-
expect(downloadResponse.status()).toEqual(200);
101-
expect(downloadHeaders['content-disposition']).toEqual('attachment; filename=test-pd_open.epub');
102-
expect(downloadHeaders['content-type']).toEqual('application/epub+zip');
103-
expect(downloadBody.length).toBeGreaterThan(0);
104-
});
60+
// test('download epub', async ({ request, page }) => {
61+
// var currentTime = new Date().getTime();
62+
//
63+
// const initialResponse = await request.get(
64+
// 'http://apache:8080/cgi/imgsrv/download/epub?id=test.pd_open&callback=tunnelCallback&_=' + currentTime
65+
// );
66+
// const initialBody = await initialResponse.text();
67+
//
68+
// const callbackParams = JSON.parse(
69+
// initialBody
70+
// .replace(/^tunnelCallback\(/, '[')
71+
// .replace(/\);$/, ']')
72+
// .replaceAll("'", '"')
73+
// );
74+
//
75+
// const callbackUrl = callbackParams[0];
76+
// const downloadUrl = callbackParams[1];
77+
//
78+
// // wait until status is done
79+
// let done = false;
80+
//
81+
// while (done == false) {
82+
// const callbackResponse = await request.get('http://apache:8080' + callbackUrl);
83+
// const callbackJson = await callbackResponse.json();
84+
//
85+
// if (callbackJson.status == 'DONE') {
86+
// done = true;
87+
// } else {
88+
// // wait for 1 second
89+
// // await page.waitForTimeout(1000);
90+
// // yes it's polling and polling is bad but that's the way imgsrv works 😿
91+
// const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
92+
// await delay(1000);
93+
// }
94+
// }
95+
//
96+
// const downloadResponse = await request.get('http://apache:8080' + downloadUrl);
97+
// const downloadHeaders = downloadResponse.headers();
98+
// const downloadBody = await downloadResponse.text();
99+
//
100+
// expect(downloadResponse.status()).toEqual(200);
101+
// expect(downloadHeaders['content-disposition']).toEqual('attachment; filename=test-pd_open.epub');
102+
// expect(downloadHeaders['content-type']).toEqual('application/epub+zip');
103+
// expect(downloadBody.length).toBeGreaterThan(0);
104+
// });
105105

106106
test('download single tiff current page, full resolution', async ({ request, page }) => {
107107
// no callback tunnel on single tiff

0 commit comments

Comments
 (0)