mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.2.1'
This commit is contained in:
@@ -32,15 +32,18 @@ public class Xoh_page implements Xoa_page {
|
||||
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
|
||||
public byte[] Content_sub() {return content_sub;} private byte[] content_sub;
|
||||
public byte[] Sidebar_div() {return sidebar_div;} private byte[] sidebar_div;
|
||||
public Xoh_section_mgr Section_mgr() {return section_mgr;} private final Xoh_section_mgr section_mgr = new Xoh_section_mgr();
|
||||
public Xoh_section_mgr Section_mgr() {return section_mgr;} private final Xoh_section_mgr section_mgr = new Xoh_section_mgr();
|
||||
public Xoh_img_mgr Img_mgr() {return img_mgr;} private Xoh_img_mgr img_mgr = new Xoh_img_mgr();
|
||||
public Ordered_hash Redlink_uids() {return redlink_uids;} private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
public Ordered_hash Redlink_uids() {return redlink_uids;} private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
public Xohd_img_itm__base[] Img_itms() {return img_itms;} public void Img_itms_(Xohd_img_itm__base[] v) {this.img_itms = v;} private Xohd_img_itm__base[] img_itms = Xohd_img_itm__base.Ary_empty;
|
||||
public Ordered_hash Gallery_itms() {return gallery_itms;} private Ordered_hash gallery_itms = Ordered_hash_.New();
|
||||
public Xopg_module_mgr Head_mgr() {return head_mgr;} private Xopg_module_mgr head_mgr = new Xopg_module_mgr();
|
||||
public void Xtn_gallery_packed_exists_y_() {}
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
|
||||
// util
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page;
|
||||
public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty; // drd:web_browser
|
||||
public byte[] Url_bry_safe() {return page_url == null ? Bry_.Empty : page_url.To_bry(Bool_.Y, Bool_.Y);}
|
||||
|
||||
@@ -147,8 +147,13 @@ public class Xoh_page_wtr_wkr {
|
||||
// get separate bfr; note that bfr already has <html> and <head> written to it, so this can't be passed to tidy; DATE:2014-06-11
|
||||
Bry_bfr tidy_bfr = app.Utl__bfr_mkr().Get_m001();
|
||||
// write wikitext
|
||||
if (page.Root() != null) // NOTE: will be null if blank; occurs for one test: Logo_has_correct_main_page; DATE:2015-09-29
|
||||
wiki.Html_mgr().Html_wtr().Write_all(tidy_bfr, page.Wikie().Parser_mgr().Ctx(), hctx, page.Root().Data_mid(), page.Root());
|
||||
if (page.Html_data().Skip_parse()) {
|
||||
tidy_bfr.Add(page.Html_data().Custom_body());
|
||||
}
|
||||
else {
|
||||
if (page.Root() != null) // NOTE: will be null if blank; occurs for one test: Logo_has_correct_main_page; DATE:2015-09-29
|
||||
wiki.Html_mgr().Html_wtr().Write_all(tidy_bfr, page.Wikie().Parser_mgr().Ctx(), hctx, page.Root().Data_mid(), page.Root());
|
||||
}
|
||||
|
||||
// if [[Category]], render rest of html (Subcategories; Pages; Files); note that a category may have other html which requires wikitext processing
|
||||
if (ns_id == Xow_ns_.Tid__category) wiki.Html_mgr().Ns_ctg().Bld_html(wiki, page, hctx, tidy_bfr);
|
||||
|
||||
@@ -17,18 +17,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Xoh_wtr_ctx {
|
||||
Xoh_wtr_ctx(int mode) {this.mode = mode;}
|
||||
public int Mode() {return mode;} private final int mode;
|
||||
Xoh_wtr_ctx(int mode, byte[] anch__href__bgn, byte[] anch__href__end) {
|
||||
this.mode = mode; this.anch__href__bgn = anch__href__bgn; this.anch__href__end = anch__href__end;
|
||||
}
|
||||
public int Mode() {return mode;} private final int mode;
|
||||
public boolean Mode_is_alt() {return mode == Mode_alt;}
|
||||
public boolean Mode_is_display_title() {return mode == Mode_display_title;}
|
||||
public boolean Mode_is_popup() {return mode == Mode_popup;}
|
||||
public boolean Mode_is_hdump() {return mode == Mode_hdump;}
|
||||
public static final int Mode_basic = 0, Mode_alt = 1, Mode_display_title = 2, Mode_popup = 3, Mode_hdump = 4;
|
||||
public static final Xoh_wtr_ctx
|
||||
Basic = new Xoh_wtr_ctx(Mode_basic)
|
||||
, Alt = new Xoh_wtr_ctx(Mode_alt)
|
||||
, Display_title = new Xoh_wtr_ctx(Mode_display_title)
|
||||
, Popup = new Xoh_wtr_ctx(Mode_popup)
|
||||
, Hdump = new Xoh_wtr_ctx(Mode_hdump)
|
||||
public byte[] Anch__href__bgn() {return anch__href__bgn;} private final byte[] anch__href__bgn;
|
||||
public byte[] Anch__href__end() {return anch__href__end;} private final byte[] anch__href__end;
|
||||
|
||||
public static final int Mode_basic = 0, Mode_alt = 1, Mode_display_title = 2, Mode_popup = 3, Mode_hdump = 4, Mode_file_dump = 5;
|
||||
|
||||
public static final Xoh_wtr_ctx
|
||||
Basic = new Xoh_wtr_ctx(Mode_basic , gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki, null)
|
||||
, Alt = new Xoh_wtr_ctx(Mode_alt , gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki, null)
|
||||
, Display_title = new Xoh_wtr_ctx(Mode_display_title , gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki, null)
|
||||
, Popup = new Xoh_wtr_ctx(Mode_popup , gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki, null)
|
||||
, Hdump = new Xoh_wtr_ctx(Mode_hdump , gplx.xowa.htmls.hrefs.Xoh_href_.Bry__wiki, null)
|
||||
;
|
||||
public static Xoh_wtr_ctx File_dump(byte[] anch__href__bgn, byte[] anch__href__end) {
|
||||
return new Xoh_wtr_ctx(Mode_file_dump, anch__href__bgn, anch__href__end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.htmls.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xoh_lnki_bldr {
|
||||
private final Xoa_app app; private final Xoh_href_wtr href_wtr; private final byte[] img_root_dir;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private final Xoa_app app; private final Xoh_href_wtr href_wtr; private final byte[] img_root_dir;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private byte[] href, title, id, caption;
|
||||
private byte[] img_rel_path; private int img_w, img_h; private boolean img_pos_is_left;
|
||||
public Xoh_lnki_bldr(Xoa_app app, Xoh_href_wtr href_wtr) {
|
||||
@@ -35,7 +35,7 @@ public class Xoh_lnki_bldr {
|
||||
public Xoh_lnki_bldr Id_(byte[] v) {this.id = Gfh_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, v); return this;}
|
||||
public Xoh_lnki_bldr Href_(Xow_wiki wiki, byte[] bry) {return Href_(wiki.Domain_bry(), wiki.Ttl_parse(bry));}
|
||||
public Xoh_lnki_bldr Href_(byte[] domain_bry, Xoa_ttl ttl) {
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, Xoh_wtr_ctx.Mode_popup, domain_bry, ttl);
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, Xoh_wtr_ctx.Popup, domain_bry, ttl);
|
||||
this.href = tmp_bfr.To_bry_and_clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,10 @@ public class Xoh_lnke_html {
|
||||
}
|
||||
public boolean Write_href(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke, int href_bgn, int href_end, boolean proto_is_xowa) {
|
||||
byte[] lnke_xwiki_wiki = lnke.Lnke_xwiki_wiki();
|
||||
if (lnke_xwiki_wiki == null || hctx.Mode_is_hdump()) { // if hdump, never write xwiki format (/site/); always write in url format (https:); note that xwiki is set when wiki is installed locally
|
||||
if ( lnke_xwiki_wiki == null
|
||||
|| hctx.Mode_is_hdump() // if hdump, never write xwiki format (/site/); always write in url format (https:); note that xwiki is set when wiki is installed locally
|
||||
|| hctx.Mode() == Xoh_wtr_ctx.Mode_file_dump
|
||||
) {
|
||||
if (lnke.Lnke_relative()) { // relative; EX: //a.org
|
||||
bfr.Add(ctx.Wiki().Utl__url_parser().Url_parser().Relative_url_protocol_bry()).Add_mid(src, href_bgn, href_end);
|
||||
return true;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xoh_file_wtr__audio__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Audio__full() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|noicon]]", String_.Concat_lines_nl_skip_last
|
||||
|
||||
@@ -101,7 +101,7 @@ public class Xoh_lnki_wtr {
|
||||
Write_caption(bfr, ctx, hctx, src, lnki, ttl_bry, true, caption_wkr);
|
||||
else {
|
||||
bfr.Add(Gfh_bldr_.Bry__a_lhs_w_href); // '<a href="'
|
||||
app.Html__href_wtr().Build_to_bfr(bfr, app, hctx.Mode(), wiki.Domain_bry(), lnki_ttl); // '/wiki/A'
|
||||
app.Html__href_wtr().Build_to_bfr(bfr, app, hctx, wiki.Domain_bry(), lnki_ttl); // '/wiki/A'
|
||||
if (cfg.Lnki__id()) {
|
||||
int lnki_html_id = lnki.Html_uid();
|
||||
if (lnki_html_id > Lnki_id_ignore) // html_id=0 for skipped lnkis; EX:anchors and interwiki
|
||||
|
||||
@@ -23,12 +23,12 @@ import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_tag_parser implements Gfh_doc_wkr {
|
||||
private final Xoh_hdoc_wkr hdoc_wkr;
|
||||
private final Gfh_tag_rdr tag_rdr = new Gfh_tag_rdr();
|
||||
private final Xoh_hdoc_wkr hdoc_wkr;
|
||||
private final Gfh_tag_rdr tag_rdr = Gfh_tag_rdr.New__html();
|
||||
private Xoh_hdoc_ctx hctx;
|
||||
private final Xoh_lnki_data wkr__lnki = new Xoh_lnki_data();
|
||||
private final Xoh_thm_data wkr__thm = new Xoh_thm_data();
|
||||
private final Xoh_gly_grp_data wkr__gly = new Xoh_gly_grp_data();
|
||||
private final Xoh_lnki_data wkr__lnki = new Xoh_lnki_data();
|
||||
private final Xoh_thm_data wkr__thm = new Xoh_thm_data();
|
||||
private final Xoh_gly_grp_data wkr__gly = new Xoh_gly_grp_data();
|
||||
public byte[] Hook() {return Byte_ascii.Angle_bgn_bry;}
|
||||
public Xoh_tag_parser(Xoh_hdoc_wkr hdoc_wkr) {this.hdoc_wkr = hdoc_wkr;}
|
||||
public void Init(Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end) {
|
||||
|
||||
@@ -17,7 +17,7 @@ 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
|
||||
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")
|
||||
@@ -37,5 +37,6 @@ public class Xoh_head_itm_ {
|
||||
, Key__dbui = Bry_.new_a7("dbui")
|
||||
, Key__bmk = Bry_.new_a7("bmk")
|
||||
, Key__server = Bry_.new_a7("server")
|
||||
, Key__tabber = Bry_.new_a7("tabber")
|
||||
;
|
||||
}
|
||||
|
||||
35
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__tabber.java
Normal file
35
400_xowa/src/gplx/xowa/htmls/heads/Xoh_head_itm__tabber.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
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__tabber extends Xoh_head_itm__base {
|
||||
@Override public byte[] Key() {return Xoh_head_itm_.Key__tabber;}
|
||||
@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 (Url__css == null) {
|
||||
Io_url tabber_dir = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("xowa", "xtns", "wikia", "Tabber");
|
||||
Url__js = tabber_dir.GenSubFil_nest("js" , "tabber.js").To_http_file_bry();
|
||||
Url__css = tabber_dir.GenSubFil_nest("css", "tabber.css").To_http_file_bry();
|
||||
}
|
||||
wtr.Write_css_include(Url__css);
|
||||
}
|
||||
@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__js);
|
||||
}
|
||||
private static byte[] Url__css, Url__js;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_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
|
||||
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()
|
||||
@@ -33,27 +33,28 @@ 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__pgbnr
|
||||
, itm__dbui, itm__pgbnr, itm__tabber
|
||||
);
|
||||
}
|
||||
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__gallery_styles Itm__gallery_styles() {return itm__gallery_styles;} private final Xoh_head_itm__gallery_styles itm__gallery_styles = new Xoh_head_itm__gallery_styles();
|
||||
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_itm__pgbnr Itm__pgbnr() {return itm__pgbnr;} private final Xoh_head_itm__pgbnr itm__pgbnr = new Xoh_head_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();
|
||||
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__gallery_styles Itm__gallery_styles() {return itm__gallery_styles;} private final Xoh_head_itm__gallery_styles itm__gallery_styles = new Xoh_head_itm__gallery_styles();
|
||||
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_itm__pgbnr Itm__pgbnr() {return itm__pgbnr;} private final Xoh_head_itm__pgbnr itm__pgbnr = new Xoh_head_itm__pgbnr();
|
||||
public Xoh_head_itm__tabber Itm__tabber() {return itm__tabber;} private final Xoh_head_itm__tabber itm__tabber = new Xoh_head_itm__tabber();
|
||||
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;
|
||||
@@ -138,7 +139,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
||||
wtr.Indent_del();
|
||||
wtr.Term();
|
||||
}
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Js__window_onload__bgn = Bry_.new_a7("window.onload = function() {")
|
||||
, Js__window_onload__end = Bry_.new_a7("};")
|
||||
;
|
||||
@@ -171,7 +172,7 @@ public class Xoh_head_mgr implements gplx.core.brys.Bfr_arg {
|
||||
}
|
||||
}
|
||||
class Xoh_head_wkr {
|
||||
private final List_adp list = List_adp_.size_(Xoh_head_itm__base.Idx__max);
|
||||
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);}
|
||||
|
||||
@@ -21,15 +21,17 @@ 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 Xoh_head_wtr Init(Bry_bfr bfr) {this.bfr = bfr; return this;}
|
||||
public void Term() {
|
||||
this.bfr = null;
|
||||
js_tail_inited = true;
|
||||
}
|
||||
public void Write_css_include(Io_url url) {Write_css_include(url.To_http_file_bry());}
|
||||
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(Io_url url) {Write_js_include(url.To_http_file_bry());}
|
||||
public void Write_js_include(byte[] url) {
|
||||
Write_nl_and_indent();
|
||||
bfr.Add(Js_include_bgn).Add(url).Add(Js_include_end);
|
||||
@@ -110,7 +112,8 @@ public class Xoh_head_wtr {
|
||||
bfr.Add(url);
|
||||
bfr.Add(Js_line_2_end);
|
||||
}
|
||||
private static final byte[]
|
||||
public byte[] To_bry_and_clear() {return bfr.To_bry_and_clear();}
|
||||
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("');")
|
||||
@@ -151,7 +154,7 @@ public class Xoh_head_wtr {
|
||||
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(", ");
|
||||
} 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();
|
||||
@@ -214,7 +217,7 @@ public class Xoh_head_wtr {
|
||||
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[]
|
||||
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=\"")
|
||||
|
||||
@@ -20,39 +20,50 @@ import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xoh_href_wtr {
|
||||
private final Bry_bfr encoder_bfr = Bry_bfr.reset_(255), tmp_bfr = Bry_bfr.reset_(255);
|
||||
private final Gfo_url_encoder encoder = Gfo_url_encoder_.Href;
|
||||
private final Bry_bfr encoder_bfr = Bry_bfr.reset_(255), tmp_bfr = Bry_bfr.reset_(255);
|
||||
private final Gfo_url_encoder encoder = Gfo_url_encoder_.Href;
|
||||
public byte[] Build_to_bry(Xow_wiki wiki, Xoa_ttl ttl) {
|
||||
synchronized (tmp_bfr) {
|
||||
Build_to_bfr(tmp_bfr, wiki.App(), Xoh_wtr_ctx.Mode_basic, wiki.Domain_bry(), ttl);
|
||||
Build_to_bfr(tmp_bfr, wiki.App(), Xoh_wtr_ctx.Basic, wiki.Domain_bry(), ttl);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
public void Build_to_bfr(Bry_bfr bfr, Xoa_app app, byte[] domain_bry, Xoa_ttl ttl) {Build_to_bfr(bfr, app, Xoh_wtr_ctx.Mode_basic, domain_bry, ttl);}
|
||||
public void Build_to_bfr(Bry_bfr bfr, Xoa_app app, int hctx_mode, byte[] domain_bry, Xoa_ttl ttl) {
|
||||
public void Build_to_bfr(Bry_bfr bfr, Xoa_app app, byte[] domain_bry, Xoa_ttl ttl) {Build_to_bfr(bfr, app, Xoh_wtr_ctx.Basic, domain_bry, ttl);}
|
||||
public void Build_to_bfr(Bry_bfr bfr, Xoa_app app, Xoh_wtr_ctx hctx, byte[] domain_bry, Xoa_ttl ttl) {
|
||||
int hctx_mode = hctx.Mode();
|
||||
byte[] page = ttl.Full_txt_raw();
|
||||
Xow_xwiki_itm xwiki = ttl.Wik_itm();
|
||||
if (xwiki == null) // not an xwiki; EX: [[wikt:Word]]
|
||||
Build_to_bfr_page(ttl, page, 0); // write page only; NOTE: changed to remove leaf logic DATE:2014-09-07
|
||||
Build_to_bfr_page(ttl, hctx, page, 0); // write page only; NOTE: changed to remove leaf logic DATE:2014-09-07
|
||||
else { // xwiki; skip wiki and encode page only;
|
||||
byte[] wik_txt = ttl.Wik_txt();
|
||||
Build_to_bfr_page(ttl, page, wik_txt.length + 1);
|
||||
Build_to_bfr_page(ttl, hctx, page, wik_txt.length + 1);
|
||||
}
|
||||
if (xwiki == null) { // not an xwiki
|
||||
if (ttl.Anch_bgn() != 1) { // not an anchor-only; EX: "#A"
|
||||
if (hctx_mode == Xoh_wtr_ctx.Mode_popup) { // popup parser always writes as "/site/"
|
||||
bfr.Add(Xoh_href_.Bry__site); // add "/site/"; EX: /site/
|
||||
bfr.Add(domain_bry); // add xwiki; EX: en_dict
|
||||
bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/
|
||||
switch (hctx_mode) {
|
||||
case Xoh_wtr_ctx.Mode_popup: { // popup parser always writes as "/site/"
|
||||
bfr.Add(Xoh_href_.Bry__site); // add "/site/"; EX: /site/
|
||||
bfr.Add(domain_bry); // add xwiki; EX: en_dict
|
||||
bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/
|
||||
break;
|
||||
}
|
||||
case Xoh_wtr_ctx.Mode_file_dump: {
|
||||
bfr.Add(hctx.Anch__href__bgn());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/Page
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/Page
|
||||
}
|
||||
else {} // anchor: noop
|
||||
}
|
||||
else { // xwiki
|
||||
if ( app.Xwiki_mgr__missing(xwiki.Domain_bry()) // xwiki is not offline; use http:
|
||||
|| hctx_mode == Xoh_wtr_ctx.Mode_hdump // hdump should never dump as "/site/"
|
||||
|| hctx_mode == Xoh_wtr_ctx.Mode_file_dump // filedump should never dump as "/site/"
|
||||
) {
|
||||
Bry_fmtr url_fmtr = xwiki.Url_fmtr();
|
||||
if (url_fmtr == null) {
|
||||
@@ -73,14 +84,23 @@ public class Xoh_href_wtr {
|
||||
}
|
||||
bfr.Add_bfr_and_clear(encoder_bfr);
|
||||
}
|
||||
private void Build_to_bfr_page(Xoa_ttl ttl, byte[] ttl_full, int page_bgn) {
|
||||
private void Build_to_bfr_page(Xoa_ttl ttl, Xoh_wtr_ctx hctx, byte[] ttl_full, int page_bgn) {
|
||||
int anch_bgn = Bry_find_.Find_fwd(ttl_full, Byte_ascii.Hash); // NOTE: cannot use Anch_bgn b/c Anch_bgn has bug with whitespace
|
||||
if (anch_bgn == Bry_find_.Not_found) // no anchor; just add page
|
||||
if (anch_bgn == Bry_find_.Not_found){ // no anchor; just add page
|
||||
encoder.Encode(encoder_bfr, ttl_full, page_bgn, ttl_full.length);
|
||||
else { // anchor exists; check if anchor is preceded by ws; EX: [[A #b]] -> "/wiki/A#b"
|
||||
if (hctx.Mode() == Xoh_wtr_ctx.Mode_file_dump) {
|
||||
byte[] href_end = hctx.Anch__href__end();
|
||||
if (href_end != null) encoder_bfr.Add(href_end);
|
||||
}
|
||||
}
|
||||
else { // anchor exists; check if anchor is preceded by ws; EX: [[A #b]] -> "/wiki/A#b"
|
||||
int page_end = Bry_find_.Find_bwd_last_ws(ttl_full, anch_bgn); // first 1st ws before #; handles multiple ws
|
||||
page_end = page_end == Bry_find_.Not_found ? anch_bgn : page_end; // if ws not found, use # pos; else use 1st ws pos
|
||||
encoder.Encode(encoder_bfr, ttl_full, page_bgn, page_end); // add page
|
||||
if (hctx.Mode() == Xoh_wtr_ctx.Mode_file_dump) {
|
||||
byte[] href_end = hctx.Anch__href__end();
|
||||
if (href_end != null) encoder_bfr.Add(href_end);
|
||||
}
|
||||
encoder.Encode(encoder_bfr, ttl_full, anch_bgn, ttl_full.length); // add anchor
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user