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-09-13 21:54:44 -04:00
parent 2145f6382c
commit 5fe27b5b3b
649 changed files with 4726 additions and 3432 deletions

View File

@@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
public class Xoa_app_eval implements Bry_fmtr_eval_mgr {
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public byte[] Eval(byte[] cmd) {
Object rslt = GfsCore._.Exec_bry(cmd);
return Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(rslt));
}
}

View 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.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*;
import gplx.xowa.apps.*;
public class Xoa_app_eval_tst {
Xoa_app_eval_fxt fxt = new Xoa_app_eval_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Basic() {
fxt.Eval_test("[~{<>app.sys_cfg.version;<>}]", "[" + Xoa_app_.Version + "]");
}
}
class Xoa_app_eval_fxt {
public void Clear() {
if (app == null) {
app = Xoa_app_fxt.app_();
fmtr = Bry_fmtr.new_();
eval = new Xoa_app_eval();
fmtr.Eval_mgr_(eval);
Xoa_gfs_mgr.Msg_parser_init();
}
} private Xoae_app app; Bry_fmtr fmtr; Xoa_app_eval eval;
public void Eval_test(String raw, String expd) {
Tfds.Eq(fmtr.Fmt_(raw).Bld_str_many(), expd);
}
}

View 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.apps; import gplx.*; import gplx.xowa.*;
import gplx.xowa.gui.views.*;
public class Xoa_cur implements GfoInvkAble {
public Xoa_cur(Xoae_app app) {this.app = app;} private Xoae_app app;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_wiki)) {
Xog_win_itm win = app.Gui_mgr().Browser_win();
return win.Active_tab() == null ? GfoInvkAble_.Null : win.Active_page().Wikie(); // null check when called from mass html gen; DATE:2014-06-04
}
else if (ctx.Match(k, Invk_win)) return app.Gui_mgr().Browser_win();
else if (ctx.Match(k, Invk_user)) return app.Usere();
else return GfoInvkAble_.Rv_unhandled;
} private static final String Invk_wiki = "wiki", Invk_win = "win", Invk_user = "user";
}

View File

@@ -0,0 +1,85 @@
/*
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.apps; import gplx.*; import gplx.xowa.*;
import gplx.xowa.langs.*;
public class Xoa_sys_cfg implements GfoInvkAble {
private Xoae_app app;
public Xoa_sys_cfg(Xoae_app app) {this.app = app;}
public byte[] Lang() {return lang_key;}
public Xoa_sys_cfg Lang_(byte[] v) {
lang_key = Xol_lang_itm_.Get_by_key_or_en(v).Key();
if (app.Stage() == gplx.xowa.apps.Xoa_stage_.Tid_launch) { // do not update user lang unless launched; DATE:2014-05-26
Xol_lang lang = app.Lang_mgr().Get_by_key_or_load(lang_key);
app.Usere().Lang_(lang);
app.Usere().Wiki().Html_mgr().Portal_mgr().Init();
}
return this;
} private byte[] lang_key = Xol_lang_.Key_en;
public int Options_version() {return options_version;} public Xoa_sys_cfg Options_version_(int v) {options_version = v; return this;} private int options_version = 1;
public KeyVal[] Options_lang_list() {if (options_lang_list == null) options_lang_list = Options_list_lang_.new_(); return options_lang_list;} private KeyVal[] options_lang_list;
public long Free_mem_when() {return free_mem_when;} long free_mem_when;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_version)) return Xoa_app_.Version;
else if (ctx.Match(k, Invk_build_date)) return Xoa_app_.Build_date;
else if (ctx.Match(k, Invk_free_mem_when_)) free_mem_when = gplx.ios.Io_size_.parse_or(m.ReadStr("v"), Io_mgr.Len_mb * 5);
else if (ctx.Match(k, Invk_lang)) return lang_key;
else if (ctx.Match(k, Invk_lang_)) Lang_(m.ReadBry("v"));
else if (ctx.Match(k, Invk_lang_list)) return Options_lang_list();
else if (ctx.Match(k, Invk_options_version)) return options_version;
else if (ctx.Match(k, Invk_options_version_)) options_version = m.ReadInt("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_version = "version", Invk_build_date = "build_date", Invk_free_mem_when_ = "free_mem_when_", Invk_options_version = "options_version", Invk_options_version_ = "options_version_"
, Invk_lang = "lang", Invk_lang_ = "lang_", Invk_lang_list = "lang_list";
}
class Options_list_lang_ {
public static KeyVal[] new_() {
Ordered_hash translated = Ordered_hash_.new_bry_();
List_adp untranslated = List_adp_.new_();
Add_itm_many(translated, Xol_lang_itm_.Id_en, Xol_lang_itm_.Id_de, Xol_lang_itm_.Id_pl, Xol_lang_itm_.Id_zh_hans, Xol_lang_itm_.Id_zh_hant); // add langs with translations first, so they alphabetize to top of list
int len = Xol_lang_itm_.Id__max;
for (int i = 0; i < len; i++) { // add rest of langs, but sort by code
Xol_lang_itm itm = Xol_lang_itm_.Get_by_id(i);
if (translated.Has(itm.Key())) continue;
untranslated.Add(itm);
}
untranslated.Sort_by(Xol_lang_itm_.Comparer_key);
KeyVal[] rv = new KeyVal[len];
int translated_max = translated.Count();
for (int i = 0; i < translated_max; i++)
rv[i] = new_itm((Xol_lang_itm)translated.Get_at(i));
for (int i = translated_max; i < len; i++)
rv[i] = new_itm((Xol_lang_itm)untranslated.Get_at(i - translated_max));
return rv;
}
private static KeyVal new_itm(Xol_lang_itm itm) {
String key_str = String_.new_u8(itm.Key());
String name_str = String_.new_u8(itm.Localized_name());
return KeyVal_.new_(key_str, name_str + " [" + key_str + "]");
}
private static void Add_itm_many(Ordered_hash translated, int... langs) {
int langs_len = langs.length;
for (int i = 0; i < langs_len; i++) {
Xol_lang_itm itm = Xol_lang_itm_.Get_by_id(langs[i]);
translated.Add_if_dupe_use_nth(itm.Key(), itm);
}
}
}

View File

@@ -0,0 +1,75 @@
/*
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.apps.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
interface Xoac_lang_obj {}
public class Xoac_lang_grp implements Cfg_nde_obj, Xoac_lang_obj {
public Xoac_lang_grp(byte[] key) {this.key_bry = key; this.name_bry = key_bry;}
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
public byte[] Name_bry() {return name_bry;} public Xoac_lang_grp Name_bry_(byte[] v) {name_bry = v; return this;} private byte[] name_bry;
public int Sort_idx() {return sort_idx;} private int sort_idx;
public byte[] Nde_key() {return key_bry;}
public boolean Nde_typ_is_grp() {return true;}
public Cfg_nde_obj Nde_subs_make(byte[] itm_type, byte[] itm_key, byte[][] itm_atrs) {
Cfg_nde_obj rv = null;
if (Bry_.Eq(itm_type, Make_grp)) rv = new Xoac_lang_grp(itm_key);
else if (Bry_.Eq(itm_type, Make_itm)) rv = new Xoac_lang_itm(itm_key);
else throw Err_.new_unhandled(itm_type);
rv.Nde_atrs_set(itm_atrs);
return rv;
}
public int Nde_subs_len() {return itms.Count();}
public Cfg_nde_obj Nde_subs_get_at(int i) {return (Cfg_nde_obj)itms.Get_at(i);}
public Cfg_nde_obj Nde_subs_get(byte[] key) {return (Cfg_nde_obj)itms.Get_by(key);}
public void Nde_subs_add(byte[] itm_key, Cfg_nde_obj itm_obj) {
if (!itm_obj.Nde_typ_is_grp()) {
Xoac_lang_itm itm = (Xoac_lang_itm)itm_obj;
if (!regy.Has(itm.Key_bry())) regy.Add(itm.Key_bry(), itm);
itm.Grp_(this);
}
itms.Add(itm_key, itm_obj);
}
public void Nde_subs_del(byte[] key) {
Cfg_nde_obj cur_obj = (Cfg_nde_obj)Nde_subs_get(key);
if (!cur_obj.Nde_typ_is_grp()) {
Xoac_lang_itm cur_itm = (Xoac_lang_itm)cur_obj;
Xoac_lang_itm reg_itm = (Xoac_lang_itm)regy.Get_by(key);
if (cur_itm.Uid() == reg_itm.Uid()) regy.Del(cur_itm.Key_bry());
}
itms.Del(key);
}
public void Nde_atrs_set(byte[][] ary) {
int ary_len = ary.length;
if (ary_len > 0) name_bry = ary[0];
if (ary_len > 1) sort_idx = Bry_.To_int_or(ary[1], -1);
}
public static final byte[] Make_grp = Bry_.new_a7("grp"), Make_itm = Bry_.new_a7("itm");
public int Itms_len() {return itms.Count();}
public Cfg_nde_obj Itms_get_at(int i) {return (Cfg_nde_obj)itms.Get_at(i);}
Ordered_hash itms = Ordered_hash_.new_bry_();
private static Ordered_hash regy = Ordered_hash_.new_bry_();
public static Xoac_lang_itm Regy_get_or_null(byte[] key) {return (Xoac_lang_itm)regy.Get_by(key);}
public static Xoac_lang_itm Regy_get_or_new (byte[] key) {
Xoac_lang_itm rv = Regy_get_or_null(key);
if (rv == null) {
rv = new Xoac_lang_itm(key);
regy.Add(key, rv);
}
return rv;
}
}

View File

@@ -0,0 +1,145 @@
/*
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.apps.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.xowa.langs.*;
public class Xoac_lang_grp_tst {
Xoac_lang_grp_fxt fxt = new Xoac_lang_grp_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Add_itm_new() {
fxt.Define_bulk(String_.Concat_lines_nl
( "+|euro|itm|fr|French"
, "+|euro|itm|de|German"
)
, fxt.grp_("euro").Itms_
( fxt.itm_("fr").Local_name_("French")
, fxt.itm_("de").Local_name_("German")
));
}
@Test public void Add_itm_nl() {
fxt.Define_bulk(String_.Concat_lines_nl
( ""
, "+|euro|itm|fr|French"
, ""
)
, fxt.grp_("euro").Itms_
( fxt.itm_("fr").Local_name_("French")
));
}
@Test public void Add_grp() {
fxt.Define_bulk(String_.Concat_lines_nl
( "+||grp|euro|European~1"
, "+|euro|itm|fr|French"
)
, fxt.grp_("euro").Name_("European").Sort_idx_(1).Itms_
( fxt.itm_("fr").Local_name_("French")
));
}
@Test public void Set_grp() {
fxt.Define_bulk(String_.Concat_lines_nl
( "+|euro|itm|fr|French"
, "+||grp|euro|European"
)
, fxt.grp_("euro").Name_("European").Itms_
( fxt.itm_("fr").Local_name_("French")
));
}
@Test public void Del() {
fxt.Define_bulk(String_.Concat_lines_nl
( "+|euro|itm|fr|French"
, "+|euro|itm|de|German"
, "-|euro|fr"
)
, fxt.grp_("euro").Itms_
( fxt.itm_("de").Local_name_("German")
));
}
@Test public void Add_grp_nest() {
fxt.Define_bulk(String_.Concat_lines_nl
( "+||grp|wiki"
, "+|wiki|grp|euro|European"
, "+|euro|itm|de|German"
)
, fxt.grp_("wiki").Itms_
( fxt.grp_("euro").Itms_
( fxt.itm_("de").Local_name_("German")
)));
}
}
class Xoac_lang_grp_fxt {
Xoa_lang_mgr lang_mgr; Tst_mgr tst_mgr = new Tst_mgr();
public void Clear() {
Xoae_app app = Xoa_app_fxt.app_();
lang_mgr = app.Lang_mgr();
}
public Xoac_lang_itm_chkr itm_(String key) {return new Xoac_lang_itm_chkr(key);}
public Xoac_lang_grp_chkr grp_(String key) {return new Xoac_lang_grp_chkr(key);}
public Xoac_lang_grp_fxt Define_bulk(String raw, Xoac_lang_grp_chkr... expd) {
lang_mgr.Groups().Set_bulk(Bry_.new_u8(raw));
tst_mgr.Tst_ary("", expd, To_ary(lang_mgr.Groups()));
return this;
}
Xoac_lang_grp[] To_ary(Cfg_nde_root root) {
int len = root.Root_len();
Xoac_lang_grp[] rv = new Xoac_lang_grp[len];
for (int i = 0; i < len; i++) {
rv[i] = (Xoac_lang_grp)root.Root_get_at(i); // ASSUME: root only has grps (no itms)
}
return rv;
}
}
abstract class Xoac_lang_chkr_base implements Tst_chkr {
public abstract Class<?> TypeOf();
public abstract int Chk(Tst_mgr mgr, String path, Object actl);
}
class Xoac_lang_itm_chkr extends Xoac_lang_chkr_base {
public Xoac_lang_itm_chkr(String key) {this.key = key;}
public String Key() {return key;} private String key;
public Xoac_lang_itm_chkr Local_name_(String v) {local_name = v; return this;} private String local_name;
@Override public Class<?> TypeOf() {return Xoac_lang_itm.class;}
@Override public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
Xoac_lang_itm actl = (Xoac_lang_itm)actl_obj;
int rv = 0;
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key_bry()));
rv += mgr.Tst_val(local_name == null, path, "local_name", local_name, String_.new_u8(actl.Local_name_bry()));
return rv;
}
}
class Xoac_lang_grp_chkr extends Xoac_lang_chkr_base {
public Xoac_lang_grp_chkr(String key) {this.key = key;}
public String Key() {return key;} private String key;
public Xoac_lang_grp_chkr Name_(String v) {name = v; return this;} private String name;
public Xoac_lang_grp_chkr Sort_idx_(int v) {sort_idx = v; return this;} private int sort_idx = -1;
public Xoac_lang_grp_chkr Itms_(Xoac_lang_chkr_base... v) {this.itms = v; return this;} private Xoac_lang_chkr_base[] itms;
@Override public Class<?> TypeOf() {return Xoac_lang_grp.class;}
@Override public int Chk(Tst_mgr mgr, String path, Object actl_obj) {
Xoac_lang_grp actl = (Xoac_lang_grp)actl_obj;
int rv = 0;
rv += mgr.Tst_val(key == null, path, "key", key, String_.new_u8(actl.Key_bry()));
rv += mgr.Tst_val(name == null, path, "name", name, String_.new_u8(actl.Name_bry()));
rv += mgr.Tst_val(sort_idx == -1, path, "sort_idx", sort_idx, actl.Sort_idx());
rv += mgr.Tst_sub_ary(itms, To_ary(actl), path, rv);
return rv;
}
Xoac_lang_obj[] To_ary(Xoac_lang_grp grp) {
int len = grp.Itms_len();
Xoac_lang_obj[] rv = new Xoac_lang_obj[len];
for (int i = 0; i < len; i++)
rv[i] = (Xoac_lang_obj)grp.Itms_get_at(i); // ASSUME: grp only has itms (no grps)
return rv;
}
}

View File

@@ -0,0 +1,37 @@
/*
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.apps.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoac_lang_itm implements Cfg_nde_obj, Xoac_lang_obj {
public Xoac_lang_itm(byte[] key) {this.key_bry = key; local_name_bry = key_bry; uid = uid_next++;} static int uid_next = 0;
public Xoac_lang_grp Grp() {return grp;} public Xoac_lang_itm Grp_(Xoac_lang_grp v) {grp = v; return this;} private Xoac_lang_grp grp;
public int Uid() {return uid;} private int uid;
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
public byte[] Local_name_bry() {return local_name_bry;} public Xoac_lang_itm Local_name_bry_(byte[] v) {local_name_bry = v; return this;} private byte[] local_name_bry;
public byte[] Nde_key() {return key_bry;}
public boolean Nde_typ_is_grp() {return false;}
public Cfg_nde_obj Nde_subs_make(byte[] itm_type, byte[] itm_key, byte[][] itm_atrs) {throw Err_.new_wo_type("langs cannot have itms", "type", itm_type, "key", itm_key);}
public Cfg_nde_obj Nde_subs_get(byte[] key) {throw Err_.new_wo_type("langs cannot have itms", "key", key);}
public int Nde_subs_len() {return 0;}
public Cfg_nde_obj Nde_subs_get_at(int i) {throw Err_.new_wo_type("langs cannot have itms", "idx", i);}
public void Nde_subs_add(byte[] itm_key, Cfg_nde_obj itm_obj) {throw Err_.new_wo_type("langs cannot have itms", "key", String_.new_u8(itm_key));}
public void Nde_subs_del(byte[] key) {throw Err_.new_wo_type("langs cannot delete itms", "key", String_.new_u8(key));}
public void Nde_atrs_set(byte[][] ary) {
if (ary.length != 1) throw Err_.new_wo_type("expecting name only", "name", String_.AryXtoStr(String_.Ary(ary)));
local_name_bry = ary[0];
}
}

View File

@@ -16,9 +16,29 @@ 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.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wmfs.data.*;
public class Xoa_meta_mgr {
private final Xoa_app app;
private final Hash_adp_bry ns__hash = Hash_adp_bry.cs();
private Site_core_db core_db;
public Xoa_meta_mgr(Xoa_app app) {
this.ns_mgr = new Xoa_ns_mgr(app);
this.app = app;
}
public void Ns__add(byte[] wiki_domain, Xow_ns_mgr ns_mgr) {ns__hash.Add(wiki_domain, ns_mgr);} // TEST:public
public Xow_ns_mgr Ns__get_or_load(byte[] wiki_domain) {
Xow_ns_mgr rv = (Xow_ns_mgr)ns__hash.Get_by_bry(wiki_domain);
if (rv == null) {
Core_db__assert();
rv = core_db.Load_namespace(wiki_domain);
Ns__add(wiki_domain, rv);
}
return rv;
}
public void Init_by_wiki(Xow_wiki wiki) {
Core_db__assert();
core_db.Load_extensiontag(wiki.Domain_itm(), wiki.Mw_parser_mgr().Xnde_tag_regy());
}
private void Core_db__assert() {
if (core_db == null) core_db = new Site_core_db(app.Fsys_mgr().Cfg_site_meta_fil());
}
public Xoa_ns_mgr Ns_mgr() {return ns_mgr;} private final Xoa_ns_mgr ns_mgr;
}

View File

@@ -1,40 +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.apps.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.dbs.*;
import gplx.xowa.langs.cases.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.wmfs.data.*;
public class Xoa_ns_mgr {
private final Xoa_app app;
private final Hash_adp_bry hash = Hash_adp_bry.cs();
private Site_core_db core_db;
public Xoa_ns_mgr(Xoa_app app) {
this.app = app;
}
public void Add(byte[] wiki_domain, Xow_ns_mgr ns_mgr) {hash.Add(wiki_domain, ns_mgr);} // TEST:
public Xow_ns_mgr Get_or_load(byte[] wiki_domain) {
Xow_ns_mgr rv = (Xow_ns_mgr)hash.Get_by_bry(wiki_domain);
if (rv == null) {
if (core_db == null) core_db = new Site_core_db(app.Fsys_mgr().Cfg_site_meta_fil());
rv = core_db.Load_ns(wiki_domain);
Add(wiki_domain, rv);
}
return rv;
}
}