1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Command-line: Fix curid argument not working 2

This commit is contained in:
gnosygnu
2017-02-22 08:44:14 -05:00
parent 0e85cc90ff
commit 5bd3371802
896 changed files with 1 additions and 69011 deletions

View File

@@ -1,39 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.guis.cbks.swts; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.cbks.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.core.gfobjs.*;
public class Gfobj_wtr__json__browser__tst {
private final Gfobj_wtr__json__browser__fxt fxt = new Gfobj_wtr__json__browser__fxt();
@Test public void Json_proc() {
fxt.Test__json_proc
( "proc_name"
, fxt.Make__nde
( fxt.Make__fld_str ("k1", "v1")
, fxt.Make__fld_long ("k2", 2)
, fxt.Make__fld_int ("k3", 3)
)
, "return proc_name('{\"k1\":\"v1\",\"k2\":2,\"k3\":3}');"
);
}
}
class Gfobj_wtr__json__browser__fxt extends Gfobj_wtr__json_fxt { public Gfobj_wtr__json__browser__fxt Test__json_proc() {return this;}
public void Test__json_proc(String proc_name, Gfobj_nde root, String expd) {
Gfobj_wtr__json__browser wtr = new Gfobj_wtr__json__browser();
String actl = wtr.Write_as_func__swt(proc_name, root);
Gftest.Eq__str(expd, actl, "json_write");
}
}

View File

@@ -1,83 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.guis.history; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import org.junit.*;
public class Xog_history_stack_tst {
@Before public void init() {fxt.Clear();} private Xog_history_stack_fxt fxt = new Xog_history_stack_fxt();
@Test public void Init() {fxt.Test_cur(null);}
@Test public void Add_1() {fxt.Exec_add_many("A").Test_cur("A").Test_len(1).Test_pos(0);}
@Test public void Add_same() {fxt.Exec_add_many("A", "A").Test_cur("A").Test_len(1).Test_pos(0);}
@Test public void Add_3() {fxt.Exec_add_many("A", "B", "C").Test_cur("C").Test_len(3).Test_pos(2);}
@Test public void Add_3_bwd() {fxt.Exec_add_many("A", "B", "C").Exec_go_bwd().Test_cur("B").Test_pos(1);}
@Test public void Add_3_bwd_fwd() {fxt.Exec_add_many("A", "B", "C").Exec_go_bwd().Exec_go_fwd().Test_cur("C").Test_pos(2);}
@Test public void Add_3_bwd_add() {fxt.Exec_add_many("A", "B", "C").Exec_go_bwd().Exec_add_many("D").Test_len(3).Test_cur("D").Test_pos(2);}
@Test public void Add_3_bwd_bwd_add() {fxt.Exec_add_many("A", "B", "C").Exec_go_bwd().Exec_go_bwd().Exec_add_many("D").Test_len(2).Test_cur("D").Test_pos(1);}
@Test public void Add_dif_ns() {fxt.Exec_add_many("A", "Help:A").Test_cur("Help:A");} // PURPOSE.fix: page_stack was only differtiating by Page_db, not Full; EX: Unicode -> Category:Unicode
@Test public void Add_qargs() {// PURPOSE.fix: page_stack was only differentiating by qtxt args
fxt .Exec_add_one("Special:AllPages", "?from=A")
.Exec_add_one("Special:AllPages", "?from=B")
.Exec_add_many("B")
.Exec_go_bwd()
.Test_cur("Special:AllPages")
.Test_cur_qargs("?from=B")
;
}
}
class Xog_history_stack_fxt {
public Xog_history_stack_fxt Clear() {
stack.Clear();
if (app == null) {
app = Xoa_app_fxt.Make__app__edit();
wiki = Xoa_app_fxt.Make__wiki__edit(app);
}
return this;
} private Xoae_app app; private Xowe_wiki wiki; private Xog_history_stack stack = new Xog_history_stack();
public Xog_history_stack_fxt Test_cur(String expd) {
Xog_history_itm page = stack.Cur_itm();
String actl = page == null ? null : String_.new_u8(page.Page());
Tfds.Eq(expd, actl, "cur");
return this;
}
public Xog_history_stack_fxt Test_cur_qargs(String expd) {
Xog_history_itm page = stack.Cur_itm();
String actl = page == null ? null : String_.new_u8(page.Qarg());
Tfds.Eq(expd, actl, "cur_qargs");
return this;
}
public Xog_history_stack_fxt Exec_go_bwd() {stack.Go_bwd(); return this;}
public Xog_history_stack_fxt Exec_go_fwd() {stack.Go_fwd(); return this;}
public Xog_history_stack_fxt Exec_add_many(String... ary) {
int len = ary.length;
for (int i = 0; i < len; i++) {
String ttl = ary[i];
Exec_add_one(ttl, null);
}
return this;
}
public Xog_history_stack_fxt Exec_add_one(String ttl_str, String arg_str) {
byte[] ttl_bry = Bry_.new_u8(ttl_str);
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
Xoae_page page = Xoae_page.New_test(wiki, ttl);
byte[] url_bry = ttl_bry;
if (arg_str != null) url_bry = Bry_.Add(url_bry, Bry_.new_u8(arg_str));
Xoa_url url = app.User().Wikii().Utl__url_parser().Parse(url_bry);
page.Url_(url); // set url b/c history_mgr.Add uses url
stack.Add(Xog_history_mgr.new_(page));
return this;
}
public Xog_history_stack_fxt Test_pos(int expd) {Tfds.Eq(expd, stack.Cur_pos(), "pos"); return this;}
public Xog_history_stack_fxt Test_len(int expd) {Tfds.Eq(expd, stack.Len(), "len"); return this;}
}

View File

@@ -1,66 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.guis.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.xowa.files.origs.*;
public class Xog_url_wkr__file__tst {
private final Xog_url_wkr__file__fxt fxt = new Xog_url_wkr__file__fxt();
@Test public void Basic() {
fxt.Test__extract("A.png", "file:///mem/xowa/file/commons.wikimedia.org/orig/7/0/A.png", 300, 200);
}
@Test public void Url_encoded() {
fxt.Test__extract("A,b.png", "file:///mem/xowa/file/commons.wikimedia.org/orig/d/6/A%2Cb.png", 300, 200);
}
@Test public void Utf8() {
fxt.Test__extract("Volcán_Chimborazo,_\"El_Taita_Chimborazo\".jpg", "file:///mem/xowa/file/commons.wikimedia.org/orig/3/c/Volc%C3%A1n_Chimborazo%2C_%22El_Taita_Chimborazo%22.jpg", 300, 200);
}
}
class Xog_url_wkr__file__fxt {
private final Xowe_wiki wiki;
private final Bry_bfr bfr = Bry_bfr_.New();
private final Xog_url_wkr__file wkr;
private final Xof_orig_wkr__mock orig_wkr = new Xof_orig_wkr__mock();
public Xog_url_wkr__file__fxt() {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
wiki = Xoa_app_fxt.Make__wiki__edit(app);
Xoa_app_fxt.repo2_(app, wiki);
wiki.File__orig_mgr().Wkrs__add(orig_wkr);
this.wkr = new Xog_url_wkr__file(app, wiki, Xoae_page.New_edit(wiki, wiki.Ttl_parse(Bry_.new_a7("Test_page"))));
}
public String Make__html(byte[] href_bry, byte[] xowa_ttl) {
bfr.Add_str_u8_fmt("<a href=\"{0}\" class=\"@gplx.Internal protected\" title=\"test_title\" xowa_title=\"{1}\">Full resolution</a>", href_bry, xowa_ttl);
return bfr.To_str_and_clear();
}
public void Make__orig(byte repo, byte[] page, int w, int h, byte[] redirect) {
orig_wkr.Add_orig(repo, page, gplx.xowa.files.Xof_ext_.new_by_ttl_(page).Id(), w, h, redirect);
}
public void Exec__extract_data(byte[] href_bry, String html_doc) {
wkr.Extract_data(html_doc, href_bry);
}
public void Test__extract(String file_page_db, String a_href_str, int orig_w, int orig_h) {
byte[] a_href = Bry_.new_u8(a_href_str);
this.Make__orig(Xof_orig_itm.Repo_wiki, Bry_.new_u8(file_page_db), orig_w, orig_h, Bry_.Empty);
byte[] xowa_title_bry = gplx.xowa.htmls.core.wkrs.lnkis.htmls.Xoh_file_fmtr__basic.Escape_xowa_title(Bry_.new_u8(file_page_db));
this.Exec__extract_data(a_href, this.Make__html(a_href, xowa_title_bry));
Gftest.Eq__str(file_page_db , wkr.File_page_db() , "file_page_db");
Gftest.Eq__bry(a_href , wkr.File_url().To_http_file_bry() , "file_url");
Gftest.Eq__bry(a_href , wkr.Fsdb().Html_view_url().To_http_file_bry() , "fsdb.view_url");
Gftest.Eq__int(orig_w , wkr.Fsdb().Orig_w() , "fsdb.orig_w");
Gftest.Eq__int(orig_h , wkr.Fsdb().Orig_h() , "fsdb.orig_h");
}
}

View File

@@ -1,46 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.guis.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*;
import org.junit.*; import gplx.core.tests.*;
public class Xog_url_wkr__tst {
private final Xog_url_wkr__fxt fxt = new Xog_url_wkr__fxt();
@Test public void Basic() {
fxt.Exec__parse("/wiki/A?k1=B%26C");
fxt.Test__raw("/wiki/A?k1=B%26C");
}
@Test public void Anch_early() { // de.wikipedia.org/wiki/Kategorie:Begriffskl%C3%A4rung?pagefrom=#::12%20PANZERDIVISION#mw-pages
fxt.Exec__parse("/wiki/A?pagefrom=%23%3A7p#mw-pages");
fxt.Test__qarg("?pagefrom=#:7p");
fxt.Test__anch("mw-pages");
}
}
class Xog_url_wkr__fxt {
private final Xowe_wiki wiki;
private final Xog_url_wkr wkr = new Xog_url_wkr();
private Xoa_url url;
public Xog_url_wkr__fxt() {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
wkr.Init(wiki);
}
public void Exec__parse(String href) {
this.url = wiki.Utl__url_parser().Parse(Bry_.new_u8(href));
this.url = wkr.Exec_url(url);
}
public void Test__raw(String expd) {Gftest.Eq__str(expd, String_.new_u8(url.Raw()));}
public void Test__qarg(String expd) {Gftest.Eq__str(expd, String_.new_u8(url.Qargs_mgr().To_bry()));}
public void Test__anch(String expd) {Gftest.Eq__str(expd, String_.new_u8(url.Anch_bry()));}
}

View File

@@ -1,54 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.guis.urls.url_macros; import gplx.*; import gplx.xowa.*; import gplx.xowa.guis.*; import gplx.xowa.guis.urls.*;
import org.junit.*;
public class Xog_url_macro_mgr_tst {
@Before public void init() {fxt.Clear();} private Xog_url_macro_mgr_fxt fxt = new Xog_url_macro_mgr_fxt();
@Test public void Custom_basic() {fxt.Test("?:Page" , "Special:Search/Page?fulltext=y");}
@Test public void Type_basic() {fxt.Test("en.w:Page" , "en.wikipedia.org/wiki/Page");}
@Test public void Type_main() {fxt.Test("en.w:" , "en.wikipedia.org/wiki/");}
@Test public void Type_tid() {fxt.Test("w:Page" , "en.wikipedia.org/wiki/Page");}
@Test public void Type_lang() {fxt.Test("fr.w:Page" , "fr.wikipedia.org/wiki/Page");}
@Test public void Type_unhandled() {fxt.Test("x:A" , null);}
@Test public void Type_unhandled_ns() {fxt.Test("Help:A" , null);}
@Test public void Type_custom() {fxt.Test("wd.q:123" , "www.wikidata.org/wiki/Q123");}
@Test public void Type_del() {
fxt.Test("w:A", "en.wikipedia.org/wiki/A");
fxt.Abrv_mgr().Types_mgr().Del(Bry_.new_a7("w"));
fxt.Test("w:A", null);
}
@Test public void Type_set() {
fxt.Abrv_mgr().Types_mgr().Set("w", "~{0}.~{1}");
fxt.Test("w.A", null);
}
@Test public void Lang_default() {
fxt.Abrv_mgr().Lang_default_(Bry_.new_a7("fr"));
fxt.Test("w:Page", "fr.wikipedia.org/wiki/Page");
}
@Test public void Precedence() { // PURPOSE: Custom should take precedence over type
fxt.Abrv_mgr().Custom_mgr().Set("w", "custom:~{0}");
fxt.Test("w:Page" , "custom:Page");
}
}
class Xog_url_macro_mgr_fxt {
public void Clear() {
abrv_mgr = new Xog_url_macro_mgr();
}
public Xog_url_macro_mgr Abrv_mgr() {return abrv_mgr;} private Xog_url_macro_mgr abrv_mgr;
public void Test(String raw, String expd) {
Tfds.Eq(expd, String_.new_a7(abrv_mgr.Fmt_or_null(Bry_.new_a7(raw))));
}
}

View File

@@ -277,7 +277,7 @@ public class Xog_win_itm implements Gfo_invk, Gfo_evt_itm {
Xowe_wiki wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_make_init_y(url.Wiki_bry());
// parse url again, but this time according to rules of actual wiki
wiki.Utl__url_parser().Parse(Bry_.new_u8(url_str));
url = wiki.Utl__url_parser().Parse(Bry_.new_u8(url_str));
// get title
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, url.Page_bry());