!7 static S text; concept Text { S conceptID; S text; S by; } p { db(); indexConceptField(Text, 'conceptID); indexConceptField(Text, 'by); load("text"); if (isMainProgram()) serveHttpAndOpenBrowser(); } synchronized html { uri = dropPrefix("/", uri); if (isPossibleGlobalID(uri)) { S id = uri; Text t = findConcept(Text, conceptID := id); ret t == null ? "Text with ID " + id + " not found" : h3(t.concept) + pre(dynamize(t.text)) + p("by " + t.by); } S newText = params.get("text"); if (newText != null) { text = newText; save("text"); } S user = cast call(getBot(#1007510), "conceptIDForCookie"); S msg = ""; if (nempty(params.get("publish"))) { Text t = uniq_sync(Text, text := text, by := user); cset(t, conceptID := aGlobalID()); msg = "Published as: " + t.conceptID; } S list = p("Published texts: " + join(", ", collect(list(Text), 'conceptID))); ret (empty(msg) ? "" : p(msg)) + list + p("You are: " + or2(user, "?")) + hpostform([[
|
#TEXT#
|
|
|