mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-05-31 22:44:34 +00:00
Full-text search: Save and load options
This commit is contained in:
parent
06acdd7335
commit
d0399d6b04
@ -22,6 +22,7 @@ import gplx.xowa.addons.wikis.searchs.fulltexts.finders.*;
|
||||
import gplx.xowa.addons.wikis.searchs.fulltexts.caches.*;
|
||||
import gplx.xowa.addons.wikis.searchs.searchers.crts.*;
|
||||
import gplx.xowa.addons.wikis.searchs.searchers.crts.visitors.*;
|
||||
import gplx.xowa.addons.apps.cfgs.*;
|
||||
class Xosearch_fulltext_svc implements Gfo_invk {
|
||||
private final Xoa_app app;
|
||||
private final gplx.xowa.guis.cbks.Xog_cbk_trg cbk_trg = gplx.xowa.guis.cbks.Xog_cbk_trg.New(Xosearch_fulltext_special.Prototype.Special__meta().Ttl_bry());
|
||||
@ -35,7 +36,19 @@ class Xosearch_fulltext_svc implements Gfo_invk {
|
||||
}
|
||||
public void Search(Json_nde args) {
|
||||
cache_mgr.Clear();
|
||||
gplx.core.threads.Thread_adp_.Start_by_val("search", Cancelable_.Never, this, Invk__search, Xosearch_search_args.New_by_json(args));
|
||||
|
||||
Xocfg_mgr cfg_mgr = app.Cfg();
|
||||
Xosearch_search_args thread_args = Xosearch_search_args.New_by_json(args);
|
||||
|
||||
cfg_mgr.Set_bool_app("xowa.addon.search.fulltext.special.case_match", thread_args.case_match);
|
||||
cfg_mgr.Set_bool_app("xowa.addon.search.fulltext.special.auto_wildcard_bgn", thread_args.auto_wildcard_bgn);
|
||||
cfg_mgr.Set_bool_app("xowa.addon.search.fulltext.special.auto_wildcard_end", thread_args.auto_wildcard_end);
|
||||
cfg_mgr.Set_bool_app("xowa.addon.search.fulltext.special.expand_matches_section", thread_args.expand_matches_section);
|
||||
cfg_mgr.Set_bool_app("xowa.addon.search.fulltext.special.show_all_matches", thread_args.show_all_matches);
|
||||
cfg_mgr.Get_int_app_or ("xowa.addon.search.fulltext.special.max_pages_per_wiki", thread_args.max_pages_per_wiki);
|
||||
cfg_mgr.Get_str_app_or ("xowa.addon.search.fulltext.special.namespaces", thread_args.namespaces);
|
||||
|
||||
gplx.core.threads.Thread_adp_.Start_by_val("search", Cancelable_.Never, this, Invk__search, thread_args);
|
||||
}
|
||||
private void Search(Xosearch_search_args args) {
|
||||
try {
|
||||
@ -139,9 +152,9 @@ class Xosearch_search_args {
|
||||
public boolean expand_matches_section;
|
||||
public boolean show_all_matches;
|
||||
public int max_pages_per_wiki;
|
||||
public int max_snips_per_page;
|
||||
public byte[] wikis;
|
||||
public byte[] query;
|
||||
public String namespaces;
|
||||
public static Xosearch_search_args New_by_json(Json_nde args) {
|
||||
Xosearch_search_args rv = new Xosearch_search_args();
|
||||
rv.case_match = args.Get_as_bool_or("case_match", false);
|
||||
@ -150,9 +163,9 @@ class Xosearch_search_args {
|
||||
rv.expand_matches_section = args.Get_as_bool_or("expand_matches_section", false);
|
||||
rv.show_all_matches = args.Get_as_bool_or("show_all_matches", false);
|
||||
rv.max_pages_per_wiki = args.Get_as_int_or("max_pages_per_wiki", 25);
|
||||
rv.max_snips_per_page = args.Get_as_int_or("max_snips_per_page", 10);
|
||||
rv.wikis = args.Get_as_bry("wikis");
|
||||
rv.query = args.Get_as_bry("query");
|
||||
rv.namespaces = args.Get_as_str("namespaces");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,20 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.xowa.addons.wikis.searchs.fulltexts.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
public class Xosearch_fulltext_doc implements Mustache_doc_itm {
|
||||
private final boolean case_match, auto_wildcard_bgn, auto_wildcard_end;
|
||||
private final int max_pages_per_wiki, max_snips_per_page;
|
||||
private final boolean case_match, auto_wildcard_bgn, auto_wildcard_end, expand_matches_section, show_all_matches;
|
||||
private final int max_pages_per_wiki;
|
||||
private final String wikis, namespaces;
|
||||
public Xosearch_fulltext_doc
|
||||
( boolean case_match, boolean auto_wildcard_bgn, boolean auto_wildcard_end
|
||||
, int max_pages_per_wiki, int max_snips_per_page
|
||||
, boolean expand_matches_section, boolean show_all_matches
|
||||
, int max_pages_per_wiki
|
||||
, String wikis, String namespaces) {
|
||||
this.case_match = case_match;
|
||||
this.auto_wildcard_bgn = auto_wildcard_bgn;
|
||||
this.auto_wildcard_end = auto_wildcard_end;
|
||||
this.expand_matches_section = expand_matches_section;
|
||||
this.show_all_matches = show_all_matches;
|
||||
this.max_pages_per_wiki = max_pages_per_wiki;
|
||||
this.max_snips_per_page = max_snips_per_page;
|
||||
this.wikis = wikis;
|
||||
this.namespaces = namespaces;
|
||||
}
|
||||
@ -38,8 +40,6 @@ public class Xosearch_fulltext_doc implements Mustache_doc_itm {
|
||||
bfr.Add_str_u8(namespaces);
|
||||
else if (String_.Eq(key, "max_pages_per_wiki"))
|
||||
bfr.Add_int(max_pages_per_wiki);
|
||||
else if (String_.Eq(key, "max_snips_per_page"))
|
||||
bfr.Add_int(max_snips_per_page);
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
@ -51,6 +51,10 @@ public class Xosearch_fulltext_doc implements Mustache_doc_itm {
|
||||
return Mustache_doc_itm_.Ary__bool(auto_wildcard_bgn);
|
||||
else if (String_.Eq(key, "auto_wildcard_end"))
|
||||
return Mustache_doc_itm_.Ary__bool(auto_wildcard_end);
|
||||
else if (String_.Eq(key, "expand_matches_section"))
|
||||
return Mustache_doc_itm_.Ary__bool(expand_matches_section);
|
||||
else if (String_.Eq(key, "show_all_matches"))
|
||||
return Mustache_doc_itm_.Ary__bool(show_all_matches);
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
||||
|
@ -17,25 +17,30 @@ package gplx.xowa.addons.wikis.searchs.fulltexts.specials; import gplx.*; import
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
import gplx.dbs.*;
|
||||
class Xosearch_fulltext_html extends Xow_special_wtr__base {
|
||||
private final boolean case_match, auto_wildcard_bgn, auto_wildcard_end;
|
||||
private final int max_pages_per_wiki, max_snips_per_page;
|
||||
private final boolean case_match, auto_wildcard_bgn, auto_wildcard_end, expand_matches_section, show_all_matches;
|
||||
private final int max_pages_per_wiki;
|
||||
private final String wikis, namespaces;
|
||||
public Xosearch_fulltext_html
|
||||
( boolean case_match, boolean auto_wildcard_bgn, boolean auto_wildcard_end
|
||||
, int max_pages_per_wiki, int max_snips_per_page
|
||||
, boolean expand_matches_section, boolean show_all_matches
|
||||
, int max_pages_per_wiki
|
||||
, String wikis, String namespaces) {
|
||||
this.case_match = case_match;
|
||||
this.auto_wildcard_bgn = auto_wildcard_bgn;
|
||||
this.auto_wildcard_end = auto_wildcard_end;
|
||||
this.expand_matches_section = expand_matches_section;
|
||||
this.show_all_matches = show_all_matches;
|
||||
this.max_pages_per_wiki = max_pages_per_wiki;
|
||||
this.max_snips_per_page = max_snips_per_page;
|
||||
this.wikis = wikis;
|
||||
this.namespaces = namespaces;
|
||||
}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return Addon_dir(app);}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xosearch_fulltext.template.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return new Xosearch_fulltext_doc(case_match, auto_wildcard_bgn, auto_wildcard_end, max_pages_per_wiki, max_snips_per_page, wikis, namespaces);
|
||||
return new Xosearch_fulltext_doc
|
||||
( case_match, auto_wildcard_bgn, auto_wildcard_end
|
||||
, expand_matches_section, show_all_matches
|
||||
, max_pages_per_wiki, wikis, namespaces);
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
|
@ -15,11 +15,22 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.wikis.searchs.fulltexts.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.fulltexts.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.qargs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xosearch_fulltext_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
// Gfo_qarg_mgr url_args = new Gfo_qarg_mgr().Init(url.Qargs_ary());
|
||||
|
||||
new Xosearch_fulltext_html(false, false, false, 100, 20, wiki.Domain_str(), "0|4").Bld_page_by_mustache(wiki.App(), page, this);
|
||||
Xocfg_mgr cfg_mgr = wiki.App().Cfg();
|
||||
new Xosearch_fulltext_html
|
||||
( cfg_mgr.Get_bool_app_or("xowa.addon.search.fulltext.special.case_match", false)
|
||||
, cfg_mgr.Get_bool_app_or("xowa.addon.search.fulltext.special.auto_wildcard_bgn", false)
|
||||
, cfg_mgr.Get_bool_app_or("xowa.addon.search.fulltext.special.auto_wildcard_end", false)
|
||||
, cfg_mgr.Get_bool_app_or("xowa.addon.search.fulltext.special.expand_matches_section", false)
|
||||
, cfg_mgr.Get_bool_app_or("xowa.addon.search.fulltext.special.show_all_matches", false)
|
||||
, cfg_mgr.Get_int_app_or ("xowa.addon.search.fulltext.special.max_pages_per_wiki", 100)
|
||||
, wiki.Domain_str()
|
||||
, cfg_mgr.Get_str_app_or ("xowa.addon.search.fulltext.special.namespaces", "0|4")
|
||||
).Bld_page_by_mustache(wiki.App(), page, this);
|
||||
}
|
||||
Xosearch_fulltext_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
|
Loading…
Reference in New Issue
Block a user