Color-code events by family member name anywhere in title
- Fuzzy name matching: if a member's name appears anywhere in the event title (word boundary, case-insensitive), it gets their color — no [prefix] required. e.g. "Daniel's Week" → green, "Jason Karate" → blue - More vibrant card color palette (deeper pastels, stronger border accent) - Bolder event title text and slightly thicker left border for clarity Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
29
app.py
29
app.py
@@ -99,17 +99,28 @@ MEMBER_PREFIX_RE = re.compile(r'^\s*\[([^\]]+)\]\s*(.*)')
|
||||
|
||||
|
||||
def parse_member_and_title(summary, family_members):
|
||||
"""Split a "[Alias] Title" event summary into (member_dict, clean_title)."""
|
||||
match = MEMBER_PREFIX_RE.match(summary)
|
||||
if not match:
|
||||
return None, summary
|
||||
"""Identify a family member from an event title.
|
||||
|
||||
alias = match.group(1).strip().lower()
|
||||
title = match.group(2).strip() or summary
|
||||
Checks in order:
|
||||
1. [Alias] prefix (strips the prefix from the displayed title)
|
||||
2. Alias word appearing anywhere in the title (title kept as-is)
|
||||
"""
|
||||
match = MEMBER_PREFIX_RE.match(summary)
|
||||
if match:
|
||||
alias = match.group(1).strip().lower()
|
||||
title = match.group(2).strip() or summary
|
||||
for member in family_members:
|
||||
if alias in member['aliases']:
|
||||
return member, title
|
||||
return None, title
|
||||
|
||||
summary_lower = summary.lower()
|
||||
for member in family_members:
|
||||
if alias in member['aliases']:
|
||||
return member, title
|
||||
return None, title
|
||||
for alias in member['aliases']:
|
||||
if re.search(r'\b' + re.escape(alias) + r'\b', summary_lower):
|
||||
return member, summary
|
||||
|
||||
return None, summary
|
||||
|
||||
|
||||
NUM_DAYS = 5
|
||||
|
||||
Reference in New Issue
Block a user