mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Http_server: Fix images not downloading on some Portal pages [#686]
This commit is contained in:
parent
efe415d3a3
commit
35475d631c
@ -1,22 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
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.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.apps.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.servers.*;
|
||||
import gplx.core.envs.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.errors.*;
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
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.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.apps.servers.http;
|
||||
|
||||
import gplx.Bry_;
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.String_;
|
||||
import gplx.core.envs.Runtime_;
|
||||
import gplx.xowa.Xoa_ttl;
|
||||
import gplx.xowa.Xoa_url;
|
||||
import gplx.xowa.Xoae_app;
|
||||
import gplx.xowa.Xoae_page;
|
||||
import gplx.xowa.Xowe_wiki;
|
||||
import gplx.xowa.Xowe_wiki_;
|
||||
import gplx.xowa.apps.servers.Gxw_html_server;
|
||||
import gplx.xowa.guis.views.Xog_tab_itm;
|
||||
import gplx.xowa.specials.Xow_special_meta_;
|
||||
import gplx.xowa.specials.xowa.errors.Xoerror_special;
|
||||
|
||||
public class Http_server_page {
|
||||
private final Xoae_app app;
|
||||
public Http_server_page(Xoae_app app) {
|
||||
@ -97,26 +111,22 @@ public class Http_server_page {
|
||||
this.html = wiki.Html_mgr().Head_mgr().Popup_mgr().Show_init(popup_id, ttl_bry, ttl_bry);
|
||||
}
|
||||
else {
|
||||
// NOTE: generates HTML, but substitutes xoimg tags for <img>; ISSUE#:686; DATE:2020-06-27
|
||||
byte[] page_html = wiki.Html_mgr().Page_wtr_mgr().Gen(page, mode);
|
||||
|
||||
page_html = Bry_.Replace_many(page_html, app.Fsys_mgr().Root_dir().To_http_file_bry(), Http_server_wkr.Url__fsys);
|
||||
this.html = String_.new_u8(page_html); // NOTE: must generate HTML now in order for "wait" and "async_server" to work with text_dbs; DATE:2016-07-10
|
||||
boolean rebuild_html = false;
|
||||
switch (retrieve_mode) {
|
||||
case File_retrieve_mode.Mode_skip: // noop
|
||||
break;
|
||||
case File_retrieve_mode.Mode_async_server:
|
||||
rebuild_html = true;
|
||||
app.Gui_mgr().Browser_win().Page__async__bgn(tab);
|
||||
break;
|
||||
case File_retrieve_mode.Mode_wait:
|
||||
rebuild_html = true;
|
||||
gplx.xowa.guis.views.Xog_async_wkr.Async(page, tab.Html_itm());
|
||||
this.page = wiki.Page_mgr().Load_page(url, ttl, tab); // HACK: fetch page again so that HTML will now include img data
|
||||
break;
|
||||
}
|
||||
if (rebuild_html)
|
||||
this.html = String_.new_u8(wiki.Html_mgr().Page_wtr_mgr().Gen(page, mode));
|
||||
// NOTE: substitutes xoimg tags for actual file; ISSUE#:686; DATE:2020-06-27
|
||||
this.html = String_.new_u8(wiki.Html__hdump_mgr().Load_mgr().Parse(page_html, this.page));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,8 @@ public class Xoh_page_wtr_wkr {
|
||||
Write_page_by_tid(ctx, hctx, page_mode, rv, mgr.Page_html_fmtr(), Gfh_utl.Escape_html_as_bry(html_bry));
|
||||
}
|
||||
else {
|
||||
hctx = Xoh_wtr_ctx.Basic;
|
||||
// NOTE: if HTTP, generate hdump html b/c of async image download; HTTP will later call make_mgr to substitute out <xoimg>; ISSUE#:686; DATE:2020-06-27
|
||||
hctx = app.Mode().Tid_is_http() ? Xoh_wtr_ctx.HttpServer : Xoh_wtr_ctx.Basic;
|
||||
Write_body(page_bfr, ctx, hctx, page);
|
||||
Write_page_by_tid(ctx, hctx, view_mode, rv, fmtr, page_bfr.To_bry_and_rls());
|
||||
scripting_mgr.Write(rv, wiki, page);
|
||||
@ -170,7 +171,7 @@ public class Xoh_page_wtr_wkr {
|
||||
int page_id = wpg.Db().Page().Id();
|
||||
Hxtn_page_mgr html_data_mgr = wpg.Wikie().Hxtn_mgr();
|
||||
|
||||
if (!hctx.Mode_is_embeddable()) {
|
||||
if (!hctx.Mode_is_hdump_wo_db()) {
|
||||
wpg.Html_data().Indicators().HxtnSave(wpg.Wikie(), html_data_mgr, wpg, page_id);
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,12 @@ public class Xow_hdump_mgr__load implements Gfo_invk {
|
||||
}
|
||||
}
|
||||
public byte[] Decode_as_bry(Bry_bfr bfr, Xoh_page hpg, byte[] src, boolean mode_is_diff) {hzip_mgr.Hctx().Mode_is_diff_(mode_is_diff); hzip_mgr.Decode(bfr, wiki, hpg, src); return bfr.To_bry_and_clear();}
|
||||
|
||||
public byte[] Parse(byte[] src, Xoae_page page) { // NOTE: currently, only used by HTTP_SERVER; may generalize later
|
||||
Xoh_page hpg = new Xoh_page();
|
||||
hpg.Ctor_by_hview(page.Wiki(), page.Url(), page.Ttl(), page.Db().Page().Id());
|
||||
return make_mgr.Parse(src, wiki, hpg);
|
||||
}
|
||||
public byte[] Parse(Xoh_page hpg, int zip_tid, int hzip_tid, byte[] src) {
|
||||
if (zip_tid > gplx.core.ios.streams.Io_stream_tid_.Tid__raw)
|
||||
src = zip_mgr.Unzip((byte)zip_tid, src);
|
||||
|
@ -29,9 +29,9 @@ public class Xoh_wtr_ctx {
|
||||
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 int Hzip_tid() {return hzip_tid;} private final int hzip_tid;
|
||||
public boolean Mode_is_hdump() {return mode == TID_HDUMP || mode == TID_EMBEDDABLE;}
|
||||
public boolean Mode_is_file_dump() {return mode == TID_HDUMP || mode == TID_EMBEDDABLE;}
|
||||
public boolean Mode_is_embeddable() {return mode == TID_EMBEDDABLE;}
|
||||
public boolean Mode_is_hdump() {return mode == TID_HDUMP || mode == TID_EMBEDDABLE || mode == TID_HTTP_SERVER;}
|
||||
public boolean Mode_is_file_dump() {return mode == TID_HDUMP || mode == TID_EMBEDDABLE || mode == TID_HTTP_SERVER;}
|
||||
public boolean Mode_is_hdump_wo_db() {return mode == TID_EMBEDDABLE || mode == TID_HTTP_SERVER;}
|
||||
public boolean Mode_is_alt() {return mode == TID_ALT;}
|
||||
public boolean Mode_is_display_title() {return mode == TID_DISPLAY_TITLE;}
|
||||
public boolean Mode_is_popup() {return mode == TID_POPUP;}
|
||||
@ -44,6 +44,7 @@ public class Xoh_wtr_ctx {
|
||||
, TID_HDUMP = 4
|
||||
, TID_FILE_DUMP = 5
|
||||
, TID_EMBEDDABLE = 6
|
||||
, TID_HTTP_SERVER = 7
|
||||
;
|
||||
|
||||
public static final Xoh_wtr_ctx
|
||||
@ -53,6 +54,7 @@ public class Xoh_wtr_ctx {
|
||||
, Display_title = new Xoh_wtr_ctx(TID_DISPLAY_TITLE, 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)
|
||||
, HttpServer = new Xoh_wtr_ctx(TID_HTTP_SERVER, 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) {
|
||||
|
@ -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());
|
||||
} finally {tmp_bfr.Mkr_rls();}
|
||||
|
||||
if (hctx.Mode_is_hdump() && !hctx.Mode_is_embeddable()) {
|
||||
if (hctx.Mode_is_hdump() && !hctx.Mode_is_hdump_wo_db()) {
|
||||
int page_id = wpg.Db().Page().Id();
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user