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,177 +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.addons.bldrs.app_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
public class Xob_wiki_cfg_bldr_tst {
|
||||
Xob_wiki_cfg_bldr_fxt fxt = new Xob_wiki_cfg_bldr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Exec() {
|
||||
fxt .Init_cmd("en.wikipedia.org", "key0", "en.val0")
|
||||
.Init_cmd("en.wikipedia.org", "key1", "en.val1")
|
||||
.Init_cmd("fr.wikipedia.org", "key0", "fr.val0")
|
||||
.Init_cmd("fr.wikipedia.org", "key1", "fr.val1")
|
||||
.Expd_txt("en.wikipedia.org", String_.Concat_lines_nl
|
||||
( "// key0.bgn"
|
||||
, "en.val0"
|
||||
, "// key0.end"
|
||||
, "// key1.bgn"
|
||||
, "en.val1"
|
||||
, "// key1.end"
|
||||
))
|
||||
.Expd_txt("fr.wikipedia.org", String_.Concat_lines_nl
|
||||
( "// key0.bgn"
|
||||
, "fr.val0"
|
||||
, "// key0.end"
|
||||
, "// key1.bgn"
|
||||
, "fr.val1"
|
||||
, "// key1.end"
|
||||
))
|
||||
.Test()
|
||||
;
|
||||
fxt .Clear()
|
||||
.Init_cmd("en.wikipedia.org", "key2", "en.val2")
|
||||
.Expd_txt("en.wikipedia.org", String_.Concat_lines_nl
|
||||
( "// key0.bgn"
|
||||
, "en.val0"
|
||||
, "// key0.end"
|
||||
, "// key1.bgn"
|
||||
, "en.val1"
|
||||
, "// key1.end"
|
||||
, "// key2.bgn"
|
||||
, "en.val2"
|
||||
, "// key2.end"
|
||||
));
|
||||
}
|
||||
// @Test public void Lang_names_run() {
|
||||
// Io_url dir = Io_url_.new_dir_("/var/www/mediawiki/languages/messages/");
|
||||
// Io_url[] fils = Io_mgr.Instance.QueryDir_args(dir).ExecAsUrlAry();
|
||||
// int fils_len = fils.length;
|
||||
// String_bldr sb = String_bldr_.new_();
|
||||
// for (int i = 0; i < fils_len; i++) {
|
||||
// Io_url fil = fils[i];
|
||||
// String lang_code = String_.Lower(String_.Replace(fil.NameOnly(), "Messages", ""));
|
||||
// String txt = Io_mgr.Instance.LoadFilStr(fil);
|
||||
// String[] lines = String_.Split(txt, '\n');
|
||||
// String line = lines[1];
|
||||
// line = String_.Replace(line, "/** ", "");
|
||||
// int pos = String_.FindBwd(line, " (");
|
||||
// if (pos == String_.Find_none) continue; // en; en_rtl have no "language" line
|
||||
// if ( String_.Has_at_bgn(lang_code, "be_")
|
||||
// || String_.Has_at_bgn(lang_code, "crh_")
|
||||
// || String_.Has_at_bgn(lang_code, "kk_")
|
||||
// || String_.Has_at_bgn(lang_code, "ku_")
|
||||
// || String_.Has_at_bgn(lang_code, "sr_")
|
||||
// || String_.In(lang_code, "de_formal", "nb", "nl_informal", "nn", "no")
|
||||
// ) {
|
||||
// int new_pos = String_.FindBwd(line, " (", pos - 1);
|
||||
// if (new_pos != String_.Find_none)
|
||||
// pos = new_pos;
|
||||
// }
|
||||
// line = Replace_by_pos(line, pos, pos + 2, "|");
|
||||
// int line_len = String_.Len(line);
|
||||
// if (line_len > 0)
|
||||
// line = String_.MidByLen(line, 0, line_len - 1);
|
||||
// String[] terms = String_.Split(line, '|');
|
||||
// sb.Add(lang_code).Add("|").Add(String_.Trim(terms[0])).Add("|").Add(String_.Trim(terms[1])).Add("\n");
|
||||
// }
|
||||
// Tfds.Dbg(sb.To_str_and_clear());
|
||||
// }
|
||||
@Test public void Ns_aliases() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Io_mgr.Instance.SaveFilStr("mem/en.wikipedia.org/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases", String_.Concat_lines_nl
|
||||
( "<api>"
|
||||
, "<query>"
|
||||
, "<namespacealiases>"
|
||||
, "<ns id=\"4\" xml:space=\"preserve\">WP"
|
||||
, "</ns>"
|
||||
, "<ns id=\"5\" xml:space=\"preserve\">WT"
|
||||
, "</ns>"
|
||||
, "<ns id=\"6\" xml:space=\"preserve\">Image"
|
||||
, "</ns>"
|
||||
, "<ns id=\"7\" xml:space=\"preserve\">Image talk"
|
||||
, "</ns>"
|
||||
, "</namespacealiases>"
|
||||
, "</query>"
|
||||
, "</api>"
|
||||
));
|
||||
String[] wikis = new String[] {"en.wikipedia.org"}; String protocol = "mem/";
|
||||
Tfds.Eq_str_lines(Query_ns(protocol, gplx.core.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
|
||||
( "app.bldr.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
|
||||
, "4|WP"
|
||||
, "5|WT"
|
||||
, "6|Image"
|
||||
, "7|Image_talk"
|
||||
, "\");');"
|
||||
));
|
||||
}
|
||||
String Query_ns(String protocol, String trg_engine_key, String[] wikis) {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
int wikis_len = wikis.length;
|
||||
for (int i = 0; i < wikis_len; i++) {
|
||||
String wiki = wikis[i];
|
||||
if (String_.Len_eq_0(wiki)) continue;
|
||||
try {
|
||||
String api = protocol + wiki + "/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases";
|
||||
String xml = String_.new_u8(Io_mgr.Instance.DownloadFil_args("", null).Trg_engine_key_(trg_engine_key).Exec_as_bry(api));
|
||||
if (xml == null) continue; // not found
|
||||
gplx.langs.xmls.XmlDoc xdoc = gplx.langs.xmls.XmlDoc_.parse(xml);
|
||||
gplx.langs.xmls.XmlNde xnde = gplx.langs.xmls.Xpath_.SelectFirst(xdoc.Root(), "query/namespacealiases");
|
||||
sb.Add("app.bldr.wiki_cfg_bldr.get('").Add(wiki).Add("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
|
||||
int xndes_len = xnde.SubNdes().Count();
|
||||
for (int j = 0; j < xndes_len; j++) {
|
||||
gplx.langs.xmls.XmlNde ns_nde = xnde.SubNdes().Get_at(j);
|
||||
if (!String_.Eq(ns_nde.Name(), "ns")) continue;
|
||||
int id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
|
||||
String name = String_.Replace(String_.Replace(ns_nde.Text_inner(), " ", "_"), "'", "''");
|
||||
sb.Add(Int_.To_str(id)).Add("|").Add(String_.Trim(name)).Add_char_nl();
|
||||
}
|
||||
sb.Add("\");');\n");
|
||||
}
|
||||
catch(Exception e) {sb.Add("// fail: " + wiki + " " + Err_.Message_gplx_full(e)).Add_char_nl();}
|
||||
}
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
class Xob_wiki_cfg_bldr_fxt {
|
||||
public Xob_wiki_cfg_bldr_fxt Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki_cfg_bldr = app.Bldr().Wiki_cfg_bldr();
|
||||
}
|
||||
wiki_cfg_bldr.Clear();
|
||||
hash.Clear();
|
||||
return this;
|
||||
} private Xoae_app app; Xob_wiki_cfg_bldr wiki_cfg_bldr; Ordered_hash hash = Ordered_hash_.New();
|
||||
public Xob_wiki_cfg_bldr_fxt Init_cmd(String wiki, String key, String text) {
|
||||
wiki_cfg_bldr.Itms_get_or_new(wiki).Itms_add(key, text);
|
||||
return this;
|
||||
}
|
||||
public Xob_wiki_cfg_bldr_fxt Expd_txt(String wiki, String text) {
|
||||
hash.Add(wiki, Keyval_.new_(wiki, text));
|
||||
return this;
|
||||
}
|
||||
public void Test() {
|
||||
wiki_cfg_bldr.Exec();
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Keyval kv = (Keyval)hash.Get_at(i);
|
||||
String wiki = kv.Key();
|
||||
String expd = (String)kv.Val();
|
||||
String actl = Io_mgr.Instance.LoadFilStr(app.Fsys_mgr().Cfg_wiki_core_dir().GenSubFil(wiki + ".gfs"));
|
||||
Tfds.Eq_str_lines(expd, actl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +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.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Host_eval_wkr__tst {
|
||||
private final Host_eval_wkr__fxt fxt = new Host_eval_wkr__fxt();
|
||||
@Test public void En_w() {fxt.Test__resolve_quick("en.wikipedia.org" , "Xowa_enwiki_latest");}
|
||||
@Test public void Fr_d() {fxt.Test__resolve_quick("fr.wiktionary.org" , "Xowa_frwiki_latest");}
|
||||
@Test public void Species() {fxt.Test__resolve_quick("species.wikimedia.org" , "Xowa_enwiki_latest");}
|
||||
}
|
||||
class Host_eval_wkr__fxt {
|
||||
public void Test__resolve_quick(String domain_str, String expd) {
|
||||
Host_eval_itm eval_itm = new Host_eval_itm();
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
Gftest.Eq__bry(Bry_.new_u8(expd), eval_itm.Eval_dir_name(domain_itm));
|
||||
}
|
||||
}
|
||||
@@ -1,35 +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.addons.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Time_dhms__tst {
|
||||
private final Time_dhms__fxt fxt = new Time_dhms__fxt();
|
||||
@Test public void S__0() {fxt.Test__to_str( 0, 4, "0 s");}
|
||||
@Test public void S__1() {fxt.Test__to_str( 1, 4, "1 s");}
|
||||
@Test public void S__2() {fxt.Test__to_str( 30, 4, "30 s");}
|
||||
@Test public void M__1() {fxt.Test__to_str( 60, 4, "1:00 m");}
|
||||
@Test public void M__2() {fxt.Test__to_str( 600, 4, "10:00 m");}
|
||||
@Test public void H__1() {fxt.Test__to_str( 3600, 4, "1:00:00 h");}
|
||||
@Test public void H__2() {fxt.Test__to_str( 5025, 4, "1:23:45 h");}
|
||||
@Test public void D__1() {fxt.Test__to_str( 86400, 4, "1:00:00:00 d");}
|
||||
@Test public void Max_places() {fxt.Test__to_str( 86400, 2, "1:00 d");}
|
||||
}
|
||||
class Time_dhms__fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public Time_dhms__fxt Test__to_str(long v, int max_places, String expd) {
|
||||
Gftest.Eq__str(expd, Time_dhms_.To_str(bfr, v, Bool_.Y, max_places));
|
||||
return this;}
|
||||
}
|
||||
@@ -1,39 +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.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Pack_zip_name_bldr__tst {
|
||||
private Pack_zip_name_bldr__fxt fxt = new Pack_zip_name_bldr__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__to_wiki_url("mem/wiki/en.wikipedia.org/", "mem/wiki/en.wikipedia.org/tmp/Xowa_enwiki_2016-09_file_deletion_2016.09/", "mem/wiki/en.wikipedia.org/en.wikipedia.org-file-deletion-2016.09.xowa");
|
||||
}
|
||||
@Test public void Bld_by_suffix() {
|
||||
Pack_zip_name_bldr bldr = fxt.Make__bldr("mem/wiki/en.wikipedia.org/tmp/pack/", "en.wikipedia.org", "enwiki", "2017-03", null);
|
||||
fxt.Test__bld_by_suffix(bldr, "xtn.fulltext_search", 1, "mem/wiki/en.wikipedia.org/tmp/pack/Xowa_enwiki_2017-03_xtn.fulltext_search.002.zip");
|
||||
}
|
||||
}
|
||||
class Pack_zip_name_bldr__fxt {
|
||||
public void Test__to_wiki_url(String wiki_dir, String zip_fil, String expd) {
|
||||
Gftest.Eq__str(expd, Pack_zip_name_bldr.To_wiki_url(Io_url_.mem_fil_(wiki_dir), Io_url_.mem_dir_(zip_fil)).Raw(), "wiki_url");
|
||||
}
|
||||
|
||||
public Pack_zip_name_bldr Make__bldr(String wiki_dir, String domain, String wiki_abrv, String wiki_date, String custom_name) {
|
||||
return new Pack_zip_name_bldr(Io_url_.new_dir_(wiki_dir), domain, wiki_abrv, wiki_date, custom_name);
|
||||
}
|
||||
public void Test__bld_by_suffix(Pack_zip_name_bldr bldr, String suffix, int pack_num, String expd) {
|
||||
Gftest.Eq__str(expd, bldr.Bld_by_suffix(suffix, pack_num).Xto_api());
|
||||
}
|
||||
}
|
||||
@@ -1,49 +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.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.files.*;
|
||||
public class Xobldr__image__create_tst {
|
||||
private Xobldr__image__create_fxt fxt = new Xobldr__image__create_fxt();
|
||||
@Test public void Basic() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_png, 220, 110) .Test(Xof_ext_.Id_png);} // A.png -> png
|
||||
@Test public void Ogg_VIDEO() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 220, 110) .Test(Xof_ext_.Id_ogv);} // A.ogg and VIDEO -> ogv
|
||||
@Test public void Ogg_VIDEO_null_size() {fxt.Init_("A.ogg" , Xof_media_type.Name_video , Xof_ext_.Bry_ogg, 0, 0) .Test(Xof_ext_.Id_ogg);} // A.ogg but 0,0 -> ogg (not ogv)
|
||||
@Test public void Png_is_jpg() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpg);} // A.png and jpg -> jpg
|
||||
@Test public void Jpeg_is_jpeg() {fxt.Init_("A.jpeg" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_jpg, 220, 110) .Test(Xof_ext_.Id_jpeg);} // A.jpeg and jpg -> jpeg (unchanged)
|
||||
}
|
||||
class Xobldr__image__create_fxt {
|
||||
private byte[] name, media_type, minor_mime; int w, h;
|
||||
public Xobldr__image__create_fxt Init_png() {Name_("A.png").Media_type_(Xof_media_type.Name_bitmap).Minor_mime_(Xof_ext_.Bry_png).W_(220).H_(110);
|
||||
return this;
|
||||
}
|
||||
public Xobldr__image__create_fxt Init_(String name, String media_type, byte[] minor_mime, int w, int h) {
|
||||
Name_(name);
|
||||
Media_type_(media_type);
|
||||
Minor_mime_(minor_mime);
|
||||
W_(w);
|
||||
H_(h);
|
||||
return this;
|
||||
}
|
||||
public Xobldr__image__create_fxt Name_(String v) {name = Bry_.new_a7(v); return this;}
|
||||
public Xobldr__image__create_fxt Media_type_(String v) {media_type = Bry_.new_a7(v); return this;}
|
||||
public Xobldr__image__create_fxt Minor_mime_(byte[] v) {minor_mime = v; return this;}
|
||||
public Xobldr__image__create_fxt Minor_mime_(String v) {return Minor_mime_(Bry_.new_a7(v));}
|
||||
public Xobldr__image__create_fxt W_(int v) {w = v; return this;}
|
||||
public Xobldr__image__create_fxt H_(int v) {h = v; return this;}
|
||||
public Xobldr__image__create_fxt Test(int expd) {
|
||||
Tfds.Eq(expd, Xobldr__image__create.Calc_ext_id(Gfo_usr_dlg_.Noop, name, media_type, minor_mime, w, h));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +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.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import org.junit.*;
|
||||
public class Xobldr__lnki_temp__create__tst {
|
||||
private Xobldr__lnki_temp__create__fxt fxt = new Xobldr__lnki_temp__create__fxt();
|
||||
@Test public void Xto_commons() {
|
||||
fxt.Init__to_commons(true);
|
||||
fxt.Test__to_commons("a", "A");
|
||||
fxt.Test__to_commons("A", null);
|
||||
fxt.Init__to_commons(false);
|
||||
fxt.Test__to_commons("a", null);
|
||||
fxt.Test__to_commons("A", null);
|
||||
}
|
||||
}
|
||||
class Xobldr__lnki_temp__create__fxt {
|
||||
private boolean wiki_ns_file_is_case_match_all;
|
||||
private Xowe_wiki commons_wiki;
|
||||
public Xobldr__lnki_temp__create__fxt Init__to_commons(boolean wiki_ns_file_is_case_match_all) {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki_ns_file_is_case_match_all = wiki_ns_file_is_case_match_all;
|
||||
this.commons_wiki = Xoa_app_fxt.Make__wiki__edit(app); // commons_wiki will default to Xow_ns.Id_file of case_match_1st
|
||||
return this;
|
||||
}
|
||||
public void Test__to_commons(String ttl, String expd) {
|
||||
Tfds.Eq(expd, String_.new_u8(gplx.xowa.addons.bldrs.mass_parses.parses.utls.Xomp_lnki_temp_wkr.To_commons_ttl(wiki_ns_file_is_case_match_all, commons_wiki, Bry_.new_u8(ttl))));
|
||||
}
|
||||
}
|
||||
@@ -1,41 +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.addons.bldrs.files.missing_origs.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.addons.bldrs.files.missing_origs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xowmf_imageinfo_item__tst {
|
||||
private final Xowmf_imageinfo_item__fxt fxt = new Xowmf_imageinfo_item__fxt();
|
||||
|
||||
@Test public void Normalize_ttl() {
|
||||
fxt.Test__Normalize_ttl("File:A b.png", "A_b.png");
|
||||
}
|
||||
@Test public void Normalize_minor_mime() {
|
||||
fxt.Test__Normalize_minor_mime("image/svg+xml", "svg+xml");
|
||||
}
|
||||
@Test public void Normalize_timestamp() {
|
||||
fxt.Test__Normalize_timestamp("2017-03-06T08:09:10Z", "20170306080910");
|
||||
}
|
||||
}
|
||||
class Xowmf_imageinfo_item__fxt {
|
||||
public void Test__Normalize_ttl(String src, String expd) {
|
||||
Gftest.Eq__str(expd, Xowmf_imageinfo_item.Normalize_ttl(Bry_.new_u8(src)));
|
||||
}
|
||||
public void Test__Normalize_timestamp(String src, String expd) {
|
||||
Gftest.Eq__str(expd, Xowmf_imageinfo_item.Normalize_timestamp(Bry_.new_u8(src)));
|
||||
}
|
||||
public void Test__Normalize_minor_mime(String src, String expd) {
|
||||
Gftest.Eq__str(expd, Xowmf_imageinfo_item.Normalize_minor_mime(Bry_.new_u8(src)));
|
||||
}
|
||||
}
|
||||
@@ -1,190 +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.addons.bldrs.files.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.gfo_ndes.*;
|
||||
import gplx.core.stores.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.files.*;
|
||||
import gplx.xowa.addons.bldrs.files.dbs.*;
|
||||
public class Xob_xfer_temp_itm_tst {
|
||||
private Xob_xfer_temp_itm_fxt fxt = new Xob_xfer_temp_itm_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Pass() {fxt.Test_pass().Test_itm_chk_fail_id_none();}
|
||||
@Test public void Missing_orig() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_page_id_is_null , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_page_id, null));}
|
||||
@Test public void File_is_audio() {fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type, Xof_media_type.Name_audio));}
|
||||
@Test public void File_is_mid() {
|
||||
fxt.Test_fail(Xob_xfer_temp_itm.Chk_tid_orig_media_type_is_audio , Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext, Xof_ext_.Id_mid));
|
||||
}
|
||||
@Test public void Redirect_src_is_empty() { // orig_cmd sets all direct files to have "orig_join" == "lnki_ttl"
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "A.png")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
);
|
||||
fxt.Test_lnki_redirect_src(""); // confirm redirect_src set to ""
|
||||
}
|
||||
@Test public void Redirect_src_has_val() { // orig_cmd sets all redirect files to have "orig_join" = redirect and "lnki_ttl" as orig; EX: A.png redirects to B.png; orig_join will be B.png (the actual image) and redirect_src will be A.png (the original lnki)
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "B.png")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
);
|
||||
fxt.Test_lnki_redirect_src("A.png"); // confirm redirect_src set to ""
|
||||
}
|
||||
@Test public void Redirect_should_take_trg_ext() {// if "A.png" redirects to "B.jpg", ext_id should be ".jpg" (the actual file) not ".png (lnki_ext_id)
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ttl , "B.jpg")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg) // .png b/c B.jpg
|
||||
);
|
||||
fxt.Test_lnki_ext_id(Xof_ext_.Id_jpg); // confirm ext changed to .jpg
|
||||
}
|
||||
@Test public void Thumbtime_check() {// PURPOSE: one image actually had a thumbtime defined; EX: General_Dynamics_F-16_Fighting_Falcon; [[File:Crash.arp.600pix.jpg|thumb|thumbtime=2]]
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_time , (double)3)
|
||||
);
|
||||
fxt.Test_lnki_thumbtime(Xof_lnki_time.Null);
|
||||
fxt.Reset().Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type , Xof_media_type.Name_video)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_time , (double)3)
|
||||
);
|
||||
fxt.Test_lnki_thumbtime(3);
|
||||
}
|
||||
@Test public void Page_check() {
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(Xof_lnki_page.Null);
|
||||
fxt.Reset().Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_pdf)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(3);
|
||||
fxt.Reset().Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_djvu)
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(3);
|
||||
}
|
||||
@Test public void Media_should_be_ignored() {// ignore [[Media:]] for xfer_thumb (needed for xfer_orig)
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.png")
|
||||
, Keyval_.new_(Xob_lnki_regy_tbl.Fld_lnki_src_tid , Xop_file_logger_.Tid__media)
|
||||
);
|
||||
fxt.Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_ns_is_media);
|
||||
}
|
||||
@Test public void Orig_width_is_0() {// PURPOSE: ignore files with an orig width of 0; note that ogg files that are sometimes flagged as VIDEO; EX:2009_10_08_Marc_Randazza_interview.ogg; DATE:2014-08-20
|
||||
fxt.Test_bgn
|
||||
( Keyval_.new_(Xob_orig_regy_tbl.Fld_lnki_ttl , "A.ogg")
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_media_type , Xof_media_type.Name_video) // VIDEO
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_w , 0) // no width defined in image table
|
||||
, Keyval_.new_(Xob_orig_regy_tbl.Fld_orig_h , 0)
|
||||
);
|
||||
fxt.Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_orig_w_is_0);
|
||||
}
|
||||
}
|
||||
class Xob_xfer_temp_itm_fxt {
|
||||
private Xob_xfer_temp_itm itm = new Xob_xfer_temp_itm();
|
||||
private Xof_img_size img_size = new Xof_img_size();
|
||||
private DataRdr_mem rdr;
|
||||
private GfoNde nde;
|
||||
public static String[] Flds = new String[]
|
||||
{ Xob_lnki_regy_tbl.Fld_lnki_ext
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_id
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_tier_id
|
||||
, Xob_orig_regy_tbl.Fld_orig_repo
|
||||
, Xob_orig_regy_tbl.Fld_orig_file_ttl
|
||||
, Xob_orig_regy_tbl.Fld_orig_file_ext
|
||||
, Xob_orig_regy_tbl.Fld_lnki_ttl
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_type
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_src_tid
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_w
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_h
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_count
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_page_id
|
||||
, Xob_orig_regy_tbl.Fld_orig_w
|
||||
, Xob_orig_regy_tbl.Fld_orig_h
|
||||
, Xob_orig_regy_tbl.Fld_orig_page_id
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_upright
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_time
|
||||
, Xob_lnki_regy_tbl.Fld_lnki_page
|
||||
, Xob_orig_regy_tbl.Fld_orig_media_type
|
||||
, Xob_orig_regy_tbl.Fld_orig_minor_mime
|
||||
}
|
||||
;
|
||||
public Xob_xfer_temp_itm_fxt Reset() {
|
||||
itm.Clear();
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Init_rdr_image() {
|
||||
GfoFldList flds = GfoFldList_.str_(Flds);
|
||||
nde = GfoNde_.vals_(flds, Object_.Ary
|
||||
( Xof_ext_.Id_png, 1, 1, Xof_repo_tid_.Tid__remote
|
||||
, "A.png", Xof_ext_.Id_png, "A.png", Xop_lnki_type.Id_thumb, Xop_file_logger_.Tid__file
|
||||
, 220, 200, 1, 2, 440, 400, 3
|
||||
, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xof_media_type.Name_bitmap, "png"
|
||||
));
|
||||
GfoNdeList subs = GfoNdeList_.new_();
|
||||
subs.Add(nde);
|
||||
GfoNde root = GfoNde_.root_(nde);
|
||||
rdr = DataRdr_mem.new_(root, flds, subs);
|
||||
rdr.MoveNextPeer();
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Init_rdr(String key, Object val) {
|
||||
nde.Write(key, val);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_pass() {return Test_bgn();}
|
||||
public Xob_xfer_temp_itm_fxt Test_fail(byte fail_tid, Keyval... kvs) {
|
||||
Test_bgn(kvs);
|
||||
this.Test_itm_chk_fail_id(fail_tid);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_bgn(Keyval... kvs) {
|
||||
Init_rdr_image();
|
||||
int len = kvs.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Keyval kv = kvs[i];
|
||||
Init_rdr(kv.Key(), kv.Val());
|
||||
}
|
||||
this.Exec_load();
|
||||
this.Exec_chk();
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_atr(String key, Object val) {
|
||||
Tfds.Eq(rdr.Read(key), val);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Exec_load() {
|
||||
itm.Load(rdr);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Exec_chk() {
|
||||
itm.Chk(img_size);
|
||||
return this;
|
||||
}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_ext_id(int expd) {Tfds.Eq(expd, itm.Lnki_ext()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_thumbtime(double expd) {Tfds.Eq(expd, itm.Lnki_thumbtime()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_page(int expd) {Tfds.Eq(expd, itm.Lnki_page()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_lnki_redirect_src(String expd) {Tfds.Eq(expd, itm.Redirect_src()); return this;}
|
||||
public Xob_xfer_temp_itm_fxt Test_itm_chk_fail_id_none() {return Test_itm_chk_fail_id(Xob_xfer_temp_itm.Chk_tid_none);}
|
||||
public Xob_xfer_temp_itm_fxt Test_itm_chk_fail_id(byte expd) {
|
||||
Tfds.Eq(expd, itm.Chk_tid());
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +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.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xobc_info_html__tst {
|
||||
private final Xobc_info_html__fxt fxt = new Xobc_info_html__fxt();
|
||||
@Test public void Torrent__en_w() {fxt.Test__torrent_link("en.wikipedia.org" , "https://archive.org/download/Xowa_enwiki_latest_archive.torrent");}
|
||||
@Test public void Torrent__fr_d() {fxt.Test__torrent_link("fr.wiktionary.org" , "https://archive.org/download/Xowa_frwiki_latest_archive.torrent");}
|
||||
}
|
||||
class Xobc_info_html__fxt {
|
||||
public void Test__torrent_link(String domain_str, String expd) {
|
||||
Gftest.Eq__str(expd, Xobc_info_html.Make_torrent_fil("https://archive.org/download/", Xow_domain_itm_.parse(Bry_.new_u8(domain_str))));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +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.addons.bldrs.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Volume_prep_rdr_tst {
|
||||
private final Volume_prep_rdr_fxt fxt = new Volume_prep_rdr_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last("A", "", "B")
|
||||
, fxt.Make__itm("A")
|
||||
, fxt.Make__itm("B")
|
||||
);
|
||||
}
|
||||
}
|
||||
class Volume_prep_rdr_fxt {
|
||||
private final Volume_prep_rdr rdr = new Volume_prep_rdr();
|
||||
public Volume_prep_rdr_fxt Test__parse(String raw, Volume_prep_itm... expd) {
|
||||
Gftest.Eq__ary(expd, rdr.Parse(Bry_.new_u8(raw)));
|
||||
return this;
|
||||
}
|
||||
public Volume_prep_itm Make__itm(String page_ttl) {
|
||||
Volume_prep_itm rv = new Volume_prep_itm();
|
||||
rv.Page_ttl = Bry_.new_u8(page_ttl);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user