worldwide todo list: public todo list of 68 real, sourced problems (planet to street) at /projects/worldwide-todo. worldtodo schema (categories, tasks, change_requests), idempotent seed on deploy, public add/edit/delete requests with Turnstile + salted daily-rotating IP-hash rate limit, owner-only review queue (approve, edit & approve, reject) with live updates over /ws/worldtodo(-owner), JSON API, detail pages with OSM map and history; listed in projects, header, /start and sitemap
Some checks failed
Deploy production / deploy (push) Failing after 9s
Some checks failed
Deploy production / deploy (push) Failing after 9s
This commit is contained in:
35
src/routes/projects/worldwide-todo/+page.server.ts
Normal file
35
src/routes/projects/worldwide-todo/+page.server.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { counts, listTasks, type Sort } from '#lib/server/worldtodo/store.js';
|
||||
import { WORLDTODO_SCALES } from '#lib/worldtodo/shared.js';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
const STATUSES = ['todo', 'open', 'in_progress', 'done', 'all'];
|
||||
const SORTS: Sort[] = ['updated', 'scale', 'title'];
|
||||
|
||||
// Filters live in the query string (shareable, SSR, works without JS). A GET form submits
|
||||
// toggle buttons that come before hidden copies of the current values, so the first value of
|
||||
// each name wins.
|
||||
export const load: PageServerLoad = async ({ url, parent }) => {
|
||||
const first = (key: string) => url.searchParams.getAll(key)[0]?.trim() ?? '';
|
||||
const { categories } = await parent();
|
||||
const scale = (WORLDTODO_SCALES as readonly string[]).includes(first('scale'))
|
||||
? first('scale')
|
||||
: '';
|
||||
const category = categories.some((c) => c.slug === first('category')) ? first('category') : '';
|
||||
const status = STATUSES.includes(first('status')) ? first('status') : 'todo';
|
||||
const sort = (SORTS as string[]).includes(first('sort')) ? (first('sort') as Sort) : 'updated';
|
||||
const q = first('q').slice(0, 100);
|
||||
const filter = { scale, category, status, q };
|
||||
const [list, totals] = await Promise.all([listTasks(filter, sort, 500), counts(filter)]);
|
||||
return {
|
||||
filter,
|
||||
sort,
|
||||
tasks: list.tasks,
|
||||
counts: totals,
|
||||
seo: {
|
||||
title: 'The worldwide todo list',
|
||||
description:
|
||||
'A public todo list of real, sourced problems, from planet-scale to a single street. Anyone can suggest additions, edits and removals.',
|
||||
index: !scale && !category && status === 'todo' && !q && sort === 'updated'
|
||||
}
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user