mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
App: Release v4.5.15.1709
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
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();
|
||||
@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_.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_.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_.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_.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_.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_.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 {
|
||||
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) {
|
||||
Tfds.Eq_bool(expd, xwiki_itm.Show_in_sitelangs(Bry_.new_u8(cur_lang_key)));
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
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_.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_.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);
|
||||
Tfds.Eq(expd_domain , String_.new_u8(itm.Domain_bry()));
|
||||
Tfds.Eq(expd_url_fmt , String_.new_u8(itm.Url_fmt()));
|
||||
Tfds.Eq(expd_wiki_tid , itm.Domain_tid(), "wiki");
|
||||
Tfds.Eq(expd_lang_tid , itm.Lang_id(), "lang");
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.wikis.xwikis.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_parser_tst {
|
||||
private final Xow_xwiki_itm_parser_fxt fxt = new Xow_xwiki_itm_parser_fxt();
|
||||
@Test public void Manual() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "0|a|https://a.org/~{0}|A"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a|https://a.org/~{0}|A"
|
||||
));
|
||||
}
|
||||
@Test public void Mw_domain() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "1|w|en.wikipedia.org|Wikipedia"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "w|https://en.wikipedia.org/wiki/~{0}|Wikipedia"
|
||||
));
|
||||
}
|
||||
@Test public void Wm_peer() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt|wiktionary|Wiktionary"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
));
|
||||
}
|
||||
@Test public void Wm_lang() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "3|fr|fr|French"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "fr|https://fr.wikipedia.org/wiki/~{0}|French"
|
||||
));
|
||||
}
|
||||
@Test public void Multiple() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt;wiktionary|wiktionary|Wiktionary"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
, "wiktionary|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
));
|
||||
}
|
||||
@Test public void Default_name() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt|wiktionary|"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|English Wiktionary"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_itm_parser_fxt {
|
||||
private final Xow_xwiki_itm_parser parser = new Xow_xwiki_itm_parser();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public Xow_xwiki_itm_parser_fxt() {
|
||||
parser.Init_by_wiki(Xow_domain_itm_.parse(Bry_.new_a7("en.wikipedia.org")));
|
||||
}
|
||||
public void Exec_parse(String raw) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Load_by_bry(src);
|
||||
}
|
||||
public void Test_parse(String expd) {
|
||||
Tfds.Eq_str_lines(expd, To_str());
|
||||
}
|
||||
private String To_str() {
|
||||
Ordered_hash list = parser.Xwiki_list();
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_xwiki_itm itm = (Xow_xwiki_itm)list.Get_at(i);
|
||||
tmp_bfr.Add(itm.Key_bry()).Add_byte_pipe();
|
||||
tmp_bfr.Add(itm.Url_fmt()).Add_byte_pipe();
|
||||
tmp_bfr.Add(itm.Domain_name()).Add_byte_nl();
|
||||
}
|
||||
list.Clear();
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.wikis.xwikis.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.langs.*;
|
||||
public class Xow_xwiki_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_xwiki_mgr_fxt fxt = new Xow_xwiki_mgr_fxt();
|
||||
@Test public void Add_bulk_langs_wiki() {
|
||||
fxt.Init_langs();
|
||||
fxt.Test_add_bulk_langs
|
||||
( fxt.xwiki_("en", "en.wikipedia.org", "https://en.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("de", "de.wikipedia.org", "https://de.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("fr", "fr.wikipedia.org", "https://fr.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("ja", "ja.wikipedia.org", "https://ja.wikipedia.org/wiki/~{0}")
|
||||
);
|
||||
}
|
||||
@Test public void Add_bulk_langs_grp_commons() {
|
||||
fxt.Init_langs();
|
||||
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() {
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_("wikt", "en.wiktionary.org"
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("wiktionary", "en.wiktionary.org"
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("s", "en.wikisource.org", "https://en.wikisource.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_skip_self() { // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is Srch_rslt_cbk; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_null_("wikipedia")
|
||||
, fxt.xwiki_("w", "en.wikipedia.org", "https://en.wikipedia.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_tid() { // PURPOSE:wikt should generate wiki_tid of wiktionary, not wikipedia; PAGE:en.s:Main_Page DATE:2014-09-14
|
||||
fxt.Init_wikt ().Test_add_bulk_peers(fxt.xwiki_("wikt", "en.wiktionary.org", "https://en.wiktionary.org/wiki/~{0}"));
|
||||
}
|
||||
// @Test public void Duplicate() { // PURPOSE.FIX: multiple aliases for same domain should only be added once to Get_at's list; DATE:2014-11-07
|
||||
// fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
// ( "0|a1|a.org"
|
||||
// , "0|a2|a.org"
|
||||
// ));
|
||||
// fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
// ( "a1|https://a.org//~{0}"
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
class Xow_xwiki_mgr_fxt {
|
||||
Xow_xwiki_mgr xwiki_mgr; Xoa_lang_mgr lang_mgr; String_bldr sb = String_bldr_.new_(); Xoae_app app; Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
if (xwiki_mgr == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
xwiki_mgr = wiki.Xwiki_mgr();
|
||||
lang_mgr = app.Lang_mgr();
|
||||
}
|
||||
xwiki_mgr.Clear();
|
||||
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_.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());
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_langs() {
|
||||
app.Xwiki_mgr__sitelink_mgr().Parse(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "0|english"
|
||||
, "1|en|English"
|
||||
, "0|europe_west"
|
||||
, "1|fr|French"
|
||||
, "1|de|German"
|
||||
, "0|asia_east"
|
||||
, "1|ja|Japanese"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_peers() {
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "1|d|www.wikidata.org"
|
||||
, "2|wikt;wiktionary|wiktionary"
|
||||
, "2|s|wikisource"
|
||||
, "2|w;wikipedia|wikipedia"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_wikt() {
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "2|wikt;wiktionary|wiktionary"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_langs(Xow_xwiki_itm... itms) {
|
||||
xwiki_mgr.Add_by_sitelink_mgr();
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_peers(Xow_xwiki_itm... itms) {
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Tst_itms(Xow_xwiki_itm... itms) {
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_len(int expd) {Tfds.Eq(expd, xwiki_mgr.Len()); return this;}
|
||||
Xow_xwiki_itm[] To_ary(Xow_xwiki_itm[] itms) {
|
||||
int len = itms.length;
|
||||
List_adp rv = List_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] alias = itms[i].Key_bry();
|
||||
Xow_xwiki_itm itm = xwiki_mgr.Get_by_key(alias);
|
||||
if (itm == null) itm = xwiki_null_(String_.new_u8(alias)); // "null", ignore
|
||||
rv.Add(itm);
|
||||
}
|
||||
return (Xow_xwiki_itm[])rv.To_ary(Xow_xwiki_itm.class);
|
||||
}
|
||||
String Xto_str(Xow_xwiki_itm[] itms) {
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_xwiki_itm itm = itms[i];
|
||||
if (Bry_.Len_eq_0(itm.Domain_bry())) // "null", ignore
|
||||
sb.Add(itm.Key_bry()).Add_char_nl();
|
||||
else {
|
||||
sb.Add(itm.Key_bry()).Add_char_pipe().Add(itm.Domain_bry()).Add_char_pipe().Add(itm.Url_fmt()).Add_char_pipe().Add(itm.Domain_tid()).Add_char_nl();
|
||||
}
|
||||
}
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.wikis.xwikis.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_sitelink_mgr_parser_tst {
|
||||
private final Xoa_sitelink_mgr_parser_fxt fxt = new Xoa_sitelink_mgr_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
String raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|de|German"
|
||||
, "1|en|English"
|
||||
, "0|Tier 1"
|
||||
, "1|ar|Arabic"
|
||||
, "1|ca|Catalan"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
fxt.Test_parse(raw);
|
||||
}
|
||||
@Test public void Move() {
|
||||
String raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|de|German"
|
||||
, "0|Tier 1"
|
||||
, "1|ar|Arabic"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|ar|Arabic"
|
||||
, "0|Tier 1"
|
||||
, "1|de|German"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
fxt.Test_parse(raw);
|
||||
}
|
||||
}
|
||||
class Xoa_sitelink_mgr_parser_fxt {
|
||||
private final Xoa_sitelink_mgr mgr = new Xoa_sitelink_mgr();
|
||||
private final Xoa_sitelink_mgr_parser parser;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public void Clear() {mgr.Grp_mgr().Clear();}
|
||||
public Xoa_sitelink_mgr_parser_fxt() {
|
||||
this.parser = new Xoa_sitelink_mgr_parser(mgr);
|
||||
}
|
||||
public void Exec_parse(String raw) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Load_by_bry(src);
|
||||
}
|
||||
public void Test_parse(String expd) {
|
||||
mgr.Grp_mgr().To_bfr(tmp_bfr);
|
||||
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.parsers.*;
|
||||
class Xoa_sitelink_div_wtr_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Init_langs(wiki);
|
||||
}
|
||||
public static void Init_langs(Xowe_wiki wiki) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Xwiki_mgr__sitelink_mgr().Parse(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "0|grp1"
|
||||
, "1|simple|Simple"
|
||||
, "1|es|Spanish"
|
||||
, "1|it|Italian"
|
||||
, "1|zh|Chinese"
|
||||
, "0|grp2"
|
||||
, "1|fr|French"
|
||||
, "1|de|German"
|
||||
)));
|
||||
wiki.Xwiki_mgr().Add_by_sitelink_mgr();
|
||||
wiki.Appe().Usere().Wiki().Xwiki_mgr().Add_by_csv(Bry_.new_a7(String_.Concat_lines_nl
|
||||
( "1|simple.wikipedia.org|simple.wikipedia.org"
|
||||
, "1|fr.wikipedia.org|fr.wikipedia.org"
|
||||
, "1|es.wikipedia.org|es.wikipedia.org"
|
||||
, "1|de.wikipedia.org|de.wikipedia.org"
|
||||
, "1|it.wikipedia.org|it.wikipedia.org"
|
||||
)));
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
Xoae_app app;
|
||||
public void tst(String raw, String expd) {
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
|
||||
ctx.Page().Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7("test_page")));
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(raw_bry);
|
||||
wiki.Parser_mgr().Main().Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), raw_bry);
|
||||
wiki.Html_mgr().Html_wtr().Write_doc(bfr, ctx, raw_bry, root);
|
||||
|
||||
Bry_bfr html_bfr = Bry_bfr_.New();
|
||||
wiki.App().Xwiki_mgr__sitelink_mgr().Write_html(html_bfr, wiki, ctx.Page().Slink_list(), gplx.xowa.xtns.wbases.Wdata_xwiki_link_wtr.Qid_null);
|
||||
Tfds.Eq_str_lines(expd, html_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_sitelink_div_wtr_tst {
|
||||
private final Xoa_sitelink_div_wtr_fxt fxt = new Xoa_sitelink_div_wtr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.tst("[[simple:Earth]] [[fr:Terre]] [[es:Tierra]] [[de:Erde]] [[it:Terre]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 5) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"Earth\" href=\"/site/simple.wikipedia.org/wiki/Earth\">Earth</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Spanish</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"es\" title=\"Tierra\" href=\"/site/es.wikipedia.org/wiki/Tierra\">Tierra</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Italian</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"it\" title=\"Terre\" href=\"/site/it.wikipedia.org/wiki/Terre\">Terre</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " <h4>grp2</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>French</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"fr\" title=\"Terre\" href=\"/site/fr.wikipedia.org/wiki/Terre\">Terre</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>German</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"de\" title=\"Erde\" href=\"/site/de.wikipedia.org/wiki/Erde\">Erde</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Empty() {
|
||||
fxt.tst("[[simple:]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"Test page\" href=\"/site/simple.wikipedia.org/wiki/\">Test page</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Unregistered() {
|
||||
// fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("zh"), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_a7("http://zh.wikipedia.org/~{0}"));
|
||||
fxt.tst("[[zh:Earth]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Chinese</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"zh\" title=\"Earth\" href=\"https://zh.wikipedia.org/wiki/Earth\">Earth</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Anchor() {// PURPOSE: A#b was not showing anchor "#b"; DATE:2013-10-23
|
||||
fxt.tst("[[simple:A#b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"A#b\" href=\"/site/simple.wikipedia.org/wiki/A#b\">A#b</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user