diff options
author | Paweł Dybiec <pawel@dybiec.info> | 2020-05-24 23:36:36 +0200 |
---|---|---|
committer | Paweł Dybiec <pawel@dybiec.info> | 2020-05-24 23:36:36 +0200 |
commit | 314c42acd1595146a66a9530c982b660832cf3e5 (patch) | |
tree | 34ef9ec80df82178887f6ae00a924d7a2b430c96 /compose/cs | |
parent | Optimize darling website (diff) |
Add cs map service
Diffstat (limited to 'compose/cs')
-rw-r--r-- | compose/cs/Dockerfile | 6 | ||||
-rw-r--r-- | compose/cs/__pycache__/cs.cpython-38.pyc | bin | 0 -> 1474 bytes | |||
-rw-r--r-- | compose/cs/cs.py | 30 | ||||
-rw-r--r-- | compose/cs/requirements.txt | 1 | ||||
-rw-r--r-- | compose/cs/static/icon.png | bin | 0 -> 3734 bytes | |||
-rw-r--r-- | compose/cs/static/style.css | 35 | ||||
-rw-r--r-- | compose/cs/templates/main.html | 27 |
7 files changed, 99 insertions, 0 deletions
diff --git a/compose/cs/Dockerfile b/compose/cs/Dockerfile new file mode 100644 index 0000000..57323dd --- /dev/null +++ b/compose/cs/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3.7-alpine +ADD . /code +WORKDIR /code +RUN pip install -r requirements.txt +ENV FLASK_APP cs.py +CMD ["python3", "-m", "flask", "run", "--host=0.0.0.0"] diff --git a/compose/cs/__pycache__/cs.cpython-38.pyc b/compose/cs/__pycache__/cs.cpython-38.pyc Binary files differnew file mode 100644 index 0000000..9d63e21 --- /dev/null +++ b/compose/cs/__pycache__/cs.cpython-38.pyc diff --git a/compose/cs/cs.py b/compose/cs/cs.py new file mode 100644 index 0000000..b455af2 --- /dev/null +++ b/compose/cs/cs.py @@ -0,0 +1,30 @@ +import datetime +from typing import List, Tuple +from flask import Flask, render_template +app = Flask("Today's maps") +maps = [ "mirage 🇲🇦", + "inferno 🔥", + "overpass 🌉", + "vertigo 🏗️", + "nuke ☢", + "train 🚆", + "dust 🏜", + "anubis ☥", + "cache ☭", + "agency 🏢", + "office 🖥"] + +def maps_of_day(day: datetime.date) -> Tuple[str, str]: + l = len(maps) + i = (day-day.replace(day=1, month=1)).days+1 + return maps[(2*i)%l], maps[(2*i+1)%l] + +def maps_of_current_week() -> List[Tuple[str, str, str]]: + today = datetime.date.today() + days = [today+datetime.timedelta(days=i) for i in range(6)] + return [(day.strftime("%A"), *maps_of_day(day)) for day in days] + +@app.route("/") +def main(): + return render_template("main.html", maps=maps_of_current_week()) + diff --git a/compose/cs/requirements.txt b/compose/cs/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/compose/cs/requirements.txt @@ -0,0 +1 @@ +flask diff --git a/compose/cs/static/icon.png b/compose/cs/static/icon.png Binary files differnew file mode 100644 index 0000000..b02d809 --- /dev/null +++ b/compose/cs/static/icon.png diff --git a/compose/cs/static/style.css b/compose/cs/static/style.css new file mode 100644 index 0000000..b4eac13 --- /dev/null +++ b/compose/cs/static/style.css @@ -0,0 +1,35 @@ +@import url("https://fonts.googleapis.com/css?family=Noto+Sans"); +html { + font-family: "Noto Sans", "Noto Color Emoji"; +} +html table { + font-size: 30px; + width: 40%; + margin: 0 auto; + border-collapse: collapse; + margin-bottom: 5mm; +} +html table th { + border-bottom: .2mm solid #5b5; + color: #5b5; + padding: 2mm; + text-transform: uppercase; +} +html table td { + padding: 2.5mm; +} +.map { + color: #55b; + font-weight: bold; + text-align: center; +} +.maps th:first-of-type, +.maps td:first-of-type { + text-align: left; + padding-left: 3mm; +} +.maps th:last-of-type, +.maps td:last-of-type { + text-align: right; + padding-right: 3mm; +} diff --git a/compose/cs/templates/main.html b/compose/cs/templates/main.html new file mode 100644 index 0000000..c93bfac --- /dev/null +++ b/compose/cs/templates/main.html @@ -0,0 +1,27 @@ +<html> + <head> + <title> Map of a day </title> + <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" /> + <link rel="icon" type="image/png" href="{{ url_for('static', filename='icon.png') }}"> + <link rel="apple-touch-icon" type="image/png" href="{{ url_for('static', filename='icon.png') }}"> + </head> + <body> + <table class="maps"> + <thead> + <th> Day </th> + <th> Map </th> + <th> Map </th> + <tbody> + {% for e in maps %} + <tr> + <td class="day">{{ e[0] }}</td> + <td class="map">{{ e[1] }}</td> + <td class="map">{{ e[2] }}</td> + </tr> + + {% endfor %} + </tbody> + </table> + </body> + +</html> |