mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.3.4.1'
This commit is contained in:
@@ -30,7 +30,7 @@ public class Xop_link_parser {
|
||||
switch (tmp_url.Protocol_tid()) {
|
||||
case Gfo_protocol_itm.Tid_http: case Gfo_protocol_itm.Tid_https: // "http:" or "https:"; check if to offline wiki and redirect
|
||||
byte[] wiki_bry = tmp_url.Wiki_bry(), page_bry = tmp_url.Page_bry();
|
||||
if ( !tmp_url.Wiki_is_missing() // https://www.a.org and others will be marked "missing" by Xoa_url_parser
|
||||
if ( !tmp_url.Wiki_is_missing() // https://www.a.org and others will be marked "missing" by Xow_url_parser
|
||||
&&( Bry_.Eq(wiki_bry, wiki.Domain_bry()) // link is to this wiki; check if alias
|
||||
|| app.Xwiki_mgr__exists(wiki_bry) // link is to an xwiki
|
||||
)
|
||||
|
||||
@@ -129,7 +129,7 @@ public class Xop_lnki_arg_parser {
|
||||
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);
|
||||
Keyval kv = digit_mgr.Get_at(i);
|
||||
int num = (byte)Int_.parse_or(kv.Key(), -1); if (num == -1) continue; // ignore separators; EX: "," "."
|
||||
size_trie.Add((byte[])kv.Val(), Byte_obj_val.new_((byte)num)); // NOTE: num corresponds to dim_d0 -> d9 below
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class Xop_lnki_arg_parser {
|
||||
px_trie.Add(word_bry, Byte_obj_val.new_(Tid_dim));
|
||||
}
|
||||
}
|
||||
public static final byte[] Bry_upright = Bry_.new_a7("upright"), Bry_thumbtime = Bry_.new_a7("thumbtime");
|
||||
public static final byte[] Bry_upright = Bry_.new_a7("upright"), Bry_thumbtime = Bry_.new_a7("thumbtime"), Bry_target = Bry_.new_a7("target");
|
||||
public static final byte
|
||||
Tid_unknown = 0, Tid_thumb = 1, Tid_left = 2, Tid_right = 3, Tid_none = 4, Tid_center = 5, Tid_frame = 6, Tid_frameless = 7, Tid_upright = 8, Tid_border = 9
|
||||
, Tid_alt = 10, Tid_link = 11, Tid_baseline = 12, Tid_sub = 13, Tid_super = 14, Tid_top = 15, Tid_text_top = 16, Tid_middle = 17, Tid_bottom = 18, Tid_text_bottom = 19
|
||||
@@ -153,6 +153,7 @@ public class Xop_lnki_arg_parser {
|
||||
, Tid_page = 23
|
||||
, Tid_noplayer = 24, Tid_noicon = 25, Tid_thumbtime = 26
|
||||
, Tid_class = 27
|
||||
, Tid_target = 28
|
||||
;
|
||||
private static final byte[] X_bry = Bry_.new_a7("x");
|
||||
private static final byte // NOTE: d0 - d9 must match 0 - 9; DATE:2015-07-18
|
||||
|
||||
@@ -51,9 +51,10 @@ public class Xop_lnki_tkn extends Xop_tkn_itm_base {
|
||||
public boolean Pipe_count_is_zero() {return pipe_count++ == 0;}
|
||||
public boolean Xtn_sites_link() {return xtn_sites_link;} public void Xtn_sites_link_(boolean v) {xtn_sites_link = v;} private boolean xtn_sites_link;
|
||||
public Xoh_file_img_wkr Lnki_file_wkr() {return lnki_file_wkr;} public void Lnki_file_wkr_(Xoh_file_img_wkr v) {lnki_file_wkr = v;} private Xoh_file_img_wkr lnki_file_wkr;
|
||||
public byte[] Target;
|
||||
public byte[] Ttl_ary() {
|
||||
return ttl.ForceLiteralLink() || ns_id != Xow_ns_.Tid__main // if [[:]] or non-main (Category, Template)
|
||||
? ttl.Full_txt() // use full_txt (no initial colon; capitalize first)
|
||||
? ttl.Full_txt_w_ttl_case() // use full_txt (no initial colon; capitalize first)
|
||||
: ttl.Raw(); // use raw (preserve case, white-spaces)
|
||||
}
|
||||
public boolean Caption_exists() {
|
||||
|
||||
@@ -98,6 +98,10 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
int bgn = arg.Val_tkn().Dat_bgn(), end = arg.Val_tkn().Dat_end();
|
||||
if (arg.KeyTkn_exists()) {bgn = arg.Key_tkn().Dat_bgn(); end = arg.Key_tkn().Dat_end();}
|
||||
arg_tid = ctx.Wiki().Lang().Lnki_arg_parser().Identify_tid(src, bgn, end, lnki);
|
||||
if (arg_tid == Xop_lnki_arg_parser.Tid_caption && ctx.Wiki().Domain_itm().Domain_type_id() == gplx.xowa.wikis.domains.Xow_domain_tid_.Int__other) {
|
||||
if (end > bgn && Bry_.Eq(src, bgn, end, Xop_lnki_arg_parser.Bry_target))
|
||||
arg_tid = Xop_lnki_arg_parser.Tid_target;
|
||||
}
|
||||
switch (arg_tid) {
|
||||
case Xop_lnki_arg_parser.Tid_none: lnki.Align_h_(Xop_lnki_type.Id_none); break;
|
||||
case Xop_lnki_arg_parser.Tid_border: lnki.Border_(Bool_.Y_byte); break;
|
||||
@@ -116,6 +120,7 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
|
||||
case Xop_lnki_arg_parser.Tid_text_bottom: lnki.Align_v_(Xop_lnki_align_v_.TextBottom); break;
|
||||
case Xop_lnki_arg_parser.Tid_baseline: lnki.Align_v_(Xop_lnki_align_v_.Baseline); break;
|
||||
case Xop_lnki_arg_parser.Tid_class: lnki.Lnki_cls_(Xop_lnki_wkr_.Val_extract(src, arg)); break;
|
||||
case Xop_lnki_arg_parser.Tid_target: lnki.Target = Xop_lnki_wkr_.Val_extract(src, arg); break;
|
||||
case Xop_lnki_arg_parser.Tid_alt: lnki.Alt_tkn_(arg);
|
||||
lnki.Alt_tkn().Tkn_ini_pos(false, arg.Src_bgn(), arg.Src_end());
|
||||
break;
|
||||
|
||||
@@ -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
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "simple.wikipedia.org");
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(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
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "species.wikimedia.org");
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(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
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "simple.wiktionary.org");
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(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
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "species.wikimedia.org");
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(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