download options should be sensitive to filetype
parent
cd504780e6
commit
9e5f41968b
|
@ -62,7 +62,7 @@ $j(document).ready(function() {
|
||||||
<a href="{% url download_ebook ebook.id %}">
|
<a href="{% url download_ebook ebook.id %}">
|
||||||
<img src="{{ ebook.rights_badge }}" alt="{{ ebook.rights}}" title="{{ ebook.rights}}" /></a>
|
<img src="{{ ebook.rights_badge }}" alt="{{ ebook.rights}}" title="{{ ebook.rights}}" /></a>
|
||||||
<a href="{% url download_ebook ebook.id %}"><img src="/static/images/{{ ebook.format }}32.png" height="32" alt="{{ ebook.format }} at {{ebook.provider}}" title="{{ ebook.format }} at {{ebook.provider}}" /></a>
|
<a href="{% url download_ebook ebook.id %}"><img src="/static/images/{{ ebook.format }}32.png" height="32" alt="{{ ebook.format }} at {{ebook.provider}}" title="{{ ebook.format }} at {{ebook.provider}}" /></a>
|
||||||
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }} at {{ebook.provider}}</a>
|
<a href="{% url download_ebook ebook.id %}">{{ ebook.format }} at {{ ebook.provider }}</a>
|
||||||
{% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %}
|
{% ifequal ebook.format 'mobi' %} (use for Kindle){% endifequal %}
|
||||||
{% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %}
|
{% ifequal ebook.format 'epub' %} (use for Nook, Apple, Sony){% endifequal %}
|
||||||
{% if not forloop.last %}<br /><br />{% endif %}
|
{% if not forloop.last %}<br /><br />{% endif %}
|
||||||
|
@ -81,13 +81,13 @@ $j(document).ready(function() {
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
{% if formats.epub %}
|
{% if formats.epub %}
|
||||||
Embedded browsers don't always know how to handle ebooks. We recommend downloading the epub file using Safari.
|
Embedded browsers don't always know how to handle ebooks. We recommend downloading the <a href="{% url download_ebook formats.epub.id %}">epub file</a> using Safari.
|
||||||
{% else %}{% if formats.pdf %}
|
{% else %}{% if formats.pdf %}
|
||||||
Embedded browsers don't always know how to handle ebooks. We recommend downloading the pdf file using Safari.
|
Embedded browsers don't always know how to handle ebooks. We recommend downloading the <a href="{% url download_ebook formats.pdf.id %}">pdf</a> file using Safari.
|
||||||
{% else %}{% if formats.html %}
|
{% else %}{% if formats.html %}
|
||||||
You can read the HTML version of this book right here in this browser.
|
You can read the <a href="{% url download_ebook formats.html.id %}">HTML version</a> of this book right here in this browser.
|
||||||
{% else %}{% if formats.text %}
|
{% else %}{% if formats.text %}
|
||||||
You can read the text version of this book right here in this browser.
|
You can read the <a href="{% url download_ebook formats.text.id %}">text version</a> of this book right here in this browser.
|
||||||
{% else %}
|
{% else %}
|
||||||
This ebook is only available in .mobi. Your best bet is to download the Amazon Kindle app to this device and then use the Send-to-Kindle option above.
|
This ebook is only available in .mobi. Your best bet is to download the Amazon Kindle app to this device and then use the Send-to-Kindle option above.
|
||||||
{% endif %}{% endif %}{% endif %}{% endif %}
|
{% endif %}{% endif %}{% endif %}{% endif %}
|
||||||
|
@ -101,31 +101,31 @@ $j(document).ready(function() {
|
||||||
<h4>iOS devices</h4>
|
<h4>iOS devices</h4>
|
||||||
{% if formats.epub %}
|
{% if formats.epub %}
|
||||||
<p>
|
<p>
|
||||||
You may already have an app which reads ebooks. Download the epub and see if you're offered an option for opening the file. If so, you're done! If not...
|
You may already have an app which reads ebooks. Download the <a href="{% url download_ebook formats.epub.id %}">epub file</a> and see if you're offered an option for opening the file. If so, you're done! If not...
|
||||||
</p>
|
</p>
|
||||||
<p class="ebook_download logo"><img src="/static/images/ibooks_logo.jpeg" alt="iBooks Logo" />iBooks</p>
|
<p class="ebook_download logo"><img src="/static/images/ibooks_logo.jpeg" alt="iBooks Logo" />iBooks</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://itunes.apple.com/us/app/ibooks/id364709193?mt=8">Download the free iBooks app</a> from the App Store.</li>
|
<li><a href="http://itunes.apple.com/us/app/ibooks/id364709193?mt=8">Download the free iBooks app</a> from the App Store.</li>
|
||||||
<li>Download the epub file.</li>
|
<li>Download the <a href="{% url download_ebook formats.epub.id %}">epub file</a>.</li>
|
||||||
<li>You will be given the option of opening the file in iBooks.</li>
|
<li>You will be given the option of opening the file in iBooks.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}{% if formats.pdf %}
|
{% else %}{% if formats.pdf %}
|
||||||
<p>
|
<p>
|
||||||
You may already have an app which reads ebooks. Download the pdf and see if you're offered an option for opening the file. If so, you're done! If not...
|
You may already have an app which reads ebooks. Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> and see if you're offered an option for opening the file. If so, you're done! If not...
|
||||||
</p>
|
</p>
|
||||||
<p class="ebook_download logo"><img src="/static/images/ibooks_logo.jpeg" alt="iBooks Logo" />iBooks</p>
|
<p class="ebook_download logo"><img src="/static/images/ibooks_logo.jpeg" alt="iBooks Logo" />iBooks</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://itunes.apple.com/us/app/ibooks/id364709193?mt=8">Download the free iBooks app</a> from the App Store.</li>
|
<li><a href="http://itunes.apple.com/us/app/ibooks/id364709193?mt=8">Download the free iBooks app</a> from the App Store.</li>
|
||||||
<li>Download the pdf file.</li>
|
<li>Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a>.</li>
|
||||||
<li>You will be given the option of opening the file in iBooks.</li>
|
<li>You will be given the option of opening the file in iBooks.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}{% if formats.html %}
|
{% else %}{% if formats.html %}
|
||||||
<p>
|
<p>
|
||||||
Download the HTML version.
|
Download the <a href="{% url download_ebook formats.html.id %}">HTML version</a>.
|
||||||
</p>
|
</p>
|
||||||
{% else %}{% if formats.text %}
|
{% else %}{% if formats.text %}
|
||||||
<p>
|
<p>
|
||||||
Download the text version.
|
Download the <a href="{% url download_ebook formats.text.id %}">text version</a>.
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
|
@ -141,33 +141,33 @@ $j(document).ready(function() {
|
||||||
<h4>Android devices</h4>
|
<h4>Android devices</h4>
|
||||||
{% if formats.epub %}
|
{% if formats.epub %}
|
||||||
<p>
|
<p>
|
||||||
You may already have an app which reads ebooks. Download the epub and see if you're offered an option for opening the file. If so, you're done! If not...
|
You may already have an app which reads ebooks. Download the <a href="{% url download_ebook formats.epub.id %}">epub file</a> and see if you're offered an option for opening the file. If so, you're done! If not...
|
||||||
</p>
|
</p>
|
||||||
<p class="ebook_download logo"><img src="/static/images/aldiko_logo.png" alt="Aldiko Logo" />Aldiko</p>
|
<p class="ebook_download logo"><img src="/static/images/aldiko_logo.png" alt="Aldiko Logo" />Aldiko</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://www.aldiko.com/download.html">Download the free Aldiko app.</a></li>
|
<li><a href="http://www.aldiko.com/download.html">Download the free Aldiko app.</a></li>
|
||||||
<li>Download the epub file.</li>
|
<li>Download the <a href="{% url download_ebook formats.epub.id %}">epub file</a>.</li>
|
||||||
<li>When the download is complete, tap it in your notifications menu. It will be added to Aldiko, ready to read next time you open the app.</li>
|
<li>When the download is complete, tap it in your notifications menu. It will be added to Aldiko, ready to read next time you open the app.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}{% if formats.pdf %}
|
{% else %}{% if formats.pdf %}
|
||||||
<p>
|
<p>
|
||||||
You may already have an app which reads ebooks. Download the epub and see if you're offered an option for opening the file. If so, you're done! If not...
|
You may already have an app which reads ebooks. Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> and see if you're offered an option for opening the file. If so, you're done! If not...
|
||||||
</p>
|
</p>
|
||||||
<p class="ebook_download logo"><img src="/static/images/aldiko_logo.png" alt="Aldiko Logo" />Aldiko</p>
|
<p class="ebook_download logo"><img src="/static/images/aldiko_logo.png" alt="Aldiko Logo" />Aldiko</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://www.aldiko.com/download.html">Download the free Aldiko app.</a></li>
|
<li><a href="http://www.aldiko.com/download.html">Download the free Aldiko app.</a></li>
|
||||||
<li>Download the epub file.</li>
|
<li>Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a>.</li>
|
||||||
<li>When the download is complete, tap it in your notifications menu. It will be added to Aldiko, ready to read next time you open the app.</li>
|
<li>When the download is complete, tap it in your notifications menu. It will be added to Aldiko, ready to read next time you open the app.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}{% if formats.html %}
|
{% else %}{% if formats.html %}
|
||||||
<p>
|
<p>
|
||||||
Download the HTML version.
|
Download the <a href="{% url download_ebook formats.html.id %}">HTML version</a>.
|
||||||
</p>
|
</p>
|
||||||
{% else %}{% if formats.text %}
|
{% else %}{% if formats.text %}
|
||||||
<p>
|
<p>
|
||||||
Download the text version.
|
Download the <a href="{% url download_ebook formats.text.id %}">text version</a>.
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
|
@ -183,29 +183,29 @@ $j(document).ready(function() {
|
||||||
<h4>PC, Mac, or Linux</h4>
|
<h4>PC, Mac, or Linux</h4>
|
||||||
{% if formats.pdf %}
|
{% if formats.pdf %}
|
||||||
<p>
|
<p>
|
||||||
You probably already have an app which reads PDFs. Download the PDF file and open it.
|
You probably already have an app which reads PDFs. Download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> and open it.
|
||||||
</p>
|
</p>
|
||||||
{% else %}{% if formats.epub %}
|
{% else %}{% if formats.epub %}
|
||||||
<p class="ebook_download logo"><img src="/static/images/calibre_logo.png" alt="Calibre Logo" />Calibre</p>
|
<p class="ebook_download logo"><img src="/static/images/calibre_logo.png" alt="Calibre Logo" />Calibre</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://calibre-ebook.com/download">Download the free Calibre app.</a></li>
|
<li><a href="http://calibre-ebook.com/download">Download the free Calibre app.</a></li>
|
||||||
<li>Download the epub file.</li>
|
<li>Download the <a href="{% url download_ebook formats.epub.id %}">epub file</a>.</li>
|
||||||
<li>Open the file in Calibre.</li>
|
<li>Open the file in Calibre.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}{% if formats.mobi %}
|
{% else %}{% if formats.mobi %}
|
||||||
<p class="ebook_download logo"><img src="/static/images/calibre_logo.png" alt="Calibre Logo" />Calibre</p>
|
<p class="ebook_download logo"><img src="/static/images/calibre_logo.png" alt="Calibre Logo" />Calibre</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://calibre-ebook.com/download">Download the free Calibre app.</a></li>
|
<li><a href="http://calibre-ebook.com/download">Download the free Calibre app.</a></li>
|
||||||
<li>Download the mobi file.</li>
|
<li>Download the <a href="{% url download_ebook formats.mobi.id %}">mobi file</a>.</li>
|
||||||
<li>Open the file in Calibre.</li>
|
<li>Open the file in Calibre.</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}{% if formats.html %}
|
{% else %}{% if formats.html %}
|
||||||
<p>
|
<p>
|
||||||
You can read the HTML version right here in your browser.
|
You can read the <a href="{% url download_ebook formats.html.id %}">HTML version</a> right here in your browser.
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
You can read the text version right here in your browser.
|
You can read the <a href="{% url download_ebook formats.text.id %}">text version</a> right here in your browser.
|
||||||
</p>
|
</p>
|
||||||
{% endif %}{% endif %}{% endif %}{% endif %}
|
{% endif %}{% endif %}{% endif %}{% endif %}
|
||||||
<p class="other_instructions_paragraph">
|
<p class="other_instructions_paragraph">
|
||||||
|
@ -220,16 +220,16 @@ $j(document).ready(function() {
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
{% if formats.mobi %}
|
{% if formats.mobi %}
|
||||||
<b>Kindle</b>: download the mobi file to a laptop or desktop computer.
|
<b>Kindle</b>: download the <a href="{% url download_ebook formats.mobi.id %}">mobi file</a> to your computer.
|
||||||
{% else %}{% if formats.pdf %}
|
{% else %}{% if formats.pdf %}
|
||||||
<b>Kindle</b>: download the mobi file to a laptop or desktop computer.
|
<b>Kindle</b>: download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> to your computer.
|
||||||
{% else %}
|
{% else %}
|
||||||
<b>Kindle</b>: We're sorry; we don't have a version suitable for Kindle.
|
<b>Kindle</b>: We're sorry; we don't have a version suitable for Kindle.
|
||||||
{% endif %}{% endif %}
|
{% endif %}{% endif %}
|
||||||
{% if formats.epub %}
|
{% if formats.epub %}
|
||||||
<b>All other ereaders</b>: download the epub file to a laptop or desktop computer.
|
<b>All other ereaders</b>: download the <a href="{% url download_ebook formats.epub.id %}">epub file</a> to your computer.
|
||||||
{% else %}{% if formats.pdf %}
|
{% else %}{% if formats.pdf %}
|
||||||
<b>All other ereaders</b>: download the pdf file to a laptop or desktop computer.
|
<b>All other ereaders</b>: download the <a href="{% url download_ebook formats.pdf.id %}">pdf file</a> to your computer.
|
||||||
{% else %}
|
{% else %}
|
||||||
<b>All other ereaders</b>: We're sorry; we don't have a version suitable for your device.
|
<b>All other ereaders</b>: We're sorry; we don't have a version suitable for your device.
|
||||||
{% endif %}{% endif %}
|
{% endif %}{% endif %}
|
||||||
|
|
|
@ -2409,34 +2409,36 @@ def download(request, work_id):
|
||||||
|
|
||||||
unglued_ebooks = work.ebooks().filter(edition__unglued=True)
|
unglued_ebooks = work.ebooks().filter(edition__unglued=True)
|
||||||
other_ebooks = work.ebooks().filter(edition__unglued=False)
|
other_ebooks = work.ebooks().filter(edition__unglued=False)
|
||||||
kindle_ebook_id = None
|
|
||||||
formats = {}
|
formats = {}
|
||||||
formats['mobi'] = False
|
|
||||||
try:
|
try:
|
||||||
kindle_ebook_id = work.ebooks().filter(format='mobi')[0].id
|
formats['epub'] = work.ebooks().filter(format='epub')[0]
|
||||||
formats['mobi'] = True
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
try:
|
formats['epub'] = None
|
||||||
kindle_ebook_id = work.ebooks().filter(format='pdf')[0].id
|
try:
|
||||||
except IndexError:
|
formats['pdf'] = work.ebooks().filter(format='pdf')[0]
|
||||||
pass
|
except IndexError:
|
||||||
if work.ebooks().filter(format='epub'):
|
formats['pdf'] = None
|
||||||
formats['epub'] = True
|
try:
|
||||||
else:
|
formats['mobi'] = work.ebooks().filter(format='mobi')[0]
|
||||||
formats['epub'] = False
|
except IndexError:
|
||||||
if work.ebooks().filter(format='pdf'):
|
formats['mobi'] = None
|
||||||
formats['pdf'] = True
|
try:
|
||||||
else:
|
formats['html'] = work.ebooks().filter(format='html')[0]
|
||||||
formats['pdf'] = False
|
except IndexError:
|
||||||
if work.ebooks().filter(format='html'):
|
formats['html'] = None
|
||||||
formats['html'] = True
|
try:
|
||||||
else:
|
formats['text'] = work.ebooks().filter(format='text')[0]
|
||||||
formats['html'] = False
|
except IndexError:
|
||||||
if work.ebooks().filter(format='text'):
|
formats['text'] = None
|
||||||
formats['text'] = True
|
|
||||||
else:
|
|
||||||
formats['text'] = False
|
|
||||||
|
|
||||||
|
if formats['mobi']:
|
||||||
|
kindle_ebook_id = formats['mobi'].id
|
||||||
|
elif formats['pdf']:
|
||||||
|
kindle_ebook_id = formats['pdf'].id
|
||||||
|
else:
|
||||||
|
kindle_ebook_id = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
readmill_epub_ebook = work.ebooks().filter(format='epub').exclude(provider='Google Books')[0]
|
readmill_epub_ebook = work.ebooks().filter(format='epub').exclude(provider='Google Books')[0]
|
||||||
readmill_epub_url = settings.BASE_URL_SECURE + reverse('download_ebook',args=[readmill_epub_ebook.id])
|
readmill_epub_url = settings.BASE_URL_SECURE + reverse('download_ebook',args=[readmill_epub_ebook.id])
|
||||||
|
|
Loading…
Reference in New Issue