Commit graph

551 commits

Author SHA1 Message Date
Mike Colagrosso
8a4da08a66 Remove non-alphanumerics (except quotes) from search query
That is, don't replace non-alphanumerics with a space. This matches the
behavior of Formatter::RemoveDiacriticsAndNonalphanumerics(), which
would be used here except that function would also remove quotes.  We
actually discussed not introducing spaces previously, but I made a
mistake and didn't apply the same change to the user's search query:

https://github.com/standardebooks/web/pull/470#discussion_r1929591492

This change fixes queries with compound words like:

`Haycraft-Queen`

and also fixes queries for authors with apostrophes:

`O'Neill`

No changes to existing DBs are necessary because they already have terms
like `haycraftqueen` and `oneill` stored in `IndexableCollections` and
`IndexableAuthors`.
2025-03-25 13:16:25 -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
34fd71e55a Tweak wording on delete artist page and add some more breadcrumbs 2025-03-07 10:37:56 -06:00
Alex Cabal
e76be32463 Add comment 2025-03-07 09:55:54 -06:00
Mike Colagrosso
a91509726c
Add admin tool to handle duplicate artist names (#480) 2025-03-06 14:28:26 -06:00
Alex Cabal
124e8343fc Completely type hint template functions and switch to named arguments 2025-03-04 20:32:20 -06:00
Alex Cabal
a019d5e87c Enable some additional PHPStan rules and fix some type issues 2025-03-01 13:39:57 -06:00
Alex Cabal
c9e5026cf4 Add logic for accepting payments from soft credits marked as 'anonymous' 2025-02-28 11:43:39 -06:00
Alex Cabal
7b278da43a Fix broken getter 2025-02-28 11:20:28 -06:00
Alex Cabal
11e5770413 Update Composer dependencies, clean up PHPStan config file, and remove Constants.php from Composer in favor of PHPStan configuration 2025-02-28 10:52:16 -06: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
a5a19f947f More type fixes 2025-02-26 14:32:04 -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
e2e14a3551 Remove DbConnection class in favor of fully-static and typed Db class 2025-02-25 16:47:25 -06:00
Alex Cabal
0a684facee Simplify exceptions in HttpInput 2025-02-24 14:46:42 -06:00
Alex Cabal
3ff13397f0 Handle case when a fetchin commits from a GitHub repo that has no commits 2025-02-24 11:56:36 -06:00
Alex Cabal
831c1531d8 Minor refactor 2025-02-15 11:44:18 -06:00
Alex Cabal
388dbab1f1 Change indexable properties to private class properties instead of public getters/setters 2025-02-13 22:52:12 -06:00
Mike Colagrosso
d05f0ea3c7 Remove blank line 2025-02-13 13:48:39 -06:00
Mike Colagrosso
804b786065 Keep IndexableText null if it's an empty string
The `Validate()` method is correctly setting it to null, but then the
`UPDATE` SQL statement is triggering another call to
`GetIndexableText()`. Without this change, empty strings are being
written to the `IndexableText` column.
2025-02-13 13:48:39 -06:00
Mike Colagrosso
55e0428006 Add a Default EbookSortType
This allows the user to run a keyword search and then change the sort
order. `Default` is interpreted as `Relevance` if a query is present,
`Newest` if not.
2025-02-13 13:48:39 -06:00
Mike Colagrosso
a3ce3f1ec1 Make IndexableText optional
Placeholders do not have FullTitle, AlternateTitle, Tags, LocSubjects,
or TocEntries.
2025-02-13 13:48:39 -06:00
Mike Colagrosso
1629d3a1a1 Remove RelevanceScore from the SELECT fields
Having it in the SELECT fields was causing warnings like this:

```
NOTICE: PHP message: PHP Deprecated:  Creation of dynamic property Ebook::$RelevanceScore is deprecated in /standardebooks.org/web/lib/Traits/Accessor.php
```
2025-02-13 13:48:39 -06:00
Mike Colagrosso
61bbf8f071 Add idxSearchCombined to match multiple fields
The data in these fields are separate:

* `IndexableText`
* `Title`
* `IndexableAuthors`
* `IndexableCollections`

There are also on indices on each of these fields so that they can have
separate weight in the relevance scoring.
2025-02-13 13:48:39 -06:00
Mike Colagrosso
fd3abb568c Remove title, authors, and collections from IndexableText
Those properties are indexed separately. `FullTitle` and
`AlternateTitle` are still indexed here.
2025-02-13 13:48:39 -06:00
Mike Colagrosso
660f8b5e3e RelevanceScore not relevance_score 2025-02-13 13:48:39 -06:00
Mike Colagrosso
0c87f1f262 Remove unnecessary check ?? '' from non-null 2025-02-13 13:48:39 -06:00
Mike Colagrosso
fce4fbc601 Delete non-alphanumerics from query, don't replace with space 2025-02-13 13:48:39 -06:00
Mike Colagrosso
1a71913794 Add a Relevance sort order and improve search
Here's what's in `IndexableText` right now:

1. Title
2. Collections
3. Authors
4. Tags
5. LocSubjects
6. TocEntries

Here is the proposed new ranking:

```
10 * Title +
8 * Authors +
3 * Collections +
IndexableText
```

New indices for existing DBs:

```
ALTER TABLE `Ebooks` ADD COLUMN `IndexableAuthors` text NOT NULL;
ALTER TABLE `Ebooks` ADD COLUMN `IndexableCollections` text NULL;
ALTER TABLE `Ebooks` ADD FULLTEXT `indexSearchTitle` (`Title`);
ALTER TABLE `Ebooks` ADD FULLTEXT `idxSearchAuthors` (`IndexableAuthors`);
ALTER TABLE `Ebooks` ADD FULLTEXT `idxSearchCollections` (`IndexableCollections`);
```
2025-02-13 13:48:39 -06:00
Alex Cabal
0c2dce3f63 Handle TIFF files with multiple pages 2025-02-08 12:33:13 -06:00
Alex Cabal
6261eee67f Correctly pull reviewer of active projects 2025-01-30 12:44:57 -06:00
Alex Cabal
d942f4642b In projects, update discussion URLs that have discussion too recent to have a full timestamp 2025-01-29 18:46:02 -06:00
Alex Cabal
0b461d7ede Refactor some function in Project 2025-01-28 10:29:08 -06:00
Alex Cabal
6378d687d8 Add 'awaiting review' and 'reviewed' project statuses that update from GitHub; allow project owners to update their project statuses 2025-01-27 15:52:21 -06:00
Alex Cabal
221daaacac Increase wait time when fetching project updated timestamps, and improve error messages 2025-01-25 11:29:18 -06:00
Alex Cabal
59083baf8c Fix validation of existing artwork name when creating a new artwork 2025-01-24 09:37:13 -06:00
Alex Cabal
bddbfe3cfa Don't list authors more than once in sitemap 2025-01-22 09:54:05 -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
db8d422133 Simplify validation logic 2025-01-15 16:16:45 -06:00
Mike Colagrosso
38f4e34a11 Match Contributor UrlName to Identifier
Fixes #459
2025-01-15 15:47:04 -06:00
Alex Cabal
e85d833bad When adding an artwork ebook URL, confirm that that ebook exists 2025-01-13 20:30:46 -06:00
Alex Cabal
284898a805 Replace ' with ’ in contributor names 2025-01-10 12:07:59 -06:00
Alex Cabal
c36d1ac3d3 Rename exception for consistency 2025-01-09 14:08:54 -06:00
Alex Cabal
94d62fdcdf Fix exception for duplicate ebook placeholder on save 2025-01-09 14:07:40 -06:00
Alex Cabal
d9fe3e9303 Fix error handling for duplicate ebook placeholders 2025-01-09 14:00:50 -06:00
Alex Cabal
affe29e83c Fix type issue 2025-01-08 19:33:43 -06:00