mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v3.1.5.1
This commit is contained in:
@@ -81,7 +81,7 @@ public class Xoh_page_wtr_mgr implements GfoInvkAble {
|
||||
public static final String Invk_page_read_ = "page_read_", Invk_page_edit_ = "page_edit_", Invk_page_html_ = "page_html_", Invk_xowa_div_edit_rename_ = "xowa_div_edit_rename_";
|
||||
private static final String[] Fmtr_keys = new String[]
|
||||
{ "app_root_dir", "app_version", "app_build_date", "xowa_mode_is_server"
|
||||
, "page_id", "page_name", "page_title", "page_modified_on_msg"
|
||||
, "page_id", "page_name", "page_title", "page_modified_on_msg", "page_heading"
|
||||
, "html_css_common_path", "html_css_wiki_path", "xowa_head"
|
||||
, "page_lang_ltr", "page_indicators", "page_content_sub", "page_jumpto", "page_pgbnr", "page_body_cls", "html_content_editable"
|
||||
, "page_data", "page_langs"
|
||||
|
||||
@@ -44,15 +44,18 @@ public class Xoh_page_wtr_wkr {
|
||||
break;
|
||||
}
|
||||
Bry_bfr page_bfr = Xoa_app_.Utl__bfr_mkr().Get_m001(); // NOTE: get separate page bfr to output page; do not reuse tmp_bfr b/c it will be used inside Fmt_do
|
||||
Xoh_wtr_ctx hctx = null;
|
||||
if (page_mode == Xopg_page_.Tid_html && wiki.App().Api_root().Html().Page().View_html_generates_hdump()) {
|
||||
Write_body(page_bfr, Xoh_wtr_ctx.Hdump, page);
|
||||
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(page_bfr.To_bry_and_clear()));
|
||||
hctx = Xoh_wtr_ctx.Hdump;
|
||||
Write_body(page_bfr, hctx, page);
|
||||
Write_page_by_tid(hctx, page_mode, bfr, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(page_bfr.To_bry_and_clear()));
|
||||
}
|
||||
else {
|
||||
Write_body(page_bfr, Xoh_wtr_ctx.Basic, page);
|
||||
Write_page_by_tid(view_mode, bfr, fmtr, page_bfr.To_bry_and_rls());
|
||||
hctx = Xoh_wtr_ctx.Basic;
|
||||
Write_body(page_bfr, hctx, page);
|
||||
Write_page_by_tid(hctx, view_mode, bfr, fmtr, page_bfr.To_bry_and_rls());
|
||||
if (page_mode == Xopg_page_.Tid_html) // if html, write page again, but wrap it in html skin this time
|
||||
Write_page_by_tid(page_mode, bfr, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(bfr.To_bry_and_clear()));
|
||||
Write_page_by_tid(hctx, page_mode, bfr, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(bfr.To_bry_and_clear()));
|
||||
wdata_lang_wtr.Page_(null);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +65,7 @@ public class Xoh_page_wtr_wkr {
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
private void Write_page_by_tid(byte html_gen_tid, Bry_bfr bfr, Bry_fmtr fmtr, byte[] page_data) {
|
||||
private void Write_page_by_tid(Xoh_wtr_ctx hctx, byte html_gen_tid, Bry_bfr bfr, Bry_fmtr fmtr, byte[] page_data) {
|
||||
// if custom_html, use it and exit; needed for Default_tab
|
||||
byte[] custom_html = page.Html_data().Custom_html();
|
||||
if (custom_html != null) {bfr.Add(custom_html); return;}
|
||||
@@ -92,9 +95,9 @@ public class Xoh_page_wtr_wkr {
|
||||
, root_dir_bry, Xoa_app_.Version, Xoa_app_.Build_date, app.Tcp_server().Running_str()
|
||||
, page.Revision_data().Id()
|
||||
, page_name, page_display
|
||||
, modified_on_msg
|
||||
, modified_on_msg, page.Html_data().Page_heading().Init(page)
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Head_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(ctx, page), page_body_class, html_content_editable
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(ctx, page, hctx, page_data), page_body_class, html_content_editable
|
||||
, page_data, wdata_lang_wtr
|
||||
, portal_mgr.Div_personal_bry(), portal_mgr.Div_ns_bry(app.Utl__bfr_mkr(), page_ttl, wiki.Ns_mgr()), portal_mgr.Div_view_bry(app.Utl__bfr_mkr(), html_gen_tid, page.Html_data().Xtn_search_text())
|
||||
, portal_mgr.Div_logo_bry(), portal_mgr.Div_home_bry(), new Xopg_xtn_skin_fmtr_arg(page, Xopg_xtn_skin_itm_tid.Tid_sidebar), portal_mgr.Div_wikis_bry(app.Utl__bfr_mkr()), portal_mgr.Sidebar_mgr().Html_bry()
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Xow_html_mgr implements GfoInvkAble {
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xoh_html_wtr Html_wtr() {return html_wtr;} private Xoh_html_wtr html_wtr;
|
||||
public Xoh_page_wtr_mgr Page_wtr_mgr() {return page_wtr_mgr;} private Xoh_page_wtr_mgr page_wtr_mgr;
|
||||
public Xoh_page_wtr_mgr Page_wtr_mgr() {return page_wtr_mgr;} private Xoh_page_wtr_mgr page_wtr_mgr;
|
||||
public Xow_portal_mgr Portal_mgr() {return portal_mgr;} private Xow_portal_mgr portal_mgr;
|
||||
public Xow_toc_mgr Toc_mgr() {return toc_mgr;} private Xow_toc_mgr toc_mgr = new Xow_toc_mgr();
|
||||
public Xow_module_mgr Head_mgr() {return module_mgr;} private Xow_module_mgr module_mgr;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class Xoh_html_wtr {
|
||||
case Xop_tkn_itm_.Tid_html_ref: Html_ref(ctx, hctx, bfr, src, (Xop_amp_tkn_txt)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_hr: Hr(ctx, hctx, bfr, src, (Xop_hr_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_apos: Apos(ctx, hctx, bfr, src, (Xop_apos_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_lnki: lnki_wtr.Write(bfr, hctx, src, (Xop_lnki_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_lnki: lnki_wtr.Write_lnki(bfr, hctx, src, (Xop_lnki_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_list: List(ctx, hctx, bfr, src, (Xop_list_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_xnde: Xnde(ctx, hctx, bfr, src, (Xop_xnde_tkn)tkn); break;
|
||||
case Xop_tkn_itm_.Tid_under: Under(ctx, hctx, bfr, src, (Xop_under_tkn)tkn); break;
|
||||
@@ -223,7 +223,7 @@ public class Xoh_html_wtr {
|
||||
if (hctx.Mode_is_alt()) return;
|
||||
switch (under.Under_tid()) {
|
||||
case Xol_kwd_grp_.Id_toc:
|
||||
wiki.Html_mgr().Toc_mgr().Html(page, hctx, src, bfr);
|
||||
wiki.Html_mgr().Toc_mgr().Html(page, hctx, src, bfr, true);
|
||||
break;
|
||||
case Xol_kwd_grp_.Id_notoc: case Xol_kwd_grp_.Id_forcetoc: // NOTE: skip output; changes flag on page only
|
||||
break;
|
||||
|
||||
@@ -22,6 +22,7 @@ import gplx.xowa.files.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.files.c
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.metas.*;
|
||||
public class Xoh_hdoc_ctx {
|
||||
private byte[] fsys__file;
|
||||
public byte[] Fsys__res() {return fsys__res;} private byte[] fsys__res;
|
||||
public byte[] Fsys__root() {return fsys__root;} private byte[] fsys__root;
|
||||
public byte[] Fsys__file__comm() {return fsys__file__comm;} private byte[] fsys__file__comm;
|
||||
public byte[] Fsys__file__wiki() {return fsys__file__wiki;} private byte[] fsys__file__wiki;
|
||||
@@ -48,8 +49,9 @@ public class Xoh_hdoc_ctx {
|
||||
this.fsys__root = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.fsys__file = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.fsys__file__comm = Bry_.Add(fsys__file, Xow_domain_itm_.Bry__commons, Byte_ascii.Slash_bry);
|
||||
// Xou_cache_mgr cache_mgr = app.User().User_db_mgr().Cache_mgr();
|
||||
// if (cache_mgr != null) file__mgr = Xou_cache_finder_.New_db(cache_mgr); // NOTE: this effectively only loads the cache db in app mode (and not in test mode)
|
||||
this.fsys__res = gplx.core.envs.Op_sys.Cur().Tid_is_drd() ? Fsys__res__drd : fsys__root;
|
||||
Xou_cache_mgr cache_mgr = app.User().User_db_mgr().Cache_mgr();
|
||||
if (cache_mgr != null) file__mgr = Xou_cache_finder_.New_db(cache_mgr); // NOTE: this effectively only loads the cache db in app mode (and not in test mode)
|
||||
pool_mgr__hzip.Init();
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki, byte[] page_url) {
|
||||
@@ -67,4 +69,5 @@ public class Xoh_hdoc_ctx {
|
||||
this.uid__gly = -1;
|
||||
}
|
||||
public static final int Invalid = -1;
|
||||
private static final byte[] Fsys__res__drd = Bry_.new_a7("file:///android_asset/xowa/");
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class Xoh_hzip_fxt {
|
||||
private final Xoh_page hpg = new Xoh_page();
|
||||
private boolean mode_is_b256;
|
||||
public Xoh_hzip_fxt() {
|
||||
gplx.core.envs.Op_sys.Cur_is_drd_(); // force drd mode; needed for img_bare
|
||||
this.wiki = parser_fxt.Wiki();
|
||||
Xoa_app_fxt.repo2_(parser_fxt.App(), wiki); // needed else will be old "mem/wiki/repo/trg/thumb/" instead of standard "mem/file/en.wikipedia.org/thumb/"
|
||||
wiki.Html__hdump_mgr().Init_by_db(parser_fxt.Wiki());
|
||||
|
||||
@@ -22,7 +22,7 @@ import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_hdr_html {
|
||||
public void Write_html(Bry_bfr bfr, Xoh_html_wtr wtr, Xowe_wiki wiki, Xoae_page page, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoh_html_wtr_cfg cfg, Xop_tkn_grp grp, int sub_idx, byte[] src, Xop_hdr_tkn hdr) {
|
||||
if (hdr.Hdr_html_first() && cfg.Toc__show() && !page.Hdr_mgr().Toc_manual()) // __TOC__ not specified; place at top; NOTE: if __TOC__ was specified, then it would be placed wherever __TOC__ appears
|
||||
wiki.Html_mgr().Toc_mgr().Html(ctx.Page(), hctx, src, bfr);
|
||||
wiki.Html_mgr().Toc_mgr().Html(ctx.Page(), hctx, src, bfr, true);
|
||||
|
||||
int hdr_len = hdr.Hdr_level();
|
||||
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Xoh_img_bare_data implements Xoh_data_itm {
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag img_head, Gfh_tag unused) {
|
||||
this.src_bgn = img_head.Src_bgn(); this.src_end = img_head.Src_end();
|
||||
Gfh_atr img_src_atr = img_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__src); if (img_src_atr.Val_dat_missing()) return false;
|
||||
byte[] root_dir_bry = hctx.Fsys__root();
|
||||
byte[] root_dir_bry = hctx.Fsys__res(); // NOTE: Fsys_res == Fsys_root on all machines except drd;
|
||||
int root_dir_bgn = img_src_atr.Val_bgn();
|
||||
int root_dir_end = root_dir_bgn + root_dir_bry.length;
|
||||
if (Bry_.Match(src, root_dir_bgn, root_dir_end, root_dir_bry)) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoh_img_bare_hzip__tst {
|
||||
@Test public void Hiero() {
|
||||
fxt.Test__bicode
|
||||
( "~(!<img style=\"margin: 1px; height: 11px;\" src=\"~X1.png\" title=\"X1 [t]\" alt=\"t\">~"
|
||||
, "<img style='margin: 1px; height: 11px;' src='file:///mem/xowa/bin/any/xowa/xtns/Wikihiero/img/hiero_X1.png' title='X1 [t]' alt='t'>"
|
||||
, "<img style='margin: 1px; height: 11px;' src='file:///android_asset/xowa/bin/any/xowa/xtns/Wikihiero/img/hiero_X1.png' title='X1 [t]' alt='t'>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xoh_img_bare_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
switch (data_itm.Img_tid()) {
|
||||
case Xoh_img_bare_data.Img_tid__hiero:
|
||||
bfr.Add_mid(src, data_itm.Src_bgn(), data_itm.Dir_bgn());
|
||||
bfr.Add(hctx.Fsys__root()).Add(Xoh_img_bare_data.Url__hiero);
|
||||
bfr.Add(hctx.Fsys__res()).Add(Xoh_img_bare_data.Url__hiero); // NOTE: must use Fsys_res will be android_asset on drd; en.w:Hieroglyphics DATE:2016-01-31
|
||||
bfr.Add_mid(src, data_itm.Dir_end(), data_itm.Src_end());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,21 +26,21 @@ public class Xoh_img_data implements Xoh_data_itm {
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public Xoh_anch_href_data Anch_href() {return anch_href;} private Xoh_anch_href_data anch_href = new Xoh_anch_href_data();
|
||||
public Xoh_anch_cls_data Anch_cls() {return anch_cls;} private Xoh_anch_cls_data anch_cls = new Xoh_anch_cls_data();
|
||||
public boolean Anch_rel_nofollow_exists() {return anch_rel_is_nofollow;} private boolean anch_rel_is_nofollow;
|
||||
public boolean Anch_rel_nofollow_exists() {return anch_rel_is_nofollow;} private boolean anch_rel_is_nofollow;
|
||||
public int Anch_title_bgn() {return anch_title_bgn;} private int anch_title_bgn;
|
||||
public int Anch_title_end() {return anch_title_end;} private int anch_title_end;
|
||||
public boolean Anch_title_exists() {return anch_title_end != -1;}
|
||||
public boolean Anch_title_exists() {return anch_title_end != -1;}
|
||||
public Bry_obj_ref Anch_page() {return anch_page;} private Bry_obj_ref anch_page = Bry_obj_ref.New_empty();
|
||||
public Xoh_img_src_data Img_src() {return img_src;} private final Xoh_img_src_data img_src = new Xoh_img_src_data();
|
||||
public Xoh_img_cls_data Img_cls() {return img_cls;} private final Xoh_img_cls_data img_cls = new Xoh_img_cls_data();
|
||||
public Xoh_img_xoimg_data Img_xoimg() {return img_xoimg;} private Xoh_img_xoimg_data img_xoimg = new Xoh_img_xoimg_data();
|
||||
public int Img_alt_bgn() {return img_alt_bgn;} private int img_alt_bgn;
|
||||
public int Img_alt_end() {return img_alt_end;} private int img_alt_end;
|
||||
public boolean Img_alt__diff__anch_title() {return img_alt__diff_anch_title;} private boolean img_alt__diff_anch_title;
|
||||
public boolean Img_alt__diff__anch_title() {return img_alt__diff_anch_title;} private boolean img_alt__diff_anch_title;
|
||||
public int Img_w() {return img_w;} private int img_w;
|
||||
public int Img_h() {return img_h;} private int img_h;
|
||||
public boolean Img_w__diff__file_w() {return img_w != img_src.File_w();}
|
||||
public boolean Img_is_vid() {return img_is_vid;} private boolean img_is_vid;
|
||||
public boolean Img_w__diff__file_w() {return img_w != img_src.File_w();}
|
||||
public boolean Img_is_vid() {return img_is_vid;} private boolean img_is_vid;
|
||||
public boolean Img_wo_anch() {return img_wo_anch;} private boolean img_wo_anch;
|
||||
public int Img_imap_idx() {return img_imap_idx;} private int img_imap_idx;
|
||||
public void Clear() {
|
||||
|
||||
@@ -58,6 +58,7 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
Init_by_decode(hpg, hctx, src, data);
|
||||
this.Bfr_arg__add(bfr);
|
||||
}
|
||||
private static final byte[] Bry__qarg__esc = Bry_.new_a7("%3F");
|
||||
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
|
||||
Xoh_img_data data = (Xoh_img_data)data_itm;
|
||||
this.Clear();
|
||||
@@ -73,7 +74,9 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
this.img_xowa_image.Set_by_arg(img_xowa_image.Clone()); // NOTE: must clone b/c img_xowa_image is member of Xoh_img_data which is poolable (and cleared); PAGE:en.w:Almagest; DATE:2016-01-05
|
||||
img_w.Set_by_int(fsdb_itm.Html_w());
|
||||
img_h.Set_by_int(fsdb_itm.Html_h());
|
||||
this.img_src.Set_by_bry(fsdb_itm.Html_view_url().To_http_file_bry());
|
||||
byte[] src_bry = fsdb_itm.Html_view_url().To_http_file_bry();
|
||||
if (gplx.core.envs.Op_sys.Cur().Tid_is_drd()) src_bry = Bry_.Replace(src_bry, Byte_ascii.Question_bry, Bry__qarg__esc); // NOTE: if drd, always escape "?" as "%3F" PAGE:en.w:Cleopatra en.w:Cave_painting; DATE:2016-01-31
|
||||
this.img_src.Set_by_bry(src_bry);
|
||||
}
|
||||
else if (data.Img_w() != -1) {
|
||||
img_w.Set_by_int(data.Img_w());
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Xoh_lnki_wtr {
|
||||
this.history_mgr = app.Usere().History_mgr();
|
||||
if (hctx.Mode_is_hdump()) cfg.Lnki__id_(false);
|
||||
}
|
||||
public void Write(Bry_bfr bfr, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
public void Write_lnki(Bry_bfr bfr, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
Xoa_ttl lnki_ttl = lnki.Ttl();
|
||||
if (lnki_ttl == null) {// NOTE: parser failed to properly invalidate lnki; escape tkn now and warn; DATE:2014-06-06
|
||||
app.Usr_dlg().Warn_many("", "", "invalid lnki evaded parser; page=~{0} ex=~{1}", ctx.Page().Url().To_str(), String_.new_u8(src, lnki.Src_bgn(), lnki.Src_end()));
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Xoh_head_itm_ {
|
||||
, Key__mathjax = Bry_.new_a7("mathjax")
|
||||
, Key__navframe = Bry_.new_a7("navframe")
|
||||
, Key__popups = Bry_.new_a7("popups")
|
||||
, Key__pgbnr = Bry_.new_a7("pgbnr")
|
||||
, Key__search_suggest = Bry_.new_a7("xowa.search_suggest")
|
||||
, Key__timeline = Bry_.new_a7("xowa.timeline")
|
||||
, Key__title_rewrite = Bry_.new_a7("title_rewrite")
|
||||
|
||||
37
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__pgbnr.java
Normal file
37
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__pgbnr.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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__pgbnr extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__pgbnr;}
|
||||
@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__styles == null) {
|
||||
Url__css__oojs_ui = app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "res", "lib", "oojs-ui", "oojs-ui-mediawiki.css").To_http_file_bry(); // needed for icons; should move to own file
|
||||
Io_url resources_dir = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("xowa", "xtns", "WikidataPageBanner", "resources");
|
||||
Url__css__styles = resources_dir.GenSubFil_nest("ext.WikidataPageBanner.styles" , "ext.WikidataPageBanner.css").To_http_file_bry();
|
||||
Url__css__toc = resources_dir.GenSubFil_nest("ext.WikidataPageBanner.toc.styles" , "ext.WikidataPageBanner.toc.css").To_http_file_bry();
|
||||
Url__css__bottomtoc = resources_dir.GenSubFil_nest("ext.WikidataPageBanner.toc.styles" , "ext.WikidataPageBanner.bottomtoc.css").To_http_file_bry();
|
||||
}
|
||||
wtr.Write_css_include(Url__css__oojs_ui);
|
||||
wtr.Write_css_include(Url__css__styles);
|
||||
wtr.Write_css_include(Url__css__toc);
|
||||
wtr.Write_css_include(Url__css__bottomtoc);
|
||||
}
|
||||
private static byte[] Url__css__styles, Url__css__toc, Url__css__bottomtoc, Url__css__oojs_ui;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
||||
public Xoh_head_mgr() {
|
||||
Itms_add(itm__css, itm__globals, itm__server, itm__popups, itm__toc, itm__collapsible, itm__navframe, itm__gallery, itm__gallery_styles
|
||||
, itm__mathjax, itm__graph, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline
|
||||
, itm__dbui
|
||||
, itm__dbui, itm__pgbnr
|
||||
);
|
||||
}
|
||||
public Xoh_head_itm__css Itm__css() {return itm__css;} private final Xoh_head_itm__css itm__css = new Xoh_head_itm__css();
|
||||
@@ -53,6 +53,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
||||
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_itm__pgbnr Itm__pgbnr() {return itm__pgbnr;} private final Xoh_head_itm__pgbnr itm__pgbnr = new Xoh_head_itm__pgbnr();
|
||||
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;
|
||||
|
||||
@@ -190,28 +190,29 @@ public class Xow_toc_mgr implements gplx.core.brys.Bfr_arg {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Html(Xoae_page page, Xoh_wtr_ctx hctx, byte[] src, Bry_bfr bfr) {
|
||||
public void Html(Xoae_page page, Xoh_wtr_ctx hctx, byte[] src, Bry_bfr bfr, boolean write_toc_cls) {
|
||||
if (!page.Hdr_mgr().Toc_enabled()) return; // REF.MW: Parser.php|formatHeadings
|
||||
if (hctx.Mode_is_hdump()) return;
|
||||
this.page = page;
|
||||
byte[] bry_contents = page.Wikie().Msg_mgr().Val_by_id(Xol_msg_itm_.Id_toc);
|
||||
bfmtr_main.Bld_bfr_many(bfr, Bfr_arg_.New_bry(bry_contents), this);
|
||||
bfmtr_main.Bld_bfr_many(bfr, write_toc_cls ? Bry_toc_cls : Bry_.Empty, Bfr_arg_.New_bry(bry_contents), this);
|
||||
}
|
||||
private static final byte[]
|
||||
Bry_list_bgn = Bry_.new_a7(" <ul>\n")
|
||||
, Bry_list_end = Bry_.new_a7(" </ul>\n")
|
||||
, Bry_item_end = Bry_.new_a7(" </li>\n")
|
||||
, Bry_toc_cls = Bry_.new_a7(" id=\"toc\" class=\"toc\"")
|
||||
;
|
||||
private Bry_fmtr
|
||||
bfmtr_main = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"toc\" class=\"toc\">"
|
||||
( "<div~{toc}>"
|
||||
, " <div id=\"toctitle\">"
|
||||
, " <h2>~{contents_title}</h2>"
|
||||
, " </div>"
|
||||
, "~{toc_list}</div>"
|
||||
, ""
|
||||
)
|
||||
, "contents_title", "toc_list"
|
||||
, "toc", "contents_title", "toc_list"
|
||||
)
|
||||
, bfmtr_line = Bry_fmtr.new_
|
||||
( " <li class=\"toclevel-~{level} tocsection-~{toc_idx}\"><a href=\"#~{anchor}\"><span class=\"tocnumber\">~{heading}</span> <span class=\"toctext\">~{text}</span></a>\n"
|
||||
|
||||
@@ -514,7 +514,7 @@ class Xow_toc_mgr_fxt {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Xop_root_tkn root = fxt.Ctx().Tkn_mkr().Root(raw_bry);
|
||||
fxt.Parser().Parse_page_all_clear(root, fxt.Ctx(), fxt.Ctx().Tkn_mkr(), raw_bry);
|
||||
toc_mgr.Html(fxt.Page(), Xoh_wtr_ctx.Basic, raw_bry, tmp);
|
||||
toc_mgr.Html(fxt.Page(), Xoh_wtr_ctx.Basic, raw_bry, tmp, true);
|
||||
Tfds.Eq_ary(String_.SplitLines_nl(expd), String_.SplitLines_nl(tmp.To_str_and_clear()), raw);
|
||||
}
|
||||
public void Test_html_all(String raw, String expd) {
|
||||
|
||||
Reference in New Issue
Block a user