mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.3.1
This commit is contained in:
@@ -21,4 +21,9 @@ public class Json_itm_ {
|
||||
public static final byte Tid_unknown = 0, Tid_null = 1, Tid_bool = 2, Tid_int = 3, Tid_decimal = 4, Tid_string = 5, Tid_kv = 6, Tid_array = 7, Tid_nde = 8;
|
||||
public static final byte[][] Names = Bry_.Ary("unknown", "null", "boolean", "int", "decimal", "string", "keyval", "array", "nde");
|
||||
public static final byte[] Const_true = Bry_.new_a7("true"), Const_false = Bry_.new_a7("false"), Const_null = Bry_.new_a7("null");
|
||||
public static byte[] To_bry(Bry_bfr bfr, Json_itm itm) {
|
||||
if (itm == null) return Bry_.Empty;
|
||||
itm.Print_as_json(bfr, 0);
|
||||
return bfr.Xto_bry_and_clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ public class Json_kv extends Json_itm_base {
|
||||
@Override public byte Tid() {return Json_itm_.Tid_kv;}
|
||||
public Json_itm Key() {return key;} Json_itm key;
|
||||
public Json_itm Val() {return val;} Json_itm val;
|
||||
public Json_nde Val_as_nde() {return Json_nde.cast_(val);}
|
||||
public Json_ary Val_as_ary() {return Json_ary.cast(val);}
|
||||
public byte[] Key_as_bry() {return key.Data_bry();}
|
||||
public String Key_as_str() {return (String)key.Data();}
|
||||
public byte[] Val_as_bry() {return val.Data_bry();}
|
||||
|
||||
@@ -31,6 +31,7 @@ public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
return rv;
|
||||
}
|
||||
public Json_itm Get_at(int i) {return subs[i];}
|
||||
public Json_kv Get_kv(byte[] key) {return Json_kv.cast_(Get_itm(key));}
|
||||
public Json_nde Get(String key) {return Get(Bry_.new_u8(key));}
|
||||
public Json_nde Get(byte[] key) {
|
||||
Json_kv kv = Json_kv.cast_(this.Get_itm(key)); if (kv == null) throw Err_.new_("json", "kv not found", "key", key);
|
||||
@@ -48,6 +49,7 @@ public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public boolean Has(byte[] key) {return Get_bry(key, null) != null;}
|
||||
public byte[] Get_bry(byte[] key) {
|
||||
byte[] rv = Get_bry(key, null); if (rv == null) throw Err_.new_("json", "key missing", "key", key);
|
||||
return rv;
|
||||
@@ -60,8 +62,7 @@ public class Json_nde extends Json_itm_base implements Json_grp {
|
||||
if (kv_obj.Tid() != Json_itm_.Tid_kv) return or; // key is not a key_val
|
||||
Json_kv kv = (Json_kv)kv_obj;
|
||||
Json_itm val = kv.Val();
|
||||
if (val == null) return or;
|
||||
return val.Data_bry();
|
||||
return (val == null) ? or : val.Data_bry();
|
||||
}
|
||||
public Json_nde Add_many(Json_itm... ary) {
|
||||
int len = ary.length;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Json_parser {
|
||||
case Byte_ascii.Brack_bgn: return Make_ary(doc);
|
||||
case Byte_ascii.Curly_bgn: return Make_nde(doc);
|
||||
}
|
||||
throw Err_.new_unhandled(Char_.XtoStr(b));
|
||||
throw Err_.new_unhandled(Char_.To_str(b));
|
||||
}
|
||||
throw Err_.new_wo_type("eos reached in val");
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class Json_parser {
|
||||
if (src[pos] == expd)
|
||||
++pos;
|
||||
else
|
||||
throw err_(src, pos, "expected '{0}' but got '{1}'", Char_.XtoStr(expd), Char_.XtoStr(src[pos]));
|
||||
throw err_(src, pos, "expected '{0}' but got '{1}'", Char_.To_str(expd), Char_.To_str(src[pos]));
|
||||
}
|
||||
Err err_(byte[] src, int bgn, String fmt, Object... args) {return err_(src, bgn, src.length, fmt, args);}
|
||||
Err err_(byte[] src, int bgn, int src_len, String fmt, Object... args) {
|
||||
|
||||
55
400_xowa/src/gplx/core/logs/Gfo_log_fil.java
Normal file
55
400_xowa/src/gplx/core/logs/Gfo_log_fil.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.logs; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_log_fil {
|
||||
private final Bry_bfr fil_bfr = Bry_bfr.new_(), msg_bfr = Bry_bfr.new_();
|
||||
private final String key;
|
||||
private final Io_url dir;
|
||||
private final long size_max;
|
||||
private int file_idx;
|
||||
private Io_url fil_cur;
|
||||
private final Gfo_log_fmtr fmtr = new Gfo_log_fmtr();
|
||||
private final Gfo_log_fil session;
|
||||
public Gfo_log_fil(Gfo_log_fil session, String key, Io_url dir, long size_max) {
|
||||
this.session = session;
|
||||
this.key = key;
|
||||
this.dir = dir;
|
||||
this.size_max = size_max;
|
||||
this.fil_cur = Fil_new();
|
||||
}
|
||||
public void Add(String msg, Object... vals) {
|
||||
fmtr.Add(msg_bfr, msg, vals);
|
||||
Add_by_bfr(msg_bfr);
|
||||
msg_bfr.Clear();
|
||||
}
|
||||
public void Add_by_bfr(Bry_bfr msg_bfr) {
|
||||
if (msg_bfr.Len() + fil_bfr.Len() > size_max) {
|
||||
this.Flush();
|
||||
fil_cur = Fil_new();
|
||||
}
|
||||
fil_bfr.Add_bfr_and_preserve(msg_bfr);
|
||||
if (session != null) session.Add_by_bfr(msg_bfr);
|
||||
}
|
||||
public void Flush() {
|
||||
Io_mgr.I.AppendFilBfr(fil_cur, fil_bfr);
|
||||
}
|
||||
private Io_url Fil_new() {
|
||||
String part = size_max == -1 ? "" : "-" + Int_.Xto_str(++file_idx);
|
||||
return dir.OwnerDir().GenSubFil_ary(key, part, ".log");
|
||||
}
|
||||
}
|
||||
58
400_xowa/src/gplx/core/logs/Gfo_log_fmtr.java
Normal file
58
400_xowa/src/gplx/core/logs/Gfo_log_fmtr.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.logs; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.btries.*;
|
||||
class Gfo_log_fmtr {
|
||||
private final Btrie_fast_mgr trie = Btrie_fast_mgr.cs()
|
||||
.Add("~|" , Bry_.new_a7("~|<"))
|
||||
.Add("|" , Bry_.new_a7("~||"))
|
||||
.Add("\n" , Bry_.new_a7("~|n"))
|
||||
.Add("\t" , Bry_.new_a7("~|t"))
|
||||
;
|
||||
public void Add(Bry_bfr bfr, String msg, Object... vals) {
|
||||
Add_bry(bfr, Bry_.new_u8(msg));
|
||||
int len = vals.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
bfr.Add_byte(Byte_ascii.Pipe);
|
||||
byte[] val_bry = Bry_.new_u8(Object_.Xto_str_strict_or_empty(vals[i]));
|
||||
Add_bry(bfr, val_bry);
|
||||
}
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
private void Add_bry(Bry_bfr bfr, byte[] src) {
|
||||
if (src == null) return;
|
||||
int len = src.length; if (len == 0) return;
|
||||
int pos = 0;
|
||||
int add_bgn = -1;
|
||||
while (true) {
|
||||
if (pos == len) break;
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, len);
|
||||
if (o == null) {
|
||||
if (add_bgn == -1) add_bgn = pos;
|
||||
}
|
||||
else {
|
||||
if (add_bgn != -1) bfr.Add_mid(src, add_bgn, pos);
|
||||
byte[] repl = (byte[])o;
|
||||
bfr.Add(repl);
|
||||
pos = trie.Match_pos();
|
||||
}
|
||||
}
|
||||
if (add_bgn != -1) bfr.Add_mid(src, add_bgn, len);
|
||||
}
|
||||
}
|
||||
55
400_xowa/src/gplx/core/logs/Gfo_log_mgr.java
Normal file
55
400_xowa/src/gplx/core/logs/Gfo_log_mgr.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.logs; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_log_mgr {
|
||||
private final Ordered_hash fil_list = Ordered_hash_.new_();
|
||||
private final Gfo_log_fil session_fil;
|
||||
private final Io_url dir;
|
||||
private final long size_dflt = Io_mgr.Len_mb * 2;
|
||||
public Gfo_log_mgr(Io_url dir) {
|
||||
this.dir = dir;
|
||||
this.session_fil = new Gfo_log_fil(null, "session", dir, -1);
|
||||
}
|
||||
public Gfo_log_fil Fils__get_or_new(String key) {
|
||||
Gfo_log_fil rv = (Gfo_log_fil)fil_list.Get_by(key);
|
||||
if (rv == null) {
|
||||
rv = new Gfo_log_fil(session_fil, key, dir, size_dflt);
|
||||
fil_list.Add(key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Msgs__add(String fil_key, String msg, Object... vals) {
|
||||
Gfo_log_fil fil = (Gfo_log_fil)Fils__get_or_new(fil_key);
|
||||
fil.Add(msg, vals);
|
||||
}
|
||||
}
|
||||
// class Some_log_cls {
|
||||
// private final Gfo_log_mgr log_mgr = new Gfo_log_mgr();
|
||||
// public void Init() {
|
||||
// }
|
||||
// private Gfo_log_fil dedicated;
|
||||
// public void Init_dedicated() {
|
||||
// dedicated = log_mgr.Fil_get_or_new("parse");
|
||||
// }
|
||||
// public void Proc_w_dedicate() {
|
||||
// dedicated.Add("file download failed", "url", "msg");
|
||||
// }
|
||||
// public void Proc_dynamic() {
|
||||
// log_mgr.Msg_add("parse", "file download failed", "url", "msg");
|
||||
// }
|
||||
// }
|
||||
@@ -57,7 +57,7 @@ public class Http_request_parser {
|
||||
if (Bry_.Has_at_end(line, Tkn_content_type_boundary_end)) break; // last form_data pair will end with "--"; stop
|
||||
line = Parse_content_type_boundary(rdr);
|
||||
}
|
||||
break; // assume form_data ends POST request
|
||||
break; // assume form_data sends POST request
|
||||
}
|
||||
Object o = trie.Match_bgn(line, 0, line_len);
|
||||
if (o == null) {
|
||||
@@ -101,7 +101,8 @@ public class Http_request_parser {
|
||||
this.protocol = Bry_.Mid(line, url_end + 1, line_len);
|
||||
}
|
||||
private void Parse_content_type(int val_bgn, byte[] line, int line_len) { // EX: Content-Type: multipart/form-data; boundary=---------------------------72432484930026
|
||||
int boundary_bgn = Bry_finder.Find_fwd(line, Tkn_boundary, val_bgn, line_len); if (boundary_bgn == Bry_finder.Not_found) throw Err_.new_wo_type("invalid content_type", "line", line, "request", To_str());
|
||||
// handle wolfram and other clients; DATE:2015-08-03
|
||||
int boundary_bgn = Bry_finder.Find_fwd(line, Tkn_boundary, val_bgn, line_len); if (boundary_bgn == Bry_finder.Not_found) return; // PURPOSE: ignore content-type for GET calls like by Mathematica server; DATE:2015-08-04 // throw Err_.new_wo_type("invalid content_type", "line", line, "request", To_str());
|
||||
int content_type_end = Bry_finder.Find_bwd(line, Byte_ascii.Semic, boundary_bgn);
|
||||
this.content_type = Bry_.Mid(line, val_bgn, content_type_end);
|
||||
this.content_type_boundary = Bry_.Add(Tkn_content_type_boundary_end, Bry_.Mid(line, boundary_bgn += Tkn_boundary.length, line_len));
|
||||
|
||||
@@ -25,6 +25,9 @@ public class Http_request_parser_tst {
|
||||
@Test public void Type_content_type() {
|
||||
fxt.Test_content_type("Content-Type: multipart/form-data; boundary=---------------------------72432484930026", "multipart/form-data", "-----------------------------72432484930026");
|
||||
}
|
||||
@Test public void Type_content_type__x_www_form_url_encoded() { // PURPOSE: ignore content-type for GET calls like by Mathematica server; DATE:2015-08-04
|
||||
fxt.Test_content_type("Content-Type: application/x-www-form-urlencoded", null, null);
|
||||
}
|
||||
@Test public void Type_form_data() {
|
||||
fxt.Test_form_data(String_.Ary
|
||||
( "POST /url HTTP/1.1"
|
||||
|
||||
@@ -52,8 +52,8 @@ public class Db_cfg_itm {
|
||||
public static Db_cfg_itm new_yn (String grp, String key, boolean val) {return new Db_cfg_itm(grp , key, Yn.Xto_str(val));}
|
||||
public static Db_cfg_itm new_DateAdp (String key, DateAdp val) {return new Db_cfg_itm(Grp_none , key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public static Db_cfg_itm new_DateAdp (String grp, String key, DateAdp val) {return new Db_cfg_itm(grp , key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public static Db_cfg_itm new_guid (String key, Guid_adp val) {return new Db_cfg_itm(Grp_none , key, val.XtoStr());}
|
||||
public static Db_cfg_itm new_guid (String grp, String key, Guid_adp val) {return new Db_cfg_itm(grp , key, val.XtoStr());}
|
||||
public static Db_cfg_itm new_guid (String key, Guid_adp val) {return new Db_cfg_itm(Grp_none , key, val.To_str());}
|
||||
public static Db_cfg_itm new_guid (String grp, String key, Guid_adp val) {return new Db_cfg_itm(grp , key, val.To_str());}
|
||||
|
||||
public static final Db_cfg_itm Empty = new Db_cfg_itm("empty", "empty", null);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
public void Insert_int (String grp, String key, int val) {Insert_str(grp, key, Int_.Xto_str(val));}
|
||||
public void Insert_long (String grp, String key, long val) {Insert_str(grp, key, Long_.Xto_str(val));}
|
||||
public void Insert_date (String grp, String key, DateAdp val) {Insert_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public void Insert_guid (String grp, String key, Guid_adp val) {Insert_str(grp, key, val.XtoStr());}
|
||||
public void Insert_guid (String grp, String key, Guid_adp val) {Insert_str(grp, key, val.To_str());}
|
||||
public void Insert_bry (String grp, String key, byte[] val) {Insert_str(grp, key, String_.new_u8(val));}
|
||||
public void Insert_str (String grp, String key, String val) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
@@ -56,7 +56,7 @@ public class Db_cfg_tbl implements RlsAble {
|
||||
public void Update_int (String grp, String key, int val) {Update_str(grp, key, Int_.Xto_str(val));}
|
||||
public void Update_long (String grp, String key, long val) {Update_str(grp, key, Long_.Xto_str(val));}
|
||||
public void Update_date (String grp, String key, DateAdp val) {Update_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public void Update_guid (String grp, String key, Guid_adp val) {Update_str(grp, key, val.XtoStr());}
|
||||
public void Update_guid (String grp, String key, Guid_adp val) {Update_str(grp, key, val.To_str());}
|
||||
public void Update_bry (String grp, String key, byte[] val) {Update_str(grp, key, String_.new_u8(val));}
|
||||
public void Update_str (String grp, String key, String val) {
|
||||
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_grp, fld_key);
|
||||
|
||||
@@ -44,6 +44,8 @@ public class Fsdb_db_mgr_ {
|
||||
if (!Db_conn_bldr.I.Exists(main_core_url)) return null;
|
||||
usr_dlg.Log_many("", "", "fsdb.db_core.v2: type=~{0} url=~{1}", layout.Name(), main_core_url.Raw());
|
||||
Db_conn main_core_conn = Db_conn_bldr.I.Get(main_core_url);
|
||||
if (wiki.Data__core_mgr().Props().Layout_file().Tid_is_all())
|
||||
return new Fsdb_db_mgr__v2(Fsdb_db_mgr__v2.Cfg__layout_file__get(main_core_conn), wiki_dir, new Fsdb_db_file(main_core_url, main_core_conn), new Fsdb_db_file(main_core_url, main_core_conn));
|
||||
Io_url user_core_url = wiki_dir.GenSubFil(Fsdb_db_mgr__v2_bldr.Make_user_name(domain_str));
|
||||
if (!Db_conn_bldr.I.Exists(user_core_url)) // if user file does not exist, create it; needed b/c offline packages don't include file; DATE:2015-04-19
|
||||
Fsdb_db_mgr__v2_bldr.I.Make_core_file_user(wiki, user_core_url, user_core_url.NameAndExt(), main_core_url.NameAndExt());
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Fsdb_db_mgr__v2_bldr {
|
||||
private Fsdb_db_file Load_core_file(Io_url url) {return new Fsdb_db_file(url, Db_conn_bldr.I.Get(url));}
|
||||
private Fsdb_db_file Make_core_file_main(Xow_wiki wiki, Io_url main_core_url, String main_core_name, Xowd_db_layout layout) {
|
||||
Db_conn conn = layout.Tid_is_all() ? Db_conn_bldr.I.Get(main_core_url) : Db_conn_bldr.I.New(main_core_url); // if all, use existing (assumes same file name); else, create new
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("fsdb__core_file");
|
||||
Fsdb_db_file rv = Make_core_file(main_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_main);
|
||||
if (!layout.Tid_is_all()) // do not make cfg data if all
|
||||
Make_cfg_data(wiki, main_core_name, rv, Main_core_tid(layout), -1);
|
||||
@@ -50,7 +50,7 @@ public class Fsdb_db_mgr__v2_bldr {
|
||||
}
|
||||
public Fsdb_db_file Make_core_file_user(Xow_wiki wiki, Io_url user_core_url, String user_file_name, String main_core_name) { // always create file; do not create mnt_tbl;
|
||||
Db_conn conn = Db_conn_bldr.I.New(user_core_url);
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("fsdb__core_user");
|
||||
Fsdb_db_file rv = Make_core_file(user_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_user);
|
||||
Fsm_bin_tbl dbb_tbl = new Fsm_bin_tbl(conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_user); dbb_tbl.Insert(0, user_file_name);
|
||||
Make_bin_tbl(rv);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Fsd_bin_tbl implements RlsAble {
|
||||
stmt_select = Db_stmt_.Rls(stmt_select);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn(); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_bgn() {conn.Txn_bgn("fsdb_bin__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_commit() {conn.Txn_sav();}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_rdr(int id, byte tid, long bin_len, Io_stream_rdr bin_rdr) {
|
||||
|
||||
@@ -29,6 +29,6 @@ public class Fsm_atr_mgr {
|
||||
public Fsm_atr_fil Db__core() {return db__core;}
|
||||
public Fsd_fil_itm Select_fil_or_null(byte[] dir, byte[] fil) {return db__core.Select_fil_or_null(dir, fil);}
|
||||
public boolean Select_thm(boolean exact, Fsd_thm_itm rv, int dir_id, int fil_id) {return db__core.Select_thm(exact, rv, dir_id, fil_id);}
|
||||
public void Txn_bgn() {db__core.Conn().Txn_bgn();}
|
||||
public void Txn_bgn() {db__core.Conn().Txn_bgn("fsdb__fsm_atr_mgr");}
|
||||
public void Txn_end() {db__core.Conn().Txn_end();}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Fsm_bin_mgr {
|
||||
}
|
||||
public void Txn_bgn() {
|
||||
for (int i = 0; i < dbs__ary_len; ++i)
|
||||
dbs__ary[i].Conn().Txn_bgn();
|
||||
dbs__ary[i].Conn().Txn_bgn("fsdb__meta__bin");
|
||||
}
|
||||
public void Txn_end() {
|
||||
for (int i = 0; i < dbs__ary_len; ++i)
|
||||
|
||||
@@ -69,7 +69,7 @@ class Gfs_msg_bldr_fxt {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (i != 0) sb.Add_char_crlf();
|
||||
sb.Add(ary[i].XtoStr());
|
||||
sb.Add(ary[i].To_str());
|
||||
}
|
||||
return sb.Xto_str_and_clear();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Gfs_parser {
|
||||
}
|
||||
class Gfs_parser_ {
|
||||
public static Btrie_fast_mgr trie_() {
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.ci_ascii_(); // NOTE:ci.ascii:gfs;letters/symbols only;
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.ci_a7(); // NOTE:ci.ascii:gfs;letters/symbols only;
|
||||
Gfs_lxr_identifier word_lxr = Gfs_lxr_identifier._;
|
||||
trie_add_rng(rv, word_lxr, Byte_ascii.Ltr_a, Byte_ascii.Ltr_z);
|
||||
trie_add_rng(rv, word_lxr, Byte_ascii.Ltr_A, Byte_ascii.Ltr_Z);
|
||||
|
||||
@@ -66,10 +66,10 @@ class Gfs_parser_ctx {
|
||||
}
|
||||
class Gfs_err_mgr {
|
||||
public void Fail_eos(Gfs_parser_ctx ctx) {Fail(ctx, Fail_msg_eos, ctx.Src_len());}
|
||||
public void Fail_unknown_char(Gfs_parser_ctx ctx, int pos, byte c) {Fail(ctx, Fail_msg_unknown_char, pos, KeyVal_.new_("char", Char_.XtoStr((char)c)));}
|
||||
public void Fail_unknown_char(Gfs_parser_ctx ctx, int pos, byte c) {Fail(ctx, Fail_msg_unknown_char, pos, KeyVal_.new_("char", Char_.To_str((char)c)));}
|
||||
public void Fail_nde_stack_empty(Gfs_parser_ctx ctx, int pos) {Fail(ctx, Fail_msg_nde_stack_empty, pos);}
|
||||
public void Fail_invalid_lxr(Gfs_parser_ctx ctx, int pos, byte cur_lxr, byte c) {
|
||||
Fail(ctx, Fail_msg_invalid_lxr, pos, KeyVal_.new_("char", Char_.XtoStr((char)c)), KeyVal_.new_("cur_lxr", Gfs_lxr_.Tid__name(cur_lxr)), KeyVal_.new_("prv_lxr", Gfs_lxr_.Tid__name(ctx.Prv_lxr())));
|
||||
Fail(ctx, Fail_msg_invalid_lxr, pos, KeyVal_.new_("char", Char_.To_str((char)c)), KeyVal_.new_("cur_lxr", Gfs_lxr_.Tid__name(cur_lxr)), KeyVal_.new_("prv_lxr", Gfs_lxr_.Tid__name(ctx.Prv_lxr())));
|
||||
}
|
||||
private void Fail(Gfs_parser_ctx ctx, String msg, int pos, KeyVal... args) {
|
||||
byte[] src = ctx.Src(); int src_len = ctx.Src_len();
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Php_srl_parser {
|
||||
switch (b) {
|
||||
case Byte_ascii.Num_1: rv = factory.Bool_y(); break;
|
||||
case Byte_ascii.Num_0: rv = factory.Bool_n(); break;
|
||||
default: throw err_(raw, pos, raw_len, "unknown boolean type {0}", Char_.XtoStr(b));
|
||||
default: throw err_(raw, pos, raw_len, "unknown boolean type {0}", Char_.To_str(b));
|
||||
}
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Semic);
|
||||
break;
|
||||
@@ -139,7 +139,7 @@ public class Php_srl_parser {
|
||||
rv = factory.Func(func_bgn, pos, func_id);
|
||||
pos += 2;
|
||||
break;
|
||||
default: throw err_(raw, pos, "unexpected type: {0}", Char_.XtoStr(b));
|
||||
default: throw err_(raw, pos, "unexpected type: {0}", Char_.To_str(b));
|
||||
}
|
||||
return rv;
|
||||
} static final byte[] CONST_funct_bgn = Bry_.new_a7("O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:"), CONST_funct_end = Bry_.new_a7(";}");
|
||||
@@ -165,7 +165,7 @@ public class Php_srl_parser {
|
||||
if (actl == expd)
|
||||
return i + 1;
|
||||
else
|
||||
throw err_(raw, i, "expected '{0}' but got '{1}'", Char_.XtoStr(expd), Char_.XtoStr(actl));
|
||||
throw err_(raw, i, "expected '{0}' but got '{1}'", Char_.To_str(expd), Char_.To_str(actl));
|
||||
}
|
||||
int Skip_while_num(byte[] raw, int raw_len, int bgn, boolean num_is_int) {
|
||||
int num_len = 1;
|
||||
|
||||
@@ -30,15 +30,15 @@ public class Dsv_tbl_parser_int_tst {
|
||||
);
|
||||
}
|
||||
}
|
||||
class Mok_int_itm implements XtoStrAble {
|
||||
class Mok_int_itm implements To_str_able {
|
||||
private String fld_0;
|
||||
private int fld_1, fld_2;
|
||||
public Mok_int_itm(String fld_0, int fld_1, int fld_2) {this.fld_0 = fld_0; this.fld_1 = fld_1; this.fld_2 = fld_2;}
|
||||
public String XtoStr() {return String_.Concat_with_str("|", fld_0, Int_.Xto_str(fld_1), Int_.Xto_str(fld_2));}
|
||||
public String To_str() {return String_.Concat_with_str("|", fld_0, Int_.Xto_str(fld_1), Int_.Xto_str(fld_2));}
|
||||
}
|
||||
class Mok_int_mgr extends Mok_mgr_base {
|
||||
public void Clear() {itms.Clear();}
|
||||
@Override public XtoStrAble[] Itms() {return (XtoStrAble[])itms.To_ary(XtoStrAble.class);} private List_adp itms = List_adp_.new_();
|
||||
@Override public To_str_able[] Itms() {return (To_str_able[])itms.To_ary(To_str_able.class);} private List_adp itms = List_adp_.new_();
|
||||
private String fld_0;
|
||||
private int fld_1, fld_2;
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Dsv_tbl_parser_str_tst {
|
||||
}
|
||||
}
|
||||
abstract class Mok_mgr_base extends Dsv_wkr_base {
|
||||
public abstract XtoStrAble[] Itms();
|
||||
public abstract To_str_able[] Itms();
|
||||
}
|
||||
class Dsv_mok_fxt {
|
||||
private Dsv_tbl_parser tbl_parser = new Dsv_tbl_parser();
|
||||
@@ -67,15 +67,15 @@ class Dsv_mok_fxt {
|
||||
public Mok_mgr_base mgr_str_(int len) {return new Mok_str_mgr(len);}
|
||||
public Mok_str_itm itm_str_(String... flds) {return new Mok_str_itm(flds);}
|
||||
public Mok_int_itm itm_int_(String fld_0, int fld_1, int fld_2) {return new Mok_int_itm(fld_0, fld_1, fld_2);}
|
||||
public void Test_load(String src, Mok_mgr_base mgr, XtoStrAble... expd) {
|
||||
public void Test_load(String src, Mok_mgr_base mgr, To_str_able... expd) {
|
||||
mgr.Load_by_bry(Bry_.new_u8(src));
|
||||
Tfds.Eq_ary_str(expd, mgr.Itms());
|
||||
}
|
||||
}
|
||||
class Mok_str_itm implements XtoStrAble {
|
||||
class Mok_str_itm implements To_str_able {
|
||||
private String[] flds;
|
||||
public Mok_str_itm(String[] flds) {this.flds = flds;}
|
||||
public String XtoStr() {return String_.Concat_with_str("|", flds);}
|
||||
public String To_str() {return String_.Concat_with_str("|", flds);}
|
||||
}
|
||||
class Mok_str_mgr extends Mok_mgr_base {
|
||||
private int flds_len;
|
||||
@@ -83,7 +83,7 @@ class Mok_str_mgr extends Mok_mgr_base {
|
||||
this.flds_len = flds_len;
|
||||
}
|
||||
public void Clear() {itms.Clear();}
|
||||
@Override public XtoStrAble[] Itms() {return (XtoStrAble[])itms.To_ary(XtoStrAble.class);} private List_adp itms = List_adp_.new_();
|
||||
@Override public To_str_able[] Itms() {return (To_str_able[])itms.To_ary(To_str_able.class);} private List_adp itms = List_adp_.new_();
|
||||
private List_adp flds = List_adp_.new_();
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
flds.Add(String_.new_u8(src, bgn, end));
|
||||
|
||||
@@ -19,16 +19,48 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.consoles.*; import gplx.dbs.*; import gplx.ios.*; import gplx.gfui.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.langs.*; import gplx.xowa.users.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.html.hdumps.*; import gplx.xowa.html.hdumps.core.*;
|
||||
import gplx.xowa.gui.views.boots.*;
|
||||
import gplx.xowa.urls.encoders.*;
|
||||
public class Xoa_app_ {
|
||||
public static void Run(String... args) {
|
||||
Xoa_app_boot_mgr boot_mgr = new Xoa_app_boot_mgr();
|
||||
boot_mgr.Run(args);
|
||||
try {
|
||||
Xoa_app_boot_mgr boot_mgr = new Xoa_app_boot_mgr();
|
||||
boot_mgr.Run(args);
|
||||
} catch (Error e) {
|
||||
String err_text = e.toString();
|
||||
String err_details = String_.Concat_lines_nl_skip_last
|
||||
( "OS: " + Op_sys.Cur().Os_name()
|
||||
, "Java: " + Env_.Env_prop__java_version() + " (" + Op_sys.Cur().Bitness_str() + " bit)"
|
||||
, "Java path: " + Env_.Env_prop("java.home")
|
||||
, "XOWA: " + Version
|
||||
, "XOWA path: " + Env_.AppUrl().Raw()
|
||||
, ""
|
||||
, "Error: " + err_text
|
||||
, "Stack: " + Err_.Trace_lang(e)
|
||||
);
|
||||
String full_msg = String_.Concat_lines_nl_skip_last
|
||||
( "Sorry! XOWA failed to run!"
|
||||
, ""
|
||||
, "Please check the TROUBLESHOOTING section in the readme.txt for known issues."
|
||||
, ""
|
||||
, "You can also open an issue or send an email with the data below."
|
||||
, ""
|
||||
, "Thanks!"
|
||||
, ""
|
||||
, "----"
|
||||
, err_details
|
||||
);
|
||||
if (Op_sys.Cur().Tid_is_osx())
|
||||
Console_adp__sys.I.Write_str(err_text);
|
||||
else
|
||||
new Xog_error_win(new Xog_error_data(full_msg, err_details, err_text));
|
||||
Gfo_usr_dlg_.I.Log_many("", "", err_details);
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.8.1.1";
|
||||
public static final String Version = "2.8.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
public static final Gfo_msg_grp Nde = Gfo_msg_grp_.prj_(Name);
|
||||
public static Gfo_usr_dlg usr_dlg_console_() {
|
||||
@@ -65,7 +97,7 @@ class Xoa_app_boot_mgr {
|
||||
Io_url jar_url = Env_.AppUrl();
|
||||
Xoa_app_.Build_date = Io_mgr.I.QueryFil(jar_url).ModifiedTime().XtoUtc().XtoStr_fmt("yyyy-MM-dd HH:mm");
|
||||
log_wtr.Log_to_session_fmt("env.init: jar_url=~{0}; build_date=~{1}", jar_url.NameAndExt(), Xoa_app_.Build_date);
|
||||
log_wtr.Log_to_session_fmt("env.init: op_sys=~{0}", Op_sys.Cur().Xto_str());
|
||||
log_wtr.Log_to_session_fmt("env.init: op_sys=~{0}", Op_sys.Cur().To_str());
|
||||
chkpoint = "init_env";
|
||||
return true;
|
||||
}
|
||||
@@ -86,7 +118,7 @@ class Xoa_app_boot_mgr {
|
||||
, App_cmd_arg.opt_("wiki_dir").Example_url_("C:\\xowa\\wiki\\").Note_("directory for wikis; defaults to '/xowa/wiki/'")
|
||||
, App_cmd_arg.opt_("bin_dir_name").Example_("windows").Note_("platform-dependent directory name inside /xowa/bin/; valid values are 'linux', 'macosx', 'windows', 'linux_64', 'macosx_64', 'windows_64'; defaults to detected version")
|
||||
, App_cmd_arg.opt_("app_mode").Example_("gui").Note_("type of app to run; valid values are 'gui', 'cmd', 'server', 'http_server'; defaults to 'gui'")
|
||||
, App_cmd_arg.opt_("cmd_file").Example_url_("C:\\xowa\\xowa.gfs").Note_("file_path of script to execute; defaults to 'xowa.gfs'")
|
||||
, App_cmd_arg.opt_("cmd_file").Example_url_("C:\\xowa\\bin\\any\\xowa\\cfg\\app\\xowa.gfs").Note_("file_path of script to execute; defaults to 'xowa.gfs'")
|
||||
, App_cmd_arg.opt_("cmd_text").Example_("\"app.shell.fetch_page('en.wikipedia.org/wiki/Earth', 'html');\"").Note_("script to run; runs after cmd_file; does nothing if empty; default is empty.\nCurrently a useful cmd is to do 'java -jar xowa_your_platform.jar --app_mode cmd --show_license n --show_args n --cmd_text \"app.shell.fetch_page('en.wikipedia.org/wiki/Earth' 'html');\"'. This will output the page's html to the console. You can also change 'html' to 'wiki' to get the wikitext.")
|
||||
, App_cmd_arg.opt_("url").Example_("en.wikipedia.org/wiki/Earth").Note_("url to be shown when xowa first launches; default is home/wiki/Main_Page")
|
||||
, App_cmd_arg.opt_("server_port_recv").Example_("55000").Note_("applies to --app_mode server; port where xowa server will receive messages; clients should send messages to this port")
|
||||
@@ -124,22 +156,23 @@ class Xoa_app_boot_mgr {
|
||||
Io_url root_dir = args_mgr.Args_get("root_dir").Val_as_url_rel_dir_or(jar_dir, jar_dir);
|
||||
Io_url user_dir = args_mgr.Args_get("user_dir").Val_as_url_rel_dir_or(root_dir.GenSubDir("user"), root_dir.GenSubDir_nest("user", Xoue_user.Key_xowa_user));
|
||||
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"));
|
||||
Io_url cmd_file = args_mgr.Args_get("cmd_file").Val_as_url_rel_fil_or(jar_dir, root_dir.GenSubFil_nest("bin", "any", "xowa", "cfg" ,"app", "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(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);
|
||||
String http_server_home = args_mgr.Args_get("http_server_home").Val_as_str_or("home/wiki/Main_Page");
|
||||
Xoa_app_.Op_sys = args_mgr.Args_get("bin_dir_name").Val_as_str_or(Bin_dir_name());
|
||||
Xoa_app_.User_agent = String_.Format("XOWA/{0} ({1}) [gnosygnu@gmail.com]", Xoa_app_.Version, Xoa_app_.Op_sys);
|
||||
Xoa_app_.Op_sys_str = args_mgr.Args_get("bin_dir_name").Val_as_str_or(Bin_dir_name());
|
||||
Xoa_app_.User_agent = String_.Format("XOWA/{0} ({1}) [gnosygnu@gmail.com]", Xoa_app_.Version, Xoa_app_.Op_sys_str);
|
||||
String cmd_text = args_mgr.Args_get("cmd_text").Val_as_str_or(null);
|
||||
Xoa_app_type app_type = Xoa_app_type.parse(app_mode);
|
||||
app_type_is_gui = app_type.Uid_is_gui();
|
||||
Xog_splash_win splash_win = new Xog_splash_win(app_type_is_gui);
|
||||
|
||||
// init app
|
||||
Db_conn_bldr.I.Reg_default_sqlite();
|
||||
app = new Xoae_app(usr_dlg, app_type, root_dir, wiki_dir, root_dir.GenSubDir("file"), user_dir, root_dir.GenSubDir_nest("user", "anonymous", "wiki"), Xoa_app_.Op_sys);
|
||||
app = new Xoae_app(usr_dlg, app_type, root_dir, wiki_dir, root_dir.GenSubDir("file"), user_dir, root_dir.GenSubDir_nest("user", "anonymous", "wiki"), Xoa_app_.Op_sys_str);
|
||||
usr_dlg.Log_wkr().Queue_enabled_(false); log_wtr.Log_to_session_fmt("app.init");
|
||||
try {
|
||||
app.Sys_cfg().Lang_(System_lang());
|
||||
@@ -175,7 +208,7 @@ class Xoa_app_boot_mgr {
|
||||
Console_adp__sys.I.Write_str_w_nl_utf8(Object_.Xto_str_strict_or_empty(app.Gfs_mgr().Run_str(cmd_text)));
|
||||
}
|
||||
if (app_type_is_gui) {
|
||||
app.Gui_mgr().Run(); chkpoint = "run";
|
||||
app.Gui_mgr().Run(splash_win); chkpoint = "run";
|
||||
}
|
||||
else // teardown app, else lua will keep process running
|
||||
if (gplx.xowa.xtns.scribunto.Scrib_core.Core() != null) gplx.xowa.xtns.scribunto.Scrib_core.Core().Term();
|
||||
|
||||
@@ -59,6 +59,14 @@ public class Xoa_app_fxt {
|
||||
app.File_mgr().Repo_mgr().Set("trg:c", "mem/wiki/repo/trg/", "commons.wikimedia.org").Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2).Primary_(true);
|
||||
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_a7("src:c"), Bry_.new_a7("trg:c"));
|
||||
}
|
||||
public static void repo2_(Xoae_app app, Xowe_wiki wiki) {
|
||||
app.File_mgr().Repo_mgr().Set("src:wiki", "mem/http/en.wikipedia.org/" , wiki.Domain_str()).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
|
||||
app.File_mgr().Repo_mgr().Set("trg:wiki", "mem/file/en.wikipedia.org/" , wiki.Domain_str()).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2).Primary_(true);
|
||||
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_a7("src:wiki"), Bry_.new_a7("trg:wiki"));
|
||||
app.File_mgr().Repo_mgr().Set("src:comm", "mem/http/commons.wikimedia.org/" , "commons.wikimedia.org").Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
|
||||
app.File_mgr().Repo_mgr().Set("trg:comm", "mem/file/commons.wikimedia.org/" , "commons.wikimedia.org").Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2).Primary_(true);
|
||||
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_a7("src:comm"), Bry_.new_a7("trg:comm"));
|
||||
}
|
||||
public static void Init_gui(Xoae_app app, Xowe_wiki wiki) {
|
||||
app.Gui_mgr().Browser_win().Init_by_kit(gplx.gfui.Mem_kit._);
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_init(wiki, Xoae_page.Empty);
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Xoa_url {
|
||||
public byte[] To_bry(boolean full, boolean show_qargs) { // currently used for status bar; not embedded in any html
|
||||
switch (tid) {
|
||||
case Xoa_url_.Tid_unknown: // unknown; should not occur?
|
||||
return Bry_.Len_eq_0(raw) ? Bry_.Add(wiki_bry, Byte_ascii.Slash_bry, page_bry) : raw; // raw is empty when using new_();
|
||||
return Bry_.Len_eq_0(raw) ? Bry_.Add(wiki_bry, Xoh_href_.Bry__wiki, page_bry) : raw; // raw is empty when using new_();
|
||||
case Xoa_url_.Tid_inet: // protocol; embed all; EX: "http://a.org/A"; "file:///C/dir/file.txt"
|
||||
case Xoa_url_.Tid_file: // file; EX: "file:///C:/A/B.jpg"
|
||||
return raw;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Xoapi_root implements GfoInvkAble {
|
||||
app_api.Ctor_by_app(app);
|
||||
usr_api.Ctor_by_app(app);
|
||||
bldr_api.Ctor_by_app(app);
|
||||
html_api.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
|
||||
@@ -18,14 +18,17 @@ 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.apis.xowa.html.*;
|
||||
public class Xoapi_html implements GfoInvkAble {
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
page.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
tidy.Init_by_kit(app);
|
||||
modules.Init_by_kit(app);
|
||||
}
|
||||
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 Xoapi_page Page() {return page;} private Xoapi_page page = new Xoapi_page();
|
||||
public Xoapi_tidy Tidy() {return tidy;} private final Xoapi_tidy tidy = new Xoapi_tidy();
|
||||
public Xoapi_modules Modules() {return modules;} private final Xoapi_modules modules = new Xoapi_modules();
|
||||
public Xoapi_skins Skins() {return skins;} private final Xoapi_skins skins = new Xoapi_skins();
|
||||
public Xoapi_page Page() {return page;} private final Xoapi_page page = new Xoapi_page();
|
||||
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;
|
||||
|
||||
@@ -18,7 +18,10 @@ 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.core.btries.*;
|
||||
public class Xoapi_page implements GfoInvkAble {
|
||||
public Xoapi_toggle_mgr Toggle_mgr() {return toggle_mgr;} private Xoapi_toggle_mgr toggle_mgr = new Xoapi_toggle_mgr();
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
toggle_mgr.Ctor_by_app(app);
|
||||
}
|
||||
public Xoapi_toggle_mgr Toggle_mgr() {return toggle_mgr;} private final Xoapi_toggle_mgr toggle_mgr = new Xoapi_toggle_mgr();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_toggles)) return toggle_mgr;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
|
||||
@@ -17,29 +17,24 @@ 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.*;
|
||||
public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
public Xoapi_toggle_itm(byte[] key_bry) {this.key_bry = key_bry;}
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
private final Xoae_app app; // NOTE: needed to get "img_dir" below
|
||||
private byte[] img_title_val_y, img_title_val_n;
|
||||
public Xoapi_toggle_itm(Xoae_app app, byte[] key_bry) {
|
||||
this.app = app; this.key_bry = key_bry;
|
||||
}
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
|
||||
public byte[] Heading_bry() {return heading_bry;} private byte[] heading_bry;
|
||||
public byte[] Icon_src() {return icon_src;} private byte[] icon_src = Bry_.Empty;
|
||||
public byte[] Icon_title() {return icon_title;} private byte[] icon_title = Bry_.Empty;
|
||||
public byte[] Elem_display() {return elem_display;} private byte[] elem_display = Bry_.Empty;
|
||||
public byte[] Html_toggle_hdr_cls() {return html_toggle_hdr_cls;} public Xoapi_toggle_itm Html_toggle_hdr_cls_(byte[] v) {html_toggle_hdr_cls = v; return this;} private byte[] html_toggle_hdr_cls = Bry_.Empty;
|
||||
public boolean Visible() {return visible;} private boolean visible;
|
||||
public Xoapi_toggle_itm Init(Xowe_wiki wiki, byte[] heading_bry) {
|
||||
if (Img_src_y == null) {
|
||||
Io_url img_dir = wiki.Appe().Usere().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "portal");
|
||||
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
|
||||
Img_src_n = img_dir.GenSubFil("twisty_right.png").To_http_file_bry();
|
||||
}
|
||||
icon_src = visible ? Img_src_y : Img_src_n;
|
||||
byte[] img_title_msg = visible ? Img_title_msg_y : Img_title_msg_n;
|
||||
icon_title = wiki.Msg_mgr().Val_by_key_obj(img_title_msg);
|
||||
elem_display = visible ? Img_display_y : Img_display_n;
|
||||
this.heading_bry = heading_bry;
|
||||
public Xoapi_toggle_itm Init(byte[] heading_bry) {
|
||||
this.heading_bry = heading_bry; // NOTE: sets "Wikis" or "In other languages"; Wikidata twisties are empty;
|
||||
this.icon_title = app.Usere().Msg_mgr().Val_by_key_obj(visible ? Img_title_msg_y : Img_title_msg_n); // set title ("show" or "hide")
|
||||
Html_toggle_gen();
|
||||
return this;
|
||||
}
|
||||
private byte[] img_title_val_y, img_title_val_n;
|
||||
public Xoapi_toggle_itm Init_fsys(Io_url img_dir) {
|
||||
if (Img_src_y == null) {
|
||||
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
|
||||
@@ -54,7 +49,15 @@ public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
}
|
||||
public byte[] Html_toggle_btn() {return html_toggle_btn;} private byte[] html_toggle_btn;
|
||||
public byte[] Html_toggle_hdr() {return html_toggle_hdr;} private byte[] html_toggle_hdr;
|
||||
private void Html_toggle_gen() {
|
||||
private void Assert_img_src() {
|
||||
if (Img_src_y == null) {
|
||||
Io_url img_dir = app.Usere().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "portal");
|
||||
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
|
||||
Img_src_n = img_dir.GenSubFil("twisty_right.png").To_http_file_bry();
|
||||
}
|
||||
}
|
||||
private void Html_toggle_gen() {
|
||||
Assert_img_src();// NOTE: must call Assert_img_src else wikidata twisties will be missing img; DATE:2015-08-05
|
||||
if (visible) {
|
||||
icon_src = Img_src_y;
|
||||
icon_title = img_title_val_y;
|
||||
@@ -77,7 +80,7 @@ public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_visible)) return Yn.Xto_str(visible);
|
||||
else if (ctx.Match(k, Invk_visible_)) {this.visible = m.ReadYn("v"); Html_toggle_gen();}
|
||||
else if (ctx.Match(k, Invk_visible_)) this.visible = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ 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.cfgs.*;
|
||||
public class Xoapi_toggle_mgr implements GfoInvkAble {
|
||||
private Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
private Xoae_app app;
|
||||
private final Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
public void Ctor_by_app(Xoae_app app) {this.app = app;}
|
||||
public Xoapi_toggle_itm Get_or_new(String key_str) {
|
||||
byte[] key_bry = Bry_.new_u8(key_str);
|
||||
Xoapi_toggle_itm rv = (Xoapi_toggle_itm)hash.Get_by(key_bry);
|
||||
if (rv == null) {
|
||||
rv = new Xoapi_toggle_itm(key_bry);
|
||||
rv = new Xoapi_toggle_itm(app, key_bry);
|
||||
hash.Add(key_bry, rv);
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
|
||||
else if (String_.Eq(type, "xowa_cfg_custom")) url = usr_fsys_mgr.App_data_cfg_custom_fil();
|
||||
else if (String_.Eq(type, "xowa_cfg_user")) url = usr_fsys_mgr.App_data_cfg_user_fil();
|
||||
else if (String_.Eq(type, "xowa_cfg_os")) {url = app_fsys_mgr.Bin_data_os_cfg_fil(); Xoa_gfs_mgr_.Cfg_os_assert(url);}
|
||||
else if (String_.Eq(type, "xowa_cfg_app")) url = app_fsys_mgr.Root_dir().GenSubFil("xowa.gfs");
|
||||
else if (String_.Eq(type, "xowa_cfg_app")) url = app_fsys_mgr.Cfg_app_fil();
|
||||
else throw Err_.new_wo_type("invalid gfs type", "type", type);
|
||||
try {Run_url(url);}
|
||||
catch (Exception e) { // gfs is corrupt; may happen if multiple XOWAs opened, and "Close all" chosen in OS; DATE:2014-07-01
|
||||
|
||||
@@ -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.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xoa_fsys_mgr implements GfoInvkAble {
|
||||
public Xoa_fsys_mgr(String plat_name, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url css_dir) {
|
||||
this.root_dir = root_dir;
|
||||
@@ -25,9 +26,12 @@ public class Xoa_fsys_mgr implements GfoInvkAble {
|
||||
this.bin_plat_dir = root_dir.GenSubDir("bin").GenSubDir(plat_name);
|
||||
this.bin_any_dir = root_dir.GenSubDir("bin").GenSubDir("any");
|
||||
this.bin_xowa_dir = bin_any_dir.GenSubDir("xowa");
|
||||
this.bin_xtns_dir = bin_any_dir.GenSubDir_nest("xowa", "xtns");
|
||||
this.cfg_lang_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "lang", "core");
|
||||
this.cfg_wiki_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "wiki", "core");
|
||||
this.bin_xtns_dir = bin_xowa_dir.GenSubDir_nest("xtns");
|
||||
this.cfg_app_fil = bin_xowa_dir.GenSubFil_nest("cfg", "app", "xowa.gfs");
|
||||
this.cfg_lang_core_dir = bin_xowa_dir.GenSubDir_nest("cfg", "lang", "core");
|
||||
this.cfg_wiki_core_dir = bin_xowa_dir.GenSubDir_nest("cfg", "wiki", "core");
|
||||
this.cfg_site_meta_fil = bin_xowa_dir.GenSubDir_nest("cfg", "wiki", "site_meta.sqlite3");
|
||||
this.home_wiki_dir = bin_xowa_dir.GenSubDir_nest("wiki", Xow_domain_.Domain_str_home);
|
||||
}
|
||||
public Io_url Root_dir() {return root_dir;} private final Io_url root_dir;
|
||||
public Io_url Wiki_dir() {return wiki_dir;} private final Io_url wiki_dir;
|
||||
@@ -39,9 +43,12 @@ public class Xoa_fsys_mgr implements GfoInvkAble {
|
||||
public Io_url Bin_xtns_dir() {return bin_xtns_dir;} private final Io_url bin_xtns_dir;
|
||||
public Io_url Cfg_lang_core_dir() {return cfg_lang_core_dir;} private final Io_url cfg_lang_core_dir;
|
||||
public Io_url Cfg_wiki_core_dir() {return cfg_wiki_core_dir;} private final Io_url cfg_wiki_core_dir;
|
||||
public Io_url Cfg_site_meta_fil() {return cfg_site_meta_fil;} private final Io_url cfg_site_meta_fil;
|
||||
public Io_url Bin_data_os_cfg_fil() {return bin_plat_dir.GenSubFil_nest("xowa", "cfg", Xoa_gfs_mgr.Cfg_os);}
|
||||
public Io_url Wiki_css_dir(String wiki) {return css_dir.GenSubDir_nest(wiki, "html");} // EX: /xowa/temp/simple.wikipedia.org/html/xowa_common.css
|
||||
public Io_url Wiki_file_dir(String wiki) {return file_dir.GenSubDir_nest(wiki);} // EX: /xowa/temp/simple.wikipedia.org/orig/
|
||||
public Io_url Home_wiki_dir() {return home_wiki_dir;} private final Io_url home_wiki_dir;
|
||||
public Io_url Cfg_app_fil() {return cfg_app_fil;} private final Io_url cfg_app_fil;
|
||||
public void Init_by_app(GfoInvkAble app_mgr_invk) {this.app_mgr_invk = app_mgr_invk;} private GfoInvkAble app_mgr_invk; // for gfs and app.launcher
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_apps)) return app_mgr_invk;
|
||||
|
||||
@@ -18,11 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.apps.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.wmfs.data.*;
|
||||
public class Xoa_ns_mgr {
|
||||
private final Xoa_app app;
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private Xowmf_site_tbl wmf_site_tbl; private Xowmf_ns_tbl wmf_ns_tbl;
|
||||
private Site_core_db core_db;
|
||||
public Xoa_ns_mgr(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
@@ -30,20 +31,10 @@ public class Xoa_ns_mgr {
|
||||
public Xow_ns_mgr Get_or_load(byte[] wiki_domain) {
|
||||
Xow_ns_mgr rv = (Xow_ns_mgr)hash.Get_by_bry(wiki_domain);
|
||||
if (rv == null) {
|
||||
rv = Load(wiki_domain);
|
||||
if (core_db == null) core_db = new Site_core_db(app.Fsys_mgr().Cfg_site_meta_fil());
|
||||
rv = core_db.Load_ns(wiki_domain);
|
||||
Add(wiki_domain, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private Xow_ns_mgr Load(byte[] wiki_domain) {
|
||||
Xow_ns_mgr rv = new Xow_ns_mgr(Xol_case_mgr_.U8());
|
||||
if (wmf_site_tbl == null) {
|
||||
Db_conn conn = Xowmf_site_tbl.Get_conn_or_new(app.Fsys_mgr().Root_dir());
|
||||
wmf_site_tbl = new Xowmf_site_tbl(conn);
|
||||
wmf_ns_tbl = new Xowmf_ns_tbl(conn);
|
||||
}
|
||||
int site_id = wmf_site_tbl.Select_id(String_.new_u8(wiki_domain));
|
||||
wmf_ns_tbl.Select_all(rv, site_id);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Xob_cmd_keys {
|
||||
, Key_wbase_qid = "wbase.qid" // "text.wdata.qid"
|
||||
, Key_wbase_pid = "wbase.pid" // "text.wdata.pid"
|
||||
, Key_wbase_db = "wbase.db" // "wiki.wdata_db"
|
||||
, Key_wbase_ns = "wbase.ns"
|
||||
, Key_site_meta = "util.site_meta"
|
||||
, Key_tdb_text_init = "tdb.text.init" // "core.init"
|
||||
, Key_tdb_make_page = "tdb.text.page" // "core.make_page"
|
||||
, Key_tdb_make_id = "core.make_id"
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Xob_cmd_mgr implements GfoInvkAble {
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_wbase_qid)) return Xml_rdr_direct_add(wiki, new Xob_wdata_qid_sql().Ctor(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_wbase_pid)) return Xml_rdr_direct_add(wiki, new Xob_wdata_pid_sql().Ctor(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_wbase_db)) return Add(new Xob_wdata_db_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_wbase_ns)) return Add(new Xob_site_ns_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_site_meta)) return Add(new Xob_site_meta_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_tdb_text_init)) return Add(new Xob_init_tdb(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_tdb_make_page)) return Xml_rdr_direct_add(wiki, new Xob_page_txt(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_keys.Key_tdb_make_id)) return Xml_rdr_direct_add(wiki, new Xob_make_id_wkr(bldr, wiki));
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class Xob_ctg_v1_base extends Xob_itm_dump_base implements Xobd_
|
||||
if (delete_temp) Io_mgr.I.DeleteDirDeep(temp_dir);
|
||||
}
|
||||
private Gfo_fld_wtr fld_wtr = Gfo_fld_wtr.xowa_();
|
||||
Btrie_fast_mgr trie = Btrie_fast_mgr.cs_().Add_stub(Tid_brack_end, "]]").Add_stub(Tid_pipe, "|").Add_stub(Tid_nl, "\n").Add_stub(Tid_brack_bgn, "[[");
|
||||
Btrie_fast_mgr trie = Btrie_fast_mgr.cs().Add_stub(Tid_brack_end, "]]").Add_stub(Tid_pipe, "|").Add_stub(Tid_nl, "\n").Add_stub(Tid_brack_bgn, "[[");
|
||||
static final int row_fixed_len = 5 + 1 + 1; // 5=rowId; 1=|; 1=\n
|
||||
List_adp category_list = List_adp_.new_(); Int_obj_ref cur_pos = Int_obj_ref.zero_();
|
||||
static final byte Tid_eos = 0, Tid_brack_end = 1, Tid_pipe = 2, Tid_nl = 3, Tid_brack_bgn = 4;
|
||||
|
||||
@@ -73,14 +73,14 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
this.trg_atr_fil = trg_mnt_itm.Atr_mgr().Db__core();
|
||||
this.trg_cfg_mgr = trg_mnt_itm.Cfg_mgr();
|
||||
bin_db_mgr.Init_by_mnt_mgr(trg_mnt_mgr);
|
||||
trg_atr_fil.Conn().Txn_bgn();
|
||||
trg_atr_fil.Conn().Txn_bgn("bldr__fsdb_make__trg_atr_fil");
|
||||
if (!trg_atr_fil.Conn().Eq(trg_cfg_mgr.Tbl().Conn())) // need to create txn for v1; DATE:2015-07-04
|
||||
trg_cfg_mgr.Tbl().Conn().Txn_bgn();
|
||||
trg_cfg_mgr.Tbl().Conn().Txn_bgn("bldr__fsdb_make__trg_cfg_fil");
|
||||
// bldr_db
|
||||
Xob_db_file bldr_db = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir());
|
||||
this.bldr_conn = bldr_db.Conn();
|
||||
this.bldr_cfg_tbl = bldr_db.Tbl__cfg(); // NOTE: cfg and atr is in same db; use it
|
||||
bldr_cfg_tbl.Conn().Txn_bgn();
|
||||
bldr_cfg_tbl.Conn().Txn_bgn("bldr__fsdb_make__bldr_cfg_tbl");
|
||||
}
|
||||
public void Cmd_run() {
|
||||
Init_bldr_bmks();
|
||||
@@ -129,7 +129,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
Db_cfg_hash bmk_hash = bldr_cfg_tbl.Select_as_hash(Cfg_fsdb_make);
|
||||
String tier_id_str = bmk_hash.Get(Cfg_tier_id_bmk).To_str_or(null);
|
||||
if (tier_id_str == null) { // bmks not found; new db;
|
||||
bldr_conn.Txn_bgn();
|
||||
bldr_conn.Txn_bgn("bldr__fsdb_make__bldr_conn");
|
||||
bldr_cfg_tbl.Insert_int(Cfg_fsdb_make, Cfg_tier_id_bmk , tier_id_bmk);
|
||||
bldr_cfg_tbl.Insert_int(Cfg_fsdb_make, Cfg_page_id_bmk , page_id_bmk);
|
||||
bldr_cfg_tbl.Insert_int(Cfg_fsdb_make, Cfg_lnki_id_bmk , lnki_id_bmk);
|
||||
@@ -227,21 +227,21 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
}
|
||||
private void Make_trg_bin_file(boolean try_nth, Xodb_tbl_oimg_xfer_itm fsdb, long src_rdr_len) {
|
||||
boolean make = true, txn_bgn = true;
|
||||
if (trg_bin_fil != null) { // pre-existing bin_file;
|
||||
if (trg_mnt_itm.Db_mgr().File__solo_file())
|
||||
txn_bgn = false; // solo file; do nothing
|
||||
else
|
||||
trg_bin_fil.Conn().Txn_end(); // close txn before making new db
|
||||
}
|
||||
int tier_id = fsdb.Lnki_tier_id();
|
||||
Xob_bin_db_itm nth_bin_db = bin_db_mgr.Get_nth_by_tier(tier_id);
|
||||
if (try_nth) { // try_nth is true; occurs for new runs or changed tier
|
||||
if ( nth_bin_db.Id() != -1 // nth exists;
|
||||
if (try_nth) { // try_nth is true; occurs for new runs or changed tier
|
||||
if ( nth_bin_db.Id() != -1 // nth exists;
|
||||
&& nth_bin_db.Db_len() + src_rdr_len < trg_bin_db_max) { // if src_rdr_len exceeds
|
||||
make = false; // do not make; use existing
|
||||
txn_bgn = false;
|
||||
make = false; // do not make; use existing
|
||||
}
|
||||
}
|
||||
if (make) { // no nth; make it;
|
||||
if (trg_bin_fil != null) { // pre-existing bin_file;
|
||||
trg_bin_fil.Conn().Txn_end(); // close txn before making new db
|
||||
if (trg_mnt_itm.Db_mgr().File__solo_file())
|
||||
txn_bgn = false;
|
||||
}
|
||||
if (make) { // no nth; make it;
|
||||
int ns_id = bin_db_mgr.Get_ns_id(tier_id);
|
||||
int pt_id = bin_db_mgr.Increment_pt_id(nth_bin_db);
|
||||
String new_bin_db_name = bin_db_mgr.Gen_name(wiki.Domain_str(), ns_id, pt_id);
|
||||
@@ -252,12 +252,12 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
Fsdb_db_mgr__v2_bldr.Make_cfg_data(wiki, trg_atr_fil.Url_rel(), trg_bin_db, Xowd_db_file_.Tid_file_data, trg_bin_fil.Id() + List_adp_.Base1);
|
||||
}
|
||||
}
|
||||
else { // nth available; use it
|
||||
else { // nth available; use it
|
||||
this.trg_bin_fil = trg_mnt_itm.Bin_mgr().Dbs__get_at(nth_bin_db.Id());
|
||||
trg_bin_fil.Bin_len_(nth_bin_db.Db_len());
|
||||
}
|
||||
if (txn_bgn)
|
||||
trg_bin_fil.Conn().Txn_bgn();
|
||||
trg_bin_fil.Conn().Txn_bgn("bldr__fsdb_make__trg_bin_fil");
|
||||
}
|
||||
private void Txn_sav() {
|
||||
usr_dlg.Prog_many("", "", "committing data: count=~{0} failed=~{1}", exec_count, exec_fail);
|
||||
|
||||
@@ -40,7 +40,7 @@ class Xob_lnki_temp_tbl {
|
||||
public Xob_lnki_temp_tbl(Db_conn conn) {this.conn = conn;}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(Tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn(); stmt_insert = conn.Stmt_insert(Tbl_name, flds);}
|
||||
public void Insert_bgn() {conn.Txn_bgn("bldr__lnki_temp"); stmt_insert = conn.Stmt_insert(Tbl_name, flds);}
|
||||
public void Insert_commit() {conn.Txn_sav();}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int tier_id, int page_id, byte[] ttl, byte[] ttl_commons, byte ext_id, byte img_type, byte lnki_src_tid, int w, int h, double upright, double time, int page) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xob_xfer_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_run() {
|
||||
Db_conn conn = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("bldr__xfer_regy");
|
||||
Xob_xfer_regy_tbl.Create_table(conn);
|
||||
Xob_xfer_regy_tbl.Create_data(usr_dlg, conn);
|
||||
Xob_xfer_regy_tbl.Create_index(usr_dlg, conn);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xob_xfer_regy_update_cmd extends Xob_itm_basic_base implements Xob_
|
||||
Io_url fsdb_atr_url = ((gplx.dbs.engines.sqlite.Sqlite_conn_info)conn.Conn_info()).Url();
|
||||
Sqlite_engine_.Tbl_create_and_delete(make_db_provider, Xob_fsdb_regy_tbl.Tbl_name, Xob_fsdb_regy_tbl.Tbl_sql);
|
||||
Sqlite_engine_.Db_attach(make_db_provider, "fsdb_db", fsdb_atr_url.Raw());
|
||||
make_db_provider.Txn_bgn();
|
||||
make_db_provider.Txn_bgn("bldr__xfer_regy_update");
|
||||
make_db_provider.Exec_sql(Xob_fsdb_regy_tbl.Update_regy_nil);
|
||||
make_db_provider.Exec_sql(Xob_fsdb_regy_tbl.Insert_fsdb_fil);
|
||||
String fsdb_thm_tbl = fsdb_abc_mgr.Db_mgr().File__schema_is_1() ? "fsdb_xtn_thm" : "fsdb_thm";
|
||||
@@ -51,7 +51,7 @@ public class Xob_xfer_regy_update_cmd extends Xob_itm_basic_base implements Xob_
|
||||
Sqlite_engine_.Db_detach(make_db_provider, "fsdb_db");
|
||||
}
|
||||
private void Update_status(Db_conn make_db_provider) {
|
||||
make_db_provider.Txn_bgn();
|
||||
make_db_provider.Txn_bgn("bldr__xfer_regy_update_status");
|
||||
make_db_provider.Exec_sql(Xob_fsdb_regy_tbl.Update_regy_fil);
|
||||
make_db_provider.Exec_sql(Xob_fsdb_regy_tbl.Update_regy_thm);
|
||||
make_db_provider.Txn_end();
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xob_xfer_temp_cmd_orig extends Xob_itm_basic_base implements Xob_cm
|
||||
Db_conn conn = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
Xob_xfer_temp_tbl.Create_table(conn);
|
||||
Db_stmt trg_stmt = Xob_xfer_temp_tbl.Insert_stmt(conn);
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("bldr__xfer_temp");
|
||||
DataRdr rdr = conn.Exec_sql_as_rdr(Sql_select);
|
||||
long[] ext_maxs = Calc_ext_max();
|
||||
while (rdr.MoveNextPeer()) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xob_xfer_temp_cmd_thumb extends Xob_itm_basic_base implements Xob_c
|
||||
Db_conn conn = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
Xob_xfer_temp_tbl.Create_table(conn);
|
||||
Db_stmt trg_stmt = Xob_xfer_temp_tbl.Insert_stmt(conn);
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("bldr__xfer_temp_thumb");
|
||||
DataRdr rdr = conn.Exec_sql_as_rdr(Sql_select);
|
||||
Xob_xfer_temp_itm temp_itm = new Xob_xfer_temp_itm();
|
||||
Xof_img_size img_size = new Xof_img_size();
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Xob_css_cmd implements Xob_cmd {
|
||||
usr_dlg.Plog_many("", "", Cmd_key() + ":css_dir; dir=~{0}", css_dir.Raw());
|
||||
wiki.Init_db_mgr(); // NOTE: must follow Install b/c Init_assert also calls Install; else will download any css from db
|
||||
Xowd_db_file core_db = wiki.Db_mgr_as_sql().Core_data_mgr().Db__core();
|
||||
core_db.Conn().Txn_bgn();
|
||||
core_db.Conn().Txn_bgn("bldr__css");
|
||||
core_db.Tbl__css_core().Create_tbl();
|
||||
core_db.Tbl__css_file().Create_tbl();
|
||||
gplx.xowa.html.css.Xowd_css_core_mgr.Set(core_db.Tbl__css_core(), core_db.Tbl__css_file(), css_dir, css_key);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
|
||||
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__text(), db_mgr, import_cfg.Text_db_max());
|
||||
if (redirect_id_enabled) {
|
||||
this.redirect_tbl = new Xob_redirect_tbl(wiki.Fsys_mgr().Root_dir(), Xoa_app_.Utl__encoder_mgr().Http_url_ttl()).Create_table();
|
||||
redirect_tbl.Conn().Txn_bgn();
|
||||
redirect_tbl.Conn().Txn_bgn("bldr__page__redirect");
|
||||
}
|
||||
this.dg_match_mgr = app.Api_root().Bldr().Wiki().Filter().Dansguardian().New_mgr(wiki.Domain_str(), wiki.Fsys_mgr().Root_dir());
|
||||
app.Bldr().Dump_parser().Trie_tab_del_(); // disable swapping 	 for \t
|
||||
|
||||
@@ -15,19 +15,16 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
package gplx.xowa.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.wmfs.*; import gplx.xowa.wmfs.data.*;
|
||||
public class Xob_site_ns_cmd implements Xob_cmd {
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xob_site_meta_cmd implements Xob_cmd {
|
||||
private final Xob_bldr bldr;
|
||||
public Xob_site_ns_cmd(Xob_bldr bldr, Xow_wiki wiki) {this.bldr = bldr;}
|
||||
public String Cmd_key() {return Xob_cmd_keys.Key_wbase_ns;}
|
||||
public Xob_site_meta_cmd(Xob_bldr bldr, Xow_wiki wiki) {this.bldr = bldr;}
|
||||
public String Cmd_key() {return Xob_cmd_keys.Key_site_meta;}
|
||||
public void Cmd_run() {
|
||||
Xow_wmf_api_mgr api_mgr = new Xow_wmf_api_mgr();
|
||||
Db_conn conn = Xowmf_site_tbl.Get_conn_or_new(bldr.App().Fsys_mgr().Root_dir());
|
||||
Xowmf_site_tbl tbl_site = new Xowmf_site_tbl(conn); Xowmf_ns_tbl tbl_itm = new Xowmf_ns_tbl(conn);
|
||||
Xow_wmf_api_wkr__ns api_wkr = new Xow_wmf_api_wkr__ns(tbl_site, tbl_itm);
|
||||
api_mgr.Api_exec(api_wkr);
|
||||
Site_meta_itm.Build_site_meta(bldr.App().Wmf_mgr(), bldr.App().Fsys_mgr().Cfg_site_meta_fil(), Xow_wmf_api_mgr.Wikis, DateAdp_.Now());
|
||||
}
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
@@ -37,7 +37,7 @@ public class Xob_image_cmd extends Xob_itm_dump_base implements Xob_cmd, GfoInvk
|
||||
parser.Src_fil_(src_fil).Trg_fil_gen_(dump_url_gen).Fld_cmd_(this).Flds_req_idx_(20, Fld_img_name, Fld_img_size, Fld_img_width, Fld_img_height, Fld_img_bits, Fld_img_media_type, Fld_img_minor_mime, Fld_img_timestamp);
|
||||
|
||||
this.conn = Xob_db_file.new__wiki_image(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("bldr__image");
|
||||
this.tbl_image = new Xob_image_tbl();
|
||||
tbl_image.Create_table(conn);
|
||||
this.stmt = tbl_image.Insert_stmt(conn);
|
||||
|
||||
@@ -30,6 +30,7 @@ class Xobd_page_dump_tbl {
|
||||
}
|
||||
public void Create_data(Io_url page_db_url, int text_db_id) {
|
||||
conn.Ddl_create_tbl(Db_meta_tbl.new_(Tbl_name, flds));
|
||||
conn.Stmt_delete(Tbl_name).Exec_delete(); // always clear tables again; allows commands to be rerun; DATE:2015-08-04
|
||||
Db_attach_cmd.new_(conn, "page_db", page_db_url)
|
||||
.Add_fmt("text_db_prep.clone_page", Sql_insert_data, text_db_id)
|
||||
.Exec();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xob_redirect_cmd extends Xob_dump_mgr_base {
|
||||
encoder = Xoa_app_.Utl__encoder_mgr().Http_url_ttl();
|
||||
redirect_tbl = new Xob_redirect_tbl(wiki.Fsys_mgr().Root_dir(), Xoa_app_.Utl__encoder_mgr().Http_url_ttl()).Create_table();
|
||||
conn = redirect_tbl.Conn();
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("bldr__redirect");
|
||||
return conn;
|
||||
}
|
||||
@Override protected void Cmd_bgn_end() {}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xoa_css_extractor {
|
||||
Xof_download_wkr download_wkr = app.Wmf_mgr().Download_wkr();
|
||||
this.download_xrg = download_wkr.Download_xrg();
|
||||
css_img_downloader = new Xoa_css_img_downloader().Ctor(usr_dlg, download_wkr, Bry_.new_u8(protocol_prefix));
|
||||
failover_dir = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("html", "xowa", "import");
|
||||
failover_dir = app.Fsys_mgr().Bin_xowa_dir().GenSubDir_nest("html", "css", "failover");
|
||||
url_encoder = Xoa_app_.Utl__encoder_mgr().Http_url();
|
||||
}
|
||||
public void Install(Xow_wiki wiki, String css_key) {
|
||||
|
||||
@@ -42,6 +42,6 @@ class Crt__match_exact implements Criteria {
|
||||
}
|
||||
public void Val_as_obj_(Object v) {Val_as_bry_ary_((byte[][])v);}
|
||||
public void Val_from_args(Hash_adp args) {throw Err_.new_unimplemented();}
|
||||
public String XtoStr() {return String_.Concat_any(this.To_str_name(), " ", String_.Ary(ary));}
|
||||
public String To_str() {return String_.Concat_any(this.To_str_name(), " ", String_.Ary(ary));}
|
||||
public byte Tid_match_exact = 12;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class Dg_log_mgr {
|
||||
tbl_rule.Conn_(conn, created);
|
||||
tbl_page_score.Conn_(conn, created);
|
||||
tbl_page_rule.Conn_(conn, created);
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("dansguardian");
|
||||
}
|
||||
public void Insert_file(Dg_file file) {tbl_file.Insert(file.Id(), file.Rel_path(), file.Lines().length);}
|
||||
public void Insert_rule(Dg_rule rule) {tbl_rule.Insert(rule.File_id(), rule.Id(), rule.Idx(), rule.Score(), Dg_word.Ary_concat(rule.Words(), tmp_bfr, Byte_ascii.Tilde));}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xob_info_file {
|
||||
public String Core_file_name() {return core_file_name;} private final String core_file_name;
|
||||
public String Orig_file_name() {return orig_file_name;} private final String orig_file_name;
|
||||
public void Save(Db_cfg_tbl tbl) {
|
||||
tbl.Conn().Txn_bgn();
|
||||
tbl.Conn().Txn_bgn("make__info__file");
|
||||
tbl.Insert_int (Cfg_grp, Cfg_key__id , id);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__type , type);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__ns_ids , ns_ids);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xob_info_session {
|
||||
public DateAdp Time() {return time;} private final DateAdp time;
|
||||
public Guid_adp Uuid() {return guid;} private final Guid_adp guid;
|
||||
public void Save(Db_cfg_tbl tbl) {
|
||||
tbl.Conn().Txn_bgn();
|
||||
tbl.Conn().Txn_bgn("make__info__session");
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__user , user);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__version , version);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__wiki_domain , wiki_domain);
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.core.btries.*;
|
||||
public class Xob_xml_parser_ {
|
||||
public static Btrie_fast_mgr trie_() {
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.cs_();
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.cs();
|
||||
trie_add(rv, Bry_page_bgn, Id_page_bgn); trie_add(rv, Bry_page_bgn_frag, Id_page_bgn_frag); trie_add(rv, Bry_page_end, Id_page_end);
|
||||
trie_add(rv, Bry_id_bgn, Id_id_bgn); trie_add(rv, Bry_id_bgn_frag, Id_id_bgn_frag); trie_add(rv, Bry_id_end, Id_id_end);
|
||||
trie_add(rv, Bry_title_bgn, Id_title_bgn); trie_add(rv, Bry_title_bgn_frag, Id_title_bgn_frag); trie_add(rv, Bry_title_end, Id_title_end);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class Xof_ext_ {
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean Id_supports_thumbtime(int v) { // identifies if tid supports thumbtime in lnki; EX: [[File:A.ogv|thumbtime=1]];
|
||||
public static boolean Id_supports_time(int v) { // identifies if tid supports thumbtime in lnki; EX: [[File:A.ogv|thumbtime=1]];
|
||||
switch (v) {
|
||||
case Id_ogg: case Id_ogv: case Id_webm: return true;
|
||||
default: return false;
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.consoles.*;
|
||||
public class Xof_file_wkr_ {
|
||||
public static final Url_encoder Md5_decoder = Url_encoder.new_http_url_().Itms_raw_same_many(Byte_ascii.Plus);
|
||||
public static byte[] Md5_fast(byte[] v) {return Bry_.new_a7(gplx.security.HashAlgo_.Md5.CalcHash(Console_adp_.Noop, gplx.ios.IoStream_.ary_(v)));}
|
||||
public static byte[] Md5_(byte[] ttl) {
|
||||
public static byte[] Md5(byte[] ttl) {
|
||||
ttl = Md5_decoder.Decode_lax(Ttl_standardize(ttl));
|
||||
return Xof_file_wkr_.Md5_fast(ttl); // NOTE: md5 is calculated off of url_decoded ttl; EX: A%2Cb is converted to A,b and then md5'd. note that A%2Cb still remains the title
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Xof_fsdb_itm implements Xof_file_itm {
|
||||
this.orig_ext = orig_ext; // NOTE: always use orig_ext since this comes directly from wmf_api; DATE:2015-05-17
|
||||
}
|
||||
public void Init_at_lnki_by_near(int file_w) {
|
||||
this.lnki_w = file_w; this.lnki_h = Xof_img_size.Size_null_deprecated;
|
||||
this.lnki_w = file_w; this.lnki_h = Xof_img_size.Size__neg1;
|
||||
}
|
||||
public void Init_at_html(int exec_tid, Xof_img_size img_size, Xof_repo_itm repo, Xof_url_bldr url_bldr) {
|
||||
Calc_html_size(exec_tid, img_size);
|
||||
@@ -116,6 +116,9 @@ public class Xof_fsdb_itm implements Xof_file_itm {
|
||||
public void Init_at_xfer(int idx, int len) {
|
||||
this.xfer_idx = idx; this.xfer_len = len;
|
||||
}
|
||||
public void Change_repo(byte orig_repo_id, byte[] orig_repo_name) {
|
||||
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
|
||||
}
|
||||
public void File_is_orig_(boolean v) {this.file_is_orig = v;}
|
||||
public void Orig_repo_name_(byte[] v) {orig_repo_name = v;}
|
||||
public void Html_elem_tid_(byte v) {this.html_elem_tid = v;}
|
||||
|
||||
80
400_xowa/src/gplx/xowa/files/Xof_fsdb_itm_fxt.java
Normal file
80
400_xowa/src/gplx/xowa/files/Xof_fsdb_itm_fxt.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
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.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.files.repos.*;
|
||||
public class Xof_fsdb_itm_fxt {
|
||||
private byte[] wiki_abrv;
|
||||
private byte[] lnki_ttl;
|
||||
private byte lnki_type;
|
||||
private double lnki_upright;
|
||||
private int lnki_w;
|
||||
private int lnki_h;
|
||||
private double lnki_time;
|
||||
private int lnki_page;
|
||||
private byte orig_repo_id;
|
||||
private byte[] orig_repo_name;
|
||||
private byte[] orig_ttl;
|
||||
private Xof_ext orig_ext;
|
||||
private int orig_w;
|
||||
private int orig_h;
|
||||
private byte[] orig_redirect;
|
||||
public Xof_fsdb_itm_fxt() {this.Clear();}
|
||||
public void Clear() {
|
||||
this.wiki_abrv = lnki_ttl = null;
|
||||
this.lnki_type = Xop_lnki_type.Id_null;
|
||||
this.lnki_upright = Xof_img_size.Upright_null;
|
||||
this.lnki_w = this.lnki_h = this.orig_w = this.orig_h = Xof_img_size.Size__neg1;
|
||||
this.lnki_h = Xof_img_size.Size__neg1;
|
||||
this.lnki_time = Xof_lnki_time.Null;
|
||||
this.lnki_page = Xof_lnki_page.Null;
|
||||
this.orig_repo_id = Xof_repo_itm_.Repo_null;
|
||||
this.orig_repo_name = orig_ttl = orig_redirect = null;
|
||||
this.orig_ext = null;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Lnki__en_w(String lnki_ttl_str) {
|
||||
this.wiki_abrv = Abrv__en_w;
|
||||
this.lnki_ttl = Bry_.new_u8(lnki_ttl_str);
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Orig__commons__lnki() {
|
||||
this.orig_repo_name = Xow_domain_.Domain_bry_commons;
|
||||
this.orig_repo_id = Xof_repo_itm_.Repo_remote;
|
||||
this.orig_ttl = lnki_ttl;
|
||||
this.orig_ext = Xof_ext_.new_by_ttl_(orig_ttl);
|
||||
this.orig_w = 880;
|
||||
this.orig_w = 440;
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Orig__enwiki__lnki() {
|
||||
this.orig_repo_name = Xow_domain_.Domain_bry_enwiki;
|
||||
this.orig_repo_id = Xof_repo_itm_.Repo_local;
|
||||
this.orig_ttl = lnki_ttl;
|
||||
this.orig_ext = Xof_ext_.new_by_ttl_(orig_ttl);
|
||||
this.orig_w = 880;
|
||||
this.orig_w = 440;
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm Make() {
|
||||
Xof_fsdb_itm rv = new Xof_fsdb_itm();
|
||||
rv.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, wiki_abrv, lnki_ttl, lnki_type, lnki_upright, lnki_w, lnki_h, lnki_time, lnki_page, Xof_patch_upright_tid_.Tid_all);
|
||||
rv.Init_at_orig(orig_repo_id, orig_repo_name, orig_ttl, orig_ext, orig_w, orig_h, orig_redirect);
|
||||
return rv;
|
||||
}
|
||||
private final static byte[] Abrv__en_w = Bry_.new_a7("en.w");
|
||||
}
|
||||
@@ -27,59 +27,63 @@ public class Xof_img_size {
|
||||
file_is_orig = false;
|
||||
}
|
||||
public void Html_size_calc(int exec_tid, int lnki_w, int lnki_h, byte lnki_type, int upright_patch, double lnki_upright, int orig_ext, int orig_w, int orig_h, int thm_dflt_w) {
|
||||
this.Clear(); // always clear before calc; caller should be responsible, but just to be safe.
|
||||
if (Enm_.HasInt(lnki_type, Xop_lnki_type.Id_frame) // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
|
||||
&& lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22
|
||||
html_w = file_w = orig_w;
|
||||
html_h = file_h = orig_h;
|
||||
file_is_orig = Xof_ext_.Orig_file_is_img(orig_ext); // file_is_orig = true, unless svg, ogv, pdf
|
||||
if (file_is_orig)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
return;
|
||||
}
|
||||
html_w = lnki_w; html_h = lnki_h; // set html vals to lnki vals
|
||||
file_is_orig = false;
|
||||
if (html_w == Null && html_h == Null) { // no size set; NOTE: do not default to thumb if only height is set; EX: x900px should have w=0 h=900
|
||||
if (Xop_lnki_type.Id_defaults_to_thumb(lnki_type))
|
||||
html_w = thm_dflt_w;
|
||||
else if ( orig_ext == Xof_ext_.Id_pdf // pdf and viewing on page; default to 220
|
||||
&& exec_tid == Xof_exec_tid.Tid_wiki_page)
|
||||
html_w = thm_dflt_w;
|
||||
else
|
||||
html_w = orig_w;
|
||||
}
|
||||
html_w = Upright_calc(upright_patch, lnki_upright, html_w, lnki_w, lnki_h, lnki_type);
|
||||
if (orig_w == Null) return; // no orig_w; just use html_w and html_h (html_h will likely be -1 and wrong)
|
||||
|
||||
boolean ext_is_svg = orig_ext == Xof_ext_.Id_svg;
|
||||
if (html_w == Xof_img_size.Null) {
|
||||
if ( ext_is_svg // following strange MW logic; REF.MW:Linker.php|makeImageLink|If its a vector image, and user only specifies height, we don't want it to be limited by its "normal" width; DATE: 2013-11-26
|
||||
&& html_h != Xof_img_size.Null)
|
||||
html_w = Svg_max_width;
|
||||
else
|
||||
html_w = orig_w; // html_w missing >>> use orig_w; REF.MW:Linker.php|makeImageLink2|$hp['width'] = $file->getWidth( $page );
|
||||
}
|
||||
if (html_h != Xof_img_size.Null) { // html_h exists; REF.MW:ImageHandler.php|normaliseParams|if ( isset( $params['height'] ) && $params['height'] != -1 ) {
|
||||
if ( (long)html_w * (long)orig_h
|
||||
> (long)html_h * (long)orig_w) // html ratio > orig ratio; recalc html_w; SEE:NOTE_2; NOTE: casting to long to prevent int overflow; [[File:A.png|9999999999x90px]]; DATE:2014-04-26
|
||||
html_w = Calc_w(orig_w, orig_h, html_h);
|
||||
}
|
||||
html_h = Scale_h(orig_w, orig_h, html_w); // calc html_h
|
||||
if ( html_w >= orig_w // html >= orig
|
||||
&& ( Xof_ext_.Orig_file_is_img(orig_ext) // orig is img (ignore for svg, ogv, pdf, etc)
|
||||
|| ext_is_svg && exec_tid == Xof_exec_tid.Tid_wiki_file // limit to size if svg and [[File]] page
|
||||
)
|
||||
) {
|
||||
file_is_orig = true; // use orig img (don't create thumb)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
if (Xop_lnki_type.Id_limits_large_size(lnki_type)) {// do not allow html_w > orig_w; REF.MW:Generic.php|normaliseParams
|
||||
html_w = orig_w;
|
||||
html_h = orig_h;
|
||||
synchronized (this) {
|
||||
this.Clear(); // always clear before calc; caller should be responsible, but just to be safe.
|
||||
if (Xof_ext_.Id_supports_time(orig_ext) && lnki_w == Xof_img_size.Null) // use orig_w if no size specified for video; EX:[[File:A.ogv]] -> [[File:A.ogv|550px]] where 550px is orig_w; DATE:2015-08-07
|
||||
lnki_w = orig_w;
|
||||
if (Enm_.HasInt(lnki_type, Xop_lnki_type.Id_frame) // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
|
||||
&& lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22
|
||||
html_w = file_w = orig_w;
|
||||
html_h = file_h = orig_h;
|
||||
file_is_orig = Xof_ext_.Orig_file_is_img(orig_ext); // file_is_orig = true, unless svg, ogv, pdf
|
||||
if (file_is_orig)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
return;
|
||||
}
|
||||
html_w = lnki_w; html_h = lnki_h; // set html vals to lnki vals
|
||||
file_is_orig = false;
|
||||
if (html_w == Null && html_h == Null) { // no size set; NOTE: do not default to thumb if only height is set; EX: x900px should have w=0 h=900
|
||||
if (Xop_lnki_type.Id_defaults_to_thumb(lnki_type))
|
||||
html_w = thm_dflt_w;
|
||||
else if ( orig_ext == Xof_ext_.Id_pdf // pdf and viewing on page; default to 220
|
||||
&& exec_tid == Xof_exec_tid.Tid_wiki_page)
|
||||
html_w = thm_dflt_w;
|
||||
else
|
||||
html_w = orig_w;
|
||||
}
|
||||
html_w = Upright_calc(upright_patch, lnki_upright, html_w, lnki_w, lnki_h, lnki_type);
|
||||
if (orig_w == Null) return; // no orig_w; just use html_w and html_h (html_h will likely be -1 and wrong)
|
||||
|
||||
boolean ext_is_svg = orig_ext == Xof_ext_.Id_svg;
|
||||
if (html_w == Xof_img_size.Null) {
|
||||
if ( ext_is_svg // following strange MW logic; REF.MW:Linker.php|makeImageLink|If its a vector image, and user only specifies height, we don't want it to be limited by its "normal" width; DATE: 2013-11-26
|
||||
&& html_h != Xof_img_size.Null)
|
||||
html_w = Svg_max_width;
|
||||
else
|
||||
html_w = orig_w; // html_w missing >>> use orig_w; REF.MW:Linker.php|makeImageLink2|$hp['width'] = $file->getWidth( $page );
|
||||
}
|
||||
if (html_h != Xof_img_size.Null) { // html_h exists; REF.MW:ImageHandler.php|normaliseParams|if ( isset( $params['height'] ) && $params['height'] != -1 ) {
|
||||
if ( (long)html_w * (long)orig_h
|
||||
> (long)html_h * (long)orig_w) // html ratio > orig ratio; recalc html_w; SEE:NOTE_2; NOTE: casting to long to prevent int overflow; [[File:A.png|9999999999x90px]]; DATE:2014-04-26
|
||||
html_w = Calc_w(orig_w, orig_h, html_h);
|
||||
}
|
||||
html_h = Scale_h(orig_w, orig_h, html_w); // calc html_h
|
||||
if ( html_w >= orig_w // html >= orig
|
||||
&& ( Xof_ext_.Orig_file_is_img(orig_ext) // orig is img (ignore for svg, ogv, pdf, etc)
|
||||
|| ext_is_svg && exec_tid == Xof_exec_tid.Tid_wiki_file // limit to size if svg and [[File]] page
|
||||
)
|
||||
) {
|
||||
file_is_orig = true; // use orig img (don't create thumb)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
if (Xop_lnki_type.Id_limits_large_size(lnki_type)) {// do not allow html_w > orig_w; REF.MW:Generic.php|normaliseParams
|
||||
html_w = orig_w;
|
||||
html_h = orig_h;
|
||||
}
|
||||
}
|
||||
else { // html < orig
|
||||
file_w = html_w;
|
||||
file_h = html_h;
|
||||
}
|
||||
}
|
||||
else { // html < orig
|
||||
file_w = html_w;
|
||||
file_h = html_h;
|
||||
}
|
||||
}
|
||||
// private static boolean Calc_limit_size(int exec_tid, int lnki_type, int lnki_ext) {
|
||||
@@ -135,7 +139,7 @@ public class Xof_img_size {
|
||||
public static final int Null = -1;
|
||||
public static final int Thumb_width_img = 220, Thumb_width_ogv = 220;
|
||||
public static final double Upright_null = -1, Upright_default_marker = 0; // REF:MW: if ( isset( $fp['upright'] ) && $fp['upright'] == 0 )
|
||||
public static final int Size_null_deprecated = -1, Size_null = 0; // Size_null = 0, b/c either imageMagick / inkscape fails when -1 is passed
|
||||
public static final int Size__neg1 = -1, Size_null = 0; // Size_null = 0, b/c either imageMagick / inkscape fails when -1 is passed
|
||||
public static final int Size__same_as_orig = -1;
|
||||
private static final int Svg_max_width = 2048;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xof_img_size_tst {
|
||||
public class Xof_img_size_tst {
|
||||
private final Xof_img_size_fxt fxt = new Xof_img_size_fxt();
|
||||
@Before public void init() {
|
||||
fxt.Reset();
|
||||
fxt.Orig_(400, 200);
|
||||
} private Xof_img_size_fxt fxt = new Xof_img_size_fxt();
|
||||
}
|
||||
@Test public void Lnki_lt_orig_null() {fxt.Lnki_type_(Xop_lnki_type.Id_null) .Lnki_(200, 100).Test_html(200, 100, Bool_.N);} // [[File:A.png|200px]] -> 200,100; File_is_orig = n
|
||||
@Test public void Lnki_lt_orig_thumb() {fxt.Lnki_type_(Xop_lnki_type.Id_thumb) .Lnki_(200, 100).Test_html(200, 100, Bool_.N);} // [[File:A.png|thumb|200px]] -> 200,100; File_is_orig = n
|
||||
@Test public void Lnki_lt_orig_frameless() {fxt.Lnki_type_(Xop_lnki_type.Id_frameless) .Lnki_(200, 100).Test_html(200, 100, Bool_.N);} // [[File:A.png|frameless|200px]] -> 200,100; File_is_orig = n
|
||||
@@ -77,6 +78,9 @@ public class Xof_img_size_tst {
|
||||
@Test public void Frame_and_thumb(){ // PURPOSE: frame and thumb should be treated as frame; Enm.Has(val, Id_frame) vs val == Id_frame; PAGE:en.w:History_of_Western_Civilization; DATE:2015-04-16
|
||||
fxt.Lnki_type_(Enm_.Add_byte(Xop_lnki_type.Id_frame, Xop_lnki_type.Id_thumb)).Lnki_(200, -1).Test_html(400, 200, Bool_.Y); // mut return same as Lnki_lt_orig_frame above
|
||||
}
|
||||
@Test public void Video__use_orig_w(){ // PURPOSE: video should use orig_w; DATE:2015-08-07
|
||||
fxt.Lnki_type_(Xop_lnki_type.Id_none).Lnki_ext_(Xof_ext_.Id_ogv).Lnki_(-1, -1).Orig_(500, 250).Test_html(500, 250, Bool_.N);
|
||||
}
|
||||
}
|
||||
class Xof_img_size_fxt {
|
||||
private Xof_img_size img_size = new Xof_img_size();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xof_lnki_time {
|
||||
public static boolean Null_n(double v) {return v != Null;}
|
||||
public static final int Null_as_int = -1;
|
||||
|
||||
public static double Convert_to_xowa_thumbtime (int ext, double val) {return Xof_ext_.Id_supports_thumbtime(ext) ? val : Null;}
|
||||
public static double Convert_to_xowa_thumbtime (int ext, double val) {return Xof_ext_.Id_supports_time(ext) ? val : Null;}
|
||||
public static int Convert_to_xowa_page (int ext, double val) {return Xof_ext_.Id_supports_page(ext) ? (int)val : Xof_lnki_page.Null;}
|
||||
public static double Convert_to_fsdb_thumbtime (int ext, double thumbtime, int page) {
|
||||
return page != Xof_lnki_page.Null
|
||||
|
||||
@@ -50,10 +50,11 @@ public class Xof_url_bldr {
|
||||
return Init(Bool_.N, Bool_.N, Byte_ascii.Slash, repo.Root_http()
|
||||
, repo.Mode_names()[mode], repo.Dir_depth(), repo.Gen_name_trg(ttl, md5, ext), md5, ext, mode, file_w, time, page);
|
||||
}
|
||||
public Xof_url_bldr Init(boolean wmf_dir_hive, boolean wmf_protocol_is_file, byte dir_spr
|
||||
private Xof_url_bldr Init(boolean wmf_dir_hive, boolean wmf_protocol_is_file, byte dir_spr
|
||||
, byte[] root, byte[] area, int md5_dir_depth
|
||||
, byte[] ttl, byte[] md5, Xof_ext ext
|
||||
, byte file_mode, int file_w, double time, int page) {
|
||||
, byte file_mode, int file_w, double time, int page
|
||||
) {
|
||||
this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.dir_spr = dir_spr;
|
||||
this.root = root; this.area = area; this.md5_dir_depth = md5_dir_depth;
|
||||
this.ttl = ttl; this.md5 = md5; this.ext = ext;
|
||||
@@ -126,10 +127,12 @@ public class Xof_url_bldr {
|
||||
case Xof_ext_.Id_ogg:
|
||||
case Xof_ext_.Id_ogv:
|
||||
case Xof_ext_.Id_webm:
|
||||
bfr.Add_int_variable(file_w); // add file_w; EX: "220"; PAGE:en.w:Alice_Brady; DATE:2015-08-06
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
if (Xof_lnki_time.Null_n(time))
|
||||
bfr.Add(Bry_seek).Add_str(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
bfr.Add(Bry_seek).Add_str(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
else
|
||||
bfr.Add(Bry_mid); // add mid; EX: "mid-"
|
||||
bfr.Add_byte(Byte_ascii.Dash); // add mid; EX: "-"; NOTE: was "mid-"; DATE:2015-08-06
|
||||
break;
|
||||
case Xof_ext_.Id_tif:
|
||||
case Xof_ext_.Id_tiff:
|
||||
@@ -148,7 +151,13 @@ public class Xof_url_bldr {
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
break;
|
||||
}
|
||||
bfr.Add(encoder_src_http.Encode(ttl)); // add ttl again; EX: "A.png"
|
||||
int ttl_len = ttl.length;
|
||||
if (ttl_len > 160) { // long file name
|
||||
bfr.Add(Bry_thumnbail_w_dot);
|
||||
bfr.Add(ext.Ext());
|
||||
}
|
||||
else
|
||||
bfr.Add(encoder_src_http.Encode(ttl)); // add ttl again; EX: "A.png"
|
||||
switch (file_ext_id) {
|
||||
case Xof_ext_.Id_svg:
|
||||
case Xof_ext_.Id_bmp:
|
||||
@@ -178,7 +187,8 @@ public class Xof_url_bldr {
|
||||
}
|
||||
private Xof_url_bldr Clear() {
|
||||
root = area = ttl = md5 = null;
|
||||
file_w = 0; time = Xof_lnki_time.Null;
|
||||
file_w = Xof_img_size.Null;
|
||||
time = Xof_lnki_time.Null;
|
||||
ext = null;
|
||||
bfr.Clear();
|
||||
return this;
|
||||
@@ -186,7 +196,8 @@ public class Xof_url_bldr {
|
||||
public static final byte[]
|
||||
Bry_reg = Bry_.new_a7("reg.csv")
|
||||
, Bry_px = Bry_.new_a7("px"), Bry_px_dash = Bry_.new_a7("px-")
|
||||
, Bry_thumb = Bry_.new_a7("thumb"), Bry_mid = Bry_.new_a7("mid-")
|
||||
, Bry_thumb = Bry_.new_a7("thumb")
|
||||
, Bry_thumnbail_w_dot = Bry_.new_a7("thumbnail.")
|
||||
;
|
||||
private static final byte[]
|
||||
Bry_lossy_page = Bry_.new_a7("lossy-page"), Bry_page = Bry_.new_a7("page")
|
||||
|
||||
@@ -19,34 +19,44 @@ package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
|
||||
public class Xof_url_bldr_tst {
|
||||
private Xof_url_bldr_fxt fxt = new Xof_url_bldr_fxt();
|
||||
@Before public void init() {fxt.ini();}
|
||||
@Test public void Ogv() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/thumb/d/d0/A.ogv/mid-A.ogv.jpg").tst();}
|
||||
@Test public void Ogv_seek() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/thumb/d/d0/A.ogv/seek%3D5-A.ogv.jpg").Seek_(5).tst();}
|
||||
@Test public void Xcf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("44").Ttl_("A.xcf").Expd_src_("http://test/thumb/4/44/A.xcf/0px-A.xcf.png").tst();}
|
||||
@Test public void Bmp() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("70").Ttl_("A.bmp").Expd_src_("http://test/thumb/7/70/A.bmp/0px-A.bmp.png").tst();}
|
||||
@Test public void Pdf_none() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Expd_src_("http://test/thumb/e/ef/A.pdf/page1-0px-A.pdf.jpg").tst();}
|
||||
@Test public void Pdf_page_2() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Page_(2).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-0px-A.pdf.jpg").tst();}
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Ogv() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").W_(220).Expd_src_("http://test/thumb/d/d0/A.ogv/220px--A.ogv.jpg").Test();}
|
||||
@Test public void Ogv__seek() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").W_(220).Expd_src_("http://test/thumb/d/d0/A.ogv/220px-seek%3D5-A.ogv.jpg").Seek_(5).Test();}
|
||||
@Test public void Ogv__no_w() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").W_( -1).Expd_src_("http://test/thumb/d/d0/A.ogv/-1px--A.ogv.jpg").Test();} // TODO: use orig_w, not -1
|
||||
@Test public void Xcf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("44").Ttl_("A.xcf").W_(220).Expd_src_("http://test/thumb/4/44/A.xcf/220px-A.xcf.png").Test();}
|
||||
@Test public void Bmp() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("70").Ttl_("A.bmp").W_(220).Expd_src_("http://test/thumb/7/70/A.bmp/220px-A.bmp.png").Test();}
|
||||
@Test public void Pdf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page1-220px-A.pdf.jpg").Test();}
|
||||
@Test public void Pdf__page_2() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-220px-A.pdf.jpg").Page_(2).Test();}
|
||||
@Test public void Long() {
|
||||
String filename = String_.Repeat("A", 200) + ".png";
|
||||
fxt.Dir_spr_http_().Root_("http://test/").Md5_("14").Ttl_(filename).W_(220)
|
||||
.Expd_src_("http://test/thumb/1/14/" + filename + "/220px-thumbnail.png")
|
||||
.Test()
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xof_url_bldr_fxt {
|
||||
private final Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
public Xof_url_bldr_fxt ini() {this.Clear(); return this;}
|
||||
public Xof_url_bldr_fxt Clear() {
|
||||
dir_spr = Byte_.Zero; ext = null; root = md5 = ttl = expd_src = null;
|
||||
seek = Xof_lnki_time.Null;
|
||||
page = Xof_lnki_page.Null;
|
||||
w = Xof_img_size.Null;
|
||||
return this;
|
||||
}
|
||||
public Xof_url_bldr_fxt Dir_spr_http_() {return Dir_spr_(Byte_ascii.Slash);}
|
||||
public Xof_url_bldr_fxt Dir_spr_fsys_wnt_() {return Dir_spr_(Byte_ascii.Backslash);}
|
||||
public Xof_url_bldr_fxt Dir_spr_(byte v) {dir_spr = v; return this;} private byte dir_spr;
|
||||
public Xof_url_bldr_fxt Root_(String v) {root = v; return this;} private String root;
|
||||
public Xof_url_bldr_fxt Md5_(String v) {md5 = v; return this;} private String md5;
|
||||
public Xof_url_bldr_fxt Ttl_(String v) {ttl = v; ext = Xof_ext_.new_by_ttl_(Bry_.new_u8(v)); return this;} private String ttl; Xof_ext ext;
|
||||
public Xof_url_bldr_fxt W_(int v) {this.w = v; return this;} private int w;
|
||||
public Xof_url_bldr_fxt Page_(int v) {page = v; return this;} private int page = Xof_lnki_page.Null;
|
||||
public Xof_url_bldr_fxt Seek_(int v) {seek = v; return this;} private double seek = Xof_lnki_time.Null;
|
||||
public Xof_url_bldr_fxt Expd_src_(String v) {expd_src = v; return this;} private String expd_src;
|
||||
private void Clear() {
|
||||
dir_spr = Byte_.Zero; ext = null; root = md5 = ttl = expd_src = null;
|
||||
seek = Xof_lnki_time.Null;
|
||||
page = Xof_lnki_page.Null;
|
||||
}
|
||||
public Xof_url_bldr_fxt tst() {
|
||||
public Xof_url_bldr_fxt Test() {
|
||||
url_bldr.Init_by_root(Bry_.new_u8(root), dir_spr, Bool_.Y, Bool_.N, 2);
|
||||
url_bldr.Init_by_itm (Xof_repo_itm_.Mode_thumb, Bry_.new_u8(ttl), Bry_.new_u8(md5), ext, 0, seek, page);
|
||||
url_bldr.Init_by_itm (Xof_repo_itm_.Mode_thumb, Bry_.new_u8(ttl), Bry_.new_u8(md5), ext, w, seek, page);
|
||||
Tfds.Eq(expd_src, url_bldr.Xto_str());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
}
|
||||
public void Init_at_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, Xof_ext orig_ext, int orig_w, int orig_h, byte[] orig_redirect) {
|
||||
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
|
||||
this.orig_ttl = orig_ttl; this.orig_ttl_md5 = Xof_file_wkr_.Md5_(orig_ttl);
|
||||
this.orig_ttl = orig_ttl; this.orig_ttl_md5 = Xof_file_wkr_.Md5(orig_ttl);
|
||||
this.orig_w = orig_w; this.orig_h = orig_h; this.orig_redirect = orig_redirect;
|
||||
if (Bry_.Len_gt_0(orig_redirect)) // redirect exists; EX: A.png redirected to B.png
|
||||
this.Orig_ttl_(orig_redirect); // update fsdb with atrs of B.png
|
||||
@@ -185,14 +185,14 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
if (meta_itm == null || trg_repo_itm == null) return false;
|
||||
if (meta_itm.Ptr_ttl_exists()) {
|
||||
lnki_ttl = meta_itm.Ptr_ttl();
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5_(lnki_ttl);
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5(lnki_ttl);
|
||||
}
|
||||
boolean limit_size = !orig_ext.Id_is_svg() || (orig_ext.Id_is_svg() && caller_is_file_page);
|
||||
if (orig_ext.Id_is_media() && html_w < 1) // if media and no width, set to default; NOTE: must be set or else dynamic download will resize play button to small size; DATE:20121227
|
||||
html_w = Xof_img_size.Thumb_width_ogv;
|
||||
if (!file_is_orig) { // file is thumb
|
||||
if (orig_ext.Id_is_video()) { // video is a special case; src is thumb_w but html_w / html_h is based on calc
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
if (meta_itm.Thumbs_indicates_oga() && orig_ext.Id_is_ogv()) {orig_ext = Xof_ext_.new_by_ext_(Xof_ext_.Bry_oga); return true;} // if audio, do not thumb; NOTE: must happen after html_orig_bry, b/c html must still be generated to auto-download files; NOTE: must change ext to oga b/c ogg may trigger video code elsewhere
|
||||
Xof_meta_thumb thumb = meta_itm.Thumbs_get_vid(Xof_lnki_time.X_int(lnki_time));
|
||||
if (thumb != null) {
|
||||
@@ -204,7 +204,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
}
|
||||
}
|
||||
else { // regular thumb
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
if (orig_ext.Id_is_audio()) return true; // if audio, do not thumb; even if user requests thumb;
|
||||
Xof_meta_thumb[] thumbs = meta_itm.Thumbs(); int thumbs_len = thumbs.length; Xof_meta_thumb thumb = null;
|
||||
if (lnki_h > 0 && orig_w < 1 && thumbs_len > 0) { // if height is specified and no orig, then iterate over thumbs to find similar height; NOTE: this is a fallback case; orig_w/h is optimal; EX: c:Jacques-Louis David and <gallery>
|
||||
|
||||
@@ -117,10 +117,10 @@ public class Xow_file_mgr implements GfoInvkAble {
|
||||
public void Init_file_mgr_by_load(Xow_wiki wiki) {
|
||||
if (db_core != null) return; // already init'd
|
||||
this.db_core = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
|
||||
// if (db_core == null) return; // no fsdb_core found; exit
|
||||
if (db_core == null) {
|
||||
db_core = Fsdb_db_mgr__v2_bldr.I.Get_or_make(wiki, false);
|
||||
}
|
||||
if ( db_core == null // "-file-core.xowa" not found
|
||||
&& !wiki.Data__core_mgr().Props().Layout_file().Tid_is_all() // DATE:2015-08-10
|
||||
)
|
||||
db_core = Fsdb_db_mgr__v2_bldr.I.Get_or_make(wiki, false); // make it
|
||||
this.version = Version_2;
|
||||
this.fsdb_mode = Xof_fsdb_mode.new_v2_gui();
|
||||
orig_mgr.Init_by_wiki(wiki, fsdb_mode, db_core.File__orig_tbl_ary(), Xof_url_bldr.new_v2());
|
||||
|
||||
@@ -15,8 +15,8 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wmfs.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wmfs.*;
|
||||
class Xowmf_val_itm {
|
||||
public Xowmf_val_itm(byte[] val) {this.val = val;}
|
||||
public byte[] Val() {return val;} private byte[] val;
|
||||
package gplx.xowa.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*;
|
||||
public interface Io_download_mgr {
|
||||
Io_stream_rdr Download_as_rdr(String src);
|
||||
}
|
||||
31
400_xowa/src/gplx/xowa/files/bins/Io_download_mgr_.java
Normal file
31
400_xowa/src/gplx/xowa/files/bins/Io_download_mgr_.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*;
|
||||
public class Io_download_mgr_ {
|
||||
public static Io_download_mgr new_system() {return new Io_download_mgr__system();}
|
||||
public static Io_download_mgr__memory new_memory() {return new Io_download_mgr__memory();}
|
||||
}
|
||||
class Io_download_mgr__system implements Io_download_mgr {
|
||||
private final IoEngine_xrg_downloadFil download_wkr = IoEngine_xrg_downloadFil.new_("", Io_url_.Empty);
|
||||
public void Upload_data(String url, byte[] data) {throw Err_.new_unimplemented();}
|
||||
public Io_stream_rdr Download_as_rdr(String url) {
|
||||
download_wkr.Init(url, Io_url_.Empty);
|
||||
return download_wkr.Exec_as_rdr();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*;
|
||||
public class Io_download_mgr__memory implements Io_download_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.new_();
|
||||
public void Clear() {hash.Clear();}
|
||||
public void Upload_data(String url, byte[] data) {hash.Add(url, data);}
|
||||
public Io_stream_rdr Download_as_rdr(String url) {
|
||||
byte[] data = (byte[])hash.Get_by(url); if (data == null) return Io_stream_rdr_.Noop;
|
||||
return Io_stream_rdr_.mem_(data);
|
||||
}
|
||||
}
|
||||
@@ -16,21 +16,38 @@ 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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*; import gplx.core.threads.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.ios.*; import gplx.core.threads.*;
|
||||
import gplx.xowa.apps.*;
|
||||
import gplx.xowa.files.fsdb.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
private final Xow_repo_mgr repo_mgr; private final IoEngine_xrg_downloadFil download_wkr;
|
||||
private final Io_download_mgr download_mgr;
|
||||
private final Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
public Xof_bin_wkr__http_wmf(Xow_repo_mgr repo_mgr, gplx.ios.IoEngine_xrg_downloadFil download_wkr) {this.repo_mgr = repo_mgr; this.download_wkr = download_wkr;}
|
||||
public Xof_bin_wkr__http_wmf(Xow_repo_mgr repo_mgr, Io_download_mgr download_mgr, IoEngine_xrg_downloadFil download_wkr) {
|
||||
this.repo_mgr = repo_mgr; this.download_mgr = download_mgr; this.download_wkr = download_wkr;
|
||||
}
|
||||
public byte Tid() {return Xof_bin_wkr_.Tid_http_wmf;}
|
||||
public String Key() {return Xof_bin_wkr_.Key_http_wmf;}
|
||||
public boolean Resize_allowed() {return bin_wkr_resize;} public void Resize_allowed_(boolean v) {bin_wkr_resize = v;} private boolean bin_wkr_resize = true;
|
||||
public int Fail_timeout() {return fail_timeout;} public Xof_bin_wkr__http_wmf Fail_timeout_(int v) {fail_timeout = v; return this;} private int fail_timeout = 0; // NOTE: always default to 0; manually set to 1000 for fsdb_make only; DATE:2014-06-21
|
||||
public Io_stream_rdr Get_as_rdr(Xof_fsdb_itm fsdb, boolean is_thumb, int w) {
|
||||
Download_init(fsdb.Orig_repo_name(), fsdb.Orig_ttl(), fsdb.Orig_ttl_md5(), fsdb.Orig_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Empty);
|
||||
Io_stream_rdr rdr = download_wkr.Exec_as_rdr();
|
||||
String src = Make_src(fsdb.Orig_repo_name(), fsdb.Orig_ttl(), fsdb.Orig_ttl_md5(), fsdb.Orig_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Empty);
|
||||
Io_stream_rdr rdr = download_mgr.Download_as_rdr(src);
|
||||
boolean rv = rdr.Exists(); // NOTE: use Exists which detects for response_code 200, not content length > 0; DATE:2015-05-20
|
||||
if (!rv) Handle_error();
|
||||
fsdb.Fsdb_insert_y_();
|
||||
if (!rv) {
|
||||
Handle_error();
|
||||
if (!rv && fsdb.Orig_repo_id() == Xof_repo_itm_.Repo_local) { // image is not found in local; check commons; occurs with bldr which relies on inaccurate data in image dumps; PAGE:en.w:Apollo_13; DATE:2015-08-05
|
||||
src = Make_src(Xow_domain_.Domain_bry_commons, fsdb.Orig_ttl(), fsdb.Orig_ttl_md5(), fsdb.Orig_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Empty);
|
||||
rdr = download_mgr.Download_as_rdr(src);
|
||||
rv = rdr.Exists();
|
||||
if (rv)
|
||||
fsdb.Change_repo(Xof_repo_itm_.Repo_remote, Xow_domain_.Domain_bry_commons); // set commons.wikimedia.org; DATE:2015-08-05
|
||||
else
|
||||
Handle_error();
|
||||
}
|
||||
}
|
||||
if (rv) fsdb.Fsdb_insert_y_();
|
||||
return rv ? rdr : Io_stream_rdr_.Noop;
|
||||
}
|
||||
public boolean Get_to_fsys(Xof_fsdb_itm fsdb, boolean is_thumb, int w, Io_url bin_url) {
|
||||
@@ -39,7 +56,7 @@ public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
return rv;
|
||||
}
|
||||
private boolean Get_to_fsys(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
Download_init(orig_repo, orig_ttl, orig_md5, orig_ext, lnki_is_thumb, file_w, lnki_time, lnki_page, file_url);
|
||||
Init_download(orig_repo, orig_ttl, orig_md5, orig_ext, lnki_is_thumb, file_w, lnki_time, lnki_page, file_url);
|
||||
boolean rv = download_wkr.Exec();
|
||||
if (!rv) Handle_error();
|
||||
return rv;
|
||||
@@ -48,16 +65,22 @@ public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
if (fail_timeout > 0)
|
||||
Thread_adp_.Sleep(fail_timeout); // as per WMF policy, pause 1 second for every cache miss; http://lists.wikimedia.org/pipermail/wikitech-l/2013-September/071948.html
|
||||
}
|
||||
private void Download_init(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
private void Init_download(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
byte mode = lnki_is_thumb ? Xof_repo_itm_.Mode_thumb : Xof_repo_itm_.Mode_orig;
|
||||
Xof_repo_pair repo_itm = repo_mgr.Repos_get_by_wiki(orig_repo);
|
||||
String src = url_bldr.Init_for_src_file(mode, repo_itm.Src(), orig_ttl, orig_md5, orig_ext, file_w, lnki_time, lnki_page).Xto_str();
|
||||
download_wkr.Init(src, file_url);
|
||||
}
|
||||
private String Make_src(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
byte mode = lnki_is_thumb ? Xof_repo_itm_.Mode_thumb : Xof_repo_itm_.Mode_orig;
|
||||
Xof_repo_pair repo_itm = repo_mgr.Repos_get_by_wiki(orig_repo);
|
||||
return url_bldr.Init_for_src_file(mode, repo_itm.Src(), orig_ttl, orig_md5, orig_ext, file_w, lnki_time, lnki_page).Xto_str();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_fail_timeout_)) fail_timeout = m.ReadInt("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_fail_timeout_ = "fail_timeout_";
|
||||
public static Xof_bin_wkr__http_wmf new_(Xow_wiki wiki) {return new Xof_bin_wkr__http_wmf(wiki.File__repo_mgr(), wiki.App().Wmf_mgr().Download_wkr().Download_xrg());}
|
||||
public static Xof_bin_wkr__http_wmf new_(Xow_wiki wiki) {return new_(wiki, Io_download_mgr_.new_system());}
|
||||
public static Xof_bin_wkr__http_wmf new_(Xow_wiki wiki, Io_download_mgr download_mgr) {return new Xof_bin_wkr__http_wmf(wiki.File__repo_mgr(), download_mgr, wiki.App().Wmf_mgr().Download_wkr().Download_xrg());}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import org.junit.*; import gplx.ios.*; import gplx.xowa.files.repos.*;
|
||||
public class Xof_bin_wkr__http_wmf__tst {
|
||||
private final Xof_bin_wkr__http_wmf__fxt fxt = new Xof_bin_wkr__http_wmf__fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Init__Http("mem/http/commons.wikimedia.org/thumb/7/70/A.png/220px-A.png", "test_data");
|
||||
fxt.Exec__Get_as_rdr(fxt.Fsdb_itm_mkr().Lnki__en_w("A.png").Orig__commons__lnki(), Bool_.Y, 220);
|
||||
fxt.Test__Get_as_rdr__rdr("test_data");
|
||||
}
|
||||
@Test public void Enwiki_fails__fallback_to_commons() {
|
||||
fxt.Init__Http("mem/http/commons.wikimedia.org/thumb/7/70/A.png/220px-A.png", "test_data"); // put file in commons
|
||||
Xof_fsdb_itm fsdb_itm = fxt.Fsdb_itm_mkr().Lnki__en_w("A.png").Orig__enwiki__lnki().Make();
|
||||
fxt.Exec__Get_as_rdr(fsdb_itm, Bool_.Y, 220); // look in enwiki
|
||||
fxt.Test__Get_as_rdr__rdr("test_data"); // test that enwiki tries commons again
|
||||
Tfds.Eq_str("commons.wikimedia.org", fsdb_itm.Orig_repo_name(), "repo_name"); // test that it's now commons
|
||||
Tfds.Eq_byte(Xof_repo_itm_.Repo_remote, fsdb_itm.Orig_repo_id(), "repo_tid"); // test that it's now commons
|
||||
}
|
||||
@Test public void Long_filename_becomes_thumbnail() {
|
||||
String filename = String_.Repeat("A", 200) + ".png";
|
||||
fxt.Init__Http("mem/http/commons.wikimedia.org/thumb/1/14/" + filename + "/220px-thumbnail.png", "test_data"); // add file as "thumbnail.png"
|
||||
Xof_fsdb_itm fsdb_itm = fxt.Fsdb_itm_mkr().Lnki__en_w(filename).Orig__enwiki__lnki().Make();
|
||||
fxt.Exec__Get_as_rdr(fsdb_itm, Bool_.Y, 220); // look in enwiki
|
||||
fxt.Test__Get_as_rdr__rdr("test_data"); // test that file is there
|
||||
}
|
||||
}
|
||||
class Xof_bin_wkr__http_wmf__fxt {
|
||||
private final Xof_bin_wkr__http_wmf wkr;
|
||||
private final Io_download_mgr__memory download_mgr;
|
||||
private Io_stream_rdr get_as_rdr__rdr;
|
||||
public Xof_fsdb_itm_fxt Fsdb_itm_mkr() {return fsdb_itm_mkr;} private final Xof_fsdb_itm_fxt fsdb_itm_mkr = new Xof_fsdb_itm_fxt();
|
||||
public Xof_bin_wkr__http_wmf__fxt() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
Xoa_app_fxt.repo2_(app, wiki);
|
||||
this.download_mgr = Io_download_mgr_.new_memory();
|
||||
this.wkr = Xof_bin_wkr__http_wmf.new_(wiki, download_mgr);
|
||||
}
|
||||
public void Clear() {
|
||||
download_mgr.Clear();
|
||||
}
|
||||
public void Init__Http(String url, String data) {download_mgr.Upload_data(url, Bry_.new_u8(data));}
|
||||
public void Exec__Get_as_rdr(Xof_fsdb_itm_fxt fsdb_itm_mkr, boolean is_thumb, int w) {Exec__Get_as_rdr(fsdb_itm_mkr.Make(), is_thumb, w);}
|
||||
public void Exec__Get_as_rdr(Xof_fsdb_itm fsdb_itm , boolean is_thumb, int w) {
|
||||
this.get_as_rdr__rdr = wkr.Get_as_rdr(fsdb_itm, is_thumb, w);
|
||||
}
|
||||
public void Test__Get_as_rdr__rdr(String expd) {
|
||||
Tfds.Eq_str(expd, Io_stream_rdr_.Load_all_as_str(get_as_rdr__rdr), "rdr_contents");
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class Xofc_fil_mgr {
|
||||
long cur_size = 0, actl_size = 0;
|
||||
Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
List_adp deleted = List_adp_.new_();
|
||||
tbl.Conn().Txn_bgn();
|
||||
tbl.Conn().Txn_bgn("user__file_cache__compress");
|
||||
long compress_to = cfg_mgr.Cache_min();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xofc_fil_itm itm = (Xofc_fil_itm)hash.Get_at(i);
|
||||
@@ -124,7 +124,7 @@ class Xofc_fil_mgr {
|
||||
wiki.Init_assert();
|
||||
Xof_repo_itm trg_repo = repo_mgr.Get_by_primary(wiki_domain);
|
||||
byte[] ttl = itm.Name();
|
||||
byte[] md5 = Xof_file_wkr_.Md5_(ttl);
|
||||
byte[] md5 = Xof_file_wkr_.Md5(ttl);
|
||||
int itm_ext_id = itm.Ext().Id();
|
||||
Io_url fil_url = url_bldr.Init_for_trg_file(mode_id, trg_repo, ttl, md5, itm.Ext(), itm.W()
|
||||
, Xof_lnki_time.Convert_to_xowa_thumbtime (itm_ext_id, itm.Time())
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Xou_cache_mgr {
|
||||
synchronized (thread_lock) {
|
||||
Db_conn conn = cache_tbl.Conn();
|
||||
try {
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("user__file_cache__save");
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xou_cache_itm itm = (Xou_cache_itm)hash.Get_at(i);
|
||||
@@ -136,14 +136,16 @@ public class Xou_cache_mgr {
|
||||
for (int i = 0; i < len; ++i) { // iterate and find items to delete
|
||||
Xou_cache_grp grp = (Xou_cache_grp)grp_hash.Get_at(i);
|
||||
fsys_size_temp = fsys_size_calc + grp.File_size();
|
||||
if (fsys_size_temp > reduce_to) // fsys_size_cur exceeded; mark itm for deletion
|
||||
if ( fsys_size_temp > reduce_to // fsys_size_cur exceeded; mark itm for deletion
|
||||
|| fsys_size_temp == -1 // fsys_size sometimes -1; note -1 b/c file is missing; should fix, but for now, consider -1 size deleted; DATE:2015-08-05
|
||||
)
|
||||
deleted.Add(grp);
|
||||
else
|
||||
fsys_size_calc = fsys_size_temp;
|
||||
}
|
||||
len = deleted.Count();
|
||||
Db_conn conn = cache_tbl.Conn();
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("user__file_cache__delete");
|
||||
for (int i = 0; i < len; i++) { // iterate and delete
|
||||
Xou_cache_grp grp = (Xou_cache_grp)deleted.Get_at(i);
|
||||
grp.Delete(hash, cache_tbl);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xof_img_wkr_resize_img_mok implements Xof_img_wkr_resize_img {
|
||||
int src_w = src_size.Width(), src_h = src_size.Height();
|
||||
if (trg_w < 1) throw Err_.new_wo_type("trg_w must be > 0", "trg_w", trg_w);
|
||||
if (trg_h < 1) trg_h = Xof_xfer_itm_.Scale_h(src_w, src_h, trg_w);
|
||||
Io_mgr.I.SaveFilStr(trg, SizeAdp_.new_(trg_w, trg_h).XtoStr());
|
||||
Io_mgr.I.SaveFilStr(trg, SizeAdp_.new_(trg_w, trg_h).To_str());
|
||||
return true;
|
||||
}
|
||||
public static final Xof_img_wkr_resize_img_mok _ = new Xof_img_wkr_resize_img_mok(); Xof_img_wkr_resize_img_mok() {}
|
||||
|
||||
@@ -61,7 +61,7 @@ class Fs_root_dir_fxt {
|
||||
}
|
||||
public static void Save_img(String url, int w, int h) {
|
||||
gplx.gfui.SizeAdp img_size = gplx.gfui.SizeAdp_.new_(w, h);
|
||||
Io_mgr.I.SaveFilStr(url, img_size.XtoStr());
|
||||
Io_mgr.I.SaveFilStr(url, img_size.To_str());
|
||||
}
|
||||
public void Test_xto_fil_bry(String url_str, String expd) {
|
||||
Io_url url = Io_url_.new_fil_(url_str);
|
||||
|
||||
@@ -30,7 +30,7 @@ class Xof_img_wkr_convert_djvu_to_tiff_app implements Xof_img_wkr_convert_djvu_t
|
||||
class Xof_img_wkr_convert_djvu_to_tiff_mok implements Xof_img_wkr_convert_djvu_to_tiff {
|
||||
public Xof_img_wkr_convert_djvu_to_tiff_mok(int w, int h) {this.w = w; this.h = h;} private int w, h;
|
||||
public boolean Exec(Io_url src, Io_url trg) {
|
||||
Io_mgr.I.SaveFilStr(trg, gplx.gfui.SizeAdp_.new_(w, h).XtoStr());
|
||||
Io_mgr.I.SaveFilStr(trg, gplx.gfui.SizeAdp_.new_(w, h).To_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xof_orig_wkr__xo_meta implements Xof_orig_wkr {
|
||||
public byte Tid() {return Xof_orig_wkr_.Tid_xowa_meta;}
|
||||
public void Find_by_list(Ordered_hash rv, List_adp itms) {Xof_orig_wkr_.Find_by_list(this, rv, itms);}
|
||||
public Xof_orig_itm Find_as_itm(byte[] ttl, int list_idx, int list_len) {
|
||||
byte[] md5 = Xof_file_wkr_.Md5_(ttl);
|
||||
byte[] md5 = Xof_file_wkr_.Md5(ttl);
|
||||
url_bfr.Add(wiki_meta_dir.RawBry()) // /xowa/file/#meta/simple.wikipedia.org/
|
||||
.Add_byte(md5[0]).Add_byte(dir_spr_byte) // 0/
|
||||
.Add_byte(md5[1]).Add_byte(dir_spr_byte) // 6/
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Xowe_repo_mgr implements Xow_repo_mgr, GfoInvkAble {
|
||||
}
|
||||
byte[] Xfer_by_meta__find_main_ptr(Xof_meta_itm meta_itm, Xof_xfer_itm xfer_itm) {
|
||||
byte[] redirect = meta_itm.Ptr_ttl(); int redirect_tries = 0;
|
||||
byte[] md5 = Xof_file_wkr_.Md5_(redirect);
|
||||
byte[] md5 = Xof_file_wkr_.Md5(redirect);
|
||||
while (true) {
|
||||
boolean found = page_finder.Locate(tmp_rslt, repos, redirect);
|
||||
if (!found) return null;
|
||||
|
||||
@@ -73,8 +73,8 @@ public class Xof_xfer_mgr {
|
||||
}
|
||||
|
||||
// BLOCK: orig; get orig for convert; note that Img_download will not download file again if src exists
|
||||
src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
if (!Img_download(src_str, trg_url, false)) return false;
|
||||
trg_url = rslt.Trg();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Xof_xfer_mgr {
|
||||
}
|
||||
if (!Bry_.Eq(rslts.Orig_page(), orig_ttl)) {
|
||||
orig_ttl = rslts.Orig_page();
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5_(orig_ttl);
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5(orig_ttl);
|
||||
meta_itm.Ptr_ttl_(orig_ttl);
|
||||
}
|
||||
meta_itm.Vrtl_repo_(xfer_itm.Orig_repo_id());
|
||||
@@ -138,7 +138,7 @@ public class Xof_xfer_mgr {
|
||||
if (!wmf_api_found) return false; // not found in wmf_api; exit now
|
||||
}
|
||||
else if (src_repo.Tarball()) {
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
meta_itm.Orig_exists_(Xof_meta_itm.Exists_unknown); // mark exists unknown; note need to assertively mark unknown b/c it may have been marked n in previous pass through multiple repos; DATE:20121227
|
||||
meta_itm.Vrtl_repo_(Xof_meta_itm.Repo_unknown); // mark repo unknown;
|
||||
if (!Cmd_query_size(Io_url_.new_fil_(src_str))) {
|
||||
@@ -256,8 +256,8 @@ public class Xof_xfer_mgr {
|
||||
}
|
||||
boolean Make_other() {
|
||||
if (!Orig_max_download() && !force_orig) return false;
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
Io_url trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
Io_url trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
return Cmd_download(src_str, trg_url, true);
|
||||
}
|
||||
boolean Orig_max_download() {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
@Test public void Ogg_vid_thumb() {
|
||||
fxt .ini_page_create_commons ("File:A.ogg");
|
||||
fxt .Lnki_orig_("A.ogg")
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/4/42/A.ogg/mid-A.ogg.jpg", 300, 40))
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/4/42/A.ogg/-1px--A.ogg.jpg", 300, 40))
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/4/2/A.ogg/300px.jpg", 300, 40)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/4/42.csv", "A.ogg|0||0?0,0|1?300,40")
|
||||
);
|
||||
@@ -234,7 +234,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogv).View_max_(0);
|
||||
Io_mgr.I.SaveFilStr("mem/xowa/file/#meta/en.wikipedia.org/d/d0.csv", "A.ogv|0||2?0,0|1?300,40\n"); // simulate (a)
|
||||
fxt .Lnki_("A.ogv", true, -1, -1, -1, 5)
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/seek%3D5-A.ogv.jpg", 300, 40)
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/-1px-seek%3D5-A.ogv.jpg", 300, 40)
|
||||
)
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/d/0/A.ogv/300px@5.jpg", 300, 40)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/d/d0.csv", "A.ogv|0||2?0,0|1?300,40@5")
|
||||
@@ -246,7 +246,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
fxt .ini_page_create_commons ("File:A.webm");
|
||||
fxt .Lnki_thumb_("A.webm", 220)
|
||||
.Src( fxt.ogg_("mem/src/commons.wikimedia.org/3/34/A.webm")
|
||||
, fxt.img_("mem/src/commons.wikimedia.org/thumb/3/34/A.webm/mid-A.webm.jpg", 300, 40)
|
||||
, fxt.img_("mem/src/commons.wikimedia.org/thumb/3/34/A.webm/220px--A.webm.jpg", 300, 40)
|
||||
)
|
||||
.Trg( fxt.ogg_("mem/trg/commons.wikimedia.org/raw/3/4/A.webm")
|
||||
, fxt.img_("mem/trg/commons.wikimedia.org/fit/3/4/A.webm/300px.jpg", 300, 40)
|
||||
@@ -257,7 +257,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
@Test public void Ogv_thumb() {// d00d1d5019e37cc219a91a2f8ad47bfe
|
||||
fxt .ini_page_create_commons ("File:A.ogv");
|
||||
fxt .Lnki_orig_("A.ogv")
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/mid-A.ogv.jpg", 300, 40))
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/-1px--A.ogv.jpg", 300, 40))
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/d/0/A.ogv/300px.jpg", 300, 40)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/d/d0.csv", "A.ogv|0||0?0,0|1?300,40")
|
||||
)
|
||||
@@ -269,7 +269,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
}
|
||||
@Test public void Thumbtime_ignored_if_non_media() { // PURPOSE: ignore thumbtime if not media; PAGE:en.w:Moon; EX:[[File:A.png|thumbtime=0.02]] DATE:2014-07-22
|
||||
fxt .ini_page_create_en_wiki("File:A.png");
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, 2) // thumbtime of 2 specified; will be ignored below
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, 2) // thumbtime of 2 specified; will be ignored below
|
||||
.Src( fxt.img_("mem/src/en.wikipedia.org/thumb/7/70/A.png/90px-A.png", 90, 80))
|
||||
.Trg( fxt.img_("mem/trg/en.wikipedia.org/fit/7/0/A.png/90px.png", 90, 80)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv", "A.png|y||2?0,0|1?90,80")
|
||||
|
||||
@@ -25,8 +25,8 @@ public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
super.Clear(src_repo_is_wmf);
|
||||
this.Api_size().Clear();
|
||||
}
|
||||
public Xof_xfer_queue_html_fxt Lnki_orig_ (String lnki_ttl) {return Lnki_(lnki_ttl, Bool_.N, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_thumb_(String lnki_ttl, int lnki_w) {return Lnki_(lnki_ttl, Bool_.Y, lnki_w, Xof_img_size.Size_null_deprecated, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_orig_ (String lnki_ttl) {return Lnki_(lnki_ttl, Bool_.N, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_thumb_(String lnki_ttl, int lnki_w) {return Lnki_(lnki_ttl, Bool_.Y, lnki_w, Xof_img_size.Size__neg1, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_thumb_(String lnki_ttl, int lnki_w, int lnki_h) {return Lnki_(lnki_ttl, Bool_.Y, lnki_w, lnki_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_(String lnki_ttl, boolean thumb, int lnki_w, int lnki_h, double upright, int seek_time) { // NOTE: only one xfer_itm; supports one Lnki_ per test only
|
||||
Xowe_wiki wiki = this.En_wiki();
|
||||
|
||||
@@ -158,7 +158,7 @@ public class Xof_xfer_queue_html_wmf_api_tst {
|
||||
@Test public void Imap() { // PURPOSE: check that imap downloads orig, even when thumb is requested; DATE:2014-08-08
|
||||
fxt .ini_page_create_commons("File:A.png");
|
||||
fxt .ini_page_api("commons", "A.png", "", 180, 160);
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, Xof_lnki_time.Null_as_int); // thumbtime of 2 specified; will be ignored below
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, Xof_lnki_time.Null_as_int); // thumbtime of 2 specified; will be ignored below
|
||||
fxt .Xfer_itm().Html_elem_tid_(Xof_html_elem.Tid_imap);
|
||||
fxt .Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/7/70/A.png/90px-A.png", 90, 80))
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/7/0/A.png/90px.png", 90, 80)
|
||||
|
||||
@@ -18,20 +18,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.gui; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.gfui.*; import gplx.xowa.specials.search.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.cmds.*; import gplx.xowa.cfgs.gui.*; import gplx.xowa.users.*;
|
||||
import gplx.xowa.gui.bnds.*; import gplx.xowa.gui.views.*; import gplx.xowa.gui.urls.url_macros.*;
|
||||
import gplx.xowa.gui.views.boots.*;
|
||||
public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
public Xoa_gui_mgr(Xoae_app app) {
|
||||
evMgr = GfoEvMgr.new_(this);
|
||||
this.ev_mgr = GfoEvMgr.new_(this);
|
||||
this.app = app;
|
||||
browser_win = new Xog_win_itm(app, this);
|
||||
this.browser_win = new Xog_win_itm(app, this);
|
||||
bnd_mgr = new Xog_bnd_mgr(browser_win);
|
||||
win_cfg = new Xocfg_win(app);
|
||||
html_mgr = new Xog_html_mgr(app);
|
||||
menu_mgr = new Xog_menu_mgr(this);
|
||||
search_suggest_mgr = new Xog_search_suggest_mgr(this);
|
||||
}
|
||||
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
|
||||
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
public Xog_win_itm Browser_win() {return browser_win;} private Xog_win_itm browser_win;
|
||||
public Xog_win_itm Browser_win() {return browser_win;} private final Xog_win_itm browser_win;
|
||||
public IptCfgRegy Ipt_cfgs() {return ipt_cfgs;} IptCfgRegy ipt_cfgs = new IptCfgRegy();
|
||||
public Xog_bnd_mgr Bnd_mgr() {return bnd_mgr;} private Xog_bnd_mgr bnd_mgr;
|
||||
public Gfui_kit Kit() {return kit;} private Gfui_kit kit = Gfui_kit_.Mem();
|
||||
@@ -78,7 +79,7 @@ public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_kit)) return kit;
|
||||
else if (ctx.Match(k, Invk_kit_)) this.kit = Gfui_kit_.Get_by_key(m.ReadStrOr("v", Gfui_kit_.Swt().Key()));
|
||||
else if (ctx.Match(k, Invk_run)) Run();
|
||||
else if (ctx.Match(k, Invk_run)) Run(RlsAble_.Null);
|
||||
else if (ctx.Match(k, Invk_browser_type)) kit.Cfg_set("HtmlBox", "BrowserType", gplx.gfui.Swt_kit.Cfg_Html_BrowserType_parse(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Invk_xul_runner_path_)) kit.Cfg_set("HtmlBox", "XulRunnerPath", Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("v")).Xto_api());
|
||||
else if (ctx.Match(k, Invk_bnds)) return bnd_mgr;
|
||||
@@ -100,7 +101,7 @@ public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
, Invk_main_win = "main_win", Invk_browser_win = "browser_win", Invk_bnds = "bnds"
|
||||
, Invk_bindings = "bindings", Invk_win_opts = "win_opts", Invk_layout = "layout", Invk_html = "html"
|
||||
, Invk_search_suggest = "search_suggest", Invk_menus = "menus", Invk_cmds = "cmds", Invk_url_macros = "url_macros";
|
||||
public void Run() {
|
||||
public void Run(RlsAble splash_win) {
|
||||
Gfo_log_bfr log_bfr = app.Log_bfr();
|
||||
try {
|
||||
Xoa_gui_mgr ui_mgr = app.Gui_mgr();
|
||||
@@ -110,6 +111,7 @@ public class Xoa_gui_mgr implements GfoEvObj, GfoInvkAble {
|
||||
Xog_win_itm_.Show_win(main_win); log_bfr.Add("app.gui.win_load.done");
|
||||
Xog_tab_itm_read_mgr.Launch(main_win);
|
||||
app.Log_wtr().Log_to_session_direct(log_bfr.Xto_str());
|
||||
splash_win.Rls();
|
||||
kit.Kit_run(); // NOTE: enters thread-loop
|
||||
} catch (Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "run_failed: ~{0} ~{1}", log_bfr.Xto_str(), Err_.Message_gplx_full(e));
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Xof_orig_file_downloader {
|
||||
public static Xof_fsdb_itm Make_fsdb(Xowe_wiki wiki, byte[] lnki_ttl, Xof_img_size img_size, Xof_url_bldr url_bldr) {
|
||||
Xof_fsdb_itm fsdb = new Xof_fsdb_itm();
|
||||
lnki_ttl = Xoa_ttl.Replace_spaces(Xoa_app_.Utl__encoder_mgr().Http_url().Decode(lnki_ttl));
|
||||
fsdb.Init_at_lnki(Xof_exec_tid.Tid_viewer_app, wiki.Domain_itm().Abrv_xo(), lnki_ttl, Xop_lnki_type.Id_none, Xop_lnki_tkn.Upright_null, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, Xof_lnki_time.Null, Xof_lnki_page.Null, Xof_patch_upright_tid_.Tid_all);
|
||||
fsdb.Init_at_lnki(Xof_exec_tid.Tid_viewer_app, wiki.Domain_itm().Abrv_xo(), lnki_ttl, Xop_lnki_type.Id_none, Xop_lnki_tkn.Upright_null, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, Xof_lnki_time.Null, Xof_lnki_page.Null, Xof_patch_upright_tid_.Tid_all);
|
||||
fsdb.Init_at_hdoc(Int_.MaxValue, Xof_html_elem.Tid_img);// NOTE: set elem_id to "impossible" number, otherwise it will auto-update an image on the page with a super-large size; [[File:Alfred Sisley 062.jpg]]
|
||||
Xof_orig_itm orig = wiki.File__orig_mgr().Find_by_ttl_or_null(lnki_ttl); if (orig == Xof_orig_itm.Null) return null; // orig not found; need orig in order to get repo
|
||||
Xof_repo_itm repo = wiki.File__repo_mgr().Get_trg_by_id_or_null(orig.Repo(), lnki_ttl, Bry_.Empty); if (repo == null) return null; // repo not found
|
||||
|
||||
@@ -18,51 +18,35 @@ 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.*;
|
||||
import gplx.core.threads.*;
|
||||
public class Load_page_wkr implements Gfo_thread_wkr {
|
||||
private Xog_tab_itm tab;
|
||||
private static final Object thread_lock = new Object(); private static boolean running = false;
|
||||
private final Xog_tab_itm tab;
|
||||
public Load_page_wkr(Xog_tab_itm tab, Xowe_wiki wiki, Xoa_url url, Xoa_ttl ttl) {this.tab = tab; this.wiki = wiki; this.url = url; this.ttl = ttl;}
|
||||
public String Name() {return "xowa.load_page_wkr";}
|
||||
public boolean Resume() {return false;}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xowe_wiki Wiki() {return wiki;} private final Xowe_wiki wiki;
|
||||
public Xoa_url Url() {return url;} private final Xoa_url url;
|
||||
public Xoa_ttl Ttl() {return ttl;} private final Xoa_ttl ttl;
|
||||
public Xoae_page Page() {return page;} private Xoae_page page;
|
||||
public Xoa_url Url() {return url;} private Xoa_url url;
|
||||
public Xoa_ttl Ttl() {return ttl;} private Xoa_ttl ttl;
|
||||
public boolean Hdump_enabled() {return hdump_enabled;} private boolean hdump_enabled;
|
||||
public Exception Err() {return exc;} private Exception exc;
|
||||
private final static Object thread_lock = new Object();
|
||||
public static boolean Running() {
|
||||
boolean rv = false;
|
||||
synchronized (thread_lock) {
|
||||
rv = running;
|
||||
}
|
||||
return rv;
|
||||
} private static boolean running = false;
|
||||
private static void Running_(boolean v) {
|
||||
synchronized (thread_lock) {
|
||||
running = v;
|
||||
}
|
||||
}
|
||||
public Exception Exec_err() {return exec_err;} private Exception exec_err;
|
||||
public void Exec() {
|
||||
try {
|
||||
Running_(true);
|
||||
int wait_count = 0;
|
||||
while (gplx.xowa.html.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100) {
|
||||
while (gplx.xowa.html.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
|
||||
Thread_adp_.Sleep(10);
|
||||
}
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
|
||||
if (Env_.System_memory_free() < app.Sys_cfg().Free_mem_when()) // check if low in memory
|
||||
app.Free_mem(false); // clear caches (which will clear bry_bfr_mk)
|
||||
app.Free_mem(false); // clear caches (which will clear bry_bfr_mkr)
|
||||
else // not low in memory
|
||||
app.Utl__bfr_mkr().Clear(); // clear bry_bfr_mk only; NOTE: call before page parse, not when page is first added, else threading errors; DATE:2014-05-30
|
||||
app.Utl__bfr_mkr().Clear(); // clear bry_bfr_mkr only; NOTE: call before page parse, not when page is first added, else threading errors; DATE:2014-05-30
|
||||
this.page = wiki.Load_page_by_ttl(url, ttl, wiki.Lang(), tab, false);
|
||||
int html_db_id = page.Revision_data().Html_db_id();
|
||||
if (wiki.Html__hdump_enabled())
|
||||
hdump_enabled = true;
|
||||
this.hdump_enabled = wiki.Html__hdump_enabled();
|
||||
wait_count = 0;
|
||||
while (gplx.xowa.html.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100) {
|
||||
while (gplx.xowa.html.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
|
||||
Thread_adp_.Sleep(10);
|
||||
}
|
||||
if (wiki.Html__hdump_enabled() && html_db_id != -1) {
|
||||
if (hdump_enabled && page.Revision_data().Html_db_id() != -1) {
|
||||
// wiki.ParsePage(page, false);
|
||||
wiki.Html__hdump_rdr().Get_by_ttl(page);
|
||||
}
|
||||
@@ -71,11 +55,23 @@ public class Load_page_wkr implements Gfo_thread_wkr {
|
||||
GfoInvkAble_.InvkCmd_val(tab.Cmd_sync(), Xog_tab_itm.Invk_show_url_loaded_swt, this);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.exc = e;
|
||||
this.exec_err = e;
|
||||
GfoInvkAble_.InvkCmd_val(tab.Cmd_sync(), Xog_tab_itm.Invk_show_url_failed_swt, this);
|
||||
}
|
||||
finally {
|
||||
Running_(false);
|
||||
}
|
||||
}
|
||||
public static boolean Running() {
|
||||
boolean rv = false;
|
||||
synchronized (thread_lock) {
|
||||
rv = running;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static void Running_(boolean v) {
|
||||
synchronized (thread_lock) {
|
||||
running = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,9 +202,12 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
thread_pool.Add_at_end(redlink_thread); thread_pool.Run();
|
||||
}
|
||||
}
|
||||
public void Exec_notify(boolean pass, String msg) {
|
||||
this.Html_box().Html_js_eval_proc_as_str("xowa.cmds.exec_by_str", "xowa.notify", "{\"text\":\"" + msg + "\",\"status\":\"" + (pass ? "success" : "error") + "\"}");
|
||||
}
|
||||
@gplx.Internal protected void Show_url_failed(Load_page_wkr wkr) {
|
||||
try {
|
||||
Xog_tab_itm_read_mgr.Show_page_err(win, this, wkr.Wiki(), wkr.Url(), wkr.Ttl(), wkr.Err());
|
||||
Xog_tab_itm_read_mgr.Show_page_err(win, this, wkr.Wiki(), wkr.Url(), wkr.Ttl(), wkr.Exec_err());
|
||||
} finally {
|
||||
wkr.Wiki().Appe().Thread_mgr().Page_load_mgr().Resume();
|
||||
}
|
||||
|
||||
@@ -60,12 +60,8 @@ public class Xog_tab_itm_read_mgr {
|
||||
public static void Update_selected_tab_blank(Xog_win_itm win) {Update_selected_tab(win, null, null);} // called when all tabs are null
|
||||
public static void Update_selected_tab(Xog_win_itm win, Xoa_url url, Xoa_ttl ttl) {
|
||||
String url_str = "", win_str = Win_text_blank;
|
||||
if (url != null && ttl != null) { // TODO: remove; no longer needed for new url parser
|
||||
try {url_str = url.To_str();}
|
||||
catch (Exception e) { // HACK: failed pages will have a null wiki; for now, catch and ignore; DATE:2014-06-22
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "failed to build url: url=~{0}, err=~{1}", String_.new_u8(url.Raw()), Err_.Message_gplx_full(e));
|
||||
url_str = String_.new_u8(ttl.Full_txt());
|
||||
}
|
||||
if (url != null && ttl != null) {
|
||||
url_str = url.To_str();
|
||||
win_str = String_.new_u8(Bry_.Add(ttl.Full_txt(), Win_text_suffix_page));
|
||||
}
|
||||
win.Url_box().Text_(url_str);
|
||||
|
||||
28
400_xowa/src/gplx/xowa/gui/views/boots/Xog_error_data.java
Normal file
28
400_xowa/src/gplx/xowa/gui/views/boots/Xog_error_data.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.gui.views.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
|
||||
public class Xog_error_data {
|
||||
public Xog_error_data(String full_msg, String err_details, String err_msg) {
|
||||
this.full_msg = full_msg;
|
||||
this.err_details = err_details;
|
||||
this.err_msg = err_msg;
|
||||
}
|
||||
public String Full_msg() {return full_msg;} private final String full_msg;
|
||||
public String Err_details() {return err_details;} private final String err_details;
|
||||
public String Err_msg() {return err_msg;} private final String err_msg;
|
||||
}
|
||||
107
400_xowa/src/gplx/xowa/gui/views/boots/Xog_error_win.java
Normal file
107
400_xowa/src/gplx/xowa/gui/views/boots/Xog_error_win.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
import java.awt.*; import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
public class Xog_error_win extends JFrame implements GfoInvkAble {
|
||||
private Xog_error_data error_data;
|
||||
public Xog_error_win(Xog_error_data error_data) {
|
||||
super("XOWA Error");
|
||||
this.setTitle("XOWA Error");
|
||||
this.error_data = error_data;
|
||||
try {
|
||||
UIManager.setLookAndFeel(
|
||||
UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Exception e) {System.out.println(e.getMessage());}
|
||||
this.setSize(700, 580);
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
this.setLocationRelativeTo(null);
|
||||
this.setBackground(Color.WHITE);
|
||||
JPanel main_panel = new JPanel();
|
||||
main_panel.setSize(700, 580);
|
||||
this.setContentPane(main_panel);
|
||||
this.setLayout(null);
|
||||
new_text_area(main_panel, error_data);
|
||||
new_link_lbl(this, main_panel, 10, 520, Invk_open_site, "<html><a href=\"\">open issue</a></html>");
|
||||
new_link_lbl(this, main_panel, 605, 520, Invk_send_mail, "<html><a href=\"\">send email</a></html>");
|
||||
this.setVisible(true);
|
||||
}
|
||||
private static JScrollPane new_text_area(JPanel owner, Xog_error_data error_data) {
|
||||
JTextArea text_area = new JTextArea();
|
||||
text_area.setForeground(Color.BLACK);
|
||||
text_area.setBackground(Color.WHITE);
|
||||
text_area.setMargin(new Insets(0, 0, 0,0));
|
||||
text_area.setLineWrap(true);
|
||||
text_area.setWrapStyleWord(true); // else text will wrap in middle of words
|
||||
text_area.setCaretColor(Color.BLACK);
|
||||
text_area.getCaret().setBlinkRate(0);
|
||||
text_area.setText(error_data.Full_msg());
|
||||
JScrollPane text_scroll_pane = new JScrollPane(text_area);
|
||||
text_scroll_pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
owner.add(text_scroll_pane);
|
||||
text_scroll_pane.setSize(675, 500);
|
||||
text_scroll_pane.setLocation(10, 10);
|
||||
return text_scroll_pane;
|
||||
}
|
||||
private static JLabel new_link_lbl(GfoInvkAble invk, JPanel owner, int x, int y, String invk_cmd, String text) {
|
||||
JLabel rv = new JLabel();
|
||||
rv.setText(text);
|
||||
rv.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
rv.addMouseListener(new Swing_mouse_adapter(GfoInvkAbleCmd.new_(invk, invk_cmd)));
|
||||
rv.setLocation(x, y);
|
||||
rv.setSize(80, 20);
|
||||
owner.add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_send_mail)) {
|
||||
try {
|
||||
Url_encoder url_encoder = Xoa_app_.Utl__encoder_mgr().Fsys_safe();
|
||||
String subject = url_encoder.Encode_str("XOWA boot error: " + error_data.Err_msg());
|
||||
String body = url_encoder.Encode_str(error_data.Err_details());
|
||||
Desktop.getDesktop().mail(new URI("mailto:gnosygnu+xowa_error_boot@gmail.com?subject=" + subject + "&body=" + body));
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
//It looks like there's a problem
|
||||
}
|
||||
}
|
||||
else if (ctx.Match(k, Invk_open_site)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://github.com/gnosygnu/xowa/issues"));
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
//It looks like there's a problem
|
||||
}
|
||||
}
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_send_mail = "send_mail", Invk_open_site = "open_site";
|
||||
}
|
||||
class Swing_mouse_adapter extends MouseAdapter {
|
||||
private final GfoInvkAbleCmd cmd;
|
||||
public Swing_mouse_adapter(GfoInvkAbleCmd cmd) {this.cmd = cmd;}
|
||||
@Override public void mouseClicked(MouseEvent ev) {
|
||||
try {cmd.Invk();}
|
||||
catch (Exception e) {
|
||||
System.out.println(Err_.Message_gplx_full(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
51
400_xowa/src/gplx/xowa/gui/views/boots/Xog_splash_win.java
Normal file
51
400_xowa/src/gplx/xowa/gui/views/boots/Xog_splash_win.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
public class Xog_splash_win implements RlsAble {
|
||||
private SplashScreen splash;
|
||||
private Graphics2D graphics; private boolean graphics_init = true;
|
||||
public Xog_splash_win(boolean app_mode_is_gui) {
|
||||
if (app_mode_is_gui) {
|
||||
this.splash = SplashScreen.getSplashScreen();
|
||||
if (splash == null) System.out.println("SplashScreen.getSplashScreen() returned null");
|
||||
}
|
||||
}
|
||||
public void Write(String msg) {
|
||||
if (splash == null) return;
|
||||
if (graphics_init) {
|
||||
graphics_init = false;
|
||||
if (graphics == null) {
|
||||
graphics = splash.createGraphics();
|
||||
if (graphics == null) System.out.println("graphics is null");
|
||||
}
|
||||
}
|
||||
if (graphics == null) return;
|
||||
graphics.setComposite(AlphaComposite.Clear);
|
||||
graphics.fillRect(120,140,200,40);
|
||||
graphics.setPaintMode();
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.drawString(msg, 0, 0);
|
||||
splash.update();
|
||||
}
|
||||
public void Rls() {
|
||||
if (splash == null) return;
|
||||
splash.close();
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,5 @@ public class Dbui_btn_itm {
|
||||
public String Cmd() {return cmd;} private final String cmd;
|
||||
public String Img() {return img;} private final String img;
|
||||
public String Text() {return text;} private final String text;
|
||||
public static final Dbui_btn_itm[] Ary_empty = new Dbui_btn_itm[0];
|
||||
}
|
||||
|
||||
@@ -22,5 +22,5 @@ public class Dbui_col_itm {
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Display() {return display;} private final String display;
|
||||
public int Width() {return width;} private final int width;
|
||||
public static final int Type_id_str = 1, Type_id_text = 2;
|
||||
public static final int Type_id_str = 1, Type_id_text = 2, Type_id_int = 3, Type_id_datetime = 4;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xowd_css_core_mgr {
|
||||
Db_conn conn = core_tbl.Conn();
|
||||
Io_url[] file_list = Io_mgr.I.QueryDir_args(css_dir).Recur_().ExecAsUrlAry();
|
||||
try {
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("schema__css_core__set");
|
||||
int css_id = core_tbl.Select_id_by_key(key);
|
||||
DateAdp updated_on = DateAdp_.Now().XtoUtc();
|
||||
if (css_id == -1)
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Xohd_hdump_rdr {
|
||||
synchronized (dbpg) {
|
||||
dbpg.Clear();
|
||||
if ( !Get_by_ttl__fill_hpg(rv, ttl)
|
||||
|| rv.Page_body() == null) { // occurs when row exists in page, but not in html
|
||||
|| rv.Page_body() == null) { // occurs when row exists in page_table, but not in html_table
|
||||
rv.Exists_n_();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ public class Xohd_hdump_wtr {
|
||||
Xowd_db_file hdump_db = Xowd_db_file.Null;
|
||||
if (html_db_id == -1) {
|
||||
hdump_db = core_data_mgr.Db__html();
|
||||
if (hdump_db == null) {
|
||||
hdump_db = core_data_mgr.Dbs__make_by_tid(Xowd_db_file_.Tid_html_data);
|
||||
Xowd_html_tbl tbl = hdump_db.Tbl__html();
|
||||
tbl.Create_tbl();
|
||||
}
|
||||
|
||||
html_db_id = hdump_db.Id();
|
||||
page.Revision_data().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Revision_data().Id(), html_db_id);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class Xohd_abrv_mgr {
|
||||
}
|
||||
}
|
||||
url_bldr.Init_by_root(img.Orig_repo_id() == Xof_repo_itm_.Repo_remote ? file_dir_comm : file_dir_wiki, Byte_ascii.Slash, false, false, 2);
|
||||
url_bldr.Init_by_itm(img.File_is_orig() ? Xof_repo_itm_.Mode_orig : Xof_repo_itm_.Mode_thumb, img.Lnki_ttl(), Xof_file_wkr_.Md5_(img.Lnki_ttl()), Xof_ext_.new_by_id_(img.Orig_ext()), img.File_w(), img.Lnki_time(), img.Lnki_page());
|
||||
url_bldr.Init_by_itm(img.File_is_orig() ? Xof_repo_itm_.Mode_orig : Xof_repo_itm_.Mode_thumb, img.Lnki_ttl(), Xof_file_wkr_.Md5(img.Lnki_ttl()), Xof_ext_.new_by_id_(img.Orig_ext()), img.File_w(), img.Lnki_time(), img.Lnki_page());
|
||||
byte[] img_src = url_bldr.Xto_bry();
|
||||
if (tid == Xohd_abrv_.Tid_img) {
|
||||
fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.Html_h());
|
||||
|
||||
@@ -48,7 +48,7 @@ class Xob_link_dump_tbl implements RlsAble {
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert_bgn() {conn.Txn_bgn();}
|
||||
public void Insert_bgn() {conn.Txn_bgn("bldr__link_dump");}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int src_page_id, int src_html_uid, int trg_ns, byte[] trg_ttl) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(Tbl_name, flds.To_str_ary_wo_autonum());
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
if (html_db_id != cur_html_db_id) {
|
||||
if (html_dump_tbl != null) html_dump_tbl.Conn().Txn_end();
|
||||
html_dump_tbl = wiki.Data__core_mgr().Dbs__get_at(html_db_id).Tbl__html();
|
||||
html_dump_tbl.Conn().Txn_bgn();
|
||||
html_dump_tbl.Conn().Txn_bgn("bldr__redlink");
|
||||
cur_html_db_id = html_db_id;
|
||||
}
|
||||
// commit page_id if needed
|
||||
|
||||
@@ -226,7 +226,7 @@ public class Xow_hzip_itm__anchor {
|
||||
;
|
||||
private static final byte Href_tid_wiki = 1, Href_tid_site = 2;
|
||||
private static final int Href_bry_len = 6; // "/wiki/".length
|
||||
private static final Btrie_fast_mgr btrie_href = Btrie_fast_mgr.cs_()
|
||||
private static final Btrie_fast_mgr btrie_href = Btrie_fast_mgr.cs()
|
||||
.Add_str_byte("/wiki/", Href_tid_wiki)
|
||||
.Add_str_byte("/site/", Href_tid_site);
|
||||
private static final int
|
||||
|
||||
@@ -102,7 +102,7 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
public byte[] Div_home_bry() {return api_skin != null && api_skin.Sidebar_home_enabled() ? div_home_bry : Bry_.Empty;} private byte[] div_home_bry = Bry_.Empty;
|
||||
public byte[] Div_wikis_bry(Bry_bfr_mkr bfr_mkr) {
|
||||
if (toggle_itm == null) // TEST:lazy-new b/c Init_by_wiki
|
||||
toggle_itm = wiki.Appe().Api_root().Html().Page().Toggle_mgr().Get_or_new("offline-wikis").Init(wiki.Appe().Usere().Wiki(), Bry_.new_a7("Wikis"));
|
||||
toggle_itm = wiki.Appe().Api_root().Html().Page().Toggle_mgr().Get_or_new("offline-wikis").Init(Bry_.new_a7("Wikis"));
|
||||
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
|
||||
div_wikis_fmtr.Bld_bfr_many(tmp_bfr, toggle_itm.Html_toggle_btn(), toggle_itm.Html_toggle_hdr());
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.langs.cases; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*; import gplx.intl.*;
|
||||
public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.new_(); private Btrie_fast_mgr upper_trie = Btrie_fast_mgr.cs_(), lower_trie = Btrie_fast_mgr.cs_(); private Xol_case_itm[] itms;
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.new_(); private Btrie_fast_mgr upper_trie = Btrie_fast_mgr.cs(), lower_trie = Btrie_fast_mgr.cs(); private Xol_case_itm[] itms;
|
||||
public Xol_case_mgr(byte tid) {this.tid = tid;}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Gfo_case_itm Get_or_null(byte bgn_byte, byte[] src, int bgn, int end) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user