Add the @download attribute to ebook download links

This commit is contained in:
Alex Cabal 2021-12-05 12:54:53 -06:00
parent f8904c8979
commit a2a49a376e
3 changed files with 8 additions and 5 deletions

View file

@ -94,6 +94,7 @@ Define domain standardebooks.org
<Location ~ ^/ebooks/.+?/downloads/.+$>
# Serve distributables using the "download" dialog instead of opening in-browser
# Note: the trailing e in the Header directive is required
# In modern browsers this is handled with the a@download attribute, we keep this here for compatibility
SetEnvIf Request_URI ^/ebooks/.+?/downloads/(.+)$ FILENAME=$1
Header set Content-Disposition "attachment; filename=%{FILENAME}e"
</Location>

View file

@ -93,6 +93,7 @@ Define domain standardebooks.test
<Location ~ ^/ebooks/.+?/downloads/.+$>
# Serve distributables using the "download" dialog instead of opening in-browser
# Note: the trailing e in the Header directive is required
# In modern browsers this is handled with the a@download attribute, we keep this here for compatibility
SetEnvIf Request_URI ^/ebooks/.+?/downloads/(.+)$ FILENAME=$1
Header set Content-Disposition "attachment; filename=%{FILENAME}e"
</Location>

View file

@ -174,12 +174,13 @@ catch(\Exception $ex){
<section id="download">
<h3>Download for ereaders</h3>
<ul>
<? /* Leave the @download attribute empty to have the browser use the target filename in the save-as dialog */ ?>
<? if($ebook->EpubUrl !== null){ ?>
<li property="schema:encoding" typeof="schema:MediaObject">
<meta property="schema:description" content="epub"/>
<meta property="schema:encodingFormat" content="application/epub+zip"/>
<p>
<span><a property="schema:contentUrl" href="<?= $ebook->EpubUrl ?>" class="epub">Compatible epub</a></span> <span></span> <span>All devices and apps except Kindles and Kobos.</span>
<span><a property="schema:contentUrl" href="<?= $ebook->EpubUrl ?>" class="epub" download="">Compatible epub</a></span> <span></span> <span>All devices and apps except Kindles and Kobos.</span>
</p>
</li>
<? } ?>
@ -188,16 +189,16 @@ catch(\Exception $ex){
<li property="schema:encoding" typeof="schema:MediaObject">
<meta property="schema:encodingFormat" content="application/x-mobipocket-ebook"/>
<p>
<span><a property="schema:contentUrl" href="<?= $ebook->Azw3Url ?>" class="amazon"><span property="schema:description">azw3</span></a></span> <span></span> <span>Kindle devices and apps.<? if($ebook->KindleCoverUrl !== null){ ?> Also download the <a href="<?= $ebook->KindleCoverUrl ?>">Kindle cover thumbnail</a> to see the cover in your Kindles library. You may be interested in our <a href="/help/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? }else{ ?> Also see our <a href="/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? } ?></span>
<span><a property="schema:contentUrl" href="<?= $ebook->Azw3Url ?>" class="amazon" download=""><span property="schema:description">azw3</span></a></span> <span></span> <span>Kindle devices and apps.<? if($ebook->KindleCoverUrl !== null){ ?> Also download the <a href="<?= $ebook->KindleCoverUrl ?>">Kindle cover thumbnail</a> to see the cover in your Kindles library. You may be interested in our <a href="/help/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? }else{ ?> Also see our <a href="/how-to-use-our-ebooks#kindle-faq">Kindle FAQ</a>.<? } ?></span>
</p>
</li>
<? } ?>
<? if($ebook->KepubUrl !== null){ ?>
<li property="schema:encoding" typeof="schema:MediaObject">
<meta property="schema:encodingFormat" content="application/kepub+zip"/>
<meta property="schema:encodingFormat" content="application/kepub+zip"/>
<p>
<span><a property="schema:contentUrl" href="<?= $ebook->KepubUrl ?>" class="kobo"><span property="schema:description">kepub</span></a></span> <span></span> <span>Kobo devices and apps.</span>
<span><a property="schema:contentUrl" href="<?= $ebook->KepubUrl ?>" class="kobo" download=""><span property="schema:description">kepub</span></a></span> <span></span> <span>Kobo devices and apps.</span>
</p>
</li>
<? } ?>
@ -206,7 +207,7 @@ catch(\Exception $ex){
<li property="schema:encoding" typeof="schema:MediaObject">
<meta property="schema:encodingFormat" content="application/epub+zip"/>
<p>
<span><a property="schema:contentUrl" href="<?= $ebook->AdvancedEpubUrl ?>" class="epub"><span property="schema:description">Advanced epub</span></a></span> <span></span> <span>An advanced format that uses the latest technology not yet fully supported by most ereaders.</span>
<span><a property="schema:contentUrl" href="<?= $ebook->AdvancedEpubUrl ?>" class="epub" download=""><span property="schema:description">Advanced epub</span></a></span> <span></span> <span>An advanced format that uses the latest technology not yet fully supported by most ereaders.</span>
</p>
</li>
<? } ?>