mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.2.4.1
This commit is contained in:
@@ -35,7 +35,7 @@ public class Xop_lnki_arg_parser {
|
||||
if (Env_.Mode_testing())
|
||||
continue; // TEST: allows partial parsing of $magicWords
|
||||
else
|
||||
list = lang.App().Lang_mgr().Lang_en().Kwd_mgr().Get_at(val[0]);
|
||||
list = lang.Lang_mgr().Lang_en().Kwd_mgr().Get_at(val[0]);
|
||||
}
|
||||
Xol_kwd_itm[] words = list.Itms();
|
||||
int words_len = words.length;
|
||||
@@ -47,7 +47,7 @@ public class Xop_lnki_arg_parser {
|
||||
}
|
||||
list = mgr.Get_at(Xol_kwd_grp_.Id_img_width);
|
||||
if (list == null)
|
||||
list = lang.App().Lang_mgr().Lang_en().Kwd_mgr().Get_at(Xol_kwd_grp_.Id_img_width);
|
||||
list = lang.Lang_mgr().Lang_en().Kwd_mgr().Get_at(Xol_kwd_grp_.Id_img_width);
|
||||
Init_size_trie(tmp_bfr, list);
|
||||
}
|
||||
public byte Identify_tid(byte[] src, int bgn, int end, Xop_lnki_tkn lnki) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import gplx.core.btries.*;
|
||||
class Xop_lnki_lxr_bgn implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_lnki_bgn;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_bgn, this);}
|
||||
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 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();
|
||||
@@ -39,7 +39,7 @@ class Xop_lnki_lxr_bgn implements Xop_lxr {
|
||||
}
|
||||
class Xop_lnki_lxr_end implements Xop_lxr {
|
||||
public byte Lxr_tid() {return Xop_lxr_.Tid_lnki_end;}
|
||||
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_end, this);}
|
||||
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 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();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
sites_regy_mgr = ctx.Wiki().Xtn_mgr().Xtn_sites().Regy_mgr(); if (!sites_regy_mgr.Xtn_mgr().Enabled()) sites_regy_mgr = null; // sets sites_xtn_mgr status for page; see below
|
||||
}
|
||||
public void Page_end(Xop_ctx ctx, Xop_root_tkn root, byte[] src, int src_len) {}
|
||||
public Xop_lnki_logger File_wkr() {return file_wkr;} public Xop_lnki_wkr File_wkr_(Xop_lnki_logger v) {file_wkr = v; return this;} private Xop_lnki_logger file_wkr;
|
||||
public Xopg_redlink_logger File_wkr() {return file_wkr;} public Xop_lnki_wkr File_wkr_(Xopg_redlink_logger v) {file_wkr = v; return this;} private Xopg_redlink_logger file_wkr;
|
||||
public void Auto_close(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 tkn) {
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)tkn;
|
||||
lnki.Tkn_tid_to_txt();
|
||||
@@ -151,10 +151,12 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
case Xop_lnki_arg_parser.Tid_dim: break;// NOOP: Identify_tid does actual setting
|
||||
case Xop_lnki_arg_parser.Tid_upright:
|
||||
if (arg.KeyTkn_exists()) {
|
||||
int valTknBgn = arg.Val_tkn().Src_bgn(), valTknEnd = arg.Val_tkn().Src_end();
|
||||
number_parser.Parse(src, valTknBgn, valTknEnd);
|
||||
int val_tkn_bgn = arg.Val_tkn().Src_bgn(), val_tkn_end = arg.Val_tkn().Src_end();
|
||||
val_tkn_bgn = Bry_finder.Find_fwd_while_space_or_tab(src, val_tkn_bgn, val_tkn_end); // trim ws at bgn; needed for next step
|
||||
if (val_tkn_end - val_tkn_bgn > 19) val_tkn_end = val_tkn_bgn + 19; // HACK: limit upright tkn to 19 digits; 20 or more will overflow long; WHEN: rewrite number_parser to handle doubles; PAGE:de.w:Feuerland DATE:2015-02-03
|
||||
number_parser.Parse(src, val_tkn_bgn, val_tkn_end);
|
||||
if (number_parser.HasErr())
|
||||
ctx.Msg_log().Add_itm_none(Xop_lnki_log.Upright_val_is_invalid, src, valTknBgn, valTknEnd);
|
||||
ctx.Msg_log().Add_itm_none(Xop_lnki_log.Upright_val_is_invalid, src, val_tkn_bgn, val_tkn_end);
|
||||
else
|
||||
lnki.Upright_(number_parser.AsDec().Xto_double());
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ public class Xop_lnki_wkr_ {
|
||||
return Parse_ttl(ctx, src, lnki, ttl_bgn, ttl_end);
|
||||
}
|
||||
public static boolean Parse_ttl(Xop_ctx ctx, byte[] src, Xop_lnki_tkn lnki, int ttl_bgn, int ttl_end) {
|
||||
Xoa_app app = ctx.App();
|
||||
Xoae_app app = ctx.App();
|
||||
byte[] ttl_bry = Bry_.Mid(src, ttl_bgn, ttl_end);
|
||||
ttl_bry = app.Encoder_mgr().Url_ttl().Decode(ttl_bry);
|
||||
ttl_bry = Xoa_app_.Utl_encoder_mgr().Url_ttl().Decode(ttl_bry);
|
||||
int ttl_bry_len = ttl_bry.length;
|
||||
Xoa_ttl page_ttl = ctx.Cur_page().Ttl();
|
||||
if (page_ttl.Ns().Subpages_enabled()
|
||||
@@ -52,7 +52,7 @@ public class Xop_lnki_wkr_ {
|
||||
ttl_bry = new_bry;
|
||||
tmp_bfr.Mkr_rls();
|
||||
}
|
||||
Xow_wiki wiki = ctx.Wiki();
|
||||
Xowe_wiki wiki = ctx.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry);
|
||||
if (ttl == null) return false;
|
||||
if ( wiki.Cfg_parser_lnki_xwiki_repos_enabled() // wiki has lnki.xwiki_repos
|
||||
@@ -63,7 +63,7 @@ public class Xop_lnki_wkr_ {
|
||||
lnki.Ns_id_(ttl.Ns().Id());
|
||||
return true;
|
||||
}
|
||||
private static Xoa_ttl Adj_ttl_for_file(Xow_wiki wiki, Xop_ctx ctx, Xoa_ttl ttl, byte[] ttl_bry) { // NOTE: remove the xwiki part; EX: [[en:File:A.png]] -> [[File:A.png]]
|
||||
private static Xoa_ttl Adj_ttl_for_file(Xowe_wiki wiki, Xop_ctx ctx, Xoa_ttl ttl, byte[] ttl_bry) { // NOTE: remove the xwiki part; EX: [[en:File:A.png]] -> [[File:A.png]]
|
||||
byte[] xwiki_bry = ttl.Wik_txt(); if (xwiki_bry == null) return ttl; // should not happen, but just in case
|
||||
int xwiki_bry_len = xwiki_bry.length;
|
||||
int ttl_bry_len = ttl_bry.length;
|
||||
|
||||
@@ -339,9 +339,9 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
fxt.Test_parse_page_wiki("[[File:A.pdf|page=12]]" , fxt.tkn_lnki_().Page_(12));
|
||||
}
|
||||
@Test public void Visited() { // PURPOSE: show redirected titles as visited; EX:fr.w:Alpes_Pennines; DATE:2014-02-28
|
||||
Xow_wiki wiki = fxt.Wiki();
|
||||
Xowe_wiki wiki = fxt.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_ascii_("Src")); // simulate requrest for "Src" page
|
||||
Xoa_page previous_page = Xoa_page.test_(wiki, ttl);
|
||||
Xoae_page previous_page = Xoae_page.test_(wiki, ttl);
|
||||
previous_page.Redirected_ttls().Add(Bry_.new_ascii_("Src")); // simulate redirect from "Src"
|
||||
fxt.App().User().History_mgr().Add(previous_page); // simulate "Src" already being clicked once; this is the key call
|
||||
fxt.Wtr_cfg().Lnki_visited_(true);
|
||||
|
||||
@@ -50,5 +50,8 @@ public class Xop_lnki_wkr__uncommon_tst {
|
||||
@Test public void Large_size() { // PURPOSE: size larger than int should be discard, not be Int_.MaxValue: PAGE:id.w:Baho; DATE:2014-06-10
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|9999999999x30px]]", " width=\"0\" height=\"30\""); // width should not be Int_.MaxValue
|
||||
}
|
||||
@Test public void Upright_is_large() { // PURPOSE: handle large upright which overflows int; PAGE:de.w:Feuerland DATE:2015-02-03
|
||||
fxt.Test_html_wiki_frag("[[File:A.png|upright=1.333333333333333333333333333333333333333333333333333333333333333333333]]", " width=\"0\" height=\"0\""); // failure would print out original lnki
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public class Xop_lnki_wkr__xwiki_tst {
|
||||
Tfds.Eq(0, fxt.Page().Slink_list().Count());
|
||||
}
|
||||
@Test public void Simple_and_english() { // PURPOSE: s.w xwiki links to en were not working b/c s.w and en had same super lang of English; PAGE:s.q:Anonymous DATE:2014-09-10
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
Xow_wiki wiki = Xoa_app_fxt.wiki_(app, "simple.wikipedia.org");
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "simple.wikipedia.org");
|
||||
fxt = new Xop_fxt(app, wiki); // change fxt to simple.wikipedia.org
|
||||
Reg_xwiki_alias("en", "en.wikipedia.org"); // register "en" alias
|
||||
fxt.Test_parse_page_wiki_str // test nothing printed
|
||||
@@ -77,8 +77,8 @@ public class Xop_lnki_wkr__xwiki_tst {
|
||||
Tfds.Eq(1, fxt.Page().Slink_list().Count()); // test 1 xwiki lang
|
||||
}
|
||||
@Test public void Species_and_commons() { // PURPOSE: species xwiki links to commons should not put link in wikidata langs; PAGE:species:Scarabaeidae DATE:2014-09-10
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
Xow_wiki wiki = Xoa_app_fxt.wiki_(app, "species.wikimedia.org");
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "species.wikimedia.org");
|
||||
fxt = new Xop_fxt(app, wiki); // change fxt to species.wikimedia.org
|
||||
Reg_xwiki_alias("commons", "commons.wikimedia.org"); // register "en" alias
|
||||
fxt.Test_parse_page_wiki_str // test something printed
|
||||
@@ -88,8 +88,8 @@ public class Xop_lnki_wkr__xwiki_tst {
|
||||
Tfds.Eq(0, fxt.Page().Slink_list().Count()); // no xwiki langs
|
||||
}
|
||||
@Test public void Wiktionary_and_wikipedia() { // PURPOSE: do not create xwiki links if same lang and differet type; PAGE:s.d:water DATE:2014-09-14
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
Xow_wiki wiki = Xoa_app_fxt.wiki_(app, "simple.wiktionary.org");
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "simple.wiktionary.org");
|
||||
fxt = new Xop_fxt(app, wiki); // change fxt to simple.wiktionary.org
|
||||
Reg_xwiki_alias("w", "simple.wikipedia.org"); // register "w" alias
|
||||
fxt.Test_parse_page_wiki_str // test something printed
|
||||
@@ -99,8 +99,8 @@ public class Xop_lnki_wkr__xwiki_tst {
|
||||
Tfds.Eq(0, fxt.Page().Slink_list().Count()); // test 0 xwiki lang
|
||||
}
|
||||
@Test public void Species_and_wikipedia() { // PURPOSE: species creates xwiki links to wikipedia; PAGE:species:Puccinia DATE:2014-09-14
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
Xow_wiki wiki = Xoa_app_fxt.wiki_(app, "species.wikimedia.org");
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "species.wikimedia.org");
|
||||
fxt = new Xop_fxt(app, wiki); // change fxt to species.wikimedia.org
|
||||
Reg_xwiki_alias("fr", "fr.wikipedia.org"); // register "fr" alias
|
||||
fxt.Test_parse_page_wiki_str // nothing printed
|
||||
|
||||
Reference in New Issue
Block a user