mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
uca category support and other changes
This commit is contained in:
@@ -21,10 +21,17 @@ public class Xoapi_addon implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoa_app app) {}
|
||||
public Xoapi_addon_search Search() {return search;} private final Xoapi_addon_search search = new Xoapi_addon_search();
|
||||
public Xoapi_addon_bldr Bldr() {return bldr;} private final Xoapi_addon_bldr bldr = new Xoapi_addon_bldr();
|
||||
public boolean Wikis__ctgs__hidden_enabled() {return wikis__ctgs__hidden_enabled;} private boolean wikis__ctgs__hidden_enabled = false;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__search)) return search;
|
||||
else if (ctx.Match(k, Invk__bldr)) return bldr;
|
||||
else if (ctx.Match(k, Invk__wikis__ctgs__hidden_enabled)) return Yn.To_str(wikis__ctgs__hidden_enabled);
|
||||
else if (ctx.Match(k, Invk__wikis__ctgs__hidden_enabled_)) wikis__ctgs__hidden_enabled = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk__search = "search", Invk__bldr = "bldr";
|
||||
private static final String Invk__search = "search", Invk__bldr = "bldr"
|
||||
, Invk__wikis__ctgs__hidden_enabled = "wikis__ctgs__hidden_enabled"
|
||||
, Invk__wikis__ctgs__hidden_enabled_ = "wikis__ctgs__hidden_enabled_"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -20,13 +20,14 @@ import gplx.xowa.apps.apis.xowa.addons.bldrs.*;
|
||||
public class Xoapi_addon_bldr implements Gfo_invk {
|
||||
public Xoapi_central_api Central() {return central;} private final Xoapi_central_api central = new Xoapi_central_api();
|
||||
public Xoapi_sync_api Sync() {return sync;} private final Xoapi_sync_api sync = new Xoapi_sync_api();
|
||||
public boolean Wikis__ctgs__hidden_enabled() {return wikis__ctgs__hidden_enabled;} private boolean wikis__ctgs__hidden_enabled = false;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__central)) return central;
|
||||
else if (ctx.Match(k, Invk__sync)) return sync;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String
|
||||
Invk__central = "central"
|
||||
, Invk__sync = "sync"
|
||||
Invk__central = "central"
|
||||
, Invk__sync = "sync"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ public class Xoapi_import implements Gfo_invk {
|
||||
public long Html_db_max() {return html_db_max;} private long html_db_max = Io_size_.To_long_by_int_mb(1500); // 3.0 GB; v2; use same as text
|
||||
public long File_db_max() {return file_db_max;} private long file_db_max = Io_size_.To_long_by_int_mb(1500); // 3.2 GB; v2
|
||||
public byte[] Ns_file_map() {return ns_file_map;} private byte[] ns_file_map = Ns_file_map__each;
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private byte zip_tid_text = Io_stream_.Tid_gzip;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private byte zip_tid_html = Io_stream_.Tid_gzip;
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private byte zip_tid_text = Io_stream_tid_.Tid__gzip;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private byte zip_tid_html = Io_stream_tid_.Tid__gzip;
|
||||
public boolean Hzip_enabled() {return hzip_enabled;} private boolean hzip_enabled = Bool_.Y;
|
||||
public boolean Hzip_mode_is_b256() {return hzip_mode_is_b256;} private boolean hzip_mode_is_b256 = Bool_.Y;
|
||||
public String User_name() {return user_name;} private String user_name = "anonymous";
|
||||
@@ -51,7 +51,7 @@ public class Xoapi_import implements Gfo_invk {
|
||||
: gplx.xowa.bldrs.cmds.Xob_ns_file_itm_parser.Ns_file_map__each; // DB.FEW: DATE:2016-06-07
|
||||
// return dump_file_size < layout_text_max ? Bry_.Empty : Ns_file_map__each;
|
||||
}
|
||||
public void Zip_tid_text_raw_() {zip_tid_text = Io_stream_.Tid_raw;} // TEST:
|
||||
public void Zip_tid_text_raw_() {zip_tid_text = Io_stream_tid_.Tid__raw;} // TEST:
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_layout_all_max)) return Io_size_.To_str_mb(layout_all_max);
|
||||
else if (ctx.Match(k, Invk_layout_all_max_)) layout_all_max = Io_size_.To_long_by_msg_mb(m, layout_all_max);
|
||||
@@ -71,11 +71,11 @@ public class Xoapi_import implements Gfo_invk {
|
||||
else if (ctx.Match(k, Invk_file_db_max_)) file_db_max = Io_size_.To_long_by_msg_mb(m, file_db_max);
|
||||
else if (ctx.Match(k, Invk_ns_file_map)) return String_.new_u8(ns_file_map);
|
||||
else if (ctx.Match(k, Invk_ns_file_map_)) ns_file_map = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk_zip_tid_text)) return Io_stream_.To_str(zip_tid_text);
|
||||
else if (ctx.Match(k, Invk_zip_tid_text_)) zip_tid_text = Io_stream_.To_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_zip_tid_text)) return Io_stream_tid_.To_key(zip_tid_text);
|
||||
else if (ctx.Match(k, Invk_zip_tid_text_)) zip_tid_text = Io_stream_tid_.To_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_zip_tid_list)) return Options_zip_tid__list;
|
||||
else if (ctx.Match(k, Invk_zip_tid_html)) return Io_stream_.To_str(zip_tid_html);
|
||||
else if (ctx.Match(k, Invk_zip_tid_html_)) zip_tid_html = Io_stream_.To_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_zip_tid_html)) return Io_stream_tid_.To_key(zip_tid_html);
|
||||
else if (ctx.Match(k, Invk_zip_tid_html_)) zip_tid_html = Io_stream_tid_.To_tid(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_hzip_enabled)) return Yn.To_str(hzip_enabled);
|
||||
else if (ctx.Match(k, Invk_hzip_enabled_)) hzip_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_hzip_mode_is_b256)) return Yn.To_str(hzip_mode_is_b256);
|
||||
@@ -86,7 +86,7 @@ public class Xoapi_import implements Gfo_invk {
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final Keyval[] Options_zip_tid__list = Keyval_.Ary(Keyval_.new_("raw", "text"), Keyval_.new_("gzip"), Keyval_.new_("bzip2"));
|
||||
private static final Keyval[] Options_zip_tid__list = Keyval_.Ary(Keyval_.new_("raw", "text"), Keyval_.new_("gzip"), Keyval_.new_("bzip2"), Keyval_.new_("xz"));
|
||||
private static final String
|
||||
Invk_layout_all_max = "layout_all_max" , Invk_layout_all_max_ = "layout_all_max_"
|
||||
, Invk_layout_text_max = "layout_text_max" , Invk_layout_text_max_ = "layout_text_max_"
|
||||
|
||||
@@ -89,7 +89,7 @@ class Http_server_wkr implements Gfo_invk {
|
||||
// client_wtr.Write_str("Expires: Sun, 17-Jan-2038 19:14:07 GMT\n");
|
||||
String mime_type = String_.new_u8(Http_file_utl.To_mime_type_by_path_as_bry(path));
|
||||
client_wtr.Write_str("Content-Type: " + mime_type + "\n\n");
|
||||
Io_stream_rdr file_stream = Io_stream_rdr_.new_by_url_(Io_url_.new_fil_(String_.new_u8(path))).Open();
|
||||
Io_stream_rdr file_stream = Io_stream_rdr_.New_by_url(Io_url_.new_fil_(String_.new_u8(path))).Open();
|
||||
client_wtr.Write_stream(file_stream);
|
||||
file_stream.Rls(); client_rdr.Rls(); socket.Rls();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*;
|
||||
class Xoa_site_cfg_itm__interwikimap extends Xoa_site_cfg_itm__base {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser(); private final Gfo_url url = new Gfo_url();
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||
public Xoa_site_cfg_itm__interwikimap() {this.Ctor(Xoa_site_cfg_loader__inet.Qarg__interwikimap);}
|
||||
@Override public void Parse_json_ary_itm(Bry_bfr bfr, Xow_wiki wiki, int i, Json_itm itm) {
|
||||
Json_nde nde = Json_nde.cast(itm);
|
||||
@@ -40,7 +40,7 @@ class Xoa_site_cfg_itm__interwikimap extends Xoa_site_cfg_itm__base {
|
||||
byte[] line = lines[i]; if (Bry_.Len_eq_0(line)) continue; // ignore blank lines
|
||||
byte[][] flds = Bry_split_.Split(line, Byte_ascii.Pipe);
|
||||
byte[] url_fmt = flds[1];
|
||||
byte[] domain_bry = Xow_xwiki_mgr.Get_domain_from_url(url_parser, url, url_fmt);
|
||||
byte[] domain_bry = Xow_xwiki_mgr.Get_domain_from_url(url_parser, url_fmt);
|
||||
wiki.Xwiki_mgr().Add_by_atrs(flds[0], domain_bry, url_fmt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ class Xoa_url__to_str__fxt extends Xow_url_parser_fxt { private final Xoh_hr
|
||||
public void Chk_to_str_href(boolean full, String raw, String expd) {Chk_to_str_href(cur_wiki, full, raw, expd);}
|
||||
public void Chk_to_str_href(Xowe_wiki wiki, boolean full, String raw, String expd) {
|
||||
href_parser.Parse_as_url(actl_url, Bry_.new_u8(raw), wiki, Bry__page);
|
||||
this.Chk_to_str(full, expd);
|
||||
this.Test__to_str(full, expd);
|
||||
}
|
||||
private static final byte[] Bry__page = Bry_.new_a7("Page_1");
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ public class Xow_url_parser {
|
||||
private final Object thread_lock = new Object();
|
||||
private final Gfo_url_encoder encoder;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser(); private final Gfo_url gfo_url = new Gfo_url();
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||
private final Gfo_url_encoder gfs_encoder = Gfo_url_encoder_.New__gfs().Make();
|
||||
private final Xoa_app app; private final Xow_wiki wiki; private final byte[] domain_bry;
|
||||
private byte tmp_protocol_tid;
|
||||
private int tmp_tid;
|
||||
private byte[] tmp_raw, tmp_wiki, tmp_page, tmp_anch, tmp_protocol_bry; private Gfo_qarg_itm[] tmp_qargs;
|
||||
private byte[] tmp_raw, tmp_orig, tmp_wiki, tmp_page, tmp_anch, tmp_protocol_bry; private Gfo_qarg_itm[] tmp_qargs;
|
||||
private byte[][] tmp_segs; private int tmp_segs_len;
|
||||
private boolean tmp_protocol_is_relative, tmp_page_is_main, tmp_wiki_is_missing;
|
||||
private byte[] tmp_vnt;
|
||||
@@ -69,9 +69,10 @@ public class Xow_url_parser {
|
||||
public boolean Parse(Xoa_url rv, byte[] src, int bgn, int end) {
|
||||
synchronized (thread_lock) {
|
||||
if (end - bgn == 0) {Init_tmp_vars(Gfo_url.Empty); Make(rv); return false;}
|
||||
src = encoder.Decode(src, bgn, end); // NOTE: must decode any url-encoded parameters
|
||||
int src_len = src.length;
|
||||
url_parser.Parse(gfo_url, src, 0, src_len); // parse to plain gfo_url
|
||||
tmp_orig = (bgn == 0 && end == src.length) ? src : Bry_.Mid(src, bgn, end);
|
||||
// src = encoder.Decode(src, bgn, end); // NOTE: must decode any url-encoded parameters; TOMBSTONE:do not auto-decode DATE:2016-10-10
|
||||
int src_len = end - bgn;
|
||||
Gfo_url gfo_url = url_parser.Parse(src, bgn, end); // parse to plain gfo_url
|
||||
Init_tmp_vars(gfo_url);
|
||||
if (src[0] == Byte_ascii.Hash) // src is anch; EX: #A
|
||||
Bld_anch();
|
||||
@@ -134,7 +135,7 @@ public class Xow_url_parser {
|
||||
}
|
||||
private Xoa_url Make(Xoa_url rv) {
|
||||
rv.Ctor
|
||||
( tmp_tid, tmp_raw, tmp_protocol_tid, tmp_protocol_bry, tmp_protocol_is_relative
|
||||
( tmp_tid, tmp_orig, tmp_raw, tmp_protocol_tid, tmp_protocol_bry, tmp_protocol_is_relative
|
||||
, tmp_wiki, tmp_page, tmp_qargs, tmp_anch
|
||||
, tmp_segs, tmp_vnt, tmp_wiki_is_missing, Bry_.Eq(tmp_wiki, wiki.Domain_bry()), tmp_page_is_main);
|
||||
return rv;
|
||||
@@ -264,9 +265,7 @@ public class Xow_url_parser {
|
||||
int qargs_len = tmp_qargs.length;
|
||||
for (int i = 0; i < qargs_len; ++i) {
|
||||
Gfo_qarg_itm qarg = tmp_qargs[i];
|
||||
if ( Bry_.Eq(qarg.Key_bry(), Qarg__title)
|
||||
&& qarg.Val_bry() != null // HACK: handle "bad-urls" from xml-encoded entities where page is null b/c = is encoded as =; http://en.wikipedia.org/w/index.php?action=edit&preload=Template:Afd2+starter&editintro=Template:Afd3+starter&title=Wikipedia:Articles+for+deletion/Template standardisation/demometa DATE:2015-08-02
|
||||
)
|
||||
if (Bry_.Eq(qarg.Key_bry(), Qarg__title))
|
||||
tmp_page = qarg.Val_bry(); // handle /w/index.php?title=Earth
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,23 +20,23 @@ import org.junit.*;
|
||||
public class Xow_url_parser__proto_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Relative() {
|
||||
tstr.Run_parse("//en.wikipedia.org/wiki/A").Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
tstr.Exec__parse("//en.wikipedia.org/wiki/A").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Http__basic() {
|
||||
tstr.Run_parse("http://en.wikipedia.org/wiki/A").Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
tstr.Exec__parse("http://en.wikipedia.org/wiki/A").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Upload__basic() {
|
||||
tstr.Prep_add_xwiki_to_user("commons.wikimedia.org"); // NOTE: need to add xwiki to be able to resolve "/commons/"
|
||||
tstr.Run_parse("http://upload.wikimedia.org/wikipedia/commons/a/ab/C.svg").Chk_wiki("commons.wikimedia.org").Chk_page("File:C.svg"); // orig
|
||||
tstr.Run_parse("http://upload.wikimedia.org/wikipedia/commons/thumb/7/70/A.png/220px-A.png").Chk_wiki("commons.wikimedia.org").Chk_page("File:A.png"); // thum
|
||||
tstr.Exec__parse("http://upload.wikimedia.org/wikipedia/commons/a/ab/C.svg").Test__wiki("commons.wikimedia.org").Test__page("File:C.svg"); // orig
|
||||
tstr.Exec__parse("http://upload.wikimedia.org/wikipedia/commons/thumb/7/70/A.png/220px-A.png").Test__wiki("commons.wikimedia.org").Test__page("File:A.png"); // thum
|
||||
}
|
||||
@Test public void File__basic() {
|
||||
tstr.Run_parse("file:///C:/a/b/c").Chk_tid(Xoa_url_.Tid_file);
|
||||
tstr.Exec__parse("file:///C:/a/b/c").Test__tid(Xoa_url_.Tid_file);
|
||||
}
|
||||
@Test public void Ftp__basic() {
|
||||
tstr.Run_parse("ftp://en.wikipedia.org/wiki/A").Chk_tid(Xoa_url_.Tid_inet);
|
||||
tstr.Exec__parse("ftp://en.wikipedia.org/wiki/A").Test__tid(Xoa_url_.Tid_inet);
|
||||
}
|
||||
@Test public void Extended() {
|
||||
tstr.Run_parse("http://en.wikipedia.org/w/index.php?A=B").Chk_wiki("en.wikipedia.org").Chk_page("index.php").Chk_qargs("?A=B").Chk_anch(null);
|
||||
tstr.Exec__parse("http://en.wikipedia.org/w/index.php?A=B").Test__wiki("en.wikipedia.org").Test__page("index.php").Test__qargs("?A=B").Test__anch(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import org.junit.*;
|
||||
public class Xow_url_parser__qarg__tst {
|
||||
private final Xow_url_parser_fxt fxt = new Xow_url_parser_fxt();
|
||||
@Test public void Redirect() {
|
||||
fxt.Exec__parse("A?redirect=no").Test__wiki("en.wikipedia.org").Test__page("A").Test__qargs("?redirect=no");
|
||||
}
|
||||
@Test public void Action_is_edit() {
|
||||
fxt.Exec__parse("A?action=edit").Test__wiki("en.wikipedia.org").Test__page("A").Test__action_is_edit_y();
|
||||
}
|
||||
@Test public void Assert_state_cleared() { // PURPOSE.fix: action_is_edit (et. al.) was not being cleared on parse even though Xoa_url reused; DATE:20121231
|
||||
fxt.Exec__parse("A?action=edit") .Test__action_is_edit_y();
|
||||
fxt.Exec__parse_reuse("B") .Test__action_is_edit_n();
|
||||
}
|
||||
@Test public void Query_arg() { // PURPOSE.fix: query args were not printing out
|
||||
fxt.Exec__parse("en.wikipedia.org/wiki/Special:Search/Earth?fulltext=yes").Test__build_str_is_same();
|
||||
}
|
||||
@Test public void Dupe_key() {
|
||||
fxt.Exec__parse("A?B=C1&B=C2").Test__page("A").Test__qargs("?B=C1&B=C2");
|
||||
}
|
||||
@Test public void Question_is_eos() {
|
||||
fxt.Exec__parse("A?").Test__wiki("en.wikipedia.org").Test__page("A?").Test__qargs("");
|
||||
}
|
||||
@Test public void Question_is_page() {
|
||||
fxt.Exec__parse("A?B").Test__wiki("en.wikipedia.org").Test__page("A?B").Test__qargs("");
|
||||
}
|
||||
@Test public void Question_is_anchor() {
|
||||
fxt.Exec__parse("A#b?c").Test__wiki("en.wikipedia.org").Test__page("A").Test__anch("b.3Fc");
|
||||
}
|
||||
@Test public void Title_remove_w() { // PURPOSE: fix /w/ showing up as seg; DATE:2014-05-30
|
||||
fxt.Exec__parse("http://en.wikipedia.org/w/index.php?title=A").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Ctg() {
|
||||
fxt.Exec__parse("Category:A?pagefrom=A#mw-pages").Test__page("Category:A").Test__qargs("?pagefrom=A").Test__anch("mw-pages");
|
||||
}
|
||||
@Test public void Anch() {
|
||||
fxt.Exec__parse("A?k1=v1#anch");
|
||||
fxt.Test__page("A");
|
||||
fxt.Test__anch("anch");
|
||||
fxt.Test__qargs("?k1=v1");
|
||||
fxt.Test__to_str("en.wikipedia.org/wiki/A?k1=v1#anch");
|
||||
}
|
||||
// DELETED: search should not depend on url-decoded entities; should be "Special:Search/Moon?fulltext=y&xowa_page_index=1" DATE:2016-10-10
|
||||
// @Test public void Search() {
|
||||
// fxt.Exec__parse("Special:Search/Moon%3Ffulltext%3Dy%26xowa_page_index%3D1").Test__page("Special:Search/Moon").Test__qargs("?fulltext=y&xowa_page_index=1");
|
||||
//}
|
||||
// DELETED: this is wrong as url should not handle html_entities like = instead # should strictly designate anch_href; DATE:2016-10-10
|
||||
// @Test public void Encoded() {
|
||||
// fxt.Exec__parse("en.wikipedia.org/wiki/A?action=edit&preload=B").Test__wiki("en.wikipedia.org").Test__page("A").Test__qargs("?action==edit=&preload=&=").Test__anch("61.3BB"); // NOTE: this is wrong; fix later
|
||||
// }
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.apps.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import org.junit.*;
|
||||
public class Xow_url_parser__qarg_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Redirect() {
|
||||
tstr.Run_parse("A?redirect=no").Chk_wiki("en.wikipedia.org").Chk_page("A").Chk_qargs("?redirect=no");
|
||||
}
|
||||
@Test public void Action_is_edit() {
|
||||
tstr.Run_parse("A?action=edit").Chk_wiki("en.wikipedia.org").Chk_page("A").Chk_action_is_edit_y();
|
||||
}
|
||||
@Test public void Assert_state_cleared() { // PURPOSE.fix: action_is_edit (et. al.) was not being cleared on parse even though Xoa_url reused; DATE:20121231
|
||||
tstr.Run_parse("A?action=edit") .Chk_action_is_edit_y();
|
||||
tstr.Run_parse_reuse("B") .Chk_action_is_edit_n();
|
||||
}
|
||||
@Test public void Query_arg() { // PURPOSE.fix: query args were not printing out
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/Special:Search/Earth?fulltext=yes").Chk_build_str_is_same();
|
||||
}
|
||||
@Test public void Dupe_key() {
|
||||
tstr.Run_parse("A?B=C1&B=C2").Chk_page("A").Chk_qargs("?B=C1&B=C2");
|
||||
}
|
||||
@Test public void Question_is_eos() {
|
||||
tstr.Run_parse("A?").Chk_wiki("en.wikipedia.org").Chk_page("A?").Chk_qargs("");
|
||||
}
|
||||
@Test public void Question_is_page() {
|
||||
tstr.Run_parse("A?B").Chk_wiki("en.wikipedia.org").Chk_page("A?B").Chk_qargs("");
|
||||
}
|
||||
@Test public void Question_is_anchor() {
|
||||
tstr.Run_parse("A#b?c").Chk_wiki("en.wikipedia.org").Chk_page("A").Chk_anch("b.3Fc");
|
||||
}
|
||||
@Test public void Title_remove_w() { // PURPOSE: fix /w/ showing up as seg; DATE:2014-05-30
|
||||
tstr.Run_parse("http://en.wikipedia.org/w/index.php?title=A").Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
}
|
||||
@Test public void Search() {
|
||||
tstr.Run_parse("Special:Search/Moon%3Ffulltext%3Dy%26xowa_page_index%3D1").Chk_page("Special:Search/Moon").Chk_qargs("?fulltext=y&xowa_page_index=1");
|
||||
}
|
||||
@Test public void Ctg() {
|
||||
tstr.Run_parse("Category:A?pagefrom=A#mw-pages").Chk_page("Category:A").Chk_qargs("?pagefrom=A").Chk_anch("mw-pages");
|
||||
}
|
||||
@Test public void Encoded() {
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/A?action=edit&preload=B").Chk_wiki("en.wikipedia.org").Chk_page("A").Chk_qargs("?action==edit=&preload=&=").Chk_anch("61.3BB"); // NOTE: this is wrong; fix later
|
||||
}
|
||||
}
|
||||
@@ -20,37 +20,37 @@ import org.junit.*;
|
||||
public class Xow_url_parser__ttl_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Name() {
|
||||
tstr.Run_parse("A").Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
tstr.Exec__parse("A").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Sub_1() {
|
||||
tstr.Run_parse("A/b").Chk_wiki("en.wikipedia.org").Chk_page("A/b");
|
||||
tstr.Exec__parse("A/b").Test__wiki("en.wikipedia.org").Test__page("A/b");
|
||||
}
|
||||
@Test public void Sub_2() {
|
||||
tstr.Run_parse("A/b/c").Chk_wiki("en.wikipedia.org").Chk_page("A/b/c");
|
||||
tstr.Exec__parse("A/b/c").Test__wiki("en.wikipedia.org").Test__page("A/b/c");
|
||||
}
|
||||
@Test public void Anch() {
|
||||
tstr.Run_parse("A#b").Chk_wiki("en.wikipedia.org").Chk_page("A").Chk_anch("b");
|
||||
tstr.Exec__parse("A#b").Test__wiki("en.wikipedia.org").Test__page("A").Test__anch("b");
|
||||
}
|
||||
@Test public void Anch_w_slash() { // PURPOSE: A/b#c/d was not parsing correctly; PAGE:en.w:Enlightenment_Spain#Enlightened_despotism_.281759%E2%80%931788.29
|
||||
tstr.Run_parse("A/b#c/d").Chk_page("A/b").Chk_anch("c.2Fd");
|
||||
tstr.Exec__parse("A/b#c/d").Test__page("A/b").Test__anch("c.2Fd");
|
||||
}
|
||||
@Test public void Ns_category() {
|
||||
tstr.Run_parse("Category:A").Chk_wiki("en.wikipedia.org").Chk_page("Category:A");
|
||||
tstr.Exec__parse("Category:A").Test__wiki("en.wikipedia.org").Test__page("Category:A");
|
||||
}
|
||||
@Test public void Main_page__basic() {
|
||||
tstr.Run_parse("en.wikipedia.org") .Chk_wiki("en.wikipedia.org").Chk_page_is_main_y();
|
||||
tstr.Run_parse("en.wikipedia.org/") .Chk_wiki("en.wikipedia.org").Chk_page_is_main_y();
|
||||
tstr.Run_parse("en.wikipedia.org/wiki") .Chk_wiki("en.wikipedia.org").Chk_page_is_main_y();
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/") .Chk_wiki("en.wikipedia.org").Chk_page_is_main_y();
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/A") .Chk_wiki("en.wikipedia.org").Chk_page_is_main_n();
|
||||
tstr.Exec__parse("en.wikipedia.org") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
|
||||
tstr.Exec__parse("en.wikipedia.org/") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki/") .Test__wiki("en.wikipedia.org").Test__page_is_main_y();
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki/A") .Test__wiki("en.wikipedia.org").Test__page_is_main_n();
|
||||
}
|
||||
@Test public void Ns_file__basic() {// PURPOSE: "File:A" should not be mistaken for "file:///" ns
|
||||
tstr.Run_parse("File:A").Chk_wiki("en.wikipedia.org").Chk_page("File:A");
|
||||
tstr.Exec__parse("File:A").Test__wiki("en.wikipedia.org").Test__page("File:A");
|
||||
}
|
||||
@Test public void Ns_file__nested() {// PURPOSE: handle fictitious "File:A/B/C.png"
|
||||
tstr.Run_parse("File:A/B/C.png").Chk_wiki("en.wikipedia.org").Chk_page("File:A/B/C.png"); // should not be C.png b/c of Gfo_url_parser_old
|
||||
tstr.Exec__parse("File:A/B/C.png").Test__wiki("en.wikipedia.org").Test__page("File:A/B/C.png"); // should not be C.png b/c of Gfo_url_parser_old
|
||||
}
|
||||
@Test public void Anch__basic() {// DATE:2015-07-26
|
||||
tstr.Run_parse("#A").Chk_tid(Xoa_url_.Tid_anch).Chk_wiki_is_missing(true).Chk_page("").Chk_anch("A");
|
||||
tstr.Exec__parse("#A").Test__tid(Xoa_url_.Tid_anch).Test__wiki_is_missing(true).Test__page("").Test__anch("A");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,49 +20,49 @@ import org.junit.*;
|
||||
public class Xow_url_parser__url_bar_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
tstr.Run_parse_from_url_bar("Page_1").Chk_to_str("en.wikipedia.org/wiki/Page_1"); // basic
|
||||
tstr.Exec__parse_from_url_bar("Page_1").Test__to_str("en.wikipedia.org/wiki/Page_1"); // basic
|
||||
}
|
||||
@Test public void Lang() {
|
||||
tstr.Prep_add_xwiki_to_user("uk", "uk.wikipedia.org");
|
||||
tstr.Run_parse_from_url_bar("uk").Chk_to_str("en.wikipedia.org/wiki/Uk"); // lang-like page (uk=Ukraine) should not try to open wiki; DATE:2014-02-07
|
||||
tstr.Exec__parse_from_url_bar("uk").Test__to_str("en.wikipedia.org/wiki/Uk"); // lang-like page (uk=Ukraine) should not try to open wiki; DATE:2014-02-07
|
||||
}
|
||||
@Test public void Lang_like() {
|
||||
tstr.Prep_add_xwiki_to_user("uk", "uk.wikipedia.org", "http://~{1}.wikipedia.org"); // NOTE: fmt needed for Type_is_lang
|
||||
tstr.Run_parse_from_url_bar("uk/A").Chk_to_str("en.wikipedia.org/wiki/Uk/A"); // uk/A should not try be interpreted as wiki="uk" page="A"; DATE:2014-04-26
|
||||
tstr.Exec__parse_from_url_bar("uk/A").Test__to_str("en.wikipedia.org/wiki/Uk/A"); // uk/A should not try be interpreted as wiki="uk" page="A"; DATE:2014-04-26
|
||||
}
|
||||
@Test public void Macro() {
|
||||
tstr.Prep_add_xwiki_to_user("fr.wikisource.org");
|
||||
tstr.Run_parse_from_url_bar("fr.s:Auteur:Shakespeare").Chk_to_str("fr.wikisource.org/wiki/Auteur:Shakespeare"); // url_macros
|
||||
tstr.Exec__parse_from_url_bar("fr.s:Auteur:Shakespeare").Test__to_str("fr.wikisource.org/wiki/Auteur:Shakespeare"); // url_macros
|
||||
}
|
||||
@Test public void Main_page__home() {
|
||||
tstr.Run_parse_from_url_bar("home").Chk_to_str("en.wikipedia.org/wiki/Home"); // home should go to current wiki's home; DATE:2014-02-09
|
||||
tstr.Run_parse_from_url_bar("home/wiki/Main_Page").Chk_to_str("home/wiki/Main_Page"); // home Main_Page should go to home; DATE:2014-02-09
|
||||
tstr.Exec__parse_from_url_bar("home").Test__to_str("en.wikipedia.org/wiki/Home"); // home should go to current wiki's home; DATE:2014-02-09
|
||||
tstr.Exec__parse_from_url_bar("home/wiki/Main_Page").Test__to_str("home/wiki/Main_Page"); // home Main_Page should go to home; DATE:2014-02-09
|
||||
}
|
||||
@Test public void Main_page__zhw() {
|
||||
Xowe_wiki zh_wiki = tstr.Prep_create_wiki("zh.wikipedia.org");
|
||||
zh_wiki.Props().Main_page_(Bry_.new_a7("Zh_Main_Page"));
|
||||
tstr.Run_parse_from_url_bar("zh.w:Main_Page") .Chk_page_is_main_n().Chk_to_str("zh.wikipedia.org/wiki/Main_Page");
|
||||
tstr.Run_parse_from_url_bar("zh.w:") .Chk_page_is_main_y().Chk_to_str("zh.wikipedia.org/wiki/Zh_Main_Page");
|
||||
tstr.Run_parse_from_url_bar("en.w:") .Chk_page_is_main_y().Chk_to_str("en.wikipedia.org/wiki/Main_Page"); // old bug: still stuck at zh main page due to reused objects
|
||||
tstr.Exec__parse_from_url_bar("zh.w:Main_Page") .Test__page_is_main_n().Test__to_str("zh.wikipedia.org/wiki/Main_Page");
|
||||
tstr.Exec__parse_from_url_bar("zh.w:") .Test__page_is_main_y().Test__to_str("zh.wikipedia.org/wiki/Zh_Main_Page");
|
||||
tstr.Exec__parse_from_url_bar("en.w:") .Test__page_is_main_y().Test__to_str("en.wikipedia.org/wiki/Main_Page"); // old bug: still stuck at zh main page due to reused objects
|
||||
}
|
||||
@Test public void Mobile() { // PURPOSE: handle mobile links; DATE:2014-05-03
|
||||
tstr.Run_parse_from_url_bar("en.m.wikipedia.org/wiki/A" ).Chk_to_str("en.wikipedia.org/wiki/A"); // basic
|
||||
tstr.Run_parse_from_url_bar("en.M.wikipedia.org/wiki/A" ).Chk_to_str("en.wikipedia.org/wiki/A"); // upper
|
||||
tstr.Run_parse_from_url_bar("A" ).Chk_to_str("en.wikipedia.org/wiki/A"); // bounds-check: 0
|
||||
tstr.Run_parse_from_url_bar("A." ).Chk_to_str("en.wikipedia.org/wiki/A."); // bounds-check: 1
|
||||
tstr.Run_parse_from_url_bar("A.b" ).Chk_to_str("en.wikipedia.org/wiki/A.b"); // bounds-check: 2
|
||||
tstr.Run_parse_from_url_bar("A.b.m." ).Chk_to_str("en.wikipedia.org/wiki/A.b.m."); // false-match
|
||||
tstr.Run_parse_from_url_bar("en.x.wikipedia.org/wiki/A" ).Chk_to_str("en.wikipedia.org/wiki/En.x.wikipedia.org/wiki/A"); // fail
|
||||
tstr.Exec__parse_from_url_bar("en.m.wikipedia.org/wiki/A" ).Test__to_str("en.wikipedia.org/wiki/A"); // basic
|
||||
tstr.Exec__parse_from_url_bar("en.M.wikipedia.org/wiki/A" ).Test__to_str("en.wikipedia.org/wiki/A"); // upper
|
||||
tstr.Exec__parse_from_url_bar("A" ).Test__to_str("en.wikipedia.org/wiki/A"); // bounds-check: 0
|
||||
tstr.Exec__parse_from_url_bar("A." ).Test__to_str("en.wikipedia.org/wiki/A."); // bounds-check: 1
|
||||
tstr.Exec__parse_from_url_bar("A.b" ).Test__to_str("en.wikipedia.org/wiki/A.b"); // bounds-check: 2
|
||||
tstr.Exec__parse_from_url_bar("A.b.m." ).Test__to_str("en.wikipedia.org/wiki/A.b.m."); // false-match
|
||||
tstr.Exec__parse_from_url_bar("en.x.wikipedia.org/wiki/A" ).Test__to_str("en.wikipedia.org/wiki/En.x.wikipedia.org/wiki/A"); // fail
|
||||
}
|
||||
@Test public void Missing_page() {
|
||||
tstr.Run_parse_from_url_bar("http://a.org").Chk_is_null(); // unknown wiki; return null;
|
||||
tstr.Run_parse_from_url_bar("http://en.wikipedia.org").Chk_to_str("en.wikipedia.org/wiki/Main_Page"); // known wiki; return Main_Page
|
||||
tstr.Exec__parse_from_url_bar("http://a.org").Test__is_null(); // unknown wiki; return null;
|
||||
tstr.Exec__parse_from_url_bar("http://en.wikipedia.org").Test__to_str("en.wikipedia.org/wiki/Main_Page"); // known wiki; return Main_Page
|
||||
}
|
||||
@Test public void Invalid_names() {
|
||||
tstr.Run_parse_from_url_bar("http://a/b/c").Chk_is_null(); // unknown url
|
||||
tstr.Run_parse_from_url_bar("war").Chk_to_str("en.wikipedia.org/wiki/War"); // word looks like lang, but is actually page; default to current
|
||||
tstr.Exec__parse_from_url_bar("http://a/b/c").Test__is_null(); // unknown url
|
||||
tstr.Exec__parse_from_url_bar("war").Test__to_str("en.wikipedia.org/wiki/War"); // word looks like lang, but is actually page; default to current
|
||||
}
|
||||
@Test public void Proper_case() {
|
||||
tstr.Run_parse_from_url_bar("a" ).Chk_to_str("en.wikipedia.org/wiki/A"); // "a" -> "A" x> "a"
|
||||
tstr.Exec__parse_from_url_bar("a" ).Test__to_str("en.wikipedia.org/wiki/A"); // "a" -> "A" x> "a"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,22 +20,22 @@ import org.junit.*;
|
||||
public class Xow_url_parser__wiki_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/A").Chk_tid(Xoa_url_.Tid_page).Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki/A").Test__tid(Xoa_url_.Tid_page).Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void No_wiki() { // PURPOSE: no "/wiki/"
|
||||
tstr.Run_parse("en.wikipedia.org/A").Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
tstr.Exec__parse("en.wikipedia.org/A").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Nested() {
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/A/b").Chk_wiki("en.wikipedia.org").Chk_page("A/b");
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki/A/b").Test__wiki("en.wikipedia.org").Test__page("A/b");
|
||||
}
|
||||
@Test public void Slash() {
|
||||
tstr.Run_parse("en.wikipedia.org/wiki//A").Chk_wiki("en.wikipedia.org").Chk_page("/A");
|
||||
tstr.Run_parse("en.wikipedia.org/wiki/A//b").Chk_wiki("en.wikipedia.org").Chk_page("A//b");
|
||||
tstr.Run_parse("en.wikipedia.org/wiki///A").Chk_wiki("en.wikipedia.org").Chk_page("//A");
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki//A").Test__wiki("en.wikipedia.org").Test__page("/A");
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki/A//b").Test__wiki("en.wikipedia.org").Test__page("A//b");
|
||||
tstr.Exec__parse("en.wikipedia.org/wiki///A").Test__wiki("en.wikipedia.org").Test__page("//A");
|
||||
}
|
||||
@Test public void Vnt() {
|
||||
Xowe_wiki wiki = tstr.Wiki();
|
||||
gplx.xowa.langs.vnts.Xol_vnt_regy_fxt.Init__vnt_mgr(wiki.Lang().Vnt_mgr(), 0, String_.Ary("zh-hans", "zh-hant"));
|
||||
tstr.Run_parse("en.wikipedia.org/zh-hans/A").Chk_wiki("en.wikipedia.org").Chk_page("A").Chk_vnt("zh-hans");
|
||||
tstr.Exec__parse("en.wikipedia.org/zh-hans/A").Test__wiki("en.wikipedia.org").Test__page("A").Test__vnt("zh-hans");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ import org.junit.*;
|
||||
public class Xow_url_parser__xcmd_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Basic() {
|
||||
tstr.Run_parse("xowa-cmd:xowa.app.version").Chk_tid(Xoa_url_.Tid_xcmd).Chk_page("xowa.app.version");
|
||||
tstr.Exec__parse("xowa-cmd:xowa.app.version").Test__tid(Xoa_url_.Tid_xcmd).Test__page("xowa.app.version");
|
||||
}
|
||||
@Test public void Encoded() {
|
||||
tstr.Run_parse("xowa-cmd:a%22b*c").Chk_tid(Xoa_url_.Tid_xcmd).Chk_page("a\"b*c");
|
||||
tstr.Exec__parse("xowa-cmd:a%22b*c").Test__tid(Xoa_url_.Tid_xcmd).Test__page("a\"b*c");
|
||||
}
|
||||
@Test public void Ignore_anchor_and_qargs() {
|
||||
tstr.Run_parse("xowa-cmd:a/b/c?d=e#f").Chk_tid(Xoa_url_.Tid_xcmd).Chk_page("a/b/c?d=e#f");
|
||||
tstr.Exec__parse("xowa-cmd:a/b/c?d=e#f").Test__tid(Xoa_url_.Tid_xcmd).Test__page("a/b/c?d=e#f");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,60 +21,60 @@ public class Xow_url_parser__xwiki_tst {
|
||||
private final Xow_url_parser_fxt tstr = new Xow_url_parser_fxt();
|
||||
@Test public void Commons() { // PURPOSE: "C" was being picked up as an xwiki to commons; PAGE:no.b:C/Variabler; DATE:2014-10-14
|
||||
tstr.Prep_add_xwiki_to_user("c", "commons.wikimedia.org"); // add alias of "c"
|
||||
tstr.Run_parse("C/D").Chk_tid(Xoa_url_.Tid_page).Chk_wiki("en.wikipedia.org").Chk_page("C/D"); // should use current wiki (enwiki), not xwiki to commons; also, page should be "C/D", not "D"
|
||||
tstr.Exec__parse("C/D").Test__tid(Xoa_url_.Tid_page).Test__wiki("en.wikipedia.org").Test__page("C/D"); // should use current wiki (enwiki), not xwiki to commons; also, page should be "C/D", not "D"
|
||||
}
|
||||
@Test public void Parse_lang() {
|
||||
tstr.Prep_add_xwiki_to_wiki("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/~{0}");
|
||||
tstr.Run_parse("http://en.wikipedia.org/wiki/fr:A").Chk_tid(Xoa_url_.Tid_page).Chk_wiki("fr.wikipedia.org").Chk_page("A");
|
||||
tstr.Exec__parse("http://en.wikipedia.org/wiki/fr:A").Test__tid(Xoa_url_.Tid_page).Test__wiki("fr.wikipedia.org").Test__page("A");
|
||||
}
|
||||
@Test public void Alias_wiki() {
|
||||
tstr.Prep_add_xwiki_to_wiki("s", "en.wikisource.org");
|
||||
tstr.Run_parse("s:A/b/c").Chk_wiki("en.wikisource.org").Chk_page("A/b/c");
|
||||
tstr.Exec__parse("s:A/b/c").Test__wiki("en.wikisource.org").Test__page("A/b/c");
|
||||
}
|
||||
@Test public void Xwiki_no_segs() { // PURPOSE: handle xwiki without full url; EX: "commons:Commons:Media_of_the_day"; DATE:2014-02-19
|
||||
tstr.Prep_add_xwiki_to_wiki("s", "en.wikisource.org");
|
||||
tstr.Run_parse("s:Project:A").Chk_wiki("en.wikisource.org").Chk_page("Project:A");
|
||||
tstr.Exec__parse("s:Project:A").Test__wiki("en.wikisource.org").Test__page("Project:A");
|
||||
}
|
||||
@Test public void Domain_only() {
|
||||
tstr.Prep_add_xwiki_to_user("fr.wikipedia.org");
|
||||
tstr.Run_parse("fr.wikipedia.org").Chk_wiki("fr.wikipedia.org").Chk_page("");
|
||||
tstr.Exec__parse("fr.wikipedia.org").Test__wiki("fr.wikipedia.org").Test__page("");
|
||||
}
|
||||
@Test public void Domain_and_wiki() {
|
||||
tstr.Prep_add_xwiki_to_user("fr.wikipedia.org");
|
||||
tstr.Run_parse("fr.wikipedia.org/wiki").Chk_wiki("fr.wikipedia.org").Chk_page("");
|
||||
tstr.Exec__parse("fr.wikipedia.org/wiki").Test__wiki("fr.wikipedia.org").Test__page("");
|
||||
}
|
||||
@Test public void Domain_and_wiki_w_http() {
|
||||
tstr.Prep_add_xwiki_to_user("fr.wikipedia.org");
|
||||
tstr.Run_parse("http://fr.wikipedia.org/wiki").Chk_wiki("fr.wikipedia.org").Chk_page("");
|
||||
tstr.Exec__parse("http://fr.wikipedia.org/wiki").Test__wiki("fr.wikipedia.org").Test__page("");
|
||||
}
|
||||
@Test public void Namespace_in_different_wiki() { // PURPOSE.fix: namespaced titles would default to default_wiki instead of current_wiki
|
||||
Xowe_wiki en_s = tstr.Prep_create_wiki("en.wikisource.org");
|
||||
tstr.Run_parse(en_s, "Category:A").Chk_wiki("en.wikisource.org").Chk_page("Category:A");
|
||||
tstr.Exec__parse(en_s, "Category:A").Test__wiki("en.wikisource.org").Test__page("Category:A");
|
||||
}
|
||||
@Test public void Case_sensitive() {
|
||||
// tstr.Run_parse("en.wikipedia.org/wiki/a").Chk_wiki("en.wikipedia.org").Chk_page("A");
|
||||
// tstr.Exec__parse("en.wikipedia.org/wiki/a").Test__wiki("en.wikipedia.org").Test__page("A");
|
||||
Xowe_wiki en_d = tstr.Prep_create_wiki("en.wiktionary.org");
|
||||
Xow_ns_mgr ns_mgr = en_d.Ns_mgr();
|
||||
|
||||
ns_mgr.Ns_main().Case_match_(Xow_ns_case_.Tid__all);
|
||||
tstr.Run_parse("en.wiktionary.org/wiki/a").Chk_wiki("en.wiktionary.org").Chk_page("a");
|
||||
tstr.Exec__parse("en.wiktionary.org/wiki/a").Test__wiki("en.wiktionary.org").Test__page("a");
|
||||
|
||||
ns_mgr.Ns_category().Case_match_(Xow_ns_case_.Tid__all);
|
||||
tstr.Run_parse("en.wiktionary.org/wiki/Category:a").Chk_wiki("en.wiktionary.org").Chk_page("Category:a");
|
||||
tstr.Exec__parse("en.wiktionary.org/wiki/Category:a").Test__wiki("en.wiktionary.org").Test__page("Category:a");
|
||||
|
||||
tstr.Run_parse("en.wiktionary.org/wiki/A/B/C").Chk_page("A/B/C");
|
||||
tstr.Exec__parse("en.wiktionary.org/wiki/A/B/C").Test__page("A/B/C");
|
||||
}
|
||||
@Test public void Xwiki__to_enwiki() { // PURPOSE: handle alias of "wikipedia" and sv.wikipedia.org/wiki/Wikipedia:Main_Page; DATE:2015-07-31
|
||||
Xowe_wiki xwiki = tstr.Prep_create_wiki("sv.wikipedia.org");
|
||||
tstr.Prep_xwiki(xwiki, "wikipedia", "en.wikipedia.org", null);
|
||||
tstr.Prep_get_ns_mgr_from_meta("sv.wikipedia.org").Add_new(Xow_ns_.Tid__project, "Wikipedia");
|
||||
tstr.Run_parse(xwiki, "sv.wikipedia.org/wiki/wikipedia:X").Chk_wiki("sv.wikipedia.org").Chk_page("wikipedia:X");
|
||||
tstr.Run_parse(xwiki, "sv.wikipedia.org/wiki/Wikipedia:X").Chk_wiki("sv.wikipedia.org").Chk_page("Wikipedia:X");
|
||||
tstr.Exec__parse(xwiki, "sv.wikipedia.org/wiki/wikipedia:X").Test__wiki("sv.wikipedia.org").Test__page("wikipedia:X");
|
||||
tstr.Exec__parse(xwiki, "sv.wikipedia.org/wiki/Wikipedia:X").Test__wiki("sv.wikipedia.org").Test__page("Wikipedia:X");
|
||||
}
|
||||
@Test public void Xwiki__to_ns() { // PURPOSE: handle alias of "wikipedia" in current, but no "Wikipedia" ns in other wiki; PAGE:pt.w:Wikipedia:P<>gina_de_testes DATE:2015-09-17
|
||||
tstr.Prep_create_wiki("pt.wikipedia.org");
|
||||
tstr.Prep_get_ns_mgr_from_meta("pt.wikipedia.org").Add_new(Xow_ns_.Tid__project, "Project"); // clear ns_mgr and add only "Project" ns, not "Wikipedia" ns
|
||||
tstr.Prep_xwiki(tstr.Wiki(), "wikipedia", "en.wikipedia.org", null); // add alias of "wikipedia" in current wiki
|
||||
tstr.Run_parse(tstr.Wiki(), "pt.wikipedia.org/wiki/Wikipedia:X").Chk_wiki("pt.wikipedia.org").Chk_page("Wikipedia:X"); // should get "pt.wikipedia.org", not "en.wikipedia.org" (through alias)
|
||||
tstr.Exec__parse(tstr.Wiki(), "pt.wikipedia.org/wiki/Wikipedia:X").Test__wiki("pt.wikipedia.org").Test__page("Wikipedia:X"); // should get "pt.wikipedia.org", not "en.wikipedia.org" (through alias)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,36 +46,36 @@ public class Xow_url_parser_fxt {
|
||||
public Xow_ns_mgr Prep_get_ns_mgr_from_meta(String wiki) {
|
||||
return app.Dbmeta_mgr().Ns__get_or_load(Bry_.new_u8(wiki));
|
||||
}
|
||||
public Xow_url_parser_fxt Run_parse(String actl_str) {return Run_parse(cur_wiki, actl_str);}
|
||||
public Xow_url_parser_fxt Run_parse(Xow_wiki wiki, String actl_str) {
|
||||
public Xow_url_parser_fxt Exec__parse(String actl_str) {return Exec__parse(cur_wiki, actl_str);}
|
||||
public Xow_url_parser_fxt Exec__parse(Xow_wiki wiki, String actl_str) {
|
||||
this.actl_url = wiki.Utl__url_parser().Parse(Bry_.new_u8(actl_str));
|
||||
return this;
|
||||
}
|
||||
public Xow_url_parser_fxt Run_parse_reuse(String actl_str) {
|
||||
public Xow_url_parser_fxt Exec__parse_reuse(String actl_str) {
|
||||
this.actl_url = parser.Parse(Bry_.new_u8(actl_str));
|
||||
return this;
|
||||
}
|
||||
public Xow_url_parser_fxt Run_parse_from_url_bar(String raw) {
|
||||
public Xow_url_parser_fxt Exec__parse_from_url_bar(String raw) {
|
||||
this.actl_url = parser.Parse_by_urlbar_or_null(raw);
|
||||
return this;
|
||||
}
|
||||
public Xow_url_parser_fxt Chk_tid(int v) {Tfds.Eq_int(v, actl_url.Tid() , "tid"); return this;}
|
||||
public Xow_url_parser_fxt Chk_is_null() {Tfds.Eq_bool(true, actl_url == null); return this;}
|
||||
public Xow_url_parser_fxt Chk_vnt(String v) {Tfds.Eq_str(v, actl_url.Vnt_bry() , "vnt"); return this;}
|
||||
public Xow_url_parser_fxt Chk_wiki(String v) {Tfds.Eq_str(v, actl_url.Wiki_bry() , "wiki"); return this;}
|
||||
public Xow_url_parser_fxt Chk_wiki_is_missing(boolean v) {Tfds.Eq_bool(v, actl_url.Wiki_is_missing(), "wiki_is_missing"); return this;}
|
||||
public Xow_url_parser_fxt Chk_page(String v) {Tfds.Eq_str(v, actl_url.Page_bry() , "page"); return this;}
|
||||
public Xow_url_parser_fxt Chk_qargs(String v) {Tfds.Eq_str(v, actl_url.Qargs_mgr().To_bry(), "qargs"); return this;}
|
||||
public Xow_url_parser_fxt Chk_page_is_main_y() {return Chk_page_is_main(Bool_.Y);}
|
||||
public Xow_url_parser_fxt Chk_page_is_main_n() {return Chk_page_is_main(Bool_.N);}
|
||||
public Xow_url_parser_fxt Chk_page_is_main(boolean v) {Tfds.Eq_bool(v, actl_url.Page_is_main() , "page_is_main"); return this;}
|
||||
public Xow_url_parser_fxt Chk_anch(String v) {Tfds.Eq_str(v, actl_url.Anch_bry(), "anch"); return this;}
|
||||
public Xow_url_parser_fxt Chk_action_is_edit_y() {return Chk_action_is_edit_(Bool_.Y);}
|
||||
public Xow_url_parser_fxt Chk_action_is_edit_n() {return Chk_action_is_edit_(Bool_.N);}
|
||||
private Xow_url_parser_fxt Chk_action_is_edit_(boolean v) {Tfds.Eq_bool(v, actl_url.Qargs_mgr().Match(Xoa_url_.Qarg__action, Xoa_url_.Qarg__action__edit), "action_is_edit"); return this;}
|
||||
public Xow_url_parser_fxt Chk_to_str(String v) {return Chk_to_str(Bool_.Y, v);}
|
||||
public Xow_url_parser_fxt Chk_to_str(boolean full, String v) {Tfds.Eq_str(v, actl_url.To_bry(full, Bool_.Y), "To_bry"); return this;}
|
||||
public Xow_url_parser_fxt Chk_build_str_is_same() {
|
||||
public Xow_url_parser_fxt Test__tid(int v) {Tfds.Eq_int(v, actl_url.Tid() , "tid"); return this;}
|
||||
public Xow_url_parser_fxt Test__is_null() {Tfds.Eq_bool(true, actl_url == null); return this;}
|
||||
public Xow_url_parser_fxt Test__vnt(String v) {Tfds.Eq_str(v, actl_url.Vnt_bry() , "vnt"); return this;}
|
||||
public Xow_url_parser_fxt Test__wiki(String v) {Tfds.Eq_str(v, actl_url.Wiki_bry() , "wiki"); return this;}
|
||||
public Xow_url_parser_fxt Test__wiki_is_missing(boolean v) {Tfds.Eq_bool(v, actl_url.Wiki_is_missing(), "wiki_is_missing"); return this;}
|
||||
public Xow_url_parser_fxt Test__page(String v) {Tfds.Eq_str(v, actl_url.Page_bry() , "page"); return this;}
|
||||
public Xow_url_parser_fxt Test__qargs(String v) {Tfds.Eq_str(v, actl_url.Qargs_mgr().To_bry(), "qargs"); return this;}
|
||||
public Xow_url_parser_fxt Test__page_is_main_y() {return Test__page_is_main(Bool_.Y);}
|
||||
public Xow_url_parser_fxt Test__page_is_main_n() {return Test__page_is_main(Bool_.N);}
|
||||
public Xow_url_parser_fxt Test__page_is_main(boolean v) {Tfds.Eq_bool(v, actl_url.Page_is_main() , "page_is_main"); return this;}
|
||||
public Xow_url_parser_fxt Test__anch(String v) {Tfds.Eq_str(v, actl_url.Anch_bry(), "anch"); return this;}
|
||||
public Xow_url_parser_fxt Test__action_is_edit_y() {return Test__action_is_edit_(Bool_.Y);}
|
||||
public Xow_url_parser_fxt Test__action_is_edit_n() {return Test__action_is_edit_(Bool_.N);}
|
||||
private Xow_url_parser_fxt Test__action_is_edit_(boolean v) {Tfds.Eq_bool(v, actl_url.Qargs_mgr().Match(Xoa_url_.Qarg__action, Xoa_url_.Qarg__action__edit), "action_is_edit"); return this;}
|
||||
public Xow_url_parser_fxt Test__to_str(String v) {return Test__to_str(Bool_.Y, v);}
|
||||
public Xow_url_parser_fxt Test__to_str(boolean full, String v) {Tfds.Eq_str(v, actl_url.To_bry(full, Bool_.Y), "To_bry"); return this;}
|
||||
public Xow_url_parser_fxt Test__build_str_is_same() {
|
||||
Xow_url_parser parser = new Xow_url_parser(cur_wiki);
|
||||
Tfds.Eq_str(actl_url.Raw(), parser.Build_str(actl_url), "build_str");
|
||||
return this;
|
||||
|
||||
@@ -46,7 +46,8 @@ public class Xoapi_orig_wmf extends Xoapi_orig_base {
|
||||
|
||||
if (Parse_xml_val(tmp_rng, usr_dlg, xml, xml_len, pos, Bry_xml_descriptionurl)) {
|
||||
byte[] file_url = Bry_.Mid(xml, tmp_rng.Val_0(), tmp_rng.Val_1());
|
||||
orig_wiki = gplx.xowa.wikis.xwikis.Xow_xwiki_mgr.Get_domain_from_url(url_parser, url, file_url);
|
||||
Gfo_url url = url_parser.Parse(file_url, 0, file_url.length);
|
||||
orig_wiki = url.Segs__get_at_1st();
|
||||
byte[] page = Xoa_ttl.Replace_spaces(url.Segs__get_at_nth());
|
||||
int colon_pos = Bry_find_.Find_fwd(page, Byte_ascii.Colon, 0, page.length);
|
||||
if (colon_pos != Bry_find_.Not_found)
|
||||
@@ -58,7 +59,7 @@ public class Xoapi_orig_wmf extends Xoapi_orig_base {
|
||||
}
|
||||
}
|
||||
private static Int_2_ref tmp_rng = new Int_2_ref();
|
||||
private static Gfo_url_parser url_parser = new Gfo_url_parser(); private static Gfo_url url = new Gfo_url();
|
||||
private static Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||
private static boolean Parse_xml_val(Int_2_ref rv, Gfo_usr_dlg usr_dlg, byte[] xml, int xml_len, int pos, byte[] key) {
|
||||
int bgn = 0, end = 0;
|
||||
bgn = Bry_find_.Find_fwd(xml, key, pos, xml_len); if (bgn == Bry_find_.Not_found) return false;
|
||||
|
||||
Reference in New Issue
Block a user