mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-02 07:24:19 +00:00
Full-text search: Add option to switch between Special:Search and Special:XowaSearch
This commit is contained in:
parent
04b798483e
commit
62d7e6adfe
@ -129,6 +129,7 @@ public class Xocfg_mgr implements Gfo_invk {
|
||||
else if (ctx.Match(k, "set_temp")) cache_mgr.Set_wo_save ((String)m.ReadValAt(0), (String)m.ReadValAt(1), (String)m.ReadValAt(2));
|
||||
else if (ctx.Match(k, "set_dflt")) dflt_mgr.Add ((String)m.ReadValAt(0), (String)m.ReadValAt(1));
|
||||
else if (ctx.Match(k, "run")) cache_mgr.Pub ((String)m.ReadValAt(0), (String)m.ReadValAt(1), (String)m.ReadValAt(2));
|
||||
else if (ctx.Match(k, "get")) return cache_mgr.Get ((String)m.ReadValAt(0), (String)m.ReadValAt(1));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
|
@ -29,9 +29,10 @@ public class Xoapi_nav_wiki implements Gfo_invk {
|
||||
if (ctx.Match(k, "main_page")) this.Main_page();
|
||||
else if (ctx.Match(k, "random")) win.Page__navigate_by_url_bar("Special:Random");
|
||||
else if (ctx.Match(k, "sandbox")) win.Page__navigate_by_url_bar("Project:Sandbox");
|
||||
else if (ctx.Match(k, "allpages")) win.Page__navigate_by_url_bar("Special:AllPages?from=!"); // NOTE: for menu, default to ! else empty page
|
||||
else if (ctx.Match(k, "allpages")) win.Page__navigate_by_url_bar("Special:AllPages?from=!"); // NOTE: for main_menu, default to ! else empty page
|
||||
else if (ctx.Match(k, "search_title")) win.Page__navigate_by_url_bar("Special:Search?fulltext=y");
|
||||
else if (ctx.Match(k, "search_full")) win.Page__navigate_by_url_bar("Special:XowaSearch");
|
||||
else if (ctx.Match(k, "search_per_cfg")) win.Page__navigate_by_url_bar(win.Gui_mgr().Win_cfg().Search_url());
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
|
@ -18,18 +18,41 @@ import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.draws.*;
|
||||
import gplx.xowa.guis.langs.*;
|
||||
public class Xocfg_win implements Gfo_invk {
|
||||
private Xoa_app app;
|
||||
public Xol_font_info Font() {return font;} private Xol_font_info font = new Xol_font_info("Arial", 8, FontStyleAdp_.Plain);
|
||||
public Bry_fmtr Search_box_fmtr() {return search_box_fmtr;} private Bry_fmtr search_box_fmtr = Bry_fmtr.new_("Special:XowaSearch?search=~{search}", "search");
|
||||
public Bry_fmtr Search_box_fmtr() {return search_box_fmtr;} private Bry_fmtr search_box_fmtr = Bry_fmtr.new_("Special:Search?search=~{search}", "search");
|
||||
public Bry_fmtr Allpages_box_fmtr() {return allpages_box_fmtr;} private Bry_fmtr allpages_box_fmtr = Bry_fmtr.new_("Special:AllPages?from=~{search}&namespace=0&hideredirects=0", "search");
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
this.app = app;
|
||||
font.Init_by_app(app);
|
||||
app.Cfg().Bind_many_app(this, Cfg__search__default_to_fulltext, Cfg__search__fallback_to_title);
|
||||
}
|
||||
public String Search_url() {return search_url;} private String search_url = "Special:Search";
|
||||
public void Search_url_(boolean default_to_fulltext) {
|
||||
search_url = default_to_fulltext ? "Special:XowaSearch" : "Special:Search?fulltext=y&search=";
|
||||
search_box_fmtr = Bry_fmtr.new_(search_url + "?fulltext=y&search=~{search}", "search");
|
||||
|
||||
// rest portal on every page in order to refresh searchform link; EX: <form id="searchform" action="/wiki/~{<>app.gui.win_opts.search_url;<>}">
|
||||
int len = app.Wiki_mgri().Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgri().Get_at(i);
|
||||
wiki.Html_mgr().Portal_mgr().Init();
|
||||
}
|
||||
}
|
||||
public boolean Search_fallsback_to_title() {return search_fallsback_to_title;} private boolean search_fallsback_to_title;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_font)) return font;
|
||||
else if (ctx.Match(k, Invk_search_box_fmt_)) search_box_fmtr.Fmt_(m.ReadBry("v"));
|
||||
if (ctx.Match(k, Invk_font)) return font;
|
||||
else if (ctx.Match(k, Invk_search_box_fmt_)) search_box_fmtr.Fmt_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, "search_url")) return search_url;
|
||||
else if (ctx.Match(k, Cfg__search__default_to_fulltext)) Search_url_(m.ReadBool("v"));
|
||||
else if (ctx.Match(k, Cfg__search__fallback_to_title)) search_fallsback_to_title = m.ReadBool("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_search_box_fmt_ = "search_box_fmt_", Invk_font = "font";
|
||||
private static final String
|
||||
Cfg__search__default_to_fulltext = "xowa.addon.fulltext_search.compatibility.default_to_fulltext"
|
||||
, Cfg__search__fallback_to_title = "xowa.addon.fulltext_search.compatibility.fallback_to_title";
|
||||
|
||||
public static final float Font_size_default = 8;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class Xoa_gui_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
else if (ctx.Match(k, Invk_bnds)) return bnd_mgr;
|
||||
else if (ctx.Match(k, Invk_bindings)) return ipt_cfgs;
|
||||
else if (ctx.MatchIn(k, Invk_main_win, Invk_browser_win)) return browser_win;
|
||||
else if (ctx.Match(k, Invk_win_opts)) return win_cfg;
|
||||
else if (ctx.Match(k, Invk_win_opts)) return win_cfg; // used by xowa.gfs and Special:Search; DATE:2017-03-29
|
||||
else if (ctx.Match(k, Invk_layout)) return layout;
|
||||
else if (ctx.Match(k, Invk_html)) return html_mgr;
|
||||
else if (ctx.Match(k, Invk_menus)) return menu_mgr;
|
||||
|
@ -46,6 +46,7 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.allpages-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.search_title-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.search_full-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.wiki.search_per_cfg-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.help-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.about-1"
|
||||
, "xowa.gui.shortcuts.xowa.nav.help.change_log-1"
|
||||
@ -233,6 +234,7 @@ public class Xog_bnd_mgr implements Gfo_invk {
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_allpages , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_search_title , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_search_full , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_search_per_cfg , Xog_bnd_box_.Tid_browser , "");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_wiki_sandbox , Xog_bnd_box_.Tid_browser , "mod.cs+key.g,mod.cs+key.s", "mod.c+key.f1");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_help , Xog_bnd_box_.Tid_browser , "key.f1");
|
||||
Init_itm(Xog_cmd_itm_.Key_nav_help_change_log , Xog_bnd_box_.Tid_browser , "");
|
||||
|
@ -31,6 +31,7 @@ public class Xog_cmd_itm_ {
|
||||
, Key_nav_wiki_allpages = new_dflt_(Xog_ctg_itm_.Tid_nav , "xowa.nav.wiki.allpages")
|
||||
, Key_nav_wiki_search_title = new_dflt_(Xog_ctg_itm_.Tid_nav , "xowa.nav.wiki.search_title")
|
||||
, Key_nav_wiki_search_full = new_dflt_(Xog_ctg_itm_.Tid_nav , "xowa.nav.wiki.search_full")
|
||||
, Key_nav_wiki_search_per_cfg = new_dflt_(Xog_ctg_itm_.Tid_nav , "xowa.nav.wiki.search_per_cfg")
|
||||
|
||||
, Key_nav_help_help = new_page_(Xog_ctg_itm_.Tid_nav_pages , "xowa.nav.help.help" , "home/wiki/Help/Contents") // HOME
|
||||
, Key_nav_help_about = new_page_(Xog_ctg_itm_.Tid_nav_pages , "xowa.nav.help.about" , "home/wiki/Help/About") // HOME
|
||||
|
@ -16,7 +16,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
package gplx.xowa.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Xot_prm_tkn_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Idx_1() {fxt.Test_parse_tmpl_str_test("{{{1}}}" , "{{test|a|b}}" , "a");}
|
||||
@Test public void Idx_2() {fxt.Test_parse_tmpl_str_test("{{{2}}}" , "{{test|a|b}}" , "b");}
|
||||
|
Loading…
Reference in New Issue
Block a user