mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.1.1
This commit is contained in:
130
400_xowa/src/gplx/core/brys/Bry_parser.java
Normal file
130
400_xowa/src/gplx/core/brys/Bry_parser.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.brys; import gplx.*; import gplx.core.*;
|
||||
public class Bry_parser {
|
||||
private final gplx.core.primitives.Int_obj_ref pos_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
private byte[] page; private String wkr_name; private int hook_bgn;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Src_len() {return src_len;} private int src_len;
|
||||
public int Pos() {return pos;} private int pos;
|
||||
public void Init_src(byte[] page, byte[] src, int src_len, int pos) {
|
||||
this.page = page; this.src = src; this.src_len = src_len; this.pos = pos;
|
||||
}
|
||||
public void Init_hook(String wkr_name, int hook_bgn, int hook_end) {
|
||||
this.wkr_name = wkr_name; this.hook_bgn = hook_bgn; this.pos = hook_end;
|
||||
}
|
||||
public int Pos_(int v) {this.pos = v; return pos;}
|
||||
public int Pos_add_one() {return Pos_add(1);}
|
||||
public int Pos_add(int adj) {
|
||||
this.pos += adj;
|
||||
return pos;
|
||||
}
|
||||
public byte Read_byte() {
|
||||
byte rv = src[pos];
|
||||
++pos;
|
||||
return rv;
|
||||
}
|
||||
public int Read_int_to(byte to_char) {
|
||||
int bgn = pos;
|
||||
int rv = 0;
|
||||
int negative = 1;
|
||||
while (pos < src_len) {
|
||||
byte b = src[pos++];
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
rv = (rv * 10) + (b - Byte_ascii.Num_0);
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
if (negative == -1) // 2nd negative
|
||||
throw Fail("invalid int", String_.new_u8(src, bgn, pos));
|
||||
else // 1st negative
|
||||
negative = -1; // flag negative
|
||||
break;
|
||||
default: {
|
||||
boolean match = b == to_char;
|
||||
if (to_char == Byte_ascii.Null) {// hack for Read_int_to_non_num
|
||||
--pos;
|
||||
match = true;
|
||||
}
|
||||
if (!match) throw Fail("invalid int", String_.new_u8(src, bgn, pos));
|
||||
return rv * negative;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bgn == pos) throw Fail("int is empty", String_.Empty);
|
||||
return rv * negative;
|
||||
}
|
||||
public byte Read_byte_as_a7_int() {
|
||||
byte rv = Byte_ascii.To_a7_int(src[pos]);
|
||||
++pos;
|
||||
return rv;
|
||||
}
|
||||
public int Read_int_by_base85(int reqd) {
|
||||
int rv = gplx.xowa.htmls.core.hzips.Xoh_hzip_int_.Decode(reqd, src, src_len, pos, pos_ref);
|
||||
pos = pos_ref.Val();
|
||||
return rv;
|
||||
}
|
||||
public boolean Is(byte find) {
|
||||
boolean rv = src[pos] == find;
|
||||
if (rv) ++pos; // only advance if match;
|
||||
return rv;
|
||||
}
|
||||
public int Chk(byte[] find) {
|
||||
int find_end = pos + find.length;
|
||||
if (!Bry_.Match(src, pos, find_end, find)) throw Fail("failed check", String_.new_u8(find));
|
||||
pos = find_end;
|
||||
return pos;
|
||||
}
|
||||
public int Chk(byte find) {
|
||||
if (src[pos] != find) throw Fail("failed check", Byte_ascii.To_str(find));
|
||||
++pos;
|
||||
return pos;
|
||||
}
|
||||
public int Fwd_bgn(byte[] find) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_len);
|
||||
if (find_pos == Bry_find_.Not_found) throw Fail("missing", String_.new_u8(find));
|
||||
pos = find_pos + find.length;
|
||||
return find_pos;
|
||||
}
|
||||
public int Fwd_bgn(byte find) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_len);
|
||||
if (find_pos == Bry_find_.Not_found) throw Fail("missing", Byte_ascii.To_str(find));
|
||||
pos = find_pos + 1;
|
||||
return find_pos;
|
||||
}
|
||||
public int Fwd_end(byte[] find) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_len);
|
||||
if (find_pos == Bry_find_.Not_found) throw Fail("missing", String_.new_u8(find));
|
||||
pos = find_pos + find.length;
|
||||
return pos;
|
||||
}
|
||||
public int Fwd_end(byte find) {
|
||||
int find_pos = Bry_find_.Find_fwd(src, find, pos, src_len);
|
||||
if (find_pos == Bry_find_.Not_found) throw Fail("missing", Byte_ascii.To_str(find));
|
||||
pos = find_pos + 1;
|
||||
return pos;
|
||||
}
|
||||
public int Fwd_while(byte find) {
|
||||
this.pos = Bry_find_.Find_fwd_while(src, pos, src_len, find);
|
||||
return pos;
|
||||
}
|
||||
public Err Fail(String msg, String arg) {
|
||||
return Err_.new_("Bry_parser", msg, "arg", arg, "page", page, "wkr", wkr_name, "excerpt", Bry_.Mid_by_len_safe(src, hook_bgn, 255));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.flds; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.encoders.*;
|
||||
public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
private Bry_bfr bfr = Bry_bfr.new_(); private static final byte[] Bry_nil = Bry_.new_a7("\\0");
|
||||
public byte[] Data() {return data;} public Gfo_fld_rdr Data_(byte[] v) {data = v; data_len = v.length; pos = 0; return this;} private byte[] data; int data_len;
|
||||
@@ -28,8 +29,8 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
|
||||
public String Read_str_simple() {Move_next_simple(); return String_.new_u8(data, fld_bgn, fld_end);}
|
||||
public byte[] Read_bry_simple() {Move_next_simple(); return Bry_.Mid(data, fld_bgn, fld_end);} // was Mid_by_len???; 20120915
|
||||
public int Read_int_base85_lenN(int len) {fld_bgn = pos; fld_end = pos + len - 1 ; pos = pos + len + 1 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int_base85_len5() {fld_bgn = pos; fld_end = pos + 4 ; pos = pos + 6 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int_base85_lenN(int len) {fld_bgn = pos; fld_end = pos + len - 1 ; pos = pos + len + 1 ; return Base85_.To_int_by_bry(data, fld_bgn, fld_end);}
|
||||
public int Read_int_base85_len5() {fld_bgn = pos; fld_end = pos + 4 ; pos = pos + 6 ; return Base85_.To_int_by_bry(data, fld_bgn, fld_end);}
|
||||
public int Read_int() {Move_next_simple(); return Bry_.To_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_int_as_byte() {Move_next_simple(); return (byte)Bry_.To_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_byte() {Move_next_simple(); return data[fld_bgn];}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.flds; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Gfo_fld_rdr_tst {
|
||||
Gfo_fld_rdr_fxt fxt = new Gfo_fld_rdr_fxt();
|
||||
@Test public void Read_int() {fxt.ini_xdat().Raw_("123|") .tst_Read_int(123);}
|
||||
|
||||
@@ -16,11 +16,11 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.flds; import gplx.*; import gplx.core.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*; import gplx.core.encoders.*;
|
||||
public class Gfo_fld_wtr extends Gfo_fld_base {
|
||||
public Bry_bfr Bfr() {return bfr;} public Gfo_fld_wtr Bfr_(Bry_bfr v) {bfr = v; return this;} Bry_bfr bfr;
|
||||
public Gfo_fld_wtr() {this.bfr = Bry_bfr.new_();}
|
||||
public Gfo_fld_wtr Write_int_base85_len5_fld(int v) {bfr.Add_base85(v, Base85_utl.Len_int); bfr.Add_byte(fld_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_base85_len5_fld(int v) {bfr.Add_base85(v, Base85_.Len_int); bfr.Add_byte(fld_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_base85_lenN_fld(int v, int len) {bfr.Add_base85(v, len); bfr.Add_byte(fld_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_variable_fld(int v) {bfr.Add_int_variable(v); bfr.Add_byte(fld_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_fixed_fld(int v, int len) {bfr.Add_int_fixed(v, len); bfr.Add_byte(fld_dlm); return this;}
|
||||
@@ -31,7 +31,7 @@ public class Gfo_fld_wtr extends Gfo_fld_base {
|
||||
public Gfo_fld_wtr Write_dlm_row() { bfr.Add_byte(row_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_dlm_fld() { bfr.Add_byte(fld_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_base85_lenN_row(int v, int len) {bfr.Add_base85(v, len); bfr.Add_byte(row_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_base85_len5_row(int v) {bfr.Add_base85(v, Base85_utl.Len_int); bfr.Add_byte(row_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_int_base85_len5_row(int v) {bfr.Add_base85(v, Base85_.Len_int); bfr.Add_byte(row_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_bry_escape_row(byte[] val) {Write_bry_escape(val, 0, val.length); bfr.Add_byte(row_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_bry_escape_row(byte[] val, int bgn, int end) {Write_bry_escape(val, bgn, end); bfr.Add_byte(row_dlm); return this;}
|
||||
public Gfo_fld_wtr Write_double_row(double v) {bfr.Add_double(v); bfr.Add_byte(row_dlm); return this;}
|
||||
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*;
|
||||
class BinaryHeap_Io_line_rdr {
|
||||
public BinaryHeap_Io_line_rdr(ComparerAble comparer) {this.comparer = comparer;} ComparerAble comparer;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class BinaryHeap_Io_line_rdr_tst {
|
||||
BinaryHeap_Io_line_rdr_fxt fxt = new BinaryHeap_Io_line_rdr_fxt();
|
||||
@@ -15,8 +15,8 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
import gplx.ios.*;/*IoStream*/
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.ios.*;/*IoStream*/
|
||||
public class Io_buffer_rdr implements RlsAble {
|
||||
private Io_stream_rdr rdr;
|
||||
Io_buffer_rdr(Io_stream_rdr rdr, Io_url url, int bfr_len) {
|
||||
@@ -43,7 +43,7 @@ public class Io_buffer_rdr implements RlsAble {
|
||||
}
|
||||
private boolean Bfr_load(int bgn, int len) {
|
||||
int read = rdr.Read(bfr, bgn, len);
|
||||
if (read == gplx.ios.Io_stream_rdr_.Read_done) {fil_eof = true; return false;}
|
||||
if (read == gplx.core.ios.Io_stream_rdr_.Read_done) {fil_eof = true; return false;}
|
||||
fil_pos += read;
|
||||
bfr_len = bgn + read;
|
||||
if (read < len) fil_eof = true;
|
||||
@@ -15,8 +15,8 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
import org.junit.*; import gplx.ios.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*; import gplx.core.ios.*;
|
||||
public class Io_buffer_rdr_tst {
|
||||
@Before public void init() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
@@ -15,15 +15,15 @@ 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.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.tests.*;
|
||||
public class Io_fil_chkr implements Tst_chkr {
|
||||
public Io_fil_chkr(Io_url url, String data) {this.expd_url = url; this.expd_data = data;}
|
||||
public Io_url Expd_url() {return expd_url;} public Io_fil_chkr Expd_url_(Io_url v) {expd_url = v; return this;} Io_url expd_url;
|
||||
public String Expd_data() {return expd_data;} public Io_fil_chkr Expd_data_(String v) {expd_data = v; return this;} private String expd_data;
|
||||
public Class<?> TypeOf() {return gplx.ios.Io_fil.class;}
|
||||
public Class<?> TypeOf() {return gplx.core.ios.Io_fil.class;}
|
||||
public int Chk(Tst_mgr mgr, String path, Object actl) {
|
||||
gplx.ios.Io_fil fil = (gplx.ios.Io_fil)actl;
|
||||
gplx.core.ios.Io_fil fil = (gplx.core.ios.Io_fil)actl;
|
||||
int rv = 0;
|
||||
rv += mgr.Tst_val(expd_url == null, path, "url", expd_url, fil.Url());
|
||||
rv += mgr.Tst_val(expd_data == null, path, "data", expd_data, fil.Data());
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_line_rdr {
|
||||
public Io_line_rdr (Gfo_usr_dlg usr_dlg, Io_url... urls) {this.usr_dlg = usr_dlg; this.urls = urls; if (urls.length == 0) bfr_state = Bfr_state_end;} Gfo_usr_dlg usr_dlg;
|
||||
public int Url_idx() {return url_idx;} private int url_idx;
|
||||
@@ -140,11 +140,11 @@ public class Io_line_rdr {
|
||||
byte[] stream_bry = Io_mgr.Instance.LoadFilBry(url);
|
||||
int stream_bry_len = stream_bry.length;
|
||||
int nl_pos = Bry_find_.Find_fwd(stream_bry, Byte_ascii.Nl, 0, stream_bry_len);
|
||||
if (nl_pos == Bry_.NotFound)
|
||||
if (nl_pos == Bry_find_.Not_found)
|
||||
stream_bry = Bry_.Empty;
|
||||
else
|
||||
stream_bry = Bry_.Mid(stream_bry, nl_pos + 1, stream_bry_len);
|
||||
stream = gplx.ios.IoStream_.ary_(stream_bry);
|
||||
stream = gplx.core.ios.IoStream_.ary_(stream_bry);
|
||||
}
|
||||
else {
|
||||
stream = Io_mgr.Instance.OpenStreamRead(url);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public interface Io_line_rdr_key_gen {
|
||||
void Gen(Io_line_rdr bfr);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_line_rdr_key_gen_ {
|
||||
public static final Io_line_rdr_key_gen first_pipe = new Io_line_rdr_key_gen_first(Byte_ascii.Pipe);
|
||||
public static final Io_line_rdr_key_gen last_pipe = new Io_line_rdr_key_gen_last(Byte_ascii.Pipe);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Io_line_rdr_tst {
|
||||
Io_line_rdr_fxt fxt;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public interface Io_make_cmd extends Io_sort_cmd {
|
||||
Io_sort_cmd Make_dir_(Io_url v);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import gplx.lists.*;
|
||||
public class Io_sort {
|
||||
public Io_sort Memory_max_(int v) {memory_max = v; return this;} private int memory_max = Io_mgr.Len_kb;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public interface Io_sort_cmd {
|
||||
void Sort_bgn();
|
||||
void Sort_do(Io_line_rdr rdr);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public interface Io_sort_filCmd {
|
||||
void Bfr_add(Io_line_rdr stream);
|
||||
void Fil_bgn(Io_line_rdr stream);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_sort_fil_basic implements Io_sort_cmd { // 123|bgn|end|1
|
||||
public Io_sort_fil_basic(Gfo_usr_dlg usr_dlg, Io_url_gen url_gen, int flush_len) {this.usr_dlg = usr_dlg; this.url_gen = url_gen; this.flush_len = flush_len;} Io_url_gen url_gen; Bry_bfr bfr = Bry_bfr.new_(); int flush_len; Gfo_usr_dlg usr_dlg;
|
||||
public void Sort_bgn() {}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Io_sort_misc_tst {
|
||||
@Before public void init() {
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_sort_split_itm {
|
||||
public Io_sort_split_itm() {}
|
||||
public Io_sort_split_itm(Io_line_rdr rdr) {Set(rdr);}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_sort_split_itm_sorter implements gplx.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Io_sort_split_itm lhs = (Io_sort_split_itm)lhsObj, rhs = (Io_sort_split_itm)rhsObj;
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
public class Io_sort_tst {
|
||||
Io_sort_fxt fxt = new Io_sort_fxt();
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import java.io.InputStream;
|
||||
public class Io_stream_rdr_process implements Io_stream_rdr {
|
||||
private Process process;
|
||||
@@ -15,9 +15,9 @@ 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.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_stream_zip_mgr {
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(256);
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(256);
|
||||
private Io_stream_wtr wtr_gzip, wtr_zip, wtr_bzip2;
|
||||
private Io_stream_rdr rdr_gzip, rdr_zip, rdr_bzip2;
|
||||
public byte[] Zip(byte type, byte[] val) {
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public interface Io_url_gen {
|
||||
Io_url Cur_url();
|
||||
Io_url Nxt_url();
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_url_gen_ {
|
||||
public static Io_url_gen dir_(Io_url v) {return new Io_url_gen_dir(v);}
|
||||
public static Io_url_gen dir_(Io_url v, String fmt, int digits) {return new Io_url_gen_dir(v).Fmt_(fmt).Fmt_digits_(digits);}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public interface Io_zip_mgr {
|
||||
void Zip_fil(Io_url src_fil, Io_url trg_fil);
|
||||
byte[] Zip_bry(byte[] src, int bgn, int len);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
public class Io_zip_mgr_base implements Io_zip_mgr {
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
public class Io_zip_mgr_mok implements Io_zip_mgr {
|
||||
public void Zip_fil(Io_url src_fil, Io_url trg_fil) {
|
||||
byte[] src_bry = Io_mgr.Instance.LoadFilBry(src_fil);
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.ios; import gplx.*;
|
||||
package gplx.core.ios; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Io_zip_mgr_tst {
|
||||
@Test public void Zip_unzip() {
|
||||
@@ -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.core.net; import gplx.*; import gplx.core.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
class Gfo_inet_conn__http implements Gfo_inet_conn {
|
||||
private final IoEngine_xrg_downloadFil downloader = IoEngine_xrg_downloadFil.new_("", Io_url_.Empty);
|
||||
public int Tid() {return Gfo_inet_conn_.Tid__http;}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Gfo_url_parser {
|
||||
}
|
||||
if (!rel) { // search for ":"; NOTE: only search if not rel; i.e.: "//"
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
|
||||
if (colon_pos != Bry_.NotFound) // colon found; EX: "http://" or "https://"
|
||||
if (colon_pos != Bry_find_.Not_found) // colon found; EX: "http://" or "https://"
|
||||
pos = colon_pos + Int_.Const_dlm_len;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
|
||||
pos += 1;
|
||||
@@ -56,7 +56,7 @@ public class Gfo_url_parser {
|
||||
}
|
||||
}
|
||||
int slash_pos = Bry_find_.Find_fwd(src, Byte_ascii.Slash, pos, src_end);
|
||||
if (slash_pos == Bry_.NotFound) // no terminating slash; EX: http://a.org
|
||||
if (slash_pos == Bry_find_.Not_found) // no terminating slash; EX: http://a.org
|
||||
slash_pos = src_end;
|
||||
slash_pos = Bry_.Trim_end_pos(src, slash_pos);
|
||||
site_data.Atrs_set(rel, pos, slash_pos);
|
||||
|
||||
@@ -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.core.net; import gplx.*; import gplx.core.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public interface Http_client_wtr {
|
||||
void Stream_(Object o);
|
||||
void Write_bry(byte[] bry);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
import java.io.*;
|
||||
class Http_client_wtr__stream implements Http_client_wtr {
|
||||
private final byte[] tmp_stream_bry = new byte[1024];
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Gfo_thread_cmd_download implements Gfo_thread_cmd {
|
||||
kit.Ask_ok(GRP_KEY, "download.fail", "download failed. Please select 'read from file' if you've already downloaded a dump: url=~{0} error=~{1}", src, xrg.Rslt_err_str());
|
||||
}
|
||||
} boolean download_pass = true;
|
||||
protected gplx.ios.IoEngine_xrg_downloadFil xrg = Io_mgr.Instance.DownloadFil_args("", Io_url_.Empty);
|
||||
protected gplx.core.ios.IoEngine_xrg_downloadFil xrg = Io_mgr.Instance.DownloadFil_args("", Io_url_.Empty);
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_async_bgn)) Download();
|
||||
else if (ctx.Match(k, Invk_owner)) return owner;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
|
||||
public boolean Async_prog_enabled() {return true;}
|
||||
public void Async_prog_run(int async_sleep_sum) {
|
||||
String size_str = " please wait...";
|
||||
if (trg.Type_fil()) size_str = gplx.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg).Size());
|
||||
if (trg.Type_fil()) size_str = gplx.core.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg).Size());
|
||||
usr_dlg.Prog_many(GRP_KEY, "unzip", "unzipping: ~{0}", size_str);
|
||||
}
|
||||
@gplx.Virtual public byte Async_init() {
|
||||
|
||||
@@ -19,10 +19,10 @@ package gplx.core.threads.poolables; import gplx.*; import gplx.core.*; import g
|
||||
public class Gfo_poolable_mgr {
|
||||
private final Object thread_lock = new Object();
|
||||
private final Gfo_poolable_itm prototype; private final Object[] make_args, clear_args;
|
||||
private Gfo_poolable_itm[] pool; private int pool_next, pool_len; private final int pool_max;
|
||||
public Gfo_poolable_mgr(Gfo_poolable_itm prototype, Object[] make_args, Object[] clear_args, int init_pool_len, int pool_max) {// NOTE: random IndexOutOfBounds errors in Get around free[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
private Gfo_poolable_itm[] pool; private int pool_nxt, pool_len;
|
||||
public Gfo_poolable_mgr(Gfo_poolable_itm prototype, Object[] make_args, Object[] clear_args, int init_pool_len, int pool_max) {// NOTE: random IndexOutOfBounds errors in Get around free_ary[--free_len] with free_len being -1; put member variable initialization within thread_lock to try to avoid; DATE:2014-09-21
|
||||
this.prototype = prototype; this.make_args = make_args; this.clear_args = clear_args;
|
||||
this.pool_len = init_pool_len; this.pool_max = pool_max;
|
||||
this.pool_len = init_pool_len;
|
||||
this.Clear_fast();
|
||||
}
|
||||
public void Clear_safe() {synchronized (thread_lock) {Clear_fast();}}
|
||||
@@ -30,21 +30,21 @@ public class Gfo_poolable_mgr {
|
||||
this.pool = new Gfo_poolable_itm[pool_len];
|
||||
for (int i = 0; i < pool_len; ++i)
|
||||
pool[i] = prototype.Pool__make(i, make_args);
|
||||
this.free = new int[pool_len];
|
||||
pool_next = free_len = 0;
|
||||
this.free_ary = new int[pool_len];
|
||||
pool_nxt = free_len = 0;
|
||||
}
|
||||
public Gfo_poolable_itm Get_safe() {synchronized (thread_lock) {return Get_fast();}}
|
||||
public Gfo_poolable_itm Get_fast() {
|
||||
Gfo_poolable_itm rv = null;
|
||||
int pool_idx = -1;
|
||||
if (free_len > 0) { // free_itms in pool; use it
|
||||
pool_idx = free[--free_len];
|
||||
pool_idx = free_ary[--free_len];
|
||||
rv = pool[pool_idx];
|
||||
}
|
||||
else { // nothing in pool; take next
|
||||
if (pool_next == pool_len)
|
||||
if (pool_nxt == pool_len)
|
||||
Expand_pool();
|
||||
pool_idx = pool_next++;
|
||||
pool_idx = pool_nxt++;
|
||||
rv = pool[pool_idx];
|
||||
if (rv == null) {
|
||||
rv = prototype.Pool__make(pool_idx, make_args);
|
||||
@@ -57,23 +57,18 @@ public class Gfo_poolable_mgr {
|
||||
public void Rls_safe(int idx) {synchronized (thread_lock) {Rls_safe(idx);}}
|
||||
public void Rls_fast(int idx) {
|
||||
if (idx == -1) throw Err_.new_wo_type("rls called on poolable that was not created by pool_mgr");
|
||||
int pool_idx = pool_next - 1;
|
||||
int pool_idx = pool_nxt - 1;
|
||||
if (idx == pool_idx) // in-sequence; decrement count
|
||||
this.pool_next = pool_idx;
|
||||
else { // out-of-sequence
|
||||
if (free_len == pool_max) { // all used; assume entire pool released, but out of order
|
||||
// Array_.Sort((Object[])free);
|
||||
// for (int i = 0; i < pool_max; ++i) {
|
||||
// if (i != free[i]) throw Err_.new_("pool", "available_list out of order", "contents", "");
|
||||
// }
|
||||
if (free_len == 0)
|
||||
this.pool_nxt = pool_idx;
|
||||
else { // idx == pool_idx; assume entire pool released, but out of order
|
||||
for (int i = 0; i < free_len; ++i)
|
||||
free[i] = 0;
|
||||
free_ary[i] = 0;
|
||||
free_len = 0;
|
||||
}
|
||||
else { // add to free pool
|
||||
free[free_len] = idx;
|
||||
++free_len;
|
||||
}
|
||||
else { // out-of-sequence
|
||||
free_ary[free_len] = idx;
|
||||
++free_len;
|
||||
}
|
||||
}
|
||||
private void Expand_pool() {
|
||||
@@ -84,44 +79,13 @@ public class Gfo_poolable_mgr {
|
||||
this.pool = new_pool;
|
||||
this.pool_len = new_pool_len;
|
||||
|
||||
// expand free to same len
|
||||
// expand free_ary to same len
|
||||
int[] new_free = new int[pool_len];
|
||||
Array_.Copy_to(free, 0, new_free, 0, free_len);
|
||||
this.free = new_free;
|
||||
Array_.Copy_to(free_ary, 0, new_free, 0, free_len);
|
||||
this.free_ary = new_free;
|
||||
}
|
||||
@gplx.Internal protected int[] Free() {return free;} private int[] free; private int free_len;
|
||||
@gplx.Internal protected int[] Free_ary() {return free_ary;} private int[] free_ary; private int free_len;
|
||||
@gplx.Internal protected int Free_len() {return free_len;}
|
||||
@gplx.Internal protected int Pool_len() {return pool_len;}
|
||||
// public int Mgr_id() {return mgr_id;} private int mgr_id;
|
||||
// public void Reset_if_gt(int v) {
|
||||
// this.Clear(); // TODO: for now, just call clear
|
||||
// }
|
||||
// public void Clear_fail_check() {
|
||||
// synchronized (thread_lock) {
|
||||
// for (int i = 0; i < ary_max; i++) {
|
||||
// Object itm = ary[i];
|
||||
// if (itm != null) {
|
||||
// if (!itm.Mkr_idx_is_null()) throw Err_.new_wo_type("failed to clear bfr", "idx", Int_.To_str(i));
|
||||
// itm.Clear();
|
||||
// }
|
||||
// ary[i] = null;
|
||||
// }
|
||||
// ary = Ary_empty;
|
||||
// free = Int_.Ary_empty;
|
||||
// free_len = 0;
|
||||
// nxt_idx = ary_max = 0;
|
||||
// }
|
||||
// }
|
||||
// public void Clear() {
|
||||
// synchronized (thread_lock) {
|
||||
// for (int i = 0; i < ary_max; i++) {
|
||||
// Object itm = ary[i];
|
||||
// if (itm != null) itm.Clear();
|
||||
// ary[i] = null;
|
||||
// }
|
||||
// ary = Ary_empty;
|
||||
// free = Int_.Ary_empty;
|
||||
// free_len = 0;
|
||||
// nxt_idx = ary_max = 0;
|
||||
// }
|
||||
// }
|
||||
@gplx.Internal protected int Pool_nxt() {return pool_nxt;}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,43 @@ public class Gfo_poolable_mgr_tst {
|
||||
@Before public void init() {tstr.Clear();}
|
||||
@Test public void Get__one() {
|
||||
tstr.Test__get(0);
|
||||
tstr.Test__mgr__free(0, 0);
|
||||
tstr.Test__free__len(0);
|
||||
tstr.Test__pool__len(2);
|
||||
}
|
||||
@Test public void Get__many__expand() {
|
||||
tstr.Test__get(0);
|
||||
tstr.Test__get(1);
|
||||
tstr.Test__get(2);
|
||||
tstr.Test__free__len(0);
|
||||
tstr.Test__pool__len(4);
|
||||
}
|
||||
@Test public void Rls__lifo() {
|
||||
tstr.Test__get(0);
|
||||
tstr.Test__get(1);
|
||||
tstr.Test__get(2);
|
||||
tstr.Exec__rls(2);
|
||||
tstr.Exec__rls(1);
|
||||
tstr.Exec__rls(0);
|
||||
tstr.Test__pool__nxt(0);
|
||||
tstr.Test__free__len(0);
|
||||
}
|
||||
@Test public void Rls__fifo() {
|
||||
tstr.Test__get(0);
|
||||
tstr.Test__get(1);
|
||||
tstr.Test__get(2);
|
||||
tstr.Exec__rls(0);
|
||||
tstr.Exec__rls(1);
|
||||
tstr.Test__pool__nxt(3);
|
||||
tstr.Test__free__len(2); // 2 items in free_ary
|
||||
tstr.Test__free__ary(0, 1, 0, 0);
|
||||
|
||||
tstr.Test__get(1);
|
||||
tstr.Exec__rls(1);
|
||||
|
||||
tstr.Exec__rls(2);
|
||||
tstr.Test__free__len(0); // 0 items in free_ary
|
||||
tstr.Test__free__ary(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
class Gfo_poolable_mgr_tstr {
|
||||
private final Gfo_poolable_mgr mgr = new Gfo_poolable_mgr(new Sample_poolable_itm(-1, Object_.Ary_empty), Object_.Ary("make"), Object_.Ary("clear"), 2, 8);
|
||||
@@ -33,12 +67,11 @@ class Gfo_poolable_mgr_tstr {
|
||||
Sample_poolable_itm actl_itm = (Sample_poolable_itm)mgr.Get_fast();
|
||||
Tfds.Eq(expd_idx, actl_itm.Pool__idx(), "pool_idx");
|
||||
}
|
||||
public void Test__mgr__free(int... expd) {
|
||||
Tfds.Eq_ary(expd, mgr.Free(), "mgr.Free()");
|
||||
}
|
||||
public void Test__pool__len(int expd) {
|
||||
Tfds.Eq(expd, mgr.Pool_len(), "mgr.Pool_len()");
|
||||
}
|
||||
public void Test__free__ary(int... expd) {Tfds.Eq_ary(expd, mgr.Free_ary(), "mgr.Free_ary()");}
|
||||
public void Test__free__len(int expd) {Tfds.Eq(expd, mgr.Free_len(), "mgr.Free_len()");}
|
||||
public void Test__pool__len(int expd) {Tfds.Eq(expd, mgr.Pool_len(), "mgr.Pool_len()");}
|
||||
public void Test__pool__nxt(int expd) {Tfds.Eq(expd, mgr.Pool_nxt(), "mgr.Pool_nxt()");}
|
||||
public void Exec__rls(int idx) {mgr.Rls_fast(idx);}
|
||||
}
|
||||
class Sample_poolable_itm implements Gfo_poolable_itm {
|
||||
public Sample_poolable_itm(int pool_idx, Object[] make_args) {this.pool_idx = pool_idx; this.pool__make_args = make_args;}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.dbs.*; import gplx.ios.*;
|
||||
import gplx.dbs.*; import gplx.core.ios.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
public class Fsd_bin_tbl implements RlsAble {
|
||||
private final String tbl_name = "fsdb_bin"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
|
||||
@@ -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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.core.primitives.*; import gplx.core.caches.*; import gplx.ios.*;
|
||||
import gplx.core.primitives.*; import gplx.core.caches.*; import gplx.core.ios.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.fsdb.data.*;
|
||||
public class Fsm_atr_fil {
|
||||
private final Fsm_mnt_itm mnt_itm; private final int mnt_id;
|
||||
|
||||
@@ -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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.ios.*; import gplx.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*;
|
||||
import gplx.fsdb.data.*;
|
||||
public class Fsm_bin_fil {
|
||||
private final Fsd_bin_tbl tbl;
|
||||
@@ -31,7 +31,7 @@ public class Fsm_bin_fil {
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public boolean Select_to_url(int id, Io_url url) {return tbl.Select_to_url(id, url);}
|
||||
public Io_stream_rdr Select_as_rdr(int id) {return tbl.Select_as_rdr(id);}
|
||||
public void Insert(int bin_id, byte owner_tid, long rdr_len, gplx.ios.Io_stream_rdr rdr) {
|
||||
public void Insert(int bin_id, byte owner_tid, long rdr_len, gplx.core.ios.Io_stream_rdr rdr) {
|
||||
tbl.Insert_rdr(bin_id, owner_tid, rdr_len, rdr);
|
||||
Bin_len_(bin_len + rdr_len);
|
||||
}
|
||||
|
||||
@@ -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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.ios.*; import gplx.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*;
|
||||
public class Fsm_bin_mgr {
|
||||
private final Fsdb_db_mgr core_mgr; private final int mnt_id; private final Fsm_bin_tbl tbl;
|
||||
private Fsm_bin_fil[] dbs__ary = Fsm_bin_fil.Ary_empty; private int dbs__ary_len = 0; private Fsm_bin_fil nth_db;
|
||||
|
||||
@@ -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.fsdb.meta; import gplx.*; import gplx.fsdb.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.fsdb.data.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.fsdb.data.*;
|
||||
public class Fsm_mnt_itm {
|
||||
public Fsm_mnt_itm(int id, String name, String url_rel) {this.id = id; this.name = name; this.url_rel = url_rel;}
|
||||
public int Id() {return id;} private final int id;
|
||||
@@ -47,7 +47,7 @@ public class Fsm_mnt_itm {
|
||||
int fil_id = atr_fil.Insert_img(rv, dir, fil, ext_id, img_w, img_h, bin_fil.Id(), bin_len, bin_rdr);
|
||||
bin_fil.Insert(fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
|
||||
}
|
||||
public void Insert_fil(Fsd_fil_itm rv, Fsm_atr_fil atr_fil, Fsm_bin_fil bin_fil, byte[] dir, byte[] fil, int ext_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
public void Insert_fil(Fsd_fil_itm rv, Fsm_atr_fil atr_fil, Fsm_bin_fil bin_fil, byte[] dir, byte[] fil, int ext_id, long bin_len, gplx.core.ios.Io_stream_rdr bin_rdr) {
|
||||
int fil_id = atr_fil.Insert_fil(rv, dir, fil, ext_id, bin_fil.Id(), bin_len, bin_rdr);
|
||||
bin_fil.Insert(fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ class Gfs_lxr_comment_flat implements Gfs_lxr {
|
||||
public int Process(Gfs_parser_ctx ctx, int lxr_bgn, int lxr_end) {
|
||||
byte[] src = ctx.Src(); int src_len = ctx.Src_len();
|
||||
int end_pos = Bry_find_.Find_fwd(src, end_bry, lxr_end, src_len);
|
||||
// if (end_pos == Bry_.NotFound) throw Err_.new_fmt_("comment is not closed: {0}", String_.new_u8(end_bry));
|
||||
return (end_pos == Bry_.NotFound)
|
||||
// if (end_pos == Bry_find_.Not_found) throw Err_.new_fmt_("comment is not closed: {0}", String_.new_u8(end_bry));
|
||||
return (end_pos == Bry_find_.Not_found)
|
||||
? src_len // allow eos to terminate flat comment; needed for "tidy-always-adds-nl-in-textarea" fix; NOTE: DATE:2014-06-21
|
||||
: end_pos + end_bry_len; // position after end_bry
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class Gfs_lxr_quote implements Gfs_lxr {
|
||||
public int Process(Gfs_parser_ctx ctx, int lxr_bgn, int lxr_end) {
|
||||
byte[] src = ctx.Src(); int src_len = ctx.Src_len();
|
||||
int end_pos = Bry_find_.Find_fwd(src, end_bry, lxr_end, src_len);
|
||||
if (end_pos == Bry_.NotFound) throw Err_.new_wo_type("quote is not closed", "end", String_.new_u8(end_bry));
|
||||
if (end_pos == Bry_find_.Not_found) throw Err_.new_wo_type("quote is not closed", "end", String_.new_u8(end_bry));
|
||||
Bry_bfr bfr = ctx.Tmp_bfr().Clear();
|
||||
int prv_pos = lxr_end;
|
||||
int nxt_pos = end_pos + end_bry_len;
|
||||
@@ -160,7 +160,7 @@ class Gfs_lxr_quote implements Gfs_lxr {
|
||||
bfr.Add(end_bry); // add end_bry
|
||||
prv_pos = nxt_pos + end_bry_len; // set prv_pos to after doubled end_bry
|
||||
end_pos = Bry_find_.Find_fwd(src, end_bry, prv_pos, src_len);
|
||||
if (end_pos == Bry_.NotFound) throw Err_.new_wo_type("quote is not closed", "end", String_.new_u8(end_bry));
|
||||
if (end_pos == Bry_find_.Not_found) throw Err_.new_wo_type("quote is not closed", "end", String_.new_u8(end_bry));
|
||||
nxt_pos = end_pos + end_bry_len;
|
||||
if (!Bry_.Match(src, nxt_pos, nxt_pos + end_bry_len, end_bry)) {
|
||||
bfr.Add_mid(src, prv_pos, end_pos);
|
||||
|
||||
@@ -88,14 +88,14 @@ class Gfs_err_mgr {
|
||||
}
|
||||
public static final String Fail_msg_invalid_lxr = "invalid character", Fail_msg_unknown_char = "unknown char", Fail_msg_eos = "end of stream", Fail_msg_nde_stack_empty = "node stack empty";
|
||||
String Fail_msg(String type, KeyValList fail_args) {
|
||||
tmp_fail_bfr.Add_str(type).Add_byte(Byte_ascii.Colon);
|
||||
tmp_fail_bfr.Add_str_u8(type).Add_byte(Byte_ascii.Colon);
|
||||
int len = fail_args.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
tmp_fail_bfr.Add_byte(Byte_ascii.Space);
|
||||
KeyVal kv = fail_args.GetAt(i);
|
||||
tmp_fail_bfr.Add_str(kv.Key());
|
||||
tmp_fail_bfr.Add_str_u8(kv.Key());
|
||||
tmp_fail_bfr.Add_byte(Byte_ascii.Eq).Add_byte(Byte_ascii.Apos);
|
||||
tmp_fail_bfr.Add_str(kv.Val_to_str_or_empty()).Add_byte(Byte_ascii.Apos);
|
||||
tmp_fail_bfr.Add_str_u8(kv.Val_to_str_or_empty()).Add_byte(Byte_ascii.Apos);
|
||||
}
|
||||
return tmp_fail_bfr.To_str_and_clear();
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
public class Html_atr_ {
|
||||
public static final String
|
||||
Src_str = "src"
|
||||
;
|
||||
public static final byte[]
|
||||
Id_bry = Bry_.new_a7("id")
|
||||
, Cls_bry = Bry_.new_a7("class")
|
||||
, Style_bry = Bry_.new_a7("style")
|
||||
, Href_bry = Bry_.new_a7("href")
|
||||
Bry__id = Bry_.new_a7("id")
|
||||
, Bry__class = Bry_.new_a7("class")
|
||||
, Bry__rel = Bry_.new_a7("rel")
|
||||
, Bry__href = Bry_.new_a7("href")
|
||||
, Bry__title = Bry_.new_a7("title")
|
||||
, Bry__style = Bry_.new_a7("style")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
|
||||
import org.junit.*;
|
||||
public class Html_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_parser_fxt fxt = new Xoh_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();} private Html_parser_fxt fxt = new Html_parser_fxt();
|
||||
@Test public void One() {fxt.Test_parse_find_all("<a id='id0'></a>", "id0");}
|
||||
@Test public void Many() {fxt.Test_parse_find_all("<a id='id0'></a><a id='id1'></a><a id='id2'></a>", "id0", "id1", "id2");}
|
||||
@Test public void Inline() {fxt.Test_parse_find_all("<a id='id0'/>", "id0");}
|
||||
@@ -26,14 +26,14 @@ public class Html_parser_tst {
|
||||
@Test public void Quote_double() {fxt.Test_parse_find_all("<a id='id''0'/>", "id'0");}
|
||||
@Test public void Quote_escape() {fxt.Test_parse_find_all("<a id='id\\'0'/>", "id'0");}
|
||||
}
|
||||
class Xoh_parser_fxt {
|
||||
class Html_parser_fxt {
|
||||
public void Clear() {
|
||||
if (parser == null) {
|
||||
parser = new Html_parser();
|
||||
}
|
||||
} private Html_parser parser;
|
||||
public Xoh_parser_fxt Test_parse_find_all(String raw_str, String... expd) {return Test_parse_find(raw_str, Html_parser.Wildcard_str, Html_parser.Wildcard_str, expd);}
|
||||
public Xoh_parser_fxt Test_parse_find(String raw_str, String find_key, String find_val, String... expd) {
|
||||
public Html_parser_fxt Test_parse_find_all(String raw_str, String... expd) {return Test_parse_find(raw_str, Html_parser.Wildcard_str, Html_parser.Wildcard_str, expd);}
|
||||
public Html_parser_fxt Test_parse_find(String raw_str, String find_key, String find_val, String... expd) {
|
||||
byte[] raw = Bry_.new_a7(raw_str);
|
||||
Html_nde[] actl_ndes = parser.Parse_as_ary(raw, 0, raw.length, Bry_.new_a7(find_key), Bry_.new_a7(find_val));
|
||||
String[] actl = Xto_ids(raw, actl_ndes);
|
||||
|
||||
@@ -29,9 +29,12 @@ public class Html_tag_ {
|
||||
Br_inl = Bry_.new_a7("<br/>")
|
||||
, Hr_inl = Bry_.new_a7("<hr/>")
|
||||
, Body_lhs = Bry_.new_a7("<body>") , Body_rhs = Bry_.new_a7("</body>")
|
||||
, A_lhs_bgn = Bry_.new_a7("<a")
|
||||
, A_rhs = Bry_.new_a7("</a>")
|
||||
, B_lhs = Bry_.new_a7("<b>") , B_rhs = Bry_.new_a7("</b>")
|
||||
, I_lhs = Bry_.new_a7("<i>") , I_rhs = Bry_.new_a7("</i>")
|
||||
, 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>")
|
||||
, Html_rhs = Bry_.new_a7("</html>")
|
||||
, Head_lhs_bgn = Bry_.new_a7("<head")
|
||||
@@ -41,6 +44,7 @@ public class Html_tag_ {
|
||||
, Script_lhs = Bry_.new_a7("<script>")
|
||||
, Script_lhs_w_type = Bry_.new_a7("<script type='text/javascript'>")
|
||||
, Script_rhs = Bry_.new_a7("</script>")
|
||||
, Span_lhs = Bry_.new_a7("<span")
|
||||
, Span_rhs = Bry_.new_a7("</span>")
|
||||
;
|
||||
|
||||
@@ -56,4 +60,28 @@ public class Html_tag_ {
|
||||
Comm_bgn_len = Comm_bgn.length
|
||||
, Comm_end_len = Comm_end.length
|
||||
;
|
||||
public static final int
|
||||
Id__eos = -2
|
||||
, Id__any = -1
|
||||
, Id__unknown = 0
|
||||
, Id__a = 1
|
||||
, Id__h2 = 2
|
||||
, Id__h3 = 3
|
||||
, Id__h4 = 4
|
||||
, Id__h5 = 5
|
||||
, Id__h6 = 6
|
||||
, Id__span = 7
|
||||
, Id__div = 8
|
||||
, Id__comment = 9
|
||||
;
|
||||
public static final Hash_adp_bry Hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_int("a" , Id__a)
|
||||
.Add_str_int("h2" , Id__h2)
|
||||
.Add_str_int("h3" , Id__h3)
|
||||
.Add_str_int("h4" , Id__h4)
|
||||
.Add_str_int("h5" , Id__h5)
|
||||
.Add_str_int("h6" , Id__h6)
|
||||
.Add_str_int("span" , Id__span)
|
||||
.Add_str_int("div" , Id__div)
|
||||
;
|
||||
}
|
||||
|
||||
35
400_xowa/src/gplx/langs/htmls/parsers/Html_atr.java
Normal file
35
400_xowa/src/gplx/langs/htmls/parsers/Html_atr.java
Normal file
@@ -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.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public class Html_atr {
|
||||
private final byte[] src;
|
||||
public Html_atr(int idx, byte[] key, byte[] val, byte[] src, int val_bgn, int val_end) {
|
||||
this.idx = idx; this.key = key; this.val = val;
|
||||
this.src = src; this.val_bgn = val_bgn; this.val_end = val_end;
|
||||
}
|
||||
public int Idx() {return idx;} private final int idx;
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public int Val_bgn() {return val_bgn;} private final int val_bgn;
|
||||
public int Val_end() {return val_end;} private final int val_end;
|
||||
public byte[] Val() {
|
||||
if (val == null)
|
||||
val = Bry_.Mid(src, val_bgn, val_end);
|
||||
return val;
|
||||
} private byte[] val;
|
||||
public static final Html_atr Noop = new Html_atr(-1, Bry_.Empty, Bry_.Empty, Bry_.Empty, 0, 0);
|
||||
}
|
||||
60
400_xowa/src/gplx/langs/htmls/parsers/Html_doc_parser.java
Normal file
60
400_xowa/src/gplx/langs/htmls/parsers/Html_doc_parser.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Html_doc_parser {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private Html_txt_wkr txt_wkr;
|
||||
public Html_doc_parser Reg_txt(Html_txt_wkr txt_wkr) {
|
||||
this.txt_wkr = txt_wkr;
|
||||
return this;
|
||||
}
|
||||
public void Reg(Html_doc_wkr... wkr_ary) {
|
||||
for (Html_doc_wkr wkr : wkr_ary) {
|
||||
trie.Add_obj(wkr.Hook(), wkr);
|
||||
list.Add(wkr);
|
||||
}
|
||||
}
|
||||
public void Parse(byte[] src, int src_bgn, int src_end) {
|
||||
txt_wkr.Init(src, src_bgn, src_end);
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Html_doc_wkr wkr = (Html_doc_wkr)list.Get_at(i);
|
||||
wkr.Init(src, src_bgn, src_end);
|
||||
}
|
||||
int pos = src_bgn;
|
||||
int txt_bgn = -1;
|
||||
while (pos < src_end) {
|
||||
Object o = trie.Match_bgn(src, pos, src_end);
|
||||
if (o == null) {
|
||||
if (txt_bgn == -1) txt_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
else {
|
||||
if (txt_bgn != -1) {
|
||||
txt_wkr.Parse(txt_bgn, pos);
|
||||
txt_bgn = -1;
|
||||
}
|
||||
Html_doc_wkr wkr = (Html_doc_wkr)o;
|
||||
pos = wkr.Parse(pos);
|
||||
}
|
||||
}
|
||||
if (txt_bgn != -1) txt_wkr.Parse(txt_bgn, src_end);
|
||||
}
|
||||
}
|
||||
23
400_xowa/src/gplx/langs/htmls/parsers/Html_doc_wkr.java
Normal file
23
400_xowa/src/gplx/langs/htmls/parsers/Html_doc_wkr.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public interface Html_doc_wkr {
|
||||
byte[] Hook();
|
||||
void Init(byte[] src, int src_bgn, int src_end);
|
||||
int Parse(int pos);
|
||||
}
|
||||
96
400_xowa/src/gplx/langs/htmls/parsers/Html_tag.java
Normal file
96
400_xowa/src/gplx/langs/htmls/parsers/Html_tag.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
import gplx.xowa.parsers.htmls.*;
|
||||
public class Html_tag implements Mwh_atr_wkr {
|
||||
private Html_tag_rdr rdr;
|
||||
private Ordered_hash atrs_hash; private boolean atrs_null; private int atrs_bgn, atrs_end;
|
||||
public Html_tag Init(Html_tag_rdr rdr, boolean tag_is_tail, boolean tag_is_inline, int src_bgn, int src_end, int atrs_bgn, int atrs_end, int name_id) {
|
||||
this.rdr = rdr; this.atrs_null = true;
|
||||
this.tag_is_tail = tag_is_tail; this.tag_is_inline = tag_is_inline;
|
||||
this.atrs_bgn = atrs_bgn; this.atrs_end = atrs_end;
|
||||
this.name_id = name_id; this.src_bgn = src_bgn; this.src_end = src_end;
|
||||
return this;
|
||||
}
|
||||
public Html_tag Copy() {
|
||||
Html_tag rv = new Html_tag().Init(rdr, tag_is_tail, tag_is_inline, src_bgn, src_end, atrs_bgn, atrs_end, name_id);
|
||||
rv.atrs_null = false;
|
||||
rv.atrs_hash = Copy(atrs_hash);
|
||||
return rv;
|
||||
}
|
||||
public int Name_id() {return name_id;} private int name_id;
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public boolean Tag_is_tail() {return tag_is_tail;} private boolean tag_is_tail;
|
||||
public boolean Tag_is_inline() {return tag_is_inline;} private boolean tag_is_inline;
|
||||
public boolean Atrs__match_pair(byte[] key, byte[] val) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key);
|
||||
return rv == null ? false : Bry_.Eq(val, rv.Val());
|
||||
}
|
||||
public byte[] Atrs__get_as_bry(byte[] key) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key);
|
||||
return rv == null ? Bry_.Empty : rv.Val();
|
||||
}
|
||||
public Html_atr Atrs__get_by(byte[] key) {
|
||||
if (atrs_null) Atrs__make();
|
||||
Html_atr rv = (Html_atr)atrs_hash.Get_by(key);
|
||||
return rv == null ? Html_atr.Noop : rv;
|
||||
}
|
||||
public String Atrs__print() {
|
||||
if (atrs_null) Atrs__make();
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
int len = atrs_hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Html_atr atr = (Html_atr)atrs_hash.Get_at(i);
|
||||
bfr.Add(atr.Key()).Add_byte_eq().Add(atr.Val()).Add_byte_nl();
|
||||
}
|
||||
return bfr.To_str();
|
||||
}
|
||||
private void Atrs__make() {
|
||||
atrs_null = false;
|
||||
if (atrs_hash == null) atrs_hash = Ordered_hash_.New_bry();
|
||||
else atrs_hash.Clear();
|
||||
rdr.Atrs__make(this, atrs_bgn, atrs_end);
|
||||
}
|
||||
public void On_atr_each (Mwh_atr_parser mgr, byte[] src, int nde_tid, boolean valid, boolean repeated, boolean key_exists, byte[] key_bry, byte[] val_bry_manual, int[] itm_ary, int itm_idx) {
|
||||
if (!valid) return;
|
||||
byte[] val_bry = val_bry_manual;
|
||||
int val_bgn = -1, val_end = -1;
|
||||
if (key_exists) {
|
||||
if (val_bry == null) {
|
||||
val_bgn = itm_ary[itm_idx + Mwh_atr_mgr.Idx_val_bgn];
|
||||
val_end = itm_ary[itm_idx + Mwh_atr_mgr.Idx_val_end];
|
||||
}
|
||||
}
|
||||
else
|
||||
val_bry_manual = key_bry;
|
||||
Html_atr atr = new Html_atr(atrs_hash.Count(), key_bry, val_bry_manual, src, val_bgn, val_end);
|
||||
atrs_hash.Add(key_bry, atr);
|
||||
}
|
||||
private static Ordered_hash Copy(Ordered_hash src) {
|
||||
Ordered_hash rv = Ordered_hash_.New();
|
||||
int len = src.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Html_atr atr = (Html_atr)src.Get_at(i);
|
||||
rv.Add(atr.Key(), atr);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
195
400_xowa/src/gplx/langs/htmls/parsers/Html_tag_rdr.java
Normal file
195
400_xowa/src/gplx/langs/htmls/parsers/Html_tag_rdr.java
Normal file
@@ -0,0 +1,195 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.parsers.htmls.*;
|
||||
public class Html_tag_rdr {
|
||||
private final Hash_adp_bry name_hash = Html_tag_.Hash;
|
||||
private final Mwh_atr_parser atr_parser = new Mwh_atr_parser();
|
||||
private final Html_tag tag__tmp = new Html_tag(), tag__eos = new Html_tag(), tag__comment = new Html_tag();
|
||||
private final Int_obj_ref tmp_depth = Int_obj_ref.zero_();
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public void Init(byte[] src, int src_bgn, int src_end) {
|
||||
this.src = src; this.pos = src_bgn; this.src_end = src_end;
|
||||
tag__eos.Init(this, Bool_.N, Bool_.N, src_end, src_end, src_end, src_end, Html_tag_.Id__eos);
|
||||
}
|
||||
public int Pos() {return pos;} private int pos;
|
||||
public void Pos_(int v) {this.pos = v;}
|
||||
public void Atrs__make(Mwh_atr_wkr atr_wkr, int head_bgn, int head_end) {atr_parser.Parse(atr_wkr, -1, -1, src, head_bgn, head_end);}
|
||||
public Html_tag Tag__move_fwd_head() {return Tag__find(Bool_.Y, Bool_.N, Bool_.N, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__move_fwd_head(int match_name_id) {return Tag__find(Bool_.Y, Bool_.N, Bool_.N, match_name_id);}
|
||||
public Html_tag Tag__move_fwd_tail(int match_name_id) {return Tag__find(Bool_.Y, Bool_.N, Bool_.Y, match_name_id);}
|
||||
public Html_tag Tag__peek_fwd_head() {return Tag__find(Bool_.N, Bool_.N, Bool_.N, Html_tag_.Id__any);}
|
||||
public Html_tag Tag__peek_fwd_head(int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.N, match_name_id);}
|
||||
public Html_tag Tag__peek_fwd_tail(int match_name_id) {return Tag__find(Bool_.N, Bool_.N, Bool_.Y, match_name_id);}
|
||||
public Html_tag Tag__peek_bwd_tail(int match_name_id) {return Tag__find(Bool_.N, Bool_.Y, Bool_.Y, match_name_id);}
|
||||
public Html_tag Tag__peek_bwd_head() {return Tag__find(Bool_.N, Bool_.Y, Bool_.Y, Html_tag_.Id__any);}
|
||||
private Html_tag Tag__find(boolean move, boolean bwd, boolean tail, int match_name_id) {
|
||||
int tmp = pos;
|
||||
int stop_pos = src_end; int adj = 1;
|
||||
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_();
|
||||
Html_tag rv = null;
|
||||
while (tmp != stop_pos) {
|
||||
if (src[tmp] == Byte_ascii.Angle_bgn) {
|
||||
rv = Tag__extract(tail, match_name_id, tmp);
|
||||
if (Tag__match(bwd, tail, match_name_id, tmp_depth, rv))
|
||||
break;
|
||||
else {
|
||||
tmp = bwd ? rv.Src_bgn() - 1 : rv.Src_end();
|
||||
rv = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
tmp += adj;
|
||||
}
|
||||
if (rv == null) rv = tag__eos;
|
||||
if (move) pos = rv.Src_end();
|
||||
return rv;
|
||||
}
|
||||
private boolean Tag__match(boolean bwd, boolean tail, int match_name_id, Int_obj_ref depth_obj, Html_tag tag) {
|
||||
int tag_name_id = tag.Name_id();
|
||||
if ( tag_name_id != match_name_id // tag doesn't match requested
|
||||
&& match_name_id != Html_tag_.Id__any // requested is not wildcard
|
||||
) return false;
|
||||
if (tag_name_id == Html_tag_.Id__comment) {
|
||||
if (match_name_id == Html_tag_.Id__comment)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int depth = depth_obj.Val();
|
||||
boolean tag_is_tail = tag.Tag_is_tail();
|
||||
if (tail == tag_is_tail) {
|
||||
if (depth == 0)
|
||||
return true;
|
||||
else {
|
||||
depth_obj.Val_add(-1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!bwd && tail && !tag_is_tail) {
|
||||
depth_obj.Val_add(1);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private Html_tag Tag__extract(boolean tail, int match_name_id, int tag_bgn) {
|
||||
int name_bgn = tag_bgn + 1; if (name_bgn == src_end) return tag__eos; // EX: "<EOS"
|
||||
byte name_0 = src[name_bgn];
|
||||
boolean cur_is_tail = false;
|
||||
switch (name_0) {
|
||||
case Byte_ascii.Bang: return Tag__comment(tag_bgn); // skip comment; EX: "<!"
|
||||
case Byte_ascii.Slash:
|
||||
++name_bgn; if (name_bgn == src_end) return tag__eos; // EX: "</EOS"
|
||||
name_0 = src[name_bgn];
|
||||
cur_is_tail = true;
|
||||
break;
|
||||
}
|
||||
if (name_0 == Byte_ascii.Bang) return Tag__comment(tag_bgn); // skip comment; EX: "<!"
|
||||
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; // EX: "<a/EOS"
|
||||
if (src[tag_end] == Byte_ascii.Angle_end) {
|
||||
atrs_end = name_end;
|
||||
inline = true;
|
||||
loop = false;
|
||||
}
|
||||
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; // 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;
|
||||
atrs_end = tag_end;
|
||||
++tag_end; // position after ">"
|
||||
}
|
||||
return tag__tmp.Init(this, cur_is_tail, inline, tag_bgn, tag_end, name_end, atrs_end, name_hash.Get_as_int_or(src, name_bgn, name_end, -1));
|
||||
}
|
||||
public boolean Read_and_move(byte match) {
|
||||
byte b = src[pos];
|
||||
if (b == match) {
|
||||
++pos;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public int Read_int_to(byte to_char, int or_int) {
|
||||
int bgn = pos;
|
||||
int rv = 0;
|
||||
int negative = 1;
|
||||
while (pos < src_end) {
|
||||
byte b = src[pos++];
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_0: case Byte_ascii.Num_1: case Byte_ascii.Num_2: case Byte_ascii.Num_3: case Byte_ascii.Num_4:
|
||||
case Byte_ascii.Num_5: case Byte_ascii.Num_6: case Byte_ascii.Num_7: case Byte_ascii.Num_8: case Byte_ascii.Num_9:
|
||||
rv = (rv * 10) + (b - Byte_ascii.Num_0);
|
||||
break;
|
||||
case Byte_ascii.Dash:
|
||||
if (negative == -1) // 2nd negative
|
||||
return or_int; // return or_int
|
||||
else // 1st negative
|
||||
negative = -1; // flag negative
|
||||
break;
|
||||
default: {
|
||||
boolean match = b == to_char;
|
||||
if (to_char == Byte_ascii.Null) {// hack for Read_int_to_non_num
|
||||
--pos;
|
||||
match = true;
|
||||
}
|
||||
return match ? rv * negative : or_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
return bgn == pos ? or_int : rv * negative;
|
||||
}
|
||||
private Html_tag Tag__comment(int tag_bgn) {
|
||||
int tag_end = Bry_find_.Move_fwd(src, gplx.langs.htmls.Html_tag_.Comm_end, tag_bgn, src_end); if (tag_end == Bry_find_.Not_found) tag_end = src_end;
|
||||
return tag__comment.Init(this, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__comment);
|
||||
}
|
||||
}
|
||||
68
400_xowa/src/gplx/langs/htmls/parsers/Html_tag_rdr_tst.java
Normal file
68
400_xowa/src/gplx/langs/htmls/parsers/Html_tag_rdr_tst.java
Normal file
@@ -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.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
import org.junit.*;
|
||||
public class Html_tag_rdr_tst {
|
||||
private final Html_tag_rdr_fxt fxt = new Html_tag_rdr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init("1<div id='1'>2</div>3<div id='2'>4</div>5<div id='3'>6</div>7");
|
||||
fxt.Test__move_fwd_head("<div id='1'>"); fxt.Test__pos("2");
|
||||
fxt.Test__peek_fwd_head("<div id='2'>"); fxt.Test__pos("2");
|
||||
fxt.Test__move_fwd_head("<div id='2'>"); fxt.Test__pos("4");
|
||||
fxt.Test__peek_bwd_tail("</div>3") ; fxt.Test__pos("4");
|
||||
}
|
||||
@Test public void Comment() {
|
||||
fxt.Init("1<!--2-->3<!--4-->5<div id='1'>6</div>");
|
||||
fxt.Test__move_fwd_head(Html_tag_.Id__comment , "<!--2-->") ; fxt.Test__pos("3");
|
||||
fxt.Test__move_fwd_head(Html_tag_.Id__any , "<div id='1'>") ; fxt.Test__pos("6");
|
||||
}
|
||||
@Test public void Recursive() {
|
||||
fxt.Init("1<a>2<a>3</a>4</a>5");
|
||||
fxt.Test__move_fwd_head(Html_tag_.Id__a , "<a>") ; fxt.Test__pos("2");
|
||||
fxt.Test__move_fwd_tail(Html_tag_.Id__a , "</a>") ; fxt.Test__pos("5");
|
||||
}
|
||||
}
|
||||
class Html_tag_rdr_fxt {
|
||||
private final Html_tag_rdr rdr = new Html_tag_rdr();
|
||||
public void Init(String src_str) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
rdr.Init(src_bry, 0, src_bry.length);
|
||||
}
|
||||
public void Test__move_fwd_head(String expd) {Test__move_fwd_head(Html_tag_.Id__any, expd);}
|
||||
public void Test__move_fwd_head(int match_name_id, String expd) {
|
||||
Html_tag actl_tag = rdr.Tag__move_fwd_head(match_name_id);
|
||||
Tfds.Eq_str(expd, String_.new_u8(rdr.Src(), actl_tag.Src_bgn(), actl_tag.Src_end()));
|
||||
}
|
||||
public void Test__move_fwd_tail(int match_name_id, String expd) {
|
||||
Html_tag actl_tag = rdr.Tag__move_fwd_tail(match_name_id);
|
||||
Tfds.Eq_str(expd, String_.new_u8(rdr.Src(), actl_tag.Src_bgn(), actl_tag.Src_end()));
|
||||
}
|
||||
public void Test__peek_fwd_head(String expd) {
|
||||
Html_tag actl_tag = rdr.Tag__peek_fwd_head();
|
||||
Tfds.Eq_str(expd, String_.new_u8(rdr.Src(), actl_tag.Src_bgn(), actl_tag.Src_end()));
|
||||
}
|
||||
public void Test__peek_bwd_tail(String expd_str) {
|
||||
byte[] expd_bry = Bry_.new_u8(expd_str);
|
||||
Html_tag actl_tag = rdr.Tag__peek_bwd_tail(-1);
|
||||
Tfds.Eq_bry(expd_bry, Bry_.Mid(rdr.Src(), actl_tag.Src_bgn(), actl_tag.Src_bgn() + expd_bry.length));
|
||||
}
|
||||
public void Test__pos(String expd_str) {
|
||||
byte[] expd_bry = Bry_.new_u8(expd_str);
|
||||
Tfds.Eq_bry(expd_bry, Bry_.Mid(rdr.Src(), rdr.Pos(), rdr.Pos() + expd_bry.length));
|
||||
}
|
||||
}
|
||||
22
400_xowa/src/gplx/langs/htmls/parsers/Html_txt_wkr.java
Normal file
22
400_xowa/src/gplx/langs/htmls/parsers/Html_txt_wkr.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.htmls.parsers; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
|
||||
public interface Html_txt_wkr {
|
||||
void Parse(int rng_bgn, int rng_end);
|
||||
void Init(byte[] src, int src_bgn, int src_end);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class Json_itm_str extends Json_itm_base {
|
||||
case Byte_ascii.Ltr_b: bfr.Add_byte(Byte_ascii.Backfeed); break;
|
||||
case Byte_ascii.Ltr_f: bfr.Add_byte(Byte_ascii.Formfeed); break;
|
||||
case Byte_ascii.Ltr_u:
|
||||
int utf8_val = gplx.texts.HexDecUtl.parse_or(src, i + 1, i + 5, -1);
|
||||
int utf8_val = gplx.core.texts.HexDecUtl.parse_or(src, i + 1, i + 5, -1);
|
||||
int len = gplx.core.intls.Utf16_.Encode_int(utf8_val, utf8_bry, 0);
|
||||
bfr.Add_mid(utf8_bry, 0, len);
|
||||
i += 4;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Json_itm_tmp implements Json_itm { // TEST:
|
||||
public int Src_bgn() {return -1;}
|
||||
public int Src_end() {return -1;}
|
||||
public Object Data() {return data;} private String data;
|
||||
public void Print_as_json(Bry_bfr bfr, int depth) {bfr.Add_str(data);}
|
||||
public void Print_as_json(Bry_bfr bfr, int depth) {bfr.Add_str_u8(data);}
|
||||
public boolean Data_eq(byte[] comp) {return false;}
|
||||
public void Clear() {}
|
||||
public static Json_itm new_str_(String v) {return new Json_itm_tmp(Json_itm_.Tid__str, "\"" + v + "\"");}
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.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:
|
||||
- all lines are assignment lines: EX: $a = b;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.core.btries.*; import gplx.core.log_msgs.*;
|
||||
interface Php_lxr {
|
||||
int Lxr_tid();
|
||||
void Lxr_ini(Btrie_slim_mgr trie, Php_parser_interrupt[] parser_interrupts);
|
||||
@@ -117,7 +117,7 @@ class Php_lxr_comment extends Php_lxr_base {
|
||||
public byte[] Comment_end() {return comment_end;} private byte[] comment_end;
|
||||
@Override public int Lxr_make(Php_ctx ctx, int bgn, int cur) {
|
||||
int end = Bry_find_.Find_fwd(src, comment_end, bgn);
|
||||
if (end == Bry_.NotFound) {
|
||||
if (end == Bry_find_.Not_found) {
|
||||
tkn_wkr.Msg_many(src, bgn, cur, Php_lxr_comment.Dangling_comment, comment_tid, comment_end);
|
||||
cur = src_len; // NOTE: terminating sequence not found; assume rest of src is comment
|
||||
}
|
||||
@@ -198,7 +198,7 @@ class Php_lxr_quote extends Php_lxr_base {
|
||||
int end = -1;
|
||||
while (true) {
|
||||
end = Bry_find_.Find_fwd(src, quote_bry, cur);
|
||||
if (end == Bry_.NotFound) {
|
||||
if (end == Bry_find_.Not_found) {
|
||||
tkn_wkr.Msg_many(src, bgn, cur, Php_lxr_quote.Dangling_quote, quote_tid, quote_bry);
|
||||
cur = src_len; // NOTE: terminating sequence not found; assume rest of src is comment
|
||||
break;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.core.btries.*; import gplx.core.log_msgs.*;
|
||||
public class Php_parser {
|
||||
Php_lxr[] lxrs; int lxrs_len;
|
||||
int txt_bgn; Php_tkn_txt txt_tkn;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
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();}
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract class Php_srl_itm_base implements Php_srl_itm {
|
||||
@gplx.Virtual public void Xto_bfr(Bry_bfr bfr, int depth) {
|
||||
Php_srl_wtr.Indent(bfr, depth);
|
||||
bfr.Add(Php_srl_itm_.Names[this.Tid()]).Add_byte(Byte_ascii.Colon);
|
||||
bfr.Add_str(Object_.Xto_str_strict_or_null_mark(this.Val())).Add_byte(Byte_ascii.Semic).Add_byte_nl();
|
||||
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(this.Val())).Add_byte(Byte_ascii.Semic).Add_byte_nl();
|
||||
}
|
||||
public void Clear() {}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import gplx.texts.*;
|
||||
import gplx.core.texts.*;
|
||||
public class Php_srl_parser {
|
||||
@gplx.Internal protected Php_srl_factory Factory() {return factory;} Php_srl_factory factory = new Php_srl_factory();
|
||||
byte[] raw; int raw_len, pos;
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.langs.phps; import gplx.*; import gplx.langs.*;
|
||||
import gplx.core.log_msgs.*;
|
||||
public interface Php_tkn_wkr {
|
||||
void Init(Php_ctx ctx);
|
||||
void Process(Php_tkn tkn);
|
||||
|
||||
@@ -16,13 +16,13 @@ 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.ios.*; import gplx.core.net.*;
|
||||
import gplx.core.ios.*; import gplx.core.net.*;
|
||||
import gplx.langs.jsons.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.metas.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.js.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.js.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.bldrs.wms.*;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*; import gplx.core.log_msgs.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.guis.views.boots.*;
|
||||
import gplx.xowa.apps.boots.*; import gplx.xowa.apps.gfs.*;
|
||||
@@ -28,13 +28,13 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args, arg_mgr);
|
||||
} catch (Error e) {
|
||||
if (arg_mgr.App_type().Tid_is_gui())
|
||||
Xog_error_win.Run(Err_.Message_lang_error(e), Err_.Trace_lang(e));
|
||||
Xog_error_win.Run(Err_.Message_lang(e), Err_.Trace_lang(e));
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.10.3.1";
|
||||
public static final String Version = "2.11.1.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_app_fxt {
|
||||
@@ -28,16 +28,39 @@ public class Xoa_app_fxt {
|
||||
Db_conn_bldr.Instance.Reg_default_mem();
|
||||
return app_("linux", Io_url_.mem_dir_("mem/xowa/"));
|
||||
}
|
||||
public static Xoav_app Make__app__view() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Db_conn_bldr.Instance.Reg_default_mem();
|
||||
return Make__app__view("linux", Io_url_.mem_dir_("mem/xowa/"));
|
||||
}
|
||||
public static Xoav_app Make__app__view(String op_sys, Io_url root_dir) {
|
||||
Io_url user_dir = root_dir.GenSubDir_nest("user", "test_user");
|
||||
Gfo_usr_dlg__log_base.Instance.Log_dir_(user_dir.GenSubDir_nest("tmp", "current"));
|
||||
Xoav_app rv = new Xoav_app(Gfo_usr_dlg_.Test(), Xoa_app_mode.Itm_gui, op_sys, root_dir, root_dir.GenSubDir("file"), root_dir.GenSubDir("css"));
|
||||
return rv;
|
||||
}
|
||||
public static Xoae_app app_(String op_sys, Io_url root_dir) {
|
||||
Io_url user_dir = root_dir.GenSubDir_nest("user", "test_user");
|
||||
Gfo_usr_dlg__log_base.Instance.Log_dir_(user_dir.GenSubDir_nest("tmp", "current"));
|
||||
Xoae_app app = new Xoae_app(Gfo_usr_dlg_.Test(), Xoa_app_mode.Itm_cmd, root_dir, root_dir.GenSubDir("wiki"), root_dir.GenSubDir("file"), user_dir, root_dir.GenSubDir_nest("user", "anonymous", "wiki"), op_sys);
|
||||
app.Setup_mgr().Dump_mgr().Data_storage_format_(gplx.ios.Io_stream_.Tid_raw); // TEST: set data_storage_format to file, else bldr tests will fails (expects plain text)
|
||||
app.Setup_mgr().Dump_mgr().Data_storage_format_(gplx.core.ios.Io_stream_.Tid_raw); // TEST: set data_storage_format to file, else bldr tests will fails (expects plain text)
|
||||
GfsCore.Instance.Clear(); // NOTE: must clear
|
||||
GfsCore.Instance.AddCmd(app, Xoae_app.Invk_app); // NOTE: must add app to GfsCore; app.Gfs_mgr() always adds current app to GfsCore; note this causes old test to leave behind GfsCore for new test
|
||||
GfsCore.Instance.AddCmd(app, Xoae_app.Invk_xowa); // add alias for app; DATE:2014-06-09
|
||||
return app;
|
||||
}
|
||||
public static Xowv_wiki Make__wiki__view(Xoa_app app) {return Make__wiki__view(app, "en.wikipedia.org");}
|
||||
public static Xowv_wiki Make__wiki__view(Xoa_app app, String domain_str) {
|
||||
byte[] domain_bry = Bry_.new_u8(domain_str);
|
||||
Io_url wiki_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(domain_str);
|
||||
Xowv_wiki rv = new Xowv_wiki((Xoav_app)app, domain_bry, wiki_dir);
|
||||
((Xoav_wiki_mgr)app.Wiki_mgri()).Add(rv);
|
||||
return rv;
|
||||
}
|
||||
// public static Xow_wiki Make__wiki__view(Xoa_app app, String domain_str) {
|
||||
// byte[] domain_bry = Bry_.new_u8(domain_str);
|
||||
// return app.Wiki_mgri().Get_by_key_or_make_init_y(domain_bry);
|
||||
// }
|
||||
public static Xowe_wiki wiki_nonwmf(Xoae_app app, String key) {
|
||||
Xol_lang_itm lang = new Xol_lang_itm(app.Lang_mgr(), Xol_lang_itm_.Key_en).Kwd_mgr__strx_(true);
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
|
||||
@@ -28,6 +28,11 @@ public class Xoa_test_ {
|
||||
wiki.Db_mgr_create_as_sql();
|
||||
wiki.Data__core_mgr().Init_by_make(Xowd_core_db_props.Test, Xob_info_session.Test);
|
||||
}
|
||||
public static void Init__db__mem(gplx.xowa.wikis.Xowv_wiki wiki) {
|
||||
Db__init__mem();
|
||||
wiki.Init_by_make(Xowd_core_db_props.Test, Xob_info_session.Test);
|
||||
// wiki.Data__core_mgr().Init_by_make(Xowd_core_db_props.Test, Xob_info_session.Test);
|
||||
}
|
||||
public static void Db__init__mem() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Db_conn_bldr.Instance.Reg_default_mem();
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*;
|
||||
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.*;
|
||||
@@ -88,7 +88,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
public byte[] Page_txt_wo_qargs() { // assume that no Special page has non-ascii characters
|
||||
int full_txt_len = full_txt.length;
|
||||
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_.NotFound ? full_txt_len : ques_pos);
|
||||
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);
|
||||
@@ -235,7 +235,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
break;
|
||||
case Xop_amp_trie_itm.Char_int_null: // &#xx;
|
||||
int end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Semic, match_pos, end);
|
||||
if (end_pos == Bry_.NotFound) {} // &# but no terminating ";" noop: defaults to current_byte which will be added below;
|
||||
if (end_pos == Bry_find_.Not_found) {} // &# but no terminating ";" noop: defaults to current_byte which will be added below;
|
||||
else {
|
||||
b_ary = amp_itm.Xml_name_bry();
|
||||
match_pos = end_pos + 1;
|
||||
@@ -340,7 +340,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
|
||||
return false;
|
||||
}
|
||||
full_txt = bfr.To_bry_and_clear();
|
||||
if ( ns.Case_match() == Xow_ns_case_.Id_1st
|
||||
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
|
||||
byte char_1st = full_txt[page_bgn];
|
||||
int char_1st_len = gplx.core.intls.Utf8_.Len_of_char_by_1st_byte(char_1st);
|
||||
|
||||
@@ -48,14 +48,14 @@ public class Xoa_url {
|
||||
public byte[] Page_for_lnki() {
|
||||
int raw_len = raw.length;
|
||||
int page_bgn = Page_bgn(raw_len);
|
||||
if (page_bgn == Bry_.NotFound) // no /wiki/ found; return page
|
||||
if (page_bgn == Bry_find_.Not_found) // no /wiki/ found; return page
|
||||
return page_bry == null ? Bry_.Empty : page_bry; // guard against null ref
|
||||
else
|
||||
return Bry_.Mid(raw, page_bgn, raw_len);// else take everything after "/wiki/";
|
||||
}
|
||||
private int Page_bgn(int raw_len) {
|
||||
int wiki_pos = Bry_find_.Find_fwd(raw, Xoh_href_.Bry__wiki, 0, raw_len); // look for /wiki/
|
||||
return wiki_pos == Bry_.NotFound ? Bry_.NotFound : wiki_pos + Xoh_href_.Bry__wiki.length;
|
||||
return wiki_pos == Bry_find_.Not_found ? Bry_find_.Not_found : wiki_pos + Xoh_href_.Bry__wiki.length;
|
||||
}
|
||||
public boolean Eq_page(Xoa_url comp) {return Bry_.Eq(wiki_bry, comp.wiki_bry) && Bry_.Eq(page_bry, comp.page_bry) && this.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes) == comp.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes);}
|
||||
public String To_str() {return String_.new_u8(To_bry(Bool_.Y, Bool_.Y));}
|
||||
|
||||
@@ -16,13 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.metas.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.progs.*; import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.apps.cfgs.old.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.guis.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.apps.fmtrs.*; import gplx.xowa.htmls.*; import gplx.xowa.wikis.xwikis.sitelinks.*; import gplx.xowa.wikis.xwikis.parsers.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.xndes.*;
|
||||
import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.math.*;
|
||||
import gplx.xowa.parsers.utils.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.apps.servers.tcp.*; import gplx.xowa.apps.servers.http.*;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.xowa.htmls.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.htmls.tocs.*;
|
||||
import gplx.xowa.htmls.modules.popups.*; import gplx.xowa.htmls.hdumps.pages.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
import gplx.xowa.htmls.modules.popups.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Xoae_page implements Xoa_page {
|
||||
Xoae_page(Xowe_wiki wiki, Xoa_ttl ttl) {
|
||||
@@ -40,7 +40,7 @@ public class Xoae_page implements Xoa_page {
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xowe_wiki Wikie() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xopg_redlink_lnki_list Redlink_lnki_list() {return redlink_lnki_list;} private Xopg_redlink_lnki_list redlink_lnki_list;
|
||||
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 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_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
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();
|
||||
|
||||
@@ -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; import gplx.*;
|
||||
import gplx.core.tests.*;
|
||||
import gplx.core.tests.*; import gplx.core.log_msgs.*;
|
||||
import gplx.xowa.apps.cfgs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.files.exts.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
@@ -103,7 +104,7 @@ public class Xop_fxt {
|
||||
public Xop_tblw_td_tkn_chkr tkn_tblw_td_(int bgn, int end) {return (Xop_tblw_td_tkn_chkr)new Xop_tblw_td_tkn_chkr().Src_rng_(bgn, end);}
|
||||
public Xop_tblw_th_tkn_chkr tkn_tblw_th_(int bgn, int end) {return (Xop_tblw_th_tkn_chkr)new Xop_tblw_th_tkn_chkr().Src_rng_(bgn, end);}
|
||||
public Xop_tblw_tr_tkn_chkr tkn_tblw_tr_(int bgn, int end) {return (Xop_tblw_tr_tkn_chkr)new Xop_tblw_tr_tkn_chkr().Src_rng_(bgn, end);}
|
||||
public Xop_hdr_tkn_chkr tkn_hdr_(int bgn, int end, int hdr_len) {return (Xop_hdr_tkn_chkr)new Xop_hdr_tkn_chkr().Hdr_len_(hdr_len).Src_rng_(bgn, end);}
|
||||
public Xop_hdr_tkn_chkr tkn_hdr_(int bgn, int end, int hdr_len) {return (Xop_hdr_tkn_chkr)new Xop_hdr_tkn_chkr().Hdr_level_(hdr_len).Src_rng_(bgn, end);}
|
||||
public Xop_xnde_tkn_chkr tkn_xnde_br_(int pos) {return tkn_xnde_(pos, pos).Xnde_tagId_(Xop_xnde_tag_.Tid_br);}
|
||||
public Xop_xnde_tkn_chkr tkn_xnde_() {return tkn_xnde_(String_.Pos_neg1, String_.Pos_neg1);}
|
||||
public Xop_xnde_tkn_chkr tkn_xnde_(int bgn, int end) {return (Xop_xnde_tkn_chkr)new Xop_xnde_tkn_chkr().Src_rng_(bgn, end);}
|
||||
@@ -165,7 +166,7 @@ public class Xop_fxt {
|
||||
public Xop_fxt Init_para_y_() {ctx.Para().Enabled_y_(); return this;}
|
||||
public Xop_fxt Init_para_n_() {ctx.Para().Enabled_n_(); return this;}
|
||||
public Xop_fxt Init_log_(Gfo_msg_itm... itms) {for (Gfo_msg_itm itm : itms) log_itms.Add(itm); return this;} List_adp log_itms = List_adp_.new_();
|
||||
public void Init_defn_add(String name, String text) {Init_defn_add(name, text, Xow_ns_case_.Id_all);}
|
||||
public void Init_defn_add(String name, String text) {Init_defn_add(name, text, Xow_ns_case_.Tid__all);}
|
||||
public void Init_defn_add(String name, String text, byte case_match) {
|
||||
Xot_defn_tmpl itm = run_Parse_tmpl(Bry_.new_a7(name), Bry_.new_u8(text));
|
||||
wiki.Cache_mgr().Defn_cache().Add(itm, case_match);
|
||||
@@ -419,4 +420,15 @@ public class Xop_fxt {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
return new Xop_fxt(app, Xoa_app_fxt.wiki_nonwmf(app, "nethackwiki"));
|
||||
}
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
public String Exec__parse_to_hdump(String src_str) {
|
||||
byte[] src_bry = Bry_.new_u8(src_str);
|
||||
Xop_root_tkn root = Exec_parse_page_all_as_root(src_bry);
|
||||
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.Cur_page().Redlink_lnki_list().Clear();
|
||||
html_wtr.Write_all(tmp_bfr, ctx, hctx, src_bry, root);
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.meta.*; import gplx.fsdb.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.hzips.*; import gplx.xowa.htmls.hdumps.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
public interface Xow_wiki extends Xow_ttl_parser, GfoInvkAble {
|
||||
@@ -41,8 +41,7 @@ public interface Xow_wiki extends Xow_ttl_parser, GfoInvkAble {
|
||||
Xof_bin_mgr File__bin_mgr();
|
||||
Fsm_mnt_mgr File__mnt_mgr();
|
||||
boolean Html__hdump_enabled();
|
||||
Xow_hzip_mgr Html__hzip_mgr();
|
||||
Xohd_hdump_rdr Html__hdump_rdr();
|
||||
Xow_hdump_mgr Html__hdump_mgr();
|
||||
Xoh_page_wtr_mgr Html__wtr_mgr();
|
||||
boolean Html__css_installing(); void Html__css_installing_(boolean v);
|
||||
Xow_mw_parser_mgr Mw_parser_mgr();
|
||||
|
||||
@@ -22,7 +22,7 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*;
|
||||
import gplx.xowa.users.*; import gplx.xowa.htmls.*; import gplx.xowa.users.history.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.*; import gplx.xowa.wikis.dbs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.hzips.*; import gplx.xowa.htmls.hdumps.*; import gplx.xowa.htmls.css.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.css.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.installs.*; import gplx.xowa.bldrs.setups.maints.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
@@ -37,9 +37,8 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
this.fsys_mgr = new Xow_fsys_mgr(wiki_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
|
||||
this.url__parser = new Xoa_url_parser(this);
|
||||
this.xwiki_mgr = new Xow_xwiki_mgr(this);
|
||||
this.html__hdump_mgr = new Xow_hdump_mgr(this);
|
||||
this.html_mgr = new Xow_html_mgr(this);
|
||||
this.html_mgr__hdump_rdr = new Xohd_hdump_rdr(app, this);
|
||||
this.html_mgr__hdump_wtr = new Xohd_hdump_wtr(app, this);
|
||||
|
||||
tdb_fsys_mgr = new Xotdb_fsys_mgr(wiki_dir, ns_mgr);
|
||||
redirect_mgr = new Xop_redirect_mgr(this);
|
||||
@@ -77,8 +76,9 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
}
|
||||
public GfoEvMgr EvMgr() {return ev_mgr;} private final GfoEvMgr 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(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.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 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;
|
||||
@@ -88,7 +88,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
public byte[] Domain_abrv() {return domain_abrv;} private final byte[] domain_abrv;
|
||||
public Xow_domain_itm Domain_itm() {return domain_itm;} private final Xow_domain_itm domain_itm;
|
||||
public Xow_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xow_fsys_mgr fsys_mgr;
|
||||
public Xowd_db_mgr Data__core_mgr() {return db_mgr.Tid() == Xodb_mgr_txt.Tid_txt ? null : this.Db_mgr_as_sql().Core_data_mgr();} // TEST:
|
||||
public Xowd_db_mgr Data__core_mgr() {if (db_mgr == null) return null; return db_mgr.Tid() == Xodb_mgr_txt.Tid_txt ? null : this.Db_mgr_as_sql().Core_data_mgr();} // TEST:
|
||||
public Xof_fsdb_mode File__fsdb_mode() {return file_mgr.Fsdb_mode();}
|
||||
public Fsdb_db_mgr File__fsdb_core() {return file_mgr.Db_core();}
|
||||
public Xow_repo_mgr File__repo_mgr() {return file_mgr.Repo_mgr();}
|
||||
@@ -96,8 +96,6 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
public Xof_bin_mgr File__bin_mgr() {return file_mgr.Fsdb_mgr().Bin_mgr();}
|
||||
public Fsm_mnt_mgr File__mnt_mgr() {return file_mgr.Fsdb_mgr().Mnt_mgr();}
|
||||
public boolean Html__hdump_enabled() {return html_mgr__hdump_enabled;} private boolean html_mgr__hdump_enabled = Bool_.N;
|
||||
public Xow_hzip_mgr Html__hzip_mgr() {return html_mgr.Hzip_mgr();}
|
||||
public Xohd_hdump_rdr Html__hdump_rdr() {return html_mgr__hdump_rdr;} private final Xohd_hdump_rdr html_mgr__hdump_rdr;
|
||||
public Xoh_page_wtr_mgr Html__wtr_mgr() {return html_mgr.Page_wtr_mgr();}
|
||||
public boolean Html__css_installing() {return html__css_installing;} public void Html__css_installing_(boolean v) {html__css_installing = v;} private boolean html__css_installing;
|
||||
public Xoa_url_parser Utl__url_parser() {return url__parser;} private final Xoa_url_parser url__parser;
|
||||
@@ -106,7 +104,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
public Xow_wiki_props Props() {return props;} private final Xow_wiki_props props = new Xow_wiki_props();
|
||||
public Xow_parser_mgr Parser_mgr() {return parser_mgr;} private final Xow_parser_mgr parser_mgr;
|
||||
|
||||
public Xohd_hdump_wtr Html__hdump_wtr() {return html_mgr__hdump_wtr;} private final Xohd_hdump_wtr html_mgr__hdump_wtr;
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public Xoae_app Appe() {return app;} private Xoae_app app;
|
||||
public Xow_gui_mgr Gui_mgr() {return gui_mgr;} private final Xow_gui_mgr gui_mgr = new Xow_gui_mgr();
|
||||
public Xow_user User() {return user;} private Xow_user user = new Xow_user();
|
||||
@@ -200,6 +198,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
app.Html__css_installer().Install(this, Xowd_css_core_mgr.Key_default);
|
||||
Html__hdump_enabled_(html_mgr__hdump_enabled);
|
||||
html_mgr.Init_by_wiki(this);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
this.Copy_cfg(app.Usere().Wiki());
|
||||
Xow_repo_mgr_.Assert_repos(app, this);
|
||||
xtn_mgr.Init_by_wiki(this);
|
||||
@@ -212,9 +211,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
private void Html__hdump_enabled_(boolean v) {
|
||||
this.html_mgr__hdump_enabled = v;
|
||||
if (html_mgr__hdump_enabled) {
|
||||
Xowd_html_tbl.Assert_col__page_html_db_id(Db_mgr_as_sql().Core_data_mgr()); // NOTE: must go above html_mgr.Init_by_wiki b/c Page_load will be done via messages
|
||||
html_mgr__hdump_rdr.Init_by_db(this.Data__core_mgr());
|
||||
html_mgr__hdump_wtr.Init_by_db(this.Data__core_mgr());
|
||||
Xowd_page_tbl.Assert_col__page_html_db_id(Db_mgr_as_sql().Core_data_mgr()); // NOTE: must go above html_mgr.Init_by_wiki b/c Page_load will be done via messages
|
||||
}
|
||||
}
|
||||
public void Rls() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xoa_sys_cfg implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_version)) return Xoa_app_.Version;
|
||||
else if (ctx.Match(k, Invk_build_date)) return Xoa_app_.Build_date;
|
||||
else if (ctx.Match(k, Invk_free_mem_when_)) free_mem_when = gplx.ios.Io_size_.parse_or(m.ReadStr("v"), Io_mgr.Len_mb * 5);
|
||||
else if (ctx.Match(k, Invk_free_mem_when_)) free_mem_when = gplx.core.ios.Io_size_.parse_or(m.ReadStr("v"), Io_mgr.Len_mb * 5);
|
||||
else if (ctx.Match(k, Invk_lang)) return lang_key;
|
||||
else if (ctx.Match(k, Invk_lang_)) Lang_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_lang_list)) return Options_lang_list();
|
||||
|
||||
@@ -16,13 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.net.*; import gplx.langs.jsons.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.net.*; import gplx.core.log_msgs.*; import gplx.langs.jsons.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.dbs.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.core.intls.*; import gplx.xowa.users.data.*;
|
||||
import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.urls.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.users.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.xowa.langs.*;
|
||||
|
||||
@@ -63,6 +63,7 @@ public class Xoav_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
hash.Add_if_dupe_use_nth(domain_bry, rv);
|
||||
return rv;
|
||||
}
|
||||
public void Add(Xow_wiki wiki) {hash.Add_if_dupe_use_nth(wiki.Domain_bry(), wiki);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_import_by_fil)) return Import_by_fil(Io_url_.new_fil_(m.ReadStr("v")));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xoapi_net implements GfoInvkAble, GfoEvObj {
|
||||
public boolean Enabled() {return enabled;} private boolean enabled = true;
|
||||
public void Enabled_(boolean v) {
|
||||
this.enabled = v;
|
||||
gplx.ios.IoEngine_system.Web_access_enabled = v;
|
||||
gplx.core.ios.IoEngine_system.Web_access_enabled = v;
|
||||
GfoEvMgr_.PubVal(this, gplx.xowa.guis.menus.dom.Xog_mnu_evt_mgr.Evt_selected_changed, v);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.bldrs.filters.dansguardians; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*; import gplx.xowa.apps.apis.xowa.bldrs.filters.*;
|
||||
import gplx.ios.*; import gplx.xowa.bldrs.filters.dansguardians.*;
|
||||
import gplx.core.ios.*; import gplx.xowa.bldrs.filters.dansguardians.*;
|
||||
public class Xoapi_dansguardian implements GfoInvkAble {
|
||||
public void Ctor_by_app(Xoa_app app) {
|
||||
root_dir = app.Fsys_mgr().Bin_xowa_dir().GenSubDir_nest("cfg", "bldr", "filter");
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.bldrs.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.ios.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xoapi_import implements GfoInvkAble {
|
||||
public long Layout_all_max() {return layout_all_max;} private long layout_all_max = 0; // disable by default; may set to 200 MB in future
|
||||
public long Layout_text_max() {return layout_text_max;} private long layout_text_max = Io_size_.To_long_by_int_mb(1500); // 1.5 GB
|
||||
@@ -29,6 +29,7 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
public byte[] Ns_file_map() {return ns_file_map;} private byte[] ns_file_map = Ns_file_map__each;
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private byte zip_tid_text = Io_stream_.Tid_gzip;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private byte zip_tid_html = Io_stream_.Tid_gzip;
|
||||
public boolean Hzip_enabled() {return hzip_enabled;} private boolean hzip_enabled = Bool_.Y;
|
||||
public String User_name() {return user_name;} private String user_name = "anonymous";
|
||||
public Xowd_core_db_props New_props(String domain_str, long dump_file_size) {
|
||||
Xowd_db_layout layout_text, layout_html, layout_file;
|
||||
@@ -39,7 +40,7 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
layout_html = dump_file_size < layout_html_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
|
||||
layout_file = dump_file_size < layout_file_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
|
||||
}
|
||||
return new Xowd_core_db_props(2, layout_text, layout_html, layout_file, zip_tid_text, zip_tid_html);
|
||||
return new Xowd_core_db_props(2, layout_text, layout_html, layout_file, zip_tid_text, zip_tid_html, hzip_enabled);
|
||||
}
|
||||
public byte[] New_ns_file_map(long dump_file_size) {
|
||||
return dump_file_size < layout_text_max ? Bry_.Empty : Ns_file_map__each;
|
||||
@@ -69,6 +70,8 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_zip_tid_list)) return Options_zip_tid__list;
|
||||
else if (ctx.Match(k, Invk_zip_tid_html)) return Io_stream_.To_str(zip_tid_html);
|
||||
else if (ctx.Match(k, Invk_zip_tid_html_)) zip_tid_html = Io_stream_.To_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_hzip_enabled)) return Yn.To_str(hzip_enabled);
|
||||
else if (ctx.Match(k, Invk_hzip_enabled_)) hzip_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_user_name)) return user_name;
|
||||
else if (ctx.Match(k, Invk_user_name_)) user_name = m.ReadStr("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
@@ -88,6 +91,7 @@ public class Xoapi_import implements GfoInvkAble {
|
||||
, Invk_zip_tid_text = "zip_tid_text" , Invk_zip_tid_text_ = "zip_tid_text_", Invk_zip_tid_list = "zip_tid_list"
|
||||
, Invk_zip_tid_html = "zip_tid_html" , Invk_zip_tid_html_ = "zip_tid_html_"
|
||||
, Invk_user_name = "user_name" , Invk_user_name_ = "user_name_"
|
||||
, Invk_hzip_enabled = "hzip_enabled" , Invk_hzip_enabled_ = "hzip_enabled_"
|
||||
;
|
||||
public static final byte[] Ns_file_map__each = Bry_.new_a7("<each>");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.htmls.tidy.*;
|
||||
import gplx.xowa.htmls.core.htmls.tidy.*;
|
||||
public class Xoapi_tidy implements GfoInvkAble {
|
||||
private Xoae_app app;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.ios.*; import gplx.xowa.files.caches.*;
|
||||
import gplx.core.ios.*; import gplx.xowa.files.caches.*;
|
||||
public class Xoapi_cache implements GfoInvkAble {
|
||||
private Xou_cache_mgr cache_mgr;
|
||||
public void Init_by_app(Xoa_app app) {this.cache_mgr = app.User().User_db_mgr().Cache_mgr();}
|
||||
|
||||
@@ -24,7 +24,10 @@ public class Xowc_xtn_pages implements GfoInvkAble {
|
||||
public int Ns_index_id() {return ns_index_id;} private int ns_index_id = Int_.Min_value;
|
||||
public int Ns_index_talk_id() {return ns_index_talk_id;} private int ns_index_talk_id = Int_.Min_value;
|
||||
public void Ns_names_(byte[] page_name, byte[] page_talk_name, byte[] index_name, byte[] index_talk_name) {
|
||||
this.page_name = page_name; this.page_talk_name = page_talk_name; this.index_name = index_name; this.index_talk_name = index_talk_name;
|
||||
this.page_name = Xoa_ttl.Replace_spaces(page_name); // ensure underlines, not space; EX:"Mục_lục" not "Mục lục"; PAGE:vi.s:Việt_Nam_sử_lược/Quyển_II DATE:2015-10-27
|
||||
this.page_talk_name = Xoa_ttl.Replace_spaces(page_talk_name);
|
||||
this.index_name = Xoa_ttl.Replace_spaces(index_name);
|
||||
this.index_talk_name = Xoa_ttl.Replace_spaces(index_talk_name);
|
||||
}
|
||||
private byte[]
|
||||
page_name = Default_ns_page_name
|
||||
|
||||
@@ -26,6 +26,13 @@ public class Xowc_xtn_pages_tst {
|
||||
fxt.Test_ns_ids(200, 201, 202, 203);
|
||||
fxt.Test_ns_canonical("Page", "Page_talk", "Index", "Index_talk");
|
||||
}
|
||||
@Test public void Spaces() { // PURPOSE: ensure underlines, not space; EX:"Mục_lục" not "Mục lục"; PAGE:vi.s:Việt_Nam_sử_lược/Quyển_II DATE:2015-10-27
|
||||
fxt.Init_ns(200, "Foreign_page").Init_ns(201, "Foreign_page_talk").Init_ns(202, "Foreign_index").Init_ns(203, "Foreign_index_talk"); // ns set by <siteinfo>
|
||||
fxt.Init_names("Foreign page", "Foreign page talk", "Foreign index", "Foreign index talk"); // ns set by .gfs files in /user/wiki/#cfg
|
||||
fxt.Exec_init();
|
||||
fxt.Test_ns_ids(200, 201, 202, 203);
|
||||
fxt.Test_ns_canonical("Page", "Page_talk", "Index", "Index_talk");
|
||||
}
|
||||
}
|
||||
class Xowc_xtn_pages_fxt {
|
||||
private Xow_ns_mgr ns_mgr;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xoa_fmtr_mgr implements GfoInvkAble {
|
||||
public Xoa_fmtr_mgr(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xoa_gfs_bldr {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
if (i != 0 || cont) bfr.Add_byte(Byte_ascii.Dot);
|
||||
bfr.Add_str(ary[i]);
|
||||
bfr.Add_str_u8(ary[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class Xoa_gfs_bldr {
|
||||
public Xoa_gfs_bldr Add_quote_0() {bfr.Add_byte(Byte_ascii.Apos); return this;}
|
||||
public Xoa_gfs_bldr Add_term_nl() {bfr.Add(Bry_semic_nl); return this;}
|
||||
public Xoa_gfs_bldr Add_eq_str(String k, byte[] v) {
|
||||
bfr.Add_str(k);
|
||||
bfr.Add_str_u8(k);
|
||||
bfr.Add(Bry_eq);
|
||||
bfr.Add_byte_apos();
|
||||
bfr.Add(v);
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.apps.gfs; import gplx.*; import gplx.xowa.*; import gplx.xowa.
|
||||
public class Xoa_gfs_wtr_ {
|
||||
public static byte[] Escape(String v) {return Escape(Bry_.new_u8(v));}
|
||||
public static byte[] Escape(byte[] v) {
|
||||
return Bry_find_.Find_fwd(v, Byte_ascii.Apos) == Bry_.NotFound ? v : Bry_.Replace(v, Byte_ascii.Apos_bry, Bry__apos_escaped);
|
||||
return Bry_find_.Find_fwd(v, Byte_ascii.Apos) == Bry_find_.Not_found ? v : Bry_.Replace(v, Byte_ascii.Apos_bry, Bry__apos_escaped);
|
||||
} private static final byte[] Bry__apos_escaped = Bry_.new_a7("''");
|
||||
public static void Write_prop(Bry_bfr bfr, byte[] prop, byte[] val) {
|
||||
bfr.Add(prop).Add(Bry__val_bgn).Add(Xoa_gfs_wtr_.Escape(val)).Add(Bry__val_end); // EX: "a_('b');\n"
|
||||
@@ -29,7 +29,7 @@ public class Xoa_gfs_wtr_ {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (i != 0) bfr.Add_byte(Byte_ascii.Dot);
|
||||
bfr.Add_str(ary[i]);
|
||||
bfr.Add_str_u8(ary[i]);
|
||||
}
|
||||
return bfr.To_str_and_rls();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.apps.*;
|
||||
import gplx.xowa.htmls.js.*;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Socket_rdr {
|
||||
private java.net.ServerSocket server;
|
||||
private java.net.Socket client;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.ios.*; import gplx.texts.*;
|
||||
import gplx.core.ios.*; import gplx.core.texts.*;
|
||||
public class Xosrv_msg_rdr {
|
||||
public Xosrv_msg_rdr(byte[] default_body_bry, IoStream rdr) {this.default_body_bry = default_body_bry; default_body_bry_len = default_body_bry.length; this.rdr = rdr;} private byte[] header_bry = new byte[24], default_body_bry; int default_body_bry_len;
|
||||
public IoStream Rdr() {return rdr;} private IoStream rdr;
|
||||
@@ -45,7 +45,7 @@ public class Xosrv_msg_rdr {
|
||||
}
|
||||
private static byte[] Read_fld(byte[] bry, int bry_len, Int_obj_ref fld_bgn, Bool_obj_ref fail_ref, String_obj_ref fld_ref) {
|
||||
int fld_end = Bry_find_.Find_fwd(bry, Byte_ascii.Pipe, fld_bgn.Val(), bry_len);
|
||||
if (fld_end == Bry_.NotFound) {fail_ref.Val_y_(); return null;}
|
||||
if (fld_end == Bry_find_.Not_found) {fail_ref.Val_y_(); return null;}
|
||||
byte[] rv = Bry_.Mid(bry, fld_bgn.Val(), fld_end);
|
||||
fld_bgn.Val_(fld_end + 1); // +1 to place after pipe
|
||||
return rv;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import org.junit.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xosrv_msg_rdr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xosrv_msg_rdr_fxt fxt = new Xosrv_msg_rdr_fxt();
|
||||
@Test public void Parse() {
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import gplx.core.primitives.*; import gplx.ios.*; import gplx.langs.jsons.*; import gplx.core.threads.*;
|
||||
import gplx.core.primitives.*; import gplx.core.ios.*; import gplx.langs.jsons.*; import gplx.core.threads.*;
|
||||
public class Xosrv_server implements GfoInvkAble {
|
||||
private long last_cmd;
|
||||
public Xosrv_socket_rdr Rdr() {return rdr;} private Xosrv_socket_rdr rdr = new Xosrv_socket_rdr();
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import org.junit.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xosrv_server_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xosrv_server_fxt fxt = new Xosrv_server_fxt();
|
||||
@Test public void Exec_js() {
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xosrv_socket_rdr implements GfoInvkAble {
|
||||
private Socket_rdr rdr = new Socket_rdr();
|
||||
public int Port() {return port;} private int port;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xoa_url__to_str__tst {
|
||||
@Test public void Alias() {
|
||||
fxt.Prep_add_xwiki_to_wiki("wikt", "en.wiktionary.org");
|
||||
Xow_wiki en_d = fxt.Prep_create_wiki("en.wiktionary.org");
|
||||
en_d.Ns_mgr().Ns_main().Case_match_(Xow_ns_case_.Id_all);
|
||||
en_d.Ns_mgr().Ns_main().Case_match_(Xow_ns_case_.Tid__all);
|
||||
fxt.Chk_to_str_href(Bool_.N, "/wiki/wikt:a" , "en.wiktionary.org/wiki/a");
|
||||
}
|
||||
@Test public void Unknown() {fxt.Chk_to_str_href(Bool_.N, "/wiki/{{{extlink}}}" , "");} // {{{extlink}}} not a valid title; return empty
|
||||
|
||||
@@ -238,7 +238,7 @@ public class Xoa_url_parser {
|
||||
private byte[] Bld_page_by_alias(byte[] bry) {
|
||||
if (bry == null) return null;
|
||||
int colon_pos = Bry_find_.Find_fwd(bry, Byte_ascii.Colon); // check for colon; EX: commons:Earth
|
||||
if (colon_pos == Bry_.NotFound) return null; // no colon
|
||||
if (colon_pos == Bry_find_.Not_found) return null; // no colon
|
||||
Xow_wiki alias_wiki = wiki; // default alias_wiki to cur_wiki
|
||||
if (!tmp_wiki_is_missing) // tmp_wiki exists; use it for alias wikis; DATE:2015-09-17
|
||||
alias_wiki = wiki.App().Wiki_mgri().Get_by_key_or_make_init_n(tmp_wiki);
|
||||
|
||||
@@ -56,10 +56,10 @@ public class Xoa_url_parser__xwiki_tst {
|
||||
Xowe_wiki en_d = tstr.Prep_create_wiki("en.wiktionary.org");
|
||||
Xow_ns_mgr ns_mgr = en_d.Ns_mgr();
|
||||
|
||||
ns_mgr.Ns_main().Case_match_(Xow_ns_case_.Id_all);
|
||||
ns_mgr.Ns_main().Case_match_(Xow_ns_case_.Tid__all);
|
||||
tstr.Run_parse("en.wiktionary.org/wiki/a").Chk_wiki("en.wiktionary.org").Chk_page("a");
|
||||
|
||||
ns_mgr.Ns_category().Case_match_(Xow_ns_case_.Id_all);
|
||||
ns_mgr.Ns_category().Case_match_(Xow_ns_case_.Tid__all);
|
||||
tstr.Run_parse("en.wiktionary.org/wiki/Category:a").Chk_wiki("en.wiktionary.org").Chk_page("Category:a");
|
||||
|
||||
tstr.Run_parse("en.wiktionary.org/wiki/A/B/C").Chk_page("A/B/C");
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xoav_url_parser {
|
||||
}
|
||||
private int Parse_wiki(Xoav_url rv, byte[] src, int src_len, int pos) {
|
||||
int wiki_bgn = pos + Bry_site.length;
|
||||
int wiki_end = Bry_find_.Find_fwd(src, Byte_ascii.Slash, wiki_bgn, src_len); if (wiki_end == Bry_.NotFound) throw Err_.new_wo_type("could not find wiki_end", "src", String_.new_u8(src));
|
||||
int wiki_end = Bry_find_.Find_fwd(src, Byte_ascii.Slash, wiki_bgn, src_len); if (wiki_end == Bry_find_.Not_found) throw Err_.new_wo_type("could not find wiki_end", "src", String_.new_u8(src));
|
||||
rv.Wiki_bry_(Bry_.Mid(src, wiki_bgn, wiki_end));
|
||||
return wiki_end;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.ios.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.core.ios.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xob_base_fxt {
|
||||
public Xob_base_fxt Clear() {
|
||||
if (app == null) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user