Validate and normalize museum URLs when submitting artwork

This commit is contained in:
Alex Cabal 2024-01-12 14:20:54 -06:00
parent 9c27d80dd9
commit 16df5b29fe
9 changed files with 554 additions and 41 deletions

View file

@ -1,6 +0,0 @@
<?
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

@ -1,6 +0,0 @@
<?
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

@ -1,6 +0,0 @@
<?
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

@ -2,5 +2,7 @@
namespace Exceptions;
class InvalidMuseumUrlException extends InvalidUrlException{
protected $message = 'Invalid link to an approved museum page.';
public function __construct(string $url, string $exampleUrl){
$this->message = 'Invalid museum URL: <' . $url . '>. Expected a URL like: <'. $exampleUrl . '>.';
}
}

View file

@ -0,0 +1,8 @@
<?
namespace Exceptions;
class InvalidPageScanUrlException extends InvalidUrlException{
public function __construct(string $url, string $exampleUrl){
$this->message = 'Invalid page scan URL: <' . $url . '>. Expected a URL like: <'. $exampleUrl . '>.';
}
}

View file

@ -6,7 +6,7 @@ class InvalidUrlException extends AppException{
public function __construct(?string $url = null){
if($url !== null){
parent::__construct('Invalid URL: “' . $url . '”.');
parent::__construct('Invalid URL: <' . $url . '>.');
}
}
}