internetarchive / openlibrary

One webpage for every book ever published!
https://openlibrary.org
GNU Affero General Public License v3.0
5.19k stars 1.35k forks source link

Support download options for web books #9581

Open scottbarnes opened 3 months ago

scottbarnes commented 3 months ago

Problem

Related: #6585

A clear and concise description of what you want to happen

Visiting the book page (e.g. http://localhost:8080/books/OL20431791M/Flatland_A_Romance_of_Many_Dimensions) should show download options for web books, to the extent they are available.

Expected behaviour / screenshots (ex: Figma design screenshots for UI feature)

Visiting a book page with a web book shows, in the left-hand menu, download options appropriate for the web book.

Additional Context

6585 adds web books, but the DirectProvider class does not support download options.

Proposal & Constraints

Which suggestions or requirements should be considered for how feature needs to appear or be implemented?

We need to think about how this would work, and the extent to which consideration of direct book providers needs to be taken into account.

Leads

Related files

The former openlibrary/templates/book_providers/direct_download_options.html may provide some useful context when implementing this:

$def with(url)

<hr>
<div class="cta-section">
<p class="cta-section-title">$_('Download Options')</p>
<ul class="ebook-download-options">
  $# FIXME: Currently only supports pressbooks
  <li><a href="$(url)open/download?type=epub" title="$_('Download as an ePub')">$_('ePub')</a></li>
  <li><a href="$(url)open/download?type=pdf" title="$_('Download as a PDF')">$_('PDF')</a></li>
  <li><a href="$(url)open/download?type=mobi" title="$_('Download as a Kindle MOBI')">$_('MOBI')</a></li>
  <li><a href="$url">$_('More options')</a></li>
</ul>
</div>

Stakeholders

@cdrini


Instructions for Contributors

sachan13harshit commented 3 months ago

@scottbarnes I would like to work on this feature. Would be great if you can assign it to me.

scottbarnes commented 3 months ago

@sachan13harshit, I'm more than happy to assign this to you, but I don't want to set you up for a frustrating time. Do you have a vision for how this would be implemented? I only ask because I'm not entirely sure how I'd approach this.

AbhinavKRN commented 3 months ago

@scottbarnes can you assign this issue to me?

scottbarnes commented 3 months ago

@AbhinavKRN, I would be happy to, but as before, I don't want to set you up for a frustrating time. Do you have a vision for how this would be implemented? I only ask because I'm not entirely sure how I'd approach this.

AbhinavKRN commented 3 months ago

So, The objective is to enhance the user experience by providing download options for web books directly from their book pages, right? and the feature to add is when a user visits a book page, if the book is available as a web book, download options (ePub, PDF, MOBI, etc.) should be visible in the left-hand menu. @scottbarnes

AbhinavKRN commented 3 months ago

so steps would be first to identify if it available on the web book and ig i will require checking specific metadata or something? i have a rough idea how to take approach. @scottbarnes

scottbarnes commented 3 months ago

The part that has been puzzling for me with respect to this issue is how to have a generic way of handling these download links. We don't want to have to create a new class or template every time a new web book provider is added. However, I am not sure whether this is really possible.

You can see here how the AbstractBookProvider class has a method for showing the download options: https://github.com/cdrini/openlibrary/blob/a52138096646c8c564ce205c48996aa87eaff055/openlibrary/book_providers.py#L93-L98

Then here is a download options template specific to Standard Ebooks: https://github.com/cdrini/openlibrary/blob/master/openlibrary/templates/book_providers/standard_ebooks_download_options.html.

Consider the different kinds of download links a site might have:

The only thing I can really think of off the top of my head is asking the patron who submits the web book to manually provide download links, but then those likely need to be stored somewhere, which may not be a route we want to go down.

I think step one here would be to propose a way for handling the downloads for the three web books above, to see if one can come up with something that can be generalized.

I think as it stands, this is a bit of a tough issue as the solution is currently hazy to me.