1
0
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:
gnosygnu
2017-02-22 08:44:14 -05:00
parent 0e85cc90ff
commit 5bd3371802
896 changed files with 1 additions and 69011 deletions

View File

@@ -1,23 +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.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
public class Pp_pagelist_nde_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Test public void Basic() {
fxt.Test_parse_page_wiki_str("a<pagelist>b</pagelist>c", "ac");
}
}

View File

@@ -1,23 +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.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
public class Pp_pagequality_nde_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Test public void Basic() {
fxt.Test_parse_page_wiki_str("a<pagequality>b</pagequality>c", "ac");
}
}

View File

@@ -1,126 +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.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.xowa.apps.cfgs.*;
public class Pp_pages_nde_basic_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Before public void Init() {
Io_mgr.Instance.InitEngine_mem();
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
}
@After public void term() {
fxt.Wiki().Cache_mgr().Free_mem__all();
}
@Test public void Basic() {
fxt.Init_page_create("Page:A/1", "abc");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", String_.Concat_lines_nl
( "<p>abc&#32;"
, "</p>"
, ""
));
}
@Test public void Multiple() {
fxt.Init_page_create("Page:A/1", "a");
fxt.Init_page_create("Page:A/2", "b");
fxt.Init_page_create("Page:A/3", "c");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 />", String_.Concat_lines_nl
( "<p>a&#32;b&#32;c&#32;"
, "</p>"
, ""
));
}
@Test public void Section() {
fxt.Init_page_create("Page:A/1", "a<section begin=\"sect_0\"/>b");
fxt.Init_page_create("Page:A/2", "cd");
fxt.Init_page_create("Page:A/3", "e<section end=\"sect_2\"/>f");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 fromsection='sect_0' tosection='sect_2' />", String_.Concat_lines_nl
( "<p>b&#32;cd&#32;e&#32;"
, "</p>"
));
}
@Test public void Section__onlyinclude() {
fxt.Init_page_create("Page:A/1", "a<section begin='sect_0'/>b<section end='sect_0'/>c");
fxt.Test_parse_page_wiki_str("<pages index='A' from=1 to=1 onlysection='sect_0' />", String_.Concat_lines_nl
( "<p>b&#32;"
, "</p>"
));
}
@Test public void Section__onlyinclude_ignores_from_to() {
fxt.Init_page_create("Page:A/1", "<section begin='sect_a'/>a<section end='sect_a'/><section begin='sect_b'/>b<section end='sect_b'/><section begin='sect_c'/>c<section end='sect_c'/>");
fxt.Test_parse_page_wiki_str("<pages from=1 index='A' onlysection='sect_b' fromsection='sect_a' tosection='sect_c' />", String_.Concat_lines_nl
( "<p>b&#32;"
, "</p>"
));
}
@Test public void Noinclude() {
fxt.Init_page_create("Page:A/1", "<noinclude>a</noinclude>{|\n|b\n|}");
fxt.Init_page_create("Page:A/2", "<noinclude>c</noinclude>''d''");
fxt.Init_page_create("Page:A/3", "<noinclude>e</noinclude>f");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 />", String_.Concat_lines_nl_skip_last
( "<table>"
, " <tr>"
, " <td>b"
, " </td>"
, " </tr>"
, "</table>"
, "&#32;<i>d</i>&#32;f&#32;"
));
}
@Test public void Err_page_ns_doesnt_exist() {
fxt.Wiki().Ns_mgr().Init().Clear(); // call .Clear() to remove ns for Page / Index
fxt.Wiki().Cfg_parser().Xtns().Itm_pages().Reset(); // must reset to clear cached valid ns_page from previous tests
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 />", "&lt;pages index=&quot;A&quot; from=1 to=3 /&gt;");
fxt.Wiki().Cfg_parser().Xtns().Itm_pages().Reset(); // must reset to clear cached invalid ns_page for next tests
}
@Test public void Subpage() { // PURPOSE: [[/Page]] should be relative to current page; EX: Flatland and [[/First World]]; DATE:2013-04-29
fxt.Init_page_create("Page:A/1", "[[/Sub1|Sub 1]]");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", String_.Concat_lines_nl
( "<p><a href=\"/wiki/Test_page/Sub1\">Sub 1</a>&#32;" // NOTE: / is relative to Page_name (in this case Test_page)
, "</p>"
));
}
@Test public void Disable() { // PURPOSE: simulate disabled wiki; PAGE:en.w:Wikipedia:Requests_for_adminship/Phantomsteve DATE:2014-09-08
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_n_();
fxt.Init_page_create("Page:A/1", "A");
fxt.Test_parse_page_wiki_str
( "<pages index=\"A\" from=1 to=1>a</pages>"
, "&lt;pages index=&quot;A&quot; from=1 to=1&gt;a"
);
}
@Test public void Page_has_nl() { // PURPOSE: parse "to" page, even if it has \n at end; PAGE:en.s:1911_Encyclop<6F>dia_Britannica/Boissier,_Marie_Louis_Antoine_Gaston DATE:2015-04-29
fxt.Init_page_create("Page:A/1", "abc");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to='1\n' />", String_.Concat_lines_nl
( "<p>abc&#32;"
, "</p>"
, ""
));
}
@Test public void Indicator() { // PURPOSE: handle indicators; PAGE:en.s:The_Parochial_System_(Wilberforce,_1838); DATE:2015-04-29
fxt.Init_page_create("Page:A/1", "<indicator name='b'>b</indicator>page_1");
fxt.Test_parse_page_wiki_str(String_.Concat_lines_nl_skip_last
( "<indicator name='a'>a</indicator>"
, "<pages index=\"A\" from=1 to='1\' />"
), String_.Concat_lines_nl
( "<p>page_1&#32;" // make sure Page:A/1 is transcribed
, "</p>"
, ""
));
Tfds.Eq(1, fxt.Page().Html_data().Indicators().Count()); // only 1 indicator, not 2
Tfds.Eq(true, fxt.Page().Html_data().Indicators().Has("a")); // indicator should be from wikitext, not <page>
}
}

View File

@@ -1,155 +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.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.xowa.apps.cfgs.*;
public class Pp_pages_nde_hdr_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Before public void Init() {
Io_mgr.Instance.InitEngine_mem();
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
fxt.Wiki().Cache_mgr().Page_cache().Free_mem(true);
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
fxt.Init_page_create("MediaWiki:Proofreadpage_header_template", String_.Concat
( "{{#if:{{{value|}}}|value={{{value}}};|value=nil;}}"
, "{{#if:{{{current|}}}|current={{{current}}};|}}"
, "{{#if:{{{prev|}}}|prev={{{prev}}};|}}"
, "{{#if:{{{next|}}}|next={{{next}}};|}}"
, "{{#if:{{{from|}}}|from={{{from}}};|}}"
, "{{#if:{{{to|}}}|to={{{to}}};|}}"
, "{{#if:{{{custom|}}}|custom={{{custom}}};|}}"
, "\n\n"
));
}
@Test public void Default_to_toc() { // PURPOSE: default header to "toc" if no "from", "to", "include"; DATE:2014-01-27
fxt.Init_page_create("Index:A", "");
// only index supplied; add header='toc'
fxt.Test_parse_page_wiki_str("<pages index='A'/>", String_.Concat_lines_nl
( "<p>value=toc;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
fxt.Init_page_create("Page:A/1", "A/1");
// from specified; don't add toc
fxt.Test_parse_page_wiki_str("<pages index='A' from='1'/>", String_.Concat_lines_nl
( "<p>A/1&#32;"
, "</p>"
));
}
@Test public void From_set() { // PURPOSE: "from" should (a) appear in toc; and (b) select pages; DATE:2014-01-27
fxt.Init_page_create("Index:A" , "idx");
fxt.Init_page_create("Page:A/1", "a1");
fxt.Init_page_create("Page:A/2", "a2");
fxt.Init_page_create("Page:A/3", "a3");
fxt.Test_parse_page_wiki_str("<pages index='A' from=2 to=2 header='toc'/>", String_.Concat_lines_nl
( "<p>value=toc;from=2;to=2;"
, "</p>"
, ""
, "<p>a2&#32;"
, "</p>"
));
}
@Test public void Mainspace_toc() { // PURPOSE: Mainspace links should be sent to toc; DATE:2014-01-27
fxt.Init_page_create("Index:A" , String_.Concat_lines_nl_skip_last
( "[[Page/1]]"
, "[[Page/2]]"
, "[[Page/3]]"
));
// next only
fxt.Page_ttl_("Page/1");
fxt.Test_parse_page_wiki_str("<pages index='A' />", String_.Concat_lines_nl
( "<p>value=toc;current=<b>Page/1</b>;next=<a href=\"/wiki/Page/2\">Page/2</a>;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
// next and prev
fxt.Page_ttl_("Page/2");
fxt.Test_parse_page_wiki_str("<pages index='A' />", String_.Concat_lines_nl
( "<p>value=toc;current=<b>Page/2</b>;prev=<a href=\"/wiki/Page/1\">Page/1</a>;next=<a href=\"/wiki/Page/3\">Page/3</a>;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
// prev only
fxt.Page_ttl_("Page/3");
fxt.Test_parse_page_wiki_str("<pages index='A' />", String_.Concat_lines_nl
( "<p>value=toc;current=<b>Page/3</b>;prev=<a href=\"/wiki/Page/2\">Page/2</a>;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
// override current only;
fxt.Page_ttl_("Page/2");
fxt.Test_parse_page_wiki_str("<pages index='A' current='custom_cur'/>", String_.Concat_lines_nl
( "<p>value=toc;current=custom_cur;prev=<a href=\"/wiki/Page/1\">Page/1</a>;next=<a href=\"/wiki/Page/3\">Page/3</a>;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
// override current, prev, next
fxt.Test_parse_page_wiki_str("<pages index='A' current='custom_cur' prev='custom_prv' next='custom_nxt'/>", String_.Concat_lines_nl
( "<p>value=toc;current=custom_cur;prev=custom_prv;next=custom_nxt;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
}
@Test public void Mainspace_caption() { // PURPOSE: extract caption; DATE:2014-01-27
fxt.Init_page_create("Index:A" , String_.Concat_lines_nl_skip_last
( "[[Page/1|Caption_1]]"
, "[[Page/2]]"
, "[[Page/3]]"
));
fxt.Page_ttl_("Page/2");
fxt.Test_parse_page_wiki_str("<pages index='A' />", String_.Concat_lines_nl
( "<p>value=toc;current=<b>Page/2</b>;prev=<a href=\"/wiki/Page/1\">Caption_1</a>;next=<a href=\"/wiki/Page/3\">Page/3</a>;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
}
@Test public void Xwiki() { // PURPOSE: Mainspace links should be sent to toc; DATE:2014-01-27
fxt.Init_xwiki_add_wiki_and_user_("commons", "commons.wikimedia.org");
fxt.Init_page_create("Index:A" , String_.Concat_lines_nl_skip_last
( "[[Page/1]]"
, "[[:commons:File:A.png]]"
));
// next only
fxt.Page_ttl_("Page/1");
fxt.Test_parse_page_wiki_str("<pages index='A' />", String_.Concat_lines_nl
( "<p>value=toc;current=<b>Page/1</b>;next=<a href=\"/site/commons.wikimedia.org/wiki/File:A.png\">File:A.png</a>;"
, "</p>"
, ""
, "<p><br/>"
, "</p>"
));
}
}

View File

@@ -1,234 +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.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.xowa.apps.cfgs.*;
public class Pp_pages_nde_index_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Before public void Init() {
Io_mgr.Instance.InitEngine_mem();
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
}
@After public void term() {
fxt.Wiki().Cache_mgr().Free_mem__all();
}
@Test public void Repeated() { // PURPOSE: repeated pages should still show (and not be excluded by recursive logic); DATE:2014-01-01
fxt.Init_page_create("Page:A/1", "<pages index=\"A\" from=1 to=1 />abc"); // NOTE: recursive call to self
fxt.Init_page_create("Page:D/1", "d");
String main_txt = String_.Concat_lines_nl
( "<pages index=\"A\" from=1 to=1 />"
, "text_0"
, "<pages index=\"D\" from=1 to=1/>"
, "text_1"
, "<pages index=\"D\" from=1 to=1/>"
);
fxt.Test_parse_page_wiki_str(main_txt, String_.Concat_lines_nl
( "<p>abc&#32;"
, "</p>"
, "text_0"
, "<p>d&#32;"
, "</p>"
, "text_1"
, "<p>d&#32;"
, "</p>"
));
}
@Test public void Index() {
fxt.Init_page_create("Index:A", String_.Concat_lines_nl
( "[[ignore]]"
, "[[Page:A b/1]]"
, "[[Page:A b/2]]"
, "[[Page:A b/3]]"
, "[[Page:A b/4]]"
, "[[Page:A b/5]]"
));
fxt.Init_page_create("Page:A_b/1", "A_b/1\n");
fxt.Init_page_create("Page:A_b/2", "A_b/2\n");
fxt.Init_page_create("Page:A_b/3", "A_b/3\n");
fxt.Init_page_create("Page:A_b/4", "A_b/4\n");
fxt.Init_page_create("Page:A_b/5", "A_b/5\n");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A b/2' to='A_b/4' />", String_.Concat_lines_nl
( "<p>A_b/2"
, "&#32;A_b/3"
, "&#32;A_b/4"
, "&#32;"
, "</p>"
));
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A b/2' />", String_.Concat_lines_nl // to missing
( "<p>A_b/2"
, "&#32;A_b/3"
, "&#32;A_b/4"
, "&#32;A_b/5"
, "&#32;"
, "</p>"
));
fxt.Test_parse_page_wiki_str("<pages index=\"A\" to='A b/4' />", String_.Concat_lines_nl // from missing
( "<p>A_b/1"
, "&#32;A_b/2"
, "&#32;A_b/3"
, "&#32;A_b/4"
, "&#32;"
, "</p>"
));
}
@Test public void Index_amp_encoded() { // handle ampersand encoded strings; EX: en.s:Team_Work_Wins!; DATE:2014-01-19
fxt.Init_page_create("Index:\"A\"", "[[Page:\"A\"]]");
fxt.Init_page_create("Page:\"A\"", "a");
fxt.Test_parse_page_wiki_str("<pages index=\"&quot;A&quot;\" from='&quot;A&quot;' />", "<p>a&#32;\n</p>");
}
@Test public void Index_amp_encoded_num() {// handle num-encoded vals; EX: pl.s:Zarządzenie_Nr_11_Ministra_Finansów_z_dnia_21_lipca_2008_r._w_sprawie_ustanowienia_„Dnia_Skarbowości”; DATE:2014-05-07
fxt.Init_page_create("Index:\"A\"", "[[Page:\"A\"]]");
fxt.Init_page_create("Page:\"A\"", "a");
fxt.Test_parse_page_wiki_str("<pages index=\"&#34;A&#34;\" from='&#34;A&#34;' />", "<p>a&#32;\n</p>");
}
// @Test public void Index_all() { // PURPOSE: if from / to not specified, add all titles
// fxt.Init_page_create("Index:A", String_.Concat_lines_nl
// ( "[[Page:A b/1]]"
// , "[[Page:A b/2]]"
// ));
// fxt.Init_page_create("Page:A_b/1", "A_b/1\n");
// fxt.Init_page_create("Page:A_b/2", "A_b/2\n");
// String main_txt = String_.Concat_lines_nl
// ( "<pages index=\"A\" />"
// );
// fxt.Test_parse_page_wiki_str(main_txt, String_.Concat_lines_nl
// ( "<p>A_b/1"
// , "A_b/2"
// , "</p>"
// ));
// }
@Test public void Section_failed_when_xnde() { // PURPOSE: section failed to be retrieved if preceding xnde; DATE:2014-01-15
fxt.Init_page_create("Page:A/1", "<b>a</b><section begin=\"sect_0\"/>b<section end=\"sect_0\"/>");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 fromsection='sect_0' tosection='sect_0' />", String_.Concat_lines_nl
( "<p>b&#32;"
, "</p>"
));
}
@Test public void Index_to_missing() { // PURPOSE: if no to, get rest of pages
fxt.Init_page_create("Index:A", String_.Concat_lines_nl
( "[[Page:A b/1]]"
, "[[Page:A b/2]]"
));
fxt.Init_page_create("Page:A_b/1", "A_b/1\n");
fxt.Init_page_create("Page:A_b/2", "A_b/2\n");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A b/1' />", String_.Concat_lines_nl
( "<p>A_b/1"
, "&#32;A_b/2"
, "&#32;"
, "</p>"
));
}
@Test public void Set_from_to_if_missing() { // PURPOSE: if no from / to, set from / to variables; note that earlier version of XO was correctly transcluding content, but just not updating from / to variable; fr.s:Constitution_de_la_France_de_1958_(version_initiale); DATE:2014-05-21
fxt.Init_page_create("MediaWiki:Proofreadpage_header_template", "{{{from}}}-{{{to}}}\n");
fxt.Init_page_create("Index:A", String_.Concat_lines_nl
( "[[Page:A/1]]"
, "[[Page:A/2]]"
));
fxt.Init_page_create("Page:A/1", "A/1\n");
fxt.Init_page_create("Page:A/2", "A/2\n");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='A/1' header='y' />", String_.Concat_lines_nl
( "<p>0-1"
, "A/1"
, "&#32;A/2"
, "&#32;"
, "</p>"
));
}
@Test public void Various() {
fxt.Init_page_create("Page:A/1", "a");
fxt.Init_page_create("Page:A/2", "b");
fxt.Init_page_create("Page:A/3", "c");
fxt.Init_page_create("Page:A/4", "d");
fxt.Init_page_create("Page:A/5", "e");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" include='1-2,4' />", "<p>a&#32;b&#32;d&#32;\n</p>\n"); // include
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 exclude='3' />", "<p>a&#32;b&#32;d&#32;e&#32;\n</p>\n"); // exclude
fxt.Test_parse_page_wiki_str("<pages index=\"A\" include=5 from=2 to=4 />", "<p>b&#32;c&#32;d&#32;e&#32;\n</p>\n"); // include should be sorted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=2 />", "<p>a&#32;c&#32;e&#32;\n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=4 />", "<p>a&#32;e&#32;\n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 step=10 />", "<p>a&#32;\n</p>\n"); // step
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to=3 />", "<p>c&#32;\n</p>\n"); // from = to
fxt.Test_parse_page_wiki_str("<pages index=\"A\" to=3/>", "<p>&#32;a&#32;b&#32;c&#32;\n</p>\n"); // from omitted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3/>", "<p>c&#32;d&#32;e&#32;\n</p>\n"); // to omitted
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from='' to=3 />", "<p>&#32;a&#32;b&#32;c&#32;\n</p>\n"); // from is blank
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to=''/>", "<p>c&#32;d&#32;e&#32;\n</p>\n"); // to is blank
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=3 to='4.' />", "<p>c&#32;d&#32;\n</p>\n"); // allow decimal-like number; PAGE:en.w:Haworth's/Chapter_XIX; DATE:2014-01-19
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=5 exclude=''3' />", "<p>a&#32;b&#32;c&#32;d&#32;e&#32;\n</p>\n");// exclude is invalid; EX:fr.s:Sanguis_martyrum/Première_partie/I DATE:2014-01-18
fxt.Test_parse_page_wiki_str("<pages index=\"A\" exclude from=1 to=5 />", "<p>a&#32;b&#32;c&#32;d&#32;e&#32;\n</p>\n"); // exclude empty; ru.s:ПБЭ/Гуттен,_Ульрихон DATE:2014-02-22
}
@Test public void Ref() { // PURPOSE: ref on page should show; DATE:2014-01-18
fxt.Init_page_create("Page:A/1", "a<ref>b</ref>c");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 /><references/>", String_.Concat_lines_nl
( "<p>a<sup id=\"cite_ref-0\" class=\"reference\"><a href=\"#cite_note-0\">[1]</a></sup>c&#32;"
, "</p>"
, "<ol class=\"references\">"
, "<li id=\"cite_note-0\"><span class=\"mw-cite-backlink\"><a href=\"#cite_ref-0\">^</a></span> <span class=\"reference-text\">b</span></li>"
, "</ol>"
));
}
@Test public void Tblw() { // PURPOSE: if page begins with *, {|, etc, , automatically prepend \n (just like templates); DATE:2014-01-23
fxt.Init_page_create("Page:A/1", "a");
fxt.Init_page_create("Page:A/2", "* b");
fxt.Init_page_create("Page:A/3", "c");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=3 />", String_.Concat_lines_nl
( "<p>a&#32;"
, "</p>"
, ""
, "<ul>"
, " <li> b&#32;c&#32;"
, " </li>"
, "</ul>"
, ""
));
}
@Test public void Index_various() {// varying logic depending on whether [[Index:]] has [[Page]] or <pagelist> DATE:2014-01-27
fxt.Init_page_create("Page:A/0", "A/0");
fxt.Init_page_create("Page:A/1", "A/1");
fxt.Init_page_create("Page:A/2", "A/2");
fxt.Init_page_create("Index:A", "");
// [[Index:]] has no [[Page:]] links; interpret to=1 as [[Page:A/1]]
fxt.Wiki().Cache_mgr().Free_mem__all();
fxt.Init_page_update("Index:A" , String_.Concat_lines_nl
( "no links"
));
fxt.Test_parse_page_wiki_str("<pages index='A' to=1 />", String_.Concat_lines_nl
( "<p>A/0&#32;A/1&#32;"
, "</p>"
));
// [[Index:]] has [[Page:]] links; interpret to=1 as 1st [[Page:]] in [[Index:]]'s [[Page:]] links
fxt.Wiki().Cache_mgr().Free_mem__all();
fxt.Init_page_update("Index:A" , String_.Concat_lines_nl
( "[[Page:A/0]]"
));
fxt.Test_parse_page_wiki_str("<pages index='A' to=1 />", String_.Concat_lines_nl
( "<p>A/0&#32;"
, "</p>"
));
// [[Index:]] has [[Page:]] links but also <pagelist>; interpret to=1 as [[Page:A/1]]
fxt.Wiki().Cache_mgr().Free_mem__all();
fxt.Init_page_update("Index:A" , String_.Concat_lines_nl
( "[[Page:A/0]]"
, "<pagelist/>"
));
fxt.Test_parse_page_wiki_str("<pages index='A' to=1 />", String_.Concat_lines_nl
( "<p>A/0&#32;A/1&#32;"
, "</p>"
));
}
}

View File

@@ -1,40 +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.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
public class Pp_pages_nde_recursion_tst {
private final Xop_fxt fxt = new Xop_fxt();
@Before public void Init() {fxt.Init_xtn_pages();}
@After public void term() {
fxt.Wiki().Cache_mgr().Free_mem__all();
}
@Test public void Page() { // PURPOSE: handle recursive calls on page; EX: fr.s:Page:NRF_19.djvu/19; DATE:2014-01-01
fxt.Init_page_create("Page:A/1", "<pages index=\"A\" from=1 to=1 />abc"); // NOTE: recursive call to self
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", String_.Concat_lines_nl
( "<p>abc&#32;"
, "</p>"
, ""
));
}
@Test public void Index() { // PURPOSE: handle recursive calls on index; EX: en.s:Poems_of_Italy:_selections_from_the_Odes_of_Giosue_Carducci/Before_the_Old_Castle_of_Verona; DATE:2014-01-19
fxt.Init_page_create("Index:A", "<pages index=A/>");
fxt.Test_parse_page_wiki_str("<pages index=\"A\" from=1 to=1 />", "<p>&#32;\n</p>");
}
@Test public void MediaWiki_Proofreadpage_header_template() { // PURPOSE: handle recursive calls through Proofreadpage_header_template; EX: fr.s:L<>Enfer_(Barbusse); DATE:2014-05-21
fxt.Init_page_create("MediaWiki:Proofreadpage_header_template", "<pages index=\"A\" />"); // NOTE: this is just a simulation of fr.s, which calls Module:Header_template which in turn calls preprocess to results in recursion
fxt.Test_parse_page_wiki_str("<pages index=\"A\" />", "<p>\n</p>");
}
}