mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.12.1.1
This commit is contained in:
@@ -25,13 +25,7 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
this.url_fmt = url_fmt; this.lang_id = lang_id;
|
||||
this.url_fmtr = Bry_.Len_eq_0(url_fmt) ? null : Bry_fmtr.new_(url_fmt, "0");
|
||||
this.domain_tid = domain_tid; this.domain_bry = domain_bry; this.domain_name = domain_name; this.abrv_wm = abrv_wm;
|
||||
int key_bry_len = key_bry.length;
|
||||
this.show_in_sitelangs_base
|
||||
= lang_id != Xol_lang_stub_.Id__unknown // valid lang code
|
||||
&& domain_tid != Xow_domain_tid_.Int__commons // commons should never be considered an xwiki_lang; EX:[[commons:A]] PAGE:species:Scarabaeidae; DATE:2014-09-10
|
||||
&& Bry_.Len_gt_0(url_fmt) // url_fmt exists
|
||||
&& Bry_.Match(domain_bry, 0, key_bry_len, key_bry) && key_bry_len + 1 < domain_bry.length && domain_bry[key_bry_len] == Byte_ascii.Dot // key + . matches start of domain; EX: "en" and "en.wikipedia.org"
|
||||
;
|
||||
this.show_in_sitelangs_base = Calc_show_in_sitelangs(key_bry, url_fmt, lang_id, domain_tid, domain_bry);
|
||||
}
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: commons
|
||||
public String Key_str() {return key_str;} private final String key_str;
|
||||
@@ -52,4 +46,15 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
public static Xow_xwiki_itm new_(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry, byte[] abrv_wm) {
|
||||
return new Xow_xwiki_itm(key_bry, url_fmt, lang_id, domain_tid, domain_bry, domain_bry, abrv_wm);
|
||||
}
|
||||
private static boolean Calc_show_in_sitelangs(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry) {
|
||||
key_bry = Xow_domain_itm_.Alt_domain__get_subdomain_by_lang(key_bry); // handle "nb" as alias for "no.wikipedia.org"; PAGE: nn.w:; DATE:2015-12-04
|
||||
int key_len = key_bry.length;
|
||||
boolean key_matches_domain_bgn = Bry_.Match(domain_bry, 0, key_len, key_bry) && key_len + 1 < domain_bry.length && domain_bry[key_len] == Byte_ascii.Dot; // key + . matches start of domain; EX: "en" and "en.wikipedia.org"
|
||||
return lang_id != Xol_lang_stub_.Id__unknown // valid lang code
|
||||
&& domain_tid != Xow_domain_tid_.Int__commons // commons should never be considered an xwiki_lang; EX:[[commons:A]] PAGE:species:Scarabaeidae; DATE:2014-09-10
|
||||
&& Bry_.Len_gt_0(url_fmt) // url_fmt exists
|
||||
&& key_matches_domain_bgn
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,23 +20,27 @@ import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_tst {
|
||||
private final Xow_xwiki_itm_fxt fxt = new Xow_xwiki_itm_fxt();
|
||||
@Test public void Show_in_sitelangs__basic() { // PURPOSE: basic test for show in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make_xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__lang_like() { // PURPOSE: only consider xwikis with key similar to domain; EX: [[w:A]] in simplewiki; PAGE:Main_Page; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make_xwiki("e", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("w", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__same() { // PURPOSE: same wiki should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make_xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "en");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "en");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__no_url_fmt() { // PURPOSE: xwikis with no format should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make_xwiki("en", "", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("en", "", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__commons() { // PURPOSE: commons should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make_xwiki("c", "commons.wikimedia.org/wiki/{0}", Xol_lang_stub_.Id__intl, Xow_domain_tid_.Int__commons, "commons.wikimedia.org", "commonswiki"), "en");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("c", "commons.wikimedia.org/wiki/{0}", Xol_lang_stub_.Id__intl, Xow_domain_tid_.Int__commons, "commons.wikimedia.org", "commonswiki"), "en");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__nb() { // PURPOSE: handle special wikis like nb, lzh, simple; EX: [[nb:]] -> no.w; PAGE:nn.w:; DATE:2015-12-04
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("nb", "no.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_no, Xow_domain_tid_.Int__wikipedia, "no.wikipedia.org", "nbwiki"), "nn");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("lzh", "zh-classical.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_zh, Xow_domain_tid_.Int__wikipedia, "zh-classical.wikipedia.org", "lzwwiki"), "zh");
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_itm_fxt {
|
||||
public Xow_xwiki_itm Make_xwiki(String key_bry, String url_fmt, int lang_id, int domain_tid, String domain_bry, String abrv_wm) {
|
||||
public Xow_xwiki_itm Make__xwiki(String key_bry, String url_fmt, int lang_id, int domain_tid, String domain_bry, String abrv_wm) {
|
||||
return Xow_xwiki_itm.new_(Bry_.new_u8(key_bry), Bry_.new_u8(url_fmt), lang_id, domain_tid, Bry_.new_u8(domain_bry), Bry_.new_u8(abrv_wm));
|
||||
}
|
||||
public void Test__type_is_xwiki_lang(boolean expd, Xow_xwiki_itm xwiki_itm, String cur_lang_key) {
|
||||
|
||||
Reference in New Issue
Block a user