{"id":13511929,"url":"https://github.com/internetarchive/bookreader","last_synced_at":"2026-01-16T23:27:30.313Z","repository":{"id":449217,"uuid":"72221","full_name":"internetarchive/bookreader","owner":"internetarchive","description":"The Internet Archive BookReader","archived":false,"fork":false,"pushed_at":"2025-04-29T16:27:48.000Z","size":52294,"stargazers_count":1044,"open_issues_count":225,"forks_count":436,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-30T10:37:28.155Z","etag":null,"topics":["bookreader","ebooks","hacktoberfest","internetarchive"],"latest_commit_sha":null,"homepage":"https://openlibrary.org/dev/docs/bookreader","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/internetarchive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2008-11-06T04:29:36.000Z","updated_at":"2025-04-29T16:25:38.000Z","dependencies_parsed_at":"2023-07-05T15:02:11.161Z","dependency_job_id":"97d81b1a-1ddb-4761-b45f-86e76f6452fd","html_url":"https://github.com/internetarchive/bookreader","commit_stats":{"total_commits":2354,"total_committers":73,"mean_commits":32.24657534246575,"dds":0.7187765505522514,"last_synced_commit":"0cffc73901e199efd7a8e2b83c75d44a804e99cf"},"previous_names":[],"tags_count":196,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Fbookreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Fbookreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Fbookreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/internetarchive%2Fbookreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/internetarchive","download_url":"https://codeload.github.com/internetarchive/bookreader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254040435,"owners_count":22004539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bookreader","ebooks","hacktoberfest","internetarchive"],"created_at":"2024-08-01T03:01:19.910Z","updated_at":"2025-12-18T08:29:57.883Z","avatar_url":"https://github.com/internetarchive.png","language":"JavaScript","readme":"# Internet Archive BookReader\n\n![Build Status](https://github.com/internetarchive/bookreader/actions/workflows/node.js.yml/badge.svg?branch=master) [![codecov](https://codecov.io/gh/internetarchive/bookreader/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/bookreader)\n\n**Disclaimer: BookReader v5 is currently in beta. It is stable enough for production use and is actively deployed on archive.org. Future updates while in v5 beta may introduce breaking changes to public BookReader APIs, although these will be noted in the CHANGELOG.**\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"200\" src=\"./BookReaderDemo/assets/v5/Bookreader-logo-lines.svg\" alt=\"Internet Archive BookReader full logo\"\u003e\n\u003c/p\u003e\n\n\n\u003cdiv style=\"border: 1px solid gray; padding: 2px; margin-bottom: 20px\"\u003e\u003cimg src=\"./BookReaderDemo/assets/v5/bookreader-v5-screenshot.png\" alt=\"BookReader v5 interface screenshot\"\u003e\u003c/div\u003e\n\n\nThe Internet Archive BookReader is used to view books from the Internet Archive online and can also be used to view other books.\n\nSee live examples:\n- On details page: https://archive.org/details/birdbookillustra00reedrich\n- Full window: https://archive.org/details/birdbookillustra00reedrich?view=theater\n- Embedded url for iFrames: https://archive.org/embed/birdbookillustra00reedrich\n\n## Demos\n\nSee `BookReaderDemo` directory. These can be tested by building the source files (make sure [Node.js is installed](https://nodejs.org/en/download/)):\n\n```bash\nnpm run build\n```\n\nand starting a simple web server in the root directory:\n\n```\nnpm run serve\n```\n\nAnd then open `http://localhost:8000/BookReaderDemo/demo-simple.html`.\n\n\n## Usage\n\nHere is a short example.\n\n```js\n// Create the BookReader object\nvar options = {\n  data: [\n    [\n      { width: 800, height: 1200,\n        uri: '//archive.org/download/BookReader/img/page001.jpg' },\n    ],\n    [\n      { width: 800, height: 1200,\n        uri: '//archive.org/download/BookReader/img/page002.jpg' },\n      { width: 800, height: 1200,\n        uri: '//archive.org/download/BookReader/img/page003.jpg' },\n    ],\n    [\n      { width: 800, height: 1200,\n        uri: '//archive.org/download/BookReader/img/page004.jpg' },\n      { width: 800, height: 1200,\n        uri: '//archive.org/download/BookReader/img/page005.jpg' },\n    ]\n  ],\n\n  bookTitle: 'Simple BookReader Presentation',\n\n  // thumbnail is optional, but it is used in the info dialog\n  thumbnail: '//archive.org/download/BookReader/img/page014.jpg',\n\n  // Metadata is optional, but it is used in the info dialog\n  metadata: [\n    {label: 'Title', value: 'Open Library BookReader Presentation'},\n    {label: 'Author', value: 'Internet Archive'},\n    {label: 'Demo Info', value: 'This demo shows how one could use BookReader with their own content.'},\n  ],\n\n  ui: 'full', // embed, full (responsive)\n\n};\nvar br = new BookReader(options);\n\n// Let's go!\nbr.init();\n\n```\n## Architecture Overview\nStarting at v5, BookReader introduces hybrid architecture that merges the core code written in jQuery closer to its evolution as a web component.  As we march toward the future of BookReader as a web component, we are taking an Event Driven approach to connect the two together.\n\nApproach:\n- Event driven\n  - BookReader's (BR) core code emits [custom events](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent), reporting the actions it takes:\n    - UI changes\n      - Core Events [src/BookReader/events.js](https://github.com/internetarchive/bookreader/tree/master/src/BookReader/events.js)\n    - API returns\n      - Search API [src/BookReader/events.js](https://github.com/internetarchive/bookreader/tree/master/src/BookReader/events.js)\n  - BookNavigator, BR's web components controller, listens and reacts to these events in order to populate the side menu panels\n- Control BR from the outside by using public methods\n  - When BookNavigator reacts to BR's events, BookNavigator can directly control BR core using public functions.\n    - As we continue to decouple the UI from drawing/calculating logic, these logical methods will become easier to spot, raise as a public method, and create unit tests for them.\n\n### Menu panels: Web Components via LitElement\nBookReader's side navigation is powered by LitElement flavored web components.\n\n\n### Core: jQuery\nBookReader's core functionality is in jQuery.\nThis includes:\n- drawing \u0026 resizing the book and the various modes (1up, 2 page spread, gallery view)\n- the horizontal navigation\n- search API service\n- plugins\n\nA peek in how to use/extend core functionality:\n- Properties\n  - TODO (for now see [src/BookReader/options.js](https://github.com/internetarchive/bookreader/tree/master/src/BookReader/options.js))\n- Plugins\n  - 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:\n    - plugin.autoplay.js - autoplay mode. Flips pages at set intervals.\n    - plugin.chapters.js - render chapter markers\n    - plugin.search.js - add search ui, and callbacks\n    - plugin.tts.js - add tts (read aloud) ui, sound library, and callbacks\n    - plugin.url.js - automatically updates the browser url\n    - plugin.resume.js - uses cookies to remember the current page\n    - plugin.vendor-fullscreen.js - replaces fullscreen mode with vendor native fullscreen\n    - see [plugin directory for current plugin files](https://github.com/internetarchive/bookreader/tree/master/src/plugins)\n\n### Embedding BookReader in an iFrame\n\nBookReader can be embedded within an `\u003ciframe\u003e`. If you use the IFrame Plugin inside the `\u003ciframe\u003e`, the reader will send notifications about changes in the state of the reader via [`window.postMessage()`](https://developer.mozilla.org/en-US/docs/Web/API/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.\n\n### Message Events\n\n#### Fragment Change\nThe Fragment Change message is sent to the parent window when the embedded BookReader moves between pages/modes. When the `\u003ciframe\u003e` receives this message, it moves to the specified page/mode. The “fragment” is formatted in accordance with the [BookReader URL spec](http://openlibrary.org/dev/docs/bookurls).\n\n```json\n{\n  \"type\": \"bookReaderFragmentChange\",\n  \"fragment\": \"page/n1/mode/2up\"\n}\n```\n\n## Development\n\n(updates?)\n\nThe 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`.\n\n### Developing icons\nTo see local icon package changes in bookreader, you'll need to install core-js into the icon package and link into bookreader.\n\nLet's use `icon-share` as an example.\n1.  Confirm your icon package is working properly in the iaux-icons demo\n2.  Navigate to your icon package (`iaux-icons/packages/icon-share`) and run command: `npm install core-js`\n    -  You shouldn't need to commit any of these core-js changes\n3.  From within your icon package directory run command: `npm link`\n    -  You can use the command `npm ls -g` to confirm your local package now appears in the registry\n4.  Navigate to `/bookreader` and run command: `npm link @internetarchive/icon-share`\n    -  You can use the command `npm ls |grep icon-share` to confirm icon-share is now a link to your local directory\n5. You may now start a local server to see your changes by running command: `npm run serve-dev`\n\n## Releases\n\nTo version bump the repo and prepare a release, run `npm version major|minor|patch` (following [semver](https://semver.org/)), 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.\n\nWe release BookReader [in-repo as tags](https://github.com/internetarchive/bookreader/releases) \u0026 also as a node module [@internetarchive/bookreader](https://www.npmjs.com/package/@internetarchive/bookreader)\n\n## Tests\nWe would like to get to 100% test coverage and are tracking our progress in this project: [BookReader Fidelity](https://github.com/internetarchive/bookreader/projects/5)\n\n### End to end tests\nWe also have end to end tests using [Testcafe](https://devexpress.github.io/testcafe/documentation/getting-started/).  We write tests for the repo itself and also for our use on archive.org. You can read about them in [here](./tests/e2e/README.md). 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.\n\nTo run all local end to end tests, run command: `npm run test:e2e`\n\nTo keep end to end test server on while developing, run command: `npm run test:e2e:dev`\n\n### Unit tests\nWe have unit tests and use Jest to run them.\nFor mocks, we use Jest's internal mocking mechanism and Sinon to set spies.\n\nTo run all local unit tests, run command: `npm run test`\n\n## Ways to contribute\n\nWe 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.\n\n## More info\n\nDeveloper documentation:\nhttps://openlibrary.org/dev/docs/bookreader\n\nHosted source code:\nhttps://github.com/internetarchive/bookreader\n\nIIIF (http://iiif.io)\nSee `BookReaderDemo/demo-iiif.html` to see an example of how to load an IIIF manifest in BookReader.\n\n\n## Target Devices\n\nNote 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.\n\n\n## Areas for improvement\n- Change libraries to be NPM dependencies rather than included in the source code\n\nSee [CHANGELOG.md](CHANGELOG.md) for history of the project.\n\n\n## License\nThe source code license is AGPL v3, as described in the LICENSE file.\n\n## Other credits\nThe ability to test on multiple devices is provided courtesy of [Browser Stack](https://www.browserstack.com).\n","funding_links":[],"categories":["JavaScript","IIIF Viewers"],"sub_categories":["IIIF Extensions"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finternetarchive%2Fbookreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finternetarchive%2Fbookreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finternetarchive%2Fbookreader/lists"}