mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-09-29 23:10:52 +00:00
Personal_wikis: Add search-indexing and auto-page rescan
This commit is contained in:
parent
451c504166
commit
01fbd21c6e
@ -30,7 +30,7 @@ class Xobc_task_html extends Xow_special_wtr__base {
|
|||||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__mustache (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__mustache (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__jquery (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__jquery (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__notifyjs (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__xonotify (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ class Xobc_task_html extends Xow_special_wtr__base {
|
|||||||
head_tags.Add(Xopg_tag_itm.New_htm_frag(addon_dir.GenSubFil_nest("bin", "xobc.row.mustache.html"), "xobc.row"));
|
head_tags.Add(Xopg_tag_itm.New_htm_frag(addon_dir.GenSubFil_nest("bin", "xobc.row.mustache.html"), "xobc.row"));
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.elem.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.elem.js")));
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.tmpl.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.tmpl.js")));
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.notify.js")));
|
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.util.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.util.js")));
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xobc.js")));
|
||||||
}
|
}
|
||||||
|
@ -30,15 +30,17 @@ public class Xowdir_item_bridge implements Bridge_cmd_itm {
|
|||||||
switch (proc_id) {
|
switch (proc_id) {
|
||||||
case Proc__save: itm_mgr.Save(args); break;
|
case Proc__save: itm_mgr.Save(args); break;
|
||||||
case Proc__delete: itm_mgr.Delete(args); break;
|
case Proc__delete: itm_mgr.Delete(args); break;
|
||||||
|
case Proc__reindex_search: itm_mgr.Reindex_search(args); break;
|
||||||
default: throw Err_.new_unhandled_default(proc_id);
|
default: throw Err_.new_unhandled_default(proc_id);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final byte Proc__save = 0, Proc__delete = 1;
|
private static final byte Proc__save = 0, Proc__delete = 1, Proc__reindex_search = 2;
|
||||||
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
|
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
|
||||||
.Add_str_byte("save" , Proc__save)
|
.Add_str_byte("save" , Proc__save)
|
||||||
.Add_str_byte("delete" , Proc__delete)
|
.Add_str_byte("delete" , Proc__delete)
|
||||||
|
.Add_str_byte("reindex_search" , Proc__reindex_search)
|
||||||
;
|
;
|
||||||
|
|
||||||
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("wiki.directory.item");
|
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("wiki.directory.item");
|
||||||
|
@ -39,6 +39,8 @@ class Xowdir_item_html extends Xow_special_wtr__base {
|
|||||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
||||||
|
Xopg_tag_wtr_.Add__jquery (head_tags, app.Fsys_mgr().Http_root());
|
||||||
|
Xopg_tag_wtr_.Add__xonotify (head_tags, app.Fsys_mgr().Http_root());
|
||||||
Xopg_alertify_.Add_tags (head_tags, app.Fsys_mgr().Http_root());
|
Xopg_alertify_.Add_tags (head_tags, app.Fsys_mgr().Http_root());
|
||||||
|
|
||||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xowdir_item.css")));
|
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xowdir_item.css")));
|
||||||
|
@ -96,6 +96,25 @@ class Xowdir_item_mgr {
|
|||||||
// navigate back to wiki_directory
|
// navigate back to wiki_directory
|
||||||
app.Gui__cbk_mgr().Send_redirect(cbk_trg, "/site/home/wiki/Special:XowaWikiDirectory");
|
app.Gui__cbk_mgr().Send_redirect(cbk_trg, "/site/home/wiki/Special:XowaWikiDirectory");
|
||||||
}
|
}
|
||||||
|
public void Reindex_search(Json_nde args) {
|
||||||
|
String domain = args.Get_as_str("domain");
|
||||||
|
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgri().Get_by_or_null(Bry_.new_u8(domain));
|
||||||
|
|
||||||
|
// update page count; needed else search cannot generate correct ranges when normalizing search_scores
|
||||||
|
int page_count = wiki.Data__core_mgr().Tbl__page().Select_count_all();
|
||||||
|
if (page_count == -1) {
|
||||||
|
Gfo_usr_dlg_.Instance.Warn_many("", "", "negative page count while reindexing search; domain=~{0}", domain);
|
||||||
|
}
|
||||||
|
wiki.Data__core_mgr().Db__core().Tbl__site_stats().Update(page_count, page_count, 0);
|
||||||
|
wiki.Data__core_mgr().Db__core().Tbl__site_stats().Select(wiki.Stats());
|
||||||
|
|
||||||
|
// run reindexer
|
||||||
|
gplx.xowa.addons.wikis.searchs.bldrs.Srch_bldr_mgr_.Setup(wiki);
|
||||||
|
app.Bldr().Run();
|
||||||
|
|
||||||
|
// send notify
|
||||||
|
app.Gui__cbk_mgr().Send_notify(cbk_trg, "search reindex done");
|
||||||
|
}
|
||||||
private String Validate(Xoa_app app, Xowdir_db_mgr db_mgr, boolean itm_is_new, String domain, String name, Io_url dir_url, String mainpage_name) {
|
private String Validate(Xoa_app app, Xowdir_db_mgr db_mgr, boolean itm_is_new, String domain, String name, Io_url dir_url, String mainpage_name) {
|
||||||
// domain
|
// domain
|
||||||
if (itm_is_new) {
|
if (itm_is_new) {
|
||||||
|
@ -26,6 +26,7 @@ class Fs_root_wkr {
|
|||||||
private Db_conn conn; private Db_cfg_tbl cfg_tbl;
|
private Db_conn conn; private Db_cfg_tbl cfg_tbl;
|
||||||
private Orig_fil_tbl orig_tbl;
|
private Orig_fil_tbl orig_tbl;
|
||||||
private int fil_id_next = 0;
|
private int fil_id_next = 0;
|
||||||
|
private long scan_time_prv = gplx.core.envs.System_.Ticks();
|
||||||
public Orig_fil_tbl Orig_tbl() {return orig_tbl;}
|
public Orig_fil_tbl Orig_tbl() {return orig_tbl;}
|
||||||
public void Init(Xof_img_wkr_query_img_size img_size_wkr, Io_url orig_dir) {
|
public void Init(Xof_img_wkr_query_img_size img_size_wkr, Io_url orig_dir) {
|
||||||
this.img_size_wkr = img_size_wkr;
|
this.img_size_wkr = img_size_wkr;
|
||||||
@ -39,7 +40,17 @@ class Fs_root_wkr {
|
|||||||
// not in db; get from fsys
|
// not in db; get from fsys
|
||||||
if (rv == null) {
|
if (rv == null) {
|
||||||
rv = Get_from_fs(lnki_ttl);
|
rv = Get_from_fs(lnki_ttl);
|
||||||
if (rv == null) return Orig_fil_row.Null;
|
if (rv == null) {
|
||||||
|
// HACK: if failed and not much time has passed, try rescanning the entire fs again; need to change to filesystem watcher
|
||||||
|
long scan_time_cur = gplx.core.envs.System_.Ticks();
|
||||||
|
if (gplx.core.envs.System_.Ticks__elapsed_in_sec(scan_time_prv) > 10) {
|
||||||
|
fs_fil_mgr = Init_fs_fil_mgr();
|
||||||
|
rv = Get_from_fs(lnki_ttl);
|
||||||
|
scan_time_prv = gplx.core.envs.System_.Ticks();
|
||||||
|
}
|
||||||
|
if (rv == null)
|
||||||
|
return Orig_fil_row.Null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cache.Add(rv);
|
cache.Add(rv);
|
||||||
}
|
}
|
||||||
|
@ -32,4 +32,7 @@ public class Xog_cbk_mgr { // INSTANCE:app
|
|||||||
public void Send_redirect(Xog_cbk_trg trg, String url) {
|
public void Send_redirect(Xog_cbk_trg trg, String url) {
|
||||||
this.Send_json(trg, "xo.server.redirect__recv", gplx.core.gfobjs.Gfobj_nde.New().Add_str("url", url));
|
this.Send_json(trg, "xo.server.redirect__recv", gplx.core.gfobjs.Gfobj_nde.New().Add_str("url", url));
|
||||||
}
|
}
|
||||||
|
public void Send_notify(Xog_cbk_trg trg, String text) {
|
||||||
|
this.Send_json(trg, "xo.notify.show__recv", gplx.core.gfobjs.Gfobj_nde.New().Add_str("text", text).Add_str("status", "success"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,6 +245,7 @@ public class Xowd_page_tbl implements Db_tbl {
|
|||||||
}
|
}
|
||||||
finally {rdr.Rls();}
|
finally {rdr.Rls();}
|
||||||
}
|
}
|
||||||
|
public int Select_count_all() {return conn.Exec_select_count_as_int(tbl_name, -1);}
|
||||||
private Db_rdr Load_ttls_starting_with_rdr(int ns_id, byte[] ttl_frag, boolean include_redirects, int max_results, int min_page_len, int browse_len, boolean fwd, boolean search_suggest) {
|
private Db_rdr Load_ttls_starting_with_rdr(int ns_id, byte[] ttl_frag, boolean include_redirects, int max_results, int min_page_len, int browse_len, boolean fwd, boolean search_suggest) {
|
||||||
String ttl_frag_str = String_.new_u8(ttl_frag);
|
String ttl_frag_str = String_.new_u8(ttl_frag);
|
||||||
Criteria crt_ttl = fwd ? Db_crt_.New_mte(fld_title, ttl_frag_str) : Db_crt_.New_lt(fld_title, ttl_frag_str);
|
Criteria crt_ttl = fwd ? Db_crt_.New_mte(fld_title, ttl_frag_str) : Db_crt_.New_lt(fld_title, ttl_frag_str);
|
||||||
|
@ -45,6 +45,11 @@ public class Xopg_tag_wtr_ {
|
|||||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoelem");
|
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoelem");
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.elem.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.elem.js")));
|
||||||
}
|
}
|
||||||
|
public static void Add__xonotify(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||||
|
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xonotify");
|
||||||
|
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "notifyjs", "notifyjs-0.3.1.js")));
|
||||||
|
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.notify.js")));
|
||||||
|
}
|
||||||
public static void Add__xoajax(Xopg_tag_mgr head_tags, Io_url http_root, Xoa_app app) {
|
public static void Add__xoajax(Xopg_tag_mgr head_tags, Io_url http_root, Xoa_app app) {
|
||||||
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoajax");
|
Io_url dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xoajax");
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.app.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(dir.GenSubFil_nest("xo.app.js")));
|
||||||
@ -67,7 +72,4 @@ public class Xopg_tag_wtr_ {
|
|||||||
public static void Add__jquery(Xopg_tag_mgr head_tags, Io_url http_root) {
|
public static void Add__jquery(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "jquery", "jquery-1.11.3.js")));
|
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "jquery", "jquery-1.11.3.js")));
|
||||||
}
|
}
|
||||||
public static void Add__notifyjs(Xopg_tag_mgr head_tags, Io_url http_root) {
|
|
||||||
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "notifyjs", "notifyjs-0.3.1.js")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user