mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.2.1'
This commit is contained in:
@@ -177,9 +177,9 @@ public class Scrib_core {
|
||||
func_rslt = engine.CallFunction(lib_mw.Mod().Fncs_get_id("executeFunction"), func_args); // call function now
|
||||
String rslt = Scrib_kv_utl_.Val_to_str(func_rslt, 0); // rslt expects an array with 1 scalar value
|
||||
bfr.Add_str_u8(rslt);
|
||||
// byte[] rslt_bry = Bry_.new_u8(rslt); // CHART
|
||||
// gplx.xowa.parsers.xndes.Xop_xnde_tkn.Hack_ctx = ctx;
|
||||
// bfr.Add(rslt_bry);
|
||||
//byte[] rslt_bry = Bry_.new_u8(rslt); // CHART
|
||||
//gplx.xowa.parsers.xndes.Xop_xnde_tkn.Hack_ctx = ctx;
|
||||
//bfr.Add(rslt_bry);
|
||||
if (!Env_.Mode_testing())
|
||||
engine.CleanupChunks(Keyval_.Ary(Keyval_.int_(proc.Id(), ""))); // cleanup chunk immediately; needed for heavy pages like en.d:water; DATE:2014-08-07
|
||||
}
|
||||
@@ -200,12 +200,6 @@ public class Scrib_core {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static Scrib_core Core() {return core;}
|
||||
public static Scrib_core Core_new_(Xoae_app app, Xop_ctx ctx) {
|
||||
core = new Scrib_core(app, ctx);
|
||||
core_invalidate_when_page_changes = false;
|
||||
return core;
|
||||
} private static Scrib_core core;
|
||||
public void Handle_error(String err, String traceback) {
|
||||
String excerpt = "";
|
||||
try {
|
||||
@@ -215,20 +209,6 @@ public class Scrib_core {
|
||||
} catch (Exception e) {Err_.Noop(e);}
|
||||
throw Err_.new_wo_type(err, "ttl", page.Ttl().Page_db_as_str(), "excerpt", excerpt, "traceback", traceback);
|
||||
}
|
||||
public static void Core_invalidate_when_page_changes() {core_invalidate_when_page_changes = true;} private static boolean core_invalidate_when_page_changes;
|
||||
public static void Core_page_changed(Xoae_page page) {
|
||||
if ( core != null // core explicitly invalidated
|
||||
|| core_invalidate_when_page_changes // core marked invalidated b/c of error in {{#invoke}} but won't be regen'd until page changes; invalidate now; PAGE:th.d:all; DATE:2014-10-03
|
||||
) {
|
||||
core_invalidate_when_page_changes = false;
|
||||
if ( core != null // null check
|
||||
&& Bry_.Eq(page.Wiki().Domain_bry(), core.Cur_wiki())) // current page is in same wiki as last page
|
||||
core.When_page_changed(page);
|
||||
else // current page is in different wiki
|
||||
Core_invalidate(); // invalidate scrib engine; note that lua will cache chunks by Module name and two modules in two different wikis can have the same name, but different data: EX:Module:Citation/CS1/Configuration and enwiki / zhwiki; DATE:2014-03-21
|
||||
}
|
||||
}
|
||||
public static void Core_invalidate() {if (core != null) core.Term(); core = null;}
|
||||
public static final String Frame_key_module = "current", Frame_key_template = "parent";
|
||||
public static final int Base_1 = 1;
|
||||
public static final String Key_mw_interface = "mw_interface";
|
||||
|
||||
@@ -22,13 +22,15 @@ public class Scrib_core_fxt {
|
||||
public Scrib_core_fxt(Xop_fxt fxt) {
|
||||
app = fxt.App();
|
||||
wiki = fxt.Wiki();
|
||||
core = Scrib_core.Core_new_(app, wiki.Parser_mgr().Ctx());
|
||||
core = wiki.Parser_mgr().Scrib().Core_make(wiki.Parser_mgr().Ctx());
|
||||
server = new Process_server_mock();
|
||||
core.Interpreter().Server_(server);
|
||||
}
|
||||
public Scrib_core_fxt Clear() {
|
||||
if (core == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
core = Scrib_core.Core_new_(app, wiki.Parser_mgr().Ctx());
|
||||
core = wiki.Parser_mgr().Scrib().Core_make(wiki.Parser_mgr().Ctx());
|
||||
server = new Process_server_mock();
|
||||
core.Interpreter().Server_(server);
|
||||
}
|
||||
|
||||
64
400_xowa/src/gplx/xowa/xtns/scribunto/Scrib_core_mgr.java
Normal file
64
400_xowa/src/gplx/xowa/xtns/scribunto/Scrib_core_mgr.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Scrib_core_mgr {
|
||||
private static final List_adp cores = List_adp_.New();
|
||||
public Scrib_core Core() {return core;} private Scrib_core core;
|
||||
public Scrib_core Core_make(Xop_ctx ctx) {
|
||||
core = new Scrib_core(ctx.App(), ctx);
|
||||
core_invalidate_when_page_changes = false;
|
||||
synchronized (cores) {
|
||||
cores.Add(core);
|
||||
}
|
||||
return core;
|
||||
}
|
||||
public void Core_term() {
|
||||
if (core != null) core.Term();
|
||||
synchronized (cores) {
|
||||
cores.Del(core);
|
||||
}
|
||||
core = null;
|
||||
}
|
||||
public void Core_invalidate_when_page_changes() {core_invalidate_when_page_changes = true;} private boolean core_invalidate_when_page_changes;
|
||||
public void Core_page_changed(Xoae_page page) {
|
||||
if ( core != null // core explicitly invalidated
|
||||
|| core_invalidate_when_page_changes // core marked invalidated b/c of error in {{#invoke}} but won't be regen'd until page changes; invalidate now; PAGE:th.d:all; DATE:2014-10-03
|
||||
) {
|
||||
if ( core != null // null check
|
||||
&& Bry_.Eq(page.Wiki().Domain_bry(), core.Cur_wiki()) // current page is in same wiki as last page
|
||||
&& !core_invalidate_when_page_changes // if core_invalidate_when_page_changes, then must call Core_term
|
||||
)
|
||||
core.When_page_changed(page);
|
||||
else // current page is in different wiki
|
||||
Core_term(); // invalidate scrib engine; note that lua will cache chunks by Module name and two modules in two different wikis can have the same name, but different data: EX:Module:Citation/CS1/Configuration and enwiki / zhwiki; DATE:2014-03-21
|
||||
core_invalidate_when_page_changes = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Term_all() {
|
||||
synchronized (cores) {
|
||||
int cores_len = cores.Len();
|
||||
for (int i = 0; i < cores_len; ++i) {
|
||||
Scrib_core core = (Scrib_core)cores.Get_at(i);
|
||||
core.Term();
|
||||
}
|
||||
cores.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,16 +38,19 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
log_time_bgn = Env_.TickCount();
|
||||
if (!invoke_wkr.Eval_bgn(ctx.Page(), mod_name, fnc_name)) return;
|
||||
}
|
||||
Scrib_core core = Scrib_core.Core();
|
||||
Scrib_core core = wiki.Parser_mgr().Scrib().Core();
|
||||
if (core == null) {
|
||||
core = Scrib_core.Core_new_(ctx.App(), ctx).Init();
|
||||
core.When_page_changed(ctx.Page());
|
||||
synchronized (this) {
|
||||
core = wiki.Parser_mgr().Scrib().Core_make(ctx);
|
||||
core.Init();
|
||||
core.When_page_changed(ctx.Page());
|
||||
}
|
||||
}
|
||||
byte[] mod_raw = null;
|
||||
Scrib_lua_mod mod = core.Mods_get(mod_name);
|
||||
if (mod == null) {
|
||||
Xow_ns module_ns = wiki.Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__module);
|
||||
Xoa_ttl mod_ttl = Xoa_ttl.parse(wiki, Bry_.Add(module_ns.Name_db_w_colon(), mod_name));
|
||||
Xoa_ttl mod_ttl = Xoa_ttl.Parse(wiki, Bry_.Add(module_ns.Name_db_w_colon(), mod_name));
|
||||
mod_raw = wiki.Cache_mgr().Page_cache().Get_or_load_as_src(mod_ttl);
|
||||
if (mod_raw == null) {Error(bfr, wiki.Msg_mgr(), Err_mod_missing); return;} // EX: "{{#invoke:missing_mod}}"
|
||||
}
|
||||
@@ -68,7 +71,7 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
|| err_filter_mgr.Count_eq_0( ) // err_filter_mgr exists, but no definitions
|
||||
|| !err_filter_mgr.Match(String_.new_u8(mod_name), String_.new_u8(fnc_name), err.To_str__msg_only())) // NOTE: must be To_str__msg_only; err_filter_mgr has defintion and it doesn't match current; print warn; DATE:2015-07-24
|
||||
ctx.App().Usr_dlg().Warn_many("", "", "invoke failed: ~{0} ~{1} ~{2}", ctx.Page().Ttl().Raw(), String_.new_u8(src, self.Src_bgn(), self.Src_end()), err.To_str__log());
|
||||
Scrib_core.Core_invalidate_when_page_changes(); // NOTE: invalidate core when page changes, not for rest of page, else page with many errors will be very slow due to multiple invalidations; PAGE:th.d:all; DATE:2014-10-03
|
||||
wiki.Parser_mgr().Scrib().Core_invalidate_when_page_changes(); // NOTE: invalidate core when page changes, not for rest of page, else page with many errors will be very slow due to multiple invalidations; PAGE:th.d:all; DATE:2014-10-03
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -76,6 +79,6 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
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);
|
||||
}
|
||||
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
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Scrib_invoke_func_fxt {
|
||||
public Scrib_core Core() {return core;}
|
||||
public void Clear_for_invoke() {
|
||||
fxt = new Xop_fxt(); // NOTE: don't try to cache fxt on func_fxt level; causes errors in Language_lib
|
||||
core_fxt = new Scrib_core_fxt();
|
||||
core_fxt = new Scrib_core_fxt(fxt);
|
||||
core_fxt.Clear();
|
||||
core_fxt.Init_lib_mw();
|
||||
core = core_fxt.Core();
|
||||
|
||||
@@ -17,26 +17,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
public class Scrib_proc_mgr {
|
||||
private Ordered_hash hash = Ordered_hash_.New();
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public void Clear() {hash.Clear();}
|
||||
public Scrib_proc Get_by_key(String key) {return (Scrib_proc)hash.Get_by(key);}
|
||||
public Scrib_proc Get_at(int i) {return (Scrib_proc)hash.Get_at(i);}
|
||||
public Scrib_proc Get_by_key(String key) {synchronized (hash) {return (Scrib_proc)hash.Get_by(key);}}
|
||||
public Scrib_proc Get_at(int i) {synchronized (hash) {return (Scrib_proc)hash.Get_at(i);}}
|
||||
public void Set(String key, Scrib_proc proc) {
|
||||
hash.Add_if_dupe_use_nth(key, proc); // WORKAROUND: Add_if_dupe_use_nth b/c some libraries reuse proc name; EX: getGlobalSiteId is used by mw.wikibase.lua and mw.wikibase.entity.lua
|
||||
// synchronized (hash) { // LOCK:DELETE; DATE:2016-07-06
|
||||
hash.Add_if_dupe_use_nth(key, proc); // WORKAROUND: Add_if_dupe_use_nth b/c some libraries reuse proc name; EX: getGlobalSiteId is used by mw.wikibase.lua and mw.wikibase.entity.lua
|
||||
// }
|
||||
}
|
||||
public Scrib_proc Set(Scrib_lib lib, String proc_name, int proc_id) {
|
||||
Scrib_proc proc = new Scrib_proc(lib, proc_name, proc_id);
|
||||
Set(proc.Proc_key(), proc);
|
||||
return proc;
|
||||
}
|
||||
public int Len() {return hash.Count();}
|
||||
public int Len() {synchronized (hash) {return hash.Count();}}
|
||||
public void Init_by_lib(Scrib_lib lib, String[] proc_names) {
|
||||
hash.Clear();
|
||||
int len = proc_names.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String proc_name = proc_names[i];
|
||||
Scrib_proc proc = new Scrib_proc(lib, proc_name, i); // ASSUME: Proc_id consts matches order in which Init is called
|
||||
hash.Add(proc_name, proc);
|
||||
synchronized (hash) {
|
||||
hash.Clear();
|
||||
int len = proc_names.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String proc_name = proc_names[i];
|
||||
Scrib_proc proc = new Scrib_proc(lib, proc_name, i); // ASSUME: Proc_id consts matches order in which Init is called
|
||||
hash.Add(proc_name, proc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Scrib_xtn_mgr extends Xox_mgr_base {
|
||||
public byte Engine_type() {return engine_type;} private byte engine_type = Scrib_engine_type.Type_luaj;
|
||||
public void Engine_type_(byte cmd) {
|
||||
engine_type = cmd;
|
||||
Scrib_core.Core_invalidate();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all();
|
||||
}
|
||||
public int Lua_timeout() {return lua_timeout;} private int lua_timeout = 4000;
|
||||
public int Lua_timeout_polling() {return lua_timeout_polling;} private int lua_timeout_polling = 1;
|
||||
@@ -36,7 +36,7 @@ public class Scrib_xtn_mgr extends Xox_mgr_base {
|
||||
public boolean Luaj_debug_enabled() {return luaj_debug_enabled;} private boolean luaj_debug_enabled;
|
||||
public void Luaj_debug_enabled_(boolean v) {
|
||||
this.luaj_debug_enabled = v;
|
||||
Scrib_core.Core_invalidate(); // restart server in case luaj caches any debug data
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all();// restart server in case luaj caches any debug data
|
||||
}
|
||||
public Xop_log_invoke_wkr Invoke_wkr() {return invoke_wkr;} private Xop_log_invoke_wkr invoke_wkr;
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -19,15 +19,17 @@ package gplx.xowa.xtns.scribunto.engines.luaj; import gplx.*; import gplx.xowa.*
|
||||
import org.luaj.vm2.*; import org.luaj.vm2.lib.*; import org.luaj.vm2.lib.jse.*;
|
||||
import gplx.xowa.xtns.scribunto.engines.process.*;
|
||||
public class Luaj_engine implements Scrib_engine {
|
||||
private final Luaj_server_func_recv func_recv;
|
||||
private final Luaj_server_func_dbg func_dbg;
|
||||
private final Scrib_proc_mgr proc_mgr;
|
||||
private final Scrib_core core;
|
||||
private Luaj_server server;
|
||||
private Scrib_proc_mgr proc_mgr;
|
||||
private Scrib_core core;
|
||||
public Luaj_engine(Xoae_app app, Scrib_core core, boolean debug_enabled) {
|
||||
this.core = core;
|
||||
server = new Luaj_server(core, debug_enabled);
|
||||
proc_mgr = core.Proc_mgr();
|
||||
Luaj_server_func_recv.Instance.Engine_(this);
|
||||
Luaj_server_func_dbg.Instance.Core_(core);
|
||||
this.proc_mgr = core.Proc_mgr();
|
||||
this.func_recv = new Luaj_server_func_recv(this);
|
||||
this.func_dbg = new Luaj_server_func_dbg(core);
|
||||
this.server = new Luaj_server(func_recv, func_dbg);
|
||||
}
|
||||
public Scrib_server Server() {return server;} public void Server_(Scrib_server v) {server = (Luaj_server)v;}
|
||||
public boolean Dbg_print() {return dbg_print;} public void Dbg_print_(boolean v) {dbg_print = v;} private boolean dbg_print;
|
||||
|
||||
@@ -20,21 +20,26 @@ import gplx.core.envs.*;
|
||||
import org.luaj.vm2.*; import org.luaj.vm2.lib.*; import org.luaj.vm2.lib.jse.*;
|
||||
import gplx.xowa.xtns.scribunto.engines.process.*;
|
||||
public class Luaj_server implements Scrib_server {
|
||||
private final Luaj_server_func_recv func_recv;
|
||||
private final Luaj_server_func_dbg func_dbg;
|
||||
private LuaTable server;
|
||||
public Luaj_server(Scrib_core core, boolean debug_enabled) {}
|
||||
public static Globals Globals_singleton;
|
||||
public Luaj_server(Luaj_server_func_recv func_recv, Luaj_server_func_dbg func_dbg) {
|
||||
this.func_recv = func_recv;
|
||||
this.func_dbg = func_dbg;
|
||||
}
|
||||
private Globals luaj_globals;
|
||||
public void Init(String... init_args) {
|
||||
Globals_singleton = JsePlatform.standardGlobals();
|
||||
Globals_singleton.load(new DebugLib());
|
||||
Globals_singleton.load(new MWClient());
|
||||
Globals_singleton.set("dbg", Luaj_server_func_dbg.Instance);
|
||||
luaj_globals = JsePlatform.standardGlobals();
|
||||
luaj_globals.load(new DebugLib());
|
||||
luaj_globals.load(new MWClient(luaj_globals, func_recv));
|
||||
luaj_globals.set("dbg", func_dbg);
|
||||
String root_str = init_args[2];
|
||||
if (Op_sys.Cur().Tid_is_wnt())
|
||||
root_str = String_.Replace(root_str, Op_sys.Wnt.Fsys_dir_spr_str(), Op_sys.Lnx.Fsys_dir_spr_str());
|
||||
LuaValue main_fil_val = LuaValue.valueOf(root_str + "engines/Luaj/mw_main.lua");
|
||||
LuaValue package_val = Globals_singleton.get("package");
|
||||
LuaValue package_val = luaj_globals.get("package");
|
||||
package_val.rawset("path", LuaValue.valueOf(root_str + "engines/Luaj/?.lua;" + root_str + "engines/LuaCommon/lualib/?.lua"));
|
||||
server = (LuaTable)Globals_singleton.get("dofile").call(main_fil_val);
|
||||
server = (LuaTable)luaj_globals.get("dofile").call(main_fil_val);
|
||||
}
|
||||
public LuaTable Dispatch(LuaTable msg) {
|
||||
return (LuaTable)server.method(Val_server_recv, msg);
|
||||
@@ -72,10 +77,16 @@ public class Luaj_server implements Scrib_server {
|
||||
* @return Value that will be returned in the require() call. In this case,
|
||||
* it is the library itself.
|
||||
*/
|
||||
private final Globals luaj_globals;
|
||||
private final Luaj_server_func_recv func_recv;
|
||||
public MWClient(Globals luaj_globals, Luaj_server_func_recv func_recv) {
|
||||
this.luaj_globals = luaj_globals;
|
||||
this.func_recv = func_recv;
|
||||
}
|
||||
public LuaValue call(LuaValue libname) {
|
||||
LuaValue library = tableOf();
|
||||
library.set("client_recv", Luaj_server_func_recv.Instance);
|
||||
LuaValue env = gplx.xowa.xtns.scribunto.engines.luaj.Luaj_server.Globals_singleton;
|
||||
library.set("client_recv", func_recv);
|
||||
LuaValue env = luaj_globals;
|
||||
env.set( "MWClient", library );
|
||||
return library;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.Varargs;
|
||||
import org.luaj.vm2.lib.VarArgFunction;
|
||||
public class Luaj_server_func_dbg extends VarArgFunction {
|
||||
private Scrib_core core;
|
||||
public void Core_(Scrib_core v) {this.core = v;}
|
||||
private final Scrib_core core;
|
||||
public Luaj_server_func_dbg(Scrib_core v) {this.core = v;}
|
||||
public Varargs invoke(Varargs args) {
|
||||
int len = args.narg();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
@@ -36,5 +36,4 @@ public class Luaj_server_func_dbg extends VarArgFunction {
|
||||
core.Page().Html_data().Xtn_scribunto_dbg_(bfr.To_bry_and_clear());
|
||||
return NONE;
|
||||
}
|
||||
public static Luaj_server_func_dbg Instance = new Luaj_server_func_dbg();
|
||||
}
|
||||
|
||||
@@ -20,13 +20,12 @@ import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.lib.OneArgFunction;
|
||||
public class Luaj_server_func_recv extends OneArgFunction {
|
||||
private Luaj_engine engine;
|
||||
public void Engine_(Luaj_engine v) {this.engine = v;}
|
||||
private final Luaj_engine engine;
|
||||
public Luaj_server_func_recv(Luaj_engine v) {this.engine = v;}
|
||||
public LuaValue call(LuaValue tbl_val) {
|
||||
LuaTable tbl = (LuaTable)tbl_val;
|
||||
String op = Luaj_value_.Get_val_as_str(tbl, "op");
|
||||
if (!String_.Eq(op, "call")) throw Err_.new_wo_type("luaj_recvr only processes op calls");
|
||||
return engine.Server_recv_call(tbl);
|
||||
}
|
||||
public static Luaj_server_func_recv Instance = new Luaj_server_func_recv();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class Luaj_value_ {
|
||||
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, Char_.Cls_ref_type)) return LuaValue.valueOf((Character)o);
|
||||
else if (Object_.Eq(c, Short_.Cls_ref_type)) return LuaValue.valueOf((Short)o);
|
||||
else return LuaValue.NIL;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Mock_scrib_fxt {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app, domain, app.Lang_mgr().Get_by_or_new(Bry_.new_u8(lang)));
|
||||
parser_fxt = new Xop_fxt(app, wiki); // NOTE: always new(); don't try to cache; causes errors in Language_lib
|
||||
core = Scrib_core.Core_new_(app, wiki.Parser_mgr().Ctx());
|
||||
core = wiki.Parser_mgr().Scrib().Core_make(wiki.Parser_mgr().Ctx());
|
||||
core.Engine_(engine); engine.Clear();
|
||||
core.Interpreter().Server_(server);
|
||||
Xot_invk parent_frame = new Xot_invk_temp(true); parent_frame.Frame_tid_(Scrib_frame_.Tid_null);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class Scrib_lib_language implements Scrib_lib {
|
||||
}
|
||||
public boolean IsValidCode(Scrib_proc_args args, Scrib_proc_rslt rslt) { // REF.MW: Language.php!isValidCode
|
||||
byte[] lang_code = args.Pull_bry(0);
|
||||
boolean valid = Xoa_ttl.parse(core.Wiki(), lang_code) != null; // NOTE: MW calls Title::getTitleInvalidRegex()
|
||||
boolean valid = Xoa_ttl.Parse(core.Wiki(), lang_code) != null; // NOTE: MW calls Title::getTitleInvalidRegex()
|
||||
if (valid) {
|
||||
int len = lang_code.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
@@ -99,11 +99,11 @@ class Scrib_lib_message_data {
|
||||
if (data_ttl == null)
|
||||
ttl = ctx.Page().Ttl();
|
||||
else
|
||||
ttl = Xoa_ttl.parse(wiki, data_ttl);
|
||||
ttl = Xoa_ttl.Parse(wiki, data_ttl);
|
||||
}
|
||||
if (raw_msg_key != null) {
|
||||
Xol_msg_itm raw_msg_itm = new Xol_msg_itm(-1, Bry_.Empty);
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New(); // wiki.Utl__bfr_mkr().Get_b512();
|
||||
byte[] raw_msg_val = Xoa_gfs_php_mgr.Xto_gfs(tmp_bfr, raw_msg_key);
|
||||
Xol_msg_itm_.update_val_(raw_msg_itm, raw_msg_val);
|
||||
byte[] raw_msg_rv = wiki.Msg_mgr().Val_by_itm(tmp_bfr, raw_msg_itm, args);
|
||||
|
||||
@@ -95,12 +95,12 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
String mod_code = fsys_mgr.Get_or_null(mod_name); // check if mod_name a file in /lualib/ directoryScribunto .lua file (in /lualib/)
|
||||
if (mod_code != null)
|
||||
return rslt.Init_obj(core.Interpreter().LoadString("@" + mod_name + ".lua", mod_code));
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, Bry_.new_u8(mod_name));// NOTE: should have Module: prefix
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(cur_wiki, Bry_.new_u8(mod_name));// NOTE: should have Module: prefix
|
||||
if (ttl == null) return rslt.Init_ary_empty();
|
||||
Xoae_page page = cur_wiki.Data_mgr().Load_page_by_ttl(ttl);
|
||||
if (page.Missing()) return rslt.Init_ary_empty();
|
||||
if (page.Db().Page().Exists_n()) return rslt.Init_ary_empty();
|
||||
Scrib_lua_mod mod = new Scrib_lua_mod(core, mod_name);
|
||||
return rslt.Init_obj(mod.LoadString(String_.new_u8(page.Data_raw())));
|
||||
return rslt.Init_obj(mod.LoadString(String_.new_u8(page.Db().Text().Text_bry())));
|
||||
}
|
||||
public boolean LoadPHPLibrary(Scrib_proc_args args, Scrib_proc_rslt rslt) { // NOTE: noop; Scribunto uses this to load the Scribunto_*Library classses (EX: Scribunto_TitleLibrary); DATE:2015-01-21
|
||||
return rslt.Init_obj(null);
|
||||
@@ -224,7 +224,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
String text_str = args.Pull_str(1);
|
||||
byte[] text_bry = Bry_.new_u8(text_str);
|
||||
Xop_root_tkn tmp_root = ctx.Tkn_mkr().Root(text_bry);
|
||||
Xop_ctx tmp_ctx = Xop_ctx.new_sub_(cur_wiki);
|
||||
Xop_ctx tmp_ctx = Xop_ctx.new_sub_(core.Ctx());
|
||||
int args_adj = Scrib_frame_.Get_arg_adj(frame_tid);
|
||||
int args_len = frame.Args_len() - args_adj;
|
||||
Keyval[] kv_args = new Keyval[args_len];
|
||||
@@ -244,6 +244,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
tmp_root.Tmpl_evaluate(tmp_ctx, text_bry, mock_frame, tmp_bfr);
|
||||
return rslt.Init_obj(tmp_bfr.To_str_and_rls());
|
||||
}
|
||||
private static final Xol_func_itm finder = new Xol_func_itm();
|
||||
public boolean CallParserFunction(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
String frame_id = args.Pull_str(0);
|
||||
int frame_tid = Scrib_frame_.Get_frame_tid(frame_id);
|
||||
@@ -254,11 +255,17 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
Bry_obj_ref fnc_name_ref = Bry_obj_ref.New(fnc_name);
|
||||
Keyval[] parser_func_args = CallParserFunction_parse_args(cur_wiki.Appe().Utl_num_parser(), argx_ref, fnc_name_ref, args.Ary());
|
||||
Xot_invk_mock frame = Xot_invk_mock.new_(parent_frame.Defn_tid(), 0, fnc_name, parser_func_args); // pass something as frame_ttl; choosng fnc_name; DATE:2014-09-21
|
||||
Xol_func_itm finder = cur_wiki.Lang().Func_regy().Find_defn(fnc_name, 0, fnc_name_len);
|
||||
Xot_defn defn = finder.Func();
|
||||
|
||||
|
||||
Xot_defn defn;
|
||||
synchronized (finder) {
|
||||
cur_wiki.Lang().Func_regy().Find_defn(finder, fnc_name, 0, fnc_name_len);
|
||||
defn = finder.Func();
|
||||
}
|
||||
|
||||
if (defn == Xot_defn_.Null) throw Err_.new_wo_type("callParserFunction: function was not found", "function", String_.new_u8(fnc_name));
|
||||
Bry_bfr bfr = cur_wiki.Utl__bfr_mkr().Get_k004();
|
||||
Xop_ctx fnc_ctx = Xop_ctx.new_sub_(cur_wiki);
|
||||
Xop_ctx fnc_ctx = Xop_ctx.new_sub_(core.Ctx());
|
||||
fnc_ctx.Parse_tid_(Xop_parser_.Parse_tid_page_tmpl); // default xnde names to template; needed for test, but should be in place; DATE:2014-06-27
|
||||
Xot_invk_tkn.Eval_func(fnc_ctx, src, parent_frame, frame, bfr, defn, argx_ref.Val());
|
||||
bfr.Mkr_rls();
|
||||
@@ -302,10 +309,10 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
public boolean ExpandTemplate(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
String ttl_str = args.Pull_str(1);
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, ttl_bry); // parse directly; handles titles where template is already part of title; EX: "Template:A"
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(cur_wiki, ttl_bry); // parse directly; handles titles where template is already part of title; EX: "Template:A"
|
||||
if (ttl == null) return rslt.Init_ary_empty(); // invalid ttl;
|
||||
if (!ttl.ForceLiteralLink() && ttl.Ns().Id_is_main()) // title is not literal and is not prefixed with Template; parse again as template; EX: ":A" and "Template:A" are fine; "A" is parsed again as "Template:A"
|
||||
ttl = Xoa_ttl.parse(cur_wiki, Bry_.Add(cur_wiki.Ns_mgr().Ns_template().Name_db_w_colon(), ttl_bry)); // parse again, but add "Template:"
|
||||
ttl = Xoa_ttl.Parse(cur_wiki, Bry_.Add(cur_wiki.Ns_mgr().Ns_template().Name_db_w_colon(), ttl_bry)); // parse again, but add "Template:"
|
||||
Keyval[] args_ary = args.Pull_kv_ary_safe(2);
|
||||
// BLOCK.bgn:Xot_invk_tkn.Transclude; cannot reuse b/c Transclude needs invk_tkn, and invk_tkn is manufactured late; DATE:2014-01-02
|
||||
byte[] sub_src = null;
|
||||
@@ -351,10 +358,10 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
Xoa_ttl ttl = null;
|
||||
if (Type_adp_.ClassOf_obj(ttl_obj) != String.class) { // title = false
|
||||
byte[] ttl_bry = frame.Frame_ttl();
|
||||
ttl = Xoa_ttl.parse(core.Wiki(), ttl_bry);
|
||||
ttl = Xoa_ttl.Parse(core.Wiki(), ttl_bry);
|
||||
}
|
||||
else {
|
||||
ttl = Xoa_ttl.parse(cur_wiki, Bry_.new_u8((String)ttl_obj));
|
||||
ttl = Xoa_ttl.Parse(cur_wiki, Bry_.new_u8((String)ttl_obj));
|
||||
if (ttl == null) throw Err_.new_wo_type("newChild: invalid title", "title", (String)ttl_obj);
|
||||
}
|
||||
Keyval[] args_ary = args.Pull_kv_ary_safe(2);
|
||||
|
||||
@@ -70,13 +70,11 @@ public class Scrib_lib_site implements Scrib_lib {
|
||||
}
|
||||
else {
|
||||
int rv_count = 0;
|
||||
switch (ctg_type) {
|
||||
case "all": rv_count = ctg_itm.All; break;
|
||||
case "pages": rv_count = ctg_itm.Pages; break;
|
||||
case "subcats": rv_count = ctg_itm.Subcs; break;
|
||||
case "files": rv_count = ctg_itm.Files; break;
|
||||
default: throw Scrib_err.Make__err__arg(Invk_pagesInCategory, 2, ctg_type, "one of '*', 'all', 'pages', 'subcats', or 'files'");
|
||||
}
|
||||
if (String_.Eq(ctg_type, "all")) rv_count = ctg_itm.All;
|
||||
else if (String_.Eq(ctg_type, "pages")) rv_count = ctg_itm.Pages;
|
||||
else if (String_.Eq(ctg_type, "subcats")) rv_count = ctg_itm.Subcs;
|
||||
else if (String_.Eq(ctg_type, "files")) rv_count = ctg_itm.Files;
|
||||
else throw Scrib_err.Make__err__arg(Invk_pagesInCategory, 2, ctg_type, "one of '*', 'all', 'pages', 'subcats', or 'files'");
|
||||
return rslt.Init_obj(rv_count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.langs.jsons.*;
|
||||
class Scrib_lib_text__json_util {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
public void Reindex_arrays(Scrib_lib_text__reindex_data rv, Keyval[] kv_ary, boolean is_encoding) {
|
||||
int next = 0;
|
||||
if (is_encoding) {
|
||||
@@ -112,10 +112,10 @@ class Scrib_lib_text__json_util {
|
||||
}
|
||||
private Object Decode_ary(Json_ary ary) {
|
||||
int len = ary.Len();
|
||||
Object rv = Array_.Create(Object.class, len);
|
||||
Object[] rv = new Object[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm itm = ary.Get_at(i);
|
||||
Array_.Set_at(rv, i, Decode_obj(itm));
|
||||
rv[i] = Decode_obj(itm);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class KeyVal__sorter__key_is_numeric implements gplx.core.lists.ComparerAble {
|
||||
int rhs_int = Int_.parse_or(rhs_itm.Key(), Int_.Min_value);
|
||||
return CompareAble_.Compare(lhs_int, rhs_int);
|
||||
}
|
||||
public static final KeyVal__sorter__key_is_numeric Instance = new KeyVal__sorter__key_is_numeric(); KeyVal__sorter__key_is_numeric() {}
|
||||
public static final KeyVal__sorter__key_is_numeric Instance = new KeyVal__sorter__key_is_numeric(); KeyVal__sorter__key_is_numeric() {}
|
||||
}
|
||||
class Scrib_lib_text__reindex_data {
|
||||
public boolean Rv_is_kvy() {return rv_is_kvy;} private boolean rv_is_kvy;
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
ttl_bry = bfr.Add(ns_bry).Add_byte(Byte_ascii.Colon).Add(ttl_bry).To_bry_and_rls();
|
||||
}
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(core.Wiki(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(core.Wiki(), ttl_bry);
|
||||
if (ttl == null) return rslt.Init_obj(null); // invalid title; exit; matches MW logic
|
||||
return rslt.Init_obj(GetInexpensiveTitleData(ttl));
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
byte url_func_tid = ((Byte_obj_val)url_func_obj).Val();
|
||||
byte[] qry_bry = args.Extract_qry_args(wiki, 2);
|
||||
// byte[] proto = Scrib_kv_utl_.Val_to_bry_or(values, 3, null); // NOTE: Scribunto has more conditional logic around argument 2 and setting protocols; DATE:2014-07-07
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
Bry_bfr bfr = wiki.Appe().Utl__bfr_mkr().Get_b512();
|
||||
//if (url_func_tid == Pfunc_urlfunc.Tid_full) {
|
||||
// if (proto == null) proto = Proto_relative;
|
||||
@@ -124,13 +124,13 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
tmp_bfr.Add(ns_bry).Add_byte(Byte_ascii.Colon);
|
||||
tmp_bfr.Add_str_u8(ttl_str);
|
||||
if (anchor_str != null) tmp_bfr.Add_byte(Byte_ascii.Hash).Add_str_u8(anchor_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, tmp_bfr.To_bry_and_rls());
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, tmp_bfr.To_bry_and_rls());
|
||||
if (ttl == null) return rslt.Init_obj(null); // invalid title; exit;
|
||||
return rslt.Init_obj(GetInexpensiveTitleData(ttl));
|
||||
}
|
||||
public boolean GetExpensiveData(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(core.Wiki(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(core.Wiki(), ttl_bry);
|
||||
if (ttl == Xoa_ttl.Null) return rslt.Init_null();
|
||||
// TODO_OLD: MW does extra logic here to cache ttl in ttl cache to avoid extra title lookups
|
||||
boolean ttl_exists = false, ttl_redirect = false; int ttl_id = 0;
|
||||
@@ -151,11 +151,11 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
public boolean GetFileInfo(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);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
if ( ttl == null
|
||||
|| !ttl.Ns().Id_is_file_or_media()
|
||||
) return rslt.Init_obj(GetFileInfo_absent);
|
||||
if (ttl.Ns().Id_is_media()) ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__file, ttl.Page_db()); // if [[Media:]] change to [[File:]]; theoretically, this should be changed in Get_page, but not sure if I want to put this logic that low; DATE:2014-01-07
|
||||
if (ttl.Ns().Id_is_media()) ttl = Xoa_ttl.Parse(wiki, Xow_ns_.Tid__file, ttl.Page_db()); // if [[Media:]] change to [[File:]]; theoretically, this should be changed in Get_page, but not sure if I want to put this logic that low; DATE:2014-01-07
|
||||
// Xoae_page file_page = Pfunc_filepath.Load_page(wiki, ttl); // EXPENSIVE
|
||||
// boolean exists = !file_page.Missing();
|
||||
// if (!exists) return rslt.Init_obj(Keyval_.Ary(Keyval_.new_("exists", false))); // NOTE: do not reinstate; will exit early if commons is not installed; DATE:2015-01-25; NOTE: Media objects are often flagged as absent in offline mode
|
||||
@@ -175,7 +175,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
public boolean GetContent(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);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
Xow_page_cache_itm page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm_2(ttl);
|
||||
byte[] rv = null;
|
||||
if (page_itm != null) {
|
||||
@@ -195,13 +195,13 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
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);
|
||||
// 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
|
||||
}
|
||||
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);
|
||||
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));
|
||||
|
||||
@@ -53,7 +53,6 @@ public class Scrib_lib_title_tst {
|
||||
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "A", "b") , ttl_fast(10, "Template", "A", "b"));
|
||||
fxt.Parser_fxt().Wiki().Xwiki_mgr().Add_by_atrs("fr", "fr.wikipedia.org");
|
||||
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "A", "b", "fr") , ttl_fast(0, "", "Template:A", "b", "fr"));
|
||||
fxt.Parser_fxt().Init_log_(gplx.xowa.wikis.ttls.Xop_ttl_log.Invalid_char);
|
||||
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "a[b"), Scrib_invoke_func_fxt.Null_rslt_ary); // PURPOSE: handle bad MakeTitle cmds; PAGE:en.w:Disney; DATE:2013-10-15
|
||||
}
|
||||
@Test public void GetExpensiveData_absent() {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Scrib_lib_uri implements Scrib_lib {
|
||||
}
|
||||
private static final int Proc_anchorEncode = 0, Proc_localUrl = 1, Proc_fullUrl = 2, Proc_canonicalUrl = 3, Proc_init_uri_for_page = 4;
|
||||
public static final String Invk_anchorEncode = "anchorEncode", Invk_localUrl = "localUrl", Invk_fullUrl = "fullUrl", Invk_canonicalUrl = "canonicalUrl", Invk_init_uri_for_page = "init_uri_for_page";
|
||||
private static final String[] Proc_names = String_.Ary(Invk_anchorEncode, Invk_localUrl, Invk_fullUrl, Invk_canonicalUrl, Invk_init_uri_for_page);
|
||||
private static final String[] Proc_names = String_.Ary(Invk_anchorEncode, Invk_localUrl, Invk_fullUrl, Invk_canonicalUrl, Invk_init_uri_for_page);
|
||||
public boolean AnchorEncode(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] raw_bry = args.Pull_bry(0);
|
||||
Bry_bfr bfr = core.App().Utl__bfr_mkr().Get_b512();
|
||||
@@ -57,7 +57,7 @@ public class Scrib_lib_uri implements Scrib_lib {
|
||||
Xowe_wiki wiki = core.Wiki();
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
byte[] qry_bry = args.Extract_qry_args(wiki, 1);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
if (ttl == null) return rslt.Init_null();
|
||||
Bry_bfr bfr = core.App().Utl__bfr_mkr().Get_b512();
|
||||
if (ttl.Ns().Id() == Xow_ns_.Tid__media) { // change "Media:" -> "File:"
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
public boolean GetEntityId(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);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
byte[] rv = wiki.Appe().Wiki_mgr().Wdata_mgr().Qid_mgr.Get_or_null(wiki, ttl); if (rv == null) rv = Bry_.Empty;
|
||||
return rslt.Init_obj(rv);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " numeric-id:'3'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'wikibase-entityid'"
|
||||
, " datatype:'wikibase-item'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -212,7 +212,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " numeric-id:'3'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'wikibase-entityid'"
|
||||
, " datatype:'wikibase-item'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, " p2:"
|
||||
@@ -226,7 +226,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " numeric-id:'3'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'wikibase-entityid'"
|
||||
, " datatype:'wikibase-item'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.junit.*;
|
||||
public class Xow_wiki_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_wiki_fxt fxt = new Xow_wiki_fxt();
|
||||
@Test public void Load_page_and_parse() { // PURPOSE.fix: unknown page causes null reference error in scribunto; DATE:2013-08-27
|
||||
Scrib_core.Core_new_(fxt.Fxt().App(), fxt.Fxt().Ctx());
|
||||
fxt.Fxt().Wiki().Parser_mgr().Scrib().Core_make(fxt.Fxt().Ctx());
|
||||
fxt.Test_getPageByTtl("Does_not_exist", null);
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,10 @@ class Xow_wiki_fxt {
|
||||
public void Test_getPageByTtl(String ttl_str, String expd) {
|
||||
Xowe_wiki wiki = fxt.Wiki();
|
||||
byte[] ttl_bry = Bry_.new_a7(ttl_str);
|
||||
Xoa_url url = Xoa_url.new_(wiki.Domain_bry(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoa_url url = Xoa_url.New(wiki.Domain_bry(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
Xoae_page actl = fxt.Wiki().Data_mgr().Load_page_and_parse(url, ttl);
|
||||
if (expd == null) Tfds.Eq_true(actl.Missing());
|
||||
if (expd == null) Tfds.Eq_true(actl.Db().Page().Exists_n());
|
||||
else Tfds.Eq(expd, String_.new_u8(actl.Ttl().Raw()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user