mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.9.4.1'
This commit is contained in:
@@ -89,12 +89,12 @@ class Dpl_page_finder {
|
||||
List_adp del_list = List_adp_.New();
|
||||
int ns_filter = itm.Ns_filter();
|
||||
Ordered_hash exclude_pages = Ordered_hash_.New();
|
||||
Find_excludes(exclude_pages, load_mgr, tmp_page, tmp_id, itm.Ctg_excludes());
|
||||
Find_excludes(exclude_pages, wiki, load_mgr, tmp_page, tmp_id, itm.Ctg_excludes());
|
||||
|
||||
for (int i = 0; i < includes_len; i++) { // loop over includes
|
||||
byte[] include = (byte[])includes.Get_at(i);
|
||||
cur_regy.Clear(); del_list.Clear();
|
||||
Find_pages_in_ctg(cur_regy, load_mgr, tmp_page, tmp_id, include);
|
||||
Find_pages_in_ctg(cur_regy, wiki, load_mgr, tmp_page, tmp_id, include);
|
||||
Del_old_pages_not_in_cur(i, tmp_id, old_regy, cur_regy, del_list);
|
||||
Add_cur_pages_also_in_old(i, tmp_id, old_regy, cur_regy, new_regy, exclude_pages, ns_filter);
|
||||
old_regy = new_regy;
|
||||
@@ -108,30 +108,35 @@ class Dpl_page_finder {
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ids(Cancelable_.Never, rv, 0, pages_len);
|
||||
rv.Sort_by(Xowd_page_itm_sorter.IdAsc);
|
||||
}
|
||||
private static void Find_excludes(Ordered_hash exclude_pages, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, List_adp exclude_ctgs) {
|
||||
private static void Find_excludes(Ordered_hash exclude_pages, Xowe_wiki wiki, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, List_adp exclude_ctgs) {
|
||||
if (exclude_ctgs == null) return;
|
||||
int exclude_ctgs_len = exclude_ctgs.Count();
|
||||
for (int i = 0; i < exclude_ctgs_len; i++) {
|
||||
byte[] exclude_ctg = (byte[])exclude_ctgs.Get_at(i);
|
||||
Find_pages_in_ctg(exclude_pages, load_mgr, tmp_page, tmp_id, exclude_ctg);
|
||||
Find_pages_in_ctg(exclude_pages, wiki, load_mgr, tmp_page, tmp_id, exclude_ctg);
|
||||
}
|
||||
}
|
||||
private static void Find_pages_in_ctg(Ordered_hash list, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, byte[] ctg_ttl) {
|
||||
Xoctg_catpage_ctg ctg = new Xoctg_catpage_ctg(ctg_ttl);
|
||||
load_mgr.Load_ctg_v1(ctg, ctg_ttl);
|
||||
private static void Find_pages_in_ctg(Ordered_hash rv, Xowe_wiki wiki, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, byte[] ctg_ttl) {
|
||||
Xoctg_catpage_ctg ctg = wiki.Html_mgr().Catpage_mgr().Get_or_load_or_null(wiki, wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, ctg_ttl));
|
||||
if (ctg == null) return;
|
||||
|
||||
for (byte ctg_tid = 0; ctg_tid < Xoa_ctg_mgr.Tid__max; ctg_tid++) {
|
||||
Xoctg_catpage_grp ctg_mgr = ctg.Grp_by_tid(ctg_tid); if (ctg_mgr == null) continue;
|
||||
int itms_len = ctg_mgr.Total();
|
||||
for (int i = 0; i < itms_len; i++) {
|
||||
Xoctg_catpage_itm ctg_itm = ctg_mgr.Itms()[i];
|
||||
int ctg_itm_id = ctg_itm.Page_id();
|
||||
if (list.Has(tmp_id.Val_(ctg_itm_id))) continue;
|
||||
list.Add(Int_obj_ref.New(ctg_itm_id), ctg_itm);
|
||||
// if (ctg_tid == Xoa_ctg_mgr.Tid_subc) { // recurse subcategories
|
||||
// load_mgr.Load_by_id(tmp_page, ctg_itm_id);
|
||||
// Find_pages_in_ctg(list, load_mgr, tmp_page, tmp_id, tmp_page.Ttl_wo_ns());
|
||||
// }
|
||||
// loop grps to get grp
|
||||
for (byte ctg_tid = 0; ctg_tid < Xoa_ctg_mgr.Tid___max; ++ctg_tid) {
|
||||
Xoctg_catpage_grp ctg_grp = ctg.Grp_by_tid(ctg_tid);
|
||||
int itms_len = ctg_grp.Itms__len();
|
||||
|
||||
// loop itms in grp and add to hash
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoctg_catpage_itm ctg_itm = ctg_grp.Itms__get_at(i);
|
||||
int itm_page_id = ctg_itm.Page_id();
|
||||
if (rv.Has(tmp_id.Val_(itm_page_id))) continue;
|
||||
rv.Add(Int_obj_ref.New(itm_page_id), ctg_itm);
|
||||
|
||||
// DELETE: recurse subcategories; PAGE:en.b:XML DATE:2016-09-18
|
||||
// if (ctg_tid == Xoa_ctg_mgr.Tid__subc) {
|
||||
// load_mgr.Load_by_id(tmp_page, itm_page_id);
|
||||
// Find_pages_in_ctg(rv, wiki, load_mgr, tmp_page, tmp_id, tmp_page.Ttl_page_db());
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,220 +17,261 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.dynamicPageList; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*; import gplx.core.strings.*; import gplx.xowa.apps.cfgs.*; import gplx.xowa.wikis.nss.*; import gplx.langs.htmls.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*;
|
||||
public class Dpl_xnde_tst {
|
||||
private final Dpl_xnde_fxt fxt = new Dpl_xnde_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Ctg() {
|
||||
fxt.Ctg_create("Ctg_0", "B", "A");
|
||||
fxt.Ul_pages("<DynamicPageList>category=Ctg_0</DynamicPageList>", fxt.Ul(Itm_html_null, "B", "A"));
|
||||
fxt.Init__create_ctg("Ctg_0", "B", "A");
|
||||
fxt.Exec__parse("<DynamicPageList>category=Ctg_0</DynamicPageList>");
|
||||
fxt.Test__html(fxt.Make__html__itms__null("B", "A"));
|
||||
}
|
||||
@Test public void Ctg_multiple() {
|
||||
fxt.Ctg_create_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
|
||||
fxt.Ctg_create_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));
|
||||
fxt.Ul_pages(String_.Concat_lines_nl
|
||||
fxt.Init__create_ctg_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
|
||||
fxt.Init__create_ctg_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "category=Ctg_1"
|
||||
, "</DynamicPageList>"
|
||||
), fxt.Ul(Itm_html_null, "A"));
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("A"));
|
||||
}
|
||||
@Test public void Ctg_multiple_none() { // PURPOSE: page must be in both categories
|
||||
fxt.Ctg_create("Ctg_0", "A");
|
||||
fxt.Ctg_create("Ctg_1", "B");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl
|
||||
fxt.Init__create_ctg("Ctg_0", "A");
|
||||
fxt.Init__create_ctg("Ctg_1", "B");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "category=Ctg_1"
|
||||
, "</DynamicPageList>"
|
||||
), "No pages meet these criteria.");
|
||||
);
|
||||
fxt.Test__html("No pages meet these criteria.");
|
||||
}
|
||||
@Test public void Notcategory() {
|
||||
fxt.Ctg_create_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
|
||||
fxt.Ctg_create_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));
|
||||
fxt.Ul_pages(String_.Concat_lines_nl
|
||||
fxt.Init__create_ctg_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
|
||||
fxt.Init__create_ctg_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "notcategory=Ctg_1"
|
||||
, "</DynamicPageList>"
|
||||
), fxt.Ul(Itm_html_null, "B"));
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("B"));
|
||||
}
|
||||
@Test public void Ctg_ascending() {
|
||||
fxt.Ctg_create("Ctg_0", "B", "A");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "B", "A");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "order=ascending"
|
||||
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("A", "B"));
|
||||
}
|
||||
@Test public void Ctg_ws() {
|
||||
fxt.Ctg_create("Ctg_0", "B", "A");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "B", "A");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, " category = Ctg_0 "
|
||||
, " order = ascending "
|
||||
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("A", "B"));
|
||||
}
|
||||
@Test public void Ctg_descending() {
|
||||
fxt.Ctg_create("Ctg_0", "A", "B");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A", "B");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "order=descending"
|
||||
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "B", "A"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("B", "A"));
|
||||
}
|
||||
@Test public void Nofollow() {
|
||||
fxt.Ctg_create("Ctg_0", "A", "B");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A", "B");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "nofollow=true"
|
||||
, "</DynamicPageList>"), fxt.Ul(" rel=\"nofollow\"", "A", "B"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html(" rel=\"nofollow\"", "A", "B"));
|
||||
}
|
||||
@Test public void Invalid_key() {
|
||||
fxt.Ctg_create("Ctg_0", "A", "B");
|
||||
fxt.Warns("dynamic_page_list:unknown_key: page=Test page key=invalid_key");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A", "B");
|
||||
fxt.Init__warns("dynamic_page_list:unknown_key: page=Test page key=invalid_key");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "invalid_key=invalid_val"
|
||||
, "category=Ctg_0"
|
||||
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("A", "B"));
|
||||
}
|
||||
@Test public void No_results() {
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "</DynamicPageList>"), "No pages meet these criteria.");
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html("No pages meet these criteria.");
|
||||
}
|
||||
@Test public void Suppress_errors() {
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "suppresserrors=true"
|
||||
, "</DynamicPageList>"), "");
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html("");
|
||||
}
|
||||
@Test public void Count() {
|
||||
fxt.Ctg_create("Ctg_0", "A", "B", "C");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A", "B", "C");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "count=2"
|
||||
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "A", "B"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("A", "B"));
|
||||
}
|
||||
@Test public void Offset() {
|
||||
fxt.Ctg_create("Ctg_0", "A", "B", "C");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A", "B", "C");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "offset=2"
|
||||
, "count=2"
|
||||
, "</DynamicPageList>"), fxt.Ul(Itm_html_null, "C"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("C"));
|
||||
}
|
||||
@Test public void Ns() {
|
||||
fxt.Ctg_create("Ctg_0", "Talk:A B", "B");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "Talk:A B", "B");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "namespace=Talk"
|
||||
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(Gfh_utl.Replace_apos_concat_lines
|
||||
( "<ul>"
|
||||
, " <li><a href='/wiki/Talk:A_B' title='Talk:A B'>A B</a></li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Show_ns() {
|
||||
fxt.Ctg_create("Ctg_0", "Talk:A");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "Talk:A");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "shownamespace=true"
|
||||
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(Gfh_utl.Replace_apos_concat_lines
|
||||
( "<ul>"
|
||||
, " <li><a href='/wiki/Talk:A' title='Talk:A'>Talk:A</a></li>"
|
||||
, "</ul>"
|
||||
));
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "shownamespace=false"
|
||||
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(Gfh_utl.Replace_apos_concat_lines
|
||||
( "<ul>"
|
||||
, " <li><a href='/wiki/Talk:A' title='Talk:A'>A</a></li>"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Comment() { // PURPOSE: comment should be ignored; en.n:Portal:Federally_Administered_Tribal_Areas; DATE:2014-01-18
|
||||
fxt.Ctg_create("Ctg_0", "B", "A");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl
|
||||
fxt.Init__create_ctg("Ctg_0", "B", "A");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "<!--category=Ctg_0-->"
|
||||
, "</DynamicPageList>"
|
||||
), fxt.Ul(Itm_html_null, "B", "A"));
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("B", "A"));
|
||||
}
|
||||
@Test public void Error_skip_line() { // PURPOSE: error should skip rest of line; was failing with array out of bounds; en.n:Portal:Austria/Wikipedia; DATE:2014-01-18
|
||||
fxt.Warns("dynamic_page_list:unknown_key: page=Test page key=Ctg_0 order"); // ignore warning message
|
||||
fxt.Ul_pages("<DynamicPageList> category=Ctg_0 order=descending</DynamicPageList>", "No pages meet these criteria.");
|
||||
fxt.Init__warns("dynamic_page_list:unknown_key: page=Test page key=Ctg_0 order"); // ignore warning message
|
||||
fxt.Exec__parse("<DynamicPageList> category=Ctg_0 order=descending</DynamicPageList>");
|
||||
fxt.Test__html("No pages meet these criteria.");
|
||||
}
|
||||
@Test public void Atr_has_template() { // PURPOSE: attribute also has template; DATE:2014-01-31
|
||||
fxt.Ctg_create("Test_page", "B", "A");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl
|
||||
fxt.Init__create_ctg("Test_page", "B", "A");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category={{PAGENAME}}"
|
||||
, "</DynamicPageList>"
|
||||
), fxt.Ul(Itm_html_null, "B", "A"));
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("B", "A"));
|
||||
}
|
||||
@Test public void Err_page_ns_doesnt_exist() {// PURPOSE: check that <dpl> is not enabled if wiki does not have Page / Index ns; PAGE:fr.w:Wikipedia:Le_Bistro/novembre_2006 DATE:2014-11-28
|
||||
fxt.Wiki().Ns_mgr().Clear().Init(); // call .Clear() to remove ns for Page / Index
|
||||
// reset categories to (a) remove ns for Page / Index; (b) add back Category (else null error)
|
||||
fxt.Wiki().Ns_mgr().Clear();
|
||||
fxt.Wiki().Ns_mgr().Add_new(14, "Category").Init();
|
||||
|
||||
fxt.Wiki().Cfg_parser().Xtns().Itm_pages().Reset(); // must reset to clear cached valid ns_page from previous tests
|
||||
fxt.Fxt().Test_parse_page_wiki_str("<dynamicpagelist>category=a</dynamicpagelist>", "No pages meet these criteria.");
|
||||
fxt.Wiki().Cfg_parser().Xtns().Itm_pages().Reset(); // must reset to clear cached invalid ns_page for next tests
|
||||
|
||||
// reset categories for rest of tests
|
||||
fxt.Wiki().Ns_mgr().Add_new(0, "").Init(); // call .Clear() to remove ns for Page / Index
|
||||
}
|
||||
@Test public void Ordermethod__invalid() { // PURPOSE: do not fail if ordermethod is invalid; PAGE:sr.d:Викиречник:Википројекат_1001_арапска_реч/Списак_уноса; DATE:2015-10-16
|
||||
fxt.Ctg_create("Ctg_0", "A", "B", "C");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A", "B", "C");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "ordermethod=ascending" // should not throw error
|
||||
, "ordermethod=sortkey"
|
||||
, "</DynamicPageList>")
|
||||
, fxt.Ul(Itm_html_null, "A", "B", "C"));
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(fxt.Make__html__itms__null("A", "B", "C"));
|
||||
}
|
||||
@Test public void Encode_spaces() {// PURPOSE:encode spaces in href; PAGE:en.q:Wikiquote:Speedy_deletions DATE:2016-01-19
|
||||
fxt.Ctg_create("Ctg_0", "A B");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A B");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "nofollow=true"
|
||||
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(Gfh_utl.Replace_apos_concat_lines
|
||||
( "<ul>"
|
||||
, " <li><a href='/wiki/A_B' title='A B' rel='nofollow'>A B</a></li>" // "/wiki/A_B" not "/wiki/A B"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Encode_quotes() {// PURPOSE:encode quotes; PAGE:en.b:Wikibooks:Alphabetical_classification/All_Books; DATE:2016-01-21
|
||||
fxt.Ctg_create("Ctg_0", "A\"B");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__create_ctg("Ctg_0", "A\"B");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "category=Ctg_0"
|
||||
, "nofollow=true"
|
||||
, "</DynamicPageList>"), Gfh_utl.Replace_apos_concat_lines
|
||||
, "</DynamicPageList>"
|
||||
);
|
||||
fxt.Test__html(Gfh_utl.Replace_apos_concat_lines
|
||||
( "<ul>"
|
||||
, " <li><a href='/wiki/A%22B' title='A"B' rel='nofollow'>A"B</a></li>" // "/wiki/A_B" not "/wiki/A B"
|
||||
, "</ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Err__bad_key_causes_out_of_bound() { // PURPOSE: bad key causes out of bounds error; PAGE:de.n:Portal:Brandenburg DATE:2016-04-21
|
||||
fxt.Warns("dynamic_page_list:unknown_key: page=Test page key=<DynamicPageList>category", "dynamic_page_list:unknown_key: page=Test page key=<DynamicPageList>category");
|
||||
fxt.Ul_pages(String_.Concat_lines_nl_skip_last
|
||||
fxt.Init__warns("dynamic_page_list:unknown_key: page=Test page key=<DynamicPageList>category", "dynamic_page_list:unknown_key: page=Test page key=<DynamicPageList>category");
|
||||
fxt.Exec__parse
|
||||
( "<DynamicPageList>"
|
||||
, "<DynamicPageList>category=A</DynamicPageList>a=b c=d"
|
||||
, "<DynamicPageList>category=B</DynamicPageList>"
|
||||
)
|
||||
, "No pages meet these criteria."
|
||||
);
|
||||
fxt.Test__html("No pages meet these criteria.");
|
||||
}
|
||||
private static final String Itm_html_null = null;
|
||||
}
|
||||
class Dpl_page_mok {
|
||||
public Dpl_page_mok(int id, String ttl) {this.id = id; this.ttl = ttl;}
|
||||
@@ -240,14 +281,17 @@ class Dpl_page_mok {
|
||||
}
|
||||
class Dpl_xnde_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
private String exec__raw;
|
||||
private int next_id;
|
||||
public void Clear() {
|
||||
next_id = 100;
|
||||
fxt.Reset();
|
||||
warns = String_.Ary_empty;
|
||||
this.exec__raw = String_.Empty;
|
||||
this.expd_warns = String_.Ary_empty;
|
||||
fxt.App().Usr_dlg().Gui_wkr().Clear();
|
||||
fxt.Wiki().Hive_mgr().Clear();
|
||||
fxt.Wiki().Db_mgr().Save_mgr().Clear(); // NOTE: must clear to reset next_id to 0; Ctg_create assumes clean slate from 0
|
||||
fxt.Wiki().Db_mgr().Save_mgr().Clear(); // NOTE: must clear to reset next_id to 0; Init__create_ctg assumes clean slate from 0
|
||||
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
|
||||
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
|
||||
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
|
||||
@@ -255,46 +299,50 @@ class Dpl_xnde_fxt {
|
||||
}
|
||||
public Xowe_wiki Wiki() {return fxt.Wiki();}
|
||||
public Xop_fxt Fxt() {return fxt;}
|
||||
public void Warns(String... v) {warns = v;} private String[] warns;
|
||||
public void Page_create(String page) {fxt.Init_page_create(page);}
|
||||
public void Ctg_create(String ctg, String... ttls) {
|
||||
public void Init__warns(String... v) {expd_warns = v;} private String[] expd_warns;
|
||||
public void Init__create_ctg(String ctg, String... ttls) {
|
||||
int len = ttls.length;
|
||||
Dpl_page_mok[] ary = new Dpl_page_mok[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
ary[i] = Dpl_page_mok.new_(++next_id, ttls[i]);
|
||||
Ctg_create_pages(ctg, ary);
|
||||
Init__create_ctg_pages(ctg, ary);
|
||||
}
|
||||
public void Ctg_create_pages(String ctg, Dpl_page_mok... pages) {
|
||||
public void Init__create_ctg_pages(String ctg, Dpl_page_mok... pages) {
|
||||
Xoctg_catpage_ctg captage_ctg = new Xoctg_catpage_ctg(Bry_.new_u8(ctg));
|
||||
int pages_len = pages.length;
|
||||
int[] page_ids = new int[pages_len];
|
||||
for (int i = 0; i < pages_len; i++) {
|
||||
Dpl_page_mok page = pages[i];
|
||||
int id = page.Id();
|
||||
String ttl = page.Ttl();
|
||||
Xoa_ttl page_ttl = Xoa_ttl.Parse(fxt.Wiki(), Bry_.new_u8(ttl));
|
||||
Xoae_page page_obj = fxt.Wiki().Data_mgr().Load_page_by_ttl(page_ttl);
|
||||
String ttl_str = page.Ttl();
|
||||
Xoa_ttl ttl = fxt.Wiki().Ttl_parse(Bry_.new_u8(ttl_str));
|
||||
Xoae_page page_obj = fxt.Wiki().Data_mgr().Load_page_by_ttl(ttl);
|
||||
if (page_obj.Db().Page().Exists_n()) {
|
||||
fxt.Init_page_create(ttl);
|
||||
fxt.Init_id_create (id, 0, 0, false, 5, Xow_ns_.Tid__main, ttl);
|
||||
fxt.Init_page_create(ttl_str, ttl_str);
|
||||
fxt.Init_id_create (id, 0, 0, false, 5, Xow_ns_.Tid__main, ttl_str);
|
||||
}
|
||||
page_ids[i] = id;
|
||||
Xoctg_catpage_itm captage_itm = new Xoctg_catpage_itm(page.Id(), ttl, ttl.Page_db());
|
||||
captage_ctg.Pages().Itms__add(captage_itm);
|
||||
}
|
||||
fxt.Init_ctg_create(ctg, page_ids);
|
||||
captage_ctg.Make_itms();
|
||||
Xoctg_catpage_mgr catpage_mgr = fxt.Wiki().Html_mgr().Catpage_mgr();
|
||||
catpage_mgr.Cache__add(Bry_.new_u8("Category:" + ctg), captage_ctg);
|
||||
}
|
||||
public String Ul(String itm_html, String... pages) {
|
||||
bfr.Add("<ul>").Add_char_nl();
|
||||
public String Make__html__itms__null(String... pages) {return this.Make__html(null, pages);}
|
||||
public String Make__html(String itm_html, String... pages) {
|
||||
bfr.Add_str_a7("<ul>").Add_byte_nl();
|
||||
int pages_len = pages.length;
|
||||
for (int i = 0; i < pages_len; i++) {
|
||||
String page = pages[i];
|
||||
bfr.Add(" <li><a href=\"/wiki/").Add(page).Add("\" title=\"").Add(page).Add("\"");
|
||||
if (itm_html != null) bfr.Add(itm_html);
|
||||
bfr.Add(">").Add(page).Add("</a></li>").Add_char_nl();
|
||||
bfr.Add_str_a7(" <li><a href=\"/wiki/").Add_str_a7(page).Add_str_a7("\" title=\"").Add_str_a7(page).Add_str_a7("\"");
|
||||
if (itm_html != null) bfr.Add_str_a7(itm_html);
|
||||
bfr.Add_str_a7(">").Add_str_a7(page).Add_str_a7("</a></li>").Add_byte_nl();
|
||||
}
|
||||
bfr.Add("</ul>").Add_char_nl();
|
||||
bfr.Add_str_a7("</ul>").Add_byte_nl();
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public void Ul_pages(String raw, String expd) {
|
||||
fxt.Test_parse_page_wiki_str(raw, expd);
|
||||
fxt.tst_Warn(warns);
|
||||
} String_bldr bfr = String_bldr_.new_();
|
||||
public void Exec__parse(String... raw_lines) {this.exec__raw = String_.Concat_lines_nl_skip_last(raw_lines);}
|
||||
public void Test__html(String expd) {
|
||||
fxt.Test_parse_page_wiki_str(exec__raw, expd);
|
||||
fxt.tst_Warn(expd_warns);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.flaggedRevs.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.flaggedRevs.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.libs.*;
|
||||
import gplx.xowa.xtns.pfuncs.exprs.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Flagged_revs_lib implements Scrib_lib {
|
||||
private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.pfuncs.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.libs.*;
|
||||
import gplx.xowa.xtns.pfuncs.exprs.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Pfunc_scrib_lib implements Scrib_lib {
|
||||
private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.xtns.pfuncs.ttls; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.envs.*; import gplx.core.caches.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.imgs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Pfunc_filepath extends Pf_func_base {
|
||||
@Override public boolean Func_require_colon_arg() {return true;}
|
||||
@@ -39,7 +39,7 @@ public class Pfunc_filepath extends Pf_func_base {
|
||||
Xof_repo_itm trg_repo = wiki.File_mgr().Repo_mgr().Repos_get_at(tmp_rslt.Repo_idx()).Trg();
|
||||
Xof_xfer_itm xfer_itm = ctx.Tmp_mgr().Xfer_itm();
|
||||
xfer_itm.Orig_ttl_and_redirect_(ttl_bry, Bry_.Empty); // redirect is empty b/c Get_page does all redirect lookups
|
||||
byte[] url = wiki.Parser_mgr().Url_bldr().Init_for_trg_html(Xof_repo_itm_.Mode_orig, trg_repo, ttl_bry, xfer_itm.Orig_ttl_md5(), xfer_itm.Orig_ext(), Xof_img_size.Size__neg1, Xof_lnki_time.Null, Xof_lnki_page.Null).Xto_bry();
|
||||
byte[] url = wiki.Parser_mgr().Url_bldr().Init_for_trg_html(trg_repo, Xof_img_mode_.Tid__orig, ttl_bry, xfer_itm.Orig_ttl_md5(), xfer_itm.Orig_ext(), Xof_img_size.Size__neg1, Xof_lnki_time.Null, Xof_lnki_page.Null).Xto_bry();
|
||||
bfr.Add(url);
|
||||
}
|
||||
public static Pfunc_filepath_itm Load_page(Xowe_wiki wiki, Xoa_ttl ttl) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import gplx.core.envs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.*; import gplx.xowa.xtns.scribunto.engines.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_core {
|
||||
private Hash_adp_bry mods = Hash_adp_bry.cs();
|
||||
private int expensive_function_count;
|
||||
|
||||
@@ -16,8 +16,8 @@ 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.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.*; import gplx.xowa.xtns.scribunto.engines.process.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.*; import gplx.xowa.xtns.scribunto.engines.process.*; import gplx.xowa.xtns.scribunto.procs.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
public class Scrib_invoke_func_fxt {
|
||||
private Xop_fxt fxt; Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); Scrib_core core; Process_server_mock server; Scrib_lua_rsp_bldr rsp_bldr = new Scrib_lua_rsp_bldr();
|
||||
public Xop_fxt Parser_fxt() {return fxt;}
|
||||
|
||||
@@ -16,6 +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.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public interface Scrib_lib {
|
||||
Scrib_proc_mgr Procs();
|
||||
Scrib_lib Init();
|
||||
|
||||
@@ -16,6 +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.xtns.scribunto.engines.luaj; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
import org.luaj.vm2.*; import org.luaj.vm2.lib.*; import org.luaj.vm2.lib.jse.*;
|
||||
import gplx.xowa.xtns.scribunto.engines.process.*;
|
||||
public class Luaj_engine implements Scrib_engine {
|
||||
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto.engines.mocks; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
|
||||
import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Mock_scrib_fxt {
|
||||
private final Mock_engine engine = new Mock_engine();
|
||||
private final Mock_server server = new Mock_server();
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.scribunto.engines.process; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
|
||||
import gplx.core.encoders.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.*; import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Process_engine implements Scrib_engine {
|
||||
private Scrib_core core; private Xoae_app app; private Scrib_xtn_mgr scrib_opts;
|
||||
private Process_recv_msg rsp = new Process_recv_msg(); private Process_send_wtr msg_encoder;
|
||||
|
||||
@@ -16,6 +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.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_html implements Scrib_lib {
|
||||
public Scrib_lib_html(Scrib_core core) {}
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.xtns.pfuncs.times.*; import gplx.xowa.langs.numbers.*; import gplx.xowa.xtns.pfuncs.numbers.*; import gplx.xowa.langs.durations.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_language implements Scrib_lib {
|
||||
public Scrib_lib_language(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -20,6 +20,7 @@ import gplx.core.primitives.*; import gplx.langs.htmls.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_message implements Scrib_lib {
|
||||
public Scrib_lib_message(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
@@ -105,7 +106,7 @@ class Scrib_lib_message_data {
|
||||
if (raw_msg_key != null) {
|
||||
Xol_msg_itm raw_msg_itm = new Xol_msg_itm(-1, Bry_.Empty);
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New(); // wiki.Utl__bfr_mkr().Get_b512();
|
||||
byte[] raw_msg_val = Xoa_gfs_php_mgr.Xto_gfs(tmp_bfr, raw_msg_key);
|
||||
byte[] raw_msg_val = Gfs_php_converter.To_gfs(tmp_bfr, raw_msg_key);
|
||||
Xol_msg_itm_.update_val_(raw_msg_itm, raw_msg_val);
|
||||
byte[] raw_msg_rv = wiki.Msg_mgr().Val_by_itm(tmp_bfr, raw_msg_itm, args);
|
||||
tmp_bfr.Mkr_rls();
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.core.primitives.*; import gplx.core.envs.*; import gplx.core.errs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.funcs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_mw implements Scrib_lib {
|
||||
private Scrib_core core; private Scrib_fsys_mgr fsys_mgr;
|
||||
public Scrib_lib_mw(Scrib_core core) {this.core = core; this.fsys_mgr = core.Fsys_mgr();}
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.addons.wikis.ctgs.*;
|
||||
import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_site implements Scrib_lib {
|
||||
public Scrib_lib_site(Scrib_core core) {this.core = core;} private final Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.core.bits.*;
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_text implements Scrib_lib {
|
||||
private final Scrib_lib_text__json_util json_util = new Scrib_lib_text__json_util();
|
||||
private final Scrib_lib_text__reindex_data reindex_data = new Scrib_lib_text__reindex_data();
|
||||
|
||||
@@ -21,6 +21,7 @@ import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.caches.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.files.commons.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.apps.wms.apis.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_title implements Scrib_lib {
|
||||
public Scrib_lib_title(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Scrib_lib_title_tst {
|
||||
}
|
||||
private static void Wiki_orig_tbl__insert(Xowe_wiki wiki, String ttl_str, int w, int h) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
wiki.File__orig_mgr().Insert(gplx.xowa.files.repos.Xof_repo_itm_.Repo_remote, ttl_bry, gplx.xowa.files.Xof_ext_.new_by_ttl_(ttl_bry).Id(), w, h, Bry_.Empty);
|
||||
wiki.File__orig_mgr().Insert(gplx.xowa.files.repos.Xof_repo_tid_.Tid__remote, ttl_bry, gplx.xowa.files.Xof_ext_.new_by_ttl_(ttl_bry).Id(), w, h, Bry_.Empty);
|
||||
}
|
||||
private static String ttl_fast(int ns_id, String ns_str, String ttl) {return ttl_fast(ns_id, ns_str, ttl, "", "", ttl);}
|
||||
private static String ttl_fast(int ns_id, String ns_str, String ttl, String anchor) {return ttl_fast(ns_id, ns_str, ttl, anchor, "", ttl);}
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.xowa.xtns.pfuncs.ttls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_uri implements Scrib_lib {
|
||||
public Scrib_lib_uri(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.langs.regxs.*; import gplx.core.intls.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_ustring implements Scrib_lib {
|
||||
private final String_surrogate_utl surrogate_utl = new String_surrogate_utl();
|
||||
public Scrib_lib_ustring(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
|
||||
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.langs.jsons.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.parsers.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
public Scrib_lib_wikibase(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.xowa.xtns.wbases.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Scrib_lib_wikibase_entity implements Scrib_lib {
|
||||
public Scrib_lib_wikibase_entity(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
|
||||
@@ -15,7 +15,7 @@ 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.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.scribunto.procs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.*;
|
||||
public class Scrib_proc {
|
||||
private Scrib_lib lib;
|
||||
@@ -15,52 +15,56 @@ 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.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.scribunto.procs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
public class Scrib_proc_args {
|
||||
private Keyval[] ary; private int ary_len;
|
||||
public Scrib_proc_args(Keyval[] v) {Init(v);}
|
||||
public int Len() {return ary_len;}
|
||||
public Scrib_proc_args(Keyval[] v) {
|
||||
// if 0 members, standardize to Keyval_.Ary_empty; could possibly find all callers of new Scrib_arg() and make sure that 0 == empty, but this is easier
|
||||
int v_len = v.length;
|
||||
if (v_len == 0) {
|
||||
ary = Keyval_.Ary_empty;
|
||||
ary_len = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// find ary_len
|
||||
int v_max = -1;
|
||||
for (int i = 0; i < v_len; ++i) {
|
||||
Keyval kv = v[i];
|
||||
int idx = Int_.cast(kv.Key_as_obj());
|
||||
if (v_max < idx) v_max = idx;
|
||||
}
|
||||
this.ary_len = v_max;
|
||||
|
||||
// keys are in sequential order; EX: [1:a,2:b,3:c]
|
||||
if (v_max == v_len)
|
||||
this.ary = v;
|
||||
// keys are not in sequential order, or there are gaps; EX: [1:a,3:c]
|
||||
else {
|
||||
ary = new Keyval[ary_len];
|
||||
for (int i = 0; i < v_len; i++) {
|
||||
Keyval kv = v[i];
|
||||
int idx = Int_.cast(kv.Key_as_obj());
|
||||
ary[idx - List_adp_.Base1] = kv;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int Len() {return ary_len;}
|
||||
public Keyval[] Ary() {return ary;}
|
||||
public boolean Pull_bool(int i) {return Bool_.cast(Get_or_fail(i));}
|
||||
public Object Pull_obj(int i) {return Get_or_fail(i);}
|
||||
public boolean Pull_bool(int i) {return Bool_.cast(Get_or_fail(i));}
|
||||
public String Pull_str(int i) {return String_.cast(Get_or_fail(i));}
|
||||
public byte[] Pull_bry(int i) {return Bry_.new_u8(String_.cast(Get_or_fail(i)));}
|
||||
public Keyval[] Pull_kv_ary_safe(int idx) { // NOTE: must check for null array items; EX:[2:v2] -> [1:null,2:v2]; PAGE:en.d:Category:Nouns_by_language DATE:2016-04-29
|
||||
Keyval[] rv = (Keyval[])Get_or_fail(idx);
|
||||
List_adp list = null;
|
||||
int rv_len = rv.length;
|
||||
for (int i = 0; i < rv_len; ++i) {
|
||||
Keyval kv = rv[i];
|
||||
if ( kv.Key_tid() == Type_adp_.Tid__int // luaj will be int
|
||||
|| kv.Key_tid() == Type_adp_.Tid__obj) { // lua will be obj; note that luaj will also have other non-key objects
|
||||
Object key_obj = kv.Key_as_obj();
|
||||
if (key_obj.getClass() == Int_.Cls_ref_type) { // key is int; cast it
|
||||
int key_int = Int_.cast(kv.Key_as_obj());
|
||||
if (key_int != i + 1) { // key_int should match i; if not, then gaps exist; EX:[2:v2] should be 2nd element, not 1st
|
||||
if (list == null) {
|
||||
list = List_adp_.New();
|
||||
rv = null;
|
||||
}
|
||||
for (int j = 0; j < key_int - 1; ++j) // add everything up to key_int as null; EX: [2:v2] -> [1:null]
|
||||
list.Add(Keyval_.int_(j + List_adp_.Base1, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rv == null)
|
||||
list.Add(kv);
|
||||
}
|
||||
if (rv == null)
|
||||
rv = (Keyval[])list.To_ary(Keyval.class);
|
||||
return rv;
|
||||
}
|
||||
public int Pull_int(int i) {Object rv = Get_or_fail(i);
|
||||
try {return Int_.coerce_(rv);} // coerce to handle "1" and 1; will still fail if "abc" is passed
|
||||
public int Pull_int(int i) {
|
||||
try {return Int_.coerce_(Get_or_fail(i));} // coerce to handle "1" and 1; will still fail if "abc" is passed
|
||||
catch (Exception e) {
|
||||
Err_.Noop(e);
|
||||
throw Err_.new_wo_type("bad argument; int expected", "idx", i, "len", ary_len);
|
||||
}
|
||||
}
|
||||
public long Pull_long(int i) {return (long)Pull_double(i);}
|
||||
public double Pull_double(int i) {Object rv = Get_or_fail(i);
|
||||
public double Pull_double(int i) {
|
||||
Object rv = Get_or_fail(i);
|
||||
try {return Int_.coerce_(rv);} // coerce to handle "1" and 1; will still fail if "abc" is passed
|
||||
catch (Exception e) {
|
||||
Err_.Noop(e);
|
||||
@@ -71,18 +75,52 @@ public class Scrib_proc_args {
|
||||
}
|
||||
}
|
||||
}
|
||||
public Object Pull_obj(int i) {return Get_or_fail(i);}
|
||||
public Keyval[] Pull_kv_ary_safe(int idx) { // NOTE: must check for null array items; EX:[1:a,3:c] -> [1:a,2:null,3:c]; PAGE:en.d:Category:Nouns_by_language DATE:2016-04-29
|
||||
Keyval[] rv = (Keyval[])Get_or_fail(idx);
|
||||
int rv_len = rv.length;
|
||||
|
||||
List_adp list = null; // list for out-of-order; lazy-instantiation
|
||||
int prv_key = -1; // mark previous itm_key; needed to reconstruct keys for gaps
|
||||
// loop itms and handle out-of-order; note that in most cases, itms should be in-order and proc will just return rv; DATE:2016-09-12
|
||||
for (int i = 0; i < rv_len; ++i) {
|
||||
Keyval kv = rv[i];
|
||||
// get integer-key; needed to handle gaps
|
||||
if ( kv.Key_tid() == Type_adp_.Tid__int // luaj will be int
|
||||
|| kv.Key_tid() == Type_adp_.Tid__obj) { // lua will be obj; note that luaj will also have other non-key objects
|
||||
Object key_obj = kv.Key_as_obj();
|
||||
if (key_obj.getClass() == Int_.Cls_ref_type) { // key is int; cast it
|
||||
int expd_key = i + List_adp_.Base1; // EX: i=1; expd_key=2
|
||||
int actl_key = Int_.cast(kv.Key_as_obj()); // EX: i=1; actl_key=3
|
||||
if (actl_key != expd_key) { // mismatch; gaps exist; EX:[1:a,3:c]
|
||||
// 1st mismatch; create list, and add everything before itm in array to list;
|
||||
if (list == null) {
|
||||
list = List_adp_.New();
|
||||
for (int j = 0; j < i; ++j)
|
||||
list.Add(rv[j]); // NOTE: everything before i is in sequence, so just add it directly
|
||||
prv_key = i + 1; // EX: i=1; prv_key=2;
|
||||
}
|
||||
for (int j = prv_key; j < actl_key; ++j) // add everything up to actl_key as null; EX: [1:a,3:c] -> [1:a,2:null]
|
||||
list.Add(Keyval_.int_(j, null));
|
||||
prv_key = actl_key + 1; // EX: i=3; prv_key=4
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list != null)
|
||||
list.Add(kv);
|
||||
}
|
||||
return (list == null)
|
||||
? rv
|
||||
: (Keyval[])list.To_ary(Keyval.class);
|
||||
}
|
||||
public String Cast_str_or(int i, String or) {Object rv = Get_or_null(i); return rv == null ? or : String_.cast (rv);}
|
||||
public String Cast_str_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : String_.cast (rv);}
|
||||
public byte[] Cast_bry_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Bry_.new_u8(String_.cast (rv));} // NOTE: cast is deliberate; Scrib call checkType whi
|
||||
public byte[] Cast_bry_or_empty(int i) {Object rv = Get_or_null(i); return rv == null ? Bry_.Empty : Bry_.new_u8(String_.cast (rv));}
|
||||
public byte[] Cast_bry_or(int i, byte[] or) {Object rv = Get_or_null(i); return rv == null ? or : Bry_.new_u8(String_.cast (rv));}
|
||||
public Object Cast_obj_or_null(int i) {return Get_or_null(i);}
|
||||
public boolean Cast_bool_or_y(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.Y : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_n(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.N : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_y(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.Y : Bool_.cast(rv);}
|
||||
public boolean Cast_bool_or_n(int i) {Object rv = Get_or_null(i); return rv == null ? Bool_.N : Bool_.cast(rv);}
|
||||
public int Cast_int_or(int i, int or) {Object rv = Get_or_null(i); return rv == null ? or : Int_.coerce_(rv);} // coerce to handle "1" and 1;
|
||||
public String Xstr_str_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Object_.Xto_str_loose_or(rv, null);} // NOTE: Modules can throw exceptions in which return value is nothing; do not fail; return ""; EX: -logy; DATE:2013-10-14
|
||||
public byte[] Xstr_bry_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Bry_.new_u8(Object_.Xto_str_loose_or(rv, null));}
|
||||
public Keyval[] Cast_kv_ary_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : (Keyval[])rv;}
|
||||
public byte[][] Cast_params_as_bry_ary_or_rest_of_ary(int params_idx) { // PAGE:ru.w:Ленин,_Владимир_Ильич; DATE:2014-07-01 MW:LanguageLibrary.php|ConvertPlural: if (is_array($args[0])) $args = $args[0]; $forms = array_values(array_map('strval', $args));
|
||||
if (params_idx < 0 || params_idx >= ary_len) return Bry_.Ary_empty;
|
||||
@@ -107,6 +145,8 @@ public class Scrib_proc_args {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
public String Xstr_str_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Object_.Xto_str_loose_or(rv, null);} // NOTE: Modules can throw exceptions in which return value is nothing; do not fail; return ""; EX: -logy; DATE:2013-10-14
|
||||
public byte[] Xstr_bry_or_null(int i) {Object rv = Get_or_null(i); return rv == null ? null : Bry_.new_u8(Object_.Xto_str_loose_or(rv, null));}
|
||||
public byte[] Extract_qry_args(Xowe_wiki wiki, int idx) {
|
||||
Object qry_args_obj = Cast_obj_or_null(idx);
|
||||
if (qry_args_obj == null) return Bry_.Empty;
|
||||
@@ -131,32 +171,6 @@ public class Scrib_proc_args {
|
||||
return Bry_.Empty;
|
||||
}
|
||||
}
|
||||
private void Init(Keyval[] v) {
|
||||
int v_len = v.length;
|
||||
if (v_len == 0) {
|
||||
ary = Keyval_.Ary_empty;
|
||||
ary_len = 0;
|
||||
return;
|
||||
}
|
||||
int v_max = -1;
|
||||
for (int i = 0; i < v_len; i++) {
|
||||
Keyval kv = v[i];
|
||||
int idx = Int_.cast(kv.Key_as_obj());
|
||||
if (v_max < idx) v_max = idx;
|
||||
}
|
||||
this.ary_len = v_max;
|
||||
if (v_max == v_len) { // keys are in sequential order; EX: [1:a,2:b,3:c]
|
||||
this.ary = v;
|
||||
}
|
||||
else { // keys are not in sequential order, or there are gaps; EX: [1:a,3:c]
|
||||
ary = new Keyval[ary_len];
|
||||
for (int i = 0; i < v_len; i++) {
|
||||
Keyval kv = v[i];
|
||||
int idx = Int_.cast(kv.Key_as_obj());
|
||||
ary[idx - List_adp_.Base1] = kv;
|
||||
}
|
||||
}
|
||||
}
|
||||
private Object Get_or_null(int i) {
|
||||
if (i < 0 || i >= ary_len) return null;
|
||||
Keyval kv = ary[i];
|
||||
@@ -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.xtns.scribunto.procs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Scrib_proc_args__tst {
|
||||
private final Scrib_proc_args__fxt fxt = new Scrib_proc_args__fxt();
|
||||
@Test public void Pull_kv_ary__basic() { // PURPOSE.assert:
|
||||
fxt.Init(Keyval_.int_(1, Keyval_.Ary(Keyval_.int_(1, "a"), Keyval_.int_(2, "b"), Keyval_.int_(3, "c"))));
|
||||
fxt.Test__pull_kv_ary(0, Keyval_.int_(1, "a"), Keyval_.int_(2, "b"), Keyval_.int_(3, "c"));
|
||||
}
|
||||
@Test public void Pull_kv_ary__gaps() { // PURPOSE.fix: gaps cause null-ref; PAGE:en.w:Shalkar_District DATE:2016-09-12
|
||||
fxt.Init(Keyval_.int_(1, Keyval_.Ary(Keyval_.int_(1, "a"), Keyval_.int_(3, "c"), Keyval_.int_(5, "e"))));
|
||||
fxt.Test__pull_kv_ary(0, Keyval_.int_(1, "a"), Keyval_.int_(2, null), Keyval_.int_(3, "c"), Keyval_.int_(4, null), Keyval_.int_(5, "e"));
|
||||
}
|
||||
@Test public void Pull_kv_ary__gaps__many() { // PURPOSE.assert:
|
||||
fxt.Init(Keyval_.int_(1, Keyval_.Ary(Keyval_.int_(1, "a"), Keyval_.int_(4, "d"), Keyval_.int_(5, "e"), Keyval_.int_(8, "h"))));
|
||||
fxt.Test__pull_kv_ary(0
|
||||
, Keyval_.int_(1, "a"), Keyval_.int_(2, null), Keyval_.int_(3, null), Keyval_.int_(4, "d"), Keyval_.int_(5, "e")
|
||||
, Keyval_.int_(6, null), Keyval_.int_(7, null), Keyval_.int_(8, "h")
|
||||
);
|
||||
}
|
||||
}
|
||||
class Scrib_proc_args__fxt {
|
||||
private Scrib_proc_args args;
|
||||
public void Init(Keyval... ary) {this.args = new Scrib_proc_args(ary);}
|
||||
public void Test__pull_kv_ary(int idx, Keyval... expd) {
|
||||
Keyval[] actl = args.Pull_kv_ary_safe(idx);
|
||||
Gftest.Eq__str(Keyval_.Ary_to_str(expd), Keyval_.Ary_to_str(actl));
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ 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.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.scribunto.procs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
public class Scrib_proc_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public void Clear() {hash.Clear();}
|
||||
@@ -15,7 +15,7 @@ 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.xtns.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
package gplx.xowa.xtns.scribunto.procs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
public class Scrib_proc_rslt {
|
||||
private Keyval[] ary;
|
||||
public Keyval[] Ary() {return ary;}
|
||||
@@ -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.xtns.titleBlacklists; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.libs.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.scribunto.libs.*; import gplx.xowa.xtns.scribunto.procs.*;
|
||||
public class Blacklist_scrib_lib implements Scrib_lib {
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
public Scrib_lib Init() {procs.Init_by_lib(this, Proc_names); return this;}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
private final Xoae_app app;
|
||||
private final Wdata_prop_val_visitor prop_val_visitor;
|
||||
private final Wdata_doc_parser wdoc_parser_v1 = new Wdata_doc_parser_v1(), wdoc_parser_v2 = new Wdata_doc_parser_v2();
|
||||
private final Object thread_lock =new Object();
|
||||
private Wdata_hwtr_mgr hwtr_mgr;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(32);
|
||||
public Wdata_wiki_mgr(Xoae_app app) {
|
||||
@@ -50,7 +51,16 @@ public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
Doc_mgr.Enabled_(v);
|
||||
}
|
||||
public byte[] Domain() {return domain;} public void Domain_(byte[] v) {domain = v;} private byte[] domain = Bry_.new_a7("www.wikidata.org");
|
||||
public Xowe_wiki Wdata_wiki() {if (wdata_wiki == null) wdata_wiki = app.Wiki_mgr().Get_by_or_make(domain).Init_assert(); return wdata_wiki;} private Xowe_wiki wdata_wiki;
|
||||
public Xowe_wiki Wdata_wiki() {
|
||||
if (wdata_wiki == null) {
|
||||
synchronized (thread_lock) { // LOCK:must synchronized b/c multiple threads may init wdata_mgr at same time;
|
||||
Xowe_wiki tmp_wdata_wiki = app.Wiki_mgr().Get_by_or_make(domain).Init_assert();
|
||||
if (wdata_wiki == null) // synchronized is not around "if (wdata_wiki == null)", so multiple threads may try to set; only set if null; DATE:2016-09-12
|
||||
wdata_wiki = tmp_wdata_wiki;
|
||||
}
|
||||
}
|
||||
return wdata_wiki;
|
||||
} private Xowe_wiki wdata_wiki;
|
||||
public Json_parser Jdoc_parser() {return jdoc_parser;} private Json_parser jdoc_parser = new Json_parser();
|
||||
public void Init_by_app() {}
|
||||
public Wdata_doc_parser Wdoc_parser(Json_doc jdoc) {
|
||||
@@ -61,7 +71,7 @@ public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
}
|
||||
public Xop_log_property_wkr Property_wkr() {return property_wkr;} private Xop_log_property_wkr property_wkr;
|
||||
public void Clear() {
|
||||
synchronized (wdoc_parser_v2) { // LOCK:app-level
|
||||
synchronized (thread_lock) { // LOCK:app-level
|
||||
Qid_mgr.Clear();
|
||||
Pid_mgr.Clear();
|
||||
Doc_mgr.Clear();
|
||||
@@ -72,14 +82,14 @@ public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
Wdata_doc wdoc = Doc_mgr.Get_by_bry_or_null(qid); if (wdoc == null) return or;
|
||||
Wbase_claim_grp claim_grp = wdoc.Claim_list_get(pid); if (claim_grp == null || claim_grp.Len() == 0) return or;
|
||||
Wbase_claim_base claim_itm = claim_grp.Get_at(0);
|
||||
synchronized (tmp_bfr) { // LOCK:must synchronized b/c prop_val_visitor has member bfr which can get overwritten; DATE:2016-07-06
|
||||
synchronized (thread_lock) { // LOCK:must synchronized b/c prop_val_visitor has member bfr which can get overwritten; DATE:2016-07-06
|
||||
prop_val_visitor.Init(tmp_bfr, hwtr_mgr.Msgs(), domain.Lang_orig_key());
|
||||
claim_itm.Welcome(prop_val_visitor);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public void Resolve_to_bfr(Bry_bfr bfr, Wbase_claim_grp prop_grp, byte[] lang_key) {
|
||||
synchronized (this) { // LOCK:must synchronized b/c prop_val_visitor has member bfr which can get overwritten; DATE:2016-07-06
|
||||
synchronized (thread_lock) { // LOCK:must synchronized b/c prop_val_visitor has member bfr which can get overwritten; DATE:2016-07-06
|
||||
Hwtr_mgr_assert();
|
||||
int len = prop_grp.Len();
|
||||
Wbase_claim_base selected = null;
|
||||
|
||||
Reference in New Issue
Block a user