Skip to content

Commit

Permalink
Merge pull request #13443 from PennyDreadfulMTG/v1v1
Browse files Browse the repository at this point in the history
Deck name sanitization and emoji improvements
  • Loading branch information
mergify[bot] authored Dec 21, 2024
2 parents fdd1637 + 06fba50 commit 6043ecb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions decksite/deck_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ def normalize_version(name: str) -> str:
if re.search(r'\d.*[a-uw-z,-].*\d', name, flags=re.IGNORECASE):
return name
name = normalize_parenthetical_versions(name)
# Convert trailing sequences of digits and spaces into dotted versions
trailing_nums = re.search(r'(\d+(?:\s+\d+)+)$', name)
if trailing_nums:
dotted_nums = re.sub(r'\s+', '.', trailing_nums.group(1))
name = name[:trailing_nums.start(1)] + dotted_nums
patterns = [
r'(\W?)[\[({]?(?:v|ver|version|rev|mk) ?(\d[\.\d]*)(?:[])}]|\b)', # Explicitly marked as a version
r'(\s)[\[({]?(\d[\.\d]*)[])}]?$', # Number at end of name
Expand Down
3 changes: 2 additions & 1 deletion decksite/deck_name_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
('depravity 500', 'Depravity 500', [], None, 6),
('catch 22', 'Catch 22', [], None, 22),
('the 0.02 tix printing of kaya was finally available', 'The 0.02 Tix Printing of Kaya Was Finally Available', [], None, 23),
('crackling drake beatdown 1.3 3', 'Crackling Drake Beatdown v1.3 v3', [], None, 23),
('crackling drake beatdown 1.3 3', 'Crackling Drake Beatdown v1.3.3', [], None, 23),
('70 rev 5 2.0', '70 Rev 5 2.0', [], None, 23),
('significantly worse 3 drops than season 19', 'Significantly Worse 3 Drops Than Season 19', [], None, 23),
('dr who: season 3, episode 10', 'Dr Who: Season 3, Episode 10', [], None, 23),
Expand Down Expand Up @@ -309,6 +309,7 @@
('Kiki-Titi', 'Kiki-Titi', ['U', 'R'], 'Izzet Twin', 32),
('Greasefag', 'Orzhov Greasefang', ['W', 'B'], 'Greasefang', 33),
('🏴‍☠️', '🏴‍☠️', ['U', 'R'], 'Pirates', 33),
('S36 Human v1 1', 'Human v1.1', ['W'], 'Mono White Humans', 36),
]

def test_replace_space_alternatives() -> None:
Expand Down
2 changes: 1 addition & 1 deletion decksite/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,4 @@ def set_legal_icons(o: Card | Deck) -> None:
def season_icon_link(code: str) -> str:
color = 'rare' if code in seasons.current_season_name() else 'common'
n = seasons.SEASONS.index(code.upper()) + 1
return f'<a href="/seasons/{n}/"><i class="ss ss-{code.lower()} ss-{color} ss-grad">S{n}</i></a>'
return f'<a href="/seasons/{n}/"><i class="ss ss-{code.lower()} ss-{color} ss-grad"><span class="ss-num">{n}</span></i></a>'
2 changes: 1 addition & 1 deletion decksite/templates/legal.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<p><span title="{{#public}}{{name}}{{/public}}{{^public}}This deck{{/public}}</span> is {{^pd_legal}}<b>not</b> {{/pd_legal}} currently Penny Dreadful legal">{{#pd_legal}}✅{{/pd_legal}}{{^pd_legal}}🚫 Not{{/pd_legal}} Legal</span></p>
{{#has_legal_format}}
{{#legal_icons}}<p>{{{legal_icons}}}</p>{{/legal_icons}}
{{#legal_icons}}<p class="ss-grid">{{{legal_icons}}}</p>{{/legal_icons}}
<div class="other-legal-formats">
{{#non_pd_legal_formats}}
<div class="legal-format">{{.}}</div>
Expand Down
13 changes: 12 additions & 1 deletion shared_web/static/css/pd.css

Large diffs are not rendered by default.

0 comments on commit 6043ecb

Please sign in to comment.