mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.1.4.1a
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.wiki_orig; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
public class Xof_wiki_orig_itm {
|
||||
public int Id() {return id;} public Xof_wiki_orig_itm Id_(int v) {id = v; return this;} private int id;
|
||||
public byte[] Ttl() {return ttl;} public Xof_wiki_orig_itm Ttl_(byte[] v) {ttl = v; return this;} private byte[] ttl;
|
||||
public byte Status() {return status;} public Xof_wiki_orig_itm Status_(byte v) {status = v; return this;} private byte status;
|
||||
public byte Orig_repo() {return orig_repo;} public Xof_wiki_orig_itm Orig_repo_(byte v) {orig_repo = v; return this;} private byte orig_repo;
|
||||
public int Orig_w() {return orig_w;} public Xof_wiki_orig_itm Orig_w_(int v) {orig_w = v; return this;} private int orig_w;
|
||||
public int Orig_h() {return orig_h;} public Xof_wiki_orig_itm Orig_h_(int v) {orig_h = v; return this;} private int orig_h;
|
||||
public int Orig_ext() {return orig_ext;} public Xof_wiki_orig_itm Orig_ext_(int v) {orig_ext = v; return this;} private int orig_ext;
|
||||
public byte[] Orig_redirect() {return orig_redirect;} public Xof_wiki_orig_itm Orig_redirect_(byte[] v) {orig_redirect = v; return this;} private byte[] orig_redirect;
|
||||
public static Xof_wiki_orig_itm load_(DataRdr rdr) {
|
||||
Xof_wiki_orig_itm rv = new Xof_wiki_orig_itm();
|
||||
rv.ttl = rdr.ReadBryByStr(Xof_wiki_orig_tbl.Fld_orig_ttl);
|
||||
rv.status = rdr.ReadByte(Xof_wiki_orig_tbl.Fld_status);
|
||||
rv.orig_repo = rdr.ReadByte(Xof_wiki_orig_tbl.Fld_orig_repo);
|
||||
rv.orig_w = rdr.ReadInt(Xof_wiki_orig_tbl.Fld_orig_w);
|
||||
rv.orig_h = rdr.ReadInt(Xof_wiki_orig_tbl.Fld_orig_h);
|
||||
rv.orig_ext = rdr.ReadInt(Xof_wiki_orig_tbl.Fld_orig_ext);
|
||||
rv.orig_redirect = rdr.ReadBryByStr(Xof_wiki_orig_tbl.Fld_orig_redirect);
|
||||
return rv;
|
||||
}
|
||||
public static final Xof_wiki_orig_itm Null = null;
|
||||
}
|
||||
@@ -1,25 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Db_provider_key {
|
||||
public Db_provider_key(String key, Db_conn_info conn_info, GfoInvkAbleCmd init_cmd) {this.key = key; this.conn_info = conn_info; this.init_cmd = init_cmd;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public Db_conn_info Conn_info() {return conn_info;} private Db_conn_info conn_info;
|
||||
public GfoInvkAbleCmd Init_cmd() {return init_cmd;} private GfoInvkAbleCmd init_cmd;
|
||||
}
|
||||
@@ -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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Db_provider_mkr {
|
||||
private final HashAdp engine_regy = HashAdp_.new_();
|
||||
public void Engines_add(Db_engine engine) {engine_regy.AddReplace(engine.Conn_info_tid(), engine);}
|
||||
public Db_provider Get(Db_provider_key provider_key) {
|
||||
Db_provider rv = Get_or_new(provider_key);
|
||||
GfoInvkAbleCmd init_cmd = provider_key.Init_cmd();
|
||||
if (init_cmd != GfoInvkAbleCmd.Null)
|
||||
GfoInvkAble_.InvkCmd_val(init_cmd.InvkAble(), init_cmd.Cmd(), rv);
|
||||
return rv;
|
||||
}
|
||||
private Db_provider Get_or_new(Db_provider_key key) {
|
||||
Db_conn_info conn_info = key.Conn_info();
|
||||
Db_engine prototype = (Db_engine)engine_regy.Fetch(conn_info.Key());
|
||||
Db_engine engine = prototype.Make_new(conn_info);
|
||||
engine.Conn_open(); // auto-open
|
||||
return new Db_provider(engine);
|
||||
}
|
||||
}
|
||||
class Mem_db_rdr implements Db_rdr {
|
||||
private int idx = -1, len;
|
||||
private Mem_db_row[] rows = new Mem_db_row[0];
|
||||
private Mem_db_rdr(Mem_db_row[] rows) {
|
||||
this.rows = rows;
|
||||
this.len = rows.length;
|
||||
}
|
||||
public boolean Move_next() {return ++idx < len;}
|
||||
public byte[] Read_bry(int i) {return (byte[])rows[idx].Get_at(i);}
|
||||
public byte[] Read_bry_by_str(int i) {return Bry_.new_utf8_((String)rows[idx].Get_at(i));}
|
||||
public String Read_str(int i) {return (String)rows[idx].Get_at(i);}
|
||||
public byte Read_byte(int i) {return Byte_.cast_(rows[idx].Get_at(i));}
|
||||
public int Read_int(int i) {return Int_.cast_(rows[idx].Get_at(i));}
|
||||
public long Read_long(int i) {return Long_.cast_(rows[idx].Get_at(i));}
|
||||
public float Read_float(int i) {return Float_.cast_(rows[idx].Get_at(i));}
|
||||
public double Read_double(int i) {return Double_.cast_(rows[idx].Get_at(i));}
|
||||
public void Close() {rows = null;}
|
||||
public static Mem_db_rdr new_by_rows(Mem_db_row[] rows) {return new Mem_db_rdr(rows);}
|
||||
public static Mem_db_rdr new_by_obj_ary(Object[][] obj_arys) {
|
||||
int obj_arys_len = obj_arys.length;
|
||||
Mem_db_row[] rows = new Mem_db_row[obj_arys_len];
|
||||
for (int i = 0; i < obj_arys_len; ++i) {
|
||||
Object[] obj_ary = obj_arys[i];
|
||||
rows[i] = new Mem_db_row(obj_ary);
|
||||
}
|
||||
return new Mem_db_rdr(rows);
|
||||
}
|
||||
}
|
||||
class Mem_db_row {
|
||||
private Object[] vals;
|
||||
public Mem_db_row(Object[] vals) {this.vals = vals;}
|
||||
public Object Get_at(int i) {return vals[i];}
|
||||
}
|
||||
@@ -1,39 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.intl.*;
|
||||
public class Xoav_app {
|
||||
public Xoav_app(Gfo_usr_dlg usr_dlg, Io_url root_dir, String plat_name) {
|
||||
this.usr_dlg = usr_dlg;
|
||||
this.fsys_mgr = new Xoa_fsys_mgr(root_dir, plat_name);
|
||||
this.wiki_mgr = new Xoav_wiki_mgr(this, fsys_mgr.Wiki_dir(), utl_case_mgr);
|
||||
this.db_mgr = new Db_provider_mkr();
|
||||
this.utl_msg_log = Gfo_msg_log.Test();
|
||||
db_mgr.Engines_add(gplx.dbs.Sqlite_engine_.New_engine());
|
||||
}
|
||||
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xoa_fsys_mgr fsys_mgr;
|
||||
public Xoav_wiki_mgr Wiki_mgr() {return wiki_mgr;} private final Xoav_wiki_mgr wiki_mgr;
|
||||
public Db_provider_mkr Db_mgr() {return db_mgr;} private Db_provider_mkr db_mgr;
|
||||
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} private Gfo_usr_dlg usr_dlg;
|
||||
public Bry_bfr_mkr Utl_bfr_mkr() {return utl_bfr_mkr;} private Bry_bfr_mkr utl_bfr_mkr = new Bry_bfr_mkr();
|
||||
public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = new Xop_amp_mgr();
|
||||
public Xol_case_mgr Utl_case_mgr() {return utl_case_mgr;} private Xol_case_mgr utl_case_mgr = Xol_case_mgr_.Utf8();
|
||||
public Url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Url_encoder utl_encoder_fsys = Url_encoder.new_fsys_lnx_();
|
||||
public Gfo_msg_log Utl_msg_log() {return utl_msg_log;} private Gfo_msg_log utl_msg_log;
|
||||
}
|
||||
@@ -1,37 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Xoav_wiki_mgr {
|
||||
private final Xoav_app app; private final OrderedHash hash = OrderedHash_.new_bry_();
|
||||
private Io_url wiki_root_dir;
|
||||
public Xoav_wiki_mgr(Xoav_app app, Io_url wiki_root_dir, Xol_case_mgr case_mgr) {this.app = app; this.wiki_root_dir = wiki_root_dir;}
|
||||
public Xowv_wiki Get_by_domain(byte[] domain) {
|
||||
Xowv_wiki rv = (Xowv_wiki)hash.Fetch(domain);
|
||||
return rv.Init_assert();
|
||||
}
|
||||
public void Load_default() {
|
||||
Io_url[] wiki_dirs = Io_mgr._.QueryDir_args(wiki_root_dir).DirOnly_().ExecAsUrlAry();
|
||||
for (Io_url wiki_dir : wiki_dirs) {
|
||||
String wiki_dir_url = wiki_dir.Raw();
|
||||
if (String_.HasAtBgn(wiki_dir_url, "#")) continue;
|
||||
Xowv_wiki wiki = new Xowv_wiki(app, wiki_dir.NameOnly(), wiki_dir);
|
||||
hash.Add(wiki.Domain_bry(), wiki);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.gui.history.*;
|
||||
public abstract class Xogv_tab_base {
|
||||
private Xog_history_stack history_stack = new Xog_history_stack();
|
||||
private Xoav_wiki_mgr wiki_mgr;
|
||||
public void Ctor(Xoav_wiki_mgr wiki_mgr) {this.wiki_mgr = wiki_mgr;}
|
||||
public Xog_history_itm Cur_itm() {return history_stack.Cur_itm();}
|
||||
public Hdump_page Go_to(byte[] page) {return Go_to(history_stack.Cur_itm().Wiki(), page, Bry_.Empty, Bry_.Empty, false, "");}
|
||||
public Hdump_page Go_to(byte[] wiki, byte[] page) {return Go_to(wiki, page, Bry_.Empty, Bry_.Empty, false, "");}
|
||||
public Hdump_page Go_to(byte[] wiki, byte[] page, byte[] anch, byte[] qarg, boolean redirect_force, String bmk_pos) {
|
||||
Xog_history_itm old_itm = this.Cur_itm();
|
||||
Xog_history_itm new_itm = new Xog_history_itm(wiki, page, anch, qarg, redirect_force, bmk_pos);
|
||||
history_stack.Add(new_itm);
|
||||
return Fetch_page_and_show(old_itm, new_itm);
|
||||
}
|
||||
public Hdump_page Go_bwd() {return Go_by_dir(Bool_.Y);}
|
||||
public Hdump_page Go_fwd() {return Go_by_dir(Bool_.N);}
|
||||
private Hdump_page Go_by_dir(boolean bwd) {
|
||||
Xog_history_itm old_itm = this.Cur_itm();
|
||||
Xog_history_itm new_itm = bwd ? history_stack.Go_bwd() : history_stack.Go_fwd();
|
||||
return Fetch_page_and_show(old_itm, new_itm);
|
||||
}
|
||||
private Hdump_page Fetch_page_and_show(Xog_history_itm old_itm, Xog_history_itm new_itm) {
|
||||
Hdump_page new_hpg = Fetch_page(new_itm.Wiki(), new_itm.Page());
|
||||
Show_page(old_itm, new_itm, new_hpg);
|
||||
return new_hpg;
|
||||
}
|
||||
private Hdump_page Fetch_page(byte[] wiki_domain, byte[] page_ttl) {
|
||||
Xowv_wiki wiki = wiki_mgr.Get_by_domain(wiki_domain);
|
||||
Hdump_page rv = new Hdump_page();
|
||||
wiki.Hdump_mgr().Load(rv, page_ttl);
|
||||
return rv;
|
||||
}
|
||||
protected abstract void Show_page(Xog_history_itm old_itm, Xog_history_itm new_itm, Hdump_page new_hpg);
|
||||
}
|
||||
@@ -1,55 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*; import gplx.xowa.dbs.*;
|
||||
public class Xowv_db_mgr implements GfoInvkAble {
|
||||
private Io_url wiki_root_dir;
|
||||
public Xowv_db_mgr(String domain_str, Io_url wiki_root_dir) {
|
||||
this.tbl_mgr = new Xowd_db_tbl_mgr(); this.wiki_root_dir = wiki_root_dir;
|
||||
this.key__core = Xowv_db_mgr.Db_key__core__default(this, domain_str, wiki_root_dir);
|
||||
}
|
||||
public Xowd_db_tbl_mgr Tbl_mgr() {return tbl_mgr;} private Xowd_db_tbl_mgr tbl_mgr;
|
||||
private Xodb_file[] db_files; private Db_provider_key[] db_keys; private int db_keys_len;
|
||||
public Db_provider_key Key__core() {return key__core;} private Db_provider_key key__core;
|
||||
public Db_provider_key Key_by_idx(int idx) {if (!Int_.Between(idx, 0, db_keys_len)) throw Err_.new_("database does not exist: idx={0}", idx); return db_keys[idx];}
|
||||
private void Core_init(Db_provider provider) {
|
||||
db_files = tbl_mgr.Tbl__dbs_new().Select_all(provider, wiki_root_dir);
|
||||
db_keys = Db_keys_make(db_files);
|
||||
db_keys_len = db_keys.length;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_core_init)) Core_init((Db_provider)m.ReadObj("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_core_init = "core_init";
|
||||
private static Db_provider_key Db_key__core__default(Xowv_db_mgr db_mgr, String domain_str, Io_url wiki_root_dir) {
|
||||
Io_url core_db_url = wiki_root_dir.GenSubFil_ary(domain_str, ".000.sqlite3");
|
||||
GfoInvkAbleCmd init_cmd = GfoInvkAbleCmd.new_(db_mgr, Invk_core_init);
|
||||
return new Db_provider_key(core_db_url.Raw(), Db_conn_info_.sqlite_(core_db_url), init_cmd);
|
||||
}
|
||||
private static Db_provider_key[] Db_keys_make(Xodb_file[] ary) {
|
||||
int len = ary.length;
|
||||
Db_provider_key[] rv = new Db_provider_key[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xodb_file itm = ary[i];
|
||||
Io_url itm_url = itm.Url();
|
||||
rv[i] = new Db_provider_key(itm_url.Raw(), Db_conn_info_.sqlite_(itm_url), GfoInvkAbleCmd.Null);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.dbs.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Xowv_db_mgr_tst {
|
||||
@Before public void init() {} private Xowv_db_mgr_fxt fxt = new Xowv_db_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init_rdr(fxt.Make_row(0, "mem/a", 2),fxt.Make_row(0, "mem/a", 2), fxt.Make_row(0, "mem/a", 2));
|
||||
// fxt.Exec_open_core();
|
||||
// fxt.Test_dbs(fxt.Make_db(0, "mem/a", 0), fxt.Make_db(1, "mem/2", 2), fxt.Make_db("mem/3, 3"));
|
||||
}
|
||||
}
|
||||
class Xowv_db_mgr_fxt {
|
||||
// private Xoav_app app; private Xowv_wiki wiki;
|
||||
public void Init_rdr(Mem_db_row... rows) {
|
||||
// Mem_db_rdr rdr = Mem_db_rdr.new_by_rows(rows);
|
||||
// app = new Xoav_app(null, nul, null);
|
||||
// Mem_db_engine engine = new Mem_db_engine();
|
||||
// engine.Pending_rdrs_add(rdr);
|
||||
// app.Db_mgr().Engines_add(engine);
|
||||
}
|
||||
public Mem_db_row Make_row(Object... vals) {return new Mem_db_row(vals);}
|
||||
public void Exec_open_core() {
|
||||
// app.Db_mgr().Get(wiki.Db_mgr().Key__core());
|
||||
}
|
||||
public void Test_dbs(Xodb_file[] expd) {
|
||||
// Tfds.Eq(expd, wiki.Db_mgr().Files());
|
||||
}
|
||||
}
|
||||
@@ -1,55 +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.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*; import gplx.xowa.apps.ttls.*; import gplx.xowa.html.hzips.*;
|
||||
import gplx.xowa.dbs.tbls.*; import gplx.dbs.*;
|
||||
public class Xowv_wiki implements Xoa_ttl_parser {
|
||||
private Xoav_app app;
|
||||
public Xowv_wiki(Xoav_app app, String domain_str, Io_url wiki_root_dir) {
|
||||
this.app = app;
|
||||
this.domain_str = domain_str; this.domain_bry = Bry_.new_utf8_(domain_str);
|
||||
this.ns_mgr = Xow_ns_mgr_.default_(app.Utl_case_mgr()); // new Xow_ns_mgr(app.Utl_case_mgr()); // FIXME
|
||||
this.db_mgr = new Xowv_db_mgr(domain_str, wiki_root_dir);
|
||||
this.hdump_mgr = new Xowd_hdump_mgr(app, this);
|
||||
this.xwiki_mgr = new Xow_xwiki_mgr();
|
||||
this.hzip_mgr = new Xow_hzip_mgr(app.Usr_dlg(), this);
|
||||
}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public Xowv_db_mgr Db_mgr() {return db_mgr;} private final Xowv_db_mgr db_mgr;
|
||||
public Xowd_hdump_mgr Hdump_mgr() {return hdump_mgr;} private final Xowd_hdump_mgr hdump_mgr;
|
||||
public Xow_hzip_mgr Hzip_mgr() {return hzip_mgr;} private Xow_hzip_mgr hzip_mgr;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private Xow_xwiki_mgr xwiki_mgr;
|
||||
private boolean init_done = false;
|
||||
public Xowv_wiki Init_assert() {
|
||||
if (init_done) return this;
|
||||
init_done = true;
|
||||
Db_provider core_provider = app.Db_mgr().Get(db_mgr.Key__core());
|
||||
Xodb_xowa_ns_tbl ns_tbl = db_mgr.Tbl_mgr().Tbl__ns();
|
||||
ns_tbl.Provider_(core_provider);
|
||||
ns_tbl.Select_all(ns_mgr);
|
||||
return this;
|
||||
}
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,66 +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.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.xowa.pages.*; import gplx.xowa.pages.skins.*;
|
||||
public class Hdump_page {
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public Xoa_url Page_url() {return page_url;} private Xoa_url page_url;
|
||||
public Xoa_ttl Page_ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public int Version_id() {return version_id;} public void Version_id_(int v) {version_id = v;} private int version_id;
|
||||
public int Img_count() {return img_count;} public void Img_count_(int v) {img_count = v;} private int img_count;
|
||||
public Hdump_module_mgr Module_mgr() {return module_mgr;} private Hdump_module_mgr module_mgr = new Hdump_module_mgr();
|
||||
public byte[] Page_body() {return page_body;} public void Page_body_(byte[] v) {this.page_body = v;} private byte[] page_body;
|
||||
public byte[] Display_ttl() {return display_ttl;} public void Display_ttl_(byte[] v) {this.display_ttl = v;} private byte[] display_ttl;
|
||||
public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {this.content_sub = v;} private byte[] content_sub;
|
||||
public byte[] Sidebar_div() {return sidebar_div;} public void Sidebar_div_(byte[] v) {this.sidebar_div = v;} private byte[] sidebar_div;
|
||||
public int[] Redlink_uids() {return redlink_uids;} public void Redlink_uids_(int[] v) {redlink_uids = v;} private int[] redlink_uids;
|
||||
public Hdump_data_img__base[] Img_itms() {return img_itms;} public void Img_itms_(Hdump_data_img__base[] v) {this.img_itms = v;} private Hdump_data_img__base[] img_itms;
|
||||
public OrderedHash Gly_itms() {return gly_itms;} private OrderedHash gly_itms = OrderedHash_.new_();
|
||||
public Hdump_page Init(int page_id, Xoa_url page_url, Xoa_ttl page_ttl) {
|
||||
this.page_id = page_id; this.page_url = page_url; this.page_ttl = page_ttl;
|
||||
content_sub = sidebar_div = Bry_.Empty;
|
||||
display_ttl = null;
|
||||
img_itms = Hdump_data_img__base.Ary_empty;
|
||||
module_mgr.Clear();
|
||||
gly_itms.Clear();
|
||||
return this;
|
||||
}
|
||||
public void Init(Bry_bfr tmp_bfr, Xoa_page page) {
|
||||
page_id = page.Revision_data().Id();
|
||||
page_body = page.Hdump_data().Body();
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
gplx.xowa.html.modules.Xoh_module_mgr mod_mgr = html_data.Module_mgr();
|
||||
module_mgr.Init(mod_mgr.Itm_mathjax().Enabled(), mod_mgr.Itm_popups().Bind_hover_area(), mod_mgr.Itm_gallery().Enabled(), mod_mgr.Itm_hiero().Enabled());
|
||||
display_ttl = html_data.Display_ttl();
|
||||
content_sub = html_data.Content_sub();
|
||||
sidebar_div = Save_sidebars(tmp_bfr, page, html_data);
|
||||
}
|
||||
private static byte[] Save_sidebars(Bry_bfr tmp_bfr, Xoa_page page, Xopg_html_data html_data) {
|
||||
Xopg_xtn_skin_mgr mgr = html_data.Xtn_skin_mgr();
|
||||
int len = mgr.Count();
|
||||
boolean sidebar_exists = false;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_xtn_skin_itm itm = mgr.Get_at(i);
|
||||
if (itm.Tid() == Xopg_xtn_skin_itm_tid.Tid_sidebar) {
|
||||
sidebar_exists = true;
|
||||
itm.Write(tmp_bfr, page);
|
||||
}
|
||||
}
|
||||
return sidebar_exists ? tmp_bfr.Xto_bry_and_clear() : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user