diff --git a/400_xowa/src/gplx/xowa/Xowe_wiki.java b/400_xowa/src/gplx/xowa/Xowe_wiki.java index e0ec13736..1f99a7420 100644 --- a/400_xowa/src/gplx/xowa/Xowe_wiki.java +++ b/400_xowa/src/gplx/xowa/Xowe_wiki.java @@ -229,7 +229,7 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm { log_bfr.Add("wiki.init.end"); app.Log_wtr().Log_to_session_direct(log_bfr.Xto_str()); init_in_process = false; - app.Api_root().Wikis().Get(domain_bry).Subscribe(this); +// app.Api_root().Wikis().Get(domain_bry).Subscribe(this); app.Site_cfg_mgr().Load(this); app.Addon_mgr().Load_by_wiki(this); ctg_pagebox_wtr.Init_by_wiki(this); @@ -237,6 +237,8 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm { file_mgr.Init_by_wiki(this); page_mgr.Init_by_wiki(this); + + app.Cfg().Bind_many_wiki(this, this, Cfg__variant__current); } public void Rls() { if (rls_list != null) { @@ -276,7 +278,8 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm { else if (ctx.Match(k, Invk_xtns)) return xtn_mgr; else if (ctx.Match(k, Invk_catpage_mgr)) return ctg_catpage_mgr; else if (ctx.Match(k, Invk_hdump_enabled_)) this.html_mgr__hdump_enabled = m.ReadYn("v"); - else if (ctx.Match(k, gplx.xowa.apps.apis.xowa.wikis.langs.Xoap_lang_variants.Evt_current_changed)) lang.Vnt_mgr().Cur_itm_(m.ReadBry("v")); + + else if (ctx.Match(k, Cfg__variant__current)) lang.Vnt_mgr().Cur_itm_(m.ReadBry("v")); else return Gfo_invk_.Rv_unhandled; return this; } @@ -291,6 +294,7 @@ public class Xowe_wiki implements Xow_wiki, Gfo_invk, Gfo_evt_itm { , Invk_domain = "domain", Invk_maint = "maint", Invk_hdump_enabled_ = "hdump_enabled_" , Invk_catpage_mgr = "catpage_mgr" ; + public static final String Cfg__variant__current = "xowa.lang.variant.current"; public static final String Invk_db_mgr = "db_mgr"; // SERIALIZED:000.sqlite3|xowa_cfg public static final String Invk_lang_ = "lang_"; } diff --git a/400_xowa/src/gplx/xowa/addons/apps/cfgs/Xocfg_mgr.java b/400_xowa/src/gplx/xowa/addons/apps/cfgs/Xocfg_mgr.java index ab15267dc..1e7baf4cc 100644 --- a/400_xowa/src/gplx/xowa/addons/apps/cfgs/Xocfg_mgr.java +++ b/400_xowa/src/gplx/xowa/addons/apps/cfgs/Xocfg_mgr.java @@ -113,6 +113,7 @@ public class Xocfg_mgr implements Gfo_invk { public void Set_float_app(String key, float val) {Set_str(Xocfg_mgr.Ctx__app, key, Float_.To_str(val));} public void Set_str_app(String key, String val) {Set_str(Xocfg_mgr.Ctx__app, key, val);} public void Set_int_app(String key, int val) {Set_str(Xocfg_mgr.Ctx__app, key, Int_.To_str(val));} + public void Set_bry_wiki(Xowe_wiki wiki, String key, byte[] val) {Set_str(wiki.Domain_itm().Abrv_xo_str(), key, String_.new_u8(val));} public void Set_str(String ctx, String key, String val) { cache_mgr.Set(ctx, key, val); } diff --git a/400_xowa/src/gplx/xowa/apps/apis/Xoapi_root.java b/400_xowa/src/gplx/xowa/apps/apis/Xoapi_root.java index a8312f4d4..b84106722 100644 --- a/400_xowa/src/gplx/xowa/apps/apis/Xoapi_root.java +++ b/400_xowa/src/gplx/xowa/apps/apis/Xoapi_root.java @@ -46,7 +46,6 @@ public class Xoapi_root implements Gfo_invk { public Xoapi_bldr Bldr() {return bldr_api;} private final Xoapi_bldr bldr_api = new Xoapi_bldr(); public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr(); public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns(); - public Xoapi_app_wikis Wikis() {return app_wikis;} private final Xoapi_app_wikis app_wikis = new Xoapi_app_wikis(); public String Test_str() {return test_str;} public void Test_str_(String v) {test_str = v;} private String test_str; // TEST private void Exec(String key) { Xog_cmd_itm cmd_itm = app.Gui_mgr().Cmd_mgr().Get_or_null(key); @@ -63,16 +62,11 @@ public class Xoapi_root implements Gfo_invk { else if (ctx.Match(k, Invk_usr)) return usr_api; else if (ctx.Match(k, Invk_xtns)) return xtns_api; else if (ctx.Match(k, Invk_exec)) Exec(m.ReadStr("v")); - else if (ctx.Match(k, Invk_wikis)) return app_wikis; else if (ctx.Match(k, Invk_test_str)) return test_str; else if (ctx.Match(k, Invk_test_str_)) test_str = m.ReadStr("v"); return this; } - private static final String - Invk_exec = "exec" + private static final String Invk_exec = "exec", Invk_test_str = "test_str", Invk_test_str_ = "test_str_" , Invk_app = "app", Invk_addon = "addon" - , Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_usr = "usr", Invk_xtns = "xtns" - , Invk_test_str = "test_str", Invk_test_str_ = "test_str_" - , Invk_wikis = "wikis" - ; + , Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_usr = "usr", Invk_xtns = "xtns"; } diff --git a/400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app_wiki.java b/400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app_wiki.java deleted file mode 100644 index 31085aed8..000000000 --- a/400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app_wiki.java +++ /dev/null @@ -1,29 +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 . -*/ -package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; -import gplx.xowa.apps.apis.xowa.wikis.*; -public class Xoapi_app_wiki implements Gfo_invk { - public Xoapi_wiki_lang Lang() {return lang;} private final Xoapi_wiki_lang lang = new Xoapi_wiki_lang(); - public void Subscribe(Gfo_evt_itm sub) {lang.Subscribe(sub);} - public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { - if (ctx.Match(k, Invk_lang)) return lang; - else return Gfo_invk_.Rv_unhandled; - } - private static final String Invk_lang = "lang"; - public static final Xoapi_app_wiki Dflt = new Xoapi_app_wiki(); -} diff --git a/400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app_wikis.java b/400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app_wikis.java deleted file mode 100644 index 90e80473d..000000000 --- a/400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app_wikis.java +++ /dev/null @@ -1,34 +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 . -*/ -package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; -public class Xoapi_app_wikis implements Gfo_invk { - private final Ordered_hash hash = Ordered_hash_.New_bry(); - public Xoapi_app_wiki Get(byte[] domain) { - Xoapi_app_wiki rv = (Xoapi_app_wiki)hash.Get_by(domain); - if (rv == null) { - rv = new Xoapi_app_wiki(); - hash.Add(domain, rv); - } - return rv; - } - public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { - if (ctx.Match(k, Invk_get)) return Get(m.ReadBry("v")); - else return Gfo_invk_.Rv_unhandled; - } - private static final String Invk_get = "get"; -} diff --git a/400_xowa/src/gplx/xowa/apps/apis/xowa/wikis/Xoapi_wiki_lang.java b/400_xowa/src/gplx/xowa/apps/apis/xowa/wikis/Xoapi_wiki_lang.java deleted file mode 100644 index 98bdb6ab7..000000000 --- a/400_xowa/src/gplx/xowa/apps/apis/xowa/wikis/Xoapi_wiki_lang.java +++ /dev/null @@ -1,28 +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 . -*/ -package gplx.xowa.apps.apis.xowa.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; -import gplx.xowa.apps.apis.xowa.wikis.langs.*; -public class Xoapi_wiki_lang implements Gfo_invk { - public Xoap_lang_variants Variants() {return variants;} private final Xoap_lang_variants variants = new Xoap_lang_variants(); - public void Subscribe(Gfo_evt_itm sub) {variants.Subscribe(sub);} - public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { - if (ctx.Match(k, Invk_variants)) return variants; - else return Gfo_invk_.Rv_unhandled; - } - private static final String Invk_variants = "variants"; -} diff --git a/400_xowa/src/gplx/xowa/apps/apis/xowa/wikis/langs/Xoap_lang_variants.java b/400_xowa/src/gplx/xowa/apps/apis/xowa/wikis/langs/Xoap_lang_variants.java deleted file mode 100644 index 365331b5c..000000000 --- a/400_xowa/src/gplx/xowa/apps/apis/xowa/wikis/langs/Xoap_lang_variants.java +++ /dev/null @@ -1,43 +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 . -*/ -package gplx.xowa.apps.apis.xowa.wikis.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.wikis.*; -public class Xoap_lang_variants implements Gfo_invk, Gfo_evt_mgr_owner { - public Xoap_lang_variants() { - this.ev_mgr = new Gfo_evt_mgr(this); - } - public Gfo_evt_mgr Evt_mgr() {return ev_mgr;} private final Gfo_evt_mgr ev_mgr; - public byte[] Current() {return current;} private byte[] current; - public void Current_(byte[] v) { - this.current = v; - Gfo_evt_mgr_.Pub_val(this, Evt_current_changed, v); - } - public void Subscribe(Gfo_evt_itm sub) { - Gfo_evt_mgr_.Sub_same(this, Evt_current_changed, sub); - if (current != null) Gfo_invk_.Invk_by_val(sub, Evt_current_changed, current); - } - public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { - if (ctx.Match(k, Invk_current)) return String_.new_u8(current); - else if (ctx.Match(k, Invk_current_)) Current_(m.ReadBry("v")); - else return Gfo_invk_.Rv_unhandled; - return this; - } - private static final String Invk_current = "current", Invk_current_ = "current_"; - public static final String - Evt_current_changed = "current_changed" - ; -} diff --git a/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java b/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java index c8a3d9011..22378b383 100644 --- a/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java +++ b/400_xowa/src/gplx/xowa/guis/views/Xog_tab_itm.java @@ -127,21 +127,17 @@ public class Xog_tab_itm implements Gfo_invk { if (page != null) page.Tab_data().Close_mgr().When_close(this, url); // cancel any current search cmds app.Log_wtr().Queue_enabled_(true); usr_dlg.Gui_wkr().Clear(); - if (url.Vnt_bry() != null) Cur_vnt_(wiki, url.Vnt_bry()); + if (url.Vnt_bry() != null) { + byte[] vnt = url.Vnt_bry(); + if (!Bry_.Eq(vnt, wiki.Lang().Vnt_mgr().Cur_itm().Key())) + wiki.Appe().Cfg().Set_bry_wiki(wiki, Xowe_wiki.Cfg__variant__current, vnt); + } Tab_name_(new_tab_name); usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_u8(ttl.Raw())); if (wiki.Html_mgr().Head_mgr().Popup_mgr().Enabled()) this.Html_box().Html_js_eval_script("if (window.xowa_popups_hide_all != null) window.xowa_popups_hide_all();"); // should be more configurable; DATE:2014-07-09 app.Thread_mgr_old().Page_load_mgr().Add_at_end(new Load_page_wkr(this, wiki, url, ttl)).Run(); } - private void Cur_vnt_(Xowe_wiki wiki, byte[] vnt) { - Xoae_app app = wiki.Appe(); - gplx.xowa.apps.apis.xowa.wikis.langs.Xoap_lang_variants vnt_mgr = app.Api_root().Wikis().Get(wiki.Domain_bry()).Lang().Variants(); - if (Bry_.Eq(vnt, vnt_mgr.Current())) return; - vnt_mgr.Current_(vnt); - app.Cfg_mgr().Set_by_app(String_.Format("xowa.api.wikis.get('{0}').lang.variants.current", wiki.Domain_str()), String_.new_u8(vnt)); - app.Cfg_mgr().Db_save_txt(); - } private void Show_url_loaded(Load_page_wkr wkr) { Xowe_wiki wiki = wkr.Wiki(); Xoae_page page = wkr.Page(); Xoa_url url = page.Url(); Xoa_ttl ttl = page.Ttl(); diff --git a/400_xowa/src/gplx/xowa/langs/vnts/Xol_vnt_mgr.java b/400_xowa/src/gplx/xowa/langs/vnts/Xol_vnt_mgr.java index b5b6bb3fe..11cbd2fe8 100644 --- a/400_xowa/src/gplx/xowa/langs/vnts/Xol_vnt_mgr.java +++ b/400_xowa/src/gplx/xowa/langs/vnts/Xol_vnt_mgr.java @@ -40,6 +40,7 @@ public class Xol_vnt_mgr implements Gfo_invk { return rv; } public void Cur_itm_(byte[] v) { + if (Bry_.Len_eq_0(v)) return; // Cfg is empty by default this.cur_itm = regy.Get_by(v); if (cur_itm == null) throw Err_.new_("lang.vnt", "vnt not found", "key", v); } public void Init_end() {