mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wiki.Dom: Refactor Wiki.Props
This commit is contained in:
@@ -22,7 +22,7 @@ public class Xoa_wiki_mgr_ {
|
||||
public static Xow_wiki Import_by_url(Xoa_app app, Xoa_wiki_mgr wiki_mgr, Io_url url) {
|
||||
Db_conn conn = Db_conn_bldr.Instance.Get_or_noop(url); if (conn == Db_conn_.Noop) return null; // invalid url
|
||||
Db_cfg_tbl cfg_tbl = Xowd_cfg_tbl_.Get_or_null(conn); if (cfg_tbl == null) return null; // no xowa_cfg;
|
||||
byte[] wiki_domain = cfg_tbl.Select_bry(Xow_cfg_consts.Grp__bldr_session, Xob_info_session.Cfg_key__wiki_domain); if (wiki_domain == null) return null;
|
||||
byte[] wiki_domain = cfg_tbl.Select_bry(Xowd_cfg_key_.Grp__bldr_session, Xob_info_session.Cfg_key__wiki_domain); if (wiki_domain == null) return null;
|
||||
Io_url wiki_root_dir = url.OwnerDir();
|
||||
Xow_wiki rv = wiki_mgr.Make(wiki_domain, wiki_root_dir);
|
||||
wiki_mgr.Add(rv);
|
||||
|
||||
@@ -1,33 +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_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"
|
||||
, Grp__empty = ""
|
||||
, Key__init__main_page = "props.main_page"
|
||||
, Key__init__bldr_version = "props.bldr_version"
|
||||
, Key__init__modified_latest = "props.modified_latest"
|
||||
, Key__init__domain = "props.domain"
|
||||
;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ public class Xow_db_file_schema_props {
|
||||
boolean wbase__qid__src_ttl_has_spaces = String_.In(version, "2.4.2.1", "2.4.3.1", "2.4.3.2");
|
||||
return new Xow_db_file_schema_props(search__word__page_count_exists, wbase__qid__src_ttl_has_spaces);
|
||||
}
|
||||
public static final String Grp = Xow_cfg_consts.Grp__wiki_schema;
|
||||
public static final String Grp = Xowd_cfg_key_.Grp__wiki_schema;
|
||||
public static final String
|
||||
Key__tbl_css_core = "tbl.css_core" // VERSION:2.4.1
|
||||
, Key__col_search_word_page_count = "col.search_word.word_page_count" // VERSION:2.4.2
|
||||
|
||||
38
400_xowa/src/gplx/xowa/wikis/data/Xowd_cfg_key_.java
Normal file
38
400_xowa/src/gplx/xowa/wikis/data/Xowd_cfg_key_.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xowd_cfg_key_ {
|
||||
public static final String
|
||||
Grp__empty = ""
|
||||
, 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"
|
||||
, Key__init__modified_latest = "props.modified_latest"
|
||||
, Key__init__siteinfo_misc = "props.siteinfo_misc"
|
||||
, Key__init__siteinfo_mainpage = "props.siteinfo_mainpage"
|
||||
|
||||
, Grp__wiki_core = "xowa.wiki.core"
|
||||
, Key__wiki_core__domain = "xowa.wiki.core.domain"
|
||||
, Key__wiki_core__name = "xowa.wiki.core.name"
|
||||
;
|
||||
}
|
||||
@@ -29,4 +29,18 @@ public class Xowd_cfg_tbl_ {
|
||||
if (rv == null) throw Err_.New("xowa_cfg tbl does not exist: file={0}", conn.Conn_info().Raw());
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static void Insert__import(Xowe_wiki wiki) {
|
||||
Db_cfg_tbl cfg_tbl = wiki.Data__core_mgr().Db__core().Tbl__cfg();
|
||||
cfg_tbl.Insert_bry(Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__bldr_version, wiki.Props().Bldr_version());
|
||||
cfg_tbl.Insert_bry(Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__siteinfo_misc, wiki.Props().Siteinfo_misc());
|
||||
cfg_tbl.Insert_bry(Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__siteinfo_mainpage, wiki.Props().Siteinfo_mainpage());
|
||||
}
|
||||
public static void Insert__create(Xowe_wiki wiki) {Insert__create(wiki.Data__core_mgr().Db__core().Tbl__cfg(), wiki.Domain_str(), wiki.Domain_str(), wiki.Props().Main_page());}
|
||||
public static void Insert__create(Db_cfg_tbl cfg_tbl, String domain, String name, byte[] main_page) {
|
||||
cfg_tbl.Insert_str(Xowd_cfg_key_.Grp__empty , Xowd_cfg_key_.Key__wiki_core__domain , domain);
|
||||
cfg_tbl.Insert_str(Xowd_cfg_key_.Grp__empty , Xowd_cfg_key_.Key__wiki_core__name , name);
|
||||
cfg_tbl.Insert_bry(Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__main_page , main_page);
|
||||
cfg_tbl.Insert_str(Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__modified_latest, Datetime_now.Get().XtoStr_fmt(DateAdp_.Fmt_iso8561_date_time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Xowd_core_db_props {
|
||||
, cfg_hash.Get_by(Cfg_key__hzip_mode_is_b256).To_yn_or(Bool_.N)
|
||||
);
|
||||
}
|
||||
private static final String Cfg_grp = Xow_cfg_consts.Grp__wiki_core
|
||||
private static final String Cfg_grp = gplx.xowa.wikis.data.Xowd_cfg_key_.Grp__wiki_core
|
||||
, Cfg_key__schema_version = "schema_version"
|
||||
, Cfg_key__layout_text = "layout_text"
|
||||
, Cfg_key__layout_html = "layout_html"
|
||||
|
||||
@@ -16,38 +16,45 @@ 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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.addons.wikis.ctgs.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.addons.wikis.searchs.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.urls.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
private Xodb_mgr_sql db_mgr; Xow_db_mgr fsys_mgr;
|
||||
public Xodb_load_mgr_sql(Xow_wiki wiki, Xodb_mgr_sql db_mgr, Xow_db_mgr fsys_mgr) {this.db_mgr = db_mgr; this.fsys_mgr = fsys_mgr;}
|
||||
private final Xodb_mgr_sql db_mgr;
|
||||
public Xodb_load_mgr_sql(Xodb_mgr_sql db_mgr) {this.db_mgr = db_mgr;}
|
||||
public void Load_init(Xowe_wiki wiki) {
|
||||
Load_init_cfg(wiki);
|
||||
Xow_db_file db_core = wiki.Data__core_mgr().Db__core();
|
||||
Load_cfg(wiki);
|
||||
db_core.Tbl__site_stats().Select(wiki.Stats());
|
||||
db_core.Tbl__ns().Select_all(wiki.Ns_mgr());
|
||||
}
|
||||
private void Load_init_cfg(Xowe_wiki wiki) {
|
||||
String version_key = Xoa_gfs_wtr_.Write_func_chain(Xowe_wiki.Invk_props, Xow_wiki_props.Invk_bldr_version);
|
||||
Db_cfg_hash cfg_hash = db_mgr.Core_data_mgr().Tbl__cfg().Select_as_hash(Xow_cfg_consts.Grp__wiki_init);
|
||||
String version_val = cfg_hash.Get_by(version_key).To_str_or("");
|
||||
Xodb_upgrade_mgr.Upgrade(db_mgr, cfg_hash, version_key, version_val);
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_k004();
|
||||
Xoa_gfs_mgr gfs_mgr = wiki.Appe().Gfs_mgr();
|
||||
try {
|
||||
int len = cfg_hash.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_cfg_itm cfg_itm = cfg_hash.Get_at(i);
|
||||
Xoa_gfs_wtr_.Write_prop(bfr, Bry_.new_u8(cfg_itm.Key()), Bry_.new_u8(cfg_itm.To_str_or("")));
|
||||
private void Load_cfg(Xowe_wiki wiki) {
|
||||
byte[] main_page = null, bldr_version = null, siteinfo_misc = null, siteinfo_mainpage = null;
|
||||
DateAdp modified_latest = null;
|
||||
|
||||
// load from xowa_cfg
|
||||
gplx.dbs.cfgs.Db_cfg_hash prop_hash = wiki.Data__core_mgr().Db__core().Tbl__cfg().Select_as_hash(Xowd_cfg_key_.Grp__wiki_init);
|
||||
int len = prop_hash.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
gplx.dbs.cfgs.Db_cfg_itm prop = prop_hash.Get_at(i);
|
||||
String prop_key = prop.Key();
|
||||
try {
|
||||
if (String_.Eq(prop_key, Xowd_cfg_key_.Key__init__main_page)) main_page = Bry_.new_u8(prop.Val());
|
||||
else if (String_.Eq(prop_key, Xowd_cfg_key_.Key__init__bldr_version)) bldr_version = Bry_.new_u8(prop.Val());
|
||||
else if (String_.Eq(prop_key, Xowd_cfg_key_.Key__init__siteinfo_misc)) siteinfo_misc = Bry_.new_u8(prop.Val());
|
||||
else if (String_.Eq(prop_key, Xowd_cfg_key_.Key__init__siteinfo_mainpage)) siteinfo_mainpage = Bry_.new_u8(prop.Val());
|
||||
else if (String_.Eq(prop_key, Xowd_cfg_key_.Key__init__modified_latest)) modified_latest = DateAdp_.parse_gplx(prop.Val());
|
||||
} catch (Exception exc) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "failed to set prop; key=~{0} val=~{1} err=~{2}", prop_key, prop.Val(), Err_.Message_gplx_log(exc));
|
||||
}
|
||||
gfs_mgr.Run_str_for(wiki, bfr.To_str_and_clear());
|
||||
} finally {bfr.Mkr_rls();}
|
||||
}
|
||||
|
||||
wiki.Props().Init_by_load_2(main_page, bldr_version, siteinfo_misc, siteinfo_mainpage, modified_latest);
|
||||
}
|
||||
public boolean Load_by_ttl(Xowd_page_itm rv, Xow_ns ns, byte[] ttl) {
|
||||
return db_mgr.Core_data_mgr().Tbl__page().Select_by_ttl(rv, ns, ttl);
|
||||
}
|
||||
public boolean Load_by_ttl(Xowd_page_itm rv, Xow_ns ns, byte[] ttl) {return db_mgr.Core_data_mgr().Tbl__page().Select_by_ttl(rv, ns, ttl);}
|
||||
public void Load_by_ttls(Cancelable cancelable, Ordered_hash rv, boolean fill_idx_fields_only, int bgn, int end) {
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_in__ns_ttl(cancelable, rv, db_mgr.Wiki().Ns_mgr(), fill_idx_fields_only, bgn, end);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, Gfo_invk {
|
||||
public Xodb_mgr_sql(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.core_data_mgr = new Xow_db_mgr(wiki, wiki.Fsys_mgr().Root_dir());
|
||||
this.load_mgr = new Xodb_load_mgr_sql(wiki, this, core_data_mgr);
|
||||
this.load_mgr = new Xodb_load_mgr_sql(this);
|
||||
this.save_mgr = new Xodb_save_mgr_sql(this);
|
||||
}
|
||||
public byte Tid() {return Tid_sql;} public String Tid_name() {return "sqlite3";} public static final byte Tid_sql = 1;
|
||||
@@ -38,7 +38,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, Gfo_invk {
|
||||
return Io_mgr.Instance.QueryFil(url).ModifiedTime();
|
||||
}
|
||||
public void Category_version_update(boolean version_is_1) {
|
||||
String grp = Xow_cfg_consts.Grp__wiki_init;
|
||||
String grp = Xowd_cfg_key_.Grp__wiki_init;
|
||||
String key = Xoa_gfs_wtr_.Write_func_chain(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_category_version);
|
||||
core_data_mgr.Tbl__cfg().Delete_val(grp, key);// always delete ctg version
|
||||
category_version = version_is_1 ? Xoa_ctg_mgr.Version_1 : Xoa_ctg_mgr.Version_2;
|
||||
|
||||
@@ -1,68 +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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
class Xodb_upgrade_mgr {
|
||||
public static void Upgrade(Xodb_mgr_sql db_mgr, Db_cfg_hash cfg_hash, String version_key, String version_val) {
|
||||
// String version_new = null;
|
||||
// if (String_.Eq(version_val, "0.6.2.0")) {
|
||||
// Xodb_upgrade_mgr_v0_6_2_0.Upgrade(db_mgr, kv_ary);
|
||||
// version_new = "0.6.2.1";
|
||||
// }
|
||||
// if (version_new != null) {
|
||||
// db_mgr.Tbl_xowa_cfg().Update(Xodb_mgr_sql.Grp__wiki_init, version_key, version_new);
|
||||
// }
|
||||
}
|
||||
}
|
||||
// class Xodb_upgrade_mgr_v0_6_2_0 {
|
||||
// public static void Upgrade(Xodb_mgr_sql db_mgr, Keyval[] kv_ary) {
|
||||
// Db_conn p = db_mgr.Fsys_mgr().Core_provider();
|
||||
// Fix_storage_format(p, db_mgr, kv_ary);
|
||||
// Fix_category_version(p, db_mgr);
|
||||
// }
|
||||
// private static void Fix_storage_format(Db_conn p, Xodb_mgr_sql db_mgr, Keyval[] kv_ary) { // storage_format saved incorrectly as int
|
||||
// int len = kv_ary.length;
|
||||
// String gfs_data_storage_format = Xoa_gfs_mgr.Build_code(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format);
|
||||
// for (int i = 0; i < len; i++) {
|
||||
// Keyval kv = kv_ary[i];
|
||||
// String kv_key = kv.Key();
|
||||
// if (String_.Eq(kv_key, gfs_data_storage_format)) {
|
||||
// byte data_storage_format_byte = Byte_.parse(kv.Val_to_str_or_empty());
|
||||
// String data_storage_format_name = Xoi_dump_mgr.Wtr_tid_to_str(data_storage_format_byte);
|
||||
// kv.Val_(data_storage_format_name); // update memory
|
||||
// db_mgr.Tbl_xowa_cfg().Update(Xodb_mgr_sql.Grp__wiki_init, gfs_data_storage_format, data_storage_format_name); // update_database
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private static void Fix_category_version(Db_conn p, Xodb_mgr_sql db_mgr) {
|
||||
// Db_qry qry = Db_qry_.select_().From_(Xodb_categorylinks_tbl.Tbl_name).Cols_(Xodb_categorylinks_tbl.Fld_cl_type_id).Where_(Db_crt_.New_eq(Xodb_categorylinks_tbl.Fld_cl_type_id, ));
|
||||
// Db_stmt stmt = Db_stmt_.Null;
|
||||
// DataRdr rdr = DataRdr_.Null;
|
||||
// int types = 0;
|
||||
// try {
|
||||
// stmt = db_mgr.Fsys_mgr().Category_provider().Prepare(qry);
|
||||
// rdr = stmt.Exec_select();
|
||||
// while (rdr.MoveNextPeer()) {
|
||||
// ++types;
|
||||
// }
|
||||
// } finally {rdr.Rls(); stmt.Rls();}
|
||||
// boolean schema_is_1 = types <= 1; // if 0 or 1 types assume version_1 (1=page only; 0=not set up)
|
||||
// db_mgr.Category_version_update(true); // assume version_1; will be wrong if user actually did version_2, but currently version_1 vs version_2 has no
|
||||
// }
|
||||
// }
|
||||
@@ -16,69 +16,78 @@ 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.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xow_wiki_props implements Gfo_invk {
|
||||
public byte[] Main_page() {return main_page;} private byte[] main_page = Xoa_page_.Main_page_bry; // HACK: default to Main_Page b/c some code tries to do Xoa_ttl.Parse() which will not work with ""; DATE:2014-02-16
|
||||
public Xow_wiki_props Main_page_(byte[] v) {main_page = v; return this;}
|
||||
public void Main_page_update(Xowe_wiki wiki) {
|
||||
siteinfo_mainpage = main_page; // note that main_page came from <siteinfo>; store old value for record's sake
|
||||
main_page = Xow_mainpage_finder.Find_or(wiki, siteinfo_mainpage); // get new main_page from mainpage_finder
|
||||
}
|
||||
public byte Protocol_tid() {return protocol_tid;} private final byte protocol_tid = gplx.core.net.Gfo_protocol_itm.Tid_https; // NOTE: default protocol to https; handles external links like [//a.org]; may need to be changed for wikia or other non-WMF wikis; DATE:2015-07-27
|
||||
public class Xow_wiki_props {
|
||||
// MW props for Pfunc_wiki_props and Scrib_lib; EX: {{SITENAME}}
|
||||
public byte[] Site_name() {return site_name;} private byte[] site_name = Bry_.Empty;
|
||||
public byte[] Server_name() {return server_name;} private byte[] server_name = Bry_.new_a7("localhost");
|
||||
public byte[] Server() {return server;} private byte[] server = Bry_.new_a7("http://localhost");
|
||||
public byte[] Article_path() {return article_path;} private byte[] article_path = Xoh_href_.Bry__wiki;
|
||||
public byte[] Script_path() {return script_path;} private byte[] script_path = Bry_.new_a7("/wiki");
|
||||
public byte[] Style_path() {return style_path;} private byte[] style_path = Bry_.new_a7("/wiki/skins");
|
||||
public byte[] Content_language() {return content_language;} private byte[] content_language = Bry_.Empty;
|
||||
public byte[] Direction_mark() {return direction_mark;} private byte[] direction_mark = Bry_.Empty;
|
||||
public byte[] Current_version() {return CURRENT_VERSION;} private static final byte[] CURRENT_VERSION = Bry_.new_a7("1.21wmf11"); // approximate level of compatibility
|
||||
|
||||
public byte[] Site_name() {return site_name;} private byte[] site_name = Bry_.Empty;
|
||||
public byte[] Server_name() {return server_name;} private byte[] server_name = Bry_.new_a7("localhost");
|
||||
public byte[] Server() {return server;} private byte[] server = Bry_.new_a7("http://localhost");
|
||||
public byte[] ArticlePath() {return articlePath;} public Xow_wiki_props ArticlePath_(byte[] v) {articlePath = v; return this;} private byte[] articlePath = Xoh_href_.Bry__wiki;
|
||||
public byte[] ScriptPath() {return scriptPath;} public Xow_wiki_props ScriptPath_(byte[] v) {scriptPath = v; return this;} private byte[] scriptPath = Bry_.new_a7("/wiki");
|
||||
public byte[] StylePath() {return stylePath;} public Xow_wiki_props StylePath_(byte[] v) {stylePath = v; return this;} private byte[] stylePath = Bry_.new_a7("/wiki/skins");
|
||||
public byte[] ContentLanguage() {return contentLanguage;} public Xow_wiki_props ContentLanguage_(byte[] v) {contentLanguage = v; return this;} private byte[] contentLanguage = Bry_.Empty;
|
||||
public byte[] DirectionMark() {return directionMark;} public Xow_wiki_props DirectionMark_(byte[] v) {directionMark = v; return this;} private byte[] directionMark = Bry_.Empty;
|
||||
public byte[] Current_version() {return Current_version_const;}
|
||||
public byte[] Bldr_version() {return bldr_version;} public Xow_wiki_props Bldr_version_(byte[] v) {bldr_version = v; return this;} private byte[] bldr_version = Bry_.Empty;
|
||||
public int Css_version() {return css_version;} public Xow_wiki_props Css_version_(int v) {css_version = v; return this;} private int css_version = 1;
|
||||
public byte[] Siteinfo_misc() {return siteinfo_misc;}
|
||||
public byte[] Siteinfo_mainpage() {return siteinfo_mainpage;} private byte[] siteinfo_mainpage = Bry_.Empty;
|
||||
public DateAdp Modified_latest() {return modified_latest;} private DateAdp modified_latest;
|
||||
public String Modified_latest__yyyy_MM_dd() {return modified_latest == null ? "" : modified_latest.XtoStr_fmt_yyyy_MM_dd();}
|
||||
public Xow_wiki_props Init_props(int domain_tid, byte[] domain_bry) {
|
||||
this.site_name = Bry_.new_a7(String_.UpperFirst(String_.new_a7(Xow_domain_tid_.Get_type_as_bry(domain_tid)))); // EX: "Wikipedia"
|
||||
this.server_name = domain_bry; // EX: "en.wikipedia.org"
|
||||
this.server = Bry_.Add(gplx.core.net.Gfo_protocol_itm.Itm_https.Text_bry(), domain_bry); // EX: "https://en.wikipedia.org"
|
||||
return this;
|
||||
// XO props
|
||||
public byte Protocol_tid() {return protocol_tid;} private final byte protocol_tid = gplx.core.net.Gfo_protocol_itm.Tid_https; // NOTE: default protocol to https; handles external links like [//a.org]; may need to be changed for wikia or other non-WMF wikis; DATE:2015-07-27
|
||||
public byte[] Main_page() {return main_page;} private byte[] main_page = Xoa_page_.Main_page_bry; // HACK: default to Main_Page b/c some code tries to do Xoa_ttl.Parse() which will not work with ""; DATE:2014-02-16
|
||||
public byte[] Bldr_version() {return bldr_version;} private byte[] bldr_version = Bry_.Empty;
|
||||
public int Css_version() {return css_version;} private int css_version = 1;
|
||||
public byte[] Siteinfo_misc() {return siteinfo_misc;} private byte[] siteinfo_misc = Bry_.Empty;
|
||||
public byte[] Siteinfo_mainpage() {return siteinfo_mainpage;} private byte[] siteinfo_mainpage = Bry_.Empty;
|
||||
public DateAdp Modified_latest() {return modified_latest;} private DateAdp modified_latest;
|
||||
public String Modified_latest__yyyy_MM_dd() {return modified_latest == null ? "" : modified_latest.XtoStr_fmt_yyyy_MM_dd();}
|
||||
|
||||
// setters
|
||||
public void ContentLanguage_ (byte[] v) {content_language = v;}
|
||||
public void Bldr_version_ (byte[] v) {bldr_version = v;}
|
||||
public void Main_page_ (byte[] v) {main_page = v;}
|
||||
public void Main_page_update_(byte[] v) {
|
||||
// old main_page comes directly from <siteinfo>; store it in siteinfo_mainpage for record's sake
|
||||
this.siteinfo_mainpage = main_page;
|
||||
|
||||
// update main_page to new_main_page
|
||||
this.main_page = v;
|
||||
}
|
||||
public Xow_wiki_props Siteinfo_misc_(byte[] v) {
|
||||
siteinfo_misc = v;
|
||||
public void Siteinfo_misc_(byte[] v) {
|
||||
this.siteinfo_misc = v;
|
||||
int pipe_0 = Bry_find_.Find_fwd(v, Byte_ascii.Pipe);
|
||||
if (pipe_0 != Bry_find_.Not_found)
|
||||
site_name = Bry_.Mid(siteinfo_misc, 0, pipe_0);
|
||||
return this;
|
||||
} private byte[] siteinfo_misc = Bry_.Empty;
|
||||
this.site_name = Bry_.Mid(siteinfo_misc, 0, pipe_0);
|
||||
}
|
||||
|
||||
// inits
|
||||
public void Init_by_ctor(int domain_tid, byte[] domain_bry) {
|
||||
// site_name is based on domain_tid; EX: "Wikipedia"
|
||||
this.site_name = Bry_.new_a7(String_.UpperFirst(String_.new_a7(Xow_domain_tid_.Get_type_as_bry(domain_tid))));
|
||||
|
||||
// server_name is domain; EX: "en.wikipedia.org"
|
||||
this.server_name = domain_bry;
|
||||
|
||||
// server_name is https: + domain EX: "https://en.wikipedia.org"
|
||||
this.server = Bry_.Add(gplx.core.net.Gfo_protocol_itm.Itm_https.Text_bry(), domain_bry);
|
||||
}
|
||||
// called by wiki.Init_by_load; leaving as separate proc b/c of "if (app.Bldr__running())"; DATE:2017-02-17
|
||||
public void Init_by_load(Xoa_app app, gplx.dbs.cfgs.Db_cfg_tbl cfg_tbl) {
|
||||
if (app.Bldr__running()) return; // never load main_page during bldr; note that Init_by_load is called by bldr cmds like css; DATE:2015-07-24
|
||||
this.main_page = cfg_tbl.Select_bry_or(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__main_page, null);
|
||||
this.modified_latest = cfg_tbl.Select_date_or(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__modified_latest, null);
|
||||
|
||||
// load from xowa_cfg
|
||||
this.main_page = cfg_tbl.Select_bry_or (Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__main_page, null);
|
||||
if (main_page == null) { // main_page not found
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "mw_props.load; main_page not found; conn=~{0}", cfg_tbl.Conn().Conn_info().Db_api());
|
||||
this.main_page = Xoa_page_.Main_page_bry;
|
||||
}
|
||||
|
||||
this.modified_latest = cfg_tbl.Select_date_or(Xowd_cfg_key_.Grp__wiki_init, Xowd_cfg_key_.Key__init__modified_latest, null);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_main_page_)) main_page = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk_bldr_version_)) bldr_version = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk_siteinfo_misc_)) Siteinfo_misc_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_siteinfo_mainpage_)) siteinfo_mainpage = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk_css_version_)) css_version = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_modified_latest_)) modified_latest = m.ReadDate("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
// called by Xodb_load_mgr_sql; note that it might be called during bldr; DATE:2017-02-17
|
||||
public void Init_by_load_2(byte[] main_page, byte[] bldr_version, byte[] siteinfo_misc, byte[] siteinfo_mainpage, DateAdp modified_latest) {
|
||||
this.main_page = main_page;
|
||||
this.bldr_version = bldr_version;
|
||||
this.siteinfo_misc = siteinfo_misc;
|
||||
this.siteinfo_mainpage = siteinfo_mainpage;
|
||||
this.modified_latest = modified_latest;
|
||||
}
|
||||
public static final String Invk_main_page_ = "main_page_"
|
||||
, Invk_bldr_version = "bldr_version", Invk_bldr_version_ = "bldr_version_", Invk_siteinfo_misc_ = "siteinfo_misc_", Invk_siteinfo_mainpage_ = "siteinfo_mainpage_"
|
||||
, Invk_css_version_ = "css_version_"
|
||||
, Invk_modified_latest_ = "modified_latest_"
|
||||
;
|
||||
private static final byte[] Current_version_const = Bry_.new_a7("1.21wmf11"); // approximate level of compatibility
|
||||
}
|
||||
|
||||
@@ -244,10 +244,10 @@ public class Xow_ns_mgr implements Gfo_invk, gplx.core.lists.ComparerAble {
|
||||
public Xow_ns Ns() {return ns;} private Xow_ns ns;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_load)) Xow_cfg_wiki_core.Load_ns_(this, m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
// NOTE: called by /xowa/bin/any/xowa/cfg/wiki/core/*.gfs for (a) aliases; (b) Subpages_enabled
|
||||
else if (ctx.Match(k, Invk_add_alias_bulk)) Exec_add_alias_bulk(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_get_by_id_or_new)) return this.Ids_get_or_empty(m.ReadInt("v")); // NOTE: called by #cfg files for setting Subpages_enabled; if ns doesn't exist, returning empty is fine; DATE:2014-02-15
|
||||
else if (ctx.Match(k, Invk_get_by_id_or_new)) return this.Ids_get_or_empty(m.ReadInt("v")); // NOTE: if ns doesn't exist, returning empty is fine; DATE:2014-02-15
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_add_alias_bulk = "add_alias_bulk", Invk_get_by_id_or_new = "get_by_id_or_new";
|
||||
|
||||
Reference in New Issue
Block a user