mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.3.1
This commit is contained in:
@@ -32,7 +32,7 @@ public class Xoh_cmd_mgr {
|
||||
itm = (Xoh_cmd_itm)cmds.Get_at(i);
|
||||
itm.Hcmd_exec(app, usr_dlg, page);
|
||||
itm.Hcmd_write(app, usr_dlg, page);
|
||||
} catch (Exception e) {throw Exc_.new_exc(e, "xo", "failed to execute html cmd", "name", itm == null ? "unknown" : itm.Hcmd_id());}
|
||||
} catch (Exception e) {throw Err_.new_exc(e, "xo", "failed to execute html cmd", "name", itm == null ? "unknown" : itm.Hcmd_id());}
|
||||
}
|
||||
this.Clear();
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_apos_tkn_.Cmd_b_end__i_bgn: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_lhs); break;
|
||||
case Xop_apos_tkn_.Cmd_i_end__b_bgn: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_lhs); break;
|
||||
case Xop_apos_tkn_.Cmd_nil: break;
|
||||
default: throw Exc_.new_unhandled(apos.Apos_cmd());
|
||||
default: throw Err_.new_unhandled(apos.Apos_cmd());
|
||||
}
|
||||
}
|
||||
public static byte[] Ttl_to_title(byte[] ttl) {return ttl;} // FUTURE: swap html chars?
|
||||
@@ -194,7 +194,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_list_tkn_.List_itmTyp_ul: tag = Tag_list_grp_ul_bgn; break;
|
||||
case Xop_list_tkn_.List_itmTyp_dd:
|
||||
case Xop_list_tkn_.List_itmTyp_dt: tag = Tag_list_grp_dl_bgn; break;
|
||||
default: throw Exc_.new_unhandled(type);
|
||||
default: throw Err_.new_unhandled(type);
|
||||
}
|
||||
if (bfr.Len() > 0) bfr.Add_byte_nl(); // NOTE: do not add newLine if start
|
||||
if (indent_level > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent_level * 2);
|
||||
@@ -208,7 +208,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_list_tkn_.List_itmTyp_ul: tag = Tag_list_itm_li_bgn; break;
|
||||
case Xop_list_tkn_.List_itmTyp_dt: tag = Tag_list_itm_dt_bgn; break;
|
||||
case Xop_list_tkn_.List_itmTyp_dd: tag = Tag_list_itm_dd_bgn; break;
|
||||
default: throw Exc_.new_unhandled(type);
|
||||
default: throw Err_.new_unhandled(type);
|
||||
}
|
||||
bfr.Add_byte_nl();
|
||||
if (indent_level > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent_level * 2);
|
||||
@@ -223,7 +223,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_list_tkn_.List_itmTyp_ul: tag = Tag_list_grp_ul_end; break;
|
||||
case Xop_list_tkn_.List_itmTyp_dd:
|
||||
case Xop_list_tkn_.List_itmTyp_dt: tag = Tag_list_grp_dl_end; break;
|
||||
default: throw Exc_.new_unhandled(type);
|
||||
default: throw Err_.new_unhandled(type);
|
||||
}
|
||||
bfr.Add_byte_nl();
|
||||
if (indent_level > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent_level * 2);
|
||||
@@ -238,7 +238,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_list_tkn_.List_itmTyp_ul: tag = Tag_list_itm_li_end; break;
|
||||
case Xop_list_tkn_.List_itmTyp_dt: tag = Tag_list_itm_dt_end; break;
|
||||
case Xop_list_tkn_.List_itmTyp_dd: tag = Tag_list_itm_dd_end; break;
|
||||
default: throw Exc_.new_unhandled(type);
|
||||
default: throw Err_.new_unhandled(type);
|
||||
}
|
||||
bfr.Add_byte_if_not_last(Byte_ascii.Nl);
|
||||
if (indent_level > 0) bfr.Add_byte_repeat(Byte_ascii.Space, indent_level * 2);
|
||||
@@ -267,13 +267,13 @@ public class Xoh_html_wtr {
|
||||
case Xop_para_tkn.Tid_none: break;
|
||||
case Xop_para_tkn.Tid_para: bfr.Add(Tag_para_end).Add_byte_nl(); break;
|
||||
case Xop_para_tkn.Tid_pre: bfr.Add(Tag_pre_end).Add_byte_nl(); break;
|
||||
default: throw Exc_.new_unhandled(para.Para_end());
|
||||
default: throw Err_.new_unhandled(para.Para_end());
|
||||
}
|
||||
switch (para.Para_bgn()) {
|
||||
case Xop_para_tkn.Tid_none: break;
|
||||
case Xop_para_tkn.Tid_para: Para_assert_tag_starts_on_nl(bfr, para.Src_bgn()); bfr.Add(Tag_para_bgn); break;
|
||||
case Xop_para_tkn.Tid_pre: Para_assert_tag_starts_on_nl(bfr, para.Src_bgn()); bfr.Add(Tag_pre_bgn); break;
|
||||
default: throw Exc_.new_unhandled(para.Para_bgn());
|
||||
default: throw Err_.new_unhandled(para.Para_bgn());
|
||||
}
|
||||
if (para.Space_bgn() > 0)
|
||||
bfr.Add_byte_repeat(Byte_ascii.Space, para.Space_bgn());
|
||||
@@ -513,7 +513,7 @@ public class Xoh_html_wtr {
|
||||
bfr.Add(atr_key);
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
}
|
||||
byte quote_byte = atr.Quote_byte(); if (quote_byte == Byte_ascii.Nil) quote_byte = Byte_ascii.Quote;
|
||||
byte quote_byte = atr.Quote_byte(); if (quote_byte == Byte_ascii.Null) quote_byte = Byte_ascii.Quote;
|
||||
bfr.Add_byte(quote_byte);
|
||||
if (atr.Key_tid() == Xop_xatr_itm.Key_tid_id) { // ids should not have spaces; DATE:2013-04-01
|
||||
if (atr.Val_bry() == null)
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Xoh_html_wtr_escaper {
|
||||
else // parse failed; escape and continue
|
||||
bfr.Add(Html_entity_.Amp_bry);
|
||||
break;
|
||||
default: throw Exc_.new_unhandled(itm_tid);
|
||||
default: throw Err_.new_unhandled(itm_tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class Xoh_html_wtr_escaper {
|
||||
return end_gt;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "unknown error in escape.nowiki: ~{0} ~{1}", Err_.Message_gplx_brief(e), String_.new_u8(src, bgn, end));
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "unknown error in escape.nowiki: ~{0} ~{1}", String_.new_u8(src, bgn, end), Err_.Message_gplx_full(e));
|
||||
return Bry_.NotFound;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Xoh_page_wtr_wkr implements Bry_fmtr_arg {
|
||||
, Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, null) // NOTE: page_name does not show display_title (<i>). always pass in null
|
||||
, Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl())
|
||||
, page_modified_on_msg
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Module_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Head_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), page_body_class, html_content_editable
|
||||
, page_data, wtr_page_lang
|
||||
, portal_mgr.Div_personal_bry(), portal_mgr.Div_ns_bry(app.Utl__bfr_mkr(), page_ttl, wiki.Ns_mgr()), portal_mgr.Div_view_bry(app.Utl__bfr_mkr(), view_tid, page.Html_data().Xtn_search_text())
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Xohe_page_wtr_mgr extends Xoh_page_wtr_mgr_base implements GfoInvkA
|
||||
case Xopg_view_mode.Tid_edit: return edit_wtr;
|
||||
case Xopg_view_mode.Tid_html: return html_wtr;
|
||||
case Xopg_view_mode.Tid_read: return read_wtr;
|
||||
default: throw Exc_.new_unhandled(output_tid);
|
||||
default: throw Err_.new_unhandled(output_tid);
|
||||
}
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Xow_html_mgr implements GfoInvkAble {
|
||||
public Xohe_page_wtr_mgr Page_wtr_mgr() {return page_wtr_mgr;} private Xohe_page_wtr_mgr page_wtr_mgr;
|
||||
public Xow_portal_mgr Portal_mgr() {return portal_mgr;} private Xow_portal_mgr portal_mgr;
|
||||
public Xow_toc_mgr Toc_mgr() {return toc_mgr;} private Xow_toc_mgr toc_mgr = new Xow_toc_mgr();
|
||||
public Xow_module_mgr Module_mgr() {return module_mgr;} private Xow_module_mgr module_mgr;
|
||||
public Xow_module_mgr Head_mgr() {return module_mgr;} private Xow_module_mgr module_mgr;
|
||||
public Xow_hzip_mgr Hzip_mgr() {return hzip_mgr;} private Xow_hzip_mgr hzip_mgr;
|
||||
public boolean Importing_ctgs() {return importing_ctgs;} public void Importing_ctgs_(boolean v) {importing_ctgs = v;} private boolean importing_ctgs;
|
||||
public int Img_thumb_width() {return img_thumb_width;} private int img_thumb_width = 220;
|
||||
|
||||
@@ -15,8 +15,9 @@ 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.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public class Xoui_val_fmtr_ {
|
||||
public static Xoui_val_fmtr new_view() {return new Xoui_val_fmtr__view();}
|
||||
public static Xoui_val_fmtr new_edit() {return new Xoui_val_fmtr__edit();}
|
||||
package gplx.xowa.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.json.*;
|
||||
public interface Bridge_cmd_itm {
|
||||
byte[] Key();
|
||||
String Exec(Json_nde data);
|
||||
}
|
||||
38
400_xowa/src/gplx/xowa/html/bridges/Bridge_cmd_mgr.java
Normal file
38
400_xowa/src/gplx/xowa/html/bridges/Bridge_cmd_mgr.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.json.*;
|
||||
public class Bridge_cmd_mgr {
|
||||
private final Hash_adp_bry cmd_hash = Hash_adp_bry.cs_();
|
||||
public void Add(Bridge_cmd_itm cmd) {cmd_hash.Add_bry_obj(cmd.Key(), cmd);}
|
||||
public String Exec(GfoMsg m) {
|
||||
if (m.Args_count() == 0) throw Err_.new_("bridge.cmds", "no json specified for json_exec");
|
||||
return Exec(m.Args_getAt(0).Val_to_bry());
|
||||
}
|
||||
public String Exec(byte[] jdoc_bry) {
|
||||
Json_doc jdoc = null;
|
||||
try {jdoc = Json_doc.new_(jdoc_bry);}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "invalid json", "json", jdoc_bry);}
|
||||
Json_nde msg = jdoc.Root();
|
||||
byte[] key_bry = msg.Get_bry(Key_cmd);
|
||||
Bridge_cmd_itm cmd = (Bridge_cmd_itm)cmd_hash.Get_by_bry(key_bry); if (cmd == null) throw Err_.new_("bridge.cmds", "unknown cmd", "cmd", cmd);
|
||||
try {return cmd.Exec(msg.Get(Key_data));}
|
||||
catch (Exception e) {throw Err_.new_exc(e, "bridge.cmds", "exec json failed", "json", jdoc_bry);}
|
||||
}
|
||||
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_data = Bry_.new_a7("data");
|
||||
}
|
||||
103
400_xowa/src/gplx/xowa/html/bridges/Bridge_msg_bldr.java
Normal file
103
400_xowa/src/gplx/xowa/html/bridges/Bridge_msg_bldr.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
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.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.json.*;
|
||||
public class Bridge_msg_bldr {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
private boolean rslt_pass; private String rslt_msg;
|
||||
private String notify_text; private String notify_status;
|
||||
private final Gfo_tree_list data_root = new Gfo_tree_list("data");
|
||||
public Bridge_msg_bldr() {
|
||||
wtr.Opt_ws_(Bool_.N);
|
||||
this.Clear();
|
||||
}
|
||||
public Bridge_msg_bldr Opt_quote_byte_apos_() {wtr.Opt_quote_byte_(Byte_ascii.Apos); return this;}
|
||||
public Bridge_msg_bldr Rslt_pass_y_() {return Rslt_pass_(Bool_.Y);}
|
||||
public Bridge_msg_bldr Rslt_pass_n_(String v) {Rslt_msg_(v); return Rslt_pass_(Bool_.N);}
|
||||
private Bridge_msg_bldr Rslt_pass_(boolean v) {synchronized(wtr){this.rslt_pass = v;} return this;}
|
||||
private Bridge_msg_bldr Rslt_msg_(String v) {synchronized(wtr){this.rslt_msg = v;} return this;}
|
||||
public Bridge_msg_bldr Notify_hint_(String v) {synchronized(wtr){this.notify_hint = v;} return this;} private String notify_hint;
|
||||
public Bridge_msg_bldr Notify_pass_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "success";} return this;}
|
||||
public Bridge_msg_bldr Notify_fail_(String v){synchronized(wtr){this.notify_text = v; this.notify_status = "error"; this.rslt_pass = false;} return this;}
|
||||
public Bridge_msg_bldr Data(String key, boolean val) {return Data_obj(key, val, ClassAdp_.Tid_bool);}
|
||||
public Bridge_msg_bldr Data(String key, int val) {return Data_obj(key, val, ClassAdp_.Tid_int);}
|
||||
public Bridge_msg_bldr Data(String key, String val) {return Data_obj(key, val, ClassAdp_.Tid_str);}
|
||||
public Bridge_msg_bldr Data(String key, byte[] val) {return Data_obj(key, val, ClassAdp_.Tid_bry);}
|
||||
private Bridge_msg_bldr Data_obj(String key, Object val, int val_tid) {
|
||||
synchronized (wtr) {data_root.Add_data(key, val, val_tid);}
|
||||
return this;
|
||||
}
|
||||
public byte[] To_json_bry() {synchronized(wtr){ Bld_json(); return wtr.To_bry_and_clear();}}
|
||||
public String To_json_str() {synchronized(wtr){ Bld_json(); return wtr.To_str_and_clear();}}
|
||||
public String To_json_str__empty() {return "{}";}
|
||||
public Bridge_msg_bldr Clear() {
|
||||
synchronized (wtr) {
|
||||
rslt_pass = true; // by default, set all msgs to pass==true
|
||||
rslt_msg = null;
|
||||
notify_hint = null;
|
||||
notify_text = null;
|
||||
notify_status = null;
|
||||
data_root.Clear();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private void Bld_json() {
|
||||
wtr.Clear();
|
||||
wtr.Doc_bgn();
|
||||
wtr.Nde_bgn(Key_rslt);
|
||||
wtr.Kv_bool(Key_rslt_pass, rslt_pass);
|
||||
if (rslt_msg != null) wtr.Kv_str(Key_rslt_msg, rslt_msg);
|
||||
wtr.Nde_end();
|
||||
if (notify_text != null) {
|
||||
wtr.Nde_bgn(Key_notify);
|
||||
wtr.Kv_str(Key_notify_text, notify_text);
|
||||
wtr.Kv_str(Key_notify_status, notify_status);
|
||||
if (notify_hint != null)
|
||||
wtr.Kv_str(Key_notify_hint, notify_hint);
|
||||
wtr.Nde_end();
|
||||
}
|
||||
Bld_json_for_hash(wtr, data_root);
|
||||
wtr.Doc_end();
|
||||
}
|
||||
private void Bld_json_for_hash(Json_wtr wtr, Gfo_tree_list hash) {
|
||||
int len = hash.Len(); if (len == 0) return;
|
||||
wtr.Nde_bgn(hash.Key());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfo_tree_itm itm = hash.Get_at(i);
|
||||
if (itm.Tid() == Gfo_tree_itm_.Tid_data) {
|
||||
Gfo_tree_data sub_kv = (Gfo_tree_data)itm;
|
||||
String key = sub_kv.Key(); Object val = sub_kv.Val();
|
||||
switch (sub_kv.Val_tid()) {
|
||||
case ClassAdp_.Tid_bool: wtr.Kv_bool(key, Bool_.cast_(val)); break;
|
||||
case ClassAdp_.Tid_int: wtr.Kv_int(key, Int_.cast_(val)); break;
|
||||
case ClassAdp_.Tid_bry: wtr.Kv_bry(key, (byte[])val); break;
|
||||
default: wtr.Kv_str(key, Object_.Xto_str_strict_or_null_mark(val)); break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Gfo_tree_list sub_hash = (Gfo_tree_list)itm;
|
||||
Bld_json_for_hash(wtr, sub_hash);
|
||||
}
|
||||
}
|
||||
wtr.Nde_end();
|
||||
}
|
||||
private static final byte[]
|
||||
Key_rslt = Bry_.new_a7("rslt"), Key_rslt_pass = Bry_.new_a7("pass"), Key_rslt_msg = Bry_.new_a7("msg")
|
||||
, Key_notify = Bry_.new_a7("notify"), Key_notify_text = Bry_.new_a7("text"), Key_notify_status = Bry_.new_a7("status"), Key_notify_hint = Bry_.new_a7("hint")
|
||||
;
|
||||
}
|
||||
33
400_xowa/src/gplx/xowa/html/bridges/Bridge_msg_bldr_tst.java
Normal file
33
400_xowa/src/gplx/xowa/html/bridges/Bridge_msg_bldr_tst.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import org.junit.*;
|
||||
public class Bridge_msg_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Bridge_msg_bldr_fxt fxt = new Bridge_msg_bldr_fxt();
|
||||
@Test public void Bld() {
|
||||
fxt.Bldr().Rslt_pass_y_().Notify_pass_("passed").Data("key1", true).Data("key2", 1).Data("key3", "val3");
|
||||
fxt.Test_to_json_str("{ 'rslt':{ 'pass':true}, 'notify':{ 'text':'passed', 'status':'success'}, 'data':{ 'key1':true, 'key2':1, 'key3':'val3'}}");
|
||||
}
|
||||
}
|
||||
class Bridge_msg_bldr_fxt {
|
||||
public Bridge_msg_bldr Bldr() {return bldr;} private final Bridge_msg_bldr bldr = new Bridge_msg_bldr().Opt_quote_byte_apos_();
|
||||
public void Clear() {}
|
||||
public void Test_to_json_str(String expd) {
|
||||
Tfds.Eq_str_lines(expd, bldr.To_json_str());
|
||||
}
|
||||
}
|
||||
45
400_xowa/src/gplx/xowa/html/bridges/Gfo_tree_itm.java
Normal file
45
400_xowa/src/gplx/xowa/html/bridges/Gfo_tree_itm.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
interface Gfo_tree_itm {
|
||||
int Tid();
|
||||
}
|
||||
class Gfo_tree_itm_ {
|
||||
public static final int Tid_data = 1, Tid_list = 2;
|
||||
}
|
||||
class Gfo_tree_data implements Gfo_tree_itm {
|
||||
public int Tid() {return Gfo_tree_itm_.Tid_data;}
|
||||
public Gfo_tree_data(String key, Object val, int val_tid) {
|
||||
this.key = key; this.val = val; this.val_tid = val_tid;
|
||||
}
|
||||
public String Key() {return key;} private final String key;
|
||||
public Object Val() {return val;} private final Object val;
|
||||
public int Val_tid() {return val_tid;} private final int val_tid;
|
||||
}
|
||||
class Gfo_tree_list implements Gfo_tree_itm {
|
||||
private final Ordered_hash list = Ordered_hash_.new_();
|
||||
public Gfo_tree_list(String key) {this.key = key;}
|
||||
public int Tid() {return Gfo_tree_itm_.Tid_list;}
|
||||
public String Key() {return key;} private final String key;
|
||||
public void Clear() {list.Clear();}
|
||||
public int Len() {return list.Count();}
|
||||
public Gfo_tree_data Add_data(String key, Object val, int val_tid) {Gfo_tree_data rv = new Gfo_tree_data(key, val, val_tid); this.Add(key, rv); return rv;}
|
||||
public Gfo_tree_list Add_list(String key) {Gfo_tree_list rv = new Gfo_tree_list(key); this.Add(key, rv); return rv;}
|
||||
private void Add(String key, Gfo_tree_itm itm) {list.Add(key, itm);}
|
||||
public Gfo_tree_itm Get_at(int i) {return (Gfo_tree_itm)list.Get_at(i);}
|
||||
}
|
||||
23
400_xowa/src/gplx/xowa/html/bridges/Xoh_bridge_mgr.java
Normal file
23
400_xowa/src/gplx/xowa/html/bridges/Xoh_bridge_mgr.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
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.html.bridges; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
public class Xoh_bridge_mgr {
|
||||
public Bridge_cmd_mgr Cmd_mgr() {return cmd_mgr;} private final Bridge_cmd_mgr cmd_mgr = new Bridge_cmd_mgr();
|
||||
public Bridge_msg_bldr Msg_bldr() {return msg_bldr;} private final Bridge_msg_bldr msg_bldr = new Bridge_msg_bldr();
|
||||
}
|
||||
87
400_xowa/src/gplx/xowa/html/bridges/dbuis/Dbui_cmd_mgr.java
Normal file
87
400_xowa/src/gplx/xowa/html/bridges/dbuis/Dbui_cmd_mgr.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
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.html.bridges.dbuis; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*;
|
||||
import gplx.core.json.*; import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
public class Dbui_cmd_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private boolean init;
|
||||
public void Init_by_bridge(Bridge_cmd_mgr cmd_mgr) {
|
||||
if (init) return;
|
||||
init = true;
|
||||
cmd_mgr.Add(new Dbui_cmd_row_edit ("xowa.dbui.edit_bgn", this));
|
||||
cmd_mgr.Add(new Dbui_cmd_row_save ("xowa.dbui.save_bgn", this));
|
||||
cmd_mgr.Add(new Dbui_cmd_row_del ("xowa.dbui.delete_bgn", this));
|
||||
cmd_mgr.Add(new Dbui_cmd_row_reorder ("xowa.dbui.reorder_bgn", this));
|
||||
}
|
||||
public void Add(Dbui_tbl_itm tbl) {hash.Add_bry_obj(tbl.Key(), tbl);}
|
||||
public String Del(Json_nde data) {return Get_tbl(data).Del (data.Get_bry(Arg_row_id), data.Get_bry(Arg_row_pkey));}
|
||||
public String Edit(Json_nde data) {return Get_tbl(data).Edit(data.Get_bry(Arg_row_id), data.Get_bry(Arg_row_pkey));}
|
||||
public String Save(Json_nde data) {return Get_tbl(data).Save(data.Get_bry(Arg_row_id), data.Get_bry(Arg_row_pkey), To_hash(data.Get(Arg_vals)));}
|
||||
public String Reorder(Json_nde data){
|
||||
byte[] pkeys_concat = data.Get_bry(Arg_pkeys);
|
||||
return Get_tbl(data).Reorder(Bry_.Split(pkeys_concat, Byte_ascii.Pipe), -1);
|
||||
}
|
||||
private Dbui_tbl_itm Get_tbl(Json_nde data) {
|
||||
byte[] tbl_key = data.Get_bry(Arg_tbl_key);
|
||||
Dbui_tbl_itm rv = (Dbui_tbl_itm)hash.Get_by(tbl_key); if (rv == null) throw Err_.new_("dbui", "unknown tbl_key", "tbl_key", tbl_key);
|
||||
return rv;
|
||||
}
|
||||
private static Dbui_val_hash To_hash(Json_grp grp) {
|
||||
Dbui_val_hash rv = new Dbui_val_hash();
|
||||
int len = grp.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv kv = (Json_itm_kv)grp.Get_at(i);
|
||||
Json_nde nde = (Json_nde)kv.Val();
|
||||
Json_itm_kv key = (Json_itm_kv)nde.Get_itm(Arg_key);
|
||||
Json_itm_kv val = (Json_itm_kv)nde.Get_itm(Arg_val);
|
||||
Dbui_val_itm fld = new Dbui_val_itm(val.Val().Data_bry(), Bry_.Empty);
|
||||
rv.Add(key.Val().Data_bry(), fld);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static final Dbui_cmd_mgr I = new Dbui_cmd_mgr(); Dbui_cmd_mgr() {}
|
||||
private static final byte[]
|
||||
Arg_tbl_key = Bry_.new_a7("tbl_key"), Arg_row_pkey = Bry_.new_a7("row_pkey"), Arg_row_id = Bry_.new_a7("row_id")
|
||||
, Arg_vals = Bry_.new_a7("vals"), Arg_key = Bry_.new_a7("key"), Arg_val = Bry_.new_a7("val")
|
||||
, Arg_pkeys = Bry_.new_a7("pkeys")
|
||||
;
|
||||
}
|
||||
class Dbui_cmd_row_del implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_del(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Del(data);}
|
||||
}
|
||||
class Dbui_cmd_row_edit implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_edit(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Edit(data);}
|
||||
}
|
||||
class Dbui_cmd_row_save implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_save(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Save(data);}
|
||||
}
|
||||
class Dbui_cmd_row_reorder implements Bridge_cmd_itm {
|
||||
private final Dbui_cmd_mgr mgr;
|
||||
public Dbui_cmd_row_reorder(String key, Dbui_cmd_mgr mgr) {this.key = Bry_.new_u8(key); this.mgr = mgr;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public String Exec(Json_nde data) {return mgr.Reorder(data);}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
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.html.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
public class Dbui_cells_fmtr implements Bry_fmtr_arg {
|
||||
private final Dbui_cell_fmtr cell_fmtr = new Dbui_cell_fmtr();
|
||||
private final Dbui_btn_fmtr btn_fmtr = new Dbui_btn_fmtr();
|
||||
private Dbui_btn_itm[] btns;
|
||||
private byte[] row_key; private Dbui_row_itm row_itm;
|
||||
public void Ctor(Dbui_val_fmtr val_fmtr, Dbui_btn_itm[] btns) {
|
||||
cell_fmtr.Ctor(val_fmtr); this.btns = btns;
|
||||
}
|
||||
public Dbui_cells_fmtr Init(byte[] row_key, Dbui_row_itm row_itm) {
|
||||
this.row_key = row_key; this.row_itm = row_itm;
|
||||
return this;
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
fmtr.Bld_bfr_many(bfr, cell_fmtr.Init(row_key, row_itm), btn_fmtr.Init(row_key, btns));
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='xo_drag_handle xo_cell'></div>~{vals}"
|
||||
, " <div class='xo_cell'>~{btns}"
|
||||
, " </div>"
|
||||
), "vals", "btns");
|
||||
}
|
||||
class Dbui_cell_fmtr implements Bry_fmtr_arg {
|
||||
private byte[] row_key; private Dbui_row_itm row_itm;
|
||||
private Dbui_val_fmtr val_fmtr;
|
||||
public void Ctor(Dbui_val_fmtr val_fmtr) {this.val_fmtr = val_fmtr;}
|
||||
public Dbui_cell_fmtr Init(byte[] row_key, Dbui_row_itm row_itm) {this.row_key = row_key; this.row_itm = row_itm; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
Dbui_col_itm[] cols = row_itm.Tbl().Cols();
|
||||
Dbui_val_itm[] vals = row_itm.Vals(); int len = vals.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_val_itm val = vals[i];
|
||||
fmtr.Bld_bfr_many(bfr, row_key, i, val_fmtr.Init(cols[i], row_key, val));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='xo_cell'>~{html}</div>"
|
||||
), "row_key", "val_idx", "html");
|
||||
}
|
||||
class Dbui_btn_fmtr implements Bry_fmtr_arg {
|
||||
private byte[] row_key; private Dbui_btn_itm[] btns;
|
||||
public Dbui_btn_fmtr Init(byte[] row_key, Dbui_btn_itm[] btns) {
|
||||
this.row_key = row_key; this.btns = btns; return this;
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
int len = btns.length;
|
||||
Io_url img_dir = gplx.xowa.html.heads.Xoh_head_itm__dbui.Img_dir();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_btn_itm btn = btns[i];
|
||||
fmtr.Bld_bfr_many(bfr, row_key, btn.Cmd(), img_dir.GenSubFil(btn.Img()).To_http_file_bry(), btn.Text());
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <span><a href='javascript:~{btn_cmd}(\"~{row_key}\");'><img src='~{btn_img}' title='~{btn_text}'/></a></span>"
|
||||
), "row_key", "btn_cmd", "btn_img", "btn_text");
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
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.html.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
public class Dbui_tbl_fmtr {
|
||||
private final Dbui_head_cell_fmtr head_cell_fmtr = new Dbui_head_cell_fmtr();
|
||||
private final Dbui_row_fmtr row_fmtr = new Dbui_row_fmtr();
|
||||
public void Write(Bry_bfr bfr, Dbui_tbl_itm tbl, byte[] origin_html, byte[] delete_confirm_msg, Dbui_row_itm[] rows) {
|
||||
tbl_fmtr.Bld_bfr_many(bfr, tbl.Key(), Dbui_tbl_itm_.Calc_width(tbl), origin_html, delete_confirm_msg, head_cell_fmtr.Init(tbl), row_fmtr.Init(tbl, rows));
|
||||
}
|
||||
private static final Bry_fmtr tbl_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div class='xo_tbl xo_sortable' data-dbui-tbl_key='~{tbl_key}'~{delete_confirm_msg} style='width: ~{width}px;'>"
|
||||
, " <div class='xo_row xo_header'>"
|
||||
, " <div class='xo_origin xo_resizable_col' style='width:20px'>~{origin}</div>~{head_cells}"
|
||||
, " </div>~{data_rows}"
|
||||
, "</div>"
|
||||
), "tbl_key", "width", "origin", "delete_confirm_msg", "head_cells", "data_rows");
|
||||
}
|
||||
class Dbui_head_cell_fmtr implements Bry_fmtr_arg {
|
||||
private Dbui_tbl_itm tbl;
|
||||
public Dbui_head_cell_fmtr Init(Dbui_tbl_itm tbl) {this.tbl = tbl; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
Dbui_col_itm[] cols = tbl.Cols(); int len = cols.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_col_itm col = cols[i];
|
||||
fmtr.Bld_bfr_many(bfr, col.Width(), col.Display());
|
||||
}
|
||||
bfr.Add_str_a7("\n <div class='xo_head xo_resizable_col' style='width:35px;'> </div>"); // btns headers
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='xo_head xo_resizable_col' style='width:~{width}px;'>~{display}</div>"
|
||||
), "width", "display");
|
||||
}
|
||||
class Dbui_row_fmtr implements Bry_fmtr_arg {
|
||||
private final Dbui_cells_fmtr cells_fmtr = new Dbui_cells_fmtr();
|
||||
private final Dbui_val_fmtr val_fmtr = Dbui_val_fmtr_.new_view();
|
||||
private final Bry_bfr row_key_bfr = Bry_bfr.new_(255);
|
||||
private Dbui_tbl_itm tbl; private Dbui_row_itm[] rows;
|
||||
public Dbui_row_fmtr Init(Dbui_tbl_itm tbl, Dbui_row_itm[] rows) {this.tbl = tbl; this.rows = rows; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
byte[] tbl_key = tbl.Key();
|
||||
int len = rows.length;
|
||||
cells_fmtr.Ctor(val_fmtr, tbl.View_btns());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Dbui_row_itm row = rows[i];
|
||||
row_key_bfr.Add(tbl_key).Add_byte(Byte_ascii.Underline).Add_int_variable(i);
|
||||
byte[] row_key = row_key_bfr.Xto_bry_and_clear();
|
||||
fmtr.Bld_bfr_many(bfr, row_key, row.Pkey(), cells_fmtr.Init(row_key, row));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div id='~{row_key}' class='xo_row xo_draggable' data-dbui-row_pkey='~{pkey}'>~{cells}"
|
||||
, " </div>"
|
||||
), "row_key", "pkey", "cells");
|
||||
}
|
||||
@@ -15,11 +15,11 @@ 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.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
import gplx.xowa.html.xouis.tbls.*;
|
||||
package gplx.xowa.html.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
import org.junit.*;
|
||||
public class Xoui_tbl_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoui_tbl_fmtr_fxt fxt = new Xoui_tbl_fmtr_fxt();
|
||||
public class Dbui_tbl_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Dbui_tbl_fmtr_fxt fxt = new Dbui_tbl_fmtr_fxt();
|
||||
@Test public void Basic() {
|
||||
// fxt.Test_write
|
||||
// ( fxt.Make_tbl()
|
||||
@@ -27,15 +27,15 @@ public class Xoui_tbl_fmtr_tst {
|
||||
// );
|
||||
}
|
||||
}
|
||||
class Xoui_tbl_fmtr_fxt {
|
||||
class Dbui_tbl_fmtr_fxt {
|
||||
private final Bry_bfr bfr = Bry_bfr.new_(255);
|
||||
private final Xoui_tbl_fmtr tbl_fmtr = new Xoui_tbl_fmtr();
|
||||
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
|
||||
public void Clear() {}
|
||||
public Xoui_tbl_itm Make_tbl() {
|
||||
public Dbui_tbl_itm Make_tbl() {
|
||||
return null;
|
||||
}
|
||||
public void Test_write(Xoui_tbl_itm tbl, String expd) {
|
||||
tbl_fmtr.Write(bfr, tbl);
|
||||
public void Test_write(Dbui_tbl_itm tbl, String expd) {
|
||||
tbl_fmtr.Write(bfr, tbl, null, null, null);
|
||||
Tfds.Eq_str_lines(expd, bfr.Xto_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.html.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
public interface Dbui_val_fmtr {
|
||||
Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val);
|
||||
}
|
||||
class Dbui_val_fmtr__view implements Bry_fmtr_arg, Dbui_val_fmtr {
|
||||
private Dbui_val_itm val;
|
||||
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.val = val; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
bfr.Add(val.Html());
|
||||
}
|
||||
}
|
||||
class Dbui_val_fmtr__edit implements Bry_fmtr_arg, Dbui_val_fmtr {
|
||||
private Dbui_col_itm col; private byte[] row_id; private Dbui_val_itm val;
|
||||
public Dbui_val_fmtr Init(Dbui_col_itm col, byte[] row_id, Dbui_val_itm val) {this.col = col; this.row_id = row_id; this.val = val; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
switch (col.Type()) {
|
||||
case Dbui_col_itm.Type_id_str: input_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
|
||||
case Dbui_col_itm.Type_id_text: textarea_fmtr_str.Bld_bfr_many(bfr, col.Key(), col.Width(), val.Data(), row_id); break;
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr input_fmtr_str = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <input class='dbui_cell xo_resizable_col' dbui_col='~{col_key}' style='border:1px solid black; width:~{width}px' value='~{value}' onkeyup='Dbui__edit__keyup(event, \"~{row_id}\");'/>"
|
||||
), "col_key", "width", "value", "row_id");
|
||||
private static final Bry_fmtr textarea_fmtr_str = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <textarea class='dbui_cell' dbui_col='~{col_key}' style='border:1px solid black; width:~{width}px; height:18px;' onkeyup='Dbui__edit__keyup(event, \"~{row_id}\");'>~{value}</textarea>"
|
||||
), "col_key", "width", "value", "row_id");
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.html.bridges.dbuis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_val_fmtr_ {
|
||||
public static Dbui_val_fmtr new_view() {return new Dbui_val_fmtr__view();}
|
||||
public static Dbui_val_fmtr new_edit() {return new Dbui_val_fmtr__edit();}
|
||||
}
|
||||
@@ -15,9 +15,9 @@ 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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public class Xoui_btn_itm {
|
||||
public Xoui_btn_itm(String cmd, String img, String text) {this.cmd = cmd; this.img = img; this.text = text;}
|
||||
package gplx.xowa.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_btn_itm {
|
||||
public Dbui_btn_itm(String cmd, String img, String text) {this.cmd = cmd; this.img = img; this.text = text;}
|
||||
public String Key() {return text;}
|
||||
public String Cmd() {return cmd;} private final String cmd;
|
||||
public String Img() {return img;} private final String img;
|
||||
@@ -15,12 +15,12 @@ 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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public class Xoui_col_itm {
|
||||
public Xoui_col_itm(int type, int width, String key, String display) {this.type = type; this.width = width; this.key = key; this.display = display;}
|
||||
package gplx.xowa.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_col_itm {
|
||||
public Dbui_col_itm(int type, int width, String key, String display) {this.type = type; this.width = width; this.key = key; this.display = display;}
|
||||
public int Type() {return type;} private final int type;
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Display() {return display;} private final String display;
|
||||
public int Width() {return width;} private final int width;
|
||||
public static final int Type_id_str = 1;
|
||||
public static final int Type_id_str = 1, Type_id_text = 2;
|
||||
}
|
||||
@@ -15,12 +15,12 @@ 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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public class Xoui_row_itm {
|
||||
public Xoui_row_itm(Xoui_tbl_itm tbl, byte[] pkey, Xoui_val_itm[] vals) {
|
||||
package gplx.xowa.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_row_itm {
|
||||
public Dbui_row_itm(Dbui_tbl_itm tbl, byte[] pkey, Dbui_val_itm[] vals) {
|
||||
this.tbl = tbl; this.pkey = pkey; this.vals = vals;
|
||||
}
|
||||
public Xoui_tbl_itm Tbl() {return tbl;} private final Xoui_tbl_itm tbl;
|
||||
public Dbui_tbl_itm Tbl() {return tbl;} private final Dbui_tbl_itm tbl;
|
||||
public byte[] Pkey() {return pkey;} private final byte[] pkey;
|
||||
public Xoui_val_itm[] Vals() {return vals;} private Xoui_val_itm[] vals;
|
||||
public Dbui_val_itm[] Vals() {return vals;} private Dbui_val_itm[] vals;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public interface Dbui_tbl_itm {
|
||||
byte[] Key();
|
||||
Dbui_col_itm[] Cols();
|
||||
Dbui_btn_itm[] View_btns();
|
||||
Dbui_btn_itm[] Edit_btns();
|
||||
String Del (byte[] row_id, byte[] row_pkey);
|
||||
String Edit(byte[] row_id, byte[] row_pkey);
|
||||
String Save(byte[] row_id, byte[] row_pkey, Dbui_val_hash vals);
|
||||
String Reorder(byte[][] pkeys, int owner);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_tbl_itm_ {
|
||||
public static int Calc_width(Dbui_tbl_itm tbl) {
|
||||
int rv = 40; // 40 for button col
|
||||
Dbui_col_itm[] ary = tbl.Cols();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
rv += ary[i].Width();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,13 @@ 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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public class Xoui_val_hash {
|
||||
package gplx.xowa.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_val_hash {
|
||||
private final Ordered_hash hash = Ordered_hash_.new_bry_();
|
||||
public void Add(byte[] key, Xoui_val_itm itm) {hash.Add(key, itm);}
|
||||
public byte[] Get_val_as_bry_or_fail(byte[] key) {
|
||||
Xoui_val_itm itm = (Xoui_val_itm)hash.Get_by(key); if (itm == null) throw Exc_.new_("dbui.val_hash; unknown key", "key", key);
|
||||
public void Add(byte[] key, Dbui_val_itm itm) {hash.Add(key, itm);}
|
||||
public byte[] Get_val_as_bry(String key) {return Get_val_as_bry(Bry_.new_u8(key));}
|
||||
public byte[] Get_val_as_bry(byte[] key) {
|
||||
Dbui_val_itm itm = (Dbui_val_itm)hash.Get_by(key); if (itm == null) throw Err_.new_wo_type("dbui.val_hash; unknown key", "key", key);
|
||||
return itm.Data();
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,9 @@ 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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public class Xoui_val_itm {
|
||||
public Xoui_val_itm(byte[] data, byte[] html) {this.data = data; this.html = html;}
|
||||
package gplx.xowa.html.bridges.dbuis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*;
|
||||
public class Dbui_val_itm {
|
||||
public Dbui_val_itm(byte[] data, byte[] html) {this.data = data; this.html = html;}
|
||||
public byte[] Data() {return data;} private byte[] data;
|
||||
public byte[] Html() {return html;} private final byte[] html;
|
||||
public void Data_(byte[] v) {this.data = v;}
|
||||
@@ -16,8 +16,8 @@ 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.html.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.html.hdumps.data.*; import gplx.xowa.html.hzips.*; import gplx.xowa.html.hdumps.abrvs.*; import gplx.xowa.html.hdumps.pages.*;
|
||||
import gplx.xowa.pages.*; import gplx.xowa.pages.skins.*; import gplx.xowa.html.modules.*;
|
||||
import gplx.xowa.html.heads.*; import gplx.xowa.html.hdumps.data.*; import gplx.xowa.html.hzips.*; import gplx.xowa.html.hdumps.abrvs.*; import gplx.xowa.html.hdumps.pages.*;
|
||||
import gplx.xowa.pages.*; import gplx.xowa.pages.skins.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa2.gui.*;
|
||||
public class Xohd_hdump_rdr {
|
||||
private final Bry_bfr_mkr bfr_mkr; private final Xow_hzip_mgr hzip_mgr;
|
||||
@@ -39,7 +39,7 @@ public class Xohd_hdump_rdr {
|
||||
html_data.Display_ttl_(hpg.Display_ttl());
|
||||
html_data.Content_sub_(hpg.Content_sub());
|
||||
html_data.Xtn_skin_mgr().Add(new Xopg_xtn_skin_itm_stub(hpg.Sidebar_div()));
|
||||
Load_module_mgr(html_data.Module_mgr(), hpg);
|
||||
Load_module_mgr(html_data.Head_mgr(), hpg);
|
||||
for (gplx.xowa.html.hdumps.core.Xohd_data_itm__base itm : hpg.Img_itms())
|
||||
page.Hdump_data().Imgs_add(itm);
|
||||
}
|
||||
@@ -78,8 +78,8 @@ public class Xohd_hdump_rdr {
|
||||
if (redirect_id == -1) break;
|
||||
}
|
||||
}
|
||||
public static void Load_module_mgr(Xoh_module_mgr page_module_mgr, Xog_page hpg) {
|
||||
Xopg_module_mgr dump_module_mgr = hpg.Module_mgr();
|
||||
public static void Load_module_mgr(Xoh_head_mgr page_module_mgr, Xog_page hpg) {
|
||||
Xopg_module_mgr dump_module_mgr = hpg.Head_mgr();
|
||||
page_module_mgr.Itm__mathjax().Enabled_ (dump_module_mgr.Math_exists());
|
||||
page_module_mgr.Itm__popups().Bind_hover_area_ (dump_module_mgr.Imap_exists());
|
||||
page_module_mgr.Itm__gallery().Enabled_ (dump_module_mgr.Gallery_packed_exists());
|
||||
|
||||
@@ -49,21 +49,21 @@ public class Xohd_abrv_ {
|
||||
;
|
||||
public static Btrie_slim_mgr new_trie() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.cs_();
|
||||
trie_itm(rv, Tid_dir , Byte_ascii.Nil , Key_dir);
|
||||
trie_itm(rv, Tid_dir , Byte_ascii.Null , Key_dir);
|
||||
trie_itm(rv, Tid_img , Byte_ascii.Apos , Key_img);
|
||||
trie_itm(rv, Tid_img_style , Byte_ascii.Apos , Key_img_style);
|
||||
trie_itm(rv, Tid_file_play , Byte_ascii.Apos , Key_file_play);
|
||||
trie_itm(rv, Tid_file_info , Byte_ascii.Apos , Key_file_info);
|
||||
trie_itm(rv, Tid_file_mgnf , Byte_ascii.Apos , Key_file_mgnf);
|
||||
trie_itm(rv, Tid_hiero_dir , Byte_ascii.Nil , Key_hiero_dir);
|
||||
trie_itm(rv, Tid_hiero_dir , Byte_ascii.Null , Key_hiero_dir);
|
||||
trie_itm(rv, Tid_gallery_box_max , Byte_ascii.Apos , Key_gallery_box_max);
|
||||
trie_itm(rv, Tid_gallery_box_w , Byte_ascii.Apos , Key_gallery_box_w);
|
||||
trie_itm(rv, Tid_gallery_img_w , Byte_ascii.Apos , Key_gallery_img_w);
|
||||
trie_itm(rv, Tid_gallery_img_pad , Byte_ascii.Apos , Key_gallery_img_pad);
|
||||
trie_itm(rv, Tid_redlink , Byte_ascii.Apos , Key_redlink);
|
||||
trie_itm(rv, Tid_toc , Byte_ascii.Nil , Key_toc);
|
||||
// trie_itm(rv, Tid_hdr_bgn , Byte_ascii.Nil , Key_hdr_bgn);
|
||||
// trie_itm(rv, Tid_hdr_end , Byte_ascii.Nil , Key_hdr_end);
|
||||
trie_itm(rv, Tid_toc , Byte_ascii.Null , Key_toc);
|
||||
// trie_itm(rv, Tid_hdr_bgn , Byte_ascii.Null , Key_hdr_bgn);
|
||||
// trie_itm(rv, Tid_hdr_end , Byte_ascii.Null , Key_hdr_end);
|
||||
return rv;
|
||||
}
|
||||
private static void trie_itm(Btrie_slim_mgr trie, byte tid, byte subst_end_byte, byte[] key_bry) {
|
||||
|
||||
@@ -68,7 +68,7 @@ public class Xohd_abrv_mgr {
|
||||
}
|
||||
private int Write_data(Bry_bfr bfr, Xoh_file_html_fmtr__base fmtr, Xog_page hpg, byte[] src, Xohd_data_itm__base[] imgs, int imgs_len, int uid_bgn, Hdump_html_fmtr_itm itm) {
|
||||
bry_rdr.Pos_(uid_bgn);
|
||||
int uid = itm.Subst_end_byte() == Byte_ascii.Nil ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
|
||||
int uid = itm.Subst_end_byte() == Byte_ascii.Null ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
|
||||
int uid_end = bry_rdr.Pos(); // set uid_end after subst_end
|
||||
int rv = uid_end;
|
||||
byte tid = itm.Tid();
|
||||
@@ -132,7 +132,7 @@ public class Xohd_abrv_mgr {
|
||||
if (tid == Xohd_abrv_.Tid_img) {
|
||||
fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.Html_h());
|
||||
}
|
||||
} catch (Exception e) {Xoa_app_.Usr_dlg().Warn_many("", "", "abrv.read: page=~{0} itm=~{1} err=~{2}", hpg.Url_bry_safe(), img == null ? "<NULL>" : img.Data_print(), Err_.Message_gplx(e));}
|
||||
} catch (Exception e) {Xoa_app_.Usr_dlg().Warn_many("", "", "abrv.read: page=~{0} itm=~{1} err=~{2}", hpg.Url_bry_safe(), img == null ? "<NULL>" : img.Data_print(), Err_.Message_gplx_full(e));}
|
||||
return rv;
|
||||
}
|
||||
private int Write_redlink(Bry_bfr bfr, Xog_page hpg, int uid, int rv) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Xob_link_dump_cmd {
|
||||
tbl.Create_idx_2();
|
||||
conn.Env_vacuum();
|
||||
} catch (Exception e) {
|
||||
Tfds.Write(Err_.Message_gplx(e));
|
||||
Tfds.Write(Err_.Message_gplx_full(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Xohd_page_html_mgr__load {
|
||||
switch (tid) {
|
||||
case Xohd_data_itm__base.Tid_basic : img_itm = new Xohd_data_itm__img(); break;
|
||||
case Xohd_data_itm__base.Tid_gallery : img_itm = new Xohd_data_itm__gallery_itm(); break;
|
||||
default : throw Exc_.new_unhandled(tid);
|
||||
default : throw Err_.new_unhandled(tid);
|
||||
}
|
||||
img_itm.Data_parse(rdr);
|
||||
// Xoa_app_.Usr_dlg().Log_many("", "", "itm: ~{0}", img_itm.Data_print());
|
||||
|
||||
@@ -35,7 +35,7 @@ abstract class Xohd_page_srl_itm__base implements Xohd_page_srl_itm {
|
||||
}
|
||||
public abstract byte[] Save_itm(Xog_page hpg);
|
||||
public int Load(Xog_page hpg, byte[] bry, int bry_len, int itm_bgn, Int_obj_ref count_ref) {
|
||||
int itm_len = Xow_hzip_int_.Load_bin_int_abrv(bry, bry_len, itm_bgn, count_ref); if (itm_len == -1) throw Exc_.new_("bry_itm has invalid len", "page", hpg.Page_id(), "tid", this.Tid());
|
||||
int itm_len = Xow_hzip_int_.Load_bin_int_abrv(bry, bry_len, itm_bgn, count_ref); if (itm_len == -1) throw Err_.new_wo_type("bry_itm has invalid len", "page", hpg.Page_id(), "tid", this.Tid());
|
||||
int data_bgn = itm_bgn + count_ref.Val(); if (itm_len == 0) return data_bgn;
|
||||
int data_end = data_bgn + itm_len;
|
||||
byte[] itm_data = Bry_.Mid(bry, data_bgn, data_end);
|
||||
|
||||
@@ -66,7 +66,7 @@ class Xog_page_bldr {
|
||||
public Xog_page Bld() {
|
||||
Xog_page rv = new Xog_page();
|
||||
rv.Page_body_(body);
|
||||
Xopg_module_mgr mod_mgr = rv.Module_mgr();
|
||||
Xopg_module_mgr mod_mgr = rv.Head_mgr();
|
||||
if (html_modules != null) {
|
||||
mod_mgr.Math_exists_(html_modules[0]);
|
||||
mod_mgr.Imap_exists_(html_modules[1]);
|
||||
|
||||
@@ -44,7 +44,7 @@ class Xohd_page_srl_itm__html_module implements Xohd_page_srl_itm {
|
||||
public int Load(Xog_page hpg, byte[] bry, int bry_len, int itm_bgn, Int_obj_ref count_ref) {
|
||||
itm_bgn += 2; // skip bin_int_abrv of [1, 0]
|
||||
byte flag = bry[itm_bgn];
|
||||
hpg.Module_mgr().Init(Enm_.Has_byte(flag, Tid_math), Enm_.Has_byte(flag, Tid_imap), Enm_.Has_byte(flag, Tid_packed), Enm_.Has_byte(flag, Tid_hiero));
|
||||
hpg.Head_mgr().Init(Enm_.Has_byte(flag, Tid_math), Enm_.Has_byte(flag, Tid_imap), Enm_.Has_byte(flag, Tid_packed), Enm_.Has_byte(flag, Tid_hiero));
|
||||
return 3;
|
||||
}
|
||||
public void Save(Xog_page hpg, Bry_bfr bfr) {
|
||||
@@ -55,7 +55,7 @@ class Xohd_page_srl_itm__html_module implements Xohd_page_srl_itm {
|
||||
bfr.Add_byte(flag);
|
||||
}
|
||||
private static byte Calc_flag(Xog_page hpg) {
|
||||
Xopg_module_mgr module_mgr = hpg.Module_mgr();
|
||||
Xopg_module_mgr module_mgr = hpg.Head_mgr();
|
||||
return Calc_flag(module_mgr.Math_exists(), module_mgr.Imap_exists(), module_mgr.Gallery_packed_exists(), module_mgr.Hiero_exists());
|
||||
}
|
||||
public static byte Calc_flag(boolean math, boolean imap, boolean packed, boolean hiero) {
|
||||
|
||||
38
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm_.java
Normal file
38
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm_.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_head_itm_ {
|
||||
public static final byte[] // SRL: navframe, toc, title_rewrite are in wiki.cfg
|
||||
Key__collapsible = Bry_.new_a7("collapsible")
|
||||
, Key__css = Bry_.new_a7("css")
|
||||
, Key__gallery = Bry_.new_a7("gallery")
|
||||
, Key__globals = Bry_.new_a7("globals")
|
||||
, Key__hiero = Bry_.new_a7("hiero")
|
||||
, Key__mathjax = Bry_.new_a7("mathjax")
|
||||
, Key__navframe = Bry_.new_a7("navframe")
|
||||
, Key__popups = Bry_.new_a7("popups")
|
||||
, Key__search_suggest = Bry_.new_a7("xowa.search_suggest")
|
||||
, Key__timeline = Bry_.new_a7("xowa.timeline")
|
||||
, Key__title_rewrite = Bry_.new_a7("title_rewrite")
|
||||
, Key__toc = Bry_.new_a7("toc")
|
||||
, Key__top_icon = Bry_.new_a7("top_icon")
|
||||
, Key__dbui = Bry_.new_a7("dbui")
|
||||
, Key__bmk = Bry_.new_a7("bmk")
|
||||
, Key__server = Bry_.new_a7("server")
|
||||
;
|
||||
}
|
||||
48
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__base.java
Normal file
48
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__base.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public abstract class Xoh_head_itm__base {
|
||||
public abstract byte[] Key();
|
||||
public abstract int Flags();
|
||||
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} public void Enabled_y_() {this.Enabled_(Bool_.Y);} public void Enabled_n_() {this.Enabled_(Bool_.N);} private boolean enabled;
|
||||
@gplx.Virtual public void Clear() {this.Enabled_(Bool_.N);}
|
||||
@gplx.Virtual public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
@gplx.Virtual public void Write_css_text(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
@gplx.Virtual public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
@gplx.Virtual public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
@gplx.Virtual public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
@gplx.Virtual public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
@gplx.Virtual public void Write_js_window_onload(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {}
|
||||
public static final int
|
||||
Flag__disabled = 0
|
||||
, Flag__css_include = 1
|
||||
, Flag__css_text = 2
|
||||
, Flag__js_include = 4
|
||||
, Flag__js_head_global = 8
|
||||
, Flag__js_head_script = 16
|
||||
, Flag__js_tail_script = 32
|
||||
, Flag__js_window_onload = 64
|
||||
;
|
||||
public static final int Idx__max = 7;
|
||||
}
|
||||
/*
|
||||
Position // top, bottom
|
||||
Targets // mobile, desktop
|
||||
Dependencies
|
||||
Messages
|
||||
*/
|
||||
@@ -15,18 +15,11 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_module_itm__collapsible implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_collapsible;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_head_itm__collapsible extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__collapsible;}
|
||||
@Override public int Flags() {return Flag__js_head_global;}
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_global_ini_atr_val(Key_enabled , true);
|
||||
wtr.Write_js_global_ini_atr_val(Key_collapsed , app.Api_root().Html().Modules().Collapsible().Collapsed());
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_collapse);
|
||||
31
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__css.java
Normal file
31
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__css.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_head_itm__css extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__css;}
|
||||
@Override public int Flags() {return Flag__css_text;}
|
||||
@Override public void Write_css_text(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_css_style_itm(app.Ctg_mgr().Missing_ctg_cls_css());
|
||||
if (app.Html_mgr().Page_mgr().Font_enabled())
|
||||
wtr.Write_css_style_itm(app.Html_mgr().Page_mgr().Font_css_bry());
|
||||
byte[] css_xtn = app.Gui_mgr().Html_mgr().Css_xtn();
|
||||
if (Bry_.Len_gt_0(css_xtn))
|
||||
wtr.Write_css_style_itm(css_xtn);
|
||||
}
|
||||
}
|
||||
123
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__dbui.java
Normal file
123
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__dbui.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_head_itm__dbui extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__dbui;}
|
||||
@Override public int Flags() {return Flag__css_text | Flag__css_include | Flag__js_tail_script | Flag__js_window_onload;}
|
||||
public Xoh_head_itm__dbui Init(Xoa_app app) {
|
||||
if (dir_url == null) {
|
||||
Io_url url_html_res = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("xowa", "html", "res");
|
||||
dir_url = url_html_res.GenSubDir_nest("src", "xowa", "dbui");
|
||||
url_dbui_js = dir_url.GenSubFil("dbui-0.1.1.js").To_http_file_bry();
|
||||
url_jquery_ui_js = url_html_res.GenSubFil_nest("lib", "jquery-ui", "jquery-ui-1.11.4.js").To_http_file_bry();
|
||||
url_jquery_ui_css = url_html_res.GenSubFil_nest("lib", "jquery-ui", "jquery-ui-1.11.4.css").To_http_file_bry();
|
||||
url_notify_js = url_html_res.GenSubFil_nest("lib", "notifyjs" , "notifyjs-0.3.1.js").To_http_file_bry();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_css_include(url_jquery_ui_css);
|
||||
}
|
||||
@Override public void Write_css_text(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_css_style_ary(Css__table_as_div);
|
||||
}
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_tail_load_lib(url_dbui_js);
|
||||
wtr.Write_js_tail_load_lib(url_notify_js);
|
||||
wtr.Write_js_tail_load_lib(url_jquery_ui_js);
|
||||
}
|
||||
@Override public void Write_js_window_onload(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_lines(Js__sortable);
|
||||
}
|
||||
public static Io_url Img_dir() {return dir_url.GenSubDir("img");} private static Io_url dir_url;
|
||||
private static byte[] url_dbui_js, url_notify_js, url_jquery_ui_js, url_jquery_ui_css;
|
||||
private static final byte[][]
|
||||
Css__table_as_div = Bry_.Ary(String_.Ary
|
||||
( ".xo_tbl {"
|
||||
, " display: table;"
|
||||
, " table-layout: fixed;" // don't auto-size to text content
|
||||
, " width: 100%;"
|
||||
, "}"
|
||||
, ".xo_row {"
|
||||
, " display: table-row;"
|
||||
, "}"
|
||||
, ".xo_head,.xo_origin {"
|
||||
, " display: table-cell;"
|
||||
, " padding: 3px 10px;"
|
||||
, " border: 1px solid #999999;"
|
||||
, " border-right: none;"
|
||||
, " font-weight:bold;"
|
||||
, "}"
|
||||
, ".xo_origin {"
|
||||
, " padding:0px;" // else box is larger than should be
|
||||
, "}"
|
||||
, ".xo_cell {"
|
||||
, " display: table-cell;"
|
||||
, " padding: 3px 10px;"
|
||||
, " vertical-align: top;" // else <textarea> will cause <input> to align at bottom
|
||||
, " border: 1px solid #999999;"
|
||||
, " border-top: none;"
|
||||
, " border-left: none;"
|
||||
, " border-right: none;"
|
||||
, " white-space: nowrap;"
|
||||
, " overflow: hidden;"
|
||||
, " text-overflow: ellipsis;"
|
||||
, "}"
|
||||
, ".xo_head:nth-child(1),.xo_cell:nth-child(1),.xo_origin {"
|
||||
, " border-left: 1px solid #999999;"
|
||||
, "}"
|
||||
, ".xo_head:nth-last-child(1),.xo_cell:nth-last-child(1) {"
|
||||
, " border-right: 1px solid #999999;"
|
||||
, "}"
|
||||
, ".xo_header {"
|
||||
, " display: table-header-group;"
|
||||
, " background-color: #ddd;"
|
||||
, " font-weight: bold;"
|
||||
, "}"
|
||||
, ".xo_footer {"
|
||||
, " display: table-footer-group;"
|
||||
, " font-weight: bold;"
|
||||
, " background-color: #ddd;"
|
||||
, "}"
|
||||
, ".xo_tbody {"
|
||||
, " display: table-row-group;"
|
||||
, "}"
|
||||
, ".xo_drag_handle {"
|
||||
, " background-color: #ddd;"
|
||||
, " cursor: move;"
|
||||
, "}"
|
||||
))
|
||||
, Js__sortable = Bry_.Ary(String_.Ary
|
||||
( " $('.xo_sortable').sortable({"
|
||||
, " revert: 100," // 100 for "fast" snap back
|
||||
, " items: '.xo_draggable'," // to prevent header from being dragged
|
||||
, " handle: '.xo_drag_handle',"
|
||||
, " cursor: 'move',"
|
||||
, " stop: function(event, ui) {"
|
||||
, " var ids = $(this).sortable('toArray');"
|
||||
, " rows__reorder(ids);"
|
||||
, " },"
|
||||
, " });"
|
||||
, " $('.xo_resizable_col').resizable({"
|
||||
, " handles: 'e',"
|
||||
, " cancel : 'textarea',"
|
||||
, " });"
|
||||
))
|
||||
;
|
||||
}
|
||||
29
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__gallery.java
Normal file
29
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__gallery.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_head_itm__gallery extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__gallery;}
|
||||
@Override public int Flags() {return Flag__js_head_global;}
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_global_ini_atr_val(Key_enabled , true);
|
||||
}
|
||||
private static final byte[]
|
||||
Key_enabled = Bry_.new_a7("gallery-packed-enabled")
|
||||
;
|
||||
}
|
||||
@@ -15,37 +15,38 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.langs.numbers.*;
|
||||
public class Xoh_module_itm__globals implements Xoh_module_itm {
|
||||
private final Xoh_module_wtr tmp_wtr = new Xoh_module_wtr();
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_globals;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_n_() {enabled = false;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
public class Xoh_head_itm__globals extends Xoh_head_itm__base {
|
||||
private final Xoh_head_wtr tmp_wtr = new Xoh_head_wtr();
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__globals;}
|
||||
@Override public int Flags() {return Flag__css_include | Flag__js_include | Flag__js_head_script | Flag__js_tail_script | Flag__js_head_global;}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_core_css == null) Url_core_css = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "core", "core.css").To_http_file_bry();
|
||||
wtr.Write_css_include(Url_core_css);
|
||||
}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_core_js == null) {
|
||||
Io_url core_dir = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("xowa", "html", "res", "src", "xowa", "core");
|
||||
Url_core_js = core_dir.GenSubFil("core.js").To_http_file_bry();
|
||||
Url_exec_js = core_dir.GenSubFil("exec.js").To_http_file_bry();
|
||||
Url_DOMContentLoaded_js = core_dir.GenSubFil("DOMContentLoaded.js").To_http_file_bry();
|
||||
}
|
||||
wtr.Write_js_include(Url_core_js);
|
||||
wtr.Write_js_include(Url_exec_js);
|
||||
wtr.Write_js_include(Url_DOMContentLoaded_js);
|
||||
}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_var(Var_xowa_root_dir , Bool_.Y, app.Fsys_mgr().Root_dir().To_http_file_bry());
|
||||
wtr.Write_js_var(Var_xowa_mode_is_server , Bool_.N, app.Tcp_server().Running() ? Bool_.True_bry : Bool_.False_bry);
|
||||
}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_xowa_var(Key__app_mode, Bool_.Y, app.App_type().Name());
|
||||
wtr.Write_js_alias_var (Page__alias, Page__key);
|
||||
wtr.Write_js_alias_kv (Page__alias, Key__wiki , page.Wiki().Domain_bry());
|
||||
wtr.Write_js_alias_kv (Page__alias, Key__ttl , page.Ttl().Page_db());
|
||||
} private static final byte[] Key__app_mode = Bry_.new_a7("xowa.app.mode"), Page__alias = Bry_.new_a7("x_p"), Page__key = Bry_.new_a7("xowa.page"), Key__wiki = Bry_.new_a7("wiki"), Key__ttl = Bry_.new_a7("ttl");
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_global_ini_atr_val(Key_mode_is_gui , app.App_type().Uid_is_gui());
|
||||
wtr.Write_js_global_ini_atr_val(Key_mode_is_http , app.App_type().Uid_is_http());
|
||||
wtr.Write_js_global_ini_atr_val(Key_http_port , app.Http_server().Port());
|
||||
@@ -78,7 +79,7 @@ public class Xoh_module_itm__globals implements Xoh_module_itm {
|
||||
, Key_wgMonthNames = Bry_.new_a7("wgMonthNames")
|
||||
, Key_wgMonthNamesShort = Bry_.new_a7("wgMonthNamesShort")
|
||||
;
|
||||
private static byte[] Html_js_table_months(Xoh_module_wtr tmp_wtr, Xow_msg_mgr msg_mgr, int january_id, int december_id) {
|
||||
private static byte[] Html_js_table_months(Xoh_head_wtr tmp_wtr, Xow_msg_mgr msg_mgr, int january_id, int december_id) {
|
||||
tmp_wtr.Write_js_ary_bgn();
|
||||
tmp_wtr.Write_js_ary_itm(Bry_.Empty); // 1st month is always empty
|
||||
for (int i = january_id; i <= december_id; i++)
|
||||
@@ -86,7 +87,7 @@ public class Xoh_module_itm__globals implements Xoh_module_itm {
|
||||
tmp_wtr.Write_js_ary_end();
|
||||
return tmp_wtr.Bfr().Xto_bry_and_clear();
|
||||
}
|
||||
private static byte[] Html_js_table_num_format_separators(Xoh_module_wtr tmp_wtr, Xol_transform_mgr separator_mgr) {
|
||||
private static byte[] Html_js_table_num_format_separators(Xoh_head_wtr tmp_wtr, Xol_transform_mgr separator_mgr) {
|
||||
byte[] dec_spr = separator_mgr.Get_val_or_self(Xol_num_mgr.Separators_key__dec);
|
||||
byte[] grp_spr = separator_mgr.Get_val_or_self(Xol_num_mgr.Separators_key__grp);
|
||||
tmp_wtr.Write_js_ary_bgn();
|
||||
@@ -101,5 +102,5 @@ public class Xoh_module_itm__globals implements Xoh_module_itm {
|
||||
, Var_xowa_root_dir = Bry_.new_a7("xowa_root_dir")
|
||||
, Var_xowa_mode_is_server = Bry_.new_a7("xowa_mode_is_server")
|
||||
;
|
||||
private static byte[] Url_core_css, Url_core_js, Url_DOMContentLoaded_js;
|
||||
private static byte[] Url_core_css, Url_core_js, Url_exec_js, Url_DOMContentLoaded_js;
|
||||
}
|
||||
28
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__hiero.java
Normal file
28
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__hiero.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_head_itm__hiero extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__hiero;}
|
||||
@Override public int Flags() {return Flag__css_include;}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_css == null) Url_css = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "xtns", "Wikihiero", "modules", "ext.wikihiero.css").To_http_file_bry();
|
||||
wtr.Write_css_include(Url_css);
|
||||
}
|
||||
private static byte[] Url_css;
|
||||
}
|
||||
28
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__mathjax.java
Normal file
28
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__mathjax.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_head_itm__mathjax extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__mathjax;}
|
||||
@Override public int Flags() {return Flag__js_include;}
|
||||
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_mathjax == null) Url_mathjax = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "xtns", "Math", "modules", "mathjax", "xowa_mathjax.js").To_http_file_bry();
|
||||
wtr.Write_js_include(Url_mathjax);
|
||||
}
|
||||
private static byte[] Url_mathjax;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_head_itm__navframe extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__navframe;}
|
||||
@Override public int Flags() {return Flag__js_head_global;}
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_global_ini_atr_val(Key_enabled , true);
|
||||
wtr.Write_js_global_ini_atr_val(Key_collapsed , app.Api_root().Html().Modules().Navframe().Collapsed() || wiki.Html_mgr().Head_mgr().Itm__navframe().Enabled_n());
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_show);
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_hide);
|
||||
}
|
||||
private static final byte[]
|
||||
Key_enabled = Bry_.new_a7("navframe-enabled")
|
||||
, Key_collapsed = Bry_.new_a7("navframe-collapsed")
|
||||
, Key_show = Bry_.new_a7("show")
|
||||
, Key_hide = Bry_.new_a7("hide")
|
||||
;
|
||||
}
|
||||
@@ -15,29 +15,19 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
import gplx.xowa.apis.xowa.html.modules.*;
|
||||
public class Xoh_module_itm__popups implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_popups;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public class Xoh_head_itm__popups extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__popups;}
|
||||
@Override public int Flags() {return Flag__css_include | Flag__js_head_global | Flag__js_tail_script;}
|
||||
public boolean Bind_hover_area() {return bind_hover_area;} public void Bind_hover_area_(boolean v) {bind_hover_area = v;} private boolean bind_hover_area;
|
||||
public void Clear() {enabled = false; bind_hover_area = false;}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Clear() {this.Enabled_n_(); bind_hover_area = false;}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Css_url == null) Css_url = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "popups", "popups.css").To_http_file_bry();
|
||||
wtr.Write_css_include(Css_url);
|
||||
}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_line(Jquery_init); // NOTE: must assert that jquery is init'd, else popup.js will not compile after going back / forward; DATE:2014-09-10
|
||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "popups", "popups.js"));
|
||||
} public static final byte[] Jquery_init = Bry_.new_a7("xowa.js.jquery.init();"), Mw_init = Bry_.new_a7("xowa.js.mediaWiki.init();");
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
Xoapi_popups api_popups = app.Api_root().Html().Modules().Popups();
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_show_delay , api_popups.Win_show_delay());
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_hide_delay , api_popups.Win_hide_delay());
|
||||
@@ -47,6 +37,10 @@ public class Xoh_module_itm__popups implements Xoh_module_itm {
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_bind_focus_blur , api_popups.Win_bind_focus_blur());
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_bind_hover_area , bind_hover_area);
|
||||
}
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_line(Jquery_init); // NOTE: must assert that jquery is init'd, else popup.js will not compile after going back / forward; DATE:2014-09-10
|
||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "popups", "popups.js"));
|
||||
} public static final byte[] Jquery_init = Bry_.new_a7("xowa.js.jquery.init();"), Mw_init = Bry_.new_a7("xowa.js.mediaWiki.init();");
|
||||
private static byte[] Css_url;
|
||||
private static final byte[]
|
||||
Key_win_show_delay = Bry_.new_a7("popups-win-show_delay")
|
||||
@@ -15,25 +15,18 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__search_suggest implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_search_suggest;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = false;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
public class Xoh_head_itm__search_suggest extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__search_suggest;}
|
||||
@Override public int Flags() {return Flag__css_include | Flag__js_include;}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_css == null) Url_css = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "search-suggest", "search-suggest.css").To_http_file_bry();
|
||||
wtr.Write_css_include(Url_css);
|
||||
}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_js == null) Url_js = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "search-suggest", "search-suggest.js").To_http_file_bry();
|
||||
wtr.Write_js_include(Url_js);
|
||||
}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
private static byte[] Url_css, Url_js;
|
||||
}
|
||||
34
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__server.java
Normal file
34
400_xowa/src/gplx/xowa/html/heads/Xoh_head_itm__server.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.json.*;
|
||||
import gplx.xowa.servers.http.*;
|
||||
public class Xoh_head_itm__server extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__server;}
|
||||
@Override public int Flags() {return Flag__js_tail_script;}
|
||||
private Http_data__client client_data;
|
||||
public Xoh_head_itm__server Init_by_http(Http_data__client client_data) {this.client_data = client_data; return this;}
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_init_global(Client_key);
|
||||
wtr.Write_js_alias_var (Client_alias, Client_key);
|
||||
wtr.Write_js_alias_kv (Client_alias, Key__server_host , client_data.Server_host());
|
||||
wtr.Write_js_alias_kv (Client_alias, Key__ip_address , client_data.Ip_address());
|
||||
}
|
||||
private static final byte[] Client_key = Bry_.new_a7("xowa.client"), Client_alias = Bry_.new_a7("x_c");
|
||||
private static final byte[] Key__server_host = Bry_.new_a7("server_host"), Key__ip_address = Bry_.new_a7("ip_address");
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_head_itm__timeline extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__timeline;}
|
||||
@Override public int Flags() {return Flag__css_include;}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url_js == null) Url_js = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "timeline", "timeline.js").To_http_file_bry();
|
||||
wtr.Write_js_include(Url_js);
|
||||
}
|
||||
private static byte[] Url_js;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
import gplx.xowa.apis.xowa.html.modules.*;
|
||||
public class Xoh_head_itm__title_rewrite extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__title_rewrite;}
|
||||
@Override public int Flags() {return Flag__js_tail_script;}
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "gadgets", "titleRewrite", "titleRewrite.js"));
|
||||
}
|
||||
}
|
||||
@@ -15,29 +15,22 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__toc implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_toc;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
// if (!enabled) return;
|
||||
// wtr.Write_js_line(Xoh_module_itm__popups.Jquery_init);
|
||||
// wtr.Write_js_line(Xoh_module_itm__popups.Mw_init);
|
||||
// wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "modules", "mw.toc", "mw.toc.js"));
|
||||
}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
public class Xoh_head_itm__toc extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__toc;}
|
||||
@Override public int Flags() {return Flag__js_head_global | Flag__js_tail_script;}
|
||||
@Override public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_global_ini_atr_val(Key_exists , true);
|
||||
wtr.Write_js_global_ini_atr_val(Key_collapsed , app.Api_root().Html().Modules().Collapsible().Collapsed() ? Val_collapsed_y : Val_collapsed_n);
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_showtoc);
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_hidetoc);
|
||||
}
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
// wtr.Write_js_line(Xoh_head_itm__popups.Jquery_init);
|
||||
// wtr.Write_js_line(Xoh_head_itm__popups.Mw_init);
|
||||
// wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "modules", "mw.toc", "mw.toc.js"));
|
||||
}
|
||||
private static final byte[]
|
||||
Key_exists = Bry_.new_a7("toc-enabled")
|
||||
, Key_collapsed = Bry_.new_a7("mw_hidetoc")
|
||||
@@ -15,25 +15,18 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
import gplx.xowa.apis.xowa.html.modules.*;
|
||||
public class Xoh_module_itm__top_icon implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_top_icon;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
public class Xoh_head_itm__top_icon extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__top_icon;}
|
||||
@Override public int Flags() {return Flag__css_include | Flag__js_tail_script;}
|
||||
@Override public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Css_url == null) Css_url = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "gadgets", "top-icon", "top-icon.css").To_http_file_bry();
|
||||
wtr.Write_css_include(Css_url);
|
||||
}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
@Override public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "gadgets", "top-icon", "top-icon.js"));
|
||||
}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
private static byte[] Css_url;
|
||||
}
|
||||
175
400_xowa/src/gplx/xowa/html/heads/Xoh_head_mgr.java
Normal file
175
400_xowa/src/gplx/xowa/html/heads/Xoh_head_mgr.java
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
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.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_head_mgr implements Bry_fmtr_arg {
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page;
|
||||
private Xoh_head_itm__base[] itms; private int itms_len;
|
||||
private Xoh_head_wtr wtr = new Xoh_head_wtr();
|
||||
private final Xoh_head_wkr
|
||||
list__css_include = new Xoh_head_wkr()
|
||||
, list__css_text = new Xoh_head_wkr()
|
||||
, list__js_include = new Xoh_head_wkr()
|
||||
, list__js_head_global = new Xoh_head_wkr()
|
||||
, list__js_head_script = new Xoh_head_wkr()
|
||||
, list__js_tail_script = new Xoh_head_wkr()
|
||||
, list__js_window_onload = new Xoh_head_wkr()
|
||||
;
|
||||
public Xoh_head_mgr() {
|
||||
Itms_add(itm__css, itm__globals, itm__server, itm__popups, itm__toc, itm__collapsible, itm__navframe, itm__gallery
|
||||
, itm__mathjax, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline
|
||||
, itm__dbui
|
||||
);
|
||||
}
|
||||
public Xoh_head_itm__css Itm__css() {return itm__css;} private final Xoh_head_itm__css itm__css = new Xoh_head_itm__css();
|
||||
public Xoh_head_itm__globals Itm__globals() {return itm__globals;} private final Xoh_head_itm__globals itm__globals = new Xoh_head_itm__globals();
|
||||
public Xoh_head_itm__server Itm__server() {return itm__server;} private final Xoh_head_itm__server itm__server = new Xoh_head_itm__server();
|
||||
public Xoh_head_itm__popups Itm__popups() {return itm__popups;} private final Xoh_head_itm__popups itm__popups = new Xoh_head_itm__popups();
|
||||
public Xoh_head_itm__toc Itm__toc() {return itm__toc;} private final Xoh_head_itm__toc itm__toc = new Xoh_head_itm__toc();
|
||||
public Xoh_head_itm__collapsible Itm__collapsible() {return itm__collapsible;} private final Xoh_head_itm__collapsible itm__collapsible = new Xoh_head_itm__collapsible();
|
||||
public Xoh_head_itm__navframe Itm__navframe() {return itm__navframe;} private final Xoh_head_itm__navframe itm__navframe = new Xoh_head_itm__navframe();
|
||||
public Xoh_head_itm__gallery Itm__gallery() {return itm__gallery;} private final Xoh_head_itm__gallery itm__gallery = new Xoh_head_itm__gallery();
|
||||
public Xoh_head_itm__mathjax Itm__mathjax() {return itm__mathjax;} private final Xoh_head_itm__mathjax itm__mathjax = new Xoh_head_itm__mathjax();
|
||||
public Xoh_head_itm__hiero Itm__hiero() {return itm__hiero;} private final Xoh_head_itm__hiero itm__hiero = new Xoh_head_itm__hiero();
|
||||
public Xoh_head_itm__top_icon Itm__top_icon() {return itm__top_icon;} private final Xoh_head_itm__top_icon itm__top_icon = new Xoh_head_itm__top_icon();
|
||||
public Xoh_head_itm__search_suggest Itm__search_suggest() {return itm__search_suggest;} private final Xoh_head_itm__search_suggest itm__search_suggest = new Xoh_head_itm__search_suggest();
|
||||
public Xoh_head_itm__timeline Itm__timeline() {return itm__timeline;} private final Xoh_head_itm__timeline itm__timeline = new Xoh_head_itm__timeline();
|
||||
public Xoh_head_itm__title_rewrite Itm__title_rewrite() {return itm__title_rewrite;} private final Xoh_head_itm__title_rewrite itm__title_rewrite = new Xoh_head_itm__title_rewrite();
|
||||
public Xoh_head_itm__dbui Itm__dbui() {return itm__dbui;} private final Xoh_head_itm__dbui itm__dbui = new Xoh_head_itm__dbui();
|
||||
public Xoh_head_mgr Init(Xoae_app app, Xowe_wiki wiki, Xoae_page page) {
|
||||
this.app = app; this.wiki = wiki; this.page = page;
|
||||
return this;
|
||||
}
|
||||
public Xoh_head_mgr Init_dflts() {
|
||||
if (page.Hdr_mgr().Toc_enabled()) itm__toc.Enabled_y_();
|
||||
if (wiki.Html_mgr().Head_mgr().Itm__top_icon().Enabled_y()) itm__top_icon.Enabled_y_();
|
||||
if (wiki.Html_mgr().Head_mgr().Itm__title_rewrite().Enabled_y()) itm__title_rewrite.Enabled_y_();
|
||||
if (app.Gui_mgr().Search_suggest_mgr().Enabled()) itm__search_suggest.Enabled_y_();
|
||||
itm__css.Enabled_y_();
|
||||
itm__globals.Enabled_y_(); // for now, always mark this and rest as exists; DATE:2014-06-09
|
||||
itm__collapsible.Enabled_y_();
|
||||
itm__navframe.Enabled_y_();
|
||||
itm__popups.Enabled_(app.Api_root().Html().Modules().Popups().Enabled());
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
for (int i = 0; i < itms_len; ++i)
|
||||
itms[i].Clear();
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {Write(bfr, app, wiki, page);}
|
||||
public void Write(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, Xoae_page page) {
|
||||
Set_wkrs();
|
||||
wtr.Init(bfr);
|
||||
wtr.Indent_add();
|
||||
int len = 0;
|
||||
len = list__css_include.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoh_head_itm__base itm = list__css_include.Get_at(i);
|
||||
itm.Write_css_include(app, wiki, page, wtr);
|
||||
}
|
||||
len = list__css_text.Len();
|
||||
if (len > 0) {
|
||||
wtr.Write_css_style_bgn();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoh_head_itm__base itm = list__css_text.Get_at(i);
|
||||
itm.Write_css_text(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_css_style_end();
|
||||
}
|
||||
int head_global_len = list__js_head_global.Len();
|
||||
int head_script_len = list__js_head_script.Len();
|
||||
if (head_global_len + head_script_len > 0) {
|
||||
len = head_script_len;
|
||||
wtr.Write_js_script_bgn(); // write <script> before <script src=""> b/c <script> will have cfg values that other scripts will use; EX: xowa_root_dir
|
||||
for (int i = 0; i < head_script_len; ++i) {
|
||||
Xoh_head_itm__base itm = list__js_head_script.Get_at(i);
|
||||
itm.Write_js_head_script(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_head_global_bgn();
|
||||
len = head_global_len;
|
||||
for (int i = 0; i < head_global_len; ++i) {
|
||||
Xoh_head_itm__base itm = list__js_head_global.Get_at(i);
|
||||
itm.Write_js_head_global(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_head_global_end();
|
||||
wtr.Write_js_script_end();
|
||||
}
|
||||
len = list__js_include.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoh_head_itm__base itm = list__js_include.Get_at(i);
|
||||
itm.Write_js_include(app, wiki, page, wtr);
|
||||
}
|
||||
int tail_script_len = list__js_tail_script.Len();
|
||||
int window_onload_len = list__js_window_onload.Len();
|
||||
if (tail_script_len + window_onload_len > 0) {
|
||||
wtr.Write_js_script_bgn();
|
||||
for (int i = 0; i < tail_script_len; ++i) {
|
||||
Xoh_head_itm__base itm = list__js_tail_script.Get_at(i);
|
||||
itm.Write_js_tail_script(app, wiki, page, wtr);
|
||||
}
|
||||
if (window_onload_len > 0) {
|
||||
wtr.Write_js_line(Js__window_onload__bgn);
|
||||
for (int i = 0; i < window_onload_len; ++i) {
|
||||
Xoh_head_itm__base itm = list__js_window_onload.Get_at(i);
|
||||
itm.Write_js_window_onload(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_line(Js__window_onload__end);
|
||||
}
|
||||
wtr.Write_js_script_end();
|
||||
}
|
||||
wtr.Indent_del();
|
||||
wtr.Term();
|
||||
}
|
||||
private static final byte[]
|
||||
Js__window_onload__bgn = Bry_.new_a7("window.onload = function() {")
|
||||
, Js__window_onload__end = Bry_.new_a7("};")
|
||||
;
|
||||
private void Itms_add(Xoh_head_itm__base... ary) {
|
||||
this.itms_len = ary.length;
|
||||
this.itms = ary;
|
||||
}
|
||||
private void Set_wkrs() {
|
||||
list__css_include.Clear();
|
||||
list__css_text.Clear();
|
||||
list__js_include.Clear();
|
||||
list__js_head_global.Clear();
|
||||
list__js_head_script.Clear();
|
||||
list__js_tail_script.Clear();
|
||||
list__js_window_onload.Clear();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_head_itm__base itm = itms[i];
|
||||
boolean enabled = itm.Enabled();
|
||||
if (enabled) {
|
||||
int flag = itms[i].Flags();
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__css_include)) list__css_include.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__css_text)) list__css_text.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_include)) list__js_include.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_head_global)) list__js_head_global.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_head_script)) list__js_head_script.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_tail_script)) list__js_tail_script.Add(itm);
|
||||
if (Enm_.HasInt(flag, Xoh_head_itm__base.Flag__js_window_onload)) list__js_window_onload.Add(itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Xoh_head_wkr {
|
||||
private final List_adp list = List_adp_.size_(Xoh_head_itm__base.Idx__max);
|
||||
public int Len() {return list.Count();}
|
||||
public void Clear() {list.Clear();}
|
||||
public void Add(Xoh_head_itm__base itm) {list.Add(itm);}
|
||||
public Xoh_head_itm__base Get_at(int i) {return (Xoh_head_itm__base)list.Get_at(i);}
|
||||
}
|
||||
@@ -15,11 +15,11 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_module_mgr_fxt fxt = new Xoh_module_mgr_fxt();
|
||||
public class Xoh_head_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_head_mgr_fxt fxt = new Xoh_head_mgr_fxt();
|
||||
@Test public void Css() {
|
||||
fxt.Mgr().Itm__css().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
@@ -30,8 +30,8 @@ public class Xoh_module_mgr_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Toc() {
|
||||
fxt.Init_msg(Xoh_module_itm__toc.Key_showtoc, "Sh\"ow");
|
||||
fxt.Init_msg(Xoh_module_itm__toc.Key_hidetoc, "Hi'de");
|
||||
fxt.Init_msg(Xoh_head_itm__toc.Key_showtoc, "Sh\"ow");
|
||||
fxt.Init_msg(Xoh_head_itm__toc.Key_hidetoc, "Hi'de");
|
||||
fxt.Mgr().Itm__toc().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
@@ -69,7 +69,14 @@ public class Xoh_module_mgr_tst {
|
||||
, " }"
|
||||
, " </script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/exec.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/DOMContentLoaded.js\" type='text/javascript'></script>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " xowa.app.mode = 'cmd';"
|
||||
, " var x_p = xowa.page;"
|
||||
, " x_p.wiki = 'en.wikipedia.org';"
|
||||
, " x_p.ttl = 'Test_page';"
|
||||
, " </script>"
|
||||
));
|
||||
fxt.Init_msg(Xol_msg_itm_.Id_dte_month_name_january, "January" ); // set it back
|
||||
}
|
||||
@@ -100,20 +107,27 @@ public class Xoh_module_mgr_tst {
|
||||
, " }"
|
||||
, " </script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/exec.js\" type='text/javascript'></script>"
|
||||
, " <script src=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/DOMContentLoaded.js\" type='text/javascript'></script>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " xowa.app.mode = 'cmd';"
|
||||
, " var x_p = xowa.page;"
|
||||
, " x_p.wiki = 'en.wikipedia.org';"
|
||||
, " x_p.ttl = 'Test_page';"
|
||||
, " </script>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_module_mgr_fxt {
|
||||
class Xoh_head_mgr_fxt {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
private Xoh_module_mgr mgr;
|
||||
private Xoh_head_mgr mgr;
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xoh_module_mgr Mgr() {return mgr;}
|
||||
public Xoh_head_mgr Mgr() {return mgr;}
|
||||
public Xol_lang Make_lang(String key) {return wiki.Appe().Lang_mgr().Get_by_key_or_new(Bry_.new_a7(key));}
|
||||
public void Clear() {
|
||||
fxt.Reset();
|
||||
mgr = fxt.Page().Html_data().Module_mgr();
|
||||
mgr = fxt.Page().Html_data().Head_mgr();
|
||||
wiki = fxt.Wiki();
|
||||
}
|
||||
public void Init_msg(byte[] key, String val) {
|
||||
@@ -15,9 +15,9 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.html.*;
|
||||
public class Xoh_module_wtr {
|
||||
public class Xoh_head_wtr {
|
||||
private int indent; private int reset_bgn, reset_end;
|
||||
private boolean js_tail_inited = false;
|
||||
public Bry_bfr Bfr() {return bfr;} private Bry_bfr bfr;
|
||||
@@ -47,14 +47,30 @@ public class Xoh_module_wtr {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Html_tag_.Style_rhs);
|
||||
}
|
||||
public void Write_css_style_ary(byte[][] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
Write_css_style_itm(ary[i]);
|
||||
}
|
||||
public void Write_css_style_itm(byte[] bry) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(bry);
|
||||
}
|
||||
public void Write_js_lines(byte[][] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i)
|
||||
Write_js_line(ary[i]);
|
||||
}
|
||||
public void Write_js_line(String str) {Write_js_line(Bry_.new_u8(str));}
|
||||
public void Write_js_line(byte[] bry) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(bry);
|
||||
}
|
||||
public void Write_js_line_ary(byte[]... ary) {
|
||||
Write_nl_and_indent();
|
||||
for (byte[] bry : ary)
|
||||
bfr.Add(bry);
|
||||
}
|
||||
public void Write_js_script_bgn() {
|
||||
reset_bgn = bfr.Len();
|
||||
Write_nl_and_indent();
|
||||
@@ -86,11 +102,12 @@ public class Xoh_module_wtr {
|
||||
js_tail_inited = true;
|
||||
Write_js_line(Js_line_1);
|
||||
}
|
||||
public void Write_js_tail_load_lib(Io_url url) {
|
||||
public void Write_js_tail_load_lib(Io_url url) {Write_js_tail_load_lib(url.To_http_file_bry());}
|
||||
public void Write_js_tail_load_lib(byte[] url) {
|
||||
Write_js_tail_init();
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_line_2_bgn);
|
||||
bfr.Add(url.To_http_file_bry());
|
||||
bfr.Add(url);
|
||||
bfr.Add(Js_line_2_end);
|
||||
}
|
||||
private static final byte[]
|
||||
@@ -136,6 +153,36 @@ public class Xoh_module_wtr {
|
||||
Write_js_quote(Byte_ascii.Apos, val);
|
||||
} private int js_ary_idx = 0; private static final byte[] js_ary_dlm = Bry_.new_a7(", ");
|
||||
public void Write_js_ary_end() {js_ary_idx = 0; bfr.Add_byte(Byte_ascii.Brack_end);}
|
||||
public void Write_js_init_global(byte[] key) { // EX: xowa.client = {};
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(key);
|
||||
bfr.Add(Js_init_obj);
|
||||
}
|
||||
public void Write_js_alias_var(byte[] alias, byte[] key) { // EX: var x_s = xowa.server;
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_var_bgn);
|
||||
bfr.Add(alias);
|
||||
bfr.Add(Js_var_mid);
|
||||
bfr.Add(key);
|
||||
bfr.Add(Js_var_end);
|
||||
}
|
||||
public void Write_js_alias_kv(byte[] alias, byte[] key, byte[] val) { // EX: x_s.port = 8080;
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(alias).Add_byte_dot().Add(key);
|
||||
bfr.Add(Js_var_mid);
|
||||
Write_js_quote(Byte_ascii.Apos, val);
|
||||
bfr.Add(Js_var_end);
|
||||
}
|
||||
public void Write_js_xowa_var(byte[] key, boolean quote_val, byte[] val) { // EX: var xowa.app.mode = 'gui';
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(key);
|
||||
bfr.Add(Js_var_mid);
|
||||
if (quote_val)
|
||||
Write_js_quote(Byte_ascii.Apos, val);
|
||||
else
|
||||
bfr.Add(val);
|
||||
bfr.Add(Js_var_end);
|
||||
}
|
||||
public void Write_js_var(byte[] key, boolean quote_val, byte[] val) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_var_bgn);
|
||||
@@ -165,8 +212,8 @@ public class Xoh_module_wtr {
|
||||
bfr.Add_byte_nl(); Indent();
|
||||
}
|
||||
private void Indent() {bfr.Add_byte_repeat(Byte_ascii.Space, indent);}
|
||||
public void Indent_add() {indent += 2;}
|
||||
public void Indent_del() {indent -= 2;}
|
||||
public Xoh_head_wtr Indent_add() {indent += 2; return this;}
|
||||
public Xoh_head_wtr Indent_del() {indent -= 2; return this;}
|
||||
private static final byte[]
|
||||
Css_include_bgn = Bry_.new_a7("<link rel=\"stylesheet\" href=\"")
|
||||
, Css_include_end = Bry_.new_a7("\" type='text/css'>")
|
||||
@@ -178,5 +225,6 @@ public class Xoh_module_wtr {
|
||||
, Js_var_bgn = Bry_.new_a7("var ")
|
||||
, Js_var_mid = Bry_.new_a7(" = ")
|
||||
, Js_var_end = Bry_.new_a7(";")
|
||||
, Js_init_obj = Bry_.new_a7(" = {};")
|
||||
;
|
||||
}
|
||||
@@ -15,19 +15,19 @@ 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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
package gplx.xowa.html.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_wtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_module_wtr_fxt fxt = new Xoh_module_wtr_fxt();
|
||||
public class Xoh_head_wtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_head_wtr_fxt fxt = new Xoh_head_wtr_fxt();
|
||||
@Test public void Globals_none() {
|
||||
Xoh_module_wtr wtr = fxt.Wtr();
|
||||
Xoh_head_wtr wtr = fxt.Wtr();
|
||||
wtr.Write_js_head_global_bgn();
|
||||
wtr.Write_js_head_global_end();
|
||||
fxt.Test("");
|
||||
}
|
||||
@Test public void Globals_some() {
|
||||
Xoh_module_wtr wtr = fxt.Wtr();
|
||||
Xoh_head_wtr wtr = fxt.Wtr();
|
||||
wtr.Write_js_head_global_bgn();
|
||||
fxt.Exec_Write_js_global_ini_atr_val("key_1", "val_1");
|
||||
fxt.Exec_Write_js_global_ini_atr_val("key_2", "val_2");
|
||||
@@ -43,9 +43,9 @@ public class Xoh_module_wtr_tst {
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_module_wtr_fxt {
|
||||
class Xoh_head_wtr_fxt {
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
public Xoh_module_wtr Wtr() {return wtr;} private Xoh_module_wtr wtr = new Xoh_module_wtr();
|
||||
public Xoh_head_wtr Wtr() {return wtr;} private Xoh_head_wtr wtr = new Xoh_head_wtr();
|
||||
public void Clear() {
|
||||
wtr.Init(bfr);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class Xoh_href_parser {
|
||||
}
|
||||
public static final String Href_file_str = "file:///", Href_wiki_str = "/wiki/", Href_site_str = "/site/", Href_xcmd_str = "/xcmd/";
|
||||
public static final byte[]
|
||||
Href_https_bry = Bry_.new_u8("https://") // NOTE: must be "https:" or wmf api won't work; DATE:2015-06-17
|
||||
Href_https_bry = Bry_.new_a7("https://") // NOTE: must be "https:" or wmf api won't work; DATE:2015-06-17
|
||||
, Href_file_bry = Bry_.new_a7(Href_file_str), Href_site_bry = Bry_.new_a7(Href_site_str), Href_wiki_bry = Bry_.new_a7(Href_wiki_str);
|
||||
|
||||
private static final int Href_wiki_len = Href_wiki_bry.length;
|
||||
@@ -166,7 +166,7 @@ public class Xoh_href_parser {
|
||||
if (ttl.Anch_bgn() != Bry_.NotFound) rv.Anchor_(ttl.Anch_txt());
|
||||
}
|
||||
private static void Parse_site(Xoh_href rv, Url_encoder encoder, Xowe_wiki wiki, byte[] raw, int bgn, int len) { // /site/; EX: /site/fr.wikipedia.org/wiki/A
|
||||
int slash = Bry_finder.Find_fwd(raw, Byte_ascii.Slash, bgn, len); if (slash == Bry_.NotFound) throw Exc_.new_("site href is missing slash", "snip", String_.new_u8(raw, bgn, len));
|
||||
int slash = Bry_finder.Find_fwd(raw, Byte_ascii.Slash, bgn, len); if (slash == Bry_.NotFound) throw Err_.new_wo_type("site href is missing slash", "snip", String_.new_u8(raw, bgn, len));
|
||||
rv.Tid_(Xoh_href.Tid_site);
|
||||
byte[] wiki_bry = Bry_.Mid(raw, bgn, slash); // wiki is text between "/site/" and next "/"
|
||||
Xow_xwiki_itm xwiki = wiki.Appe().Usere().Wiki().Xwiki_mgr().Get_by_key(wiki_bry); // NOTE: site may refer to alias in user_wiki; ex: /site/wikisource.org which points to en.wikisource.org; this occurs during lnke substitution; EX: [//wikisource.org Wikisource]
|
||||
@@ -204,7 +204,7 @@ public class Xoh_href_parser {
|
||||
page_bry = wiki.Props().Main_page();
|
||||
else
|
||||
page_bry = ttl.Page_txt();
|
||||
ttl = Xoa_ttl.parse_(wiki, page_bry); if (ttl == null) throw Exc_.new_("wiki href does not have valid title", "ttl", String_.new_u8(raw, bgn, len));
|
||||
ttl = Xoa_ttl.parse_(wiki, page_bry); if (ttl == null) throw Err_.new_wo_type("wiki href does not have valid title", "ttl", String_.new_u8(raw, bgn, len));
|
||||
}
|
||||
rv.Page_(encoder.Decode(ttl.Full_txt())); // add page; note that it should be decoded; EX: %20 -> " "; also note that anchor (#) or query params (?) are not parsed; the entire String will be reparsed later
|
||||
if (ttl.Anch_bgn() != Bry_.NotFound) // add anchor if it exists
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Xodump_stats_itm {
|
||||
case 4: ++hdr_4; break;
|
||||
case 5: ++hdr_5; break;
|
||||
case 6: ++hdr_6; break;
|
||||
default: throw Exc_.new_unhandled(hdr_num);
|
||||
default: throw Err_.new_unhandled(hdr_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xodump_stats_tbl implements RlsAble {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Insert(Xog_page hpg, Xodump_stats_itm hzip, int wtxt_len, int row_orig_len, int row_zip_len) {
|
||||
Xopg_module_mgr js_mgr = hpg.Module_mgr();
|
||||
Xopg_module_mgr js_mgr = hpg.Head_mgr();
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_page_id , hpg.Page_id())
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Xow_hzip_int_ {
|
||||
return bfr.Xto_bry_and_clear();
|
||||
}
|
||||
public static void Save_bin_int_abrv(Bry_bfr bfr, int val_int) { // save int in binary little endian form; range from -2,080,766,977 to 2,147,483,648; 255^4 or 4,228,250,625
|
||||
if (val_int == 0) {bfr.Add_byte(Byte_ascii.Nil); return;}
|
||||
if (val_int == 0) {bfr.Add_byte(Byte_ascii.Null); return;}
|
||||
long val = val_int;
|
||||
if (val < 0) val = Int_.MaxValue + -val;
|
||||
int count = 0;
|
||||
@@ -38,7 +38,7 @@ public class Xow_hzip_int_ {
|
||||
++count;
|
||||
val = (val - adj) / Base_255_int;
|
||||
}
|
||||
if (count < 4) bfr.Add_byte(Byte_ascii.Nil);
|
||||
if (count < 4) bfr.Add_byte(Byte_ascii.Null);
|
||||
}
|
||||
public static int Load_bin_int_abrv(byte[] bry, int bry_len, int bgn, Int_obj_ref count_ref) {
|
||||
int end = bgn + 4; // read no more than 4 bytes
|
||||
|
||||
@@ -64,12 +64,12 @@ public class Xow_hzip_itm__anchor_tst {
|
||||
fxt.Test_load(brys, "<a href='/wiki/A' id='xowa_lnki_3' title='A'>B<a href='/wiki/C' id='xowa_lnki_3' title='C'>C1</a>D</a>");
|
||||
}
|
||||
@Test public void Srl_noop() {
|
||||
byte[][] brys = Bry_.Ary(Bry_.new_u8("<a href='/wiki/A'>A"), Xow_hzip_dict.Bry_a_rhs); // NOTE: still converts "</a>" to hzip
|
||||
byte[][] brys = Bry_.Ary(Bry_.new_a7("<a href='/wiki/A'>A"), Xow_hzip_dict.Bry_a_rhs); // NOTE: still converts "</a>" to hzip
|
||||
fxt.Test_save(brys, "<a href='/wiki/A'>A</a>");
|
||||
fxt.Test_load(brys, "<a href='/wiki/A'>A</a>");
|
||||
}
|
||||
@Test public void Srl_lnki_text_y__multiple() { // PURPOSE: if id is missing from 1st anchor, do not get from second
|
||||
byte[][] brys = Bry_.Ary(Bry_.new_u8("<a xtid='a_lnki_text_n' href=\"/wiki/A\" title=\"A\">A")
|
||||
byte[][] brys = Bry_.Ary(Bry_.new_a7("<a xtid='a_lnki_text_n' href=\"/wiki/A\" title=\"A\">A")
|
||||
, Xow_hzip_dict.Bry_a_rhs
|
||||
, Xow_hzip_dict.Bry_lnki_text_n, Bry_.ints_(2), fxt.Make_int(3), Bry_.new_a7("B"), Xow_hzip_dict.Escape_bry
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.threads.*; import gplx.xowa.xtns.pfuncs.ifs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.json.*;
|
||||
import gplx.core.json.*;
|
||||
import gplx.xowa.html.js.*;
|
||||
import gplx.xowa.gui.views.*;
|
||||
public class Xoh_js_cbk implements GfoInvkAble {
|
||||
@@ -66,22 +66,22 @@ public class Xoh_js_cbk implements GfoInvkAble {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, m.Args_getAt(0).Val_to_bry());
|
||||
Xoae_page page = wiki.Data_mgr().Get_page(ttl, false);
|
||||
return String_.new_u8(page.Data_raw());
|
||||
} catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private String Popups_get_async_bgn(GfoMsg m) {
|
||||
try {
|
||||
byte[] js_cbk = m.Args_getAt(0).Val_to_bry();
|
||||
byte[] href_bry = m.Args_getAt(1).Val_to_bry();
|
||||
return html_itm.Owner_tab().Wiki().Html_mgr().Module_mgr().Popup_mgr().Get_async_bgn(js_cbk, href_bry);
|
||||
} catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
return html_itm.Owner_tab().Wiki().Html_mgr().Head_mgr().Popup_mgr().Get_async_bgn(js_cbk, href_bry);
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private String Popups_get_html(GfoMsg m) {
|
||||
try {
|
||||
int popups_id = Int_.Xby_double_(Double_.cast_(m.Args_getAt(0).Val()));
|
||||
byte[] href_bry = m.Args_getAt(1).Val_to_bry();
|
||||
byte[] tooltip_bry = m.Args_getAt(2).Val_to_bry();
|
||||
return html_itm.Owner_tab().Wiki().Html_mgr().Module_mgr().Popup_mgr().Show_init(popups_id, href_bry, tooltip_bry);
|
||||
} catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
return html_itm.Owner_tab().Wiki().Html_mgr().Head_mgr().Popup_mgr().Show_init(popups_id, href_bry, tooltip_bry);
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private String[] Get_title_meta(Xowe_wiki wiki, byte[] ttl_bry) {
|
||||
synchronized (tmp_page) {
|
||||
@@ -102,7 +102,7 @@ public class Xoh_js_cbk implements GfoInvkAble {
|
||||
rv[i] = Get_title_meta(wiki, ttl);
|
||||
}
|
||||
return rv;
|
||||
} catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private boolean Get_title_exists(Xowe_wiki wiki, byte[] ttl) {
|
||||
return Pfunc_ifexist.Exists(wiki, ttl);
|
||||
@@ -118,7 +118,7 @@ public class Xoh_js_cbk implements GfoInvkAble {
|
||||
rv[i] = Get_title_exists(wiki, ttl) ? "1" : "0";
|
||||
}
|
||||
return rv;
|
||||
} catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private String Get_search_suggestions(GfoMsg m) {
|
||||
Xowe_wiki wiki = html_itm.Owner_tab().Wiki();
|
||||
@@ -155,18 +155,18 @@ public class Xoh_js_cbk implements GfoInvkAble {
|
||||
rv[i - 1] = String_.new_u8(val_bry);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {Exc_.Noop(e); rv[i] = null;}
|
||||
} catch (Exception e) {Err_.Noop(e); rv[i] = null;}
|
||||
finally {}
|
||||
}
|
||||
return rv;
|
||||
} catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private String Scripts_exec(GfoMsg m) {
|
||||
Object rv = null;
|
||||
try {
|
||||
rv = app.Gfs_mgr().Run_str(m.Args_getAt(0).Val_to_str_or_empty());
|
||||
}
|
||||
catch (Exception e) {Exc_.Noop(e); return null;}
|
||||
catch (Exception e) {Err_.Noop(e); return null;}
|
||||
return Object_.Xto_str_strict_or_empty(rv);
|
||||
}
|
||||
private static final byte[] Wikidata_get_label_xowa_ui_lang = Bry_.new_a7("xowa_ui_lang"), Wikidata_get_label_xowa_title = Bry_.new_a7("xowa_title");
|
||||
@@ -184,7 +184,7 @@ public class Xoh_js_cbk implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_get_current_url)) return String_.new_u8(html_itm.Owner_tab().Page().Url().Raw());
|
||||
else if (ctx.Match(k, Invk_xowa_exec_test)) return Xowa_exec_test(m);
|
||||
else if (ctx.Match(k, Invk_xowa_exec_test_as_array)) return Xowa_exec_test_as_array(m);
|
||||
else if (ctx.Match(k, Invk_exec_json)) return app.Html__json_exec().Exec_json(m);
|
||||
else if (ctx.Match(k, Invk_exec_json)) return app.Html__bridge_mgr().Cmd_mgr().Exec(m);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
public static final String Invk_parse_to_html = "parse_to_html", Invk_wikidata_get_label = "wikidata_get_label", Invk_get_page = "get_page", Invk_cmd = "cmd", Invk_scripts_exec = "scripts_exec"
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Xoh_js_cbk_wdata_labels_tst {
|
||||
Tst_wikidata_label_get(String_.Ary("en", "q1"), String_.Ary("\ta"));
|
||||
}
|
||||
private Wdata_doc doc_(String qid, String src) {
|
||||
gplx.json.Json_doc doc = gplx.json.Json_doc.new_apos_(src);
|
||||
gplx.core.json.Json_doc doc = gplx.core.json.Json_doc.new_apos_(src);
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Wdata_doc rv = new Wdata_doc(Bry_.new_a7(qid), app.Wiki_mgr().Wdata_mgr(), doc);
|
||||
return rv;
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
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.html.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.json.*;
|
||||
public class Xoh_json_exec {
|
||||
private final Xoa_app app;
|
||||
public Xoh_json_exec(Xoa_app app) {this.app = app;}
|
||||
public String Exec_json(GfoMsg m) {
|
||||
if (m.Args_count() == 0) throw Exc_.new_("xowa_exec.json; no json specified for json_exec");
|
||||
return Exec_json(m.Args_getAt(0).Val_to_bry());
|
||||
}
|
||||
public String Exec_json(byte[] jdoc_bry) {
|
||||
Json_doc jdoc = null;
|
||||
try {jdoc = Json_doc.new_(jdoc_bry);}
|
||||
catch (Exception e) {throw Exc_.new_exc(e, "js", "xowa_exec.json; invalid json", "json", jdoc_bry);}
|
||||
return Xoui_exec(jdoc, jdoc.Root());
|
||||
}
|
||||
private String Xoui_exec(Json_doc jdoc, Json_itm_nde nde) {
|
||||
byte[] wiki_bry = nde.Subs_get_val_by_key_as_bry(Key_wiki, null); if (wiki_bry == null) throw Exc_.new_("xoui_exec.json; no wiki specified", "json", jdoc.Src());
|
||||
byte[] proc_bry = nde.Subs_get_val_by_key_as_bry(Key_proc, null); if (proc_bry == null) throw Exc_.new_("xoui_exec.json; no proc specified", "json", jdoc.Src());
|
||||
Xow_wiki wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(wiki_bry);
|
||||
Object tid_obj = proc_hash.Get_by(proc_bry); if (tid_obj == null) throw Exc_.new_("xoui_exec.json; invalid tid", "json", jdoc.Src());
|
||||
switch (((Byte_obj_val)tid_obj).Val()) {
|
||||
case Tid_edit : return wiki.Html__xoui_tbl_mgr().Edit(jdoc);
|
||||
case Tid_save : return wiki.Html__xoui_tbl_mgr().Save(wiki, jdoc);
|
||||
case Tid_delete : return wiki.Html__xoui_tbl_mgr().Del(jdoc);
|
||||
}
|
||||
throw Exc_.new_("xoui_exec.json; cmd not handled", "json", jdoc.Src());
|
||||
}
|
||||
private static final byte[] Key_wiki = Bry_.new_a7("wiki"), Key_proc = Bry_.new_a7("proc");
|
||||
private static final byte Tid_edit = 1, Tid_save = 2, Tid_delete = 3;
|
||||
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs_()
|
||||
.Add_str_byte("xowa.xoui.grid.edit" , Tid_edit)
|
||||
.Add_str_byte("xowa.xoui.grid.save" , Tid_save)
|
||||
.Add_str_byte("xowa.xoui.grid.delete" , Tid_delete)
|
||||
;
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class Xoh_lnki_consts {
|
||||
case Tid_img_cls_none: return other_is_empty ? Bry_.Empty : Bry_.Add(Bry_img_cls_prefix, other, Byte_ascii.Quote_bry);
|
||||
case Tid_img_cls_thumbimage: rv = Bry_img_cls_thumbimage; break;
|
||||
case Tid_img_cls_thumbborder: rv = Bry_img_cls_thumbborder; break;
|
||||
default: throw Exc_.new_unhandled(tid);
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
if (other_is_empty) return rv;
|
||||
rv = Bry_.Copy(rv); // copy for replace below
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public interface Xoh_module_itm {
|
||||
byte[] Key();
|
||||
void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr);
|
||||
void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr);
|
||||
void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr);
|
||||
void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr);
|
||||
void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr);
|
||||
void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr);
|
||||
void Clear();
|
||||
}
|
||||
/*
|
||||
Position // top, bottom
|
||||
Targets // mobile, desktop
|
||||
Dependencies
|
||||
Messages
|
||||
*/
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_module_itm_ {
|
||||
public static final byte[] // SRL: navframe, toc, title_rewrite are in wiki.cfg
|
||||
Key_collapsible = Bry_.new_a7("collapsible")
|
||||
, Key_css = Bry_.new_a7("css")
|
||||
, Key_gallery = Bry_.new_a7("gallery")
|
||||
, Key_globals = Bry_.new_a7("globals")
|
||||
, Key_hiero = Bry_.new_a7("hiero")
|
||||
, Key_mathjax = Bry_.new_a7("mathjax")
|
||||
, Key_navframe = Bry_.new_a7("navframe")
|
||||
, Key_popups = Bry_.new_a7("popups")
|
||||
, Key_search_suggest = Bry_.new_a7("xowa.search_suggest")
|
||||
, Key_timeline = Bry_.new_a7("xowa.timeline")
|
||||
, Key_title_rewrite = Bry_.new_a7("title_rewrite")
|
||||
, Key_toc = Bry_.new_a7("toc")
|
||||
, Key_top_icon = Bry_.new_a7("top_icon")
|
||||
, Key_xoui = Bry_.new_a7("xoui")
|
||||
;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__css implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_css;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_css_style_itm(app.Ctg_mgr().Missing_ctg_cls_css());
|
||||
if (app.Html_mgr().Page_mgr().Font_enabled())
|
||||
wtr.Write_css_style_itm(app.Html_mgr().Page_mgr().Font_css_bry());
|
||||
byte[] css_xtn = app.Gui_mgr().Html_mgr().Css_xtn();
|
||||
if (Bry_.Len_gt_0(css_xtn))
|
||||
wtr.Write_css_style_itm(css_xtn);
|
||||
}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__gallery implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_gallery;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_global_ini_atr_val(Key_enabled , true);
|
||||
}
|
||||
private static final byte[]
|
||||
Key_enabled = Bry_.new_a7("gallery-packed-enabled")
|
||||
;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__hiero implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_hiero;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
if (Url_css == null) Url_css = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "xtns", "Wikihiero", "modules", "ext.wikihiero.css").To_http_file_bry();
|
||||
wtr.Write_css_include(Url_css);
|
||||
}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
private static byte[] Url_css;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__mathjax implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_mathjax;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
if (Url_mathjax == null) Url_mathjax = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "xtns", "Math", "modules", "mathjax", "xowa_mathjax.js").To_http_file_bry();
|
||||
wtr.Write_js_include(Url_mathjax);
|
||||
}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
private static byte[] Url_mathjax;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_module_itm__navframe implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_navframe;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_global_ini_atr_val(Key_enabled , true);
|
||||
wtr.Write_js_global_ini_atr_val(Key_collapsed , app.Api_root().Html().Modules().Navframe().Collapsed() || wiki.Html_mgr().Module_mgr().Itm__navframe().Enabled_n());
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_show);
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_hide);
|
||||
}
|
||||
private static final byte[]
|
||||
Key_enabled = Bry_.new_a7("navframe-enabled")
|
||||
, Key_collapsed = Bry_.new_a7("navframe-collapsed")
|
||||
, Key_show = Bry_.new_a7("show")
|
||||
, Key_hide = Bry_.new_a7("hide")
|
||||
;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__timeline implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_timeline;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = false;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
if (Url_js == null) Url_js = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "xowa", "timeline", "timeline.js").To_http_file_bry();
|
||||
wtr.Write_js_include(Url_js);
|
||||
}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
private static byte[] Url_js;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
import gplx.xowa.apis.xowa.html.modules.*;
|
||||
public class Xoh_module_itm__title_rewrite implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_title_rewrite;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "src", "gadgets", "titleRewrite", "titleRewrite.js"));
|
||||
}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.gui.*;
|
||||
public class Xoh_module_itm__xoui implements Xoh_module_itm {
|
||||
public byte[] Key() {return Xoh_module_itm_.Key_xoui;}
|
||||
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
|
||||
public void Clear() {enabled = false;}
|
||||
public Xoh_module_itm__xoui Init(Xoae_app app) {
|
||||
if (dir_url == null) {
|
||||
dir_url = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("xowa", "html", "res", "src", "xowa", "xoui");
|
||||
url_hui_js = dir_url.GenSubFil("xoui.js").To_http_file_bry();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_include(url_hui_js);
|
||||
}
|
||||
public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_line(Bry_.new_a7("var xoui__ctx = {"));
|
||||
wtr.Write_js_line(Bry_.new_a7(" img_dir : '" + Img_dir().To_http_file_str() + "',"));
|
||||
wtr.Write_js_line(Bry_.new_a7(" wiki : '" + wiki.Domain_str() + "',"));
|
||||
wtr.Write_js_line(Bry_.new_a7("}"));
|
||||
}
|
||||
public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
|
||||
public static Io_url Img_dir() {return dir_url.GenSubDir("img");} private static Io_url dir_url; private static byte[] url_hui_js;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
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.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xoh_module_mgr implements Bry_fmtr_arg {
|
||||
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page; private Xoh_module_itm[] itms; private int itms_len;
|
||||
private Xoh_module_wtr wtr = new Xoh_module_wtr();
|
||||
public Xoh_module_mgr() {
|
||||
Itms_add(itm__css, itm__globals, itm__popups, itm__toc, itm__collapsible, itm__navframe, itm__gallery
|
||||
, itm__mathjax, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline
|
||||
, itm__xoui
|
||||
);
|
||||
}
|
||||
public Xoh_module_itm__css Itm__css() {return itm__css;} private Xoh_module_itm__css itm__css = new Xoh_module_itm__css();
|
||||
public Xoh_module_itm__globals Itm__globals() {return itm__globals;} private Xoh_module_itm__globals itm__globals = new Xoh_module_itm__globals();
|
||||
public Xoh_module_itm__popups Itm__popups() {return itm__popups;} private Xoh_module_itm__popups itm__popups = new Xoh_module_itm__popups();
|
||||
public Xoh_module_itm__toc Itm__toc() {return itm__toc;} private Xoh_module_itm__toc itm__toc = new Xoh_module_itm__toc();
|
||||
public Xoh_module_itm__collapsible Itm__collapsible() {return itm__collapsible;} private Xoh_module_itm__collapsible itm__collapsible = new Xoh_module_itm__collapsible();
|
||||
public Xoh_module_itm__navframe Itm__navframe() {return itm__navframe;} private Xoh_module_itm__navframe itm__navframe = new Xoh_module_itm__navframe();
|
||||
public Xoh_module_itm__gallery Itm__gallery() {return itm__gallery;} private Xoh_module_itm__gallery itm__gallery = new Xoh_module_itm__gallery();
|
||||
public Xoh_module_itm__mathjax Itm__mathjax() {return itm__mathjax;} private Xoh_module_itm__mathjax itm__mathjax = new Xoh_module_itm__mathjax();
|
||||
public Xoh_module_itm__hiero Itm__hiero() {return itm__hiero;} private Xoh_module_itm__hiero itm__hiero = new Xoh_module_itm__hiero();
|
||||
public Xoh_module_itm__top_icon Itm__top_icon() {return itm__top_icon;} private Xoh_module_itm__top_icon itm__top_icon = new Xoh_module_itm__top_icon();
|
||||
public Xoh_module_itm__search_suggest Itm__search_suggest() {return itm__search_suggest;} private Xoh_module_itm__search_suggest itm__search_suggest = new Xoh_module_itm__search_suggest();
|
||||
public Xoh_module_itm__timeline Itm__timeline() {return itm__timeline;} private Xoh_module_itm__timeline itm__timeline = new Xoh_module_itm__timeline();
|
||||
public Xoh_module_itm__title_rewrite Itm__title_rewrite() {return itm__title_rewrite;} private Xoh_module_itm__title_rewrite itm__title_rewrite = new Xoh_module_itm__title_rewrite();
|
||||
public Xoh_module_itm__xoui Itm__xoui() {return itm__xoui;} private Xoh_module_itm__xoui itm__xoui = new Xoh_module_itm__xoui();
|
||||
public Xoh_module_mgr Init(Xoae_app app, Xowe_wiki wiki, Xoae_page page) {
|
||||
this.app = app; this.wiki = wiki; this.page = page;
|
||||
return this;
|
||||
}
|
||||
public Xoh_module_mgr Init_dflts() {
|
||||
if (page.Hdr_mgr().Toc_enabled()) itm__toc.Enabled_y_();
|
||||
if (wiki.Html_mgr().Module_mgr().Itm__top_icon().Enabled_y()) itm__top_icon.Enabled_y_();
|
||||
if (wiki.Html_mgr().Module_mgr().Itm__title_rewrite().Enabled_y()) itm__title_rewrite.Enabled_y_();
|
||||
if (app.Gui_mgr().Search_suggest_mgr().Enabled()) itm__search_suggest.Enabled_y_();
|
||||
itm__css.Enabled_y_();
|
||||
itm__globals.Enabled_y_(); // for now, always mark this and rest as exists; DATE:2014-06-09
|
||||
itm__collapsible.Enabled_y_();
|
||||
itm__navframe.Enabled_y_();
|
||||
itm__popups.Enabled_(app.Api_root().Html().Modules().Popups().Enabled());
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
for (int i = 0; i < itms_len; ++i)
|
||||
itms[i].Clear();
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {Write(bfr, app, wiki, page);}
|
||||
public void Write(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, Xoae_page page) {
|
||||
wtr.Init(bfr);
|
||||
wtr.Indent_add();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_module_itm itm = itms[i];
|
||||
itm.Write_css_include(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_css_style_bgn();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_module_itm itm = itms[i];
|
||||
itm.Write_css_script(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_css_style_end();
|
||||
int reset_bgn = wtr.Bfr().Len();
|
||||
wtr.Write_js_script_bgn(); // write <script> before <script src=""> b/c <script> will have cfg values that other scripts will use; EX: xowa_root_dir
|
||||
int reset_end = wtr.Bfr().Len();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_module_itm itm = itms[i];
|
||||
itm.Write_js_head_script(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_head_global_bgn();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_module_itm itm = itms[i];
|
||||
itm.Write_js_head_global(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_head_global_end();
|
||||
if (wtr.Bfr().Len() == reset_end) { // no itms wrote to js_head
|
||||
wtr.Bfr().Delete_rng_to_end(reset_bgn); // delete <script> declaration
|
||||
wtr.Indent_del();
|
||||
}
|
||||
else
|
||||
wtr.Write_js_script_end();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_module_itm itm = itms[i];
|
||||
itm.Write_js_include(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_script_bgn();
|
||||
for (int i = 0; i < itms_len; ++i) {
|
||||
Xoh_module_itm itm = itms[i];
|
||||
itm.Write_js_tail_script(app, wiki, page, wtr);
|
||||
}
|
||||
wtr.Write_js_script_end();
|
||||
wtr.Indent_del();
|
||||
wtr.Term();
|
||||
}
|
||||
private void Itms_add(Xoh_module_itm... ary) {
|
||||
itms_len = ary.length;
|
||||
itms = ary;
|
||||
}
|
||||
}
|
||||
@@ -137,13 +137,13 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
|
||||
Thread_adp_.Sleep(10);
|
||||
}
|
||||
Xoae_page popup_page = popup_wiki.Data_mgr().Get_page(popup_ttl, false);
|
||||
byte[] rv = popup_wiki.Html_mgr().Module_mgr().Popup_mgr().Parser().Parse(wiki, popup_page, cur_page.Tab_data().Tab(), itm);
|
||||
byte[] rv = popup_wiki.Html_mgr().Head_mgr().Popup_mgr().Parser().Parse(wiki, popup_page, cur_page.Tab_data().Tab(), itm);
|
||||
Update_progress_bar(app, cur_wiki, cur_page, itm);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", String_.new_u8(itm.Page_href()), Err_.Message_gplx_brief(e));
|
||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", itm.Page_href(), Err_.Message_gplx_full(e));
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
@@ -172,7 +172,7 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
|
||||
GfoInvkAble_.InvkCmd(async_cmd_show, Invk_show_popup);
|
||||
}
|
||||
catch(Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", String_.new_u8(async_itm.Page_href()), Err_.Message_gplx_brief(e));
|
||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", async_itm.Page_href(), Err_.Message_gplx_full(e));
|
||||
}
|
||||
}
|
||||
private void Show_popup() {
|
||||
@@ -288,12 +288,12 @@ class Load_popup_wkr implements Gfo_thread_wkr {
|
||||
if (ns_allowed_regy.Count() > 0 && !ns_allowed_regy.Has(ns_allowed_regy_key.Val_(popup_ttl.Ns().Id()))) return;
|
||||
itm.Init(popup_wiki.Domain_bry(), popup_ttl);
|
||||
Xoae_page popup_page = popup_wiki.Data_mgr().Get_page(popup_ttl, false);
|
||||
byte[] rv = popup_wiki.Html_mgr().Module_mgr().Popup_mgr().Parser().Parse(wiki, popup_page, cur_page.Tab_data().Tab(), itm);
|
||||
byte[] rv = popup_wiki.Html_mgr().Head_mgr().Popup_mgr().Parser().Parse(wiki, popup_page, cur_page.Tab_data().Tab(), itm);
|
||||
Xow_popup_mgr.Update_progress_bar(app, wiki, cur_page, itm);
|
||||
Rslt_(rv);
|
||||
}
|
||||
catch(Exception e) {
|
||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", String_.new_u8(itm.Page_href()), Err_.Message_gplx_brief(e));
|
||||
app.Usr_dlg().Warn_many("", "", "failed to get popup: href=~{0} err=~{1}", itm.Page_href(), Err_.Message_gplx_full(e));
|
||||
Rslt_(null);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -461,7 +461,7 @@ class Xop_popup_parser_fxt {
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
this.wiki = Xoa_app_fxt.wiki_(app, "en.wiki");
|
||||
parser = wiki.Html_mgr().Module_mgr().Popup_mgr().Parser();
|
||||
parser = wiki.Html_mgr().Head_mgr().Popup_mgr().Parser();
|
||||
parser.Init_by_wiki(wiki);
|
||||
parser.Cfg().Tmpl_read_len_(4);
|
||||
parser.Cfg().Ellipsis_(Bry_.Empty);
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Xop_keeplist_wiki_srl extends Dsv_wkr_base {
|
||||
rules_count = 0;
|
||||
}
|
||||
public Xop_keeplist_wiki Get_tmpl_keeplist() {
|
||||
Xow_popup_parser popup_parser = wiki.Html_mgr().Module_mgr().Popup_mgr().Parser();
|
||||
Xow_popup_parser popup_parser = wiki.Html_mgr().Head_mgr().Popup_mgr().Parser();
|
||||
Xop_keeplist_wiki rv = popup_parser.Tmpl_keeplist();
|
||||
if (rv == null) {
|
||||
rv = new Xop_keeplist_wiki(wiki);
|
||||
|
||||
@@ -43,7 +43,7 @@ class Xop_keeplist_wiki_fxt {
|
||||
public Xop_keeplist_wiki keeplist_wiki_(String raw) {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "enwiki");
|
||||
Xow_popup_mgr popup_mgr = wiki.Html_mgr().Module_mgr().Popup_mgr();
|
||||
Xow_popup_mgr popup_mgr = wiki.Html_mgr().Head_mgr().Popup_mgr();
|
||||
popup_mgr.Init_by_wiki(wiki);
|
||||
popup_mgr.Parser().Tmpl_keeplist_init_(Bry_.new_u8(raw));
|
||||
Xop_keeplist_wiki rv = popup_mgr.Parser().Tmpl_keeplist();
|
||||
|
||||
@@ -65,9 +65,9 @@ public class Xoh_rtl_utl {
|
||||
bfr.Add_mid(src, li_n_end, ul_end); // add from nth "</li>" -> "</ul>"
|
||||
}
|
||||
private static final byte[]
|
||||
Ul_bgn = Bry_.new_u8("<ul")
|
||||
, Ul_end = Bry_.new_u8("</ul>")
|
||||
, Li_bgn = Bry_.new_u8("<li")
|
||||
, Li_end = Bry_.new_u8("</li>")
|
||||
Ul_bgn = Bry_.new_a7("<ul")
|
||||
, Ul_end = Bry_.new_a7("</ul>")
|
||||
, Li_bgn = Bry_.new_a7("<li")
|
||||
, Li_end = Bry_.new_a7("</li>")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xowh_sidebar_mgr implements GfoInvkAble {
|
||||
html_bry = bfr.To_bry_and_rls();
|
||||
comment_bfr.Clear_and_rls();
|
||||
} catch (Exception e) {
|
||||
wiki.Appe().Usr_dlg().Warn_many(GRP_KEY, "sidebar.init", "sidebar init failed: ~{0} ~{1}", wiki.Domain_str(), Err_.Message_gplx_brief(e));
|
||||
wiki.Appe().Usr_dlg().Warn_many(GRP_KEY, "sidebar.init", "sidebar init failed: ~{0} ~{1}", wiki.Domain_str(), Err_.Message_gplx_full(e));
|
||||
html_bry = Bry_.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ public class Xoh_tidy_wkr_ {
|
||||
case Tid_null: return Key_null;
|
||||
case Tid_tidy: return Key_tidy;
|
||||
case Tid_jtidy: return Key_jtidy;
|
||||
default: throw Exc_.new_unimplemented();
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(String s) {
|
||||
if (String_.Eq(s, Key_tidy)) return Tid_tidy;
|
||||
else if (String_.Eq(s, Key_jtidy)) return Tid_jtidy;
|
||||
else if (String_.Eq(s, Key_null)) return Tid_null;
|
||||
else throw Exc_.new_unimplemented();
|
||||
else throw Err_.new_unimplemented();
|
||||
}
|
||||
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_tidy), KeyVal_.new_(Key_jtidy));
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class Xoh_tidy_wkr_jtidy implements Xoh_tidy_wkr {
|
||||
}
|
||||
catch (Exception exc) {
|
||||
bfr.Add(orig); // jtidy failed; restore original
|
||||
app.Usr_dlg().Warn_many("", "", "jtidy.fail; page=~{0} exc=~{1}", page.Ttl().Full_db_as_str(), Err_.Message_gplx_brief(exc));
|
||||
app.Usr_dlg().Warn_many("", "", "jtidy.fail; page=~{0} exc=~{1}", page.Ttl().Full_db_as_str(), Err_.Message_gplx_full(exc));
|
||||
}
|
||||
finally {
|
||||
wtr.reset();
|
||||
|
||||
@@ -108,7 +108,7 @@ public class Xow_toc_mgr implements Bry_fmtr_arg {
|
||||
bfr.Mkr_rls();
|
||||
return bfr.Xto_bry_and_clear();
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "failed to write toc: url=~{0} err=~{1}", page.Url().Xto_full_str_safe(), Err_.Message_gplx_brief(e));
|
||||
Gfo_usr_dlg_.I.Warn_many("", "", "failed to write toc: url=~{0} err=~{1}", page.Url().Xto_full_str_safe(), Err_.Message_gplx_full(e));
|
||||
return Bry_.Empty;
|
||||
}
|
||||
}
|
||||
@@ -194,9 +194,9 @@ public class Xow_toc_mgr implements Bry_fmtr_arg {
|
||||
bfmtr_main.Bld_bfr_many(bfr, Bry_fmtr_arg_.bry_(bry_contents), this);
|
||||
}
|
||||
private static final byte[]
|
||||
Bry_list_bgn = Bry_.new_u8(" <ul>\n")
|
||||
, Bry_list_end = Bry_.new_u8(" </ul>\n")
|
||||
, Bry_item_end = Bry_.new_u8(" </li>\n")
|
||||
Bry_list_bgn = Bry_.new_a7(" <ul>\n")
|
||||
, Bry_list_end = Bry_.new_a7(" </ul>\n")
|
||||
, Bry_item_end = Bry_.new_a7(" </li>\n")
|
||||
;
|
||||
private Bry_fmtr
|
||||
bfmtr_main = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
|
||||
@@ -132,7 +132,7 @@ public class Xow_toc_mgr_tst {
|
||||
, " </ul>"
|
||||
));
|
||||
}
|
||||
@Test public void Exc() { // PURPOSE: models strange case wherein jumping down does not work
|
||||
@Test public void Err() { // PURPOSE: models strange case wherein jumping down does not work
|
||||
fxt.Test_html_toc(String_.Concat_lines_nl_skip_last
|
||||
( "==a=="
|
||||
, "====b===="
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
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.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
import gplx.xowa.html.xouis.tbls.*;
|
||||
public class Xoui_cells_fmtr implements Bry_fmtr_arg {
|
||||
private final Xoui_cell_fmtr cell_fmtr = new Xoui_cell_fmtr();
|
||||
private final Xoui_btn_fmtr btn_fmtr = new Xoui_btn_fmtr();
|
||||
private Xoui_btn_itm[] btns;
|
||||
private byte[] row_key; private Xoui_row_itm row_itm;
|
||||
public void Ctor(Xoui_val_fmtr val_fmtr, Xoui_btn_itm[] btns) {
|
||||
cell_fmtr.Ctor(val_fmtr); this.btns = btns;
|
||||
}
|
||||
public Xoui_cells_fmtr Init(byte[] row_key, Xoui_row_itm row_itm) {
|
||||
this.row_key = row_key; this.row_itm = row_itm;
|
||||
return this;
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
fmtr.Bld_bfr_many(bfr, row_key, cell_fmtr.Init(row_key, row_itm), btn_fmtr.Init(row_key, btns));
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "~{vals}"
|
||||
, " <td id='~{row_key}_btns'>~{btns}"
|
||||
, " </td>"
|
||||
), "row_key", "vals", "btns");
|
||||
}
|
||||
class Xoui_cell_fmtr implements Bry_fmtr_arg {
|
||||
private byte[] row_key; private Xoui_row_itm row_itm;
|
||||
private Xoui_val_fmtr val_fmtr;
|
||||
public void Ctor(Xoui_val_fmtr val_fmtr) {this.val_fmtr = val_fmtr;}
|
||||
public Xoui_cell_fmtr Init(byte[] row_key, Xoui_row_itm row_itm) {this.row_key = row_key; this.row_itm = row_itm; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
Xoui_col_itm[] cols = row_itm.Tbl().Cols();
|
||||
Xoui_val_itm[] vals = row_itm.Vals(); int len = vals.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoui_val_itm val = vals[i];
|
||||
fmtr.Bld_bfr_many(bfr, row_key, i, val_fmtr.Init(cols[i], val));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <td id='~{row_key}_~{val_idx}'>~{html}</td>"
|
||||
), "row_key", "val_idx", "html");
|
||||
}
|
||||
class Xoui_btn_fmtr implements Bry_fmtr_arg {
|
||||
private byte[] row_key; private Xoui_btn_itm[] btns;
|
||||
public Xoui_btn_fmtr Init(byte[] row_key, Xoui_btn_itm[] btns) {
|
||||
this.row_key = row_key; this.btns = btns; return this;
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
int len = btns.length;
|
||||
Io_url img_dir = gplx.xowa.html.modules.Xoh_module_itm__xoui.Img_dir();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoui_btn_itm btn = btns[i];
|
||||
fmtr.Bld_bfr_many(bfr, row_key, btn.Key(), btn.Cmd(), img_dir.GenSubFil(btn.Img()).To_http_file_bry(), btn.Text());
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <span id='~{row_key}_~{btn_key}'><a href='javascript:~{btn_cmd}(\"~{row_key}\");'><img src='~{btn_img}' title='~{btn_text}'/></a></span>"
|
||||
), "row_key", "btn_key", "btn_cmd", "btn_img", "btn_text");
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
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.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
import gplx.xowa.html.xouis.tbls.*;
|
||||
public class Xoui_tbl_fmtr {
|
||||
private final Xoui_head_cell_fmtr head_cell_fmtr = new Xoui_head_cell_fmtr();
|
||||
private final Xoui_row_fmtr row_fmtr = new Xoui_row_fmtr();
|
||||
public void Write(Bry_bfr bfr, Xoui_tbl_itm tbl) {
|
||||
tbl_fmtr.Bld_bfr_many(bfr, tbl.Key(), head_cell_fmtr.Init(tbl), row_fmtr.Init(tbl));
|
||||
}
|
||||
private static final Bry_fmtr tbl_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<table id='~{tbl_key}' class='xoui_tbl wikitable'>"
|
||||
, " <tr>~{head_cells}"
|
||||
, " </tr>~{data_rows}"
|
||||
, "</table>"
|
||||
), "tbl_key", "head_cells", "data_rows");
|
||||
}
|
||||
class Xoui_head_cell_fmtr implements Bry_fmtr_arg {
|
||||
private Xoui_tbl_itm tbl;
|
||||
public Xoui_head_cell_fmtr Init(Xoui_tbl_itm tbl) {this.tbl = tbl; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
Xoui_col_itm[] cols = tbl.Cols(); int len = cols.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoui_col_itm col = cols[i];
|
||||
fmtr.Bld_bfr_many(bfr, col.Width(), col.Display());
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <th width=~{width}>~{display}</th>"
|
||||
), "width", "display");
|
||||
}
|
||||
class Xoui_row_fmtr implements Bry_fmtr_arg {
|
||||
private final Xoui_cells_fmtr cells_fmtr = new Xoui_cells_fmtr();
|
||||
private final Xoui_val_fmtr val_fmtr = Xoui_val_fmtr_.new_view();
|
||||
private final Bry_bfr row_key_bfr = Bry_bfr.new_(255);
|
||||
private Xoui_tbl_itm tbl;
|
||||
public Xoui_row_fmtr Init(Xoui_tbl_itm tbl) {this.tbl = tbl; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
byte[] tbl_key = tbl.Key();
|
||||
Xoui_row_itm[] rows = tbl.Rows(); int len = rows.length;
|
||||
cells_fmtr.Ctor(val_fmtr, tbl.View_btns());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoui_row_itm row = rows[i];
|
||||
row_key_bfr.Add(tbl_key).Add_byte(Byte_ascii.Underline).Add_int_variable(i);
|
||||
byte[] row_key = row_key_bfr.Xto_bry_and_clear();
|
||||
fmtr.Bld_bfr_many(bfr, row_key, row.Pkey(), cells_fmtr.Init(row_key, row));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <tr id='~{row_key}' class='xoui_row' xoui_pkey='~{pkey}'>~{cells}"
|
||||
, " </tr>"
|
||||
), "row_key", "pkey", "cells");
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
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.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
import gplx.xowa.html.xouis.tbls.*;
|
||||
public interface Xoui_val_fmtr {
|
||||
Xoui_val_fmtr Init(Xoui_col_itm col, Xoui_val_itm val);
|
||||
}
|
||||
class Xoui_val_fmtr__view implements Bry_fmtr_arg, Xoui_val_fmtr {
|
||||
private Xoui_val_itm val;
|
||||
public Xoui_val_fmtr Init(Xoui_col_itm col, Xoui_val_itm val) {this.val = val; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
bfr.Add(val.Html());
|
||||
}
|
||||
}
|
||||
class Xoui_val_fmtr__edit implements Bry_fmtr_arg, Xoui_val_fmtr {
|
||||
private Xoui_col_itm col; private Xoui_val_itm val;
|
||||
public Xoui_val_fmtr Init(Xoui_col_itm col, Xoui_val_itm val) {this.col = col; this.val = val; return this;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
switch (col.Type()) {
|
||||
case Xoui_col_itm.Type_id_str: fmtr_str.Bld_bfr_many(bfr, col.Key(), val.Data().length * 8, val.Data()); break;
|
||||
default: throw Exc_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr_str = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <input class='xoui_cell' xoui_col='~{col_key}' style='width:~{width}px' value='~{value}' />"
|
||||
), "col_key", "width", "value");
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
public interface Xoui_tbl_itm {
|
||||
byte[] Key();
|
||||
Xoui_col_itm[] Cols();
|
||||
Xoui_row_itm[] Rows(); void Rows_(Xoui_row_itm[] v);
|
||||
Xoui_btn_itm[] View_btns();
|
||||
Xoui_btn_itm[] Edit_btns();
|
||||
void Del(byte[] row_pkey_bry);
|
||||
String Edit(byte[] row_key, byte[] row_pkey_bry);
|
||||
String Save(Xow_wiki wiki, byte[] row_key, byte[] row_pkey_bry, Xoui_val_hash ary);
|
||||
void Set_order_adj(byte[] row_pkey, boolean adj_down);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
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.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
|
||||
import gplx.json.*;
|
||||
import gplx.xowa.html.xouis.fmtrs.*;
|
||||
public class Xoui_tbl_mgr {
|
||||
private final Ordered_hash tbl_hash = Ordered_hash_.new_bry_();
|
||||
private final Xoui_tbl_fmtr tbl_fmtr = new Xoui_tbl_fmtr();
|
||||
public String Del(Json_doc jdoc) {
|
||||
Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
|
||||
byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
|
||||
tbl_itm.Del(row_pkey);
|
||||
return "{}";
|
||||
}
|
||||
public void Write(Bry_bfr bfr, Xoui_tbl_itm tbl) {
|
||||
tbl_hash.Del(tbl.Key());
|
||||
tbl_hash.Add(tbl.Key(), tbl);
|
||||
tbl_fmtr.Write(bfr, tbl);
|
||||
}
|
||||
public String Edit(Json_doc jdoc) {
|
||||
Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
|
||||
byte[] row_id = Get_row_key_in_jdoc(jdoc);
|
||||
byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
|
||||
return tbl_itm.Edit(row_id, row_pkey);
|
||||
}
|
||||
public String Save(Xow_wiki wiki, Json_doc jdoc) {
|
||||
Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
|
||||
byte[] row_id = Get_row_key_in_jdoc(jdoc);
|
||||
byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
|
||||
return tbl_itm.Save(wiki, row_id, row_pkey, To_hash(jdoc.Get_grp(Arg_data)));
|
||||
}
|
||||
public void Adj_order(Json_doc jdoc) {
|
||||
Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
|
||||
byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
|
||||
boolean adj_down = Yn.parse_by_char_or(String_.new_a7(jdoc.Get_val_as_bry_or(Arg_adj_down, null)), false);
|
||||
tbl_itm.Set_order_adj(row_pkey, adj_down);
|
||||
}
|
||||
private Xoui_tbl_itm Get_tbl_by_jdoc(Json_doc jdoc) {
|
||||
byte[] key = jdoc.Get_val_as_bry_or(Arg_tbl_key, null); if (key == null) throw Exc_.new_("dbui.mgr; unknown tbl", "jdoc", jdoc.Src());
|
||||
Xoui_tbl_itm tbl = (Xoui_tbl_itm)tbl_hash.Get_by(key); if (tbl == null) throw Exc_.new_("dbui.mgr; unknown tbl key", "key", key);
|
||||
return tbl;
|
||||
}
|
||||
private byte[] Get_row_pkey_in_jdoc(Json_doc jdoc) {
|
||||
byte[] rv = jdoc.Get_val_as_bry_or(Arg_row_pkey, null); if (rv == null) throw Exc_.new_("dbui.mgr; unknown row_pkey", "jdoc", jdoc.Src());
|
||||
return rv;
|
||||
}
|
||||
private byte[] Get_row_key_in_jdoc(Json_doc jdoc) {
|
||||
byte[] rv = jdoc.Get_val_as_bry_or(Arg_row_id, null); if (rv == null) throw Exc_.new_("dbui.mgr; unknown row_id", "jdoc", jdoc.Src());
|
||||
return rv;
|
||||
}
|
||||
private Xoui_val_hash To_hash(Json_grp grp) {
|
||||
Xoui_val_hash rv = new Xoui_val_hash();
|
||||
int len = grp.Subs_len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_itm_kv kv = (Json_itm_kv)grp.Subs_get_at(i);
|
||||
Json_itm_nde nde = (Json_itm_nde)kv.Val();
|
||||
Json_itm_kv key = (Json_itm_kv)nde.Subs_get_by_key(Arg_key);
|
||||
Json_itm_kv val = (Json_itm_kv)nde.Subs_get_by_key(Arg_val);
|
||||
Xoui_val_itm fld = new Xoui_val_itm(val.Val().Data_bry(), Bry_.Empty);
|
||||
rv.Add(key.Val().Data_bry(), fld);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final byte[]
|
||||
Arg_tbl_key = Bry_.new_a7("tbl_key"), Arg_row_pkey = Bry_.new_a7("row_pkey"), Arg_row_id = Bry_.new_a7("row_id"), Arg_data = Bry_.new_a7("data")
|
||||
, Arg_adj_down = Bry_.new_a7("adj_down"), Arg_key = Bry_.new_a7("key"), Arg_val = Bry_.new_a7("val");
|
||||
}
|
||||
Reference in New Issue
Block a user