Normalize URLs when submitting artwork to database

This commit is contained in:
Alex Cabal 2024-01-09 13:59:00 -06:00
parent f9c873003e
commit e17a4bcc65
10 changed files with 182 additions and 29 deletions

View file

@ -1,6 +1,6 @@
<?
namespace Exceptions;
class InvalidArtworkPageUrlException extends AppException{
class InvalidArtworkPageUrlException extends InvalidUrlException{
protected $message = 'Invalid link to page with artwork.';
}

View file

@ -1,6 +1,6 @@
<?
namespace Exceptions;
class InvalidCopyrightPageUrlException extends AppException{
class InvalidCopyrightPageUrlException extends InvalidUrlException{
protected $message = 'Invalid link to page with copyright details.';
}

View file

@ -0,0 +1,6 @@
<?
namespace Exceptions;
class InvalidGoogleBooksUrlException extends InvalidUrlException{
protected $message = 'Invalid Google Books URL. Google Books URLs begin with “https://www.google.com/books/edition/_/” and must be in single-page view. An example of a valid Google Books URL is “https://www.google.com/books/edition/_/mZpAAAAAYAAJ?gbpv=1&pg=PA70-IA2”.';
}

View file

@ -0,0 +1,6 @@
<?
namespace Exceptions;
class InvalidHathiTrustUrlException extends InvalidUrlException{
protected $message = 'Invalid HathiTrust URL. HathiTrust URLs begin with “https://babel.hathitrust.org/cgi/pt”. An example of a valid HathiTrust URL is “https://babel.hathitrust.org/cgi/pt?id=hvd.32044034383265&seq=13”.';
}

View file

@ -0,0 +1,6 @@
<?
namespace Exceptions;
class InvalidInternetArchiveUrlException extends InvalidUrlException{
protected $message = 'Invalid Internet Archive URL. Internet Archive URLs begin with “https://archive.org/details/” and must be in single-page view. An example of a valid Internet Archive URL is “https://archive.org/details/royalacademypict1902roya/page/n9/mode/1up”.';
}

View file

@ -1,6 +1,6 @@
<?
namespace Exceptions;
class InvalidMuseumUrlException extends AppException{
class InvalidMuseumUrlException extends InvalidUrlException{
protected $message = 'Invalid link to an approved museum page.';
}

View file

@ -1,6 +1,6 @@
<?
namespace Exceptions;
class InvalidPublicationYearPageUrlException extends AppException{
class InvalidPublicationYearPageUrlException extends InvalidUrlException{
protected $message = 'Invalid link to page with year of publication.';
}

View file

@ -0,0 +1,12 @@
<?
namespace Exceptions;
class InvalidUrlException extends AppException{
protected $message = 'Invalid URL.';
public function __construct(?string $url = null){
if($url !== null){
parent::__construct('Invalid URL: “' . $url . '”.');
}
}
}