diff --git a/100_core/src/gplx/core/ios/zips/Io_zip_compress_cmd__jre.java b/100_core/src/gplx/core/ios/zips/Io_zip_compress_cmd__jre.java index d1e4770f2..a3ded866b 100644 --- a/100_core/src/gplx/core/ios/zips/Io_zip_compress_cmd__jre.java +++ b/100_core/src/gplx/core/ios/zips/Io_zip_compress_cmd__jre.java @@ -24,6 +24,7 @@ public class Io_zip_compress_cmd__jre { public Io_zip_compress_cmd__jre Make_new() {return new Io_zip_compress_cmd__jre();} public byte Exec_hook(gplx.core.progs.Gfo_prog_ui prog_ui, Io_url[] src_urls, Io_url trg_url, String resume_name, long resume_file, long resume_item) { OutputStream trg_out_stream; + Io_mgr.Instance.CreateDirIfAbsent(trg_url.OwnerDir()); try {trg_out_stream = new FileOutputStream(trg_url.Xto_api());} catch (Exception e) {throw Err_.new_exc(e, "io", "trg open failed", "url", trg_url.Raw());} ZipOutputStream trg_stream = new ZipOutputStream(trg_out_stream); diff --git a/100_core/src/gplx/core/tests/Gftest.java b/100_core/src/gplx/core/tests/Gftest.java index e463d7c45..d4eee1235 100644 --- a/100_core/src/gplx/core/tests/Gftest.java +++ b/100_core/src/gplx/core/tests/Gftest.java @@ -37,6 +37,7 @@ public class Gftest { throw Err_.new_wo_type(bfr.To_str_and_clear()); } } + public static void Eq__str(String expd, byte[] actl) {Eq__str(expd, String_.new_u8(actl), null);} public static void Eq__str(String expd, String actl) {Eq__str(expd, actl, null);} public static void Eq__str(String expd, String actl, String msg_fmt, Object... msg_args) { if (String_.Eq(expd, actl)) return; @@ -64,6 +65,16 @@ public class Gftest { bfr.Add(Bry__line_end); throw Err_.new_wo_type(bfr.To_str_and_clear()); } + public static void Eq__bool_y(boolean actl) {Eq__bool(Bool_.Y, actl, null);} + public static void Eq__bool(boolean expd, boolean actl) {Eq__bool(expd, actl, null);} + public static void Eq__bool(boolean expd, boolean actl, String msg_fmt, Object... msg_args) { + if (expd == actl) return; + Write_fail_head(bfr, msg_fmt, msg_args); + bfr.Add_str_a7("expd: ").Add_bool(expd).Add_byte_nl(); + bfr.Add_str_a7("actl: ").Add_bool(actl).Add_byte_nl(); + bfr.Add(Bry__line_end); + throw Err_.new_wo_type(bfr.To_str_and_clear()); + } public static void Eq__double(double expd, double actl) {Eq__double(expd, actl, null);} public static void Eq__double(double expd, double actl, String msg_fmt, Object... msg_args) { if (expd == actl) return; diff --git a/400_xowa/src/gplx/core/net/downloads/Http_download_wkr__jre.java b/400_xowa/src/gplx/core/net/downloads/Http_download_wkr__jre.java index d5aa9149f..a38c7fd40 100644 --- a/400_xowa/src/gplx/core/net/downloads/Http_download_wkr__jre.java +++ b/400_xowa/src/gplx/core/net/downloads/Http_download_wkr__jre.java @@ -20,7 +20,7 @@ import java.io.*; import java.net.*; import gplx.core.progs.*; public class Http_download_wkr__jre extends Http_download_wkr__base { - public Http_download_wkr Make_new() {return this;} + public Http_download_wkr Make_new() {return new Http_download_wkr__jre();} @Override public byte Exec_hook(Gfo_prog_ui prog_ui, String src_url, Io_url trg_url, long downloaded) { long prog_data_cur = downloaded; boolean prog_resumed = prog_data_cur > 0; diff --git a/400_xowa/src/gplx/langs/htmls/Gfh_tag_.java b/400_xowa/src/gplx/langs/htmls/Gfh_tag_.java index a3160b5a1..a8d4b54a8 100644 --- a/400_xowa/src/gplx/langs/htmls/Gfh_tag_.java +++ b/400_xowa/src/gplx/langs/htmls/Gfh_tag_.java @@ -37,6 +37,11 @@ public class Gfh_tag_ { , Id__br = 14 , Id__hr = 15 , Id__td = 16 + , Id__pre = 17 + , Id__small = 18 + , Id__i = 19 + , Id__b = 20 + , Id__sup = 21 ; public static final byte[] Bry__a = Bry_.new_a7("a") @@ -64,6 +69,11 @@ public class Gfh_tag_ { .Add_str_int("li" , Id__li) .Add_str_int("td" , Id__td) .Add_str_int("p" , Id__p) + .Add_str_int("pre" , Id__pre) + .Add_str_int("small" , Id__small) + .Add_str_int("i" , Id__i) + .Add_str_int("b" , Id__b) + .Add_str_int("sup" , Id__sup) ; public static String To_str(int tid) { switch (tid) { @@ -86,6 +96,11 @@ public class Gfh_tag_ { case Id__td: return "td"; case Id__ul: return "ul"; case Id__li: return "li"; + case Id__pre: return "pre"; + case Id__small: return "small"; + case Id__i: return "i"; + case Id__b: return "b"; + case Id__sup: return "sup"; default: throw Err_.new_unhandled(tid); } } diff --git a/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr.java b/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr.java index 43cd46b93..941c31583 100644 --- a/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr.java +++ b/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr.java @@ -33,6 +33,9 @@ public class Gfh_tag_rdr { tag__eos.Init(this, src, Bool_.N, Bool_.N, src_end, src_end, src_end, src_end, Gfh_tag_.Id__eos, Bry_.Empty); err_wkr.Init_by_page(String_.new_u8(ctx_name), src); } + public void Src_rng_(int src_bgn, int src_end) { + this.pos = src_bgn; this.src_end = src_end; + } public int Pos() {return pos;} private int pos; public void Pos_(int v) {this.pos = v;} public void Atrs__make(Mwh_atr_wkr atr_wkr, int head_bgn, int head_end) {atr_parser.Parse(atr_wkr, -1, -1, src, head_bgn, head_end);} @@ -58,6 +61,11 @@ public class Gfh_tag_rdr { while (tmp != stop_pos) { if (src[tmp] == Byte_ascii.Angle_bgn) { rv = Tag__extract(move, tail, match_name_id, tmp); + if (rv.Name_id() == Gfh_tag_.Id__comment) { // ignore comments DATE:2016-06-25 + tmp = rv.Src_end(); + rv = null; // null rv, else rv will still be comment and may get returned to caller + continue; + } if (Tag__match(move, bwd, tail, match_name_id, tmp_depth, rv)) break; else { @@ -82,12 +90,7 @@ public class Gfh_tag_rdr { if ( tag_name_id != match_name_id // tag doesn't match requested && match_name_id != Gfh_tag_.Id__any // requested is not wildcard ) return false; - if (tag_name_id == Gfh_tag_.Id__comment) { - if (match_name_id == Gfh_tag_.Id__comment) - return true; - else - return false; - } + if (tag_name_id == Gfh_tag_.Id__comment) return true; // ignore comments int depth = depth_obj.Val(); boolean tag_is_tail = tag.Tag_is_tail(); if (tail == tag_is_tail) { @@ -141,6 +144,7 @@ public class Gfh_tag_rdr { atrs_end = name_end; inline = true; loop = false; + ++tag_end; // move tag_end after > } else { name_end = tag_end = -1; diff --git a/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr_tst.java b/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr_tst.java index f98585da3..b5aefa3fc 100644 --- a/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr_tst.java +++ b/400_xowa/src/gplx/langs/htmls/docs/Gfh_tag_rdr_tst.java @@ -28,7 +28,6 @@ public class Gfh_tag_rdr_tst { } @Test public void Comment() { fxt.Init("135
6
"); - fxt.Test__move_fwd_head(Gfh_tag_.Id__comment , "") ; fxt.Test__pos("3"); fxt.Test__move_fwd_head(Gfh_tag_.Id__any , "
") ; fxt.Test__pos("6"); } @Test public void Meta() { @@ -45,6 +44,10 @@ public class Gfh_tag_rdr_tst { fxt.Test__move_fwd_head(Gfh_tag_.Id__div , "
") ; fxt.Test__pos("2"); fxt.Test__move_fwd_tail(Gfh_tag_.Id__div , "
") ; fxt.Test__pos("6"); } + @Test public void Inline() { + fxt.Init("1
2"); + fxt.Test__move_fwd_head(Gfh_tag_.Id__br , "
") ; fxt.Test__pos("2"); + } } class Gfh_tag_rdr_fxt { private final Gfh_tag_rdr rdr = Gfh_tag_rdr.New__html(); diff --git a/400_xowa/src/gplx/xowa/Xoa_app_.java b/400_xowa/src/gplx/xowa/Xoa_app_.java index 51bd1ede6..b2fd36489 100644 --- a/400_xowa/src/gplx/xowa/Xoa_app_.java +++ b/400_xowa/src/gplx/xowa/Xoa_app_.java @@ -34,7 +34,7 @@ public class Xoa_app_ { } } public static final String Name = "xowa"; - public static final String Version = "3.6.3.4"; + public static final String Version = "3.6.4.1"; public static String Build_date = "2012-12-30 00:00:00"; public static String Op_sys_str; public static String User_agent = ""; diff --git a/400_xowa/src/gplx/xowa/Xoa_page.java b/400_xowa/src/gplx/xowa/Xoa_page.java index 9ea62ded9..5c14c5321 100644 --- a/400_xowa/src/gplx/xowa/Xoa_page.java +++ b/400_xowa/src/gplx/xowa/Xoa_page.java @@ -29,4 +29,6 @@ public interface Xoa_page { Xoa_page__commons_mgr Commons_mgr(); void Xtn_gallery_packed_exists_y_(); + boolean Xtn__timeline_exists(); + boolean Xtn__gallery_exists(); } diff --git a/400_xowa/src/gplx/xowa/Xoae_page.java b/400_xowa/src/gplx/xowa/Xoae_page.java index 757ad005e..dbac73601 100644 --- a/400_xowa/src/gplx/xowa/Xoae_page.java +++ b/400_xowa/src/gplx/xowa/Xoae_page.java @@ -26,7 +26,7 @@ public class Xoae_page implements Xoa_page { this.wiki = wiki; this.ttl = ttl; this.lang = wiki.Lang(); // default to wiki.lang; can be override later by wikitext hdr_mgr = new Xow_hdr_mgr(this); - redlink_list = new Xopg_lnki_list(ttl.Ns().Id_is_module()); + redlink_list = new Xopg_lnki_list().Disabled_(ttl.Ns().Id_is_module()); Ttl_(ttl); } Xoae_page() {} // called by Empty public Xow_wiki Wiki() {return wiki;} @@ -35,6 +35,8 @@ public class Xoae_page implements Xoa_page { public byte[] Url_bry_safe() {return url == null ? Bry_.Empty : url.Raw();} public boolean Exists() {return !Missing();} public void Xtn_gallery_packed_exists_y_() {html_data.Xtn_gallery_packed_exists_y_();} + public boolean Xtn__timeline_exists() {return false;} // drd always sets timeline + public boolean Xtn__gallery_exists() {return false;} // drd does not need to set gallery.style.css public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data(); public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data(); public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;} diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_addon.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_addon.java index cdcf06bed..9469846ce 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_addon.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_addon.java @@ -17,10 +17,12 @@ along with this program. If not, see . */ package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.specials.*; import gplx.xowa.htmls.bridges.*; +import gplx.xowa.addons.bldrs.infos.*; public class Xobc_task_addon implements Xoax_addon_itm, Xoax_addon_itm__special, Xoax_addon_itm__json { public Xow_special_page[] Special_pages() { return new Xow_special_page[] { Xobc_task_special.Prototype + , Xobc_info_special.Prototype }; } public Bridge_cmd_itm[] Json_cmds() { diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_bridge.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_bridge.java index 417a38c6a..4777c1b10 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_bridge.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_bridge.java @@ -19,9 +19,10 @@ package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; impo import gplx.langs.jsons.*; import gplx.xowa.addons.bldrs.centrals.cmds.*; public class Xobc_task_bridge implements gplx.xowa.htmls.bridges.Bridge_cmd_itm { - public void Init_by_app(Xoa_app app) {} + private Xoa_app app; + public void Init_by_app(Xoa_app app) {this.app = app;} public String Exec(Json_nde data) { - Xobc_task_mgr task_mgr = Xobc_task_special.Task_mgr; + Xobc_task_mgr task_mgr = Xobc_task_special.Task_mgr(app); byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Msg__proc, null), Byte_ascii.Max_7_bit); Json_nde args = data.Get_kv(Msg__args).Val_as_nde(); switch (proc_id) { diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_html.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_html.java index ba7e4eb81..ef0babe9d 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_html.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_html.java @@ -36,7 +36,6 @@ class Xobc_task_html extends Xow_special_wtr__base { head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xobc.css"))); head_tags.Add(Xopg_tag_itm.New_htm_frag(addon_dir.GenSubFil_nest("bin", "xobc.row.mustache.html"), "xobc.row")); head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.log.js"))); - head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.ajax.listener.js"))); head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.app.js"))); head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", Get_app_js_file(app)))); head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.elem.js"))); diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_special.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_special.java index b4337d4d0..3500ab9e9 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_special.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/Xobc_task_special.java @@ -18,16 +18,21 @@ along with this program. If not, see . package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.wikis.pages.*; public class Xobc_task_special implements Xow_special_page { - public static Xobc_task_mgr Task_mgr; public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) { // init task_mgr page.Html_data().Cbk_enabled_(true); // apply cbk_enabled early to capture logging statements Xoa_app app = wiki.App(); - if (Task_mgr == null) Task_mgr = New_task_mgr(app); - Task_mgr.Load_or_init(); + if (task_mgr == null) task_mgr = New_task_mgr(app); + task_mgr.Load_or_init(); new Xobc_task_html().Bld_page_by_mustache(app, page, this); } + public static Xobc_task_mgr Task_mgr(Xoa_app app) { + if (task_mgr == null) { + task_mgr = New_task_mgr(app); + } + return task_mgr; + } private static Xobc_task_mgr task_mgr; private static Xobc_task_mgr New_task_mgr(Xoa_app app) { Io_url data_db_url = app.Fsys_mgr().Bin_addon_dir().GenSubFil_nest("bldr", "central", "bldr_central.data_db.xowa"); app.User().User_db_mgr().Init_site_mgr(); diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/Xobc_data_db.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/Xobc_data_db.java index 4c6115698..3538efd55 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/Xobc_data_db.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/Xobc_data_db.java @@ -54,14 +54,4 @@ public class Xobc_data_db { tbl__import_step.Delete(step_id); } } - private final gplx.core.lists.hashs.Hash_adp__int host_hash = new gplx.core.lists.hashs.Hash_adp__int(); - public String Bld_src_http_url(gplx.core.brys.evals.Bry_eval_mgr eval_mgr, int host_id, String file_name) { - Xobc_host_regy_itm host_itm = (Xobc_host_regy_itm)host_hash.Get_by_or_null(host_id); - if (host_itm == null) { - host_itm = tbl__host_regy.Select(host_id); - host_hash.Add(host_id, host_itm); - } - String host_dir = String_.new_u8(eval_mgr.Eval(Bry_.new_u8(host_itm.Host_data_dir()))); - return String_.Format("http://{0}/{1}/{2}", host_itm.Host_domain(), host_dir, file_name); - } } diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_step_map_tbl.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_step_map_tbl.java index ee6edb657..42ba092a6 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_step_map_tbl.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_step_map_tbl.java @@ -68,6 +68,16 @@ public class Xobc_step_map_tbl implements Db_tbl { } finally {rdr.Rls();} throw Err_.new_("", "xobc:could not find next sort", "task_id", task_id); } + public List_adp Select_all(int task_id) { + List_adp rv = List_adp_.New(); + Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_id).Crt_int(fld_task_id, task_id).Exec_select__rls_auto(); + try { + while (rdr.Move_next()) { + rv.Add(rdr.Read_int("step_id")); + } + } finally {rdr.Rls();} + return rv; + } public void Insert(int sm_id, int task_id, int step_id, int step_seqn) { if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds); insert_stmt.Clear().Val_int(fld_sm_id, sm_id).Val_int(fld_task_id, task_id).Val_int(fld_step_id, step_id).Val_int(fld_step_seqn, step_seqn) diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_task_regy_tbl.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_task_regy_tbl.java index 0da2d429d..2c774df52 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_task_regy_tbl.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/dbs/datas/Xobc_task_regy_tbl.java @@ -56,6 +56,11 @@ public class Xobc_task_regy_tbl implements Db_tbl { try {return rdr.Move_next() ? rdr.Read_int(fld_task_id) : -1;} finally {rdr.Rls();} } + public String Select_key_by_id_or_null(int id) { + Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_id).Crt_int(fld_task_id, id).Exec_select__rls_auto(); + try {return rdr.Move_next() ? rdr.Read_str(fld_task_key) : null;} + finally {rdr.Rls();} + } public void Insert(int task_id, int task_seqn, int step_count, String task_key, String task_name) { if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds); insert_stmt.Clear().Val_int(fld_task_id, task_id).Val_int(fld_task_seqn, task_seqn).Val_int(fld_step_count, step_count) diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_itm.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_itm.java new file mode 100644 index 000000000..61733a8e1 --- /dev/null +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_itm.java @@ -0,0 +1,46 @@ +/* +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 . +*/ +package gplx.xowa.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; +import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; +import gplx.core.brys.evals.*; +import gplx.xowa.wikis.domains.*; +public class Host_eval_itm { + private final Bry_eval_mgr mgr = Bry_eval_mgr.Dflt(); + private final Host_eval_wkr wkr = new Host_eval_wkr(); + private final Hash_adp host_hash = Hash_adp_.New(); + public Host_eval_itm() { + mgr.Add_many(wkr); + } + public byte[] Eval_dir_name(Xow_domain_itm domain_itm) { + wkr.Domain_itm_(domain_itm); + return mgr.Eval(Bry_.new_u8("Xowa_~{host_regy|wiki_abrv}_latest")); + } + public String Eval_src_fil(Xobc_data_db data_db, int host_id, Xow_domain_itm domain, String file_name) { + return Eval_src_dir(data_db, host_id, domain) + file_name; + } + public String Eval_src_dir(Xobc_data_db data_db, int host_id, Xow_domain_itm domain) { + Xobc_host_regy_itm host_itm = (Xobc_host_regy_itm)host_hash.Get_by(host_id); + if (host_itm == null) { + host_itm = data_db.Tbl__host_regy().Select(host_id); + host_hash.Add(host_id, host_itm); + } + wkr.Domain_itm_(domain); + String host_dir = String_.new_u8(mgr.Eval(Bry_.new_u8(host_itm.Host_data_dir()))); + return String_.Format("http://{0}/{1}/", host_itm.Host_domain(), host_dir); + } +} diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/utils/Bry_eval_wkr__host_regy.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java similarity index 75% rename from 400_xowa/src/gplx/xowa/addons/bldrs/centrals/utils/Bry_eval_wkr__host_regy.java rename to 400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java index df364226d..11f9187f6 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/utils/Bry_eval_wkr__host_regy.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java @@ -15,18 +15,23 @@ 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 . */ -package gplx.xowa.addons.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; +package gplx.xowa.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.core.brys.evals.*; import gplx.xowa.wikis.domains.*; -public class Bry_eval_wkr__host_regy implements Bry_eval_wkr { +public class Host_eval_wkr implements Bry_eval_wkr { private Xow_domain_itm domain_itm; public String Key() {return "host_regy";} - public Bry_eval_wkr__host_regy Domain_itm_(Xow_domain_itm domain_itm) {this.domain_itm = domain_itm; return this;} + public Host_eval_wkr Domain_itm_(Xow_domain_itm domain_itm) {this.domain_itm = domain_itm; return this;} public void Resolve(Bry_bfr rv, byte[] src, int args_bgn, int args_end) { // EX: "~{host_regy|wiki_abrv}" -> "enwiki" int type = hash.Get_as_byte_or(src, args_bgn, args_end, Byte_.Max_value_127); switch (type) { - case Type__wiki_abrv: rv.Add(domain_itm.Abrv_wm()); break; + case Type__wiki_abrv: + byte[] lang_key = domain_itm.Lang_orig_key(); + if (lang_key == Bry_.Empty) lang_key = Bry_.new_a7("en"); // handle species + rv.Add(lang_key); + rv.Add_str_a7("wiki"); + break; default: throw Err_.new_unhandled_default(type); } } diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr__tst.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr__tst.java new file mode 100644 index 000000000..2c8f75e95 --- /dev/null +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr__tst.java @@ -0,0 +1,32 @@ +/* +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 . +*/ +package gplx.xowa.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; +import org.junit.*; import gplx.core.tests.*; import gplx.xowa.wikis.domains.*; +public class Host_eval_wkr__tst { + private final Host_eval_wkr__fxt fxt = new Host_eval_wkr__fxt(); + @Test public void En_w() {fxt.Test__resolve_quick("en.wikipedia.org" , "Xowa_enwiki_latest");} + @Test public void Fr_d() {fxt.Test__resolve_quick("fr.wiktionary.org" , "Xowa_frwiki_latest");} + @Test public void Species() {fxt.Test__resolve_quick("species.wikimedia.org" , "Xowa_enwiki_latest");} +} +class Host_eval_wkr__fxt { + public void Test__resolve_quick(String domain_str, String expd) { + Host_eval_itm eval_itm = new Host_eval_itm(); + Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_str)); + Gftest.Eq__bry(Bry_.new_u8(expd), eval_itm.Eval_dir_name(domain_itm)); + } +} \ No newline at end of file diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/steps/Xobc_step_factory.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/steps/Xobc_step_factory.java index 873ff48bb..d06862d0e 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/steps/Xobc_step_factory.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/steps/Xobc_step_factory.java @@ -18,19 +18,18 @@ along with this program. If not, see . package gplx.xowa.addons.bldrs.centrals.steps; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*; import gplx.core.brys.evals.*; import gplx.core.primitives.*; import gplx.xowa.addons.bldrs.centrals.tasks.*; import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.utils.*; -import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; +import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.hosts.*; import gplx.xowa.addons.bldrs.exports.merges.*; import gplx.xowa.wikis.domains.*; public class Xobc_step_factory { private final Xobc_task_mgr task_mgr; private final Xobc_data_db data_db; - private final Bry_eval_mgr eval_mgr = Bry_eval_mgr.Dflt(), eval_mgr__host_regy = Bry_eval_mgr.Dflt(); - private final Bry_eval_wkr__host_regy eval_wkr__host_regy = new Bry_eval_wkr__host_regy(); + private final Bry_eval_mgr eval_mgr = Bry_eval_mgr.Dflt(); private final Host_eval_itm host_eval = new Host_eval_itm(); + private final Host_eval_wkr eval_wkr__host_regy = new Host_eval_wkr(); public Xobc_step_factory(Xobc_task_mgr task_mgr, Xobc_data_db data_db, Io_url wiki_dir) { this.task_mgr = task_mgr; this.data_db = data_db; eval_mgr.Add_many(new Bry_eval_wkr__builder_central(wiki_dir)); - eval_mgr__host_regy.Add_many(eval_wkr__host_regy); } public void Load(Xobc_task_itm task, int step_id, int cmd_idx) { int step_type = data_db.Tbl__step_regy().Select_type(step_id); @@ -57,7 +56,7 @@ public class Xobc_step_factory { String file_name = import_itm.Import_name; step_name.Val_(file_name); eval_wkr__host_regy.Domain_itm_(domain_itm); - String src_http_url = data_db.Bld_src_http_url(eval_mgr__host_regy, import_itm.Host_id, file_name); + String src_http_url = host_eval.Eval_src_fil(data_db, import_itm.Host_id, domain_itm, file_name); Io_url zip_file_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__download_fil, wiki_domain, file_name)); Io_url unzip_dir_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__unzip_dir, wiki_domain, file_name)); Io_url wiki_dir_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__wiki_dir, wiki_domain, file_name)); diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_bldr_cmd.java b/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_bldr_cmd.java index 41997274e..982330839 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_bldr_cmd.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_bldr_cmd.java @@ -18,11 +18,19 @@ along with this program. If not, see . package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; public class Pack_file_bldr_cmd extends Xob_cmd__base { + private Io_url deploy_dir; public Pack_file_bldr_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);} @Override public void Cmd_run() { - new Pack_file_mgr().Exec(wiki); + new Pack_file_mgr().Exec(wiki, deploy_dir); } + @Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { + if (ctx.Match(k, Invk__deploy_dir_)) deploy_dir = m.ReadIoUrl("v"); + else return super.Invk (ctx, ikey, k, m); + return this; + } + private static final String Invk__deploy_dir_ = "deploy_dir_"; + public static final String BLDR_CMD_KEY = "bldr.export.pack.file"; @Override public String Cmd_key() {return BLDR_CMD_KEY;} public static final Xob_cmd Prototype = new Pack_file_bldr_cmd(null, null); diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_mgr.java b/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_mgr.java index 35d7a2249..821b5d210 100644 --- a/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_mgr.java +++ b/400_xowa/src/gplx/xowa/addons/bldrs/exports/packs/files/Pack_file_mgr.java @@ -18,9 +18,9 @@ along with this program. If not, see . package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*; import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.*; import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.fsdb.*; import gplx.fsdb.meta.*; -import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*; +import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.hosts.*; class Pack_file_mgr { - public void Exec(Xowe_wiki wiki) { + public void Exec(Xowe_wiki wiki, Io_url deploy_dir) { // init wiki.Init_assert(); Io_url wiki_dir = wiki.Fsys_mgr().Root_dir(); @@ -53,6 +53,24 @@ class Pack_file_mgr { Make_task(tmp_bfr, wiki, wiki_date, bc_db, hash, "html", Xobc_import_type.Tid__wiki__core, Xobc_import_type.Tid__wiki__srch, Xobc_import_type.Tid__wiki__html); Make_task(tmp_bfr, wiki, wiki_date, bc_db, hash, "file", Xobc_import_type.Tid__file__core, Xobc_import_type.Tid__file__data); bc_conn.Txn_end(); + + // deploy + if (deploy_dir != null) { + Host_eval_itm host_eval = new Host_eval_itm(); + int len = hash.Len(); + for (int i = 0; i < len; ++i) { + Pack_list list = (Pack_list)hash.Get_at(i); + int list_len = list.Len(); + for (int j = 0; j < list_len; ++j) { + Pack_itm itm = (Pack_itm)list.Get_at(j); + byte[] owner_dir = host_eval.Eval_dir_name(wiki.Domain_itm()); + Io_url src_url = itm.Zip_url(); + Io_url trg_url = deploy_dir.GenSubFil_nest(String_.new_u8(owner_dir), src_url.NameAndExt()); + Io_mgr.Instance.MoveFil_args(src_url, trg_url, true).Exec(); + } + } + Io_mgr.Instance.Delete_dir_empty(pack_dir); + } } private static void Make_task(Bry_bfr tmp_bfr, Xow_wiki wiki, String wiki_date, Xobc_data_db bc_db, Pack_hash hash, String task_type, int... list_tids) { // get packs @@ -86,12 +104,15 @@ class Pack_file_mgr { } } public static String Build_task_name(Bry_bfr tmp_bfr, Xow_wiki wiki, String wiki_date, String task_type, long raw_len) {// Simple Wikipedia - Articles (2016-06) [420.31 MB] - byte[] lang_name = gplx.xowa.langs.Xol_lang_stub_.Get_by_key_or_null(wiki.Domain_itm().Lang_orig_key()).Canonical_name(); // EX: Deutsch - byte[] wiki_name = wiki.Domain_itm().Domain_type().Display_bry(); // EX: Wikipedia + byte[] lang_key = wiki.Domain_itm().Lang_orig_key(); + byte[] lang_name = Bry_.Len_eq_0(lang_key) // species.wikimedia.org and other wikimedia wikis have no lang; + ? Bry_.Empty + : Bry_.Add(gplx.xowa.langs.Xol_lang_stub_.Get_by_key_or_null(lang_key).Canonical_name(), Byte_ascii.Space); // EX: "Deutsch " + byte[] wiki_name = wiki.Domain_itm().Domain_type().Display_bry(); // EX: Wikipedia String type_name = String_.Eq(task_type, "html") ? "Articles" : "Images"; wiki_date = String_.Replace(wiki_date, ".", "-"); String file_size = gplx.core.ios.Io_size_.To_str_new(tmp_bfr, raw_len, 2); - return String_.Format("{0} {1} - {2} ({3}) [{4}]", lang_name, wiki_name, type_name, wiki_date, file_size); + return String_.Format("{0}{1} - {2} ({3}) [{4}]", lang_name, wiki_name, type_name, wiki_date, file_size); } private static void Make_pack(Xowe_wiki wiki, Io_url wiki_dir, byte[] wiki_abrv, String wiki_date, Xobc_data_db bc_db, Hash_algo hash_algo, Bry_bfr tmp_bfr, Pack_itm itm, int task_id) { // hash raws diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_doc.java b/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_doc.java new file mode 100644 index 000000000..74367880b --- /dev/null +++ b/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_doc.java @@ -0,0 +1,51 @@ +/* +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 . +*/ +package gplx.xowa.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; +import gplx.langs.mustaches.*; +class Xobc_info_doc implements Mustache_doc_itm { + private final byte[] wiki_domain, task_size; + private final String wiki_dir, torrent_fil; + private final Mustache_doc_itm[] urls; + public Xobc_info_doc(byte[] wiki_domain, String wiki_dir, byte[] task_size, String torrent_fil, Mustache_doc_itm[] urls) { + this.wiki_domain = wiki_domain; this.wiki_dir = wiki_dir; this.task_size = task_size; this.torrent_fil = torrent_fil; this.urls = urls; + } + public boolean Mustache__write(String key, Mustache_bfr bfr) { + if (String_.Eq(key, "wiki_domain")) bfr.Add_bry(wiki_domain); + else if (String_.Eq(key, "wiki_dir")) bfr.Add_str_u8(wiki_dir); + else if (String_.Eq(key, "task_size")) bfr.Add_bry(task_size); + else if (String_.Eq(key, "torrent_fil")) bfr.Add_str_u8(torrent_fil); + return false; + } + public Mustache_doc_itm[] Mustache__subs(String key) { + if (String_.Eq(key, "urls")) return urls; + return Mustache_doc_itm_.Ary__empty; + } +} +class Xobc_info_url implements Mustache_doc_itm { + private final String url; private final byte[] size; + public Xobc_info_url(String url, byte[] size) { + this.url = url; this.size = size; + } + public boolean Mustache__write(String key, Mustache_bfr bfr) { + if (String_.Eq(key, "url")) bfr.Add_str_u8(url); + else if (String_.Eq(key, "size")) bfr.Add_bry(size); + else return false; + return true; + } + public Mustache_doc_itm[] Mustache__subs(String key) {return Mustache_doc_itm_.Ary__empty;} +} diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_html.java b/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_html.java new file mode 100644 index 000000000..12fea8c52 --- /dev/null +++ b/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_html.java @@ -0,0 +1,89 @@ +/* +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 . +*/ +package gplx.xowa.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; +import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*; +import gplx.xowa.addons.bldrs.centrals.*; import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.hosts.*; +import gplx.xowa.wikis.domains.*; import gplx.core.ios.*; +class Xobc_info_html extends Xow_special_wtr__base { + private final Xobc_task_mgr task_mgr; + private final int task_id; + public Xobc_info_html(Xobc_task_mgr task_mgr, int task_id) {this.task_mgr = task_mgr; this.task_id = task_id;} + @Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "bldr", "info");} + @Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xobc_info.mustache.html");} + @Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) { + // get steps for task + Xobc_data_db data_db = task_mgr.Data_db(); + List_adp list = data_db.Tbl__step_map().Select_all(task_id); + + // get underlying files + Host_eval_itm host_eval = new Host_eval_itm(); + int len = list.Len(); + Xobc_info_url[] step_urls = new Xobc_info_url[len]; + Xow_domain_itm wiki_domain = null; + int host_id = -1; + long total_size = 0; + Bry_bfr tmp_size_bfr = Bry_bfr_.New(); + for (int i = 0; i < len; ++i) { + int step_id = (int)list.Get_at(i); + Xobc_import_step_itm step_itm = data_db.Tbl__import_step().Select_one(step_id); + if (i == 0) { + wiki_domain = Xow_abrv_xo_.To_itm(step_itm.Wiki_abrv()); // ASSUME: 1st step's wiki is same for all steps + host_id = step_itm.Host_id; // ASSUME: 1st step's host_id is same for all steps + } + String src_fil = host_eval.Eval_src_fil(data_db, host_id, wiki_domain, step_itm.Import_name); + Io_size_.To_bfr_new(tmp_size_bfr, step_itm.Import_size_zip, 2); + total_size += step_itm.Import_size_raw; + Xobc_info_url step_url = new Xobc_info_url(src_fil, tmp_size_bfr.To_bry_and_clear()); + step_urls[i] = step_url; + } + + // get wiki data, total_size + host_eval.Eval_dir_name(wiki_domain); + Io_url trg_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(wiki_domain.Domain_str()); + Io_size_.To_bfr_new(tmp_size_bfr, total_size, 2); + byte[] total_size_bry = tmp_size_bfr.To_bry_and_clear(); + + // get torrent + String torrent_fil = null; + String key = data_db.Tbl__task_regy().Select_key_by_id_or_null(task_id); + if (key == null) torrent_fil = "failed to get torrent for " + Int_.To_str(task_id); + else {// convert task_key to name; en.wikipedia.org|2016.06|html + String src_dir = host_eval.Eval_src_dir(data_db, host_id, wiki_domain); + String[] ary = String_.Split(key, "|"); + ary[0] = String_.new_u8(wiki_domain.Abrv_wm()); + torrent_fil = String_.Format("{0}/Xowa_{1}_{2}_{3}.torrent", src_dir, ary[0], ary[1], ary[2]); // EX: http://archive.org/download/Xowa_enwiki_latest/Xowa_enwiktionary_2016-06_core.zip + } + + return new Xobc_info_doc + ( wiki_domain.Domain_bry() + , trg_dir.Raw() + , total_size_bry + , torrent_fil + , step_urls + ); + } + @Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) { + Xopg_tag_mgr head_tags = page_data.Head_tags(); + Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root()); + Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root()); + head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xobc_info.css"))); + } + @Override protected void Handle_invalid(Xoa_app app, Xoa_page page, Xow_special_page special) { + new Xopage_html_data(special.Special__meta().Display_ttl(), Bry_.new_u8("task has been deleted")).Apply(page); + } +} diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_special.java b/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_special.java new file mode 100644 index 000000000..12be9c4ca --- /dev/null +++ b/400_xowa/src/gplx/xowa/addons/bldrs/infos/Xobc_info_special.java @@ -0,0 +1,35 @@ +/* +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 . +*/ +package gplx.xowa.addons.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; +import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.wikis.pages.*; +import gplx.xowa.addons.bldrs.centrals.*; +public class Xobc_info_special implements Xow_special_page { + public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) { + Gfo_qarg_mgr url_args = new Gfo_qarg_mgr().Init(url.Qargs_ary()); + + int task_id = url_args.Read_int_or("task_id", -1); + if (task_id == -1) return; + + new Xobc_info_html(Xobc_task_special.Task_mgr(wiki.App()), task_id).Bld_page_by_mustache(wiki.App(), page, this); + } + + Xobc_info_special(Xow_special_meta special__meta) {this.special__meta = special__meta;} + public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta; + public Xow_special_page Special__clone() {return this;} + public static final Xow_special_page Prototype = new Xobc_info_special(Xow_special_meta.New_xo("XowaDownloadCentralInfo", "Download Central Task Info")); +} diff --git a/400_xowa/src/gplx/xowa/addons/servers/https/Http_long_poll_cmd.java b/400_xowa/src/gplx/xowa/addons/servers/https/Http_long_poll_cmd.java index a8851e51e..a8b989f39 100644 --- a/400_xowa/src/gplx/xowa/addons/servers/https/Http_long_poll_cmd.java +++ b/400_xowa/src/gplx/xowa/addons/servers/https/Http_long_poll_cmd.java @@ -16,34 +16,56 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package gplx.xowa.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*; +import gplx.core.envs.*; public class Http_long_poll_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_itm { private final List_adp msgs = List_adp_.New(); - private long send_time_prv = 0; - public int Sleep_interval = 100; - public int Send_interval = 1000; + private boolean active; public void Init_by_app(Xoa_app app) { app.Gui__cbk_mgr().Reg(Xog_cbk_wkr__http.Instance); } public void Send_msg(String msg) { - msgs.Add(msg); + synchronized (msgs) { + msgs.Add(msg); + } } public String Exec(gplx.langs.jsons.Json_nde data) { + // NOTE: this class is a singleton and only supports one user; need to track multiple requests by having http_server track incoming users + synchronized (msgs) { + if (active) return "polling"; + } + // check if already active; if so, return; while (true) { - if (msgs.Len() == 0) { - gplx.core.threads.Thread_adp_.Sleep(Sleep_interval); + // get msgs in queue + int msgs_len = 0; + synchronized (msgs) { + active = true; + msgs_len = msgs.Len(); } - else { - long send_time_cur = gplx.core.envs.Env_.TickCount(); - if (send_time_cur - send_time_prv > Send_interval) { - send_time_prv = send_time_cur; - break; - } + + // no messages + if (msgs_len == 0) { + gplx.core.threads.Thread_adp_.Sleep(Sleep_interval); + continue; } + + // message found; exit loop; + break; + } + + // return commands + String[] rv = null; + synchronized (msgs) { + rv = msgs.To_str_ary_and_clear(); + active = false; } - return String_.Concat_lines_nl(msgs.To_str_ary_and_clear()); + return String_.Concat_lines_nl(rv); } public byte[] Key() {return BRIDGE_KEY;} private static final byte[] BRIDGE_KEY = Bry_.new_a7("long_poll"); public static final Http_long_poll_cmd Instance = new Http_long_poll_cmd(); Http_long_poll_cmd() {} + + private static final int + Sleep_interval = 100 + ; } diff --git a/400_xowa/src/gplx/xowa/drds/pages/Xod_page_mgr.java b/400_xowa/src/gplx/xowa/drds/pages/Xod_page_mgr.java index 946d40394..6bb90b9d4 100644 --- a/400_xowa/src/gplx/xowa/drds/pages/Xod_page_mgr.java +++ b/400_xowa/src/gplx/xowa/drds/pages/Xod_page_mgr.java @@ -56,6 +56,7 @@ public class Xod_page_mgr { // generate special Xoh_page page = new Xoh_page(); + page.Init(wiki, Xoa_url.new_(wiki.Domain_bry(), ttl.Page_db()), ttl, 1); // NOTE: init page to set url, ttl; DATE:2016-06-23 try {proto.Special__clone().Special__gen(wiki, page, url, ttl);} catch (Exception e) {Gfo_log_.Instance.Warn("failed to generate special page", "url", url.To_str(), "err", Err_.Message_gplx_log(e)); return rv;} diff --git a/400_xowa/src/gplx/xowa/files/Xof_fsdb_itm.java b/400_xowa/src/gplx/xowa/files/Xof_fsdb_itm.java index 8a2c6e1cd..512bedab6 100644 --- a/400_xowa/src/gplx/xowa/files/Xof_fsdb_itm.java +++ b/400_xowa/src/gplx/xowa/files/Xof_fsdb_itm.java @@ -47,15 +47,15 @@ public class Xof_fsdb_itm implements Xof_file_itm { public Io_url Html_orig_url() {return html_orig_url;} private Io_url html_orig_url = Io_url_.Empty; public int Html_gallery_mgr_h() {return html_gallery_mgr_h;} private int html_gallery_mgr_h = Int_.Neg1; public Js_img_wkr Html_img_wkr() {return html_img_wkr;} private Js_img_wkr html_img_wkr; - public boolean File_is_orig() {return file_is_orig;} private boolean file_is_orig; + public boolean File_is_orig() {return file_is_orig;} private boolean file_is_orig; public int File_w() {return file_w;} private int file_w; public long File_size() {return file_size;} private long file_size; - public boolean Dbmeta_is_new() {return false;} - public boolean Orig_exists() {return orig_exists;} public void Orig_exists_y_() {orig_exists = Bool_.Y;} public void Orig_exists_n_() {orig_exists = Bool_.N;} private boolean orig_exists; - public boolean File_exists() {return file_exists;} public void File_exists_y_() {file_exists = Bool_.Y;} public void File_exists_n_() {file_exists = Bool_.N;} public void File_exists_(boolean v) {file_exists = v;} private boolean file_exists; - public boolean File_exists_in_cache() {return file_exists_in_cache;} private boolean file_exists_in_cache; - public boolean File_resized() {return file_resized;} public void File_resized_y_() {file_resized = Bool_.Y;} private boolean file_resized; - public boolean Fsdb_insert() {return fsdb_insert;} public void Fsdb_insert_y_() {fsdb_insert = true;} private boolean fsdb_insert; + public boolean Dbmeta_is_new() {return false;} + public boolean Orig_exists() {return orig_exists;} public void Orig_exists_y_() {orig_exists = Bool_.Y;} public void Orig_exists_n_() {orig_exists = Bool_.N;} private boolean orig_exists; + public boolean File_exists() {return file_exists;} public void File_exists_y_() {file_exists = Bool_.Y;} public void File_exists_n_() {file_exists = Bool_.N;} public void File_exists_(boolean v) {file_exists = v;} private boolean file_exists; + public boolean File_exists_in_cache() {return file_exists_in_cache;} private boolean file_exists_in_cache; + public boolean File_resized() {return file_resized;} public void File_resized_y_() {file_resized = Bool_.Y;} private boolean file_resized; + public boolean Fsdb_insert() {return fsdb_insert;} public void Fsdb_insert_y_() {fsdb_insert = true;} private boolean fsdb_insert; public int Xfer_idx() {return xfer_idx;} private int xfer_idx; public int Xfer_len() {return xfer_len;} private int xfer_len; public void Init_at_lnki(int exec_tid, byte[] wiki_abrv, byte[] lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page, int lnki_upright_patch) { diff --git a/400_xowa/src/gplx/xowa/guis/views/Load_page_wkr.java b/400_xowa/src/gplx/xowa/guis/views/Load_page_wkr.java index bb8739a8e..6b8bc3dbc 100644 --- a/400_xowa/src/gplx/xowa/guis/views/Load_page_wkr.java +++ b/400_xowa/src/gplx/xowa/guis/views/Load_page_wkr.java @@ -33,25 +33,6 @@ public class Load_page_wkr implements Gfo_thread_wkr { // wait_for_popups; free mem check; this.page = wiki.Page_mgr().Load_page(url, ttl, tab); - // DELETE:v3.6.4 -// Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str()); -// Wait_for_popups(); -// Xowe_wiki_.Rls_mem_if_needed(wiki); -// -// // load page meta; wait_for_popups -// this.page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false); -// boolean hdump_exists = page.Revision_data().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred(); -// page.Html_data().Hdump_exists_(hdump_exists); -// Wait_for_popups(); -// -// // load page text -// boolean parse = true; -// if (hdump_exists) { -// wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page); -// parse = Bry_.Len_eq_0(page.Hdump_data().Body()); // NOTE: need to check if actually empty -// } -// if (parse) -// wiki.Parser_mgr().Parse(page, false); // launch thread to show page Gfo_invk_.Invk_by_val(tab.Cmd_sync(), Xog_tab_itm.Invk_show_url_loaded_swt, this); @@ -64,12 +45,6 @@ public class Load_page_wkr implements Gfo_thread_wkr { Running_(false); } } - // DELETE:v3.6.4 -// private static void Wait_for_popups() {// HACK: wait for popups to finish, else thread errors due to popups and loader mutating cached items -// int wait_count = 0; -// while (gplx.xowa.htmls.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100) -// Thread_adp_.Sleep(10); -// } private static final Object thread_lock = new Object(); private static boolean running = false; public static boolean Running() { boolean rv = false; diff --git a/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java b/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java index f7d385834..f38716e65 100644 --- a/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java +++ b/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java @@ -220,62 +220,6 @@ public class Xog_tab_itm implements Gfo_invk { wkr.Wiki().Appe().Thread_mgr_old().Page_load_mgr().Resume(); } } - // DELETE:v3.6.4 -// public void Async() { -// if (page == null) return; // TEST: occurs during Xog_win_mgr_tst -// Xowe_wiki wiki = page.Wikie(); Xoae_app app = wiki.Appe(); Xog_win_itm win_itm = tab_mgr.Win(); Gfo_usr_dlg usr_dlg = win_itm.Usr_dlg(); -// app.Usr_dlg().Log_many("", "", "page.async: url=~{0}", page.Url().To_str()); -// if (page.Url().Anch_str() != null) html_itm.Scroll_page_by_id_gui(page.Url().Anch_str()); -// if (usr_dlg.Canceled()) {usr_dlg.Prog_none("", "", ""); app.Log_wtr().Queue_enabled_(false); return;} -// int xfer_len = 0; -// xfer_len = page.File_queue().Count(); -// String page_ttl_str = String_.new_u8(page.Ttl().Raw()); -// if (xfer_len > 0){ -// usr_dlg.Prog_one("", "", "downloading images: ~{0}", xfer_len); -// try { -// page.File_queue().Exec(wiki, page); -// if (page.Html_data().Xtn_gallery_packed_exists()) // packed_gallery exists; fire js once; PAGE:en.w:National_Sculpture_Museum_(Valladolid); DATE:2014-07-21 -// html_itm.Html_gallery_packed_exec(); -// if ( page.Html_data().Xtn_imap_exists() // imap exists; DATE:2014-08-07 -// && page.Html_data().Head_mgr().Itm__popups().Enabled() -// ) -// html_itm.Html_popups_bind_hover_to_doc(); // rebind all elements to popup -// } -// catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.image: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_full(e));} -// } -// xfer_len = page.File_math().Count(); -// if (xfer_len > 0){ -// try { -// usr_dlg.Prog_one("", "", "generating math: ~{0}", xfer_len); -// for (int i = 0; i < xfer_len; i++) { -// if (usr_dlg.Canceled()) {usr_dlg.Prog_none("", "", ""); app.Log_wtr().Queue_enabled_(false); return;} -// gplx.xowa.xtns.math.Xof_math_itm itm = (gplx.xowa.xtns.math.Xof_math_itm)page.File_math().Get_at(i); -// String queue_msg = usr_dlg.Prog_many("", "", "generating math ~{0} of ~{1}: ~{2}", i + List_adp_.Base1, xfer_len, String_.new_u8(itm.Math())); -// app.File_mgr().Math_mgr().MakePng(itm.Math(), itm.Hash(), itm.Png_url(), queue_msg); -// gplx.gfui.SizeAdp size = app.File_mgr().Img_mgr().Wkr_query_img_size().Exec(itm.Png_url()); -// html_itm.Html_img_update("xowa_math_img_" + itm.Id(), itm.Png_url().To_http_file_str(), size.Width(), size.Height()); -// html_itm.Html_elem_delete("xowa_math_txt_" + itm.Id()); -// } -// page.File_math().Clear(); -// } -// catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.math: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_full(e));} -// } -// if (page.Html_cmd_mgr().Count() > 0) { -// try {page.Html_cmd_mgr().Exec(app, page);} -// catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.cmds: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_full(e));} -// } -// try { -// if (page.Tab_data().Tab() != null) { // needed b/c Preview has page.Tab of null which causes null_ref error in redlinks -// Xopg_redlink_mgr redlinks_wkr = new Xopg_redlink_mgr(page, html_itm); -// Thread_adp_.Start_by_key(gplx.xowa.apps.Xoa_thread_.Key_page_redlink, redlinks_wkr, gplx.xowa.wikis.pages.lnkis.Xopg_redlink_mgr.Invk_run); -// usr_dlg.Prog_none("", "imgs.done", ""); -// } -// } catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.redlinks: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_full(e));} -// try {app.File_mgr().Cache_mgr().Compress_check();} -// catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.cache: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_full(e));} -// app.Usere().User_db_mgr().Cache_mgr().Page_end(app.Wiki_mgr()); -// app.Log_wtr().Queue_enabled_(false); -// } public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { if (ctx.Match(k, Invk_show_url_loaded_swt)) this.Show_url_loaded((Load_page_wkr)m.ReadObj("v")); else if (ctx.Match(k, Invk_show_url_failed_swt)) this.Show_url_failed((Load_page_wkr)m.ReadObj("v")); @@ -291,7 +235,6 @@ class Load_files_wkr implements Gfo_thread_wkr { public boolean Thread__resume() {return true;} public void Thread__exec() { try {Xog_async_wkr.Async(tab);} -// try {tab.Async();} // DELETE:v3.6.4 catch (Exception e) { tab.Tab_mgr().Win().App().Usr_dlg().Warn_many("error while running file wkr; page=~{0} err=~{1}", tab.Page().Url().To_str(), Err_.Message_gplx_full(e)); } diff --git a/400_xowa/src/gplx/xowa/guis/views/Xog_win_itm.java b/400_xowa/src/gplx/xowa/guis/views/Xog_win_itm.java index efba04d23..ce8a47497 100644 --- a/400_xowa/src/gplx/xowa/guis/views/Xog_win_itm.java +++ b/400_xowa/src/gplx/xowa/guis/views/Xog_win_itm.java @@ -68,7 +68,6 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm { else if (ctx.Match(k, Gfui_html.Evt_win_resized)) Refresh_win_size(); else if (ctx.Match(k, Invk_page_refresh)) Page__refresh(); else if (ctx.Match(k, Invk_page_async_exec)) Xog_async_wkr.Async(((Xog_tab_itm)m.ReadObj("v"))); - // else if (ctx.Match(k, Invk_page_async_exec)) ((Xog_tab_itm)m.ReadObj("v")).Async(); // DELETE:v3.6.4 else if (ctx.Match(k, Invk_page_view_read)) Page__mode_(Xopg_page_.Tid_read); else if (ctx.Match(k, Invk_page_view_edit)) Page__mode_(Xopg_page_.Tid_edit); else if (ctx.Match(k, Invk_page_view_html)) Page__mode_(Xopg_page_.Tid_html); diff --git a/400_xowa/src/gplx/xowa/htmls/Xoh_img_mgr.java b/400_xowa/src/gplx/xowa/htmls/Xoh_img_mgr.java index 896bcd23a..74c02603f 100644 --- a/400_xowa/src/gplx/xowa/htmls/Xoh_img_mgr.java +++ b/400_xowa/src/gplx/xowa/htmls/Xoh_img_mgr.java @@ -26,9 +26,11 @@ public class Xoh_img_mgr { } public int Len() {return list.Count();} public Xof_fsdb_itm Get_at(int i) {return (Xof_fsdb_itm)list.Get_at(i);} - public Xof_fsdb_itm Make_img() { + public Xof_fsdb_itm Make_img(boolean img_is_gallery) { Xof_fsdb_itm itm = new Xof_fsdb_itm(); - itm.Init_at_hdoc(++uid_nxt, Xof_html_elem.Tid_img); + itm.Init_at_hdoc(++uid_nxt, img_is_gallery ? Xof_html_elem.Tid_gallery : Xof_html_elem.Tid_img); + if (img_is_gallery) + itm.Html_gallery_mgr_h_(gplx.xowa.xtns.gallery.Gallery_xnde.Default); // TODO:set to ; PAGE:en.w:National_Gallery_of_Art; DATE:2016-06-25 list.Add(itm); return itm; } diff --git a/400_xowa/src/gplx/xowa/htmls/Xoh_page.java b/400_xowa/src/gplx/xowa/htmls/Xoh_page.java index 2249e2436..2b48d42e3 100644 --- a/400_xowa/src/gplx/xowa/htmls/Xoh_page.java +++ b/400_xowa/src/gplx/xowa/htmls/Xoh_page.java @@ -25,7 +25,7 @@ public class Xoh_page implements Xoa_page { public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl; // props - public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true; + public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true; public int Page_id() {return page_id;} private int page_id; public byte[] Body() {return body;} public void Body_(byte[] v) {this.body = v;} private byte[] body; public int Body_zip_tid() {return body_zip_tid;} private int body_zip_tid; @@ -40,12 +40,14 @@ public class Xoh_page implements Xoa_page { public Ordered_hash Gallery_itms() {return gallery_itms;} private Ordered_hash gallery_itms = Ordered_hash_.New(); public Xopg_module_mgr Head_mgr() {return head_mgr;} private Xopg_module_mgr head_mgr = new Xopg_module_mgr(); public void Xtn_gallery_packed_exists_y_() {} + public boolean Xtn__timeline_exists() {return xtn__timeline_exists;} private boolean xtn__timeline_exists; public void Xtn__timeline_exists_y_() {xtn__timeline_exists = true;} + public boolean Xtn__gallery_exists() {return xtn__gallery_exists;} private boolean xtn__gallery_exists; public void Xtn__gallery_exists_y_() {xtn__gallery_exists = true;} public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data(); public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data(); public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;} // util - public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list; + public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list = new Xopg_lnki_list(); public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr(); public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page; public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty; // drd:web_browser @@ -53,7 +55,7 @@ public class Xoh_page implements Xoa_page { public void Init(Xow_wiki wiki, Xoa_url page_url, Xoa_ttl page_ttl, int page_id) { this.wiki = wiki; this.page_url = page_url; this.page_ttl = page_ttl; this.page_id = page_id; this.Clear(); - this.redlink_list = new Xopg_lnki_list(page_ttl.Ns().Id_is_module()); + redlink_list.Disabled_(page_ttl.Ns().Id_is_module()); // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]] } public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, int zip_tid, int hzip_tid, byte[] body) { head_mgr.Flag_(head_flag); @@ -78,5 +80,6 @@ public class Xoh_page implements Xoa_page { img_itms = Xohd_img_itm__base.Ary_empty; head_mgr.Clear(); gallery_itms.Clear(); redlink_uids.Clear(); commons_mgr.Clear(); section_mgr.Clear(); img_mgr.Clear(); + redlink_list.Clear(); } } diff --git a/400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_mgr.java b/400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_mgr.java index d00c9ccc7..86286a060 100644 --- a/400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_mgr.java +++ b/400_xowa/src/gplx/xowa/htmls/bridges/Bridge_cmd_mgr.java @@ -32,7 +32,7 @@ public class Bridge_cmd_mgr { catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "invalid json", "json", jdoc_bry);} Json_nde msg = jdoc.Root_nde(); byte[] key_bry = msg.Get_bry(Key_cmd); - Bridge_cmd_itm cmd = (Bridge_cmd_itm)cmd_hash.Get_by_bry(key_bry); if (cmd == null) throw Err_.new_("bridge.cmds", "unknown cmd", "cmd", cmd); + Bridge_cmd_itm cmd = (Bridge_cmd_itm)cmd_hash.Get_by_bry(key_bry); if (cmd == null) throw Err_.new_("bridge.cmds", "unknown cmd", "key", key_bry); try {return cmd.Exec(msg.Get(Key_data));} catch (Exception e) { Xoa_app_.Usr_dlg().Warn_many("", "", "exec json failed: ~{0}", "json", jdoc_bry); diff --git a/400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__load.java b/400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__load.java index 24d5fa27d..0b1b8ecd5 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__load.java +++ b/400_xowa/src/gplx/xowa/htmls/core/Xow_hdump_mgr__load.java @@ -83,7 +83,8 @@ public class Xow_hdump_mgr__load { wpg_head.Itm__popups().Bind_hover_area_ (hpg_head.Imap_exists()); wpg_head.Itm__gallery().Enabled_ (hpg_head.Gallery_packed_exists()); wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists()); - wpg_head.Itm__timeline().Enabled_ (true); + wpg_head.Itm__timeline().Enabled_ (hpg.Xtn__timeline_exists()); + wpg_head.Itm__gallery_styles().Enabled_ (hpg.Xtn__gallery_exists()); // transfer images from Xoh_page to Xoae_page Xoh_img_mgr src_imgs = hpg.Img_mgr(); diff --git a/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr.java b/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr.java index edfaf6edd..8ddad6f70 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr.java @@ -295,7 +295,7 @@ public class Xoh_html_wtr { break; } case Xop_xnde_tag_.Tid__timeline: { - bfr.Add_str_a7("
");
+				bfr.Add(gplx.xowa.htmls.core.wkrs.addons.timelines.Xoh_timeline_data.Hook_bry);
 				Xox_mgr_base.Xtn_write_escape(app, bfr, src, xnde.Tag_open_end(), xnde.Tag_close_bgn());	// NOTE: do not embed  tag inside pre, else timeline will render in black; EX:
a
will fail; DATE:2014-05-22 bfr.Add_str_a7("
"); break; diff --git a/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java b/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java index c1b879199..fc7ee0c7c 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java +++ b/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java @@ -18,7 +18,7 @@ along with this program. If not, see . package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import org.junit.*; public class Xoh_html_wtr_tst { - private final Xop_fxt fxt = new Xop_fxt(); + private final Xop_fxt fxt = new Xop_fxt(); @After public void term() {fxt.Init_para_n_(); fxt.Reset();} @Test public void Hr_basic() {fxt.Test_parse_page_wiki_str("----" , "
");} @Test public void Hr_extended() {fxt.Test_parse_page_wiki_str("--------" , "
");} diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict_.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict_.java index e1efd442c..405cdb614 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict_.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict_.java @@ -18,10 +18,12 @@ along with this program. If not, see . 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.btries.*; public class Xoh_hzip_dict_ { - public static final byte Escape = Byte_.By_int(27); // SERIALIZED: 27=escape byte - public static final byte[] Escape_bry = Bry_.New_by_ints(27); // SERIALIZED + public static final byte Escape = Byte_.By_int(27); // SERIALIZED: 27=escape byte + public static final byte[] Escape_bry = Bry_.New_by_ints(27); // SERIALIZED public static final int - Tid__root = 0 + Tid__timeline = -10 + , Tid__gallery = -11 + , Tid__root = 0 , Tid__escape = 1 , Tid__xnde = 2 , Tid__lnke = 3 @@ -32,8 +34,10 @@ public class Xoh_hzip_dict_ { , Tid__gly = 8 , Tid__img_bare = 9 ; - public static final String - Key__escape = "escape" + public static final String + Key__timeline = "timeline" + , Key__gallery = "gallery" + , Key__escape = "escape" , Key__hdr = "hdr" , Key__lnke = "lnke" , Key__lnki = "lnki" diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_mgr.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_mgr.java index d5a991ba3..570c9b8d4 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_mgr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_mgr.java @@ -20,26 +20,25 @@ import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.btries. import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.wikis.ttls.*; public class Xoh_hzip_mgr implements Xoh_hzip_wkr { - private final Xoh_hdoc_wkr hdoc_wkr = new Xoh_hdoc_wkr__hzip(); - private final Xoh_hdoc_parser hdoc_parser; - private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape); + private final Xoh_hdoc_wkr hdoc_wkr = new Xoh_hdoc_wkr__hzip(); + private final Xoh_hdoc_parser hdoc_parser; + private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape); public Xoh_hzip_mgr() {this.hdoc_parser = new Xoh_hdoc_parser(hdoc_wkr);} public int Tid() {return Xoh_hzip_dict_.Tid__lnke;} public String Key() {return "root";} public byte[] Hook() {return hook;} private byte[] hook; - public Xoh_hdoc_ctx Hctx() {return hctx;} private final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx(); + public Xoh_hdoc_ctx Hctx() {return hctx;} private final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx(); public void Init_by_app(Xoa_app app) {hctx.Init_by_app(app);} public byte[] Encode_as_bry(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {Encode(bfr, wiki, hpg, src); return bfr.To_bry_and_clear();} 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) {throw Err_.new_unimplemented();} public void Encode(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) { - hctx.Init_by_page(wiki, hpg.Url_bry_safe()); + hctx.Init_by_page(wiki, hpg); hdoc_parser.Parse(bfr, hpg, hctx, src); } public void Decode(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) { - byte[] page_url = hpg.Url_bry_safe(); int src_len = src.length; - hctx.Init_by_page(wiki, page_url); - rdr.Init_by_page(page_url, src, src_len); - Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src_len, null); + hctx.Init_by_page(wiki, hpg); + rdr.Init_by_page(hpg.Url_bry_safe(), src, src.length); + Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src.length, null); } 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 pos = src_bgn, txt_bgn = -1; diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_wkr.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_wkr.java index b6e05e879..47a9d58c2 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_wkr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_wkr.java @@ -19,9 +19,9 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.htmls.core.wkrs.*; public interface Xoh_hzip_wkr extends gplx.core.threads.poolables.Gfo_poolable_itm { - int Tid(); - String Key(); - byte[] Hook(); + int Tid(); + String Key(); + byte[] Hook(); 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); 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); } diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__data.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__data.java index d4a33712d..e9b3eb201 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__data.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__data.java @@ -19,15 +19,17 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp import gplx.core.btries.*; import gplx.core.threads.poolables.*; import gplx.xowa.htmls.core.wkrs.escapes.*; import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*; -import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*; +import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; +import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*; public class Xoh_pool_mgr__data { - private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare;//, pool__gly; + private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery; public Xoh_pool_mgr__data() { pool__hdr = New_pool(new Xoh_hdr_data()); pool__lnke = New_pool(new Xoh_lnke_data()); pool__img = New_pool(new Xoh_img_data()); pool__img_bare = New_pool(new Xoh_img_bare_data()); -// pool__gly = New_pool(new Xoh_gly_grp_data()); + pool__timeline = New_pool(new Xoh_timeline_data()); + pool__gallery = New_pool(new Xoh_gallery_data()); } public Xoh_data_itm Get_by_tid(int tid) { Gfo_poolable_mgr pool = null; @@ -36,7 +38,8 @@ public class Xoh_pool_mgr__data { case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break; case Xoh_hzip_dict_.Tid__img: pool = pool__img; break; case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break; -// case Xoh_hzip_dict_.Tid__gly: pool = pool__gly; break; + case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break; + case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break; default: return null; } return (Xoh_data_itm)pool.Get_fast(); diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__hzip.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__hzip.java index b9cfd5bce..a1f54afa6 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__hzip.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__hzip.java @@ -20,9 +20,10 @@ import gplx.core.btries.*; import gplx.core.threads.poolables.*; import gplx.xowa.htmls.core.wkrs.escapes.*; import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*; import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*; +import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*; public class Xoh_pool_mgr__hzip { - private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs(); - private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare; + private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs(); + private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline; public Xoh_escape_hzip Mw__escape() {return (Xoh_escape_hzip) mkr__escape.Get_fast();} public Xoh_xnde_hzip Mw__xnde() {return (Xoh_xnde_hzip) mkr__xnde.Get_fast();} public Xoh_hdr_hzip Mw__hdr() {return (Xoh_hdr_hzip) mkr__hdr.Get_fast();} @@ -32,6 +33,8 @@ public class Xoh_pool_mgr__hzip { public Xoh_img_bare_hzip Mw__img_bare() {return (Xoh_img_bare_hzip) mkr__img_bare.Get_fast();} public Xoh_thm_hzip Mw__thm() {return (Xoh_thm_hzip) mkr__thm.Get_fast();} public Xoh_gly_hzip Mw__gly() {return (Xoh_gly_hzip) mkr__gly.Get_fast();} + public Xoh_gallery_hzip Mw__gallery() {return (Xoh_gallery_hzip) mkr__gallery.Get_fast();} + public Xoh_timeline_hzip Mw__timeline() {return (Xoh_timeline_hzip) mkr__timeline.Get_fast();} public void Init() { this.Reg_all(false, Hook__core, Hook__html, Hook__mw); } @@ -50,6 +53,8 @@ public class Xoh_pool_mgr__hzip { mkr__thm = Reg(New_hook_len2(mode_is_b256, hook__mw , 5) , new Xoh_thm_hzip()); mkr__gly = Reg(New_hook_len2(mode_is_b256, hook__mw , 6) , new Xoh_gly_hzip()); mkr__img_bare = Reg(New_hook_len2(mode_is_b256, hook__mw , 7) , new Xoh_img_bare_hzip()); + mkr__gallery = Reg(Xoh_gallery_data.Hook_bry , new Xoh_gallery_hzip()); + mkr__timeline = Reg(Xoh_timeline_data.Hook_bry , new Xoh_timeline_hzip()); } private Gfo_poolable_mgr Reg(byte[] hook, Gfo_poolable_itm proto) { Gfo_poolable_mgr rv = Gfo_poolable_mgr_.New(1, 32, proto, Object_.Ary(hook)); @@ -63,5 +68,5 @@ public class Xoh_pool_mgr__hzip { , Hook__html = 2 , Hook__mw = 27 ; - public static final byte[] Hooks_ary = new byte[] {Hook__core, Hook__html, Hook__mw}; + public static final byte[] Hooks_ary = new byte[] {Hook__core, Hook__html, Hook__mw}; } diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__wtr.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__wtr.java index b2df183c4..6d061ae4b 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__wtr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_pool_mgr__wtr.java @@ -19,14 +19,17 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.htmls.core.wkrs.escapes.*; import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*; -import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*; +import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; +import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*; public class Xoh_pool_mgr__wtr { - private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare; + private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery; public Xoh_pool_mgr__wtr() { pool__hdr = New_pool(new Xoh_hdr_wtr()); pool__lnke = New_pool(new Xoh_lnke_wtr()); pool__img = New_pool(new Xoh_img_wtr()); pool__img_bare = New_pool(new Xoh_img_bare_wtr()); + pool__timeline = New_pool(new Xoh_timeline_wtr()); + pool__gallery = New_pool(new Xoh_gallery_wtr()); } public Xoh_wtr_itm Get_by_tid(int tid) { Gfo_poolable_mgr pool = null; @@ -35,6 +38,8 @@ public class Xoh_pool_mgr__wtr { case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break; case Xoh_hzip_dict_.Tid__img: pool = pool__img; break; case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break; + case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break; + case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break; default: return null; } return (Xoh_wtr_itm)pool.Get_fast(); diff --git a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_stat_itm.java b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_stat_itm.java index 554c4cea1..3c7806789 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_stat_itm.java +++ b/400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_stat_itm.java @@ -20,7 +20,7 @@ import gplx.xowa.htmls.core.wkrs.lnkes.*; public class Xoh_stat_itm { public void Clear() { a_rhs = lnki_text_n = lnki_text_y = lnke__free = lnke__auto = lnke__text = 0; - hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = 0; + hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = timeline = gallery = 0; img_full = 0; space = 0; Bry_.Clear(escape_bry); @@ -32,6 +32,8 @@ public class Xoh_stat_itm { public int Lnke__auto() {return lnke__auto;} public void Lnke__auto__add() {++lnke__auto;} private int lnke__auto; public int Lnke__text() {return lnke__text;} public void Lnke__text__add() {++lnke__text;} private int lnke__text; public int Img_full() {return img_full;} public void Img_full_add() {++img_full;} private int img_full; + public int Timeline() {return timeline;} public void Timeline_add() {++timeline;} private int timeline; + public int Gallery() {return gallery;} public void Gallery_add() {++gallery;} private int gallery; public int Hdr_1() {return hdr_1;} private int hdr_1; public int Hdr_2() {return hdr_2;} private int hdr_2; public int Hdr_3() {return hdr_3;} private int hdr_3; @@ -39,7 +41,7 @@ public class Xoh_stat_itm { public int Hdr_5() {return hdr_5;} private int hdr_5; public int Hdr_6() {return hdr_6;} private int hdr_6; public int Space() {return space;} public void Space_add(int v) {space += v;} private int space; - public byte[] Escape_bry() {return escape_bry;} public void Escape_add(byte v) {escape_bry[v] += 1;} private final byte[] escape_bry = new byte[256]; + public byte[] Escape_bry() {return escape_bry;} public void Escape_add(byte v) {escape_bry[v] += 1;} private final byte[] escape_bry = new byte[256]; public void Hdr_add(int hdr_num) { switch (hdr_num) { case 1: ++hdr_1; break; diff --git a/400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_mgr.java b/400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_mgr.java index f48435c73..638cd59d4 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_mgr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/makes/Xoh_make_mgr.java @@ -39,7 +39,7 @@ public class Xoh_make_mgr { this.wiki_domain = wiki_domain; } public byte[] Parse(byte[] src, Xoh_page hpg, Xow_wiki wiki) { - hctx.Init_by_page(wiki, hpg.Url_bry_safe()); + hctx.Init_by_page(wiki, hpg); hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n make_parser.Parse(bfr, hpg, hctx, src); hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length); diff --git a/400_xowa/src/gplx/xowa/htmls/core/makes/tests/Xoh_page_chkr.java b/400_xowa/src/gplx/xowa/htmls/core/makes/tests/Xoh_page_chkr.java index 67df1d7ee..58bd24df7 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/makes/tests/Xoh_page_chkr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/makes/tests/Xoh_page_chkr.java @@ -31,7 +31,7 @@ public class Xoh_page_chkr { return this; } public Xoh_page_chkr Imgs__add(String wiki_abrv, String lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page) { - Xof_fsdb_itm fsdb_itm = expd_img_mgr.Make_img(); + Xof_fsdb_itm fsdb_itm = expd_img_mgr.Make_img(false); fsdb_itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, Bry_.new_u8(wiki_abrv), Bry_.new_u8(lnki_ttl), lnki_type, lnki_upright, lnki_w, lnki_h, lnki_time, lnki_page, Xof_patch_upright_tid_.Tid_all); return this; } diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hdoc_ctx.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hdoc_ctx.java index 447977b99..5d47b9af0 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hdoc_ctx.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hdoc_ctx.java @@ -33,6 +33,7 @@ public class Xoh_hdoc_ctx { public boolean Xwiki_mgr__missing(byte[] domain){return app.Xwiki_mgr__missing(domain);} 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 Xoa_page Page() {return page;} private Xoa_page page; 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(); public Xoh_pool_mgr__data Pool_mgr__data() {return pool_mgr__data;} private final Xoh_pool_mgr__data pool_mgr__data = new Xoh_pool_mgr__data(); @@ -53,13 +54,14 @@ public class Xoh_hdoc_ctx { 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) { + public void Init_by_page(Xow_wiki wiki, Xoa_page page) { if (fsys__root == null) Init_by_app(wiki.App()); // LAZY INIT this.wiki__url_parser = wiki.Utl__url_parser(); this.wiki__ttl_parser = wiki; this.wiki__domain_bry = wiki.Domain_bry(); this.fsys__file__wiki = Bry_.Add(fsys__file, wiki__domain_bry, Byte_ascii.Slash_bry); - this.page__url = page_url; + this.page = page; + this.page__url = page.Url_bry_safe(); this.Clear(); } private void Clear() { diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hzip_fxt.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hzip_fxt.java index 2cdc0d738..9abbd44c2 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hzip_fxt.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_hzip_fxt.java @@ -33,6 +33,7 @@ public class Xoh_hzip_fxt { hpg.Init(wiki, Xoa_url.blank(), parser_fxt.Wiki().Ttl_parse(Xoa_page_.Main_page_bry), 1); } public Xow_wiki Wiki() {return wiki;} + public Xoa_page Page() {return hpg;} public Xoh_hzip_fxt Init_mode_is_b256_(boolean v) {bfr.Mode_is_b256_(v); mode_is_b256 = v; return this;} public Xoh_hzip_fxt Init_mode_diff_y_() {hzip_mgr.Hctx().Mode_is_diff_(Bool_.Y); return this;} public void Clear() {hpg.Clear();} @@ -85,7 +86,7 @@ public class Xoh_hzip_fxt { Gfo_usr_dlg_.Test__show__term(); Tfds.Eq_str_lines(hzip, bfr.To_str_and_clear()); } - private void Test__decode__raw(String hzip, String html) { + public void Test__decode__raw(String hzip, String html) { Gfo_usr_dlg_.Test__show__init(); hpg.Section_mgr().Clear(); hzip_mgr.Decode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(hzip)); diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_itm_parser_fxt.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_itm_parser_fxt.java index 32e0aa01b..cb8e55451 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_itm_parser_fxt.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/Xoh_itm_parser_fxt.java @@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gpl import gplx.core.brys.*; import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; public abstract class Xoh_itm_parser_fxt { - private final Xoae_app app; - private final Xowe_wiki wiki; - private final Bry_err_wkr err_wkr = new Bry_err_wkr(); + private final Xoae_app app; + private final Xowe_wiki wiki; + private final Bry_err_wkr err_wkr = new Bry_err_wkr(); protected byte[] src; protected int src_len; - protected final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx(); + protected final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx(); public Xoh_itm_parser_fxt() { this.app = Xoa_app_fxt.Make__app__edit(); this.wiki = Xoa_app_fxt.Make__wiki__edit(app); @@ -40,7 +40,8 @@ public abstract class Xoh_itm_parser_fxt { } public void Exec_parse(String src_str) { this.src = Bry_.new_u8(src_str); this.src_len = src.length; - hctx.Init_by_page(wiki, Xoa_page_.Main_page_bry); + Xoh_page hpg = new Xoh_page(); // NOTE: no need to pass url and ttl now + hctx.Init_by_page(wiki, hpg); err_wkr.Init_by_page(Xoa_page_.Main_page_str, src); Exec_parse_hook(err_wkr, hctx, 0, src_len); } diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_data.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_data.java new file mode 100644 index 000000000..ff40b2413 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_data.java @@ -0,0 +1,43 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012 gnosygnu@gmail.com + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +package gplx.xowa.htmls.core.wkrs.addons.gallerys; 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.addons.*; +import gplx.core.threads.poolables.*; +import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; +import gplx.xowa.htmls.core.hzips.*; +public class Xoh_gallery_data implements Xoh_data_itm {// NOTE: some galleries fail hzip; use Hook_bry to catch them; PAGE:en.d:a; DATE:2016-06-24 + public int Tid() {return Xoh_hzip_dict_.Tid__gallery;} + public int Src_bgn() {return src_bgn;} private int src_bgn; + public int Src_end() {return src_end;} private int src_end; + public void Clear() { + this.src_bgn = this.src_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 gallery_lhs, Gfh_tag unused) { + this.Clear(); + this.src_bgn = gallery_lhs.Src_bgn(); + this.src_end = gallery_lhs.Src_end(); + return true; + } + public void Init_by_decode(int src_bgn, int src_end) { + this.src_bgn = src_bgn; + this.src_end = src_end; + } + public static final byte[] Hook_bry = Bry_.new_a7(" class=\"gallery mw-gallery"); + + 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_gallery_data rv = new Xoh_gallery_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;} +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_hzip.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_hzip.java new file mode 100644 index 000000000..f4b627836 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_hzip.java @@ -0,0 +1,50 @@ +/* +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 . +*/ +package gplx.xowa.htmls.core.wkrs.addons.gallerys; 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.addons.*; +import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*; +import gplx.xowa.htmls.core.hzips.*; +public class Xoh_gallery_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm { + public int Tid() {return Xoh_hzip_dict_.Tid__gallery;} + public String Key() {return Xoh_hzip_dict_.Key__gallery;} + 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_gallery_data data = (Xoh_gallery_data)data_obj; + + bfr.Add_mid(src, data.Src_bgn(), data.Src_end()); + + hctx.Hzip__stat().Gallery_add(); + return this; + } + public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) { + int gallery_bgn = src_bgn; + int gallery_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end); + if (gallery_end == -1) { + Gfo_log_.Instance.Warn("hzip.gallery.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn); + gallery_end = gallery_bgn; + } + else + ++gallery_end; + + Xoh_gallery_data data = (Xoh_gallery_data)data_itm; + data.Init_by_decode(gallery_bgn, gallery_end); + rdr.Move_to(gallery_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_gallery_hzip rv = new Xoh_gallery_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;} +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_hzip_tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_hzip_tst.java new file mode 100644 index 000000000..6f3bc5999 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_hzip_tst.java @@ -0,0 +1,29 @@ +/* +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 . +*/ +package gplx.xowa.htmls.core.wkrs.addons.gallerys; 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.addons.*; +import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*; +public class Xoh_gallery_hzip_tst { + private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_(); + @Test public void Basic() { + fxt.Test__decode + ( "
    " + , "
      " + ); + Gftest.Eq__bool_y(fxt.Page().Xtn__gallery_exists()); + } +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_wtr.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_wtr.java new file mode 100644 index 000000000..b515a0156 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/gallerys/Xoh_gallery_wtr.java @@ -0,0 +1,42 @@ +/* +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 . +*/ +package gplx.xowa.htmls.core.wkrs.addons.gallerys; 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.addons.*; +import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*; +import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; +import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*; +public class Xoh_gallery_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm { + private Xoh_page hpg; + private byte[] src; private int src_bgn, src_end; + public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_gallery_data data) { + Init_by_decode(hpg, hctx, src, data); + this.Bfr_arg__add(bfr); + } + public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) { + this.hpg = hpg; this.src = src; + Xoh_gallery_data data = (Xoh_gallery_data)data_itm; + this.src_bgn = data.Src_bgn(); + this.src_end = data.Src_end(); + return true; + } + public void Bfr_arg__add(Bry_bfr bfr) { + hpg.Xtn__gallery_exists_y_(); + bfr.Add_mid(src, src_bgn, src_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_gallery_wtr rv = new Xoh_gallery_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;} +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_data.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_data.java new file mode 100644 index 000000000..245efea5f --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_data.java @@ -0,0 +1,43 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012 gnosygnu@gmail.com + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +package gplx.xowa.htmls.core.wkrs.addons.timelines; 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.addons.*; +import gplx.core.threads.poolables.*; +import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; +import gplx.xowa.htmls.core.hzips.*; +public class Xoh_timeline_data implements Xoh_data_itm { + public int Tid() {return Xoh_hzip_dict_.Tid__timeline;} + public int Src_bgn() {return src_bgn;} private int src_bgn; + public int Src_end() {return src_end;} private int src_end; + public void Clear() { + this.src_bgn = this.src_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 timeline_lhs, Gfh_tag unused) { + this.Clear(); + this.src_bgn = timeline_lhs.Src_bgn(); + this.src_end = timeline_lhs.Src_end(); + return true; + } + public void Init_by_decode(int src_bgn, int src_end) { + this.src_bgn = src_bgn; + this.src_end = src_end; + } + public static final byte[] Hook_bry = Bry_.new_a7("
      ");
      +
      +	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_timeline_data rv = new Xoh_timeline_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
      +}
      diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_hzip.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_hzip.java
      new file mode 100644
      index 000000000..e97dbaa5a
      --- /dev/null
      +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_hzip.java
      @@ -0,0 +1,50 @@
      +/*
      +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 .
      +*/
      +package gplx.xowa.htmls.core.wkrs.addons.timelines; 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.addons.*;
      +import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
      +import gplx.xowa.htmls.core.hzips.*;
      +public class Xoh_timeline_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
      +	public int Tid()		{return Xoh_hzip_dict_.Tid__timeline;}
      +	public String Key()		{return Xoh_hzip_dict_.Key__timeline;}
      +	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_timeline_data data = (Xoh_timeline_data)data_obj;
      +
      +		// just add the entire thing; not worth trying to compress "
      "
      +		bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
      +
      +		hctx.Hzip__stat().Timeline_add();
      +		return this;
      +	}
      +	public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
      +		int timeline_bgn = src_bgn;
      +		int timeline_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end);
      +		if (timeline_end == -1) {
      +			Gfo_log_.Instance.Warn("hzip.timeline.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn);
      +			timeline_end = timeline_bgn;
      +		}
      +		else
      +			++timeline_end;
      +
      +		Xoh_timeline_data data = (Xoh_timeline_data)data_itm;
      +		data.Init_by_decode(timeline_bgn, timeline_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_timeline_hzip rv = new Xoh_timeline_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
      +}
      diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_hzip_tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_hzip_tst.java
      new file mode 100644
      index 000000000..ae7e6cc47
      --- /dev/null
      +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_hzip_tst.java
      @@ -0,0 +1,26 @@
      +/*
      +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 .
      +*/
      +package gplx.xowa.htmls.core.wkrs.addons.timelines; 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.addons.*;
      +import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
      +public class Xoh_timeline_hzip_tst {
      +	private final    Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
      +	@Test   public void Basic() {				// EX: code
      +		fxt.Test__decode__raw("
      abc
      ", "
      abc
      "); + Gftest.Eq__bool_y(fxt.Page().Xtn__timeline_exists()); + } +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_wtr.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_wtr.java new file mode 100644 index 000000000..03819a467 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/addons/timelines/Xoh_timeline_wtr.java @@ -0,0 +1,43 @@ +/* +XOWA: the XOWA Offline Wiki Application +Copyright (C) 2012 gnosygnu@gmail.com + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +package gplx.xowa.htmls.core.wkrs.addons.timelines; 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.addons.*; +import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*; +import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; +import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*; +public class Xoh_timeline_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm { + private Xoh_page hpg; + private byte[] src; private int src_bgn, src_end; + public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_timeline_data data) { + Init_by_decode(hpg, hctx, src, data); + this.Bfr_arg__add(bfr); + } + public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) { + this.hpg = hpg; + this.src = src; + Xoh_timeline_data data = (Xoh_timeline_data)data_itm; + this.src_bgn = data.Src_bgn(); + this.src_end = data.Src_end(); + return true; + } + public void Bfr_arg__add(Bry_bfr bfr) { + hpg.Xtn__timeline_exists_y_(); + bfr.Add_mid(src, src_bgn, src_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_timeline_wtr rv = new Xoh_timeline_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;} +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/bfr_args/Bfr_arg__hatr_id.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/bfr_args/Bfr_arg__hatr_id.java index cae330e5a..1cfcebfb7 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/bfr_args/Bfr_arg__hatr_id.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/bfr_args/Bfr_arg__hatr_id.java @@ -18,8 +18,8 @@ along with this program. If not, see . package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; 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; + private final byte[] atr_bgn; + private final byte[] bry; private int num; 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;} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_data.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_data.java index 7f11ec191..c7435e6e5 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_data.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_data.java @@ -20,7 +20,7 @@ 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 { // FUTURE:add gallerycaption 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; @@ -54,6 +54,11 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { while (true) { li_head = tag_rdr.Tag__peek_fwd_head(); if (li_head.Name_id() != Gfh_tag_.Id__li) break; // no more
    • ; break; + // FUTURE: galleries with gallerycaption will cause gallery to write raw; instate code below, but would need to then serialize "gallerycaption"; PAGE:en.d:A DATE:2016-06-24 + // if (li_head.Atrs__cls_has(Atr__cls__gallerycaption)) {// skip
    • A
    • + // li_head = tag_rdr.Tag__move_fwd_head(); + // li_head = tag_rdr.Tag__peek_fwd_head(); + // } if (!li_head.Atrs__cls_has(Atr__cls__gallerybox)) return false; tag_rdr.Pos_(li_head.Src_end()); Xoh_gly_itm_data itm_parser = new Xoh_gly_itm_data(); @@ -131,6 +136,7 @@ public class Xoh_gly_grp_data implements Gfh_class_parser_wkr, Gfh_style_wkr { } public static final byte[] Atr__cls__gallery = Bry_.new_a7("gallery"); private static final byte[] Atr__cls__mw_gallery = Bry_.new_a7("mw-gallery-"), Atr__cls__gallerybox = Bry_.new_a7("gallerybox") + // , Atr__cls__gallerycaption = Bry_.new_a7("gallerycaption") , Style__max_width = Bry_.new_a7("max-width"), Style___width = Bry_.new_a7("_width") ; } diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_wtr.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_wtr.java index d0f050fa1..46f952348 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_wtr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_grp_wtr.java @@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; impor 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_id("xogly_li_"); - private final Bfr_arg__hatr_gly_style ul_style = new Bfr_arg__hatr_gly_style(Gfh_atr_.Bry__style); + private final Bfr_arg_clearable[] arg_ary; + 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(); + 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}; } @@ -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:
        should be on same line if 0 items itm_list_wtr.Init(ary); - ul_style.Set_args(ul_style_max_w, ul_style_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) @@ -50,7 +50,7 @@ class Xoh_gly_grp_wtr implements Bfr_arg { public void Bfr_arg__add(Bry_bfr bfr) { fmtr.Bld_bfr_many(bfr, ul_id, ul_cls, xtra_cls, ul_style, xtra_atr_bry, itm_list_wtr, ul_nl); } - private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last + private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last ( "~{itms}~{ul_nl}
      " ), "id", "cls", "xtra_cls", "style", "xtra_atr", "itms", "ul_nl"); } @@ -58,10 +58,12 @@ class Xoh_gly_itm_list_wtr implements Bfr_arg { private Xoh_gly_itm_wtr[] ary; private int ary_len; public void Init(Xoh_gly_itm_wtr[] ary) { this.ary = ary; this.ary_len = ary.length; + } + public void Bfr_arg__clear() { for (int i = 0; i < ary_len; ++i) ary[i].Clear(); + ary = null; } - public void Bfr_arg__clear() {ary = null;} public boolean Bfr_arg__missing() {return ary == null;} public void Bfr_arg__add(Bry_bfr bfr) { for (int i = 0; i < ary_len; ++i) { @@ -71,7 +73,7 @@ class Xoh_gly_itm_list_wtr implements Bfr_arg { } } class Bfr_arg__hatr_gly_style implements Bfr_arg { - private final byte[] atr_bgn; + private final byte[] atr_bgn; private int max_w, w; private byte[] xtra_cls; public Bfr_arg__hatr_gly_style(byte[] key) { @@ -101,7 +103,7 @@ class Bfr_arg__hatr_gly_style implements Bfr_arg { } bfr.Add_byte_quote(); } - private static final byte[] + private static final byte[] Style__frag_1 = Bry_.new_a7("max-width:") , Style__frag_2 = Bry_.new_a7("_width:") , Style__frag_3 = Bry_.new_a7("px;") diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip.java index 1b8ea7dd7..20dff2641 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip.java @@ -84,13 +84,15 @@ public class Xoh_gly_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm { Xoh_data_itm img_data = hctx.Pool_mgr__data().Get_by_tid(Xoh_hzip_dict_.Tid__img); Xoh_hzip_wkr img_hzip = hctx.Pool_mgr__hzip().Mw__img(); img_hzip.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, src_bgn, src_end, img_data); - itm_wtr.Init(true, uid, li_w, div_1_w, div_2_margin, capt_tid, capt_bry); + ((gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_data)img_data).Img_is_gallery_(true); itm_wtr.Img_wtr().Init_by_decode(hpg, hctx, src, img_data); + itm_wtr.Init(hctx.Mode_is_diff(), itm_wtr.Img_wtr().Fsdb_itm().Html_uid(), li_w, div_1_w, div_2_margin, capt_tid, capt_bry); img_data.Pool__rls(); img_hzip.Pool__rls(); } 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); + hpg.Xtn__gallery_exists_y_(); } 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;} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__basic__tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__basic__tst.java new file mode 100644 index 000000000..82e718102 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__basic__tst.java @@ -0,0 +1,157 @@ +/* +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 . +*/ +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 org.junit.*; import gplx.xowa.htmls.core.hzips.*; +public class Xoh_gly_hzip__basic__tst { + private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_(); + @Test public void Basic() { + fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~9\"D\"D{\"g{\"b0!B1~!1B.png~9\"D\"Dabc", String_.Concat_lines_nl_skip_last + ( "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 + ( "abc")); + } + @Test public void Extra_cls() { // PURPOSE: handle extra cls; EX: + fxt.Test__bicode("~'1!cls1 cls2~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last + ( "")); + } + // FUTURE: galleries with gallerycaption will cause gallery to write raw; instate code below, but would need to then serialize "gallerycaption"; PAGE:en.d:A DATE:2016-06-24 + //@Test public void Caption() { // handle
    • A
    • ; PAGE:en.d:a; DATE:2016-06-24 + // fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last + // ( "")); + //} + @Test public void Extra_cls__gallery() { // handle redundant gallery; EX: ; 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 + ( "")); + } + @Test public void Xtra_atr() { // PURPOSE: handle extra atr; EX: + fxt.Test__bicode("~'A! id=\"abc\"\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last + ( "")); + } + @Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where

      is put on one line ("

      a

      ") unless it ends with
      ("

      a
      \n

      ") + fxt.Test__bicode(String_.Concat_lines_nl_skip_last + ( "~'!!\"{\"g{\"b0!A1
      " + , "~!1A.png~9\"D\"D" + ), String_.Concat_lines_nl_skip_last + ( "")); + } + @Test public void Tidy__empty() { // PURPOSE: no items should place
    on same line + fxt.Test__bicode("~'!!!", String_.Concat_lines_nl_skip_last + ( "")); // TIDY:
      should be on same line if 0 items + } +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__caption__tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__caption__tst.java new file mode 100644 index 000000000..871b3e271 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__caption__tst.java @@ -0,0 +1,124 @@ +/* +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 . +*/ +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 org.junit.*; import gplx.xowa.htmls.core.hzips.*; +public class Xoh_gly_hzip__caption__tst { + private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_(); + @Test public void Capt_is_empty() { // PURPOSE: handle empty caption + fxt.Test__bicode("~'!!#{\"g{\"b0#~!1A.png~9\"D\"D{\"g{\"b0#!1A.png9\"D\"D

      abc

      ", String_.Concat_lines_nl_skip_last + ( "

      abc

      ")); + } + @Test public void Capt_is_br() { // PURPOSE: handle captions which have
      , not

      ; PAGE:s.w:Sociology; DATE:2015-12-20 + fxt.Test__bicode(String_.Concat_lines_nl_skip_last + ( "~'!!\"{\"g{\"b0\"A1" + , "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last + ( "

      ")); + } + @Test public void Capt_has_multiple_p() { // PURPOSE: handle captions with multiple

      ; PAGE:en.w:Wikipedia:Bot_requests/Archive_25; DATE:2016-01-12 + fxt.Test__bicode(String_.Concat_lines_nl_skip_last + ( "~'!!\"{\"g{\"b0!a
      " + , "b

      " + , "


      " + , "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last + ( "

      ")); + } + @Test public void Capt_has_complicated_nl_behavior() {// handle complicated captions which force
      on different line PAGE:en.w:Tamago_kake_gohan; DATE:2016-01-05 + fxt.Test__bicode(String_.Concat_lines_nl_skip_last + ( "~'!!\"{\"g{\"b>\"
      \"\"
      " + , "abc~\"\\A.png~#9\"D\"D" + ), String_.Concat_lines_nl_skip_last + ( "
      " + , "" + , "" + )); + } + @Test public void Capt_has_hr() {// handle
      which causes

      to end early; PAGE:de.v:Kurs:Photoshop_Einzell�sungen/HighKey_mit_CS5; DATE:2016-06-24 + fxt.Test__bicode(String_.Concat_lines_nl_skip_last + ( "~'!!\"{\"g{\"b>%a

      " + , "
      " + , "b" + , "~\"\\A.png~#9\"D\"D") + , String_.Concat_lines_nl_skip_last + ( "" + )); + } +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__style__tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__style__tst.java new file mode 100644 index 000000000..f370b8670 --- /dev/null +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip__style__tst.java @@ -0,0 +1,144 @@ +/* +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 . +*/ +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 org.junit.*; import gplx.xowa.htmls.core.hzips.*; +public class Xoh_gly_hzip__style__tst { + private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_(); + @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 + ( "")); + } + @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 + ( "")); + } + @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 + ( "")); + } + @Test public void Style__append() { // PURPOSE: handle appended style; EX: + fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last + ( "")); + } + @Test public void Style__invalid_unclosed() { // handle broken styles; EX: + fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last + ( "" + )); + } + @Test public void Style__extra_colon() { // handle broken styles; EX: " + , "
    • " + , "
      " + , "
      " + , "
      " + , "
      " + , "
      " + , "

      abc

      " + , "
      " + , "
      " + , "
    • " + , "" + )); + } + @Test public void Style__replace() { // PURPOSE: handle replaced style; EX: + fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last + ( "")); + } + @Test public void Style__ws() { // PURPOSE: handle ws in style; EX: " + , "
    • " + , "
      " + , "
      " + , "
      " + , "
      " + , "
      " + , "

      A1

      " + , "
      " + , "
      " + , "
    • " + , "")); + } +} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip_tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip_tst.java deleted file mode 100644 index d2d663cb6..000000000 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_hzip_tst.java +++ /dev/null @@ -1,341 +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 . -*/ -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 org.junit.*; import gplx.xowa.htmls.core.hzips.*; -public class Xoh_gly_hzip_tst { - private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_(); - @Test public void Basic() { - fxt.Test__bicode("~'!{,L#{\"g{\"b0!A1~!1A.png~9\"D\"D{\"g{\"b0!B1~!1B.png~9\"D\"Dabc", String_.Concat_lines_nl_skip_last - ( "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 - ( "abc")); - } - @Test public void Capt_is_empty() { // PURPOSE: handle empty caption - fxt.Test__bicode("~'!!#{\"g{\"b0#~!1A.png~9\"D\"D{\"g{\"b0#!1A.png9\"D\"D

      abc

      ", String_.Concat_lines_nl_skip_last - ( "

      abc

      ")); - } - @Test public void Capt_is_br() { // PURPOSE: handle captions which have
      , not

      ; PAGE:s.w:Sociology; DATE:2015-12-20 - fxt.Test__bicode(String_.Concat_lines_nl_skip_last - ( "~'!!\"{\"g{\"b0\"A1" - , "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last - ( "

      ")); - } - @Test public void Capt_has_multiple_p() { // PURPOSE: handle captions with multiple

      ; PAGE:en.w:Wikipedia:Bot_requests/Archive_25; DATE:2016-01-12 - fxt.Test__bicode(String_.Concat_lines_nl_skip_last - ( "~'!!\"{\"g{\"b0!a
      " - , "b

      " - , "


      " - , "~!1A.png~9\"D\"D"), String_.Concat_lines_nl_skip_last - ( "

      ")); - } - @Test public void Capt_has_complicated_nl_behavior() {// handle complicated captions which force
      on different line PAGE:en.w:Tamago_kake_gohan; DATE:2016-01-05 - fxt.Test__bicode(String_.Concat_lines_nl_skip_last - ( "~'!!\"{\"g{\"b>\"
      \"\"
      " - , "abc~\"\\A.png~#9\"D\"D" - ), String_.Concat_lines_nl_skip_last - ( "
      " - , "" - , "" - )); - } - @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 - ( "")); - } - @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 - ( "")); - } - @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 - ( "")); - } - @Test public void Style__append() { // PURPOSE: handle appended style; EX: - fxt.Test__bicode("~'){,L color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last - ( "")); - } - @Test public void Style__invalid_unclosed() { // handle broken styles; EX: - fxt.Test__bicode("~'9!center~center~\"{\"g{\"bl!abc~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last - ( "" - )); - } - @Test public void Style__extra_colon() { // handle broken styles; EX: " - , "
    • " - , "
      " - , "
      " - , "
      " - , "
      " - , "
      " - , "

      abc

      " - , "
      " - , "
      " - , "
    • " - , "" - )); - } - @Test public void Style__replace() { // PURPOSE: handle replaced style; EX: - fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last - ( "")); - } - @Test public void Style__ws() { // PURPOSE: handle ws in style; EX: " - , "
    • " - , "
      " - , "
      " - , "
      " - , "
      " - , "
      " - , "

      A1

      " - , "
      " - , "
      " - , "
    • " - , "")); - } - @Test public void Extra_cls() { // PURPOSE: handle extra cls; EX: - fxt.Test__bicode("~'1!cls1 cls2~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last - ( "")); - } - @Test public void Extra_cls__gallery() { // handle redundant gallery; EX: ; 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 - ( "")); - } - @Test public void Xtra_atr() { // PURPOSE: handle extra atr; EX: - fxt.Test__bicode("~'A! id=\"abc\"\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last - ( "")); - } - @Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where

      is put on one line ("

      a

      ") unless it ends with
      ("

      a
      \n

      ") - fxt.Test__bicode(String_.Concat_lines_nl_skip_last - ( "~'!!\"{\"g{\"b0!A1
      " - , "~!1A.png~9\"D\"D" - ), String_.Concat_lines_nl_skip_last - ( "")); - } - @Test public void Tidy__empty() { // PURPOSE: no items should place on same line - fxt.Test__bicode("~'!!!", String_.Concat_lines_nl_skip_last - ( "")); // TIDY:
        should be on same line if 0 items - } -} diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_data.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_data.java index 92e50b3a4..15e3b25c7 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_data.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_data.java @@ -95,12 +95,14 @@ public class Xoh_gly_itm_data { 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

        ; 5 = "\n

        "; + else // no

        ; occurs when
        in middle; PAGE:fr.w:Forfry DATE:2016-06-24 + capt_tid = Capt_tid__p_wo_rhs; } tag_rdr.Pos_(capt_tail_end); return true; } private static final byte[] Atr__cls__gallerytext = Bry_.new_a7("gallerytext"), Bry__p__rhs = Bry_.new_a7("

        \n"); - public static final byte Capt_tid__p = 0, Capt_tid__br = 1, Capt_tid__empty = 2, Capt_tid__null = 3; + public static final byte Capt_tid__p = 0, Capt_tid__br = 1, Capt_tid__empty = 2, Capt_tid__null = 3, Capt_tid__p_wo_rhs = 4; private static final Btrie_slim_mgr Capt_tid__trie = Btrie_slim_mgr.ci_a7() .Add_bry_byte(Gfh_tag_.P_lhs , Capt_tid__p) .Add_bry_byte(Gfh_tag_.Br_lhs , Capt_tid__br) diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr.java index 7393fab05..9012d39e2 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr.java @@ -19,15 +19,15 @@ package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; impor 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_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 final Bfr_arg_clearable[] arg_ary; + 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("xowa_gallery_div1_"), div_2_id = Bfr_arg__hatr_id.New_id("xowa_gallery_div2_"), div_3_id = Bfr_arg__hatr_id.New_id("xowa_gallery_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() { arg_ary = new Bfr_arg_clearable[] {li_id, div_1_id, div_2_id, div_3_id, img_id}; } - public Xoh_img_wtr Img_wtr() {return img_wtr;} private final Xoh_img_wtr img_wtr = new Xoh_img_wtr(); + public Xoh_img_wtr Img_wtr() {return img_wtr;} private final Xoh_img_wtr img_wtr = new Xoh_img_wtr(); public void Init(boolean mode_is_diff, int img_id, int li_w, int div_1_w, int div_2_margin, byte capt_tid, byte[] itm_caption) { this.Clear(); this.li_w = li_w; this.div_1_w = div_1_w; this.div_2_margin = div_2_margin; @@ -48,8 +48,8 @@ public class Xoh_gly_itm_wtr implements Bfr_arg { public void Bfr_arg__add(Bry_bfr bfr) { fmtr.Bld_bfr_many(bfr, li_id, div_1_id, div_2_id, div_3_id, li_w, div_1_w, div_2_margin, img_wtr, itm_caption_fmtr); } - public static final Xoh_gly_itm_wtr[] Ary_empty = new Xoh_gly_itm_wtr[0]; - private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last + public static final Xoh_gly_itm_wtr[] Ary_empty = new Xoh_gly_itm_wtr[0]; + private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last ( "" , "" , "" @@ -70,9 +70,10 @@ 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; //
        - case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; //

        - case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; //


        + case Xoh_gly_itm_data.Capt_tid__empty: return; //
        + case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; //

        + case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; //


        + case Xoh_gly_itm_data.Capt_tid__p_wo_rhs: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; //

        } bfr.Add(capt_bry); int itm_caption_len = capt_bry.length; diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr_tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr_tst.java index db43e8445..ac819f949 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr_tst.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/glys/Xoh_gly_itm_wtr_tst.java @@ -25,9 +25,9 @@ public class Xoh_gly_itm_wtr_tst { fxt.Test__write(String_.Concat_lines_nl_skip_last ( "" , "
      • " - , "
        " - , "
        " - , "
        " + , "