mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.9.2.1'
This commit is contained in:
@@ -207,14 +207,14 @@ public class Scrib_core {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Handle_error(String err, String traceback) {
|
||||
public void Handle_error(String err) {
|
||||
String excerpt = "";
|
||||
try {
|
||||
Xot_invk src_frame = frame_current;
|
||||
if (src_frame != null)
|
||||
excerpt = String_.new_u8(cur_src, src_frame.Src_bgn(), src_frame.Src_end());
|
||||
} catch (Exception e) {Err_.Noop(e);}
|
||||
throw Err_.new_wo_type(err, "ttl", page.Ttl().Page_db_as_str(), "excerpt", excerpt, "traceback", traceback);
|
||||
throw Err_.new_wo_type(err, "ttl", page.Ttl().Page_db_as_str(), "excerpt", excerpt);
|
||||
}
|
||||
public static final String Frame_key_module = "current", Frame_key_template = "parent";
|
||||
public static final int Base_1 = 1;
|
||||
|
||||
@@ -65,7 +65,6 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
catch (Throwable e) {
|
||||
Err err = Err_.cast_or_make(e);
|
||||
Error(bfr, wiki.Msg_mgr(), err);
|
||||
bfr.Add(Gfh_tag_.Comm_bgn).Add_str_u8(err.To_str__full()).Add(Gfh_tag_.Comm_end);
|
||||
Scrib_err_filter_mgr err_filter_mgr = invoke_wkr == null ? null : invoke_wkr.Err_filter_mgr();
|
||||
if ( err_filter_mgr == null // no err_filter_mgr defined;
|
||||
|| err_filter_mgr.Count_eq_0( ) // err_filter_mgr exists, but no definitions
|
||||
@@ -76,8 +75,15 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
}
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, Err err) {Error(bfr, msg_mgr, Err_.cast_or_make(err).To_str__top_wo_args());}// NOTE: must use "short" error message to show in wikitext; DATE:2015-07-27
|
||||
public static void Error(Bry_bfr bfr, Xow_msg_mgr msg_mgr, String error) {
|
||||
// for Luaj, msg combines both err; split out traceback else error message will be very long; note that Warn_many will still log traceback; DATE:2016-09-09
|
||||
String error_visible = error;
|
||||
int traceback_pos = String_.FindFwd(error, "\nstack traceback:\n"); // NOTE: produced by LuaError.getMessage()
|
||||
if (traceback_pos != String_.Find_none)
|
||||
error_visible = String_.Mid(error_visible, 0, traceback_pos);
|
||||
|
||||
// write "Script error: some error"
|
||||
byte[] script_error_msg = msg_mgr.Val_by_id(Xol_msg_itm_.Id_scribunto_parser_error);
|
||||
error_fmtr.Bld_bfr_many(bfr, script_error_msg, error);
|
||||
error_fmtr.Bld_bfr_many(bfr, script_error_msg, error_visible);
|
||||
}
|
||||
private static final Bry_fmtr error_fmtr = Bry_fmtr.new_("<strong class=\"error\"><span class=\"scribunto-error\" id=\"mw-scribunto-error-0\">~{0}: ~{1}</span></strong>"); // NOTE: must be "error" not 'error'; iferror checks for quote not apos; DATE:2015-09-17
|
||||
public static final String Err_mod_missing = "No such module";
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Luaj_engine implements Scrib_engine {
|
||||
msg = Server_recv_call(rsp);
|
||||
else if (String_.Eq(op, "error")) {
|
||||
String err = Luaj_value_.Get_val_as_str(rsp, "value");
|
||||
core.Handle_error(err, "");
|
||||
core.Handle_error(err);
|
||||
return Keyval_.Ary_empty;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Process_engine implements Scrib_engine {
|
||||
return rsp.Values();
|
||||
}
|
||||
else if (String_.Eq(op, "error")) {
|
||||
core.Handle_error(rsp.Rslt_ary()[0].Val_to_str_or_empty(), "");
|
||||
core.Handle_error(rsp.Rslt_ary()[0].Val_to_str_or_empty());
|
||||
return Keyval_.Ary_empty;
|
||||
}
|
||||
else if (String_.Eq(op, "call")) {
|
||||
|
||||
@@ -192,18 +192,16 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
return rslt.Init_obj(GetInexpensiveTitleData(core.Page().Ttl()));
|
||||
}
|
||||
public boolean ProtectionLevels(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
// byte[] ttl_bry = args.Pull_bry(0);
|
||||
// Xowe_wiki wiki = core.Wiki();
|
||||
// Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
return rslt.Init_many_objs(""); // NOTE: always return no protection; protectionLevels are stored in different table which is currently not mirrored; DATE:2014-04-09
|
||||
return rslt.Init_obj(protectionLevels_dflt);
|
||||
}
|
||||
private static final Keyval[] protectionLevels_dflt = Keyval_.Ary(Keyval_.new_("move", Keyval_.int_(1, "sysop")), Keyval_.new_("edit", Keyval_.int_(1, "sysop"))); // protectionLevels are stored in different table which is currently not mirrored; per en.w:Module:Effective_protection_level; DATE:2014-04-09; 2016-09-07
|
||||
public boolean CascadingProtection(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
Xowe_wiki wiki = core.Wiki();
|
||||
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", Keyval_.Ary_empty), Keyval_.new_("restrictions", Keyval_.Ary_empty)); // changed sources from "false" to "{}"; DATE:2016-09-09
|
||||
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();
|
||||
|
||||
@@ -101,7 +101,7 @@ public class Scrib_lib_title_tst {
|
||||
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , "#REDIRECT [[B]]"); // fails with null
|
||||
}
|
||||
@Test public void ProtectionLevels() {
|
||||
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_protectionLevels, Object_.Ary("A") , "");
|
||||
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_protectionLevels, Object_.Ary("A") , String_.Concat_lines_nl_skip_last("1=", " move=1=sysop", " edit=1=sysop"));
|
||||
}
|
||||
@Test public void CascadingProtection() {
|
||||
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_cascadingProtection, Object_.Ary("A") , Scrib_lib_title.CascadingProtection_rv);
|
||||
|
||||
@@ -26,9 +26,9 @@ class Scrib_lib_wikibase_srl {
|
||||
rv.Add(Keyval_.new_("type", Wbase_claim_entity_type_.Itm__item.Key_str()));
|
||||
rv.Add(Keyval_.new_("schemaVersion", base_adj + 1)); // NOTE: needed by mw.wikibase.lua
|
||||
}
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_labels , Srl_langtexts (Wdata_dict_langtext.Str_language , Wdata_dict_langtext.Str_value, wdoc.Label_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_descriptions , Srl_langtexts (Wdata_dict_langtext.Str_language , Wdata_dict_langtext.Str_value, wdoc.Descr_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_sitelinks , Srl_sitelinks (Wdata_dict_sitelink.Str_site , Wdata_dict_sitelink.Str_title, wdoc.Slink_list(), base_adj));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_labels , Srl_langtexts (Wdata_dict_langtext.Itm__language.Key_str(), Wdata_dict_langtext.Itm__value.Key_str(), wdoc.Label_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_descriptions , Srl_langtexts (Wdata_dict_langtext.Itm__language.Key_str(), Wdata_dict_langtext.Itm__value.Key_str(), wdoc.Descr_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_sitelinks , Srl_sitelinks (Wdata_dict_sitelink.Itm__site.Key_str() , Wdata_dict_sitelink.Itm__title.Key_str(), wdoc.Slink_list(), base_adj));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_aliases , Srl_aliases (base_adj, wdoc.Alias_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_claims , Srl_claims (base_adj, legacy_style, wdoc.Claim_list()));
|
||||
return (Keyval[])rv.To_ary(Keyval.class);
|
||||
@@ -84,7 +84,7 @@ class Scrib_lib_wikibase_srl {
|
||||
Keyval[] rv = new Keyval[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] itm = ary[i];
|
||||
rv[i] = Keyval_.int_(i + base_adj, Keyval_.Ary(Keyval_.new_(Wdata_dict_langtext.Str_language, lang), Keyval_.new_(Wdata_dict_langtext.Str_value, String_.new_u8(itm)))); // NOTE: using same base_adj logic as claims
|
||||
rv[i] = Keyval_.int_(i + base_adj, Keyval_.Ary(Keyval_.new_(Wdata_dict_langtext.Itm__language.Key_str(), lang), Keyval_.new_(Wdata_dict_langtext.Itm__value.Key_str(), String_.new_u8(itm)))); // NOTE: using same base_adj logic as claims
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@@ -116,9 +116,9 @@ class Scrib_lib_wikibase_srl {
|
||||
List_adp list = List_adp_.New();
|
||||
list.Add(Keyval_.new_("id", pid));
|
||||
list.Add(Keyval_.new_("mainsnak", Srl_claims_prop_itm_core(visitor, pid, itm)));
|
||||
list.Add(Keyval_.new_(Wdata_dict_claim_v1.Str_rank, Wbase_claim_rank_.To_str_or_fail(itm.Rank_tid())));
|
||||
list.Add(Keyval_.new_(Wdata_dict_claim_v1.Str_rank, Wbase_claim_rank_.Reg.Get_str_or_fail(itm.Rank_tid())));
|
||||
list.Add(Keyval_.new_("type", itm.Prop_type()));
|
||||
Srl_root(list, Wdata_dict_claim.Str_qualifiers, Srl_qualifiers(visitor, itm.Qualifiers(), base_adj));
|
||||
Srl_root(list, Wdata_dict_claim.Itm__qualifiers.Key_str(), Srl_qualifiers(visitor, itm.Qualifiers(), base_adj));
|
||||
return (Keyval[])list.To_ary_and_clear(Keyval.class);
|
||||
}
|
||||
private static Keyval[] Srl_qualifiers(Scrib_lib_wikibase_srl_visitor visitor, Wbase_claim_grp_list list, int base_adj) {
|
||||
@@ -146,8 +146,8 @@ class Scrib_lib_wikibase_srl {
|
||||
if (snak_is_valued) // NOTE: novalue must not return slot (no datavalue node in json); PAGE:ru.w:Лимонов,_Эдуард_Вениаминович; DATE:2015-02-16; ALSO: sv.w:Joseph_Jaquet; DATE:2015-07-31
|
||||
rv[0] = Keyval_.new_("datavalue", Srl_claims_prop_itm_core_val(visitor, itm));
|
||||
rv[0 + snak_is_valued_adj] = Keyval_.new_("property", pid);
|
||||
rv[1 + snak_is_valued_adj] = Keyval_.new_("snaktype", Wbase_claim_value_type_.To_str_or_fail(itm.Snak_tid()));
|
||||
rv[2 + snak_is_valued_adj] = Keyval_.new_("datatype", Wbase_claim_type_.To_scrib_or_unknown(itm.Val_tid())); // NOTE: datatype needed for Modules; PAGE:eo.w:WikidataKoord; DATE:2015-11-08
|
||||
rv[1 + snak_is_valued_adj] = Keyval_.new_("snaktype", Wbase_claim_value_type_.Reg.Get_str_or_fail(itm.Snak_tid()));
|
||||
rv[2 + snak_is_valued_adj] = Keyval_.new_("datatype", Wbase_claim_type_.Get_scrib_or_unknown(itm.Val_tid())); // NOTE: datatype needed for Modules; PAGE:eo.w:WikidataKoord; DATE:2015-11-08
|
||||
return rv;
|
||||
}
|
||||
private static Keyval[] Srl_claims_prop_itm_core_val(Scrib_lib_wikibase_srl_visitor visitor, Wbase_claim_base itm) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class Scrib_lib_wikibase_srl_visitor implements Wbase_claim_visitor {
|
||||
public Keyval[] Rv() {return rv;} Keyval[] rv;
|
||||
public void Visit_str(Wbase_claim_string itm) {
|
||||
rv = new Keyval[2];
|
||||
rv[0] = Keyval_.new_(Scrib_lib_wikibase_srl.Key_type, Wbase_claim_type_.To_key_or_unknown(itm.Val_tid()));
|
||||
rv[0] = Keyval_.new_(Scrib_lib_wikibase_srl.Key_type, Wbase_claim_type_.Reg.Get_str_or(itm.Val_tid(), Wbase_claim_type_.Itm__unknown.Key_str()));
|
||||
rv[1] = Keyval_.new_(Scrib_lib_wikibase_srl.Key_value, String_.new_u8(itm.Val_str()));
|
||||
}
|
||||
public void Visit_entity(Wbase_claim_entity itm) {
|
||||
|
||||
Reference in New Issue
Block a user