mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 14:50:39 -04:00
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:
parent
1f41eb1e55
commit
03ed3c2257
10 changed files with 99 additions and 36 deletions
|
@ -1167,6 +1167,34 @@ final class Ebook{
|
|||
$this->SetIdentifier();
|
||||
}
|
||||
|
||||
public function GetDownloadUrl(Enums\EbookFormatType $format = Enums\EbookFormatType::Epub, ?Enums\EbookDownloadSource $source = null): ?string{
|
||||
switch($format){
|
||||
case Enums\EbookFormatType::Kepub:
|
||||
$downloadUrl = $this->KepubUrl;
|
||||
break;
|
||||
|
||||
case Enums\EbookFormatType::Azw3:
|
||||
$downloadUrl = $this->Azw3Url;
|
||||
break;
|
||||
|
||||
case Enums\EbookFormatType::AdvancedEpub:
|
||||
$downloadUrl = $this->AdvancedEpubUrl;
|
||||
break;
|
||||
|
||||
case Enums\EbookFormatType::Epub:
|
||||
default:
|
||||
$downloadUrl = $this->EpubUrl;
|
||||
break;
|
||||
}
|
||||
|
||||
if(isset($source)){
|
||||
$downloadUrl .= '?source=' . $source->value;
|
||||
|
||||
}
|
||||
|
||||
return $downloadUrl;
|
||||
}
|
||||
|
||||
// *******
|
||||
// METHODS
|
||||
// *******
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue