1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2016-01-17 23:18:07 -05:00
parent 096045614c
commit 235228976e
314 changed files with 4458 additions and 2694 deletions

View File

@@ -61,8 +61,8 @@ public class Xop_link_parser {
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]]
raw = or;
if (Bry_.Len_eq_0(raw)) // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; [[File:Loudspeaker.svg|11px|link=|alt=play]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10;
raw = Bry_.Empty;
else {
if (raw[0] == Byte_ascii.Colon) raw = Bry_.Mid(raw, 1, raw.length); // ignore initial colon; EX: [[:commons:A.png]]
if (!Parse__ttl(tmp_bfr, wiki, wiki.Domain_bry(), raw)) {
@@ -76,7 +76,7 @@ public class Xop_link_parser {
return raw;
}
private static boolean Parse__ttl(Bry_bfr tmp_bfr, Xowe_wiki wiki, byte[] wiki_bry, byte[] page_bry) {
Xoa_ttl page_ttl = Xoa_ttl.parse(wiki, page_bry);
Xoa_ttl page_ttl = wiki.Ttl_parse(page_bry);
boolean page_ttl_is_valid = page_ttl != null;
if (page_ttl_is_valid) {
Xow_xwiki_itm xwiki_itm = page_ttl.Wik_itm();
@@ -87,8 +87,13 @@ public class Xop_link_parser {
else // is regular page; use ttl.Full_db() to normalize; EX:   -> _
page_bry = page_ttl.Full_db_w_anch(); // add anch; PAGE:en.w:History_of_Nauru; DATE:2015-12-27
}
if (Bry_.Eq(wiki_bry, wiki.Domain_bry())) // NOTE: check against wiki.Key_bry() again; EX: in en_wiki, and http://commons.wikimedia.org/wiki/w:A
if (Bry_.Eq(wiki_bry, wiki.Domain_bry())) { // NOTE: check against wiki.Key_bry() again; EX: in en_wiki, and http://commons.wikimedia.org/wiki/w:A
if (page_ttl_is_valid) { // same wiki; parse in same ns to title-case; EX:link=w:Help:a -> Help:A; NOTE: must check for page_ttl_is_valid; DATE:2016-01-11
page_ttl = wiki.Ttl_parse(page_ttl.Full_db_wo_xwiki());
page_bry = page_ttl.Full_db_w_anch();
}
tmp_bfr.Add(Xoh_href_.Bry__wiki).Add(page_bry);
}
else
tmp_bfr.Add(Xoh_href_.Bry__site).Add(wiki_bry).Add(Xoh_href_.Bry__wiki).Add(page_bry);
return page_ttl_is_valid;

View File

@@ -29,7 +29,7 @@ public class Xop_lnki_wkr__link_tst {
@Test public void Link_blank() {
fxt.Test_parse_page_wiki_str
( "[[File:A.png|12x10px|link=|c]]", String_.Concat_lines_nl_skip_last
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"c\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" /></a>"
( "<img id=\"xoimg_0\" alt=\"c\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" />"
));
}
@Test public void Link_external() {