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:
45
400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_mgr_tst.java
Normal file
45
400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_mgr_tst.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.portal.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xoh_page_wtr_mgr_tst {
|
||||
@Before public void init() {}
|
||||
@Test public void Logo_has_correct_main_page() { // PURPOSE: Logo href should be "/site/en.wikipedia.org/wiki/", not "/wiki/Main_Page"
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Xow_portal_mgr portal_mgr = wiki.Html_mgr().Portal_mgr();
|
||||
Gfo_invk_.Invk_by_val(portal_mgr, Xow_portal_mgr.Invk_div_logo_, Bry_.new_a7("~{portal_nav_main_href}"));
|
||||
portal_mgr.Init_assert();
|
||||
Xoh_page_wtr_mgr page_wtr_mgr = new Xoh_page_wtr_mgr(true);
|
||||
page_wtr_mgr.Gen(wiki.Parser_mgr().Ctx().Page(), Xopg_page_.Tid_read);
|
||||
Tfds.Eq(String_.new_a7(portal_mgr.Div_logo_bry(true)), "/site/en.wikipedia.org/wiki/");
|
||||
}
|
||||
@Test public void Skip__math__basic() {
|
||||
Xop_fxt fxt = Xop_fxt.New_app_html();
|
||||
fxt.Init_lang_vnts("zh-hans", "zh-hant");
|
||||
|
||||
fxt.Test__parse_to_html_mgr(String_.Concat_lines_nl_skip_last
|
||||
( "<math>x_{1}-1</math>"
|
||||
, "<math>x-{1+2}-1</math>"
|
||||
, "-{zh-hans:A;zh-hant:B;}-"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<span id='xowa_math_txt_0'>x_{1}-1</span>" // not converted
|
||||
, "<span id='xowa_math_txt_0'>x-{1+2}-1</span>" // not converted
|
||||
, "A" // converted
|
||||
));
|
||||
}
|
||||
}
|
||||
74
400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_wkr_tst.java
Normal file
74
400_xowa/src/gplx/xowa/htmls/Xoh_page_wtr_wkr_tst.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_page_wtr_wkr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_page_wtr_fxt fxt = new Xoh_page_wtr_fxt();
|
||||
@Test public void Page_name() {
|
||||
fxt.Test_page_name_by_ttl("Earth", "Earth");
|
||||
fxt.Test_page_name_by_ttl("File:A.png", "File:A.png");
|
||||
fxt.Test_page_name_by_ttl("Special:Search/earth?fulltext=y", "Special:Search/earth");
|
||||
fxt.Test_page_name_by_ttl("Special:Search/earth", "Special:Search/earth");
|
||||
fxt.Test_page_name_by_display("Special:Allpages", "All pages", "All pages");
|
||||
}
|
||||
@Test public void Edit() {
|
||||
fxt.Test_edit("	", "&#9;\n"); // NOTE: cannot by 	 or will show up in edit box as "\t" and save as "\t" instead of 	
|
||||
}
|
||||
@Test public void Css() {
|
||||
fxt.App().Html_mgr().Page_mgr().Content_code_fmt().Fmt_("<pre style='overflow:auto'>~{page_text}</pre>");
|
||||
fxt.Test_read("MediaWiki:Common.css", ".xowa {}", "<pre style='overflow:auto'>.xowa {}</pre>");
|
||||
fxt.App().Html_mgr().Page_mgr().Content_code_fmt().Fmt_("<pre>~{page_text}</pre>");
|
||||
}
|
||||
@Test public void Amp_disable() { // PURPOSE: in js documents; " should be rendered as ", not as "; DATE:2013-11-07
|
||||
fxt.Test_read("MediaWiki:Gadget.js", """, "<pre>&quot;</pre>");
|
||||
}
|
||||
}
|
||||
class Xoh_page_wtr_fxt {
|
||||
public void Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
} private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); private Xowe_wiki wiki;
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
public void Test_page_name_by_display(String ttl, String display, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)), Bry_.new_a7(display))));
|
||||
}
|
||||
public void Test_page_name_by_ttl(String raw, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.Parse(wiki, Bry_.new_a7(raw)), null)));
|
||||
}
|
||||
public void Test_edit(String raw, String expd) {
|
||||
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true);
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
||||
Xoh_page_wtr_mgr mgr = wiki.Html_mgr().Page_wtr_mgr();
|
||||
Xoh_page_wtr_wkr wkr = mgr.Wkr(Xopg_page_.Tid_edit);
|
||||
wkr.Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Basic, page);
|
||||
Tfds.Eq(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test_read(String page_name, String page_text, String expd) {
|
||||
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true);
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
page.Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7(page_name)));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(page_text));
|
||||
Xoh_page_wtr_mgr mgr = wiki.Html_mgr().Page_wtr_mgr();
|
||||
Xoh_page_wtr_wkr wkr = mgr.Wkr(Xopg_page_.Tid_read);
|
||||
wkr.Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Basic, page);
|
||||
Tfds.Eq(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Bridge_msg_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Bridge_msg_bldr_fxt fxt = new Bridge_msg_bldr_fxt();
|
||||
@Test public void Bld() {
|
||||
fxt.Bldr().Rslt_pass_y_().Notify_pass_("passed").Data("key1", true).Data("key2", 1).Data("key3", "val3");
|
||||
fxt.Test_to_json_str("{'rslt':{'pass':true},'notify':{'text':'passed','status':'success'},'data':{'key1':true,'key2':1,'key3':'val3'}}");
|
||||
}
|
||||
}
|
||||
class Bridge_msg_bldr_fxt {
|
||||
public Bridge_msg_bldr Bldr() {return bldr;} private final Bridge_msg_bldr bldr = new Bridge_msg_bldr().Opt_quote_byte_apos_();
|
||||
public void Clear() {}
|
||||
public void Test_to_json_str(String expd) {
|
||||
Tfds.Eq_str_lines(expd, bldr.To_json_str());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import org.junit.*;
|
||||
public class Dbui_tbl_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Dbui_tbl_fmtr_fxt fxt = new Dbui_tbl_fmtr_fxt();
|
||||
@Test public void Basic() {
|
||||
// fxt.Test_write
|
||||
// ( fxt.Make_tbl()
|
||||
// , String_.Concat_lines_nl_skip_last()
|
||||
// );
|
||||
}
|
||||
}
|
||||
class Dbui_tbl_fmtr_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New_w_size(255);
|
||||
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
|
||||
public void Clear() {}
|
||||
public Dbui_tbl_itm Make_tbl() {
|
||||
return null;
|
||||
}
|
||||
public void Test_write(Dbui_tbl_itm tbl, String expd) {
|
||||
tbl_fmtr.Write(bfr, tbl, null, null, null);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
348
400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java
Normal file
348
400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java
Normal file
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
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.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_html_wtr_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@After public void term() {fxt.Init_para_n_(); fxt.Reset();}
|
||||
@Test public void Hr_basic() {fxt.Test_parse_page_wiki_str("----" , "<hr/>");}
|
||||
@Test public void Hr_extended() {fxt.Test_parse_page_wiki_str("--------" , "<hr/>");}
|
||||
@Test public void Lnki_basic() {fxt.Test_parse_page_wiki_str("[[a]]" , "<a href=\"/wiki/A\">a</a>");}
|
||||
@Test public void Lnki_caption() {fxt.Test_parse_page_wiki_str("[[a|b]]" , "<a href=\"/wiki/A\">b</a>");}
|
||||
@Test public void Lnki_caption_fmt() {fxt.Test_parse_page_wiki_str("[[a|''b'']]" , "<a href=\"/wiki/A\"><i>b</i></a>");}
|
||||
@Test public void Lnki_tail_trg() {fxt.Test_parse_page_wiki_str("[[a]]b" , "<a href=\"/wiki/A\">ab</a>");}
|
||||
@Test public void Lnki_tail_caption() {fxt.Test_parse_page_wiki_str("[[a|b]]c" , "<a href=\"/wiki/A\">bc</a>");}
|
||||
@Test public void Lnki_title() {
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_wiki_str("[[a|b]]", "<a href=\"/wiki/A\" title=\"A\">b</a>");
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Lnki_title_page_text() {
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_wiki_str("[[a_b]]", "<a href=\"/wiki/A_b\" title=\"A b\">a_b</a>");
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Lnki_category() {fxt.Test_parse_page_wiki_str("[[Category:A]]" , "");} // NOTE: Category does not get written in main page bfr
|
||||
@Test public void Lnki_category_force() {fxt.Test_parse_page_wiki_str("[[:Category:A]]" , "<a href=\"/wiki/Category:A\">Category:A</a>");}
|
||||
@Test public void Lnki_matches_page() {fxt.Test_parse_page_wiki_str("[[test page|t1]]", "<b>t1</b>");} // NOTE: "Test page" is hardcoded to be the test page name
|
||||
@Test public void Lnki_matches_page_but_has_anchor() {fxt.Test_parse_page_wiki_str("[[Test page#a|test 1]]", "<a href=\"/wiki/Test_page#a\">test 1</a>");} // NOTE: "Test page" is hardcoded to be the test page name
|
||||
@Test public void Lnki_anchor() {fxt.Test_parse_page_wiki_str("[[A#b]]" , "<a href=\"/wiki/A#b\">A#b</a>");}
|
||||
// @Test public void Img_invalid_wnt_char() {
|
||||
// fxt.Test_parse_page_wiki_str
|
||||
// ( "[[File:A*b.png]]"
|
||||
// , "<div class=\"floatnone\"><a href=\"File:A.png\" class=\"image\"><img alt=\"\" src=\"\" width=\"20\" height=\"30\" /></a></div>"
|
||||
// );
|
||||
// }
|
||||
// @Test public void Img_alt() { // FUTURE: enable; WHEN: after fixing xnde to handle bad xnde; EX: France
|
||||
// fxt.Test_parse_page_wiki_str("[[File:A.png|none|9x8px|alt=a<b>b</b>\"c\"d]]", Xop_fxt.html_img_none("File:A.png", "ab"c"d"));
|
||||
// }
|
||||
@Test public void Url_encode() {fxt.Test_parse_page_wiki_str("[[a;@$!*(),/ _^b|z]]" , "<a href=\"/wiki/A;@$!*(),/_%5Eb\">z</a>");} // NOTE: was "a" instead of "A"; "__" instead of "_" DATE:2014-09-07
|
||||
@Test public void Url_encode_space() {fxt.Test_parse_page_wiki_str("[[a _b|z]]" , "<a href=\"/wiki/A_b\">z</a>");}
|
||||
@Test public void Apos_i() {fxt.Test_parse_page_wiki_str("''a''" , "<i>a</i>");}
|
||||
@Test public void Apos_b() {fxt.Test_parse_page_wiki_str("'''a'''" , "<b>a</b>");}
|
||||
@Test public void Apos_ib() {fxt.Test_parse_page_wiki_str("'''''a'''''" , "<i><b>a</b></i>");}
|
||||
@Test public void Html_ent() {fxt.Test_parse_page_wiki_str("!" , "!");} // PURPOSE:ncrs should be literal, not decoded (!); DATE:2014-11-06
|
||||
@Test public void Html_ref() {fxt.Test_parse_page_wiki_str(">" , ">");}
|
||||
@Test public void List_1_itm() {
|
||||
fxt.Test_parse_page_wiki_str("*a", String_.Concat_lines_nl_skip_last
|
||||
( "<ul>"
|
||||
, " <li>a"
|
||||
, " </li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void List_2_itms() {
|
||||
fxt.Test_parse_page_wiki_str("*a\n*b", String_.Concat_lines_nl_skip_last
|
||||
( "<ul>"
|
||||
, " <li>a"
|
||||
, " </li>"
|
||||
, " <li>b"
|
||||
, " </li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void List_nest_ul() {
|
||||
fxt.Test_parse_page_wiki_str("*a\n**b", String_.Concat_lines_nl_skip_last
|
||||
( "<ul>"
|
||||
, " <li>a"
|
||||
, " <ul>"
|
||||
, " <li>b"
|
||||
, " </li>"
|
||||
, " </ul>"
|
||||
, " </li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void List_dt_dd() {
|
||||
fxt.Test_parse_page_wiki_str(";a:b", String_.Concat_lines_nl_skip_last
|
||||
( "<dl>"
|
||||
, " <dt>a"
|
||||
, " </dt>"
|
||||
, " <dd>b"
|
||||
, " </dd>"
|
||||
, "</dl>"
|
||||
));
|
||||
}
|
||||
@Test public void List_dd_nest2() {
|
||||
fxt.Test_parse_page_wiki_str("::a", String_.Concat_lines_nl_skip_last
|
||||
( "<dl>"
|
||||
, " <dd>"
|
||||
, " <dl>"
|
||||
, " <dd>a"
|
||||
, " </dd>"
|
||||
, " </dl>"
|
||||
, " </dd>"
|
||||
, "</dl>"
|
||||
));
|
||||
}
|
||||
@Test public void Tblw_basic() {
|
||||
fxt.Test_parse_page_wiki_str("{|\n|+a\n!b||c\n|-\n|d||e\n|}", String_.Concat_lines_nl
|
||||
( "<table>"
|
||||
, " <caption>a"
|
||||
, " </caption>"
|
||||
, " <tr>"
|
||||
, " <th>b"
|
||||
, " </th>"
|
||||
, " <th>c"
|
||||
, " </th>"
|
||||
, " </tr>"
|
||||
, " <tr>"
|
||||
, " <td>d"
|
||||
, " </td>"
|
||||
, " <td>e"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
));
|
||||
}
|
||||
@Test public void Tblw_atrs() {
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|style='z'"
|
||||
, "|+a"
|
||||
, "!style='y'|b||style='x'|c"
|
||||
, "|-style='w'"
|
||||
, "|style='v'|d||style='u'|e"
|
||||
, "|}"
|
||||
), String_.Concat_lines_nl
|
||||
( "<table style='z'>"
|
||||
, " <caption>a"
|
||||
, " </caption>"
|
||||
, " <tr>"
|
||||
, " <th style='y'>b"
|
||||
, " </th>"
|
||||
, " <th style='x'>c"
|
||||
, " </th>"
|
||||
, " </tr>"
|
||||
, " <tr style='w'>"
|
||||
, " <td style='v'>d"
|
||||
, " </td>"
|
||||
, " <td style='u'>e"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
));
|
||||
}
|
||||
@Test public void Para_hdr_list() {
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "==a=="
|
||||
, ""
|
||||
, "*b"
|
||||
, "*c"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2>a</h2>"
|
||||
, ""
|
||||
, "<ul>"
|
||||
, " <li>b"
|
||||
, " </li>"
|
||||
, " <li>c"
|
||||
, " </li>"
|
||||
, "</ul>"
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Para_nl_is_space() {
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "b"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "b"
|
||||
, "</p>"
|
||||
, ""
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Para_nl_2_2() {
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, ""
|
||||
, "b"
|
||||
, ""
|
||||
, "c"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<p>b"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<p>c"
|
||||
, "</p>"
|
||||
, ""
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Div_2() { // WP:[[Air]]#Density of air
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
|
||||
( "<div>a</div>"
|
||||
, ""
|
||||
, "<div>b</div>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div>a</div>"
|
||||
, "<div>b</div>"
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Tblw() {
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|a"
|
||||
, "|b"
|
||||
, "|-"
|
||||
, "|c"
|
||||
, "|d"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " </td>"
|
||||
, " <td>b"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " <tr>"
|
||||
, " <td>c"
|
||||
, " </td>"
|
||||
, " <td>d"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Tblw_lnki_bang() {
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "|[[a|!]]"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td><a href=\"/wiki/A\">!</a>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Tr_inside_tblw_td() { // WP:[[Earth]]
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "<tr><td>a</td></tr>"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Tblw_tr_with_newlines() {// WP:[[John Adams]] Infobox Officeholder
|
||||
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl
|
||||
( "{|"
|
||||
, "|-"
|
||||
, ""
|
||||
, ""
|
||||
, ""
|
||||
, "|a"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td>a"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Bang_doesnt_force_tbl() {
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_wiki_str("a! b! c", "<p>a! b! c\n</p>\n");
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Err_nlOnly() {
|
||||
fxt.Test_parse_page_wiki_str("{{\n}}", "{{\n}}"); // NOTE: was {{}}
|
||||
}
|
||||
@Test public void Xnde_inline() {
|
||||
fxt.Test_parse_page_wiki_str("<div/>", "<div></div>");
|
||||
}
|
||||
@Test public void Xnde_id_encode() { // PURPOSE: id should be url-encoded; DATE: 2013-11-13;
|
||||
fxt.Test_parse_page_wiki_str("<div id='a*'></div>", "<div id='a.2A'></div>");
|
||||
fxt.Test_parse_page_wiki_str("<div id='a b'></div>", "<div id='a_b'></div>");
|
||||
}
|
||||
@Test public void Timeline() {// PURPOSE: embed timeline contents in pre; DATE:2014-05-22
|
||||
fxt.Test_parse_page_wiki_str("<timeline>a</timeline>", "<pre class='xowa-timeline'>a</pre>");
|
||||
}
|
||||
@Test public void Amp_ncr_should_not_be_rendered_as_bytes() { // PURPOSE:   should be rendered as   not as literal bytes {192,160}; DATE:2013-12-09
|
||||
fxt.Test_parse_page_wiki_str("a b", "a b");
|
||||
}
|
||||
|
||||
// @Test public void Fix_PositionAbsolute_stripped() {
|
||||
// fxt.Test_parse_page_wiki_str("<span style=\"position:absolute;\"></span>", "<span style=\";\"></span>");
|
||||
// }
|
||||
// @Test public void Xnde_nl() {
|
||||
// fxt.Test_parse_page_wiki_str("<div id='a'\nclass='b'>c</div>", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div id='a' class='b'>c</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Tblw() {
|
||||
// fxt.Test_parse_page_wiki_str("{|\n|}", String_.Concat_lines_nl
|
||||
// ( "<table>"
|
||||
// , " <tr>"
|
||||
// , " <td>a"
|
||||
// , " </td>"
|
||||
// , " <td>b"
|
||||
// , " </td>"
|
||||
// , " </tr>"
|
||||
// , "</table>"
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
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.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_tidy_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_tidy_mgr_fxt fxt = new Xoh_tidy_mgr_fxt();
|
||||
@Test public void Wrap() {
|
||||
fxt.Test_wrap("<b>a</b>"
|
||||
, "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
|
||||
+ "<html>"
|
||||
+ "<head>"
|
||||
+ "<title>test</title>"
|
||||
+ "</head>"
|
||||
+ "<body><b>a</b>"
|
||||
+ "</body>"
|
||||
+ "</html>"
|
||||
);
|
||||
}
|
||||
@Test public void Unwrap_pass() {
|
||||
fxt.Test_unwrap
|
||||
( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
|
||||
+ "<html>"
|
||||
+ "<head>"
|
||||
+ "<title>test</title>"
|
||||
+ "</head>"
|
||||
+ "<body><b>a</b>"
|
||||
+ "</body>"
|
||||
+ "</html>"
|
||||
, Bool_.Y, "<b>a</b>"
|
||||
);
|
||||
}
|
||||
@Test public void Unwrap_fail_bgn() {
|
||||
fxt.Test_unwrap
|
||||
( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
|
||||
+ "<html>"
|
||||
+ "<head>"
|
||||
+ "<title>test</title>"
|
||||
+ "</head>"
|
||||
+ "<bodyx><b>a</b>"
|
||||
+ "</body>"
|
||||
+ "</html>"
|
||||
, Bool_.N, ""
|
||||
);
|
||||
}
|
||||
@Test public void Unwrap_fail_end() {
|
||||
fxt.Test_unwrap
|
||||
( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
|
||||
+ "<html>"
|
||||
+ "<head>"
|
||||
+ "<title>test</title>"
|
||||
+ "</head>"
|
||||
+ "<body><b>a</b>"
|
||||
+ "</bodyx>"
|
||||
+ "</html>"
|
||||
, Bool_.N, ""
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xoh_tidy_mgr_fxt {
|
||||
private Bry_bfr bfr = Bry_bfr_.Reset(255);
|
||||
public void Clear() {
|
||||
bfr.Clear();
|
||||
}
|
||||
public void Test_wrap(String val, String expd) {
|
||||
bfr.Add_str_u8(val);
|
||||
Xow_tidy_mgr.Tidy_wrap(bfr);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test_unwrap(String val, boolean expd_pass, String expd) {
|
||||
bfr.Add_str_u8(val);
|
||||
boolean actl_pass = Xow_tidy_mgr.Tidy_unwrap(bfr);
|
||||
if (actl_pass != expd_pass) Tfds.Fail("expd={0} actl={1}", expd_pass, actl_pass);
|
||||
else if (expd_pass) {
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.core.envs.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import org.w3c.tidy.Tidy;
|
||||
import org.junit.*;
|
||||
public class Xoh_tidy_wkr_jtidy_tst {
|
||||
@Before public void init() {fxt.Clear();} private Jtidy_fxt fxt = new Jtidy_fxt();
|
||||
@Test public void Image_full() {
|
||||
String nl = Op_sys.Cur().Tid_is_wnt() ? "\r\n" : "\n"; // NOTE: JTidy uses different line-endings based on OS; DATE:2015-05-11
|
||||
fxt.Test_tidy("<a href='http://𐎍𐎁_𐎜'>𐎍𐎁_𐎜</a>", "<a href='http://%F0%90%8E%8D%F0%90%8E%81_%F0%90%8E%9C'>𐎍𐎁_𐎜</a>" + nl);
|
||||
}
|
||||
}
|
||||
class Jtidy_fxt {
|
||||
public void Clear() {
|
||||
}
|
||||
public void Test_tidy(String raw, String expd) {
|
||||
Tidy tidy = new Tidy();
|
||||
tidy.setPrintBodyOnly(true);
|
||||
tidy.setWraplen(0);
|
||||
tidy.setQuiet(true);
|
||||
tidy.setShowWarnings(false);
|
||||
tidy.setShowErrors(0);
|
||||
ByteArrayInputStream rdr = null;
|
||||
try {
|
||||
rdr = new ByteArrayInputStream(raw.getBytes("UTF-8"));
|
||||
} catch (Exception e) {}
|
||||
ByteArrayOutputStream wtr = new ByteArrayOutputStream();
|
||||
tidy.parse(rdr, wtr);
|
||||
String actl = wtr.toString();
|
||||
Test_mgr.Eq_str(expd, actl);
|
||||
}
|
||||
}
|
||||
class Test_mgr {
|
||||
public static void Eq_str(String expd, String actl) {
|
||||
// byte[] expd_bry = Bry_.new_u8(expd);
|
||||
// byte[] actl_bry = Bry_.new_u8(actl);
|
||||
// int expd_len = expd_bry.length;
|
||||
// int actl_len = actl_bry.length;
|
||||
// if (expd_len != actl_len) throw new RuntimeException(String.format("expd != actl; expd:%s actl:%s", Int_.To_str(expd_len), Int_.To_str(actl_len)));
|
||||
// for (int i = 0; i < expd_len; ++i) {
|
||||
// byte expd_byte = expd_bry[i];
|
||||
// byte actl_byte = actl_bry[i];
|
||||
// if (expd_byte != actl_byte) throw new RuntimeException(String.format("expd != actl; %s expd:%s actl:%s", Int_.To_str(i), Byte_.To_str(expd_byte), Byte_.To_str(actl_byte)));
|
||||
// }
|
||||
if (!expd.equals(actl)) throw new RuntimeException(String.format("expd != actl; expd:%s actl:%s", expd, actl));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
public class Gfo_decimal_parser_tst {
|
||||
private final Gfo_decimal_parser_fxt fxt = new Gfo_decimal_parser_fxt();
|
||||
@Test public void Positive() {
|
||||
fxt.Test__parse("123" , Bool_.Y, 0, 123);
|
||||
fxt.Test__parse("12.3" , Bool_.Y, -1, 123);
|
||||
fxt.Test__parse("1.23" , Bool_.Y, -2, 123);
|
||||
fxt.Test__parse(".123" , Bool_.Y, -3, 123);
|
||||
fxt.Test__parse("0.123" , Bool_.Y, -3, 123);
|
||||
}
|
||||
@Test public void Negative() {
|
||||
fxt.Test__parse("-123" , Bool_.N, 0, 123);
|
||||
fxt.Test__parse("-12.3" , Bool_.N, -1, 123);
|
||||
fxt.Test__parse("-1.23" , Bool_.N, -2, 123);
|
||||
fxt.Test__parse("-.123" , Bool_.N, -3, 123);
|
||||
fxt.Test__parse("-0.123" , Bool_.N, -3, 123);
|
||||
}
|
||||
}
|
||||
class Gfo_decimal_parser_fxt {
|
||||
private final Gfo_decimal_parser bicoder = new Gfo_decimal_parser();
|
||||
public void Test__parse(String src_str, boolean expd_sign, int expd_exponent, long expd_number) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
bicoder.Parse(src_bry, 0, src_bry.length);
|
||||
Tfds.Eq_bool(expd_sign, bicoder.Sign());
|
||||
Tfds.Eq_int(expd_exponent, bicoder.Exponent());
|
||||
Tfds.Eq_long(expd_number, bicoder.Number());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*; import gplx.core.encoders.*;
|
||||
public class Xoh_hzip_int__tst {
|
||||
private final Xoh_hzip_int__fxt fxt = new Xoh_hzip_int__fxt();
|
||||
@Test public void Reqd__1() {
|
||||
fxt.Test__encode(1, 0, "!");
|
||||
fxt.Test__encode(1, 84, "u");
|
||||
fxt.Test__encode(1, 85, "{\"!");
|
||||
fxt.Test__encode(1, 7225, "|\"!!");
|
||||
fxt.Test__encode(1, 614125, "}\"!!!");
|
||||
fxt.Test__encode(1, 52200625, "~\"!!!!");
|
||||
}
|
||||
@Test public void Reqd__2() {
|
||||
fxt.Test__encode(2, 0, "!!");
|
||||
fxt.Test__encode(2, 84, "!u");
|
||||
fxt.Test__encode(2, 85, "\"!");
|
||||
fxt.Test__encode(2, 7225, "|\"!!");
|
||||
fxt.Test__encode(2, 614125, "}\"!!!");
|
||||
fxt.Test__encode(2, 52200625, "~\"!!!!");
|
||||
}
|
||||
}
|
||||
class Xoh_hzip_int__fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private final gplx.core.primitives.Int_obj_ref count_ref = gplx.core.primitives.Int_obj_ref.New_neg1();
|
||||
public void Test__encode(int reqd, int val, String expd) {
|
||||
Gfo_hzip_int_.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
Tfds.Eq(val, Gfo_hzip_int_.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
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.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_hzip_int_tst {
|
||||
private final Xoh_hzip_int_fxt fxt = new Xoh_hzip_int_fxt();
|
||||
@Test public void B256__reqd__1() {
|
||||
fxt.Init__b256();
|
||||
fxt.Test__b256(1, 0 , 0);
|
||||
fxt.Test__b256(1, 252 , 252, 252);
|
||||
fxt.Test__b256(1, 253 , 252, 253);
|
||||
fxt.Test__b256(1, 254 , 252, 254);
|
||||
fxt.Test__b256(1, 255 , 252, 255);
|
||||
fxt.Test__b256(1, 256 , 253, 1, 0);
|
||||
fxt.Test__b256(1, 65535 , 253, 255, 255);
|
||||
fxt.Test__b256(1, 65536 , 254, 1, 0, 0);
|
||||
fxt.Test__b256(1, 16777216 , 255, 1, 0, 0, 0);
|
||||
}
|
||||
@Test public void B256__reqd__2() {
|
||||
fxt.Init__b256();
|
||||
fxt.Test__b256(2, 0 , 0, 0);
|
||||
fxt.Test__b256(2, 252 , 0, 252);
|
||||
fxt.Test__b256(2, 253 , 0, 253);
|
||||
fxt.Test__b256(2, 254 , 0, 254);
|
||||
fxt.Test__b256(2, 255 , 0, 255);
|
||||
fxt.Test__b256(2, 256 , 1, 0);
|
||||
fxt.Test__b256(2, 64511 , 251, 255);
|
||||
fxt.Test__b256(2, 64512 , 253, 252, 0);
|
||||
fxt.Test__b256(2, 65535 , 253, 255, 255);
|
||||
fxt.Test__b256(2, 65536 , 254, 1, 0, 0);
|
||||
fxt.Test__b256(2, 16777216 , 255, 1, 0, 0, 0);
|
||||
}
|
||||
@Test public void B085__reqd__1() {
|
||||
fxt.Init__b085();
|
||||
fxt.Test__b085(1, 0, "!");
|
||||
fxt.Test__b085(1, 84, "u");
|
||||
fxt.Test__b085(1, 85, "{\"!");
|
||||
fxt.Test__b085(1, 7225, "|\"!!");
|
||||
fxt.Test__b085(1, 614125, "}\"!!!");
|
||||
fxt.Test__b085(1, 52200625, "~\"!!!!");
|
||||
}
|
||||
@Test public void B085__reqd__2() {
|
||||
fxt.Init__b085();
|
||||
fxt.Test__b085(2, 0, "!!");
|
||||
fxt.Test__b085(2, 84, "!u");
|
||||
fxt.Test__b085(2, 85, "\"!");
|
||||
fxt.Test__b085(2, 7225, "|\"!!");
|
||||
fxt.Test__b085(2, 614125, "}\"!!!");
|
||||
fxt.Test__b085(2, 52200625, "~\"!!!!");
|
||||
}
|
||||
}
|
||||
class Xoh_hzip_int_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private final gplx.core.primitives.Int_obj_ref count_ref = gplx.core.primitives.Int_obj_ref.New_neg1();
|
||||
private final Xoh_hzip_int hzint = new Xoh_hzip_int();
|
||||
public void Init__b256() {hzint.Mode_is_b256_(Bool_.Y);}
|
||||
public void Init__b085() {hzint.Mode_is_b256_(Bool_.N);}
|
||||
public void Test__b256(int reqd, int val, int... expd_ints) {
|
||||
hzint.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
byte[] expd = Byte_.Ary_by_ints(expd_ints);
|
||||
Tfds.Eq_ary(expd, actl, Int_.To_str(val));
|
||||
Tfds.Eq(val, hzint.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
public void Test__b085(int reqd, int val, String expd) {
|
||||
hzint.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
Tfds.Eq(val, hzint.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.htmls.core.makes.tests; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.xowa.htmls.sections.*;
|
||||
public class Xoh_make_fxt {
|
||||
public Xoh_make_fxt() {
|
||||
Xoa_app_fxt.repo2_(parser_fxt.App(), parser_fxt.Wiki()); // needed else will be old "mem/wiki/repo/trg/thumb/" instead of standard "mem/file/en.wikipedia.org/thumb/"
|
||||
parser_fxt.Wiki().Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
parser_fxt.Wiki().Html_mgr().Html_wtr().Cfg().Lnki__id_(Bool_.Y).Lnki__title_(Bool_.Y);
|
||||
}
|
||||
public void Clear() {
|
||||
parser_fxt.Reset();
|
||||
page_chkr.Clear();
|
||||
}
|
||||
public Xoh_page_chkr Page_chkr() {return page_chkr;} private final Xoh_page_chkr page_chkr = new Xoh_page_chkr();
|
||||
public Xop_fxt Parser_fxt() {return parser_fxt;} private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
public void Init_img_cache
|
||||
( String wiki_abrv, String lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page
|
||||
, boolean repo_is_commons, String html_ttl, int html_w, int html_h, double html_time, int html_page
|
||||
) {
|
||||
// fxt.Init_cache("en.wikipedia.org", "A.png", 0, 220, 110, 0.5, -1, -1, Bool_.Y, "B.png", 330, 110, -1, -1);
|
||||
}
|
||||
public void Test__html(String wtxt, String expd) {Test__html(wtxt, expd, true);}
|
||||
public void Test__html(String wtxt, String expd, boolean escape_apos) {
|
||||
if (escape_apos) expd = String_.Replace(expd, "'", "\"");
|
||||
String actl = parser_fxt.Exec__parse_to_hdump(wtxt);
|
||||
Tfds.Eq_str_lines(expd, actl);
|
||||
}
|
||||
public void Test__make(String html, Xoh_page_chkr chkr) {
|
||||
html = String_.Replace(html, "'", "\"");
|
||||
Xoh_page actl = new Xoh_page();
|
||||
actl.Ctor_by_hview(parser_fxt.Wiki(), Xoa_url.blank(), parser_fxt.Wiki().Ttl_parse(Xoa_page_.Main_page_bry), 1);
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Test_console();
|
||||
Xoh_make_mgr make_mgr = parser_fxt.Wiki().Html__hdump_mgr().Load_mgr().Make_mgr();
|
||||
byte[] actl_body = make_mgr.Parse(Bry_.new_u8(html), actl, parser_fxt.Wiki());
|
||||
actl.Db().Html().Html_bry_(actl_body);
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Noop;
|
||||
chkr.Check(actl);
|
||||
}
|
||||
}
|
||||
115
400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hzip_fxt.java
Normal file
115
400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hzip_fxt.java
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
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.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.caches.*;
|
||||
public class Xoh_hzip_fxt {
|
||||
private final Xowe_wiki wiki;
|
||||
private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
private final Xoh_hzip_bfr bfr = Xoh_hzip_bfr.New_txt(32);
|
||||
private final Xoh_hzip_mgr hzip_mgr;
|
||||
private final Xoh_page hpg = new Xoh_page();
|
||||
private boolean mode_is_b256;
|
||||
public Xoh_hzip_fxt() {
|
||||
this.wiki = parser_fxt.Wiki();
|
||||
Xoa_app_fxt.repo2_(parser_fxt.App(), wiki); // needed else will be old "mem/wiki/repo/trg/thumb/" instead of standard "mem/file/en.wikipedia.org/thumb/"
|
||||
wiki.Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
this.hzip_mgr = parser_fxt.Wiki().Html__hdump_mgr().Hzip_mgr();
|
||||
hpg.Ctor_by_hview(wiki, Xoa_url.blank(), parser_fxt.Wiki().Ttl_parse(Xoa_page_.Main_page_bry), 1);
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
public Xoa_page Page() {return hpg;}
|
||||
public Xoh_hzip_fxt Init_mode_is_b256_(boolean v) {bfr.Mode_is_b256_(v); mode_is_b256 = v; return this;}
|
||||
public Xoh_hzip_fxt Init_mode_diff_y_() {hzip_mgr.Hctx().Mode_is_diff_(Bool_.Y); return this;}
|
||||
public void Clear() {hpg.Clear();}
|
||||
public void Init_wiki_installed(String domain) {parser_fxt.Init_xwiki_add_user_(domain);}
|
||||
public Xou_cache_finder_mem Init_file_mgr__mem() {
|
||||
Xou_cache_finder_mem rv = Xou_cache_finder_.New_mem();
|
||||
hzip_mgr.Hctx().Test__cache__mgr_(rv);
|
||||
return rv;
|
||||
}
|
||||
public void Init_file_mgr__noop() {
|
||||
hzip_mgr.Hctx().Test__cache__mgr_(Xou_cache_finder_.Noop);
|
||||
}
|
||||
public Xowe_wiki Init_wiki_alias(String alias, String domain) {
|
||||
Xowe_wiki rv = Xoa_app_fxt.Make__wiki__edit(parser_fxt.App(), domain);
|
||||
parser_fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_u8(alias), Bry_.new_u8(domain), null);
|
||||
return rv;
|
||||
}
|
||||
public void Init__ns_alias__add(String alias, int ns_id) {
|
||||
parser_fxt.Wiki().Ns_mgr().Aliases_add(ns_id, alias).Init();
|
||||
}
|
||||
public void Init__ns_alias__del(String alias) {
|
||||
parser_fxt.Wiki().Ns_mgr().Aliases_del(alias);
|
||||
}
|
||||
public void Test__bicode(String hzip, String html) {Test__bicode(hzip, html, html);}
|
||||
public void Test__bicode(String hzip, String html_enc, String html_dec) {
|
||||
html_enc = Gfh_utl.Replace_apos(html_enc);
|
||||
html_dec = Gfh_utl.Replace_apos(html_dec);
|
||||
Test__bicode_raw(hzip, html_enc, html_dec);
|
||||
}
|
||||
public void Test__bicode_raw(String hzip, String html_enc, String html_dec) {
|
||||
hzip = Xoh_hzip_fxt.Escape(hzip);
|
||||
Test__encode__raw(hzip, html_enc);
|
||||
Test__decode__raw(hzip, html_dec);
|
||||
}
|
||||
public void Test__encode(String hzip, String html) {
|
||||
hzip = Xoh_hzip_fxt.Escape(hzip); html = Gfh_utl.Replace_apos(html);
|
||||
Test__encode__raw(hzip, html);
|
||||
}
|
||||
public void Test__decode(String hzip, String html) {
|
||||
hzip = Xoh_hzip_fxt.Escape(hzip); html = Gfh_utl.Replace_apos(html);
|
||||
Test__decode__raw(hzip, html);
|
||||
}
|
||||
public void Test__encode__fail(String expd, String html) {
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(html));
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
private void Test__encode__raw(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(html));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Tfds.Eq_str_lines(hzip, bfr.To_str_and_clear());
|
||||
}
|
||||
public void Test__decode__raw(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hpg.Section_mgr().Clear();
|
||||
hzip_mgr.Decode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(hzip));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Tfds.Eq_str_lines(html, bfr.To_str_and_clear());
|
||||
}
|
||||
public void Exec_write_to_fsys(Io_url dir, String fil) {
|
||||
try {
|
||||
Xoh_hzip_bfr bfr = Xoh_hzip_bfr.New_txt(32).Mode_is_b256_(mode_is_b256);
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), hpg, Io_mgr.Instance.LoadFilBry(dir.GenSubFil(fil)));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Io_mgr.Instance.SaveFilBry(dir.GenSubFil(fil).GenNewExt(".hzip.html"), actl);
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_hzip.Md5_depth = 4;
|
||||
hzip_mgr.Hctx().Mode_is_diff_(Bool_.Y);
|
||||
hzip_mgr.Decode(bfr, parser_fxt.Wiki(), hpg, actl);
|
||||
hzip_mgr.Hctx().Mode_is_diff_(Bool_.N);
|
||||
gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_hzip.Md5_depth = 2;
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Io_mgr.Instance.SaveFilBry(dir.GenSubFil(fil).GenNewExt(".hzip.decode.html"), bfr.To_bry_and_clear());
|
||||
} catch (Exception e) {
|
||||
Tfds.Dbg(e);
|
||||
}
|
||||
}
|
||||
public static String Escape(String v) {return String_.Replace(v, "~", "");}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
public abstract class Xoh_itm_parser_fxt {
|
||||
protected final Xoae_app app;
|
||||
protected final Xowe_wiki wiki;
|
||||
private final Bry_err_wkr err_wkr = new Bry_err_wkr();
|
||||
protected byte[] src; protected int src_len;
|
||||
protected final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
|
||||
public Xoh_itm_parser_fxt() {
|
||||
this.app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
hctx.Init_by_app(app);
|
||||
}
|
||||
private Xoh_itm_parser Parser() {return Parser_get();}
|
||||
public abstract Xoh_itm_parser Parser_get();
|
||||
public void Test__parse__fail(String src_str, String expd) {
|
||||
Gfo_usr_dlg_.Test__list__init();
|
||||
Parser().Fail_throws_err_(Bool_.N);
|
||||
Exec_parse(src_str);
|
||||
Parser().Fail_throws_err_(Bool_.Y);
|
||||
Tfds.Eq_str(expd, Gfo_usr_dlg_.Test__list__term__get_1st());
|
||||
}
|
||||
public void Exec_parse(String src_str) {
|
||||
this.src = Bry_.new_u8(src_str); this.src_len = src.length;
|
||||
Xoh_page hpg = new Xoh_page(); // NOTE: no need to pass url and ttl now
|
||||
hctx.Init_by_page(wiki, hpg);
|
||||
err_wkr.Init_by_page(Xoa_page_.Main_page_str, src);
|
||||
Exec_parse_hook(err_wkr, hctx, 0, src_len);
|
||||
}
|
||||
public abstract void Exec_parse_hook(Bry_err_wkr err_wkr, Xoh_hdoc_ctx hctx, int src_bgn, int src_end);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.addons.gallerys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_gallery_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__decode
|
||||
( "<ul class=\"gallery mw-gallery-traditional style=\"max-width:489px; _width:489px;\">"
|
||||
, "<ul class=\"gallery mw-gallery-traditional style=\"max-width:489px; _width:489px;\">"
|
||||
);
|
||||
Gftest.Eq__bool_y(fxt.Page().Xtn__gallery_exists());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.wkrs.addons.medias {
|
||||
// import org.junit.*; using gplx.core.tests;
|
||||
// using gplx.langs.htmls; using gplx.xowa.htmls.core.makes.tests;
|
||||
// public class Xoh_media_hzip_tst {
|
||||
// private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
// @Test public void Video__full__ogv__width_y() { // EX: [[File:A.ogv|320px|bcd|alt=efg]]; DATE:2016-08-05
|
||||
// fxt.Test__bicode // NOTE: caption not rendered; may need to reconsider;
|
||||
// ( "*!!aA.ogv~)$bA.ogv~efg~", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class='xowa_media_div'>"
|
||||
// , "<div>"
|
||||
// + "<a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'>"
|
||||
// + "<img data-xowa-title='A.ogv' data-xoimg='0|320|-1|-1|-1|-1' src='' width='0' height='0' alt='efg'>"
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "<div>"
|
||||
// + "<a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:318px;max-width:320px;' alt='Play sound'>"
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Video__full__ogv__width_n() { // EX: [[File:A.ogv]]; DATE:2016-08-05
|
||||
// fxt.Test__bicode
|
||||
// ( "*!!aA.ogv~!A.ogv~efg~", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class='xowa_media_div'>"
|
||||
// , "<div>"
|
||||
// + "<a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'>"
|
||||
// + "<img data-xowa-title='A.ogv' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='efg'>"
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "<div>"
|
||||
// + "<a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'>" // NOTE: default to 220px if no w specified
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Audio__thumb() {
|
||||
// String html = Gfh_utl.Replace_apos(String_.Concat_lines_nl
|
||||
// ( "<div class='thumb tright'>"
|
||||
// , " <div class='thumbinner' style='width:11px;'>"
|
||||
// , " <div class='xowa_media_div'>"
|
||||
// , "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:318px;max-width:320px;' alt='Play sound'></a></div>"
|
||||
// , "<div><a href='/wiki/File:A.oga' class='xowa_media_info' title='About this file'></a></div>"
|
||||
// , "</div>"
|
||||
// , " <div class='thumbcaption'>"
|
||||
// , "<div class='magnify'><a href='/wiki/File:A.oga' class='internal' title='Enlarge'></a></div>b"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
//
|
||||
// String hzip = String_.Concat_lines_nl
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div class=\"thumbinner\" style=\"width:11px;\">"
|
||||
// , " ~*#$bA.oga"
|
||||
// , " <div class=\"thumbcaption\">"
|
||||
// , "<div class=\"magnify\">$|%%,)A.ogaEnlarge</div>b"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// );
|
||||
// fxt.Test__bicode(hzip, html);
|
||||
// }
|
||||
// @Test public void Audio__noicon() {
|
||||
// String html = Gfh_utl.Replace_apos(String_.Concat_lines_nl
|
||||
// ( " <div class='xowa_media_div'>"
|
||||
// , "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:318px;max-width:320px;' alt='Play sound'></a></div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
//
|
||||
// String hzip = String_.Concat_lines_nl
|
||||
// ( " ~*$$bA.oga"
|
||||
// );
|
||||
// fxt.Test__bicode(hzip, html);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.addons.timelines; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_timeline_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() { // EX: <timeline>code</timeline>
|
||||
fxt.Test__decode__raw("<pre class='xowa-timeline'>abc</pre>", "<pre class='xowa-timeline'>abc</pre>");
|
||||
Gftest.Eq__bool_y(fxt.Page().Xtn__timeline_exists());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.escapes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_escape_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Test public void Escape() {
|
||||
fxt.Test__bicode("!" , String_.new_a7(Bry_.New_by_byte(Xoh_pool_mgr__hzip.Hook__core)));
|
||||
}
|
||||
@Test public void Html() {
|
||||
fxt.Test__bicode("!" , String_.new_a7(Bry_.New_by_byte(Xoh_pool_mgr__hzip.Hook__html)));
|
||||
}
|
||||
@Test public void Mw() {
|
||||
fxt.Test__bicode("!", "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_gly_html__dump__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "<gallery>"
|
||||
, "File:A.png|A1"
|
||||
, "File:B.png|B1"
|
||||
, "</gallery>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, " <li class='gallerybox' style='width:155px;'>"
|
||||
, " <div style='width:155px;'>"
|
||||
, " <div class='thumb' style='width:150px;'>"
|
||||
, " <div style='margin:15px auto;'>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class='gallerytext'><p>A1"
|
||||
, "</p>"
|
||||
, ""
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </li>"
|
||||
, " <li class='gallerybox' style='width:155px;'>"
|
||||
, " <div style='width:155px;'>"
|
||||
, " <div class='thumb' style='width:150px;'>"
|
||||
, " <div style='margin:15px auto;'>"
|
||||
, " <a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title=\"B.png\" data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class='gallerytext'><p>B1"
|
||||
, "</p>"
|
||||
, ""
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Atrs() {
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "<gallery perrow='5' widths='200' heights='300'>"
|
||||
, "File:A.png|A1"
|
||||
, "</gallery>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='200|300|5' class='gallery mw-gallery-traditional' style='max-width:1215px; _width:1215px;'>"
|
||||
, " <li class='gallerybox' style='width:235px;'>"
|
||||
, " <div style='width:235px;'>"
|
||||
, " <div class='thumb' style='width:230px;'>"
|
||||
, " <div style='margin:15px auto;'>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|200|300|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class='gallerytext'><p>A1"
|
||||
, "</p>"
|
||||
, ""
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Packed() {
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "<gallery mode='packed'>"
|
||||
, "File:A.png|A1"
|
||||
, "</gallery>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-packed'>"
|
||||
, " <li class='gallerybox' style='width:1302px;'>"
|
||||
, " <div style='width:1302px;'>"
|
||||
, " <div class='thumb' style='width:1300px;'>"
|
||||
, " <div style='margin:0px auto;'>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|1950|180|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class='gallerytext'><p>A1"
|
||||
, "</p>"
|
||||
, ""
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
// case Gallery_xnde_atrs.Mode_tid: mode = Gallery_mgr_base_.Get_or_traditional(xatr.Val_as_bry()); break;
|
||||
// case Gallery_xnde_atrs.Perrow_tid: itms_per_row = xatr.Val_as_int_or(Null); break;
|
||||
// case Gallery_xnde_atrs.Widths_tid: itm_w = xatr.Val_as_int_or(Null); break;
|
||||
// case Gallery_xnde_atrs.Heights_tid: itm_h = xatr.Val_as_int_or(Null); break;
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gly_hzip__basic__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~9\"D\"D{\"g{\"b0!B1~!1B.png~9\"D\"Dabc", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title='B.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>B1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>abc"));
|
||||
}
|
||||
@Test public void Clear_state() { // page # wasn't being cleared between gallery itms; PAGE:en.w:Almagest; DATE:2016-01-05
|
||||
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~{\"d\"D\"D!#{\"g{\"b0!B1~!1B.png~{\"d\"D\"D!$abc", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|2' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title='B.png' data-xoimg='0|120|120|-1|-1|3' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>B1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>abc"));
|
||||
}
|
||||
@Test public void Extra_cls() { // PURPOSE: handle extra cls; EX: <gallery class='abc'>
|
||||
fxt.Test__bicode("~'1!cls1 cls2~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional cls1 cls2'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Caption() { // handle <li class='gallerycaption'>A</li>; PAGE:en.d:a; DATE:2016-06-24
|
||||
fxt.Test__bicode("~'{\"L!Z\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerycaption'>Z</li>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Extra_cls__gallery() { // handle redundant gallery; EX: <gallery class='gallery'>; PAGE:en.w:Butuan; DATE:2016-01-05
|
||||
fxt.Test__bicode("~'1!gallery~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional gallery'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Xtra_atr() { // PURPOSE: handle extra atr; EX: <gallery id='abc'>
|
||||
fxt.Test__bicode("~'A! id=\"abc\"\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' id='abc'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where <p> is put on one line ("<p>a</p>") unless it ends with <br> ("<p>a<br>\n</p>")
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b0!A1<br>"
|
||||
, "~!1A.png~9\"D\"D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1<br>" // TIDY: <br> forces </p> to be on next line
|
||||
, "</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Tidy__empty() { // PURPOSE: no items should place </ul> on same line
|
||||
fxt.Test__bicode("~'!!!", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'></ul>")); // TIDY: <ul></ul> should be on same line if 0 items
|
||||
}
|
||||
@Test public void Xnde_atrs() {
|
||||
fxt.Test__bicode("~'{6({,L!!#?!!$N&#{\"g{\"b0!A1~!1A.png~9\"D\"D{\"g{\"b0!B1~!1B.png~9\"D\"Dabc", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='200|300|5' class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title='B.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>B1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>abc"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gly_hzip__caption__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Capt_is_empty() { // PURPOSE: handle empty caption
|
||||
fxt.Test__bicode("~'!!#{\"g{\"b0#~!1A.png~9\"D\"D{\"g{\"b0#!1A.png9\"D\"D<p>abc</p>", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'></div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'></div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul><p>abc</p>"));
|
||||
}
|
||||
@Test public void Capt_is_br() { // PURPOSE: handle captions which have <br>, not <p>; PAGE:s.w:Sociology; DATE:2015-12-20
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b0\"<b><i>A1</i></b>"
|
||||
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'><br>"
|
||||
, "<b><i>A1</i></b>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Capt_has_multiple_p() { // PURPOSE: handle captions with multiple <p>; PAGE:en.w:Wikipedia:Bot_requests/Archive_25; DATE:2016-01-12
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b0!a<br>"
|
||||
, "b</p>"
|
||||
, "<p><br>"
|
||||
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>a<br>"
|
||||
, "b</p>"
|
||||
, "<p><br>"
|
||||
, "</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Capt_has_complicated_nl_behavior() {// handle complicated captions which force <div> on different line PAGE:en.w:Tamago_kake_gohan; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b>\"<div class=\"center\"><a href=\"/wiki/B.png\" class=\"image\" xowa_title=\"B.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|120|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"></a></div>"
|
||||
, "abc~\"\\A.png~#9\"D\"D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:29px auto;'><a href='/wiki/A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'><br>"
|
||||
, "<div class='center'><a href='/wiki/B.png' class='image' xowa_title='B.png'><img data-xowa-title='A.png' data-xoimg='0|120|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "abc</div>" // NOTE: tidy forces </div> to be on same line instead of next
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Capt_has_hr() {// handle <hr> which causes <p> to end early; PAGE:de.v:Kurs:Photoshop_Einzell<6C>sungen/HighKey_mit_CS5; DATE:2016-06-24
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b>%a</p>"
|
||||
, "<hr>"
|
||||
, "b"
|
||||
, "~\"\\A.png~#9\"D\"D")
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:29px auto;'><a href='/wiki/A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>a</p>" // NOTE: </p> placed before <hr>
|
||||
, "<hr>"
|
||||
, "b" // NOTE: no <p> for "b"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_gly_hzip__style__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Style__no_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
|
||||
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__no_width() { // PURPOSE: if "_width" omitted, do not add back; EX: style="max-width:648px; margin:auto; background:transparent;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
|
||||
fxt.Test__bicode("~'i{,L! color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='max-width:978px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__max_width_duped() { // PURPOSE: if max-width duped, do not delete 2nd; EX: style="max-width:648px; color:blue; max-width:648px;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
|
||||
fxt.Test__bicode("~'){(Z max-width:648px; color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='max-width:652px; _width:652px; max-width:648px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__invalid_unclosed() { // handle broken styles; EX: <gallery style='center'>
|
||||
fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional center' style='center'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:75px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__extra_colon() { // handle broken styles; EX: <gallery style='a:b:c:d;' PAGE:en.w:Bronze_Horseman DATE:2016-01-05
|
||||
fxt.Test__bicode("~'9!center~color:red:float:right;~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional center' style='color:red:float:right;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:75px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__ws() { // PURPOSE: handle ws in style; EX: <gallery class="gallery mw-gallery-traditional" style="max-width:1115px; _width:1115px; color:blue;'>; PAGE:en.w:Anti-Serb_sentiment; DATE:2016-01-08
|
||||
fxt.Test__bicode("~'){,L color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul data-xogly='-1|-1|-1' class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Xoh_gly_itm_wtr_tst {
|
||||
private final Xoh_gly_itm_wtr_fxt fxt = new Xoh_gly_itm_wtr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init__gly(Gallery_mgr_base_.Tid__traditional, -1, -1, -1, 0, 155, 150, 5, "caption");
|
||||
fxt.Init__img("/wiki/File:A.png", "A.png", "0|120|120|-1|-1|-1");
|
||||
fxt.Test__write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<li id='xogly_li_0' class='gallerybox' style='width:155px;'>"
|
||||
, "<div id='xowa_gallery_div1_0' style='width:155px;'>"
|
||||
, "<div id='xowa_gallery_div2_0' class='thumb' style='width:150px;'>"
|
||||
, "<div id='xowa_gallery_div3_0' style='margin:5px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img id='xoimg_0' data-xoimg='0|120|120|-1|-1|-1' width='0' height='0'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>caption</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_gly_itm_wtr_fxt {
|
||||
private final Xoh_gly_itm_wtr wtr = new Xoh_gly_itm_wtr();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public void Init__gly(byte mode, int xnde_w, int xnde_h, int xnde_per_row, int id, int itm_w, int div_1_w, int div_3_margin, String caption) {
|
||||
wtr.Init(Bool_.N, mode, xnde_w, xnde_h, xnde_per_row, id, 0, 0, itm_w, div_1_w, div_3_margin, Xoh_gly_itm_data.Capt_tid__p, Bry_.new_a7(caption));
|
||||
}
|
||||
public void Init__img(String href, String xowa_title, String xoimg) {
|
||||
wtr.Img_wtr().Init_by_gly(gplx.core.brys.args.Bfr_arg__bry.New(Bry_.new_u8(href)), Bry_.new_u8(xowa_title), gplx.core.brys.args.Bfr_arg__bry.New(Bry_.new_u8(xoimg)));
|
||||
}
|
||||
public void Test__write(String expd) {
|
||||
expd = gplx.langs.htmls.Gfh_utl.Replace_apos(expd);
|
||||
wtr.Bfr_arg__add(tmp_bfr);
|
||||
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_hdr_html_tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, "==A 1=="
|
||||
, "a 1"
|
||||
, "==B=="
|
||||
, "b"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, ""
|
||||
, "<h2><span class='mw-headline' id='A_1'>A 1</span></h2>"
|
||||
, "a 1"
|
||||
, ""
|
||||
, "<h2><span class='mw-headline' id='B'>B</span></h2>"
|
||||
, "b"
|
||||
));
|
||||
}
|
||||
@Test public void Uniq() {
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "== a <math>c</math> e =="
|
||||
, "text"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2><span class=\"mw-headline\" id=\"a_c_e\"> a <span id='xowa_math_txt_0'>c</span> e </span></h2>"
|
||||
, "text"
|
||||
)
|
||||
, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.addons.htmls.tocs.*;
|
||||
public class Xoh_hdr_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Before public void init() {Xoh_toc_mgr.Enabled = false;}
|
||||
@After public void term() {Xoh_toc_mgr.Enabled = true;}
|
||||
@Test public void Same() {
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~\"'A~"
|
||||
, "a"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h6><span class='mw-headline' id='A'>A</span></h6>"
|
||||
, "a"
|
||||
));
|
||||
}
|
||||
@Test public void Diff() {
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~\"+<i>A</i>~A~"
|
||||
, "a"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2><span class='mw-headline' id='A'><i>A</i></span></h2>"
|
||||
, "a"
|
||||
));
|
||||
}
|
||||
@Test public void Diff_by_underscore() {
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~\"#A 1~"
|
||||
, "a"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2><span class='mw-headline' id='A_1'>A 1</span></h2>"
|
||||
, "a"
|
||||
));
|
||||
}
|
||||
@Test public void Diff_by_lnki() {
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~\"+<a href=\"/wiki/Category:A\" title=\"Category:A\">Category:A</a>~Category:A~"
|
||||
, "a"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2><span class='mw-headline' id='Category:A'><a href='/wiki/Category:A' title='Category:A'>Category:A</a></span></h2>"
|
||||
, "a"
|
||||
));
|
||||
}
|
||||
@Test public void Same_w_underscore() {
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~\"#A_1~"
|
||||
, "a"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2><span class='mw-headline' id='A_1'>A_1</span></h2>"
|
||||
, "a"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__bad_end() {
|
||||
fxt.Test__bicode(
|
||||
"~\"?A~AB~B~"
|
||||
, "<h6><span class='mw-headline' id='AB'>A</span>B</h6>"
|
||||
);
|
||||
}
|
||||
@Test public void Tidy__no_span() { // PURPOSE.TIDY: tidy will duplicate hdr if content has center; will fail if span/div is nearby; EX: ==<center>A</center>==\n<span><div>; PAGE:en.s:On_the_Vital_Principle/Book_2/Prelude_to_Chapter_2 DATE:2016-01-21
|
||||
fxt.Test__encode(String_.Concat_lines_nl_skip_last
|
||||
( "\"+A"
|
||||
, "<center>"
|
||||
, "<h2>A</h2>"
|
||||
, "</center>"
|
||||
, "<span class=\"mw-headline\" id=\"A\"></span>"
|
||||
, "<div style=\"color:blue;\">"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<h2><span class='mw-headline' id='A'></span></h2>"
|
||||
, "<center>"
|
||||
, "<h2>A</h2>"
|
||||
, "</center>"
|
||||
, "<span class='mw-headline' id='A'></span>"
|
||||
, "<div style='color:blue;'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Manual__no_id() {// PURPOSE: ignore manual "<h2>" with no id; PAGE:fr.w:Portail:Nord-Am<41>rindiens/Image_s<5F>lectionn<6E>e; DATE:2016-07-01
|
||||
fxt.Test__bicode
|
||||
( "<h6><span class=\"mw-headline\">A</span></h6>"
|
||||
, "<h6><span class='mw-headline'>A</span></h6>"
|
||||
);
|
||||
}
|
||||
@Test public void Manual__h_has_atrs() {// PURPOSE: ignore manual "<h2>" with atrs; PAGE:fr.w:Wikip<69>dia:LiveRC/ToDo; DATE:2016-07-02
|
||||
fxt.Test__bicode
|
||||
( "<h6 style=\"color:red\"><span class=\"mw-headline\" id=\"A\">B</span></h6>"
|
||||
, "<h6 style=\"color:red\"><span class=\"mw-headline\" id=\"A\">B</span></h6>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_hdr_make_tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Basic() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, "<h2><span class='mw-headline' id='A_1'>A 1</span></h2>"
|
||||
, "a 1"
|
||||
, "<h2><span class='mw-headline' id='B'>B</span></h2>"
|
||||
, "b"
|
||||
);
|
||||
fxt.Test__make(html, fxt.Page_chkr().Body_(html) // make sure body is same
|
||||
.Sections__add(0, 2, "" , "" , "z")
|
||||
.Sections__add(1, 2, "A_1" , "A 1" , "a 1")
|
||||
.Sections__add(2, 2, "B" , "B" , "b")
|
||||
);
|
||||
}
|
||||
@Test public void Consecutive() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "abc"
|
||||
, "<h2><span class='mw-headline' id='A'>A</span></h2>"
|
||||
, "<h2><span class='mw-headline' id='B'>B</span></h2>"
|
||||
, "xyz"
|
||||
);
|
||||
fxt.Test__make(html, fxt.Page_chkr().Body_(html) // make sure body is same
|
||||
.Sections__add(0, 2, "" , "" , "abc")
|
||||
.Sections__add(1, 2, "A" , "A" , "")
|
||||
.Sections__add(2, 2, "B" , "B" , "xyz")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.core.envs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_img_bare_hzip__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
private int prv_os_tid = -1;
|
||||
@Before public void init() {
|
||||
fxt.Clear();
|
||||
prv_os_tid = Op_sys.Cur().Tid();
|
||||
Op_sys.Cur_(Op_sys.Drd.Tid()); // force drd mode; needed for img_bare
|
||||
}
|
||||
@After public void term() {
|
||||
Op_sys.Cur_(prv_os_tid); // revert back to previous mode; otherwise global Op_sys is set to Drd which will cause other tests to fail (notably tidy)
|
||||
}
|
||||
@Test public void Hiero() {
|
||||
fxt.Test__bicode
|
||||
( "~(!<img style=\"margin: 1px; height: 11px;\" src=\"~X1.png\" title=\"X1 [t]\" alt=\"t\">~"
|
||||
, "<img style='margin: 1px; height: 11px;' src='file:///android_asset/xowa/bin/any/xowa/xtns/Wikihiero/img/hiero_X1.png' title='X1 [t]' alt='t'>"
|
||||
);
|
||||
}
|
||||
@Test public void Imap_btn() {
|
||||
fxt.Test__bicode
|
||||
( "~(\"<img alt=\"About this image\" src=\"~desc-20.png\" style=\"border: none;\">~"
|
||||
, "<img alt=\"About this image\" src=\"file:///android_asset/xowa/bin/any/xowa/xtns/ImageMap/imgs/desc-20.png\" style=\"border: none;\">"
|
||||
);
|
||||
}
|
||||
@Test public void Imap_map() {
|
||||
fxt.Test__bicode
|
||||
( "~%}*BhtA.png~#$m#T\"A.png~"
|
||||
, "<img src=\"file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/330px.png\" width=\"330\" height=\"220\" class=\"thumbimage\" alt=\"\" usemap=\"#imagemap_1_1\">"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_img_html__dump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Test__html
|
||||
( "[[File:A.png|220x110px|upright=.5|abc]]"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'/></a>");
|
||||
}
|
||||
@Test public void Empty_link() {
|
||||
fxt.Test__html("[[File:A.png|220x110px|link=|abc]]", "<img data-xowa-title=\"A.png\" data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'/>");
|
||||
}
|
||||
@Test public void Lcase_img() {
|
||||
Make_ns_case_sensitive(fxt.Parser_fxt().Wiki(), gplx.xowa.wikis.nss.Xow_ns_.Tid__file);
|
||||
fxt.Test__html("[[File:a_b.png]]", "<a href=\"/wiki/File:a_b.png\" class=\"image\" xowa_title=\"a_b.png\"><img data-xowa-title=\"a_b.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>");
|
||||
}
|
||||
@Test public void Lcase_video() {
|
||||
Make_ns_case_sensitive(fxt.Parser_fxt().Wiki(), gplx.xowa.wikis.nss.Xow_ns_.Tid__file);
|
||||
fxt.Test__html("[[File:a b.ogv]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:a_b.ogv\" class=\"image\" title=\"A_b.ogv\" xowa_title=\"a_b.ogv\"><img data-xowa-title=\"a_b.ogv\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"\" xowa_title=\"a_b.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
)
|
||||
);
|
||||
}
|
||||
private static void Make_ns_case_sensitive(Xow_wiki wiki, int ns_id) {
|
||||
gplx.xowa.wikis.nss.Xow_ns_mgr ns_mgr = wiki.Ns_mgr();
|
||||
gplx.xowa.wikis.nss.Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id);
|
||||
ns.Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
ns_mgr.Init();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_img_hzip__dump__basic__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void Clear() {fxt.Clear();}
|
||||
@Test public void Basic() { // [[File:A.png|border|class=other|220px|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!!A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Anch() { // [[File:A.png#b|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%\"<A.png#file~A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A.png#file' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding_foreign() { // [[File:Aéb.png|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%\"<A%C3%A9b.png~Aéb.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A%C3%A9b.png' class='image' xowa_title='Aéb.png'><img data-xowa-title='Aéb.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding_question() { // [[File:A?.png|abc]]; PAGE:en.w:Voiceless_alveolar_affricate; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%!qA?.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A?.png' class='image' xowa_title='A?.png'><img data-xowa-title='A?.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding__link() { // [[File:Aéb.png|abc|link=Aéb]]
|
||||
fxt.Test__bicode
|
||||
( "~%#gA%C3%A9b~Aéb.png~#)#Sabc~"
|
||||
, "<a href='/wiki/A%C3%A9b' class='image' xowa_title='Aéb.png'><img data-xowa-title='Aéb.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding_percent() {
|
||||
fxt.Test__bicode
|
||||
( "~%!q%24%3F%3D%27.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:%24%3F%3D%27.png' class='image' xowa_title='%24%3F%3D%27.png'><img data-xowa-title='%24%3F%3D%27.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__apos() { // [[File:A'b.png|border|link=A'b_link|A'b_capt]]
|
||||
String html = "<a href=\"/wiki/A%27b_link\" class=\"image\" xowa_title=\"A'b.png\"><img data-xowa-title=\"A'b.png\" data-xoimg=\"0|220|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" class=\"thumbborder\" alt=\"A'b_capt\"></a>";
|
||||
fxt.Test__bicode_raw("~%#oA%27b_link~A'b.png~#)#SA'b_capt~", html, html);
|
||||
}
|
||||
@Test public void Href__image() { // [[Image:A.png|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%-%A.png~Image~)#Sabc~"
|
||||
, "<a href='/wiki/Image:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Ns__cs() { // [[image:a.png|abc]]; PAGE:en.d:freedom_of_speech DATE:2016-01-21
|
||||
fxt.Wiki().Ns_mgr().Ns_file().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
fxt.Test__bicode
|
||||
( "~%-%a.png~image~)#Sabc~"
|
||||
, "<a href='/wiki/image:a.png' class='image' title='abc' xowa_title='a.png'><img data-xowa-title='a.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
fxt.Wiki().Ns_mgr().Ns_file().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__1st);
|
||||
}
|
||||
@Test public void Ns__foreign() { // [[Fichier:a.png|abc]]; PAGE:fr.w: DATE:2016-01-21
|
||||
Xow_ns_mgr ns_mgr = fxt.Wiki().Ns_mgr();
|
||||
ns_mgr.Ns_file().Name_bry_(Bry_.new_u8("Fichier")); ns_mgr.Init_w_defaults();
|
||||
fxt.Test__bicode
|
||||
( "~%!!a.png~)#Sabc~"
|
||||
, "<a href='/wiki/Fichier:a.png' class='image' title='abc' xowa_title='a.png'><img data-xowa-title='a.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
ns_mgr.Ns_file().Name_bry_(Bry_.new_u8("File")); ns_mgr.Init_w_defaults();
|
||||
}
|
||||
@Test public void Missing() { // PURPOSE: bad dump shouldn't write corrupt data
|
||||
fxt.Test__bicode
|
||||
( "%|\"\\QA.png!!!!A"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='A' xowa_title='A.png'><img data-xowa-title='A.png' alt='A'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Manual_img_cls() { // PURPOSE: handle manual class; EX: [[File:A.png|class=noviewer]] en.w:ASCII; DATE:2015-12-21
|
||||
fxt.Test__bicode
|
||||
( "~%95A.png~)#Sabc~cls1~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='cls1' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Imap() {
|
||||
fxt.Test__bicode
|
||||
( "~%}#P`uA.png~#:#S#+\""
|
||||
, "<img data-xowa-title='A.png' data-xoimg='1|220|180|-1|-1|-1' src='' width='0' height='0' alt='' usemap='#imagemap_1_1'>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_img_hzip__dump__link__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void Clear() {fxt.Clear();}
|
||||
@Test public void Link__cs() { // [[File:A.png|link=File:a.ogg|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Aa.ogg~A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:a.ogg' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__anchor() { // [[File:A.png|link=A#B_C|abc]]; PAGE:en.w:Arabic; DATE:2016-01-06
|
||||
fxt.Test__bicode
|
||||
( "~%#'A#B_C~D.png~#9!I!I"
|
||||
, "<a href='/wiki/A#B_C' class='image' xowa_title='D.png'><img data-xowa-title='D.png' data-xoimg='0|40|40|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n() { // [[File:A.png|link=http://a.org|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Dhttp://a.org~A.png~)#Sabc~"
|
||||
, "<a href='http://a.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n__encoded() { // PURPOSE: do not double-encode A%C3%A9b.org; [[File:A.png|link=http://Aéb.org|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Dhttp://A%C3%A9b.org~A.png~)#Sabc~"
|
||||
, "<a href='http://A%C3%A9b.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__y() { // [[File:A.png|link=http://en.wikitionary.org/wiki/Special:Search/A|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%\"men.wiktionary.org|Search/A~A.png~\")#Sabc~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Special:Search/A' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n_2() { // [[File:A.png|link=creativecommons:by/2.5]]
|
||||
fxt.Test__bicode
|
||||
( "~%#(creativecommons.org|by/2.5/~CC-BY-icon-80x15.png~#)!q"
|
||||
, "<a href='/site/creativecommons.org/wiki/by/2.5/' class='image' xowa_title='CC-BY-icon-80x15.png'><img data-xowa-title='CC-BY-icon-80x15.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__media() { // [[File:A.png|link=file:///C:/A.ogg]]
|
||||
fxt.Test__bicode
|
||||
( "~%!D~A.ogg~)!,B~"
|
||||
, "<a href='' class='image' title='B' xowa_title='A.ogg'><img data-xowa-title='A.ogg' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__encoding() { // [[File:A.svg|24px|text-top|link=wikt:𬖾|𬖾]]; PAGE:en.w:Pho; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%#Xen.wiktionary.org|%F0%AC%96%BE~A.png~#)!,abc~B~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/%F0%AC%96%BE' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__invalid() { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%\"mcommons.wikimedia.org|~A.png~1!Abc~"
|
||||
, "<a href='/site/commons.wikimedia.org/wiki/Category:' class='image' title='Abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='Abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fxt.Test__bicode
|
||||
( "~%|iVPA.png~#9#S\":abc~"
|
||||
, "<img data-xowa-title='A.png' data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty__tidy() {// <a><font><img> should not trigger empty link code; PAGE:en.w:Wikipedia:Reference_Desk_archive_unanswered_2005 ; DATE:2016-01-13
|
||||
fxt.Test__bicode
|
||||
( "<a href=\"/wiki/Image:A.png\" class=\"image\" title=\"\" xowa_title=\"A.png\"><font style=\"color:red\">~%|iVPA.png~#!abc~</font></a>"
|
||||
, "<a href='/wiki/Image:A.png' class='image' title='' xowa_title='A.png'><font style='color:red'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></font></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__ns_alias() { // [[File:A.png|link=WP:MCB]]; PAGE:en.w:Wikipedia:WikiProject_Molecular_and_Cell_Biology; DATE:2016-01-11
|
||||
fxt.Init__ns_alias__add("WP", Xow_ns_.Tid__project);
|
||||
fxt.Test__bicode
|
||||
( "~%/+MCB~A.png~'WP~)!q"
|
||||
, "<a href='/wiki/WP:MCB' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
fxt.Init__ns_alias__del("WP");
|
||||
}
|
||||
@Test public void Link__xwiki_lc() { // [[File:A.png|link=wikt:Category:en:A]]; PAGE:en.w:Portal:Trucks/Wikimedia; DATE:2016-01-11
|
||||
fxt.Test__bicode
|
||||
( "~%#(en.wiktionary.org|en:A~A.png~1)!q"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Category:en:A' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__xwiki_under() {// EX: [[File:A.png|link=User talk:B]]; PAGE:de.b:Wikibooks:Benutzersperrung/_InselFahrer DATE:2016-06-24
|
||||
fxt.Test__bicode
|
||||
( "~%/,meta.wikimedia.org|B~A.png~&User Talk~!", String_.Concat
|
||||
( "<a href='/site/meta.wikimedia.org/wiki/User_Talk:B' class='image' xowa_title='A.png'>"
|
||||
, "<img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''>"
|
||||
, "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link__xwiki_foreign() { // PURPOSE:ns in linked wikis should use canonical name, not current wiki's name PAGE:pl.w:Terytoria_Północno-Zachodnie DATE:2016-10-28
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(gplx.xowa.wikis.nss.Xow_ns_.Tid__help).Name_bry_(Bry_.new_a7("Aide")); // simulate non-English wiki with non-english names
|
||||
fxt.Test__bicode // fails if "Aide:" instead of "Help:"
|
||||
( "~%.qen.wiktionary.org|~A.png~/Help~)#Sabc~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Help:' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(gplx.xowa.wikis.nss.Xow_ns_.Tid__help).Name_bry_(Bry_.new_a7("Help")); // revert
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_img_hzip__dump__orig__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void Clear() {fxt.Clear();}
|
||||
@Test public void Basic() { // [[File:A.png|border|class=other|220px|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%|\"\\QA.png~$m#Tabc~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A.png/330px.png' width='330' height='220' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Orig() { // PURPOSE: orig with width was causing "!!" in alt; EX:[[File:A.png|abc]]; DATE:2016-08-09
|
||||
fxt.Test__bicode
|
||||
( "~%|#gqA.png~!b!Babc~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img src='file:///mem/xowa/file/commons.wikimedia.org/orig/7/0/A.png' width='64' height='32' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Gallery() {
|
||||
fxt.Test__bicode
|
||||
( "~%|3]3A.png~!b!B\"Mabc~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/128px.png' width='64' height='32' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Encode() { // [[File:A+C.png|abc]]
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__mp__y_();
|
||||
fxt.Test__bicode
|
||||
( "~%|\"\\qA%2BC.png~A+C.png~$m#Tabc~"
|
||||
, "<a href='/wiki/File:A%2BC.png' class='image' title='abc' xowa_title='A+C.png'><img src='file:///mem/xowa/file/en.wikipedia.org/thumb/2/7/A%2BC.png/330px.png' width='330' height='220' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link() { // [[File:A.png|link=File:a.ogg|abc]]; [[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/9/7/4/e/En-us-Alabama.ogg|Listen]]
|
||||
fxt.Test__bicode
|
||||
( "~%}'h(qA.ogg~\"M!babc~A.png~"
|
||||
, "<a href='/wiki/File:A.ogg' class='image' title='abc' xowa_title='A.ogg'><img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/128px.png' width='128' height='64' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty() { // [[File:A.png|link=|abc]]; PAGE:en.w:Lackawanna_Cut-Off; DATE:2016-08-19
|
||||
fxt.Test__bicode
|
||||
( "~%}([^KA.png~#\"M!babc~A.png~"
|
||||
, "<img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/128px.png' width='128' height='64' alt='abc'>"
|
||||
);
|
||||
}
|
||||
@Test public void Encode_2() { // [[File:A*C.png|abc]]; PAGE:en.w:Fibonacci_number; DATE:2016-08-10
|
||||
// Tfds.Write(gplx.xowa.files.Xof_file_wkr_.Md5(Bry_.new_a7("A*C.png")));
|
||||
fxt.Test__bicode
|
||||
( "~%|\"\\QA*C.png~$m#Tabc~"
|
||||
, "<a href='/wiki/File:A*C.png' class='image' title='abc' xowa_title='A*C.png'><img src='file:///mem/xowa/file/en.wikipedia.org/thumb/d/d/A*C.png/330px.png' width='330' height='220' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Video() { // handle thumbnail
|
||||
fxt.Test__bicode
|
||||
( "~%|=nTA.ogv~$m#T#T4.5~abc~"
|
||||
, "<a href='/wiki/File:A.ogv' class='image' title='abc' xowa_title='A.ogv'><img src='file:///mem/xowa/file/en.wikipedia.org/thumb/d/0/A.ogv/220px-4.5.jpg' width='330' height='220' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_img_hzip__dump__pgbnr__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void Clear() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Test__bicode
|
||||
( "~%}$DP@A.png~\"A~~wpb-banner-image ~00"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"A\" xowa_title=\"A.png\"><img data-xowa-title='A.png' data-xoimg='1|-1|-1|-1|-1|-1' src='' width='0' height='0' class='wpb-banner-image ' alt='' srcset='' data-pos-x='0' data-pos-y='0' style='max-width:-1px'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Data_pos_x() { // PAGE:en.v:Antartica; DATE:2016-07-12
|
||||
fxt.Test__bicode
|
||||
( "~%}$DP@A.png~\"A~~wpb-banner-image ~1.20"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"A\" xowa_title=\"A.png\"><img data-xowa-title='A.png' data-xoimg='1|-1|-1|-1|-1|-1' src='' width='0' height='0' class='wpb-banner-image ' alt='' srcset='' data-pos-x='1.2' data-pos-y='0' style='max-width:-1px'></a>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_img_hzip__view__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Before public void Clear() {fxt.Clear();}
|
||||
@Test public void Basic__border__class__caption() { // [[File:A.png|border|class=other|220px|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%iAA.png#T\";abc~other~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img id='xoimg_0' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' class='thumbborder other' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link() { // [[File:A.png|link=B]]
|
||||
fxt.Test__bicode
|
||||
( "~%}'h+RB~A.png##T\";B~A.png~A.png~"
|
||||
, "<a href='/wiki/B' class='image' title='B' xowa_title='A.png'><img id='xoimg_0' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' alt='A.png'></a>"
|
||||
);
|
||||
}
|
||||
// link_site: [[File:A.png|link=//en.wiktionary.org/B]] -> [[File:Wiktionary-logo-en.svg|25x25px|link=//en.wiktionary.org/wiki/Special:Search/Earth|Search Wiktionary]] -> <a href="/site/en.wiktionary.org/wiki/Special:Search/Earth" rel="nofollow" title="Search Wiktionary" xowa_title="Wiktionary-logo-en.svg"><img id="xoimg_88" alt="Search Wiktionary" src="file:///J:/xowa/file/commons.wikimedia.org/thumb/f/8/c/4/Wiktionary-logo-en.svg/23px.png" width="23" height="25"></a>
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_img_make__dump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Before public void Init() {fxt.Clear();}
|
||||
@Test public void Html_exists__n() {
|
||||
String
|
||||
orig = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' alt='abc'></a>"
|
||||
, expd = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img id='xoimg_0' data-xowa-title='A.png' data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
;
|
||||
fxt.Test__make(orig, fxt.Page_chkr().Body_(expd)
|
||||
.Imgs__add("en.w", "A.png", Xop_lnki_type.Id_null, 0.5, 220, 110, -1, -1)
|
||||
);
|
||||
}
|
||||
@Test public void Utf8() {
|
||||
String
|
||||
orig = "<a href='/wiki/File:A%C3%A9_b.png' class='image' title='abc' xowa_title='Aé_b.png'><img data-xowa-title='Aé_b.png' data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A%C3%A9_b.png/220px.png' width='220' height='110' alt='abc'></a>"
|
||||
, expd = "<a href='/wiki/File:A%C3%A9_b.png' class='image' title='abc' xowa_title='Aé_b.png'><img id='xoimg_0' data-xowa-title='Aé_b.png' data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
;
|
||||
fxt.Test__make(orig, fxt.Page_chkr().Body_(expd)
|
||||
.Imgs__add("en.w", "A.png", Xop_lnki_type.Id_null, 0.5, 220, 110, -1, -1)
|
||||
);
|
||||
}
|
||||
// @Test public void Html_exists__y__cache() {
|
||||
// String
|
||||
// orig = "<a href='/wiki/File:A.png' class='image' title='abc'><img alt='abc' data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A.png/220px.png' width='220' height='110'/></a>"
|
||||
// , expd = "<a href='/wiki/File:A.png' class='image' title='abc'><img id='xoimg_0' alt='abc' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/B.png/330px.png' width='330' height='110'/></a>"
|
||||
// ;
|
||||
// fxt.Init_img_cache("en.w", "A.png", 0, 0.5, 220, 110, -1, -1, Bool_.Y, "B.png", 330, 110, -1, -1);
|
||||
// fxt.Test__make(orig
|
||||
// , fxt.Page_chkr().Body_(expd)
|
||||
// .Imgs__add("en.w", "A.png", 0, 0.5, 220, 110, -1, -1)
|
||||
// );
|
||||
// }
|
||||
// @Test public void Html_exists__y__html() {
|
||||
// String
|
||||
// orig = "<a href='/wiki/File:A.png' class='image' title='abc'><img alt='abc' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A.png/220px.png' width='330' height='110'/></a>"
|
||||
// , expd = "<a href='/wiki/File:A.png' class='image' title='abc'><img id='xoimg_0' alt='abc' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/B.png/330px.png' width='330' height='110'/></a>"
|
||||
// ;
|
||||
// fxt.Test__make(orig
|
||||
// , fxt.Page_chkr().Body_(expd)
|
||||
// .Imgs__add("en.w", "A.png", 0, 0.5, 220, 110, -1, -1)
|
||||
// );
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs.atrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_img_cls__tst {
|
||||
private Xoh_img_cls__fxt fxt = new Xoh_img_cls__fxt();
|
||||
@Test public void To_html() {
|
||||
fxt.Test__to_html(Xoh_img_cls_.Tid__none , null , "");
|
||||
fxt.Test__to_html(Xoh_img_cls_.Tid__none , "a" , " class=\"a\"");
|
||||
fxt.Test__to_html(Xoh_img_cls_.Tid__thumbimage , null , " class=\"thumbimage\"");
|
||||
fxt.Test__to_html(Xoh_img_cls_.Tid__thumbborder , null , " class=\"thumbborder\"");
|
||||
fxt.Test__to_html(Xoh_img_cls_.Tid__thumbborder , "a" , " class=\"thumbborder a\"");
|
||||
}
|
||||
}
|
||||
class Xoh_img_cls__fxt {
|
||||
public void Test__to_html(byte tid, String other, String expd) {
|
||||
Tfds.Eq(expd, String_.new_u8(Xoh_img_cls_.To_html(tid, Bry_.new_u8_safe(other))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.imgs.atrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
import org.junit.*; import gplx.core.brys.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoh_img_src_data_tst {
|
||||
private final Xoh_img_src_data_fxt fxt = new Xoh_img_src_data_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Test__parse("file:///C:/xowa/file/en.wikipedia.org/orig/7/0/A.png" , "en.wikipedia.org" , Bool_.Y, "A.png", -1, -1, -1);
|
||||
fxt.Test__parse("file:///C:/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png" , "commons.wikimedia.org" , Bool_.N, "A.png", 220, -1, -1);
|
||||
}
|
||||
@Test public void Video() {
|
||||
fxt.Test__parse("file:///C:/xowa/file/commons.wikimedia.org/thumb/7/0/A.ogv/220px-5.jpg" , "commons.wikimedia.org" , Bool_.N, "A.ogv", 220, 5, -1);
|
||||
}
|
||||
@Test public void Pdf() {
|
||||
fxt.Test__parse("file:///C:/xowa/file/commons.wikimedia.org/thumb/7/0/A.pdf/220px-5.png" , "commons.wikimedia.org" , Bool_.N, "A.pdf", 220, -1, 5);
|
||||
}
|
||||
@Test public void Md5_depth_4() {
|
||||
fxt.Test__parse("file:///C:/xowa/file/en.wikipedia.org/orig/7/0/1/0/A.png" , "en.wikipedia.org" , Bool_.Y, "A.png", -1, -1, -1);
|
||||
}
|
||||
@Test public void Math() { // PURPOSE: "xowa:/math" shouldn't cause img_src_parser to fail; DATE:2016-11-17
|
||||
fxt.Test__parse("xowa:/math/596f8baf206a81478afd4194b44138715dc1a05c" , "en.wikipedia.org" , Bool_.Y, "A.png", -1, -1, -1);
|
||||
}
|
||||
// @Test public void Fail__orig_mode() {
|
||||
// fxt.Test__parse__fail("file:///C:/xowa/file/commons.wikimedia.org/fail/7/0/A.png", "failed trie check: mid='fail/7/0/A.png' ctx='Main_Page' wkr='img.src.xowa' excerpt='file:///C:/xowa/file/commons.wikimedia.org/fail/7/0/A.png'");
|
||||
// }
|
||||
// @Test public void Fail__repo_mode() {
|
||||
// fxt.Test__parse__fail("file:///C:/xowa/file/en.wiktionary.org/orig/7/0/A.png", "repo must be commons or self: repo='en.wiktionary.org' ctx='Main_Page' wkr='img.src.xowa' excerpt='file:///C:/xowa/file/en.wiktionary.org/orig/7/0/A.png'");
|
||||
// }
|
||||
}
|
||||
class Xoh_img_src_data_fxt extends Xoh_itm_parser_fxt { private final Xoh_img_src_data parser = new Xoh_img_src_data();
|
||||
public void Clear() {
|
||||
Xoa_app_fxt.repo2_(app, wiki);
|
||||
hctx.Init_by_page(wiki, new Xoh_page());
|
||||
}
|
||||
@Override public Xoh_itm_parser Parser_get() {return parser;}
|
||||
public void Test__parse(String src_str, String expd_repo, boolean expd_file_is_orig, String expd_file, int expd_w, int expd_time, int expd_page) {
|
||||
Exec_parse(src_str);
|
||||
if (parser.Repo_end() != -1) // need for Math()
|
||||
Tfds.Eq_str(expd_repo, String_.new_u8(src, parser.Repo_bgn(), parser.Repo_end()));
|
||||
if (parser.File_ttl_end() != -1) // need for Math()
|
||||
Tfds.Eq_str(expd_file, String_.new_u8(src, parser.File_ttl_bgn(), parser.File_ttl_end()));
|
||||
Tfds.Eq_bool(expd_file_is_orig, parser.File_is_orig());
|
||||
Tfds.Eq_int(expd_w, parser.File_w());
|
||||
Tfds.Eq_double(expd_time, parser.File_time());
|
||||
Tfds.Eq_int(expd_page, parser.File_page());
|
||||
}
|
||||
@Override public void Exec_parse_hook(Bry_err_wkr err_wkr, Xoh_hdoc_ctx hctx, int src_bgn, int src_end) {
|
||||
parser.Fail_throws_err_(true);
|
||||
parser.Parse(err_wkr, new Xoh_hdoc_ctx(), Xow_domain_itm_.Bry__enwiki, src_bgn, src_end);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnke_html__basic__tst {
|
||||
@After public void term() {fxt.Init_para_n_(); fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Auto__one() {fxt.Test_parse_page_wiki_str("[https://a]" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external autonumber\">[1]</a>");}
|
||||
@Test public void Auto__many() {fxt.Test_parse_page_wiki_str("[https://a] [https://b]" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external autonumber\">[1]</a> <a href=\"https://b\" rel=\"nofollow\" class=\"external autonumber\">[2]</a>");}
|
||||
@Test public void Text__basic() {fxt.Test_parse_page_wiki_str("[https://a b]" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external text\">b</a>");}
|
||||
@Test public void Text__wtxt() {fxt.Test_parse_page_wiki_str("[https://a ''b'']" , "<a href=\"https://a\" rel=\"nofollow\" class=\"external text\"><i>b</i></a>");}
|
||||
@Test public void Xowa_protocol() {
|
||||
String img = "<img src=\"file:///mem/xowa/bin/any/xowa/file/app.general/xowa_exec.png\"/>";
|
||||
fxt.Wiki().Sys_cfg().Xowa_proto_enabled_(true);
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a\" z]" , "<a href=\"xowa-cmd:a\">z" + img + "</a>");
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a.b('c_d');\" z]" , "<a href=\"xowa-cmd:a.b('c_d');\">z" + img + "</a>");
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:*\"a\"b*c\"* z]" , "<a href=\"xowa-cmd:a%22b%2Ac\">z" + img + "</a>");
|
||||
fxt.Wiki().Sys_cfg().Xowa_proto_enabled_(false);
|
||||
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a\" b]" , "[xowa-cmd:"a" b]"); // protocol is disabled: literalize String (i.e.: don't make it an anchor)
|
||||
}
|
||||
@Test public void Xwiki() {
|
||||
String wtxt = "[//en.wiktionary.org/wiki/A B]";
|
||||
String html_https = "<a href='https://en.wiktionary.org/wiki/A' rel='nofollow' class='external text'>B</a>";
|
||||
String html_xwiki = "<a href='/site/en.wiktionary.org/wiki/A'>B</a>";
|
||||
fxt.Test__parse__wtxt_to_html(wtxt, html_https); // https b/c wiki not installed
|
||||
fxt.Init_xwiki_add_user_("en.wiktionary.org");
|
||||
fxt.Test__parse__wtxt_to_html(wtxt, html_xwiki); // xwiki b/c wiki installed
|
||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Hdump);
|
||||
fxt.Test__parse__wtxt_to_html(wtxt, html_https); // https b/c hdump, even though wiki installed
|
||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Basic);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_lnke_html__hdump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
public static final String
|
||||
Html__free = "<a href=\"http://a.org\" rel=\"nofollow\" class=\"external free\">http://a.org</a>"
|
||||
, Html__auto = "<a href=\"http://a.org\" rel=\"nofollow\" class=\"external autonumber\">[1]</a>"
|
||||
, Html__text = "<a href=\"http://a.org\" rel=\"nofollow\" class=\"external text\">a</a>"
|
||||
;
|
||||
@Test public void Free() {fxt.Test__html("http://a.org" , Html__free);}
|
||||
@Test public void Auto() {fxt.Test__html("[http://a.org]" , Html__auto);}
|
||||
@Test public void Text() {fxt.Test__html("[http://a.org a]" , Html__text);}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_lnke_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Test public void Free() {
|
||||
fxt.Test__bicode("~#!http://a.org~", Xoh_lnke_html__hdump__tst.Html__free);
|
||||
}
|
||||
@Test public void Free__ws_at_end() {
|
||||
fxt.Test__bicode("~#%https://a.org/. ~https://a.org/.~", "<a href='https://a.org/. ' rel='nofollow' class='external free'>https://a.org/.</a>");
|
||||
}
|
||||
@Test public void Auto() {
|
||||
fxt.Test__bicode("~#*http://a.org~\"", Xoh_lnke_html__hdump__tst.Html__auto);
|
||||
}
|
||||
@Test public void Auto__tidy() { // PURPOSE:handle reparenting of html elements by HTML tidy EX:<font color="red">[http://a.org]</font>; DATE:2015-08-25
|
||||
fxt.Test__bicode
|
||||
( "~#&http://a.org~<font color=\"red\">[123]</font>~"
|
||||
, "<a href=\"http://a.org\" rel=\"nofollow\" class=\"external autonumber\"><font color=\"red\">[123]</font></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Auto__invalid_number() {
|
||||
String html = "<a href='http://a.org' rel='nofollow' class='external autonumber'>[abc]</a>";
|
||||
fxt.Test__bicode("~#&http://a.org~[abc]~", html);
|
||||
}
|
||||
@Test public void Text() {
|
||||
fxt.Test__bicode("~#'http://a.org~a~", Xoh_lnke_html__hdump__tst.Html__text);
|
||||
}
|
||||
@Test public void Wikivoyage__sleep() {
|
||||
fxt.Test__bicode
|
||||
( "~#7http://a.org~c~b~"
|
||||
, "<a href='http://a.org' rel='nofollow' class='external text' title='b'>c</a>");
|
||||
}
|
||||
// @Test public void Xwiki__exists() {
|
||||
// String hzip = "~#'https://en.wiktionary.org/wiki/A~A~";
|
||||
// String html_https = "<a href='https://en.wiktionary.org/wiki/A' rel='nofollow' class='external text'>A</a>";
|
||||
// String html_xwiki = "<a href='/site/en.wiktionary.org/wiki/A'>A</a>";
|
||||
// fxt.Test__bicode(hzip, html_https);
|
||||
// fxt.Init_wiki_installed("en.wiktionary.org");
|
||||
// fxt.Test__decode(hzip, html_xwiki);
|
||||
// }
|
||||
@Test public void Fail__href() {
|
||||
String html = "<a rel='nofollow' class='external autonumber'>a</a>";
|
||||
fxt.Test__encode__fail(html, html);
|
||||
}
|
||||
@Test public void Fail__lnke_type() {
|
||||
String html = "<a href='http://a.org' rel='nofollow' class='external invalid'>a</a>";
|
||||
fxt.Test__encode__fail(html, html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnki_html__basic__tst {
|
||||
@After public void term() {fxt.Init_para_n_(); fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Ns__title() { // PURPOSE: title should have full ns; "title='Help talk:A'" not "title='A'" DATE:2015-11-16
|
||||
fxt.Wtr_cfg().Lnki__title_(Bool_.Y);
|
||||
fxt.Test__parse__wtxt_to_html("[[Help talk:A b]]" , "<a href='/wiki/Help_talk:A_b' title='Help talk:A b'>Help talk:A b</a>");
|
||||
fxt.Wtr_cfg().Lnki__title_(Bool_.N);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_lnki_html__hdump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Same() {fxt.Test__html("[[A]]" , "<a href='/wiki/A' title='A'>A</a>");}
|
||||
@Test public void Diff() {fxt.Test__html("[[A|b]]" , "<a href='/wiki/A' title='A'>b</a>");}
|
||||
@Test public void Trail() {fxt.Test__html("[[A]]b" , "<a href='/wiki/A' title='A'>Ab</a>");}
|
||||
@Test public void Xwiki() {
|
||||
fxt.Parser_fxt().Init_xwiki_add_wiki_and_user_("wikt", "en.wiktionary.org");
|
||||
fxt.Test__html("[[wikt:a]]", "<a href='https://en.wiktionary.org/wiki/a' title='a'>wikt:a</a>");
|
||||
}
|
||||
@Test public void Anch() {fxt.Test__html("[[#a]]" , "<a href='#a'>#a</a>");}
|
||||
@Test public void Alt_has_quotes() {
|
||||
fxt.Test__html("[[File:A.png|alt=[[\"A\"]] B c]]", "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\""A" B c\"/></a>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnki_hzip__anch__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() { // EX: [[#a]]
|
||||
fxt.Test__bicode("~$Ba~#a~", "<a href='#a'>#a</a>");
|
||||
}
|
||||
@Test public void Capt() { // EX: [[#a|b]]
|
||||
fxt.Test__bicode("~$Ba~b~", "<a href='#a'>b</a>");
|
||||
}
|
||||
@Test public void Capt_similar() { // EX: [[#a|a]]
|
||||
fxt.Test__bicode("~$Ba~a~", "<a href='#a'>a</a>");
|
||||
}
|
||||
@Test public void Error() { // EX: [[#a|b]]; make sure bad title character does not cause error
|
||||
fxt.Test__bicode("~$Ba|b~#a|b~", "<a href='#a|b'>#a|b</a>"); // NOTE: the "|" should be url-encoded
|
||||
}
|
||||
@Test public void Inet__file() {
|
||||
fxt.Test__bicode("~$Rfile:///C://A.png~b~", "<a href='file:///C://A.png' title='file:///C://A.png'>b</a>");
|
||||
}
|
||||
@Test public void Inet__enc() {
|
||||
fxt.Test__bicode("~${'Thttps://simple.wikisource.org/wiki/A%C3%A6e~b~Aæe~", "<a href='https://simple.wikisource.org/wiki/A%C3%A6e' title='Aæe'>b</a>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnki_hzip__diff__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Diff__basic() { // EX: [[A|b]]
|
||||
fxt.Test__bicode("~$\"A~b~" , "<a href='/wiki/A' title='A'>b</a>");
|
||||
}
|
||||
@Test public void Diff__cs__lo() { // EX: [[A|a]]
|
||||
fxt.Test__bicode("~$%A~" , "<a href='/wiki/A' title='A'>a</a>");
|
||||
}
|
||||
@Test public void Diff__page_w_anch() { // EX: [[A#b|c]]
|
||||
fxt.Test__bicode("~${'$A#b~b~A~", "<a href='/wiki/A#b' title='A'>b</a>");
|
||||
}
|
||||
@Test public void Capt__nest() { // EX: [[A|B[[C|C1]]D]]
|
||||
fxt.Test__bicode
|
||||
( "~$\"A~B<a href=\"/wiki/C\" title=\"C\">C1</a>D~"
|
||||
, "<a href='/wiki/A' title='A'>B<a href='/wiki/C' title='C'>C1</a>D</a>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnki_hzip__ns__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Ns__same() { // EX: [[Help:A]]
|
||||
fxt.Test__bicode("~${#7/A~", "<a href='/wiki/Help:A' title='Help:A'>Help:A</a>");
|
||||
}
|
||||
@Test public void Ns__diff() { // EX: [[Help:A_b|c]]
|
||||
fxt.Test__bicode("~$b/A b~c~", "<a href='/wiki/Help:A_b' title='Help:A b'>c</a>");
|
||||
}
|
||||
@Test public void Ns__more() { // EX: [[Help:A|a b]]
|
||||
fxt.Test__bicode("~$g/A~ b~", "<a href='/wiki/Help:A' title='Help:A'>a b</a>");
|
||||
}
|
||||
@Test public void Ns__less() { // EX: [[Help:A_b|a]]
|
||||
fxt.Test__bicode("~$h/A~ b~", "<a href='/wiki/Help:A_b' title='Help:A b'>a</a>");
|
||||
}
|
||||
@Test public void Ns__talk() { // EX: [[Help talk:A b]]
|
||||
fxt.Test__bicode("~${#70A b~", "<a href='/wiki/Help_talk:A_b' title='Help talk:A b'>Help talk:A b</a>");
|
||||
}
|
||||
@Test public void Ns__talk__diff() { // EX: [[Help talk:A b|cde]]
|
||||
fxt.Test__bicode("~$b0A b~cde~", "<a href='/wiki/Help_talk:A_b' title='Help talk:A b'>cde</a>");
|
||||
}
|
||||
@Test public void Ns__under() { // EX: [[Help_talk:A_b]]; rare; just make sure codec can handle it;
|
||||
fxt.Test__bicode("~$b0A b~Help_talk:A_b~", "<a href='/wiki/Help_talk:A_b' title='Help talk:A b'>Help_talk:A_b</a>");
|
||||
}
|
||||
@Test public void Ns__pipe() { // EX: [[Help:A|]]
|
||||
fxt.Test__bicode("~$a/A~", "<a href='/wiki/Help:A' title='Help:A'>A</a>");
|
||||
}
|
||||
@Test public void Ns__pipe_w_words() { // EX: [[Help:A b|]]
|
||||
fxt.Test__bicode("~$a/A b~", "<a href='/wiki/Help:A_b' title='Help:A b'>A b</a>");
|
||||
}
|
||||
@Test public void Ns__anch() { // EX: [[Help:A_b#c|a]]
|
||||
fxt.Test__bicode("~${'j/A~ b#c~Help:A b~", "<a href='/wiki/Help:A_b#c' title='Help:A b'>a</a>");
|
||||
}
|
||||
@Test public void Ns__anch__alias() { // EX: [[Help:A_b#c|a]]
|
||||
fxt.Test__bicode("~${3h)Image~A.png#b~c~Image:A.png~", "<a href='/wiki/Image:A.png#b' title='Image:A.png'>c</a>");
|
||||
}
|
||||
@Test public void Fake__ns() { // EX: [[Fake:A]]
|
||||
fxt.Test__bicode("~$!Fake:A~", "<a href='/wiki/Fake:A' title='Fake:A'>Fake:A</a>");
|
||||
}
|
||||
@Test public void Alias__basic() { // EX: [[Image:A]]
|
||||
fxt.Test__bicode("~${-f)Image~A~B~", "<a href='/wiki/Image:A' title='Image:A'>B</a>");
|
||||
}
|
||||
@Test public void Alias__talk() { // EX: [[Image talk:A]]
|
||||
fxt.Test__bicode("~${/;*Image talk~Human-woman.png~", "<a href='/wiki/Image_talk:Human-woman.png' title='Image talk:Human-woman.png'>Image talk:Human-woman.png</a>");
|
||||
}
|
||||
@Test public void Alias__words() { // EX: [[Image:A b]]
|
||||
fxt.Test__bicode("~${/;)Image~A b~", "<a href='/wiki/Image:A_b' title='Image:A b'>Image:A b</a>");
|
||||
}
|
||||
@Test public void Alias__url_encoding() { // EX: [[Image:Aü.png|b]]
|
||||
fxt.Test__bicode("~${3h)Image~A%C3%BC.png~b~Image:Aü.png~", "<a href='/wiki/Image:A%C3%BC.png' title='Image:Aü.png'>b</a>");
|
||||
}
|
||||
@Test public void Ctg__main() { // links at bottom of pages in main ns; DATE:2015-12-28
|
||||
fxt.Test__bicode("~$|%\"(1A~", "<a href='/wiki/Category:A' class='inte" + "rnal' title='A'>A</a>");
|
||||
fxt.Test__decode("~$|$t'1A~", "<a href='/wiki/Category:A' class='inte" + "rnal' title='A'>A</a>"); // NOTE:backward compatibility for en.w:2015-12; delete after 2016-01 is uploaded
|
||||
}
|
||||
@Test public void Ctg__tree() { // links on Category pages;
|
||||
fxt.Test__bicode("~$|&3J1A~", "<a href='/wiki/Category:A' class='CategoryTreeLabel CategoryTreeLabelNs14 CategoryTreeLabelCategory'>A</a>");
|
||||
}
|
||||
@Test public void Ctg__xnav__space() { // previous / next 200 links on Category pages
|
||||
fxt.Test__bicode("~$|&`Z1A B?pageuntil=C, D#mw-pages~previous 200~Category:A_B~", "<a href='/wiki/Category:A_B?pageuntil=C, D#mw-pages' class='xowa_nav' title='Category:A_B'>previous 200</a>");
|
||||
}
|
||||
@Test public void Ctg__xnav__under() { // previous / next 200 links on Category pages; PAGE:en.w:Category:Public_transit_articles_with_unsupported_infobox_fields; DATE:2016-01-14
|
||||
fxt.Test__bicode("~$|&`Z1A B?pageuntil=C,_D#mw-pages~previous 200~Category:A_B~", "<a href='/wiki/Category:A_B?pageuntil=C,_D#mw-pages' class='xowa_nav' title='Category:A_B'>previous 200</a>");
|
||||
}
|
||||
@Test public void Outlier__title_wo_ns() {// should not happen, but handle situation wherein title doesnot have ns PAGE:en.b:Wikibooks:WikiProject DATE:2016-01-20
|
||||
fxt.Test__bicode("~${Tr/A B~", "<a href='/wiki/Help:A_B' title='A B'>A B</a>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnki_hzip__same__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Same__basic() { // EX: [[A]]
|
||||
fxt.Test__decode("~$!A~", "<a href='/wiki/A' title='A'>A</a>");
|
||||
}
|
||||
@Test public void Same__encoded() { // EX: [[A's]]
|
||||
String html = "<a href=\"/wiki/A%27s\" title=\"A's\">A's</a>";
|
||||
fxt.Test__bicode_raw("~${$#A%27s~A's~", html, html);
|
||||
}
|
||||
@Test public void Same__encoded__anch() { // EX: [[A#90.51]]
|
||||
fxt.Test__bicode("~${$%A~#90.51~", "<a href='/wiki/A#90.51' title='A'>A</a>");
|
||||
}
|
||||
@Test public void Same__encoded__anch__nbsp() { // EX: [[A# B|abc]]
|
||||
fxt.Test__bicode("~${$#A#.C2.A0B~abc~", "<a href='/wiki/A#.C2.A0B' title='abc'>abc</a>");
|
||||
}
|
||||
@Test public void Same__amp() { // EX: [[A&b]]
|
||||
fxt.Test__bicode("~${$#A%26b~A&b~", "<a href='/wiki/A%26b' title='A&b'>A&b</a>");
|
||||
}
|
||||
@Test public void More__basic() { // EX: [[A]]b
|
||||
fxt.Test__bicode("~$#A~b~", "<a href='/wiki/A' title='A'>Ab</a>");
|
||||
}
|
||||
@Test public void Less__cs__eq() { // EX: [[Ab|A]]
|
||||
fxt.Test__bicode("~$$A~b~", "<a href='/wiki/Ab' title='Ab'>A</a>");
|
||||
}
|
||||
@Test public void Less__cs__lo() { // EX: [[Ab|a]]
|
||||
fxt.Test__bicode("~$(A~b~", "<a href='/wiki/Ab' title='Ab'>a</a>");
|
||||
}
|
||||
@Test public void Less__ns__cs() { // EX: [[Help:A_b|a]]; make sure ns is added correctly, not "aHelp:b"
|
||||
fxt.Test__bicode("~$h/Ab~ c~", "<a href='/wiki/Help:Ab_c' title='Help:Ab c'>ab</a>");
|
||||
}
|
||||
@Test public void Ignore__audio() {
|
||||
String html = "<a href=\"file:///\" xowa_title=\"A.ogg\">a</a>";
|
||||
fxt.Test__bicode(html, html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_lnki_hzip__site__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() { // EX: [[wikt:A]]
|
||||
fxt.Test__bicode("~${$3en.wiktionary.org~A~wikt:A~" , "<a href='/site/en.wiktionary.org/wiki/A' title='wikt:A'>wikt:A</a>");
|
||||
}
|
||||
@Test public void Capt__lower() { // EX: [[wikt:A|a]]
|
||||
fxt.Test__bicode("~$5en.wiktionary.org~A~" , "<a href='/site/en.wiktionary.org/wiki/A' title='A'>a</a>");
|
||||
}
|
||||
@Test public void Capt__upper() { // EX: [[wikt:a|A]]
|
||||
fxt.Test__bicode("~$9en.wiktionary.org~a~" , "<a href='/site/en.wiktionary.org/wiki/a' title='a'>A</a>");
|
||||
}
|
||||
@Test public void Ns__href() { // EX: [[wikt:help:a]]
|
||||
fxt.Test__bicode("~${a2en.wiktionary.org~/help~a~wikt:help:a~" , "<a href='/site/en.wiktionary.org/wiki/help:a' title='wikt:help:a'>wikt:help:a</a>");
|
||||
}
|
||||
@Test public void Ns__capt() { // EX: [[wikt:help:a|b]]
|
||||
fxt.Test__bicode("~${d3en.wiktionary.org~/help~a~b~wikt:help:a~" , "<a href='/site/en.wiktionary.org/wiki/help:a' title='wikt:help:a'>b</a>"); // MW: also adds class="extiw"
|
||||
}
|
||||
@Test public void Ns__anch() { // EX: [[wikt:Help:A#b]]
|
||||
fxt.Test__bicode("~${'sen.wiktionary.org~/A#b~Help:A~" , "<a href='/site/en.wiktionary.org/wiki/Help:A#b' title='Help:A'>A#b</a>");
|
||||
}
|
||||
@Test public void Ns__more() { // EX: [[wikt:Help:A]]b
|
||||
fxt.Test__bicode("~${#Ien.wiktionary.org~/A~b~" , "<a href='/site/en.wiktionary.org/wiki/Help:A' title='Help:A'>Help:Ab</a>");
|
||||
}
|
||||
@Test public void Ns__more__name() { // EX: [[wikt:Help:A|Ab|]]
|
||||
fxt.Test__bicode("~$sen.wiktionary.org~/A~b~" , "<a href='/site/en.wiktionary.org/wiki/Help:A' title='Help:A'>Ab</a>");
|
||||
}
|
||||
@Test public void Ns__url_encoding() { // EX: [[wikt:Category:A & B|]]
|
||||
fxt.Test__bicode("~${$sen.wiktionary.org~1A %26 B~A & B~" , "<a href='/site/en.wiktionary.org/wiki/Category:A_%26_B' title='Category:A & B'>A & B</a>");
|
||||
}
|
||||
@Test public void Less__eq() { // EX: [[wikt:Ab|A]]
|
||||
fxt.Test__bicode("~${*7en.wiktionary.org~A~b~" , "<a href='/site/en.wiktionary.org/wiki/Ab'>A</a>");
|
||||
}
|
||||
@Test public void Less__lo() { // EX: [[wikt:Ab|a]]
|
||||
fxt.Test__bicode("~$8en.wiktionary.org~A~b~" , "<a href='/site/en.wiktionary.org/wiki/Ab' title='Ab'>a</a>");
|
||||
}
|
||||
@Test public void Less__hi() { // EX: [[wikt:ab|A]]
|
||||
fxt.Test__bicode("~$<en.wiktionary.org~a~b~" , "<a href='/site/en.wiktionary.org/wiki/ab' title='ab'>A</a>");
|
||||
}
|
||||
@Test public void More__hi() { // EX: [[wikt:a|Ab]]
|
||||
fxt.Test__bicode("~$;en.wiktionary.org~a~b~" , "<a href='/site/en.wiktionary.org/wiki/a' title='a'>Ab</a>");
|
||||
}
|
||||
@Test public void Encode__lnki() { // EX: [[wikt:eorðe|eorðe]]
|
||||
fxt.Test__bicode("~${$3en.wiktionary.org~eor%C3%B0e~eorðe~" , "<a href='/site/en.wiktionary.org/wiki/eor%C3%B0e' title='eorðe'>eorðe</a>");
|
||||
}
|
||||
// @Test public void Encode__lnke() { // EX: [//en.wiktionary.org/wiki/eorðe eorðe]; NOTE:MW inconsistently does not URL-encode external links (but does URL-encode @gplx.Internal protected ones)
|
||||
// fxt.Test__bicode("~$)en.wiktionary.org~eorðe~" , "<a href='/site/en.wiktionary.org/wiki/eorðe'>eorðe</a>");
|
||||
// }
|
||||
@Test public void Lnke__ns() {
|
||||
fxt.Test__bicode("~$qen.wiktionary.org~/a~" , "<a href='/site/en.wiktionary.org/wiki/Help:a' title='Help:a'>a</a>");
|
||||
}
|
||||
@Test public void Qarg_lnke() { // EX: [//en.wiktionary.org/wiki/A?b=c d]
|
||||
fxt.Test__bicode("~${*5en.wiktionary.org~A?b=c~d~" , "<a href='/site/en.wiktionary.org/wiki/A?b=c'>d</a>");
|
||||
}
|
||||
@Test public void Qarg_lnki() { // EX: [[wikt:A?b=c|d]]
|
||||
fxt.Test__bicode("~$2en.wiktionary.org~A?b=c~d~" , "<a href='/site/en.wiktionary.org/wiki/A?b=c' title='A?b=c'>d</a>"); // NOTE: mw encodes as A%3Fb%3Dc
|
||||
}
|
||||
@Test public void Main_page() { // EX: [[wikt:]]
|
||||
fxt.Test__bicode("~${<<en.wiktionary.org~~wikt:~" , "<a href='/site/en.wiktionary.org/wiki/' title='wikt:'>wikt:</a>");
|
||||
}
|
||||
@Test public void Wikivoyage__email() {
|
||||
fxt.Test__bicode
|
||||
( "$|)%6mailto:ab"
|
||||
, "<a href='mailto:a' class='email'>b</a>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.anchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.core.brys.*; import gplx.langs.htmls.docs.*;
|
||||
public class Xoh_anch_capt_itm_tst {
|
||||
private final Xoh_anch_capt_itm_fxt fxt = new Xoh_anch_capt_itm_fxt();
|
||||
@Test public void Basic__same() {fxt.Test__match("Abc" , "Abc", Xoh_anch_capt_itm.Tid__same);}
|
||||
@Test public void Basic__diff() {fxt.Test__match("Abc" , "ABC", Xoh_anch_capt_itm.Tid__diff);}
|
||||
@Test public void Space__same() {fxt.Test__match("A_b" , "A b", Xoh_anch_capt_itm.Tid__same);}
|
||||
@Test public void Case__same() {fxt.Test__match("Abc" , "abc", Xoh_anch_capt_itm.Tid__same);}
|
||||
// @Test public void Case__reverse() {fxt.Test__match("abc" , "Abc", Xoh_anch_capt_itm.Tid__diff);}
|
||||
// @Test public void Case__disabled() {
|
||||
// fxt.Wiki().Ns_mgr().Ns_main().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
// fxt.Test__match("Abcde", "abcde", Xoh_anch_capt_itm.Tid__diff);
|
||||
// }
|
||||
@Test public void Ns__href() {fxt.Test__match("Help_talk:Ab" , "Help talk:Ab" , Xoh_anch_capt_itm.Tid__same);}
|
||||
@Test public void Capt_trail() {fxt.Test__match("A" , "Abc" , Xoh_anch_capt_itm.Tid__more, 1);}
|
||||
@Test public void Href_trail() {fxt.Test__match("Ab" , "A" , Xoh_anch_capt_itm.Tid__less, 1);}
|
||||
}
|
||||
class Xoh_anch_capt_itm_fxt {
|
||||
private final Xoh_anch_capt_itm matcher = new Xoh_anch_capt_itm();
|
||||
private final Bry_rdr rdr = new Bry_rdr();
|
||||
public Xoh_anch_capt_itm_fxt() {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public void Test__match(String page_str, String capt_str, int expd_tid) {Test__match(page_str, capt_str, expd_tid, -1);}
|
||||
public void Test__match(String page_str, String capt_str, int expd_tid, int expd_trail_bgn) {
|
||||
byte[] page_bry = Bry_.new_u8(page_str);
|
||||
byte[] capt_bry = Bry_.new_u8(capt_str);
|
||||
Xoa_ttl href_ttl = wiki.Ttl_parse(page_bry);
|
||||
boolean ns_is_cs = href_ttl.Ns().Case_match() == gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all;
|
||||
Tfds.Eq_int(expd_tid , matcher.Parse(rdr.Init_by_page(Bry_.Empty, page_bry, page_bry.length), ns_is_cs, page_bry, 0, page_bry.length, capt_bry, 0, capt_bry.length));
|
||||
Tfds.Eq_int(expd_trail_bgn , matcher.Split_pos());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.anchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.core.brys.*; import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_anch_href_data_tst {
|
||||
private final Xoh_anch_href_data_fxt fxt = new Xoh_anch_href_data_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Site() {
|
||||
fxt.Test__parse("/site/A/wiki/B", "A", "B");
|
||||
}
|
||||
@Test public void Page() {
|
||||
fxt.Test__parse("/wiki/B", "", "B");
|
||||
}
|
||||
@Test public void Href() {
|
||||
fxt.Test__parse("#A", "", "A");
|
||||
}
|
||||
@Test public void None() {
|
||||
fxt.Test__parse("", "", "");
|
||||
}
|
||||
@Test public void Inet() {
|
||||
fxt.Test__parse("http://a.org", "", "http://a.org");
|
||||
}
|
||||
// @Test public void Inet__mw() {
|
||||
// fxt.Test__parse("https://en.wikipedia.org/wiki/A", "en.wikipedia.org", "A");
|
||||
// }
|
||||
@Test public void Fail__1st_seg_must_be_site_or_wiki() {
|
||||
fxt.Test__parse__fail("/fail/A", "failed trie check: mid='fail/A' page='Main_Page' sect='href' text=/fail/A");
|
||||
}
|
||||
@Test public void Fail__2nd_seg_must_be_wiki() {
|
||||
fxt.Test__parse__fail("/site/A/B/C", "failed check: chk='wiki/' page='Main_Page' sect='href' text=/site/A/B/C");
|
||||
}
|
||||
}
|
||||
class Xoh_anch_href_data_fxt extends Xoh_itm_parser_fxt { private final Xoh_anch_href_data parser = new Xoh_anch_href_data();
|
||||
public void Clear() {
|
||||
Xoa_app_fxt.repo2_(app, wiki);
|
||||
hctx.Init_by_page(wiki, new Xoh_page());
|
||||
}
|
||||
@Override public Xoh_itm_parser Parser_get() {return parser;}
|
||||
public void Test__parse(String src_str, String expd_site, String expd_page) {
|
||||
Exec_parse(src_str);
|
||||
Tfds.Eq_str(expd_site, parser.Site_bgn() == -1 ? "" : String_.new_u8(src, parser.Site_bgn(), parser.Site_end()));
|
||||
Tfds.Eq_str(expd_page, String_.new_u8(src, parser.Ttl_bgn(), parser.Ttl_end()));
|
||||
}
|
||||
@Override public void Exec_parse_hook(Bry_err_wkr err_wkr, Xoh_hdoc_ctx hctx, int src_bgn, int src_end) {
|
||||
parser.Parse(err_wkr, hctx, err_wkr.Src(), src_bgn, src_end);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__audio__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Audio__full() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|noicon]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Audio__full_ogg() {// PURPOSE: ogg should show src on first load
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(true); // simulate release-mode wherein missing images will not have src
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.ogg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"A.ogg\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" width=\"220\" height=\"-1\" />" // note that src still exists (needed for clicking)
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(false);
|
||||
}
|
||||
@Test public void Audio__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.oga\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.oga\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <div class=\"xowa_alt_text\">"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Audio__full_width() { // ISSUE: width arg ignored for v2; zh.b:小学数学/自然数; DATE:2014-05-03
|
||||
fxt.Wiki().File_mgr().Version_2_y_();
|
||||
fxt.App().Usere().Init_by_app(fxt.App()); // TEST: init cache else null reference
|
||||
fxt.Test_html_wiki_frag("[[File:A.oga|30px|a]]", "<div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:30px;\">");
|
||||
fxt.Wiki().File_mgr().Version_1_y_();
|
||||
}
|
||||
@Test public void Audio__noicon() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|noicon|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">a"
|
||||
, " </div>"
|
||||
, " <div class=\"xowa_alt_text\">"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
// @Test public void Ogg() {
|
||||
// fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogg).View_max_(0);
|
||||
// fxt .ini_page_api("commons", "A.ogg", "", 0, 0);
|
||||
// fxt .Lnki_orig_("A.ogg")
|
||||
// .Src( )
|
||||
// .Trg(
|
||||
// fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/4/42.csv", "A.ogg|z||2?0,0|0?0,0")
|
||||
// )
|
||||
// .tst();
|
||||
// fxt .Lnki_orig_("A.ogg")
|
||||
// .Html_orig_src_("file:///mem/trg/en.wikipedia.org/raw/4/2/A.ogg")
|
||||
// .tst();
|
||||
// fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogg).View_max_(-1);
|
||||
// }
|
||||
@@ -0,0 +1,378 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__image__basic__tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Img__full() { // PURPOSE: full with title was outputting invalid html; DATE:2013-12-31
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>" // NOTE: used to output class=\"image\"A.png
|
||||
));
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Xowa_title__quotes() { // PURPOSE: xowa_title should encode quotes DATE:2015-11-27
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A%22b.png]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A%22b.png\" class=\"image\" xowa_title=\"A%22b.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/d/4/A%22b.png\" width=\"0\" height=\"0\" /></a>"
|
||||
));
|
||||
}
|
||||
@Test public void Img__embed() {
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|9x8px|alt=abc]]", Xop_fxt.html_img_none("File:A.png", "abc", "file:///mem/wiki/repo/trg/thumb/7/0/A.png/9px.png", "A.png"));
|
||||
}
|
||||
@Test public void Embed_audio() {
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.jpg|thumb|b[[File:C.ogg|right|140x140px]]d]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.jpg\" class=\"image\" xowa_title=\"A.jpg\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/6/7/A.jpg/220px.jpg\" width=\"0\" height=\"0\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.jpg\" class=\"internal\" title=\"Enlarge\"></a></div>b <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:C.ogg\" class=\"image\" title=\"C.ogg\" xowa_title=\"C.ogg\"><img id=\"xoimg_1\" alt=\"\" src=\"\" width=\"140\" height=\"140\" /></a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_1\" href=\"file:///mem/wiki/repo/trg/orig/d/3/C.ogg\" xowa_title=\"C.ogg\" class=\"xowa_media_play\" style=\"width:138px;max-width:140px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>d"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Img__none() { // NOTE: floatnone is WP behavior; MW omits div tag
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|none|20x30px|b]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"floatnone\">"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/20px.png\" width=\"20\" height=\"30\" /></a></div>"
|
||||
));
|
||||
}
|
||||
@Test public void Img__thumb_none() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|thumb|none|b]]"
|
||||
, Img_thumb_str("none")
|
||||
);
|
||||
}
|
||||
@Test public void Img__thumb_ltr() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|thumb|b]]"
|
||||
, Img_thumb_str("right")
|
||||
);
|
||||
}
|
||||
@Test public void Img__thumb_rtl() {
|
||||
fxt.Wiki().Lang().Dir_ltr_(false);
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|thumb|b]]"
|
||||
, Img_thumb_str("left")
|
||||
);
|
||||
fxt.Wiki().Lang().Dir_ltr_(true);
|
||||
}
|
||||
private String Img_thumb_str(String align) {
|
||||
return String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb t" + align + "\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"0\" height=\"0\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Img__frame() { // PURPOSE: lnki with "frame" is same as thumb; DATE:2013-12-23
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|frame|220x110px|b]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"220\" height=\"110\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Img__frame_and_thumb() { // PURPOSE: lnki with "frame and thumb" was not showing box due to bit-adding; PAGE:en.w:History_of_Western_Civilization DATE:2015-04-16
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|frame|thumb|220x110px|b]]" // NOTE: frame AND thumb
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"220\" height=\"110\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Thm__alt_is_ws() { // PURPOSE: alt with space should not output <hr>; EX:[[File:A.png|thumb|alt= ]]; en.w:Bird; DATE:2015-12-28
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|thumb|220x110px|alt= ]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\" \" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"220\" height=\"110\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Cls_border() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|border]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" class=\"thumbborder\" /></a>");
|
||||
}
|
||||
@Test public void Cls_custom() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|class=abc]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" class=\"abc\" /></a>");
|
||||
}
|
||||
@Test public void Cls_border_custom() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|border|class=abc]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" class=\"thumbborder abc\" /></a>");
|
||||
}
|
||||
@Test public void Lnki_full_svg() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.svg|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A.svg\" class=\"image\" xowa_title=\"A.svg\"><img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/5/A.svg/-1px.png\" width=\"0\" height=\"0\" /></a>" // HACK: tries to get orig_w which is not available
|
||||
));
|
||||
}
|
||||
@Test public void Lnki_file_alt_link() { // PURPOSE: lnki in caption should not create alt="b<a href="c">cd</a>"
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|thumb|alt=b [[c]] d]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"b c d\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"0\" height=\"0\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"xowa_alt_text\">"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b <a href=\"/wiki/C\">c</a> d"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Pre_in_caption() { // PURPOSE: ignore pre if in caption; PAGE:s.w:Virus; DATE:2015-03-31
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
|
||||
( "[[File:A.png|thumb|a\n b]]" // "\n " is pre
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"0\" height=\"0\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>a" // no pre
|
||||
, " b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
}
|
||||
@Test public void Img__title() {
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
Tst_img_title("[[File:A.png|frameless|a b]]", "a b");
|
||||
Tst_img_title("[[File:A.png|thumb|a b]]", "Enlarge"); // caption should not replace text
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Title_escape() { // PURPOSE: escape quotes in title; PAGE:none; DATE:2014-10-27
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_wiki_str("[[A\"B]]", "<a href=\"/wiki/A%22B\" title=\"A"B\">A\"B</a>");
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Img__title__caption_has_lnki() { // PURPOSE: caption with lnki should show in title; PAGE:en.w:Earth; DATE:2014-08-06
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
Tst_img_title("[[File:A.png|frameless|[[A]]]]" , "A"); // ttl only
|
||||
Tst_img_title("[[File:A.png|frameless|[[A|B]]]]" , "B"); // caption
|
||||
Tst_img_title("[[File:A.png|frameless|[[A]]b]]" , "Ab"); // tail
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Lnki_alt_is_text() { // PURPOSE: (a) alt should default to caption; (b) alt should not show html chars (like <a src=")
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|a[[b]]c]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"aBc\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
);
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Alt_ignore_apos() {// PURPOSE: alt should ignore apos; EX: [[File:A.png|''A'']] should have alt of A; DATE:2013-10-25
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|''b'']]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"b\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
);
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Alt_ignore_lnke() {// PURPOSE: alt should ignore lnke
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|b[http://c.org d] e]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"bd e\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"bd e\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
);
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Alt_ignore_list() {// PURPOSE: alt should ignore list
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|b\n*c]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"bc\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"b*c\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
);
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Alt_ignore_tblw() {// PURPOSE: alt should ignore tblw
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|\n{|\n|-\n|b\n|}\n]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"b \" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\" b \" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
);
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Alt_ignore_para() {// PURPOSE: alt should ignore para
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Init_para_y_();
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|b\nc]]"
|
||||
, String_.Concat_lines_nl
|
||||
( "<p><a href=\"/wiki/File:A.png\" class=\"image\" title=\"b c\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"b c\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Init_para_n_();
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Lnki_empty_alt_is_omitted() {// PURPOSE: empty alt should be ignored; DATE:2013-07-30
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|a|alt=]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"a\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
);
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Href_anchor_leading_space() { // PURPOSE: space before anchor should be preserved, not " " -> "#"
|
||||
fxt.Test_parse_page_all_str("[[A #b]]", "<a href=\"/wiki/A#b\">A #b</a>");
|
||||
}
|
||||
@Test public void Href_anchor_leading_space_ns() { // PURPOSE: same as above, but with ns; DATE:2013-08-29
|
||||
fxt.Test_parse_page_all_str("[[Help:A #b]]", "<a href=\"/wiki/Help:A#b\">Help:A #b</a>");
|
||||
}
|
||||
@Test public void Href_anchor_leading_ns_lc() { // PURPOSE: same as above but with lc title
|
||||
fxt.Test_parse_page_all_str("[[Help:a#b]]", "<a href=\"/wiki/Help:A#b\">Help:A#b</a>");
|
||||
}
|
||||
@Test public void Href_anchor_leading_space_ns_lc() { // PURPOSE: same as above but with lc title
|
||||
fxt.Test_parse_page_all_str("[[Help:a #b]]", "<a href=\"/wiki/Help:A#b\">Help:A #b</a>");
|
||||
}
|
||||
@Test public void Lnki_caption_nested_file() { // PURPOSE: nested lnki in caption breaks alt with html chars; EX:de.w:Wien; DATE:2013-12-16
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|none|[[File:B.png|20px|d]] c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"floatnone\">"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" title=\"d c\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"d c\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a></div>"
|
||||
, ""
|
||||
));
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Link__file() { // PURPOSE.FIX: link=file:/// was creating "href='/wiki/file'" handle IPA links; EX:[[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/c/7/a/3/En-LudwigVanBeethoven.ogg|Listen]]; PAGE:en.w:Beethoven DATE:2015-12-28
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=file:///C:/A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///C:/A.ogg\" class=\"image\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=|abc]]", String_.Concat_lines_nl_skip_last
|
||||
( "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
));
|
||||
}
|
||||
@Test public void Link__lc() { // links to items in same Srch_rslt_cbk should automatically title-case words; DATE:2016-01-11
|
||||
fxt.Init_xwiki_add_wiki_and_user_("en", "en.wikipedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=en:Help:a?b=c#d|abc]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/Help:A?b=c#d\" class=\"image\" xowa_title=\"A.png\">" // "Help:A" not "Help:a"
|
||||
+ "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"));
|
||||
fxt.Init_xwiki_clear();
|
||||
}
|
||||
@Test public void Redirect() {// PURPOSE: redirect should use trg_lnki, not src_lnki; DATE:2016-08-10
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.png", Xof_ext_.Id_png, 320, 300, "B.png");
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__mp__y_();
|
||||
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|320px|bcd|alt=efg]]"
|
||||
, "<a href=\"/wiki/File:B.png\" class=\"image\" xowa_title=\"B.png\"><img id=\"xoimg_0\" alt=\"efg\" src=\"file:///mem/wiki/repo/trg/orig/5/7/B.png\" width=\"320\" height=\"300\" /></a>"
|
||||
);
|
||||
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__bld__y_();
|
||||
}
|
||||
@Test public void Imap() {
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.png", Xof_ext_.Id_png, 320, 300, "");
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__mp__y_();
|
||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Hdump);
|
||||
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|320px|a1"
|
||||
, "circle 0 0 5 [[B|b1]]"
|
||||
, "rect 0 0 4 8 [[C|c1]]"
|
||||
, "desc none"
|
||||
, "</imagemap>"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:320px;\">"
|
||||
, " <div id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " <area href=\"/wiki/B\" shape=\"circle\" coords=\"0,0,5\" alt=\"b1\" title=\"b1\"/>"
|
||||
, " <area href=\"/wiki/C\" shape=\"rect\" coords=\"0,0,4,8\" alt=\"c1\" title=\"c1\"/>"
|
||||
, " </map>"
|
||||
, " <img src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"320\" height=\"300\" alt=\"\" usemap=\"#imagemap_1_1\"/>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>a1"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__bld__y_();
|
||||
}
|
||||
private void Tst_img_title(String raw, String expd_ttl) {
|
||||
String actl = fxt.Exec_parse_page_wiki_as_str(raw);
|
||||
String actl_ttl = null;
|
||||
int title_bgn = String_.FindFwd(actl, " title=\"");
|
||||
if (title_bgn != String_.Find_none) {
|
||||
title_bgn += String_.Len(" title=\"");
|
||||
int title_end = String_.FindFwd(actl, "\"", title_bgn);
|
||||
if (title_end != String_.Find_none) actl_ttl = String_.Mid(actl, title_bgn, title_end);
|
||||
}
|
||||
Tfds.Eq(expd_ttl, actl_ttl, actl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__image__link__tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Link__file() { // PURPOSE.FIX: link=file:/// was creating "href='/wiki/file'" handle IPA links; EX:[[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/c/7/a/3/En-LudwigVanBeethoven.ogg|Listen]]; PAGE:en.w:Beethoven DATE:2015-12-28
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=file:///C:/A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///C:/A.ogg\" class=\"image\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=|abc]]", String_.Concat_lines_nl_skip_last
|
||||
( "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
));
|
||||
}
|
||||
@Test public void Link__lc() { // links to items in same Srch_rslt_cbk should automatically title-case words; DATE:2016-01-11
|
||||
fxt.Init_xwiki_add_wiki_and_user_("en", "en.wikipedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=en:Help:a?b=c#d|abc]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/Help:A?b=c#d\" class=\"image\" xowa_title=\"A.png\">" // "Help:A" not "Help:a"
|
||||
+ "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"));
|
||||
fxt.Init_xwiki_clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_file_wtr__media__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Page_only() { // if no caption, then use page name; DATE:2017-05-20
|
||||
fxt.Test_parse_page_wiki_str("[[Media:A.png]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" xowa_title=\"A.png\">Media:A.png"
|
||||
, "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Nested_caption() { // PAGE:en.w:Beethoven;
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|thumb|b [[Media:A.ogg|media_caption]] c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"0\" height=\"0\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>b <a href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\">media_caption"
|
||||
, "</a> c"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Caption() {
|
||||
fxt.Test_parse_page_wiki_str("[[Media:A.png|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" xowa_title=\"A.png\">b"
|
||||
, "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Literal() {
|
||||
fxt.Test_parse_page_wiki_str("[[:Media:A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\">b"
|
||||
, "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Literal_w_missing() {
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(true); // simulate missing file; DATE:2014-01-30
|
||||
fxt.Test_parse_page_wiki_str("[[Media:A.pdf|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/e/f/A.pdf\" xowa_title=\"A.pdf\">b"
|
||||
, "</a>"
|
||||
));
|
||||
Tfds.Eq(0, fxt.Page().File_queue().Count()); // make sure media does not add to queue
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__video__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Video__full__ogv__width_y() {// EX: [[File:A.ogv|320px|bcd|alt=efg]]; DATE:2016-08-05
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|320px|bcd|alt=efg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"efg\" src=\"\" width=\"320\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full__ogv__width_n() {// EX: [[File:A.ogv]]; DATE:2016-08-05
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" width=\"0\" height=\"0\" />" // NOTE: src should probably be empty;
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full__ogv__time() {
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.ogv", Xof_ext_.Id_ogv, 220, 300, "");
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__mp__y_();
|
||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Hdump);
|
||||
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|thumbtime=4]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img src=\"file:///mem/wiki/repo/trg/thumb/d/0/A.ogv/220px-4.jpg\" width=\"220\" height=\"300\" alt=\"\"/>" // NOTE: src should probably be empty;
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full_ogg() {// PURPOSE: ogg w/ width should default to video; otherwise dynamic-update won't be able to convert audio-button to thumb; DATE:2016-08-05
|
||||
// NOTE: simulates app w/ fsdb
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.ogg", Xof_ext_.Id_ogv, 320, 300, "");
|
||||
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogg|320px|bcd|alt=efg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"A.ogg\" xowa_title=\"A.ogg\"><img id=\"xoimg_0\" alt=\"efg\" src=\"file:///mem/wiki/repo/trg/thumb/4/2/A.ogg/-1px.jpg\" width=\"320\" height=\"300\" /></a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|thumb|320px|bcd|alt=efg]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"efg\" src=\"\" width=\"320\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>bcd"
|
||||
, " </div>"
|
||||
, " <div class=\"xowa_alt_text\">"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">efg"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb_webm() { // PURPOSE: webm thumb wasn't being shown; DATE:2014-01-25
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.webm|thumb|320px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.webm\" class=\"image\" title=\"A.webm\" xowa_title=\"A.webm\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"320\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/3/4/A.webm\" xowa_title=\"A.webm\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.webm\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <div class=\"xowa_alt_text\">"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.parsers.*;
|
||||
public class Xoh_lnki_title_bldr_tst {
|
||||
private final Xoh_lnki_title_bldr_fxt fxt = new Xoh_lnki_title_bldr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__parse("a b c", "a b c");
|
||||
fxt.Test__parse("a ''b'' c", "a b c");
|
||||
fxt.Test__parse("a <i>b</i> c", "a b c");
|
||||
fxt.Test__parse("a\nb", "a b");
|
||||
fxt.Test__parse("a\"b", "a"b");
|
||||
}
|
||||
@Test public void Lnki__quotes() { // PURPOSE: handle titles with quotes; PAGE:s.w:Styx_(band) DATE:2015-11-29
|
||||
fxt.Test__parse("[[A\"B]]", "A"B");
|
||||
}
|
||||
}
|
||||
class Xoh_lnki_title_bldr_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public void Test__parse(String raw, String expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Xop_root_tkn root = fxt.Ctx().Tkn_mkr().Root(raw_bry);
|
||||
fxt.Parser().Parse_page_all_clear(root, fxt.Ctx(), fxt.Ctx().Tkn_mkr(), raw_bry);
|
||||
Xoh_lnki_title_bldr.Add(bfr, raw_bry, root);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_thm_html_tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Image() {
|
||||
fxt.Test__html("[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:220px;'>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>test_caption"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Audio__link() { // PURPOSE: handle IPA links; EX:[[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/c/7/a/3/En-LudwigVanBeethoven.ogg|Listen]]; PAGE:en.w:Beethoven DATE:2015-12-28
|
||||
fxt.Test__html("[[File:A.oga|11px|link=file:///C:/A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:11px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a href=\"\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:9px;max-width:11px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.oga\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.oga\" class=\"internal\" title=\"Enlarge\"></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Video() {
|
||||
fxt.Test__html("[[File:A.ogv|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\"><img data-xowa-title=\"A.ogv\" data-xoimg=\"4|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>test_caption"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__avo__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Video() {
|
||||
fxt.Test__bicode("~&%test_caption~|E9eA.ogv~%A.ogv~~", Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "test_caption</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
@Test public void Audio() {
|
||||
fxt.Test__bicode(Gfh_utl.Replace_apos(String_.Concat_lines_nl
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a href=\"\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div>$|#na)A.ogaAbout this file</div>"
|
||||
, "</div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~$|%%,)~A.oga~Enlarge~</div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
)), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "<div><a href='/wiki/File:A.oga' class='xowa_media_info' title='About this file'></a></div>"
|
||||
, "</div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.oga' class='internal' title='Enlarge'></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__basic__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Image_wo_alt_text() {// LEGACY: pre xowa_alt_text
|
||||
fxt.Test__bicode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Image_w_alt_text() {// NOTE: xowa_alt_text; PAGE:es.w:Biome DATE:2017-09-04
|
||||
fxt.Test__bicode("~&{\"^abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<div class=\"xowa_alt_text\">"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Capt_is_missing() { // [[File:A.png|thumb]]
|
||||
fxt.Test__bicode("~&#~!%A.png~)#S~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fix__omitted_table_tail() { // PURPOSE.hdiff: handle omitted </table>; PAGE:en.w:Alphabet; DATE:2016-01-06
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&]&D~"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "~!5A.png~-&D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:460px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|460|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Div_width_uses_img_width() {
|
||||
Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, Bry_.new_a7("en.w"), Bry_.new_a7("A.png"), Xop_lnki_type.Id_null, -1, 220, -1, -1, -1, 0);
|
||||
itm.Init_at_cache(true, 400, 440, Io_url_.mem_fil_("mem/A.png"));
|
||||
Xou_cache_finder_mem finder = fxt.Init_file_mgr__mem();
|
||||
finder.Add(itm);
|
||||
|
||||
fxt.Test__decode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:400px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='file:///mem/A.png' width='400' height='440' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
|
||||
fxt.Init_file_mgr__noop();
|
||||
}
|
||||
// @Test public void Dump() {
|
||||
// Xowe_wiki en_d = fxt.Init_wiki_alias("wikt", "en.wiktionary.org");
|
||||
// gplx.xowa.wikis.nss.Xow_ns_mgr ns_mgr = en_d.Ns_mgr();
|
||||
// ns_mgr.Ns_main().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
//
|
||||
// fxt.Wiki().Ns_mgr().Aliases_add(gplx.xowa.wikis.nss.Xow_ns_.Tid__portal, "WP");
|
||||
// fxt.Wiki().Ns_mgr().Init();
|
||||
//
|
||||
// fxt.Init_mode_is_b256_(Bool_.N);
|
||||
// fxt.Exec_write_to_fsys(Io_url_.new_dir_("C:\\xowa\\debug\\html\\"), "hzip.html");
|
||||
// fxt.Init_mode_is_b256_(Bool_.N);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__pseudo__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Fake__div_1__next_nde() { // PURPOSE: handle fake-thumbs with pseudo thumbimage class; PAGE:s.w:Mars
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'>~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'><a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__style() { // PURPOSE.hdiff: handle fake-thumbs with bad style; PAGE:en.w:Carlisle_United_F.C.
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~${#7)A.jpg~</div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__width_w_space() { // PURPOSE.hdiff: handle fake-thumbs with style of "width "; PAGE:en.w:Abraham_Lincoln
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~${#7)A.jpg~</div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__thumbimage() { // PURPOSE.hdiff: handle fake-thumbs with image-map style; PAGE:en.w:UK
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;'>"
|
||||
, "<div class='thumbimage' style='width:250px;'>"
|
||||
, "<center>"
|
||||
, "<div style='width: 250px; float: none; margin: none; padding: none; border: none; clear: none; background-color: #ffffff; position: relative;'>"
|
||||
, "{0}"
|
||||
, "<div style='font-size: smaller; line-height: 10px;'>"
|
||||
, "<div style='position:absolute;text-align:center;left:150.25px;top:292px'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</center>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>def</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div style=\"background-color: ;\">~%!!A.svg~)#q~</div>"), "'", "\""), String_.Format(html, "<div style='background-color: ;'><a href='/wiki/File:A.svg' class='image' title='' xowa_title='A.svg'><img data-xowa-title='A.svg' data-xoimg='0|250|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"));
|
||||
}
|
||||
@Test public void Fake__div_1__extra_attribs() {// PURPOSE.hdiff: handle fake thumbs with extra attribs; PAGE:en.w:Wikipedia:New_CSS_framework; DATE:2016-01-11
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;color:blue;'>{0}" // "color:blue;" is invalid attribs
|
||||
, "<div class='thumbcaption'>abc"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "~%!!A.png~)#g~"), "'", "\""), String_.Format(html, "<a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"));
|
||||
}
|
||||
@Test public void Fake__div_2__not_media() { // PURPOSE.hdiff: handle fake-thumbs created through en.w:Template:Image_label_begin; PAGE:en.w:Blackburnshire; DATE:2016-01-04
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:240px;'>"
|
||||
, "<div style='width: 240pxpx;'>"
|
||||
, "{0}"
|
||||
, "<div>abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "{1}"
|
||||
, "bcd</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div>~%!!A.png~)#g~</div>", "<div class=\"magnify\">~$a)A.png~</div>"), "'", "\""), String_.Format(html, "<div><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>", "<div class='magnify'><a href='/wiki/File:A.png' title='File:A.png'>A.png</a></div>"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__tidy__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Tidy__moved_capt() {
|
||||
fxt.Test__bicode("~&S~abc\n~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__extra_closing_div() {// handle extra closing div in caption; PAGE:en.w:Damask; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&U<div>A</div>"
|
||||
, "B~"
|
||||
, "C~!1A.png~-\"b"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|150|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "<div>A</div>"
|
||||
, "B</div>"
|
||||
, "C</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__ul() { // tidy will move <div> on to different lines depending on <ul>; PAGE:en.w:Chimney_sweep; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&=$b* ABC~"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "~!uA.png~-$bABC~"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:320px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|320|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='ABC'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "* ABC</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__video() { // tidy may relocate xowa-alt-div to last div; PAGE:en.w:Non-helical_models_of_DNA_structure; DATE:2016-01-11
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&eabc~"
|
||||
, "<hr>"
|
||||
, "<div class=\"thumbcaption\">bcd</div>"
|
||||
, "~|E9eA.ogv~%A.ogv~~"), Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>bcd</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_toc_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() { // EX: <div class='xo-toc'/>
|
||||
fxt.Test__bicode("~)!", "<div class=\"xo-toc\"></div>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.xndes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*;
|
||||
import gplx.xowa.htmls.core.wkrs.xndes.atrs.*; import gplx.xowa.htmls.core.wkrs.xndes.tags.*;
|
||||
public class Xoh_xnde_hzip_nde__tst {
|
||||
// private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_is_b256_(Bool_.N);
|
||||
@Test public void Basic() {
|
||||
// fxt.Test__bicode("?#%", "<td scope='row' colspan='2' rowspan='4'/>");
|
||||
}
|
||||
@Test public void Style() {
|
||||
// fxt.Test__bicode("?#%", "<td style='text-align:center'/>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.xndes.dicts; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import org.junit.*; import gplx.core.brys.*;
|
||||
public class Xoh_xnde_dict__tst {
|
||||
private final Xoh_xnde_dict__fxt fxt = new Xoh_xnde_dict__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Exec__add("a");
|
||||
fxt.Test__get_by_key_or_new("a", 0);
|
||||
fxt.Test__get_by_key_or_new("b", 1);
|
||||
byte[] dump = fxt.Dump_bldr().Add(0, "a").Add(1, "b").To_bry();
|
||||
fxt.Test__save(dump);
|
||||
fxt.Exec__clear();
|
||||
// fxt.Test__load(dump, fxt.Make__itm(0, "a"), fxt.Make__itm(1, "b"));
|
||||
}
|
||||
}
|
||||
class Xoh_xnde_dict__fxt {
|
||||
private final Xoh_xnde_dict_grp grp = new Xoh_xnde_dict_grp(1);
|
||||
private final Xoh_hzip_bfr bfr = new Xoh_hzip_bfr(32, Bool_.Y, Byte_ascii.Escape);
|
||||
private final Bry_rdr rdr = new Bry_rdr();
|
||||
public Xoh_xnde_dict__fxt() {
|
||||
this.dump_bldr = new Xoh_xnde_dict__dump_bldr(bfr);
|
||||
}
|
||||
public Xoh_xnde_dict__dump_bldr Dump_bldr() {return dump_bldr;} private final Xoh_xnde_dict__dump_bldr dump_bldr;
|
||||
public void Exec__add(String val) {grp.Add(Bry_.new_u8(val));}
|
||||
public void Exec__clear() {grp.Clear();}
|
||||
public void Test__get_by_key_or_new(String val, int expd_id) {
|
||||
byte[] val_bry = Bry_.new_u8(val);
|
||||
Xoh_xnde_dict_itm actl_itm = grp.Get_by_key_or_new(val_bry, 0, val_bry.length);
|
||||
Tfds.Eq_int(expd_id, actl_itm.Id());
|
||||
Tfds.Eq_bry(val_bry, actl_itm.Val());
|
||||
}
|
||||
public void Test__save(byte[] expd) {
|
||||
grp.Save(bfr);
|
||||
Tfds.Eq_bry(expd, bfr.To_bry_and_clear());
|
||||
}
|
||||
public void Test__load(byte[] dump, Xoh_xnde_dict_itm... itms) {
|
||||
rdr.Init_by_page(Bry_.Empty, dump, dump.length);
|
||||
grp.Load(rdr);
|
||||
int itms_len = itms.length;
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_xnde_dict_itm expd_itm = itms[i];
|
||||
Xoh_xnde_dict_itm actl_itm = grp.Get_by_id_or_null(expd_itm.Id());
|
||||
Tfds.Eq_int(expd_itm.Id(), actl_itm.Id());
|
||||
Tfds.Eq_bry(expd_itm.Val(), actl_itm.Val());
|
||||
}
|
||||
}
|
||||
public Xoh_xnde_dict_itm Make__itm(int id, String val) {return new Xoh_xnde_dict_itm(id, Bry_.new_u8(val));}
|
||||
}
|
||||
class Xoh_xnde_dict__dump_bldr {
|
||||
private final Xoh_hzip_bfr bfr;
|
||||
public Xoh_xnde_dict__dump_bldr(Xoh_hzip_bfr bfr) {this.bfr = bfr;}
|
||||
public Xoh_xnde_dict__dump_bldr Add(int id, String val) {
|
||||
bfr.Add_hzip_int(1, (byte)id);
|
||||
bfr.Add_str_u8(val);
|
||||
bfr.Add_byte_nl();
|
||||
return this;
|
||||
}
|
||||
public byte[] To_bry() {
|
||||
bfr.Add(Xoh_xnde_dict_grp.Bry__stop);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
43
400_xowa/src/gplx/xowa/htmls/doms/Xoh_dom_tst.java
Normal file
43
400_xowa/src/gplx/xowa/htmls/doms/Xoh_dom_tst.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.htmls.doms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_dom_tst {
|
||||
@Test public void Find_atr() {
|
||||
String src = "a <nde0 atr0=\"val0\" atr1=\"val1\"/> b <nde1 atr0=\"val3\" atr1=\"val4\"/> c";
|
||||
tst_Find(src, "nde0", "atr0", "val0", "atr1", "val1"); // match nde0
|
||||
tst_Find(src, "nde1", "atr0", "val3", "atr1", "val4"); // match nde1
|
||||
tst_Find(src, "nde0", "atr0", "val5", "atr1", null); // wrong val
|
||||
tst_Find(src, "nde0", "atr2", "val0", "atr1", null); // wrong key
|
||||
tst_Find(src, "nde2", "atr0", "val0", "atr1", null); // wrong nde
|
||||
}
|
||||
@Test public void Title_by_href() {// PURPOSE: handle content-editable=n and finding file directly for download
|
||||
Title_by_href_tst
|
||||
( "/wiki/File:Bazille,_Fr%C3%A9d%C3%A9ric_%7E_Le_Petit_Jardinier_%28The_Little_Gardener%29,_c1866-67_oil_on_canvas_Museum_of_Fine_Arts,_Houston.jpg"
|
||||
, "<a href=\"lure\" xowa_title=\"wrong\"></a><a href=\"/wiki/File:Bazille,_Fr%C3%A9d%C3%A9ric_%7E_Le_Petit_Jardinier_%28The_Little_Gardener%29,_c1866-67_oil_on_canvas_Museum_of_Fine_Arts,_Houston.jpg\" xowa_title=\"find_me\"></a>"
|
||||
, "find_me"
|
||||
);
|
||||
}
|
||||
private void tst_Find(String src, String where_nde, String where_key, String where_val, String select_key, String expd) {
|
||||
Xoh_find rv = new Xoh_find();
|
||||
byte[] actl = Xoh_dom_.Query_val_by_where(rv, Bry_.new_u8(src), Bry_.new_u8(where_nde), Bry_.new_u8(where_key), Bry_.new_u8(where_val), Bry_.new_u8(select_key), 0);
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
}
|
||||
private void Title_by_href_tst(String href, String html_src, String expd) {
|
||||
String actl = Xoh_dom_.Title_by_href(Bry_.new_u8(href), Bry_.new_u8(html_src));
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
143
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_mgr_tst.java
Normal file
143
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_mgr_tst.java
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xoh_head_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_head_mgr_fxt fxt = new Xoh_head_mgr_fxt();
|
||||
@Test public void Css() {
|
||||
fxt.Mgr().Itm__css().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <style type=\"text/css\">"
|
||||
, " .xowa-missing-category-entry {color: red;}"
|
||||
, " </style>"
|
||||
));
|
||||
}
|
||||
@Test public void Toc() {
|
||||
fxt.Init_msg(Xoh_head_itm__toc.Key_showtoc, "Sh\"ow");
|
||||
fxt.Init_msg(Xoh_head_itm__toc.Key_hidetoc, "Hi'de");
|
||||
fxt.Mgr().Itm__toc().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'toc-enabled' : true,"
|
||||
, " 'mw_hidetoc' : '0',"
|
||||
, " 'showtoc' : 'Sh\"ow',"
|
||||
, " 'hidetoc' : 'Hi\\'de',"
|
||||
, " }"
|
||||
, " </script>"
|
||||
));
|
||||
}
|
||||
@Test public void Globals() {
|
||||
fxt.Init_msg(Xol_msg_itm_.Id_dte_month_name_january, "Jan'uary" ); // add apos to simulate apostrophes in Hebrew months; DATE:2014-07-28
|
||||
fxt.Mgr().Itm__globals().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <link rel=\"stylesheet\" href=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.css\" type='text/css'>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_root_dir = 'file:///mem/xowa/';"
|
||||
, " var xowa_mode_is_server = false;"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'mode_is_gui' : false,"
|
||||
, " 'mode_is_http' : false,"
|
||||
, " 'http-port' : 8080,"
|
||||
, " 'sort-ascending' : 'Sort ascending',"
|
||||
, " 'sort-descending' : 'Sort descending',"
|
||||
, " 'wgContentLanguage' : 'en',"
|
||||
, " 'wgSeparatorTransformTable' : ['.\t.', ',\t,'],"
|
||||
, " 'wgDigitTransformTable' : ['', ''],"
|
||||
, " 'wgDefaultDateFormat' : 'dmy',"
|
||||
, " 'wgMonthNames' : ['', 'Jan\\'uary', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],"
|
||||
, " 'wgMonthNamesShort' : ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],"
|
||||
, " }"
|
||||
, " </script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/exec.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/DOMContentLoaded.js\" type='text/javascript'></script>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " xowa.app.mode = 'cmd';"
|
||||
, " var x_p = xowa.page;"
|
||||
, " x_p.wiki = 'en.wikipedia.org';"
|
||||
, " x_p.ttl = 'Test_page';"
|
||||
, " </script>"
|
||||
));
|
||||
fxt.Init_msg(Xol_msg_itm_.Id_dte_month_name_january, "January" ); // set it back
|
||||
}
|
||||
@Test public void Globals_la() { // PURPOSE: la.gfs only specifies "," not "."; make sure both "." and "," show up, or else null ref error during import; DATE:2014-05-13
|
||||
Xol_lang_itm la_lang = fxt.Wiki().Lang();
|
||||
gplx.xowa.langs.numbers.Xol_transform_mgr separators_mgr = la_lang.Num_mgr().Separators_mgr();
|
||||
separators_mgr.Clear();
|
||||
separators_mgr.Set(gplx.xowa.langs.numbers.Xol_num_mgr.Separators_key__grp, Bry_.new_a7(" "));
|
||||
fxt.Mgr().Itm__globals().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <link rel=\"stylesheet\" href=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.css\" type='text/css'>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_root_dir = 'file:///mem/xowa/';"
|
||||
, " var xowa_mode_is_server = false;"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'mode_is_gui' : false,"
|
||||
, " 'mode_is_http' : false,"
|
||||
, " 'http-port' : 8080,"
|
||||
, " 'sort-ascending' : 'Sort ascending',"
|
||||
, " 'sort-descending' : 'Sort descending',"
|
||||
, " 'wgContentLanguage' : 'en',"
|
||||
, " 'wgSeparatorTransformTable' : ['.\t.', ' \t,']," // note that grp spr (",") is ""
|
||||
, " 'wgDigitTransformTable' : ['', ''],"
|
||||
, " 'wgDefaultDateFormat' : 'dmy',"
|
||||
, " 'wgMonthNames' : ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],"
|
||||
, " 'wgMonthNamesShort' : ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],"
|
||||
, " }"
|
||||
, " </script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/exec.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/DOMContentLoaded.js\" type='text/javascript'></script>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " xowa.app.mode = 'cmd';"
|
||||
, " var x_p = xowa.page;"
|
||||
, " x_p.wiki = 'en.wikipedia.org';"
|
||||
, " x_p.ttl = 'Test_page';"
|
||||
, " </script>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_head_mgr_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private Xoh_head_mgr mgr;
|
||||
private Bry_bfr bfr = Bry_bfr_.Reset(255);
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xoh_head_mgr Mgr() {return mgr;}
|
||||
public Xol_lang_itm Make_lang(String key) {return wiki.Appe().Lang_mgr().Get_by_or_new(Bry_.new_a7(key));}
|
||||
public void Clear() {
|
||||
fxt.Reset();
|
||||
mgr = fxt.Page().Html_data().Head_mgr();
|
||||
wiki = fxt.Wiki();
|
||||
}
|
||||
public void Init_msg(byte[] key, String val) {
|
||||
wiki.Msg_mgr().Get_or_make(key).Atrs_set(Bry_.new_a7(val), false, false);
|
||||
}
|
||||
public void Init_msg(int id, String val) {
|
||||
Xol_msg_itm msg_itm = wiki.Lang().Msg_mgr().Itm_by_id_or_null(id);
|
||||
msg_itm.Atrs_set(Bry_.new_a7(val), false, false);
|
||||
}
|
||||
public void Test_write(String expd) {
|
||||
mgr.Write(bfr, fxt.App(), wiki, fxt.Page());
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
61
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_wtr_tst.java
Normal file
61
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_wtr_tst.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*;
|
||||
public class Xoh_head_wtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_head_wtr_fxt fxt = new Xoh_head_wtr_fxt();
|
||||
@Test public void Globals_none() {
|
||||
Xoh_head_wtr wtr = fxt.Wtr();
|
||||
wtr.Write_js_head_global_bgn();
|
||||
wtr.Write_js_head_global_end();
|
||||
fxt.Test("");
|
||||
}
|
||||
@Test public void Globals_some() {
|
||||
Xoh_head_wtr wtr = fxt.Wtr();
|
||||
wtr.Write_js_head_global_bgn();
|
||||
fxt.Exec_Write_js_global_ini_atr_val("key_1", "val_1");
|
||||
fxt.Exec_Write_js_global_ini_atr_val("key_2", "val_2");
|
||||
fxt.Exec_Write_js_global_ini_atr_val("key_3", "apos_'_1");
|
||||
wtr.Write_js_head_global_end();
|
||||
fxt.Test(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "var xowa_global_values = {"
|
||||
, " 'key_1' : 'val_1',"
|
||||
, " 'key_2' : 'val_2',"
|
||||
, " 'key_3' : 'apos_\\'_1',"
|
||||
, "}"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_head_wtr_fxt {
|
||||
private Bry_bfr bfr = Bry_bfr_.Reset(255);
|
||||
public Xoh_head_wtr Wtr() {return wtr;} private Xoh_head_wtr wtr = new Xoh_head_wtr();
|
||||
public void Clear() {
|
||||
wtr.Init(bfr);
|
||||
}
|
||||
public void Exec_Write_js_global_ini_atr_val(String key, String val) {wtr.Write_js_global_ini_atr_val(Bry_.new_u8(key), Bry_.new_u8(val));}
|
||||
public void Test(String expd) {
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
// public void Init_msg(byte[] key, String val) {
|
||||
// wiki.Msg_mgr().Get_or_make(key).Atrs_set(Bry_.new_a7(val), false, false);
|
||||
// }
|
||||
// public void Test_write(String expd) {
|
||||
// mgr.Write(bfr, fxt.App(), wiki, fxt.Page());
|
||||
// Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
// }
|
||||
}
|
||||
55
400_xowa/src/gplx/xowa/htmls/heads/Xow_fragment_mgr_tst.java
Normal file
55
400_xowa/src/gplx/xowa/htmls/heads/Xow_fragment_mgr_tst.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.numbers.*;
|
||||
public class Xow_fragment_mgr_tst {
|
||||
Xow_fragment_mgr_fxt fxt = new Xow_fragment_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Html_js_edit_toolbar_fmt() {
|
||||
fxt.Test_fragment(Xow_fragment_mgr.Invk_html_js_edit_toolbar, String_.Concat_lines_nl
|
||||
( " var xowa_edit_i18n = {"
|
||||
, " 'bold_tip' : 'Bold text',"
|
||||
, " 'bold_sample' : 'Bold text',"
|
||||
, " 'italic_tip' : 'Italic text',"
|
||||
, " 'italic_sample' : 'Italic text',"
|
||||
, " 'link_tip' : 'Internal link',"
|
||||
, " 'link_sample' : 'Link title',"
|
||||
, " 'headline_tip' : 'Level 2 headline',"
|
||||
, " 'headline_sample' : 'Headline text',"
|
||||
, " 'ulist_tip' : 'Bulleted list',"
|
||||
, " 'ulist_sample' : 'Bulleted list item',"
|
||||
, " 'olist_tip' : 'Numbered list',"
|
||||
, " 'olist_sample' : 'Numbered list item'"
|
||||
, " };"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xow_fragment_mgr_fxt {
|
||||
public void Clear() {
|
||||
if (wiki == null) {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
} private Xowe_wiki wiki;
|
||||
public Xol_lang_itm Make_lang(String key) {return wiki.Appe().Lang_mgr().Get_by_or_new(Bry_.new_a7(key));}
|
||||
public void Test_fragment(String key, String expd) {Test_fragment(wiki.Lang(), key, expd);}
|
||||
public void Test_fragment(Xol_lang_itm lang, String key, String expd) {
|
||||
wiki.Fragment_mgr().Evt_lang_changed(lang);
|
||||
byte[] actl = (byte[])Gfo_invk_.Invk_by_key(wiki.Fragment_mgr(), key);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
66
400_xowa/src/gplx/xowa/htmls/hrefs/Xoh_href_gui_utl_tst.java
Normal file
66
400_xowa/src/gplx/xowa/htmls/hrefs/Xoh_href_gui_utl_tst.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoh_href_gui_utl_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_href_gui_utl_fxt fxt = new Xoh_href_gui_utl_fxt();
|
||||
@Test public void Extract_href__text() {
|
||||
fxt.Test_extract_href("0|" , "");
|
||||
fxt.Test_extract_href("1|selected_text" , "selected_text");
|
||||
fxt.Test_extract_href("2|http://a.org" , "http://a.org");
|
||||
}
|
||||
@Test public void Extract_href__file() {
|
||||
fxt.Test_extract_href("2|file:///site/en.wiktionary.org/wiki/Page_1" , "en.wiktionary.org/wiki/Page_1");
|
||||
fxt.Test_extract_href("2|file:///wiki/Page_2" , "en.wikipedia.org/wiki/Page_2");
|
||||
fxt.Test_extract_href("2|file://#anchor" , "en.wikipedia.org/wiki/Page_0#anchor");
|
||||
}
|
||||
@Test public void Extract_href__internal() {
|
||||
fxt.Test_extract_href("2|/site/en.wiktionary.org/wiki/Page_1" , "en.wiktionary.org/wiki/Page_1");
|
||||
fxt.Test_extract_href("2|/wiki/Page_2" , "en.wikipedia.org/wiki/Page_2");
|
||||
fxt.Test_extract_href("2|#anchor" , "en.wikipedia.org/wiki/Page_0#anchor");
|
||||
}
|
||||
@Test public void Html_window_vpos_parse() {
|
||||
fxt.Test_Html_window_vpos_parse("0|0,1,2", "0", "'0','1','2'");
|
||||
fxt.Test_Html_window_vpos_parse("org.eclipse.swt.SWTException: Permission denied for <file://> to get property Selection.rangeCount", null, null); // check that invalid path doesn't fail; DATE:2014-04-05
|
||||
}
|
||||
@Test public void Standardize_xowa_link() {
|
||||
fxt.Test_standardize_xowa_link("file:///site/en.wikipedia.org/wiki/A" , "/site/en.wikipedia.org/wiki/A");
|
||||
fxt.Test_standardize_xowa_link("file:///wiki/A" , "/wiki/A");
|
||||
fxt.Test_standardize_xowa_link("file://#A" , "#A");
|
||||
}
|
||||
}
|
||||
class Xoh_href_gui_utl_fxt {
|
||||
public void Clear() {
|
||||
cur_wiki = "en.wikipedia.org";
|
||||
cur_page = "Page_0";
|
||||
}
|
||||
public String Cur_wiki() {return cur_wiki;} public Xoh_href_gui_utl_fxt Cur_wiki_(String v) {cur_wiki = v; return this;} private String cur_wiki;
|
||||
public String Cur_page() {return cur_page;} public Xoh_href_gui_utl_fxt Cur_page_(String v) {cur_page = v; return this;} private String cur_page;
|
||||
public void Test_extract_href(String text_str, String expd) {
|
||||
Tfds.Eq(expd, Xoh_href_gui_utl.Html_extract_text(cur_wiki, cur_page, text_str));
|
||||
}
|
||||
private String_obj_ref scroll_top = String_obj_ref.null_(), node_path = String_obj_ref.null_();
|
||||
public void Test_Html_window_vpos_parse(String raw, String expd_scroll_top, String expd_node_path) {
|
||||
scroll_top.Val_null_(); node_path.Val_null_();
|
||||
Xog_html_itm.Html_window_vpos_parse(raw, scroll_top, node_path);
|
||||
Tfds.Eq(expd_scroll_top, scroll_top.Val(), expd_scroll_top);
|
||||
Tfds.Eq(expd_node_path, node_path.Val(), expd_node_path);
|
||||
}
|
||||
public void Test_standardize_xowa_link(String raw, String expd) {
|
||||
Tfds.Eq_str(expd, Xoh_href_gui_utl.Standardize_xowa_link(raw), "standardize");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
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.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.apps.urls.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_href_parser__basic__tst {
|
||||
private final Xoh_href_parser_fxt fxt = new Xoh_href_parser_fxt();
|
||||
@Test public void Site__basic() {
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/A").Test__tid(Xoa_url_.Tid_page).Test__to_str("en.wikipedia.org/wiki/A").Test__page("A");
|
||||
}
|
||||
@Test public void Site__ns_case() {
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/file:A").Test__page("File:A");
|
||||
}
|
||||
@Test public void Site__main_page() {
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/").Test__page("Main_Page").Test__page_is_main_y();
|
||||
}
|
||||
@Test public void Site__anch() {
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/A#b_c").Test__page("A").Test__anch("b_c");
|
||||
}
|
||||
@Test public void Site__qarg() {
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/A?action=edit").Test__page("A").Test__qargs("?action=edit");
|
||||
}
|
||||
@Test public void Site__invalid_ttl_shouldnt_fail() { // PURPOSE: invalid title shouldn't fail; EX: A{{B}} is invalid (b/c of braces);
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/A{{B}}").Test__page("");
|
||||
}
|
||||
@Test public void Site__xwiki_cases_correctly() { // PURPOSE: xwiki links should use case_match of xwiki (en.wiktionary.org) not cur_wiki (en.wikipedia.org); EX:w:Alphabet
|
||||
Xowe_wiki en_wiktionary_org = fxt.Prep_create_wiki("en.wiktionary.org");
|
||||
en_wiktionary_org.Ns_mgr().Ns_main().Case_match_(Xow_ns_case_.Tid__all);
|
||||
fxt.Prep_add_xwiki_to_user("en.wiktionary.org", "en.wiktionary.org");
|
||||
fxt.Exec__parse_as_url("/site/en.wiktionary.org/wiki/alphabet");
|
||||
fxt.Test__to_str("en.wiktionary.org/wiki/alphabet").Test__page("alphabet");
|
||||
}
|
||||
@Test public void Site__xwiki_compound() { // PURPOSE: [[[w:wikt:]] not handled; DATE:2013-07-25
|
||||
fxt.Prep_add_xwiki_to_wiki("wikt", "en.wiktionary.org");
|
||||
fxt.Exec__parse_as_url("/site/en.wikipedia.org/wiki/wikt:")
|
||||
.Test__tid(Xoa_url_.Tid_page)
|
||||
.Test__page("Main_Page")
|
||||
.Test__to_str("en.wiktionary.org/wiki/Main_Page")
|
||||
;
|
||||
}
|
||||
// @Test public void Vnt() {
|
||||
// Xowe_wiki wiki = fxt.Wiki();
|
||||
// fxt.Prep_add_xwiki_to_user("zh.wikipedia.org");
|
||||
// wiki.Lang().Vnt_mgr().Enabled_(true);
|
||||
// wiki.Lang().Vnt_mgr().Vnt_grp().Add(new gplx.xowa.langs.vnts.Vnt_mnu_itm(Bry_.new_a7("zh-hans"), Bry_.new_a7("zh-hant")));
|
||||
// fxt.Exec__parse_as_url("/site/zh.wikipedia.org/zh-hant/A").Test__page("A").Chk_vnt("zh-hant");
|
||||
// }
|
||||
@Test public void Http__basic() {
|
||||
fxt.Exec__parse_as_url("http://a.org/b").Test__tid(Xoa_url_.Tid_inet);
|
||||
}
|
||||
@Test public void Prot__ftp() { // PURPOSE: check that urls with form of "ftp://" return back Tid_ftp; DATE:2014-04-25
|
||||
fxt.Exec__parse_as_url("ftp://a.org").Test__tid(Xoa_url_.Tid_inet);
|
||||
}
|
||||
@Test public void File__basic() {
|
||||
fxt.Exec__parse_as_url("file:///C/xowa/file/a.png").Test__tid(Xoa_url_.Tid_file);
|
||||
}
|
||||
@Test public void Anchor__basic() {
|
||||
fxt.Exec__parse_as_url("#a").Test__tid(Xoa_url_.Tid_anch).Test__to_str("en.wikipedia.org/wiki/Page 1#a").Test__anch("a");
|
||||
}
|
||||
@Test public void Xcmd__basic() {
|
||||
fxt.Exec__parse_as_url("/xcmd/page_edit").Test__tid(Xoa_url_.Tid_xcmd).Test__page("page_edit");
|
||||
}
|
||||
@Test public void Xowa__basic() {
|
||||
fxt.Exec__parse_as_url("xowa-cmd:a%22b*c").Test__tid(Xoa_url_.Tid_xcmd).Test__page("a\"b*c");
|
||||
}
|
||||
// COMMENTED: this seems wrong; [//wikisource.org] should go to https://wikisource.org not https://en.wikisource.org; both sites are different; DATE:2015-08-02
|
||||
// @Test public void Site__user_wiki() {// PURPOSE: outlier for wikisource.org which is alias to en.wikisource.org; alias added in user_wiki; EX: [//wikisource.org a]; in browser, automatically goes to http://wikisource.org; in xowa, should go to /site/en.wikisource.org
|
||||
// fxt.Prep_xwiki(fxt.App().User().Wikii(), "en_wiki_alias", "en.wikipedia.org", null);
|
||||
// fxt.Exec__parse_as_url("/site/en_wiki_alias/wiki/")
|
||||
// .Test__tid(Xoa_url_.Tid_page)
|
||||
// .Test__page("Main_Page")
|
||||
// .Test__to_str("en.wikipedia.org/wiki/Main_Page")
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
class Xoh_href_parser_fxt extends Xow_url_parser_fxt { private final Xoh_href_parser href_parser = new Xoh_href_parser();
|
||||
public Xoh_href_parser_fxt Exec__parse_as_url(String raw) {
|
||||
href_parser.Parse_as_url(actl_url, Bry_.new_u8(raw), cur_wiki, Bry__page_1);
|
||||
return this;
|
||||
}
|
||||
private static final byte[] Bry__page_1 = Bry_.new_a7("Page 1");
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.apps.urls.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_href_parser__qargs__tst {
|
||||
private final Xoh_href_parser_fxt fxt = new Xoh_href_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Exec__parse_as_url("/wiki/A?k1=v1&k2=v2");
|
||||
fxt.Test__page("A");
|
||||
fxt.Test__to_str("en.wikipedia.org/wiki/A?k1=v1&k2=v2");
|
||||
}
|
||||
@Test public void Anch() { // PURPOSE.fix: anchor was being placed before qargs; DATE:2016-10-08
|
||||
fxt.Exec__parse_as_url("/wiki/Category:A?pagefrom=A#mw-pages");
|
||||
fxt.Test__page("Category:A");
|
||||
fxt.Test__to_str("en.wikipedia.org/wiki/Category:A?pagefrom=A#mw-pages"); // was Category:A#mw-page?pagefrom=A
|
||||
}
|
||||
// FUTURE: qargs should be unencoded by default; decoded on request
|
||||
@Test public void Encoded() { // PURPOSE.fix: do not use decoded String; DATE:2016-10-08
|
||||
fxt.Exec__parse_as_url("/wiki/Category:A?pagefrom=A%26B#mw-pages");
|
||||
fxt.Test__page("Category:A");
|
||||
fxt.Test__qargs("?pagefrom=A&B");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.apps.urls.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_href_parser__wiki__tst {
|
||||
private final Xoh_href_parser_fxt fxt = new Xoh_href_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Exec__parse_as_url("/wiki/A").Test__tid(Xoa_url_.Tid_page).Test__to_str("en.wikipedia.org/wiki/A").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Page__w_question() {
|
||||
fxt.Exec__parse_as_url("/wiki/%3F").Test__page("?");
|
||||
}
|
||||
@Test public void Qarg() {
|
||||
fxt.Exec__parse_as_url("/wiki/A?action=edit").Test__page("A").Test__qargs("?action=edit").Test__to_str("en.wikipedia.org/wiki/A?action=edit");
|
||||
}
|
||||
@Test public void Qarg__w_question() {
|
||||
fxt.Exec__parse_as_url("/wiki/A%3F?action=edit").Test__page("A?").Test__qargs("?action=edit");
|
||||
}
|
||||
@Test public void Anchor() {
|
||||
fxt.Exec__parse_as_url("/wiki/A#b").Test__to_str("en.wikipedia.org/wiki/A#b").Test__anch("b");
|
||||
}
|
||||
@Test public void Xwiki__only() {
|
||||
fxt.Prep_add_xwiki_to_wiki("c", "commons.wikimedia.org");
|
||||
fxt.Exec__parse_as_url("/wiki/c:").Test__page_is_main_y().Test__page("Main_Page").Test__to_str("commons.wikimedia.org/wiki/Main_Page");
|
||||
}
|
||||
@Test public void Encoded() {
|
||||
fxt.Exec__parse_as_url("/wiki/A%22b%22c").Test__page("A\"b\"c");
|
||||
}
|
||||
@Test public void Triple_slash() { // PURPOSE: handle triple slashes; PAGE:esolangs.org/wiki/Language_list; DATE:2015-11-14
|
||||
fxt.Exec__parse_as_url("/wiki////").Test__to_str("en.wikipedia.org/wiki////").Test__wiki("en.wikipedia.org").Test__page("///");
|
||||
}
|
||||
@Test public void Http() { // PURPOSE: variant of triple slashes; DATE:2015-11-14
|
||||
fxt.Exec__parse_as_url("/wiki/http://a").Test__to_str("en.wikipedia.org/wiki/Http://a").Test__wiki("en.wikipedia.org").Test__page("Http://a");
|
||||
}
|
||||
}
|
||||
57
400_xowa/src/gplx/xowa/htmls/hrefs/Xoh_href_wtr_tst.java
Normal file
57
400_xowa/src/gplx/xowa/htmls/hrefs/Xoh_href_wtr_tst.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.net.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_href_wtr_tst {
|
||||
private final Xoh_href_wtr_fxt fxt = new Xoh_href_wtr_fxt();
|
||||
@Test public void Xwiki_enc() {fxt.Test_build("wikt:abc?d" , "/site/en.wiktionary.org/wiki/abc%3Fd");}
|
||||
@Test public void Page_quote() {fxt.Test_build("a\"b\"c" , "/wiki/A%22b%22c");}
|
||||
@Test public void Page() {fxt.Test_build("abc" , "/wiki/Abc");}
|
||||
@Test public void Page_ns() {fxt.Test_build("Image:A.png" , "/wiki/Image:A.png");}
|
||||
@Test public void Anchor() {fxt.Test_build("#abc" , "#abc");}
|
||||
@Test public void Page_anchor() {fxt.Test_build("Abc#def" , "/wiki/Abc#def");}
|
||||
@Test public void Xwiki() {fxt.Test_build("wikt:abc" , "/site/en.wiktionary.org/wiki/abc");} // NOTE: "abc" not capitalized, b/c other wiki's case sensitivity is not known; this emulates WP's behavior
|
||||
@Test public void Xwiki_2() {fxt.Test_build("wikt:Special:Search/a" , "/site/en.wiktionary.org/wiki/Special:Search/a");}
|
||||
@Test public void Category() {fxt.Test_build("Category:abc" , "/wiki/Category:Abc");}
|
||||
@Test public void Xwiki_wikimedia_mail() { // PURPOSE: DATE:2015-04-22
|
||||
fxt.Prep_xwiki_by_many("0|mail|https://lists.wikimedia.org/mailman/listinfo/~{0}|Wikitech Mailing List");
|
||||
fxt.Test_build("mail:A" , "https://lists.wikimedia.org/mailman/listinfo/A");
|
||||
}
|
||||
}
|
||||
class Xoh_href_wtr_fxt {
|
||||
private final Xowe_wiki wiki;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
private final Xoh_href_wtr href_wtr = new Xoh_href_wtr();
|
||||
public Xoh_href_wtr_fxt() {
|
||||
this.app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_a7("1|wikt|en.wiktionary.org"));
|
||||
app.Usere().Wiki().Xwiki_mgr().Add_by_csv(Bry_.new_a7("1|en.wiktionary.org|en.wiktionary.org"));
|
||||
}
|
||||
public Xoae_app App() {return app;} private final Xoae_app app;
|
||||
public Xoh_href_wtr_fxt Prep_wiki_cs(String domain) {
|
||||
Xow_wiki wiki = app.Wiki_mgr().Get_by_or_make_init_n(Bry_.new_u8(domain));
|
||||
wiki.Ns_mgr().Ns_main().Case_match_(Xow_ns_case_.Tid__all);
|
||||
return this;
|
||||
}
|
||||
public Xoh_href_wtr_fxt Prep_xwiki_by_many(String raw) {wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(raw)); return this;} // need to add to wiki's xwiki_mgr for ttl_parse
|
||||
public void Test_build(String raw, String expd) {
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(raw));
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, wiki.Domain_bry(), ttl);
|
||||
Tfds.Eq(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
44
400_xowa/src/gplx/xowa/htmls/js/Xoh_js_cbk_tst.java
Normal file
44
400_xowa/src/gplx/xowa/htmls/js/Xoh_js_cbk_tst.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.xtns.wbases.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xoh_js_cbk_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_js_cbk_fxt fxt = new Xoh_js_cbk_fxt();
|
||||
@Test public void Get_title() {
|
||||
fxt.Fxt().Init_page_create("exists");
|
||||
fxt.Test_get_title("exists", "1" , "0" , Int_.To_str(Int_.Min_value), "Exists", "false", "0001-01-01 00:00:00", "0");
|
||||
fxt.Test_get_title("absent", "0", "-1", Int_.To_str(Int_.Min_value), null , "false", "0001-01-01 00:00:00", "0");
|
||||
}
|
||||
}
|
||||
class Xoh_js_cbk_fxt {
|
||||
public void Clear() {
|
||||
fxt = new Xop_fxt();
|
||||
Xoa_app_fxt.Init_gui(fxt.App(), fxt.Wiki());
|
||||
} private Xop_fxt fxt;
|
||||
public Xop_fxt Fxt() {return fxt;}
|
||||
public void Test_get_title(String ttl, Object... expd) {
|
||||
Xoae_app app = fxt.App();
|
||||
Xowe_wiki wiki = fxt.Wiki();
|
||||
Xoae_page page = Xoae_page.New_test(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7("mock_page")));
|
||||
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab();
|
||||
tab.Page_(page);
|
||||
Xoh_js_cbk exec = tab.Html_itm().Js_cbk();
|
||||
GfoMsg msg = GfoMsg_.new_cast_(Xoh_js_cbk.Invk_get_titles_meta).Add("ttl", ttl);
|
||||
String[][] actl = (String[][])Gfo_invk_.Invk_by_msg(exec, Xoh_js_cbk.Invk_get_titles_meta, msg);
|
||||
Tfds.Eq_ary_str(expd, actl[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.langs.jsons.*; import gplx.xowa.xtns.wbases.*;
|
||||
public class Xoh_js_cbk_wdata_labels_tst {
|
||||
@Before public void init() {fxt.Init();} private final Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init__docs__add(fxt.Wdoc_bldr("q1").Add_label("en", "en_q1").Xto_wdoc());
|
||||
fxt.Init__docs__add(fxt.Wdoc_bldr("q2").Add_label("en", "en_q2").Xto_wdoc());
|
||||
fxt.Init__docs__add(fxt.Wdoc_bldr("Property:P1").Add_label("en", "en_property_p1").Xto_wdoc());
|
||||
Tst_wikidata_label_get(String_.Ary("en", "q1", "q2", "Property:P1"), String_.Ary("en_q1", "en_q2", "en_property_p1"));
|
||||
}
|
||||
@Test public void Outliers() {
|
||||
fxt.Init__docs__add(fxt.Wdoc_bldr("q1").Add_label("en", "en_q1").Add_label("de", "de_q1").Xto_wdoc());
|
||||
Tst_wikidata_label_get(String_.Ary("fr", "q1"), String_.Ary((String)null));
|
||||
Tst_wikidata_label_get(String_.Ary("de", "q1"), String_.Ary("de_q1"));
|
||||
Tst_wikidata_label_get(String_.Ary("xowa_title", "q1"), String_.Ary("q1"));
|
||||
Tst_wikidata_label_get(String_.Ary("xowa_ui_lang", "q1"), String_.Ary("en_q1"));
|
||||
Tst_wikidata_label_get(String_.Ary("fr;de", "q1"), String_.Ary("de_q1"));
|
||||
}
|
||||
@Test public void Escaped() { // PURPOSE: \t should be escaped; EX:wd.q:2; DATE:2014-04-23
|
||||
Wdata_doc d = doc_("q1", String_.Concat_lines_nl
|
||||
( "{ 'entity':['item',1]"
|
||||
, ", 'label':"
|
||||
, " { 'en':'\\ta'" // NOTE: json literally has "\t", not (char)8
|
||||
, " }"
|
||||
, "}"
|
||||
));
|
||||
fxt.Init__docs__add(d);
|
||||
Tst_wikidata_label_get(String_.Ary("en", "q1"), String_.Ary("\ta"));
|
||||
}
|
||||
private Wdata_doc doc_(String qid, String src) {
|
||||
Json_doc jdoc = fxt.Make_json(src);
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Wdata_doc rv = new Wdata_doc(Bry_.new_a7(qid), app.Wiki_mgr().Wdata_mgr(), jdoc);
|
||||
return rv;
|
||||
}
|
||||
private void Tst_wikidata_label_get(String[] args, String[] expd) {
|
||||
Xoa_app_fxt.Init_gui(fxt.App(), fxt.Wiki());
|
||||
Xoh_js_cbk exec = fxt.App().Gui_mgr().Browser_win().Active_html_itm().Js_cbk();
|
||||
GfoMsg msg = GfoMsg_.new_cast_(Xoh_js_cbk.Invk_wikidata_get_label);
|
||||
int args_len = args.length;
|
||||
for (int i = 0; i < args_len; i++)
|
||||
msg.Add("v", args[i]);
|
||||
String[] actl = (String[])Gfo_invk_.Invk_by_msg(exec, Xoh_js_cbk.Invk_wikidata_get_label, msg);
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
}
|
||||
}
|
||||
40
400_xowa/src/gplx/xowa/htmls/js/Xoh_js_cleaner_tst.java
Normal file
40
400_xowa/src/gplx/xowa/htmls/js/Xoh_js_cleaner_tst.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_js_cleaner_tst {
|
||||
@Before public void init() {fxt.Init();} private Xoh_js_cleaner_fxt fxt = new Xoh_js_cleaner_fxt();
|
||||
@Test public void Basic() {fxt.Test_clean("<i>a</i>", "<i>a</i>");}
|
||||
@Test public void Js_nde() {fxt.Test_clean("a<script>b</script>c", "a<script>b</script>c");}
|
||||
@Test public void Js_atr() {fxt.Test_clean("a<span onmouseover = 'fail'>b</span>c", "a<span onMouseOver= 'fail'>b</span>c");}
|
||||
@Test public void Js_atr_noop() {fxt.Test_clean("a onmouseover b", "a onmouseover b");}
|
||||
@Test public void Js_atr_noop_regionSelect() {fxt.Test_clean("regionSelect=2", "regionSelect=2");}
|
||||
}
|
||||
class Xoh_js_cleaner_fxt {
|
||||
public void Init() {
|
||||
if (mgr == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
mgr = wiki.Html_mgr().Js_cleaner();
|
||||
}
|
||||
} private Xoae_app app; Xowe_wiki wiki; Xoh_js_cleaner mgr;
|
||||
public void Test_clean(String raw_str, String expd) {
|
||||
byte[] raw = Bry_.new_a7(raw_str);
|
||||
byte[] actl = mgr.Clean(wiki, raw, 0, raw.length);
|
||||
if (actl == null) actl = raw;
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
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.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xow_popup_anchor_finder__hdr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xop_popup_hdr_finder_fxt fxt = new Xop_popup_hdr_finder_fxt();
|
||||
@Test public void Basic() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "==b1=="
|
||||
, "c"
|
||||
);
|
||||
fxt.Test_find(src_str, "b1", 1);
|
||||
fxt.Test_find_not(src_str, "b");
|
||||
fxt.Test_find_not(src_str, "a");
|
||||
}
|
||||
@Test public void Mid() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "==b=="
|
||||
, "c"
|
||||
, "==d=="
|
||||
, "e"
|
||||
);
|
||||
fxt.Test_find(src_str, "d", 9);
|
||||
}
|
||||
@Test public void Eos() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "==b=="
|
||||
);
|
||||
fxt.Test_find(src_str, "b", 1);
|
||||
}
|
||||
@Test public void Bos() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "==a=="
|
||||
, "b"
|
||||
);
|
||||
fxt.Test_find(src_str, "a", -1);
|
||||
}
|
||||
@Test public void Trim() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "== b =="
|
||||
, "c"
|
||||
);
|
||||
fxt.Test_find(src_str, "b", 1);
|
||||
}
|
||||
@Test public void Ws() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "== b c =="
|
||||
, "d"
|
||||
);
|
||||
fxt.Test_find(src_str, "b c", 1);
|
||||
}
|
||||
}
|
||||
class Xop_popup_hdr_finder_fxt {
|
||||
private Xow_popup_anchor_finder finder = new Xow_popup_anchor_finder();
|
||||
public void Clear() {
|
||||
}
|
||||
public void Test_find_not(String src_str, String hdr_str) {Test_find(src_str, hdr_str, Bry_find_.Not_found);}
|
||||
public void Test_find(String src_str, String hdr_str, int expd) {
|
||||
byte[] src = Bry_.new_u8(src_str);
|
||||
byte[] hdr = Bry_.new_u8(hdr_str);
|
||||
Tfds.Eq(expd, finder.Find(src, src.length, hdr, 0), hdr_str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xow_popup_anchor_finder__id_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xop_popup_hdr_finder_fxt fxt = new Xop_popup_hdr_finder_fxt();
|
||||
@Test public void Basic() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "b"
|
||||
, "<span id=\"a\"/>"
|
||||
, "c"
|
||||
);
|
||||
fxt.Test_find(src_str, "a", 1);
|
||||
fxt.Test_find_not(src_str, "b");
|
||||
fxt.Test_find_not(src_str, "c");
|
||||
}
|
||||
@Test public void Ws() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "b"
|
||||
, "<span id = \"a\"/>"
|
||||
, "c"
|
||||
);
|
||||
fxt.Test_find(src_str, "a", 1);
|
||||
}
|
||||
@Test public void Fail() {
|
||||
String src_str = String_.Concat_lines_nl_skip_last
|
||||
( "b"
|
||||
, "<span xid = \"a\"/>"
|
||||
, "c"
|
||||
);
|
||||
fxt.Test_find_not(src_str, "a");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
/*
|
||||
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.htmls.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*;
|
||||
import org.junit.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xow_popup_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xop_popup_parser_fxt fxt = new Xop_popup_parser_fxt();
|
||||
@Test public void Text_chars_one() {
|
||||
fxt.Test_parse
|
||||
( "a b c d", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a b"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Text_chars_many() { // PURPOSE: text.read_spans_scan
|
||||
fxt.Test_parse
|
||||
( "abc def ghi", String_.Concat_lines_nl_skip_last
|
||||
( "<p>abc def"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Text_chars_bound() {// PURPOSE: text.word_spans_scan
|
||||
fxt.Test_parse
|
||||
( "abcde fghij k l", String_.Concat_lines_nl_skip_last
|
||||
( "<p>abcde fghij"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Apos() {
|
||||
fxt.Test_parse
|
||||
( "'''ab''' ''c'' de", String_.Concat_lines_nl_skip_last
|
||||
( "<p><b>ab</b> <i>c"
|
||||
, "</p>"
|
||||
, "</i>"
|
||||
));
|
||||
}
|
||||
@Test public void Lnki() {
|
||||
fxt.Test_parse("a [[b|c d e]] f"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a <a href=\"/site/en.wiki/wiki/B\">c d e</a>"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Lnke_brack() { // PURPOSE: count lnke caption words; DATE:2014-06-20
|
||||
fxt.Init_tmpl_read_len_(32).Init_word_needed_(5).Test_parse
|
||||
( "a [http://b.org b c] d e f g", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a b c d e"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Lnke_text() { // PURPOSE: count entire lnke as one word
|
||||
fxt.Init_tmpl_read_len_(32).Init_word_needed_(5).Test_parse
|
||||
( "a http://b.org c d e f g", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a <a href=\"http://b.org\" rel=\"nofollow\" class=\"external free\">http://b.org</a> c d e"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Lnke_dangling() { // PURPOSE: handle dangling lnke; DATE:2014-06-20
|
||||
fxt.Test_parse
|
||||
( "a [http://b.org c d] e f g", String_.Concat_lines_nl_skip_last // NOTE: scan_len = 4, so 1st pass will be "a [h"
|
||||
( "<p>a c d" // NOTE: (a) lnke correctly parsed, else would see "[" or "http"; (b) "c d" counts as 1 word
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Hdr() {
|
||||
fxt.Test_parse
|
||||
( "a\n===b===\n c", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<h3>b</h3>"
|
||||
));
|
||||
}
|
||||
@Test public void Hdr_one_word() { // PURPOSE: hdr.entire_tkn_counts_as_one_word
|
||||
fxt.Test_parse
|
||||
( "===a b c===\nd", String_.Concat_lines_nl_skip_last
|
||||
( "<h3>a b c</h3>"
|
||||
, ""
|
||||
, "<p>d"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Hdr_para() { // PURPOSE: hdr.para; handle para mode and hdr (para causes trailing \n to be para, not \n); PAGE:en.w:Flavius_Valerius_Severus DATE:2014-06-17
|
||||
fxt.Init_para_enabled_(true).Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "a"
|
||||
, ""
|
||||
, "==b=="
|
||||
, "c"
|
||||
, ""
|
||||
, "d"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<h2>b</h2>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void List() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "*b"
|
||||
, "c"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<ul>"
|
||||
, " <li>b"
|
||||
, " </li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Xnde_pair() {
|
||||
fxt.Test_parse
|
||||
( "<span id='a'>b</span>"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p><span id='a'>b</span>"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Xnde_inline() {
|
||||
fxt.Test_parse
|
||||
( "<span id='a'/>"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p><span id='a'></span>"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Xnde_br() { // PURPOSE: check that br is added correctly; PAGE:en.q:Earth; DATE:2014-06-30
|
||||
fxt.Init_word_needed_(3).Test_parse
|
||||
( "a<br>b<br/>"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a<br>b<br/>"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Xnde_math() { // PURPOSE: <math> should be treated as one word; PAGE:en.w:System_of_polynomial_equations; DATE:2014-07-01
|
||||
fxt .Init_word_needed_(5) // need to read more words to pick up 1st word after header
|
||||
.Init_read_til_stop_bwd_(2) // need to do read_bwd to start counting before ==e== into <math> node
|
||||
.Test_parse
|
||||
( "a <math>b c d</math> \n==e==\nf g h i"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a <span id='xowa_math_txt_0'>b c d</span> (e)" // used to fail as <p>a <math>b c d (e)
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_tblw() {// also checks for tbl spanning multiple blocks; PAGE:en.w:Stratosphere; DATE:2014-06-17
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a "
|
||||
, "{|"
|
||||
, "|-"
|
||||
, "|b"
|
||||
, "|} c"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_tblw_nested() {// PAGE:en.w:Cosmoloyg; DATE:2014-06-17
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "<span>a"
|
||||
, "{|"
|
||||
, "|-"
|
||||
, "|b"
|
||||
, "|}"
|
||||
, "</span>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p><span>a"
|
||||
, "</span>"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_tblx() {
|
||||
fxt.Test_parse
|
||||
( "a <table><tr><td>b</td></tr></table> c"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_ref() {
|
||||
fxt.Test_parse
|
||||
( "a <ref>b</ref> c"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_div() {
|
||||
fxt.Test_parse
|
||||
( "a <div>b</div> c"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_space_bos() { // pre. ignore spaces, else pre; PAGE:en.w:Volcano; en.w:War_elephant; DATE:2014-06-17
|
||||
fxt.Test_parse
|
||||
( "<div>a</div> b c d" // spaces before "b" are ignored
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>b c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_space_nl() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "<div>b</div> c" // space before "c" is ignored
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_nl_bos() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, ""
|
||||
, "a"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_nl_multiple() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, ""
|
||||
, ""
|
||||
, "" // ignored
|
||||
, "b"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<p>b"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_nl_hdr() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, ""
|
||||
, ""
|
||||
, "" // ignored
|
||||
, "==b=="
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<h2>b</h2>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_lnki_file() {
|
||||
fxt.Test_parse
|
||||
( "a [[File:b.png|thumb]] c"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_gallery() {
|
||||
fxt.Test_parse
|
||||
( "a <gallery>File:B.png|c</gallery> d"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a d"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ignore_xnde() {
|
||||
fxt.Test_parse
|
||||
( "a <span id='coordinates'>b</span> c"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a c"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Dangling() { // make sure dangling nodes don't fail
|
||||
fxt.Test_parse
|
||||
( "<i>a"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p><i>a</i>"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void End_early_dangling() { // PURPOSE: dangling tkn is too long; end early; PAGE:en.w:List_of_air_forces; DATE:2014-06-18
|
||||
fxt.Init_tmpl_read_max_(8).Test_parse
|
||||
( "a [[File:Test.png]] k"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a "
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ellipsis_() {
|
||||
fxt.Init_ellipsis_("...").Test_parse
|
||||
( "a b c d"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a b..."
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Test_parse // no ellipsis: entire extract
|
||||
( "a"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Test_parse // no ellipsis: entire extract multiple reads
|
||||
( "a <div>b</div>"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a "
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Ns_allowed() {
|
||||
fxt.Test_ns_allowed("Help" , Xow_ns_.Tid__help);
|
||||
fxt.Test_ns_allowed("(Main)" , Xow_ns_.Tid__main);
|
||||
fxt.Test_ns_allowed("" );
|
||||
fxt.Test_ns_allowed("(Main)|Help" , Xow_ns_.Tid__main, Xow_ns_.Tid__help);
|
||||
}
|
||||
@Test public void Read_til_stop_fwd() {
|
||||
fxt.Init_word_needed_(2).Init_read_til_stop_fwd_(2) // read fwd found hdr
|
||||
.Test_parse("a b c\n==d==", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a b c (d)"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Init_word_needed_(2).Init_read_til_stop_fwd_(2) // read fwd did not find hdr; reset back to min
|
||||
.Test_parse("a b c d", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a b"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Read_til_stop_bwd() {
|
||||
fxt.Init_word_needed_(8).Init_read_til_stop_bwd_(4) // read bwd found hdr
|
||||
.Test_parse("01 02 03 04 05\n==06==\n07 08 09 10 11 12 13 14 15 16", String_.Concat_lines_nl_skip_last
|
||||
( "<p>01 02 03 04 05 (06)"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Init_tmpl_read_len_(40).Init_word_needed_(5).Init_read_til_stop_bwd_(3) // read bwd at eos should not return "next_sect"; DATE:2014-07-01
|
||||
.Test_parse("01 02 03 \n==04==\n", String_.Concat_lines_nl_skip_last
|
||||
( "<p>01 02 03 "
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<h2>04</h2>"
|
||||
));
|
||||
}
|
||||
@Test public void Stop_if_hdr_after() {
|
||||
fxt.Init_word_needed_(5).Init_stop_if_hdr_after_(1)
|
||||
.Test_parse("a b\n==c==\nd e", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a b"
|
||||
, "</p>"
|
||||
, ""
|
||||
, "<h2>c</h2>"
|
||||
));
|
||||
}
|
||||
@Test public void Anchor() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a b c d"
|
||||
, ""
|
||||
, "== e =="
|
||||
, "f g h i"
|
||||
), "#e", String_.Concat_lines_nl_skip_last
|
||||
( "<h2> e </h2>"
|
||||
, ""
|
||||
, "<p>f"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Anchor_underline() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a b c d"
|
||||
, ""
|
||||
, "== e f =="
|
||||
, "g h i"
|
||||
), "#e_f", String_.Concat_lines_nl_skip_last
|
||||
( "<h2> e f </h2>"
|
||||
, ""
|
||||
, "<p>g"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Tmpl_tkn_max() {
|
||||
fxt.Init_tmpl_tkn_max_(5).Init_page("Template:A", "a"); // eval
|
||||
fxt.Test_parse
|
||||
( "{{A}}"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Test_parse("{{A|b|c}}" , ""); // skip; NOTE: output should be blank, not <p>\n</p>; PAGE:en.w:List_of_countries_by_GDP_(PPP); DATE:2014-07-01
|
||||
}
|
||||
@Test public void Tmpl_tkn_max__comment_and_tblw() { // PURPOSE: garbled popup when tmpl_tkn_max is set and comments in front of tblw; PAGE:en.w:Gwynedd; DATE:2014-07-01
|
||||
fxt .Init_tmpl_tkn_max_(5) // set tmpl_tkn_max
|
||||
.Init_tmpl_read_len_(20) // set read_len to 20 (must read entire "<!---->\n{|" at once
|
||||
.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "{{A|b}}"
|
||||
, "{{A|b}}"
|
||||
, "{|"
|
||||
, "|-"
|
||||
, "|a b c d"
|
||||
, "|}"
|
||||
), ""); // should be blank, not <table>]
|
||||
}
|
||||
@Test public void Tmpl_tkn_max__apos() { // PURPOSE: handle apos around skipped tmpl token; PAGE:en.w:Somalia; DATE:2014-07-02
|
||||
fxt.Init_tmpl_tkn_max_(5).Test_parse("a''{{A|b}}''b", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a<i> </i>b"
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Notoc_and_para_issue() { // PURPOSE.fix: issue with "\s__NOTOC__" and "a\n"b; PAGE:en.w:Spain; DATE:2014-07-05
|
||||
fxt.Init_word_needed_(3).Init_notoc_(" __NOTOC__").Test_parse("a\nb", String_.Concat_lines_nl_skip_last
|
||||
( "<p>a" // was <p>a</p>b
|
||||
, "b "
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Test_Assert_at_end() {
|
||||
fxt.Test_Assert_at_end("a" , "a\n"); // add one
|
||||
fxt.Test_Assert_at_end("a\n" , "a\n"); // noop
|
||||
fxt.Test_Assert_at_end("a\n\n\n" , "a\n"); // remove til one
|
||||
fxt.Test_Assert_at_end("" , ""); // empty check
|
||||
}
|
||||
@Test public void Skip_to_end__tblw() { // PURPOSE: skip to end of tblw; PAGE:en.w:List_of_countries_and_dependencies_by_area; DATE:2014-07-19
|
||||
fxt.Init_tmpl_read_len_(4).Test_parse
|
||||
( String_.Concat_lines_nl_skip_last
|
||||
( "a"
|
||||
, "{|"
|
||||
, "|-"
|
||||
, "|b"
|
||||
, "|c"
|
||||
, "|d"
|
||||
, "|}"
|
||||
)
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<p>a"
|
||||
, "</p>"
|
||||
));
|
||||
fxt.Expd_tmpl_loop_count(2);
|
||||
}
|
||||
}
|
||||
class Xop_popup_parser_fxt {
|
||||
private Xow_popup_parser parser; private Xowe_wiki wiki;
|
||||
private int word_min = 2;
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app, "en.wiki");
|
||||
parser = wiki.Html_mgr().Head_mgr().Popup_mgr().Parser();
|
||||
parser.Init_by_wiki(wiki);
|
||||
parser.Cfg().Tmpl_read_len_(4);
|
||||
parser.Cfg().Tmpl_read_max_(32 * Io_mgr.Len_kb);
|
||||
parser.Cfg().Ellipsis_(Bry_.Empty);
|
||||
parser.Cfg().Notoc_(Bry_.Empty);
|
||||
parser.Cfg().Show_all_if_less_than_(-1);
|
||||
parser.Cfg().Read_til_stop_fwd_(-1);
|
||||
parser.Cfg().Read_til_stop_bwd_(-1);
|
||||
parser.Cfg().Stop_if_hdr_after_(-1);
|
||||
parser.Html_mkr().Fmtr_popup().Fmt_("~{content}");
|
||||
parser.Html_mkr().Output_js_clean_(false);
|
||||
parser.Html_mkr().Output_tidy_(false);
|
||||
parser.Html_mkr().Fmtr_next_sect().Fmt_(" (~{next_sect_val})");
|
||||
parser.Wrdx_mkr().Xnde_ignore_ids_(Bry_.new_a7("coordinates"));
|
||||
word_min = 2;
|
||||
}
|
||||
public Xop_popup_parser_fxt Init_notoc_(String v) {parser.Cfg().Notoc_(Bry_.new_u8(v)); return this;}
|
||||
public Xop_popup_parser_fxt Init_tmpl_read_len_(int v) {parser.Cfg().Tmpl_read_len_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_tmpl_read_max_(int v) {parser.Cfg().Tmpl_read_max_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_word_needed_(int v) {word_min = v; return this;}
|
||||
public Xop_popup_parser_fxt Init_para_enabled_(boolean v) {parser.Wtxt_ctx().Para().Enabled_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_ellipsis_(String v) {parser.Cfg().Ellipsis_(Bry_.new_u8(v)); return this;}
|
||||
public Xop_popup_parser_fxt Init_read_til_stop_fwd_(int v) {parser.Cfg().Read_til_stop_fwd_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_read_til_stop_bwd_(int v) {parser.Cfg().Read_til_stop_bwd_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_stop_if_hdr_after_(int v) {parser.Cfg().Stop_if_hdr_after_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_tmpl_tkn_max_(int v) {parser.Tmpl_tkn_max_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_fmtr_next_sect_(String v) {parser.Html_mkr().Fmtr_next_sect().Fmt_(v); return this;}
|
||||
public Xop_popup_parser_fxt Init_page(String ttl, String txt) {Xop_fxt.Init_page_create_static(wiki, ttl, txt); return this;}
|
||||
public Xop_popup_parser_fxt Expd_tmpl_loop_count(int expd) {Tfds.Eq(expd, parser.Data().Tmpl_loop_count()); return this;}
|
||||
public Xop_popup_parser_fxt Test_ns_allowed(String raw, int... expd) {
|
||||
Int_obj_ref[] ids = Xow_popup_mgr.Ns_allowed_parse(wiki, Bry_.new_u8(raw));
|
||||
Tfds.Eq_ary(expd, To_int_ary(ids));
|
||||
return this;
|
||||
}
|
||||
private static int[] To_int_ary(Int_obj_ref[] ary) {
|
||||
int len = ary.length;
|
||||
int[] rv = new int[len];
|
||||
for (int i = 0; i < len; ++i)
|
||||
rv[i] = ary[i].Val();
|
||||
return rv;
|
||||
}
|
||||
public void Test_parse(String raw, String expd) {Test_parse(raw, "Test_1", expd);}
|
||||
public void Test_parse(String raw, String ttl, String expd) {
|
||||
Xoae_page page = Xoae_page.New_edit(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
||||
Xow_popup_itm itm = new Xow_popup_itm(1, Bry_.new_u8(raw), Bry_.Empty, word_min);
|
||||
itm.Init(wiki.Domain_bry(), page.Ttl());
|
||||
byte[] actl = parser.Parse(wiki, page, null, itm);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
public void Test_Assert_at_end(String raw, String expd) {
|
||||
if (test_bfr == null) test_bfr = Bry_bfr_.New();
|
||||
test_bfr.Clear().Add_str_u8(raw);
|
||||
Bry_bfr_.Assert_at_end(test_bfr, Byte_ascii.Nl);
|
||||
Tfds.Eq(expd, test_bfr.To_str_and_clear());
|
||||
} private Bry_bfr test_bfr;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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.htmls.modules.popups.keeplists; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.modules.*; import gplx.xowa.htmls.modules.popups.*;
|
||||
import org.junit.*;
|
||||
public class Xop_keeplist_wiki_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xop_keeplist_wiki_fxt fxt = new Xop_keeplist_wiki_fxt();
|
||||
@Test public void Tmpl_keeplist() {
|
||||
Xop_keeplist_wiki keeplist_wiki = fxt.keeplist_wiki_(String_.Concat_lines_nl
|
||||
( "enwiki|a*|abc*"
|
||||
));
|
||||
fxt.Test_Match_y(keeplist_wiki, "a", "ab");
|
||||
fxt.Test_Match_n(keeplist_wiki, "abc", "abcd", "d");
|
||||
}
|
||||
@Test public void Tmpl_keeplist2() {
|
||||
Xop_keeplist_wiki keeplist_wiki = fxt.keeplist_wiki_(String_.Concat_lines_nl
|
||||
( "enwiki|a*|abc*"
|
||||
, "enwiki|b*|*xyz"
|
||||
));
|
||||
fxt.Test_Match_y(keeplist_wiki, "a", "ab");
|
||||
fxt.Test_Match_n(keeplist_wiki, "d", "abc", "abcd");
|
||||
fxt.Test_Match_y(keeplist_wiki, "b", "bxy");
|
||||
fxt.Test_Match_n(keeplist_wiki, "bxyz", "bcdxyz");
|
||||
}
|
||||
}
|
||||
class Xop_keeplist_wiki_fxt {
|
||||
public void Clear() {
|
||||
}
|
||||
public Xop_keeplist_wiki keeplist_wiki_(String raw) {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app, "enwiki");
|
||||
Xow_popup_mgr popup_mgr = wiki.Html_mgr().Head_mgr().Popup_mgr();
|
||||
popup_mgr.Init_by_wiki(wiki);
|
||||
popup_mgr.Parser().Tmpl_keeplist_init_(Bry_.new_u8(raw));
|
||||
Xop_keeplist_wiki rv = popup_mgr.Parser().Tmpl_keeplist();
|
||||
return rv;
|
||||
}
|
||||
public void Test_Match_y(Xop_keeplist_wiki keeplist_wiki, String... itms) {Test_Match(keeplist_wiki, itms, Bool_.Y);}
|
||||
public void Test_Match_n(Xop_keeplist_wiki keeplist_wiki, String... itms) {Test_Match(keeplist_wiki, itms, Bool_.N);}
|
||||
private void Test_Match(Xop_keeplist_wiki keeplist_wiki, String[] itms, boolean expd) {
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String itm = itms[i];
|
||||
Tfds.Eq(expd, keeplist_wiki.Match(Bry_.new_u8(itm)), "itm={0} expd={1}", itm, expd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
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.htmls.ns_files; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_ns_file_page_mgr_tst {
|
||||
private final Xoh_ns_file_page_mgr_fxt fxt = new Xoh_ns_file_page_mgr_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Image() {
|
||||
fxt.Ttl_str_("Test.png").Html_src_("mem/file/cur.png").Html_orig_src_("mem/file/orig.png").Html_w_(300).Html_h_(200).Html_file_size_(100)
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <a href=\"file:///mem/file/orig.png\" xowa_title=\"Test.png\">"
|
||||
, " <img id=\"xoimg_0\" alt=\"Test.png\" src=\"file:///mem/file/cur.png\" width=\"300\" height=\"200\" />"
|
||||
, " </a>"
|
||||
, " <div class=\"mw-filepage-resolutioninfo\">Size of this preview: "
|
||||
, " <a href=\"file:///mem/file/cur.png\" class=\"mw-thumbnail-link\" xowa_title=\"Test.png\">"
|
||||
, " 300 × 200 pixels"
|
||||
, " </a>"
|
||||
, " ."
|
||||
// , " <span class=\"mw-filepage-other-resolutions\">"
|
||||
// , " Other resolutions:"
|
||||
// , ""
|
||||
// , " </span>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, "<div class=\"fullMedia\">"
|
||||
, " <a href=\"file:///mem/file/orig.png\" class=\"internal\" title=\"Test.png\" xowa_title=\"Test.png\">"
|
||||
, " Full resolution"
|
||||
, " </a>"
|
||||
, " ‎"
|
||||
, " <span class=\"fileInfo\">"
|
||||
, " (0 × 0 pixels, file size: 100, MIME type: image/png)"
|
||||
, " </span>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Audio() {
|
||||
fxt.Ttl_str_("Test.oga").Html_src_("mem/file/cur.oga").Html_orig_src_("mem/file/orig.oga").Html_w_(300).Html_h_(200).Html_file_size_(100)
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div><a href=\"file:///mem/file/orig.oga\" xowa_title=\"Test.oga\" class=\"xowa_media_play\" style=\"width:300px;max-width:300px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Video() {
|
||||
fxt.Ttl_str_("Test.ogv").Html_src_("mem/file/thumb.png").Html_orig_src_("mem/file/orig.ogv").Html_w_(300).Html_h_(200).Html_file_size_(100)
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div>"
|
||||
, " <a href=\"file:///mem/file/thumb.png\" class=\"image\" title=\"Test.ogv\">"
|
||||
, " <img id=\"xoimg_0\" src=\"file:///mem/file/thumb.png\" width=\"300\" height=\"200\" alt=\"\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div><a href=\"file:///mem/file/orig.ogv\" xowa_title=\"Test.ogv\" class=\"xowa_media_play\" style=\"width:300px;max-width:300px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_ns_file_page_mgr_fxt {
|
||||
private final Xoh_ns_file_page_mgr wkr = new Xoh_ns_file_page_mgr();
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xoh_file_page_wtr opt;
|
||||
private final Xof_file_itm file = new Xof_fsdb_itm(); private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public Xoh_ns_file_page_mgr_fxt Ttl_str_(String v) {this.ttl_str = v; return this;} private String ttl_str;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_src_(String v) {this.html_src = v; return this;} private String html_src;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_orig_src_(String v) {this.html_orig_src = v; return this;} private String html_orig_src;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_w_(int v) {this.html_w = v; return this;} private int html_w;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_h_(int v) {this.html_h = v; return this;} private int html_h;
|
||||
public Xoh_ns_file_page_mgr_fxt Html_file_size_(int v) {this.html_file_size = v; return this;} private int html_file_size;
|
||||
public void Reset() {
|
||||
if (app != null) return;
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
opt = new Xoh_file_page_wtr();
|
||||
}
|
||||
public void tst(String expd) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
file.Init_at_gallery_end(html_w, html_h, Io_url_.mem_fil_(html_src), Io_url_.mem_fil_(html_orig_src));
|
||||
// file.Orig_ttl_and_redirect_(ttl_bry, Bry_.Empty);
|
||||
file.Init_at_orig(Byte_.Zero, wiki.Domain_bry(), ttl_bry, Xof_ext_.new_by_ttl_(ttl_bry), 0, 0, Bry_.Empty);
|
||||
file.Init_at_hdoc(0, Xof_html_elem.Tid_img);
|
||||
wkr.Bld_html(wiki, bfr, file, ttl, opt, Bry_.To_a7_bry(html_file_size, 0)); // TEST: must pass in elem_val b/c test only uses 2nd Bld_html while app uses 1st
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
public static final String Hdr = String_.Concat_lines_nl_skip_last("<br/>");
|
||||
// ( "<ul id=\"filetoc\">"
|
||||
// , " <li>"
|
||||
// , " <a href=\"#file\">"
|
||||
// , " File"
|
||||
// , " </a>"
|
||||
// , " </li>"
|
||||
// , " <li>"
|
||||
// , " <a href=\"#filehistory\">"
|
||||
// , " File history"
|
||||
// , " </a>"
|
||||
// , " </li>"
|
||||
// , " <li>"
|
||||
// , " <a href=\"#filelinks\">"
|
||||
// , " File usage on Commons"
|
||||
// , " </a>"
|
||||
// , " </li>"
|
||||
// , " <li>"
|
||||
// , " <a href=\"#globalusage\">"
|
||||
// , " File usage on other wikis"
|
||||
// , " </a>"
|
||||
// , " </li>"
|
||||
// , "</ul>"
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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.htmls.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.*; import gplx.xowa.xtns.wbases.*;
|
||||
public class Xoh_page_body_cls_tst {
|
||||
@Before public void init() {} private Xoh_page_body_cls_fxt fxt = new Xoh_page_body_cls_fxt();
|
||||
@Test public void Escape_cls() {
|
||||
fxt.Test_escape_cls("0123456789", "0123456789"); // noop: num
|
||||
fxt.Test_escape_cls("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); // noop: ucase
|
||||
fxt.Test_escape_cls("abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz"); // noop: lcase
|
||||
fxt.Test_escape_cls("!\"#$%&'()*+,.\\/:;<=>?@[]^`{|}~", "______________________________"); // underline: syms
|
||||
fxt.Test_escape_cls("a.bcd..ef.", "a_bcd__ef_"); // letters + syms
|
||||
fxt.Test_escape_cls("a__b___c" , "a_b_c"); // multiple underlines
|
||||
fxt.Test_escape_cls("a b", "a_b"); // nbsp
|
||||
}
|
||||
@Test public void Calc() {
|
||||
fxt.Test_calc(Xow_page_tid.Tid_wikitext , "A" , "ns-0 ns-subject page-A");
|
||||
fxt.Test_calc(Xow_page_tid.Tid_wikitext , "Talk:A" , "ns-1 ns-talk page-Talk_A");
|
||||
fxt.Test_calc(Xow_page_tid.Tid_wikitext , "Wikipedia:Página principal" , "ns-4 ns-subject page-Wikipedia_Página_principal");
|
||||
fxt.Test_calc(Xow_page_tid.Tid_json , "Q2" , "ns-0 ns-subject page-Q2 wb-entitypage wb-itempage wb-itempage-Q2");
|
||||
fxt.Test_calc(Xow_page_tid.Tid_json , "Property:P1" , "ns-120 ns-subject page-Property_P1 wb-entitypage wb-propertypage wb-propertypage-P1");
|
||||
}
|
||||
}
|
||||
class Xoh_page_body_cls_fxt {
|
||||
private Bry_bfr tmp_bfr; private Xoae_app app; private Xowe_wiki wiki;
|
||||
public void Test_escape_cls(String raw, String expd) {
|
||||
Tfds.Eq(expd, String_.new_u8(Xoh_page_body_cls.Escape_cls(Bry_.new_u8(raw))));
|
||||
}
|
||||
public void Test_calc(byte page_tid, String ttl_str, String expd) {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
tmp_bfr = Bry_bfr_.Reset(255);
|
||||
wiki.Ns_mgr().Add_new(Wdata_wiki_mgr.Ns_property, Wdata_wiki_mgr.Ns_property_name);
|
||||
}
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
|
||||
Tfds.Eq(expd, String_.new_u8(Xoh_page_body_cls.Calc(tmp_bfr, ttl, page_tid)));
|
||||
}
|
||||
}
|
||||
62
400_xowa/src/gplx/xowa/htmls/portal/Xoh_rtl_utl_tst.java
Normal file
62
400_xowa/src/gplx/xowa/htmls/portal/Xoh_rtl_utl_tst.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
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.htmls.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_rtl_utl_tst {
|
||||
@Before public void init() {fxt.Init();} private Xoh_rtl_utl_fxt fxt = new Xoh_rtl_utl_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_reverse_li("<ul><li>a</li><li>b</li></ul>", "<ul><li>b</li><li>a</li></ul>");
|
||||
}
|
||||
@Test public void Zero() {
|
||||
fxt.Test_reverse_li("a", "a");
|
||||
}
|
||||
@Test public void One() {
|
||||
fxt.Test_reverse_li("<ul><li>a</li></ul>", "<ul><li>a</li></ul>");
|
||||
}
|
||||
@Test public void Example() {
|
||||
fxt.Test_reverse_li(String_.Concat_lines_nl_skip_last
|
||||
( "<div>"
|
||||
, " <ul>"
|
||||
, " <li>a"
|
||||
, " </li>"
|
||||
, " <li>b"
|
||||
, " </li>"
|
||||
, " <li>c"
|
||||
, " </li>"
|
||||
, " </ul>"
|
||||
, "</div>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div>"
|
||||
, " <ul>"
|
||||
, " <li>c"
|
||||
, " </li>"
|
||||
, " <li>b"
|
||||
, " </li>"
|
||||
, " <li>a"
|
||||
, " </li>"
|
||||
, " </ul>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_rtl_utl_fxt {
|
||||
public void Init() {
|
||||
}
|
||||
public void Test_reverse_li(String raw, String expd) {
|
||||
byte[] actl = Xoh_rtl_utl.Reverse_li(Bry_.new_u8(raw));
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.htmls.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_subpages_bldr_tst {
|
||||
@Before public void init() {fxt.Init();} private Xoh_subpages_bldr_fxt fxt = new Xoh_subpages_bldr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_bld("Help:A/B/C", String_.Concat_lines_nl_skip_last
|
||||
( "<span class=\"subpages\">"
|
||||
, " < <a href=\"/wiki/Help:A\" title=\"Help:A\">Help:A</a>"
|
||||
, " ‎ | <a href=\"/wiki/Help:A/B\" title=\"Help:A/B\">B</a>"
|
||||
, "</span>"
|
||||
));
|
||||
}
|
||||
@Test public void Skip_page() {
|
||||
fxt.Wiki().Ns_mgr().Add_new(104, "Page");
|
||||
fxt.Wiki().Ns_mgr().Ns_page_id_(104);
|
||||
fxt.Test_bld("Page:A/B/C", "");
|
||||
}
|
||||
}
|
||||
class Xoh_subpages_bldr_fxt {
|
||||
private Xoae_app app;
|
||||
private Xoh_subpages_bldr subpages_bldr = new Xoh_subpages_bldr();
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public void Init() {
|
||||
this.app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__help).Subpages_enabled_(true);
|
||||
}
|
||||
public void Test_bld(String ttl_str, String expd) {
|
||||
byte[] actl = subpages_bldr.Bld(wiki.Ns_mgr(), Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str)));
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
72
400_xowa/src/gplx/xowa/htmls/portal/Xow_portal_mgr_tst.java
Normal file
72
400_xowa/src/gplx/xowa/htmls/portal/Xow_portal_mgr_tst.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
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.htmls.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xow_portal_mgr_tst {
|
||||
@Before public void init() {fxt.Init();} private Xowh_portal_mgr_fxt fxt = new Xowh_portal_mgr_fxt();
|
||||
@Test public void Div_ns_bry() {
|
||||
fxt.Test_div_ns_bry("A" , "/wiki/A;selected;/wiki/Talk:A;xowa_display_none;");
|
||||
fxt.Test_div_ns_bry("Talk:A" , "/wiki/A;;/wiki/Talk:A;selected;");
|
||||
}
|
||||
@Test public void Div_personal_bry() {
|
||||
fxt.Test_div_personal_bry("/wiki/User:anonymous;anonymous;xowa_display_none;/wiki/User_talk:anonymous;xowa_display_none;");
|
||||
}
|
||||
@Test public void Missing_ns_cls() {
|
||||
fxt.Test_missing_ns_cls("xowa_display_none");
|
||||
}
|
||||
@Test public void Logo() {
|
||||
fxt.Portal_mgr().Div_logo_fmtr().Fmt_("~{portal_logo_url}");
|
||||
|
||||
// day-mode
|
||||
fxt.Portal_mgr().Init();
|
||||
fxt.Test_logo_frag(Bool_.N, "file:///mem/xowa/user/test_user/wiki/en.wikipedia.org/html/logo.png");
|
||||
|
||||
// night-mode: app
|
||||
fxt.Test_logo_frag(Bool_.Y, "file:///mem/xowa/bin/any/xowa/html/css/nightmode/logo_night.png");
|
||||
|
||||
// night-mode: wiki
|
||||
Io_mgr.Instance.SaveFilStr("mem/xowa/user/test_user/wiki/en.wikipedia.org/html/logo_night.png", "");
|
||||
fxt.Portal_mgr().Init();
|
||||
fxt.Test_logo_frag(Bool_.Y, "file:///mem/xowa/user/test_user/wiki/en.wikipedia.org/html/logo_night.png");
|
||||
}
|
||||
}
|
||||
class Xowh_portal_mgr_fxt {
|
||||
private Xow_portal_mgr portal_mgr;
|
||||
public void Init() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Ns_mgr().Ns_main().Exists_(true); // needed for ns
|
||||
this.portal_mgr = wiki.Html_mgr().Portal_mgr();
|
||||
portal_mgr.Init_assert(); // needed for personal
|
||||
portal_mgr.Missing_ns_cls_(Bry_.new_a7("xowa_display_none"));
|
||||
}
|
||||
} private Xoae_app app; Xowe_wiki wiki;
|
||||
public void Test_div_ns_bry(String ttl, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Html_mgr().Portal_mgr().Div_ns_bry(wiki.Utl__bfr_mkr(), Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)), wiki.Ns_mgr())));
|
||||
}
|
||||
public void Test_div_personal_bry(String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Html_mgr().Portal_mgr().Div_personal_bry()));
|
||||
}
|
||||
public void Test_missing_ns_cls(String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Html_mgr().Portal_mgr().Missing_ns_cls()));
|
||||
}
|
||||
public Xow_portal_mgr Portal_mgr() {return wiki.Html_mgr().Portal_mgr();}
|
||||
public void Test_logo_frag(boolean nightmode, String expd) {
|
||||
String actl = String_.new_a7(wiki.Html_mgr().Portal_mgr().Div_logo_bry(nightmode));
|
||||
Gftest.Eq__str(expd, actl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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.htmls.portal.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.portal.*;
|
||||
import org.junit.*; import gplx.xowa.langs.vnts.*;
|
||||
public class Vnt_mnu_grp_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Vnt_mnu_grp_fmtr_fxt fxt = new Vnt_mnu_grp_fmtr_fxt();
|
||||
@Test public void Basic() {
|
||||
// fxt.Test_to_str("Earth", "zh-hk", String_.Concat_lines_nl_skip_last
|
||||
// ( ""
|
||||
// , " <div id='p-variants' role='navigation' class='vectorMenu' aria-labelledby='p-variants-label'>"
|
||||
// , " <h3 id='p-variants-label'><span>Choose lang</span><a href='#'></a></h3>"
|
||||
// , " <div class='menu'>"
|
||||
// , " <ul>"
|
||||
// , " <li id='ca-varlang-0'><a href='/wiki/Earth?xowa_vnt=zh-hans' lang='zh-hans' hreflang='zh-hans'>Simplified</a></li>"
|
||||
// , " <li id='ca-varlang-1'><a href='/wiki/Earth?xowa_vnt=zh-hant' lang='zh-hant' hreflang='zh-hant'>Traditional</a></li>"
|
||||
// , " <li id='ca-varlang-2'><a href='/wiki/Earth?xowa_vnt=zh-cn' lang='zh-cn' hreflang='zh-cn'>China</a></li>"
|
||||
// , " <li id='ca-varlang-3' class='selected'><a href='/wiki/Earth?xowa_vnt=zh-hk' lang='zh-hk' hreflang='zh-hk'>Hong Kong</a></li>"
|
||||
// , " <li id='ca-varlang-4'><a href='/wiki/Earth?xowa_vnt=zh-mo' lang='zh-mo' hreflang='zh-mo'>Macau</a></li>"
|
||||
// , " <li id='ca-varlang-5'><a href='/wiki/Earth?xowa_vnt=zh-sg' lang='zh-sg' hreflang='zh-sg'>Singapore</a></li>"
|
||||
// , " <li id='ca-varlang-6'><a href='/wiki/Earth?xowa_vnt=zh-tw' lang='zh-tw' hreflang='zh-tw'>Taiwan</a></li>"
|
||||
// , " </ul>"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// ));
|
||||
}
|
||||
}
|
||||
class Vnt_mnu_grp_fmtr_fxt {
|
||||
private final Xol_vnt_regy mgr = new Xol_vnt_regy();
|
||||
public void Clear() {
|
||||
this.Init_grp("Choose lang", "zh-hans", "Simplified", "zh-hant", "Traditional", "zh-cn", "China", "zh-hk", "Hong Kong", "zh-mo", "Macau", "zh-sg", "Singapore", "zh-tw", "Taiwan");
|
||||
}
|
||||
public void Init_grp(String text, String... langs) {
|
||||
mgr.Clear();
|
||||
int len = langs.length;
|
||||
String lang_code = "";
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String lang = langs[i];
|
||||
if (i % 2 == 0)
|
||||
lang_code = lang;
|
||||
else {
|
||||
mgr.Add(Bry_.new_u8(lang_code), Bry_.new_u8(lang));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Test_to_str(String page_href, String selected_vnt, String expd) {
|
||||
Vnt_mnu_grp_fmtr vnt_grp_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
vnt_grp_fmtr.Init(mgr, Bry_.new_u8(page_href), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_u8(selected_vnt));
|
||||
vnt_grp_fmtr.Bfr_arg__add(bfr);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user