Move emojis into one place

Closes: #113
This commit is contained in:
Edward Betts 2024-01-16 15:32:39 +00:00
parent 8047cb67fe
commit 4638069e51
9 changed files with 41 additions and 11 deletions

View file

@ -13,8 +13,7 @@ def get_events(filepath: str) -> list[Event]:
date=item["from"],
end_date=item["to"],
name="accommodation",
title="🧳"
+ (
title=(
f'{item["location"]} Airbnb'
if item.get("operator") == "airbnb"
else item["name"]

View file

@ -42,7 +42,7 @@ def get_birthdays(from_date: date, filepath: str) -> list[Event]:
Event(
date=bday.replace(year=bday.year + offset),
name="birthday",
title=f'🎈 {entity["label"]} ({display_age})',
title=f'{entity["label"]} ({display_age})',
)
)

View file

@ -36,7 +36,7 @@ def build_events(events: list[Event]) -> list[dict[str, typing.Any]]:
assert e.title and e.end_date
item = {
"allDay": True,
"title": e.display_title,
"title": e.title_with_emoji,
"start": e.as_date.isoformat(),
"end": (e.end_as_date + one_day).isoformat(),
"url": e.url,
@ -66,7 +66,7 @@ def build_events(events: list[Event]) -> list[dict[str, typing.Any]]:
end = (e.end_as_date if e.end_date else e.as_date) + one_day
item = {
"allDay": not e.has_time,
"title": e.display_title,
"title": e.title_with_emoji,
"start": e.date.isoformat(),
"end": end.isoformat(),
}

View file

@ -51,7 +51,7 @@ def get_list(filepath: str) -> list[Event]:
name="conference",
date=conf.start,
end_date=conf.end,
title=f"🎤 {conf.display_name}",
title=conf.display_name,
url=conf.url,
going=conf.going,
)

View file

@ -363,7 +363,7 @@ async def get_data(
if not dt:
continue
rocket_name = f'🚀{launch["rocket"]}: {launch["mission_name"] or "[no mission]"}'
rocket_name = f'{launch["rocket"]}: {launch["mission_name"] or "[no mission]"}'
e = Event(name="rocket", date=dt, title=rocket_name)
events.append(e)

View file

@ -21,7 +21,7 @@ def get_events(data_dir: str) -> list[Event]:
date=start,
end_date=end,
name="meetup",
title="👥" + item_event["title"],
title=item_event["title"],
url=item_event["eventUrl"],
)
events.append(e)

View file

@ -93,6 +93,23 @@ class Holiday:
date: datetime.date
emojis = {
"market": "🧺",
"us_presidential_election": "🗳️🇺🇸",
"bus_route_closure": "🚌❌",
"meetup": "👥",
"dinner": "🍷",
"party": "🍷",
"ba_voucher": "✈️",
"accommodation": "🏨", # alternative: 🧳
"flight": "✈️",
"conference": "🎤",
"rocket": "🚀",
"birthday": "🎈",
"waste_schedule": "🗑️",
}
@dataclass
class Event:
"""Event."""
@ -182,3 +199,17 @@ class Event:
def display_title(self) -> str:
"""Name for display."""
return self.title or self.name
@property
def emoji(self) -> str | None:
"""Emoji."""
return emojis.get(self.name)
@property
def title_with_emoji(self) -> str | None:
"""Title with optional emoji at the start."""
title = self.title or self.name
if title is None:
return None
emoji = self.emoji
return f"{emoji} {title}" if emoji else title

View file

@ -95,7 +95,7 @@ def parse(root: lxml.html.HtmlElement) -> list[Event]:
Event(
name="waste_schedule",
date=uk_time(d, time(6, 30)),
title="🗑️ Backwell: " + ", ".join(services),
title="Backwell: " + ", ".join(services),
)
for d, services in by_date.items()
]
@ -208,6 +208,6 @@ async def get_bristol_gov_uk(
by_date[d].append(service)
return [
Event(name="waste_schedule", date=d, title="🗑️ Bristol: " + ", ".join(services))
Event(name="waste_schedule", date=d, title="Bristol: " + ", ".join(services))
for d, services in by_date.items()
]

View file

@ -184,7 +184,7 @@
<div class="col-md-7 text-start">
{% if event.url %}<a href="{{ event.url }}">{% endif %}
{{ event_labels.get(event.name) or event.name }}
{%- if event.title -%}: {{ event.title }}{% endif %}
{%- if event.title -%}: {{ event.title_with_emoji }}{% endif %}
{% if event.url %}</a>{% endif %}
</div>
<div class="col-md-1{{ cell_bg }}">