@internetarchive/bookreader 5.0.0-81 → 5.0.0-82

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 5.0.0-82
2
+ - Feature: New option to control unviewable page image: `unviewablePageURI` @cdrini
3
+
1
4
  # 5.0.0-81
2
5
  - Dev: Update test dependencies @cdrini
3
6
  - Dev: Update build dependencies @cdrini
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-81",
3
+ "version": "5.0.0-82",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -4,11 +4,6 @@ import { clamp } from './utils.js';
4
4
  /** @typedef {import('./options.js').PageData} PageData */
5
5
  /** @typedef {import('../BookReader.js').default} BookReader */
6
6
 
7
- // URI to display when a page is not viewable.
8
- // TODO Render configurable html for the user instead.
9
- // FIXME Don't reference files on archive.org
10
- const UNVIEWABLE_PAGE_URI = '/bookreader/static/preview-default.png';
11
-
12
7
  /**
13
8
  * Contains information about the Book/Document independent of the way it is
14
9
  * being rendering. Nothing here should reference e.g. the mode, zoom, etc.
@@ -160,7 +155,17 @@ export class BookModel {
160
155
  */
161
156
  // eslint-disable-next-line no-unused-vars
162
157
  getPageURI(index, reduce, rotate) {
163
- return !this.getPageProp(index, 'viewable', true) ? UNVIEWABLE_PAGE_URI : this.getPageProp(index, 'uri');
158
+ if (!this.getPageProp(index, 'viewable', true)) {
159
+ const uri = this.br.options.unviewablePageURI;
160
+ if (uri.startsWith('.')) {
161
+ // It's a relative path, so make it relative to the images path
162
+ return this.br.options.imagesBaseURL + uri;
163
+ } else {
164
+ return uri;
165
+ }
166
+ } else {
167
+ return this.getPageProp(index, 'uri');
168
+ }
164
169
  }
165
170
 
166
171
  /**
@@ -301,6 +301,15 @@ export const DEFAULT_OPTIONS = {
301
301
  * On init, by default, we want to use srcSet for images
302
302
  */
303
303
  useSrcSet: false,
304
+
305
+ /**
306
+ * @type {string}
307
+ * Path to the image to display when a page is unviewable (i.e. when
308
+ * displaying a preview of a book).
309
+ *
310
+ * Relative to the imagesBaseURL if a relative path is specified.
311
+ */
312
+ unviewablePageURI: './unviewable_page.png',
304
313
  };
305
314
 
306
315
  /**