Skip to content

Commit

Permalink
Show event location (#8)
Browse files Browse the repository at this point in the history
* Larger calendar section
* Show event location
* poetry update
  • Loading branch information
stefanthoss authored Dec 11, 2024
1 parent 18285aa commit 88c9ce2
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 27 deletions.
17 changes: 9 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/ics_cal/ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def get_events(self, ics_url, calStartDatetime, calEndDatetime, displayTZ, numDa
else:
calDict.setdefault(event["startDatetime"].date(), []).append(event)

return calDict
return sorted(calDict.items(), key=lambda x: x[0])
9 changes: 5 additions & 4 deletions src/ics_cal/icshelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ def retrieve_events(self, ics_url, startDatetime, endDatetime, localTZ):
) and event.begin < arrow.Arrow.fromdatetime(endDatetime):
# extracting and converting events data into a new list
new_event = {"summary": event.name}
new_event["allday"] = event.all_day

if event.location:
new_event["location"] = event.location

new_event["allday"] = event.all_day
if new_event["allday"]:
# All-day events are always midnight UTC to midnight UTC, therefore timezone needs to be set
new_event["startDatetime"] = dt.datetime.fromisoformat(
Expand All @@ -61,9 +64,7 @@ def retrieve_events(self, ics_url, startDatetime, endDatetime, localTZ):
new_event["isMultiday"] = (
new_event["endDatetime"] - new_event["startDatetime"]
) > dt.timedelta(days=1)

event_list.append(new_event)

# We need to sort eventList because the event will be sorted in "calendar order" instead of hours order
# TODO: improve because of double cycle for now is not much cost
event_list = sorted(event_list, key=lambda k: k["startDatetime"])
return event_list
5 changes: 1 addition & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ def get_image() -> FileResponse:
cfg.DISPLAY_TZ,
cfg.NUM_CAL_DAYS_TO_QUERY,
)
events_sorted = sorted(
events.items(), key=lambda x: x[0]
) # sort by date so we can later take the first N days

end_time = time.time()
logger.info(f"Completed data retrieval in {round(end_time - start_time, 3)} seconds.")
Expand All @@ -84,7 +81,7 @@ def get_image() -> FileResponse:
current_weather,
hourly_forecast,
daily_forecast,
events_sorted[: cfg.NUM_DAYS_IN_TEMPLATE],
events[: cfg.NUM_DAYS_IN_TEMPLATE],
tf.name,
)

Expand Down
15 changes: 10 additions & 5 deletions src/render/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
src: url('../font/TiltWarp-Regular.ttf');
}

h1, h2, p, span, .h1, .h2, .p, .span {
h1, h2, h3, p, span {
font-family: "Lexend-Regular", sans-serif;
}

.list-unstyled {
text-overflow: ellipsis;
}

.event-time {
color: gray
}

.big-day {
font-family: "TiltWarp-Regular", sans-serif;
font-size: 18rem;
Expand All @@ -42,6 +38,15 @@ h1, h2, p, span, .h1, .h2, .p, .span {
text-overflow: ellipsis;
}

.event-time, .event-location {
color: gray
}

.weather-forecast {
font-family: "Lexend-Regular", sans-serif;
font-size: 2rem;
}

.info-bar {
font-family: "Lexend-Light", sans-serif;
font-size: 1.5rem;
Expand Down
13 changes: 8 additions & 5 deletions src/render/dashboard_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="container">
<div class="row justify-content-center">
<!-- Weather -->
<div class="col-md-6">
<div class="col-md-5">
<div class="row">
<div class="col-md-12">
<div class="row">
Expand Down Expand Up @@ -55,7 +55,8 @@ <h2>{current_weather_text} | {current_weather_temp}°</h2>
</div>
<div class="row align-items-start ">
<div class="col-md-12 text-center">
<h3>Today<br />{today_weather_pop}% | {today_weather_min}-{today_weather_max}°</h3>
<h3>Today</h3>
<div class="weather-forecast">{today_weather_pop}% | {today_weather_min}-{today_weather_max}°</div>
</div>
</div>
</div>
Expand All @@ -67,7 +68,8 @@ <h3>Today<br />{today_weather_pop}% | {today_weather_min}-{today_weather_max}°<
</div>
<div class="row align-items-start ">
<div class="col-md-12 text-center">
<h3>Tomorrow<br />{tomorrow_weather_pop}% | {tomorrow_weather_min}-{tomorrow_weather_max}°</h3>
<h3>Tomorrow</h3>
<div class="weather-forecast">{tomorrow_weather_pop}% | {tomorrow_weather_min}-{tomorrow_weather_max}°</div>
</div>
</div>
</div>
Expand All @@ -79,7 +81,8 @@ <h3>Tomorrow<br />{tomorrow_weather_pop}% | {tomorrow_weather_min}-{tomorrow_wea
</div>
<div class="row align-items-start ">
<div class="col-md-12 text-center">
<h3>{dayaftertomorrow}<br />{dayafter_weather_pop}% | {dayafter_weather_min}-{dayafter_weather_max}°</h3>
<h3>{dayaftertomorrow}</h3>
<div class="weather-forecast">{dayafter_weather_pop}% | {dayafter_weather_min}-{dayafter_weather_max}°</div>
</div>
</div>
</div>
Expand All @@ -89,7 +92,7 @@ <h3>{dayaftertomorrow}<br />{dayafter_weather_pop}% | {dayafter_weather_min}-{da
</div>
</div>
<!-- Calendar -->
<div class="col-md-6">
<div class="col-md-7">
<div class="row align-items-start ">
<div class="col-md-12 text-right info-bar" style="height: 25px">
Last Updated: {update_time}
Expand Down
4 changes: 4 additions & 0 deletions src/render/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def process_inputs(
+ "</span> "
+ event["summary"]
)
if "location" in event:
cal_events_text += (
'<span class="event-location"> at ' + event["location"] + "</span>"
)
cal_events_text += "</div>\n"
if d == current_date:
cal_events_days.append("Today")
Expand Down

0 comments on commit 88c9ce2

Please sign in to comment.