1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Embeddable: Do not call hxtn code during embeddable [#733]

This commit is contained in:
gnosygnu 2020-05-27 07:29:39 -04:00
parent 0cdfa0992c
commit 7a0247417d
5 changed files with 96 additions and 78 deletions

View File

@ -61,7 +61,7 @@ public class Xop_mediawiki_wkr {
boolean is_wikitext = Xow_page_tid.Identify(wpg.Wiki().Domain_tid(), ttl.Ns().Id(), ttl.Page_db()) == Xow_page_tid.Tid_wikitext; boolean is_wikitext = Xow_page_tid.Identify(wpg.Wiki().Domain_tid(), ttl.Ns().Id(), ttl.Page_db()) == Xow_page_tid.Tid_wikitext;
byte[] orig_bry = Bry_.Empty; byte[] orig_bry = Bry_.Empty;
if (is_wikitext) { if (is_wikitext) {
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_view_mode_.Tid__read).Write_hdump(tmp_bfr, pctx, Xoh_wtr_ctx.Hdump, wpg); wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_view_mode_.Tid__read).Write_hdump(tmp_bfr, pctx, Xoh_wtr_ctx.Embeddable, wpg);
// write categories // write categories
int ctgs_len = wpg.Wtxt().Ctgs__len(); int ctgs_len = wpg.Wtxt().Ctgs__len();

View File

@ -28,12 +28,10 @@ import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xoae_app; import gplx.xowa.Xoae_app;
import gplx.xowa.Xoae_page; import gplx.xowa.Xoae_page;
import gplx.xowa.Xowe_wiki; import gplx.xowa.Xowe_wiki;
import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.Xoctg_pagebox_itm;
import gplx.xowa.apps.gfs.Gfs_php_converter; import gplx.xowa.apps.gfs.Gfs_php_converter;
import gplx.xowa.htmls.core.Xow_hdump_mode; import gplx.xowa.htmls.core.Xow_hdump_mode;
import gplx.xowa.htmls.core.htmls.Xoh_html_wtr_escaper; import gplx.xowa.htmls.core.htmls.Xoh_html_wtr_escaper;
import gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx; import gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx;
import gplx.xowa.htmls.hxtns.blobs.Hxtn_blob_tbl;
import gplx.xowa.htmls.hxtns.pages.Hxtn_page_mgr; import gplx.xowa.htmls.hxtns.pages.Hxtn_page_mgr;
import gplx.xowa.htmls.portal.Xoh_page_body_cls; import gplx.xowa.htmls.portal.Xoh_page_body_cls;
import gplx.xowa.htmls.portal.Xow_portal_mgr; import gplx.xowa.htmls.portal.Xow_portal_mgr;
@ -172,7 +170,9 @@ public class Xoh_page_wtr_wkr {
int page_id = wpg.Db().Page().Id(); int page_id = wpg.Db().Page().Id();
Hxtn_page_mgr html_data_mgr = wpg.Wikie().Hxtn_mgr(); Hxtn_page_mgr html_data_mgr = wpg.Wikie().Hxtn_mgr();
wpg.Html_data().Indicators().HxtnSave(wpg.Wikie(), html_data_mgr, wpg, page_id); if (!hctx.Mode_is_embeddable()) {
wpg.Html_data().Indicators().HxtnSave(wpg.Wikie(), html_data_mgr, wpg, page_id);
}
this.Write_body(bfr, ctx, hctx, wpg); this.Write_body(bfr, ctx, hctx, wpg);
} }

View File

@ -1,21 +1,23 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis. for your project on a case-by-case basis.
The terms of each license can be found in the source code repository: The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.htmls.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; package gplx.xowa.htmls.core.htmls;
import gplx.xowa.htmls.core.hzips.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_;
import gplx.xowa.htmls.hrefs.Xoh_href_;
public class Xoh_wtr_ctx { public class Xoh_wtr_ctx {
Xoh_wtr_ctx(int mode, int hzip_tid, byte[] anch__href__bgn, byte[] anch__href__end) { Xoh_wtr_ctx(int mode, int hzip_tid, byte[] anch__href__bgn, byte[] anch__href__end) {
this.mode = mode; this.mode = mode;
@ -23,30 +25,40 @@ public class Xoh_wtr_ctx {
this.anch__href__bgn = anch__href__bgn; this.anch__href__bgn = anch__href__bgn;
this.anch__href__end = anch__href__end; this.anch__href__end = anch__href__end;
} }
public int Mode() {return mode;} private final int mode; public int Mode() {return mode;} private final int mode;
public int Hzip_tid() {return hzip_tid;} private final int hzip_tid; public byte[] Anch__href__bgn() {return anch__href__bgn;} private final byte[] anch__href__bgn;
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 byte[] Anch__href__end() {return anch__href__end;} private final byte[] anch__href__end; public int Hzip_tid() {return hzip_tid;} private final int hzip_tid;
public boolean Mode_is_hdump() {return mode == Mode_hdump;} public boolean Mode_is_hdump() {return mode == TID_HDUMP || mode == TID_EMBEDDABLE;}
public boolean Mode_is_file_dump() {return mode == Mode_hdump;} public boolean Mode_is_file_dump() {return mode == TID_HDUMP || mode == TID_EMBEDDABLE;}
public boolean Mode_is_alt() {return mode == Mode_alt;} public boolean Mode_is_embeddable() {return mode == TID_EMBEDDABLE;}
public boolean Mode_is_display_title() {return mode == Mode_display_title;} public boolean Mode_is_alt() {return mode == TID_ALT;}
public boolean Mode_is_popup() {return mode == Mode_popup;} public boolean Mode_is_display_title() {return mode == TID_DISPLAY_TITLE;}
public boolean Mode_is_popup() {return mode == TID_POPUP;}
public static final int Mode_basic = 0, Mode_alt = 1, Mode_display_title = 2, Mode_popup = 3, Mode_hdump = 4, Mode_file_dump = 5; private static final int
TID_BASIC = 0
, TID_ALT = 1
, TID_DISPLAY_TITLE = 2
, TID_POPUP = 3
, TID_HDUMP = 4
, TID_FILE_DUMP = 5
, TID_EMBEDDABLE = 6
;
public static final Xoh_wtr_ctx public static final Xoh_wtr_ctx
Basic = new Xoh_wtr_ctx(Mode_basic , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null) Basic = new Xoh_wtr_ctx(TID_BASIC, Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
, Hdump = new Xoh_wtr_ctx(Mode_hdump , Xoh_hzip_dict_.Hdb__hzip , Xoh_href_.Bry__wiki, null) , Hdump = new Xoh_wtr_ctx(TID_HDUMP, Xoh_hzip_dict_.Hdb__hzip, Xoh_href_.Bry__wiki, null)
, Alt = new Xoh_wtr_ctx(Mode_alt , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null) , Alt = new Xoh_wtr_ctx(TID_ALT, Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
, Display_title = new Xoh_wtr_ctx(Mode_display_title , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null) , Display_title = new Xoh_wtr_ctx(TID_DISPLAY_TITLE, Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
, Popup = new Xoh_wtr_ctx(Mode_popup , Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null) , Popup = new Xoh_wtr_ctx(TID_POPUP, Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
, Embeddable = new Xoh_wtr_ctx(TID_EMBEDDABLE, Xoh_hzip_dict_.Hdb__htxt, Xoh_href_.Bry__wiki, null)
; ;
public static Xoh_wtr_ctx File_dump(byte[] anch__href__bgn, byte[] anch__href__end) { public static Xoh_wtr_ctx File_dump(byte[] anch__href__bgn, byte[] anch__href__end) {
return new Xoh_wtr_ctx(Mode_file_dump, Xoh_hzip_dict_.Hdb__htxt, anch__href__bgn, anch__href__end); return new Xoh_wtr_ctx(TID_FILE_DUMP, Xoh_hzip_dict_.Hdb__htxt, anch__href__bgn, anch__href__end);
} }
public static Xoh_wtr_ctx Hdump_by_hzip_tid(int hzip_tid) { public static Xoh_wtr_ctx Hdump_by_hzip_tid(int hzip_tid) {
return new Xoh_wtr_ctx(Mode_hdump, hzip_tid, Xoh_href_.Bry__wiki, null); return new Xoh_wtr_ctx(TID_HDUMP, hzip_tid, Xoh_href_.Bry__wiki, null);
} }
} }

View File

@ -1,22 +1,34 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis. for your project on a case-by-case basis.
The terms of each license can be found in the source code repository: The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; package gplx.xowa.htmls.hrefs;
import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.core.htmls.*; import gplx.Bool_;
import gplx.xowa.wikis.xwikis.*; import gplx.Bry_bfr;
import gplx.Bry_bfr_;
import gplx.Bry_find_;
import gplx.Byte_ascii;
import gplx.core.brys.fmtrs.Bry_fmtr;
import gplx.langs.htmls.encoders.Gfo_url_encoder;
import gplx.langs.htmls.encoders.Gfo_url_encoder_;
import gplx.xowa.Xoa_app;
import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xow_wiki;
import gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx;
import gplx.xowa.wikis.xwikis.Xow_xwiki_itm;
public class Xoh_href_wtr { // TS:do not move to app-level public class Xoh_href_wtr { // TS:do not move to app-level
private final Gfo_url_encoder encoder = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Make(); private final Gfo_url_encoder encoder = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Make();
private final Bry_bfr encoder_bfr = Bry_bfr_.Reset(255), tmp_bfr = Bry_bfr_.Reset(255); private final Bry_bfr encoder_bfr = Bry_bfr_.Reset(255), tmp_bfr = Bry_bfr_.Reset(255);
@ -46,7 +58,6 @@ public class Xoh_href_wtr { // TS:do not move to app-level
} }
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, 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) { // given ttl, write href; EX: A -> '/wiki/A' public void Build_to_bfr(Bry_bfr bfr, Xoa_app app, Xoh_wtr_ctx hctx, byte[] domain_bry, Xoa_ttl ttl) { // given ttl, write href; EX: A -> '/wiki/A'
int hctx_mode = hctx.Mode();
byte[] page = ttl.Full_txt_raw(); byte[] page = ttl.Full_txt_raw();
Xow_xwiki_itm xwiki = ttl.Wik_itm(); Xow_xwiki_itm xwiki = ttl.Wik_itm();
if (xwiki == null) // not an xwiki; EX: [[wikt:Word]] if (xwiki == null) // not an xwiki; EX: [[wikt:Word]]
@ -57,29 +68,24 @@ public class Xoh_href_wtr { // TS:do not move to app-level
} }
if (xwiki == null) { // not an xwiki if (xwiki == null) { // not an xwiki
if (ttl.Anch_bgn() != 1) { // not an anchor-only; EX: "#A" if (ttl.Anch_bgn() != 1) { // not an anchor-only; EX: "#A"
switch (hctx_mode) { if (hctx.Mode_is_popup()) { // popup parser always writes as "/site/"
case Xoh_wtr_ctx.Mode_popup: { // popup parser always writes as "/site/" bfr.Add(Xoh_href_.Bry__site); // add "/site/"; EX: /site/
bfr.Add(Xoh_href_.Bry__site); // add "/site/"; EX: /site/ bfr.Add(domain_bry); // add xwiki; EX: en_dict
bfr.Add(domain_bry); // add xwiki; EX: en_dict bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/
bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/ }
break; else if (hctx.Mode_is_file_dump()) {
} bfr.Add(hctx.Anch__href__bgn()); // add "/wiki/"; EX: /wiki/Page; can be "/home/wiki/Page" for Html__dump_to_fsys
case Xoh_wtr_ctx.Mode_file_dump: { }
bfr.Add(hctx.Anch__href__bgn()); // add "/wiki/"; EX: /wiki/Page; can be "/home/wiki/Page" for Html__dump_to_fsys else {
break; bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/Page
}
default: {
bfr.Add(Xoh_href_.Bry__wiki); // add "/wiki/"; EX: /wiki/Page
break;
}
} }
} }
else {} // anchor: noop else {} // anchor: noop
} }
else { // xwiki else { // xwiki
if ( app.Xwiki_mgr__missing(xwiki.Domain_bry()) // xwiki is not offline; use http: 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_is_hdump() // hdump should never dump as "/site/"
|| hctx_mode == Xoh_wtr_ctx.Mode_file_dump // filedump should never dump as "/site/" || hctx.Mode_is_file_dump() // filedump should never dump as "/site/"
) { ) {
Bry_fmtr url_fmtr = xwiki.Url_fmtr(); Bry_fmtr url_fmtr = xwiki.Url_fmtr();
if (url_fmtr == null) { if (url_fmtr == null) {

View File

@ -114,7 +114,7 @@ public class Template_styles_nde implements Xox_xnde, Mwh_atr_itm_owner2 {
css_dynamic.Add(tmp_bfr.To_bry_and_clear()); css_dynamic.Add(tmp_bfr.To_bry_and_clear());
} finally {tmp_bfr.Mkr_rls();} } finally {tmp_bfr.Mkr_rls();}
if (hctx.Mode_is_hdump()) { if (hctx.Mode_is_hdump() && !hctx.Mode_is_embeddable()) {
int page_id = wpg.Db().Page().Id(); int page_id = wpg.Db().Page().Id();
Hxtn_page_mgr html_data_mgr = wpg.Wikie().Hxtn_mgr(); Hxtn_page_mgr html_data_mgr = wpg.Wikie().Hxtn_mgr();
html_data_mgr.Page_tbl__insert(page_id, Hxtn_page_mgr.Id__template_styles, css_page_id); html_data_mgr.Page_tbl__insert(page_id, Hxtn_page_mgr.Id__template_styles, css_page_id);