mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
@@ -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.wikis; import gplx.*; import gplx.xowa.*;
|
||||
public interface Xoa_wiki_mgr {
|
||||
public interface Xoa_wiki_mgr extends Gfo_invk {
|
||||
int Count();
|
||||
boolean Has(byte[] key);
|
||||
Xow_wiki Get_at(int idx);
|
||||
|
||||
@@ -26,8 +26,12 @@ public class Xoa_wiki_mgr_ {
|
||||
Io_url wiki_root_dir = url.OwnerDir();
|
||||
Xow_wiki rv = wiki_mgr.Make(wiki_domain, wiki_root_dir);
|
||||
wiki_mgr.Add(rv);
|
||||
// byte[] modified_last = cfg_tbl.Select_bry(Xow_cfg_consts.Grp__wiki_init, "props.modified_latest");
|
||||
app.User().User_db_mgr().Site_mgr().Import(rv.Domain_str(), rv.Domain_str(), wiki_root_dir.Raw(), "");
|
||||
rv.Init_by_wiki(); // must init for Modified_latest
|
||||
String wiki_date = rv.Props().Modified_latest__yyyy_MM_dd();
|
||||
app.User().User_db_mgr().Site_mgr().Import(rv.Domain_str(), rv.Domain_str(), wiki_root_dir.Raw(), wiki_date, "");
|
||||
conn.Rls_conn();
|
||||
rv.Init_needed_y_(); // rls wiki else noop connection will hang around
|
||||
return rv;
|
||||
}
|
||||
public static final String Invk__import_by_url = "import_by_url";
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ 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.*; import gplx.xowa.wikis.domains.crts.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*;
|
||||
public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk {
|
||||
private final Xoae_app app;
|
||||
private final List_adp list = List_adp_.new_(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
private final List_adp list = List_adp_.New(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
public Xoae_wiki_mgr(Xoae_app app) {
|
||||
this.app = app;
|
||||
this.wiki_regy = new Xoa_wiki_regy(app);
|
||||
@@ -94,12 +94,13 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
}
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get_by_or_make(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_scripts)) return scripts;
|
||||
else if (ctx.Match(k, Invk_wdata)) return wdata_mgr;
|
||||
else if (ctx.Match(k, Invk_len)) return this.Count();
|
||||
else if (ctx.Match(k, Invk_get_at)) return this.Get_at_or_null(m.ReadInt("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
if (ctx.Match(k, Invk_get)) return Get_by_or_make(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_scripts)) return scripts;
|
||||
else if (ctx.Match(k, Invk_wdata)) return wdata_mgr;
|
||||
else if (ctx.Match(k, Invk_len)) return this.Count();
|
||||
else if (ctx.Match(k, Invk_get_at)) return this.Get_at_or_null(m.ReadInt("v"));
|
||||
else if (ctx.Match(k, Xoa_wiki_mgr_.Invk__import_by_url)) return this.Import_by_url(m.ReadIoUrl("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_get = "get", Invk_scripts = "scripts", Invk_wdata = "wdata";
|
||||
private static final String Invk_len = "len", Invk_get_at = "get_at";
|
||||
}
|
||||
|
||||
@@ -20,47 +20,7 @@ public class Xow_fsys_mgr {
|
||||
public Xow_fsys_mgr(Io_url root_dir, Io_url file_dir) {
|
||||
this.root_dir = root_dir; this.file_dir = file_dir; this.tmp_dir = root_dir.GenSubDir("tmp");
|
||||
}
|
||||
public Io_url Root_dir() {return root_dir;} private final Io_url root_dir;
|
||||
public Io_url File_dir() {return file_dir;} private final Io_url file_dir;
|
||||
public Io_url Tmp_dir() {return tmp_dir;} private final Io_url tmp_dir;
|
||||
|
||||
public static Io_url Find_core_fil(Xow_wiki wiki) {return Find_core_fil(wiki.Fsys_mgr().Root_dir(), wiki.Domain_str());}
|
||||
public static Io_url Find_core_fil(Io_url wiki_root_dir, String domain_str) {
|
||||
Io_url[] ary = Io_mgr.Instance.QueryDir_fils(wiki_root_dir);
|
||||
int ary_len = ary.length; if (ary.length == 0) return null;
|
||||
Io_url rv = Find_core_fil__xowa(ary, ary_len, domain_str);
|
||||
return rv == null ? Find_core_fil__sqlite3(wiki_root_dir, ary, ary_len, domain_str) : rv;
|
||||
}
|
||||
private static Io_url Find_core_fil__xowa(Io_url[] ary, int ary_len, String domain_str) {
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Io_url itm = ary[i];
|
||||
if (!String_.Eq(itm.Ext(), ".xowa")) continue;
|
||||
if ( String_.Eq(itm.NameOnly(), domain_str) // EX: "en.wikipedia.org"
|
||||
|| String_.Eq(itm.NameOnly(), domain_str + "-text") // EX: "en.wikipedia.org-text"
|
||||
|| String_.Eq(itm.NameOnly(), domain_str + "-core") // EX: "en.wikipedia.org-core"
|
||||
) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.v2: url=~{0}", itm.Raw());
|
||||
return itm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static Io_url Find_core_fil__sqlite3(Io_url wiki_root_dir, Io_url[] ary, int ary_len, String domain_str) {
|
||||
Io_url rv = null;
|
||||
String v0_str = domain_str + ".000";
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Io_url itm = ary[i];
|
||||
if (!String_.Eq(itm.Ext(), ".sqlite3")) continue;
|
||||
if (String_.Eq(itm.NameOnly(), v0_str)) { // EX: "en.wikipedia.org.000"
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.v1: url=~{0}", itm.Raw());
|
||||
return itm;
|
||||
}
|
||||
if (ary_len == 1) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.custom: url=~{0}", itm.Raw());
|
||||
return rv; // 1 folder and 1 sqlite file; return it; custom wikis?
|
||||
}
|
||||
}
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.none: dir=~{0}", wiki_root_dir.Raw());
|
||||
return rv;
|
||||
}
|
||||
public Io_url Root_dir() {return root_dir;} private final Io_url root_dir;
|
||||
public Io_url File_dir() {return file_dir;} private final Io_url file_dir;
|
||||
public Io_url Tmp_dir() {return tmp_dir;} private final Io_url tmp_dir;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.files.repos.*;
|
||||
public class Xowv_repo_mgr implements Xow_repo_mgr {
|
||||
private final List_adp repos = List_adp_.new_();
|
||||
private final List_adp repos = List_adp_.New();
|
||||
public Xof_repo_pair[] Repos_ary() {return (Xof_repo_pair[])repos.To_ary(Xof_repo_pair.class);}
|
||||
public Xof_repo_pair Repos_get_by_wiki(byte[] wiki) {
|
||||
int len = repos.Count();
|
||||
|
||||
@@ -23,13 +23,14 @@ import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.bins.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.addons.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.css.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.addons.apps.specials.*;
|
||||
public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
import gplx.xowa.specials.mgrs.*;
|
||||
import gplx.xowa.addons.wikis.htmls.css.bldrs.*; import gplx.xowa.addons.wikis.htmls.css.mgrs.*;
|
||||
public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
private final Xof_fsdb_mgr__sql fsdb_mgr; private Fsdb_db_mgr db_core_mgr;
|
||||
private boolean init_needed = true;
|
||||
public Xowv_wiki(Xoav_app app, byte[] domain_bry, Io_url wiki_root_dir) {
|
||||
@@ -56,7 +57,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
public byte[] Domain_abrv() {return domain_abrv;} private final byte[] domain_abrv;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public Xow_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xow_fsys_mgr fsys_mgr;
|
||||
public Xowd_db_mgr Data__core_mgr() {return data_mgr__core_mgr;} private Xowd_db_mgr data_mgr__core_mgr;
|
||||
public Xow_db_mgr Data__core_mgr() {return data_mgr__core_mgr;} private Xow_db_mgr data_mgr__core_mgr;
|
||||
public Xow_repo_mgr File__repo_mgr() {return file_mgr__repo_mgr;} private Xowv_repo_mgr file_mgr__repo_mgr = new Xowv_repo_mgr();
|
||||
public Xof_fsdb_mode File__fsdb_mode() {return file_mgr__fsdb_mode;} private final Xof_fsdb_mode file_mgr__fsdb_mode = Xof_fsdb_mode.new_v2_gui();
|
||||
public Fsdb_db_mgr File__fsdb_core() {return db_core_mgr;}
|
||||
@@ -74,30 +75,33 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
public Xow_site_stats_mgr Stats() {return stats;} private final Xow_site_stats_mgr stats;
|
||||
public Xow_url_parser Utl__url_parser() {return url__parser;} private final Xow_url_parser url__parser;
|
||||
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
|
||||
public Xosp_special_mgr Special_mgr() {return special_mgr;} private Xosp_special_mgr special_mgr;
|
||||
public Xosp_special_mgr Special_mgr() {return special_mgr;} private Xosp_special_mgr special_mgr;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private final Xow_xwiki_mgr xwiki_mgr;
|
||||
public Xoav_app Appv() {return app;} private final Xoav_app app;
|
||||
public void Init_by_wiki() {
|
||||
if (!init_needed) return;
|
||||
init_needed = false;
|
||||
if (String_.Eq(domain_str, "xowa")) return; // FIXME: ignore "xowa" for now; WHEN:converting xowa to sqlitedb
|
||||
data_mgr__core_mgr = new Xowd_db_mgr(this, fsys_mgr.Root_dir(), domain_itm);
|
||||
Io_url core_url = gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(fsys_mgr.Root_dir(), domain_str);
|
||||
data_mgr__core_mgr.Init_by_load(core_url);
|
||||
if (String_.Eq(domain_str, "xowa")) return; // HACK: ignore "xowa" for now; WHEN:converting xowa to sqlitedb
|
||||
data_mgr__core_mgr = new Xow_db_mgr(this, fsys_mgr.Root_dir());
|
||||
data_mgr__core_mgr.Init_by_load(gplx.xowa.wikis.data.Xow_db_file__core_.Find_core_fil(this));
|
||||
app.Html__css_installer().Install(this, Xowd_css_core_mgr.Key_mobile); // must init after data_mgr
|
||||
this.db_core_mgr = Fsdb_db_mgr_.new_detect(this, fsys_mgr.Root_dir(), fsys_mgr.File_dir());
|
||||
if (db_core_mgr != null) // will be null for xowa db
|
||||
if (db_core_mgr == null) // no fsdb; occurs during merge; also, will be null for xowa_db; DATE:2016-05-31
|
||||
db_core_mgr = Fsdb_db_mgr__v2_bldr.Get_or_make(this, true);
|
||||
else // fsdb exists; load it
|
||||
fsdb_mgr.Mnt_mgr().Ctor_by_load(db_core_mgr);
|
||||
file_mgr__repo_mgr.Add_repo(app, fsys_mgr.File_dir(), Xow_domain_itm_.Bry__commons, Xow_domain_itm_.Bry__commons);
|
||||
file_mgr__repo_mgr.Add_repo(app, fsys_mgr.File_dir(), domain_bry, domain_bry);
|
||||
orig_mgr.Init_by_wiki(this, file_mgr__fsdb_mode, db_core_mgr.File__orig_tbl_ary(), Xof_url_bldr.new_v2());
|
||||
Xof_orig_tbl[] orig_tbls = db_core_mgr == null ? new Xof_orig_tbl[0] : db_core_mgr.File__orig_tbl_ary();
|
||||
orig_mgr.Init_by_wiki(this, file_mgr__fsdb_mode, orig_tbls, Xof_url_bldr.new_v2());
|
||||
fsdb_mgr.Init_by_wiki(this);
|
||||
data_mgr__core_mgr.Db__core().Tbl__ns().Select_all(ns_mgr);
|
||||
data_mgr__core_mgr.Db__core().Tbl__site_stats().Select(stats);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
}
|
||||
public void Init_by_wiki__force() {init_needed = true; Init_by_wiki();}
|
||||
public void Init_by_make(Xowd_core_db_props props, gplx.xowa.bldrs.infos.Xob_info_session info_session) {
|
||||
data_mgr__core_mgr = new Xowd_db_mgr(this, fsys_mgr.Root_dir(), domain_itm);
|
||||
data_mgr__core_mgr = new Xow_db_mgr(this, fsys_mgr.Root_dir());
|
||||
data_mgr__core_mgr.Init_by_make(props, info_session);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
}
|
||||
@@ -115,5 +119,6 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
byte[] raw = Bry_.Add(ns.Name_db_w_colon(), ttl);
|
||||
return Xoa_ttl.parse(app.Utl__bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), raw, 0, raw.length);
|
||||
}
|
||||
public void Init_needed_y_() {this.init_needed = true;}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {throw Err_.new_unimplemented_w_msg("implemented for Xoa_cfg_mgr");}
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ public class Xow_cache_mgr {
|
||||
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
|
||||
public Xow_defn_cache Defn_cache() {return defn_cache;} private Xow_defn_cache defn_cache;
|
||||
public Xow_defn_cache Lst_cache() {return lst_cache;} private Xow_defn_cache lst_cache;
|
||||
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.new_();
|
||||
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New();
|
||||
public Keyval[] Scrib_lang_names() {
|
||||
if (scrib_lang_names == null) {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
Xoa_sitelink_itm_mgr itm_mgr = wiki.App().Xwiki_mgr__sitelink_mgr().Itm_mgr();
|
||||
int len = itm_mgr.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xow_defn_cache { // stores compiled Xot_defn
|
||||
private Xol_lang_itm lang; // needed to lowercase names;
|
||||
private Bry_bfr upper_1st_bfr = Bry_bfr.reset_(255);
|
||||
private Bry_bfr upper_1st_bfr = Bry_bfr_.Reset(255);
|
||||
private Gfo_cache_mgr cache = new Gfo_cache_mgr().Max_size_(64 * 1024 * 1024).Reduce_by_(32 * 1024 * 1024);
|
||||
public Xow_defn_cache(Xol_lang_itm lang) {this.lang = lang;}
|
||||
public Xot_defn Get_by_key(byte[] name) {return (Xot_defn)cache.Get_by_key(name);}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xow_page_cache {
|
||||
byte[] ttl_full_db = ttl.Full_db();
|
||||
Xow_page_cache_itm rv = (Xow_page_cache_itm)cache.Get_by_bry(ttl_full_db);
|
||||
if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Get_page(ttl, true); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if (!page.Missing()) {
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Data_raw(), page.Redirected_src());
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
@@ -36,5 +36,18 @@ public class Xow_page_cache {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xow_page_cache_itm Get_or_load_as_itm_2(Xoa_ttl ttl) { // NOTE: same as Get_or_load_as_itm, but handles redirects to missing pages; DATE:2016-05-02
|
||||
byte[] ttl_full_db = ttl.Full_db();
|
||||
Xow_page_cache_itm rv = (Xow_page_cache_itm)cache.Get_by_bry(ttl_full_db);
|
||||
if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if ( !page.Missing() // page exists
|
||||
|| page.Redirected_src() != null) { // page redirects to missing page; note that page.Missing == true and page.Redirected_src() != null; PAGE: en.w:Shah_Rukh_Khan; DATE:2016-05-02
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Data_raw(), page.Redirected_src());
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Free_mem_all() {cache.Clear();}
|
||||
}
|
||||
|
||||
@@ -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.wikis.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoa_ctg_mgr implements GfoInvkAble {
|
||||
public class Xoa_ctg_mgr implements Gfo_invk {
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
pagectgs_wtr = new Xoctg_pagelist_wtr().Init_by_app(app);
|
||||
}
|
||||
@@ -37,13 +37,13 @@ public class Xoa_ctg_mgr implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_missing_ctg_cls_list)) return Options_missing_ctg_cls_list;
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled)) return Yn.To_str(pagecats_grouping_enabled);
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled_)) pagecats_grouping_enabled = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_missing_ctg_cls = "missing_ctg_cls", Invk_missing_ctg_cls_ = "missing_ctg_cls_", Invk_missing_ctg_cls_list = "missing_ctg_cls_list", Invk_pagecats_grouping_enabled = "pagecats_grouping_enabled", Invk_pagecats_grouping_enabled_ = "pagecats_grouping_enabled_";
|
||||
private static final byte Missing_ctg_cls_normal_tid = 0, Missing_ctg_cls_hide_tid = 1, Missing_ctg_cls_red_tid = 2;
|
||||
private static final String Missing_ctg_cls_normal_str = "normal", Missing_ctg_cls_hide_str = "hide", Missing_ctg_cls_red_str = "red_link";
|
||||
private static final byte[] Missing_ctg_cls_normal_css = Bry_.new_a7(".xowa-missing-category-entry {}"), Missing_ctg_cls_hide_css = Bry_.new_a7(".xowa-missing-category-entry {display: none;}"), Missing_ctg_cls_red_css = Bry_.new_a7(".xowa-missing-category-entry {color: red;}");
|
||||
private static final byte[] Missing_ctg_cls_normal_css = Bry_.new_a7(".xowa-missing-category-entry {}"), Missing_ctg_cls_hide_css = Bry_.new_a7(".xowa-missing-category-entry {display: none;}"), Missing_ctg_cls_red_css = Bry_.new_a7(".xowa-missing-category-entry {color: red;}");
|
||||
private static Keyval[] Options_missing_ctg_cls_list = Keyval_.Ary(Keyval_.new_(Missing_ctg_cls_normal_str), Keyval_.new_(Missing_ctg_cls_hide_str), Keyval_.new_(Missing_ctg_cls_red_str));
|
||||
private static byte Missing_ctg_cls_tid_parse(String v) {
|
||||
if (String_.Eq(v, Missing_ctg_cls_normal_str)) return Missing_ctg_cls_normal_tid;
|
||||
@@ -63,5 +63,5 @@ public class Xoa_ctg_mgr implements GfoInvkAble {
|
||||
public static final byte Tid_null = Byte_.Max_value_127, Tid_subc = 0, Tid_file = 1, Tid_page = 2, Tid__max = 3;
|
||||
public static final byte Hidden_n = Byte_.Zero, Hidden_y = (byte)1;
|
||||
public static final String Html__cls__str = "CategoryTreeLabel CategoryTreeLabelNs14 CategoryTreeLabelCategory";
|
||||
public static final byte[] Html__cls__bry = Bry_.new_a7(Html__cls__str);
|
||||
public static final byte[] Html__cls__bry = Bry_.new_a7(Html__cls__str);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
public class Xoctg_html_mgr implements Gfo_invk {
|
||||
@gplx.Internal protected Xoctg_fmtr_grp Fmtr_grp() {return fmtr_grp;} private Xoctg_fmtr_grp fmtr_grp = new Xoctg_fmtr_grp();
|
||||
private final Xoctg_fmtr_all mgr_subcs = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_subc);
|
||||
private final Xoctg_fmtr_all mgr_pages = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_page);
|
||||
@@ -72,7 +72,7 @@ public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
}
|
||||
itm.Set__ttl__sortkey(itm_ttl, itm.Sort_key());
|
||||
}
|
||||
} List_adp title_list = List_adp_.new_(); static final byte[] Bry_missing = Bry_.new_a7("missing");
|
||||
} List_adp title_list = List_adp_.New(); static final byte[] Bry_missing = Bry_.new_a7("missing");
|
||||
private void Add_titles(List_adp title_list, Xoctg_view_grp grp) {
|
||||
int len = grp.Itms().length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
@@ -114,7 +114,7 @@ public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_grp_max)) return mgr_subcs.Grp_max();
|
||||
else if (ctx.Match(k, Invk_grp_max_)) {int grp_max = m.ReadInt("v"); mgr_subcs.Grp_max_(grp_max); mgr_files.Grp_max_(grp_max); mgr_pages.Grp_max_(grp_max);}
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_grp_max = "grp_max", Invk_grp_max_ = "grp_max_";
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.flds.*;
|
||||
public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
List_adp itms = List_adp_.new_();
|
||||
public class Xoctg_idx_mgr implements Gfo_invk {
|
||||
List_adp itms = List_adp_.New();
|
||||
public int Block_len() {return block_len;} public Xoctg_idx_mgr Block_len_(int v) {this.block_len = v; return this;} private int block_len = Io_mgr.Len_mb;
|
||||
public int Itms_len() {return itms.Count();}
|
||||
public Xoctg_idx_itm Itms_get_at(int i) {return (Xoctg_idx_itm)itms.Get_at(i);}
|
||||
@@ -147,11 +147,11 @@ public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
last_plus_one.Parse(fld_rdr.Pos_(tmp_pos), tmp_pos);
|
||||
}
|
||||
}
|
||||
} Int_obj_ref find_rslt = Int_obj_ref.zero_();
|
||||
} Int_obj_ref find_rslt = Int_obj_ref.New_zero();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_block_len)) return block_len;
|
||||
else if (ctx.Match(k, Invk_block_len_)) block_len = m.ReadInt("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_block_len = "block_len", Invk_block_len_ = "block_len_";
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Xoctg_idx_mgr_fxt {
|
||||
idx_mgr = new Xoctg_idx_mgr();
|
||||
}
|
||||
return this;
|
||||
} private Xoae_app app; Xowe_wiki wiki; Xoctg_idx_mgr idx_mgr; static final byte[] Ctg_name = Bry_.new_a7("Ctg_test");
|
||||
} private Xoae_app app; Xowe_wiki wiki; Xoctg_idx_mgr idx_mgr; static final byte[] Ctg_name = Bry_.new_a7("Ctg_test");
|
||||
public byte[] Make_src(int len) {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_k004().Mkr_rls();
|
||||
bfr.Add_byte_pipe(); // always have leading pipe
|
||||
@@ -108,7 +108,7 @@ class Xoctg_idx_mgr_fxt {
|
||||
Tfds.Eq(expd, String_.new_a7(rslt.Sortkey()));
|
||||
Tfds.Eq(expd_comp, comp_rslt.Val());
|
||||
return this;
|
||||
} Int_obj_ref comp_rslt = Int_obj_ref.zero_();
|
||||
} Int_obj_ref comp_rslt = Int_obj_ref.New_zero();
|
||||
public Xoctg_idx_mgr_fxt Test_find_itm_near_bmk(int idx_bgn, String find, int bmk_comp, boolean find_dir, String expd) {
|
||||
int idx_pos = (idx_bgn * Xoctg_idx_mgr_tst.Itm_len) + (bmk_comp == CompareAble_.Less ? 1 : 0);
|
||||
Xoctg_idx_itm rslt = idx_mgr.Find_itm_near_bmk(src, src_len, Bry_.new_a7(find), find_dir, bmk_comp, idx_pos);
|
||||
@@ -117,7 +117,7 @@ class Xoctg_idx_mgr_fxt {
|
||||
return this;
|
||||
}
|
||||
public Xoctg_idx_mgr_fxt Test_find(String find, boolean fill_at_bgn, String[] expd_ary, String last_plus_one) {
|
||||
if (tmp_list == null) tmp_list = List_adp_.new_();
|
||||
if (tmp_list == null) tmp_list = List_adp_.New();
|
||||
idx_mgr.Index(Gfo_usr_dlg_.Test(), Bry_.Empty, src);
|
||||
tmp_list.Clear();
|
||||
idx_mgr.Find(tmp_list, src, fill_at_bgn, Bry_.new_a7(find), 3, tmp_last_plus_one);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xoctg_pagelist_itms implements gplx.core.brys.Bfr_arg {
|
||||
this.fmtr_itm = fmtr_itm;
|
||||
}
|
||||
public void Init_wiki(Xowe_wiki wiki, Xoh_wtr_ctx hctx) {this.wiki = wiki; this.hctx = hctx;} private Xowe_wiki wiki; private Xoh_wtr_ctx hctx;
|
||||
public void Itms_clear() {itms.Clear();} private List_adp itms = List_adp_.new_();
|
||||
public void Itms_clear() {itms.Clear();} private List_adp itms = List_adp_.New();
|
||||
public void Itms_add(Xowd_page_itm page) {itms.Add(page);}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int len = itms.Count();
|
||||
|
||||
@@ -76,9 +76,9 @@ class Xoctg_pagelist_mgr_fxt {
|
||||
page.Ttl_page_db_(Bry_.new_a7(ttl));
|
||||
init_ctgs.Add_many(page);
|
||||
}
|
||||
} private List_adp init_ctgs = List_adp_.new_();
|
||||
} private List_adp init_ctgs = List_adp_.New();
|
||||
public void Test_print_hidden(String expd) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xowd_page_itm[] page_ary = (Xowd_page_itm[])init_ctgs.To_ary_and_clear(Xowd_page_itm.class);
|
||||
hidden_wtr.Print_hidden(bfr, fxt.Wiki(), page_ary, gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Basic);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
|
||||
@@ -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.wikis.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.net.qargs.*;
|
||||
public class Xoctg_url {
|
||||
public byte[][] Grp_idxs() {return grp_idxs;} private byte[][] grp_idxs = new byte[3][];
|
||||
public byte[] Grp_fwds() {return grp_fwds;} private byte[] grp_fwds = new byte[3];
|
||||
@@ -59,7 +59,7 @@ public class Xoctg_url {
|
||||
}
|
||||
}
|
||||
public static final byte Tid_all_bgn = 0, Tid_subc_bgn = 1, Tid_subc_end = 2, Tid_file_bgn = 3, Tid_file_end = 4, Tid_page_bgn = 5, Tid_page_end = 6, Tid_all_end = 8;
|
||||
public static final Hash_adp_bry Arg_keys = Hash_adp_bry.ci_a7()
|
||||
public static final Hash_adp_bry Arg_keys = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_from, Tid_all_bgn)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_until, Tid_all_end)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_subc_bgn, Tid_subc_bgn)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xoctg_view_grp {
|
||||
return rv;
|
||||
}
|
||||
public void Itms_add(Xoctg_view_itm sub) {tmp_list.Add(sub);}
|
||||
public List_adp Itms_list() {return tmp_list;} List_adp tmp_list = List_adp_.new_();
|
||||
public List_adp Itms_list() {return tmp_list;} List_adp tmp_list = List_adp_.New();
|
||||
public void Itms_make() {itms = (Xoctg_view_itm[])tmp_list.To_ary(Xoctg_view_itm.class);}
|
||||
public byte[] Itms_last_sortkey() {return itms_last_sortkey;} public Xoctg_view_grp Itms_last_sortkey_(byte[] v) {itms_last_sortkey = v; return this;} private byte[] itms_last_sortkey;
|
||||
}
|
||||
|
||||
@@ -1,146 +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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.lists.*; /*ComparerAble*/ import gplx.xowa.bldrs.cmds.ctgs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xow_data_mgr implements GfoInvkAble {
|
||||
private Xop_redirect_mgr redirect_mgr;
|
||||
private Xoa_url tmp_url = Xoa_url.blank();
|
||||
public Xow_data_mgr(Xowe_wiki wiki) {this.wiki = wiki; this.redirect_mgr = wiki.Redirect_mgr();}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public boolean Version_is_1() {return Bool_.Y;}
|
||||
public Xoae_page Get_page(Xoa_ttl ttl, boolean called_from_tmpl) {tmp_url = wiki.Utl__url_parser().Parse(ttl.Raw()); return Get_page(tmp_url, ttl, called_from_tmpl, false);}
|
||||
public Xoae_page Get_page_from_msg(Xoa_ttl ttl) {tmp_url = wiki.Utl__url_parser().Parse(ttl.Raw()); return Get_page(tmp_url, ttl, false, true);}
|
||||
public Xoae_page Get_page(Xoa_url url, Xoa_ttl ttl, boolean called_from_tmpl, boolean called_from_msg) {
|
||||
Xoae_page rv = Xoae_page.New(wiki, ttl);
|
||||
return Get_page(rv, url, ttl, called_from_tmpl, called_from_msg);
|
||||
}
|
||||
public Xoae_page Get_page(Xoae_page rv, Xoa_url url, Xoa_ttl ttl, boolean called_from_tmpl, boolean called_from_msg) {
|
||||
rv.Url_(url); // NOTE: must update page.Url(); should combine with Xoae_page.New()
|
||||
Xow_ns ns = ttl.Ns();
|
||||
switch (ns.Id()) {
|
||||
case Xow_ns_.Tid__special:
|
||||
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
|
||||
return rv;
|
||||
case Xow_ns_.Tid__mediawiki:
|
||||
if ( !called_from_msg // if called from msg, fall through to actual data retrieval below, else infinite loop; DATE:2014-05-09
|
||||
&& Xow_page_tid.Identify_by_ttl(ttl.Page_db()) == Xow_page_tid.Tid_wikitext // skip ".js" and ".css" pages in MediaWiki; DATE:2014-06-13
|
||||
) {
|
||||
Xol_lang_itm lang = wiki.Lang();
|
||||
byte[] msg_key = ttl.Page_db();
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
msg_key = lang.Case_mgr().Case_build_1st_lower(tmp_bfr, msg_key, 0, msg_key.length);
|
||||
byte[] msg_val = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, wiki.Lang(), msg_key).Val(); // NOTE: do not change to Get_msg_val; Get_msg_val, also replaces $1 with values, and $1 needs to be preserved for callers;
|
||||
rv.Data_raw_(msg_val);
|
||||
tmp_bfr.Mkr_rls();
|
||||
return rv;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return Get_page(rv, ns, ttl, called_from_tmpl, url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
|
||||
}
|
||||
public Xoae_page Get_page(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean called_from_tmpl, boolean redirect_force) {
|
||||
int redirects = 0;
|
||||
Xowd_page_itm db_page = Xowd_page_itm.new_tmp();
|
||||
while (true) {
|
||||
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(db_page, ns, ttl.Page_db());
|
||||
if (!exists) return rv.Missing_();
|
||||
if (wiki.App().Mode().Tid_is_gui()) // NOTE: must check if gui, else will write during mass build; DATE:2014-05-03
|
||||
wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "file_load", "loading page for ~{0}", String_.new_u8(ttl.Raw()));
|
||||
wiki.Db_mgr().Load_mgr().Load_page(db_page, ns, !called_from_tmpl);
|
||||
byte[] bry = db_page.Text();
|
||||
rv.Data_raw_(bry).Revision_data().Modified_on_(db_page.Modified_on()).Id_(db_page.Id()).Html_db_id_(db_page.Html_db_id());
|
||||
if (redirect_force) return rv;
|
||||
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(bry);
|
||||
if ( redirect_ttl == null // not a redirect
|
||||
|| redirects++ > 4) // too many redirects; something went wrong
|
||||
break;
|
||||
rv.Redirected_ttls().Add(ttl.Full_url()); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
if (rv.Redirected_src() == null) rv.Redirected_src_(bry); // only add src for first redirect; DATE:2014-07-11
|
||||
rv.Ttl_(redirect_ttl);
|
||||
ns = redirect_ttl.Ns();
|
||||
ttl = redirect_ttl;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xoae_page Load_page_by_ttl(Xoa_url url, Xoa_ttl ttl) {return Load_page_by_ttl(url, ttl, wiki.Lang(), wiki.Appe().Gui_mgr().Browser_win().Active_tab(), true);}
|
||||
public Xoae_page Load_page_by_ttl(Xoa_url url, Xoa_ttl ttl, Xog_tab_itm tab) {return Load_page_by_ttl(url, ttl, wiki.Lang(), tab, true);}
|
||||
public Xoae_page Load_page_by_ttl(Xoa_url url, Xoa_ttl ttl, Xol_lang_itm lang, Xog_tab_itm tab, boolean parse_page) {
|
||||
wiki.Init_assert();
|
||||
Xoae_page page = Xoae_page.New(wiki, ttl); page.Tab_data().Tab_(tab);
|
||||
this.Get_page(page, url, ttl, false, false); // get page from data_mgr
|
||||
if (page.Missing()) { // page doesn't exist
|
||||
boolean vnt_missing = true;
|
||||
Xol_vnt_mgr vnt_mgr = lang.Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) { // if vnt enabled, then try to load by vnt form; DATE:2015-09-15
|
||||
gplx.xowa.wikis.data.tbls.Xowd_page_itm page_itm = vnt_mgr.Convert_mgr().Convert_ttl(wiki, ttl);
|
||||
if (page_itm != null && page_itm.Exists()) {
|
||||
Xoa_ttl vnt_ttl = Xoa_ttl.parse(wiki, ttl.Ns().Id(), page_itm.Ttl_page_db());
|
||||
page = this.Get_page(vnt_ttl, false);
|
||||
vnt_missing = page.Missing();
|
||||
}
|
||||
}
|
||||
if (vnt_missing) {
|
||||
if (ttl.Ns().Id_is_file()) {
|
||||
Xowe_wiki commons_wiki = (Xowe_wiki)wiki.Appe().Wiki_mgr().Get_by_or_null(wiki.Commons_wiki_key());
|
||||
if (commons_wiki != null) { // commons exists
|
||||
if (!Bry_.Eq(wiki.Domain_bry(), commons_wiki.Domain_bry())) { // !Bry_.Eq is recursion guard
|
||||
Xoae_page rv = commons_wiki.Data_mgr().Load_page_by_ttl(url, ttl, wiki.Lang(), tab, true);
|
||||
if (rv.Exists()) {
|
||||
rv.Commons_mgr().Source_wiki_(wiki);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
page.Missing_(false);
|
||||
page.Commons_mgr().Xowa_mockup_(true);
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return page.Missing_();
|
||||
}
|
||||
}
|
||||
if (page.Missing()) return page; // NOTE: commons can return null page
|
||||
page.Tab_data().Tab_(tab);
|
||||
page.Lang_(lang);
|
||||
if (parse_page)
|
||||
wiki.Parser_mgr().Parse(page, false); // NOTE: do not clear page b/c reused for search
|
||||
return page;
|
||||
}
|
||||
public Xoae_page Redirect(Xoae_page page, byte[] page_bry) {
|
||||
Xoa_ttl trg_ttl = Xoa_ttl.parse(wiki, page_bry);
|
||||
Xoa_url trg_url = Xoa_url.new_(wiki.Domain_bry(), page_bry);
|
||||
page.Ttl_(trg_ttl).Url_(trg_url).Redirected_(true);
|
||||
return wiki.Data_mgr().Get_page(page, trg_ttl.Ns(), trg_ttl, false, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
|
||||
}
|
||||
public static final int File_idx_unknown = -1;
|
||||
static final String GRP_KEY = "xowa.wiki.data";
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_create_enabled_)) wiki.Db_mgr().Save_mgr().Create_enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_update_modified_on_enabled_)) wiki.Db_mgr().Save_mgr().Update_modified_on_enabled_(m.ReadYn("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_create_enabled_ = "create_enabled_", Invk_update_modified_on_enabled_ = "update_modified_on_enabled_";
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class Xow_data_mgr_tst {
|
||||
;
|
||||
}
|
||||
@Test public void Update_zip() {
|
||||
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Tid__main].Ext_tid_(gplx.core.ios.Io_stream_.Tid_zip);
|
||||
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Tid__main].Ext_tid_(gplx.core.ios.streams.Io_stream_.Tid_zip);
|
||||
// fxt.Wiki().Data_mgr().Zip_mgr_(new Io_zip_mgr_mok());
|
||||
// fxt .Create("A1", "A1 data")
|
||||
// .Create("B12", "B12 data")
|
||||
|
||||
@@ -18,10 +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.wikis.data.tbls.*; import gplx.xowa.bldrs.infos.*;
|
||||
import gplx.xowa.wikis.data.site_stats.*;
|
||||
import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.addons.apps.searchs.dbs.*;
|
||||
public class Xowd_db_file {
|
||||
Xowd_db_file(Db_cfg_tbl cfg_tbl, Xob_info_session info_session, Xob_info_file info_file, Xowd_core_db_props props, Xowd_db_file_schema_props schema_props, int id, byte tid, Io_url url, String ns_ids, int part_id, Guid_adp guid, Db_conn conn, byte cmd_mode) {
|
||||
this.id = id; this.tid = tid; this.url = url; this.ns_ids = ns_ids; this.part_id = part_id; this.guid = guid; this.db_props = props; this.schema_props = schema_props;
|
||||
import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.addons.wikis.searchs.dbs.*;
|
||||
import gplx.xowa.addons.wikis.htmls.css.dbs.*;
|
||||
public class Xow_db_file {
|
||||
protected Xow_db_file(Db_cfg_tbl cfg_tbl, Xowd_core_db_props props, Xob_info_session info_session, Xob_info_file info_file, Xow_db_file_schema_props schema_props, int id, byte tid, Io_url url, String ns_ids, int part_id, Guid_adp guid, Db_conn conn, byte cmd_mode) {
|
||||
this.id = id; this.tid = tid; this.url = url; this.ns_ids = ns_ids; this.part_id = part_id; this.guid = guid; this.db_props = props;
|
||||
this.conn = conn; this.cmd_mode = cmd_mode;
|
||||
this.url_rel = url.NameAndExt();
|
||||
boolean schema_is_1 = props.Schema_is_1();
|
||||
@@ -36,10 +37,11 @@ public class Xowd_db_file {
|
||||
this.tbl__css_file = new Xowd_css_file_tbl(conn);
|
||||
this.tbl__cat_core = new Xowd_cat_core_tbl(conn, schema_is_1);
|
||||
this.tbl__cat_link = new Xowd_cat_link_tbl(conn, schema_is_1);
|
||||
this.tbl__wbase_qid = new Xowd_wbase_qid_tbl(conn, schema_is_1, schema_props.Wbase__qid__src_ttl_has_spaces());
|
||||
this.tbl__wbase_qid = new Xowd_wbase_qid_tbl(conn, schema_is_1, schema_props == null ? Bool_.N : schema_props.Wbase__qid__src_ttl_has_spaces());
|
||||
this.tbl__wbase_pid = new Xowd_wbase_pid_tbl(conn, schema_is_1);
|
||||
this.info_session = info_session;
|
||||
this.info_file = info_file;
|
||||
this.schema_props = schema_props;
|
||||
}
|
||||
public int Id() {return id;} private final int id; // unique id in xowa_db
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
@@ -47,15 +49,13 @@ public class Xowd_db_file {
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public Xowd_core_db_props Db_props() {return db_props;} private final Xowd_core_db_props db_props;
|
||||
public Xowd_db_file_schema_props Schema_props() {return schema_props;} private final Xowd_db_file_schema_props schema_props;
|
||||
public String Ns_ids() {return ns_ids;} private final String ns_ids;
|
||||
public int Ns_id_or_fail() {return Int_.parse(ns_ids);}
|
||||
public int Part_id() {return part_id;} private final int part_id;
|
||||
public Guid_adp Guid() {return guid;} private final Guid_adp guid;
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xowd_db_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public long File_len() {return file_len;} public Xowd_db_file File_len_add(int v) {file_len += v; return this;} private long file_len;
|
||||
public long File_max() {return file_max;} public Xowd_db_file File_max_(long v) {file_max = v; return this;} private long file_max;
|
||||
public Xob_info_session Info_session() {return info_session;} private final Xob_info_session info_session;
|
||||
public Xob_info_file Info_file() {return info_file;} private final Xob_info_file info_file;
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xow_db_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public long File_len() {return file_len;} public Xow_db_file File_len_add(int v) {file_len += v; return this;} private long file_len;
|
||||
public long File_max() {return file_max;} public Xow_db_file File_max_(long v) {file_max = v; return this;} private long file_max;
|
||||
public Db_cfg_tbl Tbl__cfg() {return tbl__cfg;} private final Db_cfg_tbl tbl__cfg;
|
||||
public Xowd_xowa_db_tbl Tbl__db() {return tbl__db;} private final Xowd_xowa_db_tbl tbl__db;
|
||||
public Xowd_site_ns_tbl Tbl__ns() {return tbl__ns;} private final Xowd_site_ns_tbl tbl__ns;
|
||||
@@ -69,27 +69,44 @@ public class Xowd_db_file {
|
||||
public Xow_site_stats_tbl Tbl__site_stats() {return tbl__site_stats;} private final Xow_site_stats_tbl tbl__site_stats;
|
||||
public Xowd_wbase_qid_tbl Tbl__wbase_qid() {return tbl__wbase_qid;} private final Xowd_wbase_qid_tbl tbl__wbase_qid;
|
||||
public Xowd_wbase_pid_tbl Tbl__wbase_pid() {return tbl__wbase_pid;} private final Xowd_wbase_pid_tbl tbl__wbase_pid;
|
||||
public void Rls() {conn.Rls_conn();}
|
||||
public Xowd_page_tbl Tbl__page__rebind() {this.tbl__page = new Xowd_page_tbl(tbl__page.conn, tbl__page.schema_is_1); return tbl__page;}
|
||||
public Xob_info_session Info_session() {
|
||||
if (info_session == null) // NOTE: null when load; !null when make
|
||||
info_session = Xob_info_session.Load(tbl__cfg);
|
||||
return info_session;
|
||||
} private Xob_info_session info_session;
|
||||
public Xob_info_file Info_file() {
|
||||
if (info_file == null) // NOTE: null when load; !null when make
|
||||
info_file = Xob_info_file.Load(tbl__cfg);
|
||||
return info_file;
|
||||
} private Xob_info_file info_file;
|
||||
public Xow_db_file_schema_props Schema_props() {
|
||||
if (schema_props == null)
|
||||
schema_props = Xow_db_file_schema_props.load_(tbl__cfg, tid, this.Info_session().Version()); // NOTE: must call .Info_session
|
||||
return schema_props;
|
||||
} private Xow_db_file_schema_props schema_props;
|
||||
|
||||
public static final Xowd_db_file Null = null;
|
||||
public static Xowd_db_file make_(Xob_info_session info_session, Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, String core_file_name, Db_conn conn) {
|
||||
Guid_adp guid = Guid_adp_.new_();
|
||||
Xob_info_file info_file = new Xob_info_file(id, Xowd_db_file_.To_key(tid), ns_ids, part_id, guid, props.Schema(), core_file_name, url.NameAndExt());
|
||||
public void Rls() {conn.Rls_conn();}
|
||||
public Xowd_page_tbl Tbl__page__rebind() {
|
||||
this.tbl__page = new Xowd_page_tbl(tbl__page.Conn(), tbl__page.schema_is_1);
|
||||
return tbl__page;
|
||||
}
|
||||
|
||||
public static final Xow_db_file Null = null;
|
||||
public static Xow_db_file make_(Xob_info_session info_session, Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, String core_file_name, Db_conn conn) {
|
||||
Guid_adp guid = Guid_adp_.New();
|
||||
Xob_info_file info_file = new Xob_info_file(id, Xow_db_file_.To_key(tid), ns_ids, part_id, guid, props.Schema(), core_file_name, url.NameAndExt());
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
|
||||
Xowd_db_file rv = new Xowd_db_file(cfg_tbl, info_session, info_file, props, Xowd_db_file_schema_props.make_(), id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_create);
|
||||
Xow_db_file rv = new Xow_db_file(cfg_tbl, props, info_session, info_file, Xow_db_file_schema_props.make_(), id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_create);
|
||||
cfg_tbl.Create_tbl(); // always create cfg in each db
|
||||
return rv;
|
||||
}
|
||||
public static Xowd_db_file load_(Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, Guid_adp guid) {
|
||||
public static Xow_db_file load_(Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, Guid_adp guid) {
|
||||
Db_conn conn = Db_conn_bldr.Instance.Get(url);
|
||||
if (conn == null) {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "wiki.db:missing db; tid=~{0} url=~{1}", Xowd_db_file_.To_key(tid), url.Raw());
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "wiki.db:missing db; tid=~{0} url=~{1}", Xow_db_file_.To_key(tid), url.Raw());
|
||||
conn = Db_conn_.Noop;
|
||||
}
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn); // NOTE: this loads the cfg tbl for the current db, not the core db
|
||||
Xob_info_session info_session = Xob_info_session.Load(cfg_tbl);
|
||||
Xob_info_file info_file = Xob_info_file.Load(cfg_tbl);
|
||||
return new Xowd_db_file(cfg_tbl, info_session, info_file, props, Xowd_db_file_schema_props.load_(cfg_tbl, tid, info_session.Version()), id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_ignore);
|
||||
return new Xow_db_file(cfg_tbl, props, null, null, null, id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_ignore);
|
||||
}
|
||||
}
|
||||
60
400_xowa/src/gplx/xowa/wikis/data/Xow_db_file_.java
Normal file
60
400_xowa/src/gplx/xowa/wikis/data/Xow_db_file_.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
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 Xow_db_file_ {
|
||||
public static final int Uid__core = 0;
|
||||
public static final byte
|
||||
Tid__core = 1, Tid__text = 2, Tid__cat = 3, Tid__search_core = 4, Tid__wbase = 5 // SERIALIZED:v1
|
||||
, Tid__cat_core = 6, Tid__cat_link = 7 // SERIALIZED:v2
|
||||
, Tid__wiki_solo = 8, Tid__text_solo = 9
|
||||
, Tid__html_solo = 10, Tid__html_data = 11
|
||||
, Tid__file_solo = 12, Tid__file_core = 13, Tid__file_data = 14, Tid__file_user = 15
|
||||
, Tid__search_link = 16, Tid__random = 17, Tid__css = 18
|
||||
;
|
||||
private static final String
|
||||
Key__core = "core", Key__text = "text", Key__cat = "xtn.category", Key__search_core = "xtn.search.core", Key__wbase = "core.wbase"
|
||||
, Key__cat_core = "xtn.category.core", Key__cat_link = "xtn.category.link"
|
||||
, Key__text_solo = "text.solo", Key__wiki_solo = "wiki.solo"
|
||||
, Key__html_solo = "html.solo", Key__html_data = "html"
|
||||
, Key__file_solo = "file.solo", Key__file_core = "file.core", Key__file_data = "file.data", Key__file_user = "file.user"
|
||||
, Key__search_link = "xtn.search.link", Key__random = "xtn.random", Key__css = "xtn.css"
|
||||
;
|
||||
public static String To_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid__core: return Key__core;
|
||||
case Tid__text: return Key__text;
|
||||
case Tid__cat: return Key__cat;
|
||||
case Tid__search_core: return Key__search_core;
|
||||
case Tid__wbase: return Key__wbase;
|
||||
case Tid__cat_core: return Key__cat_core;
|
||||
case Tid__cat_link: return Key__cat_link;
|
||||
case Tid__wiki_solo: return Key__wiki_solo;
|
||||
case Tid__text_solo: return Key__text_solo;
|
||||
case Tid__html_solo: return Key__html_solo;
|
||||
case Tid__html_data: return Key__html_data;
|
||||
case Tid__file_solo: return Key__file_solo;
|
||||
case Tid__file_core: return Key__file_core;
|
||||
case Tid__file_data: return Key__file_data;
|
||||
case Tid__file_user: return Key__file_user;
|
||||
case Tid__search_link: return Key__search_link;
|
||||
case Tid__random: return Key__random;
|
||||
case Tid__css: return Key__css;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
117
400_xowa/src/gplx/xowa/wikis/data/Xow_db_file__core_.java
Normal file
117
400_xowa/src/gplx/xowa/wikis/data/Xow_db_file__core_.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
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.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Xow_db_file__core_ {
|
||||
public static Io_url Find_core_fil(Xow_wiki wiki) {
|
||||
Io_url wiki_root_dir = wiki.Fsys_mgr().Root_dir();
|
||||
String domain_str = wiki.Domain_str();
|
||||
Io_url[] ary = Io_mgr.Instance.QueryDir_fils(wiki_root_dir);
|
||||
int ary_len = ary.length; if (ary.length == 0) return null;
|
||||
Io_url rv = Find_core_fil__xowa(ary, ary_len, domain_str);
|
||||
return rv == null ? Find_core_fil__sqlite3(wiki_root_dir, ary, ary_len, domain_str) : rv;
|
||||
}
|
||||
private static Io_url Find_core_fil__xowa(Io_url[] ary, int ary_len, String domain_str) {
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Io_url itm = ary[i];
|
||||
if (!String_.Eq(itm.Ext(), ".xowa")) continue;
|
||||
if ( String_.Eq(itm.NameOnly(), domain_str) // EX: "en.wikipedia.org"
|
||||
|| String_.Eq(itm.NameOnly(), domain_str + "-core") // EX: "en.wikipedia.org-core"
|
||||
) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.v2: url=~{0}", itm.Raw());
|
||||
return itm;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < ary_len; i++) { // DB.FEW: DATE:2016-06-07
|
||||
Io_url itm = ary[i];
|
||||
if (!String_.Eq(itm.Ext(), ".xowa")) continue;
|
||||
if ( String_.Eq(itm.NameOnly(), domain_str + "-text") // EX: "en.wikipedia.org-text"
|
||||
) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.v2: url=~{0}", itm.Raw());
|
||||
return itm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static Io_url Find_core_fil__sqlite3(Io_url wiki_root_dir, Io_url[] ary, int ary_len, String domain_str) {
|
||||
Io_url rv = null;
|
||||
String v0_str = domain_str + ".000";
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Io_url itm = ary[i];
|
||||
if (!String_.Eq(itm.Ext(), ".sqlite3")) continue;
|
||||
if (String_.Eq(itm.NameOnly(), v0_str)) { // EX: "en.wikipedia.org.000"
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.v1: url=~{0}", itm.Raw());
|
||||
return itm;
|
||||
}
|
||||
if (ary_len == 1) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.custom: url=~{0}", itm.Raw());
|
||||
return rv; // 1 folder and 1 sqlite file; return it; custom wikis?
|
||||
}
|
||||
}
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "wiki.db_core.none: dir=~{0}", wiki_root_dir.Raw());
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static boolean Is_core_fil_name(String domain_name, String fil_name) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_name));
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
return String_.Has_at_end(fil_name, ".xowa");
|
||||
}
|
||||
String domain_str = domain_itm.Domain_str();
|
||||
return ( String_.Eq(fil_name, domain_str + "-text.xowa")
|
||||
|| String_.Eq(fil_name, domain_str + "-core.xowa")
|
||||
|| String_.Eq(fil_name, domain_str + ".xowa")
|
||||
);
|
||||
}
|
||||
|
||||
public static Xow_db_file Make_core_db(Xowd_core_db_props props, Xob_info_session info_session, Io_url wiki_root_dir, String domain_str) {
|
||||
String core_file_name = Xow_db_file__core_.Core_file_name(props.Layout_text(), domain_str);
|
||||
byte core_db_tid = Xow_db_file__core_.Core_db_tid(props.Layout_text());
|
||||
Io_url core_db_url = wiki_root_dir.GenSubFil(core_file_name);
|
||||
Db_conn core_conn = Db_conn_bldr.Instance.New(core_db_url);
|
||||
|
||||
// make tbls
|
||||
Xow_db_file rv = Xow_db_file.make_(info_session, props, Xow_db_file_.Uid__core, core_db_tid, core_db_url, Xob_info_file.Ns_ids_empty, Xob_info_file.Part_id_1st, core_file_name, core_conn);
|
||||
rv.Tbl__db().Create_tbl();
|
||||
rv.Tbl__ns().Create_tbl();
|
||||
rv.Tbl__site_stats().Create_tbl();
|
||||
rv.Tbl__page().Create_tbl();
|
||||
if (props.Layout_text().Tid_is_all_or_few()) { // create in advance else will fail for v2; import wiki -> wiki loads and tries to load categories; v2 category processes and builds tbl; DATE:2015-03-22
|
||||
rv.Tbl__cat_core().Create_tbl();
|
||||
rv.Tbl__cat_link().Create_tbl();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static String Core_file_name(Xow_db_layout layout, String domain_name) {
|
||||
switch (layout.Tid()) {
|
||||
case Xow_db_layout.Tid__all: return domain_name + ".xowa"; // EX: en.wikipedia.org.xowa
|
||||
case Xow_db_layout.Tid__few: //return domain_name + "-text.xowa"; // EX: en.wikipedia.org-text.xowa // DB.FEW: DATE:2016-06-07
|
||||
case Xow_db_layout.Tid__lot: return domain_name + "-core.xowa"; // EX: en.wikipedia.org-core.xowa
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static byte Core_db_tid(Xow_db_layout layout) {
|
||||
switch (layout.Tid()) {
|
||||
case Xow_db_layout.Tid__all: return Xow_db_file_.Tid__wiki_solo;
|
||||
case Xow_db_layout.Tid__few: // return Xow_db_file_.Tid__core; // DB.FEW: DATE:2016-06-07
|
||||
case Xow_db_layout.Tid__lot: return Xow_db_file_.Tid__core;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,19 +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.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
class Xowd_db_file_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
class Xow_db_file_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public int Count_total() {return count_total;} private int count_total;
|
||||
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 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;
|
||||
}
|
||||
public Ordered_hash Get_by_tid_or_null(byte tid) {return (Ordered_hash)hash.Get_by(tid);}
|
||||
public void Add_or_new(Xowd_db_file file) {
|
||||
public void Add_or_new(Xow_db_file file) {
|
||||
byte tid = file.Tid();
|
||||
Ordered_hash tids = (Ordered_hash)hash.Get_by(tid);
|
||||
if (tids == null) {
|
||||
@@ -38,6 +31,13 @@ class Xowd_db_file_hash {
|
||||
tids.Add(file.Id(), file);
|
||||
++count_total;
|
||||
}
|
||||
public void Del(Xow_db_file file) {
|
||||
Ordered_hash tids = (Ordered_hash)hash.Get_by(file.Tid());
|
||||
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;
|
||||
}
|
||||
public int Count_of_tid(byte tid) {
|
||||
Ordered_hash tids = (Ordered_hash)hash.Get_by(tid);
|
||||
return tids == null ? 0 : tids.Count();
|
||||
@@ -17,18 +17,18 @@ 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.cfgs.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Xowd_db_file_schema_props {
|
||||
Xowd_db_file_schema_props(boolean search__word__page_count_exists, boolean wbase__qid__src_ttl_has_spaces) {
|
||||
public class Xow_db_file_schema_props {
|
||||
Xow_db_file_schema_props(boolean search__word__page_count_exists, boolean wbase__qid__src_ttl_has_spaces) {
|
||||
this.search__word__page_count_exists = search__word__page_count_exists;
|
||||
this.wbase__qid__src_ttl_has_spaces = wbase__qid__src_ttl_has_spaces;
|
||||
}
|
||||
public boolean Search__word__page_count_exists() {return search__word__page_count_exists;} private final boolean search__word__page_count_exists;
|
||||
public boolean Wbase__qid__src_ttl_has_spaces() {return wbase__qid__src_ttl_has_spaces;} private final boolean wbase__qid__src_ttl_has_spaces;
|
||||
public static Xowd_db_file_schema_props make_() {return new Xowd_db_file_schema_props(Bool_.Y, Bool_.N);}
|
||||
public static Xowd_db_file_schema_props load_(Db_cfg_tbl tbl, int tid, String version) {
|
||||
public boolean Search__word__page_count_exists() {return search__word__page_count_exists;} private final boolean search__word__page_count_exists;
|
||||
public boolean Wbase__qid__src_ttl_has_spaces() {return wbase__qid__src_ttl_has_spaces;} private final boolean wbase__qid__src_ttl_has_spaces;
|
||||
public static Xow_db_file_schema_props make_() {return new Xow_db_file_schema_props(Bool_.Y, Bool_.N);}
|
||||
public static Xow_db_file_schema_props load_(Db_cfg_tbl tbl, int tid, String version) {
|
||||
boolean search__word__page_count_exists = tbl.Select_yn_or(Grp, Key__col_search_word_page_count, Bool_.N);
|
||||
boolean wbase__qid__src_ttl_has_spaces = String_.In(version, "2.4.2.1", "2.4.3.1", "2.4.3.2");
|
||||
return new Xowd_db_file_schema_props(search__word__page_count_exists, wbase__qid__src_ttl_has_spaces);
|
||||
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
|
||||
47
400_xowa/src/gplx/xowa/wikis/data/Xow_db_layout.java
Normal file
47
400_xowa/src/gplx/xowa/wikis/data/Xow_db_layout.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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 Xow_db_layout {
|
||||
public Xow_db_layout(int tid) {this.tid = tid;}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public boolean Tid_is_all() {return tid == Tid__all;}
|
||||
public boolean Tid_is_all_or_few() {return tid != Tid__lot;}
|
||||
public boolean Tid_is_lot() {return tid == Tid__lot;}
|
||||
public String Key() {
|
||||
switch (tid) {
|
||||
case Xow_db_layout.Tid__all: return Key__all;
|
||||
case Xow_db_layout.Tid__few: return Key__few;
|
||||
case Xow_db_layout.Tid__lot: return Key__lot;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
|
||||
public static final int Tid__all = 1, Tid__few = 2, Tid__lot = 3;
|
||||
public static final String Key__all = "all", Key__few = "few", Key__lot = "lot";
|
||||
public static final Xow_db_layout
|
||||
Itm_all = new Xow_db_layout(Tid__all)
|
||||
, Itm_few = new Xow_db_layout(Tid__few)
|
||||
, Itm_lot = new Xow_db_layout(Tid__lot)
|
||||
;
|
||||
public static Xow_db_layout Get_by_name(String v) {
|
||||
if (String_.Eq(v, Key__all)) return Itm_all;
|
||||
else if (String_.Eq(v, Key__few)) return Itm_few;
|
||||
else if (String_.Eq(v, Key__lot)) return Itm_lot;
|
||||
else throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
166
400_xowa/src/gplx/xowa/wikis/data/Xow_db_mgr.java
Normal file
166
400_xowa/src/gplx/xowa/wikis/data/Xow_db_mgr.java
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
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.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.core.lists.hashs.*;
|
||||
import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Xow_db_mgr {
|
||||
private final Ordered_hash hash_by_id = Ordered_hash_.New(); private final Xow_db_file_hash hash_by_tids = new Xow_db_file_hash();
|
||||
private int db_id_next = 0;
|
||||
private final Xow_wiki wiki; private final Io_url wiki_root_dir; private final String domain_str; // needed for generating new files; EX: en.wikipedia.org-text.ns.001.xowa
|
||||
public Xow_db_mgr(Xow_wiki wiki, Io_url wiki_root_dir) {
|
||||
this.wiki = wiki;
|
||||
this.wiki_root_dir = wiki_root_dir;
|
||||
this.domain_str = wiki.Domain_str();
|
||||
}
|
||||
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();}
|
||||
public Xow_db_file Db__core() {return db__core;} private Xow_db_file db__core;
|
||||
public Xow_db_file Db__text() {return db__text;} private Xow_db_file db__text;
|
||||
public Xow_db_file Db__html() {return db__html;} private Xow_db_file db__html;
|
||||
public Xow_db_file Db__cat_core() {return db__cat_core;} private Xow_db_file db__cat_core;
|
||||
public Xow_db_file Db__wbase() {return db__wbase;} private Xow_db_file db__wbase; public void Db__wbase_(Xow_db_file v) {db__wbase = v;}
|
||||
public void Init_by_load(Io_url core_url) {
|
||||
// clear lists
|
||||
hash_by_id.Clear();
|
||||
hash_by_tids.Clear();
|
||||
|
||||
// create core_conn / core_db
|
||||
Db_conn core_conn = Db_conn_bldr.Instance.Get(core_url);
|
||||
props = Xowd_core_db_props.Cfg_load(core_conn); // load props to get layout_text
|
||||
Dbs__set_by_tid(Xow_db_file.load_(props, Xow_db_file_.Uid__core, Xow_db_file__core_.Core_db_tid(props.Layout_text()), core_url, Xob_info_file.Ns_ids_empty, Xob_info_file.Part_id_1st, Guid_adp_.Empty));
|
||||
wiki.Props().Init_by_load(wiki.App(), Tbl__cfg()); // load Main_page
|
||||
|
||||
// load dbs from "xowa_db" tbl
|
||||
Xow_db_file[] ary = db__core.Tbl__db().Select_all(props, core_url.OwnerDir());
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_db_file db = ary[i];
|
||||
Dbs__set_by_tid(db);
|
||||
Dbs__add(db);
|
||||
}
|
||||
}
|
||||
public void Init_by_make(Xowd_core_db_props props, Xob_info_session info_session) {
|
||||
this.props = props;
|
||||
|
||||
// save data
|
||||
Xow_db_file core_db = Xow_db_file__core_.Make_core_db(props, info_session, wiki_root_dir, domain_str);
|
||||
Dbs__set_by_tid(core_db);
|
||||
Dbs__add_and_save(core_db);
|
||||
props.Cfg_save(db__core.Tbl__cfg()); // NOTE: must save cfg now, especially zip_tid; latter will be reloaded after import is done;
|
||||
}
|
||||
public void Rls() {
|
||||
int len = hash_by_id.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_db_file db_file = (Xow_db_file)hash_by_id.Get_at(i);
|
||||
db_file.Rls();
|
||||
}
|
||||
}
|
||||
|
||||
public int Dbs__len() {return hash_by_id.Len();}
|
||||
public Xow_db_file Dbs__get_at(int i) {return (Xow_db_file)hash_by_id.Get_at(i);}
|
||||
public Xow_db_file Dbs__get_by_id_or_fail(int id) {return (Xow_db_file)hash_by_id.Get_by_or_fail(id);}
|
||||
public Xow_db_file Dbs__get_by_id_or_null(int id) {return (Xow_db_file)hash_by_id.Get_by(id);}
|
||||
public Xow_db_file Dbs__get_by_tid_or_core(byte... tids_ary) {Xow_db_file rv = Dbs__get_by_tid_or_null(tids_ary); return rv == null ? db__core : rv;}
|
||||
public Xow_db_file Dbs__get_by_tid_or_null(byte... tids_ary) {
|
||||
int tids_len = tids_ary.length;
|
||||
for (int i = 0; i < tids_len; ++i) {
|
||||
byte tid = tids_ary[i];
|
||||
Ordered_hash tid_dbs = hash_by_tids.Get_by_tid_or_null(tid); if (tid_dbs == null) continue;
|
||||
int tid_dbs_len = tid_dbs.Len();
|
||||
if (tid_dbs_len != 1) { // NOTE: occurs when multiple search imports fail; DATE:2016-04-04
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "expecting only 1 db for tid; tid=~{0} len=~{1} db_api=~{2}", tid, tid_dbs.Len(), db__core.Conn().Conn_info().Db_api());
|
||||
}
|
||||
return (Xow_db_file)tid_dbs.Get_at(tid_dbs_len - 1); // get last idx;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Ordered_hash Dbs__get_hash_by_tid(int tid) {return hash_by_tids.Get_by_tid_or_null((byte)tid);}
|
||||
public Xow_db_file Dbs__make_by_tid(byte tid) {
|
||||
int tid_idx = Get_tid_idx(hash_by_tids, tid);
|
||||
return Dbs__make_by_tid(tid, Xob_info_file.Ns_ids_empty, tid_idx, Get_tid_name(tid_idx, tid));
|
||||
}
|
||||
public Xow_db_file Dbs__make_by_tid(byte tid, String ns_ids, int part_id, String file_name_suffix) {
|
||||
return Dbs__make_by_id(db_id_next++, tid, ns_ids, part_id, file_name_suffix);
|
||||
}
|
||||
public Xow_db_file Dbs__make_by_id(int id, byte tid, String ns_ids, int part_id, String file_name_suffix) {
|
||||
Io_url url = wiki_root_dir.GenSubFil(domain_str + file_name_suffix);
|
||||
Xow_db_file rv = Xow_db_file.make_(db__core.Info_session(), props, id, tid, url, ns_ids, part_id, db__core.Url().NameAndExt(), Db_conn_bldr.Instance.New(url));
|
||||
Dbs__add_and_save(rv);
|
||||
Dbs__set_by_tid(rv);
|
||||
return rv;
|
||||
}
|
||||
public Xow_db_file Dbs__remake_by_tid(byte tid) {
|
||||
Dbs__delete_by_tid(tid);
|
||||
return Dbs__make_by_tid(tid);
|
||||
}
|
||||
public void Dbs__delete_by_tid(byte... tids) {
|
||||
int len = hash_by_id.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_db_file db = (Xow_db_file)hash_by_id.Get_at(i);
|
||||
if (!Byte_.In(db.Tid(), tids)) continue;
|
||||
db.Rls();
|
||||
Io_mgr.Instance.DeleteFil_args(db.Url()).MissingFails_off().Exec();
|
||||
db.Cmd_mode_(Db_cmd_mode.Tid_delete);
|
||||
}
|
||||
db__core.Tbl__db().Commit_all(this);
|
||||
this.Init_by_load(db__core.Url());
|
||||
}
|
||||
public void Create_page(Xowd_page_tbl core_tbl, Xowd_text_tbl text_tbl, int page_id, int ns_id, byte[] ttl_wo_ns, boolean redirect, DateAdp modified_on, byte[] text_zip_data, int text_raw_len, int random_int, int text_db_id, int html_db_id) {
|
||||
core_tbl.Insert_cmd_by_batch(page_id, ns_id, ttl_wo_ns, redirect, modified_on, text_raw_len, random_int, text_db_id, html_db_id);
|
||||
text_tbl.Insert_cmd_by_batch(page_id, text_zip_data);
|
||||
}
|
||||
private void Dbs__set_by_tid(Xow_db_file db) {
|
||||
switch (db.Tid()) {
|
||||
case Xow_db_file_.Tid__wiki_solo:
|
||||
case Xow_db_file_.Tid__text_solo:
|
||||
case Xow_db_file_.Tid__core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__text = db; break;}
|
||||
case Xow_db_file_.Tid__text : {db__text = db; break;}
|
||||
case Xow_db_file_.Tid__html_data : {db__html = db; break;}
|
||||
case Xow_db_file_.Tid__wbase : {if (db__wbase == null) db__wbase = db; break;}
|
||||
case Xow_db_file_.Tid__cat_core :
|
||||
case Xow_db_file_.Tid__cat : {if (db__cat_core == null) db__cat_core = db; break;}
|
||||
}
|
||||
}
|
||||
private void Dbs__add(Xow_db_file db_file) {
|
||||
int db_id = db_file.Id();
|
||||
hash_by_id.Add(db_id, db_file);
|
||||
hash_by_tids.Add_or_new(db_file);
|
||||
if (db_id >= db_id_next) // always set db_id_next to largest value in given set of dbs; EX: dbs=[0,1,10]; db_id_next should be 11
|
||||
db_id_next = db_id + 1;
|
||||
}
|
||||
private void Dbs__add_and_save(Xow_db_file db_file) {
|
||||
Dbs__add(db_file);
|
||||
|
||||
db__core.Tbl__db().Commit_all(this);
|
||||
db_file.Info_file().Save(db_file.Tbl__cfg());
|
||||
db_file.Info_session().Save(db_file.Tbl__cfg());
|
||||
}
|
||||
private int Get_tid_idx(Xow_db_file_hash hash, byte tid) {return hash.Count_of_tid(tid) + Int_.Base1;}
|
||||
private static String Get_tid_name(int tid_idx, byte tid) {
|
||||
String tid_name = Xow_db_file_.To_key(tid);
|
||||
String tid_idx_str = "";
|
||||
switch (tid) {
|
||||
case Xow_db_file_.Tid__cat_core : break;
|
||||
case Xow_db_file_.Tid__cat_link : tid_idx_str = "-db." + Int_.To_str_pad_bgn_zero(tid_idx, 3); break;
|
||||
default : tid_idx_str = tid_idx == 1 ? "" : "-db." + Int_.To_str_pad_bgn_zero(tid_idx, 3); break;
|
||||
}
|
||||
return String_.Format("-{0}{1}.xowa", tid_name, tid_idx_str); // EX: en.wikipedia.org-text-001.sqlite3
|
||||
}
|
||||
}
|
||||
@@ -19,9 +19,8 @@ package gplx.xowa.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_cfg_tbl_ {
|
||||
public static final String Tbl_name = "xowa_cfg";
|
||||
public static Db_cfg_tbl New(gplx.dbs.Db_conn conn) {
|
||||
return new Db_cfg_tbl(conn, Tbl_name);
|
||||
}
|
||||
public static Db_cfg_tbl New(gplx.dbs.Db_conn conn) {return New(conn, Tbl_name);}
|
||||
public static Db_cfg_tbl New(gplx.dbs.Db_conn conn, String tbl_name) {return new Db_cfg_tbl(conn, tbl_name);}
|
||||
public static Db_cfg_tbl Get_or_null(gplx.dbs.Db_conn conn) {
|
||||
return conn.Meta_tbl_exists(Tbl_name) ? new Db_cfg_tbl(conn, Tbl_name) : null;
|
||||
}
|
||||
|
||||
@@ -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.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.dbs.metas.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.wikis.dbs.*;
|
||||
public class Xowd_core_db_props {
|
||||
public Xowd_core_db_props(int schema, Xowd_db_layout layout_text, Xowd_db_layout layout_html, Xowd_db_layout layout_file
|
||||
public Xowd_core_db_props(int schema, Xow_db_layout layout_text, Xow_db_layout layout_html, Xow_db_layout layout_file
|
||||
, byte zip_tid_text, byte zip_tid_html, boolean hzip_enabled, boolean hzip_mode_is_b256) {
|
||||
this.schema = schema;
|
||||
this.layout_text = layout_text; this.layout_html = layout_html; this.layout_file = layout_file;
|
||||
@@ -28,9 +28,9 @@ public class Xowd_core_db_props {
|
||||
}
|
||||
public int Schema() {return schema;} private final int schema;
|
||||
public boolean Schema_is_1() {return schema == 1;}
|
||||
public Xowd_db_layout Layout_text() {return layout_text;} private final Xowd_db_layout layout_text;
|
||||
public Xowd_db_layout Layout_html() {return layout_html;} private final Xowd_db_layout layout_html;
|
||||
public Xowd_db_layout Layout_file() {return layout_file;} private final Xowd_db_layout layout_file;
|
||||
public Xow_db_layout Layout_text() {return layout_text;} private final Xow_db_layout layout_text;
|
||||
public Xow_db_layout Layout_html() {return layout_html;} private final Xow_db_layout layout_html;
|
||||
public Xow_db_layout Layout_file() {return layout_file;} private final Xow_db_layout layout_file;
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private final byte zip_tid_text;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private final byte zip_tid_html;
|
||||
public boolean Hzip_enabled() {return hzip_enabled;} private final boolean hzip_enabled;
|
||||
@@ -38,20 +38,20 @@ public class Xowd_core_db_props {
|
||||
public void Cfg_save(Db_cfg_tbl tbl) {
|
||||
tbl.Conn().Txn_bgn("make__core__cfg__save");
|
||||
tbl.Insert_int (Cfg_grp, Cfg_key__schema_version , schema);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_text , layout_text.Name());
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_html , layout_html.Name());
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_file , layout_file.Name());
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_text , layout_text.Key());
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_html , layout_html.Key());
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_file , layout_file.Key());
|
||||
tbl.Insert_byte (Cfg_grp, Cfg_key__zip_tid_text , zip_tid_text);
|
||||
tbl.Insert_byte (Cfg_grp, Cfg_key__zip_tid_html , zip_tid_html);
|
||||
tbl.Insert_yn (Cfg_grp, Cfg_key__hzip_enabled , hzip_enabled);
|
||||
tbl.Insert_yn (Cfg_grp, Cfg_key__hzip_mode_is_b256 , hzip_mode_is_b256);
|
||||
tbl.Conn().Txn_end();
|
||||
}
|
||||
public static Xowd_core_db_props Cfg_load(Io_url url, Db_conn conn) {
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
|
||||
public static Xowd_core_db_props Cfg_load(Db_conn conn) {return Cfg_load(conn, gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn));}
|
||||
public static Xowd_core_db_props Cfg_load(Db_conn conn, Db_cfg_tbl cfg_tbl) {
|
||||
return cfg_tbl.Select_int_or(Cfg_grp, Cfg_key__schema_version, 1) == 1
|
||||
? new Xowd_core_db_props
|
||||
( 1, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, cfg_tbl.Select_byte_or(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format
|
||||
( 1, Xow_db_layout.Itm_lot, Xow_db_layout.Itm_lot, Xow_db_layout.Itm_lot, cfg_tbl.Select_byte_or(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format
|
||||
, Io_stream_.Tid_gzip), Io_stream_.Tid_gzip, Bool_.Y, Bool_.N)
|
||||
: Cfg_load(cfg_tbl);
|
||||
}
|
||||
@@ -59,9 +59,9 @@ public class Xowd_core_db_props {
|
||||
Db_cfg_hash cfg_hash = tbl.Select_as_hash(Cfg_grp);
|
||||
return new Xowd_core_db_props
|
||||
( cfg_hash.Get_by(Cfg_key__schema_version).To_int()
|
||||
, Xowd_db_layout.get_(cfg_hash.Get_by(Cfg_key__layout_text).To_str())
|
||||
, Xowd_db_layout.get_(cfg_hash.Get_by(Cfg_key__layout_html).To_str())
|
||||
, Xowd_db_layout.get_(cfg_hash.Get_by(Cfg_key__layout_file).To_str())
|
||||
, Xow_db_layout.Get_by_name(cfg_hash.Get_by(Cfg_key__layout_text).To_str())
|
||||
, Xow_db_layout.Get_by_name(cfg_hash.Get_by(Cfg_key__layout_html).To_str())
|
||||
, Xow_db_layout.Get_by_name(cfg_hash.Get_by(Cfg_key__layout_file).To_str())
|
||||
, cfg_hash.Get_by(Cfg_key__zip_tid_text).To_byte()
|
||||
, cfg_hash.Get_by(Cfg_key__zip_tid_html).To_byte()
|
||||
, cfg_hash.Get_by(Cfg_key__hzip_enabled).To_yn_or(Bool_.N)
|
||||
@@ -78,5 +78,5 @@ public class Xowd_core_db_props {
|
||||
, Cfg_key__hzip_enabled = "hzip_enabled"
|
||||
, Cfg_key__hzip_mode_is_b256 = "hzip_mode_is_b256"
|
||||
;
|
||||
public static final Xowd_core_db_props Test = new Xowd_core_db_props(2, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Io_stream_.Tid_raw, Io_stream_.Tid_raw, Bool_.Y, Bool_.Y);
|
||||
public static final Xowd_core_db_props Test = new Xowd_core_db_props(2, Xow_db_layout.Itm_few, Xow_db_layout.Itm_few, Xow_db_layout.Itm_few, Io_stream_.Tid_raw, Io_stream_.Tid_raw, Bool_.Y, Bool_.Y);
|
||||
}
|
||||
|
||||
@@ -1,59 +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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xowd_db_file_ {
|
||||
public static final int Id_core = 0;
|
||||
public static final byte
|
||||
Tid_core = 1, Tid_text = 2, Tid_cat = 3, Tid_search_core = 4, Tid_wbase = 5 // SERIALIZED:v1
|
||||
, Tid_cat_core = 6, Tid_cat_link = 7 // SERIALIZED:v2
|
||||
, Tid_wiki_solo = 8, Tid_text_solo = 9
|
||||
, Tid_html_solo = 10, Tid_html_data = 11
|
||||
, Tid_file_solo = 12, Tid_file_core = 13, Tid_file_data = 14, Tid_file_user = 15
|
||||
, Tid_search_link = 16, Tid_random = 17
|
||||
;
|
||||
private static final String
|
||||
Key_core = "core", Key_text = "text", Key_cat = "xtn.category", Key_search_core = "xtn.search.core", Key_wbase = "core.wbase"
|
||||
, Key_cat_core = "xtn.category.core", Key_cat_link = "xtn.category.link"
|
||||
, Key_text_solo = "text.solo", Key_wiki_solo = "wiki.solo"
|
||||
, Key_html_solo = "html.solo", Key_html_data = "html"
|
||||
, Key_file_solo = "file.solo", Key_file_core = "file.core", Key_file_data = "file.data", Key_file_user = "file.user"
|
||||
, Key_search_link = "xtn.search.link", Key_random = "xtn.random"
|
||||
;
|
||||
public static String To_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_core: return Key_core;
|
||||
case Tid_text: return Key_text;
|
||||
case Tid_cat: return Key_cat;
|
||||
case Tid_search_core: return Key_search_core;
|
||||
case Tid_wbase: return Key_wbase;
|
||||
case Tid_cat_core: return Key_cat_core;
|
||||
case Tid_cat_link: return Key_cat_link;
|
||||
case Tid_wiki_solo: return Key_wiki_solo;
|
||||
case Tid_text_solo: return Key_text_solo;
|
||||
case Tid_html_solo: return Key_html_solo;
|
||||
case Tid_html_data: return Key_html_data;
|
||||
case Tid_file_solo: return Key_file_solo;
|
||||
case Tid_file_core: return Key_file_core;
|
||||
case Tid_file_data: return Key_file_data;
|
||||
case Tid_file_user: return Key_file_user;
|
||||
case Tid_search_link: return Key_search_link;
|
||||
case Tid_random: return Key_random;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xowd_db_layout {
|
||||
public Xowd_db_layout(int tid) {this.tid = tid;}
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public boolean Tid_is_all() {return tid == Const_all;}
|
||||
public boolean Tid_is_all_or_few() {return tid != Const_lot;}
|
||||
public boolean Tid_is_lot() {return tid == Const_lot;}
|
||||
public String Name() {
|
||||
switch (tid) {
|
||||
case Const_all: return Name_all;
|
||||
case Const_few: return Name_few;
|
||||
case Const_lot: return Name_lot;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static final String Name_all = "all", Name_few = "few", Name_lot = "lot";
|
||||
public static final int Const_all = 1, Const_few = 2, Const_lot = 3;
|
||||
public static final Xowd_db_layout
|
||||
Itm_all = new Xowd_db_layout(Const_all)
|
||||
, Itm_few = new Xowd_db_layout(Const_few)
|
||||
, Itm_lot = new Xowd_db_layout(Const_lot)
|
||||
;
|
||||
public static Xowd_db_layout get_(String v) {
|
||||
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 Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
@@ -1,185 +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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
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 Hash_adp id_hash = Hash_adp_.new_(); private final gplx.core.primitives.Int_obj_ref id_hash_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
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();}
|
||||
public Xowd_db_file Db__core() {return db__core;} private Xowd_db_file db__core;
|
||||
public Xowd_db_file Db__text() {return db__text;} private Xowd_db_file db__text;
|
||||
public Xowd_db_file Db__html() {return db__html;} private Xowd_db_file db__html;
|
||||
public Xowd_db_file Db__cat_core() {return db__cat_core;} private Xowd_db_file db__cat_core;
|
||||
public Xowd_db_file Db__wbase() {return db__wbase;} private Xowd_db_file db__wbase;
|
||||
public int Dbs__len() {return dbs__ary.length;}
|
||||
public void Db__wbase_(Xowd_db_file v) {db__wbase = v;}
|
||||
public Ordered_hash Dbs__get_hash_by_tid(int tid) {return db_file_hash.Get_by_tid_or_null((byte)tid);}
|
||||
public Xowd_db_file Dbs__get_at(int i) {return dbs__ary[i];}
|
||||
public Xowd_db_file Dbs__get_by_id(int id) {return (Xowd_db_file)id_hash.Get_by_or_fail(id_hash_ref.Val_(id));}
|
||||
public Xowd_db_file Dbs__get_by_tid_or_core(byte... tids_ary) {Xowd_db_file rv = Dbs__get_by_tid_or_null(tids_ary); return rv == null ? db__core : rv;}
|
||||
public Xowd_db_file Dbs__get_by_tid_or_null(byte... tids_ary) {
|
||||
int tids_len = tids_ary.length;
|
||||
for (int i = 0; i < tids_len; ++i) {
|
||||
byte tid = tids_ary[i];
|
||||
Ordered_hash tid_dbs = db_file_hash.Get_by_tid_or_null(tid); if (tid_dbs == null) continue;
|
||||
int tid_dbs_len = tid_dbs.Len();
|
||||
if (tid_dbs_len != 1) { // NOTE: occurs when multiple search imports fail; DATE:2016-04-04
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "expecting only 1 db for tid; tid=~{0} len=~{1} db_api=~{2}", tid, tid_dbs.Len(), db__core.Conn().Conn_info().Db_api());
|
||||
}
|
||||
return (Xowd_db_file)tid_dbs.Get_at(tid_dbs_len - 1); // get last idx;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Xowd_db_file Dbs__make_by_tid(byte tid) {
|
||||
int tid_idx = Get_tid_idx(db_file_hash, tid);
|
||||
return Dbs__make_by_tid(tid, Xob_info_file.Ns_ids_empty, tid_idx, Get_tid_name(db_file_hash, tid_idx, tid));
|
||||
}
|
||||
public Xowd_db_file Dbs__make_by_tid(byte tid, String ns_ids, int part_id, String file_name_suffix) {
|
||||
Io_url url = wiki_root_dir.GenSubFil(domain_itm.Domain_str() + file_name_suffix);
|
||||
int next_id = Dbs__get_at(dbs__ary_len - 1).Id() + 1;
|
||||
Xowd_db_file rv = Xowd_db_file.make_(db__core.Info_session(), props, next_id, tid, url, ns_ids, part_id, db__core.Url().NameAndExt(), Db_conn_bldr.Instance.New(url));
|
||||
Dbs__add_and_save(rv);
|
||||
Dbs__set_by_tid(rv);
|
||||
return rv;
|
||||
}
|
||||
public Xowd_db_file Dbs__remake_by_tid(byte tid) {
|
||||
Dbs__delete_by_tid(tid);
|
||||
return Dbs__make_by_tid(tid);
|
||||
}
|
||||
public void Dbs__delete_by_tid(byte... tids) {
|
||||
int len = dbs__ary_len;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xowd_db_file db = dbs__ary[i];
|
||||
if (!Byte_.In(db.Tid(), tids)) continue;
|
||||
db.Rls();
|
||||
Io_mgr.Instance.DeleteFil_args(db.Url()).MissingFails_off().Exec();
|
||||
db.Cmd_mode_(Db_cmd_mode.Tid_delete);
|
||||
}
|
||||
db__core.Tbl__db().Commit_all(this);
|
||||
this.Init_by_load(db__core.Url());
|
||||
}
|
||||
public void Init_by_load(Io_url core_url) {
|
||||
db_file_hash.Clear();
|
||||
id_hash.Clear();
|
||||
Db_conn core_conn = Db_conn_bldr.Instance.Get(core_url);
|
||||
props = Xowd_core_db_props.Cfg_load(core_url, core_conn);
|
||||
Dbs__set_by_tid(Xowd_db_file.load_(props, Xowd_db_file_.Id_core, Core_db_tid(props.Layout_text()), core_url, Xob_info_file.Ns_ids_empty, Xob_info_file.Part_id_1st, Guid_adp_.Empty));
|
||||
dbs__ary = db__core.Tbl__db().Select_all(props, core_url.OwnerDir());
|
||||
dbs__ary_len = dbs__ary.length;
|
||||
for (int i = 0; i < dbs__ary_len; i++) {
|
||||
Xowd_db_file db = dbs__ary[i];
|
||||
Dbs__set_by_tid(db);
|
||||
db_file_hash.Add_or_new(db);
|
||||
id_hash.Add(gplx.core.primitives.Int_obj_ref.new_(db.Id()), db);
|
||||
}
|
||||
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;
|
||||
String core_file_name = Core_file_name(props.Layout_text(), domain_itm.Domain_str());
|
||||
byte core_db_tid = Core_db_tid(props.Layout_text());
|
||||
Io_url core_db_url = wiki_root_dir.GenSubFil(core_file_name);
|
||||
Db_conn conn = Db_conn_bldr.Instance.New(core_db_url);
|
||||
conn.Txn_bgn("make__core__tbls");
|
||||
Dbs__set_by_tid(Xowd_db_file.make_(info_session, props, Xowd_db_file_.Id_core, core_db_tid, core_db_url, Xob_info_file.Ns_ids_empty, Xob_info_file.Part_id_1st, core_file_name, conn));
|
||||
db__core.Tbl__db().Create_tbl();
|
||||
db__core.Tbl__ns().Create_tbl();
|
||||
db__core.Tbl__site_stats().Create_tbl();
|
||||
db__core.Tbl__page().Create_tbl();
|
||||
if (props.Layout_text().Tid_is_all_or_few()) { // create in advance else will fail for v2; import wiki -> wiki loads and tries to load categories; v2 category processes and builds tbl; DATE:2015-03-22
|
||||
db__core.Tbl__cat_core().Create_tbl();
|
||||
db__core.Tbl__cat_link().Create_tbl();
|
||||
}
|
||||
Dbs__add_and_save(db__core);
|
||||
props.Cfg_save(db__core.Tbl__cfg()); // NOTE: must save cfg now, especially zip_tid; latter will be reloaded after import is done;
|
||||
conn.Txn_end();
|
||||
}
|
||||
public void Create_page(Xowd_page_tbl core_tbl, Xowd_text_tbl text_tbl, int page_id, int ns_id, byte[] ttl_wo_ns, boolean redirect, DateAdp modified_on, byte[] text_zip_data, int text_raw_len, int random_int, int text_db_id, int html_db_id) {
|
||||
core_tbl.Insert_cmd_by_batch(page_id, ns_id, ttl_wo_ns, redirect, modified_on, text_raw_len, random_int, text_db_id, html_db_id);
|
||||
text_tbl.Insert_cmd_by_batch(page_id, text_zip_data);
|
||||
}
|
||||
private void Dbs__set_by_tid(Xowd_db_file db) {
|
||||
switch (db.Tid()) {
|
||||
case Xowd_db_file_.Tid_wiki_solo:
|
||||
case Xowd_db_file_.Tid_text_solo:
|
||||
case Xowd_db_file_.Tid_core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__text = db; break;}
|
||||
case Xowd_db_file_.Tid_text : {db__text = db; break;}
|
||||
case Xowd_db_file_.Tid_html_data : {db__html = db; break;}
|
||||
case Xowd_db_file_.Tid_wbase : {if (db__wbase == null) db__wbase = db; break;}
|
||||
case Xowd_db_file_.Tid_cat_core :
|
||||
case Xowd_db_file_.Tid_cat : {if (db__cat_core == null) db__cat_core = db; break;}
|
||||
}
|
||||
}
|
||||
private void Dbs__add_and_save(Xowd_db_file rv) {
|
||||
dbs__ary = (Xowd_db_file[])Array_.Resize(dbs__ary, dbs__ary_len + 1);
|
||||
dbs__ary[dbs__ary_len++] = rv;
|
||||
db__core.Tbl__db().Commit_all(this);
|
||||
rv.Info_file().Save(rv.Tbl__cfg());
|
||||
rv.Info_session().Save(rv.Tbl__cfg());
|
||||
db_file_hash.Add_or_new(rv);
|
||||
id_hash.Add(gplx.core.primitives.Int_obj_ref.new_(rv.Id()), rv);
|
||||
}
|
||||
public void Rls() {
|
||||
for (int i = 0; i < dbs__ary_len; i++)
|
||||
dbs__ary[i].Rls();
|
||||
}
|
||||
private int Get_tid_idx(Xowd_db_file_hash hash, byte tid) {return hash.Count_of_tid(tid) + Int_.Base1;}
|
||||
private String Get_tid_name(Xowd_db_file_hash hash, int tid_idx, byte tid) {
|
||||
String tid_name = Xowd_db_file_.To_key(tid);
|
||||
String tid_idx_str = "";
|
||||
switch (tid) {
|
||||
case Xowd_db_file_.Tid_cat_core : break;
|
||||
case Xowd_db_file_.Tid_cat_link : tid_idx_str = "-db." + Int_.To_str_pad_bgn_zero(tid_idx, 3); break;
|
||||
default : tid_idx_str = tid_idx == 1 ? "" : "-db." + Int_.To_str_pad_bgn_zero(tid_idx, 3); break;
|
||||
}
|
||||
return String_.Format("-{0}{1}.xowa", tid_name, tid_idx_str); // EX: en.wikipedia.org-text-001.sqlite3
|
||||
}
|
||||
private static String Core_file_name(Xowd_db_layout layout, String domain_name) {
|
||||
switch (layout.Tid()) {
|
||||
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 Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static boolean Maybe_core(String domain_name, String fil_name) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_name));
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
return String_.Has_at_end(fil_name, ".xowa");
|
||||
}
|
||||
String domain_str = domain_itm.Domain_str();
|
||||
return ( String_.Eq(fil_name, domain_str + "-text.xowa")
|
||||
|| String_.Eq(fil_name, domain_str + "-core.xowa")
|
||||
|| String_.Eq(fil_name, domain_str + ".xowa")
|
||||
);
|
||||
}
|
||||
private static byte Core_db_tid(Xowd_db_layout layout) {
|
||||
switch (layout.Tid()) {
|
||||
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 Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
package gplx.xowa.wikis.data.fetchers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public interface Xow_page_fetcher {
|
||||
Xow_page_fetcher Wiki_(Xowe_wiki v);
|
||||
@@ -15,11 +15,11 @@ 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.*;
|
||||
package gplx.xowa.wikis.data.fetchers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xow_page_fetcher_test implements Xow_page_fetcher {
|
||||
public Xow_page_fetcher Wiki_(Xowe_wiki v) {return this;}
|
||||
public void Clear() {pages.Clear();} private Hash_adp pages = Hash_adp_.new_();
|
||||
public void Clear() {pages.Clear();} private Hash_adp pages = Hash_adp_.New();
|
||||
public void Add(int ns_id, byte[] ttl, byte[] text) {
|
||||
Xowd_page_itm page = new Xowd_page_itm().Ns_id_(ns_id).Ttl_page_db_(ttl).Text_(text);
|
||||
pages.Add(Make_key(ns_id, ttl), page);
|
||||
@@ -15,13 +15,13 @@ 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.*;
|
||||
package gplx.xowa.wikis.data.fetchers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xow_page_fetcher_wiki implements Xow_page_fetcher {
|
||||
public Xow_page_fetcher Wiki_(Xowe_wiki v) {this.wiki = v; return this;} private Xowe_wiki wiki;
|
||||
public void Clear() {}
|
||||
public byte[] Get_by(int ns_id, byte[] ttl_bry) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ns_id, ttl_bry);
|
||||
Xoae_page page = wiki.Data_mgr().Get_page(ttl, false); // go through data_mgr in case of redirects
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // go through data_mgr in case of redirects
|
||||
return page.Missing() ? null : page.Data_raw();
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.site_stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_site_stats_mgr implements GfoInvkAble { // REF.MW:https://www.mediawiki.org/wiki/Manual:Site_stats_table
|
||||
private final Xow_wiki wiki;
|
||||
public class Xow_site_stats_mgr implements Gfo_invk { // REF.MW:https://www.mediawiki.org/wiki/Manual:Site_stats_table
|
||||
private final Xow_wiki wiki;
|
||||
public Xow_site_stats_mgr(Xow_wiki wiki) {this.wiki = wiki;}
|
||||
public long Num_pages() {return num_pages;} private long num_pages; // ss_total_pages; pages in entire wiki: 16,299,475
|
||||
public long Num_articles() {return num_articles;} private long num_articles; // ss_good_articles; pages in main ns w/o redirect: 5,072,469
|
||||
@@ -50,7 +50,7 @@ public class Xow_site_stats_mgr implements GfoInvkAble { // REF.MW:https://www.m
|
||||
else if (ctx.Match(k, Invk_number_of_articles_)) num_articles = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_files_)) num_files = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_articles_in_ns_)) return Number_of_articles_in_ns_(m);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_number_of_pages_ = "number_of_pages_", Invk_number_of_articles_ = "number_of_articles_", Invk_number_of_files_ = "number_of_files_", Invk_number_of_articles_in_ns_ = "number_of_articles_in_ns_";
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data.site_stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.site_stats.*;
|
||||
public class Xow_site_stats_tbl {
|
||||
private final String tbl_name = "site_stats";
|
||||
private final String fld_row_id, fld_good_articles, fld_total_pages, fld_images;
|
||||
private final Db_conn conn; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String tbl_name = "site_stats";
|
||||
private final String fld_row_id, fld_good_articles, fld_total_pages, fld_images;
|
||||
private final Db_conn conn; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
public Xow_site_stats_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
fld_row_id = flds.Add_int_pkey("ss_row_id");
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xowd_cat_core_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_pages, fld_subcats, fld_files, fld_hidden, fld_link_db_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
private final Xowd_cat_core_tbl__in_wkr in_wkr = new Xowd_cat_core_tbl__in_wkr();
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_id, fld_pages, fld_subcats, fld_files, fld_hidden, fld_link_db_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
private final Xowd_cat_core_tbl__in_wkr in_wkr = new Xowd_cat_core_tbl__in_wkr();
|
||||
public Db_conn Conn() {return conn;}
|
||||
public Xowd_cat_core_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.ctgs.*;
|
||||
public class Xowd_cat_link_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_from, fld_to_id, fld_sortkey, fld_timestamp, fld_type_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_in;
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_from, fld_to_id, fld_sortkey, fld_timestamp, fld_type_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_in;
|
||||
public Db_conn Conn() {return conn;}
|
||||
public Xowd_cat_link_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
|
||||
@@ -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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xowd_css_core_tbl implements Rls_able {
|
||||
private final String tbl_name = "css_core"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_key, fld_updated_on;
|
||||
public Xowd_css_core_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_id = flds.Add_int_pkey_autonum("css_id");
|
||||
this.fld_key = flds.Add_str("css_key", 255);
|
||||
this.fld_updated_on = flds.Add_str("css_updated_on", 20);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_key)));}
|
||||
public void Rls() {}
|
||||
public int Insert(String key, DateAdp updated_on) {
|
||||
Db_stmt stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Val_str(fld_key, key).Val_str(fld_updated_on, updated_on.XtoStr_fmt_yyyyMMdd_HHmmss()).Exec_insert();
|
||||
return Select_id_by_key(key);
|
||||
}
|
||||
public void Update(int id, String key, DateAdp updated_on) {
|
||||
Db_stmt stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_id);
|
||||
stmt_update.Val_str(fld_key, key).Val_str(fld_updated_on, updated_on.XtoStr_fmt_yyyyMMdd_HHmmss()).Crt_int(fld_id, id).Exec_update();
|
||||
}
|
||||
public Xowd_css_core_itm Select_by_key(String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_key).Crt_str(fld_key, key).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? new_itm(rdr) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public int Select_id_by_key(String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_key).Crt_str(fld_key, key).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? rdr.Read_int(fld_id) : Id_null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public Xowd_css_core_itm[] Select_all() { // TEST:
|
||||
Db_stmt stmt = conn.Stmt_select(tbl_name, flds);
|
||||
return Select_by_stmt(stmt);
|
||||
}
|
||||
private Xowd_css_core_itm[] Select_by_stmt(Db_stmt stmt) {
|
||||
List_adp rv = List_adp_.new_();
|
||||
Db_rdr rdr = stmt.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next())
|
||||
rv.Add(new_itm(rdr));
|
||||
} finally {rdr.Rls();}
|
||||
return (Xowd_css_core_itm[])rv.To_ary_and_clear(Xowd_css_core_itm.class);
|
||||
}
|
||||
public void Delete_all() {
|
||||
conn.Stmt_delete(tbl_name).Exec_delete();
|
||||
}
|
||||
private Xowd_css_core_itm new_itm(Db_rdr rdr) {
|
||||
return new Xowd_css_core_itm(rdr.Read_int(fld_id), rdr.Read_str(fld_key), rdr.Read_date_by_str(fld_updated_on));
|
||||
}
|
||||
public static final int Id_null = -1;
|
||||
}
|
||||
@@ -1,63 +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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xowd_css_file_tbl implements Rls_able {
|
||||
private final String tbl_name = "css_file"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_css_id, fld_path, fld_data;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Xowd_css_file_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_css_id = flds.Add_int("css_id");
|
||||
fld_path = flds.Add_str("file_path", 255);
|
||||
fld_data = flds.Add_bry("file_data");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert(int css_id, String path, byte[] data) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_int(fld_css_id, css_id).Val_str(fld_path, path).Val_bry(fld_data, data).Exec_insert();
|
||||
}
|
||||
public void Delete(int css_id) {
|
||||
conn.Stmt_delete(tbl_name, fld_css_id).Crt_int(fld_css_id, css_id).Exec_delete();
|
||||
}
|
||||
public Xowd_css_file_itm[] Select_by_owner(int css_id) {
|
||||
Db_stmt stmt = conn.Stmt_select(tbl_name, flds, fld_css_id).Crt_int(fld_css_id, css_id);
|
||||
return Select_by_stmt(stmt);
|
||||
}
|
||||
public Xowd_css_file_itm[] Select_all() { // TEST:
|
||||
Db_stmt stmt = conn.Stmt_select(tbl_name, flds);
|
||||
return Select_by_stmt(stmt);
|
||||
}
|
||||
private Xowd_css_file_itm[] Select_by_stmt(Db_stmt stmt) {
|
||||
List_adp rv = List_adp_.new_();
|
||||
Db_rdr rdr = stmt.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next())
|
||||
rv.Add(new_itm(rdr));
|
||||
} finally {rdr.Rls();}
|
||||
return (Xowd_css_file_itm[])rv.To_ary_and_clear(Xowd_css_file_itm.class);
|
||||
}
|
||||
public void Delete_all() {
|
||||
conn.Stmt_delete(tbl_name).Exec_delete();
|
||||
}
|
||||
private Xowd_css_file_itm new_itm(Db_rdr rdr) {return new Xowd_css_file_itm(rdr.Read_int(fld_css_id), rdr.Read_str(fld_path), rdr.Read_bry(fld_data));}
|
||||
}
|
||||
@@ -29,11 +29,12 @@ public class Xowd_page_itm {
|
||||
public int Text_len() {return text_len;} public Xowd_page_itm Text_len_(int v) {text_len = v; return this;} private int text_len;
|
||||
public int Text_db_id() {return text_db_id;} public Xowd_page_itm Text_db_id_(int v) {text_db_id = v; return this;} private int text_db_id;
|
||||
public byte[] Text() {return text;} public Xowd_page_itm Text_(byte[] v) {text = v; if (v != null) text_len = v.length; return this;} private byte[] text;
|
||||
public int Random_int() {return random_int;} private int random_int;
|
||||
public int Html_db_id() {return html_db_id;} private int html_db_id;
|
||||
public int Redirect_id() {return redirect_id;} private int redirect_id;
|
||||
public DateAdp Modified_on() {return modified_on;} public Xowd_page_itm Modified_on_(DateAdp v) {modified_on = v; return this;} private DateAdp modified_on;
|
||||
public boolean Exists() {return exists;} public Xowd_page_itm Exists_(boolean v) {exists = v; return this;} private boolean exists;
|
||||
public int Page_score;
|
||||
public int Score() {return score;} private int score;
|
||||
public Xow_ns Ns() {return ns;} private Xow_ns ns;
|
||||
public Object Xtn() {return xtn;} public Xowd_page_itm Xtn_(Object v) {this.xtn = v; return this;} private Object xtn;
|
||||
public int Tdb_row_idx() {return tdb_row_idx;} public void Tdb_row_idx_(int v) {tdb_row_idx = v;} private int tdb_row_idx;
|
||||
@@ -44,17 +45,18 @@ public class Xowd_page_itm {
|
||||
id_val = null;
|
||||
return this;
|
||||
}
|
||||
public void Init_by_sql(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int text_db_id, int html_db_id, int redirect_id, int page_score) {
|
||||
public void Init_by_sql(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int random_int, int text_db_id, int html_db_id, int redirect_id, int score) {
|
||||
this.id = id;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
this.modified_on = modified_on;
|
||||
this.redirected = redirected;
|
||||
this.text_len = text_len;
|
||||
this.random_int = random_int;
|
||||
this.text_db_id = text_db_id;
|
||||
this.html_db_id = html_db_id;
|
||||
this.redirect_id = redirect_id;
|
||||
this.Page_score = page_score;
|
||||
this.score = score;
|
||||
}
|
||||
public void Init_by_tdb(int id, int text_db_id, int tdb_row_idx, boolean redirected, int text_len, int ns_id, byte[] ttl_page_db) {
|
||||
this.id = id;
|
||||
@@ -128,4 +130,9 @@ public class Xowd_page_itm {
|
||||
public static final Xowd_page_itm Null = null;
|
||||
public static Xowd_page_itm new_tmp() {return new Xowd_page_itm();}
|
||||
public static Xowd_page_itm new_srch(int id, int text_len) {return new Xowd_page_itm().Id_(id).Text_len_(text_len);}
|
||||
|
||||
public static final int Db_row_size_fixed =
|
||||
(8 * 4) // page_id, page_namespace, page_random_int, page_text_db_id, page_html_db_id, page_redirect_id, page_score, page_is_redirect (assume byte saved as int in SQLITE)
|
||||
+ 14 // page_touched
|
||||
;
|
||||
}
|
||||
|
||||
@@ -21,28 +21,11 @@ import gplx.dbs.*; import gplx.xowa.*; import gplx.xowa.wikis.dbs.*; import gplx
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_page_tbl implements Rls_able {
|
||||
private final String tbl_name = "page";
|
||||
public final Db_conn conn; public final boolean schema_is_1;
|
||||
public final boolean schema_is_1;
|
||||
private String fld_id, fld_ns, fld_title, fld_is_redirect, fld_touched, fld_len, fld_random_int, fld_score, fld_text_db_id, fld_html_db_id, fld_redirect_id;
|
||||
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private Db_stmt stmt_select_all_by_ttl, stmt_select_all_by_id, stmt_select_id_by_ttl, stmt_insert;
|
||||
private final String[] flds_select_all, flds_select_idx;
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public Dbmeta_fld_list Flds__all() {return flds;}
|
||||
public String Fld_page_id() {return fld_id;}
|
||||
public String Fld_page_ns() {return fld_ns;}
|
||||
public String Fld_page_title() {return fld_title;}
|
||||
public String Fld_page_len() {return fld_len;}
|
||||
public String Fld_page_score() {return fld_score;} public static final String Fld__page_score__key = "page_score";
|
||||
public String Fld_html_db_id() {return fld_html_db_id;}
|
||||
public String Fld_is_redirect() {return fld_is_redirect;}
|
||||
public String Fld_redirect_id() {return fld_redirect_id;}
|
||||
public String[] Flds_select_idx() {return flds_select_idx;}
|
||||
public String[] Flds_select_all() {return flds_select_all;}
|
||||
public void Flds__assert() {
|
||||
conn.Meta_fld_assert(tbl_name, this.Fld_html_db_id() , Dbmeta_fld_tid.Itm__int, -1);
|
||||
conn.Meta_fld_assert(tbl_name, this.Fld_redirect_id() , Dbmeta_fld_tid.Itm__int, -1);
|
||||
conn.Meta_fld_assert(tbl_name, Fld__page_score__key , Dbmeta_fld_tid.Itm__int, -1);
|
||||
}
|
||||
public Xowd_page_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn; this.schema_is_1 = schema_is_1;
|
||||
String fld_text_db_id_name = "";
|
||||
@@ -59,10 +42,31 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
fld_html_db_id = flds.Add_int_dflt("page_html_db_id", -1); // MW:XOWA
|
||||
fld_redirect_id = flds.Add_int_dflt("page_redirect_id", -1); // MW:XOWA
|
||||
fld_score = flds.Add_int_dflt(Fld__page_score__key, -1); // MW:XOWA
|
||||
flds_select_all = String_.Ary_wo_null(fld_id, fld_ns, fld_title, fld_touched, fld_is_redirect, fld_len, fld_text_db_id, fld_html_db_id, fld_redirect_id, fld_score);
|
||||
flds_select_all = String_.Ary_wo_null(fld_id, fld_ns, fld_title, fld_touched, fld_is_redirect, fld_len, fld_random_int, fld_text_db_id, fld_html_db_id, fld_redirect_id, fld_score);
|
||||
flds_select_idx = String_.Ary_wo_null(fld_ns, fld_title, fld_id, fld_len, fld_score);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public Dbmeta_fld_list Flds__all() {return flds;}
|
||||
public String Fld_page_id() {return fld_id;}
|
||||
public String Fld_page_ns() {return fld_ns;}
|
||||
public String Fld_page_title() {return fld_title;}
|
||||
public String Fld_page_len() {return fld_len;}
|
||||
public String Fld_page_score() {return fld_score;} public static final String Fld__page_score__key = "page_score";
|
||||
public String Fld_text_db_id() {return fld_text_db_id;}
|
||||
public String Fld_html_db_id() {return fld_html_db_id;}
|
||||
public String Fld_is_redirect() {return fld_is_redirect;}
|
||||
public String Fld_random_int() {return fld_random_int;}
|
||||
public String Fld_modified_on() {return fld_touched;}
|
||||
public String Fld_redirect_id() {return fld_redirect_id;}
|
||||
public String[] Flds_select_idx() {return flds_select_idx;}
|
||||
public String[] Flds_select_all() {return flds_select_all;}
|
||||
public void Flds__assert() {
|
||||
conn.Meta_fld_assert(tbl_name, this.Fld_html_db_id() , Dbmeta_fld_tid.Itm__int, -1);
|
||||
conn.Meta_fld_assert(tbl_name, this.Fld_redirect_id() , Dbmeta_fld_tid.Itm__int, -1);
|
||||
conn.Meta_fld_assert(tbl_name, Fld__page_score__key , Dbmeta_fld_tid.Itm__int, -1);
|
||||
}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds.To_fld_ary()));}
|
||||
public void Insert(int page_id, int ns_id, byte[] ttl_wo_ns, boolean page_is_redirect, DateAdp modified_on, int page_len, int random_int, int text_db_id, int html_db_id) {
|
||||
this.Insert_bgn();
|
||||
@@ -86,6 +90,21 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
.Val_int(fld_score, -1)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Insert_by_itm(Db_stmt stmt, Xowd_page_itm itm, int html_db_id) {
|
||||
stmt.Clear()
|
||||
.Val_int (fld_id , itm.Id())
|
||||
.Val_int (fld_ns , itm.Ns_id())
|
||||
.Val_bry_as_str (fld_title , itm.Ttl_page_db())
|
||||
.Val_bool_as_byte (fld_is_redirect , itm.Redirected())
|
||||
.Val_str (fld_touched , itm.Modified_on().XtoStr_fmt(Xowd_page_tbl.Page_touched_fmt))
|
||||
.Val_int (fld_len , itm.Text_len())
|
||||
.Val_int (fld_random_int , itm.Random_int())
|
||||
.Val_int (fld_text_db_id , itm.Text_db_id())
|
||||
.Val_int (fld_html_db_id , html_db_id)
|
||||
.Val_int (fld_redirect_id , itm.Redirect_id())
|
||||
.Val_int (fld_score , itm.Score())
|
||||
.Exec_insert();
|
||||
}
|
||||
public boolean Select_by_ttl(Xowd_page_itm rv, Xow_ns ns, byte[] ttl) {
|
||||
if (stmt_select_all_by_ttl == null) stmt_select_all_by_ttl = conn.Stmt_select(tbl_name, flds, String_.Ary(fld_ns, fld_title));
|
||||
Db_rdr rdr = stmt_select_all_by_ttl.Clear().Crt_int(fld_ns, ns.Id()).Crt_bry_as_str(fld_title, ttl).Exec_select__rls_manual();
|
||||
@@ -281,6 +300,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
, DateAdp_.parse_fmt(rdr.Read_str(fld_touched), Page_touched_fmt)
|
||||
, rdr.Read_bool_by_byte(fld_is_redirect)
|
||||
, page_len
|
||||
, rdr.Read_int(fld_random_int)
|
||||
, rdr.Read_int(fld_text_db_id)
|
||||
, html_db_id
|
||||
, redirected_id
|
||||
@@ -314,7 +334,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
.Exec_update()
|
||||
;
|
||||
}
|
||||
public void Create_index() {
|
||||
public void Create_idx() {
|
||||
conn.Meta_idx_create(Xoa_app_.Usr_dlg()
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "title" , fld_title, fld_ns)
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "random" , fld_random_int)
|
||||
|
||||
@@ -19,9 +19,9 @@ package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_site_ns_tbl {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_name, fld_case, fld_count, fld_is_alias;
|
||||
private final Db_conn conn;
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_id, fld_name, fld_case, fld_count, fld_is_alias;
|
||||
private final Db_conn conn;
|
||||
public Xowd_site_ns_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = schema_is_1 ? "xowa_ns" : "site_ns";
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xowd_text_tbl implements Rls_able {
|
||||
private final String tbl_name = "text"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_page_id, fld_text_data;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private final Io_stream_zip_mgr zip_mgr = Xoa_app_.Utl__zip_mgr(); private final byte zip_tid;
|
||||
private final String tbl_name = "text"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_page_id, fld_text_data;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private final Io_stream_zip_mgr zip_mgr = Xoa_app_.Utl__zip_mgr(); private final byte zip_tid;
|
||||
public String Fld_text_data() {return fld_text_data;}
|
||||
public Xowd_text_tbl(Db_conn conn, boolean schema_is_1, byte zip_tid) {
|
||||
this.conn = conn; this.zip_tid = zip_tid;
|
||||
@@ -46,9 +46,12 @@ public class Xowd_text_tbl implements Rls_able {
|
||||
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_page_id);
|
||||
Db_rdr rdr = stmt_select.Clear().Val_int(fld_page_id, page_id).Exec_select__rls_manual();
|
||||
try {
|
||||
byte[] rv = (byte[])rdr.Read_bry(fld_text_data);
|
||||
if (rv == null) rv = Bry_.Empty; // NOTE: defect wherein blank page inserts null not ""; for now always convert nul to empty String; DATE:2015-11-08
|
||||
rv = zip_mgr.Unzip(zip_tid, rv);
|
||||
byte[] rv = Bry_.Empty;
|
||||
if (rdr.Move_next()) {
|
||||
rv = rdr.Read_bry(fld_text_data);
|
||||
if (rv == null) rv = Bry_.Empty; // NOTE: defect wherein blank page inserts null not ""; for now always convert null to empty String; DATE:2015-11-08
|
||||
rv = zip_mgr.Unzip(zip_tid, rv);
|
||||
}
|
||||
return rv;
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Xowd_wbase_pid_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_src_lang, fld_src_ttl, fld_trg_ttl;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_src_lang, fld_src_ttl, fld_trg_ttl;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
public Xowd_wbase_pid_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
String fld_prefix = "";
|
||||
|
||||
@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xowd_wbase_qid_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_src_wiki, fld_src_ns, fld_src_ttl, fld_trg_ttl;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_src_wiki, fld_src_ns, fld_src_ttl, fld_trg_ttl;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private boolean src_ttl_has_spaces;
|
||||
public Xowd_wbase_qid_tbl(Db_conn conn, boolean schema_is_1, boolean src_ttl_has_spaces) {
|
||||
this.conn = conn; this.src_ttl_has_spaces = src_ttl_has_spaces;
|
||||
|
||||
@@ -19,15 +19,16 @@ package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.xowa.wikis.data.*;
|
||||
public class Xowd_xowa_db_tbl {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_type, fld_url, fld_ns_ids, fld_part_id, fld_guid; private boolean schema_is_1;
|
||||
private final Db_conn conn; private final Db_stmt_bldr stmt_bldr = new Db_stmt_bldr();
|
||||
public static final String Tbl_name = "xowa_db", Fld_id = "db_id", Fld_type = "db_type", Fld_url = "db_url";
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_id, fld_type, fld_url, fld_ns_ids, fld_part_id, fld_guid; private boolean schema_is_1;
|
||||
private final Db_conn conn; private final Db_stmt_bldr stmt_bldr = new Db_stmt_bldr();
|
||||
public Xowd_xowa_db_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn; this.schema_is_1 = schema_is_1;
|
||||
this.tbl_name = "xowa_db";
|
||||
fld_id = flds.Add_int_pkey ("db_id");
|
||||
fld_type = flds.Add_byte ("db_type");
|
||||
fld_url = flds.Add_str ("db_url", 512);
|
||||
this.tbl_name = Tbl_name;
|
||||
fld_id = flds.Add_int_pkey (Fld_id);
|
||||
fld_type = flds.Add_byte (Fld_type);
|
||||
fld_url = flds.Add_str (Fld_url, 512);
|
||||
if (schema_is_1) {
|
||||
fld_ns_ids = fld_part_id = fld_guid = Dbmeta_fld_itm.Key_null;
|
||||
}
|
||||
@@ -39,8 +40,8 @@ public class Xowd_xowa_db_tbl {
|
||||
stmt_bldr.Conn_(conn, tbl_name, flds, fld_id);
|
||||
}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public Xowd_db_file[] Select_all(Xowd_core_db_props props, Io_url wiki_root_dir) {
|
||||
List_adp list = List_adp_.new_();
|
||||
public Xow_db_file[] Select_all(Xowd_core_db_props props, Io_url wiki_root_dir) {
|
||||
List_adp list = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
@@ -48,15 +49,17 @@ public class Xowd_xowa_db_tbl {
|
||||
if (!schema_is_1) {
|
||||
ns_ids = rdr.Read_str(fld_ns_ids);
|
||||
part_id = rdr.Read_int(fld_part_id);
|
||||
guid = Guid_adp_.parse(rdr.Read_str(fld_guid));
|
||||
guid = Guid_adp_.Parse(rdr.Read_str(fld_guid));
|
||||
}
|
||||
list.Add(Xowd_db_file.load_(props, rdr.Read_int(fld_id), rdr.Read_byte(fld_type), wiki_root_dir.GenSubFil(rdr.Read_str(fld_url)), ns_ids, part_id, guid));
|
||||
int db_id = rdr.Read_int(fld_id);
|
||||
Xow_db_file db_file = Xow_db_file.load_(props, db_id, rdr.Read_byte(fld_type), wiki_root_dir.GenSubFil(rdr.Read_str(fld_url)), ns_ids, part_id, guid);
|
||||
list.Add(db_file);
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
list.Sort_by(Xowd_db_file_sorter__id.Instance);
|
||||
return (Xowd_db_file[])list.To_ary(Xowd_db_file.class);
|
||||
list.Sort_by(Xow_db_file_sorter__id.Instance);
|
||||
return (Xow_db_file[])list.To_ary_and_clear(Xow_db_file.class);
|
||||
}
|
||||
public void Commit_all(Xowd_db_mgr core_data_mgr) {
|
||||
public void Commit_all(Xow_db_mgr core_data_mgr) {
|
||||
stmt_bldr.Batch_bgn();
|
||||
try {
|
||||
int len = core_data_mgr.Dbs__len();
|
||||
@@ -64,7 +67,7 @@ public class Xowd_xowa_db_tbl {
|
||||
Commit_itm(core_data_mgr.Dbs__get_at(i));
|
||||
} finally {stmt_bldr.Batch_end();}
|
||||
}
|
||||
private void Commit_itm(Xowd_db_file itm) {
|
||||
private void Commit_itm(Xow_db_file itm) {
|
||||
Db_stmt stmt = stmt_bldr.Get(itm.Cmd_mode());
|
||||
switch (itm.Cmd_mode()) {
|
||||
case Db_cmd_mode.Tid_create: stmt.Clear().Val_int(fld_id, itm.Id()); Commit_itm_vals(stmt, itm); stmt.Exec_insert(); break;
|
||||
@@ -75,15 +78,15 @@ public class Xowd_xowa_db_tbl {
|
||||
}
|
||||
itm.Cmd_mode_(Db_cmd_mode.Tid_ignore);
|
||||
}
|
||||
private void Commit_itm_vals(Db_stmt stmt, Xowd_db_file itm) {
|
||||
private void Commit_itm_vals(Db_stmt stmt, Xow_db_file itm) {
|
||||
stmt.Val_byte(fld_type, itm.Tid()).Val_str(fld_url, itm.Url_rel()).Val_str(fld_ns_ids, itm.Ns_ids()).Val_int(fld_part_id, itm.Part_id()).Val_str(fld_guid, itm.Guid().To_str());
|
||||
}
|
||||
}
|
||||
class Xowd_db_file_sorter__id implements gplx.core.lists.ComparerAble {
|
||||
class Xow_db_file_sorter__id implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xowd_db_file lhs = (Xowd_db_file)lhsObj;
|
||||
Xowd_db_file rhs = (Xowd_db_file)rhsObj;
|
||||
Xow_db_file lhs = (Xow_db_file)lhsObj;
|
||||
Xow_db_file rhs = (Xow_db_file)rhsObj;
|
||||
return Int_.Compare(lhs.Id(), rhs.Id());
|
||||
}
|
||||
public static final Xowd_db_file_sorter__id Instance = new Xowd_db_file_sorter__id(); Xowd_db_file_sorter__id() {}
|
||||
public static final Xow_db_file_sorter__id Instance = new Xow_db_file_sorter__id(); Xow_db_file_sorter__id() {}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public interface Xodb_load_mgr {
|
||||
void Load_init (Xowe_wiki wiki);
|
||||
void Load_page (Xowd_page_itm rv, Xow_ns ns, boolean timestamp_enabled);
|
||||
void Load_page (Xowd_page_itm rv, Xow_ns ns);
|
||||
boolean Load_by_id (Xowd_page_itm rv, int id);
|
||||
void Load_by_ids (Cancelable cancelable, List_adp rv, int bgn, int end);
|
||||
boolean Load_by_ttl (Xowd_page_itm rv, Xow_ns ns, byte[] ttl);
|
||||
|
||||
@@ -20,13 +20,13 @@ import gplx.core.primitives.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.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.apps.searchs.*;
|
||||
import gplx.xowa.addons.wikis.searchs.*;
|
||||
public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
private Xodb_mgr_sql db_mgr; Xowd_db_mgr fsys_mgr;
|
||||
public Xodb_load_mgr_sql(Xow_wiki wiki, Xodb_mgr_sql db_mgr, Xowd_db_mgr fsys_mgr) {this.db_mgr = db_mgr; this.fsys_mgr = fsys_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;}
|
||||
public void Load_init(Xowe_wiki wiki) {
|
||||
Load_init_cfg(wiki);
|
||||
Xowd_db_file db_core = wiki.Data__core_mgr().Db__core();
|
||||
Xow_db_file db_core = wiki.Data__core_mgr().Db__core();
|
||||
db_core.Tbl__site_stats().Select(wiki.Stats());
|
||||
db_core.Tbl__ns().Select_all(wiki.Ns_mgr());
|
||||
}
|
||||
@@ -50,8 +50,8 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
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);
|
||||
}
|
||||
public void Load_page(Xowd_page_itm rv, Xow_ns ns, boolean timestamp_enabled) {
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id(rv.Text_db_id()).Tbl__text();
|
||||
public void Load_page(Xowd_page_itm rv, Xow_ns ns) {
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id_or_fail(rv.Text_db_id()).Tbl__text();
|
||||
byte[] text_bry = text_tbl.Select(rv.Id());
|
||||
rv.Text_(text_bry);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
public void Load_ctg_v2a(Xoctg_view_ctg rv, Xoctg_url ctg_url, byte[] ctg_ttl, int load_max) {
|
||||
int cat_page_id = db_mgr.Core_data_mgr().Tbl__page().Select_id(Xow_ns_.Tid__category, ctg_ttl); if (cat_page_id == Xowd_page_itm.Id_null) return;
|
||||
Xowd_category_itm ctg = fsys_mgr.Db__cat_core().Tbl__cat_core().Select(cat_page_id); if (ctg == Xowd_category_itm.Null) return;
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
Load_ctg_v2a_db_retrieve(rv, ctg_url, cat_page_id, load_max, ctg.File_idx(), list);
|
||||
Load_ctg_v2a_ui_sift(rv, ctg, list);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
for (byte i = Xoa_ctg_mgr.Tid_subc; i < len; i++) {
|
||||
boolean arg_is_from = ctg_url.Grp_fwds()[i] == Bool_.N_byte;
|
||||
byte[] arg_sortkey = ctg_url.Grp_idxs()[i];
|
||||
Xowd_cat_link_tbl cat_link_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id(cat_link_db_idx).Tbl__cat_link();
|
||||
Xowd_cat_link_tbl cat_link_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id_or_fail(cat_link_db_idx).Tbl__cat_link();
|
||||
int found = cat_link_tbl.Select_by_type(list, cat_page_id, i, arg_sortkey, arg_is_from, load_max);
|
||||
if (found > 0 && found == load_max + 1) {
|
||||
Xowd_page_itm last_page = (Xowd_page_itm)List_adp_.Pop(list);
|
||||
@@ -152,9 +152,9 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
db_mgr.Core_data_mgr().Db__cat_core().Tbl__cat_core().Select_by_cat_id_in(Cancelable_.Never, hash2, 0, len);
|
||||
return (Xowd_page_itm[])hash.To_ary(Xowd_page_itm.class);
|
||||
}
|
||||
private static boolean Ctg_select_v1(Xowe_wiki wiki, Xowd_db_mgr core_data_mgr, Xoctg_view_ctg view_ctg, int link_db_id, Xowd_category_itm ctg) {
|
||||
List_adp link_list = List_adp_.new_();
|
||||
core_data_mgr.Dbs__get_by_id(link_db_id).Tbl__cat_link().Select_in(link_list, ctg.Id());
|
||||
private static boolean Ctg_select_v1(Xowe_wiki wiki, Xow_db_mgr core_data_mgr, Xoctg_view_ctg view_ctg, int link_db_id, Xowd_category_itm ctg) {
|
||||
List_adp link_list = List_adp_.New();
|
||||
core_data_mgr.Dbs__get_by_id_or_fail(link_db_id).Tbl__cat_link().Select_in(link_list, ctg.Id());
|
||||
int link_list_len = link_list.Count();
|
||||
link_list.Sort_by(Xowd_page_itm_sorter.IdAsc);
|
||||
core_data_mgr.Tbl__page().Select_in__id(Cancelable_.Never, false, link_list, 0, link_list_len);
|
||||
|
||||
@@ -40,7 +40,7 @@ class Xoctg_url_mok extends Xoctg_url { public Xoctg_url_mok Page_bgn_(String v)
|
||||
}
|
||||
}
|
||||
class Xodb_load_mgr_sql_fxt {
|
||||
Db_mgr_fxt fxt; Int_obj_ref next_id = Int_obj_ref.new_(1); Xoae_app app; Xowe_wiki wiki;
|
||||
Db_mgr_fxt fxt; Int_obj_ref next_id = Int_obj_ref.New(1); Xoae_app app; Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
if (fxt == null) {
|
||||
fxt = new Db_mgr_fxt();
|
||||
@@ -85,7 +85,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
Tfds.Eq_str_lines(Xto_str(ary), Xto_str(actl));
|
||||
}
|
||||
private static String Xto_str(Xowd_page_itm[] ary) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowd_page_itm page = ary[i];
|
||||
@@ -136,7 +136,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
class Xoctg_mok_grp {
|
||||
public byte Tid() {return tid;} public Xoctg_mok_grp Tid_(byte v) {this.tid = v; return this;} private byte tid;
|
||||
public byte[] Last_plus_one_sortkey() {return last_plus_one_sortkey;} public Xoctg_mok_grp Last_plus_one_sortkey_(byte[] v) {this.last_plus_one_sortkey = v; return this;} private byte[] last_plus_one_sortkey;
|
||||
public List_adp Itms() {return itms;} List_adp itms = List_adp_.new_();
|
||||
public List_adp Itms() {return itms;} List_adp itms = List_adp_.New();
|
||||
}
|
||||
class Xoctg_mok_ctg {
|
||||
public Xoctg_mok_ctg(Int_obj_ref next_id) {this.next_id = next_id;} Int_obj_ref next_id;
|
||||
|
||||
@@ -21,7 +21,8 @@ import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.c
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*; import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
import gplx.xowa.addons.apps.searchs.specials.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.addons.wikis.searchs.specials.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
private final Xob_xdat_file tmp_xdat_file = new Xob_xdat_file(); private final Xob_xdat_itm tmp_xdat_itm = new Xob_xdat_itm();
|
||||
@@ -33,10 +34,10 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
this.fsys_mgr = wiki.Tdb_fsys_mgr();
|
||||
}
|
||||
public void Load_init (Xowe_wiki wiki) {}
|
||||
public void Load_page(Xowd_page_itm rv, Xow_ns ns, boolean timestamp_enabled) {Load_page(rv, rv.Text_db_id(), rv.Tdb_row_idx(), ns, timestamp_enabled, tmp_xdat_file, tmp_xdat_itm);}
|
||||
public void Load_page(Xowd_page_itm rv, Xow_ns ns) {Load_page(rv, rv.Text_db_id(), rv.Tdb_row_idx(), ns, false, tmp_xdat_file, tmp_xdat_itm);}
|
||||
public void Load_page(Xowd_page_itm rv, int txt_fil_idx, int txt_row_idx, Xow_ns ns, boolean timestamp_enabled, Xob_xdat_file xdat_file, Xob_xdat_itm xdat_itm) {
|
||||
Io_url file = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_page, ns.Id(), txt_fil_idx);
|
||||
byte[] bry = gplx.core.ios.Io_stream_rdr_.Load_all(file); int bry_len = bry.length;
|
||||
byte[] bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(file); int bry_len = bry.length;
|
||||
xdat_file.Clear().Parse(bry, bry_len, file).GetAt(xdat_itm, txt_row_idx);
|
||||
Load_page_parse(rv, bry, bry_len, xdat_itm.Itm_bgn(), xdat_itm.Itm_end(), timestamp_enabled);
|
||||
}
|
||||
@@ -82,7 +83,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
match_tid = Srch_special_page.Match_tid_bgn;
|
||||
}
|
||||
int bgn_idx = this.Find_file_idx_by_ns(Xotdb_dir_info_.Tid_search_ttl, ns, search);
|
||||
if (bgn_idx == Xow_data_mgr.File_idx_unknown) return;
|
||||
if (bgn_idx == Xodb_save_mgr_txt.File_idx_unknown) return;
|
||||
if (match_tid == Srch_special_page.Match_tid_all) {
|
||||
if (!this.Load_xdat_file(cancelable, tmp_xdat_file, Xotdb_dir_info_.Tid_search_ttl, ns, bgn_idx)) return;
|
||||
tmp_xdat_file.Find(tmp_xdat_itm, search, 0, Byte_ascii.Pipe, true);
|
||||
@@ -211,7 +212,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
// find itm by key
|
||||
tmp_xdat_file.Find(xdat_itm, key, parse_bgn, parse_dlm, exact);
|
||||
return !xdat_itm.Missing();
|
||||
} private final Int_obj_ref tmp_len = Int_obj_ref.zero_();
|
||||
} private final Int_obj_ref tmp_len = Int_obj_ref.New_zero();
|
||||
public boolean Load_xdat_file(Cancelable cancelable, Xob_xdat_file xdat_file, byte regy_tid, int fil_idx) {return Load_xdat_file(cancelable, xdat_file, regy_tid, null, fil_idx);}
|
||||
boolean Load_xdat_file(Cancelable cancelable, Xob_xdat_file xdat_file, byte regy_tid, Xow_ns ns, int fil_idx) {
|
||||
Io_url fil = ns == null ? fsys_mgr.Url_site_fil(regy_tid, fil_idx) : fsys_mgr.Url_ns_fil(regy_tid, ns.Id(), fil_idx);
|
||||
@@ -261,7 +262,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
}
|
||||
public byte[] Find_random_ttl(Xow_ns ns) {
|
||||
Xowd_regy_mgr regy_mgr = this.Get_regy_by_ns(ns);
|
||||
Int_obj_ref count = Int_obj_ref.zero_();
|
||||
Int_obj_ref count = Int_obj_ref.New_zero();
|
||||
Xob_random_itm[] files = Build_random_itms(regy_mgr, count);
|
||||
int random_idx = RandomAdp_.new_().Next(count.Val() - 1); // get a random idx; -1 since count is super 1 (EX: count of 1 mil; random_idx of 0 - 999,999)
|
||||
int file_idx = CompareAble_.FindSlot(Xob_random_itm_comparer.Instance, files, new Xob_random_itm(-1, random_idx, -1));
|
||||
@@ -295,7 +296,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
Load_xdat_file(Cancelable_.Never, tmp_xdat_file, fil);
|
||||
tmp_xdat_file.Find(tmp_xdat_itm, ctg_ttl, 0, Byte_ascii.Pipe, true);
|
||||
if (tmp_xdat_itm.Missing()) return false;
|
||||
List_adp ctgs = List_adp_.new_();
|
||||
List_adp ctgs = List_adp_.New();
|
||||
Load_ctg_v1_parse(ctgs, wiki.Appe().Usr_dlg(), tmp_xdat_itm.Itm_bry());
|
||||
ctgs.Sort_by(Xowd_page_itm_sorter.IdAsc);
|
||||
this.Load_by_ids(Cancelable_.Never, ctgs, 0, ctgs.Count());
|
||||
@@ -395,7 +396,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
}
|
||||
return rv;
|
||||
} private Xowd_regy_mgr[] ns_regys = new Xowd_regy_mgr[Xow_ns_mgr_.Ordinal_max];
|
||||
private Xowd_page_itm tmp_rslt_nxt = new Xowd_page_itm(), tmp_rslt_prv = new Xowd_page_itm(); private Int_obj_ref tmp_rslt_count = Int_obj_ref.zero_();
|
||||
private Xowd_page_itm tmp_rslt_nxt = new Xowd_page_itm(), tmp_rslt_prv = new Xowd_page_itm(); private Int_obj_ref tmp_rslt_count = Int_obj_ref.New_zero();
|
||||
public void Load_ttls_for_search_suggest(Cancelable cancelable, List_adp rslt_list, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item) {
|
||||
this.Load_ttls_for_all_pages(cancelable, rslt_list, tmp_rslt_nxt, tmp_rslt_prv, tmp_rslt_count, ns, key, max_results, min_page_len, browse_len, include_redirects, fetch_prv_item);
|
||||
}
|
||||
@@ -505,7 +506,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
public int Load_ctg_count(byte[] ttl) {return wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_1 ? Load_ctg_count_v1(ttl) : Load_ctg_count_v2(ttl);}
|
||||
int Load_ctg_count_v1(byte[] ttl) {
|
||||
Xoctg_view_ctg view_ctg = new Xoctg_view_ctg();
|
||||
Int_obj_ref count = Int_obj_ref.zero_();
|
||||
Int_obj_ref count = Int_obj_ref.New_zero();
|
||||
Load_ctg_v1_wkr(view_ctg, ttl, count);
|
||||
return count.Val();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ 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.xowa.wikis.data.*; import gplx.xowa.htmls.core.*;
|
||||
public interface Xodb_mgr extends GfoInvkAble {
|
||||
public interface Xodb_mgr extends Gfo_invk {
|
||||
byte Tid();
|
||||
String Tid_name();
|
||||
byte Category_version();
|
||||
|
||||
@@ -16,21 +16,21 @@ 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.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
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 Xowd_db_mgr(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Domain_itm());
|
||||
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.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;
|
||||
public Xowd_db_mgr Core_data_mgr() {return core_data_mgr;} private final Xowd_db_mgr core_data_mgr;
|
||||
public Xowe_wiki Wiki() {return wiki;} private final Xowe_wiki wiki;
|
||||
public Xodb_load_mgr Load_mgr() {return load_mgr;} private final Xodb_load_mgr_sql load_mgr;
|
||||
public Xodb_save_mgr Save_mgr() {return save_mgr;} private final Xodb_save_mgr_sql save_mgr;
|
||||
public Xow_db_mgr Core_data_mgr() {return core_data_mgr;} private final Xow_db_mgr core_data_mgr;
|
||||
public Xowe_wiki Wiki() {return wiki;} private final Xowe_wiki wiki;
|
||||
public Xodb_load_mgr Load_mgr() {return load_mgr;} private final Xodb_load_mgr_sql load_mgr;
|
||||
public Xodb_save_mgr Save_mgr() {return save_mgr;} private final Xodb_save_mgr_sql save_mgr;
|
||||
public byte Category_version() {return category_version;} private byte category_version = Xoa_ctg_mgr.Version_null;
|
||||
public DateAdp Dump_date_query() {
|
||||
DateAdp rv = wiki.Props().Modified_latest(); if (rv != null) return rv;
|
||||
|
||||
@@ -16,16 +16,18 @@ 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.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.core.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.core.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xodb_mgr_txt implements Xodb_mgr {
|
||||
public Xodb_mgr_txt(Xowe_wiki wiki, Xow_data_mgr data_mgr) {
|
||||
public Xodb_mgr_txt(Xowe_wiki wiki, Xow_page_mgr data_mgr) {
|
||||
this.wiki = wiki;
|
||||
load_mgr = new Xodb_load_mgr_txt(wiki);
|
||||
save_mgr = new Xodb_save_mgr_txt(wiki, load_mgr);
|
||||
} private Xowe_wiki wiki;
|
||||
public byte Tid() {return Tid_txt;} public static final byte Tid_txt = 0;
|
||||
public String Tid_name() {return "xdat";}
|
||||
public byte Data_storage_format() {return data_storage_format;} public void Data_storage_format_(byte v) {data_storage_format = v;} private byte data_storage_format = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
public byte Data_storage_format() {return data_storage_format;} public void Data_storage_format_(byte v) {data_storage_format = v;} private byte data_storage_format = gplx.core.ios.streams.Io_stream_.Tid_raw;
|
||||
public Xodb_load_mgr Load_mgr() {return load_mgr;} private Xodb_load_mgr_txt load_mgr;
|
||||
public Xodb_save_mgr Save_mgr() {return save_mgr;} private Xodb_save_mgr_txt save_mgr;
|
||||
public DateAdp Dump_date_query() {
|
||||
@@ -41,7 +43,7 @@ public class Xodb_mgr_txt implements Xodb_mgr {
|
||||
}
|
||||
return category_version;
|
||||
} byte category_version = Xoa_ctg_mgr.Version_null;
|
||||
public byte Search_version() {return gplx.xowa.addons.apps.searchs.specials.Srch_special_page.Version_2;}
|
||||
public byte Search_version() {return gplx.xowa.addons.wikis.searchs.specials.Srch_special_page.Version_2;}
|
||||
public void Search_version_refresh() {throw Err_.new_unimplemented();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_data_storage_format)) return Io_stream_.Obsolete_to_str(data_storage_format);
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
class Xodb_page_rdr__sql implements Xodb_page_rdr {
|
||||
private final Xowd_db_mgr db_mgr;
|
||||
private final Xowd_page_tbl page_tbl; private final Db_rdr rdr;
|
||||
private final Xow_db_mgr db_mgr;
|
||||
private final Xowd_page_tbl page_tbl; private final Db_rdr rdr;
|
||||
public Xodb_page_rdr__sql(Xowe_wiki wiki) {
|
||||
this.db_mgr = wiki.Data__core_mgr();
|
||||
this.page_tbl = db_mgr.Tbl__page();
|
||||
@@ -29,7 +29,7 @@ class Xodb_page_rdr__sql implements Xodb_page_rdr {
|
||||
public boolean Move_next() {return rdr.Move_next();}
|
||||
public boolean Read(Xowd_page_itm page) {
|
||||
page_tbl.Read_page__all(page, rdr);
|
||||
Xowd_text_tbl text_tbl = db_mgr.Dbs__get_by_id(page.Text_db_id()).Tbl__text();
|
||||
Xowd_text_tbl text_tbl = db_mgr.Dbs__get_by_id_or_fail(page.Text_db_id()).Tbl__text();
|
||||
page.Text_(text_tbl.Select(page.Id()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*; import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
public class Xodb_page_rdr__tdb implements Xodb_page_rdr {
|
||||
private final Xow_ns_mgr ns_mgr; private final Xotdb_fsys_mgr fsys_mgr;
|
||||
private final Xow_ns_mgr ns_mgr; private final Xotdb_fsys_mgr fsys_mgr;
|
||||
private int cur_ns_ord = -1; private Xow_ns cur_ns; private Io_url[] cur_file_ary; private Io_url cur_file; private int cur_file_idx = -1;
|
||||
private final Xob_xdat_file cur_xdat_file = new Xob_xdat_file(); private int cur_xdat_len, cur_xdat_idx; private final Xob_xdat_itm cur_xdat_itm = new Xob_xdat_itm();
|
||||
private final Xob_xdat_file cur_xdat_file = new Xob_xdat_file(); private int cur_xdat_len, cur_xdat_idx; private final Xob_xdat_itm cur_xdat_itm = new Xob_xdat_itm();
|
||||
private int page_id = 0;
|
||||
public Xodb_page_rdr__tdb(Xowe_wiki wiki) {
|
||||
this.ns_mgr = wiki.Ns_mgr(); this.fsys_mgr = wiki.Tdb_fsys_mgr();
|
||||
|
||||
@@ -26,11 +26,11 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
public int Page_id_next() {return page_id_next;} public void Page_id_next_(int v) {page_id_next = v;} private int page_id_next;
|
||||
public int Data_create(Xoa_ttl ttl, byte[] text_raw) {
|
||||
int ns_id = ttl.Ns().Id();
|
||||
Xowd_db_file db_file = db_mgr.Core_data_mgr().Db__core();
|
||||
Xow_db_file db_file = db_mgr.Core_data_mgr().Db__core();
|
||||
int ns_count = db_file.Tbl__ns().Select_ns_count(ns_id) + 1;
|
||||
int page_id = db_file.Tbl__cfg().Select_int_or("db", "page.id_next", -1);
|
||||
if (page_id == -1) { // HACK: changed for tests; was dbs.qrys.Db_qry_sql.rdr_("SELECT (Max(page_id) + 1) AS max_page_id FROM page;")
|
||||
Db_rdr rdr = db_mgr.Core_data_mgr().Tbl__page().conn.Stmt_select(db_file.Tbl__page().Tbl_name(), String_.Ary(db_file.Tbl__page().Fld_page_id()), Dbmeta_fld_itm.Str_ary_empty).Exec_select__rls_auto();
|
||||
Db_rdr rdr = db_mgr.Core_data_mgr().Tbl__page().Conn().Stmt_select(db_file.Tbl__page().Tbl_name(), String_.Ary(db_file.Tbl__page().Fld_page_id()), Dbmeta_fld_itm.Str_ary_empty).Exec_select__rls_auto();
|
||||
try {
|
||||
int max_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
@@ -41,8 +41,8 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
db_mgr.Core_data_mgr().Tbl__cfg().Upsert_int("db", "page.id_next", page_id + 1);
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
Xowd_db_mgr fsys_mgr = db_mgr.Core_data_mgr();
|
||||
Xowd_db_file page_text_db = fsys_mgr.Db__text();
|
||||
Xow_db_mgr fsys_mgr = db_mgr.Core_data_mgr();
|
||||
Xow_db_file page_text_db = fsys_mgr.Db__text();
|
||||
Xowd_text_tbl page_text_tbl = page_text_db.Tbl__text();
|
||||
byte[] text_zip = page_text_tbl.Zip(text_raw);
|
||||
boolean redirect = db_mgr.Wiki().Redirect_mgr().Is_redirect(text_raw, text_raw.length);
|
||||
@@ -66,7 +66,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
db_mgr.Core_data_mgr().Tbl__page().Update__redirect__modified(page_id, redirect, modified);
|
||||
Xowd_page_itm db_page = new Xowd_page_itm();
|
||||
db_mgr.Load_mgr().Load_by_id(db_page, page.Revision_data().Id());
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id(db_page.Text_db_id()).Tbl__text();
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id_or_fail(db_page.Text_db_id()).Tbl__text();
|
||||
text_tbl.Update(page.Revision_data().Id(), text_raw);
|
||||
// int html_db_id = db_page.Html_db_id();
|
||||
// if (html_db_id != -1)
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
int ns_id = ttl.Ns().Id();
|
||||
Xotdb_page_itm_.Txt_page_save(tmp, page_id, DateAdp_.Now(), ttl_bry, text, true);
|
||||
Io_url page_rdr_url = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_page, ns_id, fil_idx);
|
||||
byte[] page_rdr_bry = gplx.core.ios.Io_stream_rdr_.Load_all(page_rdr_url);
|
||||
byte[] page_rdr_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(page_rdr_url);
|
||||
Xob_xdat_file page_rdr = new Xob_xdat_file();
|
||||
if (Bry_.Len_gt_0(page_rdr_bry)) page_rdr.Parse(page_rdr_bry, page_rdr_bry.length, page_rdr_url);
|
||||
int row_idx = page_rdr.Count();
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Xow_abrv_wm_ {
|
||||
}
|
||||
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;
|
||||
byte[] suffix = (byte[])int_hash.Get_by(Int_obj_ref.New(tid)); if (suffix == null) return null;
|
||||
switch (tid) {
|
||||
case Xow_domain_tid_.Int__commons:
|
||||
case Xow_domain_tid_.Int__species:
|
||||
@@ -116,10 +116,10 @@ public class Xow_abrv_wm_ {
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
private static final Btrie_bwd_mgr bry_trie = Init_trie();
|
||||
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_();
|
||||
int_hash = Hash_adp_.New();
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
Init_trie_itm(rv, int_hash, "wiki" , Xow_domain_tid_.Int__wikipedia);
|
||||
Init_trie_itm(rv, int_hash, "wiktionary" , Xow_domain_tid_.Int__wiktionary);
|
||||
@@ -140,7 +140,7 @@ public class Xow_abrv_wm_ {
|
||||
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);
|
||||
Int_obj_ref itm = Int_obj_ref.New(tid);
|
||||
trie.Add(str, itm);
|
||||
hash.Add(itm, Bry_.new_u8(str));
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class Xow_abrv_wm_override {
|
||||
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 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();
|
||||
|
||||
@@ -81,8 +81,8 @@ class Xow_abrv_wm_fxt {
|
||||
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));
|
||||
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.To_str_and_clear(), "to_abrv");
|
||||
}
|
||||
public void Test_to_domain_bry(String wmf_key, String expd_domain) {
|
||||
|
||||
@@ -44,11 +44,11 @@ public class Xow_domain_uid_ {
|
||||
public static int To_int(Xow_domain_itm domain) {
|
||||
int domain_tid = 0;
|
||||
switch (domain.Domain_type_id()) {
|
||||
case Xow_domain_tid_.Int__home: return Tid_xowa;
|
||||
case Xow_domain_tid_.Int__home: return Tid_xowa;
|
||||
case Xow_domain_tid_.Int__commons: return Tid_commons;
|
||||
case Xow_domain_tid_.Int__wikidata: return Tid_wikidata;
|
||||
case Xow_domain_tid_.Int__wikidata: return Tid_wikidata;
|
||||
case Xow_domain_tid_.Int__mediawiki: return Tid_mediawiki;
|
||||
case Xow_domain_tid_.Int__meta: return Tid_meta;
|
||||
case Xow_domain_tid_.Int__meta: return Tid_meta;
|
||||
case Xow_domain_tid_.Int__incubator: return Tid_incubator;
|
||||
case Xow_domain_tid_.Int__wmfblog: return Tid_wmfblog;
|
||||
case Xow_domain_tid_.Int__species: return Tid_species;
|
||||
@@ -59,7 +59,7 @@ public class Xow_domain_uid_ {
|
||||
case Xow_domain_tid_.Int__wikiquote: domain_tid = Tid_sub_wikiquote; break;
|
||||
case Xow_domain_tid_.Int__wikibooks: domain_tid = Tid_sub_wikibooks; break;
|
||||
case Xow_domain_tid_.Int__wikiversity: domain_tid = Tid_sub_wikiversity; break;
|
||||
case Xow_domain_tid_.Int__wikinews: domain_tid = Tid_sub_wikinews; break;
|
||||
case Xow_domain_tid_.Int__wikinews: domain_tid = Tid_sub_wikinews; break;
|
||||
case Xow_domain_tid_.Int__wikimedia: domain_tid = Tid_sub_wikimedia; break;
|
||||
default: throw Err_.new_unhandled(domain.Domain_type_id());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Xow_domain_crt_itm_parser {
|
||||
return rv == null ? null : (Xow_domain_crt_kv_ary[])rv.To_ary_and_clear(Xow_domain_crt_kv_ary.class);
|
||||
}
|
||||
public List_adp Parse_as_obj_or_null(byte[] raw, boolean is_ary) {
|
||||
List_adp rv = List_adp_.new_();
|
||||
List_adp rv = List_adp_.New();
|
||||
byte[][] line_ary = Bry_split_.Split_lines(raw);
|
||||
int line_len = line_ary.length;
|
||||
for (int i = 0; i < line_len; ++i) {
|
||||
@@ -80,12 +80,12 @@ class Xow_domain_crt_itm_parser {
|
||||
else
|
||||
return new Xow_domain_crt_itm__wiki(raw); // EX: en.wikipedia.org
|
||||
}
|
||||
private static final Hash_adp_bry itm_hash = Hash_adp_bry.cs()
|
||||
private static final Hash_adp_bry itm_hash = Hash_adp_bry.cs()
|
||||
.Add_str_obj("<self>" , Xow_domain_crt_itm__self.Instance)
|
||||
.Add_str_obj("<same_type>" , Xow_domain_crt_itm__same_type.Instance)
|
||||
.Add_str_obj("<same_lang>" , Xow_domain_crt_itm__same_lang.Instance)
|
||||
.Add_str_obj("<any>" , Xow_domain_crt_itm__any_wiki.Instance)
|
||||
;
|
||||
private static final byte[] Wild_lang = Bry_.new_a7("*."), Wild_type = Bry_.new_a7(".*");
|
||||
public static final Xow_domain_crt_itm_parser Instance = new Xow_domain_crt_itm_parser(); Xow_domain_crt_itm_parser() {}
|
||||
private static final byte[] Wild_lang = Bry_.new_a7("*."), Wild_type = Bry_.new_a7(".*");
|
||||
public static final Xow_domain_crt_itm_parser Instance = new Xow_domain_crt_itm_parser(); Xow_domain_crt_itm_parser() {}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_domain_crt_kv_itm_mgr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private final List_adp list = List_adp_.New();
|
||||
public void Clear() {list.Clear();}
|
||||
@gplx.Internal protected void Add(Xow_domain_crt_kv_itm itm) {list.Add(itm);}
|
||||
public boolean Parse_as_itms(byte[] raw) {
|
||||
@@ -57,11 +57,11 @@ public class Xow_domain_crt_kv_itm_mgr {
|
||||
}
|
||||
class Xow_domain_crt_kv_itm {
|
||||
public Xow_domain_crt_kv_itm(Xow_domain_crt_itm key, Xow_domain_crt_itm val) {this.key = key; this.val = val;}
|
||||
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
|
||||
public Xow_domain_crt_itm Val() {return val;} private final Xow_domain_crt_itm val;
|
||||
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
|
||||
public Xow_domain_crt_itm Val() {return val;} private final Xow_domain_crt_itm val;
|
||||
}
|
||||
class Xow_domain_crt_kv_ary {
|
||||
public Xow_domain_crt_kv_ary(Xow_domain_crt_itm key, Xow_domain_crt_itm[] val) {this.key = key; this.val = val;}
|
||||
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
|
||||
public Xow_domain_crt_itm[] Val() {return val;} private final Xow_domain_crt_itm[] val;
|
||||
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
|
||||
public Xow_domain_crt_itm[] Val() {return val;} private final Xow_domain_crt_itm[] val;
|
||||
}
|
||||
|
||||
@@ -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.wikis.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_html_util implements GfoInvkAble {
|
||||
public class Xow_html_util implements Gfo_invk {
|
||||
public Xow_html_util(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_if_bool)) return If_bool(m.ReadStr("expr"), m.ReadStr("true_val"), m.ReadStr("false_val"));
|
||||
else if (ctx.Match(k, Invk_if_yn)) return If_yn(m.ReadStr("expr"), m.ReadStr("true_val"), m.ReadStr("false_val"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_if_bool = "if_bool", Invk_if_yn = "if_yn";
|
||||
String If_bool(String expr, String true_val, String false_val) {
|
||||
Object o = wiki.Appe().Gfs_mgr().Run_str(expr);
|
||||
|
||||
@@ -18,10 +18,10 @@ 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.core.brys.fmtrs.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_script_mgr implements GfoInvkAble {
|
||||
public class Xow_script_mgr implements Gfo_invk {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_set)) Set(m.ReadBry("key"), m.ReadBry("wiki_type"), m.ReadBry("script"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_set = "set";
|
||||
public void Exec(Xowe_wiki wiki) {
|
||||
|
||||
@@ -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.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_sys_cfg implements GfoInvkAble {
|
||||
public class Xow_sys_cfg implements Gfo_invk {
|
||||
public Xow_sys_cfg(Xowe_wiki wiki) {}
|
||||
public boolean Xowa_cmd_enabled() {return xowa_cmd_enabled;} public Xow_sys_cfg Xowa_cmd_enabled_(boolean v) {xowa_cmd_enabled = v; return this;} private boolean xowa_cmd_enabled;
|
||||
public boolean Xowa_proto_enabled() {return xowa_proto_enabled;} public Xow_sys_cfg Xowa_proto_enabled_(boolean v) {xowa_proto_enabled = v; return this;} private boolean xowa_proto_enabled;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_xowa_cmd_enabled_)) xowa_cmd_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_xowa_cmd_enabled_)) xowa_proto_enabled = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_xowa_cmd_enabled_ = "xowa_cmd_enabled_";
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ 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.*;
|
||||
public class Xow_user implements GfoInvkAble {
|
||||
public class Xow_user implements Gfo_invk {
|
||||
public byte[] Name() {return name;} private byte[] name = Bry_.new_a7("anonymous");
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_name_)) name = m.ReadBry("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_name_ = "name_";
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.metas; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xow_wiki_props implements GfoInvkAble {
|
||||
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) {
|
||||
@@ -42,6 +42,7 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
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"
|
||||
@@ -58,6 +59,7 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
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);
|
||||
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;
|
||||
@@ -70,7 +72,7 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
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 GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_main_page_ = "main_page_"
|
||||
|
||||
@@ -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.*;
|
||||
public class Xow_module_base implements GfoInvkAble {
|
||||
public class Xow_module_base implements Gfo_invk {
|
||||
public byte Enabled() {return enabled;} private byte enabled = Bool_.__byte;
|
||||
public boolean Enabled_y() {return enabled == Bool_.Y_byte;}
|
||||
public boolean Enabled_n() {return enabled == Bool_.N_byte;}
|
||||
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.To_nullable_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) enabled = Yn.To_nullable_byte(m.ReadStr("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_";
|
||||
|
||||
@@ -17,7 +17,7 @@ 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.htmls.heads.*; import gplx.xowa.htmls.modules.popups.*;
|
||||
public class Xow_module_mgr implements GfoInvkAble {
|
||||
public class Xow_module_mgr implements Gfo_invk {
|
||||
private Hash_adp_bry regy = Hash_adp_bry.cs();
|
||||
public Xow_module_mgr(Xowe_wiki wiki) {
|
||||
this.popup_mgr = new Xow_popup_mgr(wiki);
|
||||
@@ -35,6 +35,6 @@ public class Xow_module_mgr implements GfoInvkAble {
|
||||
public Xow_module_base Get(byte[] key) {return (Xow_module_base)regy.Get_by_bry(key);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_get = "get";
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.nss; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.bldrs.cmds.*; import gplx.xowa.apps.urls.*;
|
||||
public class Xow_ns implements GfoInvkAble {
|
||||
public class Xow_ns implements Gfo_invk {
|
||||
public Xow_ns(int id, byte case_match, byte[] name, boolean is_alias) {
|
||||
this.id = id; this.case_match = case_match; this.is_alias = is_alias;
|
||||
Name_bry_(name);
|
||||
@@ -99,7 +99,7 @@ public class Xow_ns implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_id)) return id;
|
||||
else if (ctx.Match(k, Invk_name_txt)) return name_ui;
|
||||
else if (ctx.Match(k, Invk_name_ui)) return Name_combo();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_subpages_enabled_ = "subpages_enabled_", Invk_id = "id", Invk_name_txt = "name_txt", Invk_name_ui = "name_ui";
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.nss; import gplx.*; import gplx.xowa.*; import gplx.xowa
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.bldrs.installs.*;
|
||||
import gplx.xowa.xtns.scribunto.*;
|
||||
public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
public class Xow_ns_mgr implements Gfo_invk, gplx.core.lists.ComparerAble {
|
||||
private Ordered_hash id_hash = Ordered_hash_.New(); // hash for retrieval by id
|
||||
private Hash_adp_bry name_hash; // hash for retrieval by name; note that ns names are case-insensitive "File:" == "fILe:"
|
||||
private Hash_adp_bry tmpl_hash; // hash for retrieval by name; PERF for templates
|
||||
@@ -55,11 +55,11 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
public Xow_ns Ords_get_at(int ord) {return ords[ord];}
|
||||
public int Ids_len() {return id_hash.Count();}
|
||||
public Xow_ns Ids_get_at(int idx) {return (Xow_ns)id_hash.Get_at(idx);}
|
||||
public Xow_ns Ids_get_or_null(int id) {return (Xow_ns)id_hash.Get_by(ns_hash_lkp.Val_(id));} private Int_obj_ref ns_hash_lkp = Int_obj_ref.zero_();
|
||||
public Xow_ns Ids_get_or_null(int id) {return (Xow_ns)id_hash.Get_by(ns_hash_lkp.Val_(id));} private Int_obj_ref ns_hash_lkp = Int_obj_ref.New_zero();
|
||||
private Xow_ns Ids_get_or_empty(int id) {
|
||||
Xow_ns rv = Ids_get_or_null(id);
|
||||
return rv == null ? Ns__empty : rv;
|
||||
} private static final Xow_ns Ns__empty = new Xow_ns(Int_.Max_value, Byte_.Zero, Bry_.Empty, false);
|
||||
} private static final Xow_ns Ns__empty = new Xow_ns(Int_.Max_value, Byte_.Zero, Bry_.Empty, false);
|
||||
public Xow_ns Names_get_or_null(byte[] name_bry) {return this.Names_get_or_null(name_bry, 0, name_bry.length);}
|
||||
public Xow_ns Names_get_or_null(byte[] src, int bgn, int end) {
|
||||
Object rv = name_hash.Get_by_mid(src, bgn, end);
|
||||
@@ -127,7 +127,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
Xow_ns project_ns = ords[ns.Ord_subj_id()];
|
||||
if (project_ns == null) return; // should warn or throw error; for now just exit
|
||||
ns.Name_bry_(Bry_.Replace(ns_name, Project_talk_fmt_arg, project_ns.Name_db()));
|
||||
} private static final byte[] Project_talk_fmt_arg = Bry_.new_a7("$1");
|
||||
} private static final byte[] Project_talk_fmt_arg = Bry_.new_a7("$1");
|
||||
private void Rebuild_hashes__add(Hash_adp_bry hash, Xow_ns ns, byte[] key) {
|
||||
Xow_ns_mgr_name_itm ns_itm = new Xow_ns_mgr_name_itm(key, ns);
|
||||
hash.Add_if_dupe_use_nth(key, ns_itm);
|
||||
@@ -162,7 +162,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
}
|
||||
++ns_count;
|
||||
if (!id_hash.Has(ns_hash_lkp.Val_(ns_id))) // NOTE: do not add if already exists; avoids alias
|
||||
id_hash.Add(Int_obj_ref.new_(ns.Id()), ns);
|
||||
id_hash.Add(Int_obj_ref.New(ns.Id()), ns);
|
||||
name_hash.Add_if_dupe_use_nth(ns.Name_db(), new Xow_ns_mgr_name_itm(ns.Name_db(), ns));
|
||||
return this;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
else if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
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 return GfoInvkAble_.Rv_unhandled;
|
||||
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";
|
||||
public static final String Invk_load = "load", Invk_clear = "clear";
|
||||
|
||||
@@ -37,6 +37,7 @@ public class Xow_ns_mgr_ {
|
||||
Xow_ns ns_name = ns_names.Get_at(i);
|
||||
int ns_id = ns_name.Id();
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id);
|
||||
if (ns == null) continue; // ns_id of -2 will not be found in site_ns
|
||||
ns.Name_bry_(ns_name.Name_db());
|
||||
}
|
||||
ns_names = lang.Ns_aliases();
|
||||
|
||||
@@ -16,23 +16,27 @@ 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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.pages.tags.*;
|
||||
public class Xopage_html_data {
|
||||
public Xopage_html_data(byte[] display_ttl, byte[] body) {
|
||||
this.display_ttl = display_ttl;
|
||||
this.body = body;
|
||||
}
|
||||
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
|
||||
public byte[] Body() {return body;} private final byte[] body;
|
||||
public Xopg_tag_mgr Head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr();
|
||||
public Xopg_tag_mgr Tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr();
|
||||
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
|
||||
public byte[] Body() {return body;} private final byte[] body;
|
||||
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_y_() {this.cbk_enabled = true;}
|
||||
public Xopg_tag_mgr Head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr(Bool_.Y);
|
||||
public Xopg_tag_mgr Tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr(Bool_.N);
|
||||
|
||||
public void Apply(Xoa_page page) {
|
||||
page.Html_data().Html_restricted_n_();
|
||||
page.Html_data().Skip_parse_(Bool_.Y);
|
||||
page.Html_data().Display_ttl_(display_ttl);
|
||||
page.Html_data().Custom_body_(this.Body());
|
||||
page.Html_data().Custom_head_tags().Copy(head_tags);
|
||||
page.Html_data().Custom_tail_tags().Copy(tail_tags);
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
html_data.Html_restricted_n_();
|
||||
html_data.Skip_parse_(Bool_.Y);
|
||||
html_data.Display_ttl_(display_ttl);
|
||||
html_data.Custom_body_(this.Body());
|
||||
html_data.Custom_head_tags().Copy(head_tags);
|
||||
html_data.Custom_tail_tags().Copy(tail_tags);
|
||||
html_data.Cbk_enabled_(cbk_enabled);
|
||||
}
|
||||
|
||||
public static Xopage_html_data err_(String msg) {return new Xopage_html_data(Bry_.Empty, Bry_.new_u8(msg));}
|
||||
|
||||
@@ -20,8 +20,8 @@ import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
public class Xopg_hdump_data {
|
||||
public byte[] Body() {return body;} public void Body_(byte[] v) {body = v;} private byte[] body;
|
||||
public Xopg_redlink_idx_list Redlink_mgr() {return redlink_mgr;} private final Xopg_redlink_idx_list redlink_mgr = new Xopg_redlink_idx_list();
|
||||
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.new_();
|
||||
public Xopg_redlink_idx_list Redlink_mgr() {return redlink_mgr;} private final Xopg_redlink_idx_list redlink_mgr = new Xopg_redlink_idx_list();
|
||||
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.New();
|
||||
public void Imgs_add(Xohd_img_itm itm) {imgs.Add(itm);}
|
||||
public void Imgs_add_img(Xohd_img_itm__base img, Xof_file_itm xfer, int tid) {
|
||||
img.Data_init_base
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.xtns.indicators.*;
|
||||
import gplx.xowa.xtns.pagebanners.*;
|
||||
import gplx.xowa.xtns.pagebanners.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
public class Xopg_html_data {
|
||||
private Ordered_hash ctg_hash;
|
||||
public boolean Html_restricted() {return html_restricted;} private boolean html_restricted = true;
|
||||
@@ -31,17 +31,20 @@ public class Xopg_html_data {
|
||||
? display_ttl_vnt // return variant title; DATE:2014-08-29
|
||||
: display_ttl // return normal title
|
||||
;
|
||||
}
|
||||
}
|
||||
public Xopg_html_data Display_ttl_(byte[] v) {display_ttl = v; return this;} private byte[] display_ttl;
|
||||
public boolean Mode_wtxt_shown() {synchronized (this) {return mode_wtxt_shown;}} public void Mode_wtxt_shown_y_() {synchronized (this) {this.mode_wtxt_shown = true;}} private boolean mode_wtxt_shown;
|
||||
public byte[] Display_ttl_vnt() {return display_ttl_vnt;} public void Display_ttl_vnt_(byte[] v) {display_ttl_vnt = v;} private byte[] display_ttl_vnt;
|
||||
public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {content_sub = v;} private byte[] content_sub;
|
||||
public Xopg_page_heading Page_heading() {return page_heading;} private final Xopg_page_heading page_heading = new Xopg_page_heading();
|
||||
public String Bmk_pos() {return html_bmk_pos;} public void Bmk_pos_(String v) {html_bmk_pos = v;} private String html_bmk_pos;
|
||||
public Bry_bfr Portal_div_xtn() {return portal_div_xtn;} private Bry_bfr portal_div_xtn = Bry_bfr.reset_(255);
|
||||
public Bry_bfr Portal_div_xtn() {return portal_div_xtn;} private Bry_bfr portal_div_xtn = Bry_bfr_.Reset(255);
|
||||
public byte[] Edit_preview_w_dbg() {return Bry_.Add(xtn_scribunto_dbg, edit_preview);} public void Edit_preview_(byte[] v) {edit_preview = v;} private byte[] edit_preview = Bry_.Empty;
|
||||
public int Lnke_autonumber_next() {return lnke_autonumber++;} private int lnke_autonumber = 1;
|
||||
public int Sect_uid() {return sect_uid;} private int sect_uid = -1; public int Sect_uid_next() {return ++sect_uid;}
|
||||
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_(boolean v) {this.cbk_enabled = v;}
|
||||
public boolean Hdump_exists() {return hdump_exists;} private boolean hdump_exists; public void Hdump_exists_(boolean v) {this.hdump_exists = v;}
|
||||
|
||||
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
|
||||
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
|
||||
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
|
||||
@@ -55,8 +58,8 @@ public class Xopg_html_data {
|
||||
public Pgbnr_itm Xtn_pgbnr() {return xtn_pgbnr;} public void Xtn_pgbnr_(Pgbnr_itm v) {xtn_pgbnr = v;} private Pgbnr_itm xtn_pgbnr;
|
||||
public Xoh_head_mgr Head_mgr() {return module_mgr;} private Xoh_head_mgr module_mgr = new Xoh_head_mgr();
|
||||
public boolean Skip_parse() {return skip_parse;} public void Skip_parse_(boolean v) {skip_parse = v;} private boolean skip_parse;
|
||||
public Xopg_tag_mgr Custom_head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr();
|
||||
public Xopg_tag_mgr Custom_tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr();
|
||||
public Xopg_tag_mgr Custom_head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr(Bool_.Y);
|
||||
public Xopg_tag_mgr Custom_tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr(Bool_.N);
|
||||
public byte[] Custom_html() {return custom_html;} public Xopg_html_data Custom_html_(byte[] v) {custom_html = v; return this;} private byte[] custom_html;
|
||||
public byte[] Custom_body() {return custom_body;} public Xopg_html_data Custom_body_(byte[] v) {custom_body = v; return this;} private byte[] custom_body;
|
||||
public byte[] Custom_tab_name() {return custom_tab_name;} public Xopg_html_data Custom_tab_name_(byte[] v) {custom_tab_name = v; return this;} private byte[] custom_tab_name;
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.xowa.guis.views.*;
|
||||
public class Xopg_tab_data {
|
||||
public Xog_tab_itm Tab() {return tab;} public void Tab_(Xog_tab_itm v) {this.tab = v;} private Xog_tab_itm tab;
|
||||
public boolean Cancel_show() {return cancel_show;} public void Cancel_show_y_() {this.cancel_show = true;} private boolean cancel_show; // used for Special:Search
|
||||
public Xog_tab_close_mgr Close_mgr() {return close_mgr;} private final Xog_tab_close_mgr close_mgr = new Xog_tab_close_mgr();
|
||||
public Xog_tab_close_mgr Close_mgr() {return close_mgr;} private final Xog_tab_close_mgr close_mgr = new Xog_tab_close_mgr();
|
||||
public void Clear() {
|
||||
this.cancel_show = false;
|
||||
this.tab = null;
|
||||
|
||||
@@ -1,70 +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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Xopg_tag_itm {
|
||||
public Xopg_tag_itm(byte[] name, byte[] text, Keyval... atrs_ary) {
|
||||
this.Name = name;
|
||||
this.Text = text;
|
||||
this.Atrs_ary = atrs_ary;
|
||||
}
|
||||
public final byte[] Name;
|
||||
public final byte[] Text;
|
||||
public final Keyval[] Atrs_ary;
|
||||
public void To_html(Bry_bfr bfr) {
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn);
|
||||
bfr.Add(Name);
|
||||
int len = Atrs_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
bfr.Add_byte_space();
|
||||
Keyval atr = Atrs_ary[i];
|
||||
bfr.Add_str_a7(atr.Key());
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
bfr.Add_str_a7(atr.Val_to_str_or_empty());
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
if (Bry_.Eq(Name, Gfh_tag_.Bry__link)) return;
|
||||
if (Text != null) {
|
||||
bfr.Add_byte_nl();
|
||||
bfr.Add(Text);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
|
||||
bfr.Add(Name);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
}
|
||||
|
||||
public static Xopg_tag_itm New_css_file(Io_url href) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__link , null, Keyval_.new_("type", "text/css"), Keyval_.new_("rel", "stylesheet"), Keyval_.new_("href", href.To_http_file_str()));
|
||||
}
|
||||
public static Xopg_tag_itm New_css_code(byte[] code) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__style , code, Keyval_.new_("type", "text/css"));
|
||||
}
|
||||
public static Xopg_tag_itm New_js_file(Io_url src) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__script , null, Keyval_.new_("type", "text/javascript"), Keyval_.new_("src", src.To_http_file_str()));
|
||||
}
|
||||
public static Xopg_tag_itm New_js_code(byte[] code) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__script , code, Keyval_.new_("type", "text/javascript"));
|
||||
}
|
||||
public static Xopg_tag_itm New_html_code(Io_url url, String tmpl) {
|
||||
byte[] html = Io_mgr.Instance.LoadFilBry(url);
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__script , html, Keyval_.new_("type", "text/html"), Keyval_.new_("id", tmpl));
|
||||
}
|
||||
}
|
||||
152
400_xowa/src/gplx/xowa/wikis/pages/Xow_page_mgr.java
Normal file
152
400_xowa/src/gplx/xowa/wikis/pages/Xow_page_mgr.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.guis.views.*; import gplx.xowa.parsers.utils.*;
|
||||
public class Xow_page_mgr implements Gfo_invk {
|
||||
private final Xowe_wiki wiki;
|
||||
public Xow_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public Xoae_page Load_page_by_ttl (Xoa_ttl ttl) {return Load_page(ttl, Bool_.N);}
|
||||
public Xoae_page Load_page_by_ttl_for_msg (Xoa_ttl ttl) {return Load_page(ttl, Bool_.Y);}
|
||||
private Xoae_page Load_page(Xoa_ttl ttl, boolean called_from_msg) {
|
||||
Xoae_page rv = Xoae_page.New(wiki, ttl);
|
||||
Load_by_ns(rv, wiki.Utl__url_parser().Parse(ttl.Raw()), ttl, called_from_msg);
|
||||
return rv;
|
||||
}
|
||||
private void Load_by_ns(Xoae_page rv, Xoa_url url, Xoa_ttl ttl, boolean called_from_msg) {
|
||||
rv.Url_(url); // NOTE: must update page.Url(); should combine with Xoae_page.New()
|
||||
Xow_ns ns = ttl.Ns();
|
||||
switch (ns.Id()) {
|
||||
case Xow_ns_.Tid__special: // Special pages are built (not loaded from db)
|
||||
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
|
||||
if (rv.Redirect_to_ttl() != null) {
|
||||
ttl = wiki.Ttl_parse(rv.Redirect_to_ttl());
|
||||
url = wiki.Utl__url_parser().Parse(ttl.Raw());
|
||||
rv.Redirect_to_ttl_(null);
|
||||
Load_by_ns(rv, url, ttl, called_from_msg);
|
||||
}
|
||||
return;
|
||||
case Xow_ns_.Tid__mediawiki: // MediaWiki msgs can either be loaded from memory, or from database
|
||||
if ( !called_from_msg // if called_from_msg, fall through to actual data retrieval below, else infinite loop; DATE:2014-05-09
|
||||
&& Xow_page_tid.Identify_by_ttl(ttl.Page_db()) == Xow_page_tid.Tid_wikitext // skip ".js" and ".css" pages in MediaWiki; DATE:2014-06-13
|
||||
) {
|
||||
Xol_lang_itm lang = wiki.Lang();
|
||||
byte[] msg_key = ttl.Page_db();
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
msg_key = lang.Case_mgr().Case_build_1st_lower(tmp_bfr, msg_key, 0, msg_key.length);
|
||||
byte[] msg_val = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, wiki.Lang(), msg_key).Val(); // NOTE: do not change to Get_msg_val; Get_msg_val, also replaces $1 with values, and $1 needs to be preserved for callers;
|
||||
rv.Data_raw_(msg_val);
|
||||
tmp_bfr.Mkr_rls();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
Load_from_db(rv, ns, ttl, url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
|
||||
}
|
||||
private void Load_from_db(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean redirect_force) {
|
||||
int redirects = 0;
|
||||
Xowd_page_itm page_row = Xowd_page_itm.new_tmp();
|
||||
while (true) { // loop until (a) no more redirects or (b) page not found
|
||||
// load from page table
|
||||
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(page_row, ns, ttl.Page_db());
|
||||
if (!exists) {rv.Missing_(); return;}
|
||||
if (wiki.App().Mode().Tid_is_gui()) // NOTE: must check if gui, else will write during mass build; DATE:2014-05-03
|
||||
wiki.Appe().Usr_dlg().Prog_many("", "", "loading page for ~{0}", ttl.Raw());
|
||||
|
||||
// load from text table
|
||||
wiki.Db_mgr().Load_mgr().Load_page(page_row, ns);
|
||||
byte[] wtxt = page_row.Text();
|
||||
rv.Data_raw_(wtxt).Revision_data().Modified_on_(page_row.Modified_on()).Id_(page_row.Id()).Html_db_id_(page_row.Html_db_id());
|
||||
if (redirect_force) return; // redirect_force passed; return page now, even if page is a redirect elsewhere
|
||||
|
||||
// handle redirects
|
||||
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect(wtxt);
|
||||
if ( redirect_ttl == null // not a redirect
|
||||
|| redirects++ > 4) // too many redirects; something went wrong
|
||||
return;
|
||||
|
||||
// redirect; do some bookkeeping and reset ns / ttl
|
||||
rv.Redirected_ttls().Add(ttl.Full_url()); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
if (rv.Redirected_src() == null) rv.Redirected_src_(wtxt); // only add src for first redirect; DATE:2014-07-11
|
||||
rv.Ttl_(redirect_ttl);
|
||||
ns = redirect_ttl.Ns();
|
||||
ttl = redirect_ttl;
|
||||
}
|
||||
}
|
||||
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl) {return Load_page_and_parse(url, ttl, wiki.Lang(), wiki.Appe().Gui_mgr().Browser_win().Active_tab(), true);}
|
||||
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl, Xol_lang_itm lang, Xog_tab_itm tab, boolean parse_page) {
|
||||
wiki.Init_assert();
|
||||
Xoae_page page = Xoae_page.New(wiki, ttl); page.Tab_data().Tab_(tab);
|
||||
// COMMENT: breaks bookmark; if (tab != null) tab.Page_ref_(page); // HACK: (1) null check for http server; (2) Page_ref_(page) needed for log in xobc
|
||||
this.Load_by_ns(page, url, ttl, false);
|
||||
if (page.Missing()) { // page doesn't exist; try variants
|
||||
boolean vnt_missing = true;
|
||||
Xol_vnt_mgr vnt_mgr = lang.Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) { // if vnt enabled, then try to load by vnt form; DATE:2015-09-15
|
||||
gplx.xowa.wikis.data.tbls.Xowd_page_itm page_itm = vnt_mgr.Convert_mgr().Convert_ttl(wiki, ttl);
|
||||
if (page_itm != null && page_itm.Exists()) {
|
||||
Xoa_ttl vnt_ttl = Xoa_ttl.parse(wiki, ttl.Ns().Id(), page_itm.Ttl_page_db());
|
||||
page = this.Load_page(vnt_ttl, false);
|
||||
vnt_missing = page.Missing();
|
||||
}
|
||||
}
|
||||
if (vnt_missing) {
|
||||
if (ttl.Ns().Id_is_file()) {
|
||||
Xowe_wiki commons_wiki = (Xowe_wiki)wiki.Appe().Wiki_mgr().Get_by_or_null(wiki.Commons_wiki_key());
|
||||
if (commons_wiki != null) { // commons exists
|
||||
if (!Bry_.Eq(wiki.Domain_bry(), commons_wiki.Domain_bry())) { // !Bry_.Eq is recursion guard
|
||||
Xoae_page rv = commons_wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, true);
|
||||
if (rv.Exists()) {
|
||||
rv.Commons_mgr().Source_wiki_(wiki);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
page.Missing_(false);
|
||||
page.Commons_mgr().Xowa_mockup_(true);
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return page.Missing_();
|
||||
}
|
||||
}
|
||||
if (page.Missing()) return page; // NOTE: commons can return null page
|
||||
page.Tab_data().Tab_(tab);
|
||||
page.Lang_(lang);
|
||||
if (parse_page)
|
||||
wiki.Parser_mgr().Parse(page, false); // NOTE: do not clear page b/c reused for search
|
||||
return page;
|
||||
}
|
||||
public void Redirect(Xoae_page page, byte[] page_bry) {
|
||||
Xoa_ttl trg_ttl = Xoa_ttl.parse(wiki, page_bry);
|
||||
Xoa_url trg_url = Xoa_url.new_(wiki.Domain_bry(), page_bry);
|
||||
page.Ttl_(trg_ttl).Url_(trg_url).Redirected_(true);
|
||||
wiki.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
|
||||
}
|
||||
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_create_enabled_)) wiki.Db_mgr().Save_mgr().Create_enabled_(m.ReadYn("v"));
|
||||
else if (ctx.Match(k, Invk_update_modified_on_enabled_)) wiki.Db_mgr().Save_mgr().Update_modified_on_enabled_(m.ReadYn("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_create_enabled_ = "create_enabled_", Invk_update_modified_on_enabled_ = "update_modified_on_enabled_";
|
||||
}
|
||||
46
400_xowa/src/gplx/xowa/wikis/pages/Xowe_page_mgr.java
Normal file
46
400_xowa/src/gplx/xowa/wikis/pages/Xowe_page_mgr.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xowe_page_mgr {
|
||||
private final Xowe_wiki wiki;
|
||||
public Xowe_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public Xoae_page Load_page(Xoa_url url, Xoa_ttl ttl, Xog_tab_itm tab) {
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
|
||||
Wait_for_popups();
|
||||
Xowe_wiki_.Rls_mem_if_needed(wiki);
|
||||
|
||||
// load page meta; wait_for_popups
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
|
||||
boolean hdump_exists = page.Revision_data().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred();
|
||||
page.Html_data().Hdump_exists_(hdump_exists);
|
||||
Wait_for_popups();
|
||||
|
||||
// load page text
|
||||
if (hdump_exists)
|
||||
wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page);
|
||||
else
|
||||
wiki.Parser_mgr().Parse(page, false);
|
||||
return page;
|
||||
}
|
||||
private static void Wait_for_popups() {// HACK: wait for popups to finish, else thread errors due to popups and loader mutating cached items
|
||||
int wait_count = 0;
|
||||
while (gplx.xowa.htmls.modules.popups.Xow_popup_mgr.Running() && ++wait_count < 100)
|
||||
gplx.core.threads.Thread_adp_.Sleep(10);
|
||||
}
|
||||
}
|
||||
31
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_alertify_.java
Normal file
31
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_alertify_.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.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.guis.cbks.*; import gplx.core.gfobjs.*;
|
||||
public class Xopg_alertify_ {
|
||||
public static void Add_tags(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
Io_url alertify_root = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "lib", "alertify");
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(alertify_root.GenSubFil_nest("themes", "alertify.core.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(alertify_root.GenSubFil_nest("themes", "alertify.bootstrap.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(alertify_root.GenSubFil_nest("lib", "alertify-0.3.11.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(alertify_root.GenSubFil_nest("lib", "xo-alertify-0.0.1.js")));
|
||||
}
|
||||
public static void Exec_log(Xog_json_wkr wkr, String msg) {
|
||||
wkr.Send_json("xo.alertify.log_by_str", Gfobj_nde.New().Add_str("msg", msg));
|
||||
}
|
||||
}
|
||||
88
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_tag_itm.java
Normal file
88
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_tag_itm.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
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.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Xopg_tag_itm {
|
||||
Xopg_tag_itm(byte tid, byte[] node, byte[] href, byte[] body, Keyval... atrs) {
|
||||
this.tid = tid;
|
||||
this.node = node;
|
||||
this.href = href;
|
||||
this.body = body;
|
||||
this.atrs = atrs;
|
||||
}
|
||||
public final String Source = "xowa";
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public byte[] Node() {return node;} private final byte[] node;
|
||||
public byte[] Href() {return href;} private final byte[] href;
|
||||
public byte[] Body() {return body;} private final byte[] body;
|
||||
public Keyval[] Atrs() {return atrs;} private final Keyval[] atrs;
|
||||
public void To_html(Bry_bfr bfr) {
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn);
|
||||
bfr.Add(node);
|
||||
To_html_atr(bfr, "data-source", "xowa");
|
||||
int len = atrs.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Keyval atr = atrs[i];
|
||||
To_html_atr(bfr, atr.Key(), atr.Val_to_str_or_empty());
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
if (!Bry_.Eq(node, Gfh_tag_.Bry__link)) {
|
||||
if (body != null) {
|
||||
bfr.Add_byte_nl();
|
||||
bfr.Add(body);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
|
||||
bfr.Add(node);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
}
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
private static void To_html_atr(Bry_bfr bfr, String key, String val) {
|
||||
bfr.Add_byte_space();
|
||||
bfr.Add_str_a7(key);
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
bfr.Add_str_a7(val);
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
}
|
||||
|
||||
public static final byte Tid__css_file = 0, Tid__css_code = 1, Tid__js_file = 2, Tid__js_code = 3, Tid__htm_frag = 4;
|
||||
private static final Keyval
|
||||
Tag__type_css = Keyval_.new_("type", "text/css"), Tag__type_js = Keyval_.new_("type", "text/javascript"), Tag__type_html = Keyval_.new_("type", "text/html")
|
||||
, Tag__rel_stylesheet = Keyval_.new_("rel", "stylesheet");
|
||||
public static Xopg_tag_itm New_css_file(Io_url href_url) {
|
||||
byte[] href = href_url.To_http_file_bry();
|
||||
return new Xopg_tag_itm(Tid__css_file, Gfh_tag_.Bry__link , href, null, Tag__type_css, Tag__rel_stylesheet, Keyval_.new_("href", String_.new_u8(href)));
|
||||
}
|
||||
public static Xopg_tag_itm New_css_code(byte[] code) {
|
||||
return new Xopg_tag_itm(Tid__css_code, Gfh_tag_.Bry__style , null, code, Tag__type_css);
|
||||
}
|
||||
public static Xopg_tag_itm New_js_file(Io_url src_url) {
|
||||
byte[] src = src_url.To_http_file_bry();
|
||||
return new Xopg_tag_itm(Tid__js_file , Gfh_tag_.Bry__script, src , null, Tag__type_js, Keyval_.new_("src", String_.new_u8(src)));
|
||||
}
|
||||
public static Xopg_tag_itm New_js_code(String code) {return New_js_code(Bry_.new_u8(code));}
|
||||
public static Xopg_tag_itm New_js_code(byte[] code) {
|
||||
return new Xopg_tag_itm(Tid__js_code , Gfh_tag_.Bry__script, null, code, Tag__type_js);
|
||||
}
|
||||
public static Xopg_tag_itm New_htm_frag(Io_url url, String id) {
|
||||
byte[] html = Io_mgr.Instance.LoadFilBry(url);
|
||||
return new Xopg_tag_itm(Tid__htm_frag, Gfh_tag_.Bry__script, null, html, Tag__type_html, Keyval_.new_("id", id));
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,11 @@ 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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xopg_tag_mgr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private final List_adp list = List_adp_.New();
|
||||
public Xopg_tag_mgr(boolean pos_is_head) {this.pos_is_head = pos_is_head;}
|
||||
public boolean Pos_is_head() {return pos_is_head;} private final boolean pos_is_head;
|
||||
public int Len() {return list.Len();}
|
||||
public Xopg_tag_itm Get_at(int i) {return (Xopg_tag_itm)list.Get_at(i);}
|
||||
public void Add(Xopg_tag_itm... ary) {for (Xopg_tag_itm itm : ary) list.Add(itm);}
|
||||
@@ -31,7 +33,6 @@ public class Xopg_tag_mgr {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm tag = this.Get_at(i);
|
||||
tag.To_html(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
@@ -39,11 +40,10 @@ public class Xopg_tag_mgr {
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm tag = this.Get_at(i);
|
||||
if ( Bry_.Eq(tag.Name, gplx.langs.htmls.Gfh_tag_.Bry__style)
|
||||
&& tag.Text != null
|
||||
if ( Bry_.Eq(tag.Node(), gplx.langs.htmls.Gfh_tag_.Bry__style)
|
||||
&& tag.Body() != null
|
||||
) {
|
||||
tag.To_html(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
112
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_tag_wtr.java
Normal file
112
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_tag_wtr.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
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.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Xopg_tag_wtr {
|
||||
public static boolean Loader_as_script_static = true; // TEST
|
||||
public static byte[] Write(Bry_bfr bfr, boolean write_loader_tag, Xopg_tag_wtr_cbk cbk, Xopg_tag_mgr tag_mgr) {
|
||||
boolean loader_as_script = Loader_as_script_static; // allow disabling for dekstop later
|
||||
boolean embed_loader = !gplx.core.envs.Op_sys.Cur().Tid_is_drd(); // PERF: drd will embed in bundle.js
|
||||
|
||||
// get files_count
|
||||
int len = tag_mgr.Len();
|
||||
int files_total = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm itm = tag_mgr.Get_at(i);
|
||||
if (loader_as_script) {
|
||||
switch (itm.Tid()) {
|
||||
case Xopg_tag_itm.Tid__js_file:
|
||||
++files_total;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bgn loader_as_script
|
||||
if (loader_as_script) {
|
||||
if (write_loader_tag) bfr.Add(Gfh_tag_.Script_lhs_w_type).Add_byte_nl();
|
||||
if (embed_loader && tag_mgr.Pos_is_head())
|
||||
Wtr.Add_loader_func(bfr);
|
||||
if (files_total > 0) Wtr.Add_files_bgn(bfr);
|
||||
}
|
||||
|
||||
// write tags
|
||||
len = tag_mgr.Len();
|
||||
int files_idx = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm itm = tag_mgr.Get_at(i);
|
||||
if (loader_as_script) {
|
||||
switch (itm.Tid()) {
|
||||
case Xopg_tag_itm.Tid__js_file:
|
||||
Wtr.Add_files_itm(bfr, itm, files_idx++);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
cbk.Write_tag(bfr, itm);
|
||||
}
|
||||
|
||||
// end loader_as_script
|
||||
if (loader_as_script) {
|
||||
if (files_total > 0) Wtr.Add_files_end(bfr, files_total);
|
||||
if (write_loader_tag) bfr.Add(Gfh_tag_.Script_rhs).Add_byte_nl();
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm itm = tag_mgr.Get_at(i);
|
||||
switch (itm.Tid()) {
|
||||
case Xopg_tag_itm.Tid__js_file: continue;
|
||||
}
|
||||
cbk.Write_tag(bfr, itm);
|
||||
}
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
static class Wtr { //#*nested
|
||||
public static void Add_loader_func(Bry_bfr bfr) {
|
||||
bfr.Add_str_a7_w_nl(" function load_files_sequentially(files, idx, done_cbk) {");
|
||||
bfr.Add_str_a7_w_nl(" if (files[idx]) { // idx is valid");
|
||||
bfr.Add_str_a7_w_nl(" var script = document.createElement('script');");
|
||||
bfr.Add_str_a7_w_nl(" script.setAttribute('type','text/javascript');");
|
||||
bfr.Add_str_a7_w_nl(" script.setAttribute('src', files[idx]);");
|
||||
bfr.Add_str_a7_w_nl(" script.onload = function(){");
|
||||
bfr.Add_str_a7_w_nl(" load_files_sequentially(files, ++idx, done_cbk); // load next file");
|
||||
bfr.Add_str_a7_w_nl(" };");
|
||||
bfr.Add_str_a7_w_nl(" document.getElementsByTagName('head')[0].appendChild(script)");
|
||||
bfr.Add_str_a7_w_nl(" }");
|
||||
bfr.Add_str_a7_w_nl(" else { // idx is not valid; finished;");
|
||||
bfr.Add_str_a7_w_nl(" done_cbk();");
|
||||
bfr.Add_str_a7_w_nl(" }");
|
||||
bfr.Add_str_a7_w_nl(" }");
|
||||
}
|
||||
public static void Add_files_bgn(Bry_bfr bfr) {
|
||||
bfr.Add_str_a7_w_nl(" var files =");
|
||||
}
|
||||
public static void Add_files_itm(Bry_bfr bfr, Xopg_tag_itm itm, int idx) {
|
||||
bfr.Add_str_a7(idx == 0 ? " [ '" : " , '");
|
||||
bfr.Add(itm.Href());
|
||||
bfr.Add_byte_apos().Add_byte_nl();
|
||||
}
|
||||
public static void Add_files_end(Bry_bfr bfr, int files_count) {
|
||||
bfr.Add_str_a7_w_nl(" ];");
|
||||
bfr.Add_str_a7_w_nl(" load_files_sequentially(files, 0, function() {");
|
||||
bfr.Add_str_a7_w_nl(" console.log('javascript files loaded: count=" + files_count + "');");
|
||||
bfr.Add_str_a7_w_nl(" });");
|
||||
}
|
||||
}
|
||||
}
|
||||
39
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_tag_wtr_.java
Normal file
39
400_xowa/src/gplx/xowa/wikis/pages/tags/Xopg_tag_wtr_.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xopg_tag_wtr_{
|
||||
public static void Add__xocss(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xocss", "core");
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xocss_core-0.0.1.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xoimg_core-0.0.1.css")));
|
||||
}
|
||||
public static void Add__xohelp(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
Io_url css_dir = http_root.GenSubDir_nest("bin", "any", "xowa", "html", "res", "src", "xowa", "xocss", "help");
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(css_dir.GenSubFil_nest("xohelp-0.0.1.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(css_dir.GenSubFil_nest("xohelp-0.0.1.js")));
|
||||
}
|
||||
public static void Add__mustache(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "mustache", "mustache-2.2.1.js")));
|
||||
}
|
||||
public static void Add__jquery(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "jquery", "jquery-1.11.3.js")));
|
||||
}
|
||||
public static void Add__notifyjs(Xopg_tag_mgr head_tags, Io_url http_root) {
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(http_root.GenSubFil_nest("bin", "any", "xowa", "html", "res", "lib", "notifyjs", "notifyjs-0.3.1.js")));
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ 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.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xowd_css_file_itm {
|
||||
public Xowd_css_file_itm(int css_id, String path, byte[] data) {this.css_id = css_id; this.path = path; this.data = data;}
|
||||
public int Css_id() {return css_id;} private final int css_id;
|
||||
public String Path() {return path;} private final String path;
|
||||
public byte[] Data() {return data;} private final byte[] data;
|
||||
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public interface Xopg_tag_wtr_cbk {
|
||||
void Write_tag(Bry_bfr bfr, Xopg_tag_itm itm);
|
||||
}
|
||||
class Xopg_tag_wtr_cbk__basic implements Xopg_tag_wtr_cbk {
|
||||
public void Write_tag(Bry_bfr bfr, Xopg_tag_itm itm) {itm.To_html(bfr);}
|
||||
}
|
||||
@@ -15,12 +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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xowd_css_core_itm {
|
||||
public Xowd_css_core_itm(int id, String key, DateAdp updated_on) {
|
||||
this.id = id; this.key = key; this.updated_on = updated_on;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Key() {return key;} private final String key;
|
||||
public DateAdp Updated_on() {return updated_on;} private final DateAdp updated_on;
|
||||
}
|
||||
package gplx.xowa.wikis.pages.tags; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xopg_tag_wtr_cbk_ {
|
||||
public static final Xopg_tag_wtr_cbk Basic = new Xopg_tag_wtr_cbk__basic();
|
||||
}
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class ByteAry_fil {
|
||||
public List_adp Itms() {return itms;} List_adp itms = List_adp_.new_();
|
||||
public List_adp Itms() {return itms;} List_adp itms = List_adp_.New();
|
||||
public Io_url Fil() {return fil;} Io_url fil;
|
||||
public byte[] Raw_bry() {return raw_bry;} private byte[] raw_bry = Bry_.Empty;
|
||||
public int Raw_len() {return raw_len.Val();} Int_obj_ref raw_len = Int_obj_ref.zero_();
|
||||
public int Raw_len() {return raw_len.Val();} Int_obj_ref raw_len = Int_obj_ref.New_zero();
|
||||
public int Raw_max() {return raw_max;} private int raw_max = Io_mgr.Len_mb;
|
||||
public ByteAry_fil Ini_file(Io_url fil) {
|
||||
this.fil = fil;
|
||||
@@ -35,5 +35,5 @@ public class ByteAry_fil {
|
||||
raw_len.Val_zero_();
|
||||
return rv;
|
||||
}
|
||||
public static final ByteAry_fil Instance = new ByteAry_fil(); ByteAry_fil() {}
|
||||
public static final ByteAry_fil Instance = new ByteAry_fil(); ByteAry_fil() {}
|
||||
}
|
||||
|
||||
@@ -30,24 +30,24 @@ public class Xotdb_dir_info {
|
||||
ext_bry = Wtr_ext(v);
|
||||
ext_str = String_.new_a7(ext_bry);
|
||||
return this;
|
||||
} byte ext_tid = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
public static final String Wtr_xdat_str = ".xdat", Wtr_zip_str = ".zip", Wtr_gz_str = ".gz", Wtr_bz2_str = ".bz2";
|
||||
public static final byte[] Wtr_xdat_bry = Bry_.new_a7(Wtr_xdat_str), Wtr_zip_bry = Bry_.new_a7(Wtr_zip_str), Wtr_gz_bry = Bry_.new_a7(Wtr_gz_str), Wtr_bz2_bry = Bry_.new_a7(Wtr_bz2_str);
|
||||
} byte ext_tid = gplx.core.ios.streams.Io_stream_.Tid_raw;
|
||||
public static final String Wtr_xdat_str = ".xdat", Wtr_zip_str = ".zip", Wtr_gz_str = ".gz", Wtr_bz2_str = ".bz2";
|
||||
public static final byte[] Wtr_xdat_bry = Bry_.new_a7(Wtr_xdat_str), Wtr_zip_bry = Bry_.new_a7(Wtr_zip_str), Wtr_gz_bry = Bry_.new_a7(Wtr_gz_str), Wtr_bz2_bry = Bry_.new_a7(Wtr_bz2_str);
|
||||
public static String Wtr_dir(byte v) {
|
||||
switch (v) {
|
||||
case gplx.core.ios.Io_stream_.Tid_raw : return "";
|
||||
case gplx.core.ios.Io_stream_.Tid_zip : return "_zip";
|
||||
case gplx.core.ios.Io_stream_.Tid_gzip : return "_gz";
|
||||
case gplx.core.ios.Io_stream_.Tid_bzip2 : return "_bz2";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_raw : return "";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_zip : return "_zip";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_gzip : return "_gz";
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_bzip2 : return "_bz2";
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static byte[] Wtr_ext(byte v) {
|
||||
switch (v) {
|
||||
case gplx.core.ios.Io_stream_.Tid_raw : return Wtr_xdat_bry;
|
||||
case gplx.core.ios.Io_stream_.Tid_zip : return Wtr_zip_bry;
|
||||
case gplx.core.ios.Io_stream_.Tid_gzip : return Wtr_gz_bry;
|
||||
case gplx.core.ios.Io_stream_.Tid_bzip2 : return Wtr_bz2_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_raw : return Wtr_xdat_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_zip : return Wtr_zip_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_gzip : return Wtr_gz_bry;
|
||||
case gplx.core.ios.streams.Io_stream_.Tid_bzip2 : return Wtr_bz2_bry;
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,19 +20,19 @@ import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.tdbs.utils.*;
|
||||
public class Xotdb_fsys_mgr {
|
||||
private final Io_url root_dir; private final Xow_ns_mgr ns_mgr;
|
||||
private final Io_url root_dir; private final Xow_ns_mgr ns_mgr;
|
||||
public Xotdb_fsys_mgr(Io_url root_dir, Xow_ns_mgr ns_mgr) {
|
||||
this.root_dir = root_dir; this.ns_mgr = ns_mgr;
|
||||
this.tmp_dir = root_dir.GenSubDir("tmp");
|
||||
this.ns_dir = root_dir.GenSubDir(Xotdb_dir_info_.Name_ns);
|
||||
this.site_dir = root_dir.GenSubDir(Xotdb_dir_info_.Name_site);
|
||||
}
|
||||
public Io_url Tmp_dir() {return tmp_dir;} private final Io_url tmp_dir;
|
||||
public Io_url Ns_dir() {return ns_dir;} private final Io_url ns_dir;
|
||||
public Io_url Site_dir() {return site_dir;} private final Io_url site_dir;
|
||||
public Io_url Tmp_dir() {return tmp_dir;} private final Io_url tmp_dir;
|
||||
public Io_url Ns_dir() {return ns_dir;} private final Io_url ns_dir;
|
||||
public Io_url Site_dir() {return site_dir;} private final Io_url site_dir;
|
||||
public Io_url Cfg_wiki_core_fil() {return root_dir.GenSubFil_nest(Const_url_cfg, "wiki_core.gfs");}
|
||||
public Io_url Cfg_wiki_stats_fil() {return root_dir.GenSubFil_nest(Const_url_cfg, "wiki_stats.gfs");}
|
||||
public Xotdb_dir_info[] Tdb_dir_regy() {return dir_regy;} private final Xotdb_dir_info[] dir_regy = Xotdb_dir_info_.regy_();
|
||||
public Xotdb_dir_info[] Tdb_dir_regy() {return dir_regy;} private final Xotdb_dir_info[] dir_regy = Xotdb_dir_info_.regy_();
|
||||
public Io_url Url_ns_dir(String ns_num, byte tid) {return ns_dir.GenSubDir_nest(ns_num, Xotdb_dir_info_.Tid_name(tid));}
|
||||
public Io_url Url_ns_reg(String ns_num, byte tid) {return ns_dir.GenSubFil_nest(ns_num, Xotdb_dir_info_.Tid_name(tid), Xotdb_dir_info_.Name_reg_fil);}
|
||||
public Io_url Url_ns_fil(byte tid, int ns_id, int fil_idx) {
|
||||
@@ -56,21 +56,21 @@ public class Xotdb_fsys_mgr {
|
||||
private static void Scan_dirs_zip(Xotdb_fsys_mgr fsys_mgr, byte id) {
|
||||
Io_url[] dirs = Io_mgr.Instance.QueryDir_args(fsys_mgr.Ns_dir().GenSubDir_nest("000")).FilPath_("*page*").DirOnly_().Recur_(false).ExecAsUrlAry();
|
||||
int len = dirs.length;
|
||||
byte tid = gplx.core.ios.Io_stream_.Tid_raw; // needed for Xoa_xowa_exec_tst
|
||||
byte tid = gplx.core.ios.streams.Io_stream_.Tid_raw; // needed for Xoa_xowa_exec_tst
|
||||
for (int i = 0; i < len; i++) {
|
||||
Io_url dir = dirs[i];
|
||||
String dir_name = dir.NameOnly();
|
||||
if (String_.Eq(dir_name, "page")) {tid = gplx.core.ios.Io_stream_.Tid_raw; break;}
|
||||
else if (String_.Eq(dir_name, "page_zip")) tid = gplx.core.ios.Io_stream_.Tid_zip;
|
||||
else if (String_.Eq(dir_name, "page_gz")) tid = gplx.core.ios.Io_stream_.Tid_gzip;
|
||||
else if (String_.Eq(dir_name, "page_bz2")) tid = gplx.core.ios.Io_stream_.Tid_bzip2;
|
||||
if (String_.Eq(dir_name, "page")) {tid = gplx.core.ios.streams.Io_stream_.Tid_raw; break;}
|
||||
else if (String_.Eq(dir_name, "page_zip")) tid = gplx.core.ios.streams.Io_stream_.Tid_zip;
|
||||
else if (String_.Eq(dir_name, "page_gz")) tid = gplx.core.ios.streams.Io_stream_.Tid_gzip;
|
||||
else if (String_.Eq(dir_name, "page_bz2")) tid = gplx.core.ios.streams.Io_stream_.Tid_bzip2;
|
||||
}
|
||||
fsys_mgr.Tdb_dir_regy()[id].Ext_tid_(tid);
|
||||
}
|
||||
private static Hash_adp Scan_dirs_ns(Io_url ns_dir, Xow_ns_mgr ns_mgr) {
|
||||
Io_url[] ns_dirs = Io_mgr.Instance.QueryDir_args(ns_dir).Recur_(false).DirOnly_().ExecAsUrlAry();
|
||||
int len = ns_dirs.length;
|
||||
Hash_adp rv = Hash_adp_.new_();
|
||||
Hash_adp rv = Hash_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int ns_int = Int_.parse_or(ns_dirs[i].NameOnly(), Int_.Min_value); if (ns_int == Int_.Min_value) continue;
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_int); if (ns == null) continue;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import org.junit.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xotdb_fsys_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_fsys_mgr_fxt fxt = new Xow_fsys_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();} private final Xow_fsys_mgr_fxt fxt = new Xow_fsys_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Zip_(Xotdb_dir_info_.Tid_page, Bool_.N).Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, 123, "mem/xowa/wiki/en.wikipedia.org/ns/000/page/00/00/00/01/0000000123.xdat");
|
||||
fxt.Zip_(Xotdb_dir_info_.Tid_page, Bool_.Y).Url_ns_fil(Xotdb_dir_info_.Tid_page, Xow_ns_.Tid__main, 123, "mem/xowa/wiki/en.wikipedia.org/ns/000/page_zip/00/00/00/01/0000000123.zip");
|
||||
@@ -31,7 +31,7 @@ class Xow_fsys_mgr_fxt {
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
Xoae_app app; Xowe_wiki wiki;
|
||||
public Xow_fsys_mgr_fxt Zip_(byte tid, boolean v) {wiki.Tdb_fsys_mgr().Tdb_dir_regy()[tid].Ext_tid_(v ? gplx.core.ios.Io_stream_.Tid_zip : gplx.core.ios.Io_stream_.Tid_raw); return this;}
|
||||
public Xow_fsys_mgr_fxt Zip_(byte tid, boolean v) {wiki.Tdb_fsys_mgr().Tdb_dir_regy()[tid].Ext_tid_(v ? gplx.core.ios.streams.Io_stream_.Tid_zip : gplx.core.ios.streams.Io_stream_.Tid_raw); return this;}
|
||||
public void Url_ns_fil(byte tid, int ns_id, int fil_idx, String expd) {
|
||||
Tfds.Eq(expd, wiki.Tdb_fsys_mgr().Url_ns_fil(tid, ns_id, fil_idx).Raw());
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xoa_hive_mgr {
|
||||
if (!hive_url.Eq(regy_mgr.Fil()))
|
||||
regy_mgr.Init(hive_url);
|
||||
return regy_mgr.Files_find(ttl);
|
||||
} private Xowd_regy_mgr regy_mgr = new Xowd_regy_mgr(); Int_obj_ref bry_len = Int_obj_ref.zero_(); Xob_xdat_file xdat_rdr = new Xob_xdat_file(); Xob_xdat_itm xdat_itm = new Xob_xdat_itm();
|
||||
} private Xowd_regy_mgr regy_mgr = new Xowd_regy_mgr(); Int_obj_ref bry_len = Int_obj_ref.New_zero(); Xob_xdat_file xdat_rdr = new Xob_xdat_file(); Xob_xdat_itm xdat_itm = new Xob_xdat_itm();
|
||||
public Xowd_regy_mgr Regy_mgr() {return regy_mgr;}
|
||||
public Xob_xdat_file Get_rdr(Io_url hive_root, byte[] fil_ext_bry, int fil_idx) {
|
||||
Bry_bfr tmp_bfr = app.Utl__bfr_mkr().Get_m001();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xob_hive_mgr {
|
||||
}
|
||||
Xob_xdat_file xdat_load_(Xob_xdat_file xdat, byte dir_tid, Xow_ns ns, int fil_idx) {
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
return xdat;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class Xob_hive_mgr {
|
||||
byte dir_tid = Xotdb_dir_info_.Tid_ttl;
|
||||
int xdat_idx = Regy__find_file_ns(key, dir_tid, ns.Num_str());
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), xdat_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
xdat.Find(xdat_itm, key, Xotdb_page_itm_.Txt_ttl_pos, Byte_ascii.Tab, false);
|
||||
Find_nearby_add_fwd(list, dir_tid, ns, include_redirects, count, xdat_idx, xdat_itm.Itm_idx());
|
||||
@@ -132,7 +132,7 @@ public class Xob_hive_mgr {
|
||||
// while (loop) {
|
||||
// if (fil_idx == -1) break;
|
||||
// Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
|
||||
// byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
// byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
// xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
// int row_idx = first && row_bgn != -1 ? row_bgn : xdat.Count() - 1;
|
||||
// first = false;
|
||||
@@ -155,7 +155,7 @@ public class Xob_hive_mgr {
|
||||
while (loop) {
|
||||
if (fil_idx == regy_len) break;
|
||||
Io_url xdat_url = fsys_mgr.Url_ns_fil(dir_tid, ns.Id(), fil_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
xdat.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
int row_idx = first ? row_bgn : 0;
|
||||
int rows_len = xdat.Count();
|
||||
@@ -186,7 +186,7 @@ public class Xob_hive_mgr {
|
||||
int Regy__find_file_by_url(byte[] key, Io_url regy_url) {regy.Init(regy_url); return regy.Files_find(key);} private Xowd_regy_mgr regy = new Xowd_regy_mgr();
|
||||
private void Xdat__create_row(byte dir_tid, byte[] key, byte[] row, int xdat_idx) {
|
||||
Io_url xdat_url = fsys_mgr.Url_site_fil(dir_tid, xdat_idx);
|
||||
byte[] xdat_bry = gplx.core.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(xdat_url);
|
||||
Xob_xdat_file xdat_fil = new Xob_xdat_file();
|
||||
if (xdat_bry.length > 0) // if file is not empty, load it and parse it
|
||||
xdat_fil.Parse(xdat_bry, xdat_bry.length, xdat_url);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xow_hive_mgr_fxt {
|
||||
} private Xob_hive_mgr hive_mgr; Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public void Find_nearby(String key, int count, boolean include_redirects, String... expd) {
|
||||
List_adp list = List_adp_.new_();
|
||||
List_adp list = List_adp_.New();
|
||||
wiki.Hive_mgr().Find_bgn(list, wiki.Ns_mgr().Ns_main(), Bry_.new_a7(key), count, include_redirects);
|
||||
int actl_len = list.Count();
|
||||
String[] actl = new String[actl_len];
|
||||
@@ -47,7 +47,7 @@ public class Xow_hive_mgr_fxt {
|
||||
int id = 0;
|
||||
int ttl_bry_len = Int_.DigitCount(ttls_per_file);
|
||||
Xob_xdat_file_wtr xdat_wtr = Xob_xdat_file_wtr.new_file_(ttls_per_file * 8, wiki.Tdb_fsys_mgr().Url_ns_dir(ns.Num_str(), Xotdb_dir_info_.Tid_ttl));
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
byte ltr = Byte_ascii.Ltr_A; byte[] ttl_0 = Bry_.Empty, ttl_n = Bry_.Empty;
|
||||
for (int fil_idx = 0; fil_idx < files; fil_idx++) {
|
||||
for (int ttl_idx = 0; ttl_idx < ttls_per_file; ttl_idx++) {
|
||||
@@ -98,7 +98,7 @@ public class Xow_hive_mgr_fxt {
|
||||
}
|
||||
}
|
||||
class Xob_reg_wtr {
|
||||
Bry_bfr bfr = Bry_bfr.new_(); int fil_count = 0;
|
||||
Bry_bfr bfr = Bry_bfr_.New(); int fil_count = 0;
|
||||
public void Add(byte[] bgn, byte[] end, int itm_count) {
|
||||
bfr
|
||||
.Add_int_variable(fil_count++).Add_byte(Byte_ascii.Pipe)
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xowd_hive_regy_itm {// csv file with the format of "idx|bgn|end|cou
|
||||
List_adp rv = utl.Itms();
|
||||
byte[] ary = utl.Raw_bry();
|
||||
int ary_len = utl.Raw_len(); if (ary_len == 0) return Xowd_hive_regy_itm.Ary_empty; //throw Err_mgr.Instance.fmt_("xowa.wiki.data", "title_registry_file_not_found", "title_registry file not found: ~{0}", utl.Fil().Xto_api());
|
||||
Int_obj_ref pos = Int_obj_ref.zero_();
|
||||
Int_obj_ref pos = Int_obj_ref.New_zero();
|
||||
while (pos.Val() < ary_len) {
|
||||
Xowd_hive_regy_itm file = new Xowd_hive_regy_itm();
|
||||
file.idx = Bry_.ReadCsvInt(ary, pos, Bry_.Dlm_fld);
|
||||
@@ -49,5 +49,5 @@ public class Xowd_hive_regy_itm {// csv file with the format of "idx|bgn|end|cou
|
||||
.Add_int_variable(count).Add_byte_nl();
|
||||
}
|
||||
public static Xowd_hive_regy_itm tmp_() {return new Xowd_hive_regy_itm();}
|
||||
public static final Xowd_hive_regy_itm[] Ary_empty = new Xowd_hive_regy_itm[0];
|
||||
public static final Xowd_hive_regy_itm[] Ary_empty = new Xowd_hive_regy_itm[0];
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Xowd_regy_mgr {
|
||||
throw Err_.new_unimplemented(); // FUTURE: note that deletes are harder; rng ends could be deleted, so would need to open file and get new rng end
|
||||
}
|
||||
public void Save() {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int len = files_ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowd_hive_regy_itm itm = files_ary[i];
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xof_meta_fil {
|
||||
private final Ordered_hash itms = Ordered_hash_.New_bry();
|
||||
private final Ordered_hash itms = Ordered_hash_.New_bry();
|
||||
public Xof_meta_fil(Xof_meta_mgr meta_mgr, byte[] md5) {this.meta_mgr = meta_mgr; this.md5 = md5;}
|
||||
public Xof_meta_mgr Owner_mgr() {return meta_mgr;} private final Xof_meta_mgr meta_mgr;
|
||||
public byte[] Md5() {return md5;} private final byte[] md5;
|
||||
public Xof_meta_mgr Owner_mgr() {return meta_mgr;} private final Xof_meta_mgr meta_mgr;
|
||||
public byte[] Md5() {return md5;} private final byte[] md5;
|
||||
public void Dirty_() {meta_mgr.Dirty_(this);}
|
||||
public Xof_meta_itm Get_or_new(byte[] ttl) {
|
||||
Xof_meta_itm rv = Get_or_null(ttl);
|
||||
@@ -57,5 +57,5 @@ public class Xof_meta_fil {
|
||||
Bld_url_bfr.Add_byte(md5[i]);
|
||||
Bld_url_bfr.Add(Bry_url_ext);
|
||||
return Io_url_.new_fil_(Bld_url_bfr.To_str_and_clear());
|
||||
} static final byte[] Bry_url_ext = Bry_.new_a7(".csv"); static Bry_bfr Bld_url_bfr = Bry_bfr.new_(260); // 260 is max path of url
|
||||
} static final byte[] Bry_url_ext = Bry_.new_a7(".csv"); static Bry_bfr Bld_url_bfr = Bry_bfr_.New_w_size(260); // 260 is max path of url
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xof_meta_mgr implements GfoInvkAble {
|
||||
private Object[] root = new Object[16]; private final Ordered_hash dirty_fils = Ordered_hash_.New_bry();
|
||||
private final Gfo_fld_rdr rdr = Gfo_fld_rdr.xowa_(); private final Xof_meta_thumb_parser parser = new Xof_meta_thumb_parser();
|
||||
public class Xof_meta_mgr implements Gfo_invk {
|
||||
private Object[] root = new Object[16]; private final Ordered_hash dirty_fils = Ordered_hash_.New_bry();
|
||||
private final Gfo_fld_rdr rdr = Gfo_fld_rdr.xowa_(); private final Xof_meta_thumb_parser parser = new Xof_meta_thumb_parser();
|
||||
public Xof_meta_mgr(Xowe_wiki wiki) {this.wiki = wiki; this.root_dir = wiki.Appe().Fsys_mgr().File_dir().GenSubDir_nest("#meta", wiki.Domain_str());}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Io_url Root_dir() {return root_dir;} Io_url root_dir;
|
||||
@@ -51,7 +51,7 @@ public class Xof_meta_mgr implements GfoInvkAble {
|
||||
public void Save() {Save(false);}
|
||||
public void Save(boolean clear) {
|
||||
int dirty_len = dirty_fils.Count();
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
wtr.Bfr_(tmp_bfr);
|
||||
for (int i = 0; i < dirty_len; i++) {
|
||||
Xof_meta_fil fil = (Xof_meta_fil)dirty_fils.Get_at(i);
|
||||
@@ -75,7 +75,7 @@ public class Xof_meta_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_regy_depth_)) depth = m.ReadInt("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_regy_depth_ = "depth_";
|
||||
static final String GRP_KEY = "xowa.file_regy.";
|
||||
|
||||
@@ -44,5 +44,5 @@ public class Xos_url_gen implements Io_url_gen {
|
||||
tmp_bfr.Add(ext);
|
||||
return Io_url_.new_fil_(tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
private static Bry_bfr tmp_bfr = Bry_bfr.reset_(256);
|
||||
private static Bry_bfr tmp_bfr = Bry_bfr_.Reset(256);
|
||||
}
|
||||
|
||||
@@ -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.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.encoders.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.core.encoders.*;
|
||||
public class Xob_xdat_file {
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public int Src_len() {return src_len;} public Xob_xdat_file Src_len_(int v) {src_len = v; return this;} private int src_len; // NOTE: src_len can be different than src.length (occurs when reusing brys)
|
||||
@@ -98,9 +99,9 @@ public class Xob_xdat_file {
|
||||
if (insert) bfr.Add(new_itm);
|
||||
itm_0_bgn = (ary_len * Len_idx_itm) + Len_itm_dlm;
|
||||
src = bfr.To_bry_and_clear();
|
||||
} static final byte Dlm_hdr_fld = Byte_ascii.Pipe, Dlm_row = Byte_ascii.Nl;
|
||||
} static final byte Dlm_hdr_fld = Byte_ascii.Pipe, Dlm_row = Byte_ascii.Nl;
|
||||
public void Save(Io_url url) {
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Srl_save_bry(bfr);
|
||||
Io_stream_wtr wtr = Io_stream_wtr_.new_by_url_(url);
|
||||
try {
|
||||
@@ -179,7 +180,7 @@ public class Xob_xdat_file {
|
||||
public static byte[] Rebuid_header(byte[] orig, byte[] dlm) {
|
||||
byte[][] rows = Bry_split_.Split(orig, dlm);
|
||||
int rows_len = rows.length;
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
int dlm_len = dlm.length;
|
||||
for (int i = 1; i < rows_len; i++) { // i=1; skip 1st row (which is empty header)
|
||||
byte[] row = rows[i];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user