5.0.0-79 • Published 2 months ago

@internetarchive/bookreader v5.0.0-79

Weekly downloads
684
License
AGPL-3.0
Repository
github
Last release
2 months ago

Internet Archive BookReader

Build Status codecov

npm.io

The Internet Archive BookReader is used to view books from the Internet Archive online and can also be used to view other books.

See live examples:

Demos

See BookReaderDemo directory. These can be tested by building the source files (make sure Node.js is installed):

npm run build

and starting a simple web server in the root directory:

npm run serve

And then open http://localhost:8000/BookReaderDemo/demo-simple.html.

Usage

Here is a short example.

// Create the BookReader object
var options = {
  data: [
    [
      { width: 800, height: 1200,
        uri: '//archive.org/download/BookReader/img/page001.jpg' },
    ],
    [
      { width: 800, height: 1200,
        uri: '//archive.org/download/BookReader/img/page002.jpg' },
      { width: 800, height: 1200,
        uri: '//archive.org/download/BookReader/img/page003.jpg' },
    ],
    [
      { width: 800, height: 1200,
        uri: '//archive.org/download/BookReader/img/page004.jpg' },
      { width: 800, height: 1200,
        uri: '//archive.org/download/BookReader/img/page005.jpg' },
    ]
  ],

  bookTitle: 'Simple BookReader Presentation',

  // thumbnail is optional, but it is used in the info dialog
  thumbnail: '//archive.org/download/BookReader/img/page014.jpg',

  // Metadata is optional, but it is used in the info dialog
  metadata: [
    {label: 'Title', value: 'Open Library BookReader Presentation'},
    {label: 'Author', value: 'Internet Archive'},
    {label: 'Demo Info', value: 'This demo shows how one could use BookReader with their own content.'},
  ],

  ui: 'full', // embed, full (responsive)

};
var br = new BookReader(options);

// Let's go!
br.init();

See BookReaderDemo/demo-simple.html and BookReaderDemo/BookReaderJSSimple.js for a full example. The best way to learn how to use BookReader is to view the source of the demos.

Properties

Plugins

A basic plugin system is used. See the examples in the plugins directory. The general idea is that they are mixins that augment the BookReader prototype. See the plugins directory for all the included plugins, but here are some examples:

  • plugin.autoplay.js - autoplay mode. Flips pages at set intervals.
  • plugin.chapters.js - render chapter markers
  • plugin.search.js - add search ui, and callbacks
  • plugin.tts.js - add tts (read aloud) ui, sound library, and callbacks
  • plugin.url.js - automatically updates the browser url
  • plugin.resume.js - uses cookies to remember the current page
  • plugin.mobile_nav.js - adds responsive mobile nav to BookReader
  • plugin.vendor-fullscreen.js - replaces fullscreen mode with vendor native fullscreen

Embedding

BookReader can be embedded within an <iframe>. If you use the IFrame Plugin inside the <iframe>, the reader will send notifications about changes in the state of the reader via window.postMessage(). The parent window can send messages of its own (also via window.postMessage()) and the IFrame Plugin will handle updating the reader to match.

Message Events

Fragment Change

The Fragment Change message is sent to the parent window when the embedded BookReader moves between pages/modes. When the <iframe> receives this message, it moves to the specified page/mode. The “fragment” is formatted in accordance with the BookReader URL spec.

{
  "type": "bookReaderFragmentChange",
  "fragment": "page/n1/mode/2up"
}

Development

The source JavaScript is written in ES6 (located in the src/js directory) and in ES5 (located in BookReader). npm run serve-dev starts an auto-reloading dev server, that builds js/css that has been edited at localhost:8000.

Until the next major version bump, we have to store the build files inside the repo to maintain backwards compatibility. Please DO NOT include these files in your PR. Anything in the BookReader/ directory should not be committed.

Releases

To version bump the repo and prepare a release, run npm version major|minor|patch (following semver), then (something like) git push origin HEAD --tags. It'll automatically update the version number where it appears, build the files, and ask you to update the CHANGELOG.

Tests

We would like to get to 100% test coverage and are tracking our progress in this project: BookReader Fidelity

End to end tests

We also have end to end tests using Testcafe. We write tests for the repo itself and also for our use on archive.org. You can read about them in here. These are relatively easy to do, and a fantastic way of getting introduced to the wonders of BookReader. Check the project board for open tickets to work on. And if you don't see a test for something you spotted, feel free to make an issue.

To run all local end to end tests, run command: npm run test:e2e

To keep end to end test server on while developing, run command: npm run test:e2e:dev

Unit tests

We have unit tests and use Jest to run them. For mocks, we use Jest's internal mocking mechanism and Sinon to set spies.

To run all local unit tests, run command: npm run test

Ways to contribute

We can always use a hand building BookReader. Check out the issues and see what interests you. If you have an idea for an improvement, open an issue.

More info

Developer documentation: https://openlibrary.org/dev/docs/bookreader

Hosted source code: https://github.com/internetarchive/bookreader

IIIF (http://iiif.io) See BookReaderDemo/demo-iiif.html to see an example of how to load a IIIF manifest in BookReader.

Target Devices

Note that BookReader is a core part of Archive.org's mission of Universal Access to All Knowledge. Therefore, care must be taken to support legacy browsers. It should still work and be useable on old devices.

Areas for improvement

  • Change libraries to be NPM dependencies rather than included in the source code

See CHANGELOG.md for history of the project.

License

The source code license is AGPL v3, as described in the LICENSE file.

The mobile menu is built with mmenu, which is free for personal and non-profit use. However, for commmercial use, a license must be purchased.

To use it, include the script plugins/plugin.mobile_nav.js.

Other credits

The ability to test on multiple devices is provided courtesy of Browser Stack.

5.0.0-82

2 months ago

5.0.0-81

3 months ago

5.0.0-80

9 months ago

5.0.0-79

10 months ago

5.0.0-78-alpha23

10 months ago

5.0.0-79-alpha3

11 months ago

5.0.0-79-alpha2

11 months ago

5.0.0-79-alpha1

11 months ago

5.0.0-78

11 months ago

5.0.0-77

11 months ago

5.0.0-77-alpha

11 months ago

5.0.0-76

11 months ago

5.0.0-75

11 months ago

5.0.0-74-alpha

11 months ago

5.0.0-73-alpha1

11 months ago

5.0.0-73-alpha2

11 months ago

5.0.0-73

12 months ago

5.0.0-72

1 year ago

5.0.0-71

1 year ago

5.0.0-70

1 year ago

5.0.0-65

1 year ago

5.0.0-64

1 year ago

5.0.0-69

1 year ago

5.0.0-68

1 year ago

5.0.0-67

1 year ago

5.0.0-66

1 year ago

5.0.0-70-a3

1 year ago

5.0.0-70-a2

1 year ago

5.0.0-70-a1

1 year ago

5.0.0-63

1 year ago

5.0.0-62

1 year ago

5.0.0-61

2 years ago

5.0.0-60

2 years ago

5.0.0-59

2 years ago

5.0.0-58

2 years ago

5.0.0-57

2 years ago

5.0.0-56

2 years ago

5.0.0-55

2 years ago

5.0.0-54

2 years ago

5.0.0-53-alpha2

2 years ago

5.0.0-53-alpha3

2 years ago

5.0.0-53

2 years ago

5.0.0-52

2 years ago

5.0.0-51

2 years ago

5.0.0-50

2 years ago

5.0.0-53-a1

2 years ago

5.0.0-53-a2

2 years ago

5.0.0-49

2 years ago

5.0.0-48

2 years ago

5.0.0-52-alpha1

2 years ago

5.0.0-49-a1

2 years ago

5.0.0-50-a1

2 years ago

5.0.0-53-alpha1

2 years ago

5.0.0-47

2 years ago

5.0.0-47-alpha4

2 years ago

5.0.0-47-alpha3

2 years ago

5.0.0-48-alpha0

2 years ago

5.0.0-48-alpha1

2 years ago

5.0.0-46-alpha1

2 years ago

5.0.0-46-alpha2

2 years ago

5.0.0-48-alpha2

2 years ago

5.0.0-46

2 years ago

5.0.0-45

2 years ago

5.0.0-44

2 years ago

5.0.0-44-a7

2 years ago

5.0.0-44-a6

2 years ago

5.0.0-44-a5

2 years ago

5.0.0-44-a4

2 years ago

5.0.0-44-a3

2 years ago

5.0.0-44-a2

2 years ago

5.0.0-44-a1

2 years ago

5.0.0-43

3 years ago

5.0.0-42

3 years ago

5.0.0-41

3 years ago

5.0.0-40

3 years ago

5.0.0-42-a1

3 years ago

5.0.0-42-a2

3 years ago

5.0.0-39

3 years ago

5.0.0-40-a1

3 years ago

5.0.0-38

3 years ago

5.0.0-37

3 years ago

5.0.0-32-1

3 years ago

5.0.0-32

3 years ago

5.0.0-31

3 years ago

5.0.0-30

3 years ago

5.0.0-36

3 years ago

5.0.0-35

3 years ago

5.0.0-34

3 years ago

5.0.0-33

3 years ago

5.0.0-29

3 years ago

5.0.0-30-e

3 years ago

5.0.0-30-d

3 years ago

5.0.0-30-a

3 years ago

5.0.0-30-c

3 years ago

5.0.0-30-b

3 years ago

5.0.0-25-02

3 years ago

5.0.0-28

3 years ago

5.0.0-27

3 years ago

5.0.0-26

3 years ago

5.0.0-25

3 years ago

5.0.0-24

3 years ago

5.0.0-23

3 years ago

5.0.0-22

3 years ago

5.0.0-21

3 years ago

5.0.0-20

3 years ago

5.0.0-19

3 years ago

5.0.0-18

3 years ago

5.0.0-17

3 years ago

5.0.0-16

3 years ago

5.0.0-15

3 years ago

5.0.0-14

3 years ago

5.0.0-13

3 years ago

5.0.0-12-sorting

3 years ago

5.0.0-12

3 years ago

5.0.0-10-alpha-1

3 years ago

5.0.0-10-alpha-3

3 years ago

5.0.0-8

3 years ago

5.0.0-9

3 years ago

5.0.0-7

3 years ago

5.0.0-6-14

3 years ago

5.0.0-10

3 years ago

5.0.0-11

3 years ago

5.0.0-1

4 years ago

5.0.0-2

4 years ago

5.0.0-3

4 years ago

4.40.3

4 years ago

5.0.0-4

4 years ago

5.0.0-5

4 years ago

5.0.0-6

4 years ago

5.0.0-6-12

4 years ago

5.0.0-6-13

4 years ago

5.0.0-6-11

4 years ago

5.0.0-0

4 years ago

4.40.2

4 years ago

4.40.1

4 years ago

4.40.0

4 years ago

4.39.3-alpha-0

4 years ago

4.39.3

4 years ago

4.39.2

4 years ago

4.39.1

4 years ago

4.39.0

4 years ago

4.38.0

4 years ago

4.37.0

4 years ago

4.36.0

4 years ago

4.34.0-itemnav

4 years ago

4.35.1

4 years ago

4.35.0

4 years ago

4.34.0-item-nav

4 years ago

4.34.0

4 years ago

4.33.0

4 years ago

4.31.0

4 years ago

4.32.0

4 years ago

4.30.0

4 years ago

4.29.0

4 years ago

4.28.0-navbar2

4 years ago

4.28.0-navbar1

4 years ago

4.28.0

4 years ago

4.27.0

4 years ago

4.26.3-alpha

4 years ago

4.26.2-alpha2

4 years ago

4.26.2-alpha1

4 years ago

4.26.0

4 years ago

4.26.1

4 years ago

4.25.0

4 years ago

4.24.0

4 years ago

4.23.5

4 years ago

4.23.4

4 years ago

4.23.3

4 years ago

4.23.2

4 years ago

4.23.1-b42605e

4 years ago

4.23.1-d2c9dd7

4 years ago

4.23.0-alpha-1

4 years ago

4.23.0

4 years ago

4.22.1-alpha-3

4 years ago

4.22.1-alpha-2

4 years ago

4.22.1-alpha

4 years ago

4.22.1-alpha-1

4 years ago

4.22.0-alpha-1

4 years ago

4.21.0-alpha-1

4 years ago

4.22.0

4 years ago

4.21.0

4 years ago

4.20.1-alpha-1

4 years ago

4.20.2

4 years ago

4.20.1-alpha5

4 years ago

4.20.1

4 years ago

4.20.1-alpha4

4 years ago

4.20.1-alpha3

4 years ago

4.20.1-alpha2

4 years ago

4.20.1-alpha1

4 years ago

4.20.0

4 years ago

4.19.0

4 years ago

4.18.7

4 years ago

4.18.7-alpha6

4 years ago

4.18.7-alpha5

4 years ago

4.18.7-alpha3

4 years ago

4.18.7-alpha4

4 years ago

4.18.7-alpha2

4 years ago

4.18.7-alpha1

4 years ago

4.18.6

4 years ago

4.18.6-alpha1

4 years ago

4.18.5

4 years ago

4.18.4

4 years ago

4.18.4-alpha1

4 years ago

4.18.3

4 years ago

4.18.3-alpha2

4 years ago

4.18.3-alpha1

4 years ago

4.18.2

4 years ago

4.18.2-alpha1

4 years ago

4.18.1

4 years ago

4.19.0-alpha1

4 years ago

4.18.0

4 years ago

4.17.0

4 years ago

4.16.0

4 years ago

4.15.0

4 years ago

4.14.3

4 years ago

4.14.2

4 years ago