mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Cfg: Convert 'Wiki - HTML databases'
This commit is contained in:
@@ -48,7 +48,7 @@ public class Xoh_page_wtr_wkr {
|
||||
}
|
||||
Bry_bfr page_bfr = wiki.Utl__bfr_mkr().Get_m001(); // NOTE: get separate page rv to output page; do not reuse tmp_bfr b/c it will be used inside Fmt_do
|
||||
Xoh_wtr_ctx hctx = null;
|
||||
if (page_mode == Xopg_page_.Tid_html && wiki.App().Api_root().Wiki().Hdump().Html_mode().Tid_is_hdump_save()) {
|
||||
if (page_mode == Xopg_page_.Tid_html && wiki.Html__hdump_mgr().Load_mgr().Html_mode().Tid_is_hdump_save()) {
|
||||
hctx = Xoh_wtr_ctx.Hdump;
|
||||
Write_body(page_bfr, ctx, hctx, page);
|
||||
Write_page_by_tid(ctx, hctx, page_mode, rv, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(page_bfr.To_bry_and_clear()));
|
||||
|
||||
@@ -40,6 +40,7 @@ public class Xow_hdump_mgr {
|
||||
// mode_is_b256 = true;
|
||||
}
|
||||
Init_by_db(dflt_zip_tid, dflt_hzip_enable, mode_is_b256);
|
||||
load_mgr.Init_by_wiki(wiki);
|
||||
}
|
||||
public void Init_by_db(byte dflt_zip_tid, boolean dflt_hzip_enable, boolean mode_is_b256) {
|
||||
int dflt_hzip_tid = dflt_hzip_enable ? Xoh_hzip_dict_.Hzip__v1 : Xoh_hzip_dict_.Hzip__none;
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.makes.*; import gplx
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*;
|
||||
public class Xow_hdump_mgr__load {
|
||||
public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
private Xow_override_mgr override_mgr__html, override_mgr__page;
|
||||
@@ -29,7 +29,14 @@ public class Xow_hdump_mgr__load {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg; this.tmp_bfr = tmp_bfr;
|
||||
this.make_mgr = new Xoh_make_mgr();
|
||||
}
|
||||
public boolean Read_preferred() {return read_preferred;} private boolean read_preferred = true;
|
||||
public Xow_hdump_mode Html_mode() {return html_mode;} private Xow_hdump_mode html_mode;
|
||||
public Xoh_make_mgr Make_mgr() {return make_mgr;} private final Xoh_make_mgr make_mgr;
|
||||
public void Init_by_wiki(Xow_wiki wiki) {
|
||||
gplx.xowa.addons.apps.cfgs.Xocfg_mgr cfg_mgr = wiki.App().Cfg();
|
||||
Xow_hdump_mode.Cfg__reg_type(cfg_mgr.Type_mgr());
|
||||
cfg_mgr.Bind_many_wiki(this, wiki, Cfg__read_preferred, Cfg__html_mode);
|
||||
}
|
||||
public void Load_by_edit(Xoae_page wpg) {
|
||||
tmp_hpg.Ctor_by_hview(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Db().Page().Id());
|
||||
Load(tmp_hpg, wpg.Ttl());
|
||||
@@ -128,6 +135,16 @@ public class Xow_hdump_mgr__load {
|
||||
trg_list.Add_direct(src_list.Get_at(i));
|
||||
}
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Cfg__read_preferred)) read_preferred = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Cfg__html_mode)) html_mode = Xow_hdump_mode.Parse(m.ReadStr("v"));
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Cfg__read_preferred = "xowa.wiki.hdumps.read_preferred"
|
||||
, Cfg__html_mode = "xowa.wiki.hdumps.html_mode"
|
||||
;
|
||||
|
||||
private static boolean Load__fail(Xoh_page hpg) {hpg.Db().Page().Exists_n_(); return false;}
|
||||
private static boolean Load__dbpg(Xow_wiki wiki, Xowd_page_itm dbpg, Xoh_page hpg, Xoa_ttl ttl) {
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_ttl(dbpg, ttl.Ns(), ttl.Page_db());
|
||||
|
||||
43
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mode.java
Normal file
43
400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mode.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
public class Xow_hdump_mode {
|
||||
private final int tid;
|
||||
private final String key;
|
||||
private final String gui;
|
||||
|
||||
public Xow_hdump_mode(int tid, String key, String gui) {
|
||||
this.tid = tid; this.key = key; this.gui = gui;
|
||||
}
|
||||
public boolean Tid_is_hdump_save() {return tid == Hdump_save.tid;}
|
||||
|
||||
private static final Xow_hdump_mode
|
||||
Shown = new Xow_hdump_mode(0, "shown" , "Shown")
|
||||
, Hdump_save = new Xow_hdump_mode(1, "hdump_save" , "Saved for HTML DB")
|
||||
, Hdump_load = new Xow_hdump_mode(2, "hdump_load" , "Loaded by HTML DB");
|
||||
public static void Cfg__reg_type(gplx.xowa.addons.apps.cfgs.mgrs.types.Xocfg_type_mgr type_mgr) {
|
||||
type_mgr.Lists__add("list:xowa.wiki.hdumps.html_mode", To_kv(Shown), To_kv(Hdump_save), To_kv(Hdump_load));
|
||||
}
|
||||
private static Keyval To_kv(Xow_hdump_mode mode) {return Keyval_.new_(mode.key, mode.gui);}
|
||||
public static Xow_hdump_mode Parse(String v) {
|
||||
if (String_.Eq(v, Shown.key)) return Shown;
|
||||
else if (String_.Eq(v, Hdump_save.key)) return Hdump_save;
|
||||
else if (String_.Eq(v, Hdump_load.key)) return Hdump_load;
|
||||
else throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user