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-07-12 21:10:02 -04:00
commit 794b5a232f
3099 changed files with 238212 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__anchor_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Anch_y() {fxt.Init_ttl("a#b") .Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();}
@Test public void Anch_only() {fxt.Init_ttl("#a") .Expd_full_txt("").Expd_page_txt("").Expd_anch_txt("a").Test();}
@Test public void Anchor_fails() { // PURPOSE: :#batch:Main Page causes ttl to fail b/c # is treated as anchor; DATE:2013-01-02
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("#batch"), Bry_.new_a7("none"));
fxt.Init_ttl(":#batch:Main Page").Expd_full_txt("Main Page").Test();
}
@Test public void Anchor_angles() {// PURPOSE: angles in anchor should be encoded; DATE: 2013-01-23
fxt.Init_ttl("A#b<c>d").Expd_full_txt("A").Expd_anch_txt("b.3Cc.3Ed").Test();
}
@Test public void Anchor_arg_in_non_main_ns() {
fxt.Init_ttl("Help:A#B").Expd_full_txt("Help:A").Expd_anch_txt("B").Test();
}
@Test public void Anchor_and_slash() { // PURPOSE: slash in anchor was being treated as a subpage; DATE:2014-01-14
fxt.Init_ttl("A#b/c").Expd_full_txt("A").Expd_anch_txt("b/c").Expd_leaf_txt("A").Test(); // NOTE: Leaf_txt should be Page_txt; used to fail
}
@Test public void Decode_ncr() { // PURPOSE: convert &#x23; to #; PAGE:en.s:The_English_Constitution_(1894) DATE:2014-09-07
fxt.Init_ttl("A&#x23;b").Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();
fxt.Init_ttl("A&#35;b").Expd_full_txt("A").Expd_page_txt("A").Expd_anch_txt("b").Test();
fxt.Init_ttl("A&#36;b").Expd_full_txt("A$b").Expd_page_txt("A$b").Expd_anch_txt("").Test();
}
}

View File

@@ -0,0 +1,61 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__basic_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Ns() {fxt.Init_ttl("Help:Test") .Expd_ns_id(Xow_ns_.Id_help).Expd_page_txt("Test").Test();}
@Test public void Ns_false() {fxt.Init_ttl("Helpx:Test") .Expd_ns_id(Xow_ns_.Id_main).Expd_page_txt("Helpx:Test").Test();}
@Test public void Ns_multiple() {fxt.Init_ttl("Help:Talk:test") .Expd_page_txt("Talk:test").Test();}
@Test public void Full_txt() {fxt.Init_ttl("Help:a & b") .Expd_full_txt("Help:A & b").Test();} // preserve
@Test public void Full_url() {fxt.Init_ttl("Help:a & b") .Expd_full_url("Help:A_%26_b").Test();} // escape
@Test public void Page_txt() {fxt.Init_ttl("a & b") .Expd_page_txt("A & b").Test();} // preserve;
@Test public void Page_txt_underline() {fxt.Init_ttl("a_b") .Expd_page_txt("A b").Expd_page_url("A_b").Test();} // NOTE: raw is "a_b" but txt is "a b"
@Test public void Page_url() {fxt.Init_ttl("a & b") .Expd_page_url("A_%26_b").Test();} // escape
@Test public void Page_url_w_ns() {fxt.Init_ttl("Help:a & b") .Expd_page_url("A_%26_b").Test();} // remove ns
@Test public void Page_url_symbols() {fxt.Init_ttl(";:@&=$ -_.+!*'(),/").Expd_page_url(";:@%26%3D$_-_.%2B!*%27(),/").Test();}// symbols + space
@Test public void Leaf_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_leaf_txt("leaf").Test();}
@Test public void Leaf_txt_slash_is_last() {fxt.Init_ttl("root/mid/leaf/") .Expd_leaf_txt("").Test();}
@Test public void Leaf_txt_no_slash() {fxt.Init_ttl("root") .Expd_leaf_txt("Root").Test();}
@Test public void Leaf_url() {fxt.Init_ttl("root/mid/a & b") .Expd_leaf_url("a_%26_b").Test();} // NOTE: a not capitalized ("root" would be)
@Test public void Base_txt() {fxt.Init_ttl("a & b/mid/leaf") .Expd_base_txt("A & b/mid").Test();}
@Test public void Base_url() {fxt.Init_ttl("a & b/mid/leaf") .Expd_base_url("A_%26_b/mid").Test();}
@Test public void Root_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_root_txt("Root").Test();}
@Test public void Rest_txt() {fxt.Init_ttl("root/mid/leaf") .Expd_rest_txt("mid/leaf").Test();}
@Test public void Talk_txt() {fxt.Init_ttl("Help:test") .Expd_talk_txt("Help talk:Test").Test();}
@Test public void Talk_txt_identity() {fxt.Init_ttl("Help talk:test") .Expd_talk_txt("Help talk:Test").Test();}
@Test public void Talk_url() {fxt.Init_ttl("Help:a & b") .Expd_talk_url("Help_talk:A_%26_b").Test();}
@Test public void Talk_txt_main() {fxt.Init_ttl("test") .Expd_talk_txt("Talk:Test").Test();}
@Test public void Subj_txt() {fxt.Init_ttl("Help talk:test") .Expd_subj_txt("Help:Test").Test();}
@Test public void Subj_txt_identity() {fxt.Init_ttl("Help:test") .Expd_subj_txt("Help:Test").Test();}
@Test public void Subj_url() {fxt.Init_ttl("Help talk:a & b").Expd_subj_url("Help:A_%26_b").Test();}
@Test public void Subj_txt_main() {fxt.Init_ttl("Talk:test") .Expd_subj_txt("Test").Test();}
@Test public void Force_literal_link_y() {fxt.Init_ttl(":Help:test") .Expd_force_literal_link(1).Expd_page_txt("Test").Test();}
@Test public void Force_literal_link_n() {fxt.Init_ttl( "Help:test") .Expd_force_literal_link(0).Expd_page_txt("Test").Test();}
@Test public void Force_literal_link_y_2() {fxt.Init_ttl("::Help:test") .Expd_force_literal_link(1).Expd_page_txt("Test").Test();} // PURPOSE: 2nd initial colon should be ignored; EX:mw:MediaWiki; [[::MediaWiki]]; DATE:2013-12-14
@Test public void All_page() {fxt.Init_ttl("test") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Id_main).Expd_page_txt("Test").Expd_leaf_txt("Test").Expd_anch_txt("").Test();}
@Test public void All_ns() {fxt.Init_ttl("Help:test") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Id_help).Expd_page_txt("Test").Expd_leaf_txt("Test").Expd_anch_txt("").Test();}
@Test public void Special() {fxt.Init_ttl("Special:Random").Expd_ns_id(Xow_ns_.Id_special).Expd_page_txt("Random").Test();}
@Test public void Special_xowa() {fxt.Init_ttl("Special:xowa/Search/Ttl").Expd_ns_id(Xow_ns_.Id_special).Expd_page_txt("Xowa/Search/Ttl").Test();}
@Test public void Comment() {fxt.Init_ttl("Ab<!--b-->").Expd_page_txt("Ab").Test();}
@Test public void Comment_eos() {fxt.Init_ttl("Ab<!--b--").Expd_page_txt(null).Test();}
@Test public void Ns_case() {// PURPOSE: lowercase ns should be converted to proper case; EX: fr.w:Project:Sandbox (redirect link); en.w:Periclimenes imperator; [[commons:category:Periclimenes imperator|''Periclimenes imperator'']]; DATE: 2013-01-27
fxt.Init_ttl("help:A").Expd_full_txt("Help:A").Test();
fxt.Init_ttl("help talk:A").Expd_full_txt("Help talk:A").Test();
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__err_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Invalid() {fxt.Init_ttl("<!--A").Expd_err(Xop_ttl_log.Comment_eos).Test();}
@Test public void Invalid_brace() {fxt.Init_ttl("[[a]]").Expd_err(Xop_ttl_log.Invalid_char).Test();}
@Test public void Invalid_curly() {fxt.Init_ttl("{{a}}").Expd_err(Xop_ttl_log.Invalid_char).Test();}
@Test public void Len_0() {
fxt.Init_ttl("").Expd_err(Xop_ttl_log.Len_0).Test();
fxt.Init_ttl(" ").Expd_err(Xop_ttl_log.Len_0).Test();
fxt.Init_ttl("_").Expd_err(Xop_ttl_log.Len_0).Test();
fxt.Init_ttl("_ _").Expd_err(Xop_ttl_log.Len_0).Test();
}
@Test public void Len_max() {
fxt.Init_ttl(String_.Repeat("A", 512)).Expd_page_txt(String_.Repeat("A", 512)).Test();
// fxt.Init_ttl("File:" + String_.Repeat("A", 255)).Expd_page_txt(String_.Repeat("A", 255)).Test(); // DELETE: removing multi-byte check; DATE:2013-02-02
// fxt.Init_ttl(String_.Repeat("A", 256)).Expd_err(Xop_ttl_log.Len_max).Test();
// fxt.Init_ttl("Special:" + String_.Repeat("A", 255)).Expd_ns_id(Xow_ns_.Id_special).Expd_page_txt(String_.Repeat("A", 255)).Test();
// fxt.Init_ttl("Special:" + String_.Repeat("A", 512 + 8)).Expd_err(Xop_ttl_log.Len_max).Test(); // 8="Special:".length
}
@Test public void Colon_is_last_ns() {fxt.Init_ttl("Help:").Expd_err(Xop_ttl_log.Ttl_is_ns_only).Test();}
}

View File

@@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__html_entity_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Eacute() {fxt.Init_ttl("&eacute;").Expd_page_txt("é").Test();} //É
@Test public void Amp_at_end() {fxt.Init_ttl("Bisc &").Expd_page_txt("Bisc &").Test();}
@Test public void Ncr_dec() {fxt.Init_ttl("A&#98;").Expd_page_txt("Ab").Test();}
@Test public void Ncr_hex() {fxt.Init_ttl("A&#x62;").Expd_page_txt("Ab").Test();}
@Test public void Nbsp() {fxt.Init_ttl("A&nbsp;b").Expd_page_txt("A b").Test();} // NOTE: &nbsp must convert to space; EX:w:United States [[Image:Dust Bowl&nbsp;- Dallas, South Dakota 1936.jpg|220px|alt=]]
@Test public void Amp() {fxt.Init_ttl("A&amp;b").Expd_page_txt("A&b").Test();} // PURPOSE: A&amp;B -> A&B; PAGE:en.w:Amadou Bagayoko?redirect=n; DATE:2014-09-23
}

View File

@@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
import gplx.xowa.langs.cases.*;
public class Xow_ttl__i18n_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Bidi() {
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(226, 128, 142)) + "B").Expd_page_txt("AB").Test();
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(226, 128, 97)) + "B").Expd_page_txt("A" + String_.new_u8(Bry_.ints_(226, 128, 97)) + "B").Test();
}
@Test public void Multi_byte_char2() { // PURPOSE: multi-byte HTML entity causes array out of index error; EX: w:List_of_Unicode_characters; DATE:2013-12-25
fxt.Init_ttl("&#x2c65;").Expd_full_txt("").Test();
}
@Test public void First_char_is_multi_byte() { // PURPOSE: if multi-byte, uppercasing is complicated; EX: µ -> Μ; DATE:2013-11-27
fxt.Wiki().Lang().Case_mgr_utf8_();
fxt.Init_ttl("µ").Expd_full_txt("Μ").Test(); // NOTE: this is not an ASCII "Μ"
fxt.Init_ttl("µab").Expd_full_txt("Μab").Test(); // check that rest of title works fine
fxt.Init_ttl("Help:µab").Expd_full_txt("Help:Μab").Test(); // check ns
fxt.Init_ttl("Ι").Expd_full_txt("Ι").Test(); // check that Ι is not upper-cased to COMBINING GREEK YPOGEGRAMMENI; DATE:2014-02-24
}
@Test public void First_char_is_multi_byte_assymetrical() { // PURPOSE: test multi-byte asymmetry (lc is 3 bytes; uc is 2 bytes)
fxt.Wiki().Lang().Case_mgr_utf8_();
fxt.Init_ttl("").Expd_full_txt("Ⱥ").Test();
fxt.Init_ttl("ⱥab").Expd_full_txt("Ⱥab").Test(); // check that rest of title works fine
fxt.Init_ttl("Help:ⱥab").Expd_full_txt("Help:Ⱥab").Test(); // check ns
}
}

View File

@@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__qarg_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Base_txt_wo_qarg() {
fxt.Init_ttl("Special:Search/A?b=c").Expd_base_txt_wo_qarg("Search").Expd_qarg_txt("b=c").Test();
}
@Test public void Leaf_txt_wo_qarg() {
fxt.Init_ttl("Special:Search/A?b=c").Expd_leaf_txt_wo_qarg("A").Expd_qarg_txt("b=c").Test();
}
@Test public void Ttl_has_question_mark() { // PURPOSE: handle titles that have both question mark and leaf; PAGE:en.w:Portal:Organized_Labour/Did_You_Know?/1 DATE:2014-06-08
fxt.Init_ttl("A/B?/1").Expd_page_txt("A/B?/1").Expd_base_txt("A/B?").Expd_leaf_txt("1").Expd_leaf_txt_wo_qarg("1").Expd_qarg_txt(null).Test();
}
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__ws_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Space() {fxt.Init_ttl(" a b ") .Expd_page_url("A_b").Expd_page_txt("A b").Test();}
@Test public void Space_w_ns() {fxt.Init_ttl(" Help : a b ") .Expd_page_url("A_b").Expd_page_txt("A b").Test();}
@Test public void Nl() {fxt.Init_ttl("\n\na\n\n") .Expd_page_txt("A").Test();}
@Test public void Nl_end() {fxt.Init_ttl("a\nb") .Expd_page_txt("A b").Test();}
@Test public void Tab() {fxt.Init_ttl("\ta\t") .Expd_page_txt("A").Test();}
@Test public void Nbsp() {fxt.Init_ttl("A&nbsp;bc") .Expd_page_url("A_bc").Expd_page_txt("A bc").Test();} // PURPOSE:convert "&nbsp;" to " "; DATE:2014-09-25
@Test public void Nbsp_mix() {fxt.Init_ttl("A &nbsp; bc") .Expd_page_url("A_bc").Expd_page_txt("A bc").Test();} // PURPOSE:convert multiple "&nbsp;" to " "; PAGE:en.w:Greek_government-debt_crisis; DATE:2014-09-25
}

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__xwik_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Known() {fxt.Init_ttl("fr:a") .Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Id_main).Expd_page_txt("a").Test();}
@Test public void Known_ns() {fxt.Init_ttl("fr:Help:a") .Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Id_main).Expd_full_txt("Help:a").Expd_page_txt("Help:a").Test();} // NOTE: Page is "Help:a" b/c ns are unknowable in foreign wiki
@Test public void Unknown() {fxt.Init_ttl("frx:a") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Id_main).Expd_page_txt("Frx:a").Test();}
@Test public void Unknown_ns() {fxt.Init_ttl("frx:Help:a") .Expd_xwik_txt("").Expd_ns_id(Xow_ns_.Id_main).Expd_page_txt("Frx:Help:a").Test();}
@Test public void Known_ns_leaf_anch() {fxt.Init_ttl("fr:Help:a/b/c#d").Expd_xwik_txt("fr").Expd_ns_id(Xow_ns_.Id_main).Expd_page_txt("Help:a/b/c").Expd_leaf_txt("c").Expd_anch_txt("d").Expd_full_txt("Help:a/b/c").Test();}
@Test public void Colon_is_last() {
fxt.Init_ttl("fr:Help:").Expd_xwik_txt("fr").Expd_page_txt("Help:").Test();
fxt.Init_ttl("fr:_ _").Expd_xwik_txt("fr").Expd_page_txt("").Test(); // NOTE: fr:_ _ is invalid (resolves to "fr:");
fxt.Init_ttl("fr:Help:_ _").Expd_xwik_txt("fr").Expd_page_txt("Help:").Test();
}
@Test public void Colon_multiple() {
fxt.Init_ttl("fr::Help:Test").Expd_xwik_txt("fr").Expd_page_txt(":Help:Test").Test();
fxt.Init_ttl("fr::Test").Expd_xwik_txt("fr").Expd_page_txt(":Test").Test();
fxt.Init_ttl(":fr:Test").Expd_xwik_txt("fr").Expd_page_txt("Test").Expd_force_literal_link(1).Test();
fxt.Init_ttl(":::fr:Test").Expd_xwik_txt("").Expd_page_txt(":fr:Test").Expd_force_literal_link(1).Test();
}
@Test public void Ns_should_precede_xwiki() {// PURPOSE: the "Wikipedia" in "Wikipedia:Main page" should be interpreted as namespace, not an alias
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("Wikipedia"), Bry_.new_a7("en.wikipedia.org"));
fxt.Init_ttl("Wikipedia:Test").Expd_xwik_txt("").Expd_full_txt("Wikipedia:Test").Test();
}
}

View File

@@ -0,0 +1,86 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
class Xow_ttl_fxt {
private Xop_fxt fxt = new Xop_fxt();
public Xow_ttl_fxt Init_ttl(String raw) {test_raw = raw; return this;} private String test_raw = "";
public Xow_ttl_fxt Expd_ns_id(int v) {expd_ns_id = v; return this;} private int expd_ns_id = Int_.MinValue;
public Xow_ttl_fxt Expd_page_txt(String v) {expd_page_txt = v; return this;} private String expd_page_txt;
public Xow_ttl_fxt Expd_page_url(String v) {expd_page_url = v; return this;} private String expd_page_url;
public Xow_ttl_fxt Expd_full_txt(String v) {expd_full_txt = v; return this;} private String expd_full_txt;
public Xow_ttl_fxt Expd_full_url(String v) {expd_full_url = v; return this;} private String expd_full_url;
public Xow_ttl_fxt Expd_leaf_txt(String v) {expd_leaf_txt = v; return this;} private String expd_leaf_txt;
public Xow_ttl_fxt Expd_leaf_url(String v) {expd_leaf_url = v; return this;} private String expd_leaf_url;
public Xow_ttl_fxt Expd_base_txt(String v) {expd_base_txt = v; return this;} private String expd_base_txt;
public Xow_ttl_fxt Expd_base_url(String v) {expd_base_url = v; return this;} private String expd_base_url;
public Xow_ttl_fxt Expd_root_txt(String v) {expd_root_txt = v; return this;} private String expd_root_txt;
public Xow_ttl_fxt Expd_rest_txt(String v) {expd_rest_txt = v; return this;} private String expd_rest_txt;
public Xow_ttl_fxt Expd_talk_txt(String v) {expd_talk_txt = v; return this;} private String expd_talk_txt;
public Xow_ttl_fxt Expd_talk_url(String v) {expd_talk_url = v; return this;} private String expd_talk_url;
public Xow_ttl_fxt Expd_subj_txt(String v) {expd_subj_txt = v; return this;} private String expd_subj_txt;
public Xow_ttl_fxt Expd_subj_url(String v) {expd_subj_url = v; return this;} private String expd_subj_url;
public Xow_ttl_fxt Expd_qarg_txt(String v) {expd_qarg_txt = v; return this;} private String expd_qarg_txt;
public Xow_ttl_fxt Expd_xwik_txt(String v) {expd_xwik_txt = v; return this;} private String expd_xwik_txt;
public Xow_ttl_fxt Expd_anch_txt(String v) {expd_anch_txt = v; return this;} private String expd_anch_txt;
public Xow_ttl_fxt Expd_base_txt_wo_qarg(String v) {expd_base_txt_wo_qarg = v; return this;} private String expd_base_txt_wo_qarg;
public Xow_ttl_fxt Expd_leaf_txt_wo_qarg(String v) {expd_leaf_txt_wo_qarg = v; return this;} private String expd_leaf_txt_wo_qarg;
public Xow_ttl_fxt Expd_force_literal_link(int v) {expd_force_literal_link = v; return this;} private int expd_force_literal_link = -1;
public Xow_ttl_fxt Expd_err(Gfo_msg_itm v) {expd_err = v; return this;} private Gfo_msg_itm expd_err;
public Xowe_wiki Wiki() {return fxt.Wiki();}
public void Reset() {
fxt.Reset();
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_u8("fr"), Bry_.new_u8("fr.wikipedia.org"));
test_raw = "Test page";
expd_ns_id = Int_.MinValue;
expd_xwik_txt = expd_full_txt = expd_full_url = expd_page_txt = expd_page_url = expd_leaf_txt = expd_leaf_url = expd_base_txt = expd_base_url
= expd_root_txt = expd_rest_txt = expd_talk_txt = expd_talk_url = expd_subj_txt = expd_subj_url = expd_anch_txt
= expd_base_txt_wo_qarg = expd_leaf_txt_wo_qarg = expd_qarg_txt = null;
expd_err = null;
expd_force_literal_link = -1;
fxt.Log_clear();
}
public void Test() {
Xoa_ttl actl = Xoa_ttl.parse_(fxt.Wiki(), Bry_.new_u8(test_raw));
if (expd_err == null) {
if (expd_ns_id != Int_.MinValue) Tfds.Eq(expd_ns_id, actl.Ns().Id(), "ns");
if (expd_xwik_txt != null) Tfds.Eq(expd_xwik_txt, String_.new_u8(actl.Wik_txt()), "Wiki");
if (expd_page_txt != null) Tfds.Eq(expd_page_txt, String_.new_u8(actl.Page_txt()), "Page_txt");
if (expd_page_url != null) Tfds.Eq(expd_page_url, String_.new_u8(actl.Page_url()), "Page_url");
if (expd_full_txt != null) Tfds.Eq(expd_full_txt, String_.new_u8(actl.Full_txt()), "Full_txt");
if (expd_full_url != null) Tfds.Eq(expd_full_url, String_.new_u8(actl.Full_url()), "Full_url");
if (expd_leaf_txt != null) Tfds.Eq(expd_leaf_txt, String_.new_u8(actl.Leaf_txt()), "Leaf_txt");
if (expd_leaf_url != null) Tfds.Eq(expd_leaf_url, String_.new_u8(actl.Leaf_url()), "Leaf_url");
if (expd_base_txt != null) Tfds.Eq(expd_base_txt, String_.new_u8(actl.Base_txt()), "Base_txt");
if (expd_base_url != null) Tfds.Eq(expd_base_url, String_.new_u8(actl.Base_url()), "Base_url");
if (expd_root_txt != null) Tfds.Eq(expd_root_txt, String_.new_u8(actl.Root_txt()), "Root_txt");
if (expd_rest_txt != null) Tfds.Eq(expd_rest_txt, String_.new_u8(actl.Rest_txt()), "Rest_txt");
if (expd_talk_txt != null) Tfds.Eq(expd_talk_txt, String_.new_u8(actl.Talk_txt()), "Talk_txt");
if (expd_talk_url != null) Tfds.Eq(expd_talk_url, String_.new_u8(actl.Talk_url()), "Talk_url");
if (expd_subj_txt != null) Tfds.Eq(expd_subj_txt, String_.new_u8(actl.Subj_txt()), "Subj_txt");
if (expd_subj_url != null) Tfds.Eq(expd_subj_url, String_.new_u8(actl.Subj_url()), "Subj_url");
if (expd_anch_txt != null) Tfds.Eq(expd_anch_txt, String_.new_u8(actl.Anch_txt()), "Anch_txt");
if (expd_qarg_txt != null) Tfds.Eq(expd_qarg_txt, String_.new_u8(actl.Qarg_txt()), "Qarg_txt");
if (expd_base_txt_wo_qarg != null) Tfds.Eq(expd_base_txt_wo_qarg, String_.new_u8(actl.Base_txt_wo_qarg()), "Expd_base_txt_wo_qarg");
if (expd_leaf_txt_wo_qarg != null) Tfds.Eq(expd_leaf_txt_wo_qarg, String_.new_u8(actl.Leaf_txt_wo_qarg()), "Expd_leaf_txt_wo_qarg");
if (expd_force_literal_link != -1) Tfds.Eq(expd_force_literal_link == 1, actl.ForceLiteralLink(), "ForceLiteralLink");
}
else {
Tfds.Eq_ary(String_.Ary(String_.new_u8(expd_err.Owner().Path()) + "." + String_.new_u8(expd_err.Key_bry())), fxt.Log_xtoAry());
}
}
}

View File

@@ -0,0 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
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.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
public interface Xow_ttl_parser {
Xoa_ttl Ttl_parse(byte[] ttl);
Xoa_ttl Ttl_parse(int ns_id, byte[] ttl);
Xow_ns_mgr Ns_mgr();
}