mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Cfg: Fix 'Addon - Scribunto'
This commit is contained in:
parent
c2b4d8523f
commit
b6c8b31186
@ -19,18 +19,12 @@ package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx
|
||||
import gplx.xowa.apps.apis.xowa.xtns.*;
|
||||
public class Xoapi_xtns implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
scribunto.Init_by_kit(app);
|
||||
wikibase.Init_by_app(app);
|
||||
}
|
||||
public Xoapi_scribunto Scribunto() {return scribunto;} private final Xoapi_scribunto scribunto = new Xoapi_scribunto();
|
||||
public Xoapi_wikibase Wikibase() {return wikibase;} private final Xoapi_wikibase wikibase = new Xoapi_wikibase();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_scribunto)) return scribunto;
|
||||
else if (ctx.Match(k, Invk_wikibase)) return wikibase;
|
||||
if (ctx.Match(k, Invk_wikibase)) return wikibase;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String
|
||||
Invk_scribunto = "scribunto"
|
||||
, Invk_wikibase = "wikibase"
|
||||
;
|
||||
private static final String Invk_wikibase = "wikibase";
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
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.apps.apis.xowa.xtns; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
|
||||
public class Xoapi_scribunto implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public void Engine_(byte v) {
|
||||
Scrib_xtn_mgr scrib_xtn = (Scrib_xtn_mgr)app.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
|
||||
scrib_xtn.Engine_type_(v);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_engine_lua_)) Engine_(Scrib_engine_type.Type_lua);
|
||||
else if (ctx.Match(k, Invk_engine_luaj_)) Engine_(Scrib_engine_type.Type_luaj);
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_engine_lua_ = "engine_lua_", Invk_engine_luaj_ = "engine_luaj_"
|
||||
;
|
||||
}
|
@ -29,9 +29,9 @@ public class Xoapi_wikibase implements Gfo_invk, Gfo_evt_mgr_owner {
|
||||
app.Cfg().Bind_many_app(this, Cfg__core_langs, Cfg__link_wikis, Cfg__sort_langs);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Cfg__core_langs)) {core_langs = m.ReadBryAry(k, Byte_ascii.Semic); Gfo_evt_mgr_.Pub_val(this, Evt_core_langs_changed, core_langs);}
|
||||
else if (ctx.Match(k, Cfg__sort_langs)) {sort_langs = m.ReadBryAry(k, Byte_ascii.Semic); Gfo_evt_mgr_.Pub_val(this, Evt_sort_langs_changed, sort_langs);}
|
||||
else if (ctx.Match(k, Cfg__link_wikis)) {link_wikis = m.ReadBry(k); Gfo_evt_mgr_.Pub_val(this, Evt_link_wikis_changed, link_wikis);}
|
||||
if (ctx.Match(k, Cfg__core_langs)) {core_langs = m.ReadBryAry("v", Byte_ascii.Semic); Gfo_evt_mgr_.Pub_val(this, Evt_core_langs_changed, core_langs);}
|
||||
else if (ctx.Match(k, Cfg__sort_langs)) {sort_langs = m.ReadBryAry("v", Byte_ascii.Semic); Gfo_evt_mgr_.Pub_val(this, Evt_sort_langs_changed, sort_langs);}
|
||||
else if (ctx.Match(k, Cfg__link_wikis)) {link_wikis = m.ReadBry("v"); Gfo_evt_mgr_.Pub_val(this, Evt_link_wikis_changed, link_wikis);}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public class Xoa_prog_mgr implements Gfo_invk {
|
||||
app.Cfg().Bind_many_app(this
|
||||
, Cfg__web, Cfg__media, Cfg__image, Cfg__svg, Cfg__pdf, Cfg__djvu
|
||||
, Cfg__gz, Cfg__bz2, Cfg__bz2__stdout_cmd
|
||||
, Cfg__query_size, Cfg__resize_img, Cfg__convert_svg_to_png, Cfg__convert_djvu_to_tiff
|
||||
, Cfg__convert_tex_to_dvi, Cfg__convert_dvi_to_png
|
||||
, Cfg__lua
|
||||
, Cfg__lilypond, Cfg__abc2ly, Cfg__trim_img, Cfg__midi_to_ogg
|
||||
);
|
||||
@ -87,6 +89,7 @@ public class Xoa_prog_mgr implements Gfo_invk {
|
||||
else if (String_.Eq(k, Cfg__convert_svg_to_png)) {Init_cmd(m.ReadStr("v"), app_convert_svg_to_png);}
|
||||
else if (String_.Eq(k, Cfg__convert_djvu_to_tiff)) {Init_cmd(m.ReadStr("v"), app_convert_djvu_to_tiff);}
|
||||
else if (String_.Eq(k, Cfg__convert_tex_to_dvi)) {Init_cmd(m.ReadStr("v"), app_convert_tex_to_dvi);}
|
||||
else if (String_.Eq(k, Cfg__convert_dvi_to_png)) {Init_cmd(m.ReadStr("v"), app_convert_dvi_to_png);}
|
||||
else if (String_.Eq(k, Cfg__lua)) {Init_cmd(m.ReadStr("v"), app_lua);}
|
||||
else if (String_.Eq(k, Cfg__lilypond)) {Init_cmd(m.ReadStr("v"), app_lilypond);}
|
||||
else if (String_.Eq(k, Cfg__abc2ly)) {Init_cmd(m.ReadStr("v"), app_abc2ly);}
|
||||
@ -127,6 +130,7 @@ public class Xoa_prog_mgr implements Gfo_invk {
|
||||
, Cfg__convert_svg_to_png = "xowa.wiki.files.apps.convert_svg_to_png"
|
||||
, Cfg__convert_djvu_to_tiff = "xowa.wiki.files.apps.convert_djvu_to_tiff"
|
||||
, Cfg__convert_tex_to_dvi = "xowa.wiki.files.apps.convert_tex_to_dvi"
|
||||
, Cfg__convert_dvi_to_png = "xowa.wiki.files.apps.convert_dvi_to_png"
|
||||
, Cfg__lua = "xowa.addon.scribunto.lua.cmd"
|
||||
, Cfg__lilypond = "xowa.addon.score.apps.lilypond"
|
||||
, Cfg__abc2ly = "xowa.addon.score.apps.abc2ly"
|
||||
|
@ -168,6 +168,13 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
page.Redirect_trail().Itms__add__article(trg_url, trg_ttl, null);
|
||||
wiki.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
|
||||
}
|
||||
public void Redirect2(Xowe_wiki wiki2, Xoae_page page, byte[] page_bry) {
|
||||
Xoa_ttl trg_ttl = Xoa_ttl.Parse(wiki2, page_bry);
|
||||
Xoa_url trg_url = Xoa_url.New(wiki2.Domain_bry(), page_bry);
|
||||
page.Ttl_(trg_ttl).Url_(trg_url);
|
||||
page.Redirect_trail().Itms__add__article(trg_url, trg_ttl, null);
|
||||
wiki2.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
|
||||
}
|
||||
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_create_enabled_)) wiki.Db_mgr().Save_mgr().Create_enabled_(m.ReadYn("v"));
|
||||
|
@ -70,7 +70,7 @@ public class Scrib_core {
|
||||
public Scrib_lib_wikibase Lib_wikibase() {return lib_wikibase;} private Scrib_lib_wikibase lib_wikibase;
|
||||
public Scrib_lib_wikibase_entity Lib_wikibase_entity() {return lib_wikibase_entity;} private Scrib_lib_wikibase_entity lib_wikibase_entity;
|
||||
public Scrib_core Init() { // REF:LuaCommon.php!Load
|
||||
Scrib_xtn_mgr xtn_mgr = (Scrib_xtn_mgr)app.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
|
||||
Scrib_xtn_mgr xtn_mgr = (Scrib_xtn_mgr)wiki.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
|
||||
Engine_(xtn_mgr.Engine_type(), xtn_mgr.Luaj_debug_enabled());
|
||||
engine.Server().Server_timeout_(xtn_mgr.Lua_timeout()).Server_timeout_polling_(xtn_mgr.Lua_timeout_polling()).Server_timeout_busy_wait_(xtn_mgr.Lua_timeout_busy_wait());
|
||||
enabled = xtn_mgr.Enabled();
|
||||
|
@ -19,19 +19,12 @@ package gplx.xowa.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx
|
||||
import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.xtns.scribunto.engines.*;
|
||||
public class Scrib_xtn_mgr extends Xox_mgr_base {
|
||||
private Xowe_wiki wiki;
|
||||
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("scribunto");
|
||||
@Override public void Xtn_ctor_by_app(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
@Override public Xox_mgr Xtn_clone_new() {return new Scrib_xtn_mgr();}
|
||||
public Scrib_lib_mgr Lib_mgr() {return lib_mgr;} private Scrib_lib_mgr lib_mgr = new Scrib_lib_mgr();
|
||||
@Override public void Enabled_(boolean v) {
|
||||
Scrib_core_mgr.Term_all(app);
|
||||
super.Enabled_(v);
|
||||
}
|
||||
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;
|
||||
if (app != null) gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all(app);
|
||||
}
|
||||
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;
|
||||
public int Lua_timeout_busy_wait() {return lua_timeout_busy_wait;} private int lua_timeout_busy_wait = 250;
|
||||
@ -44,16 +37,17 @@ public class Scrib_xtn_mgr extends Xox_mgr_base {
|
||||
}
|
||||
public Xop_log_invoke_wkr Invoke_wkr() {return invoke_wkr;} private Xop_log_invoke_wkr invoke_wkr;
|
||||
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
wiki.App().Cfg().Bind_many_wiki(this, wiki, Cfg__enabled, Cfg__engine, Cfg__lua__timeout, Cfg__lua__timeout_busy_wait, Cfg__lua__timeout_polling);
|
||||
}
|
||||
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_invoke_wkr)) return m.ReadYnOrY("v") ? Invoke_wkr_or_new() : Gfo_invk_.Noop;
|
||||
else if (ctx.Match(k, Cfg__enabled)) Enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Cfg__engine)) Engine_type_(Scrib_engine_type.Xto_byte(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Cfg__lua__timeout)) lua_timeout = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Cfg__lua__timeout_polling)) lua_timeout_polling = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Cfg__lua__timeout_busy_wait)) lua_timeout_busy_wait = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Cfg__enabled)) {Enabled_(m.ReadYn("v")); wiki.Parser_mgr().Scrib().Core_term();}
|
||||
else if (ctx.Match(k, Cfg__engine)) {engine_type = Scrib_engine_type.Xto_byte(m.ReadStr("v")); wiki.Parser_mgr().Scrib().Core_term();}
|
||||
else if (ctx.Match(k, Cfg__lua__timeout)) {lua_timeout = m.ReadInt("v"); wiki.Parser_mgr().Scrib().Core_term();}
|
||||
else if (ctx.Match(k, Cfg__lua__timeout_polling)) {lua_timeout_polling = m.ReadInt("v"); wiki.Parser_mgr().Scrib().Core_term();}
|
||||
else if (ctx.Match(k, Cfg__lua__timeout_busy_wait)) {lua_timeout_busy_wait = m.ReadInt("v"); wiki.Parser_mgr().Scrib().Core_term();}
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
return this;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user