1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-07-13 23:23:30 -04:00
parent ecbe2918d8
commit bc10cd76b6
316 changed files with 3251 additions and 1652 deletions

View File

@@ -410,7 +410,7 @@ default: throw Err_mgr._.unhandled_(id);
} static byte[][] Bry__;
public static int Id_by_bry(byte[] find) {
if (hash == null) {
hash = Hash_adp_bry.ci_();
hash = Hash_adp_bry.ci_ascii_(); // ASCII: all MW kwds appear to be ASCII; EX: "redirect", "toc", "currentmont", etc.
if (Bry__ == null) Bry_init();
int len = Bry__.length;
for (int i = 0; i < len; i++) {

View File

@@ -16,11 +16,12 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.core.btries.*;
public class Xol_kwd_mgr implements GfoInvkAble {
public Xol_kwd_mgr(Xol_lang lang) {this.lang = lang;} private Xol_lang lang; Xol_kwd_grp[] grps = new Xol_kwd_grp[Xol_kwd_grp_.Id__max];
public int Len() {return grps.length;}
public ByteTrieMgr_slim Trie_raw() {if (trie_raw == null) trie_raw = Xol_kwd_mgr.trie_(this, Xol_kwd_grp_.Id_str_rawsuffix); return trie_raw;} private ByteTrieMgr_slim trie_raw;
public ByteTrieMgr_slim Trie_nosep() {if (trie_nosep == null) trie_nosep = Xol_kwd_mgr.trie_(this, Xol_kwd_grp_.Id_nocommafysuffix); return trie_nosep;} private ByteTrieMgr_slim trie_nosep;
public Btrie_slim_mgr Trie_raw() {if (trie_raw == null) trie_raw = Xol_kwd_mgr.trie_(this, Xol_kwd_grp_.Id_str_rawsuffix); return trie_raw;} private Btrie_slim_mgr trie_raw;
public Btrie_slim_mgr Trie_nosep() {if (trie_nosep == null) trie_nosep = Xol_kwd_mgr.trie_(this, Xol_kwd_grp_.Id_nocommafysuffix); return trie_nosep;} private Btrie_slim_mgr trie_nosep;
public Xol_kwd_grp Get_at(int id) {return grps[id];}
public Xol_kwd_grp Get_or_new(int id) {
Xol_kwd_grp rv = grps[id];
@@ -41,13 +42,13 @@ public class Xol_kwd_mgr implements GfoInvkAble {
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_lang = Xol_lang_srl.Invk_lang, Invk_load_text = Xol_lang_srl.Invk_load_text;
public static ByteTrieMgr_slim trie_(Xol_kwd_mgr mgr, int id) {
public static Btrie_slim_mgr trie_(Xol_kwd_mgr mgr, int id) {
Xol_kwd_grp grp = mgr.Get_at(id);
ByteTrieMgr_slim rv = ByteTrieMgr_slim.new_(grp.Case_match());
Btrie_slim_mgr rv = Btrie_slim_mgr.new_(grp.Case_match());
int len = grp.Itms().length;
for (int i = 0; i < len; i++) {
Xol_kwd_itm itm = grp.Itms()[i];
rv.Add(itm.Val(), itm);
rv.Add_obj(itm.Val(), itm);
}
return rv;
}

View File

@@ -77,11 +77,7 @@ public class Xol_lang implements GfoInvkAble {
public Xop_lnki_arg_parser Lnki_arg_parser() {return lnki_arg_parser;} private Xop_lnki_arg_parser lnki_arg_parser = new Xop_lnki_arg_parser();
public Xol_func_name_regy Func_regy() {return func_regy;} private Xol_func_name_regy func_regy;
public byte Img_thumb_halign_default() {return img_thumb_halign_default;} private byte img_thumb_halign_default = Xop_lnki_align_h.Right;
public Hash_adp_bry Xatrs_ref() {return xatrs_ref;} private Hash_adp_bry xatrs_ref = Hash_adp_bry.ci_();
public Hash_adp_bry Xatrs_references() {return xatrs_references;} private Hash_adp_bry xatrs_references = Hash_adp_bry.ci_();
public Hash_adp_bry Xatrs_pages() {return xatrs_pages;} private Hash_adp_bry xatrs_pages = Hash_adp_bry.ci_();
public Hash_adp_bry Xatrs_section() {if (xatrs_section == null) xatrs_section = Lst_pfunc_lst.new_xatrs_(this); return xatrs_section;} private Hash_adp_bry xatrs_section;
public Hash_adp_bry Xatrs_section() {if (xatrs_section == null) xatrs_section = Lst_section_nde.new_xatrs_(this); return xatrs_section;} private Hash_adp_bry xatrs_section;
public void Evt_lang_changed() {
lnki_arg_parser.Evt_lang_changed(this);
func_regy.Evt_lang_changed(this);

View File

@@ -48,10 +48,6 @@ public class Xol_lang_ {
lang.Num_mgr().Separators_mgr().Set(Xol_num_mgr.Separators_key__grp, Xol_num_mgr.Separators_key__grp);
lang.Num_mgr().Separators_mgr().Set(Xol_num_mgr.Separators_key__dec, Xol_num_mgr.Separators_key__dec);
lang.Lnki_trail_mgr().Add_range(Byte_ascii.Ltr_a, Byte_ascii.Ltr_z);// REF.MW:MessagesEn.php|$linkTrail = '/^([a-z]+)(.*)$/sD';
lang.Xatrs_ref().Add_str_obj("name", Byte_obj_val.new_(Ref_nde.Xatr_id_name));
lang.Xatrs_ref().Add_str_obj("group", Byte_obj_val.new_(Ref_nde.Xatr_id_group));
lang.Xatrs_ref().Add_str_obj("follow", Byte_obj_val.new_(Ref_nde.Xatr_id_follow));
lang.Xatrs_references().Add_str_obj("group", Byte_obj_val.new_(References_nde.Xatr_id_group));
Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_year , "CURRENTYEAR");
kwd_mgr.New(Bool_.Y, Xol_kwd_grp_.Id_utc_month_int_len2 , "CURRENTMONTH", "CURRENTMONTH2");

View File

@@ -435,7 +435,7 @@ public class Xol_lang_itm_ {
public static Hash_adp_bry Regy() {
if (regy == null) {
// NOTE: any parenthetical String below will have an "unseen" character of "\xE2\x80\xAA" at the begining and "\xE2\x80\xAC" at the end. They are responsible for parentheses-orientation in RTL langs.
regy = Hash_adp_bry.ci_(); // NOTE: must be ci; EX: {{#languages:FR}}
regy = Hash_adp_bry.ci_ascii_(); // ASCII:lang_code; NOTE: must be ci; EX: {{#languages:FR}}
Regy_add(regy, Id_aa, "aa", "Qafár af");
Regy_add(regy, Id_ab, "ab", "Аҧсуа");
Regy_add(regy, Id_ace, "ace", "Acèh");

View File

@@ -16,17 +16,18 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.core.btries.*;
public class Xol_lnki_trail_mgr implements GfoInvkAble {
public Xol_lnki_trail_mgr(Xol_lang lang) {}
public void Clear() {trie.Clear();}
public int Count() {return trie.Count();}
public ByteTrieMgr_slim Trie() {return trie;} ByteTrieMgr_slim trie = ByteTrieMgr_slim.cs_();
public void Add(byte[] v) {trie.Add(v, v);}
public Btrie_slim_mgr Trie() {return trie;} Btrie_slim_mgr trie = Btrie_slim_mgr.cs_();
public void Add(byte[] v) {trie.Add_obj(v, v);}
public void Del(byte[] v) {trie.Del(v);}
private void Add(String... ary) {
for (String itm_str : ary) {
byte[] itm = Bry_.new_utf8_(itm_str);
trie.Add(itm, itm);
trie.Add_obj(itm, itm);
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -35,7 +35,7 @@ class Xol_lnki_trail_mgr_fxt {
Tfds.Eq(expd_len, lang.Lnki_trail_mgr().Count());
for (int i = 0; i < expd_len; i++) {
byte[] expd_bry = Bry_.new_utf8_(expd_ary[i]);
byte[] actl_bry = (byte[])lnki_trail_mgr.Trie().MatchAtCur(expd_bry, 0, expd_bry.length);
byte[] actl_bry = (byte[])lnki_trail_mgr.Trie().Match_bgn(expd_bry, 0, expd_bry.length);
Tfds.Eq_bry(expd_bry, actl_bry);
}
}

View File

@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import gplx.core.btries.*;
public class Xol_msg_itm_ {
public static final int
Id_dte_dow_name_sunday = 0
@@ -266,7 +267,7 @@ public static final int
itm.Atrs_set(val, has_fmt_arg, has_tmpl_txt);
}
public static final byte[] Bry_nbsp = Byte_.Ary_by_ints(192, 160);
private static final ByteTrieMgr_slim trie_space = ByteTrieMgr_slim.cs_() // MW:cache/MessageCache.php|get|Fix for trailing whitespace, removed by textarea|DATE:2014-04-29
private static final Btrie_slim_mgr trie_space = Btrie_slim_mgr.cs_() // MW:cache/MessageCache.php|get|Fix for trailing whitespace, removed by textarea|DATE:2014-04-29
.Add_bry("&#32;" , " ")
.Add_bry("&nbsp;" , Bry_nbsp)
.Add_bry("&#160;" , Bry_nbsp)

View File

@@ -94,7 +94,7 @@ public class Xol_msg_mgr implements GfoInvkAble {
return rv;
}
private static HashAdp Hash_new(Xol_msg_itm[] ary) {
HashAdp rv = Hash_adp_bry.ci_();
HashAdp rv = Hash_adp_bry.ci_ascii_(); // ASCII:MW messages are currently all ASCII
for (int i = 0; i < Xol_msg_itm_.Id__max; i++) {
Xol_msg_itm itm = ary[i]; if (itm == null) continue; // NOTE: can be null when msg_mgr is owned by wiki
rv.Add(itm.Key(), itm);