Commit graph

91 commits

Author SHA1 Message Date
Alex Cabal
fbcafb8f1d Improve type hints 2025-03-27 16:46:05 -05:00
Alex Cabal
f21783d1f8 PHPStan updates 2025-03-27 14:13:00 -05:00
Alex Cabal
dc84ff3fa9 Style tweaks 2025-03-10 14:38:54 -05:00
Mike Colagrosso
af956b2714
Replace EbookUrl with EbookId in Artworks (#482)
* Replace `EbookUrl` with `EbookId` in `Artworks`

* Add a `FullUrl` member to `Ebook`

Add documentation about when to use it versus Url.

The full URL is also being used as an ID in RSS feeds, so use `FullUrl` there.

* Store an `EbookId` in `Artworks`
2025-03-10 14:33:20 -05:00
Alex Cabal
5066252355 Use 'insert ... returning' instead of 'Db::GetLastInsertedId()' 2025-03-10 13:03:31 -05:00
Alex Cabal
7f5ffb4aea Use shorthand assignment for basic getters 2025-02-27 16:03:26 -06:00
Alex Cabal
99b5fd66f2 More type fixes 2025-02-26 15:17:08 -06:00
Alex Cabal
9d1b66d19e Update PHPStan and Safe PHP, and review codebase for further type correctness 2025-02-25 22:41:18 -06:00
Alex Cabal
0c2dce3f63 Handle TIFF files with multiple pages 2025-02-08 12:33:13 -06:00
Alex Cabal
59083baf8c Fix validation of existing artwork name when creating a new artwork 2025-01-24 09:37:13 -06:00
Mike Colagrosso
5b5c75b2c8 Remove apostrophes, don't preserve them
Searching by `UrlName`, now for both `Artwork` and `Artist`, is clearer.
Take care to remove the apostrophes outright, don't replace them with a
space because otherwise the letter after the apostrophe becomes its own
term to match.

Follow up to the fix for #461
2025-01-18 11:03:05 -06:00
Mike Colagrosso
bb7fe5d1ac Search artwork by UrlName
`Artwork::GetAllByFilter()` is already removing diacritics from search
terms, and `UrlName` stores the artist's name with diacritics removed by
calling `Formatter::MakeUrlSafe()`.

Keeping the search by `Name` because `Formatter::MakeUrlSafe()` makes
other changes to the name, too.

Fixes #461
2025-01-18 11:03:05 -06:00
Alex Cabal
e85d833bad When adding an artwork ebook URL, confirm that that ebook exists 2025-01-13 20:30:46 -06:00
Mike Colagrosso
cae8271ecb Set ReviewerUserId only if Status changed
For non-admin reviewers (i.e., without `CanReviewOwnArtwork`), the `PATCH` form
has a hidden element with the artwork's current `Status`. If the reviewer
updates the `EbookUrl` and not `Status`, then don't record the reviewer's
`ReviewerUserId` because they didn't review or change the `Status`.

Side note: Sending the `PATCH` form an invalid `Status` will result in a
validation error, but that validation error was hard to read because it was the
wrong exception type. This commit adds a new `InvalidArtworkStatusException` to
fix that.

Fixes #433
2024-12-13 09:06:57 -06:00
Alex Cabal
05ac7884e9 Convert artwork filters to enums 2024-11-15 23:11:01 -06:00
Alex Cabal
009505d182 Set artwork updated timestamp on save 2024-11-12 11:22:04 -06:00
Alex Cabal
f8d73ebaf1 Fix variable initializaion if museum is not found 2024-11-11 16:48:08 -06:00
Alex Cabal
b7b63a4be5 Refactor functions out of Library 2024-11-10 23:05:31 -06:00
Alex Cabal
acb30b897c Add PropertyFromHttp trait and update codebase to use new pattern 2024-11-10 22:23:43 -06:00
Alex Cabal
be5574eaec Move enums into their own namespace 2024-11-08 16:34:21 -06:00
Mike Colagrosso
0138b19000 Make Artwork robust to EbookNotFoundException
This probably means the Ebook is unreleased, but the artwork page can still show the EbookUrl.

Found this error during testing of the ebook DB here:

https://github.com/standardebooks/web/pull/401#issuecomment-2450588117
2024-11-04 13:16:56 -06:00
Mike Colagrosso
4653b15288 Get ebook from DB for artworks 2024-11-04 13:16:56 -06:00
Alex Cabal
eec79712fc Use a NOW constant instead of new DateTimeImmutable objects, and tweak how some donation drive dates work 2024-10-15 22:21:12 -05:00
Alex Cabal
c51fe594bf Fix artwork validation logic 2024-06-03 13:14:37 -05:00
Alex Cabal
a9eab552ab Flesh out some PHPDocs, and consistently name enums 2024-05-14 15:40:56 -05:00
Alex Cabal
acb6b2949f Use static class names instead of strings when getting objects from the DB 2024-05-13 14:49:28 -05:00
Alex Cabal
110c091a7b Define some constants to make HTTP input code less wordy 2024-05-12 12:29:30 -05:00
Alex Cabal
ee7c8343dd Convert some constants to enums 2024-05-11 21:51:06 -05:00
Alex Cabal
703e1a7a03 Continue improving type hints 2024-05-10 23:38:57 -05:00
Alex Cabal
eb376c87bd Remove error suppression that is no longer necessary 2024-05-10 21:08:32 -05:00
Alex Cabal
c4c8e7353f Enable strict exception type hint checking in PHPStan and add exception type hints 2024-05-10 20:47:36 -05:00
Alex Cabal
41dd9db4aa Change Accessor from class to trait 2024-05-04 13:07:03 -05:00
Alex Cabal
f4613aa9af Fix docblocks 2024-05-01 23:56:52 -05:00
Alex Cabal
50efeb05d1 Style tweaks for getters and add more type hinting 2024-04-30 22:45:20 -05:00
Alex Cabal
7eaa400ae3 Type tweaks for exceptions and some validation 2024-04-25 20:40:49 -05:00
Alex Cabal
5b3f8f7b77 Add support for filling backed enum types in the DB ORM layer, and cleanup some formatting issues 2024-04-25 11:57:02 -05:00
Alex Cabal
40932332cb Remove temporary fixup tag from artworks validation 2024-04-15 12:21:35 -05:00
Alex Cabal
e55fecaaa2 Switch from DateTime to DateTimeImmutable across codebase 2024-04-13 14:05:14 -05:00
Alex Cabal
debd0c31ae Remove 'todo' tag processing 2024-04-05 14:00:15 -05:00
Alex Cabal
e4514e7882 Normalize non-.com Google TLDs in artwork page scans 2024-03-10 14:52:07 -05:00
Alex Cabal
350f65532f Rename PropertiesBase to more accurate Accessor 2024-02-24 13:58:24 -06:00
Alex Cabal
90dcef216f Force single-page view in Hathi Trust URLs 2024-02-12 13:58:48 -06:00
Mike Colagrosso
d6006528f2 Update the ebook URL validation error message 2024-02-11 13:48:54 -06:00
Alex Cabal
1bc946f7b5 Number format image dimensions in artwork listing 2024-02-09 12:17:44 -06:00
Alex Cabal
6da7f948b7 Add temporary support for the 'fixup' tag for cleaning up legacy artwork entries 2024-02-05 10:20:45 -06:00
Mike Colagrosso
f50fab37d3 Minor comment fixes
Fix one typo, remove a docstring meant for an old function
2024-01-30 11:10:05 -06:00
Alex Cabal
801b5f524a Add special 'query-ebook-url' parameter to /artworks to get covers matching exactly the ebook URL 2024-01-26 12:05:34 -06:00
Alex Cabal
cbf87487eb Use ebook URL and not filesystem slug to identify ebooks in artworks 2024-01-23 23:11:30 -06:00
Alex Cabal
770c010025 Add todo comment 2024-01-23 14:53:27 -06:00
Mike Colagrosso
d8360b28ca
Replace PHP filtering with pure SQL (#323)
* Replace PHP filtering with pure SQL
2024-01-21 14:08:46 -06:00