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

'v3.4.3.1'

This commit is contained in:
gnosygnu
2016-04-17 23:47:45 -04:00
parent 14471ca656
commit ad140a93fe
102 changed files with 1278 additions and 382 deletions

View File

@@ -87,13 +87,18 @@ class Luaj_value_ {
if (o == null) return LuaValue.NIL;
Class<?> c = Type_adp_.ClassOf_obj(o);
if (Object_.Eq(c, Bool_.Cls_ref_type)) return LuaValue.valueOf((Boolean)o);
else if (Object_.Eq(c, Byte_.Cls_ref_type)) return LuaValue.valueOf((Byte)o);
else if (Object_.Eq(c, Int_.Cls_ref_type)) return LuaValue.valueOf((Integer)o);
else if (Object_.Eq(c, Double_.Cls_ref_type)) return LuaValue.valueOf((Double)o);
else if (Object_.Eq(c, String_.Cls_ref_type)) return LuaValue.valueOf((String)o);
else if (Object_.Eq(c, Double_.Cls_ref_type)) return LuaValue.valueOf((Double)o);
else if (Object_.Eq(c, byte[].class)) return LuaValue.valueOf(String_.new_u8((byte[])o));
else if (Object_.Eq(c, Keyval.class)) return X_kv_ary_to_tbl(server, (Keyval)o);
else if (Object_.Eq(c, Keyval[].class)) return X_kv_ary_to_tbl(server, (Keyval[])o);
else if (Object_.Eq(c, Long_.Cls_ref_type)) return LuaValue.valueOf((Long)o);
else if (Object_.Eq(c, Scrib_lua_proc.class)) return server.Get_closure_by_id(((Scrib_lua_proc)o).Id());
else if (Object_.Eq(c, Float_.Cls_ref_type)) return LuaValue.valueOf((Float)o);
else if (Object_.Eq(c, Char_.Cls_ref_type)) return LuaValue.valueOf((char)o);
else if (Object_.Eq(c, Short_.Cls_ref_type)) return LuaValue.valueOf((Short)o);
else return LuaValue.NIL;
}
private static LuaTable X_kv_ary_to_tbl(Luaj_server server, Keyval... ary) {

View File

@@ -145,7 +145,7 @@ public class Scrib_lib_site implements Scrib_lib {
private void Bld_info(Keyval[] rv) {
Xow_wiki_props props = core.Wiki().Props();
rv[0] = Keyval_.new_("siteName" , props.Site_name());
rv[1] = Keyval_.new_("server" , props.Server());
rv[1] = Keyval_.new_("server" , Bry_.Add(gplx.core.net.Gfo_protocol_itm.Bry_relative, props.Server_name())); // NOTE: should generate "//en.wikipedia.org", not "de.wikipedia.org"; PAGE:de.w:Giro_d<5F>Italia_1996 DATE:2016-04-17
rv[2] = Keyval_.new_("scriptPath" , props.ScriptPath());
rv[3] = Keyval_.new_("stylePath" , props.StylePath());
rv[4] = Keyval_.new_("currentVersion" , props.Current_version());

View File

@@ -67,7 +67,7 @@ public class Scrib_lib_site_tst {
fxt.Test__proc__objs__nest(lib, Scrib_lib_site.Invk_init_site_for_wiki, Object_.Ary_empty, String_.Concat_lines_nl_skip_last
( "1="
, " siteName=Wikipedia"
, " server=http://en.wikipedia.org"
, " server=//en.wikipedia.org"
, " scriptPath=/wiki"
, " stylePath=/wiki/skins"
, " currentVersion=1.21wmf11"

View File

@@ -55,7 +55,7 @@ public class Scrib_lib_title implements Scrib_lib {
, Invk_getUrl = "getUrl", Invk_getContent = "getContent", Invk_getFileInfo = "getFileInfo", Invk_getCurrentTitle = "getCurrentTitle"
, Invk_protectionLevels = "protectionLevels", Invk_cascadingProtection = "cascadingProtection"
;
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getExpensiveData, Invk_getUrl, Invk_getContent, Invk_getFileInfo, Invk_getCurrentTitle, Invk_protectionLevels, Invk_cascadingProtection);
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getExpensiveData, Invk_getUrl, Invk_getContent, Invk_getFileInfo, Invk_getCurrentTitle, Invk_protectionLevels, Invk_cascadingProtection);
public boolean NewTitle(Scrib_proc_args args, Scrib_proc_rslt rslt) {
if (args.Len() == 0) return rslt.Init_obj(null); // invalid title, return null; EX:{{#invoke:Message box|fmbox}} DATE:2015-03-04
byte[] ttl_bry = args.Pull_bry(0);
@@ -95,12 +95,12 @@ public class Scrib_lib_title implements Scrib_lib {
Pfunc_urlfunc.UrlString(core.Ctx(), url_func_tid, false, ttl_bry, bfr, qry_bry);
return rslt.Init_obj(bfr.To_str_and_rls());
}
private static final Hash_adp_bry url_func_hash = Hash_adp_bry.ci_a7()
private static final Hash_adp_bry url_func_hash = Hash_adp_bry.ci_a7()
.Add_str_byte("fullUrl", Pfunc_urlfunc.Tid_full)
.Add_str_byte("localUrl", Pfunc_urlfunc.Tid_local)
.Add_str_byte("canonicalUrl", Pfunc_urlfunc.Tid_canonical);
// private static final byte[] Proto_relative = Bry_.new_a7("relative");
// private static final Hash_adp_bry proto_hash = Hash_adp_bry.ci_a7().Add_str_obj("http", Bry_.new_a7("http://")).Add_str_obj("https", Bry_.new_a7("https://")).Add_str_obj("relative", Bry_.new_a7("//")).Add_str_obj("canonical", Bry_.new_a7("1"));
// private static final byte[] Proto_relative = Bry_.new_a7("relative");
// private static final Hash_adp_bry proto_hash = Hash_adp_bry.ci_a7().Add_str_obj("http", Bry_.new_a7("http://")).Add_str_obj("https", Bry_.new_a7("https://")).Add_str_obj("relative", Bry_.new_a7("//")).Add_str_obj("canonical", Bry_.new_a7("1"));
private byte[] Parse_ns(Xowe_wiki wiki, Object ns_obj) {
if (Type_adp_.Eq_typeSafe(ns_obj, String.class))
return Bry_.new_u8(String_.cast(ns_obj));
@@ -171,7 +171,7 @@ public class Scrib_lib_title implements Scrib_lib {
);
return rslt.Init_obj(rv);
}
private static final Keyval[] GetFileInfo_absent = Keyval_.Ary(Keyval_.new_("exists", false));
private static final Keyval[] GetFileInfo_absent = Keyval_.Ary(Keyval_.new_("exists", false));
public boolean GetContent(Scrib_proc_args args, Scrib_proc_rslt rslt) {
byte[] ttl_bry = args.Pull_bry(0);
Xowe_wiki wiki = core.Wiki();
@@ -179,13 +179,13 @@ public class Scrib_lib_title implements Scrib_lib {
Xow_page_cache_itm page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm(ttl);
byte[] rv = null;
if (page_itm != null) {
byte[] redirected_src = page_itm.Redirected_src_wtxt();
byte[] redirected_src = page_itm.Wtxt__redirect();
if (redirected_src != null) { // page is redirect; use its src, not its target's src; DATE:2014-07-11
rv = redirected_src;
core.Frame_parent().Rslt_is_redirect_(true); // flag frame as redirect, so that \n won't be prepended; EX:"#REDIRECT" x> "\n#REDIRECT"
}
else
rv = page_itm.Wtxt();
rv = page_itm.Wtxt__direct();
}
return rv == null ? rslt.Init_obj(null) : rslt.Init_obj(String_.new_u8(rv));
}
@@ -204,7 +204,7 @@ public class Scrib_lib_title implements Scrib_lib {
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
return rslt.Init_obj(CascadingProtection_rv);
}
public static final Keyval[] CascadingProtection_rv = Keyval_.Ary(Keyval_.new_("sources", Bool_.N), Keyval_.new_("restrictions", Keyval_.Ary_empty));
public static final Keyval[] CascadingProtection_rv = Keyval_.Ary(Keyval_.new_("sources", Bool_.N), Keyval_.new_("restrictions", Keyval_.Ary_empty));
private Keyval[] GetInexpensiveTitleData(Xoa_ttl ttl) {
Xow_ns ns = ttl.Ns();
boolean ns_file_or_media = ns.Id_is_file_or_media(), ns_special = ns.Id_is_special();
@@ -226,6 +226,6 @@ public class Scrib_lib_title implements Scrib_lib {
if (!ns_file_or_media)
rv[rv_idx++] = Keyval_.new_("file" , false); // REF.MW: if ( $ns !== NS_FILE && $ns !== NS_MEDIA ) $ret['file'] = false;
return rv;
} private static final Xowd_page_itm tmp_db_page = Xowd_page_itm.new_tmp();
} private static final Xowd_page_itm tmp_db_page = Xowd_page_itm.new_tmp();
public static final String Key_wikitexet = "wikitext";
}

View File

@@ -40,11 +40,11 @@ public class Scrib_lib_title_tst {
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl") , "//en.wikipedia.org/wiki/Main_Page");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "action=edit") , "//en.wikipedia.org/wiki/Main_Page?action=edit");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "localUrl") , "/wiki/Main_Page");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl") , "http://en.wikipedia.org/wiki/Main_Page");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl") , "https://en.wikipedia.org/wiki/Main_Page");
// fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "", "http") , "http://en.wikipedia.org/wiki/Main_Page"); // TODO
}
@Test public void GetUrl__args_many() { // PUPROSE: GetUrl sometimes passes in kvs for qry_args; fr.w:Wikip<69>dia:Image_du_jour/Date; DATE:2013-12-24
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl", Keyval_.Ary(Keyval_.new_("action", "edit"), Keyval_.new_("preload", "b"))), "http://en.wikipedia.org/wiki/Main_Page?action=edit&preload=b");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl", Keyval_.Ary(Keyval_.new_("action", "edit"), Keyval_.new_("preload", "b"))), "https://en.wikipedia.org/wiki/Main_Page?action=edit&preload=b");
}
@Test public void MakeTitle() {
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Module", "A") , ttl_fast(828, "Module", "A"));

View File

@@ -25,7 +25,7 @@ public class Scrib_lib_uri_tst {
@Test public void Url() {
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("a&b! c" ), "/wiki/A%26b!_c");
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_fullUrl , Object_.Ary("a&b! c" ), "//en.wikipedia.org/wiki/A%26b!_c");
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_canonicalUrl , Object_.Ary("a&b! c" ), "http://en.wikipedia.org/wiki/A%26b!_c");
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_canonicalUrl , Object_.Ary("a&b! c" ), "https://en.wikipedia.org/wiki/A%26b!_c");
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("a&b! c" , "action=edit" ), "/wiki/A%26b!_c?action=edit");
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("Media:A.png" ), "/wiki/File:A.png");
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("[bad]" ), Scrib_invoke_func_fxt.Null_rslt); // handle invalid titles; EX:it.w:Billy_the_Kid; DATE:2014-01-20