mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Embeddable: Load modules from load_worker
This commit is contained in:
parent
42dfdcdac2
commit
c9748a6f44
@ -32,7 +32,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "3.11.2.3";
|
||||
public static final String Version = "3.11.2.4";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
@ -18,11 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.parsers.mediawikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.parsers.*;
|
||||
public class Xop_mediawiki_mgr {
|
||||
private final Xoae_app app;
|
||||
public Xop_mediawiki_mgr(String root_str) {
|
||||
private boolean mode_is_prod;
|
||||
public Xop_mediawiki_mgr(String root_str, boolean mode_is_prod) {
|
||||
Gfo_usr_dlg usr_dlg = Xoa_app_.New__usr_dlg__console();
|
||||
Gfo_usr_dlg_.Instance = usr_dlg;
|
||||
Io_url root_dir = Io_url_.new_dir_(root_str);
|
||||
|
||||
this.mode_is_prod = mode_is_prod;
|
||||
if (mode_is_prod)
|
||||
gplx.dbs.Db_conn_bldr.Instance.Reg_default_sqlite();
|
||||
this.app = new Xoae_app(usr_dlg, gplx.xowa.apps.Xoa_app_mode.Itm_cmd
|
||||
, root_dir
|
||||
, root_dir.GenSubDir("wiki")
|
||||
@ -31,10 +35,18 @@ public class Xop_mediawiki_mgr {
|
||||
, root_dir.GenSubDir_nest("user", "anonymous", "wiki")
|
||||
, gplx.xowa.apps.boots.Xoa_cmd_arg_mgr.Bin_dir_name()
|
||||
);
|
||||
if (mode_is_prod)
|
||||
app.Init_by_app();
|
||||
}
|
||||
public Xop_mediawiki_wkr Make(String domain_str) {return Make(domain_str, null);}
|
||||
public Xop_mediawiki_wkr Make(String domain_str, Xop_mediawiki_loader loader) {
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Make(Bry_.new_u8(domain_str), app.Fsys_mgr().Wiki_dir());
|
||||
if (mode_is_prod)
|
||||
wiki.Init_by_wiki();
|
||||
return new Xop_mediawiki_wkr(wiki, loader);
|
||||
}
|
||||
|
||||
public static Xop_mediawiki_mgr New(String root_str) {
|
||||
return new Xop_mediawiki_mgr(root_str, true);
|
||||
}
|
||||
}
|
||||
|
@ -36,8 +36,11 @@ public class Xop_mediawiki_wkr__tst {
|
||||
}
|
||||
}
|
||||
class Xop_mediawiki_wkr__fxt {
|
||||
private final Xop_mediawiki_mgr mgr = new Xop_mediawiki_mgr("mem/xowa/wiki/en.wikipedia.org/");
|
||||
private final Xop_mediawiki_mgr mgr = new Xop_mediawiki_mgr("mem/xowa/wiki/en.wikipedia.org/", false);
|
||||
private Xop_mediawiki_wkr wkr;
|
||||
public Xop_mediawiki_wkr__fxt() {
|
||||
gplx.dbs.Db_conn_bldr.Instance.Reg_default_mem();
|
||||
}
|
||||
public void Init__wkr(String wiki, Xop_mediawiki_loader cbk) {
|
||||
this.wkr = mgr.Make(wiki, cbk);
|
||||
}
|
||||
|
@ -99,10 +99,10 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
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
|
||||
if (ttl == null) return rslt.Init_ary_empty();
|
||||
Xoae_page page = cur_wiki.Data_mgr().Load_page_by_ttl(ttl);
|
||||
if (page.Db().Page().Exists_n()) return rslt.Init_ary_empty();
|
||||
byte[] page_db = cur_wiki.Cache_mgr().Page_cache().Get_or_load_as_src(ttl);
|
||||
if (page_db == null) 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.Db().Text().Text_bry())));
|
||||
return rslt.Init_obj(mod.LoadString(String_.new_u8(page_db)));
|
||||
}
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user