Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: updateSpeaker Arguments: name,url,imageUrl,tags,summary,biography,keynotes,long,boost Description: Page type: webl Render function: Module: speakaboutai Page source: var addPerson = fun(person, create) var ok = true; // create is false, add to existing index. "standard" analysis (no stemming). For stemming: "kstem" and "english" (porter) var writer = Wub_NewLuceneIndex("speakers", create, "standard"); var doc = Wub_NewLuceneDocument(); // Add fields to doc var default = "AI "; var boost = 0; every field in ToList(person) do var s = (person[field] ? ""); ok = ok and Wub_AddLuceneField(doc, field, s, true, true, 0); // 0 = no special boost default = default + " " + s; if field == "boost" then boost = (ToInt(person[field]) ? 0) end end; ok = ok and Wub_AddLuceneField(doc, "default", default, true, true, boost); ok = ok and Wub_AddLuceneDocument(writer, doc); ok = ok and Wub_OptimizeLucene(writer); ok = ok and Wub_CloseLuceneIndex(writer); end; var fSpeakers = Wub_GetFunctionInfo("speakaboutai.speakerslist"); var fTags = Wub_GetFunctionInfo("speakaboutai.tagslist"); var Speakers = WubCall("speakaboutai.speakerslist", []); var sTags = []; var theSpeaker = [. .]; var rest = []; every speaker in Speakers do sTags = sTags + Str_Split(speaker.tags, ","); if name == speaker.name then theSpeaker = speaker; else rest = rest + [speaker] end; end; var lTags = []; every tag in sTags do lTags = lTags + [Str_Trim(tag)] end; theSpeaker.name := name; theSpeaker.url := url; theSpeaker.imageUrl := imageUrl; theSpeaker.tags := tags; theSpeaker.summary := Wub_ReplaceAll(summary, `"`, `'`); theSpeaker.biography := Wub_ReplaceAll(biography, `"`, `'`); theSpeaker.keynotes := Wub_ReplaceAll(keynotes, `"`, `'`); theSpeaker.long := Wub_ReplaceAll(long, `"`, `'`); theSpeaker.boost := boost; // Re-create lucene index addPerson(theSpeaker, true); every speaker in rest do addPerson(speaker, false); end; rest = [theSpeaker] + rest; fSpeakers.exec := ToString(rest); Wub_SaveFunctionInfo(fSpeakers); fTags.exec := ToString(Sort(ToList(ToSet(lTags)), fun(a,b) if (Str_ToLowerCase(a) > Str_ToLowerCase(b)) then 1 elsif (Str_ToLowerCase(a) == Str_ToLowerCase(b)) then 0 else -1 end end )) + ";"; Wub_SaveFunctionInfo(fTags); var P = NewPage(Markup(WubCall("speakaboutai.searchtools", [])), "text/html");