mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 02:46:46 -04:00
Add special 'query-ebook-url' parameter to /artworks to get covers matching exactly the ebook URL
This commit is contained in:
parent
3ebe6fe457
commit
801b5f524a
2 changed files with 9 additions and 2 deletions
|
@ -501,7 +501,7 @@ class Artwork extends PropertiesBase{
|
||||||
// We don't check if it exists, because the book might not be published yet.
|
// We don't check if it exists, because the book might not be published yet.
|
||||||
// But we do a basic check that the string includes one _. It might not include a dash, for example anonymous_poetry
|
// But we do a basic check that the string includes one _. It might not include a dash, for example anonymous_poetry
|
||||||
if($this->EbookUrl !== null){
|
if($this->EbookUrl !== null){
|
||||||
if(!preg_match('|^https://standardebooks.org/ebooks/|ius', $this->EbookUrl)){
|
if(!preg_match('|^https://standardebooks.org/ebooks/[^/]+?/[^/]+?|ius', $this->EbookUrl)){
|
||||||
$error->Add(new Exceptions\EbookNotFoundException('Invalid ebook. Expected S.E. URL.'));
|
$error->Add(new Exceptions\EbookNotFoundException('Invalid ebook. Expected S.E. URL.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
$page = HttpInput::Int(GET, 'page') ?? 1;
|
$page = HttpInput::Int(GET, 'page') ?? 1;
|
||||||
$perPage = HttpInput::Int(GET, 'per-page') ?? ARTWORK_PER_PAGE;
|
$perPage = HttpInput::Int(GET, 'per-page') ?? ARTWORK_PER_PAGE;
|
||||||
$query = HttpInput::Str(GET, 'query') ?? '';
|
$query = HttpInput::Str(GET, 'query') ?? '';
|
||||||
|
$queryEbookUrl = HttpInput::Str(GET, 'query-ebook-url');
|
||||||
$status = HttpInput::Str(GET, 'status') ?? null;
|
$status = HttpInput::Str(GET, 'status') ?? null;
|
||||||
$filterArtworkStatus = $status;
|
$filterArtworkStatus = $status;
|
||||||
$sort = HttpInput::Str(GET, 'sort');
|
$sort = HttpInput::Str(GET, 'sort');
|
||||||
|
@ -64,7 +65,13 @@ if($isSubmitterView && !in_array($status, array('all', ArtworkStatus::Unverified
|
||||||
$filterArtworkStatus = $status;
|
$filterArtworkStatus = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
$artworks = Library::FilterArtwork($query != '' ? $query : null, $filterArtworkStatus, $sort, $submitterUserId);
|
if($queryEbookUrl !== null){
|
||||||
|
$artworks = Db::Query('SELECT * from Artworks where EbookUrl = ? and Status = ?', [$queryEbookUrl, ArtworkStatus::Approved], 'Artwork');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$artworks = Library::FilterArtwork($query != '' ? $query : null, $filterArtworkStatus, $sort, $submitterUserId);
|
||||||
|
}
|
||||||
|
|
||||||
$pageTitle = 'Browse Artwork';
|
$pageTitle = 'Browse Artwork';
|
||||||
$pages = ceil(sizeof($artworks) / $perPage);
|
$pages = ceil(sizeof($artworks) / $perPage);
|
||||||
$totalArtworkCount = sizeof($artworks);
|
$totalArtworkCount = sizeof($artworks);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue