From 98b4de70e793712432a8e43694702f5b13536a56 Mon Sep 17 00:00:00 2001 From: Ludwig Mey Date: Mon, 27 Jul 2026 21:17:29 +1200 Subject: [PATCH] Color-code events by family member name anywhere in title MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- app.py | 29 ++++++++++++++++++++--------- config.py | 10 +++++----- static/css/style.css | 13 +++++++------ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/app.py b/app.py index b5455fc..0d3bc15 100644 --- a/app.py +++ b/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 diff --git a/config.py b/config.py index 630098f..3294c7b 100644 --- a/config.py +++ b/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'} diff --git a/static/css/style.css b/static/css/style.css index c2f0c65..b52e56e 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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; }