mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Make: Add xomp_stats to track time per page (and other attributes) [#456]
This commit is contained in:
@@ -204,8 +204,11 @@ public class Xoh_page_wtr_wkr {
|
||||
// if (ns_id == Xow_ns_.Tid__category) wiki.Ctg__catpage_mgr().Write_catpage(tidy_bfr, page, hctx);
|
||||
|
||||
// tidy html
|
||||
if (ns_id != Xow_ns_.Tid__special) // skip Special b/c
|
||||
if (ns_id != Xow_ns_.Tid__special) { // skip Special b/c
|
||||
long tidy_time = gplx.core.envs.System_.Ticks();
|
||||
wiki.Html_mgr().Tidy_mgr().Exec_tidy(tidy_bfr, !hctx.Mode_is_hdump(), page.Url_bry_safe());
|
||||
page.Stat_itm().Tidy_time = gplx.core.envs.System_.Ticks__elapsed_in_frac(tidy_time);
|
||||
}
|
||||
|
||||
// add back to main bfr
|
||||
bfr.Add_bfr_and_clear(tidy_bfr);
|
||||
|
||||
@@ -22,11 +22,11 @@ import gplx.xowa.parsers.*;
|
||||
public class Xob_hdump_bldr implements Gfo_invk {
|
||||
private boolean enabled, hzip_enabled, hzip_diff, hzip_b256; private byte zip_tid = Byte_.Max_value_127;
|
||||
private Xowe_wiki wiki; private Xob_hdump_tbl_retriever html_tbl_retriever;
|
||||
private Xoh_stat_tbl stat_tbl; private Xoh_stat_itm stat_itm;
|
||||
private int prv_row_len = 0;
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private boolean op_sys_is_wnt;
|
||||
private byte[] toc_label = Bry_.Empty;
|
||||
public Xoh_page Tmp_hpg() {return tmp_hpg;}
|
||||
public Xob_hdump_bldr Enabled_(boolean v) {this.enabled = v; return this;}
|
||||
public Xob_hdump_bldr Hzip_enabled_(boolean v) {this.hzip_enabled = v; return this;}
|
||||
public Xob_hdump_bldr Hzip_diff_(boolean v) {this.hzip_diff = v; return this;}
|
||||
@@ -36,7 +36,6 @@ public class Xob_hdump_bldr implements Gfo_invk {
|
||||
if (!enabled) return false;
|
||||
this.op_sys_is_wnt = gplx.core.envs.Op_sys.Cur().Tid_is_wnt();
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.html_tbl_retriever = html_tbl_retriever;
|
||||
this.stat_tbl = new Xoh_stat_tbl(make_conn); this.stat_itm = hdump_mgr.Hzip_mgr().Hctx().Hzip__stat();
|
||||
this.toc_label = wiki.Msg_mgr().Val_by_id(gplx.xowa.langs.msgs.Xol_msg_itm_.Id_toc);
|
||||
|
||||
if (zip_tid == Byte_.Max_value_127) zip_tid = Xobldr_cfg.Zip_mode__html(wiki.App());
|
||||
@@ -64,7 +63,7 @@ public class Xob_hdump_bldr implements Gfo_invk {
|
||||
// save to db
|
||||
Xowd_html_tbl html_tbl = html_tbl_retriever.Get_html_tbl(wpg.Ttl().Ns(), prv_row_len); // get html_tbl
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(wpg, tmp_hpg.Ctor_by_hdiff(tmp_bfr, wpg, toc_label), html_tbl, true, is_wikitext); // save to db
|
||||
stat_tbl.Insert(tmp_hpg, stat_itm, wpg.Root().Root_src().length, tmp_hpg.Db().Html().Html_bry().length, prv_row_len); // save stats
|
||||
tmp_hpg.Db().Html().Zip_len_(prv_row_len);
|
||||
|
||||
// run hzip diff if enabled
|
||||
if (hzip_diff && is_wikitext) {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
public class Xoh_stat_itm {
|
||||
public void Clear() {
|
||||
a_rhs = lnki_text_n = lnki_text_y = lnke__free = lnke__auto = lnke__text = 0;
|
||||
hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = timeline = gallery = 0;
|
||||
img_full = 0;
|
||||
space = 0;
|
||||
Bry_.Clear(escape_bry);
|
||||
}
|
||||
public int A_rhs() {return a_rhs;} public void A_rhs_add() {++a_rhs;} private int a_rhs;
|
||||
public int Lnki_text_n() {return lnki_text_n;} public void Lnki_text_n_add() {++lnki_text_n;} private int lnki_text_n;
|
||||
public int Lnki_text_y() {return lnki_text_y;} public void Lnki_text_y_add() {++lnki_text_y;} private int lnki_text_y;
|
||||
public int Lnke__free() {return lnke__free;} public void Lnke__free__add() {++lnke__free;} private int lnke__free;
|
||||
public int Lnke__auto() {return lnke__auto;} public void Lnke__auto__add() {++lnke__auto;} private int lnke__auto;
|
||||
public int Lnke__text() {return lnke__text;} public void Lnke__text__add() {++lnke__text;} private int lnke__text;
|
||||
public int Img_full() {return img_full;} public void Img_full_add() {++img_full;} private int img_full;
|
||||
public int Timeline() {return timeline;} public void Timeline_add() {++timeline;} private int timeline;
|
||||
public int Gallery() {return gallery;} public void Gallery_add() {++gallery;} private int gallery;
|
||||
public int Hdr_1() {return hdr_1;} private int hdr_1;
|
||||
public int Hdr_2() {return hdr_2;} private int hdr_2;
|
||||
public int Hdr_3() {return hdr_3;} private int hdr_3;
|
||||
public int Hdr_4() {return hdr_4;} private int hdr_4;
|
||||
public int Hdr_5() {return hdr_5;} private int hdr_5;
|
||||
public int Hdr_6() {return hdr_6;} private int hdr_6;
|
||||
public int Space() {return space;} public void Space_add(int v) {space += v;} private int space;
|
||||
public byte[] Escape_bry() {return escape_bry;} public void Escape_add(byte v) {escape_bry[v] += 1;} private final byte[] escape_bry = new byte[256];
|
||||
public void Hdr_add(int hdr_num) {
|
||||
switch (hdr_num) {
|
||||
case 1: ++hdr_1; break;
|
||||
case 2: ++hdr_2; break;
|
||||
case 3: ++hdr_3; break;
|
||||
case 4: ++hdr_4; break;
|
||||
case 5: ++hdr_5; break;
|
||||
case 6: ++hdr_6; break;
|
||||
default: throw Err_.new_unhandled(hdr_num);
|
||||
}
|
||||
}
|
||||
public void Lnki_add(int orig_len, int hzip_len, int flag) {
|
||||
}
|
||||
public void Lnke_add(byte lnke_type) {
|
||||
switch (lnke_type) {
|
||||
case Xoh_lnke_dict_.Type__free: ++lnke__free; break;
|
||||
case Xoh_lnke_dict_.Type__auto: ++lnke__auto; break;
|
||||
case Xoh_lnke_dict_.Type__text: ++lnke__text; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xoh_stat_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hdump_stats"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private static final String
|
||||
fld_page_id = flds.Add_int_pkey("page_id"), fld_wtxt_len = flds.Add_int("wtxt_len"), fld_row_orig_len = flds.Add_int("row_orig_len"), fld_row_zip_len = flds.Add_int("row_zip_len")
|
||||
, fld_body_len = flds.Add_int("body_len"), fld_display_ttl_len = flds.Add_int("display_ttl_len"), fld_content_sub_len = flds.Add_int("content_sub_len"), fld_sidebar_div_len = flds.Add_int("sidebar_div_len")
|
||||
, fld_js_math = flds.Add_int("js_math"), fld_js_imap = flds.Add_int("js_imap"), fld_js_packed = flds.Add_int("js_packed"), fld_js_hiero = flds.Add_int("js_hiero")
|
||||
, fld_a_rhs = flds.Add_int("a_rhs"), fld_lnki_text_n = flds.Add_int("lnki_text_n"), fld_lnki_text_y = flds.Add_int("lnki_text_y")
|
||||
, fld_lnke_free = flds.Add_int("lnke_free"), fld_lnke_auto = flds.Add_int("lnke_auto"), fld_lnke_text = flds.Add_int("lnke_text")
|
||||
, fld_hdr_1 = flds.Add_int("hdr_1"), fld_hdr_2 = flds.Add_int("hdr_2"), fld_hdr_3 = flds.Add_int("hdr_3"), fld_hdr_4 = flds.Add_int("hdr_4"), fld_hdr_5 = flds.Add_int("hdr_5"), fld_hdr_6 = flds.Add_int("hdr_6")
|
||||
, fld_img_full = flds.Add_int("img_full")
|
||||
;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Xoh_stat_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.Create_tbl();
|
||||
conn.Stmt_delete(tbl_name).Exec_delete(); // always zap table
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_page_id)));}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(Xoh_page hpg, Xoh_stat_itm hzip, int wtxt_len, int row_orig_len, int row_zip_len) {
|
||||
Xopg_module_mgr js_mgr = hpg.Head_mgr();
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_page_id , hpg.Page_id())
|
||||
.Val_int(fld_wtxt_len , wtxt_len)
|
||||
.Val_int(fld_row_orig_len , row_orig_len)
|
||||
.Val_int(fld_row_zip_len , row_zip_len)
|
||||
.Val_int(fld_body_len , Len_or_0(hpg.Db().Html().Html_bry()))
|
||||
.Val_int(fld_display_ttl_len , Len_or_0(hpg.Display_ttl()))
|
||||
.Val_int(fld_content_sub_len , Len_or_0(hpg.Content_sub()))
|
||||
.Val_int(fld_sidebar_div_len , Len_or_0(hpg.Sidebar_div()))
|
||||
.Val_bool_as_byte(fld_js_math , js_mgr.Math_exists())
|
||||
.Val_bool_as_byte(fld_js_imap , js_mgr.Imap_exists())
|
||||
.Val_bool_as_byte(fld_js_packed , js_mgr.Gallery_packed_exists())
|
||||
.Val_bool_as_byte(fld_js_hiero , js_mgr.Hiero_exists())
|
||||
.Val_int(fld_a_rhs , hzip.A_rhs())
|
||||
.Val_int(fld_lnki_text_n , hzip.Lnki_text_n())
|
||||
.Val_int(fld_lnki_text_y , hzip.Lnki_text_y())
|
||||
.Val_int(fld_lnke_free , hzip.Lnke__free())
|
||||
.Val_int(fld_lnke_auto , hzip.Lnke__auto())
|
||||
.Val_int(fld_lnke_text , hzip.Lnke__text())
|
||||
.Val_int(fld_hdr_1 , hzip.Hdr_1())
|
||||
.Val_int(fld_hdr_2 , hzip.Hdr_2())
|
||||
.Val_int(fld_hdr_3 , hzip.Hdr_3())
|
||||
.Val_int(fld_hdr_4 , hzip.Hdr_4())
|
||||
.Val_int(fld_hdr_5 , hzip.Hdr_5())
|
||||
.Val_int(fld_hdr_6 , hzip.Hdr_6())
|
||||
.Val_int(fld_img_full , hzip.Img_full())
|
||||
.Exec_insert();
|
||||
}
|
||||
private int Len_or_0(byte[] bry) {return bry == null ? 0 : bry.length;}
|
||||
}
|
||||
@@ -41,7 +41,6 @@ public class Xoh_hdoc_ctx {
|
||||
public Xoh_pool_mgr__hzip Pool_mgr__hzip() {return pool_mgr__hzip;} private final Xoh_pool_mgr__hzip pool_mgr__hzip = new Xoh_pool_mgr__hzip();
|
||||
public Xoh_pool_mgr__data Pool_mgr__data() {return pool_mgr__data;} private final Xoh_pool_mgr__data pool_mgr__data = new Xoh_pool_mgr__data();
|
||||
public Xoh_pool_mgr__wtr Pool_mgr__wtr() {return pool_mgr__wtr;} private final Xoh_pool_mgr__wtr pool_mgr__wtr = new Xoh_pool_mgr__wtr();
|
||||
public Xoh_stat_itm Hzip__stat() {return hzip__stat;} private final Xoh_stat_itm hzip__stat = new Xoh_stat_itm();
|
||||
public Xohz_tag_regy Hzip__xnde__regy() {return hzip__xnde__regy;} private final Xohz_tag_regy hzip__xnde__regy = Xohz_tag_regy_.New_dflt();
|
||||
public Xoh_xnde_dict_reg Hzip__xnde__dict() {return hzip__xnde__dict;} private final Xoh_xnde_dict_reg hzip__xnde__dict = new Xoh_xnde_dict_reg();
|
||||
public int Uid__gly__nxt() {return ++uid__gly;} private int uid__gly;
|
||||
@@ -87,7 +86,6 @@ public class Xoh_hdoc_ctx {
|
||||
this.Clear();
|
||||
}
|
||||
private void Clear() {
|
||||
hzip__stat.Clear();
|
||||
this.uid__gly = -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,10 @@ package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
|
||||
private final Xoh_stat_itm stat_itm = new Xoh_stat_itm();
|
||||
private Xoh_hzip_bfr bfr; private Xoh_hdoc_ctx hctx; private byte[] src;
|
||||
private Xoh_page hpg;
|
||||
public void On_page_bgn(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end) {
|
||||
this.bfr = (Xoh_hzip_bfr)bfr; this.hpg = hpg; this.hctx = hctx; this.src = src;
|
||||
stat_itm.Clear();
|
||||
}
|
||||
public void On_page_end() {}
|
||||
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class Xoh_gallery_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
|
||||
hctx.Hzip__stat().Gallery_add();
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
|
||||
@@ -25,7 +25,6 @@ public class Xoh_pgbnr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
|
||||
hctx.Hzip__stat().Gallery_add();
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
|
||||
@@ -26,7 +26,6 @@ public class Xoh_timeline_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
// just add the entire thing; not worth trying to compress "<pre class='xowa-timeline'>"
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
|
||||
hctx.Hzip__stat().Timeline_add();
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
|
||||
@@ -17,7 +17,6 @@ package gplx.xowa.htmls.core.wkrs.escapes; import gplx.*; import gplx.xowa.*; im
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_escape_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
private byte escape_byte;
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__escape;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public String Key() {return Xoh_hzip_dict_.Key__escape;}
|
||||
@@ -26,7 +25,6 @@ public class Xoh_escape_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
Xoh_escape_data data = (Xoh_escape_data)data_obj;
|
||||
bfr.Add(hook); // EX: 1,0
|
||||
bfr.Add(data.Hook()); // EX: 2
|
||||
hctx.Hzip__stat().Escape_add(escape_byte);
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
@@ -37,7 +35,6 @@ public class Xoh_escape_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
Xoh_escape_hzip rv = new Xoh_escape_hzip();
|
||||
rv.pool_mgr = mgr; rv.pool_idx = idx;
|
||||
rv.hook = (byte[])args[0];
|
||||
rv.escape_byte = rv.hook[0];
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class Xoh_hdr_html {
|
||||
// init
|
||||
int hdr_num = hdr.Num();
|
||||
boolean hdr_is_valid = hdr_num > 0; // hdr_num == 0 when dangling
|
||||
page.Stat_itm().Hdr_count++;
|
||||
|
||||
// register hdr with TOC
|
||||
byte[] hdr_text_bry = Bld_hdr_html(hdr_text_bfr, wtr, page, ctx, hctx, src, hdr);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xoh_hdr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
Xoh_hdr_data data = (Xoh_hdr_data)data_obj;
|
||||
boolean capt_rhs_exists = flag_bldr.Set_as_bool (Flag__capt_rhs_exists , data.Capt_rhs_exists());
|
||||
boolean anch_is_diff = flag_bldr.Set_as_bool (Flag__anch_is_diff , data.Anch_is_diff());
|
||||
int hdr_level = flag_bldr.Set_as_int (Flag__hdr_level , data.Hdr_level());
|
||||
flag_bldr.Set_as_int (Flag__hdr_level , data.Hdr_level());
|
||||
|
||||
bfr.Add(hook);
|
||||
bfr.Add_hzip_int(1, flag_bldr.Encode());
|
||||
@@ -32,7 +32,6 @@ public class Xoh_hdr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
if (anch_is_diff) bfr.Add_hzip_mid(src, data.Anch_bgn(), data.Anch_end()); // add anchor
|
||||
if (capt_rhs_exists) bfr.Add_hzip_mid(src, data.Capt_rhs_bgn(), data.Capt_rhs_end());// add capt_rhs
|
||||
|
||||
hctx.Hzip__stat().Hdr_add(hdr_level);
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
@@ -50,7 +49,7 @@ public class Xoh_hdr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
Xoh_hdr_data data = (Xoh_hdr_data)data_itm;
|
||||
data.Init_by_decode(hdr_level, anch_is_diff, anch_bgn, anch_end, capt_bgn, capt_end, capt_rhs_bgn, capt_rhs_end);
|
||||
}
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (1, 1, 3);
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (1, 1, 3);
|
||||
private static final int // SERIALIZED
|
||||
Flag__capt_rhs_exists = 0
|
||||
, Flag__anch_is_diff = 1
|
||||
|
||||
@@ -105,7 +105,7 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
if (img_src.File_page_exists()) Gfo_hzip_int_.Encode(1, bfr, Gfo_hzip_int_.Neg_1_adj + img_src.File_page());
|
||||
}
|
||||
else
|
||||
xoimg.Encode(bfr, hctx.Hzip__stat(), src, img_xoimg);
|
||||
xoimg.Encode(bfr, src, img_xoimg);
|
||||
if (anch_title_exists) bfr.Add_hzip_mid(src, data.Anch_title_bgn(), data.Anch_title_end());
|
||||
if (img__alt_diff_from_anch_title) bfr.Add_hzip_mid(src, data.Img_alt_bgn(), data.Img_alt_end());
|
||||
if (img_cls.Other_exists()) bfr.Add_hzip_mid(src, img_cls.Other_bgn(), img_cls.Other_end());
|
||||
|
||||
@@ -18,7 +18,7 @@ import gplx.core.brys.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.parsers.lnkis.*; import gplx.xowa.files.*;
|
||||
public class Xoh_img_xoimg_hzip {
|
||||
public void Encode(Bry_bfr bfr, Xoh_stat_itm stat_itm, byte[] src, Xoh_img_xoimg_data arg) {
|
||||
public void Encode(Bry_bfr bfr, byte[] src, Xoh_img_xoimg_data arg) {
|
||||
boolean page_exists = arg.Lnki_page() != Xof_lnki_page.Null;
|
||||
boolean time_exists = arg.Lnki_time() != Xof_lnki_time.Null;
|
||||
boolean upright_exists = arg.Lnki_upright() != Xof_img_size.Upright_null;
|
||||
|
||||
@@ -32,6 +32,7 @@ public class Xoh_lnke_html {
|
||||
bfr.Add(Gfh_tag_.Div_rhs);
|
||||
return;
|
||||
}
|
||||
ctx.Page().Stat_itm().Lnke_count++;
|
||||
if (!hctx.Mode_is_alt()) { // do not write "<a ...>" if mode is alt
|
||||
bfr.Add(Gfh_bldr_.Bry__a_lhs_w_href);
|
||||
if (Write_href(bfr, hctx, ctx, src, lnke, href_bgn, href_end, proto_is_xowa))
|
||||
|
||||
@@ -25,14 +25,13 @@ public class Xoh_lnke_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
boolean title_exists = flag_bldr.Set_as_bool(Flag__title_exists , data.Title_exists());
|
||||
boolean auto_exists = flag_bldr.Set_as_bool(Flag__auto_exists , data.Auto_exists());
|
||||
boolean capt_exists = flag_bldr.Set_as_bool(Flag__capt_exists , data.Capt_exists());
|
||||
byte lnke_tid = flag_bldr.Set_as_byte(Flag__lnke_tid , data.Lnke_tid());
|
||||
flag_bldr.Set_as_byte(Flag__lnke_tid , data.Lnke_tid());
|
||||
bfr.Add(hook);
|
||||
bfr.Add_hzip_int(1, flag_bldr.Encode()); // add flag
|
||||
bfr.Add_hzip_mid(src, data.Href_bgn(), data.Href_end()); // add href
|
||||
if (auto_exists) bfr.Add_hzip_int(1, data.Auto_id()); // add autonumber
|
||||
if (capt_exists) bfr.Add_hzip_mid(src, data.Capt_bgn(), data.Capt_end()); // add caption
|
||||
if (title_exists) bfr.Add_hzip_mid(src, data.Title_bgn(), data.Title_end()); // add title
|
||||
hctx.Hzip__stat().Lnke_add(lnke_tid);
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
|
||||
@@ -38,7 +38,6 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
flag_bldr.Set_as_int(Flag__capt_cs0_tid , data.Capt_itm().Cs0_tid());
|
||||
byte text_type = flag_bldr.Set_as_byte(Flag__text_type , data.Text_tid());
|
||||
// Tfds.Dbg(flag_bldr.Encode(), Array_.To_str(flag_bldr.Val_ary()), text_type);
|
||||
int bfr_bgn = bfr.Len();
|
||||
int flag = flag_bldr.Encode();
|
||||
bfr.Add(hook);
|
||||
bfr.Add_hzip_int(1, flag);
|
||||
@@ -57,7 +56,6 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
break;
|
||||
}
|
||||
if (title_tid == Xoh_lnki_data.Title__diff) bfr.Add_hzip_mid(src, data.Title_bgn(), data.Title_end());
|
||||
hctx.Hzip__stat().Lnki_add(data.Src_end() - data.Src_bgn(), bfr.Len() - bfr_bgn, flag);
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
|
||||
@@ -93,6 +93,7 @@ public class Xoh_file_wtr__basic implements Gfo_invk {
|
||||
? caption_fmtr.To_bry(ctx, hctx, src, lnki.Caption_val_tkn(), Bool_.N, Xoh_lnki_text_fmtr.Null__fmt)
|
||||
: lnki.Ttl().Full_db();
|
||||
html_fmtr.Add_media(bfr, hctx.Mode_is_hdump(), img_orig_src, lnki_ttl_bry, media_html); // NOTE: use orig_src not view_src; DATE:2014-01-19
|
||||
page.Stat_itm().Media_count++;
|
||||
}
|
||||
else {
|
||||
// orig_is_video
|
||||
@@ -110,11 +111,16 @@ public class Xoh_file_wtr__basic implements Gfo_invk {
|
||||
if (orig_is_video) {
|
||||
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_vid); // mark as vid for js_mgr
|
||||
this.Write_file_video(bfr, ctx, hctx, src, lnki, img_orig_src, uid, div_width, lnki_halign_bry, lnki_href, img_alt, lnki_ttl_bry, img_view_src, xfer_itm);
|
||||
page.Stat_itm().Video_count++;
|
||||
}
|
||||
else if (orig_ext.Id_is_audio()) // audio
|
||||
else if (orig_ext.Id_is_audio()) { // audio
|
||||
this.Write_file_audio(bfr, ctx, hctx, src, lnki, img_orig_src, uid, div_width, lnki_halign_bry, lnki_href, img_alt, lnki_ttl_bry);
|
||||
else // image
|
||||
page.Stat_itm().Audio_count++;
|
||||
}
|
||||
else { // image
|
||||
this.Write_file_image(bfr, ctx, hctx, src, lnki, img_orig_src, uid, div_width, lnki_halign_bry, lnki_href, img_alt, lnki_ttl_bry, img_view_src, xfer_itm, lnki_is_thumbable, lnki_halign, orig_ext);
|
||||
page.Stat_itm().Image_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Write_file_audio(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] img_orig_src, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_href, byte[] alt, byte[] lnki_ttl) {
|
||||
|
||||
@@ -65,9 +65,22 @@ public class Xoh_lnki_wtr {
|
||||
redlinks_mgr.Add(lnki);
|
||||
boolean stage_is_alt = hctx.Mode_is_alt();
|
||||
switch (lnki.Ns_id()) {
|
||||
case Xow_ns_.Tid__media: if (!stage_is_alt) file_wtr.Write_or_queue(bfr, page, ctx, hctx, src, lnki); return; // NOTE: literal ":" has no effect; PAGE:en.w:Beethoven and [[:Media:De-Ludwig_van_Beethoven.ogg|listen]]
|
||||
case Xow_ns_.Tid__file: if (!literal_link && !stage_is_alt) {file_wtr.Write_or_queue(bfr, page, ctx, hctx, src, lnki); return;} break;
|
||||
case Xow_ns_.Tid__category: if (!literal_link) {page.Wtxt().Ctgs__add(lnki.Ttl()); return;} break;
|
||||
case Xow_ns_.Tid__media:
|
||||
if (!stage_is_alt)
|
||||
file_wtr.Write_or_queue(bfr, page, ctx, hctx, src, lnki);
|
||||
return; // NOTE: literal ":" has no effect; PAGE:en.w:Beethoven and [[:Media:De-Ludwig_van_Beethoven.ogg|listen]]
|
||||
case Xow_ns_.Tid__file:
|
||||
if (!literal_link && !stage_is_alt) {
|
||||
file_wtr.Write_or_queue(bfr, page, ctx, hctx, src, lnki);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case Xow_ns_.Tid__category:
|
||||
if (!literal_link) {
|
||||
page.Wtxt().Ctgs__add(lnki.Ttl());
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Write_plain_by_tkn(bfr, hctx, src, lnki, lnki_ttl);
|
||||
}
|
||||
@@ -98,6 +111,7 @@ public class Xoh_lnki_wtr {
|
||||
}
|
||||
}
|
||||
if (lnki.Xtn_sites_link()) return; // lnki marked for relatedSites; don't write to page
|
||||
page.Stat_itm().Lnki_count++;
|
||||
if (hctx.Mode_is_alt())
|
||||
Write_caption(bfr, ctx, hctx, src, lnki, ttl_bry, true, caption_wkr);
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user