mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.1.1
This commit is contained in:
@@ -23,7 +23,7 @@ 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.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.specials.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.hdumps.*; import gplx.xowa.htmls.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.css.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
@@ -38,8 +38,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
this.domain_tid = domain_itm.Domain_type_id();
|
||||
this.domain_abrv = Xow_abrv_wm_.To_abrv(Xow_domain_itm_.parse(domain_bry));
|
||||
this.ns_mgr = Xow_ns_mgr_.default_(app.Utl_case_mgr());
|
||||
this.html__hzip_mgr = new Xow_hzip_mgr(app.Usr_dlg(), this);
|
||||
this.html__hdump_rdr = new Xohd_hdump_rdr(app, this);
|
||||
this.html__hdump_mgr = new Xow_hdump_mgr(this);
|
||||
this.special_mgr = new Xosp_special_mgr(this);
|
||||
this.fsys_mgr = new Xow_fsys_mgr(wiki_root_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
|
||||
this.fsdb_mgr = new Xof_fsdb_mgr__sql();
|
||||
@@ -63,9 +62,8 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
public Xof_bin_mgr File__bin_mgr() {return fsdb_mgr.Bin_mgr();}
|
||||
public Fsm_mnt_mgr File__mnt_mgr() {return fsdb_mgr.Mnt_mgr();}
|
||||
public boolean Html__hdump_enabled() {return Bool_.Y;}
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public boolean Html__css_installing() {return html__css_installing;} public void Html__css_installing_(boolean v) {html__css_installing = v;} private boolean html__css_installing;
|
||||
public Xow_hzip_mgr Html__hzip_mgr() {return html__hzip_mgr;} private final Xow_hzip_mgr html__hzip_mgr;
|
||||
public Xohd_hdump_rdr Html__hdump_rdr() {return html__hdump_rdr;} private final Xohd_hdump_rdr html__hdump_rdr;
|
||||
public Xoh_page_wtr_mgr Html__wtr_mgr() {return html__wtr_mgr;} private final Xoh_page_wtr_mgr html__wtr_mgr = new Xoh_page_wtr_mgr(Bool_.Y);
|
||||
public Xow_mw_parser_mgr Mw_parser_mgr() {return mw_parser_mgr;} private final Xow_mw_parser_mgr mw_parser_mgr = new Xow_mw_parser_mgr();
|
||||
public Xow_wiki_props Props() {return props;} private final Xow_wiki_props props = new Xow_wiki_props();
|
||||
@@ -91,17 +89,23 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
orig_mgr.Init_by_wiki(this, file_mgr__fsdb_mode, db_core_mgr.File__orig_tbl_ary(), Xof_url_bldr.new_v2());
|
||||
fsdb_mgr.Init_by_wiki(this);
|
||||
data_mgr__core_mgr.Db__core().Tbl__ns().Select_all(ns_mgr);
|
||||
html__hdump_rdr.Init_by_db(data_mgr__core_mgr);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
}
|
||||
public void Pages_get(Xog_page rv, Gfo_url url, Xoa_ttl ttl) {
|
||||
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.Init_by_make(props, info_session);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
}
|
||||
public void Pages_get(Xoh_page rv, Gfo_url url, Xoa_ttl ttl) {
|
||||
if (init_needed) Init_by_wiki();
|
||||
if (ttl.Ns().Id_special())
|
||||
special_mgr.Get_by_ttl(rv, url, ttl);
|
||||
else
|
||||
html__hdump_rdr.Get_by_ttl(rv, ttl);
|
||||
html__hdump_mgr.Load_mgr().Load(rv, ttl);
|
||||
}
|
||||
public Xoa_ttl Ttl_parse(byte[] 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(), ttl, 0, ttl.length);}
|
||||
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {
|
||||
public Xoa_ttl Ttl_parse(byte[] ttl) {return Ttl_parse(ttl, 0, ttl.length);}
|
||||
public Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end) {return Xoa_ttl.parse(app.Utl__bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), src, src_bgn, src_end);}
|
||||
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id);
|
||||
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);
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Xow_defn_cache { // stores compiled Xot_defn
|
||||
byte[] name = defn.Name();
|
||||
int cache_size = defn.Cache_size(); // OBSOLETE: * 2 b/c it has src and root;
|
||||
cache.Add_replace(name, defn, cache_size);
|
||||
if (case_match == Xow_ns_case_.Id_1st) {
|
||||
if (case_match == Xow_ns_case_.Tid__1st) {
|
||||
name = lang.Case_mgr().Case_build_1st_upper(upper_1st_bfr, name, 0, name.length);
|
||||
cache.Add_replace(name, defn, 0);
|
||||
}
|
||||
|
||||
@@ -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.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.lnkis.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
abstract class Xoctg_fmtr_itm_base implements Xoctg_fmtr_itm {
|
||||
|
||||
@@ -33,17 +33,17 @@ public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
int pipe_pos_cur = -1, pipe_pos_prv = -1;
|
||||
for (int i = block_len; i < len; i += block_len) {
|
||||
usr_dlg.Prog_many("", "", "indexing ~{0} ~{1}", i, len);
|
||||
pipe_pos_cur = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, i, len); if (pipe_pos_cur == Bry_.NotFound) throw Err_.new_wo_type("ctg_idx_mgr could not find pipe.next", "ctg", String_.new_a7(ctg), "pos", i);
|
||||
pipe_pos_cur = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, i, len); if (pipe_pos_cur == Bry_find_.Not_found) throw Err_.new_wo_type("ctg_idx_mgr could not find pipe.next", "ctg", String_.new_a7(ctg), "pos", i);
|
||||
if (pipe_pos_cur == len - 1) break;
|
||||
Index_itm(ctg, src, pipe_pos_cur + 1, len); // +1 to skip pipe
|
||||
pipe_pos_prv = pipe_pos_cur;
|
||||
}
|
||||
pipe_pos_cur = Bry_find_.Find_bwd(src, Byte_ascii.Pipe, len - 1, 0); if (pipe_pos_cur == Bry_.NotFound) pipe_pos_cur = 0; // 1 entry only; will not have preceding pipe
|
||||
pipe_pos_cur = Bry_find_.Find_bwd(src, Byte_ascii.Pipe, len - 1, 0); if (pipe_pos_cur == Bry_find_.Not_found) pipe_pos_cur = 0; // 1 entry only; will not have preceding pipe
|
||||
if (pipe_pos_cur != pipe_pos_prv) // if last itm was not indexed, index it
|
||||
Index_itm(ctg, src, pipe_pos_cur + 1, len);
|
||||
}
|
||||
private void Index_itm(byte[] ctg, byte[] src, int bgn, int len) {
|
||||
int end = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, bgn, len); if (end == Bry_.NotFound) throw Err_.new_wo_type("Ctg_idx_mgr could not find pipe.end", "ctg", String_.new_a7(ctg), "pos", bgn);
|
||||
int end = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, bgn, len); if (end == Bry_find_.Not_found) throw Err_.new_wo_type("Ctg_idx_mgr could not find pipe.end", "ctg", String_.new_a7(ctg), "pos", bgn);
|
||||
fld_rdr.Pos_(bgn);
|
||||
Xoctg_idx_itm itm = new Xoctg_idx_itm().Parse(fld_rdr, bgn);
|
||||
itms.Add(itm);
|
||||
@@ -84,7 +84,7 @@ public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
tmp_prv_itm.Parse(fld_rdr.Pos_(pos_cur), pos_cur); // fill prv_itm to whatever binary search found
|
||||
while (true) {
|
||||
int itm_bgn = dir_fwd ? Bry_find_.Find_fwd(src, Byte_ascii.Pipe, pos_cur, src_len) : Bry_find_.Find_bwd(src, Byte_ascii.Pipe, pos_cur);
|
||||
if (itm_bgn == Bry_.NotFound) { // stop: at first && searched bwd; note that at last && searched fwd will never return Bry_.NotFound b/c all srcs are terminated with |
|
||||
if (itm_bgn == Bry_find_.Not_found) { // stop: at first && searched bwd; note that at last && searched fwd will never return Bry_find_.Not_found b/c all srcs are terminated with |
|
||||
if (!arg_is_from) return null; // arg is until and nothing found; return null: EX: range of B-Y and find of until=A; no results
|
||||
else break; // arg is from; stop loop; (will use first item)
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
tmp_pos = itm_0.Pos();
|
||||
if (!arg_is_from && Bry_.Compare(find, itm_0.Sortkey()) != CompareAble_.More) { // "until" means do *not* include last; go back one more; note: only do this logic if find is either < or == to slot; EX: find=AM && slot=AL; do not go back one more
|
||||
tmp_pos = Bry_find_.Find_bwd(src, Byte_ascii.Pipe, tmp_pos - 1); // -1 to position before pipe
|
||||
if (tmp_pos == Bry_.NotFound) return; // already 1st and nothing found
|
||||
if (tmp_pos == Bry_find_.Not_found) return; // already 1st and nothing found
|
||||
else tmp_pos++;
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
rv.Add(itm);
|
||||
if (!arg_is_from && tmp_pos == 0) break; // 1st item and moving bwd; stop; note that 1st item does not have preceding |
|
||||
tmp_pos = arg_is_from ? Bry_find_.Find_fwd(src, Byte_ascii.Pipe, tmp_pos, src_len) : Bry_find_.Find_bwd(src, Byte_ascii.Pipe, tmp_pos - 1); // -1 to position before pipe
|
||||
if (tmp_pos == Bry_.NotFound) {
|
||||
if (tmp_pos == Bry_find_.Not_found) {
|
||||
if (arg_is_from) // moving fwd and no pipe found; exit;
|
||||
break;
|
||||
else // moving bwd and no pipe found; position at 1st item (which doesn't have a pipe); note that -1 will become 0
|
||||
@@ -142,7 +142,7 @@ public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
Xoctg_view_itm last_itm = (Xoctg_view_itm)rv.Get_at(rv_count - 1);
|
||||
int last_itm_pos = last_itm.Pos();
|
||||
tmp_pos = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, last_itm_pos);
|
||||
if (tmp_pos != Bry_.NotFound && tmp_pos < src_len - 1) {
|
||||
if (tmp_pos != Bry_find_.Not_found && tmp_pos < src_len - 1) {
|
||||
++tmp_pos; // position after pipe
|
||||
last_plus_one.Parse(fld_rdr.Pos_(tmp_pos), tmp_pos);
|
||||
}
|
||||
|
||||
@@ -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.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.lnkis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
public class Xoctg_pagelist_itms implements Bry_fmtr_arg {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Xow_data_mgr_tst {
|
||||
;
|
||||
}
|
||||
@Test public void Update_zip() {
|
||||
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Id_main].Ext_tid_(gplx.ios.Io_stream_.Tid_zip);
|
||||
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Id_main].Ext_tid_(gplx.core.ios.Io_stream_.Tid_zip);
|
||||
// fxt.Wiki().Data_mgr().Zip_mgr_(new Io_zip_mgr_mok());
|
||||
// fxt .Create("A1", "A1 data")
|
||||
// .Create("B12", "B12 data")
|
||||
|
||||
@@ -16,13 +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.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.core.ios.*; 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, byte zip_tid_text, byte zip_tid_html) {
|
||||
public Xowd_core_db_props(int schema, Xowd_db_layout layout_text, Xowd_db_layout layout_html, Xowd_db_layout layout_file, byte zip_tid_text, byte zip_tid_html, boolean hzip_enabled) {
|
||||
this.schema = schema;
|
||||
this.layout_text = layout_text; this.layout_html = layout_html; this.layout_file = layout_file;
|
||||
this.zip_tid_text = zip_tid_text; this.zip_tid_html = zip_tid_html;
|
||||
this.hzip_enabled = hzip_enabled;
|
||||
}
|
||||
public int Schema() {return schema;} private final int schema;
|
||||
public boolean Schema_is_1() {return schema == 1;}
|
||||
@@ -31,6 +32,7 @@ public class Xowd_core_db_props {
|
||||
public Xowd_db_layout Layout_file() {return layout_file;} private final Xowd_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;
|
||||
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);
|
||||
@@ -39,12 +41,13 @@ public class Xowd_core_db_props {
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__layout_file , layout_file.Name());
|
||||
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.Conn().Txn_end();
|
||||
}
|
||||
public static Xowd_core_db_props Cfg_load(Io_url url, Db_conn conn) {
|
||||
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg");
|
||||
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, Io_stream_.Tid_gzip), Io_stream_.Tid_gzip)
|
||||
? 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, Io_stream_.Tid_gzip), Io_stream_.Tid_gzip, Bool_.Y)
|
||||
: Cfg_load(cfg_tbl);
|
||||
}
|
||||
private static Xowd_core_db_props Cfg_load(Db_cfg_tbl tbl) {
|
||||
@@ -56,6 +59,7 @@ public class Xowd_core_db_props {
|
||||
, Xowd_db_layout.get_(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)
|
||||
);
|
||||
}
|
||||
private static final String Cfg_grp = Xow_cfg_consts.Grp__wiki_core
|
||||
@@ -65,6 +69,7 @@ public class Xowd_core_db_props {
|
||||
, Cfg_key__layout_file = "layout_file"
|
||||
, Cfg_key__zip_tid_text = "zip_tid_text"
|
||||
, Cfg_key__zip_tid_html = "zip_tid_html"
|
||||
, Cfg_key__hzip_enabled = "hzip_enabled"
|
||||
;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ 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.htmls.core.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;
|
||||
@@ -29,7 +30,8 @@ public class Xowd_db_file {
|
||||
this.tbl__site_stats = new Xowd_site_stats_tbl(conn, schema_is_1);
|
||||
this.tbl__page = new Xowd_page_tbl(conn, schema_is_1);
|
||||
this.tbl__text = new Xowd_text_tbl(conn, schema_is_1, props.Zip_tid_text());
|
||||
this.tbl__html = new Xowd_html_tbl(conn, props.Zip_tid_html());
|
||||
this.tbl__html_page = new Xoh_page_tbl(conn);
|
||||
this.tbl__html_redlink = new Xoh_redlink_tbl(conn);
|
||||
this.tbl__css_core = new Xowd_css_core_tbl(conn);
|
||||
this.tbl__css_file = new Xowd_css_file_tbl(conn);
|
||||
this.tbl__cat_core = new Xowd_cat_core_tbl(conn, schema_is_1);
|
||||
@@ -59,7 +61,8 @@ public class Xowd_db_file {
|
||||
public Xowd_site_ns_tbl Tbl__ns() {return tbl__ns;} private final Xowd_site_ns_tbl tbl__ns;
|
||||
public Xowd_page_tbl Tbl__page() {return tbl__page;} private final Xowd_page_tbl tbl__page;
|
||||
public Xowd_text_tbl Tbl__text() {return tbl__text;} private final Xowd_text_tbl tbl__text;
|
||||
public Xowd_html_tbl Tbl__html() {return tbl__html;} private final Xowd_html_tbl tbl__html;
|
||||
public Xoh_page_tbl Tbl__html_page() {return tbl__html_page;} private final Xoh_page_tbl tbl__html_page;
|
||||
public Xoh_redlink_tbl Tbl__html_redlink() {return tbl__html_redlink;} private final Xoh_redlink_tbl tbl__html_redlink;
|
||||
public Xowd_css_core_tbl Tbl__css_core() {return tbl__css_core;} private final Xowd_css_core_tbl tbl__css_core;
|
||||
public Xowd_css_file_tbl Tbl__css_file() {return tbl__css_file;} private final Xowd_css_file_tbl tbl__css_file;
|
||||
public Xowd_cat_core_tbl Tbl__cat_core() {return tbl__cat_core;} private final Xowd_cat_core_tbl tbl__cat_core;
|
||||
|
||||
@@ -22,8 +22,8 @@ public class Xowd_html_row {
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public byte[] Data() {return data;} private final byte[] data;
|
||||
public static final int // SERIALIZED
|
||||
Tid_html = 0
|
||||
, Tid_img = 1
|
||||
, Tid_redlink = 2
|
||||
Tid__html = 0
|
||||
, Tid__img = 1
|
||||
, Tid__redlink = 2
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,71 +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.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_html_tbl implements RlsAble {
|
||||
private final String tbl_name = "html"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_page_id, fld_html_tid, fld_html_data;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete;
|
||||
private final Io_stream_zip_mgr zip_mgr = Xoa_app_.Utl__zip_mgr(); private final byte zip_tid;
|
||||
public Xowd_html_tbl(Db_conn conn, byte zip_tid) {
|
||||
this.conn = conn; this.zip_tid = zip_tid;
|
||||
fld_page_id = flds.Add_int("page_id");
|
||||
fld_html_tid = flds.Add_int("html_tid");
|
||||
fld_html_data = flds.Add_bry("html_data");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Ddl_create_idx(Gfo_usr_dlg_.Instance, Db_meta_idx.new_unique_by_tbl(tbl_name, "main", fld_page_id, fld_html_tid));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__html__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public int Insert(int page_id, int tid, byte[] data) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
data = zip_mgr.Zip(zip_tid, data);
|
||||
stmt_insert.Clear().Val_int(fld_page_id, page_id).Val_int(fld_html_tid, tid).Val_bry(fld_html_data, data).Exec_insert();
|
||||
return data.length;
|
||||
}
|
||||
public void Delete(int page_id) {
|
||||
if (stmt_delete == null) stmt_delete = conn.Stmt_delete(tbl_name, String_.Ary(fld_page_id));
|
||||
stmt_delete.Clear().Crt_int(fld_page_id, page_id).Exec_delete();
|
||||
}
|
||||
public void Select_by_page(List_adp rv, int page_id) {
|
||||
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, String_.Ary(fld_page_id));
|
||||
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, page_id).Exec_select__rls_manual();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Xowd_html_row row = new Xowd_html_row(rdr.Read_int(fld_page_id), rdr.Read_int(fld_html_tid), zip_mgr.Unzip(zip_tid, rdr.Read_bry(fld_html_data)));
|
||||
rv.Add(row);
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_delete = Db_stmt_.Rls(stmt_delete);
|
||||
stmt_select = Db_stmt_.Rls(stmt_select);
|
||||
}
|
||||
public static void Assert_col__page_html_db_id(Xowd_db_mgr db_mgr) {
|
||||
Xowd_page_tbl page_tbl = db_mgr.Tbl__page(); Db_conn page_conn = page_tbl.Conn();
|
||||
boolean html_flds_exists = page_conn.Meta_fld_exists(page_tbl.Tbl_name(), page_tbl.Fld_html_db_id());
|
||||
if (html_flds_exists) return;
|
||||
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Db_meta_fld.new_int(page_tbl.Fld_html_db_id()).Default_(-1));
|
||||
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Db_meta_fld.new_int(page_tbl.Fld_redirect_id()).Default_(-1));
|
||||
page_tbl.Hdump_enabled_(Bool_.Y);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class Xowd_page_itm {
|
||||
ns_id = ns.Id();
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
public Xowd_page_itm Clear() {
|
||||
id = Id_null; text_len = 0; // text_len should be 0 b/c text defaults to 0;
|
||||
text_db_id = tdb_row_idx = 0; // default to 0, b/c some tests do not set and will fail at -1
|
||||
ns_id = Int_.Min_value;
|
||||
@@ -101,6 +101,7 @@ public class Xowd_page_itm {
|
||||
id_val = null;
|
||||
html_db_id = -1;
|
||||
redirect_id = -1;
|
||||
return this;
|
||||
}
|
||||
public void Copy(Xowd_page_itm orig) {
|
||||
this.id = orig.id;
|
||||
|
||||
@@ -54,6 +54,11 @@ public class Xowd_page_tbl implements RlsAble {
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.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();
|
||||
this.Insert_cmd_by_batch(page_id, ns_id, ttl_wo_ns, page_is_redirect, modified_on, page_len, random_int, text_db_id, html_db_id);
|
||||
this.Insert_end();
|
||||
}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__page__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(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) {
|
||||
@@ -321,4 +326,12 @@ public class Xowd_page_tbl implements RlsAble {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
private static final String Page_touched_fmt = "yyyyMMddHHmmss";
|
||||
public static void Assert_col__page_html_db_id(Xowd_db_mgr db_mgr) {
|
||||
Xowd_page_tbl page_tbl = db_mgr.Tbl__page(); Db_conn page_conn = page_tbl.Conn();
|
||||
boolean html_flds_exists = page_conn.Meta_fld_exists(page_tbl.Tbl_name(), page_tbl.Fld_html_db_id());
|
||||
if (html_flds_exists) return;
|
||||
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Db_meta_fld.new_int(page_tbl.Fld_html_db_id()).Default_(-1));
|
||||
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Db_meta_fld.new_int(page_tbl.Fld_redirect_id()).Default_(-1));
|
||||
page_tbl.Hdump_enabled_(Bool_.Y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_pagelinks_tbl implements RlsAble {
|
||||
private final String tbl_name = "pagelink"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_src_id, fld_trg_id;
|
||||
|
||||
@@ -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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_pagelinks_temp_tbl implements RlsAble {
|
||||
private final String tbl_name = "pagelinks_temp"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_src_id, fld_trg_ns, fld_trg_ttl;
|
||||
|
||||
@@ -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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xowd_text_tbl implements RlsAble {
|
||||
private final String tbl_name = "text"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_page_id, fld_text_data;
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.flds.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.specials.search.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.flds.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.specials.search.*; import gplx.core.encoders.*;
|
||||
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.*;
|
||||
@@ -34,7 +34,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
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, 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.ios.Io_stream_rdr_.Load_all(file); int bry_len = bry.length;
|
||||
byte[] bry = gplx.core.ios.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);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (cancelable.Canceled()) return;
|
||||
Xowd_page_itm itm = (Xowd_page_itm)list.Get_at(i + bgn);
|
||||
Base85_utl.XtoStrByAry(itm.Id(), id_bry, 0, 5);
|
||||
Base85_.Set_bry(itm.Id(), id_bry, 0, 5);
|
||||
int cur_fil_idx = this.Find_file_idx_by_site(Xotdb_dir_info_.Tid_id, id_bry);
|
||||
if (cur_fil_idx != prv_fil_idx) {
|
||||
if (!this.Load_xdat_file(cancelable, tmp_xdat_file, Xotdb_dir_info_.Tid_id, cur_fil_idx)) continue; // file not found; ignore
|
||||
@@ -115,13 +115,13 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
byte[] raw = rdr.Src();
|
||||
int itm_bgn = xdat_itm.Itm_bgn(), itm_end = xdat_itm.Itm_end();
|
||||
int pos = Bry_find_.Find_fwd(raw, Byte_ascii.Pipe, itm_bgn, raw.length);
|
||||
if (pos == Bry_.NotFound) throw wiki.Appe().Usr_dlg().Fail_many(GRP_KEY, "invalid_search_file", "search file is invalid");
|
||||
if (pos == Bry_find_.Not_found) throw wiki.Appe().Usr_dlg().Fail_many(GRP_KEY, "invalid_search_file", "search file is invalid");
|
||||
pos += Int_.Const_dlm_len; // pipe
|
||||
|
||||
while (pos < itm_end) {
|
||||
int page_id = Base85_utl.XtoIntByAry(raw, pos, pos + 4);
|
||||
int page_id = Base85_.To_int_by_bry(raw, pos, pos + 4);
|
||||
pos += 6; // 5 + 1 for semic;
|
||||
int page_len = Base85_utl.XtoIntByAry(raw, pos, pos + 4);
|
||||
int page_len = Base85_.To_int_by_bry(raw, pos, pos + 4);
|
||||
rv.Add(Xowd_page_itm.new_srch(page_id, page_len));
|
||||
pos += 6; // 5 + 1 for pipe
|
||||
// if (match.Itms_len() == max_results) break;
|
||||
@@ -161,9 +161,9 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
byte[] bry = tmp_xdat_itm.Itm_bry();
|
||||
int bgn = name.length + 1;
|
||||
boolean hidden = bry[bgn] == Byte_ascii.Ltr_y;
|
||||
int count_subcs = Base85_utl.XtoIntByAry(bry, bgn + 2, bgn + 6);
|
||||
int count_files = Base85_utl.XtoIntByAry(bry, bgn + 8, bgn + 12);
|
||||
int count_pages = Base85_utl.XtoIntByAry(bry, bgn + 14, bgn + 18);
|
||||
int count_subcs = Base85_.To_int_by_bry(bry, bgn + 2, bgn + 6);
|
||||
int count_files = Base85_.To_int_by_bry(bry, bgn + 8, bgn + 12);
|
||||
int count_pages = Base85_.To_int_by_bry(bry, bgn + 14, bgn + 18);
|
||||
rv.Hidden_(hidden);
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
Xoctg_idx_mgr idx_mgr = rv.Grp_by_tid(i);
|
||||
@@ -178,7 +178,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
idx_mgr.Total_(count);
|
||||
}
|
||||
}
|
||||
public boolean Load_by_id(Xowd_page_itm page, int id) {Base85_utl.XtoStrByAry(id, tmp_id_bry, 0, 5); return Load_by_id(page, tmp_id_bry);} private byte[] tmp_id_bry = new byte[5];
|
||||
public boolean Load_by_id(Xowd_page_itm page, int id) {Base85_.Set_bry(id, tmp_id_bry, 0, 5); return Load_by_id(page, tmp_id_bry);} private byte[] tmp_id_bry = new byte[5];
|
||||
boolean Load_by_id(Xowd_page_itm page, byte[] id_bry) {
|
||||
if (!Load_xdat_itm(tmp_xdat_itm, Xotdb_dir_info_.Tid_id, id_bry, true)) return false;;
|
||||
Xotdb_page_itm_.Txt_id_load(page, tmp_xdat_itm.Itm_bry());
|
||||
@@ -321,16 +321,16 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
private static void Load_ctg_v1_parse(List_adp rv, Gfo_usr_dlg usr_dlg, byte[] ary) {
|
||||
int aryLen = ary.length;
|
||||
int pos = Bry_find_.Find_fwd(ary, Byte_ascii.Pipe, 0, aryLen);
|
||||
int rowCount = (aryLen - pos + 1) / (Base85_utl.Len_int + gplx.xowa.apps.progs.Xoa_prog_mgr.Len_dlm_fld);
|
||||
int rowCount = (aryLen - pos + 1) / (Base85_.Len_int + gplx.xowa.apps.progs.Xoa_prog_mgr.Len_dlm_fld);
|
||||
rv.Clear();
|
||||
boolean garbage = false;
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
Xowd_page_itm row = new Xowd_page_itm();
|
||||
rv.Add(row);
|
||||
if (garbage) continue;
|
||||
int bgn = pos + 1 + (i * (Base85_utl.Len_int + gplx.xowa.apps.progs.Xoa_prog_mgr.Len_dlm_fld));
|
||||
int bgn = pos + 1 + (i * (Base85_.Len_int + gplx.xowa.apps.progs.Xoa_prog_mgr.Len_dlm_fld));
|
||||
try {
|
||||
int id = Base85_utl.XtoIntByAry(ary, bgn, bgn + Base85_utl.Len_int - 1);
|
||||
int id = Base85_.To_int_by_bry(ary, bgn, bgn + Base85_.Len_int - 1);
|
||||
if (id < 0) throw Err_.new_wo_type("invalid id", "id", id);
|
||||
row.Id_(id);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
public static boolean Load_page_or_false(Xowd_page_itm page, Xob_xdat_itm xdat, int ns_id) {
|
||||
byte[] src = xdat.Src(); int itm_end = xdat.Itm_end();
|
||||
int bgn = xdat.Itm_bgn();
|
||||
int timestamp = Base85_utl.XtoIntByAry(src, bgn + 6 , bgn + 10);
|
||||
int timestamp = Base85_.To_int_by_bry(src, bgn + 6 , bgn + 10);
|
||||
int ttl_end = Bry_find_.Find_fwd(src, Xotdb_page_itm_.Txt_page_dlm, bgn + 12, itm_end);
|
||||
if (ttl_end == -1) return false;
|
||||
byte[] ttl = Bry_.Mid (src, bgn + 12 , ttl_end);
|
||||
@@ -371,7 +371,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
int timestamp_bgn = row_bgn + 5 + 1;
|
||||
int timestamp_end = timestamp_bgn + 5;
|
||||
if (timestamp_enabled) {
|
||||
int timestamp = Base85_utl.XtoIntByAry(src, timestamp_bgn, timestamp_end - 1);
|
||||
int timestamp = Base85_.To_int_by_bry(src, timestamp_bgn, timestamp_end - 1);
|
||||
page.Modified_on_(Bit_.Xto_date_short(timestamp));
|
||||
}
|
||||
int name_bgn = timestamp_end + 1;
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.htmls.hdumps.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.htmls.core.*;
|
||||
public interface Xodb_mgr extends GfoInvkAble {
|
||||
byte Tid();
|
||||
String Tid_name();
|
||||
|
||||
@@ -16,8 +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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.ios.*; 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.hdumps.*;
|
||||
import gplx.core.ios.*; 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 Xodb_mgr_sql(Xowe_wiki wiki) {
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.hdumps.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
|
||||
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.*;
|
||||
public class Xodb_mgr_txt implements Xodb_mgr {
|
||||
public Xodb_mgr_txt(Xowe_wiki wiki, Xow_data_mgr data_mgr) {
|
||||
this.wiki = wiki;
|
||||
@@ -25,7 +25,7 @@ public class Xodb_mgr_txt implements Xodb_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.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.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() {
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
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.*;
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.dbs.qrys.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.dbs.qrys.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
private final Xodb_mgr_sql db_mgr;
|
||||
|
||||
@@ -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.ios.Io_stream_rdr_.Load_all(page_rdr_url);
|
||||
byte[] page_rdr_bry = gplx.core.ios.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();
|
||||
@@ -114,8 +114,8 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
class Bry_comparer_fld_last implements gplx.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
byte[] lhs = (byte[])lhsObj, rhs = (byte[])rhsObj;
|
||||
int lhs_bgn = Bry_find_.Find_bwd(lhs, Byte_ascii.Pipe); if (lhs_bgn == Bry_.NotFound) lhs_bgn = -1;
|
||||
int rhs_bgn = Bry_find_.Find_bwd(rhs, Byte_ascii.Pipe); if (rhs_bgn == Bry_.NotFound) rhs_bgn = -1;
|
||||
int lhs_bgn = Bry_find_.Find_bwd(lhs, Byte_ascii.Pipe); if (lhs_bgn == Bry_find_.Not_found) lhs_bgn = -1;
|
||||
int rhs_bgn = Bry_find_.Find_bwd(rhs, Byte_ascii.Pipe); if (rhs_bgn == Bry_find_.Not_found) rhs_bgn = -1;
|
||||
return Bry_.Compare(lhs, lhs_bgn + 1, lhs.length, rhs, rhs_bgn + 1, rhs.length);
|
||||
}
|
||||
public static final Bry_comparer_fld_last Instance = new Bry_comparer_fld_last();
|
||||
|
||||
@@ -28,13 +28,13 @@ public class Xow_domain_itm_ {
|
||||
*/
|
||||
int raw_len = raw.length;
|
||||
int dot_0 = Bry_find_.Find_fwd(raw, Byte_ascii.Dot, 0, raw_len);
|
||||
if (dot_0 == Bry_.NotFound) { // 0 dots; check for "home"
|
||||
if (dot_0 == Bry_find_.Not_found) { // 0 dots; check for "home"
|
||||
return Bry_.Eq(raw, Xow_domain_tid_.Bry__home)
|
||||
? Xow_domain_uid_.To_domain(Xow_domain_uid_.Tid_xowa)
|
||||
: new_other(raw);
|
||||
}
|
||||
int dot_1 = Bry_find_.Find_fwd(raw, Byte_ascii.Dot, dot_0 + 1, raw_len);
|
||||
if (dot_1 == Bry_.NotFound) { // 1 dot; check for "wikimediafoundation.org"
|
||||
if (dot_1 == Bry_find_.Not_found) { // 1 dot; check for "wikimediafoundation.org"
|
||||
return Bry_.Match(raw, 0, dot_0, Xow_domain_tid_.Bry__wmforg)
|
||||
? Xow_domain_itm.new_(raw, Xow_domain_tid_.Int__wmfblog, Xol_lang_stub_.Key__unknown)
|
||||
: new_other(raw);
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
public Xow_wiki_props Siteinfo_misc_(byte[] v) {
|
||||
siteinfo_misc = v;
|
||||
int pipe_0 = Bry_find_.Find_fwd(v, Byte_ascii.Pipe);
|
||||
if (pipe_0 != Bry_.NotFound)
|
||||
if (pipe_0 != Bry_find_.Not_found)
|
||||
site_name = Bry_.Mid(siteinfo_misc, 0, pipe_0);
|
||||
return this;
|
||||
} private byte[] siteinfo_misc = Bry_.Empty;
|
||||
|
||||
@@ -85,5 +85,5 @@ public class Xow_ns_ {
|
||||
public static final String Ns_name_wikipedia = "Wikipedia";
|
||||
public static final byte[] Ns_name_main_bry = Bry_.new_a7(Key_main);
|
||||
public static final byte[] Ns_prefix_main = Bry_.new_a7("Main:");
|
||||
private static Xow_ns Canonical_new_(int id, String name) {return new Xow_ns(id, Xow_ns_case_.Id_1st, Bry_.new_a7(name), false);} // NOTE: for id/name reference only; case_match and alias does not matter;
|
||||
private static Xow_ns Canonical_new_(int id, String name) {return new Xow_ns(id, Xow_ns_case_.Tid__1st, Bry_.new_a7(name), false);} // NOTE: for id/name reference only; case_match and alias does not matter;
|
||||
}
|
||||
|
||||
@@ -17,19 +17,19 @@ 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.*;
|
||||
public class Xow_ns_case_ {
|
||||
public static final byte Id_all = 0, Id_1st = 1;
|
||||
public static final String Key_all = "case-sensitive", Key_1st = "first-letter";
|
||||
public static final byte[] Bry__all = Bry_.new_a7(Key_all), Bry__1st = Bry_.new_a7(Key_1st);
|
||||
public static byte parse(String s) {
|
||||
if (String_.Eq(s, Key_1st)) return Id_1st;
|
||||
else if (String_.Eq(s, Key_all)) return Id_all;
|
||||
public static final byte Tid__all = 0, Tid__1st = 1;
|
||||
public static final String Key__all = "case-sensitive", Key__1st = "first-letter";
|
||||
public static final byte[] Bry__all = Bry_.new_a7(Key__all), Bry__1st = Bry_.new_a7(Key__1st);
|
||||
public static byte To_tid(String s) {
|
||||
if (String_.Eq(s, Key__1st)) return Tid__1st;
|
||||
else if (String_.Eq(s, Key__all)) return Tid__all;
|
||||
else throw Err_.new_unhandled(s);
|
||||
}
|
||||
public static String To_str(byte uid) {
|
||||
switch (uid) {
|
||||
case Id_all: return Key_all;
|
||||
case Id_1st: return Key_1st;
|
||||
default: throw Err_.new_unhandled(uid);
|
||||
public static String To_str(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid__all: return Key__all;
|
||||
case Tid__1st: return Key__1st;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,15 +71,15 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.lists.ComparerAble {
|
||||
}
|
||||
public Object Names_get_w_colon(byte[] src, int bgn, int end) { // NOTE: get ns for a name with a ":"; EX: "Template:A" should return "Template" ns
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, bgn, end);
|
||||
if (colon_pos == Bry_.NotFound) return null; // name does not have ":"; return;
|
||||
if (colon_pos == Bry_find_.Not_found) return null; // name does not have ":"; return;
|
||||
Object rv = name_hash.Get_by_mid(src, bgn, colon_pos);
|
||||
return rv == null ? null : ((Xow_ns_mgr_name_itm)rv).Ns();
|
||||
}
|
||||
public int Tmpls_get_w_colon(byte[] src, int bgn, int end) { // NOTE: get length of template name with a ":"; EX: "Template:A" returns 10; PERF
|
||||
int colon_pos = Bry_find_.Find_fwd(src, Byte_ascii.Colon, bgn, end);
|
||||
if (colon_pos == Bry_.NotFound) return Bry_.NotFound;
|
||||
if (colon_pos == Bry_find_.Not_found) return Bry_find_.Not_found;
|
||||
Object o = tmpl_hash.Get_by_mid(src, bgn, colon_pos + 1); // +1 to include colon_pos
|
||||
return o == null ? Bry_.NotFound : ((byte[])o).length;
|
||||
return o == null ? Bry_find_.Not_found : ((byte[])o).length;
|
||||
}
|
||||
public void Aliases_clear() {aliases.Clear();}
|
||||
public Xow_ns_mgr Aliases_add(int ns_id, String name) {
|
||||
@@ -122,7 +122,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.lists.ComparerAble {
|
||||
}
|
||||
private void Fix_project_talk(Xow_ns ns) {
|
||||
byte[] ns_name = ns.Name_bry();
|
||||
if (Bry_find_.Find_fwd(ns.Name_bry(), Project_talk_fmt_arg)== Bry_.NotFound) return; // no $1 found; exit
|
||||
if (Bry_find_.Find_fwd(ns.Name_bry(), Project_talk_fmt_arg)== Bry_find_.Not_found) return; // no $1 found; exit
|
||||
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_bry()));
|
||||
@@ -130,7 +130,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.lists.ComparerAble {
|
||||
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);
|
||||
if (Bry_find_.Find_fwd(key, Byte_ascii.Underline) != Bry_.NotFound) // ns has _; add another entry for space; EX: Help_talk -> Help talk
|
||||
if (Bry_find_.Find_fwd(key, Byte_ascii.Underline) != Bry_find_.Not_found) // ns has _; add another entry for space; EX: Help_talk -> Help talk
|
||||
hash.Add_if_dupe_use_nth(Bry_.Replace(key, Byte_ascii.Underline, Byte_ascii.Space), ns_itm);
|
||||
}
|
||||
public Xow_ns_mgr Add_defaults() { // NOTE: needs to happen after File ns is added; i.e.: cannot be put in Xow_ns_mgr() {} ctor
|
||||
@@ -140,7 +140,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.lists.ComparerAble {
|
||||
Aliases_add(gplx.xowa.xtns.scribunto.Scrib_xtn_mgr.Ns_id_module, "Module"); // always add "Module" ns; de.wikipedia.org has "Modul" defined in siteinfo.xml, but also uses Module
|
||||
return this;
|
||||
}
|
||||
public Xow_ns_mgr Add_new(int nsId, String name) {return Add_new(nsId, Bry_.new_u8(name), Xow_ns_case_.Id_1st, false);} // for tst_ constructor
|
||||
public Xow_ns_mgr Add_new(int nsId, String name) {return Add_new(nsId, Bry_.new_u8(name), Xow_ns_case_.Tid__1st, false);} // for tst_ constructor
|
||||
public Xow_ns_mgr Add_new(int ns_id, byte[] name, byte caseMatchId, boolean alias) {
|
||||
Bry_.Replace_all_direct(name, Byte_ascii.Space, Byte_ascii.Underline); // standardize on _; EX: User talk -> User_talk; DATE:2013-04-21
|
||||
Xow_ns ns = new Xow_ns(ns_id, caseMatchId, name, alias);
|
||||
@@ -155,7 +155,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.lists.ComparerAble {
|
||||
case Xow_ns_.Id_category:
|
||||
ns_category = ns;
|
||||
if (category_trie == null)
|
||||
category_trie = Btrie_slim_mgr.new_(ns.Case_match() == Xow_ns_case_.Id_all);
|
||||
category_trie = Btrie_slim_mgr.new_(ns.Case_match() == Xow_ns_case_.Tid__all);
|
||||
category_trie.Add_obj(ns.Name_bry(), this);
|
||||
break;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.lists.ComparerAble {
|
||||
}
|
||||
}
|
||||
private void Ords_sort_add(int ns_id) {
|
||||
this.Add_new(ns_id, Bry_.new_by_int(ns_id), Xow_ns_case_.Id_1st, false); // NOTE: name and case_match are mostly useless defaults; note that in theory this proc should not be called (all siteInfos should be well-formed) but just in case, create items now so that Get_by_ord() does not fail
|
||||
this.Add_new(ns_id, Int_.To_bry(ns_id), Xow_ns_case_.Tid__1st, false); // NOTE: name and case_match are mostly useless defaults; note that in theory this proc should not be called (all siteInfos should be well-formed) but just in case, create items now so that Get_by_ord() does not fail
|
||||
}
|
||||
public byte[] Bld_ttl_w_ns(Bry_bfr bfr, boolean text_form, boolean literalize, int ns_id, byte[] ttl) {
|
||||
if (ns_id == Xow_ns_.Id_main) return ttl;
|
||||
|
||||
@@ -54,7 +54,7 @@ class Xow_ns_fxt {
|
||||
public Xow_ns_fxt Expd_id_subj_(boolean v) {expd_id_subj = v; return this;} private boolean expd_id_subj;
|
||||
public Xow_ns_fxt Expd_id_talk_(boolean v) {expd_id_talk = v; return this;} private boolean expd_id_talk;
|
||||
public void Test(int nsId) {
|
||||
Xow_ns actl = new Xow_ns(nsId, Xow_ns_case_.Id_1st, Bry_.Empty, false);
|
||||
Xow_ns actl = new Xow_ns(nsId, Xow_ns_case_.Tid__1st, Bry_.Empty, false);
|
||||
Tfds.Eq(expd_id_subjId, actl.Id_subj_id());
|
||||
Tfds.Eq(expd_id_talkId, actl.Id_talk_id());
|
||||
Tfds.Eq(expd_id_subj, actl.Id_subj());
|
||||
|
||||
39
400_xowa/src/gplx/xowa/wikis/pages/Xopg_hdump_data.java
Normal file
39
400_xowa/src/gplx/xowa/wikis/pages/Xopg_hdump_data.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; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
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 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
|
||||
( xfer.Lnki_ttl(), xfer.Lnki_type(), xfer.Lnki_upright(), xfer.Lnki_w(), xfer.Lnki_h(), xfer.Lnki_time(), xfer.Lnki_page()
|
||||
, xfer.Orig_repo_id(), xfer.Orig_ext().Id(), xfer.File_is_orig(), xfer.File_w()
|
||||
, xfer.Html_uid(), xfer.Html_w(), xfer.Html_h()
|
||||
);
|
||||
imgs.Add(img);
|
||||
}
|
||||
public void Clear() {
|
||||
body = null;
|
||||
imgs.Clear();
|
||||
redlink_mgr.Clear();
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ public class Xopg_html_data {
|
||||
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 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();
|
||||
@@ -71,6 +72,7 @@ public class Xopg_html_data {
|
||||
display_ttl = content_sub = display_ttl_vnt = null;
|
||||
lang_convert_content = lang_convert_title = true;
|
||||
lnke_autonumber = 1;
|
||||
sect_uid = -1;
|
||||
xtn_skin_mgr.Clear();
|
||||
xtn_gallery_packed_exists = false;
|
||||
xtn_imap_next_id = 0; xtn_gallery_next_id = -1;
|
||||
|
||||
54
400_xowa/src/gplx/xowa/wikis/pages/Xopg_module_mgr.java
Normal file
54
400_xowa/src/gplx/xowa/wikis/pages/Xopg_module_mgr.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
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.*;
|
||||
public class Xopg_module_mgr {
|
||||
public boolean Math_exists() {return math_exists;} public void Math_exists_(boolean v) {math_exists = v;} private boolean math_exists;
|
||||
public boolean Imap_exists() {return imap_exists;} public void Imap_exists_(boolean v) {imap_exists = v;} private boolean imap_exists;
|
||||
public boolean Gallery_packed_exists() {return gallery_packed_exists;} public void Gallery_packed_exists_(boolean v) {gallery_packed_exists = v;} private boolean gallery_packed_exists;
|
||||
public boolean Hiero_exists() {return hiero_exists;} public void Hiero_exists_(boolean v) {hiero_exists = v;} private boolean hiero_exists;
|
||||
public void Init(boolean math, boolean imap, boolean packed, boolean hiero) {
|
||||
this.math_exists = math;
|
||||
this.imap_exists = imap;
|
||||
this.gallery_packed_exists = packed;
|
||||
this.hiero_exists = hiero;
|
||||
}
|
||||
public int Flag() {return Calc_flag(math_exists, imap_exists, gallery_packed_exists, hiero_exists);}
|
||||
public void Flag_(int v) {
|
||||
this.math_exists = Bitmask_.Has_int(v, Tid_math);
|
||||
this.imap_exists = Bitmask_.Has_int(v, Tid_imap);
|
||||
this.gallery_packed_exists = Bitmask_.Has_int(v, Tid_packed);
|
||||
this.hiero_exists = Bitmask_.Has_int(v, Tid_hiero);
|
||||
}
|
||||
public void Clear() {
|
||||
math_exists = imap_exists = gallery_packed_exists = hiero_exists = false;
|
||||
}
|
||||
private static int Calc_flag(boolean math, boolean imap, boolean packed, boolean hiero) {
|
||||
int rv = 0;
|
||||
if (math) rv = Bitmask_.Add_int(rv, Tid_math);
|
||||
if (imap) rv = Bitmask_.Add_int(rv, Tid_imap);
|
||||
if (packed) rv = Bitmask_.Add_int(rv, Tid_packed);
|
||||
if (hiero) rv = Bitmask_.Add_int(rv, Tid_hiero);
|
||||
return rv;
|
||||
}
|
||||
private static final int // SERIALIZED; only supports 8 different types
|
||||
Tid_math = 1
|
||||
, Tid_imap = 2
|
||||
, Tid_packed = 4
|
||||
, Tid_hiero = 8
|
||||
;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.specials; import gplx.*; import gplx.xowa.*; import gplx
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.specials.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.file_browsers.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
public class Xosp_special_mgr {
|
||||
private final Xowv_wiki wiki;
|
||||
private final Hash_adp_bry hash;
|
||||
@@ -28,15 +28,15 @@ public class Xosp_special_mgr {
|
||||
// hash.Add_str_obj(Xows_special_meta_.Key__statistics , page_statistics);
|
||||
this.hash = Hash_adp_bry.cs();
|
||||
}
|
||||
public void Get_by_ttl(Xog_page rv, Gfo_url url, Xoa_ttl ttl) {
|
||||
public void Get_by_ttl(Xoh_page rv, Gfo_url url, Xoa_ttl ttl) {
|
||||
Xosp_fbrow_rslt rslt = Xosp_fbrow_special.Gen(url.Qargs(), wiki.Appv().Wiki_mgr());
|
||||
rv.Init(wiki, -1, null, ttl);
|
||||
rv.Page_body_(rslt.Html_body());
|
||||
rv.Init(wiki, null, ttl, -1);
|
||||
rv.Body_(rslt.Html_body());
|
||||
rv.Html_head_xtn_(rslt.Html_head());
|
||||
}
|
||||
public void Get_by_url(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
int slash_pos = Bry_find_.Find_fwd(ttl.Page_txt_wo_qargs(), Xoa_ttl.Subpage_spr); // check for slash
|
||||
byte[] special_name = slash_pos == Bry_.NotFound
|
||||
byte[] special_name = slash_pos == Bry_find_.Not_found
|
||||
? ttl.Base_txt_wo_qarg() // no slash found; use base_txt; ignore qry args and just get page_names; EX: Search/Earth?fulltext=y; Allpages?from=Earth...
|
||||
: Bry_.Mid(ttl.Page_txt_wo_qargs(), 0, slash_pos); // slash found; use root page; EX: Special:ItemByTitle/enwiki/Earth
|
||||
Object o = hash.Get_by_bry(special_name);
|
||||
|
||||
@@ -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.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xotdb_dir_info {
|
||||
public Xotdb_dir_info(boolean ns_root, byte id, String name) {this.ns_root = ns_root; this.id = id; this.name = name;}
|
||||
public byte Id() {return id;} private byte id;
|
||||
@@ -30,25 +30,25 @@ public class Xotdb_dir_info {
|
||||
ext_bry = Wtr_ext(v);
|
||||
ext_str = String_.new_a7(ext_bry);
|
||||
return this;
|
||||
} byte ext_tid = gplx.ios.Io_stream_.Tid_raw;
|
||||
} 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);
|
||||
public static String Wtr_dir(byte v) {
|
||||
switch (v) {
|
||||
case gplx.ios.Io_stream_.Tid_raw : return "";
|
||||
case gplx.ios.Io_stream_.Tid_zip : return "_zip";
|
||||
case gplx.ios.Io_stream_.Tid_gzip : return "_gz";
|
||||
case gplx.ios.Io_stream_.Tid_bzip2 : return "_bz2";
|
||||
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";
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static byte[] Wtr_ext(byte v) {
|
||||
switch (v) {
|
||||
case gplx.ios.Io_stream_.Tid_raw : return Wtr_xdat_bry;
|
||||
case gplx.ios.Io_stream_.Tid_zip : return Wtr_zip_bry;
|
||||
case gplx.ios.Io_stream_.Tid_gzip : return Wtr_gz_bry;
|
||||
case gplx.ios.Io_stream_.Tid_bzip2 : return Wtr_bz2_bry;
|
||||
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;
|
||||
default : throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ 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.ios.Io_stream_.Tid_raw; // needed for Xoa_xowa_exec_tst
|
||||
byte tid = gplx.core.ios.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.ios.Io_stream_.Tid_raw; break;}
|
||||
else if (String_.Eq(dir_name, "page_zip")) tid = gplx.ios.Io_stream_.Tid_zip;
|
||||
else if (String_.Eq(dir_name, "page_gz")) tid = gplx.ios.Io_stream_.Tid_gzip;
|
||||
else if (String_.Eq(dir_name, "page_bz2")) tid = gplx.ios.Io_stream_.Tid_bzip2;
|
||||
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;
|
||||
}
|
||||
fsys_mgr.Tdb_dir_regy()[id].Ext_tid_(tid);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class Xow_fsys_mgr_fxt {
|
||||
wiki = Xoa_app_fxt.wiki_tst_(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.ios.Io_stream_.Tid_zip : gplx.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.Io_stream_.Tid_zip : gplx.core.ios.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());
|
||||
}
|
||||
|
||||
@@ -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.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.core.brys.*; import gplx.core.encoders.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xotdb_page_itm_ {
|
||||
static final int Txt_len_id = 5, Txt_len_fil_idx = 5, Txt_len_row_idx = 5, Txt_len_type = 1, Txt_len_text_len = 5;
|
||||
public static final int Txt_ttl_pos = Txt_len_id + Txt_len_fil_idx + Txt_len_row_idx + Txt_len_type + Txt_len_text_len + 5;
|
||||
@@ -30,11 +30,11 @@ public class Xotdb_page_itm_ {
|
||||
private static void Txt_ttl_load(Xowd_page_itm page, byte[] bry, int bgn, int end) {
|
||||
try {
|
||||
page.Init_by_tdb
|
||||
( Base85_utl.XtoIntByAry (bry, bgn + 0, bgn + 4)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 6, bgn + 10)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 12, bgn + 16)
|
||||
( Base85_.To_int_by_bry (bry, bgn + 0, bgn + 4)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 6, bgn + 10)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 12, bgn + 16)
|
||||
, bry[18] == Byte_ascii.Num_1
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 20, bgn + 24)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 20, bgn + 24)
|
||||
, page.Ns_id()
|
||||
, Bry_.Mid (bry, bgn + 26, end)
|
||||
);
|
||||
@@ -55,12 +55,12 @@ public class Xotdb_page_itm_ {
|
||||
try {
|
||||
page.Clear();
|
||||
page.Init_by_tdb
|
||||
( Base85_utl.XtoIntByAry (bry, bgn + 0, bgn + 4)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 6, bgn + 10)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 12, bgn + 16)
|
||||
( Base85_.To_int_by_bry (bry, bgn + 0, bgn + 4)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 6, bgn + 10)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 12, bgn + 16)
|
||||
, bry[18] == Byte_ascii.Num_1
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 20, bgn + 24)
|
||||
, Base85_utl.XtoIntByAry (bry, bgn + 26, bgn + 30)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 20, bgn + 24)
|
||||
, Base85_.To_int_by_bry (bry, bgn + 26, bgn + 30)
|
||||
, Bry_.Mid (bry, bgn + 32, end)
|
||||
);
|
||||
} catch (Exception e) {throw Err_.new_exc(e, "xo", "parse_by_id failed", "id", String_.new_u8(bry, bgn, end));}
|
||||
@@ -76,8 +76,8 @@ public class Xotdb_page_itm_ {
|
||||
}
|
||||
public static void Txt_page_save(Bry_bfr bfr, int id, DateAdp modified_on, byte[] title, byte[] text, boolean add_nl) {
|
||||
int ts = Bit_.Xto_int_date_short(modified_on.XtoSegAry());
|
||||
bfr .Add_base85(id , Base85_utl.Len_int) .Add_byte(Txt_page_dlm) // needed for mass template load
|
||||
.Add_base85(ts , Base85_utl.Len_int) .Add_byte(Txt_page_dlm)
|
||||
bfr .Add_base85(id , Base85_.Len_int) .Add_byte(Txt_page_dlm) // needed for mass template load
|
||||
.Add_base85(ts , Base85_.Len_int) .Add_byte(Txt_page_dlm)
|
||||
.Add(title) .Add_byte(Txt_page_dlm) // needed for rebuilding ttl files
|
||||
.Add(text) .Add_byte(Txt_page_dlm);
|
||||
if (add_nl)
|
||||
|
||||
@@ -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.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.*; import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.core.brys.*; import gplx.core.ios.*; import gplx.core.encoders.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.tdbs.bldrs.*;
|
||||
public class Xotdb_page_raw_parser {
|
||||
@@ -43,10 +43,10 @@ public class Xotdb_page_raw_parser {
|
||||
public boolean Read(Xowd_page_itm page) {
|
||||
boolean read = false;
|
||||
read = rdr.Read_next(); if (!read) return false;
|
||||
int id = Base85_utl.XtoIntByAry(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end() - 2);
|
||||
int id = Base85_.To_int_by_bry(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end() - 2);
|
||||
page.Id_(id);
|
||||
read = rdr.Read_next(); if (!read) throw Err_.new_wo_type("could not read timestamp");
|
||||
int timestamp = Base85_utl.XtoIntByAry(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end() - 1);
|
||||
int timestamp = Base85_.To_int_by_bry(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end() - 1);
|
||||
page.Modified_on_(Bit_.Xto_date_short(timestamp));
|
||||
read = rdr.Read_next(); if (!read) throw Err_.new_wo_type("could not read ttl");
|
||||
byte[] ttl = Bry_.Mid(rdr.Bfr(), rdr.Key_pos_bgn(), rdr.Key_pos_end() - 1);
|
||||
|
||||
@@ -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.tdbs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Io_line_rdr_key_gen_all implements Io_line_rdr_key_gen {
|
||||
public void Gen(Io_line_rdr bfr) {
|
||||
bfr.Key_pos_bgn_(bfr.Itm_pos_bgn()).Key_pos_end_(bfr.Itm_pos_end());
|
||||
|
||||
@@ -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.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.bldrs.sqls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
@@ -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.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.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.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.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.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
// byte[] xdat_bry = gplx.core.ios.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.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.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.ios.Io_stream_rdr_.Load_all(xdat_url);
|
||||
byte[] xdat_bry = gplx.core.ios.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);
|
||||
|
||||
@@ -16,9 +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.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
import gplx.core.encoders.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
public class Xow_hive_mgr_fxt {
|
||||
public void Clear() {
|
||||
if (hive_mgr == null) {
|
||||
@@ -80,14 +79,14 @@ public class Xow_hive_mgr_fxt {
|
||||
public Xow_hive_mgr_fxt Create_id(int id, int fil_idx, int row_idx, boolean type_redirect, int itm_len, int ns_id, String ttl) {Create_id(app, hive_mgr, id, fil_idx, row_idx, type_redirect, itm_len, ns_id, ttl); return this;}
|
||||
public static void Create_id(Xoae_app app, Xob_hive_mgr hive_mgr, int id, int fil_idx, int row_idx, boolean type_redirect, int itm_len, int ns_id, String ttl) {
|
||||
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b512();
|
||||
byte[] key_bry = Base85_utl.XtoStrByAry(id, 5);
|
||||
byte[] key_bry = Base85_.To_bry(id, 5);
|
||||
bfr .Add(key_bry) .Add_byte_pipe()
|
||||
.Add_base85_len_5(fil_idx) .Add_byte_pipe()
|
||||
.Add_base85_len_5(row_idx) .Add_byte_pipe()
|
||||
.Add_byte(type_redirect ? Byte_ascii.Num_1 : Byte_ascii.Num_0).Add_byte_pipe()
|
||||
.Add_base85_len_5(itm_len) .Add_byte_pipe()
|
||||
.Add_base85_len_5(ns_id) .Add_byte_pipe()
|
||||
.Add_str(ttl) .Add_byte_nl();
|
||||
.Add_str_u8(ttl) .Add_byte_nl();
|
||||
byte[] row = bfr.To_bry_and_clear();
|
||||
bfr.Mkr_rls();
|
||||
hive_mgr.Create(Xotdb_dir_info_.Tid_id, key_bry, row);
|
||||
|
||||
@@ -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.tdbs.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xos_url_gen implements Io_url_gen {
|
||||
public Xos_url_gen(Io_url root) {this.root = root;} Io_url root; int idx = 0;
|
||||
public byte[] Ext() {return ext;} public Xos_url_gen Ext_(byte[] v) {ext = v; return this;} private byte[] ext = Bry_.new_a7(".csv");
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.tdbs.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import org.junit.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Xos_url_gen_tst {
|
||||
@Test public void Url_gen() {
|
||||
tst_url_gen("mem/root/", 0, "mem/root/00/00/00/00/0000000000.csv");
|
||||
|
||||
@@ -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.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.ios.*; 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)
|
||||
@@ -154,7 +154,7 @@ public class Xob_xdat_file {
|
||||
slot_bgn = itm_count * Len_idx_itm;
|
||||
if (slot_bgn >= src_len) break;
|
||||
if (src[slot_bgn] == Byte_ascii.Nl) break;
|
||||
int tmp_val = Base85_utl.XtoIntByAry(src, slot_bgn, slot_bgn + Offset_base85);
|
||||
int tmp_val = Base85_.To_int_by_bry(src, slot_bgn, slot_bgn + Offset_base85);
|
||||
slot_new = slot_old + tmp_val;
|
||||
int new_idx = itm_count + 1;
|
||||
if (tmp_len < new_idx) {
|
||||
|
||||
@@ -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.tdbs.xdats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.encoders.*; import gplx.xowa.wikis.tdbs.*;
|
||||
public class Xob_xdat_file_wtr {
|
||||
public static Xob_xdat_file_wtr new_file_(int fil_max, Io_url root_dir) {return new Xob_xdat_file_wtr(fil_max, root_dir, Io_stream_.Tid_raw);}
|
||||
public static Xob_xdat_file_wtr new_by_tid_(int fil_max, Io_url root_dir, byte dir_tid, byte tid) {return new Xob_xdat_file_wtr(fil_max, root_dir.GenSubDir(Xotdb_dir_info_.Tid_name(dir_tid) + Xotdb_dir_info.Wtr_dir(tid)), tid);}
|
||||
@@ -69,7 +69,7 @@ public class Xob_xdat_file_wtr {
|
||||
for (int i = 0; i < idx_pos; i++) {
|
||||
int idx_bry_pos = i * Len_idx_itm;
|
||||
int cur_pos = idx[i];
|
||||
Base85_utl.XtoStrByAry(cur_pos - prv_pos, idx_bry, idx_bry_pos, Len_base85);
|
||||
Base85_.Set_bry(cur_pos - prv_pos, idx_bry, idx_bry_pos, Len_base85);
|
||||
idx_bry[idx_bry_pos + Len_base85] = Dlm_fld;
|
||||
prv_pos = cur_pos;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class Xob_xdat_file_wtr {
|
||||
// for (int i = 0; i < idx_pos; i++) {
|
||||
// int idx_bry_pos = i * Len_idx_itm;
|
||||
// int cur_pos = idx[i];
|
||||
// Base85_utl.XtoStrByAry(cur_pos - prv_pos, idx_bry, idx_bry_pos, Len_base85);
|
||||
// Base85_.Set_bry(cur_pos - prv_pos, idx_bry, idx_bry_pos, Len_base85);
|
||||
// idx_bry[idx_bry_pos + Len_base85] = Dlm_idx;
|
||||
// prv_pos = cur_pos;
|
||||
// }
|
||||
|
||||
@@ -16,6 +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.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.log_msgs.*;
|
||||
public class Xop_ttl_log {
|
||||
private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "ttl");
|
||||
public static final Gfo_msg_itm
|
||||
|
||||
@@ -16,6 +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.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.log_msgs.*;
|
||||
class Xow_ttl_fxt {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
public Xow_ttl_fxt Init_ttl(String raw) {test_raw = raw; return this;} private String test_raw = "";
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public interface Xow_ttl_parser {
|
||||
Xoa_ttl Ttl_parse(byte[] ttl);
|
||||
Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end);
|
||||
Xoa_ttl Ttl_parse(int ns_id, byte[] ttl);
|
||||
Xow_ns_mgr Ns_mgr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user