summaryrefslogtreecommitdiff
path: root/templates/layouts/app.html.ep
blob: cc131432194d1a738d6c4d8bafcd76fe4a7819d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="de">
<head>
	<title><%= stash('title') // 'DBF' %></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="keywords" content="Abfahrtsmonitor, Bahnhofstafel, Abfahrten, Abfahrtstafel, ICE, IC, RE, RB, S-Bahn">
	<meta name="description" content="<%= stash('description') // 'Inoffizieller Abfahrtsmonitor für innerdeutsche Zugfahrten' %>">
	<meta name="theme-color" content="#00838f">
	<link rel="icon" type="image/png" href="/static/icons/icon-16x16.png" sizes="16x16">
	<link rel="icon" type="image/png" href="/static/icons/icon-32x32.png" sizes="32x32">
	<link rel="icon" type="image/png" href="/static/icons/icon-96x96.png" sizes="96x96">
	<link rel="apple-touch-icon" href="/static/icons/icon-120x120.png">
	<link rel="apple-touch-icon" sizes="180x180" href="/static/icons/icon-180x180.png">
	<link rel="apple-touch-icon" sizes="152x152" href="/static/icons/icon-152x152.png">
	<link rel="apple-touch-icon" sizes="167x167" href="/static/icons/icon-167x167.png">
% if ($self->stash('refresh_interval')) {
	<meta http-equiv="refresh" content="<%= $self->stash('refresh_interval') %>"/>
% }

	% my $av = 'v102'; # asset version
	% if (session('theme') and session('theme') eq 'dark' or param('dark')) {
		%= stylesheet "/static/${av}/css/dark.min.css", id => 'theme'
	% }
	% else {
		%= stylesheet "/static/${av}/css/light.min.css", id => 'theme'
	% }
	<script>
		function addStyleSheet(name, id) {
			const path = '/static/<%=$av%>/css/' + name + '.min.css';
			const old = document.getElementById(id);
			if (old && (old.href != path)) {
				old.href = path;
				document.cookie = 'theme=' + name + ';SameSite=None;Secure';
			}
		}
		const otherTheme = {
			'dark': 'light',
			'light': 'dark',
		};
		var currentTheme = localStorage.getItem('theme');
		if (!otherTheme.hasOwnProperty(currentTheme)) {
			currentTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
		}
		addStyleSheet(currentTheme, 'theme');
	</script>
	%= stylesheet "/static/${av}/css/material-icons.css"
	%= stylesheet "/static/${av}/css/jquery-ui.min.css"
	%= javascript '/static/js/jquery-3.4.1.min.js', defer => undef
	%= javascript "/static/${av}/js/jquery-ui.min.js", defer => undef
	%= javascript "/static/${av}/js/dbf.min.js", defer => undef
	% if (not stash('hide_opts')) {
	%= javascript "/dyn/${av}/autocomplete.js", defer => undef
	% }
	% if (stash('with_geostop')) {
	%= javascript "/static/${av}/js/geostop.min.js", defer => undef
	% }
	% if (stash('with_map')) {
	%= stylesheet "/static/${av}/leaflet/leaflet.css"
	%= javascript "/static/${av}/leaflet/leaflet.js"
	%= javascript "/static/${av}/js/map-refresh.min.js", defer => undef
	% }
</head>
<body>

<div class="navbar-fixed">
	<nav style="color: #ffffff; background-color: #00838f;">
		<div class="nav-wrapper container">
			% if (my $nav_link = stash('nav_link')) {
				<a class="brand-logo" style="float: left;" href="<%= $nav_link %>">
					%= stash('title') || 'DBF'
				</a>
			% }
			% else {
				<span class="brand-logo">
					%= stash('title') || 'DBF'
				</span>
			% }
			<ul id="nav-mobile" style="float: right;">
				% if (stash('api_link')) {
					<li class="waves-effect waves-light">
						<a href="<%= stash('api_link') %>"><span class="visually-hidden"><%= stash('api_text') %></span><i class="material-icons" aria-hidden="true"><%= stash('api_icon') %></i></a>
					</li>
				% }
				% if (stash('hide_opts')) {
					<li><a href="/"><span class="visually-hidden">Hauptseite</span><i class="material-icons" aria-hidden="true">edit</i></a></li>
				% }
				% else {
					<li><a href="#stationinput"><span class="visually-hidden">Menü</span><i class="material-icons" aria-hidden="true">edit</i></a></li>
				% }
			</ul>
		</div>
	</nav>
</div>

<div class="container">
% if (my $error = stash 'error') {
<div class="error"><strong>Fehler:</strong>
<p>
%= $error
</p>
</div>
% }
% elsif (stash('stationlist')) {
<div class="error"><strong>Mehrdeutige Eingabe.</strong>
Bitte eine Station aus der Liste auswählen</div>
% }
</div>

<div class="content">
%= content
</div>

% if (not stash('hide_opts')) {
<div class="container">
<div class="input-field">


%= form_for _redirect => begin
%= hidden_field efa => param('efa')
%= hidden_field hafas => param('hafas')
<div>
  <div class="field">
    <div class="desc">Zug / Station</div>
    <div>
% if (stash('stationlist')) {
      %= select_field input => stash('stationlist')
% }
% elsif (stash('input')) {
      %= text_field 'input', class => 'station', placeholder => 'Zug, Stationsname oder Ril100-Kürzel', id => 'stationinput'
% }
% else {
      %= text_field 'input', class => 'station', placeholder => 'Zug, Stationsname oder Ril100-Kürzel', id => 'stationinput', autofocus => 'autofocus'
% }
    </div>
  </div>
  <div class="field">
    %= submit_button 'Abfahrtstafel'
  </div>
  % if (stash('input')) {
    <div class="geolink">
      <a class="button" href="<%= url_for('_autostop')->to_abs->scheme('https')->query({hafas => param('hafas')}) %>">Stationen in der Umgebung suchen</a>
    </div>
  % }
  <div class="backendlink">
    <a class="button button-light" href="<%= url_for('_backend')->query({efa => param('efa'), hafas => param('hafas')}) %>">Backend: <%= param('efa') ? param('efa') . ' (EFA)' : param('hafas') ? param('hafas') . ' (HAFAS)' : 'DB (IRIS-TTS)' %></a>
  </div>
  <div class="break"></div>
  <div class="moresettings-header moresettings-header-collapsed button button-light">Weitere Einstellungen</div>
  <div class="moresettings moresettings-collapsed">
    <div class="field">
      <div class="desc">
        %= check_box 'rt' => 1, id => 'id_show_realtime'
        <label for="id_show_realtime">
          Zeiten inkl. Verspätung angeben
        </label>
      </div>
    </div>
    <div class="field">
      <div class="desc">
        %= check_box 'hidelowdelay' => 1, id => 'id_hidelowdelay'
        <label for="id_hidelowdelay">
          Verspätungen erst ab 5 Minuten anzeigen
        </label>
      </div>
    </div>
    <div class="field">
      <div class="desc">
        %= check_box 'detailed' => 1, id => 'id_detailed'
        <label for="id_detailed">
          Mehr Details
        </label>
      </div>
    </div>
    <div class="field">
      <div class="desc">
        %= check_box 'no_related' => 1, id => 'id_no_related'
        <label for="id_no_related">
          Betriebliche Bahnhofstrennungen berücksichtigen (z.B. "Hbf (Fern+Regio)" vs. "Hbf (S)")
        </label>
      </div>
    </div>
    <div class="field">
      <div class="desc">
        %= check_box 'past' => 1, id => 'past'
        <label for="past">
          Bereits abgefahrene Züge anzeigen
        </label>
      </div>
    </div>
    <div class="field">
      <div class="desc">
        %= check_box 'hide_opts' => 1, id => 'id_hide_opts'
        <label for="id_hide_opts">
          Formular verstecken
        </label>
      </div>
    </div>
    <div class="field">
      <div class="desc">
        Nur Züge über
      </div>
      <div>
        %= text_field 'via', placeholder => 'Bahnhof 1, Bhf2, ... (oder regulärer Ausdruck)', class => 'station'
      </div>
    </div>
    <div class="field">
      <div class="desc">
        Gleise
      </div>
      <div>
        %= text_field 'platforms', placeholder => '1, 2, 5, ...'
      </div>
    </div>
    <div class="field">
      <div class="desc">
        Ankunfts- oder Abfahrtszeit anzeigen?
      </div>
      <div>
        %= select_field admode => [['Abfahrt bevorzugen' => 'deparr'], ['Nur Abfahrt' => 'dep'], ['Nur Ankunft' => 'arr']]
      </div>
    </div>
    <div class="field">
      <div class="desc">
        Frontend
      </div>
      <div>
        %= select_field mode => [ ['App' => 'app'], ['Infoscreen' => 'infoscreen'], ['Bahnhofstafel (legacy)' => 'multi'], ['Gleisanzeiger (legacy)' => 'single'] ]
      </div>
    </div>
    <div class="field">
      %= submit_button 'Anzeigen'
    </div>
  </div> <!-- moresettings -->
</div>
% end

</div> <!-- input-field -->

<div class="notes">
  <div class="developers-header developers-header-collapsed button button-light">API</div>
  <div class="developers developers-collapsed">
    <ul>
      % if (0) {
        <li>You're welcome to embed DBF departure boards as iframes or use them
          in full-screen browser setups. The App frontend works best for
          small screens, whereas the legacy Infoscreen mode is better suited
          for large displays.</li>
        <li>The departure board supports names, EVA IDs, and (in IRIS mode)
          DS100/Ril100 codes as station identifiers.</li>
        <li>Requests for train details can optionally be suffixed with the
          DD.MM.[YYYY] date of the requested trip, e.g. "ICE 921 (1.1.)" or
          "ICE 921 @ 1.1.". The date refers to the scheduled departure at the
          train's origin station.</li>
        <li>A JSON IRIS API is avaliable via
          <span style="font-family: monospace;">mode=json&amp;version=3</span>
          (or just <span style="font-family: monospace;">https://dbf.finalrewind.org/Station.json?version=3</span>).
          Route elements may contain "isAdditional" and "isCancelled"; the rest
          should be self-explanatory. Please do not send more than 30 requests
          per minute and only one request per station per minute.</li>
        <li>There is no JSON API for train details yet.</li>
        <li>The optional <span style="font-family: monospace;">limit</span>
          parameter limits the number of returnd departures; e.g.
          <span style="font-family: monospace;">limit=10</span> will result in no more than ten.</li>
        <li>DBF is available as Open Source software
          (<a href="https://github.com/derf/db-fakedisplay/blob/master/README.md">installation instructions</a>).
          Please use your own installation for automated crawlers that request dozens of stations per minute.</li>
      % }
      % else {
        <li>DBF-Abfahrtstafeln können gerne als iframe eingebunden oder in
          fest installierten Vollbild-Browserfenstern verwendet werden.
          Für eine kleine Ansicht (z.B. iframe in einer normalen Website)
          empfiehlt sich das "App"-Frontend. Für eine große Ansicht
          (z.B. als alleinstehender Infoscreen) gibt es den "Infoscreen"-Modus.</li>
        <li>Die Abfahrtstafel unterstützt Namen, EVA-IDs, und (im IRIS-Backend)
          DS100/Ril100-Codes zur Identifikation von Stationen.</li>
        <li>Zugdetails können optional für spezifische Abfahrtsdaten im
          DD.MM.[YYYY]-Format abgefragt werden, z.B. "ICE 921 (1.1.)" oder
          "ICE 921 @ 1.1.". Das Datum bezieht sich auf die geplante
          Abfahrtszeit am Startbahnhof der Zugfahrt.</li>
        <li>Die Parameter <span style="font-family: monospace;">mode=json&amp;version=3</span>
          (alternativ <span style="font-family:
          monospace;">https://dbf.finalrewind.org/Bahnhofsname.json?version=3</span>)
          bieten ein JSON-IRIS-Interface. Die route-Elemente können zusätzlich
          die Felder "isAdditional" oder "isCancelled" enthalten, der Rest sollte
          selbsterklärend sein. Im Fehlerfall fehlt das "departures"-Element,
          stattdessen wird ein "error"-Element mit Fehlermeldung zurückgegeben.
          Bitte maximal 30 Anfragen pro Minute und insbesondere nur eine Anfrage
          pro Station und Minute – eine höhere Auflösung haben die Backenddaten
          ohnehin nicht.</li>
        <li>Ein JSON-Interface für Zugdetails ist in Arbeit.</li>
        <li>Mit <span style="font-family: monospace;">limit</span> kann die Anzahl der
          angezeigten / im JSON enthaltenen Abfahrten eingeschränkt werden, z.B.
          <span style="font-family: monospace;">limit=10</span> für die ersten zehn.</li>
        <li>Dieser Dienst ist Open Source-Software und kann leicht auf eigenen Servern
          <a href="https://github.com/derf/db-fakedisplay/blob/master/README.md">installiert</a>
          werden. Automatisierte Crawler, die mehrere Dutzend Stationen pro Minute
          abfragen, bitte nur auf eigenen Instanzen betreiben.</li>
      % }
    </ul>
  </div> <!-- developers -->
</div> <!-- notes -->

</div> <!-- container -->

<div class="container">
<div class="config">
Farbschema:
<a onClick="javascript:setTheme('light')">hell</a>
·
<a onClick="javascript:setTheme('dark')">dunkel</a>
·
<a onClick="javascript:setTheme('default')">automatisch</a>
<!--Language:
<br/>
<a onClick="javascript:setLang('de')">DE</a>
·
<a onClick="javascript:setLang('en')">EN</a>
·
<a onClick="javascript:setLang('default')">system language</a>
-->
</div>
<div class="about">
<a href="_about">DBF</a> v<%= stash('version') // '???' %>
·
<a href="_datenschutz" rel="nofollow">Datenschutz</a>
·
<a href="_impressum" rel="nofollow">Impressum</a>
</div> <!-- about -->
</div> <!-- container -->
% }

</body>
</html>