mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.2.1'
This commit is contained in:
@@ -16,9 +16,10 @@ 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; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.xndes.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.xndes.*;
|
||||
import gplx.langs.htmls.docs.*;
|
||||
public class Xox_xnde_ {
|
||||
public static Mwh_atr_itm[] Xatr__set(Xowe_wiki wiki, Mwh_atr_itm_owner owner, Hash_adp_bry hash, byte[] src, Xop_xnde_tkn xnde) {
|
||||
public static Mwh_atr_itm[] Xatr__set(Xowe_wiki wiki, Mwh_atr_itm_owner1 owner, Hash_adp_bry hash, byte[] src, Xop_xnde_tkn xnde) {
|
||||
Mwh_atr_itm[] rv = wiki.Appe().Parser_mgr().Xnde__parse_atrs(src, xnde.Atrs_bgn(), xnde.Atrs_end());
|
||||
int len = rv.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@@ -27,4 +28,19 @@ public class Xox_xnde_ {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static Mwh_atr_itm[] Parse_xatrs(Xowe_wiki wiki, Mwh_atr_itm_owner2 owner, Hash_adp_bry hash, byte[] src, Xop_xnde_tkn xnde) {
|
||||
Mwh_atr_itm[] rv = wiki.Appe().Parser_mgr().Xnde__parse_atrs(src, xnde.Atrs_bgn(), xnde.Atrs_end());
|
||||
int len = rv.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Mwh_atr_itm xatr = rv[i]; if (xatr.Invalid()) continue;
|
||||
byte xatr_tid = hash.Get_as_byte_or(xatr.Key_bry(), Byte_.Max_value_127);
|
||||
owner.Xatr__set(wiki, src, xatr, xatr_tid);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static Gfh_tag_rdr New_tag_rdr(Xop_ctx ctx, byte[] src, Xop_xnde_tkn xnde) {
|
||||
Gfh_tag_rdr rv = Gfh_tag_rdr.New__custom();
|
||||
rv.Init(ctx.Page().Url_bry_safe(), src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.xtns.cites; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Ref_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Ref_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
public byte[] Name() {return name;} public Ref_nde Name_(byte[] v) {name = v; return this;} private byte[] name = Bry_.Empty;
|
||||
public byte[] Group() {return group;} private byte[] group = Bry_.Empty;
|
||||
public byte[] Follow() {return follow;} private byte[] follow = Bry_.Empty;
|
||||
@@ -59,7 +59,7 @@ public class Ref_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
html_wtr.Ref_wtr().Xnde_ref(hctx, bfr, src, xnde);
|
||||
}
|
||||
private static final Ref_nde[] Ary_empty = new Ref_nde[0];
|
||||
private static final Ref_nde[] Ary_empty = new Ref_nde[0];
|
||||
public Ref_nde[] Related() {return related;} Ref_nde[] related = Ary_empty;
|
||||
public int Related_len() {return related_len;} private int related_len;
|
||||
public Ref_nde Related_get(int i) {return related[i];}
|
||||
@@ -74,9 +74,8 @@ public class Ref_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
}
|
||||
public static final int Idx_minor_follow = -2;
|
||||
public static final byte Xatr_id_name = 0, Xatr_id_group = 1, Xatr_id_follow = 2;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_obj("name", Byte_obj_val.new_(Ref_nde.Xatr_id_name))
|
||||
.Add_str_obj("group", Byte_obj_val.new_(Ref_nde.Xatr_id_group))
|
||||
.Add_str_obj("follow", Byte_obj_val.new_(Ref_nde.Xatr_id_follow));
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.xtns.cites; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class References_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class References_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
public byte[] Group() {return group;} public References_nde Group_(byte[] v) {group = v; return this;} private byte[] group = Bry_.Empty;
|
||||
public int List_idx() {return list_idx;} public References_nde List_idx_(int v) {list_idx = v; return this;} private int list_idx;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {
|
||||
@@ -54,6 +54,6 @@ public class References_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
}
|
||||
private static final byte Xatr_id_group = 0;
|
||||
public static boolean Enabled = true;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_obj("group", Byte_obj_val.new_(References_nde.Xatr_id_group));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Gallery_xnde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Gallery_xnde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
private Gallery_xtn_mgr xtn_mgr;
|
||||
public byte Mode() {return mode;} private byte mode;
|
||||
public int Itm_w() {return itm_w;} private int itm_w = Null;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.indicators; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Indicator_xnde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Indicator_xnde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
public String Name() {return name;} private String name;
|
||||
public byte[] Html() {return html;} private byte[] html;
|
||||
public void Init_for_test(String name, byte[] html) {this.name = name; this.html = html;} // TEST
|
||||
@@ -39,6 +39,6 @@ public class Indicator_xnde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
if (this.name == null) bfr.Add_str_a7("Error: Page status indicators' name attribute must not be empty.");
|
||||
}
|
||||
private static final byte Xatr_name = 0;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_obj("name", Byte_obj_val.new_(Xatr_name));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.primitives.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Listing_xnde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Listing_xnde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
public Listing_xnde(int tag_id) {}
|
||||
private byte[] xatr_name, xatr_alt, xatr_address, xatr_directions, xatr_phone, xatr_tollfree, xatr_email, xatr_fax, xatr_url, xatr_hours, xatr_price, xatr_checkin, xatr_checkout;
|
||||
private int xatr_lat = Xatr_meridian_null, xatr_long = Xatr_meridian_null;
|
||||
@@ -209,7 +209,7 @@ public class Listing_xnde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
return position_text.Fmt(tmp_bfr, rv);
|
||||
}
|
||||
private static final int Xatr_meridian_null = 361;
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Tag_strong = Bry_.new_a7("strong")
|
||||
, Tag_a = Bry_.new_a7("a")
|
||||
, Tag_em = Bry_.new_a7("em")
|
||||
@@ -227,7 +227,7 @@ public class Listing_xnde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
, Txt_dot_space = Bry_.new_a7(". ")
|
||||
, Txt_mailto = Bry_.new_a7("mailto:")
|
||||
;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Bry__invk_bgn = gplx.xowa.parsers.tmpls.Xop_curly_bgn_lxr.Hook
|
||||
, Bry__invk_end = gplx.xowa.parsers.tmpls.Xop_curly_end_lxr.Hook
|
||||
;
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.xtns.lst; import gplx.*; import gplx.xowa.*; import gplx.xowa.
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Lst_section_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Lst_section_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
public byte[] Section_name() {return section_name;} private byte[] section_name;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {
|
||||
if (xatr_id_obj == null) return;
|
||||
|
||||
@@ -146,8 +146,9 @@ public class Pgbnr_func extends Pf_func_base {
|
||||
itm.Init_from_html(max_width, banner_file, banner_url, srcset, cfg.enable_heading_override, toc_html);
|
||||
|
||||
Mustache_render_ctx mctx = new Mustache_render_ctx().Init(itm);
|
||||
wiki.Xtn_mgr().Xtn_pgbnr().Template_root().Render(tmp_bfr, mctx);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
Mustache_bfr mbfr = Mustache_bfr.New_bfr(tmp_bfr);
|
||||
wiki.Xtn_mgr().Xtn_pgbnr().Template_root().Render(mbfr, mctx);
|
||||
return mbfr.To_bry_and_clear();
|
||||
}
|
||||
private static byte[][] Get_standard_size_urls(Xow_wiki wiki, Pgbnr_cfg cfg, Xoa_ttl banner_ttl) {
|
||||
Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
@@ -183,8 +184,8 @@ public class Pgbnr_func extends Pf_func_base {
|
||||
Xof_file_itm file_itm = ctx.Wiki().Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(Xof_exec_tid.Tid_wiki_page, ctx, ctx.Page(), lnki);
|
||||
return file_itm;
|
||||
}
|
||||
private static final byte[] Bry__yes = Bry_.new_a7("yes"), Bry__icon = Bry_.new_a7("icon-"), Bry__icon_href_dflt = Bry_.new_a7("#"), Bry__origin_x__left = Bry_.new_a7("wpb-left"), Bry__origin_x__right = Bry_.new_a7("wpb-right");
|
||||
private static final byte[] Bry__yes = Bry_.new_a7("yes"), Bry__icon = Bry_.new_a7("icon-"), Bry__icon_href_dflt = Bry_.new_a7("#"), Bry__origin_x__left = Bry_.new_a7("wpb-left"), Bry__origin_x__right = Bry_.new_a7("wpb-right");
|
||||
private static final int Arg__pgname = 0, Arg__tooltip = 1, Arg__bottomtoc = 2, Arg__toc = 3, Arg__icon = 4, Arg__origin = 5;
|
||||
private static final Hash_adp_bry arg_hash = Hash_adp_bry.cs().Add_str_int("pgname", Arg__pgname)
|
||||
private static final Hash_adp_bry arg_hash = Hash_adp_bry.cs().Add_str_int("pgname", Arg__pgname)
|
||||
.Add_str_int("tooltip", Arg__tooltip).Add_str_int("bottomtoc", Arg__bottomtoc).Add_str_int("toc", Arg__toc).Add_str_int("origin", Arg__origin);
|
||||
}
|
||||
|
||||
@@ -19,22 +19,23 @@ package gplx.xowa.xtns.pagebanners; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
public class Pgbnr_icon implements Mustache_doc_itm {
|
||||
private final byte[] name, title, href, html;
|
||||
private final byte[] name, title, href, html;
|
||||
public Pgbnr_icon(Bry_bfr tmp_bfr, byte[] name, byte[] title, byte[] href) {
|
||||
this.name = name; this.title = title; this.href = href;
|
||||
fmt.Bld_many(tmp_bfr, name, title);
|
||||
this.html = tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Get_prop(String key) {
|
||||
if (String_.Eq(key, "name")) return name;
|
||||
else if (String_.Eq(key, "title")) return title;
|
||||
else if (String_.Eq(key, "url")) return href;
|
||||
else if (String_.Eq(key, "html")) return html;
|
||||
return Mustache_doc_itm_.Null_val;
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "name")) bfr.Add_bry(name);
|
||||
else if (String_.Eq(key, "title")) bfr.Add_bry(title);
|
||||
else if (String_.Eq(key, "url")) bfr.Add_bry(href);
|
||||
else if (String_.Eq(key, "html")) bfr.Add_bry(html);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Get_subs(String key) {return Mustache_doc_itm_.Ary__empty;}
|
||||
public static final Pgbnr_icon[] Ary_empty = new Pgbnr_icon[0];
|
||||
public static final Bry_fmt fmt = Bry_fmt.New
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {return Mustache_doc_itm_.Ary__empty;}
|
||||
public static final Pgbnr_icon[] Ary_empty = new Pgbnr_icon[0];
|
||||
public static final Bry_fmt fmt = Bry_fmt.New
|
||||
( Bry_.New_u8_nl_apos("<span aria-disabled='false' title='~{title}' class='oo-ui-widget oo-ui-widget-enabled oo-ui-iconElement-icon oo-ui-icon-~{name} oo-ui-iconElement oo-ui-iconWidget'></span>")
|
||||
, "name", "title"
|
||||
);
|
||||
|
||||
@@ -44,21 +44,22 @@ public class Pgbnr_itm implements Mustache_doc_itm {
|
||||
this.isHeadingOverrideEnabled = isHeadingOverrideEnabled;
|
||||
this.toc = toc;
|
||||
}
|
||||
public byte[] Get_prop(String key) {
|
||||
if (String_.Eq(key, "title")) return banner_hdr_text;
|
||||
else if (String_.Eq(key, "tooltip")) return banner_anch_title;
|
||||
else if (String_.Eq(key, "bannerfile")) return banner_anch_href;
|
||||
else if (String_.Eq(key, "banner")) return banner_img_src;
|
||||
else if (String_.Eq(key, "html_uid")) return Bry_.new_u8(gplx.xowa.htmls.Xoh_img_mgr.Str__html_uid + Int_.To_str(html_uid));
|
||||
else if (String_.Eq(key, "srcset")) return srcset == null ? Bry_.Empty : Bry_.Empty;
|
||||
else if (String_.Eq(key, "originx")) return originx;
|
||||
else if (String_.Eq(key, "data-pos-x")) return Bry_.new_a7(Double_.To_str(data_pos_x));
|
||||
else if (String_.Eq(key, "data-pos-y")) return Bry_.new_a7(Double_.To_str(data_pos_y));
|
||||
else if (String_.Eq(key, "maxWidth")) return Int_.To_bry(maxWidth);
|
||||
else if (String_.Eq(key, "toc")) return toc;
|
||||
return Mustache_doc_itm_.Null_val;
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "title")) bfr.Add_bry(banner_hdr_text);
|
||||
else if (String_.Eq(key, "tooltip")) bfr.Add_bry(banner_anch_title);
|
||||
else if (String_.Eq(key, "bannerfile")) bfr.Add_bry(banner_anch_href);
|
||||
else if (String_.Eq(key, "banner")) bfr.Add_bry(banner_img_src);
|
||||
else if (String_.Eq(key, "html_uid")) bfr.Add_bry(Bry_.new_u8(gplx.xowa.htmls.Xoh_img_mgr.Str__html_uid + Int_.To_str(html_uid)));
|
||||
else if (String_.Eq(key, "srcset")) bfr.Add_bry(srcset == null ? Bry_.Empty : Bry_.Empty);
|
||||
else if (String_.Eq(key, "originx")) bfr.Add_bry(originx);
|
||||
else if (String_.Eq(key, "data-pos-x")) bfr.Add_double(data_pos_x);
|
||||
else if (String_.Eq(key, "data-pos-y")) bfr.Add_double(data_pos_y);
|
||||
else if (String_.Eq(key, "maxWidth")) bfr.Add_int(maxWidth);
|
||||
else if (String_.Eq(key, "toc")) bfr.Add_bry(toc);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Get_subs(String key) {
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "icons")) return icons;
|
||||
else if (String_.Eq(key, "hasIcons")) return Mustache_doc_itm_.Ary__bool(icons.length > 0);
|
||||
else if (String_.Eq(key, "bottomtoc")) return Mustache_doc_itm_.Ary__bool(bottomtoc);
|
||||
|
||||
@@ -20,6 +20,7 @@ import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.xtns.pfuncs.ifs.*; import gplx.xowa.xtns.pfuncs.times.*; import gplx.xowa.xtns.pfuncs.numbers.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.xowa.xtns.pfuncs.langs.*; import gplx.xowa.xtns.pfuncs.strings.*; import gplx.xowa.xtns.pfuncs.stringutils.*; import gplx.xowa.xtns.pfuncs.pages.*; import gplx.xowa.xtns.pfuncs.wikis.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Pf_func_ {
|
||||
public static byte[] Eval_arg_or_empty(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk self, int self_args_len, int i) {return Eval_arg_or(ctx, src, caller, self, self_args_len, i, Bry_.Empty);}
|
||||
public static final byte Name_dlm = Byte_ascii.Colon;
|
||||
@@ -42,7 +43,7 @@ public class Pf_func_ {
|
||||
nde.Val_tkn().Tmpl_evaluate(ctx, src, caller, bfr);
|
||||
return bfr.To_bry_and_clear_and_trim();
|
||||
}
|
||||
private static final Number_parser lhs_parser = new Number_parser().Hex_enabled_(true), rhs_parser = new Number_parser().Hex_enabled_(true);
|
||||
private static final Number_parser lhs_parser = new Number_parser().Hex_enabled_(true), rhs_parser = new Number_parser().Hex_enabled_(true);
|
||||
public static boolean Eq_(byte[] lhs, byte[] rhs) { // PATCH.PHP: php allows "003" == "3.0"; ASSUME: numbers are either int or int-like decimal; long, float, decimal not supported
|
||||
int lhs_len = lhs.length, rhs_len = rhs.length;
|
||||
boolean rv = true;
|
||||
@@ -63,17 +64,17 @@ public class Pf_func_ {
|
||||
if (rhs_parser.Has_err()) return false;
|
||||
return lhs_parser.Has_frac() || rhs_parser.Has_frac() ? lhs_parser.Rv_as_dec().Eq(rhs_parser.Rv_as_dec()) : lhs_parser.Rv_as_int() == rhs_parser.Rv_as_int();
|
||||
}
|
||||
public static void Reg(gplx.xowa.langs.funcs.Xol_func_regy func_regy, Xol_lang_itm lang) {
|
||||
public static void Reg(Xow_domain_itm domain_itm, gplx.xowa.langs.funcs.Xol_func_regy func_regy, Xol_lang_itm lang) {
|
||||
Xol_kwd_mgr kwd_mgr = lang.Kwd_mgr();
|
||||
int[] kwd_ary = Ary_get(!lang.Kwd_mgr__strx());
|
||||
int[] kwd_ary = Ary_get(domain_itm, !lang.Kwd_mgr__strx());
|
||||
int len = kwd_ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
int id = kwd_ary[i];
|
||||
func_regy.Reg_defn(kwd_mgr, id, Get_prototype(id));
|
||||
}
|
||||
}
|
||||
public static int[] Ary_get(boolean wmf) {
|
||||
if (wmf) return Ary_wmf;
|
||||
public static int[] Ary_get(Xow_domain_itm domain_itm, boolean wmf) {
|
||||
if (wmf && domain_itm != null && domain_itm.Domain_type().Tid() != Xow_domain_tid_.Int__home) return Ary_wmf;
|
||||
if (Ary_nonwmf == null) {
|
||||
List_adp list = List_adp_.new_();
|
||||
int len = Ary_wmf.length;
|
||||
@@ -96,7 +97,7 @@ public class Pf_func_ {
|
||||
return Ary_nonwmf;
|
||||
}
|
||||
private static int[] Ary_nonwmf = null;
|
||||
private static final int[] Ary_wmf = new int[]
|
||||
private static final int[] Ary_wmf = new int[]
|
||||
{ Xol_kwd_grp_.Id_utc_year
|
||||
, Xol_kwd_grp_.Id_utc_month_int_len2
|
||||
, Xol_kwd_grp_.Id_utc_month_int
|
||||
@@ -428,6 +429,6 @@ class Pf_func_bang extends Pf_func_base {
|
||||
@Override public int Id() {return Xol_kwd_grp_.Id_bang;}
|
||||
@Override public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {bfr.Add_byte_pipe();}
|
||||
@Override public Pf_func New(int id, byte[] name) {return this;}
|
||||
public static final Pf_func_bang Instance = new Pf_func_bang();
|
||||
public static final Pf_func_bang Instance = new Pf_func_bang();
|
||||
Pf_func_bang() {this.Name_(Byte_ascii.Bang_bry);}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.xtns.lst.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.xowa.parsers.lnkis.files.*;
|
||||
public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
private boolean xtn_literal = false;
|
||||
private Xop_root_tkn xtn_root;
|
||||
private byte[] index_ttl_bry, bgn_page_bry, end_page_bry, bgn_sect_bry, end_sect_bry;
|
||||
@@ -123,7 +123,7 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
if (header != null)
|
||||
rv = Bld_wikitext_for_header(full_bfr, index_page, rv);
|
||||
return rv;
|
||||
} private static final byte[] Toc_bry = Bry_.new_a7("toc");
|
||||
} private static final byte[] Toc_bry = Bry_.new_a7("toc");
|
||||
private byte[] Make_lnki(Bry_bfr full_bfr, byte[] index_page_src, Xop_lnki_tkn lnki) {
|
||||
byte[] caption = Get_caption(full_bfr, index_page_src, lnki);
|
||||
full_bfr.Add(Xop_tkn_.Lnki_bgn);
|
||||
@@ -149,7 +149,7 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Bry_tmpl = Bry_.new_a7("{{:MediaWiki:Proofreadpage_header_template")
|
||||
, Bry_value = Bry_.new_a7("|value=")
|
||||
, Bry_toc_cur = Bry_.new_a7("|current=")
|
||||
@@ -402,8 +402,8 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
, Xatr_toc_prv = 11
|
||||
, Xatr_toc_nxt = 12
|
||||
;
|
||||
public static final Xoa_ttl[] Ttls_null = null;
|
||||
private static final Number_parser num_parser = new Number_parser().Ignore_space_at_end_y_(); // ignore space at end; PAGE:en.s:1911_Encyclop<6F>dia_Britannica/Boissier,_Marie_Louis_Antoine_Gaston DATE:2015-04-29
|
||||
public static final Xoa_ttl[] Ttls_null = null;
|
||||
private static final Number_parser num_parser = new Number_parser().Ignore_space_at_end_y_(); // ignore space at end; PAGE:en.s:1911_Encyclop<6F>dia_Britannica/Boissier,_Marie_Louis_Antoine_Gaston DATE:2015-04-29
|
||||
private String Fail_msg_suffix() {
|
||||
String excerpt = Bry_fmtr.Escape_tilde(String_.new_u8(Bry_.Mid_by_len_safe(src, xnde_tkn.Src_bgn(), 32)));
|
||||
return String_.Format(" ttl={0} src={1}", String_.new_u8(cur_page_ttl.Full_db()), excerpt);
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Score_xnde implements Xox_xnde, Mwh_atr_itm_owner, Xoh_cmd_itm {
|
||||
public class Score_xnde implements Xox_xnde, Mwh_atr_itm_owner1, Xoh_cmd_itm {
|
||||
public boolean Lang_is_abc() {return lang_is_abc;} private boolean lang_is_abc;
|
||||
public boolean Code_is_raw() {return code_is_raw;} private boolean code_is_raw;
|
||||
public boolean Output_midi() {return output_midi;} private boolean output_midi;
|
||||
@@ -187,7 +187,7 @@ public class Score_xnde implements Xox_xnde, Mwh_atr_itm_owner, Xoh_cmd_itm {
|
||||
return Bry_.Mid(rslt, bgn_pos, end_pos);
|
||||
}
|
||||
public static final byte Xatr_id_lang_is_abc = 0, Xatr_id_code_is_raw = 1, Xatr_id_output_midi = 2, Xatr_id_output_ogg = 3, Xatr_id_file_midi = 4, Xatr_id_file_ogg = 5;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("lang", Xatr_id_lang_is_abc)
|
||||
.Add_str_byte("raw", Xatr_id_code_is_raw)
|
||||
.Add_str_byte("midi", Xatr_id_output_midi)
|
||||
@@ -195,7 +195,7 @@ public class Score_xnde implements Xox_xnde, Mwh_atr_itm_owner, Xoh_cmd_itm {
|
||||
.Add_str_byte("over"+"ride_midi", Xatr_id_file_midi)
|
||||
.Add_str_byte("over"+"ride_ogg", Xatr_id_file_ogg)
|
||||
;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Lang_abc = Bry_.new_a7("ABC")
|
||||
, Abc_tagline_bgn = Bry_.new_a7("tagline ="), Abc_tagline_end = new byte[] {Byte_ascii.Nl}, Abc_tagline_repl = Bry_.new_a7("tagline = \"\"\n")
|
||||
, Version_unknown = Bry_.new_a7("unknown"), Version_find_bgn = Bry_.new_a7("GNU LilyPond")
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.xtns.syntax_highlights; import gplx.*; import gplx.xowa.*; imp
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Synh_xtn_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Synh_xtn_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
private byte[] lang = Bry_.Empty; private byte[] style = null; private byte[] enclose = Bry_.Empty;
|
||||
private boolean line_enabled = false; private int start = 1; private Int_rng_mgr highlight_idxs = Int_rng_mgr_null.Instance;
|
||||
public Xop_xnde_tkn Xnde() {throw Err_.new_unimplemented();}
|
||||
@@ -45,7 +45,7 @@ public class Synh_xtn_nde implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
Synh_xtn_nde_.Make(bfr, app, src, xnde.Tag_open_end(), xnde.Tag_close_bgn(), lang, enclose, style, line_enabled, start, highlight_idxs);
|
||||
}
|
||||
private static final byte Xatr_enclose = 1, Xatr_lang = 2, Xatr_style = 3, Xatr_line = 4, Xatr_start = 5, Xatr_highlight = 6;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("enclose" , Xatr_enclose)
|
||||
.Add_str_byte("inline" , Xatr_enclose)
|
||||
.Add_str_byte("lang" , Xatr_lang)
|
||||
|
||||
@@ -19,9 +19,10 @@ package gplx.xowa.xtns.translates; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.specials.*;
|
||||
public class Xop_mylanguage_page implements Xows_page {
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__my_language;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__my_language;}
|
||||
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
|
||||
// Special:MyLanguage/Help:A -> Help:A/fr
|
||||
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
|
||||
byte[] page_bry = ttl.Leaf_txt_wo_qarg(); // EX: Help:A
|
||||
byte[] lang_key = wiki.Appe().Usere().Lang().Key_bry(); // EX: fr
|
||||
byte[] trg_bry = page_bry;
|
||||
@@ -32,4 +33,6 @@ public class Xop_mylanguage_page implements Xows_page {
|
||||
if (found_page.Missing() && !lang_is_english) // foreign lang does not exist; default to english
|
||||
wiki.Data_mgr().Redirect(page, page_bry);
|
||||
}
|
||||
|
||||
public Xows_page Special__clone() {return this;}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class Xop_mylanguage_page_fxt {
|
||||
page.Url_(url);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7(link));
|
||||
page.Ttl_(ttl);
|
||||
special_page.Special_gen(wiki, page, url, ttl);
|
||||
special_page.Special__gen(wiki, page, url, ttl);
|
||||
Tfds.Eq(expd, String_.new_a7(page.Url().Page_bry()));
|
||||
Tfds.Eq(expd, String_.new_a7(page.Data_raw()));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xob_wbase_json_dump_cmd implements Xob_cmd {
|
||||
this.json_dump_parser = new Xob_wbase_json_dump_parser(bldr, wiki);
|
||||
}
|
||||
public String Cmd_key() {return Xob_cmd_keys.Key_wbase_json_dump;}
|
||||
public Xob_cmd Cmd_new(Xob_bldr bldr, Xowe_wiki wiki) {return null;}
|
||||
public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return null;}
|
||||
public void Cmd_run() {json_dump_parser.Parse(src_fil);}
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
|
||||
@@ -24,9 +24,9 @@ import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
import gplx.xowa.xtns.wdatas.core.*; import gplx.xowa.xtns.wdatas.parsers.*;
|
||||
class Xob_wbase_json_dump_db {
|
||||
private final Gfo_usr_dlg usr_dlg; private final Xoae_app app; private final Xowe_wiki wiki; private final Xob_bldr bldr;
|
||||
private final Json_parser json_parser;
|
||||
private final Xob_wdata_pid_sql pid_cmd = new Xob_wdata_pid_sql(); private final Xob_wdata_qid_sql qid_cmd = new Xob_wdata_qid_sql();
|
||||
private final Gfo_usr_dlg usr_dlg; private final Xoae_app app; private final Xowe_wiki wiki; private final Xob_bldr bldr;
|
||||
private final Json_parser json_parser;
|
||||
private final Xob_wdata_pid_sql pid_cmd = new Xob_wdata_pid_sql(); private final Xob_wdata_qid_sql qid_cmd = new Xob_wdata_qid_sql();
|
||||
private Xowd_page_tbl page_tbl;
|
||||
private Xob_ns_to_db_mgr ns_to_db_mgr;
|
||||
private DateAdp page_modified_on;
|
||||
@@ -86,7 +86,7 @@ class Xob_wbase_json_dump_db {
|
||||
Xowd_db_file db_core = db_mgr.Db__core();
|
||||
db_core.Tbl__site_stats().Update(page_count_main, page_id, ns_mgr.Ns_file().Count()); // save page stats
|
||||
db_core.Tbl__ns().Insert(ns_mgr); // save ns
|
||||
db_mgr.Tbl__cfg().Insert_str(Xow_cfg_consts.Grp__wiki_init, "props.modified_latest", page_modified_on.XtoStr_fmt(DateAdp_.Fmt_iso8561_date_time));
|
||||
db_mgr.Tbl__cfg().Insert_str(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__modified_latest, page_modified_on.XtoStr_fmt(DateAdp_.Fmt_iso8561_date_time));
|
||||
}
|
||||
private static final byte[] id_key = Bry_.new_a7("id");
|
||||
private static final byte[] id_key = Bry_.new_a7("id");
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ public class Xob_wdata_db_cmd extends Xob_dump_mgr_base implements Xob_cmd {
|
||||
@Override public String Cmd_key() {return Xob_cmd_keys.Key_wbase_db;}
|
||||
@Override public byte Init_redirect() {return Bool_.N_byte;} // json will never be found in a redirect
|
||||
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Tid__main, Wdata_wiki_mgr.Ns_property);}
|
||||
@Override protected void Init_reset(Db_conn p) {
|
||||
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(p, "xowa_cfg");
|
||||
@Override protected void Init_reset(Db_conn conn) {
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
|
||||
cfg_tbl.Delete_all();
|
||||
}
|
||||
@Override protected Db_conn Init_db_file() {
|
||||
|
||||
@@ -24,8 +24,9 @@ public class Wdata_itemByTitle_page implements Xows_page {
|
||||
private static final byte[] Arg_site = Bry_.new_a7("site"), Arg_page = Bry_.new_a7("page");
|
||||
public Bry_fmtr Html_fmtr() {return html_fmtr;}
|
||||
private Wdata_itemByTitle_cfg cfg;
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__item_by_title;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__item_by_title;}
|
||||
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
|
||||
if (cfg == null) cfg = (Wdata_itemByTitle_cfg)wiki.Appe().Special_mgr().Get_or_null(Wdata_itemByTitle_cfg.Key);
|
||||
// Special:ItemByTitle/enwiki/Earth -> www.wikidata.org/wiki/Q2
|
||||
Gfo_usr_dlg usr_dlg = wiki.Appe().Usr_dlg();
|
||||
@@ -83,4 +84,6 @@ public class Wdata_itemByTitle_page implements Xows_page {
|
||||
, "<br>To change the default site, see <a href='/site/home/wiki/Options/Wikibase'>Options/Wikibase</a>" // HOME
|
||||
)
|
||||
, "legend", "site_lbl", "site_val", "page_lbl", "page_val", "search_lbl");
|
||||
|
||||
public Xows_page Special__clone() {return this;}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class Wdata_itemByTitle_page_fxt {
|
||||
page.Url_(url);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7(link));
|
||||
page.Ttl_(ttl);
|
||||
special_page.Special_gen(wiki, page, url, ttl);
|
||||
special_page.Special__gen(wiki, page, url, ttl);
|
||||
Tfds.Eq_str_lines(expd, String_.new_a7(page.Data_raw()));
|
||||
}
|
||||
public String Expd_html(String wmf_key, String ttl_str) {
|
||||
|
||||
@@ -17,58 +17,95 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.tmpls.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Random_selection_xnde implements Xox_xnde {
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {}
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
public class Random_selection_xnde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
private byte[] val = Bry_.Empty;
|
||||
private byte[] choicetemplate = null, atr_before = null, atr_after = null;
|
||||
private Rndsel_option_itm[] options_ary;
|
||||
private int weight_total = 0;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, byte xatr_id) {
|
||||
switch (xatr_id) {
|
||||
case Xatr__before: atr_before = xatr.Val_as_bry(); break;
|
||||
case Xatr__after: atr_after = xatr.Val_as_bry(); break;
|
||||
}
|
||||
}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_bgn);
|
||||
// Btrie_slim_mgr sub_xnde_trie = Btrie_slim_mgr.cs(); sub_xnde_trie.Add_obj("<option", 1).Add_obj("<choicetemplate", 2);
|
||||
// int src_bgn = xnde.Src_bgn(); int src_end = xnde.Src_end();
|
||||
// for (int i = src_bgn; i < src_end; ++i) {
|
||||
// Object sub_xnde = sub_xnde_trie.Match_bgn(src, i, src_end); if (sub_xnde == null) continue;
|
||||
// int pos = sub_xnde_trie.Match_pos();
|
||||
// switch (src[pos]) {
|
||||
// case Byte_ascii.Angle_end:
|
||||
// break;
|
||||
// case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.Nl: case Byte_ascii.Cr:
|
||||
// // find sub_xnde.Atrs()
|
||||
// break;
|
||||
// }
|
||||
// int end_pos = Bry_find_.Find_fwd(src, Byte_ascii.Angle_bgn); // search for close tab
|
||||
// i = end_pos;
|
||||
// }
|
||||
/*
|
||||
int weight_total = 0;
|
||||
int[] weight_nodes = new int[options_len];
|
||||
for (int i = 0; i < options_len; ++i) {
|
||||
Xnde x = get_option(i);
|
||||
int weight_itm = x.Atr_int_or("weight", 1);
|
||||
weight_total += 1;
|
||||
}
|
||||
if (weight_total == 0) return; // ignore empty <choose>
|
||||
int rnd = RandomAdp_.new_().Next(weight_total);
|
||||
byte[] option_bry = null;
|
||||
for (int i = 0; i < options_len; ++i) {
|
||||
r -= weight_nodes[i];
|
||||
if (r <= 0) {
|
||||
Xnde x = get_option(i);
|
||||
option_bry = x.Text;
|
||||
|
||||
Xox_xnde_.Parse_xatrs(wiki, this, xatrs_hash, src, xnde);
|
||||
|
||||
// parse <choose>
|
||||
List_adp option_list = List_adp_.new_();
|
||||
Gfh_tag_rdr tag_rdr = Xox_xnde_.New_tag_rdr(ctx, src, xnde).Reg("option", Tag__option).Reg("choicetemplate", Tag__choicetemplate);
|
||||
while (true) {
|
||||
Gfh_tag head_tag = tag_rdr.Tag__move_fwd_head(Gfh_tag_.Id__any);
|
||||
int tag_tid = head_tag.Name_id();
|
||||
boolean eos = false;
|
||||
switch (tag_tid) {
|
||||
case Gfh_tag_.Id__eos: eos = true; break;
|
||||
default: continue;
|
||||
case Tag__option:
|
||||
case Tag__choicetemplate: break;
|
||||
}
|
||||
if (eos) break;
|
||||
|
||||
int head_tag_end = head_tag.Src_end();
|
||||
Gfh_tag tail_tag = tag_rdr.Tag__move_fwd_tail(tag_tid);
|
||||
int tail_tag_bgn = tail_tag.Src_bgn();
|
||||
switch (tag_tid) {
|
||||
case Tag__choicetemplate: {
|
||||
if (choicetemplate == null) { // only one <choicetemplate> should be specified; if many, always take 1st
|
||||
choicetemplate = Bry_.Mid(src, head_tag_end, tail_tag_bgn);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Tag__option: {
|
||||
int weight = tail_tag.Atrs__get_as_int_or(Atr__weight, 1);
|
||||
option_list.Add(new Rndsel_option_itm(weight, Bry_.Mid(src, head_tag_end, tail_tag_bgn)));
|
||||
weight_total += weight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (templates_len > 0) {
|
||||
Xnde x = get_option(0);
|
||||
option_bry = "{{" + x.Text + "|" + option_bry + "}}";
|
||||
if (weight_total == 0) return; // empty <choose> will be 0
|
||||
this.options_ary = (Rndsel_option_itm[])option_list.To_ary_and_clear(Rndsel_option_itm.class);
|
||||
|
||||
// randomly select option_bry from all <option>s
|
||||
byte[] option_bry = null;
|
||||
int rnd = Rnd_test == -1 ? RandomAdp_.new_().Next(weight_total) + 1 : Rnd_test;
|
||||
int options_len = options_ary.length;
|
||||
for (int i = 0; i < options_len; ++i) {
|
||||
Rndsel_option_itm option = options_ary[i];
|
||||
rnd -= option.Weight();
|
||||
if (rnd <= 0) {
|
||||
option_bry = option.Text();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (atrs(before) != null)
|
||||
atrs(before) = before + option_bry;
|
||||
if (atrs(after) != null)
|
||||
atrs(after) = option_bry + after;
|
||||
this.val = ctx.Parse(option_bry)
|
||||
*/
|
||||
|
||||
// decorate option_bry
|
||||
if (choicetemplate != null) {
|
||||
option_bry = Bry_.Add(Xop_curly_bgn_lxr.Hook, choicetemplate, Byte_ascii.Pipe_bry, option_bry, Xop_curly_end_lxr.Hook);
|
||||
}
|
||||
if (!Bry_.Eq(atr_before, Bry_.Empty)) option_bry = Bry_.Add(atr_before, option_bry);
|
||||
if (!Bry_.Eq(atr_after , Bry_.Empty)) option_bry = Bry_.Add(option_bry, atr_after);
|
||||
|
||||
this.val = Xop_parser_.Parse_text_to_html(wiki, ctx.Page(), ctx.Page().Ttl(), option_bry, false);
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
// bfr.Add(val);
|
||||
if (val != null) bfr.Add(val);
|
||||
}
|
||||
public static final byte Xatr__before = 0, Xatr__after = 1;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7().Add_str_byte("before", Xatr__before).Add_str_byte("after", Xatr__after);
|
||||
private static final byte Tag__option = 0, Tag__choicetemplate = 1;
|
||||
private static final byte[] Atr__weight = Bry_.new_a7("weight");
|
||||
public static int Rnd_test = -1;
|
||||
}
|
||||
class Rndsel_option_itm {
|
||||
public Rndsel_option_itm(int weight, byte[] text) {this.weight = weight; this.text = text;}
|
||||
public int Weight() {return weight;} private final int weight;
|
||||
public byte[] Text() {return text;} private final byte[] text;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Random_selection_xnde_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Basic() {
|
||||
Random_selection_xnde.Rnd_test = 2;
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<choose before=\"bgn_''\" after=\"''_end\">"
|
||||
, "<option>A</option>"
|
||||
, "<option>B</option>"
|
||||
, "<option>C</option>"
|
||||
, "</choose>"
|
||||
), "bgn_<i>B</i>_end");
|
||||
Random_selection_xnde.Rnd_test = -1;
|
||||
}
|
||||
@Test public void Choicetemplate() {
|
||||
Random_selection_xnde.Rnd_test = 2;
|
||||
fxt.Init_page_create("Template:Tmpl", "bgn_''{{{1}}}''_end");
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<choose>"
|
||||
, "<option>a</option>"
|
||||
, "<option>b</option>"
|
||||
, "<option>c</option>"
|
||||
, "<option>A</option>"
|
||||
, "<option>B</option>"
|
||||
, "<option>C</option>"
|
||||
, "<choicetemplate>Tmpl</choicetemplate>"
|
||||
, "</choose>"
|
||||
), "");
|
||||
), "bgn_<i>B</i>_end");
|
||||
Random_selection_xnde.Rnd_test = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,46 @@ 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.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Tabber_xnde implements Xox_xnde {
|
||||
private static final byte[] Spr__tab_itms = Bry_.new_a7("|-|");
|
||||
private byte[] html;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_bgn);
|
||||
ctx.Page().Html_data().Head_mgr().Itm__graph().Enabled_y_();
|
||||
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
tmp_bfr.Add_str_a7("<div id=\"tabber-\" "); // TODO: add key which is md5 of inner src
|
||||
tmp_bfr.Add_str_a7("class=\"tabber\">\n");
|
||||
|
||||
// split on "|-|"; EX: "A|-|B" -> tab_1='A'; tab_2='B'
|
||||
byte[][] tab_itms = Bry_split_.Split(src, xnde.Tag_open_end(), xnde.Tag_close_bgn(), Spr__tab_itms);
|
||||
for (int i = 0; i < tab_itms.length; ++i) {
|
||||
byte[] tab_itm = tab_itms[i];
|
||||
tab_itm = Bry_.Trim(tab_itm);
|
||||
int tab_itm_len = tab_itm.length; if (tab_itm_len == 0) continue;
|
||||
|
||||
// split on "="; EX: A=B -> tab_name='A'; tab_body = 'B'
|
||||
byte[][] tab_parts = Bry_split_.Split(tab_itm, Byte_ascii.Eq);
|
||||
byte[] tab_head = tab_parts[0];
|
||||
byte[] tab_body = tab_parts.length == 1 ? Bry_.Empty : Xop_parser_.Parse_text_to_html(wiki, ctx.Page(), ctx.Page().Ttl(), tab_parts[1], false);
|
||||
|
||||
tmp_bfr.Add_str_a7("<div class=\"tabbertab\" title=\"");
|
||||
tmp_bfr.Add(Gfh_utl.Escape_html_as_bry(tab_head));
|
||||
tmp_bfr.Add_str_a7("\">\n");
|
||||
tmp_bfr.Add(Gfh_tag_.P_lhs);
|
||||
tmp_bfr.Add(tab_body);
|
||||
tmp_bfr.Add(Gfh_tag_.P_rhs).Add_byte_nl();
|
||||
tmp_bfr.Add(Gfh_tag_.Div_rhs).Add_byte_nl();
|
||||
}
|
||||
tmp_bfr.Add(Gfh_tag_.Div_rhs);
|
||||
html = tmp_bfr.To_bry_and_clear();
|
||||
|
||||
ctx.Page().Html_data().Head_mgr().Itm__tabber().Enabled_y_();
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
bfr.Add_mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
if (html != null) bfr.Add(html);
|
||||
}
|
||||
}
|
||||
|
||||
54
400_xowa/src/gplx/xowa/xtns/wikias/Tabber_xnde_tst.java
Normal file
54
400_xowa/src/gplx/xowa/xtns/wikias/Tabber_xnde_tst.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
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.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Tabber_xnde_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Basic() {
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<tabber>"
|
||||
, "tab1=''a''"
|
||||
, "|-|"
|
||||
, "tab2=''b''"
|
||||
, "</tabber>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"tabber-\" class=\"tabber\">"
|
||||
, "<div class=\"tabbertab\" title=\"tab1\">"
|
||||
, "<p><i>a</i></p>"
|
||||
, "</div>"
|
||||
, "<div class=\"tabbertab\" title=\"tab2\">"
|
||||
, "<p><i>b</i></p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Eq_missing() {
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<tabber>"
|
||||
, "tab1"
|
||||
, "</tabber>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"tabber-\" class=\"tabber\">"
|
||||
, "<div class=\"tabbertab\" title=\"tab1\">"
|
||||
, "<p></p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Xox_xowa_html_cmd implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
public class Xox_xowa_html_cmd implements Xox_xnde, Mwh_atr_itm_owner1 {
|
||||
private byte pos_val = Pos_head_end;
|
||||
public Xop_root_tkn Xtn_root() {throw Err_.new_unimplemented_w_msg("xowa_html_cmd.xtn_root should not be called");}
|
||||
public byte[] Xtn_html() {throw Err_.new_unimplemented_w_msg("xowa_html_cmd.xtn_html should not be called");}
|
||||
@@ -52,15 +52,15 @@ public class Xox_xowa_html_cmd implements Xox_xnde, Mwh_atr_itm_owner {
|
||||
return ((Byte_obj_val)o).Val();
|
||||
}
|
||||
private static final byte Pos_head_end = 1, Pos_html_end = 2;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Xatr_pos_key = Bry_.new_a7("pos")
|
||||
, Xatr_pos_val__head_end = Bry_.new_a7("head.end")
|
||||
, Xatr_pos_val__html_end = Bry_.new_a7("html.end")
|
||||
;
|
||||
private static final Hash_adp_bry pos_val_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry pos_val_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_byte(Xatr_pos_val__head_end, Pos_head_end)
|
||||
.Add_bry_byte(Xatr_pos_val__html_end, Pos_html_end)
|
||||
;
|
||||
private static final byte Xatr_pos_id = 1;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7().Add_bry_byte(Xatr_pos_key, Xatr_pos_id);
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7().Add_bry_byte(Xatr_pos_key, Xatr_pos_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user