O serveOtherPage2(Req req) null { new Matches m; if (eq(req.uri, "/latestPost")) { UserPost post = highestConceptByField UserPost("created"); if (post == null) ret serve404("No posts in database"); ret servePost(post); } if (eq(req.uri, "/latestModifiedPost")) { UserPost post = highestConceptByField UserPost("_modified"); if (post == null) ret serve404("No posts in database"); ret servePost(post); } if (eq(req.uri, "/rootPosts")) { Cl posts = sortedByConceptIDDesc(filter(list(UserPost), post -> empty(post.postRefs))); framer().navBeforeTitle = true; framer().title = "Root Posts"; framer().add(ul(lmap postToHTMLWithDate(posts))); ret framer().render(); } if (eq(req.uri, "/allPosts")) { Cl posts = sortedByConceptIDDesc(list(UserPost)); framer().navBeforeTitle = true; framer().title = "All Posts"; framer().add(ul(lmap postToHTMLWithDate(posts))); ret framer().render(); } if (eq(req.uri, "/latestPosts")) { Cl posts = takeFirst(50, sortedByConceptIDDesc(list(UserPost))); framer().navBeforeTitle = true; framer().title = "Latest Posts & Replies"; framer().add(ul(lmap postToHTMLWithDate(posts))); ret framer().render(); } if (swic(req.uri, "/html/", m) && isInteger(m.rest())) { long id = parseLong(m.rest()); UserPost post = getConcept UserPost(id); if (post == null) ret serve404("Post not found"); ret post.text; } if (swic(req.uri, "/css/", m) && isInteger(m.rest())) { long id = parseLong(m.rest()); UserPost post = getConcept UserPost(id); if (post == null) ret serve404("Post not found"); ret serveWithContentType(post.text, "text/css"); } if (eq(req.uri, "/search")) { framer().navBeforeTitle = true; framer().title = "Search"; S q = trim(req.params.get("q")); framer().add(hform(hinputfield(+q) + " " + hsubmit("Search"))); framer().add(p(small("Search help: If you search for multiple words, they can appear in any order in the text. An underscore matches any character. Plus means space. Post titles, texts and types are searched."))); if (nempty(q)) { ScoredSearcher searcher = new(q); for (UserPost post) searcher.add(post, searcher.score(post.title)*3 + searcher.score(post.text)*2 + searcher.score(post.type)); L posts = searcher!; framer().add(p(b(addPlusToCount(searcher.maxResults, l(posts), nPosts(posts)) + " found for " + htmlEncode2(q)))); framer().add(ul(lmap postToHTMLWithDate(posts))); } ret framer().render(); } if (swic(req.uri, "/bot/")) { S userName = req.params.get("_user"); if (userName == null) ret serveJSON(error := "Need _user"); S botToken = req.params.get("_botToken"); if (botToken == null) ret serveJSON(error := "Need _botToken"); User user = conceptWhere User(name := userName); if (user == null) ret serveJSON(error := "User not found"); if (!eq(botToken, getVar(user.botToken))) ret serveJSON(error := "Wrong bot token"); ret serveJSON(status := "OK, logged in"); } }