mirror of
https://github.com/standardebooks/web.git
synced 2025-07-04 22:00:35 -04:00
This commit adds a rewrite rule for ebook downloads of the form: ``` /ebooks/some-author/some-book/downloads/some-filename.epub ``` to `www/ebooks/download.php`. That file handles the logic of whether to show a thank you page before beginning the download. Download URLs in RSS, Atom, and OPDS feeds follow the same pattern, but they have a query string parameter `?source=feed` to always skip the thank you page.
28 lines
1.2 KiB
PHP
28 lines
1.2 KiB
PHP
<?
|
|
use function Safe\filesize;
|
|
|
|
/**
|
|
* @var Ebook $entry
|
|
*/
|
|
|
|
try{
|
|
$filesize = @filesize(WEB_ROOT . $entry->EpubUrl);
|
|
}
|
|
catch(Safe\Exceptions\FilesystemException){
|
|
$filesize = '0';
|
|
}
|
|
?>
|
|
<item>
|
|
<title><?= Formatter::EscapeXml($entry->Title) ?>, by <?= Formatter::EscapeXml(strip_tags($entry->AuthorsHtml)) ?></title>
|
|
<link><?= SITE_URL . Formatter::EscapeXml($entry->Url) ?></link>
|
|
<description><?= Formatter::EscapeXml($entry->Description) ?></description>
|
|
<pubDate><?= $entry->EbookCreated?->format(Enums\DateTimeFormat::Rss->value) ?></pubDate>
|
|
<guid><?= Formatter::EscapeXml($entry->FullUrl) ?></guid>
|
|
<? foreach($entry->Tags as $tag){ ?>
|
|
<category domain="https://standardebooks.org/vocab/subjects"><?= Formatter::EscapeXml($tag->Name) ?></category>
|
|
<? } ?>
|
|
<media:thumbnail url="<?= SITE_URL . $entry->Url ?>/downloads/cover-thumbnail.jpg" height="525" width="350"/>
|
|
<? if($entry->EpubUrl !== null){ ?>
|
|
<enclosure url="<?= SITE_URL . Formatter::EscapeXml($entry->GetDownloadUrl(Enums\EbookFormatType::Epub, Enums\EbookDownloadSource::Feed)) ?>" length="<?= $filesize ?>" type="application/epub+zip" /> <? /* Only one <enclosure> is allowed */ ?>
|
|
<? } ?>
|
|
</item>
|