things

Mon, 05 Mar 2018 12:56:42 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 05 Mar 2018 12:56:42 +0200
changeset 85
62e753b7d3ff
parent 84
30cc6a1d1903
child 86
302f840d6a65

things

service.py file | annotate | diff | comparison | revisions
templates/stop_display.html file | annotate | diff | comparison | revisions
--- a/service.py	Mon Mar 05 12:47:40 2018 +0200
+++ b/service.py	Mon Mar 05 12:56:42 2018 +0200
@@ -81,10 +81,10 @@
 	else:
 		return schedule_entry['trip'].schedule[-1].stop.name
 
-def long_form_sign(schedule_entry):
+def long_form_sign(schedule_entry, long = True):
 	from math import ceil
 	trip_length = schedule_entry['trip'].length - schedule_entry['stop'].traveled_distance
-	sign = reduce_schedule(schedule_entry['trip'].concise_schedule(schedule_entry['stop']), trip_length = trip_length, long = True)
+	sign = reduce_schedule(schedule_entry['trip'].concise_schedule(schedule_entry['stop']), trip_length = trip_length, long = long)
 	if sign:
 		return {
 			'destination': tr(sign[-1], 'places'),
@@ -274,6 +274,13 @@
 		'abbreviation': trip_abbreviation(trip),
 	})
 
+def current_bus_day():
+	from datetime import date, datetime, timedelta
+	day = date.today()
+	if datetime.now().hour < 5:
+		day -= timedelta(1)
+	return day
+
 @app.route('/stop_display/<reference>')
 def stop_display(reference):
 	from buses import bus_stops
@@ -282,12 +289,12 @@
 		bus_stop = bus_stops[reference]
 	except KeyError:
 		abort(404)
-	for i, schedule_entry in enumerate(bus_stop.schedule_for_day(today(), arrivals = False)):
+	for i, schedule_entry in enumerate(bus_stop.schedule_for_day(current_bus_day(), arrivals = False)):
 		schedule.append({
 			'time_data': schedule_entry['time'],
 			'time': time_representation(schedule_entry['time']),
 			'route': schedule_entry['trip'].route.reference,
-			'sign': long_form_sign(schedule_entry),
+			'sign': long_form_sign(schedule_entry, long = False),
 			'trip': schedule_entry['stop'].trip.name,
 			'night': is_night_time(schedule_entry['time']),
 			'imminent': imminent(schedule_entry),
--- a/templates/stop_display.html	Mon Mar 05 12:47:40 2018 +0200
+++ b/templates/stop_display.html	Mon Mar 05 12:56:42 2018 +0200
@@ -19,17 +19,11 @@
 	
 	.next-leave td
 	{
-		height: 30vh;
+		height: 12vh;
 		vertical-align: middle;
 	}
 	
-	.next-leave-list
-	{
-		width: 100%;
-	}
-	
 	.next-leave-time,
-	.next-leave-places li.next-leave-destination,
 	.next-leave-route
 	{
 		font-weight: bold;
@@ -41,7 +35,7 @@
 		text-align: left;
 	}
 	
-	.next-leave-route
+	.next-leave-route .route-symbol
 	{
 		border: 0.5vmin solid black;
 		border-radius: 100%;
@@ -50,6 +44,11 @@
 		min-height: 12vmin;
 		text-align: center;
 		background: #ffd90f;
+	} 
+
+	.next-leave, .next-leave table
+	{
+		width: 100%;
 	}
 	
 	.next-leave-places
@@ -61,8 +60,9 @@
 	{
 		list-style: none;
 		font-size: 6vmin;
-		padding-top: 1vw;
 		font-weight: normal;
+		float: left;
+		padding-left: 10pt;
 	}
 	
 	#other-leaves
@@ -89,6 +89,13 @@
 		text-align: center;
 	}
 	
+	.next-leave-destination
+	{
+		font-size: 7vh;
+		font-weight: bold;
+		text-align: left;
+	}
+	
 	.other-leave-time
 	{
 		width: 30%;
@@ -223,10 +230,7 @@
 <body onload='cycle_leaves()'>
 	<h1><img src="../static/pysäkki.png" height="128" /><span id='stop-name'>{{ref}} {{name}}</span></h1>
 	<div class='next-leave'>
-	<ul class='next-leave-list'>
 	{% for schedule_entry in schedule[:num_imminent_leaves] %}
-	<li id="leave-{{schedule_entry['index']}}">
-	
 	<table>
 	<tr>
 	<td class='next-leave-time'>
@@ -236,24 +240,26 @@
 	{{schedule_entry['time']}}&#8203;
 	{% endif %}
 	</td>
-	<td rowspan="2">
+	<td class='next-leave-route'>
+		<span class='route-symbol'>{{schedule_entry['route']}}</span>
+	</td>
+	</tr>
+	
+	<tr>
+	<td colspan="2" class='next-leave-destination'>{{schedule_entry['sign']['destination']}}</td>
+	</tr>
+	
+	<tr>
+	<td>
 	<ul class="next-leave-places">
-		<li class='next-leave-destination'>
-			{{schedule_entry['sign']['destination']}}</li>
-		{% for entry in schedule_entry['sign']['via'] %}
-			<li>{{entry}}</li>
-		{% endfor %}
+	{% for entry in schedule_entry['sign']['via'] %}
+		<li>{{entry}}</li>
+	{% endfor %}
 	</ul>
 	</td>
 	</tr>
-	<tr>
-	<td><span class='next-leave-route'>{{schedule_entry['route']}}</span></td>
-	</tr>
 	</table>
-	
-	</li>
 	{% endfor %}
-	</ul>
 	</div>
 	{% if schedule[num_imminent_leaves] %}
 	<div id='other-leaves'>

mercurial