mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v3.1.3.1
This commit is contained in:
@@ -23,7 +23,7 @@ import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
public class Xow_hdump_mgr__load {
|
||||
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 Hash_adp_bry page_overrides;
|
||||
private Xow_override_mgr override_mgr__html, override_mgr__page;
|
||||
public Xow_hdump_mgr__load(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
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(wiki.App().Usr_dlg(), wiki.App().Fsys_mgr(), gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx, wiki.Domain_bry());
|
||||
@@ -37,11 +37,21 @@ public class Xow_hdump_mgr__load {
|
||||
}
|
||||
public boolean Load(Xoh_page hpg, Xoa_ttl ttl) {
|
||||
synchronized (tmp_dbpg) {
|
||||
if (page_overrides == null) page_overrides = Init_page_overrides(wiki);
|
||||
if (!Load__dbpg(wiki, tmp_dbpg.Clear(), hpg, ttl)) return Load__fail(hpg); // nothing in "page" table
|
||||
Xowd_db_file html_db = wiki.Data__core_mgr().Dbs__get_at(tmp_dbpg.Html_db_id());
|
||||
if (override_mgr__page == null) {
|
||||
Io_url override_root_url = wiki.Fsys_mgr().Root_dir().GenSubDir_nest("data", "wiki");
|
||||
this.override_mgr__page = new Xow_override_mgr(override_root_url.GenSubDir_nest("page"));
|
||||
this.override_mgr__html = new Xow_override_mgr(override_root_url.GenSubDir_nest("html"));
|
||||
}
|
||||
boolean loaded = Load__dbpg(wiki, tmp_dbpg.Clear(), hpg, ttl);
|
||||
hpg.Init(hpg.Wiki(), hpg.Url(), ttl, tmp_dbpg.Id());
|
||||
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html_page" table
|
||||
if (!loaded) { // nothing in "page" table
|
||||
byte[] page_override = override_mgr__page.Get_or_same(ttl.Page_db(), null);
|
||||
if (page_override == null) return Load__fail(hpg);
|
||||
hpg.Body_(page_override);
|
||||
return true;
|
||||
}
|
||||
Xowd_db_file html_db = wiki.Data__core_mgr().Dbs__get_at(tmp_dbpg.Html_db_id());
|
||||
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html" table
|
||||
byte[] src = Parse(hpg, hpg.Body_zip_tid(), hpg.Body_hzip_tid(), hpg.Body());
|
||||
hpg.Body_(src);
|
||||
return true;
|
||||
@@ -52,8 +62,7 @@ public class Xow_hdump_mgr__load {
|
||||
if (zip_tid > gplx.core.ios.Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Unzip((byte)zip_tid, src);
|
||||
if (hzip_tid == Xoh_hzip_dict_.Hzip__v1) {
|
||||
byte[] page_override_src = (byte[])page_overrides.Get_by_bry(hpg.Ttl().Page_db());
|
||||
if (page_override_src != null) src = page_override_src;
|
||||
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
|
||||
src = Decode_as_bry(tmp_bfr.Clear(), hpg, src, Bool_.N);
|
||||
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length);
|
||||
@@ -88,19 +97,28 @@ public class Xow_hdump_mgr__load {
|
||||
if (redirect_id == -1) break;
|
||||
}
|
||||
}
|
||||
private static Hash_adp_bry Init_page_overrides(Xow_wiki wiki) {
|
||||
Hash_adp_bry rv = Hash_adp_bry.cs();
|
||||
Io_url[] page_urls = Io_mgr.Instance.QueryDir_fils(wiki.Fsys_mgr().Root_dir().GenSubDir_nest("data", "page"));
|
||||
int page_urls_len = page_urls.length;
|
||||
for (int i = 0; i < page_urls_len; ++i) {
|
||||
Io_url page_url = page_urls[i];
|
||||
byte[] page_raw = Io_mgr.Instance.LoadFilBry(page_url);
|
||||
int page_raw_len = page_raw.length;
|
||||
int page_nl = Bry_find_.Find_fwd(page_raw, Byte_ascii.Nl, 0, page_raw_len); if (page_nl == Bry_find_.Not_found) continue;
|
||||
byte[] page_ttl_bry = Bry_.Mid(page_raw, 0, page_nl);
|
||||
byte[] page_src_bry = Bry_.Mid(page_raw, page_nl + 1, page_raw_len);
|
||||
rv.Add_bry_obj(page_ttl_bry, page_src_bry);
|
||||
}
|
||||
class Xow_override_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private final Io_url root_dir;
|
||||
private boolean init = true;
|
||||
public Xow_override_mgr(Io_url root_dir) {this.root_dir = root_dir;}
|
||||
public void Clear() {hash.Clear();}
|
||||
public byte[] Get_or_same(byte[] ttl, byte[] src) {
|
||||
if (init) {init = false; Load_from_fsys(hash, root_dir);}
|
||||
byte[] rv = (byte[])hash.Get_by_bry(ttl);
|
||||
return rv == null ? src : rv;
|
||||
}
|
||||
private static void Load_from_fsys(Hash_adp_bry hash, Io_url root_dir) {
|
||||
Io_url[] urls = Io_mgr.Instance.QueryDir_args(root_dir).Recur_(true).ExecAsUrlAry();
|
||||
int urls_len = urls.length;
|
||||
for (int i = 0; i < urls_len; ++i) {
|
||||
Io_url url = urls[i];
|
||||
byte[] raw = Io_mgr.Instance.LoadFilBry(url); int bry_len = raw.length;
|
||||
int nl_pos = Bry_find_.Find_fwd(raw, Byte_ascii.Nl, 0, bry_len); if (nl_pos == Bry_find_.Not_found) continue;
|
||||
byte[] ttl = Bry_.Mid(raw, 0, nl_pos);
|
||||
byte[] src = Bry_.Mid(raw, nl_pos + 1, bry_len);
|
||||
hash.Add_bry_obj(ttl, src);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class Xob_hdump_bldr implements GfoInvkAble {
|
||||
return true;
|
||||
}
|
||||
public void Insert(Xoae_page page) {
|
||||
tmp_hpg.Clear(); // NOTE: must clear tmp_hpg or else will leak memory during mass build; DATE:2016-01-09
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_body(tmp_bfr, Xoh_wtr_ctx.Hdump, page); // write to html in hdump mode
|
||||
byte[] orig_bry = tmp_bfr.To_bry_and_clear();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
class Xob_link_dump_tbl implements Rls_able {
|
||||
public static final String Tbl_name = "link_dump"; private static final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
public static final String Tbl_name = "link_dump"; private static final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
public static final String
|
||||
Fld_uid = flds.Add_int_pkey_autonum("uid")
|
||||
, Fld_src_page_id = flds.Add_int("src_page_id")
|
||||
@@ -33,16 +33,16 @@ class Xob_link_dump_tbl implements Rls_able {
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(Tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(Tbl_name, flds));}
|
||||
public void Create_idx_1() {
|
||||
conn.Ddl_create_idx
|
||||
( Db_meta_idx.new_normal_by_tbl(Tbl_name, "src", Fld_src_page_id, Fld_src_html_uid)
|
||||
, Db_meta_idx.new_normal_by_tbl(Tbl_name, "trg_temp", Fld_trg_ns, Fld_trg_ttl)
|
||||
( Dbmeta_idx_itm.new_normal_by_tbl(Tbl_name, "src", Fld_src_page_id, Fld_src_html_uid)
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(Tbl_name, "trg_temp", Fld_trg_ns, Fld_trg_ttl)
|
||||
);
|
||||
}
|
||||
public void Create_idx_2() {
|
||||
conn.Ddl_create_idx
|
||||
( Db_meta_idx.new_normal_by_tbl(Tbl_name, "trg", Fld_trg_page_id, Fld_src_page_id, Fld_src_html_uid)
|
||||
( Dbmeta_idx_itm.new_normal_by_tbl(Tbl_name, "trg", Fld_trg_page_id, Fld_src_page_id, Fld_src_html_uid)
|
||||
);
|
||||
}
|
||||
public void Rls() {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.core.brys.*;
|
||||
public class Xoh_page_tbl implements Rls_able {
|
||||
private final String tbl_name = "html"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String tbl_name = "html"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_page_id, fld_head_flag, fld_body_flag, fld_display_ttl, fld_content_sub, fld_sidebar_div, fld_body;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
private final Int_flag_bldr body_flag_bldr = new Int_flag_bldr().Pow_ary_bld_(3, 2); // 8 different zip types; 4 different hzip types
|
||||
@@ -34,7 +34,7 @@ public class Xoh_page_tbl implements Rls_able {
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("html__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(Xoh_page hpg, int zip_tid, int hzip_tid, byte[] body) {Insert(hpg.Page_id(), hpg.Head_mgr().Flag(), zip_tid, hzip_tid, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xoh_redlink_tbl implements Rls_able {
|
||||
private final String tbl_name = "html_redlink"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String tbl_name = "html_redlink"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_page_id, fld_redlink_uids;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
public Xoh_redlink_tbl(Db_conn conn) {
|
||||
@@ -28,7 +28,7 @@ public class Xoh_redlink_tbl implements Rls_able {
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("html_redlink__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(int page_id, byte[] redlink_uids) {
|
||||
|
||||
@@ -1,63 +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.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.encoders.*;
|
||||
public class Xoh_hzip_int_ {
|
||||
public static final int Neg_1_adj = 1;
|
||||
public static void Encode(int reqd, Bry_bfr bfr, int val) {
|
||||
int bfr_len = bfr.Len();
|
||||
int len_in_base85 = Base85_.Bry_len(val);
|
||||
boolean abrv = val < Base85_.Pow85[reqd];
|
||||
int adj = abrv ? 0 : 1;
|
||||
int actl_len = len_in_base85 + adj;
|
||||
if (actl_len < reqd) actl_len = reqd;
|
||||
bfr.Add_byte_repeat(Byte_ascii.Bang, actl_len); // fill with 0s; this asserts that there underlying array will be large enough for following write
|
||||
byte[] bfr_bry = bfr.Bfr(); // NOTE: set bry reference here b/c Add_byte_repeat may create a new one
|
||||
Base85_.Set_bry(val, bfr_bry, bfr_len + adj, reqd); // calc base85 val for val; EX: 7224 -> "uu"
|
||||
if (!abrv) {
|
||||
byte base85_byte = Base85_len__2;
|
||||
switch (len_in_base85) {
|
||||
case 3: base85_byte = Base85_len__3; break;
|
||||
case 4: base85_byte = Base85_len__4; break;
|
||||
case 5: base85_byte = Base85_len__5; break;
|
||||
}
|
||||
bfr_bry[bfr_len] = base85_byte;
|
||||
}
|
||||
}
|
||||
public static int Decode(int reqd, byte[] src, int src_len, int src_bgn, Int_obj_ref pos_ref) {
|
||||
byte b0 = src[src_bgn];
|
||||
int base85_bgn = src_bgn + 1;
|
||||
int len_in_base85 = 1; // default to 1
|
||||
switch (b0) {
|
||||
case Base85_len__2: len_in_base85 = 2; break;
|
||||
case Base85_len__3: len_in_base85 = 3; break;
|
||||
case Base85_len__4: len_in_base85 = 4; break;
|
||||
case Base85_len__5: len_in_base85 = 5; break;
|
||||
default: --base85_bgn; break;
|
||||
}
|
||||
if (len_in_base85 < reqd) len_in_base85 = reqd;
|
||||
int base85_end = base85_bgn + len_in_base85;
|
||||
pos_ref.Val_(base85_end);
|
||||
return Base85_.To_int_by_bry(src, base85_bgn, base85_end - 1);
|
||||
}
|
||||
private static final byte
|
||||
Base85_len__2 = Byte_ascii.Curly_bgn
|
||||
, Base85_len__3 = Byte_ascii.Pipe
|
||||
, Base85_len__4 = Byte_ascii.Curly_end
|
||||
, Base85_len__5 = Byte_ascii.Tilde;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ 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.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.core.encoders.*;
|
||||
public class Xoh_hzip_int__tst {
|
||||
private final Xoh_hzip_int__fxt fxt = new Xoh_hzip_int__fxt();
|
||||
@Test public void Reqd__1() {
|
||||
@@ -40,9 +40,9 @@ class Xoh_hzip_int__fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final gplx.core.primitives.Int_obj_ref count_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
public void Test__encode(int reqd, int val, String expd) {
|
||||
Xoh_hzip_int_.Encode(reqd, bfr, val);
|
||||
Gfo_hzip_int_.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
Tfds.Eq(val, Xoh_hzip_int_.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
Tfds.Eq(val, Gfo_hzip_int_.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.makes.imgs.*; 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 Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private static final String tbl_name = "hdump_stats"; private static final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
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")
|
||||
@@ -36,7 +36,7 @@ public class Xoh_stat_tbl implements Rls_able {
|
||||
conn.Stmt_delete(tbl_name).Exec_delete(); // always zap table
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_page_id)));}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(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);
|
||||
}
|
||||
|
||||
@@ -1,91 +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/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.makes {
|
||||
// import org.junit.*;
|
||||
// public class Xoh_make_mgr__file__tst {
|
||||
// private final Xoh_make_mgr_fxt fxt = new Xoh_make_mgr_fxt();
|
||||
// @Before public void init() {
|
||||
// fxt.Clear();
|
||||
// fxt.Init_data_img_basic("A.png", 0, 220, 110);
|
||||
// }
|
||||
// @Test public void Img() {
|
||||
// fxt .Init_body("<img xowa_img='0' />")
|
||||
// .Test_html("<img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' />");
|
||||
// }
|
||||
// @Test public void Img_style() {
|
||||
// fxt .Init_body("<div xowa_img_style='0'>")
|
||||
// .Test_html("<div style='width:220px;'>");
|
||||
// }
|
||||
// @Test public void File_info() {
|
||||
// fxt .Init_body("<xowa_info id='0'/>")
|
||||
// .Test_html(String_.Concat_lines_nl_skip_last
|
||||
// ( ""
|
||||
// , " <div>"
|
||||
// , " <a href=\"/wiki/File:A.png\" class=\"image\" title=\"About this file\">"
|
||||
// , " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/info.png\" width=\"22\" height=\"22\" />"
|
||||
// , " </a>"
|
||||
// , " </div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void File_mgnf() {
|
||||
// fxt .Init_body("<xowa_mgnf id='0'/>")
|
||||
// .Test_html(String_.Concat_lines_nl_skip_last
|
||||
// ( ""
|
||||
// , " <div class=\"magnify\">"
|
||||
// , " <a href=\"/wiki/File:A.png\" class=\"internal\" title=\"A.png\">"
|
||||
// , " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/magnify-clip.png\" width=\"15\" height=\"11\" alt=\"\" />"
|
||||
// , " </a>"
|
||||
// , " </div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void File_play() {
|
||||
// fxt .Init_body("<xowa_play id='0'/>")
|
||||
// .Test_html(String_.Concat_lines_nl_skip_last
|
||||
// ( ""
|
||||
// , " <div>"
|
||||
// , " <a id=\"xowa_file_play_0\" href=\"/wiki/File:A.png\" xowa_title=\"A.png\" class=\"xowa_anchor_button\" style=\"width:220px;max-width:1024px;\">"
|
||||
// , " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
// , " </a>"
|
||||
// , " </div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Hiero_dir() {
|
||||
// fxt .Init_body("<img src='~{xowa_hiero_dir}hiero_a&A1.png' />")
|
||||
// .Test_html("<img src='file:///mem/xowa/bin/any/xowa/xtns/Wikihiero/img/hiero_a&A1.png' />");
|
||||
// }
|
||||
// @Test public void Gallery() {
|
||||
// fxt.Clear_imgs();
|
||||
// fxt .Init_data_gly(0, 800);
|
||||
// fxt .Init_data_img_gly("A.png", 0, 220, 110, 155, 150, 15);
|
||||
// fxt .Init_body(String_.Concat_lines_nl_skip_last
|
||||
// ( "<ul xowa_gly_box_max='0'>"
|
||||
// , " <li class='gallerybox' xowa_gly_box_w='0'>"
|
||||
// , " <div xowa_gly_box_w='0'>"
|
||||
// , " <div class='thumb' xowa_gly_img_w='0'>"
|
||||
// , " <div xowa_gly_img_pad='0'>"
|
||||
// ))
|
||||
// .Test_html(String_.Concat_lines_nl_skip_last
|
||||
// ( "<ul style=\"max-width:800px;_width:800px;\">"
|
||||
// , " <li class='gallerybox' style=\"width:155px;\">"
|
||||
// , " <div style=\"width:155px;\">"
|
||||
// , " <div class='thumb' style=\"width:150px;\">"
|
||||
// , " <div style=\"margin:15px auto;\">"
|
||||
// ));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.xndes.tags.*; import gplx.xowa.htmls.core.wkrs.xndes.dicts.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.metas.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.files.caches.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.metas.*;
|
||||
public class Xoh_hdoc_ctx {
|
||||
private byte[] fsys__file;
|
||||
public byte[] Fsys__root() {return fsys__root;} private byte[] fsys__root;
|
||||
@@ -30,7 +30,7 @@ public class Xoh_hdoc_ctx {
|
||||
public Xow_ttl_parser Wiki__ttl_parser() {return wiki__ttl_parser;} private Xow_ttl_parser wiki__ttl_parser;
|
||||
public Xoa_url_parser Wiki__url_parser() {return wiki__url_parser;} private Xoa_url_parser wiki__url_parser;
|
||||
public boolean Xwiki_mgr__missing(byte[] domain){return app.Xwiki_mgr__missing(domain);}
|
||||
public Xoa_file_mgr File__mgr() {return file__mgr;} private final Xoa_file_mgr file__mgr = new Xoa_file_mgr();
|
||||
public Xou_cache_finder File__mgr() {return file__mgr;} private Xou_cache_finder file__mgr = Xou_cache_finder_.Noop;
|
||||
public Xof_url_bldr File__url_bldr() {return file__url_bldr;} private final Xof_url_bldr file__url_bldr = new Xof_url_bldr();
|
||||
public byte[] Page__url() {return page__url;} private byte[] page__url;
|
||||
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();
|
||||
@@ -48,6 +48,8 @@ public class Xoh_hdoc_ctx {
|
||||
this.fsys__root = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.fsys__file = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.fsys__file__comm = Bry_.Add(fsys__file, Xow_domain_itm_.Bry__commons, Byte_ascii.Slash_bry);
|
||||
Xou_cache_mgr cache_mgr = app.User().User_db_mgr().Cache_mgr();
|
||||
if (cache_mgr != null) file__mgr = Xou_cache_finder_.New_db(cache_mgr); // NOTE: this effectively only loads the cache db in app mode (and not in test mode)
|
||||
pool_mgr__hzip.Init();
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki, byte[] page_url) {
|
||||
|
||||
@@ -42,6 +42,12 @@ public class Xoh_hzip_fxt {
|
||||
parser_fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_u8(alias), Bry_.new_u8(domain), null);
|
||||
return rv;
|
||||
}
|
||||
public void Init__ns_alias__add(String alias, int ns_id) {
|
||||
parser_fxt.Wiki().Ns_mgr().Aliases_add(ns_id, alias).Init();
|
||||
}
|
||||
public void Init__ns_alias__del(String alias) {
|
||||
parser_fxt.Wiki().Ns_mgr().Aliases_del(alias);
|
||||
}
|
||||
public void Test__bicode(String hzip, String html) {Test__bicode(hzip, html, html);}
|
||||
public void Test__bicode(String hzip, String html_enc, String html_dec) {
|
||||
html_enc = Gfh_utl.Replace_apos(html_enc);
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.brys.*;
|
||||
public class Bfr_arg__hatr_id implements Bfr_arg_clearable {
|
||||
private final byte[] atr_bgn;
|
||||
private final byte[] bry; private int num;
|
||||
public Bfr_arg__hatr_id(byte[] bry) {this.bry = bry; this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(gplx.langs.htmls.Gfh_atr_.Bry__id);}
|
||||
public Bfr_arg__hatr_id(byte[] atr_key, byte[] bry) {this.bry = bry; this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(atr_key);}
|
||||
public Bfr_arg__hatr_id Set(int num) {this.num = num; return this;}
|
||||
public void Bfr_arg__clear() {num = -1;}
|
||||
public boolean Bfr_arg__missing() {return num == -1;}
|
||||
@@ -31,6 +31,6 @@ public class Bfr_arg__hatr_id implements Bfr_arg_clearable {
|
||||
bfr.Add_int_variable(num);
|
||||
bfr.Add_byte_quote();
|
||||
}
|
||||
public static Bfr_arg__hatr_id New(String v) {return new Bfr_arg__hatr_id(Bry_.new_u8(v));}
|
||||
public static Bfr_arg__hatr_id New(byte[] v) {return new Bfr_arg__hatr_id(v);}
|
||||
public static Bfr_arg__hatr_id New_id(String v) {return new Bfr_arg__hatr_id(gplx.langs.htmls.Gfh_atr_.Bry__id, Bry_.new_u8(v));}
|
||||
public static Bfr_arg__hatr_id New_id(byte[] v) {return new Bfr_arg__hatr_id(gplx.langs.htmls.Gfh_atr_.Bry__id, v);}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,13 @@ import gplx.core.brys.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.styles.*; import gplx.langs.htmls.clses.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.xtns.gallery.*;
|
||||
public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { //
|
||||
public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr {
|
||||
private final List_adp itms_list = List_adp_.new_();
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public int Gly_tid() {return gly_tid;} private int gly_tid;
|
||||
public int Gly_w() {return gly_w;} private int gly_w;
|
||||
public int Ul_style_max_w() {return ul_style_max_w;} private int ul_style_max_w;
|
||||
public int Ul_style_w() {return ul_style_w;} private int ul_style_w;
|
||||
public int Xtra_atr_bgn() {return xtra_atr_bgn;} private int xtra_atr_bgn;
|
||||
public int Xtra_atr_end() {return xtra_atr_end;} private int xtra_atr_end;
|
||||
public boolean Xtra_atr_exists() {return xtra_atr_end > xtra_atr_bgn;}
|
||||
@@ -39,7 +40,7 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { /
|
||||
public Xoh_gly_itm_data Itms__get_at(int i) {return (Xoh_gly_itm_data)itms_list.Get_at(i);}
|
||||
private void Clear() {
|
||||
this.gly_tid = Byte_.Max_value_127;
|
||||
this.gly_w = 0;
|
||||
this.ul_style_max_w = ul_style_w = 0;
|
||||
this.xtra_atr_bgn = xtra_atr_end = xtra_cls_bgn = xtra_cls_end = xtra_style_bgn = xtra_style_end = -1;
|
||||
itms_list.Clear();
|
||||
}
|
||||
@@ -92,8 +93,11 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { /
|
||||
}
|
||||
}
|
||||
public boolean On_cls(byte[] src, int atr_idx, int atr_bgn, int atr_end, int val_bgn, int val_end) {
|
||||
if (Bry_.Match(src, val_bgn, val_end, Atr__cls__gallery)) {} // ignore "gallery"
|
||||
else if (Bry_.Match(src, val_bgn, val_bgn + Atr__cls__mw_gallery.length, Atr__cls__mw_gallery)) { // starts with 'mw-gallery-'
|
||||
int val_pos = val_bgn - atr_bgn;
|
||||
if ( Bry_.Match(src, val_bgn, val_end, Atr__cls__gallery) // ignore "gallery"
|
||||
&& val_pos == 0) {} // only if 1st; EX:'gallery mw-traditional gallery'; PAGE:en.w:Butuan; DATE:2016-01-05
|
||||
else if (Bry_.Match(src, val_bgn, val_bgn + Atr__cls__mw_gallery.length, Atr__cls__mw_gallery) // starts with 'mw-gallery-'
|
||||
&& val_pos == 8) { // occurs after "gallery "
|
||||
int tid_bgn = val_bgn + Atr__cls__mw_gallery.length;
|
||||
this.gly_tid = Gallery_mgr_base_.Hash.Get_as_byte_or(src, tid_bgn, val_end, Byte_.Max_value_127);
|
||||
return true;
|
||||
@@ -106,15 +110,22 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { /
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_bgn, int atr_end, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
if (Bry_.Match(src, key_bgn, key_end, Style__max_width)) // 'max-width'
|
||||
gly_w = Bry_.To_int_or__lax(src, val_bgn, val_end, 0);
|
||||
else if (Bry_.Match(src, key_bgn, key_end, Style___width)) {} // '_width'
|
||||
else {
|
||||
if (this.xtra_style_bgn == -1) {
|
||||
this.xtra_style_bgn = key_bgn;
|
||||
this.xtra_style_end = atr_end;
|
||||
}
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_val_bgn, int atr_val_end, int itm_bgn, int itm_end, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
if (Bry_.Match(src, key_bgn, key_end, Style__max_width)) { // 'max-width'
|
||||
if (ul_style_max_w == 0) {
|
||||
ul_style_max_w = Bry_.To_int_or__lax(src, val_bgn, val_end, 0);
|
||||
return true;
|
||||
} // else if already set, fall-thru to below
|
||||
}
|
||||
else if (Bry_.Match(src, key_bgn, key_end, Style___width)) { // '_width'
|
||||
if (ul_style_w == 0) {
|
||||
ul_style_w = Bry_.To_int_or__lax(src, val_bgn, val_end, 0);
|
||||
return true;
|
||||
} // else if already set, fall-thru to below
|
||||
}
|
||||
if (this.xtra_style_bgn == -1) {
|
||||
this.xtra_style_bgn = itm_bgn;
|
||||
this.xtra_style_end = atr_val_end;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
|
||||
class Xoh_gly_grp_wtr implements Bfr_arg {
|
||||
private final Bfr_arg_clearable[] arg_ary;
|
||||
private final Bfr_arg__hatr_id ul_id = Bfr_arg__hatr_id.New("xogly_li_");
|
||||
private final Bfr_arg__hatr_id ul_id = Bfr_arg__hatr_id.New_id("xogly_li_");
|
||||
private final Bfr_arg__hatr_gly_style ul_style = new Bfr_arg__hatr_gly_style(Gfh_atr_.Bry__style);
|
||||
private byte[] ul_cls, xtra_cls, xtra_atr_bry, ul_nl;
|
||||
private final Xoh_gly_itm_list_wtr itm_list_wtr = new Xoh_gly_itm_list_wtr();
|
||||
public Xoh_gly_grp_wtr() {
|
||||
arg_ary = new Bfr_arg_clearable[] {ul_id};
|
||||
}
|
||||
public void Init(boolean mode_is_diff, int id, byte[] cls, int ul_w, byte[] xtra_cls, byte[] xtra_style_bry, byte[] xtra_atr_bry, Xoh_gly_itm_wtr[] ary) {
|
||||
public void Init(boolean mode_is_diff, int id, byte[] cls, int ul_style_max_w, int ul_style_w, byte[] xtra_cls, byte[] xtra_style_bry, byte[] xtra_atr_bry, Xoh_gly_itm_wtr[] ary) {
|
||||
this.Clear();
|
||||
if (!mode_is_diff)
|
||||
ul_id.Set(id);
|
||||
@@ -36,7 +36,7 @@ class Xoh_gly_grp_wtr implements Bfr_arg {
|
||||
this.xtra_atr_bry = xtra_atr_bry;
|
||||
this.ul_nl = ary.length == 0 ? Bry_.Empty : Byte_ascii.Nl_bry; // TIDY: <ul></ul> should be on same line if 0 items
|
||||
itm_list_wtr.Init(ary);
|
||||
ul_style.Set_args(ul_w, xtra_style_bry);
|
||||
ul_style.Set_args(ul_style_max_w, ul_style_w, xtra_style_bry);
|
||||
}
|
||||
public void Clear() {
|
||||
for (Bfr_arg_clearable arg : arg_ary)
|
||||
@@ -72,35 +72,38 @@ class Xoh_gly_itm_list_wtr implements Bfr_arg {
|
||||
}
|
||||
class Bfr_arg__hatr_gly_style implements Bfr_arg {
|
||||
private final byte[] atr_bgn;
|
||||
private int width;
|
||||
private int max_w, w;
|
||||
private byte[] xtra_cls;
|
||||
public Bfr_arg__hatr_gly_style(byte[] key) {
|
||||
this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key);
|
||||
this.Clear();
|
||||
}
|
||||
public void Set_args(int w, byte[] xtra_cls) {this.width = w; this.xtra_cls = xtra_cls;}
|
||||
public void Clear() {width = 0; xtra_cls = null;}
|
||||
public void Set_args(int max_w, int w, byte[] xtra_cls) {this.max_w = max_w; this.w = w; this.xtra_cls = xtra_cls;}
|
||||
public void Clear() {max_w = 0; w = 0; xtra_cls = null;}
|
||||
public void Bfr_arg__clear() {this.Clear();}
|
||||
public boolean Bfr_arg__missing() {return width == 0 && xtra_cls == null;}
|
||||
public boolean Bfr_arg__missing() {return max_w == 0 && xtra_cls == null;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (Bfr_arg__missing()) return;
|
||||
bfr.Add(atr_bgn);
|
||||
if (width > 0) {
|
||||
if (max_w > 0) {
|
||||
bfr.Add(Style__frag_1);
|
||||
bfr.Add_int_variable(width);
|
||||
bfr.Add_int_variable(max_w);
|
||||
bfr.Add(Style__frag_3);
|
||||
}
|
||||
if (w > 0) {
|
||||
bfr.Add_byte_space();
|
||||
bfr.Add(Style__frag_2);
|
||||
bfr.Add_int_variable(width);
|
||||
bfr.Add_int_variable(w);
|
||||
bfr.Add(Style__frag_3);
|
||||
}
|
||||
if (xtra_cls != null) {
|
||||
if (width > 0) bfr.Add_byte_space();
|
||||
bfr.Add(xtra_cls);
|
||||
}
|
||||
bfr.Add_byte_quote();
|
||||
}
|
||||
private static final byte[]
|
||||
Style__frag_1 = Bry_.new_a7("max-width:")
|
||||
, Style__frag_2 = Bry_.new_a7("px; _width:")
|
||||
, Style__frag_2 = Bry_.new_a7("_width:")
|
||||
, Style__frag_3 = Bry_.new_a7("px;")
|
||||
;
|
||||
}
|
||||
@@ -23,8 +23,8 @@ public class Xoh_gly_html__dump__tst {
|
||||
@Test public void Basic() {
|
||||
fxt.Test__html(String_.Concat_lines_nl_skip_last
|
||||
( "<gallery>"
|
||||
, "File:A.jpg|A1"
|
||||
, "File:B.jpg|B1"
|
||||
, "File:A.png|A1"
|
||||
, "File:B.png|B1"
|
||||
, "</gallery>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
@@ -32,7 +32,7 @@ public class Xoh_gly_html__dump__tst {
|
||||
, " <div style='width:155px;'>"
|
||||
, " <div class='thumb' style='width:150px;'>"
|
||||
, " <div style='margin:15px auto;'>"
|
||||
, " <a href='/wiki/File:A.jpg' class='image' xowa_title='A.jpg'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class='gallerytext'><p>A1"
|
||||
@@ -45,7 +45,7 @@ public class Xoh_gly_html__dump__tst {
|
||||
, " <div style='width:155px;'>"
|
||||
, " <div class='thumb' style='width:150px;'>"
|
||||
, " <div style='margin:15px auto;'>"
|
||||
, " <a href='/wiki/File:B.jpg' class='image' xowa_title='B.jpg'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " <a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title=\"B.png\" data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class='gallerytext'><p>B1"
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.core.encoders.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.lnkis.anchs.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.ttls.*;
|
||||
@@ -29,19 +29,22 @@ public class Xoh_gly_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_gly_grp_data data = (Xoh_gly_grp_data)data_obj;
|
||||
boolean xtra_atr = flag_bldr.Set_as_bool(Flag__ul__xtra_atr , data.Xtra_atr_exists());
|
||||
boolean xtra_cls = flag_bldr.Set_as_bool(Flag__ul__xtra_cls , data.Xtra_cls_exists());
|
||||
boolean xtra_style = flag_bldr.Set_as_bool(Flag__ul__xtra_style , data.Xtra_style_exists());
|
||||
int ul_style_max_w = data.Ul_style_max_w(), ul_style_w = data.Ul_style_w();
|
||||
boolean ul_style_w_diff = flag_bldr.Set_as_bool(Flag__ul__style_w_diff , ul_style_max_w != ul_style_w);
|
||||
boolean xtra_atr = flag_bldr.Set_as_bool(Flag__ul__xtra_atr , data.Xtra_atr_exists());
|
||||
boolean xtra_cls = flag_bldr.Set_as_bool(Flag__ul__xtra_cls , data.Xtra_cls_exists());
|
||||
boolean xtra_style = flag_bldr.Set_as_bool(Flag__ul__xtra_style , data.Xtra_style_exists());
|
||||
flag_bldr.Set(Flag__gly_tid, data.Gly_tid());
|
||||
int itms_len = data.Itms__len();
|
||||
|
||||
bfr.Add(hook);
|
||||
Xoh_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
Xoh_hzip_int_.Encode(1, bfr, data.Gly_w());
|
||||
Gfo_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
Gfo_hzip_int_.Encode(1, bfr, ul_style_max_w);
|
||||
if (ul_style_w_diff) Gfo_hzip_int_.Encode(1, bfr, ul_style_w);
|
||||
if (xtra_cls) bfr.Add_hzip_mid(src, data.Xtra_cls_bgn(), data.Xtra_cls_end());
|
||||
if (xtra_style) bfr.Add_hzip_mid(src, data.Xtra_style_bgn(), data.Xtra_style_end());
|
||||
if (xtra_atr) bfr.Add_hzip_mid(src, data.Xtra_atr_bgn(), data.Xtra_atr_end());
|
||||
Xoh_hzip_int_.Encode(1, bfr, itms_len);
|
||||
Gfo_hzip_int_.Encode(1, bfr, itms_len);
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_gly_itm_data itm_parser = data.Itms__get_at(i);
|
||||
bfr.Add_hzip_int(1, itm_parser.Li_w());
|
||||
@@ -50,19 +53,21 @@ public class Xoh_gly_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
bfr.Add_byte((byte)(itm_parser.Capt_tid() + gplx.core.encoders.Base85_.A7_offset));
|
||||
bfr.Add_hzip_mid(src, itm_parser.Capt_bgn(), itm_parser.Capt_end());
|
||||
Xoh_hzip_wkr hzip_wkr = hctx.Pool_mgr__hzip().Mw__img();
|
||||
hzip_wkr.Encode1(bfr, hdoc_wkr, hctx, hpg, false, src, itm_parser.Img_parser());
|
||||
hzip_wkr.Encode1(bfr, hdoc_wkr, hctx, hpg, false, src, itm_parser.Img_data());
|
||||
hzip_wkr.Pool__rls();
|
||||
}
|
||||
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) {
|
||||
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
|
||||
boolean xtra_atr = flag_bldr.Get_as_bool(Flag__ul__xtra_atr);
|
||||
boolean xtra_cls = flag_bldr.Get_as_bool(Flag__ul__xtra_cls);
|
||||
boolean xtra_style = flag_bldr.Get_as_bool(Flag__ul__xtra_style);
|
||||
byte cls_tid = flag_bldr.Get_as_byte(Flag__gly_tid);
|
||||
boolean ul_style_w_diff = flag_bldr.Get_as_bool(Flag__ul__style_w_diff);
|
||||
boolean xtra_atr = flag_bldr.Get_as_bool(Flag__ul__xtra_atr);
|
||||
boolean xtra_cls = flag_bldr.Get_as_bool(Flag__ul__xtra_cls);
|
||||
boolean xtra_style = flag_bldr.Get_as_bool(Flag__ul__xtra_style);
|
||||
byte cls_tid = flag_bldr.Get_as_byte(Flag__gly_tid);
|
||||
byte[] cls_bry = Gallery_mgr_base_.Get_bry_by_tid(cls_tid);
|
||||
int ul_w = rdr.Read_hzip_int(1);
|
||||
int ul_style_max_w = rdr.Read_hzip_int(1);
|
||||
int ul_style_w = ul_style_w_diff ? rdr.Read_hzip_int(1) : ul_style_max_w;
|
||||
byte[] xtra_cls_bry = xtra_cls ? rdr.Read_bry_to(): null;
|
||||
byte[] xtra_style_bry = xtra_style ? rdr.Read_bry_to(): null;
|
||||
byte[] xtra_atr_bry = xtra_atr ? rdr.Read_bry_to(): null;
|
||||
@@ -85,16 +90,17 @@ public class Xoh_gly_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
img_data.Pool__rls();
|
||||
img_hzip.Pool__rls();
|
||||
}
|
||||
grp_wtr.Init(hctx.Mode_is_diff(), uid, cls_bry, ul_w, xtra_cls_bry, xtra_style_bry, xtra_atr_bry, itm_ary);
|
||||
grp_wtr.Init(hctx.Mode_is_diff(), uid, cls_bry, ul_style_max_w, ul_style_w, xtra_cls_bry, xtra_style_bry, xtra_atr_bry, itm_ary);
|
||||
grp_wtr.Bfr_arg__add(bfr);
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gly_hzip rv = new Xoh_gly_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1, 1, 3);
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1, 1, 1, 3);
|
||||
private static final int // SERIALIZED
|
||||
Flag__ul__xtra_atr = 0
|
||||
, Flag__ul__xtra_cls = 1
|
||||
, Flag__ul__xtra_style = 2
|
||||
, Flag__gly_tid = 3
|
||||
Flag__ul__style_w_diff = 0
|
||||
, Flag__ul__xtra_atr = 1
|
||||
, Flag__ul__xtra_cls = 2
|
||||
, Flag__ul__xtra_style = 3
|
||||
, Flag__gly_tid = 4
|
||||
;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xoh_gly_hzip_tst {
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
@@ -35,7 +35,32 @@ public class Xoh_gly_hzip_tst {
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title='B.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>B1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>abc"));
|
||||
}
|
||||
@Test public void Clear_state() { // page # wasn't being cleared between gallery itms; PAGE:en.w:Almagest; DATE:2016-01-05
|
||||
fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~{\"d\"D\"D!#{\"g{\"b0!B1~!1B.png~{\"d\"D\"D!$abc", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|2' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xowa-title='B.png' data-xoimg='0|120|120|-1|-1|3' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>B1</p>"
|
||||
@@ -50,7 +75,7 @@ public class Xoh_gly_hzip_tst {
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'></div>"
|
||||
, "</div>"
|
||||
@@ -58,7 +83,7 @@ public class Xoh_gly_hzip_tst {
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'></div>"
|
||||
, "</div>"
|
||||
@@ -66,12 +91,14 @@ public class Xoh_gly_hzip_tst {
|
||||
, "</ul><p>abc</p>"));
|
||||
}
|
||||
@Test public void Capt_is_br() { // PURPOSE: handle captions which have <br>, not <p>; PAGE:s.w:Sociology; DATE:2015-12-20
|
||||
fxt.Test__bicode("~'!!\"{\"g{\"b0\"<b><i>A1</i></b>~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b0\"<b><i>A1</i></b>"
|
||||
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'><br>"
|
||||
, "<b><i>A1</i></b>"
|
||||
@@ -80,13 +107,161 @@ public class Xoh_gly_hzip_tst {
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void No_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
|
||||
@Test public void Capt_has_multiple_p() { // PURPOSE: handle captions with multiple <p>; PAGE:en.w:Wikipedia:Bot_requests/Archive_25; DATE:2016-01-12
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b0!a<br>"
|
||||
, "b</p>"
|
||||
, "<p><br>"
|
||||
, "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>a<br>"
|
||||
, "b</p>"
|
||||
, "<p><br>"
|
||||
, "</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Capt_has_complicated_nl_behavior() {// handle complicated captions which force <div> on different line PAGE:en.w:Tamago_kake_gohan; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b>\"<div class=\"center\"><a href=\"/wiki/B.png\" class=\"image\" xowa_title=\"B.png\"><img data-xowa-title=\"A.png\" data-xoimg=\"0|120|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"></a></div>"
|
||||
, "abc~\"\\A.png~#9\"D\"D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:29px auto;'><a href='/wiki/A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'><br>"
|
||||
, "<div class='center'><a href='/wiki/B.png' class='image' xowa_title='B.png'><img data-xowa-title='A.png' data-xoimg='0|120|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "abc</div>" // NOTE: tidy forces </div> to be on same line instead of next
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__no_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
|
||||
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__no_width() { // PURPOSE: if "_width" omitted, do not add back; EX: style="max-width:648px; margin:auto; background:transparent;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
|
||||
fxt.Test__bicode("~'i{,L! color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__max_width_duped() { // PURPOSE: if max-width duped, do not delete 2nd; EX: style="max-width:648px; color:blue; max-width:648px;"; PAGE:en.w:Wikipedia:Village_pump_(technical)/Archive_86 DATE:2016-01-12
|
||||
fxt.Test__bicode("~'){(Z max-width:648px; color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:652px; _width:652px; max-width:648px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__invalid_unclosed() { // handle broken styles; EX: <gallery style='center'>
|
||||
fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional center' style='center'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:75px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__extra_colon() { // handle broken styles; EX: <gallery style='a:b:c:d;' PAGE:en.w:Bronze_Horseman DATE:2016-01-05
|
||||
fxt.Test__bicode("~'9!center~color:red:float:right;~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional center' style='color:red:float:right;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:75px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>abc</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Style__ws() { // PURPOSE: handle ws in style; EX: <gallery class="gallery mw-gallery-traditional" style="max-width:1115px; _width:1115px; color:blue;'>; PAGE:en.w:Anti-Serb_sentiment; DATE:2016-01-08
|
||||
fxt.Test__bicode("~'){,L color:blue;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
@@ -101,7 +276,7 @@ public class Xoh_gly_hzip_tst {
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
@@ -110,28 +285,13 @@ public class Xoh_gly_hzip_tst {
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Xtra_style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~'){,Lcolor:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
|
||||
@Test public void Extra_cls__gallery() { // handle redundant gallery; EX: <gallery class='gallery'>; PAGE:en.w:Butuan; DATE:2016-01-05
|
||||
fxt.Test__bicode("~'1!gallery~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional gallery'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</li>"
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Xtra_style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
|
||||
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
@@ -146,7 +306,7 @@ public class Xoh_gly_hzip_tst {
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1</p>"
|
||||
@@ -156,12 +316,15 @@ public class Xoh_gly_hzip_tst {
|
||||
, "</ul>"));
|
||||
}
|
||||
@Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where <p> is put on one line ("<p>a</p>") unless it ends with <br> ("<p>a<br>\n</p>")
|
||||
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1<br>~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~'!!\"{\"g{\"b0!A1<br>"
|
||||
, "~!1A.png~9\"D\"D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<ul class='gallery mw-gallery-traditional'>"
|
||||
, "<li class='gallerybox' style='width:155px;'>"
|
||||
, "<div style='width:155px;'>"
|
||||
, "<div class='thumb' style='width:150px;'>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='gallerytext'>"
|
||||
, "<p>A1<br>" // TIDY: <br> forces </p> to be on next line
|
||||
|
||||
@@ -22,7 +22,7 @@ import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*
|
||||
public class Xoh_gly_itm_data {
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public Xoh_img_data Img_parser() {return img_parser;} private Xoh_img_data img_parser = new Xoh_img_data();
|
||||
public Xoh_img_data Img_data() {return img_data;} private Xoh_img_data img_data = new Xoh_img_data();
|
||||
public boolean Img_exists() {return img_exists;} private boolean img_exists;
|
||||
public int Li_w() {return li_w;} private int li_w;
|
||||
public int Div_1_w() {return div_1_w;} private int div_1_w;
|
||||
@@ -34,6 +34,7 @@ public class Xoh_gly_itm_data {
|
||||
img_exists = false;
|
||||
capt_bgn = capt_end = li_w = div_1_w = div_2_margin = -1;
|
||||
capt_tid = Capt_tid__null;
|
||||
img_data.Clear();
|
||||
}
|
||||
public boolean Parse1(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, byte[] src, Gfh_tag_rdr tag_rdr, Gfh_tag li_tag) {
|
||||
this.Clear();
|
||||
@@ -45,7 +46,7 @@ public class Xoh_gly_itm_data {
|
||||
if (!div_1_head.Chk(Gfh_tag_.Id__div, Xoh_thm_data.Atr__class__thumb)) return false; // chk for <div class="thumb" style="height: 170px;">
|
||||
this.div_1_w = div_1_head.Atrs__style_get_as_int(Gfh_style_key_.Bry__width);
|
||||
int div_2_bgn = div_1_head.Src_end();
|
||||
Gfh_tag div_1_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div); // </div> for class="thumb"
|
||||
Gfh_tag div_1_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div); // </div> for class="thumb"
|
||||
int div_2_end = div_1_tail.Src_bgn();
|
||||
Gfh_tag div_2_head = tag_rdr.Tag__find_fwd_head(div_2_bgn, div_2_end, Gfh_tag_.Id__div); // find <div style="margin:15px auto;">
|
||||
if (div_2_head.Src_exists()) { // img_exists
|
||||
@@ -54,7 +55,7 @@ public class Xoh_gly_itm_data {
|
||||
tag_rdr.Pos_(div_2_head.Src_end());
|
||||
Gfh_tag anch_tag = tag_rdr.Tag__move_fwd_head();
|
||||
if (!anch_tag.Chk(Gfh_tag_.Id__a, Xoh_img_data.Bry__cls__anch__image)) return false;
|
||||
if (!img_parser.Init_by_parse(hdoc_wkr, hctx, tag_rdr, src, anch_tag, null)) return false;
|
||||
if (!img_data.Init_by_parse(hdoc_wkr, hctx, tag_rdr, src, anch_tag, null)) return false;
|
||||
}
|
||||
else {
|
||||
img_exists = false;
|
||||
@@ -90,14 +91,15 @@ public class Xoh_gly_itm_data {
|
||||
capt_bgn = Bry_find_.Find_fwd_while_not_ws(src, capt_bgn, capt_tail_bgn);
|
||||
capt_end = capt_tail_bgn;
|
||||
if (capt_head_is_p) {
|
||||
Gfh_tag para_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__p);
|
||||
capt_end = para_tail.Src_bgn();
|
||||
Gfh_tag div_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div); // search for closing </div>
|
||||
capt_end = div_tail.Src_bgn();
|
||||
if (Bry_.Match(src, capt_end - 5, capt_end, Bry__p__rhs))
|
||||
capt_end -= 5; // set capt_end to before </p>; 5 = "\n</p>";
|
||||
}
|
||||
capt_end = Bry_find_.Find_bwd__skip_ws(src, capt_end, -1);
|
||||
tag_rdr.Pos_(capt_tail_end);
|
||||
return true;
|
||||
}
|
||||
private static final byte[] Atr__cls__gallerytext = Bry_.new_a7("gallerytext");
|
||||
private static final byte[] Atr__cls__gallerytext = Bry_.new_a7("gallerytext"), Bry__p__rhs = Bry_.new_a7("</p>\n");
|
||||
public static final byte Capt_tid__p = 0, Capt_tid__br = 1, Capt_tid__empty = 2, Capt_tid__null = 3;
|
||||
private static final Btrie_slim_mgr Capt_tid__trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_bry_byte(Gfh_tag_.P_lhs , Capt_tid__p)
|
||||
|
||||
@@ -20,8 +20,8 @@ import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
public class Xoh_gly_itm_wtr implements Bfr_arg {
|
||||
private final Bfr_arg_clearable[] arg_ary;
|
||||
private final Bfr_arg__hatr_id li_id = Bfr_arg__hatr_id.New("xogly_li_"), img_id = Bfr_arg__hatr_id.New(gplx.xowa.htmls.Xoh_img_mgr.Bry__html_uid)
|
||||
, div_1_id = Bfr_arg__hatr_id.New("xogly_div1_"), div_2_id = Bfr_arg__hatr_id.New("xogly_div2_"), div_3_id = Bfr_arg__hatr_id.New("xogly_div3_");
|
||||
private final Bfr_arg__hatr_id li_id = Bfr_arg__hatr_id.New_id("xogly_li_"), img_id = Bfr_arg__hatr_id.New_id(gplx.xowa.htmls.Xoh_img_mgr.Bry__html_uid)
|
||||
, div_1_id = Bfr_arg__hatr_id.New_id("xogly_div1_"), div_2_id = Bfr_arg__hatr_id.New_id("xogly_div2_"), div_3_id = Bfr_arg__hatr_id.New_id("xogly_div3_");
|
||||
private final Bfr_arg__itm_caption itm_caption_fmtr = new Bfr_arg__itm_caption();
|
||||
private int li_w, div_1_w, div_2_margin;
|
||||
public Xoh_gly_itm_wtr() {
|
||||
@@ -70,16 +70,16 @@ class Bfr_arg__itm_caption implements Bfr_arg {
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (Bfr_arg__missing()) return;
|
||||
switch (capt_tid) {
|
||||
case Xoh_gly_itm_data.Capt_tid__empty: return; // <div class='gallerytext'></div>
|
||||
case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; // <div class='gallerytext'><p>
|
||||
case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; // <div class='gallerytext'><br>
|
||||
case Xoh_gly_itm_data.Capt_tid__empty: return; // <div class='gallerytext'></div>
|
||||
case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; // <div class='gallerytext'><p>
|
||||
case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; // <div class='gallerytext'><br>
|
||||
}
|
||||
bfr.Add(capt_bry);
|
||||
int itm_caption_len = capt_bry.length;
|
||||
if (capt_tid == Xoh_gly_itm_data.Capt_tid__p) {
|
||||
if (itm_caption_len > 3 && Bry_.Match(capt_bry, itm_caption_len - 4, Gfh_tag_.Br_lhs)) bfr.Add_byte_nl();
|
||||
bfr.Add(Gfh_tag_.P_rhs);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Xoh_hdr_data implements Xoh_data_itm {
|
||||
Gfh_atr anch_atr = span_head.Atrs__get_by_or_fail(Gfh_atr_.Bry__id);
|
||||
this.anch_bgn = anch_atr.Val_bgn(); this.anch_end = anch_atr.Val_end();
|
||||
this.capt_bgn = span_head.Src_end();
|
||||
Gfh_tag hdr_tail = tag_rdr.Tag__move_fwd_tail(hdr_level); // find </h2> not </span_head> since <span_head> can be nested, but <h2> cannot
|
||||
Gfh_tag hdr_tail = tag_rdr.Tag__move_fwd_tail(hdr_level); // find </h2> not </span_head> since <span_head> can be nested, but <h2> cannot
|
||||
Gfh_tag span_tail = tag_rdr.Tag__peek_bwd_tail(Gfh_tag_.Id__span); // get </span_head> before </h2>
|
||||
this.capt_end = span_tail.Src_bgn();
|
||||
if (span_tail.Src_end() != hdr_tail.Src_bgn()) {
|
||||
|
||||
@@ -22,10 +22,8 @@ public class Xoh_hdr_make_tst {
|
||||
@Test public void Basic() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "z"
|
||||
, ""
|
||||
, "<h2><span class='mw-headline' id='A_1'>A 1</span></h2>"
|
||||
, "a 1"
|
||||
, ""
|
||||
, "<h2><span class='mw-headline' id='B'>B</span></h2>"
|
||||
, "b"
|
||||
);
|
||||
@@ -35,4 +33,17 @@ public class Xoh_hdr_make_tst {
|
||||
.Sections__add(2, 2, "B" , "B" , "b")
|
||||
);
|
||||
}
|
||||
@Test public void Consecutive() {
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "abc"
|
||||
, "<h2><span class='mw-headline' id='A'>A</span></h2>"
|
||||
, "<h2><span class='mw-headline' id='B'>B</span></h2>"
|
||||
, "xyz"
|
||||
);
|
||||
fxt.Test__make(html, fxt.Page_chkr().Body_(html) // make sure body is same
|
||||
.Sections__add(0, 2, "" , "" , "abc")
|
||||
.Sections__add(1, 2, "A" , "A" , "")
|
||||
.Sections__add(2, 2, "B" , "B" , "xyz")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ public class Xoh_hdr_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
|
||||
Xoh_section_mgr section_mgr = hpg.Section_mgr();
|
||||
int section_len = section_mgr.Len();
|
||||
if (section_len != 0) // guard against -1 index; should not happen
|
||||
section_mgr.Set_content(section_len - 1, bfr.Bfr(), bfr.Len() - 2); // close previous section; -2 to skip "\n\n"
|
||||
section_mgr.Set_content(section_len - 1, bfr.Bfr(), bfr.Len() - 1); // close previous section; -1 to skip "\n" before "<h2>"
|
||||
fmtr.Bld_bfr_many(bfr, hdr_num, hdr_id, hdr_content, hdr_capt_rhs);
|
||||
section_mgr.Add(section_len, hdr_num, hdr_id, hdr_content).Content_bgn_(bfr.Len() + 1); // +1 to skip "\n"
|
||||
section_mgr.Add(section_len, hdr_num, hdr_id, hdr_content).Content_bgn_(bfr.Len() + 1); // +1 to skip "\n" after "</h2>"
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hdr_wtr rv = new Xoh_hdr_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
|
||||
@@ -18,16 +18,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
public class Xoh_img_bare_data implements Xoh_data_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__img_bare;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public int Dir_tid() {return dir_tid;} private int dir_tid;
|
||||
public int Dir_bgn() {return dir_bgn;} private int dir_bgn;
|
||||
public int Dir_end() {return dir_end;} private int dir_end;
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__img_bare;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public int Img_tid() {return img_tid;} private int img_tid;
|
||||
public int Dir_bgn() {return dir_bgn;} private int dir_bgn;
|
||||
public int Dir_end() {return dir_end;} private int dir_end;
|
||||
public void Clear() {
|
||||
this.src_bgn = src_end = dir_tid = dir_bgn = dir_end = -1;
|
||||
this.src_bgn = src_end = img_tid = dir_bgn = dir_end = -1;
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag img_head, Gfh_tag unused) {
|
||||
this.src_bgn = img_head.Src_bgn(); this.src_end = img_head.Src_end();
|
||||
@@ -38,7 +38,7 @@ public class Xoh_img_bare_data implements Xoh_data_itm {
|
||||
if (Bry_.Match(src, root_dir_bgn, root_dir_end, root_dir_bry)) {
|
||||
int hiero_dir_end = root_dir_end + Url__hiero.length;
|
||||
if (Bry_.Match(src, root_dir_end, hiero_dir_end, Url__hiero)) {
|
||||
dir_tid = Dir_tid__hiero;
|
||||
img_tid = Img_tid__hiero;
|
||||
dir_bgn = root_dir_bgn;
|
||||
dir_end = hiero_dir_end;
|
||||
return true;
|
||||
@@ -46,11 +46,11 @@ public class Xoh_img_bare_data implements Xoh_data_itm {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void Init_by_decode(int src_bgn, int src_end, int dir_tid, int dir_bgn, int dir_end) {
|
||||
this.src_bgn = src_bgn; this.src_end = src_end; this.dir_tid = dir_tid; this.dir_bgn = dir_bgn; this.dir_end = dir_end;
|
||||
public void Init_by_decode__hiero(int src_bgn, int src_end, int dir_bgn, int dir_end) {
|
||||
this.img_tid = Img_tid__hiero; this.src_bgn = src_bgn; this.src_end = src_end; this.dir_bgn = dir_bgn; this.dir_end = dir_end;
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_bare_data rv = new Xoh_img_bare_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
public static final byte[] Url__hiero = Bry_.new_a7("bin/any/xowa/xtns/Wikihiero/img/hiero_");
|
||||
public static final int Dir_tid__null = -1, Dir_tid__hiero = 0;
|
||||
public static final int Img_tid__hiero = 0;
|
||||
}
|
||||
|
||||
@@ -16,37 +16,44 @@ 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.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
public class Xoh_img_bare_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__img_bare;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__img_bare;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_img_bare_data data = (Xoh_img_bare_data)data_obj;
|
||||
flag_bldr.Set(Flag__dir_tid , data.Dir_tid());
|
||||
int img_tid = flag_bldr.Set_as_int(Flag__img_tid , data.Img_tid());
|
||||
|
||||
bfr.Add(hook);
|
||||
Xoh_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
bfr.Add_hzip_mid(src, data.Src_bgn(), data.Dir_bgn());
|
||||
bfr.Add_hzip_mid(src, data.Dir_end(), data.Src_end());
|
||||
Gfo_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
switch (img_tid) {
|
||||
case Xoh_img_bare_data.Img_tid__hiero:
|
||||
bfr.Add_hzip_mid(src, data.Src_bgn(), data.Dir_bgn());
|
||||
bfr.Add_hzip_mid(src, data.Dir_end(), data.Src_end());
|
||||
break;
|
||||
}
|
||||
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) {
|
||||
Xoh_img_bare_data data = (Xoh_img_bare_data)data_itm; data.Clear();
|
||||
|
||||
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
|
||||
int dir_tid = flag_bldr.Get_as_int(Flag__dir_tid);
|
||||
int dir_tid = flag_bldr.Get_as_int(Flag__img_tid);
|
||||
|
||||
int tag_0_bgn = rdr.Pos(), tag_0_end = rdr.Find_fwd_lr();
|
||||
int tag_1_bgn = rdr.Pos(), tag_1_end = rdr.Find_fwd_lr();
|
||||
|
||||
data.Init_by_decode(tag_0_bgn, tag_1_end, dir_tid, tag_0_end, tag_1_bgn);
|
||||
switch (dir_tid) {
|
||||
case Xoh_img_bare_data.Img_tid__hiero:
|
||||
int tag_0_bgn = rdr.Pos(), tag_0_end = rdr.Find_fwd_lr();
|
||||
int tag_1_bgn = rdr.Pos(), tag_1_end = rdr.Find_fwd_lr();
|
||||
data.Init_by_decode__hiero(tag_0_bgn, tag_1_end, tag_0_end, tag_1_bgn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_bare_hzip rv = new Xoh_img_bare_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(2);
|
||||
private static final int // SERIALIZED
|
||||
Flag__dir_tid = 0
|
||||
Flag__img_tid = 0
|
||||
;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ 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.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.files.*;
|
||||
public class Xoh_img_bare_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
private byte[] src;
|
||||
private Xoh_img_bare_data data_itm;
|
||||
@@ -28,14 +29,19 @@ public class Xoh_img_bare_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
}
|
||||
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
|
||||
this.src = src; this.hctx = hctx;
|
||||
this.data_itm = (Xoh_img_bare_data)data_itm;
|
||||
this.data_itm = (Xoh_img_bare_data)data_itm;
|
||||
return true;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
bfr.Add_mid(src, data_itm.Src_bgn(), data_itm.Dir_bgn());
|
||||
bfr.Add(hctx.Fsys__root()).Add(Xoh_img_bare_data.Url__hiero);
|
||||
bfr.Add_mid(src, data_itm.Dir_end(), data_itm.Src_end());
|
||||
switch (data_itm.Img_tid()) {
|
||||
case Xoh_img_bare_data.Img_tid__hiero:
|
||||
bfr.Add_mid(src, data_itm.Src_bgn(), data_itm.Dir_bgn());
|
||||
bfr.Add(hctx.Fsys__root()).Add(Xoh_img_bare_data.Url__hiero);
|
||||
bfr.Add_mid(src, data_itm.Dir_end(), data_itm.Src_end());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_bare_wtr rv = new Xoh_img_bare_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; impor
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.anchs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.xtns.imaps.*;
|
||||
public class Xoh_img_data implements Xoh_data_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__img;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
@@ -40,28 +41,40 @@ public class Xoh_img_data implements Xoh_data_itm {
|
||||
public int Img_h() {return img_h;} private int img_h;
|
||||
public boolean Img_w__diff__file_w() {return img_w != img_src.File_w();}
|
||||
public boolean Img_is_vid() {return img_is_vid;} private boolean img_is_vid;
|
||||
public boolean Img_wo_anch() {return img_wo_anch;} private boolean img_wo_anch;
|
||||
public int Img_imap_idx() {return img_imap_idx;} private int img_imap_idx;
|
||||
public void Clear() {
|
||||
this.img_alt__diff_anch_title = anch_rel_is_nofollow = false;
|
||||
this.img_alt__diff_anch_title = anch_rel_is_nofollow = img_is_vid = img_wo_anch = false;
|
||||
this.src_bgn = src_end = anch_title_bgn = anch_title_end = img_w = img_h = img_alt_bgn = img_alt_end = -1;
|
||||
this.img_is_vid = false;
|
||||
this.img_imap_idx = -1;
|
||||
anch_href.Clear(); anch_cls.Clear();
|
||||
img_src.Clear(); img_cls.Clear(); img_xoimg.Clear();
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag anch_head, Gfh_tag unused) {
|
||||
if (anch_head.Name_id() == Gfh_tag_.Id__div) { // video / audio
|
||||
img_is_vid = true;
|
||||
tag_rdr.Tag__move_fwd_head(); // next <div>
|
||||
anch_head = tag_rdr.Tag__move_fwd_head(); // next <div>
|
||||
}
|
||||
Gfh_tag img_tag = anch_head;
|
||||
Bry_err_wkr err_wkr = tag_rdr.Err_wkr();
|
||||
this.src_bgn = anch_head.Src_bgn(); // <a
|
||||
if (!anch_href.Parse(err_wkr, hctx, src, anch_head)) return false; // href='/wiki/File:A.png'
|
||||
if (!anch_cls.Parse(err_wkr, src, anch_head)) return false; // class='image'
|
||||
Gfh_atr anch_title = anch_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__title); // title='abc'
|
||||
anch_title_bgn = anch_title.Val_bgn(); anch_title_end = anch_title.Val_end();
|
||||
Gfh_atr xowa_title = anch_head.Atrs__get_by_or_empty(Bry__atr__xowa_title); // xowa_title='A.png'
|
||||
if (xowa_title.Val_dat_exists()) anch_page.Val_(xowa_title.Val());
|
||||
Gfh_tag img_tag = tag_rdr.Tag__move_fwd_head().Chk_name_or_fail(Gfh_tag_.Id__img); // <img
|
||||
this.img_wo_anch = anch_head.Name_id() == Gfh_tag_.Id__img;
|
||||
if (img_wo_anch) {
|
||||
Gfh_atr xowa_title = anch_head.Atrs__get_by_or_empty(Xoh_img_xoimg_data.Bry__data_xowa_title); // data-xowa-title='A.png'
|
||||
anch_page.Val_(xowa_title.Val());
|
||||
}
|
||||
else {
|
||||
if (anch_head.Name_id() == Gfh_tag_.Id__div) { // video / audio
|
||||
if (!anch_head.Atrs__cls_eq(gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_data.Atr__id__xowa_media_div)) return false; // handle fake-thumbs created through en.w:Template:Image_label_begin; PAGE:en.w:Blackburnshire; DATE:2016-01-04
|
||||
img_is_vid = true;
|
||||
tag_rdr.Tag__move_fwd_head(); // next <div>
|
||||
anch_head = tag_rdr.Tag__move_fwd_head(); // next <div>
|
||||
}
|
||||
this.src_bgn = anch_head.Src_bgn(); // <a
|
||||
if (!anch_href.Parse(err_wkr, hctx, src, anch_head)) return false; // href='/wiki/File:A.png'
|
||||
if (!anch_cls.Parse(err_wkr, src, anch_head)) return false; // class='image'
|
||||
Gfh_atr anch_title = anch_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__title); // title='abc'
|
||||
anch_title_bgn = anch_title.Val_bgn(); anch_title_end = anch_title.Val_end();
|
||||
Gfh_atr xowa_title = anch_head.Atrs__get_by_or_empty(Bry__atr__xowa_title); // xowa_title='A.png'
|
||||
if (xowa_title.Val_dat_exists()) anch_page.Val_(xowa_title.Val());
|
||||
img_tag = tag_rdr.Tag__move_fwd_head();
|
||||
}
|
||||
img_tag.Chk_name_or_fail(Gfh_tag_.Id__img); // <img
|
||||
img_xoimg.Parse(err_wkr, src, img_tag); // data-xoimg='...'
|
||||
this.img_w = img_tag.Atrs__get_as_int_or(Gfh_atr_.Bry__width, Xof_img_size.Size__neg1); // width='220'
|
||||
this.img_h = img_tag.Atrs__get_as_int_or(Gfh_atr_.Bry__height, Xof_img_size.Size__neg1); // height='110'
|
||||
@@ -75,6 +88,11 @@ public class Xoh_img_data implements Xoh_data_itm {
|
||||
if (anch_page.Val_is_empty())
|
||||
anch_page.Val_(anch_href.Ttl_page_db());
|
||||
}
|
||||
this.img_imap_idx = Get_imap_idx(tag_rdr.Err_wkr(), img_tag);
|
||||
if (img_wo_anch) {
|
||||
src_end = img_tag.Src_end();
|
||||
return true;
|
||||
}
|
||||
Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // </a>
|
||||
this.src_end = anch_tail.Src_end();
|
||||
if (anch_href.Site_exists()) {
|
||||
@@ -88,15 +106,25 @@ public class Xoh_img_data implements Xoh_data_itm {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public void Init_by_decode(boolean anch_rel_is_nofollow, int anch_title_bgn, int anch_title_end, boolean img_is_vid, int img_w, int img_h, int img_alt_bgn, int img_alt_end) {
|
||||
public void Init_by_decode(boolean anch_rel_is_nofollow, int anch_title_bgn, int anch_title_end, boolean img_wo_anch, boolean img_is_vid, int img_w, int img_h, int img_alt_bgn, int img_alt_end, int img_imap_idx) {
|
||||
this.anch_rel_is_nofollow = anch_rel_is_nofollow;
|
||||
this.anch_title_bgn = anch_title_bgn; this.anch_title_end = anch_title_end;
|
||||
this.img_is_vid = img_is_vid;
|
||||
this.img_wo_anch = img_wo_anch; this.img_is_vid = img_is_vid;
|
||||
this.img_w = img_w; this.img_h = img_h;
|
||||
this.img_alt_bgn = img_alt_bgn; this.img_alt_end = img_alt_end;
|
||||
this.img_imap_idx = img_imap_idx;
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_data rv = new Xoh_img_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
private static int Get_imap_idx(Bry_err_wkr err_wkr, Gfh_tag img_tag) {
|
||||
byte[] val = img_tag.Atrs__get_as_bry(Imap_xtn_mgr.Bry__usemap__name); if (Bry_.Len_eq_0(val)) return -1;
|
||||
int rv = Bry_.To_int_or(val, Imap_xtn_mgr.Bry__usemap__prefix.length, val.length, -1);
|
||||
if (rv == -1) {
|
||||
err_wkr.Warn("invalid imap_idx", "val", val);
|
||||
return rv;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final byte[]
|
||||
Bry__cls__anch__image = Bry_.new_a7("image")
|
||||
, Bry__cls__img__thumbimage = Bry_.new_a7("thumbimage")
|
||||
|
||||
@@ -19,9 +19,13 @@ package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; impor
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_img_html__dump__tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
public static final String
|
||||
Html__basic = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'/></a>"
|
||||
;
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {fxt.Test__html("[[File:A.png|220x110px|upright=.5|abc]]" , Html__basic);}
|
||||
@Test public void Basic() {
|
||||
fxt.Test__html
|
||||
( "[[File:A.png|220x110px|upright=.5|abc]]"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'/></a>");
|
||||
}
|
||||
@Test public void Empty_link() {
|
||||
fxt.Test__html("[[File:A.png|220x110px|link=|abc]]", "<img data-xowa-title=\"A.png\" data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'/>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.core.encoders.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.lnkis.anchs.*;
|
||||
@@ -33,18 +33,21 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_img_data data = (Xoh_img_data)data_obj;
|
||||
Xoh_anch_href_data anch_href = data.Anch_href();
|
||||
boolean img_wo_anch = data.Img_wo_anch();
|
||||
Bry_obj_ref anch_page = data.Anch_page();
|
||||
byte anch_href_tid = anch_href.Tid();
|
||||
boolean anch__ns_is_custom = anch_href.Ttl_ns_custom() != null;
|
||||
boolean anch__ns_id_needs_saving = Xoh_anch_href_data.Ns_exists(anch_href.Tid()) && anch_href.Ttl_ns_id() != Xow_ns_.Tid__file;
|
||||
boolean anch_title_exists = data.Anch_title_exists();
|
||||
Xoh_img_xoimg_data img_xoimg = data.Img_xoimg();
|
||||
Xoh_img_xoimg_data img_xoimg = data.Img_xoimg();
|
||||
Xoh_img_cls_data img_cls = data.Img_cls();
|
||||
Xoh_img_src_data img_src = data.Img_src();
|
||||
boolean img__alt_diff_from_anch_title = data.Img_alt__diff__anch_title();
|
||||
boolean file__src_exists = !img_xoimg.Val_dat_exists();
|
||||
boolean anch_href_diff_file = !Bry_.Match(anch_page.Val(), anch_page.Val_bgn(), anch_page.Val_end(), anch_href.Ttl_page_db());
|
||||
boolean anch_href_diff_file = !img_wo_anch && !Bry_.Match(anch_page.Val(), anch_page.Val_bgn(), anch_page.Val_end(), anch_href.Ttl_page_db());
|
||||
|
||||
boolean img__imap_exists = flag_bldr.Set_as_bool(Flag__img__imap_exists , data.Img_imap_idx() != -1);
|
||||
flag_bldr.Set(Flag__img__wo_anch , img_wo_anch);
|
||||
flag_bldr.Set(Flag__img__is_vid , data.Img_is_vid());
|
||||
flag_bldr.Set(Flag__file__w_diff_from_html , file__src_exists && data.Img_w__diff__file_w());
|
||||
flag_bldr.Set(Flag__file__time_exists , file__src_exists && img_src.File_time_exists());
|
||||
@@ -64,20 +67,23 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
// Tfds.Dbg(flag_bldr.Encode(), Array_.To_str(flag_bldr.Val_ary()));
|
||||
|
||||
if (wkr_is_root) bfr.Add(hook);
|
||||
Xoh_hzip_int_.Encode(2, bfr, flag_bldr.Encode());
|
||||
switch (anch_href_tid) {
|
||||
case Xoh_anch_href_data.Tid__inet:
|
||||
bfr.Add_mid(src, anch_href.Rng_bgn(), anch_href.Rng_end());
|
||||
break;
|
||||
case Xoh_anch_href_data.Tid__site:
|
||||
bfr.Add_mid(src, anch_href.Site_bgn(), anch_href.Site_end()).Add_byte(Byte_ascii.Pipe).Add(anch_href.Ttl_page_db());
|
||||
break;
|
||||
case Xoh_anch_href_data.Tid__wiki:
|
||||
case Xoh_anch_href_data.Tid__anch:
|
||||
bfr.Add(anch_href.Ttl_page_db());
|
||||
break;
|
||||
Gfo_hzip_int_.Encode(2, bfr, flag_bldr.Encode());
|
||||
if (img_wo_anch) bfr.Add_hzip_mid(anch_page.Val(), anch_page.Val_bgn(), anch_page.Val_end());
|
||||
else {
|
||||
switch (anch_href_tid) {
|
||||
case Xoh_anch_href_data.Tid__inet:
|
||||
bfr.Add_mid(src, anch_href.Rng_bgn(), anch_href.Rng_end());
|
||||
break;
|
||||
case Xoh_anch_href_data.Tid__site:
|
||||
bfr.Add_mid(src, anch_href.Site_bgn(), anch_href.Site_end()).Add_byte(Byte_ascii.Pipe).Add(anch_href.Ttl_page_db());
|
||||
break;
|
||||
case Xoh_anch_href_data.Tid__wiki:
|
||||
case Xoh_anch_href_data.Tid__anch:
|
||||
bfr.Add(anch_href.Ttl_page_db());
|
||||
break;
|
||||
}
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
}
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (anch_href_diff_file) {
|
||||
data.Anch_page().Bfr_arg__add(bfr);
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
@@ -94,23 +100,26 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
}
|
||||
if (anch__ns_is_custom) bfr.Add(data.Anch_href().Ttl_ns_custom()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (file__src_exists) {
|
||||
Xoh_hzip_int_.Encode(2, bfr, Xoh_hzip_int_.Neg_1_adj + data.Img_w());
|
||||
Xoh_hzip_int_.Encode(2, bfr, Xoh_hzip_int_.Neg_1_adj + data.Img_h());
|
||||
if (data.Img_w__diff__file_w()) Xoh_hzip_int_.Encode(2, bfr, Xoh_hzip_int_.Neg_1_adj + img_src.File_w());
|
||||
if (img_src.File_time_exists()) Xoh_hzip_int_.Encode(1, bfr, Xoh_hzip_int_.Neg_1_adj + img_src.File_time());
|
||||
if (img_src.File_page_exists()) Xoh_hzip_int_.Encode(1, bfr, Xoh_hzip_int_.Neg_1_adj + img_src.File_page());
|
||||
Gfo_hzip_int_.Encode(2, bfr, Gfo_hzip_int_.Neg_1_adj + data.Img_w());
|
||||
Gfo_hzip_int_.Encode(2, bfr, Gfo_hzip_int_.Neg_1_adj + data.Img_h());
|
||||
if (data.Img_w__diff__file_w()) Gfo_hzip_int_.Encode(2, bfr, Gfo_hzip_int_.Neg_1_adj + img_src.File_w());
|
||||
if (img_src.File_time_exists()) Gfo_hzip_int_.Encode(1, bfr, Gfo_hzip_int_.Neg_1_adj + img_src.File_time());
|
||||
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);
|
||||
if (anch_title_exists) bfr.Add_mid(src, data.Anch_title_bgn(), data.Anch_title_end()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (img__alt_diff_from_anch_title) bfr.Add_mid(src, data.Img_alt_bgn(), data.Img_alt_end()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (img_cls.Other_exists()) bfr.Add_mid(src, img_cls.Other_bgn(), img_cls.Other_end()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
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());
|
||||
if (img__imap_exists) bfr.Add_hzip_int(1, data.Img_imap_idx());
|
||||
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) {
|
||||
Xoh_img_data data = (Xoh_img_data)data_itm; data.Clear();
|
||||
|
||||
int flag = rdr.Read_hzip_int(2); flag_bldr.Decode(flag);
|
||||
boolean img_imap_exists = flag_bldr.Get_as_bool(Flag__img__imap_exists);
|
||||
boolean img_wo_anch = flag_bldr.Get_as_bool(Flag__img__wo_anch);
|
||||
boolean file__is_orig = flag_bldr.Get_as_bool(Flag__file__is_orig);
|
||||
boolean file__repo_is_local = flag_bldr.Get_as_bool(Flag__file__repo_is_local);
|
||||
boolean file__src_exists = flag_bldr.Get_as_bool(Flag__file__src_exists);
|
||||
@@ -134,7 +143,7 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
case Xoh_anch_href_data.Tid__site:
|
||||
int pipe_pos = Bry_find_.Find_fwd(page_db, Byte_ascii.Pipe);
|
||||
site_bry = Bry_.Mid(page_db, 0, pipe_pos);
|
||||
page_db = Bry_.Mid(page_db, pipe_pos + 1);
|
||||
page_db = Bry_.Mid(page_db, pipe_pos + 1); // encode needed for foreign characters; PAGE:en.w:Pho; DATE:2016-01-04
|
||||
break;
|
||||
}
|
||||
byte[] file_db = page_db;
|
||||
@@ -142,16 +151,13 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
int anch_href_ns = -1;
|
||||
if (anch__ns_id_needs_saving)
|
||||
anch_href_ns = Xoh_lnki_dict_.Ns_decode(rdr);
|
||||
int ns_custom_bgn = -1, ns_custom_end = -1;
|
||||
if (anch__ns_is_custom) {
|
||||
ns_custom_bgn = rdr.Pos();
|
||||
ns_custom_end = rdr.Find_fwd_lr();
|
||||
}
|
||||
byte[] ns_custom_bry = null;
|
||||
if (anch__ns_is_custom) ns_custom_bry = rdr.Read_bry_to();
|
||||
int img_w = -1, img_h = -1, file_time = -1, file_page = -1;
|
||||
|
||||
if (file__src_exists) {
|
||||
img_w = rdr.Read_hzip_int(2) - Xoh_hzip_int_.Neg_1_adj;
|
||||
img_h = rdr.Read_hzip_int(2) - Xoh_hzip_int_.Neg_1_adj;
|
||||
img_w = rdr.Read_hzip_int(2) - Gfo_hzip_int_.Neg_1_adj;
|
||||
img_h = rdr.Read_hzip_int(2) - Gfo_hzip_int_.Neg_1_adj;
|
||||
}
|
||||
else
|
||||
xoimg.Decode(bfr, hctx, hpg, rdr, src, data.Img_xoimg());
|
||||
@@ -174,6 +180,7 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
img_cls_other_bgn = rdr.Pos();
|
||||
img_cls_other_end = rdr.Find_fwd_lr();
|
||||
}
|
||||
int img_imap_idx = img_imap_exists ? rdr.Read_hzip_int(1) : -1;
|
||||
|
||||
// transform values
|
||||
boolean anch_rel_is_nofollow = false;
|
||||
@@ -189,15 +196,32 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
byte[] page_ttl_bry = page_db;
|
||||
if ( anch__href_tid == Xoh_anch_href_data.Tid__wiki // if wiki, parse ttl
|
||||
|| anch_href_ns != Xow_ns_.Tid__main) { // or if site and !main_ns; handles /site/en.wiktionary.org/wiki/Special:Search but not /site/creativecommons.org/wiki/by/2.5; DATE:2015-12-28
|
||||
Xoa_ttl anch_href_ttl = hctx.Wiki__ttl_parser().Ttl_parse(anch_href_ns, page_db);
|
||||
page_ttl_bry = anch_href_ttl.Full_url();
|
||||
if (page_db.length == 0) { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
|
||||
Xow_ns anch_href_ns_itm = hctx.Wiki__ttl_parser().Ns_mgr().Ids_get_or_null(anch_href_ns);
|
||||
page_ttl_bry = anch_href_ns_itm.Name_db_w_colon(); // ASSUME:anch_href_ns is db_name not ui_name; EX: "Category_talk" vs "Category talk"
|
||||
}
|
||||
else {
|
||||
if (anch__ns_is_custom)
|
||||
page_ttl_bry = Bry_.Add(ns_custom_bry, Byte_ascii.Colon_bry, page_db); // handle ns aliases; EX:WP; PAGE:en.w:Wikipedia:WikiProject_Molecular_and_Cell_Biology; DATE:2016-01-11
|
||||
else {
|
||||
if (anch__href_tid == Xoh_anch_href_data.Tid__site) { // if site, do not title-case page; EX:[[File:A.png|link=wikt:Category:en:A]]; PAGE:en.w:Portal:Trucks/Wikimedia; DATE:2016-01-11
|
||||
Xow_ns anch_href_ns_itm = hctx.Wiki__ttl_parser().Ns_mgr().Ids_get_or_null(anch_href_ns);
|
||||
page_ttl_bry = Bry_.Add(anch_href_ns_itm.Name_db_w_colon(), page_db);
|
||||
}
|
||||
else {
|
||||
Xoa_ttl anch_href_ttl = hctx.Wiki__ttl_parser().Ttl_parse(anch_href_ns, page_db);
|
||||
page_ttl_bry = anch_href_ttl.Full_db_w_anch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(page_ttl_bry);
|
||||
}
|
||||
else {
|
||||
byte[] ns_bry = anch__ns_is_custom ? Bry_.Mid(src, ns_custom_bgn, ns_custom_end) : Xow_ns_.Bry__file;
|
||||
byte[] ns_bry = anch__ns_is_custom ? ns_custom_bry : Xow_ns_.Bry__file;
|
||||
tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(ns_bry).Add_byte_colon();
|
||||
Gfo_url_encoder_.Href.Encode(tmp_bfr, page_db);
|
||||
tmp_bfr.Add(page_db);
|
||||
// Gfo_url_encoder_.Href.Encode(tmp_bfr, page_db); // encode needed for ?; PAGE:en.w:Voiceless_alveolar_affricate; DATE:2016-01-04
|
||||
}
|
||||
}
|
||||
this.anch_href_bry = tmp_bfr.To_bry_and_clear();
|
||||
@@ -207,7 +231,7 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
url_bldr.Init_by_root(file__repo_is_local ? hctx.Fsys__file__wiki() : hctx.Fsys__file__comm(), Byte_ascii.Slash, false, false, Md5_depth);
|
||||
url_bldr.Init_by_itm(file__is_orig ? Xof_repo_itm_.Mode_orig : Xof_repo_itm_.Mode_thumb, file_db, Xof_file_wkr_.Md5(file_db), Xof_ext_.new_by_ttl_(file_db), img_w, file_time, file_page);
|
||||
|
||||
data.Init_by_decode(anch_rel_is_nofollow, anch_title_bgn, anch_title_end, img_is_vid, img_w, img_h, img_alt_bgn, img_alt_end);
|
||||
data.Init_by_decode(anch_rel_is_nofollow, anch_title_bgn, anch_title_end, img_wo_anch, img_is_vid, img_w, img_h, img_alt_bgn, img_alt_end, img_imap_idx);
|
||||
data.Anch_href().Init_by_decode(anch_href_bry);
|
||||
data.Anch_cls().Init_by_decode(anch__cls_tid);
|
||||
data.Img_cls().Init_by_decode(src, img_cls, img_cls_other_bgn, img_cls_other_end);
|
||||
@@ -216,23 +240,25 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_hzip rv = new Xoh_img_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
public static int Md5_depth = 2;
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_( 1, 1, 1, 1 , 1 , 1, 1, 1 , 1 , 2, 1, 1 , 1, 1, 2, 2);
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1, 1, 1, 1, 1 , 1 , 1, 1, 1 , 1 , 2, 1, 1 , 1, 1, 2, 2);
|
||||
private static final int // SERIALIZED
|
||||
Flag__img__is_vid = 0
|
||||
, Flag__file__w_diff_from_html = 1
|
||||
, Flag__file__time_exists = 2
|
||||
, Flag__file__page_exists = 3
|
||||
, Flag__file__is_orig = 4
|
||||
, Flag__file__repo_is_local = 5
|
||||
, Flag__file__src_exists = 6
|
||||
, Flag__img__cls_other_exists = 7
|
||||
, Flag__anch__ns_is_custom = 8
|
||||
, Flag__anch__cls_tid = 9 // none, image
|
||||
, Flag__anch__ns_id_needs_saving = 10
|
||||
, Flag__img__alt_diff_from_anch_title = 11
|
||||
, Flag__anch__href_diff_file = 12
|
||||
, Flag__anch__title_missing = 13
|
||||
, Flag__img__cls_tid = 14 // none, thumbimage, thumbborder
|
||||
, Flag__anch__href_tid = 15 // wiki, site, anch, inet
|
||||
Flag__img__imap_exists = 0
|
||||
, Flag__img__wo_anch = 1
|
||||
, Flag__img__is_vid = 2
|
||||
, Flag__file__w_diff_from_html = 3
|
||||
, Flag__file__time_exists = 4
|
||||
, Flag__file__page_exists = 5
|
||||
, Flag__file__is_orig = 6
|
||||
, Flag__file__repo_is_local = 7
|
||||
, Flag__file__src_exists = 8
|
||||
, Flag__img__cls_other_exists = 9
|
||||
, Flag__anch__ns_is_custom = 10
|
||||
, Flag__anch__cls_tid = 11 // none, image
|
||||
, Flag__anch__ns_id_needs_saving = 12
|
||||
, Flag__img__alt_diff_from_anch_title = 13
|
||||
, Flag__anch__href_diff_file = 14
|
||||
, Flag__anch__title_missing = 15
|
||||
, Flag__img__cls_tid = 16 // none, thumbimage, thumbborder
|
||||
, Flag__anch__href_tid = 17 // wiki, site, anch, inet
|
||||
;
|
||||
}
|
||||
|
||||
@@ -23,92 +23,148 @@ public class Xoh_img_hzip__dump__tst {
|
||||
@Test public void Basic() { // [[File:A.png|border|class=other|220px|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!!A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Anch() { // [[File:A.png#b|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%\"<A.png#file~A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A.png#file' class='image' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
, "<a href='/wiki/File:A.png#file' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__cs() { // [[File:A.png|link=File:a.ogg|abc]]
|
||||
@Test public void Href__encoding_foreign() { // [[File:Aéb.png|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Aa.ogg~A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:a.ogg' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
( "~%\"<A%C3%A9b.png~Aéb.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A%C3%A9b.png' class='image' xowa_title='Aéb.png'><img data-xowa-title='Aéb.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding() { // [[File:Aéb.png|abc]]
|
||||
@Test public void Href__encoding_question() { // [[File:A?.png|abc]]; PAGE:en.w:Voiceless_alveolar_affricate; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%!qAéb.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A%C3%A9b.png' class='image' xowa_title='Aéb.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
( "~%!qA?.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:A?.png' class='image' xowa_title='A?.png'><img data-xowa-title='A?.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding__link() { // [[File:Aéb.png|abc|link=Aéb]]
|
||||
fxt.Test__bicode
|
||||
( "~%#gAéb~Aéb.png~#)#Sabc~"
|
||||
, "<a href='/wiki/A%C3%A9b' class='image' xowa_title='Aéb.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
( "~%#gA%C3%A9b~Aéb.png~#)#Sabc~"
|
||||
, "<a href='/wiki/A%C3%A9b' class='image' xowa_title='Aéb.png'><img data-xowa-title='Aéb.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__encoding_percent() {
|
||||
fxt.Test__bicode
|
||||
( "~%!q%24%3F%3D%27.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:%24%3F%3D%27.png' class='image' xowa_title='%24%3F%3D%27.png'><img data-xowa-title='%24%3F%3D%27.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Href__apos() { // [[File:A'b.png|border|link=A'b_link|A'b_capt]]
|
||||
String html = "<a href=\"/wiki/A%27b_link\" class=\"image\" xowa_title=\"A'b.png\"><img data-xoimg=\"0|220|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" class=\"thumbborder\" alt=\"A'b_capt\"></a>";
|
||||
fxt.Test__bicode_raw("~%#oA'b_link~A'b.png~#)#SA'b_capt~", html, html);
|
||||
String html = "<a href=\"/wiki/A%27b_link\" class=\"image\" xowa_title=\"A'b.png\"><img data-xowa-title=\"A'b.png\" data-xoimg=\"0|220|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" class=\"thumbborder\" alt=\"A'b_capt\"></a>";
|
||||
fxt.Test__bicode_raw("~%#oA%27b_link~A'b.png~#)#SA'b_capt~", html, html);
|
||||
}
|
||||
@Test public void Link__cs() { // [[File:A.png|link=File:a.ogg|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Aa.ogg~A.png~)#Sabc~"
|
||||
, "<a href='/wiki/File:a.ogg' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__anchor() { // [[File:A.png|link=A#B_C|abc]]; PAGE:en.w:Arabic; DATE:2016-01-06
|
||||
fxt.Test__bicode
|
||||
( "~%#'A#B_C~D.png~#9!I!I"
|
||||
, "<a href='/wiki/A#B_C' class='image' xowa_title='D.png'><img data-xowa-title='D.png' data-xoimg='0|40|40|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n() { // [[File:A.png|link=http://a.org|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%!Dhttp://a.org~A.png~)#Sabc~"
|
||||
, "<a href='http://a.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
, "<a href='http://a.org' rel='nofollow' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__y() { // [[File:A.png|link=http://en.wikitionary.org/wiki/Special:Search/A|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%\"men.wiktionary.org|Search/A~A.png~\")#Sabc~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Special:Search/A' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Special:Search/A' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__wm__n_2() { // [[File:A.png|link=creativecommons:by/2.5]]
|
||||
fxt.Test__bicode
|
||||
( "~%#(creativecommons.org|by/2.5/~CC-BY-icon-80x15.png~#)!q"
|
||||
, "<a href='/site/creativecommons.org/wiki/by/2.5/' class='image' xowa_title='CC-BY-icon-80x15.png'><img data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
, "<a href='/site/creativecommons.org/wiki/by/2.5/' class='image' xowa_title='CC-BY-icon-80x15.png'><img data-xowa-title='CC-BY-icon-80x15.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__media() { // [[File:A.png|link=file:///C:/A.ogg]]
|
||||
fxt.Test__bicode
|
||||
( "~%!D~A.ogg~)!,B~"
|
||||
, "<a href='' class='image' title='B' xowa_title='A.ogg'><img data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
, "<a href='' class='image' title='B' xowa_title='A.ogg'><img data-xowa-title='A.ogg' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__encoding() { // [[File:A.svg|24px|text-top|link=wikt:𬖾|𬖾]]; PAGE:en.w:Pho; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%#Xen.wiktionary.org|%F0%AC%96%BE~A.png~#)!,abc~B~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/%F0%AC%96%BE' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__invalid() { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
|
||||
fxt.Test__bicode
|
||||
( "~%\"mcommons.wikimedia.org|~A.png~1!Abc~"
|
||||
, "<a href='/site/commons.wikimedia.org/wiki/Category:' class='image' title='Abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='Abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fxt.Test__bicode
|
||||
( "~%|iVPA.png~#9#S\":abc~"
|
||||
, "<img data-xowa-title='A.png' data-xoimg='0|220|110|-1|-1|-1' src='' width='0' height='0' alt='abc'>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__empty__tidy() {// <a><font><img> should not trigger empty link code; PAGE:en.w:Wikipedia:Reference_Desk_archive_unanswered_2005 ; DATE:2016-01-13
|
||||
fxt.Test__bicode
|
||||
( "<a href=\"/wiki/Image:A.png\" class=\"image\" title=\"\" xowa_title=\"A.png\"><font style=\"color:red\">~%|iVPA.png~#!abc~</font></a>"
|
||||
, "<a href='/wiki/Image:A.png' class='image' title='' xowa_title='A.png'><font style='color:red'><img data-xowa-title='A.png' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></font></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link__ns_alias() { // [[File:A.png|link=WP:MCB]]; PAGE:en.w:Wikipedia:WikiProject_Molecular_and_Cell_Biology; DATE:2016-01-11
|
||||
fxt.Init__ns_alias__add("WP", gplx.xowa.wikis.nss.Xow_ns_.Tid__project);
|
||||
fxt.Test__bicode
|
||||
( "~%/+MCB~A.png~'WP~)!q"
|
||||
, "<a href='/wiki/WP:MCB' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
fxt.Init__ns_alias__del("WP");
|
||||
}
|
||||
@Test public void Link__xwiki_lc() { // [[File:A.png|link=wikt:Category:en:A]]; PAGE:en.w:Portal:Trucks/Wikimedia; DATE:2016-01-11
|
||||
fxt.Test__bicode
|
||||
( "~%#(en.wiktionary.org|en:A~A.png~1)!q"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Category:en:A' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|80|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
|
||||
);
|
||||
}
|
||||
// @Test public void Link__encoding() { // [[File:A.svg|24px|text-top|link=wikt:𬖾|𬖾]]; PAGE:en.w:Pho
|
||||
// fxt.Test__bicode
|
||||
// ( "~%#Xen.wiktionary.org|𬖾~A.png~#)!,abc~B~"
|
||||
// , "<a href='/site/en.wiktionary.org/wiki/%F0%AC%96%BE' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|11|-1|-1|-1|-1' src='' width='0' height='0' alt='B'></a>"
|
||||
// );
|
||||
// }
|
||||
@Test public void Href__image() { // [[Image:A.png|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%-%A.png~Image~)#Sabc~"
|
||||
, "<a href='/wiki/Image:A.png' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
, "<a href='/wiki/Image:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Missing() { // PURPOSE: bad dump shouldn't write corrupt data
|
||||
fxt.Test__bicode
|
||||
( "%|\"\\QA.png!!!!A"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='A' xowa_title='A.png'><img alt='A'></a>"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='A' xowa_title='A.png'><img data-xowa-title='A.png' alt='A'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Manual_img_cls() { // PURPOSE: handle manual class; EX: [[File:A.png|class=noviewer]] en.w:ASCII; DATE:2015-12-21
|
||||
fxt.Test__bicode
|
||||
( "~%95A.png~)#Sabc~cls1~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='cls1' alt='abc'></a>"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='cls1' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Video() { // [[File:A.ogv]]
|
||||
fxt.Test__bicode
|
||||
( "%|E9eA.ogv~!A.ogv~~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_anchor_button' style='width:218px;max-width:220px;'><img src='' width='22' height='22' alt='Play sound'></a></div>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Imap() {
|
||||
fxt.Test__bicode
|
||||
( "~%}#Pa$A.png~#:#S#+\""
|
||||
, "<img data-xowa-title='A.png' data-xoimg='1|220|180|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='' usemap='#imagemap_1_1'>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ public class Xoh_img_hzip__view__tst {
|
||||
@Test public void Basic__border__class__caption() { // [[File:A.png|border|class=other|220px|abc]]
|
||||
fxt.Test__bicode
|
||||
( "~%iAA.png#T\";abc~other~"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img id='xoimg_0' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' class='thumbborder other' alt='abc'></a>"
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img id='xoimg_0' data-xowa-title='A.png' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' class='thumbborder other' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Link() { // [[File:A.png|link=B]]
|
||||
fxt.Test__bicode
|
||||
( "~%SgB~A.png~##T\";B~A.png~"
|
||||
, "<a href='/wiki/B' class='image' title='B' xowa_title='A.png'><img id='xoimg_0' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' alt='A.png'></a>"
|
||||
, "<a href='/wiki/B' class='image' title='B' xowa_title='A.png'><img id='xoimg_0' data-xowa-title='A.png' src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' alt='A.png'></a>"
|
||||
);
|
||||
}
|
||||
// link_site: [[File:A.png|link=//en.wiktionary.org/B]] -> [[File:Wiktionary-logo-en.svg|25x25px|link=//en.wiktionary.org/wiki/Special:Search/Earth|Search Wiktionary]] -> <a href="/site/en.wiktionary.org/wiki/Special:Search/Earth" rel="nofollow" title="Search Wiktionary" xowa_title="Wiktionary-logo-en.svg"><img id="xoimg_88" alt="Search Wiktionary" src="file:///J:/xowa/file/commons.wikimedia.org/thumb/f/8/c/4/Wiktionary-logo-en.svg/23px.png" width="23" height="25"></a>
|
||||
|
||||
@@ -22,8 +22,8 @@ public class Xoh_img_make__dump__tst {
|
||||
@Before public void Init() {fxt.Clear();}
|
||||
@Test public void Html_exists__n() {
|
||||
String
|
||||
orig = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' alt='abc'></a>"
|
||||
, expd = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img id='xoimg_0' data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
orig = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' alt='abc'></a>"
|
||||
, expd = "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img id='xoimg_0' data-xowa-title='A.png' data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
;
|
||||
fxt.Test__make(orig, fxt.Page_chkr().Body_(expd)
|
||||
.Imgs__add("en.w", "A.png", Xop_lnki_type.Id_null, 0.5, 220, 110, -1, -1)
|
||||
@@ -31,8 +31,8 @@ public class Xoh_img_make__dump__tst {
|
||||
}
|
||||
@Test public void Utf8() {
|
||||
String
|
||||
orig = "<a href='/wiki/File:A%C3%A9_b.png' class='image' title='abc' xowa_title='Aé_b.png'><img data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A%C3%A9_b.png/220px.png' width='220' height='110' alt='abc'></a>"
|
||||
, expd = "<a href='/wiki/File:A%C3%A9_b.png' class='image' title='abc' xowa_title='A%C3%A9_b.png'><img id='xoimg_0' data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
orig = "<a href='/wiki/File:A%C3%A9_b.png' class='image' title='abc' xowa_title='Aé_b.png'><img data-xowa-title='Aé_b.png' data-xoimg='0|220|110|0.5|-1|-1' src='file:///mem/xowa/file/en.wikipedia.org/thumb/7/0/A%C3%A9_b.png/220px.png' width='220' height='110' alt='abc'></a>"
|
||||
, expd = "<a href='/wiki/File:A%C3%A9_b.png' class='image' title='abc' xowa_title='A%C3%A9_b.png'><img id='xoimg_0' data-xowa-title='A%C3%A9_b.png' data-xoimg='0|220|110|0.5|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
;
|
||||
fxt.Test__make(orig, fxt.Page_chkr().Body_(expd)
|
||||
.Imgs__add("en.w", "A.png", Xop_lnki_type.Id_null, 0.5, 220, 110, -1, -1)
|
||||
|
||||
@@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; impor
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.args.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.xtns.imaps.*;
|
||||
public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
private final Bfr_arg_clearable[] arg_ary;
|
||||
private final Bfr_arg__hatr_arg img_xoimg = new Bfr_arg__hatr_arg(Xoh_img_xoimg_data.Bry__name);
|
||||
private final Bfr_arg__hatr_id img_id = Bfr_arg__hatr_id.New(Xoh_img_mgr.Bry__html_uid), vid_play_id = Bfr_arg__hatr_id.New("xowa_file_play_");
|
||||
private final Bfr_arg__hatr_arg img_xowa_image = new Bfr_arg__hatr_arg(Xoh_img_xoimg_data.Bry__data_xowa_image);
|
||||
private final Bfr_arg__hatr_id img_id = Bfr_arg__hatr_id.New_id(Xoh_img_mgr.Bry__html_uid), vid_play_id = Bfr_arg__hatr_id.New_id("xowa_file_play_"), img_imap_usemap = new Bfr_arg__hatr_id(Imap_xtn_mgr.Bry__usemap__name, Imap_xtn_mgr.Bry__usemap__prefix);
|
||||
private final Bfr_arg__hatr_int img_w = new Bfr_arg__hatr_int(Gfh_atr_.Bry__width), img_h = new Bfr_arg__hatr_int(Gfh_atr_.Bry__height);
|
||||
private final Bfr_arg__hatr_bry
|
||||
anch_href = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__href)
|
||||
@@ -33,13 +33,14 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
, anch_title = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__title)
|
||||
, img_alt = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__alt)
|
||||
, img_src = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__src)
|
||||
, img_cls = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__class);
|
||||
private boolean img_is_vid;
|
||||
, img_cls = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__class)
|
||||
, img_xowa_title = new Bfr_arg__hatr_bry(Xoh_img_xoimg_data.Bry__data_xowa_title);
|
||||
private boolean img_is_vid; private boolean img_wo_anch;
|
||||
private byte[] xowa_root_dir;
|
||||
public Xoh_img_wtr() {
|
||||
arg_ary = new Bfr_arg_clearable[]
|
||||
{ anch_href, anch_rel, anch_cls, anch_title, anch_xowa_title
|
||||
, img_id, img_xoimg, img_src, img_w, img_h, img_cls, img_alt
|
||||
, img_id, img_xowa_title, img_xowa_image, img_src, img_w, img_h, img_cls, img_alt
|
||||
};
|
||||
}
|
||||
public Xof_fsdb_itm Fsdb_itm() {return fsdb_itm;} private Xof_fsdb_itm fsdb_itm;
|
||||
@@ -49,7 +50,8 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
for (Bfr_arg_clearable arg : arg_ary)
|
||||
arg.Bfr_arg__clear();
|
||||
vid_play_id.Bfr_arg__clear();
|
||||
img_is_vid = false;
|
||||
img_imap_usemap.Bfr_arg__clear();
|
||||
img_is_vid = false; img_wo_anch = false;
|
||||
return this;
|
||||
}
|
||||
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_img_data data) {
|
||||
@@ -60,24 +62,24 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
Xoh_img_data data = (Xoh_img_data)data_itm;
|
||||
this.Clear();
|
||||
this.img_is_vid = data.Img_is_vid();
|
||||
this.img_wo_anch = data.Img_wo_anch();
|
||||
this.fsdb_itm = hpg.Img_mgr().Make_img();
|
||||
byte[] file_ttl_bry = data.Img_src().File_ttl_bry();
|
||||
byte[] lnki_ttl = Xoa_ttl.Replace_spaces(Gfo_url_encoder_.Href_quotes.Decode(file_ttl_bry)); // NOTE: must decode for fsdb.lnki_ttl as well as xowa_title; EX: A%C3%A9b -> A<>b
|
||||
if (data.Img_xoimg().Val_dat_exists()) {
|
||||
Xoh_img_xoimg_data img_xoimg = data.Img_xoimg();
|
||||
fsdb_itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, hpg.Wiki().Domain_itm().Abrv_xo(), lnki_ttl, gplx.xowa.parsers.lnkis.Xop_lnki_type.To_flag(img_xoimg.Lnki_type()), img_xoimg.Lnki_upright(), img_xoimg.Lnki_w(), img_xoimg.Lnki_h(), img_xoimg.Lnki_time(), img_xoimg.Lnki_page(), Xof_patch_upright_tid_.Tid_all);
|
||||
hctx.File__mgr().Check_cache(fsdb_itm);
|
||||
this.img_xoimg.Set_by_arg(img_xoimg);
|
||||
img_w.Set_by_int(0);
|
||||
img_h.Set_by_int(0);
|
||||
this.img_src.Set_by_bry(Bry_.Empty);
|
||||
Xoh_img_xoimg_data img_xowa_image = data.Img_xoimg();
|
||||
fsdb_itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, hpg.Wiki().Domain_itm().Abrv_xo(), lnki_ttl, gplx.xowa.parsers.lnkis.Xop_lnki_type.To_flag(img_xowa_image.Lnki_type()), img_xowa_image.Lnki_upright(), img_xowa_image.Lnki_w(), img_xowa_image.Lnki_h(), img_xowa_image.Lnki_time(), img_xowa_image.Lnki_page(), Xof_patch_upright_tid_.Tid_all);
|
||||
hctx.File__mgr().Find(hpg.Wiki(), hpg.Url_bry_safe(), fsdb_itm);
|
||||
this.img_xowa_image.Set_by_arg(img_xowa_image.Clone()); // NOTE: must clone b/c img_xowa_image is member of Xoh_img_data which is poolable (and cleared); PAGE:en.w:Almagest; DATE:2016-01-05
|
||||
img_w.Set_by_int(fsdb_itm.Html_w());
|
||||
img_h.Set_by_int(fsdb_itm.Html_h());
|
||||
this.img_src.Set_by_bry(fsdb_itm.Html_view_url().To_http_file_bry());
|
||||
}
|
||||
else if (data.Img_w() != -1) {
|
||||
img_w.Set_by_int(data.Img_w());
|
||||
img_h.Set_by_int(data.Img_h());
|
||||
this.img_src.Set_by_arg(data.Img_src());
|
||||
}
|
||||
|
||||
}
|
||||
if (data.Anch_rel_nofollow_exists()) anch_rel.Set_by_bry(gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_dict_.Html__rel__nofollow);
|
||||
if (!hctx.Mode_is_diff()) {
|
||||
this.Img_id_(fsdb_itm.Html_uid());
|
||||
@@ -86,32 +88,43 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
anch_href.Set_by_mid(data.Anch_href().Rng_src(), data.Anch_href().Rng_bgn(), data.Anch_href().Rng_end());
|
||||
anch_cls.Set_by_arg(data.Anch_cls());
|
||||
anch_title.Set_by_mid_or_null(src, data.Anch_title_bgn(), data.Anch_title_end());
|
||||
anch_xowa_title.Set_by_bry(file_ttl_bry);
|
||||
if ( data.Img_wo_anch() // anchor-less image
|
||||
|| Bry_.Len_gt_0(file_ttl_bry)) // regular anch with image
|
||||
anch_xowa_title.Set_by_bry(file_ttl_bry);
|
||||
img_xowa_title.Set_by_bry(file_ttl_bry);
|
||||
xowa_root_dir = hctx.Fsys__root();
|
||||
img_alt.Set_by_mid_or_empty(src, data.Img_alt_bgn(), data.Img_alt_end());
|
||||
img_cls.Set_by_arg(data.Img_cls());
|
||||
img_cls.Set_by_arg(data.Img_cls());
|
||||
if (data.Img_imap_idx() != -1) img_imap_usemap.Set(data.Img_imap_idx());
|
||||
return true;
|
||||
}
|
||||
public void Init_by_gly(Bfr_arg_clearable href, byte[] xowa_title, Bfr_arg_clearable xoimg) {
|
||||
anch_href.Set_by_arg(href);
|
||||
anch_xowa_title.Set_by_bry(xowa_title);
|
||||
img_xoimg.Set_by_arg(xoimg);
|
||||
img_xowa_image.Set_by_arg(xoimg);
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (img_is_vid) bfr.Add(Vid__bry__bgn);
|
||||
img_fmtr.Bld_bfr_many(bfr, (Object[])arg_ary);
|
||||
if (img_is_vid)
|
||||
vid_fmtr.Bld_bfr_many(bfr, vid_play_id, anch_xowa_title, xowa_root_dir, 218, 220); // TODO: hardcode widths; need to update via js from fsdb
|
||||
if (img_wo_anch)
|
||||
img_wo_anch_fmtr.Bld_bfr_many(bfr, img_id, img_xowa_title, img_xowa_image, img_src, img_w, img_h, img_cls, img_alt, img_imap_usemap);
|
||||
else {
|
||||
if (img_is_vid) bfr.Add(Vid__bry__bgn);
|
||||
img_fmtr.Bld_bfr_many(bfr, (Object[])arg_ary);
|
||||
if (img_is_vid)
|
||||
vid_fmtr.Bld_bfr_many(bfr, vid_play_id, anch_xowa_title, xowa_root_dir, 218, 220); // TODO: hardcode widths; need to update via js from fsdb
|
||||
}
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_wtr rv = new Xoh_img_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
private static final byte[] Vid__bry__bgn = Bry_.new_a7("<div class=\"xowa_media_div\">\n<div>");
|
||||
private static final Bry_fmtr
|
||||
img_fmtr = Bry_fmtr.new_
|
||||
( "<a~{anch_href}~{anch_rel}~{anch_cls}~{anch_title}~{anch_xowa_title}><img~{img_id}~{img_xoimg}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_alt}></a>"
|
||||
, "anch_href", "anch_rel", "anch_cls", "anch_title", "anch_xowa_title", "img_id", "img_xoimg", "img_src", "img_w", "img_h", "img_cls", "img_alt")
|
||||
( "<a~{anch_href}~{anch_rel}~{anch_cls}~{anch_title}~{anch_xowa_title}><img~{img_id}~{img_xowa_title}~{img_xowa_image}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_alt}></a>"
|
||||
, "anch_href", "anch_rel", "anch_cls", "anch_title", "anch_xowa_title", "img_id", "img_xowa_title", "img_xowa_image", "img_src", "img_w", "img_h", "img_cls", "img_alt")
|
||||
, img_wo_anch_fmtr = Bry_fmtr.new_
|
||||
( "<img~{img_id}~{img_xowa_title}~{img_xowa_image}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_alt}~{img_imap_usemap}>"
|
||||
, "img_id", "img_xowa_title", "img_xowa_image", "img_src", "img_w", "img_h", "img_cls", "img_alt", "img_imap_usemap")
|
||||
, vid_fmtr = Bry_fmtr.new_
|
||||
( "</div>\n<div><a~{vid_play_id} href=\"\"~{xowa_title} class=\"xowa_anchor_button\" style=\"width:218px;max-width:220px;\"><img src=\"\" width=\"22\" height=\"22\" alt=\"Play sound\"></a></div>\n</div>"
|
||||
( "</div>\n<div><a~{vid_play_id} href=\"\"~{xowa_title} class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>\n</div>"
|
||||
, "vid_play_id", "xowa_title", "xowa_root_dir", "width_neg_2", "width") // NOTE: default to href='file:///'; will be filled in dynamically
|
||||
;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ public class Xoh_img_xoimg_data implements Bfr_arg_clearable {
|
||||
public void Clear() {
|
||||
val_bgn = val_end = -1;
|
||||
val_dat_exists = false;
|
||||
lnki_type = Byte_.Zero;
|
||||
lnki_w = lnki_h = lnki_page = 0;
|
||||
lnki_upright = lnki_time = 0;
|
||||
}
|
||||
public void Set(byte tid, int w, int h, double upright, double time, int page) {
|
||||
this.lnki_type = tid;
|
||||
@@ -42,8 +45,21 @@ public class Xoh_img_xoimg_data implements Bfr_arg_clearable {
|
||||
this.lnki_page = page;
|
||||
this.val_dat_exists = true;
|
||||
}
|
||||
public Xoh_img_xoimg_data Clone() {
|
||||
Xoh_img_xoimg_data rv = new Xoh_img_xoimg_data();
|
||||
rv.val_bgn = this.val_bgn;
|
||||
rv.val_end = this.val_end;
|
||||
rv.val_dat_exists = this.val_dat_exists;
|
||||
rv.lnki_type = this.lnki_type;
|
||||
rv.lnki_w = this.lnki_w;
|
||||
rv.lnki_h = this.lnki_h;
|
||||
rv.lnki_upright = this.lnki_upright;
|
||||
rv.lnki_time = this.lnki_time;
|
||||
rv.lnki_page = this.lnki_page;
|
||||
return rv;
|
||||
}
|
||||
public void Parse(Bry_err_wkr err_wkr, byte[] src, Gfh_tag tag) {
|
||||
Gfh_atr atr = tag.Atrs__get_by_or_empty(Bry__name);
|
||||
Gfh_atr atr = tag.Atrs__get_by_or_empty(Bry__data_xowa_image);
|
||||
Parse(err_wkr, src, atr.Val_bgn(), atr.Val_end());
|
||||
}
|
||||
public void Parse(Bry_err_wkr err_wkr, byte[] src, int src_bgn, int src_end) {
|
||||
@@ -73,7 +89,7 @@ public class Xoh_img_xoimg_data implements Bfr_arg_clearable {
|
||||
bfr.Add_int_variable(lnki_page);
|
||||
}
|
||||
public static final byte[]
|
||||
Bry__name = Bry_.new_a7("data-xoimg")
|
||||
, Bry__html = Bry_.new_a7("\" data-xoimg=\"")
|
||||
Bry__data_xowa_image = Bry_.new_a7("data-xoimg")
|
||||
, Bry__data_xowa_title = Bry_.new_a7("data-xowa-title")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.wkrs.imgs.atrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
import gplx.core.brys.*;
|
||||
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 {
|
||||
@@ -32,12 +32,12 @@ public class Xoh_img_xoimg_hzip {
|
||||
flag_bldr.Set(Flag__height_exists , height_exists);
|
||||
flag_bldr.Set(Flag__width_exists , width_exists);
|
||||
flag_bldr.Set(Flag__lnki_type , arg.Lnki_type());
|
||||
Xoh_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
if (width_exists) Xoh_hzip_int_.Encode(2, bfr, arg.Lnki_w());
|
||||
if (height_exists) Xoh_hzip_int_.Encode(2, bfr, arg.Lnki_h());
|
||||
Gfo_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
if (width_exists) Gfo_hzip_int_.Encode(2, bfr, arg.Lnki_w());
|
||||
if (height_exists) Gfo_hzip_int_.Encode(2, bfr, arg.Lnki_h());
|
||||
if (upright_exists) bfr.Add_double(arg.Lnki_upright()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (time_exists) bfr.Add_double(arg.Lnki_time()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (page_exists) Xoh_hzip_int_.Encode(2, bfr, arg.Lnki_page());
|
||||
if (page_exists) Gfo_hzip_int_.Encode(2, bfr, arg.Lnki_page());
|
||||
}
|
||||
public void Decode(Bry_bfr bfr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, Xoh_img_xoimg_data arg) {
|
||||
int flag = rdr.Read_hzip_int(1);
|
||||
|
||||
@@ -41,17 +41,16 @@ public class Xoh_lnki_data {
|
||||
public int Title_tid() {return title_tid;} private int title_tid;
|
||||
public int Title_bgn() {return title_bgn;} private int title_bgn;
|
||||
public int Title_end() {return title_end;} private int title_end;
|
||||
public boolean Tid_is_ctg_main() {return tid_is_ctg_main;} private boolean tid_is_ctg_main;
|
||||
public boolean Tid_is_ctg_tree() {return tid_is_ctg_tree;} private boolean tid_is_ctg_tree;
|
||||
public boolean Tid_is_ctg_xnav() {return tid_is_ctg_xnav;} private boolean tid_is_ctg_xnav;
|
||||
public byte Cls_tid() {return cls_tid;} private byte cls_tid;
|
||||
public Xoh_anch_href_data Href_itm() {return href_itm;} private final Xoh_anch_href_data href_itm = new Xoh_anch_href_data();
|
||||
public Xoh_anch_capt_itm Capt_itm() {return capt_itm;} private final Xoh_anch_capt_itm capt_itm = new Xoh_anch_capt_itm();
|
||||
private void Init(byte[] src) {
|
||||
this.src = href_src = capt_src = src;
|
||||
capt_has_ns = title_missing_ns = tid_is_ctg_main = tid_is_ctg_tree = tid_is_ctg_xnav = false;
|
||||
capt_has_ns = title_missing_ns = false;
|
||||
href_ns_id = Xow_ns_.Tid__main; href_ns_name = null; href_ns_name_len = 0;
|
||||
href_bgn = href_end = capt_bgn = capt_end = title_bgn = title_end = -1;
|
||||
title_tid = Title__href;
|
||||
this.cls_tid = Xoh_anch_cls_.Tid__none;
|
||||
href_itm.Clear();
|
||||
}
|
||||
public boolean Parse1(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag anch_head) {
|
||||
@@ -84,13 +83,8 @@ public class Xoh_lnki_data {
|
||||
}
|
||||
}
|
||||
private void Parse_cls(Gfh_tag anch_head) {
|
||||
byte[] cls_bry = anch_head.Atrs__get_as_bry(Gfh_atr_.Bry__class);
|
||||
byte cls_tid = Cls__trie.Match_byte_or(cls_bry, 0, cls_bry.length, Byte_.Max_value_127);
|
||||
switch (cls_tid) {
|
||||
case Cls_tid__main: this.tid_is_ctg_main = true; break;
|
||||
case Cls_tid__tree: this.tid_is_ctg_tree = true; break;
|
||||
case Cls_tid__xnav: this.tid_is_ctg_xnav = true; break;
|
||||
}
|
||||
byte[] cls_bry = anch_head.Atrs__get_as_bry(Gfh_atr_.Bry__class); if (Bry_.Len_eq_0(cls_bry)) return;
|
||||
this.cls_tid = Xoh_anch_cls_.Trie.Match_byte_or(cls_bry, 0, cls_bry.length, Xoh_anch_cls_.Tid__unknown);
|
||||
}
|
||||
private void Parse_capt(Gfh_tag_rdr tag_rdr, Gfh_tag anch_head) {
|
||||
this.capt_bgn = anch_head.Src_end(); // capt starts after <a>
|
||||
@@ -158,11 +152,4 @@ public class Xoh_lnki_data {
|
||||
, Title__diff = 2
|
||||
, Title__missing = 3
|
||||
;
|
||||
public static final byte[] Cls_bry__main = Bry_.new_a7("internal"), Cls_bry__xnav = Bry_.new_a7("xowa_nav");
|
||||
private static final byte Cls_tid__main = 0, Cls_tid__tree = 1, Cls_tid__xnav = 2;
|
||||
private static final Btrie_slim_mgr Cls__trie = Btrie_slim_mgr.cs()
|
||||
.Add_bry_byte(Cls_bry__main, Cls_tid__main)
|
||||
.Add_bry_byte(gplx.xowa.wikis.ctgs.Xoa_ctg_mgr.Html__cls__bry, Cls_tid__tree)
|
||||
.Add_bry_byte(Cls_bry__xnav, Cls_tid__xnav)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.htmls.core.wkrs.lnkis.anchs.*;
|
||||
public class Xoh_lnki_dict_ {
|
||||
public static void Ns_encode(Xoh_hzip_bfr bfr, int ns_id) {bfr.Add_hzip_int(1, ns_id + 2);}
|
||||
public static void Ns_encode(Bry_bfr bfr, int ns_id) {
|
||||
gplx.xowa.htmls.core.hzips.Xoh_hzip_int_.Encode(1, bfr, ns_id + 2);
|
||||
gplx.core.encoders.Gfo_hzip_int_.Encode(1, bfr, ns_id + 2);
|
||||
}
|
||||
public static int Ns_decode(Bry_rdr rdr) {
|
||||
return rdr.Read_hzip_int(1) - 2;
|
||||
|
||||
@@ -28,4 +28,7 @@ public class Xoh_lnki_html__hdump__tst {
|
||||
fxt.Test__html("[[wikt:a]]", "<a href='https://en.wiktionary.org/wiki/a' title='a'>wikt:a</a>");
|
||||
}
|
||||
@Test public void Anch() {fxt.Test__html("[[#a]]" , "<a href='#a'>#a</a>");}
|
||||
@Test public void Alt_has_quotes() {
|
||||
fxt.Test__html("[[File:A.png|alt=[[\"A\"]] B c]]", "<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" B c\"/></a>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
Xoh_lnki_data data = (Xoh_lnki_data)data_obj;
|
||||
Xoh_anch_href_data href = data.Href_itm();
|
||||
int ns_id = href.Ttl_ns_id();
|
||||
flag_bldr.Set_as_bool(Flag__tid_is_ctg_main , data.Tid_is_ctg_main());
|
||||
flag_bldr.Set_as_bool(Flag__tid_is_ctg_tree , data.Tid_is_ctg_tree());
|
||||
flag_bldr.Set_as_bool(Flag__tid_is_ctg_xnav , data.Tid_is_ctg_xnav());
|
||||
flag_bldr.Set_as_byte(Flag__cls_tid , data.Cls_tid());
|
||||
flag_bldr.Set_as_bool(Flag__title_missing_ns , data.Title_missing_ns());
|
||||
flag_bldr.Set_as_bool(Flag__ttl_is_main_page , href.Ttl_is_main_page());
|
||||
boolean ns_custom_exists= flag_bldr.Set_as_bool(Flag__ns_custom_exists , href.Ttl_ns_custom() != null);
|
||||
@@ -68,9 +66,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
}
|
||||
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) {
|
||||
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
|
||||
boolean tid_is_ctg_main = flag_bldr.Get_as_bool(Flag__tid_is_ctg_main);
|
||||
boolean tid_is_ctg_tree = flag_bldr.Get_as_bool(Flag__tid_is_ctg_tree);
|
||||
boolean tid_is_ctg_xnav = flag_bldr.Get_as_bool(Flag__tid_is_ctg_xnav);
|
||||
byte cls_tid = flag_bldr.Get_as_byte(Flag__cls_tid);
|
||||
boolean title_missing_ns = flag_bldr.Get_as_bool(Flag__title_missing_ns);
|
||||
boolean ttl_is_main_page = flag_bldr.Get_as_bool(Flag__ttl_is_main_page);
|
||||
boolean ns_custom_exists = flag_bldr.Get_as_bool(Flag__ns_custom_exists);
|
||||
@@ -116,12 +112,15 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
tmp_bfr.Add(ns.Name_db()).Add_byte_colon();
|
||||
}
|
||||
}
|
||||
Gfo_url_encoder encoder = href_type == Xoh_anch_href_data.Tid__wiki ? Gfo_url_encoder_.Href : Gfo_url_encoder_.Href_qarg; // NOTE: lnki vs lnke will encode entities differently
|
||||
// Gfo_url_encoder encoder = href_type == Xoh_anch_href_data.Tid__wiki ? Gfo_url_encoder_.Href : Gfo_url_encoder_.Href_qarg; // NOTE: lnki vs lnke will encode entities differently
|
||||
int href_end = href_bry.length;
|
||||
if (tid_is_ctg_xnav) // NOTE: for ctg_xnav, only encode title, not its query arguments; "?" x> "%3F" or "=" x> "%3D" or "sortkey=A B" -> "sortkey=A_B"; DATE:2015-12-28
|
||||
href_end = Bry_find_.Find_fwd(href_bry, Byte_ascii.Question, 0, href_end); if (href_end == Bry_find_.Not_found) rdr.Err_wkr().Fail("encoded question not found in category xnav link", "href", href_bry);
|
||||
encoder.Encode(tmp_bfr, href_bry, 0, href_end); // encode for href; EX: "/wiki/A's" -> "/wiki/A&27s"
|
||||
if (tid_is_ctg_xnav)
|
||||
if (cls_tid == Xoh_anch_cls_.Tid__ctg_xnav) { // NOTE: for ctg_xnav, only encode title, not its query arguments; "?" x> "%3F" or "=" x> "%3D" or "sortkey=A B" -> "sortkey=A_B"; DATE:2015-12-28
|
||||
href_end = Bry_find_.Find_fwd(href_bry, Byte_ascii.Question, 0, href_end);
|
||||
}
|
||||
// encoder.Encode(tmp_bfr, href_bry, 0, href_end); // encode for href; EX: "/wiki/A's" -> "/wiki/A&27s"
|
||||
// tmp_bfr.Add_mid(href_bry, 0, href_end); // encode for href; EX: "/wiki/A's" -> "/wiki/A&27s"
|
||||
tmp_bfr.Add_mid_w_swap(href_bry, 0, href_end, Byte_ascii.Space, Byte_ascii.Underline);
|
||||
if (cls_tid == Xoh_anch_cls_.Tid__ctg_xnav && href_end != -1)
|
||||
tmp_bfr.Add_mid(href_bry, href_end, href_bry.length);
|
||||
href_bry = tmp_bfr.To_bry_and_clear();
|
||||
break;
|
||||
@@ -132,7 +131,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
case Xoh_lnki_data.Title__missing: title_bry = null; break;
|
||||
case Xoh_lnki_data.Title__diff: break;
|
||||
case Xoh_lnki_data.Title__href:
|
||||
title_bry = tid_is_ctg_main
|
||||
title_bry = cls_tid == Xoh_anch_cls_.Tid__ctg_main
|
||||
? Gfo_url_encoder_.Href.Decode(capt_bry)
|
||||
: Gfo_url_encoder_.Href.Decode(href_bry);
|
||||
break;
|
||||
@@ -158,13 +157,16 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
bfr.Add(Xoh_href_.Bry__wiki);
|
||||
break;
|
||||
}
|
||||
bfr.Add(href_bry);
|
||||
if (tid_is_ctg_main)
|
||||
bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(Xoh_lnki_data.Cls_bry__main);
|
||||
else if (tid_is_ctg_tree)
|
||||
bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(gplx.xowa.wikis.ctgs.Xoa_ctg_mgr.Html__cls__bry);
|
||||
else if (tid_is_ctg_xnav)
|
||||
bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(Xoh_lnki_data.Cls_bry__xnav);
|
||||
bfr.Add(href_bry);
|
||||
byte[] cls_bry = null;
|
||||
switch (cls_tid) {
|
||||
case Xoh_anch_cls_.Tid__ctg_main: cls_bry = Xoh_anch_cls_.Bry__ctg_main; break;
|
||||
case Xoh_anch_cls_.Tid__ctg_tree: cls_bry = Xoh_anch_cls_.Bry__ctg_tree; break;
|
||||
case Xoh_anch_cls_.Tid__ctg_xnav: cls_bry = Xoh_anch_cls_.Bry__ctg_xnav; break;
|
||||
case Xoh_anch_cls_.Tid__media_info: cls_bry = Xoh_anch_cls_.Bry__media_info; break;
|
||||
case Xoh_anch_cls_.Tid__media_play: cls_bry = Xoh_anch_cls_.Bry__media_play; break;
|
||||
}
|
||||
if (cls_bry != null) bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(cls_bry);
|
||||
if (!hctx.Mode_is_diff())
|
||||
bfr.Add(Gfh_bldr_.Bry__id__nth).Add_str_a7(gplx.xowa.parsers.lnkis.redlinks.Xopg_redlink_lnki_list.Lnki_id_prefix).Add_int_variable(hctx.Uid__lnki_nxt());
|
||||
if ( href_type != Xoh_anch_href_data.Tid__anch) { // anchs never have title;
|
||||
@@ -179,20 +181,18 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_lnki_hzip rv = new Xoh_lnki_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (1, 1, 1, 1 , 1, 1, 2, 1 , 1, 2, 2, 2);
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (3, 1 , 1, 1, 2, 1 , 1, 2, 2, 2);
|
||||
private static final int // SERIALIZED
|
||||
Flag__tid_is_ctg_main = 0
|
||||
, Flag__tid_is_ctg_tree = 1
|
||||
, Flag__tid_is_ctg_xnav = 2
|
||||
, Flag__title_missing_ns = 3 //
|
||||
, Flag__ttl_is_main_page = 4 // [[c:]] -> "/site/commons.wikimedia.org/wiki/"
|
||||
, Flag__ns_custom_exists = 5 // [[c:category:a]] -> "/site/commons.wikimedia.org/wiki/category:a"
|
||||
, Flag__title_tid = 6 // href, capt, diff, empty; [//en.wikipedia.org] where en.w is local
|
||||
, Flag__capt_has_ns = 7 // "A" vs "Help:A"
|
||||
, Flag__ns_is_not_main = 8
|
||||
, Flag__href_type = 9 // "wiki", "site", "anch", "inet"
|
||||
, Flag__capt_cs0_tid = 10 // exact, lower, upper
|
||||
, Flag__text_type = 11 // "same", "diff", "more", "less"
|
||||
Flag__cls_tid = 0
|
||||
, Flag__title_missing_ns = 1
|
||||
, Flag__ttl_is_main_page = 2 // [[c:]] -> "/site/commons.wikimedia.org/wiki/"
|
||||
, Flag__ns_custom_exists = 3 // [[c:category:a]] -> "/site/commons.wikimedia.org/wiki/category:a"
|
||||
, Flag__title_tid = 4 // href, capt, diff, empty; [//en.wikipedia.org] where en.w is local
|
||||
, Flag__capt_has_ns = 5 // "A" vs "Help:A"
|
||||
, Flag__ns_is_not_main = 6
|
||||
, Flag__href_type = 7 // "wiki", "site", "anch", "inet"
|
||||
, Flag__capt_cs0_tid = 8 // exact, lower, upper
|
||||
, Flag__text_type = 9 // "same", "diff", "more", "less"
|
||||
;
|
||||
}
|
||||
class Xoh_lnki_hzip_ {
|
||||
|
||||
@@ -65,15 +65,18 @@ public class Xoh_lnki_hzip__ns__tst {
|
||||
fxt.Test__bicode("~${/;)Image~A b~", "<a href='/wiki/Image:A_b' title='Image:A b'>Image:A b</a>");
|
||||
}
|
||||
@Test public void Alias__url_encoding() { // EX: [[Image:Aü.png|b]]
|
||||
fxt.Test__bicode("~${-f)Image~Aü.png~b~", "<a href='/wiki/Image:A%C3%BC.png' title='Image:Aü.png'>b</a>");
|
||||
fxt.Test__bicode("~${3h)Image~A%C3%BC.png~b~Image:Aü.png~", "<a href='/wiki/Image:A%C3%BC.png' title='Image:Aü.png'>b</a>");
|
||||
}
|
||||
@Test public void Ctg__main() { // links at bottom of pages in main ns; DATE:2015-12-28
|
||||
fxt.Test__bicode("~$|&*G1A~", "<a href='/wiki/Category:A' class='inte" + "rnal' title='A'>A</a>");
|
||||
fxt.Test__bicode("~$|$t'1A~", "<a href='/wiki/Category:A' class='inte" + "rnal' title='A'>A</a>");
|
||||
}
|
||||
@Test public void Ctg__tree() { // links on Category pages;
|
||||
fxt.Test__bicode("~$|#q_1A~", "<a href='/wiki/Category:A' class='CategoryTreeLabel CategoryTreeLabelNs14 CategoryTreeLabelCategory'>A</a>");
|
||||
fxt.Test__bicode("~$|&3J1A~", "<a href='/wiki/Category:A' class='CategoryTreeLabel CategoryTreeLabelNs14 CategoryTreeLabelCategory'>A</a>");
|
||||
}
|
||||
@Test public void Ctg__xnav() { // previous / next 200 links on Category pages
|
||||
fxt.Test__bicode("~$|\"3/1A B?pageuntil=C, D#mw-pages~previous 200~Category:A_B~", "<a href='/wiki/Category:A_B?pageuntil=C, D#mw-pages' class='xowa_nav' title='Category:A_B'>previous 200</a>");
|
||||
@Test public void Ctg__xnav__space() { // previous / next 200 links on Category pages
|
||||
fxt.Test__bicode("~$|&`Z1A B?pageuntil=C, D#mw-pages~previous 200~Category:A_B~", "<a href='/wiki/Category:A_B?pageuntil=C, D#mw-pages' class='xowa_nav' title='Category:A_B'>previous 200</a>");
|
||||
}
|
||||
@Test public void Ctg__xnav__under() { // previous / next 200 links on Category pages; PAGE:en.w:Category:Public_transit_articles_with_unsupported_infobox_fields; DATE:2016-01-14
|
||||
fxt.Test__bicode("~$|&`Z1A B?pageuntil=C,_D#mw-pages~previous 200~Category:A_B~", "<a href='/wiki/Category:A_B?pageuntil=C,_D#mw-pages' class='xowa_nav' title='Category:A_B'>previous 200</a>");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xoh_lnki_hzip__same__tst {
|
||||
}
|
||||
@Test public void Same__encoded() { // EX: [[A's]]
|
||||
String html = "<a href=\"/wiki/A%27s\" title=\"A's\">A's</a>";
|
||||
fxt.Test__bicode_raw("~$!A's~", html, html);
|
||||
fxt.Test__bicode_raw("~${$#A%27s~A's~", html, html);
|
||||
}
|
||||
@Test public void Same__encoded__anch() { // EX: [[A#90.51]]
|
||||
fxt.Test__bicode("~${$%A~#90.51~", "<a href='/wiki/A#90.51' title='A'>A</a>");
|
||||
@@ -33,7 +33,7 @@ public class Xoh_lnki_hzip__same__tst {
|
||||
fxt.Test__bicode("~${$#A#.C2.A0B~abc~", "<a href='/wiki/A#.C2.A0B' title='abc'>abc</a>");
|
||||
}
|
||||
@Test public void Same__amp() { // EX: [[A&b]]
|
||||
fxt.Test__bicode("~${$#A&b~A&b~", "<a href='/wiki/A%26b' title='A&b'>A&b</a>");
|
||||
fxt.Test__bicode("~${$#A%26b~A&b~", "<a href='/wiki/A%26b' title='A&b'>A&b</a>");
|
||||
}
|
||||
@Test public void More__basic() { // EX: [[A]]b
|
||||
fxt.Test__bicode("~$#A~b~", "<a href='/wiki/A' title='A'>Ab</a>");
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Xoh_lnki_hzip__site__tst {
|
||||
fxt.Test__bicode("~$sen.wiktionary.org~/A~b~" , "<a href='/site/en.wiktionary.org/wiki/Help:A' title='Help:A'>Ab</a>");
|
||||
}
|
||||
@Test public void Ns__url_encoding() { // EX: [[wikt:Category:A & B|]]
|
||||
fxt.Test__bicode("~${$sen.wiktionary.org~1A & B~A & B~" , "<a href='/site/en.wiktionary.org/wiki/Category:A_%26_B' title='Category:A & B'>A & B</a>");
|
||||
fxt.Test__bicode("~${$sen.wiktionary.org~1A %26 B~A & B~" , "<a href='/site/en.wiktionary.org/wiki/Category:A_%26_B' title='Category:A & B'>A & B</a>");
|
||||
}
|
||||
@Test public void Less__eq() { // EX: [[wikt:Ab|A]]
|
||||
fxt.Test__bicode("~${*7en.wiktionary.org~A~b~" , "<a href='/site/en.wiktionary.org/wiki/Ab'>A</a>");
|
||||
@@ -59,7 +59,7 @@ public class Xoh_lnki_hzip__site__tst {
|
||||
fxt.Test__bicode("~$;en.wiktionary.org~a~b~" , "<a href='/site/en.wiktionary.org/wiki/a' title='a'>Ab</a>");
|
||||
}
|
||||
@Test public void Encode__lnki() { // EX: [[wikt:eorðe|eorðe]]
|
||||
fxt.Test__bicode("~$1en.wiktionary.org~eorðe~" , "<a href='/site/en.wiktionary.org/wiki/eor%C3%B0e' title='eorðe'>eorðe</a>");
|
||||
fxt.Test__bicode("~${$3en.wiktionary.org~eor%C3%B0e~eorðe~" , "<a href='/site/en.wiktionary.org/wiki/eor%C3%B0e' title='eorðe'>eorðe</a>");
|
||||
}
|
||||
// @Test public void Encode__lnke() { // EX: [//en.wiktionary.org/wiki/eorðe eorðe]; NOTE:MW inconsistently does not URL-encode external links (but does URL-encode @gplx.Internal protected ones)
|
||||
// fxt.Test__bicode("~$)en.wiktionary.org~eorðe~" , "<a href='/site/en.wiktionary.org/wiki/eorðe'>eorðe</a>");
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.wkrs.lnkis.anchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xoh_anch_cls_ {
|
||||
public static final byte
|
||||
Tid__none = 0
|
||||
, Tid__unknown = 1
|
||||
, Tid__media_play = 1
|
||||
, Tid__media_info = 2
|
||||
, Tid__ctg_main = 3
|
||||
, Tid__ctg_tree = 4
|
||||
, Tid__ctg_xnav = 5
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__media_play = Bry_.new_a7("xowa_media_play")
|
||||
, Bry__media_info = Bry_.new_a7("xowa_media_info")
|
||||
, Bry__ctg_main = Bry_.new_a7("internal")
|
||||
, Bry__ctg_tree = gplx.xowa.wikis.ctgs.Xoa_ctg_mgr.Html__cls__bry
|
||||
, Bry__ctg_xnav = Bry_.new_a7("xowa_nav")
|
||||
;
|
||||
public static final Btrie_slim_mgr Trie = Btrie_slim_mgr.cs()
|
||||
.Add_bry_byte(Bry__media_play , Tid__media_play)
|
||||
.Add_bry_byte(Bry__media_info , Tid__media_info)
|
||||
.Add_bry_byte(Bry__ctg_main , Tid__ctg_main)
|
||||
.Add_bry_byte(Bry__ctg_tree , Tid__ctg_tree)
|
||||
.Add_bry_byte(Bry__ctg_xnav , Tid__ctg_xnav)
|
||||
;
|
||||
}
|
||||
@@ -93,7 +93,10 @@ public class Xoh_anch_href_data implements Xoh_itm_parser {
|
||||
ttl_full_txt = ttl_page_db = Bry_.Empty;
|
||||
}
|
||||
else {
|
||||
ttl_full_txt = Gfo_url_encoder_.Href_wo_anchor.Decode(src, ttl_bgn, ttl_end);
|
||||
ttl_full_txt = Bry_.Mid(src, ttl_bgn, ttl_end);
|
||||
int ttl_full_len = ttl_full_txt.length;
|
||||
int question_pos = Bry_find_.Find_fwd(ttl_full_txt, Byte_ascii.Question, 0, ttl_full_len); if (question_pos == -1) question_pos = ttl_full_len;
|
||||
ttl_full_txt = Xoa_ttl.Replace_unders(ttl_full_txt, 0, question_pos); // NOTE: only replace unders up to question mark to handle category and sortkey; EX:Category:A?pageuntil=A B; PAGE:en.w:Category:Public_transit_articles_with_unsupported_infobox_fields; DATE:2016-01-14
|
||||
switch (tid) {
|
||||
case Xoh_anch_href_data.Tid__anch:
|
||||
case Xoh_anch_href_data.Tid__inet:
|
||||
@@ -102,7 +105,6 @@ public class Xoh_anch_href_data implements Xoh_itm_parser {
|
||||
break;
|
||||
case Xoh_anch_href_data.Tid__wiki:
|
||||
case Xoh_anch_href_data.Tid__site:
|
||||
int ttl_full_len = ttl_full_txt.length;
|
||||
int colon_pos = Bry_find_.Find_fwd(ttl_full_txt, Byte_ascii.Colon, 0, ttl_full_len);
|
||||
ttl_page_db = ttl_full_txt;
|
||||
if (colon_pos != Bry_find_.Not_found) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
|
||||
protected final Xoh_arg_img_core arg_img_core;
|
||||
private Bry_bfr scratch_bfr = Bry_bfr.reset_(128);
|
||||
private final Bfr_arg__hatr_id thm_file_id = Bfr_arg__hatr_id.New("xowa_file_div_"), thm_play_id = Bfr_arg__hatr_id.New("xowa_file_play_");
|
||||
private final Bfr_arg__hatr_id thm_file_id = Bfr_arg__hatr_id.New_id("xowa_file_div_"), thm_play_id = Bfr_arg__hatr_id.New_id("xowa_file_play_");
|
||||
public Xoh_file_html_fmtr__base() {
|
||||
arg_img_core = New_arg_img_core();
|
||||
}
|
||||
@@ -42,15 +42,22 @@ public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
|
||||
, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
|
||||
) {
|
||||
fmtr_full_img.Bld_bfr_many(tmp_bfr, uid
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
if (Bry_.Len_eq_0(a_href)) // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fmtr_full_img_wo_link.Bld_bfr_many(tmp_bfr, uid, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
else
|
||||
fmtr_full_img.Bld_bfr_many(tmp_bfr, uid
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
}
|
||||
private Bry_fmtr fmtr_full_img = Bry_fmtr.new_
|
||||
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"
|
||||
+ "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} /></a>"
|
||||
, "uid", "a_href", "a_class", "a_rel", "a_title", "a_xowa_title", "img_core", "img_alt", "img_class"
|
||||
);
|
||||
private Bry_fmtr fmtr_full_img_wo_link = Bry_fmtr.new_
|
||||
( "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} />"
|
||||
, "uid", "img_core", "img_alt", "img_class"
|
||||
);
|
||||
public byte[] Html_thumb_part_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid, byte[] a_href, byte[] img_src, byte[] img_alt) {
|
||||
byte[] a_title_atr = Gfh_atr_.Make(tmp_bfr, Gfh_atr_.Bry__title, xfer_itm.Lnki_ttl());
|
||||
Html_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, a_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, a_title_atr, Xoh_file_html_fmtr__base.Escape_xowa_title(xfer_itm.Lnki_ttl())
|
||||
@@ -126,32 +133,23 @@ public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
|
||||
}
|
||||
private final Bry_fmtr fmtr_thumb_part_info = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div>"
|
||||
, " <a href=\"~{a_href}\" class=\"image\" title=\"About this file\">"
|
||||
, " <img src=\"~{img_src}\" width=\"22\" height=\"22\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"~{a_href}\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
), "a_href", "img_src");
|
||||
|
||||
public void Html_thumb_part_play(Bry_bfr tmp_bfr, int uid, boolean mode_is_hdump, int a_width, int a_max_width, byte[] a_href, byte[] a_xowa_title, byte[] img_src) {
|
||||
if (mode_is_hdump) {
|
||||
thm_play_id.Bfr_arg__clear();
|
||||
a_href = Bry_.Empty;
|
||||
img_src = Bry_.Empty;
|
||||
a_width = 218; a_max_width = 220; // NOTE: hardcode widths; hdump will get actual file with from fsdb
|
||||
}
|
||||
else
|
||||
thm_play_id.Set(uid);
|
||||
fmtr_thumb_part_play.Bld_bfr_many(tmp_bfr, thm_play_id, a_width, a_max_width, a_href, a_xowa_title, img_src);
|
||||
fmtr_thumb_part_play.Bld_bfr_many(tmp_bfr, thm_play_id, a_width, a_max_width, a_href, a_xowa_title);
|
||||
}
|
||||
private final Bry_fmtr fmtr_thumb_part_play = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div>"
|
||||
, " <a~{id} href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\" class=\"xowa_anchor_button\" style=\"width:~{a_width}px;max-width:~{a_max_width}px;\">"
|
||||
, " <img src=\"~{img_src}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
), "id", "a_width", "a_max_width", "a_href", "a_xowa_title", "img_src");
|
||||
, "<div><a~{id} href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\" class=\"xowa_media_play\" style=\"width:~{a_width}px;max-width:~{a_max_width}px;\" alt=\"Play sound\"></a></div>"
|
||||
), "id", "a_width", "a_max_width", "a_href", "a_xowa_title");
|
||||
|
||||
public static final Xoh_file_html_fmtr__base Base = new Xoh_file_html_fmtr__base();
|
||||
public static byte[] Escape_xowa_title(byte[] lnki_ttl) {
|
||||
|
||||
@@ -26,42 +26,44 @@ public class Xoh_file_html_fmtr__hdump extends Xoh_file_html_fmtr__base {
|
||||
@Override public void Html_full_img(Bry_bfr bfr, gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm
|
||||
, int uid, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other) {
|
||||
boolean link_is_empty = Bry_.Len_eq_0(a_href); // NOTE: set link_is_empty before blanking a_href below
|
||||
if (a_href_is_file) a_href = Bry_.Empty;
|
||||
tmp_bfr.Add_str_a7(" data-xoimg=\"");
|
||||
tmp_bfr.Add_int_digits(1, Xop_lnki_type.To_tid(xfer_itm.Lnki_type())).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(xfer_itm.Lnki_w()).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(xfer_itm.Lnki_h()).Add_byte_pipe();
|
||||
tmp_bfr.Add_double(xfer_itm.Lnki_upright()).Add_byte_pipe();
|
||||
tmp_bfr.Add_double(xfer_itm.Lnki_time()).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(xfer_itm.Lnki_page()).Add_byte_quote();
|
||||
fmtr__img__full.Bld_bfr_many(bfr
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, img_alt, tmp_bfr.To_bry_and_clear(), arg_img_core.Init(uid, Bry_.Empty, 0, 0), Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, a_xowa_title);
|
||||
byte[] data_xowa_image = Bld_xowa_image_data(tmp_bfr, xfer_itm.Lnki_type(), xfer_itm.Lnki_w(), xfer_itm.Lnki_h(), xfer_itm.Lnki_upright(), xfer_itm.Lnki_time(), xfer_itm.Lnki_page());
|
||||
if (link_is_empty)
|
||||
Bld_anch_n(bfr, data_xowa_title, data_xowa_image, img_cls, img_cls_other, img_alt, Bry_.Empty);
|
||||
else
|
||||
fmtr_anch_y.Bld_bfr_many(bfr
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, Gfh_utl.Escape_html_as_bry(img_alt), data_xowa_title, data_xowa_image, arg_img_core.Init(uid, Bry_.Empty, 0, 0), Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
}
|
||||
private Bry_fmtr fmtr__img__full = Bry_fmtr.new_
|
||||
public static void Bld_anch_n(Bry_bfr bfr, byte[] data_xowa_title, byte[] data_xowa_image, byte img_cls, byte[] img_cls_other, byte[] img_alt, byte[] img_xtra_atrs) {
|
||||
fmtr_anch_n.Bld_bfr_many(bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.To_html(img_cls, img_cls_other), Gfh_utl.Escape_html_as_bry(img_alt), img_xtra_atrs);
|
||||
}
|
||||
public static byte[] Bld_xowa_image_data(Bry_bfr tmp_bfr, byte tid, int w, int h, double upright, double time, int page) {
|
||||
tmp_bfr.Add_byte_space().Add(Xoh_img_xoimg_data.Bry__data_xowa_image).Add_byte_eq().Add_byte_quote();
|
||||
tmp_bfr.Add_int_digits(1, Xop_lnki_type.To_tid(tid)).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(w).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(h).Add_byte_pipe();
|
||||
tmp_bfr.Add_double(upright).Add_byte_pipe();
|
||||
tmp_bfr.Add_double(time).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(page).Add_byte_quote();
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
private
|
||||
Bry_fmtr fmtr_anch_y = Bry_fmtr.new_
|
||||
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"
|
||||
+ "<img~{img_xoimg}~{img_core}~{img_class} alt=\"~{img_alt}\"/>"
|
||||
+ "<img~{img_xoimg}~{data_xowa_title}~{data_xowa_image}~{img_class} alt=\"~{img_alt}\"/>"
|
||||
+ "</a>"
|
||||
, "a_href", "a_class", "a_rel", "a_title", "a_xowa_title", "img_alt", "img_xoimg", "img_core", "img_class"
|
||||
, "a_href", "a_class", "a_rel", "a_title", "a_xowa_title", "img_alt", "img_xoimg", "data_xowa_title", "data_xowa_image", "img_class"
|
||||
)
|
||||
;
|
||||
private static final Bry_fmt fmtr_anch_n = Bry_fmt.New
|
||||
( "<img~{data_xowa_title}~{data_xowa_image} src=\"\" width=\"0\" height=\"0\"~{img_class} alt=\"~{img_alt}\"~{img_xtra_atrs}/>"
|
||||
, "data_xowa_title", "data_xowa_image", "img_class", "img_alt", "img_xtra_atrs"
|
||||
);
|
||||
|
||||
// public override void Html_full_media(Bry_bfr tmp_bfr, byte[] a_href, byte[] a_title, Bfr_arg html) {
|
||||
// fmtr_full_media.Bld_bfr_many(tmp_bfr, a_href, a_title, html);
|
||||
// }
|
||||
// public override void Html_thumb_core(Bry_bfr bfr, int uid, byte[] div1_halign, int div2_width, byte[] div2_content) {
|
||||
// tmp_bfr.Add(Xoh_make_trie_.Bry__img_style);
|
||||
// tmp_bfr.Add_int_variable(uid);
|
||||
// tmp_bfr.Add_byte_quote();
|
||||
// byte[] div2_width_repl = tmp_bfr.To_bry_and_clear();
|
||||
// fmtr_thumb_core.Bld_bfr_many(bfr, uid, div1_halign, div2_width_repl, div2_content);
|
||||
// }
|
||||
// public override void Html_thumb_part_magnify(Bry_bfr bfr, int uid, byte[] a_href, byte[] a_title, byte[] img_src) {Write_xnde(bfr, Xoh_make_trie_.Bry__file_mgnf, uid);}
|
||||
// public override void Html_thumb_part_info(Bry_bfr bfr, int uid, byte[] a_href, byte[] img_src) {Write_xnde(bfr, Xoh_make_trie_.Bry__file_info, uid);}
|
||||
// public override void Html_thumb_part_play(Bry_bfr bfr, int uid, int a_width, int a_max_width, byte[] a_href, byte[] a_xowa_title, byte[] img_src) {Write_xnde(bfr, Xoh_make_trie_.Bry__file_play, uid);}
|
||||
// private static void Write_xnde(Bry_bfr bfr, byte[] key, int uid) {
|
||||
// bfr.Add(key);
|
||||
// bfr.Add_int_variable(uid);
|
||||
// bfr.Add(Bry_xnde_end);
|
||||
// } private static final byte[] Bry_xnde_end = Bry_.new_a7("\"/>");
|
||||
public static final Xoh_file_html_fmtr__hdump Hdump = new Xoh_file_html_fmtr__hdump(); Xoh_file_html_fmtr__hdump() {}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public class Xoh_file_mgr {
|
||||
case Xof_cfg_download.Redownload_none:
|
||||
if (found) return false;
|
||||
if (!found
|
||||
&& xfer.Meta_itm() != null // null check; fsdb_call does not set meta
|
||||
&& xfer.Meta_itm().Orig_exists() == Xof_meta_itm.Exists_n)
|
||||
&& xfer.Dbmeta_itm() != null // null check; fsdb_call does not set meta
|
||||
&& xfer.Dbmeta_itm().Orig_exists() == Xof_meta_itm.Exists_n)
|
||||
return false; // not found, and orig_exists is n; do not download again (NOTE: even if current lnki is thumb, don't bother looking for thumb if orig is missing)
|
||||
break;
|
||||
case Xof_cfg_download.Redownload_missing:
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
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.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__audio__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Audio__full() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|noicon]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Audio__full_ogg() {// PURPOSE: ogg should show src on first load
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(true); // simulate release-mode wherein missing images will not have src
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.ogg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"A.ogg\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" width=\"220\" height=\"-1\" />" // note that src still exists (needed for clicking)
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(false);
|
||||
}
|
||||
@Test public void Audio__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.oga\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.oga\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Audio__full_width() { // ISSUE: width arg ignored for v2; zh.b:小学数学/自然数; DATE:2014-05-03
|
||||
fxt.Wiki().File_mgr().Version_2_y_();
|
||||
fxt.App().Usere().Init_by_app(fxt.App()); // TEST: init cache else null reference
|
||||
fxt.Test_html_wiki_frag("[[File:A.oga|30px|a]]", "<div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:30px;\">");
|
||||
fxt.Wiki().File_mgr().Version_1_y_();
|
||||
}
|
||||
@Test public void Audio__noicon() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|noicon|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
// @Test public void Ogg() {
|
||||
// fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogg).View_max_(0);
|
||||
// fxt .ini_page_api("commons", "A.ogg", "", 0, 0);
|
||||
// fxt .Lnki_orig_("A.ogg")
|
||||
// .Src( )
|
||||
// .Trg(
|
||||
// fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/4/42.csv", "A.ogg|z||2?0,0|0?0,0")
|
||||
// )
|
||||
// .tst();
|
||||
// fxt .Lnki_orig_("A.ogg")
|
||||
// .Html_orig_src_("file:///mem/trg/en.wikipedia.org/raw/4/2/A.ogg")
|
||||
// .tst();
|
||||
// fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogg).View_max_(-1);
|
||||
// }
|
||||
@@ -71,7 +71,7 @@ public class Xoh_file_wtr__basic {
|
||||
|| ( orig_ext.Id_is_ogg() // id is ogg
|
||||
&& wiki.File_mgr().Version_1_y() // version is v1 (v2 always marks ogg as aud); DATE:2014-02-01
|
||||
&& ( xfer_itm.File_exists() // NOTE: xfer_itm.Html_pass() checks for video .ogg files (ext = .ogg and thumb is available); EX: WWI;
|
||||
|| xfer_itm.Meta_is_new() // NOTE: State_new() will always assume that ogg is video; needed for 1st load and dynamic updates
|
||||
|| xfer_itm.Dbmeta_is_new() // NOTE: State_new() will always assume that ogg is video; needed for 1st load and dynamic updates
|
||||
)
|
||||
)
|
||||
) {
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_file_wtr_basic_tst {
|
||||
public class Xoh_file_wtr__image__tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Img__full() { // PURPOSE: full with title was outputting invalid html; DATE:2013-12-31
|
||||
@@ -110,14 +110,6 @@ public class Xoh_file_wtr_basic_tst {
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Img__link() { // PURPOSE.FIX: link=file:/// was creating "href='/wiki/file'" handle IPA links; EX:[[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/c/7/a/3/En-LudwigVanBeethoven.ogg|Listen]]; PAGE:en.w:Beethoven DATE:2015-12-28
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=file:///C:/A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///C:/A.ogg\" class=\"image\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Thm__alt_is_ws() { // PURPOSE: alt with space should not output <hr>; EX:[[File:A.png|thumb|alt= ]]; en.w:Bird; DATE:2015-12-28
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.png|thumb|220x110px|alt= ]]"
|
||||
@@ -287,6 +279,29 @@ public class Xoh_file_wtr_basic_tst {
|
||||
));
|
||||
fxt.Wtr_cfg().Lnki__title_(false);
|
||||
}
|
||||
@Test public void Link__file() { // PURPOSE.FIX: link=file:/// was creating "href='/wiki/file'" handle IPA links; EX:[[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/c/7/a/3/En-LudwigVanBeethoven.ogg|Listen]]; PAGE:en.w:Beethoven DATE:2015-12-28
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=file:///C:/A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///C:/A.ogg\" class=\"image\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=|abc]]", String_.Concat_lines_nl_skip_last
|
||||
( "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
));
|
||||
}
|
||||
@Test public void Link__lc() { // links to items in same namespace should automatically title-case words; DATE:2016-01-11
|
||||
fxt.Init_xwiki_add_wiki_and_user_("en", "en.wikipedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|11px|link=en:Help:a?b=c#d|abc]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/Help:A?b=c#d\" class=\"image\" xowa_title=\"A.png\">" // "Help:A" not "Help:a"
|
||||
+ "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"));
|
||||
fxt.Init_xwiki_clear();
|
||||
}
|
||||
private void Tst_img_title(String raw, String expd_ttl) {
|
||||
String actl = fxt.Exec_parse_page_wiki_as_str(raw);
|
||||
String actl_ttl = null;
|
||||
@@ -17,9 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*;
|
||||
public class Xoh_file_wtr_media_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
public class Xoh_file_wtr__media__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Lnki_caption_nested_media() { // PAGE:en.w:Beethoven;
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|thumb|b [[Media:A.ogg]] c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
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.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__video__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Video__full() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"400\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:398px;max-width:400px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full_ogg() {// PURPOSE: ogg should default to video on first load; otherwise dynamic-update won't be able to put in thumb; DATE:2015-05-21
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.ogg", Xof_ext_.Id_ogv, 400, 400, "");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogg|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:400px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:398px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.ogg\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogg\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|thumb|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"400\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:398px;max-width:400px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb_webm() { // PURPOSE: webm thumb wasn't being shown; DATE:2014-01-25
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.webm|thumb|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.webm\" class=\"image\" title=\"A.webm\" xowa_title=\"A.webm\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"400\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/3/4/A.webm\" xowa_title=\"A.webm\" class=\"xowa_media_play\" style=\"width:398px;max-width:400px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.webm\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,222 +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.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr_audio_video_tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Audio__full() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|noicon]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_anchor_button\" style=\"width:218px;max-width:1024px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Audio__full_ogg() {// PURPOSE: ogg should show src on first load
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(true); // simulate release-mode wherein missing images will not have src
|
||||
fxt.Test_parse_page_all_str
|
||||
( "[[File:A.ogg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"A.ogg\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" width=\"220\" height=\"-1\" />" // note that src still exists (needed for clicking)
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\" class=\"xowa_anchor_button\" style=\"width:218px;max-width:220px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
));
|
||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(false);
|
||||
}
|
||||
@Test public void Audio__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_anchor_button\" style=\"width:218px;max-width:1024px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"/wiki/File:A.oga\" class=\"image\" title=\"About this file\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/info.png\" width=\"22\" height=\"22\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.oga\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Audio__full_width() { // ISSUE: width arg ignored for v2; zh.b:小学数学/自然数; DATE:2014-05-03
|
||||
fxt.Wiki().File_mgr().Version_2_y_();
|
||||
fxt.App().Usere().Init_by_app(fxt.App()); // TEST: init cache else null reference
|
||||
fxt.Test_html_wiki_frag("[[File:A.oga|30px|a]]", "<div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:30px;\">");
|
||||
fxt.Wiki().File_mgr().Version_1_y_();
|
||||
}
|
||||
@Test public void Audio__noicon() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|noicon|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_anchor_button\" style=\"width:218px;max-width:1024px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///\" width=\"400\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_anchor_button\" style=\"width:398px;max-width:400px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full_ogg() {// PURPOSE: ogg should default to video on first load; otherwise dynamic-update won't be able to put in thumb; DATE:2015-05-21
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.ogg", Xof_ext_.Id_ogv, 400, 400, "");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogg|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:400px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///\" xowa_title=\"A.ogg\" class=\"xowa_anchor_button\" style=\"width:398px;max-width:1024px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"About this file\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/info.png\" width=\"22\" height=\"22\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogg\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|thumb|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///\" width=\"400\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_anchor_button\" style=\"width:398px;max-width:400px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb_webm() { // PURPOSE: webm thumb wasn't being shown; DATE:2014-01-25
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.webm|thumb|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.webm\" class=\"image\" title=\"A.webm\" xowa_title=\"A.webm\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///\" width=\"400\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/3/4/A.webm\" xowa_title=\"A.webm\" class=\"xowa_anchor_button\" style=\"width:398px;max-width:400px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.webm\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
}
|
||||
}
|
||||
// @Test public void Ogg() {
|
||||
// fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogg).View_max_(0);
|
||||
// fxt .ini_page_api("commons", "A.ogg", "", 0, 0);
|
||||
// fxt .Lnki_orig_("A.ogg")
|
||||
// .Src( )
|
||||
// .Trg(
|
||||
// fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/4/42.csv", "A.ogg|z||2?0,0|0?0,0")
|
||||
// )
|
||||
// .tst();
|
||||
// fxt .Lnki_orig_("A.ogg")
|
||||
// .Html_orig_src_("file:///mem/trg/en.wikipedia.org/raw/4/2/A.ogg")
|
||||
// .tst();
|
||||
// fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogg).View_max_(-1);
|
||||
// }
|
||||
@@ -66,7 +66,9 @@ public class Xoh_tag_parser implements Gfh_doc_wkr {
|
||||
}
|
||||
break;
|
||||
case Gfh_tag_.Id__img:
|
||||
if (cur.Name_id() == Gfh_tag_.Id__img) // img; EX: <hiero>
|
||||
if (cur.Atrs__has(gplx.xowa.htmls.core.wkrs.imgs.atrs.Xoh_img_xoimg_data.Bry__data_xowa_image))
|
||||
rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__img);
|
||||
else
|
||||
rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__img_bare);
|
||||
break;
|
||||
case Gfh_tag_.Id__div:
|
||||
|
||||
@@ -47,19 +47,27 @@ public class Xoh_thm_data implements Gfh_style_wkr {
|
||||
if (!img_data.Init_by_parse(hdoc_wkr, hctx, tag_rdr, src, tag_rdr.Tag__move_fwd_head(), null)) return false; // <a>
|
||||
if (!capt_data.Parse1(hdoc_wkr, tag_rdr, src, tag_rdr.Tag__move_fwd_head())) return false; // <div>
|
||||
rng_valid = true;
|
||||
int div_2_tail_end = tag_rdr.Pos();
|
||||
Gfh_tag div_1_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
|
||||
if (!capt_data.Capt_exists()) capt_data.Chk_capt_moved_by_tidy(src, div_2_tail_end, div_1_tail.Src_bgn());
|
||||
tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
|
||||
int tag_rdr_pos = tag_rdr.Pos();
|
||||
if (!Bry_.Match(src, tag_rdr_pos, tag_rdr_pos + 7, Xoh_thm_caption_data.Bry__div_1_tail_bgn)) { // TIDY:handle tidy relocating xowa-alt-div between div2 and div3; PAGE:en.w:Non-helical_models_of_DNA_structure; DATE:2016-01-11
|
||||
tag_rdr.Pos_(tag_rdr_pos + 6); // also move tag_rdr forward one
|
||||
Gfh_tag nxt_div_tail = tag_rdr.Tag__peek_fwd_tail(Gfh_tag_.Id__div);
|
||||
int capt_3_bgn = tag_rdr_pos;
|
||||
int capt_3_end = nxt_div_tail.Src_bgn();
|
||||
capt_data.Capt_3_(capt_3_bgn, capt_3_end);
|
||||
}
|
||||
tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
|
||||
this.src_end = tag_rdr.Pos();
|
||||
hdoc_wkr.On_thm(this);
|
||||
return true;
|
||||
}
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_bgn, int atr_end, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_val_bgn, int atr_val_end, int itm_bgn, int itm_End, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
if ( Bry_.Match(src, key_bgn, key_end, Gfh_style_key_.Bry__width)
|
||||
&& val_bgn - key_end == 1) { // handle invalid styles from en.w:Template:CSS_image_crop which have "width: 123px"; PAGE:en.w:Abraham_Lincoln; DATE:2016-01-02
|
||||
this.div_1_width = Bry_.To_int_or__lax(src, val_bgn, val_end, -1);
|
||||
}
|
||||
else // if there are any other attribs, invalidate; EX:style='width:123px;color:blue;'; PAGE:en.w:Wikipedia:New_CSS_framework; DATE:2016-01-11
|
||||
this.div_1_width = -1;
|
||||
return true;
|
||||
}
|
||||
public static final byte[]
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoh_thm_html_tst {
|
||||
fxt.Test__html("[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:220px;'>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title=\"A.png\" data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>test_caption"
|
||||
, " </div>"
|
||||
@@ -36,16 +36,8 @@ public class Xoh_thm_html_tst {
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:11px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
, " <a href=\"\" xowa_title=\"A.oga\" class=\"xowa_anchor_button\" style=\"width:218px;max-width:220px;\">"
|
||||
, " <img src=\"\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"/wiki/File:A.oga\" class=\"image\" title=\"About this file\">"
|
||||
, " <img src=\"\" width=\"22\" height=\"22\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.oga\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.oga\" class=\"internal\" title=\"Enlarge\"></a></div>b"
|
||||
@@ -60,13 +52,9 @@ public class Xoh_thm_html_tst {
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\"><img data-xoimg=\"4|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"\" xowa_title=\"A.ogv\" class=\"xowa_anchor_button\" style=\"width:218px;max-width:220px;\">"
|
||||
, " <img src=\"\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " <div><a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\"><img data-xowa-title=\"A.ogv\" data-xoimg=\"4|-1|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"\"/></a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>test_caption"
|
||||
|
||||
@@ -16,12 +16,12 @@ 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.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.divs.*;
|
||||
public class Xoh_thm_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
private final Xoh_img_hzip img_hzip = new Xoh_img_hzip();
|
||||
private final Xoh_thm_wtr wtr = new Xoh_thm_wtr();
|
||||
private final Bry_obj_ref div_2_capt = Bry_obj_ref.New_empty();
|
||||
private final Bry_obj_ref capt_1 = Bry_obj_ref.New_empty();
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__thm;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__thm;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
@@ -31,47 +31,51 @@ public class Xoh_thm_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
return this;
|
||||
}
|
||||
Xoh_thm_caption_data div_2_capt_parser = data.Capt_data();
|
||||
Xoh_thm_caption_data capt_data = data.Capt_data();
|
||||
int div_1_width = data.Div_1_width();
|
||||
flag_bldr.Set_as_bool(Flag__div_2_capt_moved_by_tidy , data.Capt_data().Capt_moved_by_tidy());
|
||||
boolean div_2_alt_exists = flag_bldr.Set_as_bool(Flag__div_2_alt_exists , data.Capt_data().Alt_div_exists());
|
||||
boolean capt_3_exists = flag_bldr.Set_as_bool(Flag__capt_3_exists , capt_data.Capt_3_exists());
|
||||
flag_bldr.Set_as_bool(Flag__capt_2_is_tidy , capt_data.Capt_2_exists() && capt_data.Capt_2_is_tidy());
|
||||
boolean capt_2_exists = flag_bldr.Set_as_bool(Flag__capt_2_exists , capt_data.Capt_2_exists());
|
||||
boolean div_1_width_exists = flag_bldr.Set_as_bool(Flag__div_1_width_exists , div_1_width != 220);
|
||||
flag_bldr.Set_as_byte(Flag__div_0_align , data.Div_0_align());
|
||||
bfr.Add(hook);
|
||||
Xoh_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
if (div_1_width_exists) Xoh_hzip_int_.Encode(2, bfr, div_1_width);
|
||||
if (div_2_capt_parser.Capt_exists()) bfr.Add_mid(src, div_2_capt_parser.Capt_bgn(), div_2_capt_parser.Capt_end());
|
||||
Gfo_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
if (div_1_width_exists) Gfo_hzip_int_.Encode(2, bfr, div_1_width);
|
||||
if (capt_data.Capt_1_exists()) bfr.Add_mid(src, capt_data.Capt_1_bgn(), capt_data.Capt_1_end());
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (div_2_alt_exists) bfr.Add_mid(src, div_2_capt_parser.Alt_div_bgn(), div_2_capt_parser.Alt_div_end()).Add_byte(Xoh_hzip_dict_.Escape);
|
||||
if (capt_2_exists) bfr.Add_hzip_mid(src, capt_data.Capt_2_bgn(), capt_data.Capt_2_end());
|
||||
if (capt_3_exists) bfr.Add_hzip_mid(src, capt_data.Capt_3_bgn(), capt_data.Capt_3_end());
|
||||
img_hzip.Encode1(bfr, hdoc_wkr, hctx, hpg, Bool_.N, src, data.Img_data());
|
||||
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) {
|
||||
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
|
||||
boolean div_2_capt_moved_by_tidy = flag_bldr.Get_as_bool(Flag__div_2_capt_moved_by_tidy);
|
||||
boolean div_2_alt_exists = flag_bldr.Get_as_bool(Flag__div_2_alt_exists);
|
||||
boolean capt_3_exists = flag_bldr.Get_as_bool(Flag__capt_3_exists);
|
||||
boolean capt_2_is_tidy = flag_bldr.Get_as_bool(Flag__capt_2_is_tidy);
|
||||
boolean capt_2_exists = flag_bldr.Get_as_bool(Flag__capt_2_exists);
|
||||
boolean div_1_width_exists = flag_bldr.Get_as_bool(Flag__div_1_width_exists);
|
||||
int div_0_align = flag_bldr.Get_as_int(Flag__div_0_align);
|
||||
int div_1_width = 220;
|
||||
if (div_1_width_exists) div_1_width = rdr.Read_hzip_int(2);
|
||||
int capt_bgn = rdr.Pos();
|
||||
int capt_end = rdr.Find_fwd_lr();
|
||||
div_2_capt.Mid_(src, capt_bgn, capt_end);
|
||||
byte[] div_2_alt_bry = div_2_alt_exists ? rdr.Read_bry_to() : Bry_.Empty;
|
||||
int capt_1_bgn = rdr.Pos(); int capt_1_end = rdr.Find_fwd_lr();
|
||||
capt_1.Mid_(src, capt_1_bgn, capt_1_end);
|
||||
byte[] capt_2_bry = capt_2_exists ? rdr.Read_bry_to() : Bry_.Empty;
|
||||
byte[] capt_3_bry = capt_3_exists ? rdr.Read_bry_to() : Bry_.Empty;
|
||||
|
||||
Xoh_img_data img_data = (Xoh_img_data)hctx.Pool_mgr__data().Get_by_tid(Xoh_hzip_dict_.Tid__img);
|
||||
img_hzip.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, rdr.Pos(), src_end, img_data);
|
||||
img_hzip.Wtr().Init_by_decode(hpg, hctx, src, img_data);
|
||||
wtr.Write(bfr, hpg, hctx, src, img_data.Img_is_vid(), div_0_align, div_1_width, div_2_alt_exists, div_2_alt_bry, img_hzip.Wtr(), img_hzip.Anch_href_bry(), div_2_capt, div_2_capt_moved_by_tidy);
|
||||
wtr.Write(bfr, hpg, hctx, src, img_data.Img_is_vid(), div_0_align, div_1_width, img_hzip.Wtr(), img_hzip.Anch_href_bry(), capt_1, capt_2_exists, capt_2_is_tidy, capt_2_bry, capt_3_exists, capt_3_bry);
|
||||
img_data.Pool__rls();
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_thm_hzip rv = new Xoh_thm_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1, 1, 3);
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1, 1, 1, 3);
|
||||
private static final int // SERIALIZED
|
||||
Flag__div_2_capt_moved_by_tidy = 0
|
||||
, Flag__div_2_alt_exists = 1
|
||||
, Flag__div_1_width_exists = 2
|
||||
, Flag__div_0_align = 3 // "", "tnone", "tleft", "tcenter", "tright"
|
||||
Flag__capt_3_exists = 0
|
||||
, Flag__capt_2_is_tidy = 1
|
||||
, Flag__capt_2_exists = 2
|
||||
, Flag__div_1_width_exists = 3
|
||||
, Flag__div_0_align = 4 // "", "tnone", "tleft", "tcenter", "tright"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ 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.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_thm_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Image() {
|
||||
fxt.Test__bicode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
@@ -34,24 +34,51 @@ public class Xoh_thm_hzip_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Video() {
|
||||
fxt.Test__bicode("~&%test_caption~|E9eA.ogv~%A.ogv~~", String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
fxt.Test__bicode("~&%test_caption~|E9eA.ogv~%A.ogv~~", Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_anchor_button' style='width:218px;max-width:220px;'><img src='' width='22' height='22' alt='Play sound'></a></div>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "test_caption</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""));
|
||||
)));
|
||||
}
|
||||
@Test public void Audio() {
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'/></div>"
|
||||
, "<div>~$|#na)~A.oga~About this file~</div>"
|
||||
, " </div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~$|%%,)~A.oga~Enlarge~</div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'/></div>"
|
||||
, "<div><a href='/wiki/File:A.oga' class='xowa_media_info' title='About this file'></a></div>"
|
||||
, " </div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.oga' class='internal' title='Enlarge'></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Capt_is_missing() { // [[File:A.png|thumb]]
|
||||
fxt.Test__bicode("~&#~!%A.png~)#S~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
@@ -60,9 +87,9 @@ public class Xoh_thm_hzip_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__moved_capt() {
|
||||
fxt.Test__bicode("~&Cabc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
fxt.Test__bicode("~&S~abc\n~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>abc"
|
||||
@@ -70,6 +97,64 @@ public class Xoh_thm_hzip_tst {
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__extra_closing_div() {// handle extra closing div in caption; PAGE:en.w:Damask; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&U<div>A</div>"
|
||||
, "B~"
|
||||
, "C~!1A.png~-\"b"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|150|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "<div>A</div>"
|
||||
, "B</div>"
|
||||
, "C</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__ul() { // tidy will move <div> on to different lines depending on <ul>; PAGE:en.w:Chimney_sweep; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&=$b* ABC~"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "~!uA.png~-$bABC~"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:320px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|320|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='ABC'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "* ABC</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__video() { // tidy may relocate xowa-alt-div to last div; PAGE:en.w:Non-helical_models_of_DNA_structure; DATE:2016-01-11
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&eabc~"
|
||||
, "<hr>"
|
||||
, "<div class=\"thumbcaption\">bcd</div>"
|
||||
, "~|E9eA.ogv~%A.ogv~~"), Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>bcd</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
@Test public void Fake__div_1__next_nde() { // PURPOSE: handle fake-thumbs with pseudo thumbimage class; PAGE:s.w:Mars
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
@@ -84,7 +169,7 @@ public class Xoh_thm_hzip_tst {
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'><a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbimage'><a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
@@ -107,7 +192,7 @@ public class Xoh_thm_hzip_tst {
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
@@ -132,7 +217,7 @@ public class Xoh_thm_hzip_tst {
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
@@ -142,13 +227,13 @@ public class Xoh_thm_hzip_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__thumbimage() { // PURPOSE.hdiff: handle fake-thumbs with image-map style; PAGE:en.w:UK
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;'>"
|
||||
, "<div class='thumbimage' style='width:250px;'>"
|
||||
, "<center>"
|
||||
, "<div style='width: 250px; float: none; margin: none; padding: none; border: none; clear: none; background-color: #ffffff; position: relative;'>"
|
||||
, "<div style='background-color: ;'>~%!!A.svg~)#q~</div>"
|
||||
, "{0}"
|
||||
, "<div style='font-size: smaller; line-height: 10px;'>"
|
||||
, "<div style='position:absolute;text-align:center;left:150.25px;top:292px'>abc</div>"
|
||||
, "</div>"
|
||||
@@ -158,20 +243,61 @@ public class Xoh_thm_hzip_tst {
|
||||
, "<div class='thumbcaption'>def</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div style=\"background-color: ;\">~%!!A.svg~)#q~</div>"), "'", "\""), String_.Format(html, "<div style='background-color: ;'><a href='/wiki/File:A.svg' class='image' title='' xowa_title='A.svg'><img data-xowa-title='A.svg' data-xoimg='0|250|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"));
|
||||
}
|
||||
@Test public void Fake__div_1__extra_attribs() {// PURPOSE.hdiff: handle fake thumbs with extra attribs; PAGE:en.w:Wikipedia:New_CSS_framework; DATE:2016-01-11
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;'>"
|
||||
, "<div class='thumbimage' style='width:250px;'>"
|
||||
, "<center>"
|
||||
, "<div style='width: 250px; float: none; margin: none; padding: none; border: none; clear: none; background-color: #ffffff; position: relative;'>"
|
||||
, "<div style='background-color: ;'><a href='/wiki/File:A.svg' class='image' title='' xowa_title='A.svg'><img data-xoimg='0|250|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div style='font-size: smaller; line-height: 10px;'>"
|
||||
, "<div style='position:absolute;text-align:center;left:150.25px;top:292px'>abc</div>"
|
||||
, "<div class='thumbinner' style='width:252px;color:blue;'>{0}" // "color:blue;" is invalid attribs
|
||||
, "<div class='thumbcaption'>abc"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</center>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "~%!!A.png~)#g~"), "'", "\""), String_.Format(html, "<a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"));
|
||||
}
|
||||
@Test public void Fake__div_2__not_media() { // PURPOSE.hdiff: handle fake-thumbs created through en.w:Template:Image_label_begin; PAGE:en.w:Blackburnshire; DATE:2016-01-04
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:240px;'>"
|
||||
, "<div style='width: 240pxpx;'>"
|
||||
, "{0}"
|
||||
, "<div>abc"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>def</div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "{1}"
|
||||
, "bcd</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div>~%!!A.png~)#g~</div>", "<div class=\"magnify\">~$a)A.png~</div>"), "'", "\""), String_.Format(html, "<div><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>", "<div class='magnify'><a href='/wiki/File:A.png' title='File:A.png'>A.png</a></div>"));
|
||||
}
|
||||
@Test public void Fix__omitted_table_tail() { // PURPOSE.hdiff: handle omitted </table>; PAGE:en.w:Alphabet; DATE:2016-01-06
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&]&D~"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "~!5A.png~-&D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:460px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|460|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
|
||||
@@ -22,30 +22,22 @@ import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.im
|
||||
public class Xoh_thm_wtr implements gplx.core.brys.Bfr_arg {
|
||||
private final Bfr_arg__bry div_0_align = Bfr_arg__bry.New_empty();
|
||||
private final Bfr_arg__int div_1_width = new Bfr_arg__int(-1);
|
||||
private final Bfr_arg__hatr_id div_1_id = Bfr_arg__hatr_id.New("xothm_");
|
||||
private final Bfr_arg__hatr_id div_1_id = Bfr_arg__hatr_id.New_id("xothm_");
|
||||
private final Bfr_arg__hatr_bry div_2_href = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__href);
|
||||
private final Bfr_arg__bry_ary div_2_magnify = new Bfr_arg__bry_ary();
|
||||
private final Bfr_arg__bry div_2_alt = Bfr_arg__bry.New(Bry_.Empty);
|
||||
private final Bfr_arg__bry capt_2 = Bfr_arg__bry.New(Bry_.Empty);
|
||||
private final Bfr_arg__bry capt_3 = Bfr_arg__bry.New(Bry_.Empty);
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private Bfr_arg div_1_img = Bfr_arg_.Noop, div_2_capt_arg = Bfr_arg_.Noop, div_2_capt_moved_by_tidy_arg = Bfr_arg_.Noop;
|
||||
private Bfr_arg div_1_img = Bfr_arg_.Noop, capt_1 = Bfr_arg_.Noop;
|
||||
private byte[] img_is_vid_nl, trailing_space;
|
||||
public Xoh_thm_wtr Div_2_alt_(boolean v, byte[] img_alt_bry) {
|
||||
if (v) {
|
||||
alt_fmtr.Bld_bfr_many(tmp_bfr, img_alt_bry);
|
||||
div_2_alt.Set_by_val(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
else
|
||||
div_2_alt.Set_by_val(Bry_.Empty);
|
||||
return this;
|
||||
}
|
||||
public Xoh_thm_wtr Clear() {
|
||||
Bfr_arg_.Clear(div_0_align, div_1_id, div_2_href, div_2_alt); // , div_1_width, div_2_magnify
|
||||
div_1_img = div_2_capt_arg = div_2_capt_moved_by_tidy_arg = Bfr_arg_.Noop;
|
||||
Bfr_arg_.Clear(div_0_align, div_1_id, div_2_href, capt_2, capt_3); // , div_1_width, div_2_magnify
|
||||
div_1_img = capt_1 = Bfr_arg_.Noop;
|
||||
img_is_vid_nl = Bry_.Empty;
|
||||
return this;
|
||||
}
|
||||
public void Write(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, boolean img_is_vid, int div_0_align, int div_1_w, boolean div_2_alt_exists, byte[] img_alt, Xoh_img_wtr img_wtr
|
||||
, byte[] div_2_href, Bfr_arg div_2_capt, boolean div_2_capt_moved_by_tidy) {
|
||||
public void Write(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, boolean img_is_vid, int div_0_align, int div_1_w, Xoh_img_wtr img_wtr, byte[] div_2_href
|
||||
, Bfr_arg capt_1, boolean capt_2_exists, boolean capt_2_is_tidy, byte[] capt_2_bry, boolean capt_3_exists, byte[] capt_3_bry) {
|
||||
this.Clear();
|
||||
this.img_is_vid_nl = img_is_vid ? Byte_ascii.Nl_bry : Bry_.Empty;
|
||||
this.trailing_space = img_is_vid ? Bry_.Empty : Byte_ascii.Space_bry;
|
||||
@@ -56,33 +48,38 @@ public class Xoh_thm_wtr implements gplx.core.brys.Bfr_arg {
|
||||
this.div_1_img = img_wtr;
|
||||
this.div_2_href.Set_by_bry(div_2_href);
|
||||
div_2_magnify.Set(hctx.Fsys__root(), bry_div_2_magnify);
|
||||
if (div_2_capt_moved_by_tidy) {
|
||||
this.div_2_capt_moved_by_tidy_arg = div_2_capt;
|
||||
this.div_2_capt_arg = Bfr_arg_.Noop;
|
||||
this.capt_1 = capt_1;
|
||||
if (capt_2_exists) {
|
||||
if (capt_2_is_tidy)
|
||||
capt_2.Set_by_val(capt_2_bry);
|
||||
else {
|
||||
alt_fmtr.Bld_bfr_many(tmp_bfr, capt_2_bry);
|
||||
capt_2.Set_by_val(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.div_2_capt_moved_by_tidy_arg = Bfr_arg_.Noop;
|
||||
this.div_2_capt_arg = div_2_capt;
|
||||
}
|
||||
this.Div_2_alt_(div_2_alt_exists, img_alt);
|
||||
else
|
||||
capt_2.Set_by_val(Byte_ascii.Nl_bry); // no capt_2, so force \n betwen </div>~{capt_2}</div>
|
||||
if (capt_3_exists)
|
||||
capt_3.Set_by_val(capt_3_bry);
|
||||
else
|
||||
capt_3.Set_by_val(Byte_ascii.Nl_bry);
|
||||
this.Bfr_arg__add(bfr);
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
fmtr.Bld_bfr_many(bfr, div_0_align, div_1_id, div_1_width, img_is_vid_nl, div_1_img, trailing_space, div_2_href, div_2_magnify, div_2_capt_arg, div_2_capt_moved_by_tidy_arg, div_2_alt);
|
||||
fmtr.Bld_bfr_many(bfr, div_0_align, div_1_id, div_1_width, img_is_vid_nl, div_1_img, trailing_space, div_2_href, div_2_magnify, capt_1, capt_2, capt_3);
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb t~{div_0_align}\">"
|
||||
, "<div~{div_1_id} class=\"thumbinner\" style=\"width:~{div_1_width}px;\">~{img_is_vid_nl}~{div_1_img}~{trailing_space}" // NOTE: trailing space is intentional; matches jtidy behavior
|
||||
, "<div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a~{div_2_href} class=\"internal\" title=\"Enlarge\"></a></div>"
|
||||
, "~{div_2_capt}</div>~{div_2_capt_moved_by_tidy}~{div_2_alt}"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "div_0_align", "div_1_id", "div_1_width", "img_is_vid_nl", "div_1_img", "trailing_space", "div_2_href", "div_2_magnify", "div_2_capt", "div_2_capt_moved_by_tidy", "div_2_alt");
|
||||
, "~{capt_1}</div>~{capt_2}</div>~{capt_3}</div>"
|
||||
), "div_0_align", "div_1_id", "div_1_width", "img_is_vid_nl", "div_1_img", "trailing_space", "div_2_href", "div_2_magnify", "capt_1", "capt_2", "capt_3");
|
||||
private static final Bry_fmtr alt_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<hr>"
|
||||
, "<div class=\"thumbcaption\">~{alt}</div>"
|
||||
, ""
|
||||
), "alt");
|
||||
private static final byte[] bry_div_2_magnify = Bry_.new_a7("bin/any/xowa/file/mediawiki.file/magnify-clip.png");
|
||||
}
|
||||
|
||||
@@ -20,49 +20,56 @@ import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
public class Xoh_thm_caption_data {
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public int Capt_bgn() {return capt_bgn;} private int capt_bgn;
|
||||
public int Capt_end() {return capt_end;} private int capt_end;
|
||||
public boolean Capt_exists() {return capt_end > capt_bgn;}
|
||||
public boolean Capt_moved_by_tidy() {return capt_moved_by_tidy;} private boolean capt_moved_by_tidy;
|
||||
public int Alt_div_bgn() {return alt_div_bgn;} private int alt_div_bgn;
|
||||
public int Alt_div_end() {return alt_div_end;} private int alt_div_end;
|
||||
public boolean Alt_div_exists() {return alt_div_end > alt_div_bgn;}
|
||||
public Xoh_thm_magnify_data Magnify_parser() {return magnify_parser;} private final Xoh_thm_magnify_data magnify_parser = new Xoh_thm_magnify_data();
|
||||
public int Capt_1_bgn() {return capt_1_bgn;} private int capt_1_bgn;
|
||||
public int Capt_1_end() {return capt_1_end;} private int capt_1_end;
|
||||
public boolean Capt_1_exists() {return capt_1_end > capt_1_bgn;}
|
||||
public int Capt_2_bgn() {return capt_2_bgn;} private int capt_2_bgn;
|
||||
public int Capt_2_end() {return capt_2_end;} private int capt_2_end;
|
||||
public boolean Capt_2_exists() {return capt_2_end > capt_2_bgn;}
|
||||
public boolean Capt_2_is_tidy() {return capt_2_is_tidy;} private boolean capt_2_is_tidy;
|
||||
public int Capt_3_bgn() {return capt_3_bgn;} private int capt_3_bgn;
|
||||
public int Capt_3_end() {return capt_3_end;} private int capt_3_end;
|
||||
public boolean Capt_3_exists() {return capt_3_end > capt_3_bgn;}
|
||||
public Xoh_thm_magnify_data Magnify_data() {return magnify_data;} private final Xoh_thm_magnify_data magnify_data = new Xoh_thm_magnify_data();
|
||||
public void Clear() {
|
||||
this.capt_moved_by_tidy = false;
|
||||
this.src_bgn = src_end = capt_bgn = capt_end = alt_div_bgn = alt_div_end = -1;
|
||||
magnify_parser.Clear();
|
||||
this.capt_2_is_tidy = false;
|
||||
this.src_bgn = src_end = capt_1_bgn = capt_1_end = capt_2_bgn = capt_2_end = capt_3_bgn = capt_3_end = -1;
|
||||
magnify_data.Clear();
|
||||
}
|
||||
public boolean Parse1(Xoh_hdoc_wkr hdoc_wkr, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag capt_head) {
|
||||
this.src_bgn = capt_head.Src_bgn();
|
||||
if (!magnify_parser.Parse(hdoc_wkr, tag_rdr, src, capt_head)) return false;
|
||||
this.capt_bgn = magnify_parser.Magnify_tail_div().Src_end();
|
||||
if (src[capt_bgn] != Byte_ascii.Nl) tag_rdr.Err_wkr().Fail("expected newline before caption");
|
||||
++capt_bgn; // skip \n
|
||||
tag_rdr.Pos_(magnify_parser.Magnify_tail_div().Src_end() + 1); // also move tag_rdr forward one
|
||||
if (!magnify_data.Parse(hdoc_wkr, tag_rdr, src, capt_head)) return false;
|
||||
this.capt_1_bgn = magnify_data.Magnify_tail_div().Src_end();
|
||||
if (src[capt_1_bgn] == Byte_ascii.Cr) ++capt_1_bgn; // wikitext sometimes has \r\n instead of \n; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
|
||||
if (src[capt_1_bgn] != Byte_ascii.Nl) tag_rdr.Err_wkr().Fail("expected newline before caption");
|
||||
++capt_1_bgn; // skip \n
|
||||
tag_rdr.Pos_(magnify_data.Magnify_tail_div().Src_end() + 1); // also move tag_rdr forward one
|
||||
Gfh_tag capt_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
|
||||
this.capt_end = capt_tail.Src_bgn();
|
||||
Alt_div_exists(tag_rdr, src);
|
||||
this.capt_1_end = capt_tail.Src_bgn();
|
||||
Capt_2_chk(tag_rdr, capt_tail, src);
|
||||
this.src_end = tag_rdr.Pos();
|
||||
return true;
|
||||
}
|
||||
public void Chk_capt_moved_by_tidy(byte[] src, int div_1_tail_end, int div_0_tail_bgn) {
|
||||
int pos = Bry_find_.Find_fwd_while_ws(src, div_1_tail_end, div_0_tail_bgn);
|
||||
if (pos != div_0_tail_bgn) {
|
||||
capt_moved_by_tidy = true;
|
||||
capt_bgn = div_1_tail_end;
|
||||
capt_end = Bry_find_.Find_bwd__skip_ws(src, div_0_tail_bgn, div_1_tail_end);
|
||||
private void Capt_2_chk(Gfh_tag_rdr tag_rdr, Gfh_tag capt_tail, byte[] src) {
|
||||
int capt_tail_end = capt_tail.Src_end();
|
||||
Gfh_tag nxt_div_tail = tag_rdr.Tag__peek_fwd_tail(Gfh_tag_.Id__div);
|
||||
int nxt_div_tail_bgn = nxt_div_tail.Src_bgn();
|
||||
Gfh_tag nxt_tag = tag_rdr.Tag__find_fwd_head(tag_rdr.Pos(), nxt_div_tail_bgn, Gfh_tag_.Id__hr);
|
||||
if (nxt_tag.Name_id() == Gfh_tag_.Id__hr) { // "alt" text
|
||||
tag_rdr.Tag__move_fwd_head(); // <hr>
|
||||
nxt_tag = tag_rdr.Tag__move_fwd_head().Chk_name_or_fail(Gfh_tag_.Id__div); // <div>
|
||||
capt_2_bgn = nxt_tag.Src_end(); // NOTE: do not try to trim ws; PAGE:en.w:Chimney_sweep; DATE:2016-01-05
|
||||
nxt_tag = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div); // </div>
|
||||
capt_2_end = nxt_tag.Src_bgn(); // NOTE: do not try to trim ws; PAGE:en.w:Chimney_sweep; DATE:2016-01-05
|
||||
}
|
||||
else {
|
||||
if (!Bry_.Match(src, capt_tail_end, capt_tail_end + 7, Bry__div_1_tail_bgn)) { // next chars should be "\n</div>"
|
||||
capt_2_is_tidy = true;
|
||||
capt_2_bgn = capt_tail_end;
|
||||
capt_2_end = nxt_div_tail_bgn;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Alt_div_exists(Gfh_tag_rdr tag_rdr, byte[] src) {
|
||||
this.alt_div_bgn = alt_div_end = -1;
|
||||
Gfh_tag nxt_div_tail = tag_rdr.Tag__peek_fwd_tail(Gfh_tag_.Id__div);
|
||||
Gfh_tag nxt_tag = tag_rdr.Tag__find_fwd_head(tag_rdr.Pos(), nxt_div_tail.Src_bgn(), Gfh_tag_.Id__hr);
|
||||
if (nxt_tag.Name_id() != Gfh_tag_.Id__hr) return;
|
||||
tag_rdr.Tag__move_fwd_head(); // <hr>
|
||||
nxt_tag = tag_rdr.Tag__move_fwd_head().Chk_name_or_fail(Gfh_tag_.Id__div); // <div>
|
||||
alt_div_bgn = Bry_find_.Find_fwd_while_ws(src, nxt_tag.Src_end(), src.length);
|
||||
nxt_tag = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div); // </div>
|
||||
alt_div_end = Bry_find_.Find_bwd_non_ws_or_not_found(src, nxt_tag.Src_bgn() - 1, -1) + 1;
|
||||
}
|
||||
public void Capt_3_(int bgn, int end) {this.capt_3_bgn = bgn; this.capt_3_end = end;}
|
||||
public static final byte[] Bry__div_1_tail_bgn = Bry_.new_a7("\n</div>");
|
||||
}
|
||||
@@ -107,7 +107,7 @@ import gplx.xowa.htmls.core.hzips.*;
|
||||
// private void Save_tag(Bry_bfr bfr, Hz_tag_itm ztag) {
|
||||
// Xohz_style_itm[] atrs = ztag.Atrs();
|
||||
// int len = atrs.length;
|
||||
// Xoh_hzip_int_.Encode(1, bfr, ztag.Id());
|
||||
// Gfo_hzip_int_.Encode(1, bfr, ztag.Id());
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
// Xohz_style_itm atr = atrs[i];
|
||||
// Save_atr(bfr, atr, Byte_ascii.Escape);
|
||||
@@ -115,7 +115,7 @@ import gplx.xowa.htmls.core.hzips.*;
|
||||
// bfr.Add_byte_nl();
|
||||
// }
|
||||
// private void Save_atr(Bry_bfr bfr, Xohz_style_itm atr, byte dlm) {
|
||||
// // Xoh_hzip_int_.Encode(1, bfr, atr.Id());
|
||||
// // Gfo_hzip_int_.Encode(1, bfr, atr.Id());
|
||||
// Xohz_style_val[] vals = atr.Itms();
|
||||
// int len = vals.length;
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
@@ -130,12 +130,12 @@ import gplx.xowa.htmls.core.hzips.*;
|
||||
// Hz_tag_itm ztag = regy.Tags__get_or_new(htag.Name_id());
|
||||
//
|
||||
// bfr.Add(Hook_tag);
|
||||
// Xoh_hzip_int_.Encode(1, bfr, ztag.Id());
|
||||
// Gfo_hzip_int_.Encode(1, bfr, ztag.Id());
|
||||
// int len = htag.Atrs__len();
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
// Gfh_atr hatr = htag.Atrs__get_at(i);
|
||||
// Xohz_style_itm zatr = regy.Atrs__get_or_new(hatr.Key());
|
||||
// Xoh_hzip_int_.Encode(1, bfr, zatr.Id());
|
||||
// Gfo_hzip_int_.Encode(1, bfr, zatr.Id());
|
||||
// byte[] hval = hatr.Val();
|
||||
// if (zatr.Indexable())
|
||||
// zatr.Write(bfr, hval);
|
||||
@@ -175,7 +175,7 @@ import gplx.xowa.htmls.core.hzips.*;
|
||||
// list.Add(new Xohz_style_val(list.Count(), key, Bool_.Y));
|
||||
// }
|
||||
// public void Write(Bry_bfr bfr, byte[] key) {
|
||||
// Xoh_hzip_int_.Encode(1, bfr, 1);
|
||||
// Gfo_hzip_int_.Encode(1, bfr, 1);
|
||||
// }
|
||||
// }
|
||||
// class Xohz_style_val {
|
||||
|
||||
@@ -53,7 +53,7 @@ public class Xoh_href_parser {
|
||||
rv.Page_bry_(cur_page);
|
||||
break;
|
||||
case Xoa_url_.Tid_page:
|
||||
Xow_wiki ttl_wiki = wiki.App().Wiki_mgri().Get_by_key_or_make_init_n(rv.Wiki_bry());
|
||||
Xow_wiki ttl_wiki = wiki.App().Wiki_mgri().Get_by_or_make_init_n(rv.Wiki_bry());
|
||||
byte[] tmp_page = rv.Page_bry();
|
||||
if (rv.Page_is_main())
|
||||
tmp_page = ttl_wiki.Props().Main_page();
|
||||
|
||||
@@ -46,7 +46,7 @@ class Xoh_href_wtr_fxt {
|
||||
}
|
||||
public Xoae_app App() {return app;} private final Xoae_app app;
|
||||
public Xoh_href_wtr_fxt Prep_wiki_cs(String domain) {
|
||||
Xow_wiki wiki = app.Wiki_mgr().Get_by_key_or_make_init_n(Bry_.new_u8(domain));
|
||||
Xow_wiki wiki = app.Wiki_mgr().Get_by_or_make_init_n(Bry_.new_u8(domain));
|
||||
wiki.Ns_mgr().Ns_main().Case_match_(Xow_ns_case_.Tid__all);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xoh_js_cleaner {
|
||||
if (cleaned != null) {
|
||||
bfr.Del_by(end - bgn);
|
||||
bfr.Add(cleaned);
|
||||
app.Usr_dlg().Warn_many("", "", "javascript detected: wiki=~{0} ~{1}", wiki.Domain_str(), String_.new_u8(ttl.Full_txt()));
|
||||
app.Usr_dlg().Log_many("", "", "javascript detected: wiki=~{0} ~{1}", wiki.Domain_str(), String_.new_u8(ttl.Full_txt()));
|
||||
}
|
||||
}
|
||||
public byte[] Clean(Xowe_wiki wiki, byte[] src, int bgn, int end) {
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
|
||||
cur_page.Popup_mgr().Itms().Add_if_dupe_use_nth(itm.Popup_id(), itm);
|
||||
app.Html__href_parser().Parse_as_url(tmp_url, itm.Page_href(), wiki, cur_page.Ttl().Full_url()); // NOTE: use Full_url, not Page_url, else anchors won't work for non-main ns; PAGE:en.w:Project:Sandbox; DATE:2014-08-07
|
||||
if (!Xoa_url_.Tid_is_pagelike(tmp_url.Tid())) return Bry_.Empty; // NOTE: do not get popups for "file:///"; DATE:2015-04-05
|
||||
Xowe_wiki popup_wiki = app.Wiki_mgr().Get_by_key_or_null(tmp_url.Wiki_bry());
|
||||
Xowe_wiki popup_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_null(tmp_url.Wiki_bry());
|
||||
popup_wiki.Init_assert();
|
||||
Xoa_ttl popup_ttl = Xoa_ttl.parse(popup_wiki, tmp_url.To_bry_page_w_anch());
|
||||
switch (popup_ttl.Ns().Id()) {
|
||||
@@ -275,7 +275,7 @@ class Load_popup_wkr implements Gfo_thread_wkr {
|
||||
cur_page.Popup_mgr().Itms().Add_if_dupe_use_nth(itm.Popup_id(), itm);
|
||||
app.Html__href_parser().Parse_as_url(tmp_url, itm.Page_href(), wiki, cur_page.Ttl().Full_url()); // NOTE: use Full_url, not Page_url, else anchors won't work for non-main ns; PAGE:en.w:Project:Sandbox; DATE:2014-08-07
|
||||
if (!Xoa_url_.Tid_is_pagelike(tmp_url.Tid())) return; // NOTE: do not get popups for "file:///"; DATE:2015-04-05
|
||||
Xowe_wiki popup_wiki = app.Wiki_mgr().Get_by_key_or_null(tmp_url.Wiki_bry());
|
||||
Xowe_wiki popup_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_null(tmp_url.Wiki_bry());
|
||||
popup_wiki.Init_assert();
|
||||
Xoa_ttl popup_ttl = Xoa_ttl.parse(popup_wiki, tmp_url.To_bry_page_w_anch());
|
||||
switch (popup_ttl.Ns().Id()) {
|
||||
|
||||
@@ -78,11 +78,7 @@ public class Xoh_file_page_wtr {
|
||||
), "orig_width", "orig_height", "orig_href", "orig_file_size", "orig_mime_type", "elem_id", "thumb_width", "thumb_height", "thumb_href", "thumb_alt", "thumb_name", "section_alts");
|
||||
public Bry_fmtr Html_main_aud() {return html_main_aud;} private final Bry_fmtr html_main_aud = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div>"
|
||||
, " <a href=\"~{lnki_url}\" xowa_title=\"~{xowa_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
|
||||
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div><a href=\"~{lnki_url}\" xowa_title=\"~{xowa_title}\" class=\"xowa_media_play\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
), "lnki_url", "xowa_title", "play_width", "play_max_width", "play_icon");
|
||||
@@ -93,11 +89,7 @@ public class Xoh_file_page_wtr {
|
||||
, " <img id=\"xoimg_~{elem_id}\" src=\"~{lnki_src}\" width=\"~{lnki_width}\" height=\"~{lnki_height}\" alt=\"~{lnki_alt}\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"~{lnki_url}\" xowa_title=\"~{xowa_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
|
||||
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div><a href=\"~{lnki_url}\" xowa_title=\"~{xowa_title}\" class=\"xowa_media_play\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
), "elem_id", "lnki_href", "lnki_class", "xowa_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt", "lnki_url", "play_width", "play_max_width", "play_icon");
|
||||
|
||||
@@ -56,11 +56,7 @@ public class Xoh_ns_file_page_mgr_tst {
|
||||
.tst(String_.Concat_lines_nl_skip_last
|
||||
( Xoh_ns_file_page_mgr_fxt.Hdr
|
||||
, "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div>"
|
||||
, " <a href=\"file:///mem/file/orig.oga\" xowa_title=\"Test.oga\" class=\"xowa_anchor_button\" style=\"width:300px;max-width:300px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div><a href=\"file:///mem/file/orig.oga\" xowa_title=\"Test.oga\" class=\"xowa_media_play\" style=\"width:300px;max-width:300px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
@@ -75,11 +71,7 @@ public class Xoh_ns_file_page_mgr_tst {
|
||||
, " <img id=\"xoimg_0\" src=\"file:///mem/file/thumb.png\" width=\"300\" height=\"200\" alt=\"\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div>"
|
||||
, " <a href=\"file:///mem/file/orig.ogv\" xowa_title=\"Test.ogv\" class=\"xowa_anchor_button\" style=\"width:300px;max-width:300px;\">"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div><a href=\"file:///mem/file/orig.ogv\" xowa_title=\"Test.ogv\" class=\"xowa_media_play\" style=\"width:300px;max-width:300px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
|
||||
@@ -28,7 +28,10 @@ public class Xoh_section_mgr {
|
||||
}
|
||||
public void Set_content(int section_idx, byte[] src, int pos) {
|
||||
Xoh_section_itm itm = this.Get_at(section_idx);
|
||||
itm.Content_(Bry_.Mid(src, itm.Content_bgn(), pos));
|
||||
if (pos > itm.Content_bgn())
|
||||
itm.Content_(Bry_.Mid(src, itm.Content_bgn(), pos));
|
||||
else // TIDY:tidy will collapse "<h2>A</h2>\n\n<h2>B</h2>" to "<h2>A</h2>\n<h2>B</h2>"; this will show up as a pos < itm.Content_bgn; PAGE:en.w:Summer_solstice; DATE:2016-01-04
|
||||
itm.Content_(Bry_.Empty);
|
||||
}
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
int len = this.Len();
|
||||
|
||||
Reference in New Issue
Block a user