Skip to content

Commit 1ee8d3e

Browse files
committed
Show event location
1 parent 7e28546 commit 1ee8d3e

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

src/ics_cal/ics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ def get_events(self, ics_url, calStartDatetime, calEndDatetime, displayTZ, numDa
4646
else:
4747
calDict.setdefault(event["startDatetime"].date(), []).append(event)
4848

49-
return calDict
49+
return sorted(
50+
calDict.items(), key=lambda x: x[0]
51+
)

src/ics_cal/icshelper.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ def retrieve_events(self, ics_url, startDatetime, endDatetime, localTZ):
3939
) and event.begin < arrow.Arrow.fromdatetime(endDatetime):
4040
# extracting and converting events data into a new list
4141
new_event = {"summary": event.name}
42-
new_event["allday"] = event.all_day
4342

43+
if event.location:
44+
new_event["location"] = event.location
45+
46+
new_event["allday"] = event.all_day
4447
if new_event["allday"]:
4548
# All-day events are always midnight UTC to midnight UTC, therefore timezone needs to be set
4649
new_event["startDatetime"] = dt.datetime.fromisoformat(
@@ -61,9 +64,7 @@ def retrieve_events(self, ics_url, startDatetime, endDatetime, localTZ):
6164
new_event["isMultiday"] = (
6265
new_event["endDatetime"] - new_event["startDatetime"]
6366
) > dt.timedelta(days=1)
67+
6468
event_list.append(new_event)
6569

66-
# We need to sort eventList because the event will be sorted in "calendar order" instead of hours order
67-
# TODO: improve because of double cycle for now is not much cost
68-
event_list = sorted(event_list, key=lambda k: k["startDatetime"])
6970
return event_list

src/main.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ def get_image() -> FileResponse:
6666
cfg.DISPLAY_TZ,
6767
cfg.NUM_CAL_DAYS_TO_QUERY,
6868
)
69-
events_sorted = sorted(
70-
events.items(), key=lambda x: x[0]
71-
) # sort by date so we can later take the first N days
7269

7370
end_time = time.time()
7471
logger.info(f"Completed data retrieval in {round(end_time - start_time, 3)} seconds.")
@@ -84,7 +81,7 @@ def get_image() -> FileResponse:
8481
current_weather,
8582
hourly_forecast,
8683
daily_forecast,
87-
events_sorted[: cfg.NUM_DAYS_IN_TEMPLATE],
84+
events[: cfg.NUM_DAYS_IN_TEMPLATE],
8885
tf.name,
8986
)
9087

src/render/css/styles.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ h1, h2, h3, p, span {
2121
text-overflow: ellipsis;
2222
}
2323

24-
.event-time {
25-
color: gray
26-
}
27-
2824
.big-day {
2925
font-family: "TiltWarp-Regular", sans-serif;
3026
font-size: 18rem;
@@ -42,6 +38,10 @@ h1, h2, h3, p, span {
4238
text-overflow: ellipsis;
4339
}
4440

41+
.event-time, .event-location {
42+
color: gray
43+
}
44+
4545
.weather-forecast {
4646
font-family: "Lexend-Regular", sans-serif;
4747
font-size: 2rem;

src/render/render.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ def process_inputs(
107107
+ "</span> "
108108
+ event["summary"]
109109
)
110+
if "location" in event:
111+
cal_events_text += (
112+
'<span class="event-location"> at '
113+
+ event["location"]
114+
+ "</span>"
115+
)
110116
cal_events_text += "</div>\n"
111117
if d == current_date:
112118
cal_events_days.append("Today")

0 commit comments

Comments
 (0)