Fri, 11 Aug 2017 14:28:13 +0300
Lisätty uudelleenohjauksia
service.py | file | annotate | diff | comparison | revisions | |
templates/cluster.html | file | annotate | diff | comparison | revisions | |
templates/route.html | file | annotate | diff | comparison | revisions | |
templates/stop.html | file | annotate | diff | comparison | revisions | |
templates/trip.html | file | annotate | diff | comparison | revisions |
--- a/service.py Mon Jul 31 01:15:28 2017 +0300 +++ b/service.py Fri Aug 11 14:28:13 2017 +0300 @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -from flask import Flask, render_template, abort, send_from_directory +from flask import Flask, render_template, abort, send_from_directory, redirect from datetime import datetime, date, time, timedelta from os import path, listdir from configparser import ConfigParser @@ -77,7 +77,7 @@ def imminent(schedule_entry): return (schedule_entry['time'] - now()) <= timedelta(minutes = 3) -@app.route('/pysäkki/<reference>') +@app.route('/stop/<reference>') def bus_stop_schedule(reference): from buses import bus_stops schedule = [] @@ -120,7 +120,7 @@ with activate_locale(): return time.strftime('%-d.%-m. %H:%M').replace(' ', '\xa0') -@app.route('/pysäkkiryhmä/<cluster_name>') +@app.route('/stop_cluster/<cluster_name>') def cluster_schedule(cluster_name): from buses import bus_stops, clusters_by_name schedule = [] @@ -159,7 +159,7 @@ tr = tr, ) -@app.route('/ajovuoro/<trip_reference>') +@app.route('/trip/<trip_reference>') def trip(trip_reference): from flask import request from buses import all_trips @@ -205,7 +205,7 @@ length = trip.length / 1000, ) -@app.route('/linja/<name>') +@app.route('/route/<name>') def route_page(name): from buses import routes route = routes[name.upper()] @@ -224,6 +224,22 @@ schedule = schedule, ) +@app.route('/') +def index(): + return redirect('/stop_cluster/kauppatori') + +@app.route('/pysäkki/<reference>') +def redirect_pysäkki(reference): + return redirect('/stop/' + str(reference)) + +@app.route('/pysäkkiryhmä/<reference>') +def redirect_pysäkkiryhmä(reference): + return redirect('/stop_cluster/' + str(reference)) + +@app.route('/ajovuoro/<reference>') +def redirect_ajovuoro(reference): + return redirect('/trip/' + str(reference)) + @app.route('/static/<path:path>') def static_file(path): return send_from_directory(path.join('static', path))
--- a/templates/cluster.html Mon Jul 31 01:15:28 2017 +0300 +++ b/templates/cluster.html Fri Aug 11 14:28:13 2017 +0300 @@ -63,13 +63,13 @@ {{halt['time']}} </td> <td class='sarake-linja linja'> - <a href="../ajovuoro/{{halt['trip']}}">{{halt['route']}}</a> + <a href="../trip/{{halt['trip']}}">{{halt['route']}}</a> </td> <td class='sarake-määränpää'> - <a href="../ajovuoro/{{halt['trip']}}">{{halt['sign']}}</a> + <a href="../trip/{{halt['trip']}}">{{halt['sign']}}</a> </td> <td class='sarake-pysäkki'> - <a href="../pysäkki/{{halt['stop_id']}}"><img src="../static/pysäkki.png" height="24" /> {{halt['stop_code']}}</a> + <a href="../stop/{{halt['stop_id']}}"><img src="../static/pysäkki.png" height="24" /> {{halt['stop_code']}}</a> </td> </tr> {% endfor %}
--- a/templates/route.html Mon Jul 31 01:15:28 2017 +0300 +++ b/templates/route.html Fri Aug 11 14:28:13 2017 +0300 @@ -18,9 +18,9 @@ {% for trip in schedule %} <tr> <td>{{trip['time']}}</td> - <td><a href="../ajovuoro/{{trip['name']}}">{{trip['from']}}</a></td> - <td><a href="../ajovuoro/{{trip['name']}}">{{trip['to']}}</a></td> - <td><a href="../ajovuoro/{{trip['name']}}">{{trip['status']}}</a></td> + <td><a href="../trip/{{trip['name']}}">{{trip['from']}}</a></td> + <td><a href="../trip/{{trip['name']}}">{{trip['to']}}</a></td> + <td><a href="../trip/{{trip['name']}}">{{trip['status']}}</a></td> </tr> {% endfor %} </table>
--- a/templates/stop.html Mon Jul 31 01:15:28 2017 +0300 +++ b/templates/stop.html Fri Aug 11 14:28:13 2017 +0300 @@ -30,7 +30,7 @@ </p> {% if cluster %} <p> - <a href="../pysäkkiryhmä/{{cluster}}">{{tr('nearby-area-schedule', 'misc-text')}}</a> + <a href="../stop_cluster/{{cluster}}">{{tr('nearby-area-schedule', 'misc-text')}}</a> </p> {% endif %} <table class='aikataulu' cellspacing="0"> @@ -47,10 +47,10 @@ {% endif %} {{halt['time']}}</td> <td class='sarake-linja linja'> - <a href="../ajovuoro/{{halt['trip']}}">{{halt['route']}}</a> + <a href="../trip/{{halt['trip']}}">{{halt['route']}}</a> </td> <td class='sarake-määränpää'> - <a href="../ajovuoro/{{halt['trip']}}">{{halt['sign']}}</a> + <a href="../trip/{{halt['trip']}}">{{halt['sign']}}</a> </td> </tr> {% endfor %}
--- a/templates/trip.html Mon Jul 31 01:15:28 2017 +0300 +++ b/templates/trip.html Fri Aug 11 14:28:13 2017 +0300 @@ -67,8 +67,8 @@ {% for halt in entry['stops'] %} <tr> <td>{{halt['time']}}</td> - <td><a href="../pysäkki/{{halt['id']}}"><img src='../static/pysäkki.png' height='24' /> {{halt['code']}}</a></td> - <td><a href="../pysäkki/{{halt['id']}}">{{halt['name']}}</a></td> + <td><a href="../stop/{{halt['id']}}"><img src='../static/pysäkki.png' height='24' /> {{halt['code']}}</a></td> + <td><a href="../stop/{{halt['id']}}">{{halt['name']}}</a></td> </tr> {% endfor %} </table>