1
0
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:
gnosygnu
2015-11-01 20:50:05 -05:00
parent 4f43f51b18
commit b990ec409f
858 changed files with 6758 additions and 4187 deletions

View File

@@ -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.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.ios.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.core.ios.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_base_fxt {
public Xob_base_fxt Clear() {
if (app == null) {

View File

@@ -87,9 +87,9 @@ public class Xob_bldr implements GfoInvkAble {
if (ctx.Match(k, Invk_pause_at_end_)) pause_at_end = m.ReadBoolOrTrue("val");
else if (ctx.Match(k, Invk_cmds)) return cmd_mgr;
else if (ctx.Match(k, Invk_wiki_cfg_bldr)) return wiki_cfg_bldr;
else 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_sort_mem_len_)) sort_mem_len = gplx.core.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_dump_fil_len_)) dump_fil_len = gplx.core.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_make_fil_len_)) make_fil_len = gplx.core.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_run)) Run();
else if (ctx.Match(k, Invk_cancel)) Cancel();
else return GfoInvkAble_.Rv_unhandled;

View File

@@ -19,7 +19,7 @@ package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.core.primitives.*;
import gplx.xowa.wikis.*; import gplx.xowa.xtns.wdatas.imports.*;
import gplx.xowa.bldrs.cmds.texts.*; import gplx.xowa.bldrs.cmds.texts.sqls.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*; import gplx.xowa.bldrs.cmds.files.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.bldrs.cmds.utils.*; import gplx.xowa.bldrs.cmds.wikis.*;
import gplx.xowa.files.origs.*; import gplx.xowa.htmls.hdumps.bldrs.*;
import gplx.xowa.files.origs.*; import gplx.xowa.htmls.core.bldrs.*;
public class Xob_cmd_mgr implements GfoInvkAble {
public Xob_cmd_mgr(Xob_bldr bldr) {this.bldr = bldr;} private Xob_bldr bldr;
public void Clear() {list.Clear(); dump_rdrs.Clear();}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.core.tests.*;
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*;
import gplx.core.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*;
public class Xob_fxt {
public Xob_fxt Ctor_mem() {
Io_mgr.Instance.InitEngine_mem();

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.core.consoles.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.parsers.tmpls.*;
public class Xobd_rdr implements Xob_cmd {
@@ -40,14 +40,14 @@ public class Xobd_rdr implements Xob_cmd {
long fil_len = 0;
Gfo_usr_dlg usr_dlg = bldr.App().Usr_dlg();
try {
gplx.ios.Io_stream_rdr src_rdr = wiki.Import_cfg().Src_rdr();
gplx.core.ios.Io_stream_rdr src_rdr = wiki.Import_cfg().Src_rdr();
fil = Io_buffer_rdr.new_(src_rdr, optRdrBfrSize);
fil_len = fil.Fil_len();
if (src_rdr.Tid() == gplx.ios.Io_stream_.Tid_bzip2) fil_len = (fil_len * 100) / 18; // HACK: no way to get actual file progress; assume 18% compression
if (src_rdr.Tid() == gplx.core.ios.Io_stream_.Tid_bzip2) fil_len = (fil_len * 100) / 18; // HACK: no way to get actual file progress; assume 18% compression
// fil.Seek(bldr.Opts().ResumeAt());
int prv_pos = 0;
while (true) {
int cur_pos = parser.Parse_page(page, usr_dlg, fil, fil.Bfr(), prv_pos, ns_mgr); if (cur_pos == Bry_.NotFound) break;
int cur_pos = parser.Parse_page(page, usr_dlg, fil, fil.Bfr(), prv_pos, ns_mgr); if (cur_pos == Bry_find_.Not_found) break;
if (cur_pos < prv_pos)
bldr.Print_prog_msg(fil.Fil_pos(), fil_len, 1, optRdrFillFmt, Int_.To_str_pad_bgn_zero((int)(fil.Fil_pos() / Io_mgr.Len_mb), Int_.DigitCount((int)(fil.Fil_len() / Io_mgr.Len_mb))), "", String_.new_u8(page.Ttl_full_db()));
prv_pos = cur_pos;

View File

@@ -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.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.ios.*; import gplx.lists.*;
import gplx.core.ios.*; import gplx.lists.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.bldrs.wtrs.*;
public class Xobdc_merger {

View File

@@ -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.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.ios.*; import gplx.lists.*;
import gplx.core.ios.*; import gplx.lists.*;
import gplx.xowa.wikis.tdbs.*;
class Io_sort_filCmd_reg implements Io_sort_filCmd { // 123|bgn|end|1
public Io_sort_filCmd_reg() {}
@@ -38,7 +38,7 @@ class Io_sort_filCmd_reg implements Io_sort_filCmd { // 123|bgn|end|1
Io_mgr.Instance.SaveFilBry(fil, bfr.Bfr(), bfr.Len());
} private Bry_bfr bfr = Bry_bfr.new_(); int fil_idx = 0; int itm_count = 0;
}
class Io_url_gen_nest implements gplx.ios.Io_url_gen {
class Io_url_gen_nest implements gplx.core.ios.Io_url_gen {
public Io_url Cur_url() {return cur_url;} Io_url cur_url;
public Io_url Nxt_url() {cur_url = Xotdb_fsys_mgr.Url_fil(root_dir, fil_idx++, ext); return cur_url;}
public Io_url[] Prv_urls() {

View File

@@ -110,7 +110,7 @@ public class Xob_wiki_cfg_bldr_tst {
, "</api>"
));
String[] wikis = new String[] {"en.wikipedia.org"}; String protocol = "mem/";
Tfds.Eq_str_lines(Query_ns(protocol, gplx.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
Tfds.Eq_str_lines(Query_ns(protocol, gplx.core.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
( "app.bldr.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
, "4|WP"
, "5|WT"
@@ -129,12 +129,12 @@ public class Xob_wiki_cfg_bldr_tst {
String api = protocol + wiki + "/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases";
String xml = String_.new_u8(Io_mgr.Instance.DownloadFil_args("", null).Trg_engine_key_(trg_engine_key).Exec_as_bry(api));
if (xml == null) continue; // not found
gplx.xmls.XmlDoc xdoc = gplx.xmls.XmlDoc_.parse(xml);
gplx.xmls.XmlNde xnde = gplx.xmls.Xpath_.SelectFirst(xdoc.Root(), "query/namespacealiases");
gplx.langs.xmls.XmlDoc xdoc = gplx.langs.xmls.XmlDoc_.parse(xml);
gplx.langs.xmls.XmlNde xnde = gplx.langs.xmls.Xpath_.SelectFirst(xdoc.Root(), "query/namespacealiases");
sb.Add("app.bldr.wiki_cfg_bldr.get('").Add(wiki).Add("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
int xndes_len = xnde.SubNdes().Count();
for (int j = 0; j < xndes_len; j++) {
gplx.xmls.XmlNde ns_nde = xnde.SubNdes().Get_at(j);
gplx.langs.xmls.XmlNde ns_nde = xnde.SubNdes().Get_at(j);
if (!String_.Eq(ns_nde.Name(), "ns")) continue;
int id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
String name = String_.Replace(String_.Replace(ns_nde.Text_inner(), " ", "_"), "'", "''");

View File

@@ -274,7 +274,7 @@ class Xob_dump_bmk_mgr {
private void Save_itm(Bry_bfr save_bfr, String key, int val) {
String fmt = "{0}('{1}');\n";
String str = String_.Format(fmt, key, val);
save_bfr.Add_str(str);
save_bfr.Add_str_u8(str);
}
}
class Xob_rate_mgr {
@@ -297,7 +297,7 @@ class Xob_rate_mgr {
int dif = (int)(end - bgn) / 1000;
Decimal_adp rate = Decimal_adp_.divide_safe_(count, dif);
save_bfr
.Add_str(rate.To_str("#,##0.000")).Add_byte_pipe()
.Add_str_a7(rate.To_str("#,##0.000")).Add_byte_pipe()
.Add_int_variable(count).Add_byte_pipe()
.Add_int_variable(dif).Add_byte_nl()
;

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.bldrs.*;
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.bldrs.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.bldrs.wtrs.*;
public class Xob_category_registry_sql implements Xob_cmd {

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.nss.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.core.encoders.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.nss.*;
public class Xob_category_registry_sql_tst {
@Before public void init() {if (Xoa_test_.Db_skip()) return; fxt.Clear();} private Xob_category_registry_sql_fxt fxt = new Xob_category_registry_sql_fxt();
@After public void term() {if (Xoa_test_.Db_skip()) return; fxt.Rls();}
@@ -59,7 +59,7 @@ class Xob_category_registry_sql_fxt {
String line = lines[i];
if (String_.Len_eq_0(line)) break; // ignore blank line
String[] flds = String_.Split(line, '|');
list.Add(Base85_utl.XtoIntByStr(flds[1]));
list.Add(Base85_.To_int_by_str(flds[1]));
}
return (int[])list.To_ary_and_clear(int.class);
}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.brys.*; import gplx.ios.*; import gplx.xowa.wikis.ctgs.*;
import gplx.core.brys.*; import gplx.core.ios.*; import gplx.xowa.wikis.ctgs.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implements Sql_file_parser_cmd {
private DateAdp_parser date_parser = DateAdp_parser.new_(); private Sql_file_parser sql_parser; Uca_trie trie; private Bry_bfr uca_bfr = Bry_bfr.reset_(255);
@@ -38,7 +38,7 @@ public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implement
}
else if (Bry_.Eq(fld_key, Fld_cl_sortkey)) {
int nl_pos = Bry_find_.Find_fwd(src, Byte_ascii.Nl, fld_bgn, fld_end);
if (nl_pos != Bry_.NotFound) // sortkey sometimes has format of "sortkey\ntitle"; EX: "WALES, JIMMY\nJIMMY WALES"; discard 2nd to conserve hard-disk space
if (nl_pos != Bry_find_.Not_found) // sortkey sometimes has format of "sortkey\ntitle"; EX: "WALES, JIMMY\nJIMMY WALES"; discard 2nd to conserve hard-disk space
fld_end = nl_pos;
cur_sortkey = Bry_.Mid(src, fld_bgn, fld_end);
}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.sqls.*;
public class Xob_categorylinks_sql extends Xob_categorylinks_base {
private Db_idx_mode idx_mode = Db_idx_mode.Itm_end;

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.flds.*; import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.ctgs.*;
import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.encoders.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.ctgs.*;
import gplx.xowa.bldrs.sqls.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_categorylinks_sql_make implements Io_make_cmd {
@@ -118,7 +118,7 @@ public class Xob_categorylinks_sql_make implements Io_make_cmd {
while (true) {
int compare = Bry_.Compare(ttl, 0, ttl.length, name_id_rdr.Bfr(), name_id_rdr.Key_pos_bgn(), name_id_rdr.Key_pos_end());
switch (compare) {
case CompareAble_.Same: return Base85_utl.XtoIntByAry(name_id_rdr.Bfr(), name_id_rdr.Key_pos_end() + 1, name_id_rdr.Itm_pos_end() - 2);
case CompareAble_.Same: return Base85_.To_int_by_bry(name_id_rdr.Bfr(), name_id_rdr.Key_pos_end() + 1, name_id_rdr.Itm_pos_end() - 2);
case CompareAble_.More:
boolean reading = name_id_rdr.Read_next();
if (!reading) return Cur_cat_id_null; // eof return

View File

@@ -127,7 +127,7 @@ class Db_tst_qry {
}
if (!pass) {
bfr.Add(Lbl_row_hdr).Add_int_variable(expd_row_idx).Add_byte_nl();
bfr.Add_str(qry.Xto_sql()).Add_byte(Byte_ascii.Semic);
bfr.Add_str_u8(qry.Xto_sql()).Add_byte(Byte_ascii.Semic);
throw Err_.new_wo_type(bfr.To_str_and_clear());
}
} static final byte[] Lbl_row_hdr = Bry_.new_a7("row: "), Lbl_eq_y = Bry_.new_a7(" == "), Lbl_eq_n = Bry_.new_a7(" != ");

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.sqls.*;
public class Xob_categorylinks_txt extends Xob_categorylinks_base {
public Xob_categorylinks_txt(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.make_fil_len = Io_mgr.Len_mb;}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.xowa.wikis.tdbs.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.xowa.wikis.tdbs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.bldrs.*;
import gplx.xowa.wikis.nss.*;

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import org.junit.*; import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_ctg_v1_base_tst {
Xowd_page_wkr_ctg_fxt fxt = new Xowd_page_wkr_ctg_fxt();
@Test public void One() {fxt.ini_("[[Category:A]]").tst_("A");}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.flds.*; import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.ctgs.*;
import gplx.core.flds.*; import gplx.core.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.ctgs.*;
import gplx.xowa.bldrs.wtrs.*;
public class Xob_ctg_v1_sql extends Xob_ctg_v1_base {
@Override public String Wkr_key() {return Xob_cmd_keys.Key_text_cat_core_v1;}
@@ -34,7 +34,7 @@ class Xob_ctg_v1_sql_make implements Io_make_cmd {
Io_url sql_url = wiki.Fsys_mgr().Root_dir().GenSubFil(Url_sql);
Io_mgr.Instance.DeleteFil_args(sql_url).MissingFails_off().Exec();
sql_wtr = Xob_tmp_wtr.new_wo_ns_(Io_url_gen_.fil_(sql_url), Io_mgr.Len_mb);
sql_wtr.Bfr().Add_str(Xob_categorylinks_sql.Sql_categorylinks).Add(Sql_hdr);
sql_wtr.Bfr().Add_str_u8(Xob_categorylinks_sql.Sql_categorylinks).Add(Sql_hdr);
}
public void Sort_do(Io_line_rdr rdr) {
if (page_count++ % progress_interval == 0) usr_dlg.Prog_many("", "", "building category; count=~{0}", page_count);

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.cmds.texts.tdbs.*;
public class Xob_ctg_v1_txt extends Xob_ctg_v1_base {
@Override public String Wkr_key() {return Xob_cmd_keys.Key_tdb_make_category;}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
interface Xob_sql_join_wkr {
Io_line_rdr New_main_rdr();
Io_line_rdr New_join_rdr();

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
public abstract class Xoctg_hiddencat_parser_base extends Xob_sql_dump_base implements Sql_file_parser_cmd {
public Xoctg_hiddencat_parser_base Ctor(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.make_fil_len = Io_mgr.Len_mb; return this;}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.sqls.*;
public class Xoctg_hiddencat_parser_txt extends Xoctg_hiddencat_parser_base {
public Xoctg_hiddencat_parser_txt(Xob_bldr bldr, Xowe_wiki wiki) {this.Ctor(bldr, wiki);}

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*; import gplx.xowa.wikis.tdbs.*;
import gplx.core.ios.*; import gplx.xowa.wikis.tdbs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xoctg_hiddencat_ttl_wkr extends Xob_itm_dump_base implements Xob_cmd, GfoInvkAble {
public Xoctg_hiddencat_ttl_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.make_fil_len = Io_mgr.Len_mb;} private Xob_sql_join_wkr_ctg_hidden join_wkr;
@@ -59,7 +59,7 @@ class Xob_sql_join_wkr_ctg_hidden implements Xob_sql_join_wkr {
byte[] src = join.Bfr();
int itm_end = join.Itm_pos_end();
int pipe_pos = Bry_find_.Find_bwd(src, Byte_ascii.Pipe, itm_end);
if (pipe_pos == Bry_.NotFound) throw Err_.new_wo_type("failed to find pipe for name", "excerpt", String_.new_u8(src, join.Itm_pos_bgn(), join.Itm_pos_end()));
if (pipe_pos == Bry_find_.Not_found) throw Err_.new_wo_type("failed to find pipe for name", "excerpt", String_.new_u8(src, join.Itm_pos_bgn(), join.Itm_pos_end()));
file_bfr.Add_mid(src, pipe_pos + 1, itm_end - 1).Add_byte_pipe();
file_bfr.Add(key_bry).Add_byte_nl();
} private Bry_bfr file_bfr = Bry_bfr.new_();

View File

@@ -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.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.flds.*; import gplx.ios.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.tdbs.*;
import gplx.core.flds.*; import gplx.core.ios.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.tdbs.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*;
public class Xoctg_link_idx_wkr extends Xob_idx_base { // NOTE: similar functionality to Xob_make_cmd_site, but more complicated due to p,f,s; not inheriting
Io_url src_link_dir; int make_fil_max = Int_.Min_value;

View File

@@ -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.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.primitives.*; import gplx.ios.*;
import gplx.core.primitives.*; import gplx.core.ios.*;
import gplx.fsdb.meta.*;
class Xob_bin_db_mgr {
private final int[] ns_ids; private final int ns_ids_len;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.dbs.engines.sqlite.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.dbs.*; import gplx.fsdb.*; import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.dbs.*; import gplx.fsdb.*; import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.fsdb.*;
import gplx.fsdb.data.*; import gplx.fsdb.meta.*;
public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {

View File

@@ -21,14 +21,14 @@ import gplx.xowa.files.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.parsers.xndes.*;
import gplx.xowa.htmls.hdumps.bldrs.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.htmls.core.bldrs.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.wdatas.*;
import gplx.fsdb.meta.*; import gplx.xowa.files.fsdb.*; import gplx.fsdb.*;
import gplx.xowa.langs.vnts.*; import gplx.xowa.parsers.vnts.*;
public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink_logger {
private Xob_lnki_temp_tbl tbl; private boolean wdata_enabled = true, xtn_ref_enabled = true, gen_html, gen_hdump;
private Xop_log_invoke_wkr invoke_wkr; private Xop_log_property_wkr property_wkr;
private boolean ns_file_is_case_match_all = true; private Xowe_wiki commons_wiki;
private Xob_hdump_bldr hdump_bldr; private Xob_link_dump_cmd link_dump_cmd; private boolean hzip_enabled = false;
private Xob_hdump_mgr hdump_bldr; private Xob_link_dump_cmd link_dump_cmd; private boolean hzip_enabled = false;
private Vnt_convert_lang converter_lang;
public Xob_lnki_temp_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@Override public String Cmd_key() {return Xob_cmd_keys.Key_file_lnki_temp;}
@@ -86,7 +86,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
Fsm_mnt_mgr.Patch(trg_mnt_mgr.Mnts__get_main().Cfg_mgr().Tbl()); // NOTE: see fsdb_make; DATE:2014-04-26
if (gen_hdump) {
gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import import_cfg = wiki.Appe().Api_root().Bldr().Wiki().Import();
hdump_bldr = new Xob_hdump_bldr(wiki.Ns_mgr(), wiki.Db_mgr_as_sql(), tbl.Conn(), import_cfg.Html_db_max(), hzip_enabled);
hdump_bldr = new Xob_hdump_mgr(wiki, tbl.Conn(), import_cfg.Html_db_max(), import_cfg.Zip_tid_html(), hzip_enabled);
link_dump_cmd = new Xob_link_dump_cmd();
link_dump_cmd.Init_by_wiki(wiki);
}
@@ -114,7 +114,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
}
if (gen_hdump) {
page.Root_(root);
hdump_bldr.Insert_page(page);
hdump_bldr.Insert(page);
link_dump_cmd.Page_bgn(page.Revision_data().Id());
List_adp lnki_list = page.Redlink_lnki_list().Lnki_list();
int len = lnki_list.Count();
@@ -192,39 +192,5 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
byte[] rv = ttl.Page_db();
return Bry_.Eq(rv, ttl_bry) ? null : rv;
}
public static boolean Ns_file_is_case_match_all(Xow_wiki wiki) {return wiki.Ns_mgr().Ns_file().Case_match() == Xow_ns_case_.Id_all;}
}
class Xob_lnki_temp_wkr_ {
public static int[] Ns_ids_by_aliases(Xowe_wiki wiki, String[] aliases) {
int[] rv = Xob_lnki_temp_wkr_.Ids_by_aliases(wiki.Ns_mgr(), aliases);
int aliases_len = aliases.length;
int ids_len = rv.length;
for (int i = 0; i < aliases_len; i++) {
String alias = aliases[i];
int id = i < ids_len ? rv[i] : -1;
wiki.Appe().Usr_dlg().Note_many("", "", "ns: ~{0} <- ~{1}", Int_.To_str_fmt(id, "0000"), alias);
}
if (aliases_len != ids_len) throw Err_.new_wo_type("mismatch in aliases and ids", "aliases", aliases_len, "ids", ids_len);
return rv;
}
private static int[] Ids_by_aliases(Xow_ns_mgr ns_mgr, String[] aliases) {
List_adp list = List_adp_.new_();
int len = aliases.length;
for (int i = 0; i < len; i++) {
String alias = aliases[i];
if (String_.Eq(alias, Xow_ns_.Key_main))
list.Add(ns_mgr.Ns_main());
else {
Xow_ns ns = ns_mgr.Names_get_or_null(Bry_.new_u8(alias));
if (ns != null)
list.Add(ns);
}
}
len = list.Count();
int[] rv = new int[len];
for (int i = 0; i < len; i++) {
rv[i] = ((Xow_ns)list.Get_at(i)).Id();
}
return rv;
}
public static boolean Ns_file_is_case_match_all(Xow_wiki wiki) {return wiki.Ns_mgr().Ns_file().Case_match() == Xow_ns_case_.Tid__all;}
}

View File

@@ -0,0 +1,53 @@
/*
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.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.xowa.wikis.nss.*;
class Xob_lnki_temp_wkr_ {
public static int[] Ns_ids_by_aliases(Xowe_wiki wiki, String[] aliases) {
int[] rv = Xob_lnki_temp_wkr_.Ids_by_aliases(wiki.Ns_mgr(), aliases);
int aliases_len = aliases.length;
int ids_len = rv.length;
for (int i = 0; i < aliases_len; i++) {
String alias = aliases[i];
int id = i < ids_len ? rv[i] : -1;
wiki.Appe().Usr_dlg().Note_many("", "", "ns: ~{0} <- ~{1}", Int_.To_str_fmt(id, "0000"), alias);
}
if (aliases_len != ids_len) throw Err_.new_wo_type("mismatch in aliases and ids", "aliases", aliases_len, "ids", ids_len);
return rv;
}
private static int[] Ids_by_aliases(Xow_ns_mgr ns_mgr, String[] aliases) {
List_adp list = List_adp_.new_();
int len = aliases.length;
for (int i = 0; i < len; i++) {
String alias = aliases[i];
if (String_.Eq(alias, Xow_ns_.Key_main))
list.Add(ns_mgr.Ns_main());
else {
Xow_ns ns = ns_mgr.Names_get_or_null(Bry_.new_u8(alias));
if (ns != null)
list.Add(ns);
}
}
len = list.Count();
int[] rv = new int[len];
for (int i = 0; i < len; i++) {
rv[i] = ((Xow_ns)list.Get_at(i)).Id();
}
return rv;
}
}

View File

@@ -53,7 +53,7 @@ class Xob_orig_regy_tbl {
}
private static void Create_data_for_repo(Gfo_usr_dlg usr_dlg, Db_conn conn, Xowe_wiki local_wiki, byte repo_tid, Io_url join) {
usr_dlg.Note_many("", "", "inserting page for xowa.wiki.image: ~{0}", join.OwnerDir().NameOnly());
boolean wiki_has_cs_file = repo_tid == Xof_repo_itm_.Repo_remote && local_wiki.Ns_mgr().Ns_file().Case_match() == Xow_ns_case_.Id_all;
boolean wiki_has_cs_file = repo_tid == Xof_repo_itm_.Repo_remote && local_wiki.Ns_mgr().Ns_file().Case_match() == Xow_ns_case_.Tid__all;
String lnki_ttl_fld = wiki_has_cs_file ? "Coalesce(o.lnki_commons_ttl, o.lnki_ttl)" : "o.lnki_ttl"; // NOTE: use lnki_commons_ttl if [[File]] is cs PAGE:en.d:water EX:[[image:wikiquote-logo.png|50px|none|alt=]]; DATE:2014-09-05
if (wiki_has_cs_file)
Sqlite_engine_.Idx_create(usr_dlg, conn, "orig_regy", Idx_ttl_remote);

View File

@@ -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.bldrs.cmds.texts; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.xowa.xtns.wdatas.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*;
import gplx.xowa.bldrs.css.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.xtns.wdatas.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.cmds.texts.xmls.*;
import gplx.xowa.bldrs.css.*; import gplx.xowa.wikis.domains.*;
public abstract class Xob_init_base implements Xob_cmd, GfoInvkAble {
private Xob_bldr bldr; private Xowe_wiki wiki; private Gfo_usr_dlg usr_dlg;
private byte wbase_enabled = Bool_.__byte;
@@ -34,10 +33,8 @@ public abstract class Xob_init_base implements Xob_cmd, GfoInvkAble {
}
public void Cmd_bgn(Xob_bldr bldr) {}
public void Cmd_run() { // parse site_info
gplx.ios.Io_stream_rdr src_rdr = wiki.Import_cfg().Src_rdr();
usr_dlg.Plog_many("", "", "reading dump header: ~{0}", src_rdr.Url().Raw());
byte[] siteinfo_xml = Xob_siteinfo_parser.Siteinfo_extract(src_rdr);
Xob_siteinfo_parser.Siteinfo_parse(wiki, usr_dlg, String_.new_u8(siteinfo_xml));
gplx.core.ios.Io_stream_rdr src_rdr = wiki.Import_cfg().Src_rdr(); usr_dlg.Plog_many("", "", "reading dump header: ~{0}", src_rdr.Url().Raw());
Xob_siteinfo_parser_.Parse(Xob_siteinfo_parser_.Extract(src_rdr), wiki);
this.Cmd_run_end(wiki); // save site info
}
public void Cmd_end() {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.bldrs.cmds.texts; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.primitives.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.wtrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.langs.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*;

View File

@@ -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.bldrs.cmds.texts.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.dbs.*; import gplx.ios.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.wikis.*;
import gplx.dbs.*; import gplx.core.ios.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.wikis.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.dbs.*;

View File

@@ -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.bldrs.cmds.texts.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.ios.*;
import gplx.core.ios.*; import gplx.core.encoders.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.langs.*;
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
@@ -25,7 +25,7 @@ public class Xob_search_sql_wkr extends Xob_search_base implements Io_make_cmd {
private int search_id = 0; private byte[] prv_word = Bry_.Empty; private int page_count;
public Xob_search_sql_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@Override public String Wkr_key() {return Xob_cmd_keys.Key_text_search_wkr;}
@Override public gplx.ios.Io_make_cmd Make_cmd_site() {return this;}
@Override public gplx.core.ios.Io_make_cmd Make_cmd_site() {return this;}
public Io_sort_cmd Make_dir_(Io_url v) {return this;} // noop
public void Sort_bgn() {
this.usr_dlg = Xoa_app_.Usr_dlg();
@@ -43,7 +43,7 @@ public class Xob_search_sql_wkr extends Xob_search_base implements Io_make_cmd {
prv_word = cur_word;
page_count = 0;
}
search_page_tbl.Insert_cmd_by_batch(search_id, Base85_utl.XtoIntByAry(bry, rdr.Key_pos_end() + 1, rdr.Key_pos_end() + 5)); // -1: ignore rdr_dlm
search_page_tbl.Insert_cmd_by_batch(search_id, Base85_.To_int_by_bry(bry, rdr.Key_pos_end() + 1, rdr.Key_pos_end() + 5)); // -1: ignore rdr_dlm
++page_count;
if (search_id % 10000 == 0)
usr_dlg.Prog_many("", "", "creating title index: count=~{0}", search_id);

View File

@@ -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.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.xdats.*;
public class Io_sort_cmd_ns implements Io_make_cmd {
Xob_xdat_file_wtr fil_wtr; Bry_bfr reg_bfr = Bry_bfr.new_(), key_bfr_0 = Bry_bfr.new_(512), key_bfr_n = Bry_bfr.new_(512);

View File

@@ -56,14 +56,14 @@ public class Xob_calc_stats_cmd extends Xob_itm_basic_base implements Xob_cmd {
}
private void Gen_call(boolean first, Bry_bfr bfr, String key, Object... vals) {
if (!first) bfr.Add_byte(Byte_ascii.Dot);
bfr.Add_str(key);
bfr.Add_str_u8(key);
int len = vals.length;
if (len > 0) {
bfr.Add_byte(Byte_ascii.Paren_bgn);
for (int i = 0; i < len; i++) {
if (i != 0) bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space);
Object val = vals[i];
bfr.Add_str(Object_.Xto_str_strict_or_null_mark(val));
bfr.Add_str_u8(Object_.Xto_str_strict_or_null_mark(val));
}
bfr.Add_byte(Byte_ascii.Paren_end);
}

View File

@@ -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.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.xdats.*;
public class Xob_make_cmd_site implements Io_make_cmd {
Xob_xdat_file_wtr fil_wtr; Bry_bfr cur_bfr = Bry_bfr.new_(), reg_bfr = Bry_bfr.new_(), reg_key_0 = Bry_bfr.new_(512), reg_key_n = Bry_bfr.new_(512);

View File

@@ -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.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.ios.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.core.ios.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_make_id_wkr extends Xob_itm_dump_base implements Xobd_wkr, GfoInvkAble {
public Xob_make_id_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}

View File

@@ -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.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.wtrs.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.parsers.utils.*;
@@ -85,8 +85,8 @@ public class Xob_page_txt extends Xob_itm_dump_base implements Xobd_wkr, GfoInvk
}
}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_page_file_len_)) page_file_len = gplx.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_title_file_len_)) title_file_len = gplx.ios.Io_size_.Load_int_(m);
if (ctx.Match(k, Invk_page_file_len_)) page_file_len = gplx.core.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_title_file_len_)) title_file_len = gplx.core.ios.Io_size_.Load_int_(m);
else return super.Invk(ctx, ikey, k, m);
return this;
} private static final String Invk_page_file_len_ = "page_file_len_", Invk_title_file_len_ = "title_file_len_";

View File

@@ -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.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_parse_dump_templates_cmd extends Xob_itm_dump_base implements Xobd_wkr, GfoInvkAble {
public Xob_parse_dump_templates_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}

View File

@@ -19,7 +19,7 @@ package gplx.xowa.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; impo
public class Xob_search_tdb extends Xob_search_base {
public Xob_search_tdb(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@Override public String Wkr_key() {return Xob_cmd_keys.Key_tdb_make_search_title;}
@Override public gplx.ios.Io_make_cmd Make_cmd_site() {
@Override public gplx.core.ios.Io_make_cmd Make_cmd_site() {
return new Xob_make_cmd_site(bldr.Usr_dlg(), this.make_dir, this.make_fil_len);
}
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import org.junit.*;
import gplx.ios.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.core.ios.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.wikis.nss.*;
public class Xob_tst {
@Before public void init() {fxt = new Xob_fxt().Ctor_mem();} private Xob_fxt fxt;
@@ -175,7 +175,7 @@ public class Xob_tst {
Io_mgr.Instance.SaveFilStr(url, raw);
Xotdb_page_raw_parser parser = new Xotdb_page_raw_parser();
Xowe_wiki wiki = Xoa_app_fxt.wiki_tst_(app);
parser.Load(Gfo_usr_dlg_.Test(), wiki, new Xow_ns(Xow_ns_.Id_template, Xow_ns_case_.Id_1st, Bry_.new_a7("Template"), false), new Io_url[] {url}, 1 * Io_mgr.Len_kb);
parser.Load(Gfo_usr_dlg_.Test(), wiki, new Xow_ns(Xow_ns_.Id_template, Xow_ns_case_.Tid__1st, Bry_.new_a7("Template"), false), new Io_url[] {url}, 1 * Io_mgr.Len_kb);
List_adp actl = List_adp_.new_();
Xowd_page_itm page = new Xowd_page_itm();
while (parser.Read(page)) {

View File

@@ -0,0 +1,49 @@
/*
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.cmds.texts.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.xowa.wikis.nss.*;
public class Xob_siteinfo_nde {
public Xob_siteinfo_nde(String site_name, String db_name, byte[] main_page, String generator, String case_dflt, Xow_ns_mgr ns_mgr) {
this.site_name = site_name;
this.db_name = db_name;
this.main_page = main_page;
this.generator = generator;
this.case_dflt = case_dflt;
this.ns_mgr = ns_mgr;
}
public String Site_name() {return site_name;} private final String site_name;
public String Db_name() {return db_name;} private final String db_name;
public byte[] Main_page() {return main_page;} private final byte[] main_page;
public String Generator() {return generator;} private final String generator;
public String Case_dflt() {return case_dflt;} private final String case_dflt;
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
public void To_bfr(Bry_bfr bfr) {
bfr.Add (main_page).Add_byte_pipe();
bfr.Add_str_u8(case_dflt).Add_byte_pipe();
bfr.Add_str_u8(site_name).Add_byte_pipe();
bfr.Add_str_u8(db_name).Add_byte_pipe();
bfr.Add_str_u8(generator).Add_byte_nl();
int len = ns_mgr.Count();
for (int i = 0; i < len; ++i) {
Xow_ns ns = ns_mgr.Ords_get_at(i);
bfr.Add_int_variable(ns.Id()).Add_byte_pipe();
bfr.Add_str_u8(Xow_ns_case_.To_str(ns.Case_match())).Add_byte_pipe();
bfr.Add(ns.Name_txt()).Add_byte_nl();
}
}
}

View File

@@ -0,0 +1,80 @@
/*
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.cmds.texts.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.core.ios.*; import gplx.langs.xmls.*; // NOTE: gplx.langs.xmls does not support Android; DATE:2013-01-17
import gplx.xowa.wikis.nss.*;
public class Xob_siteinfo_parser_ {
public static byte[] Extract(Io_stream_rdr src_rdr) {
Io_buffer_rdr rdr = Io_buffer_rdr.Null;
try {
rdr = Io_buffer_rdr.new_(src_rdr, Io_mgr.Len_mb); // ASSUME: siteInfo is fully contained in the 1st MB of the src_xml
byte[] src = rdr.Bfr();
int bgn = Bry_find_.Find_fwd(src, Bry_siteinfo_bgn, 0) ; if (bgn == Bry_find_.Not_found) throw Err_.new_("Xob_siteinfo_parser_", "could not find <siteinfo>", "src", src);
int end = Bry_find_.Move_fwd(src, Bry_siteinfo_end, bgn); if (end == Bry_find_.Not_found) throw Err_.new_("Xob_siteinfo_parser_", "could not find </siteinfo>", "src", src);
return Bry_.Mid(src, bgn, end);
}
finally {rdr.Rls();}
}
public static void Parse(byte[] siteinfo_bry, Xowe_wiki wiki) {
Xob_siteinfo_nde nde = Parse(String_.new_u8(siteinfo_bry), wiki.Ns_mgr());
wiki.Props().Bldr_version_(Bry_.new_a7(Xoa_app_.Version));
wiki.Props().Main_page_(nde.Main_page());
Bry_bfr bfr = Bry_bfr.new_().Add_str_u8(nde.Site_name()).Add_byte_pipe().Add_str_u8(nde.Generator()).Add_byte_pipe().Add_str_u8(nde.Case_dflt()).Add_byte_pipe();
wiki.Props().Siteinfo_misc_(bfr.To_bry_and_clear());
}
public static Xob_siteinfo_nde Parse(String xdoc_src, Xow_ns_mgr ns_mgr) {
XmlDoc xdoc = XmlDoc_.parse(xdoc_src); XmlNde root = xdoc.Root();
String site_name = "", db_name = "", generator = "", case_dflt = Xow_ns_case_.Key__1st; byte[] main_page = Xoa_page_.Main_page_bry;
int root_len = root.SubNdes().Count();
for (int i = 0; i < root_len; ++i) {
XmlNde sub_nde = root.SubNdes().Get_at(i); String sub_name = sub_nde.Name();
if (String_.Eq(sub_name, "sitename")) site_name = sub_nde.Text_inner();
else if (String_.Eq(sub_name, "generator")) generator = sub_nde.Text_inner();
else if (String_.Eq(sub_name, "case")) case_dflt = sub_nde.Text_inner();
else if (String_.Eq(sub_name, "dbname")) db_name = sub_nde.Text_inner();
else if (String_.Eq(sub_name, "base")) main_page = Parse_base(Bry_.new_u8(sub_nde.Text_inner()));
else if (String_.Eq(sub_name, "namespaces")) Parse_namespaces(sub_nde, ns_mgr, case_dflt);
else if (String_.Eq(sub_name, "#text")) {} // JAVA.XML.#text: ignore unexpected #text nodes
}
return new Xob_siteinfo_nde(site_name, db_name, main_page, generator, case_dflt, ns_mgr);
}
private static byte[] Parse_base(byte[] url) {
int page_bgn = Bry_find_.Find_fwd(url, gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki, 0);
if (page_bgn == Bry_find_.Not_found) { // "/wiki/" not found; EX: "http://mywiki/My_main_page"
page_bgn = Bry_find_.Find_bwd(url, Byte_ascii.Slash); // ASSUME last segment is page
if (page_bgn == Bry_find_.Not_found) throw Err_.new_("Xob_siteinfo_parser_", "could not parse main page url", "url", url);
++page_bgn; // add 1 to position after slash
}
else // "/wiki/" found
page_bgn += gplx.xowa.htmls.hrefs.Xoh_href_.Len__wiki; // position bgn after "/wiki/"
return Bry_.Mid(url, page_bgn, url.length); // extract everything after "page_bgn"; EX: "http://en.wikipedia.org/wiki/Main_Page" -> "Main_Page"
}
private static void Parse_namespaces(XmlNde grp_nde, Xow_ns_mgr ns_mgr, String case_dflt) {
ns_mgr.Clear(); // NOTE: wipe out any preexisting ns; use siteinfo.xml as definitive list
int grp_len = grp_nde.SubNdes().Count();
for (int i = 0; i < grp_len; ++i) {
XmlNde itm_nde = grp_nde.SubNdes().Get_at(i); if (itm_nde.Atrs().Count() == 0) continue; // JAVA.XML.#text: ignore unexpected #text nodes
String ns_id = itm_nde.Atrs().FetchValOr("key", null); if (ns_id == null) throw Err_.new_("Xob_siteinfo_parser_", "missing key for ns", "ns_xml", itm_nde.Text_inner());
String case_match = itm_nde.Atrs().FetchValOr("case", case_dflt); // NOTE: some dumps can omit "case"; EX: https://dumps.wikimedia.org/sep11wiki; DATE:2015-11-01
String name = itm_nde.Text_inner();
ns_mgr.Add_new(Int_.parse(ns_id), Bry_.new_u8(name), Xow_ns_case_.To_tid(case_match), false);
}
ns_mgr.Init_w_defaults();
}
private static final byte[] Bry_siteinfo_bgn = Bry_.new_a7("<siteinfo>"), Bry_siteinfo_end = Bry_.new_a7("</siteinfo>");
}

View File

@@ -0,0 +1,110 @@
/*
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.cmds.texts.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import org.junit.*; import gplx.xowa.wikis.nss.*;
public class Xob_siteinfo_parser__tst {
private final Xob_siteinfo_parser__fxt fxt = new Xob_siteinfo_parser__fxt();
@Test public void Basic__simplewikt() { // PURPOSE: basic test of siteinfo parse; DATE:2015-11-01
fxt.Test__parse(String_.Concat_lines_nl_skip_last
( " <siteinfo>"
, " <sitename>Wiktionary</sitename>"
, " <dbname>simplewiktionary</dbname>"
, " <super>https://simple.wiktionary.org/wiki/Main_Page</super>"
, " <generator>MediaWiki 1.27.0-wmf.3</generator>"
, " <case>case-sensitive</case>"
, " <namespaces>"
, " <namespace key=\"-2\" case=\"case-sensitive\">Media</namespace>"
, " <namespace key=\"-1\" case=\"first-letter\">Special</namespace>"
, " <namespace key=\"0\" case=\"case-sensitive\" />"
, " <namespace key=\"1\" case=\"case-sensitive\">Talk</namespace>"
, " <namespace key=\"2\" case=\"first-letter\">User</namespace>"
, " <namespace key=\"3\" case=\"first-letter\">User talk</namespace>"
, " <namespace key=\"4\" case=\"case-sensitive\">Wiktionary</namespace>"
, " <namespace key=\"5\" case=\"case-sensitive\">Wiktionary talk</namespace>"
, " <namespace key=\"6\" case=\"case-sensitive\">File</namespace>"
, " <namespace key=\"7\" case=\"case-sensitive\">File talk</namespace>"
, " <namespace key=\"8\" case=\"first-letter\">MediaWiki</namespace>"
, " <namespace key=\"9\" case=\"first-letter\">MediaWiki talk</namespace>"
, " <namespace key=\"10\" case=\"case-sensitive\">Template</namespace>"
, " <namespace key=\"11\" case=\"case-sensitive\">Template talk</namespace>"
, " <namespace key=\"12\" case=\"case-sensitive\">Help</namespace>"
, " <namespace key=\"13\" case=\"case-sensitive\">Help talk</namespace>"
, " <namespace key=\"14\" case=\"case-sensitive\">Category</namespace>"
, " <namespace key=\"15\" case=\"case-sensitive\">Category talk</namespace>"
, " <namespace key=\"828\" case=\"case-sensitive\">Module</namespace>"
, " <namespace key=\"829\" case=\"case-sensitive\">Module talk</namespace>"
, " <namespace key=\"2300\" case=\"case-sensitive\">Gadget</namespace>"
, " <namespace key=\"2301\" case=\"case-sensitive\">Gadget talk</namespace>"
, " <namespace key=\"2302\" case=\"case-sensitive\">Gadget definition</namespace>"
, " <namespace key=\"2303\" case=\"case-sensitive\">Gadget definition talk</namespace>"
, " <namespace key=\"2600\" case=\"first-letter\">Topic</namespace>"
, " </namespaces>"
, " </siteinfo>"
), String_.Concat_lines_nl
( "Main_Page|case-sensitive|Wiktionary|simplewiktionary|MediaWiki 1.27.0-wmf.3"
, "-2|case-sensitive|Media"
, "-1|first-letter|Special"
, "0|case-sensitive|"
, "1|case-sensitive|Talk"
, "2|first-letter|User"
, "3|first-letter|User talk"
, "4|case-sensitive|Wiktionary"
, "5|case-sensitive|Wiktionary talk"
, "6|case-sensitive|File"
, "7|case-sensitive|File talk"
, "8|first-letter|MediaWiki"
, "9|first-letter|MediaWiki talk"
, "10|case-sensitive|Template"
, "11|case-sensitive|Template talk"
, "12|case-sensitive|Help"
, "13|case-sensitive|Help talk"
, "14|case-sensitive|Category"
, "15|case-sensitive|Category talk"
, "828|case-sensitive|Module"
, "829|case-sensitive|Module talk"
, "2300|case-sensitive|Gadget"
, "2301|case-sensitive|Gadget talk"
, "2302|case-sensitive|Gadget definition"
, "2303|case-sensitive|Gadget definition talk"
, "2600|first-letter|Topic"
, "2601|first-letter|2601" // NOTE: Topic_talk doesn't exist in <siteinfo>, but added by XOWA b/c every subj ns must have a talk ns
));
}
@Test public void Case_dflt() { // PURPOSE: missing case should use dflt DATE:2015-11-01
fxt.Test__parse(String_.Concat_lines_nl_skip_last
( " <siteinfo>"
, " <case>case-sensitive</case>"
, " <namespaces>"
, " <namespace key=\"-2\">Media</namespace>"
, " </namespaces>"
, " </siteinfo>"
), String_.Concat_lines_nl
( "Main_Page|case-sensitive|||"
, "-2|case-sensitive|Media"
));
}
}
class Xob_siteinfo_parser__fxt {
private final Xow_ns_mgr ns_mgr = new Xow_ns_mgr(gplx.xowa.langs.cases.Xol_case_mgr_.U8());
private final Bry_bfr bfr = Bry_bfr.new_();
public void Test__parse(String src_str, String expd) {
Xob_siteinfo_nde nde = Xob_siteinfo_parser_.Parse(src_str, ns_mgr);
nde.To_bfr(bfr);
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}
}

View File

@@ -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.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*; import gplx.core.threads.*;
import gplx.core.ios.*; import gplx.core.threads.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_decompress_bz2_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_decompress_bz2_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@@ -46,7 +46,7 @@ public class Xob_decompress_bz2_cmd extends Xob_itm_basic_base implements Xob_cm
decompress.Prog_dlg_(app.Usr_dlg()).Run_mode_(ProcessAdp.Run_mode_async);
decompress.Run(src_fil, trg_fil, trg_fil.OwnerDir().Xto_api());
while (decompress.Exit_code() == ProcessAdp.Exit_init) {
String size = gplx.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg_fil).Size());
String size = gplx.core.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg_fil).Size());
app.Usr_dlg().Prog_many(GRP_KEY, "decompress", "decompressing: ~{0}", size);
Thread_adp_.Sleep(1000);
}

View File

@@ -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.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.tdbs.*;

View File

@@ -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.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.dbs.*; import gplx.ios.*;
import gplx.dbs.*; import gplx.core.ios.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.bldrs.wms.dumps.*;
public class Xob_download_wkr extends Xob_itm_basic_base implements Xob_cmd {

View File

@@ -29,9 +29,9 @@ public class Xob_unzip_wkr {
}
public void Decompress(Io_url src, Io_url trg) {
String src_ext = src.Ext();
if (String_.Eq(src_ext, gplx.ios.Io_stream_.Ext_bz2)) process = decompress_bz2;
else if (String_.Eq(src_ext, gplx.ios.Io_stream_.Ext_zip)) process = decompress_zip;
else if (String_.Eq(src_ext, gplx.ios.Io_stream_.Ext_gz)) process = decompress_gz;
if (String_.Eq(src_ext, gplx.core.ios.Io_stream_.Ext_bz2)) process = decompress_bz2;
else if (String_.Eq(src_ext, gplx.core.ios.Io_stream_.Ext_zip)) process = decompress_zip;
else if (String_.Eq(src_ext, gplx.core.ios.Io_stream_.Ext_gz)) process = decompress_gz;
else throw Err_.new_unhandled(src_ext);
Io_url trg_owner_dir = trg.OwnerDir();
Io_mgr.Instance.CreateDirIfAbsent(trg_owner_dir);

View File

@@ -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.bldrs.cmds.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.dbs.*; import gplx.ios.*; import gplx.xowa.files.*;
import gplx.dbs.*; import gplx.core.ios.*; import gplx.xowa.files.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
public class Xob_image_cmd extends Xob_itm_dump_base implements Xob_cmd, GfoInvkAble, Sql_file_parser_cmd {
private Db_conn conn = null; private Db_stmt stmt = null;

View File

@@ -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.bldrs.cmds.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import org.junit.*; import gplx.ios.*; import gplx.xowa.files.*;
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.files.*;
public class Xob_image_cmd_tst {
private Xob_image_cmd_fxt fxt = new Xob_image_cmd_fxt();
@Test public void Basic() {fxt.Init_("A.png" , Xof_media_type.Name_bitmap , Xof_ext_.Bry_png, 220, 110) .Test(Xof_ext_.Id_png);} // A.png -> png

View File

@@ -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.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*; import gplx.xowa.htmls.*;
import gplx.core.ios.*; import gplx.xowa.htmls.*;
import gplx.langs.htmls.encoders.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*;
@@ -187,11 +187,11 @@ public class Xoa_css_extractor {
private String Logo_find_src() {
if (mainpage_html == null) return null;
int main_page_html_len = mainpage_html.length;
int logo_bgn = Bry_find_.Find_fwd(mainpage_html, Logo_find_bgn, 0); if (logo_bgn == Bry_.NotFound) return null;
int logo_bgn = Bry_find_.Find_fwd(mainpage_html, Logo_find_bgn, 0); if (logo_bgn == Bry_find_.Not_found) return null;
logo_bgn += Logo_find_bgn.length;
logo_bgn = Bry_find_.Find_fwd(mainpage_html, Logo_find_end, logo_bgn); if (logo_bgn == Bry_.NotFound) return null;
logo_bgn = Bry_find_.Find_fwd(mainpage_html, Logo_find_end, logo_bgn); if (logo_bgn == Bry_find_.Not_found) return null;
logo_bgn += Logo_find_end.length;
int logo_end = Bry_find_.Find_fwd(mainpage_html, Byte_ascii.Paren_end, logo_bgn, main_page_html_len); if (logo_bgn == Bry_.NotFound) return null;
int logo_end = Bry_find_.Find_fwd(mainpage_html, Byte_ascii.Paren_end, logo_bgn, main_page_html_len); if (logo_bgn == Bry_find_.Not_found) return null;
byte[] logo_bry = Bry_.Mid(mainpage_html, logo_bgn, logo_end);
return protocol_prefix + String_.new_u8(logo_bry);
}
@@ -240,9 +240,9 @@ public class Xoa_css_extractor {
byte[] protocol_prefix_bry = Bry_.new_u8(protocol_prefix);
Gfo_url gfo_url = new Gfo_url();
while (true) {
int url_bgn = Bry_find_.Find_fwd(raw, Css_find_bgn, prv_pos); if (url_bgn == Bry_.NotFound) break; // nothing left; stop
int url_bgn = Bry_find_.Find_fwd(raw, Css_find_bgn, prv_pos); if (url_bgn == Bry_find_.Not_found) break; // nothing left; stop
url_bgn += css_find_bgn_len;
int url_end = Bry_find_.Find_fwd(raw, Byte_ascii.Quote, url_bgn, raw_len); if (url_end == Bry_.NotFound) {usr_dlg.Warn_many("", "main_page.css_parse", "could not find css; pos='~{0}' text='~{1}'", url_bgn, String_.new_u8__by_len(raw, url_bgn, url_bgn + 32)); break;}
int url_end = Bry_find_.Find_fwd(raw, Byte_ascii.Quote, url_bgn, raw_len); if (url_end == Bry_find_.Not_found) {usr_dlg.Warn_many("", "main_page.css_parse", "could not find css; pos='~{0}' text='~{1}'", url_bgn, String_.new_u8__by_len(raw, url_bgn, url_bgn + 32)); break;}
byte[] css_url_bry = Bry_.Mid(raw, url_bgn, url_end);
css_url_bry = Bry_.Replace(css_url_bry, Css_amp_find, Css_amp_repl); // &amp; -> &
css_url_bry = url_encoder.Decode(css_url_bry); // %2C -> %7C -> |
@@ -264,7 +264,7 @@ public class Xoa_css_extractor {
usr_dlg.Prog_many("", "main_page.css_download", "downloading css for '~{0}'", css_url);
download_xrg.Prog_fmt_hdr_(css_url);
byte[] css_bry = download_xrg.Exec_as_bry(css_url); if (css_bry == null) continue; // css not found; continue
tmp_bfr.Add(Xoa_css_img_downloader.Bry_comment_bgn).Add_str(css_url).Add(Xoa_css_img_downloader.Bry_comment_end).Add_byte_nl();
tmp_bfr.Add(Xoa_css_img_downloader.Bry_comment_bgn).Add_str_u8(css_url).Add(Xoa_css_img_downloader.Bry_comment_end).Add_byte_nl();
tmp_bfr.Add(css_bry).Add_byte_nl().Add_byte_nl();
}
return tmp_bfr.To_bry_and_clear();

View File

@@ -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.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.ios.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.downloads.*;
import org.junit.*; import gplx.core.ios.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.downloads.*;
public class Xoa_css_extractor_basic_tst {
@Before public void init() {fxt.Clear();} private Xoa_css_extractor_fxt fxt = new Xoa_css_extractor_fxt();
@Test public void Logo_download() {

View File

@@ -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.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.ios.*; import gplx.xowa.wikis.nss.*;
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.wikis.nss.*;
public class Xoa_css_extractor_wiki_tst {
@Before public void init() {fxt.Clear();} private Xoa_css_extractor_fxt fxt = new Xoa_css_extractor_fxt();
@Test public void Css_wiki_generate() {

View File

@@ -42,7 +42,7 @@ public class Xoa_css_img_downloader {
Hash_adp img_hash = Hash_adp_bry.cs();
while (true) {
int url_pos = Bry_find_.Find_fwd(src, Bry_url, prv_pos);
if (url_pos == Bry_.NotFound) {bfr.Add_mid(src, prv_pos, src_len); break;} // no more "url("; exit;
if (url_pos == Bry_find_.Not_found) {bfr.Add_mid(src, prv_pos, src_len); break;} // no more "url("; exit;
int bgn_pos = url_pos + Bry_url_len; // set bgn_pos after "url("
byte bgn_byte = src[bgn_pos];
byte end_byte = Byte_ascii.Null;
@@ -58,7 +58,7 @@ public class Xoa_css_img_downloader {
break;
}
int end_pos = Bry_find_.Find_fwd(src, end_byte, bgn_pos, src_len);
if (end_pos == Bry_.NotFound) { // unclosed "url("; exit since nothing else will be found
if (end_pos == Bry_find_.Not_found) { // unclosed "url("; exit since nothing else will be found
usr_dlg.Warn_many(GRP_KEY, "parse.invalid_url.end_missing", "could not find end_sequence for 'url(': bgn='~{0}' end='~{1}'", prv_pos, String_.new_u8__by_len(src, prv_pos, prv_pos + 25));
bfr.Add_mid(src, prv_pos, src_len);
break;
@@ -76,7 +76,7 @@ public class Xoa_css_img_downloader {
continue;
}
int import_url_end = Import_url_chk(rel_url_prefix, src, src_len, prv_pos, url_pos, img_raw, bfr); // check for embedded stylesheets via @import tag
if (import_url_end != Bry_.NotFound) {
if (import_url_end != Bry_find_.Not_found) {
prv_pos = import_url_end;
continue;
}
@@ -110,8 +110,8 @@ public class Xoa_css_img_downloader {
;
}
private int Import_url_chk(byte[] rel_url_prefix, byte[] src, int src_len, int old_pos, int find_bgn, byte[] url_raw, Bry_bfr bfr) {
if (find_bgn < Bry_import_len) return Bry_.NotFound;
if (!Bry_.Match(src, find_bgn - Bry_import_len, find_bgn, Bry_import)) return Bry_.NotFound;
if (find_bgn < Bry_import_len) return Bry_find_.Not_found;
if (!Bry_.Match(src, find_bgn - Bry_import_len, find_bgn, Bry_import)) return Bry_find_.Not_found;
byte[] css_url = url_raw; int css_url_len = css_url.length;
if (css_url_len > 0 && css_url[0] == Byte_ascii.Slash) { // css_url starts with "/"; EX: "/page" or "//site/page" DATE:2014-02-03
if (css_url_len > 1 && css_url[1] != Byte_ascii.Slash) // skip if css_url starts with "//"; EX: "//site/page"
@@ -124,7 +124,7 @@ public class Xoa_css_img_downloader {
byte[] css_trg_bry = download_wkr.Download_xrg().Exec_as_bry(css_src_str);
if (css_trg_bry == null) {
usr_dlg.Warn_many("", "", "could not import css: url=~{0}", css_src_str);
return Bry_.NotFound; // css not found
return Bry_find_.Not_found; // css not found
}
bfr.Add_mid(src, old_pos, find_bgn - Bry_import_len).Add_byte_nl();
bfr.Add(Bry_comment_bgn).Add(css_url).Add(Bry_comment_end).Add_byte_nl();
@@ -144,11 +144,11 @@ public class Xoa_css_img_downloader {
if (Bry_.Has_at_bgn(raw, Bry_fwd_slashes, 0, raw_len)) pos_bgn = Bry_fwd_slashes.length;
if (Bry_.Has_at_bgn(raw, Bry_http, 0, raw_len)) pos_bgn = Bry_http.length;
int pos_slash = Bry_find_.Find_fwd(raw, Byte_ascii.Slash, pos_bgn, raw_len);
if (pos_slash == Bry_.NotFound) return null; // first segment is site_name; at least one slash must be present for image name; EX: site.org/img_name.jpg
if (pos_slash == Bry_find_.Not_found) return null; // first segment is site_name; at least one slash must be present for image name; EX: site.org/img_name.jpg
if (pos_slash == raw_len - 1) return null; // "site.org/" is invalid
int pos_end = raw_len;
int pos_question = Bry_find_.Find_bwd(raw, Byte_ascii.Question);
if (pos_question != Bry_.NotFound)
if (pos_question != Bry_find_.Not_found)
pos_end = pos_question; // remove query params; EX: img_name?key=val
return Bry_.Mid(raw, pos_bgn, pos_end);
}

View File

@@ -34,7 +34,7 @@ class Xob_css_parser__url {
break;
}
int end_pos = Bry_find_.Find_fwd(src, end_byte, bgn_pos, src_len);
if (end_pos == Bry_.NotFound) // unclosed "url("; exit since nothing else will be found
if (end_pos == Bry_find_.Not_found) // unclosed "url("; exit since nothing else will be found
return Xob_css_tkn__warn.new_(tkn_bgn, tkn_end, "mirror.parser.url:dangling; bgn=~{0} excerpt=~{1}", bgn_pos, String_.new_u8__by_len(src, tkn_bgn, tkn_bgn + 128));
if (end_pos - bgn_pos == 0) // empty; "url()"; ignore
return Xob_css_tkn__warn.new_(tkn_bgn, tkn_end, "mirror.parser.url:empty; bgn=~{0} excerpt=~{1}", bgn_pos, String_.new_u8__by_len(src, tkn_bgn, tkn_bgn + 128));

View File

@@ -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.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*; import gplx.xowa.files.downloads.*;
import gplx.core.ios.*; import gplx.xowa.files.downloads.*;
public class Xob_mirror_mgr {
private final Xof_download_wkr download_wkr; private final Xob_css_parser css_parser;
private final byte[] page_url; private final Io_url fsys_root;

View File

@@ -49,8 +49,8 @@ class Dg_parser_fxt {
Tfds.Eq_str_lines(Xto_str(bfr, expd), Xto_str(bfr, actl));
}
private String Xto_str(Bry_bfr bfr, Dg_rule line) {
bfr .Add_str("score=").Add_int_variable(line.Score()).Add_byte_nl()
.Add_str("words=").Add_str(String_.Concat_with_str(";", Dg_word.Ary_concat(line.Words(), tmp_bfr, Byte_ascii.Tick))).Add_byte_nl()
bfr .Add_str_a7("score=").Add_int_variable(line.Score()).Add_byte_nl()
.Add_str_a7("words=").Add_str_u8(String_.Concat_with_str(";", Dg_word.Ary_concat(line.Words(), tmp_bfr, Byte_ascii.Tick))).Add_byte_nl()
;
return bfr.To_str_and_clear();
}

View File

@@ -23,10 +23,10 @@ class Xoi_cmd_imageMagick_download extends Gfo_thread_cmd_download implements Gf
public Xoi_cmd_imageMagick_download(Gfo_usr_dlg usr_dlg, Gfui_kit kit, Io_url trg) {this.Ctor(usr_dlg, kit); this.trg = trg;} Io_url trg;
@Override public byte Async_init() { // <a href="ImageMagick-6.8.1-9-Q16-x86-windows.zip">
// byte[] raw = xrg.Exec_as_bry(Src_imageMagick);
// int find_pos = Bry_find_.Find_fwd(raw, Bry_windows_zip); if (find_pos == Bry_.NotFound) return Fail();
// int bgn_pos = Bry_find_.Find_bwd(raw, Byte_ascii.Quote, find_pos); if (bgn_pos == Bry_.NotFound) return Fail();
// int find_pos = Bry_find_.Find_fwd(raw, Bry_windows_zip); if (find_pos == Bry_find_.Not_found) return Fail();
// int bgn_pos = Bry_find_.Find_bwd(raw, Byte_ascii.Quote, find_pos); if (bgn_pos == Bry_find_.Not_found) return Fail();
// ++bgn_pos;
// int end_pos = Bry_find_.Find_fwd(raw, Byte_ascii.Quote, bgn_pos); if (end_pos == Bry_.NotFound) return Fail();
// int end_pos = Bry_find_.Find_fwd(raw, Byte_ascii.Quote, bgn_pos); if (end_pos == Bry_find_.Not_found) return Fail();
// String src = Src_imageMagick + String_.new_a7(Bry_.Mid(raw, bgn_pos, end_pos));
String src = "http://ftp.sunet.se/pub/multimedia/graphics/ImageMagick/binaries/ImageMagick-6.8.8-1-Q16-x86-windows.zip";
this.Init("downloading", src, trg);

View File

@@ -56,16 +56,16 @@ public class Xoi_cmd_wiki_tst {
byte[] pages_articles_key = Bry_.new_a7(wmf_key + "-latest-pages-articles.xml.bz2");
Wmf_latest_itm latest_itm = parser.Get_by(pages_articles_key);
bfr.Add(domain_bry).Add_byte_pipe();
bfr.Add_str(dump_file.File_url()).Add_byte_pipe();
bfr.Add_str_u8(dump_file.File_url()).Add_byte_pipe();
bfr.Add(Xow_domain_tid_.Get_type_as_bry(domain_itm.Domain_type_id())).Add_byte_pipe();
long src_size = latest_itm.Size();
bfr.Add_long_variable(src_size).Add_byte_pipe();
bfr.Add_str(gplx.ios.Io_size_.To_str(src_size)).Add_byte_pipe();
bfr.Add_str_a7(gplx.core.ios.Io_size_.To_str(src_size)).Add_byte_pipe();
time_fmtr.Seconds_(Math_.Div_safe_as_long(src_size, 1000000)).Fmt__do(bfr);
bfr.Add_byte_pipe();
bfr.Add_str(latest_itm.Date().XtoStr_fmt_yyyy_MM_dd_HH_mm());
bfr.Add_str_a7(latest_itm.Date().XtoStr_fmt_yyyy_MM_dd_HH_mm());
bfr.Add_byte_pipe();
bfr.Add_str(dump_file.Dump_date());
bfr.Add_str_a7(dump_file.Dump_date());
bfr.Add_byte_nl();
}
/*
@@ -94,7 +94,7 @@ public class Xoi_cmd_wiki_tst {
// bfr.Add(lang_itm.Canonical_name()).Add_byte_pipe();
long src_size = dump_file.File_len();
bfr.Add_long_variable(src_size).Add_byte_pipe();
bfr.Add_str(gplx.ios.Io_size_.To_str(src_size)).Add_byte_pipe();
bfr.Add_str(gplx.core.ios.Io_size_.To_str(src_size)).Add_byte_pipe();
time_fmtr.Seconds_(Math_.Div_safe_as_long(src_size, 1000000)).XferAry(bfr, 0);
bfr.Add_byte_pipe();
bfr.Add_str(dump_file.File_modified().XtoStr_fmt_yyyy_MM_dd_HH_mm());

View File

@@ -16,12 +16,12 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.installs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.bldrs.wms.dumps.*;
public class Xoi_dump_mgr implements GfoInvkAble {
public String[] Server_urls() {return server_urls;} private String[] server_urls = String_.Ary(Xowm_dump_file_.Server_wmf_https, Xowm_dump_file_.Server_your_org, Xowm_dump_file_.Server_c3sl, Xowm_dump_file_.Server_masaryk);
public String[] Custom_cmds() {return custom_cmds;} private String[] custom_cmds = String_.Ary(Xoi_cmd_wiki_download.Key_wiki_download, Xoi_cmd_wiki_import.KEY);
public byte Data_storage_format() {return data_storage_format;} public Xoi_dump_mgr Data_storage_format_(byte v) {data_storage_format = v; return this;} private byte data_storage_format = gplx.ios.Io_stream_.Tid_gzip;
public byte Data_storage_format() {return data_storage_format;} public Xoi_dump_mgr Data_storage_format_(byte v) {data_storage_format = v; return this;} private byte data_storage_format = gplx.core.ios.Io_stream_.Tid_gzip;
public long Db_text_max() {return db_text_max;} private long db_text_max = (long)3000 * Io_mgr.Len_mb;
public long Db_categorylinks_max() {return db_categorylinks_max;} private long db_categorylinks_max = (long)3600 * Io_mgr.Len_mb;
public long Db_wikidata_max() {return db_wikidata_max;} private long db_wikidata_max = (long)3600 * Io_mgr.Len_mb;

View File

@@ -23,9 +23,9 @@ public class Xoi_mirror_parser {
List_adp rv = List_adp_.new_();
int pos = 0;
while (true) {
int bgn = Bry_find_.Find_fwd(raw, CONST_href_bgn, pos); if (bgn == Bry_.NotFound) break;
int bgn = Bry_find_.Find_fwd(raw, CONST_href_bgn, pos); if (bgn == Bry_find_.Not_found) break;
bgn += CONST_href_bgn.length;
int end = Bry_find_.Find_fwd(raw, CONST_href_end, bgn); if (end == Bry_.NotFound) return String_.Ary_empty;
int end = Bry_find_.Find_fwd(raw, CONST_href_end, bgn); if (end == Bry_find_.Not_found) return String_.Ary_empty;
byte[] date = Bry_.Mid(raw, bgn, end);
pos = end + CONST_href_end.length;
if (Bry_.Match(date, CONST_date_parent_dir)) continue;

View File

@@ -97,7 +97,7 @@ class Xow_cfg_wiki_core_fxt {
wiki.Cfg_wiki_core().Load(raw);
Tfds.Eq_str_lines(raw, String_.new_a7(wiki.Cfg_wiki_core().Build_gfs()));
}
public Xow_ns ns_(int id, boolean case_match, String name) {return new Xow_ns(id, case_match ? Xow_ns_case_.Id_all : Xow_ns_case_.Id_1st, Bry_.new_u8(name), false);}
public Xow_ns ns_(int id, boolean case_match, String name) {return new Xow_ns(id, case_match ? Xow_ns_case_.Tid__all : Xow_ns_case_.Tid__1st, Bry_.new_u8(name), false);}
public void Load_tst(String raw, Xow_ns... expd_ary) {
wiki.Cfg_wiki_core().Load(raw);
int expd_len = expd_ary.length;

View File

@@ -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.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.apps.fsys.*;
public class Xoi_firefox_installer implements GfoInvkAble {
private Io_url src_xpi, trg_xpi;

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import org.junit.*;
import gplx.ios.*;
import gplx.core.ios.*;
public class Xoi_firefox_installer_tst {
private Xoi_firefox_pref_fxt fxt = new Xoi_firefox_pref_fxt();
@Test public void Pref_update() {

View File

@@ -21,7 +21,7 @@ public class Wmf_dump_list_parser {
Ordered_hash itms = Ordered_hash_.New_bry();
int pos = 0;
while (true) {
int a_pos = Bry_find_.Find_fwd(src, Find_anchor, pos); if (a_pos == Bry_.NotFound) break; // no more anchors found
int a_pos = Bry_find_.Find_fwd(src, Find_anchor, pos); if (a_pos == Bry_find_.Not_found) break; // no more anchors found
pos = a_pos + Find_anchor.length;
try {
Wmf_dump_itm itm = new Wmf_dump_itm();
@@ -35,31 +35,31 @@ public class Wmf_dump_list_parser {
return (Wmf_dump_itm[])itms.To_ary(Wmf_dump_itm.class);
}
private boolean Parse_href(Wmf_dump_itm itm, byte[] src, int a_pos) { // EX: http://dumps.wikimedia.org/enwiki/20130807
int href_pos = Bry_find_.Find_fwd(src, Find_href, a_pos); if (href_pos == Bry_.NotFound) return false; // no <li>; something bad happened
int href_pos = Bry_find_.Find_fwd(src, Find_href, a_pos); if (href_pos == Bry_find_.Not_found) return false; // no <li>; something bad happened
int href_bgn_pos = Bry_find_.Find_fwd(src, Byte_ascii.Quote, href_pos + Find_href.length);
int href_end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Quote, href_bgn_pos + 1); if (href_end_pos == Bry_.NotFound) return false;
int href_end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Quote, href_bgn_pos + 1); if (href_end_pos == Bry_find_.Not_found) return false;
byte[] href_bry = Bry_.Mid(src, href_bgn_pos + 1, href_end_pos);
int date_end = href_bry.length;
int date_bgn = Bry_find_.Find_bwd(href_bry, Byte_ascii.Slash); if (date_bgn == Bry_.NotFound) return false;
int date_bgn = Bry_find_.Find_bwd(href_bry, Byte_ascii.Slash); if (date_bgn == Bry_find_.Not_found) return false;
byte[] date_bry = Bry_.Mid(href_bry, date_bgn + 1, date_end);
DateAdp date = DateAdp_.parse_fmt(String_.new_a7(date_bry), "yyyyMMdd");
itm.Dump_date_(date);
int abrv_end = date_bgn;
int abrv_bgn = Bry_find_.Find_bwd(href_bry, Byte_ascii.Slash, abrv_end); if (abrv_bgn == Bry_.NotFound) abrv_bgn = -1; // "enwiki/20130708"
int abrv_bgn = Bry_find_.Find_bwd(href_bry, Byte_ascii.Slash, abrv_end); if (abrv_bgn == Bry_find_.Not_found) abrv_bgn = -1; // "enwiki/20130708"
byte[] abrv_bry = Bry_.Mid(href_bry, abrv_bgn + 1, abrv_end);
itm.Wiki_abrv_(Bry_.Replace(abrv_bry, Byte_ascii.Underline, Byte_ascii.Dash));
return true;
}
private DateAdp Parse_status_time(byte[] src, int a_pos) {
int li_pos = Bry_find_.Find_bwd(src, Find_li, a_pos); if (li_pos == Bry_.NotFound) return null;
int bgn = Bry_find_.Find_fwd(src, Byte_ascii.Gt, li_pos + Find_li.length); if (bgn == Bry_.NotFound) return null;
int li_pos = Bry_find_.Find_bwd(src, Find_li, a_pos); if (li_pos == Bry_find_.Not_found) return null;
int bgn = Bry_find_.Find_fwd(src, Byte_ascii.Gt, li_pos + Find_li.length); if (bgn == Bry_find_.Not_found) return null;
byte[] rv_bry = Bry_.Mid(src, bgn + 1, a_pos);
return DateAdp_.parse_fmt(String_.Trim(String_.new_a7(rv_bry)), "yyyy-MM-dd HH:mm:ss");
}
private byte[] Parse_status_msg(byte[] src, int a_pos) {
int span_pos = Bry_find_.Find_fwd(src, Find_span_bgn, a_pos); if (span_pos == Bry_.NotFound) return null;
int bgn = Bry_find_.Find_fwd(src, Byte_ascii.Gt, span_pos + Find_span_bgn.length); if (bgn == Bry_.NotFound) return null;
int end = Bry_find_.Find_fwd(src, Find_span_end, bgn); if (end == Bry_.NotFound) return null;
int span_pos = Bry_find_.Find_fwd(src, Find_span_bgn, a_pos); if (span_pos == Bry_find_.Not_found) return null;
int bgn = Bry_find_.Find_fwd(src, Byte_ascii.Gt, span_pos + Find_span_bgn.length); if (bgn == Bry_find_.Not_found) return null;
int end = Bry_find_.Find_fwd(src, Find_span_end, bgn); if (end == Bry_find_.Not_found) return null;
return Bry_.Mid(src, bgn + 1, end);
}
private static byte[]

View File

@@ -61,7 +61,7 @@ public class Wmf_dump_list_parser_tst {
// if (Bry_.Eq(abrv, Bry_.new_a7("testwikidatawiki"))) continue;
// byte[] domain_bry = Xow_abrv_wm_.Parse_to_domain_bry(abrv);
// if (domain_bry == null) continue; // not a standard WMF wiki; ignore
// if (Bry_find_.Find_fwd(domain_bry, Bry_.new_a7("wikimania")) != Bry_.NotFound) continue;
// if (Bry_find_.Find_fwd(domain_bry, Bry_.new_a7("wikimania")) != Bry_find_.Not_found) continue;
// if (excluded_domains.Has(domain_bry)) continue;
// Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
// byte[] tid_name = Xto_display_name(Xow_domain_tid_.Get_type_as_bry(domain_itm.Domain_type_id()));

View File

@@ -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.bldrs.setups.maints; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import gplx.core.btries.*; import gplx.ios.*;
import gplx.core.btries.*; import gplx.core.ios.*;
public class Wmf_latest_parser {
private Ordered_hash hash = Ordered_hash_.New_bry();
public int Count() {return hash.Count();}

View File

@@ -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.bldrs.setups.maints; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import org.junit.*; import gplx.ios.*;
import org.junit.*; import gplx.core.ios.*;
public class Wmf_latest_parser_tst {
@Before public void init() {fxt.Clear();} private Wmf_latest_parser_fxt fxt = new Wmf_latest_parser_fxt();
@Test public void Parse() {

View File

@@ -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.bldrs.setups.maints; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.files.downloads.*;
public class Xoa_maint_mgr implements GfoInvkAble {

View File

@@ -27,7 +27,7 @@ class Upgrader_v00_02_01 {
usr_dlg.Note_many(GRP_KEY, "siteinfo.bgn", "siteinfo.bgn for ~{0}", siteinfo_url.Raw());
String siteinfo_str = Io_mgr.Instance.LoadFilStr_args(siteinfo_url).MissingIgnored_(true).Exec(); if (String_.Len_eq_0(siteinfo_str)) throw Err_.new_wo_type("could not find siteinfo.xml", "url", siteinfo_url.Raw());
usr_dlg.Note_many(GRP_KEY, "siteinfo.parse", "parsing siteinfo");
gplx.xowa.bldrs.xmls.Xob_siteinfo_parser.Siteinfo_parse(wiki, usr_dlg, siteinfo_str); // NOTE: this also resets the namespaces on the wiki; not necessary, but is benign
gplx.xowa.bldrs.cmds.texts.xmls.Xob_siteinfo_parser_.Parse(Bry_.new_u8(siteinfo_str), wiki); // NOTE: this also resets the namespaces on the wiki; not necessary, but is benign
usr_dlg.Note_many(GRP_KEY, "siteinfo.save", "saving siteinfo");
byte[] wiki_core_bry = wiki.Cfg_wiki_core().Build_gfs();
Io_mgr.Instance.SaveFilBry(wiki.Tdb_fsys_mgr().Cfg_wiki_core_fil(), wiki_core_bry);

View File

@@ -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.bldrs.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.flds.*; import gplx.ios.*;
import gplx.core.flds.*; import gplx.core.ios.*;
public class Sql_file_parser {
public Io_url Src_fil() {return src_fil;} public Sql_file_parser Src_fil_(Io_url v) {src_fil = v; return this;} Io_url src_fil;
public int Src_len() {return src_len;} public Sql_file_parser Src_len_(int v) {src_len = v; return this;} private int src_len = 8 * Io_mgr.Len_mb;
@@ -54,7 +54,7 @@ public class Sql_file_parser {
public void Parse(Gfo_usr_dlg usr_dlg) {
Io_buffer_rdr rdr = Io_buffer_rdr.Null;
try {
rdr = Io_buffer_rdr.new_(gplx.ios.Io_stream_rdr_.new_by_url_(src_fil), src_len);
rdr = Io_buffer_rdr.new_(gplx.core.ios.Io_stream_rdr_.new_by_url_(src_fil), src_len);
Bry_bfr fil_bfr = Bry_bfr.new_(), val_bfr = Bry_bfr.new_();
byte[] bfr = rdr.Bfr(); int bfr_len = rdr.Bfr_len(), fld_idx = 0, cur_pos = 0;
if (flds_req != null) Identify_flds(bfr);
@@ -73,9 +73,9 @@ public class Sql_file_parser {
switch (mode) {
case Mode_sql_bgn:
cur_pos = Bry_find_.Find_fwd(bfr, Bry_insert_into, cur_pos);
if (cur_pos == Bry_.NotFound || cur_pos > bfr_len) {reading_file = false; continue;}
if (cur_pos == Bry_find_.Not_found || cur_pos > bfr_len) {reading_file = false; continue;}
cur_pos = Bry_find_.Find_fwd(bfr, Bry_values, cur_pos);
if (cur_pos == Bry_.NotFound || cur_pos > bfr_len) throw Err_.new_wo_type("VALUES not found"); // something went wrong;
if (cur_pos == Bry_find_.Not_found || cur_pos > bfr_len) throw Err_.new_wo_type("VALUES not found"); // something went wrong;
mode = Mode_fld;
cur_pos += Bry_values.length;
break;

View File

@@ -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.bldrs.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.ios.*;
import org.junit.*; import gplx.core.ios.*;
public class Sql_file_parser_tst {
Sql_file_parser_fxt fxt = new Sql_file_parser_fxt();
@Before public void init() {fxt.Clear();}

View File

@@ -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.bldrs.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
class Sql_fld_mgr {
public int Count() {return hash.Count();}
public Sql_fld_itm Get_by_key(String fld) {return Get_by_key(Bry_.new_u8(fld));}
@@ -25,11 +25,11 @@ class Sql_fld_mgr {
} private Ordered_hash hash = Ordered_hash_.New_bry();
public Sql_fld_mgr Parse(byte[] raw) {
hash.Clear();
int bgn = Bry_find_.Find_fwd(raw, Tkn_create_table); if (bgn == Bry_.NotFound) throw Err_.new_wo_type("could not find 'CREATE TABLE'");
bgn = Bry_find_.Find_fwd(raw, Byte_ascii.Nl, bgn); if (bgn == Bry_.NotFound) throw Err_.new_wo_type("could not find new line after 'CREATE TABLE'");
int bgn = Bry_find_.Find_fwd(raw, Tkn_create_table); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find 'CREATE TABLE'");
bgn = Bry_find_.Find_fwd(raw, Byte_ascii.Nl, bgn); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find new line after 'CREATE TABLE'");
bgn += Int_.Const_position_after_char;
int end = Bry_find_.Find_fwd(raw, Tkn_unique_index); if (end == Bry_.NotFound) throw Err_.new_wo_type("could not find 'UNIQUE KEY'");
end = Bry_find_.Find_bwd(raw, Byte_ascii.Nl, end); if (bgn == Bry_.NotFound) throw Err_.new_wo_type("could not find new line before 'UNIQUE KEY'");
int end = Bry_find_.Find_fwd(raw, Tkn_unique_index); if (end == Bry_find_.Not_found) throw Err_.new_wo_type("could not find 'UNIQUE KEY'");
end = Bry_find_.Find_bwd(raw, Byte_ascii.Nl, end); if (bgn == Bry_find_.Not_found) throw Err_.new_wo_type("could not find new line before 'UNIQUE KEY'");
Parse_lines(Bry_.Mid(raw, bgn, end));
return this;
}
@@ -39,9 +39,9 @@ class Sql_fld_mgr {
int fld_idx = 0;
for (int i = 0; i < lines_len; i++) {
byte[] line = lines[i];
int bgn = Bry_find_.Find_fwd(line, Byte_ascii.Tick); if (bgn == Bry_.NotFound) continue; // skip blank lines
int bgn = Bry_find_.Find_fwd(line, Byte_ascii.Tick); if (bgn == Bry_find_.Not_found) continue; // skip blank lines
bgn += Int_.Const_position_after_char;
int end = Bry_find_.Find_fwd(line, Byte_ascii.Tick, bgn); if (end == Bry_.NotFound) continue; // skip blank lines
int end = Bry_find_.Find_fwd(line, Byte_ascii.Tick, bgn); if (end == Bry_find_.Not_found) continue; // skip blank lines
byte[] key = Bry_.Mid(line, bgn, end);
Sql_fld_itm fld = new Sql_fld_itm(fld_idx++, key);
hash.Add(fld.Key(), fld);

View File

@@ -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.bldrs.syncs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
class Xob_sync_grp {
private final Ordered_hash itms = Ordered_hash_.New();
public Xob_sync_grp Ctor_itm(DateAdp dump_time, DateAdp upload_time) {

View File

@@ -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.bldrs.wiki_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.log_msgs.*;
import gplx.langs.phps.*; import gplx.xowa.langs.bldrs.*;
class Xob_subpage_parser {
public Xob_subpage_wiki[] Parse(byte[] src) {

View File

@@ -20,7 +20,7 @@ public class Xoi_wiki_props_alias {
public int Id() {return id;} private int id;
public String Alias() {return alias;} private String alias;
public Xoi_wiki_props_alias Init_by_ctor(int id, String alias) {this.id = id; this.alias = alias; return this;}
public void Init_by_xml(gplx.xmls.XmlNde ns_nde) {
public void Init_by_xml(gplx.langs.xmls.XmlNde ns_nde) {
this.id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
this.alias = String_.Replace(String_.Replace(ns_nde.Text_inner(), " ", "_"), "'", "''");
}

View File

@@ -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.bldrs.wiki_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.xmls.*; import gplx.ios.*;
import gplx.langs.xmls.*; import gplx.core.ios.*;
public class Xoi_wiki_props_api {
private IoEngine_xrg_downloadFil download_args = IoEngine_xrg_downloadFil.new_("", Io_url_.Empty);
public String Api_src(String wiki_domain) {
@@ -26,15 +26,15 @@ public class Xoi_wiki_props_api {
return download_args.Exec_as_bry(src);
}
public void Build_cfg(Bry_bfr bfr, Xoi_wiki_props_wiki wiki) {
bfr.Add_str_a7("app.bldr.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
bfr.Add_str_a7("app.bldr.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str_a7("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
int len = 0;
len = wiki.Alias_ary().length;
for (int i = 0; i < len; i++) {
Xoi_wiki_props_alias alias = wiki.Alias_ary()[i];
bfr.Add_int_variable(alias.Id()).Add_byte_pipe().Add_str(alias.Alias()).Add_byte_nl();
bfr.Add_int_variable(alias.Id()).Add_byte_pipe().Add_str_u8(alias.Alias()).Add_byte_nl();
}
bfr.Add_str_a7("\");');\n");
bfr.Add_str_a7("app.bldr.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str("').new_cmd_('wiki.ns_mgr.subpages', \"");
bfr.Add_str_a7("app.bldr.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str_a7("').new_cmd_('wiki.ns_mgr.subpages', \"");
len = wiki.Ns_ary().length;
boolean first = true;
for (int i = 0; i < len; i++) {
@@ -45,7 +45,7 @@ public class Xoi_wiki_props_api {
}
else
bfr.Add_byte_nl();
bfr.Add_str_a7("ns_mgr.get_by_id_or_new(").Add_int_variable(ns.Id()).Add_str(").subpages_enabled_('y');");
bfr.Add_str_a7("ns_mgr.get_by_id_or_new(").Add_int_variable(ns.Id()).Add_str_a7(").subpages_enabled_('y');");
}
}
bfr.Add_str_a7("\");\n");

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.wiki_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.core.strings.*;
import gplx.xmls.*;
import gplx.langs.xmls.*;
import gplx.xowa.bldrs.cfgs.*;
public class Xoi_wiki_props_api_tst {
private Xoi_wiki_props_fxt fxt = new Xoi_wiki_props_fxt();
@@ -47,7 +47,7 @@ public class Xoi_wiki_props_api_tst {
// .Ns_ary_(fxt.ns_(0, false), fxt.ns_(1, true))
// , "");
// }
// Tfds.Eq_str_lines(Query_ns(protocol, gplx.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
// Tfds.Eq_str_lines(Query_ns(protocol, gplx.core.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
// ( "app.bldr.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
// , "4|WP"
// , "5|WT"
@@ -82,7 +82,7 @@ class Xoi_wiki_props_fxt {
bfr.Add_str_a7("aliases").Add_byte_nl();
for (int i = 0; i < len; i++) {
Xoi_wiki_props_alias alias = v.Alias_ary()[i];
bfr.Add_int_variable(alias.Id()).Add_byte_pipe().Add_str(alias.Alias()).Add_byte_nl();
bfr.Add_int_variable(alias.Id()).Add_byte_pipe().Add_str_u8(alias.Alias()).Add_byte_nl();
}
bfr.Add_str_a7("ns").Add_byte_nl();
len = v.Ns_ary().length;

View File

@@ -20,7 +20,7 @@ public class Xoi_wiki_props_ns {
public int Id() {return id;} private int id;
public boolean Subpages_enabled() {return subpages_enabled;} private boolean subpages_enabled;
public Xoi_wiki_props_ns Init_by_ctor(int id, boolean subpages_enabled) {this.id = id; this.subpages_enabled = subpages_enabled; return this;}
public void Init_by_xml(gplx.xmls.XmlNde ns_nde) {
public void Init_by_xml(gplx.langs.xmls.XmlNde ns_nde) {
this.id = Int_.parse(ns_nde.Atrs().FetchValOr("id", "-1"));
this.subpages_enabled = ns_nde.Atrs().Fetch_or_null("subpages") != null;// per api, subpages="" means ns has subpages; no subpages attribute means no subpages
}

View File

@@ -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.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.flds.*; import gplx.ios.*;
import gplx.core.flds.*; import gplx.core.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_();

View File

@@ -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.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.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;
@@ -44,9 +44,9 @@ public abstract class Xob_itm_dump_base extends Xob_itm_basic_base {
}
protected void Flush_dump() {Io_mgr.Instance.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);
if (ctx.Match(k, Invk_sort_mem_len_)) sort_mem_len = gplx.core.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_dump_fil_len_)) dump_fil_len = gplx.core.ios.Io_size_.Load_int_(m);
else if (ctx.Match(k, Invk_make_fil_len_)) make_fil_len = gplx.core.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;

View File

@@ -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.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.flds.*; import gplx.ios.*; import gplx.xowa.wikis.tdbs.*;
import gplx.core.flds.*; import gplx.core.ios.*; import gplx.xowa.wikis.tdbs.*;
import gplx.xowa.bldrs.sqls.*; import gplx.xowa.wikis.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;

View File

@@ -20,7 +20,7 @@ import gplx.core.net.*;
public class Xowm_api_mgr {
public static byte[] Call_by_qarg(Gfo_usr_dlg usr_dlg, Gfo_inet_conn inet_conn, String domain_str, String api_args) {return Call_by_url(usr_dlg, inet_conn, domain_str, Bld_api_url(domain_str, api_args));}
public static byte[] Call_by_url (Gfo_usr_dlg usr_dlg, Gfo_inet_conn inet_conn, String domain_str, String url) {
if (!gplx.ios.IoEngine_system.Web_access_enabled) return null;
if (!gplx.core.ios.IoEngine_system.Web_access_enabled) return null;
usr_dlg.Prog_many("", "", "wm.api:calling; wiki=~{0} api=~{1}", domain_str, url);
byte[] rslt = inet_conn.Download_as_bytes_or_null(url); if (rslt == null) usr_dlg.Warn_many("", "", "wm.api:wmf api returned nothing; api=~{0}", url);
return rslt;

View File

@@ -16,10 +16,10 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.wms.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wms.*;
import gplx.ios.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.downloads.*;
import gplx.core.ios.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.downloads.*;
public abstract class Xoapi_orig_base {
public boolean Api_query_size(Xoapi_orig_rslts rv, Xof_download_wkr download_wkr, Xow_repo_mgr repo_mgr, byte[] ttl, int width, int height) {
if (!gplx.ios.IoEngine_system.Web_access_enabled) return false; // don't check api if download disabled else "download_failed" messages in log (particularly during pkg_make) DATE:2015-02-12
if (!gplx.core.ios.IoEngine_system.Web_access_enabled) return false; // don't check api if download disabled else "download_failed" messages in log (particularly during pkg_make) DATE:2015-02-12
Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
Xof_repo_pair[] repos = repo_mgr.Repos_ary();
int len = repos.length;

View File

@@ -33,7 +33,7 @@ public class Xoapi_orig_wmf extends Xoapi_orig_base {
int xml_len = xml.length;
int pos = 0;
pos = Bry_find_.Find_fwd(xml, Bry_xml_ii , pos, xml_len);
if (pos == Bry_.NotFound) {usr_dlg.Log_many(GRP_KEY, "api_failed", "api failed: ~{0}", String_.new_u8(xml)); return false;}
if (pos == Bry_find_.Not_found) {usr_dlg.Log_many(GRP_KEY, "api_failed", "api failed: ~{0}", String_.new_u8(xml)); return false;}
pos += Bry_xml_ii.length;
byte[] orig_wiki = null, orig_page = null; int orig_w = 0, orig_h = 0;
@@ -48,7 +48,7 @@ public class Xoapi_orig_wmf extends Xoapi_orig_base {
orig_wiki = gplx.xowa.wikis.xwikis.Xow_xwiki_mgr.Get_domain_from_url(url_parser, url, file_url);
byte[] page = Xoa_ttl.Replace_spaces(url.Segs__get_at_nth());
int colon_pos = Bry_find_.Find_fwd(page, Byte_ascii.Colon, 0, page.length);
if (colon_pos != Bry_.NotFound)
if (colon_pos != Bry_find_.Not_found)
page = Bry_.Mid(page, colon_pos + 1, page.length);
orig_page = page;
}
@@ -60,9 +60,9 @@ public class Xoapi_orig_wmf extends Xoapi_orig_base {
private static Gfo_url_parser url_parser = new Gfo_url_parser(); private static Gfo_url url = new Gfo_url();
private static boolean Parse_xml_val(Int_2_ref rv, Gfo_usr_dlg usr_dlg, byte[] xml, int xml_len, int pos, byte[] key) {
int bgn = 0, end = 0;
bgn = Bry_find_.Find_fwd(xml, key, pos, xml_len); if (bgn == Bry_.NotFound) return false;
bgn = Bry_find_.Find_fwd(xml, key, pos, xml_len); if (bgn == Bry_find_.Not_found) return false;
bgn += key.length;
end = Bry_find_.Find_fwd(xml, Byte_ascii.Quote , bgn, xml_len); if (end == Bry_.NotFound) return false;
end = Bry_find_.Find_fwd(xml, Byte_ascii.Quote , bgn, xml_len); if (end == Bry_find_.Not_found) return false;
rv.Val_all_(bgn, end);
return true;
}

View File

@@ -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.bldrs.wms.dumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wms.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.domains.*;
public class Xowm_dump_file {
public Xowm_dump_file(String domain_str, String dump_date, String dump_type_str) {

View File

@@ -20,8 +20,8 @@ import gplx.xowa.wikis.domains.*; import gplx.xowa.bldrs.installs.*;
public class Xowm_dump_file_ {
public static Xowm_dump_file parse(byte[] src) {
int src_len = src.length;
int dash_0 = Bry_find_.Find_fwd(src, Byte_ascii.Dash, 0 , src_len); if (dash_0 == Bry_.NotFound) throw Err_.new_parse_type(Xowm_dump_file.class, String_.new_u8(src));
int dash_1 = Bry_find_.Find_fwd(src, Byte_ascii.Dash, dash_0 + 1 , src_len); if (dash_1 == Bry_.NotFound) throw Err_.new_parse_type(Xowm_dump_file.class, String_.new_u8(src));
int dash_0 = Bry_find_.Find_fwd(src, Byte_ascii.Dash, 0 , src_len); if (dash_0 == Bry_find_.Not_found) throw Err_.new_parse_type(Xowm_dump_file.class, String_.new_u8(src));
int dash_1 = Bry_find_.Find_fwd(src, Byte_ascii.Dash, dash_0 + 1 , src_len); if (dash_1 == Bry_find_.Not_found) throw Err_.new_parse_type(Xowm_dump_file.class, String_.new_u8(src));
byte[] domain_bry = Xow_abrv_wm_.Parse_to_domain_bry(Bry_.Mid(src, 0, dash_0));
return new Xowm_dump_file(String_.new_u8(domain_bry), String_.new_u8(src, dash_0 + 1, dash_1), String_.new_u8(src, dash_1 + 1, src_len));
}
@@ -45,7 +45,7 @@ public class Xowm_dump_file_ {
Xoa_app_.Usr_dlg().Note_many("", "", "wmf.dump:dump date; server_url=~{0} dump_date=~{1}", dump_server, dump_date);
Xoi_mirror_parser mirror_parser = new Xoi_mirror_parser();
String dump_wiki_url = dump_server + String_.new_a7(rv.Dump_abrv()) + "/";
byte[] dump_url_wiki_html = gplx.ios.IoEngine_xrg_downloadFil.new_("", Io_url_.Empty).Exec_as_bry(dump_wiki_url); if (Bry_.Len_eq_0(dump_url_wiki_html)) return;
byte[] dump_url_wiki_html = gplx.core.ios.IoEngine_xrg_downloadFil.new_("", Io_url_.Empty).Exec_as_bry(dump_wiki_url); if (Bry_.Len_eq_0(dump_url_wiki_html)) return;
String[] dump_available_dates = mirror_parser.Parse(String_.new_u8(dump_url_wiki_html));
String dump_dates_latest = Xoi_mirror_parser.Find_last_lte(dump_available_dates, dump_date);
if (String_.Eq(dump_dates_latest, "")) return; // nothing found

View File

@@ -129,7 +129,7 @@ public class Site_core_db {
int len = hash.Count();
for (int i = 0; i < len; ++i) {
Site_namespace_itm itm = (Site_namespace_itm)hash.Get_at(i);
byte case_match = Xow_ns_case_.parse(String_.new_u8(itm.Case_tid()));
byte case_match = Xow_ns_case_.To_tid(String_.new_u8(itm.Case_tid()));
rv.Add_new(itm.Id(), itm.Localized(), case_match, Bool_.N);
}
}

View File

@@ -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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
public class Xob_tmp_wtr {
Xob_tmp_wtr(Xow_ns ns_itm, Io_url_gen url_gen, int fil_max) {

View File

@@ -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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
public interface Xob_tmp_wtr_wkr {
Xob_tmp_wtr Tmp_wtr_new(Xow_ns ns);

View File

@@ -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.bldrs.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.nss.*;
public class Xob_tmp_wtr_wkr__ttl implements Xob_tmp_wtr_wkr {
public Xob_tmp_wtr_wkr__ttl(Io_url temp_dir, int dump_fil_len) {this.temp_dir = temp_dir; this.dump_fil_len = dump_fil_len;} Io_url temp_dir; int dump_fil_len;

View File

@@ -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.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*;
import gplx.core.ios.*;
import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.tdbs.*;
public class Xob_import_cfg {
public Xob_import_cfg(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki; private boolean src_fil_is_bz2 = true;

View File

@@ -1,89 +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.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*; import gplx.xmls.*; // NOTE: gplx.xmls does not support Android; DATE:2013-01-17
import gplx.xowa.wikis.nss.*;
public class Xob_siteinfo_parser {
public static byte[] Siteinfo_extract(gplx.ios.Io_stream_rdr src_rdr) {
Io_buffer_rdr rdr = Io_buffer_rdr.Null;
try {
rdr = Io_buffer_rdr.new_(src_rdr, Io_mgr.Len_mb); // ASSUME: siteInfo is fully contained in the 1st MB of the src_xml
byte[] src = rdr.Bfr();
int bgn = Bry_find_.Find_fwd(src, Bry_siteinfo_bgn, 0) ; if (bgn == Bry_.NotFound) return null;
int end = Bry_find_.Find_fwd(src, Bry_siteinfo_end, bgn); if (end == Bry_.NotFound) return null;
return Bry_.Mid(src, bgn, end + Bry_siteinfo_end.length);
}
catch (Exception e) {Err_.Noop(e); return null;}
finally {rdr.Rls();}
}
public static void Siteinfo_parse(Xowe_wiki wiki, Gfo_usr_dlg usr_dlg, String siteinfo_str) {
XmlDoc xdoc = XmlDoc_.parse(siteinfo_str);
XmlNde root = xdoc.Root();
int root_subs_len = root.SubNdes().Count();
Bry_bfr siteinfo_misc_bfr = Bry_bfr.reset_(512);
for (int i = 0; i < root_subs_len; i++) {
XmlNde sub_nde = root.SubNdes().Get_at(i);
if ( String_.Eq(sub_nde.Name(), "sitename")
|| String_.Eq(sub_nde.Name(), "generator")
|| String_.Eq(sub_nde.Name(), "case")) siteinfo_misc_bfr.Add_str(sub_nde.Text_inner()).Add_byte_pipe();
else if ( String_.Eq(sub_nde.Name(), "base")) {
String mainpage_url = sub_nde.Text_inner();
byte[] mainpage_name = Siteinfo_parse_mainpage(Bry_.new_u8(mainpage_url)); if (mainpage_name == null) throw Err_.new_wo_type("could not extract mainpage", "mainpage", mainpage_url);
wiki.Props().Main_page_(mainpage_name);
}
else if ( String_.Eq(sub_nde.Name(), "namespaces")) {
Siteinfo_parse_ns(wiki, usr_dlg, sub_nde);
}
else if ( String_.Eq(sub_nde.Name(), "#text")) {} // NOTE: JAVA has node names for "#text"
// else throw Err_mgr.Instance.fmt_(GRP_KEY, "siteinfo.root.unknown_sub", "unknown sub for root nde: ~{0}", sub_nde.Name()); // NOTE: do not fail if MW introduces something odd in future (or if JAVA starts picking up other elements)
}
wiki.Props().Siteinfo_misc_(siteinfo_misc_bfr.To_bry_and_clear());
wiki.Props().Bldr_version_(Bry_.new_a7(Xoa_app_.Version));
}
private static byte[] Siteinfo_parse_mainpage(byte[] url) {
byte[] wiki_bry = gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki;
int bgn_pos = Bry_find_.Find_fwd(url, wiki_bry, 0);
if (bgn_pos == Bry_.NotFound) { // "/wiki/" not found; EX: http://mywiki/My_main_page
bgn_pos = Bry_find_.Find_bwd(url, Byte_ascii.Slash); // ASSUME last segment is page
if (bgn_pos == Bry_.NotFound) throw Err_.new_wo_type("could not parse main page url", "url", String_.new_u8(url));
++bgn_pos; // add 1 to position after slash
}
else // "/wiki/" found
bgn_pos += wiki_bry.length; // position bgn after "/wiki/"
return Bry_.Mid(url, bgn_pos, url.length);
}
private static void Siteinfo_parse_ns(Xowe_wiki wiki, Gfo_usr_dlg usr_dlg, XmlNde ns_nde) {
int subs_len = ns_nde.SubNdes().Count();
Xow_ns_mgr ns_mgr = wiki.Ns_mgr();
ns_mgr.Clear(); // NOTE: wipe out any preexisting ns; use siteinfo.xml as definitive list
for (int i = 0; i < subs_len; i++) {
XmlNde sub_nde = ns_nde.SubNdes().Get_at(i);
if (sub_nde.Atrs().Count() == 0) continue; // NOTE: JAVA again has unexpected nodes
try {
int ns_id = Int_.parse(sub_nde.Atrs().FetchValOr("key", ""));
byte case_match = Xow_ns_case_.parse(sub_nde.Atrs().FetchValOr("case", ""));
String name = sub_nde.Text_inner();
ns_mgr.Add_new(ns_id, Bry_.new_u8(name), case_match, false);
}
catch (Exception e) {throw Err_.new_exc(e, "xo", "parse failed", "inner", sub_nde.Text_inner());}
}
ns_mgr.Init_w_defaults();
}
private static final byte[] Bry_siteinfo_bgn = Bry_.new_a7("<siteinfo>"), Bry_siteinfo_end = Bry_.new_a7("</siteinfo>");
static final String GRP_KEY = "xowa.bldr.core.init";
}

View File

@@ -16,20 +16,20 @@ 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.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_xml_page_bldr {
public byte[] Xto_bry() {return bfr.To_bry_and_clear();}
public Io_buffer_rdr XtoByteStreamRdr() {return XtoByteStreamRdr(Io_mgr.Len_kb);}
public Io_buffer_rdr XtoByteStreamRdr(int bfr_len) {
Io_url url = Io_url_.mem_fil_("mem/byteStreamRdr.txt");
Io_mgr.Instance.SaveFilBry(url, bfr.To_bry_and_clear());
return Io_buffer_rdr.new_(gplx.ios.Io_stream_rdr_.file_(url), bfr_len);
return Io_buffer_rdr.new_(gplx.core.ios.Io_stream_rdr_.file_(url), bfr_len);
}
public Bry_bfr Bfr() {return bfr;} Bry_bfr bfr = Bry_bfr.new_();
public Xob_xml_page_bldr Upd(String find, String repl) {
String all = bfr.To_str_and_clear();
all = String_.Replace(all, find, repl);
bfr.Add_str(all);
bfr.Add_str_u8(all);
return this;
}
public Xob_xml_page_bldr Add_ary(Xowd_page_itm... ary) {

View File

@@ -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.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.btries.*; import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.core.btries.*; import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.wikis.nss.*;
public class Xob_xml_parser {
Btrie_fast_mgr trie = Xob_xml_parser_.trie_(); Bry_bfr data_bfr = Bry_bfr.new_(); DateAdp_parser date_parser = DateAdp_parser.new_();
@@ -44,7 +44,7 @@ public class Xob_xml_parser {
fil.Bfr_load_from(refill_pos); // refill src from pos;
src_len = fil.Bfr_len();
}
if (pos >= src_len) return Bry_.NotFound; // no more src left; should only happen at end of file
if (pos >= src_len) return Bry_find_.Not_found; // no more src left; should only happen at end of file
byte b = src[pos];
Object o = trie.Match_bgn_w_byte(b, src, pos, src_len);
if (o == null) { // text_data; not an xml_nde (<id>), xml_escape (&lt;), or tab

View File

@@ -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.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.ios.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
import org.junit.*; import gplx.core.ios.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_xml_parser_tst {
@Before public void init() {
Io_mgr.Instance.InitEngine_mem();
@@ -107,9 +107,9 @@ public class Xob_xml_parser_tst {
}
@Test public void Root() {
Xowd_page_itm doc = doc_(1, "a", "a", Date_1);
page_bldr.Bfr().Add_str("<root>\n");
page_bldr.Bfr().Add_str_a7("<root>\n");
page_bldr.Add(doc);
page_bldr.Bfr().Add_str("</root>");
page_bldr.Bfr().Add_str_a7("</root>");
fil = page_bldr.XtoByteStreamRdr();
tst_parse(fil, doc, 0);
}