feat: Dahoam start page with accounts, cards and search
images / check (push) Successful in 27s
images / image (push) Successful in 32s

Replica of the reference start page: wallpaper, serif clock, search bar
and link cards, as a TanStack Start app.

- Better Auth: email/password and OIDC single sign-on
- Postgres with Drizzle for the auth tables, cards, links, settings and
  uploaded wallpapers; the server applies the migrations on start
- cards group links; links are dragged inside and between cards
- search with DuckDuckGo, SearXNG or Google, suggestions and / commands
- settings page: name, search engine, wallpaper, account
- UI from collabry-components, copied into src/vendor/collabry
- Dockerfile and a Gitea workflow that checks the code, builds the image
  for amd64 and arm64 and pushes it to the registry on main
This commit is contained in:
Niklas Haiden
2026-11-18 00:09:19 +01:00
parent 54914e8e03
commit 8df74a849c
80 changed files with 9642 additions and 1572 deletions
+50
View File
@@ -0,0 +1,50 @@
// Where links sit in their cards. Pure, so drag and drop can be tested without a browser.
type Card = { id: string; links: { id: string }[] }
/** The card with this id, or the card that holds the link with this id. */
const cardOf = <TCard extends Card>(cards: TCard[], id: string) =>
cards.find((c) => c.id === id || c.links.some((l) => l.id === id))
/** While dragging: a link that hovers over another card moves into that card. */
export function moveOver<TCard extends Card>(
cards: TCard[],
linkId: string,
overId: string
): TCard[] {
const from = cardOf(cards, linkId)
const to = cardOf(cards, overId)
const link = from?.links.find((l) => l.id === linkId)
if (!from || !to || !link || from === to) return cards
// over a link: take its place. Over the card itself: go to the end.
const overIndex = to.links.findIndex((l) => l.id === overId)
const at = overIndex < 0 ? to.links.length : overIndex
return cards.map((c) =>
c === from
? { ...c, links: c.links.filter((l) => l !== link) }
: c === to
? { ...c, links: [...c.links.slice(0, at), link, ...c.links.slice(at)] }
: c
)
}
/** On drop: the link takes the place of the link it was dropped on. */
export function drop<TCard extends Card>(
cards: TCard[],
linkId: string,
overId: string
): TCard[] {
const moved = moveOver(cards, linkId, overId)
if (moved !== cards) return moved // it changed cards, that put it in place
const card = cardOf(cards, linkId)
const from = card?.links.findIndex((l) => l.id === linkId) ?? -1
const to = card?.links.findIndex((l) => l.id === overId) ?? -1
if (!card || from < 0 || to < 0 || from === to) return cards
const links = [...card.links]
links.splice(to, 0, ...links.splice(from, 1))
return cards.map((c) => (c === card ? { ...c, links } : c))
}
/** What the server stores: per card, its link ids in order. */
export const order = (cards: Card[]) =>
cards.map((c) => ({ id: c.id, linkIds: c.links.map((l) => l.id) }))