diff --git a/models/event.ts b/models/event.ts index 19880ae..3d82fbd 100644 --- a/models/event.ts +++ b/models/event.ts @@ -37,13 +37,34 @@ type TOPIC_EVENT_CACHE_ENTRY = { eviction_timeout: number; }; +const TOPIC_EVENT_ID_MATCHER = /^(?.*):(?.*)$/; + const TOPIC_EVENTS: Record = {}; export function get_events_collection_for_topic(topic_id: string): FSDB_COLLECTION { TOPIC_EVENTS[topic_id] = TOPIC_EVENTS[topic_id] ?? { collection: new FSDB_COLLECTION({ name: `topics/${topic_id.slice(0, 14)}/${topic_id.slice(0, 34)}/${topic_id}/events`, id_field: 'id', - organize: by_lurid, + organize: (id) => { + TOPIC_EVENT_ID_MATCHER.lastIndex = 0; + + const { + groups: { + event_type, + event_id + } + } = TOPIC_EVENT_ID_MATCHER.exec(id ?? '') ?? { + groups: {} + }; + + return [ + event_type, + event_id.slice(0, 14), + event_id.slice(0, 34), + event_id, + `${event_id}.json` + ]; + }, indexers: { creator_id: new FSDB_INDEXER_SYMLINKS({ name: 'creator_id', diff --git a/public/api/topics/:topic_id/events/index.ts b/public/api/topics/:topic_id/events/index.ts index 20e5dc8..e8fd120 100644 --- a/public/api/topics/:topic_id/events/index.ts +++ b/public/api/topics/:topic_id/events/index.ts @@ -56,7 +56,12 @@ export async function GET(request: Request, meta: Record): Promise< limit: Math.min(parseInt(meta.query?.limit ?? '10'), 1_000), sort, filter: (entry: WALK_ENTRY) => { - const [event_id, event_type] = path.basename(entry.path).replace(/\.json$/i, '').split(':'); + const { + groups: { + event_type, + event_id + } + } = /^.*\/events\/(?.*?)\/.*\/(?[A-Za-z-]+)\.json$/.exec(entry.path) ?? { groups: {} }; if (meta.query.after_id && event_id <= meta.query.after_id) { return false; @@ -165,7 +170,7 @@ export async function POST(req: Request, meta: Record): Promise hlen) { + return false; + } + if (nlen === hlen) { + return needle === haystack; + } + outer: for (var i = 0, j = 0; i < nlen; i++) { + var nch = needle.charCodeAt(i); + while (j < hlen) { + if (haystack.charCodeAt(j++) === nch) { + continue outer; + } + } + return false; + } + return true; +} + +module.exports = fuzzysearch; diff --git a/public/js/notifications.js b/public/js/notifications.js new file mode 100644 index 0000000..55d39ff --- /dev/null +++ b/public/js/notifications.js @@ -0,0 +1,18 @@ +const NOTIFICATIONS = { + send: function (message, options = {}) { + if (!Notification || Notification.permission !== "granted") { + return; + } + + const notification = new Notification(message, options); + return notification; + }, + + request_permissions: function () { + if (Notification && Notification.permission === "granted") { + return; + } + + Notification.requestPermission(); + }, +}; diff --git a/public/tabs/chat/chat.css b/public/tabs/chat/chat.css index 555c53e..e557302 100644 --- a/public/tabs/chat/chat.css +++ b/public/tabs/chat/chat.css @@ -60,15 +60,8 @@ } #chat #topic-chat-entry-container form textarea { - width: 100%; flex-grow: 1; - background: inherit; - color: inherit; - border-radius: var(--border-radius); - border: 1px solid rgba(128, 128, 128, 0.2); resize: none; - background: rgba(0, 0, 0, 0.1); - padding: 0.4rem; } #chat .message-container { @@ -84,8 +77,9 @@ #chat .message-container.user-tick.time-tock + .message-container.user-tick.time-tock, #chat .message-container.user-tock.time-tick + .message-container.user-tock.time-tick, #chat .message-container.user-tock.time-tock + .message-container.user-tock.time-tock { + padding-top: 0; + padding-bottom: 0; margin-top: 0; - padding: 0 2px; } #chat diff --git a/public/tabs/essays/README.md b/public/tabs/essays/README.md index d97ef9b..f3b0fe4 100644 --- a/public/tabs/essays/README.md +++ b/public/tabs/essays/README.md @@ -1,3 +1,4 @@ # Essays -Essays are long-form, authored posts intended to be effectively, a broadcast. +Essays are long-form, authored posts intended to be less a conversation +and more a broadcast. diff --git a/public/tabs/forum/forum.html b/public/tabs/forum/forum.html index f3f4f70..27d3d72 100644 --- a/public/tabs/forum/forum.html +++ b/public/tabs/forum/forum.html @@ -16,8 +16,165 @@
Forum
- +
+ +
+ + +
diff --git a/public/tabs/resources/README.md b/public/tabs/resources/README.md index 2771877..dcd6aa4 100644 --- a/public/tabs/resources/README.md +++ b/public/tabs/resources/README.md @@ -1,3 +1,3 @@ # Resources -Resources should be a wiki for organizing community knowledge. +Resources should be a wiki for organizing community knowledge on a topic.