Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/garda/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
footer { color: var(--muted); font-size: 11px; margin-top: 32px; line-height: 1.6; }
footer a { color: var(--muted); }
</style>
{% if cf_beacon_token %}<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "{{ cf_beacon_token }}"}'></script>{% endif %}
{% if manual_analytics and cf_beacon_token %}<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "{{ cf_beacon_token }}"}'></script>{% endif %}
</head>
<body>

Expand Down Expand Up @@ -266,7 +266,7 @@
{{ tr("footer_license_prefix") }}
<a href="https://github.com/s1st/garda-oracle/blob/main/LICENSE"
target="_blank" rel="license noopener">{{ tr("footer_license_name") }}</a>.
{% if cf_beacon_token %}<br>{{ tr("footer_analytics") }}{% endif %}
{% if manual_analytics and cf_beacon_token %}<br>{{ tr("footer_analytics") }}{% endif %}
</footer>
<script>
document.querySelectorAll("[data-dialog-id]").forEach(function (tile) {
Expand Down
1 change: 1 addition & 0 deletions src/garda/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def _page_context(request: Request, active: str, **values) -> dict:
"langs": SUPPORTED_LANGS,
"current_path": request.url.path,
"show_personal_link": not pseudonymous,
"manual_analytics": pseudonymous,
"walchensee_url": (
"https://walchensee.s1st.de" if pseudonymous else "https://walchensee.simon-stieber.de"
),
Expand Down
11 changes: 11 additions & 0 deletions tests/test_garda.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ async def no_live_data():
monkeypatch.setattr(web, "_forecast_points", no_forecast)
monkeypatch.setattr(web, "_live_torbole", no_live_data)
monkeypatch.setattr(web, "build_day_features", lambda points, day: None)
monkeypatch.setitem(web.templates.env.globals, "cf_beacon_token", "test-site-token")

client = TestClient(web.app)
r = client.get("/go/reddit", headers={"host": "garda.s1st.de"})
Expand All @@ -174,12 +175,22 @@ async def no_live_data():
assert "https://walchensee.s1st.de/" in r.text
assert "Simon Stieber" not in r.text
assert "simon-stieber.de" not in r.text
assert "https://static.cloudflareinsights.com/beacon.min.js" in r.text
assert '"token": "test-site-token"' in r.text

model_page = client.get("/modell", headers={"host": "garda.s1st.de"})
assert model_page.status_code == 200
assert "https://walchensee.s1st.de/stats" in model_page.text
assert "simon-stieber.de" not in model_page.text

real_name_page = client.get(
"/",
headers={"host": "garda.simon-stieber.de", "X-Gate-Secret": "s3cret"},
)
assert real_name_page.status_code == 200
assert "https://static.cloudflareinsights.com/beacon.min.js" not in real_name_page.text
assert "test-site-token" not in real_name_page.text


def test_unknown_campaign_landing_path_is_not_found(monkeypatch):
monkeypatch.delenv("GARDA_GATE_SECRET", raising=False)
Expand Down