mirror of https://github.com/gnosygnu/xowa
parent
8e91ac0bc4
commit
b0fdf78a41
@ -0,0 +1,66 @@
|
||||
/*
|
||||
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;
|
||||
import java.util.GregorianCalendar;
|
||||
public class Datetime_now {
|
||||
private static final DateAdp dflt = DateAdp_.parse_gplx("2001-01-01 00:00:00.000");
|
||||
private static DateAdp manual;
|
||||
private static boolean autoincrement = true;
|
||||
public static void Manual_y_() {
|
||||
manual = dflt;
|
||||
}
|
||||
public static void Manual_n_() {
|
||||
manual = null;
|
||||
autoincrement = true;
|
||||
}
|
||||
public static void Manual_and_freeze_(DateAdp v) {
|
||||
manual = v;
|
||||
autoincrement = false;
|
||||
}
|
||||
public static void Manual_(DateAdp v) {
|
||||
manual = v;
|
||||
}
|
||||
public static void Autoincrement_n_() {
|
||||
autoincrement = false;
|
||||
}
|
||||
public static DateAdp Dflt_add_min_(int v) {
|
||||
return dflt.Add_minute(v);
|
||||
}
|
||||
|
||||
public static DateAdp Get() {
|
||||
if (manual == null) return new DateAdp(new GregorianCalendar());
|
||||
DateAdp rv = manual;
|
||||
if (autoincrement) manual = rv.Add_minute(1); // simulate passage of manual by increasing manual by 1 minute with each call
|
||||
return rv;
|
||||
}
|
||||
// private static final DateAdp manual_time_dflt = DateAdp_.parse_gplx("2001-01-01 00:00:00.000");
|
||||
// private static DateAdp manual_time;
|
||||
// static boolean Now_enabled() {return now_enabled;} private static boolean now_enabled;
|
||||
// static void Now_enabled_y_() {now_enabled = Bool_.Y; manual_time = manual_time_dflt;}
|
||||
// static void Now_enabled_n_() {now_enabled = Bool_.N; now_freeze = false;}
|
||||
// public static void Now_set(DateAdp date) {now_enabled = true; manual_time = date;}
|
||||
// public static void Now_freeze_y_() {now_freeze = true;}
|
||||
// private static boolean now_freeze;
|
||||
// public static DateAdp Now_time0_add_min(int minutes) {return manual_time_dflt.Add_minute(minutes);}
|
||||
// @gplx.Internal protected static DateAdp Now() {
|
||||
// DateAdp rv = manual_time;
|
||||
// if (!now_freeze) manual_time = rv.Add_minute(1);
|
||||
// return rv;
|
||||
// }
|
||||
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/100_core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/140_dbs"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/150_gfui"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/100_core"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/140_dbs"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/150_gfui"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="lib/jtidy_xowa.jar"/>
|
||||
<classpathentry kind="lib" path="lib/luaj_xowa.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jtidy_xowa.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/luaj_xowa.jar"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
class Dumpdiff_cfg implements Gfo_invk {
|
||||
public Io_url Prv_dir() {return prv_dir;} private Io_url prv_dir;
|
||||
public Io_url Cur_dir() {return cur_dir;} private Io_url cur_dir;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__cur_dir_)) this.cur_dir = m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk__prv_dir_)) this.prv_dir = m.ReadIoUrl("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk__cur_dir_ = "cur_dir_", Invk__prv_dir_ = "prv_dir_";
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Dumpdiff_cmd extends Xob_cmd__base {
|
||||
private final Dumpdiff_cfg cfg = new Dumpdiff_cfg();
|
||||
private final Dumpdiff_mgr mgr = new Dumpdiff_mgr();
|
||||
public Dumpdiff_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
wiki.Init_assert();
|
||||
mgr.Exec(bldr.App(), wiki, cfg);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__cfg)) return cfg;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk__cfg = "cfg";
|
||||
|
||||
public static final String BLDR_CMD_KEY = "hdump.diff";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
public static final Xob_cmd Prototype = new Dumpdiff_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Dumpdiff_cmd(bldr, wiki);}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
import gplx.dbs.*;
|
||||
class Dumpdiff_log_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld__page_id, fld__cur_snip, fld__prv_snip;
|
||||
private Db_stmt stmt__insert;
|
||||
public Dumpdiff_log_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
flds.Add_int_pkey("uid");
|
||||
this.fld__page_id = flds.Add_int("page_id");
|
||||
this.fld__cur_snip = flds.Add_str("cur_snip", 1024);
|
||||
this.fld__prv_snip = flds.Add_str("prv_snip", 1024);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name = "diff_log";
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public void Create_tbl() {
|
||||
conn.Meta_tbl_remake(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, fld__page_id, fld__page_id)));
|
||||
}
|
||||
public void Insert_bgn() {
|
||||
stmt__insert = conn.Stmt_insert(tbl_name, fld__page_id, fld__cur_snip, fld__prv_snip);
|
||||
conn.Txn_bgn("diff_log");
|
||||
}
|
||||
public void Insert_by_batch(int page_id, byte[] prv_snip, byte[] cur_snip) {
|
||||
stmt__insert.Clear().Val_int(fld__page_id, page_id).Val_bry_as_str(fld__cur_snip, cur_snip).Val_bry_as_str(fld__prv_snip, prv_snip).Exec_insert();
|
||||
}
|
||||
public void Insert_end() {
|
||||
conn.Txn_end();
|
||||
stmt__insert.Rls();
|
||||
}
|
||||
public void Rls() {}
|
||||
|
||||
public static Dumpdiff_log_tbl New(Xowe_wiki wiki) {
|
||||
Db_conn conn = Db_conn_bldr.Instance.Get_or_autocreate(true, wiki.Fsys_mgr().Root_dir().GenSubFil("xowa.diff.sqlite3"));
|
||||
Dumpdiff_log_tbl rv = new Dumpdiff_log_tbl(conn);
|
||||
conn.Meta_tbl_remake(rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
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.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
class Dumpdiff_mgr {
|
||||
public void Exec(Xoae_app app, Xowe_wiki wiki, Dumpdiff_cfg cfg) {
|
||||
// init log_tbl, wikis
|
||||
Dumpdiff_log_tbl log_tbl = Dumpdiff_log_tbl.New(wiki);
|
||||
Xowe_wiki cur_wiki = Get_wiki_by_dir(wiki, Bool_.Y, cfg.Cur_dir());
|
||||
Xowe_wiki prv_wiki = Get_wiki_by_dir(wiki, Bool_.N, cfg.Prv_dir());
|
||||
|
||||
// init html_loader, page_loader
|
||||
Hdump_html_loader cur_html_loader = new Hdump_html_loader(cur_wiki);
|
||||
Hdump_html_loader prv_html_loader = new Hdump_html_loader(prv_wiki);
|
||||
Dumpdiff_page_loader page_loader = new Dumpdiff_page_loader(cur_wiki, prv_wiki, 10000);
|
||||
List_adp list = List_adp_.New();
|
||||
|
||||
// prepare for loop
|
||||
int page_count = 0, diff_count = 0;
|
||||
log_tbl.Insert_bgn();
|
||||
|
||||
// loop page_table until no more
|
||||
while (true) {
|
||||
page_loader.Load(list);
|
||||
int list_len = list.Count();
|
||||
if (list_len == 0) break;
|
||||
|
||||
// loop pages, compare, and log
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
Dumpdiff_page_itm page = (Dumpdiff_page_itm)list.Get_at(i);
|
||||
int page_id = page.Page_id();
|
||||
byte[] cur_html = cur_html_loader.Load(page_id, page.Cur_db_id());
|
||||
byte[] prv_html = prv_html_loader.Load(page_id, page.Prv_db_id());
|
||||
byte[][] diff = Bry_diff_.Diff_1st_line(cur_html, prv_html);
|
||||
++page_count;
|
||||
if (diff != null) {
|
||||
log_tbl.Insert_by_batch(page_id, diff[0], diff[1]);
|
||||
++diff_count;
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "hdump diff: pages=~{0} diffs=~{1} page_id=~{2} cur=~{3} prv=~{4}", page_count, diff_count, page_id, diff[0], diff[1]);
|
||||
}
|
||||
}
|
||||
list.Clear();
|
||||
}
|
||||
|
||||
// cleanup
|
||||
log_tbl.Insert_end();
|
||||
}
|
||||
private static Xowe_wiki Get_wiki_by_dir(Xowe_wiki dflt_wiki, boolean wiki_is_cur, Io_url wiki_dir) {
|
||||
Xowe_wiki rv = null;
|
||||
if (wiki_dir == null) {
|
||||
if (wiki_is_cur)
|
||||
rv = dflt_wiki;
|
||||
else
|
||||
throw Err_.new_("", "prv_dir not specified");
|
||||
}
|
||||
if (rv == null)
|
||||
rv = gplx.xowa.addons.bldrs.mass_parses.parses.Xow_wiki_utl_.Clone_wiki(dflt_wiki, wiki_dir);
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
class Dumpdiff_page_itm {
|
||||
public Dumpdiff_page_itm(int page_id, int ns_id, byte[] ttl_bry, int cur_db_id, int prv_db_id) {
|
||||
this.page_id = page_id;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_bry = ttl_bry;
|
||||
this.cur_db_id = cur_db_id;
|
||||
this.prv_db_id = prv_db_id;
|
||||
}
|
||||
public int Page_id() {return page_id;} private final int page_id;
|
||||
public int Ns_id() {return ns_id;} private final int ns_id;
|
||||
public byte[] Ttl_bry() {return ttl_bry;} private final byte[] ttl_bry;
|
||||
public int Cur_db_id() {return cur_db_id;} private final int cur_db_id;
|
||||
public int Prv_db_id() {return prv_db_id;} private final int prv_db_id;
|
||||
}
|
@ -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.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
import gplx.dbs.*;
|
||||
class Dumpdiff_page_loader {
|
||||
private final Db_attach_mgr attach_mgr = new Db_attach_mgr();
|
||||
private int select_count, cutoff_page_id;
|
||||
public Dumpdiff_page_loader(Xowe_wiki cur_wiki, Xowe_wiki prv_wiki, int select_count) {
|
||||
this.select_count = select_count;
|
||||
attach_mgr.Conn_main_(cur_wiki.Data__core_mgr().Db__core().Conn());
|
||||
attach_mgr.Conn_links_(new Db_attach_itm("prv_db", prv_wiki.Data__core_mgr().Db__core().Conn()));
|
||||
}
|
||||
public void Load(List_adp rv) {
|
||||
String sql = String_.Format(String_.Concat_lines_nl_skip_last // ANSI.Y
|
||||
( "SELECT cur.page_id"
|
||||
, ", cur.page_namespace AS ns_id"
|
||||
, ", cur.page_title AS ttl_bry"
|
||||
, ", cur.page_html_db_id AS cur_html_db_id"
|
||||
, ", prv.page_html_db_id AS prv_html_db_id"
|
||||
, "FROM page cur"
|
||||
, " JOIN <prv_db>page prv ON cur.page_id = prv.page_id"
|
||||
, "WHERE cur.page_id > {0}"
|
||||
, "AND cur.page_html_db_id != -1"
|
||||
, "LIMIT {1}"
|
||||
), cutoff_page_id, select_count);
|
||||
sql = attach_mgr.Resolve_sql(sql);
|
||||
|
||||
attach_mgr.Attach();
|
||||
Db_rdr rdr = attach_mgr.Conn_main().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
cutoff_page_id = rdr.Read_int("page_id");
|
||||
rv.Add(new Dumpdiff_page_itm(cutoff_page_id
|
||||
, rdr.Read_int("ns_id"), rdr.Read_bry_by_str("ttl_bry")
|
||||
, rdr.Read_int("cur_html_db_id"), rdr.Read_int("prv_html_db_id")
|
||||
));
|
||||
}
|
||||
attach_mgr.Detach();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.addons.bldrs.hdumps.diffs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.hdumps.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
class Hdump_html_loader {
|
||||
private final Xowe_wiki wiki;
|
||||
private Io_stream_zip_mgr stream_zip_mgr = new Io_stream_zip_mgr();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Xoh_page tmp_hpg = new Xoh_page();
|
||||
private final Xoa_url tmp_url; private final Xoa_ttl tmp_ttl;
|
||||
|
||||
public Hdump_html_loader(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.tmp_url = wiki.Utl__url_parser().Parse(Bry_.new_a7("temp"));
|
||||
this.tmp_ttl = wiki.Ttl_parse(Bry_.new_a7("temp"));
|
||||
}
|
||||
|
||||
public byte[] Load(int page_id, int html_db_id) {
|
||||
// load html_bry from db
|
||||
Xow_db_file html_db = wiki.Data__core_mgr().Dbs__get_by_id_or_fail(html_db_id);
|
||||
tmp_hpg.Ctor_by_hview(wiki, tmp_url, tmp_ttl, page_id);
|
||||
html_db.Tbl__html().Select_by_page(tmp_hpg);
|
||||
|
||||
// unzip it
|
||||
byte[] html_hzip = stream_zip_mgr.Unzip(Io_stream_.Tid_gzip, tmp_hpg.Db().Html().Html_bry());
|
||||
return wiki.Html__hdump_mgr().Load_mgr().Decode_as_bry(tmp_bfr, tmp_hpg, html_hzip, true);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.addons.bldrs.mass_parses.parses; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*;
|
||||
public class Xow_wiki_utl_ {
|
||||
public static Xowe_wiki Clone_wiki(Xowe_wiki wiki, Io_url wiki_dir) {
|
||||
Xol_lang_itm lang = new Xol_lang_itm(wiki.App().Lang_mgr(), wiki.Lang().Key_bry());
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
Xowe_wiki rv = new Xowe_wiki(wiki.Appe(), lang, gplx.xowa.wikis.nss.Xow_ns_mgr_.default_(lang.Case_mgr()), wiki.Domain_itm(), wiki_dir);
|
||||
rv.Init_by_wiki();
|
||||
return rv;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue