1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-08-24 00:32:13 -04:00
parent df10db140c
commit ed911e3de5
220 changed files with 2618 additions and 1569 deletions

View File

@@ -18,7 +18,7 @@ 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.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.wikis.domains.*; 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) {
@@ -73,7 +73,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
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_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 (wiki.Domain_tid() == Xow_domain_type_.Int__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);

View File

@@ -16,17 +16,17 @@ 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.xowa.wikis.*; import gplx.xowa.langs.*;
import gplx.xowa.wikis.domains.crts.*;
import gplx.core.primitives.*; import gplx.xowa.langs.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
private final Xow_domain cur_domain;
private final Xow_domain_itm cur_domain;
private final Xow_domain_crt_itm[] ary; private final int ary_len;
public Xow_domain_sorter__manual(Xow_domain cur_domain, Xow_domain_crt_itm[] ary) {
public Xow_domain_sorter__manual(Xow_domain_itm cur_domain, Xow_domain_crt_itm[] ary) {
this.cur_domain = cur_domain; this.ary = ary; this.ary_len = ary.length;
}
public int compare(Object lhsObj, Object rhsObj) {
Xow_domain lhs = (Xow_domain)lhsObj;
Xow_domain rhs = (Xow_domain)rhsObj;
Xow_domain_itm lhs = (Xow_domain_itm)lhsObj;
Xow_domain_itm rhs = (Xow_domain_itm)rhsObj;
int lhs_sort = Get_sort_idx_or_neg1(lhs);
int rhs_sort = Get_sort_idx_or_neg1(rhs);
if (lhs_sort == -1 && rhs_sort != -1) return rhs_sort;
@@ -34,7 +34,7 @@ class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
else if (lhs_sort != -1 && rhs_sort != -1) return Int_.Compare(lhs_sort, rhs_sort);
else return Bry_.Compare(lhs.Domain_bry(), rhs.Domain_bry());
}
private int Get_sort_idx_or_neg1(Xow_domain domain) {
private int Get_sort_idx_or_neg1(Xow_domain_itm domain) {
int sort_idx = domain.Sort_idx(); if (sort_idx != -1) return sort_idx;
sort_idx = Int_.MaxValue;
for (int i = 0; i < ary_len; ++i) {
@@ -44,7 +44,7 @@ class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
domain.Sort_idx_(sort_idx);
return sort_idx;
}
public static void Sort(Xow_domain_sorter__manual sorter, Xow_domain[] ary) {
public static void Sort(Xow_domain_sorter__manual sorter, Xow_domain_itm[] ary) {
int len = ary.length;
for (int i = 0; i < len; ++i)
ary[i].Sort_idx_(-1);
@@ -61,14 +61,14 @@ class Xow_domain_sorter__manual_tid implements gplx.lists.ComparerAble {
}
}
public int compare(Object lhsObj, Object rhsObj) {
Xow_domain lhs = (Xow_domain)lhsObj;
Xow_domain rhs = (Xow_domain)rhsObj;
int lhs_sort = Get_sort_idx_or_neg1(lhs.Domain_tid());
int rhs_sort = Get_sort_idx_or_neg1(rhs.Domain_tid());
Xow_domain_itm lhs = (Xow_domain_itm)lhsObj;
Xow_domain_itm rhs = (Xow_domain_itm)rhsObj;
int lhs_sort = Get_sort_idx_or_neg1(lhs.Domain_type_id());
int rhs_sort = Get_sort_idx_or_neg1(rhs.Domain_type_id());
if (lhs_sort == -1 && rhs_sort != -1) return rhs_sort;
else if (lhs_sort != -1 && rhs_sort == -1) return lhs_sort;
else if (lhs_sort != -1 && rhs_sort != -1) return Int_.Compare(lhs_sort, rhs_sort);
else return Bry_.Compare(Xow_domain_type_.Get_type_as_bry(lhs.Domain_tid()), Xow_domain_type_.Get_type_as_bry(rhs.Domain_tid()));
else return Bry_.Compare(Xow_domain_type_.Get_type_as_bry(lhs.Domain_type_id()), Xow_domain_type_.Get_type_as_bry(rhs.Domain_type_id()));
}
private int Get_sort_idx_or_neg1(int tid) {
Object o = sort_hash.Get_by(sort_key.Val_(tid));
@@ -95,14 +95,14 @@ class Xow_domain_sorter__manual_lang implements gplx.lists.ComparerAble {
}
}
public int compare(Object lhsObj, Object rhsObj) {
Xow_domain lhs = (Xow_domain)lhsObj;
Xow_domain rhs = (Xow_domain)rhsObj;
int lhs_sort = Get_sort_idx_or_neg1(lhs.Lang_uid());
int rhs_sort = Get_sort_idx_or_neg1(rhs.Lang_uid());
Xow_domain_itm lhs = (Xow_domain_itm)lhsObj;
Xow_domain_itm rhs = (Xow_domain_itm)rhsObj;
int lhs_sort = Get_sort_idx_or_neg1(lhs.Lang_actl_uid());
int rhs_sort = Get_sort_idx_or_neg1(rhs.Lang_actl_uid());
if (lhs_sort == -1 && rhs_sort != -1) return rhs_sort;
else if (lhs_sort != -1 && rhs_sort == -1) return lhs_sort;
else if (lhs_sort != -1 && rhs_sort != -1) return Int_.Compare(lhs_sort, rhs_sort);
else return Bry_.Compare(lhs.Lang_key(), rhs.Lang_key());
else return Bry_.Compare(lhs.Lang_actl_key(), rhs.Lang_actl_key());
}
private int Get_sort_idx_or_neg1(int tid) {
Object o = sort_hash.Get_by(sort_key.Val_(tid));

View File

@@ -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.dbs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
import gplx.dbs.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; 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();
@@ -33,9 +34,9 @@ class Xows_core {
}
public void Search(Xow_wiki search_wiki, Xoae_page page, Xows_ui_qry qry) {
// generate 1 cmd per wiki
Xow_domain[] domain_ary = qry.Wiki_domains(); int domain_ary_len = domain_ary.length;
Xow_domain_itm[] domain_ary = qry.Wiki_domains(); int domain_ary_len = domain_ary.length;
for (int i = 0; i < domain_ary_len; ++i) {
Xow_domain domain = domain_ary[i];
Xow_domain_itm domain = domain_ary[i];
try {
Xowe_wiki wiki = wiki_mgr.Get_by_key_or_make(domain.Domain_bry()); wiki.Init_assert();
Assert_page_count(wiki);

View File

@@ -16,7 +16,9 @@ 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 org.junit.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.tdbs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.tbls.*;
import org.junit.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.tdbs.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xows_html_wkr_tst {
@Before public void init() {fxt.Clear();} private Xows_html_wkr_fxt fxt = new Xows_html_wkr_fxt();
@Test public void Paging() {
@@ -54,7 +56,7 @@ class Xows_html_wkr_fxt {
return this;
}
public void Test_paging(boolean fwd, int paging_idx, String expd) {
Xows_ui_qry qry = new Xows_ui_qry(Bry_.new_a7("A"), paging_idx, 100, Xosrh_rslt_itm_sorter.Tid_len_dsc, new Xows_ns_mgr(), true, new Xow_domain[] {Xow_domain_.parse(wiki.Domain_bry())});
Xows_ui_qry qry = new Xows_ui_qry(Bry_.new_a7("A"), paging_idx, 100, Xosrh_rslt_itm_sorter.Tid_len_dsc, new Xows_ns_mgr(), true, new Xow_domain_itm[] {Xow_domain_itm_.parse(wiki.Domain_bry())});
qry.Page_max_(2);
html_mgr.Init_by_wiki(wiki, wiki.Lang().Num_mgr(), qry);
byte[] paging_link = html_mgr.Paging_link(fwd);

View File

@@ -16,12 +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.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.core.primitives.*; import gplx.xowa.wikis.*; import gplx.xowa.apis.xowa.specials.*;
import gplx.xowa.wikis.domains.crts.*;
import gplx.core.primitives.*; import gplx.xowa.apis.xowa.specials.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
private final Xoae_app app; private final Xow_domain wiki_domain; private final Xoapi_search search_api;
private final Xoae_app app; private final Xow_domain_itm wiki_domain; private final Xoapi_search search_api;
private final Xows_core search_mgr; private final Xows_arg_mgr args_mgr = new Xows_arg_mgr();
private Xow_domain[] search_domain_ary;
private Xow_domain_itm[] search_domain_ary;
public Xows_page__search(Xowe_wiki wiki) {
this.app = wiki.Appe();
this.wiki_domain = wiki.Domain_itm();
@@ -35,7 +35,7 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
private void Multi_wikis_changed() {
Xow_domain_crt_itm crt = search_api.Multi_wikis_crt(wiki_domain);
this.search_domain_ary = app.Usere().Wiki().Xwiki_mgr().Get_by_crt(wiki_domain, crt);
if (search_domain_ary.length == 0) search_domain_ary = new Xow_domain[] {wiki_domain}; // default to current if bad input
if (search_domain_ary.length == 0) search_domain_ary = new Xow_domain_itm[] {wiki_domain}; // default to current if bad input
Multi_sorts_changed();
}
private void Multi_sorts_changed() {
@@ -45,7 +45,7 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
Xow_domain_sorter__manual.Sort(sorter, search_domain_ary);
}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home) return; // do not allow search in home wiki; will throw null ref error b/c no search_ttl dirs
if (wiki.Domain_tid() == Xow_domain_type_.Int__home) return; // do not allow search in home wiki; will throw null ref error b/c no search_ttl dirs
if (search_domain_ary == null) Multi_wikis_changed();
// get args
Xog_search_suggest_mgr search_suggest_mgr = wiki.Appe().Gui_mgr().Search_suggest_mgr();

View File

@@ -16,10 +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.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wikis.domains.*;
class Xows_ui_qry {
private final List_adp cmd_list = List_adp_.new_();
public Xows_ui_qry(byte[] search_raw, int page_idx, int page_len, byte sort_tid, Xows_ns_mgr ns_mgr, boolean async_db, Xow_domain[] wiki_domains) {
public Xows_ui_qry(byte[] search_raw, int page_idx, int page_len, byte sort_tid, Xows_ns_mgr ns_mgr, boolean async_db, Xow_domain_itm[] wiki_domains) {
this.search_raw = search_raw; this.page_idx = page_idx; this.page_len = page_len; this.sort_tid = sort_tid; this.ns_mgr = ns_mgr; this.async_db = async_db; this.wiki_domains = wiki_domains;
this.itms_bgn = page_idx * page_len;
this.page_max = page_idx; // default page_max to page_idx; adjust later when all results are known
@@ -36,7 +36,7 @@ class Xows_ui_qry {
public int Itms_end() {return itms_bgn + page_len;}
public byte Sort_tid() {return sort_tid;} private final byte sort_tid;
public Xows_ns_mgr Ns_mgr() {return ns_mgr;} private final Xows_ns_mgr ns_mgr;
public Xow_domain[] Wiki_domains() {return wiki_domains;} private final Xow_domain[] wiki_domains;
public Xow_domain_itm[] Wiki_domains() {return wiki_domains;} private final Xow_domain_itm[] wiki_domains;
public void Page_max_(int v) {this.page_max = v;}
public int Cmds__len() {return cmd_list.Count();}
public Xows_ui_cmd Cmds__get_at(int i) {return (Xows_ui_cmd)cmd_list.Get_at(i);}