1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Html: Move get_elem_val to xo.elem

This commit is contained in:
gnosygnu
2017-02-22 09:41:37 -05:00
parent 5bd3371802
commit 12848b7cf5
896 changed files with 69011 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
/*
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.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.*;
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.specials.maints.services.*;
public class Xocfg_cache_mgr__tst {
private final Xocfg_cache_mgr__fxt fxt = new Xocfg_cache_mgr__fxt();
@Before public void init() {fxt.Clear();}
@Test public void Get__wiki() {
fxt.Init__db_add("en.w", "key_1", "val_1");
fxt.Test__get("en.w", "key_1", "val_1");
fxt.Test__get("en.d", "key_1", "dflt");
}
@Test public void Get__app() {
String ctx = Xocfg_mgr.Ctx__app;
fxt.Init__db_add(ctx, "key_1", "val_1");
fxt.Test__get(ctx, "key_1", "val_1");
fxt.Test__get("en.w", "key_1", "val_1");
fxt.Test__get("en.d", "key_1", "val_1");
}
@Test public void Set__app() {
String ctx = Xocfg_mgr.Ctx__app;
fxt.Init__db_add(ctx, "key_1", "123");
fxt.Init__sub(ctx, "key_1", "key_1");
fxt.Exec__set(ctx, "key_1", "234");
fxt.Test__get(ctx, "key_1", "234");
fxt.Sub().Test__key_1(234);
}
}
class Xocfg_cache_mgr__fxt {
private Xocfg_cache_mgr mgr = new Xocfg_cache_mgr();
private int id;
public void Clear() {
gplx.dbs.Db_conn_bldr.Instance.Reg_default_mem();
Db_conn conn = Db_conn_bldr.Instance.Get_or_autocreate(true, Io_url_.new_any_("mem/xowa/wiki/en.wikipedia.org/"));
mgr.Init_by_app(conn, conn);
}
public Xocfg_cache_sub_mock Sub() {return sub;} private Xocfg_cache_sub_mock sub = new Xocfg_cache_sub_mock();
public void Init__db_add(String ctx, String key, Object val) {
Xocfg_maint_svc.Create_grp(mgr.Db_app(), "", id++, "test_grp", "", "");
Xocfg_maint_svc.Create_itm(mgr.Db_app(), "test_grp", id++, key, "", "", "wiki", String_.Cls_val_name, "dflt", "", "");
mgr.Db_usr().Set_str(ctx, key, Object_.Xto_str_strict_or_null(val));
}
public void Init__sub(String ctx, String key, String evt) {
mgr.Sub(sub, ctx, key, evt);
}
public void Test__get(String ctx, String key, String expd) {
Gftest.Eq__str(expd, mgr.Get(ctx, key), "ctx={0} key={1}", ctx, key);
}
public void Exec__set(String ctx, String key, String val) {
mgr.Set(ctx, key, val);
}
}
class Xocfg_cache_sub_mock implements Gfo_invk {
private int key_1;
public void Test__key_1(int expd) {
Gftest.Eq__int(expd, key_1);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Evt__key_1)) {key_1 = m.ReadInt("v");}
else return Gfo_invk_.Rv_unhandled;
return this;
}
public static final String Evt__key_1 = "key_1";
}

View 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.addons.apps.cfgs.specials.maints.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.maints.*;
import org.junit.*; import gplx.core.tests.*;
public class Xocfg_maint_parser__tst {
private final Xocfg_maint_parser__fxt fxt = new Xocfg_maint_parser__fxt();
@Test public void Parse_grp() {
fxt.Exec__parse("grp {id='123'; key='key_1'; owner='owner_1'; name='name_1'; help='help_1'}"
, fxt.Make__grp("owner_1", 123, "key_1", "name_1", "help_1")
);
}
@Test public void Parse_itm() {
fxt.Exec__parse("itm {id='123'; key='key_1'; owner='owner_1'; name='name_1'; help='help_1'; scope='scope_1'; type='type_1'; dflt='dflt_1'; html_atrs='html_atrs_1'; html_cls='html_cls_1'}"
, fxt.Make__itm("owner_1", 123, "key_1", "name_1", "help_1", "scope_1", "type_1", "dflt_1", "html_atrs_1", "html_cls_1")
);
}
}
class Xocfg_maint_parser__fxt {
private Xocfg_maint_parser parser = new Xocfg_maint_parser();
public void Exec__parse(String raw, Xocfg_maint_nde... expd) {
Xocfg_maint_nde[] actl = parser.Parse(raw);
Gftest.Eq__ary(expd, actl);
}
public Xocfg_maint_grp Make__grp(String owner, int id, String key, String name, String help) {
return new Xocfg_maint_grp(owner, id, key, name, help);
}
public Xocfg_maint_itm Make__itm(String owner, int id, String key, String name, String help, String scope, String type, String dflt, String html_atrs, String html_cls) {
return new Xocfg_maint_itm(owner, id, key, name, help, scope, type, dflt, html_atrs, html_cls);
}
}

View File

@@ -0,0 +1,56 @@
/*
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.addons.apps.cfgs.upgrades; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
import org.junit.*; import gplx.core.tests.*;
public class Xocfg_upgrade_mgr__tst {
private final Xocfg_upgrade_mgr__fxt fxt = new Xocfg_upgrade_mgr__fxt();
@Test public void Parse__one() {
fxt.Test__parse("app.cfgs.get('k_1', 'app').val = 'v_1';\n", Keyval_.new_("k_1", "v_1"));
}
@Test public void Parse__apos() {
fxt.Test__parse("app.cfgs.get('k_1(''k_1a'')', 'app').val = 'v_1';\n", Keyval_.new_("k_1('k_1a')", "v_1"));
}
@Test public void Parse__many() {
fxt.Test__parse
( "app.cfgs.get('k_1', 'app').val = 'v_1';\n"
+ "app.cfgs.get('k_2', 'app').val = 'v_2';\n"
, Keyval_.new_("k_1", "v_1"), Keyval_.new_("k_2", "v_2"));
}
@Test public void Parse__multi_line() {
fxt.Test__parse
( "app.cfgs.get('k_1', 'app').val = '''v_1'';\n"
+ "v_2\n"
+ "v_3';\n"
, Keyval_.new_("k_1", "'v_1';\nv_2\nv_3"));
}
@Test public void Parse__io_cmd() {
fxt.Test__parse
( "app.cfgs.get('a.cmd', 'app').val = 'cmd_1';\n"
+ "app.cfgs.get('a.args', 'app').val = 'args_1';\n"
, Keyval_.new_("a.cmd", "cmd_1|args_1"));
}
@Test public void Parse__gui_binding() {
fxt.Test__parse
( "app.cfgs.get('app.cfg.get.gui.bnds.init(''xowa.app.exit-1'').src', 'app').val = 'box=''browser'';ipt=''key.none'';';\n"
, Keyval_.new_("xowa.gui.shortcuts.xowa.app.exit-1", "browser|key.none"));
}
}
class Xocfg_upgrade_mgr__fxt {
public void Test__parse(String raw, Keyval... expd) {
Keyval[] actl = Xocfg_upgrade_mgr.Parse(Bry_.new_u8(raw));
Gftest.Eq__str(Keyval_.Ary_to_str(expd), Keyval_.Ary_to_str(actl));
}
}

View File

@@ -30,6 +30,7 @@ class Xosql_exec_html extends Xow_special_wtr__base {
}
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
Xopg_tag_mgr head_tags = page_data.Head_tags();
Xopg_tag_wtr_.Add__xoelem (head_tags, app.Fsys_mgr().Http_root());
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());

View 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.addons.apps.scripts.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.scripts.*;
import org.junit.*; import gplx.core.tests.*;
public class Xoscript_doc_head__tst {
private final Xoscript_doc_head__fxt fxt = new Xoscript_doc_head__fxt();
@Before public void init() {
fxt.Init__sect("head");
fxt.Exec__reg_marker("<!--top-->", "top", Xoscript_doc_head.Pos__default);
fxt.Exec__reg_marker("<!--bot-->", "bot");
fxt.Exec__doc__html("a<!--top-->b<!--bot-->c");
}
@Test public void Add_html() {
fxt.Exec__add_html("top", "<b>add_1</b>");
fxt.Exec__add_html("top", "<b>add_2</b>");
fxt.Test__html("a<b>add_1</b><b>add_2</b><!--top-->b<!--bot-->c");
}
@Test public void Add_html__default() {
fxt.Exec__add_html("<b>add_1</b>");
fxt.Test__html("a<b>add_1</b><!--top-->b<!--bot-->c");
}
@Test public void Add_tag() {
fxt.Exec__add_tag("top", "div", "div_body", "k0", "v0", "k1", "v1");
fxt.Test__html
( "a<div k0=\"v0\" k1=\"v1\">div_body</div>"
, "<!--top-->b<!--bot-->c");
}
@Test public void Add_js_file() {
fxt.Exec__add_js_file("top", "./a.js");
fxt.Test__html
( "a<script src=\"file:///mem/wiki/test_wiki/bin/script/a.js\" type=\"text/javascript\"></script>"
, "<!--top-->b<!--bot-->c");
}
}
class Xoscript_doc_head__fxt {
private final Xoscript_page spg;
private Xoscript_doc_sect_base sect;
public Xoscript_doc_head__fxt() {
Bry_bfr rv = Bry_bfr_.New();
Xoscript_env env = new Xoscript_env(new gplx.core.scripts.Gfo_script_engine__noop(), Io_url_.new_any_("mem/wiki/test_wiki/bin/script/"));
Xoscript_url url = new Xoscript_url("test_wiki", "test_page");
spg = new Xoscript_page(rv, env, url);
}
public void Init__sect(String sect_name) {
if (String_.Eq(sect_name, "head"))
sect = spg.doc().head();
else if (String_.Eq(sect_name, "tail"))
sect = spg.doc().tail();
}
public void Exec__doc__html(String html) {spg.doc().html(html);}
public void Exec__reg_marker(String marker, String... pos_ary) {sect.reg_marker(marker, pos_ary);}
public void Exec__add_js_file(String pos, String file) {sect.add_js_file(pos, file);}
public void Exec__add_html(String html) {sect.add_html(html);}
public void Exec__add_html(String pos, String html) {sect.add_html(pos, html);}
public void Exec__add_tag(String pos, String tag, String body, Object... head_atrs) {sect.add_tag(pos, tag, body, head_atrs);}
public void Test__html(String... expd) {
Gftest.Eq__ary__lines(String_.Concat_lines_nl_skip_last(expd), spg.doc().html(), "html");
}
}

View File

@@ -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.addons.apps.updates.specials.svcs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.updates.*; import gplx.xowa.addons.apps.updates.specials.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Xoa_update_svc__tst {
private final Xoa_update_svc__fxt fxt = new Xoa_update_svc__fxt();
@Test public void Restart_cmd() {
Io_url jar_fil = Io_url_.new_dir_("/home/gnosygnu/xowa/xowa.jar");
fxt.Test__restart_cmd("manual" , jar_fil, Op_sys.Tid_lnx, Op_sys.Bitness_64, "manual");
fxt.Test__restart_cmd("" , jar_fil, Op_sys.Tid_lnx, Op_sys.Bitness_64, "sh /home/gnosygnu/xowa/xowa_linux_64.sh");
fxt.Test__restart_cmd("" , jar_fil, Op_sys.Tid_lnx, Op_sys.Bitness_32, "sh /home/gnosygnu/xowa/xowa_linux.sh");
fxt.Test__restart_cmd("" , jar_fil, Op_sys.Tid_osx, Op_sys.Bitness_64, "sh /home/gnosygnu/xowa/xowa_macosx_64");
fxt.Test__restart_cmd("" , jar_fil, Op_sys.Tid_osx, Op_sys.Bitness_32, "sh /home/gnosygnu/xowa/xowa_macosx");
fxt.Test__restart_cmd("" , jar_fil, Op_sys.Tid_wnt, Op_sys.Bitness_64, "/home/gnosygnu/xowa/xowa_64.exe");
fxt.Test__restart_cmd("" , jar_fil, Op_sys.Tid_wnt, Op_sys.Bitness_32, "/home/gnosygnu/xowa/xowa.exe");
}
}
class Xoa_update_svc__fxt {
public void Test__restart_cmd(String current, Io_url app_url, byte op_sys_tid, byte bitness, String expd) {
Gftest.Eq__str(expd, Xoa_update_svc.App__update__restart_cmd(current, app_url, op_sys_tid, bitness), "restart_cmd");
}
}