mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Convert rest of pages
This commit is contained in:
@@ -28,6 +28,7 @@ public class Xof_math_mgr implements Gfo_invk {
|
||||
Xoa_prog_mgr app_mgr = app.Prog_mgr();
|
||||
cmd_convert_tex_to_dvi = app_mgr.App_convert_tex_to_dvi();
|
||||
cmd_convert_dvi_to_png = app_mgr.App_convert_dvi_to_png();
|
||||
app.Cfg().Bind_many_app(this, Cfg__enabled, Cfg__renderer);
|
||||
}
|
||||
private Io_url Make_math_dir(String wiki_key) {return app.Fsys_mgr().Root_dir().GenSubDir_nest("file", wiki_key, "math");}
|
||||
public Xof_math_html_wtr Html_wtr() {return html_wtr;} private final Xof_math_html_wtr html_wtr = new Xof_math_html_wtr();
|
||||
@@ -49,8 +50,7 @@ public class Xof_math_mgr implements Gfo_invk {
|
||||
.Add(String_.CharAt(hash, 0)).Add(Math_dir_spr)
|
||||
.Add(String_.CharAt(hash, 1)).Add(Math_dir_spr)
|
||||
.Add(String_.CharAt(hash, 2)).Add(Math_dir_spr)
|
||||
.Add(hash).Add(".png")
|
||||
;
|
||||
.Add(hash).Add(".png");
|
||||
return Io_url_.new_fil_(tmp_sb.To_str_and_clear());
|
||||
}
|
||||
public boolean MakePng(byte[] math, String hash, Io_url png_url, String prog_fmt) {
|
||||
@@ -63,14 +63,14 @@ public class Xof_math_mgr implements Gfo_invk {
|
||||
cmd_convert_tex_to_dvi.Prog_fmt_(prog_fmt + " tex_to_dvi: ~{process_seconds} second(s); ~{process_exe_name} ~{process_exe_args}");
|
||||
boolean pass = cmd_convert_tex_to_dvi.Run(tex_url.Raw(), tmp_dir.Xto_api()).Exit_code_pass();
|
||||
if (!pass) {
|
||||
app.Usr_dlg().Warn_many(GRP_KEY, "tex_to_dvi.fail", "fail: tex_to_dvi: error=~{0} latex=~{1}", cmd_convert_tex_to_dvi.Rslt_out(), latex);
|
||||
app.Usr_dlg().Warn_many("", "tex_to_dvi.fail", "fail: tex_to_dvi: error=~{0} latex=~{1}", cmd_convert_tex_to_dvi.Rslt_out(), latex);
|
||||
}
|
||||
// NOTE: latex sometimes throws errors, but will generate .dvi; for sake of simplicity; always try to run dvipng
|
||||
Io_mgr.Instance.CreateDirIfAbsent(png_url.OwnerDir());
|
||||
cmd_convert_dvi_to_png.Prog_fmt_(prog_fmt + " dvi_to_png: ~{process_seconds} second(s); ~{process_exe_name} ~{process_exe_args}");
|
||||
pass = cmd_convert_dvi_to_png.Run(tex_url.GenNewExt(".dvi"), png_url, tmp_dir.Xto_api()).Exit_code_pass();
|
||||
if (!pass) {
|
||||
app.Usr_dlg().Warn_many(GRP_KEY, "dvi_to_png.fail", "fail: dvi_to_png: error=~{0} latex=~{1}", cmd_convert_tex_to_dvi.Rslt_out(), latex);
|
||||
app.Usr_dlg().Warn_many("", "dvi_to_png.fail", "fail: dvi_to_png: error=~{0} latex=~{1}", cmd_convert_tex_to_dvi.Rslt_out(), latex);
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
@@ -95,14 +95,13 @@ public class Xof_math_mgr implements Gfo_invk {
|
||||
));
|
||||
public boolean Enabled() {return enabled;} public Xof_math_mgr Enabled_(boolean v) {enabled = v; return this;} private boolean enabled = true;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_renderer)) return renderer_is_mathjax ? "mathjax" : "latex";
|
||||
else if (ctx.Match(k, Invk_renderer_)) renderer_is_mathjax = String_.Eq(m.ReadStr("v"), "mathjax");
|
||||
else if (ctx.Match(k, Invk_renderer_list)) return Options_renderer_list;
|
||||
if (ctx.Match(k, Cfg__enabled)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Cfg__renderer)) renderer_is_mathjax = String_.Eq(m.ReadStr("v"), "mathjax");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_renderer = "renderer", Invk_renderer_ = "renderer_", Invk_renderer_list = "renderer_list";
|
||||
private static Keyval[] Options_renderer_list = Keyval_.Ary(Keyval_.new_("mathjax", "MathJax"), Keyval_.new_("latex", "LaTeX"));
|
||||
private static final String GRP_KEY = "xowa.math.mgr";
|
||||
}
|
||||
private static final String
|
||||
Cfg__enabled = "xowa.addon.math.enabled"
|
||||
, Cfg__renderer = "xowa.addon.math.renderer"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.math; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Xof_math_mgr_html_tst {
|
||||
@Before public void init() {} private final Xop_fxt fxt = Xop_fxt.New_app_html();
|
||||
@Before public void init() {
|
||||
fxt.App().File_mgr().Init_by_app(fxt.App());
|
||||
} private final Xop_fxt fxt = Xop_fxt.New_app_html();
|
||||
@Test public void Basic__latex() {
|
||||
fxt.App().File_mgr().Math_mgr().Renderer_is_mathjax_(false);
|
||||
fxt.Test__parse_to_html_mgr("<math>x + y</math>", "<img id='xowa_math_img_0' src='' width='' height=''/><span id='xowa_math_txt_0'>x + y</span>"); // latex has img
|
||||
|
||||
@@ -55,6 +55,9 @@ public class Score_xtn_mgr extends Xox_mgr_base {
|
||||
, " }"
|
||||
, " }"
|
||||
, "}"), "version", "code");
|
||||
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
|
||||
wiki.App().Cfg().Bind_many_wiki(this, wiki, Cfg__enabled);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_html_img)) return html_img.Fmt();
|
||||
else if (ctx.Match(k, Invk_html_img_)) html_img.Fmt_(m.ReadBry("v"));
|
||||
@@ -62,9 +65,11 @@ public class Score_xtn_mgr extends Xox_mgr_base {
|
||||
else if (ctx.Match(k, Invk_html_txt_)) html_txt.Fmt_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_lilypond_fmt)) return lilypond_fmtr.Fmt();
|
||||
else if (ctx.Match(k, Invk_lilypond_fmt_)) lilypond_fmtr.Fmt_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Cfg__enabled)) Enabled_(m.ReadYn("v"));
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_html_img = "html_img", Invk_html_img_ = "html_img_", Invk_html_txt = "html_txt", Invk_html_txt_ = "html_txt_", Invk_lilypond_fmt = "lilypond_fmt", Invk_lilypond_fmt_ = "lilypond_fmt_";
|
||||
private static final String Cfg__enabled = "xowa.addon.score.enabled";
|
||||
public static byte[] Lilypond_version = null;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class Scrib_core_mgr {
|
||||
}
|
||||
|
||||
public static void Term_all(Xoae_app app) { // NOLOCK.app_level
|
||||
if (app == null) return;
|
||||
Xoae_wiki_mgr wiki_mgr = app.Wiki_mgr();
|
||||
int len = wiki_mgr.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
||||
@@ -30,53 +30,46 @@ 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;
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all(app);
|
||||
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;
|
||||
public int Lua_timeout_loop() {return lua_timeout_loop;} private int lua_timeout_loop = 10000000;
|
||||
public boolean Lua_log_enabled() {return lua_log_enabled;} private boolean lua_log_enabled;
|
||||
public boolean Lua_log_enabled() {return lua_log_enabled;} private boolean lua_log_enabled = false;
|
||||
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;
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all(app);// 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 void Xtn_init_by_wiki(Xowe_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_engine_type)) return Scrib_engine_type.Xto_str(engine_type);
|
||||
else if (ctx.Match(k, Invk_engine_type_)) Engine_type_(Scrib_engine_type.Xto_byte(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Invk_engine_type_list)) return Scrib_engine_type.Options__list;
|
||||
else if (ctx.Match(k, Invk_lua_timeout)) return lua_timeout;
|
||||
else if (ctx.Match(k, Invk_lua_timeout_)) lua_timeout = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_lua_timeout_polling)) return lua_timeout_polling;
|
||||
else if (ctx.Match(k, Invk_lua_timeout_polling_)) lua_timeout_polling = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_lua_log_enabled)) return Yn.To_str(lua_log_enabled);
|
||||
else if (ctx.Match(k, Invk_lua_log_enabled_)) lua_log_enabled = m.ReadBool("v");
|
||||
else if (ctx.Match(k, Invk_lua_timeout_busy_wait)) return lua_timeout_busy_wait;
|
||||
else if (ctx.Match(k, Invk_lua_timeout_busy_wait_)) lua_timeout_busy_wait = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_lua_timeout_loop)) return lua_timeout_loop;
|
||||
else if (ctx.Match(k, Invk_lua_timeout_loop_)) lua_timeout_loop = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_luaj_debug_enabled)) return Yn.To_str(luaj_debug_enabled);
|
||||
else if (ctx.Match(k, Invk_luaj_debug_enabled_)) Luaj_debug_enabled_(m.ReadBool("v"));
|
||||
else if (ctx.Match(k, Invk_invoke_wkr)) return m.ReadYnOrY("v") ? Invoke_wkr_or_new() : Gfo_invk_.Noop;
|
||||
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 return super.Invk(ctx, ikey, k, m);
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_engine_type = "engine_type", Invk_engine_type_ = "engine_type_", Invk_engine_type_list = "engine_type_list"
|
||||
, Invk_lua_timeout = "lua_timeout", Invk_lua_timeout_ = "lua_timeout_"
|
||||
, Invk_lua_timeout_polling = "lua_timeout_polling", Invk_lua_timeout_polling_ = "lua_timeout_polling_"
|
||||
, Invk_lua_log_enabled = "lua_log_enabled", Invk_lua_log_enabled_ = "lua_log_enabled_"
|
||||
, Invk_lua_timeout_loop = "lua_timeout_loop", Invk_lua_timeout_loop_ = "lua_timeout_loop_"
|
||||
, Invk_lua_timeout_busy_wait = "lua_timeout_busy_wait", Invk_lua_timeout_busy_wait_ = "lua_timeout_busy_wait_"
|
||||
, Invk_luaj_debug_enabled = "luaj_debug_enabled", Invk_luaj_debug_enabled_ = "luaj_debug_enabled_"
|
||||
, Invk_invoke_wkr = "invoke_wkr"
|
||||
;
|
||||
private static final String Invk_invoke_wkr = "invoke_wkr";
|
||||
public Xop_log_invoke_wkr Invoke_wkr_or_new() {
|
||||
if (invoke_wkr == null) invoke_wkr = app.Log_mgr().Make_wkr_invoke();
|
||||
return invoke_wkr;
|
||||
}
|
||||
public static Err err_(String fmt, Object... args) {return Err_.new_wo_type(fmt, args).Trace_ignore_add_1_();}
|
||||
public static Err err_(Exception e, String msg, Object... args) {return Err_.new_exc(e, "xo", msg, args).Trace_ignore_add_1_();}
|
||||
private static final String
|
||||
Cfg__enabled = "xowa.addon.scribunto.enabled"
|
||||
, Cfg__engine = "xowa.addon.scribunto.engine"
|
||||
, Cfg__lua__timeout = "xowa.addon.scribunto.lua.timeout"
|
||||
, Cfg__lua__timeout_polling = "xowa.addon.scribunto.lua.timeout_polling"
|
||||
, Cfg__lua__timeout_busy_wait = "xowa.addon.scribunto.lua.timeout_busy_wait"
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ class Xowb_json_dump_db {
|
||||
wiki.Ns_mgr().Init();
|
||||
|
||||
// init ns_map
|
||||
Xoapi_import import_cfg = app.Api_root().Bldr().Wiki().Import();
|
||||
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__text(), db_mgr, import_cfg.Text_db_max());
|
||||
byte[] ns_file_map = import_cfg.New_ns_file_map(src_fil_len);
|
||||
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__text(), db_mgr, Xobldr_cfg.Max_size__text(app));
|
||||
byte[] ns_file_map = Xobldr_cfg.New_ns_file_map(src_fil_len);
|
||||
Xob_ns_file_itm.Init_ns_bldr_data(Xow_db_file_.Tid__text, wiki.Ns_mgr(), ns_file_map);
|
||||
|
||||
// start import
|
||||
this.text_zip_mgr = wiki.Utl__zip_mgr(); this.text_zip_tid = import_cfg.Zip_tid_text();
|
||||
this.text_zip_mgr = wiki.Utl__zip_mgr();
|
||||
this.text_zip_tid = Xobldr_cfg.Zip_mode__text(app);
|
||||
this.page_modified_on = Datetime_now.Get();
|
||||
page_tbl.Insert_bgn();
|
||||
qid_cmd.Page_wkr__bgn();
|
||||
|
||||
@@ -18,11 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.wbases.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*;
|
||||
public class Wdata_itemByTitle_cfg implements Gfo_invk {
|
||||
public byte[] Site_default() {return site_default;} private byte[] site_default = Bry_.new_a7("enwiki");
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
app.Cfg().Bind_many_app(this, Cfg__site_default);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_site_default)) return site_default;
|
||||
else if (ctx.Match(k, Invk_site_default_)) site_default = m.ReadBry("v");
|
||||
if (ctx.Match(k, Cfg__site_default)) site_default = m.ReadBry("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_site_default = "site_default", Invk_site_default_ = "site_default_";
|
||||
}
|
||||
public static final String Key = "itemByTitle";
|
||||
private static final String Cfg__site_default = "xowa.addon.wikibase.site_default";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user