mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.2.1
This commit is contained in:
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.ios.*; import gplx.threads.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*; import gplx.threads.*;
|
||||
import gplx.xowa.apps.*; import gplx.xowa.apps.caches.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.fmtrs.*; import gplx.xowa.html.*;
|
||||
@@ -138,7 +138,7 @@ public class Xoa_app implements GfoInvkAble {
|
||||
public Url_encoder Url_converter_fsys() {return url_converter_fsys;} private Url_encoder url_converter_fsys = Url_encoder.new_fsys_lnx_();
|
||||
public Url_encoder Url_converter_fsys_safe() {return url_converter_fsys_safe;} private Url_encoder url_converter_fsys_safe = Url_encoder.new_fsys_wnt_();
|
||||
public Xoh_file_main_wkr File_main_wkr() {return file_main_wkr;} private Xoh_file_main_wkr file_main_wkr = new Xoh_file_main_wkr();
|
||||
public ByteTrieMgr_slim Utl_trie_tblw_ws() {return utl_trie_tblw_ws;} private ByteTrieMgr_slim utl_trie_tblw_ws = Xop_tblw_ws_itm.trie_();
|
||||
public Btrie_slim_mgr Utl_trie_tblw_ws() {return utl_trie_tblw_ws;} private Btrie_slim_mgr utl_trie_tblw_ws = Xop_tblw_ws_itm.trie_();
|
||||
public Bry_bfr_mkr Utl_bry_bfr_mkr() {return utl_bry_bfr_mkr;} Bry_bfr_mkr utl_bry_bfr_mkr = new Bry_bfr_mkr();
|
||||
public Gfo_fld_rdr Utl_fld_rdr() {return utl_fld_rdr;} Gfo_fld_rdr utl_fld_rdr = Gfo_fld_rdr.xowa_();
|
||||
public Gfo_log_bfr Log_bfr() {return log_bfr;} private Gfo_log_bfr log_bfr = new Gfo_log_bfr();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "1.7.1.1";
|
||||
public static final String Version = "1.7.2.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
|
||||
@@ -17,9 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*; import gplx.xowa.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.gui.*; import gplx.xowa.gui.views.*;
|
||||
public class Xoapi_html_box implements GfoInvkAble {
|
||||
public class Xoapi_html_box implements GfoInvkAble, GfoEvMgrOwner {
|
||||
private Xog_win_itm win;
|
||||
public Xoapi_html_box() {
|
||||
evMgr = GfoEvMgr.new_(this);
|
||||
}
|
||||
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
|
||||
public void Init_by_kit(Xoa_app app) {this.win = app.Gui_mgr().Browser_win();}
|
||||
public byte Load_tid() {return load_tid;} private byte load_tid;
|
||||
public void Focus() {
|
||||
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
Gfui_html html_box = tab.Html_itm().Html_box();
|
||||
@@ -33,10 +38,16 @@ public class Xoapi_html_box implements GfoInvkAble {
|
||||
html_box.Html_doc_selection_focus_toggle();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else if (ctx.Match(k, Invk_selection_focus_toggle)) this.Selection_focus();
|
||||
else if (ctx.Match(k, Invk_load_tid)) return Gxw_html_load_tid_.Xto_key(load_tid);
|
||||
else if (ctx.Match(k, Invk_load_tid_)) {load_tid = Gxw_html_load_tid_.Xto_tid(m.ReadStr("v")); GfoEvMgr_.PubVal(this, Evt_load_tid_changed, load_tid);}
|
||||
else if (ctx.Match(k, Invk_load_tid_list)) return Gxw_html_load_tid_.Options__list;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus", Invk_selection_focus_toggle = "selection_focus_toggle";
|
||||
private static final String Invk_focus = "focus", Invk_selection_focus_toggle = "selection_focus_toggle"
|
||||
, Invk_load_tid = "load_tid", Invk_load_tid_ = "load_tid_", Invk_load_tid_list = "load_tid_list"
|
||||
;
|
||||
public static final String Evt_load_tid_changed = "load_tid_changed";
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ public class Xoapi_url implements GfoInvkAble {
|
||||
public void Exec() {Exec_wkr(Bool_.N, this.Url_box().Text());}
|
||||
public void Exec_by_paste() {Exec_wkr(Bool_.N, ClipboardAdp_.GetText());}
|
||||
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());
|
||||
}
|
||||
private void Exec_wkr(boolean new_tab, String urls_text) {
|
||||
if (Op_sys.Cur().Tid_is_wnt())
|
||||
urls_text = String_.Replace(urls_text, Op_sys.Wnt.Nl_str(), Op_sys.Lnx.Nl_str());
|
||||
@@ -49,9 +53,10 @@ public class Xoapi_url implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_exec)) this.Exec();
|
||||
else if (ctx.Match(k, Invk_exec_by_paste)) this.Exec_by_paste();
|
||||
else if (ctx.Match(k, Invk_exec_new_tab_by_paste)) this.Exec_new_tab_by_paste();
|
||||
else if (ctx.Match(k, Invk_restore)) this.Restore();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus", Invk_exec_by_paste = "exec_by_paste", Invk_exec_new_tab_by_paste = "exec_new_tab_by_paste";
|
||||
private static final String Invk_focus = "focus", Invk_exec_by_paste = "exec_by_paste", Invk_exec_new_tab_by_paste = "exec_new_tab_by_paste", Invk_restore = "restore";
|
||||
public static final String Invk_exec = "exec";
|
||||
}
|
||||
|
||||
@@ -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().X_to_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().Xto_full_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();
|
||||
|
||||
@@ -184,7 +184,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
|
||||
;
|
||||
public static final byte[]
|
||||
Dflt_xnde_ignore_ids = Bry_.new_ascii_("coordinates")
|
||||
, Dflt_tmpl_keeplist = Bry_.new_ascii_("en.wikipedia.org|formatnum;age_in_days;as_of;gregorian_serial_date;currentminute;currentsecond;dmca;spaced_ndash;trim;month*;convert*;worldpop*;ipa*;lang*;nowrap*;h:*;vgy;iso_639_name;transl;translate;linktext;zh;nihongo;japanese_name;ko-hhrm;|\n")
|
||||
, Dflt_tmpl_keeplist = Bry_.new_ascii_("en.wikipedia.org|formatnum;age_in_days;as_of;gregorian_serial_date;currentminute;currentsecond;dmca;spaced_ndash;trim;month*;convert*;worldpop*;ipa*;lang*;nowrap*;h:*;mvar;math;vgy;audio;iso_639_name;transl;translate;linktext;zh;nihongo*;japanese_name;ko-hhrm|\n")
|
||||
, Dflt_html_fmtr_popup = Bry_.new_ascii_(String_.Concat_lines_nl_skip_last
|
||||
( "<div dir=~{page_lang_ltr}>"
|
||||
, " <div>~{content}"
|
||||
@@ -226,7 +226,7 @@ public class Xoapi_popups implements GfoInvkAble, GfoEvMgrOwner {
|
||||
, Dflt_show_more_word_count = 192
|
||||
, Dflt_show_all_if_less_than = -1
|
||||
, Dflt_show_all_win_max_w = -1
|
||||
, Dflt_win_show_delay = 600, Dflt_win_hide_delay = 600
|
||||
, Dflt_win_show_delay = 600, Dflt_win_hide_delay = 400
|
||||
, Dflt_win_max_w = -1, Dflt_win_max_h = -1
|
||||
, Dflt_win_show_all_max_w = 800
|
||||
, Dflt_scan_len = 1 * Io_mgr.Len_kb
|
||||
|
||||
@@ -31,7 +31,11 @@ public class Xoa_fsys_eval implements Bry_fmtr_eval_mgr {
|
||||
default: throw Err_mgr._.unhandled_(val);
|
||||
}
|
||||
}
|
||||
Hash_adp_bry hash = Hash_adp_bry.ci_().Add_bry_byte(Bry_bin_plat_dir, Tid_bin_plat_dir).Add_bry_byte(Bry_user_temp_dir, Tid_user_temp_dir).Add_bry_byte(Bry_xowa_root_dir, Tid_xowa_root_dir).Add_bry_byte(Bry_user_cfg_dir, Tid_user_cfg_dir);
|
||||
private static final byte[] Bry_bin_plat_dir = Bry_.new_ascii_("bin_plat_dir"), Bry_user_temp_dir = Bry_.new_ascii_("user_temp_dir"), Bry_xowa_root_dir = Bry_.new_ascii_("xowa_root_dir"), Bry_user_cfg_dir = Bry_.new_ascii_("user_cfg_dir");
|
||||
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 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_()
|
||||
.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)
|
||||
.Add_str_byte("user_cfg_dir", Tid_user_cfg_dir)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.imports.*;
|
||||
import gplx.core.btries.*;
|
||||
class Uca_trie {
|
||||
public void Init() {
|
||||
Init_itm(1, Bry_.ints_(1,1));
|
||||
@@ -1042,12 +1043,12 @@ 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 ByteTrieMgr_slim trie = ByteTrieMgr_slim.cs_();
|
||||
} 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;
|
||||
while (i < end) {
|
||||
Object o = trie.MatchAtCur(src, i, end);
|
||||
Object o = trie.Match_bgn(src, i, end);
|
||||
if (src[i] < 4) return;
|
||||
if (o == null) return; //throw Err_.new_fmt_("unknown error: {0}", i);
|
||||
byte[] utf8_char = (byte[])o;
|
||||
@@ -1067,7 +1068,7 @@ Init_itm(1024, Bry_.ints_(92,52,1,134,143,1,143,5));
|
||||
}
|
||||
if (uca_last == 0) return;
|
||||
uca = Bry_.Mid(uca, 0, uca_last);
|
||||
if (trie.MatchAtCur(uca, 0, uca.length) == null)
|
||||
trie.Add(uca, gplx.intl.Utf16_.Encode_int_to_bry(charAsInt));
|
||||
if (trie.Match_bgn(uca, 0, uca.length) == null)
|
||||
trie.Add_obj(uca, gplx.intl.Utf16_.Encode_int_to_bry(charAsInt));
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.imports.*;
|
||||
import gplx.ios.*; import gplx.xowa.ctgs.*;
|
||||
import gplx.core.brys.*; import gplx.ios.*; import gplx.xowa.ctgs.*;
|
||||
public abstract class Xob_categorylinks_base extends Xob_sql_dump_base implements Sql_file_parser_cmd {
|
||||
public abstract Io_sort_cmd Make_sort_cmd(Sql_file_parser sql_parser);
|
||||
@Override public String Sql_file_name() {return "categorylinks";}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.imports.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.ctgs.*;
|
||||
import gplx.core.flds.*; import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.ctgs.*;
|
||||
public class Xob_categorylinks_sql_make implements Io_make_cmd {
|
||||
public Xob_categorylinks_sql_make(Sql_file_parser sql_parser, Xow_wiki wiki) {this.wiki = wiki; this.sql_parser = sql_parser;} private Xow_wiki wiki; Xodb_mgr_sql db_mgr; Sql_file_parser sql_parser;
|
||||
public Io_sort_cmd Make_dir_(Io_url v) {return this;}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.imports.*;
|
||||
import gplx.ios.*;
|
||||
import gplx.core.btries.*; import gplx.core.flds.*; import gplx.ios.*;
|
||||
public abstract class Xob_ctg_v1_base extends Xob_itm_dump_base implements Xobd_parser_wkr, GfoInvkAble {
|
||||
protected Xob_ctg_v1_base() {} // TEST:needed for fxt
|
||||
public Xob_ctg_v1_base Ctor(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki); return this;}
|
||||
@@ -41,9 +41,9 @@ public abstract class Xob_ctg_v1_base extends Xob_itm_dump_base implements Xobd_
|
||||
Log(Tid_eos, page, src, bgn);
|
||||
return end;
|
||||
}
|
||||
Object o = trie.MatchAtCur(src, pos, src_len);
|
||||
Object o = trie.Match_bgn(src, pos, src_len);
|
||||
if (o != null) {
|
||||
ByteTrie_stub stub = (ByteTrie_stub)o;
|
||||
Btrie_itm_stub stub = (Btrie_itm_stub)o;
|
||||
byte[] bry = stub.Val();
|
||||
switch (stub.Tid()) {
|
||||
case Tid_brack_end: case Tid_pipe:
|
||||
@@ -93,7 +93,7 @@ public abstract class Xob_ctg_v1_base extends Xob_itm_dump_base implements Xobd_
|
||||
if (delete_temp) Io_mgr._.DeleteDirDeep(temp_dir);
|
||||
}
|
||||
private Gfo_fld_wtr fld_wtr = Gfo_fld_wtr.xowa_();
|
||||
ByteTrieMgr_fast trie = ByteTrieMgr_fast.cs_().Add_stub(Tid_brack_end, "]]").Add_stub(Tid_pipe, "|").Add_stub(Tid_nl, "\n").Add_stub(Tid_brack_bgn, "[[");
|
||||
Btrie_fast_mgr trie = Btrie_fast_mgr.cs_().Add_stub(Tid_brack_end, "]]").Add_stub(Tid_pipe, "|").Add_stub(Tid_nl, "\n").Add_stub(Tid_brack_bgn, "[[");
|
||||
static final int row_fixed_len = 5 + 1 + 1; // 5=rowId; 1=|; 1=\n
|
||||
ListAdp category_list = ListAdp_.new_(); Int_obj_ref cur_pos = Int_obj_ref.zero_();
|
||||
static final byte Tid_eos = 0, Tid_brack_end = 1, Tid_pipe = 2, Tid_nl = 3, Tid_brack_bgn = 4;
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.imports.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.ctgs.*;
|
||||
import gplx.core.flds.*; import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.ctgs.*;
|
||||
public class Xob_ctg_v1_sql extends Xob_ctg_v1_base {
|
||||
@Override public String Wkr_key() {return KEY;} public static final String KEY = "import.sql.category_v1";
|
||||
@Override public Io_sort_cmd Make_sort_cmd() {return new Xob_ctg_v1_sql_make(wiki);}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.imports.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.imports.*;
|
||||
import gplx.ios.*; import gplx.xowa.ctgs.*;
|
||||
import gplx.core.flds.*; import gplx.ios.*; import gplx.xowa.ctgs.*;
|
||||
public class Xoctg_link_idx_wkr extends Xob_idx_base { // NOTE: similar functionality to Xob_make_cmd_site, but more complicated due to p,f,s; not inheriting
|
||||
Io_url src_link_dir; int make_fil_max = Int_.MinValue;
|
||||
public Xoctg_link_idx_wkr(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.langs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.intl.*; import gplx.php.*;
|
||||
import gplx.core.btries.*; import gplx.intl.*; import gplx.php.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.numbers.*;
|
||||
public class Xol_mw_lang_parser {
|
||||
private Php_parser parser = new Php_parser(); private Php_evaluator evaluator;
|
||||
@@ -325,27 +325,27 @@ public class Xol_mw_lang_parser {
|
||||
;
|
||||
public static int Id_by_mw_name(byte[] src) {
|
||||
if (mw_names == null) {
|
||||
mw_names = ByteTrieMgr_slim.cs_();
|
||||
mw_names.Add("NS_MEDIA", Int_obj_val.new_(Xow_ns_.Id_media));
|
||||
mw_names.Add("NS_SPECIAL", Int_obj_val.new_(Xow_ns_.Id_special));
|
||||
mw_names.Add("NS_MAIN", Int_obj_val.new_(Xow_ns_.Id_main));
|
||||
mw_names.Add("NS_TALK", Int_obj_val.new_(Xow_ns_.Id_talk));
|
||||
mw_names.Add("NS_USER", Int_obj_val.new_(Xow_ns_.Id_user));
|
||||
mw_names.Add("NS_USER_TALK", Int_obj_val.new_(Xow_ns_.Id_user_talk));
|
||||
mw_names.Add("NS_PROJECT", Int_obj_val.new_(Xow_ns_.Id_project));
|
||||
mw_names.Add("NS_PROJECT_TALK", Int_obj_val.new_(Xow_ns_.Id_project_talk));
|
||||
mw_names.Add("NS_FILE", Int_obj_val.new_(Xow_ns_.Id_file));
|
||||
mw_names.Add("NS_FILE_TALK", Int_obj_val.new_(Xow_ns_.Id_file_talk));
|
||||
mw_names.Add("NS_MEDIAWIKI", Int_obj_val.new_(Xow_ns_.Id_mediaWiki));
|
||||
mw_names.Add("NS_MEDIAWIKI_TALK", Int_obj_val.new_(Xow_ns_.Id_mediaWiki_talk));
|
||||
mw_names.Add("NS_TEMPLATE", Int_obj_val.new_(Xow_ns_.Id_template));
|
||||
mw_names.Add("NS_TEMPLATE_TALK", Int_obj_val.new_(Xow_ns_.Id_template_talk));
|
||||
mw_names.Add("NS_HELP", Int_obj_val.new_(Xow_ns_.Id_help));
|
||||
mw_names.Add("NS_HELP_TALK", Int_obj_val.new_(Xow_ns_.Id_help_talk));
|
||||
mw_names.Add("NS_CATEGORY", Int_obj_val.new_(Xow_ns_.Id_category));
|
||||
mw_names.Add("NS_CATEGORY_TALK", Int_obj_val.new_(Xow_ns_.Id_category_talk));
|
||||
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));
|
||||
mw_names.Add_obj("NS_TALK", Int_obj_val.new_(Xow_ns_.Id_talk));
|
||||
mw_names.Add_obj("NS_USER", Int_obj_val.new_(Xow_ns_.Id_user));
|
||||
mw_names.Add_obj("NS_USER_TALK", Int_obj_val.new_(Xow_ns_.Id_user_talk));
|
||||
mw_names.Add_obj("NS_PROJECT", Int_obj_val.new_(Xow_ns_.Id_project));
|
||||
mw_names.Add_obj("NS_PROJECT_TALK", Int_obj_val.new_(Xow_ns_.Id_project_talk));
|
||||
mw_names.Add_obj("NS_FILE", Int_obj_val.new_(Xow_ns_.Id_file));
|
||||
mw_names.Add_obj("NS_FILE_TALK", Int_obj_val.new_(Xow_ns_.Id_file_talk));
|
||||
mw_names.Add_obj("NS_MEDIAWIKI", Int_obj_val.new_(Xow_ns_.Id_mediaWiki));
|
||||
mw_names.Add_obj("NS_MEDIAWIKI_TALK", Int_obj_val.new_(Xow_ns_.Id_mediaWiki_talk));
|
||||
mw_names.Add_obj("NS_TEMPLATE", Int_obj_val.new_(Xow_ns_.Id_template));
|
||||
mw_names.Add_obj("NS_TEMPLATE_TALK", Int_obj_val.new_(Xow_ns_.Id_template_talk));
|
||||
mw_names.Add_obj("NS_HELP", Int_obj_val.new_(Xow_ns_.Id_help));
|
||||
mw_names.Add_obj("NS_HELP_TALK", Int_obj_val.new_(Xow_ns_.Id_help_talk));
|
||||
mw_names.Add_obj("NS_CATEGORY", Int_obj_val.new_(Xow_ns_.Id_category));
|
||||
mw_names.Add_obj("NS_CATEGORY_TALK", Int_obj_val.new_(Xow_ns_.Id_category_talk));
|
||||
}
|
||||
Object o = mw_names.MatchAtCurExact(src, 0, src.length);
|
||||
Object o = mw_names.Match_exact(src, 0, src.length);
|
||||
return o == null ? Xow_ns_.Id_null : ((Int_obj_val)o).Val();
|
||||
} private static ByteTrieMgr_slim mw_names;
|
||||
} private static Btrie_slim_mgr mw_names;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.xmls.*; // NOTE: gplx.xmls does not support Android; DATE:2013-01-17
|
||||
import gplx.ios.*; import gplx.xmls.*; // NOTE: gplx.xmls does not support Android; DATE:2013-01-17
|
||||
public class Xob_siteinfo_parser {
|
||||
public static byte[] Siteinfo_extract(gplx.ios.Io_stream_rdr src_rdr) {
|
||||
Io_buffer_rdr rdr = Io_buffer_rdr.Null;
|
||||
|
||||
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.ios.*;
|
||||
public class Xob_xml_page_bldr {
|
||||
public byte[] Xto_bry() {return bfr.XtoAryAndClear();}
|
||||
public Io_buffer_rdr XtoByteStreamRdr() {return XtoByteStreamRdr(Io_mgr.Len_kb);}
|
||||
|
||||
@@ -16,8 +16,9 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.core.btries.*; import gplx.ios.*;
|
||||
public class Xob_xml_parser {
|
||||
ByteTrieMgr_fast trie = Xob_xml_parser_.trie_(); Bry_bfr data_bfr = Bry_bfr.new_(); DateAdp_parser date_parser = DateAdp_parser.new_();
|
||||
Btrie_fast_mgr trie = Xob_xml_parser_.trie_(); Bry_bfr data_bfr = Bry_bfr.new_(); DateAdp_parser date_parser = DateAdp_parser.new_();
|
||||
public Xob_xml_parser Tag_len_max_(int v) {tag_len_max = v; return this;} private int tag_len_max = 255; // max size of any (a) xml tag, (b) int or (c) date; everything else goes into a data_bfr
|
||||
public Xob_xml_parser Data_bfr_len_(int v) {data_bfr.Resize(v); return this;} // PERF: resize data_bfr once to large size, rather than grow incremently to it
|
||||
public Xob_xml_parser Trie_tab_del_() {trie.Del(Xob_xml_parser_.Bry_tab); return this;}
|
||||
@@ -44,7 +45,7 @@ public class Xob_xml_parser {
|
||||
}
|
||||
if (pos >= src_len) return Bry_.NotFound; // no more src left; should only happen at end of file
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match(b, src, pos, src_len);
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, src_len);
|
||||
if (o == null) { // text_data; not an xml_nde (<id>), xml_escape (<), or tab
|
||||
if (data_bfr_add) data_bfr.Add_byte(b); // add to src if data_bfr_add is on (only happens for <title>, <text>)
|
||||
++pos;
|
||||
|
||||
@@ -16,9 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.bldrs.xmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xob_xml_parser_ {
|
||||
public static ByteTrieMgr_fast trie_() {
|
||||
ByteTrieMgr_fast rv = ByteTrieMgr_fast.cs_();
|
||||
public static Btrie_fast_mgr trie_() {
|
||||
Btrie_fast_mgr rv = Btrie_fast_mgr.cs_();
|
||||
trie_add(rv, Bry_page_bgn, Id_page_bgn); trie_add(rv, Bry_page_bgn_frag, Id_page_bgn_frag); trie_add(rv, Bry_page_end, Id_page_end);
|
||||
trie_add(rv, Bry_id_bgn, Id_id_bgn); trie_add(rv, Bry_id_bgn_frag, Id_id_bgn_frag); trie_add(rv, Bry_id_end, Id_id_end);
|
||||
trie_add(rv, Bry_title_bgn, Id_title_bgn); trie_add(rv, Bry_title_bgn_frag, Id_title_bgn_frag); trie_add(rv, Bry_title_end, Id_title_end);
|
||||
@@ -58,9 +59,9 @@ public class Xob_xml_parser_ {
|
||||
, Id_amp = 33, Id_quot = 34, Id_gt = 35, Id_lt = 36
|
||||
, Id_tab = 37, Id_cr_nl = 38, Id_cr = 39
|
||||
;
|
||||
private static void trie_add(ByteTrieMgr_fast rv, byte[] hook, byte id) {rv.Add(hook, new Xob_xml_parser_itm(hook, id, Byte_.Zero , Bry_.Empty));}
|
||||
private static void trie_add(ByteTrieMgr_fast rv, byte[] hook, byte id, byte subst_byte) {rv.Add(hook, new Xob_xml_parser_itm(hook, id, subst_byte , Bry_.Empty));}
|
||||
private static void trie_add(ByteTrieMgr_fast rv, byte[] hook, byte id, byte[] subst_ary) {rv.Add(hook, new Xob_xml_parser_itm(hook, id, Byte_.Zero , subst_ary));}
|
||||
private static void trie_add(Btrie_fast_mgr rv, byte[] hook, byte id) {rv.Add(hook, new Xob_xml_parser_itm(hook, id, Byte_.Zero , Bry_.Empty));}
|
||||
private static void trie_add(Btrie_fast_mgr rv, byte[] hook, byte id, byte subst_byte) {rv.Add(hook, new Xob_xml_parser_itm(hook, id, subst_byte , Bry_.Empty));}
|
||||
private static void trie_add(Btrie_fast_mgr rv, byte[] hook, byte id, byte[] subst_ary) {rv.Add(hook, new Xob_xml_parser_itm(hook, id, Byte_.Zero , subst_ary));}
|
||||
}
|
||||
class Xob_xml_parser_itm {
|
||||
public Xob_xml_parser_itm(byte[] hook, byte tid, byte subst_byte, byte[] subst_ary) {this.hook = hook; this.hook_len = hook.length; this.tid = tid; this.subst_byte = subst_byte; this.subst_ary = subst_ary;}
|
||||
|
||||
@@ -17,6 +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
|
||||
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(Xow_wiki wiki, byte[] ctg_name) {
|
||||
Gfo_usr_dlg usr_dlg = wiki.App().Usr_dlg();
|
||||
@@ -26,5 +27,4 @@ public class Xoctg_data_cache {
|
||||
regy.Add(ctg_name, rv);
|
||||
return rv;
|
||||
}
|
||||
Hash_adp_bry regy = Hash_adp_bry.ci_();
|
||||
}
|
||||
|
||||
@@ -137,18 +137,18 @@ class Xoctg_fmtr_all {
|
||||
html_nav.Bld_bfr(bfr, nav_href, nav_ttl, nav_text);
|
||||
}
|
||||
public static final byte[]
|
||||
Url_arg_from = Bry_.new_ascii_("from")
|
||||
, Url_arg_until = Bry_.new_ascii_("until")
|
||||
, Url_arg_subc_bgn = Bry_.new_ascii_("subcatfrom")
|
||||
, Url_arg_subc_end = Bry_.new_ascii_("subcatuntil")
|
||||
, Url_arg_page_bgn = Bry_.new_ascii_("pagefrom")
|
||||
, Url_arg_page_end = Bry_.new_ascii_("pageuntil")
|
||||
, Url_arg_file_bgn = Bry_.new_ascii_("filefrom")
|
||||
, Url_arg_file_end = Bry_.new_ascii_("fileuntil")
|
||||
, Div_id_subc = Bry_.new_ascii_("mw-subcategories")
|
||||
, Div_id_page = Bry_.new_ascii_("mw-pages")
|
||||
, Div_id_file = Bry_.new_ascii_("mw-category-media")
|
||||
;
|
||||
Url_arg_from = Bry_.new_ascii_("from")
|
||||
, Url_arg_until = Bry_.new_ascii_("until")
|
||||
, Url_arg_subc_bgn = Bry_.new_ascii_("subcatfrom")
|
||||
, Url_arg_subc_end = Bry_.new_ascii_("subcatuntil")
|
||||
, Url_arg_page_bgn = Bry_.new_ascii_("pagefrom")
|
||||
, Url_arg_page_end = Bry_.new_ascii_("pageuntil")
|
||||
, Url_arg_file_bgn = Bry_.new_ascii_("filefrom")
|
||||
, Url_arg_file_end = Bry_.new_ascii_("fileuntil")
|
||||
, Div_id_subc = Bry_.new_ascii_("mw-subcategories")
|
||||
, Div_id_page = Bry_.new_ascii_("mw-pages")
|
||||
, Div_id_file = Bry_.new_ascii_("mw-category-media")
|
||||
;
|
||||
}
|
||||
interface Xoctg_fmtr_itm extends Bry_fmtr_arg {
|
||||
int Grp_end_idx();
|
||||
|
||||
@@ -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.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xoctg_idx_itm {
|
||||
public int Pos() {return pos;} public Xoctg_idx_itm Pos_(int v) {pos = v; return this;} private int pos = -1;
|
||||
public int Id() {return id;} private int id;
|
||||
|
||||
@@ -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.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xoctg_idx_mgr implements GfoInvkAble {
|
||||
ListAdp itms = ListAdp_.new_();
|
||||
public int Block_len() {return block_len;} public Xoctg_idx_mgr Block_len_(int v) {this.block_len = v; return this;} private int block_len = Io_mgr.Len_mb;
|
||||
|
||||
@@ -58,7 +58,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_()
|
||||
public static final Hash_adp_bry Arg_keys = Hash_adp_bry.ci_ascii_()
|
||||
.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)
|
||||
|
||||
@@ -31,7 +31,7 @@ class Xoctg_url_fxt {
|
||||
public void Clear() {
|
||||
if (parser == null) {
|
||||
parser = new Xoa_url_parser();
|
||||
page_url = new Xoa_url();
|
||||
page_url = Xoa_url.blank_();
|
||||
ctg_url = new Xoctg_url();
|
||||
expd = new Xoctg_url_chkr();
|
||||
}
|
||||
|
||||
@@ -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.ctgs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xoctg_view_itm implements gplx.CompareAble {
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public int Id() {return id;} private int id;
|
||||
|
||||
@@ -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.dbs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.bldrs.imports.ctgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.dbs.tbls.*; import gplx.xowa.specials.search.*;
|
||||
import gplx.core.brys.*; import gplx.core.flds.*; import gplx.xowa.bldrs.imports.ctgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.dbs.tbls.*; import gplx.xowa.specials.search.*;
|
||||
public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
public Xodb_load_mgr_txt(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Xof_fsdb_mgr_ {
|
||||
Js_img_mgr.Update_img(page, itm);
|
||||
}
|
||||
else {
|
||||
usr_dlg.Warn_many("", "", "file not found: page=~{0} file=~{1} width=~{2}", page.Url().X_to_full_str_safe(), String_.new_utf8_(itm.Lnki_ttl()), itm.Lnki_w());
|
||||
usr_dlg.Warn_many("", "", "file not found: page=~{0} file=~{1} width=~{2}", page.Url().Xto_full_str_safe(), String_.new_utf8_(itm.Lnki_ttl()), itm.Lnki_w());
|
||||
itm.Rslt_bin_(Xof_bin_wkr_.Tid_not_found);
|
||||
fsdb_mgr.Reg_insert(itm, orig_wiki, Xof_wiki_orig_wkr_.Tid_missing_bin);
|
||||
// gplx.xowa.files.gui.Js_img_mgr.Update_img_missing(usr_dlg, itm.Html_uid());
|
||||
|
||||
@@ -24,7 +24,7 @@ interface Orig_fil_tbl extends RlsAble {
|
||||
}
|
||||
class Orig_fil_tbl_mem implements Orig_fil_tbl {
|
||||
private Hash_adp_bry hash;
|
||||
public void Ctor(Db_provider provider, boolean created) {hash = Hash_adp_bry.ci_();}
|
||||
public void Ctor(Db_provider provider, boolean created) {hash = Hash_adp_bry.cs_();} // NOTE: cs_ b/c ttl-based
|
||||
public Orig_fil_itm Select_itm(byte[] ttl) {return (Orig_fil_itm)hash.Get_by_bry(ttl);}
|
||||
public void Insert(Orig_fil_itm fil_itm) {hash.Add(fil_itm.Fil_name(), fil_itm);}
|
||||
public void Rls() {}
|
||||
|
||||
@@ -144,6 +144,7 @@ public class Xog_bnd_mgr {
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_exec , Xog_bnd_box_.Tid_browser_url , "key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_exec_new_tab_by_paste , Xog_bnd_box_.Tid_browser_url , "mod.c+key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_exec_by_paste , Xog_bnd_box_.Tid_browser_url , "mouse.middle", "mod.a+key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_url_restore , Xog_bnd_box_.Tid_browser_url , "mod.c+key.u");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_search_focus , Xog_bnd_box_.Tid_browser , "mod.ca+key.s");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_search_exec , Xog_bnd_box_.Tid_browser_search , "key.enter");
|
||||
Init_itm(Xog_cmd_itm_.Key_gui_browser_tabs_new_dflt__at_dflt__focus_y , Xog_bnd_box_.Tid_browser , "mod.c+key.t");
|
||||
|
||||
@@ -76,6 +76,7 @@ public class Xog_cmd_itm_ {
|
||||
, Key_gui_browser_url_exec = new_dflt_(Xog_ctg_itm_.Tid_browser , "xowa.gui.browser.url.exec")
|
||||
, Key_gui_browser_url_exec_by_paste = new_dflt_(Xog_ctg_itm_.Tid_browser , "xowa.gui.browser.url.exec_by_paste")
|
||||
, Key_gui_browser_url_exec_new_tab_by_paste = new_dflt_(Xog_ctg_itm_.Tid_browser , "xowa.gui.browser.url.exec_new_tab_by_paste")
|
||||
, Key_gui_browser_url_restore = new_dflt_(Xog_ctg_itm_.Tid_browser , "xowa.gui.browser.url.restore")
|
||||
, Key_gui_browser_search_focus = new_dflt_(Xog_ctg_itm_.Tid_browser , "xowa.gui.browser.search.focus")
|
||||
, Key_gui_browser_search_exec = new_dflt_(Xog_ctg_itm_.Tid_browser , "xowa.gui.browser.search.exec")
|
||||
, Key_gui_browser_tabs_new_dflt__at_dflt__focus_y = new_dflt_(Xog_ctg_itm_.Tid_tabs , "xowa.gui.browser.tabs.new_dflt__at_dflt__focus_y")
|
||||
|
||||
@@ -76,8 +76,7 @@ class Xog_history_stack_fxt {
|
||||
Xoa_page page = Xoa_page.test_(wiki, ttl);
|
||||
byte[] url_bry = ttl_bry;
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_utf8_(arg_str));
|
||||
Xoa_url url = new Xoa_url();
|
||||
url_parser.Parse(url, url_bry);
|
||||
Xoa_url url = url_parser.Parse(url_bry);
|
||||
page.Url_(url); // set url b/c history_mgr.Add uses url
|
||||
stack.Add(page);
|
||||
return this;
|
||||
|
||||
@@ -24,7 +24,10 @@ public class Xog_mnu_grp extends Xog_mnu_base {
|
||||
this.Ctor(gui_mgr);
|
||||
} private Xoa_app app;
|
||||
public String Key() {return key;} private String key; private boolean mnu_is_popup;
|
||||
public Gfui_mnu_grp Under_mnu() {return under_mnu;} private Gfui_mnu_grp under_mnu;
|
||||
public Gfui_mnu_grp Under_mnu() {
|
||||
if (under_mnu.Disposed()) Build(); // NOTE: menu may be disposed when calling .dispose on Swt_html; rebuild if needed; DATE:2014-07-09
|
||||
return under_mnu;
|
||||
} private Gfui_mnu_grp under_mnu;
|
||||
@Override public boolean Tid_is_app_menu_grp() {return !mnu_is_popup;}
|
||||
public boolean Enabled() {return enabled;} private boolean enabled = true;
|
||||
public void Enabled_(boolean v) {
|
||||
|
||||
@@ -91,9 +91,8 @@ public class Xog_url_wkr {
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_page(Xoa_app app, Xoa_page page, Xog_win_itm win, byte[] href_bry) { // EX: "Page"; "/wiki/Page"; // rewritten; DATE:2014-01-19
|
||||
Xoa_url rv = new Xoa_url();
|
||||
Xow_wiki wiki = page.Wiki();
|
||||
app.Url_parser().Parse(rv, href_bry); // needed for query_args
|
||||
Xoa_url rv = app.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();
|
||||
|
||||
@@ -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.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 ByteTrieMgr_slim Trie() {return trie;} private ByteTrieMgr_slim trie = ByteTrieMgr_slim.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_utf8_(abrv), Bry_.new_utf8_(fmt));}
|
||||
public void Set(byte[] abrv, byte[] fmt) {trie.Add(abrv, new Xog_url_macro_itm(abrv, fmt));}
|
||||
public void Set(byte[] abrv, byte[] fmt) {trie.Add_obj(abrv, new Xog_url_macro_itm(abrv, fmt));}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_clear)) trie.Clear();
|
||||
else if (ctx.Match(k, Invk_set)) Set(m.ReadBry("abrv"), m.ReadBry("fmt"));
|
||||
|
||||
@@ -43,9 +43,9 @@ public class Xog_url_macro_mgr {
|
||||
boolean dot_missing = dot_pos == -1;
|
||||
int type_bgn = dot_pos + 1, type_end = colon_pos; // +1 to start type after dot;
|
||||
if (dot_missing) type_bgn = 0;
|
||||
Object custom_obj = custom_mgr.Trie().MatchAtCurExact(raw, 0, type_end); // match entire prefix
|
||||
Object custom_obj = custom_mgr.Trie().Match_exact(raw, 0, type_end); // match entire prefix
|
||||
if (custom_obj == null) {
|
||||
Object type_obj = types_mgr.Trie().MatchAtCurExact(raw, type_bgn, type_end);
|
||||
Object type_obj = types_mgr.Trie().Match_exact(raw, type_bgn, type_end);
|
||||
if (type_obj == null) return Unhandled; // type abrv is not known; exit; EX: "en.unknown:Page"; "Page"
|
||||
byte[] lang_bry = dot_missing ? lang_default : Bry_.Mid(raw, 0, dot_pos);
|
||||
Xog_url_macro_itm type_itm = (Xog_url_macro_itm)type_obj;
|
||||
|
||||
@@ -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.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.html.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.menus.dom.*;
|
||||
import gplx.core.btries.*; import gplx.gfui.*; import gplx.html.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.menus.dom.*;
|
||||
public class Xog_html_itm implements GfoInvkAble, GfoEvObj {
|
||||
private Xoa_app app;
|
||||
public Xog_html_itm(Xog_tab_itm owner_tab) {
|
||||
@@ -61,8 +61,18 @@ public class Xog_html_itm implements GfoInvkAble, GfoEvObj {
|
||||
page.Root().Data_htm_(html_src);
|
||||
}
|
||||
}
|
||||
private void Html_src_(Xoa_page page, byte[] html_src) {
|
||||
html_box.Html_doc_html_(String_.new_utf8_(html_src));
|
||||
private void Html_src_(Xoa_page page, byte[] html_bry) {
|
||||
String html_str = String_.new_utf8_(html_bry);
|
||||
if (owner_tab.Tab_mgr().Html_load_tid__url()) {
|
||||
Io_url html_url = app.User().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);}
|
||||
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(e));
|
||||
html_box.Html_doc_html_load_by_mem(html_str);
|
||||
}
|
||||
}
|
||||
else
|
||||
html_box.Html_doc_html_load_by_mem(html_str);
|
||||
}
|
||||
public void Html_swap(Xog_html_itm trg_itm) {
|
||||
Xog_html_itm src_itm = this;
|
||||
@@ -180,7 +190,7 @@ class Xog_html_itm__href_extractor {
|
||||
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_ascii_("file://");
|
||||
private static final int File_protocol_len = File_protocol_bry.length;
|
||||
private static final ByteTrieMgr_slim href_trie = ByteTrieMgr_slim.cs_()
|
||||
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)
|
||||
@@ -199,7 +209,7 @@ class Xog_html_itm__href_extractor {
|
||||
if (Bry_.HasAtBgn(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.MatchAtCur(text_bry, href_bgn, text_len);
|
||||
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_utf8_(text_bry, href_bgn, text_len);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
html_box.Html_invk_src_(win);
|
||||
html_itm.Html_box_(html_box);
|
||||
if (app.Mode() == Xoa_app_.Mode_gui) { // NOTE: only run for gui; will cause firefox addon to fail; DATE:2014-05-03
|
||||
html_box.Html_doc_html_(""); // NOTE: must set source, else control will be empty, and key events will not be raised; DATE:2014-04-30
|
||||
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);
|
||||
GfoEvMgr_.SubSame(html_box, GfuiElemKeys.Evt_menu_detected, html_itm);
|
||||
gui_mgr.Bnd_mgr().Bind(Xog_bnd_box_.Tid_browser_html, html_box);
|
||||
@@ -76,7 +76,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
this.page = page;
|
||||
if (update_ui) {
|
||||
this.Tab_name_();
|
||||
tab_box.Tab_tip_text_(String_.new_utf8_(page.Url().X_to_full()));
|
||||
tab_box.Tab_tip_text_(page.Url().Xto_full_str());
|
||||
}
|
||||
} private Xoa_page page;
|
||||
public void Tab_name_() {
|
||||
@@ -113,7 +113,8 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url.Page_bry());
|
||||
if (ttl == null) {usr_dlg.Prog_one("", "", "title is invalid: ~{0}", String_.new_utf8_(url.Raw())); return;}
|
||||
usr_dlg.Prog_one("", "", "loading: ~{0}", String_.new_utf8_(ttl.Raw()));
|
||||
this.Html_box().Html_js_eval_script("xowa_popups_hide_all();");
|
||||
if (app.Api_root().Html().Modules().Popups().Enabled())
|
||||
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();
|
||||
}
|
||||
public void Show_url_loaded(Xoa_page page) {
|
||||
@@ -129,8 +130,8 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
Xog_tab_itm_read_mgr.Show_page(this, page, false);
|
||||
}
|
||||
else {
|
||||
if (page.Redirect_list().Count() > 0)
|
||||
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_utf8_(page.Url().Page_bry()), String_.new_utf8_((byte[])page.Redirect_list().FetchAt(0)));
|
||||
if (page.Redirected_ttls().Count() > 0)
|
||||
usr_dlg.Prog_many("", "", "could not find: ~{0} (redirected from ~{1})", String_.new_utf8_(page.Url().Page_bry()), String_.new_utf8_((byte[])page.Redirected_ttls().FetchAt(0)));
|
||||
else {
|
||||
if (ttl.Ns().Id_file())
|
||||
usr_dlg.Prog_one("", "", "commons.wikimedia.org must be installed in order to view the file. See [[Help:Wikis/Commons]]: ~{0}", String_.new_utf8_(url.Raw()));
|
||||
@@ -165,7 +166,7 @@ public class Xog_tab_itm implements GfoInvkAble {
|
||||
public void Async() {
|
||||
if (page == null) return; // TEST: occurs during Xog_win_mgr_tst
|
||||
Xow_wiki wiki = page.Wiki(); Xoa_app app = wiki.App(); 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().X_to_full_str_safe());
|
||||
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());
|
||||
if (usr_dlg.Canceled()) {usr_dlg.Prog_none("", "", ""); app.Log_wtr().Queue_enabled_(false); return;}
|
||||
int xfer_len = 0;
|
||||
@@ -226,7 +227,7 @@ class Load_page_wkr implements Gfo_thread_wkr {
|
||||
public void Exec() {
|
||||
try {
|
||||
Xoa_app app = wiki.App();
|
||||
app.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.X_to_full_str_safe());
|
||||
app.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.Xto_full_str_safe());
|
||||
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
|
||||
@@ -248,7 +249,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().X_to_full_str(), Err_.Message_gplx_brief(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_brief(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Xog_tab_itm_read_mgr {
|
||||
try {tab.Html_itm().Show(new_page);}
|
||||
catch (Exception e) {
|
||||
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
|
||||
String new_page_url = new_page.Url().X_to_full_str_safe();
|
||||
String new_page_url = new_page.Url().Xto_full_str_safe();
|
||||
String err_msg = "fatal error trying to load error page; page=" + new_page_url;
|
||||
app.Usr_dlg().Warn_many("", "", err_msg);
|
||||
app.Gui_mgr().Kit().Ask_ok("", "", err_msg);
|
||||
|
||||
@@ -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.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.cfgs2.*;
|
||||
import gplx.gfui.*; import gplx.xowa.cfgs2.*; import gplx.xowa.apis.xowa.gui.browsers.*;
|
||||
public class Xog_tab_mgr implements GfoEvObj {
|
||||
private OrderedHash tab_regy = OrderedHash_.new_(); private int tab_uid = 0;
|
||||
public Xog_tab_mgr(Xog_win_itm win) {
|
||||
@@ -26,6 +26,8 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
|
||||
public Xog_win_itm Win() {return win;} private Xog_win_itm win;
|
||||
public Gfui_tab_mgr Tab_mgr() {return tab_mgr;} private Gfui_tab_mgr tab_mgr;
|
||||
public byte Html_load_tid() {return html_load_tid;} private byte html_load_tid;
|
||||
public boolean Html_load_tid__url() {return html_load_tid == Gxw_html_load_tid_.Tid_url;}
|
||||
public void Init_by_kit(Gfui_kit kit) {
|
||||
tab_mgr = kit.New_tab_mgr("xowa.tab_mgr", win.Win_box());
|
||||
active_tab = Xog_tab_itm_.Null;
|
||||
@@ -44,6 +46,10 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
, Xocfg_tab_btn_mgr.Evt_text_min_chars_changed, Xocfg_tab_btn_mgr.Evt_text_max_chars_changed
|
||||
, Xocfg_tab_btn_mgr.Evt_hide_if_one_changed
|
||||
);
|
||||
html_load_tid = win.App().Api_root().Gui().Browser().Html().Load_tid();
|
||||
GfoEvMgr_.SubSame_many(win.App().Api_root().Gui().Browser().Html(), this
|
||||
, Xoapi_html_box.Evt_load_tid_changed
|
||||
);
|
||||
}
|
||||
public Xog_tab_itm Active_tab() {return active_tab;} private Xog_tab_itm active_tab;
|
||||
public Xog_tab_itm Active_tab_assert() {
|
||||
@@ -99,7 +105,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().X_to_full_str();
|
||||
String url = active_tab.Page().Url().Xto_full_str();
|
||||
Tabs_new_dflt(focus);
|
||||
win.Page__navigate_by_url_bar(url);
|
||||
}
|
||||
@@ -120,6 +126,8 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
public void Tabs_close_cur() {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
tab_mgr.Tabs_close_by_idx(active_tab.Tab_idx());
|
||||
Xog_tab_itm cur_tab = this.Active_tab();
|
||||
if (cur_tab != null) cur_tab.Html_box().Focus(); // NOTE: needed to focus tab box else tab button will be focused; DATE:2014-07-13
|
||||
}
|
||||
public void Tabs_close_others() {this.Tabs_close_to_bgn(); this.Tabs_close_to_end();}
|
||||
public void Tabs_close_to_bgn() {if (Active_tab_is_null()) return; Tabs_close_rng(0 , active_tab.Tab_idx());}
|
||||
@@ -137,7 +145,8 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
private ListAdp closed_undo_list = ListAdp_.new_();
|
||||
private void Tabs_closed(String key) {
|
||||
Xog_tab_itm itm = Tabs_get_by_key_or_warn(key); if (itm == null) return;
|
||||
closed_undo_list.Add(itm.Page().Url().X_to_full_str());
|
||||
itm.Html_box().Html_dispose();
|
||||
closed_undo_list.Add(itm.Page().Url().Xto_full_str());
|
||||
tab_regy.Del(key);
|
||||
if (tab_regy.Count() == 0) {
|
||||
active_tab = Xog_tab_itm_.Null;
|
||||
@@ -233,6 +242,7 @@ public class Xog_tab_mgr implements GfoEvObj {
|
||||
else if (ctx.Match(k, Xocfg_tab_btn_mgr.Evt_unselected_close_visible_changed)) Btns_unselected_close_visible_(m.ReadBool("v"));
|
||||
else if (ctx.Match(k, Xocfg_tab_btn_mgr.Evt_text_min_chars_changed)) Btns_text_recalc();
|
||||
else if (ctx.Match(k, Xocfg_tab_btn_mgr.Evt_text_max_chars_changed)) Btns_text_recalc();
|
||||
else if (ctx.Match(k, Xoapi_html_box.Evt_load_tid_changed)) html_load_tid = m.ReadByte("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
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.Url_parser().Parse(url, url.X_to_full()); // remove all query args; handle (1) s.w:Earth?action=edit; (2) click on Read; DATE:2014-03-06
|
||||
app.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
|
||||
}
|
||||
tab.View_mode_(new_mode_tid);
|
||||
if (page.Missing()) return;
|
||||
@@ -246,12 +246,12 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
public byte[] App__retrieve_by_url(String url_str, String output_str) {
|
||||
synchronized (App__retrieve__lock) {
|
||||
boolean output_html = String_.Eq(output_str, "html");
|
||||
Xoa_url url = new Xoa_url();
|
||||
byte[] url_bry = Bry_.new_utf8_(url_str);
|
||||
Xow_wiki home_wiki = app.User().Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(home_wiki, Xoa_page_.Main_page_bry); // NOTE: must be Main_Page, not "" else Firefox Addon will fail; DATE:2014-03-13
|
||||
Xoa_page new_page = Xoa_page.new_(home_wiki, ttl);
|
||||
this.Active_page_(new_page);
|
||||
Xoa_url url = Xoa_url.blank_();
|
||||
url = Xoa_url_parser.Parse_url(url, app, new_page.Wiki(), url_bry, 0, url_bry.length, true);
|
||||
new_page.Url_(url);
|
||||
return App__retrieve_by_href(url, output_html);
|
||||
|
||||
@@ -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.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.net.*;
|
||||
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.net.*;
|
||||
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*;
|
||||
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*;
|
||||
public class Xoh_html_wtr {
|
||||
@@ -664,7 +664,7 @@ class Xoh_display_ttl_wtr {
|
||||
Atr_key_style = Bry_.new_ascii_("style")
|
||||
, Msg_style_restricted = Bry_.new_ascii_(" style='/* attempt to bypass $wgRestrictDisplayTitle */'")
|
||||
;
|
||||
private ByteTrieMgr_slim style_trie = ByteTrieMgr_slim.ci_ascii_()
|
||||
private Btrie_slim_mgr style_trie = Btrie_slim_mgr.ci_ascii_()
|
||||
.Add_str_byte__many(Byte_.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_html_wtr_ctx hctx, byte[] src, Xop_xatr_itm atr, byte[] atr_key) {
|
||||
if (atr_key != null
|
||||
@@ -675,7 +675,7 @@ class Xoh_display_ttl_wtr {
|
||||
int atr_pos = 0;
|
||||
while (atr_pos < atr_val_len) {
|
||||
byte b = atr_val[atr_pos];
|
||||
Object o = style_trie.Match(b, atr_val, atr_pos, atr_val_len);
|
||||
Object o = style_trie.Match_bgn_w_byte(b, atr_val, atr_pos, atr_val_len);
|
||||
if (o != null) {
|
||||
bfr.Add(Msg_style_restricted);
|
||||
return true;
|
||||
|
||||
@@ -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.html; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.html.*; import gplx.xowa.parsers.amps.*;
|
||||
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.parsers.amps.*;
|
||||
public class Xoh_html_wtr_escaper {
|
||||
public static byte[] Escape(Xoa_app app, Bry_bfr tmp_bfr, byte[] src) {
|
||||
Escape(app, tmp_bfr, src, 0, src.length, true, false);
|
||||
@@ -24,7 +24,7 @@ public class Xoh_html_wtr_escaper {
|
||||
}
|
||||
public static void Escape(Xoa_app app, Bry_bfr bfr, byte[] src, int bgn, int end, boolean interpret_amp, boolean nowiki_skip) {
|
||||
Xop_amp_mgr amp_mgr = app.Parser_amp_mgr();
|
||||
ByteTrieMgr_slim amp_trie = amp_mgr.Amp_trie();
|
||||
Btrie_slim_mgr amp_trie = amp_mgr.Amp_trie();
|
||||
for (int i = bgn; i < end; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
@@ -48,7 +48,7 @@ public class Xoh_html_wtr_escaper {
|
||||
case Byte_ascii.Amp:
|
||||
if (interpret_amp) {
|
||||
int text_bgn = i + 1; // i is &; i + 1 is first char after amp
|
||||
Object o = (text_bgn < end) ? amp_trie.MatchAtCur(src, text_bgn, end) : null; // check if this is a valid &; note must check that text_bgn < end or else arrayIndex error; occurs when src is just "&"; DATE:2013-12-19
|
||||
Object o = (text_bgn < end) ? amp_trie.Match_bgn(src, text_bgn, end) : null; // check if this is a valid &; note must check that text_bgn < end or else arrayIndex error; occurs when src is just "&"; DATE:2013-12-19
|
||||
if (o == null) // invalid; EX: "a&b"; "&bad;"; "&#letters;";
|
||||
bfr.Add(Html_entity_.Amp_bry); // escape & and continue
|
||||
else { // is either (1) a name or (2) an ncr (hex/dec)
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xoh_lnki_file_wtr {
|
||||
} private Xow_html_mgr html_mgr; private boolean lnki_title_enabled;
|
||||
private Xow_wiki wiki; private Xoh_html_wtr html_wtr;
|
||||
private Xoh_lnki_txt_fmtr media_alt_fmtr = new Xoh_lnki_txt_fmtr(), caption_fmtr = new Xoh_lnki_txt_fmtr(); private Bry_bfr_mkr bfr_mkr;
|
||||
private Xoa_url tmp_url = new Xoa_url();
|
||||
private Xoa_url tmp_url = Xoa_url.blank_();
|
||||
public void Write_or_queue(Bry_bfr bfr, Xoa_page page, Xop_ctx ctx, Xoh_html_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
Xof_xfer_itm xfer_itm = this.Lnki_eval(ctx, page, lnki, queue_add_ref);
|
||||
this.Write_media(bfr, hctx, src, lnki, xfer_itm, Alt_text(src, lnki));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Xoh_lnki_wtr {
|
||||
return;
|
||||
}
|
||||
if (lnki_ttl == null) {// NOTE: parser failed to properly invalidate lnki; escape tkn now and warn; DATE:2014-06-06
|
||||
app.Usr_dlg().Warn_many("", "", "invalid lnki evaded parser; page=~{0} ex=~{1}", ctx.Cur_page().Url().X_to_full_str(), String_.new_utf8_(src, lnki.Src_bgn(), lnki.Src_end()));
|
||||
app.Usr_dlg().Warn_many("", "", "invalid lnki evaded parser; page=~{0} ex=~{1}", ctx.Cur_page().Url().Xto_full_str(), String_.new_utf8_(src, lnki.Src_bgn(), lnki.Src_end()));
|
||||
Xoh_html_wtr_escaper.Escape(app, bfr, src, lnki.Src_bgn(), lnki.Src_end(), true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.xowa.apis.xowa.html.modules.*;
|
||||
import gplx.xowa.gui.views.*;
|
||||
import gplx.xowa.html.modules.popups.keeplists.*;
|
||||
public class Xow_popup_parser {
|
||||
private Xoa_app app; private Xow_wiki wiki; private Xop_parser parser;
|
||||
private ByteTrieMgr_fast tmpl_trie, wtxt_trie; private Xop_tkn_mkr tkn_mkr;
|
||||
private Btrie_fast_mgr tmpl_trie, wtxt_trie; private Xop_tkn_mkr tkn_mkr;
|
||||
private Xop_ctx tmpl_ctx; private Xop_root_tkn tmpl_root, wtxt_root; private Xot_compile_data tmpl_props = new Xot_compile_data();
|
||||
private Xoh_html_wtr_ctx hctx = Xoh_html_wtr_ctx.Popup;
|
||||
public Xow_popup_cfg Cfg() {return cfg;} private Xow_popup_cfg cfg = new Xow_popup_cfg();
|
||||
@@ -196,7 +197,4 @@ public class Xow_popup_parser {
|
||||
tmpl_root.Subs_get(i).Tmpl_compile(tmpl_ctx, src, tmpl_props);
|
||||
return Xot_tmpl_wtr._.Write_all(tmpl_ctx, tmpl_root, src);
|
||||
}
|
||||
private static final String Comment_txt_str = "XOWA_SKIP";
|
||||
public static final byte[] Comment_txt = Bry_.new_ascii_(Comment_txt_str);
|
||||
public static final byte[] Comment_tkn = Bry_.new_ascii_("<!--" + Comment_txt_str + "-->");
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class Xowh_sidebar_mgr implements GfoInvkAble {
|
||||
cur_grp.Itms_add(cur_itm);
|
||||
}
|
||||
}
|
||||
} private Xoa_url tmp_url = new Xoa_url();
|
||||
} private Xoa_url tmp_url = Xoa_url.blank_();
|
||||
public void Bld_html(Bry_bfr bfr) {
|
||||
int len = grps.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Xow_toc_mgr implements Bry_fmtr_arg {
|
||||
bfr.Mkr_rls();
|
||||
return bfr.XtoAryAndClear();
|
||||
} catch (Exception e) {
|
||||
page.App().Usr_dlg().Warn_many("", "", "failed to write toc: url=~{0} err=~{1}", page.Url().X_to_full_str_safe(), Err_.Message_gplx_brief(e));
|
||||
page.App().Usr_dlg().Warn_many("", "", "failed to write toc: url=~{0} err=~{1}", page.Url().Xto_full_str_safe(), Err_.Message_gplx_brief(e));
|
||||
return Bry_.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.html.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xoh_js_cleaner {
|
||||
private Xoa_app app; private boolean ctor = true;
|
||||
public Xoh_js_cleaner(Xoa_app app) {this.app = app;}
|
||||
@@ -37,7 +38,7 @@ public class Xoh_js_cleaner {
|
||||
int pos = bgn;
|
||||
while (pos < end) {
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match(b, src, pos, end);
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, end);
|
||||
if (o == null) {
|
||||
if (dirty)
|
||||
bfr.Add_byte(b);
|
||||
@@ -198,5 +199,5 @@ public class Xoh_js_cleaner {
|
||||
Reg_itm("seekSegmentTime");
|
||||
ctor = false;
|
||||
}
|
||||
private void Reg_itm(String s) {trie.Add_bry(Bry_.new_ascii_(s));} ByteTrieMgr_slim trie = ByteTrieMgr_slim.ci_ascii_(); // NOTE:ci.ascii:javascript event name
|
||||
private void Reg_itm(String s) {trie.Add_bry(Bry_.new_ascii_(s));} Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_(); // NOTE:ci.ascii:javascript event name
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Xoa_lang_mgr implements GfoInvkAble {
|
||||
private static final String Invk_get = "get", Invk_local_set_bulk = "local_set_bulk", Invk_load_lang = "load_lang"
|
||||
, Invk_groups = "groups", Invk_mediawiki_converter = "mediawiki_converter"
|
||||
;
|
||||
public Hash_adp_bry Fallback_regy() {return fallback_regy;} Hash_adp_bry fallback_regy = Hash_adp_bry.ci_();
|
||||
public Hash_adp_bry Fallback_regy() {return fallback_regy;} Hash_adp_bry fallback_regy = Hash_adp_bry.cs_(); // changed from ci; DATE:2014-07-07
|
||||
private void Load_lang(byte[] bry) {this.Get_by_key_or_new(bry).Init_by_load();}
|
||||
public void Local_set_bulk(byte[] src) { // NOTE: setting local lang names/grps on app level; may need to move to user level or wiki level (for groups) later
|
||||
int len = src.length;
|
||||
|
||||
@@ -16,8 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.intl.*;
|
||||
import gplx.core.btries.*; import gplx.intl.*;
|
||||
public class Xol_func_name_regy {
|
||||
private Xol_func_name_itm finder = new Xol_func_name_itm();
|
||||
private Btrie_slim_mgr cs_trie = Btrie_slim_mgr.cs_(), ci_trie = Btrie_slim_mgr.ci_utf_8_();
|
||||
public Xol_func_name_regy(Xol_lang lang) {this.lang = lang;} private Xol_lang lang;
|
||||
public void Evt_lang_changed(Xol_lang lang) {
|
||||
Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
|
||||
@@ -46,22 +48,22 @@ public class Xol_func_name_regy {
|
||||
}
|
||||
private void Add(byte[] ary, boolean case_match, Xot_defn func) {
|
||||
if (case_match)
|
||||
cs_trie.Add(ary, func);
|
||||
cs_trie.Add_obj(ary, func);
|
||||
else {
|
||||
byte[] lower_ary = lang.Case_mgr().Case_build_lower(ary, 0, ary.length);
|
||||
ci_trie.Add(lower_ary, func);
|
||||
ci_trie.Add_obj(lower_ary, func);
|
||||
}
|
||||
}
|
||||
public Xol_func_name_itm Find_defn(byte[] src, int txt_bgn, int txt_end) {
|
||||
finder.Clear();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (txt_bgn == txt_end) return finder; // NOTE: true when tmpl_name is either not loaded, or doesn't exist
|
||||
Xot_defn func = MatchAtCur(src, txt_bgn, txt_end);
|
||||
Xot_defn func = Match_bgn(src, txt_bgn, txt_end);
|
||||
if (func == null) return finder; // NOTE: null when tmpl_name is either not loaded, or doesn't exist
|
||||
byte[] func_name = func.Name();
|
||||
int match_pos = func_name.length + txt_bgn;
|
||||
byte typeId = func.Defn_tid();
|
||||
switch (typeId) {
|
||||
byte defn_tid = func.Defn_tid();
|
||||
switch (defn_tid) {
|
||||
case Xot_defn_.Tid_func:
|
||||
if (match_pos == txt_end) // next char is ws (b/c match_pos == txt_end)
|
||||
finder.Func_set(func, -1);
|
||||
@@ -73,11 +75,13 @@ public class Xol_func_name_regy {
|
||||
break;
|
||||
case Xot_defn_.Tid_safesubst:
|
||||
case Xot_defn_.Tid_subst:
|
||||
finder.Subst_set_(typeId, txt_bgn, match_pos);
|
||||
finder.Subst_set_(defn_tid, txt_bgn, match_pos);
|
||||
if (match_pos < txt_end) txt_bgn = Bry_finder.Find_fwd_while_not_ws(src, match_pos, txt_end);
|
||||
break;
|
||||
case Xot_defn_.Tid_raw:
|
||||
finder.Subst_set_(typeId, txt_bgn, match_pos);
|
||||
case Xot_defn_.Tid_msg:
|
||||
case Xot_defn_.Tid_msgnw:
|
||||
finder.Subst_set_(defn_tid, txt_bgn, match_pos);
|
||||
if (match_pos + 1 < txt_end) // +1 to include ":" (keyword id "raw", not "raw:")
|
||||
txt_bgn = Bry_finder.Find_fwd_while_not_ws(src, match_pos + 1, txt_end);
|
||||
break;
|
||||
@@ -86,8 +90,8 @@ public class Xol_func_name_regy {
|
||||
}
|
||||
return finder;
|
||||
}
|
||||
Xot_defn MatchAtCur(byte[] src, int bgn, int end) {
|
||||
Object cs_obj = cs_trie.MatchAtCur(src, bgn, end);
|
||||
private Xot_defn Match_bgn(byte[] src, int bgn, int end) {
|
||||
Object cs_obj = cs_trie.Match_bgn(src, bgn, end);
|
||||
Xot_defn rv = null;
|
||||
if (cs_obj != null) { // match found for cs; could be false_match; EX: NAME"+"SPACE and NAME"+"SPACENUMBER
|
||||
rv = (Xot_defn)cs_obj;
|
||||
@@ -97,7 +101,7 @@ public class Xol_func_name_regy {
|
||||
}
|
||||
LowerAry(src, bgn, end);
|
||||
byte[] ary = lang.Case_mgr().Case_build_lower(lower_ary, 0, end - bgn);
|
||||
Xot_defn rv_alt = (Xot_defn)ci_trie.MatchAtCur(ary, 0, end - bgn);
|
||||
Xot_defn rv_alt = (Xot_defn)ci_trie.Match_bgn(ary, 0, end - bgn);
|
||||
return (rv != null && rv_alt == null)
|
||||
? rv // name not found in ci, but name was found in cs; return cs; handles NAME"+"SPACENUMBER
|
||||
: rv_alt; // else return rv_alt
|
||||
@@ -108,6 +112,4 @@ public class Xol_func_name_regy {
|
||||
lower_ary_len = len;
|
||||
Array_.CopyTo(src, bgn, lower_ary, 0, len);
|
||||
} byte[] lower_ary = new byte[255]; int lower_ary_len = 255;
|
||||
Xol_func_name_itm finder = new Xol_func_name_itm();
|
||||
private ByteTrieMgr_slim cs_trie = ByteTrieMgr_slim.cs_(), ci_trie = ByteTrieMgr_slim.ci_utf_8_();
|
||||
}
|
||||
|
||||
@@ -53,14 +53,15 @@ class Xol_case_itm_byt implements Xol_case_itm {
|
||||
}
|
||||
public int Hashcode_lo() {return lower_byte;}
|
||||
public int Len_lo() {return 1;}
|
||||
public byte[] Asymmetric_bry() {return null;}
|
||||
}
|
||||
class Xol_case_itm_bry implements Xol_case_itm {
|
||||
public Xol_case_itm_bry(byte tid, byte[] src_ary, byte[] trg_ary) {
|
||||
this.tid = tid; this.src_ary = src_ary; this.trg_ary = trg_ary;
|
||||
switch (tid) {
|
||||
case Xol_case_itm_.Tid_both:
|
||||
case Xol_case_itm_.Tid_upper: upper_ary = trg_ary; lower_ary = src_ary; break;
|
||||
case Xol_case_itm_.Tid_lower: upper_ary = src_ary; lower_ary = trg_ary; break;
|
||||
case Xol_case_itm_.Tid_both: upper_ary = trg_ary; lower_ary = src_ary; break;
|
||||
case Xol_case_itm_.Tid_upper: upper_ary = trg_ary; lower_ary = src_ary; asymmetric_bry = src_ary; break;
|
||||
case Xol_case_itm_.Tid_lower: upper_ary = src_ary; lower_ary = trg_ary; asymmetric_bry = trg_ary; break;
|
||||
}
|
||||
len_lo = lower_ary.length;
|
||||
utf8_id_lo = Utf16_.Decode_to_int(lower_ary, 0);
|
||||
@@ -86,5 +87,6 @@ class Xol_case_itm_bry implements Xol_case_itm {
|
||||
Xol_case_itm_bry trg_itm = (Xol_case_itm_bry)trg_obj;
|
||||
return utf8_id_lo == trg_itm.utf8_id_lo;
|
||||
}
|
||||
public byte[] Asymmetric_bry() {return asymmetric_bry;} private byte[] asymmetric_bry;
|
||||
public int Hashcode_lo() {return hashcode_ci_lo;} private int hashcode_ci_lo;
|
||||
}
|
||||
|
||||
@@ -120,11 +120,7 @@ public class Xol_case_itm_ {
|
||||
Xol_case_itm_bry itm = (Xol_case_itm_bry)hash.Fetch(upper);
|
||||
if (itm == null) {
|
||||
itm = new Xol_case_itm_bry(tid, upper, lower);
|
||||
// try {
|
||||
hash.Add(upper, itm);
|
||||
// } catch (Exception e) {
|
||||
// Err_.Noop(e);
|
||||
// }
|
||||
hash.Add(upper, itm);
|
||||
}
|
||||
else {
|
||||
if (itm.Tid() == rev_tid && Bry_.Eq(itm.Src_ary(), upper) && Bry_.Eq(itm.Trg_ary(), lower))
|
||||
|
||||
@@ -16,23 +16,24 @@ 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.langs.cases; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.intl.*;
|
||||
import gplx.core.btries.*; import gplx.intl.*;
|
||||
public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.new_(); private ByteTrieMgr_fast upper_trie = ByteTrieMgr_fast.cs_(), lower_trie = ByteTrieMgr_fast.cs_(); private Xol_case_itm[] itms;
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.new_(); private Btrie_fast_mgr upper_trie = Btrie_fast_mgr.cs_(), lower_trie = Btrie_fast_mgr.cs_(); private Xol_case_itm[] itms;
|
||||
public Xol_case_mgr(byte tid) {this.tid = tid;}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public Gfo_case_itm Get_or_null(byte bgn_byte, byte[] src, int bgn, int end) {
|
||||
Object rv = lower_trie.Match(bgn_byte, src, bgn, end);
|
||||
Object rv = lower_trie.Match_bgn_w_byte(bgn_byte, src, bgn, end);
|
||||
return rv == null
|
||||
? (Gfo_case_itm)upper_trie.Match(bgn_byte, src, bgn, end)
|
||||
? (Gfo_case_itm)upper_trie.Match_bgn_w_byte(bgn_byte, src, bgn, end)
|
||||
: (Gfo_case_itm)rv;
|
||||
}
|
||||
public void Clear() {upper_trie.Clear(); lower_trie.Clear();}
|
||||
public boolean Match(byte b, byte[] src, int bgn_pos, int end_pos) {
|
||||
return upper_trie.Match(b, src, bgn_pos, end_pos) != null
|
||||
|| lower_trie.Match(b, src, bgn_pos, end_pos) != null
|
||||
public boolean Match_any_exists(byte b, byte[] src, int bgn_pos, int end_pos) {
|
||||
return upper_trie.Match_bgn_w_byte(b, src, bgn_pos, end_pos) != null
|
||||
|| lower_trie.Match_bgn_w_byte(b, src, bgn_pos, end_pos) != null
|
||||
;
|
||||
}
|
||||
public Object Match_upper(byte b, byte[] src, int bgn_pos, int end_pos) {return upper_trie.Match_bgn_w_byte(b, src, bgn_pos, end_pos);}
|
||||
public void Add_bulk(byte[] raw) {Add_bulk(Xol_case_itm_.parse_xo_(raw));}
|
||||
public Xol_case_mgr Add_bulk(Xol_case_itm[] ary) {
|
||||
itms = ary;
|
||||
@@ -59,12 +60,12 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
public byte[] Case_reuse(boolean upper, byte[] src, int bgn, int end) {
|
||||
int pos = bgn;
|
||||
tmp_bfr.Clear();
|
||||
ByteTrieMgr_fast trie = upper ? upper_trie : lower_trie;
|
||||
Btrie_fast_mgr trie = upper ? upper_trie : lower_trie;
|
||||
while (true) {
|
||||
if (pos >= end) break;
|
||||
byte b = src[pos];
|
||||
int b_len = gplx.intl.Utf8_.Len_of_char_by_1st_byte(b);
|
||||
Object o = trie.Match(b, src, pos, end); // NOTE: used to be (b, src, bgn, end) which would never case correctly; DATE:2013-12-25
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, end); // NOTE: used to be (b, src, bgn, end) which would never case correctly; DATE:2013-12-25
|
||||
if (o != null && pos < end) { // pos < end used for casing 1st letter only; upper_1st will pass end of 1
|
||||
Xol_case_itm itm = (Xol_case_itm)o;
|
||||
if (upper)
|
||||
@@ -82,7 +83,7 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
if (src_len == 0) return src; // empty bry
|
||||
byte b = src[0];
|
||||
int b_len = gplx.intl.Utf8_.Len_of_char_by_1st_byte(b);
|
||||
Object o = upper_trie.Match(b, src, 0, b_len);
|
||||
Object o = upper_trie.Match_bgn_w_byte(b, src, 0, b_len);
|
||||
if (o == null) return src; // 1st letter is not a lower case char (either num, symbol, or upper)
|
||||
Xol_case_itm itm = (Xol_case_itm)o;
|
||||
itm.Case_build_upper(tmp_bfr);
|
||||
@@ -97,12 +98,12 @@ public class Xol_case_mgr implements GfoInvkAble, Gfo_case_mgr {
|
||||
public byte[] Case_build(boolean upper, byte[] src, int bgn, int end) {
|
||||
int pos = bgn;
|
||||
tmp_bfr.Clear();
|
||||
ByteTrieMgr_fast trie = upper ? upper_trie : lower_trie;
|
||||
Btrie_fast_mgr trie = upper ? upper_trie : lower_trie;
|
||||
while (true) {
|
||||
if (pos >= end) break;
|
||||
byte b = src[pos];
|
||||
int b_len = gplx.intl.Utf8_.Len_of_char_by_1st_byte(b);
|
||||
Object o = trie.Match(b, src, pos, end); // NOTE: used to be (b, src, bgn, end) which would never case correctly; DATE:2013-12-25
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, end); // NOTE: used to be (b, src, bgn, end) which would never case correctly; DATE:2013-12-25
|
||||
if (o != null && pos < end) { // pos < end used for casing 1st letter only; upper_1st will pass end of 1
|
||||
Xol_case_itm itm = (Xol_case_itm)o;
|
||||
if (upper)
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.durations; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_duration_itm_ {
|
||||
private static final Hash_adp_bry regy = Hash_adp_bry.ci_ascii_(); // ascii:MW.consts
|
||||
private static final Hash_adp_bry regy = Hash_adp_bry.ci_ascii_(); // ASCII:MW.consts
|
||||
public static final byte
|
||||
Tid_millenia = 0
|
||||
, Tid_centuries = 1
|
||||
|
||||
@@ -16,10 +16,11 @@ 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.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_grammar_ {
|
||||
public static final byte Tid__max = 9;
|
||||
public static final byte Tid_genitive = 0, Tid_elative = 1, Tid_partitive = 2, Tid_illative = 3, Tid_inessive = 4, Tid_accusative = 5, Tid_instrumental = 6, Tid_prepositional = 7, Tid_dative = 8, Tid_unknown = Byte_.MaxValue_127;
|
||||
private static final ByteTrieMgr_slim Tid_trie = ByteTrieMgr_slim.ci_ascii_() // NOTE:ci.ascii:MW kwds
|
||||
private static final Btrie_slim_mgr Tid_trie = Btrie_slim_mgr.ci_ascii_() // NOTE:ci.ascii:MW kwds
|
||||
.Add_str_byte("genitive", Tid_genitive)
|
||||
.Add_str_byte("elative", Tid_elative)
|
||||
.Add_str_byte("partitive", Tid_partitive)
|
||||
@@ -32,7 +33,7 @@ public class Xol_grammar_ {
|
||||
;
|
||||
public static byte Tid_of_type(byte[] v) {
|
||||
if (Bry_.Len_eq_0(v)) return Tid_unknown;
|
||||
Object o = Xol_grammar_.Tid_trie.MatchAtCurExact(v, 0, v.length);
|
||||
Object o = Xol_grammar_.Tid_trie.Match_exact(v, 0, v.length);
|
||||
return o == null ? Tid_unknown : ((Byte_obj_val)o).Val();
|
||||
}
|
||||
public static Xol_grammar new_by_lang_id(int lang_id) {
|
||||
|
||||
@@ -16,13 +16,14 @@ 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.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_grammar_fi implements Xol_grammar {
|
||||
public boolean Vowel_harmony(byte[] word, int word_len) {
|
||||
// $aou = preg_match( '/[aou][^äöy]*$/i', $word );
|
||||
boolean aou_found = false;
|
||||
for (int i = 0; i < word_len; i++) {
|
||||
byte b = word[i];
|
||||
Object o = trie_vh.Match(b, word, i, word_len);
|
||||
Object o = trie_vh.Match_bgn_w_byte(b, word, i, word_len);
|
||||
if (o != null) {
|
||||
byte vh_type = ((Byte_obj_val)o).Val();
|
||||
if (vh_type == Trie_vh_back)
|
||||
@@ -75,5 +76,5 @@ public class Xol_grammar_fi implements Xol_grammar {
|
||||
} static Xol_grammar_manual_regy manual_regy;
|
||||
private static final byte[] Bry_sta_y = Bry_.new_ascii_("sta"), Bry_sta_n = Bry_.new_utf8_("stä"), Bry_a_y = Bry_.new_ascii_("a"), Bry_a_n = Bry_.new_utf8_("ä"), Bry_ssa_y = Bry_.new_ascii_("ssa"), Bry_ssa_n = Bry_.new_utf8_("ssä");
|
||||
static final byte Trie_vh_back = 0, Trie_vh_front = 1;
|
||||
private static ByteTrieMgr_slim trie_vh = ByteTrieMgr_slim.cs_().Add_str_byte__many(Trie_vh_back, "a", "o", "u").Add_str_byte__many(Trie_vh_front, "ä", "ö", "y");
|
||||
private static Btrie_slim_mgr trie_vh = Btrie_slim_mgr.cs_().Add_str_byte__many(Trie_vh_back, "a", "o", "u").Add_str_byte__many(Trie_vh_front, "ä", "ö", "y");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
public class Xol_grammar_manual_regy {
|
||||
private Hash_adp_bry[] ary = new Hash_adp_bry[Xol_grammar_.Tid__max];
|
||||
public byte[] Itms_get(byte type_tid, byte[] word) {
|
||||
Hash_adp_bry hash = ary[type_tid]; if (hash == null) return null;
|
||||
return (byte[])hash.Get_by_bry(word);
|
||||
@@ -24,11 +25,10 @@ public class Xol_grammar_manual_regy {
|
||||
public Xol_grammar_manual_regy Itms_add(byte type_tid, String orig, String repl) {
|
||||
Hash_adp_bry hash = ary[type_tid];
|
||||
if (hash == null) {
|
||||
hash = Hash_adp_bry.ci_();
|
||||
hash = Hash_adp_bry.ci_ascii_(); // ASCII:currently only being used for Wikiuutiset; DATE:2014-07-07
|
||||
ary[type_tid] = hash;
|
||||
}
|
||||
hash.Add_str_obj(orig, Bry_.new_ascii_(repl));
|
||||
return this;
|
||||
}
|
||||
Hash_adp_bry[] ary = new Hash_adp_bry[Xol_grammar_.Tid__max];
|
||||
}
|
||||
|
||||
@@ -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.langs.grammars; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_grammar_ru implements Xol_grammar {
|
||||
static final byte Genitive_null = 0, Genitive_bnkn = 1, Genitive_Bnkn = 26, Genitive_b = 3, Genitive_nr = 4, Genitive_ka = 5, Genitive_tn = 6, Genitive_abl = 7, Genitive_hnk = 8;
|
||||
private static ByteTrieMgr_bwd_slim Genitive_trie;
|
||||
private static ByteTrieMgr_bwd_slim genitive_trie_() {
|
||||
ByteTrieMgr_bwd_slim rv = new ByteTrieMgr_bwd_slim(false);
|
||||
private static Btrie_bwd_mgr Genitive_trie;
|
||||
private static Btrie_bwd_mgr genitive_trie_() {
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
genitive_trie_add(rv, Genitive_bnkn, "вики", null);
|
||||
genitive_trie_add(rv, Genitive_Bnkn, "Вики", null);
|
||||
genitive_trie_add(rv, Genitive_b, "ь", "я");
|
||||
@@ -31,7 +32,7 @@ public class Xol_grammar_ru implements Xol_grammar {
|
||||
genitive_trie_add(rv, Genitive_hnk , "ник", "ника");
|
||||
return rv;
|
||||
}
|
||||
private static void genitive_trie_add(ByteTrieMgr_bwd_slim trie, byte tid, String find_str, String repl_str) {
|
||||
private static void genitive_trie_add(Btrie_bwd_mgr trie, byte tid, String find_str, String repl_str) {
|
||||
byte[] find_bry = Bry_.new_utf8_(find_str);
|
||||
byte[] repl_bry = repl_str == null ? null : Bry_.new_utf8_(repl_str);
|
||||
Xol_grammar_ru_genitive_itm itm = new Xol_grammar_ru_genitive_itm(tid, find_bry, repl_bry);
|
||||
@@ -43,7 +44,7 @@ public class Xol_grammar_ru implements Xol_grammar {
|
||||
switch (tid) {
|
||||
case Xol_grammar_.Tid_genitive: {
|
||||
if (Genitive_trie == null) Genitive_trie = genitive_trie_();
|
||||
Object o = Genitive_trie.MatchAtCur(word, word.length - 1, -1);
|
||||
Object o = Genitive_trie.Match_bgn(word, word.length - 1, -1);
|
||||
if (o != null) {
|
||||
Xol_grammar_ru_genitive_itm itm = (Xol_grammar_ru_genitive_itm)o;
|
||||
if (!itm.Repl_is_noop()) {
|
||||
|
||||
@@ -16,8 +16,9 @@ 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.langs.numbers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
private ByteTrieMgr_fast dlm_trie = ByteTrieMgr_fast.cs_();
|
||||
private Btrie_fast_mgr dlm_trie = Btrie_fast_mgr.cs_();
|
||||
private Xol_num_grp[] grp_ary = Xol_num_grp.Ary_empty; int grp_ary_len;
|
||||
private Gfo_num_fmt_wkr[] cache; int cache_len = 16;
|
||||
private Bry_bfr tmp = Bry_bfr.new_();
|
||||
@@ -28,7 +29,7 @@ public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
int src_len = src.length;
|
||||
for (int i = 0; i < src_len; i++) {
|
||||
byte b = src[i];
|
||||
Object o = dlm_trie.MatchAtCur(src, i, src_len);
|
||||
Object o = dlm_trie.Match_bgn(src, i, src_len);
|
||||
if (o == null)
|
||||
tmp.Add_byte(b);
|
||||
else {
|
||||
@@ -117,7 +118,7 @@ public class Xol_num_fmtr_base implements GfoInvkAble {
|
||||
for (int i = 0; i < grp_ary_len; i++) {
|
||||
Xol_num_grp itm = grp_ary[i];
|
||||
byte[] itm_dlm = itm.Dlm();
|
||||
Object o = dlm_trie.MatchAtCurExact(itm_dlm, 0, itm_dlm.length); // check for existing Object
|
||||
Object o = dlm_trie.Match_exact(itm_dlm, 0, itm_dlm.length); // check for existing Object
|
||||
if (o == null) {
|
||||
dlm_trie.Add_bry_bval(itm_dlm, Raw_tid_grp);
|
||||
grp_dlm = itm_dlm;
|
||||
|
||||
@@ -16,9 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.numbers; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xol_transform_mgr implements GfoInvkAble {
|
||||
private ByteTrieMgr_fast trie_k_to_v = ByteTrieMgr_fast.cs_();
|
||||
private ByteTrieMgr_fast trie_v_to_k = ByteTrieMgr_fast.cs_();
|
||||
private Btrie_fast_mgr trie_k_to_v = Btrie_fast_mgr.cs_();
|
||||
private Btrie_fast_mgr trie_v_to_k = Btrie_fast_mgr.cs_();
|
||||
private OrderedHash hash = OrderedHash_.new_bry_();
|
||||
private boolean empty = true;
|
||||
public void Clear() {hash.Clear(); trie_k_to_v.Clear(); trie_v_to_k.Clear(); empty = true;}
|
||||
@@ -40,7 +41,7 @@ public class Xol_transform_mgr implements GfoInvkAble {
|
||||
public byte[] Replace(Bry_bfr tmp_bfr, byte[] src, boolean k_to_v) {
|
||||
if (empty || src == null) return src;
|
||||
int src_len = src.length; if (src_len == 0) return src;
|
||||
ByteTrieMgr_fast trie = k_to_v ? trie_k_to_v : trie_v_to_k;
|
||||
Btrie_fast_mgr trie = k_to_v ? trie_k_to_v : trie_v_to_k;
|
||||
return trie.Replace(tmp_bfr, src, 0, src_len);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -16,10 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.intl.*;
|
||||
import gplx.core.btries.*; import gplx.intl.*;
|
||||
import gplx.xowa.langs.cnvs.*;
|
||||
public class Xol_vnt_converter {
|
||||
private ByteTrieMgr_slim trie = ByteTrieMgr_slim.cs_();
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.cs_();
|
||||
public Xol_vnt_converter(Xol_vnt_itm owner) {this.owner = owner;}
|
||||
public byte[] Owner_key() {return owner.Key();}
|
||||
public Xol_vnt_itm Owner() {return owner;} private Xol_vnt_itm owner;
|
||||
@@ -29,7 +29,7 @@ public class Xol_vnt_converter {
|
||||
boolean matched = false;
|
||||
while (pos < end) {
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match(b, src, pos, end);
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, end);
|
||||
if (o == null) { // no match; skip to next char
|
||||
int char_len = Utf8_.Len_of_char_by_1st_byte(b); // NOTE: must increment by char_len, not +1
|
||||
if (matched) {
|
||||
@@ -68,7 +68,7 @@ public class Xol_vnt_converter {
|
||||
int len = convert_grp.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xol_cnv_itm convert_itm = convert_grp.Get_at(i);
|
||||
trie.Add(convert_itm.Src(), convert_itm.Trg()); // NOTE: for dupes, latest value wins
|
||||
trie.Add_obj(convert_itm.Src(), convert_itm.Trg()); // NOTE: for dupes, latest value wins
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_vnt_flag {
|
||||
public Xop_vnt_flag(byte tid) {this.tid = tid; this.langs = Bry_.Ary_empty;}
|
||||
public Xop_vnt_flag(byte tid, byte[][] langs) {this.tid = tid; this.langs = langs;}
|
||||
@@ -81,7 +82,7 @@ class Xop_vnt_flag_ {
|
||||
, Flag_macro = new Xop_vnt_flag(Tid_macro)
|
||||
, Flag_name = new Xop_vnt_flag(Tid_name)
|
||||
;
|
||||
public static final ByteTrieMgr_fast Trie = ByteTrieMgr_fast.ci_ascii_() // NOTE: match either lc or uc; EX: -{D}- or -{d}-; // NOTE:ci.ascii:MW_const.en; flag keys; EX: -{S|a}-
|
||||
public static final Btrie_fast_mgr Trie = Btrie_fast_mgr.ci_ascii_() // NOTE: match either lc or uc; EX: -{D}- or -{d}-; // NOTE:ci.ascii:MW_const.en; flag keys; EX: -{S|a}-
|
||||
.Add(Byte_ascii.Ltr_S , Xop_vnt_flag_.Flag_show)
|
||||
.Add(Byte_ascii.Plus , Xop_vnt_flag_.Flag_all)
|
||||
.Add(Byte_ascii.Ltr_E , Xop_vnt_flag_.Flag_err)
|
||||
|
||||
@@ -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.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
class Xop_vnt_flag_lang_bldr {
|
||||
private Xop_vnt_flag_lang_itm[] ary; private int ary_len;
|
||||
private int ary_count;
|
||||
@@ -25,12 +26,12 @@ class Xop_vnt_flag_lang_bldr {
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] lang = converter_ary[i].Owner().Key();
|
||||
Xop_vnt_flag_lang_itm itm = new Xop_vnt_flag_lang_itm(i, lang);
|
||||
trie.Add(lang, itm);
|
||||
trie.Add_obj(lang, itm);
|
||||
}
|
||||
ary = new Xop_vnt_flag_lang_itm[len];
|
||||
ary_len = len;
|
||||
}
|
||||
public ByteTrieMgr_slim Trie() {return trie;} private ByteTrieMgr_slim trie = ByteTrieMgr_slim.ci_ascii_(); // NOTE:ci.ascii:MW_const.en; lang variant name; EX:zh-hans
|
||||
public Btrie_slim_mgr Trie() {return trie;} private Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_(); // NOTE:ci.ascii:MW_const.en; lang variant name; EX:zh-hans
|
||||
public void Add(Xop_vnt_flag_lang_itm itm) {
|
||||
int idx = itm.Idx();
|
||||
if (ary[idx] == null) {
|
||||
|
||||
@@ -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.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
class Xop_vnt_flag_parser {
|
||||
private Xop_vnt_flag_lang_bldr flag_lang_bldr;
|
||||
public Xop_vnt_flag_parser(Xol_vnt_mgr vnt_mgr) {flag_lang_bldr = new Xop_vnt_flag_lang_bldr(vnt_mgr);}
|
||||
@@ -64,7 +65,7 @@ class Xop_vnt_flag_parser {
|
||||
private Xop_vnt_flag Parse_flag_bry(byte[] bry) {
|
||||
int bry_len = bry.length;
|
||||
if (bry_len == 0) return Xop_vnt_flag_.Flag_unknown; // EX: exit early if 0 len, else trie will fail; EX: "-{|}-"
|
||||
Object flag_obj = flag_trie.MatchAtCurExact(bry, 0, bry_len);
|
||||
Object flag_obj = flag_trie.Match_exact(bry, 0, bry_len);
|
||||
return flag_obj == null
|
||||
? Parse_flag_vnts(bry, bry_len) // unknown tid sequence; either (a) "lang" cmd ("-{zh-hans;zh-hant|a}-") or (b) invalid cmd ("-{X|a}-")
|
||||
: (Xop_vnt_flag)flag_obj; // known flag; check that next non_ws is |
|
||||
@@ -72,11 +73,11 @@ class Xop_vnt_flag_parser {
|
||||
private Xop_vnt_flag Parse_flag_vnts(byte[] bry, int bry_len) {
|
||||
boolean loop = true;
|
||||
int vnt_pos = 0;
|
||||
ByteTrieMgr_slim trie = flag_lang_bldr.Trie();
|
||||
Btrie_slim_mgr trie = flag_lang_bldr.Trie();
|
||||
while (loop) {
|
||||
boolean last = false;
|
||||
boolean valid = true;
|
||||
Object vnt_obj = trie.MatchAtCur(bry, vnt_pos, bry_len);
|
||||
Object vnt_obj = trie.Match_bgn(bry, vnt_pos, bry_len);
|
||||
if (vnt_obj == null) break; // no more vnts found; stop
|
||||
vnt_pos = trie.Match_pos(); // update pos to end of vnt
|
||||
int semic_pos = Bry_finder.Find_fwd_while_not_ws(bry, vnt_pos, bry_len);
|
||||
@@ -97,9 +98,9 @@ class Xop_vnt_flag_parser {
|
||||
}
|
||||
return flag_lang_bldr.Bld();
|
||||
}
|
||||
private static ByteTrieMgr_fast flag_trie = Xop_vnt_flag_.Trie;
|
||||
private static Btrie_fast_mgr flag_trie = Xop_vnt_flag_.Trie;
|
||||
// private static final byte Dlm_tid_bgn = 0, Dlm_tid_end = 1, Dlm_tid_pipe = 2, Dlm_tid_colon = 3, Dlm_tid_semic = 4, Dlm_tid_kv = 5;
|
||||
// private static ByteTrieMgr_fast dlm_trie = ByteTrieMgr_fast.cs_()
|
||||
// private static Btrie_fast_mgr dlm_trie = Btrie_fast_mgr.cs_()
|
||||
// .Add_bry_bval(Xop_vnt_lxr_.Hook_bgn , Dlm_tid_bgn)
|
||||
// .Add_bry_bval(Xop_vnt_lxr_.Hook_end , Dlm_tid_end)
|
||||
// .Add_bry_bval(Byte_ascii.Pipe , Dlm_tid_pipe)
|
||||
|
||||
@@ -16,15 +16,16 @@ 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.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_vnt_lxr_ {
|
||||
public static void set_(Xow_wiki wiki) {
|
||||
ByteTrieMgr_fast wiki_trie = wiki.Parser().Wtxt_trie();
|
||||
Object exists = wiki_trie.MatchAtCur(Xop_vnt_lxr_.Hook_bgn, 0, Xop_vnt_lxr_.Hook_bgn.length);
|
||||
Btrie_fast_mgr wiki_trie = wiki.Parser().Wtxt_trie();
|
||||
Object exists = wiki_trie.Match_bgn(Xop_vnt_lxr_.Hook_bgn, 0, Xop_vnt_lxr_.Hook_bgn.length);
|
||||
if (exists == null) {
|
||||
Xop_vnt_lxr_eqgt._.Init_by_wiki(wiki, wiki_trie);
|
||||
Xop_vnt_lxr_bgn._.Init_by_wiki(wiki, wiki_trie);
|
||||
new Xop_vnt_lxr_end().Init_by_wiki(wiki, wiki_trie);
|
||||
// ByteTrieMgr_fast tmpl_trie = wiki.Parser().Tmpl_trie(); // do not add to tmpl trie
|
||||
// Btrie_fast_mgr tmpl_trie = wiki.Parser().Tmpl_trie(); // do not add to tmpl trie
|
||||
// Xop_vnt_lxr_bgn._.Init_by_wiki(wiki, tmpl_trie);
|
||||
}
|
||||
}
|
||||
@@ -32,8 +33,8 @@ public class Xop_vnt_lxr_ {
|
||||
}
|
||||
class Xop_vnt_lxr_eqgt implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_vnt_eqgt;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {core_trie.Add(Hook, this);}
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
ctx.Subs_add_and_stack(root, tkn_mkr.Vnt_eqgt(bgn_pos, cur_pos));
|
||||
return cur_pos;
|
||||
@@ -43,8 +44,8 @@ class Xop_vnt_lxr_eqgt implements Xop_lxr {
|
||||
}
|
||||
class Xop_vnt_lxr_bgn implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_vnt_bgn;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {core_trie.Add(Xop_vnt_lxr_.Hook_bgn, this);}
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_vnt_lxr_.Hook_bgn, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
ctx.Subs_add_and_stack(root, tkn_mkr.Vnt(bgn_pos, cur_pos));
|
||||
return cur_pos;
|
||||
@@ -55,13 +56,13 @@ class Xop_vnt_lxr_end implements Xop_lxr {
|
||||
private Xop_vnt_flag_parser flag_parser;
|
||||
private Xop_vnt_rules_parser rule_parser;
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_vnt_end;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
core_trie.Add(Xop_vnt_lxr_.Hook_end, this);
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
flag_parser = new Xop_vnt_flag_parser(vnt_mgr);
|
||||
rule_parser = new Xop_vnt_rules_parser(vnt_mgr);
|
||||
}
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
int stack_pos = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_vnt);
|
||||
if (stack_pos == Xop_ctx.Stack_not_found) return ctx.Lxr_make_txt_(cur_pos); // "}-" found but no "-{" in stack;
|
||||
|
||||
@@ -75,7 +75,7 @@ class Xop_vnt_tkn_mok {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] bry = Bry_.new_ascii_(ary[i]);
|
||||
Xop_vnt_flag flag = (Xop_vnt_flag)Xop_vnt_flag_.Trie.MatchAtCur(bry, 0, bry.length);
|
||||
Xop_vnt_flag flag = (Xop_vnt_flag)Xop_vnt_flag_.Trie.Match_bgn(bry, 0, bry.length);
|
||||
flags_list.Add(flag);
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -16,12 +16,13 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.langs.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import gplx.core.btries.*;
|
||||
class Xop_vnt_rules_parser {
|
||||
private byte mode;
|
||||
private Xop_vnt_tkn vnt_tkn;
|
||||
private boolean loop_vnt_subs; private int vnt_subs_cur, vnt_subs_bgn, vnt_subs_len;
|
||||
private int rule_texts_bgn;
|
||||
private ByteTrieMgr_slim trie;
|
||||
private Btrie_slim_mgr trie;
|
||||
private ListAdp rules_list = ListAdp_.new_();
|
||||
private ListAdp text_tkns_list = ListAdp_.new_();
|
||||
private int text_tkns_ws_end_idx;
|
||||
@@ -32,15 +33,15 @@ class Xop_vnt_rules_parser {
|
||||
private byte[] cur_macro_bry = null;
|
||||
private byte[] cur_lang_bry = null;
|
||||
public Xop_vnt_rules_parser(Xol_vnt_mgr vnt_mgr) {
|
||||
trie = ByteTrieMgr_slim.ci_ascii_(); // NOTE:ci.ascii:MW_const.en; lang variant name; EX:zh-hans
|
||||
trie = Btrie_slim_mgr.ci_ascii_(); // NOTE:ci.ascii:MW_const.en; lang variant name; EX:zh-hans
|
||||
Xol_vnt_converter[] ary = vnt_mgr.Converter_ary();
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
Xol_vnt_converter itm = ary[i];
|
||||
byte[] itm_lang = itm.Owner_key();
|
||||
trie.Add(itm_lang, Xop_vnt_rule_trie_itm.lang_(itm_lang));
|
||||
trie.Add_obj(itm_lang, Xop_vnt_rule_trie_itm.lang_(itm_lang));
|
||||
}
|
||||
trie.Add(";", Xop_vnt_rule_trie_itm.Dlm_semic);
|
||||
trie.Add_obj(";", Xop_vnt_rule_trie_itm.Dlm_semic);
|
||||
// trie.Add("=>", Xop_vnt_rule_trie_itm.Dlm_eqgt);
|
||||
}
|
||||
public void Clear_all() {
|
||||
@@ -128,7 +129,7 @@ class Xop_vnt_rules_parser {
|
||||
if (pos == src_end) break;
|
||||
if (cur_key_bgn == -1) cur_key_bgn = pos;
|
||||
byte b = src[pos];
|
||||
Object itm_obj = trie.Match(b, src, pos, src_end);
|
||||
Object itm_obj = trie.Match_bgn_w_byte(b, src, pos, src_end);
|
||||
if (itm_obj == null) { // not a lang, semic, or eqgt; treat rest of vnt as one rule tkn
|
||||
// if (mode == Mode_key)
|
||||
// loop_key_bry = Make_rule_literal();
|
||||
|
||||
@@ -16,10 +16,11 @@ 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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_amp_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_amp;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {core_trie.Add(Byte_ascii.Amp, this);}
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Amp, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
return ctx.Amp().Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@ 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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_amp_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
|
||||
public ByteTrieMgr_slim Amp_trie() {return amp_trie;} private ByteTrieMgr_slim amp_trie = Xop_amp_trie._;
|
||||
public Btrie_slim_mgr Amp_trie() {return amp_trie;} private Btrie_slim_mgr amp_trie = Xop_amp_trie._;
|
||||
public int Rslt_pos() {return rslt_pos;} private int rslt_pos;
|
||||
public int Rslt_val() {return rslt_val;} private int rslt_val;
|
||||
public Xop_tkn_itm Parse_as_tkn(Xop_tkn_mkr tkn_mkr, byte[] src, int src_len, int amp_pos, int cur_pos) {
|
||||
rslt_pos = amp_pos + 1; // default to fail pos; after amp;
|
||||
Object o = amp_trie.MatchAtCur(src, cur_pos, src_len);
|
||||
Object o = amp_trie.Match_bgn(src, cur_pos, src_len);
|
||||
cur_pos = amp_trie.Match_pos();
|
||||
if (o == null) return null;
|
||||
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
|
||||
@@ -48,7 +49,7 @@ public class Xop_amp_mgr {
|
||||
int nxt_pos = pos + 1;
|
||||
if (nxt_pos < src_len) {
|
||||
byte nxt_b = src[nxt_pos];
|
||||
Object amp_obj = amp_trie.Match(nxt_b, src, nxt_pos, src_len);
|
||||
Object amp_obj = amp_trie.Match_bgn_w_byte(nxt_b, src, nxt_pos, src_len);
|
||||
if (amp_obj != null) {
|
||||
if (!dirty) {
|
||||
tmp_bfr.Add_mid(src, 0, pos);
|
||||
|
||||
@@ -16,10 +16,11 @@ 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.parsers.amps; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_amp_trie {
|
||||
public static final ByteTrieMgr_slim _ = new_(); Xop_amp_trie() {}
|
||||
private static ByteTrieMgr_slim new_() {// REF.MW: Sanitizer|$wgHtmlEntities; NOTE:added apos
|
||||
ByteTrieMgr_slim rv = ByteTrieMgr_slim.cs_();
|
||||
public static final Btrie_slim_mgr _ = new_(); Xop_amp_trie() {}
|
||||
private static Btrie_slim_mgr new_() {// REF.MW: Sanitizer|$wgHtmlEntities; NOTE:added apos
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.cs_();
|
||||
Reg_char(rv, 39, "'");
|
||||
Reg_char(rv, 193, "Á");
|
||||
Reg_char(rv, 225, "á");
|
||||
@@ -278,15 +279,15 @@ public class Xop_amp_trie {
|
||||
Reg_prefix(rv, Xop_amp_trie_itm.Tid_num_dec, "#");
|
||||
return rv;
|
||||
}
|
||||
private static void Reg_char(ByteTrieMgr_slim trie, int char_int, String xml_name_str) {
|
||||
private static void Reg_char(Btrie_slim_mgr trie, int char_int, String xml_name_str) {
|
||||
byte[] xml_name_bry = Bry_.new_ascii_(xml_name_str);
|
||||
Xop_amp_trie_itm itm = new Xop_amp_trie_itm(Xop_amp_trie_itm.Tid_name, char_int, xml_name_bry);
|
||||
byte[] key = Bry_.Mid(xml_name_bry, 1, xml_name_bry.length); // ignore & for purpose of trie; EX: "amp;"; NOTE: must keep trailing ";" else "& " will be valid;
|
||||
trie.Add(key, itm);
|
||||
trie.Add_obj(key, itm);
|
||||
}
|
||||
private static void Reg_prefix(ByteTrieMgr_slim trie, byte prefix_type, String prefix) {
|
||||
private static void Reg_prefix(Btrie_slim_mgr trie, byte prefix_type, String prefix) {
|
||||
byte[] prefix_ary = Bry_.new_ascii_(prefix);
|
||||
Xop_amp_trie_itm itm = new Xop_amp_trie_itm(prefix_type, Xop_amp_trie_itm.Char_int_null, prefix_ary);
|
||||
trie.Add(prefix_ary, itm);
|
||||
trie.Add_obj(prefix_ary, itm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@ 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.parsers.apos; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_apos_lxr implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_apos;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {core_trie.Add(Apos_ary, this);} private static final byte[] Apos_ary = new byte[] {Byte_ascii.Apos, Byte_ascii.Apos};
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Apos_ary, this);} private static final byte[] Apos_ary = new byte[] {Byte_ascii.Apos, Byte_ascii.Apos};
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {return ctx.Apos().Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
|
||||
public static final Xop_apos_lxr _ = new Xop_apos_lxr(); Xop_apos_lxr() {}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@ 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.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xop_lnke_end_lxr implements Xop_lxr {//20111222
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_lnke_end;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {core_trie.Add(Byte_ascii.Brack_end, this);}
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Brack_end, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {return ctx.Lnke().MakeTkn_end(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
|
||||
public static final Xop_lnke_end_lxr _ = new Xop_lnke_end_lxr(); Xop_lnke_end_lxr() {}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ 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.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.net.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.net.*;
|
||||
public class Xop_lnke_lxr implements Xop_lxr {
|
||||
Xop_lnke_lxr(byte lnke_typ, byte[] protocol, byte tid) {this.lnke_typ = lnke_typ; this.protocol = protocol; this.tid = tid;} private byte lnke_typ; byte[] protocol; byte tid;
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_lnke_bgn;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, ByteTrieMgr_fast core_trie) {
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {
|
||||
Xoo_protocol_itm[] ary = Xoo_protocol_itm.Ary();
|
||||
int ary_len = ary.length;
|
||||
for (int i = 0; i < ary_len; i++) {
|
||||
@@ -31,8 +31,8 @@ public class Xop_lnke_lxr implements Xop_lxr {
|
||||
core_trie.Add(Bry_relative_2, new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_brack, Xoa_consts.Url_relative_prefix, Xoo_protocol_itm.Tid_relative_2));
|
||||
Ctor_lxr_add(core_trie, Bry_.new_ascii_("xowa-cmd"), Xoo_protocol_itm.Tid_xowa);
|
||||
} private static final byte[] Bry_relative_1 = Bry_.new_ascii_("[//"), Bry_relative_2 = Bry_.new_ascii_("[[//");
|
||||
public void Init_by_lang(Xol_lang lang, ByteTrieMgr_fast core_trie) {}
|
||||
private void Ctor_lxr_add(ByteTrieMgr_fast core_trie, byte[] protocol_bry, byte tid) {
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
private void Ctor_lxr_add(Btrie_fast_mgr core_trie, byte[] protocol_bry, byte tid) {
|
||||
core_trie.Add(protocol_bry , new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_text, protocol_bry, tid));
|
||||
core_trie.Add(Bry_.Add(Byte_ascii.Brack_bgn, protocol_bry) , new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_brack, protocol_bry, tid));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.net.*;
|
||||
public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
public void Ctor_ctx(Xop_ctx ctx) {url_parser = ctx.App().Url_parser().Url_parser();} Gfo_url_parser url_parser; Gfo_url_site_data site_data = new Gfo_url_site_data(); Xoa_url_parser xo_url_parser = new Xoa_url_parser(); Xoa_url xo_url_parser_url = new Xoa_url();
|
||||
public void Ctor_ctx(Xop_ctx ctx) {url_parser = ctx.App().Url_parser().Url_parser();} Gfo_url_parser url_parser; Gfo_url_site_data site_data = new Gfo_url_site_data(); Xoa_url_parser xo_url_parser = new Xoa_url_parser(); Xoa_url xo_url_parser_url = Xoa_url.blank_();
|
||||
public void Page_bgn(Xop_ctx ctx, Xop_root_tkn root) {}
|
||||
public void Page_end(Xop_ctx ctx, Xop_root_tkn root, byte[] src, int src_len) {}
|
||||
public boolean Dangling_goes_on_stack() {return dangling_goes_on_stack;} public void Dangling_goes_on_stack_(boolean v) {dangling_goes_on_stack = v;} private boolean dangling_goes_on_stack;
|
||||
@@ -74,29 +74,32 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
}
|
||||
int lnke_bgn = bgn_pos, lnke_end = -1, brack_end_pos = -1;
|
||||
int lnke_endType = EndType_null;
|
||||
while (true) { // loop until lnke_endType char;
|
||||
if (cur_pos == src_len) {lnke_endType = EndType_eos; lnke_end = cur_pos; break;}
|
||||
int lnke_end_tid = End_tid_null;
|
||||
while (true) { // loop until lnke_end_tid char;
|
||||
if (cur_pos == src_len) {lnke_end_tid = End_tid_eos; lnke_end = cur_pos; break;}
|
||||
switch (src[cur_pos]) {
|
||||
case Byte_ascii.Brack_end:
|
||||
if (lnke_type_brack) { // NOTE: check that frame begins with [ in order to end with ]
|
||||
lnke_endType = EndType_brack; brack_end_pos = cur_pos + Launcher_app_mgr.Adj_next_char;
|
||||
lnke_end_tid = End_tid_brack; brack_end_pos = cur_pos + Launcher_app_mgr.Adj_next_char;
|
||||
}
|
||||
else { // NOTE: frame does not begin with [ but ] encountered. mark "invalid" in order to force parser to stop before "]"
|
||||
lnke_endType = EndType_invalid;
|
||||
lnke_end_tid = End_tid_invalid;
|
||||
}
|
||||
break;
|
||||
case Byte_ascii.Space: lnke_endType = EndType_space; break;
|
||||
case Byte_ascii.NewLine: lnke_endType = EndType_nl; break;
|
||||
case Byte_ascii.Space: lnke_end_tid = End_tid_space; break;
|
||||
case Byte_ascii.NewLine: lnke_end_tid = End_tid_nl; break;
|
||||
case Byte_ascii.Gt: case Byte_ascii.Lt:
|
||||
lnke_endType = EndType_invalid;
|
||||
lnke_end_tid = End_tid_invalid;
|
||||
break;
|
||||
case Byte_ascii.Apos:
|
||||
if (cur_pos + 1 < src_len && src[cur_pos + 1] == Byte_ascii.Apos) // NOTE: '' breaks link, but not '; EX: [http://a.org''b'']]; DATE:2013-03-18
|
||||
lnke_endType = EndType_invalid;
|
||||
lnke_end_tid = End_tid_invalid;
|
||||
break;
|
||||
case Byte_ascii.Brack_bgn: // NOTE: always stop lnke at "[" regardless of brack_type; EX: [http:a.org[[B]]] and http:a.org[[B]]; DATE:2014-07-11
|
||||
lnke_end_tid = End_tid_symbol;
|
||||
break;
|
||||
}
|
||||
if (lnke_endType == EndType_null) cur_pos++;
|
||||
if (lnke_end_tid == End_tid_null) cur_pos++;
|
||||
else {
|
||||
lnke_end = cur_pos;
|
||||
cur_pos++;
|
||||
@@ -104,8 +107,8 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
}
|
||||
if (lnke_type_brack) {
|
||||
switch (lnke_endType) {
|
||||
case EndType_eos:
|
||||
switch (lnke_end_tid) {
|
||||
case End_tid_eos:
|
||||
if (brack_end_pos == -1) { // eos but no ]; EX: "[irc://a"
|
||||
if (dangling_goes_on_stack) { // added for Xow_popup_parser which needs to handle dangling lnke due to block_len; DATE:2014-06-20
|
||||
ctx.Subs_add_and_stack(root, tkn_mkr.Txt(bgn_pos, src_len)); // note that tkn doesn't matter, as Xow_popup_parser only cares *if* something is on stack, not *what* is on stack
|
||||
@@ -118,7 +121,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
lnke_type = Xop_lnke_tkn.Lnke_typ_brack_dangling;
|
||||
}
|
||||
break;
|
||||
case EndType_nl:
|
||||
case End_tid_nl:
|
||||
lnke_type = Xop_lnke_tkn.Lnke_typ_brack_dangling;
|
||||
return ctx.Lxr_make_txt_(lnke_end); // textify lnk; EX: [irc://a\n] textifies "[irc://a"
|
||||
default:
|
||||
@@ -132,11 +135,11 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
lnke_type = Xop_lnke_tkn.Lnke_typ_text;
|
||||
if (ctx.Cur_tkn_tid() == Xop_tkn_itm_.Tid_lnki) { // SEE:NOTE_1
|
||||
Xop_tkn_itm prv_tkn = root.Subs_get(root.Subs_len() - 1); // get last tkn
|
||||
if (prv_tkn.Tkn_tid() == Xop_tkn_itm_.Tid_lnki) { // is tkn lnki?
|
||||
if (prv_tkn.Tkn_tid() == Xop_tkn_itm_.Tid_lnki) { // is tkn lnki?
|
||||
root.Subs_del_after(prv_tkn.Tkn_sub_idx()); // delete [[ tkn and replace with [ tkn
|
||||
root.Subs_add(tkn_mkr.Txt(prv_tkn.Src_bgn(), prv_tkn.Src_bgn() + 1));
|
||||
ctx.Stack_pop_last(); // don't forget to remove from stack
|
||||
lnke_type = Xop_lnke_tkn.Lnke_typ_brack; // change lnke_typee to brack
|
||||
ctx.Stack_pop_last(); // don't forget to remove from stack
|
||||
lnke_type = Xop_lnke_tkn.Lnke_typ_brack; // change lnke_typee to brack
|
||||
--bgn_pos;
|
||||
}
|
||||
}
|
||||
@@ -162,30 +165,31 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
}
|
||||
ctx.Subs_add(root, tkn);
|
||||
if (lnke_type == Xop_lnke_tkn.Lnke_typ_brack) {
|
||||
if (lnke_endType == EndType_brack) {
|
||||
if (lnke_end_tid == End_tid_brack) {
|
||||
tkn.Src_end_(cur_pos);
|
||||
tkn.Subs_move(root);
|
||||
return cur_pos;
|
||||
}
|
||||
ctx.Stack_add(tkn);
|
||||
if (lnke_endType == EndType_invalid) {
|
||||
if (lnke_end_tid == End_tid_invalid) {
|
||||
return cur_pos - 1; // -1 to return before < or >
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (lnke_endType) {
|
||||
case EndType_space:
|
||||
switch (lnke_end_tid) {
|
||||
case End_tid_space:
|
||||
ctx.Subs_add(root, tkn_mkr.Space(root, cur_pos - 1, cur_pos));
|
||||
break;
|
||||
case EndType_nl:
|
||||
case EndType_invalid: // NOTE that cur_pos is set after <, must subtract 1 else </xnde> will be ignored; EX: <span>irc://a</span>
|
||||
case End_tid_symbol:
|
||||
case End_tid_nl:
|
||||
case End_tid_invalid: // NOTE that cur_pos is set after <, must subtract 1 else </xnde> will be ignored; EX: <span>irc://a</span>
|
||||
return cur_pos - 1;
|
||||
}
|
||||
}
|
||||
return cur_pos;
|
||||
}
|
||||
private static final byte Lnki_linkMode_init = 0, Lnki_linkMode_eq = 1, Lnki_linkMode_text = 2;
|
||||
private static final byte EndType_null = 0, EndType_eos = 1, EndType_brack = 2, EndType_space = 3, EndType_nl = 4, EndType_invalid = 5;
|
||||
private static final byte End_tid_null = 0, End_tid_eos = 1, End_tid_brack = 2, End_tid_space = 3, End_tid_nl = 4, End_tid_symbol = 5, End_tid_invalid = 6;
|
||||
public int MakeTkn_end(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
|
||||
// Xop_tkn_itm last_tkn = ctx.Stack_get_last(); // BLOCK:invalid_ttl_check; // TODO: backout apos changes
|
||||
// if ( last_tkn != null
|
||||
@@ -225,7 +229,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
if (prv_byte >= Byte_ascii.Ascii_min && prv_byte <= Byte_ascii.Ascii_max) return true; // consider all other ASCII chars as true; EX: \t\n !, etc;
|
||||
prv_pos = gplx.intl.Utf8_.Get_pos0_of_char_bwd(src, prv_pos);
|
||||
prv_byte = src[prv_pos];
|
||||
boolean prv_char_is_letter = ctx.Lang().Case_mgr().Match(prv_byte, src, prv_pos, bgn_pos);
|
||||
boolean prv_char_is_letter = ctx.Lang().Case_mgr().Match_any_exists(prv_byte, src, prv_pos, bgn_pos);
|
||||
return !prv_char_is_letter;
|
||||
}
|
||||
private int Make_tkn_xowa(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos, byte[] protocol, byte proto_tid, byte lnke_type) {
|
||||
|
||||
@@ -53,4 +53,11 @@ public class Xop_lnke_wkr_brack_tst {
|
||||
, "http://a.org"
|
||||
);
|
||||
}
|
||||
@Test public void Lnki_one() { // PURPOSE: parallel test for "http://a.org[[B]]"; DATE:2014-07-11
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[http://a.org b [[C]] d]"
|
||||
,String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"http://a.org\" class=\"external text\" rel=\"nofollow\">b <a href=\"/wiki/C\">C</a> d</a>"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,11 @@ public class Xop_lnke_wkr_text_tst {
|
||||
@Test public void Defect_reverse_caption_link() { // PURPOSE: bad lnke formatting (caption before link); ] should show up at end, but only [ shows up; EX.WP: Paul Philippoteaux; [caption http://www.americanheritage.com]
|
||||
fxt.Test_parse_page_wiki_str("[caption irc://a]", "[caption <a href=\"irc://a\" class=\"external text\" rel=\"nofollow\">irc://a</a>]");
|
||||
}
|
||||
@Test public void Lnki() { // PURPOSE: trailing lnki should not get absorbed into lnke; DATE:2014-07-11
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "http://a.org[[B]]" // NOTE: [[ should create another lnki
|
||||
,String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"http://a.org\" class=\"external text\" rel=\"nofollow\">http://a.org</a><a href=\"/wiki/B\">B</a>"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.html.*;
|
||||
import gplx.core.btries.*; import gplx.html.*;
|
||||
public class Nowiki_escape_itm {
|
||||
public Nowiki_escape_itm(boolean tid_space, byte[] src, byte[] trg) {this.tid_space = tid_space; this.src = src; this.trg = trg;}
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
@@ -27,7 +27,7 @@ public class Nowiki_escape_itm {
|
||||
boolean dirty = false;
|
||||
for (int i = bgn; i < end; i++) {
|
||||
byte b = src[i];
|
||||
Object o = trie.Match(b, src, i, end);
|
||||
Object o = trie.Match_bgn_w_byte(b, src, i, end);
|
||||
if (o == null) {
|
||||
if (dirty)
|
||||
tmp_bfr.Add_byte(b);
|
||||
@@ -49,9 +49,9 @@ public class Nowiki_escape_itm {
|
||||
}
|
||||
return dirty;
|
||||
}
|
||||
private static final ByteTrieMgr_slim trie = trie_new();
|
||||
private static ByteTrieMgr_slim trie_new() {
|
||||
ByteTrieMgr_slim rv = ByteTrieMgr_slim.cs_();
|
||||
private static final Btrie_slim_mgr trie = trie_new();
|
||||
private static Btrie_slim_mgr trie_new() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.cs_();
|
||||
trie_new_itm(rv, Bool_.N, Byte_ascii.Lt_bry , Html_entity_.Lt_bry);
|
||||
trie_new_itm(rv, Bool_.N, Byte_ascii.Brack_bgn_bry , Html_entity_.Brack_bgn_bry);
|
||||
trie_new_itm(rv, Bool_.N, Byte_ascii.Pipe_bry , Html_entity_.Pipe_bry);
|
||||
@@ -62,8 +62,8 @@ public class Nowiki_escape_itm {
|
||||
trie_new_itm(rv, Bool_.Y, Byte_ascii.Space_bry , Html_entity_.Space_bry);
|
||||
return rv;
|
||||
}
|
||||
private static void trie_new_itm(ByteTrieMgr_slim rv, boolean tid_space, byte[] src, byte[] trg) {
|
||||
private static void trie_new_itm(Btrie_slim_mgr rv, boolean tid_space, byte[] src, byte[] trg) {
|
||||
Nowiki_escape_itm itm = new Nowiki_escape_itm(tid_space, src, trg);
|
||||
rv.Add(src, itm);
|
||||
rv.Add_obj(src, itm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,11 @@ public class Gxw_html_server implements Gxw_html {
|
||||
cfg = Swt_kit._.Html_cfg();
|
||||
}
|
||||
public String Html_doc_html() {return Exec(cfg.Doc_html());}
|
||||
public void Html_doc_html_(String s) {Exec("location.reload(true);");} // HACK: force reload of page
|
||||
public void Html_doc_html_load_by_mem(String html) {Exec("location.reload(true);");} // HACK: force reload of page
|
||||
public void Html_doc_html_load_by_url(String path, String html) {Exec("location.reload(true);");} // HACK: force reload of page
|
||||
public byte Html_doc_html_load_tid() {return html_doc_html_load_tid;} private byte html_doc_html_load_tid;
|
||||
public void Html_doc_html_load_tid_(byte v) {html_doc_html_load_tid = v;}
|
||||
public void Html_dispose() {}
|
||||
public String Html_doc_selected_get_text_or_href() {return Exec(cfg.Doc_selected_get_text_or_href());}
|
||||
public String Html_doc_selected_get_href_or_text() {return Exec(cfg.Doc_selected_get_href_or_text());}
|
||||
public String Html_doc_selected_get_src_or_empty() {return Exec(cfg.Doc_selected_get_src_or_empty());}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Http_server_mgr implements GfoInvkAble {
|
||||
byte[] wiki_domain = Bry_.new_utf8_(wiki_domain_str);
|
||||
byte[] page_ttl = Bry_.new_utf8_(page_ttl_str);
|
||||
Xow_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(wiki_domain); // get the wiki
|
||||
Xoa_url page_url = new Xoa_url(); app.Url_parser().Parse(page_url, page_ttl); // get the url (needed for query args)
|
||||
Xoa_url page_url = app.Url_parser().Parse(page_ttl); // get the url (needed for query args)
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, page_ttl); // get the ttl
|
||||
Xoa_page page = wiki.GetPageByTtl(page_url, ttl); // get page and parse it
|
||||
app.Gui_mgr().Browser_win().Active_page_(page); // HACK: init gui_mgr's page for output (which server ordinarily doesn't need)
|
||||
|
||||
@@ -22,12 +22,14 @@ import gplx.xowa.specials.allPages.*; import gplx.xowa.specials.search.*; import
|
||||
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
public class Xows_mgr {
|
||||
public Xows_mgr(Xow_wiki wiki) {
|
||||
private Hash_adp_bry hash;
|
||||
public Xows_mgr(Xow_wiki wiki, Xol_lang lang) {
|
||||
hash = Hash_adp_bry.ci_utf8_(lang.Case_mgr());
|
||||
page_allpages = new Xows_page_allpages(wiki);
|
||||
page_search = new Xosrh_core(wiki);
|
||||
page_random = new Xows_page_random(wiki);
|
||||
Evt_lang_changed(wiki.Lang());
|
||||
} private Hash_adp_bry hash = Hash_adp_bry.ci_();
|
||||
}
|
||||
public Xows_page_allpages Page_allpages() {return page_allpages;} private Xows_page_allpages page_allpages;
|
||||
public Xosrh_core Page_search() {return page_search;} private Xosrh_core page_search;
|
||||
public Xows_page_random Page_random() {return page_random;} private Xows_page_random page_random;
|
||||
|
||||
@@ -187,7 +187,7 @@ class Xows_page_allpages_fxt {
|
||||
Tfds.Eq_ary_str(Xto_str_ary(init_url.Args()), Xto_str_ary(expd_args_ary));
|
||||
}
|
||||
return this;
|
||||
} private Xoa_url init_url = new Xoa_url();
|
||||
} private Xoa_url init_url = Xoa_url.blank_();
|
||||
public Xows_page_allpages_fxt Test_build_html(String expd) {
|
||||
Exec_build();
|
||||
allpages.Build_html(wiki.Ctx().Cur_page());
|
||||
|
||||
@@ -168,7 +168,7 @@ class Move_url_args {
|
||||
create_redirect = false;
|
||||
}
|
||||
private static final byte Key_submitted = 1, Key_src_ttl = 2, Key_trg_ns = 3, Key_trg_ttl = 4, Key_create_redirect = 5;
|
||||
private static final Hash_adp_bry arg_keys = Hash_adp_bry.ci_()
|
||||
private static final Hash_adp_bry arg_keys = Hash_adp_bry.ci_ascii_()
|
||||
.Add_str_byte("wpMove" , Key_submitted)
|
||||
.Add_str_byte("wpOldTitle" , Key_src_ttl)
|
||||
.Add_str_byte("wpNewTitleNs" , Key_trg_ns)
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.specials.nearby; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
public class Nearby_mgr implements Xows_page {
|
||||
Xow_wiki wiki; byte[] trg;
|
||||
Hash_adp_bry excluded = Hash_adp_bry.ci_();
|
||||
Hash_adp_bry visited = Hash_adp_bry.ci_();
|
||||
private Hash_adp_bry excluded = Hash_adp_bry.ci_ascii_();
|
||||
private Hash_adp_bry visited = Hash_adp_bry.ci_ascii_();
|
||||
ListAdp trail = ListAdp_.new_();
|
||||
ListAdp results = ListAdp_.new_();
|
||||
int results_cur = 0;
|
||||
|
||||
@@ -46,7 +46,7 @@ class Nearby_mgr_fxt {
|
||||
if (fxt == null) {
|
||||
fxt = new Xop_fxt();
|
||||
nearby_mgr = new Nearby_mgr();
|
||||
excluded = Hash_adp_bry.ci_();
|
||||
excluded = Hash_adp_bry.ci_ascii_();
|
||||
tmp_bfr = Bry_bfr.new_();
|
||||
}
|
||||
fxt.Reset();
|
||||
|
||||
@@ -120,7 +120,7 @@ class Xosrh_args_mgr {
|
||||
ns_mgr.Add_main_if_empty();
|
||||
} private static final byte Arg_search = 0, Arg_page_idx = 1, Arg_sort = 2;
|
||||
private static byte[] Ns_bry = Bry_.new_ascii_("ns");
|
||||
private static final Hash_adp_bry url_args = Hash_adp_bry.ci_()
|
||||
private static final Hash_adp_bry url_args = Hash_adp_bry.ci_ascii_()
|
||||
.Add_str_byte("xowa_page_index", Arg_page_idx)
|
||||
.Add_str_byte("xowa_sort", Arg_sort)
|
||||
.Add_str_byte("search", Arg_search)
|
||||
|
||||
@@ -190,18 +190,16 @@ class Xos_search_mgr_fxt {
|
||||
byte[] ttl_bry = Bry_.new_ascii_(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry);
|
||||
Xoa_page page = Xoa_page.test_(wiki, ttl);
|
||||
Xoa_url url = new Xoa_url();
|
||||
byte[] url_bry = Bry_.new_utf8_("http://en.wikipedia.org/wiki/Special:Search/" + ttl_str + args_str);
|
||||
wiki.App().Url_parser().Parse(url, url_bry, 0, url_bry.length);
|
||||
Xoa_url url = wiki.App().Url_parser().Parse(url_bry);
|
||||
search_mgr.Special_gen(url, page, wiki, ttl);
|
||||
Tfds.Eq_str_lines(expd_html, String_.new_utf8_(page.Root().Data_htm()));
|
||||
}
|
||||
public void Test_search2(byte match_tid, String ttl_str, int page_idx, byte sort_tid, String... expd_ary) {
|
||||
Bry_bfr bfr = wiki.Utl_bry_bfr_mkr().Get_b128();
|
||||
Xoa_url url = new Xoa_url();
|
||||
Xoa_url_parser url_parser = new Xoa_url_parser();
|
||||
byte[] url_raw = Bry_.new_ascii_("Special:Search/" + ttl_str + ((match_tid == Xosrh_core.Match_tid_all) ? "" : "*") + "?fulltext=y" + Xosrh_rslt_itm_sorter.Xto_url_arg(sort_tid) + "&xowa_page_size=1&xowa_page_index=" + page_idx);
|
||||
url_parser.Parse(url, url_raw);
|
||||
Xoa_url url = url_parser.Parse(url_raw);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url_raw);
|
||||
Xoa_page page = wiki.Ctx().Cur_page();
|
||||
search_mgr.Special_gen(url, page, wiki, ttl);
|
||||
|
||||
@@ -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.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
import gplx.core.btries.*;
|
||||
class Xosrh_scanner {
|
||||
ListAdp tkns = ListAdp_.new_(); byte[] src; int src_len; int pos; int txt_bgn;
|
||||
public Xosrh_qry_tkn[] Scan(byte[] src) {
|
||||
@@ -23,7 +24,7 @@ class Xosrh_scanner {
|
||||
tkns.Clear(); pos = 0; txt_bgn = -1;
|
||||
while (pos < src_len) {
|
||||
byte cur_b = src[pos];
|
||||
Object cur_obj = trie.Match(cur_b, src, pos, src_len);
|
||||
Object cur_obj = trie.Match_bgn_w_byte(cur_b, src, pos, src_len);
|
||||
if (cur_obj == null) { // text character
|
||||
if (txt_bgn == -1) txt_bgn = pos; // 1st character not set; set it
|
||||
++pos;
|
||||
@@ -76,7 +77,7 @@ class Xosrh_scanner {
|
||||
if (txt_bgn == -1) { // no pending word;
|
||||
if (cur_tid == Xosrh_qry_tkn.Tid_not) return false; // NOT is only operator if no pending tkn; EX: -abc -> NOT abc; a-b -> a-b
|
||||
byte nxt_b = pos_end < src_len ? src[pos_end] : Byte_ascii.Nil;
|
||||
Object nxt_obj = trie.Match(nxt_b, src, pos_end, src_len);
|
||||
Object nxt_obj = trie.Match_bgn_w_byte(nxt_b, src, pos_end, src_len);
|
||||
if (nxt_obj == null) // next tkn is text; join must be word
|
||||
join_is_word = true;
|
||||
else { // next tkn is tkn
|
||||
@@ -129,7 +130,7 @@ class Xosrh_scanner {
|
||||
OrderedHash tmp_list = OrderedHash_.new_(); Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
Xosrh_qry_tkn new_tkn_(byte tid, int val_bgn, int val_end) {return Xosrh_qry_tkn.new_pos_(tid, val_bgn, val_end);}
|
||||
private static byte[] Bry_and = Bry_.new_ascii_("AND");
|
||||
private static final ByteTrieMgr_slim trie = ByteTrieMgr_slim.ci_ascii_()// NOTE:ci.ascii:OR / AND only
|
||||
private static final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_ascii_()// NOTE:ci.ascii:OR / AND only
|
||||
.Add_str_byte(" ", Xosrh_qry_tkn.Tid_space)
|
||||
.Add_str_byte("\"", Xosrh_qry_tkn.Tid_quote)
|
||||
.Add_str_byte("-", Xosrh_qry_tkn.Tid_not)
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Xou_fsys_mgr implements GfoInvkAble {
|
||||
this.cur_root = user_dir;
|
||||
app_root_dir = cur_root.GenSubDir("app");
|
||||
app_temp_dir = app_root_dir.GenSubDir("tmp");
|
||||
app_temp_html_dir = app_temp_dir.GenSubDir("html");
|
||||
app_data_history_fil = app_root_dir.GenSubFil_nest("data", "history", "page_history.csv");
|
||||
wiki_root_dir = cur_root.GenSubDir("wiki");
|
||||
home_wiki_dir = wiki_root_dir.GenSubDir_nest(Xow_wiki_domain_.Key_home_str);
|
||||
@@ -32,6 +33,7 @@ public class Xou_fsys_mgr implements GfoInvkAble {
|
||||
public Io_url Wiki_html_dir(String wiki){return wiki_root_dir.GenSubDir_nest(wiki, "html");}
|
||||
public Io_url App_data_history_fil() {return app_data_history_fil;} private Io_url app_data_history_fil;
|
||||
public Io_url App_temp_dir() {return app_temp_dir;} private Io_url app_temp_dir;
|
||||
public Io_url App_temp_html_dir() {return app_temp_html_dir;} private Io_url app_temp_html_dir;
|
||||
public Io_url App_img_dir() {return app_root_dir.GenSubDir_nest("img");}
|
||||
public Io_url App_data_dir() {return app_root_dir.GenSubDir_nest("data");}
|
||||
public Io_url App_data_cfg_dir() {return app_root_dir.GenSubDir_nest("data", "cfg");}
|
||||
|
||||
@@ -59,6 +59,8 @@ public class Xou_user implements GfoInvkAble {
|
||||
public void App_term() {
|
||||
session_mgr.Window_mgr().Save_window(app.Gui_mgr().Browser_win().Win_box());
|
||||
history_mgr.Save(app);
|
||||
if (app.Gui_mgr().Browser_win().Tab_mgr().Html_load_tid__url())
|
||||
Io_mgr._.DeleteDirDeep(fsys_mgr.App_temp_html_dir());
|
||||
db_mgr.App_term();
|
||||
}
|
||||
public void Bookmarks_add(byte[] wiki_domain, byte[] ttl_full_txt) {
|
||||
|
||||
@@ -42,9 +42,9 @@ public class Xou_history_mgr implements GfoInvkAble {// app.user.history
|
||||
Xoa_url url = page.Url();
|
||||
Xoa_ttl ttl = page.Ttl();
|
||||
byte[] page_ttl = null;
|
||||
ListAdp redirect_list = page.Redirect_list();
|
||||
ListAdp redirect_list = page.Redirected_ttls();
|
||||
if (redirect_list.Count() > 0) // page was redirected; add src ttl to history, not trg; EX: UK -> United Kingdom; add "UK"; DATE:2014-02-28
|
||||
page_ttl = (byte[])page.Redirect_list().FetchAt(0);
|
||||
page_ttl = (byte[])page.Redirected_ttls().FetchAt(0);
|
||||
else {
|
||||
page_ttl = Bry_.Add(ttl.Ns().Name_db_w_colon(), ttl.Page_txt()); // use ttl.Page_txt() b/c it normalizes space/casing (url.Page_txt does not)
|
||||
if (url.Args().length > 0)
|
||||
|
||||
@@ -69,8 +69,7 @@ class Xou_history_mgr_fxt {
|
||||
Xoa_page page = Xoa_page.test_(wiki, ttl);
|
||||
byte[] url_bry = ttl_bry;
|
||||
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_utf8_(arg_str));
|
||||
Xoa_url url = new Xoa_url();
|
||||
app.Url_parser().Parse(url, url_bry);
|
||||
Xoa_url url = app.Url_parser().Parse(url_bry);
|
||||
url.Wiki_bry_(wiki.Domain_bry());
|
||||
page.Url_(url); // set url b/c history_mgr.Add uses url
|
||||
// page.Url_(Xoa_url.new_(wiki.Key_bry(), url_bry)); // set url b/c history_mgr.Add uses url
|
||||
|
||||
@@ -17,12 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
public class Xoa_wiki_mgr implements GfoInvkAble {
|
||||
public class Xoa_wiki_mgr implements GfoInvkAble {
|
||||
private Xoa_app app;
|
||||
private ListAdp list = ListAdp_.new_(); private Hash_adp_bry hash = Hash_adp_bry.ci_ascii_(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
public Xoa_wiki_mgr(Xoa_app app) {
|
||||
this.app = app;
|
||||
wiki_regy = new Xoa_wiki_regy(app);
|
||||
wdata_mgr = new Wdata_wiki_mgr(app);
|
||||
} private Xoa_app app;
|
||||
}
|
||||
public Xoa_wiki_regy Wiki_regy() {return wiki_regy;} private Xoa_wiki_regy wiki_regy;
|
||||
public Cfg_nde_root Groups() {return groups;} Cfg_nde_root groups = new Cfg_nde_root().Root_(new Xoac_wiki_grp(Bry_.Empty), Xoac_lang_grp.Make_grp, Bry_.Ary_empty);
|
||||
public Xow_script_mgr Scripts() {return scripts;} private Xow_script_mgr scripts = new Xow_script_mgr();
|
||||
@@ -31,7 +33,7 @@ public class Xoa_wiki_mgr implements GfoInvkAble {
|
||||
public void Init_by_app() {
|
||||
css_installer.Init_by_app(app);
|
||||
}
|
||||
public int Count() {return hash.Count();} Hash_adp_bry hash = Hash_adp_bry.ci_(); ListAdp list = ListAdp_.new_();
|
||||
public int Count() {return hash.Count();}
|
||||
public Xow_wiki Get_at(int i) {return Int_.Between(i, 0, this.Count() - 1) ? (Xow_wiki)list.FetchAt(i) : null;}
|
||||
public Xow_wiki Get_by_key_or_null(byte[] key) {return Bry_.Len_eq_0(key) ? null : (Xow_wiki)hash.Fetch(key);}
|
||||
public Xow_wiki Get_by_key_or_null(byte[] src, int bgn, int end) {return (Xow_wiki)hash.Get_by_mid(src, bgn, end);}
|
||||
|
||||
@@ -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.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xow_wiki_abrv_ {
|
||||
public static boolean parse_(Xow_wiki_abrv rv, byte[] src, int bgn, int end) {
|
||||
rv.Clear();
|
||||
if (end - bgn == 0) return false; // empty bry
|
||||
Object o = trie.MatchAtCur(src, end - 1, bgn - 1); if (o == null) return false;
|
||||
Object o = trie.Match_bgn(src, end - 1, bgn - 1); if (o == null) return false;
|
||||
byte tid = ((Byte_obj_val)o).Val();
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key_or_intl(src, bgn, trie.Match_pos() + 1);
|
||||
rv.Ctor_by_parse(lang_itm, tid);
|
||||
@@ -44,9 +45,9 @@ public class Xow_wiki_abrv_ {
|
||||
, Tid_mediawiki = Xow_wiki_domain_.Tid_mediawiki
|
||||
, Tid_wikimediafoundation = Xow_wiki_domain_.Tid_wikimediafoundation
|
||||
;
|
||||
private static final ByteTrieMgr_bwd_slim trie = Init_trie();
|
||||
private static ByteTrieMgr_bwd_slim Init_trie() {
|
||||
ByteTrieMgr_bwd_slim rv = new ByteTrieMgr_bwd_slim(false);
|
||||
private static final Btrie_bwd_mgr trie = Init_trie();
|
||||
private static Btrie_bwd_mgr Init_trie() {
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
Init_trie_itm(rv, "wiki" , Tid_wikipedia);
|
||||
Init_trie_itm(rv, "wiktionary" , Tid_wiktionary);
|
||||
Init_trie_itm(rv, "wikisource" , Tid_wikisource);
|
||||
@@ -64,7 +65,7 @@ public class Xow_wiki_abrv_ {
|
||||
Init_trie_itm(rv, "foundationwiki" , Tid_wikimediafoundation);
|
||||
return rv;
|
||||
}
|
||||
private static void Init_trie_itm(ByteTrieMgr_bwd_slim rv, String abrv_name, byte abrv_tid) {
|
||||
private static void Init_trie_itm(Btrie_bwd_mgr rv, String abrv_name, byte abrv_tid) {
|
||||
rv.Add(abrv_name, Byte_obj_val.new_(abrv_tid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Xow_wiki_domain_ {
|
||||
Object o = lang_map_hash.Get_by_bry(v);
|
||||
return o == null ? v : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry lang_map_hash = Hash_adp_bry.ci_()
|
||||
private static final Hash_adp_bry lang_map_hash = Hash_adp_bry.ci_ascii_() // ASCII:lang_code
|
||||
.Add_str_obj("simple" , Bry_.new_ascii_("en"))
|
||||
.Add_str_obj("zh-classical" , Bry_.new_ascii_("lzh"))
|
||||
.Add_str_obj("no" , Bry_.new_ascii_("nb"))
|
||||
@@ -105,7 +105,7 @@ public class Xow_wiki_domain_ {
|
||||
, Key_wikidata_bry, Key_mediawiki_bry, Key_wikimediafoundation_bry
|
||||
};
|
||||
public static final byte[] Seg_org_bry = Bry_.new_ascii_("org"), Seg_wikimedia_bry = Bry_.new_ascii_("wikimedia"), Seg_www_bry = Bry_.new_utf8_("www");
|
||||
private static final Hash_adp_bry key_hash = Hash_adp_bry.ci_()
|
||||
private static final Hash_adp_bry key_hash = Hash_adp_bry.ci_ascii_()
|
||||
.Add_bry_byte(Seg_wikimedia_bry, Tid_wikimedia) // PERF: not a "key" but makes Parse quicker
|
||||
.Add_bry_byte(Key_home_bry, Tid_home)
|
||||
.Add_bry_byte(Key_commons_bry, Tid_commons)
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xow_page_cache {
|
||||
if (rv == null) {
|
||||
Xoa_page page = wiki.Data_mgr().Get_page(ttl, true); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if (!page.Missing()) {
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Data_raw());
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Data_raw(), page.Redirected_src());
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_page_cache_itm {
|
||||
public Xow_page_cache_itm(Xoa_ttl ttl, byte[] src) {this.ttl = ttl; this.src = src;}
|
||||
public Xow_page_cache_itm(Xoa_ttl ttl, byte[] src, byte[] redirected_src) {
|
||||
this.ttl = ttl; this.src = src;
|
||||
this.redirected_src = redirected_src;
|
||||
}
|
||||
public Xoa_ttl Ttl() {return ttl;} private Xoa_ttl ttl;
|
||||
public byte[] Src() {return src;} private byte[] src;
|
||||
public byte[] Redirected_src() {return redirected_src;} private byte[] redirected_src;
|
||||
public static final Xow_page_cache_itm Null = null;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.xtns.gallery.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.poems.*; import gplx.xowa.xtns.hiero.*;
|
||||
import gplx.xowa.xtns.scores.*; import gplx.xowa.xtns.listings.*; import gplx.xowa.xtns.titleBlacklists.*;
|
||||
import gplx.xowa.xtns.scores.*; import gplx.xowa.xtns.listings.*; import gplx.xowa.xtns.titleBlacklists.*; import gplx.xowa.xtns.pfuncs.scribunto.*;
|
||||
public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
private OrderedHash regy = OrderedHash_.new_bry_();
|
||||
public int Count() {return regy.Count();}
|
||||
@@ -31,6 +31,7 @@ public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
Add(app, new Score_xtn_mgr());
|
||||
Add(app, new Listing_xtn_mgr());
|
||||
Add(app, new Blacklist_xtn_mgr());
|
||||
Add(app, new Pfunc_xtn_mgr());
|
||||
return this;
|
||||
}
|
||||
public Xow_xtn_mgr Ctor_by_wiki(Xow_wiki wiki) {
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.cite; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
public class Ref_itm_mgr {
|
||||
private Hash_adp_bry grps = Hash_adp_bry.ci_();
|
||||
private Hash_adp_bry grps = Hash_adp_bry.cs_(); // CASE_MATCH:changed from ci; DATE:2014-07-07
|
||||
private Ref_itm_grp grp_default = new Ref_itm_grp(Bry_.Empty);
|
||||
private int uid_last;
|
||||
public int Tag__next_id() {return ++tag__next_id;} private int tag__next_id = 0;
|
||||
|
||||
@@ -26,8 +26,8 @@ public class Ref_itm_mgr_tst {
|
||||
@Test public void Follow() {fxt.run_Add("key_1").run_Add_follow("key_1").tst(fxt.itm_("key_1", 0, 0).Related_(fxt.itm_uid_(1).Idx_minor_follow_()));}
|
||||
}
|
||||
class Ref_itm_mgr_fxt {
|
||||
Ref_itm_mgr ref_mgr = new Ref_itm_mgr();
|
||||
Tst_mgr tst_mgr = new Tst_mgr();
|
||||
private Ref_itm_mgr ref_mgr = new Ref_itm_mgr();
|
||||
private Tst_mgr tst_mgr = new Tst_mgr();
|
||||
public Xtn_ref_nde_chkr itm_uid_(int uid) {return itm_(null, -1, uid);}
|
||||
public Xtn_ref_nde_chkr itm_(String key, int idx) {return itm_(key, idx, -1);}
|
||||
public Xtn_ref_nde_chkr itm_(String key, int idx, int uid) {return new Xtn_ref_nde_chkr().Key_(key).Idx_major_(idx).Uid_(uid);}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Ref_nde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
}
|
||||
public void Xtn_parse(Xow_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
if (ctx.Tid_is_popup()) return;
|
||||
Xop_xatr_itm.Xatr_parse(wiki.App(), this, wiki.Lang().Xatrs_ref(), wiki, src, xnde);
|
||||
Xop_xatr_itm.Xatr_parse(wiki.App(), this, xatrs_hash, wiki, src, xnde);
|
||||
if (xnde.CloseMode() == Xop_xnde_tkn.CloseMode_pair)
|
||||
body = wiki.Parser().Parse_text_to_wdom_old_ctx(ctx, Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn()), false);
|
||||
byte[] references_group = ctx.References_group(); // set by <references>
|
||||
@@ -76,4 +76,9 @@ public class Ref_nde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
}
|
||||
public static final byte Xatr_id_name = 0, Xatr_id_group = 1, Xatr_id_follow = 2;
|
||||
public static final int Idx_minor_follow = -2;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_ascii_()
|
||||
.Add_str_obj("name", Byte_obj_val.new_(Ref_nde.Xatr_id_name))
|
||||
.Add_str_obj("group", Byte_obj_val.new_(Ref_nde.Xatr_id_group))
|
||||
.Add_str_obj("follow", Byte_obj_val.new_(Ref_nde.Xatr_id_follow));
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user