mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v1.9.4.1
This commit is contained in:
parent
985863b224
commit
314de43d76
@ -955,6 +955,15 @@ public class Bry_ {
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
public static byte[] Lower_1st(byte[] ary) {
|
||||
if (ary == null) return null;
|
||||
int len = ary.length;
|
||||
if (len == 0) return ary;
|
||||
byte b = ary[0];
|
||||
if (b > 64 && b < 91)
|
||||
ary[0] = (byte)(b + 32);
|
||||
return ary;
|
||||
}
|
||||
public static byte[] Lower_ascii(byte[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
@ -50,11 +50,19 @@ public class Bry_bfr_mkr {
|
||||
}
|
||||
}
|
||||
class Bry_bfr_mkr_mgr {
|
||||
public Bry_bfr_mkr_mgr(byte mgr_id, int reset) {this.mgr_id = mgr_id; this.reset = reset;} private int reset;
|
||||
private final Object thread_lock;
|
||||
public Bry_bfr_mkr_mgr(byte mgr_id, int reset) {// 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
|
||||
thread_lock = new Object();
|
||||
synchronized (thread_lock) {
|
||||
this.mgr_id = mgr_id;
|
||||
this.reset = reset;
|
||||
this.free = Int_.Ary_empty;
|
||||
this.free_len = 0;
|
||||
}
|
||||
} private int reset;
|
||||
public byte Mgr_id() {return mgr_id;} private byte mgr_id;
|
||||
private Bry_bfr[] ary = Ary_empty; private int nxt_idx = 0, ary_max = 0;
|
||||
private int[] free = Int_.Ary_empty; private int free_len = 0;
|
||||
private Object thread_lock = new Object();
|
||||
private int[] free; private int free_len;
|
||||
public void Reset_if_gt(int v) {
|
||||
this.Clear(); // TODO: for now, just call clear
|
||||
}
|
||||
@ -94,13 +102,14 @@ class Bry_bfr_mkr_mgr {
|
||||
Bry_bfr rv = null;
|
||||
int rv_idx = -1;
|
||||
if (free_len > 0) {
|
||||
rv_idx = free[--free_len];
|
||||
rv = ary[rv_idx];
|
||||
try {rv_idx = free[--free_len];}
|
||||
catch (Exception e) {throw Err_.new_("failed to get free index; free_len={0} free.length={1} err={2}", free_len, free.length, Err_.Message_lang(e));}
|
||||
try {rv = ary[rv_idx];}
|
||||
catch (Exception e) {throw Err_.new_("failed to get bfr; rv_idx={0} ary.length={1} err={2}", rv_idx, ary.length, Err_.Message_lang(e));}
|
||||
}
|
||||
else {
|
||||
if (nxt_idx == ary_max) {
|
||||
if (nxt_idx == ary_max)
|
||||
Expand();
|
||||
}
|
||||
rv_idx = nxt_idx++;
|
||||
rv = ary[rv_idx];
|
||||
if (rv == null) {
|
||||
|
@ -254,4 +254,5 @@ public class Int_ implements GfoInvkAble {
|
||||
rv[i] = Int_.parse_(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public static byte[] Xto_bry(int v) {return Bry_.new_ascii_(Xto_str(v));}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ public class Hash_adp_bry extends gplx.lists.HashAdp_base implements HashAdp {
|
||||
@Override protected boolean Has_base(Object key) {return super.Has_base(key_ref.Init((byte[])key));}
|
||||
public Object Get_by_bry(byte[] src) {return super.Fetch_base(key_ref.Init(src));}
|
||||
public Object Get_by_mid(byte[] src, int bgn, int end) {return super.Fetch_base(key_ref.Init(src, bgn, end));}
|
||||
public Hash_adp_bry Add_bry_byte(byte[] key, byte val) {this.Add_base(key, Byte_obj_val.new_(val)); return this;}
|
||||
public Hash_adp_bry Add_bry_bry(byte[] key) {this.Add_base(key, key); return this;}
|
||||
public Hash_adp_bry Add_str_byte(String key, byte val) {this.Add_base(Bry_.new_utf8_(key), Byte_obj_val.new_(val)); return this;}
|
||||
public Hash_adp_bry Add_str_obj(String key, Object val) {this.Add_base(Bry_.new_utf8_(key), val); return this;}
|
||||
public Hash_adp_bry Add_bry_byte(byte[] key, byte val) {this.Add_base(key, Byte_obj_val.new_(val)); return this;}
|
||||
public Hash_adp_bry Add_bry_obj(byte[] key, Object val) {this.Add_base(key, val); return this;}
|
||||
public Hash_adp_bry Add_many_str(String... ary) {
|
||||
int ary_len = ary.length;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_provider {
|
||||
@gplx.Internal protected Db_provider(Db_engine engine) {
|
||||
public Db_provider(Db_engine engine) {
|
||||
this.engine = engine;
|
||||
this.txn_mgr = new Db_txn_mgr_base(engine);
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ class Db_rdr__basic implements Db_rdr {
|
||||
try {return rdr.next();}
|
||||
catch (Exception e) {throw Err_.new_fmt_("move_next failed; check column casting error in SQL: err={0} sql={1}", Err_.Message_lang(e), sql);}
|
||||
}
|
||||
public byte[] Read_bry(int i) {try {return rdr.getBytes(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Bry_.Cls_name, Err_.Message_lang(e));}}
|
||||
public byte[] Read_bry_by_str(int i) {try {return Bry_.new_utf8_(rdr.getString(i));} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, String_.Cls_name, Err_.Message_lang(e));}}
|
||||
public String Read_str(int i) {try {return rdr.getString(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, String_.Cls_name, Err_.Message_lang(e));}}
|
||||
public int Read_int(int i) {try {return rdr.getInt(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Int_.Cls_name, Err_.Message_lang(e));}}
|
||||
public long Read_long(int i) {try {return rdr.getLong(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Long_.Cls_name, Err_.Message_lang(e));}}
|
||||
public float Read_float(int i) {try {return rdr.getFloat(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Float_.Cls_name, Err_.Message_lang(e));}}
|
||||
public double Read_double(int i) {try {return rdr.getDouble(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Double_.Cls_name, Err_.Message_lang(e));}}
|
||||
public byte Read_byte(int i) {try {return rdr.getByte(i);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Byte_.Cls_name, Err_.Message_lang(e));}}
|
||||
public byte[] Read_bry(int i) {try {return rdr.getBytes(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Bry_.Cls_name, Err_.Message_lang(e));}}
|
||||
public byte[] Read_bry_by_str(int i) {try {return Bry_.new_utf8_(rdr.getString(i + 1));} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, String_.Cls_name, Err_.Message_lang(e));}}
|
||||
public String Read_str(int i) {try {return rdr.getString(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, String_.Cls_name, Err_.Message_lang(e));}}
|
||||
public int Read_int(int i) {try {return rdr.getInt(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Int_.Cls_name, Err_.Message_lang(e));}}
|
||||
public long Read_long(int i) {try {return rdr.getLong(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Long_.Cls_name, Err_.Message_lang(e));}}
|
||||
public float Read_float(int i) {try {return rdr.getFloat(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Float_.Cls_name, Err_.Message_lang(e));}}
|
||||
public double Read_double(int i) {try {return rdr.getDouble(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Double_.Cls_name, Err_.Message_lang(e));}}
|
||||
public byte Read_byte(int i) {try {return rdr.getByte(i + 1);} catch (Exception e) {throw Err_.new_("read failed: i={0} type={1} err={2}", i, Byte_.Cls_name, Err_.Message_lang(e));}}
|
||||
public void Close() {try {rdr.close();} catch (Exception e) {throw Err_.new_("close failed: err={0}", Err_.Message_lang(e));}}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class Db_qry__select_in_tbl implements Db_qry {
|
||||
}
|
||||
public String Group_by_sql() {return group_by_sql;} private final String group_by_sql;
|
||||
public String Having_sql() {return having_sql;} private final String having_sql;
|
||||
public String Order_by_sql() {return order_by_sql;} private final String order_by_sql;
|
||||
public String Order_by_sql() {return order_by_sql;} public Db_qry__select_in_tbl Order_by_sql_(String v) {order_by_sql = v; return this;} private String order_by_sql;
|
||||
public String Limit_sql() {return limit_sql;} private final String limit_sql;
|
||||
public static Db_qry__select_in_tbl new_(String tbl_name, String[] where_flds, String[] select_flds) {return new Db_qry__select_in_tbl(tbl_name, select_flds, where_flds, null, null, null, null);}
|
||||
public String KeyOfDb_qry() {return "select_in_tbl";}
|
||||
@ -49,12 +49,13 @@ public class Db_qry__select_in_tbl implements Db_qry {
|
||||
if (i != 0) sb.Add(",");
|
||||
sb.Add(select_flds[i]);
|
||||
}
|
||||
sb.Add(" FROM ").Add(tbl_name).Add(" ");
|
||||
if (where_flds != null) {sb.Add("WHERE "); Where_sql(sb);}
|
||||
sb.Add(" FROM ").Add(tbl_name);
|
||||
if (where_flds != null) {sb.Add(" WHERE "); Where_sql(sb);}
|
||||
if (group_by_sql != null) sb.Add(group_by_sql);
|
||||
if (having_sql != null) sb.Add(having_sql);
|
||||
if (order_by_sql != null) sb.Add(order_by_sql);
|
||||
if (order_by_sql != null) {sb.Add(" ORDER BY "); sb.Add(order_by_sql);}
|
||||
if (limit_sql != null) sb.Add(limit_sql);
|
||||
return sb.XtoStr();
|
||||
}
|
||||
public static final String[] Where_flds__all = null;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs; import gplx.*;
|
||||
public interface Db_engine {
|
||||
String Key();
|
||||
String Conn_info_tid();
|
||||
Db_conn_info Conn_info();
|
||||
void Conn_open();
|
||||
void Conn_term();
|
||||
@ -33,6 +34,7 @@ public interface Db_engine {
|
||||
}
|
||||
class Db_engine_null implements Db_engine {
|
||||
public String Key() {return Db_conn_info_.Null.Key();}
|
||||
public String Conn_info_tid() {return Db_conn_info_.Null.Key();}
|
||||
public Db_conn_info Conn_info() {return Db_conn_info_.Null;}
|
||||
public void Conn_open() {}
|
||||
public void Conn_term() {}
|
||||
|
@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs; import gplx.*;
|
||||
public class Db_engine_regy {
|
||||
private final HashAdp hash = HashAdp_.new_();
|
||||
Db_engine_regy() {
|
||||
public Db_engine_regy() {}
|
||||
Db_engine_regy(int dflt) {
|
||||
this.Add(Db_engine_null._)
|
||||
.Add(TdbEngine._)
|
||||
.Add(Mysql_engine._)
|
||||
@ -28,5 +29,5 @@ public class Db_engine_regy {
|
||||
}
|
||||
public Db_engine_regy Add(Db_engine engine) {hash.Add(engine.Key(), engine); return this;}
|
||||
public Db_engine Get(String key) {return (Db_engine)hash.FetchOrFail(key);}
|
||||
public static final Db_engine_regy _ = new Db_engine_regy();
|
||||
public static final Db_engine_regy _ = new Db_engine_regy(1);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package gplx.dbs; import gplx.*;
|
||||
import java.sql.*;
|
||||
abstract class Db_engine_sql_base implements Db_engine {
|
||||
public abstract String Key();
|
||||
public abstract String Conn_info_tid();
|
||||
public Db_conn_info Conn_info() {return conn_info;} protected Db_conn_info conn_info;
|
||||
@gplx.Virtual public void Txn_bgn() {Execute(Db_qry_sql.xtn_("BEGIN TRANSACTION;"));}
|
||||
@gplx.Virtual public void Txn_end() {Execute(Db_qry_sql.xtn_("COMMIT TRANSACTION;"));}
|
||||
|
@ -20,6 +20,7 @@ import gplx.stores.*;
|
||||
import java.sql.*;
|
||||
class Mysql_engine extends Db_engine_sql_base {
|
||||
@Override public String Key() {return Db_conn_info__mysql.Key_const;}
|
||||
@Override public String Conn_info_tid() {return this.Key();}
|
||||
@Override public Sql_cmd_wtr SqlWtr() {return Sql_cmd_wtr_.BackslashSensitive;}
|
||||
@Override public Db_engine Make_new(Db_conn_info connectInfo) {
|
||||
Mysql_engine rv = new Mysql_engine();
|
||||
|
@ -20,6 +20,7 @@ import gplx.stores.*;
|
||||
import java.sql.*;
|
||||
class Postgres_engine extends Db_engine_sql_base {
|
||||
@Override public String Key() {return Db_conn_info__postgres.Key_const;}
|
||||
@Override public String Conn_info_tid() {return this.Key();}
|
||||
@Override public Sql_cmd_wtr SqlWtr() {return Sql_cmd_wtr_.BackslashSensitive;}
|
||||
@Override public Db_engine Make_new(Db_conn_info connectInfo) {
|
||||
Postgres_engine rv = new Postgres_engine();
|
||||
|
@ -20,6 +20,7 @@ import gplx.stores.*;
|
||||
import java.sql.*;
|
||||
class Sqlite_engine extends Db_engine_sql_base {
|
||||
@Override public String Key() {return Db_conn_info__sqlite.Key_const;}
|
||||
@Override public String Conn_info_tid() {return this.Key();}
|
||||
@Override public Db_engine Make_new(Db_conn_info connectInfo) {
|
||||
Sqlite_engine rv = new Sqlite_engine();
|
||||
rv.ctor_SqlEngineBase(connectInfo);
|
||||
|
@ -81,6 +81,7 @@ public class Sqlite_engine_ {
|
||||
Pragma_page_size(p, 4096);
|
||||
return p;
|
||||
}
|
||||
public static Db_engine New_engine() {return Sqlite_engine._;}
|
||||
public static final int Stmt_arg_max = 999; // 999 is max number of variables allowed by sqlite
|
||||
public static final boolean Supports_read_binary_stream = false;
|
||||
public static final boolean Supports_indexed_by = true;
|
||||
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs; import gplx.*;
|
||||
class TdbEngine implements Db_engine {
|
||||
public String Key() {return KeyDef;} public static final String KeyDef = "tdb";
|
||||
public String Conn_info_tid() {return this.Key();}
|
||||
public Db_conn_info Conn_info() {return conn_info;} Db_conn_info conn_info;
|
||||
public TdbDatabase Db() {return db;} TdbDatabase db;
|
||||
public void Conn_open() {
|
||||
|
@ -39,6 +39,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
|
||||
cur = nxt;
|
||||
}
|
||||
}
|
||||
public Btrie_slim_mgr Add_bry_tid(byte[] bry, byte tid) {return (Btrie_slim_mgr)Add_obj(bry, Byte_obj_val.new_(tid));}
|
||||
public Btrie_slim_mgr Add_str_byte(String key, byte val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), Byte_obj_val.new_(val));}
|
||||
public Btrie_slim_mgr Add_bry(String key, String val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), Bry_.new_utf8_(val));}
|
||||
public Btrie_slim_mgr Add_bry(String key, byte[] val) {return (Btrie_slim_mgr)Add_obj(Bry_.new_utf8_(key), val);}
|
||||
|
@ -37,7 +37,7 @@ public class Json_doc {
|
||||
tmp_qry_bry[0] = qry_bry;
|
||||
Json_itm rv = Find_nde(root, tmp_qry_bry, 0, 0); if (rv == null) return null;
|
||||
return (Json_grp)rv;
|
||||
} byte[][] tmp_qry_bry = new byte[1][];
|
||||
} private byte[][] tmp_qry_bry = new byte[1][];
|
||||
public Json_grp Get_grp(byte[][] qry_bry) {
|
||||
Json_itm rv = Find_nde(root, qry_bry, qry_bry.length - 1, 0); if (rv == null) return null;
|
||||
return (Json_grp)rv;
|
||||
|
@ -59,6 +59,13 @@ public class Json_itm_ary extends Json_itm_base implements Json_grp {
|
||||
Json_grp_.Print_nl(bfr); Json_grp_.Print_indent(bfr, depth);
|
||||
bfr.Add_byte(Byte_ascii.Brack_end).Add_byte_nl();
|
||||
}
|
||||
Json_itm[] subs = Json_itm_.Ary_empty;
|
||||
public byte[][] Xto_bry_ary() {
|
||||
if (subs_len == 0) return Bry_.Ary_empty;
|
||||
byte[][] rv = new byte[subs_len][];
|
||||
for (int i = 0; i < subs_len; ++i)
|
||||
rv[i] = subs[i].Data_bry();
|
||||
return rv;
|
||||
}
|
||||
private Json_itm[] subs = Json_itm_.Ary_empty;
|
||||
public static Json_itm_ary cast_(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid_array ? null : (Json_itm_ary)v;}
|
||||
}
|
||||
|
@ -17,13 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.gfui.*; import gplx.xowa.users.*;
|
||||
import gplx.xowa.hdumps.*; import gplx.xowa.hdumps.core.*;
|
||||
public class Xoa_app_ {
|
||||
public static void Run(String... args) {
|
||||
Xoa_app_boot_mgr boot_mgr = new Xoa_app_boot_mgr();
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "1.9.3.1";
|
||||
public static final String Version = "1.9.4.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
@ -35,6 +36,18 @@ public class Xoa_app_ {
|
||||
rv.Log_wtr().Queue_enabled_(true);
|
||||
return rv;
|
||||
}
|
||||
public static void Run_viewer() {
|
||||
Io_url root_dir = Io_url_.new_dir_("J:\\gplx\\xowa\\");
|
||||
Xoav_app app = new Xoav_app(Gfo_usr_dlg_._, root_dir, "drd");
|
||||
app.Wiki_mgr().Load_default();
|
||||
|
||||
Xowv_wiki wiki = app.Wiki_mgr().Get_by_domain(Bry_.new_ascii_("simple.wikibooks.org"));
|
||||
Hdump_page hpg = new Hdump_page();
|
||||
wiki.Hdump_mgr().Load(hpg, Bry_.new_utf8_("Main_Page"));
|
||||
String html = String_.new_utf8_(hpg.Page_body());
|
||||
ConsoleAdp._.WriteLine(html);
|
||||
ConsoleAdp._.ReadLine("");
|
||||
}
|
||||
public static final byte Mode_console = 0, Mode_gui = 1, Mode_http = 2;
|
||||
}
|
||||
class Xoa_app_boot_mgr {
|
||||
@ -87,6 +100,7 @@ class Xoa_app_boot_mgr {
|
||||
, App_cmd_arg.opt_("server_port_recv").Example_("55000").Note_("applies to --app_mode server; port where xowa server will receive messages; clients should send messages to this port")
|
||||
, App_cmd_arg.opt_("server_port_send").Example_("55001").Note_("applies to --app_mode server; port where xowa server will send messages; clients should listen for messages from this port")
|
||||
, App_cmd_arg.opt_("http_server_port").Example_("8080").Note_("applies to --app_mode http_server; port used by http_server; default is 8080")
|
||||
, App_cmd_arg.opt_("http_server_home").Example_("home/wiki/Main_Page").Note_("applies to --app_mode http_server; default home page for root address. EX: navigating to localhost:8080 will navigate to localhost:8080/home/wiki/Main_Page")
|
||||
, App_cmd_arg.sys_header_("show_license").Dflt_(true)
|
||||
, App_cmd_arg.sys_args_("show_args").Dflt_(true)
|
||||
, App_cmd_arg.sys_help_()
|
||||
@ -124,6 +138,7 @@ class Xoa_app_boot_mgr {
|
||||
int server_port_recv = args_mgr.Args_get("server_port_recv").Val_as_int_or(55000);
|
||||
int server_port_send = args_mgr.Args_get("server_port_send").Val_as_int_or(55001);
|
||||
int http_server_port = args_mgr.Args_get("http_server_port").Val_as_int_or(8080);
|
||||
String http_server_home = args_mgr.Args_get("http_server_home").Val_as_str_or("home/wiki/Main_Page");
|
||||
Xoa_app_.Op_sys = args_mgr.Args_get("bin_dir_name").Val_as_str_or(Bin_dir_name());
|
||||
Xoa_app_.User_agent = String_.Format("XOWA/{0} ({1}) [gnosygnu@gmail.com]", Xoa_app_.Version, Xoa_app_.Op_sys);
|
||||
String cmd_text = args_mgr.Args_get("cmd_text").Val_as_str_or(null);
|
||||
@ -138,6 +153,7 @@ class Xoa_app_boot_mgr {
|
||||
app.Api_root().App().Startup().Tabs().Manual_(launch_url);
|
||||
app.Tcp_server().Rdr_port_(server_port_recv).Wtr_port_(server_port_send);
|
||||
app.Http_server().Port_(http_server_port);
|
||||
app.Http_server().Home_(http_server_home);
|
||||
app.Init(); chkpoint = "init_gfs";
|
||||
}
|
||||
catch (Exception e) {usr_dlg.Warn_many("", "", "app init failed: ~{0} ~{1}", chkpoint, Err_.Message_gplx(e));}
|
||||
|
@ -45,7 +45,7 @@ public class Xoa_app_fxt {
|
||||
}
|
||||
public static void Init_gui(Xoa_app app) {
|
||||
app.Gui_mgr().Browser_win().Init_by_kit(gplx.gfui.Mem_kit._);
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init();
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(Xoa_page.Empty);
|
||||
}
|
||||
public static Xob_bldr bldr_(Xoa_app app) {
|
||||
Xob_bldr rv = new Xob_bldr(app);
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
public class Xoa_test_ {
|
||||
public static boolean Db_skip() {return false;}
|
||||
public static boolean Db_skip() {return Bool_.N;}
|
||||
public static boolean Fsdb_is_mem = false;
|
||||
public static Io_url Url_root() {return Io_url_.Usr().GenSubDir_nest("xowa", "dev", "tst", "400_xowa");}
|
||||
public static Io_url Url_wiki_enwiki() {return Url_root().GenSubDir_nest("root", "wiki", "en.wikipedia.org");}
|
||||
|
@ -22,9 +22,12 @@ public class Xoapi_wiki implements GfoInvkAble {
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
public void Main_page() {win.Page__navigate_by_url_bar(win.Active_page().Wiki().Domain_str() + Xoh_href_parser.Href_wiki_str);} // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
|
||||
public void Random() {win.Page__navigate_by_url_bar("Special:Random");}
|
||||
public void Sandbox() {win.Page__navigate_by_url_bar("Project:Sandbox");}
|
||||
public void Main_page() {
|
||||
win.Tab_mgr().Active_tab_assert(); // force an active tab in case all tabs are closed; needed for win.Active_page() below; DATE:2014-09-17
|
||||
win.Page__navigate_by_url_bar(win.Active_page().Wiki().Domain_str() + Xoh_href_parser.Href_wiki_str); // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_main_page)) this.Main_page();
|
||||
else if (ctx.Match(k, Invk_random)) this.Random();
|
||||
|
@ -16,15 +16,15 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.html.portal.*;
|
||||
import org.junit.*; import gplx.xowa.html.portal.*; import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xob_init_base_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xob_init_base_fxt fxt = new Xob_init_base_fxt();
|
||||
@Test public void Dirty_wiki_itms() {
|
||||
Xoa_app app = fxt.App(); Xow_wiki wiki = fxt.Wiki();
|
||||
Xoa_available_wikis_mgr wikis_list = fxt.App().Gui_mgr().Html_mgr().Portal_mgr().Wikis();
|
||||
Tfds.Eq("", wikis_list.Itms_as_html()); // assert
|
||||
app.User().Wiki().Xwiki_mgr().Add_full("en.wikipedia.org", "en.wikipedia.org");
|
||||
Xow_xwiki_itm xwiki_itm = app.User().Wiki().Xwiki_mgr().Add_full("en.wikipedia.org", "en.wikipedia.org");
|
||||
xwiki_itm.Offline_(Bool_.Y); // simulate add via Available_from_fsys; DATE:2014-09-21
|
||||
Tfds.Eq("", wikis_list.Itms_as_html()); // still empty
|
||||
new Xob_init_txt(app.Bldr(), wiki).Cmd_end(); // mock "init" task
|
||||
Tfds.Eq("\n <li><a href=\"/site/en.wikipedia.org/\" class='xowa-hover-off'>en.wikipedia.org</a></li>", wikis_list.Itms_as_html()); // no longer empty
|
||||
|
@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.bldrs.oimgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.dbs.tbls.*;
|
||||
public class Xodb_db_file {
|
||||
Xodb_db_file(String name, Io_url url, Db_provider provider, boolean created) {this.name = name; this.url = url; this.provider = provider; this.created = created;}
|
||||
public String Name() {return name;} private String name;
|
||||
Xodb_db_file(Io_url url, Db_provider provider, boolean created) {this.url = url; this.provider = provider; this.created = created;}
|
||||
public Io_url Url() {return url;} private Io_url url;
|
||||
public Db_provider Provider() {return provider;} private Db_provider provider;
|
||||
public boolean Created() {return created;} public void Created_clear() {created = false;} private boolean created;
|
||||
@ -37,7 +36,7 @@ public class Xodb_db_file {
|
||||
Xodb_xowa_cfg_tbl.Create_table(provider);
|
||||
Xodb_xowa_cfg_tbl.Create_index(provider);
|
||||
}
|
||||
return new Xodb_db_file(name, url, provider, created.Val());
|
||||
return new Xodb_db_file(url, provider, created.Val());
|
||||
}
|
||||
public static final String
|
||||
Name__wiki_image = "xowa.wiki.image.sqlite3", Name__wiki_redirect = "xowa.wiki.redirect.sqlite3"
|
||||
|
@ -51,15 +51,15 @@ public class Xodb_page_tbl {
|
||||
return false;
|
||||
}
|
||||
public static void Read_page__all2(Xodb_page page, Db_rdr rdr, boolean html_db_enabled) {
|
||||
page.Id_ (rdr.Read_int(1));
|
||||
page.Ns_id_ (rdr.Read_int(2));
|
||||
page.Ttl_wo_ns_ (rdr.Read_bry_by_str(3));
|
||||
page.Modified_on_ (DateAdp_.parse_fmt(rdr.Read_str(4), Page_touched_fmt));
|
||||
page.Type_redirect_ (rdr.Read_byte(5) == 1);
|
||||
page.Text_len_ (rdr.Read_int(6));
|
||||
page.Db_file_idx_ (rdr.Read_int(7));
|
||||
page.Id_ (rdr.Read_int(0));
|
||||
page.Ns_id_ (rdr.Read_int(1));
|
||||
page.Ttl_wo_ns_ (rdr.Read_bry_by_str(2));
|
||||
page.Modified_on_ (DateAdp_.parse_fmt(rdr.Read_str(3), Page_touched_fmt));
|
||||
page.Type_redirect_ (rdr.Read_byte(4) == 1);
|
||||
page.Text_len_ (rdr.Read_int(5));
|
||||
page.Db_file_idx_ (rdr.Read_int(6));
|
||||
if (html_db_enabled)
|
||||
page.Html_db_id_(rdr.Read_int(8));
|
||||
page.Html_db_id_(rdr.Read_int(7));
|
||||
}
|
||||
public boolean Select_by_id(Xodb_page rv, int page_id) {
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
|
@ -30,6 +30,7 @@ public class Js_img_mgr {
|
||||
}
|
||||
private static void Update_img(Xoa_page page, int uid, byte lnki_type, byte elem_tid, int html_w, int html_h, String html_src, int orig_w, int orig_h, String orig_src, byte[] lnki_ttl, int gallery_mgr_h, Js_img_wkr img_wkr) {
|
||||
if (Env_.Mode_testing()) return;
|
||||
if (page.App().Mode() != Xoa_app_.Mode_gui) return; // do not update html widget unless app is gui; null ref on http server; DATE:2014-09-17
|
||||
Xog_html_itm html_itm = page.Tab().Html_itm();
|
||||
switch (elem_tid) {
|
||||
case Xof_html_elem.Tid_gallery_v2:
|
||||
|
@ -38,8 +38,7 @@ class Xog_launcher_tabs {
|
||||
int launch_urls_len = launch_urls.length;
|
||||
for (int i = 0; i < launch_urls_len; ++i) {
|
||||
String launch_url = launch_urls[i];
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init();
|
||||
Launch_tab(tab, win, home_wiki, launch_url);
|
||||
Launch_tab(win, home_wiki, launch_url);
|
||||
}
|
||||
fil_marker.End();
|
||||
return true;
|
||||
@ -52,18 +51,17 @@ class Xog_launcher_tabs {
|
||||
}
|
||||
private void Restore_tab_failover(Xoa_app app, Xow_wiki home_wiki, Xog_win_itm win) {
|
||||
try {
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(); // NOTE: was win.Active_tab which throws a nullRef; DATE:2014-09-01
|
||||
Launch_tab(tab, win, home_wiki, gplx.xowa.users.Xouc_pages_mgr.Page_xowa);
|
||||
Launch_tab(win, home_wiki, gplx.xowa.users.Xouc_pages_mgr.Page_xowa);
|
||||
}
|
||||
catch (Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "failed to launch failover tab: err=~{0}", Err_.Message_gplx(e));
|
||||
}
|
||||
}
|
||||
private void Launch_tab(Xog_tab_itm tab, Xog_win_itm win, Xow_wiki home_wiki, String launch_str) {
|
||||
private void Launch_tab(Xog_win_itm win, Xow_wiki home_wiki, String launch_str) {
|
||||
Xoa_url launch_url = Xoa_url_parser.Parse_from_url_bar(win.App(), home_wiki, launch_str);
|
||||
Xow_wiki launch_wiki = launch_url.Wiki();
|
||||
Xoa_ttl launch_ttl = Xoa_ttl.parse_(launch_wiki, launch_url.Page_bry());
|
||||
tab.Page_(Xoa_page.new_(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(Xoa_page.new_(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
|
||||
tab.Show_url_bgn(launch_url);
|
||||
}
|
||||
public static final Xog_launcher_tabs _ = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
|
||||
|
@ -20,8 +20,8 @@ import gplx.threads.*; import gplx.gfui.*; import gplx.xowa.gui.history.*; impor
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.cfgs2.*; import gplx.xowa.pages.*;
|
||||
public class Xog_tab_itm implements GfoInvkAble {
|
||||
private Xog_win_itm win; private Xocfg_tab_mgr cfg_tab_mgr;
|
||||
public Xog_tab_itm(Xog_tab_mgr tab_mgr, Gfui_tab_itm_data tab_data) {
|
||||
this.tab_mgr = tab_mgr; this.tab_data = tab_data;
|
||||
public Xog_tab_itm(Xog_tab_mgr tab_mgr, Gfui_tab_itm_data tab_data, Xoa_page page) {
|
||||
this.tab_mgr = tab_mgr; this.tab_data = tab_data; this.page = page;
|
||||
this.win = tab_mgr.Win(); this.cfg_tab_mgr = win.App().Cfg_regy ().App().Gui_mgr().Tab_mgr();
|
||||
html_itm = new Xog_html_itm(this);
|
||||
cmd_sync = win.Kit().New_cmd_sync(this);
|
||||
@ -71,14 +71,14 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
public Xog_html_itm Html_itm() {return html_itm;} private Xog_html_itm html_itm;
|
||||
public Gfui_html Html_box() {return html_itm.Html_box();}
|
||||
public Xoa_page Page() {return page;}
|
||||
public void Page_(Xoa_page page) {Page_(true, page);}
|
||||
public void Page_(boolean update_ui, Xoa_page page) {
|
||||
public void Page_(Xoa_page page) {
|
||||
this.page = page;
|
||||
if (update_ui) {
|
||||
this.Page_update_ui(); // force tab button to update when page changes
|
||||
} private Xoa_page page;
|
||||
public void Page_update_ui() {
|
||||
this.Tab_name_();
|
||||
tab_box.Tab_tip_text_(page.Url().Xto_full_str());
|
||||
}
|
||||
} private Xoa_page page;
|
||||
public void Tab_name_() {
|
||||
byte[] tab_name = page.Html_data().Custom_name();
|
||||
if (tab_name == null) tab_name = page.Ttl().Full_txt();
|
||||
@ -245,8 +245,9 @@ class Load_page_wkr implements Gfo_thread_wkr {
|
||||
else // not low in memory
|
||||
app.Utl_bry_bfr_mkr().Clear(); // clear bry_bfr_mk only; NOTE: call before page parse, not when page is first added, else threading errors; DATE:2014-05-30
|
||||
Xoa_page page = wiki.GetPageByTtl(url, ttl, wiki.Lang(), tab, false);
|
||||
if (wiki.Db_mgr().Hdump_mgr().Enabled() && page.Revision_data().Html_db_id() != -1)
|
||||
wiki.Db_mgr().Hdump_mgr().Load(wiki, page);
|
||||
int html_db_id = page.Revision_data().Html_db_id();
|
||||
if (wiki.Db_mgr().Hdump_mgr().Enabled() && html_db_id != -1)
|
||||
wiki.Db_mgr().Hdump_mgr().Load(wiki, page, html_db_id);
|
||||
else
|
||||
wiki.ParsePage(page, false);
|
||||
GfoInvkAble_.InvkCmd_val(tab.Cmd_sync(), Xog_tab_itm.Invk_show_url_loaded_swt, page);
|
||||
|
@ -53,7 +53,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
}
|
||||
public Xog_tab_itm Active_tab() {return active_tab;} private Xog_tab_itm active_tab;
|
||||
public Xog_tab_itm Active_tab_assert() {
|
||||
if (active_tab == Xog_tab_itm_.Null) this.Tabs_new_dflt(false, true); // update_ui=false; create dflt tab, but do not update name; will be updated later by whatever loads page
|
||||
if (active_tab == Xog_tab_itm_.Null) this.Tabs_new_dflt(true);
|
||||
return active_tab;
|
||||
}
|
||||
public boolean Active_tab_is_null() {return active_tab == Xog_tab_itm_.Null;}
|
||||
@ -70,24 +70,23 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
}
|
||||
}
|
||||
public int Tabs_len() {return tab_regy.Count();}
|
||||
public Xog_tab_itm Tabs_new_init() {return this.Tabs_new(true, true);}
|
||||
public Xog_tab_itm Tabs_new_init(Xoa_page page) {return this.Tabs_new(true, true, page);}
|
||||
public Xog_tab_itm Tabs_get_at(int i) {return (Xog_tab_itm)tab_regy.FetchAt(i);}
|
||||
public Xog_tab_itm Tabs_new_dflt() {return Tabs_new_dflt(false);}
|
||||
public Xog_tab_itm Tabs_new_dflt(boolean focus) {return Tabs_new_dflt(false, focus);}
|
||||
public Xog_tab_itm Tabs_new_dflt(boolean update_ui, boolean focus) {
|
||||
public Xog_tab_itm Tabs_new_dflt(boolean focus) {
|
||||
boolean active_tab_is_null = this.Active_tab_is_null();
|
||||
Xow_wiki cur_wiki = active_tab_is_null ? win.App().User().Wiki() : active_tab.Page().Wiki();
|
||||
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(cur_wiki, gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_bry);
|
||||
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(win.App(), cur_wiki, ttl.Full_db_as_str());
|
||||
rv.Page_(update_ui, Xoa_page.new_(cur_wiki, ttl));
|
||||
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null, Xoa_page.new_(cur_wiki, ttl));
|
||||
rv.Page_update_ui();
|
||||
rv.Show_url_bgn(url);
|
||||
return rv;
|
||||
}
|
||||
private Xog_tab_itm Tabs_new(boolean focus, boolean active_tab_is_null) {
|
||||
private Xog_tab_itm Tabs_new(boolean focus, boolean active_tab_is_null, Xoa_page page) {
|
||||
String tab_key = "tab_" + Int_.Xto_str(tab_uid++); int tab_idx = tab_regy.Count();
|
||||
Gfui_tab_itm_data tab_data = new Gfui_tab_itm_data(tab_key, tab_idx);
|
||||
Xog_tab_itm rv = new Xog_tab_itm(this, tab_data);
|
||||
Xog_tab_itm rv = new Xog_tab_itm(this, tab_data, page);
|
||||
Gfui_tab_itm tab_box = tab_mgr.Tabs_add(tab_data);
|
||||
rv.Make_html_box(tab_uid, tab_box, win, tab_mgr);
|
||||
tab_box.Subs_add(rv.Html_itm().Html_box());
|
||||
@ -202,8 +201,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
Xow_wiki wiki = active_tab.Page().Wiki();
|
||||
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(win.App(), wiki, link); // NOTE: link must be of form domain/wiki/page; DATE:2014-05-27
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url.Page_bry());
|
||||
Xog_tab_itm new_tab = Tabs_new(focus, false);
|
||||
new_tab.Page_(false, Xoa_page.new_(wiki, ttl));
|
||||
Xog_tab_itm new_tab = Tabs_new(focus, false, Xoa_page.new_(wiki, ttl));
|
||||
new_tab.Tab_name_(String_.new_utf8_(Xoa_ttl.Replace_unders(url.Page_bry())));
|
||||
new_tab.Show_url_bgn(url);
|
||||
if (focus)
|
||||
|
25
400_xowa/src/gplx/xowa/hdumps/Db_provider_key.java
Normal file
25
400_xowa/src/gplx/xowa/hdumps/Db_provider_key.java
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Db_provider_key {
|
||||
public Db_provider_key(String key, Db_conn_info conn_info, GfoInvkAbleCmd init_cmd) {this.key = key; this.conn_info = conn_info; this.init_cmd = init_cmd;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public Db_conn_info Conn_info() {return conn_info;} private Db_conn_info conn_info;
|
||||
public GfoInvkAbleCmd Init_cmd() {return init_cmd;} private GfoInvkAbleCmd init_cmd;
|
||||
}
|
70
400_xowa/src/gplx/xowa/hdumps/Db_provider_mkr.java
Normal file
70
400_xowa/src/gplx/xowa/hdumps/Db_provider_mkr.java
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Db_provider_mkr {
|
||||
private final HashAdp engine_regy = HashAdp_.new_();
|
||||
public void Engines_add(Db_engine engine) {engine_regy.AddReplace(engine.Conn_info_tid(), engine);}
|
||||
public Db_provider Get(Db_provider_key provider_key) {
|
||||
Db_provider rv = Get_or_new(provider_key);
|
||||
GfoInvkAbleCmd init_cmd = provider_key.Init_cmd();
|
||||
if (init_cmd != GfoInvkAbleCmd.Null)
|
||||
GfoInvkAble_.InvkCmd_val(init_cmd.InvkAble(), init_cmd.Cmd(), rv);
|
||||
return rv;
|
||||
}
|
||||
private Db_provider Get_or_new(Db_provider_key key) {
|
||||
Db_conn_info conn_info = key.Conn_info();
|
||||
Db_engine prototype = (Db_engine)engine_regy.Fetch(conn_info.Key());
|
||||
Db_engine engine = prototype.Make_new(conn_info);
|
||||
engine.Conn_open(); // auto-open
|
||||
return new Db_provider(engine);
|
||||
}
|
||||
}
|
||||
class Mem_db_rdr implements Db_rdr {
|
||||
private int idx = -1, len;
|
||||
private Mem_db_row[] rows = new Mem_db_row[0];
|
||||
private Mem_db_rdr(Mem_db_row[] rows) {
|
||||
this.rows = rows;
|
||||
this.len = rows.length;
|
||||
}
|
||||
public boolean Move_next() {return ++idx < len;}
|
||||
public byte[] Read_bry(int i) {return (byte[])rows[idx].Get_at(i);}
|
||||
public byte[] Read_bry_by_str(int i) {return Bry_.new_utf8_((String)rows[idx].Get_at(i));}
|
||||
public String Read_str(int i) {return (String)rows[idx].Get_at(i);}
|
||||
public byte Read_byte(int i) {return Byte_.cast_(rows[idx].Get_at(i));}
|
||||
public int Read_int(int i) {return Int_.cast_(rows[idx].Get_at(i));}
|
||||
public long Read_long(int i) {return Long_.cast_(rows[idx].Get_at(i));}
|
||||
public float Read_float(int i) {return Float_.cast_(rows[idx].Get_at(i));}
|
||||
public double Read_double(int i) {return Double_.cast_(rows[idx].Get_at(i));}
|
||||
public void Close() {rows = null;}
|
||||
public static Mem_db_rdr new_by_rows(Mem_db_row[] rows) {return new Mem_db_rdr(rows);}
|
||||
public static Mem_db_rdr new_by_obj_ary(Object[][] obj_arys) {
|
||||
int obj_arys_len = obj_arys.length;
|
||||
Mem_db_row[] rows = new Mem_db_row[obj_arys_len];
|
||||
for (int i = 0; i < obj_arys_len; ++i) {
|
||||
Object[] obj_ary = obj_arys[i];
|
||||
rows[i] = new Mem_db_row(obj_ary);
|
||||
}
|
||||
return new Mem_db_rdr(rows);
|
||||
}
|
||||
}
|
||||
class Mem_db_row {
|
||||
private Object[] vals;
|
||||
public Mem_db_row(Object[] vals) {this.vals = vals;}
|
||||
public Object Get_at(int i) {return vals[i];}
|
||||
}
|
39
400_xowa/src/gplx/xowa/hdumps/Xoav_app.java
Normal file
39
400_xowa/src/gplx/xowa/hdumps/Xoav_app.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.intl.*;
|
||||
public class Xoav_app {
|
||||
public Xoav_app(Gfo_usr_dlg usr_dlg, Io_url root_dir, String plat_name) {
|
||||
this.usr_dlg = usr_dlg;
|
||||
this.fsys_mgr = new Xoa_fsys_mgr(root_dir, plat_name);
|
||||
this.wiki_mgr = new Xoav_wiki_mgr(this, fsys_mgr.Wiki_dir(), utl_case_mgr);
|
||||
this.db_mgr = new Db_provider_mkr();
|
||||
this.utl_msg_log = Gfo_msg_log.Test();
|
||||
db_mgr.Engines_add(gplx.dbs.Sqlite_engine_.New_engine());
|
||||
}
|
||||
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xoa_fsys_mgr fsys_mgr;
|
||||
public Xoav_wiki_mgr Wiki_mgr() {return wiki_mgr;} private final Xoav_wiki_mgr wiki_mgr;
|
||||
public Db_provider_mkr Db_mgr() {return db_mgr;} private Db_provider_mkr db_mgr;
|
||||
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} private Gfo_usr_dlg usr_dlg;
|
||||
public Bry_bfr_mkr Utl_bfr_mkr() {return utl_bfr_mkr;} private Bry_bfr_mkr utl_bfr_mkr = new Bry_bfr_mkr();
|
||||
public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = new Xop_amp_mgr();
|
||||
public Xol_case_mgr Utl_case_mgr() {return utl_case_mgr;} private Xol_case_mgr utl_case_mgr = new Xol_case_mgr(Gfo_case_mgr_.Tid_utf8);
|
||||
public Url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Url_encoder utl_encoder_fsys = Url_encoder.new_fsys_lnx_();
|
||||
public Gfo_msg_log Utl_msg_log() {return utl_msg_log;} private Gfo_msg_log utl_msg_log;
|
||||
}
|
34
400_xowa/src/gplx/xowa/hdumps/Xoav_wiki_mgr.java
Normal file
34
400_xowa/src/gplx/xowa/hdumps/Xoav_wiki_mgr.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Xoav_wiki_mgr {
|
||||
private final Xoav_app app; private final OrderedHash hash = OrderedHash_.new_bry_();
|
||||
private Io_url wiki_root_dir;
|
||||
public Xoav_wiki_mgr(Xoav_app app, Io_url wiki_root_dir, Xol_case_mgr case_mgr) {this.app = app; this.wiki_root_dir = wiki_root_dir;}
|
||||
public Xowv_wiki Get_by_domain(byte[] domain) {return (Xowv_wiki)hash.Fetch(domain);}
|
||||
public void Load_default() {
|
||||
Io_url[] wiki_dirs = Io_mgr._.QueryDir_args(wiki_root_dir).DirOnly_().ExecAsUrlAry();
|
||||
for (Io_url wiki_dir : wiki_dirs) {
|
||||
String wiki_dir_url = wiki_dir.Raw();
|
||||
if (String_.HasAtBgn(wiki_dir_url, "#")) continue;
|
||||
Xowv_wiki wiki = new Xowv_wiki(app, wiki_dir.NameOnly(), wiki_dir);
|
||||
hash.Add(wiki.Domain_bry(), wiki);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,16 +22,16 @@ public class Xodb_hdump_mgr {
|
||||
private Xodb_file hdump_db_file;
|
||||
public Xodb_hdump_mgr(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
load_mgr = new Hdump_load_mgr(this);
|
||||
load_mgr = new Hdump_load_mgr();
|
||||
Tbl_(new Hdump_text_tbl());
|
||||
text_tbl.Init_by_wiki(wiki);
|
||||
Xoa_app app = wiki.App();
|
||||
html_mgr.Init_by_app(app);
|
||||
html_mgr.Init_by_app(app.Usr_dlg(), app.Fsys_mgr(), app.Encoder_mgr().Fsys());
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;} private final Xow_wiki wiki;
|
||||
@gplx.Internal protected Hdump_load_mgr Load_mgr() {return load_mgr;} private Hdump_load_mgr load_mgr;
|
||||
@gplx.Internal protected Hdump_save_mgr Save_mgr() {return save_mgr;} private Hdump_save_mgr save_mgr = new Hdump_save_mgr();
|
||||
public Hdump_html_mgr Html_mgr() {return html_mgr;} private Hdump_html_mgr html_mgr = new Hdump_html_mgr();
|
||||
public Hdump_html_body Html_mgr() {return html_mgr;} private Hdump_html_body html_mgr = new Hdump_html_body();
|
||||
public Hdump_text_tbl Text_tbl() {return text_tbl;} private Hdump_text_tbl text_tbl;
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
@gplx.Internal protected void Tbl_mem_() {Tbl_(new Hdump_text_tbl_mem());}
|
||||
@ -58,16 +58,16 @@ public class Xodb_hdump_mgr {
|
||||
wkr.Write_body(bfr, Xoh_wtr_ctx.Hdump, page);
|
||||
page.Hdump_data().Body_(bfr.XtoAryAndClear());
|
||||
}
|
||||
public void Load(Xow_wiki wiki, Xoa_page page) {
|
||||
public void Load(Xow_wiki wiki, Xoa_page page, int html_db_id) {
|
||||
if (!Enabled_chk()) return;
|
||||
page.Root_(new Xop_root_tkn());
|
||||
Hdump_page hpg = new Hdump_page();
|
||||
load_mgr.Load(hpg, page.Revision_data().Id(), page.Url());
|
||||
Hdump_page hpg = new Hdump_page().Init(page.Revision_data().Id(), page.Url());
|
||||
load_mgr.Load(hpg, wiki.Db_mgr_as_sql().Fsys_mgr(), html_db_id, page.Revision_data().Id());
|
||||
Load_page(wiki, page, hpg);
|
||||
}
|
||||
private void Load_page(Xow_wiki wiki, Xoa_page page, Hdump_page hpg) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl_bry_bfr_mkr().Get_m001();
|
||||
html_mgr.Write(tmp_bfr, wiki, hpg);
|
||||
html_mgr.Init_by_page(wiki.Domain_bry(), hpg).Write(tmp_bfr);
|
||||
page.Hdump_data().Body_(tmp_bfr.XtoAryAndClear());
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
html_data.Display_ttl_(hpg.Display_ttl());
|
||||
|
56
400_xowa/src/gplx/xowa/hdumps/Xodbv_dbs_tbl.java
Normal file
56
400_xowa/src/gplx/xowa/hdumps/Xodbv_dbs_tbl.java
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*; import gplx.xowa.dbs.*;
|
||||
public class Xodbv_dbs_tbl {
|
||||
public static final String Tbl_name = "xowa_db", Fld_db_id = "db_id", Fld_db_type = "db_type", Fld_db_url = "db_url";
|
||||
private static final String[] Flds__all = new String[] {Fld_db_id, Fld_db_type, Fld_db_url};
|
||||
public Xodb_file[] Select_all(Db_provider provider, Io_url wiki_root_dir) {
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
ListAdp list = ListAdp_.new_();
|
||||
try {
|
||||
Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.new_(Tbl_name, Db_qry__select_in_tbl.Where_flds__all, Flds__all).Order_by_sql_(Fld_db_id);
|
||||
Db_stmt stmt = Db_stmt_.new_select_as_rdr(provider, qry);
|
||||
rdr = stmt.Exec_select_as_rdr();
|
||||
while (rdr.Move_next()) {
|
||||
Xodb_file db = Xodb_file.load_(rdr.Read_int(0), rdr.Read_byte(1), rdr.Read_str(2));
|
||||
db.Url_(wiki_root_dir.GenSubFil(db.Url_rel()));
|
||||
list.Add(db);
|
||||
}
|
||||
} finally {rdr.Close();}
|
||||
Xodb_file[] rv = (Xodb_file[])list.XtoAry(Xodb_file.class);
|
||||
Chk_sequential(rv);
|
||||
return rv;
|
||||
}
|
||||
private void Chk_sequential(Xodb_file[] ary) {
|
||||
int len = ary.length;
|
||||
int expd_id = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_file itm = ary[i];
|
||||
int actl_id = itm.Id();
|
||||
if (expd_id != actl_id) throw Err_.new_fmt_("database ids are not sequential; expd={0} actl={1}", expd_id, actl_id);
|
||||
++expd_id;
|
||||
}
|
||||
}
|
||||
//Db_stmt_bldr stmt_bldr = new Db_stmt_bldr(Tbl_name, String_.Ary(Fld_db_id), Fld_db_type, Fld_db_url);
|
||||
}
|
||||
// class Xod_db_fil {
|
||||
// public Xod_db_fil(int idx, Io_url url) {this.idx = idx; this.url = url;}
|
||||
// public int Idx() {return idx;} private int idx;
|
||||
// public Io_url Url() {return url;} private Io_url url;
|
||||
// }
|
50
400_xowa/src/gplx/xowa/hdumps/Xodbv_page_tbl.java
Normal file
50
400_xowa/src/gplx/xowa/hdumps/Xodbv_page_tbl.java
Normal 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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xodbv_page_tbl {
|
||||
public static final String Tbl_name = "page"
|
||||
, Fld_page_id = "page_id", Fld_page_ns = "page_namespace", Fld_page_title = "page_title"
|
||||
, Fld_page_is_redirect = "page_is_redirect", Fld_page_touched = "page_touched", Fld_page_len = "page_len"
|
||||
, Fld_page_random_int = "page_random_int", Fld_page_file_idx = "page_file_idx"
|
||||
, Fld_page_html_db_id = "page_html_db_id";
|
||||
private static final String[] Select_by_id_flds__hdump = new String[] {Fld_page_id, Fld_page_ns, Fld_page_title, Fld_page_touched, Fld_page_is_redirect, Fld_page_len, Fld_page_file_idx, Fld_page_html_db_id};
|
||||
public boolean Select_by_ttl(Xodb_page rv, Db_provider provider, Xow_ns ns, byte[] ttl) {
|
||||
Db_rdr rdr = Db_rdr_.Null; Db_stmt stmt = Db_stmt_.Null;
|
||||
try {
|
||||
stmt = Db_stmt_.new_select_as_rdr(provider, Db_qry__select_in_tbl.new_(Tbl_name, String_.Ary(Fld_page_ns, Fld_page_title), Select_by_id_flds__hdump));
|
||||
rdr = stmt.Val_int_(ns.Id()).Val_str_(String_.new_utf8_(ttl)).Exec_select_as_rdr();
|
||||
if (rdr.Move_next()) {
|
||||
Read_page__all(rv, rdr);
|
||||
return true;
|
||||
}
|
||||
} finally {rdr.Close(); stmt.Rls();}
|
||||
return false;
|
||||
}
|
||||
public static void Read_page__all(Xodb_page page, Db_rdr rdr) {
|
||||
page.Id_ (rdr.Read_int(0));
|
||||
page.Ns_id_ (rdr.Read_int(1));
|
||||
page.Ttl_wo_ns_ (rdr.Read_bry_by_str(2));
|
||||
page.Modified_on_ (DateAdp_.parse_fmt(rdr.Read_str(3), Page_touched_fmt));
|
||||
page.Type_redirect_ (rdr.Read_byte(4) == 1);
|
||||
page.Text_len_ (rdr.Read_int(5));
|
||||
page.Db_file_idx_ (rdr.Read_int(6));
|
||||
page.Html_db_id_ (rdr.Read_int(7));
|
||||
}
|
||||
private static final String Page_touched_fmt = "yyyyMMddHHmmss";
|
||||
}
|
22
400_xowa/src/gplx/xowa/hdumps/Xowd_db_tbl_mgr.java
Normal file
22
400_xowa/src/gplx/xowa/hdumps/Xowd_db_tbl_mgr.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.xowa.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
public class Xowd_db_tbl_mgr {
|
||||
public Xodbv_page_tbl Tbl__page() {return tbl__page;} private Xodbv_page_tbl tbl__page = new Xodbv_page_tbl();
|
||||
public Xodbv_dbs_tbl Tbl__dbs_new() {return new Xodbv_dbs_tbl();}
|
||||
}
|
38
400_xowa/src/gplx/xowa/hdumps/Xowd_hdump_mgr.java
Normal file
38
400_xowa/src/gplx/xowa/hdumps/Xowd_hdump_mgr.java
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.intl.*; import gplx.dbs.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.loads.*; import gplx.xowa.hdumps.htmls.*; import gplx.xowa.apps.fsys.*;
|
||||
public class Xowd_hdump_mgr {
|
||||
private final Xoav_app app; private final Xowv_wiki wiki; private final Xowv_db_mgr wiki_db_mgr;
|
||||
private Xodb_page dbpg = new Xodb_page(); private Hdump_page hpg = new Hdump_page();
|
||||
private Hdump_load_mgr load_mgr = new Hdump_load_mgr();
|
||||
private Hdump_html_body html_body = new Hdump_html_body();
|
||||
public Xowd_hdump_mgr(Xoav_app app, Xowv_wiki wiki) {
|
||||
this.app = app; this.wiki = wiki; this.wiki_db_mgr = wiki.Db_mgr();
|
||||
html_body.Init_by_app(app.Usr_dlg(), app.Fsys_mgr(), app.Utl_encoder_fsys());
|
||||
}
|
||||
public void Load(Hdump_page rv, byte[] ttl_bry) {
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(ttl_bry);
|
||||
wiki_db_mgr.Tbl_mgr().Tbl__page().Select_by_ttl(dbpg, app.Db_mgr().Get(wiki_db_mgr.Key__core()), ttl.Ns(), ttl.Page_db());
|
||||
load_mgr.Load2(hpg, app.Db_mgr().Get(wiki_db_mgr.Key_by_idx(dbpg.Html_db_id())), dbpg.Id());
|
||||
Bry_bfr bfr = app.Utl_bfr_mkr().Get_m001();
|
||||
html_body.Init_by_page(wiki.Domain_bry(), hpg).Write(bfr);
|
||||
rv.Page_body_(bfr.Mkr_rls().XtoAryAndClear());
|
||||
}
|
||||
}
|
55
400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr.java
Normal file
55
400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*; import gplx.xowa.dbs.*;
|
||||
public class Xowv_db_mgr implements GfoInvkAble {
|
||||
private Io_url wiki_root_dir;
|
||||
public Xowv_db_mgr(String domain_str, Io_url wiki_root_dir) {
|
||||
this.tbl_mgr = new Xowd_db_tbl_mgr(); this.wiki_root_dir = wiki_root_dir;
|
||||
this.key__core = Xowv_db_mgr.Db_key__core__default(this, domain_str, wiki_root_dir);
|
||||
}
|
||||
public Xowd_db_tbl_mgr Tbl_mgr() {return tbl_mgr;} private Xowd_db_tbl_mgr tbl_mgr;
|
||||
private Xodb_file[] db_files; private Db_provider_key[] db_keys; private int db_keys_len;
|
||||
public Db_provider_key Key__core() {return key__core;} private Db_provider_key key__core;
|
||||
public Db_provider_key Key_by_idx(int idx) {if (!Int_.Between(idx, 0, db_keys_len)) throw Err_.new_("database does not exist: idx={0}", idx); return db_keys[idx];}
|
||||
private void Core_init(Db_provider provider) {
|
||||
db_files = tbl_mgr.Tbl__dbs_new().Select_all(provider, wiki_root_dir);
|
||||
db_keys = Db_keys_make(db_files);
|
||||
db_keys_len = db_keys.length;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_core_init)) Core_init((Db_provider)m.ReadObj("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_core_init = "core_init";
|
||||
private static Db_provider_key Db_key__core__default(Xowv_db_mgr db_mgr, String domain_str, Io_url wiki_root_dir) {
|
||||
Io_url core_db_url = wiki_root_dir.GenSubFil_ary(domain_str, ".000.sqlite3");
|
||||
GfoInvkAbleCmd init_cmd = GfoInvkAbleCmd.new_(db_mgr, Invk_core_init);
|
||||
return new Db_provider_key(core_db_url.Raw(), Db_conn_info_.sqlite_(core_db_url), init_cmd);
|
||||
}
|
||||
private static Db_provider_key[] Db_keys_make(Xodb_file[] ary) {
|
||||
int len = ary.length;
|
||||
Db_provider_key[] rv = new Db_provider_key[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xodb_file itm = ary[i];
|
||||
Io_url itm_url = itm.Url();
|
||||
rv[i] = new Db_provider_key(itm_url.Raw(), Db_conn_info_.sqlite_(itm_url), GfoInvkAbleCmd.Null);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
45
400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr_tst.java
Normal file
45
400_xowa/src/gplx/xowa/hdumps/Xowv_db_mgr_tst.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.dbs.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Xowv_db_mgr_tst {
|
||||
@Before public void init() {} private Xowv_db_mgr_fxt fxt = new Xowv_db_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init_rdr(fxt.Make_row(0, "mem/a", 2),fxt.Make_row(0, "mem/a", 2), fxt.Make_row(0, "mem/a", 2));
|
||||
// fxt.Exec_open_core();
|
||||
// fxt.Test_dbs(fxt.Make_db(0, "mem/a", 0), fxt.Make_db(1, "mem/2", 2), fxt.Make_db("mem/3, 3"));
|
||||
}
|
||||
}
|
||||
class Xowv_db_mgr_fxt {
|
||||
// private Xoav_app app; private Xowv_wiki wiki;
|
||||
public void Init_rdr(Mem_db_row... rows) {
|
||||
// Mem_db_rdr rdr = Mem_db_rdr.new_by_rows(rows);
|
||||
// app = new Xoav_app(null, nul, null);
|
||||
// Mem_db_engine engine = new Mem_db_engine();
|
||||
// engine.Pending_rdrs_add(rdr);
|
||||
// app.Db_mgr().Engines_add(engine);
|
||||
}
|
||||
public Mem_db_row Make_row(Object... vals) {return new Mem_db_row(vals);}
|
||||
public void Exec_open_core() {
|
||||
// app.Db_mgr().Get(wiki.Db_mgr().Key__core());
|
||||
}
|
||||
public void Test_dbs(Xodb_file[] expd) {
|
||||
// Tfds.Eq(expd, wiki.Db_mgr().Files());
|
||||
}
|
||||
}
|
39
400_xowa/src/gplx/xowa/hdumps/Xowv_wiki.java
Normal file
39
400_xowa/src/gplx/xowa/hdumps/Xowv_wiki.java
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*;
|
||||
public class Xowv_wiki {
|
||||
private Xoav_app app;
|
||||
public Xowv_wiki(Xoav_app app, String domain_str, Io_url wiki_root_dir) {
|
||||
this.app = app;
|
||||
this.domain_str = domain_str; this.domain_bry = Bry_.new_utf8_(domain_str);
|
||||
this.ns_mgr = Xow_ns_mgr_.default_(app.Utl_case_mgr()); // new Xow_ns_mgr(app.Utl_case_mgr()); // FIXME
|
||||
this.db_mgr = new Xowv_db_mgr(domain_str, wiki_root_dir);
|
||||
this.hdump_mgr = new Xowd_hdump_mgr(app, this);
|
||||
this.xwiki_mgr = new Xow_xwiki_mgr();
|
||||
}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public Xowv_db_mgr Db_mgr() {return db_mgr;} private final Xowv_db_mgr db_mgr;
|
||||
public Xowd_hdump_mgr Hdump_mgr() {return hdump_mgr;} private final Xowd_hdump_mgr hdump_mgr;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private Xow_xwiki_mgr xwiki_mgr;
|
||||
public Xoa_ttl Ttl_parse(byte[] ttl) {
|
||||
return Xoa_ttl.parse(app.Utl_bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), ttl, 0, ttl.length);
|
||||
}
|
||||
}
|
@ -33,20 +33,20 @@ class Hdump_img_bldr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
Db_rdr rdr = stmt.Exec_select_as_rdr();
|
||||
int cur_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_page_id = rdr.Read_int(1);
|
||||
int lnki_page_id = rdr.Read_int(0);
|
||||
if (lnki_page_id != cur_page_id) {
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());
|
||||
cur_page_id = lnki_page_id;
|
||||
}
|
||||
int html_uid = rdr.Read_int(2);
|
||||
byte[] lnki_ttl = rdr.Read_bry(3);
|
||||
int html_w = rdr.Read_int(4);
|
||||
int html_h = rdr.Read_int(5);
|
||||
int file_repo_id = rdr.Read_int(6);
|
||||
int file_ext_id = rdr.Read_int(7);
|
||||
boolean file_is_orig = rdr.Read_int(8) == 1;
|
||||
double file_time = rdr.Read_double(9);
|
||||
int file_page = rdr.Read_int(10);
|
||||
int html_uid = rdr.Read_int(1);
|
||||
byte[] lnki_ttl = rdr.Read_bry(2);
|
||||
int html_w = rdr.Read_int(3);
|
||||
int html_h = rdr.Read_int(4);
|
||||
int file_repo_id = rdr.Read_int(5);
|
||||
int file_ext_id = rdr.Read_int(6);
|
||||
boolean file_is_orig = rdr.Read_int(7) == 1;
|
||||
double file_time = rdr.Read_double(8);
|
||||
int file_page = rdr.Read_int(9);
|
||||
Hdump_data_img__base.Data_write_static(bfr, 0, lnki_ttl, html_uid, html_w, html_h, file_repo_id, file_ext_id, file_is_orig, html_w, file_time, file_page);
|
||||
}
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());;
|
||||
|
@ -29,7 +29,7 @@ public class Hdump_page {
|
||||
public int[] Redlink_uids() {return redlink_uids;} public void Redlink_uids_(int[] v) {redlink_uids = v;} private int[] redlink_uids;
|
||||
public Hdump_data_img__base[] Img_itms() {return img_itms;} public void Img_itms_(Hdump_data_img__base[] v) {this.img_itms = v;} private Hdump_data_img__base[] img_itms;
|
||||
public OrderedHash Gly_itms() {return gly_itms;} private OrderedHash gly_itms = OrderedHash_.new_();
|
||||
public void Init(int page_id, Xoa_url page_url) {
|
||||
public Hdump_page Init(int page_id, Xoa_url page_url) {
|
||||
this.page_id = page_id;
|
||||
this.page_url = page_url;
|
||||
content_sub = sidebar_div = Bry_.Empty;
|
||||
@ -37,5 +37,6 @@ public class Hdump_page {
|
||||
img_itms = Hdump_data_img__base.Ary_empty;
|
||||
module_mgr.Clear();
|
||||
gly_itms.Clear();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -80,12 +80,12 @@ class Redlink_wkr {
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
int cur_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_page_id = rdr.Read_int(1);
|
||||
int lnki_page_id = rdr.Read_int(0);
|
||||
if (lnki_page_id != cur_page_id) {
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());
|
||||
cur_page_id = lnki_page_id;
|
||||
}
|
||||
int html_uid = rdr.Read_int(2);
|
||||
int html_uid = rdr.Read_int(1);
|
||||
bfr.Add_int_variable(html_uid).Add_byte_pipe();
|
||||
}
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());;
|
||||
@ -98,9 +98,9 @@ class Redlink_wkr {
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
Db_stmt stmt = Db_stmt_.Null;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_id = rdr.Read_int(1);
|
||||
int lnki_page_id = rdr.Read_int(2);
|
||||
byte[] page_ids = rdr.Read_bry(3);
|
||||
int lnki_id = rdr.Read_int(0);
|
||||
int lnki_page_id = rdr.Read_int(1);
|
||||
byte[] page_ids = rdr.Read_bry(2);
|
||||
Save_rl_html(stmt, lnki_id, lnki_page_id, bry_rdr.Src_(page_ids));
|
||||
}
|
||||
}
|
||||
|
@ -18,35 +18,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.html.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Hdump_html_body implements Bry_fmtr_arg {
|
||||
private Bry_rdr bry_rdr = new Bry_rdr();
|
||||
private Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_();
|
||||
private Xow_wiki wiki; private Hdump_page hpg;
|
||||
private byte[] root_remote, root_local;
|
||||
private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_._; private byte[] root_dir, file_dir, hiero_img_dir; private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private Xoh_cfg_file cfg_file;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
this.usr_dlg = app.Usr_dlg();
|
||||
this.root_dir = app.Fsys_mgr().Root_dir().To_http_file_bry();
|
||||
this.file_dir = app.Fsys_mgr().File_dir().To_http_file_bry();
|
||||
this.hiero_img_dir = gplx.xowa.xtns.hieros.Hiero_xtn_mgr.Hiero_root_dir(app).GenSubDir("img").To_http_file_bry();
|
||||
cfg_file = new Xoh_cfg_file(app.Encoder_mgr().Fsys(), app.Fsys_mgr().Bin_xowa_dir());
|
||||
public class Hdump_html_body {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255); private Bry_rdr bry_rdr = new Bry_rdr(); private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_._;
|
||||
private Hdump_page hpg; private Xoh_cfg_file cfg_file; private Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_(); private Xoh_file_html_fmtr__base html_fmtr;
|
||||
private byte[] root_dir, file_dir, file_dir_comm, file_dir_wiki, hiero_img_dir;
|
||||
public Hdump_html_body Init_by_app(Gfo_usr_dlg usr_dlg, Xoa_fsys_mgr fsys_mgr, Url_encoder fsys_encoder) {
|
||||
this.usr_dlg = usr_dlg;
|
||||
this.root_dir = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.file_dir = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.hiero_img_dir = gplx.xowa.xtns.hieros.Hiero_xtn_mgr.Hiero_root_dir(fsys_mgr).GenSubDir("img").To_http_file_bry();
|
||||
this.cfg_file = new Xoh_cfg_file(fsys_encoder, fsys_mgr.Bin_xowa_dir());
|
||||
this.html_fmtr = Xoh_file_html_fmtr__hdump.Base;
|
||||
return this;
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki, Hdump_page hpg) {
|
||||
this.wiki = wiki; this.hpg = hpg;
|
||||
root_remote = tmp_bfr.Add(file_dir).Add(Xow_wiki_.Domain_commons_bry).Add_byte_slash().XtoAryAndClear();
|
||||
root_local = tmp_bfr.Add(file_dir).Add(wiki.Domain_bry()).Add_byte_slash().XtoAryAndClear();
|
||||
public Hdump_html_body Init_by_page(byte[] domain_bry, Hdump_page hpg) {
|
||||
this.hpg = hpg;
|
||||
file_dir_comm = tmp_bfr.Add(file_dir).Add(Xow_wiki_.Domain_commons_bry).Add_byte_slash().XtoAryAndClear();
|
||||
file_dir_wiki = tmp_bfr.Add(file_dir).Add(domain_bry).Add_byte_slash().XtoAryAndClear();
|
||||
return this;
|
||||
}
|
||||
public void Init_by_drd(Url_encoder fsys_encoder, Xoa_fsys_mgr fsys_mgr) {
|
||||
cfg_file = new Xoh_cfg_file(fsys_encoder, fsys_mgr.Bin_xowa_dir());
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
public void Write(Bry_bfr bfr) {
|
||||
byte[] src = hpg.Page_body(); int len = src.length;
|
||||
Hdump_data_img__base[] imgs = hpg.Img_itms(); int imgs_len = hpg.Img_itms().length;
|
||||
bry_rdr.Src_(src);
|
||||
int pos = 0; int rng_bgn = -1;
|
||||
Xow_html_mgr html_mgr = wiki.Html_mgr();
|
||||
Xoh_file_html_fmtr__base html_fmtr = html_mgr.Html_wtr().Lnki_wtr().File_wtr().File_wtr().Html_fmtr();
|
||||
while (pos < len) {
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, len);
|
||||
@ -66,15 +61,6 @@ public class Hdump_html_body implements Bry_fmtr_arg {
|
||||
}
|
||||
if (rng_bgn != -1) bfr.Add_mid(src, rng_bgn, len);
|
||||
}
|
||||
private int Write_redlink(Bry_bfr bfr, Hdump_page hpg, int uid, int rv) {
|
||||
int[] redlink_uids = hpg.Redlink_uids(); if (redlink_uids == null) return rv;
|
||||
int redlink_uid_max = redlink_uids.length;
|
||||
if (uid < redlink_uid_max && redlink_uids[uid] == 1)
|
||||
bfr.Add(Redlink_cls_new);
|
||||
else
|
||||
bfr.Del_by_1();
|
||||
return rv;
|
||||
} private static final byte[] Redlink_cls_new = Bry_.new_ascii_("class='new'");
|
||||
private int Write_data(Bry_bfr bfr, Xoh_file_html_fmtr__base fmtr, Hdump_page hpg, byte[] src, Hdump_data_img__base[] imgs, int imgs_len, int uid_bgn, Hdump_html_fmtr_itm itm) {
|
||||
bry_rdr.Pos_(uid_bgn);
|
||||
int uid = itm.Subst_end_byte() == Byte_ascii.Nil ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
|
||||
@ -132,7 +118,7 @@ public class Hdump_html_body implements Bry_fmtr_arg {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
url_bldr.Init_by_root(img.File_repo_id() == Xof_repo_itm.Repo_remote ? root_remote : root_local, Byte_ascii.Slash, false, false, 2);
|
||||
url_bldr.Init_by_root(img.File_repo_id() == Xof_repo_itm.Repo_remote ? file_dir_comm : file_dir_wiki, Byte_ascii.Slash, false, false, 2);
|
||||
url_bldr.Init_by_itm(img.File_is_orig() ? Xof_repo_itm.Mode_orig : Xof_repo_itm.Mode_thumb, img.Lnki_ttl(), Xof_xfer_itm_.Md5_(img.Lnki_ttl()), Xof_ext_.new_by_id_(img.File_ext_id()), img.File_w(), img.File_time(), img.File_page());
|
||||
byte[] img_src = url_bldr.Xto_bry();
|
||||
if (tid == Hdump_html_consts.Tid_img) {
|
||||
@ -140,6 +126,15 @@ public class Hdump_html_body implements Bry_fmtr_arg {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private int Write_redlink(Bry_bfr bfr, Hdump_page hpg, int uid, int rv) {
|
||||
int[] redlink_uids = hpg.Redlink_uids(); if (redlink_uids == null) return rv;
|
||||
int redlink_uid_max = redlink_uids.length;
|
||||
if (uid < redlink_uid_max && redlink_uids[uid] == 1)
|
||||
bfr.Add(Redlink_cls_new);
|
||||
else
|
||||
bfr.Del_by_1();
|
||||
return rv;
|
||||
} private static final byte[] Redlink_cls_new = Bry_.new_ascii_("class='new'");
|
||||
public static final Bry_fmtr fmtr_img = Bry_fmtr.new_("src='~{src}' width='~{w}' height='~{h}'", "src", "w", "h");
|
||||
private static final Btrie_slim_mgr trie = Hdump_html_consts.trie_();
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class Hdump_html_mgr_tst {
|
||||
}
|
||||
}
|
||||
class Hdump_html_mgr_fxt {
|
||||
private Hdump_html_mgr html_mgr;
|
||||
private Hdump_html_body html_mgr;
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
private ListAdp img_list = ListAdp_.new_();
|
||||
private Xow_wiki wiki;
|
||||
@ -139,7 +139,7 @@ class Hdump_html_mgr_fxt {
|
||||
}
|
||||
public Hdump_html_mgr_fxt Test_html(String expd) {
|
||||
if (img_list.Count() > 0) hpg.Img_itms_((Hdump_data_img__base[])img_list.XtoAryAndClear(Hdump_data_img__base.class));
|
||||
html_mgr.Write(bfr, wiki, hpg);
|
||||
html_mgr.Init_by_page(wiki.Domain_bry(), hpg).Write(bfr);
|
||||
Tfds.Eq_str_lines(expd, bfr.XtoStrAndClear());
|
||||
return this;
|
||||
}
|
||||
|
@ -16,17 +16,21 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.loads; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.dbs.*; import gplx.ios.*; import gplx.xowa.pages.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*;
|
||||
import gplx.xowa.pages.skins.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.dbs.*; import gplx.ios.*;
|
||||
import gplx.xowa.dbs.*; import gplx.xowa.pages.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.pages.skins.*;
|
||||
public class Hdump_load_mgr {
|
||||
private Xodb_hdump_mgr hdump_mgr; private Hdump_text_tbl text_tbl = new Hdump_text_tbl(); private Bry_rdr rdr = new Bry_rdr(); // private Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||
private Hdump_text_tbl text_tbl = new Hdump_text_tbl(); private Bry_rdr rdr = new Bry_rdr(); // private Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||
private ListAdp tmp_rows = ListAdp_.new_(), img_itms = ListAdp_.new_();
|
||||
public Hdump_load_mgr(Xodb_hdump_mgr hdump_mgr) {this.hdump_mgr = hdump_mgr;}
|
||||
public Hdump_load_mgr() {}
|
||||
public byte Zip_tid() {return zip_tid;} public void Zip_tid_(byte v) {zip_tid = v;} private byte zip_tid = gplx.ios.Io_stream_.Tid_file;
|
||||
public void Load(Hdump_page hpg, int page_id, Xoa_url page_url) {
|
||||
Db_provider provider = hdump_mgr.Db_provider_by_page(page_id);
|
||||
public void Load2(Hdump_page hpg, Db_provider provider, int page_id) {
|
||||
text_tbl.Provider_(provider).Select_by_page(tmp_rows, page_id);
|
||||
Load_rows(hpg, page_id, page_url, tmp_rows);
|
||||
Load_rows(hpg, page_id, Xoa_url.blank_(), tmp_rows);
|
||||
}
|
||||
public void Load(Hdump_page hpg, Xodb_fsys_mgr db_fsys_mgr, int html_db_id, int page_id) {
|
||||
Db_provider provider = db_fsys_mgr.Get_by_idx(html_db_id).Provider();
|
||||
text_tbl.Provider_(provider).Select_by_page(tmp_rows, page_id);
|
||||
Load_rows(hpg, page_id, hpg.Page_url(), tmp_rows);
|
||||
}
|
||||
public void Load_rows(Hdump_page hpg, int page_id, Xoa_url page_url, ListAdp rows) {
|
||||
hpg.Init(page_id, page_url);
|
||||
@ -46,7 +50,7 @@ public class Hdump_load_mgr {
|
||||
while (!rdr.Pos_is_eos()) {
|
||||
int tid = rdr.Read_int_to_pipe();
|
||||
switch (tid) {
|
||||
case Hdump_data_tid.Tid_img : Load_data_img(); break; // 1|0|220|110|A.png|commons/7/0/orig/A.png
|
||||
case Hdump_data_tid.Tid_img : Load_data_img(); break; // 1|0|A.png|0|220|110|...
|
||||
case Hdump_data_tid.Tid_gallery : Load_data_gallery(hpg); break; // 3|0|800
|
||||
case Hdump_data_tid.Tid_redlink : Load_data_redlink(hpg); break; // 2|2|0|1
|
||||
}
|
||||
|
@ -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.hdumps.loads; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.saves.*; import gplx.xowa.hdumps.pages.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.saves.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.dbs.*;
|
||||
public class Hdump_load_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Hdump_load_mgr_fxt fxt = new Hdump_load_mgr_fxt();
|
||||
@Test public void Body() {
|
||||
@ -50,7 +50,7 @@ class Hdump_load_mgr_fxt {
|
||||
private ListAdp expd_imgs = ListAdp_.new_();
|
||||
private int page_id = 0; private Xoa_url page_url;
|
||||
public void Clear() {
|
||||
load_mgr = new Hdump_load_mgr(null);
|
||||
load_mgr = new Hdump_load_mgr();
|
||||
load_mgr.Zip_tid_(gplx.ios.Io_stream_.Tid_file);
|
||||
init_rows.Clear();
|
||||
expd_body = expd_display_ttl = expd_content_sub = expd_sidebar_div = null;
|
||||
|
@ -139,23 +139,3 @@ public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
|
||||
|
||||
public static final Xoh_file_html_fmtr__base Base = new Xoh_file_html_fmtr__base();
|
||||
}
|
||||
class Xoh_file_html_fmtr__hdump extends Xoh_file_html_fmtr__base {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(128);
|
||||
@gplx.Internal @Override protected Xoh_arg_img_core New_arg_img_core() {return new Xoh_arg_img_core__hdump();}
|
||||
@Override public void Html_thumb_core(Bry_bfr bfr, int uid, byte[] div1_halign, int div2_width, byte[] div2_content) {
|
||||
tmp_bfr.Add(Hdump_html_consts.Key_img_style);
|
||||
tmp_bfr.Add_int_variable(uid);
|
||||
tmp_bfr.Add_byte_apos();
|
||||
byte[] div2_width_repl = tmp_bfr.XtoAryAndClear();
|
||||
fmtr_thumb_core.Bld_bfr_many(bfr, uid, div1_halign, div2_width_repl, div2_content);
|
||||
}
|
||||
@Override public void Html_thumb_part_magnify(Bry_bfr bfr, int uid, byte[] a_href, byte[] a_title, byte[] img_src) {Write_xnde(bfr, Hdump_html_consts.Key_file_mgnf, uid);}
|
||||
@Override public void Html_thumb_part_info(Bry_bfr bfr, int uid, byte[] a_href, byte[] img_src) {Write_xnde(bfr, Hdump_html_consts.Key_file_info, uid);}
|
||||
@Override public void Html_thumb_part_play(Bry_bfr bfr, int uid, int a_width, int a_max_width, byte[] a_href, byte[] a_xowa_title, byte[] img_src) {Write_xnde(bfr, Hdump_html_consts.Key_file_play, uid);}
|
||||
public static void Write_xnde(Bry_bfr bfr, byte[] key, int uid) {
|
||||
bfr.Add(key);
|
||||
bfr.Add_int_variable(uid);
|
||||
bfr.Add(Bry_xnde_end);
|
||||
} private static final byte[] Bry_xnde_end = Bry_.new_ascii_("'/>");
|
||||
public static final Xoh_file_html_fmtr__hdump Hdump = new Xoh_file_html_fmtr__hdump(); Xoh_file_html_fmtr__hdump() {}
|
||||
}
|
@ -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.html.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.hdumps.htmls.*;
|
||||
public class Xoh_file_html_fmtr__hdump extends Xoh_file_html_fmtr__base {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(128);
|
||||
@gplx.Internal @Override protected Xoh_arg_img_core New_arg_img_core() {return new Xoh_arg_img_core__hdump();}
|
||||
@Override public void Html_thumb_core(Bry_bfr bfr, int uid, byte[] div1_halign, int div2_width, byte[] div2_content) {
|
||||
tmp_bfr.Add(Hdump_html_consts.Key_img_style);
|
||||
tmp_bfr.Add_int_variable(uid);
|
||||
tmp_bfr.Add_byte_apos();
|
||||
byte[] div2_width_repl = tmp_bfr.XtoAryAndClear();
|
||||
fmtr_thumb_core.Bld_bfr_many(bfr, uid, div1_halign, div2_width_repl, div2_content);
|
||||
}
|
||||
@Override public void Html_thumb_part_magnify(Bry_bfr bfr, int uid, byte[] a_href, byte[] a_title, byte[] img_src) {Write_xnde(bfr, Hdump_html_consts.Key_file_mgnf, uid);}
|
||||
@Override public void Html_thumb_part_info(Bry_bfr bfr, int uid, byte[] a_href, byte[] img_src) {Write_xnde(bfr, Hdump_html_consts.Key_file_info, uid);}
|
||||
@Override public void Html_thumb_part_play(Bry_bfr bfr, int uid, int a_width, int a_max_width, byte[] a_href, byte[] a_xowa_title, byte[] img_src) {Write_xnde(bfr, Hdump_html_consts.Key_file_play, uid);}
|
||||
public static void Write_xnde(Bry_bfr bfr, byte[] key, int uid) {
|
||||
bfr.Add(key);
|
||||
bfr.Add_int_variable(uid);
|
||||
bfr.Add(Bry_xnde_end);
|
||||
} private static final byte[] Bry_xnde_end = Bry_.new_ascii_("'/>");
|
||||
public static final Xoh_file_html_fmtr__hdump Hdump = new Xoh_file_html_fmtr__hdump(); Xoh_file_html_fmtr__hdump() {}
|
||||
}
|
@ -30,6 +30,7 @@ public class Xoa_available_wikis_mgr implements GfoInvkAble {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_xwiki_itm itm = xwiki_mgr.Get_at(i);
|
||||
if (itm.Wiki_tid() == Xow_wiki_domain_.Tid_home) continue;// don't show home wiki
|
||||
if (!itm.Offline()) continue; // only show items marked Offline (added by Available_from_fsys); DATE:2014-09-21
|
||||
itms_as_html_fmtr.Bld_bfr_many(tmp_bfr, itm.Domain(), itm_cls);
|
||||
}
|
||||
itms_as_html = tmp_bfr.XtoStr();
|
||||
|
@ -63,6 +63,7 @@ public class Http_server_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Xoa_app App() {return app;} private Xoa_app app;
|
||||
public int Port() {return port;} public Http_server_mgr Port_(int v) {port = v; return this;} private int port = 8080;
|
||||
public String Home() {return home;} public void Home_(String v) {home = v;} private String home = "home/wiki/Main_Page";
|
||||
private boolean init_gui_done = false;
|
||||
private void Init_gui() { // create a shim gui to automatically handle default XOWA gui JS calls
|
||||
if (init_gui_done) return;
|
||||
@ -78,7 +79,7 @@ public class Http_server_mgr implements GfoInvkAble {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, page_ttl); // get the ttl
|
||||
Xoa_page page = wiki.GetPageByTtl(page_url, ttl); // get page and parse it
|
||||
if (app.Gui_mgr().Browser_win().Active_tab() == null) // no active tab
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(); // create at least one active tab; DATE:2014-07-30
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(page); // create at least one active tab; DATE:2014-07-30
|
||||
app.Gui_mgr().Browser_win().Active_page_(page); // HACK: init gui_mgr's page for output (which server ordinarily doesn't need)
|
||||
if (page.Missing()) { // if page does not exist, replace with message; else null_ref error; DATE:2014-03-08
|
||||
page.Data_raw_(Bry_.new_ascii_("'''Page not found.'''"));
|
||||
@ -218,8 +219,7 @@ class HttpRequest implements Runnable{
|
||||
|
||||
if(!req.contains("%file%")){
|
||||
if(req.equals("/")){
|
||||
req+="home/wiki/Main_Page"; //Forward to main page
|
||||
/*Maybe add here a address from a config file, so that a custom main page could be defined*/
|
||||
req += app.Http_server().Home();
|
||||
}
|
||||
if(req.endsWith("wiki/")) req+="Main_Page";
|
||||
if(req.endsWith("wiki")) req+="/Main_Page";
|
||||
|
@ -41,65 +41,65 @@ public class Wmf_dump_list_parser_tst {
|
||||
, fxt.itm("zh-classicalwiki", "20131128", Wmf_dump_itm.Status_tid_complete, "Dump complete", "2013-11-28 06:08:56")
|
||||
);
|
||||
}
|
||||
@Test public void Update() { // 2014-07-06
|
||||
Hash_adp_bry excluded_domains = Hash_adp_bry.cs_().Add_many_str
|
||||
( "advisory.wikipedia.org", "beta.wikiversity.org", "donate.wikipedia.org", "login.wikipedia.org"
|
||||
, "nostalgia.wikipedia.org", "outreach.wikipedia.org", "quality.wikipedia.org", "sources.wikipedia.org"
|
||||
, "strategy.wikipedia.org", "ten.wikipedia.org", "test2.wikipedia.org", "test.wikipedia.org"
|
||||
, "usability.wikipedia.org", "vote.wikipedia.org");
|
||||
Wmf_dump_itm[] itms = new Wmf_dump_list_parser().Parse(Io_mgr._.LoadFilBry("C:\\xowa\\bin\\any\\html\\xowa\\maint\\backup-index.html"));
|
||||
Array_.Sort(itms);
|
||||
Bry_bfr sql_bfr = Bry_bfr.new_();
|
||||
Bry_bfr bld_bfr = Bry_bfr.new_();
|
||||
int itms_len = itms.length;
|
||||
int counter = 1;
|
||||
for (int i = 0; i < itms_len; i++) {
|
||||
Wmf_dump_itm itm = itms[i];
|
||||
byte[] abrv = itm.Wiki_abrv();
|
||||
if (Bry_.Eq(abrv, Bry_.new_ascii_("testwikidatawiki"))) continue;
|
||||
byte[] domain_bry = Xob_bz2_file.Parse__domain_name(abrv, 0, abrv.length);
|
||||
if (domain_bry == null) continue; // not a standard WMF wiki; ignore
|
||||
if (Bry_finder.Find_fwd(domain_bry, Bry_.new_ascii_("wikimania")) != Bry_.NotFound) continue;
|
||||
if (excluded_domains.Has(domain_bry)) continue;
|
||||
Xow_wiki_domain domain_itm = Xow_wiki_domain_.parse_by_domain(domain_bry);
|
||||
byte[] tid_name = Xto_display_name(Xow_wiki_domain_.Key_by_tid(domain_itm.Tid()));
|
||||
sql_bfr
|
||||
.Add_byte(Byte_ascii.Paren_bgn)
|
||||
.Add_int_variable(counter++)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_int_variable(1)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add(domain_itm.Lang_orig())
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add(tid_name)
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add_byte(Byte_ascii.Paren_end)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_str("--" + String_.new_utf8_(abrv))
|
||||
.Add_byte_nl()
|
||||
;
|
||||
bld_bfr
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_byte(Byte_ascii.Space)
|
||||
.Add_byte(Byte_ascii.Quote)
|
||||
.Add(domain_bry)
|
||||
.Add_byte(Byte_ascii.Quote)
|
||||
.Add_byte_nl()
|
||||
;
|
||||
}
|
||||
Io_url temp = Io_url_.new_fil_("C:\\import_update.txt");
|
||||
Io_mgr._.SaveFilBfr(temp, sql_bfr);
|
||||
// Io_mgr._.AppendFilBfr(temp, bld_bfr);
|
||||
}
|
||||
private static byte[] Xto_display_name(byte[] v) {
|
||||
if (Bry_.Eq(v, Xow_wiki_domain_.Key_wikimediafoundation_bry)) return Bry_.new_ascii_("Wikimedia Foundation");
|
||||
else if (Bry_.Eq(v, Xow_wiki_domain_.Key_species_bry)) return Bry_.new_ascii_("Wikispecies");
|
||||
else if (Bry_.Eq(v, Xow_wiki_domain_.Key_mediawiki_bry)) return Bry_.new_ascii_("MediaWiki");
|
||||
else return Bry_.Add(Byte_ascii.Case_upper(v[0]), Bry_.Mid(v, 1, v.length));
|
||||
}
|
||||
// @Test public void Update() { // 2014-07-06
|
||||
// Hash_adp_bry excluded_domains = Hash_adp_bry.cs_().Add_many_str
|
||||
// ( "advisory.wikipedia.org", "beta.wikiversity.org", "donate.wikipedia.org", "login.wikipedia.org"
|
||||
// , "nostalgia.wikipedia.org", "outreach.wikipedia.org", "quality.wikipedia.org", "sources.wikipedia.org"
|
||||
// , "strategy.wikipedia.org", "ten.wikipedia.org", "test2.wikipedia.org", "test.wikipedia.org"
|
||||
// , "usability.wikipedia.org", "vote.wikipedia.org");
|
||||
// Wmf_dump_itm[] itms = new Wmf_dump_list_parser().Parse(Io_mgr._.LoadFilBry("C:\\xowa\\bin\\any\\html\\xowa\\maint\\backup-index.html"));
|
||||
// Array_.Sort(itms);
|
||||
// Bry_bfr sql_bfr = Bry_bfr.new_();
|
||||
// Bry_bfr bld_bfr = Bry_bfr.new_();
|
||||
// int itms_len = itms.length;
|
||||
// int counter = 1;
|
||||
// for (int i = 0; i < itms_len; i++) {
|
||||
// Wmf_dump_itm itm = itms[i];
|
||||
// byte[] abrv = itm.Wiki_abrv();
|
||||
// if (Bry_.Eq(abrv, Bry_.new_ascii_("testwikidatawiki"))) continue;
|
||||
// byte[] domain_bry = Xob_bz2_file.Parse__domain_name(abrv, 0, abrv.length);
|
||||
// if (domain_bry == null) continue; // not a standard WMF wiki; ignore
|
||||
// if (Bry_finder.Find_fwd(domain_bry, Bry_.new_ascii_("wikimania")) != Bry_.NotFound) continue;
|
||||
// if (excluded_domains.Has(domain_bry)) continue;
|
||||
// Xow_wiki_domain domain_itm = Xow_wiki_domain_.parse_by_domain(domain_bry);
|
||||
// byte[] tid_name = Xto_display_name(Xow_wiki_domain_.Key_by_tid(domain_itm.Tid()));
|
||||
// sql_bfr
|
||||
// .Add_byte(Byte_ascii.Paren_bgn)
|
||||
// .Add_int_variable(counter++)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_int_variable(1)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add(domain_itm.Lang_orig())
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add(tid_name)
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add_byte(Byte_ascii.Paren_end)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_str("--" + String_.new_utf8_(abrv))
|
||||
// .Add_byte_nl()
|
||||
// ;
|
||||
// bld_bfr
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_byte(Byte_ascii.Space)
|
||||
// .Add_byte(Byte_ascii.Quote)
|
||||
// .Add(domain_bry)
|
||||
// .Add_byte(Byte_ascii.Quote)
|
||||
// .Add_byte_nl()
|
||||
// ;
|
||||
// }
|
||||
// Io_url temp = Io_url_.new_fil_("C:\\import_update.txt");
|
||||
// Io_mgr._.SaveFilBfr(temp, sql_bfr);
|
||||
//// Io_mgr._.AppendFilBfr(temp, bld_bfr);
|
||||
// }
|
||||
// private static byte[] Xto_display_name(byte[] v) {
|
||||
// if (Bry_.Eq(v, Xow_wiki_domain_.Key_wikimediafoundation_bry)) return Bry_.new_ascii_("Wikimedia Foundation");
|
||||
// else if (Bry_.Eq(v, Xow_wiki_domain_.Key_species_bry)) return Bry_.new_ascii_("Wikispecies");
|
||||
// else if (Bry_.Eq(v, Xow_wiki_domain_.Key_mediawiki_bry)) return Bry_.new_ascii_("MediaWiki");
|
||||
// else return Bry_.Add(Byte_ascii.Case_upper(v[0]), Bry_.Mid(v, 1, v.length));
|
||||
// }
|
||||
}
|
||||
class Wmf_dump_list_parser_fxt {
|
||||
public void Clear() {}
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.specials; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoa_special_mgr implements GfoInvkAble {
|
||||
private OrderedHash hash = OrderedHash_.new_();
|
||||
public Xoa_special_mgr() {
|
||||
hash.Add(gplx.xowa.xtns.wdatas.Wdata_itemByTitle_cfg.Key, new gplx.xowa.xtns.wdatas.Wdata_itemByTitle_cfg());
|
||||
hash.Add(gplx.xowa.xtns.wdatas.specials.Wdata_itemByTitle_cfg.Key, new gplx.xowa.xtns.wdatas.specials.Wdata_itemByTitle_cfg());
|
||||
}
|
||||
public void Add(String key, GfoInvkAble cfg) {hash.Add(key, cfg);}
|
||||
public GfoInvkAble Get_or_null(String key) {return (GfoInvkAble)hash.Fetch(key);}
|
||||
|
@ -20,7 +20,7 @@ import gplx.xowa.users.history.*;
|
||||
import gplx.xowa.specials.*;
|
||||
import gplx.xowa.specials.allPages.*; import gplx.xowa.specials.search.*; import gplx.xowa.specials.nearby.*; import gplx.xowa.specials.randoms.*; import gplx.xowa.specials.statistics.*; import gplx.xowa.xtns.translates.*; import gplx.xowa.specials.movePage.*;
|
||||
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.xtns.wdatas.specials.*;
|
||||
public class Xows_mgr {
|
||||
private Hash_adp_bry hash;
|
||||
public Xows_mgr(Xow_wiki wiki, Xol_lang lang) {
|
||||
|
@ -16,8 +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.users; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.users.dbs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.users.history.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.users.dbs.*; import gplx.xowa.users.history.*; import gplx.xowa.xtns.scribunto.*;
|
||||
public class Xou_user implements GfoInvkAble {
|
||||
public Xou_user(Xoa_app app, Io_url user_dir) {
|
||||
this.app = app; this.key_str = user_dir.NameOnly(); key_bry = Bry_.new_utf8_(key_str);
|
||||
@ -53,8 +52,10 @@ public class Xou_user implements GfoInvkAble {
|
||||
public void Init_by_app() {
|
||||
Io_url user_system_cfg = fsys_mgr.App_data_cfg_dir().GenSubFil(Xou_fsys_mgr.Name_user_system_cfg);
|
||||
if (!Io_mgr._.ExistsFil(user_system_cfg)) Xou_user_.User_system_cfg_make(app.Usr_dlg(), user_system_cfg);
|
||||
if (!Env_.Mode_testing())
|
||||
if (!Env_.Mode_testing()) {
|
||||
db_mgr.App_init();
|
||||
this.Available_from_fsys();
|
||||
}
|
||||
}
|
||||
public void App_term() {
|
||||
session_mgr.Window_mgr().Save_window(app.Gui_mgr().Browser_win().Win_box());
|
||||
@ -105,7 +106,9 @@ public class Xou_user implements GfoInvkAble {
|
||||
// || !Io_mgr._.ExistsDir(dir.GenSubFil_nest("ns"))
|
||||
) continue;
|
||||
byte[] dir_name_as_bry = Bry_.new_utf8_(name);
|
||||
Available_add(usr_wiki, dir_name_as_bry);
|
||||
Xow_xwiki_itm xwiki = Available_add(usr_wiki, dir_name_as_bry);
|
||||
if (xwiki != null) // Add_full can return null if adding invalid lang; should not apply here, but guard against null ref
|
||||
xwiki.Offline_(true); // mark xwiki as offline; needed for available wikis sidebar; DATE:2014-09-21
|
||||
app.Setup_mgr().Maint_mgr().Wiki_mgr().Add(dir_name_as_bry);
|
||||
}
|
||||
}
|
||||
@ -116,5 +119,7 @@ public class Xou_user implements GfoInvkAble {
|
||||
for (int i = 0; i < wikis_len; i++)
|
||||
Available_add(usr_wiki, wikis[i]);
|
||||
}
|
||||
private void Available_add(Xow_wiki usr_wiki, byte[] wiki_name) {usr_wiki.Xwiki_mgr().Add_full(wiki_name, wiki_name);}
|
||||
private Xow_xwiki_itm Available_add(Xow_wiki usr_wiki, byte[] wiki_name) {
|
||||
return usr_wiki.Xwiki_mgr().Add_full(wiki_name, wiki_name);
|
||||
}
|
||||
}
|
||||
|
@ -16,19 +16,41 @@ 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.users; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xou_user_tst {
|
||||
private Xou_user_fxt fxt = new Xou_user_fxt();
|
||||
@Test public void Run() {
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
Io_url user_system_cfg_url = Io_url_.mem_fil_("mem/xowa/user/test_user/app/data/cfg/user_system_cfg.gfs");
|
||||
Fil_tst(user_system_cfg_url, ""); // check that it is blank
|
||||
app.Init(); // run Init
|
||||
Fil_tst(user_system_cfg_url, Xou_user_.User_system_cfg_text); // check that it is created
|
||||
fxt.Test_fil(user_system_cfg_url, ""); // check that it is blank
|
||||
fxt.App().Init(); // run Init
|
||||
fxt.Test_fil(user_system_cfg_url, Xou_user_.User_system_cfg_text); // check that it is created
|
||||
Io_mgr._.SaveFilStr(user_system_cfg_url, ""); // simulate edit by blanking out file
|
||||
app.Init(); // run Init again
|
||||
Fil_tst(user_system_cfg_url, ""); // check that it is still blank
|
||||
fxt.App().Init(); // run Init again
|
||||
fxt.Test_fil(user_system_cfg_url, ""); // check that it is still blank
|
||||
}
|
||||
private void Fil_tst(Io_url url, String expd) {
|
||||
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(url));
|
||||
@Test public void Available_from_fsys() {
|
||||
Io_mgr._.CreateDir(fxt.App().Fsys_mgr().Wiki_dir().GenSubDir("en.wikipedia.org"));
|
||||
fxt.App().User().Available_from_fsys();
|
||||
fxt.Test_xwikis
|
||||
( fxt.Make_xwiki(Bool_.N, "home")
|
||||
, fxt.Make_xwiki(Bool_.Y, "en.wikipedia.org") // available_from_fsys should mark as offline=y
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xou_user_fxt {
|
||||
public Xoa_app App() {return app;} private Xoa_app app = Xoa_app_fxt.app_();
|
||||
public String Make_xwiki(boolean offline, String name) {return String_.Concat_with_str("|", Yn.Xto_str(offline), name);}
|
||||
public void Test_fil(Io_url url, String expd) {
|
||||
Tfds.Eq_str_lines(expd, Io_mgr._.LoadFilStr(url));
|
||||
}
|
||||
public void Test_xwikis(String... expd) {
|
||||
Xow_xwiki_mgr xwiki_mgr = app.User().Wiki().Xwiki_mgr();
|
||||
int len = xwiki_mgr.Len();
|
||||
String[] actl = new String[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_xwiki_itm xwiki_itm = xwiki_mgr.Get_at(i);
|
||||
actl[i] = Make_xwiki(xwiki_itm.Offline(), String_.new_utf8_(xwiki_itm.Name()));
|
||||
}
|
||||
Tfds.Eq_ary_str(expd, actl);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
private Xow_xwiki_mgr_srl srl;
|
||||
public Xow_xwiki_mgr() {} // FIXME: current placeholder for viewer
|
||||
public Xow_xwiki_mgr(Xow_wiki wiki) {this.wiki = wiki; srl = new Xow_xwiki_mgr_srl(this);}
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Xow_lang_mgr Lang_mgr() {return lang_mgr;} private Xow_lang_mgr lang_mgr = Xow_lang_mgr.dflt_();
|
||||
@ -26,20 +27,21 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
public Xow_xwiki_itm Get_at(int i) {return (Xow_xwiki_itm)list.FetchAt(i);}
|
||||
public Xow_xwiki_itm Get_by_key(byte[] key) {return (Xow_xwiki_itm)hash.Get_by_bry(key);}
|
||||
public Xow_xwiki_itm Get_by_mid(byte[] src, int bgn, int end) {return (Xow_xwiki_itm)hash.Get_by_mid(src, bgn, end);}
|
||||
public void Add_full(String alias, String domain) {Add_full(Bry_.new_ascii_(alias), Bry_.new_ascii_(domain), null);}
|
||||
public void Add_full(byte[] alias, byte[] domain) {Add_full(alias, domain, null);}
|
||||
public void Add_full(byte[] alias, byte[] domain, byte[] fmt) {
|
||||
public Xow_xwiki_itm Add_full(String alias, String domain) {return Add_full(Bry_.new_ascii_(alias), Bry_.new_ascii_(domain), null);}
|
||||
public Xow_xwiki_itm Add_full(byte[] alias, byte[] domain) {return Add_full(alias, domain, null);}
|
||||
public Xow_xwiki_itm Add_full(byte[] alias, byte[] domain, byte[] fmt) {
|
||||
byte wiki_tid = Byte_.Zero;
|
||||
int lang_tid = -1;
|
||||
Xow_wiki_domain wiki_type = Xow_wiki_domain_.parse_by_domain(domain);
|
||||
wiki_tid = wiki_type.Tid();
|
||||
if (Bry_.Len_gt_0(wiki_type.Lang())) { // domain has lang (EX: "en.")
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key(wiki_type.Lang());
|
||||
if (lang_itm == null) return; // unknown lang: do not add to wiki collection; EX: en1.wikipedia.org
|
||||
if (lang_itm == null) return null; // unknown lang: do not add to wiki collection; EX: en1.wikipedia.org
|
||||
lang_tid = lang_itm.Id();
|
||||
}
|
||||
Xow_xwiki_itm itm = new Xow_xwiki_itm(alias, fmt, wiki_tid, lang_tid, domain);
|
||||
Add_itm(itm, null);
|
||||
return itm;
|
||||
}
|
||||
public void Sort_by_key() {
|
||||
list.Sort();
|
||||
|
@ -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.hieros; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.html.modules.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.html.modules.*; import gplx.xowa.apps.fsys.*;
|
||||
public class Hiero_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
|
||||
@Override public boolean Enabled_default() {return true;}
|
||||
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_ascii_("hiero");
|
||||
@ -28,7 +28,7 @@ public class Hiero_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
|
||||
if (xtn_init_done) return;
|
||||
if (!Enabled()) return;
|
||||
Xoa_app app = wiki.App();
|
||||
Io_url ext_root_dir = Hiero_root_dir(app);
|
||||
Io_url ext_root_dir = Hiero_root_dir(app.Fsys_mgr());
|
||||
Img_src_dir = Bry_.new_utf8_(ext_root_dir.GenSubDir("img").To_http_file_str());
|
||||
app.Gfs_mgr().Run_url_for(this, ext_root_dir.GenSubFil_nest("data", "tables.gfs"));
|
||||
html_wtr = new Hiero_html_mgr(this);
|
||||
@ -52,5 +52,5 @@ public class Hiero_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
}
|
||||
public static final String Invk_prefabs = "prefabs", Invk_files = "files", Invk_phonemes = "phonemes";
|
||||
public static Io_url Hiero_root_dir(Xoa_app app) {return app.Fsys_mgr().Bin_xtns_dir().GenSubDir("Wikihiero");}
|
||||
public static Io_url Hiero_root_dir(Xoa_fsys_mgr fsys_mgr) {return fsys_mgr.Bin_xtns_dir().GenSubDir("Wikihiero");}
|
||||
}
|
||||
|
@ -349,9 +349,9 @@ public class Pf_func_ {
|
||||
case Xol_kwd_grp_.Id_lstx: return gplx.xowa.xtns.lst.Lst_pfunc_lstx._;
|
||||
case Xol_kwd_grp_.Id_invoke: return new gplx.xowa.xtns.scribunto.Scrib_invoke_func();
|
||||
|
||||
case Xol_kwd_grp_.Id_property: return new gplx.xowa.xtns.wdatas.Wdata_pf_property();
|
||||
case Xol_kwd_grp_.Id_noexternallanglinks: return new gplx.xowa.xtns.wdatas.Wdata_pf_noExternalLangLinks();
|
||||
case Xol_kwd_grp_.Id_wbreponame: return new gplx.xowa.xtns.wdatas.Wdata_pf_wbreponame();
|
||||
case Xol_kwd_grp_.Id_property: return new gplx.xowa.xtns.wdatas.pfuncs.Wdata_pf_property();
|
||||
case Xol_kwd_grp_.Id_noexternallanglinks: return new gplx.xowa.xtns.wdatas.pfuncs.Wdata_pf_noExternalLangLinks();
|
||||
case Xol_kwd_grp_.Id_wbreponame: return new gplx.xowa.xtns.wdatas.pfuncs.Wdata_pf_wbreponame();
|
||||
|
||||
case Xol_kwd_grp_.Id_mapSources_deg2dd: return gplx.xowa.xtns.mapSources.Map_deg2dd_func._;
|
||||
case Xol_kwd_grp_.Id_mapSources_dd2dms: return gplx.xowa.xtns.mapSources.Map_dd2dms_func._;
|
||||
|
@ -52,13 +52,21 @@ public class Pfunc_ifexist_mgr {
|
||||
}
|
||||
private boolean Find_ttl_for_media_ns(Pfunc_ifexist_itm itm, Xow_wiki wiki, Xow_ns ns, byte[] ttl_bry) {
|
||||
Xow_ns file_ns = wiki.Ns_mgr().Ns_file();
|
||||
boolean rv = Find_ttl_in_db(itm, wiki, file_ns, ttl_bry); if (rv) return true; // rarely true, but check first anyway
|
||||
boolean rv = Find_ttl_in_db(itm, wiki, file_ns, ttl_bry); if (rv) return true; // rarely true, but check local wiki's [[File:]] table anyway
|
||||
Xow_wiki commons_wiki = wiki.App().Wiki_mgr().Wiki_commons();
|
||||
if (commons_wiki == null)
|
||||
return wiki.File_mgr().Exists(ttl_bry); // user may not have commons_wiki; try to check files
|
||||
else {
|
||||
boolean env_is_testing = Env_.Mode_testing();
|
||||
if ( commons_wiki != null // null check
|
||||
&& ( commons_wiki.Init_assert().Db_mgr().Tid() == gplx.xowa.dbs.Xodb_mgr_sql.Tid_sql // make sure tid=sql; tid=txt automatically created for online images; DATE:2014-09-21
|
||||
|| env_is_testing
|
||||
)
|
||||
) {
|
||||
file_ns = commons_wiki.Ns_mgr().Ns_file();
|
||||
return Find_ttl_in_db(itm, commons_wiki, file_ns, ttl_bry); // accurate test of whether or not Media file exists
|
||||
return Find_ttl_in_db(itm, commons_wiki, file_ns, ttl_bry); // accurate test using page table in commons wiki (provided commons is up to date)
|
||||
}
|
||||
else {
|
||||
if (!env_is_testing)
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki__add_bin_wkrs(wiki); // NOTE: must init Fsdb_mgr (else provider == null), and with bin_wkrs (else no images will ever load); DATE:2014-09-21
|
||||
return wiki.File_mgr().Exists(ttl_bry); // less-accurate test using either (1) orig_wiki table in local wiki (v2) or (2) meta_db_mgr (v1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class Pfunc_filepath extends Pf_func_base {
|
||||
byte[] val_ary = Eval_argx(ctx, src, caller, self); if (val_ary == Bry_.Empty) return;
|
||||
Xow_wiki wiki = ctx.Wiki();
|
||||
val_ary = Bry_.Add(Bry_file, val_ary);
|
||||
Xoa_ttl ttl = Xoa_ttl.new_(wiki, ctx.App().Msg_log_null(), val_ary, val_ary, 0, val_ary.length); if (ttl == null) return; // text is not valid ttl; return;
|
||||
Xoa_ttl ttl = Xoa_ttl.new_(wiki, ctx.App().Msg_log_null(), val_ary, 0, val_ary.length); if (ttl == null) return; // text is not valid ttl; return;
|
||||
Xoa_page page = Load_page(wiki, ttl);
|
||||
if (page.Missing()) return; // page not found in commons; exit;
|
||||
byte[] ttl_bry = page.Ttl().Page_url();
|
||||
|
@ -23,7 +23,7 @@ public class Pfunc_titleparts extends Pf_func_base {
|
||||
// get argx
|
||||
int args_len = self.Args_len();
|
||||
byte[] argx = Eval_argx(ctx, src, caller, self); if (argx == null) return; // no argx; return empty
|
||||
Xoa_ttl argx_as_ttl = Xoa_ttl.new_(ctx.Wiki(), ctx.App().Msg_log_null(), argx, argx, 0, argx.length); // transform to title in order to upper first, replace _, etc..
|
||||
Xoa_ttl argx_as_ttl = Xoa_ttl.new_(ctx.Wiki(), ctx.App().Msg_log_null(), argx, 0, argx.length); // transform to title in order to upper first, replace _, etc..
|
||||
if (argx_as_ttl == null) {bb.Add(argx); return;} // NOTE: argx_as_ttl will be null if invalid, such as [[a|b]]; PAGE:en.w:owl and {{taxobox/showtaxon|Dinosauria}}
|
||||
else argx = argx_as_ttl.Full_txt();
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class Pfunc_urlfunc extends Pf_func_base { // EX: {{lc:A}} -> a
|
||||
}
|
||||
public static void UrlString(Xop_ctx ctx, byte tid, boolean encode, byte[] src, Bry_bfr trg, byte[] qry_arg) {
|
||||
Xow_wiki wiki = ctx.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.new_(wiki, ctx.Msg_log(), src, src, 0, src.length);
|
||||
Xoa_ttl ttl = Xoa_ttl.new_(wiki, ctx.Msg_log(), src, 0, src.length);
|
||||
if (ttl == null) return; // NOTE: guard against null ttl; EX: {{fullurl:{{transclude|{{{1}}}}}|action=edit}} -> {{fullurl:Template:{{{1}}}|action=edit}} -> Template:{{{1}}} will be a null ttl
|
||||
byte[] ttl_ary = ttl.Full_url();// NOTE: Full_url does encoding; don't encode again
|
||||
Xow_xwiki_itm xwiki = ttl.Wik_itm();
|
||||
|
@ -120,22 +120,22 @@ public class Scrib_core_fxt {
|
||||
else
|
||||
this.Expd_server_rcvd_add("000000380000006F{[\"op\"]=\"return\",[\"nvalues\"]=1,[\"values\"]={[1]=\"" + expd + "\"}}");
|
||||
this.Init_server_prep_add("a:2:{s:6:\"values\";a:1:{i:1;s:6:\"ignore\";}s:2:\"op\";s:6:\"return\";}");
|
||||
core.Frame_current_(Xot_invk_mock.new_(args));
|
||||
core.Frame_current_(Xot_invk_mock.new_(Frame_ttl_test, args));
|
||||
core.Interpreter().ExecuteModule(9);
|
||||
Test_server_logs();
|
||||
return this;
|
||||
}
|
||||
public Scrib_core_fxt Test_GetAllExpandedArguments(KeyVal... args) {
|
||||
core.Frame_current_(Xot_invk_mock.new_(args));
|
||||
core.Frame_current_(Xot_invk_mock.new_(Frame_ttl_test, args));
|
||||
core.Interpreter().ExecuteModule(9);
|
||||
Test_server_logs();
|
||||
return this;
|
||||
}
|
||||
public Scrib_core_fxt Test_Invoke(String mod_name, String mod_code, String prc_name, KeyVal... args) {
|
||||
core.Invoke(wiki, core.Ctx(), Bry_.Empty, Xot_invk_mock.Null, Xot_invk_mock.new_(args), tmp_bfr, Bry_.new_utf8_(mod_name), Bry_.new_utf8_(mod_code), Bry_.new_utf8_(prc_name));
|
||||
core.Invoke(wiki, core.Ctx(), Bry_.Empty, Xot_invk_mock.Null, Xot_invk_mock.new_(Frame_ttl_test, args), tmp_bfr, Bry_.new_utf8_(mod_name), Bry_.new_utf8_(mod_code), Bry_.new_utf8_(prc_name));
|
||||
Test_server_logs();
|
||||
return this;
|
||||
}
|
||||
} private static final byte[] Frame_ttl_test = Bry_.new_ascii_("test");
|
||||
private void Test_server_logs() {
|
||||
if (expd_server_rcvd_list.Count() > 0) {
|
||||
Tfds.Eq_ary_str(expd_server_rcvd_list.XtoStrAry(), server.Log_rcvd().XtoStrAry());
|
||||
|
@ -27,7 +27,7 @@ public class Scrib_frame_ {
|
||||
public static Xot_invk Get_frame(Scrib_core core, String frame_id) {
|
||||
if (String_.Eq(frame_id, "current")) return core.Frame_current();
|
||||
else if (String_.Eq(frame_id, "parent")) return core.Frame_parent();
|
||||
else if (String_.Eq(frame_id, "empty")) return Xot_invk_mock.new_(core.Frame_current().Defn_tid(), 0, KeyVal_.Ary_empty); // not sure if it should return null title; DATE:2014-07-12
|
||||
else if (String_.Eq(frame_id, "empty")) return Xot_invk_mock.new_(core.Frame_current().Defn_tid(), 0, null, KeyVal_.Ary_empty); // not sure if it should return null title; DATE:2014-07-12
|
||||
else {
|
||||
return (Xot_invk)core.Frame_created_list().Fetch(frame_id); // NOTE: can return null; some calls expect nil; EX:mw.lua and "currentFrame = newFrame( 'empty' )"; DATE:2014-07-12
|
||||
}
|
||||
|
@ -103,19 +103,17 @@ public class Scrib_invoke_func_fxt {
|
||||
Tfds.Eq(expd, (String)server.Log_rcvd().FetchAt(i));
|
||||
}
|
||||
public void Init_frame_parent(String ttl, KeyVal... ary) {
|
||||
core.Frame_parent_(Xot_invk_mock.test_(ary));
|
||||
core.Frame_parent().Frame_ttl_(Bry_.new_utf8_(ttl));
|
||||
core.Frame_parent_(Xot_invk_mock.test_(Bry_.new_utf8_(ttl), ary));
|
||||
}
|
||||
public void Init_frame_current(KeyVal... ary) {
|
||||
core.Frame_current_(Xot_invk_mock.test_(ary));
|
||||
core.Frame_current().Frame_ttl_(Bry_.new_ascii_("Module:Mod_0"));
|
||||
core.Frame_current_(Xot_invk_mock.test_(Bry_.new_ascii_("Module:Mod_0"), ary));
|
||||
}
|
||||
public void Clear_for_lib() {
|
||||
fxt = new Xop_fxt(); // NOTE: don't try to cache fxt on func_fxt level; causes errors in Language_lib
|
||||
core_fxt = new Scrib_core_fxt(fxt);
|
||||
core = core_fxt.Core();
|
||||
Xot_invk parent_frame = new Xot_invk_temp(true); parent_frame.Frame_tid_(Scrib_frame_.Tid_null);
|
||||
Xot_invk current_frame = Xot_invk_mock.test_(); current_frame.Frame_ttl_(Bry_.new_ascii_("Module:Mod_0"));
|
||||
Xot_invk current_frame = Xot_invk_mock.test_(Bry_.new_ascii_("Module:Mod_0"));
|
||||
core.Invoke_init(core.Wiki(), core.Ctx(), Bry_.Empty, parent_frame, current_frame);
|
||||
core.When_page_changed(fxt.Page());
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
String val = tmp_bfr.XtoStrAndClear();
|
||||
kv_args[i] = KeyVal_.new_(key, val);
|
||||
}
|
||||
Xot_invk_mock mock_frame = Xot_invk_mock.new_(kv_args);
|
||||
Xot_invk_mock mock_frame = Xot_invk_mock.new_(Bry_.new_utf8_(frame_id), kv_args); // use frame_id for Frame_ttl; in lieu of a better candidate; DATE:2014-09-21
|
||||
tmp_ctx.Parse_tid_(Xop_parser_.Parse_tid_page_tmpl); // default xnde names to template; needed for test, but should be in place; DATE:2014-06-27
|
||||
cur_wiki.Parser().Parse_text_to_wtxt(tmp_root, tmp_ctx, tmp_ctx.Tkn_mkr(), text_bry);
|
||||
tmp_root.Tmpl_evaluate(tmp_ctx, text_bry, mock_frame, tmp_bfr);
|
||||
@ -242,7 +242,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
Bry_obj_ref argx_ref = Bry_obj_ref.null_();
|
||||
Bry_obj_ref fnc_name_ref = Bry_obj_ref.new_(fnc_name);
|
||||
KeyVal[] parser_func_args = CallParserFunction_parse_args(cur_wiki.App().Utl_num_parser(), argx_ref, fnc_name_ref, args.Ary());
|
||||
Xot_invk_mock frame = Xot_invk_mock.new_(parent_frame.Defn_tid(), 0, parser_func_args);
|
||||
Xot_invk_mock frame = Xot_invk_mock.new_(parent_frame.Defn_tid(), 0, fnc_name, parser_func_args); // pass something as frame_ttl; choosng fnc_name; DATE:2014-09-21
|
||||
Xol_func_name_itm finder = cur_wiki.Lang().Func_regy().Find_defn(fnc_name, 0, fnc_name_len);
|
||||
Xot_defn defn = finder.Func();
|
||||
if (defn == Xot_defn_.Null) throw Err_.new_fmt_("callParserFunction: function \"{0}\" was not found", String_.new_utf8_(fnc_name));
|
||||
@ -305,7 +305,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
if (sub_src == null) // ttl is not in template cache, or is a ttl in non-Template ns; load title
|
||||
sub_src = core.Wiki().Cache_mgr().Page_cache().Get_or_load_as_src(ttl);
|
||||
if (sub_src != null) {
|
||||
Xot_invk_mock sub_frame = Xot_invk_mock.new_(core.Frame_current().Defn_tid(), 0, args_ary);
|
||||
Xot_invk_mock sub_frame = Xot_invk_mock.new_(core.Frame_current().Defn_tid(), 0, ttl.Full_txt(), args_ary); // NOTE: (1) must have ns (Full); (2) must be txt (space, not underscore); EX:Template:Location map+; DATE:2014-09-21
|
||||
Xot_defn_tmpl transclude_tmpl = ctx.Wiki().Parser().Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), ttl.Ns(), ttl.Page_db(), sub_src);
|
||||
Bry_bfr sub_bfr = cur_wiki.Utl_bry_bfr_mkr().Get_k004();
|
||||
transclude_tmpl.Tmpl_evaluate(ctx, sub_frame, sub_bfr);
|
||||
@ -349,8 +349,7 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
if (ttl == null) throw Err_.new_("newChild: invalid title; title={0}", (String)ttl_obj);
|
||||
}
|
||||
KeyVal[] args_ary = args.Pull_kv_ary(2);
|
||||
Xot_invk_mock new_frame = Xot_invk_mock.new_(core.Frame_current().Defn_tid(), 0, args_ary);
|
||||
new_frame.Frame_ttl_(ttl.Full_txt()); // NOTE: use spaces, not unders; REF.MW:$frame->getTitle()->getPrefixedText(); DATE:2014-08-14
|
||||
Xot_invk_mock new_frame = Xot_invk_mock.new_(core.Frame_current().Defn_tid(), 0, ttl.Full_txt(), args_ary); // NOTE: use spaces, not unders; REF.MW:$frame->getTitle()->getPrefixedText(); DATE:2014-08-14
|
||||
String new_frame_id = "frame" + Int_.Xto_str(frame_list_len);
|
||||
frame_list.Add(new_frame_id, new_frame);
|
||||
return rslt.Init_obj(new_frame_id);
|
||||
|
@ -40,16 +40,17 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
case Proc_fileExists: return FileExists(args, rslt);
|
||||
case Proc_getCurrentTitle: return GetCurrentTitle(args, rslt);
|
||||
case Proc_protectionLevels: return ProtectionLevels(args, rslt);
|
||||
case Proc_cascadingProtection: return CascadingProtection(args, rslt);
|
||||
default: throw Err_.unhandled(key);
|
||||
}
|
||||
}
|
||||
private static final int Proc_newTitle = 0, Proc_makeTitle = 1, Proc_getUrl = 2, Proc_getContent = 3, Proc_fileExists = 4, Proc_getCurrentTitle = 5, Proc_protectionLevels = 6;
|
||||
private static final int Proc_newTitle = 0, Proc_makeTitle = 1, Proc_getUrl = 2, Proc_getContent = 3, Proc_fileExists = 4, Proc_getCurrentTitle = 5, Proc_protectionLevels = 6, Proc_cascadingProtection = 7;
|
||||
public static final String
|
||||
Invk_newTitle = "newTitle", Invk_makeTitle = "makeTitle"
|
||||
, Invk_getUrl = "getUrl", Invk_getContent = "getContent", Invk_fileExists = "fileExists", Invk_getCurrentTitle = "getCurrentTitle"
|
||||
, Invk_protectionLevels = "protectionLevels"
|
||||
, Invk_protectionLevels = "protectionLevels", Invk_cascadingProtection = "cascadingProtection"
|
||||
;
|
||||
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getUrl, Invk_getContent, Invk_fileExists, Invk_getCurrentTitle, Invk_protectionLevels);
|
||||
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getUrl, Invk_getContent, Invk_fileExists, Invk_getCurrentTitle, Invk_protectionLevels, Invk_cascadingProtection);
|
||||
public boolean NewTitle(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
Object ns_obj = args.Cast_obj_or_null(1);
|
||||
@ -156,6 +157,13 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
return rslt.Init_many_objs(""); // NOTE: always return no protection; protectionLevels are stored in different table which is currently not mirrored; DATE:2014-04-09
|
||||
}
|
||||
public boolean CascadingProtection(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
Xow_wiki wiki = core.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
return rslt.Init_obj(CascadingProtection_rv);
|
||||
}
|
||||
public static final KeyVal[] CascadingProtection_rv = KeyVal_.Ary(KeyVal_.new_("sources", Bool_.N), KeyVal_.new_("restrictions", KeyVal_.Ary_empty));
|
||||
private KeyVal[] Xto_kv_ary(Xoa_ttl ttl) {
|
||||
Xow_ns ns = ttl.Ns();
|
||||
boolean ttl_exists = core.Wiki().Db_mgr().Load_mgr().Load_by_ttl(tmp_db_page, ttl.Ns(), ttl.Page_db());
|
||||
|
@ -75,6 +75,9 @@ public class Scrib_lib_title_tst {
|
||||
@Test public void ProtectionLevels() {
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_protectionLevels, Object_.Ary("A") , "");
|
||||
}
|
||||
@Test public void CascadingProtection() {
|
||||
fxt.Test_scrib_proc_obj(lib, Scrib_lib_title.Invk_cascadingProtection, Object_.Ary("A") , Scrib_lib_title.CascadingProtection_rv);
|
||||
}
|
||||
private static String ttl_data_(int ns_id, String ns_str, String ttl) {return ttl_data_(ns_id, ns_str, ttl, "", "", ttl);}
|
||||
private static String ttl_data_(int ns_id, String ns_str, String ttl, String anchor) {return ttl_data_(ns_id, ns_str, ttl, anchor, "", ttl);}
|
||||
private static String ttl_data_(int ns_id, String ns_str, String ttl, String anchor, String xwiki) {return ttl_data_(ns_id, ns_str, ttl, anchor, xwiki, ttl);}
|
||||
|
@ -16,8 +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.scribunto.lib; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.json.*;
|
||||
import gplx.json.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.parsers.*;
|
||||
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;
|
||||
@ -47,11 +46,10 @@ public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
boolean base_0 = args.Pull_bool(1);
|
||||
Xow_wiki wiki = core.Wiki();
|
||||
Wdata_wiki_mgr wdata_mgr = wiki.App().Wiki_mgr().Wdata_mgr();
|
||||
Wdata_doc page_doc = wdata_mgr.Pages_get_by_ttl_name(ttl_bry);
|
||||
if (page_doc == null) {Wdata_wiki_mgr.Log_missing_qid(core.Ctx(), ttl_bry); return rslt.Init_ary_empty();}
|
||||
if (parser == null) parser = new Wdata_doc_parser(wiki.App().Usr_dlg());
|
||||
return rslt.Init_obj(Scrib_lib_wikibase_srl.Srl(parser, page_doc, true, base_0));
|
||||
} private Wdata_doc_parser parser;
|
||||
Wdata_doc wdoc = wdata_mgr.Pages_get_by_ttl_name(ttl_bry);
|
||||
if (wdoc == null) {Wdata_wiki_mgr.Log_missing_qid(core.Ctx(), ttl_bry); return rslt.Init_ary_empty();}
|
||||
return rslt.Init_obj(Scrib_lib_wikibase_srl.Srl(wdoc, true, base_0));
|
||||
}
|
||||
public boolean GetEntityId(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
Xow_wiki wiki = core.Wiki();
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto.lib; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.json.*;
|
||||
import gplx.json.*; import gplx.xowa.xtns.wdatas.core.*;
|
||||
public class Scrib_lib_wikibase_entity implements Scrib_lib {
|
||||
public Scrib_lib_wikibase_entity(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
@ -49,7 +49,7 @@ public class Scrib_lib_wikibase_entity implements Scrib_lib {
|
||||
byte[] lang = wiki.Wdata_wiki_lang();
|
||||
Wdata_doc wdoc = wdata_mgr.Pages_get(qid); if (wdoc == null) {Wdata_wiki_mgr.Log_missing_qid(core.Ctx(), qid); return rslt.Init_str_empty();} // NOTE: return empty String, not nil; PAGE:fr.s:Henri_Bergson; DATE:2014-08-13
|
||||
int pid_int = wdata_mgr.Pids_get(lang, pid); if (pid_int == Wdata_wiki_mgr.Pid_null) return rslt.Init_str_empty();
|
||||
Wdata_prop_grp prop_grp = wdoc.Claim_list_get(pid_int); if (prop_grp == null) return rslt.Init_str_empty();
|
||||
Wdata_claim_grp prop_grp = wdoc.Claim_list_get(pid_int); if (prop_grp == null) return rslt.Init_str_empty();
|
||||
Bry_bfr bfr = app.Utl_bry_bfr_mkr().Get_b512();
|
||||
wdata_mgr.Resolve_to_bfr(bfr, prop_grp, lang);
|
||||
return rslt.Init_obj(bfr.Mkr_rls().XtoAryAndClear());
|
||||
|
@ -16,85 +16,74 @@ 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.lib; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.json.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.parsers.*;
|
||||
class Scrib_lib_wikibase_srl {
|
||||
public static KeyVal[] Srl(Wdata_doc_parser parser, Wdata_doc doc, boolean header_enabled, boolean legacy_style) {// REF.MW:/Wikibase/lib/includes/serializers/EntitySerializer.php!getSerialized; http://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua
|
||||
public static KeyVal[] Srl(Wdata_doc wdoc, boolean header_enabled, boolean legacy_style) {// REF.MW:/Wikibase/lib/includes/serializers/EntitySerializer.php!getSerialized; http://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua
|
||||
int base_adj = legacy_style ? 0 : 1;
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
if (header_enabled) {
|
||||
rv.Add(KeyVal_.new_("id", doc.Qid()));
|
||||
rv.Add(KeyVal_.new_("type", Wdata_doc_consts.Val_ent_entity_type_item_str));
|
||||
rv.Add(KeyVal_.new_("id", wdoc.Qid()));
|
||||
rv.Add(KeyVal_.new_("type", Wdata_dict_value_entity.Val_entity_type_item_str));
|
||||
rv.Add(KeyVal_.new_("schemaVersion", base_adj + 1)); // NOTE: needed by mw.wikibase.lua
|
||||
}
|
||||
Json_itm_nde root = doc.Doc().Root();
|
||||
int len = root.Subs_len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv sub = (Json_itm_kv)root.Subs_get_at(i);
|
||||
String key = sub.Key_as_str();
|
||||
if (String_.Eq(key, Wdata_doc_consts.Key_atr_label_str)) rv.Add(KeyVal_.new_("labels", Srl_nde_langs("language", "value", (Json_grp)sub.Val())));
|
||||
else if (String_.Eq(key, Wdata_doc_consts.Key_atr_description_str)) rv.Add(KeyVal_.new_("descriptions", Srl_nde_langs("language", "value", (Json_grp)sub.Val())));
|
||||
else if (String_.Eq(key, Wdata_doc_consts.Key_atr_links_str)) rv.Add(KeyVal_.new_("sitelinks", Srl_nde_sitelinks("site", "title", (Json_grp)sub.Val())));
|
||||
else if (String_.Eq(key, Wdata_doc_consts.Key_atr_aliases_str)) rv.Add(KeyVal_.new_("aliases", Srl_aliases((Json_grp)sub.Val(), base_adj)));
|
||||
else if (String_.Eq(key, Wdata_doc_consts.Key_atr_claims_str)) rv.Add(KeyVal_.new_(Wdata_doc_consts.Key_atr_claims_str, Srl_claims(parser, doc.Doc().Src(), (Json_itm_ary)sub.Val(), legacy_style, base_adj)));
|
||||
}
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_labels , Srl_langtexts (Wdata_dict_langtext.Str_language , Wdata_dict_langtext.Str_value, wdoc.Label_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_descriptions , Srl_langtexts (Wdata_dict_langtext.Str_language , Wdata_dict_langtext.Str_value, wdoc.Description_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_sitelinks , Srl_sitelinks (Wdata_dict_sitelink.Str_site , Wdata_dict_sitelink.Str_title, wdoc.Sitelink_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_aliases , Srl_aliases (base_adj, wdoc.Alias_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_claims , Srl_claims (base_adj, legacy_style, wdoc.Claim_list()));
|
||||
return (KeyVal[])rv.XtoAry(KeyVal.class);
|
||||
}
|
||||
private static KeyVal[] Srl_nde_sitelinks(String key_label, String val_label, Json_grp grp) {
|
||||
int len = grp.Subs_len();
|
||||
private static void Srl_root(ListAdp rv, String label, KeyVal[] ary) {
|
||||
if (ary == null) return; // don't add node if empty; EX: labels:{} should not add "labels" kv
|
||||
rv.Add(KeyVal_.new_(label, ary));
|
||||
}
|
||||
private static KeyVal[] Srl_langtexts(String lang_label, String text_label, OrderedHash list) {
|
||||
int len = list.Count(); if (len == 0) return null;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv sub = (Json_itm_kv)grp.Subs_get_at(i);
|
||||
String lang = sub.Key_as_str(); // key is lang; EX: enwiki
|
||||
Json_itm sub_val = sub.Val();
|
||||
Json_itm_kv sub_kv = null;
|
||||
if (sub_val.Tid() == Json_itm_.Tid_nde) { // new fmt; EX: '"enwiki":{"name":"Earth", "badges":[]}'; DATE:2014-02-03
|
||||
Json_itm_nde sub_nde = (Json_itm_nde)sub.Val(); // key is nde; see EX: above
|
||||
sub_kv = (Json_itm_kv)sub_nde.Subs_get_by_key(Wdata_doc_.Key_name); // get "name" sub
|
||||
}
|
||||
else // old fmt; EX: '"enwiki":"Earth"';DATE:2014-02-06
|
||||
sub_kv = sub;
|
||||
Object description = sub_kv == null ? null : sub_kv.Val().Data(); // get val of "name"; EX: Earth
|
||||
rv[i] = KeyVal_.new_(lang, KeyVal_.Ary(KeyVal_.new_(key_label, lang), KeyVal_.new_(val_label, description)));
|
||||
Wdata_langtext_itm itm = (Wdata_langtext_itm)list.FetchAt(i);
|
||||
String lang = String_.new_utf8_(itm.Lang());
|
||||
String text = String_.new_utf8_(itm.Text());
|
||||
rv[i] = KeyVal_.new_(lang, KeyVal_.Ary(KeyVal_.new_(lang_label, lang), KeyVal_.new_(text_label, text)));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_nde_langs(String key_label, String val_label, Json_grp grp) {
|
||||
int len = grp.Subs_len();
|
||||
private static KeyVal[] Srl_sitelinks(String key_label, String val_label, OrderedHash list) {
|
||||
int len = list.Count(); if (len == 0) return null;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv sub = (Json_itm_kv)grp.Subs_get_at(i);
|
||||
String lang = sub.Key_as_str();
|
||||
Object description = sub.Val().Data();
|
||||
rv[i] = KeyVal_.new_(lang, KeyVal_.Ary(KeyVal_.new_(key_label, lang), KeyVal_.new_(val_label, description)));
|
||||
Wdata_sitelink_itm itm = (Wdata_sitelink_itm)list.FetchAt(i);
|
||||
String site = String_.new_utf8_(itm.Site());
|
||||
String name = String_.new_utf8_(itm.Name());
|
||||
rv[i] = KeyVal_.new_(site, KeyVal_.Ary(KeyVal_.new_(key_label, site), KeyVal_.new_(val_label, name)));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_aliases(Json_grp grp, int base_adj) {
|
||||
int len = grp.Subs_len();
|
||||
private static KeyVal[] Srl_aliases(int base_adj, OrderedHash list) {
|
||||
int len = list.Count(); if (len == 0) return null;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv sub = (Json_itm_kv)grp.Subs_get_at(i);
|
||||
String lang = sub.Key_as_str();
|
||||
rv[i] = KeyVal_.new_(lang, Srl_aliases_langs(lang, (Json_grp)sub.Val(), base_adj));
|
||||
Wdata_alias_itm itm = (Wdata_alias_itm)list.FetchAt(i);
|
||||
String lang = String_.new_utf8_(itm.Lang());
|
||||
rv[i] = KeyVal_.new_(lang, Srl_aliases_langs(base_adj, lang, itm.Vals()));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_aliases_langs(String lang, Json_grp ary, int base_adj) {
|
||||
int len = ary.Subs_len();
|
||||
private static KeyVal[] Srl_aliases_langs(int base_adj, String lang, byte[][] ary) {
|
||||
int len = ary.length;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm sub = ary.Subs_get_at(i);
|
||||
rv[i] = KeyVal_.int_(i + base_adj, KeyVal_.Ary(KeyVal_.new_("language", lang), KeyVal_.new_("value", sub.Data()))); // NOTE: using same base_adj logic as claims
|
||||
byte[] itm = ary[i];
|
||||
rv[i] = KeyVal_.int_(i + base_adj, KeyVal_.Ary(KeyVal_.new_(Wdata_dict_langtext.Str_language, lang), KeyVal_.new_(Wdata_dict_langtext.Str_value, String_.new_utf8_(itm)))); // NOTE: using same base_adj logic as claims
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims(Wdata_doc_parser parser, byte[] src, Json_itm_ary claims_nde, boolean legacy_style, int base_adj) {
|
||||
OrderedHash props = parser.Bld_props(src, claims_nde);
|
||||
int len = props.Count();
|
||||
private static KeyVal[] Srl_claims(int base_adj, boolean legacy_style, OrderedHash claim_grps) {
|
||||
int len = claim_grps.Count(); if (len == 0) return null;
|
||||
int rv_len = legacy_style ? len * 2 : len; // NOTE: legacyStyle returns 2 sets of properties: official "P" and legacy "p"; DATE:2014-05-11
|
||||
KeyVal[] rv = new KeyVal[rv_len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Wdata_prop_grp grp = (Wdata_prop_grp)props.FetchAt(i);
|
||||
Wdata_claim_grp grp = (Wdata_claim_grp)claim_grps.FetchAt(i);
|
||||
String pid_str = Int_.Xto_str(grp.Id());
|
||||
KeyVal[] grp_val = Srl_claims_prop_grp("P" + pid_str, grp, base_adj);
|
||||
rv[i] = KeyVal_.new_("P" + pid_str, grp_val);
|
||||
@ -103,123 +92,126 @@ class Scrib_lib_wikibase_srl {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_grp(String pid, Wdata_prop_grp grp, int base_adj) {
|
||||
private static KeyVal[] Srl_claims_prop_grp(String pid, Wdata_claim_grp grp, int base_adj) {
|
||||
int len = grp.Itms_len();
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Wdata_prop_itm_core itm = grp.Itms_get_at(i);
|
||||
Wdata_claim_itm_core itm = grp.Itms_get_at(i);
|
||||
rv[i] = KeyVal_.int_(i + base_adj, Srl_claims_prop_itm(pid, itm)); // NOTE: must be super 0 or super 1; DATE:2014-05-09
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm(String pid, Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm(String pid, Wdata_claim_itm_core itm) {
|
||||
ListAdp list = ListAdp_.new_();
|
||||
list.Add(KeyVal_.new_("id", String_.new_utf8_(itm.Wguid())));
|
||||
list.Add(KeyVal_.new_("mainsnak", Srl_claims_prop_itm_core(pid, itm)));
|
||||
list.Add(KeyVal_.new_(Wdata_doc_consts.Key_claims_rank_str, itm.Rank_str()));
|
||||
list.Add(KeyVal_.new_(Wdata_dict_claim_v1.Str_rank, Wdata_dict_rank.Xto_str(itm.Rank_tid())));
|
||||
list.Add(KeyVal_.new_("type", itm.Prop_type()));
|
||||
return (KeyVal[])list.XtoAryAndClear(KeyVal.class);
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core(String pid, Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core(String pid, Wdata_claim_itm_core itm) {
|
||||
KeyVal[] rv = new KeyVal[3];
|
||||
rv[0] = KeyVal_.new_("datavalue", Srl_claims_prop_itm_core_val(itm));
|
||||
rv[1] = KeyVal_.new_("property", pid);
|
||||
rv[2] = KeyVal_.new_("snaktype", itm.Snak_str());
|
||||
rv[2] = KeyVal_.new_("snaktype", Wdata_dict_snak_tid.Xto_str(itm.Snak_tid()));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_val(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_val(Wdata_claim_itm_core itm) {
|
||||
switch (itm.Snak_tid()) {
|
||||
case Wdata_prop_itm_base_.Snak_tid_somevalue:
|
||||
case Wdata_prop_itm_base_.Snak_tid_novalue: // NOTE: not sure about this logic, but can't find somevalue snaktid formattercode in wikibase; DATE:2014-04-07
|
||||
case Wdata_dict_snak_tid.Tid_somevalue:
|
||||
case Wdata_dict_snak_tid.Tid_novalue: // NOTE: not sure about this logic, but can't find somevalue snaktid formattercode in wikibase; DATE:2014-04-07
|
||||
return DataValue_nil;
|
||||
default:
|
||||
switch (itm.Val_tid_byte()) {
|
||||
case Wdata_prop_itm_base_.Val_tid_string : return Srl_claims_prop_itm_core_str(itm);
|
||||
case Wdata_prop_itm_base_.Val_tid_entity : return Srl_claims_prop_itm_core_entity(itm);
|
||||
case Wdata_prop_itm_base_.Val_tid_time : return Srl_claims_prop_itm_core_time(itm);
|
||||
case Wdata_prop_itm_base_.Val_tid_globecoordinate : return Srl_claims_prop_itm_core_globecoordinate(itm);
|
||||
case Wdata_prop_itm_base_.Val_tid_quantity : return Srl_claims_prop_itm_core_quantity(itm);
|
||||
case Wdata_prop_itm_base_.Val_tid_monolingualtext : return Srl_claims_prop_itm_core_monolingualtext(itm);
|
||||
switch (itm.Val_tid()) {
|
||||
case Wdata_dict_val_tid.Tid_string : return Srl_claims_prop_itm_core_str(itm);
|
||||
case Wdata_dict_val_tid.Tid_entity : return Srl_claims_prop_itm_core_entity(itm);
|
||||
case Wdata_dict_val_tid.Tid_time : return Srl_claims_prop_itm_core_time(itm);
|
||||
case Wdata_dict_val_tid.Tid_globecoordinate : return Srl_claims_prop_itm_core_globecoordinate(itm);
|
||||
case Wdata_dict_val_tid.Tid_quantity : return Srl_claims_prop_itm_core_quantity(itm);
|
||||
case Wdata_dict_val_tid.Tid_monolingualtext : return Srl_claims_prop_itm_core_monolingualtext(itm);
|
||||
default: return KeyVal_.Ary_empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_str(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_str(Wdata_claim_itm_core itm) {
|
||||
Wdata_claim_itm_str claim_str = (Wdata_claim_itm_str)itm;
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Key_type, itm.Val_tid_str());
|
||||
rv[1] = KeyVal_.new_(Key_value, String_.new_utf8_(itm.Val()));
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_dict_val_tid.Xto_str(itm.Val_tid()));
|
||||
rv[1] = KeyVal_.new_(Key_value, String_.new_utf8_(claim_str.Val_str()));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_entity(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_entity(Wdata_claim_itm_core itm) {
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_prop_itm_base_.Val_str_entity);
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_dict_val_tid.Str_entity);
|
||||
rv[1] = KeyVal_.new_(Key_value, Srl_claims_prop_itm_core_entity_value(itm));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_entity_value(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_entity_value(Wdata_claim_itm_core itm) {
|
||||
Wdata_claim_itm_entity claim_entity = (Wdata_claim_itm_entity)itm;
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Wdata_doc_consts.Key_ent_entity_type_str, Wdata_doc_consts.Val_ent_entity_type_item_str);
|
||||
rv[1] = KeyVal_.new_(Wdata_doc_consts.Key_ent_numeric_id_str, String_.new_utf8_(itm.Val()));
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_entity.Str_entity_type, Wdata_dict_value_entity.Val_entity_type_item_str);
|
||||
rv[1] = KeyVal_.new_(Wdata_dict_value_entity.Str_numeric_id, Int_.Xto_str(claim_entity.Entity_id()));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_time(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_time(Wdata_claim_itm_core itm) {
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_doc_consts.Key_time_time_str);
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_dict_val_tid.Str_time);
|
||||
rv[1] = KeyVal_.new_(Key_value, Srl_claims_prop_itm_core_time_value(itm));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_time_value(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_time_value(Wdata_claim_itm_core itm) {
|
||||
Wdata_claim_itm_time claim_time = (Wdata_claim_itm_time)itm;
|
||||
KeyVal[] rv = new KeyVal[6];
|
||||
rv[0] = KeyVal_.new_(Wdata_doc_consts.Key_time_time_str , String_.new_ascii_(itm.Val()));
|
||||
rv[1] = KeyVal_.new_(Wdata_doc_consts.Key_time_precision_str , Wdata_doc_consts.Val_time_precision_int); // NOTE: must return int, not str; DATE:2014-02-18
|
||||
rv[2] = KeyVal_.new_(Wdata_doc_consts.Key_time_before_str , Wdata_doc_consts.Val_time_before_int);
|
||||
rv[3] = KeyVal_.new_(Wdata_doc_consts.Key_time_after_str , Wdata_doc_consts.Val_time_after_int);
|
||||
rv[4] = KeyVal_.new_(Wdata_doc_consts.Key_time_timezone_str , Wdata_doc_consts.Val_time_timezone_str);
|
||||
rv[5] = KeyVal_.new_(Wdata_doc_consts.Key_time_calendarmodel_str , Wdata_doc_consts.Val_time_calendarmodel_str);
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_time.Str_time , String_.new_ascii_(claim_time.Time()));
|
||||
rv[1] = KeyVal_.new_(Wdata_dict_value_time.Str_precision , Wdata_dict_value_time.Val_precision_int); // NOTE: must return int, not str; DATE:2014-02-18
|
||||
rv[2] = KeyVal_.new_(Wdata_dict_value_time.Str_before , Wdata_dict_value_time.Val_before_int);
|
||||
rv[3] = KeyVal_.new_(Wdata_dict_value_time.Str_after , Wdata_dict_value_time.Val_after_int);
|
||||
rv[4] = KeyVal_.new_(Wdata_dict_value_time.Str_timezone , Wdata_dict_value_time.Val_timezone_str);
|
||||
rv[5] = KeyVal_.new_(Wdata_dict_value_time.Str_calendarmodel , Wdata_dict_value_time.Val_calendarmodel_str);
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_globecoordinate(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_globecoordinate(Wdata_claim_itm_core itm) {
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_doc_consts.Key_geo_type_str);
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_dict_val_tid.Str_globecoordinate);
|
||||
rv[1] = KeyVal_.new_(Key_value, Srl_claims_prop_itm_core_globecoordinate_value(itm));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_globecoordinate_value(Wdata_prop_itm_core itm) {
|
||||
byte[][] flds = Bry_.Split(itm.Val(), Byte_ascii.Pipe);
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_globecoordinate_value(Wdata_claim_itm_core itm) {
|
||||
Wdata_claim_itm_globecoordinate claim_globecoordinate = (Wdata_claim_itm_globecoordinate)itm;
|
||||
KeyVal[] rv = new KeyVal[5];
|
||||
rv[0] = KeyVal_.new_(Wdata_doc_consts.Key_geo_latitude_str , Double_.parse_(String_.new_ascii_(flds[0])));
|
||||
rv[1] = KeyVal_.new_(Wdata_doc_consts.Key_geo_longitude_str , Double_.parse_(String_.new_ascii_(flds[1])));
|
||||
rv[2] = KeyVal_.new_(Wdata_doc_consts.Key_geo_altitude_str , null);
|
||||
rv[3] = KeyVal_.new_(Wdata_doc_consts.Key_geo_globe_str , Wdata_doc_consts.Val_time_globe_bry);
|
||||
rv[4] = KeyVal_.new_(Wdata_doc_consts.Key_geo_precision_str , .00001d);
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_globecoordinate.Str_latitude , Double_.parse_(String_.new_ascii_(claim_globecoordinate.Lat())));
|
||||
rv[1] = KeyVal_.new_(Wdata_dict_value_globecoordinate.Str_longitude , Double_.parse_(String_.new_ascii_(claim_globecoordinate.Lng())));
|
||||
rv[2] = KeyVal_.new_(Wdata_dict_value_globecoordinate.Str_altitude , null);
|
||||
rv[3] = KeyVal_.new_(Wdata_dict_value_globecoordinate.Str_globe , Wdata_dict_value_globecoordinate.Val_globe_dflt_str);
|
||||
rv[4] = KeyVal_.new_(Wdata_dict_value_globecoordinate.Str_precision , .00001d);
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_quantity(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_quantity(Wdata_claim_itm_core itm) {
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_doc_consts.Key_quantity_type_str);
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_dict_val_tid.Str_quantity);
|
||||
rv[1] = KeyVal_.new_(Key_value, Srl_claims_prop_itm_core_quantity_value(itm));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_quantity_value(Wdata_prop_itm_core itm) {
|
||||
byte[][] flds = Bry_.Split(itm.Val(), Byte_ascii.Pipe);
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_quantity_value(Wdata_claim_itm_core itm) {
|
||||
Wdata_claim_itm_quantity claim_quantity = (Wdata_claim_itm_quantity)itm;
|
||||
KeyVal[] rv = new KeyVal[4];
|
||||
rv[0] = KeyVal_.new_(Wdata_doc_consts.Key_quantity_amount_str , String_.new_utf8_(flds[0]));
|
||||
rv[1] = KeyVal_.new_(Wdata_doc_consts.Key_quantity_unit_str , String_.new_utf8_(flds[1]));
|
||||
rv[2] = KeyVal_.new_(Wdata_doc_consts.Key_quantity_ubound_str , String_.new_utf8_(flds[2]));
|
||||
rv[3] = KeyVal_.new_(Wdata_doc_consts.Key_quantity_lbound_str , String_.new_utf8_(flds[3]));
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_quantity.Str_amount , String_.new_utf8_(claim_quantity.Amount()));
|
||||
rv[1] = KeyVal_.new_(Wdata_dict_value_quantity.Str_unit , String_.new_utf8_(claim_quantity.Unit()));
|
||||
rv[2] = KeyVal_.new_(Wdata_dict_value_quantity.Str_upperbound , String_.new_utf8_(claim_quantity.Ubound()));
|
||||
rv[3] = KeyVal_.new_(Wdata_dict_value_quantity.Str_lowerbound , String_.new_utf8_(claim_quantity.Lbound()));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_monolingualtext(Wdata_prop_itm_core itm) {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_monolingualtext(Wdata_claim_itm_core itm) {
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_doc_consts.Key_quantity_type_str);
|
||||
rv[0] = KeyVal_.new_(Key_type, Wdata_dict_value_monolingualtext.Str_language);
|
||||
rv[1] = KeyVal_.new_(Key_value, Srl_claims_prop_itm_core_monolingualtext_value(itm));
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_monolingualtext_value(Wdata_prop_itm_core itm) {
|
||||
byte[][] flds = Bry_.Split(itm.Val(), Byte_ascii.Pipe);
|
||||
private static KeyVal[] Srl_claims_prop_itm_core_monolingualtext_value(Wdata_claim_itm_core itm) {
|
||||
Wdata_claim_itm_monolingualtext claim_monolingualtext = (Wdata_claim_itm_monolingualtext)itm;
|
||||
KeyVal[] rv = new KeyVal[2];
|
||||
rv[0] = KeyVal_.new_(Wdata_doc_consts.Key_monolingualtext_text_str , String_.new_utf8_(flds[0]));
|
||||
rv[1] = KeyVal_.new_(Wdata_doc_consts.Key_monolingualtext_language_str , String_.new_utf8_(flds[1]));
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_monolingualtext.Str_text , String_.new_utf8_(claim_monolingualtext.Text()));
|
||||
rv[1] = KeyVal_.new_(Wdata_dict_value_monolingualtext.Str_language , String_.new_utf8_(claim_monolingualtext.Lang()));
|
||||
return rv;
|
||||
}
|
||||
private static final String Key_type = "type", Key_value = "value";
|
||||
|
@ -17,8 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto.lib; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.json.*;
|
||||
import gplx.json.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.parsers.*;
|
||||
public class Scrib_lib_wikibase_srl_tst {
|
||||
@Before public void init() {fxt.Clear();} private Scrib_lib_wikibase_srl_fxt fxt = new Scrib_lib_wikibase_srl_fxt();
|
||||
@Test public void Label() {
|
||||
@ -285,12 +284,10 @@ class Scrib_lib_wikibase_srl_fxt {
|
||||
wdata_fxt.Init();
|
||||
doc_bldr = wdata_fxt.page_bldr_("q2");
|
||||
header_enabled = false;
|
||||
parser = new Wdata_doc_parser(wdata_fxt.App().Usr_dlg());
|
||||
}
|
||||
public Wdata_wiki_mgr_fxt Wdata_fxt() {return wdata_fxt;} private Wdata_wiki_mgr_fxt wdata_fxt;
|
||||
private Wdata_doc_bldr doc_bldr;
|
||||
private boolean header_enabled;
|
||||
private Wdata_doc_parser parser;
|
||||
public Scrib_lib_wikibase_srl_fxt Init_header_enabled_y_() {header_enabled = true; return this;}
|
||||
public Scrib_lib_wikibase_srl_fxt Init_label(String lang, String label) {
|
||||
doc_bldr.Label_add(lang, label);
|
||||
@ -308,16 +305,16 @@ class Scrib_lib_wikibase_srl_fxt {
|
||||
doc_bldr.Alias_add(lang, ary);
|
||||
return this;
|
||||
}
|
||||
public Scrib_lib_wikibase_srl_fxt Init_prop(Wdata_prop_itm_core prop) {doc_bldr.Props_add(prop); return this;}
|
||||
public Scrib_lib_wikibase_srl_fxt Init_prop(Wdata_claim_itm_core prop) {doc_bldr.Props_add(prop); return this;}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(String... expd) {return Test(false, expd);}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(boolean base0, String... expd) {
|
||||
KeyVal[] actl = Scrib_lib_wikibase_srl.Srl(parser, doc_bldr.Xto_page_doc(), header_enabled, base0);
|
||||
KeyVal[] actl = Scrib_lib_wikibase_srl.Srl(doc_bldr.Xto_page_doc(), header_enabled, base0);
|
||||
Tfds.Eq_ary_str(expd, String_.SplitLines_nl(Xto_str(actl)));
|
||||
return this;
|
||||
}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(Wdata_doc wdoc, String... expd) {return Test(false, wdoc, expd);}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(boolean base0, Wdata_doc wdoc, String... expd) {
|
||||
KeyVal[] actl = Scrib_lib_wikibase_srl.Srl(parser, wdoc, header_enabled, base0);
|
||||
KeyVal[] actl = Scrib_lib_wikibase_srl.Srl(wdoc, header_enabled, base0);
|
||||
Tfds.Eq_ary_str(expd, String_.SplitLines_nl(Xto_str(actl)));
|
||||
return this;
|
||||
}
|
||||
|
@ -16,20 +16,20 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wdatas; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.json.*;
|
||||
import gplx.json.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.parsers.*;
|
||||
public class Wdata_doc {
|
||||
public Wdata_doc(byte[] qid, Wdata_wiki_mgr mgr, Json_doc doc) {this.qid = qid; this.mgr = mgr; this.doc = doc;} Wdata_wiki_mgr mgr;
|
||||
public Json_doc Doc() {return doc;} Json_doc doc;
|
||||
public Wdata_doc(byte[] qid, Wdata_wiki_mgr mgr, Json_doc jdoc) {this.qid = qid; this.mgr = mgr; this.jdoc = jdoc;} private Wdata_wiki_mgr mgr;
|
||||
public Json_doc Jdoc() {return jdoc;} private Json_doc jdoc;
|
||||
public byte[] Qid() {return qid;} private byte[] qid;
|
||||
public OrderedHash Link_list() {if (link_list == null) link_list = mgr.Page_doc_parser().Bld_hash(doc, Wdata_doc_consts.Key_atr_links_bry); return link_list;} private OrderedHash link_list;
|
||||
public OrderedHash Label_list() {if (label_list == null) label_list = mgr.Page_doc_parser().Bld_hash(doc, Wdata_doc_consts.Key_atr_label_bry); return label_list;} private OrderedHash label_list;
|
||||
public OrderedHash Alias_list() {if (alias_list == null) alias_list = mgr.Page_doc_parser().Bld_hash(doc, Wdata_doc_consts.Key_atr_aliases_bry); return alias_list;} private OrderedHash alias_list;
|
||||
public OrderedHash Description_list() {if (description_list == null) description_list = mgr.Page_doc_parser().Bld_hash(doc, Wdata_doc_consts.Key_atr_description_bry); return description_list;} private OrderedHash description_list;
|
||||
public OrderedHash Claim_list() {if (claim_list == null) claim_list = mgr.Page_doc_parser().Bld_props(doc); return claim_list;} private OrderedHash claim_list;
|
||||
public OrderedHash Sitelink_list() {if (sitelink_list == null) sitelink_list = mgr.Wdoc_parser(jdoc).Parse_sitelinks(qid, jdoc); return sitelink_list;} private OrderedHash sitelink_list;
|
||||
public OrderedHash Label_list() {if (label_list == null) label_list = mgr.Wdoc_parser(jdoc).Parse_langvals(qid, jdoc, Bool_.Y); return label_list;} private OrderedHash label_list;
|
||||
public OrderedHash Description_list() {if (description_list == null) description_list = mgr.Wdoc_parser(jdoc).Parse_langvals(qid, jdoc, Bool_.N); return description_list;} private OrderedHash description_list;
|
||||
public OrderedHash Alias_list() {if (alias_list == null) alias_list = mgr.Wdoc_parser(jdoc).Parse_aliases(qid, jdoc); return alias_list;} private OrderedHash alias_list;
|
||||
public OrderedHash Claim_list() {if (claim_list == null) claim_list = mgr.Wdoc_parser(jdoc).Parse_claims(jdoc); return claim_list;} private OrderedHash claim_list;
|
||||
public Wdata_claim_grp Claim_list_get(int pid) {return (Wdata_claim_grp)this.Claim_list().Fetch(mgr.Tmp_prop_ref().Val_(pid));}
|
||||
public byte[] Label_list_get(byte[] lang_key) {
|
||||
Object rv = this.Label_list().Fetch(lang_key); if (rv == null) return null;
|
||||
Json_itm_kv kv = (Json_itm_kv)rv;
|
||||
return kv.Val().Data_bry();
|
||||
Object rv_obj = this.Label_list().Fetch(lang_key); if (rv_obj == null) return null;
|
||||
Wdata_langtext_itm rv = (Wdata_langtext_itm)rv_obj;
|
||||
return rv.Text();
|
||||
}
|
||||
public Wdata_prop_grp Claim_list_get(int pid) {return (Wdata_prop_grp)this.Claim_list().Fetch(mgr.Tmp_prop_ref().Val_(pid));}
|
||||
}
|
||||
|
@ -16,16 +16,17 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wdatas; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.json.*;
|
||||
import gplx.json.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.parsers.*;
|
||||
public class Wdata_doc_bldr {
|
||||
public Wdata_doc_bldr(Wdata_wiki_mgr mgr) {this.mgr = mgr;} Wdata_wiki_mgr mgr;
|
||||
public Wdata_doc_bldr Qid_(String v) {this.qid = Bry_.new_ascii_(v); return this;} private byte[] qid; ListAdp props = ListAdp_.new_();
|
||||
public Wdata_doc_bldr Props_add(Wdata_prop_itm_core... ary) {
|
||||
public Wdata_doc_bldr Props_add(Wdata_claim_itm_core... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
props.Add(ary[i]);
|
||||
return this;
|
||||
}
|
||||
public static byte[] Xto_time(String date) {return Xto_time(DateAdp_.parse_fmt(date, "yyyy-MM-dd HH:mm:ss"));}
|
||||
public static byte[] Xto_time(DateAdp date) {
|
||||
// +0000000yyyy-MM-ddTHH:mm:ssZ
|
||||
tmp_bfr
|
||||
@ -54,10 +55,10 @@ public class Wdata_doc_bldr {
|
||||
} OrderedHash aliases = OrderedHash_.new_();
|
||||
public byte[] Xto_bry() {
|
||||
wtr.Nde_bgn();
|
||||
wtr.Kv(Bool_.N, Wdata_doc_consts.Key_atr_entity_bry, qid);
|
||||
Xto_bry__list(Wdata_doc_consts.Key_atr_label_bry, labels);
|
||||
Xto_bry__list(Wdata_doc_consts.Key_atr_description_bry, descriptions);
|
||||
Xto_bry__sitelinks(Wdata_doc_consts.Key_atr_links_bry, links);
|
||||
wtr.Kv(Bool_.N, Wdata_doc_parser_v1.Bry_entity, qid);
|
||||
Xto_bry__list(Wdata_doc_parser_v1.Bry_label, labels);
|
||||
Xto_bry__list(Wdata_doc_parser_v1.Bry_description, descriptions);
|
||||
Xto_bry__sitelinks(Wdata_doc_parser_v1.Bry_links, links);
|
||||
Xto_bry__aliases();
|
||||
Xto_bry__claims();
|
||||
wtr.Nde_end();
|
||||
@ -85,7 +86,7 @@ public class Wdata_doc_bldr {
|
||||
KeyVal kv = (KeyVal)list.FetchAt(i);
|
||||
wtr.Key(false, Bry_.new_utf8_(kv.Key())); // write key; EX: enwiki:
|
||||
wtr.Nde_bgn(); // bgn nde; EX: {
|
||||
wtr.Kv(false, Wdata_doc_.Key_name, Bry_.new_utf8_(kv.Val_to_str_or_empty())); // write name; EX: name=Earth
|
||||
wtr.Kv(false, Wdata_doc_parser_v1.Bry_name, Bry_.new_utf8_(kv.Val_to_str_or_empty())); // write name; EX: name=Earth
|
||||
wtr.Nde_end(); // end nde; EX: }
|
||||
}
|
||||
wtr.Nde_end();
|
||||
@ -94,7 +95,7 @@ public class Wdata_doc_bldr {
|
||||
private void Xto_bry__aliases() {
|
||||
int len = aliases.Count();
|
||||
if (len == 0) return;
|
||||
wtr.Key(true, Wdata_doc_consts.Key_atr_aliases_bry);
|
||||
wtr.Key(true, Wdata_doc_parser_v1.Bry_aliases);
|
||||
wtr.Nde_bgn();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Wdata_doc_alias alias = (Wdata_doc_alias)aliases.FetchAt(i);
|
||||
@ -114,91 +115,94 @@ public class Wdata_doc_bldr {
|
||||
private void Xto_bry__claims() {
|
||||
int len = props.Count();
|
||||
if (len == 0) return;
|
||||
wtr.Key(true, Wdata_doc_consts.Key_atr_claims_bry);
|
||||
wtr.Key(true, Wdata_doc_parser_v1.Bry_claims);
|
||||
wtr.Ary_bgn();
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i != 0) wtr.Comma();
|
||||
Wdata_prop_itm_core prop = (Wdata_prop_itm_core)props.FetchAt(i);
|
||||
Wdata_claim_itm_core prop = (Wdata_claim_itm_core)props.FetchAt(i);
|
||||
wtr.Nde_bgn();
|
||||
wtr.Key(false, Wdata_doc_consts.Key_claims_m_bry);
|
||||
wtr.Key(false, Wdata_dict_claim_v1.Bry_m);
|
||||
wtr.Ary_bgn();
|
||||
wtr.Val(Bool_.N, prop.Snak_bry());
|
||||
wtr.Val(Bool_.N, Wdata_dict_snak_tid.Xto_bry(prop.Snak_tid()));
|
||||
wtr.Val(Bool_.Y, prop.Pid());
|
||||
if (prop.Snak_tid() == Wdata_prop_itm_base_.Snak_tid_value) {
|
||||
switch (prop.Val_tid_byte()) {
|
||||
case Wdata_prop_itm_base_.Val_tid_string:
|
||||
wtr.Val(Bool_.Y, Wdata_prop_itm_base_.Val_bry_string);
|
||||
wtr.Val(Bool_.Y, prop.Val());
|
||||
if (prop.Snak_tid() == Wdata_dict_snak_tid.Tid_value) {
|
||||
switch (prop.Val_tid()) {
|
||||
case Wdata_dict_val_tid.Tid_string:
|
||||
Wdata_claim_itm_str claim_str = (Wdata_claim_itm_str)prop;
|
||||
wtr.Val(Bool_.Y, Wdata_dict_val_tid.Bry_string);
|
||||
wtr.Val(Bool_.Y, claim_str.Val_str());
|
||||
break;
|
||||
case Wdata_prop_itm_base_.Val_tid_entity:
|
||||
wtr.Val(Bool_.Y, Wdata_prop_itm_base_.Val_bry_entity);
|
||||
case Wdata_dict_val_tid.Tid_entity:
|
||||
Wdata_claim_itm_entity claim_entity = (Wdata_claim_itm_entity)prop;
|
||||
wtr.Val(Bool_.Y, Wdata_dict_val_tid.Bry_entity);
|
||||
wtr.Comma();
|
||||
wtr.Nde_bgn();
|
||||
wtr.Kv(Bool_.N, Wdata_doc_consts.Key_ent_entity_type_bry, Wdata_doc_consts.Val_ent_entity_type_item_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_ent_numeric_id_bry, Bry_.Xto_int(prop.Val()));
|
||||
wtr.Kv(Bool_.N, Wdata_dict_value_entity.Bry_entity_type , Wdata_dict_value_entity.Val_entity_type_item_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_value_entity.Bry_numeric_id , claim_entity.Entity_id());
|
||||
wtr.Nde_end();
|
||||
break;
|
||||
case Wdata_prop_itm_base_.Val_tid_time:
|
||||
wtr.Val(Bool_.Y, Wdata_prop_itm_base_.Val_bry_time);
|
||||
case Wdata_dict_val_tid.Tid_time:
|
||||
Wdata_claim_itm_time claim_time = (Wdata_claim_itm_time)prop;
|
||||
wtr.Val(Bool_.Y, Wdata_dict_val_tid.Bry_time);
|
||||
wtr.Comma();
|
||||
wtr.Nde_bgn();
|
||||
wtr.Kv(Bool_.N, Wdata_doc_consts.Key_time_time_bry , prop.Val());
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_time_precision_bry , Wdata_doc_consts.Val_time_precision_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_time_before_bry , Wdata_doc_consts.Val_time_before_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_time_after_bry , Wdata_doc_consts.Val_time_after_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_time_timezone_bry , Wdata_doc_consts.Val_time_timezone_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_time_calendarmodel_bry , Wdata_doc_consts.Val_time_calendarmodel_bry);
|
||||
wtr.Kv(Bool_.N, Wdata_dict_value_time.Bry_time , claim_time.Time());
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_value_time.Bry_precision , Wdata_dict_value_time.Val_timezone_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_value_time.Bry_before , Wdata_dict_value_time.Val_before_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_value_time.Bry_after , Wdata_dict_value_time.Val_after_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_value_time.Bry_timezone , Wdata_dict_value_time.Val_timezone_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_value_time.Bry_calendarmodel , Wdata_dict_value_time.Val_calendarmodel_bry);
|
||||
wtr.Nde_end();
|
||||
break;
|
||||
case Wdata_prop_itm_base_.Val_tid_globecoordinate: {
|
||||
wtr.Val(Bool_.Y, Wdata_prop_itm_base_.Val_bry_globecoordinate);
|
||||
case Wdata_dict_val_tid.Tid_globecoordinate: {
|
||||
Wdata_claim_itm_globecoordinate claim_globecoordinate = (Wdata_claim_itm_globecoordinate)prop;
|
||||
wtr.Val(Bool_.Y, Wdata_dict_val_tid.Bry_globecoordinate);
|
||||
wtr.Comma();
|
||||
wtr.Nde_bgn();
|
||||
byte[][] flds = Bry_.Split(prop.Val(), Byte_ascii.Pipe);
|
||||
wtr.Kv_double (Bool_.N, Wdata_doc_consts.Key_geo_latitude_bry , Double_.parse_(String_.new_ascii_(flds[0])));
|
||||
wtr.Kv_double (Bool_.Y, Wdata_doc_consts.Key_geo_longitude_bry , Double_.parse_(String_.new_ascii_(flds[1])));
|
||||
wtr.Kv (Bool_.Y, Wdata_doc_consts.Key_geo_altitude_bry , null);
|
||||
wtr.Kv (Bool_.Y, Wdata_doc_consts.Key_geo_globe_bry , Wdata_doc_consts.Val_time_globe_bry);
|
||||
wtr.Kv_double (Bool_.Y, Wdata_doc_consts.Key_geo_precision_bry , .00001d);
|
||||
wtr.Kv_double (Bool_.N, Wdata_dict_value_globecoordinate.Bry_latitude , Double_.parse_(String_.new_ascii_(claim_globecoordinate.Lat())));
|
||||
wtr.Kv_double (Bool_.Y, Wdata_dict_value_globecoordinate.Bry_longitude , Double_.parse_(String_.new_ascii_(claim_globecoordinate.Lng())));
|
||||
wtr.Kv (Bool_.Y, Wdata_dict_value_globecoordinate.Bry_altitude , null);
|
||||
wtr.Kv (Bool_.Y, Wdata_dict_value_globecoordinate.Bry_globe , Wdata_dict_value_globecoordinate.Val_globe_dflt_bry);
|
||||
wtr.Kv_double (Bool_.Y, Wdata_dict_value_globecoordinate.Bry_precision , .00001d);
|
||||
wtr.Nde_end();
|
||||
break;
|
||||
}
|
||||
case Wdata_prop_itm_base_.Val_tid_quantity: {
|
||||
wtr.Val(Bool_.Y, Wdata_prop_itm_base_.Val_bry_quantity);
|
||||
case Wdata_dict_val_tid.Tid_quantity: {
|
||||
Wdata_claim_itm_quantity claim_quantity = (Wdata_claim_itm_quantity)prop;
|
||||
wtr.Val(Bool_.Y, Wdata_dict_val_tid.Bry_quantity);
|
||||
wtr.Comma();
|
||||
wtr.Nde_bgn();
|
||||
byte[][] flds = Bry_.Split(prop.Val(), Byte_ascii.Pipe);
|
||||
wtr.Kv (Bool_.N, Wdata_doc_consts.Key_quantity_amount_bry , flds[0]); // +1,234
|
||||
wtr.Kv (Bool_.Y, Wdata_doc_consts.Key_quantity_unit_bry , flds[1]); // 1
|
||||
wtr.Kv (Bool_.Y, Wdata_doc_consts.Key_quantity_ubound_bry , flds[2]); // +1,235
|
||||
wtr.Kv (Bool_.Y, Wdata_doc_consts.Key_quantity_lbound_bry , flds[3]); // +1,233
|
||||
wtr.Kv (Bool_.N, Wdata_dict_value_quantity.Bry_amount , claim_quantity.Amount()); // +1,234
|
||||
wtr.Kv (Bool_.Y, Wdata_dict_value_quantity.Bry_unit , claim_quantity.Unit()); // 1
|
||||
wtr.Kv (Bool_.Y, Wdata_dict_value_quantity.Bry_upperbound , claim_quantity.Ubound()); // +1,235
|
||||
wtr.Kv (Bool_.Y, Wdata_dict_value_quantity.Bry_lowerbound , claim_quantity.Lbound()); // +1,233
|
||||
wtr.Nde_end();
|
||||
break;
|
||||
}
|
||||
case Wdata_prop_itm_base_.Val_tid_monolingualtext: {
|
||||
wtr.Val(Bool_.Y, Wdata_prop_itm_base_.Val_bry_monolingualtext);
|
||||
case Wdata_dict_val_tid.Tid_monolingualtext: {
|
||||
Wdata_claim_itm_monolingualtext claim_monolingualtext = (Wdata_claim_itm_monolingualtext)prop;
|
||||
wtr.Val(Bool_.Y, Wdata_dict_val_tid.Bry_monolingualtext);
|
||||
wtr.Comma();
|
||||
wtr.Nde_bgn();
|
||||
byte[][] flds = Bry_.Split(prop.Val(), Byte_ascii.Pipe);
|
||||
wtr.Kv (Bool_.N, Wdata_doc_consts.Key_monolingualtext_text_bry , flds[0]); // text
|
||||
wtr.Kv (Bool_.Y, Wdata_doc_consts.Key_monolingualtext_language_bry , flds[1]); // en
|
||||
wtr.Kv (Bool_.N, Wdata_dict_value_monolingualtext.Bry_text , claim_monolingualtext.Text()); // text
|
||||
wtr.Kv (Bool_.Y, Wdata_dict_value_monolingualtext.Bry_language , claim_monolingualtext.Lang()); // en
|
||||
wtr.Nde_end();
|
||||
break;
|
||||
}
|
||||
default: throw Err_.unhandled(prop.Val_tid_byte());
|
||||
default: throw Err_.unhandled(prop.Val_tid());
|
||||
}
|
||||
}
|
||||
wtr.Ary_end();
|
||||
wtr.Kv_ary_empty(Bool_.Y, Wdata_doc_consts.Key_claims_q_bry);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_claims_g_bry, qid);
|
||||
wtr.Kv(Bool_.Y, Wdata_doc_consts.Key_claims_rank_bry, Wdata_prop_itm_base_.Rank_normal);
|
||||
wtr.Kv_ary_empty(Bool_.Y, Wdata_doc_consts.Key_claims_refs_bry);
|
||||
wtr.Kv_ary_empty(Bool_.Y, Wdata_dict_claim_v1.Bry_q);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_claim_v1.Bry_g, qid);
|
||||
wtr.Kv(Bool_.Y, Wdata_dict_claim_v1.Bry_rank, Wdata_dict_rank.Tid_normal);
|
||||
wtr.Kv_ary_empty(Bool_.Y, Wdata_dict_claim_v1.Bry_refs);
|
||||
wtr.Nde_end();
|
||||
}
|
||||
wtr.Ary_end();
|
||||
props.Clear();
|
||||
}
|
||||
public Wdata_doc Xto_page_doc() {return new Wdata_doc(qid, mgr, mgr.Parser().Parse(Xto_bry()));}
|
||||
public Wdata_doc Xto_page_doc() {return new Wdata_doc(qid, mgr, mgr.Jdoc_parser().Parse(Xto_bry()));}
|
||||
}
|
||||
class Wdata_doc_alias {
|
||||
public Wdata_doc_alias(String lang, String[] aliases) {this.lang = lang; this.aliases = aliases;}
|
||||
|
@ -18,18 +18,23 @@ 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.json.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.html.*;
|
||||
import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.parsers.logs.*; import gplx.xowa.xtns.wdatas.parsers.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
public class Wdata_wiki_mgr implements GfoInvkAble {
|
||||
private Wdata_doc_parser wdoc_parser_v1, wdoc_parser_v2;
|
||||
public Wdata_wiki_mgr(Xoa_app app) {
|
||||
this.app = app;
|
||||
page_doc_parser = new Wdata_doc_parser(app.Usr_dlg());
|
||||
wdoc_parser_v1 = new Wdata_doc_parser_v1();
|
||||
wdoc_parser_v2 = new Wdata_doc_parser_v2();
|
||||
doc_cache = app.Cache_mgr().Doc_cache();
|
||||
} private Xoa_app app; gplx.xowa.apps.caches.Wdata_doc_cache doc_cache;
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
|
||||
public byte[] Domain() {return domain;} public void Domain_(byte[] v) {domain = v;} private byte[] domain = Bry_.new_ascii_("www.wikidata.org");
|
||||
public Xow_wiki Wdata_wiki() {if (wdata_wiki == null) wdata_wiki = app.Wiki_mgr().Get_by_key_or_make(domain).Init_assert(); return wdata_wiki;} private Xow_wiki wdata_wiki;
|
||||
public Json_parser Parser() {return parser;} Json_parser parser = new Json_parser();
|
||||
public Wdata_doc_parser Page_doc_parser() {return page_doc_parser;} Wdata_doc_parser page_doc_parser;
|
||||
public Json_parser Jdoc_parser() {return jdoc_parser;} private Json_parser jdoc_parser = new Json_parser();
|
||||
public Wdata_doc_parser Wdoc_parser(Json_doc jdoc) {
|
||||
Json_itm_kv itm_0 = Json_itm_kv.cast_(jdoc.Root().Subs_get_at(0)); // get 1st node
|
||||
return Bry_.Eq(itm_0.Key().Data_bry(), Wdata_doc_parser_v2.Bry_type) ? wdoc_parser_v2 : wdoc_parser_v1; // if "type", must be v2
|
||||
}
|
||||
public Xop_log_property_wkr Property_wkr() {return property_wkr;} private Xop_log_property_wkr property_wkr;
|
||||
public Int_obj_ref Tmp_prop_ref() {return tmp_prop_ref;} Int_obj_ref tmp_prop_ref = Int_obj_ref.zero_();
|
||||
public void Clear() {
|
||||
@ -71,7 +76,7 @@ public class Wdata_wiki_mgr implements GfoInvkAble {
|
||||
public void Pages_add(byte[] qid, Wdata_doc page) {
|
||||
doc_cache.Add(qid, page);
|
||||
}
|
||||
@gplx.Internal protected Wdata_doc Pages_get(Xow_wiki wiki, Xoa_ttl ttl, Wdata_pf_property_data data) {
|
||||
public Wdata_doc Pages_get(Xow_wiki wiki, Xoa_ttl ttl, Wdata_pf_property_data data) {
|
||||
if (data.Q() != null) return Pages_get(data.Q());
|
||||
else if (data.Of() != null) {
|
||||
Xoa_ttl of_ttl = Xoa_ttl.parse_(wiki, data.Of()); if (of_ttl == null) return null;
|
||||
@ -115,20 +120,27 @@ public class Wdata_wiki_mgr implements GfoInvkAble {
|
||||
}
|
||||
return qids[qid_idx];
|
||||
}
|
||||
public void Resolve_to_bfr(Bry_bfr bfr, Wdata_prop_grp prop_grp, byte[] lang_key) {
|
||||
public void Resolve_to_bfr(Bry_bfr bfr, Wdata_claim_grp prop_grp, byte[] lang_key) {
|
||||
int len = prop_grp.Itms_len();
|
||||
for (int i = 0; i < len; i++) { // NOTE: multiple props possible; EX: roles = scientist,painter
|
||||
if (i != 0) bfr.Add(Prop_tmpl_val_dlm);
|
||||
Wdata_prop_itm_core prop = prop_grp.Itms_get_at(i);
|
||||
Wdata_claim_itm_core prop = prop_grp.Itms_get_at(i);
|
||||
switch (prop.Snak_tid()) {
|
||||
case Wdata_prop_itm_base_.Snak_tid_novalue : bfr.Add(Wdata_doc_consts.Val_prop_novalue_bry); break;
|
||||
case Wdata_prop_itm_base_.Snak_tid_somevalue: bfr.Add(Wdata_doc_consts.Val_prop_somevalue_bry); break;
|
||||
case Wdata_dict_snak_tid.Tid_novalue : bfr.Add(Wdata_dict_snak_tid.Bry_novalue); break;
|
||||
case Wdata_dict_snak_tid.Tid_somevalue : bfr.Add(Wdata_dict_snak_tid.Bry_somevalue); break;
|
||||
default: {
|
||||
switch (prop.Val_tid_byte()) {
|
||||
case Wdata_prop_itm_base_.Val_tid_string :
|
||||
case Wdata_prop_itm_base_.Val_tid_time : bfr.Add(prop.Val()); break;
|
||||
case Wdata_prop_itm_base_.Val_tid_entity:
|
||||
Wdata_doc entity_doc = Pages_get(Bry_.Add(Bry_q, prop.Val()));
|
||||
switch (prop.Val_tid()) {
|
||||
case Wdata_dict_val_tid.Tid_string:
|
||||
Wdata_claim_itm_str claim_str = (Wdata_claim_itm_str)prop;
|
||||
bfr.Add(claim_str.Val_str());
|
||||
break;
|
||||
case Wdata_dict_val_tid.Tid_time:
|
||||
Wdata_claim_itm_time claim_time = (Wdata_claim_itm_time)prop;
|
||||
bfr.Add(claim_time.Time());
|
||||
break;
|
||||
case Wdata_dict_val_tid.Tid_entity:
|
||||
Wdata_claim_itm_entity claim_entity = (Wdata_claim_itm_entity)prop;
|
||||
Wdata_doc entity_doc = Pages_get(Bry_.Add(Bry_q, claim_entity.Entity_id_bry()));
|
||||
if (entity_doc == null) return; // NOTE: wiki may refer to entity that no longer exists; EX: {{#property:p1}} which links to Q1, but p1 links to Q2 and Q2 was deleted; DATE:2014-02-01
|
||||
byte[] label = entity_doc.Label_list_get(lang_key);
|
||||
if (label == null && !Bry_.Eq(lang_key, Xol_lang_.Key_en)) // NOTE: some properties may not exist in language of wiki; default to english; DATE:2013-12-19
|
||||
@ -136,29 +148,29 @@ public class Wdata_wiki_mgr implements GfoInvkAble {
|
||||
if (label != null) // if label is still not found, don't add null reference
|
||||
bfr.Add(label);
|
||||
break;
|
||||
case Wdata_prop_itm_base_.Val_tid_globecoordinate: {
|
||||
byte[][] flds = Bry_.Split(prop.Val(), Wdata_prop_itm_core.Prop_dlm);
|
||||
bfr.Add(flds[0]);
|
||||
case Wdata_dict_val_tid.Tid_globecoordinate: {
|
||||
Wdata_claim_itm_globecoordinate claim_globecoordinate = (Wdata_claim_itm_globecoordinate)prop;
|
||||
bfr.Add(claim_globecoordinate.Lat());
|
||||
bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space);
|
||||
bfr.Add(flds[1]);
|
||||
bfr.Add(claim_globecoordinate.Lng());
|
||||
break;
|
||||
}
|
||||
case Wdata_prop_itm_base_.Val_tid_quantity: {
|
||||
byte[][] flds = Bry_.Split(prop.Val(), Wdata_prop_itm_core.Prop_dlm);
|
||||
byte[] amount_bry = flds[0];
|
||||
case Wdata_dict_val_tid.Tid_quantity: {
|
||||
Wdata_claim_itm_quantity claim_quantity = (Wdata_claim_itm_quantity)prop;
|
||||
byte[] amount_bry = claim_quantity.Amount();
|
||||
int val = Bry_.Xto_int_or(amount_bry, Ignore_comma, 0, amount_bry.length, 0);
|
||||
Xol_lang lang = app.Lang_mgr().Get_by_key(lang_key);
|
||||
bfr.Add(lang.Num_mgr().Format_num(val)); // amount; EX: 1,234
|
||||
bfr.Add(Bry_quantity_margin_of_error); // symbol: EX: ±
|
||||
bfr.Add(flds[1]); // unit; EX: 1
|
||||
bfr.Add(claim_quantity.Unit()); // unit; EX: 1
|
||||
break;
|
||||
}
|
||||
case Wdata_prop_itm_base_.Val_tid_monolingualtext: { // {{#property:monolingualprop}} -> some phrase (la)
|
||||
byte[][] flds = Bry_.Split(prop.Val(), Wdata_prop_itm_core.Prop_dlm);
|
||||
bfr.Add(flds[0]); // phrase only; PAGE:en.w:Alberta; EX: {{#property:motto}} -> "Fortis et libre"; DATE:2014-08-28
|
||||
case Wdata_dict_val_tid.Tid_monolingualtext: { // {{#property:monolingualprop}} -> some phrase (la)
|
||||
Wdata_claim_itm_monolingualtext claim_monolingualtext = (Wdata_claim_itm_monolingualtext)prop;
|
||||
bfr.Add(claim_monolingualtext.Text()); // phrase only; PAGE:en.w:Alberta; EX: {{#property:motto}} -> "Fortis et libre"; DATE:2014-08-28
|
||||
break;
|
||||
}
|
||||
default: throw Err_.unhandled(prop.Val_tid_byte());
|
||||
default: throw Err_.unhandled(prop.Val_tid());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -170,7 +182,7 @@ public class Wdata_wiki_mgr implements GfoInvkAble {
|
||||
public static final byte[] Bry_q = Bry_.new_ascii_("q"), Prop_tmpl_val_dlm = Bry_.new_ascii_(", ");
|
||||
public void Write_json_as_html(Bry_bfr bfr, byte[] data_raw) {
|
||||
bfr.Add(Xoh_consts.Span_bgn_open).Add(Xoh_consts.Id_atr).Add(Html_json_id).Add(Xoh_consts.__end_quote); // <span id="xowa-wikidata-json">
|
||||
Json_doc json = parser.Parse(data_raw);
|
||||
Json_doc json = jdoc_parser.Parse(data_raw);
|
||||
json.Root().Print_as_json(bfr, 0);
|
||||
bfr.Add(Xoh_consts.Span_end);
|
||||
}
|
||||
@ -179,7 +191,7 @@ public class Wdata_wiki_mgr implements GfoInvkAble {
|
||||
Xoa_ttl qid_ttl = Xoa_ttl.parse_(this.Wdata_wiki(), qid_bry); if (qid_ttl == null) {app.Usr_dlg().Warn_many("", "", "invalid qid for ttl: qid=~{0}", String_.new_utf8_(qid_bry)); return null;}
|
||||
Xoa_page qid_page = this.Wdata_wiki().Data_mgr().Get_page(qid_ttl, false); if (qid_page.Missing()) return null;
|
||||
byte[] src = qid_page.Data_raw();
|
||||
return parser.Parse(src);
|
||||
return jdoc_parser.Parse(src);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
|
||||
|
@ -17,7 +17,7 @@ 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.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.gui.*; import gplx.xowa.xtns.wdatas.imports.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.pfuncs.*;
|
||||
public class Wdata_wiki_mgr_fxt {
|
||||
public Xow_wiki Wiki() {return parser_fxt.Wiki();}
|
||||
public Wdata_wiki_mgr_fxt Init() {return Init(new Xop_fxt(), true);}
|
||||
@ -36,16 +36,16 @@ public class Wdata_wiki_mgr_fxt {
|
||||
} private Xoa_app app; Xow_wiki wiki; Wdata_wiki_mgr wdata_mgr; Wdata_doc_bldr page_bldr; Xop_fxt parser_fxt;
|
||||
public Xoa_app App() {return app;}
|
||||
public Wdata_doc_bldr page_bldr_(String qid) {return page_bldr.Qid_(qid);}
|
||||
public Wdata_prop_itm_core prop_novalue_(int pid) {return Wdata_prop_itm_core.new_novalue_(pid);}
|
||||
public Wdata_prop_itm_core prop_somevalue_(int pid) {return Wdata_prop_itm_core.new_somevalue_(pid);}
|
||||
public Wdata_prop_itm_core prop_str_(int pid, String val) {return Wdata_prop_itm_core.new_str_(pid, val);}
|
||||
public Wdata_prop_itm_core prop_str_(int pid, byte[] val) {return Wdata_prop_itm_core.new_str_(pid, val);}
|
||||
public Wdata_prop_itm_core prop_time_(int pid, String val) {return Wdata_prop_itm_core.new_time_(pid, val);}
|
||||
public Wdata_prop_itm_core prop_geodata_(int pid, String lat, String lon) {return Wdata_prop_itm_core.new_geodata_(pid, lat, lon);}
|
||||
public Wdata_prop_itm_core prop_quantity_(int pid, String amount, String unit, String ubound, String lbound) {return Wdata_prop_itm_core.new_quantity_(pid, amount, unit, ubound, lbound);}
|
||||
public Wdata_prop_itm_core prop_monolingualtext_(int pid, String text, String lang) {return Wdata_prop_itm_core.new_monolingualtext_(pid, text, lang);}
|
||||
public Wdata_prop_itm_core prop_entity_(int pid, int val) {return Wdata_prop_itm_core.new_entity_(pid, val);}
|
||||
public Wdata_doc doc_(String qid, Wdata_prop_itm_core... props) {return page_bldr.Qid_(qid).Props_add(props).Xto_page_doc();}
|
||||
public Wdata_claim_itm_core prop_novalue_(int pid) {return Wdata_claim_itm_system.new_novalue(pid);}
|
||||
public Wdata_claim_itm_core prop_somevalue_(int pid) {return Wdata_claim_itm_system.new_somevalue(pid);}
|
||||
public Wdata_claim_itm_core prop_str_(int pid, String val) {return prop_str_(pid, Bry_.new_utf8_(val));}
|
||||
public Wdata_claim_itm_core prop_str_(int pid, byte[] val) {return new Wdata_claim_itm_str(pid, Wdata_dict_snak_tid.Tid_value, val);}
|
||||
public Wdata_claim_itm_core prop_time_(int pid, String val) {return new Wdata_claim_itm_time(pid, Wdata_dict_snak_tid.Tid_value, Wdata_doc_bldr.Xto_time(val), Bry_.Empty, Bry_.Empty, Bry_.Empty, Bry_.Empty, Bry_.Empty);}
|
||||
public Wdata_claim_itm_core prop_monolingualtext_(int pid, String text, String lang) {return new Wdata_claim_itm_monolingualtext(pid, Wdata_dict_snak_tid.Tid_value, Bry_.new_utf8_(lang), Bry_.new_utf8_(text));}
|
||||
public Wdata_claim_itm_core prop_geodata_(int pid, String lat, String lon) {return new Wdata_claim_itm_globecoordinate(pid, Wdata_dict_snak_tid.Tid_value, Bry_.new_ascii_(lat), Bry_.new_ascii_(lon), Bry_.Empty, Bry_.Empty, Bry_.Empty);}
|
||||
public Wdata_claim_itm_core prop_quantity_(int pid, String amount, String unit, String ubound, String lbound) {return new Wdata_claim_itm_quantity(pid, Wdata_dict_snak_tid.Tid_value, Bry_.new_ascii_(amount), Bry_.new_ascii_(unit), Bry_.new_ascii_(ubound), Bry_.new_ascii_(lbound));}
|
||||
public Wdata_claim_itm_core prop_entity_(int pid, int val) {return new Wdata_claim_itm_entity(pid, Wdata_dict_snak_tid.Tid_value, Int_.Xto_bry(val));}
|
||||
public Wdata_doc doc_(String qid, Wdata_claim_itm_core... props) {return page_bldr.Qid_(qid).Props_add(props).Xto_page_doc();}
|
||||
public void Init_xwikis_add(String... prefixes) {
|
||||
int len = prefixes.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
@ -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; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.json.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.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.*;
|
||||
public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
|
||||
public Wdata_xwiki_link_wtr Page_(Xoa_page page) {this.page = page; return this;} private Xoa_page page;
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
@ -36,13 +36,13 @@ public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
|
||||
Wdata_wiki_mgr wdata_mgr = wiki.App().Wiki_mgr().Wdata_mgr();
|
||||
Wdata_doc doc = wdata_mgr.Pages_get(wiki, ttl); if (doc == null) return Qid_null; // no links
|
||||
boolean external_links_mgr_enabled = external_links_mgr.Enabled();
|
||||
OrderedHash links = doc.Link_list();
|
||||
OrderedHash links = doc.Sitelink_list();
|
||||
Bry_bfr tmp_bfr = wiki.App().Utl_bry_bfr_mkr().Get_k004();
|
||||
Xow_wiki_abrv wiki_abrv = new Xow_wiki_abrv();
|
||||
int len = links.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_itm_kv kv = (Json_itm_kv)links.FetchAt(i);
|
||||
byte[] xwiki_key = kv.Key().Data_bry();
|
||||
Wdata_sitelink_itm sitelink = (Wdata_sitelink_itm)links.FetchAt(i);
|
||||
byte[] xwiki_key = sitelink.Site();
|
||||
Xow_wiki_abrv_.parse_(wiki_abrv, xwiki_key, 0, xwiki_key.length);
|
||||
if (wiki_abrv.Domain_tid() == Xow_wiki_abrv_.Tid_null) {
|
||||
wiki.App().Usr_dlg().Warn_many("", "", "unknown wiki in wikidata: ttl=~{0} wiki=~{1}", ttl.Page_db_as_str(), String_.new_utf8_(xwiki_key));
|
||||
@ -53,7 +53,7 @@ public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
|
||||
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);
|
||||
tmp_bfr.Add(Wdata_doc_.Link_extract(kv));
|
||||
tmp_bfr.Add(sitelink.Name());
|
||||
Xoa_ttl lang_ttl = Xoa_ttl.parse_(wiki, tmp_bfr.XtoAryAndClear());
|
||||
if (lang_ttl == null) continue; // invalid ttl
|
||||
Xow_xwiki_itm xwiki_itm = lang_ttl.Wik_itm();
|
||||
|
27
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_alias_itm.java
Normal file
27
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_alias_itm.java
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.json.*;
|
||||
public class Wdata_alias_itm {
|
||||
public Wdata_alias_itm(byte[] lang, byte[][] vals) {this.lang = lang; this.vals = vals;}
|
||||
public byte[] Lang() {return lang;} private byte[] lang;
|
||||
public byte[][] Vals() {return vals;} private byte[][] vals;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", String_.new_utf8_(lang), String_.Concat_with_str("~", String_.Ary(vals)));
|
||||
}
|
||||
}
|
36
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_claim_grp.java
Normal file
36
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_claim_grp.java
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_grp {
|
||||
public Wdata_claim_grp(Int_obj_ref id_ref, Wdata_claim_itm_core[] itms) {this.id_ref = id_ref; this.itms = itms;}
|
||||
public Int_obj_ref Id_ref() {return id_ref;} private final Int_obj_ref id_ref;
|
||||
public int Id() {return id_ref.Val();}
|
||||
public int Itms_len() {return itms.length;} private Wdata_claim_itm_core[] itms;
|
||||
public Wdata_claim_itm_core Itms_get_at(int i) {return itms[i];}
|
||||
public static ListAdp Xto_list(OrderedHash hash) {
|
||||
int len = hash.Count();
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Wdata_claim_grp grp = (Wdata_claim_grp)hash.FetchAt(i);
|
||||
int grp_len = grp.Itms_len();
|
||||
for (int j = 0; j < grp_len; ++j)
|
||||
rv.Add(grp.Itms_get_at(j));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public abstract class Wdata_claim_itm_base implements CompareAble {
|
||||
public Wdata_claim_itm_base Ctor(int pid, byte snak_tid) {
|
||||
this.pid = pid;
|
||||
this.snak_tid = snak_tid;
|
||||
return this;
|
||||
}
|
||||
public int Pid() {return pid;} private int pid;
|
||||
public abstract byte Val_tid();
|
||||
public byte Snak_tid() {return snak_tid;} private byte snak_tid = Wdata_dict_snak_tid.Tid_value;
|
||||
public byte Rank_tid() {return rank_tid;} public void Rank_tid_(byte v) {this.rank_tid = v;} private byte rank_tid;
|
||||
public int compareTo(Object obj) {
|
||||
Wdata_claim_itm_base comp = (Wdata_claim_itm_base)obj;
|
||||
return Int_.Compare(pid, comp.pid);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public abstract class Wdata_claim_itm_core extends Wdata_claim_itm_base {
|
||||
public byte[] Wguid() {return wguid;} public void Wguid_(byte[] v) {this.wguid = v;} private byte[] wguid;
|
||||
public String Prop_type() {return Prop_type_statement;} private static final String Prop_type_statement = "statement";
|
||||
public Wdata_claim_itm_base[] Qual_ary() {return qual_ary;} public void Qual_ary_(Wdata_claim_itm_base[] v) {this.qual_ary = v;} private Wdata_claim_itm_base[] qual_ary;
|
||||
public Wdata_claim_itm_base[] Ref_ary() {return ref_ary;} public void Ref_ary_(Wdata_claim_itm_base[] v) {this.ref_ary = v;} private Wdata_claim_itm_base[] ref_ary;
|
||||
}
|
@ -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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_entity extends Wdata_claim_itm_core { public Wdata_claim_itm_entity(int pid, byte snak_tid, byte[] entity_id_bry) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.entity_id_bry = entity_id_bry;
|
||||
this.entity_id = Bry_.Xto_int_or_fail(entity_id_bry);
|
||||
}
|
||||
@Override public byte Val_tid() {return Wdata_dict_val_tid.Tid_entity;}
|
||||
public byte[] Entity_id_bry() {return entity_id_bry;} private final byte[] entity_id_bry;
|
||||
public int Entity_id() {return entity_id;} private final int entity_id;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()), Int_.Xto_str(entity_id));
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_globecoordinate extends Wdata_claim_itm_core { public Wdata_claim_itm_globecoordinate(int pid, byte snak_tid, byte[] lat, byte[] lng, byte[] alt, byte[] prc, byte[] glb) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.lat = lat; this.lng = lng; this.alt = alt; this.prc = prc; this.glb = glb;
|
||||
}
|
||||
@Override public byte Val_tid() {return Wdata_dict_val_tid.Tid_globecoordinate;}
|
||||
public byte[] Lat() {return lat;} private final byte[] lat;
|
||||
public byte[] Lng() {return lng;} private final byte[] lng;
|
||||
public byte[] Alt() {return alt;} private final byte[] alt;
|
||||
public byte[] Prc() {return prc;} private final byte[] prc;
|
||||
public byte[] Glb() {return glb;} private final byte[] glb;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()), String_.new_utf8_(lat), String_.new_utf8_(lng), String_.new_utf8_(alt), String_.new_utf8_(prc), String_.new_utf8_(glb));
|
||||
}
|
||||
}
|
@ -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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_monolingualtext extends Wdata_claim_itm_core { public Wdata_claim_itm_monolingualtext(int pid, byte snak_tid, byte[] lang, byte[] text) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.lang = lang; this.text = text;
|
||||
}
|
||||
@Override public byte Val_tid() {return Wdata_dict_val_tid.Tid_monolingualtext;}
|
||||
public byte[] Lang() {return lang;} private final byte[] lang;
|
||||
public byte[] Text() {return text;} private final byte[] text;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()), String_.new_utf8_(lang), String_.new_utf8_(text));
|
||||
}
|
||||
}
|
@ -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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_quantity extends Wdata_claim_itm_core { public Wdata_claim_itm_quantity(int pid, byte snak_tid, byte[] amount, byte[] unit, byte[] ubound, byte[] lbound) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.amount = amount; this.unit = unit; this.ubound = ubound; this.lbound = lbound;
|
||||
}
|
||||
@Override public byte Val_tid() {return Wdata_dict_val_tid.Tid_quantity;}
|
||||
public byte[] Amount() {return amount;} private final byte[] amount;
|
||||
public byte[] Unit() {return unit;} private final byte[] unit;
|
||||
public byte[] Ubound() {return ubound;} private final byte[] ubound;
|
||||
public byte[] Lbound() {return lbound;} private final byte[] lbound;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()), String_.new_utf8_(amount), String_.new_utf8_(unit), String_.new_utf8_(ubound), String_.new_utf8_(lbound));
|
||||
}
|
||||
}
|
@ -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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_str extends Wdata_claim_itm_core { public Wdata_claim_itm_str(int pid, byte snak_tid, byte[] val) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.val = val;
|
||||
}
|
||||
@Override public byte Val_tid() {return Wdata_dict_val_tid.Tid_string;}
|
||||
public byte[] Val_str() {return val;} private final byte[] val;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()), String_.new_utf8_(val));
|
||||
}
|
||||
}
|
@ -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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_system extends Wdata_claim_itm_core { public Wdata_claim_itm_system(int pid, byte val_tid, byte snak_tid) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.val_tid = val_tid;
|
||||
}
|
||||
@Override public byte Val_tid() {return val_tid;} private byte val_tid;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()));
|
||||
}
|
||||
public static Wdata_claim_itm_system new_novalue(int pid) {return new Wdata_claim_itm_system(pid, Wdata_dict_val_tid.Tid_unknown , Wdata_dict_snak_tid.Tid_novalue);}
|
||||
public static Wdata_claim_itm_system new_somevalue(int pid) {return new Wdata_claim_itm_system(pid, Wdata_dict_val_tid.Tid_unknown , Wdata_dict_snak_tid.Tid_somevalue);}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_claim_itm_time extends Wdata_claim_itm_core { public Wdata_claim_itm_time(int pid, byte snak_tid, byte[] time, byte[] timezone, byte[] before, byte[] after, byte[] precision, byte[] calendarmodel) {
|
||||
this.Ctor(pid, snak_tid);
|
||||
this.time = time; this.before = before; this.after = after; this.precision = precision; this.calendarmodel = calendarmodel;
|
||||
}
|
||||
@Override public byte Val_tid() {return Wdata_dict_val_tid.Tid_time;}
|
||||
public byte[] Time() {return time;} private final byte[] time;
|
||||
public byte[] Before() {return before;} private final byte[] before;
|
||||
public byte[] After() {return after;} private final byte[] after;
|
||||
public byte[] Precision() {return precision;} private final byte[] precision;
|
||||
public byte[] Calendarmodel() {return calendarmodel;} private final byte[] calendarmodel;
|
||||
@Override public String toString() {// TEST:
|
||||
return String_.Concat_with_str("|", Wdata_dict_snak_tid.Xto_str(this.Snak_tid()), Wdata_dict_val_tid.Xto_str(this.Val_tid()), String_.new_utf8_(time), String_.new_utf8_(before), String_.new_utf8_(after), String_.new_utf8_(precision), String_.new_utf8_(calendarmodel));
|
||||
}
|
||||
}
|
@ -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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_claim {
|
||||
public static final byte
|
||||
Tid_mainsnak = 0
|
||||
, Tid_type = 1
|
||||
, Tid_id = 2
|
||||
, Tid_rank = 3
|
||||
, Tid_references = 4
|
||||
, Tid_qualifiers = 5
|
||||
, Tid_qualifiers_order = 6
|
||||
;
|
||||
public static byte[]
|
||||
Bry_mainsnak = Bry_.new_ascii_("mainsnak")
|
||||
, Bry_type = Bry_.new_ascii_("type")
|
||||
, Bry_id = Bry_.new_ascii_("id")
|
||||
, Bry_rank = Bry_.new_ascii_("rank")
|
||||
, Bry_references = Bry_.new_ascii_("references")
|
||||
, Bry_qualifiers = Bry_.new_ascii_("qualifiers")
|
||||
, Bry_qualifiers_order = Bry_.new_ascii_("qualifiers-order")
|
||||
;
|
||||
public static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_mainsnak , Tid_mainsnak)
|
||||
.Add_bry_byte(Bry_type , Tid_type)
|
||||
.Add_bry_byte(Bry_id , Tid_id)
|
||||
.Add_bry_byte(Bry_rank , Tid_rank)
|
||||
.Add_bry_byte(Bry_references , Tid_references)
|
||||
.Add_bry_byte(Bry_qualifiers , Tid_qualifiers)
|
||||
.Add_bry_byte(Bry_qualifiers_order , Tid_qualifiers_order)
|
||||
;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_claim_v1 {
|
||||
public static final String
|
||||
Str_m = "m"
|
||||
, Str_q = "q"
|
||||
, Str_g = "g"
|
||||
, Str_rank = "rank"
|
||||
, Str_refs = "refs"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry_m = Bry_.new_ascii_(Str_m)
|
||||
, Bry_q = Bry_.new_ascii_(Str_q)
|
||||
, Bry_g = Bry_.new_ascii_(Str_g)
|
||||
, Bry_rank = Bry_.new_ascii_(Str_rank)
|
||||
, Bry_refs = Bry_.new_ascii_(Str_refs)
|
||||
;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_datavalue {
|
||||
public static final byte
|
||||
Tid_value = 0
|
||||
, Tid_type = 1
|
||||
;
|
||||
public static byte[]
|
||||
Bry_value = Bry_.new_ascii_("value")
|
||||
, Bry_type = Bry_.new_ascii_("type")
|
||||
;
|
||||
public static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_value , Tid_value)
|
||||
.Add_bry_byte(Bry_type , Tid_type)
|
||||
;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_langtext {
|
||||
public static final byte
|
||||
Tid_language = 0
|
||||
, Tid_value = 1
|
||||
;
|
||||
public static final String
|
||||
Str_language = "language"
|
||||
, Str_value = "value"
|
||||
;
|
||||
public static byte[]
|
||||
Bry_language = Bry_.new_ascii_(Str_language)
|
||||
, Bry_value = Bry_.new_ascii_(Str_value)
|
||||
;
|
||||
public static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_language , Tid_language)
|
||||
.Add_bry_byte(Bry_value , Tid_value)
|
||||
;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_mainsnak {
|
||||
public static final byte
|
||||
Tid_snaktype = 0
|
||||
, Tid_property = 1
|
||||
, Tid_hash = 2
|
||||
, Tid_datavalue = 3
|
||||
, Tid_type = 4
|
||||
;
|
||||
public static byte[]
|
||||
Bry_snaktype = Bry_.new_ascii_("snaktype")
|
||||
, Bry_property = Bry_.new_ascii_("property")
|
||||
, Bry_hash = Bry_.new_ascii_("hash")
|
||||
, Bry_datavalue = Bry_.new_ascii_("datavalue")
|
||||
, Bry_type = Bry_.new_ascii_("type")
|
||||
;
|
||||
public static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_snaktype , Tid_snaktype)
|
||||
.Add_bry_byte(Bry_property , Tid_property)
|
||||
.Add_bry_byte(Bry_hash , Tid_hash)
|
||||
.Add_bry_byte(Bry_datavalue , Tid_datavalue)
|
||||
.Add_bry_byte(Bry_type , Tid_type)
|
||||
;
|
||||
}
|
53
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_dict_rank.java
Normal file
53
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_dict_rank.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_rank {
|
||||
public static final byte // SERIALIZED:
|
||||
Tid_preferred = 2
|
||||
, Tid_normal = 1
|
||||
, Tid_deprecated = 0
|
||||
, Tid_unknown = Byte_.MaxValue_127
|
||||
;
|
||||
public static final String
|
||||
Str_preferred = "preferred"
|
||||
, Str_normal = "normal"
|
||||
, Str_deprecated = "deprecated"
|
||||
;
|
||||
public static byte[]
|
||||
Bry_preferred = Bry_.new_ascii_(Str_preferred)
|
||||
, Bry_normal = Bry_.new_ascii_(Str_normal)
|
||||
, Bry_deprecated = Bry_.new_ascii_(Str_deprecated)
|
||||
;
|
||||
public static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_preferred , Tid_preferred)
|
||||
.Add_bry_byte(Bry_normal , Tid_normal)
|
||||
.Add_bry_byte(Bry_deprecated , Tid_deprecated)
|
||||
;
|
||||
public static String Xto_str(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid_preferred : return Str_preferred;
|
||||
case Tid_normal : return Str_normal;
|
||||
case Tid_deprecated : return Str_deprecated;
|
||||
default : throw Err_.unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(byte[] v) {
|
||||
Object rv_obj = Dict.Get_by_bry(v); if (rv_obj == null) throw Err_.new_fmt_("unknown rank: val=~{0}", String_.new_utf8_(v));
|
||||
return ((Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_sitelink {
|
||||
public static final byte
|
||||
Tid_site = 0
|
||||
, Tid_title = 1
|
||||
, Tid_badges = 2
|
||||
;
|
||||
public static final String
|
||||
Str_site = "site"
|
||||
, Str_title = "title"
|
||||
, Str_badges = "badges"
|
||||
;
|
||||
public static byte[]
|
||||
Bry_site = Bry_.new_ascii_(Str_site)
|
||||
, Bry_title = Bry_.new_ascii_(Str_title)
|
||||
, Bry_badges = Bry_.new_ascii_(Str_badges)
|
||||
;
|
||||
public static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_site , Tid_site)
|
||||
.Add_bry_byte(Bry_title , Tid_title)
|
||||
.Add_bry_byte(Bry_badges , Tid_badges)
|
||||
;
|
||||
}
|
@ -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.xowa.xtns.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_snak_tid {
|
||||
public static final byte
|
||||
Tid_novalue = 0
|
||||
, Tid_value = 1
|
||||
, Tid_somevalue = 2
|
||||
;
|
||||
public static final String
|
||||
Str_novalue = "novalue"
|
||||
, Str_value = "value"
|
||||
, Str_somevalue = "somevalue"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry_novalue = Bry_.new_ascii_(Str_novalue)
|
||||
, Bry_value = Bry_.new_ascii_(Str_value)
|
||||
, Bry_somevalue = Bry_.new_ascii_(Str_somevalue)
|
||||
;
|
||||
private static Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_novalue , Tid_novalue)
|
||||
.Add_bry_byte(Bry_value , Tid_value)
|
||||
.Add_bry_byte(Bry_somevalue , Tid_somevalue)
|
||||
;
|
||||
public static String Xto_str(byte v) {
|
||||
switch (v) {
|
||||
case Tid_novalue: return Str_novalue;
|
||||
case Tid_value: return Str_value;
|
||||
case Tid_somevalue: return Str_somevalue;
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
public static byte[] Xto_bry(byte v) {
|
||||
switch (v) {
|
||||
case Tid_novalue: return Bry_novalue;
|
||||
case Tid_value: return Bry_value;
|
||||
case Tid_somevalue: return Bry_somevalue;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(byte[] v) {
|
||||
Object rv_obj = Dict.Get_by_bry(v); if (rv_obj == null) throw Err_.new_fmt_("unknown snak tid: val=~{0}", String_.new_utf8_(v));
|
||||
return ((Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
}
|
25
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_dict_utl.java
Normal file
25
400_xowa/src/gplx/xowa/xtns/wdatas/core/Wdata_dict_utl.java
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_utl {
|
||||
public static byte Get_tid_or_fail(Hash_adp_bry dict, byte[] key) {
|
||||
Object rv_obj = dict.Get_by_bry(key);
|
||||
if (rv_obj == null) throw Err_.new_("unknown key; key={0}", String_.new_ascii_(key));
|
||||
return ((Byte_obj_val)rv_obj).Val();
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
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.wdatas.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_dict_val_tid {
|
||||
public static final byte
|
||||
Tid_unknown = 0
|
||||
, Tid_value = 1
|
||||
, Tid_bad = 1
|
||||
, Tid_string = 2
|
||||
, Tid_entity = 3
|
||||
, Tid_time = 4
|
||||
, Tid_globecoordinate = 5
|
||||
, Tid_quantity = 6
|
||||
, Tid_monolingualtext = 7
|
||||
;
|
||||
public static final String
|
||||
Str_bad = "bad"
|
||||
, Str_string = "string"
|
||||
, Str_entity = "wikibase-entityid"
|
||||
, Str_time = "time"
|
||||
, Str_globecoordinate = "globecoordinate"
|
||||
, Str_quantity = "quantity"
|
||||
, Str_monolingualtext = "monolingualtext"
|
||||
, Str_unknown = "unknown"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry_bad = Bry_.new_ascii_(Str_bad)
|
||||
, Bry_string = Bry_.new_ascii_(Str_string)
|
||||
, Bry_entity = Bry_.new_ascii_(Str_entity)
|
||||
, Bry_time = Bry_.new_ascii_(Str_time)
|
||||
, Bry_globecoordinate = Bry_.new_ascii_(Str_globecoordinate)
|
||||
, Bry_quantity = Bry_.new_ascii_(Str_quantity)
|
||||
, Bry_monolingualtext = Bry_.new_ascii_(Str_monolingualtext)
|
||||
;
|
||||
private static final Hash_adp_bry Dict = Hash_adp_bry.cs_()
|
||||
.Add_bry_byte(Bry_string , Tid_string)
|
||||
.Add_bry_byte(Bry_entity , Tid_entity)
|
||||
.Add_bry_byte(Bry_time , Tid_time)
|
||||
.Add_bry_byte(Bry_globecoordinate , Tid_globecoordinate)
|
||||
.Add_bry_byte(Bry_quantity , Tid_quantity)
|
||||
.Add_bry_byte(Bry_monolingualtext , Tid_monolingualtext)
|
||||
.Add_bry_byte(Bry_bad , Tid_bad)
|
||||
;
|
||||
public static String Xto_str(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid_string : return Str_string;
|
||||
case Tid_entity : return Str_entity;
|
||||
case Tid_time : return Str_time;
|
||||
case Tid_globecoordinate : return Str_globecoordinate;
|
||||
case Tid_quantity : return Str_quantity;
|
||||
case Tid_monolingualtext : return Str_monolingualtext;
|
||||
case Tid_bad : return Str_bad; // NOTE: wikidata identifies several entries as "bad"; Q1615351|'s-Graveland, Q107538|Baco; DATE:2013-10-20
|
||||
default : return Str_unknown;
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(byte[] src) {return Xto_tid(src, 0, src.length);}
|
||||
public static byte Xto_tid(byte[] src, int bgn, int end) {
|
||||
Object bval_obj = Dict.Get_by_mid(src, bgn, end);
|
||||
if (bval_obj == null) return Tid_unknown;
|
||||
return ((Byte_obj_val)bval_obj).Val();
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user