-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
My Books: Borrow History Page #7311
Description
Background
Please refer to the My Books Development Tutorial to provide background on which changes may be required:
https://github.com/internetarchive/openlibrary/wiki/Developing-the-Reading-Log
Problem
At the time of authoring this issue, there was no Archive.org API for fetching a patron's loan history so, instead of rendering a loan_history page on Open Library under the my books page, we had to link patrons to their archive.org account:
On Archive.org - My Loan History experience
- Going to https://archive.org/account/?tab=loans#loans-history did not switch to history tab (no way to navigate directly)
- History was not sorted from most recent borrow to least
- No way to change the sort order
- No way to search for a title to re-borrow
- No way to segment by year borrowed
- No API (I can see) to improve this experience
The things I'm trying to do are:
- See books I've borrowed (preferably recently, to continue)
- Search for a specific title
- See whether these titles are available
Unofficial Docs
We should eventually create an endpoint https://archive.org/services/loans/loan/?action=history which takes s3_secret and s3_access (as POST / headers).
Proposal & Constraints
Implement borrow history (private) on Open Library which uses s3 keys + archive.org API
Add search (by title / author), year separators, show recently borrowed first.
Developer Notes
/plugins is a directory containing python code which allows us to define new pages or URLs that we want to register for Open Library. So, imagine we want to create a new page that doesn't exist yet called /{account-name}/books/loan-history -- we can register a python function in a plugin that:
- defines a URL (e.g.
/{account-name}/books/loan-history) the patron will go - defines what data models will be used to fetch the data our page will need
- our model will likely be the borrow_history API
- calls and renders an html template, giving it the data we've fetched
Steps:
- Add a new plugin for /{account-name}/books/loan-history to the my books: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/upstream/mybooks.py
- In this plugin function, we're going to fetch the logged in patron, use the borrow_history API to fetch their historical loans
- Add a new html template into https://github.com/internetarchive/openlibrary/tree/master/openlibrary/templates/account directory for loan_history.html (you may use loans.html as a reference because its very similar to what we want to do)
- The plugin will fetch borrow_history API and pass the result into loan_history.html
- There may be 1 "gotcha" which is, in templates/account there's a file called mybooks.html which wraps around the loans page and the loan_history page we're going to be creating -- it's what renders the sidebar for the my books page.
