mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.12.1.1
This commit is contained in:
52
400_xowa/src/gplx/core/brys/Bry_diff_.java
Normal file
52
400_xowa/src/gplx/core/brys/Bry_diff_.java
Normal 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.core.brys; import gplx.*; import gplx.core.*;
|
||||
public class Bry_diff_ {
|
||||
public static byte[][] Diff_1st_line(byte[] lhs, byte[] rhs) {return Diff_1st(lhs, 0, lhs.length, rhs, 0, rhs.length, Byte_ascii.Nl_bry, Byte_ascii.Angle_bgn_bry, 255);}
|
||||
public static byte[][] Diff_1st(byte[] lhs, int lhs_bgn, int lhs_end, byte[] rhs, int rhs_bgn, int rhs_end, byte[] stop, byte[] show, int diff_max) {
|
||||
int lhs_len = lhs_end - lhs_bgn;
|
||||
int rhs_len = rhs_end - rhs_bgn;
|
||||
int len = lhs_len < rhs_len ? lhs_len : rhs_len;
|
||||
int lhs_idx = -1, rhs_idx = -1;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
byte lhs_byte = lhs[i + lhs_bgn];
|
||||
byte rhs_byte = rhs[i + rhs_bgn];
|
||||
if (lhs_byte != rhs_byte) {lhs_idx = rhs_idx = i; break;} // diff; stop iterating
|
||||
}
|
||||
if (lhs_idx == -1 && rhs_idx == -1) {
|
||||
switch (Int_.Compare(lhs_len, rhs_len)) {
|
||||
case CompareAble_.Same: return null;
|
||||
case CompareAble_.Less: lhs_idx = rhs_idx = lhs_len; break;
|
||||
case CompareAble_.More: lhs_idx = rhs_idx = rhs_len; break;
|
||||
}
|
||||
}
|
||||
byte[] lhs_diff = Get_1st(stop, show, lhs, lhs_idx, lhs_len, diff_max);
|
||||
byte[] rhs_diff = Get_1st(stop, show, rhs, rhs_idx, rhs_len, diff_max);
|
||||
return new byte[][] {lhs_diff, rhs_diff};
|
||||
}
|
||||
private static byte[] Get_1st(byte[] stop, byte[] show, byte[] src, int bgn, int end, int diff_max) {
|
||||
if (bgn == end) return Bry__eos;
|
||||
int prv_show = Bry_find_.Find_bwd(src, show, bgn , 0); if (prv_show == Bry_find_.Not_found) prv_show = 0;
|
||||
int prv_stop = Bry_find_.Find_bwd(src, stop, bgn , 0); prv_stop = (prv_stop == Bry_find_.Not_found) ? 0 : prv_stop + 1;
|
||||
int prv = prv_show > prv_stop ? prv_show : prv_stop;
|
||||
int nxt = Bry_find_.Find_fwd(src, stop, bgn , end); if (nxt == Bry_find_.Not_found) nxt = end;
|
||||
if (nxt - prv > 255) nxt = prv + diff_max;
|
||||
return Bry_.Mid(src, prv, nxt);
|
||||
}
|
||||
private static final byte[] Bry__eos = Bry_.new_a7("<<EOS>>");
|
||||
}
|
||||
44
400_xowa/src/gplx/core/brys/Bry_diff_tst.java
Normal file
44
400_xowa/src/gplx/core/brys/Bry_diff_tst.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.brys; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Bry_diff_tst {
|
||||
@Before public void init() {} private final Bry_diff_fxt fxt = new Bry_diff_fxt();
|
||||
@Test public void Diff_1st() {
|
||||
fxt.Test__diff_1st("a|b|c" , "a|b|c" , null , null);
|
||||
fxt.Test__diff_1st("a|b|c" , "a|b1|c" , "b" , "b1");
|
||||
fxt.Test__diff_1st("a|b|" , "a|b|c" , "<<EOS>>" , "c");
|
||||
fxt.Test__diff_1st("a|b|c" , "a|b|" , "c" , "<<EOS>>");
|
||||
}
|
||||
@Test public void Diff_1st_show() {
|
||||
fxt.Test__diff_1st("a|b<c>d|e" , "a|b<c>e|e" , "<c>d", "<c>e");
|
||||
}
|
||||
}
|
||||
class Bry_diff_fxt {
|
||||
public void Test__diff_1st(String lhs, String rhs, String expd_lhs, String expd_rhs) {
|
||||
byte[] lhs_src = Bry_.new_u8(lhs);
|
||||
byte[] rhs_src = Bry_.new_u8(rhs);
|
||||
byte[][] actl = Bry_diff_.Diff_1st(lhs_src, 0, lhs_src.length, rhs_src, 0, rhs_src.length, Byte_ascii.Pipe_bry, Byte_ascii.Angle_bgn_bry, 255);
|
||||
if (expd_lhs == null && expd_rhs == null)
|
||||
Tfds.Eq_true(actl == null, "actl not null");
|
||||
else {
|
||||
Tfds.Eq_bry(Bry_.new_u8(expd_lhs), actl[0]);
|
||||
Tfds.Eq_bry(Bry_.new_u8(expd_rhs), actl[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
47
400_xowa/src/gplx/core/brys/Bry_err_wkr.java
Normal file
47
400_xowa/src/gplx/core/brys/Bry_err_wkr.java
Normal 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.core.brys; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.errs.*;
|
||||
public class Bry_err_wkr {
|
||||
private String sect; private int sect_bgn;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public String Page() {return page;} private String page;
|
||||
public void Fail_throws_err_(boolean v) {this.fail_throws_err = v;} private boolean fail_throws_err = true;
|
||||
public void Init_by_page(String page, byte[] src) {this.page = page; this.src = src;}
|
||||
public void Init_by_sect(String sect, int sect_bgn) {this.sect = sect; this.sect_bgn = sect_bgn;}
|
||||
public int Fail(String msg, Object... args) {return Fail(msg, sect_bgn, sect_bgn + 255, args);}
|
||||
private int Fail(String msg, int excerpt_bgn, int excerpt_end, Object[] args) {
|
||||
String err_msg = Make_msg(msg, excerpt_bgn, excerpt_end, args);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", err_msg);
|
||||
if (fail_throws_err) throw Err_.new_("Bry_err_wkr", err_msg).Logged_y_();
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
private String Make_msg(String msg, int excerpt_bgn, int excerpt_end, Object[] args) {
|
||||
int args_len = args.length;
|
||||
args_len += 6;
|
||||
args = (Object[])Array_.Resize(args, args_len);
|
||||
args[args_len - 6] = "page"; args[args_len - 5] = Quote(page);
|
||||
args[args_len - 4] = "sect"; args[args_len - 3] = Quote(sect);
|
||||
args[args_len - 2] = "text"; args[args_len - 1] = Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end));
|
||||
for (int i = 0; i < args_len - 6; i += 2) {
|
||||
args[i + 1] = Quote(Object_.Xto_str_strict_or_null_mark(args[i + 1]));
|
||||
}
|
||||
return Err_msg.To_str(msg, args);
|
||||
}
|
||||
private static String Quote(String v) {return "'" + v + "'";}
|
||||
}
|
||||
@@ -19,18 +19,20 @@ package gplx.core.brys; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.errs.*;
|
||||
public class Bry_rdr {
|
||||
private final gplx.core.primitives.Int_obj_ref pos_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
private String ctx; private String wkr; private int err_bgn;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Pos() {return pos;} private int pos;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public Bry_rdr Dflt_dlm_(byte b) {this.dflt_dlm = b; return this;} private byte dflt_dlm;
|
||||
public Bry_rdr Fail_throws_err_(boolean v) {this.fail_throws_err = v; return this;} private boolean fail_throws_err = true;
|
||||
public Bry_rdr Init_by_page(byte[] ctx, byte[] src, int src_len) {this.ctx = Quote(String_.new_u8(ctx)); this.src = src; this.src_end = src_len; this.pos = 0; return this;}
|
||||
public Bry_rdr Init_by_hook(String wkr, int err_bgn, int pos) {this.wkr = Quote(wkr); this.err_bgn = err_bgn; this.pos = pos; return this;}
|
||||
public Bry_rdr Init_by_sub(Bry_rdr rdr, String wkr, int pos, int src_end) {
|
||||
this.src = rdr.src; this.ctx = rdr.ctx; this.wkr = Quote(wkr); this.err_bgn = pos; this.pos = pos; this.src_end = src_end;
|
||||
public Bry_rdr Fail_throws_err_(boolean v) {err_wkr.Fail_throws_err_(v); return this;}
|
||||
public Bry_rdr Init_by_page(byte[] page, byte[] src, int src_len) {err_wkr.Init_by_page(String_.new_u8(page), src); this.pos = 0; this.src = src; this.src_end = src_len; return this;}
|
||||
public Bry_rdr Init_by_sect(String sect, int sect_bgn, int pos) {err_wkr.Init_by_sect(sect, sect_bgn); this.pos = pos; return this;}
|
||||
public Bry_rdr Init_by_wkr (Bry_err_wkr wkr, String sect, int pos, int src_end) {
|
||||
this.pos = pos; this.src = wkr.Src(); this.src_end = src_end;
|
||||
err_wkr.Init_by_page(wkr.Page(), src);
|
||||
err_wkr.Init_by_sect(sect, pos);
|
||||
return this;
|
||||
}
|
||||
public Bry_err_wkr Err_wkr() {return err_wkr;} private Bry_err_wkr err_wkr = new Bry_err_wkr();
|
||||
public int Move_to(int v) {this.pos = v; return pos;}
|
||||
public int Move_by_one() {return Move_by(1);}
|
||||
public int Move_by(int v) {this.pos += v; return pos;}
|
||||
@@ -41,12 +43,12 @@ public class Bry_rdr {
|
||||
public int Find_fwd_rr(byte find) {return Find_fwd(find , Bool_.N, Bool_.N);}
|
||||
public int Find_fwd_rr(byte[] find) {return Find_fwd(find , Bool_.N, Bool_.N);}
|
||||
private int Find_fwd(byte find, boolean ret_lhs, boolean pos_lhs) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {Fail("find failed", "find", Byte_ascii.To_str(find)); return Bry_find_.Not_found;}
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {err_wkr.Fail("find failed", "find", Byte_ascii.To_str(find)); return Bry_find_.Not_found;}
|
||||
pos = find_pos + (pos_lhs ? 0 : 1);
|
||||
return ret_lhs ? find_pos : pos;
|
||||
}
|
||||
private int Find_fwd(byte[] find, boolean ret_lhs, boolean pos_lhs) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {Fail("find failed", "find", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_end); if (find_pos == Bry_find_.Not_found) {err_wkr.Fail("find failed", "find", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
pos = find_pos + (pos_lhs ? 0 : find.length);
|
||||
return ret_lhs ? find_pos : pos;
|
||||
}
|
||||
@@ -60,7 +62,7 @@ public class Bry_rdr {
|
||||
byte rv = src[pos];
|
||||
++pos;
|
||||
if (pos < src_end) {
|
||||
if (src[pos] != to_char) {Fail("read byte to failed", "to", Byte_ascii.To_str(to_char)); return Byte_.Max_value_127;}
|
||||
if (src[pos] != to_char) {err_wkr.Fail("read byte to failed", "to", Byte_ascii.To_str(to_char)); return Byte_.Max_value_127;}
|
||||
++pos;
|
||||
}
|
||||
return rv;
|
||||
@@ -84,7 +86,7 @@ public class Bry_rdr {
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
if (negative == -1) { // 2nd negative
|
||||
Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
err_wkr.Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
return Int_.Min_value;
|
||||
}
|
||||
else // 1st negative
|
||||
@@ -97,14 +99,14 @@ public class Bry_rdr {
|
||||
match = true;
|
||||
}
|
||||
if (!match) {
|
||||
Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
err_wkr.Fail("invalid int", "mid", String_.new_u8(src, bgn, pos));
|
||||
return Int_.Min_value;
|
||||
}
|
||||
return rv * negative;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bgn == pos) {Fail("int is empty", String_.Empty, String_.Empty); return Int_.Min_value;}
|
||||
if (bgn == pos) {err_wkr.Fail("int is empty"); return Int_.Min_value;}
|
||||
return rv * negative;
|
||||
}
|
||||
public byte Read_byte_as_a7_int() {
|
||||
@@ -135,13 +137,13 @@ public class Bry_rdr {
|
||||
return rv;
|
||||
}
|
||||
public int Chk(byte find) {
|
||||
if (src[pos] != find) {Fail("failed check", "chk", Byte_.To_str(find)); return Bry_find_.Not_found;}
|
||||
if (src[pos] != find) {err_wkr.Fail("failed check", "chk", Byte_.To_str(find)); return Bry_find_.Not_found;}
|
||||
++pos;
|
||||
return pos;
|
||||
}
|
||||
public int Chk(byte[] find) {
|
||||
int find_end = pos + find.length;
|
||||
if (!Bry_.Match(src, pos, find_end, find)) {Fail("failed check", "chk", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
if (!Bry_.Match(src, pos, find_end, find)) {err_wkr.Fail("failed check", "chk", String_.new_u8(find)); return Bry_find_.Not_found;}
|
||||
pos = find_end;
|
||||
return pos;
|
||||
}
|
||||
@@ -149,7 +151,7 @@ public class Bry_rdr {
|
||||
public byte Chk_or(gplx.core.btries.Btrie_slim_mgr trie, byte or) {return Chk_or(trie, pos, src_end, or);}
|
||||
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie, int itm_bgn, int itm_end) {
|
||||
byte rv = Chk_or(trie, itm_bgn, itm_end, Byte_.Max_value_127);
|
||||
if (rv == Byte_.Max_value_127) {Fail("failed trie check", "mid", String_.new_u8(Bry_.Mid_by_len_safe(src, pos, 16))); return Byte_.Max_value_127;}
|
||||
if (rv == Byte_.Max_value_127) {err_wkr.Fail("failed trie check", "mid", String_.new_u8(Bry_.Mid_by_len_safe(src, pos, 16))); return Byte_.Max_value_127;}
|
||||
return rv;
|
||||
}
|
||||
public byte Chk_or(gplx.core.btries.Btrie_slim_mgr trie, int itm_bgn, int itm_end, byte or) {
|
||||
@@ -158,20 +160,4 @@ public class Bry_rdr {
|
||||
pos = trie.Match_pos();
|
||||
return ((gplx.core.primitives.Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
public int Fail(String msg, String arg_key, Object arg_val) {return Fail(msg, arg_key, arg_val, err_bgn, err_bgn + 255);}
|
||||
public int Fail(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {
|
||||
arg_val = Quote(Object_.Xto_str_strict_or_null_mark(arg_val));
|
||||
String err_msg = Msg_make(msg, arg_key, arg_val, excerpt_bgn, excerpt_end);
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", err_msg);
|
||||
if (fail_throws_err) throw Err_.new_("Bry_rdr", err_msg).Logged_y_();
|
||||
return Bry_find_.Not_found;
|
||||
}
|
||||
public Err Err_make(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {return Err_.new_("Bry_rdr", Msg_make(msg, arg_key, arg_val, excerpt_bgn, excerpt_end));}
|
||||
private String Msg_make(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {
|
||||
if (String_.EqEmpty(arg_key))
|
||||
return Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
|
||||
else
|
||||
return Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
|
||||
}
|
||||
private static String Quote(String v) {return "'" + v + "'";}
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@ public class Int_flag_bldr {
|
||||
this.val_ary = new int[pow_ary.length];
|
||||
return this;
|
||||
}
|
||||
public Int_flag_bldr Set(int idx, int val) {val_ary[idx] = val; return this;}
|
||||
public Int_flag_bldr Set(int idx, byte val) {val_ary[idx] = val; return this;}
|
||||
public Int_flag_bldr Set(int idx, boolean val) {val_ary[idx] = val ? 1 : 0; return this;}
|
||||
public boolean Set_as_bool(int idx, boolean val) {val_ary[idx] = val ? 1 : 0; return val;}
|
||||
public byte Set_as_byte(int idx, byte val) {val_ary[idx] = val; return val;}
|
||||
public int Set_as_int(int idx, int val) {val_ary[idx] = val; return val;}
|
||||
public Int_flag_bldr Set(int idx, boolean val) {Set_as_bool(idx, val); return this;}
|
||||
public Int_flag_bldr Set(int idx, byte val) {Set_as_byte(idx, val); return this;}
|
||||
public Int_flag_bldr Set(int idx, int val) {Set_as_int(idx, val); return this;}
|
||||
public int Get_as_int(int idx) {return val_ary[idx];}
|
||||
public byte Get_as_byte(int idx) {return (byte)val_ary[idx];}
|
||||
public boolean Get_as_bool(int idx) {return val_ary[idx] == 1;}
|
||||
|
||||
@@ -59,7 +59,7 @@ class GfoCacheMgr_fxt {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class GfoCacheItm_mock implements RlsAble {
|
||||
class GfoCacheItm_mock implements Rls_able {
|
||||
public void Rls() {}
|
||||
public String S() {return s;} private String s;
|
||||
public GfoCacheItm_mock(String s) {this.s = s;}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Gfo_cache_mgr {
|
||||
hash.Del(itm.Key());
|
||||
itm.Rls();
|
||||
}
|
||||
public void Add_replace(byte[] key, RlsAble val, int size) {
|
||||
public void Add_replace(byte[] key, Rls_able val, int size) {
|
||||
// Del(key);
|
||||
// Add(key, val, size);
|
||||
Object o = hash.Get_by(key);
|
||||
@@ -57,7 +57,7 @@ public class Gfo_cache_mgr {
|
||||
itm.Replace(val, size);
|
||||
}
|
||||
}
|
||||
public void Add(byte[] key, RlsAble val, int size) {
|
||||
public void Add(byte[] key, Rls_able val, int size) {
|
||||
// if (cur_size + size > 600000000) ReduceCache();
|
||||
cur_size += size;
|
||||
// ++cur_size;
|
||||
@@ -104,12 +104,12 @@ public class Gfo_cache_mgr {
|
||||
}
|
||||
}
|
||||
}
|
||||
class Gfo_cache_data implements gplx.CompareAble, RlsAble {
|
||||
public Gfo_cache_data(byte[] key, RlsAble val, int size) {this.key = key; this.val = val; this.size = size; this.timestamp = Env_.TickCount();}
|
||||
class Gfo_cache_data implements gplx.CompareAble, Rls_able {
|
||||
public Gfo_cache_data(byte[] key, Rls_able val, int size) {this.key = key; this.val = val; this.size = size; this.timestamp = Env_.TickCount();}
|
||||
public byte[] Key() {return key;} private byte[] key;
|
||||
public RlsAble Val() {return val;} private RlsAble val;
|
||||
public Rls_able Val() {return val;} private Rls_able val;
|
||||
public int Size() {return size;} private int size;
|
||||
public void Replace(RlsAble val, int size) {this.val = val; this.size = size;}
|
||||
public void Replace(Rls_able val, int size) {this.val = val; this.size = size;}
|
||||
public long Timestamp() {return timestamp;} public void Timestamp_update() {timestamp = Env_.TickCount();} private long timestamp;
|
||||
public int compareTo(Object obj) {
|
||||
Gfo_cache_data comp = (Gfo_cache_data)obj;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.ios.*;/*IoStream*/
|
||||
public class Io_buffer_rdr implements RlsAble {
|
||||
public class Io_buffer_rdr implements Rls_able {
|
||||
private Io_stream_rdr rdr;
|
||||
Io_buffer_rdr(Io_stream_rdr rdr, Io_url url, int bfr_len) {
|
||||
this.rdr = rdr; this.url = url;
|
||||
|
||||
@@ -45,12 +45,12 @@ public class Gfo_url_parser {
|
||||
rel = true;
|
||||
}
|
||||
if (!rel) { // search for ":"; NOTE: only search if not rel; i.e.: "//"
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
|
||||
if (colon_pos != Bry_find_.Not_found) // colon found; EX: "http://" or "https://"
|
||||
pos = colon_pos + Int_.Const_dlm_len;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
|
||||
pos += 1;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) // skip 2nd slash after colon
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) // skip 2nd slash after colon
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
|
||||
public interface Gfo_poolable_itm {
|
||||
int Pool__idx();
|
||||
void Pool__clear (Object[] args);
|
||||
Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args);
|
||||
void Pool__rls();
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
|
||||
public class Gfo_poolable_mgr {
|
||||
private final Object thread_lock = new Object();
|
||||
private final Gfo_poolable_itm prototype; private final Object[] make_args, clear_args;
|
||||
private final Gfo_poolable_itm prototype; private final Object[] make_args;
|
||||
private Gfo_poolable_itm[] pool; private int pool_nxt, pool_len;
|
||||
public Gfo_poolable_mgr(Gfo_poolable_itm prototype, Object[] make_args, Object[] clear_args, int init_pool_len, int pool_max) {// NOTE: random IndexOutOfBounds errors in Get around free_ary[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
this.prototype = prototype; this.make_args = make_args; this.clear_args = clear_args;
|
||||
public Gfo_poolable_mgr(Gfo_poolable_itm prototype, Object[] make_args, int init_pool_len, int pool_max) {// NOTE: random IndexOutOfBounds errors in Get around free_ary[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
this.prototype = prototype; this.make_args = make_args;
|
||||
this.pool_len = init_pool_len;
|
||||
this.Clear_fast();
|
||||
}
|
||||
@@ -51,7 +51,6 @@ public class Gfo_poolable_mgr {
|
||||
pool[pool_idx] = rv;
|
||||
}
|
||||
}
|
||||
rv.Pool__clear(clear_args); // NOTE: ALWAYS call Clear when doing Get. caller may forget to call Clear, and reused bfr may have leftover bytes. unit tests will not catch, and difficult to spot in app
|
||||
return rv;
|
||||
}
|
||||
public void Rls_safe(int idx) {synchronized (thread_lock) {Rls_safe(idx);}}
|
||||
|
||||
@@ -17,5 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import gplx.core.threads.*;
|
||||
public class Gfo_poolable_mgr_ {
|
||||
public static Gfo_poolable_mgr New(int len, int max, Gfo_poolable_itm prototype) {return new Gfo_poolable_mgr(prototype, Object_.Ary_empty, Object_.Ary_empty, len, max);}
|
||||
public static Gfo_poolable_mgr New(int len, int max, Gfo_poolable_itm prototype) {return new Gfo_poolable_mgr(prototype, Object_.Ary_empty, len, max);}
|
||||
public static Gfo_poolable_mgr New(int len, int max, Gfo_poolable_itm prototype, Object[] make_args) {return new Gfo_poolable_mgr(prototype, make_args, len, max);}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Gfo_poolable_mgr_tst {
|
||||
}
|
||||
}
|
||||
class Gfo_poolable_mgr_tstr {
|
||||
private final Gfo_poolable_mgr mgr = new Gfo_poolable_mgr(new Sample_poolable_itm(null, -1, Object_.Ary_empty), Object_.Ary("make"), Object_.Ary("clear"), 2, 8);
|
||||
private final Gfo_poolable_mgr mgr = new Gfo_poolable_mgr(new Sample_poolable_itm(null, -1, Object_.Ary_empty), Object_.Ary("make"), 2, 8);
|
||||
public void Clear() {mgr.Clear_fast();}
|
||||
public void Test__get(int expd_idx) {
|
||||
Sample_poolable_itm actl_itm = (Sample_poolable_itm)mgr.Get_fast();
|
||||
@@ -78,8 +78,6 @@ class Sample_poolable_itm implements Gfo_poolable_itm {
|
||||
public Sample_poolable_itm(Gfo_poolable_mgr pool_mgr, int pool_idx, Object[] make_args) {this.pool_mgr = pool_mgr; this.pool_idx = pool_idx; this.pool__make_args = make_args;}
|
||||
public int Pool__idx() {return pool_idx;} private final int pool_idx;
|
||||
public Object[] Pool__make_args() {return pool__make_args;} private final Object[] pool__make_args;
|
||||
public Object[] Pool__clear_args() {return pool__clear_args;} private Object[] pool__clear_args;
|
||||
public void Pool__clear (Object[] args) {this.pool__clear_args = args;}
|
||||
public void Pool__rls() {pool_mgr.Rls_safe(pool_idx);}
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {return new Sample_poolable_itm(pool_mgr, idx, args);}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.cfgs; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Db_cfg_tbl implements RlsAble {
|
||||
public class Db_cfg_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_grp, fld_key, fld_val;
|
||||
private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.primitives.*; import gplx.core.envs.*;
|
||||
import gplx.dbs.*; import gplx.core.ios.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_bin_tbl implements RlsAble {
|
||||
public class Fsd_bin_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_bin"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_owner_id, fld_owner_tid, fld_part_id, fld_data_url, fld_data;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_select; private Bry_bfr tmp_bfr;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Fsd_dir_tbl implements RlsAble {
|
||||
public class Fsd_dir_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_dir"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_name;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select_by_name;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_fil_tbl implements RlsAble {
|
||||
public class Fsd_fil_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_fil"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_name, fld_xtn_id, fld_ext_id, fld_size, fld_modified, fld_hash, fld_bin_db_id;
|
||||
private final String idx_owner;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*; import gplx.fsdb.meta.*; import gplx.xowa.files.*;
|
||||
public class Fsd_thm_tbl implements RlsAble {
|
||||
public class Fsd_thm_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_owner_id, fld_w, fld_h, fld_time, fld_page, fld_bin_db_id, fld_size, fld_modified, fld_hash;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by_fil_exact, stmt_select_by_fil_near; private int mnt_id; private boolean schema_thm_page;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Fsm_mnt_tbl implements RlsAble {
|
||||
public class Fsm_mnt_tbl implements Rls_able {
|
||||
private final String tbl_name = "fsdb_mnt"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_name, fld_url;
|
||||
private final Db_conn conn;
|
||||
|
||||
@@ -16,6 +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.gfui; import gplx.*;
|
||||
import gplx.core.bits.*;
|
||||
public class Gfui_bnd_parser {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
|
||||
private Hash_adp_bry
|
||||
|
||||
@@ -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.langs.dsvs; import gplx.*; import gplx.langs.*;
|
||||
public class Dsv_tbl_parser implements GfoInvkAble, RlsAble {
|
||||
public class Dsv_tbl_parser implements GfoInvkAble, Rls_able {
|
||||
private Dsv_wkr_base mgr;
|
||||
private Dsv_fld_parser[] fld_parsers = new Dsv_fld_parser[2]; private int fld_parsers_len = 2;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.parsers.amps.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Gfo_url_encoder implements Url_encoder_interface {
|
||||
private Gfo_url_encoder_itm[] encode_ary, decode_ary; private Gfo_url_encoder anchor_encoder = null;
|
||||
public Gfo_url_encoder(Gfo_url_encoder_itm[] encode_ary, Gfo_url_encoder_itm[] decode_ary, Gfo_url_encoder anchor_encoder) {
|
||||
|
||||
@@ -21,14 +21,15 @@ import gplx.xowa.parsers.amps.*;
|
||||
public class Gfo_url_encoder_ {
|
||||
public static final Gfo_url_encoder
|
||||
Id = Gfo_url_encoder_.New__html_id().Make()
|
||||
, Href = Gfo_url_encoder_.New__html_href_mw().Make()
|
||||
, Href = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Make()
|
||||
, Href_wo_anchor = Gfo_url_encoder_.New__html_href_mw(Bool_.N).Make()
|
||||
, Href_quotes = Gfo_url_encoder_.New__html_href_quotes().Make()
|
||||
, Href_qarg = Gfo_url_encoder_.New__html_href_qarg().Make()
|
||||
, Xourl = Gfo_url_encoder_.New__html_href_mw().Init__same__many(Byte_ascii.Underline).Make()
|
||||
, Xourl = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Init__same__many(Byte_ascii.Underline).Make()
|
||||
, Http_url = Gfo_url_encoder_.New__http_url().Make()
|
||||
, Http_url_ttl = Gfo_url_encoder_.New__http_url_ttl().Make()
|
||||
, Fsys = Gfo_url_encoder_.New__fsys_lnx().Make()
|
||||
, Fsys_safe = Gfo_url_encoder_.New__fsys_wnt().Make()
|
||||
, Fsys_lnx = Gfo_url_encoder_.New__fsys_lnx().Make()
|
||||
, Fsys_wnt = Gfo_url_encoder_.New__fsys_wnt().Make()
|
||||
, Gfs = Gfo_url_encoder_.New__gfs().Make()
|
||||
;
|
||||
private static Gfo_url_encoder_mkr New__html_id() { // EX: "<a id='a<>b'>" -> "<a id='a.C3.A9b'>"
|
||||
@@ -37,25 +38,28 @@ public class Gfo_url_encoder_ {
|
||||
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline)
|
||||
.Init__html_ent(Byte_ascii.Amp, Xop_amp_trie.Instance);
|
||||
}
|
||||
private static Gfo_url_encoder_mkr New__html_href_mw() { // EX: "<a href='^#^'>" -> "<a href='%5E#.5E'>"
|
||||
private static Gfo_url_encoder_mkr New__html_href_mw(boolean use_anchor_encoder) { // EX: "<a href='^#^'>" -> "<a href='%5E#.5E'>"; REF.MW: ";:@$!*(),/"
|
||||
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
|
||||
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline)
|
||||
.Init__same__many
|
||||
( Byte_ascii.Semic, Byte_ascii.At, Byte_ascii.Dollar, Byte_ascii.Bang, Byte_ascii.Star
|
||||
, Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Comma, Byte_ascii.Slash, Byte_ascii.Colon
|
||||
( Byte_ascii.Semic, Byte_ascii.Colon, Byte_ascii.At, Byte_ascii.Dollar, Byte_ascii.Bang, Byte_ascii.Star
|
||||
, Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Comma, Byte_ascii.Slash
|
||||
, Byte_ascii.Hash// NOTE: not part of wfUrlEncode; not sure where this is specified; needed for A#b
|
||||
)
|
||||
.Init__anchor_encoder(New__html_id().Make());
|
||||
.Init__anchor_encoder(use_anchor_encoder ? New__html_id().Make() : null);
|
||||
}
|
||||
private static Gfo_url_encoder_mkr New__html_href_qarg() { // same as regular href encoder, but also do not encode qarg characters "?" and "="
|
||||
return New__html_href_mw().Init__same__many(Byte_ascii.Question, Byte_ascii.Eq);
|
||||
return New__html_href_mw(Bool_.Y).Init__same__many(Byte_ascii.Question, Byte_ascii.Eq);
|
||||
}
|
||||
private static Gfo_url_encoder_mkr New__html_href_quotes() {
|
||||
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent)
|
||||
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline) // convert " " to "_"
|
||||
.Init__same__rng(0, 255) // default everything to same;
|
||||
.Init__diff__many(Byte_ascii.Percent, Byte_ascii.Apos
|
||||
, Byte_ascii.Quote, Byte_ascii.Lt, Byte_ascii.Gt); // encode ', ", <, >
|
||||
private static Gfo_url_encoder_mkr New__html_href_quotes() {// same as href encoder, but do not encode ?, =, #, +; also, don't encode "%" vals
|
||||
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
|
||||
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline)
|
||||
.Init__same__many
|
||||
( Byte_ascii.Semic, Byte_ascii.Colon, Byte_ascii.At, Byte_ascii.Dollar, Byte_ascii.Bang, Byte_ascii.Star
|
||||
, Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Comma, Byte_ascii.Slash
|
||||
, Byte_ascii.Question, Byte_ascii.Eq, Byte_ascii.Hash, Byte_ascii.Plus// NOTE: not part of wfUrlEncode; not sure where this is specified; needed for A#b
|
||||
)
|
||||
;
|
||||
}
|
||||
public static Gfo_url_encoder_mkr New__http_url() {
|
||||
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.N)
|
||||
|
||||
@@ -54,7 +54,7 @@ class Gfo_url_encoder_fxt {
|
||||
public Gfo_url_encoder_fxt Encoder_id() {encoder = Gfo_url_encoder_.Id; return this;}
|
||||
public Gfo_url_encoder_fxt Encoder_href() {encoder = Gfo_url_encoder_.Href; return this;}
|
||||
public Gfo_url_encoder_fxt Encoder_url() {encoder = Gfo_url_encoder_.Http_url; return this;}
|
||||
public Gfo_url_encoder_fxt Encoder_fsys_safe() {encoder = Gfo_url_encoder_.Fsys_safe; return this;}
|
||||
public Gfo_url_encoder_fxt Encoder_fsys_safe() {encoder = Gfo_url_encoder_.Fsys_wnt; return this;}
|
||||
public void Test__bicode(String raw, String encoded) {
|
||||
Test__encode(raw, encoded);
|
||||
Test__decode(encoded, raw);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Html_atr extends gplx.core.brys.Bfr_arg_base {
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public int Val_bgn() {return val_bgn;} private final int val_bgn;
|
||||
public int Val_end() {return val_end;} private final int val_end;
|
||||
public boolean Val_dat_exists() {return val_end > val_bgn;}
|
||||
public boolean Val_dat_exists() {return val_end != -1;}
|
||||
public boolean Val_dat_missing() {return val_end == -1;}
|
||||
public byte[] Val() {
|
||||
if (val == null)
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
|| (name_id != Html_tag_.Id__eos && Int_.In(chk, Html_tag_.Id__any, Html_tag_.Id__comment))) {
|
||||
}
|
||||
else
|
||||
tag_rdr.Rdr().Fail("name_id chk failed", "expecting", Html_tag_.To_str(chk));
|
||||
tag_rdr.Err_wkr().Fail("name_id chk failed", "expecting", Html_tag_.To_str(chk));
|
||||
return this;
|
||||
}
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
@@ -48,6 +48,7 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
public boolean Src_exists() {return src_end > src_bgn;} // NOTE: only true if EOS where src_end == src_bgn == src_len
|
||||
public boolean Tag_is_tail() {return tag_is_tail;} private boolean tag_is_tail;
|
||||
public boolean Tag_is_inline() {return tag_is_inline;} private boolean tag_is_inline;
|
||||
public int Atrs__len() {if (atrs_null) Atrs__make(); return atrs_hash.Count();}
|
||||
public boolean Atrs__match_pair(byte[] key, byte[] val) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key);
|
||||
@@ -61,8 +62,8 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
}
|
||||
public byte Atrs__cls_find_or_fail(Hash_adp_bry hash) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr cls_atr = (Html_atr)atrs_hash.Get_by(Html_atr_.Bry__class); if (cls_atr == null) tag_rdr.Rdr().Fail("cls missing", String_.Empty, String_.Empty);
|
||||
byte rv = Html_atr_class_.Find_1st(src, cls_atr.Val_bgn(), cls_atr.Val_end(), hash); if (rv == Byte_.Max_value_127) tag_rdr.Rdr().Fail("cls val missing", String_.Empty, String_.Empty);
|
||||
Html_atr cls_atr = (Html_atr)atrs_hash.Get_by(Html_atr_.Bry__class); if (cls_atr == null) tag_rdr.Err_wkr().Fail("cls missing");
|
||||
byte rv = Html_atr_class_.Find_1st(src, cls_atr.Val_bgn(), cls_atr.Val_end(), hash); if (rv == Byte_.Max_value_127) tag_rdr.Err_wkr().Fail("cls val missing");
|
||||
return rv;
|
||||
}
|
||||
private static final Html_atr_style_wkr__get_val_as_int style_wkr = new Html_atr_style_wkr__get_val_as_int();
|
||||
@@ -78,7 +79,7 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
return rv == null ? Bry_.Empty : rv.Val();
|
||||
}
|
||||
public int Atrs__get_as_int(byte[] key) {
|
||||
int rv = Atrs__get_as_int_or(key, Int_.Min_value); if (rv == Int_.Min_value) tag_rdr.Rdr().Fail("atr missing", "key", key);
|
||||
int rv = Atrs__get_as_int_or(key, Int_.Min_value); if (rv == Int_.Min_value) tag_rdr.Err_wkr().Fail("atr missing", "key", key);
|
||||
return rv;
|
||||
}
|
||||
public int Atrs__get_as_int_or(byte[] key, int or) {
|
||||
@@ -86,13 +87,14 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key); if (rv == null) return or;
|
||||
return Bry_.To_int_or(src, rv.Val_bgn(), rv.Val_end(), or);
|
||||
}
|
||||
public Html_atr Atrs__get_by_or_fail(byte[] key) {return Atrs__get_by_or_fail(key, Bool_.Y);}
|
||||
public Html_atr Atrs__get_at(int i) {return (Html_atr)atrs_hash.Get_at(i);}
|
||||
public Html_atr Atrs__get_by_or_fail(byte[] key) {return Atrs__get_by_or_fail(key, Bool_.Y);}
|
||||
public Html_atr Atrs__get_by_or_empty(byte[] key) {return Atrs__get_by_or_fail(key, Bool_.N);}
|
||||
public Html_atr Atrs__get_by_or_fail(byte[] key, boolean fail_if_null) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key);
|
||||
if (rv == null) {
|
||||
if (fail_if_null) tag_rdr.Rdr().Fail("atr missing", "key", key);
|
||||
if (fail_if_null) tag_rdr.Err_wkr().Fail("atr missing", "key", key);
|
||||
else return Html_atr.Noop;
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -25,19 +25,17 @@ public class Html_tag_rdr {
|
||||
private final Int_obj_ref tmp_depth = Int_obj_ref.zero_();
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public Bry_rdr Rdr() {return rdr;} private final Bry_rdr rdr = new Bry_rdr();
|
||||
public Bry_err_wkr Err_wkr() {return err_wkr;} private final Bry_err_wkr err_wkr = new Bry_err_wkr();
|
||||
public void Init(byte[] ctx, byte[] src, int src_bgn, int src_end) {
|
||||
this.src = src; this.pos = src_bgn; this.src_end = src_end;
|
||||
tag__eos.Init(this, src, Bool_.N, Bool_.N, src_end, src_end, src_end, src_end, Html_tag_.Id__eos);
|
||||
rdr.Init_by_page(ctx, src, src_end);
|
||||
err_wkr.Init_by_page(String_.new_u8(ctx), src);
|
||||
}
|
||||
public int Pos() {return pos;} private int pos;
|
||||
public void Pos_(int v) {this.pos = v;}
|
||||
public void Atrs__make(Mwh_atr_wkr atr_wkr, int head_bgn, int head_end) {atr_parser.Parse(atr_wkr, -1, -1, src, head_bgn, head_end);}
|
||||
public void Fail(String msg, Html_tag tag) {rdr.Fail(msg, String_.Empty, String_.Empty, tag.Src_bgn(), tag.Src_end());}
|
||||
public Html_tag Tag__move_fwd_head() {return Tag__find(Bool_.Y, Bool_.N, Bool_.N, pos, src_end, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__move_fwd_head(int match_name_id) {return Tag__find(Bool_.Y, Bool_.N, Bool_.N, pos, src_end, match_name_id);}
|
||||
// public Html_tag Tag__move_fwd_tail() {return Tag__find(Bool_.Y, Bool_.N, Bool_.Y, pos, src_end, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__move_fwd_tail(int match_name_id) {return Tag__find(Bool_.Y, Bool_.N, Bool_.Y, pos, src_end, match_name_id);}
|
||||
public Html_tag Tag__peek_fwd_head() {return Tag__find(Bool_.N, Bool_.N, Bool_.N, pos, src_end, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__peek_fwd_head(int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.N, pos, src_end, match_name_id);}
|
||||
@@ -70,7 +68,7 @@ public class Html_tag_rdr {
|
||||
}
|
||||
if (rv == null) {
|
||||
if (move && tail && !bwd)
|
||||
rdr.Fail("move failed", "tag_name", Html_tag_.To_str(match_name_id));
|
||||
err_wkr.Fail("move failed", "tag_name", Html_tag_.To_str(match_name_id));
|
||||
else
|
||||
return Tag__eos(rng_bgn);
|
||||
}
|
||||
@@ -181,7 +179,7 @@ public class Html_tag_rdr {
|
||||
return false;
|
||||
}
|
||||
public int Read_int_to(byte to_char) {
|
||||
int rv = Read_int_to(to_char, Int_.Max_value); if (rv == Int_.Max_value) rdr.Fail("invalid int", "pos", pos);
|
||||
int rv = Read_int_to(to_char, Int_.Max_value); if (rv == Int_.Max_value) err_wkr.Fail("invalid int", "pos", pos);
|
||||
return rv;
|
||||
}
|
||||
public int Read_int_to(byte to_char, int or_int) {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.11.4.1";
|
||||
public static final String Version = "2.12.1.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -22,7 +22,8 @@ public interface Xoa_page {
|
||||
Xoa_url Url();
|
||||
byte[] Url_bry_safe();
|
||||
Xoa_ttl Ttl();
|
||||
void Xtn_gallery_packed_exists_y_();
|
||||
boolean Exists();
|
||||
|
||||
Xoa_page__commons_mgr Commons_mgr();
|
||||
void Xtn_gallery_packed_exists_y_();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
Bry_.Replace_reuse(rv, Byte_ascii.Space, Byte_ascii.Underline);
|
||||
return rv;
|
||||
}
|
||||
public String Page_db_as_str() {return String_.new_u8(Page_db());}
|
||||
public String Page_db_as_str() {return String_.new_u8(Page_db());}
|
||||
public byte[] Page_url_w_anch() {return Gfo_url_encoder_.Href.Encode(Bry_.Mid(full_txt, page_bgn, qarg_bgn == -1 ? full_txt.length : qarg_bgn - 1));}
|
||||
public int Leaf_bgn() {return leaf_bgn;}
|
||||
public byte[] Base_txt() {return leaf_bgn == -1 ? Page_txt() : Bry_.Mid(full_txt, page_bgn, leaf_bgn - 1);}
|
||||
public byte[] Leaf_txt() {return leaf_bgn == -1 ? Page_txt() : Bry_.Mid(full_txt, leaf_bgn, anch_bgn == -1 ? full_txt.length : anch_bgn - 1);}
|
||||
@@ -52,7 +53,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
public byte[] Anch_txt() {return anch_bgn == -1 ? Bry_.Empty : Bry_.Mid(full_txt, anch_bgn, full_txt.length);}
|
||||
public byte[] Talk_txt() {return ns.Id_is_talk() ? Full_txt() : Bry_.Add(tors_txt, Page_txt());}
|
||||
public byte[] Subj_txt() {return ns.Id_is_subj() ? Full_txt() : Bry_.Add(tors_txt, Page_txt());}
|
||||
public byte[] Full_url() {return Xoa_url_encoder.Instance.Encode(full_txt);}
|
||||
public byte[] Full_url() {return Gfo_url_encoder_.Href.Encode(full_txt);}
|
||||
public String Full_db_as_str() {return String_.new_u8(Full_db());}
|
||||
public byte[] Full_db() {return ns.Gen_ttl(this.Page_db());}
|
||||
public byte[] Full_db_w_anch() {return Replace_spaces(full_txt);}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
public Xoae_app(Gfo_usr_dlg usr_dlg, Xoa_app_mode mode, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url user_dir, Io_url css_dir, String bin_dir_name) {
|
||||
Xoa_app_.Usr_dlg_(usr_dlg);
|
||||
this.mode = mode;
|
||||
Io_url.Http_file_str_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys;
|
||||
Io_url.Http_file_str_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx;
|
||||
fsys_mgr = new Xoa_fsys_mgr(bin_dir_name, root_dir, wiki_dir, file_dir, css_dir);
|
||||
log_wtr = usr_dlg.Log_wkr();
|
||||
cfg_mgr = new Xoa_cfg_mgr(this);
|
||||
|
||||
@@ -16,11 +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; import gplx.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.xowa.htmls.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.htmls.tocs.*;
|
||||
import gplx.xowa.htmls.modules.popups.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
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.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) {
|
||||
this.wiki = wiki; this.ttl = ttl;
|
||||
@@ -28,13 +28,13 @@ public class Xoae_page implements Xoa_page {
|
||||
hdr_mgr = new Xow_hdr_mgr(this);
|
||||
redlink_lnki_list = new Xopg_redlink_lnki_list(ttl.Ns().Id_is_module());
|
||||
Ttl_(ttl);
|
||||
} Xoae_page() {} // called by Null
|
||||
} Xoae_page() {} // called by Empty
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
public Xoa_ttl Ttl() {return ttl;} public Xoae_page Ttl_(Xoa_ttl v) {ttl = v; url.Wiki_bry_(wiki.Domain_bry()).Page_bry_(v.Full_url()); return this;} private Xoa_ttl ttl;
|
||||
public Xoa_url Url() {return url;} public Xoae_page Url_(Xoa_url v) {url = v; return this;} private Xoa_url url = Xoa_url.blank();
|
||||
public byte[] Url_bry_safe() {return url == null ? Bry_.Empty : url.Raw();}
|
||||
public void Xtn_gallery_packed_exists_y_() {html_data.Xtn_gallery_packed_exists_y_();}
|
||||
public boolean Exists() {return !Missing();}
|
||||
public void Xtn_gallery_packed_exists_y_() {html_data.Xtn_gallery_packed_exists_y_();}
|
||||
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
@@ -58,7 +58,7 @@ public class Xoae_page implements Xoa_page {
|
||||
public List_adp Lnki_list() {return lnki_list;} public void Lnki_list_(List_adp v) {this.lnki_list = v;} private List_adp lnki_list = List_adp_.new_();
|
||||
public Xof_xfer_queue File_queue() {return file_queue;} private Xof_xfer_queue file_queue = new Xof_xfer_queue();
|
||||
public List_adp File_math() {return file_math;} private List_adp file_math = List_adp_.new_();
|
||||
public Ref_itm_mgr Ref_mgr() {return ref_mgr;} private Ref_itm_mgr ref_mgr = new Ref_itm_mgr();
|
||||
public Ref_itm_mgr Ref_mgr() {return ref_mgr;} private Ref_itm_mgr ref_mgr = new Ref_itm_mgr(); public void Ref_mgr_(Ref_itm_mgr v) {this.ref_mgr = v;}
|
||||
public Xopg_popup_mgr Popup_mgr() {return popup_mgr;} private Xopg_popup_mgr popup_mgr = new Xopg_popup_mgr();
|
||||
public List_adp Slink_list() {return slink_list;} private List_adp slink_list = List_adp_.new_();
|
||||
public Wdata_external_lang_links_data Wdata_external_lang_links() {return wdata_external_lang_links;} private Wdata_external_lang_links_data wdata_external_lang_links = new Wdata_external_lang_links_data();
|
||||
@@ -79,7 +79,8 @@ public class Xoae_page implements Xoa_page {
|
||||
tmpl_stack_ary_len = new_len;
|
||||
return true;
|
||||
} private byte[][] tmpl_stack_ary = Bry_.Ary_empty; private int tmpl_stack_ary_len = 0, tmpl_stack_ary_max = 0;
|
||||
public void Clear() { // NOTE: this is called post-fetch but pre-parse; do not clear items set by post-fetch, such as id, ttl, redirected_ttls, data_raw
|
||||
public void Clear_all() {Clear(true);}
|
||||
public void Clear(boolean clear_scrib) { // NOTE: this is called post-fetch but pre-parse; do not clear items set by post-fetch, such as id, ttl, redirected_ttls, data_raw
|
||||
hdr_mgr.Clear();
|
||||
lnki_list.Clear();
|
||||
file_math.Clear();
|
||||
@@ -88,7 +89,7 @@ public class Xoae_page implements Xoa_page {
|
||||
html_cmd_mgr.Clear();
|
||||
hdump_data.Clear();
|
||||
wdata_external_lang_links.Reset();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core.Core_page_changed(this);
|
||||
if (clear_scrib) gplx.xowa.xtns.scribunto.Scrib_core.Core_page_changed(this);
|
||||
slink_list.Clear();
|
||||
html_data.Clear();
|
||||
tab_data.Clear();
|
||||
@@ -100,13 +101,9 @@ public class Xoae_page implements Xoa_page {
|
||||
tmpl_prepend_mgr.Clear();
|
||||
commons_mgr.Clear();
|
||||
}
|
||||
public static final Xoae_page Null = null;
|
||||
private Xoae_page Edit_mode_create_() {edit_mode = Xoa_page_.Edit_mode_create; return this;}
|
||||
public static final Xoae_page Empty = new Xoae_page().Missing_();
|
||||
public static Xoae_page test_(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl);}
|
||||
public static Xoae_page new_(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl);}
|
||||
public static Xoae_page create_(Xowe_wiki wiki, Xoa_ttl ttl) {
|
||||
Xoae_page rv = new Xoae_page(wiki, ttl);
|
||||
rv.edit_mode = Xoa_page_.Edit_mode_create;
|
||||
return rv;
|
||||
}
|
||||
public static Xoae_page New(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl);}
|
||||
public static Xoae_page New_test(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl);}
|
||||
public static Xoae_page New_edit(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl).Edit_mode_create_();}
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ public class Xop_fxt {
|
||||
public void Lang_by_id_(int id) {ctx.Cur_page().Lang_(wiki.Appe().Lang_mgr().Get_by_or_new(Xol_lang_stub_.Get_by_id(id).Key()));}
|
||||
public Xoh_html_wtr_cfg Wtr_cfg() {return hdom_wtr.Cfg();} private Xoh_html_wtr hdom_wtr;
|
||||
public Xop_fxt Reset() {
|
||||
ctx.Clear();
|
||||
ctx.Clear_all();
|
||||
ctx.App().Free_mem(false);
|
||||
ctx.Cur_page().Clear();
|
||||
ctx.Cur_page().Clear_all();
|
||||
wiki.Db_mgr().Load_mgr().Clear();
|
||||
app.Wiki_mgr().Clear();
|
||||
Io_mgr.Instance.InitEngine_mem(); // clear created pages
|
||||
@@ -286,12 +286,13 @@ public class Xop_fxt {
|
||||
hdom_wtr.Write_all(actl_bfr, ctx, root.Root_src(), root);
|
||||
return actl_bfr.To_str_and_clear();
|
||||
}
|
||||
public void Hctx_(Xoh_wtr_ctx v) {hctx = v;} private Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Basic;
|
||||
public String Exec_parse_page_wiki_as_str(String raw) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Xop_root_tkn root = tkn_mkr.Root(raw_bry);
|
||||
parser.Parse_wtxt_to_wdom(root, ctx, tkn_mkr, raw_bry, Xop_parser_.Doc_bgn_bos);
|
||||
Bry_bfr actl_bfr = Bry_bfr.new_();
|
||||
hdom_wtr.Write_all(actl_bfr, ctx, raw_bry, root);
|
||||
hdom_wtr.Write_all(actl_bfr, ctx, hctx, raw_bry, root);
|
||||
return actl_bfr.To_str_and_clear();
|
||||
}
|
||||
private void Parse_chk(byte[] raw_bry, Xop_root_tkn root, Tst_chkr[] expd_ary) {
|
||||
|
||||
@@ -218,7 +218,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
if (rls_list == null) return;
|
||||
int len = rls_list.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
RlsAble rls = (RlsAble)rls_list.Get_at(i);
|
||||
Rls_able rls = (Rls_able)rls_list.Get_at(i);
|
||||
rls.Rls();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private byte zip_tid_text = Io_stream_.Tid_gzip;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private byte zip_tid_html = Io_stream_.Tid_gzip;
|
||||
public boolean Hzip_enabled() {return hzip_enabled;} private boolean hzip_enabled = Bool_.Y;
|
||||
public boolean Hzip_mode_is_b256() {return hzip_mode_is_b256;} private boolean hzip_mode_is_b256 = Bool_.Y;
|
||||
public String User_name() {return user_name;} private String user_name = "anonymous";
|
||||
public Xowd_core_db_props New_props(String domain_str, long dump_file_size) {
|
||||
Xowd_db_layout layout_text, layout_html, layout_file;
|
||||
@@ -40,7 +41,7 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
layout_html = dump_file_size < layout_html_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
|
||||
layout_file = dump_file_size < layout_file_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
|
||||
}
|
||||
return new Xowd_core_db_props(2, layout_text, layout_html, layout_file, zip_tid_text, zip_tid_html, hzip_enabled);
|
||||
return new Xowd_core_db_props(2, layout_text, layout_html, layout_file, zip_tid_text, zip_tid_html, hzip_enabled, hzip_mode_is_b256);
|
||||
}
|
||||
public byte[] New_ns_file_map(long dump_file_size) {
|
||||
return dump_file_size < layout_text_max ? Bry_.Empty : Ns_file_map__each;
|
||||
@@ -72,6 +73,8 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_zip_tid_html_)) zip_tid_html = Io_stream_.To_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_hzip_enabled)) return Yn.To_str(hzip_enabled);
|
||||
else if (ctx.Match(k, Invk_hzip_enabled_)) hzip_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_hzip_mode_is_b256)) return Yn.To_str(hzip_mode_is_b256);
|
||||
else if (ctx.Match(k, Invk_hzip_mode_is_b256_)) hzip_mode_is_b256 = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_user_name)) return user_name;
|
||||
else if (ctx.Match(k, Invk_user_name_)) user_name = m.ReadStr("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
@@ -91,7 +94,8 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
, Invk_zip_tid_text = "zip_tid_text" , Invk_zip_tid_text_ = "zip_tid_text_", Invk_zip_tid_list = "zip_tid_list"
|
||||
, Invk_zip_tid_html = "zip_tid_html" , Invk_zip_tid_html_ = "zip_tid_html_"
|
||||
, Invk_user_name = "user_name" , Invk_user_name_ = "user_name_"
|
||||
, Invk_hzip_enabled = "hzip_enabled" , Invk_hzip_enabled_ = "hzip_enabled_"
|
||||
, Invk_hzip_enabled = "hzip_enabled" , Invk_hzip_enabled_ = "hzip_enabled_"
|
||||
, Invk_hzip_mode_is_b256 = "hzip_mode_is_b256" , Invk_hzip_mode_is_b256_ = "hzip_mode_is_b256_"
|
||||
;
|
||||
public static final byte[] Ns_file_map__each = Bry_.new_a7("<each>");
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xoapi_view implements GfoInvkAble {
|
||||
public void Save_as() {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
Xog_tab_itm tab = win.Tab_mgr().Active_tab();
|
||||
String file_name = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_safe.Encode_str(String_.new_u8(tab.Page().Ttl().Full_url())) + ".html";
|
||||
String file_name = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_wnt.Encode_str(String_.new_u8(tab.Page().Ttl().Full_url())) + ".html";
|
||||
String file_url = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(file_name).Ask();
|
||||
if (String_.Len_eq_0(file_url)) return;
|
||||
Io_mgr.Instance.SaveFilStr(file_url, tab.Html_box().Text());
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Xoa_fsys_mgr implements GfoInvkAble {
|
||||
this.cfg_app_fil = bin_xowa_dir.GenSubFil_nest("cfg", "app", "xowa.gfs");
|
||||
this.cfg_lang_core_dir = bin_xowa_dir.GenSubDir_nest("cfg", "lang", "core");
|
||||
this.cfg_wiki_core_dir = bin_xowa_dir.GenSubDir_nest("cfg", "wiki", "core");
|
||||
this.cfg_site_meta_fil = bin_xowa_dir.GenSubDir_nest("cfg", "wiki", "site_meta.sqlite3");
|
||||
this.cfg_site_meta_fil = bin_xowa_dir.GenSubFil_nest("cfg", "wiki", "site_meta.sqlite3");
|
||||
this.home_wiki_dir = bin_xowa_dir.GenSubDir_nest("wiki", Xow_domain_itm_.Str__home);
|
||||
}
|
||||
public Io_url Root_dir() {return root_dir;} private final Io_url root_dir;
|
||||
|
||||
@@ -16,8 +16,8 @@ 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; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.tests.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*;
|
||||
import gplx.core.tests.*; import gplx.core.ios.*; import gplx.core.times.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*;
|
||||
public class Xob_fxt {
|
||||
public Xob_fxt Ctor_mem() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
|
||||
@@ -140,8 +140,10 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
|
||||
usr_dlg.Prog_many("", "", "parsing: ns=~{0} db=~{1} pg=~{2} count=~{3} time=~{4} rate=~{5} ttl=~{6}"
|
||||
, ns.Id(), db_id, page.Id(), exec_count
|
||||
, Env_.TickCount_elapsed_in_sec(time_bgn), rate_mgr.Rate_as_str(), String_.new_u8(page.Ttl_page_db()));
|
||||
ctx.Clear();
|
||||
Exec_pg_itm_hook(ns_ord, ns, page, page.Text());
|
||||
ctx.Clear_all();
|
||||
byte[] page_src = page.Text();
|
||||
if (page_src != null) // some pages have no text; ignore them else null ref; PAGE: it.d:miercuri DATE:2015-12-05
|
||||
Exec_pg_itm_hook(ns_ord, ns, page, page_src);
|
||||
ctx.App().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released
|
||||
if (ctx.Wiki().Cache_mgr().Tmpl_result_cache().Count() > 50000)
|
||||
ctx.Wiki().Cache_mgr().Tmpl_result_cache().Clear();
|
||||
@@ -155,7 +157,7 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
|
||||
Free();
|
||||
}
|
||||
catch (Exception exc) {
|
||||
bldr.Usr_dlg().Warn_many(GRP_KEY, "parse", "failed to parse ~{0} error ~{1}", String_.new_u8(page.Ttl_page_db()), Err_.Message_lang(exc));
|
||||
bldr.Usr_dlg().Warn_many("", "", "parse failed: wiki=~{0} ttl=~{1} err=~{2}", wiki.Domain_str(), page.Ttl_full_db(), Err_.Message_gplx_log(exc));
|
||||
ctx.App().Utl__bfr_mkr().Clear();
|
||||
this.Free();
|
||||
}
|
||||
@@ -216,7 +218,6 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
|
||||
, Invk_poll_mgr = "poll_mgr", Invk_reset_db_ = "reset_db_"
|
||||
, Invk_exec_count_max_ = "exec_count_max_", Invk_exit_now_ = "exit_now_", Invk_exit_after_commit_ = "exit_after_commit_"
|
||||
;
|
||||
private static final String GRP_KEY = "xowa.bldr.parse";
|
||||
}
|
||||
class Xob_dump_mgr_base_ {
|
||||
public static void Load_all_tmpls(Gfo_usr_dlg usr_dlg, Xowe_wiki wiki, Xob_dump_src_id page_src) {
|
||||
|
||||
@@ -16,8 +16,8 @@ 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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.core.brys.*; import gplx.core.ios.*; import gplx.xowa.wikis.ctgs.*;
|
||||
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
|
||||
import gplx.core.brys.*; import gplx.core.ios.*; import gplx.core.times.*;
|
||||
import gplx.xowa.wikis.ctgs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
|
||||
public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implements Sql_file_parser_cmd {
|
||||
private DateAdp_parser date_parser = DateAdp_parser.new_(); private Sql_file_parser sql_parser; Uca_trie trie; private Bry_bfr uca_bfr = Bry_bfr.reset_(255);
|
||||
public abstract Io_sort_cmd Make_sort_cmd(Sql_file_parser sql_parser);
|
||||
|
||||
@@ -25,7 +25,7 @@ import gplx.fsdb.data.*; import gplx.fsdb.meta.*;
|
||||
public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
private Db_conn bldr_conn; private Db_cfg_tbl bldr_cfg_tbl;
|
||||
private Xof_bin_mgr src_bin_mgr; private Xof_bin_wkr__fsdb_sql src_fsdb_wkr; private boolean src_bin_mgr__cache_enabled = Bool_.N; private String src_bin_mgr__fsdb_version; private String[] src_bin_mgr__fsdb_skip_wkrs; private boolean src_bin_mgr__wmf_enabled;
|
||||
private Fsm_mnt_itm trg_mnt_itm; private Fsm_cfg_mgr trg_cfg_mgr; private Fsm_atr_fil trg_atr_fil; private Fsm_bin_fil trg_bin_fil; private long trg_bin_db_max;
|
||||
private Fsm_mnt_itm trg_mnt_itm; private Fsm_cfg_mgr trg_cfg_mgr; private Fsm_atr_fil trg_atr_fil; private Fsm_bin_fil trg_bin_fil; private long trg_bin_db_max; private String trg_bin_mgr__fsdb_version;
|
||||
private final Xof_bin_updater trg_bin_updater = new Xof_bin_updater(); private Xob_bin_db_mgr bin_db_mgr; private int[] ns_ids; private int prv_lnki_tier_id = -1;
|
||||
private long download_size_max = Io_mgr.Len_mb_long * 5; private int[] download_keep_tier_ids = Int_.Ary(0);
|
||||
private Xobu_poll_mgr poll_mgr; private int poll_interval; private long time_bgn;
|
||||
@@ -66,7 +66,8 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
}
|
||||
// trg_mnt_itm
|
||||
this.trg_bin_db_max = app.Api_root().Bldr().Wiki().Import().File_db_max();
|
||||
Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
|
||||
Io_url trg_file_dir_v1 = String_.Eq(trg_bin_mgr__fsdb_version, "v1") ? wiki.Fsys_mgr().File_dir().GenNewNameOnly(wiki.Domain_str() + "-prv") : wiki.Fsys_mgr().File_dir(); // NOTE: convoluted way of setting trg to -prv if trg_bin_mgr__fsdb_version_v1 is set; otherwise set to "en.wikipedia.org" which will noop; DATE:2015-12-02
|
||||
Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), trg_file_dir_v1);
|
||||
if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, Bool_.Y);
|
||||
Fsm_mnt_mgr trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(trg_db_mgr);
|
||||
trg_mnt_mgr.Mnts__get_insert_idx_(Fsm_mnt_mgr.Mnt_idx_main); // NOTE: do not delete; mnt_mgr default to Mnt_idx_user; DATE:2014-04-25
|
||||
@@ -317,6 +318,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
else if (ctx.Match(k, Invk_src_bin_mgr__fsdb_skip_wkrs_)) src_bin_mgr__fsdb_skip_wkrs = m.ReadStrAry("v", "|");
|
||||
else if (ctx.Match(k, Invk_src_bin_mgr__wmf_enabled_)) src_bin_mgr__wmf_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_src_bin_mgr__cache_enabled_)) src_bin_mgr__cache_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_trg_bin_mgr__fsdb_version_)) trg_bin_mgr__fsdb_version = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_poll_mgr)) return poll_mgr;
|
||||
else if (ctx.Match(k, Invk_download_keep_tier_ids)) download_keep_tier_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
|
||||
else if (ctx.Match(k, Invk_download_size_max)) download_size_max = Io_size_.To_long_by_msg_mb(m, download_size_max);
|
||||
@@ -331,6 +333,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
, Invk_src_bin_mgr__fsdb_version_ = "src_bin_mgr__fsdb_version_", Invk_src_bin_mgr__fsdb_skip_wkrs_ = "src_bin_mgr__fsdb_skip_wkrs_"
|
||||
, Invk_src_bin_mgr__wmf_enabled_ = "src_bin_mgr__wmf_enabled_"
|
||||
, Invk_src_bin_mgr__cache_enabled_ = "src_bin_mgr__cache_enabled_", Invk_ns_ids_ = "ns_ids_"
|
||||
, Invk_trg_bin_mgr__fsdb_version_ = "trg_bin_mgr__fsdb_version_"
|
||||
, Invk_download_size_max = "download_size_max", Invk_download_keep_tier_ids = "download_keep_tier_ids"
|
||||
;
|
||||
public static Fsdb_db_mgr new_src_bin_db_mgr(Xow_wiki wiki, String version) {
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), ns.Id(), ttl_bry);
|
||||
if (page_tid != Xow_page_tid.Tid_wikitext) return; // ignore js, css, lua, json
|
||||
Xoae_page page = ctx.Cur_page();
|
||||
page.Clear();
|
||||
page.Clear_all();
|
||||
page.Bldr__ns_ord_(ns_ord);
|
||||
page.Ttl_(ttl).Revision_data().Id_(db_page.Id());
|
||||
page.Redlink_lnki_list().Clear();
|
||||
|
||||
@@ -68,7 +68,7 @@ class Dg_file_tbl {
|
||||
.Exec_insert();
|
||||
}
|
||||
}
|
||||
class Dg_rule_tbl implements RlsAble {
|
||||
class Dg_rule_tbl implements Rls_able {
|
||||
private String tbl_name = "dg_rule"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String fld_file_id, fld_rule_id, fld_rule_idx, fld_rule_score, fld_rule_text;
|
||||
private Db_conn conn; private Db_stmt stmt_insert;
|
||||
@@ -101,7 +101,7 @@ class Dg_rule_tbl implements RlsAble {
|
||||
.Exec_insert();
|
||||
}
|
||||
}
|
||||
class Dg_page_score_tbl implements RlsAble {
|
||||
class Dg_page_score_tbl implements Rls_able {
|
||||
private String tbl_name = "dg_page_score"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String fld_log_tid, fld_page_id, fld_page_ns, fld_page_ttl, fld_page_len, fld_page_score, fld_page_rule_count, fld_clude_type;
|
||||
private Db_conn conn; private Db_stmt stmt_insert;
|
||||
@@ -141,7 +141,7 @@ class Dg_page_score_tbl implements RlsAble {
|
||||
.Exec_insert();
|
||||
}
|
||||
}
|
||||
class Dg_page_rule_tbl implements RlsAble {
|
||||
class Dg_page_rule_tbl implements Rls_able {
|
||||
private String tbl_name = "dg_page_rule"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String fld_log_tid, fld_page_id, fld_rule_id, fld_rule_score_total;
|
||||
private Db_conn conn; private Db_stmt stmt_insert;
|
||||
|
||||
@@ -16,8 +16,8 @@ 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.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.core.btries.*; import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.core.btries.*; import gplx.core.ios.*; import gplx.core.times.*;
|
||||
import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xob_xml_parser {
|
||||
Btrie_fast_mgr trie = Xob_xml_parser_.trie_(); Bry_bfr data_bfr = Bry_bfr.new_(); DateAdp_parser date_parser = DateAdp_parser.new_();
|
||||
public Xob_xml_parser Tag_len_max_(int v) {tag_len_max = v; return this;} private int tag_len_max = 255; // max size of any (a) xml tag, (b) int or (c) date; everything else goes into a data_bfr
|
||||
|
||||
@@ -16,7 +16,8 @@ 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.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import org.junit.*; import gplx.core.ios.*; import gplx.core.times.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xob_xml_parser_tst {
|
||||
@Before public void init() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
|
||||
@@ -16,16 +16,23 @@ 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.drds; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.drds.pages.*;
|
||||
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.*;
|
||||
public class Xod_app {
|
||||
private final Xoav_app app;
|
||||
private final Xod_page_mgr page_mgr = new Xod_page_mgr();
|
||||
private final Xod_file_mgr file_mgr = new Xod_file_mgr();
|
||||
public Xod_app(Xoav_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public Xod_page_itm Get_page(String wiki_domain, String page_ttl) {
|
||||
Xow_wiki wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(Bry_.new_u8(wiki_domain));
|
||||
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 Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
|
||||
return page_mgr.Get_page(wiki, page_ttl);
|
||||
}
|
||||
public void Load_files(Xow_wiki wiki, Xod_page_itm pg, Xog_js_wkr js_wkr) {
|
||||
file_mgr.Load_files(wiki, pg, js_wkr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class Xod_app_tst {
|
||||
private final Xod_app_tstr tstr = new Xod_app_tstr();
|
||||
@Before public void init() {tstr.Init_mem();}
|
||||
@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.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")));
|
||||
}
|
||||
}
|
||||
class Xod_app_tstr {
|
||||
@@ -41,7 +41,8 @@ class Xod_app_tstr {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
}
|
||||
public void Test__get(String ttl, Xod_page_itm expd) {
|
||||
Xod_page_itm itm = drd_provider.Get_page("en.wikipedia.org", ttl);
|
||||
Xow_wiki wiki = drd_provider.Get_wiki("en.wikipedia.org");
|
||||
Xod_page_itm itm = drd_provider.Get_page(wiki, ttl);
|
||||
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) {
|
||||
|
||||
39
400_xowa/src/gplx/xowa/drds/files/Xod_file_mgr.java
Normal file
39
400_xowa/src/gplx/xowa/drds/files/Xod_file_mgr.java
Normal 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.drds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.xowa.drds.pages.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.gui.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
public class Xod_file_mgr {
|
||||
private final Gfo_thread_pool thread_pool = new Gfo_thread_pool();
|
||||
public void Load_files(Xow_wiki wiki, Xod_page_itm pg, Xog_js_wkr js_wkr) {
|
||||
Xoh_page hpg = pg.Hpg();
|
||||
List_adp img_list = To_img_list(hpg.Img_mgr());
|
||||
Xof_file_wkr img_wkr = new Xof_file_wkr(wiki.File__orig_mgr(), wiki.File__bin_mgr(), wiki.File__mnt_mgr(), wiki.App().User().User_db_mgr().Cache_mgr(), wiki.File__repo_mgr(), js_wkr, hpg, img_list);
|
||||
thread_pool.Add_at_end(img_wkr);
|
||||
thread_pool.Run();
|
||||
}
|
||||
private static List_adp To_img_list(Xoh_img_mgr img_mgr) {
|
||||
List_adp rv = List_adp_.new_();
|
||||
int len = img_mgr.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
rv.Add(img_mgr.Get_at(i));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.drds.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
|
||||
import gplx.xowa.htmls.sections.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.sections.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xod_page_itm {
|
||||
public Xod_page_itm() {}
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public long Rev_id() {return rev_id;} private long rev_id;
|
||||
public String Ttl_text() {return ttl_text;} private String ttl_text;
|
||||
@@ -35,6 +34,7 @@ public class Xod_page_itm {
|
||||
public String Head_name() {return head_ttl;} private String head_ttl;
|
||||
public String First_allowed_editor_role() {return first_allowed_editor_role;} private String first_allowed_editor_role;
|
||||
public List_adp Section_list() {return section_list;} private List_adp section_list = List_adp_.new_();
|
||||
public Xoh_page Hpg() {return hpg;} private Xoh_page hpg;
|
||||
public void Init(int page_id, int rev_id
|
||||
, String ttl_text, String ttl_db, String redirected, String description, String modified_on
|
||||
, boolean is_editable, boolean is_main_page, boolean is_disambiguation, int lang_count
|
||||
@@ -46,8 +46,7 @@ public class Xod_page_itm {
|
||||
this.is_editable = is_editable; this.is_main_page = is_main_page; this.is_disambiguation = is_disambiguation; this.lang_count = lang_count;
|
||||
this.head_url = head_url; this.head_ttl= head_ttl; this.first_allowed_editor_role = first_allowed_editor_role;
|
||||
}
|
||||
public void Init() {}
|
||||
public void Init(Xoa_ttl ttl, Xowd_page_itm db_page) {
|
||||
public void Init_by_dbpg(Xoa_ttl ttl, Xowd_page_itm db_page) {
|
||||
this.page_id = db_page.Id();
|
||||
this.rev_id = page_id;
|
||||
this.ttl_text = String_.new_u8(ttl.Page_txt());
|
||||
@@ -63,6 +62,9 @@ public class Xod_page_itm {
|
||||
this.head_ttl = null;
|
||||
this.first_allowed_editor_role = null;
|
||||
}
|
||||
public void Init_by_hpg(Xoh_page hpg) {
|
||||
this.hpg = hpg;
|
||||
}
|
||||
public String To_str() {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
bfr .Add_int_variable(page_id).Add_byte_pipe()
|
||||
|
||||
@@ -21,15 +21,17 @@ import gplx.xowa.htmls.*; import gplx.xowa.htmls.sections.*;
|
||||
public class Xod_page_mgr {
|
||||
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
|
||||
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));
|
||||
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(ttl, dbpg);
|
||||
rv.Init_by_dbpg(ttl, dbpg);
|
||||
|
||||
// load page data
|
||||
Xoh_page hpg = new Xoh_page();
|
||||
hpg.Init(wiki, Xoa_url.new_(wiki.Domain_bry(), ttl.Page_db()), ttl, 1);
|
||||
rv.Init_by_hpg(hpg);
|
||||
wiki.Html__hdump_mgr().Load_mgr().Load(hpg, ttl);
|
||||
Load_sections(rv, hpg);
|
||||
return rv;
|
||||
|
||||
@@ -16,6 +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.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.bits.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xof_img_size {
|
||||
public int Html_w() {return html_w;} private int html_w;
|
||||
|
||||
@@ -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.files; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import org.junit.*; import gplx.core.bits.*; import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xof_img_size_tst {
|
||||
private final Xof_img_size_fxt fxt = new Xof_img_size_fxt();
|
||||
@Before public void init() {
|
||||
|
||||
@@ -16,6 +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.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.bits.*;
|
||||
public class Xof_patch_upright_tid_ {
|
||||
public static final int Tid_unpatched = 0, Tid_use_thumb_w = 1, Tid_fix_default = 2;
|
||||
public static final int Tid_all = Tid_use_thumb_w | Tid_fix_default;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
|
||||
class Xofc_dir_tbl implements RlsAble {
|
||||
class Xofc_dir_tbl implements Rls_able {
|
||||
private String tbl_name = "file_cache_dir"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String fld_id, fld_name;
|
||||
private Db_conn conn; private final Db_stmt_bldr stmt_bldr = new Db_stmt_bldr(); private Db_stmt select_stmt;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
|
||||
class Xofc_fil_tbl implements RlsAble {
|
||||
class Xofc_fil_tbl implements Rls_able {
|
||||
private String tbl_name = "file_cache_fil"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String fld_uid, fld_dir_id, fld_name, fld_is_orig, fld_w, fld_h, fld_time, fld_page, fld_ext, fld_size, fld_cache_time;
|
||||
private Db_conn conn; private final Db_stmt_bldr stmt_bldr = new Db_stmt_bldr(); private Db_stmt select_itm_stmt, select_itm_v2_stmt;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xou_cache_tbl implements RlsAble {
|
||||
public class Xou_cache_tbl implements Rls_able {
|
||||
private String tbl_name = "file_cache"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String
|
||||
fld_lnki_wiki_abrv, fld_lnki_ttl, fld_lnki_type, fld_lnki_upright, fld_lnki_w, fld_lnki_h, fld_lnki_time, fld_lnki_page, fld_user_thumb_w
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.commons; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xof_commons_image_tbl implements RlsAble {
|
||||
public class Xof_commons_image_tbl implements Rls_able {
|
||||
private Db_stmt stmt_insert;
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Conn_(Db_conn v) {
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.fsdb.fs_roots; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.dbs.*;
|
||||
public class Orig_fil_tbl implements RlsAble {
|
||||
public class Orig_fil_tbl implements Rls_able {
|
||||
private String tbl_name = "orig_fil"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private String fld_uid, fld_name, fld_ext_id, fld_w, fld_h, fld_dir_url;
|
||||
private Db_conn conn; private Db_stmt stmt_insert, stmt_select;
|
||||
|
||||
@@ -70,7 +70,7 @@ class Xof_file_fxt {
|
||||
List_adp itms_list = List_adp_.new_(); itms_list.Add(itm);
|
||||
orig_mgr.Find_by_list(Ordered_hash_.New_bry(), itms_list, Xof_exec_tid.Tid_wiki_page);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__main, ttl_bry);
|
||||
Xoae_page page = Xoae_page.new_(wiki, ttl);
|
||||
Xoae_page page = Xoae_page.New(wiki, ttl);
|
||||
fsdb_mgr.Fsdb_search_by_list(itms_list, wiki, page, Xog_js_wkr_.Noop);
|
||||
if (arg.Rslt_orig_exists() != Bool_.__byte) Tfds.Eq(arg.Rslt_orig_exists() == Bool_.Y_byte, itm.Orig_exists(), "orig_exists");
|
||||
if (arg.Rslt_file_exists() != Bool_.__byte) Tfds.Eq(arg.Rslt_file_exists() == Bool_.Y_byte, itm.File_exists(), "file_exists");
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.files.origs; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
import gplx.xowa.files.fsdb.*; import gplx.xowa.files.repos.*;
|
||||
public class Xof_orig_tbl implements RlsAble {
|
||||
public class Xof_orig_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_repo, fld_ttl, fld_status, fld_ext, fld_w, fld_h, fld_redirect;
|
||||
private final Db_conn conn; private final Xof_orig_tbl__in_wkr select_in_wkr = new Xof_orig_tbl__in_wkr();
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
ini_src_fils();
|
||||
wiki.Appe().File_mgr().Wmf_mgr().Enabled_(true);
|
||||
wiki.File_mgr().Cfg_download().Enabled_(true);
|
||||
queue.Exec(wiki, Xoae_page.new_(wiki, wiki.Ttl_parse(Bry_.new_a7("A"))));
|
||||
queue.Exec(wiki, Xoae_page.New(wiki, wiki.Ttl_parse(Bry_.new_a7("A"))));
|
||||
tst_trg_fils();
|
||||
if (this.html_orig_src != null) Tfds.Eq(this.html_orig_src , xfer_itm.Html_orig_url().To_http_file_str());
|
||||
if (this.Html_view_src() != null) Tfds.Eq(this.Html_view_src(), xfer_itm.Html_view_url().To_http_file_str());
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_kit)) return kit;
|
||||
else if (ctx.Match(k, Invk_kit_)) this.kit = Gfui_kit_.Get_by_key(m.ReadStrOr("v", Gfui_kit_.Swt().Key()));
|
||||
else if (ctx.Match(k, Invk_run)) Run(RlsAble_.Null);
|
||||
else if (ctx.Match(k, Invk_run)) Run(Rls_able_.Null);
|
||||
else if (ctx.Match(k, Invk_browser_type)) kit.Cfg_set("HtmlBox", "BrowserType", gplx.gfui.Swt_kit.Cfg_Html_BrowserType_parse(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Invk_xul_runner_path_)) kit.Cfg_set("HtmlBox", "XulRunnerPath", Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("v")).Xto_api());
|
||||
else if (ctx.Match(k, Invk_bnds)) return bnd_mgr;
|
||||
@@ -94,7 +94,7 @@ public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_menus)) return menu_mgr;
|
||||
else if (ctx.Match(k, Invk_cmds)) return cmd_mgr;
|
||||
else if (ctx.Match(k, Invk_url_macros)) return url_macro_mgr;
|
||||
else if (ctx.Match(k, Xoue_user.Evt_lang_changed)) Lang_changed((Xol_lang_itm)m.ReadObj("v", ParseAble_.Null));
|
||||
else if (ctx.Match(k, Xoue_user.Evt_lang_changed)) Lang_changed((Xol_lang_itm)m.ReadObj("v", null));
|
||||
else throw Err_.new_unhandled(k);
|
||||
return this;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
, Invk_main_win = "main_win", Invk_browser_win = "browser_win", Invk_bnds = "bnds"
|
||||
, Invk_bindings = "bindings", Invk_win_opts = "win_opts", Invk_layout = "layout", Invk_html = "html"
|
||||
, Invk_search_suggest = "search_suggest", Invk_menus = "menus", Invk_cmds = "cmds", Invk_url_macros = "url_macros";
|
||||
public void Run(RlsAble splash_win) {
|
||||
public void Run(Rls_able splash_win) {
|
||||
Gfo_log_bfr log_bfr = app.Log_bfr();
|
||||
try {
|
||||
Xoa_gui_mgr ui_mgr = app.Gui_mgr();
|
||||
|
||||
@@ -72,7 +72,7 @@ class Xog_history_stack_fxt {
|
||||
public Xog_history_stack_fxt Exec_add_one(String ttl_str, String arg_str) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoae_page page = Xoae_page.test_(wiki, ttl);
|
||||
Xoae_page page = Xoae_page.New_test(wiki, ttl);
|
||||
byte[] url_bry = ttl_bry;
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));
|
||||
Xoa_url url = app.User().Wikii().Utl__url_parser().Parse(url_bry);
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.guis.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
|
||||
import gplx.core.net.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.doms.*;
|
||||
import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.doms.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xog_url_wkr {
|
||||
private final Xoa_url tmp_url = Xoa_url.blank();
|
||||
@@ -60,12 +60,16 @@ public class Xog_url_wkr {
|
||||
}
|
||||
private Xoa_url Exec_url_file(Xoae_app app, Xowe_wiki cur_wiki, Xoae_page page, Xog_win_itm win, byte[] href_bry) { // EX: file:///xowa/A.png
|
||||
Xowe_wiki wiki = (Xowe_wiki)page.Commons_mgr().Source_wiki_or(cur_wiki);
|
||||
Io_url href_url = Io_url_.http_any_(String_.new_u8(gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url.Decode(href_bry)), Op_sys.Cur().Tid_is_wnt());
|
||||
Io_url href_url = Io_url_.http_any_(String_.new_u8(Gfo_url_encoder_.Http_url.Decode(href_bry)), Op_sys.Cur().Tid_is_wnt());
|
||||
gplx.gfui.Gfui_html html_box = win.Active_html_box();
|
||||
byte[] href_bry_encoded = Gfo_url_encoder_.Fsys_lnx.Encode(href_bry); // encode to href_bry; note must encode to same href_bry as Xof_url_bldr, which uses Gfo_url_encoder_.Fsys_lnx; PAGE:en.w:File:Volc<6C>n_Chimborazo,_"El_Taita_Chimborazo".jpg DATE:2015-12-06
|
||||
String xowa_ttl = wiki.Gui_mgr().Cfg_browser().Content_editable()
|
||||
? html_box.Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, gplx.xowa.htmls.Xoh_consts.Atr_xowa_title_str, null)
|
||||
: Xoh_dom_.Title_by_href(href_bry, Bry_.new_u8(html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__root_html_get)));
|
||||
if (xowa_ttl == null) {app.Gui_mgr().Kit().Ask_ok("", "", "could not find find anchor with href in html: href=~{0}", href_bry); return Rslt_handled;}
|
||||
: Xoh_dom_.Title_by_href(href_bry_encoded, Bry_.new_u8(html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__root_html_get)));
|
||||
if (xowa_ttl == null) {
|
||||
app.Gui_mgr().Kit().Ask_ok("", "", "could not find anchor with href in html: href=~{0}", href_bry);
|
||||
return Rslt_handled;
|
||||
}
|
||||
byte[] lnki_ttl = gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url.Decode(Xoa_ttl.Replace_spaces(Bry_.new_u8(xowa_ttl)));
|
||||
Xof_fsdb_itm fsdb = Xof_orig_file_downloader.Make_fsdb(wiki, lnki_ttl, img_size, url_bldr);
|
||||
if (!Io_mgr.Instance.ExistsFil(href_url)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class Xog_launcher_tabs {
|
||||
Xoa_url launch_url = home_wiki.Utl__url_parser().Parse_by_urlbar_or_null(launch_str); if (launch_url == null) return;
|
||||
Xowe_wiki launch_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_key_or_make_init_y(launch_url.Wiki_bry());
|
||||
Xoa_ttl launch_ttl = Xoa_ttl.parse(launch_wiki, launch_url.Page_bry());
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(launch_wiki, Xoae_page.new_(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(launch_wiki, Xoae_page.New(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
|
||||
tab.Show_url_bgn(launch_url);
|
||||
}
|
||||
public static final Xog_launcher_tabs Instance = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
wiki.Parser_mgr().Ctx().Cur_page_(page);
|
||||
if (page.Missing()) {
|
||||
if (wiki.Db_mgr().Save_mgr().Create_enabled()) {
|
||||
page = Xoae_page.create_(wiki, ttl);
|
||||
page = Xoae_page.New_edit(wiki, ttl);
|
||||
view_mode = Xopg_page_.Tid_edit;
|
||||
history_mgr.Add(page); // NOTE: must put new_page on stack so that pressing back will pop new_page, not previous page
|
||||
Xog_tab_itm_read_mgr.Show_page(this, page, false);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Xog_tab_itm_edit_mgr {
|
||||
Xog_html_itm html_itm = tab.Html_itm();
|
||||
|
||||
byte[] new_text = Get_new_text(tab);
|
||||
Xoae_page new_page = Xoae_page.new_(wiki, page.Ttl());
|
||||
Xoae_page new_page = Xoae_page.New(wiki, page.Ttl());
|
||||
new_page.Revision_data().Id_(page.Revision_data().Id()); // NOTE: page_id needed for sqlite (was not needed for xdat)
|
||||
new_page.Data_raw_(new_text);
|
||||
wiki.Parser_mgr().Parse(new_page, true); // refresh html
|
||||
@@ -102,7 +102,7 @@ public class Xog_tab_itm_edit_mgr {
|
||||
ctx.Defn_trace().Clear(); // TODO: move_me
|
||||
ctx.Defn_trace_(Xot_defn_trace_dbg.Instance);
|
||||
Xoa_ttl ttl = page.Ttl();
|
||||
Xoae_page new_page = Xoae_page.new_(wiki, ttl);
|
||||
Xoae_page new_page = Xoae_page.New(wiki, ttl);
|
||||
byte[] data = tab.Html_itm().Get_elem_value_for_edit_box_as_bry();
|
||||
new_page.Data_raw_(data);
|
||||
wiki.Parser_mgr().Parse(new_page, true);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
Xowe_wiki cur_wiki = active_tab_is_null ? win.App().Usere().Wiki() : active_tab.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, Xows_special_meta_.Itm__default_tab.Ttl_bry());
|
||||
Xoa_url url = cur_wiki.Utl__url_parser().Parse_by_urlbar_or_null(ttl.Full_db_as_str()); if (url == null) throw Err_.new_("url", "invalid url", "url", url);
|
||||
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null, cur_wiki, Xoae_page.new_(cur_wiki, ttl));
|
||||
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null, cur_wiki, Xoae_page.New(cur_wiki, ttl));
|
||||
rv.Page_update_ui();
|
||||
rv.Show_url_bgn(url);
|
||||
return rv;
|
||||
@@ -218,7 +218,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
}
|
||||
public void Tabs_new_link(String link, boolean focus) {
|
||||
Xowe_wiki wiki = active_tab.Wiki();
|
||||
Xog_tab_itm new_tab = Tabs_new(focus, false, wiki, Xoae_page.new_(wiki, active_tab.Page().Ttl())); // NOTE: do not use ttl from link, else middle-clicking pages with anchors won't work; DATE:2015-05-03
|
||||
Xog_tab_itm new_tab = Tabs_new(focus, false, wiki, Xoae_page.New(wiki, active_tab.Page().Ttl())); // NOTE: do not use ttl from link, else middle-clicking pages with anchors won't work; DATE:2015-05-03
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse_by_urlbar_or_null(link); if (url == null) return; // NOTE: link must be of form domain/wiki/page; DATE:2014-05-27
|
||||
new_tab.Show_url_bgn(url);
|
||||
if (focus)
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Xog_error_win extends JFrame implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_send_mail)) {
|
||||
try {
|
||||
Gfo_url_encoder url_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_safe;
|
||||
Gfo_url_encoder url_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_wnt;
|
||||
String subject = url_encoder.Encode_str("XOWA boot error: " + error_data.Err_msg());
|
||||
String body = url_encoder.Encode_str(error_data.Err_details());
|
||||
Desktop.getDesktop().mail(new URI("mailto:gnosygnu+xowa_error_boot@gmail.com?subject=" + subject + "&body=" + body));
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.guis.views.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
public class Xog_splash_win implements RlsAble {
|
||||
public class Xog_splash_win implements Rls_able {
|
||||
private SplashScreen splash;
|
||||
private Graphics2D graphics; private boolean graphics_init = true;
|
||||
public Xog_splash_win(boolean app_mode_is_gui) {
|
||||
|
||||
@@ -55,6 +55,7 @@ public class Xoh_page implements Xoa_page {
|
||||
}
|
||||
public Xoh_page Ctor_by_page(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
this.page_id = page.Revision_data().Id();
|
||||
this.wiki = page.Wiki();
|
||||
this.body = page.Hdump_data().Body();
|
||||
this.page_url = page.Url();
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
|
||||
@@ -153,11 +153,11 @@ public class Xoh_page_wtr_wkr {
|
||||
wiki.Html_mgr().Html_wtr().Write_all(tidy_bfr, page.Wikie().Parser_mgr().Ctx(), hctx, page.Root().Data_mid(), page.Root());
|
||||
|
||||
// if [[Category]], render rest of html (Subcategories; Pages; Files); note that a category may have other html which requires wikitext processing
|
||||
if (ns_id == Xow_ns_.Tid__category) wiki.Html_mgr().Ns_ctg().Bld_html(wiki, page, tidy_bfr);
|
||||
if (ns_id == Xow_ns_.Tid__category) wiki.Html_mgr().Ns_ctg().Bld_html(wiki, page, hctx, tidy_bfr);
|
||||
|
||||
// tidy html
|
||||
gplx.xowa.htmls.core.htmls.tidy.Xoh_tidy_mgr tidy_mgr = app.Html_mgr().Tidy_mgr();
|
||||
if (tidy_mgr.Enabled()) tidy_mgr.Run_tidy_html(page, tidy_bfr);
|
||||
if (tidy_mgr.Enabled()) tidy_mgr.Run_tidy_html(page, tidy_bfr, !hctx.Mode_is_hdump());
|
||||
|
||||
// add back to main bfr
|
||||
bfr.Add_bfr_and_clear(tidy_bfr);
|
||||
|
||||
@@ -20,20 +20,20 @@ import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xohp_ctg_grp_mgr {
|
||||
final Bry_fmtr grp_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"catlinks\" class=\"catlinks\">"
|
||||
, " <div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"
|
||||
, " ~{grp_lbl}"
|
||||
, " <ul>~{grp_itms}"
|
||||
, " </ul>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
( "<div id=\"catlinks\" class=\"catlinks\">"
|
||||
, "<div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"
|
||||
, "~{grp_lbl}"
|
||||
, "<ul>~{grp_itms}"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "grp_lbl", "grp_itms")
|
||||
;
|
||||
final Bry_fmtr itm_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <li>"
|
||||
, " <a href=\"~{itm_href}\" class=\"internal\" title=\"~{itm_title}\">~{itm_text}</a>"
|
||||
, " </li>"
|
||||
( ""
|
||||
, "<li>"
|
||||
, "<a href=\"~{itm_href}\" class=\"internal\" title=\"~{itm_title}\">~{itm_text}</a>"
|
||||
, "</li>"
|
||||
), "itm_href", "itm_title", "itm_text"
|
||||
);
|
||||
Xoh_ctg_itm_fmtr itm_mgr = new Xoh_ctg_itm_fmtr();
|
||||
|
||||
@@ -23,17 +23,17 @@ public class Xohp_ctg_grp_mgr_tst {
|
||||
@Test public void Basic() {
|
||||
fxt.Init_ctgs("A", "B").Test_html(String_.Concat_lines_nl
|
||||
( "<div id=\"catlinks\" class=\"catlinks\">"
|
||||
, " <div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"
|
||||
, " Categories"
|
||||
, " <ul>"
|
||||
, " <li>"
|
||||
, " <a href=\"/wiki/Category:A\" class=\"internal\" title=\"A\">A</a>"
|
||||
, " </li>"
|
||||
, " <li>"
|
||||
, " <a href=\"/wiki/Category:B\" class=\"internal\" title=\"B\">B</a>"
|
||||
, " </li>"
|
||||
, " </ul>"
|
||||
, " </div>"
|
||||
, "<div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"
|
||||
, "Categories"
|
||||
, "<ul>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:A\" class=\"internal\" title=\"A\">A</a>"
|
||||
, "</li>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:B\" class=\"internal\" title=\"B\">B</a>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ public class Xow_html_mgr implements GfoInvkAble {
|
||||
Xoae_app app = wiki.Appe();
|
||||
page_wtr_mgr = new Xoh_page_wtr_mgr(app.Gui_mgr().Kit().Tid() != gplx.gfui.Gfui_kit_.Swing_tid); // reverse logic to handle swt,drd but not mem
|
||||
Io_url file_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("mediawiki.file");
|
||||
img_media_play_btn = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys.Encode_to_file_protocol(file_dir.GenSubFil("play.png"));
|
||||
img_media_info_btn = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys.Encode_to_file_protocol(file_dir.GenSubFil("info.png"));
|
||||
img_thumb_magnify = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys.Encode_to_file_protocol(file_dir.GenSubFil("magnify-clip.png"));
|
||||
img_xowa_protocol = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys.Encode_to_file_protocol(app.Fsys_mgr().Bin_xowa_file_dir().GenSubFil_nest("app.general", "xowa_exec.png"));
|
||||
img_media_play_btn = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(file_dir.GenSubFil("play.png"));
|
||||
img_media_info_btn = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(file_dir.GenSubFil("info.png"));
|
||||
img_thumb_magnify = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(file_dir.GenSubFil("magnify-clip.png"));
|
||||
img_xowa_protocol = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(app.Fsys_mgr().Bin_xowa_file_dir().GenSubFil_nest("app.general", "xowa_exec.png"));
|
||||
portal_mgr = new Xow_portal_mgr(wiki);
|
||||
imgs_mgr = new Xoh_imgs_mgr(this);
|
||||
module_mgr = new Xow_module_mgr(wiki);
|
||||
|
||||
@@ -23,24 +23,27 @@ public class Xow_hdump_mgr {
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private final Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||
public Xow_hdump_mgr(Xow_wiki wiki) {
|
||||
this.save_mgr = new Xow_hdump_mgr__save(wiki, hzip_mgr, zip_mgr, tmp_hpg, tmp_bfr);
|
||||
this.save_mgr = new Xow_hdump_mgr__save(wiki, hzip_mgr, zip_mgr, tmp_hpg);
|
||||
this.load_mgr = new Xow_hdump_mgr__load(wiki, hzip_mgr, zip_mgr, tmp_hpg, tmp_bfr);
|
||||
}
|
||||
public Xow_hdump_mgr__save Save_mgr() {return save_mgr;} private Xow_hdump_mgr__save save_mgr;
|
||||
public Xow_hdump_mgr__load Load_mgr() {return load_mgr;} private Xow_hdump_mgr__load load_mgr;
|
||||
public Xoh_hzip_mgr Hzip_mgr() {return hzip_mgr;} private final Xoh_hzip_mgr hzip_mgr = new Xoh_hzip_mgr();
|
||||
public void Init_by_db(Xow_wiki wiki) {
|
||||
byte default_zip_tid = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
boolean default_hzip_enable = false;
|
||||
byte dflt_zip_tid = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
boolean dflt_hzip_enable = false;
|
||||
boolean mode_is_b256 = false;
|
||||
if (wiki.Data__core_mgr() != null) { // TEST: handle null data mgr
|
||||
Xowd_core_db_props props = wiki.Data__core_mgr().Props();
|
||||
default_zip_tid = props.Zip_tid_html();
|
||||
default_hzip_enable = props.Hzip_enabled();
|
||||
dflt_zip_tid = props.Zip_tid_html();
|
||||
dflt_hzip_enable = props.Hzip_enabled();
|
||||
// dflt_hzip_enable = props.Hzip_enabled();
|
||||
// mode_is_b256 = true;
|
||||
}
|
||||
Init_by_db(default_zip_tid, default_hzip_enable);
|
||||
Init_by_db(dflt_zip_tid, dflt_hzip_enable, mode_is_b256);
|
||||
}
|
||||
public void Init_by_db(byte default_zip_tid, boolean default_hzip_enable) {
|
||||
int dflt_hzip_tid = default_hzip_enable ? Xoh_hzip_dict_.Hzip__v1 : Xoh_hzip_dict_.Hzip__none;
|
||||
save_mgr.Init_by_db(default_zip_tid, dflt_hzip_tid);
|
||||
public void Init_by_db(byte dflt_zip_tid, boolean dflt_hzip_enable, boolean mode_is_b256) {
|
||||
int dflt_hzip_tid = dflt_hzip_enable ? Xoh_hzip_dict_.Hzip__v1 : Xoh_hzip_dict_.Hzip__none;
|
||||
save_mgr.Init_by_db(dflt_zip_tid, dflt_hzip_tid, Bool_.N);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xow_hdump_mgr__load {
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
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, wiki.Domain_bry());
|
||||
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());
|
||||
}
|
||||
public Xoh_make_mgr Make_mgr() {return make_mgr;} private final Xoh_make_mgr make_mgr;
|
||||
public void Load(Xoae_page wpg) {
|
||||
@@ -45,13 +45,12 @@ public class Xow_hdump_mgr__load {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public byte[] Decode_as_bry(Bry_bfr bfr, Xoh_page hpg, byte[] src, boolean mode_is_diff) {hzip_mgr.Hctx().Mode_is_diff_(mode_is_diff); hzip_mgr.Decode(bfr, wiki, hpg, src); return bfr.To_bry_and_clear();}
|
||||
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) {
|
||||
hzip_mgr.Decode(tmp_bfr.Clear(), wiki, hpg, src);
|
||||
src = tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
if (hzip_tid == Xoh_hzip_dict_.Hzip__v1)
|
||||
src = Decode_as_bry(tmp_bfr.Clear(), hpg, src, Bool_.N);
|
||||
return src;
|
||||
}
|
||||
private void Fill_page(Xoae_page wpg, Xoh_page hpg) {
|
||||
|
||||
@@ -117,7 +117,7 @@ class Xodb_hdump_mgr__base_fxt {
|
||||
wiki = fxt.Wiki();
|
||||
page = wiki.Parser_mgr().Ctx().Cur_page();
|
||||
hdump_mgr = wiki.Html__hdump_mgr();
|
||||
hdump_mgr.Init_by_db(gplx.core.ios.Io_stream_.Tid_raw, false);
|
||||
hdump_mgr.Init_by_db(gplx.core.ios.Io_stream_.Tid_raw, false, false);
|
||||
}
|
||||
fxt.Reset();
|
||||
page.Revision_data().Id_(0);
|
||||
|
||||
@@ -16,16 +16,19 @@ 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; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.core.ios.*; import gplx.core.primitives.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xow_hdump_mgr__save {
|
||||
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 Bool_obj_ref html_db_is_new = Bool_obj_ref.n_();
|
||||
private final Xoh_page tmp_hpg; private final Xoh_hzip_bfr tmp_bfr = Xoh_hzip_bfr.New_txt(32); private Bool_obj_ref html_db_is_new = Bool_obj_ref.n_();
|
||||
private int dflt_zip_tid, dflt_hzip_tid;
|
||||
public Xow_hdump_mgr__save(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;
|
||||
public Xow_hdump_mgr__save(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg;
|
||||
}
|
||||
public void Init_by_db(int dflt_zip_tid, int dflt_hzip_tid) {this.dflt_zip_tid = dflt_zip_tid; this.dflt_hzip_tid = dflt_hzip_tid;}
|
||||
public void Init_by_db(int dflt_zip_tid, int dflt_hzip_tid, boolean mode_is_b256) {
|
||||
this.dflt_zip_tid = dflt_zip_tid; this.dflt_hzip_tid = dflt_hzip_tid; tmp_bfr.Mode_is_b256_(mode_is_b256);
|
||||
}
|
||||
public byte[] Src_as_hzip() {return src_as_hzip;} private byte[] src_as_hzip;
|
||||
public int Save(Xoae_page page) {
|
||||
synchronized (tmp_hpg) {
|
||||
Bld_hdump(page);
|
||||
@@ -45,11 +48,9 @@ public class Xow_hdump_mgr__save {
|
||||
wiki.Html__wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_body(tmp_bfr, Xoh_wtr_ctx.Hdump, page); // save as hdump_fmt
|
||||
page.Hdump_data().Body_(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
private static byte[] Write(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
if (hzip_tid == Xoh_hzip_dict_.Hzip__v1) {
|
||||
hzip_mgr.Encode(bfr.Clear(), wiki, hpg, src);
|
||||
src = bfr.To_bry_and_clear();
|
||||
}
|
||||
private byte[] Write(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
if (hzip_tid != Xoh_hzip_dict_.Hzip__none) src = hzip_mgr.Encode_as_bry((Xoh_hzip_bfr)bfr.Clear(), wiki, hpg, src);
|
||||
src_as_hzip = src;
|
||||
if (zip_tid > gplx.core.ios.Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Zip((byte)zip_tid, src);
|
||||
return src;
|
||||
|
||||
@@ -16,22 +16,26 @@ 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.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
public class Xob_hdump_bldr implements GfoInvkAble {
|
||||
private boolean enabled, hzip_enabled, hzip_compare;
|
||||
private boolean enabled, hzip_enabled, hzip_diff, hzip_b256; private byte zip_tid = Byte_.Max_value_127;
|
||||
private Xowe_wiki wiki; private Xow_hdump_mgr hdump_mgr;
|
||||
private Xob_ns_to_db_mgr ns_to_db_mgr; int prv_row_len = 0;
|
||||
private Hzip_stat_tbl stats_tbl; private Hzip_stat_itm tmp_stat_itm;
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr.reset_(Io_mgr.Len_mb);
|
||||
private Xoh_stat_tbl stats_tbl; private Xoh_stat_itm tmp_stat_itm;
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
private boolean op_sys_is_wnt;
|
||||
public boolean Init(Xowe_wiki wiki, Db_conn make_conn) {
|
||||
if (!enabled) return false;
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Hctx().Bicode__stat();
|
||||
this.stats_tbl = new Hzip_stat_tbl(make_conn);
|
||||
this.op_sys_is_wnt = gplx.core.envs.Op_sys.Cur().Tid_is_wnt();
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Hctx().Hzip__stat();
|
||||
this.stats_tbl = new Xoh_stat_tbl(make_conn);
|
||||
Xoapi_import import_cfg = wiki.Appe().Api_root().Bldr().Wiki().Import();
|
||||
hdump_mgr.Init_by_db(import_cfg.Zip_tid_html(), hzip_enabled);
|
||||
if (zip_tid == Byte_.Max_value_127) zip_tid = import_cfg.Zip_tid_html();
|
||||
hdump_mgr.Init_by_db(zip_tid, hzip_enabled, hzip_b256);
|
||||
Xowd_db_mgr core_data_mgr = wiki.Db_mgr_as_sql().Core_data_mgr();
|
||||
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__html(core_data_mgr.Db__core()), core_data_mgr, import_cfg.Html_db_max());
|
||||
Xob_ns_file_itm.Init_ns_bldr_data(Xowd_db_file_.Tid_html_data, wiki.Ns_mgr(), gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import.Ns_file_map__each);
|
||||
@@ -40,13 +44,11 @@ public class Xob_hdump_bldr implements GfoInvkAble {
|
||||
public void Insert(Xoae_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_body(tmp_bfr, Xoh_wtr_ctx.Hdump, page); // write to html in hdump mode
|
||||
byte[] html_orig_bry = tmp_bfr.To_bry_and_clear();
|
||||
page.Hdump_data().Body_(html_orig_bry); // write to body bry
|
||||
byte[] orig_bry = tmp_bfr.To_bry_and_clear();
|
||||
page.Hdump_data().Body_(orig_bry); // write to body bry
|
||||
Xowd_db_file html_db = ns_to_db_mgr.Get_by_ns(page.Ttl().Ns().Bldr_data(), prv_row_len); // get html_db
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, page), html_db, true); // save to db
|
||||
if (hzip_compare) {
|
||||
// Compare(html_orig_bry, hdump_mgr.Save_mgr());
|
||||
}
|
||||
if (hzip_diff) Hzip_exec(orig_bry);
|
||||
stats_tbl.Insert(tmp_hpg, tmp_stat_itm, page.Root().Root_src().length, tmp_hpg.Body().length, prv_row_len); // save stats
|
||||
}
|
||||
public void Bld_term() {this.Commit(); ns_to_db_mgr.Rls_all();}
|
||||
@@ -54,12 +56,21 @@ public class Xob_hdump_bldr implements GfoInvkAble {
|
||||
ns_to_db_mgr.Commit();
|
||||
// wiki_db_mgr.Tbl__cfg().Update_long(Cfg_grp_hdump_make, Cfg_itm_hdump_size, hdump_db_size); // update cfg; should happen after commit entries
|
||||
}
|
||||
private void Hzip_exec(byte[] orig_bry) {
|
||||
byte[] expd_bry = op_sys_is_wnt ? Bry_.Replace(tmp_bfr, orig_bry, Byte_ascii.Cr_lf_bry, Byte_ascii.Nl_bry) : orig_bry;
|
||||
byte[] actl_bry = hdump_mgr.Load_mgr().Decode_as_bry(tmp_bfr, tmp_hpg, hdump_mgr.Save_mgr().Src_as_hzip(), Bool_.Y);
|
||||
byte[][] diff = Bry_diff_.Diff_1st_line(expd_bry, actl_bry);
|
||||
if (diff != null)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", String_.Format("hzip diff: page={0} lhs='{1}' rhs='{2}'", tmp_hpg.Url_bry_safe(), diff[0], diff[1]));
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_zip_tid_)) zip_tid = m.ReadByte("v");
|
||||
else if (ctx.Match(k, Invk_hzip_enabled_)) hzip_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_hzip_compare_)) hzip_compare = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_hzip_diff_)) hzip_diff = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_hzip_b256_)) hzip_b256 = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_enabled_ = "enabled_", Invk_hzip_enabled_ = "hzip_enabled_", Invk_hzip_compare_ = "hzip_compare_";
|
||||
private static final String Invk_enabled_ = "enabled_", Invk_zip_tid_ = "zip_tid_", Invk_hzip_enabled_ = "hzip_enabled_", Invk_hzip_diff_ = "hzip_diff_", Invk_hzip_b256_ = "hzip_b256_";
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
class Xob_link_dump_tbl implements RlsAble {
|
||||
class Xob_link_dump_tbl implements Rls_able {
|
||||
public static final String Tbl_name = "link_dump"; private static final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
public static final String
|
||||
Fld_uid = flds.Add_int_pkey_autonum("uid")
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.core.brys.*;
|
||||
public class Xoh_page_tbl implements RlsAble {
|
||||
public class Xoh_page_tbl implements Rls_able {
|
||||
private final String tbl_name = "html"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_page_id, fld_head_flag, fld_body_flag, fld_display_ttl, fld_content_sub, fld_sidebar_div, fld_body;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xoh_redlink_tbl implements RlsAble {
|
||||
public class Xoh_redlink_tbl implements Rls_able {
|
||||
private final String tbl_name = "html_redlink"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_page_id, fld_redlink_uids;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
|
||||
@@ -17,12 +17,13 @@ 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.*;
|
||||
public class Xoh_wtr_ctx {
|
||||
Xoh_wtr_ctx(byte mode) {this.mode = mode;} private byte mode;
|
||||
Xoh_wtr_ctx(int mode) {this.mode = mode;}
|
||||
public int Mode() {return mode;} private final int mode;
|
||||
public boolean Mode_is_alt() {return mode == Mode_alt;}
|
||||
public boolean Mode_is_display_title() {return mode == Mode_display_title;}
|
||||
public boolean Mode_is_popup() {return mode == Mode_popup;}
|
||||
public boolean Mode_is_hdump() {return mode == Mode_hdump;}
|
||||
public static final byte Mode_basic = 0, Mode_alt = 1, Mode_display_title = 2, Mode_popup = 3, Mode_hdump = 4;
|
||||
public static final int Mode_basic = 0, Mode_alt = 1, Mode_display_title = 2, Mode_popup = 3, Mode_hdump = 4;
|
||||
public static final Xoh_wtr_ctx
|
||||
Basic = new Xoh_wtr_ctx(Mode_basic)
|
||||
, Alt = new Xoh_wtr_ctx(Mode_alt)
|
||||
|
||||
@@ -37,9 +37,10 @@ public class Xoh_tidy_mgr implements GfoInvkAble {
|
||||
: (Xoh_tidy_wkr)wkr_tidy
|
||||
;
|
||||
}
|
||||
public void Run_tidy_html(Xoae_page page, Bry_bfr bfr) {
|
||||
public void Run_tidy_html(Xoae_page page, Bry_bfr bfr, boolean indent) {
|
||||
if (bfr.Len_eq_0()) return; // document is empty; do not exec b/c tidy will never generate files for 0 len files, and previous file will remain; DATE:2014-06-04
|
||||
Tidy_wrap(bfr);
|
||||
wkr.Indent_(indent);
|
||||
wkr.Exec_tidy(page, bfr);
|
||||
Tidy_unwrap(bfr);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.htmls.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public interface Xoh_tidy_wkr {
|
||||
byte Tid();
|
||||
void Indent_(boolean v);
|
||||
void Exec_tidy(Xoae_page page, Bry_bfr bfr);
|
||||
}
|
||||
|
||||
@@ -38,5 +38,6 @@ public class Xoh_tidy_wkr_ {
|
||||
}
|
||||
class Xoh_tidy_wkr_null implements Xoh_tidy_wkr {
|
||||
public byte Tid() {return Xoh_tidy_wkr_.Tid_null;}
|
||||
public void Indent_(boolean v) {}
|
||||
public void Exec_tidy(Xoae_page page, Bry_bfr bfr) {}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class Xoh_tidy_wkr_jtidy implements Xoh_tidy_wkr {
|
||||
public void tidy_init() {
|
||||
long bgn = Env_.TickCount();
|
||||
wtr = new ByteArrayOutputStream();
|
||||
System.setProperty("line.separator", "\n");
|
||||
tidy = new Tidy(); // obtain a new Tidy instance
|
||||
tidy.setInputEncoding("UTF-8"); // -utf8
|
||||
tidy.setOutputEncoding("UTF-8"); // -utf8
|
||||
@@ -55,6 +56,10 @@ class Xoh_tidy_wkr_jtidy implements Xoh_tidy_wkr {
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public void Indent_(boolean v) {
|
||||
if (tidy == null) tidy_init(); // lazy create to skip tests
|
||||
tidy.setIndentContent(v);
|
||||
}
|
||||
public void Exec_tidy(Xoae_page page, Bry_bfr bfr) {
|
||||
if (tidy == null) tidy_init(); // lazy create to skip tests
|
||||
// int bfr_len = bfr.Len();
|
||||
|
||||
@@ -27,24 +27,26 @@ public class Xoh_tidy_wkr_tidy extends Process_adp implements Xoh_tidy_wkr { pr
|
||||
tidy_target = v.GenSubFil("tidy_target.html");
|
||||
return super.Tmp_dir_(v);
|
||||
}
|
||||
public void Indent_(boolean v) {Indent_val = v ? "y" : "n";}
|
||||
public void Exec_tidy(Xoae_page page, Bry_bfr bfr) {
|
||||
int bfr_len = bfr.Len();
|
||||
long bgn = Env_.TickCount();
|
||||
Io_mgr.Instance.SaveFilBfr(tidy_source, bfr); // saves bfr to source; clears bfr
|
||||
this.Run(tidy_source.Raw(), tidy_target.Raw()); // converts source to target
|
||||
this.Run(tidy_source.Raw(), tidy_target.Raw()); // converts source to target
|
||||
Io_mgr.Instance.LoadFilBryByBfr(tidy_target, bfr); // loads bfr by target
|
||||
if (bfr.Len_eq_0()) // something went wrong; load from source
|
||||
if (bfr.Len_eq_0()) // something went wrong; load from source
|
||||
Io_mgr.Instance.LoadFilBryByBfr(tidy_source, bfr); // loads bfr by target
|
||||
app.Usr_dlg().Log_many("", "", "tidy exec; elapsed=~{0} len=~{1}", Env_.TickCount_elapsed_in_frac(bgn), bfr_len);
|
||||
}
|
||||
public static final String Args_fmt = String_.Concat // see https://meta.wikimedia.org/wiki/Data_dumps; missing numeric-entities:yes; enclose-text: yes
|
||||
private static String Indent_val = "y";
|
||||
public static String Args_fmt = String_.Concat // see https://meta.wikimedia.org/wiki/Data_dumps; missing numeric-entities:yes; enclose-text: yes
|
||||
( "-utf8" // default is ascii
|
||||
, " --force-output y" // always generate output; do not fail on error
|
||||
, " --quiet y" // suppress command-line header
|
||||
, " --tidy-mark n" // do not add tidy watermark
|
||||
, " --doctype ''''" // set to empty else some wikis will show paragraph text with little vertical gap; PAGE:tr.b:
|
||||
, " --wrap 0" // default is 80; do not limit lines to 80 chars
|
||||
, " --indent y" // indent block levels
|
||||
, " --indent ", Indent_val // indent block levels
|
||||
, " --quote-nbsp y" // preserve nbsp as entities; do not convert to Unicode character 160
|
||||
, " --literal-attributes y" // do not alter whitespace chars in attributes
|
||||
, " --wrap-attributes n" // do not line-wrap attribute values (assume tidy will try to take a="b\nc" and change to a="b c" which may cause some fidelity issues?)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xoh_lnki_bldr {
|
||||
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 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, domain_bry, ttl, Bool_.Y);
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, Xoh_wtr_ctx.Mode_popup, domain_bry, ttl);
|
||||
this.href = tmp_bfr.To_bry_and_clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -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.htmls.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_lnki_wtr_utl {
|
||||
private final Xoa_app app; private final Xow_wiki wiki; private final Xoh_href_wtr href_wtr; private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
public Xoh_lnki_wtr_utl(Xow_wiki wiki, Xoh_href_wtr href_wtr) {
|
||||
@@ -25,7 +25,7 @@ public class Xoh_lnki_wtr_utl {
|
||||
}
|
||||
public byte[] Bld_href(byte[] page) {return Bld_href(wiki.Domain_bry(), wiki.Ttl_parse(page));}
|
||||
public byte[] Bld_href(byte[] domain_bry, Xoa_ttl ttl) {
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, domain_bry, ttl, Bool_.Y);
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, Xoh_wtr_ctx.Mode_popup, domain_bry, ttl);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Bld_title(byte[] text) {
|
||||
|
||||
21
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict.java
Normal file
21
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_dict.java
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
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.*;
|
||||
public class Xoh_hzip_dict {
|
||||
|
||||
}
|
||||
@@ -20,36 +20,15 @@ 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
|
||||
private static final byte Base85_ascii = 33;
|
||||
public static final byte // SERIALIZED
|
||||
Tid__space = 0 + Base85_ascii
|
||||
, Tid__hdr = 1 + Base85_ascii
|
||||
, Tid__lnke = 2 + Base85_ascii
|
||||
, Tid__lnki = 3 + Base85_ascii
|
||||
, Tid__img = 4 + Base85_ascii
|
||||
, Tid__thm = 5 + Base85_ascii
|
||||
, Tid__gly = 6 + Base85_ascii
|
||||
, Tid__escape = 84 + Base85_ascii
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__escape = Bry_.new_ints(Escape, Tid__escape)
|
||||
, Bry__space = Bry_.new_ints(Escape, Tid__space)
|
||||
, Bry__hdr = Bry_.new_ints(Escape, Tid__hdr)
|
||||
, Bry__lnke = Bry_.new_ints(Escape, Tid__lnke)
|
||||
, Bry__lnki = Bry_.new_ints(Escape, Tid__lnki)
|
||||
, Bry__img = Bry_.new_ints(Escape, Tid__img)
|
||||
, Bry__thm = Bry_.new_ints(Escape, Tid__thm)
|
||||
, Bry__gly = Bry_.new_ints(Escape, Tid__gly)
|
||||
;
|
||||
public static final String
|
||||
Key__escape = "escape"
|
||||
, Key__space = "space"
|
||||
, Key__hdr = "hdr"
|
||||
, Key__lnke = "lnke"
|
||||
, Key__lnki = "lnki"
|
||||
, Key__img = "img"
|
||||
, Key__thm = "thm"
|
||||
, Key__gly = "gly"
|
||||
, Key__xnde = "xnde"
|
||||
;
|
||||
public static final int Hzip__none = 0, Hzip__v1 = 1;
|
||||
}
|
||||
|
||||
148
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_int.java
Normal file
148
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_int.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.encoders.*;
|
||||
public class Xoh_hzip_int {
|
||||
private boolean mode_is_b256; private byte pad_byte; private byte[] prefix_ary;
|
||||
public Xoh_hzip_int Mode_is_b256_(boolean v) {
|
||||
mode_is_b256 = v;
|
||||
if (mode_is_b256) {
|
||||
pad_byte = Byte_.Zero;
|
||||
prefix_ary = prefix_ary__b256;
|
||||
}
|
||||
else {
|
||||
pad_byte = Byte_ascii.Bang;
|
||||
prefix_ary = prefix_ary__b085;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Encode(int reqd_len, Bry_bfr bfr, int val) {
|
||||
int calc_len = Calc_len(mode_is_b256, val);
|
||||
int full_len = Full_len(mode_is_b256, val, calc_len, reqd_len, B256__pow__ary);
|
||||
int hdr_adj = full_len == calc_len || full_len == reqd_len ? 0 : 1;
|
||||
int bfr_len = bfr.Len();
|
||||
bfr.Add_byte_repeat(pad_byte, full_len); // fill with 0s; asserts that underlying array will be large enough for following write
|
||||
byte[] bfr_bry = bfr.Bfr(); // NOTE: set bry reference here b/c Add_byte_repeat may create a new one
|
||||
if (mode_is_b256)
|
||||
Set_bry(val, bfr_bry, bfr_len + hdr_adj, reqd_len, calc_len, pad_byte, B256__pow__ary);
|
||||
else
|
||||
Base85_.Set_bry(val, bfr_bry, bfr_len + hdr_adj, reqd_len); // calc base85 val for val; EX: 7224 -> "uu"
|
||||
if (hdr_adj == 1)
|
||||
bfr_bry[bfr_len] = prefix_ary[full_len]; // write the hdr_byte; EX: 256 -> 253, 1, 0 where 253 is the hdr_byte
|
||||
}
|
||||
public int Decode(int reqd_len, byte[] src, int src_len, int src_bgn, Int_obj_ref pos_ref) {
|
||||
int radix = 256; byte offset = Byte_.Zero;
|
||||
boolean hdr_byte_exists = false;
|
||||
int full_len = 1; // default to 1
|
||||
byte b0 = src[src_bgn];
|
||||
if (mode_is_b256) {
|
||||
switch (b0) {
|
||||
case prefix__b256__2: full_len = 2; hdr_byte_exists = true; break;
|
||||
case prefix__b256__3: full_len = 3; hdr_byte_exists = true; break;
|
||||
case prefix__b256__4: full_len = 4; hdr_byte_exists = true; break;
|
||||
case prefix__b256__5: full_len = 5; hdr_byte_exists = true; break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
radix = 85; offset = Byte_ascii.Bang;
|
||||
switch (b0) {
|
||||
case Byte_ascii.Curly_bgn : full_len = 3; hdr_byte_exists = true; break;
|
||||
case Byte_ascii.Pipe : full_len = 4; hdr_byte_exists = true; break;
|
||||
case Byte_ascii.Curly_end : full_len = 5; hdr_byte_exists = true; break;
|
||||
case Byte_ascii.Tilde : full_len = 6; hdr_byte_exists = true; break;
|
||||
}
|
||||
}
|
||||
if (full_len < reqd_len) full_len = reqd_len; // len should be padded
|
||||
int src_end = src_bgn + full_len;
|
||||
pos_ref.Val_(src_end);
|
||||
if (hdr_byte_exists) ++src_bgn;
|
||||
return To_int_by_bry(src, src_bgn, src_end, offset, radix);
|
||||
}
|
||||
private static int Calc_len(boolean mode_is_b256, int v) {
|
||||
if (mode_is_b256) {
|
||||
if (v < B256__max__expd__1) return 1;
|
||||
else if (v < B256__max__expd__2) return 2;
|
||||
else if (v < B256__max__expd__3) return 3;
|
||||
else return 4;
|
||||
}
|
||||
else
|
||||
return Base85_.Bry_len(v);
|
||||
}
|
||||
private static int Full_len(boolean mode_is_b256, int v, int calc_len, int reqd_len, int[] pow_ary) {
|
||||
int reqd_max = v;
|
||||
if (mode_is_b256) {
|
||||
reqd_max = B256__pow__ary[reqd_len]; // EX: if reqd_len = 2, then reqd_max = 65536
|
||||
int hdr_byte_adj = 1; // default to hdr_byte
|
||||
if ( calc_len == reqd_len // only do this check if calc_len == reqd_len; i.e.: reqd_len = 2; only want to check values that would be represented with two digits where 1st digit might be 252-255; EX: 64512 is "252, 0" but 252 is reserverd; instead "253, 252, 0"
|
||||
&& v < (reqd_max - (4 * B256__pow__ary[calc_len - 1])) // calculates if current value will produce a 252-255 range in the 1st byte; note that 4 is for 255-252
|
||||
) {
|
||||
hdr_byte_adj = 0;
|
||||
}
|
||||
return calc_len + hdr_byte_adj;
|
||||
}
|
||||
else {
|
||||
reqd_max = Base85_.Pow85[reqd_len];
|
||||
if (v < reqd_max) return reqd_len;
|
||||
if (v < Base85_.Pow85[2]) return 3;
|
||||
else if (v < Base85_.Pow85[3]) return 4;
|
||||
else if (v < Base85_.Pow85[4]) return 5;
|
||||
else return 6;
|
||||
}
|
||||
}
|
||||
private static void Set_bry(int val, byte[] src, int src_bgn, int reqd_len, int calc_len, byte pad_byte, int[] pow_ary) {
|
||||
int val_len = -1, pad_len = -1;
|
||||
boolean pad = calc_len < reqd_len;
|
||||
if (pad) {
|
||||
val_len = reqd_len;
|
||||
pad_len = reqd_len - calc_len;
|
||||
}
|
||||
else {
|
||||
val_len = calc_len;
|
||||
pad_len = 0;
|
||||
}
|
||||
if (pad) {
|
||||
for (int i = 0; i < pad_len; i++) // fill src with pad_len
|
||||
src[i + src_bgn] = pad_byte;
|
||||
}
|
||||
for (int i = val_len - pad_len; i > 0; --i) {
|
||||
int div = pow_ary[i - 1];
|
||||
byte tmp = (byte)(val / div);
|
||||
src[src_bgn + val_len - i] = (byte)(tmp + pad_byte);
|
||||
val -= tmp * div;
|
||||
}
|
||||
}
|
||||
private 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
|
||||
factor *= radix;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final int
|
||||
B256__max__expd__1 = 256 // 256
|
||||
, B256__max__expd__2 = 65536 // 65,536
|
||||
, 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);
|
||||
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}
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
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 Xoh_hzip_int_tst {
|
||||
private final Xoh_hzip_int_fxt fxt = new Xoh_hzip_int_fxt();
|
||||
@Test public void B256__reqd__1() {
|
||||
fxt.Init__b256();
|
||||
fxt.Test__b256(1, 0 , 0);
|
||||
fxt.Test__b256(1, 252 , 252, 252);
|
||||
fxt.Test__b256(1, 253 , 252, 253);
|
||||
fxt.Test__b256(1, 254 , 252, 254);
|
||||
fxt.Test__b256(1, 255 , 252, 255);
|
||||
fxt.Test__b256(1, 256 , 253, 1, 0);
|
||||
fxt.Test__b256(1, 65535 , 253, 255, 255);
|
||||
fxt.Test__b256(1, 65536 , 254, 1, 0, 0);
|
||||
fxt.Test__b256(1, 16777216 , 255, 1, 0, 0, 0);
|
||||
}
|
||||
@Test public void B256__reqd__2() {
|
||||
fxt.Init__b256();
|
||||
fxt.Test__b256(2, 0 , 0, 0);
|
||||
fxt.Test__b256(2, 252 , 0, 252);
|
||||
fxt.Test__b256(2, 253 , 0, 253);
|
||||
fxt.Test__b256(2, 254 , 0, 254);
|
||||
fxt.Test__b256(2, 255 , 0, 255);
|
||||
fxt.Test__b256(2, 256 , 1, 0);
|
||||
fxt.Test__b256(2, 64511 , 251, 255);
|
||||
fxt.Test__b256(2, 64512 , 253, 252, 0);
|
||||
fxt.Test__b256(2, 65535 , 253, 255, 255);
|
||||
fxt.Test__b256(2, 65536 , 254, 1, 0, 0);
|
||||
fxt.Test__b256(2, 16777216 , 255, 1, 0, 0, 0);
|
||||
}
|
||||
@Test public void B085__reqd__1() {
|
||||
fxt.Init__b085();
|
||||
fxt.Test__b085(1, 0, "!");
|
||||
fxt.Test__b085(1, 84, "u");
|
||||
fxt.Test__b085(1, 85, "{\"!");
|
||||
fxt.Test__b085(1, 7225, "|\"!!");
|
||||
fxt.Test__b085(1, 614125, "}\"!!!");
|
||||
fxt.Test__b085(1, 52200625, "~\"!!!!");
|
||||
}
|
||||
@Test public void B085__reqd__2() {
|
||||
fxt.Init__b085();
|
||||
fxt.Test__b085(2, 0, "!!");
|
||||
fxt.Test__b085(2, 84, "!u");
|
||||
fxt.Test__b085(2, 85, "\"!");
|
||||
fxt.Test__b085(2, 7225, "|\"!!");
|
||||
fxt.Test__b085(2, 614125, "}\"!!!");
|
||||
fxt.Test__b085(2, 52200625, "~\"!!!!");
|
||||
}
|
||||
}
|
||||
class Xoh_hzip_int_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final gplx.core.primitives.Int_obj_ref count_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
private final Xoh_hzip_int hzint = new Xoh_hzip_int();
|
||||
public void Init__b256() {hzint.Mode_is_b256_(Bool_.Y);}
|
||||
public void Init__b085() {hzint.Mode_is_b256_(Bool_.N);}
|
||||
public void Test__b256(int reqd, int val, int... expd_ints) {
|
||||
hzint.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
byte[] expd = Byte_.Ary_by_ints(expd_ints);
|
||||
Tfds.Eq_ary(expd, actl, Int_.To_str(val));
|
||||
Tfds.Eq(val, hzint.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
public void Test__b085(int reqd, int val, String expd) {
|
||||
hzint.Encode(reqd, bfr, val);
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Tfds.Eq(expd, String_.new_u8(actl));
|
||||
Tfds.Eq(val, hzint.Decode(reqd, actl, actl.length, 0, count_ref));
|
||||
}
|
||||
}
|
||||
@@ -16,43 +16,57 @@ 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.brys.*; import gplx.core.btries.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.langs.htmls.parsers.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
public class Xoh_hzip_mgr {
|
||||
private final Xoh_hdoc_parser hdoc_parser = new Xoh_hdoc_parser(new Xoh_hdoc_wkr__hzip());
|
||||
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.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 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 void Encode(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {
|
||||
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 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);
|
||||
}
|
||||
public void Decode(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {
|
||||
byte[] page_url = hpg.Url_bry_safe();
|
||||
byte[] page_url = hpg.Url_bry_safe(); int src_len = src.length;
|
||||
hctx.Init_by_page(wiki, page_url);
|
||||
int pos = 0, txt_bgn = -1, src_len = src.length;
|
||||
rdr.Init_by_page(page_url, src, src_len);
|
||||
while (pos < src_len) {
|
||||
if (src[pos] == Xoh_hzip_dict_.Escape) {
|
||||
if (txt_bgn != -1) {bfr.Add_mid(src, txt_bgn, pos); txt_bgn = -1;} // handle pending txt
|
||||
int nxt_pos = pos + 1; if (nxt_pos == src_len) break; // handle escape at end of document
|
||||
Xoh_hzip_wkr wkr = hctx.Mkr().Hzip__wkr(src[nxt_pos]);
|
||||
try {
|
||||
rdr.Init_by_hook(wkr.Key(), pos, pos + 2);
|
||||
wkr.Decode(bfr, Bool_.Y, hctx, hpg, rdr, src, pos);
|
||||
pos = rdr.Pos();
|
||||
} catch (Exception e) {
|
||||
wkr.Pool__rls();
|
||||
gplx.langs.htmls.Html_utl.Log(e, "hzip decode failed", hpg.Url_bry_safe(), src, pos);
|
||||
pos += 2; // 2: skip escape and hook
|
||||
}
|
||||
}
|
||||
else {
|
||||
Decode(bfr, hdoc_wkr, hctx, hpg, Bool_.Y, rdr, src, 0, src_len);
|
||||
}
|
||||
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 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);
|
||||
if (o == null) {
|
||||
if (txt_bgn == -1) txt_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
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;
|
||||
try {
|
||||
rdr.Init_by_sect(wkr.Key(), pos, pos + 2);
|
||||
wkr.Decode(bfr, hdoc_wkr, hctx, hpg, Bool_.Y, rdr, src, pos, src_end);
|
||||
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
|
||||
}
|
||||
finally {wkr.Pool__rls();}
|
||||
}
|
||||
}
|
||||
if (txt_bgn != -1) bfr.Add_mid(src, txt_bgn, src_len);
|
||||
}
|
||||
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;}
|
||||
}
|
||||
|
||||
@@ -16,9 +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.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.brys.*;
|
||||
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 {
|
||||
String Key();
|
||||
int Decode(Bry_bfr bfr, boolean write_to_bfr, Xoh_hdoc_ctx ctx, Xoh_page hpg, Bry_rdr parser, byte[] src, int hook_bgn);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
|
||||
public class Xoh_hzip_wkr_mgr {
|
||||
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;
|
||||
public Xoh_escape_hzip Mw__escape() {return (Xoh_escape_hzip) mkr__escape.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_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);
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,14 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Hzip_stat_itm {
|
||||
import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
public class Xoh_stat_itm {
|
||||
public void Clear() {
|
||||
a_rhs = lnki_text_n = lnki_text_y = lnke__free = lnke__auto = lnke__text = 0;
|
||||
hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = 0;
|
||||
img_full = 0;
|
||||
space = 0;
|
||||
escape = 0;
|
||||
Bry_.Clear(escape_bry);
|
||||
}
|
||||
public int A_rhs() {return a_rhs;} public void A_rhs_add() {++a_rhs;} private int a_rhs;
|
||||
public int Lnki_text_n() {return lnki_text_n;} public void Lnki_text_n_add() {++lnki_text_n;} private int lnki_text_n;
|
||||
@@ -38,7 +39,7 @@ public class Hzip_stat_itm {
|
||||
public int Hdr_5() {return hdr_5;} private int hdr_5;
|
||||
public int Hdr_6() {return hdr_6;} private int hdr_6;
|
||||
public int Space() {return space;} public void Space_add(int v) {space += v;} private int space;
|
||||
public int Escape() {return escape;} public void Escape_add_one() {++escape;} private int escape;
|
||||
public byte[] Escape_bry() {return escape_bry;} public void Escape_add(byte v) {escape_bry[v] += 1;} private final byte[] escape_bry = new byte[256];
|
||||
public void Hdr_add(int hdr_num) {
|
||||
switch (hdr_num) {
|
||||
case 1: ++hdr_1; break;
|
||||
@@ -50,4 +51,13 @@ public class Hzip_stat_itm {
|
||||
default: throw Err_.new_unhandled(hdr_num);
|
||||
}
|
||||
}
|
||||
public void Lnki_add(int orig_len, int hzip_len, int flag) {
|
||||
}
|
||||
public void Lnke_add(byte lnke_type) {
|
||||
switch (lnke_type) {
|
||||
case Xoh_lnke_dict_.Type__free: ++lnke__free; break;
|
||||
case Xoh_lnke_dict_.Type__auto: ++lnke__auto; break;
|
||||
case Xoh_lnke_dict_.Type__text: ++lnke__text; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ 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.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Hzip_stat_tbl implements RlsAble {
|
||||
public class Xoh_stat_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hdump_stats"; private static final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private static final String
|
||||
fld_page_id = flds.Add_int_pkey("page_id"), fld_wtxt_len = flds.Add_int("wtxt_len"), fld_row_orig_len = flds.Add_int("row_orig_len"), fld_row_zip_len = flds.Add_int("row_zip_len")
|
||||
@@ -30,7 +30,7 @@ public class Hzip_stat_tbl implements RlsAble {
|
||||
, fld_img_full = flds.Add_int("img_full")
|
||||
;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Hzip_stat_tbl(Db_conn conn) {
|
||||
public Xoh_stat_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.Create_tbl();
|
||||
conn.Stmt_delete(tbl_name).Exec_delete(); // always zap table
|
||||
@@ -40,7 +40,7 @@ public class Hzip_stat_tbl implements RlsAble {
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(Xoh_page hpg, Hzip_stat_itm hzip, int wtxt_len, int row_orig_len, int row_zip_len) {
|
||||
public void Insert(Xoh_page hpg, Xoh_stat_itm hzip, int wtxt_len, int row_orig_len, int row_zip_len) {
|
||||
Xopg_module_mgr js_mgr = hpg.Head_mgr();
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user