1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-09-20 23:43:51 -04:00
parent 5fe27b5b3b
commit fa70c05354
1056 changed files with 8375 additions and 7095 deletions

View 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.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.flds.*; import gplx.ios.*;
public abstract class Xob_idx_base extends Xob_itm_basic_base implements Xob_cmd, GfoInvkAble {
public abstract String Cmd_key();
public Gfo_fld_wtr Fld_wtr() {return fld_wtr;} Gfo_fld_wtr fld_wtr = Gfo_fld_wtr.xowa_();
public Gfo_fld_rdr Fld_rdr() {return fld_rdr;} Gfo_fld_rdr fld_rdr = Gfo_fld_rdr.xowa_();
public Io_url Temp_dir() {return temp_dir;} Io_url temp_dir;
public void Cmd_init(Xob_bldr bldr) {}
public void Cmd_bgn(Xob_bldr bldr) {
temp_dir = wiki.Fsys_mgr().Tmp_dir().GenSubDir(this.Cmd_key());
Io_mgr.I.DeleteDirDeep(temp_dir);
Cmd_bgn_hook();
}
public abstract void Cmd_bgn_hook();
public abstract void Cmd_run();
@gplx.Virtual public void Cmd_end() {}
public void Cmd_term() {}
public Io_line_rdr rdr_(Io_url dir) {
Io_url[] fils = Io_mgr.I.QueryDir_fils(dir);
return new Io_line_rdr(bldr.Usr_dlg(), fils).Key_gen_(Io_line_rdr_key_gen_.first_pipe);
}
}

View File

@@ -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.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
public abstract class Xob_itm_basic_base implements GfoInvkAble {
protected Xoae_app app; protected Xob_bldr bldr; protected Xowe_wiki wiki; protected Gfo_usr_dlg usr_dlg;
public void Cmd_ctor(Xob_bldr bldr, Xowe_wiki wiki) {this.bldr = bldr; this.wiki = wiki; this.app = bldr.App(); usr_dlg = bldr.Usr_dlg(); this.Cmd_ctor_end(bldr, wiki);}
@gplx.Virtual protected void Cmd_ctor_end(Xob_bldr bldr, Xowe_wiki wiki) {
}
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_owner)) return bldr.Cmd_mgr();
else return GfoInvkAble_.Rv_unhandled;
} private static final String Invk_owner = "owner";
}

View File

@@ -0,0 +1,55 @@
/*
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.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.xowa.apps.*;
public abstract class Xob_itm_dump_base extends Xob_itm_basic_base {
protected int sort_mem_len = Int_.Neg1, dump_fil_len = Int_.Neg1, make_fil_len = Int_.Neg1;
public Io_url Temp_dir() {return temp_dir;}
public boolean Delete_temp() {return delete_temp;} protected boolean delete_temp = true;
protected Io_url temp_dir, make_dir;
protected Bry_bfr dump_bfr;
public int Make_fil_len() {return make_fil_len;} public void Make_fil_len_(int v) {make_fil_len = v;}
public Io_url_gen Dump_url_gen() {return dump_url_gen;} protected Io_url_gen dump_url_gen;
public void Init_dump(String tmp_dir_key) {Init_dump(tmp_dir_key, null);}
public void Init_dump(String tmp_dir_key, Io_url make_dir_val) {
if (sort_mem_len == Int_.Neg1) sort_mem_len = bldr.Sort_mem_len();
if (dump_fil_len == Int_.Neg1) dump_fil_len = bldr.Dump_fil_len();
if (make_fil_len == Int_.Neg1) make_fil_len = bldr.Make_fil_len();
dump_bfr = Bry_bfr.new_(dump_fil_len);
temp_dir = wiki.Fsys_mgr().Tmp_dir().GenSubDir(tmp_dir_key);
if (make_dir_val == null) make_dir = temp_dir.GenSubDir("make");
else make_dir = make_dir_val;
Io_mgr.I.DeleteDirDeep_ary(temp_dir, make_dir);
dump_url_gen = Io_url_gen_.dir_(temp_dir.GenSubDir("dump"));
}
@gplx.Virtual public void Term_dump(Io_sort_cmd make_cmd) {
Io_mgr.I.AppendFilBfr(dump_url_gen.Nxt_url(), dump_bfr); dump_bfr.Rls();
Xobdc_merger.Basic(bldr.Usr_dlg(), dump_url_gen, temp_dir.GenSubDir("sort"), sort_mem_len, Io_line_rdr_key_gen_.first_pipe, make_cmd);
}
protected void Flush_dump() {Io_mgr.I.AppendFilBfr(dump_url_gen.Nxt_url(), dump_bfr);}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_sort_mem_len_)) sort_mem_len = gplx.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_dump_fil_len_)) dump_fil_len = gplx.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_make_fil_len_)) make_fil_len = gplx.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_delete_temp_)) delete_temp = m.ReadBool("v");
else return super.Invk(ctx, ikey, k, m);
return this;
}
public static final String Invk_sort_mem_len_ = "sort_mem_len_", Invk_dump_fil_len_ = "dump_fil_len_", Invk_make_fil_len_ = "make_fil_len_", Invk_delete_temp_ = "delete_temp_";
}

View File

@@ -0,0 +1,60 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.flds.*; import gplx.ios.*; import gplx.xowa.tdbs.*;
import gplx.xowa.bldrs.sqls.*; import gplx.xowa.tdbs.bldrs.*;
public abstract class Xob_sql_dump_base extends Xob_itm_dump_base implements Xob_cmd, GfoInvkAble {
private final Sql_file_parser parser = new Sql_file_parser(); private boolean fail = false;
public abstract String Cmd_key();
public Io_url Src_fil() {return src_fil;} private Io_url src_fil;
public Io_url_gen Make_url_gen() {return make_url_gen;} private Io_url_gen make_url_gen;
public abstract String Sql_file_name();
public void Cmd_init(Xob_bldr bldr) {}
public void Cmd_bgn(Xob_bldr bldr) {
this.Init_dump(this.Cmd_key());
make_url_gen = Io_url_gen_.dir_(temp_dir.GenSubDir("make"));
if (src_fil == null) {
src_fil = Xotdb_fsys_mgr.Find_file_or_null(wiki.Fsys_mgr().Root_dir(), "*" + Sql_file_name() + "*", ".gz", ".sql");
if (src_fil == null) {
String msg = String_.Format(".sql file not found in dir.\nPlease download the file for your wiki from dumps.wikimedia.org.\nfile={0} dir={1}", Sql_file_name(), wiki.Fsys_mgr().Root_dir());
app.Usr_dlg().Warn_many("", "", msg);
app.Gui_mgr().Kit().Ask_ok("", "", msg);
fail = true;
return;
}
}
parser.Src_fil_(src_fil).Trg_fil_gen_(dump_url_gen);
Cmd_bgn_hook(bldr, parser);
} protected Gfo_fld_wtr fld_wtr = Gfo_fld_wtr.xowa_();
public abstract void Cmd_bgn_hook(Xob_bldr bldr, Sql_file_parser parser);
public void Cmd_run() {
if (fail) return;
parser.Parse(bldr.Usr_dlg());
}
@gplx.Virtual public void Cmd_end() {
if (fail) return;
Xobdc_merger.Basic(bldr.Usr_dlg(), dump_url_gen, temp_dir.GenSubDir("sort"), sort_mem_len, Io_line_rdr_key_gen_all._, new Io_sort_fil_basic(bldr.Usr_dlg(), make_url_gen, make_fil_len));
}
public void Cmd_term() {}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_src_fil_)) src_fil = m.ReadIoUrl("v");
else return super.Invk(ctx, ikey, k, m);
return this;
}
public static final String Invk_src_fil_ = "src_fil_";
}