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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user