mirror of
https://github.com/standardebooks/web.git
synced 2025-07-20 05:14:48 -04:00
Add a special case for hyphens: Replace with space
See #484 for details. By adding a special case for hyphens, users can search for these terms: `beta` to match `Alpha-Beta` `queen` to match `Haycraft-Queen` These searches also work as expected: `Alpha-Beta` `Alpha` `Haycraft-Queen` `Haycraft` I don't think these queries should work, and they do not: `AlphaBeta` `HaycraftQueen` This commit changes `IndexableText`, `IndexableAuthors`, and `IndexableCollections`, so existing DBs need an update. This will update all published books: ``` cd /standardebooks.org/ebooks for BOOK in $(find /standardebooks.org/ebooks -maxdepth 1 -type d) do tsp nice /standardebooks.org/web/scripts/deploy-ebook-to-www --verbose --no-build --no-images --no-recompose --no-epubcheck --no-feeds --no-bulk-downloads "$BOOK" done ``` And this PHP code will update placeholders: ``` <? require_once('/standardebooks.org/web/lib/Core.php'); $ebooks = Ebook::GetAll(); foreach($ebooks as $ebook){ if($ebook->IsPlaceholder()){ print('Saving ' . $ebook->Identifier . "\n"); // Need to force `Ebook::GetAllContributors()` to be called before `Ebook::Save()`. Otherwise, authors and translators will be deleted. $ebook->Authors; $ebook->Save(); } } ```
This commit is contained in:
parent
8a4da08a66
commit
9202717a6b
1 changed files with 5 additions and 0 deletions
|
@ -1706,6 +1706,7 @@ final class Ebook{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->IndexableText = str_replace('-', ' ', $this->IndexableText);
|
||||||
$this->IndexableText = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableText);
|
$this->IndexableText = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableText);
|
||||||
|
|
||||||
if($this->IndexableText == ''){
|
if($this->IndexableText == ''){
|
||||||
|
@ -1719,6 +1720,7 @@ final class Ebook{
|
||||||
$this->IndexableAuthors .= ' ' . $author->Name;
|
$this->IndexableAuthors .= ' ' . $author->Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->IndexableAuthors = str_replace('-', ' ', $this->IndexableAuthors);
|
||||||
$this->IndexableAuthors = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableAuthors);
|
$this->IndexableAuthors = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableAuthors);
|
||||||
|
|
||||||
// Initialize `IndexableCollections`.
|
// Initialize `IndexableCollections`.
|
||||||
|
@ -1728,6 +1730,7 @@ final class Ebook{
|
||||||
$this->IndexableCollections .= ' ' . $collectionMembership->Collection->Name;
|
$this->IndexableCollections .= ' ' . $collectionMembership->Collection->Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->IndexableCollections = str_replace('-', ' ', $this->IndexableCollections);
|
||||||
$this->IndexableCollections = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableCollections);
|
$this->IndexableCollections = Formatter::RemoveDiacriticsAndNonalphanumerics($this->IndexableCollections);
|
||||||
|
|
||||||
if($this->IndexableCollections == ''){
|
if($this->IndexableCollections == ''){
|
||||||
|
@ -2332,6 +2335,8 @@ final class Ebook{
|
||||||
}
|
}
|
||||||
|
|
||||||
if($query !== null && $query != ''){
|
if($query !== null && $query != ''){
|
||||||
|
$query = str_replace('-', ' ', $query);
|
||||||
|
|
||||||
// Preserve quotes in the query so the user can enter, e.g., "war and peace" for an exact match.
|
// Preserve quotes in the query so the user can enter, e.g., "war and peace" for an exact match.
|
||||||
$query = trim(preg_replace('|[^a-zA-Z0-9" ]|ius', '', Formatter::RemoveDiacritics($query)));
|
$query = trim(preg_replace('|[^a-zA-Z0-9" ]|ius', '', Formatter::RemoveDiacritics($query)));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue