1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-02-22 21:03:49 -05:00
parent 3df6db4b7b
commit f495595da4
1119 changed files with 11513 additions and 11734 deletions

View File

@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
import gplx.core.btries.*; import gplx.xowa.parsers.tblws.*;
public class Xop_curly_bgn_lxr implements Xop_lxr {
public byte Lxr_tid() {return Xop_lxr_.Tid_curly_bgn;}
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook, this);} public static final byte[] Hook = new byte[] {Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn};
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook, this);} public static final byte[] Hook = new byte[] {Byte_ascii.Curly_bgn, Byte_ascii.Curly_bgn};
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {return ctx.Curly().MakeTkn_bgn(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
public static final Xop_curly_bgn_lxr _ = new Xop_curly_bgn_lxr(); Xop_curly_bgn_lxr() {}

View File

@@ -23,14 +23,14 @@ public class Xop_curly_bgn_tkn extends Xop_tkn_itm_base {
}
class Xop_curly_end_lxr implements Xop_lxr {
public byte Lxr_tid() {return Xop_lxr_.Tid_curly_end;}
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook, this);} public static final byte[] Hook = new byte[] {Byte_ascii.Curly_end, Byte_ascii.Curly_end};
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook, this);} public static final byte[] Hook = new byte[] {Byte_ascii.Curly_end, Byte_ascii.Curly_end};
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {return ctx.Curly().MakeTkn_end(ctx, tkn_mkr, root, src, src_len, bgn_pos, cur_pos);}
public static final Xop_curly_end_lxr _ = new Xop_curly_end_lxr(); Xop_curly_end_lxr() {}
}
class Xop_brack_bgn_lxr implements Xop_lxr {
public byte Lxr_tid() {return Xop_lxr_.Tid_brack_bgn;}
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_bgn, this);}
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_bgn, this);}
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
Xop_tkn_itm tkn = tkn_mkr.Brack_bgn(bgn_pos, cur_pos);
@@ -41,7 +41,7 @@ class Xop_brack_bgn_lxr implements Xop_lxr {
}
class Xop_brack_end_lxr implements Xop_lxr {
public byte Lxr_tid() {return Xop_lxr_.Tid_brack_end;}
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_end, this);}
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Xop_tkn_.Lnki_end, this);}
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
public int Make_tkn(Xop_ctx ctx, Xop_tkn_mkr tkn_mkr, Xop_root_tkn root, byte[] src, int src_len, int bgn_pos, int cur_pos) {
int acs_pos = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_brack_bgn);

View File

@@ -131,7 +131,7 @@ public class Xop_curly_wkr implements Xop_ctx_wkr {
if (vnt_dash_adjust) {
Xop_tkn_itm text_tkn = root.Subs_get_or_null(root.Subs_len() - 2); // -2 to get tkn before newly-created tmpl / prm
if (text_tkn == null || text_tkn.Tkn_tid() != Xop_tkn_itm_.Tid_txt)
ctx.Wiki().App().Usr_dlg().Warn_many("", "", "token before curly_bgn was not text tkn; src=~{0}", String_.new_utf8_(src, lxr_bgn_pos, lxr_end_pos));
ctx.Wiki().Appe().Usr_dlg().Warn_many("", "", "token before curly_bgn was not text tkn; src=~{0}", String_.new_utf8_(src, lxr_bgn_pos, lxr_end_pos));
else
text_tkn.Src_end_(text_tkn.Src_end() + 1); // +1 to extend txt_tkn with dash be 1 to include curly; EX: "-" "{{{" -> "-{" "{{"
}

View File

@@ -62,14 +62,14 @@ public class Xot_defn_tmpl implements Xot_defn {
public void Parse_tmpl(Xop_ctx ctx) {ctx.Wiki().Parser().Parse_text_to_defn(this, ctx, ctx.Tkn_mkr(), ns, name, data_raw);} boolean onlyinclude_parsed = false;
public boolean Tmpl_evaluate(Xop_ctx ctx, Xot_invk caller, Bry_bfr bfr) {
if (root == null) Parse_tmpl(ctx);
Xoa_page page = ctx.Cur_page();
Xoae_page page = ctx.Cur_page();
if (!page.Tmpl_stack_add(full_name)) {
bfr.Add_str("<span class=\"error\">Template loop detected:" + String_.new_utf8_(name) + "</span>");
return false;
}
boolean rv = true;
if (onlyInclude_exists) {
Xow_wiki wiki = ctx.Wiki();
Xowe_wiki wiki = ctx.Wiki();
if (!onlyinclude_parsed) {
onlyinclude_parsed = true;
byte[] new_data = Extract_onlyinclude(data_raw, wiki.Utl_bry_bfr_mkr());

View File

@@ -20,7 +20,7 @@ public class Xot_defn_tmpl_ {
public static Xot_invk CopyNew(Xop_ctx ctx, Xot_defn_tmpl orig_defn, Xot_invk orig, Xot_invk caller, byte[] src, byte[] frame_ttl) { // SEE:NOTE_1
Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
byte[] orig_src = orig_defn.Data_raw();
Xow_wiki wiki = ctx.Wiki();
Xowe_wiki wiki = ctx.Wiki();
Xot_invk_temp rv = new Xot_invk_temp(orig.Defn_tid(), orig_src, orig.Name_tkn(), 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
rv.Frame_ttl_(wiki.Ns_mgr().Ns_template().Gen_ttl(Xoa_ttl.Replace_unders(frame_ttl))); // NOTE: always prepend "Template:" to frame_ttl; DATE:2014-06-13; NOTE: always use spaces; DATE:2014-08-14

View File

@@ -46,7 +46,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
}
@Override public boolean Tmpl_evaluate(Xop_ctx ctx, byte[] src, Xot_invk caller, Bry_bfr bfr) { // this="{{t|{{{0}}}}}" caller="{{t|1}}"
boolean rv = false;
Xot_defn defn = tmpl_defn; Xow_wiki wiki = ctx.Wiki(); Xol_lang lang = wiki.Lang();
Xot_defn defn = tmpl_defn; Xowe_wiki wiki = ctx.Wiki(); Xol_lang lang = wiki.Lang();
byte[] name_ary = defn.Name(), argx_ary = Bry_.Empty; Arg_itm_tkn name_key_tkn = name_tkn.Key_tkn();
byte[] name_ary_orig = Bry_.Empty;
int name_bgn = 0, name_ary_len = 0;
@@ -235,7 +235,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
if (Env_.Mode_testing())
throw Err_.err_(e, "failed to evaluate function: page={0} defn={1} src={2} err={3}", String_.new_utf8_(ctx.Cur_page().Ttl().Full_txt()), String_.new_utf8_(defn.Name()), String_.new_utf8_(src, this.Src_bgn(), this.Src_end()), Err_.Message_gplx_brief(e));
else {
wiki.App().Usr_dlg().Warn_many("", "", "failed to evaluate function: page=~{0} defn=~{1} src=~{2} err=~{3}", String_.new_utf8_(ctx.Cur_page().Ttl().Full_txt()), String_.new_utf8_(defn.Name()), String_.new_utf8_(src, this.Src_bgn(), this.Src_end()), Err_.Message_gplx_brief(e));
wiki.Appe().Usr_dlg().Warn_many("", "", "failed to evaluate function: page=~{0} defn=~{1} src=~{2} err=~{3}", String_.new_utf8_(ctx.Cur_page().Ttl().Full_txt()), String_.new_utf8_(defn.Name()), String_.new_utf8_(src, this.Src_bgn(), this.Src_end()), Err_.Message_gplx_brief(e));
rv = false;
}
}
@@ -331,7 +331,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
bfr.Add(nde.Val_tkn().Dat_ary());
}
}
private boolean Transclude(Xop_ctx ctx, Xow_wiki wiki, Bry_bfr bfr, byte[] name_ary, Xot_invk caller, byte[] src) {
private boolean Transclude(Xop_ctx ctx, Xowe_wiki wiki, Bry_bfr bfr, byte[] name_ary, Xot_invk caller, byte[] src) {
Xoa_ttl page_ttl = Xoa_ttl.parse_(wiki, name_ary); if (page_ttl == null) return false; // ttl not valid; EX: {{:[[abc]]}}
byte[] transclude_src = null;
if (page_ttl.Ns().Id_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
@@ -366,7 +366,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
doc.Add_bfr_and_clear(tmp_bfr);
return rv;
}
public static Xot_defn_tmpl Load_defn(Xow_wiki wiki, Xop_ctx ctx, Xot_invk_tkn invk_tkn, Xoa_ttl ttl, byte[] name_ary) {
public static Xot_defn_tmpl Load_defn(Xowe_wiki wiki, Xop_ctx ctx, Xot_invk_tkn invk_tkn, Xoa_ttl ttl, byte[] name_ary) {
Xow_page_cache_itm tmpl_page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm(ttl);
byte[] tmpl_page_bry = tmpl_page_itm == null ? null : tmpl_page_itm.Wtxt();
Xot_defn_tmpl rv = null;
@@ -385,7 +385,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
byte[] template_ns_name = ns_mgr.Ns_template().Name_bry();
bfr.Add(Xop_tkn_.Lnki_bgn).Add_byte(Byte_ascii.Colon).Add(template_ns_name).Add_byte(Byte_ascii.Colon).Add(name_ary).Add(Xop_tkn_.Lnki_end);
}
private boolean SubEval(Xop_ctx ctx, Xow_wiki wiki, Bry_bfr bfr, byte[] name_ary, Xot_invk caller, byte[] src_for_tkn) {
private boolean SubEval(Xop_ctx ctx, Xowe_wiki wiki, Bry_bfr bfr, byte[] name_ary, Xot_invk caller, byte[] src_for_tkn) {
Xoa_ttl page_ttl = Xoa_ttl.parse_(wiki, name_ary); if (page_ttl == null) return false; // ttl not valid; EX: {{:[[abc]]}}
Xot_defn_tmpl transclude_tmpl = null;
switch (page_ttl.Ns().Id()) {

View File

@@ -64,7 +64,7 @@ public class Xot_tmpl_wtr {
if (xnde.Tag_close_bgn() == Int_.MinValue)
rslt_bfr.Add_mid(src, tkn.Src_bgn(), tkn.Src_end()); // write src from bgn/end
else { // NOTE: if nowiki then "deactivate" all xndes by swapping out < for &lt; nowiki_xnde_frag; DATE:2013-01-27
Bry_bfr tmp_bfr = ctx.Wiki().App().Utl_bry_bfr_mkr().Get_k004();
Bry_bfr tmp_bfr = ctx.Wiki().Appe().Utl_bry_bfr_mkr().Get_k004();
int nowiki_content_bgn = xnde.Tag_open_end(), nowiki_content_end = xnde.Tag_close_bgn();
boolean escaped = gplx.xowa.parsers.tmpls.Nowiki_escape_itm.Escape(tmp_bfr, src, nowiki_content_bgn, nowiki_content_end);
rslt_bfr.Add_bfr_or_mid(escaped, tmp_bfr, src, nowiki_content_bgn, nowiki_content_end);