1
0
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:
gnosygnu
2016-10-12 08:57:22 -04:00
parent e3b393650d
commit 3fc2e0741f
187 changed files with 3486 additions and 2984 deletions

View File

@@ -20,7 +20,7 @@ import gplx.core.primitives.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.wikis.dbs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.amps.*;
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*;
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.urls.*;
public class Dpl_xnde implements Xox_xnde {
private Dpl_itm itm = new Dpl_itm(); private List_adp pages = List_adp_.New();
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {} // NOTE: <dynamicPageList> has no attributes
@@ -117,7 +117,7 @@ class Dpl_page_finder {
}
}
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));
Xoctg_catpage_ctg ctg = wiki.Ctg__catpage_mgr().Get_or_load_or_null(Xoctg_catpage_url.New__blank(), wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, ctg_ttl), -1);
if (ctg == null) return;
// loop grps to get grp
@@ -158,7 +158,8 @@ class Dpl_page_finder {
int found_len = cur_regy.Count();
for (int j = 0; j < found_len; j++) { // if new_page is in cur, add it
Xoctg_catpage_itm cur_itm = (Xoctg_catpage_itm)cur_regy.Get_at(j);
if (ns_filter != Dpl_itm.Ns_filter_null && ns_filter != cur_itm.Page_ttl().Ns().Id()) continue;
Xoa_ttl cur_ttl = cur_itm.Page_ttl(); if (cur_ttl == null) continue;
if (ns_filter != Dpl_itm.Ns_filter_null && ns_filter != cur_ttl.Ns().Id()) continue;
tmp_id.Val_(cur_itm.Page_id()); // set tmp_id, since it will be used at least once
if (exclude_pages.Has(tmp_id)) continue; // ignore excluded pages
if (i != 0) { // skip logic for first ctg (which doesn't have a predecessor)

View File

@@ -307,9 +307,10 @@ class Dpl_xnde_fxt {
ary[i] = Dpl_page_mok.new_(++next_id, ttls[i]);
Init__create_ctg_pages(ctg, ary);
}
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));
public void Init__create_ctg_pages(String ctg_ttl, Dpl_page_mok... pages) {
Xoctg_catpage_ctg ctg = new Xoctg_catpage_ctg(1, Bry_.new_u8(ctg_ttl));
int pages_len = pages.length;
Xoctg_catpage_tmp tmp = new Xoctg_catpage_tmp();
for (int i = 0; i < pages_len; i++) {
Dpl_page_mok page = pages[i];
int id = page.Id();
@@ -320,12 +321,13 @@ class Dpl_xnde_fxt {
fxt.Init_page_create(ttl_str, ttl_str);
fxt.Init_id_create (id, 0, 0, false, 5, Xow_ns_.Tid__main, ttl_str);
}
Xoctg_catpage_itm captage_itm = new Xoctg_catpage_itm(page.Id(), ttl, ttl.Page_db());
captage_ctg.Pages().Itms__add(captage_itm);
byte tid = gplx.xowa.addons.wikis.ctgs.Xoa_ctg_mgr.Tid__page;
Xoctg_catpage_itm catpage_itm = Xoctg_catpage_itm.New_by_ttl(tid, page.Id(), ttl);
tmp.Add(catpage_itm);
}
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);
tmp.Make_by_ctg(ctg);
Xoctg_catpage_mgr catpage_mgr = fxt.Wiki().Ctg__catpage_mgr();
catpage_mgr.Cache__add(Bry_.new_u8("Category:" + ctg_ttl), ctg);
}
public String Make__html__itms__null(String... pages) {return this.Make__html(null, pages);}
public String Make__html(String itm_html, String... pages) {

View File

@@ -49,7 +49,7 @@ public class Pfunc_filepath_tst {
}
@Test public void Wiki_is_commons() {
fxt.Init_page_create(commons_wiki, "File:A.png", "");
commons_wiki.Tdb_fsys_mgr().Tdb_dir_regy()[Xotdb_dir_info_.Tid_page].Ext_tid_(gplx.core.ios.streams.Io_stream_.Tid_raw);
commons_wiki.Tdb_fsys_mgr().Tdb_dir_regy()[Xotdb_dir_info_.Tid_page].Ext_tid_(gplx.core.ios.streams.Io_stream_tid_.Tid__raw);
mock_wkr.Redirect_("A.png", "A.png").Repo_idx_(1);
fxt.Test_parse_tmpl_str_test("{{filepath:A.png}}", "{{test}}", "file:///mem/xowa/file/commons/trg/orig/7/0/1/c/A.png");
}

View File

@@ -292,9 +292,11 @@ public class Scrib_lib_mw implements Scrib_lib {
int fnc_name_len = fnc_name.length;
int fnc_name_colon_pos = Bry_find_.Find_fwd(fnc_name, Byte_ascii.Colon, 0, fnc_name_len);
if (fnc_name_colon_pos == Bry_find_.Not_found) {
Keyval arg_argx = (Keyval)rv.Get_at(0);
argx_ref.Val_(arg_argx.Val_to_bry());
rv.Del_at(0);
if (rv.Len() > 0) {
Keyval arg_argx = (Keyval)rv.Get_at(0);
argx_ref.Val_(arg_argx.Val_to_bry());
rv.Del_at(0);
}
}
else {
argx_ref.Val_(Bry_.Mid(fnc_name, fnc_name_colon_pos + 1, fnc_name_len));

View File

@@ -44,15 +44,45 @@ class Wdata_prop_val_visitor implements Wbase_claim_visitor {
bfr.Add(label);
}
public void Visit_quantity(Wbase_claim_quantity itm) {
byte[] amount_bry = itm.Amount();
long val = Bry_.To_long_or(amount_bry, Byte_ascii.Comma_bry, 0, amount_bry.length, 0); // NOTE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
// get val
byte[] val_bry = itm.Amount();
long val = Bry_.To_long_or(val_bry, Byte_ascii.Comma_bry, 0, val_bry.length, 0); // NOTE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
// get lo, hi
long lo = itm.Lbound_as_num().To_long();
long hi = itm.Ubound_as_num().To_long();
// fmt val
Xol_lang_itm lang = app.Lang_mgr().Get_by(lang_key);
bfr.Add(lang.Num_mgr().Format_num_by_long(val)); // amount; EX: 1,234
if (itm.Lbound_as_num().To_long() != val && itm.Ubound_as_num().To_long() != val) { // NOTE: do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
bfr.Add(Bry__quantity_margin_of_error); // symbol: EX: ±
if (lo == val && hi == val) // lo, hi, val are same; print val only;
bfr.Add(lang.Num_mgr().Format_num_by_long(val)); // amount; EX: 1,234
else {
long lo_dif = val - lo;
long hi_dif = hi - val;
if (lo_dif == hi_dif) { // lo_dif, hi_dif are same; print val±dif
bfr.Add(lang.Num_mgr().Format_num_by_long(val)); // amount; EX: 1,234
bfr.Add(Bry__quantity_margin_of_error); // symbol: EX: ±
bfr.Add(lang.Num_mgr().Format_num_by_long(lo_dif)); // amount; EX: 4
}
else { // lo_dif, hi_dif are diff; print lo - hi; this may not be what MW does
bfr.Add(lang.Num_mgr().Format_num_by_long(lo)); // lo; EX: 1,230
bfr.Add_byte(Byte_ascii.Dash); // dash: EX: -
bfr.Add(lang.Num_mgr().Format_num_by_long(hi)); // hi; EX: 1,238
}
}
// output unit
bfr.Add_byte_space();
int unit_qid_bgn = Bry_find_.Find_fwd(itm.Unit(), Wikidata_url);
if (unit_qid_bgn == Bry_find_.Not_found) // entity missing; just output unit literally
bfr.Add(itm.Unit()); // unit; EX: 1
else { // entity exists; EX:"http://www.wikidata.org/entity/Q11573" (meter)
byte[] xid = Bry_.Mid(itm.Unit(), Wikidata_url.length);
Wdata_doc entity_doc = wdata_mgr.Doc_mgr.Get_by_xid_or_null(xid);
bfr.Add(entity_doc.Label_list__get_or_fallback(lang));
}
}
private static final byte[] Wikidata_url = Bry_.new_a7("http://www.wikidata.org/entity/");
public void Visit_globecoordinate(Wbase_claim_globecoordinate itm) {
Wdata_prop_val_visitor_.Render__geo(bfr, itm.Lat(), itm.Lng());
}

View File

@@ -32,7 +32,7 @@ class Io_stream_rdr_mgr {
Io_url src_itm_url = src_itm.Url();
Io_stream_rdr rv = unzip_mgr.Handles(src_itm_url)
? unzip_mgr.New_rdr(src_itm_url)
: Io_stream_rdr_.file_(src_itm_url);
: Io_stream_rdr_.New__raw(src_itm_url);
rv.Len_(src_itm.Size());
return rv;
}
@@ -67,7 +67,7 @@ class Io_stream_unzip_mgr {
public Io_stream_rdr New_rdr(Io_url url) {
return stdout_enabled
? Io_stream_rdr_process.new_(stdout_process.Exe_url(), url, stdout_process.Xto_process_bldr_args(url.Raw()))
: Io_stream_rdr_.bzip2_(url)
: Io_stream_rdr_.New__bzip2(url)
;
}
}

View File

@@ -53,20 +53,33 @@ public class Wdata_pf_property__basic__tst {
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_geo(1, "6.789", "1.2345")));
fxt.Test_parse("{{#property:p1}}", "1.2345, 6.789");
}
@Test public void Quantity() {
@Test public void Quantity__plus_minus__y() {
fxt.Init_links_add("enwiki", "Test_page", "q1");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+1234", "2", "+1236", "+1232")));
fxt.Test_parse("{{#property:p1}}", "1,234±2");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+1234", "meter", "+1236", "+1232")));
fxt.Test_parse("{{#property:p1}}", "1,234±2 meter");
}
@Test public void Quantity__no_plus_minus() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
@Test public void Quantity__plus_minus__n() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
fxt.Init_links_add("enwiki", "Test_page", "q1");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+1234", "1", "+1234", "+1234")));
fxt.Test_parse("{{#property:p1}}", "1,234");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+1234", "meter", "+1234", "+1234")));
fxt.Test_parse("{{#property:p1}}", "1,234 meter");
}
@Test public void Quantity__range() { // PURPOSE:do not output ± if lbound == val == ubound; PAGE:en.w:Tintinan DATE:2015-08-02
fxt.Init_links_add("enwiki", "Test_page", "q1");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+1234", "meter", "+1236", "+1233")));
fxt.Test_parse("{{#property:p1}}", "1,233-1,236 meter");
}
@Test public void Quantity__long() { // PURPOSE: must cast to long for large numbers; EX:{{#property:P1082}} PAGE:en.w:Earth; DATE:2015-08-02
fxt.Init_links_add("enwiki", "Test_page", "q1");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+4321000000", "1", "4321000000", "4321000000")));
fxt.Test_parse("{{#property:p1}}", "4,321,000,000");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+4321000000", "meter", "4321000000", "4321000000")));
fxt.Test_parse("{{#property:p1}}", "4,321,000,000 meter");
}
@Test public void Quantity__unit__entity() {// PURPOSE: get entity name; EX:{{#invoke:Wikidata|getUnits|P2386|FETCH_WIKIDATA}} PAGE:en.w:Arecibo_Observatory; DATE:2016-10-11
fxt.Init_links_add("enwiki", "Test_page", "q1");
fxt.Init__docs__add(fxt.doc_("q1", fxt.Make_claim_quantity(1, "+1234", "http://www.wikidata.org/entity/q2", "+1236", "+1232")));
Wdata_doc wdoc = fxt.doc_("q2", fxt.Make_claim_string(2, "a"));
wdoc.Label_list().Add(Bry_.new_a7("en"), new gplx.xowa.xtns.wbases.core.Wdata_langtext_itm(Bry_.new_a7("en"), Bry_.new_a7("meter")));
fxt.Init__docs__add(wdoc);
fxt.Test_parse("{{#property:p1}}", "1,234±2 meter");
}
@Test public void Monolingualtext() {
fxt.Init_links_add("enwiki", "Test_page", "q1");

View File

@@ -0,0 +1,79 @@
/*
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.xowa_cmds.wiki_setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.xowa_cmds.*;
import gplx.langs.mustaches.*;
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.hosts.*;
import gplx.xowa.addons.bldrs.exports.packs.files.*;
import gplx.xowa.parsers.*;
class Xop_wiki_setup_mgr {
private final Mustache_tkn_parser parser = new Mustache_tkn_parser();
private Xobc_data_db data_db;
public Xop_root_tkn Write(Xoae_app app, Xowe_wiki wiki, Xop_ctx ctx, Xoae_page wpg, byte[] language, byte[][] wiki_domains) {
Io_url mustache_url = app.Fsys_mgr().Bin_addon_dir().GenSubFil_nest("bldr", "wiki_setup", "wiki_setup_main.mustache.html");
Mustache_tkn_itm root = parser.Parse(Io_mgr.Instance.LoadFilBry(mustache_url));
Mustache_render_ctx mctx = new Mustache_render_ctx();
Bry_bfr tmp_bfr = Bry_bfr_.New();
Mustache_bfr mbfr = new Mustache_bfr(tmp_bfr);
this.data_db = Xobc_data_db.New(app.Fsys_mgr());
root.Render(mbfr, mctx.Init(Make_root(language, wiki_domains)));
return wiki.Parser_mgr().Main().Parse_text_to_wdom(Xop_ctx.New__sub(wiki, ctx, wpg), mbfr.To_bry_and_clear(), true);
}
private Xows_root_itm Make_root(byte[] language, byte[][] wiki_domains) {
Bry_bfr url_list_bfr = Bry_bfr_.New();
int len = wiki_domains.length;
Xows_wiki_itm[] wiki_ary = new Xows_wiki_itm[len];
for (int i = 0; i < len; ++i) {
byte[] wiki_domain = wiki_domains[i];
wiki_ary[i] = new Xows_wiki_itm(wiki_domain, Make_task_ary(url_list_bfr, wiki_domain));
}
return new Xows_root_itm(language, url_list_bfr.To_bry_and_clear(), wiki_ary);
}
private Xows_task_itm[] Make_task_ary(Bry_bfr url_list_bfr, byte[] wiki_domain) {
Xobc_task_regy_itm[] task_rows = data_db.Tbl__task_regy().Select_by_wiki(wiki_domain);
int len = task_rows.length;
Xows_task_itm[] rv = new Xows_task_itm[len];
for (int i = 0; i < len; ++i) {
Xobc_task_regy_itm task_row = task_rows[i];
String[] task_key_parts = Pack_file_mgr.Task_key__parse(String_.new_u8(task_row.Key()));
String task_key_type = task_key_parts[2];
if (String_.Eq(task_key_type, "html")) task_key_type = "Articles";
else if (String_.Eq(task_key_type, "file")) task_key_type = "Images";
Xows_file_itm[] files = Make_file_ary(url_list_bfr, wiki_domain, task_row.Id());
rv[i] = new Xows_task_itm(task_row.Seqn(), wiki_domain, task_row.Name(), Bry_.new_u8(task_key_type), Bry_.Replace(Bry_.new_u8(task_key_parts[1]), Byte_ascii.Dot, Byte_ascii.Dash), files);
}
Array_.Sort(rv, new Xows_task_itm_sorter());
return rv;
}
private Xows_file_itm[] Make_file_ary(Bry_bfr url_list_bfr, byte[] wiki_domain, int task_id) {
Xobc_import_step_itm[] rows = data_db.Tbl__import_step().Select_by_task_id(task_id);
int len = rows.length;
Xows_file_itm[] rv = new Xows_file_itm[len];
Host_eval_itm host_eval = new Host_eval_itm();
for (int i = 0; i < len; ++i) {
Xobc_import_step_itm row = rows[i];
String src_fil = host_eval.Eval_src_fil(data_db, row.Host_id, gplx.xowa.wikis.domains.Xow_domain_itm_.parse(wiki_domain), row.Import_name);
url_list_bfr.Add_str_u8(src_fil).Add_byte_nl();
rv[i] = new Xows_file_itm(row.Step_id, Bry_.new_u8(src_fil));
}
Array_.Sort(rv, new Xows_file_itm_sorter());
return rv;
}
}

View File

@@ -0,0 +1,52 @@
/*
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.xowa_cmds.wiki_setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.xowa_cmds.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.htmls.*;
public class Xop_wiki_setup_xnde implements Xox_xnde, Mwh_atr_itm_owner2 {
private byte[] language;
private byte[][] wikis_ary;
private Xop_root_tkn root;
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, byte xatr_id) {
switch (xatr_id) {
case Xatr__language: language = xatr.Val_as_bry(); break;
case Xatr__wikis: wikis_ary = Bry_split_.Split(xatr.Val_as_bry(), Byte_ascii.Pipe_bry); break;
default: Gfo_usr_dlg_.Instance.Warn_many("", "", "unhandled xnde atr; key=~{0}", xatr.Key_bry()); break;
}
}
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
if (!wiki.Sys_cfg().Xowa_cmd_enabled()) { // not allowed; warn and exit
wiki.Appe().Usr_dlg().Warn_many("", "", "xowa_wiki_setup only allowed in xowa_home");
return;
}
Xox_xnde_.Parse_xatrs(wiki, this, xatr_hash, src, xnde);
this.root = new Xop_wiki_setup_mgr().Write(wiki.Appe(), wiki, ctx, ctx.Page(), language, wikis_ary);
}
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) {
html_wtr.Write_tkn_to_html(bfr, ctx, hctx, root.Root_src(), xnde, Xoh_html_wtr.Sub_idx_null, root);
//
}
public Xop_root_tkn Xtn_root() {throw Err_.new_unimplemented_w_msg("xowa_wiki_setup.xtn_root should not be called");}
public byte[] Xtn_html() {throw Err_.new_unimplemented_w_msg("xowa_wiki_setup.xtn_html should not be called");}
private static final byte Xatr__language = 1, Xatr__wikis = 2;
private static final Hash_adp_bry xatr_hash = Hash_adp_bry.ci_a7().Add_str_byte("language", Xatr__language).Add_str_byte("wikis", Xatr__wikis);
}

View File

@@ -0,0 +1,108 @@
/*
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.xowa_cmds.wiki_setups; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.xowa_cmds.*;
import gplx.langs.mustaches.*;
class Xows_root_itm implements Mustache_doc_itm {
private final byte[] language, url_list;
private final Xows_wiki_itm[] wiki_ary;
public Xows_root_itm(byte[] language, byte[] url_list, Xows_wiki_itm[] wiki_ary) {
this.language = language;
this.url_list = url_list;
this.wiki_ary = wiki_ary;
}
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "language")) bfr.Add_bry(language);
else if (String_.Eq(key, "url_list")) bfr.Add_bry(url_list);
else if (String_.Eq(key, "wikis__1st")) bfr.Add_bry(wiki_ary[0].Wiki_domain());
else return false;
return false;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "wikis")) return wiki_ary;
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_wiki_itm implements Mustache_doc_itm {
private final Xows_task_itm[] task_ary;
public Xows_wiki_itm(byte[] wiki_domain, Xows_task_itm[] task_ary) {
this.wiki_domain = wiki_domain;
this.task_ary = task_ary;
}
public byte[] Wiki_domain() {return wiki_domain;} private final byte[] wiki_domain;
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "wiki_domain")) bfr.Add_bry(wiki_domain);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "tasks")) return task_ary;
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_task_itm implements Mustache_doc_itm {
private final byte[] wiki_domain, task_full_name, task_name, task_date;
private final Xows_file_itm[] file_ary;
public Xows_task_itm(int seqn_id, byte[] wiki_domain, byte[] task_full_name, byte[] task_name, byte[] task_date, Xows_file_itm[] file_ary) {
this.seqn_id = seqn_id;
this.wiki_domain = wiki_domain; this.task_full_name = task_full_name; this.task_name = task_name; this.task_date = task_date;
this.file_ary = file_ary;
}
public int Seqn_id() {return seqn_id;} private final int seqn_id;
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "wiki_domain")) bfr.Add_bry(wiki_domain);
else if (String_.Eq(key, "task_name")) bfr.Add_bry(task_name);
else if (String_.Eq(key, "task_full_name")) bfr.Add_bry(task_full_name);
else if (String_.Eq(key, "task_date")) bfr.Add_bry(task_date);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
if (String_.Eq(key, "files")) return file_ary;
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_file_itm implements Mustache_doc_itm {
private final byte[] file_href;
public Xows_file_itm(int step_id, byte[] file_href) {
this.step_id = step_id;
this.file_href = file_href;
}
public int Step_id() {return step_id;} private final int step_id;
public boolean Mustache__write(String key, Mustache_bfr bfr) {
if (String_.Eq(key, "file_href")) bfr.Add_bry(file_href);
else return false;
return true;
}
public Mustache_doc_itm[] Mustache__subs(String key) {
return Mustache_doc_itm_.Ary__empty;
}
}
class Xows_task_itm_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Xows_task_itm lhs = (Xows_task_itm)lhsObj;
Xows_task_itm rhs = (Xows_task_itm)rhsObj;
return Int_.Compare(lhs.Seqn_id(), rhs.Seqn_id());
}
}
class Xows_file_itm_sorter implements gplx.core.lists.ComparerAble {
public int compare(Object lhsObj, Object rhsObj) {
Xows_file_itm lhs = (Xows_file_itm)lhsObj;
Xows_file_itm rhs = (Xows_file_itm)rhsObj;
return Int_.Compare(lhs.Step_id(), rhs.Step_id());
}
}