mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.4.1
This commit is contained in:
@@ -29,8 +29,8 @@ public class Json_doc_srl {
|
||||
return this;
|
||||
}
|
||||
public void Write_obj(boolean comma, byte[] key, Object val) {
|
||||
Class<?> t = ClassAdp_.ClassOf_obj(val);
|
||||
if (ClassAdp_.Is_array(t))
|
||||
Class<?> t = Type_adp_.ClassOf_obj(val);
|
||||
if (Type_adp_.Is_array(t))
|
||||
Write_kv_ary(comma, key, (Object[])val);
|
||||
else
|
||||
Write_kv_str(comma, key, Object_.Xto_str_strict_or_empty(val));
|
||||
|
||||
@@ -21,11 +21,12 @@ public class Json_wtr {
|
||||
private int indent;
|
||||
private boolean nde_itm_is_first;
|
||||
private boolean ary_itm_is_first;
|
||||
public Bry_bfr Bfr() {return bfr;}
|
||||
public void Indent_(int v) {this.indent = v;}
|
||||
public byte Opt_quote_byte() {return opt_quote_byte;} public Json_wtr Opt_quote_byte_(byte v) {opt_quote_byte = v; return this;} private byte opt_quote_byte = Byte_ascii.Quote;
|
||||
public boolean Opt_ws() {return opt_ws;} public Json_wtr Opt_ws_(boolean v) {opt_ws = v; return this;} private boolean opt_ws = true;
|
||||
public byte[] To_bry_and_clear() {return bfr.Xto_bry_and_clear();}
|
||||
public String To_str_and_clear() {return bfr.Xto_str_and_clear();}
|
||||
public Bry_bfr Bfr() {return bfr;}
|
||||
public Json_wtr Clear() {
|
||||
indent = 0;
|
||||
nde_itm_is_first = ary_itm_is_first = true;
|
||||
@@ -33,11 +34,10 @@ public class Json_wtr {
|
||||
}
|
||||
public Json_wtr Doc_bgn() {return Add_grp_bgn(Sym_nde_bgn);}
|
||||
public Json_wtr Doc_end() {Add_grp_end(Bool_.Y, Sym_nde_end); return Add_nl();}
|
||||
public void Indent_(int v) {this.indent = v;}
|
||||
public Json_wtr Nde_bgn(String nde) {return Nde_bgn(Bry_.new_u8(nde));}
|
||||
public Json_wtr Nde_bgn(byte[] nde) {
|
||||
public Json_wtr Nde_bgn(String key) {return Nde_bgn(Bry_.new_u8(key));}
|
||||
public Json_wtr Nde_bgn(byte[] key) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(nde);
|
||||
Add_key(key);
|
||||
Add_nl();
|
||||
return Add_grp_bgn(Sym_nde_bgn);
|
||||
}
|
||||
@@ -49,17 +49,23 @@ public class Json_wtr {
|
||||
ary_itm_is_first = true;
|
||||
return Add_grp_bgn(Sym_ary_bgn);
|
||||
}
|
||||
public Json_wtr Ary_itm_str(String itm) {
|
||||
public Json_wtr Ary_itm_str(String itm) {return Ary_itm_by_type_tid(Type_adp_.Tid__str, itm);}
|
||||
public Json_wtr Ary_itm_bry(byte[] itm) {return Ary_itm_by_type_tid(Type_adp_.Tid__bry, itm);}
|
||||
public Json_wtr Ary_itm_obj(Object itm) {return Ary_itm_by_type_tid(Type_adp_.To_tid(itm), itm);}
|
||||
private Json_wtr Ary_itm_by_type_tid(int itm_type_tid, Object itm) {
|
||||
Add_indent_itm(ary_itm_is_first);
|
||||
Add_itm_bry(Bry_.new_u8(itm));
|
||||
Add_itm_by_tid(itm_type_tid, itm);
|
||||
Add_nl();
|
||||
ary_itm_is_first = false;
|
||||
return this;
|
||||
}
|
||||
public Json_wtr Ary_end() {Add_grp_end(Bool_.N, Sym_ary_end); return Add_nl();}
|
||||
public Json_wtr Kv_bool(String key, boolean val) {return Kv_bool(Bry_.new_u8(key), val);}
|
||||
public Json_wtr Kv_bool(byte[] key, boolean val) {return Kv_raw(key, val ? Bool_.True_bry : Bool_.False_bry);}
|
||||
public Json_wtr Kv_int(String key, int val) {return Kv_raw(Bry_.new_u8(key), Int_.Xto_bry(val));}
|
||||
public Json_wtr Kv_bool(String key, boolean val) {return Kv_bool(Bry_.new_u8(key), val);}
|
||||
public Json_wtr Kv_bool(byte[] key, boolean val) {return Kv_raw(key, val ? Bool_.True_bry : Bool_.False_bry);}
|
||||
public Json_wtr Kv_int(String key, int val) {return Kv_raw(Bry_.new_u8(key), Int_.Xto_bry(val));}
|
||||
public Json_wtr Kv_long(String key, long val) {return Kv_raw(Bry_.new_u8(key), Bry_.new_a7(Long_.Xto_str(val)));}
|
||||
public Json_wtr Kv_float(String key, float val) {return Kv_raw(Bry_.new_u8(key), Bry_.new_a7(Float_.Xto_str(val)));}
|
||||
public Json_wtr Kv_double(String key, double val) {return Kv_raw(Bry_.new_u8(key), Bry_.new_a7(Double_.Xto_str(val)));}
|
||||
private Json_wtr Kv_raw(byte[] key, byte[] val) {
|
||||
Add_indent_itm(nde_itm_is_first);
|
||||
Add_key(key);
|
||||
@@ -109,6 +115,23 @@ public class Json_wtr {
|
||||
bfr.Add_byte_colon();
|
||||
return this;
|
||||
}
|
||||
public void Add_itm_by_tid(int type_tid, Object obj) {
|
||||
switch (type_tid) {
|
||||
case Type_adp_.Tid__bool: bfr.Add_bool(Bool_.cast_(obj)); break;
|
||||
case Type_adp_.Tid__byte: bfr.Add_byte(Byte_.cast_(obj)); break;
|
||||
case Type_adp_.Tid__int: bfr.Add_int_variable(Int_.cast_(obj)); break;
|
||||
case Type_adp_.Tid__long: bfr.Add_long_variable(Long_.cast_(obj)); break;
|
||||
case Type_adp_.Tid__float: bfr.Add_float(Float_.cast_(obj)); break;
|
||||
case Type_adp_.Tid__double: bfr.Add_double(Double_.cast_(obj)); break;
|
||||
case Type_adp_.Tid__str: Add_itm_bry(Bry_.new_u8((String)obj)); break;
|
||||
case Type_adp_.Tid__bry: Add_itm_bry((byte[])obj); break;
|
||||
case Type_adp_.Tid__char:
|
||||
case Type_adp_.Tid__date:
|
||||
case Type_adp_.Tid__decimal: Add_itm_bry(Bry_.new_u8(Object_.Xto_str_strict_or_empty(obj))); break;
|
||||
case Type_adp_.Tid__null:
|
||||
default: throw Err_.new_unhandled(type_tid);
|
||||
}
|
||||
}
|
||||
private void Add_itm_bry(byte[] bry) {Add_itm_bry(bry, 0, bry.length);}
|
||||
private void Add_itm_bry(byte[] bry, int bgn, int end) {
|
||||
bfr.Add_byte(opt_quote_byte);
|
||||
|
||||
@@ -24,20 +24,22 @@ public class Gfo_protocol_itm {
|
||||
int text_len = text_bry.length;
|
||||
for (int i = 0; i < text_len; i++) {
|
||||
if (text_bry[i] == Byte_ascii.Colon) {
|
||||
key_wo_colon_bry = Bry_.Mid(text_bry, 0, i);
|
||||
key_w_colon_bry_len = i;
|
||||
key_wo_colon_str = String_.new_u8(key_wo_colon_bry);
|
||||
key_w_colon_bry = Bry_.Mid(text_bry, 0, i + 1);
|
||||
text_ends_w_colon = i == text_len - 1;
|
||||
this.key_wo_colon_bry = Bry_.Mid(text_bry, 0, i);
|
||||
this.key_w_colon_bry_len = i;
|
||||
this.key_wo_colon_str = String_.new_u8(key_wo_colon_bry);
|
||||
this.key_w_colon_bry = Bry_.Mid(text_bry, 0, i + 1);
|
||||
this.key_w_colon_str = String_.new_u8(key_w_colon_bry);
|
||||
this.text_ends_w_colon = i == text_len - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Key_wo_colon_bry() {return key_wo_colon_bry;} private byte[] key_wo_colon_bry; // http
|
||||
public String Key_wo_colon_str() {return key_wo_colon_str;} private String key_wo_colon_str;
|
||||
public byte[] Key_w_colon_bry() {return key_w_colon_bry;} private byte[] key_w_colon_bry; // http:
|
||||
public int Key_w_colon_bry_len() {return key_w_colon_bry_len;} private int key_w_colon_bry_len;
|
||||
public byte[] Key_wo_colon_bry() {return key_wo_colon_bry;} private byte[] key_wo_colon_bry; // http
|
||||
public String Key_wo_colon_str() {return key_wo_colon_str;} private String key_wo_colon_str;
|
||||
public byte[] Key_w_colon_bry() {return key_w_colon_bry;} private byte[] key_w_colon_bry; // http:
|
||||
public String Key_w_colon_str() {return key_w_colon_str;} private String key_w_colon_str;
|
||||
public int Key_w_colon_bry_len() {return key_w_colon_bry_len;} private int key_w_colon_bry_len;
|
||||
public byte[] Text_bry() {return text_bry;} private byte[] text_bry; // http://
|
||||
public String Text_str() {return text_str;} private String text_str;
|
||||
public boolean Text_ends_w_colon() {return text_ends_w_colon;} private boolean text_ends_w_colon;
|
||||
|
||||
@@ -127,7 +127,7 @@ public class Gfui_bnd_parser {
|
||||
switch (sym_tkn.Tid()) {
|
||||
case Gfui_bnd_tkn.Tid_sym_plus: // EX: Ctrl + A
|
||||
if (mod_adj != Mod_val_null) { // if mod, just update mod_val and exit
|
||||
mod_val = Enm_.FlipInt(true, mod_val, mod_adj);
|
||||
mod_val = Enm_.Flip_int(true, mod_val, mod_adj);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Dsv_fld_parser_ {
|
||||
public static final Dsv_fld_parser Int_parser = Dsv_fld_parser_int._;
|
||||
public static final Dsv_fld_parser Line_parser__comment_is_pipe = new Dsv_fld_parser_line(Byte_ascii.Pipe);
|
||||
public static Err err_fld_unhandled(Dsv_fld_parser parser, Dsv_wkr_base wkr, int fld_idx, byte[] src, int bgn, int end) {
|
||||
throw Err_.new_wo_type("fld unhandled", "parser", ClassAdp_.NameOf_obj(parser), "wkr", ClassAdp_.NameOf_obj(wkr), "fld_idx", fld_idx, "val", String_.new_u8(src, bgn, end)).Trace_ignore_add_1_();
|
||||
throw Err_.new_wo_type("fld unhandled", "parser", Type_adp_.NameOf_obj(parser), "wkr", Type_adp_.NameOf_obj(wkr), "fld_idx", fld_idx, "val", String_.new_u8(src, bgn, end)).Trace_ignore_add_1_();
|
||||
}
|
||||
}
|
||||
class Dsv_fld_parser_line implements Dsv_fld_parser {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.8.3.1";
|
||||
public static final String Version = "2.8.4.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_app_fxt {
|
||||
public static Xoae_app app_() {
|
||||
Io_mgr.I.InitEngine_mem();
|
||||
@@ -44,7 +44,7 @@ public class Xoa_app_fxt {
|
||||
public static Xowe_wiki wiki_(Xoae_app app, String key) {return wiki_(app, key, app.Lang_mgr().Lang_en());}
|
||||
public static Xowe_wiki wiki_(Xoae_app app, String key, Xol_lang lang) {
|
||||
Io_url wiki_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(key);
|
||||
Xowe_wiki rv = new Xowe_wiki(app, lang, Xow_ns_mgr_.default_(lang.Case_mgr()), Xow_domain_.parse(Bry_.new_u8(key)), wiki_dir);
|
||||
Xowe_wiki rv = new Xowe_wiki(app, lang, Xow_ns_mgr_.default_(lang.Case_mgr()), Xow_domain_itm_.parse(Bry_.new_u8(key)), wiki_dir);
|
||||
rv.File_mgr().Meta_mgr().Depth_(2); // TEST: written for 2 depth
|
||||
rv.Props().Main_page_(Xoa_page_.Main_page_bry); // TEST: default to Main Page (nothing tests loading Main Page from wiki.gfs)
|
||||
rv.Ns_mgr().Ids_get_or_null(Xow_ns_.Id_main).Subpages_enabled_(true);
|
||||
|
||||
@@ -24,6 +24,7 @@ public class Xoa_url_ {
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static String Main_page__home_str = gplx.xowa.wikis.domains.Xow_domain_itm_.Str__home + gplx.xowa.html.hrefs.Xoh_href_.Str__wiki + gplx.xowa.Xoa_page_.Main_page_str; // EX:home/wiki/Main_Page
|
||||
public static final byte[]
|
||||
Qarg__redirect = Bry_.new_a7("redirect")
|
||||
, Qarg__redirect__yes = Bry_.new_a7("yes")
|
||||
|
||||
@@ -71,6 +71,7 @@ class Xog_find_box {
|
||||
}
|
||||
private void Exec_find(String find, boolean highlight_matches) {
|
||||
Xog_tab_itm tab = win.Tab_mgr().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
find = String_.Replace(find, "\\", "\\\\"); // NOTE: backslashes are always literal, never escape codes; EX: "C:\new" "\n" means "\n", not (byte)10; DATE:2015-08-17
|
||||
boolean find_in_hdoc = tab.View_mode() == Xopg_view_mode.Tid_read;
|
||||
if (find_in_hdoc)
|
||||
tab.Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Win__find_in_hdoc , find, dir_fwd, case_match, wrap_search, highlight_matches);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
|
||||
private final Xow_domain_crt_kv_itm_mgr multi_wikis_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_wikis_bry = Dflt_multi_wikis_bry;
|
||||
private final Xow_domain_crt_kv_itm_mgr multi_sorts_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_sorts_bry = Dflt_multi_sorts_bry;
|
||||
@@ -33,7 +33,7 @@ public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
|
||||
this.multi_wikis_bry = v;
|
||||
GfoEvMgr_.PubVal(this, Evt_multi_wikis_changed, v);
|
||||
}
|
||||
public Xow_domain_crt_itm Multi_wikis_crt(Xow_domain cur_domain) {
|
||||
public Xow_domain_crt_itm Multi_wikis_crt(Xow_domain_itm cur_domain) {
|
||||
return multi_wikis_mgr.Find_itm(cur_domain, cur_domain);
|
||||
}
|
||||
public void Multi_sorts_bry_(byte[] v) {
|
||||
@@ -41,7 +41,7 @@ public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
|
||||
this.multi_sorts_bry = v;
|
||||
GfoEvMgr_.PubVal(this, Evt_multi_sorts_changed, v);
|
||||
}
|
||||
public Xow_domain_crt_itm[] Multi_sorts_crt(Xow_domain cur_domain) {
|
||||
public Xow_domain_crt_itm[] Multi_sorts_crt(Xow_domain_itm cur_domain) {
|
||||
return multi_sorts_mgr.Find_ary(cur_domain, cur_domain);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -20,9 +20,16 @@ import gplx.core.primitives.*;
|
||||
public class Xoa_app_type {
|
||||
Xoa_app_type(int uid) {this.uid = uid;}
|
||||
public int Uid() {return uid;} private final int uid;
|
||||
public boolean Uid_is_gui() {return uid == Uid_gui;}
|
||||
public boolean Uid_is_tcp() {return uid == Uid_tcp;}
|
||||
public boolean Uid_is_http() {return uid == Uid_http;}
|
||||
public boolean Uid_is_gui() {return uid == Uid_gui;}
|
||||
public boolean Uid_is_tcp() {return uid == Uid_tcp;}
|
||||
public boolean Uid_is_http() {return uid == Uid_http;}
|
||||
public boolean Uid_supports_js() {
|
||||
switch (uid) {
|
||||
case Uid_gui:
|
||||
case Uid_tcp: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public byte[] Name() {
|
||||
switch (uid) {
|
||||
case Uid_cmd: return Key_cmd;
|
||||
|
||||
@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.consoles.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
public class Xoa_shell implements GfoInvkAble {
|
||||
public Xoa_shell(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
public boolean Fetch_page_exec_async() {return fetch_page_exec_async;} private boolean fetch_page_exec_async = true;
|
||||
@@ -29,7 +31,8 @@ public class Xoa_shell implements GfoInvkAble {
|
||||
}
|
||||
private String Fetch_page(GfoMsg m) {
|
||||
String url = m.ReadStr("url");
|
||||
if (String_.Has_at_bgn(url, "//")) url = String_.Replace(url, "//", ""); // NOTE: handle Firefox_addon which sometimes sends urls of the form "//wiki/" when coming from the sidebar; DATE:2015-07-04
|
||||
if (String_.Eq(url, "home")) url = Xoa_url_.Main_page__home_str; // WORKAROUND.ADDON: toolbar button sends "home"; note that Fetch_page is only called from command-line / addon, so "home" should never mean "home" page in current wiki; EX: en.wikipedia.org/wiki/home; DATE:2015-08-18
|
||||
if (String_.Has_at_bgn(url, "//")) url = gplx.core.net.Gfo_protocol_itm.Itm_https.Key_w_colon_str() + url; // WORKAROUND.ADDON: sidebar sends urls of form "//en.wikipedia.org/"; prefix with "https:" so url parser can handle it; DATE:2015-07-05; DATE:2015-08-18
|
||||
return String_.new_u8(app.Gui_mgr().Browser_win().App__retrieve_by_url(url, m.ReadStrOr("output_type", "html")));
|
||||
}
|
||||
private static final String Invk_fetch_page = "fetch_page"
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
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;
|
||||
@@ -31,7 +31,7 @@ public class Xoa_fsys_mgr implements GfoInvkAble {
|
||||
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);
|
||||
this.home_wiki_dir = bin_xowa_dir.GenSubDir_nest("wiki", Xow_domain_itm_.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;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.aria2; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.wmfs.dumps.*;
|
||||
public class Aria2_lib_mgr implements GfoInvkAble {
|
||||
public ProcessAdp Lib() {return lib;} private ProcessAdp lib = new ProcessAdp();
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
@@ -27,7 +27,7 @@ public class Aria2_lib_mgr implements GfoInvkAble {
|
||||
, "wiki_abrv", "wiki_date", "wiki_type");
|
||||
}
|
||||
// private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public void Exec(Xob_dump_file dump_file) {
|
||||
public void Exec(Xowm_dump_file dump_file) {
|
||||
// byte[] args_bry = lib.Args_fmtr().Bld_bry_many(tmp_bfr, dump_file.Wiki_alias(), dump_file.Dump_date(), dump_file.Dump_file_type());
|
||||
// ProcessAdp process = new ProcessAdp().Exe_url_(lib.Exe_url()).Args_str_(String_.new_u8(args_bry));
|
||||
// process.Run_wait();
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*; import gplx.xowa.dbs.*; import gplx.fsdb.*; import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*; import gplx.xowa.dbs.*; import gplx.fsdb.*; import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.fsdb.data.*; import gplx.fsdb.meta.*;
|
||||
public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
@@ -181,7 +181,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
tier_id_val = fsdb.Lnki_tier_id();
|
||||
page_id_val = fsdb.Lnki_page_id();
|
||||
lnki_id_val = fsdb.Lnki_id();
|
||||
fsdb.Orig_repo_name_(fsdb.Orig_repo_id() == Xof_repo_itm_.Repo_local ? wiki.Domain_bry() : Xow_domain_.Domain_bry_commons);
|
||||
fsdb.Orig_repo_name_(fsdb.Orig_repo_id() == Xof_repo_itm_.Repo_local ? wiki.Domain_bry() : Xow_domain_itm_.Bry__commons);
|
||||
Download_exec(fsdb);
|
||||
++exec_count;
|
||||
if (exec_count % progress_interval == 0) Print_progress(fsdb);
|
||||
@@ -226,13 +226,10 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
finally {src_rdr.Rls();}
|
||||
}
|
||||
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
|
||||
}
|
||||
boolean is_solo = trg_mnt_itm.Db_mgr().File__solo_file();
|
||||
boolean make = true, use_txn = !is_solo; // solo file; should never open txn
|
||||
if (trg_bin_fil != null && use_txn) // pre-existing bin_file;
|
||||
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
|
||||
@@ -256,7 +253,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
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)
|
||||
if (use_txn)
|
||||
trg_bin_fil.Conn().Txn_bgn("bldr__fsdb_make__trg_bin_fil");
|
||||
}
|
||||
private void Txn_sav() {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.html.hdumps.bldrs.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.fsdb.meta.*; import gplx.xowa.files.fsdb.*; import gplx.fsdb.*;
|
||||
public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink_logger {
|
||||
@@ -49,7 +49,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_view_mode.Tid_read).Ctgs_enabled_(false); // disable categories else progress messages written (also for PERF)
|
||||
if (wiki.File__bin_mgr() != null)
|
||||
wiki.File__bin_mgr().Wkrs__del(gplx.xowa.files.bins.Xof_bin_wkr_.Key_http_wmf); // remove wmf wkr, else will try to download images during parsing
|
||||
commons_wiki = app.Wiki_mgr().Get_by_key_or_make(Xow_domain_.Domain_bry_commons);
|
||||
commons_wiki = app.Wiki_mgr().Get_by_key_or_make(Xow_domain_itm_.Bry__commons);
|
||||
Xop_log_mgr log_mgr = ctx.App().Log_mgr();
|
||||
log_mgr.Log_dir_(wiki.Fsys_mgr().Root_dir()); // put log in wiki dir, instead of user.temp
|
||||
invoke_wkr = this.Invoke_wkr(); // set member reference
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xob_orig_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
private boolean repo_0_is_remote = false;
|
||||
public Xob_orig_regy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
@@ -25,7 +26,7 @@ public class Xob_orig_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public void Cmd_bgn(Xob_bldr bldr) {
|
||||
Db_conn conn = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
Xob_orig_regy_tbl.Create_table(conn);
|
||||
Xowe_wiki commons_wiki = bldr.App().Wiki_mgr().Get_by_key_or_make(Xow_domain_.Domain_bry_commons).Init_assert();
|
||||
Xowe_wiki commons_wiki = bldr.App().Wiki_mgr().Get_by_key_or_make(Xow_domain_itm_.Bry__commons).Init_assert();
|
||||
Xowe_wiki repo_0 = wiki, repo_1 = commons_wiki;
|
||||
if (repo_0_is_remote) { // NOTE: default is false; local_wiki will be preferred over commons_wiki
|
||||
repo_0 = commons_wiki;
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.dbs.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.dbs.engines.sqlite.*;
|
||||
class Xob_orig_regy_tbl {
|
||||
public static void Create_table(Db_conn p) {Sqlite_engine_.Tbl_create_and_delete(p, Tbl_name, Tbl_sql);}
|
||||
@@ -30,7 +31,7 @@ class Xob_orig_regy_tbl {
|
||||
boolean local_is_remote = Bry_.Eq(repo_0_wiki.Domain_bry(), repo_1_wiki.Domain_bry());
|
||||
Xowe_wiki local_wiki = repo_0_wiki;
|
||||
if ( repo_0_is_remote // .gfs manually marked specifes repo_0 as remote
|
||||
|| ( Bry_.Eq(repo_0_wiki.Domain_bry(), Xow_domain_.Domain_bry_commons) // repo_0 = commons; force repo_0 to be remote; else all orig_repo will be 1; DATE:2014-02-01
|
||||
|| ( Bry_.Eq(repo_0_wiki.Domain_bry(), Xow_domain_itm_.Bry__commons) // repo_0 = commons; force repo_0 to be remote; else all orig_repo will be 1; DATE:2014-02-01
|
||||
&& local_is_remote // repo_0 = repo_1
|
||||
)
|
||||
) {
|
||||
|
||||
@@ -16,14 +16,15 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xob_page_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public Xob_page_regy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
private boolean build_commons = false;
|
||||
public String Cmd_key() {return Xob_cmd_keys.Key_file_page_regy;}
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {
|
||||
Xowe_wiki commons_wiki = bldr.App().Wiki_mgr().Get_by_key_or_make(Xow_domain_.Domain_bry_commons).Init_assert();
|
||||
Xowe_wiki commons_wiki = bldr.App().Wiki_mgr().Get_by_key_or_make(Xow_domain_itm_.Bry__commons).Init_assert();
|
||||
Db_conn page_regy_provider = Xob_db_file.new__page_regy(commons_wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
commons_wiki.Init_assert();
|
||||
if (build_commons) {
|
||||
|
||||
@@ -26,6 +26,7 @@ public class Xob_xfer_regy_update_cmd extends Xob_itm_basic_base implements Xob_
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_term() {}
|
||||
private void Exec_main() {
|
||||
wiki.Init_assert(); // NOTE: must init wiki to set up db_core; DATE:2015-08-17
|
||||
Db_conn make_db_provider = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
this.Copy_atrs_to_make_db(make_db_provider);
|
||||
this.Update_status(make_db_provider);
|
||||
|
||||
@@ -16,8 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.texts; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*;
|
||||
import gplx.xowa.xtns.wdatas.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public abstract class Xob_init_base implements Xob_cmd, GfoInvkAble {
|
||||
private Xob_bldr bldr; private Xowe_wiki wiki; private Gfo_usr_dlg usr_dlg;
|
||||
private byte wbase_enabled = Bool_.__byte;
|
||||
@@ -27,7 +28,7 @@ public abstract class Xob_init_base implements Xob_cmd, GfoInvkAble {
|
||||
public abstract void Cmd_run_end(Xowe_wiki wiki);
|
||||
public void Cmd_init(Xob_bldr bldr) { // add other cmds; EX: wikidata
|
||||
bldr.Import_marker().Bgn(wiki);
|
||||
if (wbase_enabled == Bool_.__byte) wbase_enabled = wiki.Domain_tid() == Xow_domain_type_.Tid_wikidata ? Bool_.Y_byte : Bool_.N_byte; // if wbase_enabled not explicitly set, set it to y if wiki is "www.wikidata.org"
|
||||
if (wbase_enabled == Bool_.__byte) wbase_enabled = wiki.Domain_tid() == Xow_domain_type_.Int__wikidata ? Bool_.Y_byte : Bool_.N_byte; // if wbase_enabled not explicitly set, set it to y if wiki is "www.wikidata.org"
|
||||
if (wbase_enabled == Bool_.Y_byte) // if wbase_enabled, auto-add wdata_wkrs bldr
|
||||
this.Cmd_ini_wdata(bldr, wiki);
|
||||
}
|
||||
|
||||
@@ -16,20 +16,22 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.wmfs.dumps.*;
|
||||
public class Xob_core_batch_utl implements GfoInvkAble {
|
||||
public Xob_core_batch_utl(Xob_bldr bldr, byte[] raw) {this.bldr = bldr; fmtr.Fmt_(raw);} private Xob_bldr bldr;
|
||||
Bry_fmtr fmtr = Bry_fmtr.keys_("bz2_fil", "wiki_key");
|
||||
private final Xob_bldr bldr;
|
||||
private final Bry_fmtr fmtr = Bry_fmtr.keys_("bz2_fil", "wiki_key");
|
||||
public Xob_core_batch_utl(Xob_bldr bldr, byte[] raw) {this.bldr = bldr; fmtr.Fmt_(raw);}
|
||||
private void Run() {
|
||||
Io_url[] bz2_fils = Io_mgr.I.QueryDir_fils(bldr.App().Fsys_mgr().Wiki_dir().GenSubDir_nest(Dir_dump, "todo"));
|
||||
Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_kb);
|
||||
int bz2_fils_len = bz2_fils.length;
|
||||
Xow_wiki_alias bz2_fil = new Xow_wiki_alias();
|
||||
for (int i = 0; i < bz2_fils_len; i++) {
|
||||
Io_url bz2_fil_url = bz2_fils[i];
|
||||
bz2_fil.Fil_(bz2_fil_url).Parse(bz2_fil_url.NameOnly());
|
||||
fmtr.Bld_bfr_many(bfr, bz2_fil_url.Raw(), bz2_fil.Domain());
|
||||
bldr.Usr_dlg().Note_many("", "", "starting script for ~{0}", String_.new_u8(bz2_fil.Domain()));
|
||||
Xowm_dump_file dump_file = Xowm_dump_file_.parse(Bry_.new_u8(bz2_fil_url.NameOnly()));
|
||||
String domain_str = dump_file.Domain_itm().Domain_str();
|
||||
fmtr.Bld_bfr_many(bfr, bz2_fil_url.Raw(), domain_str);
|
||||
bldr.Usr_dlg().Note_many("", "", "starting script for ~{0}", domain_str);
|
||||
bldr.App().Gfs_mgr().Run_str(bfr.Xto_str_and_clear());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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.ios.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.wmfs.dumps.*;
|
||||
public class Xob_download_wkr extends Xob_itm_basic_base implements Xob_cmd {
|
||||
private String dump_date = "latest";
|
||||
private String dump_type = null;
|
||||
@@ -28,7 +29,7 @@ public class Xob_download_wkr extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {
|
||||
if (dump_type == null) throw Err_.new_wo_type("dump_type must be specified");
|
||||
Xob_dump_file dump_file = Xob_dump_file.new_(wiki.Domain_str(), dump_date, dump_type);
|
||||
Xowm_dump_file dump_file = new Xowm_dump_file(wiki.Domain_str(), dump_date, dump_type);
|
||||
if (dump_src == null) {
|
||||
dump_file.Server_url_(app.Setup_mgr().Dump_mgr().Server_urls()[0]);
|
||||
dump_src = dump_file.File_url();
|
||||
|
||||
@@ -21,14 +21,25 @@ import gplx.xowa.wmfs.*; import gplx.xowa.wmfs.data.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xob_site_meta_cmd implements Xob_cmd {
|
||||
private final Xob_bldr bldr;
|
||||
private String[] wikis; private Io_url db_url; private DateAdp cutoff_time;
|
||||
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() {
|
||||
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());
|
||||
if (wikis == null) wikis = Xow_wmf_api_mgr.Wikis;
|
||||
if (db_url == null) db_url = bldr.App().Fsys_mgr().Cfg_site_meta_fil();
|
||||
if (cutoff_time == null) cutoff_time = DateAdp_.Now().Add_day(-1);
|
||||
Site_meta_itm.Build_site_meta(bldr.App().Wmf_mgr(), db_url, wikis, cutoff_time);
|
||||
}
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_term() {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return GfoInvkAble_.Rv_unhandled;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_db_url_)) this.db_url = m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk_wikis_)) this.wikis = m.ReadStrAry("v", "\n");
|
||||
else if (ctx.Match(k, Invk_cutoff_time_)) this.cutoff_time = m.ReadDate("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static String Invk_db_url_ = "db_url_", Invk_wikis_ = "wikis_", Invk_cutoff_time_ = "cutoff_time_";
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.ios.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.files.downloads.*;
|
||||
import gplx.core.net.*;
|
||||
public class Xoa_css_extractor {
|
||||
@@ -49,7 +49,7 @@ public class Xoa_css_extractor {
|
||||
Io_url css_comm_fil = wiki_html_dir.GenSubFil(Css_common_name);
|
||||
Io_url css_wiki_fil = wiki_html_dir.GenSubFil(Css_wiki_name);
|
||||
wiki.Html__page_wtr_mgr().Init_css_urls(css_comm_fil, css_wiki_fil);
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home || Env_.Mode_testing()) return; // NOTE: do not download if home_wiki; also needed for TEST
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Int__home || Env_.Mode_testing()) return; // NOTE: do not download if home_wiki; also needed for TEST
|
||||
if (Io_mgr.I.ExistsFil(css_wiki_fil)) return; // css file exists; nothing to generate
|
||||
if (wiki.Html__css_installing()) return;
|
||||
wiki.Html__css_installing_(true);
|
||||
@@ -200,7 +200,7 @@ public class Xoa_css_extractor {
|
||||
}
|
||||
private byte[] Mainpage_download_html() {
|
||||
String main_page_url_temp = mainpage_url;
|
||||
if (Bry_.Eq(wiki_domain, Xow_domain_.Domain_bry_wikidata)) // if wikidata, download css for a Q* page; Main_Page has less css; DATE:2014-09-30
|
||||
if (Bry_.Eq(wiki_domain, Xow_domain_itm_.Bry__wikidata)) // if wikidata, download css for a Q* page; Main_Page has less css; DATE:2014-09-30
|
||||
main_page_url_temp = main_page_url_temp + "/wiki/Q2";
|
||||
String log_msg = usr_dlg.Prog_many("", "main_page.download", "downloading main page for '~{0}'", main_page_url_temp);
|
||||
byte[] main_page_html = download_xrg.Prog_fmt_hdr_(log_msg).Exec_as_bry(main_page_url_temp);
|
||||
|
||||
@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.core.xmls.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xob_xml_dumper {
|
||||
private final Gfo_xml_wtr wtr = new Gfo_xml_wtr();
|
||||
public String Bld_str() {return wtr.Bld_str();}
|
||||
public void Write_root_bgn(Xow_ns_mgr ns_mgr, Xow_domain domain, String wiki_abrv, String main_page, String ns_case, String app_version) {
|
||||
public void Write_root_bgn(Xow_ns_mgr ns_mgr, Xow_domain_itm domain, String wiki_abrv, String main_page, String ns_case, String app_version) {
|
||||
wtr.Nde_lhs_bgn_grp("mediawiki");
|
||||
wtr.Atr_kv_str_a7("xmlns" , "http://www.mediawiki.org/xml/export-0.10/");
|
||||
wtr.Atr_kv_str_a7("xmlns:xsi" , "http://www.w3.org/2001/XMLSchema-instance");
|
||||
@@ -35,9 +35,9 @@ public class Xob_xml_dumper {
|
||||
public void Write_root_end() {
|
||||
wtr.Nde_rhs();
|
||||
}
|
||||
private void Write_siteinfo(Xow_domain domain, String wiki_abrv, String main_page, String ns_case, String app_version) {
|
||||
private void Write_siteinfo(Xow_domain_itm domain, String wiki_abrv, String main_page, String ns_case, String app_version) {
|
||||
wtr.Nde_lhs("siteinfo");
|
||||
wtr.Nde_txt_bry("sitename" , Xow_domain_type_.Get_type_as_bry(domain.Domain_tid()));
|
||||
wtr.Nde_txt_bry("sitename" , Xow_domain_type_.Get_type_as_bry(domain.Domain_type_id()));
|
||||
wtr.Nde_txt_str("dbname" , wiki_abrv);
|
||||
wtr.Nde_txt_str("base" , main_page);
|
||||
wtr.Nde_txt_str("generator" , app_version);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.cfgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_cfg_grp {
|
||||
public Xoa_cfg_grp(Xoa_cfg_mgr mgr, Xoa_cfg_grp_tid tid, byte[] key_bry) {
|
||||
this.mgr = mgr; this.tid = tid; this.key_bry = key_bry; this.key_str = String_.new_u8(key_bry);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.cfgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_cfg_grp_tid {
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Key() {return key;} private byte[] key;
|
||||
@@ -31,12 +31,12 @@ public class Xoa_cfg_grp_tid {
|
||||
if (Bry_.Eq(key, Key_all_bry)) rv.tid = Tid_all;
|
||||
else if (Bry_.Eq(key, Key_app_bry)) rv.tid = Tid_app;
|
||||
else {
|
||||
Xow_domain wiki_type = Xow_domain_.parse(key);
|
||||
if (wiki_type.Domain_tid() == Xow_domain_type_.Tid_other)
|
||||
Xow_domain_itm wiki_type = Xow_domain_itm_.parse(key);
|
||||
if (wiki_type.Domain_type_id() == Xow_domain_type_.Int__other)
|
||||
rv.tid = Tid_wiki;
|
||||
else {
|
||||
rv.tid = Tid_type;
|
||||
rv.wiki_tid = wiki_type.Domain_tid();
|
||||
rv.wiki_tid = wiki_type.Domain_type_id();
|
||||
}
|
||||
}
|
||||
rv.key = key;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.cfgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_cfg_mgr implements GfoInvkAble {
|
||||
public Xoa_cfg_mgr(Xoae_app app) {this.app = app;} private Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.dbs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
public Xodb_save_mgr_txt(Xowe_wiki wiki, Xodb_load_mgr_txt load_mgr) {
|
||||
this.wiki = wiki;
|
||||
@@ -59,7 +59,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
}
|
||||
public void Data_update(Xoae_page page, byte[] text) {Data_update_under(page, text, null);}
|
||||
public void Data_rename(Xoae_page page, int trg_ns, byte[] trg_ttl) {
|
||||
if (wiki.Domain_tid() != Xow_domain_type_.Tid_home) {
|
||||
if (wiki.Domain_tid() != Xow_domain_type_.Int__home) {
|
||||
wiki.Appe().Usr_dlg().Warn_many("", "", "Only pages in the home wiki can be renamed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.files.repos.*;
|
||||
public class Xof_fsdb_itm_fxt {
|
||||
private byte[] wiki_abrv;
|
||||
@@ -53,7 +53,7 @@ public class Xof_fsdb_itm_fxt {
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Orig__commons__lnki() {
|
||||
this.orig_repo_name = Xow_domain_.Domain_bry_commons;
|
||||
this.orig_repo_name = Xow_domain_itm_.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);
|
||||
@@ -62,7 +62,7 @@ public class Xof_fsdb_itm_fxt {
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Orig__enwiki__lnki() {
|
||||
this.orig_repo_name = Xow_domain_.Domain_bry_enwiki;
|
||||
this.orig_repo_name = Xow_domain_itm_.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);
|
||||
|
||||
@@ -29,9 +29,12 @@ public class Xof_img_size {
|
||||
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) {
|
||||
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
|
||||
if ( Xof_ext_.Id_supports_time(orig_ext) // ext is video
|
||||
&& lnki_w == Xof_img_size.Null // no size specified
|
||||
&& !Xop_lnki_type.Id_is_thumbable(lnki_type) // not thumb which is implicitly 220; PAGE:en.w:Edward_Snowden; DATE:2015-08-17
|
||||
)
|
||||
lnki_w = orig_w; // use original size; EX:[[File:A.ogv]] -> [[File:A.ogv|550px]] where 550px is orig_w; DATE:2015-08-07
|
||||
if (Enm_.Has_int(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;
|
||||
|
||||
@@ -81,6 +81,9 @@ public class Xof_img_size_tst {
|
||||
@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);
|
||||
}
|
||||
@Test public void Video__use_thumb(){ // PURPOSE: video should use thumb_w, not orig_w; PAGE:en.w:Edward_Snowden DATE:2015-08-17
|
||||
fxt.Lnki_type_(Xop_lnki_type.Id_thumb).Lnki_ext_(Xof_ext_.Id_ogv).Lnki_(-1, -1).Orig_(440, 220).Test_html(220, 110, Bool_.N);
|
||||
}
|
||||
}
|
||||
class Xof_img_size_fxt {
|
||||
private Xof_img_size img_size = new Xof_img_size();
|
||||
|
||||
@@ -20,11 +20,11 @@ public class Xof_patch_upright_tid_ {
|
||||
public static final int Tid_unpatched = 0, Tid_use_thumb_w = 1, Tid_fix_default = 2;
|
||||
public static final int Tid_all = Tid_use_thumb_w | Tid_fix_default;
|
||||
public static int Merge(boolean use_thumb_w, boolean fix_default) {
|
||||
if (use_thumb_w && fix_default) return Enm_.AddInt(Tid_use_thumb_w, Tid_fix_default);
|
||||
if (use_thumb_w && fix_default) return Enm_.Add_int(Tid_use_thumb_w, Tid_fix_default);
|
||||
else if (use_thumb_w) return Tid_use_thumb_w;
|
||||
else if (fix_default) return Tid_fix_default;
|
||||
else return Tid_unpatched;
|
||||
}
|
||||
public static boolean Split_use_thumb_w(int tid) {return Enm_.HasInt(tid, Tid_use_thumb_w);}
|
||||
public static boolean Split_fix_default(int tid) {return Enm_.HasInt(tid, Tid_fix_default);}
|
||||
public static boolean Split_use_thumb_w(int tid) {return Enm_.Has_int(tid, Tid_use_thumb_w);}
|
||||
public static boolean Split_fix_default(int tid) {return Enm_.Has_int(tid, Tid_fix_default);}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
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.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
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;
|
||||
@@ -38,11 +38,11 @@ public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
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);
|
||||
src = Make_src(Xow_domain_itm_.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
|
||||
fsdb.Change_repo(Xof_repo_itm_.Repo_remote, Xow_domain_itm_.Bry__commons); // set commons.wikimedia.org; DATE:2015-08-05
|
||||
else
|
||||
Handle_error();
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class Xou_cache_mgr {
|
||||
Xoa_app_.Usr_dlg().Note_many("", "", "cache compress done");
|
||||
}
|
||||
private Io_url Calc_url(Xou_cache_itm cache) {
|
||||
byte[] wiki_domain = Xow_domain_abrv_xo_.To_itm(cache.Lnki_wiki_abrv()).Domain_bry();
|
||||
byte[] wiki_domain = Xow_abrv_xo_.To_itm(cache.Lnki_wiki_abrv()).Domain_bry();
|
||||
Xow_wiki wiki = wiki_mgr.Get_by_key_or_make_init_y(wiki_domain); if (wiki == null) return Io_url_.Empty; // wiki is not available; should only happen in read-only mode; DATE:2015-05-23
|
||||
Xof_repo_itm trg_repo = wiki.File__repo_mgr().Get_trg_by_id_or_null(cache.Orig_repo_id(), cache.Lnki_ttl(), Bry_.Empty);
|
||||
if (trg_repo == null) return Io_url_.Empty;
|
||||
|
||||
@@ -25,11 +25,15 @@ public class Fs_root_fsdb_mgr implements Xof_fsdb_mgr, GfoInvkAble { // read ima
|
||||
public void Init_by_wiki(Xow_wiki wiki) {this.wiki = (Xowe_wiki)wiki;}
|
||||
public void Fsdb_search_by_list(List_adp itms, Xow_wiki wiki, Xoa_page page, Xog_js_wkr js_wkr) {
|
||||
int itms_len = itms.Count();
|
||||
// Xou_cache_mgr cache_mgr = wiki.App().User().User_db_mgr().Cache_mgr(); // repo_id is 127; DATE:2015-08-23
|
||||
for (int i = 0; i < itms_len; i++) {
|
||||
Xof_fsdb_itm itm = (Xof_fsdb_itm)itms.Get_at(i);
|
||||
if (fsdb_wkr.Find_file(itm))
|
||||
if (fsdb_wkr.Find_file(itm)) {
|
||||
Js_img_mgr.Update_img(page, js_wkr, itm);
|
||||
// cache_mgr.Update(itm);
|
||||
}
|
||||
}
|
||||
// cache_mgr.Db_save();
|
||||
}
|
||||
private Io_url Xto_url(byte[] v) {
|
||||
if (Op_sys.Cur().Tid_is_wnt())
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.fsdb.tsts; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.dbs.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.cnvs.*; import gplx.xowa.files.exts.*; import gplx.xowa.files.gui.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.fsdb.data.*;
|
||||
class Xof_file_fxt {
|
||||
private Xoae_app app; private Xof_fsdb_mgr__sql fsdb_mgr; private Xowe_wiki wiki; private Xof_orig_mgr orig_mgr;
|
||||
@@ -84,10 +84,10 @@ class Xof_repo_fxt {
|
||||
byte[] src_en_wiki = Bry_.new_a7("src_en_wiki");
|
||||
byte[] trg_commons = Bry_.new_a7("trg_commons");
|
||||
byte[] trg_en_wiki = Bry_.new_a7("trg_en_wiki");
|
||||
Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, false);
|
||||
Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/" , Xow_domain_.Domain_str_enwiki, false);
|
||||
Ini_repo_add(file_mgr, trg_commons, "mem/root/common/", Xow_domain_.Domain_str_commons, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, trg_en_wiki, "mem/root/enwiki/", Xow_domain_.Domain_str_enwiki, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_itm_.Str__commons, false);
|
||||
Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/" , Xow_domain_itm_.Str__enwiki, false);
|
||||
Ini_repo_add(file_mgr, trg_commons, "mem/root/common/", Xow_domain_itm_.Str__commons, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, trg_en_wiki, "mem/root/enwiki/", Xow_domain_itm_.Str__enwiki, true).Primary_(true);
|
||||
Xowe_repo_mgr wiki_repo_mgr = wiki.File_mgr().Repo_mgr();
|
||||
Xof_repo_pair pair = null;
|
||||
pair = wiki_repo_mgr.Add_repo(src_commons, trg_commons);
|
||||
@@ -136,14 +136,14 @@ class Xof_fsdb_arg {
|
||||
public byte[] Bin() {return bin;} private final byte[] bin;
|
||||
public DateAdp Modified() {return modified;} private final DateAdp modified = Fsd_thm_tbl.Modified_null;
|
||||
public String Hash() {return hash;} private final String hash = Fsd_thm_tbl.Hash_null;
|
||||
public static Xof_fsdb_arg new_comm_file(String ttl) {return new_(Xow_domain_.Domain_bry_commons, Bool_.N, ttl, Xof_img_size.Null, Xof_img_size.Null, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_thumb(String ttl) {return new_(Xow_domain_.Domain_bry_commons, Bool_.Y, ttl, W_default, H_default, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_thumb(String ttl, int w, int h) {return new_(Xow_domain_.Domain_bry_commons, Bool_.Y, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_thumb(String ttl, int w, int h, int s) {return new_(Xow_domain_.Domain_bry_commons, Bool_.Y, ttl, w, h, s);}
|
||||
public static Xof_fsdb_arg new_comm_orig(String ttl, int w, int h) {return new_(Xow_domain_.Domain_bry_commons, Bool_.N, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm(boolean thumb, String ttl, int w, int h) {return new_(Xow_domain_.Domain_bry_commons, thumb, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_wiki_thumb(String ttl, int w, int h) {return new_(Xow_domain_.Domain_bry_enwiki, Bool_.Y, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_wiki_orig(String ttl, int w, int h) {return new_(Xow_domain_.Domain_bry_enwiki, Bool_.N, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_file(String ttl) {return new_(Xow_domain_itm_.Bry__commons, Bool_.N, ttl, Xof_img_size.Null, Xof_img_size.Null, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_thumb(String ttl) {return new_(Xow_domain_itm_.Bry__commons, Bool_.Y, ttl, W_default, H_default, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_thumb(String ttl, int w, int h) {return new_(Xow_domain_itm_.Bry__commons, Bool_.Y, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm_thumb(String ttl, int w, int h, int s) {return new_(Xow_domain_itm_.Bry__commons, Bool_.Y, ttl, w, h, s);}
|
||||
public static Xof_fsdb_arg new_comm_orig(String ttl, int w, int h) {return new_(Xow_domain_itm_.Bry__commons, Bool_.N, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_comm(boolean thumb, String ttl, int w, int h) {return new_(Xow_domain_itm_.Bry__commons, thumb, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_wiki_thumb(String ttl, int w, int h) {return new_(Xow_domain_itm_.Bry__enwiki, Bool_.Y, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_wiki_orig(String ttl, int w, int h) {return new_(Xow_domain_itm_.Bry__enwiki, Bool_.N, ttl, w, h, Xof_lnki_time.Null_as_int);}
|
||||
public static Xof_fsdb_arg new_(byte[] wiki, boolean is_thumb, String ttl_str, int w, int h, int time) {
|
||||
byte[] ttl = Bry_.new_u8(ttl_str);
|
||||
int ext = Xof_ext_.new_by_ttl_(ttl).Id();
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Js_img_mgr {
|
||||
html_itm.Html_redlink(html_id);
|
||||
}
|
||||
private static void Update_img(Xoa_page page, Xog_js_wkr js_wkr, Js_img_wkr img_wkr, int uid, byte lnki_type, byte elem_tid, int html_w, int html_h, Io_url html_view_url, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl, int gallery_mgr_h) {
|
||||
if (!page.Wiki().App().App_type().Uid_is_gui()) return; // do not update html widget unless app is gui; null ref on http server; DATE:2014-09-17
|
||||
if (!page.Wiki().App().App_type().Uid_supports_js()) return; // do not update html widget unless app is gui; null ref on http server; DATE:2014-09-17
|
||||
switch (elem_tid) {
|
||||
case Xof_html_elem.Tid_gallery_v2:
|
||||
img_wkr.Html_update(page, js_wkr, uid, html_w, html_h, html_view_url, orig_w, orig_h, html_orig_url, lnki_ttl);
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.repos; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xof_repo_itm implements GfoInvkAble {
|
||||
private final Xoa_fsys_mgr app_fsys; private final Xof_rule_mgr ext_rule_mgr; private final Bry_bfr tmp_bfr = Bry_bfr.reset_(300);
|
||||
public Xof_repo_itm(byte[] key, Xoa_fsys_mgr app_fsys, Xof_rule_mgr ext_rule_mgr, byte[] wiki_domain) {
|
||||
@@ -41,13 +41,13 @@ public class Xof_repo_itm implements GfoInvkAble {
|
||||
public boolean Primary() {return primary;} public Xof_repo_itm Primary_(boolean v) {primary = v; return this;} private boolean primary;
|
||||
public void Wiki_domain_(byte[] v) {
|
||||
this.wiki_domain = v;
|
||||
Xow_domain domain_itm = Xow_domain_.parse(v);
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(v);
|
||||
if (domain_itm == null) {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "repo:invalid domain; raw=~{0}", v);
|
||||
this.wiki_abrv_xo = Bry_.Empty;
|
||||
}
|
||||
else
|
||||
this.wiki_abrv_xo = Xow_domain_abrv_xo_.To_bry(v, domain_itm.Lang_itm(), domain_itm.Domain_type());
|
||||
this.wiki_abrv_xo = Xow_abrv_xo_.To_bry(v, domain_itm.Lang_actl_key(), domain_itm.Domain_type());
|
||||
}
|
||||
public Xof_repo_itm Root_str_(String root_str) {
|
||||
this.wmf_fsys = String_.Has_at_bgn(root_str, "http") || String_.Has_at_bgn(root_str, "ftp");
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.repos; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.files.exts.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.files.exts.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_repo_mgr_ {
|
||||
public static void Assert_repos(Xoae_app app, Xowe_wiki wiki) {
|
||||
Xoa_repo_mgr repo_mgr = app.File_mgr().Repo_mgr();
|
||||
@@ -32,7 +33,7 @@ public class Xow_repo_mgr_ {
|
||||
if (pair_mgr.Repos_len() == 0) { // no pairs defined; add at least 1
|
||||
Xof_repo_itm repo_src = repo_mgr.Get_by(File_repo_xowa_null);
|
||||
if (repo_src == null) {
|
||||
repo_itm = new Xof_repo_itm(File_repo_xowa_null, app_fsys_mgr, ext_rule_mgr, Xow_domain_type_.Key_bry_home);
|
||||
repo_itm = new Xof_repo_itm(File_repo_xowa_null, app_fsys_mgr, ext_rule_mgr, Xow_domain_type_.Bry__home);
|
||||
repo_mgr.Add(repo_itm);
|
||||
}
|
||||
pair_mgr.Add_repo(File_repo_xowa_null, domain_bry);
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.repos; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.files.xfers.*;
|
||||
import gplx.xowa.files.xfers.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xowe_repo_mgr implements Xow_repo_mgr, GfoInvkAble {
|
||||
private Xowe_wiki wiki; private final List_adp repos = List_adp_.new_();
|
||||
public Xowe_repo_mgr(Xowe_wiki wiki) {
|
||||
@@ -192,7 +193,7 @@ public class Xowe_repo_mgr implements Xow_repo_mgr, GfoInvkAble {
|
||||
Xoa_repo_mgr repo_mgr = wiki.Appe().File_mgr().Repo_mgr();
|
||||
Xof_repo_itm src_repo = repo_mgr.Get_by(src_repo_key), trg_repo = repo_mgr.Get_by(trg_repo_key);
|
||||
byte[] src_wiki_key = src_repo.Wiki_domain(), trg_wiki_key = trg_repo.Wiki_domain();
|
||||
if (!Bry_.Eq(src_wiki_key, trg_wiki_key) && !Bry_.Eq(src_wiki_key, Xow_domain_type_.Key_bry_home)) throw Err_.new_wo_type("wiki keys do not match", "src", String_.new_u8(src_wiki_key), "trg", String_.new_u8(trg_wiki_key));
|
||||
if (!Bry_.Eq(src_wiki_key, trg_wiki_key) && !Bry_.Eq(src_wiki_key, Xow_domain_type_.Bry__home)) throw Err_.new_wo_type("wiki keys do not match", "src", String_.new_u8(src_wiki_key), "trg", String_.new_u8(trg_wiki_key));
|
||||
Xof_repo_pair pair = new Xof_repo_pair((byte)repos.Count(), src_wiki_key, src_repo, trg_repo);
|
||||
repos.Add(pair);
|
||||
return pair;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Xof_xfer_queue {
|
||||
}
|
||||
private void Exec_v2(Xowe_wiki wiki, Xoae_page page) {
|
||||
wiki.File_mgr().Init_file_mgr_by_load(wiki);
|
||||
Xog_js_wkr js_wkr = wiki.App().App_type().Uid_is_gui() ? page.Tab_data().Tab().Html_itm() : Xog_js_wkr_.Noop;
|
||||
Xog_js_wkr js_wkr = wiki.App().App_type().Uid_supports_js() ? page.Tab_data().Tab().Html_itm() : Xog_js_wkr_.Noop;
|
||||
wiki.File_mgr().Fsdb_mgr().Fsdb_search_by_list(Xfer_itms_to_fsdb_itms(wiki, page, xfer_list, wiki.File_mgr().Patch_upright()), wiki, page, js_wkr);
|
||||
}
|
||||
private List_adp Xfer_itms_to_fsdb_itms(Xowe_wiki cur_wiki, Xoae_page page, List_adp xfer_list, int upright_patch) {
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.xfers; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.*; import gplx.xowa.files.cnvs.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.files.cnvs.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wmfs.apis.*; import gplx.xowa.files.exts.*; import gplx.xowa.files.imgs.*;
|
||||
public class Xof_xfer_queue_base_fxt {
|
||||
public Xoapi_orig_mok Api_size() {return api_size;} private Xoapi_orig_mok api_size = Xoapi_orig_mok._;
|
||||
@@ -26,8 +27,8 @@ public class Xof_xfer_queue_base_fxt {
|
||||
Io_mgr.I.InitEngine_mem();
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
en_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_enwiki);
|
||||
commons = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_commons);
|
||||
en_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_itm_.Str__enwiki);
|
||||
commons = Xoa_app_fxt.wiki_(app, Xow_domain_itm_.Str__commons);
|
||||
app.Wiki_mgr().Add(commons);
|
||||
app.Wiki_mgr().Add(en_wiki);
|
||||
|
||||
@@ -40,10 +41,10 @@ public class Xof_xfer_queue_base_fxt {
|
||||
byte[] src_en_wiki = Bry_.new_a7("src_en_wiki");
|
||||
byte[] trg_commons = Bry_.new_a7("trg_commons");
|
||||
byte[] trg_en_wiki = Bry_.new_a7("trg_en_wiki");
|
||||
src_commons_repo = Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, false);
|
||||
src_en_wiki_repo = Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/" , Xow_domain_.Domain_str_enwiki, false);
|
||||
Ini_repo_add(file_mgr, trg_commons, "mem/trg/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, trg_en_wiki, "mem/trg/en.wikipedia.org/" , Xow_domain_.Domain_str_enwiki, true).Primary_(true);
|
||||
src_commons_repo = Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_itm_.Str__commons, false);
|
||||
src_en_wiki_repo = Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/" , Xow_domain_itm_.Str__enwiki, false);
|
||||
Ini_repo_add(file_mgr, trg_commons, "mem/trg/commons.wikimedia.org/", Xow_domain_itm_.Str__commons, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, trg_en_wiki, "mem/trg/en.wikipedia.org/" , Xow_domain_itm_.Str__enwiki, true).Primary_(true);
|
||||
Xowe_repo_mgr wiki_repo_mgr = en_wiki.File_mgr().Repo_mgr();
|
||||
Xof_repo_pair pair = null;
|
||||
pair = wiki_repo_mgr.Add_repo(src_commons, trg_commons);
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.xfers; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.files.*;
|
||||
public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
private final Xof_xfer_queue queue = new Xof_xfer_queue();
|
||||
@Override public void Clear(boolean src_repo_is_wmf) {
|
||||
@@ -41,7 +41,7 @@ public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
public Xof_xfer_queue_html_fxt Html_orig_src_(String v) {html_orig_src = v; return this;} private String html_orig_src;
|
||||
public Xof_xfer_queue_html_fxt ini_page_api(String wiki_str, String ttl_str, String redirect_str, int orig_w, int orig_h) {return ini_page_api(wiki_str, ttl_str, redirect_str, orig_w, orig_h, true);}
|
||||
public Xof_xfer_queue_html_fxt ini_page_api(String wiki_str, String ttl_str, String redirect_str, int orig_w, int orig_h, boolean pass) {
|
||||
String wiki_key = String_.Eq(wiki_str, "commons") ? Xow_domain_.Domain_str_commons : Xow_domain_.Domain_str_enwiki;
|
||||
String wiki_key = String_.Eq(wiki_str, "commons") ? Xow_domain_itm_.Str__commons : Xow_domain_itm_.Str__enwiki;
|
||||
this.Api_size().Ini(wiki_key, ttl_str, redirect_str, orig_w, orig_h, pass);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Xog_resizer {
|
||||
private static RectAdp Prv_elem_rect_initial = RectAdp_.Zero, Prv_elem_rect_win_7 = RectAdp_.new_(0, -1, 0, 0);
|
||||
private static void Exec_win_resize_elem(Xog_layout_box box, GfuiElem cur_elem, Rect_ref cur_elem_rect, GfuiElem prv_elem, byte layout) {Exec_win_resize_elem(box, cur_elem, cur_elem_rect, prv_elem.Rect(), layout);}
|
||||
private static void Exec_win_resize_elem(Xog_layout_box box, GfuiElem cur_elem, Rect_ref cur_elem_rect, RectAdp prv_elem_rect, byte layout) {
|
||||
if (ClassAdp_.Eq_typeSafe(cur_elem, GfuiTextBox.class)) {
|
||||
if (Type_adp_.Eq_typeSafe(cur_elem, GfuiTextBox.class)) {
|
||||
try {
|
||||
GfuiTextBox cur_box = (GfuiTextBox)cur_elem;
|
||||
cur_box.Margins_set(0, txt_margin_v, 0, txt_margin_v);
|
||||
@@ -88,7 +88,7 @@ public class Xog_resizer {
|
||||
box.Adj_pos(cur_elem_rect);
|
||||
}
|
||||
cur_elem.Rect_set(cur_elem_rect.XtoRectAdp());
|
||||
if (ClassAdp_.Eq_typeSafe(cur_elem, GfuiBtn.class)) {
|
||||
if (Type_adp_.Eq_typeSafe(cur_elem, GfuiBtn.class)) {
|
||||
GfuiBtn cur_btn = (GfuiBtn)cur_elem;
|
||||
cur_btn.Btn_img_(cur_btn.Btn_img());
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
html_box.Html_js_enabled_(gui_mgr.Html_mgr().Javascript_enabled());
|
||||
html_box.Html_invk_src_(win);
|
||||
html_itm.Html_box_(html_box);
|
||||
if (app.App_type().Uid_is_gui()) { // NOTE: only run for gui; will cause firefox addon to fail; DATE:2014-05-03
|
||||
if (app.App_type().Uid_is_gui()) { // NOTE: only run for gui; will cause firefox_addon to fail; DATE:2014-05-03
|
||||
html_box.Html_doc_html_load_by_mem(""); // NOTE: must set source, else control will be empty, and key events will not be raised; DATE:2014-04-30
|
||||
IptBnd_.ipt_to_(IptCfg_.Null, html_box, this, "popup", IptEventType_.MouseDown, IptMouseBtn_.Right);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, html_box, win, Xog_win_itm.Invk_exit, IptKey_.add_(IptKey_.Alt, IptKey_.F4)); // WORKAROUND:SWT: xulrunner_v24 no longer sends Alt+F4 to SwtShell; must manually subscribe it to quit; DATE:2015-07-31
|
||||
|
||||
@@ -249,36 +249,24 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
public byte[] App__retrieve_by_url(String url_str, String output_str) {
|
||||
synchronized (App__retrieve__lock) {
|
||||
boolean output_html = String_.Eq(output_str, "html");
|
||||
byte[] url_bry = Bry_.new_u8(url_str);
|
||||
Xowe_wiki home_wiki = app.Usere().Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(home_wiki, Xoa_page_.Main_page_bry); // NOTE: must be Main_Page, not "" else Firefox Addon will fail; DATE:2014-03-13
|
||||
Xoae_page new_page = Xoae_page.new_(home_wiki, ttl);
|
||||
Xoa_url url = home_wiki.Utl__url_parser().Parse_by_urlbar(url_str);
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_key_or_make_init_y(url.Wiki_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url.Page_bry());
|
||||
Xoae_page new_page = wiki.Load_page_by_ttl(url, ttl);
|
||||
if (new_page.Missing()) {return Bry_.Empty;}
|
||||
gplx.xowa.servers.Gxw_html_server.Assert_tab(app, new_page); // HACK: assert at least 1 tab for Firefox addon; DATE:2015-01-23
|
||||
this.Active_page_(new_page);
|
||||
Xoa_url url = Xoa_url.blank();
|
||||
url = home_wiki.Utl__url_parser().Parse(url_bry);
|
||||
new_page.Url_(url);
|
||||
return App__retrieve_by_href(url, output_html);
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab();
|
||||
tab.Page_(new_page);
|
||||
tab.History_mgr().Add(new_page);
|
||||
byte[] rv = output_html
|
||||
? wiki.Html_mgr().Page_wtr_mgr().Gen(new_page, tab.View_mode())
|
||||
: new_page.Data_raw();
|
||||
if (app.Shell().Fetch_page_exec_async())
|
||||
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
||||
return rv;
|
||||
}
|
||||
} private Object App__retrieve__lock = new Object();
|
||||
public byte[] App__retrieve_by_href(String href, boolean output_html) {return App__retrieve_by_href(Xog_url_wkr.Exec_url(this, href), output_html);} // NOTE: used by drd
|
||||
private byte[] App__retrieve_by_href(Xoa_url url, boolean output_html) {
|
||||
if (url == null) return Bry_.new_a7("missing");
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_key_or_make_init_y(url.Wiki_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url.Page_bry());
|
||||
Xoae_page new_page = wiki.Load_page_by_ttl(url, ttl);
|
||||
if (new_page.Missing()) {return Bry_.Empty;}
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab();
|
||||
tab.Page_(new_page);
|
||||
tab.History_mgr().Add(new_page);
|
||||
byte[] rv = output_html
|
||||
? wiki.Html_mgr().Page_wtr_mgr().Gen(new_page, tab.View_mode())
|
||||
: new_page.Data_raw()
|
||||
;
|
||||
if (app.Shell().Fetch_page_exec_async())
|
||||
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
||||
return rv;
|
||||
}
|
||||
public void Init_by_kit(Gfui_kit kit) {
|
||||
this.kit = kit;
|
||||
win_box = kit.New_win_app("win");
|
||||
|
||||
@@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.btries.*; import gplx.html.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*;
|
||||
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.html.hzips.*;
|
||||
public class Xoh_html_wtr {
|
||||
@@ -428,7 +429,7 @@ public class Xoh_html_wtr {
|
||||
default: // unknown tag
|
||||
if (tag.Restricted()) { // a; img; script; etc..
|
||||
if ( !page.Html_data().Html_restricted() // page is not marked restricted (only [[Special:]])
|
||||
|| page.Wiki().Domain_tid() == Xow_domain_type_.Tid_home) { // page is in home wiki
|
||||
|| page.Wiki().Domain_tid() == Xow_domain_type_.Int__home) { // page is in home wiki
|
||||
bfr.Add_mid(src, xnde.Src_bgn(), xnde.Src_end());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoh_imgs_mgr implements GfoInvkAble {
|
||||
public Xoh_imgs_mgr(Xow_html_mgr html_mgr) {wiki_is_default = html_mgr.Wiki().Domain_tid() == Xow_domain_type_.Tid_home;} private boolean wiki_is_default;
|
||||
public Xoh_imgs_mgr(Xow_html_mgr html_mgr) {wiki_is_default = html_mgr.Wiki().Domain_tid() == Xow_domain_type_.Int__home;} private boolean wiki_is_default;
|
||||
public Bool_obj_ref Alt_in_caption() {return alt_in_caption;} Bool_obj_ref alt_in_caption = Bool_obj_ref.y_();
|
||||
public Bool_obj_ref Alt_defaults_to_caption() {return alt_defaults_to_caption;} Bool_obj_ref alt_defaults_to_caption = Bool_obj_ref.y_();
|
||||
public void Copy_cfg(Xoh_imgs_mgr copy) {this.alt_in_caption = copy.alt_in_caption;}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.html.*; import gplx.xowa.html.portal.*; import gplx.xowa.pages.skins.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.gui.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.gui.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.langs.vnts.*;
|
||||
public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
private Xop_ctx ctx; private Xoae_page page; private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private byte[] root_dir_bry;
|
||||
@@ -108,7 +108,7 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
case Xow_page_tid.Tid_json: app.Wiki_mgr().Wdata_mgr().Write_json_as_html(bfr, page_ttl.Page_db(), data_raw); break;
|
||||
}
|
||||
}
|
||||
if ( wiki.Domain_tid() != Xow_domain_type_.Tid_home // allow home wiki to use javascript
|
||||
if ( wiki.Domain_tid() != Xow_domain_type_.Int__home // allow home wiki to use javascript
|
||||
&& !page_tid_uses_pre) { // if .js, .css or .lua, skip test; may have js fragments, but entire text is escaped and put in pre; don't show spurious warning; DATE:2013-11-21
|
||||
app.Html_mgr().Js_cleaner().Clean_bfr(wiki, page_ttl, bfr, bfr_page_bgn);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ public class Bridge_msg_bldr {
|
||||
public Bridge_msg_bldr Notify_hint_(String v) {synchronized(wtr){this.notify_hint = v;} return this;} private String notify_hint;
|
||||
public Bridge_msg_bldr Notify_pass_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "success";} return this;}
|
||||
public Bridge_msg_bldr Notify_fail_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "error"; this.rslt_pass = false;} return this;}
|
||||
public Bridge_msg_bldr Data(String key, boolean val) {return Data_obj(key, val, ClassAdp_.Tid_bool);}
|
||||
public Bridge_msg_bldr Data(String key, int val) {return Data_obj(key, val, ClassAdp_.Tid_int);}
|
||||
public Bridge_msg_bldr Data(String key, String val) {return Data_obj(key, val, ClassAdp_.Tid_str);}
|
||||
public Bridge_msg_bldr Data(String key, byte[] val) {return Data_obj(key, val, ClassAdp_.Tid_bry);}
|
||||
public Bridge_msg_bldr Data(String key, boolean val) {return Data_obj(key, val, Type_adp_.Tid__bool);}
|
||||
public Bridge_msg_bldr Data(String key, int val) {return Data_obj(key, val, Type_adp_.Tid__int);}
|
||||
public Bridge_msg_bldr Data(String key, String val) {return Data_obj(key, val, Type_adp_.Tid__str);}
|
||||
public Bridge_msg_bldr Data(String key, byte[] val) {return Data_obj(key, val, Type_adp_.Tid__bry);}
|
||||
private Bridge_msg_bldr Data_obj(String key, Object val, int val_tid) {
|
||||
synchronized (wtr) {data_root.Add_data(key, val, val_tid);}
|
||||
return this;
|
||||
@@ -83,9 +83,9 @@ public class Bridge_msg_bldr {
|
||||
Gfo_tree_data sub_kv = (Gfo_tree_data)itm;
|
||||
String key = sub_kv.Key(); Object val = sub_kv.Val();
|
||||
switch (sub_kv.Val_tid()) {
|
||||
case ClassAdp_.Tid_bool: wtr.Kv_bool(key, Bool_.cast_(val)); break;
|
||||
case ClassAdp_.Tid_int: wtr.Kv_int(key, Int_.cast_(val)); break;
|
||||
case ClassAdp_.Tid_bry: wtr.Kv_bry(key, (byte[])val); break;
|
||||
case Type_adp_.Tid__bool: wtr.Kv_bool(key, Bool_.cast_(val)); break;
|
||||
case Type_adp_.Tid__int: wtr.Kv_int(key, Int_.cast_(val)); break;
|
||||
case Type_adp_.Tid__bry: wtr.Kv_bry(key, (byte[])val); break;
|
||||
default: wtr.Kv_str(key, Object_.Xto_str_strict_or_null_mark(val)); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.html.hdumps.abrvs; import gplx.*; import gplx.xowa.*; import g
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.btries.*;
|
||||
import gplx.html.*; import gplx.xowa.html.*; import gplx.xowa.html.hdumps.core.*; import gplx.xowa.html.lnkis.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa2.gui.*;
|
||||
public class Xohd_abrv_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255); private Bry_rdr bry_rdr = new Bry_rdr(); private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.I;
|
||||
@@ -37,7 +37,7 @@ public class Xohd_abrv_mgr {
|
||||
this.wiki_domain = wiki_domain;
|
||||
}
|
||||
private void Init() {
|
||||
file_dir_comm = tmp_bfr.Add(file_dir).Add(Xow_domain_.Domain_bry_commons).Add_byte_slash().Xto_bry_and_clear();
|
||||
file_dir_comm = tmp_bfr.Add(file_dir).Add(Xow_domain_itm_.Bry__commons).Add_byte_slash().Xto_bry_and_clear();
|
||||
file_dir_wiki = tmp_bfr.Add(file_dir).Add(wiki_domain).Add_byte_slash().Xto_bry_and_clear();
|
||||
}
|
||||
public byte[] Parse(Bry_bfr rv, Xog_page hpg) {
|
||||
|
||||
@@ -155,13 +155,13 @@ public class Xoh_head_mgr implements Bry_fmtr_arg {
|
||||
boolean enabled = itm.Enabled();
|
||||
if (enabled) {
|
||||
int flag = itms[i].Flags();
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__css_include)) list__css_include.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__css_text)) list__css_text.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_include)) list__js_include.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_head_global)) list__js_head_global.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_head_script)) list__js_head_script.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_tail_script)) list__js_tail_script.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_window_onload)) list__js_window_onload.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__css_include)) list__css_include.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__css_text)) list__css_text.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_include)) list__js_include.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_global)) list__js_head_global.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_script)) list__js_head_script.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_tail_script)) list__js_tail_script.Add(itm);
|
||||
if (Enm_.Has_int(flag, Xoh_head_itm__base.Flag__js_window_onload)) list__js_window_onload.Add(itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,11 +211,11 @@ public class Xoh_file_wtr__basic {
|
||||
return scratch_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
private static byte[] Arg_anchor_title(Bry_bfr tmp_bfr, byte[] src, Xop_lnki_tkn lnki, byte[] lnki_ttl, Xoh_lnki_title_fmtr anchor_title_wkr) {
|
||||
if ( Enm_.HasInt(lnki.Lnki_type(), Xop_lnki_type.Id_thumb)
|
||||
|| Enm_.HasInt(lnki.Lnki_type(), Xop_lnki_type.Id_frame) // If the image is a thumb, do not add a title / alt, even if a caption is available
|
||||
if ( Enm_.Has_int(lnki.Lnki_type(), Xop_lnki_type.Id_thumb)
|
||||
|| Enm_.Has_int(lnki.Lnki_type(), Xop_lnki_type.Id_frame) // If the image is a thumb, do not add a title / alt, even if a caption is available
|
||||
)
|
||||
return Bry_.Empty;
|
||||
else if ( Enm_.HasInt(lnki.Lnki_type(), Xop_lnki_type.Id_frameless)) { // If the image is frameless, add the caption as a title / alt. If no caption is available, do not add a title / alt
|
||||
else if ( Enm_.Has_int(lnki.Lnki_type(), Xop_lnki_type.Id_frameless)) { // If the image is frameless, add the caption as a title / alt. If no caption is available, do not add a title / alt
|
||||
}
|
||||
Xop_tkn_itm anchor_title_tkn = lnki.Caption_tkn();
|
||||
if (anchor_title_tkn == Xop_tkn_null.Null_tkn) return Bry_.Empty; // no caption; return empty; (do not use lnki); DATE:2013-12-31
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xoh_lnki_wtr {
|
||||
Xow_xwiki_itm xwiki_lang = lnki_ttl.Wik_itm();
|
||||
if ( xwiki_lang != null // lnki is xwiki; EX: [[commons:]] [[en:]] [[wikt:]]
|
||||
&& xwiki_lang.Domain_tid() == wiki.Xwiki_domain_tid() // xwiki is same type as cur wiki; EX: cur=w xwiki=w -> add to xwiki_langs; cur=w xwikid=d -> don't add to xwiki_langs; DATE:2014-09-14
|
||||
&& xwiki_lang.Type_is_xwiki_lang(wiki.Domain_itm().Lang_orig_uid())// NOTE: use Lang_orig_id to handle xwikis between s.w and en.w; PAGE:s.q:Anonymous DATE:2014-09-10
|
||||
&& xwiki_lang.Type_is_xwiki_lang(wiki.Domain_itm().Lang_orig_key())// NOTE: use Lang_orig_id to handle xwikis between s.w and en.w; PAGE:s.q:Anonymous DATE:2014-09-10
|
||||
&& !lnki_ttl.ForceLiteralLink() // not literal; [[:en:A]]
|
||||
) {
|
||||
Wdata_sitelink_itm slink = new Wdata_sitelink_itm(null, null, null).Page_ttl_(lnki_ttl);
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.apis.xowa.html.modules.*; import gplx.xowa.html.modules.popups.keeplists.*;
|
||||
import gplx.xowa.gui.views.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.tblws.*;
|
||||
public class Xow_popup_parser {
|
||||
@@ -68,7 +69,7 @@ public class Xow_popup_parser {
|
||||
wtxt_ctx.Cur_page().Ttl_(ttl); // NOTE: must set cur_page, or rel lnkis won't work; EX: [[../A]]
|
||||
}
|
||||
public byte[] Parse(Xowe_wiki cur_wiki, Xoae_page page, Xog_tab_itm cur_tab, Xow_popup_itm popup_itm) { // NOTE: must pass cur_wiki for xwiki label; DATE:2014-07-02
|
||||
if (Bry_.Eq(popup_itm.Wiki_domain(), Xow_domain_.Domain_bry_wikidata)) {
|
||||
if (Bry_.Eq(popup_itm.Wiki_domain(), Xow_domain_itm_.Bry__wikidata)) {
|
||||
data.Wrdx_bfr().Add(app.Wiki_mgr().Wdata_mgr().Popup_text(page));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.files.xfers.*;
|
||||
public class Xoa_available_wikis_mgr implements GfoInvkAble {
|
||||
private Bry_fmtr itms_as_html_fmtr = Bry_fmtr.new_("\n <li><a href=\"/site/~{domain}/\"~{itm_cls}>~{domain}</a></li>", "domain", "itm_cls");
|
||||
public Xoa_available_wikis_mgr(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
@@ -29,7 +30,7 @@ public class Xoa_available_wikis_mgr implements GfoInvkAble {
|
||||
int len = xwiki_mgr.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_xwiki_itm itm = xwiki_mgr.Get_at(i);
|
||||
if (itm.Domain_tid() == Xow_domain_type_.Tid_home) continue;// don't show home wiki
|
||||
if (itm.Domain_tid() == Xow_domain_type_.Int__home) continue;// don't show home wiki
|
||||
if (!itm.Offline()) continue; // only show items marked Offline (added by Available_from_fsys); DATE:2014-09-21
|
||||
itms_as_html_fmtr.Bld_bfr_many(tmp_bfr, itm.Domain_bry(), itm_cls);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.gui.*; import gplx.xowa.html.sidebar.*; import gplx.xowa.pages.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.gui.*; import gplx.xowa.html.sidebar.*; import gplx.xowa.pages.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
import gplx.xowa.apis.xowa.html.*; import gplx.xowa.apis.xowa.html.skins.*;
|
||||
public class Xow_portal_mgr implements GfoInvkAble {
|
||||
@@ -24,7 +25,7 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
public Xow_portal_mgr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.sidebar_mgr = new Xowh_sidebar_mgr(wiki);
|
||||
this.missing_ns_cls = Bry_.Eq(wiki.Domain_bry(), Xow_domain_type_.Key_bry_home) ? Missing_ns_cls_hide : null; // if home wiki, set missing_ns to application default; if any other wiki, set to null; will be overriden during init
|
||||
this.missing_ns_cls = Bry_.Eq(wiki.Domain_bry(), Xow_domain_type_.Bry__home) ? Missing_ns_cls_hide : null; // if home wiki, set missing_ns to application default; if any other wiki, set to null; will be overriden during init
|
||||
}
|
||||
public void Init_by_lang(Xol_lang lang) {
|
||||
lang_is_rtl = !lang.Dir_ltr();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xowh_sidebar_mgr implements GfoInvkAble {
|
||||
Xol_msg_itm sidebar_msg = Xol_msg_mgr_.Get_msg_itm(bfr, wiki, wiki.Lang(), CONST_sidebar_ttl);
|
||||
if ( sidebar_msg.Src() == Xol_msg_itm.Src_missing
|
||||
|| ( sidebar_msg.Src() == Xol_msg_itm.Src_lang
|
||||
&& wiki.Domain_tid() == gplx.xowa.wikis.Xow_domain_type_.Tid_home
|
||||
&& wiki.Domain_tid() == gplx.xowa.wikis.domains.Xow_domain_type_.Int__home
|
||||
)) {
|
||||
html_bry = Bry_.Empty;
|
||||
bfr.Mkr_rls();
|
||||
|
||||
@@ -48,7 +48,8 @@ public class Gxw_html_server implements Gxw_html {
|
||||
}
|
||||
private String Exec_as_str(String s) {
|
||||
if (wtr == null) return ""; // HACK: handles http_server
|
||||
s = "(function () {" + s + "})();"; // NOTE: dependent on firefox addon which does 'var result = Function("with(arguments[0]){return "+cmd_text+"}")(session.window);'; DATE:2014-01-28
|
||||
s = "(function () {" + s + "})();"; // NOTE: dependent on firefox_addon which does 'var result = Function("with(arguments[0]){return "+cmd_text+"}")(session.window);'; DATE:2014-01-28
|
||||
gplx.core.threads.Thread_adp_.Sleep(50); // NOTE: need to sleep, else images won't actually show up on screen; PAGE:nethackwiki.com:Weapons; DATE:2015-08-23
|
||||
Xosrv_msg msg = Xosrv_msg.new_(Xosrv_cmd_types.Browser_exec, Bry_.Empty, Bry_.Empty, Bry_.Empty, Bry_.Empty, Bry_.new_u8(s));
|
||||
usr_dlg.Note_many("", "", "sending browser.js: msg=~{0}", s);
|
||||
wtr.Write(msg);
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.servers.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.langs.*;
|
||||
class Http_server_wkr_ {
|
||||
public static String Assert_main_page(Xoae_app app, String req) {
|
||||
int mode = -1;
|
||||
@@ -27,8 +27,8 @@ class Http_server_wkr_ {
|
||||
if (mode == -1) return req; // not a link to a Main Page; EX:localhost:8080/en.wikipedia.org/wiki/Earth
|
||||
if (req_array.length < 3) return req; // shouldn't happen; EX: "localhost:8080wiki"
|
||||
byte[] wiki_domain = Bry_.new_u8(req_array[1]);
|
||||
Xow_domain domain_itm = Xow_domain_.parse(wiki_domain);
|
||||
if (domain_itm.Domain_tid() == Xow_domain_type_.Tid_other && domain_itm.Lang_itm().Id() == Xol_lang_itm_.Id__intl) return req;
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(wiki_domain);
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_type_.Int__other && domain_itm.Lang_actl_itm().Id() == Xol_lang_itm_.Id__intl) return req;
|
||||
Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(wiki_domain);
|
||||
wiki.Init_assert();
|
||||
String main_page = String_.new_u8(wiki.Props().Main_page());
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Xosrv_server implements GfoInvkAble {
|
||||
}
|
||||
private String Exec_cmd(String msg_text) {
|
||||
Object rv_obj = app.Gfs_mgr().Run_str(msg_text);
|
||||
String rv = ClassAdp_.Eq_typeSafe(rv_obj, String_.Cls_ref_type) ? (String)rv_obj : Object_.Xto_str_strict_or_null(rv_obj);
|
||||
String rv = Type_adp_.Eq_typeSafe(rv_obj, String_.Cls_ref_type) ? (String)rv_obj : Object_.Xto_str_strict_or_null(rv_obj);
|
||||
return rv;
|
||||
}
|
||||
public String Exec_js(byte[] sender, byte[] msg_text) {
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.setup.maints; import gplx.*; import gplx.xowa.*; import gplx.xowa.setup.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Wmf_dump_list_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Wmf_dump_list_parser_fxt fxt = new Wmf_dump_list_parser_fxt();
|
||||
@Test public void Parse() {
|
||||
@@ -41,7 +41,7 @@ public class Wmf_dump_list_parser_tst {
|
||||
, fxt.itm("zh-classicalwiki", "20131128", Wmf_dump_itm.Status_tid_complete, "Dump complete", "2013-11-28 06:08:56")
|
||||
);
|
||||
}
|
||||
// @Test public void Update() { // MAINT:QUARTERLY:2015-03-01; must run C:\xowa\ and update dump status
|
||||
// @Test public void Update() { // MAINT:QUARTERLY:2015-08-23; must run C:\xowa\ and update dump status
|
||||
// Hash_adp_bry excluded_domains = Hash_adp_bry.cs().Add_many_str
|
||||
// ( "advisory.wikipedia.org", "beta.wikiversity.org", "donate.wikipedia.org", "login.wikipedia.org"
|
||||
// , "nostalgia.wikipedia.org", "outreach.wikipedia.org", "quality.wikipedia.org", "sources.wikipedia.org"
|
||||
@@ -49,7 +49,7 @@ public class Wmf_dump_list_parser_tst {
|
||||
// , "usability.wikipedia.org", "vote.wikipedia.org"
|
||||
// , "bd.wikimedia.org", "dk.wikimedia.org", "mx.wikimedia.org", "nyc.wikimedia.org", "nz.wikimedia.org", "pa-us.wikimedia.org", "rs.wikimedia.org", "ua.wikimedia.org"
|
||||
// );
|
||||
// Wmf_dump_itm[] itms = new Wmf_dump_list_parser().Parse(Io_mgr.I.LoadFilBry("C:\\xowa\\bin\\any\\html\\xowa\\maint\\backup-index.html"));
|
||||
// Wmf_dump_itm[] itms = new Wmf_dump_list_parser().Parse(Io_mgr.I.LoadFilBry("C:\\xowa\\bin\\any\\xowa\\xtns\\xowa\\maintenance\\backup-index.html"));
|
||||
// Array_.Sort(itms);
|
||||
// Bry_bfr sql_bfr = Bry_bfr.new_();
|
||||
// Bry_bfr bld_bfr = Bry_bfr.new_();
|
||||
@@ -59,12 +59,12 @@ public class Wmf_dump_list_parser_tst {
|
||||
// Wmf_dump_itm itm = itms[i];
|
||||
// byte[] abrv = itm.Wiki_abrv();
|
||||
// if (Bry_.Eq(abrv, Bry_.new_a7("testwikidatawiki"))) continue;
|
||||
// byte[] domain_bry = Xow_wiki_alias.Parse__domain_name(abrv, 0, abrv.length);
|
||||
// byte[] domain_bry = Xow_abrv_wm_.Parse_to_domain_bry(abrv);
|
||||
// if (domain_bry == null) continue; // not a standard WMF wiki; ignore
|
||||
// if (Bry_finder.Find_fwd(domain_bry, Bry_.new_a7("wikimania")) != Bry_.NotFound) continue;
|
||||
// if (excluded_domains.Has(domain_bry)) continue;
|
||||
// Xow_domain domain_itm = Xow_domain_.parse(domain_bry);
|
||||
// byte[] tid_name = Xto_display_name(Xow_domain_type_.Get_type_as_bry(domain_itm.Domain_tid()));
|
||||
// Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
// byte[] tid_name = Xto_display_name(Xow_domain_type_.Get_type_as_bry(domain_itm.Domain_type_id()));
|
||||
// sql_bfr
|
||||
// .Add_byte(Byte_ascii.Paren_bgn)
|
||||
// .Add_int_variable(counter++)
|
||||
@@ -97,9 +97,9 @@ public class Wmf_dump_list_parser_tst {
|
||||
//// Io_mgr.I.AppendFilBfr(temp, bld_bfr);
|
||||
// }
|
||||
// private static byte[] Xto_display_name(byte[] v) {
|
||||
// if (Bry_.Eq(v, Xow_domain_type_.Key_bry_wmforg)) return Bry_.new_a7("Wikimedia Foundation");
|
||||
// else if (Bry_.Eq(v, Xow_domain_type_.Key_bry_species)) return Bry_.new_a7("Wikispecies");
|
||||
// else if (Bry_.Eq(v, Xow_domain_type_.Key_bry_mediawiki)) return Bry_.new_a7("MediaWiki");
|
||||
// if (Bry_.Eq(v, Xow_domain_type_.Bry__wmforg)) return Bry_.new_a7("Wikimedia Foundation");
|
||||
// else if (Bry_.Eq(v, Xow_domain_type_.Bry__species)) return Bry_.new_a7("Wikispecies");
|
||||
// else if (Bry_.Eq(v, Xow_domain_type_.Bry__mediawiki)) return Bry_.new_a7("MediaWiki");
|
||||
// else return Bry_.Add(Byte_ascii.Case_upper(v[0]), Bry_.Mid(v, 1, v.length));
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.setup.maints; import gplx.*; import gplx.xowa.*; import gplx.xowa.setup.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.*; import gplx.xowa.files.downloads.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.files.downloads.*;
|
||||
public class Xoa_maint_mgr implements GfoInvkAble {
|
||||
public Xoa_maint_mgr(Xoae_app app) {
|
||||
this.app = app;
|
||||
@@ -57,8 +59,8 @@ public class Xoa_maint_mgr implements GfoInvkAble {
|
||||
Wmf_dump_itm itm = itms[i];
|
||||
byte[] wiki_abrv = itm.Wiki_abrv();
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "maint.html itm; itm=~{0}", wiki_abrv);
|
||||
byte[] wiki_domain = Xow_wiki_alias.Parse__domain_name(wiki_abrv, 0, wiki_abrv.length);
|
||||
if (wiki_domain == Xow_wiki_alias.Parse__domain_name_null) continue; // invalid wiki-name; ex: nycwikimedia
|
||||
byte[] wiki_domain = Xow_abrv_wm_.Parse_to_domain_bry(wiki_abrv);
|
||||
if (wiki_domain == null) continue; // invalid wiki-name; ex: nycwikimedia
|
||||
itms_hash.Add(wiki_domain, itm);
|
||||
}
|
||||
len = app.Wiki_mgr().Count();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.specials.allPages; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.lnkis.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.urls.*;
|
||||
public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page {
|
||||
public Xows_page_allpages(Xowe_wiki wiki) {
|
||||
@@ -73,7 +73,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
wiki.Ctx().Cur_page().Html_data().Display_ttl_(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_sp_allpages_hdr));
|
||||
url.Page_bry_(Bry_.Add(Bry_.new_a7("Special:"), ttl.Page_txt_wo_qargs())); // HACK: need to re-set Page b/c href_wtr does not eliminate qargs; DATE:2013-02-08
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home) {wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "home.invalid", "AllPages not implemented for home wiki"); return;}
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Int__home) {wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "home.invalid", "AllPages not implemented for home wiki"); return;}
|
||||
if (rslt_list_ttls == null) this.Itms_per_page_(itms_per_page);
|
||||
boolean found = Build_data(url, ttl); if (!found) return;
|
||||
Build_html(page);
|
||||
|
||||
@@ -16,17 +16,17 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.wikis.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.crts.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
|
||||
private final Xow_domain cur_domain;
|
||||
private final Xow_domain_itm cur_domain;
|
||||
private final Xow_domain_crt_itm[] ary; private final int ary_len;
|
||||
public Xow_domain_sorter__manual(Xow_domain cur_domain, Xow_domain_crt_itm[] ary) {
|
||||
public Xow_domain_sorter__manual(Xow_domain_itm cur_domain, Xow_domain_crt_itm[] ary) {
|
||||
this.cur_domain = cur_domain; this.ary = ary; this.ary_len = ary.length;
|
||||
}
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xow_domain lhs = (Xow_domain)lhsObj;
|
||||
Xow_domain rhs = (Xow_domain)rhsObj;
|
||||
Xow_domain_itm lhs = (Xow_domain_itm)lhsObj;
|
||||
Xow_domain_itm rhs = (Xow_domain_itm)rhsObj;
|
||||
int lhs_sort = Get_sort_idx_or_neg1(lhs);
|
||||
int rhs_sort = Get_sort_idx_or_neg1(rhs);
|
||||
if (lhs_sort == -1 && rhs_sort != -1) return rhs_sort;
|
||||
@@ -34,7 +34,7 @@ class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
|
||||
else if (lhs_sort != -1 && rhs_sort != -1) return Int_.Compare(lhs_sort, rhs_sort);
|
||||
else return Bry_.Compare(lhs.Domain_bry(), rhs.Domain_bry());
|
||||
}
|
||||
private int Get_sort_idx_or_neg1(Xow_domain domain) {
|
||||
private int Get_sort_idx_or_neg1(Xow_domain_itm domain) {
|
||||
int sort_idx = domain.Sort_idx(); if (sort_idx != -1) return sort_idx;
|
||||
sort_idx = Int_.MaxValue;
|
||||
for (int i = 0; i < ary_len; ++i) {
|
||||
@@ -44,7 +44,7 @@ class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
|
||||
domain.Sort_idx_(sort_idx);
|
||||
return sort_idx;
|
||||
}
|
||||
public static void Sort(Xow_domain_sorter__manual sorter, Xow_domain[] ary) {
|
||||
public static void Sort(Xow_domain_sorter__manual sorter, Xow_domain_itm[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
ary[i].Sort_idx_(-1);
|
||||
@@ -61,14 +61,14 @@ class Xow_domain_sorter__manual_tid implements gplx.lists.ComparerAble {
|
||||
}
|
||||
}
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xow_domain lhs = (Xow_domain)lhsObj;
|
||||
Xow_domain rhs = (Xow_domain)rhsObj;
|
||||
int lhs_sort = Get_sort_idx_or_neg1(lhs.Domain_tid());
|
||||
int rhs_sort = Get_sort_idx_or_neg1(rhs.Domain_tid());
|
||||
Xow_domain_itm lhs = (Xow_domain_itm)lhsObj;
|
||||
Xow_domain_itm rhs = (Xow_domain_itm)rhsObj;
|
||||
int lhs_sort = Get_sort_idx_or_neg1(lhs.Domain_type_id());
|
||||
int rhs_sort = Get_sort_idx_or_neg1(rhs.Domain_type_id());
|
||||
if (lhs_sort == -1 && rhs_sort != -1) return rhs_sort;
|
||||
else if (lhs_sort != -1 && rhs_sort == -1) return lhs_sort;
|
||||
else if (lhs_sort != -1 && rhs_sort != -1) return Int_.Compare(lhs_sort, rhs_sort);
|
||||
else return Bry_.Compare(Xow_domain_type_.Get_type_as_bry(lhs.Domain_tid()), Xow_domain_type_.Get_type_as_bry(rhs.Domain_tid()));
|
||||
else return Bry_.Compare(Xow_domain_type_.Get_type_as_bry(lhs.Domain_type_id()), Xow_domain_type_.Get_type_as_bry(rhs.Domain_type_id()));
|
||||
}
|
||||
private int Get_sort_idx_or_neg1(int tid) {
|
||||
Object o = sort_hash.Get_by(sort_key.Val_(tid));
|
||||
@@ -95,14 +95,14 @@ class Xow_domain_sorter__manual_lang implements gplx.lists.ComparerAble {
|
||||
}
|
||||
}
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xow_domain lhs = (Xow_domain)lhsObj;
|
||||
Xow_domain rhs = (Xow_domain)rhsObj;
|
||||
int lhs_sort = Get_sort_idx_or_neg1(lhs.Lang_uid());
|
||||
int rhs_sort = Get_sort_idx_or_neg1(rhs.Lang_uid());
|
||||
Xow_domain_itm lhs = (Xow_domain_itm)lhsObj;
|
||||
Xow_domain_itm rhs = (Xow_domain_itm)rhsObj;
|
||||
int lhs_sort = Get_sort_idx_or_neg1(lhs.Lang_actl_uid());
|
||||
int rhs_sort = Get_sort_idx_or_neg1(rhs.Lang_actl_uid());
|
||||
if (lhs_sort == -1 && rhs_sort != -1) return rhs_sort;
|
||||
else if (lhs_sort != -1 && rhs_sort == -1) return lhs_sort;
|
||||
else if (lhs_sort != -1 && rhs_sort != -1) return Int_.Compare(lhs_sort, rhs_sort);
|
||||
else return Bry_.Compare(lhs.Lang_key(), rhs.Lang_key());
|
||||
else return Bry_.Compare(lhs.Lang_actl_key(), rhs.Lang_actl_key());
|
||||
}
|
||||
private int Get_sort_idx_or_neg1(int tid) {
|
||||
Object o = sort_hash.Get_by(sort_key.Val_(tid));
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*;
|
||||
class Xows_core {
|
||||
private final Xoae_wiki_mgr wiki_mgr;
|
||||
private final Hash_adp_bry cache_hash = Hash_adp_bry.cs(); private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs();
|
||||
@@ -33,9 +34,9 @@ class Xows_core {
|
||||
}
|
||||
public void Search(Xow_wiki search_wiki, Xoae_page page, Xows_ui_qry qry) {
|
||||
// generate 1 cmd per wiki
|
||||
Xow_domain[] domain_ary = qry.Wiki_domains(); int domain_ary_len = domain_ary.length;
|
||||
Xow_domain_itm[] domain_ary = qry.Wiki_domains(); int domain_ary_len = domain_ary.length;
|
||||
for (int i = 0; i < domain_ary_len; ++i) {
|
||||
Xow_domain domain = domain_ary[i];
|
||||
Xow_domain_itm domain = domain_ary[i];
|
||||
try {
|
||||
Xowe_wiki wiki = wiki_mgr.Get_by_key_or_make(domain.Domain_bry()); wiki.Init_assert();
|
||||
Assert_page_count(wiki);
|
||||
|
||||
@@ -16,7 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import org.junit.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.tdbs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import org.junit.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.tdbs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xows_html_wkr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xows_html_wkr_fxt fxt = new Xows_html_wkr_fxt();
|
||||
@Test public void Paging() {
|
||||
@@ -54,7 +56,7 @@ class Xows_html_wkr_fxt {
|
||||
return this;
|
||||
}
|
||||
public void Test_paging(boolean fwd, int paging_idx, String expd) {
|
||||
Xows_ui_qry qry = new Xows_ui_qry(Bry_.new_a7("A"), paging_idx, 100, Xosrh_rslt_itm_sorter.Tid_len_dsc, new Xows_ns_mgr(), true, new Xow_domain[] {Xow_domain_.parse(wiki.Domain_bry())});
|
||||
Xows_ui_qry qry = new Xows_ui_qry(Bry_.new_a7("A"), paging_idx, 100, Xosrh_rslt_itm_sorter.Tid_len_dsc, new Xows_ns_mgr(), true, new Xow_domain_itm[] {Xow_domain_itm_.parse(wiki.Domain_bry())});
|
||||
qry.Page_max_(2);
|
||||
html_mgr.Init_by_wiki(wiki, wiki.Lang().Num_mgr(), qry);
|
||||
byte[] paging_link = html_mgr.Paging_link(fwd);
|
||||
|
||||
@@ -16,12 +16,12 @@ 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.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.wikis.*; import gplx.xowa.apis.xowa.specials.*;
|
||||
import gplx.xowa.wikis.domains.crts.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.apis.xowa.specials.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
private final Xoae_app app; private final Xow_domain wiki_domain; private final Xoapi_search search_api;
|
||||
private final Xoae_app app; private final Xow_domain_itm wiki_domain; private final Xoapi_search search_api;
|
||||
private final Xows_core search_mgr; private final Xows_arg_mgr args_mgr = new Xows_arg_mgr();
|
||||
private Xow_domain[] search_domain_ary;
|
||||
private Xow_domain_itm[] search_domain_ary;
|
||||
public Xows_page__search(Xowe_wiki wiki) {
|
||||
this.app = wiki.Appe();
|
||||
this.wiki_domain = wiki.Domain_itm();
|
||||
@@ -35,7 +35,7 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
private void Multi_wikis_changed() {
|
||||
Xow_domain_crt_itm crt = search_api.Multi_wikis_crt(wiki_domain);
|
||||
this.search_domain_ary = app.Usere().Wiki().Xwiki_mgr().Get_by_crt(wiki_domain, crt);
|
||||
if (search_domain_ary.length == 0) search_domain_ary = new Xow_domain[] {wiki_domain}; // default to current if bad input
|
||||
if (search_domain_ary.length == 0) search_domain_ary = new Xow_domain_itm[] {wiki_domain}; // default to current if bad input
|
||||
Multi_sorts_changed();
|
||||
}
|
||||
private void Multi_sorts_changed() {
|
||||
@@ -45,7 +45,7 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
Xow_domain_sorter__manual.Sort(sorter, search_domain_ary);
|
||||
}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home) return; // do not allow search in home wiki; will throw null ref error b/c no search_ttl dirs
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Int__home) return; // do not allow search in home wiki; will throw null ref error b/c no search_ttl dirs
|
||||
if (search_domain_ary == null) Multi_wikis_changed();
|
||||
// get args
|
||||
Xog_search_suggest_mgr search_suggest_mgr = wiki.Appe().Gui_mgr().Search_suggest_mgr();
|
||||
|
||||
@@ -16,10 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
class Xows_ui_qry {
|
||||
private final List_adp cmd_list = List_adp_.new_();
|
||||
public Xows_ui_qry(byte[] search_raw, int page_idx, int page_len, byte sort_tid, Xows_ns_mgr ns_mgr, boolean async_db, Xow_domain[] wiki_domains) {
|
||||
public Xows_ui_qry(byte[] search_raw, int page_idx, int page_len, byte sort_tid, Xows_ns_mgr ns_mgr, boolean async_db, Xow_domain_itm[] wiki_domains) {
|
||||
this.search_raw = search_raw; this.page_idx = page_idx; this.page_len = page_len; this.sort_tid = sort_tid; this.ns_mgr = ns_mgr; this.async_db = async_db; this.wiki_domains = wiki_domains;
|
||||
this.itms_bgn = page_idx * page_len;
|
||||
this.page_max = page_idx; // default page_max to page_idx; adjust later when all results are known
|
||||
@@ -36,7 +36,7 @@ class Xows_ui_qry {
|
||||
public int Itms_end() {return itms_bgn + page_len;}
|
||||
public byte Sort_tid() {return sort_tid;} private final byte sort_tid;
|
||||
public Xows_ns_mgr Ns_mgr() {return ns_mgr;} private final Xows_ns_mgr ns_mgr;
|
||||
public Xow_domain[] Wiki_domains() {return wiki_domains;} private final Xow_domain[] wiki_domains;
|
||||
public Xow_domain_itm[] Wiki_domains() {return wiki_domains;} private final Xow_domain_itm[] wiki_domains;
|
||||
public void Page_max_(int v) {this.page_max = v;}
|
||||
public int Cmds__len() {return cmd_list.Count();}
|
||||
public Xows_ui_cmd Cmds__get_at(int i) {return (Xows_ui_cmd)cmd_list.Get_at(i);}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.urls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.files.*;
|
||||
public class Xoa_url_parser {
|
||||
private final Url_encoder encoder;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
@@ -47,14 +47,19 @@ public class Xoa_url_parser {
|
||||
// rv.Page_bry_(rv.Wiki_bry());
|
||||
// rv.Wiki_bry_(wiki.Domain_bry());
|
||||
// }
|
||||
return this.Parse(bry);
|
||||
Xoa_url rv = Xoa_url.blank();
|
||||
this.Parse(rv, bry, 0, bry.length);
|
||||
if (rv.Page_is_main()) { // Main_Page requested; EX: "zh.wikipedia.org"; "zh.wikipedia.org/wiki/"; DATE:2014-02-16
|
||||
Xow_wiki actl_wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(rv.Wiki_bry()); // NOTE: must call Init_assert to load Main_Page; only call if from url_bar, else all sister wikis will be loaded when parsing Sister_wikis panel
|
||||
rv.Page_bry_(actl_wiki.Props().Main_page());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Gfo_url_parser Url_parser() {return url_parser;}
|
||||
public Xoa_url Parse(byte[] src) {Xoa_url rv = Xoa_url.blank(); Parse(rv, src); return rv;}
|
||||
public Xoa_url Parse(byte[] src, int bgn, int end) {Xoa_url rv = Xoa_url.blank(); Parse(rv, src, bgn, end, false); return rv;}
|
||||
public boolean Parse(Xoa_url rv, byte[] src) {return Parse(rv, src, 0, src.length, false);}
|
||||
public boolean Parse(Xoa_url rv, byte[] src, int bgn, int end) {return Parse(rv, src, bgn, end, false);}
|
||||
private boolean Parse(Xoa_url rv, byte[] src, int bgn, int end, boolean get_main_page) {
|
||||
public Xoa_url Parse(byte[] src, int bgn, int end) {Xoa_url rv = Xoa_url.blank(); Parse(rv, src, bgn, end); return rv;}
|
||||
public boolean Parse(Xoa_url rv, byte[] src) {return Parse(rv, src, 0, src.length);}
|
||||
public boolean Parse(Xoa_url rv, byte[] src, int bgn, int end) {
|
||||
if (end - bgn == 0) {Init_tmp_vars(Gfo_url.Empty); Make(rv); return false;}
|
||||
src = encoder.Decode(src, bgn, end); // NOTE: must decode any url-encoded parameters
|
||||
int src_len = src.length;
|
||||
@@ -93,15 +98,8 @@ public class Xoa_url_parser {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmp_page_is_main) { // Main_Page requested; EX: "zh.wikipedia.org"; "zh.wikipedia.org/wiki/"; DATE:2014-02-16
|
||||
if (get_main_page) {
|
||||
Xow_wiki actl_wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(tmp_wiki); // NOTE: must call Init_assert to load Main_Page; only call if from url_bar, else all sister wikis will be loaded when parsing Sister_wikis panel
|
||||
tmp_page = actl_wiki.Props().Main_page();
|
||||
}
|
||||
else
|
||||
tmp_page = Xoa_page_.Main_page_bry_empty;
|
||||
}
|
||||
Bld_qargs();
|
||||
if (tmp_page_is_main) tmp_page = Xoa_page_.Main_page_bry_empty;
|
||||
if (tmp_anch != null) {
|
||||
byte[] anchor_bry = Xoa_app_.Utl__encoder_mgr().Id().Encode(tmp_anch); // reencode for anchors (which use . encoding, not % encoding); PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
|
||||
tmp_anch = anchor_bry;
|
||||
@@ -153,8 +151,8 @@ public class Xoa_url_parser {
|
||||
// thum: https://upload.wikimedia.org/wikipedia/commons/thumb/a/ab/A.jpg/220px-A.jpg
|
||||
byte[] domain_type = tmp_segs[1]; // seg[0] = type; EX: "/wikipedia/"
|
||||
byte[] lang = tmp_segs[2]; // seg[1] = lang; EX: "en", "fr"; "commons"
|
||||
if (Bry_.Eq(lang, Xow_domain_type_.Key_bry_commons)) // commons links will have fmt of "/wikipedia/commons"; must change to wikimedia
|
||||
domain_type = Xow_domain_type_.Key_bry_wikimedia;
|
||||
if (Bry_.Eq(lang, Xow_domain_type_.Bry__commons)) // commons links will have fmt of "/wikipedia/commons"; must change to wikimedia
|
||||
domain_type = Xow_domain_type_.Bry__wikimedia;
|
||||
tmp_wiki = tmp_bfr.Clear()
|
||||
.Add(lang).Add_byte(Byte_ascii.Dot) // add lang/type + .; EX: "en."; "fr."; "commons."
|
||||
.Add(domain_type).Add(Bry_dot_org) // add type + .org; EX: "wikipedia.org"; "wikimedia.org";
|
||||
@@ -204,7 +202,7 @@ public class Xoa_url_parser {
|
||||
int rv = -1;
|
||||
switch (tmp_segs_len - bgn_seg) {
|
||||
case 1: // "en.wikipedia.org"
|
||||
if (Bry_.Eq(tmp_segs[0 + bgn_seg], Xow_domain_.Domain_bry_home)) { // ignore "home" which should always go to "home" of current wiki, not "home" wiki
|
||||
if (Bry_.Eq(tmp_segs[0 + bgn_seg], Xow_domain_itm_.Bry__home)) { // ignore "home" which should always go to "home" of current wiki, not "home" wiki
|
||||
tmp_wiki = domain_bry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ public class Xoa_url_parser__url_bar_tst {
|
||||
Xowe_wiki zh_wiki = tstr.Prep_create_wiki("zh.wikipedia.org");
|
||||
zh_wiki.Props().Main_page_(Bry_.new_a7("Zh_Main_Page"));
|
||||
tstr.Run_parse_from_url_bar("zh.w:Main_Page") .Chk_page_is_main_n().Chk_to_str("zh.wikipedia.org/wiki/Main_Page");
|
||||
tstr.Run_parse_from_url_bar("zh.w:") .Chk_page_is_main_y().Chk_to_str("zh.wikipedia.org/wiki/");
|
||||
tstr.Run_parse_from_url_bar("en.w:") .Chk_page_is_main_y().Chk_to_str("en.wikipedia.org/wiki/"); // old bug: still stuck at zh main page due to reused objects
|
||||
tstr.Run_parse_from_url_bar("zh.w:") .Chk_page_is_main_y().Chk_to_str("zh.wikipedia.org/wiki/Zh_Main_Page");
|
||||
tstr.Run_parse_from_url_bar("en.w:") .Chk_page_is_main_y().Chk_to_str("en.wikipedia.org/wiki/Main_Page"); // old bug: still stuck at zh main page due to reused objects
|
||||
}
|
||||
@Test public void Mobile() { // PURPOSE: handle mobile links; DATE:2014-05-03
|
||||
tstr.Run_parse_from_url_bar("en.m.wikipedia.org/wiki/A" ).Chk_to_str("en.wikipedia.org/wiki/A"); // basic
|
||||
|
||||
@@ -20,7 +20,6 @@ import gplx.xowa.langs.cases.*; import gplx.xowa.wikis.*; import gplx.xowa.xtns.
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
class Xou_user_ {
|
||||
public static Xowe_wiki new_or_create_(Xoue_user user, Xoae_app app) {
|
||||
// Io_url wiki_dir = user.Fsys_mgr().Home_wiki_dir().GenSubDir_nest("wiki", Xow_domain_type_.Key_str_home);
|
||||
Io_url wiki_dir = app.Fsys_mgr().Home_wiki_dir();
|
||||
Xol_lang lang = app.Lang_mgr().Get_by_key_or_new(app.Lang_mgr().Default_lang());
|
||||
lang.Init_by_load(); // NOTE: lang.Load() must occur before Xowe_wiki.new() b/c wiki will create parsers based on lang
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Xouc_setup_mgr implements GfoInvkAble {
|
||||
if (String_.Eq(plats_ary[i], op_sys_name)) return;
|
||||
}
|
||||
Io_url setup_url = app.Fsys_mgr().Root_dir().GenSubFil_nest("bin", op_sys_name, "xowa", "script", "setup_lua.sh");
|
||||
Run("sh", String_.Format("\"{0}\"", setup_url.Raw()));
|
||||
Run("sh", String_.Format("\"{0}\" \"{1}\"", setup_url.Raw(), app.Fsys_mgr().Root_dir()));
|
||||
setup_completed += op_sys_name + ";";
|
||||
app.Cfg_mgr().Set_by_all("app.user.cfg.setup.setup_completed", setup_completed);
|
||||
app.Cfg_mgr().Db_save_txt();
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.users; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.users.data.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.langs.genders.*;
|
||||
public class Xouv_user implements Xou_user {
|
||||
private Xoa_wiki_mgr wiki_mgr;
|
||||
@@ -27,7 +27,7 @@ public class Xouv_user implements Xou_user {
|
||||
public String Key() {return key;} private String key;
|
||||
public Xou_db_mgr User_db_mgr() {return user_db_mgr;} private Xou_db_mgr user_db_mgr;
|
||||
public int Gender() {return Xol_gender_.Tid_unknown;}
|
||||
public Xow_wiki Wikii() {if (wiki == null) wiki = wiki_mgr.Get_by_key_or_make_init_y(Xow_domain_.Domain_bry_home); return wiki;} private Xow_wiki wiki;
|
||||
public Xow_wiki Wikii() {if (wiki == null) wiki = wiki_mgr.Get_by_key_or_make_init_y(Xow_domain_itm_.Bry__home); return wiki;} private Xow_wiki wiki;
|
||||
public void Init_db(Xoa_app app, Xoa_wiki_mgr wiki_mgr, Io_url db_url) {
|
||||
this.wiki_mgr = wiki_mgr;
|
||||
this.user_db_mgr = new Xou_db_mgr(app);
|
||||
|
||||
@@ -17,7 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
class Xoud_opt_scope {
|
||||
public Xoud_opt_scope(int lang_id, int type_id) {this.lang_id = lang_id; this.type_id = type_id;}
|
||||
public int Lang_id() {return lang_id;} private final int lang_id;
|
||||
@@ -63,22 +64,22 @@ class Xoud_opt_scope_parser {
|
||||
return Xoud_opt_scope.App;
|
||||
}
|
||||
private static final Btrie_slim_mgr btrie_by_type = Btrie_slim_mgr.cs()
|
||||
.Add_str_int("w" , Xow_domain_type_.Tid_wikipedia)
|
||||
.Add_str_int("d" , Xow_domain_type_.Tid_wiktionary)
|
||||
.Add_str_int("s" , Xow_domain_type_.Tid_wikisource)
|
||||
.Add_str_int("v" , Xow_domain_type_.Tid_wikivoyage)
|
||||
.Add_str_int("q" , Xow_domain_type_.Tid_wikiquote)
|
||||
.Add_str_int("b" , Xow_domain_type_.Tid_wikibooks)
|
||||
.Add_str_int("u" , Xow_domain_type_.Tid_wikiversity)
|
||||
.Add_str_int("n" , Xow_domain_type_.Tid_wikinews)
|
||||
.Add_str_int("w" , Xow_domain_type_.Int__wikipedia)
|
||||
.Add_str_int("d" , Xow_domain_type_.Int__wiktionary)
|
||||
.Add_str_int("s" , Xow_domain_type_.Int__wikisource)
|
||||
.Add_str_int("v" , Xow_domain_type_.Int__wikivoyage)
|
||||
.Add_str_int("q" , Xow_domain_type_.Int__wikiquote)
|
||||
.Add_str_int("b" , Xow_domain_type_.Int__wikibooks)
|
||||
.Add_str_int("u" , Xow_domain_type_.Int__wikiversity)
|
||||
.Add_str_int("n" , Xow_domain_type_.Int__wikinews)
|
||||
.Add_str_int("*" , Xoud_opt_scope.Type_id_wildcard)
|
||||
.Add_str_int("xowa" , Xow_domain_type_.Tid_home)
|
||||
.Add_str_int("wd" , Xow_domain_type_.Tid_wikidata)
|
||||
.Add_str_int("c" , Xow_domain_type_.Tid_commons)
|
||||
.Add_str_int("species" , Xow_domain_type_.Tid_species)
|
||||
.Add_str_int("meta" , Xow_domain_type_.Tid_meta)
|
||||
.Add_str_int("mw" , Xow_domain_type_.Tid_mediawiki)
|
||||
.Add_str_int("wmf" , Xow_domain_type_.Tid_wmfblog)
|
||||
.Add_str_int("xowa" , Xow_domain_type_.Int__home)
|
||||
.Add_str_int("wd" , Xow_domain_type_.Int__wikidata)
|
||||
.Add_str_int("c" , Xow_domain_type_.Int__commons)
|
||||
.Add_str_int("species" , Xow_domain_type_.Int__species)
|
||||
.Add_str_int("meta" , Xow_domain_type_.Int__meta)
|
||||
.Add_str_int("mw" , Xow_domain_type_.Int__mediawiki)
|
||||
.Add_str_int("wmf" , Xow_domain_type_.Int__wmfblog)
|
||||
;
|
||||
private static final Xoud_opt_scope[] Ary_app = new Xoud_opt_scope[] {Xoud_opt_scope.App};
|
||||
}
|
||||
|
||||
@@ -16,16 +16,17 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoud_opt_scope_tst {
|
||||
private Xoud_opt_scope_fxt fxt = new Xoud_opt_scope_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse("en.w" , fxt.Make(Xol_lang_itm_.Id_en, Xow_domain_type_.Tid_wikipedia));
|
||||
fxt.Test_parse("en.w" , fxt.Make(Xol_lang_itm_.Id_en, Xow_domain_type_.Int__wikipedia));
|
||||
fxt.Test_parse("en.*" , fxt.Make(Xol_lang_itm_.Id_en, Xoud_opt_scope.Type_id_wildcard));
|
||||
fxt.Test_parse("*.w" , fxt.Make(Xoud_opt_scope.Lang_id_wildcard, Xow_domain_type_.Tid_wikipedia));
|
||||
fxt.Test_parse("*.w" , fxt.Make(Xoud_opt_scope.Lang_id_wildcard, Xow_domain_type_.Int__wikipedia));
|
||||
fxt.Test_parse("<any>" , Xoud_opt_scope.App);
|
||||
fxt.Test_parse("en.w,fr.d" , fxt.Make(Xol_lang_itm_.Id_en, Xow_domain_type_.Tid_wikipedia), fxt.Make(Xol_lang_itm_.Id_fr, Xow_domain_type_.Tid_wiktionary));
|
||||
fxt.Test_parse("en.w,fr.d" , fxt.Make(Xol_lang_itm_.Id_en, Xow_domain_type_.Int__wikipedia), fxt.Make(Xol_lang_itm_.Id_fr, Xow_domain_type_.Int__wiktionary));
|
||||
}
|
||||
}
|
||||
class Xoud_opt_scope_fxt {
|
||||
|
||||
@@ -16,13 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.utls.upgrades; import gplx.*; import gplx.xowa.*; import gplx.xowa.utls.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_upgrade_mgr {
|
||||
public static void Check(Xoae_app app) {
|
||||
Upgrade_history(app);
|
||||
}
|
||||
public static void Check(Xowe_wiki wiki) {
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home) return; // home wiki never needs to be migrated
|
||||
if (wiki.Domain_tid() == Xow_domain_type_.Int__home) return; // home wiki never needs to be migrated
|
||||
try {
|
||||
if (Bry_.Eq(wiki.Props().Bldr_version(), Bry_.Empty)) { // version is ""; wiki must be created prior to v0.2.1; create wiki_core.gfs
|
||||
Upgrader_v00_02_01 mgr = new Upgrader_v00_02_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.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_wiki_regy {
|
||||
private Xoae_app app;
|
||||
private boolean init_needed = true;
|
||||
@@ -28,8 +29,8 @@ public class Xoa_wiki_regy {
|
||||
}
|
||||
public boolean Url_is_invalid_domain(Xoa_url url) {
|
||||
if (!Bry_.Eq(url.Page_bry(), Xoa_page_.Main_page_bry)) return false; // page is not "Main_Page"; assume not an invalid domain str; EX: "uk/wiki/Main_Page"
|
||||
if ( Bry_.Eq(Xow_domain_type_.Key_bry_home, url.Wiki_bry()) // wiki is "home"
|
||||
&& !Bry_.Eq(Xow_domain_type_.Key_bry_home, url.Raw())) // raw is "home"; should be "home/wiki/Main_Page"; DATE:2014-02-09
|
||||
if ( Bry_.Eq(Xow_domain_type_.Bry__home, url.Wiki_bry()) // wiki is "home"
|
||||
&& !Bry_.Eq(Xow_domain_type_.Bry__home, url.Raw())) // raw is "home"; should be "home/wiki/Main_Page"; DATE:2014-02-09
|
||||
return false; // special case to handle "home" which should mean "home" in any wiki, but "home/wiki/Main_Page" in home wiki
|
||||
return !this.Has(url.Wiki_bry());
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
private Xoae_app app;
|
||||
private List_adp list = List_adp_.new_(); private Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
@@ -51,7 +52,7 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
return rv;
|
||||
}
|
||||
public Xowe_wiki Wiki_commons() {
|
||||
Xowe_wiki rv = this.Get_by_key_or_null(Xow_domain_.Domain_bry_commons);
|
||||
Xowe_wiki rv = this.Get_by_key_or_null(Xow_domain_itm_.Bry__commons);
|
||||
if (rv != null) rv.Init_assert();
|
||||
return rv;
|
||||
}
|
||||
@@ -93,13 +94,14 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
} private static final String Invk_get = "get", Invk_groups = "groups", Invk_scripts = "scripts", Invk_wdata = "wdata";
|
||||
private static final String Invk_len = "len", Invk_get_at = "get_at";
|
||||
private Xowe_wiki New_wiki(byte[] key) {
|
||||
Xow_domain domain_itm = Xow_domain_.parse(key);
|
||||
byte[] lang_key = domain_itm.Lang_key();
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(key);
|
||||
byte[] lang_key = domain_itm.Lang_actl_key();
|
||||
if (lang_key == Xol_lang_itm_.Key__unknown) lang_key = Xol_lang_.Key_en; // unknown langs default to english; note that this makes nonwmf english by default
|
||||
Xol_lang lang =
|
||||
domain_itm.Domain_tid() == Xow_domain_type_.Tid_other
|
||||
? new Xol_lang(app.Lang_mgr(), Xol_lang_.Key_en).Kwd_mgr__strx_(true)
|
||||
: app.Lang_mgr().Get_by_key_or_new(lang_key);
|
||||
Xol_lang lang = app.Lang_mgr().Get_by_key_or_new(lang_key);
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_type_.Int__other) {
|
||||
lang = new Xol_lang(app.Lang_mgr(), Xol_lang_.Key_en).Kwd_mgr__strx_(true); // create a new english lang, but enable strx functions; DATE:2015-08-23
|
||||
Xol_lang_.Lang_init(lang);
|
||||
}
|
||||
Xow_ns_mgr ns_mgr = Xow_ns_mgr_.default_(lang.Case_mgr());
|
||||
Io_url wiki_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(domain_itm.Domain_str());
|
||||
Xowe_wiki rv = new Xowe_wiki(app, lang, ns_mgr, domain_itm, wiki_dir);
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain {
|
||||
Xow_domain(byte[] domain_bry, Xow_domain_type domain_type, Xol_lang_itm lang_itm, Xol_lang_itm lang_orig_itm) {
|
||||
this.domain_bry = domain_bry; this.domain_type = domain_type; this.lang_itm = lang_itm; this.lang_orig_itm = lang_orig_itm;
|
||||
this.domain_str = String_.new_u8(domain_bry);
|
||||
this.abrv_xo = Xow_domain_abrv_xo_.To_bry(domain_bry, lang_orig_itm, domain_type);
|
||||
}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public int Domain_tid() {return domain_type.Tid();}
|
||||
public Xow_domain_type Domain_type() {return domain_type;} private final Xow_domain_type domain_type;
|
||||
public byte[] Abrv_wm() {return abrv_wm;} public void Abrv_wm_(byte[] v) {abrv_wm = v;} private byte[] abrv_wm; // EX: enwiki
|
||||
public byte[] Abrv_xo() {return abrv_xo;} private final byte[] abrv_xo;
|
||||
public Xol_lang_itm Lang_itm() {return lang_itm;} private final Xol_lang_itm lang_itm;
|
||||
public int Lang_uid() {return lang_itm.Id();}
|
||||
public byte[] Lang_key() {return lang_itm.Key();}
|
||||
public Xol_lang_itm Lang_orig_itm() {return lang_orig_itm;} private final Xol_lang_itm lang_orig_itm;
|
||||
public int Lang_orig_uid() {return lang_orig_itm.Id();}
|
||||
public byte[] Lang_orig_key() {return lang_orig_itm.Key();}
|
||||
public int Sort_idx() {return sort_idx;} public void Sort_idx_(int v) {sort_idx = v;} private int sort_idx = -1; // used for Search
|
||||
public static Xow_domain new_(byte[] domain_bry, int domain_tid, byte[] lang_key) {
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key_or_intl(lang_key);
|
||||
return new Xow_domain(domain_bry, Xow_domain_type_.Get_type_as_itm(domain_tid), lang_itm, lang_itm);
|
||||
}
|
||||
public static Xow_domain new_(byte[] domain_bry, int domain_tid, Xol_lang_itm lang) {return new Xow_domain(domain_bry, Xow_domain_type_.Get_type_as_itm(domain_tid), lang, lang);}
|
||||
public static Xow_domain new_orig(byte[] domain_bry, int domain_tid, byte[] lang_key, byte[] lang_orig_key) {
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key_or_intl(lang_key);
|
||||
Xol_lang_itm lang_orig_itm = Bry_.Eq(lang_key, lang_orig_key) ? lang_itm : Xol_lang_itm_.Get_by_key_or_intl(lang_orig_key);
|
||||
return new Xow_domain(domain_bry, Xow_domain_type_.Get_type_as_itm(domain_tid), lang_itm, lang_orig_itm);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_ {
|
||||
public static final String
|
||||
Domain_str_enwiki = "en.wikipedia.org"
|
||||
, Domain_str_species = "species.wikimedia.org"
|
||||
, Domain_str_commons = "commons.wikimedia.org"
|
||||
, Domain_str_wikidata = "www.wikidata.org"
|
||||
, Domain_str_mediawiki = "www.mediawiki.org"
|
||||
, Domain_str_meta = "meta.wikimedia.org"
|
||||
, Domain_str_incubator = "incubator.wikimedia.org"
|
||||
, Domain_str_wmforg = "wikimediafoundation.org"
|
||||
, Domain_str_home = "home"
|
||||
;
|
||||
public static final byte[]
|
||||
Domain_bry_enwiki = Bry_.new_a7(Domain_str_enwiki)
|
||||
, Domain_bry_species = Bry_.new_a7(Domain_str_species)
|
||||
, Domain_bry_commons = Bry_.new_a7(Domain_str_commons)
|
||||
, Domain_bry_wikidata = Bry_.new_a7(Domain_str_wikidata)
|
||||
, Domain_bry_mediawiki = Bry_.new_a7(Domain_str_mediawiki)
|
||||
, Domain_bry_meta = Bry_.new_a7(Domain_str_meta)
|
||||
, Domain_bry_incubator = Bry_.new_a7(Domain_str_incubator)
|
||||
, Domain_bry_wmforg = Bry_.new_a7(Domain_str_wmforg)
|
||||
, Domain_bry_home = Bry_.new_a7(Domain_str_home)
|
||||
;
|
||||
public static final byte[] Seg_bry_org = Bry_.new_a7("org"), Seg_bry_www = Bry_.new_a7("www");
|
||||
public static Xow_domain parse(byte[] raw) {
|
||||
/*
|
||||
~{type}.org EX: wikimediafoundation
|
||||
~{type}.wikimedia.org EX: commons; species; meta; incubator
|
||||
~{lang}.~{type}.org EX: en.wikipedia, etc;
|
||||
~www.~{type}.org EX: mediawiki; wikidata;
|
||||
*/
|
||||
int raw_len = raw.length;
|
||||
int dot_0 = Bry_finder.Find_fwd(raw, Byte_ascii.Dot, 0, raw_len);
|
||||
if (dot_0 == Bry_.NotFound) { // 0 dots; check for "home"
|
||||
return Bry_.Eq(raw, Xow_domain_type_.Key_bry_home)
|
||||
? Xow_domain_uid_.To_domain(Xow_domain_uid_.Tid_xowa)
|
||||
: new_other(raw);
|
||||
}
|
||||
int dot_1 = Bry_finder.Find_fwd(raw, Byte_ascii.Dot, dot_0 + 1, raw_len);
|
||||
if (dot_1 == Bry_.NotFound) { // 1 dot; check for "wikimediafoundation.org"
|
||||
return Bry_.Match(raw, 0, dot_0, Xow_domain_type_.Key_bry_wmforg)
|
||||
? Xow_domain.new_(raw, Xow_domain_type_.Tid_wmfblog, Xol_lang_itm_.Key__unknown)
|
||||
: new_other(raw);
|
||||
}
|
||||
// 2 dots
|
||||
int seg_1_tid = Xow_domain_type_.Get_type_as_tid(raw, dot_0 + 1, dot_1); // parse middle; EX: ".wikipedia."
|
||||
if (seg_1_tid == Xow_domain_type_.Tid_null) return new_other(raw); // seg_1 is unknown; return other;
|
||||
switch (seg_1_tid) {
|
||||
case Xow_domain_type_.Tid_wikipedia: case Xow_domain_type_.Tid_wiktionary: case Xow_domain_type_.Tid_wikisource: case Xow_domain_type_.Tid_wikibooks:
|
||||
case Xow_domain_type_.Tid_wikiversity: case Xow_domain_type_.Tid_wikiquote: case Xow_domain_type_.Tid_wikinews: case Xow_domain_type_.Tid_wikivoyage: // ~{lang}.~{type}.org
|
||||
byte[] lang_orig = Bry_.Mid(raw, 0, dot_0);
|
||||
byte[] lang_actl = Get_lang_code_for_mw_messages_file(lang_orig);
|
||||
return Xow_domain.new_orig(raw, seg_1_tid, lang_actl, lang_orig); // NOTE: seg_tids must match wiki_tids
|
||||
case Xow_domain_type_.Tid_wikidata: case Xow_domain_type_.Tid_mediawiki: // ~www.~{type}.org
|
||||
return Xow_domain.new_(raw, seg_1_tid, Xol_lang_itm_.Key__unknown);
|
||||
case Xow_domain_type_.Tid_wikimedia: // ~{type}.wikimedia.org;
|
||||
int seg_0_tid = Xow_domain_type_.Get_type_as_tid(raw, 0, dot_0); // try to get "incubator", "meta", etc..
|
||||
if (seg_0_tid == Xow_domain_type_.Tid_null) {
|
||||
Xol_lang_itm wikimedia_lang = Xol_lang_itm_.Get_by_key_or_null(raw, 0, dot_0);
|
||||
return wikimedia_lang == null ? new_other(raw) : Xow_domain.new_(raw, Xow_domain_type_.Tid_wikimedia, wikimedia_lang.Key());
|
||||
}
|
||||
switch (seg_0_tid) {
|
||||
case Xow_domain_type_.Tid_commons: case Xow_domain_type_.Tid_species: case Xow_domain_type_.Tid_meta: case Xow_domain_type_.Tid_incubator:
|
||||
return Xow_domain.new_(raw, seg_0_tid, Xol_lang_itm_.Key__unknown); // NOTE: seg_tids must match wiki_tids; NOTE: lang_key is "en" (really, "multi" but making things easier)
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
case Xow_domain_type_.Tid_other:
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
}
|
||||
private static Xow_domain new_other(byte[] raw) {return Xow_domain.new_(raw, Xow_domain_type_.Tid_other, Xol_lang_itm_.Key__unknown);}
|
||||
private static byte[] Get_lang_code_for_mw_messages_file(byte[] v) {
|
||||
Object o = lang_to_gfs_hash.Get_by_bry(v);
|
||||
return o == null ? v : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry lang_to_gfs_hash = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
.Add_str_obj("simple" , Bry_.new_a7("en"))
|
||||
.Add_str_obj("zh-classical" , Bry_.new_a7("lzh"))
|
||||
.Add_str_obj("no" , Bry_.new_a7("nb"))
|
||||
;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_domain_fxt fxt = new Xow_domain_fxt();
|
||||
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , Xow_domain_type_.Tid_wikipedia);}
|
||||
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , Xow_domain_type_.Tid_wikipedia);}
|
||||
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , Xow_domain_type_.Tid_wiktionary);}
|
||||
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "lzh" , Xow_domain_type_.Tid_wikipedia);}
|
||||
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , Xow_domain_type_.Tid_commons);}
|
||||
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , Xow_domain_type_.Tid_species);}
|
||||
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , Xow_domain_type_.Tid_wikimedia);}
|
||||
@Test public void Parse_home() {fxt.Test_parse("home" , "" , Xow_domain_type_.Tid_home);}
|
||||
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , Xow_domain_type_.Tid_other);}
|
||||
}
|
||||
class Xow_domain_fxt {
|
||||
public void Clear() {}
|
||||
public void Test_parse(String domain, String expd_lang, int expd_tid) {
|
||||
Xow_domain actl = Xow_domain_.parse(Bry_.new_a7(domain));
|
||||
Tfds.Eq(expd_lang, String_.new_a7((actl.Lang_key())));
|
||||
Tfds.Eq(expd_tid, actl.Domain_tid());
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
public class Xow_domain_type_ {
|
||||
public static final int
|
||||
Tid_null = 0
|
||||
, Tid_wikipedia = 1
|
||||
, Tid_wiktionary = 2
|
||||
, Tid_wikisource = 3
|
||||
, Tid_wikivoyage = 4
|
||||
, Tid_wikiquote = 5
|
||||
, Tid_wikibooks = 6
|
||||
, Tid_wikiversity = 7
|
||||
, Tid_wikinews = 8
|
||||
, Tid_wikimedia = 9
|
||||
, Tid_species = 10
|
||||
, Tid_commons = 11
|
||||
, Tid_wikidata = 12
|
||||
, Tid_mediawiki = 13
|
||||
, Tid_meta = 14
|
||||
, Tid_incubator = 15
|
||||
, Tid_wmfblog = 16
|
||||
, Tid_home = 17
|
||||
, Tid_other = 18
|
||||
, Tid__len = 19
|
||||
;
|
||||
public static final String // SERIALIZED:xowa.gfs
|
||||
Key_str_wikipedia = "wikipedia"
|
||||
, Key_str_wiktionary = "wiktionary"
|
||||
, Key_str_wikisource = "wikisource"
|
||||
, Key_str_wikivoyage = "wikivoyage"
|
||||
, Key_str_wikiquote = "wikiquote"
|
||||
, Key_str_wikibooks = "wikibooks"
|
||||
, Key_str_wikiversity = "wikiversity"
|
||||
, Key_str_wikinews = "wikinews"
|
||||
, Key_str_wikimedia = "wikimedia"
|
||||
, Key_str_species = "species"
|
||||
, Key_str_commons = "commons"
|
||||
, Key_str_wikidata = "wikidata"
|
||||
, Key_str_mediawiki = "mediawiki"
|
||||
, Key_str_meta = "meta"
|
||||
, Key_str_incubator = "incubator"
|
||||
, Key_str_wmforg = "wikimediafoundation"
|
||||
, Key_str_home = "home"
|
||||
, Key_str_other = "other"
|
||||
;
|
||||
public static final byte[]
|
||||
Key_bry_wikipedia = Bry_.new_a7(Key_str_wikipedia)
|
||||
, Key_bry_wiktionary = Bry_.new_a7(Key_str_wiktionary)
|
||||
, Key_bry_wikisource = Bry_.new_a7(Key_str_wikisource)
|
||||
, Key_bry_wikivoyage = Bry_.new_a7(Key_str_wikivoyage)
|
||||
, Key_bry_wikiquote = Bry_.new_a7(Key_str_wikiquote)
|
||||
, Key_bry_wikibooks = Bry_.new_a7(Key_str_wikibooks)
|
||||
, Key_bry_wikiversity = Bry_.new_a7(Key_str_wikiversity)
|
||||
, Key_bry_wikinews = Bry_.new_a7(Key_str_wikinews)
|
||||
, Key_bry_wikimedia = Bry_.new_a7(Key_str_wikimedia)
|
||||
, Key_bry_species = Bry_.new_a7(Key_str_species)
|
||||
, Key_bry_commons = Bry_.new_a7(Key_str_commons)
|
||||
, Key_bry_wikidata = Bry_.new_a7(Key_str_wikidata)
|
||||
, Key_bry_mediawiki = Bry_.new_a7(Key_str_mediawiki)
|
||||
, Key_bry_meta = Bry_.new_a7(Key_str_meta)
|
||||
, Key_bry_incubator = Bry_.new_a7(Key_str_incubator)
|
||||
, Key_bry_wmforg = Bry_.new_a7(Key_str_wmforg)
|
||||
, Key_bry_home = Bry_.new_a7(Key_str_home)
|
||||
, Key_bry_other = Bry_.new_a7(Key_str_other)
|
||||
;
|
||||
private static final Xow_domain_type[] ary = new Xow_domain_type[Tid__len];
|
||||
private static final Hash_adp_bry type_regy = Hash_adp_bry.ci_a7(); // LOC:must go before new_()
|
||||
private static final Hash_adp_bry abrv_regy = Hash_adp_bry.cs(); // LOC:must go before new_()
|
||||
public static final Xow_domain_type
|
||||
Itm_wikipedia = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikipedia , Key_bry_wikipedia , "w" , ".wikipedia.org")
|
||||
, Itm_wiktionary = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wiktionary , Key_bry_wiktionary , "d" , ".wiktionary.org")
|
||||
, Itm_wikisource = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikisource , Key_bry_wikisource , "s" , ".wikisource.org")
|
||||
, Itm_wikivoyage = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikivoyage , Key_bry_wikivoyage , "v" , ".wikivoyage.org")
|
||||
, Itm_wikiquote = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikiquote , Key_bry_wikiquote , "q" , ".wikiquote.org")
|
||||
, Itm_wikibooks = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikibooks , Key_bry_wikibooks , "b" , ".wikibooks.org")
|
||||
, Itm_wikiversity = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikiversity , Key_bry_wikiversity , "u" , ".wikiversity.org")
|
||||
, Itm_wikinews = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikinews , Key_bry_wikinews , "n" , ".wikinews.org")
|
||||
, Itm_wikimedia = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikimedia , Key_bry_wikimedia , "m" , ".wikimedia.org")
|
||||
, Itm_species = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_species , Key_bry_species , "species" , Xow_domain_.Domain_str_species)
|
||||
, Itm_commons = new_(Bool_.N , Xow_domain_type_src_.Tid_wmf , Tid_commons , Key_bry_commons , "c" , Xow_domain_.Domain_str_commons)
|
||||
, Itm_wikidata = new_(Bool_.N , Xow_domain_type_src_.Tid_wmf , Tid_wikidata , Key_bry_wikidata , "wd" , Xow_domain_.Domain_str_wikidata)
|
||||
, Itm_mediawiki = new_(Bool_.N , Xow_domain_type_src_.Tid_wmf , Tid_mediawiki , Key_bry_mediawiki , "mw" , Xow_domain_.Domain_str_mediawiki)
|
||||
, Itm_meta = new_(Bool_.N , Xow_domain_type_src_.Tid_wmf , Tid_meta , Key_bry_meta , "meta" , Xow_domain_.Domain_str_meta)
|
||||
, Itm_incubator = new_(Bool_.N , Xow_domain_type_src_.Tid_wmf , Tid_incubator , Key_bry_incubator , "qb" , Xow_domain_.Domain_str_incubator)
|
||||
, Itm_wmforg = new_(Bool_.N , Xow_domain_type_src_.Tid_wmf , Tid_wmfblog , Key_bry_wmforg , "wmf" , Xow_domain_.Domain_str_wmforg)
|
||||
, Itm_home = new_(Bool_.N , Xow_domain_type_src_.Tid_xowa , Tid_home , Key_bry_home , "home" , Xow_domain_.Domain_str_home)
|
||||
, Itm_other = new_(Bool_.N , Xow_domain_type_src_.Tid_mw , Tid_other , Key_bry_other , "" , "")
|
||||
;
|
||||
private static Xow_domain_type new_(boolean multi_lang, int src, int tid, byte[] key_bry, String abrv_str, String domain_bry) {
|
||||
byte[] abrv_bry = Bry_.new_u8(abrv_str);
|
||||
Xow_domain_type rv = new Xow_domain_type(multi_lang, src, tid, key_bry, abrv_bry, Bry_.new_u8(domain_bry));
|
||||
ary[tid] = rv;
|
||||
type_regy.Add(key_bry , rv);
|
||||
abrv_regy.Add(abrv_bry , rv);
|
||||
return rv;
|
||||
}
|
||||
public static Xow_domain_type Get_abrv_as_itm(byte[] src, int bgn, int end) {
|
||||
return (Xow_domain_type)abrv_regy.Get_by_mid(src, bgn, end);
|
||||
}
|
||||
public static Xow_domain_type Get_type_as_itm(int tid) {return ary[tid];}
|
||||
public static byte[] Get_type_as_bry(int tid) {return ary[tid].Key_bry();}
|
||||
public static int Get_type_as_tid(byte[] src) {return Get_type_as_tid(src, 0, src.length);}
|
||||
public static int Get_type_as_tid(byte[] src, int bgn, int end) {
|
||||
Object o = type_regy.Get_by_mid(src, bgn, end);
|
||||
return o == null ? Xow_domain_type_.Tid_null : ((Xow_domain_type)o).Tid();
|
||||
}
|
||||
}
|
||||
class Xow_domain_type_src_ {
|
||||
public static final int
|
||||
Tid_wmf = 1 // administered by wmf; wikipedia, etc.
|
||||
, Tid_wikia = 2 // *.wikia.com
|
||||
, Tid_mw = 3 // mediawiki installations not part of wmf, wikia
|
||||
, Tid_xowa = 4 // xowa
|
||||
;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_wiki_abrv_ {
|
||||
public static boolean parse_(Xow_wiki_abrv rv, byte[] src, int bgn, int end) {
|
||||
rv.Clear();
|
||||
if (end - bgn == 0) return false; // empty bry
|
||||
Object o = trie.Match_bgn(src, end - 1, bgn - 1); if (o == null) return false;
|
||||
byte tid = ((Byte_obj_val)o).Val();
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key_or_intl(src, bgn, trie.Match_pos() + 1);
|
||||
rv.Ctor_by_parse(lang_itm, tid);
|
||||
return true;
|
||||
}
|
||||
public static final byte
|
||||
Tid_null = Xow_domain_type_.Tid_other
|
||||
, Tid_wikipedia = Xow_domain_type_.Tid_wikipedia
|
||||
, Tid_wiktionary = Xow_domain_type_.Tid_wiktionary
|
||||
, Tid_wikisource = Xow_domain_type_.Tid_wikisource
|
||||
, Tid_wikibooks = Xow_domain_type_.Tid_wikibooks
|
||||
, Tid_wikiversity = Xow_domain_type_.Tid_wikiversity
|
||||
, Tid_wikiquote = Xow_domain_type_.Tid_wikiquote
|
||||
, Tid_wikinews = Xow_domain_type_.Tid_wikinews
|
||||
, Tid_wikivoyage = Xow_domain_type_.Tid_wikivoyage
|
||||
, Tid_commons = Xow_domain_type_.Tid_commons
|
||||
, Tid_species = Xow_domain_type_.Tid_species
|
||||
, Tid_meta = Xow_domain_type_.Tid_meta
|
||||
, Tid_incubator = Xow_domain_type_.Tid_incubator
|
||||
, Tid_wikidata = Xow_domain_type_.Tid_wikidata
|
||||
, Tid_mediawiki = Xow_domain_type_.Tid_mediawiki
|
||||
, Tid_wmfblog = Xow_domain_type_.Tid_wmfblog
|
||||
;
|
||||
private static final Btrie_bwd_mgr trie = Init_trie();
|
||||
private static Btrie_bwd_mgr Init_trie() {
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
Init_trie_itm(rv, "wiki" , Tid_wikipedia);
|
||||
Init_trie_itm(rv, "wiktionary" , Tid_wiktionary);
|
||||
Init_trie_itm(rv, "wikisource" , Tid_wikisource);
|
||||
Init_trie_itm(rv, "wikibooks" , Tid_wikibooks);
|
||||
Init_trie_itm(rv, "wikiversity" , Tid_wikiversity);
|
||||
Init_trie_itm(rv, "wikiquote" , Tid_wikiquote);
|
||||
Init_trie_itm(rv, "wikinews" , Tid_wikinews);
|
||||
Init_trie_itm(rv, "wikivoyage" , Tid_wikivoyage);
|
||||
Init_trie_itm(rv, "commonswiki" , Tid_commons);
|
||||
Init_trie_itm(rv, "specieswiki" , Tid_species);
|
||||
Init_trie_itm(rv, "metawiki" , Tid_meta);
|
||||
Init_trie_itm(rv, "incubatorwiki" , Tid_incubator);
|
||||
Init_trie_itm(rv, "wikidatawiki" , Tid_wikidata);
|
||||
Init_trie_itm(rv, "mediawikiwiki" , Tid_mediawiki);
|
||||
Init_trie_itm(rv, "foundationwiki" , Tid_wmfblog);
|
||||
return rv;
|
||||
}
|
||||
private static void Init_trie_itm(Btrie_bwd_mgr rv, String abrv_name, byte abrv_tid) {
|
||||
rv.Add(abrv_name, Byte_obj_val.new_(abrv_tid));
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*;
|
||||
public class Xow_wiki_abrv_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_wiki_abrv_fxt fxt = new Xow_wiki_abrv_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Parse("foundationwiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_wmfblog);
|
||||
fxt.Parse("wikidatawiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_wikidata);
|
||||
fxt.Parse("mediawikiwiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_mediawiki);
|
||||
fxt.Parse("commonswiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_commons);
|
||||
fxt.Parse("specieswiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_species);
|
||||
fxt.Parse("metawiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_meta);
|
||||
fxt.Parse("incubatorwiki" , Xol_lang_itm_.Id__intl , Xow_wiki_abrv_.Tid_incubator);
|
||||
fxt.Parse("enwiki" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikipedia);
|
||||
fxt.Parse("enwiktionary" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wiktionary);
|
||||
fxt.Parse("enwikisource" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikisource);
|
||||
fxt.Parse("enwikibooks" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikibooks);
|
||||
fxt.Parse("enwikiversity" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikiversity);
|
||||
fxt.Parse("enwikiquote" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikiquote);
|
||||
fxt.Parse("enwikinews" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikinews);
|
||||
fxt.Parse("enwikivoyage" , Xol_lang_itm_.Id_en , Xow_wiki_abrv_.Tid_wikivoyage);
|
||||
fxt.Parse("frwiki" , Xol_lang_itm_.Id_fr , Xow_wiki_abrv_.Tid_wikipedia);
|
||||
fxt.Parse("unknown" , Xol_lang_itm_.Id__unknown , Xow_wiki_abrv_.Tid_null);
|
||||
}
|
||||
}
|
||||
class Xow_wiki_abrv_fxt {
|
||||
private Xow_wiki_abrv abrv = new Xow_wiki_abrv();
|
||||
public void Clear() {}
|
||||
public void Parse(String raw, int expd_lang_id, byte expd_domain_tid) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_wiki_abrv_.parse_(abrv, raw_bry, 0, raw_bry.length);
|
||||
Xol_lang_itm actl_lang_itm = abrv.Lang_itm();
|
||||
Tfds.Eq(expd_lang_id , actl_lang_itm == null ? Xol_lang_itm_.Id__unknown : actl_lang_itm.Id());
|
||||
Tfds.Eq(expd_domain_tid , abrv.Domain_tid());
|
||||
}
|
||||
}
|
||||
@@ -1,244 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
public class Xow_wiki_alias {
|
||||
public Io_url Fil() {return fil;} public Xow_wiki_alias Fil_(Io_url v) {fil = v; return this;} Io_url fil;
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Domain() {return domain;} private byte[] domain;
|
||||
public String Date() {return date;} private String date; // needs to be String to handle "latest"
|
||||
public Xow_wiki_alias Parse(String fil_name) {return Parse(Bry_.new_a7(fil_name));}
|
||||
public Xow_wiki_alias Parse(byte[] fil_name) {
|
||||
int fil_name_len = fil_name.length;
|
||||
int dash_0 = Bry_finder.Find_fwd(fil_name, Byte_ascii.Dash, 0 , fil_name_len); if (dash_0 == Bry_.NotFound) throw Err_.new_parse_type(Xow_wiki_alias.class, String_.new_u8(fil_name));
|
||||
int dash_1 = Bry_finder.Find_fwd(fil_name, Byte_ascii.Dash, dash_0 + 1 , fil_name_len); if (dash_1 == Bry_.NotFound) throw Err_.new_parse_type(Xow_wiki_alias.class, String_.new_u8(fil_name));
|
||||
domain = Parse__domain_name(fil_name, 0, dash_0);
|
||||
date = String_.new_a7(fil_name, dash_0 + 1, dash_1);
|
||||
tid = Parse__tid(fil_name, dash_1 + 1, fil_name_len);
|
||||
return this;
|
||||
}
|
||||
public static int Extract_lang(byte[] src) {
|
||||
if (alias_bry_trie == null) Init_aliases();
|
||||
Object o = alias_bry_trie.Match_bgn(src, src.length - 1, 0 - 1);
|
||||
return (o == null) ? -1 : alias_bry_trie.Match_pos();
|
||||
}
|
||||
public static byte[] Build_alias(Xow_domain wiki_type) {
|
||||
if (alias_bry_trie == null) Init_aliases();
|
||||
int tid = wiki_type.Domain_tid();
|
||||
byte[] alias = (byte[])alias_val_hash.Get_by(Int_obj_ref.new_(tid));
|
||||
if (alias == null) return null;
|
||||
switch (tid) {
|
||||
case Xow_domain_type_.Tid_commons:
|
||||
case Xow_domain_type_.Tid_species:
|
||||
case Xow_domain_type_.Tid_meta:
|
||||
case Xow_domain_type_.Tid_incubator:
|
||||
case Xow_domain_type_.Tid_wikidata:
|
||||
case Xow_domain_type_.Tid_mediawiki:
|
||||
case Xow_domain_type_.Tid_wmfblog:
|
||||
return alias;
|
||||
case Xow_domain_type_.Tid_wikipedia:
|
||||
case Xow_domain_type_.Tid_wiktionary:
|
||||
case Xow_domain_type_.Tid_wikisource:
|
||||
case Xow_domain_type_.Tid_wikibooks:
|
||||
case Xow_domain_type_.Tid_wikiversity:
|
||||
case Xow_domain_type_.Tid_wikiquote:
|
||||
case Xow_domain_type_.Tid_wikinews:
|
||||
case Xow_domain_type_.Tid_wikivoyage:
|
||||
case Xow_domain_type_.Tid_wikimedia:
|
||||
return Bry_.Add(wiki_type.Lang_orig_key(), alias);
|
||||
default:
|
||||
throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static byte[] Parse_wmf_key(byte[] src) {return Parse__domain_name(src, 0, src.length);}
|
||||
public static byte[] Parse__domain_name_null = null;
|
||||
public static byte[] Parse__domain_name(byte[] src, int bgn, int end) {
|
||||
if (end - bgn == 0) return null; // empty bry;
|
||||
if (alias_bry_trie == null) Init_aliases();
|
||||
Object o = alias_bry_trie.Match_bgn(src, end - 1, bgn - 1); if (o == null) return Parse__domain_name_null;
|
||||
int domain_tid = ((Int_obj_ref)o).Val();
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
switch (domain_tid) {
|
||||
case Domain_wikimediafoundation: return bfr.Add(Xow_domain_type_.Key_bry_wmforg).Add_byte(Byte_ascii.Dot).Add(Xow_domain_.Seg_bry_org).Xto_bry_and_clear();
|
||||
case Domain_wikidata:
|
||||
case Domain_mediawiki: return bfr.Add(Xow_domain_.Seg_bry_www).Add_byte(Byte_ascii.Dot).Add(Xow_domain_type_.Get_type_as_bry(domain_tid)).Add_byte(Byte_ascii.Dot).Add(Xow_domain_.Seg_bry_org).Xto_bry_and_clear();
|
||||
case Domain_commons:
|
||||
case Domain_species:
|
||||
case Domain_meta:
|
||||
case Domain_incubator: return bfr.Add(Xow_domain_type_.Get_type_as_bry(domain_tid)).Add_byte(Byte_ascii.Dot).Add(Xow_domain_type_.Key_bry_wikimedia).Add_byte(Byte_ascii.Dot).Add(Xow_domain_.Seg_bry_org).Xto_bry_and_clear();
|
||||
case Domain_wikipedia:
|
||||
case Domain_wiktionary:
|
||||
case Domain_wikisource:
|
||||
case Domain_wikibooks:
|
||||
case Domain_wikiversity:
|
||||
case Domain_wikiquote:
|
||||
case Domain_wikinews:
|
||||
case Domain_wikivoyage:
|
||||
case Domain_wikimedia:
|
||||
bfr.Add_mid(src, 0, alias_bry_trie.Match_pos() + 1);
|
||||
bfr.Add_byte(Byte_ascii.Dot);
|
||||
return bfr.Add(Xow_domain_type_.Get_type_as_bry(domain_tid)).Add_byte(Byte_ascii.Dot).Add(Xow_domain_.Seg_bry_org).Xto_bry_and_clear();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// TODO: swap out above with below
|
||||
// public byte[] Domain() {if (domain == null) domain = Domain_init(lang_itm, domain_tid); return domain;} private byte[] domain;
|
||||
// private static byte[] Domain_init(Xol_lang_itm lang_itm, byte domain_tid) {
|
||||
// switch (domain_tid) {
|
||||
// case Xow_wiki_abrv_.Tid_wmfblog: return Xow_domain_.Bry_wikimediafoundation;
|
||||
// case Xow_wiki_abrv_.Tid_wikidata: return Xow_domain_.Domain_bry_wikidata;
|
||||
// case Xow_wiki_abrv_.Tid_mediawiki: return Xow_domain_.Bry_mediawiki;
|
||||
// case Xow_wiki_abrv_.Tid_commons: return Xow_domain_.Domain_bry_commons;
|
||||
// case Xow_wiki_abrv_.Tid_species: return Xow_domain_.Bry_species;
|
||||
// case Xow_wiki_abrv_.Tid_meta: return Xow_domain_.Bry_meta;
|
||||
// case Xow_wiki_abrv_.Tid_incubator: return Xow_domain_.Bry_incubator;
|
||||
// case Xow_wiki_abrv_.Tid_wikipedia:
|
||||
// case Xow_wiki_abrv_.Tid_wiktionary:
|
||||
// case Xow_wiki_abrv_.Tid_wikisource:
|
||||
// case Xow_wiki_abrv_.Tid_wikibooks:
|
||||
// case Xow_wiki_abrv_.Tid_wikiversity:
|
||||
// case Xow_wiki_abrv_.Tid_wikiquote:
|
||||
// case Xow_wiki_abrv_.Tid_wikinews:
|
||||
// case Xow_wiki_abrv_.Tid_wikivoyage:
|
||||
// return Bry_.Add
|
||||
// ( lang_itm.Key() // en
|
||||
// , Byte_ascii.Dot_bry // .
|
||||
// , Xow_domain_type_.Get_type_as_bry(domain_tid) // wikipedia
|
||||
// , Byte_ascii.Dot_bry // .
|
||||
// , Xow_domain_.Seg_bry_org // org
|
||||
// );
|
||||
// default:
|
||||
// return Bry_.Empty;
|
||||
// }
|
||||
// }
|
||||
public static byte Parse__tid(String src) {return Parse__tid(Bry_.new_u8(src));}
|
||||
public static byte Parse__tid(byte[] src) {return Parse__tid(src, 0, src.length);}
|
||||
public static byte Parse__tid(byte[] src, int bgn, int end) {
|
||||
if (tid_bry_trie == null) Init_tids();
|
||||
Object o = tid_bry_trie.Match_bgn(src, bgn, end); if (o == null) throw Err_.new_parse_type(Xow_wiki_alias.class, String_.new_u8(src));
|
||||
return ((Byte_obj_ref)o).Val();
|
||||
}
|
||||
public static void Build_alias_by_lang_tid(Bry_bfr bfr, byte[] lang_key, Int_obj_ref wiki_tid) {
|
||||
if (alias_bry_trie == null) Init_aliases();
|
||||
byte[] domain_suffix = (byte[])alias_val_hash.Get_by(wiki_tid);
|
||||
if (domain_suffix == null) return;
|
||||
switch (wiki_tid.Val()) {
|
||||
case Xow_domain_type_.Tid_commons:
|
||||
case Xow_domain_type_.Tid_species:
|
||||
case Xow_domain_type_.Tid_meta:
|
||||
case Xow_domain_type_.Tid_incubator:
|
||||
case Xow_domain_type_.Tid_wikidata:
|
||||
case Xow_domain_type_.Tid_mediawiki:
|
||||
case Xow_domain_type_.Tid_wmfblog:
|
||||
bfr.Add(domain_suffix);
|
||||
break;
|
||||
case Xow_domain_type_.Tid_other:
|
||||
break;
|
||||
default:
|
||||
bfr.Add(lang_key).Add(domain_suffix);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static Xow_domain parse_by_wmf_key(byte[] wmf_key) {
|
||||
if (Bry_.Has(wmf_key, Byte_ascii.Underline)) // convert "_" to "-"; note that wmf_keys have a strict format of langtype; EX: "zh_yuewiki"; DATE:2014-10-06
|
||||
wmf_key = Bry_.Replace_create(wmf_key, Byte_ascii.Underline, Byte_ascii.Dash);
|
||||
byte[] domain_bry = Parse__domain_name(wmf_key, 0, wmf_key.length);
|
||||
Xow_domain rv = Xow_domain_.parse(domain_bry);
|
||||
rv.Abrv_wm_(wmf_key);
|
||||
return rv;
|
||||
}
|
||||
public static final byte Tid_null = 0, Tid_pages_articles = 1, Tid_pages_meta_current = 2, Tid_categorylinks = 3, Tid_page_props = 4, Tid_image = 5;
|
||||
public static final String Key_null = ""
|
||||
, Key_pages_articles = "pages-articles", Key_pages_meta_current = "pages-meta-current"
|
||||
, Key_categorylinks = "categorylinks", Key_page_props = "page_props"
|
||||
, Key_image = "image"
|
||||
;
|
||||
private static final byte
|
||||
Domain_wikipedia = Xow_domain_type_.Tid_wikipedia
|
||||
, Domain_wiktionary = Xow_domain_type_.Tid_wiktionary
|
||||
, Domain_wikisource = Xow_domain_type_.Tid_wikisource
|
||||
, Domain_wikibooks = Xow_domain_type_.Tid_wikibooks
|
||||
, Domain_wikiversity = Xow_domain_type_.Tid_wikiversity
|
||||
, Domain_wikiquote = Xow_domain_type_.Tid_wikiquote
|
||||
, Domain_wikinews = Xow_domain_type_.Tid_wikinews
|
||||
, Domain_wikivoyage = Xow_domain_type_.Tid_wikivoyage
|
||||
, Domain_wikimedia = Xow_domain_type_.Tid_wikimedia
|
||||
, Domain_commons = Xow_domain_type_.Tid_commons
|
||||
, Domain_species = Xow_domain_type_.Tid_species
|
||||
, Domain_meta = Xow_domain_type_.Tid_meta
|
||||
, Domain_incubator = Xow_domain_type_.Tid_incubator
|
||||
, Domain_wikidata = Xow_domain_type_.Tid_wikidata
|
||||
, Domain_mediawiki = Xow_domain_type_.Tid_mediawiki
|
||||
, Domain_wikimediafoundation = Xow_domain_type_.Tid_wmfblog;
|
||||
private static void Init_aliases() {
|
||||
alias_bry_trie = new Btrie_bwd_mgr(false);
|
||||
alias_val_hash = Hash_adp_.new_();
|
||||
Init_alias("wiki" , Domain_wikipedia);
|
||||
Init_alias("wiktionary" , Domain_wiktionary);
|
||||
Init_alias("wikisource" , Domain_wikisource);
|
||||
Init_alias("wikibooks" , Domain_wikibooks);
|
||||
Init_alias("wikiversity" , Domain_wikiversity);
|
||||
Init_alias("wikiquote" , Domain_wikiquote);
|
||||
Init_alias("wikinews" , Domain_wikinews);
|
||||
Init_alias("wikivoyage" , Domain_wikivoyage);
|
||||
Init_alias("wikimedia" , Domain_wikimedia);
|
||||
Init_alias("commonswiki" , Domain_commons);
|
||||
Init_alias("specieswiki" , Domain_species);
|
||||
Init_alias("metawiki" , Domain_meta);
|
||||
Init_alias("incubatorwiki" , Domain_incubator);
|
||||
Init_alias("wikidatawiki" , Domain_wikidata);
|
||||
Init_alias("mediawikiwiki" , Domain_mediawiki);
|
||||
Init_alias("foundationwiki" , Domain_wikimediafoundation);
|
||||
}
|
||||
private static void Init_alias(String alias_str, byte domain) {
|
||||
byte[] alias_bry = Bry_.new_a7(alias_str);
|
||||
Int_obj_ref domain_bval = Int_obj_ref.new_(domain);
|
||||
alias_bry_trie.Add(alias_bry, domain_bval);
|
||||
alias_val_hash.Add(domain_bval, alias_bry);
|
||||
}
|
||||
private static void Init_tids() {
|
||||
tid_bry_trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en
|
||||
tid_val_hash = Hash_adp_.new_();
|
||||
Init_tid(Key_pages_articles , Tid_pages_articles);
|
||||
Init_tid(Key_pages_meta_current , Tid_pages_meta_current);
|
||||
Init_tid(Key_categorylinks , Tid_categorylinks);
|
||||
Init_tid(Key_page_props , Tid_page_props);
|
||||
Init_tid(Key_image , Tid_image);
|
||||
}
|
||||
public static String Tid_to_str(byte v) {
|
||||
switch (v) {
|
||||
case Tid_pages_articles : return Key_pages_articles;
|
||||
case Tid_pages_meta_current : return Key_pages_meta_current;
|
||||
case Tid_categorylinks : return Key_categorylinks;
|
||||
case Tid_page_props : return Key_page_props;
|
||||
case Tid_image : return Key_image;
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
private static void Init_tid(String tid_str, byte tid) {
|
||||
byte[] tid_bry = Bry_.new_a7(tid_str);
|
||||
Byte_obj_ref tid_val = Byte_obj_ref.new_(tid);
|
||||
tid_bry_trie.Add_obj(tid_bry, tid_val);
|
||||
tid_val_hash.Add(tid_val, tid_bry);
|
||||
}
|
||||
private static Hash_adp alias_val_hash;
|
||||
private static Btrie_bwd_mgr alias_bry_trie;
|
||||
private static Hash_adp tid_val_hash;
|
||||
private static Btrie_slim_mgr tid_bry_trie;
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_wiki_alias_tst {
|
||||
Xow_wiki_alias_fxt fxt = new Xow_wiki_alias_fxt();
|
||||
@Test public void Parse() {fxt.Parse("enwiki-20121201-pages-articles.xml.bz2", "en.wikipedia.org", "20121201", Xow_wiki_alias.Tid_pages_articles);}
|
||||
@Test public void Parse__domain_name() {
|
||||
fxt.Parse__domain_name("foundationwiki" , "wikimediafoundation.org");
|
||||
fxt.Parse__domain_name("wikidatawiki" , "www.wikidata.org");
|
||||
fxt.Parse__domain_name("mediawikiwiki" , "www.mediawiki.org");
|
||||
fxt.Parse__domain_name("commonswiki" , "commons.wikimedia.org");
|
||||
fxt.Parse__domain_name("specieswiki" , "species.wikimedia.org");
|
||||
fxt.Parse__domain_name("metawiki" , "meta.wikimedia.org");
|
||||
fxt.Parse__domain_name("incubatorwiki" , "incubator.wikimedia.org");
|
||||
fxt.Parse__domain_name("enwiki" , "en.wikipedia.org");
|
||||
fxt.Parse__domain_name("enwiktionary" , "en.wiktionary.org");
|
||||
fxt.Parse__domain_name("enwikisource" , "en.wikisource.org");
|
||||
fxt.Parse__domain_name("enwikibooks" , "en.wikibooks.org");
|
||||
fxt.Parse__domain_name("enwikiversity" , "en.wikiversity.org");
|
||||
fxt.Parse__domain_name("enwikiquote" , "en.wikiquote.org");
|
||||
fxt.Parse__domain_name("enwikinews" , "en.wikinews.org");
|
||||
fxt.Parse__domain_name("enwikivoyage" , "en.wikivoyage.org");
|
||||
fxt.Parse__domain_name("plwikimedia" , "pl.wikimedia.org");
|
||||
}
|
||||
@Test public void Parse__tid() {
|
||||
fxt.Parse__tid("pages-articles.xml" , Xow_wiki_alias.Tid_pages_articles);
|
||||
fxt.Parse__tid("pages-meta-current.xml" , Xow_wiki_alias.Tid_pages_meta_current);
|
||||
}
|
||||
@Test public void Build_alias() {
|
||||
fxt.Build_alias("simple.wikipedia.org", "simplewiki");
|
||||
fxt.Build_alias("en.wikipedia.org", "enwiki");
|
||||
fxt.Build_alias("commons.wikimedia.org", "commonswiki");
|
||||
}
|
||||
@Test public void Build_wmf_src_dir() {
|
||||
fxt.Build_wmf_src_dir("simplewiki", "latest", "http://dumps.wikimedia.your.org/simplewiki/latest/");
|
||||
}
|
||||
@Test public void Build_wmf_src_name() {
|
||||
fxt.Build_wmf_src_name("simplewiki", "latest", Xow_wiki_alias.Key_pages_articles, "simplewiki-latest-pages-articles.xml.bz2");
|
||||
}
|
||||
@Test public void Build_alias_by_lang_tid() {
|
||||
fxt.Build_alias_by_lang_tid("en", Xow_domain_type_.Tid_wikipedia, "enwiki");
|
||||
}
|
||||
@Test public void Parse_by_wmf_key() {
|
||||
fxt.Test_parse_by_wmf_key("enwiki", "en", "en.wikipedia.org");
|
||||
fxt.Test_parse_by_wmf_key("zh_yuewiki", "zh-yue", "zh-yue.wikipedia.org");
|
||||
}
|
||||
}
|
||||
class Xow_wiki_alias_fxt {
|
||||
Xow_wiki_alias file = new Xow_wiki_alias();
|
||||
public void Parse(String name, String domain, String date, byte tid) {
|
||||
Io_url fil = Io_url_.mem_fil_("mem/xowa/temp/" + name);
|
||||
file.Fil_(fil).Parse(fil.NameOnly());
|
||||
Tfds.Eq(domain , String_.new_a7(file.Domain()));
|
||||
Tfds.Eq(date , file.Date());
|
||||
Tfds.Eq(tid , file.Tid());
|
||||
}
|
||||
public void Parse__domain_name(String raw_str, String expd) {byte[] raw = Bry_.new_a7(raw_str); Tfds.Eq(expd, String_.new_a7(Xow_wiki_alias.Parse__domain_name(raw, 0, raw.length)));}
|
||||
public void Parse__tid(String raw_str, byte expd) {Tfds.Eq(expd, Xow_wiki_alias.Parse__tid(raw_str));}
|
||||
public void Build_alias(String domain_str, String expd) {
|
||||
Xow_domain domain = Xow_domain_.parse(Bry_.new_a7(domain_str));
|
||||
byte[] actl = Xow_wiki_alias.Build_alias(domain);
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
} private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public void Build_wmf_src_dir(String alias, String date, String expd) {
|
||||
byte[] actl = Xob_dump_file_.Bld_dump_dir_url(Bry_.new_a7(Xob_dump_file_.Server_your_org), Bry_.new_a7(alias), Bry_.new_a7(date));
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Build_wmf_src_name(String alias, String date, String dump_type, String expd) {
|
||||
byte[] actl = Xob_dump_file_.Bld_dump_file_name(Bry_.new_a7(alias), Bry_.new_a7(date), Bry_.new_a7(dump_type), Xob_dump_file_.Ext_xml_bz2);
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Build_alias_by_lang_tid(String lang_key, int wiki_tid, String expd) {
|
||||
Xow_wiki_alias.Build_alias_by_lang_tid(tmp_bfr, Bry_.new_a7(lang_key), wiki_tid_ref.Val_(wiki_tid));
|
||||
Tfds.Eq_bry(Bry_.new_u8(expd), tmp_bfr.Xto_bry_and_clear());
|
||||
} static final Int_obj_ref wiki_tid_ref = Int_obj_ref.zero_();
|
||||
public void Test_parse_by_wmf_key(String wmf_key, String expd_lang_key, String expd_domain) {
|
||||
Xow_domain domain = Xow_wiki_alias.parse_by_wmf_key(Bry_.new_a7(wmf_key));
|
||||
Tfds.Eq(expd_lang_key , String_.new_a7(domain.Lang_key()));
|
||||
Tfds.Eq(expd_domain , String_.new_a7(domain.Domain_bry()));
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.xowa.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.bldrs.infos.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Xowd_db_mgr {
|
||||
private Xowd_db_file[] dbs__ary = new Xowd_db_file[0]; private int dbs__ary_len = 0; private final Xowd_db_file_hash db_file_hash = new Xowd_db_file_hash();
|
||||
private final Xow_wiki wiki; private final Io_url wiki_root_dir; private final Xow_domain domain_itm;
|
||||
public Xowd_db_mgr(Xow_wiki wiki, Io_url wiki_root_dir, Xow_domain domain_itm) {this.wiki = wiki; this.wiki_root_dir = wiki_root_dir; this.domain_itm = domain_itm;}
|
||||
private final Xow_wiki wiki; private final Io_url wiki_root_dir; private final Xow_domain_itm domain_itm;
|
||||
public Xowd_db_mgr(Xow_wiki wiki, Io_url wiki_root_dir, Xow_domain_itm domain_itm) {this.wiki = wiki; this.wiki_root_dir = wiki_root_dir; this.domain_itm = domain_itm;}
|
||||
public Xowd_core_db_props Props() {return props;} private Xowd_core_db_props props = Xowd_core_db_props.Test;
|
||||
public Db_cfg_tbl Tbl__cfg() {return db__core.Tbl__cfg();}
|
||||
public Xowd_page_tbl Tbl__page() {return db__core.Tbl__page();}
|
||||
|
||||
31
400_xowa/src/gplx/xowa/wikis/domains/Xow_abrv_wm.java
Normal file
31
400_xowa/src/gplx/xowa/wikis/domains/Xow_abrv_wm.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.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm {
|
||||
public Xow_abrv_wm(byte[] raw, byte[] lang_domain, Xol_lang_itm lang_actl, int domain_type) {
|
||||
this.raw = raw;
|
||||
this.lang_domain = lang_domain;
|
||||
this.lang_actl = lang_actl;
|
||||
this.domain_type = domain_type;
|
||||
}
|
||||
public byte[] Raw() {return raw;} private final byte[] raw;
|
||||
public byte[] Lang_domain() {return lang_domain;} private final byte[] lang_domain;
|
||||
public Xol_lang_itm Lang_actl() {return lang_actl;} private final Xol_lang_itm lang_actl;
|
||||
public int Domain_type() {return domain_type;} private final int domain_type;
|
||||
}
|
||||
178
400_xowa/src/gplx/xowa/wikis/domains/Xow_abrv_wm_.java
Normal file
178
400_xowa/src/gplx/xowa/wikis/domains/Xow_abrv_wm_.java
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
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.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm_ {
|
||||
public static Xow_abrv_wm Parse_to_abrv_or_null(byte[] src) { // EX: parse "enwiki" to abrv_itm
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return null; // empty bry
|
||||
Object o = bry_trie.Match_bgn(src, src_len - 1, -1); if (o == null) return null;
|
||||
Xow_abrv_wm rv = Xow_abrv_wm_override.To_abrv_itm_or_null(src); if (rv != null) return rv;
|
||||
int domain_type = ((Int_obj_ref)o).Val();
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key_or_intl(src, 0, bry_trie.Match_pos() + 1);
|
||||
return new Xow_abrv_wm(src, lang_itm.Key(), lang_itm, domain_type);
|
||||
}
|
||||
public static Xow_domain_itm Parse_to_domain_itm(byte[] src) { // EX: parse "enwiki" to "en.wikipedia.org" itm
|
||||
if (Bry_.Has(src, Byte_ascii.Underline)) // convert "_" to "-"; note that wmf_keys have a strict format of langtype; EX: "zh_yuewiki"; DATE:2014-10-06
|
||||
src = Bry_.Replace_create(src, Byte_ascii.Underline, Byte_ascii.Dash);
|
||||
return Xow_domain_itm_.parse(Xow_abrv_wm_.Parse_to_domain_bry(src));
|
||||
}
|
||||
public static byte[] Parse_to_domain_bry(byte[] src) { // EX: parse "enwiki" to en.wikipedia.org
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return null; // empty bry
|
||||
Object o = bry_trie.Match_bgn(src, src_len - 1, - 1); if (o == null) return null;
|
||||
int domain_type = -1;
|
||||
byte[] lang = null;
|
||||
Xow_abrv_wm rv = Xow_abrv_wm_override.To_abrv_itm_or_null(src);
|
||||
if (rv != null) {
|
||||
lang = rv.Lang_domain();
|
||||
domain_type = rv.Domain_type();
|
||||
}
|
||||
else {
|
||||
domain_type = ((Int_obj_ref)o).Val();
|
||||
}
|
||||
switch (domain_type) {
|
||||
case Xow_domain_type_.Int__wmfblog: return Xow_domain_itm_.Bry__wmforg;
|
||||
case Xow_domain_type_.Int__wikidata: return Xow_domain_itm_.Bry__wikidata;
|
||||
case Xow_domain_type_.Int__mediawiki: return Xow_domain_itm_.Bry__mediawiki;
|
||||
case Xow_domain_type_.Int__commons: return Xow_domain_itm_.Bry__commons;
|
||||
case Xow_domain_type_.Int__species: return Xow_domain_itm_.Bry__species;
|
||||
case Xow_domain_type_.Int__meta: return Xow_domain_itm_.Bry__meta;
|
||||
case Xow_domain_type_.Int__incubator: return Xow_domain_itm_.Bry__incubator;
|
||||
case Xow_domain_type_.Int__wikipedia:
|
||||
case Xow_domain_type_.Int__wiktionary:
|
||||
case Xow_domain_type_.Int__wikisource:
|
||||
case Xow_domain_type_.Int__wikibooks:
|
||||
case Xow_domain_type_.Int__wikiversity:
|
||||
case Xow_domain_type_.Int__wikiquote:
|
||||
case Xow_domain_type_.Int__wikinews:
|
||||
case Xow_domain_type_.Int__wikivoyage:
|
||||
case Xow_domain_type_.Int__wikimedia:
|
||||
if (lang == null) {
|
||||
lang = Bry_.Mid(src, 0, bry_trie.Match_pos() + 1); // en
|
||||
if (Bry_.Has(lang, Byte_ascii.Underline)) // convert "_" to "-"; note that wmf_keys have a strict format of langtype; EX: "zh_yuewiki"; DATE:2014-10-06
|
||||
lang = Bry_.Replace_create(lang, Byte_ascii.Underline, Byte_ascii.Dash);
|
||||
}
|
||||
return Bry_.Add
|
||||
( lang
|
||||
, Byte_ascii.Dot_bry // .
|
||||
, Xow_domain_type_.Get_type_as_bry(domain_type) // wikipedia
|
||||
, Byte_ascii.Dot_bry // .
|
||||
, Xow_domain_itm_.Seg__org // org
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void To_abrv(Bry_bfr bfr, byte[] lang_key, Int_obj_ref domain_type) {
|
||||
byte[] suffix_bry = (byte[])int_hash.Get_by(domain_type); if (suffix_bry == null) return;
|
||||
switch (domain_type.Val()) {
|
||||
case Xow_domain_type_.Int__commons:
|
||||
case Xow_domain_type_.Int__species:
|
||||
case Xow_domain_type_.Int__meta:
|
||||
case Xow_domain_type_.Int__incubator:
|
||||
case Xow_domain_type_.Int__wikidata:
|
||||
case Xow_domain_type_.Int__mediawiki:
|
||||
case Xow_domain_type_.Int__wmfblog: bfr.Add(suffix_bry); break;
|
||||
case Xow_domain_type_.Int__other: break;
|
||||
default: bfr.Add(lang_key).Add(suffix_bry); break;
|
||||
}
|
||||
}
|
||||
public static byte[] To_abrv(Xow_domain_itm domain_itm) {
|
||||
int tid = domain_itm.Domain_type_id();
|
||||
byte[] suffix = (byte[])int_hash.Get_by(Int_obj_ref.new_(tid)); if (suffix == null) return null;
|
||||
switch (tid) {
|
||||
case Xow_domain_type_.Int__commons:
|
||||
case Xow_domain_type_.Int__species:
|
||||
case Xow_domain_type_.Int__meta:
|
||||
case Xow_domain_type_.Int__incubator:
|
||||
case Xow_domain_type_.Int__wikidata:
|
||||
case Xow_domain_type_.Int__mediawiki:
|
||||
case Xow_domain_type_.Int__wmfblog: return suffix;
|
||||
case Xow_domain_type_.Int__wikipedia:
|
||||
case Xow_domain_type_.Int__wiktionary:
|
||||
case Xow_domain_type_.Int__wikisource:
|
||||
case Xow_domain_type_.Int__wikibooks:
|
||||
case Xow_domain_type_.Int__wikiversity:
|
||||
case Xow_domain_type_.Int__wikiquote:
|
||||
case Xow_domain_type_.Int__wikinews:
|
||||
case Xow_domain_type_.Int__wikivoyage:
|
||||
case Xow_domain_type_.Int__wikimedia: return Bry_.Add(domain_itm.Lang_orig_key(), suffix);
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
private static final Btrie_bwd_mgr bry_trie = Init_trie();
|
||||
private static Hash_adp int_hash;
|
||||
private static Btrie_bwd_mgr Init_trie() {
|
||||
int_hash = Hash_adp_.new_();
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
Init_trie_itm(rv, int_hash, "wiki" , Xow_domain_type_.Int__wikipedia);
|
||||
Init_trie_itm(rv, int_hash, "wiktionary" , Xow_domain_type_.Int__wiktionary);
|
||||
Init_trie_itm(rv, int_hash, "wikisource" , Xow_domain_type_.Int__wikisource);
|
||||
Init_trie_itm(rv, int_hash, "wikibooks" , Xow_domain_type_.Int__wikibooks);
|
||||
Init_trie_itm(rv, int_hash, "wikiversity" , Xow_domain_type_.Int__wikiversity);
|
||||
Init_trie_itm(rv, int_hash, "wikiquote" , Xow_domain_type_.Int__wikiquote);
|
||||
Init_trie_itm(rv, int_hash, "wikinews" , Xow_domain_type_.Int__wikinews);
|
||||
Init_trie_itm(rv, int_hash, "wikivoyage" , Xow_domain_type_.Int__wikivoyage);
|
||||
Init_trie_itm(rv, int_hash, "wikimedia" , Xow_domain_type_.Int__wikimedia);
|
||||
Init_trie_itm(rv, int_hash, "commonswiki" , Xow_domain_type_.Int__commons);
|
||||
Init_trie_itm(rv, int_hash, "specieswiki" , Xow_domain_type_.Int__species);
|
||||
Init_trie_itm(rv, int_hash, "metawiki" , Xow_domain_type_.Int__meta);
|
||||
Init_trie_itm(rv, int_hash, "incubatorwiki" , Xow_domain_type_.Int__incubator);
|
||||
Init_trie_itm(rv, int_hash, "wikidatawiki" , Xow_domain_type_.Int__wikidata);
|
||||
Init_trie_itm(rv, int_hash, "mediawikiwiki" , Xow_domain_type_.Int__mediawiki);
|
||||
Init_trie_itm(rv, int_hash, "foundationwiki" , Xow_domain_type_.Int__wmfblog);
|
||||
return rv;
|
||||
}
|
||||
private static void Init_trie_itm(Btrie_bwd_mgr trie, Hash_adp hash, String str, int tid) {
|
||||
Int_obj_ref itm = Int_obj_ref.new_(tid);
|
||||
trie.Add(str, itm);
|
||||
hash.Add(itm, Bry_.new_u8(str));
|
||||
}
|
||||
}
|
||||
class Xow_abrv_wm_override {
|
||||
public static Xow_abrv_wm To_abrv_itm_or_null(byte[] abrv) {
|
||||
Object o = itm_hash.Get_by_bry(abrv);
|
||||
return o == null ? null : (Xow_abrv_wm)o;
|
||||
}
|
||||
public static byte[] To_lang_key_or_null(byte[] domain_bry) {
|
||||
Object o = lang_hash.Get_by_bry(domain_bry);
|
||||
return o == null ? null : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry itm_hash = itm_hash__make();
|
||||
private static Hash_adp_bry lang_hash;
|
||||
private static Hash_adp_bry itm_hash__make() {
|
||||
Hash_adp_bry rv = Hash_adp_bry.cs();
|
||||
lang_hash = Hash_adp_bry.cs();
|
||||
itm_hash__add(rv, lang_hash, "ar.wikimedia.org", "arwikimedia", "ar", Xol_lang_itm_.Id_es, Xow_domain_type_.Int__wikimedia); // NOTE: ar means Argentina not Arabic
|
||||
itm_hash__add(rv, lang_hash, "br.wikimedia.org", "brwikimedia", "br", Xol_lang_itm_.Id_es, Xow_domain_type_.Int__wikimedia); // NOTE: br means Brazil not Breto
|
||||
itm_hash__add(rv, lang_hash, "co.wikimedia.org", "cowikimedia", "co", Xol_lang_itm_.Id_es, Xow_domain_type_.Int__wikimedia); // NOTE: co means Columbia not Corsican
|
||||
itm_hash__add(rv, lang_hash, "ua.wikimedia.org", "ukwikimedia", "ua", Xol_lang_itm_.Id_uk, Xow_domain_type_.Int__wikimedia); // NOTE: ua means Ukrainian; NOTE: uk does not means United Kingdom (which redirects to https://wikimedia.org.uk)
|
||||
itm_hash__add(rv, lang_hash, "ca.wikimedia.org", "cawikimedia", "ca", Xol_lang_itm_.Id_en, Xow_domain_type_.Int__wikimedia); // NOTE: ca means Canada not Catalan
|
||||
itm_hash__add(rv, lang_hash, "be.wikimedia.org", "bewikimedia", "be", Xol_lang_itm_.Id_en, Xow_domain_type_.Int__wikimedia); // NOTE: be means Belgium not Belarusian
|
||||
itm_hash__add(rv, lang_hash, "se.wikimedia.org", "sewikimedia", "se", Xol_lang_itm_.Id_sv, Xow_domain_type_.Int__wikimedia); // NOTE: se means Swedish not Northern Sami
|
||||
return rv;
|
||||
}
|
||||
private static void itm_hash__add(Hash_adp_bry hash, Hash_adp_bry lang_hash, String domain, String raw, String lang_domain, int lang_actl, int domain_type) {
|
||||
byte[] abrv_bry = Bry_.new_u8(raw);
|
||||
Xol_lang_itm lang_actl_itm = Xol_lang_itm_.Get_by_id(lang_actl);
|
||||
Xow_abrv_wm itm = new Xow_abrv_wm(abrv_bry, Bry_.new_a7(lang_domain), lang_actl_itm, domain_type);
|
||||
hash.Add_bry_obj(abrv_bry, itm);
|
||||
lang_hash.Add_str_obj(domain, lang_actl_itm.Key());
|
||||
}
|
||||
}
|
||||
96
400_xowa/src/gplx/xowa/wikis/domains/Xow_abrv_wm_tst.java
Normal file
96
400_xowa/src/gplx/xowa/wikis/domains/Xow_abrv_wm_tst.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm_tst {
|
||||
private Xow_abrv_wm_fxt fxt = new Xow_abrv_wm_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Test_parse("foundationwiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__wmfblog);
|
||||
fxt.Test_parse("wikidatawiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__wikidata);
|
||||
fxt.Test_parse("mediawikiwiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__mediawiki);
|
||||
fxt.Test_parse("commonswiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__commons);
|
||||
fxt.Test_parse("specieswiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__species);
|
||||
fxt.Test_parse("metawiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__meta);
|
||||
fxt.Test_parse("incubatorwiki" , Xol_lang_itm_.Id__intl , Xow_domain_type_.Int__incubator);
|
||||
fxt.Test_parse("enwiki" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikipedia);
|
||||
fxt.Test_parse("enwiktionary" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wiktionary);
|
||||
fxt.Test_parse("enwikisource" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikisource);
|
||||
fxt.Test_parse("enwikibooks" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikibooks);
|
||||
fxt.Test_parse("enwikiversity" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikiversity);
|
||||
fxt.Test_parse("enwikiquote" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikiquote);
|
||||
fxt.Test_parse("enwikinews" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikinews);
|
||||
fxt.Test_parse("enwikivoyage" , Xol_lang_itm_.Id_en , Xow_domain_type_.Int__wikivoyage);
|
||||
fxt.Test_parse("frwiki" , Xol_lang_itm_.Id_fr , Xow_domain_type_.Int__wikipedia);
|
||||
fxt.Test_parse_null("unknown");
|
||||
fxt.Test_parse("plwikimedia" , Xol_lang_itm_.Id_pl , Xow_domain_type_.Int__wikimedia);
|
||||
}
|
||||
@Test public void Parse_override() {
|
||||
fxt.Test_parse("arwikimedia" , Xol_lang_itm_.Id_es , Xow_domain_type_.Int__wikimedia);
|
||||
fxt.Test_parse("ukwikimedia" , Xol_lang_itm_.Id_uk , Xow_domain_type_.Int__wikimedia);
|
||||
}
|
||||
@Test public void To_domain_itm() {
|
||||
fxt.Test_to_domain_itm("enwiki" , "en" , "en.wikipedia.org");
|
||||
fxt.Test_to_domain_itm("zh_yuewiki" , "zh-yue" , "zh-yue.wikipedia.org");
|
||||
}
|
||||
@Test public void To_domain_bry() {
|
||||
fxt.Test_to_domain_bry("enwiki" , "en.wikipedia.org");
|
||||
fxt.Test_to_domain_bry("zh_yuewiki" , "zh-yue.wikipedia.org");
|
||||
fxt.Test_to_domain_bry("arwikimedia", "ar.wikimedia.org");
|
||||
fxt.Test_to_domain_bry("ukwikimedia", "ua.wikimedia.org");
|
||||
}
|
||||
@Test public void To_abrv() {
|
||||
fxt.Test_to_abrv("simple.wikipedia.org" , "simplewiki");
|
||||
fxt.Test_to_abrv("en.wikipedia.org" , "enwiki");
|
||||
fxt.Test_to_abrv("commons.wikimedia.org" , "commonswiki");
|
||||
}
|
||||
@Test public void To_abrv_by_lang() {
|
||||
fxt.Test_to_abrv_by_lang("en", Xow_domain_type_.Int__wikipedia, "enwiki");
|
||||
}
|
||||
}
|
||||
class Xow_abrv_wm_fxt {
|
||||
public void Test_parse(String raw, int expd_lang_id, int expd_domain_tid) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
|
||||
Xol_lang_itm actl_lang_itm = abrv.Lang_actl();
|
||||
Tfds.Eq(expd_lang_id , actl_lang_itm == null ? Xol_lang_itm_.Id__unknown : actl_lang_itm.Id());
|
||||
Tfds.Eq(expd_domain_tid , abrv.Domain_type());
|
||||
}
|
||||
public void Test_parse_null(String raw) {
|
||||
byte[] raw_bry = Bry_.new_a7(raw);
|
||||
Xow_abrv_wm abrv = Xow_abrv_wm_.Parse_to_abrv_or_null(raw_bry);
|
||||
Tfds.Eq_true(abrv == null);
|
||||
}
|
||||
public void Test_to_abrv(String domain_str, String expd) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_a7(domain_str));
|
||||
byte[] actl = Xow_abrv_wm_.To_abrv(domain);
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
public void Test_to_abrv_by_lang(String lang_key, int wiki_tid, String expd) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
Xow_abrv_wm_.To_abrv(tmp_bfr, Bry_.new_a7(lang_key), gplx.core.primitives.Int_obj_ref.new_(wiki_tid));
|
||||
Tfds.Eq_str(expd, tmp_bfr.Xto_str_and_clear(), "to_abrv");
|
||||
}
|
||||
public void Test_to_domain_bry(String wmf_key, String expd_domain) {
|
||||
Tfds.Eq(expd_domain , String_.new_a7(Xow_abrv_wm_.Parse_to_domain_bry(Bry_.new_a7(wmf_key))));
|
||||
}
|
||||
public void Test_to_domain_itm(String wmf_key, String expd_lang_key, String expd_domain) {
|
||||
Xow_domain_itm domain = Xow_abrv_wm_.Parse_to_domain_itm(Bry_.new_a7(wmf_key));
|
||||
Tfds.Eq(expd_lang_key , String_.new_a7(domain.Lang_actl_key()));
|
||||
Tfds.Eq(expd_domain , String_.new_a7(domain.Domain_bry()));
|
||||
}
|
||||
}
|
||||
@@ -17,21 +17,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_abrv_xo_ {
|
||||
public class Xow_abrv_xo_ {
|
||||
public static byte[] To_bry(byte[] domain_bry) {
|
||||
Xow_domain domain_itm = Xow_domain_.parse(domain_bry);
|
||||
return Xow_domain_abrv_xo_.To_bry(domain_itm.Domain_bry(), domain_itm.Lang_orig_itm(), domain_itm.Domain_type());
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
return Xow_abrv_xo_.To_bry(domain_itm.Domain_bry(), domain_itm.Lang_orig_key(), domain_itm.Domain_type());
|
||||
}
|
||||
public static byte[] To_bry(byte[] domain_bry, Xol_lang_itm lang, Xow_domain_type type) { // en.wikipedia.org -> en.w
|
||||
public static byte[] To_bry(byte[] domain_bry, byte[] lang_key, Xow_domain_type type) { // en.wikipedia.org -> en.w
|
||||
byte[] type_abrv = type.Abrv();
|
||||
if (type.Multi_lang()) // wikipedia,wiktionary,etc..
|
||||
return Bry_.Add(lang.Key(), Byte_ascii.Dot_bry, type_abrv);
|
||||
return Bry_.Add(lang_key, Byte_ascii.Dot_bry, type_abrv);
|
||||
else if (type_abrv.length > 0) // commons,wbase,species,etc..
|
||||
return type_abrv;
|
||||
else // home;wikia;others
|
||||
return domain_bry;
|
||||
}
|
||||
public static Xow_domain To_itm(byte[] src) {
|
||||
public static Xow_domain_itm To_itm(byte[] src) {
|
||||
int src_len = src.length;
|
||||
byte[] domain_bry = src; // default to src; handles unknown abrv like "a.wikia.com";"xowa";others
|
||||
Xow_domain_type type = null;
|
||||
@@ -50,6 +50,6 @@ public class Xow_domain_abrv_xo_ {
|
||||
domain_bry = type.Domain_bry();
|
||||
}
|
||||
}
|
||||
return Xow_domain_.parse(domain_bry); // for consolidation's sake, parse abrv to domain_bry and pass to Xow_domain_.parse_()
|
||||
return Xow_domain_itm_.parse(domain_bry); // for consolidation's sake, parse abrv to domain_bry and pass to Xow_domain_itm_.parse_()
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_abrv_xo__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_domain_abrv_xo__fxt fxt = new Xow_domain_abrv_xo__fxt();
|
||||
public class Xow_abrv_xo__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_abrv_xo__fxt fxt = new Xow_abrv_xo__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test("en.wikipedia.org" , "en.w"); // multi.enwiki
|
||||
fxt.Test("fr.wiktionary.org" , "fr.d"); // multi.frwiktionary
|
||||
@@ -30,13 +30,13 @@ public class Xow_domain_abrv_xo__tst {
|
||||
fxt.Test("a.b.c" , "a.b.c"); // unkonwn
|
||||
}
|
||||
}
|
||||
class Xow_domain_abrv_xo__fxt {
|
||||
class Xow_abrv_xo__fxt {
|
||||
public void Clear() {}
|
||||
public void Test(String domain_str, String expd_abrv) {
|
||||
Xow_domain domain = Xow_domain_.parse(Bry_.new_u8(domain_str));
|
||||
byte[] actl_abrv = Xow_domain_abrv_xo_.To_bry(domain.Domain_bry(), domain.Lang_itm(), domain.Domain_type());
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
byte[] actl_abrv = Xow_abrv_xo_.To_bry(domain.Domain_bry(), domain.Lang_actl_key(), domain.Domain_type());
|
||||
Tfds.Eq(expd_abrv, String_.new_u8(actl_abrv), "To_bry");
|
||||
domain = Xow_domain_abrv_xo_.To_itm(actl_abrv);
|
||||
domain = Xow_abrv_xo_.To_itm(actl_abrv);
|
||||
Tfds.Eq(domain_str, domain.Domain_str(), "To_itm");
|
||||
}
|
||||
}
|
||||
48
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_itm.java
Normal file
48
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_itm.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_itm {
|
||||
Xow_domain_itm(byte[] domain_bry, Xow_domain_type domain_type, Xol_lang_itm lang_actl_itm, byte[] lang_orig_key) {
|
||||
this.domain_bry = domain_bry; this.domain_type = domain_type; this.lang_actl_itm = lang_actl_itm; this.lang_orig_key = lang_orig_key;
|
||||
this.domain_str = String_.new_u8(domain_bry);
|
||||
this.abrv_wm = Xow_abrv_wm_.To_abrv(this);
|
||||
this.abrv_xo = Xow_abrv_xo_.To_bry(domain_bry, lang_orig_key, domain_type);
|
||||
}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public Xow_domain_type Domain_type() {return domain_type;} private final Xow_domain_type domain_type;
|
||||
public int Domain_type_id() {return domain_type.Tid();}
|
||||
public byte[] Abrv_wm() {return abrv_wm;} private final byte[] abrv_wm; // EX: enwiki
|
||||
public byte[] Abrv_xo() {return abrv_xo;} private final byte[] abrv_xo; // EX: en.w
|
||||
public Xol_lang_itm Lang_actl_itm() {return lang_actl_itm;} private final Xol_lang_itm lang_actl_itm; // EX: zh
|
||||
public int Lang_actl_uid() {return lang_actl_itm.Id();}
|
||||
public byte[] Lang_actl_key() {return lang_actl_itm.Key();}
|
||||
public byte[] Lang_orig_key() {return lang_orig_key;} private final byte[] lang_orig_key; // EX: lzh
|
||||
public int Sort_idx() {return sort_idx;} public void Sort_idx_(int v) {sort_idx = v;} private int sort_idx = -1; // used for Search
|
||||
public static Xow_domain_itm new_(byte[] domain_bry, int domain_tid, byte[] lang_key) {
|
||||
Xol_lang_itm lang_actl_itm = Xol_lang_itm_.Get_by_key_or_intl(lang_key);
|
||||
return new Xow_domain_itm(domain_bry, Xow_domain_type_.Get_type_as_itm(domain_tid), lang_actl_itm, lang_actl_itm.Key());
|
||||
}
|
||||
public static Xow_domain_itm new_(byte[] domain_bry, int domain_tid, Xol_lang_itm lang_actl, byte[] lang_orig) {
|
||||
return new Xow_domain_itm(domain_bry, Xow_domain_type_.Get_type_as_itm(domain_tid), lang_actl, lang_orig);
|
||||
}
|
||||
public static Xow_domain_itm new_(byte[] domain_bry, int domain_tid, byte[] lang_actl_key, byte[] lang_orig_key) {
|
||||
return new Xow_domain_itm(domain_bry, Xow_domain_type_.Get_type_as_itm(domain_tid), Xol_lang_itm_.Get_by_key_or_intl(lang_actl_key), lang_orig_key);
|
||||
}
|
||||
}
|
||||
108
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_itm_.java
Normal file
108
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_itm_.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
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.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_itm_ {
|
||||
public static Xow_domain_itm parse(byte[] raw) {
|
||||
/*
|
||||
~{type}.org EX: wikimediafoundation
|
||||
~{type}.wikimedia.org EX: commons; species; meta; incubator
|
||||
~{lang}.~{type}.org EX: en.wikipedia, etc;
|
||||
~www.~{type}.org EX: mediawiki; wikidata;
|
||||
*/
|
||||
int raw_len = raw.length;
|
||||
int dot_0 = Bry_finder.Find_fwd(raw, Byte_ascii.Dot, 0, raw_len);
|
||||
if (dot_0 == Bry_.NotFound) { // 0 dots; check for "home"
|
||||
return Bry_.Eq(raw, Xow_domain_type_.Bry__home)
|
||||
? Xow_domain_uid_.To_domain(Xow_domain_uid_.Tid_xowa)
|
||||
: new_other(raw);
|
||||
}
|
||||
int dot_1 = Bry_finder.Find_fwd(raw, Byte_ascii.Dot, dot_0 + 1, raw_len);
|
||||
if (dot_1 == Bry_.NotFound) { // 1 dot; check for "wikimediafoundation.org"
|
||||
return Bry_.Match(raw, 0, dot_0, Xow_domain_type_.Bry__wmforg)
|
||||
? Xow_domain_itm.new_(raw, Xow_domain_type_.Int__wmfblog, Xol_lang_itm_.Key__unknown)
|
||||
: new_other(raw);
|
||||
}
|
||||
// 2 dots
|
||||
int seg_1_tid = Xow_domain_type_.Get_type_as_tid(raw, dot_0 + 1, dot_1); // parse middle; EX: ".wikipedia."
|
||||
if (seg_1_tid == Xow_domain_type_.Int__null) return new_other(raw); // seg_1 is unknown; return other;
|
||||
switch (seg_1_tid) {
|
||||
case Xow_domain_type_.Int__wikipedia: case Xow_domain_type_.Int__wiktionary: case Xow_domain_type_.Int__wikisource: case Xow_domain_type_.Int__wikibooks:
|
||||
case Xow_domain_type_.Int__wikiversity: case Xow_domain_type_.Int__wikiquote: case Xow_domain_type_.Int__wikinews: case Xow_domain_type_.Int__wikivoyage: // ~{lang}.~{type}.org
|
||||
byte[] lang_orig = Bry_.Mid(raw, 0, dot_0);
|
||||
byte[] lang_actl = Get_lang_code_for_mw_messages_file(lang_orig);
|
||||
return Xow_domain_itm.new_(raw, seg_1_tid, lang_actl, lang_orig); // NOTE: seg_tids must match wiki_tids
|
||||
case Xow_domain_type_.Int__wikidata: case Xow_domain_type_.Int__mediawiki:// ~www.~{type}.org
|
||||
return Xow_domain_itm.new_(raw, seg_1_tid, Xol_lang_itm_.Key__unknown);
|
||||
case Xow_domain_type_.Int__wikimedia: // ~{type}.wikimedia.org;
|
||||
int seg_0_tid = Xow_domain_type_.Get_type_as_tid(raw, 0, dot_0); // try to get "incubator", "meta", etc..
|
||||
if (seg_0_tid == Xow_domain_type_.Int__null) { // not a known name; try language
|
||||
byte[] lang_override = Xow_abrv_wm_override.To_lang_key_or_null(raw); // handle "lang-like" wikimedia domains like "ar.wikimedia.org" which is actually to "Argentina Wikimedia"
|
||||
if (lang_override == null) {
|
||||
Xol_lang_itm wikimedia_lang = Xol_lang_itm_.Get_by_key_or_null(raw, 0, dot_0);
|
||||
return wikimedia_lang == null ? new_other(raw) : Xow_domain_itm.new_(raw, Xow_domain_type_.Int__wikimedia, wikimedia_lang.Key());
|
||||
}
|
||||
else
|
||||
return Xow_domain_itm.new_(raw, Xow_domain_type_.Int__wikimedia, lang_override, Bry_.Mid(raw, 0, dot_0));
|
||||
}
|
||||
switch (seg_0_tid) {
|
||||
case Xow_domain_type_.Int__commons: case Xow_domain_type_.Int__species: case Xow_domain_type_.Int__meta: case Xow_domain_type_.Int__incubator:
|
||||
return Xow_domain_itm.new_(raw, seg_0_tid, Xol_lang_itm_.Key__unknown); // NOTE: seg_tids must match wiki_tids; NOTE: lang_key is "en" (really, "multi" but making things easier)
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
case Xow_domain_type_.Int__other:
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
}
|
||||
private static Xow_domain_itm new_other(byte[] raw) {return Xow_domain_itm.new_(raw, Xow_domain_type_.Int__other, Xol_lang_itm_.Key__unknown);}
|
||||
private static byte[] Get_lang_code_for_mw_messages_file(byte[] v) {
|
||||
Object o = lang_to_gfs_hash.Get_by_bry(v);
|
||||
return o == null ? v : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry lang_to_gfs_hash = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
.Add_str_obj("simple" , Bry_.new_a7("en"))
|
||||
.Add_str_obj("zh-classical" , Bry_.new_a7("lzh"))
|
||||
.Add_str_obj("no" , Bry_.new_a7("nb"))
|
||||
;
|
||||
public static final String
|
||||
Str__enwiki = "en.wikipedia.org"
|
||||
, Str__species = "species.wikimedia.org"
|
||||
, Str__commons = "commons.wikimedia.org"
|
||||
, Str__wikidata = "www.wikidata.org"
|
||||
, Str__mediawiki = "www.mediawiki.org"
|
||||
, Str__meta = "meta.wikimedia.org"
|
||||
, Str__incubator = "incubator.wikimedia.org"
|
||||
, Str__wmforg = "wikimediafoundation.org"
|
||||
, Str__home = "home"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__enwiki = Bry_.new_a7(Str__enwiki)
|
||||
, Bry__species = Bry_.new_a7(Str__species)
|
||||
, Bry__commons = Bry_.new_a7(Str__commons)
|
||||
, Bry__wikidata = Bry_.new_a7(Str__wikidata)
|
||||
, Bry__mediawiki = Bry_.new_a7(Str__mediawiki)
|
||||
, Bry__meta = Bry_.new_a7(Str__meta)
|
||||
, Bry__incubator = Bry_.new_a7(Str__incubator)
|
||||
, Bry__wmforg = Bry_.new_a7(Str__wmforg)
|
||||
, Bry__home = Bry_.new_a7(Str__home)
|
||||
;
|
||||
public static final byte[] Seg__org = Bry_.new_a7("org"), Seg__www = Bry_.new_a7("www");
|
||||
}
|
||||
41
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_itm_tst.java
Normal file
41
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_itm_tst.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_itm_tst {
|
||||
private final Xow_domain_fxt fxt = new Xow_domain_fxt();
|
||||
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , "en" , Xow_domain_type_.Int__wikipedia);}
|
||||
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , "fr" , Xow_domain_type_.Int__wikipedia);}
|
||||
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , "en" , Xow_domain_type_.Int__wiktionary);}
|
||||
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "zh-classical" , "lzh" , Xow_domain_type_.Int__wikipedia);}
|
||||
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , "" , Xow_domain_type_.Int__commons);}
|
||||
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , "" , Xow_domain_type_.Int__species);}
|
||||
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , "ru" , Xow_domain_type_.Int__wikimedia);}
|
||||
@Test public void Parse_home() {fxt.Test_parse("home" , "" , "" , Xow_domain_type_.Int__home);}
|
||||
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , "" , Xow_domain_type_.Int__other);}
|
||||
@Test public void Parse_ua_wikimedia_org() {fxt.Test_parse("ua.wikimedia.org" , "ua" , "uk" , Xow_domain_type_.Int__wikimedia);}
|
||||
@Test public void Parse_ar_wikimedia_org() {fxt.Test_parse("ar.wikimedia.org" , "ar" , "es" , Xow_domain_type_.Int__wikimedia);}
|
||||
}
|
||||
class Xow_domain_fxt {
|
||||
public void Test_parse(String domain, String expd_orig_lang, String expd_actl_lang, int expd_tid) {
|
||||
Xow_domain_itm actl = Xow_domain_itm_.parse(Bry_.new_a7(domain));
|
||||
Tfds.Eq_str(expd_orig_lang, String_.new_a7((actl.Lang_orig_key())));
|
||||
Tfds.Eq_str(expd_actl_lang, String_.new_a7((actl.Lang_actl_key())));
|
||||
Tfds.Eq_int(expd_tid, actl.Domain_type_id());
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_domain_type {
|
||||
public Xow_domain_type(boolean multi_lang, int src, int tid, byte[] key_bry, byte[] abrv, byte[] domain_bry) {
|
||||
this.multi_lang = multi_lang; this.src = src; this.tid = tid; this.key_bry = key_bry; this.abrv = abrv; this.domain_bry = domain_bry;
|
||||
@@ -23,9 +23,17 @@ public class Xow_domain_type {
|
||||
}
|
||||
public boolean Multi_lang() {return multi_lang;} private final boolean multi_lang; // EX: y
|
||||
public int Src() {return src;} private final int src; // EX: 1 (wm,mw,wk,xo)
|
||||
public int Tid() {return tid;} private final int tid; // EX: 1
|
||||
public int Tid() {return tid;} private final int tid; // EX: 1 (Tid_wikipedia)
|
||||
public String Key_str() {return key_str;} private final String key_str; // EX: wikipedia
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: wikipedia
|
||||
public byte[] Abrv() {return abrv;} private final byte[] abrv; // EX: w
|
||||
public byte[] Domain_bry() {return domain_bry;} private byte[] domain_bry; // EX: .wikipedia.org
|
||||
}
|
||||
class Xow_domain_type_src_ {
|
||||
public static final int
|
||||
Int__wmf = 1 // administered by wmf; wikipedia, etc.
|
||||
, Int__wikia = 2 // *.wikia.com
|
||||
, Int__mw = 3 // mediawiki installations not part of wmf, wikia
|
||||
, Int__xowa = 4 // xowa
|
||||
;
|
||||
}
|
||||
121
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_type_.java
Normal file
121
400_xowa/src/gplx/xowa/wikis/domains/Xow_domain_type_.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
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.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_domain_type_ {
|
||||
public static final int
|
||||
Int__null = 0
|
||||
, Int__wikipedia = 1
|
||||
, Int__wiktionary = 2
|
||||
, Int__wikisource = 3
|
||||
, Int__wikivoyage = 4
|
||||
, Int__wikiquote = 5
|
||||
, Int__wikibooks = 6
|
||||
, Int__wikiversity = 7
|
||||
, Int__wikinews = 8
|
||||
, Int__wikimedia = 9
|
||||
, Int__species = 10
|
||||
, Int__commons = 11
|
||||
, Int__wikidata = 12
|
||||
, Int__mediawiki = 13
|
||||
, Int__meta = 14
|
||||
, Int__incubator = 15
|
||||
, Int__wmfblog = 16
|
||||
, Int__home = 17
|
||||
, Int__other = 18
|
||||
, Int___len = 19
|
||||
;
|
||||
public static final String // SERIALIZED:xowa.gfs
|
||||
Str__wikipedia = "wikipedia"
|
||||
, Str__wiktionary = "wiktionary"
|
||||
, Str__wikisource = "wikisource"
|
||||
, Str__wikivoyage = "wikivoyage"
|
||||
, Str__wikiquote = "wikiquote"
|
||||
, Str__wikibooks = "wikibooks"
|
||||
, Str__wikiversity = "wikiversity"
|
||||
, Str__wikinews = "wikinews"
|
||||
, Str__wikimedia = "wikimedia"
|
||||
, Str__species = "species"
|
||||
, Str__commons = "commons"
|
||||
, Str__wikidata = "wikidata"
|
||||
, Str__mediawiki = "mediawiki"
|
||||
, Str__meta = "meta"
|
||||
, Str__incubator = "incubator"
|
||||
, Str__wmforg = "wikimediafoundation"
|
||||
, Str__home = "home"
|
||||
, Str__other = "other"
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__wikipedia = Bry_.new_a7(Str__wikipedia)
|
||||
, Bry__wiktionary = Bry_.new_a7(Str__wiktionary)
|
||||
, Bry__wikisource = Bry_.new_a7(Str__wikisource)
|
||||
, Bry__wikivoyage = Bry_.new_a7(Str__wikivoyage)
|
||||
, Bry__wikiquote = Bry_.new_a7(Str__wikiquote)
|
||||
, Bry__wikibooks = Bry_.new_a7(Str__wikibooks)
|
||||
, Bry__wikiversity = Bry_.new_a7(Str__wikiversity)
|
||||
, Bry__wikinews = Bry_.new_a7(Str__wikinews)
|
||||
, Bry__wikimedia = Bry_.new_a7(Str__wikimedia)
|
||||
, Bry__species = Bry_.new_a7(Str__species)
|
||||
, Bry__commons = Bry_.new_a7(Str__commons)
|
||||
, Bry__wikidata = Bry_.new_a7(Str__wikidata)
|
||||
, Bry__mediawiki = Bry_.new_a7(Str__mediawiki)
|
||||
, Bry__meta = Bry_.new_a7(Str__meta)
|
||||
, Bry__incubator = Bry_.new_a7(Str__incubator)
|
||||
, Bry__wmforg = Bry_.new_a7(Str__wmforg)
|
||||
, Bry__home = Bry_.new_a7(Str__home)
|
||||
, Bry__other = Bry_.new_a7(Str__other)
|
||||
;
|
||||
private static final Xow_domain_type[] ary = new Xow_domain_type[Int___len];
|
||||
private static final Hash_adp_bry type_regy = Hash_adp_bry.ci_a7(); // LOC:must go before new_()
|
||||
private static final Hash_adp_bry abrv_regy = Hash_adp_bry.cs(); // LOC:must go before new_()
|
||||
public static final Xow_domain_type
|
||||
Itm__wikipedia = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikipedia , Bry__wikipedia , "w" , ".wikipedia.org")
|
||||
, Itm__wiktionary = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wiktionary , Bry__wiktionary , "d" , ".wiktionary.org")
|
||||
, Itm__wikisource = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikisource , Bry__wikisource , "s" , ".wikisource.org")
|
||||
, Itm__wikivoyage = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikivoyage , Bry__wikivoyage , "v" , ".wikivoyage.org")
|
||||
, Itm__wikiquote = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikiquote , Bry__wikiquote , "q" , ".wikiquote.org")
|
||||
, Itm__wikibooks = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikibooks , Bry__wikibooks , "b" , ".wikibooks.org")
|
||||
, Itm__wikiversity = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikiversity , Bry__wikiversity , "u" , ".wikiversity.org")
|
||||
, Itm__wikinews = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikinews , Bry__wikinews , "n" , ".wikinews.org")
|
||||
, Itm__wikimedia = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikimedia , Bry__wikimedia , "m" , ".wikimedia.org")
|
||||
, Itm__species = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__species , Bry__species , "species" , Xow_domain_itm_.Str__species)
|
||||
, Itm__commons = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__commons , Bry__commons , "c" , Xow_domain_itm_.Str__commons)
|
||||
, Itm__wikidata = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__wikidata , Bry__wikidata , "wd" , Xow_domain_itm_.Str__wikidata)
|
||||
, Itm__mediawiki = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__mediawiki , Bry__mediawiki , "mw" , Xow_domain_itm_.Str__mediawiki)
|
||||
, Itm__meta = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__meta , Bry__meta , "meta" , Xow_domain_itm_.Str__meta)
|
||||
, Itm__incubator = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__incubator , Bry__incubator , "qb" , Xow_domain_itm_.Str__incubator)
|
||||
, Itm__wmforg = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__wmfblog , Bry__wmforg , "wmf" , Xow_domain_itm_.Str__wmforg)
|
||||
, Itm__home = new_(Bool_.N , Xow_domain_type_src_.Int__xowa, Int__home , Bry__home , "home" , Xow_domain_itm_.Str__home)
|
||||
, Itm__other = new_(Bool_.N , Xow_domain_type_src_.Int__mw , Int__other , Bry__other , "" , "")
|
||||
;
|
||||
private static Xow_domain_type new_(boolean multi_lang, int src, int tid, byte[] key_bry, String abrv_xo_str, String domain_bry) {
|
||||
byte[] abrv_xo_bry = Bry_.new_u8(abrv_xo_str);
|
||||
Xow_domain_type rv = new Xow_domain_type(multi_lang, src, tid, key_bry, abrv_xo_bry, Bry_.new_u8(domain_bry));
|
||||
ary[tid] = rv;
|
||||
type_regy.Add(key_bry, rv);
|
||||
abrv_regy.Add(abrv_xo_bry, rv);
|
||||
return rv;
|
||||
}
|
||||
public static Xow_domain_type Get_abrv_as_itm(byte[] src, int bgn, int end) {return (Xow_domain_type)abrv_regy.Get_by_mid(src, bgn, end);}
|
||||
public static Xow_domain_type Get_type_as_itm(int tid) {return ary[tid];}
|
||||
public static byte[] Get_type_as_bry(int tid) {return ary[tid].Key_bry();}
|
||||
public static int Get_type_as_tid(byte[] src) {return Get_type_as_tid(src, 0, src.length);}
|
||||
public static int Get_type_as_tid(byte[] src, int bgn, int end) {
|
||||
Object o = type_regy.Get_by_mid(src, bgn, end);
|
||||
return o == null ? Xow_domain_type_.Int__null : ((Xow_domain_type)o).Tid();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user