Sign up
internetarchive
/
bookreader
Public
bookreader 4.40.3 Latest version
Install from the command line:
Learn more
$ npm install @​internetarchive​/​bookreader​@​4.40.3
Install via package.json:
"@​internetarchive​/​bookreader​": "4.40.3"
About this package
Internet Archive BookReader
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 objectvar 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
TODO (for now see src/js/BookReader/options.js​)
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:
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 an 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.
Details
internetarchive
April 21, 2021
28 dependencies
GNU AGPLv3
Assets
bookreader-4.40.3-npm.tgz
Download activity
Total downloads0
Last 30 days0
Last week0
Today0
Topics
ebooksbookreaderHacktoberfestinternetarchive
Recent versions
View all
4.40.3on Apr 21
4.40.2on Apr 15
4.40.1on Apr 13
4.40.0on Apr 12
4.39.3on Apr 1
© 2021 GitHub, Inc.
Terms
Privacy
Security
Status
Docs
Contact GitHubPricingAPITrainingBlogAbout
CodeCodeIssuesIssues96Pull requestsPull requests77ActionsActionsProjectsProjects4WikiWikiSecuritySecurityInsightsInsights Code Issues Pull requests Actions Projects Wiki Security Insights