mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.10.3.1
This commit is contained in:
@@ -16,7 +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.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.html.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Xop_xowa_cmd implements Xox_xnde {
|
||||
public Xop_root_tkn Xtn_root() {throw Err_.new_unimplemented_w_msg("xowa_cmd.xtn_root should not be called");}
|
||||
|
||||
@@ -17,14 +17,14 @@ 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 org.junit.*;
|
||||
import gplx.xowa.apps.gfss.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
public class Xop_xowa_cmd_tst {
|
||||
@Before public void init() {
|
||||
Xoa_gfs_mgr.Msg_parser_init();
|
||||
fxt.Reset();
|
||||
} private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Basic() {
|
||||
GfsCore._.AddCmd(fxt.App(), Xoae_app.Invk_app);
|
||||
GfsCore.Instance.AddCmd(fxt.App(), Xoae_app.Invk_app);
|
||||
fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(false);
|
||||
fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last
|
||||
( "<xowa_cmd>"
|
||||
|
||||
@@ -16,7 +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.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xop_xowa_func extends Pf_func_base {
|
||||
|
||||
@@ -17,13 +17,13 @@ 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 org.junit.*;
|
||||
import gplx.xowa.apps.gfss.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
public class Xop_xowa_func_tst {
|
||||
@Before public void init() {
|
||||
Xoa_gfs_mgr.Msg_parser_init();
|
||||
} private Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Template() {
|
||||
GfsCore._.AddCmd(fxt.App(), Xoae_app.Invk_app);
|
||||
GfsCore.Instance.AddCmd(fxt.App(), Xoae_app.Invk_app);
|
||||
fxt.Wiki().Sys_cfg().Xowa_cmd_enabled_(true);
|
||||
fxt.Init_defn_add("A", "{{#xowa|{{{1}}}}}");
|
||||
fxt.Test_parse_page_all_str("{{A|app.users.get('anonymous').name;}}", "anonymous");
|
||||
|
||||
@@ -16,18 +16,18 @@ 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; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Xox_xowa_html_cmd implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
import gplx.core.primitives.*; import gplx.xowa.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 {
|
||||
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");}
|
||||
public void Xatr_parse(Xowe_wiki wiki, byte[] src, Xop_xatr_itm xatr, Object xatr_key_obj) {
|
||||
if (xatr_key_obj == null) return;
|
||||
Byte_obj_val xatr_key = (Byte_obj_val)xatr_key_obj;
|
||||
switch (xatr_key.Val()) {
|
||||
case Xatr_pos_id: pos_val = Pos_val(xatr.Val_as_bry(src)); break;
|
||||
default: throw Err_.new_unhandled(xatr_key.Val());
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {
|
||||
if (xatr_id_obj == null) return;
|
||||
Byte_obj_val xatr_id = (Byte_obj_val)xatr_id_obj;
|
||||
switch (xatr_id.Val()) {
|
||||
case Xatr_pos_id: pos_val = Pos_val(xatr.Val_as_bry()); break;
|
||||
default: throw Err_.new_unhandled(xatr_id.Val());
|
||||
}
|
||||
}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
@@ -35,7 +35,7 @@ public class Xox_xowa_html_cmd implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
wiki.Appe().Usr_dlg().Warn_many("", "", "xowa_html command only allowed in xowa_home");
|
||||
return;
|
||||
}
|
||||
Xop_xatr_itm.Xatr_parse(wiki.Appe(), this, atr_hash, wiki, src, xnde);
|
||||
Xox_xnde_.Xatr__set(wiki, this, xatrs_hash, src, xnde);
|
||||
int itm_bgn = xnde.Tag_open_end(), itm_end = xnde.Tag_close_bgn();
|
||||
if (src[itm_bgn] == Byte_ascii.Nl) ++itm_bgn; // ignore 1st \n;
|
||||
// if (src[itm_end - 1] == Byte_ascii.Nl) --itm_end; // ignore last \n;
|
||||
@@ -62,5 +62,5 @@ public class Xox_xowa_html_cmd implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
.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 atr_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);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,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 org.junit.*;
|
||||
import gplx.xowa.html.*; import gplx.xowa.gui.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.guis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Xox_xowa_html_cmd_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xox_xowa_html_cmd_fxt fxt = new Xox_xowa_html_cmd_fxt();
|
||||
@@ -50,7 +50,7 @@ class Xox_xowa_html_cmd_fxt {
|
||||
Xop_root_tkn root = fxt.Exec_parse_page_all_as_root(raw_bry);
|
||||
fxt.Page().Root_(root);
|
||||
html_mgr.Html_wtr().Write_all(bfr, fxt.Ctx(), raw_bry, root);
|
||||
byte[] actl = html_mgr.Page_wtr_mgr().Wkr(Xopg_view_mode.Tid_read).Write(html_mgr.Page_wtr_mgr(), fxt.Page(), fxt.Ctx(), bfr);
|
||||
byte[] actl = html_mgr.Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_page(fxt.Page(), fxt.Ctx(), bfr);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user