mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.10.3.1
This commit is contained in:
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.net.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.html.hrefs.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.lnkis.*; import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xop_link_parser {
|
||||
public byte[] Html_xowa_ttl() {return html_xowa_ttl;} private byte[] html_xowa_ttl;
|
||||
public byte Html_anchor_cls() {return html_anchor_cls;} private byte html_anchor_cls;
|
||||
@@ -44,7 +44,7 @@ public class Xop_link_parser {
|
||||
}
|
||||
tmp_bfr.Add(raw); // dump everything
|
||||
}
|
||||
raw = tmp_bfr.Xto_bry_and_clear();
|
||||
raw = tmp_bfr.To_bry_and_clear();
|
||||
html_anchor_cls = Xoh_lnki_consts.Tid_a_cls_none;
|
||||
html_anchor_rel = Xoh_lnki_consts.Tid_a_rel_nofollow;
|
||||
break;
|
||||
@@ -56,7 +56,7 @@ public class Xop_link_parser {
|
||||
html_xowa_ttl = Bry_.Mid(raw, slash_pos + Int_.Const_dlm_len, raw.length);
|
||||
}
|
||||
else // next char is not slash; assume xfer_itm refers to ns; EX:File:A.png
|
||||
raw = tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(raw).Xto_bry_and_clear();
|
||||
raw = tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(raw).To_bry_and_clear();
|
||||
break;
|
||||
default: // is page only; EX: Abc
|
||||
if (Bry_.Len_eq_0(raw)) // NOTE: handle blank link; EX: [[File:Loudspeaker.svg|11px|link=|alt=play]]
|
||||
@@ -67,7 +67,7 @@ public class Xop_link_parser {
|
||||
tmp_bfr.Clear();
|
||||
return null;
|
||||
}
|
||||
raw = tmp_bfr.Xto_bry_and_clear();
|
||||
raw = tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.numbers.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.numbers.*;
|
||||
public class Xop_lnki_arg_parser {
|
||||
private final Btrie_fast_mgr key_trie = Btrie_fast_mgr.cs();
|
||||
private final Bry_bfr int_bfr = Bry_bfr.reset_(16);
|
||||
private final Btrie_bwd_mgr px_trie = Btrie_bwd_mgr.cs_(); private final Btrie_fast_mgr size_trie = Btrie_fast_mgr.cs();
|
||||
private int lnki_w, lnki_h;
|
||||
public void Evt_lang_changed(Xol_lang lang) {
|
||||
public void Evt_lang_changed(Xol_lang_itm lang) {
|
||||
Bry_bfr tmp_bfr = int_bfr;
|
||||
Byte_obj_ref rslt = Byte_obj_ref.zero_();
|
||||
Xol_kwd_mgr mgr = lang.Kwd_mgr();
|
||||
@@ -103,7 +103,7 @@ public class Xop_lnki_arg_parser {
|
||||
}
|
||||
case Key_dim_x: {
|
||||
if (mode_width) {
|
||||
this.lnki_w = int_bfr.XtoIntAndClear(-1);
|
||||
this.lnki_w = int_bfr.To_int_and_clear(-1);
|
||||
mode_width = false;
|
||||
break;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ public class Xop_lnki_arg_parser {
|
||||
}
|
||||
}
|
||||
}
|
||||
int dim = int_bfr.XtoIntAndClear(-1);
|
||||
int dim = int_bfr.To_int_and_clear(-1);
|
||||
if (mode_width) this.lnki_w = dim;
|
||||
else this.lnki_h = dim;
|
||||
return Tid_dim;
|
||||
@@ -126,7 +126,7 @@ public class Xop_lnki_arg_parser {
|
||||
if (list == null && Env_.Mode_testing()) return; // TEST: allows partial parsing of $magicWords
|
||||
size_trie.Clear(); px_trie.Clear();
|
||||
for (int i = 0; i < 10; i++)
|
||||
size_trie.Add((byte)(i + Char_.AsciiZero), Byte_obj_val.new_(Key_dim_num));
|
||||
size_trie.Add((byte)(i + Byte_ascii.Num_0), Byte_obj_val.new_(Key_dim_num));
|
||||
int len = digit_mgr.Len(); // NOTE: add non-english numbers; EX: ۲۰۰px; DATE:2015-07-18
|
||||
for (int i = 0; i < len; ++i) {
|
||||
KeyVal kv = digit_mgr.Get_at(i);
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xop_lnki_lxr_bgn implements Xop_lxr {
|
||||
public int Lxr_tid() {return Xop_lxr_.Tid_lnki_bgn;}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_bgn, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Init_by_lang(Xol_lang_itm lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Term(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) {
|
||||
Xop_tkn_itm prv_tkn = ctx.Stack_get_last();
|
||||
@@ -37,7 +37,7 @@ public class Xop_lnki_lxr_bgn implements Xop_lxr {
|
||||
ctx.Subs_add_and_stack(root, lnki);
|
||||
return cur_pos;
|
||||
}
|
||||
public static final Xop_lnki_lxr_bgn _ = new Xop_lnki_lxr_bgn();
|
||||
public static final Xop_lnki_lxr_bgn Instance = new Xop_lnki_lxr_bgn();
|
||||
}
|
||||
class Xop_lnki_size {public static final int None = 0, Width = 1, Height = 2, WidthHeight = 4, Upright = 8;}
|
||||
/*
|
||||
|
||||
@@ -21,8 +21,8 @@ import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xop_lnki_lxr_end implements Xop_lxr {
|
||||
public int Lxr_tid() {return Xop_lxr_.Tid_lnki_end;}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_end, this);}
|
||||
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Init_by_lang(Xol_lang_itm lang, Btrie_fast_mgr core_trie) {}
|
||||
public void Term(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.Lnki().Make_tkn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
|
||||
public static final Xop_lnki_lxr_end _ = new Xop_lnki_lxr_end();
|
||||
public static final Xop_lnki_lxr_end Instance = new Xop_lnki_lxr_end();
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.xtns.pfuncs.ttls.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.lnkis.*; import gplx.xowa.xtns.pfuncs.ttls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xop_lnki_tkn extends Xop_tkn_itm_base {
|
||||
@Override public byte Tkn_tid() {return tkn_tid;} private byte tkn_tid = Xop_tkn_itm_.Tid_lnki;
|
||||
|
||||
@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.xowa.xtns.relatedSites.*;
|
||||
import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.miscs.*;
|
||||
public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
private Arg_bldr arg_bldr = Arg_bldr._;
|
||||
private Arg_bldr arg_bldr = Arg_bldr.Instance;
|
||||
private Number_parser number_parser = new Number_parser();
|
||||
private Sites_regy_mgr sites_regy_mgr;
|
||||
public void Ctor_ctx(Xop_ctx ctx) {}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.xowa.xtns.relatedSites.*;
|
||||
import gplx.xowa.parsers.tmpls.*; import gplx.xowa.parsers.lnkis.redlinks.*;
|
||||
public class Xop_lnki_wkr_ {
|
||||
@@ -77,7 +77,7 @@ public class Xop_lnki_wkr_ {
|
||||
if (ttl_in_xwiki == null) return ttl; // occurs if ttl is bad in xwiki; EX: [[en:<bad>]]
|
||||
return ttl_in_xwiki.Ns().Id_file() ? ttl_in_xwiki : ttl;
|
||||
}
|
||||
public static int Chk_for_tail(Xol_lang lang, byte[] src, int cur_pos, int src_len, Xop_lnki_tkn lnki) {
|
||||
public static int Chk_for_tail(Xol_lang_itm lang, byte[] src, int cur_pos, int src_len, Xop_lnki_tkn lnki) {
|
||||
int bgn_pos = cur_pos;
|
||||
Btrie_slim_mgr lnki_trail = lang.Lnki_trail_mgr().Trie();
|
||||
while (true) { // loop b/c there can be multiple consecutive lnki_trail_chars; EX: [[A]]bcde
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*; import gplx.xowa.langs.funcs.*; import gplx.xowa.langs.lnki_trails.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.paras.*; import gplx.xowa.wikis.ttls.*;
|
||||
public class Xop_lnki_wkr__basic_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
|
||||
@@ -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.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import org.junit.*; import gplx.xowa.nss.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.nss.*;
|
||||
public class Xop_lnki_wkr__subpage_tst {
|
||||
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Disabled() { // PURPOSE: slash being interpreted as subpage; PAGE:en.w:[[/dev/null]]
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xop_lnki_wkr__uncommon_tst {
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|upright=1.333333333333333333333333333333333333333333333333333333333333333333333]]", " width=\"0\" height=\"0\""); // failure would print out original lnki
|
||||
}
|
||||
@Test public void Persian() { // PURPOSE: handle il8n nums; EX:[[پرونده:Shahbazi 3.jpg|۲۰۰px]] -> 200px; PAGE:fa.w:فهرست_آثار_علیرضا_شاپور_شهبازی; DATE:2015-07-18
|
||||
Xol_lang lang = fxt.Wiki().Lang();
|
||||
Xol_lang_itm lang = fxt.Wiki().Lang();
|
||||
fxt.App().Gfs_mgr().Run_str_for(lang, gplx.xowa.xtns.pfuncs.numbers.Pf_formatnum_fa_tst.Persian_numbers_gfs);
|
||||
lang.Evt_lang_changed(); // force rebuild of size_trie
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|۲۰۰px]]", " width=\"200\" height=\"0\"");
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xop_lnki_wkr__xwiki_tst {
|
||||
}
|
||||
@Test public void Xwiki_not_registered() {
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Clear();
|
||||
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("test"), Bry_.new_a7("test.wikimedia.org")); // register alias only, but not in user_wiki
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("test"), Bry_.new_a7("test.wikimedia.org")); // register alias only, but not in user_wiki
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[test:A|A]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"https://test.wikimedia.org/wiki/A\">A</a>"
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoc_xwiki_repo_mgr implements GfoInvkAble {
|
||||
private Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
private Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private Xowe_wiki wiki;
|
||||
public Xoc_xwiki_repo_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public boolean Has(byte[] abrv) {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.parsers.lnkis.redlinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*; import gplx.xowa.html.hdumps.core.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.htmls.hdumps.core.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
private Xog_win_itm win; private Xog_html_itm html_itm; private Xowe_wiki wiki; private Xoae_page page;
|
||||
@@ -29,7 +29,7 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
this.redlink_lnki_list = page.Redlink_lnki_list();
|
||||
this.lnki_list = redlink_lnki_list.Lnki_list();
|
||||
this.thread_id = redlink_lnki_list.Thread_id();
|
||||
this.log_enabled = log_enabled; this.usr_dlg = log_enabled ? Gfo_usr_dlg_.I : Gfo_usr_dlg_.Noop;
|
||||
this.log_enabled = log_enabled; this.usr_dlg = log_enabled ? Gfo_usr_dlg_.Instance : Gfo_usr_dlg_.Noop;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_run)) Redlink();
|
||||
@@ -40,7 +40,7 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
synchronized (this) { // NOTE: attempt to eliminate random IndexBounds errors; DATE:2014-09-02
|
||||
if (redlink_lnki_list.Disabled()) return;
|
||||
List_adp work_list = List_adp_.new_();
|
||||
Ordered_hash page_hash = Ordered_hash_.new_bry_();
|
||||
Ordered_hash page_hash = Ordered_hash_.New_bry();
|
||||
page_hash.Clear(); // NOTE: do not clear in Page_bgn, else will fail b/c of threading; EX: Open Page -> Preview -> Save; DATE:2013-11-17
|
||||
work_list.Clear();
|
||||
int len = lnki_list.Count();
|
||||
@@ -79,7 +79,7 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
Xowd_page_itm db_page = (Xowd_page_itm)page_hash.Get_by(full_db);
|
||||
if (db_page == null) continue; // pages shouldn't be null, but just in case
|
||||
if (!db_page.Exists()) {
|
||||
String lnki_id = Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.Xto_str(lnki.Html_uid());
|
||||
String lnki_id = Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(lnki.Html_uid());
|
||||
if (variants_enabled) {
|
||||
Xowd_page_itm vnt_page = vnt_mgr.Convert_mgr().Convert_ttl(wiki, lnki.Ttl());
|
||||
if (vnt_page != null) {
|
||||
@@ -97,13 +97,13 @@ public class Xog_redlink_mgr implements GfoInvkAble {
|
||||
if (win.Usr_dlg().Canceled()) return;
|
||||
if (redlink_lnki_list.Thread_id() != thread_id) return;
|
||||
int uid = lnki.Html_uid();
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.Xto_str(uid));
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(uid));
|
||||
redlink_mgr.Add(uid);
|
||||
++redlink_count;
|
||||
}
|
||||
}
|
||||
if (log_enabled)
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0} links=~{1}", redlink_count, bfr == null ? String_.Empty : bfr.Xto_str_and_clear());
|
||||
usr_dlg.Log_many("", "", "redlink.redlink_end: redlinks_run=~{0} links=~{1}", redlink_count, bfr == null ? String_.Empty : bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
public static final Xog_redlink_mgr Null = new Xog_redlink_mgr(); Xog_redlink_mgr() {}
|
||||
@@ -118,6 +118,6 @@ class Xog_redlink_wkr {
|
||||
}
|
||||
}
|
||||
public static void Redlink(Xog_html_itm html_itm, int uid) {
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.Xto_str(uid));
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xopg_redlink_lnki_list.Lnki_id_prefix + Int_.To_str(uid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.parsers.lnkis.redlinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.nss.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.users.*;
|
||||
public class Xopg_redlink_lnki_list {
|
||||
private int lnki_idx = gplx.xowa.html.lnkis.Xoh_lnki_wtr.Lnki_id_min; // NOTE: default to 1, not 0, b/c 0 is ignored by wtr; DATE:2014-10-09
|
||||
private int lnki_idx = gplx.xowa.htmls.lnkis.Xoh_lnki_wtr.Lnki_id_min; // NOTE: default to 1, not 0, b/c 0 is ignored by wtr; DATE:2014-10-09
|
||||
public Xopg_redlink_lnki_list(boolean ttl_is_module) { // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
this.disabled = ttl_is_module;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user