Tue, 13 Jun 2017 00:47:24 +0300
Yleistä päivittelyä
buses.py | file | annotate | diff | comparison | revisions | |
busroute.py | file | annotate | diff | comparison | revisions | |
misc.py | file | annotate | diff | comparison | revisions | |
service.py | file | annotate | diff | comparison | revisions | |
static/style.css | file | annotate | diff | comparison | revisions | |
templates/ajovuoro-suppea.html | file | annotate | diff | comparison | revisions | |
templates/ajovuoro.html | file | annotate | diff | comparison | revisions | |
templates/cluster.html | file | annotate | diff | comparison | revisions | |
templates/pysäkki.html | file | annotate | diff | comparison | revisions | |
tr/en.ini | file | annotate | diff | comparison | revisions | |
tr/sv.ini | file | annotate | diff | comparison | revisions |
--- a/buses.py Sun Jun 11 01:28:25 2017 +0300 +++ b/buses.py Tue Jun 13 00:47:24 2017 +0300 @@ -199,11 +199,15 @@ pysäkit[pysäkkitunniste].alue = alue print('%d pysäkkiä' % len(pysäkit), file = stderr) + class BusStopCluster: def __init__(self): self.stops = set() self._center = None self.name = None + @property + def url_name(self): + return self.name.lower().replace('(', '').replace(')', '').replace(' ', '-') def add_stop(self, stop): assert not stop.cluster stop.cluster = self @@ -294,8 +298,7 @@ clusters_per_name = defaultdict(set) for cluster in all_clusters: name_representing_stop = min((len(pysäkki.tunniste), pysäkki.tunniste, pysäkki) for pysäkki in cluster.stops)[2] - name = name_representing_stop.nimi.lower().replace(' ', '-') - clusters_per_name[name].add(cluster) + clusters_per_name[name_representing_stop.nimi].add(cluster) for name, clusters in clusters_per_name.items(): if len(clusters) == 1: # Ryhmä on ainoa jolla on varaus tälle nimelle. Sen kuin vaan. @@ -315,7 +318,7 @@ for cluster, unique_areas in proposal.items(): individual_cluster_name = name if unique_areas: - individual_cluster_name += '-' + min(unique_areas).lower().replace(' ', '-') + individual_cluster_name += ' (' + min(unique_areas) + ')' cluster.name = individual_cluster_name else: # Typerä reunatapaus. Indeksoidaan numeroin... @@ -332,8 +335,8 @@ clusters_by_name = {} for cluster in all_clusters: - assert cluster.name not in clusters_by_name - clusters_by_name[cluster.name] = cluster + assert cluster.url_name not in clusters_by_name + clusters_by_name[cluster.url_name] = cluster print('Ladataan aikataulut... ', end = '', flush = True, file = stderr) with open('gtfs/stop_times.txt') as file:
--- a/busroute.py Sun Jun 11 01:28:25 2017 +0300 +++ b/busroute.py Tue Jun 13 00:47:24 2017 +0300 @@ -12,9 +12,6 @@ 'Haarla': 'Hirvensalo', 'Lauttasaari': 'Hirvensalo', 'Pikisaari': 'Hirvensalo', - 'Vienola': 'Pahaniemi', - 'Takakirves': 'Kärsämäki', - 'Liljalaakso': 'Länsinummi', 'Pernon telakka': 'Perno', } try: @@ -71,7 +68,7 @@ 'Haarla': 50, 'Ylioppilaskylä': 50, 'Halinen': 70, - 'Kakskerta': 50, + 'Kakskerta': 200, 'Pansio': 50, 'Räntämäki': 10, 'Verkahovi': 20,
--- a/misc.py Sun Jun 11 01:28:25 2017 +0300 +++ b/misc.py Tue Jun 13 00:47:24 2017 +0300 @@ -12,6 +12,8 @@ import csv lukija = csv.reader(tiedosto) otsakkeet = next(lukija) + for i in range(len(otsakkeet)): + otsakkeet[i] = otsakkeet[i].replace('\ufeff', '').strip() for rivi in lukija: tietue = dict(zip(otsakkeet, rivi)) if muunnokset:
--- a/service.py Sun Jun 11 01:28:25 2017 +0300 +++ b/service.py Tue Jun 13 00:47:24 2017 +0300 @@ -61,9 +61,9 @@ sign = supista_reitti(schedule_entry['trip'].suppea_reitti(schedule_entry['stop'])) sign = [tr(paikka, 'paikat') for paikka in sign] sign_representation = ' - '.join(sign) - if len(sign_representation) > 25: - k = ceil(len(sign) / 2) - sign_representation = ' - '.join(sign[:k]) + '\n' + ' - '.join(sign[k:]) + #if len(sign_representation) > 25: + # k = ceil(len(sign) / 2) + # sign_representation = ' - '.join(sign[:k]) + '\n' + ' - '.join(sign[k:]) return sign_representation @app.route('/pysäkki/<tunniste>') @@ -89,15 +89,15 @@ linkki_karttaan = pysäkki.sijainti.link_to_map, alue = pysäkki.alue, sijainti = pysäkki.sijainti, - cluster = pysäkki.cluster.name if len(pysäkki.cluster.stops) > 1 else None, + cluster = pysäkki.cluster.url_name if len(pysäkki.cluster.stops) > 1 else None, tr = tr, ) def time_representation(aika, suhteellinen = True): erotus = aika - nyt() - if suhteellinen and erotus < timedelta(minutes = 1): + if suhteellinen and erotus > timedelta(0) and erotus < timedelta(minutes = 1): return tr('right-now', 'misc-text') - elif suhteellinen and erotus < timedelta(minutes = 10): + elif suhteellinen and erotus > timedelta(0) and erotus < timedelta(minutes = 10): return '%dm' % round(erotus.seconds / 60) elif aika.date() == tänään(): return '%d:%02d' % (aika.hour, aika.minute) @@ -129,7 +129,7 @@ return render_template( 'cluster.html', aikataulu = aikataulu, - nimi = 'Yhdistetty pysäkkiaikataulu ' + cluster_name, + nimi = cluster.name, linkki_karttaan = cluster.center.link_to_map, sijainti = cluster.center, stops_in_cluster = sorted( @@ -168,10 +168,11 @@ if alue not in käydyt_alueet: suppea_reitti.append({ 'aika': muotoiltu_aika, - 'alue': alue, + 'alue': tr(alue or '', 'paikat'), }) käydyt_alueet.add(alue) kyltti = supista_reitti([k['alue'] for k in suppea_reitti], kokonainen = True) + kyltti = [kyltti[0], kyltti[-1]] sivu = suppea and 'ajovuoro-suppea.html' or 'ajovuoro.html' return render_template(sivu, reitti = reitti,
--- a/static/style.css Sun Jun 11 01:28:25 2017 +0300 +++ b/static/style.css Tue Jun 13 00:47:24 2017 +0300 @@ -19,16 +19,26 @@ h1 { padding-top: 10pt; - padding-bottom: 10pt; + padding-bottom: 20pt; text-align: center; + /* font-variant: small-caps; */ + font-weight: normal; background: #dc9e00; - background: linear-gradient(to bottom, #dc9e00 0%,#eaaf19 49%,#dc9e00 92%,#906700 100%); - color: white; + /*background: linear-gradient(to bottom, #dc9e00 0%,#eaaf19 49%,#dc9e00 92%,#906700 100%);*/ + /* background: linear-gradient(to bottom, #dcbb00 0%,#eacb19 49%,#dcbb00 92%,#906700 100%); */ + background: linear-gradient(to bottom, #ffd90f 0%, #ffd90f 95%, #906700 100%); + /*color: white;*/ + color: black; + vertical-align: middle; +} +h1 img, h1 span +{ + vertical-align: middle; } #aikataulu { - width:100%; margin: auto; + min-width: 50%; } .sarake-aika, .sarake-linja @@ -36,38 +46,21 @@ text-align: center; } -.sarake-määränpää -{ - text-align: left; -} - td, th, body { font-size: 24pt; } -.sarake-aika, .sarake-linja -{ - width: 25%; -} - -h1 +#aikataulu th, #aikataulu td { - font-variant: small-caps; -} - -.sarake-määränpää a -{ - white-space: pre-wrap; + padding-left: 40pt; + padding-right: 40pt; + padding-bottom: 10px; + padding-top: 10px; } #aikataulu tr td { - padding-bottom: 10px; - padding-top: 10px; - padding-left: 0px; - padding-right: 0px; - margin: 0px; border-top: 1px solid gray; } @@ -102,12 +95,12 @@ font-size: smaller; } -.sarake-määränpää +.sarake-pysäkki { text-align: center; } -.sarake-pysäkki +p { - text-align: center; + text-align: center }
--- a/templates/ajovuoro-suppea.html Sun Jun 11 01:28:25 2017 +0300 +++ b/templates/ajovuoro-suppea.html Tue Jun 13 00:47:24 2017 +0300 @@ -1,65 +1,27 @@ <html> <head> <link rel="icon" type="image/png" href="/static/favicon.png" /> + <link rel="stylesheet" type="text/css" href="/static/style.css" /> <meta charset='UTF-8' /> - <style> - body - { - font-family: FreeSans, Arial, sans-serif; - background: white; - color: black; - margin: 0; - padding: 0; - font-size: 24pt; - } - h1 - { - padding-top: 10pt; - padding-bottom: 10pt; - text-align: center; - background: #dc9e00; - background: linear-gradient(to bottom, #dc9e00 0%,#eaaf19 49%,#dc9e00 92%,#906700 100%); - color: white; - } - a - { - color: inherit; - text-decoration: none; - } - a:hover - { - text-decoration: underline; - } - #aikataulu - { - width:100%; - margin: auto; - } - #aikataulu td - { - text-align: center; - } td, th, body { font-size: 24pt; } - .sarake-aika { - width: 15%; + text-align: center; } - - h1 + .sarake-alue { - font-variant: small-caps; + text-align: left; } </style> <title>{{linja}} {{selite}}</title> </head> <body> <h1>{{linja}} {{selite}}</h1> - <table id='aikataulu'> + <table id='aikataulu' cellspacing='0'> <tr> <th class='sarake-aika'>Aika</th> <th class='sarake-alue'>Alue</th>
--- a/templates/ajovuoro.html Sun Jun 11 01:28:25 2017 +0300 +++ b/templates/ajovuoro.html Tue Jun 13 00:47:24 2017 +0300 @@ -1,61 +1,31 @@ <html> <head> <link rel="icon" type="image/png" href="/static/favicon.png" /> + <link rel="stylesheet" type="text/css" href="/static/style.css" /> <meta charset='UTF-8' /> <style> - body - { - font-family: FreeSans, Arial, sans-serif; - background: white; - color: black; - margin: 0; - padding: 0; - font-size: 24pt; - } - h1 - { - padding-top: 10pt; - padding-bottom: 10pt; - text-align: center; - background: #dc9e00; - background: linear-gradient(to bottom, #dc9e00 0%,#eaaf19 49%,#dc9e00 92%,#906700 100%); - color: white; - } - a - { - color: inherit; - text-decoration: none; - } - a:hover - { - text-decoration: underline; - } #aikataulu { - width:100%; margin: auto; } #aikataulu td { text-align: center; } + #aikataulu .sarake-pysäkki + { + text-align: left; + } td, th, body { font-size: 24pt; } - .sarake-aika, .sarake-tunniste { width: 15%; } - - h1 - { - font-variant: small-caps; - } </style> - <!--<title>Ajovuoro #{{numero}}: {{linja}} {{selite}}</title>--> <title>{{linja}} {{selite}}</title> </head> <body> @@ -64,25 +34,21 @@ 🌙 {% endif %} <!--Ajo {{numero}}: -->{{linja}} {{selite}}</h1> - <table id='aikataulu'> + <table id='aikataulu' cellspacing='0'> <tr> <th class='sarake-aika'>Aika</th> - <th class='sarake-linja'>Viite</th> - <th class='sarake-nimi'>Nimi</th> - <th class='sarake-alue'>Alue</th> + <th class='sarake-pysäkkiviite'>Pysäkki</th> + <th class='sarake-pysäkki'>Nimi</th> </tr> {% for rivi in reitti %} <tr> <td class='sarake-aika'>{{rivi['aika']}}</td> - <td class='sarake-tunniste'> - <a href="/pysäkki/{{rivi['tunniste']}}">{{rivi['tunniste']}}</a> + <td class='sarake-pysäkkiviite'> + <a href="/pysäkki/{{rivi['tunniste']}}"><img src='/static/pysäkki.png' height='24' /> {{rivi['tunniste']}}</a> </td> - <td class='sarake-nimi'> + <td class='sarake-pysäkki'> <a href="/pysäkki/{{rivi['tunniste']}}">{{rivi['nimi']}}</a> </td> - <td class='sarake-alue'> - {{rivi['alue'] or ''}} - </td> </tr> {% endfor %} </table>
--- a/templates/cluster.html Sun Jun 11 01:28:25 2017 +0300 +++ b/templates/cluster.html Tue Jun 13 00:47:24 2017 +0300 @@ -5,21 +5,30 @@ <meta charset='UTF-8' /> <title>{{nimi}}</title> <style> - p { text-align: center } + div.stops-in-cluster + { + margin-left: auto; + margin-right: auto; + } + div.stops-in-cluster ul + { + columns: 3; + } </style> </head> <body> - <h1>{{nimi}}</h1> + <h1><img src="/static/iso-pysäkki.png" height="96" /> <span>{{nimi}}</span></h1> <p id="pysäkki-info"> <a class="pysäkki-sijainti" href="{{linkki_karttaan}}" target="_blank">📌 ({{sijainti}})</a> </p> - <p>Pysäkit ryhmässä: - <ul> - {% for stop in stops_in_cluster %} - <li><a href="/pysäkki/{{stop['id']}}">{{stop['id']}} {{stop['name']}}</a></li> - {% endfor %} - </ul> - </p> + <p>Pysäkit ryhmässä:</p> + <div class="stops-in-cluster"> + <ul> + {% for stop in stops_in_cluster %} + <li><a href="/pysäkki/{{stop['id']}}"><img src="/static/pysäkki.png" height="24" /> {{stop['id']}} {{stop['name']}}</a></li> + {% endfor %} + </ul> + </div> <table id='aikataulu' cellspacing="0"> <tr> <th class='sarake-aika'>{{tr('time', 'headings')}}</th> @@ -37,7 +46,7 @@ <a href="/ajovuoro/{{rivi['ajovuoro']}}">{{rivi['kyltti']}}</a> </td> <td class='sarake-pysäkki'> - <a href="/pysäkki/{{rivi['stop_id']}}">{{rivi['stop_id']}}</a> + <a href="/pysäkki/{{rivi['stop_id']}}"><img src="/static/pysäkki.png" height="24" /> {{rivi['stop_id']}}</a> </td> </tr> {% endfor %}
--- a/templates/pysäkki.html Sun Jun 11 01:28:25 2017 +0300 +++ b/templates/pysäkki.html Tue Jun 13 00:47:24 2017 +0300 @@ -5,11 +5,14 @@ <meta charset='UTF-8' /> <title>{{nimi}}</title> <style> - p { text-align: center } + .sarake-määränpää + { + text-align: left; + } </style> </head> <body> - <h1>{{nimi}}</h1> + <h1><img src="/static/iso-pysäkki.png" height="96" /> <span>{{nimi}}</span></h1> <p id="pysäkki-info"> {{alue or ""}} —
--- a/tr/en.ini Sun Jun 11 01:28:25 2017 +0300 +++ b/tr/en.ini Tue Jun 13 00:47:24 2017 +0300 @@ -3,7 +3,7 @@ kauppatori = City Centre lentoasema = ✈ Airport ylioppilaskylä = Student Village -kauppakeskus mylly = Shopping Center Mylly +kauppakeskus mylly = Mylly raision keskusta = Raisio Centrum naantalin keskusta = Naantali Centrum linja-autoasema = Bus Station
--- a/tr/sv.ini Sun Jun 11 01:28:25 2017 +0300 +++ b/tr/sv.ini Tue Jun 13 00:47:24 2017 +0300 @@ -1714,7 +1714,7 @@ ylioppilaskylä-itä = Östra Studentbyn caribia = Spa Caribia lieto as. = Lundo stn. -kauppakeskus mylly = Köpcentrum Mylly +kauppakeskus mylly = Mylly turku = Åbo piikkiö = Pikis paimio = Pemar