1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-29 23:10:52 +00:00

'v3.4.4.1'

This commit is contained in:
gnosygnu 2016-04-24 22:05:38 -04:00
parent ad140a93fe
commit 5ce4ea2a08
103 changed files with 1767 additions and 340 deletions

View File

@ -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<EFBFBD>ne Delacroix - La libert<EFBFBD> guidant le peuple.jpg

View File

@ -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()));
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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();}
}

View File

@ -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) {}
}
}
}

View File

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

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.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);

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.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.*;

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.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) {}
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() {}
}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.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() {

View File

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

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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 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;
}

View File

@ -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) {

View File

@ -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();
}

View File

@ -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() {}
}

View File

@ -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();}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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() {}
}
}

View File

@ -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);
}

View File

@ -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++)

View File

@ -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;
}
}

View File

@ -20,6 +20,7 @@ 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_ {

View File

@ -18,6 +18,7 @@ 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;
@ -25,12 +26,55 @@ public class Json_nde extends Json_itm_base implements Json_grp {
@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;}
}

View File

@ -38,9 +38,15 @@ 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();
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);

View File

@ -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);}

View File

@ -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);

View File

@ -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 = "";

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -16,9 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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());

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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());

View File

@ -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();
}
}

View File

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

View File

@ -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);}
}

View File

@ -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();

View File

@ -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

View File

@ -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() {}
}

View File

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

View File

@ -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;}
}

View File

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

View File

@ -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
// }

View File

@ -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
}
}

View File

@ -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;}
}

View File

@ -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);
}

View File

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

View File

@ -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);
}

View File

@ -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);}
}

View File

@ -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];
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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();
}

View File

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

View File

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

View File

@ -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;

View File

@ -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 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";
}

View File

@ -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() {}
}

View File

@ -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();

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.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.*;

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.setups.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.setups.*;
import gplx.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;

View File

@ -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());

View File

@ -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);

View File

@ -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);
}
}
}

View File

@ -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];
}

View File

@ -31,14 +31,18 @@ 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();
@ -46,6 +50,8 @@ public class Xoh_lnke_data implements Xoh_data_itm {
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_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) {

View File

@ -24,6 +24,7 @@ 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());
@ -32,27 +33,31 @@ public class Xoh_lnke_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
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 (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"
;
}

View File

@ -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>";

View File

@ -21,24 +21,26 @@ 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__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");
( "<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;

View File

@ -162,6 +162,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
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())

View File

@ -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>");
}
}

View File

@ -18,14 +18,15 @@ 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
public static final byte // SERIALIZED
Tid__none = 0
, Tid__unknown = 1
, Tid__media_play = 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")
@ -33,6 +34,7 @@ public class Xoh_anch_cls_ {
, 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)
@ -40,5 +42,6 @@ public class Xoh_anch_cls_ {
.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)
;
}

View File

@ -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);
// }
}

View File

@ -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;

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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.*;

View File

@ -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);

View File

@ -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");
@ -220,6 +220,16 @@ public class Dpl_xnde_tst {
, "</ul>"
));
}
@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 {

View File

@ -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);

View File

@ -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() {

View File

@ -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() {

View File

@ -21,6 +21,7 @@ public class Pfunc_pagesincategory_tst {
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");}

View File

@ -20,8 +20,8 @@ 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;
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();
@ -42,6 +42,7 @@ public class Mock_scrib_fxt {
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, 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);}

View File

@ -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;

View File

@ -16,99 +16,100 @@ 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.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import org.junit.*;
import gplx.dbs.*; import gplx.xowa.files.commons.*; import gplx.xowa.wikis.data.*;
import gplx.fsdb.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.ttls.*;
import org.junit.*; import gplx.xowa.xtns.scribunto.engines.mocks.*;
public class Scrib_lib_title_tst {
private final Mock_scrib_fxt fxt = new Mock_scrib_fxt(); private Scrib_lib lib;
@Before public void init() {
Db_conn_bldr.Instance.Reg_default_mem();
fxt.Clear_for_lib();
gplx.dbs.Db_conn_bldr.Instance.Reg_default_mem();
fxt.Clear();
fxt.Core().Wiki().File__fsdb_mode().Tid_v2_bld_y_();
lib = fxt.Core().Lib_title().Init();
} private Scrib_invoke_func_fxt fxt = new Scrib_invoke_func_fxt(); private Scrib_lib lib;
}
@Test public void NewTitle() {
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("Page_0") , ttl_fast(0 , "", "Page 0", "", "", "Page_0"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("a[b") , Scrib_invoke_func_fxt.Null_rslt_ary); // invalid
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("Page_0") , ttl_fast(0 , "", "Page 0", "", "", "Page_0"));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A"));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("a[b") , Scrib_invoke_func_fxt.Null_rslt_ary); // invalid
}
@Test public void NewTitle_int() {
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary(1234) , ttl_fast(0 , "", "1234", "", "", "1234"));
}
@Test public void NewTitle__foreign() {// PURPOSE: always return English name b/c some modules expect English "Template"; PAGE:sh.w:Koprno DATE:2015-11-08
fxt.Core().Wiki().Ns_mgr().Ns_template().Name_bry_(Bry_.new_a7("Template_in_nonenglish_name"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A")); // "Template" not "Template_in_nonenglish_name"
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A")); // "Template" not "Template_in_nonenglish_name"
}
@Test public void GetUrl() {
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl") , "//en.wikipedia.org/wiki/Main_Page");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "action=edit") , "//en.wikipedia.org/wiki/Main_Page?action=edit");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "localUrl") , "/wiki/Main_Page");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl") , "https://en.wikipedia.org/wiki/Main_Page");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl") , "//en.wikipedia.org/wiki/Main_Page");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "action=edit") , "//en.wikipedia.org/wiki/Main_Page?action=edit");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "localUrl") , "/wiki/Main_Page");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl") , "https://en.wikipedia.org/wiki/Main_Page");
// fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "", "http") , "http://en.wikipedia.org/wiki/Main_Page"); // TODO
}
@Test public void GetUrl__args_many() { // PUPROSE: GetUrl sometimes passes in kvs for qry_args; fr.w:Wikip<EFBFBD>dia:Image_du_jour/Date; DATE:2013-12-24
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl", Keyval_.Ary(Keyval_.new_("action", "edit"), Keyval_.new_("preload", "b"))), "https://en.wikipedia.org/wiki/Main_Page?action=edit&preload=b");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl", Keyval_.Ary(Keyval_.new_("action", "edit"), Keyval_.new_("preload", "b"))), "https://en.wikipedia.org/wiki/Main_Page?action=edit&preload=b");
}
@Test public void MakeTitle() {
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Module", "A") , ttl_fast(828, "Module", "A"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary(828, "A") , ttl_fast(828, "Module", "A"));
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "A", "b") , ttl_fast(10, "Template", "A", "b"));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Module", "A") , ttl_fast(828, "Module", "A"));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary(828, "A") , ttl_fast(828, "Module", "A"));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "A", "b") , ttl_fast(10, "Template", "A", "b"));
fxt.Parser_fxt().Wiki().Xwiki_mgr().Add_by_atrs("fr", "fr.wikipedia.org");
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "A", "b", "fr") , ttl_fast(0, "", "Template:A", "b", "fr"));
fxt.Parser_fxt().Init_log_(Xop_ttl_log.Invalid_char);
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "a[b"), Scrib_invoke_func_fxt.Null_rslt_ary); // PURPOSE: handle bad MakeTitle cmds; PAGE:en.w:Disney; DATE:2013-10-15
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "A", "b", "fr") , ttl_fast(0, "", "Template:A", "b", "fr"));
fxt.Parser_fxt().Init_log_(gplx.xowa.wikis.ttls.Xop_ttl_log.Invalid_char);
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Template", "a[b"), Scrib_invoke_func_fxt.Null_rslt_ary); // PURPOSE: handle bad MakeTitle cmds; PAGE:en.w:Disney; DATE:2013-10-15
}
@Test public void GetExpensiveData_absent() {
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getExpensiveData, Object_.Ary("A") , ttl_slow(Bool_.N, 0, Bool_.N));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getExpensiveData, Object_.Ary("A") , ttl_slow(Bool_.N, 0, Bool_.N));
}
@Test public void GetExpensiveData_exists() {
fxt.Parser_fxt().Init_page_create("A");
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getExpensiveData, Object_.Ary("A") , ttl_slow(Bool_.Y, 0, Bool_.N));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getExpensiveData, Object_.Ary("A") , ttl_slow(Bool_.Y, 0, Bool_.N));
}
@Test public void GetFileInfo() {
Wiki_orig_tbl__create(fxt.Core().Wiki());
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("A") , file_info_absent());
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("Template:A") , file_info_absent());
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_absent());
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("A") , file_info_absent());
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("Template:A") , file_info_absent());
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_absent());
fxt.Parser_fxt().Init_page_create("File:A.png");
Wiki_orig_tbl__insert(fxt.Core().Wiki(), "A.png", 220, 200);
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_exists("A.png", 220, 200));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_exists("A.png", 220, 200));
}
@Test public void GetFileInfo_commons() { // PURPOSE: check that Scribunto GetFileInfo calls filepath.FileExists; DATE:2014-01-07
Xowe_wiki commons_wiki = fxt.Parser_fxt().Wiki().Appe().Wiki_mgr().Get_by_or_make(Xow_domain_itm_.Bry__commons).Init_assert();
Xowe_wiki commons_wiki = fxt.Parser_fxt().Wiki().Appe().Wiki_mgr().Get_by_or_make(gplx.xowa.wikis.domains.Xow_domain_itm_.Bry__commons).Init_assert();
Wiki_orig_tbl__create(fxt.Core().Wiki());
Wiki_orig_tbl__insert(fxt.Core().Wiki(), "A.png", 220, 200);
fxt.Parser_fxt().Init_page_create(commons_wiki, "File:A.png", "text_is_blank");
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_exists("A.png", 220, 200));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("File:A.png") , file_info_exists("A.png", 220, 200));
}
@Test public void GetFileInfo_media() { // PURPOSE: [[Media:]] ns should find entries in [[File:]]; DATE:2014-01-07
Wiki_orig_tbl__create(fxt.Core().Wiki());
Wiki_orig_tbl__insert(fxt.Core().Wiki(), "A.png", 220, 200);
fxt.Parser_fxt().Init_page_create("File:A.png");
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("Media:A.png") , file_info_exists("A.png", 220, 200));
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_getFileInfo, Object_.Ary("Media:A.png") , file_info_exists("A.png", 220, 200));
}
@Test public void GetContent() {
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , Scrib_invoke_func_fxt.Null_rslt);
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , Scrib_invoke_func_fxt.Null_rslt);
fxt.Parser_fxt().Init_page_create("A", "test");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , "test");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , "test");
}
@Test public void GetContent_redirect() {// PURPOSE: GetContent should return source text for redirect, not target; PAGE:de.w:Wikipedia:Autorenportal DATE:2014-07-11
fxt.Parser_fxt().Init_page_create("A", "#REDIRECT [[B]]");
fxt.Parser_fxt().Init_page_create("B", "C");
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , "#REDIRECT [[B]]"); // should not be "C"
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_getContent, Object_.Ary("A") , "#REDIRECT [[B]]"); // should not be "C"
}
@Test public void ProtectionLevels() {
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_protectionLevels, Object_.Ary("A") , "");
fxt.Test__proc__objs__flat(lib, Scrib_lib_title.Invk_protectionLevels, Object_.Ary("A") , "");
}
@Test public void CascadingProtection() {
fxt.Test_scrib_proc_obj(lib, Scrib_lib_title.Invk_cascadingProtection, Object_.Ary("A") , Scrib_lib_title.CascadingProtection_rv);
fxt.Test__proc__objs__nest(lib, Scrib_lib_title.Invk_cascadingProtection, Object_.Ary("A") , Scrib_lib_title.CascadingProtection_rv);
}
private static void Wiki_orig_tbl__create(Xowe_wiki 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_bldr.Instance.Get_or_make(wiki, Bool_.Y);
gplx.xowa.wikis.data.Xowd_db_file text_db = wiki.Data__core_mgr().Dbs__make_by_tid(gplx.xowa.wikis.data.Xowd_db_file_.Tid_text); text_db.Tbl__text().Create_tbl();
gplx.fsdb.Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
wiki.File_mgr().Init_file_mgr_by_load(wiki);
}
private static void Wiki_orig_tbl__insert(Xowe_wiki wiki, String ttl_str, int w, int h) {
byte[] ttl_bry = Bry_.new_u8(ttl_str);
wiki.File__orig_mgr().Insert(Xof_repo_itm_.Repo_remote, ttl_bry, Xof_ext_.new_by_ttl_(ttl_bry).Id(), w, h, Bry_.Empty);
wiki.File__orig_mgr().Insert(gplx.xowa.files.repos.Xof_repo_itm_.Repo_remote, ttl_bry, gplx.xowa.files.Xof_ext_.new_by_ttl_(ttl_bry).Id(), w, h, Bry_.Empty);
}
private static String ttl_fast(int ns_id, String ns_str, String ttl) {return ttl_fast(ns_id, ns_str, ttl, "", "", ttl);}
private static String ttl_fast(int ns_id, String ns_str, String ttl, String anchor) {return ttl_fast(ns_id, ns_str, ttl, anchor, "", ttl);}

View File

@ -233,6 +233,10 @@ class Scrib_lib_ustring_gsub_mgr {
tmp_repl_tid = Repl_tid_luacbk;
repl_func = (Scrib_lua_proc)repl_obj;
}
else if (Object_.Eq(repl_type, Double_.Cls_ref_type)) { // NOTE:@replace sometimes double; PAGE:de.v:Wikivoyage:Wikidata/Test_Modul:Wikidata2; DATE:2016-04-21
tmp_repl_tid = Repl_tid_string;
tmp_repl_bry = Bry_.new_u8(Double_.To_str(Double_.cast(repl_obj)));
}
else throw Err_.new_unhandled(Type_adp_.NameOf_type(repl_type));
}
private String Exec_repl(byte repl_tid, byte[] repl_bry, String text, String regx, int limit) {

View File

@ -37,6 +37,9 @@ public class Scrib_lib_ustring__gsub__tst {
@Test public void Replace__int() { // PURPOSE: do not fail if integer is passed in for @replace; PAGE:en.d:λύω DATE:2014-09-02
Exec_gsub("abcd", 1 , -1, 1 , "abcd;0");
}
@Test public void Replace__double() { // PURPOSE: do not fail if double is passed in for @replace; PAGE:de.v:Wikivoyage:Wikidata/Test_Modul:Wikidata2 DATE:2016-04-21
Exec_gsub("abcd", 1 , -1, 1.23d , "abcd;0");
}
@Test public void Replace__table() {
Exec_gsub("abcd", "[ac]" , -1, Scrib_kv_utl_.flat_many_("a", "A", "c", "C") , "AbCd;2");
Exec_gsub("abc" , "[ab]" , -1, Scrib_kv_utl_.flat_many_("a", "A") , "Abc;2"); // PURPOSE: match not in regex should still print itself; in this case [c] is not in tbl regex; DATE:2014-03-31