1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-07-19 23:16:49 -04:00
parent 794b5a232f
commit 8e041d6e06
834 changed files with 4749 additions and 4461 deletions

View File

@@ -18,12 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
public class Xow_cfg_consts {
public static final String
Grp__wiki_core = "xowa.wiki.core"
, Grp__wiki_schema = "xowa.wiki.schema"
, Grp__bldr_session = "xowa.bldr.session"
, Grp__bldr_db = "xowa.bldr.db"
, Grp__bldr_fsdb = "xowa.bldr.fsdb"
, Grp__wiki_init = "wiki.init"
, Key__init__main_page = "props.main_page"
Grp__wiki_core = "xowa.wiki.core"
, Grp__wiki_schema = "xowa.wiki.schema"
, Grp__bldr_session = "xowa.bldr.session"
, Grp__bldr_db = "xowa.bldr.db"
, Grp__bldr_fsdb = "xowa.bldr.fsdb"
, Grp__wiki_init = "wiki.init"
, Key__init__main_page = "props.main_page"
, Key__init__bldr_version = "props.bldr_version"
;
}

View File

@@ -42,7 +42,7 @@ public class Xow_domain_ {
, 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_u8("www");
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

View File

@@ -26,8 +26,8 @@ public class Xow_wiki_alias {
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 Exc_.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 Exc_.new_parse_type(Xow_wiki_alias.class, String_.new_u8(fil_name));
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);
@@ -63,7 +63,7 @@ public class Xow_wiki_alias {
case Xow_domain_type_.Tid_wikimedia:
return Bry_.Add(wiki_type.Lang_orig_key(), alias);
default:
throw Exc_.new_unhandled(tid);
throw Err_.new_unhandled(tid);
}
}
public static byte[] Parse_wmf_key(byte[] src) {return Parse__domain_name(src, 0, src.length);}
@@ -131,7 +131,7 @@ public class Xow_wiki_alias {
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 Exc_.new_parse_type(Xow_wiki_alias.class, String_.new_u8(src));
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) {
@@ -228,7 +228,7 @@ public class Xow_wiki_alias {
case Tid_categorylinks : return Key_categorylinks;
case Tid_page_props : return Key_page_props;
case Tid_image : return Key_image;
default : throw Exc_.new_unhandled(v);
default : throw Err_.new_unhandled(v);
}
}
private static void Init_tid(String tid_str, byte tid) {

View File

@@ -49,7 +49,7 @@ public class Xowd_db_file_ {
case Tid_file_core: return Key_file_core;
case Tid_file_data: return Key_file_data;
case Tid_file_user: return Key_file_user;
default: throw Exc_.new_unhandled(v);
default: throw Err_.new_unhandled(v);
}
}
}

View File

@@ -22,8 +22,8 @@ class Xowd_db_file_hash {
public void Clear() {hash.Clear(); count_total = 0;}
public void Del(Xowd_db_file file) {
Ordered_hash tids = (Ordered_hash)hash.Get_by(file.Tid());
if (tids == null) throw Exc_.new_("unknown file.tid", "url", file.Url());
if (!tids.Has(file.Id())) throw Exc_.new_("unknown file.id", "url", file.Url());
if (tids == null) throw Err_.new_wo_type("unknown file.tid", "url", file.Url());
if (!tids.Has(file.Id())) throw Err_.new_wo_type("unknown file.id", "url", file.Url());
tids.Del(file.Id());
--count_total;
}

View File

@@ -27,7 +27,7 @@ public class Xowd_db_layout {
case Const_all: return Name_all;
case Const_few: return Name_few;
case Const_lot: return Name_lot;
default: throw Exc_.new_unimplemented();
default: throw Err_.new_unimplemented();
}
}
public static final String Name_all = "all", Name_few = "few", Name_lot = "lot";
@@ -41,6 +41,6 @@ public class Xowd_db_layout {
if (String_.Eq(v, Name_all)) return Itm_all;
else if (String_.Eq(v, Name_few)) return Itm_few;
else if (String_.Eq(v, Name_lot)) return Itm_lot;
else throw Exc_.new_unimplemented();
else throw Err_.new_unimplemented();
}
}

View File

@@ -70,7 +70,7 @@ public class Xowd_db_mgr {
Dbs__set_by_tid(db);
db_file_hash.Add_or_new(db);
}
wiki.Props().Init_by_load(Tbl__cfg());
wiki.Props().Init_by_load(wiki.App(), Tbl__cfg());
}
public void Init_by_make(Xowd_core_db_props props, Xob_info_session info_session) {
this.props = props;
@@ -133,7 +133,7 @@ public class Xowd_db_mgr {
case Xowd_db_layout.Const_all: return domain_name + ".xowa"; // EX: en.wikipedia.org.xowa
case Xowd_db_layout.Const_few: return domain_name + "-text.xowa"; // EX: en.wikipedia.org-text.xowa
case Xowd_db_layout.Const_lot: return domain_name + "-core.xowa"; // EX: en.wikipedia.org-core.xowa
default: throw Exc_.new_unimplemented();
default: throw Err_.new_unimplemented();
}
}
private static byte Core_db_tid(Xowd_db_layout layout) {
@@ -141,7 +141,7 @@ public class Xowd_db_mgr {
case Xowd_db_layout.Const_all: return Xowd_db_file_.Tid_wiki_solo;
case Xowd_db_layout.Const_few: return Xowd_db_file_.Tid_text_solo;
case Xowd_db_layout.Const_lot: return Xowd_db_file_.Tid_core;
default: throw Exc_.new_unimplemented();
default: throw Err_.new_unimplemented();
}
}
}

View File

@@ -31,7 +31,7 @@ public class Xowd_category_itm {
case Xoa_ctg_mgr.Tid_subc: return count_subcs;
case Xoa_ctg_mgr.Tid_page: return count_pages;
case Xoa_ctg_mgr.Tid_file: return count_files;
default: throw Exc_.new_unhandled(tid);
default: throw Err_.new_unhandled(tid);
}
}
public static Xowd_category_itm load_(int id, int file_idx, boolean hidden, int count_subcs, int count_files, int count_pages) {

View File

@@ -38,7 +38,7 @@ public class Xowd_page_itm_sorter implements ComparerAble {
int tid_comparable = Byte_.Compare(lhs_xtn.Tid(), rhs_xtn.Tid());
if (tid_comparable != CompareAble_.Same) return tid_comparable;
return Bry_.Compare(lhs_xtn.Sortkey(), rhs_xtn.Sortkey());
default: throw Exc_.new_unhandled(compareType);
default: throw Err_.new_unhandled(compareType);
}
}
Xowd_page_itm_sorter(byte compareType, int order) {this.compareType = compareType; this.order = order;}

View File

@@ -293,7 +293,7 @@ public class Xowd_page_tbl implements RlsAble {
.Exec_update();
break;
} catch (Exception exc) {
if (String_.Has(Err_.Message_gplx_brief(exc), "columns page_namespace, page_random_int are not unique")) { // HACK: terrible hack, but moving pages across ns will break UNIQUE index
if (String_.Has(Err_.Message_gplx_full(exc), "columns page_namespace, page_random_int are not unique")) { // HACK: terrible hack, but moving pages across ns will break UNIQUE index
conn.Exec_sql_args("DROP INDEX {0}__name_random;", tbl_name); // is UNIQUE by default
conn.Exec_sql_args("CREATE INDEX {0}__name_random ON {0} ({1}, {2});", tbl_name, fld_ns, fld_random_int);
}

View File

@@ -48,10 +48,10 @@ public class Xowd_search_temp_tbl {
public void Create_idx(Gfo_usr_dlg usr_dlg, Xowd_search_link_tbl search_link_tbl, Xowd_search_word_tbl search_word_tbl) {
conn.Ddl_delete_tbl(tbl_name);
try {search_word_tbl.Create_idx();}
catch (Exception e) {usr_dlg.Warn_many("", "", "bldr.search_word.unique_search_failed: err=~{0}", Err_.Message_gplx_brief(e));}
catch (Exception e) {usr_dlg.Warn_many("", "", "bldr.search_word.unique_search_failed: err=~{0}", Err_.Message_gplx_full(e));}
try {search_link_tbl.Create_idx_unique();}
catch (Exception e) {
usr_dlg.Warn_many("", "", "bldr.search_page.unique_search_failed: err=~{0}", Err_.Message_gplx_brief(e));
usr_dlg.Warn_many("", "", "bldr.search_page.unique_search_failed: err=~{0}", Err_.Message_gplx_full(e));
search_link_tbl.Create_idx_normal();;
}
}

View File

@@ -71,7 +71,7 @@ public class Xowd_xowa_db_tbl {
case Db_cmd_mode.Tid_update: stmt.Clear(); Commit_itm_vals(stmt, itm); stmt.Crt_int(fld_id, itm.Id()).Exec_update(); break;
case Db_cmd_mode.Tid_delete: stmt.Clear().Crt_int(fld_id, itm.Id()).Exec_delete(); break;
case Db_cmd_mode.Tid_ignore: break;
default: throw Exc_.new_unhandled(itm.Cmd_mode());
default: throw Err_.new_unhandled(itm.Cmd_mode());
}
itm.Cmd_mode_(Db_cmd_mode.Tid_ignore);
}

View File

@@ -61,7 +61,7 @@ public class Xow_domain_uid_ {
case Xow_domain_type_.Tid_wikiversity: domain_tid = Tid_sub_wikiversity; break;
case Xow_domain_type_.Tid_wikinews: domain_tid = Tid_sub_wikinews; break;
case Xow_domain_type_.Tid_wikimedia: domain_tid = Tid_sub_wikimedia; break;
default: throw Exc_.new_unhandled(domain.Domain_tid());
default: throw Err_.new_unhandled(domain.Domain_tid());
}
return Const_system_reserved // reserve first 100 slots
+ domain_tid // domain_tid assigned above
@@ -93,7 +93,7 @@ public class Xow_domain_uid_ {
case Tid_sub_wikiversity: tid_int = Xow_domain_type_.Tid_wikiversity; tid_bry = Xow_domain_type_.Key_bry_wikiversity; break;
case Tid_sub_wikinews: tid_int = Xow_domain_type_.Tid_wikinews; tid_bry = Xow_domain_type_.Key_bry_wikinews; break;
case Tid_sub_wikimedia: tid_int = Xow_domain_type_.Tid_wikimedia; tid_bry = Xow_domain_type_.Key_bry_wikimedia; break;
default: throw Exc_.new_unhandled(type_id);
default: throw Err_.new_unhandled(type_id);
}
Xol_lang_itm lang = Xol_lang_itm_.Get_by_id(lang_id);
Bry_bfr bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();

View File

@@ -16,14 +16,14 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.html.modules.*; import gplx.xowa.html.modules.popups.*;
import gplx.xowa.html.heads.*; import gplx.xowa.html.modules.popups.*;
public class Xow_module_mgr implements GfoInvkAble {
private Hash_adp_bry regy = Hash_adp_bry.cs_();
public Xow_module_mgr(Xowe_wiki wiki) {
this.popup_mgr = new Xow_popup_mgr(wiki);
regy.Add_bry_obj(Xoh_module_itm_.Key_top_icon , itm__top_icon);
regy.Add_bry_obj(Xoh_module_itm_.Key_navframe , itm__navframe);
regy.Add_bry_obj(Xoh_module_itm_.Key_title_rewrite , itm__title_rewrite);
regy.Add_bry_obj(Xoh_head_itm_.Key__top_icon , itm__top_icon);
regy.Add_bry_obj(Xoh_head_itm_.Key__navframe , itm__navframe);
regy.Add_bry_obj(Xoh_head_itm_.Key__title_rewrite , itm__title_rewrite);
}
public void Init_by_wiki(Xowe_wiki wiki) {
popup_mgr.Init_by_wiki(wiki);

View File

@@ -44,7 +44,7 @@ class Xow_ttl_fxt {
public Xowe_wiki Wiki() {return fxt.Wiki();}
public void Reset() {
fxt.Reset();
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_u8("fr"), Bry_.new_u8("fr.wikipedia.org"));
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("fr"), Bry_.new_a7("fr.wikipedia.org"));
test_raw = "Test page";
expd_ns_id = Int_.MinValue;
expd_xwik_txt = expd_full_txt = expd_full_url = expd_page_txt = expd_page_url = expd_leaf_txt = expd_leaf_url = expd_base_txt = expd_base_url

View File

@@ -60,7 +60,7 @@ public class Xow_lang_mgr_tst {
));
}
@Test public void Unregistered() {
// fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_u8("zh"), Bry_.new_u8("zh.wikipedia.org"), Bry_.new_u8("http://zh.wikipedia.org/~{0}"));
// fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("zh"), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_a7("http://zh.wikipedia.org/~{0}"));
fxt.tst("[[zh:Earth]]", String_.Concat_lines_nl_skip_last
( "<div id=\"xowa-lang\">"
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a></h5>"

View File

@@ -80,7 +80,7 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
case 0: alias = fld; break;
case 1: domain_bry = fld; break;
case 2: break; // reserved for 0,1 (0=custom; 1=wmf)
default: throw Exc_.new_unhandled(j);
default: throw Err_.new_unhandled(j);
}
}
Xow_domain domain = Xow_domain_.parse(domain_bry);
@@ -119,7 +119,7 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
byte[] key = keys[i];
Cfg_nde_obj peer_grp = peer_root.Grps_get(key);
if (peer_grp == null)
throw Exc_.new_("unknown peer group", "key", String_.new_u8(key));
throw Err_.new_wo_type("unknown peer group", "key", String_.new_u8(key));
else
Cfg_nde_obj_.Fill_recurse(peers, peer_grp);
}