mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.1.1
This commit is contained in:
@@ -25,7 +25,7 @@ import gplx.xowa.users.data.*;
|
||||
public class Xows_mgr {
|
||||
private final Hash_adp_bry hash;
|
||||
public Xows_mgr(Xowe_wiki wiki, Xol_lang lang) {
|
||||
hash = Hash_adp_bry.ci_utf8_(lang.Case_mgr());
|
||||
hash = Hash_adp_bry.ci_u8(lang.Case_mgr());
|
||||
page_allpages = new Xows_page_allpages(wiki);
|
||||
page_search = new Xows_page__search(wiki);
|
||||
page_random = new Xows_page_random(wiki);
|
||||
|
||||
@@ -16,9 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.allPages; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.lnkis.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.urls.*;
|
||||
public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page {
|
||||
public Xows_page_allpages(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
@@ -71,13 +72,13 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
public Xowd_page_itm[] Rslt_list_ttls() {return rslt_list_ttls;} private Xowd_page_itm[] rslt_list_ttls;
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
wiki.Ctx().Cur_page().Html_data().Display_ttl_(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_sp_allpages_hdr));
|
||||
url.Page_bry_(Bry_.Add(Bry_.new_a7("Special:"), ttl.Page_txt_wo_qargs())); // HACK: need to re-set Page b/c href_parser does not eliminate qargs; DATE:2013-02-08
|
||||
url.Page_bry_(Bry_.Add(Bry_.new_a7("Special:"), ttl.Page_txt_wo_qargs())); // HACK: need to re-set Page b/c href_wtr does not eliminate qargs; DATE:2013-02-08
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home) {wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "home.invalid", "AllPages not implemented for home wiki"); return;}
|
||||
if (rslt_list_ttls == null) this.Itms_per_page_(itms_per_page);
|
||||
boolean found = Build_data(url, ttl); if (!found) return;
|
||||
Build_html(page);
|
||||
}
|
||||
private static byte[] Get_from(Xoa_url_arg_hash arg_hash, Xowe_wiki wiki, Xoa_url url, Xoa_ttl ttl) {
|
||||
private static byte[] Get_from(Gfo_qarg_mgr arg_hash, Xowe_wiki wiki, Xoa_url url, Xoa_ttl ttl) {
|
||||
return ttl.Leaf_bgn() == -1
|
||||
? arg_hash.Get_val_bry_or(Bry_arg_from, null)
|
||||
: ttl.Leaf_url()
|
||||
@@ -85,7 +86,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
}
|
||||
public boolean Build_data(Xoa_url url, Xoa_ttl ttl) {
|
||||
init_ns = wiki.Ns_mgr().Ns_main();
|
||||
arg_hash.Load(url);
|
||||
arg_hash.Load(url.Qargs_ary());
|
||||
byte[] from_val = Get_from(arg_hash, wiki, url, ttl); if (from_val == null) return false;
|
||||
from_val = Xoa_app_.Utl__encoder_mgr().Id().Decode(from_val);
|
||||
int ns_val = arg_hash.Get_val_int_or(Bry_arg_ns, init_ns.Id()); init_ns = wiki.Ns_mgr().Ids_get_or_null(ns_val);
|
||||
@@ -99,7 +100,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
init_ns = from_ttl.Ns();
|
||||
arg_hash.Set_val_by_int(Bry_arg_ns, init_ns.Id());
|
||||
arg_hash.Set_val_by_bry(Bry_arg_from, from_ttl.Page_db());
|
||||
arg_hash.Save(url);
|
||||
url.Qargs_ary_(arg_hash.To_ary());
|
||||
}
|
||||
Int_obj_ref rslt_len = Int_obj_ref.new_(rslt_list_len);
|
||||
Xowd_page_itm rslt_nxt2 = new Xowd_page_itm();
|
||||
@@ -113,7 +114,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
rslt_nxt = rslt_nxt2;
|
||||
rslt_prv = rslt_prv2;
|
||||
return true;
|
||||
} private Xoa_url_arg_hash arg_hash = new Xoa_url_arg_hash();
|
||||
} private Gfo_qarg_mgr arg_hash = new Gfo_qarg_mgr();
|
||||
private static final byte[] Bry_arg_from = Bry_.new_a7("from"), Bry_arg_ns = Bry_.new_a7("namespace"), Bry_arg_hideredirects = Bry_.new_a7("hideredirects");
|
||||
public Xow_ns Init_ns() {return init_ns;} private Xow_ns init_ns;
|
||||
public void Build_html(Xoae_page page) {
|
||||
@@ -166,10 +167,10 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
}
|
||||
class Xos_pagelist_html_itm_fmtr implements Bry_fmtr_arg {
|
||||
public Xos_pagelist_html_itm_fmtr(Xows_page_allpages mgr, Xowe_wiki wiki) {
|
||||
this.mgr = mgr; this.wiki = wiki; this.href_parser = wiki.Appe().Href_parser(); this.wiki_key = wiki.Domain_bry();
|
||||
this.mgr = mgr; this.wiki = wiki; this.href_wtr = wiki.Appe().Html__href_wtr(); this.wiki_key = wiki.Domain_bry();
|
||||
this.itm_normal = mgr.Html_list_itm_normal(); this.itm_redirect = mgr.Html_list_itm_redirect();
|
||||
history_mgr = wiki.Appe().Usere().History_mgr();
|
||||
} private Xows_page_allpages mgr; Xowe_wiki wiki; Xoh_href_parser href_parser; Bry_fmtr itm_normal, itm_redirect; byte[] wiki_key; gplx.xowa.users.history.Xou_history_mgr history_mgr;
|
||||
} private Xows_page_allpages mgr; Xowe_wiki wiki; Xoh_href_wtr href_wtr; Bry_fmtr itm_normal, itm_redirect; byte[] wiki_key; gplx.xowa.users.history.Xou_history_mgr history_mgr;
|
||||
public void Itm_idx_(int v) {itm_idx = v;} private int itm_idx;
|
||||
public void XferAry_bgn() {
|
||||
itms_per_grp = mgr.Itms_per_grp();
|
||||
@@ -186,7 +187,7 @@ class Xos_pagelist_html_itm_fmtr implements Bry_fmtr_arg {
|
||||
Xowd_page_itm ttl_itm = ttls[i];
|
||||
if (ttl_itm == null) break; // ttl_itm can be null at bgn or end of title list; EX: list=A-Z; count=5; key=Z; itms=X,Y,Z,null,null
|
||||
Xoa_ttl ttl = Xows_page_allpages.ttl_(wiki, init_ns, ttl_itm);
|
||||
byte[] href = href_parser.Build_to_bry(wiki, ttl);
|
||||
byte[] href = href_wtr.Build_to_bry(wiki, ttl);
|
||||
byte[] title = Xoh_html_wtr.Ttl_to_title(ttl.Full_txt());
|
||||
byte[] cls = Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki_key, ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
Bry_fmtr fmtr = ttl_itm.Redirected() ? itm_redirect : itm_normal;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.allPages; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import org.junit.*; import gplx.core.net.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xows_page_allpages_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xows_page_allpages_fxt fxt = new Xows_page_allpages_fxt();
|
||||
@Test public void Build_data() {
|
||||
@@ -134,10 +134,10 @@ class Xows_page_allpages_fxt {
|
||||
return this;
|
||||
} private Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki; Xows_page_allpages allpages;
|
||||
public Xows_page_allpages_fxt Init_arg(String key, String val) {init_args.Add(new Gfo_url_arg(Bry_.new_a7(key), Bry_.new_a7(val))); return this;} private List_adp init_args = List_adp_.new_();
|
||||
public Xows_page_allpages_fxt Init_arg(String key, String val) {init_args.Add(new Gfo_qarg_itm(Bry_.new_a7(key), Bry_.new_a7(val))); return this;} private List_adp init_args = List_adp_.new_();
|
||||
public Xows_page_allpages_fxt Init_ttl_leaf(String val) {init_ttl_leaf = val; return this;} private String init_ttl_leaf;
|
||||
public Xows_page_allpages_fxt Init_itms_per_page(int v) {init_itms_per_page = v; return this;} private int init_itms_per_page = 5;
|
||||
public Xows_page_allpages_fxt Expd_arg(String key, String val) {expd_args.Add(new Gfo_url_arg(Bry_.new_a7(key), Bry_.new_a7(val))); return this;} private List_adp expd_args = List_adp_.new_();
|
||||
public Xows_page_allpages_fxt Expd_arg(String key, String val) {expd_args.Add(new Gfo_qarg_itm(Bry_.new_a7(key), Bry_.new_a7(val))); return this;} private List_adp expd_args = List_adp_.new_();
|
||||
public Xows_page_allpages_fxt Expd_prv(String v) {expd_prv = v; return this;} private String expd_prv;
|
||||
public Xows_page_allpages_fxt Expd_nxt(String v) {expd_nxt = v; return this;} private String expd_nxt;
|
||||
public Xows_page_allpages_fxt Expd_ttls(String... v) {expd_ttls = v; return this;} private String[] expd_ttls;
|
||||
@@ -159,18 +159,17 @@ class Xows_page_allpages_fxt {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static String[] Xto_str_ary(Gfo_url_arg[] ary) {
|
||||
public static String[] Xto_str_ary(Gfo_qarg_itm[] ary) {
|
||||
int ary_len = ary.length;
|
||||
String[] rv = new String[ary_len];
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Gfo_url_arg itm = ary[i];
|
||||
Gfo_qarg_itm itm = ary[i];
|
||||
rv[i] = String_.new_u8(itm.Key_bry()) + "=" + String_.new_u8(itm.Val_bry());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xows_page_allpages_fxt Test_special_gen() {
|
||||
Xoa_url_parser parserx = new Xoa_url_parser();
|
||||
parserx.Parse(init_url, Xows_special_meta_.Itm__all_pages.Ttl_bry());
|
||||
init_url = app.User().Wikii().Utl__url_parser().Parse(Xows_special_meta_.Itm__all_pages.Ttl_bry());
|
||||
Xoa_ttl init_ttl = Make_init_ttl();
|
||||
allpages.Special_gen(wiki, wiki.Ctx().Cur_page(), init_url, init_ttl);
|
||||
if (expd_display_ttl != null) Tfds.Eq(expd_display_ttl, String_.new_u8(wiki.Ctx().Cur_page().Html_data().Display_ttl()));
|
||||
@@ -183,11 +182,11 @@ class Xows_page_allpages_fxt {
|
||||
if (expd_nxt != null) Tfds.Eq(expd_nxt, Xto_str(wiki, allpages.Rslt_nxt()));
|
||||
if (expd_prv != null) Tfds.Eq(expd_prv, Xto_str(wiki, allpages.Rslt_prv()));
|
||||
if (expd_args.Count() > 0) {
|
||||
Gfo_url_arg[] expd_args_ary = (Gfo_url_arg[])expd_args.To_ary(Gfo_url_arg.class);
|
||||
Tfds.Eq_ary_str(Xto_str_ary(init_url.Args()), Xto_str_ary(expd_args_ary));
|
||||
Gfo_qarg_itm[] expd_args_ary = (Gfo_qarg_itm[])expd_args.To_ary(Gfo_qarg_itm.class);
|
||||
Tfds.Eq_ary_str(Xto_str_ary(expd_args_ary), Xto_str_ary(init_url.Qargs_ary()));
|
||||
}
|
||||
return this;
|
||||
} private Xoa_url init_url = Xoa_url.blank_();
|
||||
} private Xoa_url init_url = Xoa_url.blank();
|
||||
public Xows_page_allpages_fxt Test_build_html(String expd) {
|
||||
Exec_build();
|
||||
allpages.Build_html(wiki.Ctx().Cur_page());
|
||||
@@ -196,7 +195,7 @@ class Xows_page_allpages_fxt {
|
||||
}
|
||||
private void Exec_build() {
|
||||
if (allpages.Itms_per_page() != init_itms_per_page) allpages.Itms_per_page_(init_itms_per_page);
|
||||
init_url.Args_((Gfo_url_arg[])init_args.To_ary(Gfo_url_arg.class));
|
||||
init_url.Qargs_ary_((Gfo_qarg_itm[])init_args.To_ary(Gfo_qarg_itm.class));
|
||||
init_args.Clear();
|
||||
Xoa_ttl init_ttl = Make_init_ttl();
|
||||
allpages.Build_data(init_url, init_ttl);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.movePage; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
public class Move_page implements Xows_page {
|
||||
private Move_trg_ns_list_fmtr ns_list_fmtr = new Move_trg_ns_list_fmtr();
|
||||
@@ -67,7 +67,7 @@ public class Move_page implements Xows_page {
|
||||
wiki.Parser().Parse_text_to_html(tmp_bfr, page, true, msg_mgr.Val_by_key_obj("movepagetext"));
|
||||
fmtr_all.Bld_bfr_many(tmp_bfr
|
||||
, msg_mgr.Val_by_key_obj("move-page-legend")
|
||||
, Bry_.Add(Xoh_href_parser.Href_wiki_bry, src_ttl.Full_db())
|
||||
, Bry_.Add(Xoh_href_.Bry__wiki, src_ttl.Full_db())
|
||||
, gplx.html.Html_utl.Escape_html_as_bry(src_ttl.Full_txt())
|
||||
, src_ttl.Full_txt()
|
||||
, msg_mgr.Val_by_key_obj("newtitle")
|
||||
@@ -147,19 +147,19 @@ class Move_url_args {
|
||||
public boolean Create_redirect() {return create_redirect;} private boolean create_redirect;
|
||||
public void Parse(Xoa_url url) {
|
||||
this.Clear();
|
||||
Gfo_url_arg[] args = url.Args();
|
||||
Gfo_qarg_itm[] args = url.Qargs_ary();
|
||||
int args_len = args.length;
|
||||
for (int i = 0; i < args_len; i++) {
|
||||
Gfo_url_arg arg = args[i];
|
||||
Gfo_qarg_itm arg = args[i];
|
||||
Object tid_obj = arg_keys.Get_by(arg.Key_bry());
|
||||
byte[] val_bry = arg.Val_bry();
|
||||
if (tid_obj != null) {
|
||||
switch (((Byte_obj_val)tid_obj).Val()) {
|
||||
case Key_submitted: submitted = true; break; // wpMove will only be in query_args if move button is pressed
|
||||
case Key_src_ttl: src_ttl = val_bry; break;
|
||||
case Key_trg_ns: trg_ns = Bry_.Xto_int_or_fail(val_bry); break;
|
||||
case Key_trg_ns: trg_ns = Bry_.To_int(val_bry); break;
|
||||
case Key_trg_ttl: trg_ttl = val_bry; break;
|
||||
case Key_create_redirect: create_redirect = Bry_.Xto_bool_by_int_or_fail(val_bry); break;
|
||||
case Key_create_redirect: create_redirect = Bry_.To_bool_by_int(val_bry); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ class Move_url_args {
|
||||
create_redirect = false;
|
||||
}
|
||||
private static final byte Key_submitted = 1, Key_src_ttl = 2, Key_trg_ns = 3, Key_trg_ttl = 4, Key_create_redirect = 5;
|
||||
private static final Hash_adp_bry arg_keys = Hash_adp_bry.ci_ascii_()
|
||||
private static final Hash_adp_bry arg_keys = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("wpMove" , Key_submitted)
|
||||
.Add_str_byte("wpOldTitle" , Key_src_ttl)
|
||||
.Add_str_byte("wpNewTitleNs" , Key_trg_ns)
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.specials.nearby; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
public class Nearby_mgr implements Xows_page {
|
||||
Xowe_wiki wiki; byte[] trg;
|
||||
private Hash_adp_bry excluded = Hash_adp_bry.ci_ascii_();
|
||||
private Hash_adp_bry visited = Hash_adp_bry.ci_ascii_();
|
||||
private Hash_adp_bry excluded = Hash_adp_bry.ci_a7();
|
||||
private Hash_adp_bry visited = Hash_adp_bry.ci_a7();
|
||||
List_adp trail = List_adp_.new_();
|
||||
List_adp results = List_adp_.new_();
|
||||
int results_cur = 0;
|
||||
|
||||
@@ -46,7 +46,7 @@ class Nearby_mgr_fxt {
|
||||
if (fxt == null) {
|
||||
fxt = new Xop_fxt();
|
||||
nearby_mgr = new Nearby_mgr();
|
||||
excluded = Hash_adp_bry.ci_ascii_();
|
||||
excluded = Hash_adp_bry.ci_a7();
|
||||
tmp_bfr = Bry_bfr.new_();
|
||||
}
|
||||
fxt.Reset();
|
||||
|
||||
@@ -45,7 +45,7 @@ class Xop_randomRootPage_page_fxt {
|
||||
}
|
||||
public static Xoae_page Test_special_open(Xowe_wiki wiki, Xows_page special_page, String special_url) {
|
||||
Xoae_page page = wiki.Ctx().Cur_page();
|
||||
Xoa_url url = wiki.Appe().Utl__url_parser().Parse(Bry_.new_u8(special_url));
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(special_url));
|
||||
page.Url_(url);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_a7(special_url));
|
||||
page.Ttl_(ttl);
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.gfui.*; import gplx.core.threads.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.core.net.*; import gplx.core.threads.*;
|
||||
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.core.js.*;
|
||||
public class Xog_search_suggest_mgr implements GfoInvkAble {
|
||||
public Xog_search_suggest_mgr(Xoa_gui_mgr gui_mgr) {
|
||||
@@ -30,13 +31,13 @@ public class Xog_search_suggest_mgr implements GfoInvkAble {
|
||||
public int All_pages_extend() {return all_pages_extend;} private int all_pages_extend = 1000; // look ahead by 1000
|
||||
public int All_pages_min() {return all_pages_min;} private int all_pages_min = 10000; // only look at pages > 10 kb
|
||||
public boolean Auto_wildcard() {return auto_wildcard;} private boolean auto_wildcard = false; // automatically add wild-card; EX: Earth -> *Earth*
|
||||
public Gfo_url_arg[] Args_default() {return args_default;} private Gfo_url_arg[] args_default = Gfo_url_arg.Ary_empty;
|
||||
public Gfo_qarg_itm[] Args_default() {return args_default;} private Gfo_qarg_itm[] args_default = Gfo_qarg_itm.Ary_empty;
|
||||
public void Args_default_str_(String v) {
|
||||
this.args_default_str = v;
|
||||
byte[] bry = Bry_.new_a7("http://x.org/a?" + v);
|
||||
Gfo_url tmp_url = new Gfo_url();
|
||||
app.Utl__url_parser().Url_parser().Parse(tmp_url, bry, 0, bry.length);
|
||||
args_default = tmp_url.Args();
|
||||
app.User().Wikii().Utl__url_parser().Url_parser().Parse(tmp_url, bry, 0, bry.length);
|
||||
args_default = tmp_url.Qargs();
|
||||
}
|
||||
private String args_default_str = "";// default args for search
|
||||
public static final int[] Ns_default_main = new int[] {Xow_ns_.Id_main};
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xosrh_core_tst {
|
||||
// fxt.Test_search("b*", 3, "B3_13");
|
||||
// }
|
||||
// @Test public void Url() {
|
||||
// Xoa_url url = Xoa_url_parser.Parse_url(fxt.App(), fxt.Wiki(), "Special:Search/Abc?fulltext=y&xowa_sort=len_desc");
|
||||
// Xoa_url url = Xoa_url_parser_old.Parse_url(fxt.App(), fxt.Wiki(), "Special:Search/Abc?fulltext=y&xowa_sort=len_desc");
|
||||
// fxt.Search_mgr().Args_mgr().Clear().Parse(url.Args());
|
||||
// Tfds.Eq(Xosrh_rslt_itm_sorter.Tid_len_dsc, fxt.Search_mgr().Args_mgr().Sort_tid());
|
||||
// }
|
||||
@@ -167,12 +167,12 @@ public class Xosrh_core_tst {
|
||||
// }
|
||||
// public Xows_page__search Search_mgr() {return search_mgr;}
|
||||
// public void Test_url_search_bry(String url_str, String expd) {
|
||||
// Xoa_url url = Xoa_url_parser.Parse_url(app, wiki, url_str);
|
||||
// Xoa_url url = Xoa_url_parser_old.Parse_url(app, wiki, url_str);
|
||||
// search_mgr.Args_mgr().Clear().Parse(url.Args());
|
||||
// Tfds.Eq(expd, String_.new_u8(search_mgr.Args_mgr().Search_bry()));
|
||||
// }
|
||||
// public void Test_url__ns(String url_str, String expd) {
|
||||
// Xoa_url url = Xoa_url_parser.Parse_url(app, wiki, url_str);
|
||||
// Xoa_url url = Xoa_url_parser_old.Parse_url(app, wiki, url_str);
|
||||
// search_mgr.Args_mgr().Clear().Parse(url.Args());
|
||||
// Tfds.Eq(expd, String_.new_a7(search_mgr.Args_mgr().Ns_mgr().Xto_hash_key()));
|
||||
// }
|
||||
@@ -197,7 +197,7 @@ public class Xosrh_core_tst {
|
||||
// }
|
||||
// public void Test_search2(byte match_tid, String ttl_str, int page_idx, byte sort_tid, params String[] expd_ary) {
|
||||
// Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b128();
|
||||
// Xoa_url_parser url_parser = new Xoa_url_parser();
|
||||
// Xoa_url_parser_old url_parser = new Xoa_url_parser_old();
|
||||
// byte[] url_raw = Bry_.new_a7("Special:Search/" + ttl_str + ((match_tid == Xows_page__search.Match_tid_all) ? "" : "*") + "?fulltext=y" + Xosrh_rslt_itm_sorter.Xto_url_arg(sort_tid) + "&xowa_page_size=1&xowa_page_index=" + page_idx);
|
||||
// Xoa_url url = url_parser.Parse(url_raw);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url_raw);
|
||||
|
||||
@@ -46,7 +46,7 @@ class Xosrh_page_mgr_fxt {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
byte[] id_bry = new byte[5]; // NOTE: do not reuse; will break hive_mgr
|
||||
Base85_utl.XtoStrByAry(i, id_bry, 0, 5);
|
||||
tmp_itm.Ns_id_(Xow_ns_.Id_main).Init(i, Bry_.XtoStrBytesByInt(i, 0), false, 10, 0, i - bgn);
|
||||
tmp_itm.Ns_id_(Xow_ns_.Id_main).Init(i, Bry_.To_a7_bry(i, 0), false, 10, 0, i - bgn);
|
||||
Xotdb_page_itm_.Txt_id_save(tmp_bfr, tmp_itm);
|
||||
hive_mgr.Create(id_bry, tmp_bfr.Xto_bry_and_clear(), null);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class Xosrh_scanner {
|
||||
Ordered_hash tmp_list = Ordered_hash_.new_(); Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Xosrh_qry_tkn new_tkn_(byte tid, int val_bgn, int val_end) {return Xosrh_qry_tkn.new_pos_(tid, val_bgn, val_end);}
|
||||
private static byte[] Bry_and = Bry_.new_a7("AND");
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_()// NOTE:ci.ascii:OR / AND only
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()// NOTE:ci.ascii:OR / AND only
|
||||
.Add_str_byte(" ", Xosrh_qry_tkn.Tid_space)
|
||||
.Add_str_byte("\"", Xosrh_qry_tkn.Tid_quote)
|
||||
.Add_str_byte("-", Xosrh_qry_tkn.Tid_not)
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
class Xows_arg_mgr {
|
||||
private final Xows_paging_parser paging_parser = new Xows_paging_parser();
|
||||
public Xows_ns_mgr Ns_mgr() {return ns_mgr;} private final Xows_ns_mgr ns_mgr = new Xows_ns_mgr();
|
||||
@@ -34,17 +34,17 @@ class Xows_arg_mgr {
|
||||
this.cancel = null;
|
||||
return this;
|
||||
}
|
||||
public void Parse(Gfo_url_arg[] arg_ary) {
|
||||
public void Parse(Gfo_qarg_itm[] arg_ary) {
|
||||
if (arg_ary == null) return;
|
||||
int len = arg_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_url_arg arg = arg_ary[i];
|
||||
Gfo_qarg_itm arg = arg_ary[i];
|
||||
byte[] key = arg.Key_bry();
|
||||
Object tid = url_args.Get_by(key);
|
||||
if (tid != null) {
|
||||
switch (((Byte_obj_val)tid).Val()) {
|
||||
case Arg_search: this.search_bry = Bry_.Replace(arg.Val_bry(), Byte_ascii.Plus, Byte_ascii.Space); break;
|
||||
case Arg_page_idx: this.paging_idx = Bry_.Xto_int_or(arg.Val_bry(), 0); break;
|
||||
case Arg_page_idx: this.paging_idx = Bry_.To_int_or(arg.Val_bry(), 0); break;
|
||||
case Arg_sort: this.sort_tid = Xosrh_rslt_itm_sorter.parse_(String_.new_a7(arg.Val_bry())); break;
|
||||
case Arg_cancel: this.cancel = arg.Val_bry(); break;
|
||||
case Arg_paging: this.paging_itms = paging_parser.Parse(arg.Val_bry()); break;
|
||||
@@ -64,7 +64,7 @@ class Xows_arg_mgr {
|
||||
Arg_bry_page_index = Bry_.new_a7("xowa_page_index")
|
||||
, Arg_bry_cancel = Bry_.new_a7("cancel")
|
||||
;
|
||||
private static final Hash_adp_bry url_args = Hash_adp_bry.ci_ascii_()
|
||||
private static final Hash_adp_bry url_args = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("xowa_paging", Arg_paging)
|
||||
.Add_bry_byte(Arg_bry_page_index, Arg_page_idx)
|
||||
.Add_str_byte("xowa_sort", Arg_sort)
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
class Xows_core {
|
||||
private final Xoae_wiki_mgr wiki_mgr;
|
||||
private final Hash_adp_bry cache_hash = Hash_adp_bry.cs_(); private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs_();
|
||||
private boolean ask_for_upgrade = true; private final Hash_adp_bry upgraded_wikis = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry cache_hash = Hash_adp_bry.cs(); private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs();
|
||||
private boolean ask_for_upgrade = true; private final Hash_adp_bry upgraded_wikis = Hash_adp_bry.cs();
|
||||
public Xows_core(Xoae_wiki_mgr wiki_mgr) {this.wiki_mgr = wiki_mgr;}
|
||||
private final Xows_html_wkr html_wkr = new Xows_html_wkr();
|
||||
public Xows_db_cache Get_cache_or_new(byte[] key) {
|
||||
|
||||
@@ -44,13 +44,13 @@ public class Xows_ns_mgr {
|
||||
ns_all = true;
|
||||
}
|
||||
public void Add_by_parse(byte[] key, byte[] val) {
|
||||
int ns_enabled = Bry_.Xto_int(val);
|
||||
int ns_enabled = Bry_.To_int_or_neg1(val);
|
||||
if (ns_enabled == 1) { // make sure set to 1; EX: ignore &ns0=0
|
||||
int key_len = key.length;
|
||||
if (key_len == 3 && key[2] == Byte_ascii.Star) // translate ns* as ns_all
|
||||
ns_all = true;
|
||||
else {
|
||||
int ns_id = Bry_.Xto_int_or(key, 2, key_len, Int_.MinValue);
|
||||
int ns_id = Bry_.To_int_or(key, 2, key_len, Int_.MinValue);
|
||||
if (ns_id != Int_.MinValue) { // ignore invalid ints; EX: &nsabc=1;
|
||||
Add_by_id(ns_id);
|
||||
ns_main = ns_all = false;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
Xog_search_suggest_mgr search_suggest_mgr = wiki.Appe().Gui_mgr().Search_suggest_mgr();
|
||||
args_mgr.Clear();
|
||||
args_mgr.Parse(search_suggest_mgr.Args_default());
|
||||
args_mgr.Parse(url.Args());
|
||||
args_mgr.Parse(url.Qargs_ary());
|
||||
args_mgr.Ns_mgr().Add_main_if_empty();
|
||||
// get search_bry
|
||||
byte[] search_bry = args_mgr.Search_bry();
|
||||
@@ -64,14 +64,14 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
&& Bry_finder.Find_fwd(search_bry, Byte_ascii.Star) == -1 // search term does not have asterisk
|
||||
)
|
||||
search_bry = Bry_.Add(search_bry, Byte_ascii.Star);
|
||||
url.Page_bry_(Bry_.Add(Xows_special_meta_.Itm__search.Ttl_bry(), Byte_ascii.Slash_bry, search_bry));// HACK: need to re-set Page b/c href_parser does not eliminate qargs; DATE:2013-02-08
|
||||
// url.Page_bry_(Bry_.Add(Xows_special_meta_.Itm__search.Ttl_bry(), Byte_ascii.Slash_bry, search_bry));// HACK: need to re-set Page b/c href_parser does not eliminate qargs; DATE:2013-02-08
|
||||
// search wiki
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse_(wiki, search_bry);
|
||||
Xoae_page search_page = page;
|
||||
if (!Bry_.Eq(search_bry, Xows_special_meta_.Itm__search.Ttl_bry())) // do not lookup page else stack overflow; happens when going directly to Special:Search (from history)
|
||||
search_page = wiki.Data_mgr().Get_page(search_ttl, false); // try to find page; EX:Special:Search?search=Earth -> en.w:Earth; needed for search suggest
|
||||
// page not found, or explicit_search invoked
|
||||
if (search_page.Missing() || url.Search_fulltext()) {
|
||||
if (search_page.Missing() || url.Qargs_mgr().Match(Qarg__fulltext, Qarg__fulltext__y)) {
|
||||
if (args_mgr.Cancel() != null) {
|
||||
search_mgr.Cancel(args_mgr.Cancel());
|
||||
page.Tab_data().Cancel_show_y_();
|
||||
@@ -99,4 +99,5 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
}
|
||||
public static final byte Match_tid_all = 0, Match_tid_bgn = 1;
|
||||
public static final byte Version_null = 0, Version_1 = 1, Version_2 = 2;
|
||||
private static final byte[] Qarg__fulltext = Bry_.new_a7("fulltext"), Qarg__fulltext__y = Bry_.new_a7("y");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class Xows_ui_cmd implements GfoInvkAble, Cancelable, Xog_tab_close_lnr {
|
||||
if (!cache.Done() && (qry.Itms_end() > cache.Itms_end())) {
|
||||
if (async) {
|
||||
fill_from_cache = false; // NOTE: do not retrieve cached results to page, else ui_async cmd will add out of order; DATE:2015-04-24
|
||||
if (async_wkr == null) async_wkr = new Xows_ui_async(this, new Xows_html_row(new gplx.xowa.html.wtrs.Xoh_lnki_bldr(wiki.App(), wiki.App().Html__href_parser())), js_wkr, qry.Page_len(), wiki.Domain_bry());
|
||||
if (async_wkr == null) async_wkr = new Xows_ui_async(this, new Xows_html_row(new gplx.xowa.html.wtrs.Xoh_lnki_bldr(wiki.App(), wiki.App().Html__href_wtr())), js_wkr, qry.Page_len(), wiki.Domain_bry());
|
||||
Thread_adp_.invk_(gplx.xowa.apps.Xoa_thread_.Key_special_search_db, this, Invk_search_db).Start();
|
||||
}
|
||||
else
|
||||
@@ -88,7 +88,7 @@ class Xows_ui_cmd implements GfoInvkAble, Cancelable, Xog_tab_close_lnr {
|
||||
}
|
||||
public boolean When_close(Xog_tab_itm tab, Xoa_url url) {
|
||||
if (url != Xoa_url.Null) { // not called by close_tab (Ctrl+W)
|
||||
byte[] cancel_arg = url.Args_hash().Get_val_bry_or(Xows_arg_mgr.Arg_bry_cancel, null);
|
||||
byte[] cancel_arg = url.Qargs_mgr().Get_val_bry_or(Xows_arg_mgr.Arg_bry_cancel, null);
|
||||
if (cancel_arg != null) return true; // cancel arg exists; assume tab is not being closed; note that cancel will be processed by Xows_page__special; DATE:2015-04-30
|
||||
}
|
||||
this.Cancel();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.specials.search.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.search.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.langs.cases.*;
|
||||
class Xows_text_parser__v2 {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs_();
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(32);
|
||||
private Xob_word_mgr word_mgr; private Xol_case_mgr case_mgr;
|
||||
private byte[] src; private int end; // bgn,
|
||||
|
||||
@@ -115,7 +115,7 @@ class Xows_text_parser__v2_fxt {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(32);
|
||||
private Xol_case_mgr case_mgr;
|
||||
public void Init() {
|
||||
case_mgr = Xol_case_mgr_.Ascii();
|
||||
case_mgr = Xol_case_mgr_.A7();
|
||||
word_parser.Init_for_ttl(word_mgr, case_mgr);
|
||||
}
|
||||
public Xows_text_parser__v2_fxt Clear() {
|
||||
|
||||
@@ -22,7 +22,7 @@ interface Xows_text_tkn {
|
||||
}
|
||||
class Xows_text_tkn__split implements Xows_text_tkn {
|
||||
private final boolean add_sym_as_word;
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs_();
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
public Xows_text_tkn__split(boolean add_sym_as_word, byte[][] ary) {
|
||||
this.add_sym_as_word = add_sym_as_word;
|
||||
int len = ary.length;
|
||||
|
||||
@@ -133,7 +133,7 @@ class Xow_search_scanner {
|
||||
}
|
||||
private Xow_search_tkn new_tkn(byte tid, int val_bgn, int val_end) {return Xow_search_tkn.new_pos(tid, val_bgn, val_end);}
|
||||
private static final byte[] Bry_and = Bry_.new_a7("AND");
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_()// NOTE:ci.ascii:OR / AND only
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()// NOTE:ci.ascii:OR / AND only
|
||||
.Add_str_byte(" " , Xow_search_tkn.Tid_space)
|
||||
.Add_str_byte("\"" , Xow_search_tkn.Tid_quote)
|
||||
.Add_str_byte("-" , Xow_search_tkn.Tid_not)
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Dbui_tbl_itm__bmk implements Dbui_tbl_itm {
|
||||
byte[] new_name = vals.Get_val_as_bry("name");
|
||||
byte[] new_url_bry = vals.Get_val_as_bry("url");
|
||||
byte[] new_comment = vals.Get_val_as_bry("comment");
|
||||
Xoa_url new_url = app.Utl__url_parser().Parse(new_url_bry);
|
||||
Xoa_url new_url = app.User().Wikii().Utl__url_parser().Parse(new_url_bry);
|
||||
if (new_url.Page_bry() == null) return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Url is invalid", "url", new_url.Raw())).To_json_str();
|
||||
tbl.Update(db_row.Id(), db_row.Owner(), db_row.Sort(), new_name, new_url.Wiki_bry(), new_url_bry, new_comment);
|
||||
Dbui_row_itm ui_row = Get_ui_row(row_pkey, new_name, new_url_bry, new_comment);
|
||||
@@ -67,7 +67,7 @@ public class Dbui_tbl_itm__bmk implements Dbui_tbl_itm {
|
||||
int len = db_rows.length; if (len != pkeys.length) return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Rows have changed")).Notify_hint_("Please reload the page").To_json_str();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int old_pkey = db_rows[i].Id();
|
||||
int new_pkey = Bry_.Xto_int(pkeys[i]);
|
||||
int new_pkey = Bry_.To_int_or_neg1(pkeys[i]);
|
||||
if (old_pkey == new_pkey) continue; // order hasn't changed; EX: 5 in list; 4th moved to 5th; 1 through 3 will have same sort order;
|
||||
tbl.Update_sort(new_pkey, i);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class Dbui_tbl_itm__bmk implements Dbui_tbl_itm {
|
||||
return app.Html__bridge_mgr().Msg_bldr().Clear().Data("html", tmp_bfr.Xto_bry_and_clear()).To_json_str();
|
||||
}
|
||||
private Xoud_bmk_itm_row Get_db_row(byte[] pkey) {
|
||||
int bmk_id = Bry_.Xto_int_or_fail(pkey);
|
||||
int bmk_id = Bry_.To_int(pkey);
|
||||
return tbl.Select_or_null(bmk_id);
|
||||
}
|
||||
private Dbui_row_itm Get_ui_row(Xoud_bmk_itm_row row) {return Get_ui_row(Int_.Xto_bry(row.Id()), row.Name(), row.Url(), row.Comment());}
|
||||
|
||||
@@ -16,11 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.diags; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.urls.*;
|
||||
class Xows_cmd__file_check {
|
||||
private Io_url tmp_dir;
|
||||
public void Exec(Bry_bfr bfr, Xoa_app app, Xoa_url url, Xoa_url_arg_hash arg_hash) {
|
||||
public void Exec(Bry_bfr bfr, Xoa_app app, Xoa_url url, Gfo_qarg_mgr arg_hash) {
|
||||
byte[] wiki_bry = arg_hash.Get_val_bry_or(Arg_wiki, null); if (wiki_bry == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; no wiki: url=~{0}", url.Raw()); return;}
|
||||
byte[] file_bry = arg_hash.Get_val_bry_or(Arg_file, null); if (file_bry == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; no file: url=~{0}", url.Raw()); return;}
|
||||
Xow_wiki wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(wiki_bry);
|
||||
|
||||
@@ -16,10 +16,11 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.diags; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.ios.*; import gplx.core.net.*;
|
||||
import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.urls.*;
|
||||
class Xows_cmd__fs_check {
|
||||
public void Exec(Bry_bfr bfr, Xoa_app app, Xoa_url url, Xoa_url_arg_hash arg_hash) {
|
||||
public void Exec(Bry_bfr bfr, Xoa_app app, Xoa_url url, Gfo_qarg_mgr arg_hash) {
|
||||
byte[] dir_bry = arg_hash.Get_val_bry_or(Arg_dir, null);
|
||||
if (dir_bry != null) {
|
||||
Write_dir(bfr, Io_url_.new_dir_(String_.new_u8(dir_bry)));
|
||||
|
||||
@@ -16,11 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.diags; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.ios.*; import gplx.core.primitives.*;
|
||||
import gplx.ios.*; import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.urls.*;
|
||||
class Xows_cmd__sql_dump {
|
||||
public void Exec(Bry_bfr bfr, Xoa_app app, Xoa_url url, Xoa_url_arg_hash arg_hash) {
|
||||
public void Exec(Bry_bfr bfr, Xoa_app app, Xoa_url url, Gfo_qarg_mgr arg_hash) {
|
||||
Db_conn conn = null;
|
||||
byte[] sql_bry = arg_hash.Get_val_bry_or(Arg_sql, null); if (sql_bry == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; no sql: url=~{0}", url.Raw()); return;}
|
||||
byte[] wiki_bry = arg_hash.Get_val_bry_or(Arg_wiki, null);
|
||||
@@ -43,7 +44,7 @@ class Xows_cmd__sql_dump {
|
||||
public static final Xows_cmd__sql_dump I = new Xows_cmd__sql_dump(); Xows_cmd__sql_dump() {}
|
||||
private static final byte[] Arg_wiki = Bry_.new_a7("wiki"), Arg_db_file = Bry_.new_a7("db_file"), Arg_db_type = Bry_.new_a7("db_type"), Arg_sql = Bry_.new_a7("sql");
|
||||
private static final byte Db_type_fsdb_abc = 1, Db_type_fsdb_atr = 2, Db_type_wiki_core = 3;
|
||||
private static final Hash_adp_bry db_type_hash = Hash_adp_bry.cs_()
|
||||
private static final Hash_adp_bry db_type_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("fsdb.abc" , Db_type_fsdb_abc)
|
||||
.Add_str_byte("fsdb.atr" , Db_type_fsdb_atr)
|
||||
.Add_str_byte("wiki.core" , Db_type_wiki_core)
|
||||
|
||||
@@ -16,12 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.diags; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.xowa.urls.*;
|
||||
public class Xows_diag_page implements Xows_page {
|
||||
private Xoa_url_arg_hash arg_hash = new Xoa_url_arg_hash();
|
||||
private Gfo_qarg_mgr arg_hash = new Gfo_qarg_mgr();
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__diag;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
arg_hash.Load(url);
|
||||
arg_hash.Load(url.Qargs_ary());
|
||||
byte[] cmd_type_bry = arg_hash.Get_val_bry_or(Arg_type, null); if (cmd_type_bry == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; no type: url=~{0}", url.Raw()); return;}
|
||||
Byte_obj_val cmd_type_val = (Byte_obj_val)type_hash.Get_by_bry(cmd_type_bry); if (cmd_type_val == null) {Xoa_app_.Usr_dlg().Warn_many("", "", "special.cmd; bad type: url=~{0}", url.Raw()); return;}
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||
@@ -36,7 +37,7 @@ public class Xows_diag_page implements Xows_page {
|
||||
}
|
||||
private static final byte[] Arg_type = Bry_.new_a7("type");
|
||||
private static final byte Type_file_check = 1, Type_fs_check = 2, Type_sql_dump = 3;
|
||||
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs_()
|
||||
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("file.check" , Type_file_check)
|
||||
.Add_str_byte("fs.check" , Type_fs_check)
|
||||
.Add_str_byte("sql.dump" , Type_sql_dump)
|
||||
|
||||
@@ -16,38 +16,38 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
class Xoa_url_arg_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private final Xoa_url_enum_mgr enm_mgr;
|
||||
public Xoa_url_arg_mgr(Xoa_url_enum_mgr enm_mgr) {this.enm_mgr = enm_mgr;}
|
||||
public void Init(Gfo_url_arg[] args) {
|
||||
public void Init(Gfo_qarg_itm[] args) {
|
||||
hash.Clear();
|
||||
int len = args.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_url_arg arg = args[i];
|
||||
Gfo_qarg_itm arg = args[i];
|
||||
hash.Add_bry_obj(arg.Key_bry(), arg);
|
||||
}
|
||||
}
|
||||
public int Read_enm_or_neg1(byte[] key) {
|
||||
Xoa_url_enum_itm enm = enm_mgr.Get(key); if (enm == null) return -1;
|
||||
Gfo_url_arg arg = (Gfo_url_arg)hash.Get_by_bry(key); if (arg == null) return -1;
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key); if (arg == null) return -1;
|
||||
return enm.Get_as_int_or(arg.Val_bry(), -1);
|
||||
}
|
||||
public byte[] Read_bry_or_empty(byte[] key) {return Read_bry_or(key, Bry_.Empty);}
|
||||
public byte[] Read_bry_or_null(byte[] key) {return Read_bry_or(key, null);}
|
||||
public byte[] Read_bry_or(byte[] key, byte[] or) {
|
||||
Gfo_url_arg arg = (Gfo_url_arg)hash.Get_by_bry(key);
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key);
|
||||
return arg == null ? or : arg.Val_bry();
|
||||
}
|
||||
public String Read_str_or_null(String key) {return Read_str_or_null(Bry_.new_u8(key));}
|
||||
public String Read_str_or_null(byte[] key) {
|
||||
Gfo_url_arg arg = (Gfo_url_arg)hash.Get_by_bry(key);
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by_bry(key);
|
||||
return arg == null ? null : String_.new_u8(arg.Val_bry());
|
||||
}
|
||||
}
|
||||
class Xoa_url_enum_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_url_enum_mgr(Xoa_url_enum_itm... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@@ -58,7 +58,7 @@ class Xoa_url_enum_mgr {
|
||||
public Xoa_url_enum_itm Get(byte[] key) {return (Xoa_url_enum_itm)hash.Get_by_bry(key);}
|
||||
}
|
||||
class Xoa_url_enum_itm {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_url_enum_itm(byte[] key) {this.key = key;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public Xoa_url_enum_itm Add(String key, int val) {
|
||||
|
||||
@@ -16,24 +16,24 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.xowa.specials.*; import gplx.ios.*;
|
||||
import gplx.xowa.specials.*; import gplx.ios.*; import gplx.core.net.*;
|
||||
public class Xosp_fbrow_special implements Xows_page {
|
||||
private static final Xoa_url_arg_mgr url_args = new Xoa_url_arg_mgr(null);
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__file_browser;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xosp_fbrow_rslt rslt = Gen(url.Args(), GfoInvkAble_.Null);
|
||||
Xosp_fbrow_rslt rslt = Gen(url.Qargs_ary(), GfoInvkAble_.Null);
|
||||
page.Html_data().Html_restricted_n_();
|
||||
page.Html_data().Custom_head_end_concat(rslt.Html_head());
|
||||
page.Data_raw_(rslt.Html_body());
|
||||
}
|
||||
public static Xosp_fbrow_rslt Gen(Gfo_url_arg[] args, GfoInvkAble select_invkable) {
|
||||
public static Xosp_fbrow_rslt Gen(Gfo_qarg_itm[] args, GfoInvkAble select_invkable) {
|
||||
url_args.Init(args);
|
||||
byte[] cmd_bry = url_args.Read_bry_or_empty(Arg_cmd);
|
||||
Xosp_fbrow_cmd cmd = (Xosp_fbrow_cmd)cmd_regy.Get_by_bry(cmd_bry); if (cmd == null) cmd = Xosp_fbrow_cmd__err.I;
|
||||
return cmd.Make_new().Write_html(url_args, select_invkable);
|
||||
}
|
||||
private static final byte[] Arg_cmd = Bry_.new_a7("cmd");
|
||||
private static final Hash_adp_bry cmd_regy = Hash_adp_bry.cs_()
|
||||
private static final Hash_adp_bry cmd_regy = Hash_adp_bry.cs()
|
||||
.Add_bry_obj(Xosp_fbrow_cmd__wiki_add.Regy_key, Xosp_fbrow_cmd__wiki_add.I)
|
||||
.Add_bry_obj(Xosp_fbrow_cmd__root_set.Regy_key, Xosp_fbrow_cmd__root_set.I)
|
||||
;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import org.junit.*; import gplx.ios.*;
|
||||
import org.junit.*; import gplx.core.net.*; import gplx.ios.*;
|
||||
public class Xosp_fbrow_special_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xosp_fbrow_special_fxt fxt = new Xosp_fbrow_special_fxt();
|
||||
@Test public void Basic() {
|
||||
@@ -136,8 +136,8 @@ class Xosp_fbrow_special_fxt {
|
||||
}
|
||||
public void Test_nav(String path, String expd) {
|
||||
Xoa_url_arg_mgr args_mgr = new Xoa_url_arg_mgr(null);
|
||||
Xoa_url url = Xoa_url.new_(Bry_.Empty, Bry_.Empty).Args_(Gfo_url_arg.Ary("cmd", "xowa.wiki.add", "mode", "view", "path", path));
|
||||
args_mgr.Init(url.Args());
|
||||
Xoa_url url = Xoa_url.new_(Bry_.Empty, Bry_.Empty).Qargs_ary_(Gfo_qarg_itm.Ary("cmd", "xowa.wiki.add", "mode", "view", "path", path));
|
||||
args_mgr.Init(url.Qargs_ary());
|
||||
Xosp_fbrow_cmd__wiki_add cmd = new Xosp_fbrow_cmd__wiki_add();
|
||||
byte[] actl = cmd.Write_html(args_mgr, GfoInvkAble_.Null).Html_body();
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
|
||||
@@ -16,12 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.xowa.system_data; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.xowa.urls.*;
|
||||
public class System_data_page implements Xows_page {
|
||||
private Xoa_url_arg_hash arg_hash = new Xoa_url_arg_hash();
|
||||
private Gfo_qarg_mgr arg_hash = new Gfo_qarg_mgr();
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__system_data;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
arg_hash.Load(url);
|
||||
arg_hash.Load(url.Qargs_ary());
|
||||
byte[] file_type = arg_hash.Get_val_bry_or(Arg_type, null); if (file_type == null) return;
|
||||
Byte_obj_val type_val = (Byte_obj_val)type_hash.Get_by_bry(file_type); if (type_val == null) return;
|
||||
Io_url file_url = Path_from_type(wiki, type_val.Val()); if (file_url == null) return;
|
||||
@@ -46,7 +47,7 @@ public class System_data_page implements Xows_page {
|
||||
|
||||
private static final byte[] Arg_type = Bry_.new_a7("type");
|
||||
private static final byte Type_log_session = 1, Type_cfg_app = 2, Type_cfg_lang = 3, Type_cfg_user = 4, Type_cfg_custom = 5, Type_usr_history = 6;
|
||||
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs_()
|
||||
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("log_session" , Type_log_session)
|
||||
.Add_str_byte("cfg_app" , Type_cfg_app)
|
||||
.Add_str_byte("cfg_lang" , Type_cfg_lang)
|
||||
|
||||
Reference in New Issue
Block a user