diff --git a/README.md b/README.md index 6ac09274..0593a6ce 100644 --- a/README.md +++ b/README.md @@ -136,16 +136,6 @@ Before submitting design contributions, please discuss them with the Standard Eb - Converting some constants to enums, like `SORT_*` or `SOURCE_*`. -### Artwork database - -- Tags should be searched as whole words. For example a search for `male` should not return items tagged as `female`. - -- Include in-use ebook slug as a search parameter when searching for artwork by keyword. - -- Artwork searching/filtering should be done in pure SQL, no after-SQL filtering in PHP. - -- Allow listing artwork by artist by visiting `/artworks/`, and link instances of artist name to that URL. - ## PHP code style - Indent with tabs. diff --git a/config/apache/standardebooks.org.conf b/config/apache/standardebooks.org.conf index 24fa6372..9b5fc08e 100644 --- a/config/apache/standardebooks.org.conf +++ b/config/apache/standardebooks.org.conf @@ -296,6 +296,8 @@ Define webroot /standardebooks.org/web RewriteRule ^/bulk-downloads/([^/\.]+)$ /bulk-downloads/collection.php?class=$1 # Rewrite rules for cover art + RewriteRule ^/artworks/([^\./]+?)$ /artworks/artist.php?artist-url-name=$1 [L] + RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/" RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L] diff --git a/config/apache/standardebooks.test.conf b/config/apache/standardebooks.test.conf index 0b759d5c..b154029e 100644 --- a/config/apache/standardebooks.test.conf +++ b/config/apache/standardebooks.test.conf @@ -278,6 +278,8 @@ Define webroot /standardebooks.org/web RewriteRule ^/bulk-downloads/([^/\.]+)$ /bulk-downloads/collection.php?class=$1 # Rewrite rules for cover art + RewriteRule ^/artworks/([^\./]+?)$ /artworks/artist.php?artist-url-name=$1 [L] + RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/" RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L] diff --git a/config/sql/se/Artworks.sql b/config/sql/se/Artworks.sql index efd2d04d..0f5d5453 100644 --- a/config/sql/se/Artworks.sql +++ b/config/sql/se/Artworks.sql @@ -22,5 +22,6 @@ CREATE TABLE `Artworks` ( `Notes` TEXT NULL DEFAULT NULL PRIMARY KEY (`ArtworkId`), KEY `index1` (`Status`), - KEY `index2` (`UrlName`) + KEY `index2` (`UrlName`), + KEY `index3` (`ArtistId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/lib/Artist.php b/lib/Artist.php index 850423e7..5fea165f 100644 --- a/lib/Artist.php +++ b/lib/Artist.php @@ -4,6 +4,7 @@ use function Safe\date; /** * @property string $UrlName + * @property string $Url * @property array $AlternateNames * @property array $_AlternateNames */ @@ -14,6 +15,7 @@ class Artist extends PropertiesBase{ public ?datetime $Created = null; public ?datetime $Updated = null; protected ?string $_UrlName = null; + protected ?string $_Url = null; protected $_AlternateNames; // ******* @@ -32,6 +34,14 @@ class Artist extends PropertiesBase{ return $this->_UrlName; } + protected function GetUrl(): string{ + if($this->_Url === null){ + $this->_Url = '/artworks/' . $this->UrlName; + } + + return $this->_Url; + } + /** * @return array */ diff --git a/lib/Library.php b/lib/Library.php index 2f9c0217..cb49b893 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -247,6 +247,20 @@ class Library{ return $artworks; } + /** + * @return array + */ + public static function GetArtworkByArtist(string $artistUrlName): array{ + $artworks = Db::Query(' + SELECT art.* + from Artworks art + inner join Artists a using (ArtistId) + where a.UrlName = ? + order by art.Created desc', [$artistUrlName], 'Artwork'); + + return $artworks; + } + /** * @return array */ diff --git a/www/artworks/artist.php b/www/artworks/artist.php new file mode 100644 index 00000000..4d2a54f3 --- /dev/null +++ b/www/artworks/artist.php @@ -0,0 +1,32 @@ +Artist->Name; +} +catch(Exceptions\ArtistNotFoundException){ + Template::Emit404(); +} +?> 'Artwork by ' . $artistName, 'artwork' => true]) ?> +
+
+

Artwork by

+ + + + $artworks]) ?> +
+
+ diff --git a/www/artworks/get.php b/www/artworks/get.php index aa75c9ec..6af2ec1e 100644 --- a/www/artworks/get.php +++ b/www/artworks/get.php @@ -75,7 +75,7 @@ catch(Exceptions\InvalidPermissionsException){ Artist - Artist->Name) ?>Artist->AlternateNames) > 0){ ?> (A.K.A. , ', array_map('Formatter::EscapeHtml', $artwork->Artist->AlternateNames)) ?>)Artist->DeathYear !== null){ ?> (d. Artist->DeathYear ?>) (#Artist->ArtistId ?>) + Artist->Name) ?>Artist->AlternateNames) > 0){ ?> (A.K.A. , ', array_map('Formatter::EscapeHtml', $artwork->Artist->AlternateNames)) ?>)Artist->DeathYear !== null){ ?> (d. Artist->DeathYear ?>) (#Artist->ArtistId ?>)