Initial commit

This commit is contained in:
Edward Betts 2022-09-03 21:38:46 +01:00
commit cbc681ddbc
9 changed files with 568 additions and 0 deletions

33
templates/all_routes.html Normal file
View file

@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ferries to France</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
{% from "individual_route.html" import route_table with context %}
<body>
<div class="m-3">
<p>{{ days_until_start }} days until start of Dodainville week: Friday 16 September 2022</p>
<p><a href="{{ url_for(other + "_page") }}">{{ other }}</a></p>
{% if extra_routes %}
<ul>
{% for dep, arr in extra_routes %}
<li><a href="{{ url_for("show_route", departure_port=ports[dep], arrival_port=ports[arr], from_date=from_date, to_date=to_date) }}">{{ dep }} - {{ arr }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% for dep, arr, days in data %}
<h4>{{ dep.title() }} to {{ arr.title() }}</h4>
{{ route_table(dep, arr, days) }}
{% endfor %}
</div>
</body>
</html>

38
templates/cabins.html Normal file
View file

@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ferries to France</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
<body>
<div class="m-3">
<h1>{{ departure_port }} to {{ arrival_port }}</h1>
<p>{{ departure_date }} {{ ticket_tier }}</p>
<table class="table">
<tr>
<th>code</th>
<th>description</th>
<th>max adults</th>
<th>quantity available</th>
<th>price</th>
</tr>
{% for a in accommodations if a.quantityAvailable > 0 %}
<tr>
<td>{{ a.code }}</td>
<td>{{ a.description }}</td>
<td>{{ a.maxAdults }}</td>
<td>{{ a.quantityAvailable }}</td>
<td>£{{ a.unitCost.amount }}</td>
</tr>
{% endfor %}
</table>
</div>
</body>
</html>

21
templates/index.html Normal file
View file

@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
<body>
<div class="m-3">
<ul>
{% for dep, arr in routes %}
<li><a href="{{ url_for("show_route", departure_port=ports[dep], arrival_port=ports[arr]) }}">{{ dep }} - {{ arr }}</a></li>
{% endfor %}
</ul>
</div>
</body>
</html>

View file

@ -0,0 +1,57 @@
{% macro headings() %}
<tr>
<th>day</th>
<th>depart</th>
<th>arrive</th>
<th>ship</th>
<th>economy</th>
<th>standard</th>
<th>flexi</th>
<th></th>
</tr>
{% endmacro %}
{% macro route_table(dep, arr, days) %}
<table class="table w-auto">
{{ headings() }}
{% for day in days %}
{% set date = parse_date(day.date) %}
{% for crossing in day.prices %}
{# <tr><td colspan="7">{{ crossing }}</td></tr> #}
<tr>
<td class="text-nowrap text-end">{{ date.strftime("%a, %d %b") }}</td>
<td class="text-nowrap">
{{ crossing.departureDateTime.time }}
</td>
<td class="text-nowrap">
{{ crossing.arrivalDateTime.time }}
</td>
<td class="text-nowrap">
{{ crossing.shipName }}
</td>
<td class="text-nowrap">
<a href="{{ cabins_url(dep, arr, crossing, "ECONOMY") }}">
£{{ crossing.economyPrice.amount }}
</a>
</td>
<td class="text-nowrap">
<a href="{{ cabins_url(dep, arr, crossing, "STANDARD") }}">
£{{ crossing.standardPrice.amount }}
</a>
</td>
<td class="text-nowrap">
<a href="{{ cabins_url(dep, arr, crossing, "FLEXI") }}">
£{{ crossing.flexiPrice.amount }}
</a>
</td>
<td class="text-nowrap">
{% if crossing.full %}full |{% endif %}
{% if crossing.isCabinSpaceFull %}no cabin space |{% endif %}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% endmacro %}

17
templates/route.html Normal file
View file

@ -0,0 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
{% from "individual_route.html" import route_table with context %}
<body>
<div class="m-3">
<p>{{ departure_port.title() }} to {{ arrival_port.title() }}</p>
{{ route_table(days) }}
</div>
</body>
</html>

View file

@ -0,0 +1,60 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
</head>
{% macro headings() %}
<tr>
<th>depart</th>
<th>arrive</th>
<th>ship</th>
<th>economy</th>
<th>standard</th>
<th>flexi</th>
<th></th>
</tr>
{% endmacro %}
<body>
<div class="m-3">
<p>{{ departure_port.title() }} to {{ arrival_port.title() }}</p>
<table class="table w-auto">
{% for day in days %}
{% set date = parse_date(day.date) %}
<tr><td colspan="3"><h3>{{ date.strftime("%A, %d %B %Y") }}</h3></td></tr>
{{ headings() }}
{% for crossing in day.prices %}
<tr>
<td>
{{ crossing.departureDateTime.time }}
</td>
<td>
{{ crossing.arrivalDateTime.time }}
</td>
<td>
{{ crossing.shipName }}
</td>
<td>
£{{ crossing.economyPrice.amount }}
</td>
<td>
£{{ crossing.standardPrice.amount }}
</td>
<td>
£{{ crossing.flexiPrice.amount }}
</td>
<td>
{% if crossing.full %}full |{% endif %}
{% if crossing.isCabinSpaceFull %}no cabin space |{% endif %}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
</div>
</body>
</html>

30
templates/show_error.html Normal file
View file

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block style %}
<link rel="stylesheet" href="{{url_for('static', filename='css/exception.css')}}" />
{% endblock %}
{% block content %}
<div class="p-2">
<h1>Software error: {{ tb.exception_type }}</h1>
<div>
<pre>{{ tb.exception }}</pre>
</div>
{% set body %}
URL: {{ request.url }}
{{ tb.plaintext | safe }}
{% endset %}
<p><a class="btn btn-primary btn-lg" role="button" href="https://github.com/EdwardBetts/dab-mechanic/issues/new?title={{ tb.exception + " " + request.url | urlencode }}&body={{ body | urlencode }}">Submit as an issue on GitHub</a> (requires an account with GitHub)</p>
<h2 class="traceback">Traceback <em>(most recent call last)</em></h2>
{{ tb.render_summary(include_title=False) | safe }}
<p>Error in function "{{ last_frame.function_name }}": {{ last_frame_args | pprint }}</p>
<pre>{{ last_frame.locals | pprint }}</pre>
</div>
{% endblock %}