1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

v2.11.4.1

This commit is contained in:
gnosygnu
2015-11-22 21:39:33 -05:00
parent 8a5d58a973
commit 097e6c7f80
581 changed files with 2897 additions and 2097 deletions

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import gplx.lists.*;
import gplx.core.lists.*;
public class Bry_comparer implements ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
byte[] lhs = (byte[])lhsObj, rhs = (byte[])rhsObj;

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.brys; import gplx.*; import gplx.core.*;
import gplx.core.errs.*;
public class Bry_rdr {
private final gplx.core.primitives.Int_obj_ref pos_ref = gplx.core.primitives.Int_obj_ref.neg1_();
private String ctx; private String wkr; private int err_bgn;
@@ -144,10 +145,16 @@ public class Bry_rdr {
pos = find_end;
return pos;
}
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie) {return Chk(trie, pos, src_end);}
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie) {return Chk(trie, pos, src_end);}
public byte Chk_or(gplx.core.btries.Btrie_slim_mgr trie, byte or) {return Chk_or(trie, pos, src_end, or);}
public byte Chk(gplx.core.btries.Btrie_slim_mgr trie, int itm_bgn, int itm_end) {
byte rv = Chk_or(trie, itm_bgn, itm_end, Byte_.Max_value_127);
if (rv == Byte_.Max_value_127) {Fail("failed trie check", "mid", String_.new_u8(Bry_.Mid_by_len_safe(src, pos, 16))); return Byte_.Max_value_127;}
return rv;
}
public byte Chk_or(gplx.core.btries.Btrie_slim_mgr trie, int itm_bgn, int itm_end, byte or) {
Object rv_obj = trie.Match_bgn(src, itm_bgn, itm_end);
if (rv_obj == null) {Fail("failed trie check", "mid", String_.new_u8(Bry_.Mid_by_len_safe(src, pos, 16))); return Byte_.Max_value_127;}
if (rv_obj == null) return or;
pos = trie.Match_pos();
return ((gplx.core.primitives.Byte_obj_val)rv_obj).Val();
}
@@ -162,9 +169,9 @@ public class Bry_rdr {
public Err Err_make(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {return Err_.new_("Bry_rdr", Msg_make(msg, arg_key, arg_val, excerpt_bgn, excerpt_end));}
private String Msg_make(String msg, String arg_key, Object arg_val, int excerpt_bgn, int excerpt_end) {
if (String_.EqEmpty(arg_key))
return String_.Replace(Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)), "\n", "\\n");
return Err_msg.To_str(msg, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
else
return String_.Replace(Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Quote(String_.new_u8(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)))), "\n", "\\n");
return Err_msg.To_str(msg, arg_key, arg_val, "ctx", ctx, "wkr", wkr, "excerpt", Bry_.Escape_ws(Bry_.Mid_safe(src, excerpt_bgn, excerpt_end)));
}
private static String Quote(String v) {return "'" + v + "'";}
}

View File

@@ -58,6 +58,8 @@ class Int_flag_bldr__fxt {
public void Test__to_int(int[] seg_ary, int[] val_ary, int expd) {
int[] pow_ary = Int_flag_bldr_.Bld_pow_ary(seg_ary);
Tfds.Eq(expd, Int_flag_bldr_.To_int(pow_ary, val_ary));
int[] actl_val_ary = Int_flag_bldr_.To_int_ary(pow_ary, expd);
Tfds.Eq_ary(val_ary, actl_val_ary);
}
public void Test__to_int_ary(int[] seg_ary, int val, int[] expd) {
int[] pow_ary = Int_flag_bldr_.Bld_pow_ary(seg_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.core.caches; import gplx.*; import gplx.core.*;
import org.junit.*;
import org.junit.*; import gplx.core.envs.*;
public class GfoCacheMgr_tst {
@Before public void init() {fxt = new GfoCacheMgr_fxt();} GfoCacheMgr_fxt fxt;
@Test public void teardown() {Env_.TickCount_Test = -1;}

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.core.caches; import gplx.*; import gplx.core.*;
import gplx.core.consoles.*;
import gplx.core.consoles.*; import gplx.core.envs.*;
public class Gfo_cache_mgr {
private Ordered_hash hash = Ordered_hash_.New_bry();
private Ordered_hash recent = Ordered_hash_.New_bry();

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.caches; import gplx.*; import gplx.core.*;
import gplx.core.primitives.*;
import gplx.core.primitives.*; import gplx.core.envs.*;
public class Gfo_cache_mgr_bry extends Gfo_cache_mgr_base {
public Object Get_or_null(byte[] key) {return Base_get_or_null(key);}
public void Add(byte[] key, Object val) {Base_add(key, val);}
@@ -29,7 +29,7 @@ class Gfo_cache_itm {
public long Touched() {return touched;} private long touched;
public Gfo_cache_itm Touched_update() {touched = Env_.TickCount(); return this;}
}
class Gfo_cache_itm_comparer implements gplx.lists.ComparerAble {
class Gfo_cache_itm_comparer implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Gfo_cache_itm lhs = (Gfo_cache_itm)lhsObj;
Gfo_cache_itm rhs = (Gfo_cache_itm)rhsObj;

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.consoles; import gplx.*; import gplx.core.*;
import gplx.core.envs.*;
public class Gfo_cmd_arg_itm_ {
public static final int Tid_general = 0, Tid_system = 1;
public static final int Val_tid_string = 0, Val_tid_yn = 1, Val_tid_url = 2, Val_tid_list_string = 3;

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.core.consoles; import gplx.*; import gplx.core.*;
import org.junit.*; import gplx.core.tests.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.envs.*;
public class Gfo_cmd_arg_mgr_tst {
@Before public void init() {fxt.Clear();} private final Gfo_cmd_arg_mgr_fxt fxt = new Gfo_cmd_arg_mgr_fxt();
@Test public void Val__many() {

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.core.ios; import gplx.*; import gplx.core.*;
import gplx.lists.*;
import gplx.core.lists.*;
class BinaryHeap_Io_line_rdr {
public BinaryHeap_Io_line_rdr(ComparerAble comparer) {this.comparer = comparer;} ComparerAble comparer;
Io_line_rdr[] ary = Ary_empty; int ary_len = 0, ary_max = 0;

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.core.ios; import gplx.*; import gplx.core.*;
import org.junit.*;
import org.junit.*; import gplx.core.envs.*;
public class Io_line_rdr_tst {
Io_line_rdr_fxt fxt;
@Before public void init() {

View File

@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.ios; import gplx.*; import gplx.core.*;
import gplx.lists.*;
import gplx.core.envs.*;
import gplx.core.lists.*;
public class Io_sort {
public Io_sort Memory_max_(int v) {memory_max = v; return this;} private int memory_max = Io_mgr.Len_kb;
public Io_url[] Split(Gfo_usr_dlg usr_dlg, Io_url_gen src_fil_gen, Io_url_gen trg_fil_gen, Io_line_rdr_key_gen key_gen) {return Split(usr_dlg, src_fil_gen, trg_fil_gen, Io_sort_split_itm_sorter.Instance, key_gen);}

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.core.ios; import gplx.*; import gplx.core.*;
public class Io_sort_split_itm_sorter implements gplx.lists.ComparerAble {
public class Io_sort_split_itm_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Io_sort_split_itm lhs = (Io_sort_split_itm)lhsObj, rhs = (Io_sort_split_itm)rhsObj;
// Tfds.Write(String_.new_u8(lhs.Bfr(), lhs.Key_bgn(), lhs.Key_end()), String_.new_u8(rhs.Bfr(), rhs.Key_bgn(), rhs.Key_end()));

View File

@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.core.ios; import gplx.*; import gplx.core.*;
import java.io.*;
import java.util.zip.*;
import gplx.core.envs.*;
public class Io_zip_mgr_base 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);

View File

@@ -73,10 +73,10 @@ public class Gfo_qarg_mgr {
public byte[] To_bry() {
int len = list.Count(); if (len == 0) return Bry_.Empty;
Bry_bfr bfr = Bry_bfr.new_();
To_bry(bfr, gplx.xowa.Xoa_app_.Utl__encoder_mgr().Href(), false);
To_bry(bfr, gplx.langs.htmls.encoders.Gfo_url_encoder_.Href, false);
return bfr.To_bry_and_clear();
}
public void To_bry(Bry_bfr bfr, Url_encoder href_encoder, boolean encode) {
public void To_bry(Bry_bfr bfr, Gfo_url_encoder href_encoder, boolean encode) {
int len = list.Count(); if (len == 0) return;
for (int i = 0; i < len; ++i) {
Gfo_qarg_itm itm = (Gfo_qarg_itm)list.Get_at(i);
@@ -86,8 +86,8 @@ public class Gfo_qarg_mgr {
Write_or_encode(bfr, href_encoder, encode, itm.Val_bry());
}
}
public static void Concat_bfr(Bry_bfr bfr, Url_encoder href_encoder, Gfo_qarg_itm[] ary) {Concat_bfr(bfr, href_encoder, ary, true);}
private static void Concat_bfr(Bry_bfr bfr, Url_encoder href_encoder, Gfo_qarg_itm[] ary, boolean encode) {
public static void Concat_bfr(Bry_bfr bfr, Gfo_url_encoder href_encoder, Gfo_qarg_itm[] ary) {Concat_bfr(bfr, href_encoder, ary, true);}
private static void Concat_bfr(Bry_bfr bfr, Gfo_url_encoder href_encoder, Gfo_qarg_itm[] ary, boolean encode) {
int ary_len = ary.length;
for (int i = 0; i < ary_len; i++) {
Gfo_qarg_itm itm = ary[i];
@@ -97,7 +97,7 @@ public class Gfo_qarg_mgr {
Write_or_encode(bfr, href_encoder, encode, itm.Val_bry());
}
}
private static void Write_or_encode(Bry_bfr bfr, Url_encoder href_encoder, boolean encode, byte[] bry) {
private static void Write_or_encode(Bry_bfr bfr, Gfo_url_encoder href_encoder, boolean encode, byte[] bry) {
if (bry == null) return; // NOTE: need null check b/c itm.Val_bry can be null
if (encode)
href_encoder.Encode(bfr, bry);

View File

@@ -16,11 +16,10 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.net; import gplx.*; import gplx.core.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
import gplx.core.primitives.*; import gplx.core.btries.*;
public class Gfo_url_parser {
private final Btrie_slim_mgr protocols = Btrie_slim_mgr.ci_a7(); // ASCII:url_protocol; EX:"http:", "ftp:", etc
private final Bry_ary segs_ary = new Bry_ary(4), qargs = new Bry_ary(4);
private final Url_encoder encoder = Url_encoder.new_html_href_mw_().Itms_raw_same_many(Byte_ascii.Underline);
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(500);
public byte[] Relative_url_protocol_bry() {return Gfo_protocol_itm.Itm_https.Key_w_colon_bry();} // NOTE: https b/c any WMF wiki will now default to WMF; DATE:2015-07-26
public Gfo_url_parser() {
@@ -223,7 +222,7 @@ public class Gfo_url_parser {
return pos + 1;
}
private byte[] Make_bry(int bgn, int end) {
return encoded ? encoder.Decode(tmp_bfr, src, bgn, end) : Bry_.Mid(src, bgn, end);
return encoded ? gplx.langs.htmls.encoders.Gfo_url_encoder_.Xourl.Decode(tmp_bfr, Bool_.N, src, bgn, end).To_bry_and_clear() : Bry_.Mid(src, bgn, end);
}
private Gfo_qarg_itm[] Make_qargs() {
int qargs_len = qargs.Len(); if (qargs_len == 0) return Gfo_qarg_itm.Ary_empty;

View File

@@ -16,12 +16,12 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.core.threads; import gplx.*; import gplx.core.*;
import gplx.core.brys.fmtrs.*;
import gplx.core.brys.fmtrs.*; import gplx.core.envs.*;
import gplx.gfui.*; import gplx.xowa.bldrs.cmds.utils.*;
public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
public Gfo_thread_cmd_unzip Init(Gfo_usr_dlg usr_dlg, Gfui_kit kit, ProcessAdp bzip2_process, ProcessAdp zip_process, ProcessAdp gz_process, Io_url src, Io_url trg) {
public Gfo_thread_cmd_unzip Init(Gfo_usr_dlg usr_dlg, Gfui_kit kit, Process_adp bzip2_process, Process_adp zip_process, Process_adp gz_process, Io_url src, Io_url trg) {
this.src = src; this.trg = trg; this.kit = kit; this.usr_dlg = usr_dlg;
unzip_wkr = new Xob_unzip_wkr().Init(bzip2_process, zip_process, gz_process).Process_run_mode_(ProcessAdp.Run_mode_async);
unzip_wkr = new Xob_unzip_wkr().Init(bzip2_process, zip_process, gz_process).Process_run_mode_(Process_adp.Run_mode_async);
return this;
} private Io_url src, trg; private Gfui_kit kit; private Gfo_usr_dlg usr_dlg; private Xob_unzip_wkr unzip_wkr;
public GfoInvkAble Owner() {return owner;} public Gfo_thread_cmd_unzip Owner_(GfoInvkAble v) {owner = v; return this;} GfoInvkAble owner;
@@ -55,7 +55,7 @@ public class Gfo_thread_cmd_unzip implements Gfo_thread_cmd {
}
return Gfo_thread_cmd_.Init_ok;
}
public boolean Async_running() {return unzip_wkr.Process_exit_code() == ProcessAdp.Exit_init;}
public boolean Async_running() {return unzip_wkr.Process_exit_code() == Process_adp.Exit_init;}
public void Async_run() {
usr_dlg.Prog_many(GRP_KEY, "bgn", "unzipping");
unzip_wkr.Decompress(src, trg);

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.fsdb.data; import gplx.*; import gplx.fsdb.*;
import gplx.core.primitives.*;
import gplx.core.primitives.*; import gplx.core.envs.*;
import gplx.dbs.*; import gplx.core.ios.*;
import gplx.dbs.engines.sqlite.*;
public class Fsd_bin_tbl implements RlsAble {

View File

@@ -49,7 +49,7 @@ public class Fsd_thm_itm {
public static final Fsd_thm_itm[] Ary_empty = new Fsd_thm_itm[0];
public static Fsd_thm_itm new_() {return new Fsd_thm_itm();} Fsd_thm_itm() {}
}
class Fsdb_thm_itm_sorter implements gplx.lists.ComparerAble {
class Fsdb_thm_itm_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Fsd_thm_itm lhs = (Fsd_thm_itm)lhsObj;
Fsd_thm_itm rhs = (Fsd_thm_itm)rhsObj;

View File

@@ -34,6 +34,7 @@ public class Html_tag_ {
, Id__ul = 11
, Id__li = 12
, Id__p = 13
, Id__hr = 14
;
public static final byte[]
Bry__a = Bry_.new_a7("a")
@@ -49,6 +50,8 @@ public class Html_tag_ {
.Add_str_int("span" , Id__span)
.Add_str_int("div" , Id__div)
.Add_str_int("img" , Id__img)
.Add_str_int("hr" , Id__hr)
.Add_str_int("ul" , Id__ul)
;
public static String To_str(int tid) {
switch (tid) {
@@ -65,6 +68,7 @@ public class Html_tag_ {
case Id__span: return "span";
case Id__div: return "div";
case Id__img: return "img";
case Id__hr: return "hr";
default: throw Err_.new_unhandled(tid);
}
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.langs.htmls; import gplx.*; import gplx.langs.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
public class Html_utl {
private static final Url_encoder encoder_id = Url_encoder.new_html_id_(); private static final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
private static final Gfo_url_encoder encoder_id = Gfo_url_encoder_.Id; private static final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
public static String Encode_id_as_str(byte[] key) {return String_.new_u8(Encode_id_as_bry(key));}
public static byte[] Encode_id_as_bry(byte[] key) {
byte[] escaped = Escape_html_as_bry(tmp_bfr, key, Bool_.N, Bool_.N, Bool_.N, Bool_.Y, Bool_.Y);
@@ -178,4 +178,9 @@ public class Html_utl {
return bfr.To_bry_and_clear();
}
public static String Replace_apos(String s) {return String_.Replace(s, "'", "\"");}
public static void Log(Exception e, String head, byte[] page_url, byte[] src, int pos) {
Err err = Err_.cast_or_make(e); if (err.Logged()) return;
String msg = String_.Format("{0}; page={1} err={2} mid={3} trace={4}", head, page_url, Err_.To_str(e), Bry_.Escape_ws(Bry_.Mid_by_len_safe(src, pos, 255)), err.To_str__log());
Gfo_usr_dlg_.Instance.Warn_many("", "", msg);
}
}

View File

@@ -0,0 +1,64 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import gplx.core.btries.*; import gplx.xowa.parsers.amps.*;
public class Gfo_url_encoder implements Url_encoder_interface {
private Gfo_url_encoder_itm[] encode_ary, decode_ary; private Gfo_url_encoder anchor_encoder = null;
public Gfo_url_encoder(Gfo_url_encoder_itm[] encode_ary, Gfo_url_encoder_itm[] decode_ary, Gfo_url_encoder anchor_encoder) {
this.encode_ary = encode_ary; this.decode_ary = decode_ary; this.anchor_encoder = anchor_encoder;
}
public String Encode_str(String str) {return String_.new_u8(Encode(Bry_.new_u8(str)));}
public byte[] Encode_bry(String str) {return Encode(Bry_.new_u8(str));}
public byte[] Encode(byte[] bry) {Bry_bfr bfr = Bry_bfr_.Get(); Encode(bfr, bry, 0, bry.length); return bfr.To_bry_and_rls();}
public Bry_bfr Encode(Bry_bfr bfr, byte[] bry) { Encode(bfr, bry, 0, bry.length); return bfr;}
public void Encode(Bry_bfr bfr, byte[] bry, int bgn, int end) {
for (int i = bgn; i < end; ++i) {
byte b = bry[i];
if (anchor_encoder != null && b == Byte_ascii.Hash) {
bfr.Add_byte(Byte_ascii.Hash);
anchor_encoder.Encode(bfr, bry, i + 1, end);
break;
}
Gfo_url_encoder_itm itm = encode_ary[b & 0xff];// PATCH.JAVA:need to convert to unsigned byte
i += itm.Encode(bfr, bry, end, i, b);
}
}
public byte[] Encode_to_file_protocol(Io_url url) {
Bry_bfr bfr = Bry_bfr_.Get();
bfr.Add(Io_url.Http_file_bry);
Encode(bfr, url.RawBry());
return bfr.To_bry_and_rls();
}
public String Decode_str(String str) {return String_.new_u8(Decode(Bry_.new_u8(str)));}
public byte[] Decode(byte[] bry) {return Decode(Bool_.N, bry, 0, bry.length);}
public byte[] Decode(byte[] bry, int bgn, int end) {return Decode(Bool_.N, bry, bgn, end);}
private byte[] Decode(boolean fail, byte[] bry, int bgn, int end) {Bry_bfr bfr = Bry_bfr_.Get(); Decode(bfr, fail, bry, bgn, end); return bfr.To_bry_and_rls();}
public Bry_bfr Decode(Bry_bfr bfr, boolean fail, byte[] bry, int bgn, int end) {
for (int i = bgn; i < end; ++i) {
byte b = bry[i];
if (anchor_encoder != null && b == Byte_ascii.Hash) {
bfr.Add_byte(Byte_ascii.Hash);
anchor_encoder.Decode(bfr, Bool_.N, bry, i + 1, end);
break;
}
Gfo_url_encoder_itm itm = decode_ary[b & 0xff];// PATCH.JAVA:need to convert to unsigned byte
i += itm.Decode(bfr, bry, end, i, b, fail);
}
return bfr;
}
}

View File

@@ -0,0 +1,87 @@
/*
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.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import gplx.core.btries.*;
import gplx.xowa.parsers.amps.*;
public class Gfo_url_encoder_ {
public static final Gfo_url_encoder
Id = Gfo_url_encoder_.New__html_id().Make()
, Href = Gfo_url_encoder_.New__html_href_mw().Make()
, Href_quotes = Gfo_url_encoder_.New__html_href_quotes().Make()
, Href_qarg = Gfo_url_encoder_.New__html_href_qarg().Make()
, Xourl = Gfo_url_encoder_.New__html_href_mw().Init__same__many(Byte_ascii.Underline).Make()
, Http_url = Gfo_url_encoder_.New__http_url().Make()
, Http_url_ttl = Gfo_url_encoder_.New__http_url_ttl().Make()
, Fsys = Gfo_url_encoder_.New__fsys_lnx().Make()
, Fsys_safe = Gfo_url_encoder_.New__fsys_wnt().Make()
, Gfs = Gfo_url_encoder_.New__gfs().Make()
;
private static Gfo_url_encoder_mkr New__html_id() { // EX: "<a id='a<>b'>" -> "<a id='a.C3.A9b'>"
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Dot).Init_common(Bool_.Y)
.Init__decode_mark(Byte_ascii.Dot)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline)
.Init__html_ent(Byte_ascii.Amp, Xop_amp_trie.Instance);
}
private static Gfo_url_encoder_mkr New__html_href_mw() { // EX: "<a href='^#^'>" -> "<a href='%5E#.5E'>"
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline)
.Init__same__many
( Byte_ascii.Semic, Byte_ascii.At, Byte_ascii.Dollar, Byte_ascii.Bang, Byte_ascii.Star
, Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Comma, Byte_ascii.Slash, Byte_ascii.Colon
, Byte_ascii.Hash// NOTE: not part of wfUrlEncode; not sure where this is specified; needed for A#b
)
.Init__anchor_encoder(New__html_id().Make());
}
private static Gfo_url_encoder_mkr New__html_href_qarg() { // same as regular href encoder, but also do not encode qarg characters "?" and "="
return New__html_href_mw().Init__same__many(Byte_ascii.Question, Byte_ascii.Eq);
}
private static Gfo_url_encoder_mkr New__html_href_quotes() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline) // convert " " to "_"
.Init__same__rng(0, 255) // default everything to same;
.Init__diff__many(Byte_ascii.Percent, Byte_ascii.Apos
, Byte_ascii.Quote, Byte_ascii.Lt, Byte_ascii.Gt); // encode ', ", <, >
}
public static Gfo_url_encoder_mkr New__http_url() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.N)
.Init__diff__one(Byte_ascii.Space, Byte_ascii.Plus);
}
private static Gfo_url_encoder_mkr New__http_url_ttl() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y);
}
private static Gfo_url_encoder_mkr New__fsys_lnx() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__same__many(Byte_ascii.Slash)
.Init__diff__one(Byte_ascii.Backslash, Byte_ascii.Slash);
}
private static Gfo_url_encoder_mkr New__fsys_wnt() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent)
.Init__same__rng(Byte_ascii.Num_0, Byte_ascii.Num_9)
.Init__same__rng(Byte_ascii.Ltr_A, Byte_ascii.Ltr_Z)
.Init__same__rng(Byte_ascii.Ltr_a, Byte_ascii.Ltr_z)
.Init__same__many
( Byte_ascii.Bang, Byte_ascii.At, Byte_ascii.Hash, Byte_ascii.Dollar, Byte_ascii.Percent, Byte_ascii.Pow, Byte_ascii.Amp
, Byte_ascii.Plus, Byte_ascii.Eq, Byte_ascii.Underline, Byte_ascii.Dash
, Byte_ascii.Dot, Byte_ascii.Comma
, Byte_ascii.Tick, Byte_ascii.Tilde, Byte_ascii.Brack_bgn, Byte_ascii.Brack_end, Byte_ascii.Curly_bgn, Byte_ascii.Curly_end);
}
private static Gfo_url_encoder_mkr New__gfs() {
return new Gfo_url_encoder_mkr().Init(Byte_ascii.Percent).Init_common(Bool_.Y)
.Init__same__many(Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Apos, Byte_ascii.Semic);
}
}

View File

@@ -0,0 +1,101 @@
/*
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.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import gplx.core.btries.*; import gplx.xowa.parsers.amps.*;
public interface Gfo_url_encoder_itm {
int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b);
int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid);
}
class Gfo_url_encoder_itm_same implements Gfo_url_encoder_itm {
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {bfr.Add_byte(b); return 0;}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {bfr.Add_byte(b); return 0;}
public static final Gfo_url_encoder_itm Instance = new Gfo_url_encoder_itm_same();
}
class Gfo_url_encoder_itm_diff implements Gfo_url_encoder_itm {
public Gfo_url_encoder_itm_diff(byte orig, byte repl) {this.orig = orig; this.repl = repl;} private byte orig, repl;
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {bfr.Add_byte(repl); return 0;}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {bfr.Add_byte(orig); return 0;}
}
class Gfo_url_encoder_itm_hex implements Gfo_url_encoder_itm {
public Gfo_url_encoder_itm_hex(byte encode_marker) {this.encode_marker = encode_marker;} private byte encode_marker;
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {Encode_byte(b, bfr, encode_marker); return 0;}
public static void Encode_byte(byte b, Bry_bfr bfr, byte encode_marker) {
int b_int = b & 0xFF;// PATCH.JAVA:need to convert to unsigned byte
bfr.Add_byte(encode_marker);
bfr.Add_byte(HexBytes[b_int >> 4]);
bfr.Add_byte(HexBytes[b_int & 15]);
}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {
if (idx + 2 >= end) {
if (fail_when_invalid) throw Err_.new_wo_type("decode needs 3 bytes", "idx", idx, "len", end, "snip", String_.new_u8(Bry_.Mid_by_len_safe(src, idx, 3)));
else {
bfr.Add_byte(b);
return 0;
}
}
int hex_val = Int_.To_int_hex(src[idx + 1]);
if (hex_val == -1) { // invalid hex byte; EX: %GC; DATE:2014-04-10
bfr.Add_byte(b);
return 0;
}
int v_0 = hex_val * 16;
if (v_0 != -1) {
int v_1 = Int_.To_int_hex(src[idx + 2]);
if (v_1 != -1) {
bfr.Add_byte((byte)(v_0 + v_1));
return 2;
}
}
if (fail_when_invalid)
throw Err_.new_wo_type("decode is invalid", "idx", idx, "snip", String_.new_u8(Bry_.Mid_by_len_safe(src, idx, 3)));
else {
bfr.Add_byte(b);
return 0;
}
}
public static final byte[] HexBytes = new byte[]
{ Byte_ascii.Num_0, Byte_ascii.Num_1, Byte_ascii.Num_2, Byte_ascii.Num_3, Byte_ascii.Num_4, Byte_ascii.Num_5, Byte_ascii.Num_6, Byte_ascii.Num_7
, Byte_ascii.Num_8, Byte_ascii.Num_9, Byte_ascii.Ltr_A, Byte_ascii.Ltr_B, Byte_ascii.Ltr_C, Byte_ascii.Ltr_D, Byte_ascii.Ltr_E, Byte_ascii.Ltr_F
};
}
class Gfo_url_encoder_itm_html_ent implements Gfo_url_encoder_itm {
public Gfo_url_encoder_itm_html_ent(Btrie_slim_mgr amp_trie) {this.amp_trie = amp_trie;} Btrie_slim_mgr amp_trie;
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {
++idx; // b is &; get next character afterwards
if (idx == end) { // & is last char; return
Gfo_url_encoder_itm_hex.Encode_byte(Byte_ascii.Amp, bfr, Byte_ascii.Dot);
return 0;
}
b = src[idx];
Object o = amp_trie.Match_bgn_w_byte(b, src, idx, end);
if (o == null) { // unknown entity (EX:&unknown;); return &;
Gfo_url_encoder_itm_hex.Encode_byte(Byte_ascii.Amp, bfr, Byte_ascii.Dot);
return 0;
}
else {
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
byte[] bry_u8 = itm.U8_bry(); // NOTE: must utf8 encode val; EX: &nbsp; is 160 but must become 192,160
for (int i = 0; i < bry_u8.length; i++)
Gfo_url_encoder_itm_hex.Encode_byte(bry_u8[i], bfr, Byte_ascii.Dot);
return itm.Xml_name_bry().length - 1; // -1 to ignore & in XmlEntityName
}
}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {
bfr.Add_byte(b); return 0;
}
}

View File

@@ -0,0 +1,83 @@
/*
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.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import gplx.core.btries.*;
public class Gfo_url_encoder_mkr {
private Gfo_url_encoder_itm[] encode_ary, decode_ary; private Gfo_url_encoder anchor_encoder;
public Gfo_url_encoder_mkr Init(byte bicode_mark) {
encode_ary = new Gfo_url_encoder_itm[256]; decode_ary = new Gfo_url_encoder_itm[256];
Gfo_url_encoder_itm_hex hex = new Gfo_url_encoder_itm_hex(bicode_mark);
for (int i = 0; i < 256; ++i) {
encode_ary[i] = hex; // default encode to hex
decode_ary[i] = Gfo_url_encoder_itm_same.Instance; // default decode to same; needed for files; EX: A!%21.png -> A!!.png;
}
decode_ary[bicode_mark] = hex;
return this;
}
public Gfo_url_encoder_mkr Init__same__rng(int bgn, int end) {
for (int i = bgn; i <= end; ++i)
encode_ary[i] = decode_ary[i] = Gfo_url_encoder_itm_same.Instance;
return this;
}
public Gfo_url_encoder_mkr Init__same__many(int... ary) {
int len = ary.length;
for (int i = 0; i < len; i++) {
int idx = ary[i];
encode_ary[idx] = decode_ary[idx] = Gfo_url_encoder_itm_same.Instance;
}
return this;
}
public Gfo_url_encoder_mkr Init_common(boolean encode_colon) {
Init__same__rng(Byte_ascii.Num_0, Byte_ascii.Num_9);
Init__same__rng(Byte_ascii.Ltr_A, Byte_ascii.Ltr_Z);
Init__same__rng(Byte_ascii.Ltr_a, Byte_ascii.Ltr_z);
Init__same__many(Byte_ascii.Dash, Byte_ascii.Dot, Byte_ascii.Underline);
if (encode_colon) Init__same__many(Byte_ascii.Colon);
return this;
}
public Gfo_url_encoder_mkr Init__decode_mark(byte decode_mark) {
decode_ary[decode_mark & 0xff] = new Gfo_url_encoder_itm_hex(decode_mark);// PATCH.JAVA:need to convert to unsigned byte
return this;
}
public Gfo_url_encoder_mkr Init__diff__one(byte src, byte trg) {
Gfo_url_encoder_itm_diff itm = new Gfo_url_encoder_itm_diff(src, trg);
encode_ary[src] = decode_ary[trg] = itm;
return this;
}
public Gfo_url_encoder_mkr Init__diff__many(byte bicode_mark, int... ary) {
Gfo_url_encoder_itm_hex hex = new Gfo_url_encoder_itm_hex(bicode_mark);
int len = ary.length;
for (int i = 0; i < len; i++) {
int idx = ary[i];
encode_ary[idx] = decode_ary[idx] = hex;
}
decode_ary[bicode_mark] = hex;
return this;
}
public Gfo_url_encoder_mkr Init__html_ent(byte src, Btrie_slim_mgr trie) {
Gfo_url_encoder_itm_html_ent itm = new Gfo_url_encoder_itm_html_ent(trie);
encode_ary[src] = itm;
return this;
}
public Gfo_url_encoder_mkr Init__anchor_encoder(Gfo_url_encoder v) {this.anchor_encoder = v; return this;}
public Gfo_url_encoder Make() {
Gfo_url_encoder rv = new Gfo_url_encoder(encode_ary, decode_ary, anchor_encoder);
encode_ary = decode_ary = null; anchor_encoder = null;
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.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Gfo_url_encoder_tst {
private final Gfo_url_encoder_fxt fxt = new Gfo_url_encoder_fxt();
@Test public void Id__nums() {fxt.Encoder_id().Test__bicode("0123456789" , "0123456789");}
@Test public void Id__ltrs_lower() {fxt.Encoder_id().Test__bicode("abcdefghijklmnopqrstuvwxyz" , "abcdefghijklmnopqrstuvwxyz");}
@Test public void Id__ltrs_upper() {fxt.Encoder_id().Test__bicode("ABCDEFGHIJKLMNOPQRSTUVWXYZ" , "ABCDEFGHIJKLMNOPQRSTUVWXYZ");}
@Test public void Id__syms() {fxt.Encoder_id().Test__encode("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ".21.22.23.24.25.26.27.28.29.2A.2B.2C-..2F:.3B.3C.3D.3E.3F.40.5B.5C.5D.5E_.60.7B.7C.7D.7E");} // NOTE: not reversible since "." is encode_marker but not encoded
@Test public void Id__foreign() {fxt.Encoder_id().Test__bicode("aéb", "a.C3.A9b");}
@Test public void Id__nbsp() {fxt.Encoder_id().Test__encode("a&nbsp;b", "a.C2.A0b");} // NOTE: not just .A0 (160) but utf8-encoded .C2.A0
@Test public void Id__space() {fxt.Encoder_id().Test__bicode("a b", "a_b");}
@Test public void Id__err() {
byte[] raw = Bry_.new_a7("0%.jpg");
Bry_bfr tmp_bfr = Bry_bfr.new_();
fxt.Encoder_id().Encoder().Decode(tmp_bfr, Bool_.N, raw, 0, raw.length);
Tfds.Eq("0%.jpg", tmp_bfr.To_str_and_clear());
}
@Test public void Url__syms() {fxt.Encoder_url().Test__bicode("!?^~", "%21%3F%5E%7E");}
@Test public void Url__foreign() {fxt.Encoder_url().Test__bicode("aéb", "a%C3%A9b");}
@Test public void Url__space() {fxt.Encoder_url().Test__bicode("a b", "a+b");}
@Test public void Href__space() {
fxt.Encoder_href().Test__encode("a b", "a_b");
}
@Test public void Href__special_and_anchor() { // PURPOSE: MediaWiki encodes with % for ttls, but . for anchors; REF:Title.php!(before-anchor)getLocalUrl;wfUrlencode (after-anchor)escapeFragmentForURL
fxt.Encoder_href().Test__bicode("^#^", "%5E#.5E");
fxt.Encoder_href().Test__encode("A#", "A#");
}
@Test public void Href__invalid() { // PURPOSE: check that invalid url decodings are rendered literally; DATE:2014-04-10
fxt.Encoder_href().Test__encode("%GC", "%25GC");
}
@Test public void Fsys__wnt() {
fxt.Encoder_fsys_safe().Test__encode("Help:Options/HTML", "Help%3AOptions%2FHTML");
}
}
class Gfo_url_encoder_fxt {
public Gfo_url_encoder Encoder() {return encoder;} private Gfo_url_encoder encoder;
public Gfo_url_encoder_fxt Encoder_id() {encoder = Gfo_url_encoder_.Id; return this;}
public Gfo_url_encoder_fxt Encoder_href() {encoder = Gfo_url_encoder_.Href; return this;}
public Gfo_url_encoder_fxt Encoder_url() {encoder = Gfo_url_encoder_.Http_url; return this;}
public Gfo_url_encoder_fxt Encoder_fsys_safe() {encoder = Gfo_url_encoder_.Fsys_safe; return this;}
public void Test__bicode(String raw, String encoded) {
Test__encode(raw, encoded);
Test__decode(encoded, raw);
}
public void Test__encode(String raw, String expd) {
Tfds.Eq(expd, String_.new_u8(encoder.Encode(Bry_.new_u8(raw))));
}
public void Test__decode(String raw, String expd) {
Tfds.Eq(expd, String_.new_u8(encoder.Decode(Bry_.new_u8(raw))));
}
}

View File

@@ -1,307 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import gplx.core.btries.*;
import gplx.xowa.parsers.amps.*;
public class Url_encoder implements Url_encoder_interface {
private Url_encoder_itm[] encode_ary = new Url_encoder_itm[256], decode_ary = new Url_encoder_itm[256];
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
private Url_encoder anchor_encoder = null;
private Object thread_lock = new Object();
public void Itms_ini(byte primary_encode_marker) {
Url_encoder_itm_hex hex = new Url_encoder_itm_hex(primary_encode_marker);
for (int i = 0; i < 256; i++) {
encode_ary[i] = hex; // default encode to hex
decode_ary[i] = Url_encoder_itm_same.Instance; // default decode to same; needed for files; EX: A!%21.png -> A!!.png;
}
decode_ary[primary_encode_marker] = hex;
}
public void Itms_raw_diff_many(byte primary_encode_marker, int... ary) {
Url_encoder_itm_hex hex = new Url_encoder_itm_hex(primary_encode_marker);
int ary_len = ary.length;
for (int i = 0; i < ary_len; i++) {
encode_ary[ary[i]] = hex;
decode_ary[ary[i]] = hex;
}
decode_ary[primary_encode_marker] = hex;
}
public void Itms_decode_marker(byte decode_marker) {
Url_encoder_itm_hex hex = new Url_encoder_itm_hex(decode_marker);
decode_ary[decode_marker & 0xff] = hex;// PATCH.JAVA:need to convert to unsigned byte
}
public void Itms_decode_diff(byte orig, byte repl) {
decode_ary[orig & 0xff] = new Url_encoder_itm_diff(orig, repl);// PATCH.JAVA:need to convert to unsigned byte
}
public void Itms_raw_same_rng(int bgn, int end) {
for (int i = bgn; i <= end; i++) {
encode_ary[i] = Url_encoder_itm_same.Instance;
decode_ary[i] = Url_encoder_itm_same.Instance;
}
}
public Url_encoder Itms_raw_same_many(int... ary) {
int ary_len = ary.length;
for (int i = 0; i < ary_len; i++) {
encode_ary[ary[i]] = Url_encoder_itm_same.Instance;
decode_ary[ary[i]] = Url_encoder_itm_same.Instance;
}
return this;
}
public void Itms_raw_html_ent(byte src, Btrie_slim_mgr trie) {
Url_encoder_itm_html_ent itm = new Url_encoder_itm_html_ent(trie);
encode_ary[src] = itm;
}
public Url_encoder Itms_raw_diff(byte src, byte trg) {
Url_encoder_itm_diff itm = new Url_encoder_itm_diff(src, trg);
encode_ary[src] = itm;
decode_ary[trg] = itm;
return this;
}
public byte[] Encode_http(Io_url url) {
synchronized (thread_lock) {
tmp_bfr.Add(Io_url.Http_file_bry);
Encode(tmp_bfr, url.RawBry());
return tmp_bfr.To_bry_and_clear();
}
}
public String Encode_str(String str) {
synchronized (thread_lock) {
byte[] bry = Bry_.new_u8(str); Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.To_str_and_clear();
}
}
public byte[] Encode_bry(String str) {
synchronized (thread_lock) {
byte[] bry = Bry_.new_u8(str); Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.To_bry_and_clear();
}
}
public byte[] Encode(byte[] bry) {Encode(tmp_bfr, bry, 0, bry.length); return tmp_bfr.To_bry_and_clear();}
public Bry_bfr Encode(Bry_bfr bfr, byte[] bry) {Encode(bfr, bry, 0, bry.length); return bfr;}
public void Encode(Bry_bfr bfr, byte[] bry, int bgn, int end) {
synchronized (thread_lock) {
for (int i = bgn; i < end; i++) {
byte b = bry[i];
if (anchor_encoder != null && b == Byte_ascii.Hash) {
bfr.Add_byte(Byte_ascii.Hash);
anchor_encoder.Encode(bfr, bry, i + 1, end);
break;
}
Url_encoder_itm itm = encode_ary[b & 0xff];// PATCH.JAVA:need to convert to unsigned byte
i += itm.Encode(bfr, bry, end, i, b);
}
}
}
public String Decode_str(String str) {
synchronized (thread_lock) {
byte[] bry = Bry_.new_u8(str); Decode(bry, 0, bry.length, tmp_bfr, true); return tmp_bfr.To_str_and_clear();
}
}
public byte[] Decode(byte[] bry) {return Decode(tmp_bfr, bry, 0, bry.length);}
public byte[] Decode(byte[] bry, int bgn, int end) {return Decode(tmp_bfr, bry, bgn, end);}
public byte[] Decode(Bry_bfr bfr, byte[] bry, int bgn, int end) {Decode(bry, bgn, end, bfr , false); return bfr.To_bry_and_clear();}
public byte[] Decode_lax(byte[] bry) {
synchronized (thread_lock) {
Decode(bry, 0, bry.length, tmp_bfr, false); return tmp_bfr.To_bry_and_clear();
}
}
public void Decode(byte[] bry, int bgn, int end, Bry_bfr bfr, boolean fail_when_invalid) {
synchronized (thread_lock) {
for (int i = bgn; i < end; i++) {
byte b = bry[i];
if (anchor_encoder != null && b == Byte_ascii.Hash) {
bfr.Add_byte(Byte_ascii.Hash);
anchor_encoder.Decode(bry, i + 1, end, bfr, false);
break;
}
Url_encoder_itm itm = decode_ary[b & 0xff];// PATCH.JAVA:need to convert to unsigned byte
i += itm.Decode(bfr, bry, end, i, b, fail_when_invalid);
}
}
}
private static void mediawiki_base(Url_encoder rv, boolean encode_colon) {
rv.Itms_raw_same_rng(Byte_ascii.Num_0, Byte_ascii.Num_9);
rv.Itms_raw_same_rng(Byte_ascii.Ltr_A, Byte_ascii.Ltr_Z);
rv.Itms_raw_same_rng(Byte_ascii.Ltr_a, Byte_ascii.Ltr_z);
rv.Itms_raw_same_many(Byte_ascii.Dash, Byte_ascii.Dot, Byte_ascii.Underline);
if (encode_colon)
rv.Itms_raw_same_many(Byte_ascii.Colon);
}
public static Url_encoder new_html_id_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Dot);
mediawiki_base(rv, true);
rv.Itms_decode_marker(Byte_ascii.Dot);
rv.Itms_raw_diff(Byte_ascii.Space, Byte_ascii.Underline);
rv.Itms_raw_html_ent(Byte_ascii.Amp, Xop_amp_trie.Instance);
return rv;
}
public static Url_encoder new_http_url_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
mediawiki_base(rv, false);
rv.Itms_raw_diff(Byte_ascii.Space, Byte_ascii.Plus);
return rv;
}
public static Url_encoder new_http_url_ttl_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
mediawiki_base(rv, true);
return rv;
}
public static Url_encoder new_http_url_space_is_space() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
mediawiki_base(rv, true);
return rv;
}
public static Url_encoder new_fsys_lnx_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
mediawiki_base(rv, true);
rv.Itms_raw_same_many(Byte_ascii.Slash);
rv.Itms_raw_diff(Byte_ascii.Backslash, Byte_ascii.Slash);
return rv;
}
public static Url_encoder new_fsys_wnt_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
rv.Itms_raw_same_rng(Byte_ascii.Num_0, Byte_ascii.Num_9);
rv.Itms_raw_same_rng(Byte_ascii.Ltr_A, Byte_ascii.Ltr_Z);
rv.Itms_raw_same_rng(Byte_ascii.Ltr_a, Byte_ascii.Ltr_z);
rv.Itms_raw_same_many
( Byte_ascii.Bang, Byte_ascii.At, Byte_ascii.Hash, Byte_ascii.Dollar, Byte_ascii.Percent, Byte_ascii.Pow, Byte_ascii.Amp
, Byte_ascii.Plus, Byte_ascii.Eq, Byte_ascii.Underline, Byte_ascii.Dash
, Byte_ascii.Dot, Byte_ascii.Comma
, Byte_ascii.Tick, Byte_ascii.Tilde, Byte_ascii.Brack_bgn, Byte_ascii.Brack_end, Byte_ascii.Curly_bgn, Byte_ascii.Curly_end);
return rv;
}
public static Url_encoder new_file_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
mediawiki_base(rv, true);
return rv;
}
public static Url_encoder new_gfs_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
rv.Itms_raw_same_many(Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Apos, Byte_ascii.Semic);
mediawiki_base(rv, true);
return rv;
}
public static Url_encoder new_html_href_mw_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
mediawiki_base(rv, true);
rv.Itms_raw_diff(Byte_ascii.Space, Byte_ascii.Underline);
rv.Itms_raw_same_many(Byte_ascii.Semic, Byte_ascii.At, Byte_ascii.Dollar, Byte_ascii.Bang, Byte_ascii.Star
, Byte_ascii.Paren_bgn, Byte_ascii.Paren_end, Byte_ascii.Comma, Byte_ascii.Slash, Byte_ascii.Colon
, Byte_ascii.Hash// NOTE: not part of wfUrlEncode; not sure where this is specified; needed for A#b
);
rv.anchor_encoder = new_html_id_();
return rv;
}
public static Url_encoder new_html_href_quotes_() {
Url_encoder rv = new Url_encoder();
rv.Itms_ini(Byte_ascii.Percent);
rv.Itms_raw_same_rng(0, 255); // default everything to same;
rv.Itms_raw_diff_many(Byte_ascii.Percent
, Byte_ascii.Apos, Byte_ascii.Quote, Byte_ascii.Lt, Byte_ascii.Gt); // encode ', ", <, >
rv.Itms_raw_diff(Byte_ascii.Space, Byte_ascii.Underline); // convert " " to "_"
return rv;
}
}
interface Url_encoder_itm {
int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b);
int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid);
}
class Url_encoder_itm_same implements Url_encoder_itm {
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {bfr.Add_byte(b); return 0;}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {bfr.Add_byte(b); return 0;}
public static final Url_encoder_itm Instance = new Url_encoder_itm_same();
}
class Url_encoder_itm_diff implements Url_encoder_itm {
public Url_encoder_itm_diff(byte orig, byte repl) {this.orig = orig; this.repl = repl;} private byte orig, repl;
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {bfr.Add_byte(repl); return 0;}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {bfr.Add_byte(orig); return 0;}
}
class Url_encoder_itm_hex implements Url_encoder_itm {
public Url_encoder_itm_hex(byte encode_marker) {this.encode_marker = encode_marker;} private byte encode_marker;
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {Encode_byte(b, bfr, encode_marker); return 0;}
public static void Encode_byte(byte b, Bry_bfr bfr, byte encode_marker) {
int b_int = b & 0xFF;// PATCH.JAVA:need to convert to unsigned byte
bfr.Add_byte(encode_marker);
bfr.Add_byte(HexBytes[b_int >> 4]);
bfr.Add_byte(HexBytes[b_int & 15]);
}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {
if (idx + 2 >= end) {
if (fail_when_invalid) throw Err_.new_wo_type("decode needs 3 bytes", "idx", idx, "len", end, "snip", String_.new_u8(Bry_.Mid_by_len_safe(src, idx, 3)));
else {
bfr.Add_byte(b);
return 0;
}
}
int hex_val = Int_.To_int_hex(src[idx + 1]);
if (hex_val == -1) { // invalid hex byte; EX: %GC; DATE:2014-04-10
bfr.Add_byte(b);
return 0;
}
int v_0 = hex_val * 16;
if (v_0 != -1) {
int v_1 = Int_.To_int_hex(src[idx + 2]);
if (v_1 != -1) {
bfr.Add_byte((byte)(v_0 + v_1));
return 2;
}
}
if (fail_when_invalid)
throw Err_.new_wo_type("decode is invalid", "idx", idx, "snip", String_.new_u8(Bry_.Mid_by_len_safe(src, idx, 3)));
else {
bfr.Add_byte(b);
return 0;
}
}
public static final byte[] HexBytes = new byte[]
{ Byte_ascii.Num_0, Byte_ascii.Num_1, Byte_ascii.Num_2, Byte_ascii.Num_3, Byte_ascii.Num_4, Byte_ascii.Num_5, Byte_ascii.Num_6, Byte_ascii.Num_7
, Byte_ascii.Num_8, Byte_ascii.Num_9, Byte_ascii.Ltr_A, Byte_ascii.Ltr_B, Byte_ascii.Ltr_C, Byte_ascii.Ltr_D, Byte_ascii.Ltr_E, Byte_ascii.Ltr_F
};
}
class Url_encoder_itm_html_ent implements Url_encoder_itm {
public Url_encoder_itm_html_ent(Btrie_slim_mgr amp_trie) {this.amp_trie = amp_trie;} Btrie_slim_mgr amp_trie;
public int Encode(Bry_bfr bfr, byte[] src, int end, int idx, byte b) {
++idx; // b is &; get next character afterwards
if (idx == end) { // & is last char; return
Url_encoder_itm_hex.Encode_byte(Byte_ascii.Amp, bfr, Byte_ascii.Dot);
return 0;
}
b = src[idx];
Object o = amp_trie.Match_bgn_w_byte(b, src, idx, end);
if (o == null) { // unknown entity (EX:&unknown;); return &;
Url_encoder_itm_hex.Encode_byte(Byte_ascii.Amp, bfr, Byte_ascii.Dot);
return 0;
}
else {
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
byte[] bry_u8 = itm.U8_bry(); // NOTE: must utf8 encode val; EX: &nbsp; is 160 but must become 192,160
for (int i = 0; i < bry_u8.length; i++)
Url_encoder_itm_hex.Encode_byte(bry_u8[i], bfr, Byte_ascii.Dot);
return itm.Xml_name_bry().length - 1; // -1 to ignore & in XmlEntityName
}
}
public int Decode(Bry_bfr bfr, byte[] src, int end, int idx, byte b, boolean fail_when_invalid) {
bfr.Add_byte(b); return 0;
}
}

View File

@@ -1,30 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
public class Url_encoder_mgr {
public Url_encoder File() {return file;} private final Url_encoder file = Url_encoder.new_file_();
public Url_encoder Http_url() {return http_url;} private final Url_encoder http_url = Url_encoder.new_http_url_();
public Url_encoder Http_url_ttl() {return http_url_ttl;} private final Url_encoder http_url_ttl = Url_encoder.new_http_url_ttl_();
public Url_encoder Id() {return html_id;} private final Url_encoder html_id = Url_encoder.new_html_id_();
public Url_encoder Href() {return href;} private final Url_encoder href = Url_encoder.new_html_href_mw_();
public Url_encoder Href_quotes() {return href_quotes;} private final Url_encoder href_quotes = Url_encoder.new_html_href_quotes_();
public Url_encoder Gfs() {return gfs;} private final Url_encoder gfs = Url_encoder.new_gfs_();
public Url_encoder Fsys() {return fsys;} private final Url_encoder fsys = Url_encoder.new_fsys_lnx_();
public Url_encoder Fsys_safe() {return fsys_safe;} private final Url_encoder fsys_safe = Url_encoder.new_fsys_wnt_();
public Url_encoder Xourl() {return xourl;} private final Url_encoder xourl = Url_encoder.new_html_href_mw_().Itms_raw_same_many(Byte_ascii.Underline);
}

View File

@@ -1,72 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.langs.htmls.encoders; import gplx.*; import gplx.langs.*; import gplx.langs.htmls.*;
import org.junit.*;
public class Url_encoder_tst {
@Before public void init() {fxt = new Url_encoder_fxt();} Url_encoder_fxt fxt;
@Test public void Id_nums() {fxt.Encoder_id().Test_encode_decode("0123456789", "0123456789");}
@Test public void Id_ltrs_lower() {fxt.Encoder_id().Test_encode_decode("abcdefghijklmnopqrstuvwxyz", "abcdefghijklmnopqrstuvwxyz");}
@Test public void Id_ltrs_upper() {fxt.Encoder_id().Test_encode_decode("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");}
@Test public void Id_syms() {fxt.Encoder_id().Test_encode("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ".21.22.23.24.25.26.27.28.29.2A.2B.2C-..2F:.3B.3C.3D.3E.3F.40.5B.5C.5D.5E_.60.7B.7C.7D.7E");} // NOTE: not reversible since "." is encode_marker but not encoded
@Test public void Id_foreign() {fxt.Encoder_id().Test_encode_decode("aéb", "a.C3.A9b");}
@Test public void Id_space() {fxt.Encoder_id().Test_encode_decode("a b", "a_b");}
@Test public void Id_err() {
byte[] raw = Bry_.new_a7("0%.jpg");
Bry_bfr tmp_bfr = Bry_bfr.new_();
fxt.Encoder_id().Encoder().Decode(raw, 0, raw.length, tmp_bfr, false);
Tfds.Eq("0%.jpg", tmp_bfr.To_str_and_clear());
}
@Test public void Id_nbsp() {fxt.Encoder_id().Test_encode("a&nbsp;b", "a.C2.A0b");} // NOTE: not just .A0 (160) but utf8-encoded .C2.A0
@Test public void Url_syms() {fxt.Encoder_url().Test_encode_decode("!?^~", "%21%3F%5E%7E");}
@Test public void Url_foreign() {fxt.Encoder_url().Test_encode_decode("aéb", "a%C3%A9b");}
@Test public void Url_space() {fxt.Encoder_url().Test_encode_decode("a b", "a+b");}
@Test public void File_space() {
fxt.Encoder_href().Test_encode("a b", "a_b");
// fxt.Encoder_url().tst_decode("a_b", "a_b");
}
@Test public void Href_special_and_anchor() { // PURPOSE: MediaWiki encodes with % for ttls, but . for anchors; REF:Title.php!(before-anchor)getLocalUrl;wfUrlencode (after-anchor)escapeFragmentForURL
fxt.Encoder_href().Test_encode("^#^", "%5E#.5E");
fxt.Encoder_href().Test_encode("A#", "A#");
fxt.Encoder_href().tst_decode("%5E#.5E", "^#^");
}
@Test public void Fsys_wnt() {
fxt.Encoder_fsys_safe().Test_encode("Help:Options/HTML", "Help%3AOptions%2FHTML");
}
@Test public void Invalid_url_decode() { // PURPOSE: check that invalid url decodings are rendered literally; DATE:2014-04-10
fxt.Encoder_href().Test_encode("%GC", "%25GC");
}
}
class Url_encoder_fxt {
public Url_encoder Encoder() {return encoder;} Url_encoder encoder;
public Url_encoder_fxt Encoder_id() {encoder = Url_encoder.new_html_id_(); return this;}
public Url_encoder_fxt Encoder_href() {encoder = Url_encoder.new_html_href_mw_(); return this;}
public Url_encoder_fxt Encoder_url() {encoder = Url_encoder.new_http_url_(); return this;}
public Url_encoder_fxt Encoder_fsys_safe() {encoder = Url_encoder.new_fsys_wnt_(); return this;}
public void Test_encode_decode(String raw, String encoded) {
Test_encode(raw, encoded);
tst_decode(encoded, raw);
}
public void Test_encode(String raw, String expd) {
byte[] bry = encoder.Encode(Bry_.new_u8(raw));
Tfds.Eq(expd, String_.new_u8(bry));
}
public void tst_decode(String raw, String expd) {
byte[] bry = encoder.Decode(Bry_.new_u8(raw));
Tfds.Eq(expd, String_.new_u8(bry));
}
}

View File

@@ -26,7 +26,8 @@ public class Html_atr extends gplx.core.brys.Bfr_arg_base {
public byte[] Key() {return key;} private final byte[] key;
public int Val_bgn() {return val_bgn;} private final int val_bgn;
public int Val_end() {return val_end;} private final int val_end;
public boolean Val_exists() {return val_end > val_bgn;}
public boolean Val_dat_exists() {return val_end > val_bgn;}
public boolean Val_dat_missing() {return val_end == -1;}
public byte[] Val() {
if (val == null)
val = Bry_.Mid(src, val_bgn, val_end);
@@ -36,9 +37,9 @@ public class Html_atr extends gplx.core.brys.Bfr_arg_base {
if (val_end > val_bgn)
bfr.Add_mid(src, val_bgn, val_end);
}
@Override public boolean Bfr_arg__exists() {return this.Val_exists();}
@Override public boolean Bfr_arg__exists() {return this.Val_dat_exists();}
@Override public void Bfr_arg__add(Bry_bfr bfr) {
if (Val_exists())
if (Val_dat_exists())
bfr.Add_mid(src, val_bgn, val_end);
}
public static final Html_atr Noop = new Html_atr(-1, Bry_.Empty, Bry_.Empty, Bry_.Empty, -1, -1);

View File

@@ -42,8 +42,7 @@ public class Html_doc_parser {
Html_doc_wkr wkr = (Html_doc_wkr)o;
try {pos = wkr.Parse(src, src_bgn, src_end, pos);}
catch (Exception e) {
Err err = Err_.cast_or_make(e);
if (!err.Logged()) Gfo_usr_dlg_.Instance.Warn_many("", "", Err_.Message_gplx_log(e), "page_url", page_url, "mid", Bry_.Mid_by_len_safe(src, pos, 255));
Html_utl.Log(e, "html parse failed", page_url, src, pos);
txt_bgn = pos; // set txt_bgn to hook_bgn which is "pos"; i.e.: txt resumes from start of failed hook
pos = trie.Match_pos(); // set pos to hook_end
}

View File

@@ -20,15 +20,15 @@ import gplx.xowa.parsers.htmls.*; import gplx.langs.htmls.parsers.styles.*; impo
public class Html_tag implements Mwh_atr_wkr {
private Html_tag_rdr tag_rdr;
private Ordered_hash atrs_hash; private boolean atrs_null; private int atrs_bgn, atrs_end;
public Html_tag Init(Html_tag_rdr tag_rdr, boolean tag_is_tail, boolean tag_is_inline, int src_bgn, int src_end, int atrs_bgn, int atrs_end, int name_id) {
this.tag_rdr = tag_rdr; this.src = tag_rdr.Src(); this.atrs_null = true;
public Html_tag Init(Html_tag_rdr tag_rdr, byte[] src, boolean tag_is_tail, boolean tag_is_inline, int src_bgn, int src_end, int atrs_bgn, int atrs_end, int name_id) {
this.tag_rdr = tag_rdr; this.src = src; this.atrs_null = true;
this.tag_is_tail = tag_is_tail; this.tag_is_inline = tag_is_inline;
this.atrs_bgn = atrs_bgn; this.atrs_end = atrs_end;
this.name_id = name_id; this.src_bgn = src_bgn; this.src_end = src_end;
return this;
}
public Html_tag Copy() {
Html_tag rv = new Html_tag().Init(tag_rdr, tag_is_tail, tag_is_inline, src_bgn, src_end, atrs_bgn, atrs_end, name_id);
Html_tag rv = new Html_tag().Init(tag_rdr, src, tag_is_tail, tag_is_inline, src_bgn, src_end, atrs_bgn, atrs_end, name_id);
rv.atrs_null = false;
rv.atrs_hash = Copy(atrs_hash);
return rv;

View File

@@ -26,10 +26,10 @@ public class Html_tag_rdr {
public byte[] Src() {return src;} private byte[] src;
public int Src_end() {return src_end;} private int src_end;
public Bry_rdr Rdr() {return rdr;} private final Bry_rdr rdr = new Bry_rdr();
public void Init(byte[] src, int src_bgn, int src_end) {
public void Init(byte[] ctx, byte[] src, int src_bgn, int src_end) {
this.src = src; this.pos = src_bgn; this.src_end = src_end;
tag__eos.Init(this, Bool_.N, Bool_.N, src_end, src_end, src_end, src_end, Html_tag_.Id__eos);
rdr.Init_by_page(Bry_.Empty, src, src_end);
tag__eos.Init(this, src, Bool_.N, Bool_.N, src_end, src_end, src_end, src_end, Html_tag_.Id__eos);
rdr.Init_by_page(ctx, src, src_end);
}
public int Pos() {return pos;} private int pos;
public void Pos_(int v) {this.pos = v;}
@@ -169,7 +169,7 @@ public class Html_tag_rdr {
++tag_end; // position after ">"
}
Html_tag tmp = move ? tag__tmp__move : tag__tmp__peek;
return tmp.Init(this, cur_is_tail, inline, tag_bgn, tag_end, name_end, atrs_end, name_hash.Get_as_int_or(src, name_bgn, name_end, -1));
return tmp.Init(this, src, cur_is_tail, inline, tag_bgn, tag_end, name_end, atrs_end, name_hash.Get_as_int_or(src, name_bgn, name_end, -1));
}
public boolean Read_and_move(byte match) {
byte b = src[pos];
@@ -215,11 +215,11 @@ public class Html_tag_rdr {
}
private Html_tag Tag__comment(int tag_bgn) {
int tag_end = Bry_find_.Move_fwd(src, gplx.langs.htmls.Html_tag_.Comm_end, tag_bgn, src_end); if (tag_end == Bry_find_.Not_found) tag_end = src_end;
return tag__comment.Init(this, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__comment);
return tag__comment.Init(this, src, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__comment);
}
private Html_tag Tag__eos(int tag_bgn) {
int tag_end = tag_bgn + 255; if (tag_end > src_end) tag_end = src_end;
return tag__comment.Init(this, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__eos);
return tag__comment.Init(this, src, Bool_.N, Bool_.N, tag_bgn, tag_end, tag_end, tag_end, Html_tag_.Id__eos);
}
private static final byte[] Bry__comment__mid = Bry_.new_a7("--");
}

View File

@@ -50,7 +50,7 @@ class Html_tag_rdr_fxt {
private final Html_tag_rdr rdr = new Html_tag_rdr();
public void Init(String src_str) {
byte[] src_bry = Bry_.new_u8(src_str);
rdr.Init(src_bry, 0, src_bry.length);
rdr.Init(Bry_.Empty, src_bry, 0, src_bry.length);
}
public void Test__move_fwd_head(String expd) {Test__move_fwd_head(Html_tag_.Id__any, expd);}
public void Test__move_fwd_head(int match_name_id, String expd) {

View File

@@ -19,7 +19,7 @@ package gplx.langs.htmls.parsers.clses; import gplx.*; import gplx.langs.*; impo
public class Html_atr_class_parser_ {
public static void Parse(Html_tag tag, Html_atr_class_wkr wkr) {
Html_atr atr = tag.Atrs__get_by_or_empty(Html_atr_.Bry__class);
if (atr.Val_exists())
if (atr.Val_dat_exists())
Parse(tag.Src(), atr.Val_bgn(), atr.Val_end(), wkr);
}
public static void Parse(byte[] src, int src_bgn, int src_end, Html_atr_class_wkr wkr) {

View File

@@ -19,7 +19,7 @@ package gplx.langs.htmls.parsers.styles; import gplx.*; import gplx.langs.*; imp
public class Html_atr_style_parser_ {
public static void Parse(Html_tag tag, Html_atr_style_wkr wkr) {
Html_atr atr = tag.Atrs__get_by_or_empty(Html_atr_.Bry__style);
if (atr.Val_exists())
if (atr.Val_dat_exists())
Parse(tag.Src(), atr.Val_bgn(), atr.Val_end(), wkr);
}
public static void Parse(byte[] src, int src_bgn, int src_end, Html_atr_style_wkr wkr) {

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; import gplx.*;
import gplx.core.ios.*; import gplx.core.net.*;
import gplx.core.brys.*; import gplx.core.ios.*; import gplx.core.net.*;
import gplx.langs.jsons.*; import gplx.langs.htmls.encoders.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.metas.*; import gplx.xowa.apps.apis.*;
import gplx.xowa.apps.gfs.*;
@@ -51,7 +51,6 @@ public interface Xoa_app extends GfoInvkAble {
boolean Bldr__running(); void Bldr__running_(boolean v);
Gfo_usr_dlg Usr_dlg();
Bry_bfr_mkr Utl__bfr_mkr();
Url_encoder_mgr Utl__encoder_mgr();
Json_parser Utl__json_parser();
Gfo_inet_conn Utl__inet_conn();
Xoa_meta_mgr Meta_mgr();

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; import gplx.*;
import gplx.core.ios.*; import gplx.core.log_msgs.*;
import gplx.core.brys.*; import gplx.core.ios.*; import gplx.core.log_msgs.*;
import gplx.langs.htmls.encoders.*;
import gplx.xowa.guis.views.boots.*;
import gplx.xowa.apps.boots.*; import gplx.xowa.apps.gfs.*;
@@ -34,14 +34,13 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
public static final String Version = "2.11.3.1";
public static final String Version = "2.11.4.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";
public static final Gfo_msg_grp Nde = Gfo_msg_grp_.prj_(Name);
public static Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public static void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v;} private static Gfo_usr_dlg usr_dlg;
public static Bry_bfr_mkr Utl__bfr_mkr() {return utl__bry_bfr_mkr;} private static final Bry_bfr_mkr utl__bry_bfr_mkr = new Bry_bfr_mkr();
public static Url_encoder_mgr Utl__encoder_mgr() {return utl__encoder_mgr;} private static final Url_encoder_mgr utl__encoder_mgr = new Url_encoder_mgr();
public static Io_stream_zip_mgr Utl__zip_mgr() {return utl__zip_mgr;} private static final Io_stream_zip_mgr utl__zip_mgr = new Io_stream_zip_mgr();
public static Xoa_gfs_mgr Gfs_mgr() {return gfs_mgr;} public static void Gfs_mgr_(Xoa_gfs_mgr v) {gfs_mgr = v;} private static Xoa_gfs_mgr gfs_mgr;
public static Gfo_usr_dlg usr_dlg_console_() {

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.core.envs.*;
import gplx.langs.gfs.*;
import gplx.dbs.*;
import gplx.xowa.bldrs.*;

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; import gplx.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*; import gplx.core.log_msgs.*;
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.langs.cases.*; import gplx.core.log_msgs.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.wikis.ttls.*;
import gplx.xowa.apps.urls.*;
@@ -54,7 +54,8 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
public byte[] Subj_txt() {return ns.Id_is_subj() ? Full_txt() : Bry_.Add(tors_txt, Page_txt());}
public byte[] Full_url() {return Xoa_url_encoder.Instance.Encode(full_txt);}
public String Full_db_as_str() {return String_.new_u8(Full_db());}
public byte[] Full_db() {return ns.Gen_ttl(this.Page_db());}
public byte[] Full_db() {return ns.Gen_ttl(this.Page_db());}
public byte[] Full_db_w_anch() {return Replace_spaces(full_txt);}
public byte[] Page_url() {return Xoa_url_encoder.Instance.Encode(this.Page_txt());}
public byte[] Leaf_url() {return Xoa_url_encoder.Instance.Encode(this.Leaf_txt());}
public byte[] Base_url() {return Xoa_url_encoder.Instance.Encode(this.Base_txt());}
@@ -135,7 +136,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
- forbid ~~~
- handle ip address urls for User and User talk
*/
Url_encoder anchor_encoder = null;
Gfo_url_encoder anchor_encoder = null;
Bry_bfr anchor_encoder_bfr = null;
bfr.Clear();
if (end - bgn == 0) {msg_log.Add_itm_none(Xop_ttl_log.Len_0, src, bgn, bgn); return false;}
@@ -278,7 +279,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
}
if (anch_bgn != -1) {
if (anchor_encoder == null) {
anchor_encoder = Url_encoder.new_html_id_();
anchor_encoder = Gfo_url_encoder_.Id;
anchor_encoder_bfr = Bry_bfr.reset_(32);
}
anchor_encoder.Encode(anchor_encoder_bfr, src, cur, cur + 1);
@@ -291,7 +292,7 @@ public class Xoa_ttl { // PAGE:en.w:http://en.wikipedia.org/wiki/Help:Link; REF.
case Byte_ascii.Brack_bgn: case Byte_ascii.Brack_end: case Byte_ascii.Curly_bgn: case Byte_ascii.Curly_end:
if (anch_bgn != -1) {
if (anchor_encoder == null) {
anchor_encoder = Url_encoder.new_html_id_();
anchor_encoder = Gfo_url_encoder_.Id;
anchor_encoder_bfr = Bry_bfr.reset_(32);
}
anchor_encoder.Encode(anchor_encoder_bfr, src, cur, cur + 1);

View File

@@ -100,7 +100,7 @@ public class Xoa_url {
if (show_qargs || qargs_ary.length > 0) {
Bry_bfr bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
bfr.Add(rv);
Gfo_qarg_mgr.Concat_bfr(bfr, Xoa_app_.Utl__encoder_mgr().Href(), qargs_ary);
Gfo_qarg_mgr.Concat_bfr(bfr, gplx.langs.htmls.encoders.Gfo_url_encoder_.Href, qargs_ary);
return bfr.To_bry_and_rls();
}
else

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; import gplx.*;
import gplx.core.btries.*; import gplx.core.brys.fmtrs.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*;
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.brys.fmtrs.*; import gplx.core.flds.*; import gplx.core.ios.*; import gplx.core.threads.*; import gplx.langs.jsons.*; import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.log_msgs.*; import gplx.core.envs.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.metas.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.progs.*; import gplx.xowa.apps.gfs.*;
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.*;
@@ -32,7 +32,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xoae_app(Gfo_usr_dlg usr_dlg, Xoa_app_mode mode, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url user_dir, Io_url css_dir, String bin_dir_name) {
Xoa_app_.Usr_dlg_(usr_dlg);
this.mode = mode;
Io_url.Http_file_str_encoder = Xoa_app_.Utl__encoder_mgr().Fsys();
Io_url.Http_file_str_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys;
fsys_mgr = new Xoa_fsys_mgr(bin_dir_name, root_dir, wiki_dir, file_dir, css_dir);
log_wtr = usr_dlg.Log_wkr();
cfg_mgr = new Xoa_cfg_mgr(this);
@@ -79,7 +79,6 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xoh_bridge_mgr Html__bridge_mgr() {return html__bridge_mgr;} private final Xoh_bridge_mgr html__bridge_mgr;
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
public Url_encoder_mgr Utl__encoder_mgr() {return Xoa_app_.Utl__encoder_mgr();}
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
public Gfo_inet_conn Utl__inet_conn() {return inet_conn;} private final Gfo_inet_conn inet_conn = Gfo_inet_conn_.new_();
public Xoa_meta_mgr Meta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;

View File

@@ -25,7 +25,7 @@ public class Xoae_page implements Xoa_page {
Xoae_page(Xowe_wiki wiki, Xoa_ttl ttl) {
this.wiki = wiki; this.ttl = ttl;
this.lang = wiki.Lang(); // default to wiki.lang; can be override later by wikitext
hdr_mgr = new Xow_hdr_mgr(this, Xoa_app_.Utl__encoder_mgr());
hdr_mgr = new Xow_hdr_mgr(this);
redlink_lnki_list = new Xopg_redlink_lnki_list(ttl.Ns().Id_is_module());
Ttl_(ttl);
} Xoae_page() {} // called by Null

View File

@@ -366,6 +366,10 @@ public class Xop_fxt {
public void Test_html_wiki_frag(String raw, String... expd_frags) {Test_str_part_y(Exec_html_wiki(raw), expd_frags);}
public void Test_html_full_frag(String raw, String... expd_frags) {Test_str_part_y(Exec_html_full(raw), expd_frags);}
public void Test_html_full_frag_n(String raw, String... expd_frags) {Test_str_part_n(Exec_html_full(raw), expd_frags);}
public void Test__parse__wtxt_to_html(String raw, String expd) {
String actl = Exec_html_wiki(raw);
Tfds.Eq_str_lines(gplx.langs.htmls.Html_utl.Replace_apos(expd), actl, raw);
}
public void Test_str_full(String raw, String expd, String actl) {Tfds.Eq_str_lines(expd, actl, raw);}
private void Test_str_part_y(String actl, String... expd_parts) {

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; import gplx.*;
import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.apps.cfgs.gui.*; import gplx.xowa.apps.urls.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.caches.*;

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.core.net.*; import gplx.core.log_msgs.*; import gplx.langs.jsons.*;
import gplx.core.net.*; import gplx.core.log_msgs.*; import gplx.langs.jsons.*; import gplx.core.brys.*;
import gplx.core.ios.*;
import gplx.dbs.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.core.intls.*; import gplx.xowa.users.data.*;
import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.urls.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
@@ -72,13 +72,12 @@ public class Xoav_app implements Xoa_app, GfoInvkAble {
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; Xoa_app_.Usr_dlg_(usr_dlg);} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Noop;
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
public Url_encoder_mgr Utl__encoder_mgr() {return Xoa_app_.Utl__encoder_mgr();}
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = Xop_amp_mgr.Instance;
public Xol_case_mgr Utl_case_mgr() {return utl_case_mgr;} private Xol_case_mgr utl_case_mgr = Xol_case_mgr_.U8();
public Url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Url_encoder utl_encoder_fsys = Url_encoder.new_fsys_lnx_();
// public Gfo_url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Gfo_url_encoder utl_encoder_fsys = Gfo_url_encoder.New_fsys_lnx();
public Gfo_msg_log Utl_msg_log() {return utl_msg_log;} private Gfo_msg_log utl_msg_log;
public Xoav_url_parser Utl_url_parser_xo() {return utl_url_parser_xo;} private Xoav_url_parser utl_url_parser_xo = new Xoav_url_parser();
public Gfo_url_parser Utl_url_parser_gfo() {return utl_url_parser_gfo;} private final Gfo_url_parser utl_url_parser_gfo = new Gfo_url_parser();

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.apps; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.core.envs.*;
public class Xoapi_fsys implements GfoInvkAble {
public void Ctor_by_app(Xoae_app app) {
this.plat_jar = Env_.AppUrl();

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.gui.browsers; 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.gui.*;
import gplx.gfui.*; import gplx.xowa.guis.views.*;
import gplx.gfui.*; import gplx.xowa.guis.views.*; import gplx.core.envs.*;
public class Xoapi_url implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private GfuiTextBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.gui.pages; 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.gui.*;
import gplx.gfui.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
import gplx.gfui.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.core.envs.*;
public class Xoapi_selection implements GfoInvkAble {
private Xoae_app app; private Xog_win_itm win;
public void Init_by_kit(Xoae_app app) {

View File

@@ -36,7 +36,7 @@ public class Xoapi_view implements GfoInvkAble {
public void Save_as() {
if (this.Active_tab_is_null()) return;
Xog_tab_itm tab = win.Tab_mgr().Active_tab();
String file_name = Xoa_app_.Utl__encoder_mgr().Fsys_safe().Encode_str(String_.new_u8(tab.Page().Ttl().Full_url())) + ".html";
String file_name = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_safe.Encode_str(String_.new_u8(tab.Page().Ttl().Full_url())) + ".html";
String file_url = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(file_name).Ask();
if (String_.Len_eq_0(file_url)) return;
Io_mgr.Instance.SaveFilStr(file_url, tab.Html_box().Text());

View File

@@ -21,10 +21,13 @@ public class Xoapi_page implements GfoInvkAble {
public void Ctor_by_app(Xoae_app app) {
toggle_mgr.Ctor_by_app(app);
}
public boolean View_html_generates_hdump() {return view_html_generates_hdump;} private boolean view_html_generates_hdump = false;
public Xoapi_toggle_mgr Toggle_mgr() {return toggle_mgr;} private final Xoapi_toggle_mgr toggle_mgr = new Xoapi_toggle_mgr();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_toggles)) return toggle_mgr;
if (ctx.Match(k, Invk_toggles)) return toggle_mgr;
else if (ctx.Match(k, Invk_view_html_generates_hdump_)) view_html_generates_hdump = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_toggles = "toggles";
private static final String Invk_toggles = "toggles", Invk_view_html_generates_hdump_ = "view_html_generates_hdump_";
}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.core.consoles.*;
import gplx.core.consoles.*; import gplx.core.envs.*;
import gplx.dbs.*;
import gplx.gfui.*; import gplx.xowa.guis.views.boots.*;
import gplx.xowa.langs.*;

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.core.consoles.*;
import gplx.core.consoles.*; import gplx.core.envs.*;
import gplx.xowa.apps.*;
public class Xoa_cmd_arg_mgr {
Xoa_cmd_arg_mgr(Gfo_cmd_arg_mgr arg_mgr) {this.arg_mgr = arg_mgr;}

View File

@@ -42,7 +42,7 @@ public class Xocfg_bnd_mgr implements GfoInvkAble, Gfo_sort_able {
private Xocfg_bnd_itm_srl Init(String key) {return new Xocfg_bnd_itm_srl(app, key);}
public Xocfg_bnd_itm Get_at(int i) {return (Xocfg_bnd_itm)regy.Get_at(i);}
public int Len() {return regy.Count();}
public void Sort(gplx.lists.ComparerAble comparer) {regy.Sort_by(comparer);}
public void Sort(gplx.core.lists.ComparerAble comparer) {regy.Sort_by(comparer);}
private void Set_bulk(byte[] src) {
try {
bnd_mgr_srl.Load_by_bry(src);

View File

@@ -17,5 +17,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public interface Gfo_sort_able {
void Sort(gplx.lists.ComparerAble comparer);
void Sort(gplx.core.lists.ComparerAble comparer);
}

View File

@@ -47,7 +47,7 @@ class Xoa_fmtr_sort_itm {
public int Comp_mult() {return comp_mult;} private int comp_mult;
public String Key() {return key;} private String key;
}
class Xoa_fmtr_sort_wkr implements gplx.lists.ComparerAble {
class Xoa_fmtr_sort_wkr implements gplx.core.lists.ComparerAble {
public Xoa_fmtr_sort_itm[] Itms() {return itms;} public void Itms_(Xoa_fmtr_sort_itm[] v) {itms = v; itms_len = v.length;} private Xoa_fmtr_sort_itm[] itms; private int itms_len;
public int compare(Object lhsObj, Object rhsObj) {
GfoInvkAble lhs_invk = (GfoInvkAble)lhsObj;

View File

@@ -16,52 +16,52 @@ 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.progs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.apps.fsys.*; import gplx.xowa.files.*;
import gplx.xowa.apps.fsys.*; import gplx.xowa.files.*; import gplx.core.envs.*;
public class Xoa_prog_mgr implements GfoInvkAble {
public void Init_by_app(Xoa_fsys_eval cmd_eval) {
Gfo_usr_dlg usr_dlg = Xoa_app_.Usr_dlg();
ProcessAdp.ini_(this, usr_dlg, app_query_img_size , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\identify", "-ping -format \"<{%w,%h}>\" \"~{file}\"", "file");
ProcessAdp.ini_(this, usr_dlg, app_resize_img , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "\"~{source}\" -coalesce -resize ~{width}x~{height} \"~{target}\"", "source", "target", "width", "height");
ProcessAdp.ini_(this, usr_dlg, app_convert_svg_to_png , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}inkscape\\inkscape", "-z -w ~{width} -f \"~{source}\" -e \"~{target}\"", "source", "target", "width").Thread_kill_name_("inkscape.exe"); // // -z=without-gui; -w=width; -f=file -e=export-png
ProcessAdp.ini_(this, usr_dlg, app_convert_tex_to_dvi , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\latex", "-quiet -output-directory=~{temp_dir} -job-name=xowa_temp ~{tex_file}", "tex_file", "temp_dir");
ProcessAdp.ini_(this, usr_dlg, app_convert_dvi_to_png , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\dvipng", "~{dvi_file} -o ~{png_file} -q* -T tight -bg Transparent", "dvi_file", "png_file", "temp_dir");
ProcessAdp.ini_(this, usr_dlg, app_convert_djvu_to_tiff , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}djvulibre\\ddjvu", "-format=tiff -page=1 \"~{source}\" \"~{target}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_decompress_bz2 , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, usr_dlg, app_decompress_bz2_by_stdout , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -so \"~{src}\"", "src"); // x=extract; -so=stdout
ProcessAdp.ini_(this, usr_dlg, app_decompress_zip , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, usr_dlg, app_decompress_gz , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
ProcessAdp.ini_(this, usr_dlg, app_lua , cmd_eval, ProcessAdp.Run_mode_async , 0 , "~{<>bin_plat_dir<>}lua\\lua", "", "");
ProcessAdp.ini_(this, usr_dlg, app_lilypond , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\lilypond.exe", "\"-dsafe=#t\" -dbackend=ps --png --header=texidoc -dmidi-extension=midi \"~{file}\"", "file");
ProcessAdp.ini_(this, usr_dlg, app_abc2ly , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\python.exe", "abc2ly.py -s \"--output=~{target}\" \"~{source}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_trim_img , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "-trim \"~{source}\" \"~{target}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_convert_midi_to_ogg , cmd_eval, ProcessAdp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}timidity\\timidity", "-Ov \"--output-file=~{target}\" \"~{source}\"", "source", "target");
ProcessAdp.ini_(this, usr_dlg, app_view_web , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
ProcessAdp.ini_(this, usr_dlg, app_view_text , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
Process_adp.ini_(this, usr_dlg, app_query_img_size , cmd_eval, Process_adp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\identify", "-ping -format \"<{%w,%h}>\" \"~{file}\"", "file");
Process_adp.ini_(this, usr_dlg, app_resize_img , cmd_eval, Process_adp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "\"~{source}\" -coalesce -resize ~{width}x~{height} \"~{target}\"", "source", "target", "width", "height");
Process_adp.ini_(this, usr_dlg, app_convert_svg_to_png , cmd_eval, Process_adp.Run_mode_sync_timeout , 10 * 60, "~{<>bin_plat_dir<>}inkscape\\inkscape", "-z -w ~{width} -f \"~{source}\" -e \"~{target}\"", "source", "target", "width").Thread_kill_name_("inkscape.exe"); // // -z=without-gui; -w=width; -f=file -e=export-png
Process_adp.ini_(this, usr_dlg, app_convert_tex_to_dvi , cmd_eval, Process_adp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\latex", "-quiet -output-directory=~{temp_dir} -job-name=xowa_temp ~{tex_file}", "tex_file", "temp_dir");
Process_adp.ini_(this, usr_dlg, app_convert_dvi_to_png , cmd_eval, Process_adp.Run_mode_sync_timeout , 2 * 60, "~{<>bin_plat_dir<>}miktex\\miktex\\bin\\dvipng", "~{dvi_file} -o ~{png_file} -q* -T tight -bg Transparent", "dvi_file", "png_file", "temp_dir");
Process_adp.ini_(this, usr_dlg, app_convert_djvu_to_tiff , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}djvulibre\\ddjvu", "-format=tiff -page=1 \"~{source}\" \"~{target}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_decompress_bz2 , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
Process_adp.ini_(this, usr_dlg, app_decompress_bz2_by_stdout , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -so \"~{src}\"", "src"); // x=extract; -so=stdout
Process_adp.ini_(this, usr_dlg, app_decompress_zip , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
Process_adp.ini_(this, usr_dlg, app_decompress_gz , cmd_eval, Process_adp.Run_mode_sync_timeout , 0 , "~{<>bin_plat_dir<>}7-zip\\7za", "x -y \"~{src}\" -o\"~{trg_dir}\"", "src", "trg", "trg_dir"); // x=extract; -y=yes on all queries; -o=output_dir
Process_adp.ini_(this, usr_dlg, app_lua , cmd_eval, Process_adp.Run_mode_async , 0 , "~{<>bin_plat_dir<>}lua\\lua", "", "");
Process_adp.ini_(this, usr_dlg, app_lilypond , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\lilypond.exe", "\"-dsafe=#t\" -dbackend=ps --png --header=texidoc -dmidi-extension=midi \"~{file}\"", "file");
Process_adp.ini_(this, usr_dlg, app_abc2ly , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}lilypond\\usr\\bin\\python.exe", "abc2ly.py -s \"--output=~{target}\" \"~{source}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_trim_img , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}imagemagick\\convert", "-trim \"~{source}\" \"~{target}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_convert_midi_to_ogg , cmd_eval, Process_adp.Run_mode_sync_timeout , 1 * 60, "~{<>bin_plat_dir<>}timidity\\timidity", "-Ov \"--output-file=~{target}\" \"~{source}\"", "source", "target");
Process_adp.ini_(this, usr_dlg, app_view_web , cmd_eval, Process_adp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
Process_adp.ini_(this, usr_dlg, app_view_text , cmd_eval, Process_adp.Run_mode_async , 0 , "cmd", "/c start \"~{url}\"", "url");
int cmds_view_file_by_ext_len = cmds_view_file_by_ext.length;
for (int i= 0; i < cmds_view_file_by_ext_len; i++) {
ProcessAdp cmd = new ProcessAdp();
Process_adp cmd = new Process_adp();
cmds_view_file_by_ext [i] = cmd;
ProcessAdp.ini_(this, usr_dlg, cmd , cmd_eval, ProcessAdp.Run_mode_async , 0 , "cmd", "/c start \"~{file}\"", "file");
Process_adp.ini_(this, usr_dlg, cmd , cmd_eval, Process_adp.Run_mode_async , 0 , "cmd", "/c start \"~{file}\"", "file");
}
}
public ProcessAdp App_query_img_size() {return app_query_img_size;} private ProcessAdp app_query_img_size = new ProcessAdp();
public ProcessAdp App_resize_img() {return app_resize_img;} private ProcessAdp app_resize_img = new ProcessAdp();
public ProcessAdp App_convert_svg_to_png() {return app_convert_svg_to_png;} private ProcessAdp app_convert_svg_to_png = new ProcessAdp();
public ProcessAdp App_convert_tex_to_dvi() {return app_convert_tex_to_dvi;} private ProcessAdp app_convert_tex_to_dvi = new ProcessAdp();
public ProcessAdp App_convert_dvi_to_png() {return app_convert_dvi_to_png;} private ProcessAdp app_convert_dvi_to_png = new ProcessAdp();
public ProcessAdp App_convert_djvu_to_tiff() {return app_convert_djvu_to_tiff;} private ProcessAdp app_convert_djvu_to_tiff = new ProcessAdp();
public ProcessAdp App_view_web() {return app_view_web;} private ProcessAdp app_view_web = new ProcessAdp();
public ProcessAdp App_view_text() {return app_view_text;} private ProcessAdp app_view_text = new ProcessAdp();
public ProcessAdp App_decompress_bz2() {return app_decompress_bz2;} private ProcessAdp app_decompress_bz2 = new ProcessAdp();
public ProcessAdp App_decompress_zip() {return app_decompress_zip;} private ProcessAdp app_decompress_zip = new ProcessAdp();
public ProcessAdp App_decompress_gz() {return app_decompress_gz;} private ProcessAdp app_decompress_gz = new ProcessAdp();
public ProcessAdp App_decompress_bz2_by_stdout() {return app_decompress_bz2_by_stdout;} private ProcessAdp app_decompress_bz2_by_stdout = new ProcessAdp();
public ProcessAdp App_lua() {return app_lua;} private ProcessAdp app_lua = new ProcessAdp();
public ProcessAdp App_lilypond() {return app_lilypond;} private ProcessAdp app_lilypond = new ProcessAdp();
public ProcessAdp App_abc2ly() {return app_abc2ly;} private ProcessAdp app_abc2ly = new ProcessAdp();
public ProcessAdp App_trim_img() {return app_trim_img;} private ProcessAdp app_trim_img = new ProcessAdp();
public ProcessAdp App_convert_midi_to_ogg() {return app_convert_midi_to_ogg;} private ProcessAdp app_convert_midi_to_ogg = new ProcessAdp();
public ProcessAdp App_by_ext(String ext) {return App_by_ext_key(String_.Mid(ext, 1));} // ignore 1st . in ext; EX: ".png" -> "png"
public Process_adp App_query_img_size() {return app_query_img_size;} private Process_adp app_query_img_size = new Process_adp();
public Process_adp App_resize_img() {return app_resize_img;} private Process_adp app_resize_img = new Process_adp();
public Process_adp App_convert_svg_to_png() {return app_convert_svg_to_png;} private Process_adp app_convert_svg_to_png = new Process_adp();
public Process_adp App_convert_tex_to_dvi() {return app_convert_tex_to_dvi;} private Process_adp app_convert_tex_to_dvi = new Process_adp();
public Process_adp App_convert_dvi_to_png() {return app_convert_dvi_to_png;} private Process_adp app_convert_dvi_to_png = new Process_adp();
public Process_adp App_convert_djvu_to_tiff() {return app_convert_djvu_to_tiff;} private Process_adp app_convert_djvu_to_tiff = new Process_adp();
public Process_adp App_view_web() {return app_view_web;} private Process_adp app_view_web = new Process_adp();
public Process_adp App_view_text() {return app_view_text;} private Process_adp app_view_text = new Process_adp();
public Process_adp App_decompress_bz2() {return app_decompress_bz2;} private Process_adp app_decompress_bz2 = new Process_adp();
public Process_adp App_decompress_zip() {return app_decompress_zip;} private Process_adp app_decompress_zip = new Process_adp();
public Process_adp App_decompress_gz() {return app_decompress_gz;} private Process_adp app_decompress_gz = new Process_adp();
public Process_adp App_decompress_bz2_by_stdout() {return app_decompress_bz2_by_stdout;} private Process_adp app_decompress_bz2_by_stdout = new Process_adp();
public Process_adp App_lua() {return app_lua;} private Process_adp app_lua = new Process_adp();
public Process_adp App_lilypond() {return app_lilypond;} private Process_adp app_lilypond = new Process_adp();
public Process_adp App_abc2ly() {return app_abc2ly;} private Process_adp app_abc2ly = new Process_adp();
public Process_adp App_trim_img() {return app_trim_img;} private Process_adp app_trim_img = new Process_adp();
public Process_adp App_convert_midi_to_ogg() {return app_convert_midi_to_ogg;} private Process_adp app_convert_midi_to_ogg = new Process_adp();
public Process_adp App_by_ext(String ext) {return App_by_ext_key(String_.Mid(ext, 1));} // ignore 1st . in ext; EX: ".png" -> "png"
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_query_img_size)) return app_query_img_size;
else if (ctx.Match(k, Invk_resize_img)) return app_resize_img;
@@ -93,18 +93,18 @@ public class Xoa_prog_mgr implements GfoInvkAble {
public void Exec_view_web(byte[] url) {
url = Bry_.Replace(url, Quote_normal, Quote_escape); // escape quotes; DATE:2013-03-31
String url_str = String_.new_u8(url);
url_str = ProcessAdp.Escape_ampersands_if_process_is_cmd(Op_sys.Cur().Tid_is_wnt(), app_view_web.Exe_url().Raw(), url_str); // escape ampersands; DATE:2014-05-20
url_str = Process_adp.Escape_ampersands_if_process_is_cmd(Op_sys.Cur().Tid_is_wnt(), app_view_web.Exe_url().Raw(), url_str); // escape ampersands; DATE:2014-05-20
app_view_web.Run(url_str);
} private static final byte[] Quote_normal = new byte[] {Byte_ascii.Quote}, Quote_escape = new byte[] {Byte_ascii.Quote, Byte_ascii.Quote};
private ProcessAdp App_by_ext_key(String ext) {return cmds_view_file_by_ext[Xof_ext_.Get_id_by_ext_(Bry_.new_a7(ext))];}
private Process_adp App_by_ext_key(String ext) {return cmds_view_file_by_ext[Xof_ext_.Get_id_by_ext_(Bry_.new_a7(ext))];}
public void Exec_view_by_ext(String exts_raw, String cmd, String args) {
String[] exts_ary = String_.Split(exts_raw, '|');
int exts_ary_len = exts_ary.length;
for (int i = 0; i < exts_ary_len; i++)
App_by_ext_key(exts_ary[i]).Cmd_args(cmd, args);
} ProcessAdp[] cmds_view_file_by_ext = new ProcessAdp[Xof_ext_.Id__max];
private ProcessAdp Init_by_exts(String... exts) {
ProcessAdp rv = App_by_ext_key(exts[0]);
} Process_adp[] cmds_view_file_by_ext = new Process_adp[Xof_ext_.Id__max];
private Process_adp Init_by_exts(String... exts) {
Process_adp rv = App_by_ext_key(exts[0]);
int len = exts.length;
for (int i = 0; i < len; i++) {
cmds_view_file_by_ext[Xof_ext_.Get_id_by_ext_(Bry_.new_a7(exts[i]))] = rv;

View File

@@ -33,7 +33,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import gplx.core.threads.*; import gplx.core.net.*; import gplx.core.primitives.*; import gplx.langs.jsons.*; import gplx.langs.htmls.encoders.*;
import gplx.core.threads.*; import gplx.core.net.*; import gplx.core.primitives.*; import gplx.core.envs.*;
import gplx.langs.jsons.*; import gplx.langs.htmls.encoders.*;
import gplx.xowa.wikis.pages.*;
public class Http_server_mgr implements GfoInvkAble {
private final Object thread_lock = new Object();
@@ -49,7 +50,7 @@ public class Http_server_mgr implements GfoInvkAble {
public Xoae_app App() {return app;} private final Xoae_app app;
public Http_server_wtr Server_wtr() {return server_wtr;} private final Http_server_wtr server_wtr = Http_server_wtr_.new_console();
public Http_request_parser Request_parser() {return request_parser;} private final Http_request_parser request_parser;
public Url_encoder Encoder() {return encoder;} private final Url_encoder encoder = Url_encoder.new_http_url_();
public Gfo_url_encoder Encoder() {return encoder;} private final Gfo_url_encoder encoder = Gfo_url_encoder_.New__http_url().Make();
public int Port() {return port;} public Http_server_mgr Port_(int v) {port = v; return this;} private int port = 8080;
public Http_server_wkr_pool Wkr_pool() {return wkr_pool;} private final Http_server_wkr_pool wkr_pool = new Http_server_wkr_pool();
public Int_pool Uid_pool() {return uid_pool;} private final Int_pool uid_pool = new Int_pool();
@@ -84,7 +85,7 @@ public class Http_server_mgr implements GfoInvkAble {
Note("HTTP Server started: Navigate to http://localhost:" + Int_.To_str(port));
}
public void Run_xowa_cmd(Xoae_app app, String url_encoded_str) {
Url_encoder url_converter = Url_encoder.new_http_url_(); // create instance for each call
Gfo_url_encoder url_converter = Gfo_url_encoder_.New__http_url().Make(); // create instance for each call
String cmd = url_converter.Decode_str(url_encoded_str);
app.Gfs_mgr().Run_str(cmd);
}

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import gplx.core.envs.Op_sys;
import gplx.core.net.*; import gplx.core.threads.*; import gplx.langs.htmls.encoders.*;
import java.io.*;
import java.net.*;
@@ -72,7 +73,7 @@ class Http_server_wkr_v1 implements Runnable{
else if(req.contains("%file%")){
String path = req.replace("/%file%/", app_root_dir); err_line = "19";
path = path.substring(path.indexOf(app_root_dir)+5); err_line = "20";
Url_encoder url_converter = Url_encoder.new_http_url_(); err_line = "21";
Gfo_url_encoder url_converter = Gfo_url_encoder_.Http_url; err_line = "21";
path = url_converter.Decode_str(path); err_line = "22";
if(path.contains("?")){
path = path.substring(0, path.indexOf("?")); err_line = "23";
@@ -100,7 +101,7 @@ class Http_server_wkr_v1 implements Runnable{
for(int i = 4; i <= req_split.length-1; i++){
page_name += "/"+req_split[i]; err_line = "36";
}
Url_encoder url_converter = Url_encoder.new_http_url_(); err_line = "37";
Gfo_url_encoder url_converter = Gfo_url_encoder_.Http_url; err_line = "37";
page_name = url_converter.Decode_str(page_name); err_line = "38";
//page_name = app.Url_converter_url().Decode_str(page_name);
}

View File

@@ -27,7 +27,7 @@ class Http_server_wkr_v2 implements GfoInvkAble {
private final Http_client_wtr client_wtr = Http_client_wtr_.new_stream();
private final Http_client_rdr client_rdr = Http_client_rdr_.new_stream();
private final Http_request_parser request_parser;
private final Url_encoder url_encoder;
private final Gfo_url_encoder url_encoder;
private final Xoae_app app;
private final String root_dir_http;
private final byte[] root_dir_fsys;
@@ -82,7 +82,7 @@ class Http_server_wkr_v2 implements GfoInvkAble {
int question_pos = Bry_find_.Find_fwd(url, Byte_ascii.Question);
int url_bgn = Bry_.Has_at_bgn(url, Url__fsys) ? Url__fsys_len : 0; // most files will have "/fsys/" at start, but Mathjax will not
int url_end = question_pos == Bry_find_.Not_found ? url.length : question_pos; // ignore files with query params; EX: /file/A.png?key=val
url_encoder.Decode(url, url_bgn, url_end, tmp_bfr, false); // decode url to actual chars; note that XOWA stores on fsys in UTF-8 chars; "<22>" not "%C3"
url_encoder.Decode(tmp_bfr, Bool_.N, url, url_bgn, url_end); // decode url to actual chars; note that XOWA stores on fsys in UTF-8 chars; "<22>" not "%C3"
byte[] path = tmp_bfr.To_bry_and_clear();
client_wtr.Write_bry(Xosrv_http_wkr_.Rsp__http_ok);
// client_wtr.Write_str("Expires: Sun, 17-Jan-2038 19:14:07 GMT\n");

View File

@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.servers.tcp; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
import gplx.core.primitives.*; import gplx.core.ios.*; import gplx.langs.jsons.*; import gplx.core.threads.*;
import gplx.core.primitives.*; import gplx.core.ios.*; import gplx.core.envs.*; import gplx.core.threads.*;
import gplx.langs.jsons.*;
public class Xosrv_server implements GfoInvkAble {
private long last_cmd;
public Xosrv_socket_rdr Rdr() {return rdr;} private Xosrv_socket_rdr rdr = new Xosrv_socket_rdr();

View File

@@ -22,7 +22,7 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.vnts.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.files.*;
public class Xoa_url_parser {
private final Url_encoder encoder;
private final Gfo_url_encoder encoder;
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
private final Gfo_url_parser url_parser = new Gfo_url_parser(); private final Gfo_url gfo_url = new Gfo_url();
private final Xoa_app app; private final Xow_wiki wiki; private final byte[] domain_bry;
@@ -36,7 +36,7 @@ public class Xoa_url_parser {
public Xoa_url_parser(Xow_wiki wiki) {
this.app = wiki.App();
this.wiki = wiki; this.domain_bry = wiki.Domain_bry();
this.encoder = app.Utl__encoder_mgr().Xourl();
this.encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Xourl;
this.vnt_mgr = wiki.Type_is_edit() ? wiki.Lang().Vnt_mgr() : null;
}
public Xoa_url Parse_by_urlbar_or_null(String str) {
@@ -101,7 +101,7 @@ public class Xoa_url_parser {
Bld_qargs();
if (tmp_page_is_main) tmp_page = Xoa_page_.Main_page_bry_empty;
if (tmp_anch != null) {
byte[] anchor_bry = Xoa_app_.Utl__encoder_mgr().Id().Encode(tmp_anch); // reencode for anchors (which use . encoding, not % encoding); PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
byte[] anchor_bry = gplx.langs.htmls.encoders.Gfo_url_encoder_.Id.Encode(tmp_anch); // reencode for anchors (which use . encoding, not % encoding); PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
tmp_anch = anchor_bry;
}
Make(rv);
@@ -138,7 +138,7 @@ public class Xoa_url_parser {
private void Bld_xowa() {
tmp_tid = Xoa_url_.Tid_xcmd;
tmp_page = Bry_.Mid(tmp_raw, Gfo_protocol_itm.Len_xcmd); // NOTE: just get String after protocol; anchor (#) or query params (?) must not be parsed
tmp_page = Xoa_app_.Utl__encoder_mgr().Gfs().Decode(tmp_page); // NOTE: should be decoded; EX: %20 -> " "
tmp_page = gplx.langs.htmls.encoders.Gfo_url_encoder_.Gfs.Decode(tmp_page); // NOTE: should be decoded; EX: %20 -> " "
}
private void Bld_page_by_file_ns() {
tmp_tid = Xoa_url_.Tid_page;

View File

@@ -96,7 +96,7 @@ public class Db_mgr_fxt {
int len = grp.Itms_list().Count();
for (int i = 0; i < len; i++) {
Xoctg_view_itm itm = (Xoctg_view_itm)grp.Itms_list().Get_at(i);
list.Add(itm.Id());
list.Add(itm.Page_id());
}
}
return (int[])list.To_ary_and_clear(int.class);

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.core.consoles.*;
import gplx.core.consoles.*; import gplx.core.envs.*;
import gplx.xowa.apps.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.xmls.*; import gplx.xowa.bldrs.cfgs.*; import gplx.xowa.langs.bldrs.*;
public class Xob_bldr implements GfoInvkAble {
private boolean pause_at_end = false; private long prv_prog_time; private Xob_xml_parser dump_parser;

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.core.ios.*; import gplx.lists.*;
import gplx.core.ios.*; import gplx.core.lists.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.bldrs.wtrs.*;
public class Xobdc_merger {

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs; import gplx.*; import gplx.xowa.*;
import gplx.core.ios.*; import gplx.lists.*;
import gplx.core.ios.*; import gplx.core.lists.*;
import gplx.xowa.wikis.tdbs.*;
class Io_sort_filCmd_reg implements Io_sort_filCmd { // 123|bgn|end|1
public Io_sort_filCmd_reg() {}

View File

@@ -16,12 +16,13 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.aria2; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.envs.*;
import gplx.xowa.apps.fsys.*; import gplx.xowa.bldrs.wms.dumps.*;
public class Aria2_lib_mgr implements GfoInvkAble {
public ProcessAdp Lib() {return lib;} private ProcessAdp lib = new ProcessAdp();
public Process_adp Lib() {return lib;} private Process_adp lib = new Process_adp();
public void Init_by_app(Xoae_app app) {
Xoa_fsys_eval cmd_eval = app.Url_cmd_eval();
ProcessAdp.ini_(this, app.Usr_dlg(), lib, cmd_eval, ProcessAdp.Run_mode_sync_block, Int_.Max_value
Process_adp.ini_(this, app.Usr_dlg(), lib, cmd_eval, Process_adp.Run_mode_sync_block, Int_.Max_value
, "~{<>bin_plat_dir<>}aria2" + Op_sys.Cur().Fsys_dir_spr_str() + "aria2c"
, Lib_args_fmt
, "wiki_abrv", "wiki_date", "wiki_type");
@@ -29,7 +30,7 @@ public class Aria2_lib_mgr implements GfoInvkAble {
// private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
public void Exec(Xowm_dump_file dump_file) {
// byte[] args_bry = lib.Args_fmtr().Bld_bry_many(tmp_bfr, dump_file.Wiki_alias(), dump_file.Dump_date(), dump_file.Dump_file_type());
// ProcessAdp process = new ProcessAdp().Exe_url_(lib.Exe_url()).Args_str_(String_.new_u8(args_bry));
// Process_adp process = new Process_adp().Exe_url_(lib.Exe_url()).Args_str_(String_.new_u8(args_bry));
// process.Run_wait();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.envs.*;
import gplx.dbs.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.bldrs.cmds.files.*; import gplx.xowa.files.origs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wikis.nss.*;
@@ -41,8 +42,8 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
public void Cmd_bgn(Xob_bldr bldr) {
parser = wiki.Parser_mgr().Main();
ctx = wiki.Parser_mgr().Ctx();
root = ctx.Tkn_mkr().Root(Bry_.Empty);
wiki.Init_assert(); // NOTE: must init wiki for db_mgr_as_sql
root = ctx.Tkn_mkr().Root(Bry_.Empty);
wiki.Init_assert(); // NOTE: must init wiki for db_mgr_as_sql
wiki.Db_mgr_as_sql().Core_data_mgr().Init_by_load(gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(wiki)); // NOTE: must reinit providers as previous steps may have rls'd (and left member variable conn which is closed)
wiki.File__orig_mgr().Wkrs_del(Xof_orig_wkr_.Tid_wmf_api);
db_fsys_mgr = wiki.Db_mgr_as_sql().Core_data_mgr();
@@ -50,7 +51,7 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
poll_interval = poll_mgr.Poll_interval();
page_src = new Xob_dump_src_id().Init(wiki, this.Init_redirect(), select_size);
ns_ary = Init_ns_ary();
ns_ary = Init_ns_ary();
Db_conn conn = Init_db_file();
Io_url wiki_dir = wiki.Fsys_mgr().Root_dir();
bmk_mgr.Cfg_url_(wiki_dir.GenSubFil("xowa.file.make.cfg.gfs"));

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.stores.*;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.data.tbls.*;
class Xob_dump_src_id {
private Xodb_mgr_sql db_mgr; private byte redirect;

View File

@@ -73,7 +73,7 @@ public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implement
private static final byte[] Fld_cl_from = Bry_.new_a7("cl_from"), Fld_cl_to = Bry_.new_a7("cl_to"), Fld_cl_timestamp = Bry_.new_a7("cl_timestamp"), Fld_cl_collation = Bry_.new_a7("cl_collation"), Fld_cl_sortkey = Bry_.new_a7("cl_sortkey"), Fld_cl_type = Bry_.new_a7("cl_type");
private static final byte[] Collation_uca = Bry_.new_a7("uca"), Sortkey_space = new byte[] {Byte_ascii.Space};
}
class Xoctg_link_sql_sorter implements gplx.lists.ComparerAble {
class Xoctg_link_sql_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Io_sort_split_itm lhs = (Io_sort_split_itm)lhsObj, rhs = (Io_sort_split_itm)rhsObj;
byte[] lhs_bry = lhs.Bfr(); int lhs_bgn = 0, lhs_end = lhs.Row_bgn() - 1;

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.nss.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.core.stores.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.nss.*;
public class Xob_categorylinks_sql_tst {
@Before public void init() {if (Xoa_test_.Db_skip()) return; fxt.Ctor_fsys();} Db_mgr_fxt fxt = new Db_mgr_fxt();
@After public void term() {if (Xoa_test_.Db_skip()) return; fxt.Rls();}

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.envs.*;
import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.bldrs.sqls.*;
import gplx.xowa.wikis.data.*;

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*;
import gplx.dbs.*; import gplx.fsdb.*; import gplx.dbs.engines.sqlite.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_diff_regy_make_cmd extends Xob_itm_basic_base implements Xob_cmd {

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*; import gplx.core.envs.*;
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.dbs.engines.sqlite.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.dbs.*; import gplx.fsdb.*; import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*;

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.envs.*;
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.fsdb.meta.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_fsdb_reduce_cmd extends Xob_itm_basic_base implements Xob_cmd {
@@ -39,10 +40,10 @@ public class Xob_fsdb_reduce_cmd extends Xob_itm_basic_base implements Xob_cmd {
}
}
class Fsdb_reduce_wkr {
private final ProcessAdp convert_process;
private final Process_adp convert_process;
private final Io_url src_url, trg_url;
private final int dpi, quality;
public Fsdb_reduce_wkr(ProcessAdp convert_process, Io_url tmp_dir, int dpi, int quality) {
public Fsdb_reduce_wkr(Process_adp convert_process, Io_url tmp_dir, int dpi, int quality) {
this.convert_process = convert_process;
this.src_url = tmp_dir.GenSubFil("fsdb_reduce.src.bin");
this.trg_url = tmp_dir.GenSubFil("fsdb_reduce.trg.bin");

View File

@@ -28,10 +28,9 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
private Xob_lnki_temp_tbl tbl; private boolean wdata_enabled = true, xtn_ref_enabled = true, gen_html, gen_hdump;
private Xop_log_invoke_wkr invoke_wkr; private Xop_log_property_wkr property_wkr;
private boolean ns_file_is_case_match_all = true; private Xowe_wiki commons_wiki;
private Xob_hdump_mgr hdump_bldr; private Xob_link_dump_cmd link_dump_cmd; private boolean hzip_enabled = false;
private Vnt_convert_lang converter_lang;
private final Xob_hdump_bldr hdump_bldr = new Xob_hdump_bldr(); private Vnt_convert_lang converter_lang;
public Xob_lnki_temp_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@Override public String Cmd_key() {return Xob_cmd_keys.Key_file_lnki_temp;}
@Override public String Cmd_key() {return Xob_cmd_keys.Key_file_lnki_temp;}
@Override public byte Init_redirect() {return Bool_.N_byte;} // lnki_temp does not look at redirect pages
@Override public int[] Init_ns_ary() {return ns_ids;} private int[] ns_ids = Int_.Ary(Xow_ns_.Tid__main);
@Override protected void Init_reset(Db_conn conn) {
@@ -42,16 +41,16 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
}
@Override protected Db_conn Init_db_file() {
ctx.Lnki().File_wkr_(this);
Xob_db_file make_db_file = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir());
Db_conn conn = make_db_file.Conn();
this.tbl = new Xob_lnki_temp_tbl(conn);
tbl.Create_tbl();
Xob_db_file make_db = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir());
Db_conn make_conn = make_db.Conn();
this.tbl = new Xob_lnki_temp_tbl(make_conn); tbl.Create_tbl();
this.gen_hdump = hdump_bldr.Init(wiki, make_conn);
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
if (vnt_mgr.Enabled()) {
this.converter_lang = vnt_mgr.Convert_lang();
converter_lang.Log__init(conn);
converter_lang.Log__init(make_conn);
}
return conn;
return make_conn;
}
@Override protected void Cmd_bgn_end() {
ns_file_is_case_match_all = Ns_file_is_case_match_all(wiki); // NOTE: must call after wiki.init
@@ -84,12 +83,6 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(fsdb_core);
trg_mnt_mgr.Mnts__get_insert_idx_(Fsm_mnt_mgr.Mnt_idx_main);
Fsm_mnt_mgr.Patch(trg_mnt_mgr.Mnts__get_main().Cfg_mgr().Tbl()); // NOTE: see fsdb_make; DATE:2014-04-26
if (gen_hdump) {
gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import import_cfg = wiki.Appe().Api_root().Bldr().Wiki().Import();
hdump_bldr = new Xob_hdump_mgr(wiki, tbl.Conn(), import_cfg.Html_db_max(), import_cfg.Zip_tid_html(), hzip_enabled);
link_dump_cmd = new Xob_link_dump_cmd();
link_dump_cmd.Init_by_wiki(wiki);
}
tbl.Insert_bgn();
log_mgr.Txn_bgn();
}
@@ -103,27 +96,15 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
page.Bldr__ns_ord_(ns_ord);
page.Ttl_(ttl).Revision_data().Id_(db_page.Id());
page.Redlink_lnki_list().Clear();
page.Url_(Xoa_url.new_(wiki.Domain_bry(), ttl.Full_db()));
if (ns.Id_is_tmpl())
parser.Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), wiki.Ns_mgr().Ns_template(), ttl_bry, page_src);
else {
parser.Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), page_src);
if (gen_html) {
page.Root_(root);
if (!page.Redirected())
wiki.Html_mgr().Page_wtr_mgr().Gen(ctx.Cur_page(), Xopg_page_.Tid_read);
}
if (gen_hdump) {
page.Root_(root);
hdump_bldr.Insert(page);
link_dump_cmd.Page_bgn(page.Revision_data().Id());
List_adp lnki_list = page.Redlink_lnki_list().Lnki_list();
int len = lnki_list.Count();
for (int i = 0; i < len; ++i) {
Xop_lnki_tkn lnki = (Xop_lnki_tkn)lnki_list.Get_at(i);
Xoa_ttl trg_ttl = lnki.Ttl();
link_dump_cmd.Add(lnki.Html_uid(), trg_ttl.Ns().Id(), trg_ttl.Page_db());
}
}
if (gen_html && !page.Redirected())
wiki.Html_mgr().Page_wtr_mgr().Gen(ctx.Cur_page().Root_(root), Xopg_page_.Tid_read);
if (gen_hdump)
hdump_bldr.Insert(page.Root_(root));
root.Clear();
}
}
@@ -132,14 +113,12 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
// if (converter_lang != null) converter_lang.Log__save();
if (gen_hdump) {
hdump_bldr.Commit();
link_dump_cmd.Wkr_commit();
}
}
@Override public void Exec_end_hook() {
// if (converter_lang != null) converter_lang.Log__rls();
if (gen_hdump) {
hdump_bldr.Bld_term();
link_dump_cmd.Wkr_end();
}
String err_filter_mgr = invoke_wkr.Err_filter_mgr().Print();
if (String_.Len_gt_0(err_filter_mgr)) usr_dlg.Warn_many("", "", err_filter_mgr);
@@ -163,20 +142,18 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_wdata_enabled_)) wdata_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_xtn_ref_enabled_)) xtn_ref_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_gen_html_)) gen_html = m.ReadYn("v");
else if (ctx.Match(k, Invk_gen_hdump_)) gen_hdump = m.ReadYn("v");
else if (ctx.Match(k, Invk_hzip_enabled_)) hzip_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_ns_ids_)) ns_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
else if (ctx.Match(k, Invk_ns_ids_by_aliases)) ns_ids = Xob_lnki_temp_wkr_.Ns_ids_by_aliases(wiki, m.ReadStrAry("v", "|"));
else if (ctx.Match(k, Invk_gen_html_)) gen_html = m.ReadYn("v");
else if (ctx.Match(k, Invk_hdump_bldr)) return hdump_bldr;
else if (ctx.Match(k, Invk_property_wkr)) return this.Property_wkr();
else if (ctx.Match(k, Invk_invoke_wkr)) return this.Invoke_wkr();
else return super.Invk(ctx, ikey, k, m);
return this;
}
private static final String Invk_wdata_enabled_ = "wdata_enabled_", Invk_xtn_ref_enabled_ = "xtn_ref_enabled_"
private static final String Invk_wdata_enabled_ = "wdata_enabled_", Invk_xtn_ref_enabled_ = "xtn_ref_enabled_", Invk_gen_html_ = "gen_html_"
, Invk_ns_ids_ = "ns_ids_", Invk_ns_ids_by_aliases = "ns_ids_by_aliases"
, Invk_invoke_wkr = "invoke_wkr", Invk_property_wkr = "property_wkr"
, Invk_gen_html_ = "gen_html_", Invk_gen_hdump_ = "gen_hdump_", Invk_hzip_enabled_ = "hzip_enabled_"
, Invk_invoke_wkr = "invoke_wkr", Invk_property_wkr = "property_wkr", Invk_hdump_bldr = "hdump_bldr"
;
private Xop_log_invoke_wkr Invoke_wkr() {
if (invoke_wkr == null) invoke_wkr = ((Scrib_xtn_mgr)bldr.App().Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY)).Invoke_wkr_or_new();

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*;
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.files.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.origs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_orig_regy_update_cmd extends Xob_itm_basic_base implements Xob_cmd { // downloads latest orig data

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*;
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
public class Xob_xfer_regy_tbl {
public static final String Tbl_name = "xfer_regy"

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*;
import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.files.*; import gplx.xowa.files.exts.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.parsers.lnkis.*;

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*;
import gplx.dbs.*; import gplx.xowa.files.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_xfer_temp_cmd_thumb extends Xob_itm_basic_base implements Xob_cmd {

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.core.stores.*;
import gplx.dbs.*; import gplx.xowa.files.*;
import gplx.xowa.parsers.lnkis.*;
class Xob_xfer_temp_itm {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.bldrs.cmds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import org.junit.*;
import gplx.core.gfo_ndes.*;
import gplx.stores.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
import gplx.core.stores.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
import gplx.xowa.parsers.lnkis.*;
public class Xob_xfer_temp_itm_tst {
private Xob_xfer_temp_itm_fxt fxt = new Xob_xfer_temp_itm_fxt();

View File

@@ -38,7 +38,7 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
this.text_zip_mgr = Xoa_app_.Utl__zip_mgr(); text_zip_tid = import_cfg.Zip_tid_text();
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__text(), db_mgr, import_cfg.Text_db_max());
if (redirect_id_enabled) {
this.redirect_tbl = new Xob_redirect_tbl(wiki.Fsys_mgr().Root_dir(), Xoa_app_.Utl__encoder_mgr().Http_url_ttl()).Create_table();
this.redirect_tbl = new Xob_redirect_tbl(wiki.Fsys_mgr().Root_dir(), gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url_ttl).Create_table();
redirect_tbl.Conn().Txn_bgn("bldr__page__redirect");
}
this.dg_match_mgr = app.Api_root().Bldr().Wiki().Filter().Dansguardian().New_mgr(wiki.Domain_str(), wiki.Fsys_mgr().Root_dir());

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.texts.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.core.envs.*;
import gplx.xowa.langs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.*;

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.texts.sqls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.bldrs.cmds.texts.*;
import gplx.core.ios.*; import gplx.core.encoders.*;
import gplx.core.ios.*; import gplx.core.encoders.*; import gplx.core.envs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.langs.*;
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;

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.threads.*;
import gplx.core.ios.*; import gplx.core.threads.*; import gplx.core.envs.*;
import gplx.xowa.bldrs.wkrs.*;
public class Xob_decompress_bz2_cmd extends Xob_itm_basic_base implements Xob_cmd {
public Xob_decompress_bz2_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
@@ -42,10 +42,10 @@ public class Xob_decompress_bz2_cmd extends Xob_itm_basic_base implements Xob_cm
static final String GRP_KEY = "xowa.bldr.cmd.decompress_bz2";
public static boolean Decompress(Xoae_app app, String src_fil, Io_url trg_fil) {
Io_mgr.Instance.CreateDirIfAbsent(trg_fil.OwnerDir()); // 7zip will fail if dir does not exist
ProcessAdp decompress = app.Prog_mgr().App_decompress_bz2();
decompress.Prog_dlg_(app.Usr_dlg()).Run_mode_(ProcessAdp.Run_mode_async);
Process_adp decompress = app.Prog_mgr().App_decompress_bz2();
decompress.Prog_dlg_(app.Usr_dlg()).Run_mode_(Process_adp.Run_mode_async);
decompress.Run(src_fil, trg_fil, trg_fil.OwnerDir().Xto_api());
while (decompress.Exit_code() == ProcessAdp.Exit_init) {
while (decompress.Exit_code() == Process_adp.Exit_init) {
String size = gplx.core.ios.Io_size_.To_str(Io_mgr.Instance.QueryFil(trg_fil).Size());
app.Usr_dlg().Prog_many(GRP_KEY, "decompress", "decompressing: ~{0}", size);
Thread_adp_.Sleep(1000);

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.cmds.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
import gplx.dbs.*; import gplx.core.ios.*;
import gplx.dbs.*; import gplx.core.ios.*; import gplx.core.envs.*;
import gplx.xowa.bldrs.wkrs.*;
import gplx.xowa.bldrs.wms.dumps.*;
public class Xob_download_wkr extends Xob_itm_basic_base implements Xob_cmd {
@@ -48,7 +48,7 @@ public class Xob_download_wkr extends Xob_itm_basic_base implements Xob_cmd {
usr_dlg.Warn_many("", "", "download failed: src=~{0} trg=~{1} err=~{2}", dump_src, dump_trg_zip.Raw(), Err_.Message_gplx_full(download_wkr.Rslt_err()));
if (unzip) {
usr_dlg.Note_many("", "", "unzipping file: now=~{0} trg=~{1}", DateAdp_.Now().XtoStr_fmt_yyyyMMdd_HHmmss(), dump_trg_bin.Raw());
Xob_unzip_wkr unzip_wkr = new Xob_unzip_wkr().Init(app).Process_run_mode_(ProcessAdp.Run_mode_sync_block);
Xob_unzip_wkr unzip_wkr = new Xob_unzip_wkr().Init(app).Process_run_mode_(Process_adp.Run_mode_sync_block);
unzip_wkr.Decompress(dump_trg_zip, dump_trg_bin);
}
}

View File

@@ -16,12 +16,13 @@ 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.envs.*;
public class Xob_unzip_wkr {
private ProcessAdp decompress_bz2, decompress_zip, decompress_gz, process;
private Process_adp decompress_bz2, decompress_zip, decompress_gz, process;
public int Process_exit_code() {return process.Exit_code();}
public byte Process_run_mode() {return process_run_mode;} public Xob_unzip_wkr Process_run_mode_(byte v) {process_run_mode = v; return this;} private byte process_run_mode = ProcessAdp.Run_mode_async;
public byte Process_run_mode() {return process_run_mode;} public Xob_unzip_wkr Process_run_mode_(byte v) {process_run_mode = v; return this;} private byte process_run_mode = Process_adp.Run_mode_async;
public Xob_unzip_wkr Init(Xoae_app app) {return Init(app.Prog_mgr().App_decompress_bz2(), app.Prog_mgr().App_decompress_zip(), app.Prog_mgr().App_decompress_gz());}
public Xob_unzip_wkr Init(ProcessAdp decompress_bz2, ProcessAdp decompress_zip, ProcessAdp decompress_gz) {
public Xob_unzip_wkr Init(Process_adp decompress_bz2, Process_adp decompress_zip, Process_adp decompress_gz) {
this.decompress_bz2 = decompress_bz2;
this.decompress_zip = decompress_zip;
this.decompress_gz = decompress_gz;

View File

@@ -22,7 +22,7 @@ import gplx.xowa.wikis.nss.*;
import gplx.xowa.parsers.utils.*;
public class Xob_redirect_cmd extends Xob_dump_mgr_base {
private Db_conn conn; private Xob_redirect_tbl redirect_tbl;
private Xodb_mgr_sql db_mgr; private Xop_redirect_mgr redirect_mgr; private Url_encoder encoder;
private Xodb_mgr_sql db_mgr; private Xop_redirect_mgr redirect_mgr; private Gfo_url_encoder encoder;
public Xob_redirect_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); this.Reset_db_y_();}
@Override public String Cmd_key() {return Xob_cmd_keys.Key_wiki_redirect;}
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Tid__file);} // restrict to file ns
@@ -35,8 +35,8 @@ public class Xob_redirect_cmd extends Xob_dump_mgr_base {
@Override protected Db_conn Init_db_file() {
this.db_mgr = wiki.Db_mgr_as_sql();
redirect_mgr = wiki.Redirect_mgr();
encoder = Xoa_app_.Utl__encoder_mgr().Http_url_ttl();
redirect_tbl = new Xob_redirect_tbl(wiki.Fsys_mgr().Root_dir(), Xoa_app_.Utl__encoder_mgr().Http_url_ttl()).Create_table();
encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url_ttl;
redirect_tbl = new Xob_redirect_tbl(wiki.Fsys_mgr().Root_dir(), gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url_ttl).Create_table();
conn = redirect_tbl.Conn();
conn.Txn_bgn("bldr__redirect");
return conn;

View File

@@ -19,8 +19,8 @@ package gplx.xowa.bldrs.cmds.wikis; import gplx.*; import gplx.xowa.*; import gp
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
import gplx.langs.htmls.encoders.*;
public class Xob_redirect_tbl {
private Url_encoder encoder; private Db_stmt insert_stmt;
public Xob_redirect_tbl(Io_url root_dir, Url_encoder encoder) {
private Gfo_url_encoder encoder; private Db_stmt insert_stmt;
public Xob_redirect_tbl(Io_url root_dir, Gfo_url_encoder encoder) {
this.db_file = Xob_db_file.new__wiki_redirect(root_dir);
this.conn = db_file.Conn();
this.encoder = encoder;

View File

@@ -16,8 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.brys.fmtrs.*; import gplx.core.ios.*; import gplx.xowa.htmls.*;
import gplx.langs.htmls.encoders.*;
import gplx.core.brys.fmtrs.*; import gplx.core.ios.*; import gplx.core.envs.*;
import gplx.xowa.htmls.*; import gplx.langs.htmls.encoders.*;
import gplx.xowa.wikis.nss.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.data.*;
import gplx.xowa.files.downloads.*;
@@ -33,7 +33,7 @@ public class Xoa_css_extractor {
public Xoa_css_extractor Page_fetcher_(Xow_page_fetcher v) {page_fetcher = v; return this;} private Xow_page_fetcher page_fetcher;
public Xoa_css_extractor Css_img_downloader_(Xoa_css_img_downloader v) {this.css_img_downloader = v; return this;} private Xoa_css_img_downloader css_img_downloader;
public Xoa_css_extractor Opt_download_css_common_(boolean v) {opt_download_css_common = v; return this;} private boolean opt_download_css_common;
public Xoa_css_extractor Url_encoder_(Url_encoder v) {url_encoder = v; return this;} private Url_encoder url_encoder;
public Xoa_css_extractor Url_encoder_(Gfo_url_encoder v) {url_encoder = v; return this;} private Gfo_url_encoder url_encoder;
public Xoa_css_extractor Wiki_code_(byte[] v) {this.wiki_code = v; return this;} private byte[] wiki_code = null;
private byte[] mainpage_html; private boolean lang_is_ltr = true;
private final Gfo_url_parser url_parser = new Gfo_url_parser();
@@ -43,7 +43,7 @@ public class Xoa_css_extractor {
this.download_xrg = download_wkr.Download_xrg();
css_img_downloader = new Xoa_css_img_downloader().Ctor(usr_dlg, download_wkr, Bry_.new_u8(protocol_prefix));
failover_dir = app.Fsys_mgr().Bin_xowa_dir().GenSubDir_nest("html", "css", "failover");
url_encoder = Xoa_app_.Utl__encoder_mgr().Http_url();
url_encoder = gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url;
}
public void Install(Xow_wiki wiki, String css_key) {
try {

View File

@@ -56,7 +56,7 @@ public class Xoa_css_extractor_basic_tst {
fxt.Test_fil("mem/xowa/user/anonymous/wiki/en.wikipedia.org/html/xowa_common.css", "failover");
}
@Test public void Css_scrape_download() {
fxt.Css_installer().Url_encoder_(Url_encoder.new_http_url_());
fxt.Css_installer().Url_encoder_(Gfo_url_encoder_.Http_url);
fxt.Init_fil("mem/http/en.wikipedia.org" , Xoa_css_extractor_fxt.Main_page_html);
fxt.Init_fil("mem/http/en.wikipedia.org/common.css" , "download");
fxt.Init_fil("mem/http/www/a&0|b,c" , "data=css_0");

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.xowa.files.downloads.*;
import gplx.xowa.files.downloads.*; import gplx.core.envs.*;
public class Xoa_css_img_downloader {
private byte[] wiki_domain;
public Xoa_css_img_downloader Ctor(Gfo_usr_dlg usr_dlg, Xof_download_wkr download_wkr, byte[] stylesheet_prefix) {

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.envs.*;
abstract class Xob_css_tkn__base {
public void Init(int tid, int pos_bgn, int pos_end) {
this.tid = tid; this.pos_bgn = pos_bgn; this.pos_end = pos_end;

View File

@@ -58,8 +58,8 @@ class Xoi_cmd_msg_ok extends Gfo_thread_cmd_base implements Gfo_thread_cmd {
// return Gfo_thread_cmd_.Init_ok;
// }
// public override void Async_run() {
// ProcessAdp process = new ProcessAdp().Exe_url_(exec_url).Args_str_(exec_args).Prog_dlg_(usr_dlg);
// process.Run_mode_(ProcessAdp.Run_mode_sync_block);
// Process_adp process = new Process_adp().Exe_url_(exec_url).Args_str_(exec_args).Prog_dlg_(usr_dlg);
// process.Run_mode_(Process_adp.Run_mode_sync_block);
// process.Run();
// }
// public static final String KEY = "exec.sync";

View File

@@ -16,18 +16,18 @@ 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.ios.*; import gplx.core.envs.*;
import gplx.xowa.apps.fsys.*;
public class Xoi_firefox_installer implements GfoInvkAble {
private Io_url src_xpi, trg_xpi;
private Io_url trg_xpi_package;
private ProcessAdp program = new ProcessAdp();
private Process_adp program = new Process_adp();
public void Init_by_app(Xoae_app app) {
src_xpi = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("firefox", "xowa_viewer", "default", "xowa_viewer@piotrex.xpi");
trg_xpi = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("firefox", "xowa_viewer", "install", "xowa_viewer@piotrex.xpi");
trg_xpi_package = trg_xpi.OwnerDir().GenSubDir("package");
Xoa_fsys_eval cmd_eval = app.Url_cmd_eval();
ProcessAdp.ini_(this, app.Usr_dlg(), program, cmd_eval, ProcessAdp.Run_mode_async, 0, "firefox", "\"~{url}\"", "url");
Process_adp.ini_(this, app.Usr_dlg(), program, cmd_eval, Process_adp.Run_mode_async, 0, "firefox", "\"~{url}\"", "url");
}
public void Install_via_process() {
Generate();

View File

@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.wms.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wms.*;
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.langs.htmls.encoders.*;
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.envs.*;
import gplx.langs.htmls.encoders.*;
import gplx.xowa.files.downloads.*;
import gplx.xowa.htmls.hrefs.*;
public class Xoapi_orig_wmf extends Xoapi_orig_base {
@@ -80,7 +81,7 @@ public class Xoapi_orig_wmf extends Xoapi_orig_base {
return tmp_bfr.To_str_and_clear();
}
}
private static Url_encoder tmp_encoder = Url_encoder.new_http_url_().Itms_raw_diff(Byte_ascii.Space, Byte_ascii.Underline);
private static Gfo_url_encoder tmp_encoder = Gfo_url_encoder_.New__http_url().Init__diff__one(Byte_ascii.Space, Byte_ascii.Underline).Make();
private static final Bry_bfr tmp_bfr = Bry_bfr.new_();
private static final byte[]
Bry_api = Bry_.new_a7("/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:") // NOTE: using File b/c it should be canonical

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
import gplx.core.ios.*;
import gplx.core.ios.*; import gplx.core.envs.*;
import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.tdbs.*;
public class Xob_import_cfg {
public Xob_import_cfg(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki; private boolean src_fil_is_bz2 = true;
@@ -43,7 +43,7 @@ public class Xob_import_cfg {
src_fil = src_fil_bz2; src_rdr_len = Io_mgr.Instance.QueryFil(src_fil_bz2).Size();
Xoae_app app = wiki.Appe();
if (app.Setup_mgr().Dump_mgr().Import_bz2_by_stdout()) {
ProcessAdp process = app.Prog_mgr().App_decompress_bz2_by_stdout();
Process_adp process = app.Prog_mgr().App_decompress_bz2_by_stdout();
return Io_stream_rdr_process.new_(process.Exe_url(), src_fil_bz2, process.Xto_process_bldr_args(src_fil_bz2.Raw()));
}
else

View File

@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import gplx.core.consoles.*; import gplx.langs.htmls.encoders.*;
public class Xof_file_wkr_ {
public static final Url_encoder Md5_decoder = Url_encoder.new_http_url_().Itms_raw_same_many(Byte_ascii.Plus);
public static final Gfo_url_encoder Md5_decoder = Gfo_url_encoder_.New__http_url().Init__same__many(Byte_ascii.Plus).Make();
public static byte[] Md5_fast(byte[] v) {return Bry_.new_a7(gplx.core.security.HashAlgo_.Md5.CalcHash(Console_adp_.Noop, gplx.core.ios.IoStream_.ary_(v)));}
public static byte[] Md5(byte[] ttl) {
ttl = Md5_decoder.Decode_lax(Ttl_standardize(ttl));
ttl = Md5_decoder.Decode(Ttl_standardize(ttl));
return Xof_file_wkr_.Md5_fast(ttl); // NOTE: md5 is calculated off of url_decoded ttl; EX: A%2Cb is converted to A,b and then md5'd. note that A%2Cb still remains the title
}
public static byte[] Ttl_standardize(byte[] ttl) {

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import gplx.core.stores.*;
import gplx.dbs.*;
public class Xof_lnki_page {
public static final int Null = -1;

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
import gplx.core.stores.*;
import gplx.dbs.*;
public class Xof_lnki_time {
public static double Db_save_double(double v) {return v;}

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