mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.12.1.1
This commit is contained in:
@@ -17,19 +17,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
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 = gplx.langs.htmls.encoders.Gfo_url_encoder_.Href;
|
||||
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(), wiki.Domain_bry(), ttl, Bool_.N);
|
||||
Build_to_bfr(tmp_bfr, wiki.App(), Xoh_wtr_ctx.Mode_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, domain_bry, ttl, Bool_.N);}
|
||||
public void Build_to_bfr(Bry_bfr bfr, Xoa_app app, byte[] domain_bry, Xoa_ttl ttl, boolean force_site) {
|
||||
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) {
|
||||
byte[] page = ttl.Full_txt_raw();
|
||||
Xow_xwiki_itm xwiki = ttl.Wik_itm();
|
||||
if (xwiki == null) // not an xwiki; EX: [[wikt:Word]]
|
||||
@@ -40,7 +40,7 @@ public class Xoh_href_wtr {
|
||||
}
|
||||
if (xwiki == null) { // not an xwiki
|
||||
if (ttl.Anch_bgn() != 1) { // not an anchor-only; EX: "#A"
|
||||
if (force_site) { // popup parser always writes as "/site/"
|
||||
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/
|
||||
@@ -51,7 +51,9 @@ public class Xoh_href_wtr {
|
||||
else {} // anchor: noop
|
||||
}
|
||||
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/"
|
||||
) {
|
||||
Bry_fmtr url_fmtr = xwiki.Url_fmtr();
|
||||
if (url_fmtr == null) {
|
||||
bfr.Add(Xoh_href_.Bry__https); // add "https://"; EX: https://
|
||||
@@ -77,7 +79,7 @@ public class Xoh_href_wtr {
|
||||
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"
|
||||
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
|
||||
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
|
||||
encoder.Encode(encoder_bfr, ttl_full, anch_bgn, ttl_full.length); // add anchor
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user