Choose even the first region in the browser; update Docker and Nix
A node now starts without any region (it only helps others connect, and prints a hint). The owner's sign-in link leads straight to the Regions page when none is followed, visitors get a notice instead of an empty search, and status always lists regions as an array. The Docker image no longer pins Bonn, the NixOS module no longer requires regions, and the VM test now starts without any, chooses the first region over the API and checks it survives a restart. README and the init hint follow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { lang, t } from "./i18n.ts";
|
||||
import type { Listing } from "./verify.ts";
|
||||
|
||||
/** The line under the title: what the node holds and follows. */
|
||||
export function statusLine(n: { listings: number; peers: number; regions: string[] }): string {
|
||||
return t("status.line", {
|
||||
listings: n.listings,
|
||||
peers: n.peers,
|
||||
regions: n.regions.length ? n.regions.join(", ") : t("status.noRegions"),
|
||||
});
|
||||
}
|
||||
|
||||
export function money(cents: number): string {
|
||||
return new Intl.NumberFormat(lang, { style: "currency", currency: "EUR" }).format(cents / 100);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
const de = {
|
||||
"app.tagline": "Wohnungen und Häuser, getragen von allen. Kostenlos, ohne Konzern.",
|
||||
"status.line": "{listings} Anzeigen · {peers} verbundene Knoten · Regionen: {regions}",
|
||||
"status.noRegions": "noch keine",
|
||||
"search.noRegions": "Dieser Knoten folgt noch keiner Region und hat deshalb keine Anzeigen. Wer ihn betreibt, wählt Regionen unter „Meine Anzeigen“ > „Regionen“.",
|
||||
"search.chooseRegions": "Regionen wählen",
|
||||
"status.unreachable": "Dieser Knoten ist nicht erreichbar.",
|
||||
"filter.kind": "Angebot",
|
||||
"filter.category": "Art",
|
||||
@@ -277,6 +280,9 @@ const de = {
|
||||
const en: Record<keyof typeof de, string> = {
|
||||
"app.tagline": "Homes to rent and buy, run by everyone. Free, with no company behind it.",
|
||||
"status.line": "{listings} listings · {peers} connected nodes · regions: {regions}",
|
||||
"status.noRegions": "none yet",
|
||||
"search.noRegions": "This node follows no region yet, so it has no listings. Whoever runs it chooses regions under “My listings” > “Regions”.",
|
||||
"search.chooseRegions": "Choose regions",
|
||||
"status.unreachable": "This node is not reachable.",
|
||||
"filter.kind": "Offer",
|
||||
"filter.category": "Type",
|
||||
|
||||
+23
-9
@@ -1,6 +1,6 @@
|
||||
import { getListing, getStatus, search } from "./api.ts";
|
||||
import { append, clear, h } from "./dom.ts";
|
||||
import { date, price, rooms, shortKey } from "./format.ts";
|
||||
import { date, price, rooms, shortKey, statusLine } from "./format.ts";
|
||||
import { decodeGeohash } from "./geohash.ts";
|
||||
import { lang, t, type Key } from "./i18n.ts";
|
||||
import { contactPanel, showConversation, showInbox } from "./chat.ts";
|
||||
@@ -191,7 +191,19 @@ function showSearch(params: URLSearchParams): void {
|
||||
const gen = state.generation;
|
||||
clear(app);
|
||||
const results = h("div", { class: "results", "aria-live": "polite" });
|
||||
app.append(h("p", { class: "tagline" }, t("app.tagline")), searchForm(params), results);
|
||||
app.append(h("p", { class: "tagline" }, t("app.tagline")));
|
||||
if (state.node && state.node.regions.length === 0) {
|
||||
app.append(
|
||||
h(
|
||||
"p",
|
||||
{ class: "notice", role: "status" },
|
||||
t("search.noRegions"),
|
||||
" ",
|
||||
getToken() ? h("a", { href: "#/mine/regions" }, t("search.chooseRegions")) : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
app.append(searchForm(params), results);
|
||||
|
||||
const prefix = params.get("geohash")?.trim().toLowerCase();
|
||||
if (prefix && !GEOHASH_PREFIX.test(prefix)) {
|
||||
@@ -353,8 +365,14 @@ function route(): void {
|
||||
if (login) {
|
||||
// The token came in the URL fragment: keep it for this tab and take it out of the address bar.
|
||||
setToken(login[1]!);
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
if (state.node && state.node.regions.length === 0) {
|
||||
// A node that follows nothing has nothing to show: the first thing to do is choose.
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine/regions");
|
||||
showRegions();
|
||||
} else {
|
||||
history.replaceState(null, "", location.pathname + location.search + "#/mine");
|
||||
void showOwner();
|
||||
}
|
||||
} else if (m) void showDetail(m[1]!, m[2]!);
|
||||
else if (c) void showConversation(c[1]!, c[2]!, c[3]!);
|
||||
else if (path === "/messages") showInbox();
|
||||
@@ -372,11 +390,7 @@ async function boot(): Promise<void> {
|
||||
document.getElementById("foot")!.textContent = t("footer.text");
|
||||
try {
|
||||
state.node = await getStatus();
|
||||
statusEl.textContent = t("status.line", {
|
||||
listings: state.node.listings,
|
||||
peers: state.node.peers,
|
||||
regions: state.node.regions.join(", "),
|
||||
});
|
||||
statusEl.textContent = statusLine(state.node);
|
||||
} catch {
|
||||
statusEl.textContent = t("status.unreachable");
|
||||
}
|
||||
|
||||
+2
-3
@@ -6,6 +6,7 @@
|
||||
// typed for those who know them. Saving changes what the node follows at once.
|
||||
|
||||
import { append, clear, h } from "./dom.ts";
|
||||
import { statusLine } from "./format.ts";
|
||||
import { lang, t } from "./i18n.ts";
|
||||
import { Unauthorized, getToken, setRegions } from "./ownerApi.ts";
|
||||
import { biggestPlaceByCell, cellsNear, loadPlaces, searchPlaces, type Match, type Place } from "./places.ts";
|
||||
@@ -239,9 +240,7 @@ export function showRegions(message = ""): void {
|
||||
const now = await setRegions(regions);
|
||||
if (state.node) state.node.regions = now;
|
||||
const statusEl = document.getElementById("status");
|
||||
if (statusEl && state.node) {
|
||||
statusEl.textContent = t("status.line", { listings: state.node.listings, peers: state.node.peers, regions: now.join(", ") });
|
||||
}
|
||||
if (statusEl && state.node) statusEl.textContent = statusLine(state.node);
|
||||
showRegions(t("reg.saved")); // the page again, showing what is followed now
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user