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-09-20 23:43:51 -04:00
parent 5fe27b5b3b
commit fa70c05354
1056 changed files with 8375 additions and 7095 deletions

View File

@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.translates; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.primitives.*;
import gplx.xowa.nss.*;
import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
public class Xop_languages_xnde implements Xox_xnde {
@@ -29,7 +30,7 @@ public class Xop_languages_xnde implements Xox_xnde {
public Xoa_ttl Root_ttl() {return root_ttl;} private Xoa_ttl root_ttl;
private Xoa_ttl Root_ttl_of(Xowe_wiki wiki, Xoa_ttl ttl) {
byte[] page_bry = ttl.Page_db();
int slash_pos = Bry_finder.Find_bwd(page_bry, Xoa_ttl.Subpage_spr);
int slash_pos = Bry_find_.Find_bwd(page_bry, Xoa_ttl.Subpage_spr);
if (slash_pos == Bry_.NotFound) return ttl;
byte[] root_bry = Bry_.Mid(page_bry, 0, slash_pos);
return Xoa_ttl.parse(wiki, ttl.Ns().Id(), root_bry);

View File

@@ -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.translates; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
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;}

View File

@@ -25,7 +25,7 @@ public class Xop_translate_xnde implements Xox_xnde, Xop_xnde_atr_parser {
byte[] translate_src = Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
translate_src = Bry_.Trim(translate_src, 0, translate_src.length);
Xop_ctx sub_ctx = Xop_ctx.new_sub_(wiki);
xtn_root = wiki.Parser().Parse_text_to_wdom_old_ctx(sub_ctx, translate_src, true);
xtn_root = wiki.Parser_mgr().Main().Parse_text_to_wdom_old_ctx(sub_ctx, translate_src, true);
}
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.Write_tkn(bfr, ctx, hctx, xtn_root.Root_src(), xnde, Xoh_html_wtr.Sub_idx_null, xtn_root);

View File

@@ -16,20 +16,21 @@ 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.translates; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.btries.*;
import gplx.core.btries.*; import gplx.xowa.langs.*;
import gplx.xowa.parsers.*;
public class Xop_tvar_lxr implements Xop_lxr {
public byte Lxr_tid() {return Xop_lxr_.Tid_tvar;}
public int Lxr_tid() {return Xop_lxr_.Tid_tvar;}
public void Init_by_wiki(Xowe_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook_bgn, this);}
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}
public void Term(Btrie_fast_mgr core_trie) {}
private static final byte[] Hook_bgn = Bry_.new_a7("<tvar|"), Close_nde = Bry_.new_a7("</>");
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 rhs_end = Bry_finder.Find_fwd(src, Byte_ascii.Gt, cur_pos); if (rhs_end == Bry_.NotFound) return ctx.Lxr_make_txt_(cur_pos);
int lhs_bgn = Bry_finder.Find_fwd(src, Close_nde , rhs_end); if (lhs_bgn == Bry_.NotFound) return ctx.Lxr_make_txt_(cur_pos);
int rhs_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, cur_pos); if (rhs_end == Bry_.NotFound) return ctx.Lxr_make_txt_(cur_pos);
int lhs_bgn = Bry_find_.Find_fwd(src, Close_nde , rhs_end); if (lhs_bgn == Bry_.NotFound) return ctx.Lxr_make_txt_(cur_pos);
byte[] body = Bry_.Mid(src, rhs_end + Int_.Const_position_after_char, lhs_bgn);
Xop_ctx sub_ctx = Xop_ctx.new_sub_(ctx.Wiki());
Xop_root_tkn sub_root = tkn_mkr.Root(body);
body = ctx.Wiki().Parser().Parse_text_to_wtxt(sub_root, sub_ctx, tkn_mkr, body); // NOTE: must parse inner text for templates; EX:<tvar|a>{{B}}</>; PAGE:mw:Download; DATE:2014-04-27
body = ctx.Wiki().Parser_mgr().Main().Parse_text_to_wtxt(sub_root, sub_ctx, tkn_mkr, body); // NOTE: must parse inner text for templates; EX:<tvar|a>{{B}}</>; PAGE:mw:Download; DATE:2014-04-27
int end_pos = lhs_bgn + Close_nde.length;
ctx.Subs_add(root, tkn_mkr.Tvar(bgn_pos, end_pos, cur_pos, rhs_end, rhs_end + Int_.Const_position_after_char, lhs_bgn, body));
return end_pos;