mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Parser: Rename Hzip types to Hdb_htxt and Hdb_hzip [#553]
This commit is contained in:
parent
115ae8139e
commit
518605ece1
@ -29,7 +29,7 @@ public class Xowd_html_tbl_mgr {
|
||||
byte[] content_sub = null;
|
||||
byte[] sidebar_div = null;
|
||||
db.Conn().Meta_tbl_assert(tbl);
|
||||
tbl.Upsert(page_id, Xopg_module_mgr.Tid_null, Io_stream_tid_.Tid__raw, Xoh_hzip_dict_.Hzip__plain, display_ttl, content_sub, sidebar_div, src);
|
||||
tbl.Upsert(page_id, Xopg_module_mgr.Tid_null, Io_stream_tid_.Tid__raw, Xoh_hzip_dict_.Hdb__page_sync, display_ttl, content_sub, sidebar_div, src);
|
||||
|
||||
wiki.Data__core_mgr().Db__core().Tbl__page().Update__html_db_id(page_id, db.Id());
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class Xowd_data_tstr {
|
||||
Xoh_page hpg = new Xoh_page();
|
||||
hpg.Db().Html().Html_bry_(html_bry);
|
||||
byte[] data = html_bry;
|
||||
html_db.Tbl__html().Insert(page_id, 0, gplx.core.ios.streams.Io_stream_tid_.Tid__raw, gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_.Hzip__none, Bry_.Empty, Bry_.Empty, Bry_.Empty, data);
|
||||
html_db.Tbl__html().Insert(page_id, 0, gplx.core.ios.streams.Io_stream_tid_.Tid__raw, gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_.Hdb__htxt, Bry_.Empty, Bry_.Empty, Bry_.Empty, data);
|
||||
}
|
||||
public void Text__insert(int page_id, String text) {
|
||||
Xow_db_file db = wiki.Data__core_mgr().Db__text();
|
||||
|
@ -35,6 +35,7 @@ public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
Xow_hdump_mode.Cfg__reg_type(cfg_mgr.Type_mgr());
|
||||
cfg_mgr.Bind_many_wiki(this, wiki, Cfg__read_preferred, Cfg__html_mode);
|
||||
wiki.Hxtn_mgr().Init_by_wiki(wiki, Bool_.N);
|
||||
make_mgr.Init_by_wiki(wiki);
|
||||
}
|
||||
public void Load_by_xowe(Xoae_page wpg) {
|
||||
tmp_hpg.Ctor_by_hview(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Db().Page().Id());
|
||||
@ -82,14 +83,14 @@ public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
if (zip_tid > gplx.core.ios.streams.Io_stream_tid_.Tid__raw)
|
||||
src = zip_mgr.Unzip((byte)zip_tid, src);
|
||||
switch (hzip_tid) {
|
||||
case Xoh_hzip_dict_.Hzip__none:
|
||||
case Xoh_hzip_dict_.Hdb__htxt:
|
||||
src = make_mgr.Parse(src, hpg.Wiki(), hpg);
|
||||
break;
|
||||
case Xoh_hzip_dict_.Hzip__plain:
|
||||
case Xoh_hzip_dict_.Hdb__page_sync:
|
||||
gplx.xowa.addons.wikis.pages.syncs.core.loaders.Xosync_page_loader page_loader = new gplx.xowa.addons.wikis.pages.syncs.core.loaders.Xosync_page_loader();
|
||||
src = page_loader.Parse(wiki, hpg, src);
|
||||
break;
|
||||
case Xoh_hzip_dict_.Hzip__v1:
|
||||
case Xoh_hzip_dict_.Hdb__hzip:
|
||||
if (override_mgr__html != null) // null when Parse is called directly
|
||||
src = override_mgr__html.Get_or_same(hpg.Ttl().Page_db(), src);
|
||||
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
|
||||
|
@ -37,7 +37,7 @@ public class Xow_hdump_mgr__save {
|
||||
}
|
||||
}
|
||||
public int Save(Xoae_page page, Xoh_page hpg, Xowd_html_tbl html_tbl, boolean insert, boolean use_hzip_dflt) {
|
||||
int hzip_tid = use_hzip_dflt ? dflt_hzip_tid : Xoh_hzip_dict_.Hzip__none;
|
||||
int hzip_tid = use_hzip_dflt ? dflt_hzip_tid : Xoh_hzip_dict_.Hdb__htxt;
|
||||
byte[] db_body = Write(tmp_bfr, wiki, page, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, hzip_tid, hpg.Db().Html().Html_bry());
|
||||
if (insert) html_tbl.Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_tbl.Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
@ -51,13 +51,13 @@ public class Xow_hdump_mgr__save {
|
||||
}
|
||||
private byte[] Write(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoae_page page, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
switch (hzip_tid) {
|
||||
case Xoh_hzip_dict_.Hzip__none:
|
||||
case Xoh_hzip_dict_.Hdb__htxt:
|
||||
break;
|
||||
case Xoh_hzip_dict_.Hzip__v1:
|
||||
case Xoh_hzip_dict_.Hdb__hzip:
|
||||
src = hzip_mgr.Encode_as_bry((Xoh_hzip_bfr)bfr.Clear(), wiki, hpg, src);
|
||||
break;
|
||||
// TOMBSTONE: not used; Xosync_update_mgr calls save directly; unsure if this should be restored for parallelism
|
||||
// case Xoh_hzip_dict_.Hzip__plain:
|
||||
// case Xoh_hzip_dict_.Hdb__page_sync:
|
||||
// src = plain_parser.Parse_hdoc(wiki.Domain_itm(), page.Url_bry_safe(), hpg.Hdump_mgr().Imgs(), src);
|
||||
// break;
|
||||
}
|
||||
|
@ -36,15 +36,15 @@ public class Xoh_wtr_ctx {
|
||||
public static final int Mode_basic = 0, Mode_alt = 1, Mode_display_title = 2, Mode_popup = 3, Mode_hdump = 4, Mode_file_dump = 5;
|
||||
|
||||
public static final Xoh_wtr_ctx
|
||||
Basic = new Xoh_wtr_ctx(Mode_basic , Xoh_hzip_dict_.Hzip__none, Xoh_href_.Bry__wiki, null)
|
||||
, Hdump = new Xoh_wtr_ctx(Mode_hdump , Xoh_hzip_dict_.Hzip__v1 , Xoh_href_.Bry__wiki, null)
|
||||
, Alt = new Xoh_wtr_ctx(Mode_alt , Xoh_hzip_dict_.Hzip__none, Xoh_href_.Bry__wiki, null)
|
||||
, Display_title = new Xoh_wtr_ctx(Mode_display_title , Xoh_hzip_dict_.Hzip__none, Xoh_href_.Bry__wiki, null)
|
||||
, Popup = new Xoh_wtr_ctx(Mode_popup , Xoh_hzip_dict_.Hzip__none, Xoh_href_.Bry__wiki, null)
|
||||
Basic = new Xoh_wtr_ctx(Mode_basic , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
|
||||
, Hdump = new Xoh_wtr_ctx(Mode_hdump , Xoh_hzip_dict_.Hdb__hzip , Xoh_href_.Bry__wiki, null)
|
||||
, Alt = new Xoh_wtr_ctx(Mode_alt , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
|
||||
, Display_title = new Xoh_wtr_ctx(Mode_display_title , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
|
||||
, Popup = new Xoh_wtr_ctx(Mode_popup , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
|
||||
;
|
||||
|
||||
public static Xoh_wtr_ctx File_dump(byte[] anch__href__bgn, byte[] anch__href__end) {
|
||||
return new Xoh_wtr_ctx(Mode_file_dump, Xoh_hzip_dict_.Hzip__none, anch__href__bgn, anch__href__end);
|
||||
return new Xoh_wtr_ctx(Mode_file_dump, Xoh_hzip_dict_.Hdb__htxt, anch__href__bgn, anch__href__end);
|
||||
}
|
||||
public static Xoh_wtr_ctx Hdump_by_hzip_tid(int hzip_tid) {
|
||||
return new Xoh_wtr_ctx(Mode_hdump, hzip_tid, Xoh_href_.Bry__wiki, null);
|
||||
|
@ -54,8 +54,8 @@ public class Xoh_hzip_dict_ {
|
||||
, Key__form = "form"
|
||||
;
|
||||
public static final int // SERIALIZED:html_db.html.body_flag
|
||||
Hzip__none = 0
|
||||
, Hzip__v1 = 1
|
||||
, Hzip__plain = 2 // used for page_sync
|
||||
Hdb__htxt = 0 // XOWA parse; uses "data-xoimg" for files;
|
||||
, Hdb__hzip = 1 // XOWA parse but additional binary compression
|
||||
, Hdb__page_sync = 2 // WM_api results; aka "page_sync"; uses "xowa:/file" for files; will also have edit-section and other WM artifacts
|
||||
;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class Xoh_htxt_fxt {
|
||||
this.wiki = parser_fxt.Wiki();
|
||||
Xoa_app_fxt.repo2_(parser_fxt.App(), wiki); // needed else will be old "mem/wiki/repo/trg/thumb/" instead of standard "mem/file/en.wikipedia.org/thumb/"
|
||||
wiki.Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
parser_fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hzip__none));
|
||||
parser_fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hdb__htxt));
|
||||
hpg.Ctor_by_hview(wiki, Xoa_url.blank(), parser_fxt.Wiki().Ttl_parse(Xoa_page_.Main_page_bry), 1);
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
|
@ -25,7 +25,7 @@ public class Xoh_file_wtr__hdump__tst {
|
||||
( "[[File:A.png]]"
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\">"
|
||||
+ "<img data-xowa-title=\"A.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
|
||||
+ "<img data-xowa-title=\"A.png\" data-xoimg=\"0|-1|-1|-1|-1|-1\" alt=\"\" src=\"\" width=\"0\" height=\"0\"/></a>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -36,15 +36,15 @@ class Xoh_file_wtr__hdump__fxt {
|
||||
fxt.Reset();
|
||||
|
||||
// default to none
|
||||
fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hzip__none));
|
||||
fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hdb__htxt));
|
||||
|
||||
// create file_fx
|
||||
this.file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__mp__y_();
|
||||
this.Init__orig__add("A.png", 400, 300);
|
||||
}
|
||||
public void Init__hctx__hzip__none() {fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hzip__none));}
|
||||
public void Init__hctx__hzip__v1() {fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hzip__plain));}
|
||||
public void Init__hctx__hzip__none() {fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hdb__htxt));}
|
||||
public void Init__hctx__hzip__v1() {fxt.Hctx_(Xoh_wtr_ctx.Hdump_by_hzip_tid(Xoh_hzip_dict_.Hdb__page_sync));}
|
||||
public void Init__orig__add(String orig_ttl, int orig_w, int orig_h) {
|
||||
file_fxt.Exec_orig_add(Bool_.Y, orig_ttl, Xof_ext_.new_by_ttl_(Bry_.new_u8(orig_ttl)).Id(), orig_w, orig_h, "");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user