mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.10.3.1
This commit is contained in:
39
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm_.java
Normal file
39
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm_.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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__graph = Bry_.new_a7("graph")
|
||||
, 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/htmls/heads/Xoh_head_itm__base.java
Normal file
48
400_xowa/src/gplx/xowa/htmls/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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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
|
||||
*/
|
||||
@@ -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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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);
|
||||
wtr.Write_js_global_ini_atr_msg(wiki , Key_expand);
|
||||
}
|
||||
private static final byte[]
|
||||
Key_enabled = Bry_.new_a7("collapsible-enabled")
|
||||
, Key_collapsed = Bry_.new_a7("collapsible-collapsed")
|
||||
, Key_collapse = Bry_.new_a7("collapsible-collapse")
|
||||
, Key_expand = Bry_.new_a7("collapsible-expand")
|
||||
;
|
||||
}
|
||||
31
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__css.java
Normal file
31
400_xowa/src/gplx/xowa/htmls/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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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/htmls/heads/Xoh_head_itm__dbui.java
Normal file
123
400_xowa/src/gplx/xowa/htmls/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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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',"
|
||||
, " });"
|
||||
))
|
||||
;
|
||||
}
|
||||
@@ -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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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")
|
||||
;
|
||||
}
|
||||
106
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__globals.java
Normal file
106
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__globals.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.numbers.*;
|
||||
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);
|
||||
}
|
||||
@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);
|
||||
}
|
||||
@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);
|
||||
}
|
||||
@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.Mode().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.Mode().Tid_is_gui());
|
||||
wtr.Write_js_global_ini_atr_val(Key_mode_is_http , app.Mode().Tid_is_http());
|
||||
wtr.Write_js_global_ini_atr_val(Key_http_port , app.Http_server().Port());
|
||||
wtr.Write_js_global_ini_atr_msg(wiki, Key_sort_ascending);
|
||||
wtr.Write_js_global_ini_atr_msg(wiki, Key_sort_descending);
|
||||
Xol_lang_itm lang = wiki.Lang(); Xow_msg_mgr msg_mgr = wiki.Msg_mgr();
|
||||
Bry_bfr tmp_bfr = app.Utl__bfr_mkr().Get_b512();
|
||||
tmp_wtr.Init(tmp_bfr);
|
||||
byte[] months_long = Html_js_table_months(tmp_wtr, msg_mgr, Xol_msg_itm_.Id_dte_month_name_january, Xol_msg_itm_.Id_dte_month_name_december);
|
||||
byte[] months_short = Html_js_table_months(tmp_wtr, msg_mgr, Xol_msg_itm_.Id_dte_month_abrv_jan, Xol_msg_itm_.Id_dte_month_abrv_dec);
|
||||
byte[] num_format_separators = Html_js_table_num_format_separators(tmp_wtr, lang.Num_mgr().Separators_mgr());
|
||||
tmp_bfr.Mkr_rls();
|
||||
wtr.Write_js_global_ini_atr_val(Key_wgContentLanguage , lang.Key_bry());
|
||||
wtr.Write_js_global_ini_atr_obj(Key_wgSeparatorTransformTable , num_format_separators);
|
||||
wtr.Write_js_global_ini_atr_obj(Key_wgDigitTransformTable , Num_format_digits);
|
||||
wtr.Write_js_global_ini_atr_val(Key_wgDefaultDateFormat , Date_format_default);
|
||||
wtr.Write_js_global_ini_atr_obj(Key_wgMonthNames , months_long);
|
||||
wtr.Write_js_global_ini_atr_obj(Key_wgMonthNamesShort , months_short);
|
||||
}
|
||||
public static final byte[] // NOTE: most of these are for the table-sorter
|
||||
Key_mode_is_gui = Bry_.new_a7("mode_is_gui")
|
||||
, Key_mode_is_http = Bry_.new_a7("mode_is_http")
|
||||
, Key_http_port = Bry_.new_a7("http-port")
|
||||
, Key_sort_descending = Bry_.new_a7("sort-descending")
|
||||
, Key_sort_ascending = Bry_.new_a7("sort-ascending")
|
||||
, Key_wgContentLanguage = Bry_.new_a7("wgContentLanguage")
|
||||
, Key_wgSeparatorTransformTable = Bry_.new_a7("wgSeparatorTransformTable")
|
||||
, Key_wgDigitTransformTable = Bry_.new_a7("wgDigitTransformTable")
|
||||
, Key_wgDefaultDateFormat = Bry_.new_a7("wgDefaultDateFormat")
|
||||
, Key_wgMonthNames = Bry_.new_a7("wgMonthNames")
|
||||
, Key_wgMonthNamesShort = Bry_.new_a7("wgMonthNamesShort")
|
||||
;
|
||||
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++)
|
||||
tmp_wtr.Write_js_ary_itm(msg_mgr.Val_by_id(i));
|
||||
tmp_wtr.Write_js_ary_end();
|
||||
return tmp_wtr.Bfr().To_bry_and_clear();
|
||||
}
|
||||
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();
|
||||
tmp_wtr.Write_js_ary_itm(Bry_.Add(dec_spr, Byte_ascii.Tab_bry, Byte_ascii.Dot_bry));
|
||||
tmp_wtr.Write_js_ary_itm(Bry_.Add(grp_spr, Byte_ascii.Tab_bry, Byte_ascii.Comma_bry));
|
||||
tmp_wtr.Write_js_ary_end();
|
||||
return tmp_wtr.Bfr().To_bry_and_clear();
|
||||
}
|
||||
private static final byte[]
|
||||
Date_format_default = Bry_.new_a7("dmy")
|
||||
, Num_format_digits = Bry_.new_a7("['', '']")
|
||||
, 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_exec_js, Url_DOMContentLoaded_js;
|
||||
}
|
||||
44
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__graph.java
Normal file
44
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__graph.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
public class Xoh_head_itm__graph extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__graph;}
|
||||
@Override public int Flags() {return Flag__js_include | Flag__js_window_onload;}
|
||||
@Override public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
if (Url__ary == null) {
|
||||
Io_url lib_dir = app.Fsys_mgr().Bin_xtns_dir().GenSubDir_nest("Graph", "lib");
|
||||
Url__ary = new byte[][]
|
||||
{ app.Fsys_mgr().Bin_xowa_dir().GenSubFil_nest("html", "res", "lib", "jquery", "jquery-1.11.3.min.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("d3.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("d3.layout.cloud.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("topojson.js").To_http_file_bry()
|
||||
, lib_dir.GenSubFil("vega.js").To_http_file_bry()
|
||||
, app.Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("Graph", "js", "graph.js").To_http_file_bry()
|
||||
};
|
||||
}
|
||||
for (int i = 0; i < Url__ary_len; ++i)
|
||||
wtr.Write_js_include(Url__ary[i]);
|
||||
}
|
||||
@Override public void Write_js_window_onload(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_head_wtr wtr) {
|
||||
wtr.Write_js_line(Js__graph_exec);
|
||||
}
|
||||
private static final int Url__ary_len = 6;
|
||||
private static byte[][] Url__ary;
|
||||
private static final byte[] Js__graph_exec = Bry_.new_a7("xtn__graph__exec();");
|
||||
}
|
||||
28
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__hiero.java
Normal file
28
400_xowa/src/gplx/xowa/htmls/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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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;
|
||||
}
|
||||
@@ -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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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")
|
||||
;
|
||||
}
|
||||
54
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__popups.java
Normal file
54
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__popups.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
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;
|
||||
@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);
|
||||
}
|
||||
@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());
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_max_w , api_popups.Win_max_w());
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_max_h , api_popups.Win_max_h());
|
||||
wtr.Write_js_global_ini_atr_val(Key_win_show_all_max_w , api_popups.Win_show_all_max_w());
|
||||
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")
|
||||
, Key_win_hide_delay = Bry_.new_a7("popups-win-hide_delay")
|
||||
, Key_win_max_w = Bry_.new_a7("popups-win-max_w")
|
||||
, Key_win_max_h = Bry_.new_a7("popups-win-max_h")
|
||||
, Key_win_show_all_max_w = Bry_.new_a7("popups-win-show_all_max_w")
|
||||
, Key_win_bind_focus_blur = Bry_.new_a7("popups-win-bind_focus_blur")
|
||||
, Key_win_bind_hover_area = Bry_.new_a7("popups-win-bind_hover_area")
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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);
|
||||
}
|
||||
@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);
|
||||
}
|
||||
private static byte[] Url_css, Url_js;
|
||||
}
|
||||
34
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__server.java
Normal file
34
400_xowa/src/gplx/xowa/htmls/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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.apps.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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.apps.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"));
|
||||
}
|
||||
}
|
||||
44
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__toc.java
Normal file
44
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__toc.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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")
|
||||
, Val_collapsed_y = Bry_.new_a7("1")
|
||||
, Val_collapsed_n = Bry_.new_a7("0")
|
||||
;
|
||||
public static final byte[]
|
||||
Key_showtoc = Bry_.new_a7("showtoc")
|
||||
, Key_hidetoc = Bry_.new_a7("hidetoc")
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
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);
|
||||
}
|
||||
@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"));
|
||||
}
|
||||
private static byte[] Css_url;
|
||||
}
|
||||
176
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_mgr.java
Normal file
176
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_mgr.java
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
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__graph, 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__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__gallery Itm__gallery() {return itm__gallery;} private final Xoh_head_itm__gallery itm__gallery = new Xoh_head_itm__gallery();
|
||||
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__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__graph Itm__graph() {return itm__graph;} private final Xoh_head_itm__graph itm__graph = new Xoh_head_itm__graph();
|
||||
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__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__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 Fmt__do(Bry_bfr bfr) {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 (Bitmask_.Has_int(flag, Xoh_head_itm__base.Flag__css_include)) list__css_include.Add(itm);
|
||||
if (Bitmask_.Has_int(flag, Xoh_head_itm__base.Flag__css_text)) list__css_text.Add(itm);
|
||||
if (Bitmask_.Has_int(flag, Xoh_head_itm__base.Flag__js_include)) list__js_include.Add(itm);
|
||||
if (Bitmask_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_global)) list__js_head_global.Add(itm);
|
||||
if (Bitmask_.Has_int(flag, Xoh_head_itm__base.Flag__js_head_script)) list__js_head_script.Add(itm);
|
||||
if (Bitmask_.Has_int(flag, Xoh_head_itm__base.Flag__js_tail_script)) list__js_tail_script.Add(itm);
|
||||
if (Bitmask_.Has_int(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);}
|
||||
}
|
||||
145
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_mgr_tst.java
Normal file
145
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_mgr_tst.java
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
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
|
||||
( ""
|
||||
, " <style type=\"text/css\">"
|
||||
, " .xowa-missing-category-entry {color: red;}"
|
||||
, " </style>"
|
||||
));
|
||||
}
|
||||
@Test public void Toc() {
|
||||
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
|
||||
( ""
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'toc-enabled' : true,"
|
||||
, " 'mw_hidetoc' : '0',"
|
||||
, " 'showtoc' : 'Sh\"ow',"
|
||||
, " 'hidetoc' : 'Hi\\'de',"
|
||||
, " }"
|
||||
, " </script>"
|
||||
));
|
||||
}
|
||||
@Test public void Globals() {
|
||||
fxt.Init_msg(Xol_msg_itm_.Id_dte_month_name_january, "Jan'uary" ); // add apos to simulate apostrophes in Hebrew months; DATE:2014-07-28
|
||||
fxt.Mgr().Itm__globals().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <link rel=\"stylesheet\" href=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.css\" type='text/css'>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_root_dir = 'file:///mem/xowa/';"
|
||||
, " var xowa_mode_is_server = false;"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'mode_is_gui' : false,"
|
||||
, " 'mode_is_http' : false,"
|
||||
, " 'http-port' : 8080,"
|
||||
, " 'sort-ascending' : 'Sort ascending',"
|
||||
, " 'sort-descending' : 'Sort descending',"
|
||||
, " 'wgContentLanguage' : 'en',"
|
||||
, " 'wgSeparatorTransformTable' : ['.\t.', ',\t,'],"
|
||||
, " 'wgDigitTransformTable' : ['', ''],"
|
||||
, " 'wgDefaultDateFormat' : 'dmy',"
|
||||
, " 'wgMonthNames' : ['', 'Jan\\'uary', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],"
|
||||
, " 'wgMonthNamesShort' : ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],"
|
||||
, " }"
|
||||
, " </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
|
||||
}
|
||||
@Test public void Globals_la() { // PURPOSE: la.gfs only specifies "," not "."; make sure both "." and "," show up, or else null ref error during import; DATE:2014-05-13
|
||||
Xol_lang_itm la_lang = fxt.Wiki().Lang();
|
||||
gplx.xowa.langs.numbers.Xol_transform_mgr separators_mgr = la_lang.Num_mgr().Separators_mgr();
|
||||
separators_mgr.Clear();
|
||||
separators_mgr.Set(gplx.xowa.langs.numbers.Xol_num_mgr.Separators_key__grp, Bry_.new_a7(" "));
|
||||
fxt.Mgr().Itm__globals().Enabled_y_();
|
||||
fxt.Test_write(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <link rel=\"stylesheet\" href=\"file:///mem/xowa/bin/any/xowa/html/res/src/xowa/core/core.css\" type='text/css'>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_root_dir = 'file:///mem/xowa/';"
|
||||
, " var xowa_mode_is_server = false;"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'mode_is_gui' : false,"
|
||||
, " 'mode_is_http' : false,"
|
||||
, " 'http-port' : 8080,"
|
||||
, " 'sort-ascending' : 'Sort ascending',"
|
||||
, " 'sort-descending' : 'Sort descending',"
|
||||
, " 'wgContentLanguage' : 'en',"
|
||||
, " 'wgSeparatorTransformTable' : ['.\t.', ' \t,']," // note that grp spr (",") is ""
|
||||
, " 'wgDigitTransformTable' : ['', ''],"
|
||||
, " 'wgDefaultDateFormat' : 'dmy',"
|
||||
, " 'wgMonthNames' : ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],"
|
||||
, " 'wgMonthNamesShort' : ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],"
|
||||
, " }"
|
||||
, " </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_head_mgr_fxt {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
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_head_mgr Mgr() {return mgr;}
|
||||
public Xol_lang_itm Make_lang(String key) {return wiki.Appe().Lang_mgr().Get_by_or_new(Bry_.new_a7(key));}
|
||||
public void Clear() {
|
||||
fxt.Reset();
|
||||
mgr = fxt.Page().Html_data().Head_mgr();
|
||||
wiki = fxt.Wiki();
|
||||
}
|
||||
public void Init_msg(byte[] key, String val) {
|
||||
wiki.Msg_mgr().Get_or_make(key).Atrs_set(Bry_.new_a7(val), false, false);
|
||||
}
|
||||
public void Init_msg(int id, String val) {
|
||||
Xol_msg_itm msg_itm = wiki.Lang().Msg_mgr().Itm_by_id_or_null(id);
|
||||
msg_itm.Atrs_set(Bry_.new_a7(val), false, false);
|
||||
}
|
||||
public void Test_write(String expd) {
|
||||
mgr.Write(bfr, fxt.App(), wiki, fxt.Page());
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
230
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_wtr.java
Normal file
230
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_wtr.java
Normal file
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.htmls.*;
|
||||
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;
|
||||
public void Init(Bry_bfr bfr) {this.bfr = bfr;}
|
||||
public void Term() {
|
||||
this.bfr = null;
|
||||
js_tail_inited = true;
|
||||
}
|
||||
public void Write_css_include(byte[] url) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Css_include_bgn).Add(url).Add(Css_include_end);
|
||||
}
|
||||
public void Write_js_include(byte[] url) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_include_bgn).Add(url).Add(Js_include_end);
|
||||
}
|
||||
public void Write_css_style_bgn() {
|
||||
reset_bgn = bfr.Len();
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Html_tag_.Style_lhs_w_type);
|
||||
Indent_add();
|
||||
reset_end = bfr.Len();
|
||||
}
|
||||
public void Write_css_style_end() {
|
||||
Indent_del();
|
||||
if (Reset()) return;
|
||||
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();
|
||||
bfr.Add(Html_tag_.Script_lhs_w_type);
|
||||
Indent_add();
|
||||
reset_end = bfr.Len();
|
||||
}
|
||||
public void Write_js_script_end() {
|
||||
Indent_del();
|
||||
if (Reset()) return;
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Html_tag_.Script_rhs);
|
||||
}
|
||||
public void Write_js_head_global_bgn() {
|
||||
reset_bgn = bfr.Len();
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_globals_ini_var_bgn);
|
||||
Indent_add();
|
||||
reset_end = bfr.Len();
|
||||
}
|
||||
public void Write_js_head_global_end() {
|
||||
Indent_del();
|
||||
if (Reset()) return;
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_globals_ini_var_end);
|
||||
}
|
||||
private void Write_js_tail_init() {
|
||||
if (js_tail_inited) return;
|
||||
js_tail_inited = true;
|
||||
Write_js_line(Js_line_1);
|
||||
}
|
||||
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);
|
||||
bfr.Add(Js_line_2_end);
|
||||
}
|
||||
private static final byte[]
|
||||
Js_line_1 = Bry_.new_a7("xowa.js.jquery.init();")
|
||||
, Js_line_2_bgn = Bry_.new_a7("xowa.js.load_lib('")
|
||||
, Js_line_2_end = Bry_.new_a7("');")
|
||||
;
|
||||
private boolean Reset() {
|
||||
if (bfr.Len() == reset_end) { // itms wrote nothing
|
||||
bfr.Delete_rng_to_end(reset_bgn); // delete bgn
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
public void Write_js_global_ini_atr_val(byte[] key, boolean val) {Write_js_global_ini_atr(key, Bool_.N, val ? Bool_.True_bry : Bool_.False_bry);}
|
||||
public void Write_js_global_ini_atr_val(byte[] key, byte[] val) {Write_js_global_ini_atr(key, Bool_.Y, val);}
|
||||
public void Write_js_global_ini_atr_obj(byte[] key, byte[] val) {Write_js_global_ini_atr(key, Bool_.N, val);}
|
||||
public void Write_js_global_ini_atr_msg(Xowe_wiki wiki, byte[] key) {Write_js_global_ini_atr(key, Bool_.Y, wiki.Msg_mgr().Val_by_key_obj(key));}
|
||||
private void Write_js_global_ini_atr(byte[] key, boolean quote_val, byte[] val) {
|
||||
Write_js_global_ini_atr_bgn(key);
|
||||
if (quote_val)
|
||||
Write_js_quote(Byte_ascii.Apos, val);
|
||||
else
|
||||
bfr.Add(val);
|
||||
bfr.Add_byte(Byte_ascii.Comma);
|
||||
}
|
||||
public void Write_js_global_ini_atr_val(byte[] key, int val) {
|
||||
Write_js_global_ini_atr_bgn(key);
|
||||
bfr.Add_int_variable(val);
|
||||
bfr.Add_byte(Byte_ascii.Comma);
|
||||
}
|
||||
private void Write_js_global_ini_atr_bgn(byte[] key) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add_byte_apos();
|
||||
bfr.Add(key);
|
||||
bfr.Add_byte_apos();
|
||||
bfr.Add(Js_globals_ini_atr_mid);
|
||||
}
|
||||
public void Write_js_ary_bgn() {js_ary_idx = 0; bfr.Add_byte(Byte_ascii.Brack_bgn);}
|
||||
public void Write_js_ary_itm(byte[] val) {
|
||||
if (++js_ary_idx != 1) bfr.Add(js_ary_dlm);
|
||||
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);
|
||||
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(byte[] v) {
|
||||
Indent();
|
||||
bfr.Add(v);
|
||||
}
|
||||
private void Write_js_quote(byte quote_byte, byte[] val) {
|
||||
int val_len = val.length;
|
||||
bfr.Add_byte(quote_byte);
|
||||
for (int i = 0; i < val_len; i++) {
|
||||
byte b = val[i];
|
||||
if (b == quote_byte) bfr.Add_byte_backslash(); // escape quote
|
||||
bfr.Add_byte(b);
|
||||
}
|
||||
bfr.Add_byte(quote_byte);
|
||||
}
|
||||
private void Write_nl_and_indent() {
|
||||
bfr.Add_byte_nl(); Indent();
|
||||
}
|
||||
private void Indent() {bfr.Add_byte_repeat(Byte_ascii.Space, indent);}
|
||||
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'>")
|
||||
, Js_include_bgn = Bry_.new_a7("<script src=\"")
|
||||
, Js_include_end = Bry_.new_a7("\" type='text/javascript'></script>")
|
||||
, Js_globals_ini_var_bgn = Bry_.new_a7("var xowa_global_values = {")
|
||||
, Js_globals_ini_var_end = Bry_.new_a7("}")
|
||||
, Js_globals_ini_atr_mid = Bry_.new_a7(" : ")
|
||||
, 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(" = {};")
|
||||
;
|
||||
}
|
||||
63
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_wtr_tst.java
Normal file
63
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_wtr_tst.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.guis.*;
|
||||
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_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_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");
|
||||
fxt.Exec_Write_js_global_ini_atr_val("key_3", "apos_'_1");
|
||||
wtr.Write_js_head_global_end();
|
||||
fxt.Test(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "var xowa_global_values = {"
|
||||
, " 'key_1' : 'val_1',"
|
||||
, " 'key_2' : 'val_2',"
|
||||
, " 'key_3' : 'apos_\\'_1',"
|
||||
, "}"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoh_head_wtr_fxt {
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(255);
|
||||
public Xoh_head_wtr Wtr() {return wtr;} private Xoh_head_wtr wtr = new Xoh_head_wtr();
|
||||
public void Clear() {
|
||||
wtr.Init(bfr);
|
||||
}
|
||||
public void Exec_Write_js_global_ini_atr_val(String key, String val) {wtr.Write_js_global_ini_atr_val(Bry_.new_u8(key), Bry_.new_u8(val));}
|
||||
public void Test(String expd) {
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
// public void Init_msg(byte[] key, String val) {
|
||||
// wiki.Msg_mgr().Get_or_make(key).Atrs_set(Bry_.new_a7(val), false, false);
|
||||
// }
|
||||
// public void Test_write(String expd) {
|
||||
// mgr.Write(bfr, fxt.App(), wiki, fxt.Page());
|
||||
// Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
// }
|
||||
}
|
||||
65
400_xowa/src/gplx/xowa/htmls/heads/Xow_fragment_mgr.java
Normal file
65
400_xowa/src/gplx/xowa/htmls/heads/Xow_fragment_mgr.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.numbers.*;
|
||||
public class Xow_fragment_mgr implements GfoInvkAble {
|
||||
public Xow_fragment_mgr(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
|
||||
public byte[] Html_js_edit_toolbar() {return html_js_edit_toolbar;} private byte[] html_js_edit_toolbar;
|
||||
private Bry_fmtr html_js_edit_toolbar_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl
|
||||
( " var xowa_edit_i18n = {"
|
||||
, " 'bold_tip' : '~{bold_tip}',"
|
||||
, " 'bold_sample' : '~{bold_sample}',"
|
||||
, " 'italic_tip' : '~{italic_tip}',"
|
||||
, " 'italic_sample' : '~{italic_sample}',"
|
||||
, " 'link_tip' : '~{link_tip}',"
|
||||
, " 'link_sample' : '~{link_sample}',"
|
||||
, " 'headline_tip' : '~{headline_tip}',"
|
||||
, " 'headline_sample' : '~{headline_sample}',"
|
||||
, " 'ulist_tip' : '~{ulist_tip}',"
|
||||
, " 'ulist_sample' : '~{ulist_sample}',"
|
||||
, " 'olist_tip' : '~{olist_tip}',"
|
||||
, " 'olist_sample' : '~{olist_sample}'"
|
||||
, " };"
|
||||
), "bold_tip", "bold_sample", "italic_tip", "italic_sample", "link_tip", "link_sample", "headline_tip", "headline_sample", "ulist_tip", "ulist_sample", "olist_tip", "olist_sample");
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_html_js_edit_toolbar_fmt_)) html_js_edit_toolbar_fmtr.Fmt_(m.ReadBry("v"));
|
||||
else if (ctx.Match(k, Invk_html_js_edit_toolbar)) return html_js_edit_toolbar;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String Invk_html_js_edit_toolbar_fmt_ = "html_js_edit_toolbar_fmt_", Invk_html_js_edit_toolbar = "html_js_edit_toolbar";
|
||||
public void Evt_lang_changed(Xol_lang_itm lang) {
|
||||
Bry_bfr bfr = Xoa_app_.Utl__bfr_mkr().Get_b512();
|
||||
Xow_msg_mgr msg_mgr = wiki.Appe().Usere().Msg_mgr();
|
||||
html_js_edit_toolbar = html_js_edit_toolbar_fmtr.Bld_bry_many(bfr
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_bold_tip)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_bold_sample)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_italic_tip)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_italic_sample)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_link_tip)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_link_sample)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_headline_tip)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_headline_sample)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_ulist_tip)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_ulist_sample)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_olist_tip)
|
||||
, msg_mgr.Val_by_id(Xol_msg_itm_.Id_edit_toolbar_olist_sample)
|
||||
);
|
||||
bfr.Mkr_rls();
|
||||
}
|
||||
}
|
||||
57
400_xowa/src/gplx/xowa/htmls/heads/Xow_fragment_mgr_tst.java
Normal file
57
400_xowa/src/gplx/xowa/htmls/heads/Xow_fragment_mgr_tst.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.htmls.heads; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.numbers.*;
|
||||
public class Xow_fragment_mgr_tst {
|
||||
Xow_fragment_mgr_fxt fxt = new Xow_fragment_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Html_js_edit_toolbar_fmt() {
|
||||
fxt.Test_fragment(Xow_fragment_mgr.Invk_html_js_edit_toolbar, String_.Concat_lines_nl
|
||||
( " var xowa_edit_i18n = {"
|
||||
, " 'bold_tip' : 'Bold text',"
|
||||
, " 'bold_sample' : 'Bold text',"
|
||||
, " 'italic_tip' : 'Italic text',"
|
||||
, " 'italic_sample' : 'Italic text',"
|
||||
, " 'link_tip' : 'Internal link',"
|
||||
, " 'link_sample' : 'Link title',"
|
||||
, " 'headline_tip' : 'Level 2 headline',"
|
||||
, " 'headline_sample' : 'Headline text',"
|
||||
, " 'ulist_tip' : 'Bulleted list',"
|
||||
, " 'ulist_sample' : 'Bulleted list item',"
|
||||
, " 'olist_tip' : 'Numbered list',"
|
||||
, " 'olist_sample' : 'Numbered list item'"
|
||||
, " };"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xow_fragment_mgr_fxt {
|
||||
public void Clear() {
|
||||
if (wiki == null) {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
}
|
||||
} private Xowe_wiki wiki;
|
||||
public Xol_lang_itm Make_lang(String key) {return wiki.Appe().Lang_mgr().Get_by_or_new(Bry_.new_a7(key));}
|
||||
public void Test_fragment(String key, String expd) {Test_fragment(wiki.Lang(), key, expd);}
|
||||
public void Test_fragment(Xol_lang_itm lang, String key, String expd) {
|
||||
wiki.Fragment_mgr().Evt_lang_changed(lang);
|
||||
byte[] actl = (byte[])GfoInvkAble_.InvkCmd(wiki.Fragment_mgr(), key);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user