!7 static double aiConceptsCacheInterval = 60; concept Search { S q, ip; } p { db(); } html { print("Wiki URI: " + uri); uri = dropSuffix("/", uri); uri = dropPrefix("/", uri); S q = trim(params.get("q")); if (nempty(q)) cnew(Search, +q, ip := getClientIP()); if (eq(uri, "import")) { triggerStandardAIImport(); ret "OK"; } aiConceptsMap_clearCache(aiConceptsCacheInterval); final Map map = aiConceptsMap_cached(); if (possibleGlobalID(uri)) { // Serve concept final AIConcept c = map.get(toLower(uri)); if (c == null) ret "Concept not found: " + toLower(uri); S html = htitle(c.name + " [" + (nempty(c.comment) ? c.comment + " / " : "") + c.globalID + "]") + h2(htmlencode(aiConceptToString(c))); html += ul( "Image MD5: " + htmlencode(c.imageMD5) ); if (nempty(c.imageMD5) && imageServerHas(c.imageMD5)) html += p(himg(imageServerLink(c.imageMD5))); //L statements = [S s : trueStatements_cached() | containsIgnoreCase(s, c.globalID)]; L statements = [Statement s : loadTruth_cached() | containsIgnoreCase(s.text, c.globalID)]; if (nempty(statements)) html += h3("Statements about this") + ul(map(f statementToHTML, statements)); html += p(ahref("http://ai1.lol/wiki", "[All Concepts]")); ret html; } L l = sortedByFieldDesc(values(map), "imported"); S search = p("Search (coming up)") + hform(htextinput("q", "") + " " + hsubmit("Search")); S line = "See " + ahref("https://www.youtube.com/watch?v=gTlgZkc95IU", "Video") + "." + (webAuthed() ? " " + ahref("/wiki/import", "Import.") : ""); S concepts = ul(map(func(AIConcept c) { ahref("http://ai1.lol/" + c.globalID, htmlencode(c.globalID)) + " - " + htmlencode(aiConceptToString2(c)) }, l)); S relations = ul(map(f statementToHTML, reversed(loadTruth_cached()))); ret htitle("Intelligence Machine") + hcenter2( p(hTBImage(#1007526, "title", "Intelligence Machine")) + search) + p(line) + htableRaw(ll(ll( h3("Concepts") + concepts, h3("Relations") + relations)), "border", "0"); } static S statementToHTML(Statement s) { ret htmlencode(s.text + " - " + or2(s.possibleEnglishTranslation, "?")); }