mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.1.1
This commit is contained in:
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.core.btries; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Btrie_utf8_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Btrie_utf8_mgr_fxt fxt = new Btrie_utf8_mgr_fxt();
|
||||
public class Btrie_u8_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Btrie_u8_mgr_fxt fxt = new Btrie_u8_mgr_fxt();
|
||||
@Test public void Ascii() {
|
||||
fxt.Init_add(Bry_.new_a7("a") , "1");
|
||||
fxt.Init_add(Bry_.new_a7("abc") , "123");
|
||||
@@ -47,7 +47,7 @@ public class Btrie_utf8_mgr_tst {
|
||||
fxt.Init_add(Bry_.new_u8("İ") , "1");
|
||||
fxt.Test_match("İ" , "1"); // exact=y; İ = Bry_.ints_(196,176)
|
||||
fxt.Test_match("i" , "1"); // lower=y; i = Bry_.ints_(105)
|
||||
fxt.Test_match("I" , null); // upper=n; I = Bry_.ints_( 73); see Btrie_utf8_itm and rv.asymmetric_bry
|
||||
fxt.Test_match("I" , null); // upper=n; I = Bry_.ints_( 73); see Btrie_u8_itm and rv.asymmetric_bry
|
||||
|
||||
fxt.Clear();
|
||||
fxt.Init_add(Bry_.new_u8("i") , "1");
|
||||
@@ -62,7 +62,7 @@ public class Btrie_utf8_mgr_tst {
|
||||
fxt.Test_match("İi" , "1"); // mixed
|
||||
fxt.Test_match("iİ" , "1"); // mixed
|
||||
}
|
||||
@Test public void Utf8_asymmetric_upper() { // PURPOSE: "İ" and "I" should co-exist; see Btrie_utf8_itm and called_by_match
|
||||
@Test public void Utf8_asymmetric_upper() { // PURPOSE: "İ" and "I" should co-exist; see Btrie_u8_itm and called_by_match
|
||||
fxt.Init_add(Bry_.new_u8("İ") , "1");
|
||||
fxt.Init_add(Bry_.new_u8("I") , "1");
|
||||
fxt.Test_match("İ" , "1"); // exact
|
||||
@@ -77,10 +77,10 @@ public class Btrie_utf8_mgr_tst {
|
||||
fxt.Test_match("a_b" , null); // diff : len=1
|
||||
}
|
||||
}
|
||||
class Btrie_utf8_mgr_fxt {
|
||||
private Btrie_utf8_mgr trie;
|
||||
class Btrie_u8_mgr_fxt {
|
||||
private Btrie_u8_mgr trie;
|
||||
public void Clear() {
|
||||
trie = Btrie_utf8_mgr.new_(Xol_case_mgr_.Utf8());
|
||||
trie = Btrie_u8_mgr.new_(Xol_case_mgr_.U8());
|
||||
}
|
||||
public void Init_add(byte[] key, Object val) {trie.Add_obj(key, val);}
|
||||
public void Test_match_pos(String src_str, int bgn_pos, String expd) {
|
||||
@@ -30,10 +30,10 @@ public class Gfo_fld_rdr extends Gfo_fld_base {
|
||||
public byte[] Read_bry_simple() {Move_next_simple(); return Bry_.Mid(data, fld_bgn, fld_end);} // was Mid_by_len???; 20120915
|
||||
public int Read_int_base85_lenN(int len) {fld_bgn = pos; fld_end = pos + len - 1 ; pos = pos + len + 1 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int_base85_len5() {fld_bgn = pos; fld_end = pos + 4 ; pos = pos + 6 ; return Base85_utl.XtoIntByAry(data, fld_bgn, fld_end);}
|
||||
public int Read_int() {Move_next_simple(); return Bry_.Xto_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_int_as_byte() {Move_next_simple(); return (byte)Bry_.Xto_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public int Read_int() {Move_next_simple(); return Bry_.To_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_int_as_byte() {Move_next_simple(); return (byte)Bry_.To_int_or(data, fld_bgn, fld_end, -1);}
|
||||
public byte Read_byte() {Move_next_simple(); return data[fld_bgn];}
|
||||
public double Read_double() {Move_next_simple(); return Bry_.XtoDoubleByPos(data, fld_bgn, fld_end);}
|
||||
public double Read_double() {Move_next_simple(); return Bry_.To_double(data, fld_bgn, fld_end);}
|
||||
public DateAdp Read_dte() {// NOTE: fmt = yyyyMMdd HHmmss.fff
|
||||
int y = 0, M = 0, d = 0, H = 0, m = 0, s = 0, f = 0;
|
||||
if (pos < data_len && data[pos] == row_dlm) {++pos; ++row_idx; fld_idx = 0;} fld_bgn = pos;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Json_doc {
|
||||
public void Ctor(byte[] src, Json_nde root) {this.src = src; this.root = root;}
|
||||
public Bry_bfr Bfr() {return bfr;} Bry_bfr bfr = Bry_bfr.new_();
|
||||
public Number_parser Utl_num_parser() {return utl_num_parser;} Number_parser utl_num_parser = new Number_parser();
|
||||
public byte[] Str_utf8_bry() {return str_utf8_bry;} private byte[] str_utf8_bry = new byte[6];
|
||||
public byte[] Str_u8_bry() {return str_u8_bry;} private byte[] str_u8_bry = new byte[6];
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public Json_nde Root() {return root;} Json_nde root;
|
||||
public byte[] Get_val_as_bry_or(byte[] qry_bry, byte[] or) {tmp_qry_bry[0] = qry_bry; return Get_val_as_bry_or(tmp_qry_bry, or);}
|
||||
|
||||
@@ -47,9 +47,9 @@ class Json_itm_decimal extends Json_itm_base {
|
||||
@Override public byte Tid() {return Json_itm_.Tid_decimal;}
|
||||
@Override public Object Data() {
|
||||
if (data == null)
|
||||
data = DecimalAdp_.parse_(String_.new_a7(this.Data_bry()));
|
||||
data = Decimal_adp_.parse_(String_.new_a7(this.Data_bry()));
|
||||
return data;
|
||||
} DecimalAdp data;
|
||||
} Decimal_adp data;
|
||||
@Override public byte[] Data_bry() {
|
||||
if (data_bry == null) data_bry = Bry_.Mid(doc.Src(), this.Src_bgn(), this.Src_end());
|
||||
return data_bry;
|
||||
@@ -82,7 +82,7 @@ class Json_itm_str extends Json_itm_base {
|
||||
byte[] src = doc.Src(); int bgn = this.Src_bgn(), end = this.Src_end();
|
||||
if (exact) return Bry_.Mid(src, bgn, end);
|
||||
Bry_bfr bfr = doc.Bfr();
|
||||
byte[] utf8_bry = doc.Str_utf8_bry();
|
||||
byte[] utf8_bry = doc.Str_u8_bry();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Json_kv_ary_srl_tst {
|
||||
@Test public void Bool_n() {fxt.Test_parse("{'k0':false}" , fxt.ary_(fxt.kv_bool_("k0", false)));}
|
||||
@Test public void Num() {fxt.Test_parse("{'k0':123}" , fxt.ary_(fxt.kv_int_("k0", 123)));}
|
||||
@Test public void Str() {fxt.Test_parse("{'k0':'v0'}" , fxt.ary_(fxt.kv_str_("k0", "v0")));}
|
||||
@Test public void Num_dec() {fxt.Test_parse("{'k0':1.23}" , fxt.ary_(fxt.kv_dec_("k0", DecimalAdp_.parse_("1.23"))));}
|
||||
@Test public void Num_dec() {fxt.Test_parse("{'k0':1.23}" , fxt.ary_(fxt.kv_dec_("k0", Decimal_adp_.parse_("1.23"))));}
|
||||
@Test public void Ary_int() {fxt.Test_parse("{'k0':[1,2,3]}" , fxt.ary_(fxt.kv_obj_("k0", fxt.ary_(fxt.kv_int_("1", 1), fxt.kv_int_("2", 2), fxt.kv_int_("3", 3)))));}
|
||||
@Test public void Ary_empty() {fxt.Test_parse("{'k0':[]}" , fxt.ary_(fxt.kv_obj_("k0", fxt.ary_())));}
|
||||
@Test public void Subs_int() {fxt.Test_parse("{'k0':{'k00':1,'k01':2}}" , fxt.ary_(fxt.kv_obj_("k0", fxt.ary_(fxt.kv_int_("k00", 1), fxt.kv_int_("k01", 2)))));}
|
||||
@@ -46,5 +46,5 @@ class Json_kv_ary_srl_fxt {
|
||||
public KeyVal kv_str_(String key, String val) {return KeyVal_.new_(key, val);}
|
||||
public KeyVal kv_int_(String key, int val) {return KeyVal_.new_(key, val);}
|
||||
public KeyVal kv_bool_(String key, boolean val) {return KeyVal_.new_(key, Bool_.Xto_str_lower(val));}
|
||||
public KeyVal kv_dec_(String key, DecimalAdp val) {return KeyVal_.new_(key, val.Xto_str());}
|
||||
public KeyVal kv_dec_(String key, Decimal_adp val) {return KeyVal_.new_(key, val.To_str());}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.net; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoo_protocol_itm {
|
||||
public Xoo_protocol_itm(byte tid, String text) {
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_protocol_itm {
|
||||
public Gfo_protocol_itm(byte tid, String text) {
|
||||
this.tid = tid;
|
||||
this.text_bry = Bry_.new_u8(text);
|
||||
this.text_str = text;
|
||||
@@ -68,13 +68,14 @@ public class Xoo_protocol_itm {
|
||||
, Tid_urn = 23
|
||||
, Tid_geo = 24
|
||||
, Tid_null = 25
|
||||
, Tid_xowa = 26
|
||||
, Tid_file = 27
|
||||
, Tid_relative_1 = 28 // [//a.org]
|
||||
, Tid_relative_2 = 29 // [[//a.org]]
|
||||
, Tid_unknown = 26
|
||||
, Tid_xowa = 27
|
||||
, Tid_file = 28
|
||||
, Tid_relative_1 = 29 // [//a.org]
|
||||
, Tid_relative_2 = 30 // [[//a.org]]
|
||||
;
|
||||
public static final Ordered_hash Regy = Ordered_hash_.new_bry_();
|
||||
public static final Xoo_protocol_itm
|
||||
public static final Gfo_protocol_itm
|
||||
Itm_http = new_(Tid_http , "http://")
|
||||
, Itm_https = new_(Tid_https , "https://")
|
||||
, Itm_ftp = new_(Tid_ftp , "ftp://")
|
||||
@@ -101,28 +102,34 @@ public class Xoo_protocol_itm {
|
||||
, Itm_urn = new_(Tid_urn , "urn:")
|
||||
, Itm_geo = new_(Tid_geo , "geo:")
|
||||
;
|
||||
public static final String Str_file = "file:";
|
||||
public static final byte[] Bry_file = Bry_.new_a7(Str_file);
|
||||
public static Xoo_protocol_itm[] Ary() {
|
||||
public static final String Str_file = "file:", Str_xcmd = "xowa-cmd:";
|
||||
public static final byte[] Bry_file = Bry_.new_a7(Str_file), Bry_xcmd = Bry_.new_a7(Str_xcmd);
|
||||
public static final int Len_xcmd = Bry_xcmd.length;
|
||||
public static final byte[] Bry_relative = Bry_.new_a7("//");
|
||||
public static Gfo_protocol_itm Get_or(byte tid, Gfo_protocol_itm or) {
|
||||
Gfo_protocol_itm[] ary = Ary();
|
||||
return tid >= ary.length ? or : ary[tid];
|
||||
}
|
||||
public static Gfo_protocol_itm[] Ary() {
|
||||
if (protocol_itm_ary == null) {
|
||||
int len = Regy.Count();
|
||||
protocol_itm_ary = new Xoo_protocol_itm[len];
|
||||
protocol_itm_ary = new Gfo_protocol_itm[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
protocol_itm_ary[i] = (Xoo_protocol_itm)Regy.Get_at(i);
|
||||
protocol_itm_ary[i] = (Gfo_protocol_itm)Regy.Get_at(i);
|
||||
}
|
||||
return protocol_itm_ary;
|
||||
} private static Xoo_protocol_itm[] protocol_itm_ary;
|
||||
} private static Gfo_protocol_itm[] protocol_itm_ary;
|
||||
public static String[] Protocol_str_ary() {
|
||||
if (protocol_str_ary == null) {
|
||||
int len = Regy.Count();
|
||||
protocol_str_ary = new String[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
protocol_str_ary[i] = ((Xoo_protocol_itm)Regy.Get_at(i)).Text_str();
|
||||
protocol_str_ary[i] = ((Gfo_protocol_itm)Regy.Get_at(i)).Text_str();
|
||||
}
|
||||
return protocol_str_ary;
|
||||
} private static String[] protocol_str_ary;
|
||||
private static Xoo_protocol_itm new_(byte tid, String text) {
|
||||
Xoo_protocol_itm rv = new Xoo_protocol_itm(tid, text);
|
||||
private static Gfo_protocol_itm new_(byte tid, String text) {
|
||||
Gfo_protocol_itm rv = new Gfo_protocol_itm(tid, text);
|
||||
Regy.Add(rv.Key_wo_colon_bry(), rv);
|
||||
return rv;
|
||||
}
|
||||
51
400_xowa/src/gplx/core/net/Gfo_qarg_itm.java
Normal file
51
400_xowa/src/gplx/core/net/Gfo_qarg_itm.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_qarg_itm {
|
||||
public Gfo_qarg_itm(byte[] key_bry, byte[] val_bry) {this.key_bry = key_bry; this.val_bry = val_bry;}
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
public byte[] Val_bry() {return val_bry;} private byte[] val_bry;
|
||||
public Gfo_qarg_itm Val_bry_(byte[] v) {val_bry = v; return this;}
|
||||
public static final Gfo_qarg_itm[] Ary_empty = new Gfo_qarg_itm[0];
|
||||
public static Gfo_qarg_itm new_key_(String key) {return new Gfo_qarg_itm(Bry_.new_u8(key), Bry_.Empty);}
|
||||
public static Gfo_qarg_itm[] Ary(String... kvs) {
|
||||
int len = kvs.length;
|
||||
Gfo_qarg_itm[] rv = new Gfo_qarg_itm[len / 2];
|
||||
String key = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String s = kvs[i];
|
||||
if (i % 2 == 0)
|
||||
key = s;
|
||||
else
|
||||
rv[i / 2] = new Gfo_qarg_itm(Bry_.new_u8(key), Bry_.new_u8(s));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static String To_str(Gfo_qarg_itm[] ary) {
|
||||
int len = ary.length;
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_qarg_itm itm = ary[i];
|
||||
bfr.Add(itm.Key_bry()).Add_byte_eq();
|
||||
if (itm.Val_bry() != null)
|
||||
bfr.Add(itm.Val_bry());
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
return bfr.Xto_str_and_clear();
|
||||
}
|
||||
}
|
||||
106
400_xowa/src/gplx/core/net/Gfo_qarg_mgr.java
Normal file
106
400_xowa/src/gplx/core/net/Gfo_qarg_mgr.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_qarg_mgr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
private final Hash_adp hash = Hash_adp_bry.cs();
|
||||
public int Len() {return list.Count();}
|
||||
public boolean Match(byte[] key, byte[] val) {
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by(key);
|
||||
return arg == null ? false : Bry_.Eq(val, arg.Val_bry());
|
||||
}
|
||||
public Gfo_qarg_itm Get_at(int i) {return (Gfo_qarg_itm)list.Get_at(i);}
|
||||
public Gfo_qarg_itm Get_arg(byte[] key) {return (Gfo_qarg_itm)hash.Get_by(key);}
|
||||
public int Get_val_int_or(byte[] key, int or) {
|
||||
byte[] val_bry = Get_val_bry_or(key, null); if (val_bry == null) return or;
|
||||
return Bry_.To_int_or(val_bry, or);
|
||||
}
|
||||
public byte[] Get_val_bry_or(byte[] key, byte[] or) {
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by(key);
|
||||
return arg == null ? or : arg.Val_bry();
|
||||
}
|
||||
public String Get_val_str_or(byte[] key, String or) {
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by(key);
|
||||
return arg == null ? or : String_.new_u8(arg.Val_bry());
|
||||
}
|
||||
public void Set_val_by_int(byte[] key, int val) {Set_val_by_bry(key, Bry_.new_a7(Int_.Xto_str(val)));}
|
||||
public void Set_val_by_bry(byte[] key, byte[] val) {
|
||||
Gfo_qarg_itm arg = (Gfo_qarg_itm)hash.Get_by(key);
|
||||
if (arg == null) {
|
||||
arg = new Gfo_qarg_itm(key, Bry_.Empty);
|
||||
list.Add(arg);
|
||||
hash.Add(key, arg);
|
||||
}
|
||||
arg.Val_bry_(val);
|
||||
}
|
||||
public Gfo_qarg_mgr Load(Gfo_qarg_itm[] ary) {
|
||||
hash.Clear();
|
||||
list.Clear();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_qarg_itm itm = ary[i];
|
||||
list.Add(itm);
|
||||
hash.Add_if_dupe_use_nth(itm.Key_bry(), itm);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Gfo_qarg_itm[] To_ary() {return (Gfo_qarg_itm[])list.To_ary(Gfo_qarg_itm.class);}
|
||||
public byte[] Concat(Bry_bfr bfr, byte[]... ary) {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
byte[] key = ary[i];
|
||||
Gfo_qarg_itm itm = Get_arg(key); if (itm == null) continue;
|
||||
bfr.Add_byte(Byte_ascii.Amp).Add(itm.Key_bry()).Add_byte(Byte_ascii.Eq).Add(itm.Val_bry());
|
||||
}
|
||||
return bfr.Xto_bry_and_clear();
|
||||
}
|
||||
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);
|
||||
return bfr.Xto_bry_and_clear();
|
||||
}
|
||||
public void To_bry(Bry_bfr bfr, 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);
|
||||
bfr.Add_byte(i == 0 ? Byte_ascii.Question : Byte_ascii.Amp);
|
||||
Write_or_encode(bfr, href_encoder, encode, itm.Key_bry());
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
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) {
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Gfo_qarg_itm itm = ary[i];
|
||||
bfr.Add_byte(i == 0 ? Byte_ascii.Question : Byte_ascii.Amp);
|
||||
Write_or_encode(bfr, href_encoder, encode, itm.Key_bry());
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
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) {
|
||||
if (bry == null) return; // NOTE: need null check b/c itm.Val_bry can be null
|
||||
if (encode)
|
||||
href_encoder.Encode(bfr, bry);
|
||||
else
|
||||
bfr.Add(bry);
|
||||
}
|
||||
}
|
||||
38
400_xowa/src/gplx/core/net/Gfo_url.java
Normal file
38
400_xowa/src/gplx/core/net/Gfo_url.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_url {
|
||||
public byte[] Raw() {return raw;} private byte[] raw;
|
||||
public byte Protocol_tid() {return protocol_tid;} private byte protocol_tid;
|
||||
public byte[] Protocol_bry() {return protocol_bry;} private byte[] protocol_bry;
|
||||
public byte[] Anch() {return anch;} private byte[] anch;
|
||||
public Gfo_qarg_itm[] Qargs() {return qargs;} private Gfo_qarg_itm[] qargs;
|
||||
public byte[][] Segs() {return segs;} private byte[][] segs; private int segs__len;
|
||||
public byte[] Segs__get_at(int i) {return i < segs__len ? segs[i] : null;}
|
||||
public byte[] Segs__get_at_1st() {return segs__len > 0 ? segs[0] : null;}
|
||||
public byte[] Segs__get_at_nth() {return segs__len > 1 ? segs[segs__len - 1] : null;}
|
||||
public Gfo_url Ctor(byte[] raw, byte protocol_tid, byte[] protocol_bry, byte[][] segs, Gfo_qarg_itm[] qargs, byte[] anch) {
|
||||
this.raw = raw;
|
||||
this.protocol_tid = protocol_tid; this.protocol_bry = protocol_bry;
|
||||
this.segs = segs; this.segs__len = segs.length;
|
||||
this.qargs = qargs;
|
||||
this.anch = anch;
|
||||
return this;
|
||||
}
|
||||
public static final Gfo_url Empty = new Gfo_url().Ctor(Bry_.Empty, Gfo_protocol_itm.Tid_unknown, Bry_.Empty, Bry_.Ary_empty, null, null);
|
||||
}
|
||||
261
400_xowa/src/gplx/core/net/Gfo_url_parser.java
Normal file
261
400_xowa/src/gplx/core/net/Gfo_url_parser.java
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
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() {
|
||||
Init_protocols(Gfo_protocol_itm.Ary());
|
||||
Init_protocol_itm(Gfo_protocol_itm.Bry_relative, Gfo_protocol_itm.Tid_relative_1);
|
||||
Init_protocol_itm(Gfo_protocol_itm.Bry_file, Gfo_protocol_itm.Tid_file);
|
||||
Init_protocol_itm(gplx.xowa.parsers.lnkes.Xop_lnke_wkr.Bry_xowa_protocol, Gfo_protocol_itm.Tid_xowa);
|
||||
}
|
||||
private void Init_protocols(Gfo_protocol_itm... itms) {
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Gfo_protocol_itm itm = itms[i];
|
||||
Init_protocol_itm(itm.Key_w_colon_bry(), itm.Tid());
|
||||
}
|
||||
}
|
||||
public void Init_protocol_itm(byte[] key, byte protocol_tid) {
|
||||
protocols.Add_bry_byte(key, protocol_tid);
|
||||
}
|
||||
public void Parse_site_fast(Gfo_url_site_data site_data, byte[] src, int src_bgn, int src_end) {
|
||||
int pos = src_bgn; boolean rel = false;
|
||||
if (pos + 1 < src_end && src[pos] == Byte_ascii.Slash && src[pos + 1] == Byte_ascii.Slash) { // starts with "//"
|
||||
pos += 2;
|
||||
rel = true;
|
||||
}
|
||||
if (!rel) { // search for ":"; NOTE: only search if not rel; i.e.: "//"
|
||||
int colon_pos = Bry_finder.Find_fwd(src, Byte_ascii.Colon, pos, src_end); // no colon found; EX: "//a.org/b"; "a.org/b"
|
||||
if (colon_pos != Bry_.NotFound) // colon found; EX: "http://" or "https://"
|
||||
pos = colon_pos + Int_.Const_dlm_len;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) { // skip slash after colon
|
||||
pos += 1;
|
||||
if (pos < src_end && src[pos] == Byte_ascii.Slash) // skip 2nd slash after colon
|
||||
pos += 1;
|
||||
}
|
||||
}
|
||||
int slash_pos = Bry_finder.Find_fwd(src, Byte_ascii.Slash, pos, src_end);
|
||||
if (slash_pos == Bry_.NotFound) // no terminating slash; EX: http://a.org
|
||||
slash_pos = src_end;
|
||||
slash_pos = Bry_.Trim_end_pos(src, slash_pos);
|
||||
site_data.Atrs_set(rel, pos, slash_pos);
|
||||
}
|
||||
private static final int Area__path = 1, Area__qarg_key_1st = 2, Area__qarg_key_nth = 3, Area__qarg_val = 4, Area__anch = 5;
|
||||
private byte[] src; int src_bgn, src_end;
|
||||
private int area;
|
||||
private boolean encoded;
|
||||
private byte protocol_tid; private byte[] protocol_bry, anch;
|
||||
private int path_bgn, qarg_key_bgn, qarg_val_bgn, anch_bgn, anch_nth_bgn;
|
||||
public Gfo_url Parse(byte[] src) {return Parse(new Gfo_url(), src, 0, src.length);}
|
||||
public Gfo_url Parse(Gfo_url rv, byte[] src, int src_bgn, int src_end) {
|
||||
this.src = src; this.src_bgn = src_bgn; this.src_end = src_end;
|
||||
encoded = false;
|
||||
protocol_tid = Gfo_protocol_itm.Tid_null;
|
||||
protocol_bry = anch = null;
|
||||
path_bgn = qarg_key_bgn = qarg_val_bgn = anch_bgn = anch_nth_bgn = -1;
|
||||
segs_ary.Clear(); qargs.Clear();
|
||||
|
||||
int pos = src_bgn;
|
||||
Object protocol_obj = protocols.Match_bgn(src, src_bgn, src_end);
|
||||
pos = protocols.Match_pos();
|
||||
pos = Bry_finder.Find_fwd_while(src, pos, src_end, Byte_ascii.Slash);
|
||||
if (protocol_obj == null) {
|
||||
this.protocol_tid = Gfo_protocol_itm.Tid_unknown;
|
||||
}
|
||||
else {
|
||||
this.protocol_tid = ((Byte_obj_val)protocol_obj).Val();
|
||||
this.protocol_bry = Make_bry(src_bgn, pos);
|
||||
}
|
||||
|
||||
area = Area__path;
|
||||
path_bgn = pos;
|
||||
while (true) {
|
||||
if (pos == src_end) break;
|
||||
byte b = src[pos];
|
||||
switch (b) {
|
||||
case Byte_ascii.Slash: pos = Parse_slash(pos, b); break;
|
||||
case Byte_ascii.Question: pos = Parse_qarg_key_1st(pos, b); break;
|
||||
case Byte_ascii.Amp: pos = Parse_qarg_key_nth(pos, b); break;
|
||||
case Byte_ascii.Eq: pos = Parse_qarg_val(pos, b); break;
|
||||
case Byte_ascii.Hash: pos = Parse_anch(pos, b); break;
|
||||
case Byte_ascii.Percent: encoded = true; ++pos; break;
|
||||
default:
|
||||
++pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
End_area(pos, Byte_ascii.Null);
|
||||
rv.Ctor(src, protocol_tid, protocol_bry, segs_ary.To_ary(0), Make_qargs(), anch);
|
||||
return rv;
|
||||
}
|
||||
private int Parse_slash(int pos, byte b) {
|
||||
switch (area) {
|
||||
case Area__path: return End_area(pos, b);
|
||||
default: return pos + 1;
|
||||
}
|
||||
}
|
||||
private int Parse_anch(int pos, byte b) {
|
||||
switch (area) {
|
||||
case Area__path:
|
||||
End_area(pos, b);
|
||||
area = Area__anch;
|
||||
anch_bgn = pos + 1;
|
||||
break;
|
||||
case Area__anch: // handle double; A#B#C -> "A#B", "C"
|
||||
Append_to_last_path(Byte_ascii.Hash, Make_bry(anch_bgn, pos));
|
||||
anch_bgn = pos + 1;
|
||||
break;
|
||||
case Area__qarg_val:
|
||||
case Area__qarg_key_1st:
|
||||
case Area__qarg_key_nth:
|
||||
if (anch_nth_bgn == -1)
|
||||
anch_nth_bgn = Bry_finder.Find_bwd(src, Byte_ascii.Hash, src_end);
|
||||
if (pos == anch_nth_bgn) {
|
||||
End_area(pos, b);
|
||||
area = Area__anch;
|
||||
anch_bgn = pos + 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return pos + 1;
|
||||
}
|
||||
private int Parse_qarg_key_1st(int pos, byte b) {
|
||||
switch (area) {
|
||||
case Area__path: // only valid way to start qarg; EX: A?B=C
|
||||
End_area(pos, b);
|
||||
area = Area__qarg_key_1st;
|
||||
qarg_key_bgn = pos + 1;
|
||||
break;
|
||||
case Area__qarg_key_1st: // handle dupe; EX: A?B?C
|
||||
case Area__qarg_key_nth: // handle dupe; EX: A?B=C&D?
|
||||
case Area__qarg_val: // handle dupe; EX: A?B=?
|
||||
End_area(pos, b);
|
||||
Append_to_last_path__qargs();
|
||||
area = Area__qarg_key_1st;
|
||||
qarg_key_bgn = pos + 1;
|
||||
break;
|
||||
}
|
||||
return pos + 1;
|
||||
}
|
||||
private int Parse_qarg_key_nth(int pos, byte b) {
|
||||
switch (area) {
|
||||
case Area__path: // ignore if qarg not started; EX: A&B
|
||||
break;
|
||||
case Area__qarg_key_1st: // handle invalid; A?B&C
|
||||
case Area__qarg_key_nth: // handle invalid; A?B=C&D&E=F
|
||||
End_area(pos, b);
|
||||
qargs.Add(null);
|
||||
area = Area__qarg_key_nth;
|
||||
qarg_key_bgn = pos + 1;
|
||||
break;
|
||||
case Area__qarg_val:
|
||||
End_area(pos, b);
|
||||
area = Area__qarg_key_nth;
|
||||
qarg_key_bgn = pos + 1;
|
||||
break;
|
||||
}
|
||||
return pos + 1;
|
||||
}
|
||||
private int Parse_qarg_val(int pos, byte b) {
|
||||
switch (area) {
|
||||
case Area__qarg_key_1st:
|
||||
case Area__qarg_key_nth:
|
||||
End_area(pos, b); break;
|
||||
default: break;
|
||||
}
|
||||
return pos + 1;
|
||||
}
|
||||
private int End_area(int pos, byte b) {
|
||||
switch (area) {
|
||||
case Area__path:
|
||||
segs_ary.Add(Make_bry(path_bgn, pos));
|
||||
path_bgn = pos + 1;
|
||||
break;
|
||||
case Area__qarg_key_1st:
|
||||
case Area__qarg_key_nth:
|
||||
if (b == Byte_ascii.Null && qargs.Len() == 0) // handle A?b but not A?b=c&d
|
||||
Append_to_last_path(Byte_ascii.Question, Make_bry(qarg_key_bgn, src_end));
|
||||
else {
|
||||
qargs.Add(Make_bry(qarg_key_bgn, pos));
|
||||
qarg_val_bgn = pos + 1;
|
||||
area = Area__qarg_val;
|
||||
}
|
||||
break;
|
||||
case Area__qarg_val:
|
||||
qargs.Add(Make_bry(qarg_val_bgn, pos));
|
||||
qarg_key_bgn = pos + 1;
|
||||
qarg_val_bgn = -1;
|
||||
area = Area__qarg_key_nth;
|
||||
break;
|
||||
case Area__anch:
|
||||
if (b == Byte_ascii.Null && anch_bgn == src_end) // handle A# but not "A#B"
|
||||
Append_to_last_path(Byte_ascii.Hash, Make_bry(anch_bgn, src_end));
|
||||
else
|
||||
anch = Make_bry(anch_bgn, pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
encoded = false;
|
||||
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);
|
||||
}
|
||||
private Gfo_qarg_itm[] Make_qargs() {
|
||||
int qargs_len = qargs.Len(); if (qargs_len == 0) return Gfo_qarg_itm.Ary_empty;
|
||||
if (qargs_len % 2 == 1) ++qargs_len; // handle odd qargs; EX: ?A=B&C&D=E
|
||||
Gfo_qarg_itm[] rv = new Gfo_qarg_itm[qargs_len / 2];
|
||||
for (int i = 0; i < qargs_len; i += 2) {
|
||||
byte[] key = qargs.Get_at(i);
|
||||
int val_idx = i + 1;
|
||||
byte[] val = val_idx < qargs_len ? qargs.Get_at(val_idx) : null;
|
||||
rv[i / 2] = new Gfo_qarg_itm(key, val);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private void Append_to_last_path(byte b, byte[] append) {
|
||||
byte[] last_path = segs_ary.Get_at_last(); if (last_path == null) return;
|
||||
last_path = Bry_.Add_w_dlm(b, last_path, append);
|
||||
segs_ary.Set_at_last(last_path);
|
||||
}
|
||||
private void Append_to_last_path__qargs() {
|
||||
byte[] last_path = segs_ary.Get_at_last(); if (last_path == null) return;
|
||||
tmp_bfr.Add(last_path);
|
||||
int len = qargs.Len();
|
||||
if (len % 2 == 1) qargs.Add(null); // handle odd qargs
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
tmp_bfr.Add_byte(i == 0 ? Byte_ascii.Question : Byte_ascii.Amp);
|
||||
tmp_bfr.Add(qargs.Get_at(i));
|
||||
byte[] qarg_val = qargs.Get_at(i + 1);
|
||||
if (qarg_val != null) // handle "null" added above
|
||||
tmp_bfr.Add_byte_eq().Add(qarg_val);
|
||||
}
|
||||
qargs.Clear();
|
||||
segs_ary.Set_at_last(tmp_bfr.Xto_bry_and_clear());
|
||||
}
|
||||
public static final byte[] Bry_double_slash = new byte[] {Byte_ascii.Slash, Byte_ascii.Slash};
|
||||
}
|
||||
39
400_xowa/src/gplx/core/net/Gfo_url_parser_fxt.java
Normal file
39
400_xowa/src/gplx/core/net/Gfo_url_parser_fxt.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
class Gfo_url_parser_fxt {
|
||||
private final Gfo_url_parser parser = new Gfo_url_parser();
|
||||
private Gfo_url actl;
|
||||
public Gfo_url_parser_fxt Chk_protocol_tid(byte v) {Tfds.Eq_byte(v, actl.Protocol_tid(), "protocol_tid"); return this;}
|
||||
public Gfo_url_parser_fxt Chk_protocol_bry(String v) {Tfds.Eq_str(v, actl.Protocol_bry(), "protocol_bry"); return this;}
|
||||
public Gfo_url_parser_fxt Chk_site(String v) {Tfds.Eq_str(v, actl.Segs__get_at_1st(), "site"); return this;}
|
||||
public Gfo_url_parser_fxt Chk_page(String v) {Tfds.Eq_str(v, actl.Segs__get_at_nth(), "page"); return this;}
|
||||
public Gfo_url_parser_fxt Chk_anch(String v) {Tfds.Eq_str(v, actl.Anch(), "anch"); return this;}
|
||||
public Gfo_url_parser_fxt Chk_segs(String... ary) {Tfds.Eq_int(ary.length, actl.Segs().length, "segs_len"); Tfds.Eq_str_lines(String_.Concat_lines_nl(ary), String_.Concat_lines_nl(String_.Ary(actl.Segs())), "segs"); return this;}
|
||||
public Gfo_url_parser_fxt Chk_qargs(String... ary) {Tfds.Eq_str_lines(String_.To_str__as_kv_ary(ary), Gfo_qarg_itm.To_str(actl.Qargs()), "qargs"); return this;}
|
||||
public Gfo_url_parser_fxt Run_parse(String v) {
|
||||
this.actl = parser.Parse(Bry_.new_u8(v));
|
||||
return this;
|
||||
}
|
||||
public void Test_Parse_site_fast(String raw, String expd) {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
parser.Parse_site_fast(site_data, raw_bry, 0, raw_bry.length);
|
||||
String actl = String_.new_u8(raw_bry, site_data.Site_bgn(), site_data.Site_end());
|
||||
Tfds.Eq(expd, actl);
|
||||
} private final Gfo_url_site_data site_data = new Gfo_url_site_data();
|
||||
}
|
||||
124
400_xowa/src/gplx/core/net/Gfo_url_parser_tst.java
Normal file
124
400_xowa/src/gplx/core/net/Gfo_url_parser_tst.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
import org.junit.*;
|
||||
public class Gfo_url_parser_tst {
|
||||
private final Gfo_url_parser_fxt tstr = new Gfo_url_parser_fxt();
|
||||
@Test public void Protocol__relative() {
|
||||
tstr.Run_parse("//en.wikipedia.org").Chk_protocol_tid(Gfo_protocol_itm.Tid_relative_1).Chk_protocol_bry("//").Chk_site("en.wikipedia.org");
|
||||
}
|
||||
@Test public void Protocol__none() {
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/A").Chk_protocol_tid(Gfo_protocol_itm.Tid_unknown).Chk_segs("en.wikipedia.org", "wiki", "A");
|
||||
}
|
||||
@Test public void Site__parts__3() {
|
||||
tstr.Run_parse("https://en.wikipedia.org").Chk_protocol_tid(Gfo_protocol_itm.Tid_https).Chk_protocol_bry("https://").Chk_segs("en.wikipedia.org");
|
||||
}
|
||||
@Test public void Site__parts__2() {
|
||||
tstr.Run_parse("https://wikipedia.org").Chk_protocol_tid(Gfo_protocol_itm.Tid_https).Chk_segs("wikipedia.org");
|
||||
}
|
||||
@Test public void Site__parts__1() {
|
||||
tstr.Run_parse("https://wikipedia").Chk_protocol_tid(Gfo_protocol_itm.Tid_https).Chk_segs("wikipedia");
|
||||
}
|
||||
@Test public void Site__slash__none() {
|
||||
tstr.Run_parse("https:site").Chk_protocol_tid(Gfo_protocol_itm.Tid_https).Chk_site("site");
|
||||
}
|
||||
@Test public void Paths__1() {
|
||||
tstr.Run_parse("https://site/A").Chk_segs("site", "A");
|
||||
}
|
||||
@Test public void Paths__2() {
|
||||
tstr.Run_parse("https://site/wiki/A").Chk_segs("site", "wiki", "A");
|
||||
}
|
||||
@Test public void Paths__n() {
|
||||
tstr.Run_parse("https://site/wiki/A/B/C/D").Chk_segs("site", "wiki", "A", "B", "C", "D");
|
||||
}
|
||||
@Test public void Qargs__1() {
|
||||
tstr.Run_parse("https://site/A?B=C").Chk_page("A").Chk_qargs("B", "C");
|
||||
}
|
||||
@Test public void Qargs__2() {
|
||||
tstr.Run_parse("https://site/A?B=C&D=E").Chk_page("A").Chk_qargs("B", "C", "D", "E");
|
||||
}
|
||||
@Test public void Qargs__3() {
|
||||
tstr.Run_parse("https://site/A?B=C&D=E&F=G").Chk_page("A").Chk_qargs("B", "C", "D", "E", "F", "G");
|
||||
}
|
||||
@Test public void Qargs__ques__dupe__ques() {
|
||||
tstr.Run_parse("https://site/A?B?Y=Z").Chk_page("A?B").Chk_qargs("Y", "Z");
|
||||
}
|
||||
@Test public void Qargs__ques__dupe__amp() {
|
||||
tstr.Run_parse("https://site/A?B=C&D?Y=Z").Chk_page("A?B=C&D").Chk_qargs("Y", "Z");
|
||||
}
|
||||
@Test public void Qargs__ques__dupe__eq() {
|
||||
tstr.Run_parse("https://site/A?B=C?Y=Z").Chk_page("A?B=C").Chk_qargs("Y", "Z");
|
||||
}
|
||||
@Test public void Qargs__amp__dupe__ques() {
|
||||
tstr.Run_parse("https://site/A?B&Y=Z").Chk_page("A").Chk_qargs("B", null, "Y", "Z");
|
||||
}
|
||||
@Test public void Qargs__amp__dupe__amp() {
|
||||
tstr.Run_parse("https://site/A?B=C&D&Y=Z").Chk_page("A").Chk_qargs("B", "C", "D", null, "Y", "Z");
|
||||
}
|
||||
@Test public void Qargs__missing_val__0() {
|
||||
tstr.Run_parse("https://site/A?").Chk_page("A?").Chk_qargs();
|
||||
}
|
||||
@Test public void Qargs__missing_val__2() {
|
||||
tstr.Run_parse("https://site/A?B=C&D&F=G").Chk_page("A").Chk_qargs("B", "C", "D", null, "F", "G");
|
||||
}
|
||||
@Test public void Qargs__missing_val__n() {
|
||||
tstr.Run_parse("https://site/A?B=C&D=E&F").Chk_page("A").Chk_qargs("B", "C", "D", "E", "F", null);
|
||||
}
|
||||
@Test public void Qargs__site_less__missing__0() {
|
||||
tstr.Run_parse("A?B").Chk_segs("A?B").Chk_qargs();
|
||||
}
|
||||
@Test public void Qargs__site_less() {
|
||||
tstr.Run_parse("A?B=C&D=E").Chk_site("A").Chk_qargs("B", "C", "D", "E");
|
||||
}
|
||||
@Test public void Anch__basic() {
|
||||
tstr.Run_parse("https://site/A#B").Chk_page("A").Chk_anch("B");
|
||||
}
|
||||
@Test public void Anch__repeat__2() {
|
||||
tstr.Run_parse("https://site/A#B#C").Chk_page("A#B").Chk_anch("C");
|
||||
}
|
||||
@Test public void Anch__repeat__3() {
|
||||
tstr.Run_parse("https://site/A#B#C#D").Chk_page("A#B#C").Chk_anch("D");
|
||||
}
|
||||
@Test public void Anch__missing() {
|
||||
tstr.Run_parse("https://site/A#").Chk_page("A#").Chk_anch(null);
|
||||
}
|
||||
@Test public void Anch__missing__eos() {
|
||||
tstr.Run_parse("https://site/A#B#").Chk_page("A#B#").Chk_anch(null);
|
||||
}
|
||||
@Test public void Anch__qargs__basic() {
|
||||
tstr.Run_parse("https://site/A?B=C&D=E#F").Chk_page("A").Chk_qargs("B", "C", "D", "E").Chk_anch("F");
|
||||
}
|
||||
@Test public void Anch__qargs__repeat() {
|
||||
tstr.Run_parse("https://site/A?B=C#&D=E#F").Chk_page("A").Chk_qargs("B", "C#", "D", "E").Chk_anch("F");
|
||||
}
|
||||
@Test public void Anch__site_less() {
|
||||
tstr.Run_parse("A#B").Chk_site("A").Chk_anch("B");
|
||||
}
|
||||
@Test public void Encode__page() {
|
||||
tstr.Run_parse("http://site/A%27s").Chk_site("site").Chk_page("A's");
|
||||
}
|
||||
@Test public void Protocol_less__qargs() {
|
||||
tstr.Run_parse("Special:Search/Earth?fulltext=yes").Chk_segs("Special:Search", "Earth").Chk_page("Earth").Chk_qargs("fulltext", "yes");
|
||||
}
|
||||
@Test public void Parse_site_fast() {
|
||||
tstr.Test_Parse_site_fast("http://a.org/B" , "a.org");
|
||||
tstr.Test_Parse_site_fast("http://a.org" , "a.org");
|
||||
tstr.Test_Parse_site_fast("//a.org/B" , "a.org");
|
||||
tstr.Test_Parse_site_fast("//a.org/B:C" , "a.org");
|
||||
}
|
||||
}
|
||||
24
400_xowa/src/gplx/core/net/Gfo_url_site_data.java
Normal file
24
400_xowa/src/gplx/core/net/Gfo_url_site_data.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.core.net; import gplx.*; import gplx.core.*;
|
||||
public class Gfo_url_site_data {
|
||||
public boolean Rel() {return rel;} private boolean rel;
|
||||
public int Site_bgn() {return site_bgn;} private int site_bgn;
|
||||
public int Site_end() {return site_end;} private int site_end;
|
||||
public void Atrs_set(boolean rel, int bgn, int end) {this.rel = rel; this.site_bgn = bgn; this.site_end = end;}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class Http_request_parser {
|
||||
case Tid_x_requested_with: this.x_requested_with = Bry_.Mid(line, val_bgn, line_len); break;
|
||||
case Tid_cookie: this.cookie = Bry_.Mid(line, val_bgn, line_len); break;
|
||||
case Tid_referer: this.referer = Bry_.Mid(line, val_bgn, line_len); break;
|
||||
case Tid_content_length: this.content_length = Bry_.Xto_int_or(line, val_bgn, line_len, -1); break;
|
||||
case Tid_content_length: this.content_length = Bry_.To_int_or(line, val_bgn, line_len, -1); break;
|
||||
case Tid_content_type: Parse_content_type(val_bgn, line, line_len); break;
|
||||
case Tid_connection: this.connection = Bry_.Mid(line, val_bgn, line_len); break;
|
||||
case Tid_pragma: this.pragma = Bry_.Mid(line, val_bgn, line_len); break;
|
||||
@@ -146,7 +146,7 @@ public class Http_request_parser {
|
||||
private String To_str() {return Make_request_itm().To_str(tmp_bfr, Bool_.N);}
|
||||
private static final int Tid_get = 1, Tid_post = 2, Tid_host = 3, Tid_user_agent = 4, Tid_accept = 5, Tid_accept_language = 6, Tid_accept_encoding = 7, Tid_dnt = 8
|
||||
, Tid_x_requested_with = 9, Tid_cookie = 10, Tid_referer = 11, Tid_content_length = 12, Tid_content_type = 13, Tid_connection = 14, Tid_pragma = 15, Tid_cache_control = 16, Tid_origin = 17;
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_()
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_str_int("GET" , Tid_get)
|
||||
.Add_str_int("POST" , Tid_post)
|
||||
.Add_str_int("Host:" , Tid_host)
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.gfui; import gplx.*;
|
||||
public class Gfui_bnd_parser {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
|
||||
private Hash_adp_bry
|
||||
gfui_regy = Hash_adp_bry.ci_ascii_()
|
||||
, norm_regy = Hash_adp_bry.ci_ascii_()
|
||||
gfui_regy = Hash_adp_bry.ci_a7()
|
||||
, norm_regy = Hash_adp_bry.ci_a7()
|
||||
;
|
||||
private static final Gfui_bnd_tkn
|
||||
Itm_sym_plus = new_sym_(Gfui_bnd_tkn.Tid_sym_plus , new byte[] {Byte_ascii.Plus})
|
||||
@@ -106,7 +106,7 @@ public class Gfui_bnd_parser {
|
||||
if (tkn_bgn == -1) throw Err_.new_wo_type("invalid keycode.dot", "keycode", Bry_.Mid(src, tkn_bgn, itm_end));
|
||||
++tkn_bgn; // skip #
|
||||
}
|
||||
int keycode = Bry_.Xto_int_or(src, tkn_bgn, itm_end, -1); if (keycode == -1) throw Err_.new_wo_type("invalid keycode", "keycode", Bry_.Mid(src, tkn_bgn, itm_end));
|
||||
int keycode = Bry_.To_int_or(src, tkn_bgn, itm_end, -1); if (keycode == -1) throw Err_.new_wo_type("invalid keycode", "keycode", Bry_.Mid(src, tkn_bgn, itm_end));
|
||||
tkn = new Gfui_bnd_tkn(Gfui_bnd_tkn.Tid_key, keycode, Bry_.Empty, Bry_.Empty);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -103,12 +103,12 @@ public class Html_utl {
|
||||
return dirty ? bfr.Xto_bry_and_clear() : bry;
|
||||
}
|
||||
|
||||
private static final Btrie_slim_mgr unescape_trie = Btrie_slim_mgr.ci_ascii_()
|
||||
.Add_bry_bval(Html_entity_.Lt_bry , Byte_ascii.Lt)
|
||||
.Add_bry_bval(Html_entity_.Gt_bry , Byte_ascii.Gt)
|
||||
.Add_bry_bval(Html_entity_.Amp_bry , Byte_ascii.Amp)
|
||||
.Add_bry_bval(Html_entity_.Quote_bry , Byte_ascii.Quote)
|
||||
.Add_bry_bval(Html_entity_.Apos_num_bry , Byte_ascii.Apos)
|
||||
private static final Btrie_slim_mgr unescape_trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_bry_byte(Html_entity_.Lt_bry , Byte_ascii.Lt)
|
||||
.Add_bry_byte(Html_entity_.Gt_bry , Byte_ascii.Gt)
|
||||
.Add_bry_byte(Html_entity_.Amp_bry , Byte_ascii.Amp)
|
||||
.Add_bry_byte(Html_entity_.Quote_bry , Byte_ascii.Quote)
|
||||
.Add_bry_byte(Html_entity_.Apos_num_bry , Byte_ascii.Apos)
|
||||
;
|
||||
public static String Unescape_as_str(String src) {
|
||||
Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Gfo_i18n_mgr {
|
||||
public Gfo_i18n_mgr Add_txt_many(String key, String... ary) {return this;}
|
||||
}
|
||||
class Gfo_i18n_lng {
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Gfo_i18n_lng(String lng) {this.lng = lng;}
|
||||
public String Lng() {return lng;} private final String lng;
|
||||
public void Add(int src, byte[] key, byte[] val, boolean val_fmt_exists, Gfo_i18n_val_cmd val_cmd) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Php_itm_ {
|
||||
return rv;
|
||||
case Php_itm_.Tid_quote:
|
||||
byte[] bry = ((Php_itm_quote)itm).Val_obj_bry();
|
||||
rv = Bry_.Xto_int_or(bry, -1);
|
||||
rv = Bry_.To_int_or(bry, -1);
|
||||
return (rv == -1) ? or : rv;
|
||||
default:
|
||||
return or;
|
||||
|
||||
@@ -19,6 +19,6 @@ package gplx.php; import gplx.*;
|
||||
public class Php_itm_int implements Php_itm, Php_itm_sub, Php_key {
|
||||
public Php_itm_int(int v) {this.val_obj_int = v;}
|
||||
public byte Itm_tid() {return Php_itm_.Tid_int;}
|
||||
public byte[] Val_obj_bry() {return Bry_.XbyInt(val_obj_int);}
|
||||
public byte[] Val_obj_bry() {return Bry_.new_by_int(val_obj_int);}
|
||||
public int Val_obj_int() {return val_obj_int;} private int val_obj_int;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*;
|
||||
public class Php_parser {
|
||||
Php_lxr[] lxrs; int lxrs_len;
|
||||
int txt_bgn; Php_tkn_txt txt_tkn;
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_(); // NOTE:ci:PHP tkns are ASCII
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci:PHP tkns are ASCII
|
||||
byte[] src; int src_len; Php_tkn_wkr tkn_wkr; Php_tkn_factory tkn_factory = new Php_tkn_factory(); Php_ctx ctx = new Php_ctx();
|
||||
Php_parser_interrupt[] parser_interrupts = new Php_parser_interrupt[256];
|
||||
public Php_parser() {
|
||||
|
||||
@@ -147,7 +147,7 @@ public class Php_srl_parser {
|
||||
pos = bgn;
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Colon);
|
||||
int int_end = Skip_while_num(raw, raw_len, pos, true);
|
||||
int int_val = Bry_.Xto_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
int int_val = Bry_.To_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
pos = int_end;
|
||||
return int_val;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class Php_srl_parser {
|
||||
pos = bgn;
|
||||
pos = Chk(raw, pos + 1, Byte_ascii.Colon);
|
||||
int int_end = Skip_while_num(raw, raw_len, pos, true);
|
||||
int int_val = Bry_.Xto_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
int int_val = Bry_.To_int_or(raw, pos, int_end, Int_.MinValue);
|
||||
Php_srl_itm_int rv = factory.Int(pos, int_end, int_val);
|
||||
pos = int_end;
|
||||
return rv;
|
||||
|
||||
@@ -104,7 +104,7 @@ public class Php_text_itm_parser {
|
||||
//throw Err_mgr._.fmt_auto_(GRP_KEY, "dollar_is_last_char", String_.new_u8(raw));
|
||||
}
|
||||
int int_end = Find_fwd_non_int(raw, i + 1, raw_len); // +1 to search after $
|
||||
int int_val = Bry_.Xto_int_or(raw, i + 1, int_end, -1); // +1 to search after $
|
||||
int int_val = Bry_.To_int_or(raw, i + 1, int_end, -1); // +1 to search after $
|
||||
if (int_val == -1) {
|
||||
tmp_list.Add(new Php_text_itm_text(i, i + 1));
|
||||
continue;
|
||||
|
||||
@@ -59,7 +59,7 @@ class Php_tkn_var extends Php_tkn_base {
|
||||
class Php_tkn_num extends Php_tkn_base {
|
||||
public Php_tkn_num(int src_bgn, int src_end) {this.Src_rng_(src_bgn, src_end);}
|
||||
@Override public byte Tkn_tid() {return Php_tkn_.Tid_num;}
|
||||
public int Num_val_int(byte[] src) {return Bry_.Xto_int_or(src, this.Src_bgn(), this.Src_end(), Int_.MinValue);}
|
||||
public int Num_val_int(byte[] src) {return Bry_.To_int_or(src, this.Src_bgn(), this.Src_end(), Int_.MinValue);}
|
||||
}
|
||||
class Php_tkn_quote extends Php_tkn_base {
|
||||
public Php_tkn_quote(int src_bgn, int src_end, byte quote_tid) {this.Src_rng_(src_bgn, src_end); this.quote_tid = quote_tid;}
|
||||
|
||||
@@ -92,14 +92,14 @@ class Dsv_fld_parser_int implements Dsv_fld_parser {
|
||||
boolean pos_is_last = pos == src_len;
|
||||
byte b = pos_is_last ? row_dlm : src[pos];
|
||||
if (b == fld_dlm) {
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.Xto_int_or(src, fld_bgn, pos, -1));
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.To_int_or(src, fld_bgn, pos, -1));
|
||||
if (!pass) throw Dsv_fld_parser_.err_fld_unhandled(this, wkr, fld_idx, src, fld_bgn, pos);
|
||||
int rv = pos + 1; // fld_dlm is always 1 byte
|
||||
parser.Update_by_fld(rv);
|
||||
return rv;
|
||||
}
|
||||
else if (b == row_dlm) {
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.Xto_int_or(src, fld_bgn, pos, -1));
|
||||
boolean pass = wkr.Write_int(parser, fld_idx, pos, Bry_.To_int_or(src, fld_bgn, pos, -1));
|
||||
if (!pass) throw Dsv_fld_parser_.err_fld_unhandled(this, wkr, fld_idx, src, fld_bgn, pos);
|
||||
wkr.Commit_itm(parser, pos);
|
||||
int rv = pos + 1; // row_dlm is always 1 byte
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.urls.encoders.*;
|
||||
@@ -34,9 +34,11 @@ public interface Xoa_app {
|
||||
Xof_img_mgr File__img_mgr();
|
||||
Io_download_fmt File__download_fmt();
|
||||
Xoh_href_parser Html__href_parser();
|
||||
Xoh_href_wtr Html__href_wtr();
|
||||
Xoh_lnki_bldr Html__lnki_bldr();
|
||||
Xoa_css_extractor Html__css_installer();
|
||||
Xoh_bridge_mgr Html__bridge_mgr();
|
||||
Xoa_meta_mgr Meta_mgr();
|
||||
Xou_user User();
|
||||
Xowmf_mgr Wmf_mgr();
|
||||
boolean Xwiki_mgr__missing(byte[] domain);
|
||||
@@ -44,5 +46,4 @@ public interface Xoa_app {
|
||||
Gfo_usr_dlg Usr_dlg();
|
||||
Bry_bfr_mkr Utl__bfr_mkr();
|
||||
Url_encoder_mgr Utl__encoder_mgr();
|
||||
Xoa_url_parser Utl__url_parser();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.7.3.3";
|
||||
public static final String Version = "2.8.1.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
|
||||
118
400_xowa/src/gplx/xowa/Xoa_url.java
Normal file
118
400_xowa/src/gplx/xowa/Xoa_url.java
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.net.*; import gplx.xowa.urls.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
public class Xoa_url {
|
||||
public int Tid() {return tid;} private int tid;
|
||||
public byte[] Raw() {return raw;} private byte[] raw = Bry_.Empty;
|
||||
public byte[] Wiki_bry() {return wiki_bry;} public Xoa_url Wiki_bry_(byte[] v) {wiki_bry = v; return this;} private byte[] wiki_bry;
|
||||
public byte[] Page_bry() {return page_bry;} public Xoa_url Page_bry_(byte[] v) {page_bry = v; return this;} private byte[] page_bry;
|
||||
public byte[] Anch_bry() {return anch_bry;} public Xoa_url Anch_bry_(byte[] v) {anch_bry = v; return this;} private byte[] anch_bry;
|
||||
public String Anch_str() {return anch_bry == null ? null : String_.new_u8(anch_bry);}
|
||||
public byte[][] Segs_ary() {return segs_ary;} private byte[][] segs_ary;
|
||||
public Gfo_qarg_itm[] Qargs_ary() {return qargs_ary;} public Xoa_url Qargs_ary_(Gfo_qarg_itm[] v) {qargs_ary = v; return this;} private Gfo_qarg_itm[] qargs_ary = Gfo_qarg_itm.Ary_empty;
|
||||
public Gfo_qarg_mgr Qargs_mgr() {if (qargs_mgr == null) qargs_mgr = new Gfo_qarg_mgr().Load(qargs_ary); return qargs_mgr;} private Gfo_qarg_mgr qargs_mgr;
|
||||
public byte Protocol_tid() {return protocol_tid;} private byte protocol_tid;
|
||||
public byte[] Protocol_bry() {return protocol_bry;} private byte[] protocol_bry;
|
||||
public boolean Protocol_is_relative() {return protocol_is_relative;} private boolean protocol_is_relative;
|
||||
public byte[] Vnt_bry() {return vnt_bry;} private byte[] vnt_bry;
|
||||
public boolean Wiki_is_missing() {return wiki_is_missing;} private boolean wiki_is_missing;
|
||||
public boolean Wiki_is_same() {return wiki_is_same;} private boolean wiki_is_same;
|
||||
public boolean Page_is_main() {return page_is_main;} private boolean page_is_main;
|
||||
public Xoa_url Ctor(int tid, byte[] raw, byte protocol_tid, byte[] protocol_bry, boolean protocol_is_relative
|
||||
, byte[] wiki, byte[] page, Gfo_qarg_itm[] qargs, byte[] anch
|
||||
, byte[][] segs_ary, byte[] vnt_bry, boolean wiki_is_missing, boolean wiki_is_same, boolean page_is_main) {
|
||||
this.tid = tid; this.raw = raw;
|
||||
this.protocol_tid = protocol_tid; this.protocol_bry = protocol_bry; this.protocol_is_relative = protocol_is_relative;
|
||||
this.wiki_bry = wiki; this.page_bry = page; this.qargs_ary = qargs; this.anch_bry = anch;
|
||||
this.segs_ary = segs_ary; this.vnt_bry = vnt_bry;
|
||||
this.wiki_is_missing = wiki_is_missing; this.wiki_is_same = wiki_is_same; this.page_is_main = page_is_main;
|
||||
return this;
|
||||
}
|
||||
public byte[] Page_for_lnki() {
|
||||
int raw_len = raw.length;
|
||||
int page_bgn = Page_bgn(raw_len);
|
||||
if (page_bgn == Bry_.NotFound) // no /wiki/ found; return page
|
||||
return page_bry == null ? Bry_.Empty : page_bry; // guard against null ref
|
||||
else
|
||||
return Bry_.Mid(raw, page_bgn, raw_len);// else take everything after "/wiki/";
|
||||
}
|
||||
private int Page_bgn(int raw_len) {
|
||||
int wiki_pos = Bry_finder.Find_fwd(raw, Xoh_href_.Bry__wiki, 0, raw_len); // look for /wiki/
|
||||
return wiki_pos == Bry_.NotFound ? Bry_.NotFound : wiki_pos + Xoh_href_.Bry__wiki.length;
|
||||
}
|
||||
public boolean Eq_page(Xoa_url comp) {return Bry_.Eq(wiki_bry, comp.wiki_bry) && Bry_.Eq(page_bry, comp.page_bry) && this.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes) == comp.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes);}
|
||||
public String To_str() {return String_.new_u8(To_bry(Bool_.Y, Bool_.Y));}
|
||||
public byte[] To_bry_page_w_anch() {
|
||||
byte[] page = page_bry, anch = anch_bry;
|
||||
byte[] anch_spr = anch == null ? null : Byte_ascii.Hash_bry;
|
||||
return Bry_.Add(page, anch_spr, anch);
|
||||
}
|
||||
public byte[] To_bry_full_wo_qargs() {return To_bry(Bool_.Y, Bool_.N);}
|
||||
public byte[] To_bry(boolean full, boolean show_qargs) { // currently used for status bar; not embedded in any html
|
||||
switch (tid) {
|
||||
case Xoa_url_.Tid_unknown: // unknown; should not occur?
|
||||
return Bry_.Len_eq_0(raw) ? Bry_.Add(wiki_bry, Byte_ascii.Slash_bry, page_bry) : raw; // raw is empty when using new_();
|
||||
case Xoa_url_.Tid_inet: // protocol; embed all; EX: "http://a.org/A"; "file:///C/dir/file.txt"
|
||||
case Xoa_url_.Tid_file: // file; EX: "file:///C:/A/B.jpg"
|
||||
return raw;
|
||||
case Xoa_url_.Tid_xcmd: // xcmd; embed page only; EX: "xowa.usr.bookmarks.add"
|
||||
return page_bry;
|
||||
default:
|
||||
throw Err_.new_unhandled(tid);
|
||||
case Xoa_url_.Tid_anch:
|
||||
case Xoa_url_.Tid_page:
|
||||
break;
|
||||
}
|
||||
byte[] wiki = wiki_bry, page = page_bry, anch = anch_bry;
|
||||
byte[] wiki_spr = vnt_bry == null ? Xoh_href_.Bry__wiki : Bry_.Add(Byte_ascii.Slash_bry, vnt_bry, Byte_ascii.Slash_bry);
|
||||
byte[] anch_spr = anch == null ? null : Byte_ascii.Hash_bry;
|
||||
if (!full) {
|
||||
boolean tid_is_anch = tid == Xoa_url_.Tid_anch;
|
||||
if ( wiki_is_same // same wiki; don't show wiki; EX: "/wiki/A" -> "A" x> "en.wikipedia.org/wiki/A"
|
||||
|| tid_is_anch) { // anch never shows wiki; EX: #A
|
||||
wiki = wiki_spr = null; // don't show wiki;
|
||||
}
|
||||
if (tid_is_anch)
|
||||
page = null;
|
||||
}
|
||||
byte[] rv = Bry_.Add
|
||||
( wiki, wiki_spr // add wiki_key; EX: "en.wikipedia.org", "/wiki/"
|
||||
, page // add page; EX: "A"
|
||||
, anch_spr, anch // add anch EX: "#", "B"
|
||||
);
|
||||
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);
|
||||
return bfr.To_bry_and_rls();
|
||||
}
|
||||
else
|
||||
return rv;
|
||||
}
|
||||
public static final Xoa_url Null = null;
|
||||
public static Xoa_url blank() {return new Xoa_url();}
|
||||
public static Xoa_url new_(byte[] wiki, byte[] page) {
|
||||
Xoa_url rv = new Xoa_url();
|
||||
rv.Wiki_bry_(wiki);
|
||||
rv.Page_bry_(page);
|
||||
rv.tid = Xoa_url_.Tid_page;
|
||||
return rv;
|
||||
} Xoa_url() {}
|
||||
}
|
||||
33
400_xowa/src/gplx/xowa/Xoa_url_.java
Normal file
33
400_xowa/src/gplx/xowa/Xoa_url_.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
public class Xoa_url_ {
|
||||
public static final int Tid_unknown = 0, Tid_page = 1, Tid_anch = 2, Tid_inet = 3, Tid_file = 4, Tid_xcmd = 5;
|
||||
public static boolean Tid_is_pagelike(int tid) {
|
||||
switch (tid) {
|
||||
case Tid_page: case Tid_anch: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static final byte[]
|
||||
Qarg__redirect = Bry_.new_a7("redirect")
|
||||
, Qarg__redirect__yes = Bry_.new_a7("yes")
|
||||
, Qarg__action = Bry_.new_a7("action")
|
||||
, Qarg__action__edit = Bry_.new_a7("edit")
|
||||
;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.core.threads.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.urls.encoders.*; import gplx.xowa.apps.progs.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*; import gplx.xowa.apps.metas.*; import gplx.xowa.urls.encoders.*; import gplx.xowa.apps.progs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
|
||||
import gplx.xowa.bldrs.css.*;
|
||||
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
|
||||
@@ -37,6 +37,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
cfg_mgr = new Xoa_cfg_mgr(this);
|
||||
api_root = new Xoapi_root(this);
|
||||
user = new Xoue_user(this, user_dir);
|
||||
this.meta_mgr = new Xoa_meta_mgr(this);
|
||||
url_cmd_eval = new Xoa_fsys_eval(fsys_mgr, user.Fsys_mgr());
|
||||
fsys_mgr.Init_by_app(prog_mgr);
|
||||
log_wtr.Log_dir_(user.Fsys_mgr().App_temp_dir().GenSubDir("log"));
|
||||
@@ -45,7 +46,6 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
gui_mgr = new Xoa_gui_mgr(this);
|
||||
bldr = new Xob_bldr(this);
|
||||
file_mgr.Ctor_by_app(this);
|
||||
href_parser = new Xoh_href_parser(Xoa_app_.Utl__encoder_mgr().Href(), utl_url_parser.Url_parser());
|
||||
sanitizer = new Xop_sanitizer(parser_amp_mgr, msg_log);
|
||||
user_mgr = new Xou_user_mgr(this, user);
|
||||
sys_cfg = new Xoa_sys_cfg(this);
|
||||
@@ -61,21 +61,22 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
http_server = new Http_server_mgr(this);
|
||||
cfg_regy = new Xocfg_regy(this);
|
||||
html_mgr = new Xoh_html_mgr(this);
|
||||
this.html__lnki_bldr = new Xoh_lnki_bldr(this, href_parser);
|
||||
this.html__lnki_bldr = new Xoh_lnki_bldr(this, html__href_wtr);
|
||||
}
|
||||
public Xoa_app_type App_type() {return app_type;} private final Xoa_app_type app_type;
|
||||
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
|
||||
public Xof_cache_mgr File__cache_mgr() {return file_mgr.Cache_mgr();}
|
||||
public Xof_img_mgr File__img_mgr() {return file_mgr.Img_mgr();}
|
||||
public Io_download_fmt File__download_fmt() {return wmf_mgr.Download_wkr().Download_xrg().Download_fmt();}
|
||||
public Xoh_href_parser Html__href_parser() {return href_parser;} private Xoh_href_parser href_parser;
|
||||
public Xoh_href_parser Html__href_parser() {return html__href_parser;} private final Xoh_href_parser html__href_parser = new Xoh_href_parser();
|
||||
public Xoh_href_wtr Html__href_wtr() {return html__href_wtr;} private final Xoh_href_wtr html__href_wtr = new Xoh_href_wtr();
|
||||
public Xoh_lnki_bldr Html__lnki_bldr() {return html__lnki_bldr;} private final Xoh_lnki_bldr html__lnki_bldr;
|
||||
public Xoa_css_extractor Html__css_installer() {return html__css_installer;} private final Xoa_css_extractor html__css_installer = new Xoa_css_extractor();
|
||||
public Xoh_bridge_mgr Html__bridge_mgr() {return html__bridge_mgr;} private final Xoh_bridge_mgr html__bridge_mgr = new Xoh_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 Xoa_url_parser Utl__url_parser() {return utl_url_parser;} private final Xoa_url_parser utl_url_parser = new Xoa_url_parser();
|
||||
public Xoa_meta_mgr Meta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
|
||||
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
|
||||
|
||||
public Xoae_wiki_mgr Wiki_mgr() {return wiki_mgr;} private Xoae_wiki_mgr wiki_mgr;
|
||||
@@ -99,7 +100,6 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
public Xoa_shell Shell() {return shell;} private Xoa_shell shell;
|
||||
public Xoa_thread_mgr Thread_mgr() {return thread_mgr;} private Xoa_thread_mgr thread_mgr = new Xoa_thread_mgr();
|
||||
public Xoa_hive_mgr Hive_mgr() {return hive_mgr;} private Xoa_hive_mgr hive_mgr;
|
||||
public Xoh_href_parser Href_parser() {return href_parser;}
|
||||
public Xop_sanitizer Sanitizer() {return sanitizer;} private Xop_sanitizer sanitizer;
|
||||
public Xop_xatr_parser Xatr_parser() {return xatr_parser;} private Xop_xatr_parser xatr_parser = new Xop_xatr_parser();
|
||||
public Xop_xnde_tag_regy Xnde_tag_regy() {return xnde_tag_regy;} private Xop_xnde_tag_regy xnde_tag_regy = new Xop_xnde_tag_regy();
|
||||
@@ -129,7 +129,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
|
||||
|
||||
public Xosrv_server Tcp_server() {return tcp_server;} private Xosrv_server tcp_server = new Xosrv_server();
|
||||
public Http_server_mgr Http_server() {return http_server;} private Http_server_mgr http_server;
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = new Xop_amp_mgr();
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = Xop_amp_mgr.I;
|
||||
|
||||
private Xoa_fmtr_mgr fmtr_mgr;
|
||||
public Number_parser Utl_num_parser() {return utl_num_parser;} private Number_parser utl_num_parser = new Number_parser();
|
||||
|
||||
@@ -48,6 +48,7 @@ public class Xoapi_root implements GfoInvkAble {
|
||||
public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr();
|
||||
public Xoapi_special Special() {return special_api;} private final Xoapi_special special_api = new Xoapi_special();
|
||||
public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
|
||||
public Xoapi_app_wikis Wikis() {return app_wikis;} private final Xoapi_app_wikis app_wikis = new Xoapi_app_wikis();
|
||||
public String Test_str() {return test_str;} public void Test_str_(String v) {test_str = v;} private String test_str; // TEST
|
||||
private void Exec(String key) {
|
||||
Xog_cmd_itm cmd_itm = app.Gui_mgr().Cmd_mgr().Get_or_null(key);
|
||||
@@ -65,6 +66,7 @@ public class Xoapi_root implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_special)) return special_api;
|
||||
else if (ctx.Match(k, Invk_xtns)) return xtns_api;
|
||||
else if (ctx.Match(k, Invk_exec)) Exec(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_wikis)) return app_wikis;
|
||||
else if (ctx.Match(k, Invk_test_str)) return test_str;
|
||||
else if (ctx.Match(k, Invk_test_str_)) test_str = m.ReadStr("v");
|
||||
return this;
|
||||
@@ -73,5 +75,6 @@ public class Xoapi_root implements GfoInvkAble {
|
||||
Invk_exec = "exec"
|
||||
, Invk_app = "app", Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_special = "special", Invk_xtns = "xtns"
|
||||
, Invk_test_str = "test_str", Invk_test_str_ = "test_str_"
|
||||
, Invk_wikis = "wikis"
|
||||
;
|
||||
}
|
||||
|
||||
29
400_xowa/src/gplx/xowa/apis/xowa/Xoapi_app_wiki.java
Normal file
29
400_xowa/src/gplx/xowa/apis/xowa/Xoapi_app_wiki.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.apis.xowa.wikis.*;
|
||||
public class Xoapi_app_wiki implements GfoInvkAble {
|
||||
public Xoapi_wiki_lang Lang() {return lang;} private final Xoapi_wiki_lang lang = new Xoapi_wiki_lang();
|
||||
public void Subscribe(GfoEvObj sub) {lang.Subscribe(sub);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_lang)) return lang;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_lang = "lang";
|
||||
public static final Xoapi_app_wiki Dflt = new Xoapi_app_wiki();
|
||||
}
|
||||
34
400_xowa/src/gplx/xowa/apis/xowa/Xoapi_app_wikis.java
Normal file
34
400_xowa/src/gplx/xowa/apis/xowa/Xoapi_app_wikis.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
|
||||
public class Xoapi_app_wikis implements GfoInvkAble {
|
||||
private final Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
public Xoapi_app_wiki Get(byte[] domain) {
|
||||
Xoapi_app_wiki rv = (Xoapi_app_wiki)hash.Get_by(domain);
|
||||
if (rv == null) {
|
||||
rv = new Xoapi_app_wiki();
|
||||
hash.Add(domain, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_get = "get";
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class Xoapi_url implements GfoInvkAble {
|
||||
public void Exec_new_tab_by_paste() {Exec_wkr(Bool_.Y, ClipboardAdp_.GetText());}
|
||||
public void Restore() {
|
||||
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
this.Url_box().Text_(tab.Page().Url().Xto_full_str());
|
||||
this.Url_box().Text_(tab.Page().Url().To_str());
|
||||
}
|
||||
private void Exec_wkr(boolean new_tab, String urls_text) {
|
||||
if (Op_sys.Cur().Tid_is_wnt())
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xoapi_selection implements GfoInvkAble {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
Xog_html_itm html_itm = win.Tab_mgr().Active_tab().Html_itm();
|
||||
String src = html_itm.Html_selected_get_src_or_empty();
|
||||
if (String_.Len_eq_0(src)) {app.Usr_dlg().Prog_many("", "", "no file selected: tab=~{0}", html_itm.Owner_tab().Page().Url().Xto_full_str()); return;}
|
||||
if (String_.Len_eq_0(src)) {app.Usr_dlg().Prog_many("", "", "no file selected: tab=~{0}", html_itm.Owner_tab().Page().Url().To_str()); return;}
|
||||
Io_url src_url = Io_url_.http_any_(src, Op_sys.Cur().Tid_is_wnt());
|
||||
String trg_name = src_url.NameAndExt();
|
||||
if (String_.Has(src, "/thumb/")) trg_name = src_url.OwnerDir().NameOnly();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xoapi_wiki implements GfoInvkAble {
|
||||
public void Sandbox() {win.Page__navigate_by_url_bar("Project:Sandbox");}
|
||||
public void Main_page() {
|
||||
win.Tab_mgr().Active_tab_assert(); // force an active tab in case all tabs are closed; needed for win.Active_page() below; DATE:2014-09-17
|
||||
win.Page__navigate_by_url_bar(win.Active_tab().Wiki().Domain_str() + Xoh_href_parser.Href_wiki_str); // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
|
||||
win.Page__navigate_by_url_bar(win.Active_tab().Wiki().Domain_str() + Xoh_href_.Str__wiki); // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_main_page)) this.Main_page();
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
import gplx.xowa.gui.history.*; import gplx.xowa.gui.views.*;
|
||||
import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xoapi_bookmarks implements GfoInvkAble {
|
||||
private Xoae_app app; private Xog_win_itm win;
|
||||
public void Ctor_by_app(Xoae_app app) {this.app = app;}
|
||||
@@ -30,20 +31,11 @@ public class Xoapi_bookmarks implements GfoInvkAble {
|
||||
if (!enabled) return app.Html__bridge_mgr().Msg_bldr().To_json_str__empty();
|
||||
Xoa_url url = null;
|
||||
if (url_str == null) {
|
||||
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return app.Html__bridge_mgr().Msg_bldr().Clear().Notify_pass_("bookmark added").To_json_str();
|
||||
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return app.Html__bridge_mgr().Msg_bldr().Clear().Notify_pass_("bookmark added").To_json_str(); // called by http_server; return success
|
||||
url = tab.Page().Url();
|
||||
if (url.Wiki_bry() == null) {
|
||||
url_str = "home/wiki/" + String_.new_u8(url.Page_bry());
|
||||
}
|
||||
else if (url.Page_bry() == null) {
|
||||
url_str = tab.Wiki().Domain_str() + "/wiki/" + String_.new_u8(url.Wiki_bry());
|
||||
}
|
||||
else
|
||||
url_str = String_.new_u8(url.Raw());
|
||||
url = app.Utl__url_parser().Parse(Bry_.new_u8(url_str));
|
||||
}
|
||||
else
|
||||
url = app.Utl__url_parser().Parse(Bry_.new_u8(url_str));
|
||||
url = app.User().Wikii().Utl__url_parser().Parse(Bry_.new_u8(url_str));
|
||||
app.User().User_db_mgr().Bmk_mgr().Itms__add(Xoud_bmk_mgr.Owner_root, url);
|
||||
String msg = "bookmark added: " + String_.new_u8(url.Page_bry());
|
||||
String rv = app.Html__bridge_mgr().Msg_bldr().Clear().Notify_pass_(msg).To_json_str();
|
||||
|
||||
28
400_xowa/src/gplx/xowa/apis/xowa/wikis/Xoapi_wiki_lang.java
Normal file
28
400_xowa/src/gplx/xowa/apis/xowa/wikis/Xoapi_wiki_lang.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
|
||||
import gplx.xowa.apis.xowa.wikis.langs.*;
|
||||
public class Xoapi_wiki_lang implements GfoInvkAble {
|
||||
public Xoap_lang_variants Variants() {return variants;} private final Xoap_lang_variants variants = new Xoap_lang_variants();
|
||||
public void Subscribe(GfoEvObj sub) {variants.Subscribe(sub);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_variants)) return variants;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_variants = "variants";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.wikis.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.wikis.*;
|
||||
public class Xoap_lang_variants implements GfoInvkAble, GfoEvMgrOwner {
|
||||
public Xoap_lang_variants() {
|
||||
this.ev_mgr = GfoEvMgr.new_(this);
|
||||
}
|
||||
public GfoEvMgr EvMgr() {return ev_mgr;} private final GfoEvMgr ev_mgr;
|
||||
public byte[] Current() {return current;} private byte[] current;
|
||||
public void Current_(byte[] v) {
|
||||
this.current = v;
|
||||
GfoEvMgr_.PubVal(this, Evt_current_changed, v);
|
||||
}
|
||||
public void Subscribe(GfoEvObj sub) {
|
||||
GfoEvMgr_.SubSame(this, Evt_current_changed, sub);
|
||||
if (current != null) GfoInvkAble_.InvkCmd_val(sub, Evt_current_changed, current);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_current)) return String_.new_u8(current);
|
||||
else if (ctx.Match(k, Invk_current_)) Current_(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_current = "current", Invk_current_ = "current_";
|
||||
public static final String
|
||||
Evt_current_changed = "current_changed"
|
||||
;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class Xoa_app_type {
|
||||
}
|
||||
private static final int Uid_cmd = 1, Uid_gui = 2, Uid_tcp = 3, Uid_http = 4, Uid_file = 5;
|
||||
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_gui = Bry_.new_a7("gui"), Key_tcp = Bry_.new_a7("server"), Key_http = Bry_.new_a7("http_server"), Key_file = Bry_.new_a7("file");
|
||||
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs_()
|
||||
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
|
||||
.Add_bry_int(Key_cmd , Uid_cmd)
|
||||
.Add_bry_int(Key_gui , Uid_gui)
|
||||
.Add_bry_int(Key_http , Uid_http)
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Xoa_gfs_php_mgr {
|
||||
)
|
||||
throw Err_.new_wo_type("invalid gfs; num_end not found", "src", String_.new_u8(src));
|
||||
bfr.Add_byte(Byte_ascii.Dollar);
|
||||
int arg_idx = Bry_.Xto_int_or(src, num_bgn, num_end, -1);
|
||||
int arg_idx = Bry_.To_int_or(src, num_bgn, num_end, -1);
|
||||
if (arg_idx == -1) {
|
||||
throw Err_.new_wo_type("invalid int");
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class Xoa_gfs_php_mgr {
|
||||
break;
|
||||
case Byte_ascii.Dollar:
|
||||
int end_pos = Php_text_itm_parser.Find_fwd_non_int(raw, i + 1, raw_len);
|
||||
int int_val = Bry_.Xto_int_or(raw, i + 1, end_pos, -1);
|
||||
int int_val = Bry_.To_int_or(raw, i + 1, end_pos, -1);
|
||||
bfr.Add_byte(Bry_fmtr.char_escape).Add_byte(Bry_fmtr.char_arg_bgn).Add_int_variable(int_val - 1).Add_byte(Bry_fmtr.char_arg_end);
|
||||
i = end_pos - 1;
|
||||
break;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.apps.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
public class Wdata_doc_cache {
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public void Add(byte[] qid, Wdata_doc doc) {hash.Add(qid, doc);}
|
||||
public Wdata_doc Get_or_null(byte[] qid) {return (Wdata_doc)hash.Get_by_bry(qid);}
|
||||
public void Free_mem_all() {this.Clear();}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Xoa_fsys_eval implements Bry_fmtr_eval_mgr {
|
||||
}
|
||||
}
|
||||
private static final byte Tid_bin_plat_dir = 0, Tid_user_temp_dir = 1, Tid_xowa_root_dir = 2, Tid_user_cfg_dir = 3;
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.ci_ascii_()
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("bin_plat_dir" , Tid_bin_plat_dir)
|
||||
.Add_str_byte("user_temp_dir" , Tid_user_temp_dir)
|
||||
.Add_str_byte("xowa_root_dir" , Tid_xowa_root_dir)
|
||||
|
||||
24
400_xowa/src/gplx/xowa/apps/metas/Xoa_meta_mgr.java
Normal file
24
400_xowa/src/gplx/xowa/apps/metas/Xoa_meta_mgr.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
public class Xoa_meta_mgr {
|
||||
public Xoa_meta_mgr(Xoa_app app) {
|
||||
this.ns_mgr = new Xoa_ns_mgr(app);
|
||||
}
|
||||
public Xoa_ns_mgr Ns_mgr() {return ns_mgr;} private final Xoa_ns_mgr ns_mgr;
|
||||
}
|
||||
49
400_xowa/src/gplx/xowa/apps/metas/Xoa_ns_mgr.java
Normal file
49
400_xowa/src/gplx/xowa/apps/metas/Xoa_ns_mgr.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.wmfs.data.*;
|
||||
public class Xoa_ns_mgr {
|
||||
private final Xoa_app app;
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private Xowmf_site_tbl wmf_site_tbl; private Xowmf_ns_tbl wmf_ns_tbl;
|
||||
public Xoa_ns_mgr(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public void Add(byte[] wiki_domain, Xow_ns_mgr ns_mgr) {hash.Add(wiki_domain, ns_mgr);} // TEST:
|
||||
public Xow_ns_mgr Get_or_load(byte[] wiki_domain) {
|
||||
Xow_ns_mgr rv = (Xow_ns_mgr)hash.Get_by_bry(wiki_domain);
|
||||
if (rv == null) {
|
||||
rv = Load(wiki_domain);
|
||||
Add(wiki_domain, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private Xow_ns_mgr Load(byte[] wiki_domain) {
|
||||
Xow_ns_mgr rv = new Xow_ns_mgr(Xol_case_mgr_.U8());
|
||||
if (wmf_site_tbl == null) {
|
||||
Db_conn conn = Xowmf_site_tbl.Get_conn_or_new(app.Fsys_mgr().Root_dir());
|
||||
wmf_site_tbl = new Xowmf_site_tbl(conn);
|
||||
wmf_ns_tbl = new Xowmf_ns_tbl(conn);
|
||||
}
|
||||
int site_id = wmf_site_tbl.Select_id(String_.new_u8(wiki_domain));
|
||||
wmf_ns_tbl.Select_all(rv, site_id);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
|
||||
Exec_commit(-1, -1, -1, Bry_.Empty);
|
||||
Exec_end_hook();
|
||||
Free();
|
||||
usr_dlg.Note_many("", "", "done: ~{0} ~{1}", exec_count, DecimalAdp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).Xto_str("#,###.000"));
|
||||
usr_dlg.Note_many("", "", "done: ~{0} ~{1}", exec_count, Decimal_adp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).To_str("#,###.000"));
|
||||
}
|
||||
private void Free() {
|
||||
ctx.App().Free_mem(true);
|
||||
@@ -294,9 +294,9 @@ class Xob_rate_mgr {
|
||||
}
|
||||
private void Save(int count, long bgn, long end) {
|
||||
int dif = (int)(end - bgn) / 1000;
|
||||
DecimalAdp rate = DecimalAdp_.divide_safe_(count, dif);
|
||||
Decimal_adp rate = Decimal_adp_.divide_safe_(count, dif);
|
||||
save_bfr
|
||||
.Add_str(rate.Xto_str("#,##0.000")).Add_byte_pipe()
|
||||
.Add_str(rate.To_str("#,##0.000")).Add_byte_pipe()
|
||||
.Add_int_variable(count).Add_byte_pipe()
|
||||
.Add_int_variable(dif).Add_byte_nl()
|
||||
;
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.bldrs.cmds.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.core.btries.*;
|
||||
class Uca_trie {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
public void Init() {
|
||||
Init_itm(1, Bry_.ints_(1,1));
|
||||
Init_itm(2, Bry_.ints_(1,1));
|
||||
@@ -1043,7 +1044,7 @@ Init_itm(1021, Bry_.ints_(91,74,1,5,1,143));
|
||||
Init_itm(1022, Bry_.ints_(91,72,1,5,1,143));
|
||||
Init_itm(1023, Bry_.ints_(91,76,1,5,1,143));
|
||||
Init_itm(1024, Bry_.ints_(92,52,1,134,143,1,143,5));
|
||||
} private Btrie_slim_mgr trie = Btrie_slim_mgr.cs_();
|
||||
}
|
||||
public void Clear() {trie.Clear();}
|
||||
public void Decode(Bry_bfr tmp, byte[] src, int bgn, int end) {
|
||||
int i = bgn;
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implement
|
||||
parser.Fld_cmd_(this).Flds_req_(Fld_cl_from, Fld_cl_to, Fld_cl_timestamp, Fld_cl_collation, Fld_cl_sortkey, Fld_cl_type);
|
||||
}
|
||||
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
|
||||
if (Bry_.Eq(fld_key, Fld_cl_from)) cur_id = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1);
|
||||
if (Bry_.Eq(fld_key, Fld_cl_from)) cur_id = Bry_.To_int_or(src, fld_bgn, fld_end, -1);
|
||||
else if (Bry_.Eq(fld_key, Fld_cl_to)) cur_ctg = Bry_.Mid(src, fld_bgn, fld_end);
|
||||
else if (Bry_.Eq(fld_key, Fld_cl_collation)) cur_collation_is_uca = Bry_.Has_at_bgn(src, Collation_uca, fld_bgn, fld_end);
|
||||
else if (Bry_.Eq(fld_key, Fld_cl_timestamp)) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class Xoctg_hiddencat_parser_base extends Xob_sql_dump_base impl
|
||||
}
|
||||
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
|
||||
switch (fld_idx) {
|
||||
case Fld_id: cur_id = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_id: cur_id = Bry_.To_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_key: cur_is_hiddencat = Bry_.Eq(Key_hiddencat, src, fld_bgn, fld_end); break;
|
||||
case Fld_val:
|
||||
if (!cur_is_hiddencat) {data.Cancel_row_y_(); return;}
|
||||
|
||||
@@ -38,7 +38,7 @@ class Xob_bin_db_itm {
|
||||
public static Xob_bin_db_itm new_v1(Fsm_bin_fil fil) {
|
||||
byte[] name = Bry_.new_u8(fil.Url_rel()); // EX: "fsdb.bin.0000.sqlite3"
|
||||
int ns_id = 0; // assume v1 dbs are all in main ns
|
||||
int pt_id = Bry_.Xto_int_or(name, 9 , 13, Int_.MinValue); if (pt_id == Int_.MinValue) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
int pt_id = Bry_.To_int_or(name, 9 , 13, Int_.MinValue); if (pt_id == Int_.MinValue) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
return new Xob_bin_db_itm(fil.Id(), fil.Url(), ns_id, pt_id);
|
||||
}
|
||||
public static Xob_bin_db_itm new_v2(Fsm_bin_fil fil) {
|
||||
@@ -50,8 +50,8 @@ class Xob_bin_db_itm {
|
||||
int ns_end = Bry_finder.Find_fwd(name, ns_end_tkn, ns_bgn); if (ns_end == Bry_finder.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_end", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
int pt_bgn = ns_end + ns_end_tkn_len;
|
||||
int pt_end = Bry_finder.Find_fwd(name, pt_end_tkn, pt_bgn); if (pt_end == Bry_finder.Not_found) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_end", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
int ns_id = Bry_.Xto_int_or(name, ns_bgn, ns_end, Int_.MinValue); if (ns_id == Int_.MinValue) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
int pt_id = Bry_.Xto_int_or(name, pt_bgn, pt_end, Int_.MinValue); if (pt_id == Int_.MinValue) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
int ns_id = Bry_.To_int_or(name, ns_bgn, ns_end, Int_.MinValue); if (ns_id == Int_.MinValue) throw Err_.new_wo_type("bin_db_itm.parse: invalid ns_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
int pt_id = Bry_.To_int_or(name, pt_bgn, pt_end, Int_.MinValue); if (pt_id == Int_.MinValue) throw Err_.new_wo_type("bin_db_itm.parse: invalid pt_id", "name", fil.Url_rel(), "conn", fil.Conn().Conn_info().Xto_raw());
|
||||
return new Xob_bin_db_itm(fil.Id(), fil.Url(), ns_id, pt_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
if (exit_after_commit) exit_now = true;
|
||||
}
|
||||
public void Cmd_end() {
|
||||
usr_dlg.Note_many("", "", "fsdb_make.done: count=~{0} rate=~{1}", exec_count, DecimalAdp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).Xto_str("#,###.000"));
|
||||
usr_dlg.Note_many("", "", "fsdb_make.done: count=~{0} rate=~{1}", exec_count, Decimal_adp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).To_str("#,###.000"));
|
||||
if (src_fsdb_wkr != null) {
|
||||
src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Txn_end(); // NOTE: src_fsdb_wkr will be null if no src db defined
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ public class Xob_image_cmd extends Xob_itm_dump_base implements Xob_cmd, GfoInvk
|
||||
public void Exec(byte[] src, byte[] fld_key, int fld_idx, int fld_bgn, int fld_end, Bry_bfr file_bfr, Sql_file_parser_data data) {
|
||||
switch (fld_idx) {
|
||||
case Fld_img_name: cur_ttl = Bry_.Mid(src, fld_bgn, fld_end); break;
|
||||
case Fld_img_size: cur_size = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_width: cur_width = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_height: cur_height = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_bits: cur_bits = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_size: cur_size = Bry_.To_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_width: cur_width = Bry_.To_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_height: cur_height = Bry_.To_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_bits: cur_bits = Bry_.To_int_or(src, fld_bgn, fld_end, -1); break;
|
||||
case Fld_img_media_type: cur_media_type = Bry_.Mid(src, fld_bgn, fld_end); break;
|
||||
case Fld_img_minor_mime: cur_minor_mime = Bry_.Mid(src, fld_bgn, fld_end); break;
|
||||
case Fld_img_timestamp: cur_timestamp = Bry_.Mid(src, fld_bgn, fld_end);
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.bldrs.css; import gplx.*; import gplx.xowa.*; import gplx.xowa
|
||||
import gplx.ios.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.files.downloads.*;
|
||||
import gplx.core.net.*;
|
||||
public class Xoa_css_extractor {
|
||||
public IoEngine_xrg_downloadFil Download_xrg() {return download_xrg;} private IoEngine_xrg_downloadFil download_xrg = Io_mgr.I.DownloadFil_args("", Io_url_.Empty);
|
||||
public Xoa_css_extractor Wiki_domain_(byte[] v) {wiki_domain = v; return this;} private byte[] wiki_domain;
|
||||
@@ -33,6 +34,7 @@ public class Xoa_css_extractor {
|
||||
public Xoa_css_extractor Url_encoder_(Url_encoder v) {url_encoder = v; return this;} private 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();
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
this.usr_dlg = app.Usr_dlg();
|
||||
Xof_download_wkr download_wkr = app.Wmf_mgr().Download_wkr();
|
||||
@@ -234,6 +236,7 @@ public class Xoa_css_extractor {
|
||||
int prv_pos = 0;
|
||||
int css_find_bgn_len = Css_find_bgn.length;
|
||||
byte[] protocol_prefix_bry = Bry_.new_u8(protocol_prefix);
|
||||
Gfo_url gfo_url = new Gfo_url();
|
||||
while (true) {
|
||||
int url_bgn = Bry_finder.Find_fwd(raw, Css_find_bgn, prv_pos); if (url_bgn == Bry_.NotFound) break; // nothing left; stop
|
||||
url_bgn += css_find_bgn_len;
|
||||
@@ -241,7 +244,10 @@ public class Xoa_css_extractor {
|
||||
byte[] css_url_bry = Bry_.Mid(raw, url_bgn, url_end);
|
||||
css_url_bry = Bry_.Replace(css_url_bry, Css_amp_find, Css_amp_repl); // & -> &
|
||||
css_url_bry = url_encoder.Decode(css_url_bry); // %2C -> %7C -> |
|
||||
css_url_bry = Bry_.Add(protocol_prefix_bry, css_url_bry);
|
||||
url_parser.Parse(gfo_url, css_url_bry, 0, css_url_bry.length);
|
||||
if ( gfo_url.Protocol_tid() == Gfo_protocol_itm.Tid_relative_1 // if rel url, add protocol_prefix DATE:2015-08-01
|
||||
|| (Env_.Mode_testing() && gfo_url.Protocol_tid() == Gfo_protocol_itm.Tid_unknown)) // TEST:
|
||||
css_url_bry = Bry_.Add(protocol_prefix_bry, css_url_bry);
|
||||
rv.Add(String_.new_u8(css_url_bry));
|
||||
prv_pos = url_end;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Xoa_css_img_downloader {
|
||||
int src_len = src.length;
|
||||
int prv_pos = 0;
|
||||
Bry_bfr bfr = Bry_bfr.new_(src_len);
|
||||
Hash_adp img_hash = Hash_adp_bry.cs_();
|
||||
Hash_adp img_hash = Hash_adp_bry.cs();
|
||||
while (true) {
|
||||
int url_pos = Bry_finder.Find_fwd(src, Bry_url, prv_pos);
|
||||
if (url_pos == Bry_.NotFound) {bfr.Add_mid(src, prv_pos, src_len); break;} // no more "url("; exit;
|
||||
|
||||
@@ -49,7 +49,7 @@ class Xob_css_parser {
|
||||
}
|
||||
}
|
||||
private static final byte Tkn_import = 1, Tkn_url = 2;
|
||||
private static final Btrie_slim_mgr tkns_trie = Btrie_slim_mgr.ci_ascii_()
|
||||
private static final Btrie_slim_mgr tkns_trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_str_byte("@import" , Tkn_import)
|
||||
.Add_str_byte(" url(" , Tkn_url)
|
||||
;
|
||||
|
||||
@@ -76,7 +76,7 @@ class Xob_url_fixer_tkn {
|
||||
private static Btrie_slim_mgr bgn_trie;
|
||||
public static Btrie_slim_mgr Bgn_trie() {
|
||||
if (bgn_trie == null) {
|
||||
bgn_trie = Btrie_slim_mgr.ci_ascii_();
|
||||
bgn_trie = Btrie_slim_mgr.ci_a7();
|
||||
trie_add(bgn_trie, Tid_bgn_slash_1 , "/");
|
||||
trie_add(bgn_trie, Tid_bgn_slash_2 , "//");
|
||||
trie_add(bgn_trie, Tid_bgn_http , "http://");
|
||||
@@ -88,7 +88,7 @@ class Xob_url_fixer_tkn {
|
||||
private static Btrie_slim_mgr mid_trie;
|
||||
public static Btrie_slim_mgr Mid_trie() {
|
||||
if (mid_trie == null) {
|
||||
mid_trie = Btrie_slim_mgr.ci_ascii_();
|
||||
mid_trie = Btrie_slim_mgr.ci_a7();
|
||||
trie_add(mid_trie, Tid_mid_rel_1 , "/../");
|
||||
trie_add(mid_trie, Tid_mid_rel_2 , "/./");
|
||||
trie_add(mid_trie, Tid_mid_slash , "/");
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.xowa.wikis.ttls.*;
|
||||
public class Xob_ttl_filter_mgr {
|
||||
private boolean exclude_is_empty = true, include_is_empty = true;
|
||||
private final Xob_ttl_filter_mgr_srl srl = new Xob_ttl_filter_mgr_srl();
|
||||
private Hash_adp_bry exclude_hash = Hash_adp_bry.cs_(), include_hash = Hash_adp_bry.cs_();
|
||||
private Hash_adp_bry exclude_hash = Hash_adp_bry.cs(), include_hash = Hash_adp_bry.cs();
|
||||
public void Clear() {
|
||||
exclude_hash.Clear();
|
||||
include_hash.Clear();
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xob_ttl_filter_mgr_srl_tst {
|
||||
}
|
||||
class Xob_ttl_filter_mgr_srl_fxt {
|
||||
private final Xob_ttl_filter_mgr_srl mgr = new Xob_ttl_filter_mgr_srl();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public void Clear() {
|
||||
hash.Clear();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class Dg_file {
|
||||
public Dg_rule[] Lines() {return lines;} private final Dg_rule[] lines;
|
||||
}
|
||||
class Dg_rule {// EX: < wikipedia ><-30>
|
||||
private final Hash_adp_bry word_idx_hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry word_idx_hash = Hash_adp_bry.cs();
|
||||
public Dg_rule(int file_id, int id, int idx, int tid, byte[] key, int score, Dg_word[] words) {
|
||||
this.file_id = file_id;
|
||||
this.id = id; this.idx = idx; this.tid = tid; this.key = key; this.score = score; this.words = words;
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.bldrs.filters.core.*;
|
||||
public class Dg_match_mgr {
|
||||
private int score_init, score_fail; private boolean log_enabled, case_match;
|
||||
private final Btrie_slim_mgr btrie = Btrie_slim_mgr.cs_();
|
||||
private final Btrie_slim_mgr btrie = Btrie_slim_mgr.cs();
|
||||
private final Ordered_hash rules = Ordered_hash_.new_bry_();
|
||||
private final Ordered_hash rule_group_hash = Ordered_hash_.new_bry_(), rule_tally_hash = Ordered_hash_.new_bry_();
|
||||
private final Dg_parser parser = new Dg_parser();
|
||||
|
||||
@@ -71,7 +71,7 @@ class Dg_parser {
|
||||
if (src[brack_bgn] != Byte_ascii.Lt) {Warn("dg.invalid_line.wrong_term_dlm", rel_path, line_idx, src, line_bgn, line_end); break;}
|
||||
brack_end = Bry_finder.Find_fwd(src, Byte_ascii.Gt, brack_bgn);
|
||||
if (brack_end == Bry_finder.Not_found) {Warn("dg.invalid_line.score not found", rel_path, line_idx, src, line_bgn, line_end); break;}
|
||||
int parse_score = Bry_.Xto_int_or(src, brack_bgn + 1, brack_end, Int_.MinValue);
|
||||
int parse_score = Bry_.To_int_or(src, brack_bgn + 1, brack_end, Int_.MinValue);
|
||||
if (parse_score == Int_.MinValue) {Warn("dg.invalid_line.score is invalid", rel_path, line_idx, src, line_bgn, line_end); break;}
|
||||
score = parse_score;
|
||||
break;
|
||||
|
||||
@@ -331,7 +331,7 @@ public class Xol_mw_lang_parser {
|
||||
, Tid_fallback = 5, Tid_rtl = 6
|
||||
, Tid_separatorTransformTable = 7, Tid_digitTransformTable = 8, Tid_digitGroupingPattern = 9
|
||||
;
|
||||
private static Hash_adp_bry Tid_hash = Hash_adp_bry.cs_()
|
||||
private static Hash_adp_bry Tid_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("namespaceNames", Tid_namespaceNames).Add_str_byte("namespaceAliases", Tid_namespaceAliases).Add_str_byte("specialPageAliases", Tid_specialPageAliases)
|
||||
.Add_str_byte("messages", Tid_messages).Add_str_byte("magicWords", Tid_magicwords)
|
||||
.Add_str_byte("fallback", Tid_fallback).Add_str_byte("rtl", Tid_rtl)
|
||||
@@ -340,7 +340,7 @@ public class Xol_mw_lang_parser {
|
||||
;
|
||||
public static int Id_by_mw_name(byte[] src) {
|
||||
if (mw_names == null) {
|
||||
mw_names = Btrie_slim_mgr.cs_();
|
||||
mw_names = Btrie_slim_mgr.cs();
|
||||
mw_names.Add_obj("NS_MEDIA", Int_obj_val.new_(Xow_ns_.Id_media));
|
||||
mw_names.Add_obj("NS_SPECIAL", Int_obj_val.new_(Xow_ns_.Id_special));
|
||||
mw_names.Add_obj("NS_MAIN", Int_obj_val.new_(Xow_ns_.Id_main));
|
||||
|
||||
@@ -18,7 +18,7 @@ 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.gfui.*; import gplx.xowa.bldrs.cmds.utils.*;
|
||||
public class Xob_import_marker {
|
||||
private final Hash_adp_bry in_progress_hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry in_progress_hash = Hash_adp_bry.cs();
|
||||
public void Bgn(Xowe_wiki wiki) {
|
||||
in_progress_hash.Add_as_key_and_val(wiki.Domain_bry());
|
||||
Io_mgr.I.SaveFilStr(url_(wiki), "XOWA has created this file to indicate that an import is in progress. This file will be deleted once the import is completed.");
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Xob_xml_parser {
|
||||
case Xob_xml_parser_.Id_id_bgn: if (page_id_needed) data_bgn = pos; break; // only flag if first <id>; note that 1st <id> always belongs to <page>;
|
||||
case Xob_xml_parser_.Id_id_end:
|
||||
if (page_id_needed) {
|
||||
int page_id = Bry_.Xto_int_or(src, data_bgn, hook_bgn, -1); if (page_id == -1) usr_dlg.Warn_many(GRP_KEY, "page_id_invalid", "page_id_is_invalid: ~{0}", String_.new_u8(src, data_bgn, hook_bgn));
|
||||
int page_id = Bry_.To_int_or(src, data_bgn, hook_bgn, -1); if (page_id == -1) usr_dlg.Warn_many(GRP_KEY, "page_id_invalid", "page_id_is_invalid: ~{0}", String_.new_u8(src, data_bgn, hook_bgn));
|
||||
rv.Id_(page_id);
|
||||
page_id_needed = false; // turn off for other <id> tags (<contributor>; <revision>)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Xob_xml_parser_tst {
|
||||
Io_mgr.I.InitEngine_mem();
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
bldr = new Xob_bldr(app);
|
||||
} private Xow_ns_mgr ns_mgr = Xow_ns_mgr_.default_(gplx.xowa.langs.cases.Xol_case_mgr_.Ascii());
|
||||
} private Xow_ns_mgr ns_mgr = Xow_ns_mgr_.default_(gplx.xowa.langs.cases.Xol_case_mgr_.A7());
|
||||
@Test public void Basic_docs_1() {
|
||||
Xowd_page_itm doc = doc_(1, "a", "a a", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
|
||||
@@ -43,5 +43,5 @@ public class Xoa_cfg_grp_tid {
|
||||
factory.Add(key, rv);
|
||||
}
|
||||
return rv;
|
||||
} static Hash_adp_bry factory = Hash_adp_bry.cs_();
|
||||
} static Hash_adp_bry factory = Hash_adp_bry.cs();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoctg_data_cache {
|
||||
private Hash_adp_bry regy = Hash_adp_bry.cs_(); // NOTE: changed to cs from ci; cache is hashing page_ttls by ctg_name which is always ttl.Page_txt(); DATE:2014-07-07
|
||||
private Hash_adp_bry regy = Hash_adp_bry.cs(); // NOTE: changed to cs from ci; cache is hashing page_ttls by ctg_name which is always ttl.Page_txt(); DATE:2014-07-07
|
||||
public Xoctg_data_ctg Get_or_null(byte[] ctg_name) {return (Xoctg_data_ctg)regy.Get_by_bry(ctg_name);}
|
||||
public Xoctg_data_ctg Load_or_null(Xowe_wiki wiki, byte[] ctg_name) {
|
||||
Gfo_usr_dlg usr_dlg = wiki.Appe().Usr_dlg();
|
||||
|
||||
@@ -116,7 +116,7 @@ class Xoctg_fmtr_all {
|
||||
private void Html_nav_bry(Bry_bfr bfr, Xowe_wiki wiki, Xoa_ttl ttl, Xoctg_view_grp view_grp, boolean fill_at_bgn) {
|
||||
Bry_bfr href_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Href_parser().Build_to_bfr(href_bfr, app, wiki.Domain_bry(), ttl);
|
||||
app.Html__href_wtr().Build_to_bfr(href_bfr, app, wiki.Domain_bry(), ttl);
|
||||
byte[] arg_idx_lbl = null; byte[] arg_sortkey = null;
|
||||
if (fill_at_bgn) {
|
||||
arg_idx_lbl = url_arg_bgn;
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.users.history.*;
|
||||
abstract class Xoctg_fmtr_itm_base implements Xoctg_fmtr_itm {
|
||||
public void Init_from_all(Xowe_wiki wiki, Xol_lang lang, Xoctg_view_ctg ctg, Xoctg_fmtr_all mgr, Xoctg_view_grp itms_list, int itms_list_len) {
|
||||
this.wiki = wiki; this.lang = lang; this.ctg = ctg; this.list = itms_list; this.len = itms_list_len; this.msg_mgr = wiki.Msg_mgr();
|
||||
href_parser = wiki.Appe().Href_parser();
|
||||
href_parser = wiki.Appe().Html__href_parser();
|
||||
html_itm = mgr.Html_itm();
|
||||
html_itm_missing = mgr.Html_itm_missing();
|
||||
history_mgr = wiki.Appe().Usere().History_mgr();
|
||||
@@ -58,7 +58,7 @@ abstract class Xoctg_fmtr_itm_base implements Xoctg_fmtr_itm {
|
||||
grp_end_at_col = true;
|
||||
}
|
||||
@gplx.Virtual public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
byte[] itm_href = href_parser.Build_to_bry(wiki, ttl);
|
||||
byte[] itm_href = wiki.App().Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
byte[] itm_full_ttl = ttl.Full_txt();// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
|
||||
byte[] itm_atr_cls = Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
Bry_fmtr fmtr = itm.Id_missing() ? html_itm_missing : html_itm;
|
||||
@@ -94,7 +94,7 @@ class Xoctg_fmtr_itm_file extends Xoctg_fmtr_itm_base {
|
||||
}
|
||||
class Xoctg_fmtr_itm_subc extends Xoctg_fmtr_itm_base {
|
||||
@Override public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
byte[] itm_href = href_parser.Build_to_bry(wiki, ttl);
|
||||
byte[] itm_href = wiki.App().Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
int sub_ctgs = itm.Subs_ctgs();
|
||||
int sub_pages = itm.Subs_pages();
|
||||
int sub_files = itm.Subs_files();
|
||||
|
||||
@@ -19,11 +19,12 @@ package gplx.xowa.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
public class Xoctg_pagelist_itms implements Bry_fmtr_arg {
|
||||
private Xoh_href_wtr href_wtr; private Xou_history_mgr history_mgr; private Bry_fmtr fmtr_itm;
|
||||
public void Init_app(Xoae_app app, Bry_fmtr fmtr_itm) {
|
||||
this.href_parser = app.Href_parser();
|
||||
this.href_wtr = app.Html__href_wtr();
|
||||
this.history_mgr = app.Usere().History_mgr();
|
||||
this.fmtr_itm = fmtr_itm;
|
||||
} private Xoh_href_parser href_parser; private Xou_history_mgr history_mgr; private Bry_fmtr fmtr_itm;
|
||||
}
|
||||
public void Init_wiki(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
|
||||
public void Itms_clear() {itms.Clear();} private List_adp itms = List_adp_.new_();
|
||||
public void Itms_add(Xowd_page_itm page) {itms.Add(page);}
|
||||
@@ -33,7 +34,7 @@ public class Xoctg_pagelist_itms implements Bry_fmtr_arg {
|
||||
Xowd_page_itm page = (Xowd_page_itm)itms.Get_at(i);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Xow_ns_.Id_category, page.Ttl_page_db());
|
||||
byte[] lnki_cls = Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
byte[] lnki_href = href_parser.Build_to_bry(wiki, ttl);
|
||||
byte[] lnki_href = href_wtr.Build_to_bry(wiki, ttl);
|
||||
byte[] lnki_ttl = ttl.Full_txt();
|
||||
byte[] lnki_text = ttl.Page_txt();
|
||||
fmtr_itm.Bld_bfr_many(bfr, lnki_cls, lnki_href, lnki_ttl, lnki_text);
|
||||
|
||||
@@ -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.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
public class Xoctg_url {
|
||||
public byte[][] Grp_idxs() {return grp_idxs;} private byte[][] grp_idxs = new byte[3][];
|
||||
public byte[] Grp_fwds() {return grp_fwds;} private byte[] grp_fwds = new byte[3];
|
||||
@@ -28,10 +28,10 @@ public class Xoctg_url {
|
||||
}
|
||||
public Xoctg_url Parse(Gfo_usr_dlg usr_dlg, Xoa_url url) {
|
||||
this.Clear();
|
||||
Gfo_url_arg[] args = url.Args();
|
||||
Gfo_qarg_itm[] args = url.Qargs_ary();
|
||||
int len = args.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Gfo_url_arg arg = args[i];
|
||||
Gfo_qarg_itm arg = args[i];
|
||||
byte[] arg_key = arg.Key_bry();
|
||||
Object tid_obj = Arg_keys.Get_by_bry(arg_key);
|
||||
if (tid_obj == null) {usr_dlg.Warn_many("", "", "unknown arg_key: ~{0}", String_.new_u8(arg_key)); continue;} // ignore invalid args
|
||||
@@ -59,7 +59,7 @@ public class Xoctg_url {
|
||||
}
|
||||
}
|
||||
public static final byte Tid_all_bgn = 0, Tid_subc_bgn = 1, Tid_subc_end = 2, Tid_file_bgn = 3, Tid_file_end = 4, Tid_page_bgn = 5, Tid_page_end = 6, Tid_all_end = 8;
|
||||
public static final Hash_adp_bry Arg_keys = Hash_adp_bry.ci_ascii_()
|
||||
public static final Hash_adp_bry Arg_keys = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_from, Tid_all_bgn)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_until, Tid_all_end)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_subc_bgn, Tid_subc_bgn)
|
||||
|
||||
@@ -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.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*;
|
||||
import org.junit.*; import gplx.xowa.urls.*;
|
||||
public class Xoctg_url_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoctg_url_fxt fxt = new Xoctg_url_fxt();
|
||||
@Test public void Basic() {
|
||||
@@ -30,14 +30,15 @@ class Xoctg_url_fxt {
|
||||
public Xoctg_url_chkr url() {return expd.Clear();} private Xoctg_url_chkr expd;
|
||||
public void Clear() {
|
||||
if (parser == null) {
|
||||
parser = new Xoa_url_parser();
|
||||
page_url = Xoa_url.blank_();
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
parser = app.User().Wikii().Utl__url_parser();
|
||||
page_url = Xoa_url.blank();
|
||||
ctg_url = new Xoctg_url();
|
||||
expd = new Xoctg_url_chkr();
|
||||
}
|
||||
} private Xoa_url_parser parser; Xoa_url page_url; Xoctg_url ctg_url;
|
||||
public void Test_parse(String url_str, Xoctg_url_chkr expd) {
|
||||
parser.Parse(page_url, Bry_.new_u8(url_str));
|
||||
page_url = parser.Parse(Bry_.new_u8(url_str));
|
||||
ctg_url.Parse(Gfo_usr_dlg_.Test(), page_url);
|
||||
expd.Chk(ctg_url);
|
||||
expd.Clear();
|
||||
|
||||
@@ -498,7 +498,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
if (pids_root == null)
|
||||
pids_root = wiki.Appe().Wiki_mgr().Wdata_mgr().Wdata_wiki().Tdb_fsys_mgr().Site_dir().GenSubDir_nest("data", "pid");
|
||||
Xob_xdat_itm pid_itm = Load_xdat_itm_by_dir(pids_root.GenSubDir(String_.new_u8(lang_key)), pid_name); if (pid_itm == null) return gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null;
|
||||
return Bry_.Xto_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
return Bry_.To_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
} Io_url pids_root;
|
||||
public int Load_ctg_count(byte[] ttl) {return wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_1 ? Load_ctg_count_v1(ttl) : Load_ctg_count_v2(ttl);}
|
||||
int Load_ctg_count_v1(byte[] ttl) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Xof_ext_ {
|
||||
};
|
||||
private static final Hash_adp id_hash = id_hash_new_();
|
||||
private static Hash_adp id_hash_new_() {
|
||||
Hash_adp rv = Hash_adp_bry.cs_();
|
||||
Hash_adp rv = Hash_adp_bry.cs();
|
||||
id_hash_new_(rv, Bry_png, Id_png); id_hash_new_(rv, Bry_jpg, Id_jpg); id_hash_new_(rv, Bry_jpeg, Id_jpeg);
|
||||
id_hash_new_(rv, Bry_gif, Id_gif); id_hash_new_(rv, Bry_tif, Id_tif); id_hash_new_(rv, Bry_tiff, Id_tiff);
|
||||
id_hash_new_(rv, Bry_svg, Id_svg); id_hash_new_(rv, Bry_djvu, Id_djvu); id_hash_new_(rv, Bry_pdf, Id_pdf);
|
||||
@@ -61,7 +61,7 @@ public class Xof_ext_ {
|
||||
}
|
||||
private static void id_hash_new_(Hash_adp hash, byte[] key, int val) {hash.Add(key, Int_obj_val.new_(val));}
|
||||
|
||||
private static final Hash_adp_bry ext_hash = Hash_adp_bry.ci_ascii_()
|
||||
private static final Hash_adp_bry ext_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_bry(Bry_png).Add_bry_bry(Bry_jpg).Add_bry_bry(Bry_jpeg)
|
||||
.Add_bry_bry(Bry_gif).Add_bry_bry(Bry_tif).Add_bry_bry(Bry_tiff)
|
||||
.Add_bry_bry(Bry_svg).Add_bry_bry(Bry_djvu).Add_bry_bry(Bry_pdf)
|
||||
@@ -82,7 +82,7 @@ public class Xof_ext_ {
|
||||
public static Xof_ext new_by_ttl_(byte[] ttl) {
|
||||
int ttl_len = ttl.length;
|
||||
int dot_pos = Bry_finder.Find_bwd(ttl, Byte_ascii.Dot);
|
||||
byte[] ext = (dot_pos == Bry_.NotFound || dot_pos == ttl_len) ? Bry_.Empty : Bry_.Xto_str_lower(ttl, dot_pos + 1, ttl_len); // +1 to bgn after .
|
||||
byte[] ext = (dot_pos == Bry_.NotFound || dot_pos == ttl_len) ? Bry_.Empty : Bry_.Lcase__all(ttl, dot_pos + 1, ttl_len); // +1 to bgn after .
|
||||
return new_(Get_id_by_ext_(ext), ext);
|
||||
}
|
||||
public static Xof_ext new_by_ext_(byte[] ext) {return new_(Get_id_by_ext_(ext), ext);}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xof_mime_minor_ {
|
||||
, Mime_bmp = Bry_.new_a7("x-bmp"), Mime_bmp_2 = Bry_.new_a7("x-ms-bmp");
|
||||
private static final Hash_adp mime_hash = mime_hash_();
|
||||
private static Hash_adp mime_hash_() {
|
||||
Hash_adp rv = Hash_adp_bry.cs_();
|
||||
Hash_adp rv = Hash_adp_bry.cs();
|
||||
mime_hash_itm_(rv, Xof_ext_.Bry_png , Xof_ext_.Id_png);
|
||||
mime_hash_itm_(rv, Xof_ext_.Bry_jpg , Xof_ext_.Id_jpg);
|
||||
mime_hash_itm_(rv, Xof_ext_.Bry_jpeg , Xof_ext_.Id_jpeg);
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.files.exts; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xof_rule_grp implements GfoInvkAble {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xof_rule_grp(Xof_rule_mgr owner, byte[] key) {this.owner = owner; this.key = key;}
|
||||
public Xof_rule_mgr Owner() {return owner;} private final Xof_rule_mgr owner;
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.files.exts; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.apps.*;
|
||||
public class Xof_rule_mgr implements GfoInvkAble {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xof_rule_mgr() {
|
||||
Xof_rule_grp app_default = new Xof_rule_grp(this, Xof_rule_grp.Grp_app_default);
|
||||
Set_app_default(app_default, Io_mgr.Len_gb, Xof_ext_.Bry__ary);
|
||||
|
||||
@@ -104,7 +104,7 @@ class Fs_root_dir {
|
||||
public static byte[] Xto_fil_bry(Io_url url) {
|
||||
byte[] rv = Bry_.new_u8(url.NameAndExt());
|
||||
rv = Bry_.Replace(rv, Byte_ascii.Space, Byte_ascii.Underline);
|
||||
rv = Bry_.Upper_1st(rv);
|
||||
rv = Bry_.Ucase__1st(rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xog_history_mgr {
|
||||
if (itm == Xog_history_itm.Null) return Xoae_page.Empty;
|
||||
Xoae_page rv = Get_or_fetch(wiki, itm);
|
||||
byte[] anch_key = itm.Anch();
|
||||
rv.Url().Anchor_bry_(anch_key); // must override anchor as it may be different for cached page
|
||||
rv.Url().Anch_bry_(anch_key); // must override anchor as it may be different for cached page
|
||||
rv.Html_data().Bmk_pos_(itm.Bmk_pos());
|
||||
return rv;
|
||||
}
|
||||
@@ -62,14 +62,14 @@ public class Xog_history_mgr {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, itm.Page());
|
||||
return wiki.Data_mgr().Get_page(ttl, false);
|
||||
}
|
||||
private static byte[] Build_page_key(Xoae_page page) {return Build_page_key(page.Wiki().Domain_bry(), page.Ttl().Full_url(), page.Url().Args_all_as_bry());}
|
||||
private static byte[] Build_page_key(Xoae_page page) {return Build_page_key(page.Wiki().Domain_bry(), page.Ttl().Full_url(), page.Url().Qargs_mgr().To_bry());}
|
||||
private static byte[] Build_page_key(byte[] wiki_key, byte[] page_key, byte[] args_key) {return Bry_.Add_w_dlm(Byte_ascii.Pipe, wiki_key, page_key, args_key);}
|
||||
public static Xog_history_itm new_(Xoae_page pg) {
|
||||
byte[] wiki = pg.Wiki().Domain_bry();
|
||||
byte[] page = pg.Ttl().Full_url(); // get page_name only (no anchor; no query args)
|
||||
byte[] anch = pg.Url().Anchor_bry();
|
||||
byte[] qarg = pg.Url().Args_all_as_bry();
|
||||
boolean redirect_force = pg.Url().Redirect_force();
|
||||
byte[] anch = pg.Url().Anch_bry();
|
||||
byte[] qarg = pg.Url().Qargs_mgr().To_bry();
|
||||
boolean redirect_force = pg.Url().Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__yes);
|
||||
String bmk_pos = pg.Html_data().Bmk_pos();
|
||||
if (bmk_pos == null) bmk_pos = Xog_history_itm.Html_doc_pos_toc; // never allow null doc_pos; set to top
|
||||
return new Xog_history_itm(wiki, page, anch, qarg, redirect_force, bmk_pos);
|
||||
|
||||
@@ -44,10 +44,9 @@ class Xog_history_stack_fxt {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
url_parser = app.Utl__url_parser();
|
||||
}
|
||||
return this;
|
||||
} private Xoae_app app; private Xowe_wiki wiki; private Xog_history_stack stack = new Xog_history_stack(); private Xoa_url_parser url_parser;
|
||||
} private Xoae_app app; private Xowe_wiki wiki; private Xog_history_stack stack = new Xog_history_stack();
|
||||
public Xog_history_stack_fxt Test_cur(String expd) {
|
||||
Xog_history_itm page = stack.Cur_itm();
|
||||
String actl = page == null ? null : String_.new_u8(page.Page());
|
||||
@@ -75,8 +74,8 @@ class Xog_history_stack_fxt {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry);
|
||||
Xoae_page page = Xoae_page.test_(wiki, ttl);
|
||||
byte[] url_bry = ttl_bry;
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));
|
||||
Xoa_url url = url_parser.Parse(url_bry);
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));
|
||||
Xoa_url url = app.User().Wikii().Utl__url_parser().Parse(url_bry);
|
||||
page.Url_(url); // set url b/c history_mgr.Add uses url
|
||||
stack.Add(Xog_history_mgr.new_(page));
|
||||
return this;
|
||||
|
||||
@@ -16,59 +16,58 @@ You should have 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.gui.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
import gplx.xowa.gui.views.*;
|
||||
public class Xog_url_wkr {
|
||||
private Xoh_href href = new Xoh_href();
|
||||
private final Xoa_url tmp_url = Xoa_url.blank();
|
||||
private Xoae_app app; private Xog_win_itm win; private Xowe_wiki wiki; private Xoae_page page;
|
||||
private final Xof_img_size img_size = new Xof_img_size(); private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2();
|
||||
public byte Href_tid() {return href.Tid();}
|
||||
public Xog_url_wkr Parse(Xog_win_itm win, String href_str) {
|
||||
if (href_str == null) return this; // text is not link; return;
|
||||
byte[] href_bry = Bry_.new_u8(href_str);
|
||||
this.win = win; this.app = win.App();
|
||||
this.page = win.Active_page();
|
||||
this.wiki = win.Active_tab().Wiki();
|
||||
app.Href_parser().Parse(href, href_bry, wiki, page.Ttl().Page_url());
|
||||
app.Html__href_parser().Parse_as_url(tmp_url, href_bry, wiki, page.Ttl().Page_url());
|
||||
return this;
|
||||
}
|
||||
public Xoa_url Exec() {
|
||||
byte[] href_bry = href.Raw();
|
||||
switch (href.Tid()) {
|
||||
case Xoh_href.Tid_null: return Rslt_handled; // url is invalid; return handled (which effectively ignores)
|
||||
case Xoh_href.Tid_xowa: return Exec_url_xowa(app); // xowa:app.version
|
||||
case Xoh_href.Tid_http: return Exec_url_http(app); // http://site.org
|
||||
case Xoh_href.Tid_anchor: return Exec_url_anchor(win); // #anchor
|
||||
case Xoh_href.Tid_xcmd: return Exec_url_xcmd(win); // /xcmd/app.version
|
||||
case Xoh_href.Tid_file: return Exec_url_file(app, wiki, page, win, href_bry); // file:///xowa/A.png
|
||||
default: return Exec_url_page(app, wiki, page, win, href_bry); // Page /wiki/Page
|
||||
switch (tmp_url.Tid()) {
|
||||
case Xoa_url_.Tid_unknown: return Xoa_url.Null; // unknown; return null which will become a noop
|
||||
case Xoa_url_.Tid_inet: return Exec_url_http(app); // http://site.org
|
||||
case Xoa_url_.Tid_anch: return Exec_url_anchor(win); // #anchor
|
||||
case Xoa_url_.Tid_xcmd: return Exec_url_xowa(app); // xowa:app.version or /xcmd/app.version
|
||||
case Xoa_url_.Tid_file: return Exec_url_file(app, wiki, page, win, tmp_url.Raw()); // file:///xowa/A.png
|
||||
case Xoa_url_.Tid_page: return Exec_url_page(app, wiki, page, win, tmp_url.Raw()); // Page /wiki/Page
|
||||
default: throw Err_.new_unhandled(tmp_url.Tid());
|
||||
}
|
||||
}
|
||||
private Xoa_url Exec_url_xowa(Xoae_app app) { // EX: xowa:app.version
|
||||
// NOTE: must catch exception else it will bubble to SWT browser and raise secondary exception of xowa is not a registered protocol
|
||||
try {app.Gfs_mgr().Run_str(String_.new_u8(href.Page()));}
|
||||
try {app.Gfs_mgr().Run_str(String_.new_u8(tmp_url.Page_bry()));}
|
||||
catch (Exception e) {app.Gui_mgr().Kit().Ask_ok("", "", Err_.Message_gplx_full(e));}
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_http(Xoae_app app) { // EX: http:a.org
|
||||
app.Prog_mgr().Exec_view_web(href.Raw());
|
||||
// private Xoa_url Exec_url_xcmd(Xog_win_itm win) { // EX: /xcmd/
|
||||
// byte[] xowa_href_bry = tmp_url.Page();
|
||||
// int xowa_href_bry_len = xowa_href_bry.length;
|
||||
// int slash_pos = Bry_finder.Find_fwd(xowa_href_bry, Byte_ascii.Slash); if (slash_pos == Bry_.NotFound) slash_pos = xowa_href_bry_len;
|
||||
// byte[] xowa_cmd_bry = Bry_.Mid(xowa_href_bry, 0, slash_pos);
|
||||
// String xowa_cmd_str = String_.new_u8(xowa_cmd_bry);
|
||||
// GfoMsg m = GfoMsg_.new_cast_(xowa_cmd_str);
|
||||
// if (String_.Eq(xowa_cmd_str, Xog_win_itm.Invk_eval))
|
||||
// m.Add("cmd", String_.new_u8(xowa_href_bry, slash_pos + 1, xowa_href_bry_len));
|
||||
// win.Invk(GfsCtx.new_(), 0, xowa_cmd_str, m);
|
||||
// return Rslt_handled;
|
||||
// }
|
||||
private Xoa_url Exec_url_http(Xoae_app app) { // EX: http://a.org
|
||||
app.Prog_mgr().Exec_view_web(tmp_url.Raw());
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_anchor(Xog_win_itm win) { // EX: #anchor
|
||||
win.Active_html_itm().Scroll_page_by_id_gui(String_.new_u8(href.Anchor())); // NOTE: was originally directly; changed to call on thread; DATE:2014-05-03
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_xcmd(Xog_win_itm win) { // EX: /xcmd/
|
||||
byte[] xowa_href_bry = href.Page();
|
||||
int xowa_href_bry_len = xowa_href_bry.length;
|
||||
int slash_pos = Bry_finder.Find_fwd(xowa_href_bry, Byte_ascii.Slash); if (slash_pos == Bry_.NotFound) slash_pos = xowa_href_bry_len;
|
||||
byte[] xowa_cmd_bry = Bry_.Mid(xowa_href_bry, 0, slash_pos);
|
||||
String xowa_cmd_str = String_.new_u8(xowa_cmd_bry);
|
||||
GfoMsg m = GfoMsg_.new_cast_(xowa_cmd_str);
|
||||
if (String_.Eq(xowa_cmd_str, Xog_win_itm.Invk_eval))
|
||||
m.Add("cmd", String_.new_u8(xowa_href_bry, slash_pos + 1, xowa_href_bry_len));
|
||||
win.Invk(GfsCtx.new_(), 0, xowa_cmd_str, m);
|
||||
win.Active_html_itm().Scroll_page_by_id_gui(tmp_url.Anch_str()); // NOTE: was originally directly; changed to call on thread; DATE:2014-05-03
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_file(Xoae_app app, Xowe_wiki cur_wiki, Xoae_page page, Xog_win_itm win, byte[] href_bry) { // EX: file:///xowa/A.png
|
||||
@@ -97,59 +96,73 @@ public class Xog_url_wkr {
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_page(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xog_win_itm win, byte[] href_bry) { // EX: "Page"; "/wiki/Page"; // rewritten; DATE:2014-01-19
|
||||
Xoa_url rv = app.Utl__url_parser().Parse(href_bry); // needed for query_args
|
||||
byte[] anchor_bry = href.Anchor();
|
||||
byte[] page_bry = rv.Page_bry();
|
||||
byte[][] segs_ary = rv.Segs_ary();
|
||||
int segs_ary_len = segs_ary.length;
|
||||
boolean use_main_page = false;
|
||||
if ( segs_ary_len > 0 // handle "Special:Search/Earth" which creates segs[1] {"Special:Search"} and page="Earth"
|
||||
|| href.Tid() == Xoh_href.Tid_site) { // NOTE: if site, must always (a) zap Segs_ary and (b) force correct page; see tests; DATE:2014-01-21
|
||||
int segs_bgn = 0;
|
||||
boolean segs_iterate = true;
|
||||
if (href.Tid() == Xoh_href.Tid_site) { // site, handle multiple segs; EX: "home/wiki/", "home/wiki/Help:Contents"; DATE:2014-01-21
|
||||
if (segs_ary_len < 2) { // only 0 or 1 seg; usually occurs for logo and other xwiki links to Main_Page; EX: "/site/en.wikipedia.org/wiki/"; "/site/en.wikipedia.org/"
|
||||
page_bry = wiki.Init_assert().Props().Main_page(); // use Main_page; DATE:2014-02-16
|
||||
use_main_page = true;
|
||||
segs_iterate = false;
|
||||
}
|
||||
else
|
||||
segs_bgn = 2; // start from seg_2; seg_0="/en.wikipedia.org/" and seg_1="/wiki/"; note that > 2 segs possible; EX: "/site/en.wikipedia.org/wiki/A/B/C
|
||||
}
|
||||
if (segs_iterate) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b128();
|
||||
for (int i = segs_bgn; i < segs_ary_len; i++) {
|
||||
tmp_bfr.Add(segs_ary[i]);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Slash);
|
||||
}
|
||||
tmp_bfr.Add(page_bry);
|
||||
page_bry = tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
rv.Segs_ary_(Bry_.Ary_empty);
|
||||
}
|
||||
Gfo_url_arg[] qargs = rv.Args();
|
||||
Xoa_url rv = wiki.Utl__url_parser().Parse(href_bry);// needed for query_args
|
||||
Gfo_qarg_itm[] qargs = rv.Qargs_ary();
|
||||
int qargs_len = qargs.length;
|
||||
if (qargs_len > 0) { // remove anchors from qargs; EX: "to=B#mw_pages"
|
||||
for (int i = 0; i < qargs_len; i++) {
|
||||
Gfo_url_arg arg = qargs[i];
|
||||
int anchor_pos = Bry_finder.Find_bwd(arg.Val_bry(), Byte_ascii.Hash); // NOTE: must .FindBwd to handle Category args like de.wikipedia.org/wiki/Kategorie:Begriffskl%C3%A4rung?pagefrom=#::12%20PANZERDIVISION#mw-pages; DATE:2013-06-18
|
||||
if (anchor_pos != Bry_.NotFound)
|
||||
arg.Val_bry_(Bry_.Mid(arg.Val_bry(), 0, anchor_pos));
|
||||
Gfo_qarg_itm arg = qargs[i];
|
||||
int anch_pos = Bry_finder.Find_bwd(arg.Val_bry(), Byte_ascii.Hash); // NOTE: must .FindBwd to handle Category args like de.wikipedia.org/wiki/Kategorie:Begriffskl%C3%A4rung?pagefrom=#::12%20PANZERDIVISION#mw-pages; DATE:2013-06-18
|
||||
if (anch_pos != Bry_.NotFound)
|
||||
arg.Val_bry_(Bry_.Mid(arg.Val_bry(), 0, anch_pos));
|
||||
}
|
||||
}
|
||||
if (!Bry_.Eq(page.Wiki().Domain_bry(), href.Wiki())) {// xwiki; EX: "file:///site/en.wiktionary.org/wiki/a"; EX: (1) goto w:Anything; (2) click on "anything" in wikt; "anything" will be parsed by en.wiki's rules, not en.wikt; DATE:2013-01-30
|
||||
wiki = app.Wiki_mgr().Get_by_key_or_make(href.Wiki()).Init_assert(); // get xwiki and set to wiki
|
||||
if (use_main_page)
|
||||
page_bry = wiki.Props().Main_page(); // get Main_page for new wiki; DATE:2014-02-23
|
||||
Xoa_ttl tmp_ttl = Xoa_ttl.parse_(wiki, page_bry); // reparse ttl according to xwiki's case_match rules; NOTE: do not use rv.Page_bry() or else will lose sub_pages (A/B/C); DATE:2014-02-21
|
||||
if (tmp_ttl != null)
|
||||
page_bry = tmp_ttl.Full_db();
|
||||
}
|
||||
rv.Wiki_bry_(wiki.Domain_bry()); // needed b/c url_parser.Parse(href) will result in wiki of "wiki" for "/wiki/Page"
|
||||
rv.Page_bry_(page_bry);
|
||||
rv.Anchor_bry_(anchor_bry);
|
||||
return rv;
|
||||
}
|
||||
// private Xoa_url Exec_url_page(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xog_win_itm win, byte[] href_bry) { // EX: "Page"; "/wiki/Page"; // rewritten; DATE:2014-01-19
|
||||
// Xoa_url rv = wiki.Utl__url_parser().Parse(href_bry);// needed for query_args
|
||||
// byte[] anchor_bry = href.Anchor();
|
||||
// byte[] page_bry = rv.Page_bry();
|
||||
// byte[][] segs_ary = rv.Mids_ary();
|
||||
// int segs_ary_len = segs_ary.length;
|
||||
// boolean use_main_page = false;
|
||||
// if ( segs_ary_len > 0 // handle "Special:Search/Earth" which creates segs[1] {"Special:Search"} and page="Earth"
|
||||
// || href.Tid() == Xoh_href_.Tid_site) { // NOTE: if site, must always (a) zap Segs_ary and (b) force correct page; see tests; DATE:2014-01-21
|
||||
// int segs_bgn = 0;
|
||||
// boolean segs_iterate = true;
|
||||
// if (href.Tid() == Xoh_href_.Tid_site) { // site, handle multiple segs; EX: "home/wiki/", "home/wiki/Help:Contents"; DATE:2014-01-21
|
||||
// if (segs_ary_len < 2) { // only 0 or 1 seg; usually occurs for logo and other xwiki links to Main_Page; EX: "/site/en.wikipedia.org/wiki/"; "/site/en.wikipedia.org/"
|
||||
// page_bry = wiki.Init_assert().Props().Main_page(); // use Main_page; DATE:2014-02-16
|
||||
// use_main_page = true;
|
||||
// segs_iterate = false;
|
||||
// }
|
||||
// else
|
||||
// segs_bgn = 2; // start from seg_2; seg_0="/en.wikipedia.org/" and seg_1="/wiki/"; note that > 2 segs possible; EX: "/site/en.wikipedia.org/wiki/A/B/C
|
||||
// }
|
||||
// if (segs_iterate) {
|
||||
// Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b128();
|
||||
// for (int i = segs_bgn; i < segs_ary_len; i++) {
|
||||
// tmp_bfr.Add(segs_ary[i]);
|
||||
// tmp_bfr.Add_byte(Byte_ascii.Slash);
|
||||
// }
|
||||
// tmp_bfr.Add(page_bry);
|
||||
// page_bry = tmp_bfr.To_bry_and_rls();
|
||||
// }
|
||||
// rv.Mids_ary_(Bry_.Ary_empty);
|
||||
// }
|
||||
// Gfo_qarg_itm[] qargs = rv.Qargs_ary();
|
||||
// int qargs_len = qargs.length;
|
||||
// if (qargs_len > 0) { // remove anchors from qargs; EX: "to=B#mw_pages"
|
||||
// for (int i = 0; i < qargs_len; i++) {
|
||||
// Gfo_qarg_itm arg = qargs[i];
|
||||
// int anch_pos = Bry_finder.Find_bwd(arg.Val_bry(), Byte_ascii.Hash); // NOTE: must .FindBwd to handle Category args like de.wikipedia.org/wiki/Kategorie:Begriffskl%C3%A4rung?pagefrom=#::12%20PANZERDIVISION#mw-pages; DATE:2013-06-18
|
||||
// if (anch_pos != Bry_.NotFound)
|
||||
// arg.Val_bry_(Bry_.Mid(arg.Val_bry(), 0, anch_pos));
|
||||
// }
|
||||
// }
|
||||
// if (!Bry_.Eq(page.Wiki().Domain_bry(), href.Wiki())) {// xwiki; EX: "file:///site/en.wiktionary.org/wiki/a"; EX: (1) goto w:Anything; (2) click on "anything" in wikt; "anything" will be parsed by en.wiki's rules, not en.wikt; DATE:2013-01-30
|
||||
// wiki = app.Wiki_mgr().Get_by_key_or_make(href.Wiki()).Init_assert(); // get xwiki and set to wiki
|
||||
// if (use_main_page)
|
||||
// page_bry = wiki.Props().Main_page(); // get Main_page for new wiki; DATE:2014-02-23
|
||||
// Xoa_ttl tmp_ttl = Xoa_ttl.parse_(wiki, page_bry); // reparse ttl according to xwiki's case_match rules; NOTE: do not use rv.Page_bry() or else will lose sub_pages (A/B/C); DATE:2014-02-21
|
||||
// if (tmp_ttl != null)
|
||||
// page_bry = tmp_ttl.Full_db();
|
||||
// }
|
||||
// rv.Wiki_bry_(wiki.Domain_bry()); // needed b/c url_parser.Parse(href) will result in wiki of "wiki" for "/wiki/Page"
|
||||
// rv.Page_bry_(page_bry);
|
||||
// rv.Anch_bry_(anchor_bry);
|
||||
// return rv;
|
||||
// }
|
||||
public static Xoa_url Rslt_handled = null;
|
||||
public static Xoa_url Exec_url(Xog_win_itm win, String href_str) {
|
||||
Xog_url_wkr url_wkr = new Xog_url_wkr();
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.gui.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import org.junit.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.gui.views.*;
|
||||
public class Xog_url_wkr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xog_url_wkr_fxt fxt = new Xog_url_wkr_fxt();
|
||||
@Test public void term() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Init_exec("file:///wiki/A").Expd_tid_(Xoh_href.Tid_wiki).Expd_page_("A").Test();
|
||||
}
|
||||
@Test public void Basic_question() {
|
||||
fxt.Init_exec("file:///wiki/A?").Expd_tid_(Xoh_href.Tid_wiki).Expd_page_("A?").Expd_qargs_("").Test();
|
||||
}
|
||||
@Test public void Basic_question_text() {
|
||||
fxt.Init_exec("file:///wiki/A?B").Expd_tid_(Xoh_href.Tid_wiki).Expd_page_("A?B").Expd_qargs_("").Test();
|
||||
}
|
||||
@Test public void Redirect() {
|
||||
fxt.Init_exec("file:///wiki/A?redirect=no").Expd_tid_(Xoh_href.Tid_wiki).Expd_page_("A").Expd_qargs_("?redirect=no").Test();
|
||||
}
|
||||
@Test public void Search() {
|
||||
fxt.Init_exec("file:///wiki/Special:Search/Moon%3Ffulltext%3Dy%26xowa_page_index%3D1").Expd_tid_(Xoh_href.Tid_wiki).Expd_page_("Special:Search/Moon").Expd_qargs_("?fulltext=y&xowa_page_index=1").Test();
|
||||
}
|
||||
@Test public void Ctg() {
|
||||
fxt.Init_exec("file:///wiki/Category:A?pagefrom=A#mw-pages").Expd_tid_(Xoh_href.Tid_wiki).Expd_page_("Category:A").Expd_qargs_("?pagefrom=A").Expd_anchor_("mw-pages").Test();
|
||||
}
|
||||
@Test public void Xwiki() {
|
||||
Xow_ns_mgr ns_mgr = fxt.App().Wiki_mgr().Get_by_key_or_make(Bry_.new_a7("en.wiktionary.org")).Ns_mgr();
|
||||
|
||||
ns_mgr.Ns_main().Case_match_(Xow_ns_case_.Id_all);
|
||||
fxt.Init_exec("file:///site/en.wiktionary.org/wiki/a").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wiktionary.org").Expd_page_("a").Test();
|
||||
|
||||
ns_mgr.Ns_category().Case_match_(Xow_ns_case_.Id_all);
|
||||
fxt.Init_exec("file:///site/en.wiktionary.org/wiki/Category:a").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wiktionary.org").Expd_page_("Category:a").Test();
|
||||
|
||||
fxt.Init_exec("file:///site/en.wiktionary.org/wiki/A/B/C").Expd_tid_(Xoh_href.Tid_site).Expd_page_("A/B/C").Test();
|
||||
}
|
||||
@Test public void Xwiki_site_sidebar() {// PURPOSE: make sure sidebar links don't fail; DATE:2014-01-21
|
||||
fxt.Init_exec("file:///site/en.wikipedia.org/wiki/A").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wikipedia.org").Expd_page_("A").Test();
|
||||
}
|
||||
@Test public void Xwiki_site_logo() { // DATE:2014-01-21
|
||||
fxt.Init_exec("file:///site/en.wikipedia.org/wiki/").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wikipedia.org").Expd_page_("Main_Page").Test();
|
||||
fxt.Init_exec("file:///site/en.wikipedia.org/wiki").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wikipedia.org").Expd_page_("Main_Page").Test();
|
||||
fxt.Init_exec("file:///site/en.wikipedia.org/").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wikipedia.org").Expd_page_("Main_Page").Test();
|
||||
}
|
||||
@Test public void Main_page() {// PURPOSE: Main_page does not update to use Main_page of xwiki; DATE:2014-02-23
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full("zh.wikipedia.org", "zh.wikipedia.org");
|
||||
gplx.xowa.wikis.Xoa_wiki_regy.Make_wiki_dir(fxt.App(), "zh.wikipedia.org");
|
||||
fxt.App().Wiki_mgr().Get_by_key_or_make(Bry_.new_a7("zh.wikipedia.org")).Props().Main_page_(Bry_.new_a7("Zh_Main_Page"));
|
||||
fxt.App().Wiki_mgr().Get_by_key_or_make(Bry_.new_a7("en.wikipedia.org")).Props().Main_page_(Bry_.new_a7("En_Main_Page"));
|
||||
fxt.Init_exec("file:///site/zh.wikipedia.org/").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("zh.wikipedia.org").Expd_page_("Zh_Main_Page").Test();
|
||||
fxt.Init_exec("file:///site/en.wikipedia.org/").Expd_tid_(Xoh_href.Tid_site).Expd_wiki_("en.wikipedia.org").Expd_page_("En_Main_Page").Test(); // still stuck at Zh
|
||||
}
|
||||
}
|
||||
class Xog_url_wkr_fxt {
|
||||
private Xoae_app app; private Xowe_wiki wiki;
|
||||
private Xog_win_itm win;
|
||||
private Xog_url_wkr url_wkr = new Xog_url_wkr();
|
||||
private String init_raw;
|
||||
public Xoae_app App() {return app;}
|
||||
public Xog_url_wkr_fxt Expd_tid_(byte v) {expd_tid = v; return this;} private byte expd_tid;
|
||||
public Xog_url_wkr_fxt Expd_wiki_(String v) {expd_wiki = v; return this;} private String expd_wiki;
|
||||
public Xog_url_wkr_fxt Expd_page_(String v) {expd_page = v; return this;} private String expd_page;
|
||||
public Xog_url_wkr_fxt Expd_anchor_(String v) {expd_anchor = v; return this;} private String expd_anchor;
|
||||
public Xog_url_wkr_fxt Expd_qargs_(String v) {expd_qargs = v; return this;} private String expd_qargs;
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
Xoa_app_fxt.Init_gui(app, wiki);
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
win.Active_page_(Xoae_page.test_(wiki, Xoa_ttl.parse_(wiki, Bry_.new_a7("test")))); // TODO: remove unnecessary page init
|
||||
expd_wiki = expd_page = expd_qargs = expd_anchor = null;
|
||||
}
|
||||
public Xog_url_wkr_fxt Init_exec(String raw) {
|
||||
this.init_raw = raw;
|
||||
return this;
|
||||
}
|
||||
public void Test() {
|
||||
Xoa_url url = url_wkr.Parse(win, init_raw).Exec();
|
||||
Tfds.Eq(expd_tid, url_wkr.Href_tid());
|
||||
Tfds.Eq(expd_page, String_.new_u8(url.Page_bry()));
|
||||
if (expd_wiki != null) Tfds.Eq(expd_wiki , String_.new_u8(url.Wiki_bry()));
|
||||
if (expd_anchor != null) Tfds.Eq(expd_anchor , String_.new_u8(url.Anchor_bry()));
|
||||
if (expd_qargs != null) Tfds.Eq(expd_qargs , String_.new_u8(url.Args_all_as_bry()));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.gui.urls.url_macros; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*; import gplx.xowa.gui.urls.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xog_url_macro_grp implements GfoInvkAble {
|
||||
public Btrie_slim_mgr Trie() {return trie;} private Btrie_slim_mgr trie = Btrie_slim_mgr.cs_();
|
||||
public Btrie_slim_mgr Trie() {return trie;} private Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
public void Del(byte[] abrv) {trie.Del(abrv);}
|
||||
public void Set(String abrv, String fmt) {Set(Bry_.new_u8(abrv), Bry_.new_u8(fmt));}
|
||||
public void Set(byte[] abrv, byte[] fmt) {trie.Add_obj(abrv, new Xog_url_macro_itm(abrv, fmt));}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Load_page_wkr implements Gfo_thread_wkr {
|
||||
Thread_adp_.Sleep(10);
|
||||
}
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.Xto_full_str_safe());
|
||||
app.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
|
||||
if (Env_.System_memory_free() < app.Sys_cfg().Free_mem_when()) // check if low in memory
|
||||
app.Free_mem(false); // clear caches (which will clear bry_bfr_mk)
|
||||
else // not low in memory
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.gfui.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.menus.dom.*; import gplx.xowa.files.gui.*;
|
||||
import gplx.html.*; import gplx.xowa.html.js.*; import gplx.xowa.html.heads.*; import gplx.xowa.pages.*;
|
||||
import gplx.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.js.*; import gplx.xowa.html.heads.*; import gplx.xowa.pages.*;
|
||||
public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
|
||||
private Xoae_app app; private final Object thread_lock = new Object();
|
||||
private final String_obj_ref scroll_top = String_obj_ref.null_(), node_path = String_obj_ref.null_();
|
||||
@@ -56,7 +56,7 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
|
||||
Xoae_page page = owner_tab.Page();
|
||||
String site = owner_tab.Wiki().Domain_str();
|
||||
String ttl = String_.new_u8(page.Ttl().Full_db());
|
||||
return Xog_html_itm__href_extractor.Html_extract_text(site, ttl, v);
|
||||
return Xoh_href_gui_utl.Html_extract_text(site, ttl, v);
|
||||
}
|
||||
public void Show(Xoae_page page) {
|
||||
byte view_mode = owner_tab.View_mode();
|
||||
@@ -71,9 +71,9 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
|
||||
String html_str = String_.new_u8(html_bry);
|
||||
if (owner_tab.Tab_mgr().Html_load_tid__url()) {
|
||||
Io_url html_url = app.Usere().Fsys_mgr().App_temp_html_dir().GenSubFil_ary(owner_tab.Tab_key(), ".html");
|
||||
try {html_box.Html_doc_html_load_by_url(html_url.Xto_api(), html_str);}
|
||||
try {html_box.Html_doc_html_load_by_url(html_url, html_str);}
|
||||
catch (Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "failed to write html to file; writing directly by memory: page=~{0} file=~{1} err=~{2}", page.Url().Xto_full_str_safe(), html_url.Raw(), Err_.Message_gplx_full(e));
|
||||
app.Usr_dlg().Warn_many("", "", "failed to write html to file; writing directly by memory: page=~{0} file=~{1} err=~{2}", page.Url().To_str(), html_url.Raw(), Err_.Message_gplx_full(e));
|
||||
html_box.Html_doc_html_load_by_mem(html_str);
|
||||
}
|
||||
}
|
||||
@@ -223,39 +223,3 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
|
||||
node_path.Val_(node_path_val);
|
||||
}
|
||||
}
|
||||
class Xog_html_itm__href_extractor {
|
||||
private static final byte Text_tid_none = 0, Text_tid_text = 1, Text_tid_href = 2;
|
||||
private static final byte Href_tid_wiki = 1, Href_tid_site = 2, Href_tid_anchor = 3;
|
||||
private static final byte[] File_protocol_bry = Bry_.new_a7("file://");
|
||||
private static final int File_protocol_len = File_protocol_bry.length;
|
||||
private static final Btrie_slim_mgr href_trie = Btrie_slim_mgr.cs_()
|
||||
.Add_str_byte("/site/" , Href_tid_site)
|
||||
.Add_str_byte("/wiki/" , Href_tid_wiki)
|
||||
.Add_str_byte("#" , Href_tid_anchor)
|
||||
;
|
||||
public static String Html_extract_text(String site, String page, String text_str) {
|
||||
byte[] text_bry = Bry_.new_u8(text_str);
|
||||
int text_tid = Byte_ascii.Xto_digit(text_bry[0]);
|
||||
int text_len = text_bry.length;
|
||||
switch (text_tid) {
|
||||
case Text_tid_none: return "";
|
||||
case Text_tid_text: return String_.new_u8(text_bry, 2, text_len); // 2 to skip "1|"
|
||||
case Text_tid_href: break; // fall through to below
|
||||
default: throw Err_.new_unhandled(text_tid);
|
||||
}
|
||||
int href_bgn = 2; // 2 for length of "2|"
|
||||
if (Bry_.Has_at_bgn(text_bry, File_protocol_bry, 2, text_len)) {
|
||||
href_bgn += File_protocol_len; // skip "file://"
|
||||
}
|
||||
Byte_obj_val href_tid = (Byte_obj_val)href_trie.Match_bgn(text_bry, href_bgn, text_len);
|
||||
if (href_tid != null) {
|
||||
switch (href_tid.Val()) {
|
||||
case Href_tid_wiki: return site + String_.new_u8(text_bry, href_bgn, text_len);
|
||||
case Href_tid_site: return String_.new_u8(text_bry, href_bgn + 6, text_len); // +6 to skip "site/"
|
||||
case Href_tid_anchor: return site + "/wiki/" + page + String_.new_u8(text_bry, href_bgn, text_len);
|
||||
}
|
||||
}
|
||||
return String_.new_u8(text_bry, 2, text_len); // 2 to skip "2|"; handles "http://" text as well as any fall-thru from above
|
||||
}
|
||||
public static final Xog_html_itm__href_extractor _ = new Xog_html_itm__href_extractor(); Xog_html_itm__href_extractor() {}
|
||||
}
|
||||
|
||||
@@ -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.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.xowa.urls.*;
|
||||
class Xog_launcher_tabs {
|
||||
public void Launch(Xog_win_itm win) {
|
||||
Xoae_app app = win.App(); Gfo_log_bfr log_bfr = app.Log_bfr();
|
||||
@@ -59,8 +60,8 @@ class Xog_launcher_tabs {
|
||||
}
|
||||
private void Launch_tab(Xog_win_itm win, Xowe_wiki home_wiki, String launch_str) {
|
||||
Xoae_app app = win.App();
|
||||
Xoa_url launch_url = Xoa_url_parser.Parse_from_url_bar(app, home_wiki, launch_str);
|
||||
Xowe_wiki launch_wiki = app.Wiki_mgr().Get_by_key_or_null(launch_url.Wiki_bry());
|
||||
Xoa_url launch_url = home_wiki.Utl__url_parser().Parse_by_urlbar(launch_str);
|
||||
Xowe_wiki launch_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_key_or_make_init_y(launch_url.Wiki_bry());
|
||||
Xoa_ttl launch_ttl = Xoa_ttl.parse_(launch_wiki, launch_url.Page_bry());
|
||||
Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init(launch_wiki, Xoae_page.new_(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
|
||||
tab.Show_url_bgn(launch_url);
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.core.threads.*; import gplx.gfui.*; import gplx.xowa.gui.history.*; import gplx.xowa.gui.bnds.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.cfgs2.*;
|
||||
import gplx.xowa.pages.*; import gplx.xowa.pages.skins.*;
|
||||
public class Xog_tab_itm implements GfoInvkAble {
|
||||
@@ -25,7 +26,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
public Xog_tab_itm(Xog_tab_mgr tab_mgr, Gfui_tab_itm_data tab_data, Xowe_wiki wiki, Xoae_page page) {
|
||||
this.tab_mgr = tab_mgr; this.tab_data = tab_data; this.wiki = wiki; this.page = page;
|
||||
this.win = tab_mgr.Win(); this.cfg_tab_mgr = win.App().Cfg_regy ().App().Gui_mgr().Tab_mgr();
|
||||
html_itm = new Xog_html_itm(this);
|
||||
this.html_itm = new Xog_html_itm(this);
|
||||
cmd_sync = win.Kit().New_cmd_sync(this);
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;} public void Wiki_(Xowe_wiki v) {this.wiki = v;} private Xowe_wiki wiki;
|
||||
@@ -40,6 +41,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
if (app.App_type().Uid_is_gui()) { // NOTE: only run for gui; will cause firefox addon to fail; DATE:2014-05-03
|
||||
html_box.Html_doc_html_load_by_mem(""); // NOTE: must set source, else control will be empty, and key events will not be raised; DATE:2014-04-30
|
||||
IptBnd_.ipt_to_(IptCfg_.Null, html_box, this, "popup", IptEventType_.MouseDown, IptMouseBtn_.Right);
|
||||
IptBnd_.cmd_to_(IptCfg_.Null, html_box, win, Xog_win_itm.Invk_exit, IptKey_.add_(IptKey_.Alt, IptKey_.F4)); // WORKAROUND:SWT: xulrunner_v24 no longer sends Alt+F4 to SwtShell; must manually subscribe it to quit; DATE:2015-07-31
|
||||
GfoEvMgr_.SubSame(html_box, GfuiElemKeys.Evt_menu_detected, html_itm);
|
||||
gui_mgr.Bnd_mgr().Bind(Xog_bnd_box_.Tid_browser_html, html_box);
|
||||
if (!Env_.Mode_testing())
|
||||
@@ -81,7 +83,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
} private Xoae_page page;
|
||||
public void Page_update_ui() {
|
||||
this.Tab_name_();
|
||||
tab_box.Tab_tip_text_(page.Url().Xto_full_str());
|
||||
tab_box.Tab_tip_text_(page.Url().To_str());
|
||||
}
|
||||
public void Tab_name_() {
|
||||
byte[] tab_name = page.Html_data().Custom_name();
|
||||
@@ -100,21 +102,20 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
public void Show_url_bgn(Xoa_url url) {
|
||||
this.tab_is_loading = true;
|
||||
Xoae_app app = win.App(); Gfo_usr_dlg usr_dlg = app.Usr_dlg();
|
||||
if ( url.Anchor_str() != null // url has anchor
|
||||
if ( url.Anch_str() != null // url has anchor
|
||||
&& url.Eq_page(page.Url()) // url has same page_name as existing page
|
||||
&& url.Args().length == 0) { // url has no args; needed for Category:A?from=b#mw-pages
|
||||
html_itm.Scroll_page_by_id_gui(url.Anchor_str()); // skip page_load and jump to anchor
|
||||
&& url.Qargs_ary().length == 0) { // url has no args; needed for Category:A?from=b#mw-pages
|
||||
html_itm.Scroll_page_by_id_gui(url.Anch_str()); // skip page_load and jump to anchor
|
||||
return;
|
||||
}
|
||||
if (url.Xowa_vnt() != null)
|
||||
wiki.Lang().Vnt_mgr().Cur_vnt_(url.Xowa_vnt());
|
||||
if (win.Page__async__working(url)) return;
|
||||
app.Gui_mgr().Search_suggest_mgr().Cancel(); // cancel pending search_suggest calls
|
||||
if (page != null) page.Tab_data().Close_mgr().When_close(this, url); // cancel any current search cmds
|
||||
app.Log_wtr().Queue_enabled_(true);
|
||||
usr_dlg.Gui_wkr().Clear();
|
||||
this.wiki = app.Wiki_mgr().Get_by_key_or_null(url.Wiki_bry()); // NOTE: must update wiki
|
||||
wiki.Init_assert(); // NOTE: assert wiki.Init before parsing; needed b/c lang (with lang-specific ns) is only loaded on init, and parse Xoa_ttl.parse_ will fail below; EX:pt.wikipedia.org/wiki/Wikipedia:P<>gina principal
|
||||
this.wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_key_or_make_init_y(url.Wiki_bry()); // NOTE: must update wiki variable; DATE:????-??-??; NOTE: must load wiki; DATE:2015-07-22
|
||||
if (url.Page_is_main()) url.Page_bry_(wiki.Props().Main_page());
|
||||
if (url.Vnt_bry() != null) Cur_vnt_(wiki, url.Vnt_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url.Page_bry());
|
||||
if (ttl == null) {usr_dlg.Prog_one("", "", "title is invalid: ~{0}", String_.new_u8(url.Raw())); return;}
|
||||
Tab_name_(String_.new_u8(ttl.Full_txt()));
|
||||
@@ -123,6 +124,14 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
this.Html_box().Html_js_eval_script("if (window.xowa_popups_hide_all != null) window.xowa_popups_hide_all();"); // should be more configurable; DATE:2014-07-09
|
||||
app.Thread_mgr().Page_load_mgr().Add_at_end(new Load_page_wkr(this, wiki, url, ttl)).Run();
|
||||
}
|
||||
private void Cur_vnt_(Xowe_wiki wiki, byte[] vnt) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
gplx.xowa.apis.xowa.wikis.langs.Xoap_lang_variants vnt_mgr = app.Api_root().Wikis().Get(wiki.Domain_bry()).Lang().Variants();
|
||||
if (Bry_.Eq(vnt, vnt_mgr.Current())) return;
|
||||
vnt_mgr.Current_(vnt);
|
||||
app.Cfg_mgr().Set_by_app(String_.Format("xowa.api.wikis.get('{0}').lang.variants.current", wiki.Domain_str()), String_.new_u8(vnt));
|
||||
app.Cfg_mgr().Db_save_txt();
|
||||
}
|
||||
private void Show_url_loaded(Load_page_wkr wkr) {
|
||||
Xowe_wiki wiki = wkr.Wiki(); Xoae_page page = wkr.Page();
|
||||
Xoa_url url = page.Url(); Xoa_ttl ttl = page.Ttl();
|
||||
@@ -151,7 +160,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
return;
|
||||
}
|
||||
if (!page.Redirected()) page.Url_(url); // NOTE: handle redirect from commons
|
||||
if (page.Ttl().Anch_bgn() != Bry_.NotFound) page.Url().Anchor_bry_(page.Ttl().Anch_txt()); // NOTE: occurs when page is a redirect to an anchor; EX: w:Duck race -> Rubber duck#Races
|
||||
if (page.Ttl().Anch_bgn() != Bry_.NotFound) page.Url().Anch_bry_(page.Ttl().Anch_txt()); // NOTE: occurs when page is a redirect to an anchor; EX: w:Duck race -> Rubber duck#Races
|
||||
history_mgr.Add(page);
|
||||
Xog_tab_itm_read_mgr.Show_page(this, page, true);
|
||||
if (app.Api_root().Usr().History().Enabled()) {
|
||||
@@ -203,8 +212,8 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
public void Async() {
|
||||
if (page == null) return; // TEST: occurs during Xog_win_mgr_tst
|
||||
Xowe_wiki wiki = page.Wikie(); Xoae_app app = wiki.Appe(); Xog_win_itm win_itm = tab_mgr.Win(); Gfo_usr_dlg usr_dlg = win_itm.Usr_dlg();
|
||||
app.Usr_dlg().Log_many("", "", "page.async: url=~{0}", page.Url().Xto_full_str_safe());
|
||||
if (page.Url().Anchor_str() != null) html_itm.Scroll_page_by_id_gui(page.Url().Anchor_str());
|
||||
app.Usr_dlg().Log_many("", "", "page.async: url=~{0}", page.Url().To_str());
|
||||
if (page.Url().Anch_str() != null) html_itm.Scroll_page_by_id_gui(page.Url().Anch_str());
|
||||
if (usr_dlg.Canceled()) {usr_dlg.Prog_none("", "", ""); app.Log_wtr().Queue_enabled_(false); return;}
|
||||
int xfer_len = 0;
|
||||
xfer_len = page.File_queue().Count();
|
||||
@@ -271,7 +280,7 @@ class Load_files_wkr implements Gfo_thread_wkr {
|
||||
public void Exec() {
|
||||
try {tab.Async();}
|
||||
catch (Exception e) {
|
||||
tab.Tab_mgr().Win().App().Usr_dlg().Warn_many("error while running file wkr; page=~{0} err=~{1}", tab.Page().Url().Xto_full_str(), Err_.Message_gplx_full(e));
|
||||
tab.Tab_mgr().Win().App().Usr_dlg().Warn_many("error while running file wkr; page=~{0} err=~{1}", tab.Page().Url().To_str(), Err_.Message_gplx_full(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,12 +19,11 @@ package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa
|
||||
import gplx.gfui.*; import gplx.core.threads.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.gui.history.*; import gplx.xowa.pages.*;
|
||||
public class Xog_tab_itm_read_mgr {
|
||||
private static final Xoa_url_parser url_parser = new Xoa_url_parser(); // NOTE: separate url_parser to reduce threading issues
|
||||
public static void Async(Xog_tab_itm tab) {tab.Async();}
|
||||
public static void Show_page(Xog_tab_itm tab, Xoae_page new_page, boolean reset_to_read) {Show_page(tab, new_page, reset_to_read, false, false, Xog_history_stack.Nav_fwd);}
|
||||
public static void Show_page(Xog_tab_itm tab, Xoae_page new_page, boolean reset_to_read, boolean new_page_is_same, boolean show_is_err, byte history_nav_type) {
|
||||
if (reset_to_read) tab.View_mode_(Xopg_view_mode.Tid_read);
|
||||
if (new_page.Url().Action_is_edit()) tab.View_mode_(Xopg_view_mode.Tid_edit);
|
||||
if (new_page.Url().Qargs_mgr().Match(Xoa_url_.Qarg__action, Xoa_url_.Qarg__action__edit)) tab.View_mode_(Xopg_view_mode.Tid_edit);
|
||||
Xoae_page cur_page = tab.Page(); Xog_html_itm html_itm = tab.Html_itm(); Gfui_html html_box = html_itm.Html_box();
|
||||
Xog_win_itm win = tab.Tab_mgr().Win();
|
||||
if (cur_page != null && !new_page_is_same) { // if new_page_is_same, don't update DocPos; will "lose" current position
|
||||
@@ -37,7 +36,7 @@ public class Xog_tab_itm_read_mgr {
|
||||
catch (Exception e) {
|
||||
if (String_.Eq(Err_.Message_lang(e), "class org.eclipse.swt.SWTException Widget is disposed")) return; // ignore errors caused by user closing tab early; DATE:2014-07-26
|
||||
if (show_is_err) { // trying to show error page, but failed; don't show again, else recursion until out of memory; TODO:always load error page; no reason it should fail; WHEN:html_skin; DATE:2014-06-08
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "fatal error trying to load error page; page=~{0} err=~{1}" + new_page.Url().Xto_full_str_safe(), Err_.Message_gplx_full(e));
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "fatal error trying to load error page; page=~{0} err=~{1}" + new_page.Url().To_str(), Err_.Message_gplx_full(e));
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -61,8 +60,8 @@ public class Xog_tab_itm_read_mgr {
|
||||
public static void Update_selected_tab_blank(Xog_win_itm win) {Update_selected_tab(win, null, null);} // called when all tabs are null
|
||||
public static void Update_selected_tab(Xog_win_itm win, Xoa_url url, Xoa_ttl ttl) {
|
||||
String url_str = "", win_str = Win_text_blank;
|
||||
if (url != null && ttl != null) {
|
||||
try {url_str = url_parser.Build_str(url);}
|
||||
if (url != null && ttl != null) { // TODO: remove; no longer needed for new url parser
|
||||
try {url_str = url.To_str();}
|
||||
catch (Exception e) { // HACK: failed pages will have a null wiki; for now, catch and ignore; DATE:2014-06-22
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "failed to build url: url=~{0}, err=~{1}", String_.new_u8(url.Raw()), Err_.Message_gplx_full(e));
|
||||
url_str = String_.new_u8(ttl.Full_txt());
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.cfgs2.*; import gplx.xowa.apis.xowa.gui.browsers.*; import gplx.xowa.specials.*;
|
||||
import gplx.xowa.urls.*;
|
||||
public class Xog_tab_mgr implements GfoEvObj {
|
||||
private Ordered_hash tab_regy = Ordered_hash_.new_(); private int tab_uid = 0;
|
||||
public Xog_tab_mgr(Xog_win_itm win) {
|
||||
@@ -77,7 +78,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
boolean active_tab_is_null = this.Active_tab_is_null();
|
||||
Xowe_wiki cur_wiki = active_tab_is_null ? win.App().Usere().Wiki() : active_tab.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(cur_wiki, Xows_special_meta_.Itm__default_tab.Ttl_bry());
|
||||
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(win.App(), cur_wiki, ttl.Full_db_as_str());
|
||||
Xoa_url url = cur_wiki.Utl__url_parser().Parse_by_urlbar(ttl.Full_db_as_str());
|
||||
Xog_tab_itm rv = Tabs_new(focus, active_tab_is_null, cur_wiki, Xoae_page.new_(cur_wiki, ttl));
|
||||
rv.Page_update_ui();
|
||||
rv.Show_url_bgn(url);
|
||||
@@ -102,7 +103,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
}
|
||||
public void Tabs_new_dupe(boolean focus) {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
String url = active_tab.Page().Url().Xto_full_str();
|
||||
String url = active_tab.Page().Url().To_str();
|
||||
Tabs_new_dflt(focus);
|
||||
win.Page__navigate_by_url_bar(url);
|
||||
}
|
||||
@@ -161,7 +162,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
private void Tabs_closed(String key) {
|
||||
Xog_tab_itm itm = Tabs_get_by_key_or_warn(key); if (itm == null) return;
|
||||
itm.Html_box().Html_dispose();
|
||||
closed_undo_list.Add(itm.Page().Url().Xto_full_str());
|
||||
closed_undo_list.Add(itm.Page().Url().To_str());
|
||||
tab_regy.Del(key);
|
||||
if (tab_regy.Count() == 0) {
|
||||
active_tab = Xog_tab_itm_.Null;
|
||||
@@ -218,7 +219,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
public void Tabs_new_link(String link, boolean focus) {
|
||||
Xowe_wiki wiki = active_tab.Wiki();
|
||||
Xog_tab_itm new_tab = Tabs_new(focus, false, wiki, Xoae_page.new_(wiki, active_tab.Page().Ttl())); // NOTE: do not use ttl from link, else middle-clicking pages with anchors won't work; DATE:2015-05-03
|
||||
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(win.App(), wiki, link); // NOTE: link must be of form domain/wiki/page; DATE:2014-05-27
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse_by_urlbar(link); // NOTE: link must be of form domain/wiki/page; DATE:2014-05-27
|
||||
new_tab.Show_url_bgn(url);
|
||||
if (focus)
|
||||
tab_mgr.Tabs_select_by_idx(new_tab.Tab_idx());
|
||||
|
||||
@@ -18,12 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.core.threads.*; import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.history.*; import gplx.xowa.xtns.math.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.gui.urls.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.specials.*;
|
||||
import gplx.xowa.urls.*;
|
||||
public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
private GfoInvkAble sync_cmd;
|
||||
public Xog_win_itm(Xoae_app app, Xoa_gui_mgr gui_mgr) {
|
||||
this.app = app; this.gui_mgr = gui_mgr;
|
||||
this.tab_mgr = new Xog_tab_mgr(this);
|
||||
this.tab_mgr = new Xog_tab_mgr(this);
|
||||
}
|
||||
public Gfui_kit Kit() {return kit;} private Gfui_kit kit;
|
||||
public Xoa_gui_mgr Gui_mgr() {return gui_mgr;} private Xoa_gui_mgr gui_mgr;
|
||||
@@ -57,9 +59,9 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_link_click)) Win__link_click();
|
||||
else if (ctx.Match(k, Invk_link_print)) Xog_win_itm__prog_href_mgr.Print(this);
|
||||
else if (ctx.Match(k, Gfui_html.Evt_link_hover)) Xog_win_itm__prog_href_mgr.Hover(app, this.Active_tab().Wiki(), this.Active_page(), m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Gfui_html.Evt_link_hover)) Xog_win_itm__prog_href_mgr.Hover(app, this.Active_tab().Wiki(), this.Active_page(), Xoh_href_gui_utl.Standardize_xowa_link(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Gfui_html.Evt_location_changed)) Win__link_clicked(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Gfui_html.Evt_location_changing)) Page__navigate_by_internal_href(m.ReadStr("v"), tab_mgr.Active_tab());
|
||||
else if (ctx.Match(k, Gfui_html.Evt_location_changing)) Page__navigate_by_href(tab_mgr.Active_tab(), Xoh_href_gui_utl.Standardize_xowa_link(m.ReadStr("v")));
|
||||
else if (ctx.Match(k, Gfui_html.Evt_win_resized)) Refresh_win_size();
|
||||
else if (ctx.Match(k, Invk_page_refresh)) Page__refresh();
|
||||
else if (ctx.Match(k, Invk_page_async_exec)) Xog_tab_itm_read_mgr.Async((Xog_tab_itm)m.ReadObj("v"));
|
||||
@@ -86,6 +88,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
else if (ctx.Match(k, Invk_app)) return app;
|
||||
else if (ctx.Match(k, Invk_page)) return this.Active_page();
|
||||
else if (ctx.Match(k, Invk_wiki)) return this.Active_tab().Wiki();
|
||||
else if (ctx.Match(k, Invk_exit)) App__exit();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
@@ -105,6 +108,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
, Invk_page_edit_save = "page_edit_save", Invk_page_edit_save_draft = "page_edit_save_draft", Invk_page_edit_preview = "page_edit_preview", Invk_page_edit_rename = "page_edit_rename"
|
||||
, Invk_page_dbg_wiki = "page_dbg_wiki", Invk_page_dbg_html = "page_dbg_html"
|
||||
, Invk_eval = "eval"
|
||||
, Invk_exit = "exit"
|
||||
// xowa.gfs: shortcuts
|
||||
, Invk_page_goto = "page_goto", Invk_page_goto_recent = "page_goto_recent"
|
||||
;
|
||||
@@ -113,7 +117,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
if (wiki.Gui_mgr().Cfg_browser().Content_editable()) {
|
||||
String href = tab.Html_itm().Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, Gfui_html.Atr_href, null);
|
||||
if (String_.Len_eq_0(href)) return; // NOTE: href can be null for images; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]; link= basically means don't link to image
|
||||
Page__navigate_by_internal_href(href, tab);
|
||||
Page__navigate_by_href(tab, href);
|
||||
}
|
||||
}
|
||||
private void Win__link_clicked(String anchor_raw) {
|
||||
@@ -127,7 +131,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
url_box.Text_(url + "#" + anchor_str); // update url box
|
||||
page.Html_data().Bmk_pos_(Xog_history_itm.Html_doc_pos_toc); // HACK: anchor clicked; set docPos of curentPage to TOC (so back will go back to TOC)
|
||||
tab.History_mgr().Update_html_doc_pos(page, Xog_history_stack.Nav_by_anchor); // HACK: update history_mgr; note that this must occur before setting Anchor (since Anchor will generate a new history itm)
|
||||
page.Url().Anchor_bry_(anchor_bry); // update url
|
||||
page.Url().Anch_bry_(anchor_bry); // update url
|
||||
}
|
||||
tab.History_mgr().Add(page);
|
||||
app.Usere().History_mgr().Add(page.Url(), page.Ttl(), Bry_.Add_w_dlm(Byte_ascii.Hash, page.Url().Page_bry(), anchor_bry));
|
||||
@@ -155,8 +159,8 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
tab.Page_(page);
|
||||
wiki.ParsePage_root(page, true); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
|
||||
Xoa_url url = page.Url();
|
||||
if (url.Args_exists(Xoa_url_parser.Bry_arg_action, Xoa_url_parser.Bry_arg_action_edit)) // url has ?action=edit
|
||||
app.Utl__url_parser().Parse(url, url.Xto_full_bry()); // remove all query args; handle (1) s.w:Earth?action=edit; (2) click on Read; DATE:2014-03-06
|
||||
if (url.Qargs_mgr().Match(Xoa_url_.Qarg__action, Xoa_url_.Qarg__action__edit)) // url has ?action=edit
|
||||
url = tab.Wiki().Utl__url_parser().Parse(url.To_bry_full_wo_qargs()); // remove all query args; handle (1) s.w:Earth?action=edit; (2) click on Read; DATE:2014-03-06
|
||||
}
|
||||
tab.View_mode_(new_mode_tid);
|
||||
if (page.Missing()) return;
|
||||
@@ -166,10 +170,9 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
public void Page__navigate_by_search() {Page__navigate_by_url_bar(app.Gui_mgr().Win_cfg().Search_box_fmtr().Bld_str_many(search_box.Text()));}
|
||||
public void Page__navigate_by_url_bar(String href) {
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab_assert();
|
||||
Xoa_url url = Xoa_url_parser.Parse_from_url_bar(app, tab.Wiki(), href);
|
||||
tab.Show_url_bgn(url);
|
||||
tab.Show_url_bgn(tab.Wiki().Utl__url_parser().Parse_by_urlbar(href));
|
||||
}
|
||||
private void Page__navigate_by_internal_href(String href, Xog_tab_itm tab) { // NOTE: different from Navigate_by_url_bar in that it handles "file:///" and other @gplx.Internal protected formats; EX: "/site/", "about:blank"; etc..
|
||||
private void Page__navigate_by_href(Xog_tab_itm tab, String href) { // NOTE: different from Navigate_by_url_bar in that it handles "file:///" and other @gplx.Internal protected formats; EX: "/site/", "about:blank"; etc..
|
||||
Xoa_url url = Xog_url_wkr.Exec_url(this, href);
|
||||
if (url != Xog_url_wkr.Rslt_handled)
|
||||
tab.Show_url_bgn(url);
|
||||
@@ -198,10 +201,10 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab(); Xoae_page page = tab.Page(); Xog_html_itm html_itm = tab.Html_itm();
|
||||
page.Html_data().Bmk_pos_(html_itm.Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Win__vpos_get));
|
||||
html_itm.Show(page);
|
||||
if (page.Url().Anchor_str() == null)
|
||||
if (page.Url().Anch_str() == null)
|
||||
html_itm.Scroll_page_by_bmk_gui();
|
||||
else
|
||||
html_itm.Scroll_page_by_id_gui(page.Url().Anchor_str());
|
||||
html_itm.Scroll_page_by_id_gui(page.Url().Anch_str());
|
||||
Page__async__bgn(tab);
|
||||
}
|
||||
public void Page__async__bgn(Xog_tab_itm tab) {
|
||||
@@ -252,8 +255,8 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
Xoae_page new_page = Xoae_page.new_(home_wiki, ttl);
|
||||
gplx.xowa.servers.Gxw_html_server.Assert_tab(app, new_page); // HACK: assert at least 1 tab for Firefox addon; DATE:2015-01-23
|
||||
this.Active_page_(new_page);
|
||||
Xoa_url url = Xoa_url.blank_();
|
||||
url = Xoa_url_parser.Parse_url(url, app, home_wiki, url_bry, 0, url_bry.length, true);
|
||||
Xoa_url url = Xoa_url.blank();
|
||||
url = home_wiki.Utl__url_parser().Parse(url_bry);
|
||||
new_page.Url_(url);
|
||||
return App__retrieve_by_href(url, output_html);
|
||||
}
|
||||
@@ -261,7 +264,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
public byte[] App__retrieve_by_href(String href, boolean output_html) {return App__retrieve_by_href(Xog_url_wkr.Exec_url(this, href), output_html);} // NOTE: used by drd
|
||||
private byte[] App__retrieve_by_href(Xoa_url url, boolean output_html) {
|
||||
if (url == null) return Bry_.new_a7("missing");
|
||||
Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_null(url.Wiki_bry());
|
||||
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_key_or_make_init_y(url.Wiki_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url.Page_bry());
|
||||
Xoae_page new_page = wiki.Load_page_by_ttl(url, ttl);
|
||||
if (new_page.Missing()) {return Bry_.Empty;}
|
||||
@@ -299,7 +302,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
|
||||
GfoEvMgr_.SubSame_many(this, this, Gfui_html.Evt_location_changed, Gfui_html.Evt_location_changing, Gfui_html.Evt_link_hover);
|
||||
GfoEvMgr_.SubSame(win_box, Gfui_html.Evt_win_resized, this);
|
||||
GfoEvMgr_.Sub(app.Gui_mgr().Win_cfg().Font(), Xol_font_info.Font_changed, this, Invk_window_font_changed);
|
||||
GfoEvMgr_.Sub(app.Gui_mgr().Win_cfg().Font(), Xol_font_info.Font_changed, this, Invk_window_font_changed);
|
||||
|
||||
if ( !Env_.Mode_testing()
|
||||
&& app.App_type().Uid_is_gui()) // only run for gui; do not run for tcp/http server; DATE:2014-05-03
|
||||
|
||||
@@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.html.hrefs.*;
|
||||
public class Xog_win_itm__prog_href_mgr {
|
||||
private static Xoh_href tmp_href = new Xoh_href();
|
||||
private static Bry_bfr tmp_bfr = Bry_bfr.reset_(512);
|
||||
public static void Print(Xog_win_itm win) { // PURPOSE: print href in prog box when in content editable mode
|
||||
String href = win.Active_html_box().Html_js_eval_proc_as_str(Xog_js_procs.Selection__get_active_for_editable_mode, Gfui_html.Atr_href, "");// get selected href from html_box
|
||||
href = Xoa_app_.Utl__encoder_mgr().Href().Decode_str(href); // remove url encodings
|
||||
@@ -33,8 +31,9 @@ public class Xog_win_itm__prog_href_mgr {
|
||||
usr_dlg.Prog_direct(""); // clear out previous entry
|
||||
return;
|
||||
}
|
||||
app.Href_parser().Parse(tmp_href, href, wiki, page.Ttl().Page_url());
|
||||
tmp_href.Print_to_bfr(tmp_bfr, !app.Api_root().Gui().Browser().Prog().Show_short_url());
|
||||
usr_dlg.Prog_direct(tmp_bfr.Xto_str_and_clear());
|
||||
Xoa_url url = Xoa_url.blank();
|
||||
app.Html__href_parser().Parse_as_url(url, Bry_.new_u8(href), wiki, page.Ttl().Page_txt());
|
||||
// Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(href));
|
||||
usr_dlg.Prog_direct(String_.new_u8(url.To_bry(!app.Api_root().Gui().Browser().Prog().Show_short_url(), Bool_.Y)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoh_consts {
|
||||
public static final String
|
||||
Atr_xowa_title_str = "xowa_title"
|
||||
Atr_xowa_title_str = "xowa_title"
|
||||
, Img_w_str = "width"
|
||||
, Img_h_str = "height"
|
||||
;
|
||||
@@ -31,14 +31,13 @@ public class Xoh_consts {
|
||||
, A_bgn = Bry_.new_a7("<a href=\""), A_bgn_lnki_0 = Bry_.new_a7("\" title=\""), A_mid_xowa_title = Bry_.new_a7("\" xowa_title=\"")
|
||||
, A_mid_id = Bry_.new_a7("\" id=\"xowa_lnki_")
|
||||
, A_end = Bry_.new_a7("</a>")
|
||||
|
||||
, Div_bgn_open = Bry_.new_a7("<div ")
|
||||
, Div_end = Bry_.new_a7("</div>")
|
||||
|
||||
, Img_bgn = Bry_.new_a7("<img src=\"")
|
||||
, Span_bgn_open = Bry_.new_a7("<span")
|
||||
, Span_end = Bry_.new_a7("</span>")
|
||||
, Span_bgn = Bry_.new_a7("<span>")
|
||||
, Img_bgn = Bry_.new_a7("<img src=\"")
|
||||
, Span_bgn_open = Bry_.new_a7("<span")
|
||||
, Span_end = Bry_.new_a7("</span>")
|
||||
, Span_bgn = Bry_.new_a7("<span>")
|
||||
|
||||
, Pre_bgn = Bry_.new_a7("<pre>"), Pre_end = Bry_.new_a7("</pre>")
|
||||
, Pre_bgn_open = Bry_.new_a7("<pre")
|
||||
@@ -53,6 +52,5 @@ public class Xoh_consts {
|
||||
, Style_atr = Bry_.new_a7(" style=\"")
|
||||
, Atr_xowa_title_bry = Bry_.new_a7(Atr_xowa_title_str)
|
||||
;
|
||||
|
||||
public static final int Nbsp_int = 160;
|
||||
}
|
||||
|
||||
@@ -19,17 +19,16 @@ package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.html.tidy.*; import gplx.xowa.html.utils.*; import gplx.xowa.html.skins.*;
|
||||
public class Xoh_html_mgr implements GfoInvkAble {
|
||||
public Xoh_html_mgr(Xoae_app app) {
|
||||
page_mgr = new Xoh_page_mgr(app);
|
||||
js_cleaner = new Xoh_js_cleaner(app);
|
||||
}
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
tidy_mgr.Init_by_app(app);
|
||||
}
|
||||
public Xop_xatr_whitelist_mgr Whitelist_mgr() {return whitelist_mgr;} private Xop_xatr_whitelist_mgr whitelist_mgr = new Xop_xatr_whitelist_mgr().Ini();
|
||||
public Xoh_page_mgr Page_mgr() {return page_mgr;} private Xoh_page_mgr page_mgr;
|
||||
public Xoh_tidy_mgr Tidy_mgr() {return tidy_mgr;} private Xoh_tidy_mgr tidy_mgr = new Xoh_tidy_mgr();
|
||||
public Xoh_js_cleaner Js_cleaner() {return js_cleaner;} private Xoh_js_cleaner js_cleaner;
|
||||
public Xoh_skin_mgr Skin_mgr() {return skin_mgr;} private Xoh_skin_mgr skin_mgr = new Xoh_skin_mgr();
|
||||
public Xop_xatr_whitelist_mgr Whitelist_mgr() {return whitelist_mgr;} private final Xop_xatr_whitelist_mgr whitelist_mgr = new Xop_xatr_whitelist_mgr().Ini();
|
||||
public Xoh_page_mgr Page_mgr() {return page_mgr;} private final Xoh_page_mgr page_mgr = new Xoh_page_mgr();
|
||||
public Xoh_tidy_mgr Tidy_mgr() {return tidy_mgr;} private final Xoh_tidy_mgr tidy_mgr = new Xoh_tidy_mgr();
|
||||
public Xoh_js_cleaner Js_cleaner() {return js_cleaner;} private final Xoh_js_cleaner js_cleaner;
|
||||
public Xoh_skin_mgr Skin_mgr() {return skin_mgr;} private final Xoh_skin_mgr skin_mgr = new Xoh_skin_mgr();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_page)) return page_mgr;
|
||||
else if (ctx.Match(k, Invk_tidy)) return tidy_mgr;
|
||||
|
||||
@@ -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.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.net.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*;
|
||||
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.html.hzips.*;
|
||||
public class Xoh_html_wtr {
|
||||
@@ -633,7 +633,7 @@ class Xoh_display_ttl_wtr {
|
||||
Atr_key_style = Bry_.new_a7("style")
|
||||
, Msg_style_restricted = Bry_.new_a7(" style='/* attempt to bypass $wgRestrictDisplayTitle */'")
|
||||
;
|
||||
private Btrie_slim_mgr style_trie = Btrie_slim_mgr.ci_ascii_()
|
||||
private Btrie_slim_mgr style_trie = Btrie_slim_mgr.ci_a7()
|
||||
.Add_str_byte__many(Byte_.By_int(0), "display", "user-select", "visibility"); // if ( preg_match( '/(display|user-select|visibility)\s*:/i', $decoded['style'] ) ) {
|
||||
public boolean Is_style_restricted(Bry_bfr bfr, Xoh_wtr_ctx hctx, byte[] src, Xop_xatr_itm atr, byte[] atr_key) {
|
||||
if (atr_key != null
|
||||
|
||||
@@ -18,10 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.html.portal.*;
|
||||
public class Xoh_page_mgr implements GfoInvkAble {
|
||||
public Xoh_page_mgr(Xoae_app app) {
|
||||
this.subpages_bldr = new Xoh_subpages_bldr(app);
|
||||
}
|
||||
public Xoh_subpages_bldr Subpages_bldr() {return subpages_bldr;} private Xoh_subpages_bldr subpages_bldr;
|
||||
public Xoh_subpages_bldr Subpages_bldr() {return subpages_bldr;} private final Xoh_subpages_bldr subpages_bldr = new Xoh_subpages_bldr();
|
||||
public boolean Font_enabled() {return font_enabled;} private boolean font_enabled = false;
|
||||
public void Font_enabled_(boolean v) {font_enabled = v;}
|
||||
public String Font_name() {return font_name;} private String font_name = "Arial";
|
||||
|
||||
@@ -67,11 +67,17 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
byte[] page_content_sub = Xoh_page_wtr_wkr_.Bld_page_content_sub(app, wiki, page, tmp_bfr);
|
||||
byte[] js_edit_toolbar_bry = view_tid == Xopg_view_mode.Tid_edit ? wiki.Fragment_mgr().Html_js_edit_toolbar() : Bry_.Empty;
|
||||
Xow_portal_mgr portal_mgr = wiki.Html_mgr().Portal_mgr().Init_assert();
|
||||
byte[] page_name = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, null); // NOTE: page_name does not show display_title (<i>). always pass in null
|
||||
byte[] page_display = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl());
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) { // VNT
|
||||
page_name = vnt_mgr.Convert_text(wiki, page_name);
|
||||
page_display = vnt_mgr.Convert_text(wiki, page_display);
|
||||
}
|
||||
fmtr.Bld_bfr_many(html_bfr
|
||||
, root_dir_bry, Xoa_app_.Version, Xoa_app_.Build_date, app.Tcp_server().Running_str()
|
||||
, page.Revision_data().Id()
|
||||
, Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, null) // NOTE: page_name does not show display_title (<i>). always pass in null
|
||||
, Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl())
|
||||
, page_name, page_display
|
||||
, page_modified_on_msg
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Head_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), page_body_class, html_content_editable
|
||||
@@ -123,9 +129,6 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
boolean tidy_enabled = tidy_mgr.Enabled();
|
||||
Bry_bfr hdom_bfr = tidy_enabled ? app.Utl__bfr_mkr().Get_m001() : bfr; // if tidy, then write to tidy_bfr; note that bfr already has <html> and <head> written to it, so this can't be passed to tidy; DATE:2014-06-11
|
||||
wiki.Html_mgr().Html_wtr().Write_all(hdom_bfr, page.Wikie().Ctx(), hctx, page.Root().Data_mid(), page.Root());
|
||||
// Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
// if (vnt_mgr.Enabled()) // VNT
|
||||
// hdom_bfr.Add(vnt_mgr.Convert_text(wiki, hdom_bfr.Xto_bry_and_clear()));
|
||||
if (tidy_enabled) {
|
||||
tidy_mgr.Run_tidy_html(page, hdom_bfr);
|
||||
bfr.Add_bfr_and_clear(hdom_bfr);
|
||||
@@ -145,6 +148,9 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
else
|
||||
wiki.Html_mgr().Ctg_mgr().Bld(bfr, page, ctgs_len);
|
||||
}
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) // VNT
|
||||
bfr.Add(vnt_mgr.Convert_text(wiki, bfr.Xto_bry_and_clear()));
|
||||
}
|
||||
private void Write_body_pre(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, byte[] data_raw, Bry_bfr tmp_bfr) {
|
||||
Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), tmp_bfr, data_raw, 0, data_raw.length, false, false);
|
||||
|
||||
@@ -53,7 +53,7 @@ class Xoh_ctg_itm_fmtr implements Bry_fmtr_arg {
|
||||
for (int i = 0; i < ctgs_len; i++) {
|
||||
byte[] page_name = page.Category_list()[i];
|
||||
tmp_bfr.Add(ctg_prefix).Add(page_name);
|
||||
page.Wikie().Appe().Href_parser().Build_to_bfr(tmp_href, app, wiki.Domain_bry(), wiki.Ttl_parse(tmp_bfr.Xto_bry_and_clear()));
|
||||
page.Wikie().Appe().Html__href_wtr().Build_to_bfr(tmp_href, app, wiki.Domain_bry(), wiki.Ttl_parse(tmp_bfr.Xto_bry_and_clear()));
|
||||
itm_fmtr.Bld_bfr(bfr, tmp_href.Xto_bry_and_clear(), page_name, page_name);
|
||||
}
|
||||
tmp_bfr.Mkr_rls();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.json.*;
|
||||
public class Bridge_cmd_mgr {
|
||||
private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs();
|
||||
public void Add(Bridge_cmd_itm cmd) {cmd_hash.Add_bry_obj(cmd.Key(), cmd);}
|
||||
public String Exec(GfoMsg m) {
|
||||
if (m.Args_count() == 0) throw Err_.new_("bridge.cmds", "no json specified for json_exec");
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.html.bridges.dbuis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*;
|
||||
import gplx.core.json.*; import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
public class Dbui_cmd_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private boolean init;
|
||||
public void Init_by_bridge(Bridge_cmd_mgr cmd_mgr) {
|
||||
if (init) return;
|
||||
|
||||
@@ -41,7 +41,7 @@ class Dbui_head_cell_fmtr implements Bry_fmtr_arg {
|
||||
Dbui_col_itm col = cols[i];
|
||||
fmtr.Bld_bfr_many(bfr, col.Width(), col.Display());
|
||||
}
|
||||
bfr.Add_str_a7("\n <div class='xo_head xo_resizable_col' style='width:35px;'> </div>"); // btns headers
|
||||
bfr.Add_str_a7("\n <div class='xo_head xo_resizable_col' style='width:50px;'> </div>"); // btns headers
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xohd_hdump_wtr {
|
||||
public void Generate_hdump(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
page_wtr_mgr.Wkr(Xopg_view_mode.Tid_read).Write_body(tmp_bfr, Xoh_wtr_ctx.Hdump, page);
|
||||
if (!Env_.Mode_testing()) page.Wikie().Html_mgr().Hzip_mgr().Write(tmp_bfr, new Xodump_stats_itm(), page.Url().Xto_full_bry(), tmp_bfr.Xto_bry_and_clear()); // hzip data;
|
||||
if (!Env_.Mode_testing()) page.Wikie().Html_mgr().Hzip_mgr().Write(tmp_bfr, new Xodump_stats_itm(), page.Url().To_bry_full_wo_qargs(), tmp_bfr.Xto_bry_and_clear()); // hzip data;
|
||||
page.Hdump_data().Body_(tmp_bfr.Xto_bry_and_clear()); // write to body bry
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user