Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/docker/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ x-healthcheck-defaults: &healthcheck-defaults
services:
solr-sdr-catalog:
# This is a core service
image: ghcr.io/hathitrust/catalog-solr-sample
image: ghcr.io/hathitrust/catalog-solr-sample:399beb50c4ab83d963abde50c349029c95182132
ports:
- "9033:9033"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion imgsrv/apps/download.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ builder {
mount "/" => $app;
mount "/volume" => builder {
mount "/pdf" => $loader->('SRV::Volume::PDF');
mount "/epub" => $loader->('SRV::Volume::EPUB');
#mount "/epub" => $loader->('SRV::Volume::EPUB');
mount "/plaintext" => $loader->('SRV::Volume::Text::Bundle');
mount "/image" => $loader->('SRV::Volume::Image::Bundle');
mount "/remediated" => $loader->('SRV::Volume::Remediated::Bundle');
Expand Down
2 changes: 1 addition & 1 deletion imgsrv/lib/SRV/Utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ sub parse_env {
$path_info =~ s,.*/$id/,,;

my $format;
if ( $path_info =~ m,\.jpg$|\.tif$|\.png|\.pdf|\.epub$, ) {
if ( $path_info =~ m,\.jpg$|\.tif$|\.png|\.pdf$, ) {
my $ridx = rindex($path_info, '.');
$format = substr($path_info, $ridx + 1);
$path_info = substr($path_info, 0, $ridx) . "/$format";
Expand Down
1 change: 1 addition & 0 deletions imgsrv/lib/SRV/Volume/EPUB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ sub new {

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

if ( my $num_attempts = $req->param('num_attempts') ) {
Expand Down
26 changes: 13 additions & 13 deletions imgsrv/t/plack.t
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ subtest "download.psgi" => sub {
};
};

subtest "volume/epub" => sub {
subtest "with callback" => sub {
my $res = $test->request(GET "/epub?id=test.pd_open&callback=1");
is $res->message, 'OK';
is $res->header('Content-Type'), 'application/javascript';
};

subtest "without callback" => sub {
my $res = $test->request(GET "/epub?id=test.pd_open");
is $res->message, 'OK';
is $res->header('Content-Type'), 'application/epub+zip';
};
};
#subtest "volume/epub" => sub {
# subtest "with callback" => sub {
# my $res = $test->request(GET "/epub?id=test.pd_open&callback=1");
# is $res->message, 'OK';
# is $res->header('Content-Type'), 'application/javascript';
# };

# subtest "without callback" => sub {
# my $res = $test->request(GET "/epub?id=test.pd_open");
# is $res->message, 'OK';
# is $res->header('Content-Type'), 'application/epub+zip';
# };
#};

subtest "volume/plaintext" => sub {
my $res = $test->request(GET "/plaintext?id=test.pd_open");
Expand Down
8 changes: 4 additions & 4 deletions pt/lib/PT/PIFiller/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ sub BuildViewTypeUrl

if ( $view eq 'fpdf' || $view eq 'pdf' ) {
return BuildImageServerPDFUrl($cgi, $view);
} elsif ( $view eq 'epub' ) {
return BuildImageServerPDFUrl($cgi, $view);
#} elsif ( $view eq 'epub' ) {
# return BuildImageServerPDFUrl($cgi, $view);
}

$tempCgi->delete('ui'); # clear ui=embed
Expand Down Expand Up @@ -96,8 +96,8 @@ sub BuildImageServerPDFUrl
$tempCgi->param('num', scalar $cgi->param('num'));
$tempCgi->param('attachment', 0);
$action = "download/pdf";
} elsif ( $view eq 'epub' ) {
$action = 'download/epub';
#} elsif ( $view eq 'epub' ) {
# $action = 'download/epub';
}

if ( $cgi->param('debug') ) {
Expand Down
7 changes: 0 additions & 7 deletions pt/web/2021/common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1257,13 +1257,6 @@
<label for="format-pdf">Ebook (PDF)</label>
</div>

<xsl:if test="$gFullPdfAccess = 'allow'">
<div class="form-control">
<input name="download_format" type="radio" id="format-epub" value="epub" />
<label for="format-epub">Ebook (EPUB)</label>
</div>
</xsl:if>

<xsl:if test="$gHasOcr = 'YES'">
<div class="form-control">
<input name="download_format" type="radio" id="format-plaintext" value="plaintext" />
Expand Down
24 changes: 5 additions & 19 deletions pt/web/firebird/src/js/components/DownloadPanel/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

const formatTitle = $state({});
formatTitle['pdf'] = 'PDF';
formatTitle['epub'] = 'EPUB';
formatTitle['plaintext'] = 'Text (.txt)';
formatTitle['plaintext-zip'] = 'Text (.zip)';
formatTitle['image-jpeg'] = 'Image (JPEG)';
Expand Down Expand Up @@ -423,7 +422,7 @@
}

$effect(() => {
if ((format == 'plaintext-zip' || format == 'epub') && range != 'volume') {
if (format == 'plaintext-zip' && range != 'volume') {
range = 'volume';
}
});
Expand Down Expand Up @@ -526,19 +525,6 @@
/>
<label class="form-check-label" for="format-pdf"> Ebook (PDF) </label>
</div>
{#if manifest.allowFullDownload}
<div class="form-check">
<input
name="format"
class="form-check-input"
type="radio"
value="epub"
id="format-epub"
bind:group={format}
/>
<label class="form-check-label" for="format-epub"> Ebook (EPUB) </label>
</div>
{/if}
<div class="form-check">
<input
name="format"
Expand Down Expand Up @@ -636,7 +622,7 @@
type="radio"
value="current-page"
id="range-current-page"
disabled={format == 'epub' || format == 'plaintext-zip'}
disabled={format == 'plaintext-zip'}
bind:group={range}
/>
<label class="form-check-label" for="range-current-page">
Expand All @@ -652,7 +638,7 @@
type="radio"
value="current-page-verso"
id="range-current-verso-page"
disabled={format == 'epub' || format == 'plaintext-zip'}
disabled={format == 'plaintext-zip'}
bind:group={range}
/>
<label class="form-check-label" for="range-current-verso-page">
Expand All @@ -668,7 +654,7 @@
type="radio"
value="current-page-recto"
id="range-current-recto-page"
disabled={format == 'epub' || format == 'plaintext-zip'}
disabled={format == 'plaintext-zip'}
bind:group={range}
/>
<label class="form-check-label" for="range-current-recto-page">
Expand Down Expand Up @@ -697,7 +683,7 @@
type="radio"
value="selected-pages"
id="range-selected-pages"
disabled={format == 'epub' || format == 'plaintext-zip'}
disabled={format == 'plaintext-zip'}
bind:group={range}
/>
<label class="form-check-label" for="range-selected-pages"> Selected page scans </label>
Expand Down
90 changes: 45 additions & 45 deletions pt/web/firebird/tests/imgsrv_download.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,51 @@ test.describe('imgsrv download', () => {
expect(downloadBody.length).toBeGreaterThan(512 * 1024);
});

test('download epub', async ({ request, page }) => {
var currentTime = new Date().getTime();

const initialResponse = await request.get(
'http://apache:8080/cgi/imgsrv/download/epub?id=test.pd_open&callback=tunnelCallback&_=' + currentTime
);
const initialBody = await initialResponse.text();

const callbackParams = JSON.parse(
initialBody
.replace(/^tunnelCallback\(/, '[')
.replace(/\);$/, ']')
.replaceAll("'", '"')
);

const callbackUrl = callbackParams[0];
const downloadUrl = callbackParams[1];

// wait until status is done
let done = false;

while (done == false) {
const callbackResponse = await request.get('http://apache:8080' + callbackUrl);
const callbackJson = await callbackResponse.json();

if (callbackJson.status == 'DONE') {
done = true;
} else {
// wait for 1 second
// await page.waitForTimeout(1000);
// yes it's polling and polling is bad but that's the way imgsrv works 😿
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
await delay(1000);
}
}

const downloadResponse = await request.get('http://apache:8080' + downloadUrl);
const downloadHeaders = downloadResponse.headers();
const downloadBody = await downloadResponse.text();

expect(downloadResponse.status()).toEqual(200);
expect(downloadHeaders['content-disposition']).toEqual('attachment; filename=test-pd_open.epub');
expect(downloadHeaders['content-type']).toEqual('application/epub+zip');
expect(downloadBody.length).toBeGreaterThan(0);
});
// test('download epub', async ({ request, page }) => {
// var currentTime = new Date().getTime();
//
// const initialResponse = await request.get(
// 'http://apache:8080/cgi/imgsrv/download/epub?id=test.pd_open&callback=tunnelCallback&_=' + currentTime
// );
// const initialBody = await initialResponse.text();
//
// const callbackParams = JSON.parse(
// initialBody
// .replace(/^tunnelCallback\(/, '[')
// .replace(/\);$/, ']')
// .replaceAll("'", '"')
// );
//
// const callbackUrl = callbackParams[0];
// const downloadUrl = callbackParams[1];
//
// // wait until status is done
// let done = false;
//
// while (done == false) {
// const callbackResponse = await request.get('http://apache:8080' + callbackUrl);
// const callbackJson = await callbackResponse.json();
//
// if (callbackJson.status == 'DONE') {
// done = true;
// } else {
// // wait for 1 second
// // await page.waitForTimeout(1000);
// // yes it's polling and polling is bad but that's the way imgsrv works 😿
// const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
// await delay(1000);
// }
// }
//
// const downloadResponse = await request.get('http://apache:8080' + downloadUrl);
// const downloadHeaders = downloadResponse.headers();
// const downloadBody = await downloadResponse.text();
//
// expect(downloadResponse.status()).toEqual(200);
// expect(downloadHeaders['content-disposition']).toEqual('attachment; filename=test-pd_open.epub');
// expect(downloadHeaders['content-type']).toEqual('application/epub+zip');
// expect(downloadBody.length).toBeGreaterThan(0);
// });

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