web/templates/RssEntry.php
Mike Colagrosso 03ed3c2257 Add Ebook::DownloadUrl for web and feed downloads
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.
2025-04-25 14:31:44 -05:00

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>