mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.3.1
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
<classpathentry kind="src" path="src_490_xnde"/>
|
||||
<classpathentry kind="src" path="src_500_tmpl"/>
|
||||
<classpathentry kind="src" path="src_510_pf_core"/>
|
||||
<classpathentry kind="src" path="src_530_pf_str"/>
|
||||
<classpathentry kind="src" path="xtn"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/100_core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/150_gfui"/>
|
||||
|
||||
@@ -30,8 +30,8 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
public byte[] Read_bry_simple() {Move_next_simple(); return Bry_.Mid(data, fld_bgn, fld_end);} // was Mid_by_len???; 20120915
|
||||
public int Read_int_base85_lenN(int len) {fld_bgn = pos; fld_end = pos + len - 1 ; pos = pos + len + 1 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int_base85_len5() {fld_bgn = pos; fld_end = pos + 4 ; pos = pos + 6 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int() {Move_next_simple(); return Bry_.X_to_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_int_as_byte() {Move_next_simple(); return (byte)Bry_.X_to_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public int Read_int() {Move_next_simple(); return Bry_.Xto_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_int_as_byte() {Move_next_simple(); return (byte)Bry_.Xto_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_byte() {Move_next_simple(); return data[fld_bgn];}
|
||||
public double Read_double() {Move_next_simple(); return Bry_.XtoDoubleByPos(data, fld_bgn, fld_end);}
|
||||
public DateAdp Read_dte() {// NOTE: fmt = yyyyMMdd HHmmss.fff
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Fsdb_db_bin_mgr implements RlsAble {
|
||||
for (int i = 0; i < itms_len; i++)
|
||||
itms[i].Bin_max_(v);
|
||||
return this;
|
||||
} private long db_bin_max = Io_mgr.Len_mb * Long_.X_by_int(188);
|
||||
} private long db_bin_max = Io_mgr.Len_mb * Long_.Xby_int(188);
|
||||
public Fsdb_db_bin_fil Get_at(int i) {return itms[i];}
|
||||
private Fsdb_db_bin_fil Get_cur() {return itms_len == 0 ? null : itms[itms_len - 1];}
|
||||
public void Txn_open() {
|
||||
|
||||
36
400_xowa/src/gplx/fsdb/Fsdb_db_tid_.java
Normal file
36
400_xowa/src/gplx/fsdb/Fsdb_db_tid_.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.fsdb; import gplx.*;
|
||||
public class Fsdb_db_tid_ {
|
||||
public static final byte Tid_cfg = 0, Tid_atr = 1, Tid_bin = 2;
|
||||
public static final String Key_cfg = "cfg", Key_atr = "atr", Key_bin = "bin";
|
||||
public static byte Xto_tid(String s) {
|
||||
if (String_.Eq(s, Key_cfg)) return Tid_cfg;
|
||||
else if (String_.Eq(s, Key_atr)) return Tid_atr;
|
||||
else if (String_.Eq(s, Key_bin)) return Tid_bin;
|
||||
else throw Err_.unhandled(s);
|
||||
}
|
||||
public static String Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_cfg: return Key_cfg;
|
||||
case Tid_atr: return Key_atr;
|
||||
case Tid_bin: return Key_bin;
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,8 @@ public class Gfui_bnd_parser {
|
||||
};
|
||||
private byte[] src; private int src_len;
|
||||
private ListAdp tkns = ListAdp_.new_(); private int mod_val = Mod_val_null;
|
||||
public String X_to_norm(String src_str) {return Convert(Bool_.Y, src_str);}
|
||||
public String X_to_gfui(String src_str) {return Convert(Bool_.N, src_str);}
|
||||
public String Xto_norm(String src_str) {return Convert(Bool_.Y, src_str);}
|
||||
public String Xto_gfui(String src_str) {return Convert(Bool_.N, src_str);}
|
||||
private String Convert(boolean src_is_gfui, String src_str) {
|
||||
this.src = Bry_.new_utf8_(src_str); this.src_len = src.length;
|
||||
tkns.Clear(); mod_val = Mod_val_null;
|
||||
|
||||
@@ -48,9 +48,9 @@ class Gfui_bnd_parser_fxt {
|
||||
parser = Gfui_bnd_parser.new_en_();
|
||||
}
|
||||
public void Test_x_to_norm(String key, String expd) {
|
||||
Tfds.Eq(expd, parser.X_to_norm(key));
|
||||
Tfds.Eq(expd, parser.Xto_norm(key));
|
||||
}
|
||||
public void Test_x_to_gfui(String key, String expd) {
|
||||
Tfds.Eq(expd, parser.X_to_gfui(key));
|
||||
Tfds.Eq(expd, parser.Xto_gfui(key));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public class Html_wtr {
|
||||
bfr.Add_byte(Byte_ascii.Gt);
|
||||
return this;
|
||||
}
|
||||
public byte[] X_to_bry_and_clear() {return bfr.XtoAryAndClear();}
|
||||
public byte[] X_to_bry() {return bfr.XtoAry();}
|
||||
public String X_to_str() {return bfr.XtoStr();}
|
||||
public byte[] Xto_bry_and_clear() {return bfr.XtoAryAndClear();}
|
||||
public byte[] Xto_bry() {return bfr.XtoAry();}
|
||||
public String Xto_str() {return bfr.XtoStr();}
|
||||
public static void Write_atr(Bry_bfr bfr, byte[] key, byte[] val) {Write_atr(bfr, Byte_ascii.Quote, key, val);}
|
||||
public static void Write_atr(Bry_bfr bfr, byte atr_quote, byte[] key, byte[] val) {
|
||||
if (Bry_.Len_eq_0(val)) return; // don't write empty
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Json_doc_srl {
|
||||
if (ClassAdp_.Is_array(t))
|
||||
Write_kv_ary(comma, key, (Object[])val);
|
||||
else
|
||||
Write_kv_str(comma, key, Object_.XtoStr_OrEmpty(val));
|
||||
Write_kv_str(comma, key, Object_.Xto_str_strict_or_empty(val));
|
||||
}
|
||||
private void Write_kv_ary(boolean comma, byte[] key, Object[] val) {
|
||||
Write_key(comma, key); Write_new_line(); // '"key":\n'
|
||||
@@ -42,7 +42,7 @@ public class Json_doc_srl {
|
||||
int len = val.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Write_itm_hdr(i != 0); // ', '
|
||||
Write_str(Bry_.new_utf8_(Object_.XtoStr_OrNull(val[i])));
|
||||
Write_str(Bry_.new_utf8_(Object_.Xto_str_strict_or_null(val[i])));
|
||||
Write_new_line();
|
||||
}
|
||||
Indent_del();
|
||||
|
||||
@@ -67,6 +67,6 @@ public class Json_itm_nde extends Json_itm_base implements Json_grp {
|
||||
Json_grp_.Print_nl(bfr); Json_grp_.Print_indent(bfr, depth);
|
||||
bfr.Add_byte(Byte_ascii.Curly_end).Add_byte_nl();
|
||||
}
|
||||
Json_itm[] subs = Json_itm_.Ary_empty;
|
||||
private Json_itm[] subs = Json_itm_.Ary_empty;
|
||||
public static Json_itm_nde cast_(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid_nde ? null : (Json_itm_nde)v;}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.json; import gplx.*;
|
||||
public class Json_itm_tmp implements Json_itm {
|
||||
public Json_itm_tmp(byte tid, String data) {this.tid = tid; this.data = data;}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Data_bry() {return Bry_.new_utf8_(Object_.XtoStr_OrEmpty(data));}
|
||||
public byte[] Data_bry() {return Bry_.new_utf8_(Object_.Xto_str_strict_or_empty(data));}
|
||||
public int Src_bgn() {return -1;}
|
||||
public int Src_end() {return -1;}
|
||||
public Object Data() {return data;} private String data;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Php_itm_ {
|
||||
return rv;
|
||||
case Php_itm_.Tid_quote:
|
||||
byte[] bry = ((Php_itm_quote)itm).Val_obj_bry();
|
||||
rv = Bry_.X_to_int_or(bry, -1);
|
||||
rv = Bry_.Xto_int_or(bry, -1);
|
||||
return (rv == -1) ? or : rv;
|
||||
default:
|
||||
return or;
|
||||
|
||||
@@ -39,7 +39,7 @@ abstract class Php_srl_itm_base implements Php_srl_itm {
|
||||
@gplx.Virtual public void Xto_bfr(Bry_bfr bfr, int depth) {
|
||||
Php_srl_wtr.Indent(bfr, depth);
|
||||
bfr.Add(Php_srl_itm_.Names[this.Tid()]).Add_byte(Byte_ascii.Colon);
|
||||
bfr.Add_str(Object_.XtoStr_OrNullStr(this.Val())).Add_byte(Byte_ascii.Semic).Add_byte_nl();
|
||||
bfr.Add_str(Object_.Xto_str_strict_or_null_mark(this.Val())).Add_byte(Byte_ascii.Semic).Add_byte_nl();
|
||||
}
|
||||
public void Clear() {}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Php_srl_parser {
|
||||
val = Xto_kv_ary(ary);
|
||||
break;
|
||||
case Php_srl_itm_.Tid_function:
|
||||
val = new gplx.xowa.xtns.scribunto.Scrib_lua_proc(Object_.XtoStr_OrNullStr(key), Int_.cast_(itm_val.Val())); // NOTE: in most cases, key is a STRING (name of ScribFunction); however, for gsub it is an INT (arg_idx) b/c it is passed as a parameter
|
||||
val = new gplx.xowa.xtns.scribunto.Scrib_lua_proc(Object_.Xto_str_strict_or_null_mark(key), Int_.cast_(itm_val.Val())); // NOTE: in most cases, key is a STRING (name of ScribFunction); however, for gsub it is an INT (arg_idx) b/c it is passed as a parameter
|
||||
break;
|
||||
default:
|
||||
val = itm_val.Val();
|
||||
@@ -147,7 +147,7 @@ public class Php_srl_parser {
|
||||
pos = bgn;
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Colon);
|
||||
int int_end = Skip_while_num(raw, raw_len, pos, true);
|
||||
int int_val = Bry_.X_to_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
int int_val = Bry_.Xto_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
pos = int_end;
|
||||
return int_val;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class Php_srl_parser {
|
||||
pos = bgn;
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Colon);
|
||||
int int_end = Skip_while_num(raw, raw_len, pos, true);
|
||||
int int_val = Bry_.X_to_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
int int_val = Bry_.Xto_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
Php_srl_itm_int rv = factory.Int(pos, int_end, int_val);
|
||||
pos = int_end;
|
||||
return rv;
|
||||
|
||||
@@ -84,7 +84,7 @@ public class Php_text_itm_parser {
|
||||
//throw Err_mgr._.fmt_auto_(GRP_KEY, "dollar_is_last_char", String_.new_utf8_(raw));
|
||||
}
|
||||
int int_end = Find_fwd_non_int(raw, i + 1, raw_len); // +1 to search after $
|
||||
int int_val = Bry_.X_to_int_or(raw, i + 1, int_end, -1); // +1 to search after $
|
||||
int int_val = Bry_.Xto_int_or(raw, i + 1, int_end, -1); // +1 to search after $
|
||||
if (int_val == -1) {
|
||||
tmp_list.Add(new Php_text_itm_text(i, i + 1));
|
||||
continue;
|
||||
|
||||
@@ -59,7 +59,7 @@ class Php_tkn_var extends Php_tkn_base {
|
||||
class Php_tkn_num extends Php_tkn_base {
|
||||
public Php_tkn_num(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_num;}
|
||||
public int Num_val_int(byte[] src) {return Bry_.X_to_int_or(src, this.Src_bgn(), this.Src_end(), Int_.MinValue);}
|
||||
public int Num_val_int(byte[] src) {return Bry_.Xto_int_or(src, this.Src_bgn(), this.Src_end(), Int_.MinValue);}
|
||||
}
|
||||
class Php_tkn_quote extends Php_tkn_base {
|
||||
public Php_tkn_quote(int src_bgn, int src_end, byte quote_tid) {this.Src_rng_(src_bgn, src_end); this.quote_tid = quote_tid;}
|
||||
|
||||
@@ -63,14 +63,14 @@ class Dsv_fld_parser_int implements Dsv_fld_parser {
|
||||
boolean pos_is_last = pos == src_len;
|
||||
byte b = pos_is_last ? row_dlm : src[pos];
|
||||
if (b == fld_dlm) {
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.X_to_int_or(src, fld_bgn, pos, -1));
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.Xto_int_or(src, fld_bgn, pos, -1));
|
||||
if (!pass) throw Dsv_fld_parser_.err_fld_unhandled(this, wkr, fld_idx, src, fld_bgn, pos);
|
||||
int rv = pos + 1; // fld_dlm is always 1 byte
|
||||
parser.Update_by_fld(rv);
|
||||
return rv;
|
||||
}
|
||||
else if (b == row_dlm) {
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.X_to_int_or(src, fld_bgn, pos, -1));
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.Xto_int_or(src, fld_bgn, pos, -1));
|
||||
if (!pass) throw Dsv_fld_parser_.err_fld_unhandled(this, wkr, fld_idx, src, fld_bgn, pos);
|
||||
wkr.Commit_itm(parser, pos);
|
||||
int rv = pos + 1; // row_dlm is always 1 byte
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.threads.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.urls.encoders.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.fmtrs.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*;
|
||||
@@ -39,7 +39,7 @@ public class Xoa_app implements GfoInvkAble {
|
||||
gui_mgr = new Xoa_gui_mgr(this);
|
||||
bldr = new Xob_bldr(this);
|
||||
file_mgr.Init_app(this, usr_dlg);
|
||||
href_parser = new Xoh_href_parser(url_converter_href, url_parser.Url_parser());
|
||||
href_parser = new Xoh_href_parser(encoder_mgr.Href(), url_parser.Url_parser());
|
||||
sanitizer = new Xop_sanitizer(parser_amp_mgr, msg_log);
|
||||
user_mgr = new Xou_user_mgr(this, user);
|
||||
sys_cfg = new Xoa_sys_cfg(this);
|
||||
@@ -49,7 +49,7 @@ public class Xoa_app implements GfoInvkAble {
|
||||
gfs_mgr = new Xoa_gfs_mgr(this);
|
||||
xtn_mgr = new Xow_xtn_mgr().Ctor_by_app(this);
|
||||
hive_mgr = new Xoa_hive_mgr(this);
|
||||
Io_url.Http_file_str_encoder = url_converter_fsys;
|
||||
Io_url.Http_file_str_encoder = encoder_mgr.Fsys();
|
||||
tcp_server.App_ctor(this);
|
||||
fmtr_mgr = new Xoa_fmtr_mgr(this);
|
||||
log_mgr = new Xop_log_mgr(this);
|
||||
@@ -113,7 +113,7 @@ public class Xoa_app implements GfoInvkAble {
|
||||
public byte Mode() {return mode;} public Xoa_app Mode_(byte v) {mode = v; return this;} private byte mode = Xoa_app_.Mode_console;
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = new Xop_amp_mgr();
|
||||
public Xoa_thread_mgr Thread_mgr() {return thread_mgr;} private Xoa_thread_mgr thread_mgr = new Xoa_thread_mgr();
|
||||
|
||||
public Url_encoder_mgr Encoder_mgr() {return encoder_mgr;} private Url_encoder_mgr encoder_mgr = new Url_encoder_mgr();
|
||||
|
||||
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xoa_fsys_mgr fsys_mgr;
|
||||
public Xoa_hive_mgr Hive_mgr() {return hive_mgr;} private Xoa_hive_mgr hive_mgr;
|
||||
@@ -129,21 +129,13 @@ public class Xoa_app implements GfoInvkAble {
|
||||
public Gfo_msg_log Msg_log() {return msg_log;} private Gfo_msg_log msg_log = new Gfo_msg_log(Xoa_app_.Name);
|
||||
public Gfo_msg_log Msg_log_null() {return msg_log_null;} private Gfo_msg_log msg_log_null = new Gfo_msg_log("null_log");
|
||||
|
||||
public Url_encoder Url_converter_id() {return url_converter_id;} private Url_encoder url_converter_id = Url_encoder.new_html_id_();
|
||||
public Url_encoder Url_converter_url() {return url_converter_url;} private Url_encoder url_converter_url = Url_encoder.new_http_url_();
|
||||
public Url_encoder Url_converter_url_ttl() {return url_converter_url_ttl;} private Url_encoder url_converter_url_ttl = Url_encoder.new_http_url_ttl_();
|
||||
public Url_encoder Url_converter_href() {return url_converter_href;} private Url_encoder url_converter_href = Url_encoder.new_html_href_mw_();
|
||||
public Url_encoder Url_converter_comma() {return url_converter_comma;} private Url_encoder url_converter_comma = Url_encoder.url_comma();
|
||||
public Url_encoder Url_converter_gfs() {return url_converter_gfs;} private Url_encoder url_converter_gfs = Url_encoder.new_gfs_();
|
||||
public Url_encoder Url_converter_fsys() {return url_converter_fsys;} private Url_encoder url_converter_fsys = Url_encoder.new_fsys_lnx_();
|
||||
public Url_encoder Url_converter_fsys_safe() {return url_converter_fsys_safe;} private Url_encoder url_converter_fsys_safe = Url_encoder.new_fsys_wnt_();
|
||||
public Xoh_file_main_wkr File_main_wkr() {return file_main_wkr;} private Xoh_file_main_wkr file_main_wkr = new Xoh_file_main_wkr();
|
||||
public Btrie_slim_mgr Utl_trie_tblw_ws() {return utl_trie_tblw_ws;} private Btrie_slim_mgr utl_trie_tblw_ws = Xop_tblw_ws_itm.trie_();
|
||||
public Bry_bfr_mkr Utl_bry_bfr_mkr() {return utl_bry_bfr_mkr;} Bry_bfr_mkr utl_bry_bfr_mkr = new Bry_bfr_mkr();
|
||||
public Gfo_fld_rdr Utl_fld_rdr() {return utl_fld_rdr;} Gfo_fld_rdr utl_fld_rdr = Gfo_fld_rdr.xowa_();
|
||||
public Gfo_log_bfr Log_bfr() {return log_bfr;} private Gfo_log_bfr log_bfr = new Gfo_log_bfr();
|
||||
public Xoa_sys_cfg Sys_cfg() {return sys_cfg;} private Xoa_sys_cfg sys_cfg;
|
||||
public Bry_fmtr Tmp_fmtr() {return tmp_fmtr;} Bry_fmtr tmp_fmtr = Bry_fmtr.new_("");
|
||||
public Bry_fmtr Tmp_fmtr() {return tmp_fmtr;} Bry_fmtr tmp_fmtr = Bry_fmtr.new_("");
|
||||
public boolean Xwiki_missing(byte[] wiki_key) {return user.Wiki().Xwiki_mgr().Get_by_key(wiki_key) == null;} // NOTE: only the user_wiki has a full list of all wikis b/c it has xwiki objects; wiki_mgr does not, b/c it has heavier wiki objects which are loaded dynamically;
|
||||
public boolean Xwiki_exists(byte[] wiki_key) {return user.Wiki().Xwiki_mgr().Get_by_key(wiki_key) != null;}
|
||||
public Xoa_ctg_mgr Ctg_mgr() {return ctg_mgr;} private Xoa_ctg_mgr ctg_mgr = new Xoa_ctg_mgr();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "1.7.2.1";
|
||||
public static final String Version = "1.7.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
@@ -120,7 +120,7 @@ class Xoa_app_boot_mgr {
|
||||
Io_url wiki_dir = args_mgr.Args_get("wiki_dir").Val_as_url_rel_dir_or(root_dir.GenSubDir("wiki"), root_dir.GenSubDir("wiki"));
|
||||
Io_url cmd_file = args_mgr.Args_get("cmd_file").Val_as_url_rel_fil_or(jar_dir, root_dir.GenSubFil("xowa.gfs"));
|
||||
String app_mode = args_mgr.Args_get("app_mode").Val_as_str_or("gui");
|
||||
String launch_url = args_mgr.Args_get("url").Val_as_str_or(Xoa_sys_cfg.Launch_url_dflt);
|
||||
String launch_url = args_mgr.Args_get("url").Val_as_str_or(null);
|
||||
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);
|
||||
@@ -133,8 +133,9 @@ class Xoa_app_boot_mgr {
|
||||
app = new Xoa_app(usr_dlg, root_dir, user_dir, Xoa_app_.Op_sys); usr_dlg.Log_wtr().Queue_enabled_(false); log_wtr.Log_msg_to_session_fmt("app.init");
|
||||
app.Fsys_mgr().Wiki_dir_(wiki_dir);
|
||||
try {
|
||||
app.Sys_cfg().Lang_(System_lang()); chkpoint = "lang";
|
||||
app.Sys_cfg().Launch_url_(launch_url); chkpoint = "url";
|
||||
app.Sys_cfg().Lang_(System_lang());
|
||||
if (launch_url != null)
|
||||
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.Init(); chkpoint = "init_gfs";
|
||||
@@ -147,7 +148,7 @@ class Xoa_app_boot_mgr {
|
||||
catch (Exception e) {
|
||||
usr_dlg.Warn_many("", "", "script file failed: ~{0} ~{1} ~{2}", chkpoint, cmd_file.Raw(), Err_.Message_gplx(e));
|
||||
if (app_mode_gui)
|
||||
GfuiEnv_.ShowMsg(Err_.Message_gplx_brief(e));
|
||||
GfuiEnv_.ShowMsg(Err_.Message_gplx(e));
|
||||
}
|
||||
|
||||
// launch
|
||||
@@ -158,7 +159,7 @@ class Xoa_app_boot_mgr {
|
||||
app.Http_server().Run();
|
||||
else {
|
||||
if (cmd_text != null)
|
||||
ConsoleAdp._.WriteLine_utf8(Object_.XtoStr_OrEmpty(app.Gfs_mgr().Run_str(cmd_text)));
|
||||
ConsoleAdp._.WriteLine_utf8(Object_.Xto_str_strict_or_empty(app.Gfs_mgr().Run_str(cmd_text)));
|
||||
if (app_mode_gui) {
|
||||
app.Mode_(Xoa_app_.Mode_gui);
|
||||
app.Gui_mgr().Run(); chkpoint = "run";
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.apis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.apis.xowa.*; import gplx.xowa.gui.cmds.*;
|
||||
public class Xoapi_root implements GfoInvkAble {
|
||||
public Xoa_app app;
|
||||
private Xoa_app app;
|
||||
public Xoapi_root(Xoa_app app) {usr_api.Ctor_by_app(app);}
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
this.app = app;
|
||||
|
||||
@@ -17,16 +17,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.gui.views.*;
|
||||
import gplx.xowa.apis.xowa.startups.*;
|
||||
public class Xoapi_app implements GfoInvkAble {
|
||||
private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
public void Exit() {win.App__exit();}
|
||||
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_exit)) this.Exit();
|
||||
else if (ctx.Match(k, Invk_startup)) return startup;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exit = "exit";
|
||||
private static final String Invk_exit = "exit", Invk_startup = "startup";
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@ public class Xoapi_html implements GfoInvkAble {
|
||||
}
|
||||
public Xoapi_tidy Tidy() {return tidy;} private Xoapi_tidy tidy = new Xoapi_tidy();
|
||||
public Xoapi_modules Modules() {return modules;} private Xoapi_modules modules = new Xoapi_modules();
|
||||
public Xoapi_skins Skins() {return skins;} private Xoapi_skins skins = new Xoapi_skins();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_tidy)) return tidy;
|
||||
else if (ctx.Match(k, Invk_modules)) return modules;
|
||||
else if (ctx.Match(k, Invk_skins)) return skins;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_tidy = "tidy", Invk_modules = "modules";
|
||||
private static final String Invk_tidy = "tidy", Invk_modules = "modules", Invk_skins = "skins";
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.gui.views.*;
|
||||
public class Xoapi_info implements GfoInvkAble {
|
||||
public class Xoapi_info implements Gfo_usr_dlg_ui_opt, GfoInvkAble {
|
||||
public void Init_by_kit(Xoa_app app) {this.app = app;} private Xoa_app app;
|
||||
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
|
||||
public void Focus() {this.Win().Info_box().Focus();}
|
||||
@@ -26,12 +26,21 @@ public class Xoapi_info implements GfoInvkAble {
|
||||
Io_url session_fil = app.Log_wtr().Session_fil();
|
||||
app.Fsys_mgr().App_mgr().App_view_text().Run(session_fil);
|
||||
}
|
||||
public boolean Warn_enabled() {return warn_enabled;} private boolean warn_enabled;
|
||||
public boolean Note_enabled() {return note_enabled;} private boolean note_enabled;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
else if (ctx.Match(k, Invk_launch)) this.Launch();
|
||||
else if (ctx.Match(k, Invk_warn_enabled)) return Yn.Xto_str(warn_enabled);
|
||||
else if (ctx.Match(k, Invk_warn_enabled_)) warn_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_note_enabled)) return Yn.Xto_str(note_enabled);
|
||||
else if (ctx.Match(k, Invk_note_enabled_)) note_enabled = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus", Invk_clear = "clear", Invk_launch = "launch";
|
||||
private static final String Invk_focus = "focus", Invk_clear = "clear", Invk_launch = "launch"
|
||||
, Invk_warn_enabled = "warn_enabled", Invk_warn_enabled_ = "warn_enabled_"
|
||||
, Invk_note_enabled = "note_enabled", Invk_note_enabled_ = "note_enabled_"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xoapi_view implements GfoInvkAble {
|
||||
public void Save_as() {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
Xog_tab_itm tab = win.Tab_mgr().Active_tab();
|
||||
String file_name = app.Url_converter_fsys_safe().Encode_str(String_.new_utf8_(tab.Page().Ttl().Full_url())) + ".html";
|
||||
String file_name = app.Encoder_mgr().Fsys_safe().Encode_str(String_.new_utf8_(tab.Page().Ttl().Full_url())) + ".html";
|
||||
String file_url = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(file_name).Ask();
|
||||
if (String_.Len_eq_0(file_url)) return;
|
||||
Io_mgr._.SaveFilStr(file_url, tab.Html_box().Text());
|
||||
|
||||
35
400_xowa/src/gplx/xowa/apis/xowa/html/Xoapi_skins.java
Normal file
35
400_xowa/src/gplx/xowa/apis/xowa/html/Xoapi_skins.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
import gplx.xowa.apis.xowa.html.skins.*;
|
||||
public class Xoapi_skins implements GfoInvkAble {
|
||||
private HashAdp hash = HashAdp_.new_();
|
||||
public Xoapi_skins() {
|
||||
server.Sidebar_home_enabled_(true);
|
||||
hash.Add("desktop", desktop);
|
||||
hash.Add("server", server);
|
||||
}
|
||||
public Xoapi_skin_app_base Desktop() {return desktop;} private Xoapi_skin_app_base desktop = new Xoapi_skin_app_base();
|
||||
public Xoapi_skin_app_base Server () {return server ;} private Xoapi_skin_app_base server = new Xoapi_skin_app_base();
|
||||
private GfoInvkAble Get(String key) {return (GfoInvkAble)hash.Fetch(key);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get(m.ReadStr("v"));
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_get = "get";
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class Xoapi_collapsible implements GfoInvkAble {
|
||||
}
|
||||
public boolean Collapsed() {return collapsed;} private boolean collapsed;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_collapsed)) return Yn.X_to_str(collapsed);
|
||||
if (ctx.Match(k, Invk_collapsed)) return Yn.Xto_str(collapsed);
|
||||
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Xoapi_navframe implements GfoInvkAble {
|
||||
}
|
||||
public boolean Collapsed() {return collapsed;} private boolean collapsed;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_collapsed)) return Yn.X_to_str(collapsed);
|
||||
if (ctx.Match(k, Invk_collapsed)) return Yn.Xto_str(collapsed);
|
||||
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
|
||||
wiki.Html_mgr().Module_mgr().Popup_mgr().Show_all(popup_id);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(enabled);
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_show_more)) Show_more(m.ReadStr("popup_id"));
|
||||
else if (ctx.Match(k, Invk_show_all)) Show_all (m.ReadStr("popup_id"));
|
||||
@@ -80,7 +80,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
|
||||
else if (ctx.Match(k, Invk_win_max_h_)) {win_max_h = Set_int(m, win_max_h, Evt_win_max_h_changed);}
|
||||
else if (ctx.Match(k, Invk_win_show_all_max_w)) return win_show_all_max_w;
|
||||
else if (ctx.Match(k, Invk_win_show_all_max_w_)) {win_show_all_max_w = m.ReadInt("v");}
|
||||
else if (ctx.Match(k, Invk_win_bind_focus_blur)) return Yn.X_to_str(win_bind_focus_blur);
|
||||
else if (ctx.Match(k, Invk_win_bind_focus_blur)) return Yn.Xto_str(win_bind_focus_blur);
|
||||
else if (ctx.Match(k, Invk_win_bind_focus_blur_)) win_bind_focus_blur = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_xnde_ignore_ids)) return String_.new_utf8_(xnde_ignore_ids);
|
||||
else if (ctx.Match(k, Invk_xnde_ignore_ids_)) {xnde_ignore_ids = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_xnde_ignore_ids_changed, xnde_ignore_ids);}
|
||||
@@ -184,7 +184,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
|
||||
;
|
||||
public static final byte[]
|
||||
Dflt_xnde_ignore_ids = Bry_.new_ascii_("coordinates")
|
||||
, Dflt_tmpl_keeplist = Bry_.new_ascii_("en.wikipedia.org|formatnum;age_in_days;as_of;gregorian_serial_date;currentminute;currentsecond;dmca;spaced_ndash;trim;month*;convert*;worldpop*;ipa*;lang*;nowrap*;h:*;mvar;math;vgy;audio;iso_639_name;transl;translate;linktext;zh;nihongo*;japanese_name;ko-hhrm|\n")
|
||||
, Dflt_tmpl_keeplist = Bry_.new_ascii_("en.wikipedia.org|formatnum;age;age_in_days;age_in_years_and_days*;nts;number_table_sorting*;as_of;gregorian_serial_date;currentminute;currentsecond;dmca;spaced_ndash;trim;month*;convert*;worldpop*;ipa*;lang*;nowrap*;h:*;mvar;math;vgy;audio;iso_639_name;transl;translate;linktext;zh;nihongo*;japanese_name;ko-hhrm|\n")
|
||||
, Dflt_html_fmtr_popup = Bry_.new_ascii_(String_.Concat_lines_nl_skip_last
|
||||
( "<div dir=~{page_lang_ltr}>"
|
||||
, " <div>~{content}"
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Xoapi_toc implements GfoInvkAble {
|
||||
}
|
||||
public boolean Collapsed() {return collapsed;} private boolean collapsed = false;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_collapsed)) return Yn.X_to_str(collapsed);
|
||||
if (ctx.Match(k, Invk_collapsed)) return Yn.Xto_str(collapsed);
|
||||
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -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.apis.xowa.html.skins; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.html.*;
|
||||
public class Xoapi_skin_app_base implements GfoInvkAble {
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
}
|
||||
public boolean Sidebar_home_enabled() {return sidebar_home_enabled;} public void Sidebar_home_enabled_(boolean v) {sidebar_home_enabled = v;} private boolean sidebar_home_enabled;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_sidebar_home_enabled)) return Yn.Xto_str(sidebar_home_enabled);
|
||||
else if (ctx.Match(k, Invk_sidebar_home_enabled_)) sidebar_home_enabled = m.ReadYn("v");
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_sidebar_home_enabled = "sidebar_home_enabled", Invk_sidebar_home_enabled_ = "sidebar_home_enabled_";
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.startup; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
class Xoapi_startup_tabs implements GfoInvkAble {
|
||||
public String[] Calc_startup_strs() {
|
||||
switch (type) {
|
||||
case Xoapi_startup_tabs_type_.Tid_blank: return new String[] {gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str};
|
||||
case Xoapi_startup_tabs_type_.Tid_xowa: return new String[] {gplx.xowa.users.Xouc_pages_mgr.Page_xowa};
|
||||
case Xoapi_startup_tabs_type_.Tid_custom: return String_.SplitLines_nl(custom);
|
||||
case Xoapi_startup_tabs_type_.Tid_previous: return String_.SplitLines_nl(previous);
|
||||
default: throw Err_.unhandled(type);
|
||||
}
|
||||
}
|
||||
public String Custom() {return custom;} private String custom;
|
||||
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
|
||||
public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous = "";
|
||||
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_type_.Tid_xowa;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_type_.X_to_key(type);
|
||||
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_type_.X_to_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_custom)) return custom;
|
||||
else if (ctx.Match(k, Invk_custom_)) custom = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_custom_is_expr)) return Yn.X_to_str(custom_is_expr);
|
||||
else if (ctx.Match(k, Invk_custom_is_expr_)) custom_is_expr = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_type = "type", Invk_type_ = "type_"
|
||||
, Invk_custom = "custom", Invk_custom_ = "custom_"
|
||||
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
|
||||
;
|
||||
}
|
||||
class Xoapi_startup_tabs_type_ {
|
||||
public static final byte Tid_blank = 0, Tid_xowa = 1, Tid_previous = 2, Tid_custom = 3;
|
||||
public static final String Key_blank = "blank", Key_xowa = "xowa", Key_previous = "previous", Key_custom = "custom";
|
||||
public static String X_to_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_blank: return Key_blank;
|
||||
case Tid_xowa: return Key_xowa;
|
||||
case Tid_previous: return Key_previous;
|
||||
case Tid_custom: return Key_custom;
|
||||
default: throw Err_.not_implemented_();
|
||||
}
|
||||
}
|
||||
public static byte X_to_tid(String s) {
|
||||
if (String_.Eq(s, Key_blank)) return Tid_blank;
|
||||
else if (String_.Eq(s, Key_xowa)) return Tid_xowa;
|
||||
else if (String_.Eq(s, Key_previous)) return Tid_previous;
|
||||
else if (String_.Eq(s, Key_custom)) return Tid_custom;
|
||||
else throw Err_.not_implemented_();
|
||||
}
|
||||
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_blank), KeyVal_.new_(Key_xowa), KeyVal_.new_(Key_previous), KeyVal_.new_(Key_custom));
|
||||
}
|
||||
/*
|
||||
startup {
|
||||
tabs {
|
||||
type = 'previous|blank|custom|xowa_home';
|
||||
custom = 'en.wikipedia.org/wiki/{{{MONTHNAME}}} {{{DAY}}';
|
||||
custom_has_wikitext = 'n';
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -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.apis.xowa.startups; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
import gplx.xowa.apis.xowa.startups.tabs.*;
|
||||
public class Xoapi_startups implements GfoInvkAble {
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
}
|
||||
public Xoapi_startup_tabs Tabs() {return tabs;} private Xoapi_startup_tabs tabs = new Xoapi_startup_tabs();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_tabs)) return tabs;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_tabs = "tabs";
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.startups.tabs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.startups.*;
|
||||
public class Xoapi_startup_tabs implements GfoInvkAble {
|
||||
public String Custom() {return custom;} private String custom;
|
||||
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
|
||||
public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous = "";
|
||||
public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual;
|
||||
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_xowa;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type);
|
||||
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_type_list)) return Xoapi_startup_tabs_tid_.Options__list;
|
||||
else if (ctx.Match(k, Invk_previous)) return previous;
|
||||
else if (ctx.Match(k, Invk_previous_)) previous = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_custom)) return custom;
|
||||
else if (ctx.Match(k, Invk_custom_)) custom = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_custom_is_expr)) return Yn.Xto_str(custom_is_expr);
|
||||
else if (ctx.Match(k, Invk_custom_is_expr_)) custom_is_expr = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_type = "type", Invk_type_ = "type_", Invk_type_list = "type_list"
|
||||
, Invk_custom = "custom", Invk_custom_ = "custom_"
|
||||
, Invk_previous = "previous", Invk_previous_ = "previous_"
|
||||
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
|
||||
;
|
||||
public String[] Calc_startup_strs() {
|
||||
if (manual != null) return new String[] {manual};
|
||||
switch (type) {
|
||||
case Xoapi_startup_tabs_tid_.Tid_blank: return new String[] {gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str};
|
||||
case Xoapi_startup_tabs_tid_.Tid_xowa: return new String[] {gplx.xowa.users.Xouc_pages_mgr.Page_xowa};
|
||||
case Xoapi_startup_tabs_tid_.Tid_custom: return String_.SplitLines_nl(String_.Trim(custom));
|
||||
case Xoapi_startup_tabs_tid_.Tid_previous: return String_.SplitLines_nl(String_.Trim(previous));
|
||||
default: throw Err_.unhandled(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.apis.xowa.startups.tabs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.startups.*;
|
||||
public class Xoapi_startup_tabs_tid_ {
|
||||
public static final byte Tid_blank = 0, Tid_xowa = 1, Tid_previous = 2, Tid_custom = 3;
|
||||
public static final String Key_blank = "blank", Key_xowa = "xowa", Key_previous = "previous", Key_custom = "custom";
|
||||
public static String Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_blank: return Key_blank;
|
||||
case Tid_xowa: return Key_xowa;
|
||||
case Tid_previous: return Key_previous;
|
||||
case Tid_custom: return Key_custom;
|
||||
default: throw Err_.not_implemented_();
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(String s) {
|
||||
if (String_.Eq(s, Key_blank)) return Tid_blank;
|
||||
else if (String_.Eq(s, Key_xowa)) return Tid_xowa;
|
||||
else if (String_.Eq(s, Key_previous)) return Tid_previous;
|
||||
else if (String_.Eq(s, Key_custom)) return Tid_custom;
|
||||
else throw Err_.not_implemented_();
|
||||
}
|
||||
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_blank), KeyVal_.new_(Key_xowa), KeyVal_.new_(Key_previous), KeyVal_.new_(Key_custom));
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class Xoapi_bookmarks implements GfoInvkAble {
|
||||
}
|
||||
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Data:Bookmarks");}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(this.Enabled());
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(this.Enabled());
|
||||
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_add)) this.Add(m.ReadStrOr("v", null));
|
||||
else if (ctx.Match(k, Invk_show)) this.Show();
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xoapi_history implements GfoInvkAble {
|
||||
public void Goto_recent() {win.Page__navigate_by_url_bar(app.User().History_mgr().Get_at_last(app));}
|
||||
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaPageHistory");}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(this.Enabled());
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(this.Enabled());
|
||||
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_goto_recent)) this.Goto_recent();
|
||||
else if (ctx.Match(k, Invk_show)) this.Show();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xoapi_logs implements GfoInvkAble {
|
||||
Io_mgr._.DeleteFil_args(app.Log_wtr().Session_fil()).MissingFails_off().Exec();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(this.Enabled());
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(this.Enabled());
|
||||
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
|
||||
public static void Msg_parser_init() {
|
||||
GfsCore._.MsgParser_(gplx.gfs.Gfs_msg_bldr._);
|
||||
}
|
||||
public static byte[] Cfg_save_escape(String v) {return Cfg_save_escape(Bry_.new_ascii_(v));}
|
||||
public static byte[] Cfg_save_escape(String v) {return Cfg_save_escape(Bry_.new_utf8_(v));}
|
||||
public static byte[] Cfg_save_escape(byte[] v) {
|
||||
return Bry_finder.Find_fwd(v, Byte_ascii.Apos) == Bry_.NotFound ? v : Bry_.Replace(v, Bry_apos_1, Bry_apos_2);
|
||||
} static final byte[] Bry_apos_1 = Bry_.new_ascii_("'"), Bry_apos_2 = Bry_.new_ascii_("''");
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Xoa_gfs_php_mgr {
|
||||
)
|
||||
throw Err_.new_("invalid gfs; num_end not found={0}", String_.new_utf8_(src));
|
||||
bfr.Add_byte(Byte_ascii.Dollar);
|
||||
int arg_idx = Bry_.X_to_int_or(src, num_bgn, num_end, -1);
|
||||
int arg_idx = Bry_.Xto_int_or(src, num_bgn, num_end, -1);
|
||||
if (arg_idx == -1) {
|
||||
throw Err_.new_("invalid int");
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class Xoa_gfs_php_mgr {
|
||||
break;
|
||||
case Byte_ascii.Dollar:
|
||||
int end_pos = Php_text_itm_parser.Find_fwd_non_int(raw, i + 1, raw_len);
|
||||
int int_val = Bry_.X_to_int_or(raw, i + 1, end_pos, -1);
|
||||
int int_val = Bry_.Xto_int_or(raw, i + 1, end_pos, -1);
|
||||
bfr.Add_byte(Bry_fmtr.char_escape).Add_byte(Bry_fmtr.char_arg_bgn).Add_int_variable(int_val - 1).Add_byte(Bry_fmtr.char_arg_end);
|
||||
i = end_pos - 1;
|
||||
break;
|
||||
|
||||
@@ -53,6 +53,8 @@ public class Xob_cmd_mgr implements GfoInvkAble {
|
||||
else if (String_.Eq(cmd_key, Xob_xfer_regy_cmd.KEY_oimg)) return Add(new Xob_xfer_regy_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_xfer_regy_update_cmd.KEY_oimg)) return Add(new Xob_xfer_regy_update_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_xfer_update_cmd.KEY_oimg)) return Add(new Xob_xfer_update_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_diff_regy_exec_cmd.KEY_oimg)) return Add(new Xob_diff_regy_exec_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_diff_regy_make_cmd.KEY_oimg)) return Add(new Xob_diff_regy_make_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xof_wiki_orig_cmd.KEY_oimg)) return Add(new Xof_wiki_orig_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_download_wkr.KEY_oimg)) return Add(new Xob_download_wkr(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_page_regy_cmd.KEY_oimg)) return Add(new Xob_page_regy_cmd(bldr, wiki));
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
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.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.dbs.*; import gplx.fsdb.*; import gplx.xowa.bldrs.oimgs.*;
|
||||
public class Xob_diff_regy_exec_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
private Io_url sql_dir;
|
||||
public Xob_diff_regy_exec_cmd(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Cmd_key() {return KEY_oimg;} public static final String KEY_oimg = "file.diff_regy.exec";
|
||||
public void Cmd_ini(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_run() {Exec_main();}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_print() {}
|
||||
private void Exec_main() {
|
||||
if (sql_dir == null)
|
||||
sql_dir = wiki.Ctx().App().Fsys_mgr().File_dir().GenSubDir_nest(wiki.Domain_str(), "tmp_sql");
|
||||
Xob_diff_regy_sql_runner runner = new Xob_diff_regy_sql_runner();
|
||||
Io_url[] urls = Io_mgr._.QueryDir_fils(sql_dir);
|
||||
int urls_len = urls.length;
|
||||
for (int i = 0; i < urls_len; ++i)
|
||||
runner.Exec(app, urls[i]);
|
||||
Xob_diff_regy_sql_runner.Get_provider(wiki, 0, Fsdb_db_tid_.Tid_atr).Exec_sql("VACUUM;");
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_sql_dir_)) sql_dir = m.ReadIoUrl("v");
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
return this;
|
||||
} private static final String Invk_sql_dir_ = "sql_dir_";
|
||||
}
|
||||
class Xob_diff_regy_sql_runner {
|
||||
public Io_url Url() {return url;} private Io_url url;
|
||||
public String Wiki_domain() {return wiki_domain;} private String wiki_domain;
|
||||
public int Fsdb_db_id() {return fsdb_db_id;} private int fsdb_db_id;
|
||||
public byte Fsdb_db_tid() {return fsdb_db_tid;} private byte fsdb_db_tid;
|
||||
public void Exec(Xoa_app app, Io_url url) {
|
||||
Parse_url(url);
|
||||
Run_sql(app);
|
||||
}
|
||||
public void Parse_url(Io_url url) {
|
||||
this.url = url;
|
||||
String[] parts = String_.Split(url.NameOnly(), "-");
|
||||
wiki_domain = parts[0];
|
||||
fsdb_db_id = Int_.parse_(parts[1]);
|
||||
fsdb_db_tid = Fsdb_db_tid_.Xto_tid(parts[2]);
|
||||
}
|
||||
public void Run_sql(Xoa_app app) {
|
||||
Xow_wiki wiki = app.Wiki_mgr().Get_by_key_or_null(Bry_.new_utf8_(wiki_domain));
|
||||
app.Usr_dlg().Prog_many("", "", "running sql: url=~{0}", url.Raw());
|
||||
Db_provider provider = Get_provider(wiki, fsdb_db_id, fsdb_db_tid);
|
||||
provider.Exec_sql(Io_mgr._.LoadFilStr(url));
|
||||
if (fsdb_db_tid == Fsdb_db_tid_.Tid_bin)
|
||||
provider.Exec_sql("VACUUM;");
|
||||
}
|
||||
public static Db_provider Get_provider(Xow_wiki wiki, int fsdb_db_id, byte fsdb_db_tid) {
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki(wiki);
|
||||
Fsdb_db_abc_mgr abc_mgr = wiki.File_mgr().Fsdb_mgr().Mnt_mgr().Abc_mgr_at(0);
|
||||
if (fsdb_db_tid == Fsdb_db_tid_.Tid_bin)
|
||||
return abc_mgr.Bin_mgr().Get_at(fsdb_db_id).Provider();
|
||||
else if (fsdb_db_tid == Fsdb_db_tid_.Tid_atr)
|
||||
return abc_mgr.Atr_mgr().Get_at(0).Provider();
|
||||
else
|
||||
throw Err_.unhandled(fsdb_db_tid);
|
||||
}
|
||||
public static String Build_url(String wiki_domain, int fsdb_db_id, String fsdb_db_type) {
|
||||
return String_.Format("{0}-{1}-{2}.sql", wiki_domain, Int_.XtoStr_PadBgn(fsdb_db_id, 3), fsdb_db_type);
|
||||
}
|
||||
}
|
||||
@@ -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.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import org.junit.*;
|
||||
import gplx.fsdb.*;
|
||||
public class Xob_diff_regy_exec_cmd_tst {
|
||||
private Xob_diff_regy_exec_cmd_fxt fxt = new Xob_diff_regy_exec_cmd_fxt();
|
||||
@Test public void Xto_commons() {
|
||||
fxt.Test_build_url("enwiki", 1, "atr", "enwiki-001-atr.sql");
|
||||
fxt.Test_parse_url("/file/enwiki-001-atr.sql", "enwiki", 1, Fsdb_db_tid_.Tid_atr);
|
||||
}
|
||||
// @Test public void Smoke() {
|
||||
// Xoa_app app = Xoa_app_fxt.app_(Io_url_.new_dir_("C:\\xowa\\"), "wnt");
|
||||
// Xow_wiki wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
// Xob_diff_regy_make_cmd cmd = new Xob_diff_regy_make_cmd(app.Bldr(), wiki);
|
||||
// cmd.Cmd_run();
|
||||
// }
|
||||
}
|
||||
class Xob_diff_regy_exec_cmd_fxt {
|
||||
public void Test_build_url(String wiki_domain, int fsdb_db_id, String fsdb_db_type, String expd) {
|
||||
Tfds.Eq(expd, Xob_diff_regy_sql_runner.Build_url(wiki_domain, fsdb_db_id, fsdb_db_type));
|
||||
}
|
||||
public void Test_parse_url(String raw, String expd_wiki_domain, int expd_fsdb_db_id, byte expd_fsdb_db_tid) {
|
||||
Xob_diff_regy_sql_runner runner = new Xob_diff_regy_sql_runner();
|
||||
runner.Parse_url(Io_url_.new_any_(raw));
|
||||
Tfds.Eq(expd_wiki_domain, runner.Wiki_domain());
|
||||
Tfds.Eq(expd_fsdb_db_id, runner.Fsdb_db_id());
|
||||
Tfds.Eq(expd_fsdb_db_tid, runner.Fsdb_db_tid());
|
||||
}
|
||||
}
|
||||
132
400_xowa/src/gplx/xowa/bldrs/files/Xob_diff_regy_make_cmd.java
Normal file
132
400_xowa/src/gplx/xowa/bldrs/files/Xob_diff_regy_make_cmd.java
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
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.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.dbs.*; import gplx.fsdb.*; import gplx.xowa.bldrs.oimgs.*;
|
||||
public class Xob_diff_regy_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public Xob_diff_regy_make_cmd(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Cmd_key() {return KEY_oimg;} public static final String KEY_oimg = "file.diff_regy.make";
|
||||
public void Cmd_ini(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_run() {Exec_main();}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_print() {}
|
||||
private void Exec_main() {
|
||||
Db_provider make_db_provider = Xodb_db_file.init__file_make(wiki.Fsys_mgr().Root_dir()).Provider();
|
||||
this.Make_join_indexes(make_db_provider);
|
||||
this.Make_diff_regy(make_db_provider);
|
||||
this.Make_delete_sql(make_db_provider);
|
||||
}
|
||||
private void Make_join_indexes(Db_provider make_db_provider) {
|
||||
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_fsdb_regy__join);
|
||||
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_xfer_regy__join);
|
||||
}
|
||||
private void Make_diff_regy(Db_provider make_db_provider) {
|
||||
Sqlite_engine_.Tbl_create_and_delete(make_db_provider, Xob_diff_regy_tbl.Tbl_name, Xob_diff_regy_tbl.Tbl_sql);
|
||||
make_db_provider.Exec_sql(Xob_diff_regy_tbl.Make_diff_regy);
|
||||
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_xfer_regy__join);
|
||||
}
|
||||
private void Make_delete_sql(Db_provider make_db_provider) {
|
||||
DataRdr rdr = make_db_provider.Exec_sql_as_rdr(Xob_diff_regy_tbl.Make_deletes);
|
||||
int cur_db_id = -1, cur_count = 0;
|
||||
Bry_bfr atr_bfr = Bry_bfr.new_(), bin_bfr = Bry_bfr.new_();
|
||||
Io_url sql_tmp_dir = wiki.Ctx().App().Fsys_mgr().File_dir().GenSubDir_nest(wiki.Domain_str(), "tmp_sql");
|
||||
while (rdr.MoveNextPeer()) {
|
||||
byte diff_is_orig = rdr.ReadByte("diff_is_orig");
|
||||
int diff_db_id = rdr.ReadInt("diff_db_id");
|
||||
int diff_fil_id = rdr.ReadInt("diff_fil_id");
|
||||
int diff_thm_id = rdr.ReadInt("diff_thm_id");
|
||||
if (cur_db_id != diff_db_id) {
|
||||
Make_delete_sql_file(atr_bfr, bin_bfr, sql_tmp_dir, cur_db_id, cur_count);
|
||||
cur_db_id = diff_db_id;
|
||||
cur_count = 0;
|
||||
}
|
||||
Make_delete_sql_item(atr_bfr, bin_bfr, diff_is_orig, diff_db_id, diff_fil_id, diff_thm_id);
|
||||
++cur_count;
|
||||
}
|
||||
}
|
||||
private void Make_delete_sql_file(Bry_bfr atr_bfr, Bry_bfr bin_bfr, Io_url sql_tmp_dir, int cur_db_id, int cur_count) {
|
||||
Make_delete_sql_file(atr_bfr, sql_tmp_dir, cur_db_id, cur_count, Fsdb_db_tid_.Tid_atr);
|
||||
Make_delete_sql_file(bin_bfr, sql_tmp_dir, cur_db_id, cur_count, Fsdb_db_tid_.Tid_bin);
|
||||
app.Usr_dlg().Note_many("", "", "file.diff:sql generated: db_id=~{0} count=~{1}", Int_.XtoStr_PadBgn_space(cur_db_id, 3), Int_.XtoStr_PadBgn_space(cur_count, 7));
|
||||
}
|
||||
private void Make_delete_sql_file(Bry_bfr bfr, Io_url sql_dir, int db_id, int cur_count, byte db_tid) {
|
||||
if (db_id != -1 && cur_count > 0) { // do not write 1st bfr
|
||||
bfr.Add_str("COMMIT;\n");
|
||||
String sql_url_name = String_.Format("{0}-{1}-{2}.sql", wiki.Domain_str(), Int_.XtoStr_PadBgn(db_id, 3), Fsdb_db_tid_.Xto_key(db_tid));
|
||||
Io_url sql_url = sql_dir.GenSubFil(sql_url_name);
|
||||
Io_mgr._.SaveFilBfr(sql_url, bfr);
|
||||
}
|
||||
bfr.Clear(); // clear bfr if cur_count == 0
|
||||
bfr.Add_str("BEGIN TRANSACTION;\n");
|
||||
}
|
||||
private void Make_delete_sql_item(Bry_bfr atr_bfr, Bry_bfr bin_bfr, byte diff_is_orig, int diff_db_id, int diff_fil_id, int diff_thm_id) {
|
||||
if (diff_is_orig == Byte_.Zero) {
|
||||
atr_bfr.Add_str("DELETE FROM fsdb_xtn_thm WHERE thm_id = " + Int_.XtoStr(diff_thm_id) + ";\n");
|
||||
bin_bfr.Add_str("DELETE FROM fsdb_bin WHERE bin_owner_id = " + Int_.XtoStr(diff_thm_id) + ";\n");
|
||||
}
|
||||
else {
|
||||
atr_bfr.Add_str("UPDATE fsdb_fil SET fil_bin_db_id = -1 WHERE fil_id = " + Int_.XtoStr(diff_fil_id) + ";\n");
|
||||
bin_bfr.Add_str("DELETE FROM fsdb_bin WHERE bin_owner_id = " + Int_.XtoStr(diff_fil_id) + ";\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
class Xob_diff_regy_tbl {
|
||||
public static final String Tbl_name = "diff_regy";
|
||||
public static final String Tbl_sql = String_.Concat_lines_nl
|
||||
( "CREATE TABLE diff_regy"
|
||||
, "( diff_id integer NOT NULL PRIMARY KEY"
|
||||
, ", diff_is_orig tinyint NOT NULL "
|
||||
, ", diff_status integer NOT NULL"
|
||||
, ", diff_db_id integer NOT NULL"
|
||||
, ", diff_fil_id integer NOT NULL"
|
||||
, ", diff_thm_id integer NOT NULL"
|
||||
, ", diff_name varchar(255) NOT NULL"
|
||||
, ", diff_repo tinyint NOT NULL"
|
||||
, ", diff_w integer NOT NULL"
|
||||
, ", diff_time double NOT NULL"
|
||||
, ", diff_page integer NOT NULL"
|
||||
, ", diff_size bigint NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
public static final Db_idx_itm Idx_fsdb_regy__join = Db_idx_itm.sql_("CREATE INDEX fsdb_regy__join ON fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page);");
|
||||
public static final Db_idx_itm Idx_xfer_regy__join = Db_idx_itm.sql_("CREATE INDEX xfer_regy__join ON xfer_regy (lnki_ttl , file_is_orig, orig_repo, file_w, lnki_time, lnki_page);");
|
||||
public static final Db_idx_itm Idx_diff_regy__load = Db_idx_itm.sql_("CREATE INDEX diff_regy__load ON diff_regy (diff_status, diff_db_id, diff_is_orig, diff_fil_id, diff_thm_id);");
|
||||
public static final String
|
||||
Make_diff_regy = String_.Concat_lines_nl
|
||||
( "INSERT INTO diff_regy "
|
||||
, " (diff_id, diff_is_orig, diff_db_id, diff_fil_id, diff_thm_id, diff_name, diff_repo, diff_w, diff_time, diff_page, diff_size, diff_status)"
|
||||
, "SELECT "
|
||||
, " f.fsdb_id, f.fsdb_is_orig, f.fsdb_db_id, f.fsdb_fil_id, f.fsdb_thm_id, f.fsdb_name, f.fsdb_repo, f.fsdb_w, f.fsdb_time, f.fsdb_page, f.fsdb_size, CASE WHEN x.lnki_ttl IS NULL THEN 0 ELSE 1 END"
|
||||
, "FROM fsdb_regy f"
|
||||
, " LEFT JOIN xfer_regy x "
|
||||
, " ON f.fsdb_name = x.lnki_ttl"
|
||||
, " AND f.fsdb_is_orig = x.file_is_orig"
|
||||
, " AND f.fsdb_repo = x.orig_repo"
|
||||
, " AND f.fsdb_w = x.file_w"
|
||||
, " AND f.fsdb_time = x.lnki_time"
|
||||
, " AND f.fsdb_page = x.lnki_page"
|
||||
, ";"
|
||||
)
|
||||
, Make_deletes = String_.Concat_lines_nl
|
||||
( "SELECT diff_db_id, diff_is_orig, diff_fil_id, diff_thm_id"
|
||||
, "FROM diff_regy"
|
||||
, "WHERE diff_status = 0"
|
||||
, "ORDER BY diff_db_id, diff_is_orig, diff_fil_id, diff_thm_id"
|
||||
)
|
||||
;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
|
||||
Xof_ext ext = Xof_ext_.new_by_ttl_(ttl);
|
||||
double lnki_thumbtime = lnki.Thumbtime();
|
||||
int lnki_page = lnki.Page();
|
||||
byte[] ttl_commons = X_to_commons(wiki_ns_file_is_case_match_all, commons_wiki, ttl);
|
||||
byte[] ttl_commons = Xto_commons(wiki_ns_file_is_case_match_all, commons_wiki, ttl);
|
||||
if ( Xof_doc_page.Null_n(lnki_page) // page set
|
||||
&& Xof_doc_thumb.Null_n(lnki_thumbtime)) // thumbtime set
|
||||
usr_dlg.Warn_many("", "", "page and thumbtime both set; this may be an issue with fsdb: page=~{0} ttl=~{1}", ctx.Cur_page().Ttl().Page_db_as_str(), String_.new_utf8_(ttl));
|
||||
@@ -137,7 +137,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
|
||||
if (property_wkr == null) property_wkr = bldr.App().Wiki_mgr().Wdata_mgr().Property_wkr_or_new();
|
||||
return property_wkr;
|
||||
}
|
||||
public static byte[] X_to_commons(boolean wiki_ns_file_is_case_match_all, Xow_wiki commons_wiki, byte[] ttl_bry) {
|
||||
public static byte[] Xto_commons(boolean wiki_ns_file_is_case_match_all, Xow_wiki commons_wiki, byte[] ttl_bry) {
|
||||
if (!wiki_ns_file_is_case_match_all) return null; // return "" if wiki matches common
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(commons_wiki, Xow_ns_.Id_file, ttl_bry);
|
||||
byte[] rv = ttl.Page_db();
|
||||
|
||||
@@ -19,27 +19,27 @@ package gplx.xowa.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import org.junit.*;
|
||||
public class Xob_lnki_temp_wkr_tst {
|
||||
private Xob_lnki_temp_wkr_fxt fxt = new Xob_lnki_temp_wkr_fxt();
|
||||
@Test public void X_to_commons() {
|
||||
fxt.Init_X_to_commons(true);
|
||||
fxt.Test_X_to_commons("a", "A");
|
||||
fxt.Test_X_to_commons("A", null);
|
||||
@Test public void Xto_commons() {
|
||||
fxt.Init_Xto_commons(true);
|
||||
fxt.Test_Xto_commons("a", "A");
|
||||
fxt.Test_Xto_commons("A", null);
|
||||
|
||||
fxt.Init_X_to_commons(false);
|
||||
fxt.Test_X_to_commons("a", null);
|
||||
fxt.Test_X_to_commons("A", null);
|
||||
fxt.Init_Xto_commons(false);
|
||||
fxt.Test_Xto_commons("a", null);
|
||||
fxt.Test_Xto_commons("A", null);
|
||||
}
|
||||
}
|
||||
class Xob_lnki_temp_wkr_fxt {
|
||||
private boolean wiki_ns_file_is_case_match_all;
|
||||
private Xow_wiki commons_wiki;
|
||||
public Xob_lnki_temp_wkr_fxt Init_X_to_commons(boolean wiki_ns_file_is_case_match_all) {
|
||||
public Xob_lnki_temp_wkr_fxt Init_Xto_commons(boolean wiki_ns_file_is_case_match_all) {
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
this.wiki_ns_file_is_case_match_all = wiki_ns_file_is_case_match_all;
|
||||
this.commons_wiki = Xoa_app_fxt.wiki_tst_(app); // commons_wiki will default to Xow_ns.Id_file of case_match_1st
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Test_X_to_commons(String ttl, String expd) {
|
||||
Tfds.Eq(expd, String_.new_utf8_(Xob_lnki_temp_wkr.X_to_commons(wiki_ns_file_is_case_match_all, commons_wiki, Bry_.new_utf8_(ttl))));
|
||||
public void Test_Xto_commons(String ttl, String expd) {
|
||||
Tfds.Eq(expd, String_.new_utf8_(Xob_lnki_temp_wkr.Xto_commons(wiki_ns_file_is_case_match_all, commons_wiki, Bry_.new_utf8_(ttl))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.bldrs.oimgs.*;
|
||||
class Xob_page_regy_tbl {
|
||||
public static void Reset_table(Db_provider p) {Sqlite_engine_.Tbl_create_and_delete(p, Tbl_name, Tbl_sql);}
|
||||
public static void Create_data(Gfo_usr_dlg usr_dlg, Db_provider p, byte repo_tid, Xow_wiki wiki) {
|
||||
Create_data__insert_page(usr_dlg, p, repo_tid, wiki.Db_mgr_as_sql().Fsys_mgr().Get_url(Xodb_file.Tid_core));
|
||||
Create_data__insert_page(usr_dlg, p, repo_tid, wiki.Db_mgr_as_sql().Fsys_mgr().Get_url(Xodb_file_tid_.Tid_core));
|
||||
Create_data__insert_redirect(usr_dlg, p, repo_tid, wiki.Fsys_mgr().Root_dir().GenSubFil(Xodb_db_file.Name__wiki_redirect));
|
||||
}
|
||||
public static void Delete_local(Db_provider p) {
|
||||
|
||||
@@ -71,12 +71,14 @@ class Xob_fsdb_regy_tbl {
|
||||
, ", fsdb_db_id integer NOT NULL"
|
||||
, ", fsdb_size bigint NOT NULL"
|
||||
, ", fsdb_status tinyint NOT NULL"
|
||||
, ", fsdb_fil_id integer NOT NULL"
|
||||
, ", fsdb_thm_id integer NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
public static final Db_idx_itm Idx_main = Db_idx_itm.sql_("CREATE INDEX fsdb_regy__main ON fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page);");
|
||||
public static final String
|
||||
Insert_fsdb_fil = String_.Concat_lines_nl
|
||||
( "INSERT INTO fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page, fsdb_db_id, fsdb_size, fsdb_status)"
|
||||
( "INSERT INTO fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page, fsdb_db_id, fsdb_size, fsdb_status, fsdb_fil_id, fsdb_thm_id)"
|
||||
, "SELECT f.fil_name"
|
||||
, ", 1"
|
||||
, ", CASE WHEN d.dir_name = 'commons.wikimedia.org' THEN 0 ELSE 1 END"
|
||||
@@ -86,13 +88,15 @@ class Xob_fsdb_regy_tbl {
|
||||
, ", f.fil_bin_db_id"
|
||||
, ", f.fil_size"
|
||||
, ", 0"
|
||||
, ", f.fil_id"
|
||||
, ", -1"
|
||||
, "FROM fsdb_db.fsdb_fil f"
|
||||
, " JOIN fsdb_db.fsdb_dir d ON f.fil_owner_id = d.dir_id"
|
||||
, "WHERE f.fil_bin_db_id != -1"
|
||||
, ";"
|
||||
)
|
||||
, Insert_fsdb_thm = String_.Concat_lines_nl
|
||||
( "INSERT INTO fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page, fsdb_db_id, fsdb_size, fsdb_status)"
|
||||
( "INSERT INTO fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page, fsdb_db_id, fsdb_size, fsdb_status, fsdb_fil_id, fsdb_thm_id)"
|
||||
, "SELECT f.fil_name"
|
||||
, ", 0"
|
||||
, ", CASE WHEN d.dir_name = 'commons.wikimedia.org' THEN 0 ELSE 1 END"
|
||||
@@ -102,13 +106,15 @@ class Xob_fsdb_regy_tbl {
|
||||
, ", t.thm_bin_db_id"
|
||||
, ", t.thm_size"
|
||||
, ", 0"
|
||||
, ", f.fil_id"
|
||||
, ", t.thm_id"
|
||||
, "FROM fsdb_db.fsdb_fil f"
|
||||
, " JOIN fsdb_db.fsdb_xtn_thm t ON f.fil_id = t.thm_owner_id"
|
||||
, " JOIN fsdb_db.fsdb_dir d ON f.fil_owner_id = d.dir_id"
|
||||
, ";"
|
||||
)
|
||||
, Insert_fsdb_thm_v0 = String_.Concat_lines_nl
|
||||
( "INSERT INTO fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page, fsdb_db_id, fsdb_size, fsdb_status)"
|
||||
( "INSERT INTO fsdb_regy (fsdb_name, fsdb_is_orig, fsdb_repo, fsdb_w, fsdb_time, fsdb_page, fsdb_db_id, fsdb_size, fsdb_status, fsdb_fil_id, fsdb_thm_id)"
|
||||
, "SELECT f.fil_name"
|
||||
, ", 0"
|
||||
, ", CASE WHEN d.dir_name = 'commons.wikimedia.org' THEN 0 ELSE 1 END"
|
||||
@@ -118,6 +124,8 @@ class Xob_fsdb_regy_tbl {
|
||||
, ", t.thm_bin_db_id"
|
||||
, ", t.thm_size"
|
||||
, ", 0"
|
||||
, ", f.fil_id"
|
||||
, ", t.thm_id"
|
||||
, "FROM fsdb_db.fsdb_fil f"
|
||||
, " JOIN fsdb_db.fsdb_xtn_thm t ON f.fil_id = t.thm_owner_id"
|
||||
, " JOIN fsdb_db.fsdb_dir d ON f.fil_owner_id = d.dir_id"
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xob_import_cfg {
|
||||
Xoa_app app = wiki.App();
|
||||
if (app.Setup_mgr().Dump_mgr().Import_bz2_by_stdout()) {
|
||||
ProcessAdp process = app.Fsys_mgr().App_mgr().App_decompress_bz2_by_stdout();
|
||||
return Io_stream_rdr_process.new_(process.Exe_url(), src_fil_bz2, process.X_to_process_bldr_args(src_fil_bz2.Raw()));
|
||||
return Io_stream_rdr_process.new_(process.Exe_url(), src_fil_bz2, process.Xto_process_bldr_args(src_fil_bz2.Raw()));
|
||||
}
|
||||
else
|
||||
return gplx.ios.Io_stream_rdr_.bzip2_(src_fil_bz2);
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Xob_page_sql extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
|
||||
db_mgr.Tbl_xowa_ns().Insert(ns_mgr); // save ns
|
||||
db_mgr.Tbl_xowa_db().Commit_all(page_provider, db_mgr.Fsys_mgr().Ary()); // save dbs; note that dbs can be saved again later
|
||||
db_mgr.Tbl_xowa_cfg().Insert_str(Xodb_mgr_sql.Grp_wiki_init, "props.modified_latest", modified_latest.XtoStr_fmt(DateAdp_.Fmt_iso8561_date_time));
|
||||
fsys_mgr.Index_create(usr_dlg, Byte_.Ary(Xodb_file.Tid_core, Xodb_file.Tid_text), Xodb_file.Indexes_page_title, Xodb_file.Indexes_page_random);
|
||||
fsys_mgr.Index_create(usr_dlg, Byte_.Ary(Xodb_file_tid_.Tid_core, Xodb_file_tid_.Tid_text), Index_page_title, Index_page_random);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_txn_commit_interval_)) txn_commit_interval = m.ReadInt("v");
|
||||
@@ -85,6 +85,10 @@ public class Xob_page_sql extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
|
||||
} private static final String Invk_txn_commit_interval_ = "txn_commit_interval_";
|
||||
public void Wkr_ini(Xob_bldr bldr) {}
|
||||
public void Wkr_print() {}
|
||||
private static final Db_idx_itm
|
||||
Index_page_title = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__title ON page (page_namespace, page_title, page_id, page_len, page_is_redirect);") // PERF:page_id for general queries; PERF: page_len for search_suggest; PREF:page_is_redirect for oimg
|
||||
, Index_page_random = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__name_random ON page (page_namespace, page_random_int);")
|
||||
;
|
||||
}
|
||||
class Xob_text_stmts_mgr {
|
||||
public Xob_text_stmts_mgr(Xodb_mgr_sql db_mgr, Xodb_fsys_mgr fsys_mgr) {this.db_mgr = db_mgr; this.fsys_mgr = fsys_mgr;} private Xodb_mgr_sql db_mgr; Xodb_fsys_mgr fsys_mgr;
|
||||
@@ -116,12 +120,12 @@ class Xob_text_stmts_mgr {
|
||||
Xodb_file File_get(int file_idx, int text_len) {
|
||||
if (file_idx == Xow_ns.Bldr_file_idx_heap) {
|
||||
file_idx = fsys_mgr.Tid_text_idx();
|
||||
Xodb_file file = fsys_mgr.Get_or_make(Xodb_file.Tid_text, file_idx);
|
||||
Xodb_file file = fsys_mgr.Get_or_make(Xodb_file_tid_.Tid_text, file_idx);
|
||||
long file_len = file.File_len();
|
||||
long file_max = fsys_mgr.Tid_text_max();
|
||||
if (file_max != Xodb_fsys_mgr.Heap_max_infinite && (file_len + text_len > file_max)) { // file is "full"
|
||||
file.Provider().Txn_mgr().Txn_end_all(); // close txn
|
||||
file = fsys_mgr.Make(Xodb_file.Tid_text);
|
||||
file = fsys_mgr.Make(Xodb_file_tid_.Tid_text);
|
||||
file_idx = file.Id();
|
||||
fsys_mgr.Tid_text_idx_(file_idx);
|
||||
}
|
||||
@@ -129,7 +133,7 @@ class Xob_text_stmts_mgr {
|
||||
return file;
|
||||
}
|
||||
else
|
||||
return fsys_mgr.Get_or_make(Xodb_file.Tid_text, file_idx);
|
||||
return fsys_mgr.Get_or_make(Xodb_file_tid_.Tid_text, file_idx);
|
||||
}
|
||||
private void Add(Db_stmt stmt, int stmt_idx) {
|
||||
int new_len = stmt_idx + 1;
|
||||
|
||||
@@ -30,12 +30,12 @@ public class Xob_search_sql_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
if (!Env_.Mode_testing()) wiki.Init_assert();
|
||||
Xodb_fsys_mgr db_fs = wiki.Db_mgr_as_sql().Fsys_mgr();
|
||||
usr_dlg.Log_many("", "", "search_title.cmd: getting core db");
|
||||
Xodb_file page_db = db_fs.Get_tid_root(Xodb_file.Tid_core);
|
||||
Xodb_file page_db = db_fs.Get_tid_root(Xodb_file_tid_.Tid_core);
|
||||
usr_dlg.Log_many("", "", "search_title.cmd: getting existing searchdb");
|
||||
Xodb_file search_db = db_fs.Get_tid_root(Xodb_file.Tid_search);
|
||||
Xodb_file search_db = db_fs.Get_tid_root(Xodb_file_tid_.Tid_search);
|
||||
if (search_db == null) {
|
||||
usr_dlg.Log_many("", "", "search_title.cmd: making new searchdb");
|
||||
search_db = db_fs.Make(Xodb_file.Tid_search);
|
||||
search_db = db_fs.Make(Xodb_file_tid_.Tid_search);
|
||||
}
|
||||
DataRdr page_rdr = DataRdr_.Null;
|
||||
Db_provider search_provider = search_db.Provider();
|
||||
|
||||
@@ -25,9 +25,9 @@ public class Xob_search_sql_wkr extends Xob_search_base implements Io_make_cmd {
|
||||
public void Sort_bgn() {
|
||||
db_mgr = wiki.Db_mgr_as_sql();
|
||||
boolean created = false;
|
||||
Xodb_file search_db = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file.Tid_search);
|
||||
Xodb_file search_db = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file_tid_.Tid_search);
|
||||
if (search_db == null) {
|
||||
search_db = db_mgr.Fsys_mgr().Make(Xodb_file.Tid_search);
|
||||
search_db = db_mgr.Fsys_mgr().Make(Xodb_file_tid_.Tid_search);
|
||||
created = true;
|
||||
}
|
||||
provider = search_db.Provider();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Xobc_core_calc_stats extends Xob_itm_basic_base implements Xob_cmd
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i != 0) bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space);
|
||||
Object val = vals[i];
|
||||
bfr.Add_str(Object_.XtoStr_OrNullStr(val));
|
||||
bfr.Add_str(Object_.Xto_str_strict_or_null_mark(val));
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Paren_end);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implement
|
||||
parser.Fld_cmd_(this).Flds_req_(Fld_cl_from, Fld_cl_to, Fld_cl_timestamp, Fld_cl_collation, Fld_cl_sortkey, Fld_cl_type);
|
||||
} static final byte[] Fld_cl_from = Bry_.new_ascii_("cl_from"), Fld_cl_to = Bry_.new_ascii_("cl_to"), Fld_cl_timestamp = Bry_.new_ascii_("cl_timestamp"), Fld_cl_collation = Bry_.new_ascii_("cl_collation"), Fld_cl_sortkey = Bry_.new_ascii_("cl_sortkey"), Fld_cl_type = Bry_.new_ascii_("cl_type");
|
||||
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
|
||||
if (Bry_.Eq(fld_key, Fld_cl_from)) cur_id = Bry_.X_to_int_or(src, fld_bgn, fld_end, -1);
|
||||
if (Bry_.Eq(fld_key, Fld_cl_from)) cur_id = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1);
|
||||
else if (Bry_.Eq(fld_key, Fld_cl_to)) cur_ctg = Bry_.Mid(src, fld_bgn, fld_end);
|
||||
else if (Bry_.Eq(fld_key, Fld_cl_collation)) cur_collation_is_uca = Bry_.HasAtBgn(src, Collation_uca, fld_bgn, fld_end);
|
||||
else if (Bry_.Eq(fld_key, Fld_cl_timestamp)) {
|
||||
|
||||
@@ -26,11 +26,11 @@ public class Xob_categorylinks_sql_make implements Io_make_cmd {
|
||||
name_id_rdr = New_registry_rdr(wiki, usr_dlg);
|
||||
cur_cat_file_max = wiki.App().Setup_mgr().Dump_mgr().Db_categorylinks_max();
|
||||
|
||||
db_mgr.Delete_by_tid(Xodb_file.Tid_category);
|
||||
db_mgr.Delete_by_tid(Xodb_file_tid_.Tid_category);
|
||||
Xodb_fsys_mgr fsys_mgr = db_mgr.Fsys_mgr();
|
||||
Xodb_file category_file = fsys_mgr.Get_tid_root(Xodb_file.Tid_core);
|
||||
Xodb_file category_file = fsys_mgr.Get_tid_root(Xodb_file_tid_.Tid_core);
|
||||
if (cur_cat_file_max > 0) {
|
||||
category_file = fsys_mgr.Make(Xodb_file.Tid_category);
|
||||
category_file = fsys_mgr.Make(Xodb_file_tid_.Tid_category);
|
||||
fsys_mgr.Init_by_tid_category(category_file);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Xob_categorylinks_sql_make implements Io_make_cmd {
|
||||
db_mgr.Category_version_update(false);
|
||||
cat_provider.Txn_mgr().Txn_end_all();
|
||||
ctg_stmt.Rls();
|
||||
fsys_mgr.Index_create(usr_dlg, Byte_.Ary(Xodb_file.Tid_core, Xodb_file.Tid_category), Xodb_file.Indexes_categorylinks_from, Xodb_file.Indexes_categorylinks_main);
|
||||
fsys_mgr.Index_create(usr_dlg, Byte_.Ary(Xodb_file_tid_.Tid_core, Xodb_file_tid_.Tid_category), Index_categorylinks_from, Index_categorylinks_main);
|
||||
name_id_rdr.Rls();
|
||||
if (String_.Eq(sql_parser.Src_fil().NameAndExt(), Xob_ctg_v1_sql_make.Url_sql)) // delete temp xowa_categorylinks.sql file created by cat_v1
|
||||
Io_mgr._.DeleteFil(sql_parser.Src_fil());
|
||||
@@ -79,7 +79,7 @@ public class Xob_categorylinks_sql_make implements Io_make_cmd {
|
||||
if (cur_cat_ttl != Bry_.Empty && cur_cat_id != -1)
|
||||
db_mgr.Tbl_category().Insert(ctg_stmt, cur_cat_id, cur_cat_counts[Xoa_ctg_mgr.Tid_page], cur_cat_counts[Xoa_ctg_mgr.Tid_subc], cur_cat_counts[Xoa_ctg_mgr.Tid_file], Xoa_ctg_mgr.Hidden_n, cur_cat_file_idx);
|
||||
if (new_ctg_ttl == Ttl_last) return Cur_cat_id_null; // last ttl; called by this.End(); exit early else will fail in Cur_cat_id_find()
|
||||
if (cur_cat_file_max > 0 && cur_cat_file_size > cur_cat_file_max) {File_close(); File_open(db_mgr.Fsys_mgr().Make(Xodb_file.Tid_category));}
|
||||
if (cur_cat_file_max > 0 && cur_cat_file_size > cur_cat_file_max) {File_close(); File_open(db_mgr.Fsys_mgr().Make(Xodb_file_tid_.Tid_category));}
|
||||
cur_cat_id = Cur_cat_id_find(new_ctg_ttl);
|
||||
for (int i = 0; i < Xoa_ctg_mgr.Tid__max; i++)
|
||||
cur_cat_counts[i] = 0;
|
||||
@@ -130,6 +130,10 @@ public class Xob_categorylinks_sql_make implements Io_make_cmd {
|
||||
return new Io_line_rdr(usr_dlg, urls).Key_gen_(Io_line_rdr_key_gen_.first_pipe);
|
||||
} Io_line_rdr name_id_rdr;
|
||||
private static final byte[] Ttl_last = null, Ttl_first = Bry_.Empty;
|
||||
private static final Db_idx_itm
|
||||
Index_categorylinks_main = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS categorylinks__cl_main ON categorylinks (cl_to_id, cl_type_id, cl_sortkey, cl_from);")
|
||||
, Index_categorylinks_from = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS categorylinks__cl_from ON categorylinks (cl_from);")
|
||||
;
|
||||
}
|
||||
/*
|
||||
NOTE_1: categorylinks row size: 34 + 20 + 12 + (ctg_sortkey.length * 2)
|
||||
|
||||
@@ -115,8 +115,8 @@ class Db_tst_qry {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Db_tst_val expd_val = expd_vals[i];
|
||||
String expd_key = expd_val.Key();
|
||||
String expd_str = Object_.XtoStr_OrEmpty(expd_val.Val());
|
||||
String actl_str = Object_.XtoStr_OrEmpty(rdr.Read(expd_key));
|
||||
String expd_str = Object_.Xto_str_strict_or_empty(expd_val.Val());
|
||||
String actl_str = Object_.Xto_str_strict_or_empty(rdr.Read(expd_key));
|
||||
boolean eq = String_.Eq(expd_str, actl_str); // NOTE: always compare strings, not objs; problems with comparing byte to int
|
||||
bfr.Add_str_pad_space_end(expd_key, pad_max);
|
||||
bfr.Add_str_pad_space_bgn(expd_str, pad_max);
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class Xoctg_hiddencat_parser_base extends Xob_sql_dump_base impl
|
||||
}
|
||||
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
|
||||
switch (fld_idx) {
|
||||
case Fld_id: cur_id = Bry_.X_to_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_id: cur_id = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_key: cur_is_hiddencat = Bry_.Eq(Key_hiddencat, src, fld_bgn, fld_end); break;
|
||||
case Fld_val:
|
||||
if (!cur_is_hiddencat) {data.Cancel_row_y_(); return;}
|
||||
|
||||
52
400_xowa/src/gplx/xowa/bldrs/langs/Xob_lang_json_parser.java
Normal file
52
400_xowa/src/gplx/xowa/bldrs/langs/Xob_lang_json_parser.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.json.*; import gplx.gfs.*;
|
||||
public class Xob_lang_json_parser {
|
||||
private Json_parser json_parser = new Json_parser();
|
||||
private Gfs_bldr gfs_bldr = new Gfs_bldr();
|
||||
private Xol_csv_parser csv_parser = Xol_csv_parser._;
|
||||
public Xob_lang_json_parser() {}
|
||||
public byte[] Parse(byte[] raw) {
|
||||
Json_doc jdoc = json_parser.Parse(raw);
|
||||
Json_itm_nde jnde = jdoc.Root();
|
||||
gfs_bldr.Add_proc_init_many("this", "messages", "load_text").Add_paren_bgn().Add_nl();
|
||||
gfs_bldr.Add_quote_xtn_bgn();
|
||||
int subs_len = jnde.Subs_len();
|
||||
Bry_bfr bfr = gfs_bldr.Bfr();
|
||||
for (int i = 0; i < subs_len; ++i)
|
||||
Parse_sub(bfr, raw, jnde.Subs_get_at(i));
|
||||
gfs_bldr.Add_quote_xtn_end().Add_paren_end().Add_term_nl();
|
||||
return gfs_bldr.Xto_bry();
|
||||
}
|
||||
private void Parse_sub(Bry_bfr bfr, byte[] raw, Json_itm itm) {
|
||||
switch (itm.Tid()) {
|
||||
case Json_itm_.Tid_kv:
|
||||
Json_itm_kv kv = (Json_itm_kv)itm;
|
||||
if (kv.Key().Data_eq(Name_metadata)) return; // ignore @metadata node
|
||||
byte[] key_bry = kv.Key().Data_bry();
|
||||
byte[] val_bry = kv.Val().Data_bry();
|
||||
csv_parser.Save(bfr, key_bry); // key
|
||||
bfr.Add_byte_pipe(); // |
|
||||
csv_parser.Save(bfr, val_bry); // val
|
||||
bfr.Add_byte_nl(); // \n
|
||||
break;
|
||||
}
|
||||
}
|
||||
private static final byte[] Name_metadata = Bry_.new_ascii_("@metadata");
|
||||
}
|
||||
@@ -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.bldrs.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import org.junit.*;
|
||||
import gplx.intl.*;
|
||||
public class Xob_lang_json_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xob_lang_json_parser_fxt fxt = new Xob_lang_json_parser_fxt();
|
||||
@Test public void Core_keywords() {
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "{"
|
||||
, " \"@metadata\": {"
|
||||
, " \"authors\": []"
|
||||
, " },"
|
||||
, "\"key_1\": \"val_1\","
|
||||
, "\"key_2\": \"val_2\","
|
||||
, "}"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "this.messages.load_text("
|
||||
, "<:['"
|
||||
, "key_1|val_1"
|
||||
, "key_2|val_2"
|
||||
, "']:>"
|
||||
, ");"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xob_lang_json_parser_fxt {
|
||||
private Xob_lang_json_parser parser = new Xob_lang_json_parser();
|
||||
public void Clear() {
|
||||
}
|
||||
public void Test_parse(String raw, String expd) {
|
||||
byte[] actl = parser.Parse(Bry_.new_utf8_(raw));
|
||||
Tfds.Eq_str_lines(expd, String_.new_utf8_(actl));
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class Xobc_utl_make_lang_kwds implements GfoInvkAble, Xol_lang_transform
|
||||
tmp.Clear();
|
||||
if (kwd_grp == null) {
|
||||
kwd_grp = lang.Kwd_mgr().Get_or_new(kwd_id);
|
||||
kwd_grp.Srl_load(false, Bry_.Ary_empty); // ASSUME: kwd explicitly added, but does not exist in language; default to !case_match
|
||||
kwd_grp.Srl_load(Bool_.N, Bry_.Ary_empty); // ASSUME: kwd explicitly added, but does not exist in language; default to !case_match
|
||||
}
|
||||
|
||||
for (Xol_kwd_itm itm : kwd_grp.Itms())
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Xol_mw_lang_parser {
|
||||
if (lang.Fallback_bry() != null) // NOTE: fallback will often be null; EX: en
|
||||
bldr.Add_proc_cont_one(Xol_lang.Invk_fallback_load).Add_parens_str(lang.Fallback_bry()).Add_nl();
|
||||
if (!lang.Dir_ltr()) // NOTE: only save dir_ltr if false; EX: en
|
||||
bldr.Add_proc_cont_one(Xol_lang.Invk_dir_rtl_).Add_parens_str(Yn.X_to_str(!lang.Dir_ltr())).Add_nl();
|
||||
bldr.Add_proc_cont_one(Xol_lang.Invk_dir_rtl_).Add_parens_str(Yn.Xto_str(!lang.Dir_ltr())).Add_nl();
|
||||
Xol_lang_srl.Save_ns_grps(bldr, lang.Ns_names(), Xol_lang.Invk_ns_names);
|
||||
Xol_lang_srl.Save_ns_grps(bldr, lang.Ns_aliases(), Xol_lang.Invk_ns_aliases);
|
||||
Xol_lang_srl.Save_specials(bldr, lang.Specials_mgr());
|
||||
|
||||
@@ -41,7 +41,7 @@ class Xob_dump_src_ttl implements Xob_parse_all_db {
|
||||
if (len == 1) return new Xodb_file[] {file_ary[0]}; // single file: return core; note that there are no Tid = Text
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_file file = file_ary[i];
|
||||
if (file.Tid() == Xodb_file.Tid_text)
|
||||
if (file.Tid() == Xodb_file_tid_.Tid_text)
|
||||
text_files_list.Add(file);
|
||||
}
|
||||
return (Xodb_file[])text_files_list.XtoAryAndClear(Xodb_file.class);
|
||||
@@ -54,7 +54,7 @@ class Xob_dump_src_id {
|
||||
public Xob_dump_src_id Init(Xow_wiki wiki, byte redirect, int size_max) {
|
||||
this.db_mgr = wiki.Db_mgr_as_sql(); this.redirect = redirect;
|
||||
this.size_max = size_max;
|
||||
page_db_url = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file.Tid_core).Url().Raw();
|
||||
page_db_url = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file_tid_.Tid_core).Url().Raw();
|
||||
return this;
|
||||
}
|
||||
public void Get_pages(ListAdp list, int text_db_idx, int cur_ns, int prv_id) {
|
||||
|
||||
@@ -27,12 +27,12 @@ public class Xob_text_db_prep extends Xob_itm_basic_base implements Xob_cmd {
|
||||
}
|
||||
public void Cmd_run() {
|
||||
Xodb_fsys_mgr db_fsys_mgr = wiki.Db_mgr_as_sql().Fsys_mgr();
|
||||
String page_db_url = db_fsys_mgr.Get_tid_root(Xodb_file.Tid_core).Url().Raw();
|
||||
String page_db_url = db_fsys_mgr.Get_tid_root(Xodb_file_tid_.Tid_core).Url().Raw();
|
||||
db_files = db_fsys_mgr.Ary();
|
||||
int len = db_files.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_file db_file = db_files[i];
|
||||
if (db_file.Tid() == Xodb_file.Tid_text)
|
||||
if (db_file.Tid() == Xodb_file_tid_.Tid_text)
|
||||
Prep_db(page_db_url, db_file);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class Xob_text_db_prep extends Xob_itm_basic_base implements Xob_cmd {
|
||||
int len = db_files.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_file db_file = db_files[i];
|
||||
if (db_file.Tid() == Xodb_file.Tid_text)
|
||||
if (db_file.Tid() == Xodb_file_tid_.Tid_text)
|
||||
db_file.Rls();
|
||||
}
|
||||
db_files = null;
|
||||
|
||||
@@ -71,13 +71,13 @@ class Xoi_wiki_props_fxt {
|
||||
public void Test_parse(String xml, Xoi_wiki_props_wiki expd) {
|
||||
Xoi_wiki_props_wiki actl = new Xoi_wiki_props_wiki();
|
||||
api.Parse(actl, xml);
|
||||
Tfds.Eq_str_lines(X_to_str(expd), X_to_str(actl));
|
||||
Tfds.Eq_str_lines(Xto_str(expd), Xto_str(actl));
|
||||
}
|
||||
public void Test_build(Xoi_wiki_props_wiki wiki, String expd) {
|
||||
api.Build_cfg(bfr, wiki);
|
||||
Tfds.Eq_str_lines(expd, bfr.XtoStrAndClear());
|
||||
}
|
||||
private String X_to_str(Xoi_wiki_props_wiki v) {
|
||||
private String Xto_str(Xoi_wiki_props_wiki v) {
|
||||
int len = v.Alias_ary().length;
|
||||
bfr.Add_str("aliases").Add_byte_nl();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
@@ -50,10 +50,10 @@ public class Xob_wiki_image_sql extends Xob_itm_dump_base implements Xob_cmd, Gf
|
||||
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
|
||||
switch (fld_idx) {
|
||||
case Fld_img_name: cur_ttl = Bry_.Mid(src, fld_bgn, fld_end); break;
|
||||
case Fld_img_size: cur_size = Bry_.X_to_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_width: cur_width = Bry_.X_to_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_height: cur_height = Bry_.X_to_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_bits: cur_bits = Bry_.X_to_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_size: cur_size = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_width: cur_width = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_height: cur_height = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_bits: cur_bits = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_media_type: cur_media_type = Bry_.Mid(src, fld_bgn, fld_end); break;
|
||||
case Fld_img_minor_mime: cur_minor_mime = Bry_.Mid(src, fld_bgn, fld_end);
|
||||
cur_ext_id = Calc_ext_id(show_issues ? app.Usr_dlg() : Gfo_usr_dlg_.Null, cur_ttl, cur_media_type, cur_minor_mime, cur_width, cur_height);
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Xob_wiki_redirect_cmd extends Xob_dump_mgr_base {
|
||||
this.db_mgr = wiki.Db_mgr_as_sql();
|
||||
Xoa_app app = bldr.App();
|
||||
redirect_mgr = wiki.Redirect_mgr();
|
||||
encoder = app.Url_converter_url_ttl();
|
||||
encoder = app.Encoder_mgr().Url_ttl();
|
||||
// app.Usr_dlg().Prog_none("", "", "dropping index: page__title");
|
||||
// db_mgr.Fsys_mgr().Core_provider().Exec_sql("DROP INDEX IF EXISTS page__title");
|
||||
// Sqlite_engine_.Idx_create(app.Usr_dlg(), db_mgr.Fsys_mgr().Core_provider(), "page", Idx_page_title);
|
||||
@@ -57,7 +57,7 @@ public class Xob_wiki_redirect_cmd extends Xob_dump_mgr_base {
|
||||
@Override public void Exec_end_hook() {
|
||||
provider.Txn_mgr().Txn_end_all();
|
||||
tbl_redirect.Create_indexes(usr_dlg, provider);
|
||||
tbl_redirect.Update_redirects(provider, db_mgr.Fsys_mgr().Get_url(Xodb_file.Tid_core), 4);
|
||||
tbl_redirect.Update_redirects(provider, db_mgr.Fsys_mgr().Get_url(Xodb_file_tid_.Tid_core), 4);
|
||||
}
|
||||
// private static final Db_idx_itm Idx_page_title = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__title ON page (page_namespace, page_title, page_id, page_len, page_is_redirect, page_file_idx);"); // PERF:page_id for general queries; PERF: page_len for search_suggest
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Xob_xml_parser {
|
||||
case Xob_xml_parser_.Id_id_bgn: if (page_id_needed) data_bgn = pos; break; // only flag if first <id>; note that 1st <id> always belongs to <page>;
|
||||
case Xob_xml_parser_.Id_id_end:
|
||||
if (page_id_needed) {
|
||||
int page_id = Bry_.X_to_int_or(src, data_bgn, hook_bgn, -1); if (page_id == -1) usr_dlg.Warn_many(GRP_KEY, "page_id_invalid", "page_id_is_invalid: ~{0}", String_.new_utf8_(src, data_bgn, hook_bgn));
|
||||
int page_id = Bry_.Xto_int_or(src, data_bgn, hook_bgn, -1); if (page_id == -1) usr_dlg.Warn_many(GRP_KEY, "page_id_invalid", "page_id_is_invalid: ~{0}", String_.new_utf8_(src, data_bgn, hook_bgn));
|
||||
rv.Id_(page_id);
|
||||
page_id_needed = false; // turn off for other <id> tags (<contributor>; <revision>)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class Xoa_cfg_mgr_fxt {
|
||||
Test_cfg_get(wiki, prop_key, expd_val);
|
||||
}
|
||||
private void Test_cfg_get(GfoInvkAble invk, String prop, String expd) {
|
||||
Tfds.Eq(expd, Object_.XtoStr_OrNullStr(app.Cfg_mgr().Eval_get(invk, prop)));
|
||||
Tfds.Eq(expd, Object_.Xto_str_strict_or_null_mark(app.Cfg_mgr().Eval_get(invk, prop)));
|
||||
}
|
||||
public void Test_cfg_itm(String wiki, String prop, boolean expd_customized, boolean expd_dirty) {
|
||||
Test_cfg_itm(Bry_.new_ascii_(wiki), Bry_.new_ascii_(prop), expd_customized, expd_dirty);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xocfg_html implements GfoInvkAble {
|
||||
public boolean Link_hover_full() {return link_hover_full;} public Xocfg_html Link_hover_full_(boolean v) {link_hover_full = v; return this;} private boolean link_hover_full;
|
||||
public boolean Content_editable() {return content_editable;} public Xocfg_html Content_editable_(boolean v) {content_editable = v; return this;} private boolean content_editable;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_content_editable)) return Yn.X_to_str(content_editable);
|
||||
if (ctx.Match(k, Invk_content_editable)) return Yn.Xto_str(content_editable);
|
||||
else if (ctx.Match(k, Invk_content_editable_)) content_editable = m.ReadYn_toggle("v", content_editable);
|
||||
else if (ctx.Match(k, Invk_link_hover_full_)) link_hover_full = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
|
||||
@@ -16,20 +16,16 @@ 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.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.cfgs.*;
|
||||
public class Xocfg_win implements Gfo_usr_dlg_ui_opt, GfoInvkAble {
|
||||
public class Xocfg_win implements GfoInvkAble {
|
||||
public Xocfg_win(Xoa_app app) {}
|
||||
public boolean Warn_enabled() {return warn_enabled;} private boolean warn_enabled = true;
|
||||
public boolean Note_enabled() {return note_enabled;} private boolean note_enabled = true;
|
||||
public Xol_font_info Font() {return font;} private Xol_font_info font = new Xol_font_info("Arial", 8, gplx.gfui.FontStyleAdp_.Plain);
|
||||
public Bry_fmtr Search_box_fmtr() {return search_box_fmtr;} private Bry_fmtr search_box_fmtr = Bry_fmtr.new_("Special:Allpages?from=", "search");
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_warn_enabled_)) warn_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_note_enabled_)) note_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_font)) return font;
|
||||
if (ctx.Match(k, Invk_font)) return font;
|
||||
else if (ctx.Match(k, Invk_search_box_fmt_)) search_box_fmtr.Fmt_(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_warn_enabled_ = "warn_enabled_", Invk_note_enabled_ = "note_enabled_", Invk_search_box_fmt_ = "search_box_fmt_", Invk_font = "font";
|
||||
private static final String Invk_search_box_fmt_ = "search_box_fmt_", Invk_font = "font";
|
||||
public static final float Font_size_default = 8;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,12 @@ public class Xocfg_bnd_itm implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_cmd_ctg_sort)) return cmd.Ctg().Tid();
|
||||
else if (ctx.Match(k, Invk_bnd_key)) return bnd.Key();
|
||||
else if (ctx.Match(k, Invk_bnd_uid)) return bnd.Uid();
|
||||
else if (ctx.Match(k, Invk_bnd_sys)) return Yn.X_to_str(bnd.Sys());
|
||||
else if (ctx.Match(k, Invk_bnd_sys)) return Yn.Xto_str(bnd.Sys());
|
||||
else if (ctx.Match(k, Invk_bnd_cmd)) return bnd.Cmd();
|
||||
else if (ctx.Match(k, Invk_bnd_cmd_)) bnd.Cmd_(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_bnd_box)) return Xog_bnd_box_.X_to_gui_str(bnd.Box());
|
||||
else if (ctx.Match(k, Invk_bnd_box)) return Xog_bnd_box_.Xto_gui_str(bnd.Box());
|
||||
else if (ctx.Match(k, Invk_bnd_box_idx)) return bnd.Box();
|
||||
else if (ctx.Match(k, Invk_bnd_ipt)) return mgr.Bnd_mgr().Bnd_parser().X_to_norm(bnd.Ipt().Key());
|
||||
else if (ctx.Match(k, Invk_bnd_ipt)) return mgr.Bnd_mgr().Bnd_parser().Xto_norm(bnd.Ipt().Key());
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xocfg_bnd_itm_srl implements GfoInvkAble {
|
||||
public IptArg Ipt() {return ipt;} private IptArg ipt;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_src_)) Src_(app, this, m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_box_)) box = Xog_bnd_box_.X_to_sys_int(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_box_)) box = Xog_bnd_box_.Xto_sys_int(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_ipt_)) ipt = IptArg_.parse_(m.ReadStr("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
@@ -37,7 +37,7 @@ public class Xocfg_bnd_itm_srl implements GfoInvkAble {
|
||||
private static final String Invk_src_ = "src_", Invk_box_ = "box_", Invk_ipt_ = "ipt_";
|
||||
public static String Src(Xoa_app app, int box, IptArg ipt) { // box_('browser').ipt_('mod.c+key.q');
|
||||
Gfs_wtr wtr = app.Gfs_mgr().Wtr();
|
||||
wtr.Add_set_eq(Key_box, Bry_.new_ascii_(Xog_bnd_box_.X_to_sys_str(box)));
|
||||
wtr.Add_set_eq(Key_box, Bry_.new_ascii_(Xog_bnd_box_.Xto_sys_str(box)));
|
||||
wtr.Add_set_eq(Key_ipt, Bry_.new_ascii_(ipt.Key()));
|
||||
return wtr.Bfr().XtoStrAndClear();
|
||||
} private static final byte[] Key_box = Bry_.new_ascii_("box"), Key_ipt = Bry_.new_ascii_("ipt");
|
||||
|
||||
@@ -31,21 +31,21 @@ public class Xocfg_tab_btn_mgr implements GfoInvkAble, GfoEvMgrOwner {
|
||||
public int Text_max_chars() {return text_max_chars;} public Xocfg_tab_btn_mgr Text_max_chars_(int v) {text_max_chars = v; return this;} private int text_max_chars = 40;
|
||||
public boolean Hide_if_one() {return hide_if_one;} public Xocfg_tab_btn_mgr Hide_if_one_(boolean v) {hide_if_one = v; return this;} private boolean hide_if_one;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_place_on_top)) return Yn.X_to_str(place_on_top);
|
||||
if (ctx.Match(k, Invk_place_on_top)) return Yn.Xto_str(place_on_top);
|
||||
else if (ctx.Match(k, Invk_place_on_top_)) {place_on_top = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_place_on_top_changed, place_on_top);}
|
||||
else if (ctx.Match(k, Invk_curved)) return Yn.X_to_str(curved);
|
||||
else if (ctx.Match(k, Invk_curved)) return Yn.Xto_str(curved);
|
||||
else if (ctx.Match(k, Invk_curved_)) {curved = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_curved_changed, curved);}
|
||||
else if (ctx.Match(k, Invk_height)) return height;
|
||||
else if (ctx.Match(k, Invk_height_)) {height = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_height_changed, height);}
|
||||
else if (ctx.Match(k, Invk_close_visible)) return Yn.X_to_str(close_visible);
|
||||
else if (ctx.Match(k, Invk_close_visible)) return Yn.Xto_str(close_visible);
|
||||
else if (ctx.Match(k, Invk_close_visible_)) {close_visible = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_close_visible_changed, close_visible);}
|
||||
else if (ctx.Match(k, Invk_unselected_close_visible)) return Yn.X_to_str(unselected_close_visible);
|
||||
else if (ctx.Match(k, Invk_unselected_close_visible)) return Yn.Xto_str(unselected_close_visible);
|
||||
else if (ctx.Match(k, Invk_unselected_close_visible_)) {unselected_close_visible = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_unselected_close_visible_changed, unselected_close_visible);}
|
||||
else if (ctx.Match(k, Invk_text_min_chars)) return text_min_chars;
|
||||
else if (ctx.Match(k, Invk_text_min_chars_)) {text_min_chars = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_text_min_chars_changed, text_min_chars);}
|
||||
else if (ctx.Match(k, Invk_text_max_chars)) return text_max_chars;
|
||||
else if (ctx.Match(k, Invk_text_max_chars_)) {text_max_chars = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_text_max_chars_changed, text_max_chars);}
|
||||
else if (ctx.Match(k, Invk_hide_if_one)) return Yn.X_to_str(hide_if_one);
|
||||
else if (ctx.Match(k, Invk_hide_if_one)) return Yn.Xto_str(hide_if_one);
|
||||
else if (ctx.Match(k, Invk_hide_if_one_)) {hide_if_one = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_hide_if_one_changed, hide_if_one);}
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.xowa.cfgs2; import gplx.*; import gplx.xowa.*;
|
||||
public class Xocfg_tab_new_mgr implements GfoInvkAble {
|
||||
public byte Insert_pos() {return insert_pos;} private byte insert_pos = Xocfg_new_tab_pos.Tid_cur_nxt;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_insert_pos)) return Xocfg_new_tab_pos.X_to_str(insert_pos);
|
||||
else if (ctx.Match(k, Invk_insert_pos_)) insert_pos = Xocfg_new_tab_pos.X_to_tid(m.ReadStr("v"));
|
||||
if (ctx.Match(k, Invk_insert_pos)) return Xocfg_new_tab_pos.Xto_str(insert_pos);
|
||||
else if (ctx.Match(k, Invk_insert_pos_)) insert_pos = Xocfg_new_tab_pos.Xto_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_insert_pos_list)) return Xocfg_new_tab_pos.Options__all;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
@@ -30,14 +30,14 @@ public class Xocfg_tab_new_mgr implements GfoInvkAble {
|
||||
class Xocfg_new_tab_pos {
|
||||
public static final byte Tid_all_bgn = 0, Tid_all_end = 1, Tid_cur_prv = 2, Tid_cur_nxt = 3;
|
||||
public static final String Key_all_bgn = "first", Key_all_end = "last", Key_cur_prv = "before", Key_cur_nxt = "after";
|
||||
public static byte X_to_tid(String v) {
|
||||
public static byte Xto_tid(String v) {
|
||||
if (String_.Eq(v, Key_all_bgn)) return Tid_all_bgn;
|
||||
else if (String_.Eq(v, Key_all_end)) return Tid_all_end;
|
||||
else if (String_.Eq(v, Key_cur_prv)) return Tid_all_end;
|
||||
else if (String_.Eq(v, Key_cur_nxt)) return Tid_all_end;
|
||||
else throw Err_.unhandled(v);
|
||||
}
|
||||
public static String X_to_str(byte v) {
|
||||
public static String Xto_str(byte v) {
|
||||
switch (v) {
|
||||
case Tid_all_bgn: return Key_all_bgn;
|
||||
case Tid_all_end: return Key_all_end;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xoa_ctg_mgr implements GfoInvkAble {
|
||||
if (ctx.Match(k, Invk_missing_ctg_cls)) return Missing_ctg_cls_tid_print(missing_ctg_cls_tid);
|
||||
else if (ctx.Match(k, Invk_missing_ctg_cls_)) missing_ctg_cls_tid = Missing_ctg_cls_tid_parse(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_missing_ctg_cls_list)) return Options_missing_ctg_cls_list;
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled)) return Yn.X_to_str(pagecats_grouping_enabled);
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled)) return Yn.Xto_str(pagecats_grouping_enabled);
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled_)) pagecats_grouping_enabled = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
public class Xoctg_pagelist_grp implements Bry_fmtr_arg {
|
||||
public void Init_app(Xoa_app app, boolean type_is_normal, Bry_fmtr fmtr_grp, Bry_fmtr fmtr_itm) {
|
||||
this.type_is_normal = type_is_normal;
|
||||
@@ -24,7 +25,7 @@ public class Xoctg_pagelist_grp implements Bry_fmtr_arg {
|
||||
} private Bry_fmtr fmtr_grp;
|
||||
public void Init_by_wiki(Xow_wiki wiki) {
|
||||
lbl_ctg_text = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_ctg_tbl_hdr);
|
||||
lbl_ctg_help = Pf_msg_mgr.Get_msg_val(wiki, wiki.Lang(), Key_pagecategorieslink, Bry_.Ary_empty);
|
||||
lbl_ctg_help = Xol_msg_mgr_.Get_msg_val(wiki, wiki.Lang(), Key_pagecategorieslink, Bry_.Ary_empty);
|
||||
lbl_hidden = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_ctg_tbl_hidden);
|
||||
itms.Init_wiki(wiki);
|
||||
} private byte[] lbl_ctg_help, lbl_ctg_text, lbl_hidden; private static final byte[] Key_pagecategorieslink = Bry_.new_ascii_("pagecategorieslink");
|
||||
|
||||
@@ -19,18 +19,18 @@ package gplx.xowa.dbs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xodb_file {
|
||||
public Xodb_file(int id, byte tid) {this.id = id; this.tid = tid;}
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xodb_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public int Id() {return id;} private int id;
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Io_url Url() {return url;} public Xodb_file Url_(Io_url v) {url = v; return this;} private Io_url url;
|
||||
public String Url_rel() {return url_rel;} public Xodb_file Url_rel_(String v) {this.url_rel = v; return this;} private String url_rel;
|
||||
public Db_connect Connect() {return connect;} public Xodb_file Connect_(Db_connect v) {connect = v; return this;} Db_connect connect;
|
||||
public long File_len() {return file_len;} public void File_len_add(int v) {file_len += v;} long file_len;
|
||||
public long File_max() {return file_max;} public Xodb_file File_max_(long v) {file_max = v; return this;} long file_max;
|
||||
public int Id() {return id;} private int id;
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Io_url Url() {return url;} public Xodb_file Url_(Io_url v) {url = v; return this;} private Io_url url;
|
||||
public String Url_rel() {return url_rel;} public Xodb_file Url_rel_(String v) {url_rel = v; return this;} private String url_rel;
|
||||
public long File_len() {return file_len;} public Xodb_file File_len_add(int v) {file_len += v; return this;} private long file_len;
|
||||
public long File_max() {return file_max;} public Xodb_file File_max_(long v) {file_max = v; return this;} private long file_max;
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xodb_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public Db_connect Connect() {return connect;} public Xodb_file Connect_(Db_connect v) {connect = v; return this;} private Db_connect connect;
|
||||
public Db_provider Provider() {
|
||||
if (provider == null) provider = Db_provider_pool._.FetchOrNew(connect);
|
||||
return provider;
|
||||
} Db_provider provider;
|
||||
} private Db_provider provider;
|
||||
public void Provider_(Db_provider p) {provider = p;}
|
||||
public void Rls() {
|
||||
if (provider == null) return;
|
||||
@@ -39,37 +39,7 @@ public class Xodb_file {
|
||||
provider.Rls();
|
||||
} finally {provider = null;}
|
||||
}
|
||||
public static final byte Tid_core = 1, Tid_text = 2, Tid_category = 3, Tid_search = 4, Tid_wikidata = 5, Tid_temp = 6;
|
||||
public static String Tid_to_name(byte v) {
|
||||
switch (v) {
|
||||
case Tid_core: return "core";
|
||||
case Tid_text: return "text";
|
||||
case Tid_category: return "category";
|
||||
case Tid_wikidata: return "wikidata";
|
||||
case Tid_temp: return "temp";
|
||||
case Tid_search: return "search";
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
|
||||
public static Xodb_file load_(int id, byte tid, String url) {return new Xodb_file(id, tid).Url_rel_(url).Cmd_mode_(Db_cmd_mode.Ignore);}
|
||||
public static Xodb_file make_(int id, byte tid, String url) {return new Xodb_file(id, tid).Url_rel_(url).Cmd_mode_(Db_cmd_mode.Create);}
|
||||
public void Index_create(Gfo_usr_dlg usr_dlg, Db_idx_itm[] idxs) {
|
||||
int len = idxs.length;
|
||||
provider.Txn_mgr().Txn_end_all(); // commit any pending transactions
|
||||
for (int i = 0; i < len; i++) {
|
||||
provider.Txn_mgr().Txn_bgn_if_none();
|
||||
String index = idxs[i].Xto_sql();
|
||||
usr_dlg.Prog_many("", "", "creating index: ~{0} ~{1}", id, index);
|
||||
provider.Exec_sql(index);
|
||||
provider.Txn_mgr().Txn_end_all();
|
||||
}
|
||||
}
|
||||
public static final Db_idx_itm
|
||||
Indexes_page_title = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__title ON page (page_namespace, page_title, page_id, page_len, page_is_redirect);") // PERF:page_id for general queries; PERF: page_len for search_suggest; PREF:page_is_redirect for oimg
|
||||
, Indexes_page_random = Db_idx_itm.sql_("CREATE UNIQUE INDEX IF NOT EXISTS page__name_random ON page (page_namespace, page_random_int);")
|
||||
, Indexes_categorylinks_main = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS categorylinks__cl_main ON categorylinks (cl_to_id, cl_type_id, cl_sortkey, cl_from);")
|
||||
, Indexes_categorylinks_from = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS categorylinks__cl_from ON categorylinks (cl_from);")
|
||||
, Indexes_wikidata_qids = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS wdata_qids__src ON wdata_qids (wq_src_wiki, wq_src_ns, wq_src_ttl);")
|
||||
, Indexes_wikidata_pids = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS wdata_pids__src ON wdata_pids (wp_src_lang, wp_src_ttl);")
|
||||
;
|
||||
}
|
||||
|
||||
33
400_xowa/src/gplx/xowa/dbs/Xodb_file_tid_.java
Normal file
33
400_xowa/src/gplx/xowa/dbs/Xodb_file_tid_.java
Normal file
@@ -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.dbs; import gplx.*; import gplx.xowa.*;
|
||||
public class Xodb_file_tid_ {
|
||||
public static final byte Tid_core = 1, Tid_text = 2, Tid_category = 3, Tid_search = 4, Tid_wikidata = 5, Tid_temp = 6;
|
||||
public static final String Key_core = "core", Key_text = "text", Key_category = "category", Key_wikidata = "wikidata", Key_temp = "temp", Key_search = "search";
|
||||
public static String Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_core: return Key_core;
|
||||
case Tid_text: return Key_text;
|
||||
case Tid_category: return Key_category;
|
||||
case Tid_wikidata: return Key_wikidata;
|
||||
case Tid_temp: return Key_temp;
|
||||
case Tid_search: return Key_search;
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,10 @@ public class Xodb_fsys_mgr {
|
||||
this.trg_name = trg_name;
|
||||
return this;
|
||||
} private Io_url src_dir; private String trg_name;
|
||||
public Db_provider Core_provider() {return core_provider;} Db_provider core_provider;
|
||||
public Db_provider Page_provider() {return page_provider;} Db_provider page_provider;
|
||||
public Db_provider Category_provider() {return category_provider;} Db_provider category_provider;
|
||||
public Db_provider Wdata_provider() {return wikidata_provider;} Db_provider wikidata_provider;
|
||||
public Db_provider Core_provider() {return core_provider;} private Db_provider core_provider;
|
||||
public Db_provider Page_provider() {return page_provider;} private Db_provider page_provider;
|
||||
public Db_provider Category_provider() {return category_provider;} private Db_provider category_provider;
|
||||
public Db_provider Wdata_provider() {return wikidata_provider;} private Db_provider wikidata_provider;
|
||||
public Io_url Trg_dir() {return trg_dir;} private Io_url trg_dir;
|
||||
public int Tid_text_idx() {return tid_text_idx;} public Xodb_fsys_mgr Tid_text_idx_(int v) {tid_text_idx = v; return this;} private int tid_text_idx = File_id_core;
|
||||
public long Tid_text_max() {return tid_text_max;} long tid_text_max = Heap_max_infinite;
|
||||
@@ -41,18 +41,18 @@ public class Xodb_fsys_mgr {
|
||||
Io_url url = trg_dir.GenSubFil(file.Url_rel()); // relative name only
|
||||
file.Connect_(Db_connect_.sqlite_(url)).Url_(url);
|
||||
switch (file.Tid()) {
|
||||
case Xodb_file.Tid_core : file.Provider_(p); Init_by_tid_core(file); break;
|
||||
case Xodb_file.Tid_category : if (category_provider_core_null) {Init_by_tid_category(file); category_provider_core_null = false;}break;
|
||||
case Xodb_file.Tid_wikidata : Init_by_tid_wikidata(file); break;
|
||||
case Xodb_file.Tid_text : Init_by_tid_text(file); break;
|
||||
case Xodb_file_tid_.Tid_core : file.Provider_(p); Init_by_tid_core(file); break;
|
||||
case Xodb_file_tid_.Tid_category : if (category_provider_core_null) {Init_by_tid_category(file); category_provider_core_null = false;}break;
|
||||
case Xodb_file_tid_.Tid_wikidata : Init_by_tid_wikidata(file); break;
|
||||
case Xodb_file_tid_.Tid_text : Init_by_tid_text(file); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Init_make(Xow_ns_mgr ns_mgr, String ns_map_str, long text_max) {
|
||||
Init_by_tid_core(Make(Xodb_file.Tid_core));
|
||||
Init_by_tid_core(Make(Xodb_file_tid_.Tid_core));
|
||||
Init_by_ns_map(ns_mgr, Xodb_ns_map_mgr.Parse(Bry_.new_ascii_(ns_map_str)));
|
||||
if (text_max > 0)
|
||||
Init_by_tid_text(Init_make_file(Xodb_file.Tid_text, text_max));
|
||||
Init_by_tid_text(Init_make_file(Xodb_file_tid_.Tid_text, text_max));
|
||||
}
|
||||
public Xodb_file Init_make_file(byte tid, long max) {
|
||||
if (max == Max_core_db) return files_ary[File_id_core];
|
||||
@@ -68,7 +68,7 @@ public class Xodb_fsys_mgr {
|
||||
Xodb_ns_map_itm itm = ns_map_itms[i];
|
||||
int[] ns_ids = itm.Ns_ids();
|
||||
int ns_ids_len = ns_ids.length;
|
||||
Xodb_file file = Make(Xodb_file.Tid_text);
|
||||
Xodb_file file = Make(Xodb_file_tid_.Tid_text);
|
||||
for (int j = 0; j < ns_ids_len; j++) {
|
||||
int ns_id = ns_ids[j];
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id); if (ns == null) continue; // some dumps may not have ns; for example, pre-2013 dumps won't have Module (828)
|
||||
@@ -97,7 +97,7 @@ public class Xodb_fsys_mgr {
|
||||
for (int i = 0; i < files_ary_len; i++) {
|
||||
Xodb_file file = files_ary[i];
|
||||
if (Byte_.In(file.Tid(), tids))
|
||||
file.Index_create(usr_dlg, idxs);
|
||||
Xodb_fsdb_mgr_.Index_create(usr_dlg, file, idxs);
|
||||
}
|
||||
}
|
||||
public void Overwrite(int file_idx) {Create_sqlite3(src_dir, trg_dir, trg_name, file_idx);}
|
||||
@@ -105,13 +105,13 @@ public class Xodb_fsys_mgr {
|
||||
Io_url url = trg_dir.GenSubFil(name + ".sqlite3");
|
||||
if (!Io_mgr._.ExistsFil(url))
|
||||
Io_mgr._.CopyFil(src_dir.GenSubFil("xowa.sqlite3"), url, true);
|
||||
return Xodb_file.make_(-1, Xodb_file.Tid_temp, url.NameAndExt()).Connect_(Db_connect_.sqlite_(url));
|
||||
return Xodb_file.make_(-1, Xodb_file_tid_.Tid_temp, url.NameAndExt()).Connect_(Db_connect_.sqlite_(url));
|
||||
}
|
||||
public Xodb_file Make(byte file_tid) {
|
||||
int file_idx = files_ary_len;
|
||||
Io_url url = Create_sqlite3(src_dir, trg_dir, trg_name, file_idx);
|
||||
Xodb_file rv = Xodb_file.make_(file_idx, file_tid, url.NameAndExt()).Connect_(Db_connect_.sqlite_(url));
|
||||
gplx.xowa.dbs.tbls.Xodb_xowa_cfg_tbl.Insert_str(rv.Provider(), "db.meta", "type_name", Xodb_file.Tid_to_name(file_tid));
|
||||
gplx.xowa.dbs.tbls.Xodb_xowa_cfg_tbl.Insert_str(rv.Provider(), "db.meta", "type_name", Xodb_file_tid_.Xto_key(file_tid));
|
||||
files_ary = (Xodb_file[])Array_.Resize(files_ary, files_ary_len + 1);
|
||||
files_ary[files_ary_len] = rv;
|
||||
++files_ary_len;
|
||||
@@ -130,3 +130,17 @@ public class Xodb_fsys_mgr {
|
||||
public static final int Heap_max_infinite = 0;
|
||||
public static final long Max_core_db = -1;
|
||||
}
|
||||
class Xodb_fsdb_mgr_ {
|
||||
public static void Index_create(Gfo_usr_dlg usr_dlg, Xodb_file file, Db_idx_itm[] idxs) {
|
||||
Db_provider provider = file.Provider();
|
||||
provider.Txn_mgr().Txn_end_all(); // commit any pending transactions
|
||||
int len = idxs.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
provider.Txn_mgr().Txn_bgn_if_none();
|
||||
String index = idxs[i].Xto_sql();
|
||||
usr_dlg.Prog_many("", "", "creating index: ~{0} ~{1}", file.Id(), index);
|
||||
provider.Exec_sql(index);
|
||||
provider.Txn_mgr().Txn_end_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
private Db_provider search_provider = null;
|
||||
private void Search_version_init() {
|
||||
if (search_provider == null) {
|
||||
Xodb_file search_file = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file.Tid_search);
|
||||
Xodb_file search_file = db_mgr.Fsys_mgr().Get_tid_root(Xodb_file_tid_.Tid_search);
|
||||
if (search_file == null) {
|
||||
search_provider = Db_provider_.Null;
|
||||
search_version = gplx.xowa.specials.search.Xosrh_core.Version_1;
|
||||
@@ -128,7 +128,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
if (search_version == gplx.xowa.specials.search.Xosrh_core.Version_1)
|
||||
db_mgr.Tbl_page().Select_by_search(cancelable, rv, search, results_max);
|
||||
else {
|
||||
Xodb_search_title_word_tbl.Select_by_word(cancelable, rv, search, results_max, db_mgr.Fsys_mgr().Get_tid_root(Xodb_file.Tid_search).Provider());
|
||||
Xodb_search_title_word_tbl.Select_by_word(cancelable, rv, search, results_max, db_mgr.Fsys_mgr().Get_tid_root(Xodb_file_tid_.Tid_search).Provider());
|
||||
db_mgr.Tbl_page().Select_by_id_list(cancelable, true, rv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
if (pids_root == null)
|
||||
pids_root = wiki.App().Wiki_mgr().Wdata_mgr().Wdata_wiki().Fsys_mgr().Site_dir().GenSubDir_nest("data", "pid");
|
||||
Xob_xdat_itm pid_itm = Load_xdat_itm_by_dir(pids_root.GenSubDir(String_.new_utf8_(lang_key)), pid_name); if (pid_itm == null) return gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null;
|
||||
return Bry_.X_to_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
return Bry_.Xto_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
} Io_url pids_root;
|
||||
public int Load_ctg_count(byte[] ttl) {return wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_1 ? Load_ctg_count_v1(ttl) : Load_ctg_count_v2(ttl);}
|
||||
int Load_ctg_count_v1(byte[] ttl) {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
public DateAdp Dump_date_query() {
|
||||
DateAdp rv = wiki.Props().Modified_latest();
|
||||
if (rv != null) return rv;
|
||||
Io_url url = fsys_mgr.Get_url(Xodb_file.Tid_core);
|
||||
Io_url url = fsys_mgr.Get_url(Xodb_file_tid_.Tid_core);
|
||||
return Io_mgr._.QueryFil(url).ModifiedTime();
|
||||
}
|
||||
public void Init_make(String ns_map) {
|
||||
|
||||
32
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_row.java
Normal file
32
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_row.java
Normal file
@@ -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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
|
||||
import gplx.ios.*;
|
||||
public class Hdump_page_row {
|
||||
public int Id() {return id;} private int id;
|
||||
public byte[] Html() {return html;} private byte[] html;
|
||||
public int Frags_len() {return frags_len;} private int frags_len;
|
||||
public int Make_id() {return make_id;} private int make_id;
|
||||
public Hdump_page_row Ctor(int id, byte[] html, int frags_len, int make_id) {
|
||||
this.id = id;
|
||||
this.html = html;
|
||||
this.frags_len = frags_len;
|
||||
this.make_id = make_id;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
86
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_tbl.java
Normal file
86
400_xowa/src/gplx/xowa/dbs/hdumps/Hdump_page_tbl.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
|
||||
import gplx.dbs.*; import gplx.ios.*;
|
||||
public class Hdump_page_tbl {
|
||||
private Db_stmt stmt_select, stmt_insert, stmt_update;
|
||||
private Io_stream_zip_mgr zip_mgr; private byte zip_tid;
|
||||
public void Ctor(Io_stream_zip_mgr zip_mgr, byte zip_tid) {this.zip_mgr = zip_mgr; this.zip_tid = zip_tid;}
|
||||
@gplx.Virtual public void Insert(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all);
|
||||
try {
|
||||
html = zip_mgr.Zip(zip_tid, html);
|
||||
stmt_insert.Val_int_(page_id).Val_bry_(html).Val_int_(frags_len).Val_int_(make_id).Exec_insert();
|
||||
} finally {stmt_insert.Rls();}
|
||||
}
|
||||
@gplx.Virtual public void Update(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
if (stmt_update == null) stmt_update = Db_stmt_.new_update_(provider, Tbl_name, Flds_all);
|
||||
try {
|
||||
html = zip_mgr.Zip(zip_tid, html);
|
||||
stmt_update.Val_int_(page_id).Val_bry_(html).Val_int_(frags_len).Val_int_(make_id).Exec_update();
|
||||
} finally {stmt_update.Rls();}
|
||||
}
|
||||
@gplx.Virtual public void Select(Db_provider provider, Hdump_page_row rv, int page_id) {
|
||||
if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_page_id), Flds_all);
|
||||
try {
|
||||
DataRdr rdr = stmt_select.Exec_select();
|
||||
rv.Ctor
|
||||
( rdr.ReadInt(Fld_page_id)
|
||||
, zip_mgr.Unzip(zip_tid, rdr.ReadBry(Fld_page_text))
|
||||
, rdr.ReadInt(Fld_frags_len)
|
||||
, rdr.ReadInt(Fld_make_id)
|
||||
);
|
||||
rdr.Rls();
|
||||
} finally {stmt_select.Rls();}
|
||||
}
|
||||
@gplx.Virtual public void Delete_all(Db_provider provider) {
|
||||
Db_qry_.delete_tbl_(Tbl_name).Exec_qry(provider);
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_select = stmt_insert = stmt_update = null;
|
||||
zip_mgr = null;
|
||||
}
|
||||
public static final String Tbl_name = "html_page"
|
||||
, Fld_page_id = "page_id", Fld_page_text = "page_text", Fld_frags_len = "frags_len", Fld_make_id= "make_id";
|
||||
private static final String[] Flds_all = new String[] {Fld_page_id, Fld_page_text, Fld_frags_len, Fld_make_id};
|
||||
public static final String Tbl_sql = String_.Concat_lines_nl
|
||||
( "CREATE TABLE IF NOT EXISTS html_page"
|
||||
, "( page_id integer NOT NULL PRIMARY KEY"
|
||||
, ", page_text mediumblob NOT NULL"
|
||||
, ", frags_len integer NOT NULL"
|
||||
, ", make_id integer NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
}
|
||||
class Hdump_page_tbl_mem extends Hdump_page_tbl { private OrderedHash hash = OrderedHash_.new_();
|
||||
@Override public void Insert(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
Hdump_page_row row = new Hdump_page_row().Ctor(page_id, html, frags_len, make_id);
|
||||
hash.Add(page_id, row);
|
||||
}
|
||||
@Override public void Update(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) {
|
||||
Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id);
|
||||
row.Ctor(page_id, html, frags_len, make_id);
|
||||
}
|
||||
@Override public void Select(Db_provider provider, Hdump_page_row rv, int page_id) {
|
||||
Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id);
|
||||
rv.Ctor(row.Id(), row.Html(), row.Frags_len(), row.Make_id());
|
||||
}
|
||||
@Override public void Delete_all(Db_provider provider) {
|
||||
hash.Clear();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.dbs.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
|
||||
import gplx.dbs.*; import gplx.ios.*;
|
||||
public class Xodb_text_tbl {
|
||||
public Xodb_text_tbl(Xodb_mgr_sql db_mgr) {this.db_mgr = db_mgr; zip_mgr = db_mgr.Wiki().App().Zip_mgr();} private Xodb_mgr_sql db_mgr; Io_stream_zip_mgr zip_mgr;
|
||||
public Xodb_text_tbl(Xodb_mgr_sql db_mgr) {this.db_mgr = db_mgr; zip_mgr = db_mgr.Wiki().App().Zip_mgr();} private Xodb_mgr_sql db_mgr; private Io_stream_zip_mgr zip_mgr;
|
||||
public void Delete_all(Db_provider provider) {provider.Exec_qry(Db_qry_.delete_tbl_(Tbl_name));}
|
||||
public Db_stmt Insert_stmt(Db_provider prov) {return Db_stmt_.new_insert_(prov, Tbl_name, Fld_page_id, Fld_old_text);}
|
||||
public void Insert(Db_stmt stmt, int page_id, byte[] text, byte storage_type) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xodb_wdata_pids_tbl {
|
||||
String pid_str = (String)stmt.Val_str_by_bry_(src_lang).Val_str_by_bry_(src_ttl).Exec_select_val();
|
||||
if (pid_str == null) return Wdata_wiki_mgr.Pid_null; // occurs when pid exists, but does not have entry for language; see hu.w:Marco Polo argali; DATE: 2014-02-01
|
||||
byte[] pid_bry = Bry_.new_utf8_(pid_str);
|
||||
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.X_to_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
|
||||
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.Xto_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
|
||||
} finally {stmt.Rls();}
|
||||
}
|
||||
public static final String Tbl_name = "wdata_pids", Fld_wp_src_lang = "wp_src_lang", Fld_wp_src_ttl = "wp_src_ttl", Fld_wp_trg_ttl = "wp_trg_ttl";
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xodb_wdata_qids_tbl {
|
||||
Db_stmt stmt = Db_stmt_.Null;
|
||||
try {
|
||||
stmt = Db_stmt_.new_select_(p, Tbl_name, String_.Ary(Fld_wq_src_wiki, Fld_wq_src_ns, Fld_wq_src_ttl), Fld_wq_trg_ttl);
|
||||
String rv = (String)stmt.Val_str_by_bry_(src_wiki).Val_int_(Bry_.X_to_int(src_ns)).Val_str_by_bry_(src_ttl).Exec_select_val();
|
||||
String rv = (String)stmt.Val_str_by_bry_(src_wiki).Val_int_(Bry_.Xto_int(src_ns)).Val_str_by_bry_(src_ttl).Exec_select_val();
|
||||
return rv == null ? null : Bry_.new_utf8_(rv);
|
||||
} finally {stmt.Rls();}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
html_view_src = Trg_html(Xof_repo_itm.Mode_thumb, this.File_w());
|
||||
thumb = meta_itm.Thumbs_get_img(html_w, 0);
|
||||
if (thumb == null) { // exact thumb not found
|
||||
if (html_w == meta_itm.Orig_w() // html_w matches orig_w; occurs when thumb,upright requested, but upright size is larger than orig; EX.WP:St. Petersburg
|
||||
if (html_w == meta_itm.Orig_w() // html_w matches orig_w; occurs when thumb,upright requested, but upright size is larger than orig; PAGE:en.w:St. Petersburg
|
||||
&& !lnki_ext.Id_needs_convert() // but ext cannot be something that needs conversion; EX: 120,90 svg may match thumb of 120,90, but .png still needs to be generated
|
||||
&& meta_itm.Orig_exists() == Xof_meta_itm.Exists_y
|
||||
) {
|
||||
|
||||
@@ -89,6 +89,8 @@ public class Xof_fsdb_itm {
|
||||
Html_size_calc(img_size, exec_tid);
|
||||
Xof_repo_itm repo = repo_mgr.Repos_get_by_wiki(orig_wiki).Trg();
|
||||
byte[] name_bry = Bry_.Len_eq_0(orig_redirect) ? lnki_ttl : orig_redirect;
|
||||
if (!lnki_ext.Id_is_media() && lnki_thumbtime != Xof_doc_thumb.Null) // file is not media, but has thumbtime; this check can't be moved to Lnki_thumbtime_() b/c it needs ext
|
||||
lnki_thumbtime = Xof_doc_thumb.Null; // set thumbtime to null; needed else url will reference thumbtime; PAGE:en.w:Moon; EX:[[File:Lunar libration with phase Oct 2007 450px.gif|thumbtime=0:02]]; DATE:2014-07-20
|
||||
html_url = url_bldr.Set_trg_file_(lnki_type_as_mode, repo, name_bry, lnki_md5, lnki_ext, html_w, lnki_thumbtime, lnki_page).Xto_url();
|
||||
html_orig_url = url_bldr.Set_trg_file_(Xof_repo_itm.Mode_orig, repo, name_bry, lnki_md5, lnki_ext, Xof_img_size.Size_null_deprecated, Xof_doc_thumb.Null, Xof_doc_page.Null).Xto_url();
|
||||
}
|
||||
|
||||
@@ -57,19 +57,21 @@ public class Xof_fsdb_mgr_sql implements Xof_fsdb_mgr, GfoInvkAble {
|
||||
}
|
||||
public boolean Init_by_wiki(Xow_wiki wiki) {
|
||||
if (init) return false;
|
||||
this.wiki = wiki;
|
||||
usr_dlg = wiki.App().Usr_dlg();
|
||||
mnt_mgr.Usr_dlg_(usr_dlg);
|
||||
init = true;
|
||||
Xow_repo_mgr repo_mgr = wiki.File_mgr().Repo_mgr();
|
||||
Init_by_wiki(wiki, wiki.App().Fsys_mgr().File_dir().GenSubDir(wiki.Domain_str()), wiki.App().Fsys_mgr().File_dir(), repo_mgr);
|
||||
Xof_qry_wkr_xowa_reg qry_xowa = new Xof_qry_wkr_xowa_reg(img_regy_provider);
|
||||
try {
|
||||
this.wiki = wiki;
|
||||
usr_dlg = wiki.App().Usr_dlg();
|
||||
mnt_mgr.Usr_dlg_(usr_dlg);
|
||||
init = true;
|
||||
Xow_repo_mgr repo_mgr = wiki.File_mgr().Repo_mgr();
|
||||
Init_by_wiki(wiki, wiki.App().Fsys_mgr().File_dir().GenSubDir(wiki.Domain_str()), wiki.App().Fsys_mgr().File_dir(), repo_mgr);
|
||||
Xof_qry_wkr_xowa_reg qry_xowa = new Xof_qry_wkr_xowa_reg(img_regy_provider);
|
||||
// Xof_qry_wkr_xowa qry_xowa = new Xof_qry_wkr_xowa(new Xof_wiki_finder(wiki.App().Wiki_mgr().Get_by_key_or_make(Xow_wiki_.Domain_commons_bry), wiki), new gplx.xowa.files.qrys.Xof_img_meta_wkr_xowa());
|
||||
Xof_qry_wkr_wmf_api qry_wmf_api = new Xof_qry_wkr_wmf_api(wiki, new Xof_img_wkr_api_size_base_wmf());
|
||||
qry_mgr.Add_many(qry_xowa, qry_wmf_api);
|
||||
wiki.Rls_list().Add(this);
|
||||
bin_mgr.Resizer_(wiki.App().File_mgr().Img_mgr().Wkr_resize_img());
|
||||
return true;
|
||||
Xof_qry_wkr_wmf_api qry_wmf_api = new Xof_qry_wkr_wmf_api(wiki, new Xof_img_wkr_api_size_base_wmf());
|
||||
qry_mgr.Add_many(qry_xowa, qry_wmf_api);
|
||||
wiki.Rls_list().Add(this);
|
||||
bin_mgr.Resizer_(wiki.App().File_mgr().Img_mgr().Wkr_resize_img());
|
||||
return true;
|
||||
} catch (Exception exc) {throw Err_.new_fmt_("failed to initialize fsdb_mgr: wiki=~{0) err=~{1}", wiki.Domain_str(), Err_.Message_gplx_brief(exc));}
|
||||
}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Io_url db_dir, Io_url app_file_dir, Xow_repo_mgr repo_mgr) {
|
||||
this.app_file_dir = app_file_dir;
|
||||
|
||||
@@ -29,12 +29,12 @@ public class Cache_fil_itm implements CompareAble {
|
||||
public long Fil_size() {return fil_size;} private long fil_size;
|
||||
public void Fil_size_(long v) {
|
||||
this.fil_size = v;
|
||||
cmd_mode = Db_cmd_mode.X_to_update(cmd_mode);
|
||||
cmd_mode = Db_cmd_mode.Xto_update(cmd_mode);
|
||||
}
|
||||
public long Cache_time() {return cache_time;} private long cache_time;
|
||||
public void Cache_time_now_() {
|
||||
this.cache_time = DateAdp_.Now().XtoUtc().Timestamp_unix();
|
||||
cmd_mode = Db_cmd_mode.X_to_update(cmd_mode);
|
||||
cmd_mode = Db_cmd_mode.Xto_update(cmd_mode);
|
||||
}
|
||||
public byte Cmd_mode() {return cmd_mode;} public Cache_fil_itm Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public void Cmd_mode_delete_() {
|
||||
|
||||
@@ -60,6 +60,6 @@ class Bfmtr_eval_invk implements Bry_fmtr_eval_mgr {
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
|
||||
public byte[] Eval(byte[] cmd) {
|
||||
Object rslt = app.Gfs_mgr().Run_str_for(invk, String_.new_utf8_(cmd));
|
||||
return Bry_.new_utf8_(Object_.XtoStr_OrNullStr(rslt));
|
||||
return Bry_.new_utf8_(Object_.Xto_str_strict_or_null_mark(rslt));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xog_html_mgr implements GfoInvkAble {
|
||||
public String Auto_focus_id() {return auto_focus_id;} private String auto_focus_id = "";
|
||||
public byte[] Css_xtn() {return css_xtn;} public void Css_xtn_(byte[] v) {css_xtn = v;} private byte[] css_xtn = Bry_.Empty;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_javascript_enabled)) return Yn.X_to_str(javascript_enabled);
|
||||
if (ctx.Match(k, Invk_javascript_enabled)) return Yn.Xto_str(javascript_enabled);
|
||||
else if (ctx.Match(k, Invk_javascript_enabled_)) Javascript_enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_auto_focus_id_)) auto_focus_id = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_css_xtn)) return css_xtn;
|
||||
|
||||
@@ -35,15 +35,15 @@ public class Xog_bnd_box_ {
|
||||
return ary;
|
||||
} private static Xog_bnd_box[] ary;
|
||||
private static void ary_init(Xog_bnd_box[] ary, int tid, String key) {ary[tid] = new Xog_bnd_box(tid, key);}
|
||||
public static int[] X_to_sys_int_ary(String s) {
|
||||
public static int[] Xto_sys_int_ary(String s) {
|
||||
String[] ary = String_.Split(s, "|");
|
||||
int len = ary.length;
|
||||
int[] rv = new int[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
rv[i] = X_to_sys_int(ary[i]);
|
||||
rv[i] = Xto_sys_int(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public static int X_to_sys_int(String s) {
|
||||
public static int Xto_sys_int(String s) {
|
||||
if (String_.Eq(s, Key_browser)) return Tid_browser;
|
||||
else if (String_.Eq(s, Key_browser_url)) return Tid_browser_url;
|
||||
else if (String_.Eq(s, Key_browser_search)) return Tid_browser_search;
|
||||
@@ -53,7 +53,7 @@ public class Xog_bnd_box_ {
|
||||
else if (String_.Eq(s, Key_browser_info)) return Tid_browser_info;
|
||||
else throw Err_.unhandled(s);
|
||||
}
|
||||
public static String X_to_sys_str(int v) {
|
||||
public static String Xto_sys_str(int v) {
|
||||
switch (v) {
|
||||
case Tid_browser: return Key_browser;
|
||||
case Tid_browser_url: return Key_browser_url;
|
||||
@@ -65,7 +65,7 @@ public class Xog_bnd_box_ {
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
public static String X_to_gui_str(int v) {
|
||||
public static String Xto_gui_str(int v) {
|
||||
switch (v) {
|
||||
case Tid_browser: return Gui_browser;
|
||||
case Tid_browser_url: return Gui_browser_url;
|
||||
@@ -77,7 +77,7 @@ public class Xog_bnd_box_ {
|
||||
default: throw Err_.unhandled(v);
|
||||
}
|
||||
}
|
||||
public static int X_by_gui_str(String s) {
|
||||
public static int Xby_gui_str(String s) {
|
||||
if (String_.Eq(s, Gui_browser)) return Tid_browser;
|
||||
else if (String_.Eq(s, Gui_browser_url)) return Tid_browser_url;
|
||||
else if (String_.Eq(s, Gui_browser_search)) return Tid_browser_search;
|
||||
|
||||
@@ -55,8 +55,8 @@ public class Xog_bnd_mgr_srl extends Dsv_wkr_base {
|
||||
|
||||
if (uids == null) Init();
|
||||
Xog_bnd_itm bnd = (Xog_bnd_itm)uids.Fetch(Int_obj_val.new_(uid));
|
||||
int box = Xog_bnd_box_.X_by_gui_str(String_.new_utf8_(box_bry));
|
||||
IptArg ipt = IptArg_.parse_or_none_(bnd_parser.X_to_gfui(String_.new_utf8_(ipt_bry)));
|
||||
int box = Xog_bnd_box_.Xby_gui_str(String_.new_utf8_(box_bry));
|
||||
IptArg ipt = IptArg_.parse_or_none_(bnd_parser.Xto_gfui(String_.new_utf8_(ipt_bry)));
|
||||
bnd_mgr.Del(bnd, ipt);
|
||||
Xog_bnd_mgr_srl.Update_cfg(app, bnd, box, ipt);
|
||||
uid = -1; box_bry = ipt_bry = null;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.gui.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.xowa.apis.xowa.*;
|
||||
import gplx.xowa.apis.xowa.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xog_cmd_mgr {
|
||||
public void Init_by_kit(Xoa_app app) {
|
||||
invk_mgr.Ctor(app, this);
|
||||
@@ -30,7 +30,7 @@ public class Xog_cmd_mgr {
|
||||
Xol_lang lang = app.User().Lang();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xog_cmd_ctg itm = ary[i];
|
||||
itm.Name_(Pf_msg_mgr.Get_msg_val_gui_or_null(lang, Xog_cmd_itm_.Msg_pre_ctg, itm.Key_bry(), Xog_cmd_itm_.Msg_suf_name));
|
||||
itm.Name_(Xol_msg_mgr_.Get_msg_val_gui_or_null(lang, Xog_cmd_itm_.Msg_pre_ctg, itm.Key_bry(), Xog_cmd_itm_.Msg_suf_name));
|
||||
}
|
||||
}
|
||||
private void Load_cmd_msgs(Xoa_app app) {
|
||||
@@ -38,8 +38,8 @@ public class Xog_cmd_mgr {
|
||||
Xol_lang lang = app.User().Lang();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xog_cmd_itm itm = this.Get_at(i);
|
||||
itm.Name_(Pf_msg_mgr.Get_msg_val_gui_or_null(lang, Xog_cmd_itm_.Msg_pre_api, itm.Key_bry(), Xog_cmd_itm_.Msg_suf_name));
|
||||
itm.Tip_(Pf_msg_mgr.Get_msg_val_gui_or_null(lang, Xog_cmd_itm_.Msg_pre_api, itm.Key_bry(), Xog_cmd_itm_.Msg_suf_tip));
|
||||
itm.Name_(Xol_msg_mgr_.Get_msg_val_gui_or_null(lang, Xog_cmd_itm_.Msg_pre_api, itm.Key_bry(), Xog_cmd_itm_.Msg_suf_name));
|
||||
itm.Tip_(Xol_msg_mgr_.Get_msg_val_gui_or_null(lang, Xog_cmd_itm_.Msg_pre_api, itm.Key_bry(), Xog_cmd_itm_.Msg_suf_tip));
|
||||
}
|
||||
}
|
||||
public int Len() {return Xog_cmd_itm_.Regy_len();}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Xog_mnu_grp extends Xog_mnu_base {
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_build)) this.Build();
|
||||
else if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) this.Enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_source)) return source;
|
||||
else if (ctx.Match(k, Invk_source_)) this.Source_(app.Gfs_mgr(), m.ReadStr("v"));
|
||||
|
||||
@@ -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.gui.menus.dom; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*; import gplx.xowa.gui.menus.*;
|
||||
import gplx.gfui.*; import gplx.xowa.gui.cmds.*;
|
||||
import gplx.gfui.*; import gplx.xowa.gui.cmds.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xog_mnu_itm extends Xog_mnu_base {
|
||||
private Xoa_gui_mgr gui_mgr;
|
||||
public Xog_mnu_itm(Xoa_gui_mgr gui_mgr, String key) {
|
||||
@@ -45,9 +45,9 @@ public class Xog_mnu_itm extends Xog_mnu_base {
|
||||
return this;
|
||||
}
|
||||
public void Init_by_lang(Xol_lang lang) {
|
||||
this.name = Pf_msg_mgr.Get_msg_val_gui_or(lang, Xog_cmd_itm_.Msg_pre_api, key_bry, Xog_cmd_itm_.Msg_suf_name, name); // NOTE: custom cmds must use Get_val_or, not Get_val_or_null; DATE:2014-05-30
|
||||
this.shortcut = Pf_msg_mgr.Get_msg_val_gui_or(lang, Xog_cmd_itm_.Msg_pre_api, key_bry, Xog_cmd_itm_.Msg_suf_letter, shortcut);
|
||||
this.img_nest = Img_nest_of(Pf_msg_mgr.Get_msg_val_gui_or(lang, Xog_cmd_itm_.Msg_pre_api, key_bry, Xog_cmd_itm_.Msg_suf_image, ""));
|
||||
this.name = Xol_msg_mgr_.Get_msg_val_gui_or(lang, Xog_cmd_itm_.Msg_pre_api, key_bry, Xog_cmd_itm_.Msg_suf_name, name); // NOTE: custom cmds must use Get_val_or, not Get_val_or_null; DATE:2014-05-30
|
||||
this.shortcut = Xol_msg_mgr_.Get_msg_val_gui_or(lang, Xog_cmd_itm_.Msg_pre_api, key_bry, Xog_cmd_itm_.Msg_suf_letter, shortcut);
|
||||
this.img_nest = Img_nest_of(Xol_msg_mgr_.Get_msg_val_gui_or(lang, Xog_cmd_itm_.Msg_pre_api, key_bry, Xog_cmd_itm_.Msg_suf_image, ""));
|
||||
this.gui_text = Gui_text_calc(name, shortcut);
|
||||
}
|
||||
public void Init_by_custom(String name, String shortcut, String img_nest_str) {
|
||||
|
||||
@@ -67,15 +67,15 @@ public class Xog_url_wkr {
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_file(Xoa_app app, Xoa_page page, Xog_win_itm win, byte[] href_bry) { // EX: file:///xowa/A.png
|
||||
href_bry = app.Url_converter_url().Decode(href_bry);
|
||||
href_bry = app.Encoder_mgr().Url().Decode(href_bry);
|
||||
Io_url href_url = Io_url_.http_any_(String_.new_utf8_(href_bry), Op_sys.Cur().Tid_is_wnt());
|
||||
gplx.gfui.Gfui_html html_box = win.Active_html_box();
|
||||
String xowa_ttl = page.Wiki().Gui_mgr().Cfg_browser().Content_editable()
|
||||
? html_box.Html_active_atr_get_str(gplx.xowa.html.Xoh_html_tag.Nde_xowa_title_str, null)
|
||||
: Xoh_dom_.Title_by_href(app.Url_converter_comma(), app.Utl_bry_bfr_mkr().Get_b512().Mkr_rls(), href_bry, Bry_.new_utf8_(html_box.Html_doc_html()));
|
||||
: Xoh_dom_.Title_by_href(app.Encoder_mgr().Comma(), app.Utl_bry_bfr_mkr().Get_b512().Mkr_rls(), href_bry, Bry_.new_utf8_(html_box.Html_doc_html()));
|
||||
if (!Io_mgr._.ExistsFil(href_url)) {
|
||||
Xof_xfer_itm xfer_itm = new Xof_xfer_itm();
|
||||
byte[] title = app.Url_converter_url().Decode(Bry_.new_utf8_(xowa_ttl));
|
||||
byte[] title = app.Encoder_mgr().Url().Decode(Bry_.new_utf8_(xowa_ttl));
|
||||
xfer_itm.Atrs_by_lnki(Xop_lnki_type.Id_none, -1, -1, -1, Xof_doc_thumb.Null, Xof_doc_page.Null).Atrs_by_ttl(title, Bry_.Empty);
|
||||
page.Wiki().File_mgr().Find_meta(xfer_itm);
|
||||
page.File_queue().Clear();
|
||||
|
||||
@@ -143,7 +143,7 @@ public class Xog_html_itm implements GfoInvkAble, GfoEvObj {
|
||||
private boolean Scroll_page_by_id(String id) {
|
||||
return (id == null)
|
||||
? false
|
||||
: html_box.Html_elem_scroll_into_view(app.Url_converter_id().Encode_str(id));
|
||||
: html_box.Html_elem_scroll_into_view(app.Encoder_mgr().Id().Encode_str(id));
|
||||
}
|
||||
public void Js_enabled_(boolean v) {
|
||||
html_box.Html_js_enabled_(v);
|
||||
@@ -197,7 +197,7 @@ class Xog_html_itm__href_extractor {
|
||||
;
|
||||
public static String Html_extract_text(String site, String page, String text_str) {
|
||||
byte[] text_bry = Bry_.new_utf8_(text_str);
|
||||
int text_tid = Byte_ascii.X_to_digit(text_bry[0]);
|
||||
int text_tid = Byte_ascii.Xto_digit(text_bry[0]);
|
||||
int text_len = text_bry.length;
|
||||
switch (text_tid) {
|
||||
case Text_tid_none: return "";
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xog_html_js_cbk implements GfoInvkAble {
|
||||
String[] rv = new String[len + 1];
|
||||
rv[0] = Invk_xowa_exec_test_as_array;
|
||||
for (int i = 0; i < len; i++)
|
||||
rv[i + 1] = Object_.XtoStr_OrEmpty(m.ReadValAt(i));
|
||||
rv[i + 1] = Object_.Xto_str_strict_or_empty(m.ReadValAt(i));
|
||||
return rv;
|
||||
}
|
||||
private String Parse_to_html(GfoMsg m) {
|
||||
@@ -75,7 +75,7 @@ public class Xog_html_js_cbk implements GfoInvkAble {
|
||||
}
|
||||
private String Popups_get_html(GfoMsg m) {
|
||||
try {
|
||||
int popups_id = Int_.X_by_double_(Double_.cast_(m.Args_getAt(0).Val()));
|
||||
int popups_id = Int_.Xby_double_(Double_.cast_(m.Args_getAt(0).Val()));
|
||||
byte[] href_bry = m.Args_getAt(1).Val_to_bry();
|
||||
return html_itm.Owner_tab().Page().Wiki().Html_mgr().Module_mgr().Popup_mgr().Show_init(href_bry, popups_id);
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
@@ -164,7 +164,7 @@ public class Xog_html_js_cbk implements GfoInvkAble {
|
||||
rv = app.Gfs_mgr().Run_str(m.Args_getAt(0).Val_to_str_or_empty());
|
||||
}
|
||||
catch (Exception e) {Err_.Noop(e); return null;}
|
||||
return Object_.XtoStr_OrEmpty(rv);
|
||||
return Object_.Xto_str_strict_or_empty(rv);
|
||||
}
|
||||
private static final byte[] Wikidata_get_label_xowa_ui_lang = Bry_.new_ascii_("xowa_ui_lang"), Wikidata_get_label_xowa_title = Bry_.new_ascii_("xowa_title");
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
106
400_xowa/src/gplx/xowa/gui/views/Xog_launcher_tabs.java
Normal file
106
400_xowa/src/gplx/xowa/gui/views/Xog_launcher_tabs.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
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.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
class Xog_launcher_tabs {
|
||||
public void Launch(Xog_win_itm win) {
|
||||
Xoa_app app = win.App(); Gfo_log_bfr log_bfr = app.Log_bfr();
|
||||
log_bfr.Add("app.launch.page.bgn");
|
||||
Io_fil_marker fil_marker = new Io_fil_marker().Usr_dlg_(app.Usr_dlg()).Url_(app.User().Fsys_mgr().App_temp_dir().GenSubFil_nest("session", "launch.tabs.marker"));
|
||||
boolean tabs_restored = false;
|
||||
Xow_wiki home_wiki = app.User().Wiki();
|
||||
if (fil_marker.Bgn())
|
||||
tabs_restored = Restore_tabs(app, home_wiki, win, fil_marker);
|
||||
if (!tabs_restored)
|
||||
Restore_tab_failover(app, home_wiki, win);
|
||||
// tab.Html_itm().Html_box().Focus(); // focus the html_box so wheel scroll works; DATE:2013-02-08
|
||||
app.Gui_wtr().Prog_none("", "", "");
|
||||
log_bfr.Add("app.launch.page.end");
|
||||
app.Gui_wtr().Log_wtr().Log_msg_to_session_direct(log_bfr.Xto_str());
|
||||
}
|
||||
private boolean Restore_tabs(Xoa_app app, Xow_wiki home_wiki, Xog_win_itm win, Io_fil_marker fil_marker) {
|
||||
Xog_tab_itm tab = win.Active_tab();
|
||||
String[] launch_urls = app.Api_root().App().Startup().Tabs().Calc_startup_strs();
|
||||
try {
|
||||
int launch_urls_len = launch_urls.length;
|
||||
for (int i = 0; i < launch_urls_len; ++i) {
|
||||
String launch_url = launch_urls[i];
|
||||
tab = i == 0 ? win.Active_tab() : win.Tab_mgr().Tabs_new_init();
|
||||
Launch_tab(tab, win, home_wiki, launch_url);
|
||||
}
|
||||
fil_marker.End();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "failed to launch urls: urls=~{0} err=~{1}", String_.AryXtoStr(launch_urls), Err_.Message_gplx(e));
|
||||
Restore_tab_failover(app, home_wiki, win);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private void Restore_tab_failover(Xoa_app app, Xow_wiki home_wiki, Xog_win_itm win) {
|
||||
Launch_tab(win.Active_tab(), win, home_wiki, gplx.xowa.users.Xouc_pages_mgr.Page_xowa);
|
||||
}
|
||||
private void Launch_tab(Xog_tab_itm tab, Xog_win_itm win, Xow_wiki home_wiki, String launch_str) {
|
||||
Xoa_page launch_page = Launch_page(win, home_wiki, launch_str);
|
||||
if (launch_page.Missing()) return;
|
||||
Xog_tab_itm_read_mgr.Show_page(tab, launch_page, false);
|
||||
tab.History_mgr().Add(launch_page);
|
||||
}
|
||||
private Xoa_page Launch_page(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());
|
||||
Xoa_page rv = launch_wiki.GetPageByTtl(launch_url, launch_ttl).Url_(launch_url); // FUTURE: .Url_() should not be called (needed for anchor); EX: en.wikipedia.org/Earth#Biosphere
|
||||
win.Active_page_(rv); // set to blank page
|
||||
return rv;
|
||||
}
|
||||
public static final Xog_launcher_tabs _ = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
|
||||
}
|
||||
class Io_fil_marker {
|
||||
private Io_url url;
|
||||
private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_._;
|
||||
public Io_fil_marker Usr_dlg_(Gfo_usr_dlg v) {this.usr_dlg = v; return this;}
|
||||
public Io_fil_marker Url_(Io_url url) {this.url = url; return this;}
|
||||
public boolean Bgn() {
|
||||
boolean rv = false;
|
||||
synchronized (this) {
|
||||
try {
|
||||
rv = !Io_mgr._.ExistsFil(url); // exists = fail; !exists = pass;
|
||||
if (rv) // pass: file does not exist;
|
||||
Io_mgr._.SaveFilStr(url, ""); // create
|
||||
else // file exists from previous run
|
||||
Io_mgr._.DeleteFil(url); // delete
|
||||
}
|
||||
catch (Exception exc) { // something unexpected happened
|
||||
usr_dlg.Warn_many("", "", "marker.bgn failed: url=~{0} err=~{1}", url.Raw(), Err_.Message_gplx(exc));
|
||||
Io_mgr._.DeleteFil(url); // try to delete it again
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void End() {
|
||||
synchronized (this) {
|
||||
try {
|
||||
Io_mgr._.DeleteFil(url); // delete
|
||||
}
|
||||
catch (Exception exc) {
|
||||
usr_dlg.Warn_many("", "", "marker.end failed: url=~{0} err=~{1}", url.Raw(), Err_.Message_gplx(exc));
|
||||
Io_mgr._.DeleteFil(url); // try to delete it again
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user