Parser.Lnke: Handle xwiki links to history pages

v3.3.4
gnosygnu 8 years ago
parent 468b9b6ed5
commit e0ee9a952d

@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.apps.urls.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.apps.urls.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.hrefs.*;
public class Xoa_url { public class Xoa_url {
public int Tid() {return tid;} private int tid; public int Tid() {return tid;} public void Tid_(int v) {this.tid = v;} private int tid;
public byte[] Raw() {return raw;} private byte[] raw = Bry_.Empty; public byte[] Raw() {return raw;} private byte[] raw = Bry_.Empty;
public byte[] Orig() {return orig;} private byte[] orig; public byte[] Orig() {return orig;} private byte[] orig;
public byte[] Wiki_bry() {return wiki_bry;} public Xoa_url Wiki_bry_(byte[] v) {wiki_bry = v; return this;} private byte[] wiki_bry; public byte[] Wiki_bry() {return wiki_bry;} public Xoa_url Wiki_bry_(byte[] v) {wiki_bry = v; return this;} private byte[] wiki_bry;

@ -70,6 +70,9 @@ public class Xoh_href_parser {
} }
} }
rv.Page_bry_(tmp_page); rv.Page_bry_(tmp_page);
if (tmp_page == null) { // handle xwiki lnke's to history page else null ref; EX:[http://ru.wikipedia.org/w/index.php?title&diff=19103464&oldid=18910980 ???????]; PAGE:ru.w:Project:??????_??_??????_??????/?????/?????????????/2009 DATE:2016-11-24
rv.Tid_(Xoa_url_.Tid_inet);
}
break; break;
} }
} }

@ -176,6 +176,10 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
byte[] xwiki_wiki = xo_url_parser_url.Wiki_bry(); byte[] xwiki_wiki = xo_url_parser_url.Wiki_bry();
byte[] xwiki_page = xo_url_parser_url.Page_bry(); byte[] xwiki_page = xo_url_parser_url.Page_bry();
if (xwiki_page == null) { // handle xwiki lnke's to history page else null ref; EX:[http://ru.wikipedia.org/w/index.php?title&diff=19103464&oldid=18910980 извещен]; PAGE:ru.w:Project:Заявки_на_снятие_флагов/Архив/Патрулирующие/2009 DATE:2016-11-24
xwiki_page = decoded_src;
}
else {
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, xwiki_page); Xoa_ttl ttl = Xoa_ttl.Parse(wiki, xwiki_page);
if (ttl != null && ttl.Wik_itm() != null) { if (ttl != null && ttl.Wik_itm() != null) {
xwiki_wiki = ttl.Wik_itm().Domain_bry(); xwiki_wiki = ttl.Wik_itm().Domain_bry();
@ -183,6 +187,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
} }
tkn.Lnke_xwiki_(xwiki_wiki, xwiki_page, xo_url_parser_url.Qargs_ary()); tkn.Lnke_xwiki_(xwiki_wiki, xwiki_page, xo_url_parser_url.Qargs_ary());
} }
}
ctx.Subs_add(root, tkn); ctx.Subs_add(root, tkn);
if (lnke_type == Xop_lnke_tkn.Lnke_typ_brack) { if (lnke_type == Xop_lnke_tkn.Lnke_typ_brack) {
if (lnke_end_tid == End_tid_brack) { if (lnke_end_tid == End_tid_brack) {

@ -40,6 +40,10 @@ public class Xop_lnke_wkr_xwiki_tst {
fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org")); fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org"));
fxt.Test__parse__wtxt_to_html("[http://en.wikipedia.org/wiki/A?action=edit a]", "<a href='/site/en.wikipedia.org/wiki/A?action=edit'>a</a>"); fxt.Test__parse__wtxt_to_html("[http://en.wikipedia.org/wiki/A?action=edit a]", "<a href='/site/en.wikipedia.org/wiki/A?action=edit'>a</a>");
} }
@Test public void Xwiki__history() { // PURPOSE: handle xwiki lnke's to history page else null ref; EX:[http://ru.wikipedia.org/w/index.php?title&diff=19103464&oldid=18910980 извещен]; PAGE:ru.w:Project:Заявки_на_снятие_флагов/Архив/Патрулирующие/2009 DATE:2016-11-24
fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org"));
fxt.Test__parse__wtxt_to_html("[http://en.wikipedia.org/w/index.php?title&diff=1&oldid=2 abc]", "<a href='http://en.wikipedia.org/w/index.php?title&diff=1&oldid=2' rel='nofollow' class='external text'>abc</a>");
}
@Test public void Ignore_proto() { // PURPOSE: handle other protocols; PAGE:uk.w:Маскалі; DATE:2015-07-28 @Test public void Ignore_proto() { // PURPOSE: handle other protocols; PAGE:uk.w:Маскалі; DATE:2015-07-28
fxt.Test__parse__wtxt_to_html("[mailto:a b]", "<a href='mailto:a' rel='nofollow' class='external text'>b</a>");// should be /w/, not /en.wikipedia.org fxt.Test__parse__wtxt_to_html("[mailto:a b]", "<a href='mailto:a' rel='nofollow' class='external text'>b</a>");// should be /w/, not /en.wikipedia.org
} }

Loading…
Cancel
Save