1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-08-24 00:32:13 -04:00
parent df10db140c
commit ed911e3de5
220 changed files with 2618 additions and 1569 deletions

View File

@@ -0,0 +1,30 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
interface Mwm_lxr {
int Tid();
int Make_tkn(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int cur_pos);
}
class Mwm_lxr_ {
public static final int
Tid__ws = 0
, Tid__backslash = 1
, Tid__curly_bgn = 2
, Tid__curly_end = 3
;
}

View File

@@ -0,0 +1,50 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_lxr__backslash implements Mwm_lxr {
public int Tid() {return Mwm_lxr_.Tid__backslash;}
public int Make_tkn(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
boolean loop = true;
while (loop) {
if (cur_pos == src_len) break;
byte b = src[cur_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:
case Byte_ascii.Ltr_A: case Byte_ascii.Ltr_B: case Byte_ascii.Ltr_C: case Byte_ascii.Ltr_D: case Byte_ascii.Ltr_E:
case Byte_ascii.Ltr_F: case Byte_ascii.Ltr_G: case Byte_ascii.Ltr_H: case Byte_ascii.Ltr_I: case Byte_ascii.Ltr_J:
case Byte_ascii.Ltr_K: case Byte_ascii.Ltr_L: case Byte_ascii.Ltr_M: case Byte_ascii.Ltr_N: case Byte_ascii.Ltr_O:
case Byte_ascii.Ltr_P: case Byte_ascii.Ltr_Q: case Byte_ascii.Ltr_R: case Byte_ascii.Ltr_S: case Byte_ascii.Ltr_T:
case Byte_ascii.Ltr_U: case Byte_ascii.Ltr_V: case Byte_ascii.Ltr_W: case Byte_ascii.Ltr_X: case Byte_ascii.Ltr_Y: case Byte_ascii.Ltr_Z:
case Byte_ascii.Ltr_a: case Byte_ascii.Ltr_b: case Byte_ascii.Ltr_c: case Byte_ascii.Ltr_d: case Byte_ascii.Ltr_e:
case Byte_ascii.Ltr_f: case Byte_ascii.Ltr_g: case Byte_ascii.Ltr_h: case Byte_ascii.Ltr_i: case Byte_ascii.Ltr_j:
case Byte_ascii.Ltr_k: case Byte_ascii.Ltr_l: case Byte_ascii.Ltr_m: case Byte_ascii.Ltr_n: case Byte_ascii.Ltr_o:
case Byte_ascii.Ltr_p: case Byte_ascii.Ltr_q: case Byte_ascii.Ltr_r: case Byte_ascii.Ltr_s: case Byte_ascii.Ltr_t:
case Byte_ascii.Ltr_u: case Byte_ascii.Ltr_v: case Byte_ascii.Ltr_w: case Byte_ascii.Ltr_x: case Byte_ascii.Ltr_y: case Byte_ascii.Ltr_z:
case Byte_ascii.Underline:
++cur_pos;
break;
default:
loop = false;
break;
}
}
root.Regy__add(Mwm_tkn_.Tid__func, bgn_pos, cur_pos, new Mwm_tkn__node());
return cur_pos;
}
}

View 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.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_lxr__curly_bgn implements Mwm_lxr {
public int Tid() {return Mwm_lxr_.Tid__curly_bgn;}
public int Make_tkn(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
int uid = root.Regy__add(Mwm_tkn_.Tid__arg, bgn_pos, cur_pos, new Mwm_tkn__node());
Mwm_tkn tkn = root.Subs__get_at(uid);
ctx.Stack().Add(tkn);
return cur_pos;
}
}
class Mwm_lxr__curly_end implements Mwm_lxr {
public int Tid() {return Mwm_lxr_.Tid__curly_end;}
public int Make_tkn(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
Mwm_tkn bgn_tkn = ctx.Stack().Pop();
root.Regy__move(bgn_tkn, null);
return cur_pos;
}
}

View File

@@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_lxr__ws implements Mwm_lxr {
public int Tid() {return Mwm_lxr_.Tid__ws;}
public int Make_tkn(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
while (true) {
if (cur_pos == src_len) break;
if (src[cur_pos] != Byte_ascii.Space)
break;
++cur_pos;
}
root.Regy__add(Mwm_tkn_.Tid__ws, bgn_pos, cur_pos, null);
return cur_pos;
}
}

View File

@@ -0,0 +1,62 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
import gplx.core.btries.*;
class Mwm_parser {
public void Parse(Mwm_tkn__root root, byte[] src) {
int src_len = src.length;
Parse(root, new Mwm_ctx(this, Mwm_trie_bldr.new_()), src, src_len, 0, src_len);
}
private int Parse(Mwm_tkn__root root, Mwm_ctx ctx, byte[] src, int src_len, int bgn_pos, int end_pos) {
Btrie_fast_mgr trie = ctx.Trie();
int pos = bgn_pos;
int txt_bgn = pos, txt_uid = -1;
byte b = src[pos];
while (true) {
Object o = trie.Match_bgn_w_byte(b, src, pos, src_len);
if (o == null) // no lxr found; char is txt; increment pos
pos++;
else { // lxr found
Mwm_lxr lxr = (Mwm_lxr)o;
if (txt_bgn != pos) txt_uid = Txt_calc(ctx, root, src, src_len, pos, txt_bgn, txt_uid);// chars exist between pos and txt_bgn; make txt_tkn;
pos = lxr.Make_tkn(ctx, root, src, src_len, pos, trie.Match_pos());
if (pos > 0) {txt_bgn = pos; txt_uid = -1;} // reset txt_tkn
}
if (pos == end_pos) break;
b = src[pos];
}
if (txt_bgn != pos) txt_uid = Txt_calc(ctx, root, src, src_len, src_len, txt_bgn, txt_uid);
return pos;
}
private static int Txt_calc(Mwm_ctx ctx, Mwm_tkn__root root, byte[] src, int src_len, int bgn_pos, int txt_bgn, int txt_uid) {
if (txt_uid == -1) // no existing txt_tkn; create new one
txt_uid = root.Regy__add(Mwm_tkn_.Tid__text, txt_bgn, bgn_pos, null);
else // existing txt_tkn; happens for false matches; EX: abc[[\nef[[a]]; see NOTE_1
root.Regy__update_end(txt_uid, bgn_pos);
return txt_uid;
}
}
class Mwm_ctx {
public Mwm_ctx(Mwm_parser parser, Btrie_fast_mgr trie) {
this.parser = parser;
this.trie = trie;
}
public Mwm_tkn_stack Stack() {return stack;} private Mwm_tkn_stack stack = new Mwm_tkn_stack();
public Btrie_fast_mgr Trie() {return trie;} private final Btrie_fast_mgr trie;
public Mwm_parser Parser() {return parser;} private final Mwm_parser parser;
}

View File

@@ -0,0 +1,105 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
import org.junit.*;
public class Mwm_parser_tst {
private final Mwm_parser_fxt fxt = new Mwm_parser_fxt();
@Test public void Text() {
fxt.Test_parse("abc"
, fxt.text(0, 3)
);
}
@Test public void Ws() {
fxt.Test_parse(" "
, fxt.ws(0, 3)
);
}
@Test public void Mix() {
fxt.Test_parse("a b c"
, fxt.text(0, 1)
, fxt.ws (1, 2)
, fxt.text(2, 3)
, fxt.ws (3, 4)
, fxt.text(4, 5)
);
}
@Test public void Func() {
fxt.Test_parse("\\abc \\def"
, fxt.func(0, 4)
, fxt.ws (4, 5)
, fxt.func(5, 9)
);
}
// @Test public void Arg() {
// fxt.Test_parse("{a}"
// , fxt.arg(0, 3
// , fxt.text(1, 2)
// )
// );
// }
}
class Mwm_parser_fxt {
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
private final Mwm_parser parser = new Mwm_parser();
private final Mwm_tkn__root expd_root, actl_root;
private final Mwm_tkn_mkr tkn_mkr = new Mwm_tkn_mkr();
public Mwm_parser_fxt() {
this.expd_root = new Mwm_tkn__root(tkn_mkr);
this.actl_root = new Mwm_tkn__root(tkn_mkr);
}
public void Test_parse(String src_str, Mwm_tkn... expd_tkns) {
byte[] src_bry = Bry_.new_u8(src_str);
int src_len = src_bry.length;
expd_root.Init_as_root(0, src_len);
actl_root.Init_as_root(0, src_len);
parser.Parse(actl_root, src_bry);
int len = actl_root.Subs__len();
for (int i = 0; i < len; ++i) {
Mwm_tkn sub = actl_root.Subs__get_at(i);
sub.To_bry(tmp_bfr, 0);
}
String expd = tmp_bfr.Xto_str_and_clear();
len = expd_tkns.length;
for (int i = 0; i < len; ++i) {
Mwm_tkn sub = expd_tkns[i];
sub.To_bry(tmp_bfr, 0);
}
String actl = tmp_bfr.Xto_str_and_clear();
Tfds.Eq_str_lines(expd, actl, src_str);
}
private Mwm_tkn leaf(int tid, int bgn, int end) {
int uid = expd_root.Regy__add(tid, bgn, end, null);
return new Mwm_tkn__leaf().Init(expd_root, tid, uid, bgn, end);
}
private Mwm_tkn node(int tid, int bgn, int end, Mwm_tkn tkn) {
int uid = expd_root.Regy__add(tid, bgn, end, tkn);
return new Mwm_tkn__node().Init(expd_root, tid, uid, bgn, end);
}
public Mwm_tkn text (int bgn, int end) {return leaf(Mwm_tkn_.Tid__text , bgn, end);}
public Mwm_tkn ws (int bgn, int end) {return leaf(Mwm_tkn_.Tid__ws , bgn, end);}
public Mwm_tkn func (int bgn, int end) {return node(Mwm_tkn_.Tid__func , bgn, end, new Mwm_tkn__node());}
public Mwm_tkn arg (int bgn, int end, Mwm_tkn... subs) {
Mwm_tkn rv = node(Mwm_tkn_.Tid__func , bgn, end, new Mwm_tkn__node());
int len = subs.length;
for (int i = 0; i < len; ++i) {
Mwm_tkn sub = subs[i];
expd_root.Regy__move(rv, sub);
}
return rv;
}
}

View File

@@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_root_ary {
private Mwm_tkn[] ary = Mwm_tkn_.Ary_empty; private int ary_max;
public Mwm_tkn Get_at(int i) {return i < ary_max ? ary[i] : null;}
public void Init(int expd_itms) {
if (expd_itms > ary_max) {
this.ary_max = expd_itms;
this.ary = new Mwm_tkn[ary_max];
}
else {
for (int i = 0; i < ary_max; ++i)
ary[i] = null;
}
}
public void Add(int idx, Mwm_tkn tkn) {
if (idx >= ary_max) {
int new_max = idx == 0 ? 2 : idx * 2;
Mwm_tkn[] new_ary = new Mwm_tkn[new_max];
for (int i = 0; i < ary_max; ++i)
new_ary[i] = ary[i];
this.ary = new_ary;
this.ary_max = new_max;
}
ary[idx] = tkn;
}
}

View File

@@ -0,0 +1,79 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_root_reg {
private int[] ary = Int_.Ary_empty; private int ary_len, ary_max; private int itms_len;
private final Mwm_tkn__root root;
public int Len() {return itms_len;}
public Mwm_root_reg(Mwm_tkn__root root) {
this.root = root;
}
public void Init(int expd_itms) {
int expd_max = expd_itms * Idx__slots;
if (expd_max > ary_max) {
this.ary = new int[expd_max];
this.ary_max = expd_max;
}
else {
for (int i = 0; i < ary_len; ++i)
ary[i] = 0;
}
this.ary_len = 0;
this.itms_len = 0;
}
public Mwm_tkn Get_at(Mwm_tkn_mkr tkn_mkr, int uid) {
int idx = uid * Idx__slots;
int tid = ary[idx];
switch (tid) {
case Mwm_tkn_.Tid__text:
case Mwm_tkn_.Tid__ws:
return tkn_mkr.Make_leaf(root, tid, uid, ary[idx + Idx__bgn], ary[idx + Idx__end]);
default:
return null;
}
}
public int Add(int tid, int oid, int bgn, int end) {
int new_ary_len = ary_len + Idx__slots;
if (new_ary_len >= ary_max) {
int new_max = ary_max == 0 ? Idx__slots : ary_max * 2;
int[] new_ary = new int[new_max];
for (int i = 0; i < ary_len; ++i)
new_ary[i] = ary[i];
this.ary = new_ary;
this.ary_max = new_max;
}
int idx = ary_len;
int uid = idx / Idx__slots;
ary[idx ] = tid;
ary[idx + Idx__oid] = oid;
ary[idx + Idx__bgn] = bgn;
ary[idx + Idx__end] = end;
this.ary_len = new_ary_len;
++itms_len;
return uid;
}
public void Update_end(int uid, int end) {
ary[(uid * Idx__slots) + Idx__end] = end;
}
private static final int
Idx__oid = 1
, Idx__bgn = 2
, Idx__end = 3
, Idx__slots = 4
;
}

View File

@@ -0,0 +1,52 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_root_sub {
private Int_ary[] ary = new Int_ary[0]; private int ary_max;
public Int_ary Get_at(int i) {return i < ary_max ? ary[i] : null;}
public int Get_subs_len(int uid) {
Int_ary subs_ary = uid < ary_max ? ary[uid] : null;
return subs_ary == null ? 0 : subs_ary.Len();
}
public void Init(int expd_itms) {
if (expd_itms > ary_max) {
this.ary_max = expd_itms;
this.ary = new Int_ary[ary_max];
}
else {
for (int i = 0; i < ary_max; ++i)
ary[i] = null;
}
}
public void Add(int owner_uid, int sub_uid) {
if (owner_uid >= ary_max) {
int new_max = owner_uid == 0 ? 2 : owner_uid * 2;
Int_ary[] new_ary = new Int_ary[new_max];
for (int i = 0; i < ary_max; ++i)
new_ary[i] = ary[i];
this.ary = new_ary;
this.ary_max = new_max;
}
Int_ary subs_ary = ary[owner_uid];
if (subs_ary == null) {
subs_ary = new Int_ary(2);
ary[owner_uid] = subs_ary;
}
subs_ary.Add(sub_uid);
}
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
interface Mwm_tkn {
int Tid();
Mwm_tkn__root Root();
int Uid();
int Src_bgn();
int Src_end();
Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end);
int Subs__len();
Mwm_tkn Subs__get_at(int i);
void To_bry(Bry_bfr bfr, int indent);
}

View File

@@ -0,0 +1,58 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_tkn_ {
public static final Mwm_tkn Owner__null = null;
public static final Mwm_tkn[] Ary_empty = new Mwm_tkn[0];
public static final int Uid__root = 0;
public static final int
Tid__root = 0
, Tid__text = 1
, Tid__ws = 2
, Tid__func = 3
, Tid__arg = 4
;
public static byte[]
Bry__root = Bry_.new_a7("root")
, Bry__text = Bry_.new_a7("text")
, Bry__ws = Bry_.new_a7("ws")
, Bry__func = Bry_.new_a7("func")
, Bry__arg = Bry_.new_a7("arg")
;
public static byte[] Tid_to_bry(int tid) {
switch (tid) {
case Tid__root: return Bry__root;
case Tid__text: return Bry__text;
case Tid__ws: return Bry__ws;
case Tid__func: return Bry__func;
case Tid__arg: return Bry__arg;
default: throw Err_.new_unhandled(tid);
}
}
public static void Tkn_to_bry__bgn(Bry_bfr bfr, int indent, Mwm_tkn tkn) {
if (indent > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent);
bfr.Add(Mwm_tkn_.Tid_to_bry(tkn.Tid()));
bfr.Add_byte(Byte_ascii.Paren_bgn);
bfr.Add_int_variable(tkn.Src_bgn());
bfr.Add_byte_comma().Add_int_variable(tkn.Src_end());
}
public static void Tkn_to_bry__end_head(Bry_bfr bfr) {
bfr.Add_byte(Byte_ascii.Paren_end);
bfr.Add_byte_nl();
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_tkn__leaf implements Mwm_tkn {
public Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end) {
this.root = root;
this.tid = tid;
this.uid = uid;
this.src_bgn = src_bgn;
this.src_end = src_end;
return this;
}
public Mwm_tkn__root Root() {return root;} private Mwm_tkn__root root;
public int Tid() {return tid;} private int tid;
public int Uid() {return uid;} private int uid;
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public int Subs__len() {return 0;}
public Mwm_tkn Subs__get_at(int i) {throw Err_.new_unsupported();}
public void To_bry(Bry_bfr bfr, int indent) {
Mwm_tkn_.Tkn_to_bry__bgn(bfr, indent, this);
Mwm_tkn_.Tkn_to_bry__end_head(bfr);
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_tkn__node implements Mwm_tkn {
public Mwm_tkn__root Root() {return root;} private Mwm_tkn__root root;
public int Tid() {return tid;} private int tid;
public int Uid() {return uid;} private int uid;
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end) {
this.root = root;
this.tid = tid;
this.uid = uid;
this.src_bgn = src_bgn;
this.src_end = src_end;
return this;
}
public int Subs__len() {return root.Regy__get_subs_len(uid);}
public Mwm_tkn Subs__get_at(int i) {return root.Regy__get_subs_tkn(uid, i);}
public void To_bry(Bry_bfr bfr, int indent) {
Mwm_tkn_.Tkn_to_bry__bgn(bfr, indent, this);
Mwm_tkn_.Tkn_to_bry__end_head(bfr);
}
}

View File

@@ -0,0 +1,73 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_tkn__root implements Mwm_tkn {
private final Mwm_root_reg root_reg;
private final Mwm_root_ary root_ary = new Mwm_root_ary();
private final Mwm_root_sub root_sub = new Mwm_root_sub();
public Mwm_tkn__root(Mwm_tkn_mkr tkn_mkr) {
this.tkn_mkr = tkn_mkr;
this.root_reg = new Mwm_root_reg(this);
}
public Mwm_tkn__root Root() {return this;}
public Mwm_tkn_mkr Tkn_mkr() {return tkn_mkr;} private final Mwm_tkn_mkr tkn_mkr;
public int Tid() {return Mwm_tkn_.Tid__root;}
public int Uid() {return Mwm_tkn_.Uid__root;}
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public Mwm_tkn Init(Mwm_tkn__root root, int tid, int uid, int src_bgn, int src_end) {throw Err_.new_unsupported();}
public Mwm_tkn Init_as_root(int src_bgn, int src_end) {
this.src_bgn = src_bgn; this.src_end = src_end;
int expd_len = (src_end - src_bgn) / 5;
root_reg.Init(expd_len);
root_ary.Init(expd_len);
root_sub.Init(expd_len);
root_reg.Add(Mwm_tkn_.Tid__root, Mwm_tkn_.Uid__root, src_bgn, src_end);
// this.Regy__add(Mwm_tkn_.Tid__root, src_bgn, src_end, this);
return this;
}
public int Subs__len() {return Regy__get_subs_len(Mwm_tkn_.Uid__root);}
public Mwm_tkn Subs__get_at(int i) {return Regy__get_subs_tkn(Mwm_tkn_.Uid__root, i);}
public void To_bry(Bry_bfr bfr, int indent) {
Mwm_tkn_.Tkn_to_bry__bgn(bfr, indent, this);
Mwm_tkn_.Tkn_to_bry__end_head(bfr);
}
public int Regy__add(int tid, int bgn, int end, Mwm_tkn tkn) {
int uid = root_reg.Add(tid, Mwm_tkn_.Uid__root, bgn, end);
if (tkn != null) {
tkn.Init(this, tid, uid, bgn, end);
root_ary.Add(uid, tkn);
}
root_sub.Add(Mwm_tkn_.Uid__root, uid);
return uid;
}
public int Regy__get_subs_len(int uid) {return root_sub.Get_subs_len(uid);}
public Mwm_tkn Regy__get_subs_tkn(int owner_uid, int sub_idx) {
return Regy__get_tkn(root_sub.Get_at(owner_uid).Get_at(sub_idx));
}
public Mwm_tkn Regy__get_tkn(int uid) {
Mwm_tkn rv = root_reg.Get_at(tkn_mkr, uid);
return rv == null ? root_ary.Get_at(uid) : rv;
}
public void Regy__move(Mwm_tkn new_owner, Mwm_tkn sub) {
// int cur_owner_id = root_reg.Get_owner_id(sub.Uid());
// Mwm_tkn cur_owner = Regy__get_tkn(cur_owner_id);
// root_reg.Change_owner(cur_owner, new_owner);
}
public void Regy__update_end(int uid, int end) {}
}

View File

@@ -0,0 +1,37 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_tkn_mkr {
private final Mwm_tkn__leaf tmp_leaf = new Mwm_tkn__leaf();
public Mwm_tkn Make_leaf(Mwm_tkn__root root, int tid, int uid, int bgn, int end) {
synchronized (tmp_leaf) {
tmp_leaf.Init(root, tid, uid, bgn, end);
return tmp_leaf;
}
}
public Mwm_tkn Make_func(Mwm_tkn__root root, int uid, int bgn, int end) {
Mwm_tkn__node rv = new Mwm_tkn__node();
rv.Init(root, Mwm_tkn_.Tid__func, uid, bgn, end);
return rv;
}
public Mwm_tkn Make_arg(Mwm_tkn__root root, int uid, int bgn, int end) {
Mwm_tkn__node rv = new Mwm_tkn__node();
rv.Init(root, Mwm_tkn_.Tid__arg, uid, bgn, end);
return rv;
}
}

View File

@@ -0,0 +1,47 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
class Mwm_tkn_stack {
private Mwm_tkn[] ary; private int ary_len, ary_max;
public Mwm_tkn_stack() {this.Clear();}
public int Len() {return ary_len;}
public void Clear() {
this.ary = Mwm_tkn_.Ary_empty;
this.ary_len = 0;
this.ary_max = 0;
}
public void Add(Mwm_tkn tkn) {
int new_ary_len = ary_len + 1;
if (new_ary_len >= ary_max) {
int new_max = ary_max == 0 ? 2 : ary_max * 2;
Mwm_tkn[] new_ary = new Mwm_tkn[new_max];
for (int i = 0; i < ary_len; ++i)
new_ary[i] = ary[i];
this.ary = new_ary;
this.ary_max = new_max;
}
ary[ary_len] = tkn;
this.ary_len = new_ary_len;
}
public Mwm_tkn Pop() {
int new_ary_len = ary_len - 1;
Mwm_tkn rv = ary[new_ary_len];
this.ary_len = new_ary_len;
return rv;
}
}

View File

@@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.math.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
import gplx.core.btries.*;
class Mwm_trie_bldr {
public static Btrie_fast_mgr new_() {
Btrie_fast_mgr rv = Btrie_fast_mgr.cs();
rv.Add(" " , new Mwm_lxr__ws());
rv.Add("\\" , new Mwm_lxr__backslash());
rv.Add("{" , new Mwm_lxr__curly_bgn());
return rv;
}
}

View File

@@ -37,7 +37,7 @@ public class Pfunc_ifexist_tst {
}
@Test public void Media_y_commons() {// DATE:2014-07-04
Pfunc_ifexist.Mgr.Clear();
Xowe_wiki commons_wiki = fxt.App().Wiki_mgr().Get_by_key_or_make(gplx.xowa.wikis.Xow_domain_.Domain_bry_commons);
Xowe_wiki commons_wiki = fxt.App().Wiki_mgr().Get_by_key_or_make(gplx.xowa.wikis.domains.Xow_domain_itm_.Bry__commons);
fxt.Init_page_create(commons_wiki, "File:A.png", "");
fxt.Test_parse_tmpl_str_test("{{#ifexist:Media:A.png|y|n}}", "{{test}}", "y");
}

View File

@@ -19,7 +19,7 @@ package gplx.xowa.xtns.pfuncs.ttls; import gplx.*; import gplx.xowa.*; import gp
import org.junit.*; import gplx.dbs.*;
import gplx.xowa.tdbs.*;
import gplx.xowa.files.*; import gplx.xowa.files.exts.*; import gplx.xowa.files.origs.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wikis.domains.*;
public class Pfunc_filepath_tst {
private final Xop_fxt fxt = new Xop_fxt();
private final Xofw_wiki_wkr_mock mock_wkr = new Xofw_wiki_wkr_mock();
@@ -31,7 +31,7 @@ public class Pfunc_filepath_tst {
Xoae_app app = fxt.App();
en_wiki = fxt.Wiki();
// Init_orig_mgr(en_wiki);
commons_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_commons);
commons_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_itm_.Str__commons);
mock_wkr.Clear_commons(); // assume all files are in repo 0
en_wiki.File_mgr().Repo_mgr().Page_finder_(mock_wkr);
commons_wiki.Db_mgr().Load_mgr().Clear();

View File

@@ -16,13 +16,14 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.proofreadPage; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
import gplx.html.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*;
public class Pp_xtn_mgr extends Xox_mgr_base {
@Override public boolean Enabled_default() {return false;}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("ProofreadPages");
@Override public Xox_mgr Clone_new() {return new Pp_xtn_mgr();}
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
if (!this.Enabled_manually())
this.Enabled_(wiki.Domain_tid() == Xow_domain_type_.Tid_wikisource); // only enable for wikisource
this.Enabled_(wiki.Domain_tid() == Xow_domain_type_.Int__wikisource); // only enable for wikisource
}
}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.relatedSites; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.pages.skins.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.pages.skins.*;
import gplx.xowa.html.hrefs.*;
class Sites_xtn_skin_itm implements Xopg_xtn_skin_itm {
private List_adp itms = List_adp_.new_();
@@ -56,7 +56,7 @@ public class Sites_html_bldr implements Bry_fmtr_arg {
private static byte[] Xto_href(Bry_bfr tmp_bfr, Bry_fmtr url_fmtr, Xoh_href_parser href_parser, Xowe_wiki wiki, Xow_xwiki_itm xwiki_itm, byte[] ttl_page_db) {
Xoa_app_.Utl__encoder_mgr().Href().Encode(tmp_bfr, ttl_page_db);
byte[] rv = url_fmtr.Fmt_(xwiki_itm.Url_fmt()).Bld_bry_many(tmp_bfr, tmp_bfr.Xto_bry_and_clear());
if (xwiki_itm.Domain_tid() != Xow_domain_type_.Tid_other)
if (xwiki_itm.Domain_tid() != Xow_domain_type_.Int__other)
rv = Bry_.Add(Xoh_href_.Bry__site, rv);
return rv;
}

View File

@@ -192,7 +192,7 @@ class Scrib_lua_rsp_bldr {
else if (Object_.Eq(v_type, Double_.Cls_ref_type)) Bld_double(bfr, Double_.cast_(v));
else if (Object_.Eq(v_type, KeyVal[].class)) Bld_kv_ary(bfr, (KeyVal[])v);
else if (Object_.Eq(v_type, Scrib_lua_proc.class)) Bld_fnc(bfr, (Scrib_lua_proc)v);
else throw Err_.new_unhandled(ClassAdp_.NameOf_obj(v));
else throw Err_.new_unhandled(Type_adp_.NameOf_obj(v));
}
private void Bld_bool(Bry_bfr bfr, boolean v) {bfr.Add_str_a7("b:").Add_int_fixed(v ? 1 : 0, 1).Add_byte(Byte_ascii.Semic);}
private void Bld_int(Bry_bfr bfr, int v) {bfr.Add_str_a7("i:").Add_int_variable(v).Add_byte(Byte_ascii.Semic);}

View File

@@ -52,7 +52,7 @@ public class Scrib_lua_mod {
String prc_key = prc_kv.Key();
Object prc_val = prc_kv.Val();
Scrib_lua_proc fnc = null;
if (ClassAdp_.ClassOf_obj(prc_val) == Scrib_lua_proc.class)
if (Type_adp_.ClassOf_obj(prc_val) == Scrib_lua_proc.class)
fnc = (Scrib_lua_proc)prc_val;
else
fnc = new Scrib_lua_proc(prc_key, -1);

View File

@@ -22,6 +22,6 @@ public class Scrib_lua_proc {
public int Id() {return id;} private int id;
@Override public String toString() {return key + ":" + id;}
public static Scrib_lua_proc cast_or_null_(Object o) { // NOTE: maxStringLength and maxPatternLength return d:INF; ignore these
return ClassAdp_.ClassOf_obj(o) == Scrib_lua_proc.class ? (Scrib_lua_proc)o : null;
return Type_adp_.ClassOf_obj(o) == Scrib_lua_proc.class ? (Scrib_lua_proc)o : null;
}
}

View File

@@ -61,7 +61,7 @@ public class Scrib_proc_args {
public byte[][] Cast_params_as_bry_ary_or_rest_of_ary(int params_idx) { // PAGE:ru.w:Ленин,_Владимир_Ильич; DATE:2014-07-01 MW:LanguageLibrary.php|ConvertPlural: if (is_array($args[0])) $args = $args[0]; $forms = array_values(array_map('strval', $args));
if (params_idx < 0 || params_idx >= ary_len) return Bry_.Ary_empty;
Object o = ary[params_idx].Val();
if (ClassAdp_.Eq_typeSafe(o, KeyVal[].class)) {
if (Type_adp_.Eq_typeSafe(o, KeyVal[].class)) {
KeyVal[] tbl = (KeyVal[])o;
int rv_len = tbl.length;
byte[][] rv = new byte[rv_len][];
@@ -84,7 +84,7 @@ public class Scrib_proc_args {
public byte[] Extract_qry_args(Xowe_wiki wiki, int idx) {
Object qry_args_obj = Cast_obj_or_null(idx);
if (qry_args_obj == null) return Bry_.Empty;
Class<?> qry_args_cls = ClassAdp_.ClassOf_obj(qry_args_obj);
Class<?> qry_args_cls = Type_adp_.ClassOf_obj(qry_args_obj);
if (qry_args_cls == String.class)
return Bry_.new_u8((String)qry_args_obj);
else if (qry_args_cls == KeyVal[].class) {
@@ -101,7 +101,7 @@ public class Scrib_proc_args {
return bfr.To_bry_and_rls();
}
else {
wiki.Appe().Usr_dlg().Warn_many("", "", "unknown type for GetUrl query args: ~{0}", ClassAdp_.NameOf_type(qry_args_cls));
wiki.Appe().Usr_dlg().Warn_many("", "", "unknown type for GetUrl query args: ~{0}", Type_adp_.NameOf_type(qry_args_cls));
return Bry_.Empty;
}
}

View File

@@ -85,7 +85,7 @@ class Luaj_value_ {
}
public static LuaValue X_obj_to_val(Luaj_server server, Object o) {
if (o == null) return LuaValue.NIL;
Class<?> c = ClassAdp_.ClassOf_obj(o);
Class<?> c = Type_adp_.ClassOf_obj(o);
if (Object_.Eq(c, Bool_.Cls_ref_type)) return LuaValue.valueOf((Boolean)o);
else if (Object_.Eq(c, Int_.Cls_ref_type)) return LuaValue.valueOf((Integer)o);
else if (Object_.Eq(c, Double_.Cls_ref_type)) return LuaValue.valueOf((Double)o);

View File

@@ -81,7 +81,7 @@ public class Process_send_wtr {
}
public boolean Encode_obj(Bry_bfr bfr, Object o) {
if (o == null) {bfr.Add(CONST_nil); return true;}
Class<?> c = ClassAdp_.ClassOf_obj(o);
Class<?> c = Type_adp_.ClassOf_obj(o);
if (Object_.Eq(c, Bool_.Cls_ref_type)) Encode_bool(bfr, Bool_.cast_(o));
else if (Object_.Eq(c, Int_.Cls_ref_type)) Encode_int(bfr, Int_.cast_(o));
else if (Object_.Eq(c, Double_.Cls_ref_type)) {if (!Encode_double(bfr, Double_.cast_(o))) return false;}
@@ -90,7 +90,7 @@ public class Process_send_wtr {
else if (Object_.Eq(c, Scrib_lua_proc.class)) {if (!Encode_prc(bfr, (Scrib_lua_proc)o)) return false;}
else if (Object_.Eq(c, KeyVal.class)) {if (!Encode_kv(bfr, (KeyVal)o)) return false;}
else if (Object_.Eq(c, KeyVal[].class)) {if (!Encode_ary(bfr, (KeyVal[])o)) return false;}
else {throw Scrib_xtn_mgr.err_("Object cannot be serialized: {0}", ClassAdp_.NameOf_obj(o));}
else {throw Scrib_xtn_mgr.err_("Object cannot be serialized: {0}", Type_adp_.NameOf_obj(o));}
return true;
}
private static final byte[] CONST_nil = Bry_.new_a7("nil"), CONST_bool_true = Bry_.new_a7("true"), CONST_bool_false = Bry_.new_a7("false"), CONST_escape_000 = Bry_.new_a7("\\000");

View File

@@ -71,10 +71,10 @@ class Process_server_mock_rcvd_val implements Process_server_mock_rcvd {
continue;
}
Class<?> kv_val_type = kv_val.getClass();
boolean kv_val_is_array = ClassAdp_.Eq(kv_val_type, KeyVal[].class);
boolean kv_val_is_array = Type_adp_.Eq(kv_val_type, KeyVal[].class);
if (print_key && !kv_val_is_array)
bfr.Add_str(kv.Key()).Add_byte(Byte_ascii.Colon);
if (ClassAdp_.Eq(kv_val_type, Bool_.Cls_ref_type))
if (Type_adp_.Eq(kv_val_type, Bool_.Cls_ref_type))
bfr.Add(Bool_.cast_(kv_val) ? gplx.core.json.Json_itm_.Const_true : gplx.core.json.Json_itm_.Const_false);
else if (kv_val_is_array) {
KeyVal[] sub = (KeyVal[])kv_val;

View File

@@ -135,7 +135,7 @@ public class Scrib_lib_language_tst {
, " seconds=3"
));
}
private static KeyVal[] Kv_ary_(String... ary) {
public static KeyVal[] Kv_ary_(String... ary) {
int ary_len = ary.length;
KeyVal[] rv = new KeyVal[ary_len];
for (int i = 0; i < ary_len; i++) {

View File

@@ -295,7 +295,7 @@ public class Scrib_lib_mw implements Scrib_lib {
}
return (KeyVal[])rv.To_ary(KeyVal.class);
}
private static boolean Is_kv_ary(KeyVal kv) {return ClassAdp_.Eq_typeSafe(kv.Val(), KeyVal[].class);}
private static boolean Is_kv_ary(KeyVal kv) {return Type_adp_.Eq_typeSafe(kv.Val(), KeyVal[].class);}
public boolean ExpandTemplate(Scrib_proc_args args, Scrib_proc_rslt rslt) {
String ttl_str = args.Pull_str(1);
byte[] ttl_bry = Bry_.new_u8(ttl_str);
@@ -348,7 +348,7 @@ public class Scrib_lib_mw implements Scrib_lib {
Xot_invk frame = Scrib_frame_.Get_frame(core, frame_id);
Object ttl_obj = args.Cast_obj_or_null(1); // NOTE: callers must pass named title else title will be false; EX: frame:newChild{'current', 'title0'} -> false; frame:newChild{'current', title='title0'} -> 'title0'; DATE:2014-05-20
Xoa_ttl ttl = null;
if (ClassAdp_.ClassOf_obj(ttl_obj) != String.class) { // title = false
if (Type_adp_.ClassOf_obj(ttl_obj) != String.class) { // title = false
byte[] ttl_bry = frame.Frame_ttl();
ttl = Xoa_ttl.parse_(core.Wiki(), ttl_bry);
}

View File

@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
public class Scrib_lib_text implements Scrib_lib {
private final Scrib_lib_text__json_util json_util = new Scrib_lib_text__json_util();
public Scrib_lib_text(Scrib_core core) {this.core = core;} private Scrib_core core;
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
public Scrib_lib Init() {procs.Init_by_lib(this, Proc_names); return this;}
@@ -51,19 +52,27 @@ public class Scrib_lib_text implements Scrib_lib {
return rslt.Init_obj(Html_entity_);
} private static KeyVal[] Html_entity_;
public boolean JsonEncode(Scrib_proc_args args, Scrib_proc_rslt rslt) {
throw Err_.new_unimplemented();
// KeyVal[] kv_ary = args.Pull_kv_ary(0);
// int flags = args.Cast_int_or(1, 0);
// if (!(flags & Scrib_lib_text__json_util.Flag__preserve_keys)) { // && is_array( $value )
// text = Scrib_lib_text__json_util.Reindex_arrays(text, true);
// }
// byte[] rv = Scrib_lib_text__json_util.Encode(kv_ary, flags && Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);
// if (!Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys))
// kv_ary = json_util.Reindex_arrays(kv_ary, true);
// byte[] rv = json_util.Encode(kv_ary, flags & Scrib_lib_text__json_util.Flag__pretty, Scrib_lib_text__json_util.Skip__all);
// if (rv == null) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to encode value");
// return rslt.Init_obj(rv);
return false;
}
public boolean JsonDecode(Scrib_proc_args args, Scrib_proc_rslt rslt) {
throw Err_.new_unimplemented();
// return false;
// byte[] json = args.Pull_bry(0);
// int flags = args.Cast_int_or(1, 0);
// int opts = Scrib_lib_text__json_util.Opt__force_assoc;
// if (Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__try_fixing))
// opts = Enm_.Add_int(opts, Scrib_lib_text__json_util.Flag__try_fixing);
// KeyVal[] rv = json_util.Decode(json, opts);
// if (rv == null) throw Err_.new_("scribunto", "mw.text.jsonEncode: Unable to decode String " + String_.new_u8(json));
// if (!(Enm_.Has_int(flags, Scrib_lib_text__json_util.Flag__preserve_keys)))
// rv = json_util.Reindex_arrays(rv, false);
// return rslt.Init_obj(rv);
return false;
}
public void Notify_wiki_changed() {if (notify_wiki_changed_fnc != null) core.Interpreter().CallFunction(notify_wiki_changed_fnc.Id(), KeyVal_.Ary_empty);}
public boolean Init_text_for_wiki(Scrib_proc_args args, Scrib_proc_rslt rslt) {
@@ -75,22 +84,8 @@ public class Scrib_lib_text implements Scrib_lib {
rv[3] = KeyVal_.new_("nowiki_protocols", KeyVal_.Ary_empty); // NOTE: code implemented, but waiting for it to be used; DATE:2014-03-20
return rslt.Init_obj(rv);
}
public void Init_for_tests() {json_util.Init_for_tests();}
private String Init_lib_text_get_msg(Xow_msg_mgr msg_mgr, String msg_key) {
return String_.new_u8(msg_mgr.Val_by_key_obj(Bry_.new_u8(msg_key)));
}
}
class Scrib_lib_text__json_util {
public static KeyVal[] Reindex_arrays(KeyVal[] kv_ary, boolean is_encoding) {
return kv_ary;
}
public static final int
Flag__preserve_keys = 1
, Flag__try_fixing = 2
, Flag__pretty = 4
;
public static final int
Skip__utf8 = 1
, Skip__xml = 2
, Skip__all = 3
;
}

View File

@@ -0,0 +1,110 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import gplx.core.json.*;
class Scrib_lib_text__json_util {
private final Json_wtr wtr = new Json_wtr();
public void Init_for_tests() {wtr.Opt_quote_byte_(Byte_ascii.Apos);}
public KeyVal[] Reindex_arrays(KeyVal[] kv_ary, boolean is_encoding) {
int next = 0;
if (is_encoding) {
// ksort( $arr, SORT_NUMERIC );
next = 1;
}
boolean is_sequence = true;
int len = kv_ary.length;
for (int i = 0; i < len; ++i) {
KeyVal kv = kv_ary[i];
Object kv_val = kv.Val();
if (kv_val != null && Type_adp_.Eq(kv_val.getClass(), KeyVal[].class))
kv_val = Reindex_arrays((KeyVal[])kv_val, is_encoding);
if (is_sequence) {
if (kv.Key_tid() == KeyVal_.Key_tid_int) {
int kv_key_as_int = Int_.cast_(kv.Key_as_obj());
is_sequence = next++ == kv_key_as_int;
// } elseif ( $isEncoding && ctype_digit( $k ) ) {
// // json_decode currently doesn't return integer keys for {}
// $isSequence = $next++ === (int)$k;
} else {
is_sequence = false;
}
}
}
if (is_sequence) {
if (is_encoding) {
// return array_values( $arr );
} else {
// return $arr ? array_combine( range( 1, count( $arr ) ), $arr ) : $arr;
}
}
return kv_ary;
}
public KeyVal[] Decode(byte[] src, int flag) {
return null;
}
public byte[] Encode(KeyVal[] kv_ary, int flag, int skip) {
synchronized (wtr ) {
wtr.Clear().Doc_bgn();
Encode_kv_ary(kv_ary);
return wtr.Doc_end().To_bry_and_clear();
}
}
private void Encode_kv_ary(KeyVal[] kv_ary) {
int len = kv_ary.length;
for (int i = 0; i < len; ++i) {
KeyVal kv = kv_ary[i];
Encode_kv(kv);
}
}
private void Encode_kv(KeyVal kv) {
Object kv_val = kv.Val();
Class<?> type = Type_adp_.ClassOf_obj(kv_val);
if (Type_adp_.Eq(type, KeyVal[].class)) {
wtr.Nde_bgn(kv.Key());
Encode_kv_ary((KeyVal[])kv_val);
wtr.Nde_end();
}
else if (Type_adp_.Is_array(type)) { // encode as array
wtr.Ary_bgn(kv.Key());
Object ary = Array_.cast(kv_val);
int ary_len = Array_.Len(ary);
for (int j = 0; j < ary_len; ++j)
wtr.Ary_itm_obj(Array_.Get_at(ary, j));
wtr.Ary_end();
}
else if (Type_adp_.Eq(type, Int_.Cls_ref_type)) wtr.Kv_int(kv.Key(), Int_.cast_(kv_val));
else if (Type_adp_.Eq(type, Long_.Cls_ref_type)) wtr.Kv_long(kv.Key(), Long_.cast_(kv_val));
else if (Type_adp_.Eq(type, Float_.Cls_ref_type)) wtr.Kv_float(kv.Key(), Float_.cast_(kv_val));
else if (Type_adp_.Eq(type, Double_.Cls_ref_type)) wtr.Kv_double(kv.Key(), Double_.cast_(kv_val));
else if (Type_adp_.Eq(type, Bool_.Cls_ref_type)) wtr.Kv_bool(kv.Key(), Bool_.cast_(kv_val));
else wtr.Kv_str(kv.Key(), Object_.Xto_str_strict_or_null(kv_val));
}
public static final int
Flag__preserve_keys = 1
, Flag__try_fixing = 2
, Flag__pretty = 4
;
public static final int
Skip__utf8 = 1
, Skip__xml = 2
, Skip__all = 3
;
public static final int
Opt__force_assoc = 1
;
}

View File

@@ -18,10 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import org.junit.*;
public class Scrib_lib_text_tst {
private Scrib_invoke_func_fxt fxt = new Scrib_invoke_func_fxt(); private Scrib_lib_text lib;
@Before public void init() {
fxt.Clear_for_lib();
lib = fxt.Core().Lib_text().Init();
} private Scrib_invoke_func_fxt fxt = new Scrib_invoke_func_fxt(); private Scrib_lib lib;
lib = fxt.Core().Lib_text();
lib.Init();
lib.Init_for_tests();
}
@Test public void Unstrip() {
fxt.Test_scrib_proc_str(lib, Scrib_lib_text.Invk_unstrip, Object_.Ary("a"), "a");
}
@@ -29,4 +32,45 @@ public class Scrib_lib_text_tst {
KeyVal[] actl = fxt.Test_scrib_proc_rv_as_kv_ary(lib, Scrib_lib_text.Invk_getEntityTable, Object_.Ary());
Tfds.Eq(1510, actl.length); // large result; only test # of entries
}
}
// @Test public void JsonEncode() {
// fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_text.Invk_jsonEncode, Object_.Ary((Object)Kv_ary_utl.new_
// ( true
// , true
// , 1
// , "a"
// , new int[] {1, 2, 3}
// , Kv_ary_utl.new_(true, "b")
// )), String_.Concat_lines_nl_skip_last
// ( "1="
// + "{ '1':true"
// , ", '2':1"
// , ", '3':'a'"
// , ", '4':"
// , " [ 1"
// , " , 2"
// , " , 3"
// , " ]"
// , ", '5':"
// , " { '1':'b'"
// , " }"
// , "}"
// ));
// }
}
class Kv_ary_utl {
public static KeyVal[] new_(boolean base_1, Object... vals) {
int len = vals.length;
KeyVal[] rv = new KeyVal[len];
for (int i = 0; i < len; ++i)
rv[i] = KeyVal_.int_(i + (base_1 ? 1 : 0), vals[i]);
return rv;
}
}
// class Scrib_lib_text_fxt {
// public void Test_json_decode(Scrib_invoke_func_fxt fxt, Scrib_lib_text lib, KeyVal[] kv_ary, String expd) {
// fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_text.Invk_jsonEncode, Object_.Ary((Object)Scrib_lib_language_tst.Kv_ary_("a")), String_.Concat_lines_nl_skip_last
// ( "1={ '0':'a'"
// , "}"
// ));
// }
// }

View File

@@ -101,7 +101,7 @@ public class Scrib_lib_title implements Scrib_lib {
// private static final byte[] Proto_relative = Bry_.new_a7("relative");
// private static final Hash_adp_bry proto_hash = Hash_adp_bry.ci_a7().Add_str_obj("http", Bry_.new_a7("http://")).Add_str_obj("https", Bry_.new_a7("https://")).Add_str_obj("relative", Bry_.new_a7("//")).Add_str_obj("canonical", Bry_.new_a7("1"));
private byte[] Parse_ns(Xowe_wiki wiki, Object ns_obj) {
if (ClassAdp_.Eq_typeSafe(ns_obj, String.class))
if (Type_adp_.Eq_typeSafe(ns_obj, String.class))
return Bry_.new_u8(String_.cast_(ns_obj));
else {
int ns_id = Int_.cast_(ns_obj);

View File

@@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import org.junit.*;
import gplx.dbs.*; import gplx.xowa2.files.commons.*; import gplx.xowa.wikis.data.*;
import gplx.fsdb.*; import gplx.xowa.wikis.*; import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.repos.*;
import gplx.fsdb.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.repos.*;
public class Scrib_lib_title_tst {
@Before public void init() {
Db_conn_bldr.I.Reg_default_mem();
@@ -67,7 +68,7 @@ public class Scrib_lib_title_tst {
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_exists("A.png", 220, 200));
}
@Test public void GetFileInfo_commons() { // PURPOSE: check that Scribunto GetFileInfo calls filepath.FileExists; DATE:2014-01-07
Xowe_wiki commons_wiki = fxt.Parser_fxt().Wiki().Appe().Wiki_mgr().Get_by_key_or_make(Xow_domain_.Domain_bry_commons).Init_assert();
Xowe_wiki commons_wiki = fxt.Parser_fxt().Wiki().Appe().Wiki_mgr().Get_by_key_or_make(Xow_domain_itm_.Bry__commons).Init_assert();
Wiki_orig_tbl__create(fxt.Core().Wiki());
Wiki_orig_tbl__insert(fxt.Core().Wiki(), "A.png", 220, 200);
fxt.Parser_fxt().Init_page_create(commons_wiki, "File:A.png", "text_is_blank");

View File

@@ -209,7 +209,7 @@ class Scrib_lib_ustring_gsub_mgr {
tmp_repl_tid = Repl_tid_luacbk;
repl_func = (Scrib_lua_proc)repl_obj;
}
else throw Err_.new_unhandled(ClassAdp_.NameOf_type(repl_type));
else throw Err_.new_unhandled(Type_adp_.NameOf_type(repl_type));
}
private String Exec_repl(byte repl_tid, byte[] repl_bry, String text, String regx, int limit) {
Regx_adp regx_mgr = Scrib_lib_ustring.RegxAdp_new_(core.Ctx(), regx);

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import gplx.core.json.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.parsers.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wikis.domains.*;
public class Scrib_lib_wikibase implements Scrib_lib {
public Scrib_lib_wikibase(Scrib_core core) {this.core = core;} private Scrib_core core;
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
@@ -85,10 +85,7 @@ public class Scrib_lib_wikibase implements Scrib_lib {
public boolean GetSiteLinkPageName(Scrib_proc_args args, Scrib_proc_rslt rslt) {
byte[] ttl_bry = args.Pull_bry(0); if (Bry_.Len_eq_0(ttl_bry)) return rslt.Init_ary_empty();
Wdata_doc wdoc = Get_wdoc(ttl_bry); if (wdoc == null) return rslt.Init_ary_empty();
Xow_domain domain_itm = core.Wiki().Domain_itm();
if (domain_itm.Abrv_wm() == null) {
domain_itm.Abrv_wm_(Xow_wiki_alias.Build_alias(domain_itm));
}
Xow_domain_itm domain_itm = core.Wiki().Domain_itm();
return rslt.Init_obj(wdoc.Slink_list__get_or_fallback(domain_itm.Abrv_wm()));
}
public boolean IncrementExpensiveFunctionCount(Scrib_proc_args args, Scrib_proc_rslt rslt) {return rslt.Init_obj(KeyVal_.Ary_empty);} // NOTE: for now, always return null (XOWA does not care about expensive parser functions)

View File

@@ -410,8 +410,8 @@ class Scrib_lib_wikibase_srl_fxt {
Object kv_val = kv.Val();
if (kv_val == null) {bfr.Add_str_a7("null").Add_byte_nl(); return;}
Class<?> kv_val_cls = kv_val.getClass();
if (ClassAdp_.Eq(kv_val_cls, KeyVal[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (KeyVal[])kv_val, depth + 1);}
else if (ClassAdp_.Eq(kv_val_cls, KeyVal[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (KeyVal)kv_val, depth + 1);}
if (Type_adp_.Eq(kv_val_cls, KeyVal[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (KeyVal[])kv_val, depth + 1);}
else if (Type_adp_.Eq(kv_val_cls, KeyVal[].class)) {bfr.Add_byte_nl(); Xto_str(bfr, (KeyVal)kv_val, depth + 1);}
else bfr.Add_byte(Byte_ascii.Apos).Add_str(Object_.Xto_str_strict_or_empty(kv_val)).Add_byte(Byte_ascii.Apos).Add_byte_nl();
}
}

View File

@@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.primitives.*;
import gplx.core.json.*; import gplx.xowa.wikis.*; import gplx.xowa.html.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.apis.xowa.xtns.*; import gplx.xowa.apis.xowa.html.*; import gplx.xowa.users.*;
import gplx.core.json.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.html.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.apis.xowa.xtns.*; import gplx.xowa.apis.xowa.html.*; import gplx.xowa.users.*;
import gplx.xowa.xtns.wdatas.parsers.*; import gplx.xowa.xtns.wdatas.pfuncs.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.hwtrs.*;
public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
private final Wdata_doc_parser wdoc_parser_v1, wdoc_parser_v2;
@@ -53,7 +54,7 @@ public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
doc_cache.Clear();
}
public void Qids_add(Bry_bfr bfr, byte[] lang_key, int wiki_tid, byte[] ns_num, byte[] ttl, byte[] qid) {
Xow_wiki_alias.Build_alias_by_lang_tid(bfr, lang_key, wiki_tid_ref.Val_(wiki_tid));
Xow_abrv_wm_.To_abrv(bfr, lang_key, wiki_tid_ref.Val_(wiki_tid));
byte[] qids_key = bfr.Add_byte(Byte_ascii.Pipe).Add(ns_num).Add_byte(Byte_ascii.Pipe).Add(ttl).Xto_bry();
qids_cache.Add(qids_key, qid);
}
@@ -172,7 +173,7 @@ public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
GfoEvMgr_.SubSame_many(app.Usere(), this, Xoue_user.Evt_lang_changed);
}
private void Hwtr_msgs_make() {
if (!app.Wiki_mgr().Wiki_regy().Has(Xow_domain_.Domain_bry_wikidata)) return;
if (!app.Wiki_mgr().Wiki_regy().Has(Xow_domain_itm_.Bry__wikidata)) return;
Xol_lang new_lang = app.Usere().Lang();
Xowe_wiki cur_wiki = this.Wdata_wiki();
cur_wiki.Xtn_mgr().Xtn_wikibase().Load_msgs(cur_wiki, new_lang);
@@ -219,11 +220,11 @@ public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
public static final byte[] Html_json_id = Bry_.new_a7("xowa-wikidata-json");
public static boolean Wiki_page_is_json(int wiki_tid, int ns_id) {
switch (wiki_tid) {
case Xow_domain_type_.Tid_wikidata:
case Xow_domain_type_.Int__wikidata:
if (ns_id == Xow_ns_.Id_main || ns_id == gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Ns_property)
return true;
break;
case Xow_domain_type_.Tid_home:
case Xow_domain_type_.Int__home:
if (ns_id == gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Ns_property)
return true;
break;

View File

@@ -16,7 +16,9 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.json.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
import gplx.core.json.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*;
import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
public Wdata_xwiki_link_wtr Page_(Xoae_page page) {this.page = page; return this;} private Xoae_page page;
public void XferAry(Bry_bfr bfr, int idx) {
@@ -29,8 +31,8 @@ public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
public static byte[] Write_wdata_links(List_adp slink_list, Xowe_wiki wiki, Xoa_ttl ttl, Wdata_external_lang_links_data external_links_mgr) {
try {
switch (wiki.Domain_tid()) {
case Xow_domain_type_.Tid_home: // home will never be in wikidata
case Xow_domain_type_.Tid_wikidata: // wikidata will never be in wikidata
case Xow_domain_type_.Int__home: // home will never be in wikidata
case Xow_domain_type_.Int__wikidata: // wikidata will never be in wikidata
return Qid_null;
}
Wdata_wiki_mgr wdata_mgr = wiki.Appe().Wiki_mgr().Wdata_mgr();
@@ -38,18 +40,17 @@ public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
boolean external_links_mgr_enabled = external_links_mgr.Enabled();
Ordered_hash links = doc.Slink_list();
Bry_bfr tmp_bfr = wiki.Appe().Utl__bfr_mkr().Get_k004();
Xow_wiki_abrv wiki_abrv = new Xow_wiki_abrv();
int len = links.Count();
for (int i = 0; i < len; i++) {
Wdata_sitelink_itm slink = (Wdata_sitelink_itm)links.Get_at(i);
byte[] xwiki_key = slink.Site();
Xow_wiki_abrv_.parse_(wiki_abrv, xwiki_key, 0, xwiki_key.length);
if (wiki_abrv.Domain_tid() == Xow_wiki_abrv_.Tid_null) {
Xow_abrv_wm abrv_itm = Xow_abrv_wm_.Parse_to_abrv_or_null(xwiki_key);
if (abrv_itm == null) {
wiki.Appe().Usr_dlg().Warn_many("", "", "unknown wiki in wikidata: ttl=~{0} wiki=~{1}", ttl.Page_db_as_str(), String_.new_u8(xwiki_key));
continue;
}
if (wiki_abrv.Domain_tid() != wiki.Domain_tid()) continue; // ignore wikis in a different domain; EX: looking at enwiki:Earth, and wikidata has dewikiquote; ignore dewikiquote; DATE:2014-06-21
byte[] lang_key = wiki_abrv.Lang_itm().Key();
if (abrv_itm.Domain_type() != wiki.Domain_tid()) continue; // ignore wikis in a different domain; EX: looking at enwiki:Earth, and wikidata has dewikiquote; ignore dewikiquote; DATE:2014-06-21
byte[] lang_key = abrv_itm.Lang_actl().Key();
if (external_links_mgr_enabled && external_links_mgr.Langs_hide(lang_key, 0, lang_key.length)) continue;
tmp_bfr.Add(lang_key);
tmp_bfr.Add_byte(Byte_ascii.Colon);

View File

@@ -16,18 +16,19 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.core.json.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.core.json.*;
import gplx.xowa.wikis.domains.*;
public class Wdata_xwiki_link_wtr_tst {
@Before public void init() {fxt.Init();} Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt();
@Test public void Skip_xwiki_lang_for_self() { // PURPOSE: list of language links should not include self
fxt.Init_xwikis_add("en", "fr", "de");
fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, "Q1_en", "Q1");
fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, "Q1_en", "Q1");
fxt.Init_pages_add(fxt.Wdoc_bldr("Q1").Add_sitelink("enwiki", "Q1_en").Add_sitelink("frwiki", "Q1_fr").Add_sitelink("dewiki", "Q1_de").Xto_wdoc());
fxt.Test_xwiki_links("Q1_en", "Q1_fr", "Q1_de");
}
@Test public void No_external_lang_links__de() {
fxt.Init_xwikis_add("fr", "de");
fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, "Q1_en", "Q1");
fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, "Q1_en", "Q1");
fxt.Init_pages_add(fxt.Wdoc_bldr("Q1").Add_sitelink("enwiki", "Q1_en").Add_sitelink("frwiki", "Q1_fr").Add_sitelink("dewiki", "Q1_de").Xto_wdoc());
fxt.Init_external_links_mgr_add("de");
fxt.Test_xwiki_links("Q1_en", "Q1_de");
@@ -48,7 +49,7 @@ public class Wdata_xwiki_link_wtr_tst {
}
@Test public void Links_w_name_fmt() { // PURPOSE: wikidata changed links node from "enwiki:A" to "enwiki:{name:A,badges:[]}"; DATE:2013-09-14
fxt.Init_xwikis_add("en", "fr", "de");
fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, "Q1_en", "Q1");
fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, "Q1_en", "Q1");
Json_doc jdoc = Json_doc.new_(String_.Concat_lines_nl
( "{ \"entity\":\"q1\""
, ", \"links\":"
@@ -63,7 +64,7 @@ public class Wdata_xwiki_link_wtr_tst {
}
@Test public void Same_lang_but_different_domains() { // PURPOSE: if two entries for same lang, but one is in different domain, use the one for the current wiki DATE:2014-06-21
fxt.Init_xwikis_add("en", "fr", "de");
fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, "Q1_en", "Q1");
fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, "Q1_en", "Q1");
Json_doc jdoc = Json_doc.new_(String_.Concat_lines_nl
( "{ \"entity\":\"q1\""
, ", \"links\":"
@@ -79,7 +80,7 @@ public class Wdata_xwiki_link_wtr_tst {
}
@Test public void Badges() {
fxt.Init_xwikis_add("de", "fr", "pl");
fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, "Q1_en", "Q1");
fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, "Q1_en", "Q1");
fxt.Init_pages_add
( fxt.Wdoc_bldr("Q1")
.Add_sitelink("enwiki", "Q1_en")
@@ -120,7 +121,7 @@ public class Wdata_xwiki_link_wtr_tst {
// @Test public void No_external_lang_links__sort() {
// fxt.Init_xwikis_add("de", "fr");
// fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, "Q1_en", "Q1");
// fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, "Q1_en", "Q1");
// fxt.Init_pages_add("Q1", fxt.page_bldr_("Q1").Add_sitelink("enwiki", "Q1_en").Add_sitelink("frwiki", "Q1_fr").Add_sitelink("dewiki", "Q1_de").Xto_page_doc());
// fxt.Init_external_links_mgr_add("*");
// fxt.Test_xwiki_links("Q1_en", "Q1_de", "Q1_fr");

View File

@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import gplx.core.json.*; import gplx.xowa.wikis.*;
import gplx.core.json.*;
import gplx.xowa.wikis.domains.*;
public class Wdata_sitelink_itm implements Wdata_lang_sortable {
public Wdata_sitelink_itm(byte[] site, byte[] name, byte[][] badges) {this.site = site; this.name = name; this.badges = badges;}
public byte[] Site() {return site;} private final byte[] site;
@@ -25,7 +26,7 @@ public class Wdata_sitelink_itm implements Wdata_lang_sortable {
public byte[] Lang() {return lang;} public void Lang_(byte[] v) {lang = v;} private byte[] lang = Bry_.Empty;
public byte[] Lang_code() {return lang;}
public int Lang_sort() {return lang_sort;} public void Lang_sort_(int v) {lang_sort = v;} private int lang_sort = Wdata_lang_sorter.Sort_null;
public Xow_domain Domain_info() {if (domain_info == null) domain_info = Xow_wiki_alias.parse_by_wmf_key(site); return domain_info;} private Xow_domain domain_info;
public Xow_domain_itm Domain_info() {if (domain_info == null) domain_info = Xow_abrv_wm_.Parse_to_domain_itm(site); return domain_info;} private Xow_domain_itm domain_info;
public Xoa_ttl Page_ttl() {return page_ttl;} public Wdata_sitelink_itm Page_ttl_(Xoa_ttl v) {page_ttl = v; return this;} private Xoa_ttl page_ttl; // PERF: cache title to avoid creating new Object for "In Other langs"; DATE:2014-10-20
@Override public String toString() {// TEST:
return String_.Concat_with_str("|", String_.new_u8(site), String_.new_u8(name), String_.Concat_with_str(",", String_.Ary(badges)));

View File

@@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.hwtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import gplx.html.*;
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.wikis.*; import gplx.xowa.apis.xowa.html.*; import gplx.xowa.wikis.xwikis.*;
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.core.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.apis.xowa.html.*; import gplx.xowa.wikis.xwikis.*;
class Wdata_fmtr__slink_grp implements Bry_fmtr_arg {
private final Wdata_fmtr__slink_tbl fmtr_tbl = new Wdata_fmtr__slink_tbl(); private boolean is_empty;
public void Init_by_ctor(Wdata_lang_sorter lang_sorter, Xoapi_toggle_mgr toggle_mgr, Wdata_lbl_mgr lbl_regy, Url_encoder href_encoder, Wdata_fmtr__toc_div fmtr_toc, Xow_xwiki_mgr xwiki_mgr) {
@@ -109,9 +110,9 @@ class Wdata_fmtr__slink_row implements Bry_fmtr_arg {
int len = list.Count();
for (int i = 0; i < len; ++i) {
Wdata_sitelink_itm itm = (Wdata_sitelink_itm)list.Get_at(i);
Xow_domain domain_info = itm.Domain_info();
Xow_domain_itm domain_info = itm.Domain_info();
byte[] wmf_key = domain_info.Abrv_wm();
Xol_lang_itm lang_itm = domain_info.Lang_itm();
Xol_lang_itm lang_itm = domain_info.Lang_actl_itm();
byte[] lang_key = lang_itm.Key();
byte[] lang_name = lang_itm.Localized_name();
byte[] domain_bry = domain_info.Domain_bry();

View File

@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.hwtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.langs.msgs.*; import gplx.xowa.wikis.*;
import gplx.xowa.langs.msgs.*;
import gplx.xowa.wikis.domains.*;
public class Wdata_hwtr_msgs {
public Wdata_hwtr_msgs(byte[][] brys) { int offset = 0; // String[] strs = String_.Ary(brys); // TEST
this.ary = brys;
@@ -85,14 +86,14 @@ public class Wdata_hwtr_msgs {
geo_meters = brys[offset + 7];
Bry_fmtr fmtr = Bry_fmtr.new_( slink_tbl_hdr_fmt, "wiki_type");
Bry_bfr bfr = Bry_bfr.new_(64);
slink_tbl_hdr_w = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikipedia));
slink_tbl_hdr_d = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wiktionary));
slink_tbl_hdr_s = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikisource));
slink_tbl_hdr_v = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikivoyage));
slink_tbl_hdr_q = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikiquote));
slink_tbl_hdr_b = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikibooks));
slink_tbl_hdr_u = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikiversity));
slink_tbl_hdr_n = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Key_bry_wikinews));
slink_tbl_hdr_w = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikipedia));
slink_tbl_hdr_d = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wiktionary));
slink_tbl_hdr_s = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikisource));
slink_tbl_hdr_v = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikivoyage));
slink_tbl_hdr_q = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikiquote));
slink_tbl_hdr_b = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikibooks));
slink_tbl_hdr_u = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikiversity));
slink_tbl_hdr_n = fmtr.Bld_bry_many(bfr, Name_(Xow_domain_type_.Bry__wikinews));
slink_tbl_hdr_x = fmtr.Bld_bry_many(bfr, slink_tbl_hdr_fmt_other);
}
public byte[][] Ary() {return ary;} private final byte[][] ary;

View File

@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.hwtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.wikis.*; import gplx.xowa.apis.xowa.html.*;
import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.apis.xowa.html.*;
import gplx.xowa.wikis.domains.*;
class Wdata_slink_grp {
public Wdata_slink_grp(int tid, byte[] wiki_name, Xoapi_toggle_itm toggle_itm, Wdata_toc_data toc_data) {
this.tid = tid; this.wiki_name = wiki_name; this.toggle_itm = toggle_itm; this.toc_data = toc_data;
@@ -32,20 +33,20 @@ class Wdata_slink_grp {
int list_len = list.Count();
for (int i = 0; i < list_len; ++i) {
Wdata_sitelink_itm itm = (Wdata_sitelink_itm)list.Get_at(i);
int idx = Idx_by_tid(itm.Domain_info().Domain_tid());
int idx = Idx_by_tid(itm.Domain_info().Domain_type_id());
rv[idx].Rows().Add(itm.Site(), itm);
}
}
public static int Idx_by_tid(int tid) {
switch (tid) {
case Xow_domain_type_.Tid_wikipedia: return Idx_w;
case Xow_domain_type_.Tid_wiktionary: return Idx_d;
case Xow_domain_type_.Tid_wikisource: return Idx_s;
case Xow_domain_type_.Tid_wikivoyage: return Idx_v;
case Xow_domain_type_.Tid_wikiquote: return Idx_q;
case Xow_domain_type_.Tid_wikibooks: return Idx_b;
case Xow_domain_type_.Tid_wikiversity: return Idx_u;
case Xow_domain_type_.Tid_wikinews: return Idx_n;
case Xow_domain_type_.Int__wikipedia: return Idx_w;
case Xow_domain_type_.Int__wiktionary: return Idx_d;
case Xow_domain_type_.Int__wikisource: return Idx_s;
case Xow_domain_type_.Int__wikivoyage: return Idx_v;
case Xow_domain_type_.Int__wikiquote: return Idx_q;
case Xow_domain_type_.Int__wikibooks: return Idx_b;
case Xow_domain_type_.Int__wikiversity: return Idx_u;
case Xow_domain_type_.Int__wikinews: return Idx_n;
default: return Idx_x;
}
}
@@ -65,14 +66,14 @@ class Wdata_slink_grp {
}
public static byte[] Name_by_tid(int idx) {
switch (idx) {
case Idx_w: return Xow_domain_type_.Key_bry_wikipedia;
case Idx_d: return Xow_domain_type_.Key_bry_wiktionary;
case Idx_s: return Xow_domain_type_.Key_bry_wikisource;
case Idx_v: return Xow_domain_type_.Key_bry_wikivoyage;
case Idx_q: return Xow_domain_type_.Key_bry_wikiquote;
case Idx_b: return Xow_domain_type_.Key_bry_wikibooks;
case Idx_u: return Xow_domain_type_.Key_bry_wikiversity;
case Idx_n: return Xow_domain_type_.Key_bry_wikinews;
case Idx_w: return Xow_domain_type_.Bry__wikipedia;
case Idx_d: return Xow_domain_type_.Bry__wiktionary;
case Idx_s: return Xow_domain_type_.Bry__wikisource;
case Idx_v: return Xow_domain_type_.Bry__wikivoyage;
case Idx_q: return Xow_domain_type_.Bry__wikiquote;
case Idx_b: return Xow_domain_type_.Bry__wikibooks;
case Idx_u: return Xow_domain_type_.Bry__wikiversity;
case Idx_n: return Xow_domain_type_.Bry__wikinews;
case Idx_x: return Name_special;
default: throw Err_.new_unhandled(idx);
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import gplx.dbs.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.wmfs.data.*;
class Xob_wbase_ns_parser {
private final Hash_adp_bry ns_mgr_hash = Hash_adp_bry.cs();
@@ -32,7 +32,7 @@ class Xob_wbase_ns_parser {
int colon_pos = Bry_finder.Find_fwd(ttl, Byte_ascii.Colon, 0, ttl_len); if (colon_pos == Bry_finder.Not_found) return;
if (ns_mgr == null) { // ns_mgr not found; load from db
wiki_abrv = Bry_.Replace(wiki_abrv, Byte_ascii.Underline, Byte_ascii.Dash);
byte[] wiki_domain = Xow_wiki_alias.Parse__domain_name(wiki_abrv, 0, wiki_abrv.length);
byte[] wiki_domain = Xow_abrv_wm_.Parse_to_domain_bry(wiki_abrv);
ns_mgr = core_db.Load_ns(wiki_domain);
if (ns_mgr.Count() == 0) {Xoa_app_.Usr_dlg().Warn_many("", "", "wbase.ns_parser:no ns found; abrv=~{0}", wiki_abrv); return;}
ns_mgr_hash.Add_bry_obj(wiki_abrv, ns_mgr);

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import gplx.core.net.*;
import gplx.xowa.wikis.*; import gplx.xowa.specials.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.specials.*;
import gplx.xowa.urls.*;
public class Wdata_itemByTitle_page implements Xows_page {
private Gfo_qarg_mgr arg_hash = new Gfo_qarg_mgr();
@@ -57,8 +57,8 @@ public class Wdata_itemByTitle_page implements Xows_page {
}
private static boolean Navigate(Gfo_usr_dlg usr_dlg, Xoae_app app, Wdata_wiki_mgr wdata_mgr, Xoae_page page, byte[] site_bry, byte[] page_bry) {
page_bry = Xoa_app_.Utl__encoder_mgr().Http_url().Decode(page_bry); // NOTE: space is converted to + on postback to url; decode
byte[] wiki_domain = Xow_wiki_alias.Parse_wmf_key(site_bry); if (wiki_domain == null) {usr_dlg.Warn_many("", "", "site_bry parse failed; site_bry:~{0}", String_.new_u8(site_bry)); return false;}
Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(wiki_domain); if (wiki == null) {usr_dlg.Warn_many("", "", "wiki_domain does not exist; wiki_domain:~{0}", String_.new_u8(wiki_domain)); return false;}
byte[] wiki_domain = Xow_abrv_wm_.Parse_to_domain_bry(site_bry); if (wiki_domain == null) {usr_dlg.Warn_many("", "", "site_bry parse failed; site_bry:~{0}", String_.new_u8(site_bry)); return false;}
Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(wiki_domain); if (wiki == null) {usr_dlg.Warn_many("", "", "wiki_domain does not exist; wiki_domain:~{0}", String_.new_u8(wiki_domain)); return false;}
Xoa_ttl wdata_ttl = Xoa_ttl.parse_(wiki, page_bry); if (wdata_ttl == null) {usr_dlg.Warn_many("", "", "ttl is invalid; ttl:~{0}", String_.new_u8(page_bry)); return false;}
Wdata_doc doc = wdata_mgr.Pages_get(wiki, wdata_ttl); if (doc == null) {usr_dlg.Warn_many("", "", "ttl cannot be found in wikidata; ttl:~{0}", String_.new_u8(wdata_ttl.Raw())); return false;}
byte[] qid_bry = doc.Qid();

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
import org.junit.*; import gplx.xowa.wikis.*;
import org.junit.*; import gplx.xowa.wikis.domains.*;
public class Wdata_itemByTitle_page_tst {
@Before public void init() {fxt.Clear();} private Wdata_itemByTitle_page_fxt fxt = new Wdata_itemByTitle_page_fxt();
@Test public void Url() {
@@ -57,7 +57,7 @@ class Wdata_itemByTitle_page_fxt {
parser_fxt.Init_page_create(app.Wiki_mgr().Wdata_mgr().Wdata_wiki(), qid_ttl, text);
}
public void Init_wdata_label(String wmf_key_str, String wdata_label, String qid) {
wdata_fxt.Init_qids_add("en", Xow_domain_type_.Tid_wikipedia, wdata_label, qid);
wdata_fxt.Init_qids_add("en", Xow_domain_type_.Int__wikipedia, wdata_label, qid);
}
public void Test_open(String link, String expd) {
Xoae_page page = wiki.Ctx().Cur_page();