!7
p { ai_spec_init(); }
html {
bool authed = creatorAuthed();
S _topic = params.get("topic");
if (empty(_topic))
_topic = ai_randomString();
fS topic = _topic;
if (nempty(params.get("topic"))) { // not from "random topic" url
// post user's answers (verified or unverified)
// free-text line
S newCat = params.get("new-cat"), newValue = params.get("new-value");
if (nempty(newCat)) {
S verb = ai_matrix_answerToVerb(newValue);
if (nempty(verb))
post(topic, verb, newCat);
else
post(quote(newCat), " is a matrix category for", topic);
}
// all other lines
for (S key : keysStartingWith2(params, "cat-")) {
S value = params.get(key);
continue if empty(value);
S verb = ai_matrix_answerToVerb(value);
continue if empty(verb);
S cat = urldecode(dropPrefix("cat-", key));
temp tempSetThreadLocal(ai_postTriple_verified, authed);
post(topic, verb, cat);
}
}
L functions = ai_matrix_standardFunctions();
SS results = mapValues(f struct, evaluateFunctionsAsMap(functions, topic));
final L answers = concatLists(ll(""), ai_matrix_standardAnswers());
Set options = ai_matrix_categoriesForTopic(topic);
options.addAll(ai_matrix_standardCategories());
L