1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2016-01-03 21:27:38 -05:00
parent 9509363f46
commit 096045614c
647 changed files with 11693 additions and 7648 deletions

View File

@@ -34,7 +34,7 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
public static final String Version = "2.12.1.1";
public static final String Version = "3.1.1.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";

View File

@@ -39,6 +39,8 @@ public class Xoa_app_fxt {
Io_url user_dir = root_dir.GenSubDir_nest("user", "test_user");
Gfo_usr_dlg__log_base.Instance.Log_dir_(user_dir.GenSubDir_nest("tmp", "current"));
Xoav_app rv = new Xoav_app(Gfo_usr_dlg_.Test(), Xoa_app_mode.Itm_gui, op_sys, root_dir, root_dir.GenSubDir("file"), root_dir.GenSubDir("css"));
rv.Init_by_app(user_dir);
rv.Wiki_mgr().Add(new Xowv_wiki(rv, Xow_domain_itm_.Bry__home, user_dir));
return rv;
}
public static Xoae_app app_(String op_sys, Io_url root_dir) {

View File

@@ -103,7 +103,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
// $dbkey = preg_replace( '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u', '_', $dbkey );
private static final int Char__bidi = 1, Char__ws = 2;
private static final Btrie_slim_mgr char_trie = Btrie_slim_mgr.cs()
.Add_many_int(Char__bidi , Bry_.new_ints(0xE2, 0x80, 0x8E), Bry_.new_ints(0xE2, 0x80, 0x8F), Bry_.new_ints(0xE2, 0x80, 0xAA), Bry_.new_ints(0xE2, 0x80, 0xAB), Bry_.new_ints(0xE2, 0x80, 0xAC), Bry_.new_ints(0xE2, 0x80, 0xAD), Bry_.new_ints(0xE2, 0x80, 0xAE))
.Add_many_int(Char__bidi , Bry_.New_by_ints(0xE2, 0x80, 0x8E), Bry_.New_by_ints(0xE2, 0x80, 0x8F), Bry_.New_by_ints(0xE2, 0x80, 0xAA), Bry_.New_by_ints(0xE2, 0x80, 0xAB), Bry_.New_by_ints(0xE2, 0x80, 0xAC), Bry_.New_by_ints(0xE2, 0x80, 0xAD), Bry_.New_by_ints(0xE2, 0x80, 0xAE))
.Add_many_int(Char__ws , "\u00A0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u2028", "\u2029", "\u202F", "\u205F", "\u3000")
;
public static Xoa_ttl new_(Xowe_wiki wiki, Gfo_msg_log msg_log, byte[] src, int bgn, int end) {
@@ -196,7 +196,10 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
colon_count++; // increment colon count
break;
}
case Byte_ascii.Hash: anch_bgn = (txt_bb_len) + 1; break; // flag last anch_bgn
case Byte_ascii.Hash:
if (anch_bgn == -1) // anchor begins at 1st #, not last #; EX:A#B#C has anchor of "B#C" not "C" PAGE:en.w:Grand_Central_Terminal; DATE:2015-12-31
anch_bgn = (txt_bb_len) + 1;
break;
case Byte_ascii.Slash:
if (root_bgn == -1)
root_bgn = (txt_bb_len) + 1;

View File

@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
import gplx.xowa.langs.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.xtns.cites.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.htmls.modules.popups.*;
public class Xoae_page implements Xoa_page {
Xoae_page(Xowe_wiki wiki, Xoa_ttl ttl) {

View File

@@ -64,6 +64,7 @@ public class Xop_fxt {
ctx.Clear_all();
ctx.App().Free_mem(false);
ctx.Cur_page().Clear_all();
wiki.File_mgr().Clear_for_tests();
wiki.Db_mgr().Load_mgr().Clear();
app.Wiki_mgr().Clear();
Io_mgr.Instance.InitEngine_mem(); // clear created pages
@@ -221,6 +222,8 @@ public class Xop_fxt {
public byte[] Test_parse_tmpl_str_rv(String raw) {
byte[] raw_bry = Bry_.new_u8(raw);
Xop_root_tkn root = tkn_mkr.Root(raw_bry);
ctx.Cur_page().Root_(root);
ctx.Cur_page().Data_raw_(raw_bry);
return parser.Parse_text_to_wtxt(root, ctx, tkn_mkr, raw_bry);
}
public Xot_defn_tmpl run_Parse_tmpl(byte[] name, byte[] raw) {return parser.Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), wiki.Ns_mgr().Ns_template(), name, raw);}
@@ -358,7 +361,7 @@ public class Xop_fxt {
wiki.Appe().Usere().Wiki().Xwiki_mgr().Add_by_atrs(domain_bry, domain_bry);
}
public static String html_img_none(String trg, String alt, String src, String ttl) {
return String_.Format(String_.Concat_lines_nl_skip_last("<a href=\"/wiki/{0}\" class=\"image\" xowa_title=\"{3}\"><img id=\"xowa_file_img_0\" alt=\"{1}\" src=\"{2}\" width=\"9\" height=\"8\" /></a>"), trg, alt, src, ttl);
return String_.Format(String_.Concat_lines_nl_skip_last("<a href=\"/wiki/{0}\" class=\"image\" xowa_title=\"{3}\"><img id=\"xoimg_0\" alt=\"{1}\" src=\"{2}\" width=\"9\" height=\"8\" /></a>"), trg, alt, src, ttl);
}
private String Exec_html_full(String raw) {return this.Exec_parse_page_all_as_str(raw);}
private String Exec_html_wiki(String raw) {return this.Exec_parse_page_wiki_as_str(raw);}
@@ -369,7 +372,7 @@ public class Xop_fxt {
public void Test_html_full_frag_n(String raw, String... expd_frags) {Test_str_part_n(Exec_html_full(raw), expd_frags);}
public void Test__parse__wtxt_to_html(String raw, String expd) {
String actl = Exec_html_wiki(raw);
Tfds.Eq_str_lines(gplx.langs.htmls.Html_utl.Replace_apos(expd), actl, raw);
Tfds.Eq_str_lines(gplx.langs.htmls.Gfh_utl.Replace_apos(expd), actl, raw);
}
public void Test_str_full(String raw, String expd, String actl) {Tfds.Eq_str_lines(expd, actl, raw);}
@@ -436,6 +439,7 @@ public class Xop_fxt {
html_wtr.Cfg().Toc__show_(Bool_.Y); // needed for hdr to show <span class='mw-headline' id='A'>
ctx.Cur_page().Redlink_lnki_list().Clear();
html_wtr.Write_all(tmp_bfr, ctx, hctx, src_bry, root);
// Tfds.Dbg(tmp_bfr.To_str());
return tmp_bfr.To_str_and_clear();
}
}

View File

@@ -26,18 +26,18 @@ public class Xoa_fsys_eval implements Bry_fmtr_eval_mgr {
Object o = hash.Get_by_bry(cmd); if (o == null) return null;
byte val = ((Byte_obj_val)o).Val();
switch (val) {
case Tid_xowa_root_dir: return app_fsys_mgr.Root_dir().RawBry();
case Tid_bin_plat_dir: return app_fsys_mgr.Bin_plat_dir().RawBry();
case Tid_user_temp_dir: return usr_fsys_mgr.App_temp_dir().RawBry();
case Tid_user_cfg_dir: return usr_fsys_mgr.App_data_cfg_dir().RawBry();
case Tid__xowa_root_dir: return app_fsys_mgr.Root_dir().RawBry();
case Tid__bin_plat_dir: return app_fsys_mgr.Bin_plat_dir().RawBry();
case Tid__user_temp_dir: return usr_fsys_mgr.App_temp_dir().RawBry();
case Tid__user_cfg_dir: return usr_fsys_mgr.App_data_cfg_dir().RawBry();
default: throw Err_.new_unhandled(val);
}
}
private static final byte Tid_bin_plat_dir = 0, Tid_user_temp_dir = 1, Tid_xowa_root_dir = 2, Tid_user_cfg_dir = 3;
private static final byte Tid__bin_plat_dir = 0, Tid__user_temp_dir = 1, Tid__xowa_root_dir = 2, Tid__user_cfg_dir = 3;
private static final Hash_adp_bry hash = Hash_adp_bry.ci_a7()
.Add_str_byte("bin_plat_dir" , Tid_bin_plat_dir)
.Add_str_byte("user_temp_dir" , Tid_user_temp_dir)
.Add_str_byte("xowa_root_dir" , Tid_xowa_root_dir)
.Add_str_byte("user_cfg_dir" , Tid_user_cfg_dir)
.Add_str_byte("bin_plat_dir" , Tid__bin_plat_dir)
.Add_str_byte("user_temp_dir" , Tid__user_temp_dir)
.Add_str_byte("xowa_root_dir" , Tid__xowa_root_dir)
.Add_str_byte("user_cfg_dir" , Tid__user_cfg_dir)
;
}

View File

@@ -25,17 +25,17 @@ public class Xoa_prog_mgr implements GfoInvkAble {
Process_adp.ini_(this, usr_dlg, app_convert_svg_to_png , cmd_eval, Process_adp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}inkscape\\inkscape", "-z -w ~{width} -f \"~{source}\" -e \"~{target}\"", "source", "target", "width").Thread_kill_name_("inkscape.exe"); // // -z=without-gui; -w=width; -f=file -e=export-png
Process_adp.ini_(this, usr_dlg, app_convert_tex_to_dvi , cmd_eval, Process_adp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\latex", "-quiet -output-directory=~{temp_dir} -job-name=xowa_temp ~{tex_file}", "tex_file", "temp_dir");
Process_adp.ini_(this, usr_dlg, app_convert_dvi_to_png , cmd_eval, Process_adp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\dvipng", "~{dvi_file} -o ~{png_file} -q* -T tight -bg Transparent", "dvi_file", "png_file", "temp_dir");
Process_adp.ini_(this, usr_dlg, app_convert_djvu_to_tiff , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}djvulibre\\ddjvu", "-format=tiff -page=1 \"~{source}\" \"~{target}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_convert_djvu_to_tiff , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}djvulibre\\ddjvu", "-format=tiff -page=1 \"~{source}\" \"~{target}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_decompress_bz2 , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
Process_adp.ini_(this, usr_dlg, app_decompress_bz2_by_stdout , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -so \"~{src}\"", "src"); // x=extract; -so=stdout
Process_adp.ini_(this, usr_dlg, app_decompress_bz2_by_stdout, cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -so \"~{src}\"", "src"); // x=extract; -so=stdout
Process_adp.ini_(this, usr_dlg, app_decompress_zip , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
Process_adp.ini_(this, usr_dlg, app_decompress_gz , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
Process_adp.ini_(this, usr_dlg, app_lua , cmd_eval, Process_adp.Run_mode_async , 0 , "~{<>bin_plat_dir<>}lua\\lua", "", "");
Process_adp.ini_(this, usr_dlg, app_lilypond , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\lilypond.exe", "\"-dsafe=#t\" -dbackend=ps --png --header=texidoc -dmidi-extension=midi \"~{file}\"", "file");
Process_adp.ini_(this, usr_dlg, app_lilypond , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\lilypond.exe", "\"-dsafe=#t\" -dbackend=ps --png --header=texidoc -dmidi-extension=midi \"~{file}\"", "file");
Process_adp.ini_(this, usr_dlg, app_abc2ly , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\python.exe", "abc2ly.py -s \"--output=~{target}\" \"~{source}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_trim_img , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "-trim \"~{source}\" \"~{target}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_trim_img , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "-trim \"~{source}\" \"~{target}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_convert_midi_to_ogg , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}timidity\\timidity", "-Ov \"--output-file=~{target}\" \"~{source}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_view_web , cmd_eval, Process_adp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
Process_adp.ini_(this, usr_dlg, app_view_web , cmd_eval, Process_adp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
Process_adp.ini_(this, usr_dlg, app_view_text , cmd_eval, Process_adp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
int cmds_view_file_by_ext_len = cmds_view_file_by_ext.length;
for (int i= 0; i < cmds_view_file_by_ext_len; i++) {
@@ -56,11 +56,11 @@ public class Xoa_prog_mgr implements GfoInvkAble {
public Process_adp App_decompress_zip() {return app_decompress_zip;} private Process_adp app_decompress_zip = new Process_adp();
public Process_adp App_decompress_gz() {return app_decompress_gz;} private Process_adp app_decompress_gz = new Process_adp();
public Process_adp App_decompress_bz2_by_stdout() {return app_decompress_bz2_by_stdout;} private Process_adp app_decompress_bz2_by_stdout = new Process_adp();
public Process_adp App_lua() {return app_lua;} private Process_adp app_lua = new Process_adp();
public Process_adp App_lua() {return app_lua;} private Process_adp app_lua = new Process_adp();
public Process_adp App_lilypond() {return app_lilypond;} private Process_adp app_lilypond = new Process_adp();
public Process_adp App_abc2ly() {return app_abc2ly;} private Process_adp app_abc2ly = new Process_adp();
public Process_adp App_trim_img() {return app_trim_img;} private Process_adp app_trim_img = new Process_adp();
public Process_adp App_convert_midi_to_ogg() {return app_convert_midi_to_ogg;} private Process_adp app_convert_midi_to_ogg = new Process_adp();
public Process_adp App_convert_midi_to_ogg() {return app_convert_midi_to_ogg;} private Process_adp app_convert_midi_to_ogg = new Process_adp();
public Process_adp App_by_ext(String ext) {return App_by_ext_key(String_.Mid(ext, 1));} // ignore 1st . in ext; EX: ".png" -> "png"
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_query_img_size)) return app_query_img_size;

View File

@@ -63,7 +63,7 @@ public class Xoa_site_cfg_mgr_tst {
}
// @Test public void Print() {
// String s = fxt.Make_api(fxt.Make_api_interwikimap("k1", "v1", "k2", "v2"), fxt.Make_api_extensiontags2("k3", "v3", "k4", "v4"));
// Tfds.Write(s);
// Tfds.Dbg(s);
// }
}
class Xoa_site_cfg_mgr_fxt {

View File

@@ -54,6 +54,9 @@ public class Xob_cmd_keys {
, Key_wbase_pid = "wbase.pid" // "text.wdata.pid"
, Key_wbase_db = "wbase.db" // "wiki.wdata_db"
, Key_site_meta = "util.site_meta"
, Key_diff_build = "diff.build"
, Key_diff_merge = "diff.merge"
, Key_tdb_text_init = "tdb.text.init" // "core.init"
, Key_tdb_make_page = "tdb.text.page" // "core.make_page"
, Key_tdb_make_id = "core.make_id"

View File

@@ -89,7 +89,7 @@ public class Xob_wiki_cfg_bldr_tst {
// String[] terms = String_.Split(line, '|');
// sb.Add(lang_code).Add("|").Add(String_.Trim(terms[0])).Add("|").Add(String_.Trim(terms[1])).Add("\n");
// }
// Tfds.Write(sb.To_str_and_clear());
// Tfds.Dbg(sb.To_str_and_clear());
// }
@Test public void Ns_aliases() {
Io_mgr.Instance.InitEngine_mem();

File diff suppressed because it is too large Load Diff

View File

@@ -22,11 +22,11 @@ public class Uca_trie_tst {
@Test public void Basic() {
Uca_trie_fxt fxt = new Uca_trie_fxt();
fxt.Clear();
fxt.Init_trie_itm("a", Bry_.new_ints(10, 11));
fxt.Init_trie_itm("b", Bry_.new_ints(20, 21));
fxt.Init_trie_itm("c", Bry_.new_ints(30, 31));
fxt.Test_decode(Bry_.new_ints(10, 11), "a");
fxt.Test_decode(Bry_.new_ints(10, 11, 20, 21, 30, 31), "abc");
fxt.Init_trie_itm("a", Bry_.New_by_ints(10, 11));
fxt.Init_trie_itm("b", Bry_.New_by_ints(20, 21));
fxt.Init_trie_itm("c", Bry_.New_by_ints(30, 31));
fxt.Test_decode(Bry_.New_by_ints(10, 11), "a");
fxt.Test_decode(Bry_.New_by_ints(10, 11, 20, 21, 30, 31), "abc");
}
}
class Uca_trie_fxt {

View File

@@ -0,0 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
public class Xob_diff_build_cmd implements Xob_cmd {
private final Xob_bldr bldr; private final Xowe_wiki wiki;
private String prev_url, curr_url, diff_url; private int commit_interval;
public Xob_diff_build_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.bldr = bldr; this.wiki = wiki;}
public String Cmd_key() {return Xob_cmd_keys.Key_diff_build;}
public void Cmd_run() {
new Xob_diff_build_wkr(bldr, wiki, prev_url, curr_url, diff_url, commit_interval).Exec();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__prev_url_)) prev_url = m.ReadStr("v");
else if (ctx.Match(k, Invk__curr_url_)) curr_url = m.ReadStr("v");
else if (ctx.Match(k, Invk__diff_url_)) diff_url = m.ReadStr("v");
else if (ctx.Match(k, Invk__commit_interval_)) commit_interval = m.ReadInt("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
public void Cmd_init(Xob_bldr bldr) {}
public void Cmd_bgn(Xob_bldr bldr) {}
public void Cmd_end() {}
public void Cmd_term() {}
private static final String Invk__prev_url_ = "prev_url_", Invk__curr_url_ = "curr_url_", Invk__diff_url_ = "diff_url_", Invk__commit_interval_ = "commit_interval_";
}

View File

@@ -0,0 +1,55 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.dbs.*; import gplx.dbs.diffs.*; import gplx.dbs.diffs.builds.*;
class Xob_diff_build_wkr {
private final Gfdb_diff_bldr diff_bldr = new Gfdb_diff_bldr();
private Db_conn prev_conn, curr_conn, diff_conn;
public Xob_diff_build_wkr(Xob_bldr bldr, Xowe_wiki wiki, String prev_url, String curr_url, String diff_url, int commit_interval) {
Bry_fmt url_fmt = Bry_fmt.New("").Args_(New_url_args(wiki));
Bry_bfr tmp_bfr = Bry_bfr.new_();
prev_conn = New_conn(wiki, url_fmt, prev_url, tmp_bfr);
curr_conn = New_conn(wiki, url_fmt, curr_url, tmp_bfr);
diff_conn = New_conn(wiki, url_fmt, diff_url, tmp_bfr);
// get Gfdb_diff_tbl; format urls
Tfds.Write(prev_conn, curr_conn, diff_conn);
}
public void Exec() {
diff_bldr.Init(null); // diff_db_wkr
diff_bldr.Compare(null, null); // lhs_tbl, rhs_tbl
}
public static Db_conn New_conn(Xow_wiki wiki, Bry_fmt fmtr, String url_fmt, Bry_bfr tmp_bfr) {
fmtr.Fmt_(url_fmt).Bld_bfr_many(tmp_bfr);
Db_conn conn = Db_conn_pool.Instance.Get_or_new(tmp_bfr.To_str_and_clear());
return conn;
}
private static Bfr_fmt_arg[] New_url_args(Xow_wiki wiki) {
return null;
}
//prev_url='~{.dump_dir}-prev/~{.dump_core}';
//curr_url='~{.dump_dir}/~{.dump_core}';
//diff_url='~{.dump_dir}/~{.dump_domain}-diff.xowa';
}
// class Bfr_arg__dump_dir : Bfr_arg {
// public void Bfr_arg__add(Bry_bfr bfr) {
// // dump_dir = bfr.Add("C:\xowa\wiki\en.wikipedia.org");
// // dump_core = en.wikipedia.org-core.xowa
// // dump_domain = en.wikipedia.org
// }
// }

View File

@@ -35,8 +35,8 @@ public class Xob_diff_regy_make_cmd extends Xob_itm_basic_base implements Xob_cm
}
private void Make_join_indexes(Db_conn make_db_provider) {
try {
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_fsdb_regy__join);
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_xfer_regy__join);
make_db_provider.Ddl_create_idx(Db_meta_idx.new_normal_by_name("fsdb_regy", "fsdb_regy__join", "fsdb_name", "fsdb_is_orig", "fsdb_repo", "fsdb_w", "fsdb_time", "fsdb_page"));
make_db_provider.Ddl_create_idx(Db_meta_idx.new_normal_by_name("xfer_regy", "xfer_regy__join", "lnki_ttl", "file_is_orig", "orig_repo", "file_w", "lnki_time", "lnki_page"));
}
catch (Exception exc) {
app.Usr_dlg().Warn_many("", "", "error while making indexes: err=~{0}", Err_.Message_gplx_full(exc));
@@ -110,8 +110,8 @@ class Xob_diff_regy_tbl {
, ", diff_size bigint NOT NULL"
, ");"
);
public static final Db_idx_itm Idx_fsdb_regy__join = Db_idx_itm.sql_("CREATE INDEX fsdb_regy__join ON fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page);");
public static final Db_idx_itm Idx_xfer_regy__join = Db_idx_itm.sql_("CREATE INDEX xfer_regy__join ON xfer_regy (lnki_ttl , file_is_orig, orig_repo, file_w, lnki_time, lnki_page);");
// public static final Db_idx_itm Idx_fsdb_regy__join = Db_idx_itm.sql_("CREATE INDEX fsdb_regy__join ON fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page);");
// public static final Db_idx_itm Idx_xfer_regy__join = Db_idx_itm.sql_("CREATE INDEX xfer_regy__join ON xfer_regy (lnki_ttl , file_is_orig, orig_repo, file_w, lnki_time, lnki_page);");
public static final Db_idx_itm Idx_diff_regy__load = Db_idx_itm.sql_("CREATE INDEX diff_regy__load ON diff_regy (diff_status, diff_db_id, diff_is_orig, diff_fil_id, diff_thm_id);");
public static final String
Make_diff_regy = String_.Concat_lines_nl

View File

@@ -65,7 +65,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
property_wkr = this.Property_wkr(); // set member reference
property_wkr = log_mgr.Make_wkr_property();
wiki.Appe().Wiki_mgr().Wdata_mgr().Enabled_(wdata_enabled);
if (!xtn_ref_enabled) gplx.xowa.xtns.cite.References_nde.Enabled = false;
if (!xtn_ref_enabled) gplx.xowa.xtns.cites.References_nde.Enabled = false;
gplx.xowa.xtns.gallery.Gallery_xnde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y);
gplx.xowa.xtns.imaps.Imap_xnde.Log_wkr = log_mgr.Make_wkr();
gplx.xowa.parsers.xndes.Xop_xnde_wkr.Timeline_log_wkr = log_mgr.Make_wkr();

View File

@@ -39,7 +39,7 @@ public class Xob_search_sql_wkr extends Xob_search_base implements Io_make_cmd {
byte[] bry = rdr.Bfr();
byte[] cur_word = Bry_.Mid(bry, rdr.Key_pos_bgn(), rdr.Key_pos_end());
if (!Bry_.Eq(cur_word, prv_word)) {
search_word_tbl.Insert_cmd_by_batch(++search_id, cur_word, page_count);
search_word_tbl.Insert_cmd_by_batch(++search_id, prv_word, page_count);
prv_word = cur_word;
page_count = 0;
}

View File

@@ -26,7 +26,7 @@ public class Xob_redirect_cmd extends Xob_dump_mgr_base {
public Xob_redirect_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.Reset_db_y_();}
@Override public String Cmd_key() {return Xob_cmd_keys.Key_wiki_redirect;}
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Tid__file);} // restrict to file ns
@Override public byte Init_redirect() {return Bool_.Y_byte;} // restrict to redirects
@Override public byte Init_redirect() {return Bool_.Y_byte;} // restrict to redirects
@Override protected void Init_reset(Db_conn conn) {
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg");
cfg_tbl.Delete_all();

View File

@@ -46,10 +46,10 @@ public class Xoi_cmd_wiki_tst {
for (int j = 0; j < 5; ++j) {
latest_html = Io_mgr.Instance.DownloadFil_args("", Io_url_.Empty).Exec_as_bry(url);
if (latest_html != null) break;
Tfds.Write("fail|" + url);
Tfds.Dbg("fail|" + url);
if (j == 4) return;
}
Tfds.Write("pass|" + url);
Tfds.Dbg("pass|" + url);
parser.Parse(latest_html);
Xowm_dump_file dump_file = new Xowm_dump_file(domain_str, "latest", Xowm_dump_type_.Str__pages_articles);
dump_file.Server_url_(Xowm_dump_file_.Server_wmf_https);

View File

@@ -28,7 +28,7 @@ public class Wmf_latest_parser_tst {
// @Test public void Smoke() {
// Wmf_latest_parser parser = new Wmf_latest_parser();
// parser.Parse(Io_mgr.Instance.LoadFilBry("C:\\wmf_latest.html"));
// Tfds.Write(String_.Concat_lines_nl(Wmf_latest_parser_fxt.Xto_str_ary(parser.To_ary())));
// Tfds.Dbg(String_.Concat_lines_nl(Wmf_latest_parser_fxt.Xto_str_ary(parser.To_ary())));
// }
}
class Wmf_latest_parser_fxt {

View File

@@ -19,6 +19,7 @@ package gplx.xowa.drds; import gplx.*; import gplx.xowa.*;
import gplx.xowa.drds.pages.*; import gplx.xowa.drds.files.*;
import gplx.xowa.apps.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.files.gui.*;
import gplx.xowa.specials.search.*;
public class Xod_app {
private final Xoav_app app;
private final Xod_page_mgr page_mgr = new Xod_page_mgr();
@@ -26,13 +27,29 @@ public class Xod_app {
public Xod_app(Xoav_app app) {
this.app = app;
}
public Xow_wiki Get_wiki(String wiki_domain) {
return app.Wiki_mgri().Get_by_key_or_make_init_y(Bry_.new_u8(wiki_domain));
public int Get_wiki_count() {
int rv = app.Wiki_mgri().Count();
return rv - 1; // ignore home wiki
}
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
return page_mgr.Get_page(wiki, page_ttl);
public Xow_wiki Get_wiki(String wiki_domain) {
Xow_wiki rv = app.Wiki_mgri().Get_by_key_or_make_init_y(Bry_.new_u8(wiki_domain));
if (rv.Data__core_mgr() == null) rv.Init_by_wiki();
return rv;
}
public Xod_page_itm Get_page(Xow_wiki wiki, Xoa_url page_url) {
return page_mgr.Get_page(wiki, page_url);
}
public void Load_files(Xow_wiki wiki, Xod_page_itm pg, Xog_js_wkr js_wkr) {
file_mgr.Load_files(wiki, pg, js_wkr);
}
public String[] Search_titles(Cancelable cancelable, Xow_wiki wiki, Xows_ui_async ui_async, String search) {
Xows_db_wkr search_wkr = new Xows_db_wkr();
Xows_db_row[] rows = search_wkr.Search_by_drd(cancelable, wiki, ui_async, Bry_.new_u8(search), 50);
int len = rows.length;
String[] rv = new String[len];
for (int i = 0; i < len; ++i) {
rv[i] = String_.new_u8(rows[i].Page_ttl().Page_txt());
}
return rv;
}
}

View File

@@ -23,7 +23,7 @@ public class Xod_app_tst {
@Test public void Get() {
tstr.Data_mgr().Page__insert(1, "A", "2015-10-19 00:01:02");
tstr.Data_mgr().Html__insert(1, "abc");
tstr.Test__get("A", tstr.Make_page(1, "A", "2015-10-19 00:01:02", tstr.Make_section(0, 2, "", "", "abc")));
tstr.Test__get("A", tstr.Make_page(1, "A", "2015-10-19T00:01:02Z", tstr.Make_section(0, 2, "", "", "abc")));
}
}
class Xod_app_tstr {
@@ -42,7 +42,8 @@ class Xod_app_tstr {
}
public void Test__get(String ttl, Xod_page_itm expd) {
Xow_wiki wiki = drd_provider.Get_wiki("en.wikipedia.org");
Xod_page_itm itm = drd_provider.Get_page(wiki, ttl);
Xoa_url page_url = wiki.Utl__url_parser().Parse(Bry_.new_u8(ttl));
Xod_page_itm itm = drd_provider.Get_page(wiki, page_url);
Tfds.Eq(expd.To_str(), itm.To_str());
}
public Xod_page_itm Make_page(int page_id, String ttl, String modified_on, Xoh_section_itm... section_ary) {

View File

@@ -51,7 +51,7 @@ public class Xod_page_itm {
this.rev_id = page_id;
this.ttl_text = String_.new_u8(ttl.Page_txt());
this.ttl_db = ttl.Page_db_as_str();
this.modified_on = db_page.Modified_on().XtoStr_fmt_iso_8561();
this.modified_on = db_page.Modified_on().XtoStr_fmt_iso_8561_w_tz();
this.lang_count = 1;
this.redirected = null;
this.description = null;

View File

@@ -18,12 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.drds.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.htmls.*; import gplx.xowa.htmls.sections.*;
import gplx.core.net.*; import gplx.xowa.specials.xowa.file_browsers.*;
public class Xod_page_mgr {
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
public Xod_page_itm Get_page(Xow_wiki wiki, Xoa_url page_url) {
Xod_page_itm rv = new Xod_page_itm();
// load meta info like page_id, modified, etc
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(page_ttl));
Xoa_ttl ttl = wiki.Ttl_parse(page_url.Page_bry());
if (ttl.Ns().Id_is_special()) return Load_special(rv, wiki, ttl, page_url.Qargs_ary());
Xowd_page_itm dbpg = new Xowd_page_itm();
wiki.Data__core_mgr().Tbl__page().Select_by_ttl(dbpg, ttl.Ns(), ttl.Page_db());
rv.Init_by_dbpg(ttl, dbpg);
@@ -44,4 +46,13 @@ public class Xod_page_mgr {
rv.Section_list().Add(itm);
}
}
private Xod_page_itm Load_special(Xod_page_itm rv, Xow_wiki wiki, Xoa_ttl ttl, Gfo_qarg_itm[] qargs) {
Xosp_fbrow_rslt rslt = Xosp_fbrow_special.Gen(qargs, wiki.App().Wiki_mgri());
rv.Init(-1, -1, String_.new_u8(ttl.Page_txt()), String_.new_u8(ttl.Page_db()), null, null, DateAdp_.Now().XtoStr_fmt_iso_8561(), false, false, false, 0, "", "", "");
rv.Init_by_hpg(new Xoh_page());
Xoh_section_itm section = new Xoh_section_itm(1, 1, Bry_.Empty, Bry_.Empty);
section.Content_(rslt.Html_body());
rv.Section_list().Add(section);
return rv;
}
}

View File

@@ -33,6 +33,12 @@ public class Xof_file_wkr implements Gfo_thread_wkr {
public String Name() {return "xowa.load_imgs";}
public boolean Resume() {return true;}
public void Exec() {
int len = imgs.Count();
for (int i = 0; i < len; ++i)
Exec_by_fsdb((Xof_fsdb_itm)imgs.Get_at(i));
Xoa_app_.Usr_dlg().Prog_none("", "", "");
}
public void Exec_old() {
int len = imgs.Count();
for (int i = 0; i < len; ++i)
Ctor_by_hdump(hpg, (Xohd_img_itm__base)imgs.Get_at(i));
@@ -42,6 +48,9 @@ public class Xof_file_wkr implements Gfo_thread_wkr {
Xof_fsdb_itm fsdb = new Xof_fsdb_itm();
fsdb.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, hpg.Wiki().Domain_itm().Abrv_xo(), hdump.Lnki_ttl(), hdump.Lnki_type(), hdump.Lnki_upright(), hdump.Lnki_w(), hdump.Lnki_h(), hdump.Lnki_time(), hdump.Lnki_page(), Xof_patch_upright_tid_.Tid_all);
fsdb.Init_at_hdoc(hdump.Html_uid(), hdump.Html_elem_tid());
Exec_by_fsdb(fsdb);
}
private void Exec_by_fsdb(Xof_fsdb_itm fsdb) {
fsdb.Orig_exists_n_();
Xof_orig_itm orig = orig_mgr.Find_by_ttl_or_null(fsdb.Lnki_ttl()); if (orig == Xof_orig_itm.Null) return;
Eval_orig(orig, fsdb, url_bldr, repo_mgr, img_size);

View File

@@ -89,6 +89,10 @@ public class Xow_file_mgr implements GfoInvkAble {
return fsdb_mgr.Mnt_mgr().Mnts__get_main().Cfg_mgr().Grps_get_or_load(grp);
}
public Xof_fsdb_mgr Fsdb_mgr() {return fsdb_mgr;} private Xof_fsdb_mgr fsdb_mgr = new Xof_fsdb_mgr__sql();
public void Clear_for_tests() { // NOTE: must clear else fsdb_mode will be cached for multiple runs; will generally be v1, but some tests will set to v2; DATE:2015-12-22
version = Bool_.__byte;
fsdb_mode = null;
}
public boolean Find_meta(Xof_xfer_itm xfer_itm) {
xfer_itm.Orig_repo_id_(Xof_meta_itm.Repo_unknown);
byte[] xfer_itm_ttl = xfer_itm.Lnki_ttl();

View File

@@ -53,5 +53,5 @@ public class Js_img_mgr {
break;
}
}
public static String To_doc_uid(int html_uid) {return "xowa_file_img_" + Int_.To_str(html_uid);}
public static String To_doc_uid(int html_uid) {return gplx.xowa.htmls.Xoh_img_mgr.Str__html_uid + Int_.To_str(html_uid);}
}

View File

@@ -123,7 +123,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
}
private void Win__link_clicked(String anchor_raw) {
String url = url_box.Text();
int pos = String_.FindFwd(url, gplx.langs.htmls.Html_tag_.Anchor_str);
int pos = String_.FindFwd(url, gplx.langs.htmls.Gfh_tag_.Anchor_str);
if (pos != Bry_find_.Not_found) url = String_.Mid(url, 0, pos);
String anchor_str = Parse_evt_location_changing(anchor_raw);
byte[] anchor_bry = Bry_.new_u8(anchor_str);
@@ -145,7 +145,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
app.Gfs_mgr().Run_str(snippet);
}
private static String Parse_evt_location_changing(String v) { // EX: about:blank#anchor -> anchor
int pos = String_.FindFwd(v, gplx.langs.htmls.Html_tag_.Anchor_str);
int pos = String_.FindFwd(v, gplx.langs.htmls.Gfh_tag_.Anchor_str);
return pos == Bry_find_.Not_found
? null
: String_.Mid(v, pos + 1);

View File

@@ -29,11 +29,8 @@ public class Xoh_consts {
, __inline_quote = Bry_.new_a7("\"/>")
, Space_2 = Bry_.new_a7(" ")
, A_bgn = Bry_.new_a7("<a href=\""), A_bgn_lnki_0 = Bry_.new_a7("\" title=\""), A_mid_xowa_title = Bry_.new_a7("\" xowa_title=\"")
, A_mid_id = Bry_.new_a7("\" id=\"xolnki_")
, A_end = Bry_.new_a7("</a>")
, Div_bgn_open = Bry_.new_a7("<div ")
, Div_end = Bry_.new_a7("</div>")
, Img_bgn = Bry_.new_a7("<img src=\"")
, Span_bgn_open = Bry_.new_a7("<span")
@@ -47,7 +44,6 @@ public class Xoh_consts {
, Code_bgn_closed = Bry_.new_a7("<code>")
, Code_bgn_open = Bry_.new_a7("<code")
, Code_end = Bry_.new_a7("</code>")
, Title_atr = Bry_.new_a7("\" title=\"")
, Id_atr = Bry_.new_a7(" id=\"")
, Style_atr = Bry_.new_a7(" style=\"")
, Atr_xowa_title_bry = Bry_.new_a7(Atr_xowa_title_str)

View File

@@ -39,5 +39,6 @@ public class Xoh_img_mgr {
itm.To_bfr(bfr);
}
}
public static final byte[] Bry__html_uid = Bry_.new_a7("xoimg_");
public static final String Str__html_uid = "xoimg_";
public static final byte[] Bry__html_uid = Bry_.new_a7(Str__html_uid);
}

View File

@@ -46,13 +46,13 @@ public class Xoh_page_wtr_wkr {
Bry_bfr page_bfr = Xoa_app_.Utl__bfr_mkr().Get_m001(); // NOTE: get separate page bfr to output page; do not reuse tmp_bfr b/c it will be used inside Fmt_do
if (page_mode == Xopg_page_.Tid_html && wiki.App().Api_root().Html().Page().View_html_generates_hdump()) {
Write_body(page_bfr, Xoh_wtr_ctx.Hdump, page);
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Html_utl.Escape_html_as_bry(page_bfr.To_bry_and_clear()));
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(page_bfr.To_bry_and_clear()));
}
else {
Write_body(page_bfr, Xoh_wtr_ctx.Basic, page);
Write_page_by_tid(view_mode, bfr, fmtr, page_bfr.To_bry_and_rls());
if (page_mode == Xopg_page_.Tid_html) // if html, write page again, but wrap it in html skin this time
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Html_utl.Escape_html_as_bry(bfr.To_bry_and_clear()));
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(bfr.To_bry_and_clear()));
wdata_lang_wtr.Page_(null);
}
}

View File

@@ -23,7 +23,7 @@ public class Xoh_page_wtr_wkr_ {
public static byte[] Bld_page_content_sub(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Bry_bfr tmp_bfr) {
byte[] subpages = app.Html_mgr().Page_mgr().Subpages_bldr().Bld(wiki.Ns_mgr(), page.Ttl());
byte[] page_content_sub = page.Html_data().Content_sub(); // contentSub exists; SEE: {{#isin}}
byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page);
byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page.Redirected_ttls());
return Bry_.Add(subpages, page_content_sub, redirect_msg);
}
public static byte[] Bld_page_name(Bry_bfr tmp_bfr, Xoa_ttl ttl, byte[] display_ttl) {
@@ -38,7 +38,7 @@ public class Xoh_page_wtr_wkr_ {
public static void Bld_head_end(Bry_bfr html_bfr, Xoae_page page) {
byte[] head_end = page.Html_data().Custom_head_end();
if (head_end == null) return;
int insert_pos = Bry_find_.Find_fwd(html_bfr.Bfr(), Html_tag_.Head_rhs);
int insert_pos = Bry_find_.Find_fwd(html_bfr.Bfr(), Gfh_tag_.Head_rhs);
if (insert_pos == Bry_find_.Not_found) {
Gfo_usr_dlg_.Instance.Warn_many("", "", "could not find </head>");
return;
@@ -48,7 +48,7 @@ public class Xoh_page_wtr_wkr_ {
public static void Bld_html_end(Bry_bfr html_bfr, Xoae_page page) {
byte[] html_end = page.Html_data().Custom_html_end();
if (html_end == null) return;
int insert_pos = Bry_find_.Find_bwd(html_bfr.Bfr(), Html_tag_.Html_rhs, html_bfr.Len());
int insert_pos = Bry_find_.Find_bwd(html_bfr.Bfr(), Gfh_tag_.Html_rhs, html_bfr.Len());
if (insert_pos == Bry_find_.Not_found) {
Gfo_usr_dlg_.Instance.Warn_many("", "", "could not find </html>");
return;

View File

@@ -43,9 +43,9 @@ public class Xohp_ctg_grp_mgr {
grp_fmtr.Bld_bfr_many(bfr, categories_lbl, itm_mgr);
}
}
class Xoh_ctg_itm_fmtr extends gplx.core.brys.Bfr_arg_base {
class Xoh_ctg_itm_fmtr implements gplx.core.brys.Bfr_arg {
public void Set(Xoae_page page, Bry_fmtr itm_fmtr) {this.page = page; this.itm_fmtr = itm_fmtr;} private Xoae_page page; Bry_fmtr itm_fmtr;
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
int ctgs_len = page.Category_list().length;
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
Bry_bfr tmp_href = Xoa_app_.Utl__bfr_mkr().Get_b128();

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
import gplx.core.brys.fmtrs.*;
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
public class Dbui_cells_fmtr extends gplx.core.brys.Bfr_arg_base {
public class Dbui_cells_fmtr implements gplx.core.brys.Bfr_arg {
private final Dbui_cell_fmtr cell_fmtr = new Dbui_cell_fmtr();
private final Dbui_btn_fmtr btn_fmtr = new Dbui_btn_fmtr();
private Dbui_btn_itm[] btns;
@@ -30,7 +30,7 @@ public class Dbui_cells_fmtr extends gplx.core.brys.Bfr_arg_base {
this.row_key = row_key; this.row_itm = row_itm;
return this;
}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
fmtr.Bld_bfr_many(bfr, cell_fmtr.Init(row_key, row_itm), btn_fmtr.Init(row_key, btns));
}
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
@@ -40,12 +40,12 @@ public class Dbui_cells_fmtr extends gplx.core.brys.Bfr_arg_base {
, " </div>"
), "vals", "btns");
}
class Dbui_cell_fmtr extends gplx.core.brys.Bfr_arg_base {
class Dbui_cell_fmtr implements gplx.core.brys.Bfr_arg {
private byte[] row_key; private Dbui_row_itm row_itm;
private Dbui_val_fmtr val_fmtr;
public void Ctor(Dbui_val_fmtr val_fmtr) {this.val_fmtr = val_fmtr;}
public Dbui_cell_fmtr Init(byte[] row_key, Dbui_row_itm row_itm) {this.row_key = row_key; this.row_itm = row_itm; return this;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
Dbui_col_itm[] cols = row_itm.Tbl().Cols();
Dbui_val_itm[] vals = row_itm.Vals(); int len = vals.length;
for (int i = 0; i < len; ++i) {
@@ -58,12 +58,12 @@ class Dbui_cell_fmtr extends gplx.core.brys.Bfr_arg_base {
, " <div class='xo_cell'>~{html}</div>"
), "row_key", "val_idx", "html");
}
class Dbui_btn_fmtr extends gplx.core.brys.Bfr_arg_base {
class Dbui_btn_fmtr implements gplx.core.brys.Bfr_arg {
private byte[] row_key; private Dbui_btn_itm[] btns;
public Dbui_btn_fmtr Init(byte[] row_key, Dbui_btn_itm[] btns) {
this.row_key = row_key; this.btns = btns; return this;
}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
int len = btns.length;
Io_url img_dir = gplx.xowa.htmls.heads.Xoh_head_itm__dbui.Img_dir();
for (int i = 0; i < len; ++i) {

View File

@@ -33,10 +33,10 @@ public class Dbui_tbl_fmtr {
, "</div>"
), "tbl_key", "width", "origin", "delete_confirm_msg", "head_cells", "data_rows");
}
class Dbui_head_cell_fmtr extends gplx.core.brys.Bfr_arg_base {
class Dbui_head_cell_fmtr implements gplx.core.brys.Bfr_arg {
private Dbui_tbl_itm tbl;
public Dbui_head_cell_fmtr Init(Dbui_tbl_itm tbl) {this.tbl = tbl; return this;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
Dbui_col_itm[] cols = tbl.Cols(); int len = cols.length;
for (int i = 0; i < len; ++i) {
Dbui_col_itm col = cols[i];
@@ -49,13 +49,13 @@ class Dbui_head_cell_fmtr extends gplx.core.brys.Bfr_arg_base {
, " <div class='xo_head xo_resizable_col' style='width:~{width}px;'>~{display}</div>"
), "width", "display");
}
class Dbui_row_fmtr extends gplx.core.brys.Bfr_arg_base {
class Dbui_row_fmtr implements gplx.core.brys.Bfr_arg {
private final Dbui_cells_fmtr cells_fmtr = new Dbui_cells_fmtr();
private final Dbui_val_fmtr val_fmtr = Dbui_val_fmtr_.new_view();
private final Bry_bfr row_key_bfr = Bry_bfr.new_(255);
private Dbui_tbl_itm tbl; private Dbui_row_itm[] rows;
public Dbui_row_fmtr Init(Dbui_tbl_itm tbl, Dbui_row_itm[] rows) {this.tbl = tbl; this.rows = rows; return this;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
byte[] tbl_key = tbl.Key();
int len = rows.length;
cells_fmtr.Ctor(val_fmtr, tbl.View_btns());

View File

@@ -21,17 +21,17 @@ import gplx.xowa.htmls.bridges.dbuis.tbls.*;
public interface Dbui_val_fmtr {
Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val);
}
class Dbui_val_fmtr__view extends gplx.core.brys.Bfr_arg_base implements Dbui_val_fmtr {
class Dbui_val_fmtr__view implements gplx.core.brys.Bfr_arg, Dbui_val_fmtr {
private Dbui_val_itm val;
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.val = val; return this;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
bfr.Add(val.Html());
}
}
class Dbui_val_fmtr__edit extends gplx.core.brys.Bfr_arg_base implements Dbui_val_fmtr {
class Dbui_val_fmtr__edit implements gplx.core.brys.Bfr_arg, Dbui_val_fmtr {
private Dbui_col_itm col; private byte[] row_id; private Dbui_val_itm val;
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.col = col; this.row_id = row_id; this.val = val; return this;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
public void Bfr_arg__add(Bry_bfr bfr) {
switch (col.Type()) {
case Dbui_col_itm.Type_id_str: input_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
case Dbui_col_itm.Type_id_text: textarea_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;

View File

@@ -23,6 +23,7 @@ import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
public class Xow_hdump_mgr__load {
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
private Hash_adp_bry page_overrides;
public Xow_hdump_mgr__load(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg; this.tmp_bfr = tmp_bfr;
this.make_mgr = new Xoh_make_mgr(wiki.App().Usr_dlg(), wiki.App().Fsys_mgr(), gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx, wiki.Domain_bry());
@@ -36,12 +37,13 @@ public class Xow_hdump_mgr__load {
}
public boolean Load(Xoh_page hpg, Xoa_ttl ttl) {
synchronized (tmp_dbpg) {
if (page_overrides == null) page_overrides = Init_page_overrides(wiki);
if (!Load__dbpg(wiki, tmp_dbpg.Clear(), hpg, ttl)) return Load__fail(hpg); // nothing in "page" table
Xowd_db_file html_db = wiki.Data__core_mgr().Dbs__get_at(tmp_dbpg.Html_db_id());
hpg.Init(hpg.Wiki(), hpg.Url(), ttl, tmp_dbpg.Id());
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html_page" table
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html_page" table
byte[] src = Parse(hpg, hpg.Body_zip_tid(), hpg.Body_hzip_tid(), hpg.Body());
hpg.Body_(make_mgr.Parse(src, hpg, hpg.Wiki()));
hpg.Body_(src);
return true;
}
}
@@ -49,8 +51,15 @@ public class Xow_hdump_mgr__load {
private byte[] Parse(Xoh_page hpg, int zip_tid, int hzip_tid, byte[] src) {
if (zip_tid > gplx.core.ios.Io_stream_.Tid_raw)
src = zip_mgr.Unzip((byte)zip_tid, src);
if (hzip_tid == Xoh_hzip_dict_.Hzip__v1)
if (hzip_tid == Xoh_hzip_dict_.Hzip__v1) {
byte[] page_override_src = (byte[])page_overrides.Get_by_bry(hpg.Ttl().Page_db());
if (page_override_src != null) src = page_override_src;
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
src = Decode_as_bry(tmp_bfr.Clear(), hpg, src, Bool_.N);
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length);
}
else
src = make_mgr.Parse(src, hpg, hpg.Wiki());
return src;
}
private void Fill_page(Xoae_page wpg, Xoh_page hpg) {
@@ -79,4 +88,19 @@ public class Xow_hdump_mgr__load {
if (redirect_id == -1) break;
}
}
private static Hash_adp_bry Init_page_overrides(Xow_wiki wiki) {
Hash_adp_bry rv = Hash_adp_bry.cs();
Io_url[] page_urls = Io_mgr.Instance.QueryDir_fils(wiki.Fsys_mgr().Root_dir().GenSubDir_nest("data", "page"));
int page_urls_len = page_urls.length;
for (int i = 0; i < page_urls_len; ++i) {
Io_url page_url = page_urls[i];
byte[] page_raw = Io_mgr.Instance.LoadFilBry(page_url);
int page_raw_len = page_raw.length;
int page_nl = Bry_find_.Find_fwd(page_raw, Byte_ascii.Nl, 0, page_raw_len); if (page_nl == Bry_find_.Not_found) continue;
byte[] page_ttl_bry = Bry_.Mid(page_raw, 0, page_nl);
byte[] page_src_bry = Bry_.Mid(page_raw, page_nl + 1, page_raw_len);
rv.Add_bry_obj(page_ttl_bry, page_src_bry);
}
return rv;
}
}

View File

@@ -35,7 +35,7 @@ public class Xow_hdump_mgr__load_tst {
// ( "[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
// ( "<div class=\"thumb tright\">"
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" xowa_img='0' /></a>"
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" xowa_img='0' /></a>"
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
// , " test_caption"
// , " </div>"
@@ -49,7 +49,7 @@ public class Xow_hdump_mgr__load_tst {
// ( "[[File:A.oga|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
// ( "<div class=\"thumb tright\">"
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
// , " <div id=\"xowa_media_div\"><xowa_play id='0'/><xowa_info id='0'/>"
// , " <div class=\"xowa_media_div\"><xowa_play id='0'/><xowa_info id='0'/>"
// , " </div>"
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
// , " test_caption"
@@ -64,10 +64,10 @@ public class Xow_hdump_mgr__load_tst {
// ( "[[File:A.ogv|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
// ( "<div class=\"thumb tright\">"
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
// , " <div id=\"xowa_media_div\">"
// , " <div class=\"xowa_media_div\">"
// , " <div>"
// , " <a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\">"
// , " <img id=\"xowa_file_img_0\" xowa_img='0' alt=\"\" />"
// , " <img id=\"xoimg_0\" xowa_img='0' alt=\"\" />"
// , " </a>"
// , " </div><xowa_play id='0'/>"
// , " </div>"
@@ -93,7 +93,7 @@ public class Xow_hdump_mgr__load_tst {
// , " <div xowa_gly_box_w='0'>"
// , " <div class=\"thumb\" style=\"width: 150px;\">"
// , " <div xowa_gly_img_pad='0'>"
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" xowa_img='0' /></a>"
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" xowa_img='0' /></a>"
// , " </div>"
// , " </div>"
// , " <div class=\"gallerytext\"><p>A1"

View File

@@ -50,7 +50,7 @@ public class Xob_link_dump_cmd {
tbl.Create_idx_2();
conn.Env_vacuum();
} catch (Exception e) {
Tfds.Write(Err_.Message_gplx_full(e));
Tfds.Dbg(Err_.Message_gplx_full(e));
}
}
}

View File

@@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.btries.*
import gplx.langs.htmls.*; import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.parsers.vnts.*; import gplx.xowa.parsers.htmls.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.parsers.hdrs.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.xtns.cites.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.parsers.hdrs.*;
import gplx.xowa.htmls.core.*;
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*;
public class Xoh_html_wtr {
@@ -114,18 +114,18 @@ public class Xoh_html_wtr {
if (literal_apos > 0)
bfr.Add_byte_repeat(Byte_ascii.Apos, literal_apos);
switch (apos.Apos_cmd()) {
case Xop_apos_tkn_.Cmd_b_bgn: bfr.Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_b_end: bfr.Add(Html_tag_.B_rhs); break;
case Xop_apos_tkn_.Cmd_i_bgn: bfr.Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_i_end: bfr.Add(Html_tag_.I_rhs); break;
case Xop_apos_tkn_.Cmd_bi_bgn: bfr.Add(Html_tag_.B_lhs).Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_ib_end: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_rhs); break;
case Xop_apos_tkn_.Cmd_ib_bgn: bfr.Add(Html_tag_.I_lhs).Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_bi_end: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_rhs);; break;
case Xop_apos_tkn_.Cmd_bi_end__b_bgn: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_rhs).Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_ib_end__i_bgn: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_rhs).Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_b_end__i_bgn: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_i_end__b_bgn: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_b_bgn: bfr.Add(Gfh_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_b_end: bfr.Add(Gfh_tag_.B_rhs); break;
case Xop_apos_tkn_.Cmd_i_bgn: bfr.Add(Gfh_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_i_end: bfr.Add(Gfh_tag_.I_rhs); break;
case Xop_apos_tkn_.Cmd_bi_bgn: bfr.Add(Gfh_tag_.B_lhs).Add(Gfh_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_ib_end: bfr.Add(Gfh_tag_.I_rhs).Add(Gfh_tag_.B_rhs); break;
case Xop_apos_tkn_.Cmd_ib_bgn: bfr.Add(Gfh_tag_.I_lhs).Add(Gfh_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_bi_end: bfr.Add(Gfh_tag_.B_rhs).Add(Gfh_tag_.I_rhs);; break;
case Xop_apos_tkn_.Cmd_bi_end__b_bgn: bfr.Add(Gfh_tag_.B_rhs).Add(Gfh_tag_.I_rhs).Add(Gfh_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_ib_end__i_bgn: bfr.Add(Gfh_tag_.I_rhs).Add(Gfh_tag_.B_rhs).Add(Gfh_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_b_end__i_bgn: bfr.Add(Gfh_tag_.B_rhs).Add(Gfh_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_i_end__b_bgn: bfr.Add(Gfh_tag_.I_rhs).Add(Gfh_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_nil: break;
default: throw Err_.new_unhandled(apos.Apos_cmd());
}
@@ -466,9 +466,9 @@ public class Xoh_html_wtr {
break;
default:
byte[] tag_name = sub_xnde.Tag().Name_bry();
bfr.Add(Html_entity_.Lt_bry).Add(tag_name);
bfr.Add(Gfh_entity_.Lt_bry).Add(tag_name);
if (xnde.Atrs_bgn() > Xop_tblw_wkr.Atrs_ignore_check) Xnde_atrs(sub_xnde.Tag().Id(), hctx, src, sub_xnde.Atrs_bgn(), sub_xnde.Atrs_end(), xnde.Atrs_ary(), bfr);
bfr.Add(Html_entity_.Gt_bry);
bfr.Add(Gfh_entity_.Gt_bry);
break;
}
Xnde_subs_escape(ctx, hctx, bfr, src, sub_xnde, amp_enable, false);

View File

@@ -40,17 +40,17 @@ public class Xoh_html_wtr_escaper {
}
}
}
bfr.Add(Html_entity_.Lt_bry);
bfr.Add(Gfh_entity_.Lt_bry);
break;
case Byte_ascii.Gt:
bfr.Add(Html_entity_.Gt_bry);
bfr.Add(Gfh_entity_.Gt_bry);
break;
case Byte_ascii.Amp:
if (interpret_amp) {
int text_bgn = i + 1; // i is &; i + 1 is first char after amp
Object o = (text_bgn < end) ? amp_trie.Match_bgn(src, text_bgn, end) : null; // check if this is a valid &; note must check that text_bgn < end or else arrayIndex error; occurs when src is just "&"; DATE:2013-12-19
if (o == null) // invalid; EX: "a&b"; "&bad;"; "&#letters;";
bfr.Add(Html_entity_.Amp_bry); // escape & and continue
bfr.Add(Gfh_entity_.Amp_bry); // escape & and continue
else { // is either (1) a name or (2) an ncr (hex/dec)
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
int match_pos = amp_trie.Match_pos();
@@ -70,17 +70,17 @@ public class Xoh_html_wtr_escaper {
i = end_pos - 1;
}
else // parse failed; escape and continue
bfr.Add(Html_entity_.Amp_bry);
bfr.Add(Gfh_entity_.Amp_bry);
break;
default: throw Err_.new_unhandled(itm_tid);
}
}
}
else
bfr.Add(Html_entity_.Amp_bry);
bfr.Add(Gfh_entity_.Amp_bry);
break;
case Byte_ascii.Quote:
bfr.Add(Html_entity_.Quote_bry);
bfr.Add(Gfh_entity_.Quote_bry);
break;
default:
bfr.Add_byte(b);
@@ -103,7 +103,7 @@ public class Xoh_html_wtr_escaper {
if ( tag_is_bgn // <nowiki < found
|| (i + nowiki_name_len + 2 > end) // not enough chars for "/nowiki>"
|| src[i + 1] != Byte_ascii.Slash // /
|| !Bry_.Eq(src, i + 2, i + 2 + nowiki_name_len, nowiki_name) // nowiki
|| !Bry_.Eq(src, i + 2, i + 2 + nowiki_name_len, nowiki_name) // nowiki
|| src[i + 2 + nowiki_name_len] != Byte_ascii.Gt // >
) return Bry_find_.Not_found;
end_lt = i;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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 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("----" , "<hr/>");}
@Test public void Hr_extended() {fxt.Test_parse_page_wiki_str("--------" , "<hr/>");}

View File

@@ -65,9 +65,9 @@ public class Xoh_tidy_mgr implements GfoInvkAble {
}
public static boolean Tidy_unwrap(Bry_bfr bfr) {
byte[] bfr_bry = bfr.Bfr();
int find = Bry_find_.Find_fwd(bfr_bry, Html_tag_.Body_lhs); if (find == Bry_find_.Not_found) return false;
bfr.Delete_rng_to_bgn(find + Html_tag_.Body_lhs.length);
find = Bry_find_.Find_bwd(bfr_bry, Html_tag_.Body_rhs, bfr.Len()); if (find == Bry_find_.Not_found) return false;
int find = Bry_find_.Find_fwd(bfr_bry, Gfh_tag_.Body_lhs); if (find == Bry_find_.Not_found) return false;
bfr.Delete_rng_to_bgn(find + Gfh_tag_.Body_lhs.length);
find = Bry_find_.Find_bwd(bfr_bry, Gfh_tag_.Body_rhs, bfr.Len()); if (find == Bry_find_.Not_found) return false;
bfr.Delete_rng_to_end(find);
return true;
}

View File

@@ -38,7 +38,7 @@ public class Xoh_anchor_kv_bldr {
tmp_bfr.Add_byte(has_qarg ? Byte_ascii.Amp : Byte_ascii.Question);
tmp_bfr.Add(key);
tmp_bfr.Add_byte(Byte_ascii.Eq);
tmp_bfr.Add(Html_utl.Escape_for_atr_val_as_bry(apos_bfr, Byte_ascii.Apos, bry));
tmp_bfr.Add(Gfh_utl.Escape_for_atr_val_as_bry(apos_bfr, Byte_ascii.Apos, bry));
return this;
}
public byte[] Bld_to_bry() {

View File

@@ -32,7 +32,7 @@ public class Xoh_lnki_bldr {
img_pos_is_left = true;
return this;
}
public Xoh_lnki_bldr Id_(byte[] v) {this.id = Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, v); return this;}
public Xoh_lnki_bldr Id_(byte[] v) {this.id = Gfh_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, v); return this;}
public Xoh_lnki_bldr Href_(Xow_wiki wiki, byte[] bry) {return Href_(wiki.Domain_bry(), wiki.Ttl_parse(bry));}
public Xoh_lnki_bldr Href_(byte[] domain_bry, Xoa_ttl ttl) {
href_wtr.Build_to_bfr(tmp_bfr, app, Xoh_wtr_ctx.Mode_popup, domain_bry, ttl);
@@ -40,7 +40,7 @@ public class Xoh_lnki_bldr {
return this;
}
public Xoh_lnki_bldr Title_(byte[] title) {
this.title = Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, title);
this.title = Gfh_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, title);
return this;
}
public Xoh_lnki_bldr Img_pos_is_left_(boolean v) {this.img_pos_is_left = v; return this;}
@@ -52,7 +52,7 @@ public class Xoh_lnki_bldr {
return this;
}
public Xoh_lnki_bldr Caption_(byte[] text) {
this.caption = Html_utl.Escape_html_as_bry(tmp_bfr, text, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y);
this.caption = Gfh_utl.Escape_html_as_bry(tmp_bfr, text, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y);
return this;
}
public byte[] Bld_to_bry() {

View File

@@ -29,6 +29,6 @@ public class Xoh_lnki_wtr_utl {
return tmp_bfr.To_bry_and_clear();
}
public byte[] Bld_title(byte[] text) {
return gplx.langs.htmls.Html_utl.Escape_html_as_bry(tmp_bfr, text, Bool_.N, Bool_.N, Bool_.N, Bool_.Y, Bool_.Y);
return gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(tmp_bfr, text, Bool_.N, Bool_.N, Bool_.N, Bool_.Y, Bool_.Y);
}
}

View File

@@ -0,0 +1,81 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.primitives.*; import gplx.core.encoders.*;
public class Gfo_decimal_parser {
public boolean Sign() {return sign;} private boolean sign;
public int Exponent() {return exponent;} private int exponent;
public long Number() {return number;} private long number;
public boolean Parse(byte[] src, int src_bgn, int src_end) {
sign = true;
number = 0;
exponent = 0;
if (src_end - src_bgn < 1) return false;
int pos = src_bgn;
int dot_offset = 0;
byte b = Byte_ascii.Null;
boolean loop = true;
while (loop) {
b = src[pos++];
switch (b) {
case Byte_ascii.Dash:
if (!sign) return false; // fail if "--"
sign = false; // keep looping; handle "-0.12"
++dot_offset;
break;
case Byte_ascii.Num_0:
b = src[pos++];
if (b != Byte_ascii.Dot) return false; // fail if not "0."
++dot_offset;
loop = false;
break;
default:
loop = false;
break;
}
}
int dot_pos = -1;
boolean num_seen = false;
while (true) {
switch (b) {
case Byte_ascii.Dot:
if (dot_pos != -1) return false; // fail if multiple dots
dot_pos = pos - src_bgn - dot_offset - 1; // pos already advanced forward one
break;
case Byte_ascii.Num_0:
if (num_seen)
number *= 10;
break;
case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
if (!num_seen) num_seen = true; // save first "number"; for "0.00001" where num will be 0 and left shift will be 5
number *= 10;
number += b - Byte_ascii.Num_0;
break;
}
if (pos == src_end) break;
b = src[pos];
++pos;
}
switch (dot_pos) {
case -1: exponent = 0; break;
default: exponent = dot_pos + dot_offset - src_end + 1; break;
}
return true;
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import org.junit.*;
public class Gfo_decimal_parser_tst {
private final Gfo_decimal_parser_fxt fxt = new Gfo_decimal_parser_fxt();
@Test public void Positive() {
fxt.Test__parse("123" , Bool_.Y, 0, 123);
fxt.Test__parse("12.3" , Bool_.Y, -1, 123);
fxt.Test__parse("1.23" , Bool_.Y, -2, 123);
fxt.Test__parse(".123" , Bool_.Y, -3, 123);
fxt.Test__parse("0.123" , Bool_.Y, -3, 123);
}
@Test public void Negative() {
fxt.Test__parse("-123" , Bool_.N, 0, 123);
fxt.Test__parse("-12.3" , Bool_.N, -1, 123);
fxt.Test__parse("-1.23" , Bool_.N, -2, 123);
fxt.Test__parse("-.123" , Bool_.N, -3, 123);
fxt.Test__parse("-0.123" , Bool_.N, -3, 123);
}
}
class Gfo_decimal_parser_fxt {
private final Gfo_decimal_parser bicoder = new Gfo_decimal_parser();
public void Test__parse(String src_str, boolean expd_sign, int expd_exponent, long expd_number) {
byte[] src_bry = Bry_.new_u8(src_str);
bicoder.Parse(src_bry, 0, src_bry.length);
Tfds.Eq_bool(expd_sign, bicoder.Sign());
Tfds.Eq_int(expd_exponent, bicoder.Exponent());
Tfds.Eq_long(expd_number, bicoder.Number());
}
}

View File

@@ -0,0 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.wkrs.*; import gplx.core.threads.poolables.*;
public interface Xoh_data_itm extends Gfo_poolable_itm {
int Tid();
int Src_bgn();
int Src_end();
void Clear();
boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag cur, Gfh_tag nxt);
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.primitives.*; import gplx.core.encoders.*;
public class Xoh_hzip_decimal {
private final Gfo_decimal_parser decimal_parser = new Gfo_decimal_parser();
public boolean Encode(Bry_bfr bfr, byte[] src, int src_bgn, int src_end) {
if (!decimal_parser.Parse(src, src_bgn, src_end)) return false;
// if (positive && dot_pos == -1 && num_val < 128) {
// bfr.Add_byte((byte)(num_val + 128));
// }
return true;
/*
0.001000
1:size_is_1
1:exp.neg
6:exp.val
5:exp.val
1:num.neg
7:num.val; 111-127 for extended bits
8:num.val
8:num.val
127
125 2
126 3
127 4
*/
}
}

View File

@@ -18,8 +18,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.primitives.*; import gplx.core.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_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__escape = 1
, Tid__xnde = 2
, Tid__lnke = 3
, Tid__lnki = 4
, Tid__hdr = 5
, Tid__img = 6
, Tid__thm = 7
, Tid__gly = 8
, Tid__img_bare = 9
;
public static final String
Key__escape = "escape"
, Key__hdr = "hdr"
@@ -29,6 +41,7 @@ public class Xoh_hzip_dict_ {
, Key__thm = "thm"
, Key__gly = "gly"
, Key__xnde = "xnde"
, Key__img_bare = "img_bare"
;
public static final int Hzip__none = 0, Hzip__v1 = 1;
}

View File

@@ -126,7 +126,7 @@ public class Xoh_hzip_int {
val -= tmp * div;
}
}
private static int To_int_by_bry(byte[] src, int bgn, int end, byte offset, int radix) {
public static int To_int_by_bry(byte[] src, int bgn, int end, byte offset, int radix) {
int rv = 0, factor = 1;
for (int i = end - 1; i >= bgn; --i) {
rv += ((src[i] & 0xFF) - offset) * factor; // PATCH.JAVA:need to convert to unsigned byte
@@ -140,7 +140,7 @@ public class Xoh_hzip_int {
, B256__max__expd__3 = 16777216 // 16,777,216
;
private static final int[] B256__pow__ary = new int[] {1, B256__max__expd__1, B256__max__expd__2, B256__max__expd__3, Int_.Max_value};
private static final byte prefix__b256__2 = (byte)(252 & 0xFF), prefix__b256__3 = (byte)(253 & 0xFF), prefix__b256__4 = (byte)(254 & 0xFF), prefix__b256__5 = (byte)(255 & 0xFF);
public static final byte prefix__b256__2 = (byte)(252 & 0xFF), prefix__b256__3 = (byte)(253 & 0xFF), prefix__b256__4 = (byte)(254 & 0xFF), prefix__b256__5 = (byte)(255 & 0xFF);
private static final byte[]
prefix_ary__b256 = new byte[] {0, 0, prefix__b256__2, prefix__b256__3, prefix__b256__4, prefix__b256__5}
, prefix_ary__b085 = new byte[] {0, 0, 0, Byte_ascii.Curly_bgn, Byte_ascii.Pipe, Byte_ascii.Curly_end, Byte_ascii.Tilde}

View File

@@ -17,19 +17,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.threads.poolables.*;
import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.*;
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);
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 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 Encode(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 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());
hdoc_parser.Parse(bfr, hpg, hctx, src);
@@ -38,14 +39,14 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
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);
Decode(bfr, hdoc_wkr, hctx, hpg, Bool_.Y, rdr, src, 0, src_len);
Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src_len, null);
}
public int Decode(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, Bry_rdr rdr, byte[] src, int src_bgn, int src_end) {
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;
while (true) {
if (pos == src_end) break;
byte b = src[pos];
Object o = hctx.Wkr_mkr().Get(b, src, pos, src_end);
Object o = hctx.Pool_mgr__hzip().Get(b, src, pos, src_end);
if (o == null) {
if (txt_bgn == -1) txt_bgn = pos;
++pos;
@@ -53,19 +54,27 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
else {
if (txt_bgn != -1) {bfr.Add_mid(src, txt_bgn, pos); txt_bgn = -1;} // handle pending txt
Xoh_hzip_wkr wkr = (Xoh_hzip_wkr)o;
int hook_len = wkr.Hook().length;
try {
rdr.Init_by_sect(wkr.Key(), pos, pos + 2);
wkr.Decode(bfr, hdoc_wkr, hctx, hpg, Bool_.Y, rdr, src, pos, src_end);
rdr.Init_by_sect(wkr.Key(), pos, pos + hook_len);
Xoh_data_itm data = hctx.Pool_mgr__data().Get_by_tid(wkr.Tid());
wkr.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, pos, src_end, data);
Xoh_wtr_itm wtr = hctx.Pool_mgr__wtr().Get_by_tid(wkr.Tid());
if (data != null && wtr != null) {
wtr.Init_by_decode(hpg, hctx, src, data);
wtr.Bfr_arg__add(bfr);
}
if (data != null) data.Pool__rls();
if (wtr != null) wtr.Pool__rls();
pos = rdr.Pos();
} catch (Exception e) {
gplx.langs.htmls.Html_utl.Log(e, "hzip decode failed", hpg.Url_bry_safe(), src, pos);
pos += 2; // 2: skip escape and hook
gplx.langs.htmls.Gfh_utl.Log(e, "hzip decode failed", hpg.Url_bry_safe(), src, pos);
pos += hook_len;
}
finally {wkr.Pool__rls();}
}
}
if (txt_bgn != -1) bfr.Add_mid(src, txt_bgn, src_end);
return 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_hzip_mgr rv = new Xoh_hzip_mgr(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}

View File

@@ -19,8 +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();
Gfo_poolable_itm Encode(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);
int Decode(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, Bry_rdr rdr, byte[] src, int src_bgn, int src_end);
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);
}

View File

@@ -0,0 +1,47 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.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.*;
public class Xoh_pool_mgr__data {
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare;//, pool__gly;
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());
}
public Xoh_data_itm Get_by_tid(int tid) {
Gfo_poolable_mgr pool = null;
switch (tid) {
case Xoh_hzip_dict_.Tid__hdr: pool = pool__hdr; break;
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;
default: return null;
}
return (Xoh_data_itm)pool.Get_fast();
}
private static Gfo_poolable_mgr New_pool(Gfo_poolable_itm proto) {
return Gfo_poolable_mgr_.New(1, 32, proto);
}
}

View File

@@ -18,41 +18,50 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.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.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.*;
public class Xoh_hzip_wkr_mgr {
public class Xoh_pool_mgr__hzip {
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
private Gfo_poolable_mgr mkr__escape, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly;
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare;
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();}
public Xoh_lnke_hzip Mw__lnke() {return (Xoh_lnke_hzip) mkr__lnke.Get_fast();}
public Xoh_lnki_hzip Mw__lnki() {return (Xoh_lnki_hzip) mkr__lnki.Get_fast();}
public Xoh_img_hzip Mw__img() {return (Xoh_img_hzip) mkr__img.Get_fast();}
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 void Init() {
this.Reg_all(false, Byte_ascii.Escape);
this.Reg_all(false, Hook__core, Hook__html, Hook__mw);
}
public Xoh_hzip_wkr Get(byte b, byte[] src, int src_bgn, int src_end) {
Object mgr_obj = trie.Match_bgn_w_byte(b, src, src_bgn, src_end); if (mgr_obj == null) return null;
Gfo_poolable_mgr mgr = (Gfo_poolable_mgr)mgr_obj;
return (Xoh_hzip_wkr)mgr.Get_fast();
}
private void Reg_all(boolean mode_is_b256, int escape__mw) {
mkr__escape = Reg(New_hook_len2(mode_is_b256, escape__mw, 84), new Xoh_escape_hzip());
mkr__hdr = Reg(New_hook_len2(mode_is_b256, escape__mw, 1), new Xoh_hdr_hzip());
mkr__lnke = Reg(New_hook_len2(mode_is_b256, escape__mw, 2), new Xoh_lnke_hzip());
mkr__lnki = Reg(New_hook_len2(mode_is_b256, escape__mw, 3), new Xoh_lnki_hzip());
mkr__img = Reg(New_hook_len2(mode_is_b256, escape__mw, 4), new Xoh_img_hzip());
mkr__thm = Reg(New_hook_len2(mode_is_b256, escape__mw, 5), new Xoh_thm_hzip());
mkr__gly = Reg(New_hook_len2(mode_is_b256, escape__mw, 6), new Xoh_gly_hzip());
private void Reg_all(boolean mode_is_b256, int hook__core, int hook__html, int hook__mw) {
mkr__escape = Reg(New_hook_len2(mode_is_b256, hook__core, 0) , new Xoh_escape_hzip());
mkr__xnde = Reg(New_hook_len1(mode_is_b256, hook__html) , new Xoh_xnde_hzip());
mkr__hdr = Reg(New_hook_len2(mode_is_b256, hook__mw , 1) , new Xoh_hdr_hzip());
mkr__lnke = Reg(New_hook_len2(mode_is_b256, hook__mw , 2) , new Xoh_lnke_hzip());
mkr__lnki = Reg(New_hook_len2(mode_is_b256, hook__mw , 3) , new Xoh_lnki_hzip());
mkr__img = Reg(New_hook_len2(mode_is_b256, hook__mw , 4) , new Xoh_img_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());
}
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));
trie.Add_obj(hook, rv);
return rv;
}
private static byte[] New_hook_len2(boolean mode_is_b256, int b0, int b1) {
return Bry_.new_ints(b0, mode_is_b256 ? b1 : b1 + Byte_ascii.Bang);
}
private static byte[] New_hook_len2(boolean mode_is_b256, int b0, int b1) {return Bry_.New_by_ints(b0, mode_is_b256 ? b1 : b1 + Byte_ascii.Bang);}
private static byte[] New_hook_len1(boolean mode_is_b256, int b0) {return Bry_.New_by_ints(b0);}
public static final byte
Hook__core = 1
, Hook__html = 2
, Hook__mw = 27
;
public static final byte[] Hooks_ary = new byte[] {Hook__core, Hook__html, Hook__mw};
}

View File

@@ -0,0 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.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.*;
public class Xoh_pool_mgr__wtr {
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare;
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());
}
public Xoh_wtr_itm Get_by_tid(int tid) {
Gfo_poolable_mgr pool = null;
switch (tid) {
case Xoh_hzip_dict_.Tid__hdr: pool = pool__hdr; break;
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;
default: return null;
}
return (Xoh_wtr_itm)pool.Get_fast();
}
private static Gfo_poolable_mgr New_pool(Gfo_poolable_itm proto) {
return Gfo_poolable_mgr_.New(1, 32, proto);
}
}

View File

@@ -0,0 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.brys.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.wkrs.*; import gplx.core.threads.poolables.*;
public interface Xoh_wtr_itm extends Bfr_arg, Gfo_poolable_itm {
boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm);
}

View File

@@ -100,33 +100,33 @@ public class Xoh_make_mgr {
byte[] a_href = Bry_.Add(Xoh_make_trie_.A_href_bgn, a_title);
try {
switch (tid) {
case Xoh_make_trie_.Tid__file_info: fmtr.Html_thumb_part_info (bfr, uid, a_href, cfg_file.Img_media_info_btn()); return rv;
case Xoh_make_trie_.Tid__file_info: fmtr.Html_thumb_part_info (bfr, uid, true, a_href, cfg_file.Img_media_info_btn()); return rv;
case Xoh_make_trie_.Tid__file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, cfg_file.Img_thumb_magnify()); return rv;
case Xoh_make_trie_.Tid__file_play: fmtr.Html_thumb_part_play (bfr, uid, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, cfg_file.Img_media_play_btn()); return rv;
case Xoh_make_trie_.Tid__file_play: fmtr.Html_thumb_part_play (bfr, uid, true, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, cfg_file.Img_media_play_btn()); return rv;
case Xoh_make_trie_.Tid__gallery_box_max: {
Xohd_img_itm__gallery_mgr gly = (Xohd_img_itm__gallery_mgr)hpg.Gallery_itms().Get_by(uid);
if (gly != null) { // -1 means no box_max
byte[] style = Gallery_mgr_base.box_style_max_width_fmtr.Bld_bry_many(tmp_bfr, gly.Box_max());
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Bry__style, style);
byte[] style = Gallery_html_wtr_.Fmtr__ul__style.Bld_bry_many(tmp_bfr, gly.Box_max());
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
}
return rv;
}
case Xoh_make_trie_.Tid__gallery_box_w: {
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
byte[] style = Gallery_mgr_base.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Box_w());
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Bry__style, style);
byte[] style = Gallery_html_wtr_.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Box_w());
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
return rv;
}
case Xoh_make_trie_.Tid__gallery_img_w: {
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
byte[] style = Gallery_mgr_base.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Img_w());
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Bry__style, style);
byte[] style = Gallery_html_wtr_.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Img_w());
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
return rv;
}
case Xoh_make_trie_.Tid__gallery_img_pad: {
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
byte[] style = Gallery_mgr_base.hdump_img_pad_fmtr.Bld_bry_many(tmp_bfr, gly.Img_pad());
Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Bry__style, style);
byte[] style = Gallery_html_wtr_.hdump_img_pad_fmtr.Bld_bry_many(tmp_bfr, gly.Img_pad());
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
return rv;
}
}

View File

@@ -30,7 +30,7 @@ public class Xoh_make_trie_ {
, Bry__file_play = Bry_.new_a7("<xowa_play id='")
, Bry__file_info = Bry_.new_a7("<xowa_info id='")
, Bry__file_mgnf = Bry_.new_a7("<xowa_mgnf id=\"")
, Bry__hiero_dir = Bry_.new_a7("~{xowa_hiero_dir}")
// , Bry__hiero_dir = Bry_.new_a7("~{xowa_hiero_dir}")
// , Bry__gallery_box_max = Bry_.new_a7("xowa_gly_box_max='")
// , Bry__gallery_box_w = Bry_.new_a7("xowa_gly_box_w='")
// , Bry__gallery_img_w = Bry_.new_a7("xowa_gly_img_w='")
@@ -50,7 +50,7 @@ public class Xoh_make_trie_ {
trie_itm(rv, Tid__file_play , Byte_ascii.Apos , Bry__file_play);
trie_itm(rv, Tid__file_info , Byte_ascii.Apos , Bry__file_info);
trie_itm(rv, Tid__file_mgnf , Byte_ascii.Apos , Bry__file_mgnf);
trie_itm(rv, Tid__hiero_dir , Byte_ascii.Escape , Bry__hiero_dir);
// trie_itm(rv, Tid__hiero_dir , Byte_ascii.Escape , Bry__hiero_dir);
// trie_itm(rv, Tid__gallery_box_max , Byte_ascii.Apos , Bry__gallery_box_max);
// trie_itm(rv, Tid__gallery_box_w , Byte_ascii.Apos , Bry__gallery_box_w);
// trie_itm(rv, Tid__gallery_img_w , Byte_ascii.Apos , Bry__gallery_img_w);

View File

@@ -37,7 +37,8 @@ public class Xoh_make_fxt {
}
public void Test__html(String wtxt, String expd) {
expd = String_.Replace(expd, "'", "\"");
Tfds.Eq_str_lines(expd, parser_fxt.Exec__parse_to_hdump(wtxt));
String actl = parser_fxt.Exec__parse_to_hdump(wtxt);
Tfds.Eq_str_lines(expd, actl);
}
public void Test__make(String html, Xoh_page_chkr chkr) {
html = String_.Replace(html, "'", "\"");

View File

@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.xowa.apps.urls.*;
import gplx.xowa.htmls.core.hzips.*;
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.xndes.tags.*; import gplx.xowa.htmls.core.wkrs.xndes.dicts.*;
import gplx.xowa.files.*; import gplx.xowa.apps.fsys.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.metas.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.metas.*;
public class Xoh_hdoc_ctx {
private byte[] fsys__file;
public byte[] Fsys__root() {return fsys__root;} private byte[] fsys__root;
@@ -32,10 +32,15 @@ public class Xoh_hdoc_ctx {
public boolean Xwiki_mgr__missing(byte[] domain){return app.Xwiki_mgr__missing(domain);}
public Xoa_file_mgr File__mgr() {return file__mgr;} private final Xoa_file_mgr file__mgr = new Xoa_file_mgr();
public Xof_url_bldr File__url_bldr() {return file__url_bldr;} private final Xof_url_bldr file__url_bldr = new Xof_url_bldr();
public Xoh_hzip_wkr_mgr Wkr_mkr() {return wkr_mgr;} private final Xoh_hzip_wkr_mgr wkr_mgr = new Xoh_hzip_wkr_mgr();
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();
public Xoh_pool_mgr__wtr Pool_mgr__wtr() {return pool_mgr__wtr;} private final Xoh_pool_mgr__wtr pool_mgr__wtr = new Xoh_pool_mgr__wtr();
public Xoh_stat_itm Hzip__stat() {return hzip__stat;} private final Xoh_stat_itm hzip__stat = new Xoh_stat_itm();
public int Lnki__uid__nxt() {return ++lnki__uid;} private int lnki__uid; // NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
public Xohz_tag_regy Hzip__xnde__regy() {return hzip__xnde__regy;} private final Xohz_tag_regy hzip__xnde__regy = Xohz_tag_regy_.New_dflt();
public Xoh_xnde_dict_reg Hzip__xnde__dict() {return hzip__xnde__dict;} private final Xoh_xnde_dict_reg hzip__xnde__dict = new Xoh_xnde_dict_reg();
public int Uid__lnki_nxt() {return ++uid__lnki;} private int uid__lnki;
public int Uid__gly__nxt() {return ++uid__gly;} private int uid__gly;
public boolean Mode_is_diff() {return mode_is_diff;} private boolean mode_is_diff; public void Mode_is_diff_(boolean v) {mode_is_diff = v;}
public void Init_by_app(Xoa_app app) {
Xoa_fsys_mgr fsys_mgr = app.Fsys_mgr();
@@ -43,7 +48,7 @@ public class Xoh_hdoc_ctx {
this.fsys__root = fsys_mgr.Root_dir().To_http_file_bry();
this.fsys__file = fsys_mgr.File_dir().To_http_file_bry();
this.fsys__file__comm = Bry_.Add(fsys__file, Xow_domain_itm_.Bry__commons, Byte_ascii.Slash_bry);
wkr_mgr.Init();
pool_mgr__hzip.Init();
}
public void Init_by_page(Xow_wiki wiki, byte[] page_url) {
if (fsys__root == null) Init_by_app(wiki.App()); // LAZY INIT
@@ -56,7 +61,8 @@ public class Xoh_hdoc_ctx {
}
private void Clear() {
hzip__stat.Clear();
this.lnki__uid = 1; // NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
this.uid__lnki = 1; // NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
this.uid__gly = -1;
}
public static final int Invalid = -1;
}

View File

@@ -16,19 +16,22 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.langs.htmls.parsers.*; import gplx.xowa.wikis.ttls.*;
import gplx.langs.htmls.docs.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.wkrs.tags.*; import gplx.xowa.htmls.core.wkrs.txts.*; import gplx.xowa.htmls.core.wkrs.escapes.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_hdoc_parser {
private final Xoh_hdoc_wkr hdoc_wkr;
private final Html_doc_parser hdoc_parser;
private final Gfh_doc_parser hdoc_parser;
private final Xoh_tag_parser tag_parser;
public Xoh_hdoc_parser(Xoh_hdoc_wkr hdoc_wkr) {
this.hdoc_wkr = hdoc_wkr;
this.tag_parser = new Xoh_tag_parser(hdoc_wkr);
this.hdoc_parser = new Html_doc_parser(new Xoh_txt_parser(hdoc_wkr)
, tag_parser
, new Xoh_escape_data(hdoc_wkr)
);
int wkr_ary_len = Xoh_pool_mgr__hzip.Hooks_ary.length + 1;
Gfh_doc_wkr[] wkr_ary = new Gfh_doc_wkr[wkr_ary_len];
wkr_ary[0] = tag_parser;
for (int i = 1; i < wkr_ary_len; ++i)
wkr_ary[i] = new Xoh_escape_data(hdoc_wkr, Xoh_pool_mgr__hzip.Hooks_ary[i - 1]);
this.hdoc_parser = new Gfh_doc_parser(new Xoh_txt_parser(hdoc_wkr), wkr_ary);
}
public void Parse(Xoh_hzip_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src) {
int src_len = src.length;

View File

@@ -16,16 +16,16 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.langs.htmls.parsers.*;
import gplx.langs.htmls.docs.*;
import gplx.xowa.wikis.ttls.*;
import gplx.xowa.htmls.core.hzips.*;
public interface Xoh_hdoc_wkr {
void On_new_page(Xoh_hzip_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end);
void On_escape (int rng_bgn, int rng_end);
void On_txt (int rng_bgn, int rng_end);
void On_hdr (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_parser parser);
void On_lnke (gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_parser parser);
void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser parser);
void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser parser);
void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_parser parser);
void On_gly (gplx.xowa.htmls.core.wkrs.glys.Xoh_gly_grp_parser parser);
void On_escape (gplx.xowa.htmls.core.wkrs.escapes.Xoh_escape_data data);
void On_xnde (gplx.xowa.htmls.core.wkrs.xndes.Xoh_xnde_parser parser);
void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_data parser);
void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_data parser);
void On_gly (gplx.xowa.htmls.core.wkrs.glys.Xoh_gly_grp_data parser);
boolean Process_parse(Xoh_data_itm data);
}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.hzips.*;
import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.hzips.*;
import gplx.xowa.wikis.ttls.*;
public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
private final Xoh_stat_itm stat_itm = new Xoh_stat_itm();
@@ -27,11 +27,21 @@ public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
stat_itm.Clear();
}
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
public void On_escape (int rng_bgn, int rng_end) {hctx.Wkr_mkr().Mw__escape().Encode(bfr, this, hctx, hpg, Bool_.Y, src, null).Pool__rls();}
public void On_hdr (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_parser parser) {hctx.Wkr_mkr().Mw__hdr().Encode(bfr, this, hctx, hpg, Bool_.Y, src, parser).Pool__rls();}
public void On_lnke (gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_parser parser) {hctx.Wkr_mkr().Mw__lnke().Encode(bfr, this, hctx, hpg, Bool_.Y, src, parser).Pool__rls();}
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser parser) {hctx.Wkr_mkr().Mw__lnki().Encode(bfr, this, hctx, hpg, Bool_.Y, src, parser).Pool__rls();}
public void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser parser) {hctx.Wkr_mkr().Mw__img().Encode(bfr, this, hctx, hpg, Bool_.Y, src, parser).Pool__rls();}
public void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_parser parser) {hctx.Wkr_mkr().Mw__thm().Encode(bfr, this, hctx, hpg, Bool_.Y, src, parser).Pool__rls();}
public void On_gly (gplx.xowa.htmls.core.wkrs.glys.Xoh_gly_grp_parser parser) {hctx.Wkr_mkr().Mw__gly().Encode(bfr, this, hctx, hpg, Bool_.Y, src, parser).Pool__rls();}
public void On_escape (gplx.xowa.htmls.core.wkrs.escapes.Xoh_escape_data data) {hctx.Pool_mgr__hzip().Mw__escape().Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();}
public void On_xnde (gplx.xowa.htmls.core.wkrs.xndes.Xoh_xnde_parser data) {hctx.Pool_mgr__hzip().Mw__xnde().Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();}
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_data data) {hctx.Pool_mgr__hzip().Mw__lnki().Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();}
public void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_data data) {hctx.Pool_mgr__hzip().Mw__thm().Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();}
public void On_gly (gplx.xowa.htmls.core.wkrs.glys.Xoh_gly_grp_data data) {hctx.Pool_mgr__hzip().Mw__gly().Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();}
public boolean Process_parse(Xoh_data_itm data) {
Xoh_hzip_wkr wkr = null;
switch (data.Tid()) {
case Xoh_hzip_dict_.Tid__hdr: wkr = hctx.Pool_mgr__hzip().Mw__hdr(); break;
case Xoh_hzip_dict_.Tid__lnke: wkr = hctx.Pool_mgr__hzip().Mw__lnke(); break;
case Xoh_hzip_dict_.Tid__img: wkr = hctx.Pool_mgr__hzip().Mw__img(); break;
case Xoh_hzip_dict_.Tid__img_bare: wkr = hctx.Pool_mgr__hzip().Mw__img_bare(); break;
default: throw Err_.new_unhandled(data.Tid());
}
wkr.Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();
return true;
}
}

View File

@@ -16,23 +16,31 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.langs.htmls.parsers.*;
import gplx.langs.htmls.docs.*;
import gplx.xowa.wikis.ttls.*;
import gplx.xowa.htmls.core.hzips.*;
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
public class Xoh_hdoc_wkr__make implements Xoh_hdoc_wkr {
private Xoh_hzip_bfr bfr; private Xoh_page hpg; private Xoh_hdoc_ctx hctx; private byte[] src;
private final Xoh_hdr_make wkr__hdr = new Xoh_hdr_make();
private final Xoh_img_bldr wkr__img = new Xoh_img_bldr();
private final Xoh_hdr_wtr wkr__hdr = new Xoh_hdr_wtr();
private final Xoh_img_wtr wkr__img = new Xoh_img_wtr();
public void On_new_page(Xoh_hzip_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end) {
this.bfr = bfr; this.hpg = hpg; this.hctx = hctx; this.src = src;
}
public void On_escape (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
public void On_lnke (gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_parser parser) {bfr.Add_mid(src, parser.Src_bgn(), parser.Src_end());}
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser parser) {bfr.Add_mid(src, parser.Src_bgn(), parser.Src_end());}
public void On_hdr (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_parser parser) {wkr__hdr.Make(bfr, hpg, src, parser);}
public void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser parser) {wkr__img.Make_by_parse(bfr, hpg, hctx, src, parser);}
public void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_parser parser) {bfr.Add_mid(src, parser.Src_bgn(), parser.Src_end());}
public void On_gly (gplx.xowa.htmls.core.wkrs.glys.Xoh_gly_grp_parser parser) {}
public void On_escape (gplx.xowa.htmls.core.wkrs.escapes.Xoh_escape_data data) {bfr.Add(data.Hook());}
public void On_xnde (gplx.xowa.htmls.core.wkrs.xndes.Xoh_xnde_parser data) {bfr.Add_mid(src, data.Src_bgn(), data.Src_end());}
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_data data) {bfr.Add_mid(src, data.Src_bgn(), data.Src_end());}
public void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_data data) {bfr.Add_mid(src, data.Src_bgn(), data.Src_end());}
public void On_gly (gplx.xowa.htmls.core.wkrs.glys.Xoh_gly_grp_data data) {}
public boolean Process_parse(Xoh_data_itm data) {
switch (data.Tid()) {
case Xoh_hzip_dict_.Tid__img: wkr__img.Init_by_parse(bfr, hpg, hctx, src, (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_data)data); return true;
case Xoh_hzip_dict_.Tid__hdr: wkr__hdr.Init_by_parse(bfr, hpg, hctx, src, (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_data)data); return true;
case Xoh_hzip_dict_.Tid__lnke: break;
default: throw Err_.new_unhandled(data.Tid());
}
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
return true;
}
}

View File

@@ -44,8 +44,8 @@ public class Xoh_hzip_fxt {
}
public void Test__bicode(String hzip, String html) {Test__bicode(hzip, html, html);}
public void Test__bicode(String hzip, String html_enc, String html_dec) {
html_enc = Html_utl.Replace_apos(html_enc);
html_dec = Html_utl.Replace_apos(html_dec);
html_enc = Gfh_utl.Replace_apos(html_enc);
html_dec = Gfh_utl.Replace_apos(html_dec);
Test__bicode_raw(hzip, html_enc, html_dec);
}
public void Test__bicode_raw(String hzip, String html_enc, String html_dec) {
@@ -54,11 +54,11 @@ public class Xoh_hzip_fxt {
Test__decode__raw(hzip, html_dec);
}
public void Test__encode(String hzip, String html) {
hzip = Html_utl.Replace_apos(Xoh_hzip_fxt.Escape(hzip)); html = Html_utl.Replace_apos(html);
hzip = Xoh_hzip_fxt.Escape(hzip); html = Gfh_utl.Replace_apos(html);
Test__encode__raw(hzip, html);
}
public void Test__decode(String hzip, String html) {
hzip = Html_utl.Replace_apos(Xoh_hzip_fxt.Escape(hzip)); html = Html_utl.Replace_apos(html);
hzip = Xoh_hzip_fxt.Escape(hzip); html = Gfh_utl.Replace_apos(html);
Test__decode__raw(hzip, html);
}
public void Test__encode__fail(String expd, String html) {
@@ -73,6 +73,7 @@ public class Xoh_hzip_fxt {
}
private 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));
Gfo_usr_dlg_.Test__show__term();
Tfds.Eq_str_lines(html, bfr.To_str_and_clear());
@@ -94,7 +95,7 @@ public class Xoh_hzip_fxt {
Gfo_usr_dlg_.Test__show__term();
Io_mgr.Instance.SaveFilBry(dir.GenSubFil(fil).GenNewExt(".hzip.decode.html"), bfr.To_bry_and_clear());
} catch (Exception e) {
Tfds.Write(e);
Tfds.Dbg(e);
}
}
public static String Escape(String v) {return String_.Replace(v, "~", "");}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
import gplx.core.brys.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
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;

View File

@@ -16,14 +16,6 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
public class Bfr_arg__indent extends gplx.core.brys.Bfr_arg_base implements gplx.core.brys.Clear_able {
private int indent = 0;
public void Clear() {
this.indent = 0;
}
public void Set(int v) {this.indent = v;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
if (indent > 0)
bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2);
}
public class Bfr_arg__hatr_ {
public static byte[] Bld_atr_bgn(byte[] key) {return Bry_.Add(Byte_ascii.Space_bry, key, Byte_ascii.Eq_bry, Byte_ascii.Quote_bry);} // ' key="'
}

View File

@@ -0,0 +1,40 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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_arg implements Bfr_arg_clearable {
private final byte[] atr_bgn;
private Bfr_arg_clearable val_as_arg;
public Bfr_arg__hatr_arg(byte[] key) {this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key);}
public Bfr_arg__hatr_arg Set_by_arg(Bfr_arg_clearable v) {val_as_arg = v; return this;}
public Bfr_arg__hatr_arg Set_by_arg_empty() {val_as_arg = Bfr_arg__html_atr__empty.Instance; return this;}
public void Bfr_arg__clear() {val_as_arg = null;}
public boolean Bfr_arg__missing() {return val_as_arg == null || val_as_arg.Bfr_arg__missing();}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
val_as_arg.Bfr_arg__add(bfr);
bfr.Add_byte_quote();
}
}
class Bfr_arg__html_atr__empty implements Bfr_arg_clearable {
public void Bfr_arg__clear() {}
public boolean Bfr_arg__missing() {return false;}
public void Bfr_arg__add(Bry_bfr bfr) {}
public static final Bfr_arg__html_atr__empty Instance = new Bfr_arg__html_atr__empty(); Bfr_arg__html_atr__empty() {}
}

View File

@@ -0,0 +1,49 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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.*; import gplx.core.primitives.*;
public class Bfr_arg__hatr_bry implements Bfr_arg_clearable {
private final byte[] atr_bgn;
public Bfr_arg__hatr_bry(byte[] key) {this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key); this.Bfr_arg__clear();}
private Bfr_arg_clearable arg;
public byte[] Src() {return src;} private byte[] src;
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public Bfr_arg__hatr_bry Set_by_bry(byte[] bry) {src = bry; return this;}
public Bfr_arg__hatr_bry Set_by_mid(byte[] bry, int bgn, int end) {src = bry; src_bgn = bgn; src_end = end; return this;}
public Bfr_arg__hatr_bry Set_by_arg(Bfr_arg_clearable v) {arg = v; return this;}
public Bfr_arg__hatr_bry Set_by_mid_or_empty(byte[] bry, int bgn, int end) {
if (end == -1) this.Set_by_bry(Bry_.Empty);
else this.Set_by_mid(bry, bgn, end);
return this;
}
public Bfr_arg__hatr_bry Set_by_mid_or_null(byte[] bry, int bgn, int end) {
if (end != -1) this.Set_by_mid(bry, bgn, end);
return this;
}
public void Bfr_arg__clear() {arg = null; src = null; src_bgn = src_end = -1;}
public boolean Bfr_arg__missing() {return src == null && (arg == null || arg.Bfr_arg__missing());}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
if (src == null) arg.Bfr_arg__add(bfr);
else if (src_bgn == -1) bfr.Add(src);
else bfr.Add_mid(src, src_bgn, src_end);
bfr.Add_byte_quote();
}
}

View File

@@ -0,0 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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_cls implements Bfr_arg {
private final byte[] atr_bgn;
private byte[][] ary;
public Bfr_arg__hatr_cls() {this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(gplx.langs.htmls.Gfh_atr_.Bry__class);}
public Bfr_arg__hatr_cls Set_by_ary(byte[][] v) {ary = v; return this;}
public void Bfr_arg__clear() {ary = null;}
public boolean Bfr_arg__missing() {return ary == null;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
int len = ary.length;
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_byte_space();
bfr.Add(ary[i]);
}
bfr.Add_byte_quote();
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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.*; import gplx.core.brys.fmtrs.*;
public class Bfr_arg__hatr_fmtr implements Bfr_arg {
private final byte[] atr_bgn;
private final Bry_fmtr fmtr = Bry_fmtr.new_();
private Object[] args;
public Bfr_arg__hatr_fmtr(byte[] key, String fmt, String... keys) {
this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key);
this.fmtr.Fmt_(fmt).Keys_(keys);
this.Clear();
}
public void Set_args(Object... args) {this.args = args;}
public void Clear() {args = null;}
public void Bfr_arg__clear() {this.Clear();}
public boolean Bfr_arg__missing() {return args == null;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
fmtr.Bld_bfr_many(bfr, args);
bfr.Add_byte_quote();
}
}

View File

@@ -0,0 +1,36 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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;
public Bfr_arg__hatr_id(byte[] bry) {this.bry = bry; this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(gplx.langs.htmls.Gfh_atr_.Bry__id);}
public Bfr_arg__hatr_id Set(int num) {this.num = num; return this;}
public void Bfr_arg__clear() {num = -1;}
public boolean Bfr_arg__missing() {return num == -1;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
bfr.Add(bry);
bfr.Add_int_variable(num);
bfr.Add_byte_quote();
}
public static Bfr_arg__hatr_id New(String v) {return new Bfr_arg__hatr_id(Bry_.new_u8(v));}
public static Bfr_arg__hatr_id New(byte[] v) {return new Bfr_arg__hatr_id(v);}
}

View File

@@ -16,16 +16,18 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
public class Bfr_arg__id extends gplx.core.brys.Bfr_arg_base {
private byte[] prefix; private int id;
public Bfr_arg__id Set(byte[] prefix, int id) {
this.prefix = prefix;
this.id = id;
return this;
}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
bfr.Add(prefix);
bfr.Add_int_variable(id);
import gplx.core.brys.*;
public class Bfr_arg__hatr_int implements Bfr_arg_clearable {
private final byte[] atr_bgn;
private int val;
public Bfr_arg__hatr_int(byte[] key) {this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key);}
public Bfr_arg__hatr_int Set_by_int(int v) {val = v; return this;}
public void Bfr_arg__clear() {val = Int_.Min_value;}
public boolean Bfr_arg__missing() {return val == Int_.Min_value;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
bfr.Add_int_variable(val);
bfr.Add_byte_quote();
}
}

View File

@@ -15,37 +15,38 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.wikis.nss.*;
public class Bfr_arg__href extends gplx.core.brys.Bfr_arg_base implements gplx.core.brys.Clear_able {
private byte[] val; private int val_bgn, val_end;
private int href_type;
public void Clear() {
href_type = Tid__null;
}
public void Set_by_atr(gplx.langs.htmls.parsers.Html_atr atr) {Set_by_mid(atr.Src(), atr.Val_bgn(), atr.Val_end());}
public void Set_by_mid(byte[] v, int bgn, int end) {this.val = v; this.href_type = Tid__mid; this.val_bgn = bgn; this.val_end = end;}
public void Set_by_raw(byte[] v) {this.val = v; this.href_type = Tid__raw;}
public void Set_by_page(byte[] v) {this.val = v; this.href_type = Tid__page;}
public void Set_by_file(byte[] v) {this.val = v; this.href_type = Tid__file;}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
if (val == null) return;
switch (href_type) {
case Tid__raw:
bfr.Add(val);
break;
case Tid__mid:
bfr.Add_mid(val, val_bgn, val_end);
break;
case Tid__page:
bfr.Add(Xoh_href_.Bry__wiki); // '/wiki/'
bfr.Add(val); // 'File:A.png'
break;
case Tid__file:
bfr.Add(Xoh_href_.Bry__wiki).Add(Xow_ns_.Bry__file).Add_byte_colon();
bfr.Add(val);
break;
}
}
private static final int Tid__null = 0, Tid__raw = 1, Tid__page = 2, Tid__file = 3, Tid__mid = 4;
}
//namespace gplx.xowa.htmls.core.wkrs.bfr_args {
// using gplx.xowa.htmls.hrefs; using gplx.xowa.wikis.nss;
// public class Bfr_arg__href : gplx.core.brys.Bfr_arg_clearable {
// private byte[] val; private int val_bgn, val_end;
// private int href_type;
//// public void Clear() {
//// href_type = Tid__null;
//// }
// public void Set_by_atr(gplx.langs.htmls.docs.Gfh_atr atr) {Set_by_mid(atr.Src(), atr.Val_bgn(), atr.Val_end());}
// public void Set_by_mid(byte[] v, int bgn, int end) {this.val = v; this.href_type = Tid__mid; this.val_bgn = bgn; this.val_end = end;}
// public void Set_by_raw(byte[] v) {this.val = v; this.href_type = Tid__raw;}
// public void Set_by_page(byte[] v) {this.val = v; this.href_type = Tid__page;}
// public void Set_by_file(byte[] v) {this.val = v; this.href_type = Tid__file;}
// public void Bfr_arg__add(Bry_bfr bfr) {
// if (val == null) return;
// switch (href_type) {
// case Tid__raw:
// bfr.Add(val);
// break;
// case Tid__mid:
// bfr.Add_mid(val, val_bgn, val_end);
// break;
// case Tid__page:
// bfr.Add(Xoh_href_.Bry__wiki); // '/wiki/'
// bfr.Add(val); // 'File:A.png'
// break;
// case Tid__file:
// bfr.Add(Xoh_href_.Bry__wiki).Add(Xow_ns_.Bry__file).Add_byte_colon();
// bfr.Add(val);
// break;
// }
// }
// private static final int Tid__null = 0, Tid__raw = 1, Tid__page = 2, Tid__file = 3, Tid__mid = 4;
// }
//}

View File

@@ -1,76 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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__html_atr implements Bfr_arg, Clear_able {
private final byte[] atr_bgn;
private int val_type;
private int val_as_int;
private byte[] val_as_bry; private int val_as_bry_bgn, val_as_bry_end;
private byte[][] val_as_ary;
private Bfr_arg val_as_arg;
public Bfr_arg__html_atr(byte[] key) {this.atr_bgn = Bld_atr_bgn(key);}
public void Clear() {
val_type = Tid__null;
val_as_arg = null;
val_as_int = Int_.Min_value;
val_as_bry = null;
val_as_ary = null;
}
public byte[] Val_as_bry() {return val_as_bry;}
public int Val_as_bry_bgn() {return val_as_bry_bgn;}
public int Val_as_bry_end() {return val_as_bry_end;}
public Bfr_arg__html_atr Set_by_arg(Bfr_arg v) {val_type = Tid__arg; val_as_arg = v; return this;}
public Bfr_arg__html_atr Set_by_int(int v) {val_type = Tid__int; val_as_int = v; return this;}
public Bfr_arg__html_atr Set_by_ary(byte[]... ary) {val_type = Tid__bry__ary; val_as_ary = ary; return this;}
public Bfr_arg__html_atr Set_by_bry(byte[] bry) {val_type = Tid__bry__val; val_as_bry = bry; return this;}
public Bfr_arg__html_atr Set_by_mid(byte[] bry, int bgn, int end) {val_type = Tid__bry__mid; val_as_bry = bry; val_as_bry_bgn = bgn; val_as_bry_end = end; return this;}
public void Bfr_arg__clear() {this.Clear();}
public boolean Bfr_arg__exists() {
switch (val_type) {
case Tid__null: return false;
case Tid__arg: return val_as_arg.Bfr_arg__exists();
case Tid__int: return val_as_int != Int_.Min_value;
case Tid__bry__ary: return val_as_ary != null;
case Tid__bry__val: return val_as_bry != null;
case Tid__bry__mid: return val_as_bry != null;
default: throw Err_.new_unhandled(val_type);
}
}
public void Bfr_arg__add(Bry_bfr bfr) {
if (!Bfr_arg__exists()) return;
bfr.Add(atr_bgn);
switch (val_type) {
case Tid__arg: val_as_arg.Bfr_arg__add(bfr); break;
case Tid__int: bfr.Add_int_variable(val_as_int); break;
case Tid__bry__val: bfr.Add(val_as_bry); break;
case Tid__bry__mid: bfr.Add_mid(val_as_bry, val_as_bry_bgn, val_as_bry_end); break;
case Tid__bry__ary:
int len = val_as_ary.length;
for (int i = 0; i < len; ++i) {
if (i != 0) bfr.Add_byte_space();
byte[] v = val_as_ary[i];
bfr.Add(v);
}
break;
}
bfr.Add_byte_quote();
}
public static byte[] Bld_atr_bgn(byte[] key) {return Bry_.Add(Byte_ascii.Space_bry, key, Byte_ascii.Eq_bry, Byte_ascii.Quote_bry);} // ' key="'
private static final int Tid__null = 0, Tid__arg = 1, Tid__int = 2, Tid__bry__mid = 3, Tid__bry__val = 4, Tid__bry__ary = 5;
}

View File

@@ -24,9 +24,9 @@ public class Bfr_arg__wrapper implements Bfr_arg {
}
public Bfr_arg__wrapper Set(Bfr_arg v) {inner = v; return this;}
public void Bfr_arg__clear() {this.Clear();}
public boolean Bfr_arg__exists() {return inner != Bfr_arg_.Noop;}
public boolean Bfr_arg__missing() {return inner == Bfr_arg_.Noop;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (!Bfr_arg__exists()) return;
if (Bfr_arg__missing()) return;
inner.Bfr_arg__add(bfr);
}
}

View File

@@ -16,15 +16,15 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.escapes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_escape_data implements Html_doc_wkr {
private final Xoh_hdoc_wkr wkr;
public Xoh_escape_data(Xoh_hdoc_wkr wkr) {this.wkr = wkr;}
public byte[] Hook() {return Xoh_hzip_dict_.Escape_bry;}
public class Xoh_escape_data implements Gfh_doc_wkr {
private final Xoh_hdoc_wkr wkr;
public Xoh_escape_data(Xoh_hdoc_wkr wkr, byte hook_byte) {this.wkr = wkr; this.hook = Bry_.New_by_byte(hook_byte);}
public byte[] Hook() {return hook;} private final byte[] hook; // NOTE: bry with 1 member which is hook to be escaped; EX: "1" or "2" or "27"
public int Parse(byte[] src, int src_bgn, int src_end, int pos) {
int rv = pos + 1;
wkr.On_escape(pos, rv);
wkr.On_escape(this);
return rv;
}
}

View File

@@ -20,16 +20,18 @@ import gplx.core.brys.*; import gplx.core.threads.poolables.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_escape_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
private byte escape_byte;
public int Tid() {return Xoh_hzip_dict_.Tid__escape;}
public byte[] Hook() {return hook;} private byte[] hook;
public String Key() {return Xoh_hzip_dict_.Key__escape;}
public Gfo_poolable_itm Encode(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) {
bfr.Add(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_escape_data data = (Xoh_escape_data)data_obj;
bfr.Add(hook); // EX: 1,0
bfr.Add(data.Hook()); // EX: 2
hctx.Hzip__stat().Escape_add(escape_byte);
return this;
}
public int Decode(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, Bry_rdr rdr, byte[] src, int src_bgn, int src_end) {
bfr.Add_byte(Xoh_hzip_dict_.Escape);
return rdr.Pos();
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) {
bfr.Add_byte(rdr.Read_byte());
}
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) {

View File

@@ -19,7 +19,13 @@ package gplx.xowa.htmls.core.wkrs.escapes; import gplx.*; import gplx.xowa.*; im
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_escape_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
@Test public void Basic() {
fxt.Test__bicode("~u", "");
@Test public void Escape() {
fxt.Test__bicode("!" , String_.new_a7(Bry_.New_by_byte(Xoh_pool_mgr__hzip.Hook__core)));
}
@Test public void Html() {
fxt.Test__bicode("!" , String_.new_a7(Bry_.New_by_byte(Xoh_pool_mgr__hzip.Hook__html)));
}
@Test public void Mw() {
fxt.Test__bicode("!", "");
}
}

View File

@@ -0,0 +1,125 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*;
import gplx.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 { //
private final List_adp itms_list = List_adp_.new_();
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public int Gly_tid() {return gly_tid;} private int gly_tid;
public int Gly_w() {return gly_w;} private int gly_w;
public int Xtra_atr_bgn() {return xtra_atr_bgn;} private int xtra_atr_bgn;
public int Xtra_atr_end() {return xtra_atr_end;} private int xtra_atr_end;
public boolean Xtra_atr_exists() {return xtra_atr_end > xtra_atr_bgn;}
public int Xtra_cls_bgn() {return xtra_cls_bgn;} private int xtra_cls_bgn;
public int Xtra_cls_end() {return xtra_cls_end;} private int xtra_cls_end;
public boolean Xtra_cls_exists() {return xtra_cls_end > xtra_cls_bgn;}
public int Xtra_style_bgn() {return xtra_style_bgn;} private int xtra_style_bgn;
public int Xtra_style_end() {return xtra_style_end;} private int xtra_style_end;
public boolean Xtra_style_exists() {return xtra_style_end > xtra_style_bgn;}
public int Itms__len() {return itms_list.Count();}
public Xoh_gly_itm_data Itms__get_at(int i) {return (Xoh_gly_itm_data)itms_list.Get_at(i);}
private void Clear() {
this.gly_tid = Byte_.Max_value_127;
this.gly_w = 0;
this.xtra_atr_bgn = xtra_atr_end = xtra_cls_bgn = xtra_cls_end = xtra_style_bgn = xtra_style_end = -1;
itms_list.Clear();
}
public boolean Parse1(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, byte[] src, Gfh_tag_rdr tag_rdr, Gfh_tag ul_head) {
this.Clear();
this.src_bgn = ul_head.Src_bgn();
if (!Parse_cls (src, tag_rdr, ul_head)) return false;
if (!Parse_style(src, tag_rdr, ul_head)) return false;
Parse_ul_atrs(src, tag_rdr, ul_head);
Gfh_tag li_head = null;
while (true) {
li_head = tag_rdr.Tag__peek_fwd_head();
if (li_head.Name_id() != Gfh_tag_.Id__li) break; // no more <li>; break;
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();
if (!itm_parser.Parse1(hdoc_wkr, hctx, src, tag_rdr, li_head)) return false;
tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__li);
itms_list.Add(itm_parser);
}
Gfh_tag ul_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__ul);
this.src_end = ul_tail.Src_end();
hdoc_wkr.On_gly(this);
return true;
}
private boolean Parse_cls(byte[] src, Gfh_tag_rdr tag_rdr, Gfh_tag ul_head) {
Gfh_atr ul_cls = ul_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__class);
Gfh_class_parser_.Parse(src, ul_cls.Val_bgn(), ul_cls.Val_end(), this);
if (gly_tid == Byte_.Max_value_127) {
tag_rdr.Err_wkr().Fail("unable to find gallery tid");
return false;
}
return true;
}
private boolean Parse_style(byte[] src, Gfh_tag_rdr tag_rdr, Gfh_tag ul_head) {
Gfh_atr ul_style = ul_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__style);
Gfh_style_parser_.Parse(src, ul_style.Val_bgn(), ul_style.Val_end(), this); // parse for width; note width only appears if items_per_row is specified
return true;
}
private void Parse_ul_atrs(byte[] src, Gfh_tag_rdr tag_rdr, Gfh_tag ul_head) {
int atrs_len = ul_head.Atrs__len();
for (int i = 0; i < atrs_len; ++i) {
Gfh_atr hatr = ul_head.Atrs__get_at(i);
if (Bry_.Eq(hatr.Key(), Gfh_atr_.Bry__class)) {}
else if (Bry_.Eq(hatr.Key(), Gfh_atr_.Bry__style)) {}
else {
if (xtra_atr_bgn == -1) this.xtra_atr_bgn = hatr.Atr_bgn();
this.xtra_atr_end = hatr.Atr_end();
}
}
}
public boolean On_cls(byte[] src, int atr_idx, int atr_bgn, int atr_end, int val_bgn, int val_end) {
if (Bry_.Match(src, val_bgn, val_end, Atr__cls__gallery)) {} // ignore "gallery"
else if (Bry_.Match(src, val_bgn, val_bgn + Atr__cls__mw_gallery.length, Atr__cls__mw_gallery)) { // starts with 'mw-gallery-'
int tid_bgn = val_bgn + Atr__cls__mw_gallery.length;
this.gly_tid = Gallery_mgr_base_.Hash.Get_as_byte_or(src, tid_bgn, val_end, Byte_.Max_value_127);
return true;
}
else {
if (this.xtra_cls_bgn == -1) {
this.xtra_cls_bgn = val_bgn;
this.xtra_cls_end = atr_end;
}
}
return true;
}
public boolean On_atr(byte[] src, int atr_idx, int atr_bgn, int atr_end, int key_bgn, int key_end, int val_bgn, int val_end) {
if (Bry_.Match(src, key_bgn, key_end, Style__max_width)) // 'max-width'
gly_w = Bry_.To_int_or__lax(src, val_bgn, val_end, 0);
else if (Bry_.Match(src, key_bgn, key_end, Style___width)) {} // '_width'
else {
if (this.xtra_style_bgn == -1) {
this.xtra_style_bgn = key_bgn;
this.xtra_style_end = atr_end;
}
}
return true;
}
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")
, Style__max_width = Bry_.new_a7("max-width"), Style___width = Bry_.new_a7("_width")
;
}

View File

@@ -1,49 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.langs.htmls.parsers.styles.*; import gplx.langs.htmls.parsers.clses.*;
public class Xoh_gly_grp_parser implements Html_atr_class_wkr {
public int Rng_bgn() {return rng_bgn;} private int rng_bgn;
public int Rng_end() {return rng_end;} private int rng_end;
// private Xoh_gly_itm_parser itm_parser = new Xoh_gly_itm_parser();
public int Parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, byte[] src, Html_tag_rdr tag_rdr, Html_tag ul_tag) {
this.rng_bgn = ul_tag.Src_bgn();
/*
parse class for traditional
parse style for max_width
*/
// Html_tag cur_tag = null;
// while (true) {
// cur_tag = tag_rdr.Tag__move_fwd_head();
// if (cur_tag.Name_id() != Html_tag_.Id__li) break; // no more <li>; break;
// itm_parser.Parse(hdoc_wkr, hctx, src, tag_rdr, cur_tag);
// }
// hdoc_wkr.On_thm(this);
Html_tag cur_tag = tag_rdr.Tag__move_fwd_tail(Html_tag_.Id__ul);
this.rng_end = cur_tag.Src_end();
return rng_end;
}
public boolean On_cls(byte[] src, int atr_idx, int atr_bgn, int atr_end, int val_bgn, int val_end) {
// if (Bry_.Match(src, val_bgn, val_end, Bry__cls__traditional)) {
//
// }
return false;
}
public static final byte[] Atr__class__gallery = Bry_.new_a7("gallery");
}

View File

@@ -0,0 +1,106 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
class Xoh_gly_grp_wtr implements Bfr_arg {
private final Bfr_arg_clearable[] arg_ary;
private final Bfr_arg__hatr_id ul_id = Bfr_arg__hatr_id.New("xogly_li_");
private final Bfr_arg__hatr_gly_style ul_style = new Bfr_arg__hatr_gly_style(Gfh_atr_.Bry__style);
private byte[] ul_cls, xtra_cls, xtra_atr_bry, ul_nl;
private final Xoh_gly_itm_list_wtr itm_list_wtr = new Xoh_gly_itm_list_wtr();
public Xoh_gly_grp_wtr() {
arg_ary = new Bfr_arg_clearable[] {ul_id};
}
public void Init(boolean mode_is_diff, int id, byte[] cls, int ul_w, byte[] xtra_cls, byte[] xtra_style_bry, byte[] xtra_atr_bry, Xoh_gly_itm_wtr[] ary) {
this.Clear();
if (!mode_is_diff)
ul_id.Set(id);
this.ul_cls = cls;
this.xtra_cls = xtra_cls == null ? Bry_.Empty : Bry_.Add(Byte_ascii.Space_bry, xtra_cls);
this.xtra_atr_bry = xtra_atr_bry;
this.ul_nl = ary.length == 0 ? Bry_.Empty : Byte_ascii.Nl_bry; // TIDY: <ul></ul> should be on same line if 0 items
itm_list_wtr.Init(ary);
ul_style.Set_args(ul_w, xtra_style_bry);
}
public void Clear() {
for (Bfr_arg_clearable arg : arg_ary)
arg.Bfr_arg__clear();
ul_id.Bfr_arg__clear();
ul_style.Clear();
ul_cls = null;
}
public void Bfr_arg__clear() {this.Clear();}
public boolean Bfr_arg__missing() {return false;}
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
( "<ul~{id} class=\"gallery mw-gallery-~{cls}~{xtra_cls}\"~{style}~{xtra_atr}>~{itms}~{ul_nl}</ul>"
), "id", "cls", "xtra_cls", "style", "xtra_atr", "itms", "ul_nl");
}
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;
for (int i = 0; i < ary_len; ++i)
ary[i].Clear();
}
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) {
Xoh_gly_itm_wtr itm = ary[i];
itm.Bfr_arg__add(bfr);
}
}
}
class Bfr_arg__hatr_gly_style implements Bfr_arg {
private final byte[] atr_bgn;
private int width;
private byte[] xtra_cls;
public Bfr_arg__hatr_gly_style(byte[] key) {
this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key);
this.Clear();
}
public void Set_args(int w, byte[] xtra_cls) {this.width = w; this.xtra_cls = xtra_cls;}
public void Clear() {width = 0; xtra_cls = null;}
public void Bfr_arg__clear() {this.Clear();}
public boolean Bfr_arg__missing() {return width == 0 && xtra_cls == null;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
bfr.Add(atr_bgn);
if (width > 0) {
bfr.Add(Style__frag_1);
bfr.Add_int_variable(width);
bfr.Add(Style__frag_2);
bfr.Add_int_variable(width);
bfr.Add(Style__frag_3);
}
if (xtra_cls != null) {
if (width > 0) bfr.Add_byte_space();
bfr.Add(xtra_cls);
}
bfr.Add_byte_quote();
}
private static final byte[]
Style__frag_1 = Bry_.new_a7("max-width:")
, Style__frag_2 = Bry_.new_a7("px; _width:")
, Style__frag_3 = Bry_.new_a7("px;")
;
}

View File

@@ -0,0 +1,59 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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.makes.tests.*;
public class Xoh_gly_html__dump__tst {
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Basic() {
fxt.Test__html(String_.Concat_lines_nl_skip_last
( "<gallery>"
, "File:A.jpg|A1"
, "File:B.jpg|B1"
, "</gallery>"
), String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, " <li class='gallerybox' style='width:155px;'>"
, " <div style='width:155px;'>"
, " <div class='thumb' style='width:150px;'>"
, " <div style='margin:15px auto;'>"
, " <a href='/wiki/File:A.jpg' class='image' xowa_title='A.jpg'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'><p>A1"
, "</p>"
, ""
, " </div>"
, " </div>"
, " </li>"
, " <li class='gallerybox' style='width:155px;'>"
, " <div style='width:155px;'>"
, " <div class='thumb' style='width:150px;'>"
, " <div style='margin:15px auto;'>"
, " <a href='/wiki/File:B.jpg' class='image' xowa_title='B.jpg'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''/></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'><p>B1"
, "</p>"
, ""
, " </div>"
, " </div>"
, " </li>"
, "</ul>"));
}
}

View File

@@ -17,21 +17,84 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.threads.poolables.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.hzips.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.hzips.*;
import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.lnkis.anchs.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
import gplx.xowa.xtns.gallery.*;
public class Xoh_gly_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
private final Xoh_gly_grp_wtr grp_wtr = new Xoh_gly_grp_wtr();
public int Tid() {return Xoh_hzip_dict_.Tid__gly;}
public String Key() {return Xoh_hzip_dict_.Key__gly;}
public byte[] Hook() {return hook;} private byte[] hook;
public Gfo_poolable_itm Encode(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
Xoh_gly_grp_parser data = (Xoh_gly_grp_parser)data_obj;
bfr.Add_mid(src, data.Rng_bgn(), data.Rng_end());
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
Xoh_gly_grp_data data = (Xoh_gly_grp_data)data_obj;
boolean xtra_atr = flag_bldr.Set_as_bool(Flag__ul__xtra_atr , data.Xtra_atr_exists());
boolean xtra_cls = flag_bldr.Set_as_bool(Flag__ul__xtra_cls , data.Xtra_cls_exists());
boolean xtra_style = flag_bldr.Set_as_bool(Flag__ul__xtra_style , data.Xtra_style_exists());
flag_bldr.Set(Flag__gly_tid, data.Gly_tid());
int itms_len = data.Itms__len();
bfr.Add(hook);
Xoh_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
Xoh_hzip_int_.Encode(1, bfr, data.Gly_w());
if (xtra_cls) bfr.Add_hzip_mid(src, data.Xtra_cls_bgn(), data.Xtra_cls_end());
if (xtra_style) bfr.Add_hzip_mid(src, data.Xtra_style_bgn(), data.Xtra_style_end());
if (xtra_atr) bfr.Add_hzip_mid(src, data.Xtra_atr_bgn(), data.Xtra_atr_end());
Xoh_hzip_int_.Encode(1, bfr, itms_len);
for (int i = 0; i < itms_len; ++i) {
Xoh_gly_itm_data itm_parser = data.Itms__get_at(i);
bfr.Add_hzip_int(1, itm_parser.Li_w());
bfr.Add_hzip_int(1, itm_parser.Div_1_w());
bfr.Add_hzip_int(1, itm_parser.Div_2_margin());
bfr.Add_byte((byte)(itm_parser.Capt_tid() + gplx.core.encoders.Base85_.A7_offset));
bfr.Add_hzip_mid(src, itm_parser.Capt_bgn(), itm_parser.Capt_end());
Xoh_hzip_wkr hzip_wkr = hctx.Pool_mgr__hzip().Mw__img();
hzip_wkr.Encode1(bfr, hdoc_wkr, hctx, hpg, false, src, itm_parser.Img_parser());
hzip_wkr.Pool__rls();
}
return this;
}
public int Decode(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, Bry_rdr rdr, byte[] src, int src_bgn, int src_end) {
return src_bgn + 2;
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
boolean xtra_atr = flag_bldr.Get_as_bool(Flag__ul__xtra_atr);
boolean xtra_cls = flag_bldr.Get_as_bool(Flag__ul__xtra_cls);
boolean xtra_style = flag_bldr.Get_as_bool(Flag__ul__xtra_style);
byte cls_tid = flag_bldr.Get_as_byte(Flag__gly_tid);
byte[] cls_bry = Gallery_mgr_base_.Get_bry_by_tid(cls_tid);
int ul_w = rdr.Read_hzip_int(1);
byte[] xtra_cls_bry = xtra_cls ? rdr.Read_bry_to(): null;
byte[] xtra_style_bry = xtra_style ? rdr.Read_bry_to(): null;
byte[] xtra_atr_bry = xtra_atr ? rdr.Read_bry_to(): null;
int li_len = rdr.Read_hzip_int(1);
int uid = hctx.Uid__gly__nxt();
Xoh_gly_itm_wtr[] itm_ary = new Xoh_gly_itm_wtr[li_len];
for (int i = 0; i < li_len; ++i) {
Xoh_gly_itm_wtr itm_wtr = new Xoh_gly_itm_wtr();
itm_ary[i] = itm_wtr;
int li_w = rdr.Read_hzip_int(1);
int div_1_w = rdr.Read_hzip_int(1);
int div_2_margin = rdr.Read_hzip_int(1);
byte capt_tid = (byte)(rdr.Read_byte() - gplx.core.encoders.Base85_.A7_offset);
byte[] capt_bry = rdr.Read_bry_to();
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);
itm_wtr.Img_wtr().Init_by_decode(hpg, hctx, src, img_data);
img_data.Pool__rls();
img_hzip.Pool__rls();
}
grp_wtr.Init(hctx.Mode_is_diff(), uid, cls_bry, ul_w, xtra_cls_bry, xtra_style_bry, xtra_atr_bry, itm_ary);
grp_wtr.Bfr_arg__add(bfr);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_gly_hzip rv = new Xoh_gly_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1, 1, 3);
private static final int // SERIALIZED
Flag__ul__xtra_atr = 0
, Flag__ul__xtra_cls = 1
, Flag__ul__xtra_style = 2
, Flag__gly_tid = 3
;
}

View File

@@ -18,40 +18,161 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gly_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
private String Html__basic = gplx.langs.htmls.Html_utl.Replace_apos(String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px;_width:978px;'>"
, " <li class='gallerybox' style='width: 155px'>"
, " <div style='width: 155px'>"
, " <div class='thumb' style='width: 150px;'>"
, " <div style='margin:75px auto;'>"
, " <a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'>"
, " <p>"
, " abc"
, " </p>"
, " </div>"
, " </div>"
, " </li>"
, " <li class='gallerybox' style='width: 155px'>"
, " <div style='width: 155px'>"
, " <div class='thumb' style='width: 150px;'>"
, " <div style='margin:75px auto;'>"
, " <a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a>"
, " </div>"
, " </div>"
, " <div class='gallerytext'>"
, " <p>"
, " abc"
, " </p>"
, " </div>"
, " </div>"
, " </li>"
, "</ul>"
));
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Basic() {
fxt.Test__bicode(Html__basic, Html__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
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:B.png' class='image' xowa_title='B.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>B1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>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<p>abc</p>", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'></div>"
, "</div>"
, "</li>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'></div>"
, "</div>"
, "</li>"
, "</ul><p>abc</p>"));
}
@Test public void Capt_is_br() { // PURPOSE: handle captions which have <br>, not <p>; PAGE:s.w:Sociology; DATE:2015-12-20
fxt.Test__bicode("~'!!\"{\"g{\"b0\"<b><i>A1</i></b>~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'><br>"
, "<b><i>A1</i></b>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void No_max_width() { // PURPOSE: if no perrow=# then no "style='max-width:###; _width:###;'"
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Extra_cls() { // PURPOSE: handle extra cls; EX: <gallery class='abc'>
fxt.Test__bicode("~'1!cls1 cls2~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional cls1 cls2'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Xtra_style__append() { // PURPOSE: handle appended style; EX: <gallery perrow=4 style='color:blue; float:left;'>
fxt.Test__bicode("~'){,Lcolor:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='max-width:978px; _width:978px; color:blue; float:left;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Xtra_style__replace() { // PURPOSE: handle replaced style; EX: <gallery style='color:blue; float:left;'>
fxt.Test__bicode("~')!color:blue; float:left;~\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' style='color:blue; float:left;'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Xtra_atr() { // PURPOSE: handle extra atr; EX: <gallery id='abc'>
fxt.Test__bicode("~'A! id=\"abc\"\"{\"g{\"b0!A1~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional' id='abc'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Tidy__br_at_end() { // PURPOSE: handle inconsistent tidy behavior where <p> is put on one line ("<p>a</p>") unless it ends with <br> ("<p>a<br>\n</p>")
fxt.Test__bicode("~'!!\"{\"g{\"b0!A1<br>~!1A.png~9\"D\"D", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'>"
, "<li class='gallerybox' style='width:155px;'>"
, "<div style='width:155px;'>"
, "<div class='thumb' style='width:150px;'>"
, "<div style='margin:15px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xoimg='0|120|120|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>A1<br>" // TIDY: <br> forces </p> to be on next line
, "</p>"
, "</div>"
, "</div>"
, "</li>"
, "</ul>"));
}
@Test public void Tidy__empty() { // PURPOSE: no items should place </ul> on same line
fxt.Test__bicode("~'!!!", String_.Concat_lines_nl_skip_last
( "<ul class='gallery mw-gallery-traditional'></ul>")); // TIDY: <ul></ul> should be on same line if 0 items
}
}

View File

@@ -0,0 +1,106 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.btries.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.styles.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
public class Xoh_gly_itm_data {
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public Xoh_img_data Img_parser() {return img_parser;} private Xoh_img_data img_parser = new Xoh_img_data();
public boolean Img_exists() {return img_exists;} private boolean img_exists;
public int Li_w() {return li_w;} private int li_w;
public int Div_1_w() {return div_1_w;} private int div_1_w;
public int Div_2_margin() {return div_2_margin;} private int div_2_margin;
public byte Capt_tid() {return capt_tid;} private byte capt_tid;
public int Capt_bgn() {return capt_bgn;} private int capt_bgn;
public int Capt_end() {return capt_end;} private int capt_end;
private void Clear() {
img_exists = false;
capt_bgn = capt_end = li_w = div_1_w = div_2_margin = -1;
capt_tid = Capt_tid__null;
}
public boolean Parse1(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, byte[] src, Gfh_tag_rdr tag_rdr, Gfh_tag li_tag) {
this.Clear();
this.src_bgn = li_tag.Src_bgn();
this.li_w = li_tag.Atrs__style_get_as_int(Gfh_style_key_.Bry__width);
Gfh_tag div_0_head = tag_rdr.Tag__move_fwd_head();
if (!div_0_head.Chk_name(Gfh_tag_.Id__div)) return false; // <div style="width: 175px">
Gfh_tag div_1_head = tag_rdr.Tag__move_fwd_head();
if (!div_1_head.Chk(Gfh_tag_.Id__div, Xoh_thm_data.Atr__class__thumb)) return false; // chk for <div class="thumb" style="height: 170px;">
this.div_1_w = div_1_head.Atrs__style_get_as_int(Gfh_style_key_.Bry__width);
int div_2_bgn = div_1_head.Src_end();
Gfh_tag div_1_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div); // </div> for class="thumb"
int div_2_end = div_1_tail.Src_bgn();
Gfh_tag div_2_head = tag_rdr.Tag__find_fwd_head(div_2_bgn, div_2_end, Gfh_tag_.Id__div); // find <div style="margin:15px auto;">
if (div_2_head.Src_exists()) { // img_exists
img_exists = true;
this.div_2_margin = div_2_head.Atrs__style_get_as_int(Gfh_style_key_.Bry__margin);
tag_rdr.Pos_(div_2_head.Src_end());
Gfh_tag anch_tag = tag_rdr.Tag__move_fwd_head();
if (!anch_tag.Chk(Gfh_tag_.Id__a, Xoh_img_data.Bry__cls__anch__image)) return false;
if (!img_parser.Init_by_parse(hdoc_wkr, hctx, tag_rdr, src, anch_tag, null)) return false;
}
else {
img_exists = false;
}
if (!Parse_gallerytext(src, tag_rdr)) return false;
tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
this.src_end = tag_rdr.Pos();
return true;
}
private boolean Parse_gallerytext(byte[] src, Gfh_tag_rdr tag_rdr) {
Gfh_tag capt_head = tag_rdr.Tag__move_fwd_head();
if (!capt_head.Chk(Gfh_tag_.Id__div, Atr__cls__gallerytext)) return false; // chk for <div class='gallerytext'>
int capt_head_end = capt_head.Src_end();
Gfh_tag capt_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
int capt_tail_bgn = capt_tail.Src_bgn();
int capt_tail_end = capt_tail.Src_end();
capt_bgn = Bry_find_.Find_fwd_while_not_ws(src, capt_head_end, capt_tail_bgn); // skip any \n, \s
if (capt_tail_bgn - capt_bgn == 0) {
capt_tid = Capt_tid__empty;
capt_end = capt_bgn;
return true; // EX: <div class='gallerytext'></div>
}
Object capt_tid_obj = Capt_tid__trie.Match_bgn(src, capt_bgn, capt_tail_bgn);
if (capt_tid_obj == null) return false; // something wrong;
this.capt_tid = ((Byte_obj_val)capt_tid_obj).Val();
boolean capt_head_is_p = false;
switch (capt_tid) {
case Capt_tid__p: capt_bgn += 3; capt_head_is_p = true; break; // EX: <div class='gallerytext'><p>
case Capt_tid__br: capt_bgn += 4; break; // EX: <div class='gallerytext'><br>
}
if (capt_head_is_p)
tag_rdr.Pos_(capt_bgn);
capt_bgn = Bry_find_.Find_fwd_while_not_ws(src, capt_bgn, capt_tail_bgn);
capt_end = capt_tail_bgn;
if (capt_head_is_p) {
Gfh_tag para_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__p);
capt_end = para_tail.Src_bgn();
}
capt_end = Bry_find_.Find_bwd__skip_ws(src, capt_end, -1);
tag_rdr.Pos_(capt_tail_end);
return true;
}
private static final byte[] Atr__cls__gallerytext = Bry_.new_a7("gallerytext");
public static final byte Capt_tid__p = 0, Capt_tid__br = 1, Capt_tid__empty = 2, Capt_tid__null = 3;
private static final Btrie_slim_mgr Capt_tid__trie = Btrie_slim_mgr.ci_a7()
.Add_bry_byte(Gfh_tag_.P_lhs , Capt_tid__p)
.Add_bry_byte(Gfh_tag_.Br_lhs , Capt_tid__br)
;
}

View File

@@ -1,56 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*; import gplx.langs.htmls.parsers.styles.*;
public class Xoh_gly_itm_parser {
public int Rng_bgn() {return rng_bgn;} private int rng_bgn;
public int Rng_end() {return rng_end;} private int rng_end;
// xoimg_parser
public boolean Img_exists() {return img_exists;} private boolean img_exists;
public int Capt_bgn() {return capt_bgn;} private int capt_bgn;
public int Capt_end() {return capt_end;} private int capt_end;
public int Parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, byte[] src, Html_tag_rdr tag_rdr, Html_tag li_tag) {
this.rng_bgn = li_tag.Src_bgn();
this.rng_end = li_tag.Src_end();
tag_rdr.Tag__move_fwd_head().Chk_id(Html_tag_.Id__div); // <div style="width: 175px">
Html_tag div_1_head = tag_rdr.Tag__move_fwd_head().Chk_id(Html_tag_.Id__div); // <div class="thumb" style="height: 170px;">
int file_text_bgn = div_1_head.Src_end();
Html_tag div_1_tail = tag_rdr.Tag__move_fwd_tail(Html_tag_.Id__div);
int file_text_end = div_1_tail.Src_bgn();
Html_tag img_tag = tag_rdr.Tag__find_fwd_head(file_text_bgn, file_text_end, Html_tag_.Id__div); // search <div style="margin:15px auto;">
if (img_tag.Src_exists()) { // img_exists
img_exists = true;
// div_nxt.Atrs__cls_has(Bry__gallery_text); // assert cls = Bry_gallery_text
}
else {
img_exists = false;
}
tag_rdr.Tag__move_fwd_head().Chk_id(Html_tag_.Id__div); // <div class="gallerytext">
Html_tag para_head = tag_rdr.Tag__move_fwd_head().Chk_id(Html_tag_.Id__p);
capt_bgn = para_head.Src_end();
Html_tag para_tail = tag_rdr.Tag__move_fwd_tail(Html_tag_.Id__p);
capt_end = para_tail.Src_bgn();
tag_rdr.Tag__move_fwd_tail(Html_tag_.Id__div);
tag_rdr.Tag__move_fwd_tail(Html_tag_.Id__div);
this.rng_end = tag_rdr.Pos();
return rng_end;
}
// private static final byte[] Bry__gallery_text = Bry_.new_a7("gallerytext");
}

View File

@@ -0,0 +1,85 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.glys; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
public class Xoh_gly_itm_wtr implements Bfr_arg {
private final Bfr_arg_clearable[] arg_ary;
private final Bfr_arg__hatr_id li_id = Bfr_arg__hatr_id.New("xogly_li_"), img_id = Bfr_arg__hatr_id.New(gplx.xowa.htmls.Xoh_img_mgr.Bry__html_uid)
, div_1_id = Bfr_arg__hatr_id.New("xogly_div1_"), div_2_id = Bfr_arg__hatr_id.New("xogly_div2_"), div_3_id = Bfr_arg__hatr_id.New("xogly_div3_");
private final Bfr_arg__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 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;
itm_caption_fmtr.Set(capt_tid, itm_caption);
if (!mode_is_diff) {
li_id.Set(img_id); div_1_id.Set(img_id); div_2_id.Set(img_id); div_3_id.Set(img_id); img_wtr.Img_id_(img_id);
}
img_wtr.Anch_cls_(Xoh_img_data.Bry__cls__anch__image);
}
public Xoh_gly_itm_wtr Clear() {
for (Bfr_arg_clearable arg : arg_ary)
arg.Bfr_arg__clear();
// img_wtr.Clear(); // TOMBSTONE: do not clear; clear will be called by Xoh_hzip_img.Decode1
return this;
}
public void Bfr_arg__clear() {this.Clear();}
public boolean Bfr_arg__missing() {return false;}
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
( ""
, "<li~{li_id} class=\"gallerybox\" style=\"width:~{li_w}px;\">"
, "<div~{div_1_id} style=\"width:~{li_w}px;\">"
, "<div~{div_2_id} class=\"thumb\" style=\"width:~{div_1_w}px;\">"
, "<div~{div_3_id} style=\"margin:~{div_2_margin}px auto;\">~{img_itm}</div>"
, "</div>"
, "<div class=\"gallerytext\">~{itm_caption}</div>"
, "</div>"
, "</li>"
), "li_id", "div_1_id", "div_2_id", "div_3_id", "li_w", "div_1_w", "div_2_margin", "img_itm", "itm_caption");
}
class Bfr_arg__itm_caption implements Bfr_arg {
private byte capt_tid;
private byte[] capt_bry;
public void Set(byte tid, byte[] bry) {this.capt_tid = tid; this.capt_bry = bry;}
public void Bfr_arg__clear() {capt_bry = null;}
public boolean Bfr_arg__missing() {return capt_bry == null;}
public void Bfr_arg__add(Bry_bfr bfr) {
if (Bfr_arg__missing()) return;
switch (capt_tid) {
case Xoh_gly_itm_data.Capt_tid__empty: return; // <div class='gallerytext'></div>
case Xoh_gly_itm_data.Capt_tid__p: bfr.Add_byte_nl().Add(Gfh_tag_.P_lhs); break; // <div class='gallerytext'><p>
case Xoh_gly_itm_data.Capt_tid__br: bfr.Add(Gfh_tag_.Br_lhs).Add_byte_nl(); break; // <div class='gallerytext'><br>
}
bfr.Add(capt_bry);
int itm_caption_len = capt_bry.length;
if (capt_tid == Xoh_gly_itm_data.Capt_tid__p) {
if (itm_caption_len > 3 && Bry_.Match(capt_bry, itm_caption_len - 4, Gfh_tag_.Br_lhs)) bfr.Add_byte_nl();
bfr.Add(Gfh_tag_.P_rhs);
}
bfr.Add_byte_nl();
}
}

View File

@@ -0,0 +1,54 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.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.core.primitives.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_gly_itm_wtr_tst {
private final Xoh_gly_itm_wtr_fxt fxt = new Xoh_gly_itm_wtr_fxt();
@Test public void Basic() {
fxt.Init__gly(0, 155, 150, 5, "caption");
fxt.Init__img("/wiki/File:A.png", "A.png", "0|120|120|-1|-1|-1");
fxt.Test__write(String_.Concat_lines_nl_skip_last
( ""
, "<li id='xogly_li_0' class='gallerybox' style='width:155px;'>"
, "<div id='xogly_div1_0' style='width:155px;'>"
, "<div id='xogly_div2_0' class='thumb' style='width:150px;'>"
, "<div id='xogly_div3_0' style='margin:5px auto;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img id='xoimg_0' data-xoimg='0|120|120|-1|-1|-1' width='0' height='0'></a></div>"
, "</div>"
, "<div class='gallerytext'>"
, "<p>caption</p>"
, "</div>"
, "</div>"
, "</li>"
));
}
}
class Xoh_gly_itm_wtr_fxt {
private final Xoh_gly_itm_wtr wtr = new Xoh_gly_itm_wtr();
private final Bry_bfr tmp_bfr = Bry_bfr.new_();
public void Init__gly(int id, int itm_w, int file_div_w, int file_div_margin, String caption) {
wtr.Init(Bool_.N, id, itm_w, file_div_w, file_div_margin, Xoh_gly_itm_data.Capt_tid__p, Bry_.new_a7(caption));
}
public void Init__img(String href, String xowa_title, String xoimg) {
wtr.Img_wtr().Init_by_gly(gplx.core.brys.args.Bfr_arg__bry.New(Bry_.new_u8(href)), Bry_.new_u8(xowa_title), gplx.core.brys.args.Bfr_arg__bry.New(Bry_.new_u8(xoimg)));
}
public void Test__write(String expd) {
expd = gplx.langs.htmls.Gfh_utl.Replace_apos(expd);
wtr.Bfr_arg__add(tmp_bfr);
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
}
}

View File

@@ -16,8 +16,11 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
public class Xoh_hdr_parser {
import gplx.core.threads.poolables.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_hdr_data implements Xoh_data_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__hdr;}
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public int Hdr_level() {return hdr_level;} private int hdr_level;
@@ -28,28 +31,34 @@ public class Xoh_hdr_parser {
public int Capt_end() {return capt_end;} private int capt_end;
public int Capt_rhs_bgn() {return capt_rhs_bgn;} private int capt_rhs_bgn;
public int Capt_rhs_end() {return capt_rhs_end;} private int capt_rhs_end;
public boolean Capt_rhs_exists() {return capt_rhs_exists;} private boolean capt_rhs_exists;
public boolean Capt_rhs_exists() {return capt_rhs_end > capt_rhs_bgn;}
public void Clear() {
this.anch_bgn = anch_end = capt_bgn = capt_end = capt_rhs_bgn = capt_rhs_end -1;
this.anch_is_diff = capt_rhs_exists = false;
this.anch_bgn = anch_end = capt_bgn = capt_end = capt_rhs_bgn = capt_rhs_end = -1;
this.anch_is_diff = false;
}
public boolean Parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Html_tag_rdr tag_rdr, byte[] src, Html_tag hdr_head, Html_tag span_head) {
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag hdr_head, Gfh_tag span_head) {
this.Clear();
this.src_bgn = hdr_head.Src_bgn(); this.hdr_level = hdr_head.Name_id();
Html_atr anch_atr = span_head.Atrs__get_by_or_fail(Html_atr_.Bry__id);
Gfh_atr anch_atr = span_head.Atrs__get_by_or_fail(Gfh_atr_.Bry__id);
this.anch_bgn = anch_atr.Val_bgn(); this.anch_end = anch_atr.Val_end();
this.capt_bgn = span_head.Src_end();
Html_tag hdr_tail = tag_rdr.Tag__move_fwd_tail(hdr_level); // find </h2> not </span_head> since <span_head> can be nested, but <h2> cannot
Html_tag span_tail = tag_rdr.Tag__peek_bwd_tail(Html_tag_.Id__span); // get </span_head> before </h2>
Gfh_tag hdr_tail = tag_rdr.Tag__move_fwd_tail(hdr_level); // find </h2> not </span_head> since <span_head> can be nested, but <h2> cannot
Gfh_tag span_tail = tag_rdr.Tag__peek_bwd_tail(Gfh_tag_.Id__span); // get </span_head> before </h2>
this.capt_end = span_tail.Src_bgn();
if (span_tail.Src_end() != hdr_tail.Src_bgn()) {
capt_rhs_exists = true;
capt_rhs_bgn = span_tail.Src_end(); capt_rhs_end = hdr_tail.Src_bgn();
}
this.anch_is_diff = !Bry_.Match_w_swap(src, capt_bgn, capt_end, src, anch_bgn, anch_end, Byte_ascii.Space, Byte_ascii.Underline); // anch is different than capt; occurs with html and dupe-anchors; EX: "==<i>A</i>==" -> id='A'
this.src_end = tag_rdr.Pos();
hdoc_wkr.On_hdr(this);
return true;
}
public void Init_by_decode(int hdr_level, boolean anch_is_diff, int anch_bgn, int anch_end, int capt_bgn, int capt_end, int capt_rhs_bgn, int capt_rhs_end) {
this.hdr_level = hdr_level;
this.anch_is_diff = anch_is_diff;
this.anch_bgn = anch_bgn; this.anch_end = anch_end; this.capt_bgn = capt_bgn; this.capt_end = capt_end;
this.capt_rhs_bgn = capt_rhs_bgn; this.capt_rhs_end = capt_rhs_end;
}
public static final byte[] Bry__class__mw_headline = Bry_.new_a7("mw-headline");
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hdr_data rv = new Xoh_hdr_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
}

View File

@@ -42,7 +42,7 @@ public class Xoh_hdr_html {
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
if (hdr.Hdr_end_manual() > 0) bfr.Add_byte_repeat(Byte_ascii.Eq, hdr.Hdr_end_manual()); // '='
if (cfg.Toc__show())
bfr.Add(Html_tag_.Span_rhs); // '</span>'
bfr.Add(Gfh_tag_.Span_rhs); // '</span>'
bfr.Add(Bry__hdr_rhs_bgn).Add_int(hdr_len, 1, 1); // '</h', '2'
bfr.Add(Bry__hdr_rhs_end); // '>\n'
}

View File

@@ -19,10 +19,11 @@ package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; impor
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_hdr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__hdr;}
public String Key() {return Xoh_hzip_dict_.Key__hdr;}
public byte[] Hook() {return hook;} private byte[] hook;
public Gfo_poolable_itm Encode(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_hdr_parser data = (Xoh_hdr_parser)data_obj;
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_hdr_data data = (Xoh_hdr_data)data_obj;
boolean capt_rhs_exists = flag_bldr.Set_as_bool (Flag__capt_rhs_exists , data.Capt_rhs_exists());
boolean anch_is_diff = flag_bldr.Set_as_bool (Flag__anch_is_diff , data.Anch_is_diff());
int hdr_level = flag_bldr.Set_as_int (Flag__hdr_level , data.Hdr_level());
@@ -36,33 +37,20 @@ public class Xoh_hdr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
hctx.Hzip__stat().Hdr_add(hdr_level);
return this;
}
public int Decode(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, Bry_rdr rdr, byte[] src, int src_bgn, int src_end) {
int flag = rdr.Read_int_by_base85(1); flag_bldr.Decode(flag);
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
boolean capt_rhs_exists = flag_bldr.Get_as_bool(Flag__capt_rhs_exists);
boolean anch_is_diff = flag_bldr.Get_as_bool(Flag__anch_is_diff);
byte hdr_level = flag_bldr.Get_as_byte(Flag__hdr_level);
int capt_bgn = rdr.Pos(); int capt_end = rdr.Find_fwd_lr();
int anch_bgn = -1, anch_end = -1;
if (anch_is_diff) {
anch_bgn = rdr.Pos(); anch_end = rdr.Find_fwd_lr();
}
byte[] capt_manual_end = capt_rhs_exists ? rdr.Read_bry_to() : null;
bfr.Add(Bry__hdr__0).Add_byte_as_a7(hdr_level);
bfr.Add(Bry__hdr__1);
if (anch_is_diff)
bfr.Add_mid (src, anch_bgn, anch_end);
else
bfr.Add_mid_w_swap (src, capt_bgn, capt_end, Byte_ascii.Space, Byte_ascii.Underline);
bfr.Add(Bry__hdr__2);
bfr.Add_mid(src, capt_bgn, capt_end);
bfr.Add(Bry__hdr__3);
if (capt_rhs_exists)
bfr.Add(capt_manual_end);
bfr.Add(Bry__hdr__4).Add_byte_as_a7(hdr_level);
bfr.Add_byte(Byte_ascii.Angle_end);
return rdr.Pos();
if (anch_is_diff) {anch_bgn = rdr.Pos(); anch_end = rdr.Find_fwd_lr();}
int capt_rhs_bgn = -1, capt_rhs_end = -1;
if (capt_rhs_exists) {capt_rhs_bgn = rdr.Pos(); capt_rhs_end = rdr.Find_fwd_lr();}
Xoh_hdr_data data = (Xoh_hdr_data)data_itm;
data.Init_by_decode(hdr_level, anch_is_diff, anch_bgn, anch_end, capt_bgn, capt_end, capt_rhs_bgn, capt_rhs_end);
}
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (1, 1, 3);
private static final int // SERIALIZED
@@ -70,13 +58,6 @@ public class Xoh_hdr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
, Flag__anch_is_diff = 1
, Flag__hdr_level = 2
;
private static final byte[]
Bry__hdr__0 = Bry_.new_a7("<h")
, Bry__hdr__1 = Bry_.new_a7("><span class=\"mw-headline\" id=\"")
, Bry__hdr__2 = Bry_.new_a7("\">")
, Bry__hdr__3 = Bry_.new_a7("</span>")
, Bry__hdr__4 = Bry_.new_a7("</h")
;
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hdr_hzip rv = new Xoh_hdr_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
}

View File

@@ -1,37 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
import gplx.xowa.htmls.sections.*;
public class Xoh_hdr_make {
public void Make(Bry_bfr bfr, Xoh_page hpg, byte[] src, Xoh_hdr_parser arg) {
// , int rng_bgn, int rng_end, int level, int capt_bgn, int capt_end, byte[] anch
// register section
int rng_bgn = arg.Src_bgn(), rng_end = arg.Src_end();
int level = arg.Hdr_level();
Xoh_section_mgr section_mgr = hpg.Section_mgr();
int section_len = section_mgr.Len();
if (section_len != 0) // guard against -1 index; should not happen
section_mgr.Set_content(section_len - 1, src, rng_bgn - 2); // -2 to skip "\n\n"
byte[] capt = Bry_.Mid(src, arg.Capt_bgn(), arg.Capt_end());
byte[] anch = Bry_.Mid(src, arg.Anch_bgn(), arg.Anch_end());
if (anch == null) anch = Bry_.Replace(capt, Byte_ascii.Space, Byte_ascii.Underline);
hpg.Section_mgr().Add(section_len, level, anch, capt).Content_bgn_(rng_end + 1); // +1 to skip "\n"
bfr.Add_mid(src, rng_bgn, rng_end);
}
}

View File

@@ -23,14 +23,10 @@ public class Xoh_hdr_make_tst {
String html = String_.Concat_lines_nl_skip_last
( "z"
, ""
, "<h2>"
, " <span class='mw-headline' id='A_1'>A 1</span>"
, "</h2>"
, "<h2><span class='mw-headline' id='A_1'>A 1</span></h2>"
, "a 1"
, ""
, "<h2>"
, " <span class='mw-headline' id='B'>B</span>"
, "</h2>"
, "<h2><span class='mw-headline' id='B'>B</span></h2>"
, "b"
);
fxt.Test__make(html, fxt.Page_chkr().Body_(html) // make sure body is same

View File

@@ -0,0 +1,54 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*; import gplx.core.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_hdr_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
private int hdr_num; private byte[] hdr_id, hdr_content, hdr_capt_rhs;
private Xoh_page hpg;
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_hdr_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;
Xoh_hdr_data data = (Xoh_hdr_data)data_itm;
this.hdr_num = data.Hdr_level();
this.hdr_content = Bry_.Mid(src, data.Capt_bgn(), data.Capt_end());
if (data.Anch_is_diff())
hdr_id = Bry_.Mid(src, data.Anch_bgn(), data.Anch_end());
else
hdr_id = Bry_.Replace(hdr_content, Byte_ascii.Space, Byte_ascii.Underline);
hdr_capt_rhs = data.Capt_rhs_exists() ? Bry_.Mid(src, data.Capt_rhs_bgn(), data.Capt_rhs_end()) : Bry_.Empty;
return true;
}
public void Bfr_arg__add(Bry_bfr bfr) {
Xoh_section_mgr section_mgr = hpg.Section_mgr();
int section_len = section_mgr.Len();
if (section_len != 0) // guard against -1 index; should not happen
section_mgr.Set_content(section_len - 1, bfr.Bfr(), bfr.Len() - 2); // close previous section; -2 to skip "\n\n"
fmtr.Bld_bfr_many(bfr, hdr_num, hdr_id, hdr_content, hdr_capt_rhs);
section_mgr.Add(section_len, hdr_num, hdr_id, hdr_content).Content_bgn_(bfr.Len() + 1); // +1 to skip "\n"
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hdr_wtr rv = new Xoh_hdr_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
private static final Bry_fmtr fmtr = Bry_fmtr.new_
( "<h~{lvl}><span class=\"mw-headline\" id=\"~{id}\">~{content}</span>~{capt_rhs}</h~{lvl}>"
, "lvl", "id", "content", "capt_rhs");
}

View File

@@ -0,0 +1,56 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.threads.poolables.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_img_bare_data implements Xoh_data_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__img_bare;}
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public int Dir_tid() {return dir_tid;} private int dir_tid;
public int Dir_bgn() {return dir_bgn;} private int dir_bgn;
public int Dir_end() {return dir_end;} private int dir_end;
public void Clear() {
this.src_bgn = src_end = dir_tid = dir_bgn = dir_end = -1;
}
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag img_head, Gfh_tag unused) {
this.src_bgn = img_head.Src_bgn(); this.src_end = img_head.Src_end();
Gfh_atr img_src_atr = img_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__src); if (img_src_atr.Val_dat_missing()) return false;
byte[] root_dir_bry = hctx.Fsys__root();
int root_dir_bgn = img_src_atr.Val_bgn();
int root_dir_end = root_dir_bgn + root_dir_bry.length;
if (Bry_.Match(src, root_dir_bgn, root_dir_end, root_dir_bry)) {
int hiero_dir_end = root_dir_end + Url__hiero.length;
if (Bry_.Match(src, root_dir_end, hiero_dir_end, Url__hiero)) {
dir_tid = Dir_tid__hiero;
dir_bgn = root_dir_bgn;
dir_end = hiero_dir_end;
return true;
}
}
return false;
}
public void Init_by_decode(int src_bgn, int src_end, int dir_tid, int dir_bgn, int dir_end) {
this.src_bgn = src_bgn; this.src_end = src_end; this.dir_tid = dir_tid; this.dir_bgn = dir_bgn; this.dir_end = dir_end;
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_bare_data rv = new Xoh_img_bare_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
public static final byte[] Url__hiero = Bry_.new_a7("bin/any/xowa/xtns/Wikihiero/img/hiero_");
public static final int Dir_tid__null = -1, Dir_tid__hiero = 0;
}

View File

@@ -0,0 +1,52 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_img_bare_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
public int Tid() {return Xoh_hzip_dict_.Tid__img_bare;}
public String Key() {return Xoh_hzip_dict_.Key__img_bare;}
public byte[] Hook() {return hook;} private byte[] hook;
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
Xoh_img_bare_data data = (Xoh_img_bare_data)data_obj;
flag_bldr.Set(Flag__dir_tid , data.Dir_tid());
bfr.Add(hook);
Xoh_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
bfr.Add_hzip_mid(src, data.Src_bgn(), data.Dir_bgn());
bfr.Add_hzip_mid(src, data.Dir_end(), data.Src_end());
return this;
}
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
Xoh_img_bare_data data = (Xoh_img_bare_data)data_itm; data.Clear();
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
int dir_tid = flag_bldr.Get_as_int(Flag__dir_tid);
int tag_0_bgn = rdr.Pos(), tag_0_end = rdr.Find_fwd_lr();
int tag_1_bgn = rdr.Pos(), tag_1_end = rdr.Find_fwd_lr();
data.Init_by_decode(tag_0_bgn, tag_1_end, dir_tid, tag_0_end, tag_1_bgn);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_img_bare_hzip rv = new Xoh_img_bare_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(2);
private static final int // SERIALIZED
Flag__dir_tid = 0
;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.htmls.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_img_bare_hzip__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Before public void Clear() {fxt.Clear();}
@Test public void Hiero() {
fxt.Test__bicode
( "~(!<img style=\"margin: 1px; height: 11px;\" src=\"~X1.png\" title=\"X1 [t]\" alt=\"t\">~"
, "<img style='margin: 1px; height: 11px;' src='file:///mem/xowa/bin/any/xowa/xtns/Wikihiero/img/hiero_X1.png' title='X1 [t]' alt='t'>"
);
}
}

Some files were not shown because too many files have changed in this diff Show More