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:
19
app.py
19
app.py
@@ -99,11 +99,14 @@ 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.
|
||||
|
||||
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:
|
||||
@@ -111,6 +114,14 @@ def parse_member_and_title(summary, family_members):
|
||||
return member, title
|
||||
return None, title
|
||||
|
||||
summary_lower = summary.lower()
|
||||
for member in family_members:
|
||||
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
|
||||
|
||||
|
||||
10
config.py
10
config.py
@@ -35,9 +35,9 @@ class Config:
|
||||
# Event titles prefixed with "[Alias]" (e.g. "[Daniel] Football Practice")
|
||||
# are tagged with that member's name/color and the prefix is stripped for display.
|
||||
FAMILY_MEMBERS = [
|
||||
{'key': 'dad', 'name': 'Ludwig', 'aliases': ['ludwig', 'dad'], 'color': '#4A90D9', 'bg': '#DCEAFB'},
|
||||
{'key': 'mom', 'name': 'Michelle', 'aliases': ['michelle', 'mom'], 'color': '#D9669B', 'bg': '#FBDDEB'},
|
||||
{'key': 'jason', 'name': 'Jason', 'aliases': ['jason'], 'color': '#5FA85B', 'bg': '#E1F2DD'},
|
||||
{'key': 'daniel', 'name': 'Daniel', 'aliases': ['daniel'], 'color': '#D9A53B', 'bg': '#FBEFD3'},
|
||||
{'key': 'dad', 'name': 'Ludwig', 'aliases': ['ludwig', 'dad'], 'color': '#1A6BBF', 'bg': '#C2DEFA'},
|
||||
{'key': 'mom', 'name': 'Michelle', 'aliases': ['michelle', 'mom'], 'color': '#BF1A6B', 'bg': '#FAC2DC'},
|
||||
{'key': 'jason', 'name': 'Jason', 'aliases': ['jason'], 'color': '#1A8C1E', 'bg': '#BFEDCA'},
|
||||
{'key': 'daniel', 'name': 'Daniel', 'aliases': ['daniel'], 'color': '#BF7A00', 'bg': '#FAE4A0'},
|
||||
]
|
||||
DEFAULT_MEMBER = {'key': 'family', 'name': 'Family', 'color': '#8C8C8C', 'bg': '#E9E9E9'}
|
||||
DEFAULT_MEMBER = {'key': 'family', 'name': 'Family', 'color': '#666666', 'bg': '#E0E0E0'}
|
||||
|
||||
@@ -119,27 +119,28 @@ html, body {
|
||||
.event-card {
|
||||
border-radius: 8px;
|
||||
padding: 6px 8px;
|
||||
border-left: 4px solid transparent;
|
||||
border-left: 5px solid transparent;
|
||||
font-size: 11.5px;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.event-time {
|
||||
font-weight: 700;
|
||||
color: rgba(0, 0, 0, 0.55);
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
font-size: 10.5px;
|
||||
}
|
||||
|
||||
.event-title {
|
||||
font-weight: 600;
|
||||
color: #2B2B33;
|
||||
font-weight: 700;
|
||||
color: #1A1A2A;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.event-member {
|
||||
font-size: 10px;
|
||||
color: rgba(0, 0, 0, 0.5);
|
||||
margin-top: 1px;
|
||||
font-weight: 600;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user