Skip to content

Commit

Permalink
Merge pull request #813 from plural/fix-fancy-quotes
Browse files Browse the repository at this point in the history
Use stripped title to handle fancy characters.
  • Loading branch information
plural authored Mar 20, 2024
2 parents 1868a98 + 8d8bc30 commit 8939b8f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/AppBundle/Service/CardsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public function get_search_rows(array $conditions, string $sortorder, string $lo
$parameters[$i++] = $arg;
} elseif ($acronym) {
$cond = [];
$cond[] = "(BINARY(c.title) like ?$i)";
$cond[] = "(c.strippedTitle like ?$i)";
$parameters[$i++] = "%$arg%";
$like = implode('% ', str_split($arg));
$cond[] = "(REPLACE(c.title, '-', ' ') like ?$i)";
Expand All @@ -280,7 +280,7 @@ public function get_search_rows(array $conditions, string $sortorder, string $lo
$or[] = "not (" . implode ("or", $cond) . ")";
}
} else {
$or[] = "(c.title " . ($operator == ":" ? "like" : "not like") . " ?$i)";
$or[] = "(c.strippedTitle " . ($operator == ":" ? "like" : "not like") . " ?$i)";
$parameters[$i++] = "%$arg%";
}
}
Expand Down
6 changes: 3 additions & 3 deletions web/js/deck.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ Promise.all([NRDB.data.promise, NRDB.settings.promise]).then(function() {
return _.deburr(cardTitle).toLowerCase().trim();
}
var matchingCards = _.filter(latestCards, function (card) {
return regexp.test(normalizeTitle(card.title));
return regexp.test(normalizeTitle(card.stripped_title));
});
matchingCards.sort((card1, card2) => {
var card1title = normalizeTitle(card1.title);
var card2title = normalizeTitle(card2.title);
var card1title = normalizeTitle(card1.stripped_title);
var card2title = normalizeTitle(card2.stripped_title);
var normalizedQuery = normalizeTitle(q);
if(card1title.startsWith(normalizedQuery) && !card2title.startsWith(normalizedQuery)) {
return -1;
Expand Down
4 changes: 2 additions & 2 deletions web/js/nrdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function check_ampere_agenda_limits() {
for (faction in agendasByFaction) {
if (agendasByFaction[faction] > 2) {
nb_violations++;
}
}
}
});
if(nb_violations > 0) {
Expand Down Expand Up @@ -1119,7 +1119,7 @@ function build_jintekinet(deck) {
return this.nodeType == 3;
})[0].nodeValue[0];
var name = $(line).children('a').eq(0).text();
lines.push(num + " " + name);
lines.push(num + " " + name.replaceAll(/ʼ/g, `'`).replaceAll(/[“”]/g, `"`));
});
return lines;
}
Expand Down
2 changes: 1 addition & 1 deletion web/js/nrdb.smart_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
switch (type) {
case "":
case "_":
add_string_sf('title', operator, values);
add_string_sf('stripped_title', operator, values);
break;
case "x":
add_string_sf('text', operator, values);
Expand Down
2 changes: 1 addition & 1 deletion web/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $(document).on('data.app', function() {
return _.deburr(cardTitle).toLowerCase().trim();
}
var matchingCards = _.filter(latestCards, function (card) {
return regexp.test(normalizeTitle(card.title));
return regexp.test(normalizeTitle(card.stripped_title));
});
matchingCards.sort((card1, card2) => {
var card1title = normalizeTitle(card1.title);
Expand Down
6 changes: 3 additions & 3 deletions web/js/topnav.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ Promise.all([NRDB.data.promise, NRDB.ui.promise]).then(function() {
return _.deburr(cardTitle).toLowerCase().trim();
}
var matchingCards = _.filter(latest_cards, function (card) {
return regexp.test(normalizeTitle(card.title));
return regexp.test(normalizeTitle(card.stripped_title));
});
matchingCards.sort((card1, card2) => {
var card1title = normalizeTitle(card1.title);
var card2title = normalizeTitle(card2.title);
var card1title = normalizeTitle(card1.stripped_title);
var card2title = normalizeTitle(card2.stripped_title);
var normalizedQuery = normalizeTitle(q);
if(card1title.startsWith(normalizedQuery) && !card2title.startsWith(normalizedQuery)) {
return -1;
Expand Down

0 comments on commit 8939b8f

Please sign in to comment.