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

View File

@@ -16,14 +16,14 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.ios.*;
import gplx.core.json.*;
import gplx.ios.*; import gplx.core.net.*;
import gplx.langs.jsons.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.apis.*;
import gplx.xowa.bldrs.css.*;
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.urls.encoders.*;
import gplx.langs.htmls.encoders.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wmfs.*;
import gplx.xowa.wms.*;
import gplx.xowa.html.hrefs.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.js.*; import gplx.xowa.html.bridges.*;
import gplx.xowa.users.*;
public interface Xoa_app {
@@ -48,4 +48,5 @@ public interface Xoa_app {
Bry_bfr_mkr Utl__bfr_mkr();
Url_encoder_mgr Utl__encoder_mgr();
Json_parser Utl__json_parser();
Gfo_inet_conn Utl__inet_conn();
}

View File

@@ -17,10 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.core.consoles.*; import gplx.dbs.*; import gplx.ios.*; import gplx.gfui.*;
import gplx.xowa.apps.*; import gplx.xowa.langs.*; import gplx.xowa.users.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.gfss.*; import gplx.xowa.langs.*; import gplx.xowa.users.*;
import gplx.xowa.files.*; import gplx.xowa.html.hdumps.*; import gplx.xowa.html.hdumps.core.*;
import gplx.xowa.gui.views.boots.*;
import gplx.xowa.urls.encoders.*;
import gplx.langs.htmls.encoders.*;
public class Xoa_app_ {
public static void Run(String... args) {
try {
@@ -58,7 +58,7 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
public static final String Version = "2.9.2.1";
public static final String Version = "2.9.3.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";
@@ -125,6 +125,8 @@ class Xoa_app_boot_mgr {
, App_cmd_arg.opt_("server_port_send").Example_("55001").Note_("applies to --app_mode server; port where xowa server will send messages; clients should listen for messages from this port")
, App_cmd_arg.opt_("http_server_port").Example_("8080").Note_("applies to --app_mode http_server; port used by http_server; default is 8080")
, App_cmd_arg.opt_("http_server_home").Example_("home/wiki/Main_Page").Note_("applies to --app_mode http_server; default home page for root address. EX: navigating to localhost:8080 will navigate to localhost:8080/home/wiki/Main_Page")
, App_cmd_arg.opt_("http_server.max_clients").Example_("15").Note_("applies to --app_mode http_server; limits maximum number of concurrent connections; default is 0 (no limit)")
, App_cmd_arg.opt_("http_server.max_clients_timeout").Example_("50").Note_("applies to --app_mode http_server; time in milliseconds to wait before checking again to see if a connection is free; default is 50 (wait 50 ms)")
, App_cmd_arg.sys_header_("show_license").Dflt_(true)
, App_cmd_arg.sys_args_("show_args").Dflt_(true)
, App_cmd_arg.sys_help_()
@@ -163,6 +165,8 @@ class Xoa_app_boot_mgr {
int server_port_send = args_mgr.Args_get("server_port_send").Val_as_int_or(55001);
int http_server_port = args_mgr.Args_get("http_server_port").Val_as_int_or(8080);
String http_server_home = args_mgr.Args_get("http_server_home").Val_as_str_or("home/wiki/Main_Page");
int http_server_max_clients = args_mgr.Args_get("http_server.max_clients").Val_as_int_or(0);
int http_server_max_clients_timeout = args_mgr.Args_get("http_server.max_clients_timeout").Val_as_int_or(50);
Xoa_app_.Op_sys_str = args_mgr.Args_get("bin_dir_name").Val_as_str_or(Bin_dir_name());
Xoa_app_.User_agent = String_.Format("XOWA/{0} ({1}) [gnosygnu@gmail.com]", Xoa_app_.Version, Xoa_app_.Op_sys_str);
String cmd_text = args_mgr.Args_get("cmd_text").Val_as_str_or(null);
@@ -179,8 +183,10 @@ class Xoa_app_boot_mgr {
if (launch_url != null)
app.Api_root().App().Startup().Tabs().Manual_(launch_url);
app.Tcp_server().Rdr_port_(server_port_recv).Wtr_port_(server_port_send);
app.Http_server().Port_(http_server_port);
app.Http_server().Home_(http_server_home);
gplx.xowa.servers.http.Http_server_mgr server_mgr = app.Http_server();
server_mgr.Port_(http_server_port);
server_mgr.Home_(http_server_home);
server_mgr.Wkr_pool().Init(http_server_max_clients, http_server_max_clients_timeout);
app.Init_by_app(); chkpoint = "init_gfs";
}
catch (Exception e) {usr_dlg.Warn_many("", "", "app init failed: ~{0} ~{1}", chkpoint, Err_.Message_gplx_full(e));}

View File

@@ -17,6 +17,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.dbs.*;
import gplx.xowa.bldrs.*;
import gplx.xowa.langs.*;
import gplx.xowa.nss.*;
import gplx.xowa.apps.*; import gplx.xowa.files.exts.*;
import gplx.xowa.wikis.domains.*;
public class Xoa_app_fxt {

View File

@@ -16,7 +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; import gplx.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*;
import gplx.xowa.nss.*;
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.wikis.ttls.*;
public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.MW: Ttl.php|secureAndSplit;
public Xow_ns Ns() {return ns;} private Xow_ns ns;
@@ -85,7 +86,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
}
public byte[] Page_txt_wo_qargs() { // assume that no Special page has non-ascii characters
int full_txt_len = full_txt.length;
int ques_pos = Bry_finder.Find_bwd(full_txt, Byte_ascii.Question, full_txt_len, page_bgn);
int ques_pos = Bry_find_.Find_bwd(full_txt, Byte_ascii.Question, full_txt_len, page_bgn);
return Bry_.Mid(full_txt, page_bgn, ques_pos == Bry_.NotFound ? full_txt_len : ques_pos);
}
public static Xoa_ttl parse(Xowe_wiki wiki, int ns_id, byte[] ttl) {
@@ -99,7 +100,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
// $dbkey = preg_replace( '/[ _\xA0\x{1680}\x{180E}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}]+/u', '_', $dbkey );
private static final int Char__bidi = 1, Char__ws = 2;
private static final Btrie_slim_mgr char_trie = Btrie_slim_mgr.cs()
.Add_many_int(Char__bidi , Bry_.ints_(0xE2, 0x80, 0x8E), Bry_.ints_(0xE2, 0x80, 0x8F), Bry_.ints_(0xE2, 0x80, 0xAA), Bry_.ints_(0xE2, 0x80, 0xAB), Bry_.ints_(0xE2, 0x80, 0xAC), Bry_.ints_(0xE2, 0x80, 0xAD), Bry_.ints_(0xE2, 0x80, 0xAE))
.Add_many_int(Char__bidi , Bry_.new_ints(0xE2, 0x80, 0x8E), Bry_.new_ints(0xE2, 0x80, 0x8F), Bry_.new_ints(0xE2, 0x80, 0xAA), Bry_.new_ints(0xE2, 0x80, 0xAB), Bry_.new_ints(0xE2, 0x80, 0xAC), Bry_.new_ints(0xE2, 0x80, 0xAD), Bry_.new_ints(0xE2, 0x80, 0xAE))
.Add_many_int(Char__ws , "\u00A0", "\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u2028", "\u2029", "\u202F", "\u205F", "\u3000")
;
public static Xoa_ttl new_(Xowe_wiki wiki, Gfo_msg_log msg_log, byte[] src, int bgn, int end) {
@@ -177,7 +178,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
byte[] ns_name = ns.Name_txt();
int ns_name_len = ns_name.length;
int tmp_bfr_end = bfr.Len();
if (!Bry_.Eq(ns_name, bfr.Bfr(), ltr_bgn, tmp_bfr_end) && ns_name_len == tmp_bfr_end - ltr_bgn) { // if (a) ns_name != bfr_txt (b) both are same length; note that (b) should not happen, but want to safeguard against mismatched arrays
if (!Bry_.Eq(bfr.Bfr(), ltr_bgn, tmp_bfr_end, ns_name) && ns_name_len == tmp_bfr_end - ltr_bgn) { // if (a) ns_name != bfr_txt (b) both are same length; note that (b) should not happen, but want to safeguard against mismatched arrays
Bry_.Set(bfr.Bfr(), ltr_bgn, tmp_bfr_end, ns_name);
}
ns_bgn = ltr_bgn;
@@ -232,7 +233,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
b_ary = amp_itm.Xml_name_bry();
break;
case Xop_amp_trie_itm.Char_int_null: // &#xx;
int end_pos = Bry_finder.Find_fwd(src, Byte_ascii.Semic, match_pos, end);
int end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Semic, match_pos, end);
if (end_pos == Bry_.NotFound) {} // &# but no terminating ";" noop: defaults to current_byte which will be added below;
else {
b_ary = amp_itm.Xml_name_bry();
@@ -247,7 +248,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
else {
boolean pass = amp_mgr.Parse_as_int(amp_itm.Tid() == Xop_amp_trie_itm.Tid_num_hex, src, end, cur2, match_pos);
if (pass) {
b_ary = gplx.intl.Utf16_.Encode_int_to_bry(amp_mgr.Rslt_val());
b_ary = gplx.core.intls.Utf16_.Encode_int_to_bry(amp_mgr.Rslt_val());
if (b_ary.length == 1 && b_ary[0] == Byte_ascii.Hash) // NOTE: A&#x23;B should be interpreted as A#b; PAGE:en.s:The_English_Constitution_(1894) DATE:2014-09-07
anch_bgn = (txt_bb_len) + 1;
match_pos = amp_mgr.Rslt_pos();
@@ -263,7 +264,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
&& src[cur + 3] == Byte_ascii.Dash
) {
int cur3 = cur + 3;//cur = ttlTrie.Match_pos();
int find = Bry_finder.Find_fwd(src, Xop_comm_lxr.End_ary, cur3, end);
int find = Bry_find_.Find_fwd(src, Xop_comm_lxr.End_ary, cur3, end);
if (find != -1) {
cur = find + Xop_comm_lxr.End_ary.length;
continue;
@@ -341,7 +342,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
if ( ns.Case_match() == Xow_ns_case_.Id_1st
&& wik_bgn == -1 ) { // do not check case if xwiki; EX: "fr:" would have a wik_bgn of 0 (and a wik_end of 3); "A" (and any non-xwiki ttl) would have a wik_bgn == -1
byte char_1st = full_txt[page_bgn];
int char_1st_len = gplx.intl.Utf8_.Len_of_char_by_1st_byte(char_1st);
int char_1st_len = gplx.core.intls.Utf8_.Len_of_char_by_1st_byte(char_1st);
int page_end = page_bgn + char_1st_len;
if ( char_1st_len > 1) { // 1st char is multi-byte char
int full_txt_len = full_txt.length;
@@ -375,30 +376,6 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
public static final int Null_wik_bgn = -1;
public static final Xoa_ttl Null = null;
}
class Xoa_url_encoder {
public byte[] Encode(byte[] src) {
int src_len = src.length;
for (int i = 0; i < src_len; i++) {
byte b = src[i];
switch (b) {
case Byte_ascii.Space: bb.Add(Bry_underline); break;
case Byte_ascii.Amp: bb.Add(Bry_amp); break;
case Byte_ascii.Apos: bb.Add(Bry_apos); break;
case Byte_ascii.Eq: bb.Add(Bry_eq); break;
case Byte_ascii.Plus: bb.Add(Bry_plus); break;
default: bb.Add_byte(b); break;
// FUTURE: html_entities, etc:
}
}
return bb.Xto_bry_and_clear();
}
private static final byte[] Bry_amp = Bry_.new_a7("%26"), Bry_eq = Bry_.new_a7("%3D")
, Bry_plus = Bry_.new_a7("%2B"), Bry_apos = Bry_.new_a7("%27")
, Bry_underline = new byte[] {Byte_ascii.Underline}
;
Bry_bfr bb = Bry_bfr.new_();
public static final Xoa_url_encoder _ = new Xoa_url_encoder(); Xoa_url_encoder() {}
}
class Xoa_ttl_trie {
public static Btrie_fast_mgr new_() {
Btrie_fast_mgr rv = Btrie_fast_mgr.cs();

View File

@@ -54,7 +54,7 @@ public class Xoa_url {
return Bry_.Mid(raw, page_bgn, raw_len);// else take everything after "/wiki/";
}
private int Page_bgn(int raw_len) {
int wiki_pos = Bry_finder.Find_fwd(raw, Xoh_href_.Bry__wiki, 0, raw_len); // look for /wiki/
int wiki_pos = Bry_find_.Find_fwd(raw, Xoh_href_.Bry__wiki, 0, raw_len); // look for /wiki/
return wiki_pos == Bry_.NotFound ? Bry_.NotFound : wiki_pos + Xoh_href_.Bry__wiki.length;
}
public boolean Eq_page(Xoa_url comp) {return Bry_.Eq(wiki_bry, comp.wiki_bry) && Bry_.Eq(page_bry, comp.page_bry) && this.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes) == comp.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes);}

View File

@@ -0,0 +1,42 @@
/*
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; import gplx.*;
public class Xoa_url_encoder {
public byte[] Encode(byte[] src) {
int src_len = src.length;
for (int i = 0; i < src_len; i++) {
byte b = src[i];
switch (b) {
case Byte_ascii.Space: bb.Add(Bry_underline); break;
case Byte_ascii.Amp: bb.Add(Bry_amp); break;
case Byte_ascii.Apos: bb.Add(Bry_apos); break;
case Byte_ascii.Eq: bb.Add(Bry_eq); break;
case Byte_ascii.Plus: bb.Add(Bry_plus); break;
default: bb.Add_byte(b); break;
// FUTURE: html_entities, etc:
}
}
return bb.Xto_bry_and_clear();
}
private static final byte[] Bry_amp = Bry_.new_a7("%26"), Bry_eq = Bry_.new_a7("%3D")
, Bry_plus = Bry_.new_a7("%2B"), Bry_apos = Bry_.new_a7("%27")
, Bry_underline = new byte[] {Byte_ascii.Underline}
;
Bry_bfr bb = Bry_bfr.new_();
public static final Xoa_url_encoder _ = new Xoa_url_encoder(); Xoa_url_encoder() {}
}

View File

@@ -16,17 +16,17 @@ 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; import gplx.*;
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.core.threads.*; import gplx.core.json.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.apps.metas.*; import gplx.xowa.urls.encoders.*; import gplx.xowa.apps.progs.*;
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.apps.metas.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.progs.*; import gplx.xowa.apps.gfss.*;
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.css.*; import gplx.xowa.bldrs.installs.*;
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.fmtrs.*; import gplx.xowa.html.*;
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.apps.fmtrs.*; import gplx.xowa.html.*;
import gplx.xowa.html.hrefs.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.ns_files.*; import gplx.xowa.html.bridges.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.xndes.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.math.*;
import gplx.xowa.parsers.utils.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.servers.tcp.*; import gplx.xowa.servers.http.*;
import gplx.xowa.wmfs.*;
import gplx.xowa.wms.*;
import gplx.xowa.tdbs.*; import gplx.xowa.tdbs.hives.*;
public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xoae_app(Gfo_usr_dlg usr_dlg, Xoa_app_type app_type, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url user_dir, Io_url css_dir, String bin_dir_name) {
@@ -65,22 +65,24 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
this.html__lnki_bldr = new Xoh_lnki_bldr(this, html__href_wtr);
this.html__bridge_mgr = new Xoh_bridge_mgr(utl__json_parser);
}
public Xoa_app_type App_type() {return app_type;} private final Xoa_app_type app_type;
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
public Xof_cache_mgr File__cache_mgr() {return file_mgr.Cache_mgr();}
public Xof_img_mgr File__img_mgr() {return file_mgr.Img_mgr();}
public Io_download_fmt File__download_fmt() {return wmf_mgr.Download_wkr().Download_xrg().Download_fmt();}
public Xoh_href_parser Html__href_parser() {return html__href_parser;} private final Xoh_href_parser html__href_parser = new Xoh_href_parser();
public Xoh_href_wtr Html__href_wtr() {return html__href_wtr;} private final Xoh_href_wtr html__href_wtr = new Xoh_href_wtr();
public Xoh_lnki_bldr Html__lnki_bldr() {return html__lnki_bldr;} private final Xoh_lnki_bldr html__lnki_bldr;
public Xoa_css_extractor Html__css_installer() {return html__css_installer;} private final Xoa_css_extractor html__css_installer = new Xoa_css_extractor();
public Xoh_bridge_mgr Html__bridge_mgr() {return html__bridge_mgr;} private final Xoh_bridge_mgr html__bridge_mgr;
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
public Url_encoder_mgr Utl__encoder_mgr() {return Xoa_app_.Utl__encoder_mgr();}
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
public Xoa_meta_mgr Meta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
public Xoa_app_type App_type() {return app_type;} private final Xoa_app_type app_type;
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
public Xof_cache_mgr File__cache_mgr() {return file_mgr.Cache_mgr();}
public Xof_img_mgr File__img_mgr() {return file_mgr.Img_mgr();}
public Io_download_fmt File__download_fmt() {return wmf_mgr.Download_wkr().Download_xrg().Download_fmt();}
public Xoh_href_parser Html__href_parser() {return html__href_parser;} private final Xoh_href_parser html__href_parser = new Xoh_href_parser();
public Xoh_href_wtr Html__href_wtr() {return html__href_wtr;} private final Xoh_href_wtr html__href_wtr = new Xoh_href_wtr();
public Xoh_lnki_bldr Html__lnki_bldr() {return html__lnki_bldr;} private final Xoh_lnki_bldr html__lnki_bldr;
public Xoa_css_extractor Html__css_installer() {return html__css_installer;} private final Xoa_css_extractor html__css_installer = new Xoa_css_extractor();
public Xoh_bridge_mgr Html__bridge_mgr() {return html__bridge_mgr;} private final Xoh_bridge_mgr html__bridge_mgr;
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
public Url_encoder_mgr Utl__encoder_mgr() {return Xoa_app_.Utl__encoder_mgr();}
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
public Gfo_inet_conn Utl__inet_conn() {return inet_conn;} public void Utl__inet_conn_(Gfo_inet_conn v) {this.inet_conn = v;} private Gfo_inet_conn inet_conn = Gfo_inet_conn_.new_http();
public Xoa_meta_mgr Meta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
public Xoa_parser_mgr Parser_mgr() {return parser_mgr;} private final Xoa_parser_mgr parser_mgr = new Xoa_parser_mgr();
public Xoae_wiki_mgr Wiki_mgr() {return wiki_mgr;} private Xoae_wiki_mgr wiki_mgr;
public Xoa_wiki_mgr Wiki_mgri() {return wiki_mgr;}
@@ -93,7 +95,6 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xob_bldr Bldr() {return bldr;} private Xob_bldr bldr;
public Xow_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Xow_xtn_mgr xtn_mgr;
public Xoapi_root Api_root() {return api_root;} private Xoapi_root api_root;
public Xop_tkn_mkr Tkn_mkr() {return tkn_mkr;} private Xop_tkn_mkr tkn_mkr = new Xop_tkn_mkr();
public Gfo_usr_dlg Usr_dlg() {return Xoa_app_.Usr_dlg();}
public Gfo_usr_dlg__log Log_wtr() {return log_wtr;} private Gfo_usr_dlg__log log_wtr;
public Xoa_gfs_mgr Gfs_mgr() {return Xoa_app_.Gfs_mgr();}

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; import gplx.*;
import gplx.xowa.langs.*;
import gplx.xowa.gui.*; import gplx.xowa.gui.views.*; import gplx.xowa.html.*; import gplx.xowa.pages.*;
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.html.tocs.*;
import gplx.xowa.html.modules.popups.*; import gplx.xowa.html.hdumps.pages.*; import gplx.xowa.xtns.wdatas.pfuncs.*;

View File

@@ -16,9 +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; import gplx.*;
import gplx.core.tests.*;
import gplx.xowa.cfgs.*;
import gplx.xowa.langs.*; import gplx.xowa.html.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.lnkis.*;
import gplx.xowa.files.exts.*; import gplx.xowa.files.repos.*;
import gplx.xowa.nss.*;
import gplx.xowa.tdbs.hives.*;
public class Xop_fxt {
public Xop_fxt() {
@@ -36,11 +39,11 @@ public class Xop_fxt {
app.File_mgr().Repo_mgr().Set("src:wiki", "mem/wiki/repo/src/", wiki.Domain_str()).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
app.File_mgr().Repo_mgr().Set("trg:wiki", "mem/wiki/repo/trg/", wiki.Domain_str()).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2).Primary_(true);
wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_a7("src:wiki"), Bry_.new_a7("trg:wiki"));
ctx = wiki.Ctx();
ctx = wiki.Parser_mgr().Ctx();
mock_wkr.Clear_commons(); // assume all files are in repo 0
wiki.File_mgr().Repo_mgr().Page_finder_(mock_wkr);
parser = wiki.Parser();
tkn_mkr = app.Tkn_mkr();
parser = wiki.Parser_mgr().Main();
this.tkn_mkr = app.Parser_mgr().Tkn_mkr();
ctx.Para().Enabled_n_();
hdom_wtr = wiki.Html_mgr().Html_wtr();
wiki.Html_mgr().Img_suppress_missing_src_(false);
@@ -343,7 +346,7 @@ public class Xop_fxt {
byte[] ttl_bry = Bry_.new_u8(ttl_str);
Xoa_url page_url = Xoa_url.new_(wiki.Domain_bry(), ttl_bry);
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
return wiki.Load_page_by_ttl(page_url, ttl).Data_raw();
return wiki.Data_mgr().Load_page_by_ttl(page_url, ttl).Data_raw();
}
public static void Reg_xwiki_alias(Xowe_wiki wiki, String alias, String domain) {
byte[] domain_bry = Bry_.new_a7(domain);

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; import gplx.*;
import gplx.core.primitives.*;
import gplx.xowa.langs.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.xwikis.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.meta.*; import gplx.fsdb.*;
import gplx.xowa.html.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.hzips.*; import gplx.xowa.html.hdumps.*; import gplx.xowa.html.bridges.dbuis.tbls.*;
import gplx.xowa.parsers.*;
import gplx.xowa.urls.*;
public interface Xow_wiki extends Xow_ttl_parser {
boolean Type_is_edit();
Xoa_app App();
Xol_lang Lang();
byte[] Domain_bry(); // EX: en.wikipedia.org
String Domain_str();
int Domain_tid(); // Xow_domain_type_.Int__wikipedia
byte[] Domain_abrv(); // enwiki
Xow_domain_itm Domain_itm();
Xow_fsys_mgr Fsys_mgr();
Xowd_db_mgr Data__core_mgr();
Xof_fsdb_mode File__fsdb_mode();
Fsdb_db_mgr File__fsdb_core();
Xow_repo_mgr File__repo_mgr();
Xof_orig_mgr File__orig_mgr();
Xof_bin_mgr File__bin_mgr();
Fsm_mnt_mgr File__mnt_mgr();
boolean Html__hdump_enabled();
Xow_hzip_mgr Html__hzip_mgr();
Xohd_hdump_rdr Html__hdump_rdr();
Xoh_page_wtr_mgr_base Html__page_wtr_mgr();
boolean Html__css_installing(); void Html__css_installing_(boolean v);
Xow_mw_parser_mgr Mw_parser_mgr();
Xow_xwiki_mgr Xwiki_mgr();
Xow_wiki_props Props();
void Init_by_wiki();
Xoa_url_parser Utl__url_parser();
}

View File

@@ -15,9 +15,11 @@ 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.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
public class Vnt_mnu_itm {
public Vnt_mnu_itm(byte[] key, byte[] text) {this.key = key; this.text = text;}
public byte[] Key() {return key;} private final byte[] key;
public byte[] Text() {return text;} private final byte[] text;
package gplx.xowa; import gplx.*;
public class Xow_wiki_ {
public static void Rls_mem(Xowe_wiki wiki, boolean clear_ctx) {
wiki.Appe().Free_mem(clear_ctx);
wiki.Cache_mgr().Free_mem_all();
gplx.xowa.xtns.scribunto.Scrib_core.Core_invalidate();
}
}

View File

@@ -0,0 +1,23 @@
/*
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; import gplx.*;
public class Xowa_main {
public static void main(String[] args) {
gplx.xowa.Xoa_app_.Run(args);
}
}

View File

@@ -0,0 +1,274 @@
/*
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; import gplx.*;
import gplx.core.primitives.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.cfgs.*; import gplx.xowa.cfgs.gui.*; import gplx.xowa.urls.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*;
import gplx.xowa.users.*; import gplx.xowa.html.*; import gplx.xowa.users.history.*; import gplx.xowa.specials.*; import gplx.xowa.xtns.*; import gplx.xowa.dbs.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.xowa.files.exts.*;
import gplx.xowa.html.heads.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.hzips.*; import gplx.xowa.html.hdumps.*; import gplx.xowa.html.css.*; import gplx.xowa.html.ns_files.*; import gplx.xowa.html.bridges.dbuis.tbls.*;
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.installs.*; import gplx.xowa.setup.maints.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.utils.*;
import gplx.xowa.gui.views.*;
import gplx.xowa.xtns.gallery.*; import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.tdbs.*; import gplx.xowa.tdbs.hives.*;
public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
private boolean init_in_process = false;
public Xowe_wiki(Xoae_app app, Xol_lang lang, Xow_ns_mgr ns_mgr, Xow_domain_itm domain_itm, Io_url wiki_dir) {
this.ev_mgr = GfoEvMgr.new_(this);
this.app = app; this.lang = lang; this.ns_mgr = ns_mgr;
this.domain_itm = domain_itm; this.domain_str = domain_itm.Domain_str(); this.domain_bry = domain_itm.Domain_bry(); this.domain_tid = domain_itm.Domain_type_id(); this.domain_abrv = Xow_abrv_wm_.To_abrv(domain_itm);
this.fsys_mgr = new Xow_fsys_mgr(wiki_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
this.url__parser = new Xoa_url_parser(this);
this.xwiki_mgr = new Xow_xwiki_mgr(this, url__parser.Url_parser());
this.html_mgr = new Xow_html_mgr(this);
this.html_mgr__hdump_rdr = new Xohd_hdump_rdr(app, this);
this.html_mgr__hdump_wtr = new Xohd_hdump_wtr(app, this);
tdb_fsys_mgr = new Xotdb_fsys_mgr(wiki_dir, ns_mgr);
redirect_mgr = new Xop_redirect_mgr(this);
data_mgr = new Xow_data_mgr(this);
file_mgr = new Xow_file_mgr(this);
parser_mgr = new Xow_parser_mgr(this);
cfg_parser = new Xowc_parser(this);
props.SiteName_(domain_tid).ServerName_(domain_bry);
props.ContentLanguage_(lang.Key_bry());
Pf_func_.Reg(lang.Func_regy(), lang);
special_mgr = new Xows_mgr(this, lang);
stats = new Xow_wiki_stats(this);
sys_cfg = new Xow_sys_cfg(this);
hive_mgr = new Xob_hive_mgr(this);
util = new Xow_html_util(this);
cfg_wiki_core = new Xow_cfg_wiki_core(this);
import_cfg = new Xob_import_cfg(this);
msg_mgr = new Xow_msg_mgr(this, lang);
eval_mgr = new Bfmtr_eval_wiki(this);
fragment_mgr = new Xow_fragment_mgr(this);
xtn_mgr = new Xow_xtn_mgr().Ctor_by_wiki(this);
if (domain_tid == Xow_domain_type_.Int__home) {
wdata_wiki_tid = Xow_domain_type_.Int__wikipedia;
wdata_wiki_lang = Xol_lang_.Key_en;
}
else {
wdata_wiki_tid = domain_tid;
wdata_wiki_lang = domain_itm.Lang_orig_key(); // NOTE: must use orig_key for nowiki; "no" not "nb" DATE:2014-10-07
}
Wdata_wiki_abrv_();
db_mgr = new gplx.xowa.dbs.Xodb_mgr_txt(this, data_mgr);
maint_mgr = new Xow_maint_mgr(this);
cache_mgr = new Xow_cache_mgr(this);
/*if (Bry_.Eq(domain_bry, Xow_domain_itm_.Bry__home))*/ xwiki_mgr.Add_full(domain_bry, domain_bry); // add full name to xwiki_mgr; needed for lookup in home ns; EX: [[home:Help/Contents]]
}
public GfoEvMgr EvMgr() {return ev_mgr;} private final GfoEvMgr ev_mgr;
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
public Xoa_ttl Ttl_parse(byte[] ttl) {return Xoa_ttl.parse(this, ttl);}
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {return Xoa_ttl.parse(this, ns_id, ttl);}
public boolean Type_is_edit() {return Bool_.Y;}
public Xoa_app App() {return app;}
public Xol_lang Lang() {return lang;} private final Xol_lang lang;
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
public String Domain_str() {return domain_str;} private final String domain_str;
public int Domain_tid() {return domain_tid;} private final int domain_tid;
public byte[] Domain_abrv() {return domain_abrv;} private final byte[] domain_abrv;
public Xow_domain_itm Domain_itm() {return domain_itm;} private final Xow_domain_itm domain_itm;
public Xow_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xow_fsys_mgr fsys_mgr;
public Xowd_db_mgr Data__core_mgr() {return db_mgr.Tid() == Xodb_mgr_txt.Tid_txt ? null : this.Db_mgr_as_sql().Core_data_mgr();} // TEST:
public Xof_fsdb_mode File__fsdb_mode() {return file_mgr.Fsdb_mode();}
public Fsdb_db_mgr File__fsdb_core() {return file_mgr.Db_core();}
public Xow_repo_mgr File__repo_mgr() {return file_mgr.Repo_mgr();}
public Xof_orig_mgr File__orig_mgr() {return file_mgr.Orig_mgr();}
public Xof_bin_mgr File__bin_mgr() {return file_mgr.Fsdb_mgr().Bin_mgr();}
public Fsm_mnt_mgr File__mnt_mgr() {return file_mgr.Fsdb_mgr().Mnt_mgr();}
public boolean Html__hdump_enabled() {return html_mgr__hdump_enabled;} private boolean html_mgr__hdump_enabled = Bool_.N;
public Xow_hzip_mgr Html__hzip_mgr() {return html_mgr.Hzip_mgr();}
public Xohd_hdump_rdr Html__hdump_rdr() {return html_mgr__hdump_rdr;} private final Xohd_hdump_rdr html_mgr__hdump_rdr;
public Xoh_page_wtr_mgr_base Html__page_wtr_mgr() {return html_mgr.Page_wtr_mgr();}
public boolean Html__css_installing() {return html__css_installing;} public void Html__css_installing_(boolean v) {html__css_installing = v;} private boolean html__css_installing;
public Xoa_url_parser Utl__url_parser() {return url__parser;} private final Xoa_url_parser url__parser;
public Xow_mw_parser_mgr Mw_parser_mgr() {return mw_parser_mgr;} private final Xow_mw_parser_mgr mw_parser_mgr = new Xow_mw_parser_mgr();
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private final Xow_xwiki_mgr xwiki_mgr;
public Xow_wiki_props Props() {return props;} private final Xow_wiki_props props = new Xow_wiki_props();
public Xow_parser_mgr Parser_mgr() {return parser_mgr;} private final Xow_parser_mgr parser_mgr;
public Xohd_hdump_wtr Html__hdump_wtr() {return html_mgr__hdump_wtr;} private final Xohd_hdump_wtr html_mgr__hdump_wtr;
public Xoae_app Appe() {return app;} private Xoae_app app;
public Xow_gui_mgr Gui_mgr() {return gui_mgr;} private final Xow_gui_mgr gui_mgr = new Xow_gui_mgr();
public Xow_user User() {return user;} private Xow_user user = new Xow_user();
public Xow_data_mgr Data_mgr() {return data_mgr;} private Xow_data_mgr data_mgr;
public Xodb_mgr Db_mgr() {return db_mgr;} private Xodb_mgr db_mgr;
public Xodb_mgr_sql Db_mgr_as_sql() {return (Xodb_mgr_sql)db_mgr;}
public Xows_mgr Special_mgr() {return special_mgr;} private Xows_mgr special_mgr;
public Xow_html_mgr Html_mgr() {return html_mgr;} private Xow_html_mgr html_mgr;
public Xow_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Xow_xtn_mgr xtn_mgr;
public Xow_cache_mgr Cache_mgr() {return cache_mgr;} private Xow_cache_mgr cache_mgr;
public byte[] Commons_wiki_key() {return commons_wiki_key;} private byte[] commons_wiki_key = Xow_domain_itm_.Bry__commons;
public Xob_hive_mgr Hive_mgr() {return hive_mgr;} private Xob_hive_mgr hive_mgr;
public Xow_msg_mgr Msg_mgr() {return msg_mgr;} private Xow_msg_mgr msg_mgr;
public Xow_fragment_mgr Fragment_mgr() {return fragment_mgr;} private Xow_fragment_mgr fragment_mgr;
public Bfmtr_eval_wiki Eval_mgr() {return eval_mgr;} private Bfmtr_eval_wiki eval_mgr;
public Bry_bfr_mkr Utl__bfr_mkr() {return app.Utl__bfr_mkr();}
public byte[] Wdata_wiki_lang() {return wdata_wiki_lang;} private byte[] wdata_wiki_lang;
public void Wdata_wiki_lang_(byte[] v) {this.wdata_wiki_lang = v; Wdata_wiki_abrv_();} // TEST:
public byte[] Wdata_wiki_abrv() {return wdata_wiki_abrv;} private byte[] wdata_wiki_abrv; private int wdata_wiki_tid;
private void Wdata_wiki_abrv_() {
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b128();
Xow_abrv_wm_.To_abrv(bfr, wdata_wiki_lang, Int_obj_ref.new_(wdata_wiki_tid));
wdata_wiki_abrv = bfr.To_bry_and_rls();
}
private Xow_html_util util;
public boolean Init_needed() {return init_needed;} public Xowe_wiki Init_needed_(boolean v) {init_needed = v; return this;} private boolean init_needed = true;
public Xop_redirect_mgr Redirect_mgr() {return redirect_mgr;} private Xop_redirect_mgr redirect_mgr;
public List_adp Rls_list() {if (rls_list == null) rls_list = List_adp_.new_(); return rls_list;} private List_adp rls_list;
public Xow_file_mgr File_mgr() {return file_mgr;} private Xow_file_mgr file_mgr;
public Xow_cfg_wiki_core Cfg_wiki_core() {return cfg_wiki_core;} private Xow_cfg_wiki_core cfg_wiki_core;
public Xob_import_cfg Import_cfg() {return import_cfg;} private Xob_import_cfg import_cfg;
public Xotdb_fsys_mgr Tdb_fsys_mgr() {return tdb_fsys_mgr;} private final Xotdb_fsys_mgr tdb_fsys_mgr;
public Xow_wiki_stats Stats() {return stats;} private Xow_wiki_stats stats;
public Xou_history_cfg Cfg_history() {return cfg_history;} private Xou_history_cfg cfg_history = new Xou_history_cfg();
public Xoh_cfg_gallery Cfg_gallery() {return cfg_gallery;} private Xoh_cfg_gallery cfg_gallery = new Xoh_cfg_gallery();
public Xoh_file_page_wtr Cfg_file_page() {return cfg_file_page;} private Xoh_file_page_wtr cfg_file_page = new Xoh_file_page_wtr();
public Xow_sys_cfg Sys_cfg() {return sys_cfg;} private Xow_sys_cfg sys_cfg;
public Xowc_parser Cfg_parser() {return cfg_parser;} private Xowc_parser cfg_parser;
public boolean Cfg_parser_lnki_xwiki_repos_enabled() {return cfg_parser_lnki_xwiki_repos_enabled;} public Xowe_wiki Cfg_parser_lnki_xwiki_repos_enabled_(boolean v) {cfg_parser_lnki_xwiki_repos_enabled = v; return this;} private boolean cfg_parser_lnki_xwiki_repos_enabled;
public Xoi_dump_mgr Import_mgr() {return import_mgr;} private Xoi_dump_mgr import_mgr = new Xoi_dump_mgr();
public Xow_maint_mgr Maint_mgr() {return maint_mgr;} private Xow_maint_mgr maint_mgr;
public void Clear_for_tests() { // NOTE: these are structures that cache items for PERF; need to be cleared out for multiple test runs
file_mgr.Meta_mgr().Clear();
db_mgr.Load_mgr().Clear();
}
public Xodb_mgr_sql Db_mgr_create_as_sql() {Xodb_mgr_sql rv = new Xodb_mgr_sql(this); db_mgr = rv; return rv;}
public void Init_by_wiki() {Init_assert();}
public Xowe_wiki Init_assert() {if (init_needed) Init_wiki(app.Usere()); return this;}
public void Init_db_mgr() {
Io_url core_db_url = gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(this);
if (core_db_url == null) {
tdb_fsys_mgr.Scan_dirs();
}
else {
Xodb_mgr_sql db_mgr_sql = this.Db_mgr_create_as_sql();
db_mgr_sql.Core_data_mgr().Init_by_load(core_db_url);
file_mgr.Init_file_mgr_by_load(this);
}
}
private void Init_wiki(Xoue_user user) { // NOTE: (a) one-time initialization for all wikis; (b) not called by tests
if (init_in_process) {
app.Usr_dlg().Log_many("", "", "wiki.init: circular call canceled: ~{0}", domain_str);
return; // NOTE: may be called multiple times due to "if (app.Stage() == Xoa_stage_.Tid_launch) init_needed = false;"; TODO: call this only once; DATE:2014-06-07
}
init_in_process = true;
if (app.Stage() == Xoa_stage_.Tid_launch) init_needed = false; // NOTE: only mark inited if app fully launched; otherwise statements in xowa.gfs can fire and prematurely set home to inited; DATE:2013-03-24
Gfo_log_bfr log_bfr = app.Log_bfr(); log_bfr.Add("wiki.init.bgn: " + domain_str);
app.Cfg_mgr().Init(this);
file_mgr.Cfg_download().Enabled_(app.File_mgr().Wmf_mgr().Enabled()); // default download to app global; can be overriden below
app.Gfs_mgr().Run_url_for(this, tdb_fsys_mgr.Cfg_wiki_stats_fil());
Init_db_mgr();
if (!app.Bldr().Import_marker().Chk(this)) {app.Wiki_mgr().Del(domain_bry); init_needed = false; return;} // NOTE: must call after Db_mgr_create_as_sql(); also, must delete wiki from mgr; DATE:2014-08-24
db_mgr.Load_mgr().Load_init(this);
app.Gfs_mgr().Run_url_for(this, tdb_fsys_mgr.Cfg_wiki_core_fil());
gplx.xowa.utls.upgrades.Xoa_upgrade_mgr.Check(this);
// init ns_mgr
if (lang.Init_by_load()) {
if (domain_tid == Xow_domain_type_.Int__wikipedia) // NOTE: if type is wikipedia, add "Wikipedia" as an alias; PAGE:en.w:pt.wikipedia.org/wiki/Página principal which redirects to Wikipedia:Página principal
ns_mgr.Aliases_add(Xow_ns_.Id_project, Xow_ns_.Ns_name_wikipedia);
}
app.Gfs_mgr().Run_url_for(this, app.Fsys_mgr().Cfg_wiki_core_dir().GenSubFil(domain_str + ".gfs")); // NOTE: must be run after lang.Init_by_load b/c lang will reload ns_mgr; DATE:2015-04-17run cfg for wiki by user ; EX: /xowa/user/anonymous/wiki/en.wikipedia.org/cfg/user_wiki.gfs
cfg_parser.Xtns().Itm_pages().Init(ns_mgr); // init ns_mgr for Page / Index ns just before rebuild; usually set by #cfg file
Xow_ns_mgr_.rebuild_(lang, ns_mgr); // always rebuild; may be changed by user_wiki.gfs; different lang will change namespaces; EX: de.wikisource.org will have Seite for File and none of {{#lst}} will work
// push lang changes
fragment_mgr.Evt_lang_changed(lang);
parser_mgr.Main().Init_by_lang(lang);
html_mgr.Init_by_lang(lang);
lang.Vnt_mgr().Init_by_wiki(this);
// other init
Bry_fmtr.Null.Eval_mgr().Enabled_(false); app.Wiki_mgr().Scripts().Exec(this); Bry_fmtr.Null.Eval_mgr().Enabled_(true);
app.Html__css_installer().Install(this, Xowd_css_core_mgr.Key_default);
Html__hdump_enabled_(html_mgr__hdump_enabled);
html_mgr.Init_by_wiki(this);
this.Copy_cfg(app.Usere().Wiki());
Xow_repo_mgr_.Assert_repos(app, this);
xtn_mgr.Init_by_wiki(this);
log_bfr.Add("wiki.init.end");
app.Log_wtr().Log_to_session_direct(log_bfr.Xto_str());
init_in_process = false;
app.Api_root().Wikis().Get(domain_bry).Subscribe(this);
app.Meta_mgr().Init_by_wiki(this);
}
private void Html__hdump_enabled_(boolean v) {
this.html_mgr__hdump_enabled = v;
if (html_mgr__hdump_enabled) {
Xowd_html_tbl.Assert_col__page_html_db_id(Db_mgr_as_sql().Core_data_mgr()); // NOTE: must go above html_mgr.Init_by_wiki b/c Page_load will be done via messages
html_mgr__hdump_rdr.Init_by_db(this.Data__core_mgr());
html_mgr__hdump_wtr.Init_by_db(this.Data__core_mgr());
}
}
public void Rls() {
if (rls_list == null) return;
int len = rls_list.Count();
for (int i = 0; i < len; i++) {
RlsAble rls = (RlsAble)rls_list.Get_at(i);
rls.Rls();
}
}
private void Copy_cfg(Xowe_wiki wiki) {html_mgr.Copy_cfg(wiki.Html_mgr());}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_files)) return file_mgr;
else if (ctx.Match(k, Invk_xwikis)) return xwiki_mgr;
else if (ctx.Match(k, Invk_stats)) return stats;
else if (ctx.Match(k, Invk_props)) return props;
else if (ctx.Match(k, Invk_cfg_gallery_)) return cfg_gallery;
else if (ctx.Match(k, Invk_commons_wiki_)) commons_wiki_key = m.ReadBry("v");
else if (ctx.Match(k, Invk_lang)) return lang;
else if (ctx.Match(k, Invk_lang_)) throw Err_.new_deprecated("wiki.lang_");
else if (ctx.Match(k, Invk_html)) return html_mgr;
else if (ctx.Match(k, Invk_gui)) return gui_mgr;
else if (ctx.Match(k, Invk_cfg_history)) return cfg_history;
else if (ctx.Match(k, Invk_user)) return user;
else if (ctx.Match(k, Invk_data_mgr)) return data_mgr;
else if (ctx.Match(k, Invk_ns_mgr)) return ns_mgr;
else if (ctx.Match(k, Invk_sys_cfg)) return sys_cfg;
else if (ctx.Match(k, Invk_special)) return special_mgr;
else if (ctx.Match(k, Invk_parser)) return cfg_parser;
else if (ctx.Match(k, Invk_msgs)) return msg_mgr;
else if (ctx.Match(k, Invk_util)) return util;
else if (ctx.Match(k, Invk_app)) return app;
else if (ctx.Match(k, Invk_db_mgr)) return db_mgr;
else if (ctx.Match(k, Invk_db_mgr_to_sql_)) this.Db_mgr_create_as_sql();
else if (ctx.Match(k, Invk_import_mgr)) return import_mgr;
else if (ctx.Match(k, Invk_maint)) return maint_mgr;
else if (ctx.Match(k, Invk_domain)) return domain_str;
else if (ctx.Match(k, Invk_xtns)) return xtn_mgr;
else if (ctx.Match(k, Invk_hdump_enabled_)) this.html_mgr__hdump_enabled = m.ReadYn("v");
else if (ctx.Match(k, gplx.xowa.apis.xowa.wikis.langs.Xoap_lang_variants.Evt_current_changed)) lang.Vnt_mgr().Cur_vnt_(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
public static final String
Invk_ZipDirs = "zip_dirs_", Invk_files = "files", Invk_xwikis = "xwikis", Invk_cfg_gallery_ = "cfg_gallery_", Invk_commons_wiki_ = "commons_wiki_", Invk_stats = "stats"
, Invk_lang = "lang", Invk_html = "html", Invk_gui = "gui", Invk_cfg_history = "cfg_history", Invk_user = "user", Invk_data_mgr = "data_mgr", Invk_sys_cfg = "sys_cfg", Invk_ns_mgr = "ns_mgr"
, Invk_special = "special"
, Invk_props = "props", Invk_parser = "parser"
, Invk_msgs = "msgs", Invk_app = "app", Invk_util = "util"
, Invk_xtns = "xtns", Invk_import_mgr = "import"
, Invk_db_mgr_to_sql_ = "db_mgr_to_sql_"
, Invk_domain = "domain", Invk_maint = "maint", Invk_hdump_enabled_ = "hdump_enabled_"
;
public static final String Invk_db_mgr = "db_mgr"; // SERIALIZED:000.sqlite3|xowa_cfg
public static final String Invk_lang_ = "lang_";
}

View File

@@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.xowa.apis.xowa.bldrs.imports.*; import gplx.xowa.wikis.data.*; import gplx.xowa.bldrs.infos.*;
public class Xowe_wiki_ {
public static void Create(Xowe_wiki wiki, long src_fil_len, String src_fil_name) {
wiki.Db_mgr_create_as_sql(); // create db_mgr as sql
Xoapi_import import_api = wiki.Appe().Api_root().Bldr().Wiki().Import();
Xowd_core_db_props db_mgr_props = import_api.New_props(wiki.Domain_str(), src_fil_len);
Xob_info_session info_session = Xob_info_session.new_(import_api.User_name(), wiki.Domain_str(), src_fil_name);
wiki.Db_mgr_as_sql().Core_data_mgr().Init_by_make(db_mgr_props, info_session); // make core_db
}
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*;
import gplx.xowa.apps.*;
import gplx.xowa.apps.gfss.*;
public class Xoa_app_eval_tst {
Xoa_app_eval_fxt fxt = new Xoa_app_eval_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.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*;
import org.junit.*; import gplx.xowa.apps.gfss.*;
public class Xoa_shell_tst {
@Test public void Fetch_page() { // PURPOSE.fix: fetch_page failed with nullRef; DATE:2013-04-12
Xop_fxt parser_fxt = new Xop_fxt();

View File

@@ -0,0 +1,78 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.core.net.*; import gplx.langs.jsons.*;
import gplx.ios.*;
import gplx.dbs.*; import gplx.xowa.apis.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.core.intls.*; import gplx.xowa.users.data.*;
import gplx.xowa.apps.urls.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.bldrs.css.*;
import gplx.xowa.html.hrefs.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.bridges.*;
import gplx.xowa.users.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wms.*;
import gplx.langs.htmls.encoders.*;
public class Xoav_app implements Xoa_app {
public Xoav_app(Gfo_usr_dlg usr_dlg, Xoa_app_type app_type, String plat_name, Io_url root_dir, Io_url file_dir, Io_url css_dir) {
Xoa_app_.Usr_dlg_(usr_dlg); this.usr_dlg = usr_dlg; this.app_type = app_type;
this.fsys_mgr = new Xoa_fsys_mgr(plat_name, root_dir, root_dir.GenSubDir("wiki"), file_dir, css_dir);
this.meta_mgr = new Xoa_meta_mgr(this);
this.file__cache_mgr = new Xof_cache_mgr(usr_dlg, null, null);
this.file__img_mgr = new Xof_img_mgr();
this.wiki_mgr = new Xoav_wiki_mgr(this, utl_case_mgr);
this.utl_msg_log = Gfo_msg_log.Test();
this.html__lnki_bldr = new Xoh_lnki_bldr(this, html__href_wtr);
this.html__bridge_mgr = new Xoh_bridge_mgr(utl__json_parser);
this.user = new Xouv_user("anonymous");
this.api_root = null;
}
public Xou_user User() {return user;} private final Xouv_user user;
public Xoapi_root Api_root() {return api_root;} private final Xoapi_root api_root;
public Xoa_app_type App_type() {return app_type;} private final Xoa_app_type app_type;
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
public Xoav_wiki_mgr Wiki_mgr() {return wiki_mgr;} private final Xoav_wiki_mgr wiki_mgr;
public Xoa_wiki_mgr Wiki_mgri() {return wiki_mgr;}
public Xof_cache_mgr File__cache_mgr() {return file__cache_mgr;} private final Xof_cache_mgr file__cache_mgr;
public Xof_img_mgr File__img_mgr() {return file__img_mgr;} private final Xof_img_mgr file__img_mgr;
public Io_download_fmt File__download_fmt() {return file__download_fmt;} private final Io_download_fmt file__download_fmt = new Io_download_fmt();
public Xoh_href_parser Html__href_parser() {return href_parser;} private final Xoh_href_parser href_parser = new Xoh_href_parser();
public Xoh_href_wtr Html__href_wtr() {return html__href_wtr;} private final Xoh_href_wtr html__href_wtr = new Xoh_href_wtr();
public Xoh_lnki_bldr Html__lnki_bldr() {return html__lnki_bldr;} private final Xoh_lnki_bldr html__lnki_bldr;
public Xoa_css_extractor Html__css_installer() {return html__css_installer;} private final Xoa_css_extractor html__css_installer = new Xoa_css_extractor();
public Xoh_bridge_mgr Html__bridge_mgr() {return html__bridge_mgr;} private final Xoh_bridge_mgr html__bridge_mgr;
public Xoa_meta_mgr Meta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
public Gfo_inet_conn Utl__inet_conn() {return inet_conn;} public void Utl__inet_conn_(Gfo_inet_conn v) {this.inet_conn = v;} private Gfo_inet_conn inet_conn;
public boolean Xwiki_mgr__missing(byte[] domain) {return wiki_mgr.Get_by_domain(domain) == null;}
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; Xoa_app_.Usr_dlg_(usr_dlg);} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Noop;
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
public Url_encoder_mgr Utl__encoder_mgr() {return Xoa_app_.Utl__encoder_mgr();}
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = Xop_amp_mgr.I;
public Xol_case_mgr Utl_case_mgr() {return utl_case_mgr;} private Xol_case_mgr utl_case_mgr = Xol_case_mgr_.U8();
public Url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Url_encoder utl_encoder_fsys = Url_encoder.new_fsys_lnx_();
public Gfo_msg_log Utl_msg_log() {return utl_msg_log;} private Gfo_msg_log utl_msg_log;
public Xoav_url_parser Utl_url_parser_xo() {return utl_url_parser_xo;} private Xoav_url_parser utl_url_parser_xo = new Xoav_url_parser();
public Gfo_url_parser Utl_url_parser_gfo() {return utl_url_parser_gfo;} private final Gfo_url_parser utl_url_parser_gfo = new Gfo_url_parser();
public void Init_by_app(Io_url user_db_url) {
user.Init_db(this, wiki_mgr, user_db_url);
}
}

View File

@@ -0,0 +1,73 @@
/*
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.apps; import gplx.*; import gplx.xowa.*;
import gplx.xowa.*; import gplx.xowa.langs.cases.*; import gplx.xowa.users.data.*;
import gplx.xowa.wikis.*;
public class Xoav_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
private final Xoav_app app; private final Ordered_hash hash = Ordered_hash_.new_bry_();
public Xoav_wiki_mgr(Xoav_app app, Xol_case_mgr case_mgr) {this.app = app;}
public Xowv_wiki Get_by_domain(byte[] domain) {return (Xowv_wiki)hash.Get_by(domain);}
public Xowv_wiki Import_by_fil(Io_url fil) {
Io_url wiki_dir = fil.OwnerDir();
Xowv_wiki rv = Load(Gen_domain_str(fil.NameOnly()), wiki_dir);
app.User().User_db_mgr().Site_mgr().Import(rv.Domain_str(), rv.Domain_str(), wiki_dir.Raw(), "");
return rv;
}
public void Load_by_user_data() {
Xoud_site_row[] ary = app.User().User_db_mgr().Site_mgr().Get_all();
int len = ary.length;
for (int i = 0; i < len; ++i) {
Xoud_site_row itm = ary[i];
Load(itm.Domain(), Io_url_.new_dir_(itm.Path()));
}
}
public Xowv_wiki Load_by_fil(Io_url fil) {
return Load(Gen_domain_str(fil.NameOnly()), fil.OwnerDir());
}
public boolean Has(byte[] key) {return hash.Has(key);}
public Xow_wiki Get_by_key_or_make_init_y(byte[] key) {
Xow_wiki rv = this.Get_by_domain(key);
// if (rv == null) rv = New_wiki(key); // TODO: must init wiki, but need wiki_url; DATE:2015-05-23
return rv;
}
public Xow_wiki Get_by_key_or_make_init_n(byte[] key) {return Get_by_key_or_make_init_y(key);}
public void Load_by_dir(Io_url wiki_root_dir) {
Io_url[] wiki_dirs = Io_mgr.I.QueryDir_args(wiki_root_dir).DirOnly_().ExecAsUrlAry();
for (Io_url wiki_dir : wiki_dirs) {
String wiki_dir_url = wiki_dir.Raw();
if (String_.Has_at_bgn(wiki_dir_url, "#")) continue;
Load(wiki_dir.NameOnly(), wiki_dir);
}
}
private Xowv_wiki Load(String domain_str, Io_url wiki_dir) {
byte[] domain_bry = Bry_.new_u8(domain_str);
Xowv_wiki rv = new Xowv_wiki(app, domain_bry, wiki_dir);
hash.Add_if_dupe_use_nth(domain_bry, rv);
return rv;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_import_by_fil)) return Import_by_fil(Io_url_.new_fil_(m.ReadStr("v")));
else return GfoInvkAble_.Rv_unhandled;
}
public static final String Invk_import_by_fil = "import_by_fil";
private static String Gen_domain_str(String file_name) {
int dash_pos = String_.FindFwd(file_name, "-");
if (dash_pos != Bry_find_.Not_found) file_name = String_.Mid(file_name, 0, dash_pos);
return file_name;
}
}

View File

@@ -15,7 +15,7 @@ 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.fmtrs; import gplx.*; import gplx.xowa.*;
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public interface Gfo_sort_able {
void Sort(gplx.lists.ComparerAble comparer);
}

View File

@@ -15,7 +15,7 @@ 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.fmtrs; import gplx.*; import gplx.xowa.*;
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_fmtr_itm implements GfoInvkAble {
public Xoa_fmtr_itm(Xoae_app app) {this.app = app;} private Xoae_app app;
public String Src() {return src;} public Xoa_fmtr_itm Src_(String v) {this.src = v; return this;} private String src;

View File

@@ -15,7 +15,7 @@ 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.fmtrs; import gplx.*; import gplx.xowa.*;
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoa_fmtr_itm_tst {
@Before public void init() {fxt.Clear();} private Xoa_fmtr_itm_fxt fxt = new Xoa_fmtr_itm_fxt();
@@ -31,7 +31,7 @@ class Xoa_fmtr_itm_fxt {
app = Xoa_app_fxt.app_();
Xoa_app_fxt.wiki_tst_(app); // create enwiki
itm = new Xoa_fmtr_itm(app);
GfsCore._.MsgParser_(gplx.gfs.Gfs_msg_bldr._);
GfsCore._.MsgParser_(gplx.langs.gfss.Gfs_msg_bldr._);
}
public Xoa_fmtr_itm_fxt Init_src(String v) {itm.Src_(v); return this;}
public Xoa_fmtr_itm_fxt Init_fmt(String v) {itm.Fmt_(Bry_.new_a7(v)); return this;}

View File

@@ -15,7 +15,7 @@ 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.fmtrs; import gplx.*; import gplx.xowa.*;
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.ios.*;
public class Xoa_fmtr_mgr implements GfoInvkAble {
public Xoa_fmtr_mgr(Xoae_app app) {this.app = app;} private Xoae_app app;

View File

@@ -15,7 +15,7 @@ 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.fmtrs; import gplx.*; import gplx.xowa.*;
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_fmtr_sort_mgr implements GfoInvkAble {
private Ordered_hash itms = Ordered_hash_.new_();
private Xoa_fmtr_sort_wkr wkr = new Xoa_fmtr_sort_wkr();

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.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.apps.gfss.*;
import gplx.xowa.wikis.domains.*;
public class Xoa_fsys_mgr implements GfoInvkAble {
public Xoa_fsys_mgr(String plat_name, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url css_dir) {

View File

@@ -0,0 +1,89 @@
/*
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.apps.gfss; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Gfs_bldr {
public Bry_bfr Bfr() {return bfr;} private Bry_bfr bfr = Bry_bfr.new_();
public byte[] Xto_bry() {return bfr.Xto_bry_and_clear();}
public Gfs_bldr Add_byte(byte b) {bfr.Add_byte(b); return this;}
public Gfs_bldr Add_blob(byte[] bry) {bfr.Add(bry); return this;}
public Gfs_bldr Add_proc_init_many(String... ary) {return Add_proc_core_many(false, ary);}
public Gfs_bldr Add_proc_init_one(String itm) {return Add_proc_core_many(false, itm);}
public Gfs_bldr Add_proc_cont_one(String itm) {return Add_proc_core_many(true, itm);}
public Gfs_bldr Add_proc_cont_many(String... ary) {return Add_proc_core_many(true, ary);}
Gfs_bldr Add_proc_core_many(boolean cont, String... ary) {
int ary_len = ary.length;
for (int i = 0; i < ary_len; i++) {
if (i != 0 || cont) bfr.Add_byte(Byte_ascii.Dot);
bfr.Add_str(ary[i]);
}
return this;
}
public Gfs_bldr Add_indent(int i) {bfr.Add_byte_repeat(Byte_ascii.Space, i * 2); return this;}
public Gfs_bldr Add_parens_str(String v) {return Add_parens_str(Bry_.new_u8(v));}
public Gfs_bldr Add_parens_str(byte[] v) {return this.Add_paren_bgn().Add_arg_str(v).Add_paren_end();}
public Gfs_bldr Add_parens_str_many(String... ary) {
this.Add_paren_bgn();
int len = ary.length;
for (int i = 0; i < len; i++) {
if (i != 0) this.Add_comma();
this.Add_arg_str(Bry_.new_u8(ary[i]));
}
this.Add_paren_end();
return this;
}
public Gfs_bldr Add_arg_int(int v) {bfr.Add_int_variable(v); return this;}
public Gfs_bldr Add_arg_yn(boolean v) {Add_quote_0(); bfr.Add_byte(v ? Byte_ascii.Ltr_y : Byte_ascii.Ltr_n); Add_quote_0(); return this;}
public Gfs_bldr Add_arg_str(byte[] v) {bfr.Add_byte(Byte_ascii.Apos); Add_str_escape_apos(bfr, v); bfr.Add_byte(Byte_ascii.Apos); return this;}
public Gfs_bldr Add_indent() {bfr.Add_byte(Byte_ascii.Space).Add_byte(Byte_ascii.Space); return this;}
public Gfs_bldr Add_nl() {bfr.Add_byte_nl(); return this;}
public Gfs_bldr Add_comma() {bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space); return this;}
public Gfs_bldr Add_curly_bgn_nl() {bfr.Add_byte(Byte_ascii.Space).Add_byte(Byte_ascii.Curly_bgn).Add_byte_nl(); return this;}
public Gfs_bldr Add_curly_end_nl() {bfr.Add_byte(Byte_ascii.Curly_end).Add_byte_nl(); return this;}
public Gfs_bldr Add_paren_bgn() {bfr.Add_byte(Byte_ascii.Paren_bgn); return this;}
public Gfs_bldr Add_paren_end() {bfr.Add_byte(Byte_ascii.Paren_end); return this;}
public Gfs_bldr Add_quote_xtn_bgn() {bfr.Add(Bry_xquote_bgn); return this;}
public Gfs_bldr Add_quote_xtn_end() {bfr.Add(Bry_xquote_end); return this;}
public Gfs_bldr Add_quote_xtn_apos_bgn() {bfr.Add_byte(Byte_ascii.Paren_bgn).Add_byte(Byte_ascii.Apos).Add_byte(Byte_ascii.Nl); return this;}
public Gfs_bldr Add_quote_xtn_apos_end() {bfr.Add_byte(Byte_ascii.Apos).Add_byte(Byte_ascii.Paren_end).Add_byte(Byte_ascii.Semic).Add_byte(Byte_ascii.Nl); return this;}
public Gfs_bldr Add_quote_0() {bfr.Add_byte(Byte_ascii.Apos); return this;}
public Gfs_bldr Add_term_nl() {bfr.Add(Bry_semic_nl); return this;}
public Gfs_bldr Add_eq_str(String k, byte[] v) {
bfr.Add_str(k);
bfr.Add(Bry_eq);
bfr.Add_byte_apos();
bfr.Add(v);
bfr.Add_byte_apos();
bfr.Add(Bry_semic_nl);
return this;
}
private static final byte[] Bry_eq = Bry_.new_a7(" = "), Bry_semic_nl = Bry_.new_a7(";\n");
private void Add_str_escape_apos(Bry_bfr bfr, byte[] src) {
int len = src.length;
for (int i = 0; i < len; i++) {
byte b = src[i];
if (b == Byte_ascii.Apos)
bfr.Add_byte(Byte_ascii.Apos).Add_byte(Byte_ascii.Apos);
else
bfr.Add_byte(b);
}
}
public static final byte[]
Bry_xquote_bgn = Bry_.new_a7("<:['\n")
, Bry_xquote_end = Bry_.new_a7("']:>\n")
;
}

View File

@@ -15,8 +15,8 @@ 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.apps; import gplx.*; import gplx.xowa.*;
import gplx.gfs.*;
package gplx.xowa.apps.gfss; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.langs.gfss.*;
import gplx.xowa.users.*; import gplx.xowa.apps.fsys.*;
public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
private final GfoInvkAble root_invk; private final Xoa_fsys_mgr app_fsys_mgr; private final Xou_fsys_mgr usr_fsys_mgr;
@@ -44,7 +44,7 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
Gfo_usr_dlg_.I.Warn_many("", "", "invalid gfs; obsoleting: src=~{0} err=~{1}", url.Raw(), Err_.Message_gplx_full(e));
}
}
public GfoMsg Parse_root_msg(String v) {return gplx.gfs.Gfs_msg_bldr._.ParseToMsg(v);}
public GfoMsg Parse_root_msg(String v) {return gplx.langs.gfss.Gfs_msg_bldr._.ParseToMsg(v);}
public Gfs_wtr Wtr() {return wtr;} private Gfs_wtr wtr = new Gfs_wtr();
public void Run_url(Io_url url) {
Run_url_for(GfsCore._.Root(), url);
@@ -97,11 +97,11 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
return this;
} private static final String Invk_run_file_by_type = "run_file_by_type", Invk_fail_if_unhandled_ = "fail_if_unhandled_", Invk_txns = "txns";
public static void Msg_parser_init() {
GfsCore._.MsgParser_(gplx.gfs.Gfs_msg_bldr._);
GfsCore._.MsgParser_(gplx.langs.gfss.Gfs_msg_bldr._);
}
public static byte[] Cfg_save_escape(String v) {return Cfg_save_escape(Bry_.new_u8(v));}
public static byte[] Cfg_save_escape(byte[] v) {
return Bry_finder.Find_fwd(v, Byte_ascii.Apos) == Bry_.NotFound ? v : Bry_.Replace(v, Bry_apos_1, Bry_apos_2);
return Bry_find_.Find_fwd(v, Byte_ascii.Apos) == Bry_.NotFound ? v : Bry_.Replace(v, Bry_apos_1, Bry_apos_2);
} static final byte[] Bry_apos_1 = Bry_.new_a7("'"), Bry_apos_2 = Bry_.new_a7("''");
public static String Build_code(String... ary) {
int len = ary.length;

View File

@@ -15,8 +15,8 @@ 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.apps; import gplx.*; import gplx.xowa.*;
import gplx.php.*;
package gplx.xowa.apps.gfss; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.langs.phps.*;
public class Xoa_gfs_php_mgr {
public static byte[] Xto_php(Bry_bfr bfr, boolean escape_backslash, byte[] src) {
int len = src.length;
@@ -67,8 +67,8 @@ public class Xoa_gfs_php_mgr {
}
case Byte_ascii.Curly_bgn: {
int num_bgn = pos + 1;
int num_end = Bry_finder.Find_fwd_while_num(src, num_bgn, len); // +1 to position after {
if ( num_end == Bry_finder.Not_found
int num_end = Bry_find_.Find_fwd_while_num(src, num_bgn, len); // +1 to position after {
if ( num_end == Bry_find_.Not_found
|| num_end == len
|| src[num_end] != Byte_ascii.Curly_end
)

View File

@@ -15,7 +15,7 @@ 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.apps; import gplx.*; import gplx.xowa.*;
package gplx.xowa.apps.gfss; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoa_gfs_php_mgr_tst {
@Before public void init() {fxt.Clear();} private Xoa_gfs_php_mgr_fxt fxt = new Xoa_gfs_php_mgr_fxt();

View File

@@ -16,7 +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.apps.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wmfs.data.*;
import gplx.xowa.nss.*;
import gplx.xowa.wms.sites.*;
public class Xoa_meta_mgr {
private final Xoa_app app;
private final Hash_adp_bry ns__hash = Hash_adp_bry.cs();

View File

@@ -0,0 +1,25 @@
/*
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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoav_url {
public byte[] Wiki_bry() {return wiki_bry;} public void Wiki_bry_(byte[] v) {wiki_bry = v;} private byte[] wiki_bry;
public byte[] Page_bry() {return page_bry;} public void Page_bry_(byte[] v) {page_bry = v;} private byte[] page_bry;
public byte[] Anch_bry() {return anch_bry;} public void Anch_bry_(byte[] v) {anch_bry = v;} private byte[] anch_bry;
public byte[] Qarg_bry() {return qarg_bry;} public void Qarg_bry_(byte[] v) {qarg_bry = v;} private byte[] qarg_bry;
public void Clear() {wiki_bry = page_bry = null;}
}

View File

@@ -0,0 +1,43 @@
/*
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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoav_url_parser {
private static final byte[] Bry_site = Bry_.new_a7("/site/"), Bry_wiki = Bry_.new_a7("/wiki/"), Bry_http = Bry_.new_a7("http:");
public void Parse_xo_href(Xoav_url rv, byte[] src, byte[] cur_wiki_bry) {
rv.Clear();
int pos = Bry_.Has_at_bgn(src, Bry_http) ? Bry_http.length : 0; // DRD: DRD:2.2 adds "http:" to all links
int src_len = src.length;
if (Bry_.Has_at_bgn(src, Bry_site, pos, src_len))
pos = Parse_wiki(rv, src, src_len, pos);
else
rv.Wiki_bry_(cur_wiki_bry);
if (Bry_.Has_at_bgn(src, Bry_wiki, pos, src_len)) pos = Parse_page(rv, src, src_len, pos);
}
private int Parse_wiki(Xoav_url rv, byte[] src, int src_len, int pos) {
int wiki_bgn = pos + Bry_site.length;
int wiki_end = Bry_find_.Find_fwd(src, Byte_ascii.Slash, wiki_bgn, src_len); if (wiki_end == Bry_.NotFound) throw Err_.new_wo_type("could not find wiki_end", "src", String_.new_u8(src));
rv.Wiki_bry_(Bry_.Mid(src, wiki_bgn, wiki_end));
return wiki_end;
}
private int Parse_page(Xoav_url rv, byte[] src, int src_len, int pos) {
int page_bgn = pos + Bry_wiki.length;
int page_end = src_len;
rv.Page_bry_(Bry_.Mid(src, page_bgn, page_end));
return page_end;
}
}

View File

@@ -0,0 +1,43 @@
/*
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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*;
public class Xoav_url_parser_tst {
@Before public void init() {fxt.Clear();} private final Xoav_url_parser_fxt fxt = new Xoav_url_parser_fxt();
@Test public void Page() {
fxt.Exec_parse_xo_href("http:/wiki/Earth").Test_wiki("en.wikipedia.org").Test_page("Earth");
}
@Test public void Site() {
fxt.Exec_parse_xo_href("http:/site/en.wikipedia.org/wiki/Earth").Test_wiki("en.wikipedia.org").Test_page("Earth");
}
}
class Xoav_url_parser_fxt {
private Xoav_url_parser url_parser = new Xoav_url_parser(); private Xoav_url url = new Xoav_url();
public void Clear() {
cur_wiki = Bry_.new_a7("en.wikipedia.org");
url.Clear();
}
public Xoav_url_parser_fxt Init_cur_wiki(String v) {cur_wiki = Bry_.new_u8(v); return this;} private byte[] cur_wiki;
public Xoav_url_parser_fxt Test_wiki(String v) {Tfds.Eq_bry(Bry_.new_u8(v), url.Wiki_bry()); return this;}
public Xoav_url_parser_fxt Test_page(String v) {Tfds.Eq_bry(Bry_.new_u8(v), url.Page_bry()); return this;}
public Xoav_url_parser_fxt Exec_parse_xo_href(String src_str) {
byte[] src_bry = Bry_.new_u8(src_str);
url_parser.Parse_xo_href(url, src_bry, cur_wiki);
return this;
}
}

View File

@@ -18,6 +18,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.primitives.*; import gplx.core.strings.*;
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.dbs.*; import gplx.xowa.specials.search.*; import gplx.xowa.ctgs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.infos.*;
public class Db_mgr_fxt {
public Db_mgr_fxt Ctor_fsys() {bldr_fxt = new Xob_fxt().Ctor(Xoa_test_.Url_root().GenSubDir("root")); return this;}

View File

@@ -0,0 +1,118 @@
/*
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; import gplx.*; import gplx.xowa.*;
import gplx.core.consoles.*;
import gplx.xowa.apps.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.cfgs.*; import gplx.xowa.bldrs.langs.*;
public class Xob_bldr implements GfoInvkAble {
private boolean pause_at_end = false; private long prv_prog_time; private Xob_xml_parser dump_parser;
public Xob_bldr(Xoae_app app) {
this.app = app;
this.cmd_mgr = new Xob_cmd_mgr(this);
this.import_marker = new Xob_import_marker();
this.wiki_cfg_bldr = new Xob_wiki_cfg_bldr(this);
}
public Xoae_app App() {return app;} private final Xoae_app app;
public Xob_cmd_mgr Cmd_mgr() {return cmd_mgr;} private final Xob_cmd_mgr cmd_mgr;
public Gfo_usr_dlg Usr_dlg() {return app.Usr_dlg();}
public int Sort_mem_len() {return sort_mem_len;} public Xob_bldr Sort_mem_len_(int v) {sort_mem_len = v; return this;} private int sort_mem_len = 16 * Io_mgr.Len_mb;
public int Dump_fil_len() {return dump_fil_len;} public Xob_bldr Dump_fil_len_(int v) {dump_fil_len = v; return this;} private int dump_fil_len = 1 * Io_mgr.Len_mb;
public int Make_fil_len() {return make_fil_len;} public Xob_bldr Make_fil_len_(int v) {make_fil_len = v; return this;} private int make_fil_len = 64 * Io_mgr.Len_kb;
public Xob_xml_parser Dump_parser() {if (dump_parser == null) this.dump_parser = new Xob_xml_parser(); return dump_parser;}
public Xob_import_marker Import_marker() {return import_marker;} private Xob_import_marker import_marker;
public Xob_wiki_cfg_bldr Wiki_cfg_bldr() {return wiki_cfg_bldr;} private Xob_wiki_cfg_bldr wiki_cfg_bldr;
public void Pause_at_end_(boolean v) {this.pause_at_end = v;}
public void Print_prog_msg(long cur, long end, int pct_idx, String fmt, Object... ary) {
long now = Env_.TickCount(); if (now - prv_prog_time < 100) return;
this.prv_prog_time = now;
if (pct_idx > -1) ary[pct_idx] = Decimal_adp_.CalcPctStr(cur, end, "00.00");
app.Usr_dlg().Prog_many("", "", fmt, ary);
}
public void Run() {
try {
app.Bldr__running_(true);
app.Launch(); // HACK: bldr will be called by a gfs file which embeds "bldr.run" inside it; need to call Launch though before Run; DATE:2013-03-23
long time_bgn = Env_.TickCount();
int cmd_mgr_len = cmd_mgr.Len();
for (int i = 0; i < cmd_mgr_len; i++) {
Xob_cmd cmd = cmd_mgr.Get_at(i);
cmd.Cmd_init(this);
}
cmd_mgr_len = cmd_mgr.Len(); // NOTE: refresh len b/c other cmds may have added new ones in Cmd_init
for (int i = 0; i < cmd_mgr_len; i++) {
Xob_cmd cmd = cmd_mgr.Get_at(i);
app.Usr_dlg().Note_many("", "", "cmd bgn: ~{0}", cmd.Cmd_key());
long time_cur = Env_.TickCount();
cmd.Cmd_bgn(this);
cmd.Cmd_run();
cmd.Cmd_end();
Env_.GarbageCollect();
app.Usr_dlg().Note_many("", "", "cmd end: ~{0} ~{1}", cmd.Cmd_key(), TimeSpanAdp_.from_(time_cur).XtoStrUiAbbrv());
}
for (int i = 0; i < cmd_mgr_len; i++) {
Xob_cmd cmd = cmd_mgr.Get_at(i);
cmd.Cmd_term();
}
app.Usr_dlg().Note_many("", "", "bldr done: ~{0}", TimeSpanAdp_.from_(time_bgn).XtoStrUiAbbrv());
cmd_mgr.Clear();
if (pause_at_end && !Env_.Mode_testing()) {Console_adp__sys.I.Read_line("press enter to continue");}
}
catch (Exception e) {
app.Bldr__running_(false);
throw Err_.new_exc(e, "bldr", "unknown error");
}
}
private void Cancel() {
int cmd_mgr_len = cmd_mgr.Len();
for (int i = 0; i < cmd_mgr_len; i++) {
Xob_cmd cmd = cmd_mgr.Get_at(i);
cmd.Cmd_end();
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
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_run)) Run();
else if (ctx.Match(k, Invk_cancel)) Cancel();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_cmds = "cmds", Invk_wiki_cfg_bldr = "wiki_cfg_bldr"
, Invk_pause_at_end_ = "pause_at_end_", Invk_sort_mem_len_ = "sort_mem_len_", Invk_dump_fil_len_ = "dump_fil_len_", Invk_make_fil_len_ = "make_fil_len_"
, Invk_run = "run", Invk_cancel = "cancel"
;
}
/*
. make_fil_len: max size of made file; EX: /id/..../0000000001.csv will have max len of 64 KB
. dump_fil_len: max size of temp file; EX: /tmp/.../0000000001.csv will have max len of 1 MB
. sort_mem_len: max size of memory for external merge process; note the following
.. a continguous range of memory of that size will be needed: "Bry_bfr.new_(sort_mem_len)" will be called
.. large sort_mem_len will result in smaller number of merge files
... EX: 16 MB will take en.wikipedia.org's 640 MB title files and generate 40 temp files of 8 MB each
.. number of merge files is number of open file channels during merge process
... 40 is a "reasonable" number; the 1st max is 512 (for older windows OS's) and 2048 for Windows XP; Linux seems to be about 7000
.. small sort_mem_len will use smaller buffer; 16 MB / 40 files -> 400 kb buffer for each file
... do not go under max page size for a given row
... for example, a 100 b buffer will fail if a given row is > 100 b (the entire row won't be loaded in memory)
.. smaller buffer will mean more refills which will require more I/O
... EX: 400 kb buffer will require at least 20 refills to read the entire 8 MB file
*/

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; import gplx.*; import gplx.xowa.*;
import gplx.core.tests.*;
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.tdbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.cmds.texts.tdbs.*;
public class Xob_fxt {
public Xob_fxt Ctor_mem() {

View File

@@ -15,9 +15,11 @@ 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.langs.cnvs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
public class Xol_cnv_itm {
public Xol_cnv_itm(byte[] src, byte[] trg) {this.src = src; this.trg = trg;}
public byte[] Src() {return src;} private byte[] src;
public byte[] Trg() {return trg;} private byte[] trg;
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.xowa.wikis.data.tbls.*;
interface Xowd_page_cmd {
String Cmd_key();
void Cmd_bgn(Xob_bldr bldr);
void Cmd_run(Xowd_page_itm page);
void Cmd_end();
}

View File

@@ -0,0 +1,64 @@
/*
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; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xobd_parser implements Xobd_wkr {
private Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en; ctg.v1 assumes [[Category:
private List_adp wkr_list = List_adp_.new_();
public String Wkr_key() {return KEY;} static final String KEY = "page_parser";
public void Wkr_ini(Xob_bldr bldr) {}
public void Wkr_add(Xobd_parser_wkr wkr) {wkr_list.Add(wkr);}
public void Wkr_bgn(Xob_bldr app) {
int wkr_list_len = wkr_list.Count();
for (int i = 0; i < wkr_list_len; i++) {
Xobd_parser_wkr wkr = (Xobd_parser_wkr)wkr_list.Get_at(i);
wkr.Wkr_bgn(app);
int hooks_len = wkr.Wkr_hooks().Count();
for (int j = 0; j < hooks_len; j++) {
byte[] bry = (byte[])wkr.Wkr_hooks().Get_at(j);
trie.Add_obj(bry, wkr);
}
}
}
public void Wkr_run(Xowd_page_itm page) {
byte[] src = page.Text(); int src_len = src.length;
int pos = 0;
while (true) {
if (pos == src_len) break;
Object o = trie.Match_bgn(src, pos, src_len);
if (o == null)
++pos;
else {
Xobd_parser_wkr wkr = (Xobd_parser_wkr)o;
pos = wkr.Wkr_run(page, src, src_len, pos, trie.Match_pos());
}
}
}
public void Wkr_end() {
int wkr_list_len = wkr_list.Count();
for (int i = 0; i < wkr_list_len; i++) {
Xobd_parser_wkr wkr = (Xobd_parser_wkr)wkr_list.Get_at(i);
wkr.Wkr_end();
}
}
public void Wkr_print() {}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
throw Err_.new_unimplemented();
}
}

View File

@@ -15,11 +15,11 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xow_page_mgr {
public void Create(Xowd_page_tbl core_tbl, Xowd_text_tbl text_tbl, int page_id, int ns_id, byte[] ttl_wo_ns, boolean redirect, DateAdp modified_on, byte[] text_zip_data, int text_raw_len, int random_int, int text_db_id, int html_db_id) {
core_tbl.Insert_cmd_by_batch(page_id, ns_id, ttl_wo_ns, redirect, modified_on, text_raw_len, random_int, text_db_id, html_db_id);
text_tbl.Insert_cmd_by_batch(page_id, text_zip_data);
}
public interface Xobd_parser_wkr extends GfoInvkAble {
Ordered_hash Wkr_hooks();
void Wkr_bgn(Xob_bldr bldr);
int Wkr_run(Xowd_page_itm page, byte[] src, int src_len, int bgn, int end);
void Wkr_end();
}

View File

@@ -0,0 +1,104 @@
/*
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; import gplx.*; import gplx.xowa.*;
import gplx.core.consoles.*;
import gplx.ios.*;
import gplx.xowa.nss.*;
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.parsers.tmpls.*;
public class Xobd_rdr implements Xob_cmd {
private Xob_bldr bldr; private Xowe_wiki wiki;
public Xobd_rdr(Xob_bldr bldr, Xowe_wiki wiki) {this.bldr = bldr; this.wiki = wiki;}
public String Cmd_key() {return KEY;} public static final String KEY = "dump_mgr";
public void Cmd_init(Xob_bldr bldr) {
Xobd_wkr[] wkr_ary = (Xobd_wkr[])wkrs.To_ary(Xobd_wkr.class); int wkr_ary_len = wkr_ary.length;
for (int i = 0; i < wkr_ary_len; i++)
wkr_ary[i].Wkr_ini(bldr);
}
public void Cmd_bgn(Xob_bldr bldr) {}
public void Cmd_end() {}
public void Cmd_run() {
Xobd_wkr[] wkr_ary = (Xobd_wkr[])wkrs.To_ary(Xobd_wkr.class); int wkr_ary_len = wkr_ary.length;
for (int i = 0; i < wkr_ary_len; i++)
wkr_ary[i].Wkr_bgn(bldr);
Io_buffer_rdr fil = Io_buffer_rdr.Null; Xowd_page_itm page = new Xowd_page_itm(); Xow_ns_mgr ns_mgr = wiki.Ns_mgr();
Xob_xml_parser parser = bldr.Dump_parser().Data_bfr_len_(Io_mgr.Len_mb);
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();
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
// 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;
if (cur_pos < prv_pos)
bldr.Print_prog_msg(fil.Fil_pos(), fil_len, 1, optRdrFillFmt, Int_.Xto_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;
try {
for (int i = 0; i < wkr_ary_len; i++)
wkr_ary[i].Wkr_run(page);
}
catch (Exception e) {
Err_.Noop(e);
long dividend = fil.Fil_pos();
if (dividend >= fil_len) dividend = fil_len - 1; // prevent % from going over 100
String msg = Decimal_adp_.CalcPctStr(dividend, fil_len, "00.00") + "|" + String_.new_u8(page.Ttl_full_db()) + "|" + Err_.Message_gplx_log(e) + "|" + Xot_tmpl_wtr.Err_string; Xot_tmpl_wtr.Err_string = "";
bldr.Usr_dlg().Log_wkr().Log_to_session(msg);
Console_adp__sys.I.Write_str_w_nl(msg);
}
}
}
catch (Exception e) {
String msg = Err_.Message_lang(e);
bldr.Usr_dlg().Log_wkr().Log_to_session(msg);
Console_adp__sys.I.Write_str_w_nl(msg);
throw Err_.new_exc(e, "xo", "error while reading dump");
}
finally {fil.Rls();}
bldr.Usr_dlg().Prog_none("", "", "reading completed: performing post-processing clean-up");
for (int i = 0; i < wkr_ary_len; i++)
wkr_ary[i].Wkr_end();
}
public void Cmd_term() {
Xobd_wkr[] wkr_ary = (Xobd_wkr[])wkrs.To_ary(Xobd_wkr.class); int wkr_ary_len = wkr_ary.length;
for (int i = 0; i < wkr_ary_len; i++)
wkr_ary[i].Wkr_print();
}
public void Wkr_add(Xobd_wkr wkr) {wkrs.Add(wkr.Wkr_key(), wkr);} private Ordered_hash wkrs = Ordered_hash_.new_();
public Xobd_wkr Wkr_get(String key) {return (Xobd_wkr)wkrs.Get_by(key);}
public Xobd_parser Page_parser_assert() {
if (page_parser == null) {
page_parser = new Xobd_parser();
this.Wkr_add(page_parser);
}
return page_parser;
} private Xobd_parser page_parser;
public static Io_url Find_fil_by(Io_url dir, String filter) {
Io_url[] fil_ary = Io_mgr.I.QueryDir_args(dir).FilPath_(filter).ExecAsUrlAry();
int fil_ary_len = fil_ary.length;
return fil_ary_len == 0 ? null : fil_ary[fil_ary_len - 1]; // return last
}
int optRdrBfrSize = 8 * Io_mgr.Len_mb;
String optRdrFillFmt = "reading ~{0} MB: ~{1} ~{2}";
static final String GRP_KEY = "xowa.bldr.rdr";
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
throw Err_.new_unimplemented();
}
}

View File

@@ -0,0 +1,27 @@
/*
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; import gplx.*; import gplx.xowa.*;
import gplx.xowa.wikis.data.tbls.*;
public interface Xobd_wkr extends GfoInvkAble {
String Wkr_key();
void Wkr_ini(Xob_bldr bldr);
void Wkr_bgn(Xob_bldr bldr);
void Wkr_run(Xowd_page_itm page);
void Wkr_end();
void Wkr_print();
}

View File

@@ -0,0 +1,43 @@
/*
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; import gplx.*; import gplx.xowa.*;
import gplx.ios.*; import gplx.lists.*;
import gplx.xowa.nss.*;
import gplx.xowa.bldrs.wtrs.*;
public class Xobdc_merger {
public static void Basic(Gfo_usr_dlg usr_dlg, Io_url_gen dump_url_gen, Io_url sort_dir, int memory_max, Io_line_rdr_key_gen key_gen, Io_sort_cmd make_cmd) {Basic(usr_dlg, dump_url_gen, sort_dir, memory_max, Io_sort_split_itm_sorter._, key_gen, make_cmd);}
public static void Basic(Gfo_usr_dlg usr_dlg, Io_url_gen dump_url_gen, Io_url sort_dir, int memory_max, ComparerAble row_comparer, Io_line_rdr_key_gen key_gen, Io_sort_cmd make_cmd) {
Io_sort sort = new Io_sort().Memory_max_(memory_max);
Io_url_gen sort_url_gen = Io_url_gen_.dir_(sort_dir);
sort.Split(usr_dlg, dump_url_gen, sort_url_gen, row_comparer, key_gen);
sort.Merge(usr_dlg, sort_url_gen.Prv_urls(), row_comparer, key_gen, make_cmd);
}
public static void Ns(Gfo_usr_dlg usr_dlg, Xob_tmp_wtr[] ttl_wtrs, String type, Io_url tmp_root, Io_url make_root, int memory_max, Io_line_rdr_key_gen key_gen, Io_make_cmd make_cmd) {
int len = ttl_wtrs.length;
for (int i = 0; i < len; i++) {
Xob_tmp_wtr ttl_wtr = ttl_wtrs[i]; if (ttl_wtr == null) continue;
Xow_ns ns = ttl_wtr.Ns_itm();
Io_url make_dir = make_root.GenSubDir_nest(ns.Num_str(), type);
make_cmd.Make_dir_(make_dir);
Basic(usr_dlg
, ttl_wtr.Url_gen()
, tmp_root.GenSubDir_nest(ns.Num_str(), "sort")
, memory_max, key_gen, make_cmd);
}
}
}

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; import gplx.*; import gplx.xowa.*;
import gplx.ios.*; import gplx.lists.*;
import gplx.xowa.tdbs.*;
class Io_sort_filCmd_reg implements Io_sort_filCmd { // 123|bgn|end|1
public Io_sort_filCmd_reg() {}
public void Bfr_add(Io_line_rdr stream) {
++itm_count;
int key_bgn = stream.Key_pos_bgn(), key_end = stream.Key_pos_end();
Bry_.Copy_by_pos(stream.Bfr(), key_bgn, key_end, prv_key, 0); prv_key_len = key_end - key_bgn;
} byte[] prv_key = new byte[1024]; int prv_key_len = 0;
public void Fil_bgn(Io_line_rdr stream) {
bfr.Add_int_variable(fil_idx++).Add_byte(Byte_ascii.Pipe);
bfr.Add_mid(stream.Bfr(), stream.Key_pos_bgn(), stream.Key_pos_end()).Add_byte(Byte_ascii.Pipe);
}
public void Fil_end() {
bfr.Add_mid(prv_key, 0, prv_key_len).Add_byte(Byte_ascii.Pipe)
.Add_int_variable(itm_count).Add_byte(Byte_ascii.Nl);
itm_count = 0;
}
public void Flush(Io_url fil) {
Io_mgr.I.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 {
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() {
Io_url[] rv = new Io_url[fil_idx];
for (int i = 0; i < fil_idx; i++) {
rv[i] = Xotdb_fsys_mgr.Url_fil(root_dir, fil_idx++, ext);
}
return rv;
}
public void Del_all() {if (Io_mgr.I.ExistsDir(root_dir)) Io_mgr.I.DeleteDirDeep(root_dir);}
public Io_url_gen_nest(Io_url root_dir, String ext) {this.root_dir = root_dir; this.ext = Bry_.new_u8(ext);} Io_url root_dir; byte[] ext; int fil_idx;
}

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.aria2; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.xowa.apps.fsys.*; import gplx.xowa.wmfs.dumps.*;
import gplx.xowa.apps.fsys.*; import gplx.xowa.wms.dumps.*;
public class Aria2_lib_mgr implements GfoInvkAble {
public ProcessAdp Lib() {return lib;} private ProcessAdp lib = new ProcessAdp();
public void Init_by_app(Xoae_app app) {

View File

@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.dbs.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.bldrs.cmds.files.*; import gplx.xowa.files.origs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.dbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xob_cmd, GfoInvkAble {
@@ -37,8 +39,8 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
poll_mgr = new Xobu_poll_mgr(bldr.App()); // init in ctor so gfs can invoke methods
}
public void Cmd_bgn(Xob_bldr bldr) {
parser = wiki.Parser();
ctx = wiki.Ctx();
parser = wiki.Parser_mgr().Main();
ctx = wiki.Parser_mgr().Ctx();
root = ctx.Tkn_mkr().Root(Bry_.Empty);
wiki.Init_assert(); // NOTE: must init wiki for db_mgr_as_sql
wiki.Db_mgr_as_sql().Core_data_mgr().Init_by_load(gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(wiki)); // NOTE: must reinit providers as previous steps may have rls'd (and left member variable conn which is closed)

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.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.data.*;
public class Xob_ns_file_itm {
public Xob_ns_file_itm(byte db_file_tid, String file_name, int[] ns_ids) {

View File

@@ -16,7 +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; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.srls.dsvs.*;
import gplx.langs.dsvs.*;
import gplx.xowa.nss.*;
public class Xob_ns_file_itm_parser extends Dsv_wkr_base {
private byte[] ns_ids_bry; private String name; private final List_adp rslts = List_adp_.new_();
private Xow_ns_mgr ns_mgr; private byte db_file_tid; private boolean mode_each = false;

File diff suppressed because it is too large Load Diff

View File

@@ -22,11 +22,11 @@ public class Uca_trie_tst {
@Test public void Basic() {
Uca_trie_fxt fxt = new Uca_trie_fxt();
fxt.Clear();
fxt.Init_trie_itm("a", Bry_.ints_(10, 11));
fxt.Init_trie_itm("b", Bry_.ints_(20, 21));
fxt.Init_trie_itm("c", Bry_.ints_(30, 31));
fxt.Test_decode(Bry_.ints_(10, 11), "a");
fxt.Test_decode(Bry_.ints_(10, 11, 20, 21, 30, 31), "abc");
fxt.Init_trie_itm("a", Bry_.new_ints(10, 11));
fxt.Init_trie_itm("b", Bry_.new_ints(20, 21));
fxt.Init_trie_itm("c", Bry_.new_ints(30, 31));
fxt.Test_decode(Bry_.new_ints(10, 11), "a");
fxt.Test_decode(Bry_.new_ints(10, 11, 20, 21, 30, 31), "abc");
}
}
class Uca_trie_fxt {
@@ -37,7 +37,7 @@ class Uca_trie_fxt {
}
trie.Clear();
} Uca_trie trie; Bry_bfr bfr;
public void Init_trie_itm(String charAsStr, byte[] uca) {trie.Init_itm(gplx.intl.Utf16_.Decode_to_int(Bry_.new_u8(charAsStr), 0), uca);}
public void Init_trie_itm(String charAsStr, byte[] uca) {trie.Init_itm(gplx.core.intls.Utf16_.Decode_to_int(Bry_.new_u8(charAsStr), 0), uca);}
public void Test_decode(byte[] bry, String expd) {
trie.Decode(bfr, bry, 0, bry.length);
Tfds.Eq(expd, bfr.Xto_str_and_clear());

View File

@@ -17,6 +17,8 @@ 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.dbs.*; import gplx.xowa.bldrs.*;
import gplx.xowa.nss.*;
import gplx.xowa.bldrs.wtrs.*;
public class Xob_category_registry_sql implements Xob_cmd {
public Xob_category_registry_sql(Xob_bldr bldr, Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
public String Cmd_key() {return Xob_cmd_keys.Key_text_cat_core;}

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 org.junit.*; import gplx.core.primitives.*; import gplx.xowa.bldrs.*; import gplx.xowa.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();}

View File

@@ -17,7 +17,7 @@ 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.ctgs.*;
import gplx.xowa.bldrs.sqls.*;
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);
public abstract Io_sort_cmd Make_sort_cmd(Sql_file_parser sql_parser);
@@ -37,7 +37,7 @@ public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implement
? 0 : Bit_.Xto_int_date_short(cur_modified_on);
}
else if (Bry_.Eq(fld_key, Fld_cl_sortkey)) {
int nl_pos = Bry_finder.Find_fwd(src, Byte_ascii.Nl, fld_bgn, fld_end);
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
fld_end = nl_pos;
cur_sortkey = Bry_.Mid(src, fld_bgn, fld_end);
@@ -79,8 +79,8 @@ class Xoctg_link_sql_sorter implements gplx.lists.ComparerAble {
byte[] lhs_bry = lhs.Bfr(); int lhs_bgn = 0, lhs_end = lhs.Row_bgn() - 1;
byte[] rhs_bry = rhs.Bfr(); int rhs_bgn = 0, rhs_end = rhs.Row_bgn() - 1;
for (int i = 0; i < 3; i++) {
lhs_bgn = lhs_end + 1; lhs_end = Bry_finder.Find_fwd(lhs_bry, Byte_ascii.Pipe, lhs_bgn);
rhs_bgn = rhs_end + 1; rhs_end = Bry_finder.Find_fwd(rhs_bry, Byte_ascii.Pipe, rhs_bgn);
lhs_bgn = lhs_end + 1; lhs_end = Bry_find_.Find_fwd(lhs_bry, Byte_ascii.Pipe, lhs_bgn);
rhs_bgn = rhs_end + 1; rhs_end = Bry_find_.Find_fwd(rhs_bry, Byte_ascii.Pipe, rhs_bgn);
int comp = Bry_.Compare(lhs_bry, lhs_bgn, lhs_end, rhs_bry, rhs_bgn, rhs_end);
if (comp != CompareAble_.Same) return comp;
}

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.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.ctgs.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.ctgs.*; import gplx.xowa.bldrs.*; import gplx.xowa.nss.*;
public class Xob_categorylinks_sql_tst {
@Before public void init() {if (Xoa_test_.Db_skip()) return; fxt.Ctor_fsys();} Db_mgr_fxt fxt = new Db_mgr_fxt();
@After public void term() {if (Xoa_test_.Db_skip()) return; fxt.Rls();}

View File

@@ -17,6 +17,9 @@ 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.tdbs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.langs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.data.tbls.*;
public abstract class Xob_ctg_v1_base extends Xob_itm_dump_base implements Xobd_parser_wkr, GfoInvkAble {
protected Xob_ctg_v1_base() {} // TEST:needed for fxt

View File

@@ -17,6 +17,7 @@ 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.dbs.*; import gplx.xowa.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;}
@Override public Io_sort_cmd Make_sort_cmd() {return new Xob_ctg_v1_sql_make(wiki);}

View File

@@ -17,6 +17,7 @@ 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.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;}
@Override public Io_sort_cmd Make_sort_cmd() {return new Xob_make_cmd_site(bldr.Usr_dlg(), make_dir, 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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*;
import gplx.xowa.bldrs.sqls.*;
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;}
@Override public String Sql_file_name() {return "page_props";}
@@ -31,7 +31,7 @@ public abstract class Xoctg_hiddencat_parser_base extends Xob_sql_dump_base impl
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
switch (fld_idx) {
case Fld_id: cur_id = Bry_.To_int_or(src, fld_bgn, fld_end, -1); break;
case Fld_key: cur_is_hiddencat = Bry_.Eq(Key_hiddencat, src, fld_bgn, fld_end); break;
case Fld_key: cur_is_hiddencat = Bry_.Eq(src, fld_bgn, fld_end, Key_hiddencat); break;
case Fld_val:
if (!cur_is_hiddencat) {data.Cancel_row_y_(); return;}
Exec_hook(file_bfr, cur_id, cur_is_hiddencat);

View File

@@ -16,7 +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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*; import gplx.xowa.tdbs.*; import gplx.xowa.bldrs.*;
import gplx.ios.*; import gplx.xowa.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;
public String Cmd_key() {return Xob_cmd_keys.Key_tdb_cat_hidden_ttl;}
@@ -57,7 +58,7 @@ class Xob_sql_join_wkr_ctg_hidden implements Xob_sql_join_wkr {
public void Process_match(Io_line_rdr main, Io_line_rdr join, byte[] key_bry) {
byte[] src = join.Bfr();
int itm_end = join.Itm_pos_end();
int pipe_pos = Bry_finder.Find_bwd(src, Byte_ascii.Pipe, itm_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()));
file_bfr.Add_mid(src, pipe_pos + 1, itm_end - 1).Add_byte_pipe();
file_bfr.Add(key_bry).Add_byte_nl();

View File

@@ -17,6 +17,7 @@ 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.ctgs.*; import gplx.xowa.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;
public Xoctg_link_idx_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}

View File

@@ -45,11 +45,11 @@ class Xob_bin_db_itm {
byte[] ns_bgn_tkn = Bry_.new_a7("file-ns."), ns_end_tkn = Bry_.new_a7("-db."), pt_end_tkn = Bry_.new_a7(".xowa");
int ns_bgn_tkn_len = ns_bgn_tkn.length, ns_end_tkn_len = ns_end_tkn.length;
byte[] name = Bry_.new_u8(fil.Url_rel()); // EX: en.wikipedia.org-file-ns.000-db.001.xowa
int ns_bgn = Bry_finder.Find_fwd(name, ns_bgn_tkn, 0); if (ns_bgn == Bry_finder.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_bgn", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
int ns_bgn = Bry_find_.Find_fwd(name, ns_bgn_tkn, 0); if (ns_bgn == Bry_find_.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_bgn", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
ns_bgn += ns_bgn_tkn_len;
int ns_end = Bry_finder.Find_fwd(name, ns_end_tkn, ns_bgn); if (ns_end == Bry_finder.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_end", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
int ns_end = Bry_find_.Find_fwd(name, ns_end_tkn, ns_bgn); if (ns_end == Bry_find_.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_end", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
int pt_bgn = ns_end + ns_end_tkn_len;
int pt_end = Bry_finder.Find_fwd(name, pt_end_tkn, pt_bgn); if (pt_end == Bry_finder.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_end", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
int pt_end = Bry_find_.Find_fwd(name, pt_end_tkn, pt_bgn); if (pt_end == Bry_find_.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_end", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
int ns_id = Bry_.To_int_or(name, ns_bgn, ns_end, Int_.Min_value); if (ns_id == Int_.Min_value) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
int pt_id = Bry_.To_int_or(name, pt_bgn, pt_end, Int_.Min_value); if (pt_id == Int_.Min_value) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
return new Xob_bin_db_itm(fil.Id(), fil.Url(), ns_id, pt_id);

View File

@@ -17,7 +17,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.fsdb.*; import gplx.fsdb.meta.*;
import gplx.xowa.bldrs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_diff_regy_exec_cmd extends Xob_itm_basic_base implements Xob_cmd {
private Io_url sql_dir;
public Xob_diff_regy_exec_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@@ -29,7 +29,7 @@ public class Xob_diff_regy_exec_cmd extends Xob_itm_basic_base implements Xob_cm
public void Cmd_term() {}
private void Exec_main() {
if (sql_dir == null)
sql_dir = wiki.Ctx().App().Fsys_mgr().File_dir().GenSubDir_nest(wiki.Domain_str(), "tmp_sql");
sql_dir = wiki.Parser_mgr().Ctx().App().Fsys_mgr().File_dir().GenSubDir_nest(wiki.Domain_str(), "tmp_sql");
Xob_diff_regy_sql_runner runner = new Xob_diff_regy_sql_runner();
Io_url[] urls = Io_mgr.I.QueryDir_fils(sql_dir);
int urls_len = urls.length;

View File

@@ -17,6 +17,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.fsdb.*; import gplx.dbs.engines.sqlite.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_diff_regy_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_diff_regy_make_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_diff_regy_make;}
@@ -49,7 +50,7 @@ public class Xob_diff_regy_make_cmd extends Xob_itm_basic_base implements Xob_cm
DataRdr rdr = make_db_provider.Exec_sql_as_rdr(Xob_diff_regy_tbl.Make_deletes);
int cur_db_id = -1, cur_count = 0;
Bry_bfr atr_bfr = Bry_bfr.new_(), bin_bfr = Bry_bfr.new_();
Io_url sql_tmp_dir = wiki.Ctx().App().Fsys_mgr().File_dir().GenSubDir_nest(wiki.Domain_str(), "tmp_sql");
Io_url sql_tmp_dir = wiki.App().Fsys_mgr().File_dir().GenSubDir_nest(wiki.Domain_str(), "tmp_sql");
while (rdr.MoveNextPeer()) {
byte diff_is_orig = rdr.ReadByte("diff_is_orig");
int diff_db_id = rdr.ReadInt("diff_db_id");

View File

@@ -17,6 +17,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.dbs.*; import gplx.fsdb.*; import gplx.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.*;

View File

@@ -17,6 +17,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.engines.sqlite.*; import gplx.fsdb.meta.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_fsdb_reduce_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_fsdb_reduce_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_file_fsdb_reduce;}

View File

@@ -17,6 +17,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.xowa.dbs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_lnki_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_lnki_regy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_file_lnki_regy;}

View File

@@ -18,6 +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.xowa.wikis.data.tbls.*; import gplx.xowa.pages.*;
import gplx.xowa.files.*;
import gplx.xowa.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.html.hdumps.bldrs.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.wdatas.*;

View File

@@ -18,6 +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.xowa.wikis.domains.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_orig_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
private boolean repo_0_is_remote = false;
public Xob_orig_regy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}

View File

@@ -17,6 +17,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.xowa.files.repos.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.domains.*;
import gplx.dbs.engines.sqlite.*;
class Xob_orig_regy_tbl {

View File

@@ -17,6 +17,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.qrys.*; import gplx.xowa.dbs.*; import gplx.xowa.files.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.origs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_orig_regy_update_cmd extends Xob_itm_basic_base implements Xob_cmd { // downloads latest orig data
public Xob_orig_regy_update_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return KEY_oimg;} public static final String KEY_oimg = "oimg.orig_qry";

View File

@@ -18,6 +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.engines.sqlite.*; import gplx.xowa.files.repos.*;
import gplx.xowa.wikis.domains.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_page_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_page_regy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
private boolean build_commons = false;

View File

@@ -17,6 +17,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.xowa.bldrs.wkrs.*;
public class Xob_xfer_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_xfer_regy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_file_xfer_regy;}

View File

@@ -17,6 +17,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.engines.sqlite.*; import gplx.fsdb.meta.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_xfer_regy_update_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_xfer_regy_update_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_file_xfer_regy_update;}

View File

@@ -17,6 +17,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.xowa.dbs.*; import gplx.xowa.files.*; import gplx.xowa.files.exts.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.parsers.lnkis.*;
public class Xob_xfer_temp_cmd_orig extends Xob_itm_basic_base implements Xob_cmd {
private byte[] ext_rules_key = Bry_.Empty;

View File

@@ -17,6 +17,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.xowa.files.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_xfer_temp_cmd_thumb extends Xob_itm_basic_base implements Xob_cmd {
public Xob_xfer_temp_cmd_thumb(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_file_xfer_temp_thumb;}

View File

@@ -17,6 +17,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.engines.sqlite.*; import gplx.xowa.dbs.*; import gplx.xowa.files.*; import gplx.xowa.bldrs.cmds.files.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_xfer_update_cmd extends Xob_itm_basic_base implements Xob_cmd {
private Io_url prv_url;
public Xob_xfer_update_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}

View File

@@ -17,7 +17,10 @@ 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.xowa.langs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.dbs.*; import gplx.xowa.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
public abstract class Xob_search_base extends Xob_itm_dump_base implements Xobd_wkr, GfoInvkAble {
private final Ordered_hash list = Ordered_hash_.new_(); private Xol_lang lang;

View File

@@ -28,6 +28,6 @@ public class Xob_init_cmd extends Xob_init_base {
@Override public void Cmd_run_end(Xowe_wiki wiki) {
if (gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(wiki) != null)
throw wiki.Appe().Bldr().Usr_dlg().Fail_many("", "", "directory must not contain any .xowa or .sqlite3 files: dir=~{0}", wiki.Fsys_mgr().Root_dir().Raw());
Xowe_wiki_bldr.Create(wiki, wiki.Import_cfg().Src_rdr_len(), wiki.Import_cfg().Src_fil().NameOnly());
Xowe_wiki_.Create(wiki, wiki.Import_cfg().Src_rdr_len(), wiki.Import_cfg().Src_fil().NameOnly());
}
}

View File

@@ -17,6 +17,8 @@ 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.xowa.bldrs.wkrs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.dbs.*;
import gplx.xowa.wikis.*; import gplx.xowa.bldrs.filters.dansguardians.*; import gplx.xowa.apis.xowa.bldrs.imports.*;
import gplx.xowa.parsers.utils.*;
@@ -24,8 +26,8 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
private Xowd_db_mgr db_mgr; private Db_idx_mode idx_mode = Db_idx_mode.Itm_end; private Xowd_page_tbl page_core_tbl; private Io_stream_zip_mgr text_zip_mgr; private byte text_zip_tid;
private Xop_redirect_mgr redirect_mgr; private Xob_redirect_tbl redirect_tbl; private boolean redirect_id_enabled;
private DateAdp modified_latest = DateAdp_.MinValue; private int page_count_all, page_count_main = 0; private int commit_interval = 100000; // 100 k
private Dg_match_mgr dg_match_mgr; private final Xow_page_mgr page_mgr; private Xob_ns_to_db_mgr ns_to_db_mgr;
public Xob_page_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.page_mgr = wiki.Page_mgr();}
private Dg_match_mgr dg_match_mgr; private Xob_ns_to_db_mgr ns_to_db_mgr;
public Xob_page_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Wkr_key() {return Xob_cmd_keys.Key_text_page;}
public void Wkr_bgn(Xob_bldr bldr) {
Xoae_app app = wiki.Appe();
@@ -60,7 +62,7 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
}
byte[] text_zip = text_zip_mgr.Zip(text_zip_tid, text_raw);
Xowd_db_file text_db = ns_to_db_mgr.Get_by_ns(ns.Bldr_data(), text_zip.length);
try {page_mgr.Create(page_core_tbl, text_db.Tbl__text(), id, page.Ns_id(), page.Ttl_page_db(), redirect, modified, text_zip, text_raw_len, random_int, text_db.Id(), -1);}
try {db_mgr.Create_page(page_core_tbl, text_db.Tbl__text(), id, page.Ns_id(), page.Ttl_page_db(), redirect, modified, text_zip, text_raw_len, random_int, text_db.Id(), -1);}
catch (Exception e) {
throw Err_.new_exc(e, "bldr", "create page in db failed; skipping page", "id", id, "ns", page.Ns_id(), "name", page.Ttl_page_db(), "redirect", redirect, "modified", modified, "text_len", text_raw_len, "text_db_id", text_db.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.sqls; 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.dbs.*; import gplx.xowa.specials.search.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.ctgs.*;
import org.junit.*; import gplx.dbs.*; import gplx.xowa.specials.search.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.nss.*;
public class Xob_page_cmd_tst {
@Before public void init() {if (Xoa_test_.Db_skip()) return; fxt.Ctor_fsys();} Db_mgr_fxt fxt = new Db_mgr_fxt();
@After public void term() {if (Xoa_test_.Db_skip()) return; fxt.Rls();}

View File

@@ -17,7 +17,7 @@ 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.xowa.bldrs.sqls.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_pagelinks_parser_cmd extends Xob_sql_dump_base implements Sql_file_parser_cmd {
private Db_conn core_conn;

View File

@@ -16,6 +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.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.xowa.langs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.*;
public class Xob_search_sql_cmd extends Xob_itm_basic_base implements Xob_cmd { // search version 2; upgrade
private int commit_interval = 100000, progress_interval = 10000;

View File

@@ -17,6 +17,8 @@ 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.xowa.bldrs.wkrs.*;
import gplx.xowa.langs.*;
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.dbs.*; import gplx.xowa.wikis.data.tbls.*;
public class Xob_search_sql_wkr extends Xob_search_base implements Io_make_cmd { // search version 2
private Xowd_db_mgr db_mgr; private Xowd_search_link_tbl search_page_tbl; private Xowd_search_word_tbl search_word_tbl;

View File

@@ -0,0 +1,61 @@
/*
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.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.tdbs.*; import gplx.xowa.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);
int fil_count = 0, itm_count = 0;
public Io_sort_cmd_ns(Gfo_usr_dlg usr_dlg) {this.usr_dlg = usr_dlg;} Gfo_usr_dlg usr_dlg;
public int Trg_fil_max() {return trg_fil_max;} public Io_sort_cmd_ns Trg_fil_max_(int v) {trg_fil_max = v; return this;} private int trg_fil_max = 65 * Io_mgr.Len_kb;
Io_url reg_url;
public Io_sort_cmd Make_dir_(Io_url v) {make_dir = v; return this;} Io_url make_dir;
public void Sort_bgn() {
fil_count = itm_count = 0;
fil_wtr = Xob_xdat_file_wtr.new_file_(trg_fil_max, make_dir);
reg_url = make_dir.GenSubFil(Xotdb_dir_info_.Name_reg_fil);
}
public void Sort_do(Io_line_rdr rdr) {
int itm_bgn = rdr.Itm_pos_bgn(), itm_end = rdr.Itm_pos_end(), key_bgn = rdr.Key_pos_bgn(), key_end = rdr.Key_pos_end();
int itm_len = itm_end - itm_bgn;
if (fil_wtr.FlushNeeded(itm_len)) Flush();
byte[] bfr = rdr.Bfr();
if (key_bfr_0.Len() == 0) {key_bfr_0.Add_mid(bfr, key_bgn, key_end);}
key_bfr_n.Clear().Add_mid(bfr, key_bgn, key_end);
fil_wtr.Bfr().Add_mid(rdr.Bfr(), itm_bgn, itm_end);
fil_wtr.Add_idx(Byte_ascii.Null);
++itm_count;
}
public void Sort_end() {
Flush();
Io_mgr.I.AppendFilBfr(reg_url, reg_bfr);
//fil_wtr.Rls(); reg_bfr.Rls(); key_bfr_0.Rls(); key_bfr_n.Rls();
}
private void Flush() {
reg_bfr
.Add_int_variable(fil_count++).Add_byte(Byte_ascii.Pipe)
.Add_bfr_and_preserve(key_bfr_0).Add_byte(Byte_ascii.Pipe)
.Add_bfr_and_preserve(key_bfr_n).Add_byte(Byte_ascii.Pipe)
.Add_int_variable(itm_count).Add_byte(Byte_ascii.Nl);
itm_count = 0;
key_bfr_0.Clear();
if (fil_wtr.Fil_idx() % 10 == 0)
usr_dlg.Prog_many("cmd_ns", "prog", "saving: ~{0} ~{1}", reg_url.OwnerDir().OwnerDir().NameOnly(), fil_wtr.Fil_url().NameOnly());
fil_wtr.Flush(usr_dlg);
}
}

View File

@@ -16,7 +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.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.xowa.tdbs.*; import gplx.xowa.tdbs.hives.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.nss.*;
import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.tdbs.*; import gplx.xowa.tdbs.hives.*; import gplx.xowa.tdbs.xdats.*;
public class Xob_calc_stats_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_calc_stats_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_tdb_calc_stats;}

View File

@@ -0,0 +1,138 @@
/*
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.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.tdbs.*; import gplx.xowa.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);
int make_fil_max = 65 * Io_mgr.Len_kb, fil_count = 0, itm_count = 0, itm_key_end = 0; Io_url reg_url;
public Xob_make_cmd_site(Gfo_usr_dlg usr_dlg, Io_url make_dir, int make_fil_max) {this.usr_dlg = usr_dlg; this.make_dir = make_dir; this.make_fil_max = make_fil_max;} Gfo_usr_dlg usr_dlg;
public Io_sort_cmd Make_dir_(Io_url v) {make_dir = v; return this;} Io_url make_dir;
public byte Line_dlm() {return line_dlm;} public Xob_make_cmd_site Line_dlm_(byte v) {line_dlm = v; return this;} private byte line_dlm = Byte_ascii.Null;
public void Sort_bgn() {
fil_count = itm_count = itm_key_end = 0;
reg_url = make_dir.GenSubFil(Xotdb_dir_info_.Name_reg_fil);
fil_wtr = Xob_xdat_file_wtr.new_file_(make_fil_max, make_dir);
}
public void Sort_do(Io_line_rdr rdr) {
if (line_dlm == Byte_ascii.Null) line_dlm = rdr.Line_dlm();
int rdr_key_bgn = rdr.Key_pos_bgn(), rdr_key_end = rdr.Key_pos_end();
int rdr_key_len = rdr_key_end - rdr_key_bgn;
int rdr_val_bgn = rdr_key_end, /* NOTE: no +1: want to include fld_dlm for below*/ rdr_val_end = rdr.Itm_pos_end() - 1; // -1: ignore rdr_dlm
if (Bry_.Match(cur_bfr.Bfr(), 0, itm_key_end, rdr.Bfr(), rdr_key_bgn, rdr_key_end)) // key is same; add rest of line as val
cur_bfr.Add_mid(rdr.Bfr(), rdr_val_bgn, rdr_val_end);
else {
if (fil_wtr.FlushNeeded(cur_bfr.Len() + rdr_key_len)) Flush();
byte[] bfr = rdr.Bfr();
if (reg_key_0.Len() == 0) {
if (cur_bfr.Len() == 0)
reg_key_0.Add_mid(bfr, rdr_key_bgn, rdr_key_end);
else
reg_key_0.Add_mid(cur_bfr.Bfr(), 0, itm_key_end);
}
if (cur_bfr.Len() > 0) {
reg_key_n.Clear().Add_mid(cur_bfr.Bfr(), 0, itm_key_end);
fil_wtr.Bfr().Add_bfr_and_clear(cur_bfr);
fil_wtr.Add_idx(line_dlm);
}
cur_bfr.Add_mid(rdr.Bfr(), rdr.Itm_pos_bgn(), rdr.Itm_pos_end() - 1); // -1 to ignore closing newline
itm_key_end = rdr_key_len; // NOTE: must be set last
++itm_count;
}
}
public void Do_bry(byte[] bry, int key_bgn, int key_end, int itm_bgn, int itm_end) {
int val_bgn = key_end, /* NOTE: no +1: want to include fld_dlm for below*/ val_end = itm_end - 1; // -1: ignore rdr_dlm
if (Bry_.Match(cur_bfr.Bfr(), 0, itm_key_end, bry, key_bgn, key_end)) // key is same; add rest of line as val
cur_bfr.Add_mid(bry, val_bgn, val_end);
else { // key changed;
int itm_len = itm_end - itm_bgn;
if (cur_bfr.Len() > 0) { // pending itm
fil_wtr.Bfr().Add_bfr_and_clear(cur_bfr); // add cur_bfr to fil_bfr
fil_wtr.Add_idx(line_dlm); // add cur_itm to hdr
if (fil_wtr.FlushNeeded(cur_bfr.Len() + itm_len))
Flush();
}
if (reg_key_0.Len() == 0) // regy.key_0 bfr is empty
reg_key_0.Add_mid(bry, key_bgn, key_end); // update reg_0key_0
reg_key_n.Clear().Add_mid(bry, key_bgn, key_end); // always update reg_key_n
if (itm_len > 100 * Io_mgr.Len_mb)
Flush_large(bry, itm_bgn, itm_end, itm_len);
else {
cur_bfr.Add_mid(bry, itm_bgn, itm_end - 1); // add incoming itm; -1 to ignore closing newline
itm_key_end = key_end; // NOTE: must be set last
++itm_count;
}
}
}
public void Sort_end() {
reg_key_n.Clear().Add_mid(cur_bfr.Bfr(), 0, itm_key_end);
fil_wtr.Bfr().Add_bfr_and_clear(cur_bfr);
fil_wtr.Add_idx(line_dlm);
Flush();
Io_mgr.I.AppendFilBfr(reg_url, reg_bfr);
//fil_wtr.Rls(); cur_bfr.Rls(); fil_wtr.Rls(); reg_bfr.Rls(); reg_key_0.Rls(); reg_key_n.Rls();
}
// private void Flush_large(byte[] bry, int itm_bgn, int itm_end, int itm_len) {
// ++itm_count;
// this.Flush_reg();
// fil_wtr.Add_idx_direct(itm_len, Byte_.Zero);
// IoStream stream = IoStream_.Null;
// try {
// stream = Io_mgr.I.OpenStreamWrite(fil_wtr.Fil_url());
// fil_wtr.FlushIdx(stream);
// stream.Write_and_flush(bry, itm_bgn, itm_end);
// fil_wtr.Clear();
// fil_wtr.Url_gen_add();
// }
// finally {stream.Rls();}
// }
private void Flush_large(byte[] bry, int itm_bgn, int itm_end, int itm_len) {
++itm_count;
this.Flush_reg();
fil_wtr.Add_idx_direct(itm_len, Byte_.Zero);
Io_stream_wtr wtr = null;
try {
wtr = Io_stream_wtr_.file_(fil_wtr.Fil_url());
wtr.Open();
fil_wtr.FlushIdx(wtr);
wtr.Write(bry, itm_bgn, itm_end);
wtr.Flush();
fil_wtr.Clear();
fil_wtr.Url_gen_add();
}
finally {if (wtr != null) wtr.Rls();}
}
private void Flush() {
Flush_reg();
Flush_fil();
}
private void Flush_reg() {
reg_bfr
.Add_int_variable(fil_count++).Add_byte(Byte_ascii.Pipe)
.Add_bfr_and_preserve(reg_key_0).Add_byte(Byte_ascii.Pipe)
.Add_bfr_and_preserve(reg_key_n).Add_byte(Byte_ascii.Pipe)
.Add_int_variable(itm_count).Add_byte(Byte_ascii.Nl);
itm_count = 0;
reg_key_0.Clear();
}
private void Flush_fil() {
if (fil_wtr.Fil_idx() % 10 == 0)
usr_dlg.Prog_many("cmd_site", "prog", "saving: ~{0} ~{1}", reg_url.OwnerDir().NameOnly(), fil_wtr.Fil_url().NameOnly());
fil_wtr.Flush(usr_dlg);
}
}

View File

@@ -17,6 +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 gplx.ios.*; import gplx.xowa.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);}
public String Wkr_key() {return KEY;} public static final String KEY = "core.make_id";

View File

@@ -16,8 +16,11 @@ 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.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.wtrs.*;
import gplx.xowa.nss.*;
import gplx.xowa.parsers.utils.*;
import gplx.xowa.tdbs.*; import gplx.xowa.tdbs.xdats.*; import gplx.xowa.tdbs.stats.*;
public class Xob_page_txt extends Xob_itm_dump_base implements Xobd_wkr, GfoInvkAble {
public Xob_page_txt(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Wkr_key() {return Xob_cmd_keys.Key_tdb_make_page;}

View File

@@ -16,7 +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.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.tdbs.*;
import gplx.ios.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.tdbs.*; import gplx.xowa.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);}
public String Wkr_key() {return KEY;} public static final String KEY = "parse.dump_templates";

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 org.junit.*; import gplx.xowa.tdbs.*; import gplx.xowa.bldrs.*;
import org.junit.*; import gplx.xowa.tdbs.*; import gplx.xowa.bldrs.*; import gplx.xowa.nss.*;
public class Xob_search_base_tst {
@Test public void Split() {
tst_Split("a", "a");

View File

@@ -18,6 +18,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.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.nss.*;
public class Xob_tst {
@Before public void init() {fxt = new Xob_fxt().Ctor_mem();} private Xob_fxt fxt;
// @After public void term() {fxt.Wiki().Ctx().Sys_load_tmpls_(true);} // commented during wiki.Ctx() removal; DATE:2014-04-22

View File

@@ -17,6 +17,7 @@ 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.core.criterias.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_cleanup_cmd extends Xob_itm_basic_base implements Xob_cmd {
private String bz2_cmd;
private boolean delete_all, delete_tmp;

View File

@@ -17,7 +17,7 @@ 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.xowa.wikis.domains.*;
import gplx.xowa.wmfs.dumps.*;
import gplx.xowa.wms.dumps.*;
public class Xob_core_batch_utl implements GfoInvkAble {
private final Xob_bldr bldr;
private final Bry_fmtr fmtr = Bry_fmtr.keys_("bz2_fil", "wiki_key");

View File

@@ -16,7 +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.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.ios.*; import gplx.core.threads.*; import gplx.xowa.bldrs.*;
import gplx.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);}
public String Cmd_key() {return Xob_cmd_keys.Key_decompress_bz2;}

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.xowa.bldrs.*; import gplx.xowa.tdbs.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.tdbs.*;
public class Xob_deploy_copy_cmd extends Xob_itm_basic_base implements Xob_cmd, GfoInvkAble {
public Xob_deploy_copy_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_deploy_copy;}

View File

@@ -16,7 +16,9 @@ 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.xowa.bldrs.sqls.*;
import gplx.ios.*;
import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.sqls.*;
import gplx.xowa.nss.*;
import gplx.xowa.tdbs.*;
public class Xob_deploy_zip_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_deploy_zip_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}

View File

@@ -16,8 +16,9 @@ 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.xowa.bldrs.*;
import gplx.xowa.wmfs.dumps.*;
import gplx.dbs.*; import gplx.ios.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wms.dumps.*;
public class Xob_download_wkr extends Xob_itm_basic_base implements Xob_cmd {
private String dump_date = "latest";
private String dump_type = null;

View File

@@ -17,7 +17,7 @@ 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.xowa.bldrs.*;
import gplx.xowa.wmfs.*; import gplx.xowa.wmfs.data.*;
import gplx.xowa.wms.*; import gplx.xowa.wms.sites.*;
import gplx.xowa.wikis.domains.*;
public class Xob_site_meta_cmd implements Xob_cmd {
private final Xob_bldr bldr;
@@ -25,10 +25,11 @@ public class Xob_site_meta_cmd implements Xob_cmd {
public Xob_site_meta_cmd(Xob_bldr bldr, Xow_wiki wiki) {this.bldr = bldr;}
public String Cmd_key() {return Xob_cmd_keys.Key_site_meta;}
public void Cmd_run() {
if (wikis == null) wikis = Xow_wmf_api_mgr.Wikis;
if (db_url == null) db_url = bldr.App().Fsys_mgr().Cfg_site_meta_fil();
Xoa_app app = bldr.App();
if (wikis == null) wikis = Xow_domain_regy.All;
if (db_url == null) db_url = app.Fsys_mgr().Cfg_site_meta_fil();
if (cutoff_time == null) cutoff_time = DateAdp_.Now().Add_day(-1);
Site_meta_itm.Build_site_meta(bldr.App().Utl__json_parser(), bldr.App().Wmf_mgr(), db_url, wikis, cutoff_time);
new Site_api_mgr().Load_all(app.Usr_dlg(), app.Utl__inet_conn(), db_url, wikis, cutoff_time);
}
public void Cmd_init(Xob_bldr bldr) {}
public void Cmd_bgn(Xob_bldr bldr) {}

View File

@@ -17,7 +17,7 @@ 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.xowa.bldrs.sqls.*;
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;
private Xob_image_tbl tbl_image = new Xob_image_tbl();

View File

@@ -17,6 +17,7 @@ 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.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.dbs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_page_dump_cmd_drop extends Xob_itm_basic_base implements Xob_cmd {
public Xob_page_dump_cmd_drop(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_wiki_page_dump_drop;}

View File

@@ -17,6 +17,7 @@ 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.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.dbs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_page_dump_cmd_make extends Xob_itm_basic_base implements Xob_cmd {
public Xob_page_dump_cmd_make(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return Xob_cmd_keys.Key_wiki_page_dump_make;}

View File

@@ -17,6 +17,8 @@ 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.dbs.cfgs.*; import gplx.xowa.dbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.langs.htmls.encoders.*;
import gplx.xowa.nss.*;
import gplx.xowa.parsers.utils.*;
public class Xob_redirect_cmd extends Xob_dump_mgr_base {
private Db_conn conn; private Xob_redirect_tbl redirect_tbl;

Some files were not shown because too many files have changed in this diff Show More