1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.9.2.1'

This commit is contained in:
gnosygnu
2016-09-11 21:49:20 -04:00
parent 232838c732
commit 35d78f6106
310 changed files with 4358 additions and 5116 deletions

View File

@@ -51,7 +51,7 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
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
&& domain_tid != Xow_domain_tid_.Tid__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
;

View File

@@ -18,25 +18,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
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();
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_.Tid__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("w", "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_.Tid__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_.Tid__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_.Tid__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_.Tid__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");
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_.Tid__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_.Tid__wikipedia, "zh-classical.wikipedia.org", "lzwwiki"), "zh");
}
}
class Xow_xwiki_itm_fxt {

View File

@@ -77,9 +77,9 @@ public class Xow_xwiki_mgr {
}
private static int Xwiki_tid(int tid) {
switch (tid) {
case Xow_domain_tid_.Int__commons: case Xow_domain_tid_.Int__species: case Xow_domain_tid_.Int__incubator:
case Xow_domain_tid_.Int__mediawiki: case Xow_domain_tid_.Int__wmfblog: case Xow_domain_tid_.Int__home:
return Xow_domain_tid_.Int__wikipedia; // set xwiki_tid to wikipedia; allows [[da:Page]] to point to da.wikipedia.org; PAGE:species:Puccinia; DATE:2014-09-14
case Xow_domain_tid_.Tid__commons: case Xow_domain_tid_.Tid__species: case Xow_domain_tid_.Tid__incubator:
case Xow_domain_tid_.Tid__mediawiki: case Xow_domain_tid_.Tid__wmfblog: case Xow_domain_tid_.Tid__home:
return Xow_domain_tid_.Tid__wikipedia; // set xwiki_tid to wikipedia; allows [[da:Page]] to point to da.wikipedia.org; PAGE:species:Puccinia; DATE:2014-09-14
default: return tid;
}
}

View File

@@ -32,8 +32,8 @@ public class Xow_xwiki_itm_bldr {
if (domain_name == null) { // no hard-coded name; currently dmoz or commons
domain_name = (byte[])domain_name_hash.Get_by_bry(domain_bry); // NOTE: domain_name is needed for "Related Sites" in wikivoyage
if (domain_name == null) {
if ( cur_domain.Domain_type_id() != Xow_domain_tid_.Int__wikipedia // cur_domain is not wikipedia
&& domain_itm.Domain_type_id() == Xow_domain_tid_.Int__wikipedia // domain_itm is wikipedia
if ( cur_domain.Domain_type_id() != Xow_domain_tid_.Tid__wikipedia // cur_domain is not wikipedia
&& domain_itm.Domain_type_id() == Xow_domain_tid_.Tid__wikipedia // domain_itm is wikipedia
&& cur_domain.Lang_actl_uid() == domain_itm.Lang_actl_uid() // cur_domain lang matches domain_lang
) {
domain_name = Bry__domain_name__wikipedia; // EX: in "en.wikivoyage.org", "en.wikipedia.org" should have name of "Wikipedia" (not "en.wikipedia.org")

View File

@@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.wikis.xwikis.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
public class Xow_xwiki_itm_bldr_tst {
@Before public void init() {fxt.Clear();} private final Xow_xwiki_itm_bldr_fxt fxt = new Xow_xwiki_itm_bldr_fxt();
@Test public void Commons() {fxt.Test_bld("commons.wikimedia.org/wiki/$1" , "commons.wikimedia.org" , "commons.wikimedia.org/wiki/~{0}" , Xow_domain_tid_.Int__commons , Xol_lang_stub_.Id__unknown);}
@Test public void Wiktionary() {fxt.Test_bld("fr.wiktionary.org/wiki/$1" , "fr.wiktionary.org" , "fr.wiktionary.org/wiki/~{0}" , Xow_domain_tid_.Int__wiktionary , Xol_lang_stub_.Id_fr);}
@Test public void Lang() {fxt.Test_bld("fr.wikipedia.org/wiki/$1" , "fr.wikipedia.org" , "fr.wikipedia.org/wiki/~{0}" , Xow_domain_tid_.Int__wikipedia , Xol_lang_stub_.Id_fr);}
@Before public void init() {fxt.Clear();} private final Xow_xwiki_itm_bldr_fxt fxt = new Xow_xwiki_itm_bldr_fxt();
@Test public void Commons() {fxt.Test_bld("commons.wikimedia.org/wiki/$1" , "commons.wikimedia.org" , "commons.wikimedia.org/wiki/~{0}" , Xow_domain_tid_.Tid__commons , Xol_lang_stub_.Id__unknown);}
@Test public void Wiktionary() {fxt.Test_bld("fr.wiktionary.org/wiki/$1" , "fr.wiktionary.org" , "fr.wiktionary.org/wiki/~{0}" , Xow_domain_tid_.Tid__wiktionary , Xol_lang_stub_.Id_fr);}
@Test public void Lang() {fxt.Test_bld("fr.wikipedia.org/wiki/$1" , "fr.wikipedia.org" , "fr.wikipedia.org/wiki/~{0}" , Xow_domain_tid_.Tid__wikipedia , Xol_lang_stub_.Id_fr);}
}
class Xow_xwiki_itm_bldr_fxt {
private Xow_domain_itm domain_itm;
public void Clear() {
domain_itm = Xow_domain_itm.new_(Bry_.new_a7("en.wikivoyage.org"), Xow_domain_tid_.Int__wikivoyage, Xol_lang_itm_.Key_en); // NOTE: use "en.wikivoyage.org" to domain_name; needed for "Related sites"
domain_itm = Xow_domain_itm.new_(Bry_.new_a7("en.wikivoyage.org"), Xow_domain_tid_.Tid__wikivoyage, Xol_lang_itm_.Key_en); // NOTE: use "en.wikivoyage.org" to domain_name; needed for "Related sites"
}
public void Test_bld(String url, String expd_domain, String expd_url_fmt, int expd_wiki_tid, int expd_lang_tid) {
Xow_xwiki_itm itm = Xow_xwiki_itm_bldr.Instance.Bld_mw(domain_itm, domain_itm.Domain_bry(), Bry_.new_u8(url), null);

View File

@@ -60,7 +60,7 @@ public class Xow_xwiki_itm_parser extends Dsv_wkr_base {
default: throw Err_.new_unhandled(cur_tid);
}
byte[] abrv_wm = null;
int lang_id = Xol_lang_stub_.Id__unknown, domain_tid = Xow_domain_tid_.Int__other;
int lang_id = Xol_lang_stub_.Id__unknown, domain_tid = Xow_domain_tid_.Tid__other;
if (xwiki_is_mw) {
url_fmt = Xow_xwiki_mgr.Bld_url_fmt(domain_bry);
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);

View File

@@ -31,7 +31,7 @@ public class Xow_xwiki_mgr_tst {
}
@Test public void Add_bulk_langs_grp_commons() {
fxt.Init_langs();
fxt.Wiki().Xwiki_mgr().Add_by_sitelink_mgr(Xow_domain_tid_.Int__wikipedia);
fxt.Wiki().Xwiki_mgr().Add_by_sitelink_mgr(Xow_domain_tid_.Tid__wikipedia);
fxt.Tst_itms(fxt.xwiki_("de", "de.wikipedia.org", "https://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "https://fr.wikipedia.org/wiki/~{0}"));
}
@Test public void Add_bulk_peers() {
@@ -75,7 +75,7 @@ class Xow_xwiki_mgr_fxt {
lang_mgr.Clear();
}
public Xowe_wiki Wiki() {return wiki;}
public Xow_xwiki_itm xwiki_null_(String key) {return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.Empty, Xol_lang_stub_.Id__unknown, Xow_domain_tid_.Int__other, Bry_.Empty, Bry_.Empty);}
public Xow_xwiki_itm xwiki_null_(String key) {return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.Empty, Xol_lang_stub_.Id__unknown, Xow_domain_tid_.Tid__other, Bry_.Empty, Bry_.Empty);}
public Xow_xwiki_itm xwiki_(String key, String domain_str, String url_fmt) {
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.new_u8(url_fmt), domain.Lang_actl_itm().Id(), domain.Domain_type_id(), domain.Domain_bry(), domain.Abrv_wm());