mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.3.1'
This commit is contained in:
@@ -19,13 +19,13 @@ package gplx.xowa.htmls.portal; import gplx.*; import gplx.xowa.*; import gplx.x
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.files.xfers.*;
|
||||
public class Xoa_available_wikis_mgr implements GfoInvkAble {
|
||||
public class Xoa_available_wikis_mgr implements Gfo_invk {
|
||||
private Bry_fmtr itms_as_html_fmtr = Bry_fmtr.new_("\n <li><a href=\"/site/~{domain}/\"~{itm_cls}>~{domain}</a></li>", "domain", "itm_cls");
|
||||
public Xoa_available_wikis_mgr(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
public String Itms_as_html() {
|
||||
if (itms_as_html == null) {
|
||||
String itm_cls = app.Api_root().Html().Modules().Popups().Enabled() ? " class='xowa-hover-off'" : "";
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_(); // NOTE: do not use app.Utl__bfr_mkr().Get_k004() as it is being used simultaneously by another caller; TODO: find call
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.New(); // NOTE: do not use app.Utl__bfr_mkr().Get_k004() as it is being used simultaneously by another caller; TODO_OLD: find call
|
||||
Xow_xwiki_mgr xwiki_mgr = app.Usere().Wiki().Xwiki_mgr();
|
||||
xwiki_mgr.Sort_by_key();
|
||||
int len = xwiki_mgr.Len();
|
||||
@@ -48,7 +48,7 @@ public class Xoa_available_wikis_mgr implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_visible_)) visible = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_visible_toggle)) {visible = !visible; app.Gui_mgr().Browser_win().Active_html_box().Html_js_eval_proc_as_str("xowa-portal-wikis-visible-toggle", Bool_.To_str_lower(visible));}
|
||||
else if (ctx.Match(k, Invk_itms_as_html_fmtr_)) itms_as_html_fmtr.Fmt_(m.ReadBry("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_visible = "visible", Invk_visible_ = "visible_", Invk_visible_toggle = "visible_toggle", Invk_itms_as_html = "itms_as_html", Invk_itms_as_html_fmtr_ = "itms_as_html_fmtr_", Invk_itms_refresh = "itms_refresh";
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ 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.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
public class Xoa_portal_mgr implements GfoInvkAble {
|
||||
public class Xoa_portal_mgr implements Gfo_invk {
|
||||
public Xoa_portal_mgr(Xoae_app app) {wikis = new Xoa_available_wikis_mgr(app);}
|
||||
public Xoa_available_wikis_mgr Wikis() {return wikis;} private Xoa_available_wikis_mgr wikis;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_wikis)) return wikis;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
} private static final String Invk_wikis = "wikis";
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Xoh_page_body_cls { // REF.MW:Skin.php|getPageClasses
|
||||
break;
|
||||
case Byte_ascii.Underline:
|
||||
if (trg_bfr == null) {
|
||||
trg_bfr = Bry_bfr.new_(src_len);
|
||||
trg_bfr = Bry_bfr_.New_w_size(src_len);
|
||||
trg_bfr.Add_mid(src, 0, i);
|
||||
}
|
||||
if (bgn != -1) {
|
||||
@@ -99,7 +99,7 @@ public class Xoh_page_body_cls { // REF.MW:Skin.php|getPageClasses
|
||||
int next = i + 1;
|
||||
if (next < src_len && src[next] == -96) {
|
||||
if (trg_bfr == null) {
|
||||
trg_bfr = Bry_bfr.new_(src_len);
|
||||
trg_bfr = Bry_bfr_.New_w_size(src_len);
|
||||
trg_bfr.Add_mid(src, 0, i);
|
||||
}
|
||||
trg_bfr.Add_byte(Byte_ascii.Underline);
|
||||
@@ -118,7 +118,7 @@ public class Xoh_page_body_cls { // REF.MW:Skin.php|getPageClasses
|
||||
if (bgn != -1) trg_bfr.Add_mid(src, bgn, src_len);
|
||||
return trg_bfr == null ? src : trg_bfr.To_bry_and_clear();
|
||||
}
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Bry_id_prefix = Bry_.new_a7("ns-")
|
||||
, Bry_type_special = Bry_.new_a7("ns-special")
|
||||
, Bry_type_talk = Bry_.new_a7("ns-talk")
|
||||
|
||||
@@ -45,7 +45,7 @@ class Xoh_page_body_cls_fxt {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
tmp_bfr = Bry_bfr.reset_(255);
|
||||
tmp_bfr = Bry_bfr_.Reset(255);
|
||||
wiki.Ns_mgr().Add_new(Wdata_wiki_mgr.Ns_property, Wdata_wiki_mgr.Ns_property_name);
|
||||
}
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str));
|
||||
|
||||
@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
public class Xoh_rtl_utl {
|
||||
private static final int[] tmp_ary = new int[32]; // support no more than 16 items
|
||||
private static Bry_bfr bfr = Bry_bfr.reset_(32);
|
||||
private static final int[] tmp_ary = new int[32]; // support no more than 16 items
|
||||
private static Bry_bfr bfr = Bry_bfr_.Reset(32);
|
||||
public static byte[] Reverse_li(byte[] src) {
|
||||
int src_len = src.length;
|
||||
int pos = 0;
|
||||
@@ -64,7 +64,7 @@ public class Xoh_rtl_utl {
|
||||
}
|
||||
bfr.Add_mid(src, li_n_end, ul_end); // add from nth "</li>" -> "</ul>"
|
||||
}
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Ul_bgn = Bry_.new_a7("<ul")
|
||||
, Ul_end = Bry_.new_a7("</ul>")
|
||||
, Li_bgn = Bry_.new_a7("<li")
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xoh_subpages_bldr implements gplx.core.brys.Bfr_arg {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255), ttl_bfr = Bry_bfr.reset_(255);
|
||||
private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255), ttl_bfr = Bry_bfr_.Reset(255);
|
||||
private byte[][] segs;
|
||||
public byte[] Bld(Xow_ns_mgr ns_mgr, Xoa_ttl ttl) {
|
||||
Xow_ns ns = ttl.Ns();
|
||||
@@ -53,8 +53,8 @@ public class Xoh_subpages_bldr implements gplx.core.brys.Bfr_arg {
|
||||
}
|
||||
ttl_bfr.Clear();
|
||||
}
|
||||
private static final byte[] Dlm_1st = Bry_.new_a7("< "), Dlm_nth = Bry_.new_a7("‎ | ");
|
||||
private static final Bry_fmtr
|
||||
private static final byte[] Dlm_1st = Bry_.new_a7("< "), Dlm_nth = Bry_.new_a7("‎ | ");
|
||||
private static final Bry_fmtr
|
||||
fmtr_grp = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<span class=\"subpages\">~{itms}"
|
||||
, "</span>"
|
||||
|
||||
@@ -24,9 +24,9 @@ import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.*; import gplx.xowa.apps.apis.xowa.html.skins.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.htmls.portal.vnts.*;
|
||||
public class Xow_portal_mgr implements GfoInvkAble {
|
||||
public class Xow_portal_mgr implements Gfo_invk {
|
||||
private Xowe_wiki wiki; private boolean lang_is_rtl; private Xoapi_toggle_itm toggle_itm;
|
||||
private final Vnt_mnu_grp_fmtr vnt_menu_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
private final Vnt_mnu_grp_fmtr vnt_menu_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
public Xow_portal_mgr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.sidebar_mgr = new Xowh_sidebar_mgr(wiki);
|
||||
@@ -102,7 +102,7 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
}
|
||||
div_view_fmtr.Bld_bfr_many(tmp_bfr, read_cls, edit_cls, html_cls, search_text);
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
} public static final byte[] Cls_selected_y = Bry_.new_a7("selected"), Cls_new = Bry_.new_a7("new"), Cls_display_none = Bry_.new_a7("xowa_display_none");
|
||||
} public static final byte[] Cls_selected_y = Bry_.new_a7("selected"), Cls_new = Bry_.new_a7("new"), Cls_display_none = Bry_.new_a7("xowa_display_none");
|
||||
public byte[] Div_logo_bry() {return div_logo_bry;} private byte[] div_logo_bry = Bry_.Empty;
|
||||
public byte[] Div_home_bry() {return api_skin != null && api_skin.Sidebar_home_enabled() ? div_home_bry : Bry_.Empty;} private byte[] div_home_bry = Bry_.Empty;
|
||||
public byte[] Div_wikis_bry(Bry_bfr_mkr bfr_mkr) {
|
||||
@@ -113,11 +113,11 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
public byte[] Missing_ns_cls() {return missing_ns_cls;} public Xow_portal_mgr Missing_ns_cls_(byte[] v) {missing_ns_cls = v; return this;} private byte[] missing_ns_cls; // NOTE: must be null due to Init check above
|
||||
private final Bry_fmtr div_personal_fmtr = Bry_fmtr.new_("~{portal_personal_subj_href};~{portal_personal_subj_text};~{portal_personal_talk_cls};~{portal_personal_talk_href};~{portal_personal_talk_cls};", "portal_personal_subj_href", "portal_personal_subj_text", "portal_personal_subj_cls", "portal_personal_talk_href", "portal_personal_talk_cls");
|
||||
private final Bry_fmtr div_ns_fmtr = Bry_fmtr.new_("~{portal_ns_subj_href};~{portal_ns_subj_cls};~{portal_ns_talk_href};~{portal_ns_talk_cls};~{portal_div_vnts}", "portal_ns_subj_href", "portal_ns_subj_cls", "portal_ns_talk_href", "portal_ns_talk_cls", "portal_div_vnts");
|
||||
private final Bry_fmtr div_view_fmtr = Bry_fmtr.new_("", "portal_view_read_cls", "portal_view_edit_cls", "portal_view_html_cls", "search_text");
|
||||
private final Bry_fmtr div_logo_fmtr = Bry_fmtr.new_("", "portal_nav_main_href", "portal_logo_url");
|
||||
private final Bry_fmtr div_wikis_fmtr = Bry_fmtr.new_("", "toggle_btn", "toggle_hdr");
|
||||
private final Bry_fmtr div_personal_fmtr = Bry_fmtr.new_("~{portal_personal_subj_href};~{portal_personal_subj_text};~{portal_personal_talk_cls};~{portal_personal_talk_href};~{portal_personal_talk_cls};", "portal_personal_subj_href", "portal_personal_subj_text", "portal_personal_subj_cls", "portal_personal_talk_href", "portal_personal_talk_cls");
|
||||
private final Bry_fmtr div_ns_fmtr = Bry_fmtr.new_("~{portal_ns_subj_href};~{portal_ns_subj_cls};~{portal_ns_talk_href};~{portal_ns_talk_cls};~{portal_div_vnts}", "portal_ns_subj_href", "portal_ns_subj_cls", "portal_ns_talk_href", "portal_ns_talk_cls", "portal_div_vnts");
|
||||
private final Bry_fmtr div_view_fmtr = Bry_fmtr.new_("", "portal_view_read_cls", "portal_view_edit_cls", "portal_view_html_cls", "search_text");
|
||||
private final Bry_fmtr div_logo_fmtr = Bry_fmtr.new_("", "portal_nav_main_href", "portal_logo_url");
|
||||
private final Bry_fmtr div_wikis_fmtr = Bry_fmtr.new_("", "toggle_btn", "toggle_hdr");
|
||||
private byte[] Reverse_li(byte[] bry) {
|
||||
return lang_is_rtl ? Xoh_rtl_utl.Reverse_li(bry) : bry;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_missing_ns_cls)) return String_.new_u8(missing_ns_cls);
|
||||
else if (ctx.Match(k, Invk_missing_ns_cls_)) missing_ns_cls = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk_missing_ns_cls_list)) return Options_missing_ns_cls_list;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_div_personal_ = "div_personal_", Invk_div_view_ = "div_view_", Invk_div_ns_ = "div_ns_", Invk_div_home_ = "div_home_", Invk_div_wikis_ = "div_wikis_"
|
||||
@@ -139,8 +139,8 @@ public class Xow_portal_mgr implements GfoInvkAble {
|
||||
;
|
||||
public static final String Invk_div_logo_ = "div_logo_";
|
||||
private static Keyval[] Options_missing_ns_cls_list = Keyval_.Ary(Keyval_.new_("", "Show as blue link"), Keyval_.new_("new", "Show as red link"), Keyval_.new_("xowa_display_none", "Hide"));
|
||||
private static final byte[] Missing_ns_cls_hide = Bry_.new_a7("xowa_display_none");
|
||||
private static final Bry_fmtr Div_jump_to_fmtr = Bry_fmtr.new_
|
||||
private static final byte[] Missing_ns_cls_hide = Bry_.new_a7("xowa_display_none");
|
||||
private static final Bry_fmtr Div_jump_to_fmtr = Bry_fmtr.new_
|
||||
( "\n <div id=\"jump-to-nav\" class=\"mw-jump\">~{jumpto}<a href=\"#mw-navigation\">~{jumptonavigation}</a>~{comma-separator}<a href=\"#p-search\">~{jumptosearch}</a></div>"
|
||||
, "jumpto", "jumptonavigation", "comma-separator", "jumptosearch");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.portal.vnts; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.portal.*;
|
||||
import org.junit.*; import gplx.xowa.langs.vnts.*;
|
||||
public class Vnt_mnu_grp_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Vnt_mnu_grp_fmtr_fxt fxt = new Vnt_mnu_grp_fmtr_fxt();
|
||||
@Before public void init() {fxt.Clear();} private final Vnt_mnu_grp_fmtr_fxt fxt = new Vnt_mnu_grp_fmtr_fxt();
|
||||
@Test public void Basic() {
|
||||
// fxt.Test_to_str("Earth", "zh-hk", String_.Concat_lines_nl_skip_last
|
||||
// ( ""
|
||||
@@ -40,7 +40,7 @@ public class Vnt_mnu_grp_fmtr_tst {
|
||||
}
|
||||
}
|
||||
class Vnt_mnu_grp_fmtr_fxt {
|
||||
private final Xol_vnt_regy mgr = new Xol_vnt_regy();
|
||||
private final Xol_vnt_regy mgr = new Xol_vnt_regy();
|
||||
public void Clear() {
|
||||
this.Init_grp("Choose lang", "zh-hans", "Simplified", "zh-hant", "Traditional", "zh-cn", "China", "zh-hk", "Hong Kong", "zh-mo", "Macau", "zh-sg", "Singapore", "zh-tw", "Taiwan");
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class Vnt_mnu_grp_fmtr_fxt {
|
||||
}
|
||||
public void Test_to_str(String page_href, String selected_vnt, String expd) {
|
||||
Vnt_mnu_grp_fmtr vnt_grp_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
vnt_grp_fmtr.Init(mgr, Bry_.new_u8(page_href), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_u8(selected_vnt));
|
||||
vnt_grp_fmtr.Bfr_arg__add(bfr);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
|
||||
Reference in New Issue
Block a user