diff --git a/packages/forum_forge/scripts/create_thread.lua b/packages/forum_forge/scripts/create_thread.lua new file mode 100644 index 000000000..21b9bb476 --- /dev/null +++ b/packages/forum_forge/scripts/create_thread.lua @@ -0,0 +1,73 @@ +-- forum_forge: Create Thread Component +-- Provides UI for creating new forum threads + +local M = {} + +function M.render(context) + local user = context.user or {} + + return { + type = "form", + className = "forum_forge_create_thread", + children = { + { + type = "div", + className = "card", + children = { + { + type = "h2", + className = "forum_forge_heading", + text = "Create New Thread" + }, + { + type = "input", + className = "input forum_forge_input", + name = "title", + placeholder = "Thread title...", + required = true + }, + { + type = "select", + className = "input forum_forge_select", + name = "category", + required = true, + options = { + { value = "general", label = "General Discussion" }, + { value = "support", label = "Support" }, + { value = "showcase", label = "Showcase" }, + { value = "feedback", label = "Feedback" } + } + }, + { + type = "textarea", + className = "input forum_forge_textarea", + name = "content", + placeholder = "Write your post...", + rows = 8, + required = true + }, + { + type = "div", + className = "forum_forge_actions", + children = { + { + type = "button", + className = "button forum_forge_button", + text = "Create Thread", + action = "forum.thread.create" + }, + { + type = "button", + className = "button forum_forge_button_secondary", + text = "Cancel", + action = "forum.cancel" + } + } + } + } + } + } + } +end + +return M diff --git a/packages/forum_forge/scripts/thread_list.lua b/packages/forum_forge/scripts/thread_list.lua new file mode 100644 index 000000000..1294ed9ad --- /dev/null +++ b/packages/forum_forge/scripts/thread_list.lua @@ -0,0 +1,89 @@ +-- forum_forge: Thread List Component +-- Displays threads in a category with moderation controls + +local M = {} + +function M.render(context) + local threads = context.threads or { + { id = 1, title = "Welcome to the forum!", author = "Admin", replies = 12, views = 245, pinned = true }, + { id = 2, title = "How do I get started?", author = "NewUser", replies = 5, views = 89, pinned = false }, + { id = 3, title = "Feature request: Dark mode", author = "User123", replies = 23, views = 156, pinned = false }, + { id = 4, title = "Bug report: Login issues", author = "TestUser", replies = 3, views = 45, pinned = false } + } + + local user = context.user or {} + local isModerator = user.level and user.level >= 3 + + local threadItems = {} + for _, thread in ipairs(threads) do + local threadChildren = { + { + type = "div", + className = "forum_forge_thread_info", + children = { + { + type = "h3", + className = "forum_forge_thread_title", + text = (thread.pinned and "📌 " or "") .. thread.title + }, + { + type = "span", + className = "forum_forge_thread_author", + text = "by " .. thread.author + } + } + }, + { + type = "div", + className = "forum_forge_thread_stats", + children = { + { + type = "span", + text = thread.replies .. " replies" + }, + { + type = "span", + text = thread.views .. " views" + } + } + } + } + + if isModerator then + table.insert(threadChildren, { + type = "div", + className = "forum_forge_mod_actions", + children = { + { + type = "button", + className = "button forum_forge_button_small", + text = "Pin", + action = "forum.moderate.pin", + data = { threadId = thread.id } + }, + { + type = "button", + className = "button forum_forge_button_small", + text = "Lock", + action = "forum.moderate.lock", + data = { threadId = thread.id } + } + } + }) + end + + table.insert(threadItems, { + type = "div", + className = "card forum_forge_thread", + children = threadChildren + }) + end + + return { + type = "div", + className = "forum_forge_thread_list", + children = threadItems + } +end + +return M diff --git a/packages/forum_forge/scripts/view_categories.lua b/packages/forum_forge/scripts/view_categories.lua new file mode 100644 index 000000000..efe653cc8 --- /dev/null +++ b/packages/forum_forge/scripts/view_categories.lua @@ -0,0 +1,68 @@ +-- forum_forge: View Categories Component +-- Displays forum categories and thread counts + +local M = {} + +function M.render(context) + local categories = context.categories or { + { id = "general", name = "General Discussion", threads = 42, posts = 156 }, + { id = "support", name = "Support", threads = 28, posts = 94 }, + { id = "showcase", name = "Showcase", threads = 15, posts = 73 }, + { id = "feedback", name = "Feedback", threads = 8, posts = 31 } + } + + local categoryItems = {} + for _, cat in ipairs(categories) do + table.insert(categoryItems, { + type = "div", + className = "card forum_forge_category", + children = { + { + type = "h3", + className = "forum_forge_category_name", + text = cat.name + }, + { + type = "div", + className = "forum_forge_stats", + children = { + { + type = "span", + text = cat.threads .. " threads" + }, + { + type = "span", + text = cat.posts .. " posts" + } + } + }, + { + type = "button", + className = "button forum_forge_button", + text = "View Threads", + action = "forum.view.category", + data = { categoryId = cat.id } + } + } + }) + end + + return { + type = "div", + className = "forum_forge_categories", + children = { + { + type = "h2", + className = "forum_forge_heading", + text = "Forum Categories" + }, + { + type = "div", + className = "forum_forge_category_list", + children = categoryItems + } + } + } +end + +return M