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:
@@ -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