From 99d62eaf48bd65338840d6da91607d587c7cf650 Mon Sep 17 00:00:00 2001 From: James Yoo Date: Sat, 14 Jun 2025 17:12:18 -0700 Subject: [PATCH 1/4] Start implementing a "total mileage" column for the schedule --- _bin/mkical.py | 2 ++ _includes/schedule_table.html | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/_bin/mkical.py b/_bin/mkical.py index de9ec07..bb16551 100755 --- a/_bin/mkical.py +++ b/_bin/mkical.py @@ -59,6 +59,8 @@ def dtstart(date, time): for run in sched: date = datetime.strptime(run['date'], '%Y-%m-%d') phases = run['plan'] + # Maybe something here? + # total_dist = 0 if 'cancelled' in run.keys(): continue for i in range(len(phases)): diff --git a/_includes/schedule_table.html b/_includes/schedule_table.html index 72a653a..9eb3d64 100644 --- a/_includes/schedule_table.html +++ b/_includes/schedule_table.html @@ -5,7 +5,8 @@ Date Time - Route (miles) + Routes (miles) + Total mileage {% endif %} @@ -58,6 +59,9 @@ {% if route.gpx %}   {% endif %} + {% if forloop.last %} + TODO: fill in total mileage + {% endif %} {% if plan.notes %} From 36225cadf0b91ee04e56a1326bb42d096e4717df Mon Sep 17 00:00:00 2001 From: James Yoo Date: Thu, 26 Mar 2026 10:55:29 -0700 Subject: [PATCH 2/4] Finish implementing a "Total distance" column --- _bin/mkical.py | 5 +++-- _includes/schedule_table.html | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/_bin/mkical.py b/_bin/mkical.py index bb16551..e035287 100755 --- a/_bin/mkical.py +++ b/_bin/mkical.py @@ -59,10 +59,9 @@ def dtstart(date, time): for run in sched: date = datetime.strptime(run['date'], '%Y-%m-%d') phases = run['plan'] - # Maybe something here? - # total_dist = 0 if 'cancelled' in run.keys(): continue + total_dist = 0 for i in range(len(phases)): phase = phases[i] if 'cancelled' in phase.keys(): @@ -75,6 +74,8 @@ def dtstart(date, time): name = route['name'] gmap = route['map'] if 'map' in route else '' dist = route['distance_mi'] if 'distance_mi' in route else None + if dist: + total_dist += dist event_name = f'{name} ({dist}mi)' if dist else name diff --git a/_includes/schedule_table.html b/_includes/schedule_table.html index 415dc8b..0053946 100644 --- a/_includes/schedule_table.html +++ b/_includes/schedule_table.html @@ -6,7 +6,7 @@ Date Time Routes (miles) - Total mileage + Total distance (miles) {% endif %} @@ -16,6 +16,17 @@ {% else %} {% assign cancelled-class = "" %} {% endif %} + {% assign total_dist = 0.0 %} + {% for _phase in run.plan %} + {% unless _phase.cancelled %} + {% if _phase.route_id %} + {% assign _r = site.data.routes | where: 'id', _phase.route_id | first %} + {% if _r.distance_mi %}{% assign total_dist = total_dist | plus: _r.distance_mi %}{% endif %} + {% elsif _phase.route.distance_mi %} + {% assign total_dist = total_dist | plus: _phase.route.distance_mi %} + {% endif %} + {% endunless %} + {% endfor %} {% for plan in run.plan %} {% if plan.cancelled %} @@ -62,15 +73,14 @@ {% if route.gpx and include.link_gpx %}   {% endif %} - {% if forloop.last %} - TODO: fill in total mileage - {% endif %} + {% if forloop.last %}{{ total_dist | round: 1 }}{% endif %} {% if plan.notes %} {{ plan.notes }} + {% endif %} {% if plan.cancelled and plan.cancelled != "" %} @@ -78,6 +88,7 @@ {{ plan.cancelled }} + {% endif %} @@ -90,6 +101,7 @@ + {% endif %} @@ -99,10 +111,11 @@ {{ run.cancelled }} + {% endif %} {% endfor %} - A new schedule is coming! Contribute on GitHub + A new schedule is coming! Contribute on GitHub From ca3069241ed2a8cfa98db1728f248338b91c404f Mon Sep 17 00:00:00 2001 From: James Yoo Date: Thu, 26 Mar 2026 14:36:53 -0700 Subject: [PATCH 3/4] Tweaking table --- _includes/schedule_table.html | 52 +++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/_includes/schedule_table.html b/_includes/schedule_table.html index 0053946..f0d451e 100644 --- a/_includes/schedule_table.html +++ b/_includes/schedule_table.html @@ -5,8 +5,7 @@ Date Time - Routes (miles) - Total distance (miles) +
RoutesDistance (mi)
{% endif %} @@ -56,31 +55,33 @@ {% endunless %} {% endif %} - {% if plan.route_id %} - {{route.name}} -
- {{ route.name }} map +
+ + {% if plan.route_id %} + {{route.name}} +
+ {{ route.name }} map +
+ {% elsif route.map %} + {{route.name}} + {% else %} + {{route.name}} + {% endif %} + {% if route.gpx and include.link_gpx %} +   + {% endif %} +
+ {% if route.distance_mi %}{{ route.distance_mi | round: 1 }}{% endif %}
- {% elsif route.map %} - {{route.name}} - {% else %} - {{route.name}} - {% endif %} - {% if route.distance_mi %}  ({{ route.distance_mi | round: 1}}){% endif %} - {% if route.gpx and include.link_gpx %} -   - {% endif %} - {% if forloop.last %}{{ total_dist | round: 1 }}{% endif %} {% if plan.notes %} {{ plan.notes }} - {% endif %} {% if plan.cancelled and plan.cancelled != "" %} @@ -88,7 +89,6 @@ {{ plan.cancelled }} - {% endif %} @@ -101,21 +101,25 @@ - {% endif %} {% endfor %} + {% if total_dist > 0 and run.plan.size > 1 %} + + + {{ total_dist | round: 1 }} + + {% endif %} {% if run.cancelled and plan.cancelled != "" %} {{ run.cancelled }} - {% endif %} {% endfor %} - A new schedule is coming! Contribute on GitHub + A new schedule is coming! Contribute on GitHub
From 25e47ceef02eb82b74dfdd79b84d57a924c72498 Mon Sep 17 00:00:00 2001 From: James Yoo Date: Thu, 26 Mar 2026 14:55:41 -0700 Subject: [PATCH 4/4] Adding km/mi toggle --- _includes/schedule_table.html | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/_includes/schedule_table.html b/_includes/schedule_table.html index f0d451e..f9899d5 100644 --- a/_includes/schedule_table.html +++ b/_includes/schedule_table.html @@ -1,11 +1,11 @@ -
+
{% if include.show_header %} - + {% endif %} @@ -74,7 +74,7 @@   {% endif %} - {% if route.distance_mi %}{{ route.distance_mi | round: 1 }}{% endif %} + {% if route.distance_mi %}{{ route.distance_mi | round: 1 }}{% endif %} @@ -108,7 +108,7 @@ {% if total_dist > 0 and run.plan.size > 1 %} - + {% endif %} {% if run.cancelled and plan.cancelled != "" %} @@ -123,3 +123,22 @@
Date Time
RoutesDistance (mi)
RoutesDistance ()
{{ total_dist | round: 1 }}
{{ total_dist | round: 1 }}
+