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,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.net.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*;
|
||||
import gplx.xowa.urls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
public class Xoh_lnke_wtr {
|
||||
// private Xoae_app app;
|
||||
public Xoh_lnke_wtr(Xowe_wiki wiki) {}// this.app = wiki.Appe();}
|
||||
|
||||
@@ -20,8 +20,8 @@ import gplx.core.btries.*; import gplx.xowa.langs.*;
|
||||
public class Xop_lnke_end_lxr implements Xop_lxr {
|
||||
public int Lxr_tid() {return Xop_lxr_.Tid_lnke_end;}
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Byte_ascii.Brack_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.Lnke().MakeTkn_end(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
|
||||
public static final Xop_lnke_end_lxr _ = new Xop_lnke_end_lxr(); Xop_lnke_end_lxr() {}
|
||||
public static final Xop_lnke_end_lxr Instance = new Xop_lnke_end_lxr(); Xop_lnke_end_lxr() {}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ public class Xop_lnke_lxr implements Xop_lxr {
|
||||
Gfo_protocol_itm itm = ary[i];
|
||||
Ctor_lxr_add(core_trie, itm.Key_w_colon_bry(), itm.Tid());
|
||||
}
|
||||
core_trie.Add(Bry_relative_1, new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_brack, Xoa_consts.Url_relative_prefix, Gfo_protocol_itm.Tid_relative_1));
|
||||
core_trie.Add(Bry_relative_2, new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_brack, Xoa_consts.Url_relative_prefix, Gfo_protocol_itm.Tid_relative_2));
|
||||
core_trie.Add(Bry_relative_1, new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_brack, Gfo_protocol_itm.Bry_relative, Gfo_protocol_itm.Tid_relative_1));
|
||||
core_trie.Add(Bry_relative_2, new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_brack, Gfo_protocol_itm.Bry_relative, Gfo_protocol_itm.Tid_relative_2));
|
||||
Ctor_lxr_add(core_trie, Bry_.new_a7("xowa-cmd"), Gfo_protocol_itm.Tid_xowa);
|
||||
} private static final byte[] Bry_relative_1 = Bry_.new_a7("[//"), Bry_relative_2 = Bry_.new_a7("[[//");
|
||||
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) {}
|
||||
private void Ctor_lxr_add(Btrie_fast_mgr core_trie, byte[] protocol_bry, byte tid) {
|
||||
core_trie.Add(protocol_bry , new Xop_lnke_lxr(Xop_lnke_tkn.Lnke_typ_text, protocol_bry, tid));
|
||||
@@ -42,5 +42,5 @@ public class Xop_lnke_lxr implements Xop_lxr {
|
||||
if (this.tid == Gfo_protocol_itm.Tid_xowa && !ctx.Wiki().Sys_cfg().Xowa_proto_enabled()) return ctx.Lxr_make_txt_(cur_pos);
|
||||
return ctx.Lnke().MakeTkn_bgn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos, protocol, tid, lnke_typ);
|
||||
}
|
||||
public static final Xop_lnke_lxr _ = new Xop_lnke_lxr(); Xop_lnke_lxr() {}
|
||||
public static final Xop_lnke_lxr Instance = new Xop_lnke_lxr(); Xop_lnke_lxr() {}
|
||||
}
|
||||
|
||||
@@ -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.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.net.*; import gplx.xowa.urls.*;
|
||||
import gplx.core.net.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.xowa.apps.progs.*; import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
public void Ctor_ctx(Xop_ctx ctx) {url_parser = ctx.Wiki().Utl__url_parser().Url_parser();} Gfo_url_parser url_parser; Gfo_url_site_data site_data = new Gfo_url_site_data();
|
||||
@@ -288,7 +288,7 @@ public class Xop_lnke_wkr implements Xop_ctx_wkr {
|
||||
byte[] rhs_dlm_bry = Bry_quote;
|
||||
if (lhs_dlm_pos - proto_end_pos > 0) {
|
||||
Bry_bfr bfr = ctx.App().Utl__bfr_mkr().Get_k004();
|
||||
rhs_dlm_bry = bfr.Add(Bry_quote).Add_mid(src, proto_end_pos, lhs_dlm_pos).Xto_bry_and_clear();
|
||||
rhs_dlm_bry = bfr.Add(Bry_quote).Add_mid(src, proto_end_pos, lhs_dlm_pos).To_bry_and_clear();
|
||||
bfr.Mkr_rls();
|
||||
}
|
||||
int rhs_dlm_pos = Bry_find_.Find_fwd(src, rhs_dlm_bry, lnke_bgn_pos, src_len); if (rhs_dlm_pos == Bry_.NotFound) return ctx.Lxr_make_txt_(cur_pos);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Xop_lnke_wkr_brack_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Encode_xwiki() { // PURPOSE: href title and args should always be encoded; PAGE:en.w:List_of_Category_A_listed_buildings_in_West_Lothian DATE:2014-07-15
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("commons.wikimedia.org"), Bry_.new_a7("commons.wikimedia.org"));
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("commons.wikimedia.org"), Bry_.new_a7("commons.wikimedia.org"));
|
||||
fxt.Test_parse_page_wiki_str // encode page
|
||||
( "[http://commons.wikimedia.org/%22%3E_A B]"
|
||||
, "<a href=\"/site/commons.wikimedia.org/wiki/%22%3E_A\">B</a>" // '%22%3E' not '">'
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xop_lnke_wkr_relative_tst {
|
||||
fxt.Test_parse_page_wiki_str("[//en.wikipedia.org/wiki/Category:A A]", "<a href=\"/site/en.wikipedia.org/wiki/Category:A\">A</a>");
|
||||
}
|
||||
@Test public void Relurl() {
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full(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_page_wiki_str("[[//en.wikipedia.org/ a]]", "[<a href=\"/site/en.wikipedia.org/wiki/\">a</a>]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ import org.junit.*;
|
||||
public class Xop_lnke_wkr_xwiki_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Xwiki() {
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full(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_page_wiki_str("[http://en.wikipedia.org/wiki/A a]", "<a href=\"/site/en.wikipedia.org/wiki/A\">a</a>");
|
||||
}
|
||||
@Test public void Xwiki_relative() {
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full(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_page_wiki_str("[//en.wikipedia.org/ a]", "<a href=\"/site/en.wikipedia.org/wiki/\">a</a>");
|
||||
}
|
||||
@Test public void Xwiki_qarg() {// DATE:2013-02-02
|
||||
@@ -32,12 +32,12 @@ public class Xop_lnke_wkr_xwiki_tst {
|
||||
fxt.Test_parse_page_wiki_str("http://en.wikipedia.org/wiki/Special:Allpages?from=Earth", "<a href=\"/site/en.wikipedia.org/wiki/Special:Allpages?from=Earth\">http://en.wikipedia.org/wiki/Special:Allpages?from=Earth</a>");
|
||||
}
|
||||
@Test public void Lang_prefix() {
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org"));
|
||||
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("fr"), Bry_.new_a7("fr.wikipedia.org"));
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("en.wikipedia.org"), Bry_.new_a7("en.wikipedia.org"));
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("fr"), Bry_.new_a7("fr.wikipedia.org"));
|
||||
fxt.Test_parse_page_wiki_str("[http://en.wikipedia.org/wiki/fr:A a]", "<a href=\"/site/fr.wikipedia.org/wiki/A\">a</a>");
|
||||
}
|
||||
@Test public void Xwiki_query_arg() {
|
||||
fxt.App().Usere().Wiki().Xwiki_mgr().Add_full(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_page_wiki_str("[http://en.wikipedia.org/wiki/A?action=edit a]", "<a href=\"/site/en.wikipedia.org/wiki/A?action=edit\">a</a>");
|
||||
}
|
||||
@Test public void Ignore_proto() { // PURPOSE: handle other protocols; PAGE:uk.w:Маскалі; DATE:2015-07-28
|
||||
|
||||
Reference in New Issue
Block a user