diff --git a/README.md b/README.md index cc03a0a..9a0b596 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Počitadlo je dostupné na: ``` Na notebooku otevři `/board`, naskenuj QR kód telefonem a hraj. Tabule -zobrazuje i zbylé adresy — když jedna nefunguje, zkus další. Zastavuje se -`Ctrl+C`. +nabízí i zbylé adresy — když jedna nefunguje, klikni na jinou a QR kód se +přepne na ni. Zastavuje se `Ctrl+C`. | Proměnná | K čemu je | Výchozí | |---|---|---| diff --git a/static/style.css b/static/style.css index ce95cdb..9284f3e 100644 --- a/static/style.css +++ b/static/style.css @@ -373,7 +373,7 @@ button { line-height: 1.4; } -.join .address span { +.join .address .what { display: block; font-family: var(--font-ui); font-size: 0.7rem; @@ -382,6 +382,8 @@ button { color: var(--ink-soft); } +.join .address .url { display: block; } + .qr { width: 5.5rem; height: 5.5rem; fill: var(--ink); } .idle { @@ -480,6 +482,24 @@ button { .alt li { white-space: nowrap; } +/* Adresa je tlačítko, ale nemá vypadat jako tlačítko — jen dát najevo, + že se na ni dá kliknout. */ +.alt button { + font: inherit; + color: inherit; + background: none; + border: 0; + border-bottom: 1px dotted var(--rule); + padding: 0; + cursor: pointer; +} + +.alt button:hover, +.alt button:focus-visible { + color: var(--ink); + border-bottom-color: currentColor; +} + .alt em { font-family: var(--font-ui); font-style: normal; diff --git a/templates/_join.html b/templates/_join.html index a9126c7..ee1a39c 100644 --- a/templates/_join.html +++ b/templates/_join.html @@ -1,22 +1,58 @@ -{# Kudy se na počitadlo dostane telefon. Nabídneme víc cest, vybrat si může člověk. #} -{% if primary %} +{# Kudy se na počitadlo dostane telefon. Nabídneme víc cest, vybrat si může + člověk — QR kódy jsou vykreslené všechny, přepíná se jen ten viditelný. #} +{% if choices %}
- {{ target|qr }} +
+ {% for choice in choices %} +
+ {{ choice.url|qr }} +
+ {% endfor %} +
+
- Zapisuje se z telefonu - {{ target }} - {% if others %} + Zapisuje se z telefonu + {{ choices[0].url }} + + {% if choices|length > 1 %} {% endif %}
+ + {% else %}
-

Adresu se nepodařilo zjistit +

Adresu se nepodařilo zjistit Spusť server s DICE_HOST=<adresa>.

{% endif %} diff --git a/templates/_panel.html b/templates/_panel.html index ef24f89..72195af 100644 --- a/templates/_panel.html +++ b/templates/_panel.html @@ -1,3 +1,3 @@ {# Fragment pro tabuli: obě části, které se během hry mění. #} - +
{% include "_sheet.html" %}
diff --git a/templates/board.html b/templates/board.html index a430dfc..277b751 100644 --- a/templates/board.html +++ b/templates/board.html @@ -4,7 +4,7 @@ {% block body %}
- + {% include "_join.html" %}
diff --git a/tests/test_web.py b/tests/test_web.py index b10660e..e6d28a7 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -1,5 +1,8 @@ +import re + import pytest +import net import storage import web @@ -236,3 +239,90 @@ def test_kratka_hra_nic_neuseka(client): ]) def test_sklonovani_kol(count, expected): assert web.kola(count) == expected + + +def offer(monkeypatch, *ips): + """Server nabídne přesně tyhle adresy, v tomhle pořadí.""" + found = [net.Address(ip=ip, interface="test", kind="lan", primary=not i) + for i, ip in enumerate(ips)] + monkeypatch.setattr(web.net, "addresses", lambda: found) + + +def test_tabule_nabidne_qr_ke_kazde_adrese(client, monkeypatch): + """Kódy jsou vykreslené předem, přepíná se jen ten viditelný.""" + offer(monkeypatch, "192.168.0.10", "100.91.0.24", "172.17.0.1") + game_id = start_game(client, "Adam", "Eva") + + page = text(client.get(f"/board/{game_id}")) + + assert page.count('
  • ' in page + + +def test_jedina_adresa_nema_co_prepinat(client, monkeypatch): + offer(monkeypatch, "192.168.0.10") + + page = text(client.get("/board")) + + assert '