1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-28 14:30:51 +00:00

Scribunto: Add frame_ttl to all Xot_invk_tkn [#503]

This commit is contained in:
gnosygnu 2019-06-29 22:29:15 -04:00
parent 9b51a7c660
commit 0bfacb2ea5
7 changed files with 19 additions and 14 deletions

View File

@ -20,7 +20,7 @@ public class Xot_defn_tmpl_ {
Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
byte[] orig_src = orig_defn.Data_raw();
Xowe_wiki wiki = ctx.Wiki();
Xot_invk_temp rv = Xot_invk_temp.New(orig.Defn_tid(), orig.Name_tkn(), orig_src, caller.Src_bgn(), caller.Src_end());
Xot_invk_temp rv = Xot_invk_temp.New(orig.Defn_tid(), ctx.Page().Ttl().Page_txt(), orig.Name_tkn(), orig_src, caller.Src_bgn(), caller.Src_end());
frame_ttl = wiki.Lang().Case_mgr().Case_reuse_1st_upper(frame_ttl); // NOTE: always uppercase 1st; EX:{{navbox -> "Template:Navbox"; PAGE:en.w:Achilles DATE:2014-06-21
frame_ttl = Xoa_ttl.Replace_unders(frame_ttl);
if (frame_ns == Xow_ns_.Tid__template)

View File

@ -20,8 +20,9 @@ public class Xot_invk_temp implements Xot_invk {
private List_adp list;
private Hash_adp_bry arg_key_hash;
private Hash_adp arg_idx_hash; private Int_obj_ref arg_idx_ref;
Xot_invk_temp(boolean root_frame, byte defn_tid, Arg_nde_tkn name_tkn, byte[] src, int src_bgn, int src_end) {
Xot_invk_temp(boolean root_frame, byte defn_tid, byte[] frame_ttl, Arg_nde_tkn name_tkn, byte[] src, int src_bgn, int src_end) {
this.root_frame = root_frame;
this.frame_ttl = frame_ttl;
this.defn_tid = defn_tid;
this.name_tkn = name_tkn;
this.src = src; this.src_bgn = src_bgn; this.src_end = src_end;
@ -68,14 +69,14 @@ public class Xot_invk_temp implements Xot_invk {
public static final Xot_invk Null_frame = null;
public static Xot_invk_temp New_root_w_src(byte[] src) {
return new Xot_invk_temp(true, Xot_defn_.Tid_page, null, src, 0, src.length);
public static Xot_invk_temp New_root_w_src(byte[] frame_ttl, byte[] src) {
return new Xot_invk_temp(true, Xot_defn_.Tid_page, frame_ttl, null, src, 0, src.length);
}
public static Xot_invk_temp New_root() {
return new Xot_invk_temp(true, Xot_defn_.Tid_page, null, null, -1, -1);
public static Xot_invk_temp New_root(byte[] frame_ttl) {
return new Xot_invk_temp(true, Xot_defn_.Tid_page, frame_ttl, null, null, -1, -1);
}
public static Xot_invk_temp New(byte defn_tid, Arg_nde_tkn name_tkn, byte[] src, int src_bgn, int src_end) {
return new Xot_invk_temp(false, defn_tid, name_tkn, src, src_bgn, src_end);
public static Xot_invk_temp New(byte defn_tid, byte[] frame_ttl, Arg_nde_tkn name_tkn, byte[] src, int src_bgn, int src_end) {
return new Xot_invk_temp(false, defn_tid, frame_ttl, name_tkn, src, src_bgn, src_end);
}
}
/*

View File

@ -53,7 +53,7 @@ public class Xot_tmpl_wtr {
// NOTE: originally "if (ctx.Parse_tid() == Xop_parser_tid_.Tid__tmpl) {" but if not needed; Xot_tmpl_wtr should not be called for tmpls and <oi> should not make it to page_wiki
Bry_bfr tmp_bfr = Bry_bfr_.New();
ctx.Only_include_evaluate_(true);
xnde.Tmpl_evaluate(ctx, src, Xot_invk_temp.New_root(), tmp_bfr);
xnde.Tmpl_evaluate(ctx, src, Xot_invk_temp.New_root(ctx.Page().Ttl().Page_txt()), tmp_bfr);
ctx.Only_include_evaluate_(false);
rslt_bfr.Add_bfr_and_preserve(tmp_bfr);
break;
@ -89,7 +89,7 @@ public class Xot_tmpl_wtr {
rslt_bfr.Add_mid(src, tkn.Src_bgn(), tkn.Src_end()); break; // write src from bgn/end
case Xop_tkn_itm_.Tid_ignore: break; // hide comments and <*include*> ndes
case Xop_tkn_itm_.Tid_tmpl_prm:
tkn.Tmpl_evaluate(ctx, src, Xot_invk_temp.New_root_w_src(src), rslt_bfr);
tkn.Tmpl_evaluate(ctx, src, Xot_invk_temp.New_root_w_src(ctx.Page().Ttl().Page_txt(), src), rslt_bfr);
break;
case Xop_tkn_itm_.Tid_tvar:
gplx.xowa.xtns.translates.Xop_tvar_tkn tvar_tkn = (gplx.xowa.xtns.translates.Xop_tvar_tkn)tkn;
@ -98,7 +98,7 @@ public class Xot_tmpl_wtr {
case Xop_tkn_itm_.Tid_tmpl_invk:
try {
if (frame == Xot_invk_temp.Null_frame) { // NOTE: should probably remove lazy-instantiation and always force frame to be passed in; DATE:2017-09-03
frame = Xot_invk_temp.New_root_w_src(src);
frame = Xot_invk_temp.New_root_w_src(ctx.Page().Ttl().Page_txt(), src);
frame.Frame_ttl_(ctx.Page().Ttl().Full_txt_raw());
}
tkn.Tmpl_evaluate(ctx, src, frame, rslt_bfr);

View File

@ -46,7 +46,7 @@ public class Lst_pfunc_itm {
// eval tmpl
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_m001();
try {
tmpl.Tmpl_evaluate(sub_ctx, Xot_invk_temp.New_root(), tmp_bfr);
tmpl.Tmpl_evaluate(sub_ctx, Xot_invk_temp.New_root(ttl.Page_txt()), tmp_bfr);
sub_src = tmp_bfr.To_bry_and_clear();
} finally {
tmp_bfr.Mkr_rls();

View File

@ -115,7 +115,7 @@ public class Scrib_invoke_func_fxt {
fxt = new Xop_fxt(app, Xoa_app_fxt.Make__wiki__edit(app, domain, app.Lang_mgr().Get_by_or_new(Bry_.new_u8(lang)))); // NOTE: don't try to cache fxt on func_fxt level; causes errors in Language_lib
core_fxt = new Scrib_core_fxt(fxt);
core = core_fxt.Core();
Xot_invk parent_frame = Xot_invk_temp.New_root(); parent_frame.Frame_tid_(Scrib_frame_.Tid_null);
Xot_invk parent_frame = Xot_invk_temp.New_root(fxt.Page().Ttl().Page_txt()); parent_frame.Frame_tid_(Scrib_frame_.Tid_null);
Xot_invk current_frame = Xot_invk_mock.test_(Bry_.new_a7("Module:Mod_0"));
core.Invoke_init(core.Wiki(), core.Ctx(), Bry_.Empty, parent_frame, current_frame);
core.When_page_changed(fxt.Page());

View File

@ -31,7 +31,7 @@ public class Mock_scrib_fxt {
core = wiki.Parser_mgr().Scrib().Core_init(wiki.Parser_mgr().Ctx());
core.Engine_(engine); engine.Clear();
core.Interpreter().Server_(server);
Xot_invk parent_frame = Xot_invk_temp.New_root(); parent_frame.Frame_tid_(Scrib_frame_.Tid_null);
Xot_invk parent_frame = Xot_invk_temp.New_root(parser_fxt.Page().Ttl().Page_txt()); parent_frame.Frame_tid_(Scrib_frame_.Tid_null);
Xot_invk current_frame = Xot_invk_mock.test_(Bry_.new_a7("Module:Mod_0"));
core.Invoke_init(core.Wiki(), core.Ctx(), Bry_.Empty, parent_frame, current_frame);
core.When_page_changed(parser_fxt.Page());

View File

@ -45,4 +45,8 @@ public class Scrib_lib_mw__frame_tst {
fxt.Test__parse__tmpl_to_html("{{#invoke:Mod_1|Get_frame_title_parent}}", "Test page");
fxt.Test__parse__tmpl_to_html("{{#invoke:Mod_1|Get_frame_title_current}}", "Module:Mod 1");
}
@Test public void GetFrameTitle__onlyinclude() {
fxt.Test__parse__tmpl_to_html("<onlyinclude>{{#invoke:Mod_1|Get_frame_title_parent}}</onlyinclude>", "Test page");
fxt.Test__parse__tmpl_to_html("<onlyinclude>{{#invoke:Mod_1|Get_frame_title_current}}</onlyinclude>", "Module:Mod 1");
}
}