v3.3.4 v3.4.4.1
gnosygnu 8 years ago
parent ad140a93fe
commit 5ce4ea2a08

@ -572,6 +572,55 @@ public class Bry_bfr {
bfr = null;
this.Mkr_rls();
}
public byte[][] To_bry_ary_and_clear() {
if (bfr_len == 0) return Bry_.Ary_empty;
Int_list line_ends = Find_all(Byte_ascii.Nl);
// create lines
int lines_len = line_ends.Len();
byte[][] rv = new byte[lines_len][];
int line_bgn = 0;
for (int i = 0; i < lines_len; ++i) {
int line_end = line_ends.Get_at(i);
rv[i] = Bry_.Mid(bfr, line_bgn, line_end);
line_bgn = line_end + 1;
}
this.ClearAndReset();
return rv;
}
public String[] To_str_ary_and_clear() {
if (bfr_len == 0) return String_.Ary_empty;
Int_list line_ends = Find_all(Byte_ascii.Nl);
// create lines
int lines_len = line_ends.Len();
String[] rv = new String[lines_len];
int line_bgn = 0;
for (int i = 0; i < lines_len; ++i) {
int line_end = line_ends.Get_at(i);
rv[i] = String_.new_u8(bfr, line_bgn, line_end);
line_bgn = line_end + 1;
}
this.ClearAndReset();
return rv;
}
private Int_list Find_all(byte find) {
Int_list rv = new Int_list();
// scan bfr for nl
int line_bgn = 0, line_end = 0;
while (line_bgn < bfr_len) {
line_end = Bry_find_.Find_fwd(bfr, find, line_bgn, bfr_len);
if (line_end == Bry_find_.Not_found) { // no more \n; add bfr_end
rv.Add(bfr_len);
break;
}
else { // \n found; add it
rv.Add(line_end);
line_bgn = line_end + 1;
}
}
return rv;
}
@Override public int hashCode() {return Bry_obj_ref.CalcHashCode(bfr, 0, bfr_len);}
@Override public boolean equals(Object obj) {
if (obj == null) return false; // NOTE: strange, but null check needed; throws null error; EX.WP: File:Eug<75>ne Delacroix - La libert<72> guidant le peuple.jpg

@ -208,9 +208,15 @@ public class Bry_bfr_tst {
@Test public void Delete_rng_to_end() {
fxt.Test_Delete_rng_to_end("abcd", 2 , "ab");
}
@Test public void To_bry_ary_and_clear() {
fxt.Test__to_bry_ary_and_clear("" ); // empty
fxt.Test__to_bry_ary_and_clear("a" , "a"); // lines=1
fxt.Test__to_bry_ary_and_clear("a\nb\nc" , "a", "b", "c"); // lines=n
fxt.Test__to_bry_ary_and_clear("a\n" , "a"); // nl at end
}
}
class ByteAryBfr_fxt {
private Bry_bfr bfr = Bry_bfr.reset_(16);
private final Bry_bfr bfr = Bry_bfr.reset_(16);
public void Clear() {
bfr.ClearAndReset();
}
@ -224,4 +230,7 @@ class ByteAryBfr_fxt {
public void Test_Delete_rng(String init, int bgn, int end, String expd) {Tfds.Eq(expd, bfr.Add_str_u8(init).Delete_rng(bgn, end).To_str_and_clear());}
public void Test_Delete_rng_to_bgn(String init, int pos, String expd) {Tfds.Eq(expd, bfr.Add_str_u8(init).Delete_rng_to_bgn(pos).To_str_and_clear());}
public void Test_Delete_rng_to_end(String init, int pos, String expd) {Tfds.Eq(expd, bfr.Add_str_u8(init).Delete_rng_to_end(pos).To_str_and_clear());}
public void Test__to_bry_ary_and_clear(String bfr_str, String... expd) {
Tfds.Eq_ary(expd, String_.Ary(bfr.Add_str_u8(bfr_str).To_bry_ary_and_clear()));
}
}

@ -23,6 +23,7 @@ public class Btrie_slim_mgr implements Btrie_mgr {
public int Match_pos() {return match_pos;} private int match_pos;
public Object Match_exact(byte[] src) {return src == null ? null : Match_exact(src, 0, src.length);}
public Object Match_exact(byte[] src, int bgn_pos, int end_pos) {
if (bgn_pos == end_pos) return null; // NOTE:handle empty String; DATE:2016-04-21
Object rv = Match_bgn_w_byte(src[bgn_pos], src, bgn_pos, end_pos);
return rv == null ? null : match_pos - bgn_pos == end_pos - bgn_pos ? rv : null;
}

@ -0,0 +1,21 @@
/*
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.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
public interface Io_zip_decompress_cmd {
void Decompress__exec(Io_zip_decompress_task task, Io_url src_fil, Io_url trg_dir);
}

@ -0,0 +1,21 @@
/*
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.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
public class Io_zip_decompress_cmd_ {
public static Io_zip_decompress_cmd New__jre() {return new Io_zip_decompress_cmd__jre();}
}

@ -0,0 +1,103 @@
/*
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.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import java.io.*;
import java.util.zip.*;
import gplx.core.envs.*; import gplx.core.threads.*;
class Io_zip_decompress_cmd__jre implements Io_zip_decompress_cmd {
public void Decompress__exec(Io_zip_decompress_task task, Io_url src_fil, Io_url trg_dir) {
// init
byte[] buffer = new byte[4096];
String resume_entry_name = task.Resume__entry();
long resume_bytes = task.Resume__bytes();
// assert that trg_dir exists and can be written
Io_mgr.Instance.CreateDirIfAbsent(trg_dir);
// open src_fil_stream
FileInputStream src_fil_stream = null;
try {src_fil_stream = new FileInputStream(src_fil.Raw());}
catch (FileNotFoundException e) {throw Err_.new_("ios.zip", "file not found", "path", src_fil.Raw());}
ZipInputStream src_zip_stream = new ZipInputStream(src_fil_stream);
try {
ZipEntry entry = null;
boolean loop_entries = true;
while (loop_entries) {
// read next entry
entry = src_zip_stream.getNextEntry();
if ( entry == null // no more entries
|| resume_entry_name == null // resume_entry_name will be null in most cases
|| String_.Eq(resume_entry_name, entry.getName()) // if resume_entry_name is not null, keep reading until match
)
break;
if (resume_bytes > 0) {
src_zip_stream.skip(resume_bytes);
resume_bytes = 0;
}
// get entry name; also convert / to \ for wnt
String entry_name = entry.getName();
task.Prog__update_name(entry_name);
if (Op_sys.Cur().Tid_is_wnt()) entry_name = String_.Replace(entry_name, "/", "\\");
// create file
Io_url trg_fil_url = Io_url_.new_any_(trg_dir.GenSubFil(entry_name).Raw());
Io_mgr.Instance.CreateDirIfAbsent(trg_fil_url.OwnerDir()); // make sure owner dir exists
if (trg_fil_url.Type_fil()) {
// write file
Io_mgr.Instance.SaveFilStr_args(trg_fil_url, "").Exec(); // need to write to create dirs; permissions;
FileOutputStream trg_fil_stream = new FileOutputStream(new File(trg_fil_url.Raw()));
boolean loop_bytes = true;
while (loop_bytes) {
int len = src_zip_stream.read(buffer); if (len < 1) break;
trg_fil_stream.write(buffer, 0, len);
switch (task.Prog__update(len)) {
case Io_zip_decompress_task.Status__canceled:
loop_entries = false;
loop_bytes = false;
break;
case Io_zip_decompress_task.Status__paused:
while (true) {
Thread_adp_.Sleep(1000);
if (!task.Paused()) break;
if (task.Canceled()) {
loop_entries = false;
loop_bytes = false;
break;
}
}
break;
case Io_zip_decompress_task.Status__ok:
break;
}
}
trg_fil_stream.close();
}
}
}
catch(IOException e) {throw Err_.new_exc(e, "ios.zip", "error duing unzip", "src", src_fil.Raw(), "trg", trg_dir.Raw());}
finally {
try {
src_zip_stream.closeEntry();
src_zip_stream.close();
} catch (Exception e) {}
}
}
}

@ -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.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import gplx.core.threads.*; import gplx.core.progs.*;
public class Io_zip_decompress_task implements GfoInvkAble {
private Gfo_prog_ui prog_ui;
private Io_url src_fil, trg_dir;
private boolean async;
private boolean canceled, paused;
private long src_fil_len = 0;
private long prog__cur = 0;
private Io_zip_decompress_cmd cmd;
public Gfo_prog_task Prog__owner() {return Gfo_prog_task_.Null;}
public void Init(boolean async, Gfo_prog_ui prog_ui, Io_zip_decompress_cmd cmd, Io_url src_fil, Io_url trg_dir) {
this.async = async; this.cmd = cmd; this.prog_ui = prog_ui;
this.src_fil = src_fil; this.trg_dir = trg_dir;
}
public String Resume__entry() {return resume__entry;} private String resume__entry;
public long Resume__bytes() {return resume__bytes;} private long resume__bytes;
public boolean Canceled() {return canceled;}
public boolean Paused() {return paused;}
public void Prog__start() {
this.src_fil_len = Io_mgr.Instance.QueryFil(src_fil).Size();
this.resume__entry = null;
this.resume__bytes = 0;
// load resume
// prog_ui.Prog__init(src_fil_len);
Thread_adp_.Run_cmd(async, "zip.decompress:" + src_fil.Raw(), this, Invk__unzip);
}
public byte Prog__update(long v) {
prog__cur += v;
prog_ui.Prog__update_val(prog__cur, src_fil_len);
if (paused) return Status__paused;
else if (canceled) return Status__canceled;
else return Status__ok;
}
public boolean Prog__update_name(String name) {
// prog_ui.Prog__update_misc("name", name);
return canceled;
}
public void Prog__pause() {
paused = true;
// save resume
}
public void Prog__resume() {
paused = false;
}
public void Prog__cancel() {
canceled = true;
// discard resume
}
public void Unzip() {
cmd.Decompress__exec(this, src_fil, trg_dir);
prog_ui.Prog__end();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk__unzip)) this.Unzip();
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk__unzip = "unzip";
public static final byte Status__ok = 0, Status__paused = 1, Status__canceled = 2;
}
/*
class Notifier {
public Prog_update_bgn() {
for(Object o : list)
o.Prog_update_bgn();
}
public Prog_update_end() {
for(Object o : list)
o.Prog_update_bgn();
}
public Prog_update_val(long cur, long all) {
for(Object o : list)
o.Prog_update_bgn();
}
public Prog_update_name(String name) {
for(Object o : list)
o.Prog_update_bgn();
}
}
class unzip_prog_bar {
public Prog_update_val(long itm_cur, long itm_all) {
cur += itm_cur;
double pct = (cur / all) * 100;
pbar.style.width = pct + "%";
pbar.text = Io_size.To_str(cur);
}
public Prog_update_name(String name) {
file.text = "unzipping:" + name;
}
public Prog_update_bgn(long cur) {
if (all == 0) {
panels.add(this);
}
all += cur;
}
public Prog_update_end() {
if (cur >= all) {
panels.del(this);
}
}
}
class pack_prog_bar {
public Prog_update_val(long cur, long all) {
double pct = (cur / all) * 100;
pbar.style.width = pct + "%";
pbar.text = Io_size.To_str(cur);
}
public Prog_update_name(String name) {
file.text = "unzipping:" + name;
}
public Prog_update_bgn() {
pbar.visible = true;
file.visible = true;
file.text = "unzipping: " + ;
}
public Prog_update_end() {
pbar.visible = false;
file.visible = false;
}
}
*/

@ -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.core.ios; import gplx.*; import gplx.core.*;
package gplx.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
public interface Io_zip_mgr {
void Zip_fil(Io_url src_fil, Io_url trg_fil);
byte[] Zip_bry(byte[] src, int bgn, int len);

@ -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.core.ios; import gplx.*; import gplx.core.*;
package gplx.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import java.io.*;
import java.util.zip.*;
import gplx.core.envs.*;
@ -116,5 +116,5 @@ public class Io_zip_mgr_base implements Io_zip_mgr {
} catch(IOException e) {throw Err_.new_exc(e, "io", "error duing unzip", "src", src_fil.Raw(), "trg", trg_dir.Raw());}
}
byte[] tmp = new byte[4096]; int tmpLen = 4096;
public static final Io_zip_mgr Instance = new Io_zip_mgr_base();
public static final Io_zip_mgr Instance = new Io_zip_mgr_base();
}

@ -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.core.ios; import gplx.*; import gplx.core.*;
package gplx.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
public class Io_zip_mgr_mok implements Io_zip_mgr {
public void Zip_fil(Io_url src_fil, Io_url trg_fil) {
byte[] src_bry = Io_mgr.Instance.LoadFilBry(src_fil);
@ -31,6 +31,7 @@ public class Io_zip_mgr_mok implements Io_zip_mgr {
return Bry_.Mid(section, Bry_zipped.length, section.length);
}
public void Unzip_to_dir(Io_url src_fil, Io_url trg_dir) {}
private static final byte[] Bry_zipped = Bry_.new_a7("zipped:");
public static final Io_zip_mgr_mok Instance = new Io_zip_mgr_mok(); Io_zip_mgr_mok() {}
public void Unzip_to_dir_prog(Io_zip_decompress_task task, Io_url src_fil, Io_url trg_dir) {}
private static final byte[] Bry_zipped = Bry_.new_a7("zipped:");
public static final Io_zip_mgr_mok Instance = new Io_zip_mgr_mok(); Io_zip_mgr_mok() {}
}

@ -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.core.ios; import gplx.*; import gplx.core.*;
package gplx.core.ios.zips; import gplx.*; import gplx.core.*; import gplx.core.ios.*;
import org.junit.*;
public class Io_zip_mgr_tst {
@Test public void Zip_unzip() {

@ -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.core.progs; import gplx.*; import gplx.core.*;
public interface Gfo_prog_task {
Gfo_prog_task Prog__owner();
long Prog__all();
long Prog__cur();
void Prog__start();
void Prog__cancel();
void Prog__pause();
void Prog__resume();
}

@ -0,0 +1,21 @@
/*
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.core.progs; import gplx.*; import gplx.core.*;
public class Gfo_prog_task_ {
public static final Gfo_prog_task Null = null;
}

@ -0,0 +1,22 @@
/*
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.core.progs; import gplx.*; import gplx.core.*;
public interface Gfo_prog_ui {
void Prog__update_val(long cur, long max);
void Prog__end();
}

@ -32,5 +32,12 @@ public class Thread_adp_ {
public static void Run_invk_msg(String name, GfoInvkAble invk, GfoMsg m) {
Thread_adp_.invk_msg_(name, invk, m).Start();
}
public static final String Name_null = null;
public static void Run_cmd(boolean async, String thread_name, GfoInvkAble invk, String cmd) {
GfoMsg msg = GfoMsg_.new_cast_(cmd);
if (async)
Thread_adp_.invk_msg_(thread_name, invk, msg).Start();
else
GfoInvkAble_.InvkCmd_msg(invk, cmd, msg);
}
public static final String Name_null = null;
}

@ -55,7 +55,7 @@ class Db_conn_bldr_wkr__mem implements Db_conn_bldr_wkr {
}
public Db_conn New(Io_url url) {
String io_url_str = url.Xto_api();
hash.Add(io_url_str, io_url_str);
hash.Add_if_dupe_use_nth(io_url_str, io_url_str); // NOTE: tests can call New multiple times; don't fail if exists; just overwrite existing entry; DATE:2016-04-21
return Get_or_new(url);
}
private Db_conn Get_or_new(Io_url url) {

@ -20,5 +20,6 @@ public interface Http_client_rdr {
void Stream_(Object o);
String Read_line();
byte[] Read_line_as_bry();
int Read_char_ary(char[] ary, int bgn, int len);
void Rls();
}

@ -31,5 +31,6 @@ class Http_client_rdr__mem implements Http_client_rdr {
return idx == ary_len ? null : ary[idx++];
}
public byte[] Read_line_as_bry() {return Bry_.new_u8(Read_line());}
public int Read_char_ary(char[] ary, int bgn, int len) {throw Err_.new_unimplemented();}
public void Rls() {}
}

@ -26,6 +26,10 @@ class Http_client_rdr__stream implements Http_client_rdr {
try {return br.readLine();}
catch (IOException e) {throw Err_.new_exc(e, "net", "Read_line failed");}
}
public int Read_char_ary(char[] ary, int bgn, int len) {
try {return br.read(ary, bgn, len);}
catch (IOException e) {throw Err_.new_exc(e, "net", "Read_line failed");}
}
public byte[] Read_line_as_bry() {return Bry_.new_u8(Read_line());}
public void Rls() {
try {br.close();}

@ -22,8 +22,8 @@ public class Http_request_parser {
private int type, content_length;
private byte[] url, protocol, host, user_agent, accept, accept_language, accept_encoding, x_requested_with, cookie, referer, content_type, content_type_boundary, connection, pragma, cache_control, origin;
private Http_post_data_hash post_data_hash;
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
private final Http_server_wtr server_wtr; private final boolean log;
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
private final Http_server_wtr server_wtr; private final boolean log;
public Http_request_parser(Http_server_wtr server_wtr, boolean log) {this.server_wtr = server_wtr; this.log = log;}
public void Clear() {
this.dnt = false;
@ -147,7 +147,7 @@ public class Http_request_parser {
private String To_str() {return Make_request_itm().To_str(tmp_bfr, Bool_.N);}
private static final int Tid_get = 1, Tid_post = 2, Tid_host = 3, Tid_user_agent = 4, Tid_accept = 5, Tid_accept_language = 6, Tid_accept_encoding = 7, Tid_dnt = 8
, Tid_x_requested_with = 9, Tid_cookie = 10, Tid_referer = 11, Tid_content_length = 12, Tid_content_type = 13, Tid_connection = 14, Tid_pragma = 15, Tid_cache_control = 16, Tid_origin = 17;
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
.Add_str_int("GET" , Tid_get)
.Add_str_int("POST" , Tid_post)
.Add_str_int("Host:" , Tid_host)
@ -166,7 +166,7 @@ public class Http_request_parser {
.Add_str_int("Cache-Control:" , Tid_cache_control)
.Add_str_int("Origin:" , Tid_origin)
;
private static final byte[] Tkn_boundary = Bry_.new_a7("boundary="), Tkn_content_type_boundary_end = Bry_.new_a7("--")
private static final byte[] Tkn_boundary = Bry_.new_a7("boundary="), Tkn_content_type_boundary_end = Bry_.new_a7("--")
, Tkn_content_disposition = Bry_.new_a7("Content-Disposition:"), Tkn_form_data = Bry_.new_a7("form-data;")
, Tkn_name = Bry_.new_a7("name=")
;

@ -18,11 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.core.tests; import gplx.*; import gplx.core.*;
import gplx.core.brys.*;
public class Gftest {
private static Bry_bfr bfr = Bry_bfr.new_();
private static final Bry_bfr bfr = Bry_bfr.new_();
public static void Eq__ary(String[] expd, byte[][] actl, String msg_fmt, Object... msg_args) {Eq__ary(Bry_.Ary(expd), actl, msg_fmt, msg_args);}
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary) {Eq__ary(expd_ary, actl_ary, null);}
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary, String msg_fmt, Object... msg_args) {
byte[][] expd_bry_ary = Bry_bfr_able_.To_bry_ary(bfr, expd_ary);
byte[][] actl_bry_ary = Bry_bfr_able_.To_bry_ary(bfr, actl_ary);
Eq__ary(Bry_bfr_able_.To_bry_ary(bfr, expd_ary), Bry_bfr_able_.To_bry_ary(bfr, actl_ary), msg_fmt, msg_args);
}
public static void Eq__ary(byte[][] expd_bry_ary, byte[][] actl_bry_ary, String msg_fmt, Object... msg_args) {
boolean[] failures = Calc__failures(Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
if (failures != null) {
bfr.Add(Bry__line_bgn);
@ -40,10 +42,11 @@ public class Gftest {
int actl_len = Array_.Len(actl_ary);
for (int i = 0; i < len; ++i) {
boolean failure = failures[i];
bfr.Add_int_pad_bgn(Byte_ascii.Num_0, 5 - Int_.DigitCount(i), i).Add_byte_colon().Add_byte_space();
int pad_len = 5 - Int_.DigitCount(i);
bfr.Add_int_pad_bgn(Byte_ascii.Num_0, pad_len, i).Add_byte_colon().Add_byte_space();
Write__itm(bfr, type_id, expd_ary, expd_len, i);
if (failure) {
bfr.Add(Bry__item__eq_n).Add_byte_repeat(Byte_ascii.Space, 3);
bfr.Add(Bry__item__eq_n).Add_byte_repeat(Byte_ascii.Space, pad_len - 1);
Write__itm(bfr, type_id, actl_ary, actl_len, i);
}
}

@ -44,12 +44,25 @@ public class Fsdb_db_mgr_ {
if (!Db_conn_bldr.Instance.Exists(main_core_url)) return null;
usr_dlg.Log_many("", "", "fsdb.db_core.v2: type=~{0} url=~{1}", layout.Name(), main_core_url.Raw());
Db_conn main_core_conn = Db_conn_bldr.Instance.Get(main_core_url);
if (wiki.Data__core_mgr().Props().Layout_file().Tid_is_all())
if (wiki.Data__core_mgr().Props().Layout_file().Tid_is_all()) {
return new Fsdb_db_mgr__v2(Fsdb_db_mgr__v2.Cfg__layout_file__get(main_core_conn), wiki_dir, new Fsdb_db_file(main_core_url, main_core_conn), new Fsdb_db_file(main_core_url, main_core_conn));
}
Io_url user_core_url = wiki_dir.GenSubFil(Fsdb_db_mgr__v2_bldr.Make_user_name(domain_str));
if (!Db_conn_bldr.Instance.Exists(user_core_url)) // if user file does not exist, create it; needed b/c offline packages don't include file; DATE:2015-04-19
Fsdb_db_mgr__v2_bldr.Instance.Make_core_file_user(wiki, user_core_url, user_core_url.NameAndExt(), main_core_url.NameAndExt());
Db_conn user_core_conn = Db_conn_bldr.Instance.Get(user_core_url);
if (!Db_conn_bldr.Instance.Exists(user_core_url)) { // if user file does not exist, create it; needed b/c offline packages don't include file; DATE:2015-04-19
try {Fsdb_db_mgr__v2_bldr.Make_core_file_user(wiki, user_core_url, user_core_url.NameAndExt(), main_core_url.NameAndExt());}
catch (Exception e) { // do not fail if read-only permissions
usr_dlg.Warn_many("", "", "failed to create user db: url=~{0} err=~{1}", user_core_url.Raw(), Err_.Message_gplx_log(e));
user_core_url = null; // null out for conditional below
}
}
Db_conn user_core_conn = null;
if (user_core_url == null) { // null when write permissions do not exist; for example, on Andriod; DATE:2016-04-22
user_core_url = main_core_url; // default to main_core; note that downloading will still fail, but at least app won't crash; DATE:2016-04-22
user_core_conn = main_core_conn;
}
else {
user_core_conn = Db_conn_bldr.Instance.Get(user_core_url);
}
return new Fsdb_db_mgr__v2(Fsdb_db_mgr__v2.Cfg__layout_file__get(main_core_conn), wiki_dir, new Fsdb_db_file(main_core_url, main_core_conn), new Fsdb_db_file(user_core_url, user_core_conn));
}
}

@ -19,7 +19,7 @@ package gplx.fsdb; import gplx.*;
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.fsdb.meta.*; import gplx.fsdb.data.*; import gplx.xowa.files.origs.*;
import gplx.xowa.*; import gplx.xowa.wikis.data.*; import gplx.xowa.bldrs.infos.*;
public class Fsdb_db_mgr__v2_bldr {
public Fsdb_db_mgr__v2 Get_or_make(Xow_wiki wiki, boolean delete_if_exists) { // NOTE: must check if file exists else imports with existing v2 dbs will fail; DATE:2015-05-23
public static Fsdb_db_mgr__v2 Get_or_make(Xow_wiki wiki, boolean delete_if_exists) { // NOTE: must check if file exists else imports with existing v2 dbs will fail; DATE:2015-05-23
Xowd_db_layout layout = wiki.Data__core_mgr().Props().Layout_file();
String domain_str = wiki.Domain_str();
Io_url wiki_dir = wiki.Fsys_mgr().Root_dir();
@ -37,8 +37,8 @@ public class Fsdb_db_mgr__v2_bldr {
Fsdb_db_file user_core_file = Io_mgr.Instance.ExistsFil(user_core_url) ? Load_core_file(user_core_url) : Make_core_file_user(wiki, user_core_url, user_core_name, main_core_name);
return new Fsdb_db_mgr__v2(layout, wiki_dir, main_core_file, user_core_file);
}
private Fsdb_db_file Load_core_file(Io_url url) {return new Fsdb_db_file(url, Db_conn_bldr.Instance.Get(url));}
private Fsdb_db_file Make_core_file_main(Xow_wiki wiki, Io_url main_core_url, String main_core_name, Xowd_db_layout layout) {
private static Fsdb_db_file Load_core_file(Io_url url) {return new Fsdb_db_file(url, Db_conn_bldr.Instance.Get(url));}
private static Fsdb_db_file Make_core_file_main(Xow_wiki wiki, Io_url main_core_url, String main_core_name, Xowd_db_layout layout) {
Db_conn conn = layout.Tid_is_all() ? Db_conn_bldr.Instance.Get(main_core_url) : Db_conn_bldr.Instance.New(main_core_url); // if all, use existing (assumes same file name); else, create new
conn.Txn_bgn("fsdb__core_file");
Fsdb_db_file rv = Make_core_file(main_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_main);
@ -48,7 +48,7 @@ public class Fsdb_db_mgr__v2_bldr {
conn.Txn_end();
return rv;
}
public Fsdb_db_file Make_core_file_user(Xow_wiki wiki, Io_url user_core_url, String user_file_name, String main_core_name) { // always create file; do not create mnt_tbl;
public static Fsdb_db_file Make_core_file_user(Xow_wiki wiki, Io_url user_core_url, String user_file_name, String main_core_name) { // always create file; do not create mnt_tbl;
Db_conn conn = Db_conn_bldr.Instance.New(user_core_url);
conn.Txn_bgn("fsdb__core_user");
Fsdb_db_file rv = Make_core_file(user_core_url, conn, schema_is_1, Fsm_mnt_mgr.Mnt_idx_user);
@ -58,7 +58,7 @@ public class Fsdb_db_mgr__v2_bldr {
conn.Txn_end();
return rv;
}
private Fsdb_db_file Make_core_file(Io_url core_url, Db_conn core_conn, boolean schema_is_1, int mnt_id) {
private static Fsdb_db_file Make_core_file(Io_url core_url, Db_conn core_conn, boolean schema_is_1, int mnt_id) {
Fsdb_db_file rv = new Fsdb_db_file(core_url, core_conn);
Db_cfg_tbl cfg_tbl = rv.Tbl__cfg();
cfg_tbl.Create_tbl();
@ -109,5 +109,4 @@ public class Fsdb_db_mgr__v2_bldr {
private static String Main_core_name_lot(String wiki_domain) {return wiki_domain + "-file-core.xowa";} // EX: en.wikipedia.org-file-core.xowa
public static String Make_user_name(String wiki_domain) {return wiki_domain + "-file-user.xowa";} // EX: en.wikipedia.org-file-user.xowa
private static final boolean schema_is_1 = false;
public static final Fsdb_db_mgr__v2_bldr Instance = new Fsdb_db_mgr__v2_bldr(); Fsdb_db_mgr__v2_bldr() {}
}
}

@ -70,7 +70,7 @@ public class Gfh_tag_rdr {
}
if (rv == null) {
if (move && tail && !bwd)
err_wkr.Fail("move failed", "tag_name", Gfh_tag_.To_str(match_name_id));
err_wkr.Fail("move tag fwd failed", "tag_name", Gfh_tag_.To_str(match_name_id));
else
return Tag__eos(rng_bgn);
}

@ -28,6 +28,7 @@ public class Json_ary extends Json_itm_base implements Json_grp {
return (Json_nde)rv;
}
public Json_itm Get_at(int i) {return subs[i];}
public Json_nde Get_as_nde(int i) {return Json_nde.cast(subs[i]);}
public Json_ary Add_many(Json_itm... ary) {
int len = ary.length;
for (int i = 0; i < len; i++)

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
import gplx.core.primitives.*;
public class Json_doc {
private final byte[][] tmp_qry_bry = new byte[1][];
private final byte[][] tmp_qry_bry = new byte[1][];
public void Ctor(byte[] src, Json_grp new_root) {
this.src = src;
this.root_grp = new_root;
@ -32,9 +32,9 @@ public class Json_doc {
public Json_grp Root_grp() {return root_grp;} private Json_grp root_grp;
public Json_nde Root_nde() {return root_nde;} private Json_nde root_nde;
public Json_ary Root_ary() {return root_ary;} private Json_ary root_ary;
public Bry_bfr Bfr() {return bfr;} private final Bry_bfr bfr = Bry_bfr.new_();
public Number_parser Utl_num_parser() {return utl_num_parser;} private final Number_parser utl_num_parser = new Number_parser();
public byte[] Tmp_u8_bry() {return tmp_u8_bry;} private final byte[] tmp_u8_bry = new byte[6]; // tmp bry[] for decoding sequences like \u0008
public Bry_bfr Bfr() {return bfr;} private final Bry_bfr bfr = Bry_bfr.new_();
public Number_parser Utl_num_parser() {return utl_num_parser;} private final Number_parser utl_num_parser = new Number_parser();
public byte[] Tmp_u8_bry() {return tmp_u8_bry;} private final byte[] tmp_u8_bry = new byte[6]; // tmp bry[] for decoding sequences like \u0008
public byte[] Get_val_as_bry_or(byte[] qry_bry, byte[] or) {tmp_qry_bry[0] = qry_bry; return Get_val_as_bry_or(tmp_qry_bry, or);}
public byte[] Get_val_as_bry_or(byte[][] qry_bry, byte[] or) {
Json_itm nde = Find_nde(root_nde, qry_bry, qry_bry.length - 1, 0);
@ -71,4 +71,13 @@ public class Json_doc {
return null;
}
public static String Make_str_by_apos(String... ary) {return String_.Replace(String_.Concat_lines_nl_skip_last(ary), "'", "\"");}
public static String[] Make_str_ary_by_apos(String... ary) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
String itm = ary[i];
if (String_.Has(itm, "'"))
ary[i] = String_.Replace(itm, "'", "\"");
}
return ary;
}
}

@ -20,10 +20,11 @@ public interface Json_grp extends Json_itm {
void Src_end_(int v);
int Len();
Json_itm Get_at(int i);
Json_nde Get_as_nde(int i);
void Add(Json_itm itm);
}
class Json_grp_ {
public static final Json_grp[] Ary_empty = new Json_grp[0];
public static final Json_grp[] Ary_empty = new Json_grp[0];
public static void Print_nl(Bry_bfr bfr) { // \n\n can be caused by nested groups (EX: "[[]]"); only print 1
if (bfr.Bfr()[bfr.Len() - 1] != Byte_ascii.Nl)
bfr.Add_byte_nl();

@ -18,19 +18,63 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
public class Json_nde extends Json_itm_base implements Json_grp {
private Json_itm[] subs = Json_itm_.Ary_empty; private int subs_len = 0, subs_max = 0;
private Hash_adp_bry subs_hash;
public Json_nde(Json_doc jdoc, int src_bgn) {this.jdoc = jdoc; this.Ctor(src_bgn, -1);}
@Override public byte Tid() {return Json_itm_.Tid__nde;}
public Json_doc Doc() {return jdoc;} private final Json_doc jdoc;
public Json_doc Doc() {return jdoc;} private final Json_doc jdoc;
public void Src_end_(int v) {this.src_end = v;}
@Override public Object Data() {return null;}
@Override public byte[] Data_bry() {return null;}
public int Len() {return subs_len;}
public Json_itm Get_at(int i) {return subs[i];}
public Json_itm Get_as_itm_or_null(byte[] key) {if (subs_hash == null) subs_hash = subs_hash_init(); return (Json_itm)subs_hash.Get_by_bry(key);}
public Json_ary Get_as_ary(int idx) {return Json_ary.cast(Get_at(idx));}
public Json_nde Get_as_nde(int idx) {return Json_nde.cast(Get_at(idx));}
public Json_ary Get_as_ary(String key) {return Get_as_ary(Bry_.new_u8(key));}
public Json_ary Get_as_ary(byte[] key) {
Json_itm rv = Get_as_itm_or_null(key); if (rv == null) throw Err_.new_("json", "key missing", "key", key);
return Json_ary.cast(rv);
}
public byte[] Get_as_bry_or(byte[] key, byte[] or) {
Json_itm rv = Get_as_itm_or_null(key);
return rv == null ? or : rv.Data_bry();
}
public String Get_as_str(String key) {
String rv = Get_as_str_or(key, null); if (rv == null) throw Err_.new_("json", "key missing", "key", key);
return rv;
}
public String Get_as_str_or(String key, String or) {return Get_as_str_or(Bry_.new_u8(key), or);}
public String Get_as_str_or(byte[] key, String or) {
byte[] rv = Get_as_bry_or(key, null);
return rv == null ? or : String_.new_u8(rv);
}
public int Get_as_int(String key) {
int rv = Get_as_int_or(key, Int_.Min_value); if (rv == Int_.Min_value) throw Err_.new_("json", "key missing", "key", key);
return rv;
}
public int Get_as_int_or(String key, int or) {return Get_as_int_or(Bry_.new_u8(key), or);}
public int Get_as_int_or(byte[] key, int or) {
byte[] rv = Get_as_bry_or(key, null);
return rv == null ? or : Bry_.To_int(rv);
}
public long Get_as_long(String key) {
long rv = Get_as_long_or(key, Long_.Min_value); if (rv == Long_.Min_value) throw Err_.new_("json", "key missing", "key", key);
return rv;
}
public long Get_as_long_or(String key, long or) {return Get_as_long_or(Bry_.new_u8(key), or);}
public long Get_as_long_or(byte[] key, long or) {
byte[] rv = Get_as_bry_or(key, null);
return rv == null ? or : Bry_.To_long_or(rv, or);
}
// to convert
public boolean Has(byte[] key) {return Get_bry(key, null) != null;}
public Json_kv Get_at_as_kv(int i) {
Json_itm rv_itm = Get_at(i);
Json_kv rv = Json_kv.cast(rv_itm); if (rv == null) throw Err_.new_("json", "sub is not kv", "i", i, "src", Bry_.Mid(jdoc.Src(), this.Src_bgn(), src_end));
return rv;
}
public Json_itm Get_at(int i) {return subs[i];}
public Json_kv Get_kv(byte[] key) {return Json_kv.cast(Get_itm(key));}
public Json_nde Get(String key) {return Get(Bry_.new_u8(key));}
public Json_nde Get(byte[] key) {
@ -49,7 +93,9 @@ public class Json_nde extends Json_itm_base implements Json_grp {
}
return null;
}
public boolean Has(byte[] key) {return Get_bry(key, null) != null;}
public Json_ary Get_ary(String key) {return Get_ary(Bry_.new_u8(key));}
public Json_ary Get_ary(byte[] key) {return Json_ary.cast(Get_kv(key).Val_as_ary());}
public String Get_str(String key) {return String_.new_u8(Get_bry(Bry_.new_u8(key)));}
public byte[] Get_bry(byte[] key) {
byte[] rv = Get_bry(key, null); if (rv == null) throw Err_.new_("json", "key missing", "key", key);
return rv;
@ -80,10 +126,10 @@ public class Json_nde extends Json_itm_base implements Json_grp {
}
subs[subs_len] = (Json_itm)itm;
subs_len = new_len;
subs_hash = null;
}
@Override public void Print_as_json(Bry_bfr bfr, int depth) {
if (bfr.Len() != 0)
bfr.Add_byte_nl();
if (bfr.Len() != 0) bfr.Add_byte_nl();
Json_grp_.Print_indent(bfr, depth);
bfr.Add_byte(Byte_ascii.Curly_bgn).Add_byte(Byte_ascii.Space);
for (int i = 0; i < subs_len; i++) {
@ -96,5 +142,16 @@ public class Json_nde extends Json_itm_base implements Json_grp {
Json_grp_.Print_nl(bfr); Json_grp_.Print_indent(bfr, depth);
bfr.Add_byte(Byte_ascii.Curly_end).Add_byte_nl();
}
private Hash_adp_bry subs_hash_init() {
Hash_adp_bry rv = Hash_adp_bry.cs();
for (int i = 0; i < subs_len; ++i) {
Json_itm itm = subs[i];
if (itm.Tid() == Json_itm_.Tid__kv) {
Json_kv itm_as_kv = (Json_kv)itm;
rv.Add(itm_as_kv.Key().Data_bry(), itm_as_kv.Val());
}
}
return rv;
}
public static Json_nde cast(Json_itm v) {return v == null || v.Tid() != Json_itm_.Tid__nde ? null : (Json_nde)v;}
}

@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.langs.jsons; import gplx.*; import gplx.langs.*;
import gplx.core.primitives.*;
public class Json_wtr {
private final Bry_bfr bfr = Bry_bfr.new_(255);
private final Int_ary idx_stack = new Int_ary(4);
private final Bry_bfr bfr = Bry_bfr.new_(255);
private final Int_ary idx_stack = new Int_ary(4);
private int idx = 0;
public Bry_bfr Bfr() {return bfr;}
public void Indent_(int v) {this.indent = v;} private int indent;
@ -38,10 +38,16 @@ public class Json_wtr {
public Json_wtr Doc_nde_end() {Write_grp_end(Bool_.Y, Sym_nde_end); return Write_nl();}
public Json_wtr Doc_ary_bgn() {return Write_grp_bgn(Sym_ary_bgn);}
public Json_wtr Doc_ary_end() {Write_grp_end(Bool_.N, Sym_ary_end); return Write_nl();}
public Json_wtr Nde_bgn_ary() {return Nde_bgn(Bry_.Empty);}
public Json_wtr Nde_bgn(String key) {return Nde_bgn(Bry_.new_u8(key));}
public Json_wtr Nde_bgn(byte[] key) {
Write_indent_itm();
Write_key(key);
if (key == Bry_.Empty) {
bfr.Del_by_1(); // remove trailing space from Write_indent_itm
++idx;
}
else
Write_key(key);
Write_nl();
return Write_grp_bgn(Sym_nde_bgn);
}
@ -277,7 +283,7 @@ public class Json_wtr {
if (opt_ws) bfr.Add_byte_nl();
return this;
}
private static final byte[]
private static final byte[]
Sym_nde_bgn = Bry_.new_a7("{")
, Sym_nde_end = Bry_.new_a7("}")
, Sym_ary_bgn = Bry_.new_a7("[")

@ -22,6 +22,7 @@ public class Mustache_bfr {
public Bry_bfr Bfr() {return bfr;}
public Mustache_bfr Escape_(boolean v) {escape = v; return this;} private boolean escape;
public void Add_int (int v) {bfr.Add_int_variable(v);}
public void Add_long (long v) {bfr.Add_long_variable(v);}
public void Add_double (double v) {bfr.Add_double(v);}
public void Add_str_u8 (String v) {bfr.Add_str_u8(v);}
public void Add_mid (byte[] src, int bgn, int end) {bfr.Add_mid(src, bgn, end);}

@ -22,6 +22,7 @@ import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.sit
import gplx.xowa.apps.gfs.*;
import gplx.xowa.bldrs.css.*;
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.guis.cbks.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.js.*; import gplx.xowa.htmls.bridges.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
import gplx.xowa.langs.*;
@ -45,6 +46,7 @@ public interface Xoa_app extends GfoInvkAble {
Xoh_lnki_bldr Html__lnki_bldr();
Xoa_css_extractor Html__css_installer();
Xoh_bridge_mgr Html__bridge_mgr();
Xog_cbk_mgr Gui__cbk_mgr();
Xou_user User();
Xowmf_mgr Wmf_mgr();
boolean Xwiki_mgr__missing(byte[] domain);

@ -34,7 +34,7 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
public static final String Version = "3.4.3.1";
public static final String Version = "3.4.4.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";

@ -21,6 +21,7 @@ import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.sit
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.apps.cfgs.old.*;
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.guis.cbks.*;
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.guis.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.tocs.*; import gplx.xowa.apps.fmtrs.*; import gplx.xowa.htmls.*; import gplx.xowa.wikis.xwikis.sitelinks.*; import gplx.xowa.wikis.xwikis.parsers.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.ns_files.*; import gplx.xowa.htmls.bridges.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.xndes.*;
@ -93,6 +94,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
public Xoa_special_regy Special_regy() {return special_regy;} private final Xoa_special_regy special_regy = new Xoa_special_regy();
public Xob_bldr Bldr() {return bldr;} private Xob_bldr bldr;
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
public Xoae_wiki_mgr Wiki_mgr() {return wiki_mgr;} private Xoae_wiki_mgr wiki_mgr;

@ -26,7 +26,7 @@ import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.htmls.utls.*; import
import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.installs.*; import gplx.xowa.bldrs.setups.maints.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.utils.*;
import gplx.xowa.wikis.ctgs.*;
import gplx.xowa.guis.views.*;
import gplx.xowa.guis.cbks.*; import gplx.xowa.guis.views.*;
import gplx.xowa.xtns.gallery.*; import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*;
public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
@ -107,6 +107,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
public Xow_site_stats_mgr Stats() {return stats;} private final Xow_site_stats_mgr stats;
public Xow_parser_mgr Parser_mgr() {return parser_mgr;} private final Xow_parser_mgr parser_mgr;
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
public Xoae_app Appe() {return app;} private Xoae_app app;

@ -0,0 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
public interface Xoax_addon_itm__json {
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] Json__cmds();
}

@ -17,6 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
import gplx.xowa.bldrs.wkrs.*;
public interface Xoax_addon_itm__sp {
public interface Xoax_addon_itm__special {
gplx.xowa.specials.Xows_page[] Pages_ary();
}

@ -35,13 +35,20 @@ public class Xoax_addon_mgr {
( gplx.xowa.bldrs.cmds.utils.Xob_alert_cmd.Prototype
);
app.Addon_mgr().Itms__add_many
// bldrs
( new gplx.xowa.addons.builds.files .Xoax_builds_files_addon()
, new gplx.xowa.addons.builds.pagelinks .Xoax_builds_pagelinks_addon()
, new gplx.xowa.addons.builds.utils_rankings .Xoax_builds_utils_rankings_addon()
, new gplx.xowa.addons.apps.searchs .Xoax_builds_search_addon()
, new gplx.xowa.addons.apps.file_browsers .Fbrow_addon()
, new gplx.xowa.addons.updates.files .Xoax_updates_files_addon()
, new gplx.xowa.addons.builds.htmls .Html__dump_to_fsys__addon()
// specials
, new gplx.xowa.addons.apps.file_browsers .Fbrow_addon()
, new gplx.xowa.addons.updates.downloads .Xoax_downloads_addon()
// jsons
, new gplx.xowa.addons.servers.https .Xoax_long_poll_addon()
);
return this;
}
@ -53,10 +60,17 @@ public class Xoax_addon_mgr {
Xoax_addon_itm__bldr addon_bldr = (Xoax_addon_itm__bldr)addon;
app.Bldr().Cmd_regy().Add_many(addon_bldr.Cmds_ary());
}
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__sp.class)) {
Xoax_addon_itm__sp addon_sp = (Xoax_addon_itm__sp)addon;
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__special.class)) {
Xoax_addon_itm__special addon_sp = (Xoax_addon_itm__special)addon;
app.Special_regy().Add_many(addon_sp.Pages_ary());
}
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__json.class)) {
Xoax_addon_itm__json addon_json = (Xoax_addon_itm__json)addon;
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] json_cmds = addon_json.Json__cmds();
for (gplx.xowa.htmls.bridges.Bridge_cmd_itm json_cmd : json_cmds)
app.Html__bridge_mgr().Cmd_mgr().Add(json_cmd);
}
}
app.Gui__cbk_mgr().Reg(gplx.xowa.addons.servers.https.Xog_cbk_wkr__http.Instance);
}
}

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
import gplx.xowa.specials.*;
public class Fbrow_addon implements Xoax_addon_itm, Xoax_addon_itm__sp {
public class Fbrow_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
public Xows_page[] Pages_ary() {
return new Xows_page[]
{ Fbrow_special_page.Prototype

@ -16,9 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
import gplx.core.ios.*; import gplx.core.net.*;
import gplx.xowa.specials.*;
import gplx.xowa.wikis.pages.*;
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
import gplx.core.ios.*;
public class Fbrow_special_page implements Xows_page {
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
Xopage_html_data html_data = Write_html(wiki.App(), url.Qargs_ary());

@ -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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
import gplx.xowa.specials.*; import gplx.core.ios.*; import gplx.core.net.*;
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
public class Wikis_list_page implements Xows_page {
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
Xoa_url_arg_mgr arg_mgr = new Xoa_url_arg_mgr(null).Init(url.Qargs_ary());

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
import gplx.core.primitives.*; import gplx.core.net.*;
class Xoa_url_arg_mgr {
public class Xoa_url_arg_mgr {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
private final Xoa_url_enum_mgr enm_mgr;
public Xoa_url_arg_mgr(Xoa_url_enum_mgr enm_mgr) {this.enm_mgr = enm_mgr;}
@ -48,27 +48,3 @@ class Xoa_url_arg_mgr {
return arg == null ? null : String_.new_u8(arg.Val_bry());
}
}
class Xoa_url_enum_mgr {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
public Xoa_url_enum_mgr(Xoa_url_enum_itm... ary) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Xoa_url_enum_itm itm = ary[i];
hash.Add_bry_obj(itm.Key(), itm);
}
}
public Xoa_url_enum_itm Get(byte[] key) {return (Xoa_url_enum_itm)hash.Get_by_bry(key);}
}
class Xoa_url_enum_itm {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
public Xoa_url_enum_itm(byte[] key) {this.key = key;}
public byte[] Key() {return key;} private final byte[] key;
public Xoa_url_enum_itm Add(String key, int val) {
hash.Add_bry_obj(Bry_.new_u8(key), Int_obj_val.new_(val));
return this;
}
public int Get_as_int_or(byte[] val, int or) {
Int_obj_val rv = (Int_obj_val)hash.Get_by_bry(val);
return rv == null ? or : rv.Val();
}
}

@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
public class Xoa_url_enum_itm {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
public Xoa_url_enum_itm(byte[] key) {this.key = key;}
public byte[] Key() {return key;} private final byte[] key;
public Xoa_url_enum_itm Add(String key, int val) {
hash.Add_bry_int(Bry_.new_u8(key), val);
return this;
}
public int Get_as_int_or(byte[] val, int or) {return hash.Get_as_int_or(val, or);}
}

@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
public class Xoa_url_enum_mgr {
private final Hash_adp_bry hash = Hash_adp_bry.cs();
public Xoa_url_enum_mgr(Xoa_url_enum_itm... ary) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Xoa_url_enum_itm itm = ary[i];
hash.Add_bry_obj(itm.Key(), itm);
}
}
public Xoa_url_enum_itm Get(byte[] key) {return (Xoa_url_enum_itm)hash.Get_by_bry(key);}
}

@ -69,7 +69,7 @@ public class Xobldr__fsdb_db__create_data extends Xob_cmd__base implements Xob_c
this.trg_bin_db_max = app.Api_root().Bldr().Wiki().Import().File_db_max();
Io_url trg_file_dir_v1 = String_.Eq(trg_bin_mgr__fsdb_version, "v1") ? wiki.Fsys_mgr().File_dir().GenNewNameOnly(wiki.Domain_str() + "-prv") : wiki.Fsys_mgr().File_dir(); // NOTE: convoluted way of setting trg to -prv if trg_bin_mgr__fsdb_version_v1 is set; otherwise set to "en.wikipedia.org" which will noop; DATE:2015-12-02
Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), trg_file_dir_v1);
if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, Bool_.Y);
if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
Fsm_mnt_mgr trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(trg_db_mgr);
trg_mnt_mgr.Mnts__get_insert_idx_(Fsm_mnt_mgr.Mnt_idx_main); // NOTE: do not delete; mnt_mgr default to Mnt_idx_user; DATE:2014-04-25
this.trg_mnt_itm = trg_mnt_mgr.Mnts__get_insert();

@ -76,7 +76,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
gplx.xowa.xtns.math.Math_nde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y); // enabled; DATE:2015-10-10
Xof_fsdb_mgr__sql trg_fsdb_mgr = new Xof_fsdb_mgr__sql();
wiki.File__fsdb_mode().Tid_v2_bld_y_();
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, Bool_.Y);
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
trg_fsdb_mgr.Init_by_wiki(wiki);
Fsm_mnt_mgr trg_mnt_mgr = trg_fsdb_mgr.Mnt_mgr();
wiki.File_mgr().Init_file_mgr_by_load(wiki); // must happen after fsdb.make

@ -0,0 +1,47 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
public class Http_long_poll_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
private final List_adp msgs = List_adp_.new_();
private long send_time_prv = 0;
public int Sleep_interval = 100;
public int Send_interval = 1000;
public void Send_msg(String msg) {
msgs.Add(msg);
}
public String Exec(gplx.langs.jsons.Json_nde data) {
while (true) {
if (msgs.Len() == 0) {
gplx.core.threads.Thread_adp_.Sleep(Sleep_interval);
}
else {
long send_time_cur = gplx.core.envs.Env_.TickCount();
if (send_time_cur - send_time_prv > Send_interval) {
send_time_prv = send_time_cur;
break;
}
}
}
return String_.Concat_lines_nl(msgs.To_str_ary_and_clear());
}
public byte[] Key() {return BRIDGE_KEY;}
public static final byte[] BRIDGE_KEY = Bry_.new_a7("long_poll");
public static final Http_long_poll_cmd Instance = new Http_long_poll_cmd(); Http_long_poll_cmd() {}
}

@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
public class Http_send_msg_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
public String Exec(gplx.langs.jsons.Json_nde data) {
gplx.langs.jsons.Json_nde jnde = (gplx.langs.jsons.Json_nde)data.Get_as_itm_or_null(Bry_.new_a7("msg"));
Http_long_poll_cmd.Instance.Send_msg(jnde.Print_as_json());
return "{}";
}
public byte[] Key() {return BRIDGE_KEY;}
public static final byte[] BRIDGE_KEY = Bry_.new_a7("send_msg");
}

@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.htmls.bridges.*;
public class Xoax_long_poll_addon implements Xoax_addon_itm, Xoax_addon_itm__json {
public Bridge_cmd_itm[] Json__cmds() {
return new Bridge_cmd_itm[]
{ Http_long_poll_cmd.Instance
, new Http_send_msg_cmd()
};
}
public static final byte[] ADDON_KEY = Bry_.new_a7("xowa.servers.https.long_poll");
public byte[] Addon__key() {return ADDON_KEY;}
}

@ -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.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
import gplx.xowa.guis.cbks.*;
public class Xog_cbk_wkr__http implements Xog_cbk_wkr {
public void Send_prog(String head) {
Http_long_poll_cmd.Instance.Send_msg(head);
}
public static final Xog_cbk_wkr__http Instance = new Xog_cbk_wkr__http(); Xog_cbk_wkr__http() {}
}

@ -0,0 +1,41 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
import gplx.xowa.specials.*;
public class Xoax_downloads_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
public Xows_page[] Pages_ary() {
return new Xows_page[]
{ Xodl_special_page.Prototype
};
}
public static final byte[] ADDON_KEY = Bry_.new_a7("xowa.imports.downloads");
public byte[] Addon__key() {return ADDON_KEY;}
}
// class Xodl_core_regy {
// public void Update() {} // update from http
// public void Load() {} // load bin/
// }
// class Xodl_user_regy {
// public void Load() {}
// public void Apply() {} // mark already downloaded items
// }
// class Xodl_main_mgr {
// public void Show_ui() {} // show list for ui
// public void Process() {} // process choices
// }

@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
import gplx.xowa.addons.updates.downloads.core.*;
import gplx.xowa.addons.updates.downloads.itms.*;
class Xodl_download_mgr implements Gfo_download_cbk {
public void Download(Gfo_download_wkr download_wkr, Xodl_itm_pack[] packs) {
download_wkr.Download__bgn(this, packs);
}
public void Download__end_itm(Gfo_download_itm itm) {
// unzip; start
}
public void Download__end_all(Gfo_download_itm[] itms) {}
public void Unzip__end(Gfo_download_itm[] itms) {
// register
}
}

@ -0,0 +1,63 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.addons.updates.downloads.itms.*; import gplx.xowa.addons.updates.downloads.core.*;
import gplx.xowa.addons.apps.file_browsers.*;
public class Xodl_special_page implements Xows_page {
public static Gfo_download_wkr Download_wkr = Gfo_download_wkr_.Noop;
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
Io_url addon_dir = wiki.App().Fsys_mgr().Bin_addon_dir().GenSubDir_nest("import", "wiki_download");
Xoa_url_arg_mgr arg_mgr = new Xoa_url_arg_mgr(null).Init(url.Qargs_ary());
byte[] ids_bry = arg_mgr.Read_bry_or_null("ids");
if (ids_bry == null) {
Xopage_html_data html_data = Write_html(wiki.App(), addon_dir);
html_data.Apply(page);
}
else {
Xodl_itm_regy regy = Load_regy(addon_dir);
int[] ids_ary = Int_.Ary_parse(String_.new_u8(ids_bry), ",");
Xodl_itm_pack[] packs = regy.Packs__select(ids_ary);
if (packs.length > 0) {
Xodl_download_mgr download_mgr = new Xodl_download_mgr();
download_mgr.Download(Download_wkr, packs);
}
}
}
private static Xodl_itm_regy Load_regy(Io_url addon_dir) {
return Xodl_itm_regy.Load_by_json(addon_dir.GenSubFil_nest("data", "wiki_download.json"));
}
private static Xopage_html_data Write_html(Xoa_app app, Io_url addon_dir) {
// write body
Xodl_itm_regy owner_itm = Load_regy(addon_dir);
byte[] template_src = Io_mgr.Instance.LoadFilBry(addon_dir.GenSubFil_nest("bin", "wiki_download.mustache.html"));
Bry_bfr tmp_bfr = Bry_bfr.new_();
byte[] body = gplx.langs.mustaches.Mustache_wtr_.Write_to_bry(tmp_bfr, template_src, owner_itm);
// write head
Xopage_html_data rv = new Xopage_html_data(Display_ttl, body);
rv.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "wiki_download.css")));
return rv;
}
public static final String SPECIAL_KEY = "XowaWikiDownload";
public static final byte[] Display_ttl = Bry_.new_a7("Download wikis");
public Xows_special_meta Special__meta() {return new Xows_special_meta(Xows_special_meta_.Src__xowa, SPECIAL_KEY);}
public static final Xows_page Prototype = new Xodl_special_page();
public Xows_page Special__clone() {return this;}
}

@ -0,0 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public interface Gfo_download_cbk {
void Download__end_itm(Gfo_download_itm itm);
void Download__end_all(Gfo_download_itm[] itms);
}

@ -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.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public interface Gfo_download_itm {
String Download__src();
Io_url Download__trg();
void Download__trg_(Io_url v);
}

@ -0,0 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public interface Gfo_download_wkr {
void Download__bgn(Gfo_download_cbk cbk, Gfo_download_itm[] itms);
}

@ -0,0 +1,24 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public class Gfo_download_wkr_ {
public static final Gfo_download_wkr Noop = new Gfo_download_wkr__noop();
}
class Gfo_download_wkr__noop implements Gfo_download_wkr {
public void Download__bgn(Gfo_download_cbk cbk, Gfo_download_itm[] itms) {cbk.Download__end_all(itms);}
}

@ -0,0 +1,82 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
import gplx.langs.jsons.*; import gplx.langs.mustaches.*;
import gplx.xowa.addons.updates.downloads.core.*;
public class Xodl_itm_pack implements Mustache_doc_itm, Gfo_download_itm {
public int Id = -1; // EX: 1
public String Wiki = ""; // EX: 'simple.wikipedia.org'
public String Date = ""; // EX: '2016-04-07'
public String Type = ""; // EX: 'html' or 'file'
public String Name = ""; // EX: 'html: complete'
public long Size = 0; // EX: 1234
public String Url = ""; // EX: https://archive.org/download/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-06_html.7z
public int Ns = -1; // EX: 0
public int Part = -1; // EX: 1, 2
public Xodl_itm_pack() {}
public Xodl_itm_pack(int id, String wiki, String date, String type, int ns, int part, String name, long size, String url) {
this.Id = id;
this.Wiki = wiki;
this.Date = date;
this.Type = type;
this.Ns = ns;
this.Part = part;
this.Name = name;
this.Size = size;
this.Url = url;
}
public String Download__src() {return Url;}
public Io_url Download__trg() {return trg;} private Io_url trg; public void Download__trg_(Io_url v) {this.trg = v;}
public void To_json(Json_wtr wtr) {
wtr.Kv_int("id", Id);
wtr.Kv_str("wiki", Wiki);
wtr.Kv_str("date", Date);
wtr.Kv_str("type", Type);
wtr.Kv_str("name", Name);
wtr.Kv_long("size", Size);
wtr.Kv_str("url", Url);
if (Ns != -1) wtr.Kv_int("ns", Ns);
if (Part != -1) wtr.Kv_int("part", Part);
}
public void By_json(Json_nde nde) {
this.Id = nde.Get_as_int("id");
this.Wiki = nde.Get_as_str("wiki");
this.Date = nde.Get_as_str("date");
this.Type = nde.Get_as_str("type");
this.Name = nde.Get_as_str("name");
this.Size = nde.Get_as_long("size");
this.Url = nde.Get_as_str("url");
this.Ns = nde.Get_as_int_or("ns", -1);
this.Part = nde.Get_as_int_or("part", -1);
}
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "id")) bfr.Add_int(Id);
else if (String_.Eq(key, "wiki")) bfr.Add_str_u8(Wiki);
else if (String_.Eq(key, "date")) bfr.Add_str_u8(Date);
else if (String_.Eq(key, "type")) bfr.Add_str_u8(Type);
else if (String_.Eq(key, "name")) bfr.Add_str_u8(Name);
else if (String_.Eq(key, "size")) bfr.Add_long(Size);
else if (String_.Eq(key, "url")) bfr.Add_str_u8(Url);
else if (String_.Eq(key, "ns")) bfr.Add_int(Ns);
else if (String_.Eq(key, "part")) bfr.Add_int(Part);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {return Mustache_doc_itm_.Ary__empty;}
public static final Xodl_itm_pack[] Ary_empty = new Xodl_itm_pack[0];
}

@ -0,0 +1,76 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
import gplx.langs.jsons.*; import gplx.langs.mustaches.*;
public class Xodl_itm_regy implements Mustache_doc_itm {
public Xodl_itm_pack[] Packs = Xodl_itm_pack.Ary_empty;
public Xodl_itm_regy() {}
public Xodl_itm_regy(Xodl_itm_pack[] pack_ary) {this.Packs = pack_ary;}
public Xodl_itm_pack[] Packs__select(int[] ids) {
Hash_adp packs_hash = Hash_adp_.new_();
int packs_len = Packs.length;
for (int i = 0; i < packs_len; ++i) {
Xodl_itm_pack pack = Packs[i];
packs_hash.Add(pack.Id, pack);
}
List_adp rv = List_adp_.new_();
int ids_len = ids.length;
for (int i = 0; i < ids_len; ++i) {
int id = ids[i];
Xodl_itm_pack pack = (Xodl_itm_pack)packs_hash.Get_by(id);
if (pack != null)
rv.Add(pack);
}
return (Xodl_itm_pack[])rv.To_ary_and_clear(Xodl_itm_pack.class);
}
public void To_json(Json_wtr wtr) {
wtr.Doc_ary_bgn();
int wikis_len = Packs.length;
for (int i = 0; i < wikis_len; ++i) {
wtr.Nde_bgn_ary();
Xodl_itm_pack wiki = Packs[i];
wiki.To_json(wtr);
wtr.Nde_end();
}
wtr.Doc_ary_end();
}
public void By_json(Json_grp ary) {
int len = ary.Len();
Packs = new Xodl_itm_pack[len];
for (int i = 0; i < len; ++i) {
Json_nde sub_nde = ary.Get_as_nde(i);
Xodl_itm_pack sub_itm = new Xodl_itm_pack();
Packs[i] = sub_itm;
sub_itm.By_json(sub_nde);
}
}
public boolean Mustache__write(String key, Mustache_bfr bfr) {return false;}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "packs")) return Packs;
return Mustache_doc_itm_.Ary__empty;
}
public static Xodl_itm_regy Load_by_json(Io_url url) {return Load_by_json(Io_mgr.Instance.LoadFilBry(url));}
public static Xodl_itm_regy Load_by_json(byte[] bry) {
Xodl_itm_regy rv = new Xodl_itm_regy();
Json_parser parser = new Json_parser();
Json_doc jdoc = parser.Parse(bry);
rv.By_json(jdoc.Root_grp());
return rv;
}
}

@ -0,0 +1,68 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.langs.jsons.*;
public class Xodl_itm_regy_tst {
private final Xodl_itm_regy_fxt fxt = new Xodl_itm_regy_fxt();
@Test public void Basic() {
fxt.Test__srl
( Json_doc.Make_str_ary_by_apos
( "["
, " { 'id':1"
, " , 'wiki':'simple.wikipedia.org'"
, " , 'date':'2016-04-07'"
, " , 'type':'html'"
, " , 'name':'html: complete'"
, " , 'size':1234"
, " , 'url':'http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_html.zip'"
, " }"
, ","
, " { 'id':2"
, " , 'wiki':'simple.wikipedia.org'"
, " , 'date':'2016-04-07'"
, " , 'type':'file'"
, " , 'name':'file: complete'"
, " , 'size':4321"
, " , 'url':'http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_file.zip'"
, " }"
, "]"
)
, fxt.Make__regy
( fxt.Make__pack(1, "simple.wikipedia.org", "2016-04-07", "html", -1, -1, "html: complete", 1234, "http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_html.zip")
, fxt.Make__pack(2, "simple.wikipedia.org", "2016-04-07", "file", -1, -1, "file: complete", 4321, "http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_file.zip")
)
);
}
}
class Xodl_itm_regy_fxt {
private final Json_wtr wtr = new Json_wtr();
public Xodl_itm_regy Make__regy(Xodl_itm_pack... pack_ary) {return new Xodl_itm_regy(pack_ary);}
public Xodl_itm_pack Make__pack(int id, String wiki, String date, String type, int ns, int part, String name, long size, String url) {return new Xodl_itm_pack(id, wiki, date, type, ns, part, name, size, url);}
public Xodl_itm_regy_fxt Test__srl(String[] json, Xodl_itm_regy regy) {
regy.To_json(wtr);
byte[][] json_bry = wtr.Bfr().To_bry_ary_and_clear();
Gftest.Eq__ary(json, json_bry, "to_json");
regy = Xodl_itm_regy.Load_by_json(Bry_.Add(json_bry));
regy.To_json(wtr);
json_bry = wtr.Bfr().To_bry_ary_and_clear();
Gftest.Eq__ary(json, json_bry, "by_json");
return this;
}
}

@ -0,0 +1,21 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public interface Gfo_unzip_cbk {
void Unzip__end_itm(Gfo_unzip_itm itm);
}

@ -0,0 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public interface Gfo_unzip_itm {
Io_url Unzip__src_fil();
Io_url Unzip__trg_dir();
}

@ -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.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
public interface Gfo_unzip_wkr {
void Unzip__bgn(Gfo_unzip_cbk cbk, Gfo_unzip_itm itm);
}
class Gfo_unzip_wkr__noop implements Gfo_unzip_wkr {
public void Unzip__bgn(Gfo_unzip_cbk cbk, Gfo_unzip_itm itm) {cbk.Unzip__end_itm(itm);}
public static final Gfo_unzip_wkr__noop Instance = new Gfo_unzip_wkr__noop(); Gfo_unzip_wkr__noop() {}
}

@ -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.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
import gplx.core.ios.zips.*;
class Gfo_unzip_wkr__jre implements Gfo_unzip_wkr {
public void Unzip__bgn(Gfo_unzip_cbk cbk, Gfo_unzip_itm itm) {
Io_zip_mgr_base.Instance.Unzip_to_dir(itm.Unzip__src_fil(), itm.Unzip__trg_dir());
cbk.Unzip__end_itm(itm);
}
public static final Gfo_unzip_wkr__jre Instance = new Gfo_unzip_wkr__jre(); Gfo_unzip_wkr__jre() {}
}

@ -25,6 +25,7 @@ import gplx.xowa.apps.gfs.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.bridges.*;
import gplx.xowa.users.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
import gplx.xowa.guis.cbks.*;
import gplx.xowa.langs.*;
import gplx.xowa.bldrs.wms.*;
import gplx.langs.htmls.encoders.*;
@ -74,6 +75,7 @@ public class Xoav_app implements Xoa_app, GfoInvkAble {
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
public Xob_bldr Bldr() {return bldr;} private final Xob_bldr bldr;
public Xoa_special_regy Special_regy() {return special_regy;} private final Xoa_special_regy special_regy = new Xoa_special_regy();
public Xog_cbk_mgr Gui__cbk_mgr() {return gui__cbk_mgr;} private final Xog_cbk_mgr gui__cbk_mgr = new Xog_cbk_mgr();
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;

@ -18,14 +18,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apps.apis.xowa.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.xowa.apps.apis.xowa.bldrs.filters.*;
import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
import gplx.xowa.apps.apis.xowa.bldrs.runners.*;
public class Xoapi_bldr_wiki implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {filter.Ctor_by_app(app);}
public Xoapi_filter Filter() {return filter;} private final Xoapi_filter filter = new Xoapi_filter();
public Xoapi_import Import() {return import_api;} private final Xoapi_import import_api = new Xoapi_import();
public void Ctor_by_app(Xoa_app app) {
filter.Ctor_by_app(app);
runner.Ctor_by_app(app);
}
public Xoapi_filter Filter() {return filter;} private final Xoapi_filter filter = new Xoapi_filter();
public Xoapi_import Import() {return import_api;} private final Xoapi_import import_api = new Xoapi_import();
public Xoapi_runner Runner() {return runner;} private final Xoapi_runner runner = new Xoapi_runner();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_filter)) return filter;
else if (ctx.Match(k, Invk_import)) return import_api;
else if (ctx.Match(k, Invk_runner)) return runner;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_filter = "filter", Invk_import = "import";
private static final String Invk_filter = "filter", Invk_import = "import", Invk_runner = "runner";
}

@ -0,0 +1,47 @@
/*
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.apis.xowa.bldrs.runners; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*;
public class Xoapi_runner implements GfoInvkAble {
private Xoa_app app;
public void Ctor_by_app(Xoa_app app) {this.app = app;}
private void Exec(GfoMsg msg) {
// int len = msg.Args_count();
// String cmd = (String)msg.Args_getAt(0).Val();
// Keyval[] args = new Keyval[len - 1];
// for (int i = 1; i < len; ++i) {
// String arg = (String)msg.Args_getAt(i).Val();
// int eq_pos = String_.FindFwd(arg, "=");
// String key = String_.Mid(arg, 0, eq_pos);
// String val = String_.Mid(arg, eq_pos + 1);
// args[i - 1] = Keyval_.new_(key, val);
// }
// gplx.core.ios.zips.Io_zip_decompress_task task = new gplx.core.ios.zips.Io_zip_decompress_task();
// task.Init(true, Gfo
app.Gui__cbk_mgr().Send_prog("test", "key_0", "val_0");
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_exec)) Exec(m);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_exec = "exec";
}
class Xodl_prog_ui implements gplx.core.progs.Gfo_prog_ui {
public void Prog__update_val(long cur, long max) {}
public void Prog__end() {}
}

@ -19,7 +19,7 @@ package gplx.xowa.bldrs.cmds.texts.sqls; import gplx.*; import gplx.xowa.*; impo
import gplx.dbs.cfgs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.*;
public class Xob_term_cmd extends Xob_term_base {
public Xob_term_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Ctor(bldr, wiki); this.wiki = wiki;} private Xowe_wiki wiki;
@Override public String Cmd_key() {return KEY;} public static final String KEY = "text.term";
@Override public String Cmd_key() {return KEY;} public static final String KEY = "text.term";
@Override public void Cmd_end_hook() {
Io_mgr.Instance.DeleteDirDeep(wiki.Fsys_mgr().Tmp_dir());
Db_cfg_tbl cfg_tbl = wiki.Data__core_mgr().Tbl__cfg();
@ -27,7 +27,7 @@ public class Xob_term_cmd extends Xob_term_base {
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__main_page, wiki.Props().Main_page());
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp__wiki_init, "props.siteinfo_misc", wiki.Props().Siteinfo_misc());
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp__wiki_init, "props.siteinfo_mainpage", wiki.Props().Siteinfo_mainpage());
gplx.fsdb.Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, false);// always build file.user db; DATE:2015-05-12
gplx.fsdb.Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, false);// always build file.user db; DATE:2015-05-12
if (wiki.Appe().Api_root().Bldr().Wiki().Filter().Dansguardian().Enabled()) // if dansguardian, delete missing pages; DATE:2016-01-06
new Xob_page_delete_cmd(wiki.Appe().Bldr(), wiki).Cmd_run();
wiki.Data__core_mgr().Rls();

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

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import gplx.core.ios.*; import gplx.core.envs.*;
import gplx.core.ios.zips.*; import gplx.core.envs.*;
import gplx.xowa.apps.fsys.*;
public class Xoi_firefox_installer implements GfoInvkAble {
private Io_url src_xpi, trg_xpi;
@ -61,5 +61,5 @@ public class Xoi_firefox_installer implements GfoInvkAble {
if (ctx.Match(k, Invk_install)) Install_via_process();
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_program = "program", Invk_install = "install";
} private static final String Invk_program = "program", Invk_install = "install";
}

@ -29,7 +29,7 @@ public class Xow_file_mgr implements GfoInvkAble {
wkr_mgr = new Xof_wkr_mgr(this);
}
public Fsdb_db_mgr Db_core() {return db_core;} private Fsdb_db_mgr db_core;
public Xof_orig_mgr Orig_mgr() {return orig_mgr;} private final Xof_orig_mgr orig_mgr = new Xof_orig_mgr();
public Xof_orig_mgr Orig_mgr() {return orig_mgr;} private final Xof_orig_mgr orig_mgr = new Xof_orig_mgr();
public Xof_fsdb_mode Fsdb_mode() {
if (fsdb_mode == null) {
Version();
@ -125,7 +125,7 @@ public class Xow_file_mgr implements GfoInvkAble {
if ( db_core == null // "-file-core.xowa" not found
&& !wiki.Data__core_mgr().Props().Layout_file().Tid_is_all() // DATE:2015-08-10
)
db_core = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, false); // make it
db_core = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, false); // make it
this.version = Version_2;
this.fsdb_mode = Xof_fsdb_mode.new_v2_gui();
orig_mgr.Init_by_wiki(wiki, fsdb_mode, db_core.File__orig_tbl_ary(), Xof_url_bldr.new_v2());

@ -21,12 +21,12 @@ import gplx.fsdb.meta.*;
import gplx.xowa.files.repos.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.cnvs.*; import gplx.xowa.files.caches.*;
import gplx.xowa.bldrs.wms.*;
public class Xof_bin_mgr {
private final Fsm_mnt_mgr mnt_mgr;
private final Gfo_usr_dlg usr_dlg; private final Xow_repo_mgr repo_mgr; private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2();
private final Fsm_mnt_mgr mnt_mgr;
private final Gfo_usr_dlg usr_dlg; private final Xow_repo_mgr repo_mgr; private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2();
private Xof_bin_wkr[] wkrs = Xof_bin_wkr_.Ary_empty; private int wkrs_len;
private final String_obj_ref resize_warning = String_obj_ref.null_(); private final Xof_img_size tmp_size = new Xof_img_size();
private final Io_download_fmt download_fmt;
private final Io_stream_rdr_wrapper rdr_wrapper = new Io_stream_rdr_wrapper();
private final String_obj_ref resize_warning = String_obj_ref.null_(); private final Xof_img_size tmp_size = new Xof_img_size();
private final Io_download_fmt download_fmt;
private final Io_stream_rdr_wrapper rdr_wrapper = new Io_stream_rdr_wrapper();
public Xof_bin_mgr(Fsm_mnt_mgr mnt_mgr, Xow_repo_mgr repo_mgr, Xof_img_wkr_resize_img resize_wkr, Io_download_fmt download_fmt) {
this.mnt_mgr = mnt_mgr; this.repo_mgr = repo_mgr; this.download_fmt = download_fmt;
this.usr_dlg = Gfo_usr_dlg_.Instance;

@ -24,7 +24,7 @@ import gplx.xowa.wikis.nss.*;
import gplx.xowa.parsers.lnkis.*;
class Xof_file_fxt {
private Xoae_app app; private Xof_fsdb_mgr__sql fsdb_mgr; private Xowe_wiki wiki; private Xof_orig_mgr orig_mgr;
private final Fsd_thm_itm tmp_thm = Fsd_thm_itm.new_(); private final Fsd_img_itm tmp_img = new Fsd_img_itm();
private final Fsd_thm_itm tmp_thm = Fsd_thm_itm.new_(); private final Fsd_img_itm tmp_img = new Fsd_img_itm();
public void Rls() {}
public void Reset() {
Io_mgr.Instance.InitEngine_mem(); // NOTE: files are downloaded to mem_engine, regardless of Db being mem or sqlite; always reset
@ -38,7 +38,7 @@ class Xof_file_fxt {
Xof_repo_fxt.Repos_init(app.File_mgr(), true, wiki);
Xowe_wiki_.Create(wiki, 1, "dump.xml");
Xowd_db_file text_db = wiki.Data__core_mgr().Dbs__make_by_tid(Xowd_db_file_.Tid_text); text_db.Tbl__text().Create_tbl();
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, Bool_.Y);
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
fsdb_mgr.Mnt_mgr().Ctor_by_load(fsdb_core);
fsdb_mgr.Mnt_mgr().Mnts__get_main().Bin_mgr().Dbs__make("temp.xowa");
wiki.File_mgr().Init_file_mgr_by_load(wiki);
@ -107,11 +107,11 @@ class Xof_repo_fxt {
}
class Xof_orig_arg {
Xof_orig_arg(byte repo, byte[] page, int w, int h, byte[] redirect) {this.repo = repo; this.page = page; this.w = w; this.h = h; this.redirect = redirect;}
public byte Repo() {return repo;} private final byte repo;
public byte[] Page() {return page;} private final byte[] page;
public int W() {return w;} private final int w;
public int H() {return h;} private final int h;
public byte[] Redirect() {return redirect;} private final byte[] redirect;
public byte Repo() {return repo;} private final byte repo;
public byte[] Page() {return page;} private final byte[] page;
public int W() {return w;} private final int w;
public int H() {return h;} private final int h;
public byte[] Redirect() {return redirect;} private final byte[] redirect;
public static Xof_orig_arg new_comm_file(String page) {return new_(Bool_.Y, page, Xof_img_size.Size_null, Xof_img_size.Size_null);}
public static Xof_orig_arg new_comm(String page, int w, int h) {return new_(Bool_.Y, page, w, h);}
public static Xof_orig_arg new_wiki(String page, int w, int h) {return new_(Bool_.N, page, w, h);}
@ -128,17 +128,17 @@ class Xof_fsdb_arg {
Xof_fsdb_arg(byte[] wiki, byte[] ttl, boolean is_thumb, int ext, int w, int h, int time, byte[] bin) {
this.wiki = wiki; this.ttl = ttl; this.is_thumb = is_thumb; this.w = w; this.h = h; this.time = time; this.ext = ext; this.bin = bin;
}
public byte[] Wiki() {return wiki;} private final byte[] wiki;
public byte[] Ttl() {return ttl;} private final byte[] ttl;
public int Ext() {return ext;} private final int ext;
public boolean Is_thumb() {return is_thumb;} private final boolean is_thumb;
public int W() {return w;} private final int w;
public int H() {return h;} private final int h;
public double Time() {return time;} private final double time;
public int Page() {return page;} private final int page = Xof_lnki_page.Null;
public byte[] Bin() {return bin;} private final byte[] bin;
public DateAdp Modified() {return modified;} private final DateAdp modified = Fsd_thm_tbl.Modified_null;
public String Hash() {return hash;} private final String hash = Fsd_thm_tbl.Hash_null;
public byte[] Wiki() {return wiki;} private final byte[] wiki;
public byte[] Ttl() {return ttl;} private final byte[] ttl;
public int Ext() {return ext;} private final int ext;
public boolean Is_thumb() {return is_thumb;} private final boolean is_thumb;
public int W() {return w;} private final int w;
public int H() {return h;} private final int h;
public double Time() {return time;} private final double time;
public int Page() {return page;} private final int page = Xof_lnki_page.Null;
public byte[] Bin() {return bin;} private final byte[] bin;
public DateAdp Modified() {return modified;} private final DateAdp modified = Fsd_thm_tbl.Modified_null;
public String Hash() {return hash;} private final String hash = Fsd_thm_tbl.Hash_null;
public static Xof_fsdb_arg new_comm_file(String ttl) {return new_(Xow_domain_itm_.Bry__commons, Bool_.N, ttl, Xof_img_size.Null, Xof_img_size.Null, Xof_lnki_time.Null_as_int);}
public static Xof_fsdb_arg new_comm_thumb(String ttl) {return new_(Xow_domain_itm_.Bry__commons, Bool_.Y, ttl, W_default, H_default, Xof_lnki_time.Null_as_int);}
public static Xof_fsdb_arg new_comm_thumb(String ttl, int w, int h) {return new_(Xow_domain_itm_.Bry__commons, Bool_.Y, ttl, w, h, Xof_lnki_time.Null_as_int);}

@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.files.origs; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
import gplx.dbs.*;
public class Xof_orig_wkr__orig_db implements Xof_orig_wkr {
private final boolean addable;
private final boolean addable;
public Xof_orig_wkr__orig_db(Xof_orig_tbl tbl, boolean addable) {this.tbl = tbl; this.addable = addable;}
public byte Tid() {return Xof_orig_wkr_.Tid_xowa_db;}
public Xof_orig_tbl Tbl() {return tbl;} private final Xof_orig_tbl tbl;
public Xof_orig_tbl Tbl() {return tbl;} private final Xof_orig_tbl tbl;
public void Find_by_list(Ordered_hash rv, List_adp itms) {tbl.Select_by_list(rv, itms);}
public Xof_orig_itm Find_as_itm(byte[] ttl, int list_idx, int list_len) {return tbl.Select_itm(ttl);}
public boolean Add_orig(byte repo, byte[] page, int ext_id, int w, int h, byte[] redirect) {

@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
public class Xog_cbk_mgr { // INSTANCE:app
private Xog_cbk_wkr[] wkrs = Xog_cbk_wkr_.Ary_empty; private int wkrs_len = 0;
public void Reg(Xog_cbk_wkr wkr) {
this.wkrs = (Xog_cbk_wkr[])Array_.Resize_add_one(wkrs, wkrs_len, wkr);
++wkrs_len;
}
public void Send_prog(String head, Object... args) {
String msg = gplx.core.errs.Err_msg.To_str(head, args);
for (int i = 0; i < wkrs_len; ++i) {
Xog_cbk_wkr wkr = wkrs[i];
wkr.Send_prog(msg);
}
}
}

@ -0,0 +1,24 @@
/*
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.guis.cbks; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
public interface Xog_cbk_wkr {
void Send_prog(String head);
}
class Xog_cbk_wkr_ {
public static final Xog_cbk_wkr[] Ary_empty = new Xog_cbk_wkr[0];
}

@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
import gplx.langs.jsons.*;
public class Bridge_cmd_mgr {
private final Json_parser parser;
private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs();
private final Json_parser parser;
private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs();
public Bridge_cmd_mgr(Json_parser parser) {this.parser = parser;}
public void Add(Bridge_cmd_itm cmd) {cmd_hash.Add_bry_obj(cmd.Key(), cmd);}
public String Exec(GfoMsg m) {
@ -36,5 +36,5 @@ public class Bridge_cmd_mgr {
try {return cmd.Exec(msg.Get(Key_data));}
catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "exec json failed", "json", jdoc_bry);}
}
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_data = Bry_.new_a7("data");
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_data = Bry_.new_a7("data");
}

@ -31,22 +31,28 @@ public class Xoh_lnke_data implements Xoh_data_itm {
public int Capt_bgn() {return capt_bgn;} private int capt_bgn;
public int Capt_end() {return capt_end;} private int capt_end;
public boolean Capt_exists() {return capt_exists;} private boolean capt_exists;
public int Title_bgn() {return title_bgn;} private int title_bgn;
public int Title_end() {return title_end;} private int title_end;
public boolean Title_exists() {return title_end > title_bgn;}
public void Clear() {
capt_exists = false;
lnke_tid = Byte_ascii.Max_7_bit;
src_bgn = src_end = href_bgn = href_end = capt_bgn = capt_end = auto_id = -1;
src_bgn = src_end = href_bgn = href_end = capt_bgn = capt_end = auto_id = title_bgn = title_end = -1;
}
public void Init_by_decode(byte lnke_tid, int auto_id, int href_bgn, int href_end, int capt_bgn, int capt_end, boolean capt_exists) {
public void Init_by_decode(byte lnke_tid, int auto_id, int href_bgn, int href_end, int capt_bgn, int capt_end, boolean capt_exists, int title_bgn, int title_end) {
this.lnke_tid = lnke_tid; this.auto_id = auto_id; this.href_bgn = href_bgn; this.href_end = href_end;
this.capt_bgn = capt_bgn; this.capt_end = capt_end; this.capt_exists = capt_exists;
this.title_bgn = title_bgn; this.title_end = title_end;
}
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag anch_head, Gfh_tag unused) {
this.src_bgn = anch_head.Src_bgn();
Gfh_atr href_atr = anch_head.Atrs__get_by_or_fail(Gfh_atr_.Bry__href); // get href; "EX: href='http://a.org'"
Gfh_atr href_atr = anch_head.Atrs__get_by_or_fail(Gfh_atr_.Bry__href); // get href; "EX: href='http://a.org'"
this.href_bgn = href_atr.Val_bgn(); this.href_end = href_atr.Val_end();
this.lnke_tid = anch_head.Atrs__cls_find_or_fail(Xoh_lnke_dict_.Hash); // get type by class; EX: "class='external free'"
this.capt_bgn = anch_head.Src_end();
Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // find '</a>'
Gfh_atr title_atr = anch_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__title);
this.title_bgn = title_atr.Val_bgn(); this.title_end = title_atr.Val_end();
Gfh_tag anch_tail = tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__a); // find '</a>'
this.capt_end = anch_tail.Src_bgn();
switch (lnke_tid) {
case Xoh_lnke_dict_.Type__free:

@ -24,35 +24,40 @@ public class Xoh_lnke_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
public byte[] Hook() {return hook;} private byte[] hook;
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
Xoh_lnke_data data = (Xoh_lnke_data)data_obj;
boolean title_exists = flag_bldr.Set_as_bool(Flag__title_exists , data.Title_exists());
boolean auto_exists = flag_bldr.Set_as_bool(Flag__auto_exists , data.Auto_exists());
boolean capt_exists = flag_bldr.Set_as_bool(Flag__capt_exists , data.Capt_exists());
byte lnke_tid = flag_bldr.Set_as_byte(Flag__lnke_tid , data.Lnke_tid());
bfr.Add(hook);
bfr.Add_hzip_int(1, flag_bldr.Encode()); // add flag
bfr.Add_hzip_mid(src, data.Href_bgn(), data.Href_end()); // add href
if (auto_exists) bfr.Add_hzip_int(1, data.Auto_id()); // add autonumber
if (capt_exists) bfr.Add_hzip_mid(src, data.Capt_bgn(), data.Capt_end()); // add caption
bfr.Add_hzip_int(1, flag_bldr.Encode()); // add flag
bfr.Add_hzip_mid(src, data.Href_bgn(), data.Href_end()); // add href
if (auto_exists) bfr.Add_hzip_int(1, data.Auto_id()); // add autonumber
if (capt_exists) bfr.Add_hzip_mid(src, data.Capt_bgn(), data.Capt_end()); // add caption
if (title_exists) bfr.Add_hzip_mid(src, data.Title_bgn(), data.Title_end()); // add title
hctx.Hzip__stat().Lnke_add(lnke_tid);
return this;
}
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
boolean title_exists = flag_bldr.Get_as_bool(Flag__title_exists);
boolean auto_exists = flag_bldr.Get_as_bool(Flag__auto_exists);
boolean capt_exists = flag_bldr.Get_as_bool(Flag__capt_exists);
byte lnke_tid = flag_bldr.Get_as_byte(Flag__lnke_tid);
int href_bgn = rdr.Pos(); int href_end = rdr.Find_fwd_lr();
int auto_id = -1, capt_bgn = -1, capt_end = -1;
int auto_id = -1, capt_bgn = -1, capt_end = -1, title_bgn = -1, title_end = -1;
if (auto_exists) auto_id = rdr.Read_hzip_int(1);
if (capt_exists) {capt_bgn = rdr.Pos(); capt_end = rdr.Find_fwd_lr();}
if (capt_exists) {capt_bgn = rdr.Pos(); capt_end = rdr.Find_fwd_lr();}
if (title_exists) {title_bgn = rdr.Pos(); title_end = rdr.Find_fwd_lr();}
Xoh_lnke_data data = (Xoh_lnke_data)data_itm;
data.Init_by_decode(lnke_tid, auto_id, href_bgn, href_end, capt_bgn, capt_end, capt_exists);
data.Init_by_decode(lnke_tid, auto_id, href_bgn, href_end, capt_bgn, capt_end, capt_exists, title_bgn, title_end);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_lnke_hzip rv = new Xoh_lnke_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (1, 1, 2);
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (1, 1, 1, 2);
private static final int // SERIALIZED
Flag__auto_exists = 0
, Flag__capt_exists = 1
, Flag__lnke_tid = 2 // "free", "autonumber", "text"
Flag__title_exists = 0
, Flag__auto_exists = 1
, Flag__capt_exists = 2
, Flag__lnke_tid = 3 // "free", "autonumber", "text"
;
}

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_lnke_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
@Test public void Free() {
fxt.Test__bicode("~#!http://a.org~", Xoh_lnke_html__hdump__tst.Html__free);
}
@ -41,6 +41,11 @@ public class Xoh_lnke_hzip_tst {
@Test public void Text() {
fxt.Test__bicode("~#'http://a.org~a~", Xoh_lnke_html__hdump__tst.Html__text);
}
@Test public void Wikivoyage__sleep() {
fxt.Test__bicode
( "~#7http://a.org~c~b~"
, "<a href='http://a.org' rel='nofollow' class='external text' title='b'>c</a>");
}
// @Test public void Xwiki__exists() {
// String hzip = "~#'https://en.wiktionary.org/wiki/A~A~";
// String html_https = "<a href='https://en.wiktionary.org/wiki/A' rel='nofollow' class='external text'>A</a>";

@ -20,25 +20,27 @@ import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fm
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
import gplx.xowa.htmls.core.hzips.*;
public class Xoh_lnke_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
private final Bfr_arg__bry anch_href = Bfr_arg__bry.New_empty(), anch_cls = Bfr_arg__bry.New_empty(), anch_content = Bfr_arg__bry.New_empty();
private final Bfr_arg__bry anch_href = Bfr_arg__bry.New_empty(), anch_cls = Bfr_arg__bry.New_empty(), anch_content = Bfr_arg__bry.New_empty();
private final Bfr_arg__hatr_bry anch_title = new Bfr_arg__hatr_bry(Gfh_atr_.Bry__title);
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
Bfr_arg_.Clear(anch_href, anch_cls,anch_content);
Xoh_lnke_data data = (Xoh_lnke_data)data_itm;
anch_href.Set_by_mid(src, data.Href_bgn(), data.Href_end());
anch_cls.Set_by_val(Xoh_lnke_dict_.To_html_class(data.Lnke_tid()));
if (data.Title_exists()) anch_title.Set_by_mid(src, data.Title_bgn(), data.Title_end());
if (data.Auto_exists()) anch_content.Set_by_arg(Xoh_lnke_wtr_arg__autonum.Instance.Set_by_auto_id(data.Auto_id()));
else if (data.Capt_exists()) anch_content.Set_by_mid(src, data.Capt_bgn(), data.Capt_end());
else anch_content.Set_by_mid(src, data.Href_bgn(), data.Href_end());
return true;
}
public void Bfr_arg__add(Bry_bfr bfr) {
fmtr.Bld_bfr_many(bfr, anch_href, anch_cls, anch_content);
fmtr.Bld_bfr_many(bfr, anch_href, anch_cls, anch_content, anch_title);
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_lnke_wtr rv = new Xoh_lnke_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
private static final Bry_fmtr fmtr = Bry_fmtr.new_
( "<a href=\"~{href}\" rel=\"nofollow\" class=\"external ~{cls}\">~{content}</a>"
, "href", "cls", "content");
private static final Bry_fmtr fmtr = Bry_fmtr.new_
( "<a href=\"~{href}\" rel=\"nofollow\" class=\"external ~{cls}\"~{title}>~{content}</a>"
, "href", "cls", "content", "title");
}
class Xoh_lnke_wtr_arg__autonum implements Bfr_arg {
private int auto_id;
@ -46,5 +48,5 @@ class Xoh_lnke_wtr_arg__autonum implements Bfr_arg {
public void Bfr_arg__add(Bry_bfr bfr) {
bfr.Add_byte(Byte_ascii.Brack_bgn).Add_int_variable(auto_id).Add_byte(Byte_ascii.Brack_end);
}
public static final Xoh_lnke_wtr_arg__autonum Instance = new Xoh_lnke_wtr_arg__autonum(); Xoh_lnke_wtr_arg__autonum() {}
public static final Xoh_lnke_wtr_arg__autonum Instance = new Xoh_lnke_wtr_arg__autonum(); Xoh_lnke_wtr_arg__autonum() {}
}

@ -23,7 +23,7 @@ public class Xoh_lnki_data {
private byte[] src;
private int href_ns_id; private byte[] href_ns_name; private int href_ns_name_len;
private byte[] capt_src; private int capt_bgn, capt_end;
private final Bry_rdr rdr = new Bry_rdr();
private final Bry_rdr rdr = new Bry_rdr();
public int Src_bgn() {return src_bgn;} private int src_bgn;
public int Src_end() {return src_end;} private int src_end;
public boolean Capt_has_ns() {return capt_has_ns;} private boolean capt_has_ns;
@ -42,8 +42,8 @@ public class Xoh_lnki_data {
public int Title_bgn() {return title_bgn;} private int title_bgn;
public int Title_end() {return title_end;} private int title_end;
public byte Cls_tid() {return cls_tid;} private byte cls_tid;
public Xoh_anch_href_data Href_itm() {return href_itm;} private final Xoh_anch_href_data href_itm = new Xoh_anch_href_data();
public Xoh_anch_capt_itm Capt_itm() {return capt_itm;} private final Xoh_anch_capt_itm capt_itm = new Xoh_anch_capt_itm();
public Xoh_anch_href_data Href_itm() {return href_itm;} private final Xoh_anch_href_data href_itm = new Xoh_anch_href_data();
public Xoh_anch_capt_itm Capt_itm() {return capt_itm;} private final Xoh_anch_capt_itm capt_itm = new Xoh_anch_capt_itm();
private void Init(byte[] src) {
this.src = href_src = capt_src = src;
capt_has_ns = title_missing_ns = false;

@ -21,7 +21,7 @@ import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.lnkis.anch
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.parsers.lnkis.*;
public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
private final Bry_bfr tmp_bfr = Bry_bfr.new_(32);
private final Bry_bfr tmp_bfr = Bry_bfr.new_(32);
public int Tid() {return Xoh_hzip_dict_.Tid__lnki;}
public String Key() {return Xoh_hzip_dict_.Key__lnki;}
public byte[] Hook() {return hook;} private byte[] hook;
@ -157,11 +157,12 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
bfr.Add(href_bry);
byte[] cls_bry = null;
switch (cls_tid) {
case Xoh_anch_cls_.Tid__ctg_main: cls_bry = Xoh_anch_cls_.Bry__ctg_main; break;
case Xoh_anch_cls_.Tid__ctg_tree: cls_bry = Xoh_anch_cls_.Bry__ctg_tree; break;
case Xoh_anch_cls_.Tid__ctg_xnav: cls_bry = Xoh_anch_cls_.Bry__ctg_xnav; break;
case Xoh_anch_cls_.Tid__media_info: cls_bry = Xoh_anch_cls_.Bry__media_info; break;
case Xoh_anch_cls_.Tid__media_play: cls_bry = Xoh_anch_cls_.Bry__media_play; break;
case Xoh_anch_cls_.Tid__ctg_main: cls_bry = Xoh_anch_cls_.Bry__ctg_main; break;
case Xoh_anch_cls_.Tid__ctg_tree: cls_bry = Xoh_anch_cls_.Bry__ctg_tree; break;
case Xoh_anch_cls_.Tid__ctg_xnav: cls_bry = Xoh_anch_cls_.Bry__ctg_xnav; break;
case Xoh_anch_cls_.Tid__media_info: cls_bry = Xoh_anch_cls_.Bry__media_info; break;
case Xoh_anch_cls_.Tid__media_play: cls_bry = Xoh_anch_cls_.Bry__media_play; break;
case Xoh_anch_cls_.Tid__voyage__email: cls_bry = Xoh_anch_cls_.Bry__voyage_email; break;
}
if (cls_bry != null) bfr.Add(Gfh_bldr_.Bry__cls__nth).Add(cls_bry);
if (!hctx.Mode_is_diff())
@ -178,7 +179,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
}
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_lnki_hzip rv = new Xoh_lnki_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (3, 1 , 1, 1, 2, 1 , 1, 2, 2, 2);
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_ (3, 1 , 1, 1, 2, 1 , 1, 2, 2, 2);
private static final int // SERIALIZED
Flag__cls_tid = 0
, Flag__title_missing_ns = 1

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*;
public class Xoh_lnki_hzip__site__tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Test public void Basic() { // EX: [[wikt:A]]
fxt.Test__bicode("~${$3en.wiktionary.org~A~wikt:A~" , "<a href='/site/en.wiktionary.org/wiki/A' title='wikt:A'>wikt:A</a>");
}
@ -76,4 +76,9 @@ public class Xoh_lnki_hzip__site__tst {
@Test public void Main_page() { // EX: [[wikt:]]
fxt.Test__bicode("~${<<en.wiktionary.org~~wikt:~" , "<a href='/site/en.wiktionary.org/wiki/' title='wikt:'>wikt:</a>");
}
@Test public void Wikivoyage__email() {
fxt.Test__bicode
( "$|)%6mailto:ab"
, "<a href='mailto:a' class='email'>b</a>");
}
}

@ -18,27 +18,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.lnkis.anchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
import gplx.core.btries.*;
public class Xoh_anch_cls_ {
public static final byte
Tid__none = 0
, Tid__unknown = 1
, Tid__media_play = 1
, Tid__media_info = 2
, Tid__ctg_main = 3
, Tid__ctg_tree = 4
, Tid__ctg_xnav = 5
public static final byte // SERIALIZED
Tid__none = 0
, Tid__unknown = 1
, Tid__media_play = 6 // NOTE: was 1; DATE:2016-04-21
, Tid__media_info = 2
, Tid__ctg_main = 3
, Tid__ctg_tree = 4
, Tid__ctg_xnav = 5
, Tid__voyage__email = 7
;
public static final byte[]
Bry__media_play = Bry_.new_a7("xowa_media_play")
, Bry__media_info = Bry_.new_a7("xowa_media_info")
, Bry__ctg_main = Bry_.new_a7("internal")
, Bry__ctg_tree = gplx.xowa.wikis.ctgs.Xoa_ctg_mgr.Html__cls__bry
, Bry__ctg_xnav = Bry_.new_a7("xowa_nav")
public static final byte[]
Bry__media_play = Bry_.new_a7("xowa_media_play")
, Bry__media_info = Bry_.new_a7("xowa_media_info")
, Bry__ctg_main = Bry_.new_a7("internal")
, Bry__ctg_tree = gplx.xowa.wikis.ctgs.Xoa_ctg_mgr.Html__cls__bry
, Bry__ctg_xnav = Bry_.new_a7("xowa_nav")
, Bry__voyage_email = Bry_.new_a7("email")
;
public static final Btrie_slim_mgr Trie = Btrie_slim_mgr.cs()
.Add_bry_byte(Bry__media_play , Tid__media_play)
.Add_bry_byte(Bry__media_info , Tid__media_info)
.Add_bry_byte(Bry__ctg_main , Tid__ctg_main)
.Add_bry_byte(Bry__ctg_tree , Tid__ctg_tree)
.Add_bry_byte(Bry__ctg_xnav , Tid__ctg_xnav)
public static final Btrie_slim_mgr Trie = Btrie_slim_mgr.cs()
.Add_bry_byte(Bry__media_play , Tid__media_play)
.Add_bry_byte(Bry__media_info , Tid__media_info)
.Add_bry_byte(Bry__ctg_main , Tid__ctg_main)
.Add_bry_byte(Bry__ctg_tree , Tid__ctg_tree)
.Add_bry_byte(Bry__ctg_xnav , Tid__ctg_xnav)
.Add_bry_byte(Bry__voyage_email , Tid__voyage__email)
;
}

@ -25,8 +25,8 @@ public class Xoh_thm_data implements Gfh_style_wkr {
public boolean Rng_valid() {return rng_valid;} private boolean rng_valid;
public byte Div_0_align() {return div_0_align;} private byte div_0_align;
public int Div_1_width() {return div_1_width;} private int div_1_width;
public Xoh_img_data Img_data() {return img_data;} private final Xoh_img_data img_data = new Xoh_img_data();
public Xoh_thm_caption_data Capt_data() {return capt_data;} private final Xoh_thm_caption_data capt_data = new Xoh_thm_caption_data();
public Xoh_img_data Img_data() {return img_data;} private final Xoh_img_data img_data = new Xoh_img_data();
public Xoh_thm_caption_data Capt_data() {return capt_data;} private final Xoh_thm_caption_data capt_data = new Xoh_thm_caption_data();
public void Clear() {
rng_valid = false;
capt_data.Clear();
@ -70,7 +70,7 @@ public class Xoh_thm_data implements Gfh_style_wkr {
this.div_1_width = -1;
return true;
}
public static final byte[]
public static final byte[]
Atr__class__thumb = Bry_.new_a7("thumb")
, Atr__class__thumbinner = Bry_.new_a7("thumbinner")
, Atr__id__xowa_media_div = Bry_.new_a7("xowa_media_div")

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
public class Xoh_thm_hzip_tst {
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
@Before public void setup() {fxt.Clear();}
@Test public void Image() {
fxt.Test__bicode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
@ -311,7 +311,7 @@ public class Xoh_thm_hzip_tst {
// fxt.Wiki().Ns_mgr().Init();
//
// fxt.Init_mode_is_b256_(Bool_.N);
// fxt.Exec_write_to_fsys(Io_url_.new_dir_("J:\\xowa\\research\\html\\"), "debug.html");
// fxt.Exec_write_to_fsys(Io_url_.new_dir_("C:\\xowa\\debug\\html\\"), "hzip.html");
// fxt.Init_mode_is_b256_(Bool_.N);
// }
}

@ -15,8 +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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
import gplx.xowa.wikis.pages.*;
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
public class Xopage_html_data {
public Xopage_html_data(byte[] display_ttl, byte[] body) {
this.display_ttl = display_ttl;

@ -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.wikis.tdbs.hives; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
import gplx.core.ios.*;
import gplx.core.ios.zips.*;
import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.bldrs.sqls.*;
import gplx.xowa.wikis.nss.*;

@ -41,7 +41,7 @@ class Dpl_itm {
public byte Quality_pages() {return quality_pages;} private byte quality_pages;
public byte Stable_pages() {return stable_pages;} private byte stable_pages;
private Xop_ctx sub_ctx; private Xop_tkn_mkr sub_tkn_mkr; private Xop_root_tkn sub_root;
public void Parse(Xowe_wiki wiki, Xop_ctx ctx, byte[] page_ttl, byte[] src, Xop_xnde_tkn xnde) { // parse kvs in node; EX:<dpl>category=abc\nredirects=y\n</dpl>
public void Parse(Xowe_wiki wiki, Xop_ctx ctx, byte[] page_ttl, byte[] src, Xop_xnde_tkn xnde) { // parse kvps in xnde; EX:<dpl>category=abc\nredirects=y\n</dpl>
sub_ctx = Xop_ctx.new_sub_(wiki);
sub_tkn_mkr = sub_ctx.Tkn_mkr();
sub_root = sub_tkn_mkr.Root(Bry_.Empty);
@ -54,20 +54,25 @@ class Dpl_itm {
boolean loop = true;
while (loop) { // iterate over content
boolean done = pos >= content_end;
byte b = done ? Dlm_row : src[pos]; // get cur byte
byte b = done ? Byte_ascii.Nl : src[pos]; // get cur byte
switch (b) {
case Byte_ascii.Space: case Byte_ascii.Tab:
if (ws_bgn_chk) ws_bgn_idx = pos; // definite ws at bgn; set ws_bgn_idx, and keep setting until text reached; handles mixed sequence of \s\n\t where last tkn should be ws_bgn_idx
else {if (ws_end_idx == -1) ws_end_idx = pos;}; // possible ws at end; may be overriden later; see AdjustWsForTxtTkn
break;
case Dlm_fld: { // dlm is fld; EX: "=" in "category="
case Byte_ascii.Eq: { // =; make key; EX: "=" in "category="
if (ws_bgn_idx != -1) fld_bgn = ws_bgn_idx + 1; // +1 to position after last known ws
int fld_end = ws_end_idx == -1 ? pos : ws_end_idx;
key_id = Dpl_itm_keys.Parse(src, fld_bgn, fld_end, Dpl_itm_keys.Key_null);
if (key_id == Dpl_itm_keys.Key_null) { // unknown key; warn and set pos to end of line; EX: "unknown=";
Parse_missing_key(usr_dlg, page_ttl, src, fld_bgn, fld_end);
fld_bgn = Bry_find_.Find_fwd(src, Byte_ascii.Nl, pos);
if (fld_bgn == Bry_find_.Not_found) loop = false;
if (fld_bgn == Bry_find_.Not_found)
loop = false;
else {
pos = fld_bgn; // set pos after \n else bounds error if multiple bad keys on same line; NOTE: ++pos below; EX: \nbad1=a bad2=b\n; PAGE:de.n:Brandenburg DATE:2016-04-21
++fld_bgn; // set fld_bgn after \n;
}
}
else { // known key; set pos to val_bgn
fld_bgn = pos + Int_.Const_dlm_len;
@ -75,7 +80,7 @@ class Dpl_itm {
ws_bgn_chk = true; ws_bgn_idx = ws_end_idx = -1;
break;
}
case Dlm_row: { // dlm is nl; EX: "\n" in "category=abc\n"
case Byte_ascii.Nl: { // dlm is nl; EX: "\n" in "category=abc\n"
if (fld_bgn != pos) { // ignores blank lines
if (ws_bgn_idx != -1) fld_bgn = ws_bgn_idx + 1; // +1 to position after last known ws
int fld_end = ws_end_idx == -1 ? pos : ws_end_idx;
@ -94,7 +99,6 @@ class Dpl_itm {
++pos;
}
}
private static final byte Dlm_fld = Byte_ascii.Eq, Dlm_row = Byte_ascii.Nl;
public void Parse_cmd(Xowe_wiki wiki, byte key_id, byte[] val) {
sub_root.Clear();
val = wiki.Parser_mgr().Main().Parse_text_to_wtxt(sub_root, sub_ctx, sub_tkn_mkr, val);
@ -150,7 +154,7 @@ class Dpl_itm {
else
usr_dlg.Warn_many("", "", err_msg);
}
private static final Hash_adp_bry Known_invalid_keys = Hash_adp_bry.ci_a7()
private static final Hash_adp_bry Known_invalid_keys = Hash_adp_bry.ci_a7()
.Add_str_obj("orcer" , Bool_obj_val.True) // ignore as per http://en.wikinews.org/wiki/Template_talk:United_States; (Note it doesn't make a difference, as categoryadd is the default order method.)
.Add_str_obj("addcategorydatefirst" , Bool_obj_val.True)
.Add_str_obj("mainspace" , Bool_obj_val.True)

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.dynamicPageList; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.core.strings.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.wikis.nss.*; import gplx.langs.htmls.*;
public class Dpl_xnde_tst {
private Dpl_xnde_fxt fxt = new Dpl_xnde_fxt();
private final Dpl_xnde_fxt fxt = new Dpl_xnde_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Ctg() {
fxt.Ctg_create("Ctg_0", "B", "A");
@ -28,110 +28,110 @@ public class Dpl_xnde_tst {
fxt.Ctg_create_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
fxt.Ctg_create_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));
fxt.Ul_pages(String_.Concat_lines_nl
( "<DynamicPageList>"
, "category=Ctg_0"
, "category=Ctg_1"
, "</DynamicPageList>"
( "<DynamicPageList>"
, "category=Ctg_0"
, "category=Ctg_1"
, "</DynamicPageList>"
), fxt.Ul(Itm_html_null, "A"));
}
@Test public void Ctg_multiple_none() { // PURPOSE: page must be in both categories
fxt.Ctg_create("Ctg_0", "A");
fxt.Ctg_create("Ctg_1", "B");
fxt.Ul_pages(String_.Concat_lines_nl
( "<DynamicPageList>"
, "category=Ctg_0"
, "category=Ctg_1"
, "</DynamicPageList>"
( "<DynamicPageList>"
, "category=Ctg_0"
, "category=Ctg_1"
, "</DynamicPageList>"
), "No pages meet these criteria.");
}
@Test public void Notcategory() {
fxt.Ctg_create_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
fxt.Ctg_create_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));
fxt.Ul_pages(String_.Concat_lines_nl
( "<DynamicPageList>"
, "category=Ctg_0"
, "notcategory=Ctg_1"
, "</DynamicPageList>"
), fxt.Ul(Itm_html_null, "B"));
( "<DynamicPageList>"
, "category=Ctg_0"
, "notcategory=Ctg_1"
, "</DynamicPageList>"
), fxt.Ul(Itm_html_null, "B"));
}
@Test public void Ctg_ascending() {
fxt.Ctg_create("Ctg_0", "B", "A");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "order=ascending"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
( "<DynamicPageList>"
, "category=Ctg_0"
, "order=ascending"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
}
@Test public void Ctg_ws() {
fxt.Ctg_create("Ctg_0", "B", "A");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, " category = Ctg_0 "
, " order = ascending "
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
( "<DynamicPageList>"
, " category = Ctg_0 "
, " order = ascending "
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
}
@Test public void Ctg_descending() {
fxt.Ctg_create("Ctg_0", "A", "B");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "order=descending"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "B", "A"));
( "<DynamicPageList>"
, "category=Ctg_0"
, "order=descending"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "B", "A"));
}
@Test public void Nofollow() {
fxt.Ctg_create("Ctg_0", "A", "B");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "nofollow=true"
, "</DynamicPageList>"), fxt.Ul(" rel=\"nofollow\"", "A", "B"));
( "<DynamicPageList>"
, "category=Ctg_0"
, "nofollow=true"
, "</DynamicPageList>"), fxt.Ul(" rel=\"nofollow\"", "A", "B"));
}
@Test public void Invalid_key() {
fxt.Ctg_create("Ctg_0", "A", "B");
fxt.Warns("dynamic_page_list:unknown_key: page=Test page key=invalid_key");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "invalid_key=invalid_val"
, "category=Ctg_0"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
( "<DynamicPageList>"
, "invalid_key=invalid_val"
, "category=Ctg_0"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
}
@Test public void No_results() {
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "</DynamicPageList>"), "No pages meet these criteria.");
( "<DynamicPageList>"
, "category=Ctg_0"
, "</DynamicPageList>"), "No pages meet these criteria.");
}
@Test public void Suppress_errors() {
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "suppresserrors=true"
, "</DynamicPageList>"), "");
( "<DynamicPageList>"
, "category=Ctg_0"
, "suppresserrors=true"
, "</DynamicPageList>"), "");
}
@Test public void Count() {
fxt.Ctg_create("Ctg_0", "A", "B", "C");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "count=2"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
( "<DynamicPageList>"
, "category=Ctg_0"
, "count=2"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
}
@Test public void Offset() {
fxt.Ctg_create("Ctg_0", "A", "B", "C");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "offset=2"
, "count=2"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "C"));
( "<DynamicPageList>"
, "category=Ctg_0"
, "offset=2"
, "count=2"
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "C"));
}
@Test public void Ns() {
fxt.Ctg_create("Ctg_0", "Talk:A B", "B");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "namespace=Talk"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<DynamicPageList>"
, "category=Ctg_0"
, "namespace=Talk"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<ul>"
, " <li><a href='/wiki/Talk:A_B' title='Talk:A B'>A B</a></li>"
, "</ul>"
@ -140,19 +140,19 @@ public class Dpl_xnde_tst {
@Test public void Show_ns() {
fxt.Ctg_create("Ctg_0", "Talk:A");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "shownamespace=true"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<DynamicPageList>"
, "category=Ctg_0"
, "shownamespace=true"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<ul>"
, " <li><a href='/wiki/Talk:A' title='Talk:A'>Talk:A</a></li>"
, "</ul>"
));
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "shownamespace=false"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<DynamicPageList>"
, "category=Ctg_0"
, "shownamespace=false"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<ul>"
, " <li><a href='/wiki/Talk:A' title='Talk:A'>A</a></li>"
, "</ul>"
@ -161,10 +161,10 @@ public class Dpl_xnde_tst {
@Test public void Comment() { // PURPOSE: comment should be ignored; en.n:Portal:Federally_Administered_Tribal_Areas; DATE:2014-01-18
fxt.Ctg_create("Ctg_0", "B", "A");
fxt.Ul_pages(String_.Concat_lines_nl
( "<DynamicPageList>"
, "category=Ctg_0"
, "<!--category=Ctg_0-->"
, "</DynamicPageList>"
( "<DynamicPageList>"
, "category=Ctg_0"
, "<!--category=Ctg_0-->"
, "</DynamicPageList>"
), fxt.Ul(Itm_html_null, "B", "A"));
}
@Test public void Error_skip_line() { // PURPOSE: error should skip rest of line; was failing with array out of bounds; en.n:Portal:Austria/Wikipedia; DATE:2014-01-18
@ -174,9 +174,9 @@ public class Dpl_xnde_tst {
@Test public void Atr_has_template() { // PURPOSE: attribute also has template; DATE:2014-01-31
fxt.Ctg_create("Test_page", "B", "A");
fxt.Ul_pages(String_.Concat_lines_nl
( "<DynamicPageList>"
, "category={{PAGENAME}}"
, "</DynamicPageList>"
( "<DynamicPageList>"
, "category={{PAGENAME}}"
, "</DynamicPageList>"
), fxt.Ul(Itm_html_null, "B", "A"));
}
@Test public void Err_page_ns_doesnt_exist() {// PURPOSE: check that <dpl> is not enabled if wiki does not have Page / Index ns; PAGE:fr.w:Wikipedia:Le_Bistro/novembre_2006 DATE:2014-11-28
@ -199,10 +199,10 @@ public class Dpl_xnde_tst {
@Test public void Encode_spaces() {// PURPOSE:encode spaces in href; PAGE:en.q:Wikiquote:Speedy_deletions DATE:2016-01-19
fxt.Ctg_create("Ctg_0", "A B");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "nofollow=true"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<DynamicPageList>"
, "category=Ctg_0"
, "nofollow=true"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<ul>"
, " <li><a href='/wiki/A_B' title='A B' rel='nofollow'>A B</a></li>" // "/wiki/A_B" not "/wiki/A B"
, "</ul>"
@ -211,16 +211,26 @@ public class Dpl_xnde_tst {
@Test public void Encode_quotes() {// PURPOSE:encode quotes; PAGE:en.b:Wikibooks:Alphabetical_classification/All_Books; DATE:2016-01-21
fxt.Ctg_create("Ctg_0", "A\"B");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "category=Ctg_0"
, "nofollow=true"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<DynamicPageList>"
, "category=Ctg_0"
, "nofollow=true"
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
( "<ul>"
, " <li><a href='/wiki/A%22B' title='A&quot;B' rel='nofollow'>A&quot;B</a></li>" // "/wiki/A_B" not "/wiki/A B"
, "</ul>"
));
}
private static final String Itm_html_null = null;
@Test public void Err__bad_key_causes_out_of_bound() { // PURPOSE: bad key causes out of bounds error; PAGE:de.n:Portal:Brandenburg DATE:2016-04-21
fxt.Warns("dynamic_page_list:unknown_key: page=Test page key=<DynamicPageList>category", "dynamic_page_list:unknown_key: page=Test page key=<DynamicPageList>category");
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
( "<DynamicPageList>"
, "<DynamicPageList>category=A</DynamicPageList>a=b c=d"
, "<DynamicPageList>category=B</DynamicPageList>"
)
, "No pages meet these criteria."
);
}
private static final String Itm_html_null = null;
}
class Dpl_page_mok {
public Dpl_page_mok(int id, String ttl) {this.id = id; this.ttl = ttl;}
@ -229,7 +239,7 @@ class Dpl_page_mok {
public static Dpl_page_mok new_(int id, String ttl) {return new Dpl_page_mok(id, ttl);}
}
class Dpl_xnde_fxt {
private final Xop_fxt fxt = new Xop_fxt();
private final Xop_fxt fxt = new Xop_fxt();
private int next_id;
public void Clear() {
next_id = 100;

@ -163,8 +163,8 @@ public class Listing_xnde implements Xox_xnde, Mwh_atr_itm_owner1 {
.Txt(Txt_colon_space)
;
wtr .Nde_full_atrs(Tag_a, xatr_email, true
, Atr_a_href , Bry_.Add(Txt_mailto, xatr_email) // NOTE: switched from "class,href" to "href,class" for hzip; PAGE:de.v:Bansin; DATE:2016-04-21
, Atr_a_class , Atr_a_class_email
, Atr_a_href , Bry_.Add(Txt_mailto, xatr_email)
);
}
wtr.Txt(Txt_dot_space);

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.listings; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
public class Listing_xnde_basic_tst {
private final Xop_fxt fxt = new Xop_fxt();
private final Xop_fxt fxt = new Xop_fxt();
private Listing_xtn_mgr listings_xtn_mgr;
@Before public void init() {
fxt.Reset_for_msgs();
@ -60,7 +60,7 @@ public class Listing_xnde_basic_tst {
@Test public void Email() {
fxt.Test_parse_page_all_str
( "<sleep name='name_0' email='email_0'/>"
, "<strong>name_0</strong>, email: <a class=\"email\" href=\"mailto:email_0\">email_0</a>. "
, "<strong>name_0</strong>, email: <a href=\"mailto:email_0\" class=\"email\">email_0</a>. "
);
}
@Test public void Hours() {

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.listings; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
public class Listing_xnde_template_tst {
private final Xop_fxt fxt = new Xop_fxt();
private final Xop_fxt fxt = new Xop_fxt();
private Listing_xtn_mgr listings_xtn_mgr;
@Before public void init() {
fxt.Reset_for_msgs();
@ -120,7 +120,7 @@ public class Listing_xnde_template_tst {
Init_xtn_mgr();
fxt.Test_parse_page_all_str
( "<sleep name='name_0' email='a@b.org'></sleep>"
, "<strong>name_0</strong>, <abbr title=\"email\">e</abbr>: <a class=\"email\" href=\"mailto:a@b.org\">a@b.org</a>. "
, "<strong>name_0</strong>, <abbr title=\"email\">e</abbr>: <a href=\"mailto:a@b.org\" class=\"email\">a@b.org</a>. "
);
}
@Test public void Checkin__template() {

@ -59,5 +59,5 @@ public class Pfunc_pagesincategory extends Pf_func_base {
byte[] rslt = fmt_num ? lang.Num_mgr().Format_num(num_bry) : lang.Num_mgr().Raw(num_bry);
bfr.Add(rslt);
}
public static final Pfunc_pagesincategory Instance = new Pfunc_pagesincategory(); Pfunc_pagesincategory() {}
public static final Pfunc_pagesincategory Instance = new Pfunc_pagesincategory(); Pfunc_pagesincategory() {}
}

@ -18,9 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pfuncs.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import org.junit.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
public class Pfunc_pagesincategory_tst {
private final Pfunc_pagesincategory_tstr tstr = new Pfunc_pagesincategory_tstr();
private final Pfunc_pagesincategory_tstr tstr = new Pfunc_pagesincategory_tstr();
@Before public void setup() {tstr.Init(); tstr.Init_category_counts("A", 1000, 2000, 3000);}
@Test public void Type__none() {tstr.Test_parse("{{PAGESINCATEGORY:A}}" , "6,000");}
@Test public void Type__empty() {tstr.Test_parse("{{PAGESINCATEGORY:A|}}" , "6,000");} // FIX:throws null error; PAGE: DATE:2016-04-21
@Test public void Type__none__fmt() {tstr.Test_parse("{{PAGESINCATEGORY:A|R}}" , "6000");}
@Test public void Type__page__1st() {tstr.Test_parse("{{PAGESINCATEGORY:A|pages}}" , "1,000");}
@Test public void Type__subc__1st() {tstr.Test_parse("{{PAGESINCATEGORY:A|subcats}}" , "2,000");}
@ -33,10 +34,10 @@ public class Pfunc_pagesincategory_tst {
@Test public void Wrong_args() {tstr.Test_parse("{{PAGESINCATEGORY:A|invalid|x}}" , "6,000");} // defaults to all,fmt
}
class Pfunc_pagesincategory_tstr {
private final Xop_fxt parser_tstr;
private final Xoae_app app; private final Xowe_wiki wiki;
private final Xowd_db_mgr core_data_mgr;
private final Xowd_page_tbl page_tbl; private final Xowd_cat_core_tbl cat_core_tbl;
private final Xop_fxt parser_tstr;
private final Xoae_app app; private final Xowe_wiki wiki;
private final Xowd_db_mgr core_data_mgr;
private final Xowd_page_tbl page_tbl; private final Xowd_cat_core_tbl cat_core_tbl;
public Pfunc_pagesincategory_tstr() {
Xoa_test_.Inet__init();
this.app = Xoa_app_fxt.Make__app__edit();

@ -204,16 +204,16 @@ class Scrib_lua_rsp_bldr {
}
private void Bld_obj(Bry_bfr bfr, Object v) {
Class<?> v_type = v.getClass();
if (Object_.Eq(v_type, Int_.Cls_ref_type)) Bld_int(bfr, Int_.cast(v));
else if (Object_.Eq(v_type, String_.Cls_ref_type)) Bld_str(bfr, String_.cast(v));
else if (Object_.Eq(v_type, Bool_.Cls_ref_type)) Bld_bool(bfr, Bool_.cast(v));
else if (Object_.Eq(v_type, Double_.Cls_ref_type)) Bld_double(bfr, Double_.cast(v));
if (Object_.Eq(v_type, Int_.Cls_ref_type)) Bld_int(bfr, Int_.cast(v));
else if (Object_.Eq(v_type, String_.Cls_ref_type)) Bld_str(bfr, String_.cast(v));
else if (Object_.Eq(v_type, Bool_.Cls_ref_type)) Bld_bool(bfr, Bool_.cast(v));
else if (Object_.Eq(v_type, Double_.Cls_ref_type)) Bld_double(bfr, Double_.cast(v));
else if (Object_.Eq(v_type, Keyval[].class)) Bld_kv_ary(bfr, (Keyval[])v);
else if (Object_.Eq(v_type, Scrib_lua_proc.class)) Bld_fnc(bfr, (Scrib_lua_proc)v);
else throw Err_.new_unhandled(Type_adp_.NameOf_obj(v));
}
private void Bld_bool(Bry_bfr bfr, boolean v) {bfr.Add_str_a7("b:").Add_int_fixed(v ? 1 : 0, 1).Add_byte(Byte_ascii.Semic);}
private void Bld_int(Bry_bfr bfr, int v) {bfr.Add_str_a7("i:").Add_int_variable(v).Add_byte(Byte_ascii.Semic);}
private void Bld_int(Bry_bfr bfr, int v) {bfr.Add_str_a7("i:").Add_int_variable(v).Add_byte(Byte_ascii.Semic);}
private void Bld_double(Bry_bfr bfr, double v) {bfr.Add_str_a7("d:").Add_double(v).Add_byte(Byte_ascii.Semic);}
private void Bld_str(Bry_bfr bfr, String v) {bfr.Add_str_a7("s:").Add_int_variable(Bry_.new_u8(v).length).Add_str_a7(":\"").Add_str_a7(v).Add_str_a7("\";");} // NOTE: must use Bry_.new_u8(v).length to calculate full bry len
private void Bld_fnc(Bry_bfr bfr, Scrib_lua_proc v) {bfr.Add_str_a7("O:42:\"Scribunto_LuaStandaloneInterpreterFunction\":1:{s:2:\"id\";i:").Add_int_variable(v.Id()).Add_byte(Byte_ascii.Semic).Add_byte(Byte_ascii.Curly_end);}

@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.scribunto.engines.mocks; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
import gplx.xowa.parsers.tmpls.*;
public class Mock_scrib_fxt {
private final Mock_engine engine = new Mock_engine();
private final Mock_server server = new Mock_server();
private Xop_fxt parser_fxt;
private final Mock_engine engine = new Mock_engine();
private final Mock_server server = new Mock_server();
public Scrib_core Core() {return core;} private Scrib_core core;
public Xop_fxt Parser_fxt() {return parser_fxt;} private Xop_fxt parser_fxt;
public void Clear() {Clear("en.wikipedia.org", "en");}
public void Clear(String domain, String lang) {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
@ -40,9 +40,10 @@ public class Mock_scrib_fxt {
engine.RegisterLibraryForTest(proc);
}
public void Init__page(String ttl, String txt) {parser_fxt.Init_page_create(ttl, txt);}
public void Test__proc__ints (Scrib_lib lib, String proc_name, Object[] args, int expd) {Test__proc__kvps(lib, proc_name, Bool_.Y, Int_.To_str(expd), Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__objs__flat(Scrib_lib lib, String proc_name, Object[] args, String expd) {Test__proc__kvps(lib, proc_name, Bool_.Y, expd, Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__objs__nest(Scrib_lib lib, String proc_name, Object[] args, String expd) {Test__proc__kvps(lib, proc_name, Bool_.N, expd, Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__ints (Scrib_lib lib, String proc_name, Object[] args, int expd) {Test__proc__kvps(lib, proc_name, Bool_.Y, Int_.To_str(expd), Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__objs__flat(Scrib_lib lib, String proc_name, Object[] args, String expd) {Test__proc__kvps(lib, proc_name, Bool_.Y, expd, Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__objs__nest(Scrib_lib lib, String proc_name, Object[] args, Keyval[] expd) {Test__proc__kvps(lib, proc_name, Bool_.N, Keyval_.Ary__to_str__nest(new Keyval[] {Keyval_.int_(Scrib_core.Base_1, expd)}), Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__objs__nest(Scrib_lib lib, String proc_name, Object[] args, String expd) {Test__proc__kvps(lib, proc_name, Bool_.N, expd, Scrib_kv_utl_.base1_many_(args));}
public void Test__proc__kvps__flat(Scrib_lib lib, String proc_name, Keyval[] args, String expd) {Test__proc__kvps(lib, proc_name, Bool_.Y, expd, args);}
public void Test__proc__kvps__nest(Scrib_lib lib, String proc_name, Keyval[] args, String expd) {Test__proc__kvps(lib, proc_name, Bool_.N, expd, args);}
private static void Test__proc__kvps(Scrib_lib lib, String proc_name, boolean flat, String expd, Keyval[] args) {

@ -71,7 +71,7 @@ public class Scrib_lib_language implements Scrib_lib {
, Invk_formatNum = "formatNum", Invk_formatDate = "formatDate", Invk_formatDuration = "formatDuration", Invk_getDurationIntervals = "getDurationIntervals", Invk_parseFormattedNumber = "parseFormattedNumber"
, Invk_convertPlural = "convertPlural", Invk_convertGrammar = "convertGrammar", Invk_gender = "gender", Invk_isRTL = "isRTL"
;
private static final String[] Proc_names = String_.Ary
private static final String[] Proc_names = String_.Ary
( Invk_getContLangCode, Invk_isSupportedLanguage, Invk_isKnownLanguageTag
, Invk_isValidCode, Invk_isValidBuiltInCode, Invk_fetchLanguageName, Invk_fetchLanguageNames, Invk_getFallbacksFor
, Invk_lcfirst, Invk_ucfirst, Invk_lc, Invk_uc, Invk_caseFold

@ -58,7 +58,7 @@ public class Scrib_lib_title implements Scrib_lib {
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getExpensiveData, Invk_getUrl, Invk_getContent, Invk_getFileInfo, Invk_getCurrentTitle, Invk_protectionLevels, Invk_cascadingProtection);
public boolean NewTitle(Scrib_proc_args args, Scrib_proc_rslt rslt) {
if (args.Len() == 0) return rslt.Init_obj(null); // invalid title, return null; EX:{{#invoke:Message box|fmbox}} DATE:2015-03-04
byte[] ttl_bry = args.Pull_bry(0);
byte[] ttl_bry = args.Xstr_bry_or_null(0); // NOTE: Pull_bry fails if caller passes int; PAGE:de.w:Wikipedia:Lua/Modul/Pinging/Test/recipients; DATE:2016-04-21
Object ns_obj = args.Cast_obj_or_null(1);
Xowe_wiki wiki = core.Wiki();
byte[] ns_bry = null;

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

Loading…
Cancel
Save