mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Command-line: Fix curid argument not working 2
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_base_fxt {
|
||||
protected Xoae_app app; protected Xowe_wiki wiki;
|
||||
@gplx.Virtual public void Reset() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Parser_mgr().Ctx().Para().Enabled_n_();
|
||||
}
|
||||
public Imap_part_shape itm_rect_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_rect, link, pts_ary);}
|
||||
public Imap_part_shape itm_circle_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_circle, link, pts_ary);}
|
||||
public Imap_part_shape itm_poly_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_poly, link, pts_ary);}
|
||||
private Imap_part_shape itm_shape_(byte tid, String link, double... pts_ary) {
|
||||
int pts_len = pts_ary.length;
|
||||
Double_obj_val[] pts_doubles = new Double_obj_val[pts_len];
|
||||
for (int i = 0; i < pts_len; ++i)
|
||||
pts_doubles[i] = Double_obj_val.new_(pts_ary[i]);
|
||||
byte[] link_bry = Bry_.new_u8(link);
|
||||
Imap_part_shape rv = new Imap_part_shape(tid, pts_doubles);
|
||||
Imap_link_owner_.Init(rv, app, wiki, link_bry, Make_link_tkn(link_bry));
|
||||
return rv;
|
||||
}
|
||||
private Xop_tkn_itm Make_link_tkn(byte[] src) {
|
||||
Xop_root_tkn root_tkn = new Xop_root_tkn();
|
||||
wiki.Parser_mgr().Main().Parse_text_to_wdom(root_tkn, wiki.Parser_mgr().Ctx(), app.Parser_mgr().Tkn_mkr(), src, Xop_parser_.Doc_bgn_bos);
|
||||
return root_tkn.Subs_get(0);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.parsers.*; import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_parser_tst {
|
||||
@Before public void init() {fxt.Reset();} private Imap_parser_fxt fxt = new Imap_parser_fxt();
|
||||
@Test public void Rect_pass() {fxt.Test_shape("rect 1 2 3 4 [[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));}
|
||||
@Test public void Rect_pass_many() {fxt.Test_shape("rect 1 2 3 4 5 6[[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));} // PURPOSE: MW allows extra points to be passed; PAGE:en.w:Kilauea DATE:2014-07-28
|
||||
@Test public void Rect_pass_invalid() {fxt.Test_shape("rect 1 2 3 4 a b [[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));} // PURPOSE: MW only scans first 4 tokens for numbers; PAGE:de.w:Wilhelm_Angele DATE:2014-10-30
|
||||
@Test public void Circle_pass() {fxt.Test_shape("circle 1 2 3 [[A]]" , fxt.itm_circle_("[[A]]", 1, 2, 3));}
|
||||
@Test public void Poly_pass() {fxt.Test_shape("poly 1 2 3 4 5 6 [[A]]" , fxt.itm_poly_("[[A]]", 1, 2, 3, 4, 5, 6));}
|
||||
@Test public void Poly_pass_chars() {fxt.Test_shape("poly a b [[A]]" , fxt.itm_poly_("[[A]]", 0, 0));} // PURPOSE: non-numeric should be converted to 0; PAGE:uk.w:Стратосфера; DATE:2014-07-26
|
||||
@Test public void Poly_pass_chars_2() {fxt.Test_shape("poly 1a 2a [[A]]" , fxt.itm_poly_("[[A]]", 0, 0));} // PURPOSE: non-numeric should be converted to 0; PAGE:ru.w:Системный_блок; DATE:2014-10-22
|
||||
@Test public void Poly_pass_dots() {fxt.Test_shape("poly 1.2 3.4 [[A]]" , fxt.itm_poly_("[[A]]", 1.2d, 3.4d));} // PURPOSE: make sure decimals are handled correctly
|
||||
@Test public void Poly_pass_commas() {fxt.Test_shape("poly 1, 2, 3, 4 [[A]]" , fxt.itm_poly_("[[A]]", 1, 2, 3, 4));} // PURPOSE: commas should be ignored; PAGE:de.w:Kaimnitz; DATE:2014-08-05
|
||||
@Test public void Poly_pass_commas_2() {fxt.Test_shape("poly 1,2 3,4 [[A]]" , fxt.itm_poly_("[[A]]", 1, 3));} // PURPOSE: commas should be ignored for purpose of parse; PAGE:fr.w:Gouesnou; DATE:2014-08-12
|
||||
@Test public void Poly_pass_commas_3() {fxt.Test_shape("poly ,1 2 [[A]]" , fxt.itm_poly_("[[A]]", 1, 2));} // PURPOSE: do not fail if comma is at start of number; PAGE:en.w:Area_codes_281,_346,_713,_and_832; DATE:2015-07-31
|
||||
@Test public void Rect_fail() {fxt.Test_shape_err("rect 1 2 3 [[A]]" , "imagemap_missing_coord");}
|
||||
@Test public void Circle_fail() {fxt.Test_shape_err("circle 1 2 [[A]]" , "imagemap_missing_coord");}
|
||||
@Test public void Poly_fail_odd() {fxt.Test_shape_err("poly 1 2 3 [[A]]" , "imagemap_poly_odd");}
|
||||
@Test public void Poly_fail_zero() {fxt.Test_shape_err("poly [[A]]" , "imagemap_missing_coord");}
|
||||
@Test public void Circle_fail_invalid() {fxt.Test_shape_err("rect 1 2..3 4 [[A]]" , "imagemap_invalid_coord");}
|
||||
}
|
||||
class Imap_parser_fxt extends Imap_base_fxt {
|
||||
private Imap_parser parser;
|
||||
private Imap_map imap;
|
||||
@Override public void Reset() {
|
||||
super.Reset();
|
||||
byte[] ttl_bry = Bry_.new_a7("Test_1");
|
||||
Imap_xtn_mgr xtn_mgr = new Imap_xtn_mgr();
|
||||
Xoae_page page = Xoae_page.New(wiki, wiki.Ttl_parse(ttl_bry));
|
||||
parser = new Imap_parser(xtn_mgr);
|
||||
parser.Init(wiki, page, Gfo_usr_dlg_.Noop);
|
||||
parser.Clear();
|
||||
imap = new Imap_map(1);
|
||||
}
|
||||
public void Test_shape(String raw_str, Imap_part_shape expd) {
|
||||
raw_str = "File:A.png\n" + raw_str;
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
parser.Parse(imap, raw, 0, raw.length);
|
||||
Imap_part_shape[] actl_ary = imap.Shapes();
|
||||
Imap_part_shape actl = actl_ary == null | actl_ary.length != 1 ? null : (Imap_part_shape)actl_ary[0];
|
||||
if (actl == null && expd == null) {} // noop; test passed
|
||||
else if (actl == null && expd != null) {Tfds.Fail("actl should not be null", raw);}
|
||||
else if (actl != null && expd == null) {Tfds.Fail("actl should be null", raw);}
|
||||
else {
|
||||
Tfds.Eq(expd.Part_tid(), actl.Part_tid(), "tid");
|
||||
Tfds.Eq_ary(expd.Shape_pts(), actl.Shape_pts(), "pts");
|
||||
Tfds.Eq(String_.new_u8(expd.Link_href()), String_.new_u8(actl.Link_href()));
|
||||
Tfds.Eq(String_.new_u8(expd.Link_text()), String_.new_u8(actl.Link_text()));
|
||||
}
|
||||
Tfds.Eq(0, imap.Errs().length, "expd 0 errors");
|
||||
}
|
||||
public void Test_shape_err(String raw_str, String expd_err) {
|
||||
raw_str = "File:A.png\n" + raw_str;
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
parser.Parse(imap, raw, 0, raw.length);
|
||||
Imap_err[] err_ary = imap.Errs();
|
||||
Tfds.Eq(1, err_ary.length, "expd 1 err");
|
||||
Tfds.Eq(expd_err, err_ary[0].Err_msg());
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Imap_html__hdump__tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Fxt().Hctx_(Xoh_wtr_ctx.Hdump);} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|100x200px|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:100px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <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 data-xowa-title=\"A.png\" data-xoimg=\"1|100|200|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Imap_html__hview__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|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 id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <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 id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
@Test public void Caption_xml() { // PURPOSE: xnde in caption was being escaped; PAGE:en.w:Council_of_Europe; DATE:2014-07-25
|
||||
fxt.Test_html_full_frag("<imagemap>File:A.png|thumb|<b>c</b>\n</imagemap>", "<b>c</b>");
|
||||
}
|
||||
@Test public void Default() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|a1"
|
||||
, "default [[B|b1]]"
|
||||
, "</imagemap>"
|
||||
), 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 id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <a href=\"/wiki/B\" title=\"b1\">"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" usemap=\"#imageMap_1_1\"/>"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>a1"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Desc() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|123px|a1"
|
||||
, "desc top-left"
|
||||
, "</imagemap>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"imap_div_0\" class=\"noresize\" style=\"height:0px; width: 123px;\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"a1\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" usemap=\"#imageMap_1_1\"/>"
|
||||
, " <div style=\"margin-left:0px; margin-top:1px; text-align:left;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" title=\"click here\">"
|
||||
, " <img alt=\"click here\" src=\"file:///mem/xowa/bin/any/xowa/xtns/ImageMap/imgs/desc-20.png\" style=\"border: none;\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Lnke() { // PURPOSE: handle shapes with lnke; PAGE:en.w:Cholesterolt DATE:2014-07-25
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|a1"
|
||||
, "circle 0 0 5 [[http://b.org b1]]"
|
||||
, "desc none"
|
||||
, "</imagemap>"
|
||||
), 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 id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " <area href=\"http://b.org\" shape=\"circle\" coords=\"0,0,5\" alt=\"b1\" title=\"b1\"/>"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
@Test public void Err_trailing_ws() { // PURPOSE: empty 1st line causes failure
|
||||
fxt.Test_html_full_frag(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap> "
|
||||
, "File:A.png|thumb|test_caption"
|
||||
, "</imagemap>"
|
||||
), "test_caption" // no error if test_caption appears;
|
||||
);
|
||||
}
|
||||
@Test public void Para_omitted() { // PURPOSE: imagemap should not be automatically enclosed in para; PAGE:cs.w:Seznam_clenu_ctrn<72>ct<63>ho_Knesetu; DATE:2014-05-08;
|
||||
fxt.Fxt().Init_para_y_();
|
||||
fxt.Test_html_full_str("<imagemap>File:A.png</imagemap> a", fxt.Frag_html_full() + " a"); // NOTE: "a" no longer enclosed in <p>; DATE:2014-07-25
|
||||
fxt.Fxt().Init_para_n_();
|
||||
}
|
||||
@Test public void Xnde_double_pipe() {// PURPOSE: if || is inside table and imagemap, treat as lnki; EX:w:United_States_presidential_election,_1992; DATE:2014-03-29; DATE:2014-05-06
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "| z"
|
||||
, "<imagemap>"
|
||||
, "File:A.png||123px|b" // NOTE: "||" should not be tblw; also should not be pipe + text; if it is pipe + text, then caption will be "|123px" and width will be -1; DATE:2014-05-06
|
||||
, "</imagemap>"
|
||||
, "|}"
|
||||
) , String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td> z"
|
||||
, "<div id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" usemap=\"#imageMap_1_1\"/>" // NOTE: width must be 123, not 0
|
||||
, " </div>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Template_image() { // PURPOSE: handle templates in caption; PAGE:en.w:Kilauea; DATE:2014-07-27
|
||||
fxt.Fxt().Init_page_create("Template:Test_template", "xyz");
|
||||
fxt.Test_html_full_frag("<imagemap>File:A.png|thumb|{{Test_template}}\n</imagemap>", "xyz");
|
||||
}
|
||||
@Test public void Template_shape() { // PURPOSE: handle templates in shape; PAGE:fr.w:Arrondissements_de_Lyon DATE:2014-08-12
|
||||
fxt.Fxt().Init_page_create("Template:B1", "<b>b1</b>"); // note that an xnde is a better example as it will throw ArrayOutOfBounds error
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|a1"
|
||||
, "circle 0 0 5 [[B|{{b1}}]]"
|
||||
, "desc none"
|
||||
, "</imagemap>"
|
||||
), 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 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\"/>"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
@Test public void Template_multi_line() { // PURPOSE: handle multiple-line captions; PAGE:en.w:Archaea; DATE:2014-08-22
|
||||
fxt.Test_html_full_frag(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|<ref>text"
|
||||
, "</ref>"
|
||||
, "</imagemap>"
|
||||
), "id=\"cite_ref-0\"");
|
||||
}
|
||||
}
|
||||
class Imap_xnde_html_fxt {
|
||||
public void Reset() {
|
||||
fxt.Reset();
|
||||
Xol_msg_itm msg = fxt.Wiki().Msg_mgr().Get_or_make(Bry_.new_a7("imagemap_description"));
|
||||
msg.Atrs_set(Bry_.new_a7("click here"), false, false);
|
||||
}
|
||||
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
|
||||
public void Test_html_full_str(String raw, String expd) {fxt.Test_html_full_str(raw, expd);}
|
||||
public void Test_html_full_frag(String raw, String expd) {fxt.Test_html_full_frag(raw, expd);}
|
||||
public String Frag_html_full() {
|
||||
return String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" usemap=\"#imageMap_1_1\"/>"
|
||||
, " </div>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import org.junit.*; import gplx.xowa.xtns.imaps.itms.*;
|
||||
public class Imap_shapes_arg_tst {
|
||||
@Before public void init() {fxt.Reset();} private Imap_shapes_arg_fxt fxt = new Imap_shapes_arg_fxt();
|
||||
@Test public void Rect() {fxt.Test_shape_html(fxt.itm_rect_("[[A|b]]", 1, 2, 3, 4), "\n <area href=\"/wiki/A\" shape=\"rect\" coords=\"1,2,3,4\" alt=\"b\" title=\"b\"/>");}
|
||||
@Test public void Circle() {fxt.Test_shape_html(fxt.itm_circle_("[[A|b]]", 1, 2, 3 ), "\n <area href=\"/wiki/A\" shape=\"circle\" coords=\"1,2,3\" alt=\"b\" title=\"b\"/>");}
|
||||
@Test public void Poly() {fxt.Test_shape_html(fxt.itm_poly_("[[A|b]]", 1, 2, 3, 4), "\n <area href=\"/wiki/A\" shape=\"poly\" coords=\"1,2,3,4\" alt=\"b\" title=\"b\"/>");}
|
||||
}
|
||||
class Imap_shapes_arg_fxt extends Imap_base_fxt {
|
||||
public void Test_shape_html(Imap_part_shape shape, String expd) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Imap_shape_pts_arg pts_fmtr_arg = new Imap_shape_pts_arg(1);
|
||||
Imap_shapes_arg.Fmt_shape(bfr, Imap_html_fmtrs.Area, pts_fmtr_arg, shape);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user