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.
This commit is contained in:
Mike Colagrosso 2025-04-24 16:20:44 -06:00 committed by Alex Cabal
parent 1f41eb1e55
commit 03ed3c2257
10 changed files with 99 additions and 36 deletions

View file

@ -59,7 +59,7 @@ RewriteRule ^/ebooks/jules-verne/eight-hundred-leagues-on-the-amazon/w-j-gordon(
RewriteRule ^/ebooks/jules-verne/twenty-thousand-leagues-under-the-seas/f-p-walter.* - [R=451,L]
# Rewrite ebook downloads.
RewriteRule ^/ebooks/(.+?)/download$ /ebooks/download.php?url-path=$1 [QSA]
RewriteRule ^/ebooks/(.+?)/downloads/(.+?\.(?:epub|azw3))$ /ebooks/download.php?url-path=$1&filename=$2 [L,QSA]
# Prevent this rule from firing if we're getting a distribution file.
RewriteCond %{REQUEST_FILENAME} !^/ebooks/.+?/downloads/.+$