mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.5.1
This commit is contained in:
@@ -20,7 +20,7 @@ public class Xow_page_fetcher_wiki implements Xow_page_fetcher {
|
||||
public Xow_page_fetcher Wiki_(Xowe_wiki v) {this.wiki = v; return this;} private Xowe_wiki wiki;
|
||||
public void Clear() {}
|
||||
public byte[] Get_by(int ns_id, byte[] ttl_bry) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ns_id, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ns_id, ttl_bry);
|
||||
Xoae_page page = wiki.Data_mgr().Get_page(ttl, false); // go through data_mgr in case of redirects
|
||||
return page.Missing() ? null : page.Data_raw();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Xowd_page_itm implements Xobl_data_itm {
|
||||
public void Clear() {
|
||||
id = Id_null; text_len = 0; // text_len should be 0 b/c text defaults to 0;
|
||||
text_db_id = tdb_row_idx = 0; // default to 0, b/c some tests do not set and will fail at -1
|
||||
ns_id = Int_.MinValue;
|
||||
ns_id = Int_.Min_value;
|
||||
ttl_full_db = ttl_page_db = null; text = Bry_.Empty; // default to Ary_empty for entries that have <text />
|
||||
ns = null;
|
||||
redirected = exists = false;
|
||||
|
||||
@@ -219,7 +219,7 @@ public class Xowd_page_tbl implements RlsAble {
|
||||
public void Select_for_special_all_pages(Cancelable cancelable, List_adp rslt_list, Xowd_page_itm rslt_nxt, Xowd_page_itm rslt_prv, Int_obj_ref rslt_count, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item) {
|
||||
Xowd_page_itm nxt_itm = null;
|
||||
int rslt_idx = 0;
|
||||
boolean max_val_check = max_results == Int_.MaxValue;
|
||||
boolean max_val_check = max_results == Int_.Max_value;
|
||||
Db_rdr rdr = Load_ttls_starting_with_rdr(ns.Id(), key, include_redirects, max_results, min_page_len, browse_len, true, true);
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_pagelinks_tbl implements RlsAble {
|
||||
private final String tbl_name = "pagelinks"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_src_id, fld_trg_id;
|
||||
private final Db_conn conn;
|
||||
public Xowd_pagelinks_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_src_id = flds.Add_int("src_id");
|
||||
fld_trg_id = flds.Add_int("trg_id");
|
||||
flds.Add_int("trg_count");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Create_idx__src_trg() {conn.Ddl_create_idx(Gfo_usr_dlg_.I, Db_meta_idx.new_unique_by_tbl(tbl_name, "src_trg", fld_src_id, fld_trg_id));}
|
||||
public void Create_idx__trg_src() {conn.Ddl_create_idx(Gfo_usr_dlg_.I, Db_meta_idx.new_unique_by_tbl(tbl_name, "trg_src", fld_trg_id, fld_src_id));}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_pagelinks_temp_tbl implements RlsAble {
|
||||
private final String tbl_name = "pagelinks_temp"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_src_id, fld_trg_ns, fld_trg_ttl;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Xowd_pagelinks_temp_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
flds.Add_int_pkey_autonum("uid");
|
||||
fld_src_id = flds.Add_int("src_id");
|
||||
fld_trg_ns = flds.Add_int("trg_ns");
|
||||
fld_trg_ttl = flds.Add_str("trg_ttl", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Ddl_create_idx(Gfo_usr_dlg_.I, Db_meta_idx.new_normal_by_tbl(tbl_name, "main", fld_src_id, fld_trg_ns, fld_trg_ttl));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__pagelinks__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(int src_id, int trg_ns, byte[] trg_ttl) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_int(fld_src_id, src_id).Val_int(fld_trg_ns, trg_ns).Val_bry_as_str(fld_trg_ttl, trg_ttl).Exec_insert();
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class Xowd_site_ns_tbl {
|
||||
.Crt_int(fld_id, ns_id)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
return rdr.Move_next() ? Int_.cast_(rdr.Read_int(fld_count)) : 0;
|
||||
return rdr.Move_next() ? Int_.cast(rdr.Read_int(fld_count)) : 0;
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public void Update_ns_count(int ns_id, int ns_count) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Xowd_xowa_db_tbl {
|
||||
if (!schema_is_1) {
|
||||
ns_ids = rdr.Read_str(fld_ns_ids);
|
||||
part_id = rdr.Read_int(fld_part_id);
|
||||
guid = Guid_adp_.parse_(rdr.Read_str(fld_guid));
|
||||
guid = Guid_adp_.parse(rdr.Read_str(fld_guid));
|
||||
}
|
||||
list.Add(Xowd_db_file.load_(props, rdr.Read_int(fld_id), rdr.Read_byte(fld_type), wiki_root_dir.GenSubFil(rdr.Read_str(fld_url)), ns_ids, part_id, guid));
|
||||
}
|
||||
|
||||
@@ -50,6 +50,6 @@ public class Xow_abrv_xo_ {
|
||||
domain_bry = type.Domain_bry();
|
||||
}
|
||||
}
|
||||
return Xow_domain_itm_.parse(domain_bry); // for consolidation's sake, parse abrv to domain_bry and pass to Xow_domain_itm_.parse_()
|
||||
return Xow_domain_itm_.parse(domain_bry); // for consolidation's sake, parse abrv to domain_bry and pass to Xow_domain_itm_.parse()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,14 @@ import org.junit.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Xow_ttl__i18n_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Bidi() { // PURPOSE: handle bidirectional characters; DATE:2015-07-28
|
||||
fxt.Init_ttl("A\u00E2\u0080\u008E\u00E2\u0080\u008F\u00E2\u0080\u00AA\u00E2\u0080\u00AB\u00E2\u0080\u00AC\u00E2\u0080\u00AD\u00E2\u0080\u00AEB").Expd_page_txt("AB").Test();
|
||||
@Test public void Bidi() { // PURPOSE: handle bidirectional characters; DATE:2015-07-28; DATE:2015-08-24
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0x8E)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0x8F)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0xAA)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0xAB)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0xAC)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0xAD)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(0xE2, 0x80, 0xAE)) + "B").Expd_page_txt("AB").Test();
|
||||
}
|
||||
@Test public void Multi_byte_char2() { // PURPOSE: multi-byte HTML entity causes array out of index error; EX: w:List_of_Unicode_characters; DATE:2013-12-25
|
||||
fxt.Init_ttl("ⱥ").Expd_full_txt("ⱥ").Test();
|
||||
|
||||
@@ -19,9 +19,10 @@ package gplx.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
class Xow_ttl_fxt {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
public Xow_ttl_fxt Init_ttl(String raw) {test_raw = raw; return this;} private String test_raw = "";
|
||||
public Xow_ttl_fxt Expd_ns_id(int v) {expd_ns_id = v; return this;} private int expd_ns_id = Int_.MinValue;
|
||||
public Xow_ttl_fxt Expd_ns_id(int v) {expd_ns_id = v; return this;} private int expd_ns_id = Int_.Min_value;
|
||||
public Xow_ttl_fxt Expd_page_txt(String v) {expd_page_txt = v; return this;} private String expd_page_txt;
|
||||
public Xow_ttl_fxt Expd_page_url(String v) {expd_page_url = v; return this;} private String expd_page_url;
|
||||
public Xow_ttl_fxt Expd_page_db (String v) {expd_page_db = v; return this;} private String expd_page_db;
|
||||
public Xow_ttl_fxt Expd_full_txt(String v) {expd_full_txt = v; return this;} private String expd_full_txt;
|
||||
public Xow_ttl_fxt Expd_full_url(String v) {expd_full_url = v; return this;} private String expd_full_url;
|
||||
public Xow_ttl_fxt Expd_leaf_txt(String v) {expd_leaf_txt = v; return this;} private String expd_leaf_txt;
|
||||
@@ -46,7 +47,7 @@ class Xow_ttl_fxt {
|
||||
fxt.Reset();
|
||||
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("fr"), Bry_.new_a7("fr.wikipedia.org"));
|
||||
test_raw = "Test page";
|
||||
expd_ns_id = Int_.MinValue;
|
||||
expd_ns_id = Int_.Min_value;
|
||||
expd_xwik_txt = expd_full_txt = expd_full_url = expd_page_txt = expd_page_url = expd_leaf_txt = expd_leaf_url = expd_base_txt = expd_base_url
|
||||
= expd_root_txt = expd_rest_txt = expd_talk_txt = expd_talk_url = expd_subj_txt = expd_subj_url = expd_anch_txt
|
||||
= expd_base_txt_wo_qarg = expd_leaf_txt_wo_qarg = expd_qarg_txt = null;
|
||||
@@ -55,12 +56,13 @@ class Xow_ttl_fxt {
|
||||
fxt.Log_clear();
|
||||
}
|
||||
public void Test() {
|
||||
Xoa_ttl actl = Xoa_ttl.parse_(fxt.Wiki(), Bry_.new_u8(test_raw));
|
||||
Xoa_ttl actl = Xoa_ttl.parse(fxt.Wiki(), Bry_.new_u8(test_raw));
|
||||
if (expd_err == null) {
|
||||
if (expd_ns_id != Int_.MinValue) Tfds.Eq(expd_ns_id, actl.Ns().Id(), "ns");
|
||||
if (expd_ns_id != Int_.Min_value) Tfds.Eq(expd_ns_id, actl.Ns().Id(), "ns");
|
||||
if (expd_xwik_txt != null) Tfds.Eq(expd_xwik_txt, String_.new_u8(actl.Wik_txt()), "Wiki");
|
||||
if (expd_page_txt != null) Tfds.Eq(expd_page_txt, String_.new_u8(actl.Page_txt()), "Page_txt");
|
||||
if (expd_page_url != null) Tfds.Eq(expd_page_url, String_.new_u8(actl.Page_url()), "Page_url");
|
||||
if (expd_page_db != null) Tfds.Eq(expd_page_db , String_.new_u8(actl.Page_db()) , "Page_db");
|
||||
if (expd_full_txt != null) Tfds.Eq(expd_full_txt, String_.new_u8(actl.Full_txt()), "Full_txt");
|
||||
if (expd_full_url != null) Tfds.Eq(expd_full_url, String_.new_u8(actl.Full_url()), "Full_url");
|
||||
if (expd_leaf_txt != null) Tfds.Eq(expd_leaf_txt, String_.new_u8(actl.Leaf_txt()), "Leaf_txt");
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xow_lang_mgr_fxt {
|
||||
Xoae_app app;
|
||||
public void tst(String raw, String expd) {
|
||||
Xop_ctx ctx = wiki.Ctx();
|
||||
ctx.Cur_page().Ttl_(Xoa_ttl.parse_(wiki, Bry_.new_a7("test_page")));
|
||||
ctx.Cur_page().Ttl_(Xoa_ttl.parse(wiki, Bry_.new_a7("test_page")));
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(raw_bry);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xow_lang_mgr_tst {
|
||||
@Test public void Basic() {
|
||||
fxt.tst("[[simple:Earth]] [[fr:Terre]] [[es:Tierra]] [[de:Erde]] [[it:Terre]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 5) </h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 5) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
@@ -47,7 +47,7 @@ public class Xow_lang_mgr_tst {
|
||||
@Test public void Empty() {
|
||||
fxt.tst("[[simple:]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
@@ -63,7 +63,7 @@ public class Xow_lang_mgr_tst {
|
||||
// fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("zh"), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_a7("http://zh.wikipedia.org/~{0}"));
|
||||
fxt.tst("[[zh:Earth]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
@@ -78,7 +78,7 @@ public class Xow_lang_mgr_tst {
|
||||
@Test public void Anchor() {// PURPOSE: A#b was not showing anchor "#b"; DATE:2013-10-23
|
||||
fxt.tst("[[simple:A#b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
|
||||
Reference in New Issue
Block a user