mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.2.1'
This commit is contained in:
@@ -29,10 +29,12 @@ public class Io_stream_zip_mgr {
|
||||
return wtr.To_ary_and_clear();
|
||||
}
|
||||
public byte[] Unzip(byte type, byte[] val) {
|
||||
if (type == Io_stream_.Tid_raw) return val;
|
||||
Io_stream_rdr rdr = Rdr(type);
|
||||
rdr.Open_mem(val);
|
||||
return Io_stream_rdr_.Load_all_as_bry(bfr, rdr);
|
||||
synchronized (this) { // LOCK:static-obj;rdr_*;necessary; DATE:2016-07-06
|
||||
if (type == Io_stream_.Tid_raw) return val;
|
||||
Io_stream_rdr rdr = Rdr(type);
|
||||
rdr.Open_mem(val);
|
||||
return Io_stream_rdr_.Load_all_as_bry(bfr, rdr);
|
||||
}
|
||||
}
|
||||
private Io_stream_wtr Wtr(byte type) {
|
||||
switch (type) {
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
public class Gfh_atr_ {
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
// "coreattrs"
|
||||
Bry__id = Bry_.new_a7("id")
|
||||
, Bry__class = Bry_.new_a7("class")
|
||||
@@ -54,7 +54,16 @@ public class Gfh_atr_ {
|
||||
public static byte[] Make(Bry_bfr bfr, byte[] key, byte[] val) {
|
||||
return bfr.Add_byte_space().Add(key).Add_byte_eq().Add_byte_quote().Add(val).Add_byte_quote().To_bry_and_clear();
|
||||
}
|
||||
public static byte[] Add_to_bry(Bry_bfr bfr, byte[] key, byte[] val) {
|
||||
bfr.Add_byte_space().Add(key).Add_byte_eq().Add_byte_quote().Add(val).Add_byte_quote();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public static void Add(Bry_bfr bfr, byte[] key, byte[] val) {
|
||||
bfr.Add_byte_space().Add(key).Add_byte_eq().Add_byte_quote().Add(val).Add_byte_quote();
|
||||
}
|
||||
public static void Add(Bry_bfr bfr, byte[] key, int val) {
|
||||
bfr.Add_byte_space().Add(key).Add_byte_eq().Add_byte_quote();
|
||||
bfr.Add_int_variable(val);
|
||||
bfr.Add_byte_quote();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,17 @@ public class Gfh_tag_ { // NOTE: not serialized; used by tag_rdr
|
||||
, Id__sup = 30
|
||||
, Id__sub = 31
|
||||
, Id__bdi = 32
|
||||
, Id__font = 33
|
||||
, Id__strong = 34
|
||||
, Id__s = 35
|
||||
, Id__abbr = 36
|
||||
, Id__cite = 37
|
||||
, Id__var = 38
|
||||
, Id__u = 39
|
||||
, Id__big = 40
|
||||
, Id__del = 41
|
||||
, Id__strike = 42
|
||||
, Id__tt = 43
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__a = Bry_.new_a7("a")
|
||||
@@ -64,6 +75,8 @@ public class Gfh_tag_ { // NOTE: not serialized; used by tag_rdr
|
||||
, Bry__link = Bry_.new_a7("link")
|
||||
, Bry__style = Bry_.new_a7("style")
|
||||
, Bry__script = Bry_.new_a7("script")
|
||||
, Bry__xowa_any = Bry_.new_a7("xowa_any")
|
||||
, Bry__xowa_comment = Bry_.new_a7("xowa_comment")
|
||||
;
|
||||
public static final Hash_adp_bry Hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_int(Bry__a , Id__a)
|
||||
@@ -98,6 +111,17 @@ public class Gfh_tag_ { // NOTE: not serialized; used by tag_rdr
|
||||
.Add_str_int("sup" , Id__sup)
|
||||
.Add_str_int("sub" , Id__sub)
|
||||
.Add_str_int("bdi" , Id__bdi)
|
||||
.Add_str_int("font" , Id__font)
|
||||
.Add_str_int("strong" , Id__strong)
|
||||
.Add_str_int("s" , Id__s)
|
||||
.Add_str_int("abbr" , Id__abbr)
|
||||
.Add_str_int("cite" , Id__cite)
|
||||
.Add_str_int("var" , Id__var)
|
||||
.Add_str_int("u" , Id__u)
|
||||
.Add_str_int("big" , Id__big)
|
||||
.Add_str_int("del" , Id__del)
|
||||
.Add_str_int("strike" , Id__strike)
|
||||
.Add_str_int("tt" , Id__tt)
|
||||
;
|
||||
public static String To_str(int tid) {
|
||||
switch (tid) {
|
||||
@@ -137,6 +161,17 @@ public class Gfh_tag_ { // NOTE: not serialized; used by tag_rdr
|
||||
case Id__sup: return "sup";
|
||||
case Id__sub: return "sub";
|
||||
case Id__bdi: return "bdi";
|
||||
case Id__font: return "font";
|
||||
case Id__strong: return "strong";
|
||||
case Id__s: return "s";
|
||||
case Id__abbr: return "abbr";
|
||||
case Id__cite: return "cite";
|
||||
case Id__var: return "var";
|
||||
case Id__u: return "u";
|
||||
case Id__big: return "big";
|
||||
case Id__del: return "del";
|
||||
case Id__strike: return "strike";
|
||||
case Id__tt: return "tt";
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
@@ -150,6 +185,7 @@ public class Gfh_tag_ { // NOTE: not serialized; used by tag_rdr
|
||||
, P_lhs = Bry_.new_a7("<p>") , P_rhs = Bry_.new_a7("</p>")
|
||||
, Pre_lhs = Bry_.new_a7("<pre>") , Pre_rhs = Bry_.new_a7("</pre>")
|
||||
, Div_lhs = Bry_.new_a7("<div>") , Div_rhs = Bry_.new_a7("</div>")
|
||||
, Div_lhs_bgn = Bry_.new_a7("<div")
|
||||
, Html_rhs = Bry_.new_a7("</html>")
|
||||
, Head_lhs_bgn = Bry_.new_a7("<head") , Head_rhs = Bry_.new_a7("</head>")
|
||||
, Style_lhs_w_type = Bry_.new_a7("<style type=\"text/css\">")
|
||||
@@ -174,4 +210,6 @@ public class Gfh_tag_ { // NOTE: not serialized; used by tag_rdr
|
||||
Comm_bgn_len = Comm_bgn.length
|
||||
, Comm_end_len = Comm_end.length
|
||||
;
|
||||
public static void Lhs_end_nde(Bry_bfr bfr) {bfr.Add_byte(Byte_ascii.Gt);}
|
||||
public static void Lhs_end_inl(Bry_bfr bfr) {bfr.Add_byte(Byte_ascii.Slash).Add_byte(Byte_ascii.Gt);}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public class Gfh_tag implements Mwh_atr_wkr {
|
||||
return rv;
|
||||
}
|
||||
public int Name_id() {return name_id;} private int name_id;
|
||||
public boolean Tid_is_comment() {return name_id == Gfh_tag_.Id__comment;}
|
||||
public byte[] Name_bry() {return name_bry;} private byte[] name_bry;
|
||||
public Gfh_tag Chk_name_or_fail(int chk) {
|
||||
if (!Chk_name(chk)) tag_rdr.Err_wkr().Fail("name_id chk failed", "expecting", Gfh_tag_.To_str(chk));
|
||||
|
||||
@@ -112,6 +112,133 @@ public class Gfh_tag_rdr {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public Gfh_tag Tag__move_fwd_tail(byte[] find_tag_bry) {return Tag__find(Bool_.Y, Bool_.N, Bool_.Y, pos, src_end, find_tag_bry);}
|
||||
private Gfh_tag Tag__find(boolean move, boolean bwd, boolean tail, int rng_bgn, int rng_end, byte[] find_tag_bry) {
|
||||
int tmp = rng_bgn;
|
||||
int stop_pos = rng_end; int adj = 1;
|
||||
if (bwd) {
|
||||
stop_pos = -1;
|
||||
adj = -1;
|
||||
--tmp; // subtract 1 from tmp; needed when pos is at src_len, else array error below
|
||||
}
|
||||
tmp_depth.Val_zero_();
|
||||
Gfh_tag rv = null;
|
||||
while (tmp != stop_pos) {
|
||||
if (src[tmp] == Byte_ascii.Angle_bgn) {
|
||||
rv = Tag__extract(move, tail, find_tag_bry, tmp);
|
||||
if (Bry_.Eq(rv.Name_bry(), Gfh_tag_.Bry__xowa_comment)) { // ignore comments DATE:2016-06-25
|
||||
tmp = rv.Src_end();
|
||||
rv = null; // null rv, else rv will still be comment and may get returned to caller
|
||||
continue;
|
||||
}
|
||||
if (Tag__match(move, bwd, tail, find_tag_bry, tmp_depth, rv))
|
||||
break;
|
||||
else {
|
||||
tmp = bwd ? rv.Src_bgn() - 1 : rv.Src_end();
|
||||
rv = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
tmp += adj;
|
||||
}
|
||||
if (rv == null) {
|
||||
if (move && tail && !bwd)
|
||||
err_wkr.Fail("move tag fwd failed", "tag_name", find_tag_bry);
|
||||
else
|
||||
return Tag__eos(rng_bgn);
|
||||
}
|
||||
if (move) pos = rv.Src_end();
|
||||
return rv;
|
||||
}
|
||||
private boolean Tag__match(boolean move, boolean bwd, boolean tail, byte[] find_tag_bry, Int_obj_ref depth_obj, Gfh_tag tag) {
|
||||
byte[] cur_tag_bry = tag.Name_bry();
|
||||
if ( !Bry_.Eq(cur_tag_bry, find_tag_bry) // tag doesn't match requested
|
||||
&& find_tag_bry != Gfh_tag_.Bry__xowa_any // requested is not wildcard
|
||||
) return false;
|
||||
if (cur_tag_bry == Gfh_tag_.Bry__xowa_comment) return true; // ignore comments
|
||||
int depth = depth_obj.Val();
|
||||
boolean tag_is_tail = tag.Tag_is_tail();
|
||||
if (tail == tag_is_tail) {
|
||||
if (depth == 0)
|
||||
return true;
|
||||
else {
|
||||
if (Bry_.Eq(cur_tag_bry, find_tag_bry))
|
||||
depth_obj.Val_add(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!bwd && tail && !tag_is_tail && !tag.Tag_is_inline()) {
|
||||
if (Bry_.Eq(cur_tag_bry, find_tag_bry))
|
||||
depth_obj.Val_add(1);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public Gfh_tag Tag__extract(boolean move, boolean tail, byte[] find_tag_bry, int tag_bgn) {
|
||||
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) {
|
||||
case Byte_ascii.Bang:
|
||||
if (Bry_.Match(src, name_bgn + 1, name_bgn + 3, Bry__comment__mid)) // skip comment; EX: "<!"
|
||||
return Tag__comment(tag_bgn);
|
||||
break;
|
||||
case Byte_ascii.Slash:
|
||||
++name_bgn; if (name_bgn == src_end) return Tag__eos(tag_bgn); // EX: "</EOS"
|
||||
name_0 = src[name_bgn];
|
||||
cur_is_tail = true;
|
||||
break;
|
||||
}
|
||||
int name_end = -1, atrs_end = -1, tag_end = -1, name_pos = name_bgn;
|
||||
byte name_byte = name_0; boolean inline = false;
|
||||
boolean loop = true;
|
||||
while (true) {
|
||||
switch (name_byte) {
|
||||
case Byte_ascii.Angle_end: // EX: "<a>"
|
||||
name_end = atrs_end = name_pos;
|
||||
tag_end = name_end + 1;
|
||||
loop = false;
|
||||
break;
|
||||
case Byte_ascii.Slash: // EX: "<a/>"
|
||||
name_end = name_pos;
|
||||
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;
|
||||
loop = false;
|
||||
++tag_end; // move tag_end after >
|
||||
}
|
||||
else {
|
||||
name_end = tag_end = -1;
|
||||
}
|
||||
break;
|
||||
case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr: case Byte_ascii.Space:
|
||||
name_end = name_pos;
|
||||
loop = false;
|
||||
break;
|
||||
}
|
||||
if (!loop) break;
|
||||
++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(tag_bgn);
|
||||
int prv_pos = tag_end - 1;
|
||||
if (src[prv_pos] == Byte_ascii.Slash) {
|
||||
atrs_end = prv_pos;
|
||||
inline = true;
|
||||
}
|
||||
else
|
||||
atrs_end = tag_end;
|
||||
++tag_end; // position after ">"
|
||||
}
|
||||
Gfh_tag tmp = move ? tag__tmp__move : tag__tmp__peek;
|
||||
return tmp.Init(this, src, cur_is_tail, inline, tag_bgn, tag_end, name_end, atrs_end, Gfh_tag_.Id__unknown, Bry_.Mid(src, name_bgn, name_end));
|
||||
}
|
||||
public Gfh_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(tag_bgn); // EX: "<EOS"
|
||||
byte name_0 = src[name_bgn];
|
||||
@@ -172,7 +299,9 @@ public class Gfh_tag_rdr {
|
||||
++tag_end; // position after ">"
|
||||
}
|
||||
Gfh_tag tmp = move ? tag__tmp__move : tag__tmp__peek;
|
||||
return tmp.Init(this, src, cur_is_tail, inline, tag_bgn, tag_end, name_end, atrs_end, name_hash.Get_as_int_or(src, name_bgn, name_end, -1), Bry_.Mid(src, name_bgn, name_end));
|
||||
return tmp.Init(this, src, cur_is_tail, inline, tag_bgn, tag_end, name_end, atrs_end
|
||||
, name_hash.Get_as_int_or(src, name_bgn, name_end, -1) // TODO: change from -1 to Unknown
|
||||
, Bry_.Mid(src, name_bgn, name_end));
|
||||
}
|
||||
public boolean Read_and_move(byte match) {
|
||||
byte b = src[pos];
|
||||
|
||||
@@ -50,16 +50,18 @@ public class Gfo_url_encoder implements Url_encoder_interface {
|
||||
public byte[] Decode(byte[] bry, int bgn, int end) {return Decode(Bool_.N, bry, bgn, end);}
|
||||
private byte[] Decode(boolean fail, byte[] bry, int bgn, int end) {Bry_bfr bfr = Bry_bfr_.Get(); Decode(bfr, fail, bry, bgn, end); return bfr.To_bry_and_rls();}
|
||||
public Bry_bfr Decode(Bry_bfr bfr, boolean fail, byte[] bry, int bgn, int end) {
|
||||
for (int i = bgn; i < end; ++i) {
|
||||
byte b = bry[i];
|
||||
if (anchor_encoder != null && b == Byte_ascii.Hash) {
|
||||
bfr.Add_byte(Byte_ascii.Hash);
|
||||
anchor_encoder.Decode(bfr, Bool_.N, bry, i + 1, end);
|
||||
break;
|
||||
// synchronized (this) { // LOCK:DELETE; DATE:2016-07-06
|
||||
for (int i = bgn; i < end; ++i) {
|
||||
byte b = bry[i];
|
||||
if (anchor_encoder != null && b == Byte_ascii.Hash) {
|
||||
bfr.Add_byte(Byte_ascii.Hash);
|
||||
anchor_encoder.Decode(bfr, Bool_.N, bry, i + 1, end);
|
||||
break;
|
||||
}
|
||||
Gfo_url_encoder_itm itm = decode_ary[b & 0xff];// PATCH.JAVA:need to convert to unsigned byte
|
||||
i += itm.Decode(bfr, bry, end, i, b, fail);
|
||||
}
|
||||
Gfo_url_encoder_itm itm = decode_ary[b & 0xff];// PATCH.JAVA:need to convert to unsigned byte
|
||||
i += itm.Decode(bfr, bry, end, i, b, fail);
|
||||
}
|
||||
return bfr;
|
||||
return bfr;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.log_msgs.*;
|
||||
/*
|
||||
NOTE: naive implementation of PHP evaluator. intended only for parsing Messages**.php files in MediaWiki. Specifically, it assumes the following:
|
||||
NOTE: naive implementation of PHP parser; intended only for parsing Messages**.php files in MediaWiki. Specifically, it assumes the following:
|
||||
- all lines are assignment lines: EX: $a = b;
|
||||
- only the assignment operator is allowed (=); EX: $a = 5 + 7; fails b/c of + operator;
|
||||
- no functions are supported: EX: strlen('a') fails
|
||||
@@ -46,7 +46,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
return;
|
||||
}
|
||||
switch (mode) {
|
||||
case Mode_expect: // handles sequences like "array("
|
||||
case Mode_expect: // handles sequences like "array(" which hook in to "array" but need to skip "("
|
||||
if (tkn_tid == next_tid)
|
||||
mode = next_mode;
|
||||
else {
|
||||
@@ -112,7 +112,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
line_val = new Php_itm_quote(tkn_quote.Quote_text(src));
|
||||
break;
|
||||
case Php_tkn_.Tid_ary:
|
||||
Expect(Php_tkn_.Tid_paren_bgn, Mode_ary_subs);
|
||||
case Php_tkn_.Tid_brack_bgn:
|
||||
Php_itm_ary ary = new Php_itm_ary();
|
||||
if (cur_ary == null)
|
||||
line_val = ary;
|
||||
@@ -122,6 +122,10 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
cur_kv_key = null;
|
||||
}
|
||||
this.cur_ary = ary;
|
||||
if (tkn_tid == Php_tkn_.Tid_ary)
|
||||
Expect(Php_tkn_.Tid_paren_bgn, Mode_ary_subs);
|
||||
else
|
||||
mode = Mode_ary_subs;
|
||||
break;
|
||||
case Php_tkn_.Tid_txt:
|
||||
case Php_tkn_.Tid_var:
|
||||
@@ -132,6 +136,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
case Php_tkn_.Tid_comma:
|
||||
case Php_tkn_.Tid_paren_bgn:
|
||||
case Php_tkn_.Tid_paren_end:
|
||||
case Php_tkn_.Tid_brack_end:
|
||||
case Php_tkn_.Tid_num:
|
||||
break;
|
||||
}
|
||||
@@ -159,7 +164,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
Ary_add_itm(new Php_itm_var(Bry_.Mid(src, tkn_txt.Src_bgn(), tkn_txt.Src_end())));
|
||||
break;
|
||||
case Php_tkn_.Tid_ary:
|
||||
Expect(Php_tkn_.Tid_paren_bgn, Mode_ary_subs);
|
||||
case Php_tkn_.Tid_brack_bgn:
|
||||
Php_itm_ary ary = new Php_itm_ary();
|
||||
if (cur_ary == null)
|
||||
line_val = ary;
|
||||
@@ -174,8 +179,13 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
}
|
||||
}
|
||||
this.cur_ary = ary;
|
||||
if (tkn_tid == Php_tkn_.Tid_ary)
|
||||
Expect(Php_tkn_.Tid_paren_bgn, Mode_ary_subs);
|
||||
else
|
||||
mode = Mode_ary_subs;
|
||||
break;
|
||||
case Php_tkn_.Tid_paren_end:
|
||||
case Php_tkn_.Tid_brack_end:
|
||||
mode = Mode_ary_term;
|
||||
if (frame_stack.Count() == 0)
|
||||
cur_ary = null;
|
||||
@@ -201,6 +211,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
mode = Mode_ary_subs;
|
||||
break;
|
||||
case Php_tkn_.Tid_paren_end:
|
||||
case Php_tkn_.Tid_brack_end:
|
||||
mode = Mode_ary_term;
|
||||
if (frame_stack.Count() == 0)
|
||||
cur_ary = null;
|
||||
@@ -221,6 +232,7 @@ public class Php_evaluator implements Php_tkn_wkr {
|
||||
switch (tkn_tid) {
|
||||
case Php_tkn_.Tid_comma:
|
||||
case Php_tkn_.Tid_paren_end: // NOTE: paren_end occurs in multiple nests; EX: array(array())
|
||||
case Php_tkn_.Tid_brack_end:
|
||||
mode = Mode_ary_subs;
|
||||
break;
|
||||
case Php_tkn_.Tid_semic:
|
||||
|
||||
292
400_xowa/src/gplx/langs/phps/Php_parser_fxt.java
Normal file
292
400_xowa/src/gplx/langs/phps/Php_parser_fxt.java
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
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.phps; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.tests.*; import gplx.core.log_msgs.*;
|
||||
class Php_parser_fxt {
|
||||
Php_tkn_factory tkn_factory = new Php_tkn_factory();
|
||||
Php_parser parser = new Php_parser();
|
||||
Php_tkn_wkr_tkn tkn_wkr = new Php_tkn_wkr_tkn();
|
||||
Php_evaluator line_wkr = new Php_evaluator(new Gfo_msg_log("test"));
|
||||
Tst_mgr tst_mgr = new Tst_mgr();
|
||||
Gfo_msg_log_chkr log_mgr_chkr = new Gfo_msg_log_chkr();
|
||||
public void Clear() {log_mgr_chkr.Clear(); tkn_wkr.Clear(); line_wkr.Clear();}
|
||||
public Php_tkn_chkr_base tkn_declaration() {return Php_tkn_declaration_chkr.Instance;}
|
||||
public Php_tkn_chkr_base tkn_txt(int bgn, int end) {return new Php_tkn_txt_chkr(bgn, end);}
|
||||
public Php_tkn_chkr_base tkn_ws(int bgn, int end) {return new Php_tkn_ws_chkr(bgn, end);}
|
||||
public Php_tkn_chkr_base tkn_generic(int bgn, int end, byte tid) {return new Php_tkn_generic_chkr(bgn, end, tid);}
|
||||
public Php_tkn_comment_chkr tkn_comment_mult(int bgn, int end) {return new Php_tkn_comment_chkr(bgn, end).Comment_tid_(Php_tkn_comment.Tid_mult);}
|
||||
public Php_tkn_comment_chkr tkn_comment_slash(int bgn, int end) {return new Php_tkn_comment_chkr(bgn, end).Comment_tid_(Php_tkn_comment.Tid_slash);}
|
||||
public Php_tkn_comment_chkr tkn_comment_hash(int bgn, int end) {return new Php_tkn_comment_chkr(bgn, end).Comment_tid_(Php_tkn_comment.Tid_hash);}
|
||||
public Php_tkn_quote_chkr tkn_quote_apos(int bgn, int end) {return new Php_tkn_quote_chkr(bgn, end).Quote_tid_(Byte_ascii.Apos);}
|
||||
public Php_tkn_quote_chkr tkn_quote_quote(int bgn, int end) {return new Php_tkn_quote_chkr(bgn, end).Quote_tid_(Byte_ascii.Quote);}
|
||||
public Php_parser_fxt Msg(Gfo_msg_itm itm, int bgn, int end) {
|
||||
log_mgr_chkr.Add_itm(itm, bgn, end);
|
||||
return this;
|
||||
}
|
||||
public Php_tkn_var_chkr tkn_var(int bgn, int end, String v) {return new Php_tkn_var_chkr(bgn, end).Var_name_(v);}
|
||||
public Php_tkn_num_chkr tkn_num(int bgn, int end, int v) {return new Php_tkn_num_chkr(bgn, end).Num_val_int_(v);}
|
||||
public Php_line_assign_chkr line_assign(String key, Php_itm_chkr_base val) {return new Php_line_assign_chkr().Key_(key).Val_(val);}
|
||||
public Php_line_assign_chkr line_assign_subs(String key, String[] subs, Php_itm_chkr_base val) {return new Php_line_assign_chkr().Key_(key).Subs_(subs).Val_(val);}
|
||||
public Php_itm_chkr_base itm_bool_true() {return new Php_itm_generic_chkr(Php_itm_.Tid_bool_true);}
|
||||
public Php_itm_chkr_base itm_bool_false() {return new Php_itm_generic_chkr(Php_itm_.Tid_bool_false);}
|
||||
public Php_itm_chkr_base itm_null() {return new Php_itm_generic_chkr(Php_itm_.Tid_null);}
|
||||
public Php_itm_chkr_base itm_quote(String v) {return new Php_itm_quote_chkr().Val_obj_str_(v);}
|
||||
public Php_itm_chkr_base itm_int(int v) {return new Php_itm_int_chkr().Val_obj_int_(v);}
|
||||
public Php_itm_chkr_base itm_txt(String v) {return new Php_itm_txt_chkr().Val_obj_str_(v);}
|
||||
public Php_itm_ary_chkr itm_ary() {return new Php_itm_ary_chkr();}
|
||||
public Php_itm_kv_chkr itm_kv_quote(String k, String v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_quote(v));}
|
||||
public Php_itm_kv_chkr itm_kv_txt(String k, String v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_txt(v));}
|
||||
public Php_itm_kv_chkr itm_kv_int(String k, int v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_int(v));}
|
||||
public Php_itm_kv_chkr itm_kv_itm(String k, Php_itm_chkr_base v) {return new Php_itm_kv_chkr().Key_(k).Val_(v);}
|
||||
public void tst_tkns(String raw, Php_tkn_chkr_base... expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_tkns(raw_bry, tkn_wkr);
|
||||
Php_tkn[] actl = (Php_tkn[])tkn_wkr.List().To_ary(Php_tkn.class);
|
||||
tst_mgr.Vars().Clear().Add("raw_bry", raw_bry);
|
||||
tst_mgr.Tst_ary("", expd, actl);
|
||||
log_mgr_chkr.tst(tst_mgr, tkn_wkr.Msg_log());
|
||||
}
|
||||
public void tst_lines(String raw, Php_line_assign_chkr... expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_tkns(raw_bry, line_wkr);
|
||||
Php_line[] actl = (Php_line[])line_wkr.List().To_ary(Php_line.class);
|
||||
tst_mgr.Vars().Clear().Add("raw_bry", raw_bry);
|
||||
tst_mgr.Tst_ary("", expd, actl);
|
||||
log_mgr_chkr.tst(tst_mgr, line_wkr.Msg_log());
|
||||
}
|
||||
}
|
||||
abstract class Php_tkn_chkr_base implements Tst_chkr {
|
||||
public abstract byte Tkn_tid();
|
||||
public abstract Class<?> TypeOf();
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn = -1;
|
||||
public int Src_end() {return src_end;} private int src_end = -1;
|
||||
public void Src_rng_(int src_bgn, int src_end) {this.src_bgn = src_bgn; this.src_end = src_end;}
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_tkn actl = (Php_tkn)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "tkn_tid", this.Tkn_tid(), actl.Tkn_tid());
|
||||
rv += mgr.Tst_val(src_bgn == -1, path, "src_bgn", src_bgn, actl.Src_bgn());
|
||||
rv += mgr.Tst_val(src_end == -1, path, "src_end", src_end, actl.Src_end());
|
||||
rv += Chk_tkn(mgr, path, actl);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {return 0;}
|
||||
}
|
||||
class Php_tkn_declaration_chkr extends Php_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_declaration.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_declaration;}
|
||||
public static final Php_tkn_declaration_chkr Instance = new Php_tkn_declaration_chkr();
|
||||
}
|
||||
class Php_tkn_txt_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_txt_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_txt.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_txt;}
|
||||
}
|
||||
class Php_tkn_ws_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_ws_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_ws.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_ws;}
|
||||
}
|
||||
class Php_tkn_comment_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_comment_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_comment.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_comment;}
|
||||
public Php_tkn_comment_chkr Comment_tid_(byte v) {this.comment_tid = v; return this;} private byte comment_tid = Php_tkn_comment.Tid_null;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_comment actl = (Php_tkn_comment)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(comment_tid == Php_tkn_comment.Tid_null, path, "comment_tid", comment_tid, actl.Comment_tid());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_quote_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_quote_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_quote.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_quote;}
|
||||
public Php_tkn_quote_chkr Quote_tid_(byte v) {this.quote_tid = v; return this;} private byte quote_tid = Byte_ascii.Null;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_quote actl = (Php_tkn_quote)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(quote_tid == Byte_ascii.Null, path, "quote_tid", quote_tid, actl.Quote_tid());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_var_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_var_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_var.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_var;}
|
||||
public Php_tkn_var_chkr Var_name_(String v) {this.var_name = v; return this;} private String var_name;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_var actl = (Php_tkn_var)actl_obj;
|
||||
int rv = 0;
|
||||
byte[] raw_bry = (byte[])mgr.Vars_get_by_key("raw_bry");
|
||||
rv += mgr.Tst_val(var_name == null, path, "var_name", var_name, String_.new_u8(actl.Var_name(raw_bry)));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_num_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_num_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_num.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_num;}
|
||||
public Php_tkn_num_chkr Num_val_int_(int v) {this.num_val_int = v; return this;} private int num_val_int = Int_.Min_value;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_num actl = (Php_tkn_num)actl_obj;
|
||||
int rv = 0;
|
||||
byte[] raw_bry = (byte[])mgr.Vars_get_by_key("raw_bry");
|
||||
rv += mgr.Tst_val(num_val_int == Int_.Min_value, path, "num_val_int", num_val_int, actl.Num_val_int(raw_bry));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_generic_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_generic_chkr(int src_bgn, int src_end, byte tkn_tid) {this.Src_rng_(src_bgn, src_end); this.tkn_tid = tkn_tid;}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return tkn_tid;} private byte tkn_tid;
|
||||
}
|
||||
class Php_line_assign_chkr implements Tst_chkr {
|
||||
public Class<?> TypeOf() {return Php_line_assign.class;}
|
||||
public Php_line_assign_chkr Key_(String v) {key = v; return this;} private String key;
|
||||
public Php_line_assign_chkr Subs_(String[] v) {
|
||||
int subs_len = v.length;
|
||||
subs = new Php_itm_quote_chkr[subs_len];
|
||||
for (int i = 0; i < subs_len; i++)
|
||||
subs[i] = new Php_itm_quote_chkr().Val_obj_str_(v[i]);
|
||||
return this;
|
||||
} Php_itm_chkr_base[] subs;
|
||||
public Php_line_assign_chkr Val_(Php_itm_chkr_base v) {val = v; return this;} Php_itm_chkr_base val;
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_line_assign actl = (Php_line_assign)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key().Val_obj_bry()));
|
||||
if (subs != null) rv += mgr.Tst_sub_ary(subs, actl.Key_subs(), "subs", rv);
|
||||
rv += mgr.Tst_sub_obj(val, actl.Val(), "val", rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
abstract class Php_itm_chkr_base implements Tst_chkr {
|
||||
public abstract byte Itm_tid();
|
||||
public abstract Class<?> TypeOf();
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_itm actl = (Php_itm)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "tkn_tid", this.Itm_tid(), actl.Itm_tid());
|
||||
rv += Chk_itm(mgr, path, actl);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {return 0;}
|
||||
public static final Php_itm_chkr_base[] Ary_empty = new Php_itm_chkr_base[0];
|
||||
}
|
||||
class Php_itm_generic_chkr extends Php_itm_chkr_base {
|
||||
public Php_itm_generic_chkr(byte itm_tid) {this.itm_tid = itm_tid;} private byte itm_tid;
|
||||
@Override public byte Itm_tid() {return itm_tid;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
}
|
||||
class Php_itm_int_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_int;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_int_chkr Val_obj_int_(int v) {this.val_obj_int = v; return this;} private int val_obj_int;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_int actl = (Php_itm_int)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_int, actl.Val_obj_int());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_txt_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_var;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_txt_chkr Val_obj_str_(String v) {this.val_obj_str = v; return this;} private String val_obj_str;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_var actl = (Php_itm_var)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_u8(actl.Val_obj_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_quote_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_quote;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_quote_chkr Val_obj_str_(String v) {this.val_obj_str = v; return this;} private String val_obj_str;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_quote actl = (Php_itm_quote)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_u8(actl.Val_obj_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_ary_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_ary;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_ary_chkr Subs_(Php_itm_chkr_base... v) {this.itms = v; return this;} Php_itm_chkr_base[] itms = Php_itm_chkr_base.Ary_empty;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_ary actl = (Php_itm_ary)actl_obj;
|
||||
int rv = 0;
|
||||
int actl_subs_len = actl.Subs_len();
|
||||
Php_itm[] actl_ary = new Php_itm[actl_subs_len];
|
||||
for (int i = 0; i < actl_subs_len; i++) {
|
||||
actl_ary[i] = (Php_itm)actl.Subs_get(i);
|
||||
}
|
||||
rv += mgr.Tst_sub_ary(itms, actl_ary, "subs", rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_kv_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_kv;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_kv_chkr Key_(String v) {key = v; return this;} private String key;
|
||||
public Php_itm_kv_chkr Val_(Php_itm_chkr_base v) {val = v; return this;} Php_itm_chkr_base val;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_kv actl = (Php_itm_kv)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "key", key, String_.new_u8(actl.Key().Val_obj_bry()));
|
||||
rv += mgr.Tst_sub_obj(val, actl.Val(), path, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Gfo_msg_log_chkr implements Tst_chkr {
|
||||
List_adp itms = List_adp_.New();
|
||||
public Class<?> TypeOf() {return Gfo_msg_log.class;}
|
||||
public void Clear() {itms.Clear();}
|
||||
public void Add_itm(Gfo_msg_itm itm, int bgn, int end) {
|
||||
Gfo_msg_data_chkr chkr = new Gfo_msg_data_chkr();
|
||||
chkr.Itm_(itm).Excerpt_bgn_(bgn).Excerpt_end_(end);
|
||||
itms.Add(chkr);
|
||||
}
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {return 0;}
|
||||
public void tst(Tst_mgr mgr, Object actl_obj) {
|
||||
Gfo_msg_log actl = (Gfo_msg_log)actl_obj;
|
||||
int actl_itms_len = actl.Ary_len();
|
||||
Gfo_msg_data[] actl_itms = new Gfo_msg_data[actl_itms_len];
|
||||
for (int i = 0; i < actl_itms_len; i++)
|
||||
actl_itms[i] = actl.Ary_get(i);
|
||||
mgr.Tst_ary("itms", (Gfo_msg_data_chkr[])itms.To_ary(Gfo_msg_data_chkr.class), actl_itms);
|
||||
}
|
||||
}
|
||||
class Gfo_msg_data_chkr implements Tst_chkr {
|
||||
public Class<?> TypeOf() {return Gfo_msg_data.class;}
|
||||
public Gfo_msg_data_chkr Itm_(Gfo_msg_itm v) {itm = v; return this;} Gfo_msg_itm itm;
|
||||
public Gfo_msg_data_chkr Excerpt_bgn_(int v) {excerpt_bgn = v; return this;} private int excerpt_bgn = -1;
|
||||
public Gfo_msg_data_chkr Excerpt_end_(int v) {excerpt_end = v; return this;} private int excerpt_end = -1;
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Gfo_msg_data actl = (Gfo_msg_data)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(itm == null, path, "itm", itm.Path_str(), actl.Item().Path_str());
|
||||
rv += mgr.Tst_val(excerpt_bgn == -1, path, "excerpt_bgn", excerpt_bgn, actl.Src_bgn());
|
||||
rv += mgr.Tst_val(excerpt_end == -1, path, "excerpt_end", excerpt_end, actl.Src_end());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -16,89 +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.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.core.log_msgs.*;
|
||||
public class Php_parser_tst {
|
||||
Php_parser_fxt fxt = new Php_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Text() {
|
||||
fxt.tst_tkns("text", fxt.tkn_txt(0, 4));
|
||||
import org.junit.*;
|
||||
public class Php_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Php_parser_fxt fxt = new Php_parser_fxt();
|
||||
@Test public void Text() {fxt.tst_tkns("text", fxt.tkn_txt(0, 4)); }
|
||||
@Test public void Declaration_pass() {fxt.tst_tkns("<?php", fxt.tkn_declaration());}
|
||||
@Test public void Declaration_fail() {fxt.tst_tkns("<?phpx", fxt.tkn_txt(0, 6));}
|
||||
@Test public void Ws_basic() {fxt.tst_tkns(" ", fxt.tkn_ws(0, 1));}
|
||||
@Test public void Ws_mix() {fxt.tst_tkns(" a\n", fxt.tkn_ws(0, 1), fxt.tkn_txt(1, 2), fxt.tkn_ws(2, 3));}
|
||||
@Test public void Comment_mult() {fxt.tst_tkns("/*a*/", fxt.tkn_comment_mult(0, 5));}
|
||||
@Test public void Comment_slash() {fxt.tst_tkns("//a\n", fxt.tkn_comment_slash(0, 4));}
|
||||
@Test public void Comment_hash() {fxt.tst_tkns("#a\n", fxt.tkn_comment_hash(0, 3));}
|
||||
@Test public void Comment_mult_fail() {fxt.Msg(Php_lxr_comment.Dangling_comment, 0, 2).tst_tkns("/*a", fxt.tkn_comment_mult(0, 3));}
|
||||
@Test public void Var() {fxt.tst_tkns("$abc", fxt.tkn_var(0, 4, "abc"));}
|
||||
@Test public void Sym() {fxt.tst_tkns(";==>,()", fxt.tkn_generic(0, 1, Php_tkn_.Tid_semic), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_generic(2, 4, Php_tkn_.Tid_eq_kv), fxt.tkn_generic(4, 5, Php_tkn_.Tid_comma), fxt.tkn_generic(5, 6, Php_tkn_.Tid_paren_bgn), fxt.tkn_generic(6, 7, Php_tkn_.Tid_paren_end));}
|
||||
@Test public void Keyword() {fxt.tst_tkns("null=nulla", fxt.tkn_generic(0, 4, Php_tkn_.Tid_null), fxt.tkn_generic(4, 5, Php_tkn_.Tid_eq), fxt.tkn_txt(5, 10));}
|
||||
@Test public void Num() {fxt.tst_tkns("0=123", fxt.tkn_num(0, 1, 0), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_num(2, 5, 123));}
|
||||
@Test public void Quote_apos() {fxt.tst_tkns("'a\"b'", fxt.tkn_quote_apos(0, 5));}
|
||||
@Test public void Quote_quote() {fxt.tst_tkns("\"a'b\"", fxt.tkn_quote_quote(0, 5));}
|
||||
@Test public void Quote_escape() {fxt.tst_tkns("'a\\'b'", fxt.tkn_quote_apos(0, 6));}
|
||||
@Test public void Brack() {fxt.tst_tkns("['a']", fxt.tkn_generic(0, 1, Php_tkn_.Tid_brack_bgn), fxt.tkn_quote_apos(1, 4), fxt.tkn_generic(4, 5, Php_tkn_.Tid_brack_end));}
|
||||
@Test public void Line_ws() {fxt.tst_lines("\r\n$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));}
|
||||
@Test public void Line_brack() {fxt.tst_lines("$a['b'] = 'c';", fxt.line_assign_subs("a", String_.Ary("b"), fxt.itm_quote("c")));}
|
||||
@Test public void Line_assign_false() {fxt.tst_lines("$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));}
|
||||
@Test public void Line_assign_quote_charcode() {fxt.tst_lines("$a = 'bc';", fxt.line_assign("a", fxt.itm_quote("bc")));}
|
||||
@Test public void Line_assign_mult() {fxt.tst_lines("$a = 'b';\n$c='d';", fxt.line_assign("a", fxt.itm_quote("b")), fxt.line_assign("c", fxt.itm_quote("d")));}
|
||||
@Test public void Empty_usr_array() {
|
||||
fxt.tst_lines("$a = array();\n$b = array();"
|
||||
, fxt.line_assign("a", fxt.itm_ary())
|
||||
, fxt.line_assign("b", fxt.itm_ary())
|
||||
);
|
||||
}
|
||||
@Test public void Declaration_pass() {
|
||||
fxt.tst_tkns("<?php", fxt.tkn_declaration());
|
||||
}
|
||||
@Test public void Declaration_fail() {
|
||||
fxt.tst_tkns("<?phpx", fxt.tkn_txt(0, 6));
|
||||
}
|
||||
@Test public void Ws_basic() {
|
||||
fxt.tst_tkns(" ", fxt.tkn_ws(0, 1));
|
||||
}
|
||||
@Test public void Ws_mix() {
|
||||
fxt.tst_tkns(" a\n", fxt.tkn_ws(0, 1), fxt.tkn_txt(1, 2), fxt.tkn_ws(2, 3));
|
||||
}
|
||||
@Test public void Comment_mult() {
|
||||
fxt.tst_tkns("/*a*/", fxt.tkn_comment_mult(0, 5));
|
||||
}
|
||||
@Test public void Comment_slash() {
|
||||
fxt.tst_tkns("//a\n", fxt.tkn_comment_slash(0, 4));
|
||||
}
|
||||
@Test public void Comment_hash() {
|
||||
fxt.tst_tkns("#a\n", fxt.tkn_comment_hash(0, 3));
|
||||
}
|
||||
@Test public void Comment_mult_fail() {
|
||||
fxt.Msg(Php_lxr_comment.Dangling_comment, 0, 2).tst_tkns("/*a", fxt.tkn_comment_mult(0, 3));
|
||||
}
|
||||
@Test public void Var() {
|
||||
fxt.tst_tkns("$abc", fxt.tkn_var(0, 4, "abc"));
|
||||
}
|
||||
@Test public void Sym() {
|
||||
fxt.tst_tkns(";==>,()", fxt.tkn_generic(0, 1, Php_tkn_.Tid_semic), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_generic(2, 4, Php_tkn_.Tid_eq_kv), fxt.tkn_generic(4, 5, Php_tkn_.Tid_comma), fxt.tkn_generic(5, 6, Php_tkn_.Tid_paren_bgn), fxt.tkn_generic(6, 7, Php_tkn_.Tid_paren_end));
|
||||
}
|
||||
@Test public void Keyword() {
|
||||
fxt.tst_tkns("null=nulla", fxt.tkn_generic(0, 4, Php_tkn_.Tid_null), fxt.tkn_generic(4, 5, Php_tkn_.Tid_eq), fxt.tkn_txt(5, 10));
|
||||
}
|
||||
@Test public void Num() {
|
||||
fxt.tst_tkns("0=123", fxt.tkn_num(0, 1, 0), fxt.tkn_generic(1, 2, Php_tkn_.Tid_eq), fxt.tkn_num(2, 5, 123));
|
||||
}
|
||||
@Test public void Quote_apos() {
|
||||
fxt.tst_tkns("'a\"b'", fxt.tkn_quote_apos(0, 5));
|
||||
}
|
||||
@Test public void Quote_quote() {
|
||||
fxt.tst_tkns("\"a'b\"", fxt.tkn_quote_quote(0, 5));
|
||||
}
|
||||
@Test public void Quote_escape() {
|
||||
fxt.tst_tkns("'a\\'b'", fxt.tkn_quote_apos(0, 6));
|
||||
}
|
||||
@Test public void Brack() {
|
||||
fxt.tst_tkns("['a']", fxt.tkn_generic(0, 1, Php_tkn_.Tid_brack_bgn), fxt.tkn_quote_apos(1, 4), fxt.tkn_generic(4, 5, Php_tkn_.Tid_brack_end));
|
||||
}
|
||||
@Test public void Line_assign_false() {
|
||||
fxt.tst_lines("$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));
|
||||
}
|
||||
@Test public void Line_assign_quote_charcode() {
|
||||
fxt.tst_lines("$a = 'bc';", fxt.line_assign("a", fxt.itm_quote("bc")));
|
||||
}
|
||||
@Test public void Line_assign_mult() {
|
||||
fxt.tst_lines("$a = 'b';\n$c='d';", fxt.line_assign("a", fxt.itm_quote("b")), fxt.line_assign("c", fxt.itm_quote("d")));
|
||||
}
|
||||
@Test public void Line_ary_flat() {
|
||||
fxt.tst_lines("$a = array('b', 'c', 'd');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));
|
||||
}
|
||||
@Test public void Line_ary_flat_escape() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
|
||||
@Test public void Ary_flat() {fxt.tst_lines("$a = array('b', 'c', 'd');" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));}
|
||||
@Test public void Brack_flat() {fxt.tst_lines("$a = ['b', 'c', 'd'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_quote("c"), fxt.itm_quote("d"))));}
|
||||
@Test public void Ary_flat_escape() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
|
||||
fxt.tst_lines("$a = array('b\\\\', 'c');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b\\\\"), fxt.itm_quote("c"))));
|
||||
}
|
||||
@Test public void Line_ary_flat_escape2() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
|
||||
@Test public void Ary_flat_escape2() { // PURPOSE.fix: \\' was being interpreted incorrectly; \\ should escape \, but somehow \' was being escaped
|
||||
fxt.tst_lines("$a = array('b\\\\\\'c', 'd');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b\\\\\\'c"), fxt.itm_quote("d"))));
|
||||
}
|
||||
@Test public void Line_ary_kv() {
|
||||
fxt.tst_lines("$a = array(k0 => 'v0', k1 => 'v1', k2 => 'v2');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));
|
||||
}
|
||||
@Test public void Line_ary_kv_num() {
|
||||
fxt.tst_lines("$a = array(k0 => 0, k1 => 1);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_int("k0", 0), fxt.itm_kv_int("k1", 1))));
|
||||
}
|
||||
@Test public void Line_ary_nest() {
|
||||
fxt.tst_lines("$a = array('b', array('c', 'd'), 'e');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));
|
||||
}
|
||||
@Test public void Line_ary_nest_kv() {
|
||||
@Test public void Ary_kv() {fxt.tst_lines("$a = array(k0 => 'v0', k1 => 'v1', k2 => 'v2');", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));}
|
||||
@Test public void Brack_kv() {fxt.tst_lines("$a = [k0 => 'v0', k1 => 'v1', k2 => 'v2'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_quote("k0", "v0"), fxt.itm_kv_quote("k1", "v1"), fxt.itm_kv_quote("k2", "v2"))));}
|
||||
@Test public void Ary_kv_num() {fxt.tst_lines("$a = array(k0 => 0, k1 => 1);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_int("k0", 0), fxt.itm_kv_int("k1", 1))));}
|
||||
@Test public void Ary_kv_txt() {fxt.tst_lines("$a = array('k0' => a, 'k1' => b);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_txt("k0", "a"), fxt.itm_kv_txt("k1", "b"))));}
|
||||
@Test public void Ary_nest() {fxt.tst_lines("$a = array('b', array('c', 'd'), 'e');" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));}
|
||||
@Test public void Brack_nest() {fxt.tst_lines("$a = ['b', ['c', 'd'], 'e'];" , fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_quote("b"), fxt.itm_ary().Subs_(fxt.itm_quote("c"), fxt.itm_quote("d")), fxt.itm_quote("e"))));}
|
||||
@Test public void Ary_nest_kv() {
|
||||
fxt.tst_lines("$a = array('i00' => array('01', '02'), 'i10' => array('11', '12'), 'i20' => array('21', '22'));"
|
||||
, fxt.line_assign
|
||||
( "a"
|
||||
@@ -108,292 +71,14 @@ public class Php_parser_tst {
|
||||
, fxt.itm_kv_itm("i20", fxt.itm_ary().Subs_(fxt.itm_quote("21"), fxt.itm_quote("22")))
|
||||
)));
|
||||
}
|
||||
@Test public void Line_ws() {
|
||||
fxt.tst_lines("\r\n$a = false;", fxt.line_assign("a", fxt.itm_bool_false()));
|
||||
}
|
||||
@Test public void Empty_usr_array() {
|
||||
fxt.tst_lines("$a = array();\n$b = array();"
|
||||
, fxt.line_assign("a", fxt.itm_ary())
|
||||
, fxt.line_assign("b", fxt.itm_ary())
|
||||
);
|
||||
}
|
||||
@Test public void Line_ary_kv_txt() {
|
||||
fxt.tst_lines("$a = array('k0' => a, 'k1' => b);", fxt.line_assign("a", fxt.itm_ary().Subs_(fxt.itm_kv_txt("k0", "a"), fxt.itm_kv_txt("k1", "b"))));
|
||||
}
|
||||
@Test public void Line_brack() {
|
||||
fxt.tst_lines("$a['b'] = 'c';", fxt.line_assign_subs("a", String_.Ary("b"), fxt.itm_quote("c")));
|
||||
}
|
||||
}
|
||||
class Php_parser_fxt {
|
||||
Php_tkn_factory tkn_factory = new Php_tkn_factory();
|
||||
Php_parser parser = new Php_parser();
|
||||
Php_tkn_wkr_tkn tkn_wkr = new Php_tkn_wkr_tkn();
|
||||
Php_evaluator line_wkr = new Php_evaluator(new Gfo_msg_log("test"));
|
||||
Tst_mgr tst_mgr = new Tst_mgr();
|
||||
Gfo_msg_log_chkr log_mgr_chkr = new Gfo_msg_log_chkr();
|
||||
public void Clear() {log_mgr_chkr.Clear(); tkn_wkr.Clear(); line_wkr.Clear();}
|
||||
public Php_tkn_chkr_base tkn_declaration() {return Php_tkn_declaration_chkr.Instance;}
|
||||
public Php_tkn_chkr_base tkn_txt(int bgn, int end) {return new Php_tkn_txt_chkr(bgn, end);}
|
||||
public Php_tkn_chkr_base tkn_ws(int bgn, int end) {return new Php_tkn_ws_chkr(bgn, end);}
|
||||
public Php_tkn_chkr_base tkn_generic(int bgn, int end, byte tid) {return new Php_tkn_generic_chkr(bgn, end, tid);}
|
||||
public Php_tkn_comment_chkr tkn_comment_mult(int bgn, int end) {return new Php_tkn_comment_chkr(bgn, end).Comment_tid_(Php_tkn_comment.Tid_mult);}
|
||||
public Php_tkn_comment_chkr tkn_comment_slash(int bgn, int end) {return new Php_tkn_comment_chkr(bgn, end).Comment_tid_(Php_tkn_comment.Tid_slash);}
|
||||
public Php_tkn_comment_chkr tkn_comment_hash(int bgn, int end) {return new Php_tkn_comment_chkr(bgn, end).Comment_tid_(Php_tkn_comment.Tid_hash);}
|
||||
public Php_tkn_quote_chkr tkn_quote_apos(int bgn, int end) {return new Php_tkn_quote_chkr(bgn, end).Quote_tid_(Byte_ascii.Apos);}
|
||||
public Php_tkn_quote_chkr tkn_quote_quote(int bgn, int end) {return new Php_tkn_quote_chkr(bgn, end).Quote_tid_(Byte_ascii.Quote);}
|
||||
public Php_parser_fxt Msg(Gfo_msg_itm itm, int bgn, int end) {
|
||||
log_mgr_chkr.Add_itm(itm, bgn, end);
|
||||
return this;
|
||||
}
|
||||
public Php_tkn_var_chkr tkn_var(int bgn, int end, String v) {return new Php_tkn_var_chkr(bgn, end).Var_name_(v);}
|
||||
public Php_tkn_num_chkr tkn_num(int bgn, int end, int v) {return new Php_tkn_num_chkr(bgn, end).Num_val_int_(v);}
|
||||
public Php_line_assign_chkr line_assign(String key, Php_itm_chkr_base val) {return new Php_line_assign_chkr().Key_(key).Val_(val);}
|
||||
public Php_line_assign_chkr line_assign_subs(String key, String[] subs, Php_itm_chkr_base val) {return new Php_line_assign_chkr().Key_(key).Subs_(subs).Val_(val);}
|
||||
public Php_itm_chkr_base itm_bool_true() {return new Php_itm_generic_chkr(Php_itm_.Tid_bool_true);}
|
||||
public Php_itm_chkr_base itm_bool_false() {return new Php_itm_generic_chkr(Php_itm_.Tid_bool_false);}
|
||||
public Php_itm_chkr_base itm_null() {return new Php_itm_generic_chkr(Php_itm_.Tid_null);}
|
||||
public Php_itm_chkr_base itm_quote(String v) {return new Php_itm_quote_chkr().Val_obj_str_(v);}
|
||||
public Php_itm_chkr_base itm_int(int v) {return new Php_itm_int_chkr().Val_obj_int_(v);}
|
||||
public Php_itm_chkr_base itm_txt(String v) {return new Php_itm_txt_chkr().Val_obj_str_(v);}
|
||||
public Php_itm_ary_chkr itm_ary() {return new Php_itm_ary_chkr();}
|
||||
public Php_itm_kv_chkr itm_kv_quote(String k, String v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_quote(v));}
|
||||
public Php_itm_kv_chkr itm_kv_txt(String k, String v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_txt(v));}
|
||||
public Php_itm_kv_chkr itm_kv_int(String k, int v) {return new Php_itm_kv_chkr().Key_(k).Val_(itm_int(v));}
|
||||
public Php_itm_kv_chkr itm_kv_itm(String k, Php_itm_chkr_base v) {return new Php_itm_kv_chkr().Key_(k).Val_(v);}
|
||||
public void tst_tkns(String raw, Php_tkn_chkr_base... expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_tkns(raw_bry, tkn_wkr);
|
||||
Php_tkn[] actl = (Php_tkn[])tkn_wkr.List().To_ary(Php_tkn.class);
|
||||
tst_mgr.Vars().Clear().Add("raw_bry", raw_bry);
|
||||
tst_mgr.Tst_ary("", expd, actl);
|
||||
log_mgr_chkr.tst(tst_mgr, tkn_wkr.Msg_log());
|
||||
}
|
||||
public void tst_lines(String raw, Php_line_assign_chkr... expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_tkns(raw_bry, line_wkr);
|
||||
Php_line[] actl = (Php_line[])line_wkr.List().To_ary(Php_line.class);
|
||||
tst_mgr.Vars().Clear().Add("raw_bry", raw_bry);
|
||||
tst_mgr.Tst_ary("", expd, actl);
|
||||
log_mgr_chkr.tst(tst_mgr, line_wkr.Msg_log());
|
||||
}
|
||||
}
|
||||
abstract class Php_tkn_chkr_base implements Tst_chkr {
|
||||
public abstract byte Tkn_tid();
|
||||
public abstract Class<?> TypeOf();
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn = -1;
|
||||
public int Src_end() {return src_end;} private int src_end = -1;
|
||||
public void Src_rng_(int src_bgn, int src_end) {this.src_bgn = src_bgn; this.src_end = src_end;}
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_tkn actl = (Php_tkn)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "tkn_tid", this.Tkn_tid(), actl.Tkn_tid());
|
||||
rv += mgr.Tst_val(src_bgn == -1, path, "src_bgn", src_bgn, actl.Src_bgn());
|
||||
rv += mgr.Tst_val(src_end == -1, path, "src_end", src_end, actl.Src_end());
|
||||
rv += Chk_tkn(mgr, path, actl);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {return 0;}
|
||||
}
|
||||
class Php_tkn_declaration_chkr extends Php_tkn_chkr_base {
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_declaration.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_declaration;}
|
||||
public static final Php_tkn_declaration_chkr Instance = new Php_tkn_declaration_chkr();
|
||||
}
|
||||
class Php_tkn_txt_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_txt_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_txt.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_txt;}
|
||||
}
|
||||
class Php_tkn_ws_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_ws_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_ws.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_ws;}
|
||||
}
|
||||
class Php_tkn_comment_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_comment_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_comment.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_comment;}
|
||||
public Php_tkn_comment_chkr Comment_tid_(byte v) {this.comment_tid = v; return this;} private byte comment_tid = Php_tkn_comment.Tid_null;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_comment actl = (Php_tkn_comment)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(comment_tid == Php_tkn_comment.Tid_null, path, "comment_tid", comment_tid, actl.Comment_tid());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_quote_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_quote_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_quote.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_quote;}
|
||||
public Php_tkn_quote_chkr Quote_tid_(byte v) {this.quote_tid = v; return this;} private byte quote_tid = Byte_ascii.Null;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_quote actl = (Php_tkn_quote)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(quote_tid == Byte_ascii.Null, path, "quote_tid", quote_tid, actl.Quote_tid());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_var_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_var_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_var.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_var;}
|
||||
public Php_tkn_var_chkr Var_name_(String v) {this.var_name = v; return this;} private String var_name;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_var actl = (Php_tkn_var)actl_obj;
|
||||
int rv = 0;
|
||||
byte[] raw_bry = (byte[])mgr.Vars_get_by_key("raw_bry");
|
||||
rv += mgr.Tst_val(var_name == null, path, "var_name", var_name, String_.new_u8(actl.Var_name(raw_bry)));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_num_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_num_chkr(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn_num.class;}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_num;}
|
||||
public Php_tkn_num_chkr Num_val_int_(int v) {this.num_val_int = v; return this;} private int num_val_int = Int_.Min_value;
|
||||
@Override public int Chk_tkn(Tst_mgr mgr, String path, Php_tkn actl_obj) {
|
||||
Php_tkn_num actl = (Php_tkn_num)actl_obj;
|
||||
int rv = 0;
|
||||
byte[] raw_bry = (byte[])mgr.Vars_get_by_key("raw_bry");
|
||||
rv += mgr.Tst_val(num_val_int == Int_.Min_value, path, "num_val_int", num_val_int, actl.Num_val_int(raw_bry));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_tkn_generic_chkr extends Php_tkn_chkr_base {
|
||||
public Php_tkn_generic_chkr(int src_bgn, int src_end, byte tkn_tid) {this.Src_rng_(src_bgn, src_end); this.tkn_tid = tkn_tid;}
|
||||
@Override public Class<?> TypeOf() {return Php_tkn.class;}
|
||||
@Override public byte Tkn_tid() {return tkn_tid;} private byte tkn_tid;
|
||||
}
|
||||
class Php_line_assign_chkr implements Tst_chkr {
|
||||
public Class<?> TypeOf() {return Php_line_assign.class;}
|
||||
public Php_line_assign_chkr Key_(String v) {key = v; return this;} private String key;
|
||||
public Php_line_assign_chkr Subs_(String[] v) {
|
||||
int subs_len = v.length;
|
||||
subs = new Php_itm_quote_chkr[subs_len];
|
||||
for (int i = 0; i < subs_len; i++)
|
||||
subs[i] = new Php_itm_quote_chkr().Val_obj_str_(v[i]);
|
||||
return this;
|
||||
} Php_itm_chkr_base[] subs;
|
||||
public Php_line_assign_chkr Val_(Php_itm_chkr_base v) {val = v; return this;} Php_itm_chkr_base val;
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_line_assign actl = (Php_line_assign)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key().Val_obj_bry()));
|
||||
if (subs != null) rv += mgr.Tst_sub_ary(subs, actl.Key_subs(), "subs", rv);
|
||||
rv += mgr.Tst_sub_obj(val, actl.Val(), "val", rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
abstract class Php_itm_chkr_base implements Tst_chkr {
|
||||
public abstract byte Itm_tid();
|
||||
public abstract Class<?> TypeOf();
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Php_itm actl = (Php_itm)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "tkn_tid", this.Itm_tid(), actl.Itm_tid());
|
||||
rv += Chk_itm(mgr, path, actl);
|
||||
return rv;
|
||||
}
|
||||
@gplx.Virtual public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {return 0;}
|
||||
public static final Php_itm_chkr_base[] Ary_empty = new Php_itm_chkr_base[0];
|
||||
}
|
||||
class Php_itm_generic_chkr extends Php_itm_chkr_base {
|
||||
public Php_itm_generic_chkr(byte itm_tid) {this.itm_tid = itm_tid;} private byte itm_tid;
|
||||
@Override public byte Itm_tid() {return itm_tid;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
}
|
||||
class Php_itm_int_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_int;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_int_chkr Val_obj_int_(int v) {this.val_obj_int = v; return this;} private int val_obj_int;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_int actl = (Php_itm_int)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_int, actl.Val_obj_int());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_txt_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_var;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_txt_chkr Val_obj_str_(String v) {this.val_obj_str = v; return this;} private String val_obj_str;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_var actl = (Php_itm_var)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_u8(actl.Val_obj_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_quote_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_quote;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_quote_chkr Val_obj_str_(String v) {this.val_obj_str = v; return this;} private String val_obj_str;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_quote actl = (Php_itm_quote)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "val_obj_str", val_obj_str, String_.new_u8(actl.Val_obj_bry()));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_ary_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_ary;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_ary_chkr Subs_(Php_itm_chkr_base... v) {this.itms = v; return this;} Php_itm_chkr_base[] itms = Php_itm_chkr_base.Ary_empty;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_ary actl = (Php_itm_ary)actl_obj;
|
||||
int rv = 0;
|
||||
int actl_subs_len = actl.Subs_len();
|
||||
Php_itm[] actl_ary = new Php_itm[actl_subs_len];
|
||||
for (int i = 0; i < actl_subs_len; i++) {
|
||||
actl_ary[i] = (Php_itm)actl.Subs_get(i);
|
||||
}
|
||||
rv += mgr.Tst_sub_ary(itms, actl_ary, "subs", rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Php_itm_kv_chkr extends Php_itm_chkr_base {
|
||||
@Override public byte Itm_tid() {return Php_itm_.Tid_kv;}
|
||||
@Override public Class<?> TypeOf() {return Php_itm.class;}
|
||||
public Php_itm_kv_chkr Key_(String v) {key = v; return this;} private String key;
|
||||
public Php_itm_kv_chkr Val_(Php_itm_chkr_base v) {val = v; return this;} Php_itm_chkr_base val;
|
||||
@Override public int Chk_itm(Tst_mgr mgr, String path, Php_itm actl_obj) {
|
||||
Php_itm_kv actl = (Php_itm_kv)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(false, path, "key", key, String_.new_u8(actl.Key().Val_obj_bry()));
|
||||
rv += mgr.Tst_sub_obj(val, actl.Val(), path, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Gfo_msg_log_chkr implements Tst_chkr {
|
||||
List_adp itms = List_adp_.New();
|
||||
public Class<?> TypeOf() {return Gfo_msg_log.class;}
|
||||
public void Clear() {itms.Clear();}
|
||||
public void Add_itm(Gfo_msg_itm itm, int bgn, int end) {
|
||||
Gfo_msg_data_chkr chkr = new Gfo_msg_data_chkr();
|
||||
chkr.Itm_(itm).Excerpt_bgn_(bgn).Excerpt_end_(end);
|
||||
itms.Add(chkr);
|
||||
}
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {return 0;}
|
||||
public void tst(Tst_mgr mgr, Object actl_obj) {
|
||||
Gfo_msg_log actl = (Gfo_msg_log)actl_obj;
|
||||
int actl_itms_len = actl.Ary_len();
|
||||
Gfo_msg_data[] actl_itms = new Gfo_msg_data[actl_itms_len];
|
||||
for (int i = 0; i < actl_itms_len; i++)
|
||||
actl_itms[i] = actl.Ary_get(i);
|
||||
mgr.Tst_ary("itms", (Gfo_msg_data_chkr[])itms.To_ary(Gfo_msg_data_chkr.class), actl_itms);
|
||||
}
|
||||
}
|
||||
class Gfo_msg_data_chkr implements Tst_chkr {
|
||||
public Class<?> TypeOf() {return Gfo_msg_data.class;}
|
||||
public Gfo_msg_data_chkr Itm_(Gfo_msg_itm v) {itm = v; return this;} Gfo_msg_itm itm;
|
||||
public Gfo_msg_data_chkr Excerpt_bgn_(int v) {excerpt_bgn = v; return this;} private int excerpt_bgn = -1;
|
||||
public Gfo_msg_data_chkr Excerpt_end_(int v) {excerpt_end = v; return this;} private int excerpt_end = -1;
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
|
||||
Gfo_msg_data actl = (Gfo_msg_data)actl_obj;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(itm == null, path, "itm", itm.Path_str(), actl.Item().Path_str());
|
||||
rv += mgr.Tst_val(excerpt_bgn == -1, path, "excerpt_bgn", excerpt_bgn, actl.Src_bgn());
|
||||
rv += mgr.Tst_val(excerpt_end == -1, path, "excerpt_end", excerpt_end, actl.Src_end());
|
||||
return rv;
|
||||
@Test public void Brack_nest_kv() {
|
||||
fxt.tst_lines("$a = ['i00' => ['01', '02'], 'i10' => ['11', '12'], 'i20' => ['21', '22']];"
|
||||
, fxt.line_assign
|
||||
( "a"
|
||||
, fxt.itm_ary().Subs_
|
||||
( fxt.itm_kv_itm("i00", fxt.itm_ary().Subs_(fxt.itm_quote("01"), fxt.itm_quote("02")))
|
||||
, fxt.itm_kv_itm("i10", fxt.itm_ary().Subs_(fxt.itm_quote("11"), fxt.itm_quote("12")))
|
||||
, fxt.itm_kv_itm("i20", fxt.itm_ary().Subs_(fxt.itm_quote("21"), fxt.itm_quote("22")))
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import gplx.xowa.bldrs.wms.*;
|
||||
import gplx.xowa.users.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.addons.*; import gplx.xowa.specials.mgrs.*;
|
||||
import gplx.xowa.parsers.amps.*;
|
||||
public interface Xoa_app extends Gfo_invk {
|
||||
boolean Tid_is_edit();
|
||||
Xoa_app_mode Mode();
|
||||
@@ -64,4 +65,5 @@ public interface Xoa_app extends Gfo_invk {
|
||||
Xob_bldr Bldr();
|
||||
Xoa_special_regy Special_regy();
|
||||
Gfo_thread_mgr Thread_mgr();
|
||||
Xop_amp_mgr Parser_amp_mgr();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "3.7.1.2";
|
||||
public static final String Version = "3.7.2.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -16,16 +16,17 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.dbs.*; import gplx.xowa.wikis.pages.redirects.*; import gplx.xowa.wikis.pages.hdumps.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public interface Xoa_page {
|
||||
Xow_wiki Wiki();
|
||||
Xoa_url Url(); byte[] Url_bry_safe();
|
||||
Xoa_ttl Ttl();
|
||||
boolean Exists();
|
||||
Xopg_revision_data Revision_data();
|
||||
Xopg_db_data Db();
|
||||
Xopg_redirect_data Redirect();
|
||||
Xopg_html_data Html_data();
|
||||
Xopg_lnki_list Redlink_list();
|
||||
byte[] Redirect_to_ttl(); void Redirect_to_ttl_(byte[] v);
|
||||
Xopg_hdump_data Hdump_mgr();
|
||||
|
||||
// Xopg_lnki_list Redlink_list();
|
||||
|
||||
Xoa_page__commons_mgr Commons_mgr();
|
||||
void Xtn_gallery_packed_exists_y_();
|
||||
|
||||
@@ -16,11 +16,14 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*; import gplx.core.log_msgs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.miscs.*;
|
||||
import gplx.xowa.apps.urls.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.langs.cases.*;
|
||||
public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.MW: Ttl.php|secureAndSplit;
|
||||
private int wik_bgn = -1, ns_bgn = -1, page_bgn = 0, leaf_bgn = -1, anch_bgn = -1, root_bgn = -1;
|
||||
private byte[] tors_txt;
|
||||
private Xoa_ttl() {}
|
||||
public Xow_ns Ns() {return ns;} private Xow_ns ns;
|
||||
public boolean ForceLiteralLink() {return forceLiteralLink;} private boolean forceLiteralLink;
|
||||
// NOTE: in procs below, all -1 are used to skip previous delimiters; they will only occur for end_pos arguments
|
||||
@@ -98,37 +101,33 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
int ques_pos = Bry_find_.Find_bwd(full_txt, Byte_ascii.Question, full_txt_len, page_bgn);
|
||||
return Bry_.Mid(full_txt, page_bgn, ques_pos == Bry_find_.Not_found ? full_txt_len : ques_pos);
|
||||
}
|
||||
public static Xoa_ttl parse(Xowe_wiki wiki, int ns_id, byte[] ttl) {
|
||||
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
|
||||
byte[] raw = Bry_.Add(ns.Name_db_w_colon(), ttl);
|
||||
return new_(wiki, wiki.Appe().Msg_log(), raw, 0, raw.length);
|
||||
}
|
||||
public static Xoa_ttl parse(Xowe_wiki wiki, byte[] raw) {return new_(wiki, wiki.Appe().Msg_log(), raw, 0, raw.length);}
|
||||
private static final Object thread_lock = new Object();
|
||||
// $dbkey = preg_replace( '/\xE2\x80[\x8E\x8F\xAA-\xAE]/S', '', $dbkey );
|
||||
// $dbkey = preg_replace( '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u', '_', $dbkey );
|
||||
|
||||
public static final byte Subpage_spr = Byte_ascii.Slash; // EX: A/B/C
|
||||
public static final Xoa_ttl Null = null;
|
||||
|
||||
private static final int Char__bidi = 1, Char__ws = 2;
|
||||
private static final Btrie_slim_mgr char_trie = Btrie_slim_mgr.cs()
|
||||
.Add_many_int(Char__bidi , Bry_.New_by_ints(0xE2, 0x80, 0x8E), Bry_.New_by_ints(0xE2, 0x80, 0x8F), Bry_.New_by_ints(0xE2, 0x80, 0xAA), Bry_.New_by_ints(0xE2, 0x80, 0xAB), Bry_.New_by_ints(0xE2, 0x80, 0xAC), Bry_.New_by_ints(0xE2, 0x80, 0xAD), Bry_.New_by_ints(0xE2, 0x80, 0xAE))
|
||||
.Add_many_int(Char__ws , "\u00A0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u2028", "\u2029", "\u202F", "\u205F", "\u3000")
|
||||
;
|
||||
public static Xoa_ttl new_(Xowe_wiki wiki, Gfo_msg_log msg_log, byte[] src, int bgn, int end) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
Bry_bfr_mkr bry_mkr = app.Utl__bfr_mkr();
|
||||
return parse(bry_mkr, app.Parser_amp_mgr(), wiki.Lang().Case_mgr(), wiki.Xwiki_mgr(), wiki.Ns_mgr(), msg_log, src, bgn, end);
|
||||
} private Xoa_ttl() {}
|
||||
public static Xoa_ttl parse(Bry_bfr_mkr bry_mkr, Xop_amp_mgr amp_mgr, Xol_case_mgr case_mgr, Xow_xwiki_mgr xwiki_mgr, Xow_ns_mgr ns_mgr, Gfo_msg_log msg_log, byte[] src, int bgn, int end) {
|
||||
synchronized (thread_lock) {
|
||||
Xoa_ttl rv = new Xoa_ttl();
|
||||
Bry_bfr bfr = bry_mkr.Get_b512();
|
||||
try {
|
||||
boolean pass = rv.Parse(bfr, bry_mkr, amp_mgr, case_mgr, xwiki_mgr, ns_mgr, msg_log, src, bgn, end);
|
||||
return pass ? rv : null;
|
||||
}
|
||||
finally {bfr.Mkr_rls();}
|
||||
}
|
||||
.Add_many_int(Char__ws , "\u00A0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u2028", "\u2029", "\u202F", "\u205F", "\u3000");
|
||||
|
||||
public static byte[] Replace_spaces(byte[] raw) {return Bry_.Replace(raw, Byte_ascii.Space, Byte_ascii.Underline);}
|
||||
public static byte[] Replace_unders(byte[] raw) {return Replace_unders(raw, 0, raw.length);}
|
||||
public static byte[] Replace_unders(byte[] raw, int bgn, int end) {return Bry_.Replace(raw, bgn, end, Byte_ascii.Underline, Byte_ascii.Space);}
|
||||
|
||||
public static Xoa_ttl Parse(Xow_wiki wiki, byte[] raw) {return Parse(wiki, raw, 0, raw.length);}
|
||||
public static Xoa_ttl Parse(Xow_wiki wiki, int ns_id, byte[] ttl) {
|
||||
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
|
||||
byte[] raw = Bry_.Add(ns.Name_db_w_colon(), ttl);
|
||||
return Parse(wiki, raw, 0, raw.length);
|
||||
}
|
||||
private boolean Parse(Bry_bfr bfr, Bry_bfr_mkr bry_mkr, Xop_amp_mgr amp_mgr, Xol_case_mgr case_mgr, Xow_xwiki_mgr xwiki_mgr, Xow_ns_mgr ns_mgr, Gfo_msg_log msg_log, byte[] src, int bgn, int end) {
|
||||
public static Xoa_ttl Parse(Xow_wiki wiki, byte[] src, int bgn, int end){return Parse(wiki.App().Parser_amp_mgr(), wiki.Lang().Case_mgr(), wiki.Xwiki_mgr(), wiki.Ns_mgr(), src, bgn, end);}
|
||||
public static Xoa_ttl Parse(Xop_amp_mgr amp_mgr, Xol_case_mgr case_mgr, Xow_xwiki_mgr xwiki_mgr, Xow_ns_mgr ns_mgr, byte[] src, int bgn, int end) {
|
||||
Xoa_ttl rv = new Xoa_ttl();
|
||||
Bry_bfr bfr = Bry_bfr_.Get(); // changed from bry_mkr.Get_b512(); DATE:2016-07-06
|
||||
try {return rv.Parse(bfr, amp_mgr, case_mgr, xwiki_mgr, ns_mgr, src, bgn, end) ? rv : null;}
|
||||
finally {bfr.Mkr_rls();}
|
||||
}
|
||||
private boolean Parse(Bry_bfr bfr, Xop_amp_mgr amp_mgr, Xol_case_mgr case_mgr, Xow_xwiki_mgr xwiki_mgr, Xow_ns_mgr ns_mgr, byte[] src, int bgn, int end) {
|
||||
/* This proc will
|
||||
- identify all parts: Wiki, Namespace, Base/Leaf, Anchor; it will also identify Subject/Talk ns
|
||||
- trim whitespace around part delimiters; EX: "Help : Test" --> "Help:Test"; note that it will trim only if the ns part is real; EX: "Helpx : Test" is unchanged
|
||||
@@ -146,12 +145,12 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
Gfo_url_encoder anchor_encoder = null;
|
||||
Bry_bfr anchor_encoder_bfr = null;
|
||||
bfr.Clear();
|
||||
if (end - bgn == 0) {msg_log.Add_itm_none(Xop_ttl_log.Len_0, src, bgn, bgn); return false;}
|
||||
if (end - bgn == 0) return false;
|
||||
this.raw = src;
|
||||
ns = ns_mgr.Ns_main();
|
||||
boolean add_ws = false, ltr_bgn_reset = false;
|
||||
int ltr_bgn = -1, txt_bb_len = 0, colon_count = 0; bfr.Clear();
|
||||
Btrie_slim_mgr amp_trie = amp_mgr.Amp_trie();
|
||||
int ltr_bgn = -1, txt_bb_len = 0, colon_count = 0;
|
||||
Btrie_slim_mgr amp_trie = amp_mgr.Amp_trie(); Btrie_rv trv = null;
|
||||
byte[] b_ary = null;
|
||||
int cur = bgn;
|
||||
int match_pos = -1;
|
||||
@@ -226,10 +225,11 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
int cur2 = cur + 1;//cur = ttlTrie.Match_pos();
|
||||
if (cur2 == end) {} // guards against terminating &; EX: [[Bisc &]]; NOTE: needed b/c Match_bgn does not do bounds checking for cur in src; src[src.length] will be called when & is last character;
|
||||
else {
|
||||
Object html_ent_obj = amp_trie.Match_bgn(src, cur2, end);
|
||||
if (trv == null) trv = new Btrie_rv();
|
||||
Object html_ent_obj = amp_trie.Match_at(trv, src, cur2, end);
|
||||
if (html_ent_obj != null) {
|
||||
Xop_amp_trie_itm amp_itm = (Xop_amp_trie_itm)html_ent_obj;
|
||||
match_pos = amp_trie.Match_pos();
|
||||
match_pos = trv.Pos();
|
||||
if (amp_itm.Tid() == Xop_amp_trie_itm.Tid_name_std) {
|
||||
switch (amp_itm.Char_int()) {
|
||||
case 160: // NOTE:   must convert to space; EX:w:United States [[Image:Dust Bowl - Dallas, South Dakota 1936.jpg|220px|alt=]]
|
||||
@@ -282,10 +282,8 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
cur = find + Xop_comm_lxr.End_ary.length;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
msg_log.Add_itm_none(Xop_ttl_log.Comment_eos, src, bgn, end);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (anch_bgn != -1) {
|
||||
@@ -310,22 +308,20 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
b_ary = anchor_encoder_bfr.To_bry_and_clear();
|
||||
match_pos = cur + 1;
|
||||
}
|
||||
else {
|
||||
msg_log.Add_itm_none(Xop_ttl_log.Invalid_char, src, bgn, end);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ((b & 0xff) > 127) {// PATCH.JAVA:need to convert to unsigned byte
|
||||
Object char_obj = char_trie.Match_bgn_w_byte(b, src, cur, end);
|
||||
if (trv == null) trv = new Btrie_rv();
|
||||
Object char_obj = char_trie.Match_at_w_b0(trv, b, src, cur, end);
|
||||
if (char_obj != null) {
|
||||
int tid = ((Int_obj_val)(char_obj)).Val();
|
||||
cur = trv.Pos();
|
||||
switch (tid) {
|
||||
case Char__bidi: // ignore bidi
|
||||
cur = char_trie.Match_pos();
|
||||
continue;
|
||||
case Char__ws: // treat extended_ws as space; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
|
||||
cur = char_trie.Match_pos();
|
||||
if (ltr_bgn != -1) add_ws = true;
|
||||
continue;
|
||||
}
|
||||
@@ -346,11 +342,8 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
ltr_bgn = -1;
|
||||
}
|
||||
}
|
||||
if (txt_bb_len == 0) {msg_log.Add_itm_none(Xop_ttl_log.Len_0, src, bgn, end); return false;}
|
||||
if (wik_bgn == -1 && page_bgn == txt_bb_len) { // if no wiki, but page_bgn is at end, then ttl is ns only; EX: "Help:"; NOTE: "fr:", "fr:Help" is allowed
|
||||
msg_log.Add_itm_none(Xop_ttl_log.Ttl_is_ns_only, src, bgn, end);
|
||||
return false;
|
||||
}
|
||||
if (txt_bb_len == 0) return false;
|
||||
if (wik_bgn == -1 && page_bgn == txt_bb_len) return false; // if no wiki, but page_bgn is at end, then ttl is ns only; EX: "Help:"; NOTE: "fr:", "fr:Help" is allowed
|
||||
full_txt = bfr.To_bry_and_clear();
|
||||
if ( ns.Case_match() == Xow_ns_case_.Tid__1st
|
||||
&& wik_bgn == -1 ) { // do not check case if xwiki; EX: "fr:" would have a wik_bgn of 0 (and a wik_end of 3); "A" (and any non-xwiki ttl) would have a wik_bgn == -1
|
||||
@@ -362,7 +355,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
if (page_end > full_txt_len) // ttl is too too short for 1st multi-byte char; EX: [[%D0]] is 208 but in utf8, 208 requires at least another char; DATE:2013-11-11
|
||||
return false; // ttl is invalid
|
||||
else { // ttl is long enough for 1st mult-byte char; need to use platform uppercasing; Xol_case_mgr_.Utf_8 is not sufficient
|
||||
Bry_bfr upper_1st = bry_mkr.Get_b512();
|
||||
Bry_bfr upper_1st = Bry_bfr_.Get();
|
||||
byte[] page_txt = case_mgr.Case_build_1st_upper(upper_1st, full_txt, page_bgn, full_txt_len); // always build; never reuse; (multi-byte character will expand array)
|
||||
if (page_bgn == 0) // page only; EX: A
|
||||
full_txt = page_txt;
|
||||
@@ -379,17 +372,6 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
// tors_txt = tors_ns == null ? Bry_.Empty : tors_ns.Name_ui_w_colon();
|
||||
return true;
|
||||
}
|
||||
public static byte[] Replace_spaces(byte[] raw) {return Bry_.Replace(raw, Byte_ascii.Space, Byte_ascii.Underline);}
|
||||
public static byte[] Replace_unders(byte[] raw) {return Replace_unders(raw, 0, raw.length);}
|
||||
public static byte[] Replace_unders(byte[] raw, int bgn, int end) {return Bry_.Replace(raw, bgn, end, Byte_ascii.Underline, Byte_ascii.Space);}
|
||||
private int wik_bgn = -1, ns_bgn = -1, page_bgn = 0, leaf_bgn = -1, anch_bgn = -1, root_bgn = -1;
|
||||
private byte[] tors_txt;
|
||||
public static final int Wik_bgn_int = -1;
|
||||
public static final byte Subpage_spr = Byte_ascii.Slash; // EX: A/B/C
|
||||
public static final int Anch_bgn_anchor_only = 1; // signifies lnki which is only anchor; EX: [[#anchor]]
|
||||
public static final int Max_len = 2048; // ASSUME: max len of 256 * 8 bytes
|
||||
public static final int Null_wik_bgn = -1;
|
||||
public static final Xoa_ttl Null = null;
|
||||
}
|
||||
class Xoa_ttl_trie {
|
||||
public static Btrie_fast_mgr new_() {
|
||||
|
||||
@@ -108,7 +108,8 @@ public class Xoa_url {
|
||||
}
|
||||
public static final Xoa_url Null = null;
|
||||
public static Xoa_url blank() {return new Xoa_url();}
|
||||
public static Xoa_url new_(byte[] wiki, byte[] page) {
|
||||
public static Xoa_url New(Xow_wiki wiki, Xoa_ttl ttl) {return New(wiki.Domain_bry(), ttl.Full_txt_w_ttl_case());}
|
||||
public static Xoa_url New(byte[] wiki, byte[] page) {
|
||||
Xoa_url rv = new Xoa_url();
|
||||
rv.Wiki_bry_(wiki);
|
||||
rv.Page_bry_(page);
|
||||
|
||||
@@ -144,7 +144,7 @@ public class Xoae_app implements Xoa_app, Gfo_invk {
|
||||
|
||||
public Xosrv_server Tcp_server() {return tcp_server;} private Xosrv_server tcp_server = new Xosrv_server();
|
||||
public Http_server_mgr Http_server() {return http_server;} private Http_server_mgr http_server;
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = Xop_amp_mgr.Instance;
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private final Xop_amp_mgr parser_amp_mgr = Xop_amp_mgr.Instance;
|
||||
|
||||
private Xoa_fmtr_mgr fmtr_mgr;
|
||||
public Number_parser Utl_num_parser() {return utl_num_parser;} private Number_parser utl_num_parser = new Number_parser();
|
||||
@@ -186,13 +186,13 @@ public class Xoae_app implements Xoa_app, Gfo_invk {
|
||||
user.App_term(); usr_dlg.Log_many("", "", "term:app_term");
|
||||
log_wtr.Log_term(); usr_dlg.Log_many("", "", "term:log_wtr");
|
||||
log_mgr.Rls(); usr_dlg.Log_many("", "", "term:log_mgr");
|
||||
if (Scrib_core.Core() != null) {Scrib_core.Core().Term(); usr_dlg.Log_many("", "", "term:scrib");}
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all();
|
||||
wiki_mgr.Rls(); usr_dlg.Log_many("", "", "term:wiki_mgr");
|
||||
return true;
|
||||
}
|
||||
public void Reset_all() {
|
||||
this.Free_mem(true);
|
||||
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all();
|
||||
Env_.GarbageCollect();
|
||||
}
|
||||
public void Free_mem(boolean clear_ctx) {
|
||||
|
||||
@@ -20,49 +20,44 @@ import gplx.xowa.langs.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.xtns.cites.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.htmls.modules.popups.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.htmls.modules.popups.*;
|
||||
import gplx.xowa.wikis.pages.dbs.*; import gplx.xowa.wikis.pages.redirects.*; import gplx.xowa.wikis.pages.hdumps.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xoae_page implements Xoa_page {
|
||||
Xoae_page(Xowe_wiki wiki, Xoa_ttl ttl) {
|
||||
this.wiki = wiki; this.ttl = ttl;
|
||||
this.lang = wiki.Lang(); // default to wiki.lang; can be override later by wikitext
|
||||
hdr_mgr = new Xow_hdr_mgr(this);
|
||||
redlink_list = new Xopg_lnki_list().Disabled_(ttl.Ns().Id_is_module());
|
||||
html.Init_by_page(ttl);
|
||||
Ttl_(ttl);
|
||||
} Xoae_page() {} // called by Empty
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
public Xoa_ttl Ttl() {return ttl;} public Xoae_page Ttl_(Xoa_ttl v) {ttl = v; url.Wiki_bry_(wiki.Domain_bry()).Page_bry_(v.Full_url()); return this;} private Xoa_ttl ttl;
|
||||
public Xoa_url Url() {return url;} public Xoae_page Url_(Xoa_url v) {url = v; return this;} private Xoa_url url = Xoa_url.blank();
|
||||
public byte[] Url_bry_safe() {return url == null ? Bry_.Empty : url.Raw();}
|
||||
public boolean Exists() {return !Missing();}
|
||||
public void Xtn_gallery_packed_exists_y_() {html_data.Xtn_gallery_packed_exists_y_();}
|
||||
public boolean Xtn__timeline_exists() {return false;} // drd always sets timeline
|
||||
public boolean Xtn__gallery_exists() {return false;} // drd does not need to set gallery.style.css
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
|
||||
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list;
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
public Xoa_ttl Ttl() {return ttl;} public Xoae_page Ttl_(Xoa_ttl v) {ttl = v; url.Wiki_bry_(wiki.Domain_bry()).Page_bry_(v.Full_url()); return this;} private Xoa_ttl ttl;
|
||||
public Xoa_url Url() {return url;} public Xoae_page Url_(Xoa_url v) {url = v; return this;} private Xoa_url url = Xoa_url.blank();
|
||||
public byte[] Url_bry_safe() {return url == null ? Bry_.Empty : url.Raw();}
|
||||
public Xopg_db_data Db() {return db;} private final Xopg_db_data db = new Xopg_db_data();
|
||||
public Xopg_redirect_data Redirect() {return redirect;} private final Xopg_redirect_data redirect = new Xopg_redirect_data();
|
||||
public Xopg_html_data Html_data() {return html;} private final Xopg_html_data html = new Xopg_html_data();
|
||||
public Xopg_hdump_data Hdump_mgr() {return hdump;} private final Xopg_hdump_data hdump = new Xopg_hdump_data();
|
||||
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public void Xtn_gallery_packed_exists_y_() {html.Xtn_gallery_packed_exists_y_();}
|
||||
public boolean Xtn__timeline_exists() {return false;} // drd always sets timeline
|
||||
public boolean Xtn__gallery_exists() {return false;} // drd does not need to set gallery.style.css
|
||||
|
||||
public Xowe_wiki Wikie() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xol_lang_itm Lang() {return lang;} public Xoae_page Lang_(Xol_lang_itm v) {lang = v; return this;} private Xol_lang_itm lang;
|
||||
public Xopg_tab_data Tab_data() {return tab_data;} private final Xopg_tab_data tab_data = new Xopg_tab_data();
|
||||
public Xopg_hdump_data Hdump_data() {return hdump_data;} private final Xopg_hdump_data hdump_data = new Xopg_hdump_data();
|
||||
public boolean Missing() {return missing;} public Xoae_page Missing_() {return Missing_(true);} public Xoae_page Missing_(boolean v) {missing = v; return this;} private boolean missing;
|
||||
public boolean Redirected() {return redirected;} public Xoae_page Redirected_(boolean v) {redirected = v; return this;} private boolean redirected;
|
||||
public List_adp Redirected_ttls() {return redirected_ttls;} private List_adp redirected_ttls = List_adp_.New();
|
||||
public byte[] Redirected_ttls__itm_0() {return (byte[])redirected_ttls.Get_at(0);}
|
||||
public byte[] Redirected_src() {return redirected_src;} public void Redirected_src_(byte[] v) {this.redirected_src = v;} private byte[] redirected_src;
|
||||
public byte Edit_mode() {return edit_mode;} private byte edit_mode; public void Edit_mode_update_() {edit_mode = Xoa_page_.Edit_mode_update;}
|
||||
public Xop_root_tkn Root() {return root;} public Xoae_page Root_(Xop_root_tkn v) {root = v; return this;} private Xop_root_tkn root;
|
||||
public byte[] Data_raw() {return data_raw;} public Xoae_page Data_raw_(byte[] v) {data_raw = v; return this;} private byte[] data_raw = Bry_.Empty;
|
||||
public Xow_hdr_mgr Hdr_mgr() {return hdr_mgr;} private Xow_hdr_mgr hdr_mgr;
|
||||
|
||||
public Xoh_cmd_mgr Html_cmd_mgr() {return html_cmd_mgr;} private Xoh_cmd_mgr html_cmd_mgr = new Xoh_cmd_mgr();
|
||||
public byte[][] Category_list() {return category_list;} public Xoae_page Category_list_(byte[][] v) {category_list = v; return this;} private byte[][] category_list = new byte[0][];
|
||||
public List_adp Lnki_list() {return lnki_list;} public void Lnki_list_(List_adp v) {this.lnki_list = v;} private List_adp lnki_list = List_adp_.New();
|
||||
public Xof_xfer_queue File_queue() {return file_queue;} private Xof_xfer_queue file_queue = new Xof_xfer_queue();
|
||||
public List_adp File_math() {return file_math;} private List_adp file_math = List_adp_.New();
|
||||
public Xow_hdr_mgr Hdr_mgr() {return hdr_mgr;} private Xow_hdr_mgr hdr_mgr;
|
||||
public List_adp Lnki_list() {return lnki_list;} public void Lnki_list_(List_adp v) {this.lnki_list = v;} private List_adp lnki_list = List_adp_.New();
|
||||
public Ref_itm_mgr Ref_mgr() {return ref_mgr;} private Ref_itm_mgr ref_mgr = new Ref_itm_mgr(); public void Ref_mgr_(Ref_itm_mgr v) {this.ref_mgr = v;}
|
||||
public Xopg_popup_mgr Popup_mgr() {return popup_mgr;} private Xopg_popup_mgr popup_mgr = new Xopg_popup_mgr();
|
||||
public byte[][] Category_list() {return category_list;} public Xoae_page Category_list_(byte[][] v) {category_list = v; return this;} private byte[][] category_list = new byte[0][];
|
||||
public List_adp Slink_list() {return slink_list;} private List_adp slink_list = List_adp_.New();
|
||||
public Wdata_external_lang_links_data Wdata_external_lang_links() {return wdata_external_lang_links;} private Wdata_external_lang_links_data wdata_external_lang_links = new Wdata_external_lang_links_data();
|
||||
public boolean Pages_recursed() {return pages_recursed;} public void Pages_recursed_(boolean v) {pages_recursed = v; } private boolean pages_recursed;
|
||||
@@ -84,29 +79,34 @@ public class Xoae_page implements Xoa_page {
|
||||
} private byte[][] tmpl_stack_ary = Bry_.Ary_empty; private int tmpl_stack_ary_len = 0, tmpl_stack_ary_max = 0;
|
||||
public void Clear_all() {Clear(true);}
|
||||
public void Clear(boolean clear_scrib) { // NOTE: this is called post-fetch but pre-parse; do not clear items set by post-fetch, such as id, ttl, redirected_ttls, data_raw
|
||||
db.Clear();
|
||||
redirect.Clear();
|
||||
html.Clear();
|
||||
hdump.Clear();
|
||||
|
||||
hdr_mgr.Clear();
|
||||
lnki_list.Clear();
|
||||
file_math.Clear();
|
||||
file_queue.Clear();
|
||||
ref_mgr.Grps_clear();
|
||||
html_cmd_mgr.Clear();
|
||||
hdump_data.Clear();
|
||||
wdata_external_lang_links.Reset();
|
||||
if (clear_scrib) gplx.xowa.xtns.scribunto.Scrib_core.Core_page_changed(this);
|
||||
if (clear_scrib) wiki.Parser_mgr().Scrib().Core_page_changed(this);
|
||||
slink_list.Clear();
|
||||
html_data.Clear();
|
||||
tab_data.Clear();
|
||||
pages_recursed = false;
|
||||
tmpl_stack_ary = Bry_.Ary_empty;
|
||||
tmpl_stack_ary_len = tmpl_stack_ary_max = 0;
|
||||
popup_mgr.Clear();
|
||||
revision_data.Clear();
|
||||
tmpl_prepend_mgr.Clear();
|
||||
commons_mgr.Clear();
|
||||
}
|
||||
private Xoae_page Edit_mode_create_() {edit_mode = Xoa_page_.Edit_mode_create; return this;}
|
||||
public static final Xoae_page Empty = new Xoae_page().Missing_();
|
||||
public static final Xoae_page Empty = new Xoae_page();
|
||||
public static Xoae_page New(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl);}
|
||||
public static Xoae_page New_test(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl);}
|
||||
public static Xoae_page New_edit(Xowe_wiki wiki, Xoa_ttl ttl) {return new Xoae_page(wiki, ttl).Edit_mode_create_();}
|
||||
public static Xoae_page New_edit(Xowe_wiki wiki, Xoa_ttl ttl) {
|
||||
Xoae_page rv = new Xoae_page(wiki, ttl);
|
||||
rv.edit_mode = Xoa_page_.Edit_mode_create;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Xop_fxt {
|
||||
return this;
|
||||
}
|
||||
public Xoa_ttl Page_ttl_(String txt) {
|
||||
Xoa_ttl rv = Xoa_ttl.parse(wiki, Bry_.new_u8(txt));
|
||||
Xoa_ttl rv = Xoa_ttl.Parse(wiki, Bry_.new_u8(txt));
|
||||
ctx.Page().Ttl_(rv);
|
||||
return rv;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ public class Xop_fxt {
|
||||
public Xop_fxt Init_page_create(String ttl, String txt) {return Init_page_create(wiki, ttl, txt);}
|
||||
public Xop_fxt Init_page_create(Xowe_wiki wiki, String ttl, String txt) {Init_page_create_static(wiki, ttl, txt);return this;}
|
||||
public static void Init_page_create_static(Xowe_wiki wiki, String ttl_str, String text_str) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str));
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
|
||||
byte[] text = Bry_.new_u8(text_str);
|
||||
wiki.Db_mgr().Save_mgr().Data_create(ttl, text);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class Xop_fxt {
|
||||
}
|
||||
public Xop_fxt Init_page_update(String ttl, String txt) {return Init_page_update(wiki, ttl, txt);}
|
||||
public Xop_fxt Init_page_update(Xowe_wiki wiki, String ttl, String txt) {
|
||||
Xoa_ttl page_ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl));
|
||||
Xoa_ttl page_ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl));
|
||||
byte[] page_raw = Bry_.new_u8(txt);
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(page_ttl);
|
||||
wiki.Db_mgr().Save_mgr().Data_update(page, page_raw);
|
||||
@@ -221,7 +221,7 @@ public class Xop_fxt {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Xop_root_tkn root = tkn_mkr.Root(raw_bry);
|
||||
ctx.Page().Root_(root);
|
||||
ctx.Page().Data_raw_(raw_bry);
|
||||
ctx.Page().Db().Text().Text_bry_(raw_bry);
|
||||
return parser.Parse_text_to_wtxt(root, ctx, tkn_mkr, raw_bry);
|
||||
}
|
||||
public Xot_defn_tmpl run_Parse_tmpl(byte[] name, byte[] raw) {return parser.Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), wiki.Ns_mgr().Ns_template(), name, raw);}
|
||||
@@ -349,9 +349,9 @@ public class Xop_fxt {
|
||||
}
|
||||
public static byte[] Load_page(Xowe_wiki wiki, String ttl_str) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_url page_url = Xoa_url.new_(wiki.Domain_bry(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
return wiki.Data_mgr().Load_page_and_parse(page_url, ttl).Data_raw();
|
||||
Xoa_url page_url = Xoa_url.New(wiki.Domain_bry(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
return wiki.Data_mgr().Load_page_and_parse(page_url, ttl).Db().Text().Text_bry();
|
||||
}
|
||||
public static void Reg_xwiki_alias(Xowe_wiki wiki, String alias, String domain) {
|
||||
byte[] domain_bry = Bry_.new_a7(domain);
|
||||
@@ -436,7 +436,7 @@ public class Xop_fxt {
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump;
|
||||
Xoh_html_wtr html_wtr = wiki.Html_mgr().Html_wtr();
|
||||
html_wtr.Cfg().Toc__show_(Bool_.Y); // needed for hdr to show <span class='mw-headline' id='A'>
|
||||
ctx.Page().Redlink_list().Clear();
|
||||
ctx.Page().Html_data().Redlink_list().Clear();
|
||||
html_wtr.Write_all(tmp_bfr, ctx, hctx, src_bry, root);
|
||||
// Tfds.Dbg(tmp_bfr.To_str());
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
|
||||
@@ -79,9 +79,9 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm {
|
||||
}
|
||||
public Gfo_evt_mgr Evt_mgr() {return ev_mgr;} private final Gfo_evt_mgr ev_mgr;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public Xoa_ttl Ttl_parse(byte[] ttl) {return Xoa_ttl.parse(this, ttl);}
|
||||
public Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end) {return Xoa_ttl.new_(this, app.Msg_log(), src, src_bgn, src_end);}
|
||||
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {return Xoa_ttl.parse(this, ns_id, ttl);}
|
||||
public Xoa_ttl Ttl_parse(byte[] ttl) {return Xoa_ttl.Parse(this, ttl);}
|
||||
public Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end) {return Xoa_ttl.Parse(this, src, src_bgn, src_end);}
|
||||
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {return Xoa_ttl.Parse(this, ns_id, ttl);}
|
||||
public boolean Type_is_edit() {return Bool_.Y;}
|
||||
public Xoa_app App() {return app;}
|
||||
public Xol_lang_itm Lang() {return lang;} private final Xol_lang_itm lang;
|
||||
|
||||
@@ -35,6 +35,6 @@ public class Xowe_wiki_ {
|
||||
public static void Rls_mem(Xowe_wiki wiki, boolean clear_ctx) {
|
||||
wiki.Appe().Free_mem(clear_ctx);
|
||||
wiki.Cache_mgr().Free_mem_all();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
|
||||
wiki.Parser_mgr().Scrib().Core_term();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,11 @@ public class Xolog_special implements Xow_special_page {
|
||||
}
|
||||
|
||||
if (redirect) {
|
||||
String redirect_ttl = special__meta.Ttl_str() + "?cmd=view";
|
||||
String redirect_ttl_str = special__meta.Ttl_str() + "?cmd=view";
|
||||
if (redirect_to_same_file && file != null)
|
||||
redirect_ttl += "&file=" + file;
|
||||
page.Redirect_to_ttl_(Bry_.new_u8(redirect_ttl));
|
||||
redirect_ttl_str += "&file=" + file;
|
||||
Xoa_ttl redirect_ttl = wiki.Ttl_parse(Bry_.new_u8(redirect_ttl_str));
|
||||
page.Redirect().Itms__add__special(Xoa_url.New(wiki, redirect_ttl), redirect_ttl);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -87,7 +87,7 @@ class Reindex_html_dbs_cmd {
|
||||
Db_stmt stmt_update = core_conn.Stmt_update(tbl_page, String_.Ary(fld_page_id), fld_page_html_db_id);
|
||||
Xoh_page_tbl_itm trg_html_tbl = null;
|
||||
try {
|
||||
Xoh_page_row src_html_row = new Xoh_page_row();
|
||||
Xowd_html_row src_html_row = new Xowd_html_row();
|
||||
long trg_db_size = 0;
|
||||
int ns_cur = -1, part_id = 0;
|
||||
int trg_db = -1;
|
||||
|
||||
@@ -21,15 +21,15 @@ import gplx.xowa.addons.bldrs.exports.splits.metas.*; import gplx.xowa.addons.bl
|
||||
import gplx.xowa.htmls.core.dbs.*;
|
||||
public class Split_wkr__html implements Split_wkr {
|
||||
private Xoh_src_tbl_mgr src_tbl_mgr;
|
||||
private Xoh_page_tbl tbl; private Db_stmt stmt;
|
||||
private final Xoh_page_row trg_itm = new Xoh_page_row();
|
||||
private Xowd_html_tbl tbl; private Db_stmt stmt;
|
||||
private final Xowd_html_row trg_itm = new Xowd_html_row();
|
||||
private final Split_rslt_wkr__html rslt_wkr = new Split_rslt_wkr__html();
|
||||
public void Split__init(Split_ctx ctx, Xow_wiki wiki, Db_conn wkr_conn) {
|
||||
this.src_tbl_mgr = new Xoh_src_tbl_mgr(wiki);
|
||||
ctx.Rslt_mgr().Reg_wkr(rslt_wkr);
|
||||
}
|
||||
public void Split__trg__nth__new(Split_ctx ctx, Db_conn trg_conn) {
|
||||
this.tbl = new Xoh_page_tbl(trg_conn);
|
||||
this.tbl = new Xowd_html_tbl(trg_conn);
|
||||
Dbmeta_fld_list trg_flds = Make_flds_for_split(tbl.Flds());
|
||||
trg_conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl.Tbl_name(), trg_flds));
|
||||
this.stmt = trg_conn.Stmt_insert(tbl.Tbl_name(), trg_flds);
|
||||
@@ -52,7 +52,7 @@ public class Split_wkr__html implements Split_wkr {
|
||||
byte[] sidebar_div = trg_itm.Sidebar_div();
|
||||
|
||||
// calc db_idx based on db_size
|
||||
int db_row_size = Xoh_page_row.Db_row_size_fixed + display_ttl.length + content_sub.length + sidebar_div.length + body_len;
|
||||
int db_row_size = Xowd_html_row.Db_row_size_fixed + display_ttl.length + content_sub.length + sidebar_div.length + body_len;
|
||||
int trg_db_id = ctx.Html_size_calc().Size_cur_add_(db_row_size);
|
||||
|
||||
// do insert
|
||||
|
||||
@@ -22,10 +22,10 @@ public class Xoh_page_tbl_itm {
|
||||
public Xoh_page_tbl_itm(boolean trg, int db_id, Db_conn conn) {
|
||||
this.trg = trg;
|
||||
this.db_id = db_id;
|
||||
this.html_tbl = new Xoh_page_tbl(conn);
|
||||
this.html_tbl = new Xowd_html_tbl(conn);
|
||||
}
|
||||
public int Db_id() {return db_id;} private final int db_id;
|
||||
public Xoh_page_tbl Html_tbl() {return html_tbl;} private final Xoh_page_tbl html_tbl;
|
||||
public Xowd_html_tbl Html_tbl() {return html_tbl;} private final Xowd_html_tbl html_tbl;
|
||||
public void Rls() {
|
||||
html_tbl.Conn().Rls_conn();
|
||||
if (trg) html_tbl.Conn().Env_vacuum();
|
||||
|
||||
@@ -86,7 +86,7 @@ class Split_tbl__html implements Split_tbl {
|
||||
public boolean Layout_is_lot() {return Bool_.Y;}
|
||||
public String[] Fld_pkeys() {return String_.Ary("page_id");}
|
||||
public String Fld_blob() {return "body";}
|
||||
public Dbmeta_fld_list Flds() {if (flds == null) flds = new gplx.xowa.htmls.core.dbs.Xoh_page_tbl(Db_conn_.Noop).Flds(); return flds;} private Dbmeta_fld_list flds;
|
||||
public Dbmeta_fld_list Flds() {if (flds == null) flds = new gplx.xowa.htmls.core.dbs.Xowd_html_tbl(Db_conn_.Noop).Flds(); return flds;} private Dbmeta_fld_list flds;
|
||||
public Db_conn Wiki_conn__get_or_new(Xow_wiki wiki, int db_id) {
|
||||
if (db_id == -1) // HACK: return core_conn just so that bin_tbl below can be created
|
||||
return wiki.Data__core_mgr().Db__core().Conn();
|
||||
|
||||
@@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.addons.bldrs.files.cmds.*;
|
||||
import gplx.xowa.addons.bldrs.mass_parses.inits.*;
|
||||
import gplx.xowa.addons.bldrs.mass_parses.makes.*;
|
||||
public class Xoax_builds_files_addon implements Xoax_addon_itm, Xoax_addon_itm__bldr {
|
||||
public Xob_cmd[] Bldr_cmds() {
|
||||
return new Xob_cmd[]
|
||||
@@ -38,6 +40,9 @@ public class Xoax_builds_files_addon implements Xoax_addon_itm, Xoax_addon_itm__
|
||||
, Xobldr__text_db__drop_page.Prototype
|
||||
, Xobldr__redirect__create.Prototype
|
||||
, Xobldr__image__create.Prototype
|
||||
|
||||
, Xomp_init_cmd.Prototype
|
||||
, Xomp_parse_cmd.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.addons.bldrs.files.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.files.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.htmls.core.bldrs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.wikis.data.*;
|
||||
class Xob_hdump_tbl_retriever__ns_to_db implements Xob_hdump_tbl_retriever {
|
||||
private final Xob_ns_to_db_mgr ns_to_db_mgr;
|
||||
public Xob_hdump_tbl_retriever__ns_to_db(Xowe_wiki wiki) {
|
||||
Xow_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, wiki.Appe().Api_root().Bldr().Wiki().Import().Html_db_max());
|
||||
Xob_ns_file_itm.Init_ns_bldr_data(Xow_db_file_.Tid__html_data, wiki.Ns_mgr(), gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import.Ns_file_map__each);
|
||||
}
|
||||
public Xowd_html_tbl Get_html_tbl(Xow_ns ns, int prv_row_len) {
|
||||
Xow_db_file html_db = ns_to_db_mgr.Get_by_ns(ns.Bldr_data(), prv_row_len); // get html_db
|
||||
return html_db.Tbl__html();
|
||||
}
|
||||
public void Commit() {ns_to_db_mgr.Commit();}
|
||||
public void Rls_all() {ns_to_db_mgr.Rls_all();}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
Xob_db_file make_db = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir());
|
||||
Db_conn make_conn = make_db.Conn();
|
||||
this.tbl = new Xob_lnki_temp_tbl(make_conn); tbl.Create_tbl();
|
||||
this.gen_hdump = hdump_bldr.Init(wiki, make_conn);
|
||||
this.gen_hdump = hdump_bldr.Init(wiki, make_conn, new Xob_hdump_tbl_retriever__ns_to_db(wiki));
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) {
|
||||
this.converter_lang = vnt_mgr.Convert_lang();
|
||||
@@ -58,8 +58,10 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
ns_file_is_case_match_all = Ns_file_is_case_match_all(wiki); // NOTE: must call after wiki.init
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Ctgs_enabled_(false); // disable categories else progress messages written (also for PERF)
|
||||
if (wiki.File__bin_mgr() != null)
|
||||
wiki.File__bin_mgr().Wkrs__del(gplx.xowa.files.bins.Xof_bin_wkr_.Key_http_wmf); // remove wmf wkr, else will try to download images during parsing
|
||||
wiki.File__bin_mgr().Wkrs__del(gplx.xowa.files.bins.Xof_bin_wkr_.Key_http_wmf); // remove wmf wkr, else will try to download images during parsing
|
||||
commons_wiki = app.Wiki_mgr().Get_by_or_make(Xow_domain_itm_.Bry__commons);
|
||||
|
||||
// init log_mgr / property_wkr
|
||||
Xop_log_mgr log_mgr = ctx.App().Log_mgr();
|
||||
log_mgr.Log_dir_(wiki.Fsys_mgr().Root_dir()); // put log in wiki dir, instead of user.temp
|
||||
invoke_wkr = this.Invoke_wkr(); // set member reference
|
||||
@@ -68,20 +70,25 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
property_wkr = log_mgr.Make_wkr_property();
|
||||
wiki.Appe().Wiki_mgr().Wdata_mgr().Enabled_(wdata_enabled);
|
||||
if (!xtn_ref_enabled) gplx.xowa.xtns.cites.References_nde.Enabled = false;
|
||||
|
||||
// init log wkrs
|
||||
gplx.xowa.xtns.gallery.Gallery_xnde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y);
|
||||
gplx.xowa.xtns.imaps.Imap_xnde.Log_wkr = log_mgr.Make_wkr();
|
||||
gplx.xowa.parsers.xndes.Xop_xnde_wkr.Timeline_log_wkr = log_mgr.Make_wkr();
|
||||
gplx.xowa.xtns.scores.Score_xnde.Log_wkr = log_mgr.Make_wkr();
|
||||
gplx.xowa.xtns.hieros.Hiero_xnde.Log_wkr = log_mgr.Make_wkr();
|
||||
gplx.xowa.xtns.math.Math_nde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y); // enabled; DATE:2015-10-10
|
||||
|
||||
// init fsdb
|
||||
Xof_fsdb_mgr__sql trg_fsdb_mgr = new Xof_fsdb_mgr__sql();
|
||||
wiki.File__fsdb_mode().Tid_v2_bld_y_();
|
||||
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
|
||||
trg_fsdb_mgr.Init_by_wiki(wiki);
|
||||
Fsm_mnt_mgr trg_mnt_mgr = trg_fsdb_mgr.Mnt_mgr();
|
||||
wiki.File_mgr().Init_file_mgr_by_load(wiki); // must happen after fsdb.make
|
||||
wiki.File__bin_mgr().Wkrs__del(gplx.xowa.files.bins.Xof_bin_wkr_.Key_http_wmf); // must happen after init_file_mgr_by_load; remove wmf wkr, else will try to download images during parsing
|
||||
wiki.File__bin_mgr().Wkrs__del(gplx.xowa.files.bins.Xof_bin_wkr_.Key_http_wmf); // must happen after init_file_mgr_by_load; remove wmf wkr, else will try to download images during parsing
|
||||
wiki.File__orig_mgr().Wkrs_del(gplx.xowa.files.origs.Xof_orig_wkr_.Tid_wmf_api);
|
||||
|
||||
trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(fsdb_core);
|
||||
trg_mnt_mgr.Mnts__get_insert_idx_(Fsm_mnt_mgr.Mnt_idx_main);
|
||||
Fsm_mnt_mgr.Patch(trg_mnt_mgr.Mnts__get_main().Cfg_mgr().Tbl()); // NOTE: see fsdb_make; DATE:2014-04-26
|
||||
@@ -89,21 +96,23 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
log_mgr.Txn_bgn();
|
||||
}
|
||||
@Override public void Exec_pg_itm_hook(int ns_ord, Xow_ns ns, Xowd_page_itm db_page, byte[] page_src) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ns.Gen_ttl(db_page.Ttl_page_db()));
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ns.Gen_ttl(db_page.Ttl_page_db()));
|
||||
byte[] ttl_bry = ttl.Page_db();
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), ns.Id(), ttl_bry);
|
||||
if (page_tid != Xow_page_tid.Tid_wikitext) return; // ignore js, css, lua, json
|
||||
Xoae_page page = ctx.Page();
|
||||
page.Clear_all();
|
||||
page.Bldr__ns_ord_(ns_ord);
|
||||
page.Ttl_(ttl).Revision_data().Id_(db_page.Id());
|
||||
page.Redlink_list().Clear();
|
||||
page.Url_(Xoa_url.new_(wiki.Domain_bry(), ttl.Full_db()));
|
||||
page.Ttl_(ttl);
|
||||
page.Db().Page().Id_(db_page.Id());
|
||||
page.Html_data().Redlink_list().Clear();
|
||||
page.Url_(Xoa_url.New(wiki, ttl));
|
||||
if (ns.Id_is_tmpl())
|
||||
parser.Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), wiki.Ns_mgr().Ns_template(), ttl_bry, page_src);
|
||||
else {
|
||||
parser.Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), page_src);
|
||||
if (gen_html && !page.Redirected())
|
||||
if ( gen_html
|
||||
&& page.Redirect().Itms__len() == 0) // don't generate html for redirected pages
|
||||
wiki.Html_mgr().Page_wtr_mgr().Gen(ctx.Page().Root_(root), Xopg_page_.Tid_read);
|
||||
if (gen_hdump)
|
||||
hdump_bldr.Insert(page.Root_(root));
|
||||
@@ -119,9 +128,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
}
|
||||
@Override public void Exec_end_hook() {
|
||||
// if (converter_lang != null) converter_lang.Log__rls();
|
||||
if (gen_hdump) {
|
||||
hdump_bldr.Bld_term();
|
||||
}
|
||||
if (gen_hdump) hdump_bldr.Term();
|
||||
String err_filter_mgr = invoke_wkr.Err_filter_mgr().Print();
|
||||
if (String_.Len_gt_0(err_filter_mgr)) usr_dlg.Warn_many("", "", err_filter_mgr);
|
||||
wiki.Appe().Log_mgr().Txn_end();
|
||||
@@ -139,7 +146,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
usr_dlg.Warn_many("", "", "page and thumbtime both set; this may be an issue with fsdb: page=~{0} ttl=~{1}", ctx.Page().Ttl().Page_db_as_str(), String_.new_u8(ttl));
|
||||
if (lnki.Ns_id() == Xow_ns_.Tid__media)
|
||||
caller_tid = Xop_file_logger_.Tid__media;
|
||||
tbl.Insert_cmd_by_batch(ctx.Page().Bldr__ns_ord(), ctx.Page().Revision_data().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki.Lnki_type(), caller_tid, lnki.W(), lnki.H(), lnki.Upright(), lnki_time, lnki_page);
|
||||
tbl.Insert_cmd_by_batch(ctx.Page().Bldr__ns_ord(), ctx.Page().Db().Page().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki.Lnki_type(), caller_tid, lnki.W(), lnki.H(), lnki.Upright(), lnki_time, lnki_page);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_wdata_enabled_)) wdata_enabled = m.ReadYn("v");
|
||||
@@ -172,7 +179,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
}
|
||||
public static byte[] Xto_commons(boolean ns_file_is_case_match_all, Xowe_wiki commons_wiki, byte[] ttl_bry) {
|
||||
if (!ns_file_is_case_match_all) return null; // return "" if wiki matches common
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(commons_wiki, Xow_ns_.Tid__file, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(commons_wiki, Xow_ns_.Tid__file, ttl_bry);
|
||||
byte[] rv = ttl.Page_db();
|
||||
return Bry_.Eq(rv, ttl_bry) ? null : rv;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Xobc_info_html extends Xow_special_wtr__base {
|
||||
long total_size = 0;
|
||||
Bry_bfr tmp_size_bfr = Bry_bfr_.New();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int step_id = (int)list.Get_at(i);
|
||||
int step_id = Int_.cast(list.Get_at(i));
|
||||
Xobc_import_step_itm step_itm = data_db.Tbl__import_step().Select_one(step_id);
|
||||
if (i == 0) {
|
||||
wiki_domain = Xow_abrv_xo_.To_itm(step_itm.Wiki_abrv()); // ASSUME: 1st step's wiki is same for all steps
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.inits; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xomp_init_cmd extends Xob_cmd__base {
|
||||
private final Xomp_init_mgr mgr;
|
||||
public Xomp_init_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);
|
||||
mgr = new Xomp_init_mgr(wiki);
|
||||
}
|
||||
@Override public void Cmd_run() {
|
||||
wiki.Init_assert();
|
||||
mgr.Exec();
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__cfg)) return this;
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
} private static final String Invk__cfg = "cfg";
|
||||
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;} private static final String BLDR_CMD_KEY = "wiki.mass_parse.init";
|
||||
public static final Xob_cmd Prototype = new Xomp_init_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Xomp_init_cmd(bldr, wiki);}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.inits; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
class Xomp_init_mgr {
|
||||
private final Xow_wiki wiki;
|
||||
public Xomp_init_mgr(Xow_wiki wiki) {this.wiki = wiki;}
|
||||
public void Exec() {
|
||||
Xob_db_file make_db = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir());
|
||||
Db_conn conn = make_db.Conn();
|
||||
|
||||
// make table
|
||||
conn.Meta_tbl_remake(Dbmeta_tbl_itm.New("mp_page", new Dbmeta_fld_itm[]
|
||||
{ Dbmeta_fld_itm.new_int("page_id").Primary_y_()
|
||||
, Dbmeta_fld_itm.new_bool("page_done")
|
||||
}
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl("mp_page", "page_id__page_done", "page_id", "page_done")
|
||||
));
|
||||
|
||||
// fill table
|
||||
Db_attach_mgr attach_mgr = new Db_attach_mgr(conn, new Db_attach_itm("page_db", wiki.Data__core_mgr().Db__core().Conn()));
|
||||
int[] ns_ary = new int[] {0, 4, 14};
|
||||
int len = ns_ary.length;
|
||||
String sql = String_.Concat_lines_nl_skip_last
|
||||
( "INSERT INTO mp_page (page_id, page_done)"
|
||||
, "SELECT page_id, 0"
|
||||
, "FROM <page_db>page"
|
||||
, "WHERE page_namespace = {0}"
|
||||
, "AND page_is_redirect = 0"
|
||||
);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int ns_id = ns_ary[i];
|
||||
attach_mgr.Exec_sql_w_msg("adding rows for mp_page: ns=" + ns_id, sql, ns_id);// ANSI.Y
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.htmls.core.bldrs.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
class Xob_hdump_tbl_retriever__xomp implements Xob_hdump_tbl_retriever {
|
||||
private final Db_conn conn;
|
||||
private final Xowd_html_tbl tbl;
|
||||
public Xob_hdump_tbl_retriever__xomp(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl = new Xowd_html_tbl(conn);
|
||||
conn.Meta_tbl_assert(tbl);
|
||||
}
|
||||
public Xowd_html_tbl Get_html_tbl(Xow_ns ns, int prv_row_len) {
|
||||
return tbl;
|
||||
}
|
||||
public void Commit() {conn.Txn_sav();}
|
||||
public void Rls_all() {conn.Txn_sav(); conn.Rls_conn();}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
class Xomp_page_itm {
|
||||
public Xomp_page_itm(int id) {this.id = id;}
|
||||
public int Id() {return id;} private final int id;
|
||||
public int Ns_id() {return ns_id;} private int ns_id;
|
||||
public byte[] Ttl_bry() {return ttl_bry;} private byte[] ttl_bry;
|
||||
public int Text_db_id() {return text_db_id;} private int text_db_id;
|
||||
public byte[] Text() {return text;} private byte[] text;
|
||||
|
||||
public void Init_by_page(int ns_id, byte[] ttl_bry, int text_db_id) {
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_bry = ttl_bry;
|
||||
this.text_db_id = text_db_id;
|
||||
}
|
||||
public void Init_by_text(byte[] text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public static final Xomp_page_itm Null = new Xomp_page_itm(-1);
|
||||
}
|
||||
@@ -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.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.dbs.*;
|
||||
class Xomp_page_pool {
|
||||
private final Object thread_lock = new Object();
|
||||
private Xomp_page_pool_loader loader;
|
||||
private List_adp pool = List_adp_.New(); private int pool_idx = 0, pool_len = 0;
|
||||
private Db_conn make_conn;
|
||||
private final Bry_bfr prog_bfr = Bry_bfr_.New();
|
||||
private int pages_done, pages_total;
|
||||
private long time_bgn, time_prv, time_done;
|
||||
public void Init(Xow_wiki wiki, int num_pages_per_load) {
|
||||
this.make_conn = gplx.xowa.bldrs.Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
this.loader = new Xomp_page_pool_loader(wiki, make_conn, num_pages_per_load);
|
||||
this.pages_done = 0;
|
||||
this.time_bgn = this.time_prv = gplx.core.envs.Env_.TickCount();
|
||||
this.pages_total = loader.Get_pending_count();
|
||||
}
|
||||
public boolean Empty() {return empty;} private boolean empty = false;
|
||||
public void Get_next(List_adp wkr_list, int num_pages_per_wkr) {
|
||||
synchronized (thread_lock) {
|
||||
// pool already marked exhausted by another wkr; return;
|
||||
if (empty) return;
|
||||
int wkr_end = pool_idx + num_pages_per_wkr;
|
||||
|
||||
// need pages to fulfill request
|
||||
if (wkr_end > pool_len) {
|
||||
this.pool = loader.Load(pool, pool_idx, pool_len);
|
||||
this.pool_idx = 0;
|
||||
this.pool_len = pool.Len();
|
||||
if (pool_len == 0) { // no more pages; return;
|
||||
empty = true;
|
||||
return;
|
||||
}
|
||||
wkr_end = num_pages_per_wkr; // recalc wkr_end
|
||||
}
|
||||
|
||||
// reset wkr_end; needed for very last set
|
||||
if (wkr_end >= pool_len)
|
||||
wkr_end = pool_len;
|
||||
|
||||
// add pages to wkr_list
|
||||
for (int i = pool_idx; i < wkr_end; ++i) {
|
||||
Xomp_page_itm page = (Xomp_page_itm)pool.Get_at(i);
|
||||
wkr_list.Add(page);
|
||||
}
|
||||
pool_idx = wkr_end;
|
||||
}
|
||||
}
|
||||
public void Mark_done(int id) {
|
||||
synchronized (thread_lock) {
|
||||
pages_done += 1;
|
||||
if (pages_done % 1000 == 0) {
|
||||
long time_cur = gplx.core.envs.Env_.TickCount();
|
||||
int pages_left = pages_total - pages_done;
|
||||
time_done += (time_cur - time_prv);
|
||||
double rate_cur = pages_done / (time_done / Time_span_.Ratio_f_to_s);
|
||||
String time_past = gplx.xowa.addons.bldrs.centrals.utils.Time_dhms_.To_str(prog_bfr, (int)((time_cur - time_bgn) / 1000), true, 0);
|
||||
String time_left = gplx.xowa.addons.bldrs.centrals.utils.Time_dhms_.To_str(prog_bfr, (int)(pages_left / rate_cur), true, 0);
|
||||
Gfo_usr_dlg_.Instance.Prog_many("", "", "done=~{0} left=~{1} rate=~{2} time_past=~{3} time_left=~{4}", pages_done, pages_left, (int)rate_cur, time_past, time_left);
|
||||
time_prv = time_cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Rls() {
|
||||
make_conn.Rls_conn();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
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.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.dbs.*;
|
||||
class Xomp_page_pool_loader {
|
||||
private final Xow_wiki wiki;
|
||||
private int prv_page_id = -1;
|
||||
private final Db_conn make_conn;
|
||||
private final int num_pages_per_load;
|
||||
private final Db_attach_mgr attach_mgr;
|
||||
public Xomp_page_pool_loader(Xow_wiki wiki, Db_conn make_conn, int num_pages_per_load) {
|
||||
this.wiki = wiki;
|
||||
this.make_conn = make_conn;
|
||||
this.attach_mgr = new Db_attach_mgr(make_conn);
|
||||
this.num_pages_per_load = num_pages_per_load;
|
||||
}
|
||||
public int Get_pending_count() {
|
||||
Db_rdr rdr = make_conn.Stmt_sql("SELECT Count(*) AS Count_of FROM mp_page mp WHERE mp.page_done = 0").Exec_select__rls_auto();
|
||||
try {
|
||||
return rdr.Move_next() ? rdr.Read_int("Count_of") : 0;
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public List_adp Load(List_adp list, int list_idx, int list_len) {
|
||||
List_adp rv = List_adp_.New();
|
||||
// add remaining pages from old pool to new_pool;
|
||||
for (int i = list_idx; i < list_len; ++i) {
|
||||
rv.Add((Xomp_page_itm)list.Get_at(i));
|
||||
}
|
||||
|
||||
// load pages into new pool
|
||||
this.Load_from_db(rv);
|
||||
return rv;
|
||||
}
|
||||
private void Load_from_db(List_adp list) {
|
||||
// prepare for page_tbl
|
||||
String sql = String_.Format(String_.Concat_lines_nl_skip_last // ANSI.Y
|
||||
( "SELECT mp.page_id"
|
||||
, ", pp.page_namespace"
|
||||
, ", pp.page_title"
|
||||
, ", pp.page_text_db_id"
|
||||
, "FROM mp_page mp"
|
||||
, " JOIN <page_db>page pp ON mp.page_id = pp.page_id"
|
||||
, "WHERE mp.page_id > {0}"
|
||||
, "AND mp.page_done = 0"
|
||||
, "LIMIT {1}"
|
||||
), prv_page_id, num_pages_per_load);
|
||||
this.attach_mgr.Conn_others_(new Db_attach_itm("page_db", wiki.Data__core_mgr().Db__core().Conn()));
|
||||
sql = attach_mgr.Resolve_sql(sql);
|
||||
|
||||
// run page_tbl
|
||||
Xomp_text_db_loader text_db_loader = new Xomp_text_db_loader(wiki);
|
||||
attach_mgr.Attach();
|
||||
Db_rdr rdr = make_conn.Stmt_sql(sql).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
prv_page_id = rdr.Read_int("page_id");
|
||||
int text_db_id = rdr.Read_int("page_text_db_id");
|
||||
Xomp_page_itm ppg = new Xomp_page_itm(prv_page_id);
|
||||
ppg.Init_by_page
|
||||
( rdr.Read_int("page_namespace")
|
||||
, rdr.Read_bry_by_str("page_title")
|
||||
, text_db_id
|
||||
);
|
||||
list.Add(ppg);
|
||||
text_db_loader.Add(text_db_id, ppg);
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
attach_mgr.Detach();
|
||||
|
||||
text_db_loader.Load();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xomp_parse_cmd extends Xob_cmd__base {
|
||||
private final Xomp_parse_mgr mgr = new Xomp_parse_mgr();
|
||||
public Xomp_parse_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
wiki.Init_assert();
|
||||
mgr.Run(wiki);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__cfg)) return mgr.Cfg();
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
} private static final String Invk__cfg = "cfg";
|
||||
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;} private static final String BLDR_CMD_KEY = "wiki.mass_parse.exec";
|
||||
public static final Xob_cmd Prototype = new Xomp_parse_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Xomp_parse_cmd(bldr, wiki);}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.core.threads.*;
|
||||
import gplx.xowa.langs.*;
|
||||
class Xomp_parse_mgr {
|
||||
private final Xomp_page_pool page_pool = new Xomp_page_pool();
|
||||
public Xomp_parse_mgr_cfg Cfg() {return cfg;} private final Xomp_parse_mgr_cfg cfg = new Xomp_parse_mgr_cfg();
|
||||
private int wkrs_done;
|
||||
public void Wkrs_done_add_1() {synchronized (page_pool) {++wkrs_done;}}
|
||||
public void Run(Xowe_wiki wiki) {
|
||||
// init pool
|
||||
cfg.Init(wiki);
|
||||
page_pool.Init(wiki, cfg.Num_pages_in_pool());
|
||||
|
||||
// init threads
|
||||
int wkr_len = cfg.Num_wkrs();
|
||||
Xomp_parse_wkr[] wkrs = new Xomp_parse_wkr[wkr_len];
|
||||
for (int i = 0; i < wkr_len; ++i) {
|
||||
Xomp_parse_wkr wkr = new Xomp_parse_wkr(this, Clone_wiki(wiki), page_pool, i, cfg.Num_pages_per_wkr());
|
||||
wkrs[i] = wkr;
|
||||
}
|
||||
|
||||
// start threads; done separately b/c thread issues when done right after init
|
||||
for (int i = 0; i < wkr_len; ++i) {
|
||||
Xomp_parse_wkr wkr = wkrs[i];
|
||||
Thread_adp_.Start_by_key("xomp." + Int_.To_str_fmt(i, "000"), Cancelable_.Never, wkr, Xomp_parse_wkr.Invk__exec);
|
||||
}
|
||||
|
||||
// wait until wkrs are wkrs_done
|
||||
while (true) {
|
||||
synchronized (page_pool) {
|
||||
if (wkrs_done == wkr_len) break;
|
||||
}
|
||||
Thread_adp_.Sleep(1000);
|
||||
}
|
||||
page_pool.Rls();
|
||||
|
||||
// print stats
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
for (int i = 0; i < wkr_len; ++i) {
|
||||
wkrs[i].Bld_stats(bfr);
|
||||
}
|
||||
Gfo_usr_dlg_.Instance.Note_many("", "", bfr.To_str_and_clear());
|
||||
}
|
||||
private static Xowe_wiki Clone_wiki(Xowe_wiki wiki) {
|
||||
Xol_lang_itm lang = new Xol_lang_itm(wiki.App().Lang_mgr(), wiki.Lang().Key_bry());
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
Xowe_wiki rv = new Xowe_wiki(wiki.Appe(), lang, wiki.Ns_mgr(), wiki.Domain_itm(), wiki.Fsys_mgr().Root_dir());
|
||||
rv.Init_by_wiki();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
class Xomp_parse_mgr_cfg implements Gfo_invk {
|
||||
public Io_url Root_dir() {return root_dir;} private Io_url root_dir;
|
||||
public int Num_wkrs() {return num_wkrs;} private int num_wkrs = -1;
|
||||
public int Num_pages_in_pool() {return num_pages_in_pool;} private int num_pages_in_pool = 1000;
|
||||
public int Num_pages_per_wkr() {return num_pages_per_wkr;} private int num_pages_per_wkr = 1000;
|
||||
public void Init(Xowe_wiki wiki) {
|
||||
if (root_dir == null) root_dir = wiki.Fsys_mgr().Root_dir().GenSubDir_nest("tmp", "xomp");
|
||||
if (num_wkrs == -1) num_wkrs = gplx.core.envs.Env_.System_cpu_count();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__num_wkrs_)) num_wkrs = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk__num_pages_in_pool_)) num_pages_in_pool = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk__num_pages_per_wkr_)) num_pages_per_wkr = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk__num_pages_per_wkr_)) num_pages_per_wkr = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk__root_dir_)) root_dir = m.ReadIoUrl("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk__num_wkrs_ = "num_wkrs_", Invk__num_pages_in_pool_ = "num_pages_in_pool_", Invk__num_pages_per_wkr_ = "num_pages_per_wkr_"
|
||||
, Invk__root_dir_ = "root_dir_"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
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.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.htmls.core.bldrs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
class Xomp_parse_wkr implements Gfo_invk {
|
||||
private final Xomp_parse_mgr mgr;
|
||||
private final Xowe_wiki wiki;
|
||||
private final Xomp_page_pool page_pool;
|
||||
private final List_adp list = List_adp_.New(); private int list_idx = 0, list_len = 0;
|
||||
private final int num_pages_per_wkr;
|
||||
private final int idx;
|
||||
private final Xob_hdump_bldr hdump_bldr = new Xob_hdump_bldr();
|
||||
// private boolean gen_html = true;// gen_hdump = true;
|
||||
private int done_count; private long done_time;
|
||||
public Xomp_parse_wkr(Xomp_parse_mgr mgr, Xowe_wiki wiki, Xomp_page_pool page_pool, int idx, int num_pages_per_wkr) {
|
||||
this.mgr = mgr; this.wiki = wiki;
|
||||
this.page_pool = page_pool; this.num_pages_per_wkr = num_pages_per_wkr;
|
||||
this.idx = idx;
|
||||
}
|
||||
public void Exec() {
|
||||
// init
|
||||
Db_conn wkr_conn = Db_conn_bldr.Instance.Get_or_autocreate(true, mgr.Cfg().Root_dir().GenSubFil_nest("xomp_" + Int_.To_str_fmt(idx, "000"), "xomp_wkr.sqlite3"));
|
||||
Xow_parser_mgr parser = new Xow_parser_mgr(wiki);
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(gplx.xowa.wikis.pages.Xopg_page_.Tid_read).Ctgs_enabled_(false); // disable categories else progress messages written (also for PERF)
|
||||
if (wiki.File__bin_mgr() != null)
|
||||
wiki.File__bin_mgr().Wkrs__del(gplx.xowa.files.bins.Xof_bin_wkr_.Key_http_wmf); // remove wmf wkr, else will try to download images during parsing
|
||||
hdump_bldr.Init(wiki, wkr_conn, new Xob_hdump_tbl_retriever__xomp(wkr_conn));
|
||||
|
||||
while (true) {
|
||||
Xomp_page_itm ppg = Get_next(); if (ppg == Xomp_page_itm.Null) break; // no more pages
|
||||
if (ppg.Text() == null) continue; // some pages have no text; ignore them else null ref; PAGE: it.d:miercuri DATE:2015-12-05
|
||||
|
||||
try {
|
||||
// init page
|
||||
long done_bgn = gplx.core.envs.Env_.TickCount();
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(ppg.Ns_id(), ppg.Ttl_bry());
|
||||
Xoae_page wpg = Xoae_page.New(wiki, ttl);
|
||||
wpg.Db().Text().Text_bry_(ppg.Text());
|
||||
wpg.Db().Page().Id_(ppg.Id());
|
||||
|
||||
// parse page
|
||||
parser.Ctx().Clear_all();
|
||||
parser.Parse(wpg, true);
|
||||
|
||||
// gen_html
|
||||
// if ( gen_html
|
||||
// && wpg.Redirect().Itms__len() == 0) // don't generate html for redirected pages
|
||||
// wiki.Html_mgr().Page_wtr_mgr().Gen(wpg, gplx.xowa.wikis.pages.Xopg_page_.Tid_read);
|
||||
// if (gen_hdump)
|
||||
// hdump_bldr.Insert(wpg);
|
||||
|
||||
// mark done for sake of progress
|
||||
page_pool.Mark_done(ppg.Id());
|
||||
|
||||
// update stats
|
||||
long time_cur = gplx.core.envs.Env_.TickCount();
|
||||
done_time += time_cur - done_bgn;
|
||||
done_bgn = time_cur;
|
||||
++done_count;
|
||||
|
||||
// cleanup
|
||||
// ctx.App().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released
|
||||
if (wiki.Cache_mgr().Tmpl_result_cache().Count() > 50000)
|
||||
wiki.Cache_mgr().Tmpl_result_cache().Clear();
|
||||
if (done_count % 50 == 0) {
|
||||
wiki.Cache_mgr().Free_mem_all();
|
||||
wiki.Parser_mgr().Scrib().Core_term();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "mass_parse.fail:ns=~{0} ttl=~{1} err=~{2}", ppg.Ns_id(), ppg.Ttl_bry(), Err_.Message_gplx_log(e));
|
||||
}
|
||||
}
|
||||
mgr.Wkrs_done_add_1();
|
||||
wkr_conn.Rls_conn();
|
||||
}
|
||||
public void Bld_stats(Bry_bfr bfr) {
|
||||
int done_time_in_sec = (int)(done_time / 1000); if (done_time_in_sec == 0) done_time_in_sec = 1;
|
||||
bfr.Add_int_pad_bgn(Byte_ascii.Space, 4, idx );
|
||||
bfr.Add_int_pad_bgn(Byte_ascii.Space, 8, (int)(done_count / done_time_in_sec));
|
||||
bfr.Add_int_pad_bgn(Byte_ascii.Space, 8, done_count);
|
||||
bfr.Add_int_pad_bgn(Byte_ascii.Space, 8, done_time_in_sec);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
private Xomp_page_itm Get_next() {
|
||||
if (list_idx == list_len) {
|
||||
list.Clear();
|
||||
page_pool.Get_next(list, num_pages_per_wkr);
|
||||
list_len = list.Len();
|
||||
if (list_len == 0) return Xomp_page_itm.Null;
|
||||
list_idx = 0;
|
||||
}
|
||||
return (Xomp_page_itm)list.Get_at(list_idx++);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__exec)) this.Exec();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk__exec = "exec";
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
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.addons.bldrs.mass_parses.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.ios.*;
|
||||
class Xomp_text_db_loader {
|
||||
private final Xow_wiki wiki;
|
||||
private final Ordered_hash text_db_hash = Ordered_hash_.New();
|
||||
private final Io_stream_zip_mgr zip_mgr = Xoa_app_.Utl__zip_mgr();
|
||||
public Xomp_text_db_loader(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
}
|
||||
public void Add(int text_db_id, Xomp_page_itm ppg) {
|
||||
Xomp_text_db_itm itm = (Xomp_text_db_itm)text_db_hash.Get_by(text_db_id);
|
||||
if (itm == null) {
|
||||
itm = new Xomp_text_db_itm(text_db_id);
|
||||
text_db_hash.Add(text_db_id, itm);
|
||||
}
|
||||
itm.Page_list().Add(ppg);
|
||||
}
|
||||
public void Load() {
|
||||
int text_db_hash_len = text_db_hash.Len();
|
||||
for (int i = 0; i < text_db_hash_len; ++i) {
|
||||
Xomp_text_db_itm itm = (Xomp_text_db_itm)text_db_hash.Get_at(i);
|
||||
Load_list(itm.Text_db_id(), itm.Page_list());
|
||||
}
|
||||
}
|
||||
private void Load_list(int text_db_id, List_adp list) {
|
||||
int list_len = list.Len();
|
||||
int batch_idx = 0;
|
||||
Bry_bfr bry = Bry_bfr_.New();
|
||||
Ordered_hash page_hash = Ordered_hash_.New();
|
||||
byte zip_tid = wiki.Data__core_mgr().Props().Zip_tid_text();
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
if (batch_idx == 0) {
|
||||
page_hash.Clear();
|
||||
bry.Add_str_a7("SELECT page_id, text_data FROM text WHERE page_id IN (");
|
||||
}
|
||||
|
||||
// build WHERE IN for page_ids; EX: "1, 2, 3, 4"
|
||||
Xomp_page_itm ppg = (Xomp_page_itm)list.Get_at(i);
|
||||
int page_id = ppg.Id();
|
||||
if (batch_idx != 0) bry.Add_byte_comma();
|
||||
bry.Add_int_variable(page_id);
|
||||
page_hash.Add(page_id, ppg);
|
||||
++batch_idx;
|
||||
|
||||
// load if 255 in list, or last
|
||||
if ( batch_idx % 255 == 0
|
||||
|| i == list_len - 1) {
|
||||
bry.Add_byte(Byte_ascii.Paren_end);
|
||||
Load_from_text_db(page_hash, zip_tid, text_db_id, bry.To_str_and_clear());
|
||||
batch_idx = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Load_from_text_db(Ordered_hash page_hash, byte zip_tid, int text_db_id, String sql) {
|
||||
Db_conn text_conn = wiki.Data__core_mgr().Dbs__get_by_id_or_fail(text_db_id).Conn();
|
||||
Db_rdr rdr = text_conn.Stmt_sql(sql).Exec_select__rls_auto(); // ANSI.Y
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
int page_id = rdr.Read_int("page_id");
|
||||
byte[] text_data = rdr.Read_bry("text_data");
|
||||
text_data = zip_mgr.Unzip(zip_tid, text_data);
|
||||
Xomp_page_itm ppg = (Xomp_page_itm)page_hash.Get_by(page_id);
|
||||
ppg.Init_by_text(text_data);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
rdr.Rls();
|
||||
// text_conn.Rls_conn(); // TOMBSTONE: causes strange errors in tables; DATE:2016-07-06
|
||||
}
|
||||
}
|
||||
}
|
||||
class Xomp_text_db_itm {
|
||||
public Xomp_text_db_itm(int text_db_id) {this.text_db_id = text_db_id;}
|
||||
public int Text_db_id() {return text_db_id;} private final int text_db_id;
|
||||
public List_adp Page_list() {return page_list;} private final List_adp page_list = List_adp_.New();
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class Xowd_css_core_mgr {
|
||||
}
|
||||
conn.Txn_end();
|
||||
}
|
||||
catch (Exception e) {conn.Txn_cxl(); throw e;}
|
||||
catch (Exception e) {conn.Txn_cxl(); throw Err_.new_exc(e, "css", "Xowd_css_core_mgr.Set failed", "key", key, "err", Err_.Message_gplx_log(e));}
|
||||
}
|
||||
public static boolean Get(Xowd_css_core_tbl core_tbl, Xowd_css_file_tbl file_tbl, Io_url css_dir, String key) {
|
||||
String dbg = "enter";
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Rndm_root_special implements Xow_special_page {
|
||||
Xow_ns ns = wiki.Ns_mgr().Names_get_or_main(ttl.Rest_txt());
|
||||
// Rndm_addon.Get(wiki).Mgr().Regy().Get_rndm_page_by_ns(ns);
|
||||
byte[] random_ttl_bry = wiki.Db_mgr().Load_mgr().Find_random_ttl(ns);
|
||||
byte[] root_bry = Xoa_ttl.parse(wiki, random_ttl_bry).Root_txt();
|
||||
byte[] root_bry = Xoa_ttl.Parse(wiki, random_ttl_bry).Root_txt();
|
||||
wiki.Data_mgr().Redirect(page, ns.Gen_ttl(root_bry));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ class Rndm_root_special_fxt {
|
||||
public void Test_open(String special_url, String expd) {
|
||||
Xoae_page page = Test_special_open(wiki, special_page, special_url);
|
||||
Tfds.Eq(expd, String_.new_a7(page.Url().Page_bry()));
|
||||
Tfds.Eq(expd, String_.new_a7(page.Data_raw()));
|
||||
Tfds.Eq(expd, String_.new_a7(page.Db().Text().Text_bry()));
|
||||
}
|
||||
public static Xoae_page Test_special_open(Xowe_wiki wiki, Xow_special_page special_page, String special_url) {
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(special_url));
|
||||
page.Url_(url);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7(special_url));
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_a7(special_url));
|
||||
page.Ttl_(ttl);
|
||||
special_page.Special__gen(wiki, page, url, ttl);
|
||||
return page;
|
||||
|
||||
@@ -31,7 +31,8 @@ public class Xow_info_special implements Xow_special_page {
|
||||
delete_wiki.Data__core_mgr().Rls(); // release connection if open
|
||||
Delete_wiki_files(delete_wiki.Fsys_mgr().Root_dir());
|
||||
}
|
||||
page.Redirect_to_ttl_(gplx.xowa.addons.wikis.registrys.lists.Xow_list_special.Prototype.Special__meta().Ttl_bry());
|
||||
Xoa_ttl redirect_ttl = wiki.Ttl_parse(gplx.xowa.addons.wikis.registrys.lists.Xow_list_special.Prototype.Special__meta().Ttl_bry());
|
||||
page.Redirect().Itms__add__special(Xoa_url.New(wiki, redirect_ttl), redirect_ttl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public class Srch_word_tbl implements Rls_able {
|
||||
if (fld_link_count_score != Dbmeta_fld_itm.Key_null) {
|
||||
try {link_count_score = rdr.Read_int(fld_link_count_score);}
|
||||
catch (Exception e) {// handle 2016-05 and earlier wikis which stored value as double instead of int
|
||||
Err_.Noop(e);
|
||||
link_count_score = (int)rdr.Read_double(fld_link_count_score);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ public class Srch_special_page implements Xow_special_page, Gfo_invk, Gfo_evt_it
|
||||
|
||||
// get page directly from url
|
||||
boolean fulltext_invoked = url.Qargs_mgr().Match(Qarg__fulltext, Qarg__fulltext__y);
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse(wiki, search_raw);
|
||||
Xoa_ttl search_ttl = Xoa_ttl.Parse(wiki, search_raw);
|
||||
Xoae_page search_page = page;
|
||||
if ( !fulltext_invoked
|
||||
&& !Bry_.Eq(search_raw, Xow_special_meta_.Itm__search.Ttl_bry())) // do not lookup self else stack overflow; happens when going directly to Special:Search (from history)
|
||||
search_page = wiki.Data_mgr().Load_page_by_ttl(search_ttl); // try to find page; EX:Special:Search?search=Earth -> en.w:Earth; needed for search suggest
|
||||
|
||||
// page not found, or explicit_search invoked
|
||||
if (search_page.Missing() || fulltext_invoked) {
|
||||
if (search_page.Db().Page().Exists_n() || fulltext_invoked) {
|
||||
if (qargs_mgr.Cancel() != null) { // cancel any existing searches
|
||||
search_mgr.Search__cancel(qargs_mgr.Cancel());
|
||||
page.Tab_data().Cancel_show_y_();
|
||||
@@ -81,10 +81,12 @@ public class Srch_special_page implements Xow_special_page, Gfo_invk, Gfo_evt_it
|
||||
// page found; return it;
|
||||
else {
|
||||
wiki.Parser_mgr().Parse(search_page, true);
|
||||
page.Data_raw_(search_page.Data_raw());
|
||||
page.Db().Text().Text_bry_(search_page.Db().Text().Text_bry());
|
||||
if (page.Root() != null) // NOTE: null when going from w:Earth -> q:Earth; DATE:2013-03-20
|
||||
page.Root().Data_htm_(search_page.Root().Data_htm());
|
||||
page.Ttl_(search_ttl).Url_(Xoa_url.new_(wiki.Domain_bry(), search_ttl.Full_txt_w_ttl_case())).Redirected_(true);
|
||||
Xoa_url redirect_url = Xoa_url.New(wiki, search_ttl);
|
||||
page.Ttl_(search_ttl).Url_(redirect_url);
|
||||
page.Redirect().Itms__add__special(redirect_url, search_ttl);
|
||||
}
|
||||
}
|
||||
private void Multi_wikis_changed() {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Srch_special_searcher {
|
||||
}
|
||||
|
||||
// generate html; note if async, this will just generate the page header
|
||||
page.Data_raw_(html_page_bldr.Bld_page(tmp_bfr.To_bry_and_clear()));
|
||||
page.Db().Text().Text_bry_(html_page_bldr.Bld_page(tmp_bfr.To_bry_and_clear()));
|
||||
}
|
||||
public void Search__done(Srch_special_cmd cmd) {
|
||||
cancel_hash.Del(cmd.key);
|
||||
|
||||
@@ -188,7 +188,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// public void Test_html_by_url(String ttl_str, String args_str, String expd_html) {
|
||||
// wiki.Init_needed_(false);
|
||||
// byte[] ttl_bry = Bry_.new_a7(ttl_str);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
// Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
// Xoae_page page = Xoae_page.New_test(wiki, ttl);
|
||||
// byte[] url_bry = Bry_.new_a7("http://en.wikipedia.org/wiki/Special:Search/" + ttl_str + args_str);
|
||||
// Xoa_url url = wiki.Appe().Url_parser().Parse(url_bry);
|
||||
@@ -200,7 +200,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// Xow_url_parser_old url_parser = new Xow_url_parser_old();
|
||||
// byte[] url_raw = Bry_.new_a7("Special:Search/" + ttl_str + ((match_tid == Srch_special_page.Match_tid_all) ? "" : "*") + "?fulltext=y" + Srch_rslt_row_sorter.Xto_url_arg(sort_tid) + "&xowa_page_size=1&xowa_page_index=" + page_idx);
|
||||
// Xoa_url url = url_parser.Parse(url_raw);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse(wiki, url_raw);
|
||||
// Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url_raw);
|
||||
// Xoae_page page = wiki.Ctx().Page();
|
||||
// search_mgr.Special__gen(url, page, wiki, ttl);
|
||||
// Xosrh_rslt_grp cur_grp = search_mgr.Cur_grp();
|
||||
|
||||
@@ -79,6 +79,7 @@ public class Xoav_app implements Xoa_app, Gfo_invk {
|
||||
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
|
||||
public Xog_tab_mgr Gui__tab_mgr() {return gui__tab_mgr;} private final Xog_tab_mgr gui__tab_mgr;
|
||||
public Gfo_thread_mgr Thread_mgr() {return thread_mgr;} private final Gfo_thread_mgr thread_mgr = new Gfo_thread_mgr();
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private final Xop_amp_mgr parser_amp_mgr = Xop_amp_mgr.Instance;
|
||||
|
||||
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; Xoa_app_.Usr_dlg_(usr_dlg);} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Noop;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Xoa_boot_mgr {
|
||||
if (app_type_is_gui)
|
||||
app.Gui_mgr().Run(splash_win);
|
||||
else // teardown app, else lua will keep process running
|
||||
if (gplx.xowa.xtns.scribunto.Scrib_core.Core() != null) gplx.xowa.xtns.scribunto.Scrib_core.Core().Term();
|
||||
gplx.xowa.xtns.scribunto.Scrib_core_mgr.Term_all();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {usr_dlg.Warn_many("", "", "app launch failed: ~{0}", Err_.Message_gplx_full(e));}
|
||||
|
||||
@@ -99,28 +99,36 @@ public class Http_server_mgr implements Gfo_invk {
|
||||
// get the url / ttl
|
||||
if (Bry_.Len_eq_0(ttl_bry)) ttl_bry = wiki.Props().Main_page();
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse(ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
|
||||
// get the page
|
||||
gplx.xowa.guis.views.Xog_tab_itm tab = Gxw_html_server.Assert_tab2(app, wiki); // HACK: assert tab exists
|
||||
Xoae_page page = wiki.Page_mgr().Load_page(url, ttl, tab);
|
||||
app.Gui_mgr().Browser_win().Active_page_(page); // HACK: init gui_mgr's page for output (which server ordinarily doesn't need)
|
||||
if (page.Missing()) { // if page does not exist, replace with message; else null_ref error; DATE:2014-03-08
|
||||
page.Data_raw_(Bry_.new_a7("'''Page not found.'''"));
|
||||
if (page.Db().Page().Exists_n()) { // if page does not exist, replace with message; else null_ref error; DATE:2014-03-08
|
||||
page.Db().Text().Text_bry_(Bry_.new_a7("'''Page not found.'''"));
|
||||
wiki.Parser_mgr().Parse(page, false);
|
||||
}
|
||||
page.Html_data().Head_mgr().Itm__server().Init_by_http(data__client).Enabled_y_();
|
||||
|
||||
// generate html
|
||||
String rv = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, Xopg_page_.Tid_read)); // NOTE: must generate HTML now in order for "wait" and "async_server" to work with text_dbs; DATE:2016-07-10
|
||||
boolean rebuild_html = false;
|
||||
switch (retrieve_mode) {
|
||||
case File_retrieve_mode.Mode_skip: break; // noop
|
||||
case File_retrieve_mode.Mode_async_server: app.Gui_mgr().Browser_win().Page__async__bgn(tab); break;
|
||||
case File_retrieve_mode.Mode_skip: // noop
|
||||
break;
|
||||
case File_retrieve_mode.Mode_async_server:
|
||||
rebuild_html = true;
|
||||
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
||||
break;
|
||||
case File_retrieve_mode.Mode_wait:
|
||||
rebuild_html = true;
|
||||
gplx.xowa.guis.views.Xog_async_wkr.Async(page, tab.Html_itm());
|
||||
page = wiki.Page_mgr().Load_page(url, ttl, tab); // HACK: fetch page again so that HTML will now include img data
|
||||
break;
|
||||
}
|
||||
return String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, Xopg_page_.Tid_read));
|
||||
if (rebuild_html) rv = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, Xopg_page_.Tid_read));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
private void Note(String s) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.files.*;
|
||||
public class Xow_url_parser {
|
||||
private final Object thread_lock = new Object();
|
||||
private final Gfo_url_encoder encoder;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser(); private final Gfo_url gfo_url = new Gfo_url();
|
||||
@@ -65,52 +66,54 @@ public class Xow_url_parser {
|
||||
public Xoa_url Parse(byte[] src, int bgn, int end) {Xoa_url rv = Xoa_url.blank(); Parse(rv, src, bgn, end); return rv;}
|
||||
public boolean Parse(Xoa_url rv, byte[] src) {return Parse(rv, src, 0, src.length);}
|
||||
public boolean Parse(Xoa_url rv, byte[] src, int bgn, int end) {
|
||||
if (end - bgn == 0) {Init_tmp_vars(Gfo_url.Empty); Make(rv); return false;}
|
||||
src = encoder.Decode(src, bgn, end); // NOTE: must decode any url-encoded parameters
|
||||
int src_len = src.length;
|
||||
url_parser.Parse(gfo_url, src, 0, src_len); // parse to plain gfo_url
|
||||
Init_tmp_vars(gfo_url);
|
||||
if (src[0] == Byte_ascii.Hash) // src is anch; EX: #A
|
||||
Bld_anch();
|
||||
else {
|
||||
switch (tmp_protocol_tid) {
|
||||
case Gfo_protocol_itm.Tid_file:
|
||||
if (src_len > 5 && src[5] != Byte_ascii.Slash) // src is ttl in [[File]] ns; EX: "File:A.png"
|
||||
Bld_page_by_file_ns();
|
||||
else // src is file:///; EX: EX: "file:///C:/A.png"
|
||||
tmp_tid = Xoa_url_.Tid_file;
|
||||
break;
|
||||
case Gfo_protocol_itm.Tid_xowa:
|
||||
Bld_xowa();
|
||||
break;
|
||||
case Gfo_protocol_itm.Tid_http:
|
||||
case Gfo_protocol_itm.Tid_https:
|
||||
case Gfo_protocol_itm.Tid_relative_1:
|
||||
if (tmp_protocol_tid == Gfo_protocol_itm.Tid_relative_1) // interpret relative protocol links to match wiki's protocol; EX: [//a.org] -> https://a.org for all WMF wikis; DATE:2015-07-27
|
||||
tmp_protocol_tid = wiki.Props().Protocol_tid();
|
||||
if (app.User().Wikii().Xwiki_mgr().Get_by_key(tmp_wiki) != null)// src is offline wiki; EX: http://fr.wikipedia.org/wiki/A
|
||||
synchronized (thread_lock) {
|
||||
if (end - bgn == 0) {Init_tmp_vars(Gfo_url.Empty); Make(rv); return false;}
|
||||
src = encoder.Decode(src, bgn, end); // NOTE: must decode any url-encoded parameters
|
||||
int src_len = src.length;
|
||||
url_parser.Parse(gfo_url, src, 0, src_len); // parse to plain gfo_url
|
||||
Init_tmp_vars(gfo_url);
|
||||
if (src[0] == Byte_ascii.Hash) // src is anch; EX: #A
|
||||
Bld_anch();
|
||||
else {
|
||||
switch (tmp_protocol_tid) {
|
||||
case Gfo_protocol_itm.Tid_file:
|
||||
if (src_len > 5 && src[5] != Byte_ascii.Slash) // src is ttl in [[File]] ns; EX: "File:A.png"
|
||||
Bld_page_by_file_ns();
|
||||
else // src is file:///; EX: EX: "file:///C:/A.png"
|
||||
tmp_tid = Xoa_url_.Tid_file;
|
||||
break;
|
||||
case Gfo_protocol_itm.Tid_xowa:
|
||||
Bld_xowa();
|
||||
break;
|
||||
case Gfo_protocol_itm.Tid_http:
|
||||
case Gfo_protocol_itm.Tid_https:
|
||||
case Gfo_protocol_itm.Tid_relative_1:
|
||||
if (tmp_protocol_tid == Gfo_protocol_itm.Tid_relative_1) // interpret relative protocol links to match wiki's protocol; EX: [//a.org] -> https://a.org for all WMF wikis; DATE:2015-07-27
|
||||
tmp_protocol_tid = wiki.Props().Protocol_tid();
|
||||
if (app.User().Wikii().Xwiki_mgr().Get_by_key(tmp_wiki) != null)// src is offline wiki; EX: http://fr.wikipedia.org/wiki/A
|
||||
Bld_page(0);
|
||||
else if (Bry_.Eq(tmp_wiki, Bry_upload_wikimedia_org)) // src is upload.wikimedia.org; EX: "http://upload.wikimedia.org/wikipedia/commons/a/ab/C.svg"
|
||||
Bld_page_from_upload_wikimedia_org();
|
||||
else // src is unknown site: EX: "http://a.org"
|
||||
tmp_tid = Xoa_url_.Tid_inet;
|
||||
break;
|
||||
case Gfo_protocol_itm.Tid_unknown:
|
||||
Bld_page(0);
|
||||
else if (Bry_.Eq(tmp_wiki, Bry_upload_wikimedia_org)) // src is upload.wikimedia.org; EX: "http://upload.wikimedia.org/wikipedia/commons/a/ab/C.svg"
|
||||
Bld_page_from_upload_wikimedia_org();
|
||||
else // src is unknown site: EX: "http://a.org"
|
||||
break;
|
||||
default:
|
||||
tmp_tid = Xoa_url_.Tid_inet;
|
||||
break;
|
||||
case Gfo_protocol_itm.Tid_unknown:
|
||||
Bld_page(0);
|
||||
break;
|
||||
default:
|
||||
tmp_tid = Xoa_url_.Tid_inet;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Bld_qargs();
|
||||
if (tmp_page_is_main) tmp_page = Xoa_page_.Main_page_bry_empty;
|
||||
if (tmp_anch != null) {
|
||||
byte[] anchor_bry = gplx.langs.htmls.encoders.Gfo_url_encoder_.Id.Encode(tmp_anch); // reencode for anchors (which use . encoding, not % encoding); PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
|
||||
tmp_anch = anchor_bry;
|
||||
}
|
||||
Make(rv);
|
||||
return true;
|
||||
}
|
||||
Bld_qargs();
|
||||
if (tmp_page_is_main) tmp_page = Xoa_page_.Main_page_bry_empty;
|
||||
if (tmp_anch != null) {
|
||||
byte[] anchor_bry = gplx.langs.htmls.encoders.Gfo_url_encoder_.Id.Encode(tmp_anch); // reencode for anchors (which use . encoding, not % encoding); PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
|
||||
tmp_anch = anchor_bry;
|
||||
}
|
||||
Make(rv);
|
||||
return true;
|
||||
}
|
||||
private void Init_tmp_vars(Gfo_url gfo_url) {
|
||||
tmp_tid = Xoa_url_.Tid_unknown;
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.core.stores.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.nss.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.core.stores.*;
|
||||
import gplx.dbs.*; import gplx.dbs.sqls.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xob_categorylinks_sql_tst {
|
||||
@Before public void init() {if (Xoa_test_.Db_skip()) return; fxt.Ctor_fsys();} Db_mgr_fxt fxt = new Db_mgr_fxt();
|
||||
@After public void term() {if (Xoa_test_.Db_skip()) return; fxt.Rls();}
|
||||
@@ -84,6 +85,7 @@ class Db_tst_row {
|
||||
}
|
||||
}
|
||||
class Db_tst_qry {
|
||||
private final Sql_qry_wtr qry_wtr = Sql_qry_wtr_.New__sqlite();
|
||||
public Db_qry Qry() {return qry;} Db_qry qry;
|
||||
public String[] Cols() {return cols;} public Db_tst_qry Cols_(String... v) {this.cols = v; return this;} private String[] cols;
|
||||
public List_adp Rows() {return rows;} List_adp rows = List_adp_.New();
|
||||
@@ -127,7 +129,7 @@ class Db_tst_qry {
|
||||
}
|
||||
if (!pass) {
|
||||
bfr.Add(Lbl_row_hdr).Add_int_variable(expd_row_idx).Add_byte_nl();
|
||||
bfr.Add_str_u8(qry.To_sql__exec(gplx.dbs.sqls.Sql_qry_wtr_.Sqlite)).Add_byte(Byte_ascii.Semic);
|
||||
bfr.Add_str_u8(qry.To_sql__exec(qry_wtr)).Add_byte(Byte_ascii.Semic);
|
||||
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
||||
}
|
||||
} static final byte[] Lbl_row_hdr = Bry_.new_a7("row: "), Lbl_eq_y = Bry_.new_a7(" == "), Lbl_eq_n = Bry_.new_a7(" != ");
|
||||
|
||||
@@ -28,7 +28,12 @@ class Sql_fld_mgr {
|
||||
int bgn = Bry_find_.Find_fwd(raw, Tkn_create_table); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find 'CREATE TABLE'");
|
||||
bgn = Bry_find_.Find_fwd(raw, Byte_ascii.Nl, bgn); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find new line after 'CREATE TABLE'");
|
||||
bgn += Int_.Const_position_after_char;
|
||||
int end = Bry_find_.Find_fwd(raw, Tkn_unique_index); if (end == Bry_find_.Not_found) throw Err_.new_wo_type("could not find 'UNIQUE KEY'");
|
||||
int end = Bry_find_.Find_fwd(raw, Tkn_unique_index);
|
||||
if (end == Bry_find_.Not_found) { // as of 2016-07, en.w:categorylinks no longer has UNIQUE KEY; try PRIMARY KEY; DATE:2016-07-08
|
||||
end = Bry_find_.Find_fwd(raw, Tkn_primary_key);
|
||||
if (end == Bry_find_.Not_found)
|
||||
throw Err_.new_wo_type("could not find 'UNIQUE KEY' or 'PRIMARY KEY'");
|
||||
}
|
||||
end = Bry_find_.Find_bwd(raw, Byte_ascii.Nl, end); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find new line before 'UNIQUE KEY'");
|
||||
Parse_lines(Bry_.Mid(raw, bgn, end));
|
||||
return this;
|
||||
@@ -47,9 +52,10 @@ class Sql_fld_mgr {
|
||||
hash.Add(fld.Key(), fld);
|
||||
}
|
||||
}
|
||||
private static final byte[]
|
||||
Tkn_create_table = Bry_.new_a7("CREATE TABLE")
|
||||
, Tkn_unique_index = Bry_.new_a7("UNIQUE KEY")
|
||||
private static final byte[]
|
||||
Tkn_create_table = Bry_.new_a7("CREATE TABLE")
|
||||
, Tkn_unique_index = Bry_.new_a7("UNIQUE KEY")
|
||||
, Tkn_primary_key = Bry_.new_a7("PRIMARY KEY")
|
||||
;
|
||||
public static final int Not_found = -1;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,22 @@ Sql_fld_mgr_fxt fxt = new Sql_fld_mgr_fxt();
|
||||
fxt.Exec_get("fld_2", 0);
|
||||
fxt.Exec_get("fld_3", -1);
|
||||
}
|
||||
@Test public void Primary_key() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl
|
||||
( "ignore"
|
||||
, "CREATE TABLE tbl_0 ("
|
||||
, " `fld_2` int,"
|
||||
, " `fld_1` int,"
|
||||
, " `fld_0` int,"
|
||||
, " PRIMARY KEY idx_0 (fld_2)"
|
||||
, ");"
|
||||
));
|
||||
fxt.Test_count(3);
|
||||
fxt.Exec_get("fld_0", 2);
|
||||
fxt.Exec_get("fld_1", 1);
|
||||
fxt.Exec_get("fld_2", 0);
|
||||
fxt.Exec_get("fld_3", -1);
|
||||
}
|
||||
}
|
||||
class Sql_fld_mgr_fxt {
|
||||
Sql_fld_mgr fld_mgr = new Sql_fld_mgr();
|
||||
|
||||
@@ -32,8 +32,8 @@ public class Xowd_data_tstr {
|
||||
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);
|
||||
Xoh_page hpg = new Xoh_page();
|
||||
hpg.Db().Html().Html_bry_(html_bry);
|
||||
byte[] data = html_bry;
|
||||
html_db.Tbl__html().Insert(page_id, 0, gplx.core.ios.streams.Io_stream_.Tid_raw, gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_.Hzip__none, Bry_.Empty, Bry_.Empty, Bry_.Empty, data);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.drds.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
|
||||
import gplx.core.net.*; import gplx.xowa.addons.wikis.imports.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.sections.*;
|
||||
import gplx.core.net.*; import gplx.xowa.addons.wikis.imports.*;
|
||||
import gplx.xowa.wikis.pages.redirects.*;
|
||||
public class Xod_page_mgr {
|
||||
public Xod_page_itm Get_page(Xow_wiki wiki, Xoa_url page_url) {
|
||||
Xod_page_itm rv = new Xod_page_itm();
|
||||
@@ -35,7 +36,7 @@ public class Xod_page_mgr {
|
||||
|
||||
// load page data
|
||||
Xoh_page hpg = new Xoh_page();
|
||||
hpg.Init(wiki, Xoa_url.new_(wiki.Domain_bry(), ttl.Page_db()), ttl, 1);
|
||||
hpg.Init(wiki, Xoa_url.New(wiki, ttl), ttl, 1);
|
||||
rv.Init_by_hpg(hpg);
|
||||
wiki.Html__hdump_mgr().Load_mgr().Load(hpg, ttl);
|
||||
Load_sections(rv, hpg);
|
||||
@@ -56,17 +57,14 @@ public class Xod_page_mgr {
|
||||
|
||||
// generate special
|
||||
Xoh_page page = new Xoh_page();
|
||||
page.Init(wiki, Xoa_url.new_(wiki.Domain_bry(), ttl.Page_db()), ttl, 1); // NOTE: init page to set url, ttl; DATE:2016-06-23
|
||||
page.Init(wiki, Xoa_url.New(wiki, ttl), ttl, 1); // NOTE: init page to set url, ttl; DATE:2016-06-23
|
||||
try {proto.Special__clone().Special__gen(wiki, page, url, ttl);}
|
||||
catch (Exception e) {Gfo_log_.Instance.Warn("failed to generate special page", "url", url.To_str(), "err", Err_.Message_gplx_log(e)); return rv;}
|
||||
|
||||
// handle redirects; EX: Special:XowaWikiInfo
|
||||
byte[] redirect_to_ttl = page.Redirect_to_ttl();
|
||||
if (redirect_to_ttl != null) {
|
||||
ttl = wiki.Ttl_parse(redirect_to_ttl);
|
||||
url = Xoa_url.new_(wiki.Domain_bry(), redirect_to_ttl);
|
||||
return Get_page(wiki, url);
|
||||
}
|
||||
Xopg_redirect_itm redirect_itm = page.Redirect().Itms__get_at_nth_or_null();
|
||||
if (redirect_itm != null)
|
||||
return Get_page(wiki, redirect_itm.Url());
|
||||
|
||||
rv.Init(-1, -1, String_.new_u8(ttl.Page_txt()), String_.new_u8(ttl.Page_db()), null, null, DateAdp_.Now().XtoStr_fmt_iso_8561(), false, false, false, 0, "", "", "");
|
||||
rv.Init_by_hpg(page);
|
||||
|
||||
@@ -19,7 +19,6 @@ package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.threads.*; import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.fsdb.data.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.caches.*; import gplx.xowa.guis.cbks.js.*;
|
||||
import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
public class Xof_file_wkr implements Gfo_thread_wkr {
|
||||
private final Xof_orig_mgr orig_mgr; private final Xof_bin_mgr bin_mgr; private final Fsm_mnt_mgr mnt_mgr; private final Xou_cache_mgr cache_mgr;
|
||||
private final Gfo_usr_dlg usr_dlg; private final Xow_repo_mgr repo_mgr; private final Xog_js_wkr js_wkr;
|
||||
@@ -83,7 +82,7 @@ public class Xof_file_wkr implements Gfo_thread_wkr {
|
||||
fsdb.File_size_(file.Size());
|
||||
}
|
||||
Js_img_mgr.Update_img(page, js_wkr, fsdb);
|
||||
cache_mgr.Update(fsdb);
|
||||
if (cache_mgr != null) cache_mgr.Update(fsdb); // cache_mgr null during tests;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
usr_dlg.Warn_many("", "", "file.unknown: err=~{0}", Err_.Message_gplx_full(e));
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Xou_cache_mgr {
|
||||
}
|
||||
conn.Txn_end();
|
||||
}
|
||||
catch (Exception e) {conn.Txn_cxl(); throw e;}
|
||||
catch (Exception e) {conn.Txn_cxl(); throw Err_.new_exc(e, "cache", "unknown error while saving cache; err=~{0}", Err_.Message_gplx_log(e));}
|
||||
}
|
||||
}
|
||||
public void Reduce(long reduce_to) {
|
||||
|
||||
@@ -69,7 +69,7 @@ class Xof_file_fxt {
|
||||
itm.Init_at_lnki(arg.Exec_tid(), wiki.Domain_itm().Abrv_xo(), ttl_bry, arg.Lnki_type(), arg.Lnki_upright(), arg.Lnki_w(), arg.Lnki_h(), arg.Lnki_time(), Xof_lnki_page.Null, Xof_patch_upright_tid_.Tid_all);
|
||||
List_adp itms_list = List_adp_.New(); itms_list.Add(itm);
|
||||
orig_mgr.Find_by_list(Ordered_hash_.New_bry(), itms_list, Xof_exec_tid.Tid_wiki_page);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__main, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Xow_ns_.Tid__main, ttl_bry);
|
||||
Xoae_page page = Xoae_page.New(wiki, ttl);
|
||||
fsdb_mgr.Fsdb_search_by_list(itms_list, wiki, page, Xog_js_wkr_.Noop);
|
||||
if (arg.Rslt_orig_exists() != Bool_.__byte) Tfds.Eq(arg.Rslt_orig_exists() == Bool_.Y_byte, itm.Orig_exists(), "orig_exists");
|
||||
|
||||
@@ -26,13 +26,13 @@ class Xof_wiki_finder { // UNUSED
|
||||
}
|
||||
public Xoae_page Get_page(int ns, byte[] ttl_bry) {
|
||||
Xoae_page rv = Get_page__by_wiki(wiki_0, ns, ttl_bry);
|
||||
if (rv.Missing())
|
||||
if (rv.Db().Page().Exists_n())
|
||||
rv = Get_page__by_wiki(wiki_1, ns, ttl_bry);
|
||||
return rv;
|
||||
}
|
||||
private Xoae_page Get_page__by_wiki(Xowe_wiki wiki, int ns_id, byte[] ttl_bry) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ns_id, ttl_bry) ;
|
||||
Xoa_url url = Xoa_url.new_(wiki.Domain_bry(), ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ns_id, ttl_bry) ;
|
||||
Xoa_url url = Xoa_url.New(wiki, ttl);
|
||||
return wiki.Data_mgr().Load_page_and_parse(url, ttl);
|
||||
}
|
||||
private int qry_count, qry_count_max = 1000;
|
||||
@@ -53,7 +53,7 @@ class Xof_wiki_finder { // UNUSED
|
||||
itm.Orig_ttl_(ttl_bry);
|
||||
if (db_page.Redirected()) {
|
||||
Xoae_page page = Get_page__by_wiki(wiki, ns_id, ttl_bry);
|
||||
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect_loop(page.Data_raw());
|
||||
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect_loop(page.Db().Text().Text_bry());
|
||||
itm.Orig_redirect_(redirect_ttl);
|
||||
++qry_count;
|
||||
if (qry_count >= qry_count_max) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xofw_wiki_wkr_base implements Xofw_wiki_finder {
|
||||
byte[] wiki_key = repo_pair.Src().Wiki_domain();
|
||||
if (repo_pair.Src().Wmf_api()) continue;
|
||||
Xowe_wiki repo_wiki = (Xowe_wiki)wiki_mgr.Get_by_or_null(wiki_key); if (repo_wiki == null) {continue;}
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(repo_wiki, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(repo_wiki, ttl_bry);
|
||||
Xow_ns file_ns = repo_wiki.Ns_mgr().Ns_file();
|
||||
boolean found = repo_wiki.Db_mgr().Load_mgr().Load_by_ttl(tmp_db_page, file_ns, ttl.Page_db());
|
||||
if (!found) {continue;}
|
||||
@@ -41,7 +41,7 @@ public class Xofw_wiki_wkr_base implements Xofw_wiki_finder {
|
||||
file.Orig_repo_id_(-1);
|
||||
}
|
||||
public boolean Locate(Xofw_file_finder_rslt rv, List_adp repo_pairs, byte[] ttl_bry) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry); // NOTE: parse(ttl_bry) should be the same across all wikis; i.e.: there should be no aliases/namespaces
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry); // NOTE: parse(ttl_bry) should be the same across all wikis; i.e.: there should be no aliases/namespaces
|
||||
Xow_ns file_ns = wiki.Ns_mgr().Ns_file(); // NOTE: file_ns should also be the same across all wikis; being used for data_mgr.Parse below
|
||||
byte[] ttl_db_key = ttl.Page_db();
|
||||
rv.Init(ttl_db_key);
|
||||
|
||||
@@ -20,23 +20,35 @@ import gplx.xowa.apps.fsys.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_repo_mgr_ {
|
||||
public static void Assert_repos(Xoae_app app, Xowe_wiki wiki) {
|
||||
Xoa_repo_mgr repo_mgr = app.File_mgr().Repo_mgr();
|
||||
Xoa_fsys_mgr app_fsys_mgr = app.Fsys_mgr();
|
||||
Xof_rule_mgr ext_rule_mgr = app.File_mgr().Ext_rules();
|
||||
byte[] domain_bry = wiki.Domain_bry();
|
||||
Xof_repo_itm repo_itm = repo_mgr.Get_by(domain_bry);
|
||||
if (repo_itm == null) { // no repo for wiki exists; create it;
|
||||
repo_itm = new Xof_repo_itm(domain_bry, app_fsys_mgr, ext_rule_mgr, domain_bry);
|
||||
repo_mgr.Add(repo_itm);
|
||||
}
|
||||
Xowe_repo_mgr pair_mgr = wiki.File_mgr().Repo_mgr();
|
||||
if (pair_mgr.Repos_len() == 0) { // no pairs defined; add at least 1
|
||||
Xof_repo_itm repo_src = repo_mgr.Get_by(File_repo_xowa_null);
|
||||
if (repo_src == null) {
|
||||
repo_itm = new Xof_repo_itm(File_repo_xowa_null, app_fsys_mgr, ext_rule_mgr, Xow_domain_tid_.Bry__home);
|
||||
synchronized (app) { // LOCK:app-level; DATE:2016-07-07
|
||||
Xoa_repo_mgr repo_mgr = app.File_mgr().Repo_mgr();
|
||||
Xoa_fsys_mgr app_fsys_mgr = app.Fsys_mgr();
|
||||
Xof_rule_mgr ext_rule_mgr = app.File_mgr().Ext_rules();
|
||||
byte[] domain_bry = wiki.Domain_bry();
|
||||
Xof_repo_itm repo_itm = repo_mgr.Get_by(domain_bry);
|
||||
if (repo_itm == null) { // no repo for wiki exists; create it;
|
||||
repo_itm = new Xof_repo_itm(domain_bry, app_fsys_mgr, ext_rule_mgr, domain_bry);
|
||||
repo_itm.Root_str_(wiki.Fsys_mgr().Root_dir().Raw()); // NOTE: needed for mass_parse; ordinarily called by xowa.gfs; DATE:2016-07-07
|
||||
repo_mgr.Add(repo_itm);
|
||||
}
|
||||
pair_mgr.Add_repo(File_repo_xowa_null, domain_bry);
|
||||
Xowe_repo_mgr pair_mgr = wiki.File_mgr().Repo_mgr();
|
||||
if (pair_mgr.Repos_len() == 0) { // no pairs defined; add at least 1
|
||||
Xof_repo_itm repo_src = repo_mgr.Get_by(File_repo_xowa_null);
|
||||
if (repo_src == null) {
|
||||
repo_itm = new Xof_repo_itm(File_repo_xowa_null, app_fsys_mgr, ext_rule_mgr, Xow_domain_tid_.Bry__home);
|
||||
repo_mgr.Add(repo_itm);
|
||||
}
|
||||
pair_mgr.Add_repo(File_repo_xowa_null, domain_bry);
|
||||
|
||||
// add commons; needed for mass_parse, else multiple "repo_mgr.invalid_repo" when common files exist in user_cache; DATE:2016-07-07
|
||||
Xof_repo_itm commons_repo = repo_mgr.Get_by(Xow_domain_itm_.Bry__commons);
|
||||
if (commons_repo == null) {
|
||||
commons_repo = new Xof_repo_itm(Xow_domain_itm_.Bry__commons, app_fsys_mgr, ext_rule_mgr, domain_bry);
|
||||
commons_repo.Root_str_(app.Fsys_mgr().Wiki_dir().GenSubDir(Xow_domain_itm_.Str__commons).Raw()); // NOTE: needed for mass_parse; ordinarily called by xowa.gfs; DATE:2016-07-07
|
||||
repo_mgr.Add(commons_repo);
|
||||
}
|
||||
pair_mgr.Add_repo(Xow_domain_itm_.Bry__commons, Xow_domain_itm_.Bry__commons);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static byte[] File_repo_xowa_null = Bry_.new_a7("xowa_repo_null");
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Xof_xfer_queue_base_fxt {
|
||||
public void ini_page_create_en_wiki(String ttl) {Init_page_create(en_wiki, ttl, "");}
|
||||
public void ini_page_create_en_wiki_redirect(String ttl, String redirect) {Init_page_create(en_wiki, ttl, "#REDIRECT [[" + redirect + "]]");}
|
||||
public void Init_page_create(Xowe_wiki wiki, String ttl, String txt) {
|
||||
Xoa_ttl page_ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl));
|
||||
Xoa_ttl page_ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl));
|
||||
byte[] page_raw = Bry_.new_u8(txt);
|
||||
wiki.Db_mgr().Save_mgr().Data_create(page_ttl, page_raw);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Xogv_page_load_wkr implements Gfo_thread_wkr, Gfo_invk {
|
||||
}
|
||||
private Xoh_page Fetch_page(byte[] wiki_domain, byte[] page_bry, byte[] qarg_bry) {
|
||||
Xowv_wiki wiki = (Xowv_wiki)wiki_mgr.Get_by_or_null(wiki_domain);
|
||||
if (wiki == null) return new Xoh_page().Exists_n_(); // wiki does not exist; happens with xwiki; PAGE:s.w:Photon; EX:[[wikt:transmit]]; DATE:2015-04-27
|
||||
if (wiki == null) return Xoh_page.New_missing(); // wiki does not exist; happens with xwiki; PAGE:s.w:Photon; EX:[[wikt:transmit]]; DATE:2015-04-27
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(page_bry);
|
||||
Gfo_url url = url_parser.Parse(Bry_.Add(wiki_domain, Byte_ascii.Slash_bry, page_bry, qarg_bry));
|
||||
Xoh_page rv = new Xoh_page();
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.guis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.guis.history.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.guis.history.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.wikis.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.core.threads.*;
|
||||
public abstract class Xogv_tab_base {
|
||||
@@ -34,7 +34,7 @@ public abstract class Xogv_tab_base {
|
||||
Xog_history_itm old_itm = this.Cur_itm();
|
||||
Xog_history_itm new_itm = new Xog_history_itm(wiki, page, anch, qarg, redirect_force, bmk_pos);
|
||||
Xoh_page rv = Fetch_page_and_show(old_itm, new_itm);
|
||||
if (rv.Exists())
|
||||
if (rv.Db().Page().Exists())
|
||||
history_stack.Add(new_itm);
|
||||
return rv;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public abstract class Xogv_tab_base {
|
||||
return Fetch_page_and_show(old_itm, new_itm);
|
||||
}
|
||||
private Xoh_page Fetch_page_and_show(Xog_history_itm old_itm, Xog_history_itm new_itm) {
|
||||
if (new_itm == Xog_history_itm.Null) return new Xoh_page().Exists_n_();
|
||||
if (new_itm == Xog_history_itm.Null) return Xoh_page.New_missing();
|
||||
Fetch_page__bgn(new_itm.Wiki(), new_itm.Page(), new_itm.Qarg());
|
||||
Xoh_page new_hpg = new Xoh_page();
|
||||
// Thread_adp_.Start_by_key(Xogv_page_load_wkr.Thread_name, new Xogv_page_load_wkr(wiki_mgr, url_parser, this, old_itm, new_itm), Xogv_page_load_wkr.Invk_exec);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Xog_history_mgr {
|
||||
byte[] page_key = Build_page_key(itm.Wiki(), itm.Page(), itm.Qarg());
|
||||
Xoae_page rv = (Xoae_page)hash.Get_by(page_key);
|
||||
if (rv != null) return rv;
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, itm.Page());
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, itm.Page());
|
||||
return wiki.Data_mgr().Load_page_by_ttl(ttl);
|
||||
}
|
||||
private static byte[] Build_page_key(Xoae_page page) {return Build_page_key(page.Wiki().Domain_bry(), page.Ttl().Full_url(), page.Url().Qargs_mgr().To_bry());}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Xog_history_stack_fxt {
|
||||
}
|
||||
public Xog_history_stack_fxt Exec_add_one(String ttl_str, String arg_str) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
Xoae_page page = Xoae_page.New_test(wiki, ttl);
|
||||
byte[] url_bry = ttl_bry;
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));
|
||||
|
||||
@@ -62,11 +62,11 @@ class Xog_launcher_tabs {
|
||||
Xoae_app app = win.App();
|
||||
Xoa_url launch_url = home_wiki.Utl__url_parser().Parse_by_urlbar_or_null(launch_str); if (launch_url == null) return;
|
||||
Xowe_wiki launch_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(launch_url.Wiki_bry());
|
||||
Xoa_ttl launch_ttl = Xoa_ttl.parse(launch_wiki, launch_url.Page_bry());
|
||||
Xoa_ttl launch_ttl = Xoa_ttl.Parse(launch_wiki, launch_url.Page_bry());
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(launch_wiki, Xoae_page.New(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
|
||||
tab.Show_url_bgn(launch_url);
|
||||
}
|
||||
public static final Xog_launcher_tabs Instance = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
|
||||
public static final Xog_launcher_tabs Instance = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
|
||||
}
|
||||
class Io_fil_marker {
|
||||
private Io_url url;
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Xog_tab_itm implements Gfo_invk {
|
||||
this.wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(url.Wiki_bry()); // NOTE: must update wiki variable; DATE:????-??-??; NOTE: must load wiki; DATE:2015-07-22
|
||||
if (url.Page_is_main()) url.Page_bry_(wiki.Props().Main_page());
|
||||
if (url.Vnt_bry() != null) Cur_vnt_(wiki, url.Vnt_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, url.Page_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url.Page_bry());
|
||||
if (ttl == null) {usr_dlg.Prog_one("", "", "title is invalid: ~{0}", String_.new_u8(url.Raw())); return;}
|
||||
Tab_name_(String_.new_u8(ttl.Full_txt_w_ttl_case()));
|
||||
usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_u8(ttl.Raw()));
|
||||
@@ -143,7 +143,7 @@ public class Xog_tab_itm implements Gfo_invk {
|
||||
try {
|
||||
if (page.Tab_data().Cancel_show()) return; // Special:Search canceled show; NOTE: must be inside try b/c finally handles thread
|
||||
wiki.Parser_mgr().Ctx().Page_(page);
|
||||
if (page.Missing()) {
|
||||
if (page.Db().Page().Exists_n()) {
|
||||
if (wiki.Db_mgr().Save_mgr().Create_enabled()) {
|
||||
page = Xoae_page.New_edit(wiki, ttl);
|
||||
view_mode = Xopg_page_.Tid_edit;
|
||||
@@ -152,8 +152,8 @@ public class Xog_tab_itm implements Gfo_invk {
|
||||
}
|
||||
else {
|
||||
wkr.Page().Tab_data().Tab().Page_(page); // NOTE: must set tab's page to current page, so that switching to it will update url bar; EX:pt.b:A"MANUAL_DE_PROCEDURI_.Sectiunea:""CONTABILITATE_SI_MANAGEMENT_FINANCIAR""" DATE:2015-09-17
|
||||
if (page.Redirected_ttls().Count() > 0)
|
||||
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_u8(page.Url().Page_bry()), String_.new_u8((byte[])page.Redirected_ttls().Get_at(0)));
|
||||
if (page.Redirect().Itms__len() > 0)
|
||||
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_u8(page.Url().Page_bry()), page.Redirect().Itms__get_at(0).Ttl().Full_db());
|
||||
else {
|
||||
if (ttl.Ns().Id_is_file())
|
||||
usr_dlg.Prog_one("", "", "commons.wikimedia.org must be installed in order to view the file. See [[App/Wiki_types/Commons]]: ~{0}", String_.new_u8(url.Raw()));// HOME
|
||||
@@ -164,7 +164,7 @@ public class Xog_tab_itm implements Gfo_invk {
|
||||
app.Log_wtr().Queue_enabled_(false);
|
||||
return;
|
||||
}
|
||||
if (!page.Redirected()) page.Url_(url); // NOTE: handle redirect from commons
|
||||
// if (!page.Redirected()) page.Url_(url); // NOTE: handle redirect from commons; COMMENTED: part of redirect rewrite; DATE:2016-07-05
|
||||
if (page.Ttl().Anch_bgn() != Bry_find_.Not_found) page.Url().Anch_bry_(page.Ttl().Anch_txt()); // NOTE: occurs when page is a redirect to an anchor; EX: w:Duck race -> Rubber duck#Races
|
||||
history_mgr.Add(page);
|
||||
Xog_tab_itm_read_mgr.Show_page(this, page, true);
|
||||
@@ -179,9 +179,9 @@ public class Xog_tab_itm implements Gfo_invk {
|
||||
if (page.Html_data().Hdump_exists()) {
|
||||
// wiki.File_mgr().Init_file_mgr_by_load(wiki);
|
||||
// Xof_fsdb_mgr fsdb_mgr = wiki.File_mgr().Fsdb_mgr();
|
||||
// async_wkr = new Xof_file_wkr(wiki.File__orig_mgr(), fsdb_mgr.Bin_mgr(), fsdb_mgr.Mnt_mgr(), app.Usere().User_db_mgr().Cache_mgr(), wiki.File__repo_mgr(), html_itm, page, page.Hdump_data().Imgs());
|
||||
// async_wkr = new Xof_file_wkr(wiki.File__orig_mgr(), fsdb_mgr.Bin_mgr(), fsdb_mgr.Mnt_mgr(), app.Usere().User_db_mgr().Cache_mgr(), wiki.File__repo_mgr(), html_itm, page, page.Hdump_mgr().Imgs());
|
||||
async_wkr = new Load_files_wkr(this);
|
||||
if (wiki.Html__hdump_enabled() && page.Revision_data().Html_db_id() == -1) {
|
||||
if (wiki.Html__hdump_enabled() && page.Db().Page().Html_db_id() == -1) {
|
||||
wiki.Html__hdump_mgr().Save_mgr().Save(page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,22 +26,22 @@ public class Xog_tab_itm_edit_mgr {
|
||||
byte[] new_text = Get_new_text(tab);
|
||||
if (page.Edit_mode() == Xoa_page_.Edit_mode_create) {
|
||||
int page_id = wiki.Db_mgr().Save_mgr().Data_create(page.Ttl(), new_text);
|
||||
page.Revision_data().Id_(page_id);
|
||||
page.Db().Page().Id_(page_id);
|
||||
page.Edit_mode_update_(); // set to update so that next save does not try to create
|
||||
}
|
||||
else {
|
||||
wiki.Db_mgr().Save_mgr().Data_update(page, new_text);
|
||||
}
|
||||
Invalidate(wiki);
|
||||
page.Data_raw_(new_text);
|
||||
page.Db().Text().Text_bry_(new_text);
|
||||
wiki.Parser_mgr().Parse(page, true); // refresh html
|
||||
if (wiki.Html__hdump_enabled()) wiki.Html__hdump_mgr().Save_mgr().Save(page); // must go after wiki.Parse
|
||||
win_itm.Usr_dlg().Prog_one("", "", "saved page ~{0}", String_.new_u8(page.Ttl().Full_txt_raw())); // NOTE: show message after Parse, b/c Parse will flash "Loading page"; DATE:2014-05-17
|
||||
if (!quick_save) { // full_save; save page and go to read mode
|
||||
page.Html_data().Edit_preview_(Bry_.Empty);
|
||||
Xoae_page stack_page = tab.History_mgr().Cur_page(wiki); // NOTE: must be to CurPage() else changes will be lost when going Bwd,Fwd
|
||||
stack_page.Data_raw_(page.Data_raw()); // NOTE: overwrite with "saved" changes
|
||||
stack_page.Wikie().Parser_mgr().Parse(page, true); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
|
||||
stack_page.Db().Text().Text_bry_(page.Db().Text().Text_bry()); // NOTE: overwrite with "saved" changes
|
||||
stack_page.Wikie().Parser_mgr().Parse(page, true); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
|
||||
win_itm.Page__mode_(Xopg_page_.Tid_read);
|
||||
win_itm.Page__async__bgn(tab);
|
||||
}
|
||||
@@ -54,8 +54,8 @@ public class Xog_tab_itm_edit_mgr {
|
||||
|
||||
byte[] new_text = Get_new_text(tab);
|
||||
Xoae_page new_page = Xoae_page.New(wiki, page.Ttl());
|
||||
new_page.Revision_data().Id_(page.Revision_data().Id()); // NOTE: page_id needed for sqlite (was not needed for xdat)
|
||||
new_page.Data_raw_(new_text);
|
||||
new_page.Db().Page().Id_(page.Db().Page().Id()); // NOTE: page_id needed for sqlite (was not needed for xdat)
|
||||
new_page.Db().Text().Text_bry_(new_text);
|
||||
wiki.Parser_mgr().Parse(new_page, true); // refresh html
|
||||
tab.Page_(new_page); new_page.Tab_data().Tab_(tab); // replace old page with new_page; DATE:2014-10-09
|
||||
|
||||
@@ -81,14 +81,14 @@ public class Xog_tab_itm_edit_mgr {
|
||||
byte[] new_text = Bry_.new_u8(tab.Html_itm().Get_elem_value(Xog_html_itm.Elem_id__xowa_edit_rename_box));
|
||||
if (Bry_.Len_eq_0(new_text)) return; // no ttl given; exit
|
||||
new_text = Xoa_ttl.Replace_spaces(new_text); // ttls cannot have spaces; only underscores
|
||||
Xoa_ttl new_ttl = Xoa_ttl.parse(wiki, new_text);
|
||||
Xoa_ttl new_ttl = Xoa_ttl.Parse(wiki, new_text);
|
||||
int new_ns_id = new_ttl.Ns().Id();
|
||||
if (new_ns_id != Xow_ns_.Tid__main) {
|
||||
win_itm.Usr_dlg().Warn_many("", "", "The new page name must remain in the same namespace");
|
||||
return;
|
||||
}
|
||||
wiki.Db_mgr().Save_mgr().Data_rename(page, new_ns_id, new_text);
|
||||
page.Ttl_(Xoa_ttl.parse(wiki, Bry_.Add(page.Ttl().Ns().Name_db_w_colon(), new_text)));
|
||||
page.Ttl_(Xoa_ttl.Parse(wiki, Bry_.Add(page.Ttl().Ns().Name_db_w_colon(), new_text)));
|
||||
win_itm.Page__mode_(Xopg_page_.Tid_read);
|
||||
win_itm.Usr_dlg().Prog_one("", "", "renamed page to {0}", String_.new_u8(page.Ttl().Full_txt_raw()));
|
||||
}
|
||||
@@ -105,12 +105,12 @@ public class Xog_tab_itm_edit_mgr {
|
||||
Xoa_ttl ttl = page.Ttl();
|
||||
Xoae_page new_page = Xoae_page.New(wiki, ttl);
|
||||
byte[] data = tab.Html_itm().Get_elem_value_for_edit_box_as_bry();
|
||||
new_page.Data_raw_(data);
|
||||
new_page.Db().Text().Text_bry_(data);
|
||||
wiki.Parser_mgr().Parse(new_page, true);
|
||||
Bry_bfr bfr = win.App().Utl__bfr_mkr().Get_m001();
|
||||
bfr.Add(new_page.Root().Root_src());
|
||||
wiki.Parser_mgr().Ctx().Defn_trace().Print(data, bfr);
|
||||
new_page.Data_raw_(bfr.To_bry_and_rls());
|
||||
new_page.Db().Text().Text_bry_(bfr.To_bry_and_rls());
|
||||
byte old = tab.View_mode();
|
||||
tab.View_mode_(view_tid);
|
||||
Xog_tab_itm_read_mgr.Show_page(tab, new_page, false);
|
||||
@@ -118,7 +118,7 @@ public class Xog_tab_itm_edit_mgr {
|
||||
tab.View_mode_(old);
|
||||
}
|
||||
private static void Invalidate(Xowe_wiki wiki) {// invalidate everything on updates; especially needed for page transclusion; {{/my_subpage}} DATE:2014-04-10
|
||||
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
|
||||
wiki.Parser_mgr().Scrib().Core().Term();
|
||||
wiki.Cache_mgr().Free_mem_all();
|
||||
}
|
||||
private static byte[] Get_new_text(Xog_tab_itm tab) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Xog_tab_mgr implements Gfo_evt_itm {
|
||||
public Xog_tab_itm Tabs_new_dflt(boolean focus) {
|
||||
boolean active_tab_is_null = this.Active_tab_is_null();
|
||||
Xowe_wiki cur_wiki = active_tab_is_null ? win.App().Usere().Wiki() : active_tab.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, Xow_special_meta_.Itm__default_tab.Ttl_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(cur_wiki, Xow_special_meta_.Itm__default_tab.Ttl_bry());
|
||||
Xoa_url url = cur_wiki.Utl__url_parser().Parse_by_urlbar_or_null(ttl.Full_db_as_str()); if (url == null) throw Err_.new_("url", "invalid url", "url", url);
|
||||
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null, cur_wiki, Xoae_page.New(cur_wiki, ttl));
|
||||
rv.Page_update_ui();
|
||||
|
||||
@@ -155,7 +155,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
public void Page__mode_(byte new_mode_tid) {
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab(); Xoae_page page = tab.Page(); Xowe_wiki wiki = tab.Wiki();
|
||||
if ( new_mode_tid == Xopg_page_.Tid_read // used to be && cur_view_tid == Edit; removed clause else redlinks wouldn't show when going form html to read (or clicking read multiple times) DATE: 2013-11-26;
|
||||
&& !page.Missing() // if new page, don't try to reload
|
||||
&& page.Db().Page().Exists() // if new page, don't try to reload
|
||||
) {
|
||||
// NOTE: if moving from "Edit" to "Read", reload page (else Preview changes will still show); NOTE: do not call Exec_page_reload / Exec_page_refresh, which will fire redlinks code
|
||||
page = tab_mgr.Active_tab().History_mgr().Cur_page(wiki); // NOTE: must set to CurPage() else changes will be lost when going Bwd,Fwd
|
||||
@@ -166,7 +166,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
url = tab.Wiki().Utl__url_parser().Parse(url.To_bry_full_wo_qargs()); // remove all query args; handle (1) s.w:Earth?action=edit; (2) click on Read; DATE:2014-03-06
|
||||
}
|
||||
tab.View_mode_(new_mode_tid);
|
||||
if (page.Missing()) return;
|
||||
if (page.Db().Page().Exists_n()) return;
|
||||
Xog_tab_itm_read_mgr.Show_page(tab, page, false);
|
||||
// Exec_page_refresh(); // commented out; causes lnke to show as [2] instead of [1] when saving page; EX: [http://a.org b] DATE:2014-04-24
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
if (tab == Xog_tab_itm_.Null) return;
|
||||
Xoae_page cur_page = tab.Page(); Xowe_wiki cur_wiki = tab.Wiki();
|
||||
Xoae_page new_page = tab.History_mgr().Go_by_dir(cur_wiki, fwd);
|
||||
if (new_page.Missing()) return;
|
||||
if (new_page.Db().Page().Exists_n()) return;
|
||||
if (new_page.Ttl().Ns().Id_is_special()) // if Special, reload page; needed for Special:Search (DATE:2015-04-19; async loading) and Special:XowaBookmarks DATE:2015-10-05
|
||||
new_page = new_page.Wikie().Data_mgr().Load_page_and_parse(new_page.Url(), new_page.Ttl()); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
|
||||
byte history_nav_type = fwd ? Xog_history_stack.Nav_fwd : Xog_history_stack.Nav_bwd;
|
||||
@@ -213,7 +213,6 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
}
|
||||
public void Page__async__bgn(Xog_tab_itm tab) {
|
||||
page__async__thread = Thread_adp_.Start_by_val(gplx.xowa.apps.Xoa_thread_.Key_page_async, this, Invk_page_async_exec, tab);
|
||||
page__async__thread.Thread__start();
|
||||
} private Thread_adp page__async__thread = Thread_adp.Noop;
|
||||
public boolean Page__async__working(Xoa_url url) {
|
||||
if (page__async__thread.Thread__is_alive()) { // cancel pending image downloads
|
||||
@@ -257,16 +256,16 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
|
||||
Xowe_wiki home_wiki = app.Usere().Wiki();
|
||||
Xoa_url url = home_wiki.Utl__url_parser().Parse_by_urlbar_or_null(url_str); if (url == null) return Bry_.Empty;
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(url.Wiki_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, url.Page_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url.Page_bry());
|
||||
Xoae_page new_page = wiki.Data_mgr().Load_page_and_parse(url, ttl);
|
||||
if (new_page.Missing()) {return Bry_.Empty;}
|
||||
if (new_page.Db().Page().Exists_n()) {return Bry_.Empty;}
|
||||
gplx.xowa.apps.servers.Gxw_html_server.Assert_tab(app, new_page); // HACK: assert at least 1 tab for Firefox addon; DATE:2015-01-23
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab();
|
||||
tab.Page_(new_page);
|
||||
tab.History_mgr().Add(new_page);
|
||||
byte[] rv = output_html
|
||||
? wiki.Html_mgr().Page_wtr_mgr().Gen(new_page, tab.View_mode())
|
||||
: new_page.Data_raw();
|
||||
: new_page.Db().Text().Text_bry();
|
||||
if (app.Shell().Fetch_page_exec_async())
|
||||
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
||||
return rv;
|
||||
|
||||
@@ -81,14 +81,16 @@ public class Xog_error_win extends JFrame implements Gfo_invk {
|
||||
String subject = url_encoder.Encode_str("XOWA boot error: " + error_data.Err_msg());
|
||||
String body = url_encoder.Encode_str(error_data.Err_details());
|
||||
Desktop.getDesktop().mail(new URI("mailto:gnosygnu+xowa_error_boot@gmail.com?subject=" + subject + "&body=" + body));
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
}
|
||||
}
|
||||
catch (URISyntaxException ex) {}
|
||||
catch (IOException ex) {}
|
||||
}
|
||||
else if (ctx.Match(k, Invk_open_site)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://github.com/gnosygnu/xowa/issues"));
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
}
|
||||
}
|
||||
catch (URISyntaxException ex) {}
|
||||
catch (IOException ex) {}
|
||||
}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -16,38 +16,34 @@ 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.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.redirects.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.tocs.*;
|
||||
import gplx.xowa.wikis.pages.dbs.*; import gplx.xowa.wikis.pages.hdumps.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xoh_page implements Xoa_page {
|
||||
// core
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Xoa_url Url() {return page_url;} private Xoa_url page_url;
|
||||
public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Xoa_url Url() {return page_url;} private Xoa_url page_url;
|
||||
public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public Xopg_db_data Db() {return db;} private final Xopg_db_data db = new Xopg_db_data();
|
||||
public Xopg_redirect_data Redirect() {return redirect;} private final Xopg_redirect_data redirect = new Xopg_redirect_data();
|
||||
public Xopg_html_data Html_data() {return html;} private final Xopg_html_data html = new Xopg_html_data();
|
||||
public Xopg_hdump_data Hdump_mgr() {return hdump;} private final Xopg_hdump_data hdump = new Xopg_hdump_data();
|
||||
|
||||
public void Xtn_gallery_packed_exists_y_() {}
|
||||
public boolean Xtn__timeline_exists() {return xtn__timeline_exists;} private boolean xtn__timeline_exists; public void Xtn__timeline_exists_y_() {xtn__timeline_exists = true;}
|
||||
public boolean Xtn__gallery_exists() {return xtn__gallery_exists;} private boolean xtn__gallery_exists; public void Xtn__gallery_exists_y_() {xtn__gallery_exists = true;}
|
||||
|
||||
// props
|
||||
public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true;
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public byte[] Body() {return body;} public void Body_(byte[] v) {this.body = v;} private byte[] body;
|
||||
public int Body_zip_tid() {return body_zip_tid;} private int body_zip_tid;
|
||||
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;
|
||||
public Xoh_section_mgr Section_mgr() {return section_mgr;} private final Xoh_section_mgr section_mgr = new Xoh_section_mgr();
|
||||
public Xoh_img_mgr Img_mgr() {return img_mgr;} private Xoh_img_mgr img_mgr = new Xoh_img_mgr();
|
||||
public Ordered_hash Redlink_uids() {return redlink_uids;} private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
public Xohd_img_itm__base[] Img_itms() {return img_itms;} public void Img_itms_(Xohd_img_itm__base[] v) {this.img_itms = v;} private Xohd_img_itm__base[] img_itms = Xohd_img_itm__base.Ary_empty;
|
||||
public Ordered_hash Gallery_itms() {return gallery_itms;} private Ordered_hash gallery_itms = Ordered_hash_.New();
|
||||
public Xopg_module_mgr Head_mgr() {return head_mgr;} private Xopg_module_mgr head_mgr = new Xopg_module_mgr();
|
||||
public void Xtn_gallery_packed_exists_y_() {}
|
||||
public boolean Xtn__timeline_exists() {return xtn__timeline_exists;} private boolean xtn__timeline_exists; public void Xtn__timeline_exists_y_() {xtn__timeline_exists = true;}
|
||||
public boolean Xtn__gallery_exists() {return xtn__gallery_exists;} private boolean xtn__gallery_exists; public void Xtn__gallery_exists_y_() {xtn__gallery_exists = true;}
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
|
||||
|
||||
// util
|
||||
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list = new Xopg_lnki_list();
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page;
|
||||
public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty; // drd:web_browser
|
||||
@@ -55,31 +51,41 @@ public class Xoh_page implements Xoa_page {
|
||||
public void Init(Xow_wiki wiki, Xoa_url page_url, Xoa_ttl page_ttl, int page_id) {
|
||||
this.wiki = wiki; this.page_url = page_url; this.page_ttl = page_ttl; this.page_id = page_id;
|
||||
this.Clear();
|
||||
redlink_list.Disabled_(page_ttl.Ns().Id_is_module()); // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
html.Redlink_list().Disabled_(page_ttl.Ns().Id_is_module()); // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
hdump.Toc_wtr().Init(wiki.Lang().Msg_mgr().Itm_by_id_or_null(gplx.xowa.langs.msgs.Xol_msg_itm_.Id_toc).Val(), page_url.Raw());
|
||||
}
|
||||
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_zip_tid = zip_tid; this.body_hzip_tid = hzip_tid;
|
||||
this.display_ttl = display_ttl; this.content_sub = content_sub; this.sidebar_div = sidebar_div;
|
||||
db.Html().Html_bry_(body);
|
||||
db.Html().Zip_tids_(zip_tid, hzip_tid);
|
||||
}
|
||||
public Xoh_page Ctor_by_page(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
this.page_id = page.Revision_data().Id();
|
||||
this.page_id = page.Db().Page().Id();
|
||||
this.wiki = page.Wiki();
|
||||
this.body = page.Hdump_data().Body();
|
||||
db.Html().Html_bry_(page.Db().Html().Html_bry());
|
||||
this.page_url = page.Url();
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
Xoh_head_mgr mod_mgr = html_data.Head_mgr();
|
||||
Xopg_html_data html = page.Html_data();
|
||||
html.Init_by_page(page.Ttl());
|
||||
Xoh_head_mgr mod_mgr = html.Head_mgr();
|
||||
head_mgr.Init(mod_mgr.Itm__mathjax().Enabled(), mod_mgr.Itm__popups().Bind_hover_area(), mod_mgr.Itm__gallery().Enabled(), mod_mgr.Itm__hiero().Enabled());
|
||||
this.display_ttl = html_data.Display_ttl();
|
||||
this.content_sub = html_data.Content_sub();
|
||||
this.sidebar_div = Xoh_page_.Save_sidebars(tmp_bfr, page, html_data);
|
||||
this.display_ttl = html.Display_ttl();
|
||||
this.content_sub = html.Content_sub();
|
||||
this.sidebar_div = Xoh_page_.Save_sidebars(tmp_bfr, page, html);
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
this.body_zip_tid = -1; this.body_hzip_tid = -1;
|
||||
redirect.Clear();
|
||||
html.Clear();
|
||||
hdump.Clear();
|
||||
|
||||
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();
|
||||
head_mgr.Clear(); commons_mgr.Clear();
|
||||
section_mgr.Clear(); img_mgr.Clear();
|
||||
redlink_list.Clear();
|
||||
}
|
||||
public static Xoh_page New_missing() {
|
||||
Xoh_page rv = new Xoh_page();
|
||||
rv.Db().Page().Exists_n_();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xoh_page_ {
|
||||
public static byte[] Save_sidebars(Bry_bfr tmp_bfr, Xoae_page page, Xopg_html_data html_data) {
|
||||
Xopg_xtn_skin_mgr mgr = html_data.Xtn_skin_mgr();
|
||||
|
||||
@@ -20,6 +20,7 @@ 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.xtns.pagebanners.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.htmls.portal.*;
|
||||
public class Xoh_page_wtr_wkr {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); private final Object thread_lock_1 = new Object(), thread_lock_2 = new Object();
|
||||
@@ -73,7 +74,7 @@ public class Xoh_page_wtr_wkr {
|
||||
if (root_dir_bry == null) this.root_dir_bry = app.Fsys_mgr().Root_dir().To_http_file_bry();
|
||||
Xoa_ttl page_ttl = page.Ttl(); int page_ns_id = page_ttl.Ns().Id();
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), page_ns_id, page_ttl.Page_db());
|
||||
DateAdp modified_on = page.Revision_data().Modified_on();
|
||||
DateAdp modified_on = page.Db().Page().Modified_on();
|
||||
byte[] modified_on_msg = wiki.Msg_mgr().Val_by_id_args(Xol_msg_itm_.Id_portal_lastmodified, modified_on.XtoStr_fmt_yyyy_MM_dd(), modified_on.XtoStr_fmt_HHmm());
|
||||
byte[] page_body_class = Xoh_page_body_cls.Calc(tmp_bfr, page_ttl, page_tid);
|
||||
byte[] html_content_editable = wiki.Gui_mgr().Cfg_browser().Content_editable() ? Content_editable_bry : Bry_.Empty;
|
||||
@@ -84,7 +85,7 @@ public class Xoh_page_wtr_wkr {
|
||||
byte[] converted_title = vnt_mgr.Convert_lang().Converted_title(); // prefer converted title
|
||||
if (converted_title == null) // converted title does not exist; use regular page title and convert it
|
||||
converted_title = vnt_mgr.Convert_lang().Auto_convert(vnt_mgr.Cur_itm(), page_ttl.Page_txt());
|
||||
page_ttl = Xoa_ttl.parse(wiki, page_ttl.Ns().Id(), converted_title);
|
||||
page_ttl = Xoa_ttl.Parse(wiki, page_ttl.Ns().Id(), converted_title);
|
||||
}
|
||||
byte[] page_name = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, null); // NOTE: page_name does not show display_title (<i>). always pass in null
|
||||
byte[] page_display_title = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl());
|
||||
@@ -92,12 +93,12 @@ public class Xoh_page_wtr_wkr {
|
||||
Xow_portal_mgr portal_mgr = wiki.Html_mgr().Portal_mgr().Init_assert();
|
||||
fmtr.Bld_bfr_many(bfr
|
||||
, root_dir_bry, Xoa_app_.Version, Xoa_app_.Build_date, app.Tcp_server().Running_str()
|
||||
, page.Revision_data().Id()
|
||||
, page.Db().Page().Id()
|
||||
, page_name, page.Html_data().Page_heading().Init(page.Html_data(), page_display_title)
|
||||
, modified_on_msg
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Head_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(ctx, page, hctx, page_data), page_body_class, html_content_editable
|
||||
, page_data, wdata_lang_wtr
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(page, ctx, hctx), page_body_class, html_content_editable
|
||||
, page_data, wdata_lang_wtr
|
||||
, portal_mgr.Div_personal_bry(), portal_mgr.Div_ns_bry(app.Utl__bfr_mkr(), page_ttl, wiki.Ns_mgr()), portal_mgr.Div_view_bry(app.Utl__bfr_mkr(), html_gen_tid, page.Html_data().Xtn_search_text())
|
||||
, portal_mgr.Div_logo_bry(), portal_mgr.Div_home_bry(), new Xopg_xtn_skin_fmtr_arg(page, Xopg_xtn_skin_itm_tid.Tid_sidebar), portal_mgr.Div_wikis_bry(app.Utl__bfr_mkr()), portal_mgr.Sidebar_mgr().Html_bry()
|
||||
, mgr.Edit_rename_div_bry(page_ttl), page.Html_data().Edit_preview_w_dbg(), js_edit_toolbar_bry
|
||||
@@ -105,12 +106,18 @@ public class Xoh_page_wtr_wkr {
|
||||
Xoh_page_wtr_wkr_.Bld_head_end(bfr, tmp_bfr, page); // add after </head>
|
||||
Xoh_page_wtr_wkr_.Bld_html_end(bfr, tmp_bfr, page); // add after </html>
|
||||
}
|
||||
public void Write_hdump(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page wpg) {
|
||||
if (wpg.Html_data().Xtn_pgbnr() != null) {
|
||||
ctx.Wiki().Xtn_mgr().Xtn_pgbnr().Write_html(wpg, ctx, hctx).Bfr_arg__add(bfr); // if pgbnr exists, write to top of html
|
||||
}
|
||||
this.Write_body(bfr, ctx, hctx, wpg);
|
||||
}
|
||||
public void Write_body(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page page) {
|
||||
synchronized (thread_lock_2) {
|
||||
this.page = page; this.wiki = page.Wikie(); this.app = wiki.Appe();
|
||||
Xoa_ttl page_ttl = page.Ttl(); int page_ns_id = page_ttl.Ns().Id();
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), page_ns_id, page_ttl.Page_db()); // NOTE: can't cache page_tid b/c Write_body is called directly; DATE:2014-10-02
|
||||
byte[] data_raw = page.Data_raw();
|
||||
byte[] data_raw = page.Db().Text().Text_bry();
|
||||
int bfr_page_bgn = bfr.Len();
|
||||
boolean page_tid_uses_pre = false;
|
||||
if (page_mode == Xopg_page_.Tid_edit)
|
||||
@@ -132,7 +139,7 @@ public class Xoh_page_wtr_wkr {
|
||||
}
|
||||
private void Write_body_wikitext(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, byte[] data_raw, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page page, byte page_tid, int ns_id) {
|
||||
// dump and exit if pre-generated html from html dumps
|
||||
byte[] hdump_data = page.Hdump_data().Body();
|
||||
byte[] hdump_data = page.Db().Html().Html_bry();
|
||||
if (Bry_.Len_gt_0(hdump_data)) {
|
||||
bfr.Add(hdump_data);
|
||||
return;
|
||||
@@ -178,7 +185,7 @@ public class Xoh_page_wtr_wkr {
|
||||
}
|
||||
// translate if variants are enabled
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) bfr.Add(vnt_mgr.Convert_lang().Parse_page(vnt_mgr.Cur_itm(), page.Revision_data().Id(), bfr.To_bry_and_clear()));
|
||||
if (vnt_mgr.Enabled()) bfr.Add(vnt_mgr.Convert_lang().Parse_page(vnt_mgr.Cur_itm(), page.Db().Page().Id(), bfr.To_bry_and_clear()));
|
||||
}
|
||||
private void Write_body_pre(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, byte[] data_raw, Bry_bfr tmp_bfr) {
|
||||
Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), tmp_bfr, data_raw, 0, data_raw.length, false, false);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoh_page_wtr_wkr_ {
|
||||
public static byte[] Bld_page_content_sub(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Bry_bfr tmp_bfr) {
|
||||
byte[] subpages = app.Html_mgr().Page_mgr().Subpages_bldr().Bld(wiki.Ns_mgr(), page.Ttl());
|
||||
byte[] page_content_sub = page.Html_data().Content_sub(); // contentSub exists; SEE: {{#isin}}
|
||||
byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page.Redirected_ttls());
|
||||
byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page.Redirect());
|
||||
return Bry_.Add(subpages, page_content_sub, redirect_msg);
|
||||
}
|
||||
public static byte[] Bld_page_name(Bry_bfr tmp_bfr, Xoa_ttl ttl, byte[] display_ttl) {
|
||||
|
||||
@@ -49,15 +49,15 @@ class Xoh_page_wtr_fxt {
|
||||
} private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); private Xowe_wiki wiki;
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
public void Test_page_name_by_display(String ttl, String display, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.parse(wiki, Bry_.new_a7(ttl)), Bry_.new_a7(display))));
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)), Bry_.new_a7(display))));
|
||||
}
|
||||
public void Test_page_name_by_ttl(String raw, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.parse(wiki, Bry_.new_a7(raw)), null)));
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.Parse(wiki, Bry_.new_a7(raw)), null)));
|
||||
}
|
||||
public void Test_edit(String raw, String expd) {
|
||||
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true);
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
page.Data_raw_(Bry_.new_u8(raw));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
||||
Xoh_page_wtr_mgr mgr = wiki.Html_mgr().Page_wtr_mgr();
|
||||
Xoh_page_wtr_wkr wkr = mgr.Wkr(Xopg_page_.Tid_edit);
|
||||
wkr.Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Basic, page);
|
||||
@@ -66,8 +66,8 @@ class Xoh_page_wtr_fxt {
|
||||
public void Test_read(String page_name, String page_text, String expd) {
|
||||
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true);
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
page.Ttl_(Xoa_ttl.parse(wiki, Bry_.new_a7(page_name)));
|
||||
page.Data_raw_(Bry_.new_u8(page_text));
|
||||
page.Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7(page_name)));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(page_text));
|
||||
Xoh_page_wtr_mgr mgr = wiki.Html_mgr().Page_wtr_mgr();
|
||||
Xoh_page_wtr_wkr wkr = mgr.Wkr(Xopg_page_.Tid_read);
|
||||
wkr.Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Basic, page);
|
||||
|
||||
@@ -37,8 +37,7 @@ public class Xow_hdump_mgr {
|
||||
Xowd_core_db_props props = wiki.Data__core_mgr().Props();
|
||||
dflt_zip_tid = props.Zip_tid_html();
|
||||
dflt_hzip_enable = props.Hzip_enabled();
|
||||
// dflt_hzip_enable = props.Hzip_enabled();
|
||||
// mode_is_b256 = true;
|
||||
// mode_is_b256 = true;
|
||||
}
|
||||
Init_by_db(dflt_zip_tid, dflt_hzip_enable, mode_is_b256);
|
||||
}
|
||||
|
||||
@@ -19,20 +19,20 @@ package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
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.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xow_hdump_mgr__load {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
private Xow_override_mgr override_mgr__html, override_mgr__page;
|
||||
public Xow_hdump_mgr__load(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg; this.tmp_bfr = tmp_bfr;
|
||||
this.make_mgr = new Xoh_make_mgr(wiki.App().Usr_dlg(), wiki.App().Fsys_mgr(), gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx, wiki.Domain_bry());
|
||||
this.make_mgr = new Xoh_make_mgr();
|
||||
}
|
||||
public Xoh_make_mgr Make_mgr() {return make_mgr;} private final Xoh_make_mgr make_mgr;
|
||||
public void Load_by_edit(Xoae_page wpg) {
|
||||
tmp_hpg.Init(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Revision_data().Id());
|
||||
tmp_hpg.Init(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Db().Page().Id());
|
||||
Load(tmp_hpg, wpg.Ttl());
|
||||
wpg.Hdump_data().Body_(tmp_hpg.Body());
|
||||
wpg.Db().Html().Html_bry_(tmp_hpg.Db().Html().Html_bry());
|
||||
wpg.Root_(new gplx.xowa.parsers.Xop_root_tkn()); // HACK: set root, else load page will fail
|
||||
Fill_page(wpg, tmp_hpg);
|
||||
}
|
||||
@@ -48,13 +48,13 @@ public class Xow_hdump_mgr__load {
|
||||
if (!loaded) { // nothing in "page" table
|
||||
byte[] page_override = override_mgr__page.Get_or_same(ttl.Page_db(), null);
|
||||
if (page_override == null) return Load__fail(hpg);
|
||||
hpg.Body_(page_override);
|
||||
hpg.Db().Html().Html_bry_(page_override);
|
||||
return true;
|
||||
}
|
||||
Xow_db_file html_db = wiki.Data__core_mgr().Dbs__get_by_id_or_fail(tmp_dbpg.Html_db_id());
|
||||
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html" table
|
||||
byte[] src = Parse(hpg, hpg.Body_zip_tid(), hpg.Body_hzip_tid(), hpg.Body());
|
||||
hpg.Body_(src);
|
||||
byte[] src = Parse(hpg, hpg.Db().Html().Zip_tid(), hpg.Db().Html().Hzip_tid(), hpg.Db().Html().Html_bry());
|
||||
hpg.Db().Html().Html_bry_(src);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -85,25 +85,27 @@ public class Xow_hdump_mgr__load {
|
||||
wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists());
|
||||
wpg_head.Itm__timeline().Enabled_ (hpg.Xtn__timeline_exists());
|
||||
wpg_head.Itm__gallery_styles().Enabled_ (hpg.Xtn__gallery_exists());
|
||||
wpg_head.Itm__toc().Enabled_(hpg.Hdump_mgr().Toc_wtr().Exists());
|
||||
wpg_head.Itm__pgbnr().Enabled_(hpg.Html_data().Head_mgr().Itm__pgbnr().Enabled());
|
||||
|
||||
// transfer images from Xoh_page to Xoae_page
|
||||
Xoh_img_mgr src_imgs = hpg.Img_mgr();
|
||||
int len = src_imgs.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
gplx.xowa.files.Xof_fsdb_itm itm = src_imgs.Get_at(i);
|
||||
wpg.Hdump_data().Imgs().Add(itm);
|
||||
wpg.Hdump_mgr().Imgs().Add(itm);
|
||||
wpg.File_queue().Add(itm); // add to file_queue for http_server
|
||||
}
|
||||
|
||||
// transfer redlinks
|
||||
Xopg_lnki_list src_list = hpg.Redlink_list();
|
||||
Xopg_lnki_list trg_list = wpg.Redlink_list();
|
||||
Xopg_lnki_list src_list = hpg.Html_data().Redlink_list();
|
||||
Xopg_lnki_list trg_list = wpg.Html_data().Redlink_list();
|
||||
len = src_list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
trg_list.Add_direct(src_list.Get_at(i));
|
||||
}
|
||||
}
|
||||
private static boolean Load__fail(Xoh_page hpg) {hpg.Exists_n_(); return false;}
|
||||
private static boolean Load__fail(Xoh_page hpg) {hpg.Db().Page().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);
|
||||
|
||||
@@ -1,161 +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; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Xow_hdump_mgr__load_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xohd_hdump_wtr_fxt fxt = new Xohd_hdump_wtr_fxt();
|
||||
@Test public void Stub() {}
|
||||
// @Test public void Image_full() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.png|test_caption]]"
|
||||
// , "<a xtid='a_img_full' xatrs='1|0|0||0|test_caption'/>"
|
||||
// );
|
||||
// }
|
||||
// @Test public void Image_thumb() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.N, Xof_ext_.Id_png));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
|
||||
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" xowa_img='0' /></a>"
|
||||
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
|
||||
// , " test_caption"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Audio_thumb() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.oga", 0, 220, -1, Bool_.N, Xof_ext_.Id_oga));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.oga|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
|
||||
// , " <div class=\"xowa_media_div\"><xowa_play id='0'/><xowa_info id='0'/>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
|
||||
// , " test_caption"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Video_thumb() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.ogv", 0, 0, 0, Bool_.N, Xof_ext_.Id_ogv));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.ogv|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
|
||||
// , " <div class=\"xowa_media_div\">"
|
||||
// , " <div>"
|
||||
// , " <a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\">"
|
||||
// , " <img id=\"xoimg_0\" xowa_img='0' alt=\"\" />"
|
||||
// , " </a>"
|
||||
// , " </div><xowa_play id='0'/>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
|
||||
// , " test_caption"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Hiero() {
|
||||
// Hiero_html_mgr_fxt hiero_fxt = new Hiero_html_mgr_fxt(fxt.Fxt());
|
||||
// hiero_fxt.Reset();
|
||||
// hiero_fxt.Init_hiero_A1_B1();
|
||||
// fxt.Test_write_frag("<hiero>A1</hiero>", "src='~{xowa_hiero_dir}hiero_A1.png'");
|
||||
// }
|
||||
// @Test public void Gallery() {
|
||||
// Gallery_mgr_base.File_found_mode = Bool_.__byte;
|
||||
// fxt.Test_write_all
|
||||
// ( "<gallery>File:A.png|A1</gallery>", String_.Concat_lines_nl_skip_last
|
||||
// ( "<ul id=\"xowa_gallery_ul_0\" class=\"gallery mw-gallery-traditional\" xowa_gly_box_max='0'>"
|
||||
// , " <li id=\"xowa_gallery_li_0\" class=\"gallerybox\" xowa_gly_box_w='0'>"
|
||||
// , " <div xowa_gly_box_w='0'>"
|
||||
// , " <div class=\"thumb\" style=\"width: 150px;\">"
|
||||
// , " <div xowa_gly_img_pad='0'>"
|
||||
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" xowa_img='0' /></a>"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"gallerytext\"><p>A1"
|
||||
// , "</p>"
|
||||
// , ""
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , " </li>"
|
||||
// , "</ul>"
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
class Xodb_hdump_mgr__base_fxt {
|
||||
protected Bry_bfr bfr = Bry_bfr_.Reset(255);
|
||||
protected Xowe_wiki wiki; protected Xoae_page page;
|
||||
private Xow_hdump_mgr hdump_mgr;
|
||||
public Xop_fxt Fxt() {return fxt;} protected Xop_fxt fxt;
|
||||
public void Clear() {
|
||||
if (fxt == null) {
|
||||
fxt = new Xop_fxt();
|
||||
wiki = fxt.Wiki();
|
||||
page = wiki.Parser_mgr().Ctx().Page();
|
||||
hdump_mgr = wiki.Html__hdump_mgr();
|
||||
hdump_mgr.Init_by_db(gplx.core.ios.streams.Io_stream_.Tid_raw, false, false);
|
||||
}
|
||||
fxt.Reset();
|
||||
page.Revision_data().Id_(0);
|
||||
this.Clear_end();
|
||||
}
|
||||
@gplx.Virtual public void Clear_end() {}
|
||||
@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().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
|
||||
(Bry_.new_u8(lnki_ttl), Byte_.Zero, Xof_img_size.Upright_null, 0, 0, Xof_lnki_time.Null, Xof_lnki_page.Null, Xohd_img_itm__base.File_repo_id_null, file_ext_id, file_is_orig, html_w, html_uid, html_w, html_h);
|
||||
}
|
||||
}
|
||||
class Xohd_hdump_wtr_fxt extends Xodb_hdump_mgr__base_fxt {
|
||||
private List_adp expd_itms_xfers = List_adp_.New();
|
||||
@Override public void Clear_end() {expd_itms_xfers.Clear();}
|
||||
public void Expd_itms_xfers(Xohd_img_itm__base... itms) {expd_itms_xfers.Add_many((Object[])itms);}
|
||||
public void Test_write_all (String raw, String expd_html) {Test_write(Bool_.N, raw, expd_html);}
|
||||
public void Test_write_frag(String raw, String expd_frag) {Test_write(Bool_.Y, raw, expd_frag);}
|
||||
public void Test_write(boolean frag, String raw, String expd_html) {
|
||||
this.Exec_write(raw);
|
||||
String actl_html = String_.new_u8(page.Hdump_data().Body());
|
||||
if (frag)
|
||||
Tfds.Eq_true(String_.Has(actl_html, expd_html), actl_html);
|
||||
else
|
||||
Tfds.Eq_str_lines(expd_html, actl_html);
|
||||
if (expd_itms_xfers.Count() > 0) Tfds.Eq_ary_str(Xfer_to_str_ary(expd_itms_xfers), Xfer_to_str_ary(page.Hdump_data().Imgs()));
|
||||
}
|
||||
private static String[] Xfer_to_str_ary(List_adp list) {
|
||||
int len = list.Count();
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xohd_img_itm__base itm = (Xohd_img_itm__base)list.Get_at(i);
|
||||
rv[i] = itm.Data_print();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.primitives.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xow_hdump_mgr__save {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
@@ -34,19 +34,19 @@ public class Xow_hdump_mgr__save {
|
||||
Bld_hdump(page);
|
||||
tmp_hpg.Ctor_by_page(tmp_bfr, page);
|
||||
Xow_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());
|
||||
return Save(tmp_hpg, html_db.Tbl__html(), html_db_is_new.Val());
|
||||
}
|
||||
}
|
||||
public int Save(Xoh_page hpg, Xow_db_file html_db, boolean insert) {
|
||||
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);
|
||||
public int Save(Xoh_page hpg, Xowd_html_tbl html_tbl, boolean insert) {
|
||||
byte[] db_body = Write(tmp_bfr, wiki, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, dflt_hzip_tid, hpg.Db().Html().Html_bry());
|
||||
if (insert) html_tbl.Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_tbl.Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
return db_body.length;
|
||||
}
|
||||
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, page.Wikie().Parser_mgr().Ctx(), Xoh_wtr_ctx.Hdump, page); // save as hdump_fmt
|
||||
page.Hdump_data().Body_(tmp_bfr.To_bry_and_clear());
|
||||
page.Db().Html().Html_bry_(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
private byte[] Write(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
if (hzip_tid != Xoh_hzip_dict_.Hzip__none) src = hzip_mgr.Encode_as_bry((Xoh_hzip_bfr)bfr.Clear(), wiki, hpg, src);
|
||||
@@ -58,14 +58,14 @@ public class Xow_hdump_mgr__save {
|
||||
private static Xow_db_file Get_html_db(Xow_wiki wiki, Xoae_page page, Bool_obj_ref html_db_is_new) {
|
||||
Xow_db_file rv = Xow_db_file.Null;
|
||||
Xow_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int html_db_id = page.Revision_data().Html_db_id();
|
||||
int html_db_id = page.Db().Page().Html_db_id();
|
||||
if (html_db_id == -1) {
|
||||
html_db_is_new.Val_y_();
|
||||
rv = core_data_mgr.Db__html();
|
||||
if (rv == null) rv = core_data_mgr.Dbs__make_by_tid(Xow_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);
|
||||
page.Db().Page().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Db().Page().Id(), html_db_id);
|
||||
}
|
||||
else {
|
||||
rv = core_data_mgr.Dbs__get_by_id_or_fail(html_db_id);
|
||||
|
||||
@@ -16,54 +16,57 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
import gplx.core.brys.*; import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xob_hdump_bldr implements Gfo_invk {
|
||||
private boolean enabled, hzip_enabled, hzip_diff, hzip_b256; private byte zip_tid = Byte_.Max_value_127;
|
||||
private Xowe_wiki wiki; private Xow_hdump_mgr hdump_mgr;
|
||||
private Xob_ns_to_db_mgr ns_to_db_mgr; int prv_row_len = 0;
|
||||
private Xoh_stat_tbl stats_tbl; private Xoh_stat_itm tmp_stat_itm;
|
||||
private Xowe_wiki wiki; private Xow_hdump_mgr hdump_mgr; private Xob_hdump_tbl_retriever html_tbl_retriever;
|
||||
private Xoh_stat_tbl stat_tbl; private Xoh_stat_itm stat_itm;
|
||||
private int prv_row_len = 0;
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private boolean op_sys_is_wnt;
|
||||
public boolean Init(Xowe_wiki wiki, Db_conn make_conn) {
|
||||
public boolean Init(Xowe_wiki wiki, Db_conn make_conn, Xob_hdump_tbl_retriever html_tbl_retriever) {
|
||||
if (!enabled) return false;
|
||||
this.op_sys_is_wnt = gplx.core.envs.Op_sys.Cur().Tid_is_wnt();
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Hctx().Hzip__stat();
|
||||
this.stats_tbl = new Xoh_stat_tbl(make_conn);
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.html_tbl_retriever = html_tbl_retriever;
|
||||
this.stat_tbl = new Xoh_stat_tbl(make_conn); this.stat_itm = hdump_mgr.Hzip_mgr().Hctx().Hzip__stat();
|
||||
|
||||
Xoapi_import import_cfg = wiki.Appe().Api_root().Bldr().Wiki().Import();
|
||||
if (zip_tid == Byte_.Max_value_127) zip_tid = import_cfg.Zip_tid_html();
|
||||
hdump_mgr.Init_by_db(zip_tid, hzip_enabled, hzip_b256);
|
||||
Xow_db_mgr core_data_mgr = wiki.Db_mgr_as_sql().Core_data_mgr();
|
||||
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__html(core_data_mgr.Db__core()), core_data_mgr, import_cfg.Html_db_max());
|
||||
Xob_ns_file_itm.Init_ns_bldr_data(Xow_db_file_.Tid__html_data, wiki.Ns_mgr(), gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import.Ns_file_map__each);
|
||||
return true;
|
||||
}
|
||||
public void Insert(Xoae_page page) {
|
||||
tmp_hpg.Clear(); // NOTE: must clear tmp_hpg or else will leak memory during mass build; DATE:2016-01-09
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Hdump, page); // write to html in hdump mode
|
||||
public void Insert(Xoae_page wpg) {
|
||||
// clear
|
||||
tmp_hpg.Clear(); // NOTE: must clear tmp_hpg or else will leak memory during mass build; DATE:2016-01-09
|
||||
wpg.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
|
||||
// write to html
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_hdump(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Hdump, wpg);
|
||||
byte[] orig_bry = tmp_bfr.To_bry_and_clear();
|
||||
page.Hdump_data().Body_(orig_bry); // write to body bry
|
||||
Xow_db_file html_db = ns_to_db_mgr.Get_by_ns(page.Ttl().Ns().Bldr_data(), prv_row_len); // get html_db
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, page), html_db, true); // save to db
|
||||
if (hzip_diff) Hzip_exec(orig_bry);
|
||||
stats_tbl.Insert(tmp_hpg, tmp_stat_itm, page.Root().Root_src().length, tmp_hpg.Body().length, prv_row_len); // save stats
|
||||
wpg.Db().Html().Html_bry_(orig_bry);
|
||||
|
||||
// save to db
|
||||
Xowd_html_tbl html_tbl = html_tbl_retriever.Get_html_tbl(wpg.Ttl().Ns(), prv_row_len); // get html_tbl
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, wpg), html_tbl, true); // save to db
|
||||
stat_tbl.Insert(tmp_hpg, stat_itm, wpg.Root().Root_src().length, tmp_hpg.Db().Html().Html_bry().length, prv_row_len); // save stats
|
||||
|
||||
// run hzip diff if enabled
|
||||
if (hzip_diff) {
|
||||
byte[] expd_bry = op_sys_is_wnt ? Bry_.Replace(tmp_bfr, orig_bry, Byte_ascii.Cr_lf_bry, Byte_ascii.Nl_bry) : orig_bry; // tidy adds crlf if wnt
|
||||
byte[] actl_bry = hdump_mgr.Load_mgr().Decode_as_bry(tmp_bfr, tmp_hpg, hdump_mgr.Save_mgr().Src_as_hzip(), Bool_.Y);
|
||||
byte[][] diff = Bry_diff_.Diff_1st_line(expd_bry, actl_bry);
|
||||
if (diff != null)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", String_.Format("hzip diff: page={0} lhs='{1}' rhs='{2}'", tmp_hpg.Url_bry_safe(), diff[0], diff[1]));
|
||||
}
|
||||
}
|
||||
public void Bld_term() {this.Commit(); ns_to_db_mgr.Rls_all();}
|
||||
public void Commit() {
|
||||
ns_to_db_mgr.Commit();
|
||||
html_tbl_retriever.Commit();
|
||||
// wiki_db_mgr.Tbl__cfg().Update_long(Cfg_grp_hdump_make, Cfg_itm_hdump_size, hdump_db_size); // update cfg; should happen after commit entries
|
||||
}
|
||||
private void Hzip_exec(byte[] orig_bry) {
|
||||
byte[] expd_bry = op_sys_is_wnt ? Bry_.Replace(tmp_bfr, orig_bry, Byte_ascii.Cr_lf_bry, Byte_ascii.Nl_bry) : orig_bry;
|
||||
byte[] actl_bry = hdump_mgr.Load_mgr().Decode_as_bry(tmp_bfr, tmp_hpg, hdump_mgr.Save_mgr().Src_as_hzip(), Bool_.Y);
|
||||
byte[][] diff = Bry_diff_.Diff_1st_line(expd_bry, actl_bry);
|
||||
if (diff != null)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", String_.Format("hzip diff: page={0} lhs='{1}' rhs='{2}'", tmp_hpg.Url_bry_safe(), diff[0], diff[1]));
|
||||
}
|
||||
public void Term() {this.Commit(); html_tbl_retriever.Rls_all();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_zip_tid_)) zip_tid = m.ReadByte("v");
|
||||
|
||||
@@ -1,116 +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.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.guis.*;
|
||||
class Xob_hdump_img_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public Xob_hdump_img_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Cmd_key() {return Key_const;} public static final String Key_const = "hdump.make.imgs";
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_run() {Exec_main();}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_term() {}
|
||||
private void Exec_main() {
|
||||
Bry_bfr bfr = Bry_bfr_.Reset(Io_mgr.Len_mb);
|
||||
Db_conn conn = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
Db_rdr rdr = conn.Stmt_sql(Sql_select_clause).Exec_select__rls_auto();
|
||||
// html_tbl = new Xowd_html_tbl(conn, wiki.Db_mgr_as_sql().Core_data_mgr().Props().Zip_tid_text());
|
||||
int cur_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_page_id = rdr.Read_int("lnki_page_id");
|
||||
if (lnki_page_id != cur_page_id) {
|
||||
Save(cur_page_id, bfr.To_bry_and_clear());
|
||||
cur_page_id = lnki_page_id;
|
||||
}
|
||||
// int html_uid = rdr.Read_int(1);
|
||||
// byte[] lnki_ttl = rdr.Read_bry(2);
|
||||
// int html_w = rdr.Read_int(3);
|
||||
// int html_h = rdr.Read_int(4);
|
||||
// int file_repo_id = rdr.Read_int(5);
|
||||
// int file_ext_id = rdr.Read_int(6);
|
||||
// boolean file_is_orig = rdr.Read_int(7) == 1;
|
||||
// double file_time = rdr.Read_double(8);
|
||||
// int file_page = rdr.Read_int(9);
|
||||
// Xohd_img_itm__base.Data_write_static(bfr, 0, lnki_ttl, Byte_.Zero, 0, 0, Xof_img_size.Upright_null, html_uid, html_w, html_h, file_repo_id, file_ext_id, file_is_orig, html_w, file_time, file_page);
|
||||
}
|
||||
Save(cur_page_id, bfr.To_bry_and_clear());;
|
||||
}
|
||||
private void Save(int page_id, byte[] data) {
|
||||
if (page_id == -1 || data.length == 0) return;
|
||||
// html_tbl.Insert(page_id, Xohd_img_tid.Tid_img, data);
|
||||
}
|
||||
private static final String Sql_select_clause = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT lt.lnki_page_id"
|
||||
, ", lt.html_uid"
|
||||
, ", lt.lnki_ttl"
|
||||
, ", xr.file_w"
|
||||
, ", xr.file_h"
|
||||
, ", xr.orig_repo"
|
||||
, ", xr.lnki_ext"
|
||||
, ", xr.file_is_orig"
|
||||
, ", xr.lnki_time"
|
||||
, ", xr.lnki_page"
|
||||
, "FROM xfer_regy xr"
|
||||
, " JOIN lnki_temp lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
// , " LEFT JOIN xtn_gallery lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
// , " LEFT JOIN xtn_imap lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
, "ORDER BY "
|
||||
, " lt.lnki_page_id"
|
||||
, ", lt.lnki_uid"
|
||||
);
|
||||
}
|
||||
interface Page_async_cmd {
|
||||
void Prep();
|
||||
void Exec();
|
||||
}
|
||||
// class Page_async_cmd__img : Page_async_cmd {
|
||||
// private Xoh_page hpg;
|
||||
// private List_adp missing = List_adp_.New();
|
||||
// public Page_async_cmd__img(Xoh_page hpg) {this.hpg = hpg;}
|
||||
// public void Prep() {
|
||||
//// int len = hpg.Img_count();
|
||||
//// Xohd_img_itm__base[] ary = hpg.Img_itms();
|
||||
//// missing.Clear();
|
||||
//// for (int i = 0; i < len; ++i) {
|
||||
//// Xohd_img_itm__base itm = ary[i];
|
||||
//// boolean exists = Io_mgr.Instance.ExistsFil(itm.Html_view_url());
|
||||
//// if (!exists) missing.Add(itm);
|
||||
//// }
|
||||
// }
|
||||
// public void Exec() {
|
||||
// int len = missing.Count();
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
//// Xohd_img_itm__base itm = (Xohd_img_itm__base)missing.Get_at(i);
|
||||
//// byte[] bytes = null; //fsdb.Db_get()ttl, file_w,....):
|
||||
//// Write file(bytes);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// /*
|
||||
// CREATE TABLE xtn_gallery
|
||||
// ( src_page_id integer NOT NULL
|
||||
// , html_uid integer NOT NULL
|
||||
// , box_max integer NOT NULL
|
||||
// , box_w integer NOT NULL
|
||||
// , img_w integer NOT NULL
|
||||
// , img_pad integer NOT NULL
|
||||
// );
|
||||
// */
|
||||
@@ -15,9 +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.xowa.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
public interface Xohd_img_itm {
|
||||
int Data_tid();
|
||||
void Data_write(Bry_bfr bfr);
|
||||
String Data_print();
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
public interface Xob_hdump_tbl_retriever {
|
||||
Xowd_html_tbl Get_html_tbl(Xow_ns ns, int prv_row_len);
|
||||
void Commit();
|
||||
void Rls_all();
|
||||
}
|
||||
@@ -18,12 +18,12 @@ 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.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
class Xob_ns_to_db_wkr__html implements Xob_ns_to_db_wkr {
|
||||
public class Xob_ns_to_db_wkr__html implements Xob_ns_to_db_wkr {
|
||||
private final Xow_db_file page_db;
|
||||
public Xob_ns_to_db_wkr__html(Xow_db_file page_db) {this.page_db = page_db;}
|
||||
public byte Db_tid() {return Xow_db_file_.Tid__html_data;}
|
||||
public void Tbl_init(Xow_db_file db) {
|
||||
Xoh_page_tbl tbl = db.Tbl__html();
|
||||
Xowd_html_tbl tbl = db.Tbl__html();
|
||||
tbl.Create_tbl();
|
||||
tbl.Insert_bgn();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
int page_id = rdr.Read_int(page_tbl.Fld_page_id());
|
||||
if (cur_page_id != page_id) {
|
||||
if (cur_page_id != -1) Commit(redlink_tbl, cur_page_id, bfr);
|
||||
bfr.Add_int_variable(gplx.xowa.htmls.core.makes.imgs.Xohd_img_tid.Tid_redlink).Add_byte_pipe();
|
||||
bfr.Add_int_variable(2).Add_byte_pipe(); // 2=gplx.xowa.htmls.core.makes.imgs.Xohd_img_tid.Tid_redlink
|
||||
cur_page_id = page_id;
|
||||
}
|
||||
// add html_uid to cur_page's bfr
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Xoh_page_row {
|
||||
public class Xowd_html_row {
|
||||
public void Load(int page_id, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
this.page_id = page_id;
|
||||
this.head_flag = head_flag;
|
||||
@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.core.brys.*;
|
||||
public class Xoh_page_tbl implements Rls_able {
|
||||
public class Xowd_html_tbl implements Db_tbl {
|
||||
private final String fld_page_id, fld_head_flag, fld_body_flag, fld_display_ttl, fld_content_sub, fld_sidebar_div, fld_body;
|
||||
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) {
|
||||
public Xowd_html_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_page_id = flds.Add_int_pkey("page_id");
|
||||
this.fld_head_flag = flds.Add_int("head_flag");
|
||||
@@ -75,7 +75,7 @@ public class Xoh_page_tbl implements Rls_able {
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public boolean Select_as_row(Xoh_page_row rv, int page_id) {
|
||||
public boolean Select_as_row(Xowd_html_row rv, int page_id) {
|
||||
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_page_id);
|
||||
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, page_id).Exec_select__rls_manual();
|
||||
try {
|
||||
@@ -223,7 +223,7 @@ public class Xoh_html_wtr {
|
||||
if (hctx.Mode_is_alt()) return;
|
||||
switch (under.Under_tid()) {
|
||||
case Xol_kwd_grp_.Id_toc:
|
||||
wiki.Html_mgr().Toc_mgr().Html(page, hctx, src, bfr, true);
|
||||
wiki.Html_mgr().Toc_mgr().Html(page, hctx, bfr, false);
|
||||
break;
|
||||
case Xol_kwd_grp_.Id_notoc: case Xol_kwd_grp_.Id_forcetoc: // NOTE: skip output; changes flag on page only
|
||||
break;
|
||||
|
||||
46
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_bfr_mgr.java
Normal file
46
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_bfr_mgr.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
class Xoh_bfr_mgr {
|
||||
private Xoh_page hpg;
|
||||
private Bry_bfr html_bfr;
|
||||
private Bry_bfr bfr_0 = Bry_bfr_.New(), bfr_1 = Bry_bfr_.New();
|
||||
private boolean toc_mode_is_pgbnr;
|
||||
public Bry_bfr Init(Xoh_page hpg, Bry_bfr html_bfr) {
|
||||
this.hpg = hpg; this.html_bfr = html_bfr;
|
||||
this.toc_mode_is_pgbnr = false;
|
||||
return bfr_0;
|
||||
}
|
||||
public Bry_bfr Split_by_toc(Xoh_data_itm data_itm) {
|
||||
hpg.Hdump_mgr().Toc_wtr().Exists_y_();
|
||||
this.toc_mode_is_pgbnr = ((Xoh_toc_data)data_itm).Toc_mode() == Xoh_toc_data.Toc_mode__pgbnr;
|
||||
if (toc_mode_is_pgbnr)
|
||||
hpg.Html_data().Head_mgr().Itm__pgbnr().Enabled_y_();
|
||||
return bfr_1;
|
||||
}
|
||||
public void Commit() {
|
||||
html_bfr.Add_bfr_and_clear(bfr_0);
|
||||
|
||||
// calc toc by iterating sections
|
||||
if (hpg.Hdump_mgr().Toc_wtr().Exists())
|
||||
html_bfr.Add(hpg.Hdump_mgr().Toc_wtr().To_html(toc_mode_is_pgbnr));
|
||||
|
||||
html_bfr.Add_bfr_and_clear(bfr_1);
|
||||
}
|
||||
}
|
||||
@@ -21,18 +21,20 @@ public class Xoh_hzip_dict_ {
|
||||
public static final byte Escape = Byte_.By_int(27); // SERIALIZED: 27=escape byte
|
||||
public static final byte[] Escape_bry = Bry_.New_by_ints(27); // SERIALIZED
|
||||
public static final int
|
||||
Tid__timeline = -10
|
||||
, Tid__gallery = -11
|
||||
, Tid__root = 0
|
||||
, Tid__escape = 1
|
||||
, Tid__xnde = 2
|
||||
, Tid__lnke = 3
|
||||
, Tid__lnki = 4
|
||||
, Tid__hdr = 5
|
||||
, Tid__img = 6
|
||||
, Tid__thm = 7
|
||||
, Tid__gly = 8
|
||||
, Tid__img_bare = 9
|
||||
Tid__timeline = -10
|
||||
, Tid__gallery = -11
|
||||
, Tid__root = 0
|
||||
, Tid__escape = 1
|
||||
, Tid__xnde = 2
|
||||
, Tid__lnke = 3
|
||||
, Tid__lnki = 4
|
||||
, Tid__hdr = 5
|
||||
, Tid__img = 6
|
||||
, Tid__thm = 7
|
||||
, Tid__gly = 8
|
||||
, Tid__img_bare = 9
|
||||
, Tid__toc = 10
|
||||
, Tid__pgbnr = 11
|
||||
;
|
||||
public static final String
|
||||
Key__timeline = "timeline"
|
||||
@@ -46,6 +48,8 @@ public class Xoh_hzip_dict_ {
|
||||
, Key__gly = "gly"
|
||||
, Key__xnde = "xnde"
|
||||
, Key__img_bare = "img_bare"
|
||||
, Key__toc = "toc"
|
||||
, Key__pgbnr = "pgbnr"
|
||||
;
|
||||
public static final int Hzip__none = 0, Hzip__v1 = 1;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
private final Xoh_hdoc_wkr hdoc_wkr = new Xoh_hdoc_wkr__hzip();
|
||||
private final Xoh_hdoc_parser hdoc_parser;
|
||||
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape);
|
||||
private final Xoh_bfr_mgr bfr_mgr = new Xoh_bfr_mgr();
|
||||
public Xoh_hzip_mgr() {this.hdoc_parser = new Xoh_hdoc_parser(hdoc_wkr);}
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__lnke;}
|
||||
public String Key() {return "root";}
|
||||
@@ -40,8 +41,10 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
rdr.Init_by_page(hpg.Url_bry_safe(), src, src.length);
|
||||
Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src.length, null);
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
public void Decode1(Bry_bfr html_bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
int pos = src_bgn, txt_bgn = -1;
|
||||
boolean toc_enabled = !gplx.core.envs.Op_sys.Cur().Tid_is_drd() && !hctx.Mode_is_diff();
|
||||
Bry_bfr bfr = toc_enabled ? bfr_mgr.Init(hpg, html_bfr) : html_bfr;
|
||||
while (true) {
|
||||
if (pos == src_end) break;
|
||||
byte b = src[pos];
|
||||
@@ -57,6 +60,11 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
try {
|
||||
rdr.Init_by_sect(wkr.Key(), pos, pos + hook_len);
|
||||
Xoh_data_itm data = hctx.Pool_mgr__data().Get_by_tid(wkr.Tid());
|
||||
if ( data != null
|
||||
&& toc_enabled
|
||||
&& data.Tid() == Xoh_hzip_dict_.Tid__toc) {
|
||||
bfr = bfr_mgr.Split_by_toc(data);
|
||||
}
|
||||
wkr.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, pos, src_end, data);
|
||||
Xoh_wtr_itm wtr = hctx.Pool_mgr__wtr().Get_by_tid(wkr.Tid());
|
||||
if (data != null && wtr != null) {
|
||||
@@ -74,6 +82,7 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
}
|
||||
}
|
||||
if (txt_bgn != -1) bfr.Add_mid(src, txt_bgn, src_end);
|
||||
if (toc_enabled) bfr_mgr.Commit();
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hzip_mgr rv = new Xoh_hzip_mgr(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
|
||||
@@ -19,15 +19,16 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.btries.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
public class Xoh_pool_mgr__data {
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery;
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__toc, pool__timeline, pool__gallery;
|
||||
public Xoh_pool_mgr__data() {
|
||||
pool__hdr = New_pool(new Xoh_hdr_data());
|
||||
pool__lnke = New_pool(new Xoh_lnke_data());
|
||||
pool__img = New_pool(new Xoh_img_data());
|
||||
pool__img_bare = New_pool(new Xoh_img_bare_data());
|
||||
pool__toc = New_pool(new Xoh_toc_data());
|
||||
pool__timeline = New_pool(new Xoh_timeline_data());
|
||||
pool__gallery = New_pool(new Xoh_gallery_data());
|
||||
}
|
||||
@@ -38,6 +39,7 @@ public class Xoh_pool_mgr__data {
|
||||
case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break;
|
||||
case Xoh_hzip_dict_.Tid__img: pool = pool__img; break;
|
||||
case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break;
|
||||
case Xoh_hzip_dict_.Tid__toc: pool = pool__toc; break;
|
||||
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
|
||||
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
|
||||
default: return null;
|
||||
|
||||
@@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.btries.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
public class Xoh_pool_mgr__hzip {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline;
|
||||
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline, mkr__toc;
|
||||
public Xoh_escape_hzip Mw__escape() {return (Xoh_escape_hzip) mkr__escape.Get_fast();}
|
||||
public Xoh_xnde_hzip Mw__xnde() {return (Xoh_xnde_hzip) mkr__xnde.Get_fast();}
|
||||
public Xoh_hdr_hzip Mw__hdr() {return (Xoh_hdr_hzip) mkr__hdr.Get_fast();}
|
||||
@@ -33,6 +33,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
public Xoh_img_bare_hzip Mw__img_bare() {return (Xoh_img_bare_hzip) mkr__img_bare.Get_fast();}
|
||||
public Xoh_thm_hzip Mw__thm() {return (Xoh_thm_hzip) mkr__thm.Get_fast();}
|
||||
public Xoh_gly_hzip Mw__gly() {return (Xoh_gly_hzip) mkr__gly.Get_fast();}
|
||||
public Xoh_toc_hzip Mw__toc() {return (Xoh_toc_hzip) mkr__toc.Get_fast();}
|
||||
public Xoh_gallery_hzip Mw__gallery() {return (Xoh_gallery_hzip) mkr__gallery.Get_fast();}
|
||||
public Xoh_timeline_hzip Mw__timeline() {return (Xoh_timeline_hzip) mkr__timeline.Get_fast();}
|
||||
public void Init() {
|
||||
@@ -53,6 +54,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
mkr__thm = Reg(New_hook_len2(mode_is_b256, hook__mw , 5) , new Xoh_thm_hzip());
|
||||
mkr__gly = Reg(New_hook_len2(mode_is_b256, hook__mw , 6) , new Xoh_gly_hzip());
|
||||
mkr__img_bare = Reg(New_hook_len2(mode_is_b256, hook__mw , 7) , new Xoh_img_bare_hzip());
|
||||
mkr__toc = Reg(New_hook_len2(mode_is_b256, hook__mw , 8) , new Xoh_toc_hzip());
|
||||
mkr__gallery = Reg(Xoh_gallery_data.Hook_bry , new Xoh_gallery_hzip());
|
||||
mkr__timeline = Reg(Xoh_timeline_data.Hook_bry , new Xoh_timeline_hzip());
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
public class Xoh_pool_mgr__wtr {
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery;
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__toc, pool__timeline, pool__gallery;
|
||||
public Xoh_pool_mgr__wtr() {
|
||||
pool__hdr = New_pool(new Xoh_hdr_wtr());
|
||||
pool__lnke = New_pool(new Xoh_lnke_wtr());
|
||||
pool__img = New_pool(new Xoh_img_wtr());
|
||||
pool__img_bare = New_pool(new Xoh_img_bare_wtr());
|
||||
pool__toc = New_pool(new Xoh_toc_wtr());
|
||||
pool__timeline = New_pool(new Xoh_timeline_wtr());
|
||||
pool__gallery = New_pool(new Xoh_gallery_wtr());
|
||||
}
|
||||
@@ -38,6 +39,7 @@ public class Xoh_pool_mgr__wtr {
|
||||
case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break;
|
||||
case Xoh_hzip_dict_.Tid__img: pool = pool__img; break;
|
||||
case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break;
|
||||
case Xoh_hzip_dict_.Tid__toc: pool = pool__toc; break;
|
||||
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
|
||||
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
|
||||
default: return null;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xoh_stat_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hdump_stats"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
@@ -48,7 +48,7 @@ public class Xoh_stat_tbl implements Rls_able {
|
||||
.Val_int(fld_wtxt_len , wtxt_len)
|
||||
.Val_int(fld_row_orig_len , row_orig_len)
|
||||
.Val_int(fld_row_zip_len , row_zip_len)
|
||||
.Val_int(fld_body_len , Len_or_0(hpg.Body()))
|
||||
.Val_int(fld_body_len , Len_or_0(hpg.Db().Html().Html_bry()))
|
||||
.Val_int(fld_display_ttl_len , Len_or_0(hpg.Display_ttl()))
|
||||
.Val_int(fld_content_sub_len , Len_or_0(hpg.Content_sub()))
|
||||
.Val_int(fld_sidebar_div_len , Len_or_0(hpg.Sidebar_div()))
|
||||
|
||||
@@ -16,28 +16,11 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.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.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 Xoh_hzip_bfr bfr = Xoh_hzip_bfr.New_txt(255); private final Bry_bfr 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_hzip_bfr bfr = Xoh_hzip_bfr.New_txt(255);
|
||||
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, Gfo_url_encoder fsys_encoder, byte[] wiki_domain) {
|
||||
this.usr_dlg = usr_dlg;
|
||||
this.root_dir = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.file_dir = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.hiero_img_dir = gplx.xowa.xtns.hieros.Hiero_xtn_mgr.Hiero_root_dir(fsys_mgr).GenSubDir("img").To_http_file_bry();
|
||||
this.cfg_file = new Xoh_cfg_file(fsys_encoder, fsys_mgr.Bin_xowa_dir());
|
||||
this.html_fmtr = Xoh_file_html_fmtr__hdump.Base;
|
||||
this.wiki_domain = wiki_domain;
|
||||
}
|
||||
public byte[] Parse(byte[] src, Xoh_page hpg, Xow_wiki wiki) {
|
||||
hctx.Init_by_page(wiki, hpg);
|
||||
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
|
||||
@@ -45,100 +28,4 @@ public class Xoh_make_mgr {
|
||||
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Parse_old(Xoh_page hpg, byte[] src) {
|
||||
this.file_dir_comm = tmp_bfr.Add(file_dir).Add(Xow_domain_itm_.Bry__commons).Add_byte_slash().To_bry_and_clear();
|
||||
this.file_dir_wiki = tmp_bfr.Add(file_dir).Add(wiki_domain).Add_byte_slash().To_bry_and_clear();
|
||||
int src_len = src.length;
|
||||
bry_rdr.Init(src);
|
||||
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.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);
|
||||
if (o == null) { // regular char; set bgn and move to next char
|
||||
if (rng_bgn == -1) rng_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
else { // special tkn
|
||||
if (rng_bgn != -1) { // pending rng exists; add it
|
||||
bfr.Add_mid(src, rng_bgn, pos);
|
||||
rng_bgn = -1;
|
||||
}
|
||||
pos = Parse_itm(bfr, html_fmtr, hpg, src, src_len, imgs, imgs_len, pos, trie.Match_pos(), (Xoh_make_trie_itm)o);
|
||||
}
|
||||
}
|
||||
if (rng_bgn != -1) bfr.Add_mid(src, rng_bgn, src_len);
|
||||
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src_len);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
private int Parse_itm(Bry_bfr bfr, Xoh_file_html_fmtr__base fmtr, Xoh_page hpg, byte[] src, int src_len, Xohd_img_itm__base[] imgs, int imgs_len, int hook_bgn, int hook_end, Xoh_make_trie_itm itm) {
|
||||
bry_rdr.Pos_(hook_end);
|
||||
int uid = itm.Subst_end_byte() == Byte_ascii.Escape ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
|
||||
int uid_end = bry_rdr.Pos(); // set uid_end after subst_end
|
||||
int rv = uid_end;
|
||||
byte tid = itm.Tid();
|
||||
switch (tid) {
|
||||
case Xoh_make_trie_.Tid__dir: bfr.Add(root_dir); return rv;
|
||||
case Xoh_make_trie_.Tid__hiero_dir: bfr.Add(hiero_img_dir); return rv;
|
||||
}
|
||||
if (itm.Elem_is_xnde()) rv += 2; // if xnde, skip "/>"
|
||||
if (uid == bry_rdr.Or_int()) {usr_dlg.Warn_many("", "", "index is not a valid int; hpg=~{0} text=~{1}", hpg.Url().To_str(), Bry_.Mid_safe(src, hook_end, uid_end)); return uid_end;}
|
||||
if (!Int_.Between(uid, 0, imgs_len)) {usr_dlg.Warn_many("", "", "index is out of range; hpg=~{0} idx=~{1} len=~{2}", hpg.Url().To_str(), uid, imgs_len); return uid_end;}
|
||||
if (uid >= imgs.length) return rv;
|
||||
Xohd_img_itm__base img = imgs[uid];
|
||||
int img_view_w = img.Html_w();
|
||||
switch (tid) {
|
||||
case Xoh_make_trie_.Tid__img_style:
|
||||
bfr.Add(Xoh_make_trie_.Bry_img_style_bgn);
|
||||
bfr.Add_int_variable(img_view_w);
|
||||
bfr.Add(Xoh_make_trie_.Bry_img_style_end);
|
||||
return rv;
|
||||
}
|
||||
byte[] a_title = img.Lnki_ttl();
|
||||
byte[] a_href = Bry_.Add(Xoh_make_trie_.A_href_bgn, a_title);
|
||||
try {
|
||||
switch (tid) {
|
||||
case Xoh_make_trie_.Tid__file_info: fmtr.Html_thumb_part_info (bfr, uid, true, a_href, cfg_file.Img_media_info_btn()); return rv;
|
||||
case Xoh_make_trie_.Tid__file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, cfg_file.Img_thumb_magnify()); return rv;
|
||||
case Xoh_make_trie_.Tid__file_play: fmtr.Html_thumb_part_play (bfr, uid, true, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, cfg_file.Img_media_play_btn()); return rv;
|
||||
case Xoh_make_trie_.Tid__gallery_box_max: {
|
||||
Xohd_img_itm__gallery_mgr gly = (Xohd_img_itm__gallery_mgr)hpg.Gallery_itms().Get_by(uid);
|
||||
if (gly != null) { // -1 means no box_max
|
||||
byte[] style = Gallery_mgr_wtr_.Fmtr__ul__style.Bld_bry_many(tmp_bfr, gly.Box_max());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
case Xoh_make_trie_.Tid__gallery_box_w: {
|
||||
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
|
||||
byte[] style = Gallery_mgr_wtr_.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Box_w());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
return rv;
|
||||
}
|
||||
case Xoh_make_trie_.Tid__gallery_img_w: {
|
||||
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
|
||||
byte[] style = Gallery_mgr_wtr_.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Img_w());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
return rv;
|
||||
}
|
||||
case Xoh_make_trie_.Tid__gallery_img_pad: {
|
||||
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
|
||||
byte[] style = Gallery_mgr_wtr_.hdump_img_pad_fmtr.Bld_bry_many(tmp_bfr, gly.Img_pad());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
url_bldr.Init_by_root(img.Orig_repo_id() == Xof_repo_itm_.Repo_remote ? file_dir_comm : file_dir_wiki, Byte_ascii.Slash, false, false, 2);
|
||||
url_bldr.Init_by_itm(img.File_is_orig() ? Xof_repo_itm_.Mode_orig : Xof_repo_itm_.Mode_thumb, img.Lnki_ttl(), Xof_file_wkr_.Md5(img.Lnki_ttl()), Xof_ext_.new_by_id_(img.Orig_ext()), img.File_w(), img.Lnki_time(), img.Lnki_page());
|
||||
byte[] img_src = url_bldr.Xto_bry();
|
||||
if (tid == Xoh_make_trie_.Tid__img) {
|
||||
fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.Html_h());
|
||||
}
|
||||
} catch (Exception e) {Xoa_app_.Usr_dlg().Warn_many("", "", "abrv.read: page=~{0} itm=~{1} err=~{2}", hpg.Url_bry_safe(), img == null ? "<NULL>" : img.Data_print(), Err_.Message_gplx_full(e));}
|
||||
return rv;
|
||||
}
|
||||
public static final Bry_fmtr fmtr_img = Bry_fmtr.new_("src='~{src}' width='~{w}' height='~{h}'", "src", "w", "h");
|
||||
private static final Btrie_slim_mgr trie = Xoh_make_trie_.new_trie();
|
||||
}
|
||||
|
||||
@@ -1,68 +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.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
|
||||
class Xoh_make_mgr_fxt {
|
||||
private final List_adp img_list = List_adp_.New();
|
||||
private final Xoh_page hpg = new Xoh_page();
|
||||
private Xoh_make_mgr hswap_mgr; private Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
this.wiki.Init_by_wiki();
|
||||
this.hswap_mgr = wiki.Html__hdump_mgr().Load_mgr().Make_mgr();
|
||||
}
|
||||
public void Clear_imgs() {img_list.Clear();}
|
||||
public Xoh_make_mgr_fxt Init_body(String body) {hpg.Body_(Bry_.new_u8(body)); return this;}
|
||||
public Xoh_make_mgr_fxt Init_data_gly(int uid, int box_max) {hpg.Gallery_itms().Add(uid, new Xohd_img_itm__gallery_mgr(uid, box_max)); return this;}
|
||||
public Xoh_make_mgr_fxt Init_data_img_basic(String ttl, int html_uid, int html_w, int html_h) {
|
||||
Xohd_img_itm__img img = new Xohd_img_itm__img();
|
||||
img.Data_init_base(Bry_.new_u8(ttl), Xop_lnki_type.Id_none, Xof_img_size.Upright_null, Xof_img_size.Null, Xof_img_size.Null
|
||||
, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xohd_img_itm__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w
|
||||
, html_uid, html_w, html_h
|
||||
);
|
||||
img_list.Add(img);
|
||||
return this;
|
||||
}
|
||||
public Xoh_make_mgr_fxt Init_data_img_gly(String ttl, int html_uid, int html_w, int html_h, int box_w, int img_w, int img_pad) {
|
||||
Xohd_img_itm__gallery_itm img = new Xohd_img_itm__gallery_itm();
|
||||
img.Data_init_gallery(box_w, img_w, img_pad);
|
||||
img.Data_init_base(Bry_.new_u8(ttl), Xop_lnki_type.Id_none, Xof_img_size.Upright_null, Xof_img_size.Null, Xof_img_size.Null
|
||||
, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xohd_img_itm__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w
|
||||
, html_uid, html_w, html_h
|
||||
);
|
||||
img_list.Add(img);
|
||||
return this;
|
||||
}
|
||||
public Xoh_make_mgr_fxt Init_data_redlink(int... uids) {
|
||||
int uids_len = uids.length;
|
||||
for (int i = 0; i < uids_len; ++i) {
|
||||
Int_obj_ref redlink_uid = Int_obj_ref.New(uids[i]);
|
||||
hpg.Redlink_uids().Add(redlink_uid, redlink_uid);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Xoh_make_mgr_fxt Test_html(String expd) {
|
||||
if (img_list.Count() > 0) hpg.Img_itms_((Xohd_img_itm__base[])img_list.To_ary_and_clear(Xohd_img_itm__base.class));
|
||||
byte[] actl = hswap_mgr.Parse(hpg.Body(), hpg, wiki);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +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.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xoh_make_trie_ {
|
||||
public static final byte
|
||||
Tid__dir = 1, Tid__img = 2, Tid__img_style = 3, Tid__file_play = 4, Tid__file_info = 5, Tid__file_mgnf = 6
|
||||
, Tid__hiero_dir = 7, Tid__gallery_box_max = 8, Tid__gallery_box_w = 9, Tid__gallery_img_w = 10, Tid__gallery_img_pad = 11
|
||||
, Tid__toc = 12, Tid__hdr = 13
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__dir = Bry_.new_a7("~{xowa_dir}")
|
||||
, Bry__img = Bry_.new_a7("xowa_img=\"")
|
||||
, Bry__img_style = Bry_.new_a7("xowa_img_style=\"")
|
||||
, Bry__file_play = Bry_.new_a7("<xowa_play id='")
|
||||
, Bry__file_info = Bry_.new_a7("<xowa_info id='")
|
||||
, Bry__file_mgnf = Bry_.new_a7("<xowa_mgnf id=\"")
|
||||
// , Bry__hiero_dir = Bry_.new_a7("~{xowa_hiero_dir}")
|
||||
// , Bry__gallery_box_max = Bry_.new_a7("xowa_gly_box_max='")
|
||||
// , Bry__gallery_box_w = Bry_.new_a7("xowa_gly_box_w='")
|
||||
// , Bry__gallery_img_w = Bry_.new_a7("xowa_gly_img_w='")
|
||||
// , Bry__gallery_img_pad = Bry_.new_a7("xowa_gly_img_pad='")
|
||||
, Bry__toc = Bry_.new_a7("~{xowa_toc}")
|
||||
;
|
||||
public static final byte[]
|
||||
A_href_bgn = Bry_.new_a7("/wiki/File:")
|
||||
, Bry_img_style_bgn = Bry_.new_a7("style='width:")
|
||||
, Bry_img_style_end = Bry_.new_a7("px;'")
|
||||
;
|
||||
public static Btrie_slim_mgr new_trie() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.cs();
|
||||
trie_itm(rv, Tid__dir , Byte_ascii.Escape , Bry__dir);
|
||||
trie_itm(rv, Tid__img , Byte_ascii.Apos , Bry__img);
|
||||
trie_itm(rv, Tid__img_style , Byte_ascii.Apos , Bry__img_style);
|
||||
trie_itm(rv, Tid__file_play , Byte_ascii.Apos , Bry__file_play);
|
||||
trie_itm(rv, Tid__file_info , Byte_ascii.Apos , Bry__file_info);
|
||||
trie_itm(rv, Tid__file_mgnf , Byte_ascii.Apos , Bry__file_mgnf);
|
||||
// trie_itm(rv, Tid__hiero_dir , Byte_ascii.Escape , Bry__hiero_dir);
|
||||
// trie_itm(rv, Tid__gallery_box_max , Byte_ascii.Apos , Bry__gallery_box_max);
|
||||
// trie_itm(rv, Tid__gallery_box_w , Byte_ascii.Apos , Bry__gallery_box_w);
|
||||
// trie_itm(rv, Tid__gallery_img_w , Byte_ascii.Apos , Bry__gallery_img_w);
|
||||
// trie_itm(rv, Tid__gallery_img_pad , Byte_ascii.Apos , Bry__gallery_img_pad);
|
||||
trie_itm(rv, Tid__toc , Byte_ascii.Escape , Bry__toc);
|
||||
return rv;
|
||||
}
|
||||
private static void trie_itm(Btrie_slim_mgr trie, byte tid, byte subst_end_byte, byte[] key_bry) {
|
||||
boolean elem_is_xnde = key_bry[0] == Byte_ascii.Lt;
|
||||
Xoh_make_trie_itm itm = new Xoh_make_trie_itm(tid, elem_is_xnde, subst_end_byte, key_bry);
|
||||
trie.Add_obj(key_bry, itm);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user