mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.3.1
This commit is contained in:
@@ -24,11 +24,10 @@ public class Bry_rdr {
|
||||
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 Ctor_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_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;
|
||||
this.dflt_dlm = Byte_ascii.Null;
|
||||
return this;
|
||||
}
|
||||
public int Move_to(int v) {this.pos = v; return pos;}
|
||||
@@ -157,15 +156,15 @@ public class Bry_rdr {
|
||||
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);
|
||||
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_.Mid_safe(src, excerpt_bgn, excerpt_end));
|
||||
return String_.Replace(Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)), "\n", "\\n");
|
||||
else
|
||||
return Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Quote(String_.new_u8(Bry_.Mid_by_len_safe(src, excerpt_bgn, excerpt_end))));
|
||||
return String_.Replace(Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Quote(String_.new_u8(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)))), "\n", "\\n");
|
||||
}
|
||||
private static String Quote(String v) {return "'" + v + "'";}
|
||||
}
|
||||
|
||||
21
400_xowa/src/gplx/core/brys/Clear_able.java
Normal file
21
400_xowa/src/gplx/core/brys/Clear_able.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.core.brys; import gplx.*; import gplx.core.*;
|
||||
public interface Clear_able {
|
||||
void Clear();
|
||||
}
|
||||
@@ -24,6 +24,12 @@ public class Int_flag_bldr {
|
||||
this.val_ary = new int[pow_ary.length];
|
||||
return this;
|
||||
}
|
||||
public int Encode() {return Int_flag_bldr_.To_int(pow_ary, val_ary);}
|
||||
public void Decode(int v) {Int_flag_bldr_.To_int_ary(val_ary, pow_ary, v);}
|
||||
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 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;}
|
||||
public int Encode() {return Int_flag_bldr_.To_int(pow_ary, val_ary);}
|
||||
public void Decode(int v) {Int_flag_bldr_.To_int_ary(val_ary, pow_ary, v);}
|
||||
}
|
||||
|
||||
23
400_xowa/src/gplx/core/brys/Mid_able.java
Normal file
23
400_xowa/src/gplx/core/brys/Mid_able.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
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 interface Mid_able {
|
||||
byte[] Mid__src();
|
||||
int Mid__bgn();
|
||||
int Mid__end();
|
||||
}
|
||||
@@ -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.core.intls; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
class Gfo_i18n_itm {
|
||||
public Gfo_i18n_itm(int src, byte[] key, byte[] val, boolean val_fmt_exists, Gfo_i18n_val_cmd val_cmd) {
|
||||
this.src = src; this.key = key; this.val = val; this.val_fmt_exists = val_fmt_exists; this.val_cmd = val_cmd;
|
||||
|
||||
@@ -16,19 +16,20 @@ 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.primitives; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.*;
|
||||
public class Bry_cache {
|
||||
private final Hash_adp hash = Hash_adp_.new_(); private final Bry_obj_ref hash_ref = Bry_obj_ref.New_empty();
|
||||
public byte[] Get_or_new(String v) {return Get_or_new(Bry_.new_u8(v));}
|
||||
public byte[] Get_or_new(byte[] v) {
|
||||
if (v.length == 0) return Bry_.Empty;
|
||||
Object rv = hash.Get_by(hash_ref.Val_(v));
|
||||
if (rv == null) {
|
||||
Bry_obj_ref bry = Bry_obj_ref.new_(v);
|
||||
Bry_obj_ref bry = Bry_obj_ref.New(v);
|
||||
hash.Add_as_key_and_val(bry);
|
||||
return v;
|
||||
}
|
||||
else
|
||||
return ((Bry_obj_ref)rv).Val();
|
||||
}
|
||||
Hash_adp hash = Hash_adp_.new_(); Bry_obj_ref hash_ref = Bry_obj_ref.null_();
|
||||
public static final Bry_cache Instance = new Bry_cache(); Bry_cache() {}
|
||||
}
|
||||
|
||||
@@ -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.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.*;
|
||||
public class Gfo_thread_cmd_base implements Gfo_thread_cmd {
|
||||
@gplx.Virtual public String Async_key() {return "undefined";}
|
||||
|
||||
@@ -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.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.*;
|
||||
public class Gfo_thread_cmd_download implements Gfo_thread_cmd {
|
||||
public Gfo_thread_cmd Ctor(Gfo_usr_dlg usr_dlg, Gfui_kit kit) {this.usr_dlg = usr_dlg; this.kit = kit; xrg.Prog_dlg_(usr_dlg); return this;}
|
||||
|
||||
@@ -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.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.*;
|
||||
public class Gfo_thread_cmd_replace implements Gfo_thread_cmd {
|
||||
public Gfo_thread_cmd Init(Gfo_usr_dlg usr_dlg, Gfui_kit kit, Io_url fil) {
|
||||
|
||||
@@ -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.core.threads; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.*; import gplx.xowa.bldrs.cmds.utils.*;
|
||||
public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
public Gfo_thread_cmd_unzip Init(Gfo_usr_dlg usr_dlg, Gfui_kit kit, ProcessAdp bzip2_process, ProcessAdp zip_process, ProcessAdp gz_process, Io_url src, Io_url trg) {
|
||||
|
||||
@@ -19,5 +19,6 @@ package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import g
|
||||
public interface Gfo_poolable_itm {
|
||||
int Pool__idx();
|
||||
void Pool__clear (Object[] args);
|
||||
Gfo_poolable_itm Pool__make (int idx, Object[] args);
|
||||
Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args);
|
||||
void Pool__rls();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Gfo_poolable_mgr {
|
||||
public void Clear_fast() {
|
||||
this.pool = new Gfo_poolable_itm[pool_len];
|
||||
for (int i = 0; i < pool_len; ++i)
|
||||
pool[i] = prototype.Pool__make(i, make_args);
|
||||
pool[i] = prototype.Pool__make(this, i, make_args);
|
||||
this.free_ary = new int[pool_len];
|
||||
pool_nxt = free_len = 0;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class Gfo_poolable_mgr {
|
||||
pool_idx = pool_nxt++;
|
||||
rv = pool[pool_idx];
|
||||
if (rv == null) {
|
||||
rv = prototype.Pool__make(pool_idx, make_args);
|
||||
rv = prototype.Pool__make(this, pool_idx, make_args);
|
||||
pool[pool_idx] = rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.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);}
|
||||
}
|
||||
@@ -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(-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"), Object_.Ary("clear"), 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();
|
||||
@@ -74,10 +74,12 @@ class Gfo_poolable_mgr_tstr {
|
||||
public void Exec__rls(int idx) {mgr.Rls_fast(idx);}
|
||||
}
|
||||
class Sample_poolable_itm implements Gfo_poolable_itm {
|
||||
public Sample_poolable_itm(int pool_idx, Object[] make_args) {this.pool_idx = pool_idx; this.pool__make_args = make_args;}
|
||||
private Gfo_poolable_mgr pool_mgr;
|
||||
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 Gfo_poolable_itm Pool__make (int idx, Object[] args) {return new Sample_poolable_itm(idx, 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);}
|
||||
}
|
||||
|
||||
54
400_xowa/src/gplx/dbs/Db_diff_bldr.java
Normal file
54
400_xowa/src/gplx/dbs/Db_diff_bldr.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.dbs.metas.*; import gplx.dbs.sqls.*;
|
||||
class Db_diff_bldr {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final Db_sqlbldr__sqlite sql_bldr = new Db_sqlbldr__sqlite();
|
||||
public Db_diff_bldr() {sql_bldr.Bfr_(bfr);}
|
||||
public String Compare_db(String src_str, String trg_str) {
|
||||
// Io_url src_url = Io_url_.new_fil_(src_str);
|
||||
// Io_url trg_url = Io_url_.new_fil_(trg_str);
|
||||
// Db_conn src_conn = Db_conn_bldr.Instance.Get_or_new(src_url).Conn();
|
||||
// Db_conn trg_conn = Db_conn_bldr.Instance.Get_or_new(trg_url).Conn();
|
||||
Meta_tbl_mgr src_tbls = new Meta_tbl_mgr();
|
||||
Meta_tbl_mgr trg_tbls = new Meta_tbl_mgr();
|
||||
return Compare_tbls(src_tbls, trg_tbls);
|
||||
}
|
||||
public String Compare_tbls(Meta_tbl_mgr src_tbls, Meta_tbl_mgr trg_tbls) {
|
||||
int src_len = src_tbls.Len();
|
||||
for (int i = 0; i < src_len; ++i) {
|
||||
Meta_tbl_itm src_tbl = src_tbls.Get_at(i);
|
||||
Meta_tbl_itm trg_tbl = trg_tbls.Get_by(src_tbl.Name());
|
||||
if (trg_tbl == null) Tbl_delete(src_tbl);
|
||||
}
|
||||
int trg_len = trg_tbls.Len();
|
||||
for (int i = 0; i < trg_len; ++i) {
|
||||
Meta_tbl_itm trg_tbl = src_tbls.Get_at(i);
|
||||
Meta_tbl_itm src_tbl = trg_tbls.Get_by(trg_tbl.Name());
|
||||
if (src_tbl == null) Tbl_create(trg_tbl);
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
private void Tbl_delete(Meta_tbl_itm tbl) {
|
||||
bfr.Add_str_a7("DROP TABLE ").Add_str_u8(tbl.Name()).Add_byte_nl();
|
||||
}
|
||||
private void Tbl_create(Meta_tbl_itm tbl) {
|
||||
// sql_bldr.Bld_create_tbl(tbl);
|
||||
}
|
||||
}
|
||||
@@ -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.langs.gfs; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.gfo_regys.*;
|
||||
public class Gfs_msg_bldr implements GfoMsgParser {
|
||||
private final Gfs_parser parser = new Gfs_parser();
|
||||
public GfoMsg ParseToMsg(String s) {return Bld(s);}
|
||||
|
||||
@@ -23,8 +23,11 @@ public class Html_bldr_ {
|
||||
, Bry__a_lhs_w_href = Bry_.new_a7("<a href=\"")
|
||||
, Bry__img_lhs_w_alt = Bry_.new_a7("<img alt=\"")
|
||||
, Bry__img_lhs = Bry_.new_a7("<img")
|
||||
, Bry__div_lhs = Bry_.new_a7("<div")
|
||||
, Bry__div_rhs = Bry_.new_a7("</div>")
|
||||
, Bry__id__1st = Bry_.new_a7(" id=\"")
|
||||
, Bry__id__nth = Bry_.new_a7("\" id=\"")
|
||||
, Bry__cls__1st = Bry_.new_a7(" class=\"")
|
||||
, Bry__cls__nth = Bry_.new_a7("\" class=\"")
|
||||
, Bry__title__nth = Bry_.new_a7("\" title=\"")
|
||||
, Bry__alt__nth = Bry_.new_a7("\" alt=\"")
|
||||
|
||||
@@ -31,6 +31,9 @@ public class Html_tag_ {
|
||||
, Id__span = 8
|
||||
, Id__div = 9
|
||||
, Id__img = 10
|
||||
, Id__ul = 11
|
||||
, Id__li = 12
|
||||
, Id__p = 13
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__a = Bry_.new_a7("a")
|
||||
@@ -47,6 +50,24 @@ public class Html_tag_ {
|
||||
.Add_str_int("div" , Id__div)
|
||||
.Add_str_int("img" , Id__img)
|
||||
;
|
||||
public static String To_str(int tid) {
|
||||
switch (tid) {
|
||||
case Id__eos: return "EOS";
|
||||
case Id__any: return "any";
|
||||
case Id__unknown: return "unknown";
|
||||
case Id__comment: return "comment";
|
||||
case Id__h2: return "h2";
|
||||
case Id__h3: return "h2";
|
||||
case Id__h4: return "h2";
|
||||
case Id__h5: return "h2";
|
||||
case Id__h6: return "h2";
|
||||
case Id__a: return "a";
|
||||
case Id__span: return "span";
|
||||
case Id__div: return "div";
|
||||
case Id__img: return "img";
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static final byte[]
|
||||
Br_inl = Bry_.new_a7("<br/>")
|
||||
, Hr_inl = Bry_.new_a7("<hr/>")
|
||||
|
||||
@@ -177,4 +177,5 @@ public class Html_utl {
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public static String Replace_apos(String s) {return String_.Replace(s, "'", "\"");}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
import org.junit.*;
|
||||
public class Html_utl_tst {
|
||||
@Before public void init() {fxt.Clear();} private Html_atr_cls_fxt fxt = new Html_atr_cls_fxt();
|
||||
@Before public void init() {fxt.Clear();} private Html_atr_class_fxt fxt = new Html_atr_class_fxt();
|
||||
@Test public void Basic() {fxt.Test_del_comments("a<!-- b -->c" , "ac");}
|
||||
@Test public void Bgn_missing() {fxt.Test_del_comments("a b c" , "a b c");}
|
||||
@Test public void End_missing() {fxt.Test_del_comments("a<!-- b c" , "a<!-- b c");}
|
||||
@@ -37,7 +37,7 @@ public class Html_utl_tst {
|
||||
fxt.Test_unescape_html(Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, Bool_.Y, "a<>'&"b" , "a<>'&\"b"); // basic
|
||||
}
|
||||
}
|
||||
class Html_atr_cls_fxt {
|
||||
class Html_atr_class_fxt {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public void Clear() {
|
||||
tmp_bfr.Clear();
|
||||
|
||||
@@ -16,12 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public class Html_atr {
|
||||
private final byte[] src;
|
||||
public class Html_atr extends gplx.core.brys.Bfr_arg_base {
|
||||
public Html_atr(int idx, byte[] key, byte[] val, byte[] src, int val_bgn, int val_end) {
|
||||
this.idx = idx; this.key = key; this.val = val;
|
||||
this.src = src; this.val_bgn = val_bgn; this.val_end = val_end;
|
||||
}
|
||||
public byte[] Src() {return src;} private final byte[] src;
|
||||
public int Idx() {return idx;} private final int idx;
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public int Val_bgn() {return val_bgn;} private final int val_bgn;
|
||||
@@ -36,5 +36,10 @@ public class Html_atr {
|
||||
if (val_end > val_bgn)
|
||||
bfr.Add_mid(src, val_bgn, val_end);
|
||||
}
|
||||
@Override public boolean Bfr_arg__exists() {return this.Val_exists();}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (Val_exists())
|
||||
bfr.Add_mid(src, val_bgn, val_end);
|
||||
}
|
||||
public static final Html_atr Noop = new Html_atr(-1, Bry_.Empty, Bry_.Empty, Bry_.Empty, -1, -1);
|
||||
}
|
||||
|
||||
@@ -19,45 +19,36 @@ package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gpl
|
||||
import gplx.core.btries.*;
|
||||
public class Html_doc_parser {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private Html_txt_wkr txt_wkr;
|
||||
public Html_doc_parser Reg_txt(Html_txt_wkr txt_wkr) {
|
||||
private final Html_txt_wkr txt_wkr;
|
||||
public Html_doc_parser(Html_txt_wkr txt_wkr, Html_doc_wkr... wkr_ary) {
|
||||
this.txt_wkr = txt_wkr;
|
||||
return this;
|
||||
}
|
||||
public Html_doc_parser Reg_wkrs(Html_doc_wkr... wkr_ary) {
|
||||
for (Html_doc_wkr wkr : wkr_ary) {
|
||||
for (Html_doc_wkr wkr : wkr_ary)
|
||||
trie.Add_obj(wkr.Hook(), wkr);
|
||||
list.Add(wkr);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Parse(byte[] src, int src_bgn, int src_end) {
|
||||
txt_wkr.Init(src, src_bgn, src_end);
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Html_doc_wkr wkr = (Html_doc_wkr)list.Get_at(i);
|
||||
wkr.Init(src, src_bgn, src_end);
|
||||
}
|
||||
int pos = src_bgn;
|
||||
public void Parse(byte[] page_url, byte[] src, int src_bgn, int src_end) {
|
||||
int txt_bgn = -1;
|
||||
int pos = src_bgn;
|
||||
while (pos < src_end) {
|
||||
Object o = trie.Match_bgn(src, pos, src_end);
|
||||
if (o == null) {
|
||||
if (o == null) { // not a known hook; add to txt
|
||||
if (txt_bgn == -1) txt_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
else {
|
||||
if (txt_bgn != -1) {
|
||||
else { // known hook
|
||||
if (txt_bgn != -1) { // txt pending; handle it
|
||||
txt_wkr.Parse(txt_bgn, pos);
|
||||
txt_bgn = -1;
|
||||
}
|
||||
Html_doc_wkr wkr = (Html_doc_wkr)o;
|
||||
int hook_end = trie.Match_pos();
|
||||
try {pos = wkr.Parse(pos);}
|
||||
catch (Exception e) {Err_.Noop(e); txt_bgn = pos; pos = hook_end;}
|
||||
try {pos = wkr.Parse(src, src_bgn, src_end, pos);}
|
||||
catch (Exception e) {
|
||||
Err err = Err_.cast_or_make(e);
|
||||
if (!err.Logged()) Gfo_usr_dlg_.Instance.Warn_many("", "", Err_.Message_gplx_log(e), "page_url", page_url, "mid", Bry_.Mid_by_len_safe(src, pos, 255));
|
||||
txt_bgn = pos; // set txt_bgn to hook_bgn which is "pos"; i.e.: txt resumes from start of failed hook
|
||||
pos = trie.Match_pos(); // set pos to hook_end
|
||||
}
|
||||
}
|
||||
}
|
||||
if (txt_bgn != -1) txt_wkr.Parse(txt_bgn, src_end);
|
||||
if (txt_bgn != -1) txt_wkr.Parse(txt_bgn, src_end); // handle add pending txt at EOS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public interface Html_doc_wkr {
|
||||
byte[] Hook();
|
||||
void Init(byte[] src, int src_bgn, int src_end);
|
||||
int Parse(int pos);
|
||||
int Parse(byte[] src, int src_bgn, int src_end, int pos);
|
||||
}
|
||||
@@ -16,12 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
import gplx.xowa.parsers.htmls.*; import gplx.langs.htmls.parsers.styles.*;
|
||||
import gplx.xowa.parsers.htmls.*; import gplx.langs.htmls.parsers.styles.*; import gplx.langs.htmls.parsers.clses.*;
|
||||
public class Html_tag implements Mwh_atr_wkr {
|
||||
private Html_tag_rdr tag_rdr;
|
||||
private Ordered_hash atrs_hash; private boolean atrs_null; private int atrs_bgn, atrs_end;
|
||||
public Html_tag Init(Html_tag_rdr tag_rdr, boolean tag_is_tail, boolean tag_is_inline, int src_bgn, int src_end, int atrs_bgn, int atrs_end, int name_id) {
|
||||
this.tag_rdr = tag_rdr; this.atrs_null = true;
|
||||
this.tag_rdr = tag_rdr; this.src = tag_rdr.Src(); this.atrs_null = true;
|
||||
this.tag_is_tail = tag_is_tail; this.tag_is_inline = tag_is_inline;
|
||||
this.atrs_bgn = atrs_bgn; this.atrs_end = atrs_end;
|
||||
this.name_id = name_id; this.src_bgn = src_bgn; this.src_end = src_end;
|
||||
@@ -34,8 +34,18 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
return rv;
|
||||
}
|
||||
public int Name_id() {return name_id;} private int name_id;
|
||||
public Html_tag Chk_id(int chk) {
|
||||
if ( chk == name_id
|
||||
|| (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));
|
||||
return this;
|
||||
}
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public 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 boolean Atrs__match_pair(byte[] key, byte[] val) {
|
||||
@@ -47,12 +57,12 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(Html_atr_.Bry__class); if (rv == null) return false;
|
||||
byte[] rv_val = rv.Val();
|
||||
return Html_atr_cls_.Has(rv_val, 0, rv_val.length, val);
|
||||
return Html_atr_class_.Has(rv_val, 0, rv_val.length, val);
|
||||
}
|
||||
public byte Atrs__cls_find_1st(Hash_adp_bry hash) {
|
||||
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_cls_.Find_1st(tag_rdr.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);
|
||||
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);
|
||||
return rv;
|
||||
}
|
||||
private static final Html_atr_style_wkr__get_val_as_int style_wkr = new Html_atr_style_wkr__get_val_as_int();
|
||||
@@ -74,11 +84,11 @@ public class Html_tag implements Mwh_atr_wkr {
|
||||
public int Atrs__get_as_int_or(byte[] key, int or) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key); if (rv == null) return or;
|
||||
return Bry_.To_int_or(tag_rdr.Src(), rv.Val_bgn(), rv.Val_end(), or);
|
||||
return Bry_.To_int_or(src, rv.Val_bgn(), rv.Val_end(), or);
|
||||
}
|
||||
public Html_atr Atrs__get_by(byte[] key) {return Atrs__get_by(key, Bool_.Y);}
|
||||
public Html_atr Atrs__get_by_or_empty(byte[] key) {return Atrs__get_by(key, Bool_.N);}
|
||||
public Html_atr Atrs__get_by(byte[] key, boolean fail_if_null) {
|
||||
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) {
|
||||
|
||||
@@ -29,28 +29,25 @@ public class Html_tag_rdr {
|
||||
public void Init(byte[] src, int src_bgn, int src_end) {
|
||||
this.src = src; this.pos = src_bgn; this.src_end = src_end;
|
||||
tag__eos.Init(this, Bool_.N, Bool_.N, src_end, src_end, src_end, src_end, Html_tag_.Id__eos);
|
||||
rdr.Ctor_by_page(Bry_.Empty, src, src_end);
|
||||
rdr.Init_by_page(Bry_.Empty, src, src_end);
|
||||
}
|
||||
public int Pos() {return pos;} private int pos;
|
||||
public void Pos_(int v) {this.pos = v;}
|
||||
public void Atrs__make(Mwh_atr_wkr atr_wkr, int head_bgn, int head_end) {atr_parser.Parse(atr_wkr, -1, -1, src, head_bgn, head_end);}
|
||||
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, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__move_fwd_head(int match_name_id) {return Tag__find(Bool_.Y, Bool_.N, Bool_.N, match_name_id);}
|
||||
public Html_tag Tag__move_fwd_tail(int match_name_id) {return Tag__find(Bool_.Y, Bool_.N, Bool_.Y, match_name_id);}
|
||||
public Html_tag Tag__peek_fwd_head() {return Tag__find(Bool_.N, Bool_.N, Bool_.N, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__peek_fwd_head(int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.N, match_name_id);}
|
||||
public Html_tag Tag__peek_fwd_tail(int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.Y, match_name_id);}
|
||||
public Html_tag Tag__peek_bwd_tail(int match_name_id) {return Tag__find(Bool_.N, Bool_.Y, Bool_.Y, match_name_id);}
|
||||
public Html_tag Tag__peek_bwd_head() {return Tag__find(Bool_.N, Bool_.Y, Bool_.Y, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__move_fwd_head(byte[] cls) {
|
||||
Html_tag rv = Tag__find(Bool_.Y, Bool_.N, Bool_.N, Html_tag_.Id__any);
|
||||
if (!rv.Atrs__cls_has(cls)) rdr.Fail("missing cls", "cls", cls);
|
||||
return rv;
|
||||
}
|
||||
private Html_tag Tag__find(boolean move, boolean bwd, boolean tail, int match_name_id) {
|
||||
int tmp = pos;
|
||||
int stop_pos = src_end; int adj = 1;
|
||||
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);}
|
||||
public Html_tag Tag__peek_fwd_tail(int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.Y, pos, src_end, match_name_id);}
|
||||
public Html_tag Tag__peek_bwd_tail(int match_name_id) {return Tag__find(Bool_.N, Bool_.Y, Bool_.Y, pos, src_end, match_name_id);}
|
||||
public Html_tag Tag__peek_bwd_head() {return Tag__find(Bool_.N, Bool_.Y, Bool_.Y, pos, src_end, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__find_fwd_head(int bgn, int end, int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.N, bgn, end, match_name_id);}
|
||||
private Html_tag Tag__find(boolean move, boolean bwd, boolean tail, int rng_bgn, int rng_end, int match_name_id) {
|
||||
int tmp = rng_bgn;
|
||||
int stop_pos = rng_end; int adj = 1;
|
||||
if (bwd) {
|
||||
stop_pos = -1;
|
||||
adj = -1;
|
||||
@@ -72,10 +69,10 @@ public class Html_tag_rdr {
|
||||
tmp += adj;
|
||||
}
|
||||
if (rv == null) {
|
||||
if (move)
|
||||
rdr.Fail("missing tag", "name_id", match_name_id);
|
||||
if (move && tail && !bwd)
|
||||
rdr.Fail("move failed", "tag_name", Html_tag_.To_str(match_name_id));
|
||||
else
|
||||
return tag__eos;
|
||||
return Tag__eos(rng_bgn);
|
||||
}
|
||||
if (move) pos = rv.Src_end();
|
||||
return rv;
|
||||
@@ -98,13 +95,15 @@ public class Html_tag_rdr {
|
||||
if (depth == 0)
|
||||
return true;
|
||||
else {
|
||||
depth_obj.Val_add(-1);
|
||||
if (match_name_id == tag_name_id)
|
||||
depth_obj.Val_add(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!bwd && tail && !tag_is_tail) {
|
||||
depth_obj.Val_add(1);
|
||||
if (!bwd && tail && !tag_is_tail && !tag.Tag_is_inline()) {
|
||||
if (match_name_id == tag_name_id)
|
||||
depth_obj.Val_add(1);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -112,7 +111,7 @@ public class Html_tag_rdr {
|
||||
}
|
||||
}
|
||||
public Html_tag Tag__extract(boolean move, boolean tail, int match_name_id, int tag_bgn) {
|
||||
int name_bgn = tag_bgn + 1; if (name_bgn == src_end) return tag__eos; // EX: "<EOS"
|
||||
int name_bgn = tag_bgn + 1; if (name_bgn == src_end) return Tag__eos(tag_bgn); // EX: "<EOS"
|
||||
byte name_0 = src[name_bgn];
|
||||
boolean cur_is_tail = false;
|
||||
switch (name_0) {
|
||||
@@ -121,7 +120,7 @@ public class Html_tag_rdr {
|
||||
return Tag__comment(tag_bgn);
|
||||
break;
|
||||
case Byte_ascii.Slash:
|
||||
++name_bgn; if (name_bgn == src_end) return tag__eos; // EX: "</EOS"
|
||||
++name_bgn; if (name_bgn == src_end) return Tag__eos(tag_bgn); // EX: "</EOS"
|
||||
name_0 = src[name_bgn];
|
||||
cur_is_tail = true;
|
||||
break;
|
||||
@@ -138,7 +137,7 @@ public class Html_tag_rdr {
|
||||
break;
|
||||
case Byte_ascii.Slash: // EX: "<a/>"
|
||||
name_end = name_pos;
|
||||
tag_end = name_pos + 1; if (tag_end == src_end) return tag__eos; // EX: "<a/EOS"
|
||||
tag_end = name_pos + 1; if (tag_end == src_end) return Tag__eos(tag_bgn);// EX: "<a/EOS"
|
||||
if (src[tag_end] == Byte_ascii.Angle_end) {
|
||||
atrs_end = name_end;
|
||||
inline = true;
|
||||
@@ -154,12 +153,12 @@ public class Html_tag_rdr {
|
||||
break;
|
||||
}
|
||||
if (!loop) break;
|
||||
++name_pos; if (name_pos == src_end) return tag__eos; // EX: "<abEOS"
|
||||
++name_pos; if (name_pos == src_end) return Tag__eos(tag_bgn); // EX: "<abEOS"
|
||||
name_byte = src[name_pos];
|
||||
}
|
||||
if (tag_end == -1) {
|
||||
tag_end = Bry_find_.Find_fwd(src, Byte_ascii.Angle_end, name_end, src_end);
|
||||
if (tag_end == Bry_find_.Not_found) return tag__eos;
|
||||
if (tag_end == Bry_find_.Not_found) return Tag__eos(tag_bgn);
|
||||
int prv_pos = tag_end - 1;
|
||||
if (src[prv_pos] == Byte_ascii.Slash) {
|
||||
atrs_end = prv_pos;
|
||||
@@ -218,5 +217,9 @@ public class Html_tag_rdr {
|
||||
int tag_end = Bry_find_.Move_fwd(src, gplx.langs.htmls.Html_tag_.Comm_end, tag_bgn, src_end); if (tag_end == Bry_find_.Not_found) tag_end = src_end;
|
||||
return tag__comment.Init(this, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__comment);
|
||||
}
|
||||
private Html_tag Tag__eos(int tag_bgn) {
|
||||
int tag_end = tag_bgn + 255; if (tag_end > src_end) tag_end = src_end;
|
||||
return tag__comment.Init(this, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__eos);
|
||||
}
|
||||
private static final byte[] Bry__comment__mid = Bry_.new_a7("--");
|
||||
}
|
||||
|
||||
@@ -35,22 +35,26 @@ public class Html_tag_rdr_tst {
|
||||
fxt.Init("<!DOCTYPE html>1<div id='1'>2</div>3");
|
||||
fxt.Test__move_fwd_head(Html_tag_.Id__div , "<div id='1'>") ; fxt.Test__pos("2");
|
||||
}
|
||||
@Test public void Recursive() {
|
||||
@Test public void Recursive__same_tags() {
|
||||
fxt.Init("1<a>2<a>3</a>4</a>5");
|
||||
fxt.Test__move_fwd_head(Html_tag_.Id__a , "<a>") ; fxt.Test__pos("2");
|
||||
fxt.Test__move_fwd_tail(Html_tag_.Id__a , "</a>") ; fxt.Test__pos("5");
|
||||
}
|
||||
@Test public void Recursive__diff_tags() {
|
||||
fxt.Init("1<div>2<a>3<img/>4</a>5</div>6");
|
||||
fxt.Test__move_fwd_head(Html_tag_.Id__div , "<div>") ; fxt.Test__pos("2");
|
||||
fxt.Test__move_fwd_tail(Html_tag_.Id__div , "</div>") ; fxt.Test__pos("6");
|
||||
}
|
||||
}
|
||||
class Html_tag_rdr_fxt {
|
||||
private final Html_tag_rdr rdr = new Html_tag_rdr();
|
||||
// private final Html_doc_log log = new Html_doc_log();
|
||||
public void Init(String src_str) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
rdr.Init(src_bry, 0, src_bry.length);
|
||||
}
|
||||
public void Test__move_fwd_head(String expd) {Test__move_fwd_head(Html_tag_.Id__any, expd);}
|
||||
public void Test__move_fwd_head(int match_name_id, String expd) {
|
||||
Html_tag actl_tag = rdr.Tag__move_fwd_head(match_name_id);
|
||||
Html_tag actl_tag = rdr.Tag__move_fwd_head(match_name_id).Chk_id(match_name_id);
|
||||
Tfds.Eq_str(expd, String_.new_u8(rdr.Src(), actl_tag.Src_bgn(), actl_tag.Src_end()));
|
||||
}
|
||||
public void Test__move_fwd_tail(int match_name_id, String expd) {
|
||||
|
||||
@@ -18,5 +18,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public interface Html_txt_wkr {
|
||||
void Parse(int rng_bgn, int rng_end);
|
||||
void Init(byte[] src, int src_bgn, int src_end);
|
||||
}
|
||||
@@ -15,8 +15,8 @@ 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.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public class Html_atr_cls_ {
|
||||
package gplx.langs.htmls.parsers.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
public class Html_atr_class_ {
|
||||
public static boolean Has(byte[] src, int src_bgn, int src_end, byte[] cls) {
|
||||
int cls_bgn = src_bgn;
|
||||
int pos = src_bgn;
|
||||
@@ -15,10 +15,10 @@ 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.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
package gplx.langs.htmls.parsers.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Html_atr_cls__tst {
|
||||
private final Html_atr_cls__fxt fxt = new Html_atr_cls__fxt();
|
||||
public class Html_atr_class__tst {
|
||||
private final Html_atr_class__fxt fxt = new Html_atr_class__fxt();
|
||||
@Test public void Has() {
|
||||
fxt.Test__has__y("a b c", "a", "b", "c");
|
||||
fxt.Test__has__n("a b c", "d");
|
||||
@@ -34,14 +34,14 @@ public class Html_atr_cls__tst {
|
||||
fxt.Test__find_1st(hash, Byte_.Max_value_127, "xyz");
|
||||
}
|
||||
}
|
||||
class Html_atr_cls__fxt {
|
||||
class Html_atr_class__fxt {
|
||||
public void Test__has__y(String src, String... ary) {Test__has(Bool_.Y, src, ary);}
|
||||
public void Test__has__n(String src, String... ary) {Test__has(Bool_.N, src, ary);}
|
||||
public void Test__has(boolean expd, String src, String... ary) {
|
||||
byte[] src_bry = Bry_.new_u8(src);
|
||||
for (String itm : ary) {
|
||||
byte[] itm_bry = Bry_.new_u8(itm);
|
||||
Tfds.Eq_bool(expd, Html_atr_cls_.Has(src_bry, 0, src_bry.length, itm_bry), itm);
|
||||
Tfds.Eq_bool(expd, Html_atr_class_.Has(src_bry, 0, src_bry.length, itm_bry), itm);
|
||||
}
|
||||
}
|
||||
public Hash_adp_bry Make_hash(String... ary) {
|
||||
@@ -53,6 +53,6 @@ class Html_atr_cls__fxt {
|
||||
}
|
||||
public void Test__find_1st(Hash_adp_bry hash, int expd, String src) {
|
||||
byte[] src_bry = Bry_.new_u8(src);
|
||||
Tfds.Eq_byte((byte)expd, Html_atr_cls_.Find_1st(src_bry, 0, src_bry.length, hash), src);
|
||||
Tfds.Eq_byte((byte)expd, Html_atr_class_.Find_1st(src_bry, 0, src_bry.length, hash), src);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.langs.htmls.parsers.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
public class Html_atr_class_parser_ {
|
||||
public static void Parse(Html_tag tag, Html_atr_class_wkr wkr) {
|
||||
Html_atr atr = tag.Atrs__get_by_or_empty(Html_atr_.Bry__class);
|
||||
if (atr.Val_exists())
|
||||
Parse(tag.Src(), atr.Val_bgn(), atr.Val_end(), wkr);
|
||||
}
|
||||
public static void Parse(byte[] src, int src_bgn, int src_end, Html_atr_class_wkr wkr) {
|
||||
int atr_idx = 0, atr_bgn = -1, atr_end = -1, tmp_bgn = -1, tmp_end = -1;
|
||||
int pos = src_bgn;
|
||||
while (true) {
|
||||
boolean pos_is_last = pos == src_end;
|
||||
byte b = pos_is_last ? Byte_ascii.Space : src[pos];
|
||||
switch (b) {
|
||||
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
|
||||
if (tmp_bgn != -1) { // ignore empty atrs
|
||||
if (!wkr.On_cls(src, atr_idx, atr_bgn, atr_end, tmp_bgn, tmp_end))
|
||||
pos_is_last = true;
|
||||
}
|
||||
++atr_idx; atr_bgn = -1; atr_end = -1; tmp_bgn = -1; tmp_end = -1;
|
||||
break;
|
||||
default:
|
||||
if (tmp_bgn == -1) tmp_bgn = pos;
|
||||
tmp_end = pos + 1;
|
||||
break;
|
||||
}
|
||||
if (pos_is_last) break;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.langs.htmls.parsers.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Html_atr_class_parser__tst {
|
||||
private final Html_atr_class_parser__fxt fxt = new Html_atr_class_parser__fxt();
|
||||
@Test public void Basic() {fxt.Test__parse("v1" , "v1");}
|
||||
@Test public void Many() {fxt.Test__parse("v1 v2" , "v1", "v2");}
|
||||
}
|
||||
class Html_atr_class_parser__fxt {
|
||||
private final Html_atr_class_wkr__list wkr = new Html_atr_class_wkr__list();
|
||||
public void Test__parse(String src_str, String... expd) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
String[] actl = wkr.Parse(src_bry, 0, src_bry.length);
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
}
|
||||
}
|
||||
class Html_atr_class_wkr__list implements Html_atr_class_wkr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public boolean On_cls(byte[] src, int atr_idx, int atr_bgn, int atr_end, int val_bgn, int val_end) {
|
||||
String s = String_.new_u8(src, val_bgn, val_end);
|
||||
list.Add(s); //
|
||||
return true;
|
||||
}
|
||||
public String[] Parse(byte[] src, int src_bgn, int src_end) {
|
||||
Html_atr_class_parser_.Parse(src, src_bgn, src_end, this);
|
||||
return (String[])list.To_ary_and_clear(String.class);
|
||||
}
|
||||
}
|
||||
@@ -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.langs.htmls.parsers.clses; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
public interface Html_atr_class_wkr {
|
||||
boolean On_cls(byte[] src, int atr_idx, int atr_bgn, int atr_end, int val_bgn, int val_end);
|
||||
}
|
||||
@@ -16,7 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers.styles; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
public class Html_atr_style_parser {
|
||||
public class Html_atr_style_parser_ {
|
||||
public static void Parse(Html_tag tag, Html_atr_style_wkr wkr) {
|
||||
Html_atr atr = tag.Atrs__get_by_or_empty(Html_atr_.Bry__style);
|
||||
if (atr.Val_exists())
|
||||
Parse(tag.Src(), atr.Val_bgn(), atr.Val_end(), wkr);
|
||||
}
|
||||
public static void Parse(byte[] src, int src_bgn, int src_end, Html_atr_style_wkr wkr) {
|
||||
int atr_idx = 0, atr_bgn = -1, atr_end = -1, key_bgn = -1, key_end = -1, tmp_bgn = -1, tmp_end = -1;
|
||||
int pos = src_bgn;
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers.styles; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
import org.junit.*;
|
||||
public class Html_atr_style_parser_tst {
|
||||
private final Html_atr_style_parser_fxt fxt = new Html_atr_style_parser_fxt();
|
||||
public class Html_atr_style_parser__tst {
|
||||
private final Html_atr_style_parser__fxt fxt = new Html_atr_style_parser__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__parse("k_0:v_0" , fxt.Make("k_0", "v_0"));
|
||||
fxt.Test__parse("k_0:v_0;" , fxt.Make("k_0", "v_0"));
|
||||
@@ -30,7 +30,7 @@ public class Html_atr_style_parser_tst {
|
||||
fxt.Test__parse(" k_0 : v 0 ;" , fxt.Make("k_0", "v 0"));
|
||||
}
|
||||
}
|
||||
class Html_atr_style_parser_fxt {
|
||||
class Html_atr_style_parser__fxt {
|
||||
private final Html_atr_style_wkr__kv_list wkr = new Html_atr_style_wkr__kv_list();
|
||||
public KeyVal Make(String k, String v) {return KeyVal_.new_(k, v);}
|
||||
public void Test__parse(String src_str, KeyVal... expd) {
|
||||
@@ -39,3 +39,15 @@ class Html_atr_style_parser_fxt {
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
}
|
||||
}
|
||||
class Html_atr_style_wkr__kv_list implements Html_atr_style_wkr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_bgn, int atr_end, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
KeyVal kv = KeyVal_.new_(String_.new_u8(src, key_bgn, key_end), String_.new_u8(src, val_bgn, val_end));
|
||||
list.Add(kv);
|
||||
return true;
|
||||
}
|
||||
public KeyVal[] Parse(byte[] src, int src_bgn, int src_end) {
|
||||
Html_atr_style_parser_.Parse(src, src_bgn, src_end, this);
|
||||
return (KeyVal[])list.To_ary_and_clear(KeyVal.class);
|
||||
}
|
||||
}
|
||||
@@ -19,15 +19,3 @@ package gplx.langs.htmls.parsers.styles; import gplx.*; import gplx.langs.*; imp
|
||||
public interface Html_atr_style_wkr {
|
||||
boolean On_atr(byte[] src, int atr_idx, int atr_bgn, int atr_end, int key_bgn, int key_end, int val_bgn, int val_end);
|
||||
}
|
||||
class Html_atr_style_wkr__kv_list implements Html_atr_style_wkr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_bgn, int atr_end, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
KeyVal kv = KeyVal_.new_(String_.new_u8(src, key_bgn, key_end), String_.new_u8(src, val_bgn, val_end));
|
||||
list.Add(kv);
|
||||
return true;
|
||||
}
|
||||
public KeyVal[] Parse(byte[] src, int src_bgn, int src_end) {
|
||||
Html_atr_style_parser.Parse(src, src_bgn, src_end, this);
|
||||
return (KeyVal[])list.To_ary_and_clear(KeyVal.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Html_atr_style_wkr__get_val_as_int implements Html_atr_style_wkr {
|
||||
}
|
||||
public int Parse(byte[] src, int src_bgn, int src_end, byte[] find_key) {
|
||||
this.find_key = find_key;
|
||||
Html_atr_style_parser.Parse(src, src_bgn, src_end, this);
|
||||
Html_atr_style_parser_.Parse(src, src_bgn, src_end, this);
|
||||
return Bry_.To_int_or__lax(src, val_bgn, val_end, -1);
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.11.2.1";
|
||||
public static final String Version = "2.11.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -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; import gplx.*;
|
||||
import gplx.langs.gfs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
|
||||
@@ -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; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*;
|
||||
import gplx.core.btries.*; import gplx.core.brys.fmtrs.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.metas.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.progs.*; import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
|
||||
|
||||
@@ -389,7 +389,7 @@ public class Xop_fxt {
|
||||
public void Test_html_modules_js(String expd) {
|
||||
Bry_bfr bfr = app.Utl__bfr_mkr().Get_k004();
|
||||
this.Page().Html_data().Head_mgr().Init(app, wiki, this.Page());
|
||||
this.Page().Html_data().Head_mgr().Fmt__do(bfr);
|
||||
this.Page().Html_data().Head_mgr().Bfr_arg__add(bfr);
|
||||
bfr.Mkr_rls();
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
|
||||
@@ -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; import gplx.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.apps.cfgs.gui.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*;
|
||||
|
||||
@@ -16,6 +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.apps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.gfs.*;
|
||||
public class Xoa_app_eval implements Bry_fmtr_eval_mgr {
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
|
||||
public byte[] Eval(byte[] cmd) {
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
public class Xoa_app_eval_tst {
|
||||
Xoa_app_eval_fxt fxt = new Xoa_app_eval_fxt();
|
||||
|
||||
@@ -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.apps.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
private final Xoae_app app; // NOTE: needed to get "img_dir" below
|
||||
private byte[] img_title_val_y, img_title_val_n;
|
||||
|
||||
@@ -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.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
public class Xoa_cfg_db_txt implements Xoa_cfg_db {
|
||||
private Bry_fmtr fmtr = Bry_fmtr.new_("app.cfgs.get('~{msg}', '~{wiki}').val = '~{val}';\n", "msg", "wiki", "val");
|
||||
|
||||
@@ -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.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.guis.langs.*;
|
||||
public class Xocfg_win implements GfoInvkAble {
|
||||
public Xocfg_win(Xoae_app app) {}
|
||||
|
||||
@@ -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.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
public class Xoa_fmtr_itm implements GfoInvkAble {
|
||||
public Xoa_fmtr_itm(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
public String Src() {return src;} public Xoa_fmtr_itm Src_(String v) {this.src = v; return this;} private String src;
|
||||
|
||||
@@ -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.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.langs.gfs.*;
|
||||
public class Xoa_fmtr_itm_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoa_fmtr_itm_fxt fxt = new Xoa_fmtr_itm_fxt();
|
||||
@Test public void Basic() {
|
||||
|
||||
@@ -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.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.users.*;
|
||||
public class Xoa_fsys_eval implements Bry_fmtr_eval_mgr {
|
||||
private final Xoa_fsys_mgr app_fsys_mgr; private final Xou_fsys_mgr usr_fsys_mgr;
|
||||
|
||||
@@ -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.apps.gfs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.phps.*;
|
||||
public class Xoa_gfs_php_mgr {
|
||||
public static byte[] Xto_php(Bry_bfr bfr, boolean escape_backslash, byte[] src) {
|
||||
|
||||
@@ -98,12 +98,12 @@ public class Xob_cmd_mgr implements GfoInvkAble {
|
||||
Xobd_rdr rv = (Xobd_rdr)dump_rdrs.Get_by(dump_rdrs_ref.Val_(wiki_key));
|
||||
if (rv == null) {
|
||||
rv = new Xobd_rdr(bldr, wiki);
|
||||
dump_rdrs.Add(Bry_obj_ref.new_(wiki_key), rv);
|
||||
dump_rdrs.Add(Bry_obj_ref.New(wiki_key), rv);
|
||||
this.Add(rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private Hash_adp dump_rdrs = Hash_adp_.new_(); private Bry_obj_ref dump_rdrs_ref = Bry_obj_ref.null_();
|
||||
private Hash_adp dump_rdrs = Hash_adp_.new_(); private Bry_obj_ref dump_rdrs_ref = Bry_obj_ref.New_empty();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_add)) return Add_cmd(Wiki_get_or_make(m), m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_add_many)) return Add_many(m);
|
||||
|
||||
@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.core.flds.*; import gplx.core.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.ctgs.*;
|
||||
import gplx.xowa.bldrs.wtrs.*;
|
||||
public class Xob_ctg_v1_sql extends Xob_ctg_v1_base {
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.gfo_ndes.*;
|
||||
import gplx.stores.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xob_xfer_temp_itm_tst {
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class Xob_search_base extends Xob_itm_dump_base implements Xobd_
|
||||
public static byte[][] Split_ttl_into_words(Xol_lang_itm lang, Ordered_hash list, Bry_bfr bfr, byte[] ttl) {
|
||||
if (lang != null) // null lang passed in by searcher
|
||||
ttl = lang.Case_mgr().Case_build_lower(ttl);
|
||||
int ttl_len = ttl.length; Bry_obj_ref word_ref = Bry_obj_ref.new_(Bry_.Empty);
|
||||
int ttl_len = ttl.length; Bry_obj_ref word_ref = Bry_obj_ref.New(Bry_.Empty);
|
||||
int i = 0; boolean word_done = false;
|
||||
while (true) {
|
||||
if (word_done || i == ttl_len) {
|
||||
|
||||
@@ -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.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.bldrs.wms.dumps.*;
|
||||
public class Xob_core_batch_utl implements GfoInvkAble {
|
||||
|
||||
@@ -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.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.core.ios.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.brys.fmtrs.*; import gplx.core.ios.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*;
|
||||
|
||||
@@ -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.bldrs.installs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.core.brys.fmtrs.*; import gplx.core.threads.*;
|
||||
public class Xoi_cmd_mgr implements GfoInvkAble {
|
||||
List_adp cmds = List_adp_.new_();
|
||||
public Xoi_cmd_mgr(Xoi_setup_mgr install_mgr) {this.app = install_mgr.App(); this.install_mgr = install_mgr;} private Xoae_app app; Xoi_setup_mgr install_mgr;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.bldrs.installs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import org.junit.*;
|
||||
import gplx.core.consoles.*;
|
||||
import gplx.brys.*; import gplx.core.threads.*; import gplx.xowa.bldrs.setups.maints.*; import gplx.xowa.xtns.wdatas.imports.*;
|
||||
import gplx.core.brys.args.*; import gplx.core.threads.*; import gplx.xowa.bldrs.setups.maints.*; import gplx.xowa.xtns.wdatas.imports.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.bldrs.wms.*; import gplx.xowa.bldrs.wms.dumps.*;
|
||||
public class Xoi_cmd_wiki_tst {
|
||||
@@ -30,12 +30,12 @@ public class Xoi_cmd_wiki_tst {
|
||||
int ary_len = ary.length;
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
Wmf_latest_parser parser = new Wmf_latest_parser();
|
||||
Bry_fmtr_arg_time time_fmtr = new Bry_fmtr_arg_time();
|
||||
Bfr_arg__time time_fmtr = new Bfr_arg__time();
|
||||
for (int i = 0; i < ary_len; i++)
|
||||
Bld_import_list_itm2(bfr, parser, time_fmtr, ary, i);
|
||||
Io_mgr.Instance.SaveFilStr("C:\\temp.txt", bfr.To_str());
|
||||
}
|
||||
private void Bld_import_list_itm2(Bry_bfr bfr, Wmf_latest_parser parser, Bry_fmtr_arg_time time_fmtr, String[] ary, int i) {
|
||||
private void Bld_import_list_itm2(Bry_bfr bfr, Wmf_latest_parser parser, Bfr_arg__time time_fmtr, String[] ary, int i) {
|
||||
String domain_str = ary[i];
|
||||
byte[] domain_bry = Bry_.new_a7(domain_str);
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
@@ -61,7 +61,7 @@ public class Xoi_cmd_wiki_tst {
|
||||
long src_size = latest_itm.Size();
|
||||
bfr.Add_long_variable(src_size).Add_byte_pipe();
|
||||
bfr.Add_str_a7(gplx.core.ios.Io_size_.To_str(src_size)).Add_byte_pipe();
|
||||
time_fmtr.Seconds_(Math_.Div_safe_as_long(src_size, 1000000)).Fmt__do(bfr);
|
||||
time_fmtr.Seconds_(Math_.Div_safe_as_long(src_size, 1000000)).Bfr_arg__add(bfr);
|
||||
bfr.Add_byte_pipe();
|
||||
bfr.Add_str_a7(latest_itm.Date().XtoStr_fmt_yyyy_MM_dd_HH_mm());
|
||||
bfr.Add_byte_pipe();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -29,12 +29,12 @@ public class Xowd_data_tstr {
|
||||
Xowd_db_file html_db = wiki.Data__core_mgr().Db__html();
|
||||
if (html_db == null) {
|
||||
html_db = wiki.Data__core_mgr().Db__core();
|
||||
html_db.Tbl__html_page().Create_tbl();
|
||||
html_db.Tbl__html().Create_tbl();
|
||||
}
|
||||
byte[] html_bry = Bry_.new_u8(html);
|
||||
Xoh_page gui_page = new Xoh_page();
|
||||
gui_page.Body_(html_bry);
|
||||
byte[] data = html_bry;
|
||||
html_db.Tbl__html_page().Insert(page_id, 0, 0, Bry_.Empty, Bry_.Empty, Bry_.Empty, data);
|
||||
html_db.Tbl__html().Insert(page_id, 0, gplx.core.ios.Io_stream_.Tid_raw, gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_.Hzip__none, Bry_.Empty, Bry_.Empty, Bry_.Empty, data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.fsdb.fs_roots; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.core.ios.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.data.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.files.gui.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.caches.*;
|
||||
public class Fs_root_fsdb_mgr implements Xof_fsdb_mgr, GfoInvkAble { // read images from file-system dir
|
||||
|
||||
@@ -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.guis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.gfui.*; import gplx.xowa.specials.search.*; import gplx.xowa.guis.menus.*; import gplx.xowa.guis.cmds.*; import gplx.xowa.apps.cfgs.gui.*; import gplx.xowa.users.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.guis.bnds.*; import gplx.xowa.guis.views.*; import gplx.xowa.guis.urls.url_macros.*;
|
||||
|
||||
@@ -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.guis.urls.url_macros; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.urls.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.core.btries.*; import gplx.core.brys.fmtrs.*;
|
||||
public class Xog_url_macro_grp implements GfoInvkAble {
|
||||
public Btrie_slim_mgr Trie() {return trie;} private Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
public void Del(byte[] abrv) {trie.Del(abrv);}
|
||||
|
||||
@@ -27,7 +27,8 @@ public class Xoh_page implements Xoa_page {
|
||||
public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true;
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public byte[] Body() {return body;} public void Body_(byte[] v) {this.body = v;} private byte[] body;
|
||||
public byte Body_flag() {return body_flag;} private byte body_flag = Byte_.Max_value_127;
|
||||
public int Body_zip_tid() {return body_zip_tid;} private int body_zip_tid;
|
||||
public int Body_hzip_tid() {return body_hzip_tid;} private int body_hzip_tid;
|
||||
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
|
||||
public byte[] Content_sub() {return content_sub;} private byte[] content_sub;
|
||||
public byte[] Sidebar_div() {return sidebar_div;} private byte[] sidebar_div;
|
||||
@@ -48,9 +49,9 @@ public class Xoh_page implements Xoa_page {
|
||||
this.wiki = wiki; this.page_url = page_url; this.page_ttl = page_ttl; this.page_id = page_id;
|
||||
this.Clear();
|
||||
}
|
||||
public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte body_flag, byte[] body) {
|
||||
public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, int zip_tid, int hzip_tid, byte[] body) {
|
||||
head_mgr.Flag_(head_flag);
|
||||
this.display_ttl = display_ttl; this.content_sub = content_sub; this.sidebar_div = sidebar_div; this.body = body; this.body_flag = body_flag;
|
||||
this.display_ttl = display_ttl; this.content_sub = content_sub; this.sidebar_div = sidebar_div; this.body = body; this.body_zip_tid = zip_tid; this.body_hzip_tid = hzip_tid;
|
||||
}
|
||||
public Xoh_page Ctor_by_page(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
this.page_id = page.Revision_data().Id();
|
||||
@@ -64,6 +65,7 @@ public class Xoh_page implements Xoa_page {
|
||||
return this;
|
||||
}
|
||||
private void Clear() {
|
||||
this.body_zip_tid = -1; this.body_hzip_tid = -1;
|
||||
display_ttl = content_sub = sidebar_div = Bry_.Empty;
|
||||
img_itms = Xohd_img_itm__base.Ary_empty;
|
||||
head_mgr.Clear(); gallery_itms.Clear(); redlink_uids.Clear(); commons_mgr.Clear();
|
||||
|
||||
@@ -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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.portal.*;
|
||||
public class Xoh_page_mgr implements GfoInvkAble {
|
||||
public Xoh_subpages_bldr Subpages_bldr() {return subpages_bldr;} private final Xoh_subpages_bldr subpages_bldr = new Xoh_subpages_bldr();
|
||||
|
||||
@@ -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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xoh_page_wtr_mgr implements GfoInvkAble {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
|
||||
@@ -16,11 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.langs.htmls.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.parsers.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.htmls.portal.*;
|
||||
public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
public class Xoh_page_wtr_wkr extends gplx.core.brys.Bfr_arg_base {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255); private final Object thread_lock_1 = new Object(), thread_lock_2 = new Object();
|
||||
private final Xoh_page_wtr_mgr mgr; private final byte page_mode;
|
||||
private final Wdata_xwiki_link_wtr wdata_lang_wtr = new Wdata_xwiki_link_wtr(); // In other languages
|
||||
@@ -43,14 +44,14 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
break;
|
||||
}
|
||||
Bry_bfr page_bfr = Xoa_app_.Utl__bfr_mkr().Get_m001(); // NOTE: get separate page bfr to output page; do not reuse tmp_bfr b/c it will be used inside Fmt_do
|
||||
Fmt__do(page_bfr);
|
||||
Bfr_arg__add(page_bfr);
|
||||
Write_page_by_tid(view_mode, bfr, fmtr, page_bfr.To_bry_and_rls());
|
||||
if (page_mode == Xopg_page_.Tid_html) // if html, write page again, but wrap it in html skin this time
|
||||
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Html_utl.Escape_html_as_bry(bfr.To_bry_and_clear()));
|
||||
wdata_lang_wtr.Page_(null);
|
||||
}
|
||||
else
|
||||
Fmt__do(bfr);
|
||||
Bfr_arg__add(bfr);
|
||||
this.page = null;
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
Xoh_page_wtr_wkr_.Bld_head_end(bfr, page); // add after </head>
|
||||
Xoh_page_wtr_wkr_.Bld_html_end(bfr, page); // add after </html>
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {Write_body(bfr, Xoh_wtr_ctx.Basic, page);}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {Write_body(bfr, Xoh_wtr_ctx.Basic, page);}
|
||||
public void Write_body(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xoae_page page) {
|
||||
synchronized (thread_lock_2) {
|
||||
this.page = page; this.wiki = page.Wikie(); this.app = wiki.Appe();
|
||||
|
||||
@@ -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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
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
|
||||
@@ -42,9 +43,9 @@ public class Xohp_ctg_grp_mgr {
|
||||
grp_fmtr.Bld_bfr_many(bfr, categories_lbl, itm_mgr);
|
||||
}
|
||||
}
|
||||
class Xoh_ctg_itm_fmtr implements Bry_fmtr_arg {
|
||||
class Xoh_ctg_itm_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
public void Set(Xoae_page page, Bry_fmtr itm_fmtr) {this.page = page; this.itm_fmtr = itm_fmtr;} private Xoae_page page; Bry_fmtr itm_fmtr;
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int ctgs_len = page.Category_list().length;
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
|
||||
Bry_bfr tmp_href = Xoa_app_.Utl__bfr_mkr().Get_b128();
|
||||
|
||||
@@ -16,8 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public class Dbui_cells_fmtr implements Bry_fmtr_arg {
|
||||
public class Dbui_cells_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
private final Dbui_cell_fmtr cell_fmtr = new Dbui_cell_fmtr();
|
||||
private final Dbui_btn_fmtr btn_fmtr = new Dbui_btn_fmtr();
|
||||
private Dbui_btn_itm[] btns;
|
||||
@@ -29,7 +30,7 @@ public class Dbui_cells_fmtr implements Bry_fmtr_arg {
|
||||
this.row_key = row_key; this.row_itm = row_itm;
|
||||
return this;
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
fmtr.Bld_bfr_many(bfr, cell_fmtr.Init(row_key, row_itm), btn_fmtr.Init(row_key, btns));
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
@@ -39,12 +40,12 @@ public class Dbui_cells_fmtr implements Bry_fmtr_arg {
|
||||
, " </div>"
|
||||
), "vals", "btns");
|
||||
}
|
||||
class Dbui_cell_fmtr implements Bry_fmtr_arg {
|
||||
class Dbui_cell_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
private byte[] row_key; private Dbui_row_itm row_itm;
|
||||
private Dbui_val_fmtr val_fmtr;
|
||||
public void Ctor(Dbui_val_fmtr val_fmtr) {this.val_fmtr = val_fmtr;}
|
||||
public Dbui_cell_fmtr Init(byte[] row_key, Dbui_row_itm row_itm) {this.row_key = row_key; this.row_itm = row_itm; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Dbui_col_itm[] cols = row_itm.Tbl().Cols();
|
||||
Dbui_val_itm[] vals = row_itm.Vals(); int len = vals.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@@ -57,12 +58,12 @@ class Dbui_cell_fmtr implements Bry_fmtr_arg {
|
||||
, " <div class='xo_cell'>~{html}</div>"
|
||||
), "row_key", "val_idx", "html");
|
||||
}
|
||||
class Dbui_btn_fmtr implements Bry_fmtr_arg {
|
||||
class Dbui_btn_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
private byte[] row_key; private Dbui_btn_itm[] btns;
|
||||
public Dbui_btn_fmtr Init(byte[] row_key, Dbui_btn_itm[] btns) {
|
||||
this.row_key = row_key; this.btns = btns; return this;
|
||||
}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int len = btns.length;
|
||||
Io_url img_dir = gplx.xowa.htmls.heads.Xoh_head_itm__dbui.Img_dir();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
||||
@@ -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.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public class Dbui_tbl_fmtr {
|
||||
private final Dbui_head_cell_fmtr head_cell_fmtr = new Dbui_head_cell_fmtr();
|
||||
@@ -32,10 +33,10 @@ public class Dbui_tbl_fmtr {
|
||||
, "</div>"
|
||||
), "tbl_key", "width", "origin", "delete_confirm_msg", "head_cells", "data_rows");
|
||||
}
|
||||
class Dbui_head_cell_fmtr implements Bry_fmtr_arg {
|
||||
class Dbui_head_cell_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
private Dbui_tbl_itm tbl;
|
||||
public Dbui_head_cell_fmtr Init(Dbui_tbl_itm tbl) {this.tbl = tbl; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Dbui_col_itm[] cols = tbl.Cols(); int len = cols.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_col_itm col = cols[i];
|
||||
@@ -48,13 +49,13 @@ class Dbui_head_cell_fmtr implements Bry_fmtr_arg {
|
||||
, " <div class='xo_head xo_resizable_col' style='width:~{width}px;'>~{display}</div>"
|
||||
), "width", "display");
|
||||
}
|
||||
class Dbui_row_fmtr implements Bry_fmtr_arg {
|
||||
class Dbui_row_fmtr extends gplx.core.brys.Bfr_arg_base {
|
||||
private final Dbui_cells_fmtr cells_fmtr = new Dbui_cells_fmtr();
|
||||
private final Dbui_val_fmtr val_fmtr = Dbui_val_fmtr_.new_view();
|
||||
private final Bry_bfr row_key_bfr = Bry_bfr.new_(255);
|
||||
private Dbui_tbl_itm tbl; private Dbui_row_itm[] rows;
|
||||
public Dbui_row_fmtr Init(Dbui_tbl_itm tbl, Dbui_row_itm[] rows) {this.tbl = tbl; this.rows = rows; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
byte[] tbl_key = tbl.Key();
|
||||
int len = rows.length;
|
||||
cells_fmtr.Ctor(val_fmtr, tbl.View_btns());
|
||||
|
||||
@@ -16,21 +16,22 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.bridges.*; import gplx.xowa.htmls.bridges.dbuis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
public interface Dbui_val_fmtr {
|
||||
Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val);
|
||||
}
|
||||
class Dbui_val_fmtr__view implements Bry_fmtr_arg, Dbui_val_fmtr {
|
||||
class Dbui_val_fmtr__view extends gplx.core.brys.Bfr_arg_base implements Dbui_val_fmtr {
|
||||
private Dbui_val_itm val;
|
||||
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.val = val; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
bfr.Add(val.Html());
|
||||
}
|
||||
}
|
||||
class Dbui_val_fmtr__edit implements Bry_fmtr_arg, Dbui_val_fmtr {
|
||||
class Dbui_val_fmtr__edit extends gplx.core.brys.Bfr_arg_base implements Dbui_val_fmtr {
|
||||
private Dbui_col_itm col; private byte[] row_id; private Dbui_val_itm val;
|
||||
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.col = col; this.row_id = row_id; this.val = val; return this;}
|
||||
public void Fmt__do(Bry_bfr bfr) {
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
switch (col.Type()) {
|
||||
case Dbui_col_itm.Type_id_str: input_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
|
||||
case Dbui_col_itm.Type_id_text: textarea_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
|
||||
|
||||
@@ -16,15 +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.core.ios.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.data.*;
|
||||
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.hzip_mgr = new Xow_hzip_mgr(wiki);
|
||||
this.save_mgr = new Xow_hdump_mgr__save(wiki, hzip_mgr, tmp_hpg, tmp_bfr);
|
||||
this.load_mgr = new Xow_hdump_mgr__load(wiki, hzip_mgr, tmp_hpg, tmp_bfr);
|
||||
this.save_mgr = new Xow_hdump_mgr__save(wiki, hzip_mgr, zip_mgr, tmp_hpg, tmp_bfr);
|
||||
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;
|
||||
@@ -33,12 +37,10 @@ public class Xow_hdump_mgr {
|
||||
default_zip_tid = props.Zip_tid_html();
|
||||
default_hzip_enable = props.Hzip_enabled();
|
||||
}
|
||||
Init_by_db(wiki, default_zip_tid, default_hzip_enable);
|
||||
Init_by_db(default_zip_tid, default_hzip_enable);
|
||||
}
|
||||
public void Init_by_db(Xow_wiki wiki, byte default_zip_tid, boolean default_hzip_enable) {
|
||||
hzip_mgr.Init_by_atrs(default_zip_tid, default_hzip_enable);
|
||||
public void Init_by_db(byte default_zip_tid, boolean default_hzip_enable) {
|
||||
int dflt_hzip_tid = default_hzip_enable ? Xoh_hzip_dict_.Hzip__none : Xoh_hzip_dict_.Hzip__v1;
|
||||
save_mgr.Init_by_db(default_zip_tid, dflt_hzip_tid);
|
||||
}
|
||||
public Xow_hzip_mgr Hzip_mgr() {return hzip_mgr;} private Xow_hzip_mgr hzip_mgr;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
public class Xow_hdump_mgr__load {
|
||||
private final Xow_wiki wiki; private final Xow_hzip_mgr hzip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
public Xow_hdump_mgr__load(Xow_wiki wiki, Xow_hzip_mgr hzip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.tmp_hpg = tmp_hpg;
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
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(), Xoa_app_.Utl__encoder_mgr().Fsys(), wiki.Domain_bry());
|
||||
}
|
||||
public Xoh_make_mgr Make_mgr() {return make_mgr;} private final Xoh_make_mgr make_mgr;
|
||||
@@ -32,33 +33,26 @@ public class Xow_hdump_mgr__load {
|
||||
wpg.Hdump_data().Body_(tmp_hpg.Body());
|
||||
// wpg.Root_(new Xop_root_tkn());
|
||||
Fill_page(wpg, tmp_hpg);
|
||||
// foreach (gplx.xowa.htmls.core.makes.imgs.Xohd_img_itm__base itm in hpg.Img_itms())
|
||||
// wpg.Hdump_data().Imgs_add(itm);
|
||||
}
|
||||
public boolean Load(Xoh_page hpg, Xoa_ttl ttl) {
|
||||
synchronized (tmp_dbpg) {
|
||||
if (!Load__dbpg(tmp_dbpg.Clear(), hpg, ttl)) return Load__fail(hpg); // nothing in "page" table
|
||||
if (!Load__dbpg(wiki, tmp_dbpg.Clear(), hpg, ttl)) return Load__fail(hpg); // nothing in "page" table
|
||||
Xowd_db_file html_db = wiki.Data__core_mgr().Dbs__get_at(tmp_dbpg.Html_db_id());
|
||||
hpg.Init(hpg.Wiki(), hpg.Url(), ttl, tmp_dbpg.Id());
|
||||
if (!html_db.Tbl__html_page().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html_page" table
|
||||
byte[] src = hzip_mgr.Parse(hpg.Url_bry_safe(), hpg.Body_flag(), hpg.Body());
|
||||
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html_page" table
|
||||
byte[] src = Parse(hpg, hpg.Body_zip_tid(), hpg.Body_hzip_tid(), hpg.Body());
|
||||
hpg.Body_(make_mgr.Parse(src, hpg, hpg.Wiki()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
private boolean Load__fail(Xoh_page hpg) {hpg.Exists_n_(); return false;}
|
||||
private boolean Load__dbpg(Xowd_page_itm dbpg, Xoh_page hpg, Xoa_ttl ttl) {
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_ttl(dbpg, ttl.Ns(), ttl.Page_db());
|
||||
if (dbpg.Redirect_id() != -1) Load__dbpg__redirects(dbpg);
|
||||
return dbpg.Html_db_id() != -1;
|
||||
}
|
||||
private void Load__dbpg__redirects(Xowd_page_itm dbpg) {
|
||||
int redirect_count = 0;
|
||||
while (redirect_count < 5) {
|
||||
int redirect_id = dbpg.Redirect_id();
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_id(dbpg, redirect_id);
|
||||
if (redirect_id == -1) break;
|
||||
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();
|
||||
}
|
||||
return src;
|
||||
}
|
||||
private void Fill_page(Xoae_page wpg, Xoh_page hpg) {
|
||||
Xopg_html_data html_data = wpg.Html_data();
|
||||
@@ -72,4 +66,18 @@ public class Xow_hdump_mgr__load {
|
||||
wpg_head.Itm__gallery().Enabled_ (hpg_head.Gallery_packed_exists());
|
||||
wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists());
|
||||
}
|
||||
private static boolean Load__fail(Xoh_page hpg) {hpg.Exists_n_(); return false;}
|
||||
private static boolean Load__dbpg(Xow_wiki wiki, Xowd_page_itm dbpg, Xoh_page hpg, Xoa_ttl ttl) {
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_ttl(dbpg, ttl.Ns(), ttl.Page_db());
|
||||
if (dbpg.Redirect_id() != -1) Load__dbpg__redirects(wiki, dbpg);
|
||||
return dbpg.Html_db_id() != -1;
|
||||
}
|
||||
private static void Load__dbpg__redirects(Xow_wiki wiki, Xowd_page_itm dbpg) {
|
||||
int redirect_count = 0;
|
||||
while (redirect_count < 5) {
|
||||
int redirect_id = dbpg.Redirect_id();
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_id(dbpg, redirect_id);
|
||||
if (redirect_id == -1) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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(wiki, gplx.core.ios.Io_stream_.Tid_raw, false);
|
||||
hdump_mgr.Init_by_db(gplx.core.ios.Io_stream_.Tid_raw, false);
|
||||
}
|
||||
fxt.Reset();
|
||||
page.Revision_data().Id_(0);
|
||||
@@ -127,7 +127,7 @@ class Xodb_hdump_mgr__base_fxt {
|
||||
@gplx.Virtual public void Exec_write(String raw) {
|
||||
Xop_root_tkn root = fxt.Exec_parse_page_all_as_root(Bry_.new_u8(raw));
|
||||
page.Root_(root);
|
||||
hdump_mgr.Save_mgr().Make_body_as_hswap(page);
|
||||
hdump_mgr.Save_mgr().Bld_hdump(page);
|
||||
}
|
||||
public Xohd_img_itm__base Make_xfer(String lnki_ttl, int html_uid, int html_w, int html_h, boolean file_is_orig, int file_ext_id) {
|
||||
return new Xohd_img_itm__img().Data_init_base
|
||||
|
||||
@@ -16,49 +16,52 @@ 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.core.hzips.stats.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; 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 Xow_hzip_mgr hzip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private boolean html_db_is_new = false;
|
||||
public Xow_hdump_mgr__save(Xow_wiki wiki, Xow_hzip_mgr hzip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr;
|
||||
this.tmp_hpg = tmp_hpg; this.tmp_bfr = tmp_bfr;
|
||||
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 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 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 int Save(Xoae_page page) {
|
||||
synchronized (tmp_hpg) {
|
||||
Make_body_as_hswap(page);
|
||||
Bld_hdump(page);
|
||||
tmp_hpg.Ctor_by_page(tmp_bfr, page);
|
||||
this.html_db_is_new = false;
|
||||
Xowd_db_file html_db = Get_html_db(page);
|
||||
return Save(tmp_hpg, html_db, html_db_is_new);
|
||||
Xowd_db_file html_db = Get_html_db(wiki, page, html_db_is_new.Val_n_());
|
||||
return Save(tmp_hpg, html_db, html_db_is_new.Val());
|
||||
}
|
||||
}
|
||||
public int Save(Xoh_page hpg, Xowd_db_file html_db, boolean insert) {
|
||||
byte db_body_flag = hzip_mgr.Body_flag();
|
||||
byte[] db_body = hzip_mgr.Write(hpg.Url_bry_safe(), db_body_flag, hpg.Body());
|
||||
if (insert)
|
||||
html_db.Tbl__html_page().Insert(hpg, db_body_flag, db_body);
|
||||
else
|
||||
html_db.Tbl__html_page().Update(hpg, db_body_flag, db_body);
|
||||
byte[] db_body = Write(tmp_bfr, wiki, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, dflt_hzip_tid, hpg.Body());
|
||||
if (insert) html_db.Tbl__html().Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_db.Tbl__html().Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
return db_body.length;
|
||||
}
|
||||
public void Make_body_as_hswap(Xoae_page page) {
|
||||
public void Bld_hdump(Xoae_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will keep incrementing upwards
|
||||
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 Xowd_db_file Get_html_db(Xoae_page page) {
|
||||
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_rls();
|
||||
}
|
||||
if (zip_tid > gplx.core.ios.Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Zip((byte)zip_tid, src);
|
||||
return src;
|
||||
}
|
||||
private static Xowd_db_file Get_html_db(Xow_wiki wiki, Xoae_page page, Bool_obj_ref html_db_is_new) {
|
||||
Xowd_db_file rv = Xowd_db_file.Null;
|
||||
Xowd_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int html_db_id = page.Revision_data().Html_db_id();
|
||||
if (html_db_id == -1) {
|
||||
html_db_is_new = true;
|
||||
html_db_is_new.Val_y_();
|
||||
rv = core_data_mgr.Db__html();
|
||||
if (rv == null) {
|
||||
rv = core_data_mgr.Dbs__make_by_tid(Xowd_db_file_.Tid_html_data);
|
||||
rv.Tbl__html_redlink().Create_tbl();
|
||||
}
|
||||
if (rv == null) rv = core_data_mgr.Dbs__make_by_tid(Xowd_db_file_.Tid_html_data);
|
||||
html_db_id = rv.Id();
|
||||
page.Revision_data().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Revision_data().Id(), html_db_id);
|
||||
|
||||
@@ -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.*; 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.stats.*;
|
||||
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.*;
|
||||
public class Xob_hdump_mgr {
|
||||
private final Xowe_wiki wiki; private final Xow_hdump_mgr hdump_mgr;
|
||||
@@ -25,8 +25,8 @@ public class Xob_hdump_mgr {
|
||||
private final Hzip_stat_tbl stats_tbl; private final 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);
|
||||
public Xob_hdump_mgr(Xowe_wiki wiki, Db_conn make_conn, long hdump_db_max, byte zip_tid, boolean hzip_enabled) {
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Stat_itm();
|
||||
hdump_mgr.Hzip_mgr().Init_by_atrs(zip_tid, hzip_enabled);
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Hctx().Bicode__stat();
|
||||
hdump_mgr.Init_by_db(zip_tid, hzip_enabled);
|
||||
this.stats_tbl = new Hzip_stat_tbl(make_conn);
|
||||
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, hdump_db_max);
|
||||
@@ -35,9 +35,7 @@ public class Xob_hdump_mgr {
|
||||
public void Insert(Xoae_page page) {
|
||||
Make_page_body(page);
|
||||
Xowd_db_file html_db = ns_to_db_mgr.Get_by_ns(page.Ttl().Ns().Bldr_data(), prv_row_len); // get html_db
|
||||
synchronized (tmp_hpg) {
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, page), html_db, true); // save to db
|
||||
}
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, page), html_db, true); // save to db
|
||||
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();}
|
||||
|
||||
@@ -23,7 +23,7 @@ class Xob_ns_to_db_wkr__html implements Xob_ns_to_db_wkr {
|
||||
public Xob_ns_to_db_wkr__html(Xowd_db_file page_db) {this.page_db = page_db;}
|
||||
public byte Db_tid() {return Xowd_db_file_.Tid_html_data;}
|
||||
public void Tbl_init(Xowd_db_file db) {
|
||||
Xoh_page_tbl tbl = db.Tbl__html_page();
|
||||
Xoh_page_tbl tbl = db.Tbl__html();
|
||||
tbl.Create_tbl();
|
||||
tbl.Insert_bgn();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
Db_attach_rdr attach_rdr = new Db_attach_rdr(link_dump_db.Conn(), "page_db", core_db.Url());
|
||||
attach_rdr.Attach();
|
||||
Xowd_page_tbl page_tbl = core_db.Tbl__page();
|
||||
int cur_html_db_id = -1, cur_page_id = -1; Xoh_redlink_tbl redlink_tbl = null;
|
||||
int cur_html_db_id = -1, cur_page_id = -1;
|
||||
Xoh_redlink_tbl redlink_tbl = new Xoh_redlink_tbl(page_tbl.Conn());
|
||||
Db_rdr rdr = attach_rdr.Exec_as_rdr(Sql_select);
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
@@ -41,7 +42,7 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
int html_db_id = rdr.Read_int(page_tbl.Fld_html_db_id());
|
||||
if (html_db_id != cur_html_db_id) {
|
||||
if (redlink_tbl != null) redlink_tbl.Conn().Txn_end();
|
||||
redlink_tbl = wiki.Data__core_mgr().Dbs__get_at(html_db_id).Tbl__html_redlink();
|
||||
// redlink_tbl = wiki.Data__core_mgr().Dbs__get_at(html_db_id).Tbl__html_redlink();
|
||||
redlink_tbl.Conn().Txn_bgn("bldr__redlink");
|
||||
cur_html_db_id = html_db_id;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.dbs.*; import gplx.core.brys.*;
|
||||
public class Xoh_page_tbl implements RlsAble {
|
||||
private final String tbl_name = "html_page"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
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;
|
||||
private final Int_flag_bldr body_flag_bldr = new Int_flag_bldr().Pow_ary_bld_(3, 2); // 8 different zip types; 4 different hzip types
|
||||
public Xoh_page_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_page_id = flds.Add_int_pkey("page_id");
|
||||
@@ -34,18 +35,20 @@ public class Xoh_page_tbl implements RlsAble {
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("html_page__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_bgn() {conn.Txn_bgn("html__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(Xoh_page hpg, byte db_body_flag, byte[] body) {Insert(hpg.Page_id(), hpg.Head_mgr().Flag(), db_body_flag, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
public void Insert(int page_id, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
public void Insert(Xoh_page hpg, int zip_tid, int hzip_tid, byte[] body) {Insert(hpg.Page_id(), hpg.Head_mgr().Flag(), zip_tid, hzip_tid, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
public void Insert(int page_id, int head_flag, int zip_tid, int hzip_tid, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
int body_flag = body_flag_bldr.Set(0, zip_tid).Set(1, hzip_tid).Encode();
|
||||
stmt_insert.Clear().Val_int(fld_page_id, page_id);
|
||||
Fill_stmt(stmt_insert, head_flag, body_flag, display_ttl, content_sub, sidebar_div, body);
|
||||
stmt_insert.Exec_insert();
|
||||
}
|
||||
public void Update(Xoh_page hpg, byte db_body_flag, byte[] body) {Update(hpg.Page_id(), hpg.Head_mgr().Flag(), db_body_flag, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
public void Update(int page_id, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
public void Update(Xoh_page hpg, int zip_tid, int hzip_tid, byte[] body) {Update(hpg.Page_id(), hpg.Head_mgr().Flag(), zip_tid, hzip_tid, hpg.Display_ttl(), hpg.Content_sub(), hpg.Sidebar_div(), body);}
|
||||
public void Update(int page_id, int head_flag, int zip_tid, int hzip_tid, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_page_id);
|
||||
int body_flag = body_flag_bldr.Set(0, zip_tid).Set(1, hzip_tid).Encode();
|
||||
stmt_update.Clear();
|
||||
Fill_stmt(stmt_update, head_flag, body_flag, display_ttl, content_sub, sidebar_div, body);
|
||||
stmt_update.Crt_int(fld_page_id, page_id).Exec_update();
|
||||
@@ -59,7 +62,9 @@ public class Xoh_page_tbl implements RlsAble {
|
||||
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, hpg.Page_id()).Exec_select__rls_manual();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
hpg.Ctor_by_db(rdr.Read_int(fld_head_flag), rdr.Read_bry_by_str(fld_display_ttl), rdr.Read_bry_by_str(fld_content_sub), rdr.Read_bry_by_str(fld_sidebar_div), (byte)rdr.Read_int(fld_body_flag), rdr.Read_bry(fld_body));
|
||||
int body_flag = rdr.Read_int(fld_body_flag);
|
||||
body_flag_bldr.Decode(body_flag);
|
||||
hpg.Ctor_by_db(rdr.Read_int(fld_head_flag), rdr.Read_bry_by_str(fld_display_ttl), rdr.Read_bry_by_str(fld_content_sub), rdr.Read_bry_by_str(fld_sidebar_div), body_flag_bldr.Get_as_int(0), body_flag_bldr.Get_as_int(1), rdr.Read_bry(fld_body));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -15,7 +15,7 @@ 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.stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
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 {
|
||||
public void Clear() {
|
||||
a_rhs = lnki_text_n = lnki_text_y = lnke_txt = lnke_brk_text_n = lnke_brk_text_y = 0;
|
||||
@@ -15,7 +15,7 @@ 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.stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
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 {
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_decode_ctx {
|
||||
private byte[] dir__file;
|
||||
public Xof_url_bldr Url_bldr() {return url_bldr;} private Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
public byte[] Dir__root() {return dir__root;} private byte[] dir__root;
|
||||
public byte[] Dir__file__comm() {return dir__file__comm;} private byte[] dir__file__comm;
|
||||
public byte[] Dir__file__wiki() {return dir__file__wiki;} private byte[] dir__file__wiki;
|
||||
public Xow_ttl_parser Ttl_parser() {return ttl_parser;} private Xow_ttl_parser ttl_parser;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
Xoa_fsys_mgr fsys_mgr = app.Fsys_mgr();
|
||||
this.dir__root = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.dir__file = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.dir__file__comm = Bry_.Add(dir__file, Xow_domain_itm_.Bry__commons, Byte_ascii.Slash_bry);
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki) {
|
||||
if (dir__root == null) Init_by_app(wiki.App()); // LAZY INIT
|
||||
this.ttl_parser = wiki;
|
||||
this.dir__file__wiki = Bry_.Add(dir__file, wiki.Domain_bry(), Byte_ascii.Slash_bry);
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.htmls.core.wkrs.spaces.*; 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.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
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
|
||||
@@ -29,6 +27,7 @@ public class Xoh_hzip_dict_ {
|
||||
, Tid__lnke = 2 + Base85_ascii
|
||||
, Tid__lnki = 3 + Base85_ascii
|
||||
, Tid__img = 4 + Base85_ascii
|
||||
, Tid__thm = 5 + Base85_ascii
|
||||
, Tid__escape = 84 + Base85_ascii
|
||||
;
|
||||
public static final byte[]
|
||||
@@ -38,6 +37,7 @@ public class Xoh_hzip_dict_ {
|
||||
, 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)
|
||||
;
|
||||
public static final String
|
||||
Key__escape = "escape"
|
||||
@@ -46,22 +46,7 @@ public class Xoh_hzip_dict_ {
|
||||
, Key__lnke = "lnke"
|
||||
, Key__lnki = "lnki"
|
||||
, Key__img = "img"
|
||||
, Key__thm = "thm"
|
||||
;
|
||||
public static Xoh_hzip_wkr To_wkr(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid__escape: return Wkr__escape;
|
||||
case Tid__space: return Wkr__space;
|
||||
case Tid__hdr: return Wkr__hdr;
|
||||
case Tid__lnke: return Wkr__lnke;
|
||||
case Tid__lnki: return Wkr__lnki;
|
||||
case Tid__img: return Wkr__img;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static final Xoh_escape_hzip Wkr__escape = new Xoh_escape_hzip();
|
||||
public static final Xoh_space_hzip Wkr__space = new Xoh_space_hzip();
|
||||
public static final Xoh_hdr_hzip Wkr__hdr = new Xoh_hdr_hzip();
|
||||
public static final Xoh_lnke_hzip Wkr__lnke = new Xoh_lnke_hzip();
|
||||
public static final Xoh_lnki_hzip Wkr__lnki = new Xoh_lnki_hzip();
|
||||
public static final Xoh_img_hzip Wkr__img = new Xoh_img_hzip();
|
||||
public static final int Hzip__none = 0, Hzip__v1 = 1;
|
||||
}
|
||||
|
||||
84
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_fxt.java
Normal file
84
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_hzip_fxt.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_hzip_fxt {
|
||||
private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final Xoh_hzip_mgr hzip_mgr;
|
||||
private final Xoh_page hpg = new Xoh_page();
|
||||
public Xoh_hzip_fxt() {
|
||||
Xowe_wiki wiki = parser_fxt.Wiki();
|
||||
Xoa_app_fxt.repo2_(parser_fxt.App(), wiki); // needed else will be old "mem/wiki/repo/trg/thumb/" instead of standard "mem/file/en.wikipedia.org/thumb/"
|
||||
wiki.Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
this.hzip_mgr = parser_fxt.Wiki().Html__hdump_mgr().Hzip_mgr();
|
||||
hpg.Init(wiki, Xoa_url.blank(), parser_fxt.Wiki().Ttl_parse(Xoa_page_.Main_page_bry), 1);
|
||||
}
|
||||
public void Test__bicode(String hzip, String html) {Test__bicode(hzip, html, html);}
|
||||
public void Test__bicode(String hzip, String html_enc, String html_dec) {
|
||||
hzip = Html_utl.Replace_apos(Xoh_hzip_fxt.Escape(hzip));
|
||||
html_enc = Html_utl.Replace_apos(html_enc);
|
||||
html_dec = Html_utl.Replace_apos(html_dec);
|
||||
Test__encode__raw(hzip, html_enc);
|
||||
Test__decode__raw(hzip, html_dec);
|
||||
}
|
||||
public void Test__encode(String hzip, String html) {
|
||||
hzip = Html_utl.Replace_apos(Xoh_hzip_fxt.Escape(hzip)); html = Html_utl.Replace_apos(html);
|
||||
Test__encode__raw(hzip, html);
|
||||
}
|
||||
public void Test__decode(String hzip, String html) {
|
||||
hzip = Html_utl.Replace_apos(Xoh_hzip_fxt.Escape(hzip)); html = Html_utl.Replace_apos(html);
|
||||
Test__decode__raw(hzip, html);
|
||||
}
|
||||
public void Test__encode__fail(String expd, String html) {
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(html));
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
private void Test__encode__raw(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(html));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Tfds.Eq_str_lines(hzip, bfr.To_str_and_clear());
|
||||
}
|
||||
private void Test__decode__raw(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hzip_mgr.Decode(bfr, parser_fxt.Wiki(), hpg, Bry_.new_u8(hzip));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Tfds.Eq_str_lines(html, bfr.To_str_and_clear());
|
||||
}
|
||||
public void Exec_write_to_fsys(Io_url dir, String fil) {
|
||||
try {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), hpg, Io_mgr.Instance.LoadFilBry(dir.GenSubFil(fil)));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
byte[] actl = bfr.To_bry_and_clear();
|
||||
Io_mgr.Instance.SaveFilBry(dir.GenSubFil(fil).GenNewExt(".hzip.html"), actl);
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_hzip.Md5_depth = 4;
|
||||
hzip_mgr.Decode(bfr, parser_fxt.Wiki(), hpg, actl);
|
||||
gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_hzip.Md5_depth = 2;
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Io_mgr.Instance.SaveFilBry(dir.GenSubFil(fil).GenNewExt(".hzip.decode.html"), bfr.To_bry_and_clear());
|
||||
} catch (Exception e) {
|
||||
Tfds.Write(e);
|
||||
}
|
||||
}
|
||||
public static String Escape(String v) {return String_.Replace(v, "~", "");}
|
||||
}
|
||||
@@ -17,41 +17,43 @@ 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.xowa.htmls.core.hzips.stats.*;
|
||||
import gplx.xowa.htmls.core.wkrs.*; import gplx.langs.htmls.parsers.*;
|
||||
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());
|
||||
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape);
|
||||
private final Xoh_hdoc_wkr__base hdoc_parser = new Xoh_hdoc_wkr__base(new Xoh_hdoc_wkr__hzip());
|
||||
private final Xoh_decode_ctx decode_ctx = new Xoh_decode_ctx();
|
||||
public void Init_by_app(Xoa_app app) {decode_ctx.Init_by_app(app);}
|
||||
public void Encode(Bry_bfr bfr, Xow_wiki wiki, byte[] page_url, byte[] src, Hzip_stat_itm stat_itm) {
|
||||
hdoc_parser.Parse(bfr, wiki, null, page_url, src);
|
||||
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) {
|
||||
hctx.Init_by_page(wiki, hpg.Url_bry_safe());
|
||||
hdoc_parser.Parse(bfr, hpg, hctx, src);
|
||||
}
|
||||
public byte[] Decode(Bry_bfr bfr, Xow_wiki wiki, byte[] page_url, byte[] src) {
|
||||
bfr.Clear();
|
||||
((gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_hzip)Xoh_hzip_dict_.To_wkr(Xoh_hzip_dict_.Tid__lnki)).Ttl_parser_(wiki);
|
||||
int pos = 0, add_bgn = -1; int src_len = src.length;
|
||||
rdr.Ctor_by_page(page_url, src, src_len);
|
||||
decode_ctx.Init_by_page(wiki);
|
||||
public void Decode(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src) {
|
||||
byte[] page_url = hpg.Url_bry_safe();
|
||||
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 (add_bgn != -1) {bfr.Add_mid(src, add_bgn, pos); add_bgn = -1;}
|
||||
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 {
|
||||
Xoh_hzip_wkr wkr = Xoh_hzip_dict_.To_wkr(src[pos + 1]);
|
||||
rdr.Init_by_hook(wkr.Key(), pos, pos + 2);
|
||||
wkr.Decode(bfr, decode_ctx, rdr, src, pos);
|
||||
wkr.Decode(bfr, Bool_.Y, hctx, hpg, rdr, src, pos);
|
||||
pos = rdr.Pos();
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", Err_.Message_gplx_log(e));
|
||||
pos += 2;
|
||||
wkr.Pool__rls();
|
||||
Err err = Err_.cast_or_make(e);
|
||||
if (!err.Logged()) Gfo_usr_dlg_.Instance.Warn_many("", "", Err_.Message_gplx_log(e), "page_url", page_url, "mid", Bry_.Mid_by_len_safe(src, pos, 255));
|
||||
pos += 2; // 2: skip escape and hook
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (add_bgn == -1) add_bgn = pos;
|
||||
if (txt_bgn == -1) txt_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
if (add_bgn != -1) bfr.Add_mid(src, add_bgn, src_len);
|
||||
return bfr.To_bry_and_clear();
|
||||
if (txt_bgn != -1) bfr.Add_mid(src, txt_bgn, src_len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ 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.*;
|
||||
public interface Xoh_hzip_wkr {
|
||||
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, Xoh_decode_ctx ctx, Bry_rdr parser, byte[] src, int hook_bgn);
|
||||
int Decode(Bry_bfr bfr, boolean write_to_bfr, Xoh_hdoc_ctx ctx, Xoh_page hpg, Bry_rdr parser, byte[] src, int hook_bgn);
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.ios.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xow_hzip_mgr {
|
||||
private final Xow_wiki wiki; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private boolean default_hzip_enabled; private byte default_zip_tid, body_flag;
|
||||
public Xow_hzip_mgr(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.zip_mgr = new Io_stream_zip_mgr();
|
||||
}
|
||||
public Xoh_hzip_mgr Hzip_mgr() {return hzip_mgr;} private final Xoh_hzip_mgr hzip_mgr = new Xoh_hzip_mgr();
|
||||
public Hzip_stat_itm Stat_itm() {return stat_itm;} private final Hzip_stat_itm stat_itm = new Hzip_stat_itm();
|
||||
public byte Body_flag() {return body_flag;}
|
||||
public void Init_by_db(Xow_wiki wiki) {
|
||||
this.Init_by_atrs(wiki.Data__core_mgr().Props().Zip_tid_html(), wiki.Data__core_mgr().Props().Hzip_enabled());
|
||||
}
|
||||
public void Init_by_atrs(byte default_zip_tid, boolean default_hzip_enabled) {
|
||||
this.default_zip_tid = default_zip_tid;
|
||||
this.default_hzip_enabled = default_hzip_enabled;
|
||||
this.body_flag = default_hzip_enabled ? (byte)(default_zip_tid + Zip_tid_cutoff) : default_zip_tid;
|
||||
}
|
||||
public byte[] Write(byte[] page_url, byte storage_flag, byte[] src) {
|
||||
byte zip_tid = default_zip_tid;
|
||||
boolean hzip_enabled = default_hzip_enabled;
|
||||
if (storage_flag != Byte_.Max_value_127) {
|
||||
zip_tid = storage_flag;
|
||||
if (storage_flag > Zip_tid_cutoff) {
|
||||
hzip_enabled = Bool_.Y;
|
||||
zip_tid -= Zip_tid_cutoff;
|
||||
}
|
||||
}
|
||||
if (hzip_enabled) {
|
||||
hzip_mgr.Encode(tmp_bfr, wiki, page_url, src, stat_itm);
|
||||
src = tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
if (zip_tid != Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Zip(zip_tid, src);
|
||||
return src;
|
||||
}
|
||||
public byte[] Parse(byte[] page_url, byte storage_flag, byte[] src) {
|
||||
byte zip_tid = default_zip_tid;
|
||||
boolean hzip_enabled = default_hzip_enabled;
|
||||
if (storage_flag != Byte_.Max_value_127) {
|
||||
zip_tid = storage_flag;
|
||||
if (storage_flag > Zip_tid_cutoff) {
|
||||
hzip_enabled = Bool_.Y;
|
||||
zip_tid -= Zip_tid_cutoff;
|
||||
}
|
||||
}
|
||||
if (zip_tid != Io_stream_.Tid_raw)
|
||||
src = zip_mgr.Unzip(default_zip_tid, src);
|
||||
if (hzip_enabled)
|
||||
src = hzip_mgr.Decode(tmp_bfr, wiki, page_url, src);
|
||||
return src;
|
||||
}
|
||||
private static final byte Zip_tid_cutoff = 7;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips.tests; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_hzip_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private final Xoh_hzip_mgr hzip_mgr;
|
||||
private final Hzip_stat_itm stat_itm = new Hzip_stat_itm();
|
||||
public Xoh_hzip_fxt() {
|
||||
Xoa_app_fxt.repo2_(parser_fxt.App(), parser_fxt.Wiki()); // needed else will be old "mem/wiki/repo/trg/thumb/" instead of standard "mem/file/en.wikipedia.org/thumb/"
|
||||
parser_fxt.Wiki().Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
this.hzip_mgr = parser_fxt.Wiki().Html__hdump_mgr().Hzip_mgr().Hzip_mgr();
|
||||
}
|
||||
public Xop_fxt Parser_fxt() {return parser_fxt;} private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
public Xoh_hzip_mgr Hzip_mgr() {return hzip_mgr;}
|
||||
public void Test__bicode(String hzip, String html) {
|
||||
hzip = String_.Replace(Xoh_hzip_fxt.Escape(hzip), "'", "\""); html = String_.Replace(html, "'", "\"");
|
||||
Test__encode__raw(hzip, html);
|
||||
Test__decode__raw(hzip, html);
|
||||
}
|
||||
public void Test__encode(String hzip, String html) {
|
||||
hzip = String_.Replace(Xoh_hzip_fxt.Escape(hzip), "'", "\""); html = String_.Replace(html, "'", "\"");
|
||||
Test__encode__raw(hzip, html);
|
||||
}
|
||||
public void Test__decode(String hzip, String html) {
|
||||
hzip = String_.Replace(Xoh_hzip_fxt.Escape(hzip), "'", "\""); html = String_.Replace(html, "'", "\"");
|
||||
Test__decode__raw(hzip, html);
|
||||
}
|
||||
public void Test__encode__fail(String expd, String html) {
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), Bry_.Empty, Bry_.new_u8(html), stat_itm);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
private void Test__encode__raw(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
hzip_mgr.Encode(bfr, parser_fxt.Wiki(), Bry_.Empty, Bry_.new_u8(html), stat_itm);
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Tfds.Eq_str_lines(hzip, bfr.To_str_and_clear());
|
||||
}
|
||||
private void Test__decode__raw(String hzip, String html) {
|
||||
Gfo_usr_dlg_.Test__show__init();
|
||||
byte[] actl = hzip_mgr.Decode(bfr, parser_fxt.Wiki(), Bry_.Empty, Bry_.new_u8(hzip));
|
||||
Gfo_usr_dlg_.Test__show__term();
|
||||
Tfds.Eq_str_lines(html, String_.new_u8(actl));
|
||||
}
|
||||
public static String Escape(String v) {return String_.Replace(v, "~", "");}
|
||||
}
|
||||
@@ -16,17 +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.makes; 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.langs.htmls.encoders.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.brys.fmtrs.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_make_mgr {
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(255), tmp_bfr = Bry_bfr.reset_(255); private final Bry_rdr_old bry_rdr = new Bry_rdr_old(); private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
private Xoh_cfg_file cfg_file; private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2(); private Xoh_file_html_fmtr__base html_fmtr;
|
||||
private final byte[] root_dir, file_dir; private byte[] file_dir_comm, file_dir_wiki, hiero_img_dir; private final byte[] wiki_domain;
|
||||
private final Bry_rdr parser = new Bry_rdr();
|
||||
private final Xoh_hdoc_wkr__base hdoc_parser = new Xoh_hdoc_wkr__base(new Xoh_hdoc_wkr__make());
|
||||
private final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
|
||||
private final Xoh_hdoc_parser make_parser = new Xoh_hdoc_parser(new Xoh_hdoc_wkr__make());
|
||||
public Xoh_make_mgr(Gfo_usr_dlg usr_dlg, Xoa_fsys_mgr fsys_mgr, Url_encoder fsys_encoder, byte[] wiki_domain) {
|
||||
this.usr_dlg = usr_dlg;
|
||||
this.root_dir = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
@@ -37,8 +39,9 @@ public class Xoh_make_mgr {
|
||||
this.wiki_domain = wiki_domain;
|
||||
}
|
||||
public byte[] Parse(byte[] src, Xoh_page hpg, Xow_wiki wiki) {
|
||||
hctx.Init_by_page(wiki, hpg.Url_bry_safe());
|
||||
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
|
||||
hdoc_parser.Parse(bfr, wiki, hpg, hpg.Url_bry_safe(), src);
|
||||
make_parser.Parse(bfr, hpg, hctx, src);
|
||||
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
@@ -50,7 +53,7 @@ public class Xoh_make_mgr {
|
||||
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
|
||||
Xohd_img_itm__base[] imgs = hpg.Img_itms(); int imgs_len = hpg.Img_itms().length;
|
||||
int pos = 0; int rng_bgn = -1;
|
||||
parser.Ctor_by_page(hpg.Url_bry_safe(), src, src_len);
|
||||
parser.Init_by_page(hpg.Url_bry_safe(), src, src_len);
|
||||
while (pos < src_len) {
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, src_len);
|
||||
|
||||
@@ -16,10 +16,37 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.htmls.core.wkrs.mkrs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_hdoc_ctx {
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public void Ctor(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
private byte[] fsys__file;
|
||||
public byte[] Fsys__root() {return fsys__root;} private byte[] fsys__root;
|
||||
public byte[] Fsys__file__comm() {return fsys__file__comm;} private byte[] fsys__file__comm;
|
||||
public byte[] Fsys__file__wiki() {return fsys__file__wiki;} private byte[] fsys__file__wiki;
|
||||
public byte[] Wiki__domain_bry() {return wiki__domain_bry;} private byte[] wiki__domain_bry;
|
||||
public Xow_ttl_parser Wiki__ttl_parser() {return wiki__ttl_parser;} private Xow_ttl_parser wiki__ttl_parser;
|
||||
public Xoa_file_mgr File__mgr() {return file__mgr;} private final Xoa_file_mgr file__mgr = new Xoa_file_mgr();
|
||||
public Xof_url_bldr File__url_bldr() {return file__url_bldr;} private Xof_url_bldr file__url_bldr = new Xof_url_bldr();
|
||||
public Xoh_hdoc_mkr Mkr() {return mkr;} private Xoh_hdoc_mkr mkr = new Xoh_hdoc_mkr();
|
||||
public byte[] Page__url() {return page__url;} private byte[] page__url;
|
||||
public Hzip_stat_itm Bicode__stat() {return bicode__stat;} private final Hzip_stat_itm bicode__stat = new Hzip_stat_itm();
|
||||
public int Lnki__uid__nxt() {return ++lnki__uid;} private int lnki__uid; // NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
Xoa_fsys_mgr fsys_mgr = app.Fsys_mgr();
|
||||
this.fsys__root = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.fsys__file = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.fsys__file__comm = Bry_.Add(fsys__file, Xow_domain_itm_.Bry__commons, Byte_ascii.Slash_bry);
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki, byte[] page_url) {
|
||||
if (fsys__root == null) Init_by_app(wiki.App()); // LAZY INIT
|
||||
this.wiki__ttl_parser = wiki;
|
||||
this.wiki__domain_bry = wiki.Domain_bry();
|
||||
this.fsys__file__wiki = Bry_.Add(fsys__file, wiki__domain_bry, Byte_ascii.Slash_bry);
|
||||
this.page__url = page_url;
|
||||
this.Clear();
|
||||
}
|
||||
private void Clear() {
|
||||
bicode__stat.Clear();
|
||||
this.lnki__uid = 1; // NOTE: should be 0, but for historical reasons, 1st lnki starts at 2; EX: id='xowa_lnki_2'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,23 +17,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.parsers.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.wkrs.tags.*; import gplx.xowa.htmls.core.wkrs.txts.*; import gplx.xowa.htmls.core.wkrs.escapes.*; import gplx.xowa.htmls.core.wkrs.spaces.*;
|
||||
public class Xoh_hdoc_wkr__base {
|
||||
private final Html_doc_parser hdoc_parser = new Html_doc_parser();
|
||||
import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.wkrs.tags.*; import gplx.xowa.htmls.core.wkrs.txts.*; import gplx.xowa.htmls.core.wkrs.escapes.*; import gplx.xowa.htmls.core.wkrs.spaces.*;
|
||||
public class Xoh_hdoc_parser {
|
||||
private final Xoh_hdoc_wkr hdoc_wkr;
|
||||
private final Xoh_doc_wkr__tag wkr__tag = new Xoh_doc_wkr__tag();
|
||||
public Xoh_hdoc_wkr__base(Xoh_hdoc_wkr hdoc_wkr) {
|
||||
private final Html_doc_parser hdoc_parser;
|
||||
private final Xoh_tag_parser tag_parser;
|
||||
public Xoh_hdoc_parser(Xoh_hdoc_wkr hdoc_wkr) {
|
||||
this.hdoc_wkr = hdoc_wkr;
|
||||
this.hdoc_parser.Reg_txt(new Xoh_txt_parser(hdoc_wkr)).Reg_wkrs
|
||||
( wkr__tag
|
||||
this.tag_parser = new Xoh_tag_parser(hdoc_wkr);
|
||||
this.hdoc_parser = new Html_doc_parser(new Xoh_txt_parser(hdoc_wkr)
|
||||
, tag_parser
|
||||
, new Xoh_escape_parser(hdoc_wkr)
|
||||
, new Xoh_space_parser(hdoc_wkr)
|
||||
);
|
||||
}
|
||||
public void Parse(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] page_url, byte[] src) {
|
||||
public void Parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src) {
|
||||
int src_len = src.length;
|
||||
hdoc_wkr.On_new_page(bfr, wiki, hpg, src, 0, src_len);
|
||||
wkr__tag.Ctor(hdoc_wkr, wiki).Init(src, 0, src_len);
|
||||
hdoc_parser.Parse(src, 0, src_len);
|
||||
tag_parser.Init(hctx, src, 0, src_len);
|
||||
hdoc_wkr.On_new_page(bfr, hpg, hctx, src, 0, src_len);
|
||||
hdoc_parser.Parse(hctx.Page__url(), src, 0, src_len);
|
||||
}
|
||||
}
|
||||
@@ -19,14 +19,13 @@ package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.langs.htmls.parsers.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
public interface Xoh_hdoc_wkr {
|
||||
Xoh_hdoc_ctx Ctx();
|
||||
void On_new_page(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src, int src_bgn, int src_end);
|
||||
void On_new_page(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end);
|
||||
void On_escape (int rng_bgn, int rng_end);
|
||||
void On_txt (int rng_bgn, int rng_end);
|
||||
void On_space (int rng_bgn, int rng_end);
|
||||
void On_hdr (int tag_bgn, int tag_end, int level, int capt_bgn, int capt_end, byte[] anch);
|
||||
void On_lnke (int tag_bgn, int tag_end, byte lnke_type, int autonumber_id, int href_bgn, int href_end);
|
||||
void On_hdr (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_parser arg);
|
||||
void On_lnke (gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_parser arg);
|
||||
void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser arg);
|
||||
void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser arg);
|
||||
void On_img_thm (int rng_bgn, int rng_end);
|
||||
void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_parser arg);
|
||||
}
|
||||
|
||||
@@ -16,31 +16,21 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
import gplx.langs.htmls.parsers.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
|
||||
private final Hzip_stat_itm stat_itm = new Hzip_stat_itm();
|
||||
private Bry_bfr bfr; private byte[] src; private int src_end;
|
||||
public Xoh_hdoc_ctx Ctx() {return ctx;} private final Xoh_hdoc_ctx ctx = new Xoh_hdoc_ctx();
|
||||
public void On_new_page(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src, int src_bgn, int src_end) {
|
||||
this.bfr = bfr; this.src = src; this.src_end = src_end;
|
||||
ctx.Ctor(wiki);
|
||||
private Bry_bfr bfr; private Xoh_hdoc_ctx hctx; private byte[] src; private int src_end;
|
||||
public void On_new_page(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end) {
|
||||
this.bfr = bfr; this.hctx = hctx; this.src = src; this.src_end = src_end;
|
||||
stat_itm.Clear();
|
||||
}
|
||||
public void On_hdr (int rng_bgn, int rng_end, int level, int capt_bgn, int capt_end, byte[] anch) {
|
||||
Xoh_hzip_dict_.Wkr__hdr.Encode(bfr, stat_itm, src, rng_bgn, rng_end, level, capt_bgn, capt_end, anch);
|
||||
}
|
||||
public void On_lnke (int rng_bgn, int rng_end, byte lnke_type, int autonumber_id, int href_bgn, int href_end) {
|
||||
Xoh_hzip_dict_.Wkr__lnke.Encode(bfr, stat_itm, src, rng_bgn, rng_end, lnke_type, href_bgn, href_end, autonumber_id);
|
||||
}
|
||||
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser arg) {
|
||||
Xoh_hzip_dict_.Wkr__lnki.Encode(bfr, stat_itm, src, arg);
|
||||
}
|
||||
public void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser arg) {
|
||||
Xoh_hzip_dict_.Wkr__img.Encode(bfr, stat_itm, src, arg);
|
||||
}
|
||||
public void On_img_thm (int rng_bgn, int rng_end) {}//wkr__img_thm.Encode(bfr, stat_itm, src, rng_bgn, rng_end);}
|
||||
public void On_escape (int rng_bgn, int rng_end) {Xoh_hzip_dict_.Wkr__escape.Encode(bfr, stat_itm);}
|
||||
public void On_space (int rng_bgn, int rng_end) {Xoh_hzip_dict_.Wkr__space.Encode(bfr, stat_itm, src, src_end, rng_bgn, rng_end);}
|
||||
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_escape (int rng_bgn, int rng_end) {hctx.Mkr().Escape__hzip().Encode(bfr, stat_itm).Pool__rls();}
|
||||
public void On_space (int rng_bgn, int rng_end) {hctx.Mkr().Space__hzip().Encode(bfr, stat_itm, src, src_end, rng_bgn, rng_end).Pool__rls();}
|
||||
public void On_hdr (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_parser arg) {hctx.Mkr().Hdr__hzip().Encode(bfr, stat_itm, src, arg).Pool__rls();}
|
||||
public void On_lnke (gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_parser arg) {hctx.Mkr().Lnke__hzip().Encode(bfr, stat_itm, src, arg).Pool__rls();}
|
||||
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser arg) {hctx.Mkr().Lnki__hzip().Encode(bfr, hctx, stat_itm, src, arg).Pool__rls();}
|
||||
public void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_parser arg) {hctx.Mkr().Thm__hzip().Encode(bfr, this, stat_itm, src, arg).Pool__rls();}
|
||||
public void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser arg) {hctx.Mkr().Img__hzip().Encode(bfr, stat_itm, src, arg, Bool_.Y).Pool__rls();}
|
||||
}
|
||||
|
||||
@@ -18,24 +18,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.langs.htmls.parsers.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
public class Xoh_hdoc_wkr__make implements Xoh_hdoc_wkr {
|
||||
private Bry_bfr bfr; private Xoh_page hpg; private Xoh_hdoc_ctx hctx; private byte[] src;
|
||||
private final Xoh_hdr_make wkr__hdr = new Xoh_hdr_make();
|
||||
private final Xoh_img_make wkr__img = new Xoh_img_make();
|
||||
private Bry_bfr bfr; private Xoh_page hpg; private byte[] src;
|
||||
public Xoh_hdoc_ctx Ctx() {return ctx;} private final Xoh_hdoc_ctx ctx = new Xoh_hdoc_ctx();
|
||||
public void On_new_page(Bry_bfr bfr, Xow_wiki wiki, Xoh_page hpg, byte[] src, int src_bgn, int src_end) {
|
||||
this.bfr = bfr; this.src = src; this.hpg = hpg;
|
||||
ctx.Ctor(wiki);
|
||||
private final Xoh_img_bldr wkr__img = new Xoh_img_bldr();
|
||||
public void On_new_page(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end) {
|
||||
this.bfr = bfr; this.hpg = hpg; this.hctx = hctx; this.src = src;
|
||||
}
|
||||
public void On_escape (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_space (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_hdr (int rng_bgn, int rng_end, int level, int capt_bgn, int capt_end, byte[] anch) {
|
||||
wkr__hdr.Make(bfr, hpg, src, rng_bgn, rng_end, level, capt_bgn, capt_end, anch);
|
||||
}
|
||||
public void On_lnke (int rng_bgn, int rng_end, byte lnke_type, int autonumber_id, int href_bgn, int href_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser arg) {bfr.Add_mid(src, arg.Rng_bgn(), arg.Rng_end());}
|
||||
public void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser arg) {wkr__img.Make(bfr, hpg, src, arg);}
|
||||
public void On_img_thm (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_escape (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_txt (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_space (int rng_bgn, int rng_end) {bfr.Add_mid(src, rng_bgn, rng_end);}
|
||||
public void On_lnke (gplx.xowa.htmls.core.wkrs.lnkes.Xoh_lnke_parser arg) {bfr.Add_mid(src, arg.Rng_bgn(), arg.Rng_end());}
|
||||
public void On_lnki (gplx.xowa.htmls.core.wkrs.lnkis.Xoh_lnki_parser arg) {bfr.Add_mid(src, arg.Rng_bgn(), arg.Rng_end());}
|
||||
public void On_hdr (gplx.xowa.htmls.core.wkrs.hdrs.Xoh_hdr_parser arg) {wkr__hdr.Make(bfr, hpg, src, arg);}
|
||||
public void On_img (gplx.xowa.htmls.core.wkrs.imgs.Xoh_img_parser arg) {wkr__img.Make_by_parse(bfr, hpg, hctx, src, arg);}
|
||||
public void On_thm (gplx.xowa.htmls.core.wkrs.thms.Xoh_thm_parser arg) {bfr.Add_mid(src, arg.Rng_bgn(), arg.Rng_end());}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public abstract class Xoh_itm_parser_fxt_base {
|
||||
}
|
||||
public void Exec_parse(String src_str) {
|
||||
this.src = Bry_.new_u8(src_str); this.src_len = src.length;
|
||||
rdr.Ctor_by_page(Xoa_page_.Main_page_bry, src, src_len);
|
||||
rdr.Init_by_page(Xoa_page_.Main_page_bry, src, src_len);
|
||||
Exec_parse_hook(rdr, 0, src_len);
|
||||
}
|
||||
public abstract void Exec_parse_hook(Bry_rdr owner_rdr, int src_bgn, int src_end);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Bfr_arg__href extends gplx.core.brys.Bfr_arg_base implements gplx.core.brys.Clear_able {
|
||||
private byte[] val; private int val_bgn, val_end;
|
||||
private int href_type;
|
||||
public void Clear() {
|
||||
href_type = Tid__null;
|
||||
}
|
||||
public void Set_by_atr(gplx.langs.htmls.parsers.Html_atr atr) {Set_by_mid(atr.Src(), atr.Val_bgn(), atr.Val_end());}
|
||||
public void Set_by_mid(byte[] v, int bgn, int end) {this.val = v; this.href_type = Tid__mid; this.val_bgn = bgn; this.val_end = end;}
|
||||
public void Set_by_raw(byte[] v) {this.val = v; this.href_type = Tid__raw;}
|
||||
public void Set_by_page(byte[] v) {this.val = v; this.href_type = Tid__page;}
|
||||
public void Set_by_file(byte[] v) {this.val = v; this.href_type = Tid__file;}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (val == null) return;
|
||||
switch (href_type) {
|
||||
case Tid__raw:
|
||||
bfr.Add(val);
|
||||
break;
|
||||
case Tid__mid:
|
||||
bfr.Add_mid(val, val_bgn, val_end);
|
||||
break;
|
||||
case Tid__page:
|
||||
bfr.Add(Xoh_href_.Bry__wiki); // '/wiki/'
|
||||
bfr.Add(val); // 'File:A.png'
|
||||
break;
|
||||
case Tid__file:
|
||||
bfr.Add(Xoh_href_.Bry__wiki).Add(Xow_ns_.Bry__file).Add_byte_colon();
|
||||
bfr.Add(val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private static final int Tid__null = 0, Tid__raw = 1, Tid__page = 2, Tid__file = 3, Tid__mid = 4;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*;
|
||||
public class Bfr_arg__html_atr implements Bfr_arg, Clear_able {
|
||||
private final byte[] atr_bgn;
|
||||
private int val_type;
|
||||
private int val_as_int;
|
||||
private Bfr_arg val_as_arg;
|
||||
public Bfr_arg__html_atr(byte[] key) {this.atr_bgn = Bld_atr_bgn(key);}
|
||||
public void Clear() {
|
||||
val_type = Type__null;
|
||||
val_as_arg = null;
|
||||
val_as_int = Int_.Min_value;
|
||||
}
|
||||
public Bfr_arg__html_atr Set_by_arg(Bfr_arg v) {val_type = Type__arg; val_as_arg = v; return this;}
|
||||
public Bfr_arg__html_atr Set_by_int(int v) {val_type = Type__int; val_as_int = v; return this;}
|
||||
public void Bfr_arg__clear() {this.Clear();}
|
||||
public boolean Bfr_arg__exists() {
|
||||
switch (val_type) {
|
||||
case Type__null: return false;
|
||||
case Type__arg: return val_as_arg.Bfr_arg__exists();
|
||||
case Type__int: return val_as_int != Int_.Min_value;
|
||||
default: throw Err_.new_unhandled(val_type);
|
||||
}
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (!Bfr_arg__exists()) return;
|
||||
bfr.Add(atr_bgn);
|
||||
switch (val_type) {
|
||||
case Type__arg: val_as_arg.Bfr_arg__add(bfr); break;
|
||||
case Type__int: bfr.Add_int_variable(val_as_int); break;
|
||||
}
|
||||
bfr.Add_byte_quote();
|
||||
}
|
||||
public static byte[] Bld_atr_bgn(byte[] key) {return Bry_.Add(Byte_ascii.Space_bry, key, Byte_ascii.Eq_bry, Byte_ascii.Quote_bry);} // ' key="'
|
||||
private static final int Type__null = 0, Type__arg = 1, Type__int = 2;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.parsers.*;
|
||||
public class Bfr_arg__id extends gplx.core.brys.Bfr_arg_base {
|
||||
private byte[] prefix; private int id;
|
||||
public Bfr_arg__id Set(byte[] prefix, int id) {
|
||||
this.prefix = prefix;
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
bfr.Add(prefix);
|
||||
bfr.Add_int_variable(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
public class Bfr_arg__indent extends gplx.core.brys.Bfr_arg_base implements gplx.core.brys.Clear_able {
|
||||
private int indent = 0;
|
||||
public void Clear() {
|
||||
this.indent = 0;
|
||||
}
|
||||
public void Set(int v) {this.indent = v;}
|
||||
@Override public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (indent > 0)
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, indent * 2);
|
||||
}
|
||||
}
|
||||
@@ -16,16 +16,21 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.escapes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.hzips.stats.*;
|
||||
public class Xoh_escape_hzip implements Xoh_hzip_wkr {
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_escape_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public String Key() {return Xoh_hzip_dict_.Key__escape;}
|
||||
public void Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm) {
|
||||
public Xoh_escape_hzip Encode(Bry_bfr bfr, Hzip_stat_itm stat_itm) {
|
||||
stat_itm.Escape_add_one();
|
||||
bfr.Add(Xoh_hzip_dict_.Bry__escape);
|
||||
return this;
|
||||
}
|
||||
public int Decode(Bry_bfr bfr, Xoh_decode_ctx ctx, Bry_rdr rdr, byte[] src, int hook_bgn) {
|
||||
public int Decode(Bry_bfr bfr, boolean write_to_bfr, Xoh_hdoc_ctx ctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int hook_bgn) {
|
||||
bfr.Add_byte(Xoh_hzip_dict_.Escape);
|
||||
return rdr.Pos();
|
||||
}
|
||||
public int Pool__idx() {return pool_idx;} private int pool_idx;
|
||||
public void Pool__clear (Object[] args) {}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_escape_hzip rv = new Xoh_escape_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user