mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.8.2.1'
This commit is contained in:
@@ -26,6 +26,12 @@ public class Xoh_img_mgr {
|
||||
}
|
||||
public int Len() {return list.Count();}
|
||||
public Xof_fsdb_itm Get_at(int i) {return (Xof_fsdb_itm)list.Get_at(i);}
|
||||
public Xof_fsdb_itm Make_aud() {
|
||||
Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
itm.Init_at_hdoc(++uid_nxt, Xof_html_elem.Tid_aud);
|
||||
list.Add(itm);
|
||||
return itm;
|
||||
}
|
||||
public Xof_fsdb_itm Make_img(boolean img_is_gallery) {
|
||||
Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
itm.Init_at_hdoc(++uid_nxt, img_is_gallery ? Xof_html_elem.Tid_gallery : Xof_html_elem.Tid_img);
|
||||
|
||||
@@ -21,17 +21,15 @@ import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.ctgs.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.parsers.xndes.*;
|
||||
import gplx.xowa.htmls.portal.*; import gplx.xowa.addons.htmls.tocs.*; import gplx.xowa.wikis.modules.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.htmls.tidy.*; import gplx.xowa.htmls.js.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
public class Xow_html_mgr implements Gfo_invk {
|
||||
private final Gfo_url_encoder fsys_lnx_encoder = Gfo_url_encoder_.New__fsys_lnx().Make();
|
||||
public Xow_html_mgr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
html_wtr = new Xoh_html_wtr(wiki, this);
|
||||
Xoae_app app = wiki.Appe();
|
||||
page_wtr_mgr = new Xoh_page_wtr_mgr(app.Gui_mgr().Kit().Tid() != Gfui_kit_.Swing_tid); // reverse logic to handle swt,drd but not mem
|
||||
Io_url file_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("mediawiki.file");
|
||||
img_media_play_btn = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(file_dir.GenSubFil("play.png"));
|
||||
img_media_info_btn = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(file_dir.GenSubFil("info.png"));
|
||||
img_thumb_magnify = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(file_dir.GenSubFil("magnify-clip.png"));
|
||||
img_xowa_protocol = gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(app.Fsys_mgr().Bin_xowa_file_dir().GenSubFil_nest("app.general", "xowa_exec.png"));
|
||||
img_xowa_protocol = fsys_lnx_encoder.Encode_to_file_protocol(app.Fsys_mgr().Bin_xowa_file_dir().GenSubFil_nest("app.general", "xowa_exec.png"));
|
||||
portal_mgr = new Xow_portal_mgr(wiki);
|
||||
imgs_mgr = new Xoh_imgs_mgr(this);
|
||||
module_mgr = new Xow_module_mgr(wiki);
|
||||
@@ -55,9 +53,6 @@ public class Xow_html_mgr implements Gfo_invk {
|
||||
public Xow_module_mgr Head_mgr() {return module_mgr;} private Xow_module_mgr module_mgr;
|
||||
public boolean Importing_ctgs() {return importing_ctgs;} public void Importing_ctgs_(boolean v) {importing_ctgs = v;} private boolean importing_ctgs;
|
||||
public int Img_thumb_width() {return img_thumb_width;} private int img_thumb_width = 220;
|
||||
public byte[] Img_media_play_btn() {return img_media_play_btn;} private byte[] img_media_play_btn;
|
||||
public byte[] Img_media_info_btn() {return img_media_info_btn;} private byte[] img_media_info_btn;
|
||||
public byte[] Img_thumb_magnify() {return img_thumb_magnify;} private byte[] img_thumb_magnify;
|
||||
public byte[] Img_xowa_protocol() {return img_xowa_protocol;} private byte[] img_xowa_protocol;
|
||||
public boolean Img_suppress_missing_src() {return img_suppress_missing_src;} public Xow_html_mgr Img_suppress_missing_src_(boolean v) {img_suppress_missing_src = v; return this;} private boolean img_suppress_missing_src = true;
|
||||
public Xohp_ctg_grp_mgr Ctg_mgr() {return ctg_mgr;} private Xohp_ctg_grp_mgr ctg_mgr = new Xohp_ctg_grp_mgr();
|
||||
|
||||
@@ -17,7 +17,7 @@ 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.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.langs.kwds.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.langs.kwds.*; import gplx.langs.htmls.entitys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.lists.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.parsers.tblws.*; import gplx.xowa.parsers.paras.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.miscs.*; import gplx.xowa.parsers.htmls.*;
|
||||
|
||||
@@ -16,7 +16,8 @@ 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.core.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.btries.*; import gplx.langs.htmls.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.entitys.*;
|
||||
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.xndes.*;
|
||||
public class Xoh_html_wtr_escaper {
|
||||
public static byte[] Escape(Xop_amp_mgr amp_mgr, Bry_bfr tmp_bfr, byte[] src) {
|
||||
@@ -53,19 +54,19 @@ public class Xoh_html_wtr_escaper {
|
||||
if (o == null) // invalid; EX: "a&b"; "&bad;"; "&#letters;";
|
||||
bfr.Add(Gfh_entity_.Amp_bry); // escape & and continue
|
||||
else { // is either (1) a name or (2) an ncr (hex/dec)
|
||||
Xop_amp_trie_itm itm = (Xop_amp_trie_itm)o;
|
||||
Gfh_entity_itm itm = (Gfh_entity_itm)o;
|
||||
int match_pos = trv.Pos();
|
||||
int itm_tid = itm.Tid();
|
||||
switch (itm_tid) {
|
||||
case Xop_amp_trie_itm.Tid_name_std:
|
||||
case Xop_amp_trie_itm.Tid_name_xowa: // name
|
||||
case Gfh_entity_itm.Tid_name_std:
|
||||
case Gfh_entity_itm.Tid_name_xowa: // name
|
||||
bfr.Add_mid(src, i, match_pos); // embed entire name
|
||||
i = match_pos - 1;
|
||||
break;
|
||||
case Xop_amp_trie_itm.Tid_num_dec:
|
||||
case Xop_amp_trie_itm.Tid_num_hex: // ncr: dec/hex; escape if invalid
|
||||
case Gfh_entity_itm.Tid_num_dec:
|
||||
case Gfh_entity_itm.Tid_num_hex: // ncr: dec/hex; escape if invalid
|
||||
Xop_amp_mgr_rslt rslt = new Xop_amp_mgr_rslt();
|
||||
boolean pass = amp_mgr.Parse_ncr(rslt, itm_tid == Xop_amp_trie_itm.Tid_num_hex, src, end, i, match_pos);
|
||||
boolean pass = amp_mgr.Parse_ncr(rslt, itm_tid == Gfh_entity_itm.Tid_num_hex, src, end, i, match_pos);
|
||||
if (pass) { // parse worked; embed entire ncr; EX: "{"
|
||||
int end_pos = rslt.Pos();
|
||||
bfr.Add_mid(src, i, end_pos);
|
||||
|
||||
@@ -35,6 +35,7 @@ public class Xoh_hzip_dict_ {
|
||||
, Tid__img_bare = 9
|
||||
, Tid__toc = 10
|
||||
, Tid__pgbnr = 11
|
||||
, Tid__media = 12
|
||||
;
|
||||
public static final String
|
||||
Key__timeline = "timeline"
|
||||
@@ -50,6 +51,7 @@ public class Xoh_hzip_dict_ {
|
||||
, Key__img_bare = "img_bare"
|
||||
, Key__toc = "toc"
|
||||
, Key__pgbnr = "pgbnr"
|
||||
, Key__media = "media"
|
||||
;
|
||||
public static final int Hzip__none = 0, Hzip__v1 = 1;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ import gplx.core.btries.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*; import gplx.xowa.htmls.core.wkrs.addons.medias.*;
|
||||
public class Xoh_pool_mgr__data {
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__toc, pool__timeline, pool__gallery;
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__toc, pool__timeline, pool__gallery, pool__media;
|
||||
public Xoh_pool_mgr__data() {
|
||||
pool__hdr = New_pool(new Xoh_hdr_data());
|
||||
pool__lnke = New_pool(new Xoh_lnke_data());
|
||||
@@ -31,6 +31,7 @@ public class Xoh_pool_mgr__data {
|
||||
pool__toc = New_pool(new Xoh_toc_data());
|
||||
pool__timeline = New_pool(new Xoh_timeline_data());
|
||||
pool__gallery = New_pool(new Xoh_gallery_data());
|
||||
pool__media = New_pool(new Xoh_media_data());
|
||||
}
|
||||
public Xoh_data_itm Get_by_tid(int tid) {
|
||||
Gfo_poolable_mgr pool = null;
|
||||
@@ -42,6 +43,7 @@ public class Xoh_pool_mgr__data {
|
||||
case Xoh_hzip_dict_.Tid__toc: pool = pool__toc; break;
|
||||
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
|
||||
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
|
||||
case Xoh_hzip_dict_.Tid__media: pool = pool__media; break;
|
||||
default: return null;
|
||||
}
|
||||
return (Xoh_data_itm)pool.Get_fast();
|
||||
|
||||
@@ -20,10 +20,10 @@ import gplx.core.btries.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*; import gplx.xowa.htmls.core.wkrs.addons.medias.*;
|
||||
public class Xoh_pool_mgr__hzip {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline, mkr__toc;
|
||||
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline, mkr__toc, mkr__media;
|
||||
public Xoh_escape_hzip Mw__escape() {return (Xoh_escape_hzip) mkr__escape.Get_fast();}
|
||||
public Xoh_xnde_hzip Mw__xnde() {return (Xoh_xnde_hzip) mkr__xnde.Get_fast();}
|
||||
public Xoh_hdr_hzip Mw__hdr() {return (Xoh_hdr_hzip) mkr__hdr.Get_fast();}
|
||||
@@ -36,6 +36,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
public Xoh_toc_hzip Mw__toc() {return (Xoh_toc_hzip) mkr__toc.Get_fast();}
|
||||
public Xoh_gallery_hzip Mw__gallery() {return (Xoh_gallery_hzip) mkr__gallery.Get_fast();}
|
||||
public Xoh_timeline_hzip Mw__timeline() {return (Xoh_timeline_hzip) mkr__timeline.Get_fast();}
|
||||
public Xoh_media_hzip Mw__media() {return (Xoh_media_hzip) mkr__media.Get_fast();}
|
||||
public void Init() {
|
||||
this.Reg_all(false, Hook__core, Hook__html, Hook__mw);
|
||||
}
|
||||
@@ -44,7 +45,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
Gfo_poolable_mgr mgr = (Gfo_poolable_mgr)mgr_obj;
|
||||
return (Xoh_hzip_wkr)mgr.Get_fast();
|
||||
}
|
||||
private void Reg_all(boolean mode_is_b256, int hook__core, int hook__html, int hook__mw) {
|
||||
private void Reg_all(boolean mode_is_b256, int hook__core, int hook__html, int hook__mw) { // SERIALIZED
|
||||
mkr__escape = Reg(New_hook_len2(mode_is_b256, hook__core, 0) , new Xoh_escape_hzip());
|
||||
mkr__xnde = Reg(New_hook_len1(mode_is_b256, hook__html) , new Xoh_xnde_hzip());
|
||||
mkr__hdr = Reg(New_hook_len2(mode_is_b256, hook__mw , 1) , new Xoh_hdr_hzip());
|
||||
@@ -55,6 +56,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
mkr__gly = Reg(New_hook_len2(mode_is_b256, hook__mw , 6) , new Xoh_gly_hzip());
|
||||
mkr__img_bare = Reg(New_hook_len2(mode_is_b256, hook__mw , 7) , new Xoh_img_bare_hzip());
|
||||
mkr__toc = Reg(New_hook_len2(mode_is_b256, hook__mw , 8) , new Xoh_toc_hzip());
|
||||
mkr__media = Reg(New_hook_len2(mode_is_b256, hook__mw , 9) , new Xoh_media_hzip());
|
||||
mkr__gallery = Reg(Xoh_gallery_data.Hook_bry , new Xoh_gallery_hzip());
|
||||
mkr__timeline = Reg(Xoh_timeline_data.Hook_bry , new Xoh_timeline_hzip());
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
|
||||
case Xoh_hzip_dict_.Tid__img: wkr = hctx.Pool_mgr__hzip().Mw__img(); break;
|
||||
case Xoh_hzip_dict_.Tid__img_bare: wkr = hctx.Pool_mgr__hzip().Mw__img_bare(); break;
|
||||
case Xoh_hzip_dict_.Tid__toc: wkr = hctx.Pool_mgr__hzip().Mw__toc(); break;
|
||||
case Xoh_hzip_dict_.Tid__media: wkr = hctx.Pool_mgr__hzip().Mw__media(); break;
|
||||
default: throw Err_.new_unhandled(data.Tid());
|
||||
}
|
||||
wkr.Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
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.core.wkrs.addons.medias; 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.addons.*;
|
||||
import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.styles.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.lnkis.anchs.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
public class Xoh_media_data implements Xoh_data_itm, Gfh_style_wkr {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__media;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public boolean Rng_valid() {return rng_valid;} private boolean rng_valid;
|
||||
public boolean Is_audio() {return is_audio;} private boolean is_audio;
|
||||
public boolean Aud_noicon() {return aud_noicon;} private boolean aud_noicon;
|
||||
public int Aud_width() {return aud_width;} private int aud_width;
|
||||
public int Lnki_ttl_bgn() {return lnki_ttl_bgn;} private int lnki_ttl_bgn;
|
||||
public int Lnki_ttl_end() {return lnki_ttl_end;} private int lnki_ttl_end;
|
||||
public Xoh_img_data Img_data() {return img_data;} private final Xoh_img_data img_data = new Xoh_img_data();
|
||||
public void Clear() {
|
||||
this.src_bgn = this.src_end = this.lnki_ttl_bgn = this.lnki_ttl_end = aud_width = -1;
|
||||
this.rng_valid = true;
|
||||
this.is_audio = this.aud_noicon = false;
|
||||
img_data.Clear();
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag media_div_head, Gfh_tag unused) {
|
||||
this.Clear();
|
||||
this.src_bgn = media_div_head.Src_bgn();
|
||||
|
||||
// peek media_div_tail; needed b/c audio div may have 1 or 2 divs
|
||||
Gfh_tag media_div_tail = tag_rdr.Tag__peek_fwd_tail(Gfh_tag_.Id__div);
|
||||
this.src_end = media_div_tail.Src_end();
|
||||
|
||||
// move div_0_head and get anch_0_head; EX: <div class='xowa_media_div'> ... <div><a>
|
||||
Gfh_tag div_0_head = tag_rdr.Tag__move_fwd_head(); if (div_0_head.Name_id() != Gfh_tag_.Id__div) return Log_failure(tag_rdr, "hzip.media:missing.div_0");
|
||||
Gfh_tag anch_0_head = tag_rdr.Tag__move_fwd_head(); if (anch_0_head.Name_id() != Gfh_tag_.Id__a) return Log_failure(tag_rdr, "hzip.media:missing.anch_0");
|
||||
|
||||
// check cls; if "xowa_media_play", then audio; else video
|
||||
if (anch_0_head.Atrs__cls_eq(Xoh_anch_cls_.Bry__media_play)) {
|
||||
if (!Parse_aud(tag_rdr, src, anch_0_head)) return false;
|
||||
}
|
||||
else {
|
||||
if (!Parse_vid(hdoc_wkr, hctx, tag_rdr, src, anch_0_head)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
private boolean Parse_aud(Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag anch_0_head) {
|
||||
this.is_audio = true;
|
||||
|
||||
// get lnki_ttl from xowa_title; EX: xowa_title="A.png"
|
||||
Gfh_atr xowa_title_atr = anch_0_head.Atrs__get_by_or_fail(Xoh_img_data.Bry__atr__xowa_title);
|
||||
this.lnki_ttl_bgn = xowa_title_atr.Val_bgn();
|
||||
this.lnki_ttl_end = xowa_title_atr.Val_end();
|
||||
|
||||
// get width from style='max-width:'
|
||||
Gfh_atr style_atr = anch_0_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__style);
|
||||
Gfh_style_parser_.Parse(src, style_atr.Val_bgn(), style_atr.Val_end(), this); // parse for width; note width only appears if items_per_row is specified
|
||||
|
||||
// move to div_0_tail
|
||||
tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
|
||||
|
||||
// check if div_1 exists (info icon)
|
||||
Gfh_tag div_1_head = tag_rdr.Tag__peek_fwd_head(Gfh_tag_.Id__div);
|
||||
if ( div_1_head.Name_id() == Gfh_tag_.Id__eos // <div> not found
|
||||
|| div_1_head.Src_bgn() > src_end // <div> is after </div.xowa_media_div>
|
||||
) {
|
||||
aud_noicon = true;
|
||||
}
|
||||
|
||||
// move rdr to media_div_tail.end
|
||||
tag_rdr.Pos_(src_end);
|
||||
return true;
|
||||
}
|
||||
private boolean Parse_vid(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag anch_0_head) {
|
||||
this.is_audio = false;
|
||||
|
||||
// get lnki_ttl from xowa_title; EX: xowa_title="A.png"
|
||||
img_data.Init_by_parse(hdoc_wkr, hctx, tag_rdr, src, anch_0_head, null);
|
||||
|
||||
// move to div_0_tail
|
||||
tag_rdr.Tag__move_fwd_tail(Gfh_tag_.Id__div);
|
||||
|
||||
// check if div_1 exists (info icon)
|
||||
tag_rdr.Tag__move_fwd_head(Gfh_tag_.Id__div);
|
||||
// move rdr to media_div_tail.end
|
||||
tag_rdr.Pos_(src_end);
|
||||
return true;
|
||||
}
|
||||
public void Init_by_decode(boolean is_audio, int aud_width, boolean aud_noicon, int lnki_ttl_bgn, int lnki_ttl_end) {
|
||||
this.is_audio = is_audio; this.aud_width = aud_width; this.aud_noicon = aud_noicon;
|
||||
this.lnki_ttl_bgn = lnki_ttl_bgn; this.lnki_ttl_end = lnki_ttl_end;
|
||||
}
|
||||
public boolean On_atr(byte[] src, int atr_idx, int atr_val_bgn, int atr_val_end, int itm_bgn, int itm_end, int key_bgn, int key_end, int val_bgn, int val_end) {
|
||||
if (Bry_.Match(src, key_bgn, key_end, Style__max_width)) { // 'max-width'
|
||||
if (aud_width == -1) {
|
||||
aud_width = Bry_.To_int_or__lax(src, val_bgn, val_end, -1);
|
||||
return true;
|
||||
} // else if already set, fall-thru to below
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean Log_failure(Gfh_tag_rdr tag_rdr, String msg, Object... args) {
|
||||
tag_rdr.Err_wkr().Warn(msg, args);
|
||||
return false;
|
||||
}
|
||||
public static final byte[] Hook_bry = Bry_.new_a7(" class=\"media mw-media");
|
||||
private static final byte[] Style__max_width = Bry_.new_a7("max-width");
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_media_data rv = new Xoh_media_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
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.core.wkrs.addons.medias; 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.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.encoders.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.imgs.*;
|
||||
public class Xoh_media_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
private final Xoh_img_hzip img_hzip = new Xoh_img_hzip();
|
||||
private final Xoh_media_wtr wtr = new Xoh_media_wtr();
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__media;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__media;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_media_data data = (Xoh_media_data)data_obj;
|
||||
if (!data.Rng_valid()) {
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
return this;
|
||||
}
|
||||
|
||||
// flags
|
||||
boolean is_audio = flag_bldr.Set_as_bool(Flag__is_audio, data.Is_audio());
|
||||
flag_bldr.Set(Flag__noicon, data.Aud_noicon());
|
||||
|
||||
// hzip
|
||||
bfr.Add(hook);
|
||||
Gfo_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
|
||||
if (is_audio) {
|
||||
bfr.Add_hzip_int(2, data.Aud_width());
|
||||
bfr.Add_hzip_mid(src, data.Lnki_ttl_bgn(), data.Lnki_ttl_end());
|
||||
}
|
||||
else {
|
||||
img_hzip.Encode1(bfr, hdoc_wkr, hctx, hpg, Bool_.N, src, data.Img_data());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
// flags
|
||||
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
|
||||
boolean is_audio = flag_bldr.Get_as_bool(Flag__is_audio);
|
||||
boolean aud_noicon = flag_bldr.Get_as_bool(Flag__noicon);
|
||||
|
||||
// lnki_ttl
|
||||
int aud_width = -1;
|
||||
int lnki_ttl_bgn = -1, lnki_ttl_end = -1;
|
||||
if (is_audio) {
|
||||
aud_width = rdr.Read_hzip_int(2);
|
||||
lnki_ttl_bgn = rdr.Pos(); lnki_ttl_end = rdr.Find_fwd_lr();
|
||||
}
|
||||
|
||||
// write
|
||||
Xoh_media_data data = (Xoh_media_data)data_itm;
|
||||
data.Init_by_decode(is_audio, aud_width, aud_noicon, lnki_ttl_bgn, lnki_ttl_end);
|
||||
if (!is_audio) {
|
||||
img_hzip.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, rdr.Pos(), src_end, data.Img_data());
|
||||
img_hzip.Wtr().Init_by_decode(hpg, hctx, src, data.Img_data());
|
||||
}
|
||||
|
||||
wtr.Write(bfr, hpg, hctx, src, data, img_hzip.Wtr());
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_media_hzip rv = new Xoh_media_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(1, 1);
|
||||
private static final int // SERIALIZED
|
||||
Flag__is_audio = 0
|
||||
, Flag__noicon = 1
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
//namespace gplx.xowa.htmls.core.wkrs.addons.medias {
|
||||
// import org.junit.*; using gplx.core.tests;
|
||||
// using gplx.langs.htmls; using gplx.xowa.htmls.core.makes.tests;
|
||||
// public class Xoh_media_hzip_tst {
|
||||
// private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
// @Test public void Video__full__ogv__width_y() { // EX: [[File:A.ogv|320px|bcd|alt=efg]]; DATE:2016-08-05
|
||||
// fxt.Test__bicode // NOTE: caption not rendered; may need to reconsider;
|
||||
// ( "*!!aA.ogv~)$bA.ogv~efg~", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class='xowa_media_div'>"
|
||||
// , "<div>"
|
||||
// + "<a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'>"
|
||||
// + "<img data-xowa-title='A.ogv' data-xoimg='0|320|-1|-1|-1|-1' src='' width='0' height='0' alt='efg'>"
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "<div>"
|
||||
// + "<a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:318px;max-width:320px;' alt='Play sound'>"
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Video__full__ogv__width_n() { // EX: [[File:A.ogv]]; DATE:2016-08-05
|
||||
// fxt.Test__bicode
|
||||
// ( "*!!aA.ogv~!A.ogv~efg~", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class='xowa_media_div'>"
|
||||
// , "<div>"
|
||||
// + "<a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'>"
|
||||
// + "<img data-xowa-title='A.ogv' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt='efg'>"
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "<div>"
|
||||
// + "<a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'>" // NOTE: default to 220px if no w specified
|
||||
// + "</a>"
|
||||
// + "</div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Audio__thumb() {
|
||||
// String html = Gfh_utl.Replace_apos(String_.Concat_lines_nl
|
||||
// ( "<div class='thumb tright'>"
|
||||
// , " <div class='thumbinner' style='width:11px;'>"
|
||||
// , " <div class='xowa_media_div'>"
|
||||
// , "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:318px;max-width:320px;' alt='Play sound'></a></div>"
|
||||
// , "<div><a href='/wiki/File:A.oga' class='xowa_media_info' title='About this file'></a></div>"
|
||||
// , "</div>"
|
||||
// , " <div class='thumbcaption'>"
|
||||
// , "<div class='magnify'><a href='/wiki/File:A.oga' class='internal' title='Enlarge'></a></div>b"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
//
|
||||
// String hzip = String_.Concat_lines_nl
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div class=\"thumbinner\" style=\"width:11px;\">"
|
||||
// , " ~*#$bA.oga"
|
||||
// , " <div class=\"thumbcaption\">"
|
||||
// , "<div class=\"magnify\">$|%%,)A.ogaEnlarge</div>b"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// );
|
||||
// fxt.Test__bicode(hzip, html);
|
||||
// }
|
||||
// @Test public void Audio__noicon() {
|
||||
// String html = Gfh_utl.Replace_apos(String_.Concat_lines_nl
|
||||
// ( " <div class='xowa_media_div'>"
|
||||
// , "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:318px;max-width:320px;' alt='Play sound'></a></div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
//
|
||||
// String hzip = String_.Concat_lines_nl
|
||||
// ( " ~*$$bA.oga"
|
||||
// );
|
||||
// fxt.Test__bicode(hzip, html);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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.core.wkrs.addons.medias; 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.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
|
||||
import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_media_wtr {
|
||||
private final Bfr_arg__bry lnki_ttl = Bfr_arg__bry.New_empty();
|
||||
public void Write(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm, Xoh_img_wtr img_wtr) {
|
||||
// make fsdb_itm
|
||||
hpg.Img_mgr().Make_aud();
|
||||
|
||||
// set props and write
|
||||
Xoh_media_data data = (Xoh_media_data)data_itm;
|
||||
if (data.Is_audio()) {
|
||||
lnki_ttl.Set_by_mid(src, data.Lnki_ttl_bgn(), data.Lnki_ttl_end());
|
||||
if (data.Aud_noicon())
|
||||
fmt__noicon.Bfr_arg__clear();
|
||||
else
|
||||
fmt__noicon.Args_(lnki_ttl);
|
||||
|
||||
int aud_width = data.Aud_width();
|
||||
fmt__audio.Bld_many(bfr, lnki_ttl, aud_width - 2, aud_width, fmt__noicon);
|
||||
}
|
||||
else {
|
||||
Xoh_img_data img_data = data.Img_data();
|
||||
lnki_ttl.Set_by_val(img_data.Img_src().File_ttl_bry());
|
||||
|
||||
// lnki_w
|
||||
int lnki_w = img_data.Img_xoimg().Lnki_w();
|
||||
if (lnki_w == -1) lnki_w = Xof_img_size.Thumb_width_ogv; // no width; default to 220; EX: [[File:A.ogv]]
|
||||
|
||||
fmt__video.Bld_many(bfr, img_wtr, lnki_ttl, lnki_w - 2, lnki_w);
|
||||
}
|
||||
}
|
||||
|
||||
private final Bfr_arg__bry_fmt fmt__noicon = new Bfr_arg__bry_fmt(Bry_fmt.Auto_nl_apos("\n<div><a href='/wiki/File:~{lnki_ttl}' class='xowa_media_info' title='About this file'></a></div>"));
|
||||
private final Bry_fmt
|
||||
fmt__audio = Bry_fmt.Auto_nl_apos
|
||||
( "<div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='~{lnki_ttl}' class='xowa_media_play' style='width:~{a_width}px;max-width:~{a_max_width}px;' alt='Play sound'></a></div>~{noicon}"
|
||||
, "</div>"
|
||||
)
|
||||
, fmt__video = Bry_fmt.Auto_nl_apos
|
||||
( "<div class='xowa_media_div'>"
|
||||
, "<div>~{div1_img}</div>"
|
||||
, "<div><a href='' xowa_title='~{lnki_ttl}' class='xowa_media_play' style='width:~{a_width}px;max-width:~{a_max_width}px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.wkrs.bfr_args; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*;
|
||||
public class Bfr_arg__hatr_arg implements Bfr_arg_clearable {
|
||||
private final byte[] atr_bgn;
|
||||
private final byte[] atr_bgn;
|
||||
private Bfr_arg_clearable val_as_arg;
|
||||
public Bfr_arg__hatr_arg(byte[] key) {this.atr_bgn = Bfr_arg__hatr_.Bld_atr_bgn(key);}
|
||||
public Bfr_arg__hatr_arg Set_by_arg(Bfr_arg_clearable v) {val_as_arg = v; return this;}
|
||||
@@ -36,5 +36,5 @@ class Bfr_arg__html_atr__empty implements Bfr_arg_clearable {
|
||||
public void Bfr_arg__clear() {}
|
||||
public boolean Bfr_arg__missing() {return false;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {}
|
||||
public static final Bfr_arg__html_atr__empty Instance = new Bfr_arg__html_atr__empty(); Bfr_arg__html_atr__empty() {}
|
||||
public static final Bfr_arg__html_atr__empty Instance = new Bfr_arg__html_atr__empty(); Bfr_arg__html_atr__empty() {}
|
||||
}
|
||||
|
||||
@@ -34,4 +34,5 @@ public class Bfr_arg__hatr_id implements Bfr_arg_clearable {
|
||||
}
|
||||
public static Bfr_arg__hatr_id New_id(String v) {return new Bfr_arg__hatr_id(gplx.langs.htmls.Gfh_atr_.Bry__id, Bry_.new_u8(v));}
|
||||
public static Bfr_arg__hatr_id New_id(byte[] v) {return new Bfr_arg__hatr_id(gplx.langs.htmls.Gfh_atr_.Bry__id, v);}
|
||||
public static final int Id__ignore = -1;
|
||||
}
|
||||
|
||||
@@ -95,15 +95,6 @@ public class Xoh_img_hzip__dump__basic__tst {
|
||||
, "<a href='/wiki/File:A.png' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='cls1' alt='abc'></a>"
|
||||
);
|
||||
}
|
||||
@Test public void Video() { // [[File:A.ogv]]
|
||||
fxt.Test__bicode
|
||||
( "%|E9eA.ogv~!A.ogv~~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='0|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Imap() {
|
||||
fxt.Test__bicode
|
||||
( "~%}#Pa$A.png~#:#S#+\""
|
||||
|
||||
@@ -16,10 +16,10 @@ 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.core.wkrs.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.args.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.xtns.pagebanners.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
private final Bfr_arg_clearable[] arg_ary;
|
||||
private final Bfr_arg__hatr_arg img_xowa_image = new Bfr_arg__hatr_arg(Xoh_img_xoimg_data.Bry__data_xowa_image);
|
||||
@@ -38,7 +38,7 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
;
|
||||
private final Bfr_arg__pgbnr img_pgbnr_atrs = new Bfr_arg__pgbnr();
|
||||
private boolean img_is_vid; private boolean img_wo_anch;
|
||||
private byte[] xowa_root_dir;
|
||||
private int div_w;
|
||||
public Xoh_img_wtr() {
|
||||
arg_ary = new Bfr_arg_clearable[]
|
||||
{ anch_href, anch_rel, anch_cls, anch_title, anch_xowa_title
|
||||
@@ -47,33 +47,35 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
};
|
||||
}
|
||||
public Xof_fsdb_itm Fsdb_itm() {return fsdb_itm;} private Xof_fsdb_itm fsdb_itm;
|
||||
public Xoh_img_wtr Anch_cls_(byte[] v) {anch_cls.Set_by_bry(v); return this;}
|
||||
public Xoh_img_wtr Img_id_(int uid) {img_id.Set(uid); return this;}
|
||||
public Xoh_img_wtr Clear() {
|
||||
for (Bfr_arg_clearable arg : arg_ary)
|
||||
arg.Bfr_arg__clear();
|
||||
vid_play_id.Bfr_arg__clear();
|
||||
img_imap_usemap.Bfr_arg__clear();
|
||||
img_is_vid = false; img_wo_anch = false;
|
||||
div_w = -1;
|
||||
return this;
|
||||
}
|
||||
public Xoh_img_wtr Anch_cls_(byte[] v) {anch_cls.Set_by_bry(v); return this;}
|
||||
public Xoh_img_wtr Img_id_(int uid) {img_id.Set(uid); return this;}
|
||||
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_img_data data) {
|
||||
Init_by_decode(hpg, hctx, src, data);
|
||||
this.Bfr_arg__add(bfr);
|
||||
}
|
||||
private static final byte[] Bry__qarg__esc = Bry_.new_a7("%3F");
|
||||
public void Init_html(int html_w, int html_h, byte[] src_bry) {
|
||||
img_w.Set_by_int(html_w);
|
||||
img_h.Set_by_int(html_h);
|
||||
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
|
||||
img_src.Set_by_bry(src_bry);
|
||||
this.div_w = html_w;
|
||||
}
|
||||
private void Init_xoimg(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] lnki_ttl, Xoh_img_xoimg_data img_xowa_image) {
|
||||
fsdb_itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, hpg.Wiki().Domain_itm().Abrv_xo(), lnki_ttl, Xop_lnki_type.To_flag(img_xowa_image.Lnki_type()), img_xowa_image.Lnki_upright(), img_xowa_image.Lnki_w(), img_xowa_image.Lnki_h(), img_xowa_image.Lnki_time(), img_xowa_image.Lnki_page(), Xof_patch_upright_tid_.Tid_all);
|
||||
hctx.File__mgr().Find(hpg.Wiki(), hpg.Url_bry_safe(), fsdb_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
|
||||
this.Init_html(fsdb_itm.Html_w(), fsdb_itm.Html_h(), fsdb_itm.Html_view_url().To_http_file_bry());
|
||||
this.div_w = fsdb_itm.Lnki_w();
|
||||
}
|
||||
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;
|
||||
@@ -109,7 +111,6 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
|| Bry_.Len_gt_0(file_ttl_bry)) // regular anch with image
|
||||
anch_xowa_title.Set_by_bry(file_ttl_bry);
|
||||
img_xowa_title.Set_by_bry(file_ttl_bry);
|
||||
xowa_root_dir = hctx.Fsys__root();
|
||||
img_alt.Set_by_mid_or_empty(src, data.Img_alt_bgn(), data.Img_alt_end());
|
||||
img_cls.Set_by_arg(data.Img_cls());
|
||||
if (data.Img_imap_idx() != -1) img_imap_usemap.Set(data.Img_imap_idx());
|
||||
@@ -124,10 +125,14 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
if (img_wo_anch)
|
||||
img_wo_anch_fmtr.Bld_bfr_many(bfr, img_id, img_xowa_title, img_xowa_image, img_src, img_w, img_h, img_cls, img_alt, img_imap_usemap);
|
||||
else {
|
||||
if (img_is_vid) bfr.Add(Vid__bry__bgn);
|
||||
if (img_is_vid) {
|
||||
bfr.Add(Vid__bry__bgn);
|
||||
}
|
||||
img_fmtr.Bld_bfr_many(bfr, (Object[])arg_ary);
|
||||
if (img_is_vid)
|
||||
vid_fmtr.Bld_bfr_many(bfr, vid_play_id, anch_xowa_title, xowa_root_dir, 218, 220); // TODO_OLD: hardcode widths; need to update via js from fsdb
|
||||
if (img_is_vid) {
|
||||
if (div_w <= 0) div_w = Xof_img_size.Thumb_width_img; // if no div_w, default to 220;
|
||||
vid_fmt.Bld_many(bfr, vid_play_id, anch_xowa_title, div_w - 2, div_w);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
@@ -140,8 +145,12 @@ public class Xoh_img_wtr implements Bfr_arg, Xoh_wtr_itm {
|
||||
, img_wo_anch_fmtr = Bry_fmtr.new_
|
||||
( "<img~{img_id}~{img_xowa_title}~{img_xowa_image}~{img_src}~{img_w}~{img_h}~{img_cls}~{img_alt}~{img_imap_usemap}>"
|
||||
, "img_id", "img_xowa_title", "img_xowa_image", "img_src", "img_w", "img_h", "img_cls", "img_alt", "img_imap_usemap")
|
||||
, vid_fmtr = Bry_fmtr.new_
|
||||
( "</div>\n<div><a~{vid_play_id} href=\"\"~{xowa_title} class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>\n</div>"
|
||||
, "vid_play_id", "xowa_title", "xowa_root_dir", "width_neg_2", "width") // NOTE: default to href='file:///'; will be filled in dynamically
|
||||
;
|
||||
private final Bry_fmt
|
||||
vid_fmt = Bry_fmt.Auto_nl_apos
|
||||
( "</div>"
|
||||
, "<div><a~{vid_play_id} href=''~{xowa_title} class='xowa_media_play' style='width:~{a_width}px;max-width:~{a_max_width}px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
);
|
||||
private static final byte[] Bry__qarg__esc = Bry_.new_a7("%3F");
|
||||
}
|
||||
|
||||
@@ -22,31 +22,38 @@ public class Xoh_anch_cls_ {
|
||||
public static final byte // SERIALIZED
|
||||
Tid__image = 0 // EX: [[File:A.png]] -> "<a class='image'>"
|
||||
, Tid__none = 1 // EX: [[File:A.png|link=A]] -> "<a class=''>"
|
||||
// , Tid__xowa_media_play = 2 // EX: [[File:A.ogg]] -> "<a class='xowa_media_play'>"
|
||||
;
|
||||
public static final String
|
||||
Str__image = "image"
|
||||
// , Str__xowa_media_play = "xowa_media_play"
|
||||
;
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Bry__image = Bry_.new_a7(Str__image)
|
||||
// , Bry__xowa_media_play = Bry_.new_a7(Str__xowa_media_play)
|
||||
;
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Html__image = Bry_.Add(Gfh_bldr_.Bry__cls__nth, Bry__image)
|
||||
// , Html__xowa_media_play = Bry_.Add(Gfh_bldr_.Bry__cls__nth, Bry__xowa_media_play)
|
||||
;
|
||||
public static final Btrie_slim_mgr Trie = Btrie_slim_mgr.cs()
|
||||
.Add_bry_byte(Bry__image , Tid__image)
|
||||
public static final Btrie_slim_mgr Trie = Btrie_slim_mgr.cs()
|
||||
.Add_bry_byte(Bry__image , Tid__image)
|
||||
// .Add_bry_byte(Bry__xowa_media_play , Tid__xowa_media_play)
|
||||
;
|
||||
public static byte[] To_html(int tid) {
|
||||
switch (tid) {
|
||||
case Xoh_anch_cls_.Tid__none: return Bry_.Empty;
|
||||
case Xoh_anch_cls_.Tid__image: return Html__image;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
case Xoh_anch_cls_.Tid__none: return Bry_.Empty;
|
||||
case Xoh_anch_cls_.Tid__image: return Html__image;
|
||||
// case Xoh_anch_cls_.Tid__xowa_media_play: return Html__xowa_media_play;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static byte[] To_val(int tid) {
|
||||
switch (tid) {
|
||||
case Xoh_anch_cls_.Tid__none: return Bry_.Empty;
|
||||
case Xoh_anch_cls_.Tid__image: return Bry__image;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
case Xoh_anch_cls_.Tid__none: return Bry_.Empty;
|
||||
case Xoh_anch_cls_.Tid__image: return Bry__image;
|
||||
// case Xoh_anch_cls_.Tid__xowa_media_play: return Bry__xowa_media_play;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.btries.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.apps.urls.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.entitys.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkes.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_lnke_html {
|
||||
private static final byte[] Disabled_button = Bry_.new_a7("⊗");
|
||||
private final Gfo_url_encoder href_encoder = Gfo_url_encoder_.New__html_href_quotes().Make();
|
||||
private final Gfo_url_encoder gfs_encoder = Gfo_url_encoder_.New__gfs().Make();
|
||||
public void Write_html(Bry_bfr bfr, Xow_html_mgr html_mgr, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke) {
|
||||
int href_bgn = lnke.Lnke_href_bgn(), href_end = lnke.Lnke_href_end(); boolean proto_is_xowa = lnke.Proto_tid() == Gfo_protocol_itm.Tid_xowa;
|
||||
byte lnke_type = Calc_type(lnke);
|
||||
@@ -59,7 +60,7 @@ public class Xoh_lnke_html {
|
||||
else { // xowa or regular; EX: http://a.org
|
||||
if (proto_is_xowa) {
|
||||
bfr.Add(Xop_lnke_wkr.Bry_xowa_protocol);
|
||||
gplx.langs.htmls.encoders.Gfo_url_encoder_.Gfs.Encode(bfr, src, href_bgn, href_end);
|
||||
gfs_encoder.Encode(bfr, src, href_bgn, href_end);
|
||||
return false;
|
||||
}
|
||||
else { // regular; add href
|
||||
|
||||
@@ -17,8 +17,8 @@ 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 gplx.xowa.files.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public interface Xoh_file_img_wkr {
|
||||
void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid
|
||||
public interface Xoh_file_fmtr {
|
||||
void Add_full_img(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid
|
||||
, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
|
||||
);
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
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.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 gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*; import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_file_fmtr__basic implements Xoh_file_fmtr {
|
||||
private final Xoh_arg_img_core img_atrs = new Xoh_arg_img_core__basic();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(128);
|
||||
private final Bfr_arg__hatr_id div2_id_atr = Bfr_arg__hatr_id.New_id("xowa_file_div_"), play_id_atr = Bfr_arg__hatr_id.New_id("xowa_file_play_");
|
||||
|
||||
public void Add_media(Bry_bfr bfr, boolean mode_is_hdump, byte[] a_href, byte[] a_title, byte[] a_html) {
|
||||
if (mode_is_hdump) a_href = Bry_.Empty;
|
||||
fmtr_full_media.Bld_many(bfr, a_href, a_title, a_html);
|
||||
}
|
||||
private final Bry_fmt fmtr_full_media = Bry_fmt.Auto("<a href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\">~{html}\n</a>");
|
||||
|
||||
@gplx.Virtual public void Add_full_img(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid
|
||||
, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
|
||||
) {
|
||||
// init atrs
|
||||
img_atrs.Init(uid, img_src, img_w, img_h);
|
||||
byte[] img_cls_atr = Xoh_img_cls_.To_html(img_cls, img_cls_other);
|
||||
|
||||
// fmt
|
||||
if (Bry_.Len_eq_0(a_href)) // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fmtr_full_img__anch_n.Bld_many(bfr
|
||||
, uid, img_alt, img_atrs, img_cls_atr);
|
||||
else
|
||||
fmtr_full_img__anch_y.Bld_many(bfr
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, uid, img_alt, img_atrs, img_cls_atr);
|
||||
}
|
||||
private final Bry_fmt fmtr_full_img__anch_y = Bry_fmt.Auto
|
||||
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"
|
||||
+ "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} /></a>"
|
||||
);
|
||||
private final Bry_fmt fmtr_full_img__anch_n = Bry_fmt.Auto
|
||||
( "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} />");
|
||||
|
||||
public byte[] Bld_thumb_part_img(Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid, byte[] lnki_ttl, byte[] a_href, byte[] img_src, byte[] img_alt) {
|
||||
byte[] a_title_atr = Gfh_atr_.Make(tmp_bfr, Gfh_atr_.Bry__title, xfer_itm.Lnki_ttl());
|
||||
Add_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, a_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image
|
||||
, Xoh_lnki_consts.Tid_a_rel_none, a_title_atr
|
||||
, Xoh_file_fmtr__basic.Escape_xowa_title(lnki_ttl) // NOTE: must use lnki_ttl, not xfer_itm.Lnki_ttl(); 1st observes case-sensitivity; EX:"a.ogv"; PAGE:de.d:fappieren DATE:2016-06-23
|
||||
, xfer_itm.Html_w(), xfer_itm.Html_h(), img_src, img_alt, Xoh_img_cls_.Tid__none, null);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
public void Add_thumb_core(Bry_bfr bfr, boolean mode_is_hdump, byte[] div1_halign, int div2_id, int div2_width, byte[] div2_content) {
|
||||
div2_id_atr.Set(mode_is_hdump ? Bfr_arg__hatr_id.Id__ignore : div2_id);
|
||||
fmtr_thumb_core.Bld_many(bfr, div1_halign, div2_id_atr, div2_width, div2_content);
|
||||
}
|
||||
private final Bry_fmt fmtr_thumb_core = Bry_fmt.Auto(String_.Concat_lines_nl_skip_last // REF.MW: Linker.php|makeImageLink2
|
||||
( "<div class=\"thumb t~{div1_halign}\">"
|
||||
, " <div~{div2_id} class=\"thumbinner\" style=\"width:~{div2_width}px;\">"
|
||||
, "~{div3_content}"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
public byte[] Bld_thumb_part_caption(byte[] magnify_btn, byte[] caption) {return fmtr_thumb_part_caption.Bld_many_to_bry(tmp_bfr, magnify_btn, caption);}
|
||||
private final Bry_fmt fmtr_thumb_part_caption = Bry_fmt.Auto(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class=\"thumbcaption\">~{magnify_btn}~{caption}"
|
||||
, " </div>"
|
||||
));
|
||||
|
||||
public byte[] Bld_thumb_file_image(byte[] thumb_image, byte[] caption, byte[] alt) {return fmtr_thumb_file_image.Bld_many_to_bry(tmp_bfr, thumb_image, caption, alt);}
|
||||
private final Bry_fmt fmtr_thumb_file_image = Bry_fmt.Auto(" ~{thumb_image}~{caption}~{alt}");
|
||||
|
||||
@gplx.Virtual public byte[] Bld_thumb_file_audio(byte[] caption, byte[] alt, byte[] play_btn, byte[] info_btn) {return fmtr_thumb_file_audio.Bld_many_to_bry(tmp_bfr, play_btn, info_btn, caption, alt);}
|
||||
private Bry_fmt fmtr_thumb_file_audio = Bry_fmt.Auto(String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">~{play_btn}~{info_btn}"
|
||||
, " </div>~{caption}~{alt}"
|
||||
));
|
||||
|
||||
@gplx.Virtual public byte[] Bld_thumb_file_video(byte[] caption, byte[] alt, byte[] play_btn, byte[] vid_img) {return fmtr_thumb_file_video.Bld_many_to_bry(tmp_bfr, vid_img, play_btn, caption, alt);}
|
||||
private final Bry_fmt fmtr_thumb_file_video = Bry_fmt.Auto(String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>~{vid_img}"
|
||||
, " </div>~{play_btn}"
|
||||
, " </div>~{caption}~{alt}"
|
||||
));
|
||||
|
||||
public Bry_fmt Fmt_thumb_part_alt() {return fmt__thumb_part_alt;} private final Bry_fmt fmt__thumb_part_alt = Bry_fmt.Auto
|
||||
(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">~{html}"
|
||||
, " </div>"
|
||||
));
|
||||
|
||||
public byte[] Bld_thumb_part_magnify(byte[] a_href, byte[] a_title) {
|
||||
return fmtr_thumb_part_magnify.Bld_many_to_bry(tmp_bfr, a_href, a_title);
|
||||
}
|
||||
private final Bry_fmt fmtr_thumb_part_magnify = Bry_fmt.Auto("\n<div class=\"magnify\"><a href=\"~{a_href}\" class=\"internal\" title=\"~{a_title}\"></a></div>");
|
||||
|
||||
public byte[] Bld_thumb_part_info(byte[] a_href) {
|
||||
return fmtr_thumb_part_info.Bld_many_to_bry(tmp_bfr, a_href);
|
||||
}
|
||||
private final Bry_fmt fmtr_thumb_part_info = Bry_fmt.Auto("\n<div><a href=\"~{a_href}\" class=\"xowa_media_info\" title=\"About this file\"></a></div>");
|
||||
|
||||
public byte[] Bld_thumb_part_play(boolean mode_is_hdump, int uid, byte[] a_href, byte[] a_xowa_title, int a_width, int a_max_width) {
|
||||
if (mode_is_hdump) {
|
||||
play_id_atr.Set(Bfr_arg__hatr_id.Id__ignore);
|
||||
a_href = Bry_.Empty;
|
||||
if (a_max_width == -1) {
|
||||
a_width = 218; a_max_width = 220; // NOTE: hardcode widths; hdump will get actual file with from fsdb
|
||||
}
|
||||
}
|
||||
else
|
||||
play_id_atr.Set(uid);
|
||||
return fmtr_thumb_part_play.Bld_many_to_bry(tmp_bfr, play_id_atr, a_href, a_xowa_title, a_width, a_max_width);
|
||||
}
|
||||
private final Bry_fmt fmtr_thumb_part_play = Bry_fmt.Auto
|
||||
("\n<div><a~{id} href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\" class=\"xowa_media_play\" style=\"width:~{a_width}px;max-width:~{a_max_width}px;\" alt=\"Play sound\"></a></div>");
|
||||
|
||||
public static byte[] Escape_xowa_title(byte[] lnki_ttl) {
|
||||
return Xoa_ttl.Replace_spaces(gplx.langs.htmls.encoders.Gfo_url_encoder_.Href_quotes.Encode(lnki_ttl)); // must encode xowa_title, particularly quotes; EX: xowa_title="A"b.png"; PAGE:en.w:Earth DATE:2015-11-27
|
||||
}
|
||||
public static byte[] Escape_xowa_title_v2(byte[] lnki_ttl) {
|
||||
return Xoa_ttl.Replace_spaces(gplx.langs.htmls.encoders.Gfo_url_encoder_.Href_quotes_v2.Encode(lnki_ttl)); // must encode xowa_title, particularly quotes; EX: xowa_title="A"b.png"; PAGE:en.w:Earth DATE:2015-11-27
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
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.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 gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_file_fmtr__hdump extends Xoh_file_fmtr__basic { private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(128);
|
||||
@Override public void Add_full_img(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm
|
||||
, int uid, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other) {
|
||||
|
||||
// init data_xowa_title / data_xowa_image; EX: "xowa_title='A.png'"; "xowa_image='1|220|440|-1|-1|-1'"
|
||||
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, a_xowa_title);
|
||||
byte[] data_xowa_image = Bld_xowa_image_data(tmp_bfr, xfer_itm.Lnki_type(), xfer_itm.Lnki_w(), xfer_itm.Lnki_h(), xfer_itm.Lnki_upright(), xfer_itm.Lnki_time(), xfer_itm.Lnki_page());
|
||||
|
||||
// bld bfr
|
||||
if (Bry_.Len_eq_0(a_href))
|
||||
Add_anch_n(bfr, data_xowa_title, data_xowa_image, img_cls, img_cls_other, img_alt, Bry_.Empty);
|
||||
else {
|
||||
if (a_href_is_file) a_href = Bry_.Empty;
|
||||
fmt__anch_y.Bld_many(bfr
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, data_xowa_title, data_xowa_image, Xoh_img_cls_.To_html(img_cls, img_cls_other), Gfh_utl.Escape_html_as_bry(img_alt)
|
||||
);
|
||||
}
|
||||
}
|
||||
public static void Add_anch_n(Bry_bfr bfr, byte[] data_xowa_title, byte[] data_xowa_image, byte img_cls, byte[] img_cls_other, byte[] img_alt, byte[] img_xtra_atrs) {
|
||||
fmt__anch_n.Bld_many(bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.To_html(img_cls, img_cls_other), Gfh_utl.Escape_html_as_bry(img_alt), img_xtra_atrs);
|
||||
}
|
||||
public static byte[] Bld_xowa_image_data(Bry_bfr bfr, byte tid, int w, int h, double upright, double time, int page) {
|
||||
bfr.Add_byte_space().Add(Xoh_img_xoimg_data.Bry__data_xowa_image).Add_byte_eq().Add_byte_quote();
|
||||
bfr.Add_int_digits(1, Xop_lnki_type.To_tid(tid)).Add_byte_pipe();
|
||||
bfr.Add_int_variable(w).Add_byte_pipe();
|
||||
bfr.Add_int_variable(h).Add_byte_pipe();
|
||||
bfr.Add_double(upright).Add_byte_pipe();
|
||||
bfr.Add_double(time).Add_byte_pipe();
|
||||
bfr.Add_int_variable(page).Add_byte_quote();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
private static final Bry_fmt
|
||||
fmt__anch_n = Bry_fmt.Auto
|
||||
( "<img~{data_xowa_title}~{data_xowa_image} src=\"\" width=\"0\" height=\"0\"~{img_cls} alt=\"~{img_alt}\"~{img_xtra_atrs}/>"
|
||||
)
|
||||
, fmt__anch_y = Bry_fmt.Auto
|
||||
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"
|
||||
+ "<img~{data_xowa_title}~{data_xowa_image} src=\"\" width=\"0\" height=\"0\"~{img_cls} alt=\"~{img_alt}\"/>"
|
||||
+ "</a>"
|
||||
);
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
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.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 gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_file_html_fmtr__base implements Xoh_file_img_wkr {
|
||||
protected final Xoh_arg_img_core arg_img_core;
|
||||
private Bry_bfr scratch_bfr = Bry_bfr_.Reset(128);
|
||||
private final Bfr_arg__hatr_id thm_file_id = Bfr_arg__hatr_id.New_id("xowa_file_div_"), thm_play_id = Bfr_arg__hatr_id.New_id("xowa_file_play_");
|
||||
public Xoh_file_html_fmtr__base() {
|
||||
arg_img_core = New_arg_img_core();
|
||||
}
|
||||
@gplx.Internal @gplx.Virtual protected Xoh_arg_img_core New_arg_img_core() {return new Xoh_arg_img_core__basic();}
|
||||
@gplx.Virtual public void Html_full_media(Bry_bfr tmp_bfr, boolean mode_is_hdump, byte[] a_href, byte[] a_title, Bfr_arg html) {
|
||||
if (mode_is_hdump) a_href = Bry_.Empty;
|
||||
fmtr_full_media.Bld_bfr_many(tmp_bfr, a_href, a_title, html);
|
||||
}
|
||||
private final Bry_fmtr fmtr_full_media = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\">~{html}"
|
||||
, "</a>"
|
||||
), "a_href", "a_xowa_title", "html"
|
||||
);
|
||||
@gplx.Virtual public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid
|
||||
, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
|
||||
) {
|
||||
if (Bry_.Len_eq_0(a_href)) // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
|
||||
fmtr_full_img_wo_link.Bld_bfr_many(tmp_bfr, uid, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
else
|
||||
fmtr_full_img.Bld_bfr_many(tmp_bfr, uid
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, arg_img_core.Init(uid, img_src, img_w, img_h), img_alt, Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
}
|
||||
private Bry_fmtr fmtr_full_img = Bry_fmtr.new_
|
||||
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"
|
||||
+ "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} /></a>"
|
||||
, "uid", "a_href", "a_class", "a_rel", "a_title", "a_xowa_title", "img_core", "img_alt", "img_class"
|
||||
);
|
||||
private Bry_fmtr fmtr_full_img_wo_link = Bry_fmtr.new_
|
||||
( "<img id=\"xoimg_~{uid}\" alt=\"~{img_alt}\"~{img_core}~{img_class} />"
|
||||
, "uid", "img_core", "img_alt", "img_class"
|
||||
);
|
||||
public byte[] Html_thumb_part_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid, byte[] lnki_ttl, byte[] a_href, byte[] img_src, byte[] img_alt) {
|
||||
byte[] a_title_atr = Gfh_atr_.Make(tmp_bfr, Gfh_atr_.Bry__title, xfer_itm.Lnki_ttl());
|
||||
Html_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, a_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image
|
||||
, Xoh_lnki_consts.Tid_a_rel_none, a_title_atr
|
||||
, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki_ttl) // NOTE: must use lnki_ttl, not xfer_itm.Lnki_ttl(); 1st observes case-sensitivity; EX:"a.ogv"; PAGE:de.d:fappieren DATE:2016-06-23
|
||||
, xfer_itm.Html_w(), xfer_itm.Html_h(), img_src, img_alt, Xoh_img_cls_.Tid__none, null);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
@gplx.Virtual public void Html_thumb_core(Bry_bfr tmp_bfr, boolean mode_is_hdump, int uid, byte[] div1_halign, int div2_width, byte[] div2_content) {
|
||||
scratch_bfr.Add(Bry_style_bgn);
|
||||
scratch_bfr.Add_int_variable(div2_width);
|
||||
scratch_bfr.Add(Bry_style_end);
|
||||
thm_file_id.Bfr_arg__clear();
|
||||
if (mode_is_hdump)
|
||||
thm_file_id.Bfr_arg__clear();
|
||||
else
|
||||
thm_file_id.Set(uid);
|
||||
fmtr_thumb_core.Bld_bfr_many(tmp_bfr, thm_file_id, div1_halign, scratch_bfr.To_bry_and_clear(), div2_content);
|
||||
}
|
||||
private static final byte[] Bry_style_bgn = Bry_.new_a7("style=\"width:"), Bry_style_end = Bry_.new_a7("px;\"");
|
||||
protected Bry_fmtr fmtr_thumb_core = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last // REF.MW: Linker.php|makeImageLink2
|
||||
( "<div class=\"thumb t~{div1_halign}\">"
|
||||
, " <div~{div_id} class=\"thumbinner\" ~{style}>"
|
||||
, "~{div2_content}"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
), "div_id", "div1_halign", "style", "div2_content"
|
||||
);
|
||||
public void Html_thumb_part_caption(Bry_bfr tmp_bfr, byte[] magnify_btn, Bfr_arg caption) {fmtr_thumb_part_caption.Bld_bfr_many(tmp_bfr, magnify_btn, caption);}
|
||||
private Bry_fmtr fmtr_thumb_part_caption = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class=\"thumbcaption\">~{magnify_btn}~{caption}"
|
||||
, " </div>"
|
||||
), "magnify_btn", "caption");
|
||||
|
||||
public void Html_thumb_file_image(Bry_bfr tmp_bfr, byte[] thumb_image, byte[] caption, byte[] alt) {fmtr_thumb_file_image.Bld_bfr_many(tmp_bfr, thumb_image, caption, alt);}
|
||||
private final Bry_fmtr fmtr_thumb_file_image = Bry_fmtr.new_(" ~{thumb_image}~{caption}~{alt}", "thumb_image", "caption", "alt");
|
||||
|
||||
public void Html_thumb_file_audio(Bry_bfr tmp_bfr, byte[] caption, byte[] alt, byte[] play_btn, byte[] audio_info) {fmtr_thumb_file_audio.Bld_bfr_many(tmp_bfr, caption, alt, play_btn, audio_info);}
|
||||
private Bry_fmtr fmtr_thumb_file_audio = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">~{play_btn}~{audio_info}"
|
||||
, " </div>~{caption}~{alt}"
|
||||
), "caption", "alt", "play_btn", "audio_info");
|
||||
|
||||
public void Html_thumb_file_video(Bry_bfr tmp_bfr, byte[] play_btn, byte[] video_thumb, byte[] caption, byte[] alt) {fmtr_thumb_file_video.Bld_bfr_many(tmp_bfr, caption, alt, play_btn, video_thumb);}
|
||||
private final Bry_fmtr fmtr_thumb_file_video = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>~{video_thumb}"
|
||||
, " </div>~{play_btn}"
|
||||
, " </div>~{caption}~{alt}"
|
||||
), "caption", "alt", "play_btn", "video_thumb");
|
||||
|
||||
public void Html_thumb_part_alt(Bry_bfr tmp_bfr, byte[] alt_html) {fmtr_thumb_part_alt.Bld_bfr_many(tmp_bfr, alt_html);}
|
||||
public Bry_fmtr Html_thumb_part_alt_fmtr() {return fmtr_thumb_part_alt;} private Bry_fmtr fmtr_thumb_part_alt = Bry_fmtr.new_
|
||||
(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">~{html}"
|
||||
, " </div>"
|
||||
), "html");
|
||||
|
||||
@gplx.Virtual public void Html_thumb_part_magnify(Bry_bfr tmp_bfr, int uid, byte[] a_href, byte[] a_title, byte[] img_src) {
|
||||
fmtr_thumb_part_magnify.Bld_bfr_many(tmp_bfr, a_href, a_title);
|
||||
}
|
||||
private final Bry_fmtr fmtr_thumb_part_magnify = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div class=\"magnify\"><a href=\"~{a_href}\" class=\"internal\" title=\"~{a_title}\"></a></div>"
|
||||
), "a_href", "a_title");
|
||||
|
||||
@gplx.Virtual public void Html_thumb_part_info(Bry_bfr tmp_bfr, int uid, boolean mode_is_hdump, byte[] a_href, byte[] img_src) {
|
||||
if (mode_is_hdump)
|
||||
img_src = Bry_.Empty;
|
||||
fmtr_thumb_part_info.Bld_bfr_many(tmp_bfr, a_href, img_src);
|
||||
}
|
||||
private final Bry_fmtr fmtr_thumb_part_info = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div><a href=\"~{a_href}\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
), "a_href", "img_src");
|
||||
|
||||
public void Html_thumb_part_play(Bry_bfr tmp_bfr, int uid, boolean mode_is_hdump, int a_width, int a_max_width, byte[] a_href, byte[] a_xowa_title, byte[] img_src) {
|
||||
if (mode_is_hdump) {
|
||||
thm_play_id.Bfr_arg__clear();
|
||||
a_href = Bry_.Empty;
|
||||
a_width = 218; a_max_width = 220; // NOTE: hardcode widths; hdump will get actual file with from fsdb
|
||||
}
|
||||
else
|
||||
thm_play_id.Set(uid);
|
||||
fmtr_thumb_part_play.Bld_bfr_many(tmp_bfr, thm_play_id, a_width, a_max_width, a_href, a_xowa_title);
|
||||
}
|
||||
private final Bry_fmtr fmtr_thumb_part_play = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div><a~{id} href=\"~{a_href}\" xowa_title=\"~{a_xowa_title}\" class=\"xowa_media_play\" style=\"width:~{a_width}px;max-width:~{a_max_width}px;\" alt=\"Play sound\"></a></div>"
|
||||
), "id", "a_width", "a_max_width", "a_href", "a_xowa_title");
|
||||
|
||||
public static byte[] Escape_xowa_title(byte[] lnki_ttl) {
|
||||
return Xoa_ttl.Replace_spaces(gplx.langs.htmls.encoders.Gfo_url_encoder_.Href_quotes.Encode(lnki_ttl)); // must encode xowa_title, particularly quotes; EX: xowa_title="A"b.png"; PAGE:en.w:Earth DATE:2015-11-27
|
||||
}
|
||||
public static byte[] Escape_xowa_title_v2(byte[] lnki_ttl) {
|
||||
return Xoa_ttl.Replace_spaces(gplx.langs.htmls.encoders.Gfo_url_encoder_.Href_quotes_v2.Encode(lnki_ttl)); // must encode xowa_title, particularly quotes; EX: xowa_title="A"b.png"; PAGE:en.w:Earth DATE:2015-11-27
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
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.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 gplx.core.brys.fmtrs.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_file_html_fmtr__hdump extends Xoh_file_html_fmtr__base {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(128);
|
||||
@Override public void Html_full_img(Bry_bfr bfr, gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm
|
||||
, int uid, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other) {
|
||||
boolean link_is_empty = Bry_.Len_eq_0(a_href); // NOTE: set link_is_empty before blanking a_href below
|
||||
if (a_href_is_file) a_href = Bry_.Empty;
|
||||
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, a_xowa_title);
|
||||
byte[] data_xowa_image = Bld_xowa_image_data(tmp_bfr, xfer_itm.Lnki_type(), xfer_itm.Lnki_w(), xfer_itm.Lnki_h(), xfer_itm.Lnki_upright(), xfer_itm.Lnki_time(), xfer_itm.Lnki_page());
|
||||
if (link_is_empty)
|
||||
Bld_anch_n(bfr, data_xowa_title, data_xowa_image, img_cls, img_cls_other, img_alt, Bry_.Empty);
|
||||
else
|
||||
fmtr_anch_y.Bld_bfr_many(bfr
|
||||
, a_href, Xoh_lnki_consts.A_cls_to_bry(a_cls), Xoh_lnki_consts.A_rel_to_bry(a_rel), a_title, a_xowa_title
|
||||
, Gfh_utl.Escape_html_as_bry(img_alt), data_xowa_title, data_xowa_image, arg_img_core.Init(uid, Bry_.Empty, 0, 0), Xoh_img_cls_.To_html(img_cls, img_cls_other));
|
||||
}
|
||||
public static void Bld_anch_n(Bry_bfr bfr, byte[] data_xowa_title, byte[] data_xowa_image, byte img_cls, byte[] img_cls_other, byte[] img_alt, byte[] img_xtra_atrs) {
|
||||
fmtr_anch_n.Bld_many(bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.To_html(img_cls, img_cls_other), Gfh_utl.Escape_html_as_bry(img_alt), img_xtra_atrs);
|
||||
}
|
||||
public static byte[] Bld_xowa_image_data(Bry_bfr tmp_bfr, byte tid, int w, int h, double upright, double time, int page) {
|
||||
tmp_bfr.Add_byte_space().Add(Xoh_img_xoimg_data.Bry__data_xowa_image).Add_byte_eq().Add_byte_quote();
|
||||
tmp_bfr.Add_int_digits(1, Xop_lnki_type.To_tid(tid)).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(w).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(h).Add_byte_pipe();
|
||||
tmp_bfr.Add_double(upright).Add_byte_pipe();
|
||||
tmp_bfr.Add_double(time).Add_byte_pipe();
|
||||
tmp_bfr.Add_int_variable(page).Add_byte_quote();
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
private
|
||||
Bry_fmtr fmtr_anch_y = Bry_fmtr.new_
|
||||
( "<a href=\"~{a_href}\"~{a_class}~{a_rel}~{a_title} xowa_title=\"~{a_xowa_title}\">"
|
||||
+ "<img~{img_xoimg}~{data_xowa_title}~{data_xowa_image}~{img_class} alt=\"~{img_alt}\"/>"
|
||||
+ "</a>"
|
||||
, "a_href", "a_class", "a_rel", "a_title", "a_xowa_title", "img_alt", "img_xoimg", "data_xowa_title", "data_xowa_image", "img_class"
|
||||
)
|
||||
;
|
||||
private static final Bry_fmt fmtr_anch_n = Bry_fmt.New
|
||||
( "<img~{data_xowa_title}~{data_xowa_image} src=\"\" width=\"0\" height=\"0\"~{img_class} alt=\"~{img_alt}\"~{img_xtra_atrs}/>"
|
||||
, "data_xowa_title", "data_xowa_image", "img_class", "img_alt", "img_xtra_atrs"
|
||||
);
|
||||
// public override void Html_full_media(Bry_bfr tmp_bfr, byte[] a_href, byte[] a_title, Bfr_arg html) {
|
||||
// fmtr_full_media.Bld_bfr_many(tmp_bfr, a_href, a_title, html);
|
||||
// }
|
||||
}
|
||||
@@ -17,7 +17,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 gplx.core.primitives.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.xfers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.wikis.tdbs.metas.*;
|
||||
@@ -29,7 +29,7 @@ public class Xoh_file_mgr {
|
||||
}
|
||||
public Xoh_file_wtr__basic File_wtr() {return file_wtr;} private final Xoh_file_wtr__basic file_wtr;
|
||||
public void Init_by_page(Xoh_wtr_ctx hctx, Xoae_page page) {file_wtr.Init_by_page(hctx, page);}
|
||||
public void Write_or_queue(Bry_bfr bfr, Xoae_page page, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {Write_or_queue(bfr, page, ctx, hctx, src, lnki, file_wtr.Arg_alt_text(ctx, src, lnki));}
|
||||
public void Write_or_queue(Bry_bfr bfr, Xoae_page page, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {Write_or_queue(bfr, page, ctx, hctx, src, lnki, file_wtr.Bld_alt(Bool_.N, ctx, Xoh_wtr_ctx.Alt, src, lnki));}
|
||||
public void Write_or_queue(Bry_bfr bfr, Xoae_page page, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] alt_text) {
|
||||
file_wtr.Write_file(bfr, ctx, hctx, src, lnki, this.Lnki_eval(Xof_exec_tid.Tid_wiki_page, ctx, page, lnki), alt_text);
|
||||
}
|
||||
@@ -49,8 +49,19 @@ public class Xoh_file_mgr {
|
||||
return xfer;
|
||||
}
|
||||
private boolean Find_file(Xop_ctx ctx, Xowe_wiki source_wiki, Xof_xfer_itm xfer) {
|
||||
if (source_wiki.File__fsdb_mode().Tid__v2__mp()) {
|
||||
Xof_orig_itm itm = source_wiki.File__orig_mgr().Find_by_ttl_or_null(xfer.Lnki_ttl());
|
||||
if (itm == null)
|
||||
return false;
|
||||
else {
|
||||
byte repo_id = itm.Repo();
|
||||
byte[] repo_name = source_wiki.File_mgr().Repo_mgr().Repos_get_at(repo_id).Wiki_domain();
|
||||
xfer.Init_at_orig(itm.Repo(), repo_name, itm.Ttl(), itm.Ext(), itm.W(), itm.H(), itm.Redirect());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ( source_wiki.File__fsdb_mode() == null // ignore if null; occurs during some tests; also null-ref check for next
|
||||
|| source_wiki.File__fsdb_mode().Tid_v2_bld() // ignore builds
|
||||
|| source_wiki.File__fsdb_mode().Tid__v2__bld() // ignore builds
|
||||
)
|
||||
return false;
|
||||
if (source_wiki.File_mgr().Version() == Xow_file_mgr.Version_2)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoh_file_wtr__audio__tst {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|noicon]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, " </div>"
|
||||
@@ -50,7 +50,7 @@ public class Xoh_file_wtr__audio__tst {
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.oga\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
@@ -74,7 +74,7 @@ public class Xoh_file_wtr__audio__tst {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.oga|thumb|noicon|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/f/A.oga\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">a"
|
||||
, " </div>"
|
||||
|
||||
@@ -21,48 +21,55 @@ import gplx.langs.htmls.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xoh_file_wtr__basic {
|
||||
private final Xowe_wiki wiki; private final Xow_html_mgr html_mgr; private final Xoh_html_wtr html_wtr; private final Bry_bfr_mkr bfr_mkr; private final Bry_bfr scratch_bfr = Bry_bfr_.Reset(Io_mgr.Len_kb);
|
||||
private final Xoh_lnki_text_fmtr media_alt_fmtr, caption_fmtr;
|
||||
private final Xop_link_parser tmp_link_parser = new Xop_link_parser(); private Xoa_url tmp_url = Xoa_url.blank(); private final Xoh_lnki_title_fmtr anchor_title_wkr = new Xoh_lnki_title_fmtr();
|
||||
private Xoae_page page; private boolean cfg_alt_defaults_to_caption;
|
||||
private Xoh_file_html_fmtr__base html_fmtr;
|
||||
private final Xoh_file_html_fmtr__hdump fmtr__hdump = new Xoh_file_html_fmtr__hdump();
|
||||
private final Xoh_file_html_fmtr__base fmtr__base = new Xoh_file_html_fmtr__base();
|
||||
public class Xoh_file_wtr__basic {
|
||||
private final Xowe_wiki wiki; private final Xow_html_mgr html_mgr; private final Xoh_html_wtr html_wtr;
|
||||
private final Xoh_file_fmtr__basic fmtr__basic = new Xoh_file_fmtr__basic(), fmtr__hdump = new Xoh_file_fmtr__hdump();
|
||||
private final Xoh_lnki_text_fmtr alt_fmtr, caption_fmtr;
|
||||
private final Xop_link_parser tmp_link_parser = new Xop_link_parser(); private Xoa_url tmp_url = Xoa_url.blank();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(32);
|
||||
private Xoae_page page; private boolean cfg_alt_defaults_to_caption; private byte[] msg_file_enlarge;
|
||||
private Xoh_file_fmtr__basic html_fmtr;
|
||||
public Xoh_file_wtr__basic(Xowe_wiki wiki, Xow_html_mgr html_mgr, Xoh_html_wtr html_wtr) {
|
||||
this.wiki = wiki; this.html_mgr = html_mgr; this.html_wtr = html_wtr; this.bfr_mkr = wiki.Utl__bfr_mkr();
|
||||
this.media_alt_fmtr = new Xoh_lnki_text_fmtr(bfr_mkr, html_wtr);
|
||||
this.caption_fmtr = new Xoh_lnki_text_fmtr(bfr_mkr, html_wtr);
|
||||
this.html_fmtr = fmtr__base;
|
||||
this.wiki = wiki; this.html_mgr = html_mgr; this.html_wtr = html_wtr;
|
||||
this.alt_fmtr = new Xoh_lnki_text_fmtr(wiki.Utl__bfr_mkr(), html_wtr);
|
||||
this.caption_fmtr = new Xoh_lnki_text_fmtr(wiki.Utl__bfr_mkr(), html_wtr);
|
||||
this.html_fmtr = fmtr__basic;
|
||||
}
|
||||
public Xoh_file_html_fmtr__base Html_fmtr() {return html_fmtr;}
|
||||
public void Init_by_page(Xoh_wtr_ctx hctx, Xoae_page page) {
|
||||
this.page = page;
|
||||
this.cfg_alt_defaults_to_caption = wiki.Appe().Usere().Wiki().Html_mgr().Imgs_mgr().Alt_defaults_to_caption().Val();
|
||||
html_fmtr = hctx.Mode_is_hdump() ? fmtr__hdump : fmtr__base;
|
||||
this.html_fmtr = hctx.Mode_is_hdump() ? fmtr__hdump : fmtr__basic;
|
||||
if (msg_file_enlarge == null) this.msg_file_enlarge = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_file_enlarge);
|
||||
}
|
||||
public void Write_file(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_file_itm xfer_itm, byte[] img_alt) {
|
||||
// init
|
||||
int uid = xfer_itm.Html_uid();
|
||||
byte[] lnki_ttl = lnki.Ttl().Page_txt();
|
||||
Xof_ext orig_ext = xfer_itm.Orig_ext();
|
||||
byte[] lnki_href = wiki.Html__href_wtr().Build_to_bry(wiki, lnki.Ttl());
|
||||
|
||||
// get div_width
|
||||
int div_width = xfer_itm.Html_w();
|
||||
if (div_width < 1 && wiki.File_mgr().Version_2_y()) // NOTE: html_w is -1 for v2 and missing files; use lnki_w if available; primarily affects audio files with specified width; [[File:A.oga|30px]]; DATE:2014-05-03
|
||||
div_width = xfer_itm.Lnki_w();
|
||||
if (div_width < 1) // && hctx.Mode_is_hdump() // TODO: should manually insert?
|
||||
div_width = wiki.Html_mgr().Img_thumb_width();
|
||||
int lnki_halign = lnki.Align_h();
|
||||
if (lnki_halign == Xop_lnki_align_h_.Null)
|
||||
lnki_halign = wiki.Lang().Img_thumb_halign_default(); // if halign is not supplied, then default to align for language
|
||||
byte[] lnki_halign_bry = Xop_lnki_align_h_.Html_names[lnki_halign];
|
||||
byte[] lnki_href = wiki.Html__href_wtr().Build_to_bry(wiki, lnki.Ttl());
|
||||
byte[] img_view_src = xfer_itm.Html_view_url().To_http_file_bry();
|
||||
byte[] img_orig_src = xfer_itm.Html_orig_url().To_http_file_bry();
|
||||
byte[] lnki_ttl = lnki.Ttl().Page_txt();
|
||||
Xof_ext orig_ext = xfer_itm.Orig_ext();
|
||||
boolean lnki_is_thumbable = Xop_lnki_type.Id_is_thumbable(lnki.Lnki_type());
|
||||
if ( lnki_is_thumbable
|
||||
&& ( !xfer_itm.File_exists() // "non-found" thumbs should default to 220; otherwise large "non-found" thumbs will create large boxes; PAGE:en.w:Wikipedia:Featured_picture_candidates/September_Morn "|1000000x260px"; DATE:2014-09-24
|
||||
&& !hctx.Mode_is_hdump()) // ignore for hdump mode b/c all images are "non-found"; DATE:2016-05-30
|
||||
)
|
||||
div_width = Xof_img_size.Thumb_width_img;
|
||||
|
||||
// get halign
|
||||
int lnki_halign = lnki.Align_h();
|
||||
if (lnki_halign == Xop_lnki_align_h_.Null)
|
||||
lnki_halign = wiki.Lang().Img_thumb_halign_default(); // if halign is not supplied, then default to align for language
|
||||
byte[] lnki_halign_bry = Xop_lnki_align_h_.Html_names[lnki_halign];
|
||||
|
||||
// img_view_src, img_orig_src
|
||||
byte[] img_view_src = xfer_itm.Html_view_url().To_http_file_bry();
|
||||
byte[] img_orig_src = xfer_itm.Html_orig_url().To_http_file_bry();
|
||||
if ( html_mgr.Img_suppress_missing_src() // option to suppress src when file is missing
|
||||
&& !xfer_itm.File_exists() // file is missing; wipe values and wait for "correct" info before regenerating; mostly to handle unknown redirects
|
||||
&& !orig_ext.Id_is_media() // file is media; never suppress; src needs to be available for "click" on play; note that most media will be missing (not downloaded)
|
||||
@@ -70,78 +77,138 @@ public class Xoh_file_wtr__basic {
|
||||
) {
|
||||
img_orig_src = img_view_src = Bry_.Empty; // null out src
|
||||
}
|
||||
|
||||
// main html build
|
||||
if (lnki.Ns_id() == Xow_ns_.Tid__media) // NOTE: regardless of ext (ogg vs jpeg) and literal status (Media vs :Media), [[Media]] links are always rendered the same way; REF.MW:Linker.php|makeMediaLinkObj; PAGE:en.w:Beethoven; EX: [[:Media:De-Ludwig_van_Beethoven.ogg|listen]]); [[File:Beethoven 3.jpg|The [[Media:BeethovenWithLyreGuitar( W. J. Mahler - 1804).jpg|complete painting]]...]]
|
||||
this.Write_file_ns_media(bfr, ctx, hctx, src, lnki, img_orig_src);
|
||||
html_fmtr.Add_media(bfr, hctx.Mode_is_hdump(), img_orig_src, lnki_ttl, Bld_caption(ctx, Xoh_wtr_ctx.Basic, src, lnki)); // NOTE: use orig_src not view_src; DATE:2014-01-19
|
||||
else {
|
||||
if ( Xof_ext_.Id_is_video_strict(orig_ext.Id()) // id is .ogv or .webm
|
||||
|| ( orig_ext.Id_is_ogg() // id is ogg
|
||||
&& wiki.File_mgr().Version_1_y() // version is v1 (v2 always marks ogg as aud); DATE:2014-02-01
|
||||
// identify if video; note that this is complicated b/c .ogg is used for both audio and video files
|
||||
boolean orig_is_video = Xof_ext_.Id_is_video_strict(orig_ext.Id());
|
||||
if (orig_ext.Id_is_ogg()) {
|
||||
if ( wiki.File_mgr().Version_1_y() // version is v1 (v2 always marks ogg as aud if from fsdb); DATE:2014-02-01
|
||||
&& ( xfer_itm.File_exists() // NOTE: xfer_itm.Html_pass() checks for video .ogg files (ext = .ogg and thumb is available); EX: WWI;
|
||||
|| xfer_itm.Dbmeta_is_new() // NOTE: State_new() will always assume that ogg is video; needed for 1st load and dynamic updates
|
||||
)
|
||||
)
|
||||
) {
|
||||
)
|
||||
orig_is_video = true;
|
||||
else if ( wiki.File_mgr().Version_2_y() // version is v2
|
||||
&& ( lnki.Lnki_type() != Xop_lnki_type.Id_null // any one of w, h, time, upright, type is present
|
||||
|| lnki.W() > 0
|
||||
|| lnki.H() > 0
|
||||
|| lnki.Time() != Xof_lnki_time.Null
|
||||
|| lnki.Upright() != Xop_lnki_tkn.Upright_null
|
||||
)) {
|
||||
orig_is_video = true; // ASSUME: .ogg is video b/c of supplied values; DATE:2016-08-05
|
||||
}
|
||||
}
|
||||
if (orig_is_video) {
|
||||
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_vid);
|
||||
this.Write_file_video(bfr, ctx, hctx, src, lnki, uid, div_width, lnki_halign_bry, lnki_ttl, lnki_href, img_view_src, img_orig_src, img_alt, xfer_itm);
|
||||
int vid_lnki_w = lnki.W(); if (vid_lnki_w == -1) vid_lnki_w = 0; if (vid_lnki_w == 0 && xfer_itm.Html_w() != 0) vid_lnki_w = xfer_itm.Html_w();
|
||||
int vid_lnki_h = lnki.H(); if (vid_lnki_h == -1) vid_lnki_h = 0; if (vid_lnki_h == 0 && xfer_itm.Html_h() != 0) vid_lnki_h = xfer_itm.Html_h();
|
||||
xfer_itm.Init_at_gallery_bgn(vid_lnki_w, vid_lnki_h, vid_lnki_w); // HACK: force html_w to be lnki_w; needed b/c play_btn uses html_w; DATE:2016-08-05
|
||||
this.Write_file_video(bfr, ctx, hctx, src, lnki, img_orig_src, uid, div_width, lnki_halign_bry, lnki_href, img_alt, lnki_ttl, img_view_src, xfer_itm);
|
||||
}
|
||||
else if (orig_ext.Id_is_audio()) // audio
|
||||
this.Write_file_audio(bfr, ctx, hctx, src, lnki, uid, div_width, lnki_halign_bry, lnki_href, img_orig_src, img_alt);
|
||||
this.Write_file_audio(bfr, ctx, hctx, src, lnki, img_orig_src, uid, div_width, lnki_halign_bry, lnki_href, img_alt, lnki_ttl);
|
||||
else // image
|
||||
this.Write_file_image(bfr, ctx, hctx, src, lnki, xfer_itm, uid, lnki_is_thumbable, div_width, lnki_halign, lnki_halign_bry, lnki_ttl, orig_ext, lnki_href, img_view_src, img_orig_src, img_alt);
|
||||
this.Write_file_image(bfr, ctx, hctx, src, lnki, img_orig_src, uid, div_width, lnki_halign_bry, lnki_href, img_alt, lnki_ttl, img_view_src, xfer_itm, lnki_is_thumbable, lnki_halign, orig_ext);
|
||||
}
|
||||
}
|
||||
private void Write_file_ns_media(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] img_orig_src) {
|
||||
html_fmtr.Html_full_media(bfr, hctx.Mode_is_hdump(), img_orig_src, lnki.Ttl().Page_txt(), Arg_caption(ctx, src, Xoh_wtr_ctx.Basic, lnki)); // NOTE: use orig_src not view_src; DATE:2014-01-19
|
||||
}
|
||||
private void Write_file_audio(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_href, byte[] img_orig_src, byte[] alt) {
|
||||
byte[] content = Arg_content_audio(lnki, ctx, hctx, src, uid, lnki_href, img_orig_src, alt);
|
||||
private void Write_file_audio(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] img_orig_src, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_href, byte[] alt, byte[] lnki_ttl) {
|
||||
// init
|
||||
int play_btn_width = Get_play_btn_width(lnki.W());
|
||||
byte[] info_btn = lnki.Media_icon() ? html_fmtr.Bld_thumb_part_info(lnki_href) : Bry_.Empty;
|
||||
|
||||
// bld audio_div
|
||||
byte[] audio_div = html_fmtr.Bld_thumb_file_audio
|
||||
( Bld_caption_div(ctx, hctx, src, lnki, uid, img_orig_src, lnki_href)
|
||||
, Bld_alt(Bool_.Y, ctx, hctx, src, lnki)
|
||||
, Bld_play_btn(hctx, uid, img_orig_src, lnki_ttl, play_btn_width, play_btn_width) // NOTE: changed max_width from 1024: DATE:2016-08-05
|
||||
, info_btn);
|
||||
|
||||
// if "media" flag, add as thumb; else, add directly
|
||||
if (lnki.Media_icon())
|
||||
html_fmtr.Html_thumb_core(bfr, hctx.Mode_is_hdump(), uid, lnki_halign_bry, div_width, content);
|
||||
html_fmtr.Add_thumb_core(bfr, hctx.Mode_is_hdump(), lnki_halign_bry, uid, div_width, audio_div);
|
||||
else
|
||||
bfr.Add(content);
|
||||
bfr.Add(audio_div);
|
||||
}
|
||||
private void Write_file_video(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_ttl, byte[] lnki_href, byte[] img_view_src, byte[] img_orig_src, byte[] alt, Xof_file_itm xfer_itm) {
|
||||
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_vid);
|
||||
private void Write_file_video(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] img_orig_src, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_href, byte[] alt, byte[] lnki_ttl, byte[] img_view_src, Xof_file_itm xfer_itm) {
|
||||
// init
|
||||
int play_btn_width = Get_play_btn_width(xfer_itm.Html_w());
|
||||
boolean video_is_thumb = Xop_lnki_type.Id_defaults_to_thumb(lnki.Lnki_type());
|
||||
byte[] content = Arg_content_video(ctx, hctx, src, lnki, xfer_itm, uid, video_is_thumb, lnki_ttl, lnki_href, img_view_src, img_orig_src, alt);
|
||||
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_vid);
|
||||
|
||||
// bld caption / alt
|
||||
byte[] caption_html = Bry_.Empty, alt_html = Bry_.Empty;
|
||||
if (video_is_thumb) {
|
||||
caption_html = Bld_caption_div(ctx, hctx, src, lnki, uid, img_orig_src, lnki_href);
|
||||
alt_html = Bld_alt(Bool_.Y, ctx, hctx, src, lnki);
|
||||
}
|
||||
|
||||
// bld video_div
|
||||
byte[] video_div = html_fmtr.Bld_thumb_file_video(caption_html, alt_html
|
||||
, Bld_play_btn(hctx, uid, img_orig_src, lnki_ttl, play_btn_width, play_btn_width)
|
||||
, html_fmtr.Bld_thumb_part_img(hctx, page, src, xfer_itm, uid, lnki_ttl, lnki_href, img_view_src, alt));
|
||||
|
||||
// if "thumbable", add as thumb; else, add directly
|
||||
if (video_is_thumb)
|
||||
html_fmtr.Html_thumb_core(bfr, hctx.Mode_is_hdump(), uid, lnki_halign_bry, div_width, content);
|
||||
html_fmtr.Add_thumb_core(bfr, hctx.Mode_is_hdump(), lnki_halign_bry, uid, div_width, video_div);
|
||||
else
|
||||
bfr.Add(content);
|
||||
bfr.Add(video_div);
|
||||
}
|
||||
private void Write_file_image(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_file_itm xfer_itm, int uid, boolean lnki_is_thumbable, int div_width, int lnki_halign, byte[] lnki_halign_bry
|
||||
, byte[] lnki_ttl, Xof_ext orig_ext, byte[] lnki_href, byte[] img_view_src, byte[] img_orig_src, byte[] alt) {
|
||||
private void Write_file_image(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] img_orig_src, int uid, int div_width, byte[] lnki_halign_bry, byte[] lnki_href, byte[] alt, byte[] lnki_ttl, byte[] img_view_src, Xof_file_itm xfer_itm
|
||||
, boolean lnki_is_thumbable, int lnki_halign, Xof_ext orig_ext) {
|
||||
// if centered, add <div class="center">; applies to both thumb and full
|
||||
if (lnki_halign == Xop_lnki_align_h_.Center) bfr.Add(Div_center_bgn);
|
||||
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
|
||||
byte[] anchor_title = html_wtr.Cfg().Lnki__title()
|
||||
? Arg_anchor_title(tmp_bfr, src, lnki, lnki_ttl, anchor_title_wkr) // NOTE: Arg_anchor_title should only be called if there is no caption, else refs may not show; DATE:2014-03-05
|
||||
: Bry_.Empty;
|
||||
Xoh_file_img_wkr lnki_file_wkr = lnki.Lnki_file_wkr(); if (lnki_file_wkr == null) lnki_file_wkr = html_fmtr;
|
||||
|
||||
// bld anch_ttl; EX: title="A.png"
|
||||
byte[] anch_ttl = html_wtr.Cfg().Lnki__title()
|
||||
? Bld_anch_title(tmp_bfr, src, lnki, lnki_ttl) // NOTE: Bld_anch_title should only be called if there is no caption, else refs may not show; DATE:2014-03-05
|
||||
: Bry_.Empty;
|
||||
|
||||
// get fmtr; note conditional is for imap, which has its own img_fmtr to put in 'imagemap=""'
|
||||
Xoh_file_fmtr img_fmtr = lnki.Lnki_file_wkr(); if (img_fmtr == null) img_fmtr = html_fmtr;
|
||||
|
||||
// main image build
|
||||
if (lnki_is_thumbable) { // is "thumb"
|
||||
if (bfr.Len() > 0) bfr.Add_byte_nl();
|
||||
byte[] content = Arg_content_thumb(lnki_file_wkr, ctx, hctx, src, lnki, xfer_itm, uid, lnki_href, img_view_src, img_orig_src, alt, lnki_ttl, anchor_title);
|
||||
html_fmtr.Html_thumb_core(bfr, hctx.Mode_is_hdump(), uid, lnki_halign_bry, div_width, content);
|
||||
|
||||
// write image_div
|
||||
byte[] alt_html = wiki.Html_mgr().Imgs_mgr().Alt_in_caption().Val() ? Bld_alt(Bool_.Y, ctx, hctx, src, lnki) : Bry_.Empty;
|
||||
img_fmtr.Add_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, lnki_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, anch_ttl
|
||||
, Xoh_file_fmtr__basic.Escape_xowa_title(lnki_ttl), xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt
|
||||
, xfer_itm.File_exists() ? Xoh_img_cls_.Tid__thumbimage : Xoh_img_cls_.Tid__none
|
||||
, Xoh_img_cls_.Bry__none);
|
||||
byte[] thumb = tmp_bfr.To_bry_and_clear();
|
||||
html_fmtr.Add_thumb_core(bfr, hctx.Mode_is_hdump(), lnki_halign_bry, uid, div_width
|
||||
, html_fmtr.Bld_thumb_file_image(thumb, Bld_caption_div(ctx, hctx, src, lnki, uid, img_orig_src, lnki_href), alt_html)
|
||||
);
|
||||
}
|
||||
else {
|
||||
else { // is full
|
||||
if ( cfg_alt_defaults_to_caption
|
||||
&& Bry_.Len_eq_0(alt) // NOTE: if no alt, always use caption; DATE:2013-07-22
|
||||
&& Bry_.Len_eq_0(alt) // NOTE: if no alt, always use caption for alt; DATE:2013-07-22
|
||||
&& !lnki.Alt_exists() // unless blank alt exists; EX: [[File:A.png|a|alt=]] should have alt of "", not "a"
|
||||
) {
|
||||
Arg_caption(ctx, src, Xoh_wtr_ctx.Alt, lnki).Bfr_arg__add(tmp_bfr);
|
||||
alt = tmp_bfr.To_bry_and_clear();
|
||||
alt = Bld_caption(ctx, Xoh_wtr_ctx.Alt, src, lnki);
|
||||
}
|
||||
|
||||
// open "<div class=float>"
|
||||
boolean div_align_exists = false;
|
||||
switch (lnki.Align_h()) {
|
||||
case Xop_lnki_align_h_.Left: bfr.Add(Div_float_left) .Add_byte_nl(); div_align_exists = true; break;
|
||||
case Xop_lnki_align_h_.Right: bfr.Add(Div_float_right).Add_byte_nl(); div_align_exists = true; break;
|
||||
case Xop_lnki_align_h_.None: bfr.Add(Div_float_none) .Add_byte_nl(); div_align_exists = true; break;
|
||||
}
|
||||
|
||||
// init vars
|
||||
byte img_cls_tid = lnki.Border() == Bool_.Y_byte ? Xoh_img_cls_.Tid__thumbborder : Xoh_img_cls_.Tid__none;
|
||||
byte[] img_cls_other = lnki.Lnki_cls(); // PAGE:en.s:Page:Notes_on_Osteology_of_Baptanodon._With_a_Description_of_a_New_Species.pdf/3; DATE:2014-09-06
|
||||
|
||||
Arg_nde_tkn lnki_link_tkn = lnki.Link_tkn();
|
||||
if (lnki_link_tkn == Arg_nde_tkn.Null) // full
|
||||
lnki_file_wkr.Html_full_img(bfr, hctx, page, src, xfer_itm, uid, lnki_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, anchor_title, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki_ttl), xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, img_cls_tid, img_cls_other);
|
||||
else { // thumb
|
||||
if (lnki_link_tkn == Arg_nde_tkn.Null) // link absent; just write it
|
||||
img_fmtr.Add_full_img(bfr, hctx, page, src, xfer_itm, uid, lnki_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, anch_ttl, Xoh_file_fmtr__basic.Escape_xowa_title(lnki_ttl), xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, img_cls_tid, img_cls_other);
|
||||
else { // link exists; more logic; EX: [[File:A.png|thumb|link=B]]
|
||||
// over-ride other vars based on link arg; below should be cleaned up
|
||||
Arg_itm_tkn link_tkn = lnki_link_tkn.Val_tkn();
|
||||
byte[] link_arg = Xoa_ttl.Replace_spaces(link_tkn.Dat_to_bry(src)); // replace spaces with unders, else "/wiki/File:A b.ogg" instead of "A_b.ogg"; DATE:2015-11-27
|
||||
if (Bry_.Has_at_bgn(link_arg, Xop_tkn_.Anchor_byte)) link_arg = Bry_.Add(ctx.Page().Ttl().Page_db(), link_arg);
|
||||
@@ -152,93 +219,55 @@ public class Xoh_file_wtr__basic {
|
||||
link_arg = link_arg_html == null ? lnki_href : link_arg_html; // if parse fails, then assign to lnki_href; EX:link={{{1}}}
|
||||
link_arg = Gfo_url_encoder_.Href_qarg.Encode(link_arg); // must encode quotes; PAGE:en.w:List_of_cultural_heritage_sites_in_Punjab,_Pakistan; DATE:2014-07-16
|
||||
// if (Bry_.Len_gt_0(tmp_link_parser.Html_xowa_ttl())) lnki_ttl = tmp_link_parser.Html_xowa_ttl(); // DELETE: not sure why this is here; breaks test; DATE:2015-11-28
|
||||
lnki_file_wkr.Html_full_img(bfr, hctx, page, src, xfer_itm, uid, link_arg, a_href_is_file, tmp_link_parser.Html_anchor_cls(), tmp_link_parser.Html_anchor_rel(), anchor_title, Xoh_file_html_fmtr__base.Escape_xowa_title(xowa_title_bry), xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, img_cls_tid, img_cls_other);
|
||||
img_fmtr.Add_full_img(bfr, hctx, page, src, xfer_itm, uid, link_arg, a_href_is_file, tmp_link_parser.Html_anchor_cls(), tmp_link_parser.Html_anchor_rel(), anch_ttl, Xoh_file_fmtr__basic.Escape_xowa_title(xowa_title_bry), xfer_itm.Html_w(), xfer_itm.Html_h(), img_view_src, alt, img_cls_tid, img_cls_other);
|
||||
}
|
||||
if (div_align_exists) bfr.Add(Gfh_tag_.Div_rhs); // close div from above
|
||||
|
||||
// close "<div class=float>"
|
||||
if (div_align_exists) bfr.Add(Gfh_tag_.Div_rhs);
|
||||
}
|
||||
|
||||
// close <div class="center">
|
||||
if (lnki_halign == Xop_lnki_align_h_.Center) bfr.Add(Gfh_tag_.Div_rhs);
|
||||
tmp_bfr.Mkr_rls();
|
||||
}
|
||||
private byte[] Arg_content_thumb(Xoh_file_img_wkr lnki_file_wkr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_file_itm xfer_itm, int uid, byte[] lnki_href, byte[] view_src, byte[] img_orig_src, byte[] lnki_alt_text, byte[] lnki_ttl, byte[] anchor_title) {
|
||||
byte[] lnki_alt_html = wiki.Html_mgr().Imgs_mgr().Alt_in_caption().Val() ? Arg_alt_html(ctx, hctx, src, lnki) : Bry_.Empty;
|
||||
byte img_cls_tid = xfer_itm.File_exists() ? Xoh_img_cls_.Tid__thumbimage : Xoh_img_cls_.Tid__none;
|
||||
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
|
||||
lnki_file_wkr.Html_full_img(tmp_bfr, hctx, page, src, xfer_itm, uid, lnki_href, Bool_.N, Xoh_lnki_consts.Tid_a_cls_image, Xoh_lnki_consts.Tid_a_rel_none, anchor_title, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki_ttl), xfer_itm.Html_w(), xfer_itm.Html_h(), view_src, lnki_alt_text, img_cls_tid, Xoh_img_cls_.Bry__none);
|
||||
byte[] thumb = tmp_bfr.To_bry_and_clear();
|
||||
html_fmtr.Html_thumb_file_image(tmp_bfr, thumb, Arg_caption_div(ctx, hctx, src, lnki, uid, img_orig_src, lnki_href), lnki_alt_html);
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
private byte[] Bld_caption_div(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, int uid, byte[] img_orig_src, byte[] lnki_href) {
|
||||
byte[] caption = Bld_caption(ctx, hctx, src, lnki);
|
||||
byte[] magnify_btn = lnki.Media_icon() ? html_fmtr.Bld_thumb_part_magnify(lnki_href, msg_file_enlarge) : Bry_.Empty;
|
||||
return html_fmtr.Bld_thumb_part_caption(magnify_btn, caption);
|
||||
}
|
||||
private byte[] Arg_content_audio(Xop_lnki_tkn lnki, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, int uid, byte[] lnki_href, byte[] img_orig_src, byte[] alt) {
|
||||
byte[] info_btn = Bry_.Empty;
|
||||
if (lnki.Media_icon()) {
|
||||
html_fmtr.Html_thumb_part_info(scratch_bfr, uid, hctx.Mode_is_hdump(), lnki_href, html_mgr.Img_media_info_btn());
|
||||
info_btn = scratch_bfr.To_bry_and_clear();
|
||||
}
|
||||
int play_btn_width = lnki.W(); if (play_btn_width < 1) play_btn_width = html_mgr.Img_thumb_width(); // if no width set width to default img width
|
||||
html_fmtr.Html_thumb_file_audio(scratch_bfr, Arg_caption_div(ctx, hctx, src, lnki, uid, img_orig_src, lnki_href), Arg_alt_html(ctx, hctx, src, lnki), Arg_play_btn(hctx.Mode_is_hdump(), uid, play_btn_width, Play_btn_max_width, img_orig_src, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki.Ttl().Page_txt())), info_btn);
|
||||
return scratch_bfr.To_bry_and_clear();
|
||||
private byte[] Bld_caption(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
return lnki.Caption_exists()
|
||||
? caption_fmtr.To_bry(ctx, hctx, src, lnki.Caption_val_tkn(), Bool_.N, Xoh_lnki_text_fmtr.Null__fmt)
|
||||
: Bry_.Empty;
|
||||
}
|
||||
private byte[] Arg_content_video(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xof_file_itm xfer_itm, int uid, boolean lnki_thumb, byte[] lnki_ttl, byte[] a_href, byte[] view_src, byte[] orig_src, byte[] img_alt) {
|
||||
int thumb_w = xfer_itm.Html_w();
|
||||
int play_btn_width = thumb_w; if (play_btn_width < 1) play_btn_width = wiki.Html_mgr().Img_thumb_width();
|
||||
byte[] caption_html = Bry_.Empty, alt_html = Bry_.Empty;
|
||||
if (lnki_thumb) {
|
||||
caption_html = Arg_caption_div(ctx, hctx, src, lnki, uid, orig_src, a_href);
|
||||
alt_html = Arg_alt_html(ctx, hctx, src, lnki);
|
||||
}
|
||||
html_fmtr.Html_thumb_file_video(scratch_bfr
|
||||
, Arg_play_btn(hctx.Mode_is_hdump(), uid, play_btn_width, play_btn_width, orig_src, Xoh_file_html_fmtr__base.Escape_xowa_title(lnki.Ttl().Page_txt()))
|
||||
, html_fmtr.Html_thumb_part_img(scratch_bfr, hctx, page, src, xfer_itm, uid, lnki_ttl, a_href, view_src, img_alt)
|
||||
, caption_html, alt_html);
|
||||
return scratch_bfr.To_bry_and_clear();
|
||||
}
|
||||
private byte[] Arg_caption_div(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, int uid, byte[] img_orig_src, byte[] lnki_href) {
|
||||
Bfr_arg caption = Arg_caption(ctx, src, hctx, lnki);
|
||||
byte[] magnify_btn = Bry_.Empty;
|
||||
if (lnki.Media_icon()) {
|
||||
if (msg_file_enlarge == null) msg_file_enlarge = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_file_enlarge);
|
||||
html_fmtr.Html_thumb_part_magnify(scratch_bfr, uid, lnki_href, msg_file_enlarge, html_mgr.Img_thumb_magnify());
|
||||
magnify_btn = scratch_bfr.To_bry_and_clear();
|
||||
}
|
||||
html_fmtr.Html_thumb_part_caption(scratch_bfr, magnify_btn, caption);
|
||||
return scratch_bfr.To_bry_and_clear();
|
||||
} private byte[] msg_file_enlarge;
|
||||
private Bfr_arg Arg_caption(Xop_ctx ctx, byte[] src, Xoh_wtr_ctx hctx_for_caption, Xop_lnki_tkn lnki) {
|
||||
return lnki.Caption_exists() ? caption_fmtr.Set(ctx, hctx_for_caption, src, lnki.Caption_val_tkn(), Xoh_lnki_text_fmtr.Null_fmtr, Bool_.N) : Bfr_arg_.Noop;
|
||||
}
|
||||
public byte[] Arg_alt_text(Xop_ctx ctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
if (!lnki.Alt_exists()) return Bry_.Empty;
|
||||
media_alt_fmtr.Set(ctx, Xoh_wtr_ctx.Alt, src, lnki.Alt_tkn().Val_tkn(), Xoh_lnki_text_fmtr.Null_fmtr, Bool_.N);
|
||||
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
|
||||
media_alt_fmtr.Bfr_arg__add(tmp_bfr);
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
private byte[] Arg_alt_html(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] alt_src, Xop_lnki_tkn lnki) {
|
||||
if (!lnki.Alt_exists()) return Bry_.Empty;
|
||||
media_alt_fmtr.Set(ctx, hctx, alt_src, lnki.Alt_tkn().Val_tkn(), html_fmtr.Html_thumb_part_alt_fmtr(), Bool_.Y);
|
||||
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
|
||||
media_alt_fmtr.Bfr_arg__add(tmp_bfr);
|
||||
return tmp_bfr.To_bry_and_rls();
|
||||
}
|
||||
private byte[] Arg_play_btn(boolean mode_is_hdump, int uid, int width, int max_width, byte[] a_href, byte[] a_xowa_title) {
|
||||
html_fmtr.Html_thumb_part_play(scratch_bfr, uid, mode_is_hdump, width - 2, max_width, a_href, a_xowa_title, html_mgr.Img_media_play_btn()); // NOTE: -2 is fudge factor else play btn will jut out over video thumb; see Earth and ISS video
|
||||
return scratch_bfr.To_bry_and_clear();
|
||||
}
|
||||
private static byte[] Arg_anchor_title(Bry_bfr tmp_bfr, byte[] src, Xop_lnki_tkn lnki, byte[] lnki_ttl, Xoh_lnki_title_fmtr anchor_title_wkr) {
|
||||
private byte[] Bld_anch_title(Bry_bfr bfr, byte[] src, Xop_lnki_tkn lnki, byte[] lnki_ttl) {
|
||||
if ( Bitmask_.Has_int(lnki.Lnki_type(), Xop_lnki_type.Id_thumb)
|
||||
|| Bitmask_.Has_int(lnki.Lnki_type(), Xop_lnki_type.Id_frame) // If the image is a thumb, do not add a title / alt, even if a caption is available
|
||||
)
|
||||
return Bry_.Empty;
|
||||
return Bry_.Empty;
|
||||
else if ( Bitmask_.Has_int(lnki.Lnki_type(), Xop_lnki_type.Id_frameless)) { // If the image is frameless, add the caption as a title / alt. If no caption is available, do not add a title / alt
|
||||
}
|
||||
Xop_tkn_itm anchor_title_tkn = lnki.Caption_tkn();
|
||||
if (anchor_title_tkn == Xop_tkn_null.Null_tkn) return Bry_.Empty; // no caption; return empty; (do not use lnki); DATE:2013-12-31
|
||||
tmp_bfr.Add(Atr_title);
|
||||
anchor_title_wkr.Set(src, anchor_title_tkn).Bfr_arg__add(tmp_bfr);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Quote);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
Xop_tkn_itm capt_tkn = lnki.Caption_tkn();
|
||||
if (capt_tkn == Xop_tkn_null.Null_tkn) return Bry_.Empty; // no caption; return empty; NOTE: do not use lnki as caption; DATE:2013-12-31
|
||||
|
||||
// build title="text"
|
||||
bfr.Add(Atr_title);
|
||||
Xoh_lnki_title_bldr.Add(bfr, src, capt_tkn);
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public static final int Play_btn_max_width = 1024;
|
||||
public byte[] Bld_alt(boolean html, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
if (!lnki.Alt_exists()) return Bry_.Empty;
|
||||
return html
|
||||
? alt_fmtr.To_bry(ctx, hctx, src, lnki.Alt_tkn().Val_tkn(), Bool_.Y, html_fmtr.Fmt_thumb_part_alt())
|
||||
: alt_fmtr.To_bry(ctx, hctx, src, lnki.Alt_tkn().Val_tkn(), Bool_.N, Xoh_lnki_text_fmtr.Null__fmt);
|
||||
}
|
||||
private byte[] Bld_play_btn(Xoh_wtr_ctx hctx, int uid, byte[] a_href, byte[] lnki_href, int width, int max_width) {
|
||||
return html_fmtr.Bld_thumb_part_play(hctx.Mode_is_hdump(), uid, a_href, Xoh_file_fmtr__basic.Escape_xowa_title(lnki_href)
|
||||
, width - 2, max_width); // NOTE: -2 is fudge factor else play btn will jut out over video thumb; see Earth and ISS video
|
||||
}
|
||||
private int Get_play_btn_width(int w) {return w > 0 ? w : html_mgr.Img_thumb_width();} // if no width set width to default img width
|
||||
|
||||
// private static final int Play_btn_max_width = 1024;
|
||||
private static final byte[]
|
||||
Div_center_bgn = Bry_.new_a7("<div class=\"center\">")
|
||||
, Div_float_none = Bry_.new_a7("<div class=\"floatnone\">")
|
||||
|
||||
@@ -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.*;
|
||||
public class Xoh_file_wtr__image__tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Img__full() { // PURPOSE: full with title was outputting invalid html; DATE:2013-12-31
|
||||
fxt.Wtr_cfg().Lnki__title_(true);
|
||||
@@ -39,6 +39,22 @@ public class Xoh_file_wtr__image__tst {
|
||||
@Test public void Img__embed() {
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|9x8px|alt=abc]]", Xop_fxt.html_img_none("File:A.png", "abc", "file:///mem/wiki/repo/trg/thumb/7/0/A.png/9px.png", "A.png"));
|
||||
}
|
||||
@Test public void Embed_audio() {
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.jpg|thumb|b[[File:C.ogg|right|140x140px]]d]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||
, " <a href=\"/wiki/File:A.jpg\" class=\"image\" xowa_title=\"A.jpg\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/6/7/A.jpg/220px.jpg\" width=\"0\" height=\"0\" /></a>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.jpg\" class=\"internal\" title=\"Enlarge\"></a></div>b <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:C.ogg\" class=\"image\" title=\"C.ogg\" xowa_title=\"C.ogg\"><img id=\"xoimg_1\" alt=\"\" src=\"\" width=\"140\" height=\"140\" /></a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_1\" href=\"file:///mem/wiki/repo/trg/orig/d/3/C.ogg\" xowa_title=\"C.ogg\" class=\"xowa_media_play\" style=\"width:138px;max-width:140px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>d"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Img__none() { // NOTE: floatnone is WP behavior; MW omits div tag
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|none|20x30px|b]]"
|
||||
|
||||
@@ -18,30 +18,64 @@ 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__video__tst {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Video__full() {
|
||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Test public void Video__full__ogv__width_y() {// EX: [[File:A.ogv|320px|bcd|alt=efg]]; DATE:2016-08-05
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "[[File:A.ogv|320px|bcd|alt=efg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"400\" height=\"0\" />"
|
||||
+ "<img id=\"xoimg_0\" alt=\"efg\" src=\"\" width=\"320\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:398px;max-width:400px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full_ogg() {// PURPOSE: ogg should default to video on first load; otherwise dynamic-update won't be able to put in thumb; DATE:2015-05-21
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.ogg", Xof_ext_.Id_ogv, 400, 400, "");
|
||||
@Test public void Video__full__ogv__width_n() {// EX: [[File:A.ogv]]; DATE:2016-08-05
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogg|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "[[File:A.ogv]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" width=\"0\" height=\"0\" />" // NOTE: src should probably be empty;
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__full_ogg() {// PURPOSE: ogg w/ width should default to video; otherwise dynamic-update won't be able to convert audio-button to thumb; DATE:2016-08-05
|
||||
// NOTE: simulates app w/ fsdb
|
||||
Xof_file_fxt file_fxt = Xof_file_fxt.new_all(fxt.Wiki());
|
||||
file_fxt.Exec_orig_add(Bool_.Y, "A.ogg", Xof_ext_.Id_ogv, 320, 300, "");
|
||||
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogg|320px|bcd|alt=efg]]", String_.Concat_lines_nl_skip_last
|
||||
( " <div class=\"xowa_media_div\">"
|
||||
, " <div><a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"A.ogg\" xowa_title=\"A.ogg\"><img id=\"xoimg_0\" alt=\"efg\" src=\"file:///mem/wiki/repo/trg/thumb/4/2/A.ogg/-1px.jpg\" width=\"320\" height=\"300\" /></a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video__thumb_ogg() { // PURPOSE: w/ width should default to video; DATE:2016-08-05
|
||||
// NOTE: simulates hdump w/ no fsdb
|
||||
fxt.Wiki().File_mgr().Version_2_y_();
|
||||
fxt.Wiki().File__fsdb_mode().Tid__v2__bld__y_();
|
||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Hdump);
|
||||
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogg|thumb|320px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:400px;\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:320px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:398px;max-width:1024px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.ogg\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogg\" class=\"image\" title=\"A.ogg\" xowa_title=\"A.ogg\">"
|
||||
+ "<img data-xowa-title=\"A.ogg\" data-xoimg=\"4|320|-1|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" alt=\"b\"/>"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a href=\"\" xowa_title=\"A.ogg\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogg\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
@@ -51,26 +85,30 @@ public class Xoh_file_wtr__video__tst {
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
|
||||
fxt.Wiki().File_mgr().Version_1_y_();
|
||||
fxt.Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Basic);
|
||||
}
|
||||
@Test public void Video__thumb() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.ogv|thumb|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "[[File:A.ogv|thumb|320px|bcd|alt=efg]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\" xowa_title=\"A.ogv\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"400\" height=\"0\" />"
|
||||
+ "<img id=\"xoimg_0\" alt=\"efg\" src=\"\" width=\"320\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:398px;max-width:400px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/d/0/A.ogv\" xowa_title=\"A.ogv\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.ogv\" class=\"internal\" title=\"Enlarge\"></a></div>bcd"
|
||||
, " </div>"
|
||||
, " <hr/>"
|
||||
, " <div class=\"thumbcaption\">b"
|
||||
, " <div class=\"thumbcaption\">efg"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
@@ -79,16 +117,16 @@ public class Xoh_file_wtr__video__tst {
|
||||
}
|
||||
@Test public void Video__thumb_webm() { // PURPOSE: webm thumb wasn't being shown; DATE:2014-01-25
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.webm|thumb|400px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "[[File:A.webm|thumb|320px|a|alt=b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, " <div>"
|
||||
+ "<a href=\"/wiki/File:A.webm\" class=\"image\" title=\"A.webm\" xowa_title=\"A.webm\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"400\" height=\"0\" />"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"\" width=\"320\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
, " </div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/3/4/A.webm\" xowa_title=\"A.webm\" class=\"xowa_media_play\" style=\"width:398px;max-width:400px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a id=\"xowa_file_play_0\" href=\"file:///mem/wiki/repo/trg/orig/3/4/A.webm\" xowa_title=\"A.webm\" class=\"xowa_media_play\" style=\"width:318px;max-width:320px;\" alt=\"Play sound\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.webm\" class=\"internal\" title=\"Enlarge\"></a></div>a"
|
||||
@@ -99,6 +137,6 @@ public class Xoh_file_wtr__video__tst {
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
));
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,27 @@ package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*
|
||||
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_lnki_text_fmtr implements gplx.core.brys.Bfr_arg { // formats alt or caption
|
||||
private final Bry_bfr_mkr bfr_mkr; private final Xoh_html_wtr html_wtr;
|
||||
private Xop_ctx ctx; private Xoh_wtr_ctx hctx; private byte[] src; private Xop_tkn_itm text_tkn; private Bry_fmtr fmtr;
|
||||
private boolean called_by_alt_as_caption;
|
||||
public Xoh_lnki_text_fmtr(Bry_bfr_mkr bfr_mkr, Xoh_html_wtr html_wtr) {this.bfr_mkr = bfr_mkr; this.html_wtr = html_wtr;}
|
||||
public Xoh_lnki_text_fmtr Set(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_tkn_itm text_tkn, Bry_fmtr fmtr, boolean called_by_alt_as_caption) {
|
||||
this.ctx = ctx; this.hctx = hctx; this.src = src; this.text_tkn = text_tkn; this.fmtr = fmtr; this.called_by_alt_as_caption = called_by_alt_as_caption;
|
||||
return this;
|
||||
public class Xoh_lnki_text_fmtr { // formats alt or caption
|
||||
private final Bry_bfr_mkr bfr_mkr; private final Xoh_html_wtr html_wtr;
|
||||
private final Bry_bfr fmt_bfr = Bry_bfr_.Reset(32);
|
||||
public Xoh_lnki_text_fmtr(Bry_bfr_mkr bfr_mkr, Xoh_html_wtr html_wtr) {
|
||||
this.bfr_mkr = bfr_mkr; this.html_wtr = html_wtr;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
|
||||
html_wtr.Write_tkn_to_html(tmp_bfr, ctx, hctx, src, null, Xoh_html_wtr.Sub_idx_null, text_tkn);
|
||||
tmp_bfr.Mkr_rls();
|
||||
byte[] bry = called_by_alt_as_caption
|
||||
? tmp_bfr.To_bry_and_clear_and_trim() // NOTE: Trim to handle ws-only alt; EX:[[File:A.png|thumb|alt= ]]; en.w:Bird; DATE:2015-12-28
|
||||
: tmp_bfr.To_bry();
|
||||
if (bry.length == 0) return;
|
||||
if (fmtr == Null_fmtr)
|
||||
bfr.Add(bry);
|
||||
else
|
||||
fmtr.Bld_bfr_many(bfr, bry);
|
||||
|
||||
public byte[] To_bry(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_tkn_itm text_tkn, boolean called_by_alt_as_caption, Bry_fmt fmt) {
|
||||
// write lnki_text using tkn and html_wtr
|
||||
Bry_bfr html_bfr = bfr_mkr.Get_k004(); // NOTE: do not make bfr member-variable; possible for captions to be nested, especially during call to Write_tkn_to_html
|
||||
html_wtr.Write_tkn_to_html(html_bfr, ctx, hctx, src, null, Xoh_html_wtr.Sub_idx_null, text_tkn);
|
||||
byte[] rv = called_by_alt_as_caption
|
||||
? html_bfr.To_bry_and_clear_and_trim() // NOTE: Trim to handle ws-only alt; EX:[[File:A.png|thumb|alt= ]]; en.w:Bird; DATE:2015-12-28
|
||||
: html_bfr.To_bry_and_clear();
|
||||
html_bfr.Mkr_rls();
|
||||
if (rv.length == 0) return Bry_.Empty; // NOTE: if no text, exit now; else, empty text will generate empty thumb div
|
||||
|
||||
// return value; fmt if necessary
|
||||
return fmt == Null__fmt
|
||||
? rv
|
||||
: fmt.Bld_many_to_bry(fmt_bfr, rv);
|
||||
}
|
||||
public static final Bry_fmtr Null_fmtr = null;
|
||||
public static final Bry_fmt Null__fmt = null;
|
||||
}
|
||||
|
||||
@@ -16,26 +16,22 @@ 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.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 gplx.langs.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*;
|
||||
public class Xoh_lnki_title_fmtr implements gplx.core.brys.Bfr_arg {
|
||||
public Xoh_lnki_title_fmtr Set(byte[] src, Xop_tkn_itm tkn) {this.src = src; this.tkn = tkn; return this;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Bld_recurse(bfr, tkn);
|
||||
}
|
||||
public void Bld_recurse(Bry_bfr bfr, Xop_tkn_itm tkn) {
|
||||
switch (tkn.Tkn_tid()) {
|
||||
case Xop_tkn_itm_.Tid_newLine: case Xop_tkn_itm_.Tid_space: case Xop_tkn_itm_.Tid_txt: // leaf tkns which will have no subs
|
||||
import gplx.langs.htmls.entitys.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*; import gplx.xowa.xtns.cites.*;
|
||||
public class Xoh_lnki_title_bldr {
|
||||
public static void Add(Bry_bfr bfr, byte[] src, Xop_tkn_itm tkn) {Add_recurse(bfr, src, tkn);}
|
||||
private static void Add_recurse(Bry_bfr bfr, byte[] src, Xop_tkn_itm tkn) {
|
||||
switch (tkn.Tkn_tid()) {
|
||||
case Xop_tkn_itm_.Tid_newLine: case Xop_tkn_itm_.Tid_space: case Xop_tkn_itm_.Tid_txt: // leaf tkns have no subs
|
||||
Write_atr_text(bfr, src, tkn.Src_bgn(), tkn.Src_end());
|
||||
break;
|
||||
case Xop_tkn_itm_.Tid_arg_nde: // caption tkns have no subs; just a key and a val; recurse val
|
||||
Arg_nde_tkn arg_nde = (Arg_nde_tkn)tkn;
|
||||
Bld_recurse(bfr, arg_nde.Val_tkn());
|
||||
break;
|
||||
case Xop_tkn_itm_.Tid_arg_nde: // caption tkns have no subs; just a key and a val; recurse val
|
||||
Add_recurse(bfr, src, ((Arg_nde_tkn)tkn).Val_tkn());
|
||||
break;
|
||||
case Xop_tkn_itm_.Tid_lnki:
|
||||
Xop_lnki_tkn tkn_as_lnki = (Xop_lnki_tkn)tkn;
|
||||
if (tkn_as_lnki.Caption_exists())
|
||||
Bld_recurse(bfr, tkn_as_lnki.Caption_tkn());
|
||||
Add_recurse(bfr, src, tkn_as_lnki.Caption_tkn());
|
||||
else {
|
||||
if (tkn_as_lnki.Ttl() != null) { // guard against invalid ttls
|
||||
byte[] ttl_bry = tkn_as_lnki.Ttl().Page_txt();
|
||||
@@ -44,24 +40,22 @@ public class Xoh_lnki_title_fmtr implements gplx.core.brys.Bfr_arg {
|
||||
}
|
||||
if (tkn_as_lnki.Tail_bgn() != -1)
|
||||
bfr.Add_mid(src, tkn_as_lnki.Tail_bgn(), tkn_as_lnki.Tail_end());
|
||||
break;
|
||||
default: // all other tkns, just iterate over subs for txt tkns
|
||||
break;
|
||||
default: // all other tkns, just iterate over subs for txt tkns
|
||||
if (tkn.Tkn_tid() == Xop_tkn_itm_.Tid_xnde) {
|
||||
Xop_xnde_tkn xnde = (Xop_xnde_tkn)tkn;
|
||||
if (xnde.Tag().Id() == Xop_xnde_tag_.Tid__ref) { // if ref, disable tkn
|
||||
gplx.xowa.xtns.cites.Ref_nde ref_xnde = (gplx.xowa.xtns.cites.Ref_nde)xnde.Xnde_xtn();
|
||||
Ref_nde ref_xnde = (Ref_nde)xnde.Xnde_xtn();
|
||||
ref_xnde.Exists_in_lnki_title_(true); // ref found during html_title_wkr's generation; mark ref; will be ignored by references_html_wtr later; DATE:2014-03-05
|
||||
}
|
||||
}
|
||||
int len = tkn.Subs_len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xop_tkn_itm sub = tkn.Subs_get(i);
|
||||
Bld_recurse(bfr, sub);
|
||||
}
|
||||
for (int i = 0; i < len; i++)
|
||||
Add_recurse(bfr, src, tkn.Subs_get(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
public static void Write_atr_text(Bry_bfr bfr, byte[] src, int bgn, int end) {
|
||||
private static void Write_atr_text(Bry_bfr bfr, byte[] src, int bgn, int end) {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
byte b = src[i];
|
||||
switch (b) {
|
||||
@@ -76,6 +70,4 @@ public class Xoh_lnki_title_fmtr implements gplx.core.brys.Bfr_arg {
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] src; Xop_tkn_itm tkn;
|
||||
public static final byte[] Escape_bgn = Bry_.new_a7("&#");
|
||||
}
|
||||
@@ -17,29 +17,27 @@ 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.parsers.*;
|
||||
public class Xoh_lnki_title_fmtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_lnki_title_fmtr_fxt fxt = new Xoh_lnki_title_fmtr_fxt();
|
||||
public class Xoh_lnki_title_bldr_tst {
|
||||
private final Xoh_lnki_title_bldr_fxt fxt = new Xoh_lnki_title_bldr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse("a b c", "a b c");
|
||||
fxt.Test_parse("a ''b'' c", "a b c");
|
||||
fxt.Test_parse("a <i>b</i> c", "a b c");
|
||||
fxt.Test_parse("a\nb", "a b");
|
||||
fxt.Test_parse("a\"b", "a"b");
|
||||
fxt.Test__parse("a b c", "a b c");
|
||||
fxt.Test__parse("a ''b'' c", "a b c");
|
||||
fxt.Test__parse("a <i>b</i> c", "a b c");
|
||||
fxt.Test__parse("a\nb", "a b");
|
||||
fxt.Test__parse("a\"b", "a"b");
|
||||
}
|
||||
@Test public void Lnki__quotes() { // PURPOSE: handle titles with quotes; PAGE:s.w:Styx_(band) DATE:2015-11-29
|
||||
fxt.Test_parse("[[A\"B]]", "A"B");
|
||||
fxt.Test__parse("[[A\"B]]", "A"B");
|
||||
}
|
||||
}
|
||||
class Xoh_lnki_title_fmtr_fxt {
|
||||
class Xoh_lnki_title_bldr_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xoh_lnki_title_fmtr title_wkr = new Xoh_lnki_title_fmtr();
|
||||
public Xoh_lnki_title_fmtr_fxt Clear() {return this;}
|
||||
public void Test_parse(String raw, String expd) {
|
||||
private final Bry_bfr bfr = Bry_bfr_.New();
|
||||
public void Test__parse(String raw, String expd) {
|
||||
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);
|
||||
title_wkr.Set(raw_bry, root).Bld_recurse(bfr, root);
|
||||
Xoh_lnki_title_bldr.Add(bfr, raw_bry, root);
|
||||
Tfds.Eq(expd, bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -76,6 +76,7 @@ public class Xoh_tag_parser implements Gfh_doc_wkr {
|
||||
if (wkr__thm.Parse1(hdoc_wkr, hctx, src, tag_rdr, cur)) return wkr__thm.Src_end();
|
||||
}
|
||||
else if (cur.Atrs__cls_has(Xoh_thm_data.Atr__id__xowa_media_div))
|
||||
// rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__media);
|
||||
rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__img);
|
||||
else if (cur.Atrs__cls_has(Xoh_toc_wtr.Atr__class__toc))
|
||||
rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__toc);
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_thm_html_tst {
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
private final Xoh_make_fxt fxt = new Xoh_make_fxt();
|
||||
@Test public void Image() {
|
||||
fxt.Test__html("[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
@@ -36,7 +36,7 @@ public class Xoh_thm_html_tst {
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div class=\"thumbinner\" style=\"width:11px;\">"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a href=\"\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:9px;max-width:11px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div><a href=\"/wiki/File:A.oga\" class=\"xowa_media_info\" title=\"About this file\"></a></div>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
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.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__avo__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Video() {
|
||||
fxt.Test__bicode("~&%test_caption~|E9eA.ogv~%A.ogv~~", Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "test_caption</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
@Test public void Audio() {
|
||||
fxt.Test__bicode(Gfh_utl.Replace_apos(String_.Concat_lines_nl
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class=\"xowa_media_div\">"
|
||||
, "<div><a href=\"\" xowa_title=\"A.oga\" class=\"xowa_media_play\" style=\"width:218px;max-width:220px;\" alt=\"Play sound\"></a></div>"
|
||||
, "<div>$|#na)A.ogaAbout this file</div>"
|
||||
, "</div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~$|%%,)~A.oga~Enlarge~</div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
)), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "<div><a href='/wiki/File:A.oga' class='xowa_media_info' title='About this file'></a></div>"
|
||||
, "</div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.oga' class='internal' title='Enlarge'></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
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.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__basic__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Image() {
|
||||
fxt.Test__bicode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Capt_is_missing() { // [[File:A.png|thumb]]
|
||||
fxt.Test__bicode("~&#~!%A.png~)#S~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fix__omitted_table_tail() { // PURPOSE.hdiff: handle omitted </table>; PAGE:en.w:Alphabet; DATE:2016-01-06
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&]&D~"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "~!5A.png~-&D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:460px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|460|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Div_width_uses_img_width() {
|
||||
Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, Bry_.new_a7("en.w"), Bry_.new_a7("A.png"), Xop_lnki_type.Id_null, -1, 220, -1, -1, -1, 0);
|
||||
itm.Init_at_cache(true, 400, 440, Io_url_.mem_fil_("mem/A.png"));
|
||||
Xou_cache_finder_mem finder = fxt.Init_file_mgr__mem();
|
||||
finder.Add(itm);
|
||||
|
||||
fxt.Test__decode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:400px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='file:///mem/A.png' width='400' height='440' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
|
||||
fxt.Init_file_mgr__noop();
|
||||
}
|
||||
// @Test public void Dump() {
|
||||
// Xowe_wiki en_d = fxt.Init_wiki_alias("wikt", "en.wiktionary.org");
|
||||
// gplx.xowa.wikis.nss.Xow_ns_mgr ns_mgr = en_d.Ns_mgr();
|
||||
// ns_mgr.Ns_main().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
//
|
||||
// fxt.Wiki().Ns_mgr().Aliases_add(gplx.xowa.wikis.nss.Xow_ns_.Tid__portal, "WP");
|
||||
// fxt.Wiki().Ns_mgr().Init();
|
||||
//
|
||||
// fxt.Init_mode_is_b256_(Bool_.N);
|
||||
// fxt.Exec_write_to_fsys(Io_url_.new_dir_("C:\\xowa\\debug\\html\\"), "hzip.html");
|
||||
// fxt.Init_mode_is_b256_(Bool_.N);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
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.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__pseudo__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Fake__div_1__next_nde() { // PURPOSE: handle fake-thumbs with pseudo thumbimage class; PAGE:s.w:Mars
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'>~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'><a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__style() { // PURPOSE.hdiff: handle fake-thumbs with bad style; PAGE:en.w:Carlisle_United_F.C.
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~${#7)A.jpg~</div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__width_w_space() { // PURPOSE.hdiff: handle fake-thumbs with style of "width "; PAGE:en.w:Abraham_Lincoln
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~${#7)A.jpg~</div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__thumbimage() { // PURPOSE.hdiff: handle fake-thumbs with image-map style; PAGE:en.w:UK
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;'>"
|
||||
, "<div class='thumbimage' style='width:250px;'>"
|
||||
, "<center>"
|
||||
, "<div style='width: 250px; float: none; margin: none; padding: none; border: none; clear: none; background-color: #ffffff; position: relative;'>"
|
||||
, "{0}"
|
||||
, "<div style='font-size: smaller; line-height: 10px;'>"
|
||||
, "<div style='position:absolute;text-align:center;left:150.25px;top:292px'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</center>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>def</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div style=\"background-color: ;\">~%!!A.svg~)#q~</div>"), "'", "\""), String_.Format(html, "<div style='background-color: ;'><a href='/wiki/File:A.svg' class='image' title='' xowa_title='A.svg'><img data-xowa-title='A.svg' data-xoimg='0|250|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"));
|
||||
}
|
||||
@Test public void Fake__div_1__extra_attribs() {// PURPOSE.hdiff: handle fake thumbs with extra attribs; PAGE:en.w:Wikipedia:New_CSS_framework; DATE:2016-01-11
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;color:blue;'>{0}" // "color:blue;" is invalid attribs
|
||||
, "<div class='thumbcaption'>abc"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "~%!!A.png~)#g~"), "'", "\""), String_.Format(html, "<a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"));
|
||||
}
|
||||
@Test public void Fake__div_2__not_media() { // PURPOSE.hdiff: handle fake-thumbs created through en.w:Template:Image_label_begin; PAGE:en.w:Blackburnshire; DATE:2016-01-04
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:240px;'>"
|
||||
, "<div style='width: 240pxpx;'>"
|
||||
, "{0}"
|
||||
, "<div>abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "{1}"
|
||||
, "bcd</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div>~%!!A.png~)#g~</div>", "<div class=\"magnify\">~$a)A.png~</div>"), "'", "\""), String_.Format(html, "<div><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>", "<div class='magnify'><a href='/wiki/File:A.png' title='File:A.png'>A.png</a></div>"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
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.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip__tidy__tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Tidy__moved_capt() {
|
||||
fxt.Test__bicode("~&S~abc\n~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__extra_closing_div() {// handle extra closing div in caption; PAGE:en.w:Damask; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&U<div>A</div>"
|
||||
, "B~"
|
||||
, "C~!1A.png~-\"b"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|150|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "<div>A</div>"
|
||||
, "B</div>"
|
||||
, "C</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__ul() { // tidy will move <div> on to different lines depending on <ul>; PAGE:en.w:Chimney_sweep; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&=$b* ABC~"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "~!uA.png~-$bABC~"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:320px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|320|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='ABC'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "* ABC</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__video() { // tidy may relocate xowa-alt-div to last div; PAGE:en.w:Non-helical_models_of_DNA_structure; DATE:2016-01-11
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&eabc~"
|
||||
, "<hr>"
|
||||
, "<div class=\"thumbcaption\">bcd</div>"
|
||||
, "~|E9eA.ogv~%A.ogv~~"), Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>bcd</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -1,339 +0,0 @@
|
||||
/*
|
||||
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.core.wkrs.thms; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.caches.*; import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xoh_thm_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Before public void setup() {fxt.Clear();}
|
||||
@Test public void Image() {
|
||||
fxt.Test__bicode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Video() {
|
||||
fxt.Test__bicode("~&%test_caption~|E9eA.ogv~%A.ogv~~", Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "test_caption</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
@Test public void Audio() {
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'/></div>"
|
||||
, "<div>~$|#na)~A.oga~About this file~</div>"
|
||||
, " </div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~$|%%,)~A.oga~Enlarge~</div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, " <div class='thumbinner' style='width:11px;'>"
|
||||
, " <div class='xowa_media_div'>"
|
||||
, "<div><a href='' xowa_title='A.oga' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'/></div>"
|
||||
, "<div><a href='/wiki/File:A.oga' class='xowa_media_info' title='About this file'></a></div>"
|
||||
, " </div>"
|
||||
, " <div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.oga' class='internal' title='Enlarge'></a></div>b"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Capt_is_missing() { // [[File:A.png|thumb]]
|
||||
fxt.Test__bicode("~&#~!%A.png~)#S~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__moved_capt() {
|
||||
fxt.Test__bicode("~&S~abc\n~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__extra_closing_div() {// handle extra closing div in caption; PAGE:en.w:Damask; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&U<div>A</div>"
|
||||
, "B~"
|
||||
, "C~!1A.png~-\"b"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|150|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "<div>A</div>"
|
||||
, "B</div>"
|
||||
, "C</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__ul() { // tidy will move <div> on to different lines depending on <ul>; PAGE:en.w:Chimney_sweep; DATE:2016-01-05
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&=$b* ABC~"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "~!uA.png~-$bABC~"), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:320px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|320|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt='ABC'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "* ABC</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<ul>"
|
||||
, "<li>ABC</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Tidy__video() { // tidy may relocate xowa-alt-div to last div; PAGE:en.w:Non-helical_models_of_DNA_structure; DATE:2016-01-11
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&eabc~"
|
||||
, "<hr>"
|
||||
, "<div class=\"thumbcaption\">bcd</div>"
|
||||
, "~|E9eA.ogv~%A.ogv~~"), Gfh_utl.Replace_apos(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:220px;'>"
|
||||
, "<div class='xowa_media_div'>"
|
||||
, "<div><a href='/wiki/File:A.ogv' class='image' title='A.ogv' xowa_title='A.ogv'><img data-xowa-title='A.ogv' data-xoimg='4|-1|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"
|
||||
, "<div><a href='' xowa_title='A.ogv' class='xowa_media_play' style='width:218px;max-width:220px;' alt='Play sound'></a></div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.ogv' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>bcd</div>"
|
||||
, "</div>"
|
||||
)));
|
||||
}
|
||||
@Test public void Fake__div_1__next_nde() { // PURPOSE: handle fake-thumbs with pseudo thumbimage class; PAGE:s.w:Mars
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'>~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright' style='width:212px;'>"
|
||||
, "<div class='thumbinner'>"
|
||||
, "<div style='margin:1px;width:202px;'>"
|
||||
, "<div class='thumbimage'><a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption' style='clear:left;'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__style() { // PURPOSE.hdiff: handle fake-thumbs with bad style; PAGE:en.w:Carlisle_United_F.C.
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~${#7)A.jpg~</div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: px;'>"
|
||||
, "<div style='position: relative; top: -75px; left: -px; width: 200px'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__width_w_space() { // PURPOSE.hdiff: handle fake-thumbs with style of "width "; PAGE:en.w:Abraham_Lincoln
|
||||
fxt.Test__bicode(String_.Replace(String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "~%-eA.jpg~Image~)#?A.jpg~abc~</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'>~${#7)A.jpg~</div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
), "'", "\""), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width: 230px;'>"
|
||||
, "<div style='width: 230px; height: 270px; overflow: hidden;'>"
|
||||
, "<a href='/wiki/Image:A.jpg' class='image' title='A.jpg' xowa_title='A.jpg'><img data-xowa-title='A.jpg' data-xoimg='0|200|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a></div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.jpg' title='File:A.jpg'>File:A.jpg</a></div>"
|
||||
, "abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Fake__div_1__thumbimage() { // PURPOSE.hdiff: handle fake-thumbs with image-map style; PAGE:en.w:UK
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;'>"
|
||||
, "<div class='thumbimage' style='width:250px;'>"
|
||||
, "<center>"
|
||||
, "<div style='width: 250px; float: none; margin: none; padding: none; border: none; clear: none; background-color: #ffffff; position: relative;'>"
|
||||
, "{0}"
|
||||
, "<div style='font-size: smaller; line-height: 10px;'>"
|
||||
, "<div style='position:absolute;text-align:center;left:150.25px;top:292px'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "</center>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>def</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div style=\"background-color: ;\">~%!!A.svg~)#q~</div>"), "'", "\""), String_.Format(html, "<div style='background-color: ;'><a href='/wiki/File:A.svg' class='image' title='' xowa_title='A.svg'><img data-xowa-title='A.svg' data-xoimg='0|250|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>"));
|
||||
}
|
||||
@Test public void Fake__div_1__extra_attribs() {// PURPOSE.hdiff: handle fake thumbs with extra attribs; PAGE:en.w:Wikipedia:New_CSS_framework; DATE:2016-01-11
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:252px;color:blue;'>{0}" // "color:blue;" is invalid attribs
|
||||
, "<div class='thumbcaption'>abc"
|
||||
, "abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "~%!!A.png~)#g~"), "'", "\""), String_.Format(html, "<a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a>"));
|
||||
}
|
||||
@Test public void Fake__div_2__not_media() { // PURPOSE.hdiff: handle fake-thumbs created through en.w:Template:Image_label_begin; PAGE:en.w:Blackburnshire; DATE:2016-01-04
|
||||
String html = String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:240px;'>"
|
||||
, "<div style='width: 240pxpx;'>"
|
||||
, "{0}"
|
||||
, "<div>abc"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
, "<div class='thumbcaption'>"
|
||||
, "{1}"
|
||||
, "bcd</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
);
|
||||
fxt.Test__bicode(String_.Replace(String_.Format(html, "<div>~%!!A.png~)#g~</div>", "<div class=\"magnify\">~$a)A.png~</div>"), "'", "\""), String_.Format(html, "<div><a href='/wiki/File:A.png' class='image' title='' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|240|-1|-1|-1|-1' src='' width='0' height='0' alt=''></a></div>", "<div class='magnify'><a href='/wiki/File:A.png' title='File:A.png'>A.png</a></div>"));
|
||||
}
|
||||
@Test public void Fix__omitted_table_tail() { // PURPOSE.hdiff: handle omitted </table>; PAGE:en.w:Alphabet; DATE:2016-01-06
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~&]&D~"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "~!5A.png~-&D"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tright'>"
|
||||
, "<div class='thumbinner' style='width:460px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='4|460|-1|-1|-1|-1' src='' width='0' height='0' class='thumbimage' alt=''></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "</div>"
|
||||
, "<table>"
|
||||
, "<tr>"
|
||||
, "<td>"
|
||||
, "abc"
|
||||
, "</td>"
|
||||
, "</tr>"
|
||||
, "</table>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Div_width_uses_img_width() {
|
||||
Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
itm.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, Bry_.new_a7("en.w"), Bry_.new_a7("A.png"), Xop_lnki_type.Id_null, -1, 220, -1, -1, -1, 0);
|
||||
itm.Init_at_cache(true, 400, 440, Io_url_.mem_fil_("mem/A.png"));
|
||||
Xou_cache_finder_mem finder = fxt.Init_file_mgr__mem();
|
||||
finder.Add(itm);
|
||||
|
||||
fxt.Test__decode("~&3abc~abc~!uA.png~)#Sabc~", String_.Concat_lines_nl_skip_last
|
||||
( "<div class='thumb tleft'>"
|
||||
, "<div class='thumbinner' style='width:400px;'><a href='/wiki/File:A.png' class='image' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='file:///mem/A.png' width='400' height='440' class='thumbimage' alt='abc'></a> "
|
||||
, "<div class='thumbcaption'>"
|
||||
, "<div class='magnify'><a href='/wiki/File:A.png' class='internal' title='Enlarge'></a></div>"
|
||||
, "abc</div>"
|
||||
, "<hr>"
|
||||
, "<div class='thumbcaption'>abc</div>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
|
||||
fxt.Init_file_mgr__noop();
|
||||
}
|
||||
// @Test public void Dump() {
|
||||
// Xowe_wiki en_d = fxt.Init_wiki_alias("wikt", "en.wiktionary.org");
|
||||
// gplx.xowa.wikis.nss.Xow_ns_mgr ns_mgr = en_d.Ns_mgr();
|
||||
// ns_mgr.Ns_main().Case_match_(gplx.xowa.wikis.nss.Xow_ns_case_.Tid__all);
|
||||
//
|
||||
// fxt.Wiki().Ns_mgr().Aliases_add(gplx.xowa.wikis.nss.Xow_ns_.Tid__portal, "WP");
|
||||
// fxt.Wiki().Ns_mgr().Init();
|
||||
//
|
||||
// fxt.Init_mode_is_b256_(Bool_.N);
|
||||
// fxt.Exec_write_to_fsys(Io_url_.new_dir_("C:\\xowa\\debug\\html\\"), "hzip.html");
|
||||
// fxt.Init_mode_is_b256_(Bool_.N);
|
||||
// }
|
||||
}
|
||||
33
400_xowa/src/gplx/xowa/htmls/encoders/Xow_encoder_mgr.java
Normal file
33
400_xowa/src/gplx/xowa/htmls/encoders/Xow_encoder_mgr.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.encoders; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
public class Xow_encoder_mgr {
|
||||
public Gfo_url_encoder Id() {return id;} private final Gfo_url_encoder id = Gfo_url_encoder_.New__html_id().Make();
|
||||
public Gfo_url_encoder Href() {return href;} private final Gfo_url_encoder href = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Make();
|
||||
public Gfo_url_encoder Href_wo_anch() {return href_wo_anch;} private final Gfo_url_encoder href_wo_anch = Gfo_url_encoder_.New__html_href_mw(Bool_.N).Make();
|
||||
// , Href_quotes = Gfo_url_encoder_.New__html_href_quotes().Make()
|
||||
// , Href_quotes_v2 = Gfo_url_encoder_.New__html_href_quotes_v2().Make()
|
||||
// , Href_qarg = Gfo_url_encoder_.New__html_href_qarg().Make()
|
||||
// , Xourl = Gfo_url_encoder_.New__html_href_mw(Bool_.Y).Init__same__many(Byte_ascii.Underline).Make()
|
||||
// , Http_url = Gfo_url_encoder_.New__http_url().Make()
|
||||
// , Http_url_ttl = Gfo_url_encoder_.New__http_url_ttl().Make()
|
||||
// , Fsys_lnx = Gfo_url_encoder_.New__fsys_lnx().Make()
|
||||
// , Fsys_wnt = Gfo_url_encoder_.New__fsys_wnt().Make()
|
||||
// , Gfs = Gfo_url_encoder_.New__gfs().Make()
|
||||
}
|
||||
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.langs.htmls.entitys.*;
|
||||
public class Xoh_js_cleaner {
|
||||
private Xoae_app app; private boolean ctor = true;
|
||||
public Xoh_js_cleaner(Xoae_app app) {this.app = app;}
|
||||
@@ -49,7 +50,7 @@ public class Xoh_js_cleaner {
|
||||
int frag_len = frag.length;
|
||||
if (frag[0] == Byte_ascii.Lt) { // jscript node; EX: <script
|
||||
if (!dirty) {bfr.Add_mid(src, bgn, pos); dirty = true;}
|
||||
bfr.Add(gplx.langs.htmls.Gfh_entity_.Lt_bry);
|
||||
bfr.Add(Gfh_entity_.Lt_bry);
|
||||
bfr.Add_mid(frag, 1, frag.length);
|
||||
pos += frag_len;
|
||||
}
|
||||
@@ -60,7 +61,7 @@ public class Xoh_js_cleaner {
|
||||
else {
|
||||
if (!dirty) {bfr.Add_mid(src, bgn, pos); dirty = true;}
|
||||
bfr.Add(frag);
|
||||
bfr.Add(gplx.langs.htmls.Gfh_entity_.Eq_bry);
|
||||
bfr.Add(Gfh_entity_.Eq_bry);
|
||||
pos = atr_pos;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Xoh_file_page_wtr {
|
||||
, " <div><a href=\"~{lnki_url}\" xowa_title=\"~{xowa_title}\" class=\"xowa_media_play\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
), "lnki_url", "xowa_title", "play_width", "play_max_width", "play_icon");
|
||||
), "lnki_url", "xowa_title", "play_width", "play_max_width");
|
||||
public Bry_fmtr Html_main_vid() {return html_main_vid;} private final Bry_fmtr html_main_vid = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"fullImageLink\" id=\"file\">"
|
||||
, " <div>"
|
||||
@@ -92,7 +92,7 @@ public class Xoh_file_page_wtr {
|
||||
, " <div><a href=\"~{lnki_url}\" xowa_title=\"~{xowa_title}\" class=\"xowa_media_play\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\" alt=\"Play sound\"></a></div>"
|
||||
, "</div>"
|
||||
, ""
|
||||
), "elem_id", "lnki_href", "lnki_class", "xowa_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt", "lnki_url", "play_width", "play_max_width", "play_icon");
|
||||
), "elem_id", "lnki_href", "lnki_class", "xowa_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt", "lnki_url", "play_width", "play_max_width");
|
||||
public Bry_fmtr Html_alts() {return html_alts;} private final Bry_fmtr html_alts = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( " <a href=\"~{thumb_href}\" class=\"mw-thumbnail-link\" xowa_title=\"~{xowa_title}\">"
|
||||
, " ~{thumb_width} × ~{thumb_height}"
|
||||
|
||||
@@ -24,12 +24,11 @@ public class Xoh_ns_file_page_mgr implements gplx.core.brys.Bfr_arg {
|
||||
private Xoa_ttl ttl; private Xoh_file_page_wtr html_wtr; private final Xoh_file_page__other_resolutions alt_wtr = new Xoh_file_page__other_resolutions();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private Xow_repo_mgr repo_mgr;
|
||||
private Xof_file_itm xfer_itm; private byte[] file_size_bry; private byte[] play_btn_icon;
|
||||
private Xof_file_itm xfer_itm; private byte[] file_size_bry;
|
||||
private final Xof_img_size img_size = new Xof_img_size(); private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2();
|
||||
public void Bld_html(Xowe_wiki cur_wiki, Xop_ctx ctx, Xoae_page page, Bry_bfr bfr, Xoa_ttl ttl, Xoh_file_page_wtr html_wtr, Xof_xfer_queue queue) {
|
||||
Xowe_wiki wiki = (Xowe_wiki)page.Commons_mgr().Source_wiki_or(cur_wiki);
|
||||
this.ttl = ttl; this.html_wtr = html_wtr; this.repo_mgr = wiki.File__repo_mgr();
|
||||
this.play_btn_icon = wiki.Html_mgr().Img_media_play_btn();
|
||||
this.xfer_itm = wiki.Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(Xof_exec_tid.Tid_wiki_file, ctx, ctx.Page(), queue, ttl.Page_txt()
|
||||
, Xop_lnki_type.Id_thumb, Xop_lnki_tkn.Upright_null, html_wtr.Main_img_w(), html_wtr.Main_img_h(), Xof_lnki_time.Null, Xof_lnki_page.Null, Bool_.N);
|
||||
Xof_orig_itm orig = wiki.File_mgr().Orig_mgr().Find_by_ttl_or_null(xfer_itm.Lnki_ttl());
|
||||
@@ -50,9 +49,8 @@ public class Xoh_ns_file_page_mgr implements gplx.core.brys.Bfr_arg {
|
||||
html_wtr.Html_main().Bld_bfr_many(bfr, this, commons_notice);
|
||||
}
|
||||
|
||||
public void Bld_html(Xowe_wiki wiki, Bry_bfr bfr, Xof_file_itm xfer_itm, Xoa_ttl ttl, Xoh_file_page_wtr html_wtr, byte[] file_size_bry, byte[] play_btn_icon) { // TEST:
|
||||
public void Bld_html(Xowe_wiki wiki, Bry_bfr bfr, Xof_file_itm xfer_itm, Xoa_ttl ttl, Xoh_file_page_wtr html_wtr, byte[] file_size_bry) { // TEST:
|
||||
this.ttl = ttl; this.html_wtr = html_wtr; this.repo_mgr = wiki.File__repo_mgr();
|
||||
this.play_btn_icon = play_btn_icon;
|
||||
this.xfer_itm = xfer_itm; this.file_size_bry = file_size_bry;
|
||||
html_wtr.Html_main().Bld_bfr_many(bfr, this, "");
|
||||
}
|
||||
@@ -67,9 +65,9 @@ public class Xoh_ns_file_page_mgr implements gplx.core.brys.Bfr_arg {
|
||||
, alt_bry, xowa_title, alt_wtr);
|
||||
else if (orig_ext.Id_is_video()) // NOTE: video must precede audio else File:***.ogg will not show thumbs
|
||||
html_wtr.Html_main_vid().Bld_bfr_many(bfr, xfer_itm.Html_uid(), xfer_itm.Html_view_url().To_http_file_bry(), Atr_class_image, xowa_title
|
||||
, xfer_itm.Html_view_url().To_http_file_bry(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_url().To_http_file_bry(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
|
||||
, xfer_itm.Html_view_url().To_http_file_bry(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_url().To_http_file_bry(), xfer_itm.Html_w(), xfer_itm.Html_w());
|
||||
else if (orig_ext.Id_is_audio())
|
||||
html_wtr.Html_main_aud().Bld_bfr_many(bfr, xfer_itm.Html_orig_url().To_http_file_bry(), xowa_title, xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
|
||||
html_wtr.Html_main_aud().Bld_bfr_many(bfr, xfer_itm.Html_orig_url().To_http_file_bry(), xowa_title, xfer_itm.Html_w(), xfer_itm.Html_w());
|
||||
}
|
||||
private static final byte[] Atr_class_image = Bry_.new_a7("image");
|
||||
private static final String Str_commons_notice = String_.Concat_lines_nl_skip_last
|
||||
|
||||
@@ -100,9 +100,9 @@ class Xoh_ns_file_page_mgr_fxt {
|
||||
// file.Orig_ttl_and_redirect_(ttl_bry, Bry_.Empty);
|
||||
file.Init_at_orig(Byte_.Zero, wiki.Domain_bry(), ttl_bry, Xof_ext_.new_by_ttl_(ttl_bry), 0, 0, Bry_.Empty);
|
||||
file.Init_at_hdoc(0, Xof_html_elem.Tid_img);
|
||||
wkr.Bld_html(wiki, bfr, file, ttl, opt, Bry_.To_a7_bry(html_file_size, 0), play_btn_icon); // TEST: must pass in elem_val b/c test only uses 2nd Bld_html while app uses 1st
|
||||
wkr.Bld_html(wiki, bfr, file, ttl, opt, Bry_.To_a7_bry(html_file_size, 0)); // TEST: must pass in elem_val b/c test only uses 2nd Bld_html while app uses 1st
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
} static final byte[] play_btn_icon = Bry_.new_a7("file:///mem/xowa/bin/any/xowa/file/mediawiki.file/play.png");
|
||||
}
|
||||
public static final String Hdr = String_.Concat_lines_nl_skip_last
|
||||
( "<ul id=\"filetoc\">"
|
||||
, " <li>"
|
||||
|
||||
@@ -21,12 +21,13 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.htmls.sidebar.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.*; import gplx.xowa.apps.apis.xowa.html.skins.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.htmls.portal.vnts.*;
|
||||
public class Xow_portal_mgr implements Gfo_invk {
|
||||
private Xowe_wiki wiki; private boolean lang_is_rtl; private Xoapi_toggle_itm toggle_itm;
|
||||
private final Vnt_mnu_grp_fmtr vnt_menu_fmtr = new Vnt_mnu_grp_fmtr();
|
||||
private final Gfo_url_encoder fsys_lnx_encoder = Gfo_url_encoder_.New__fsys_lnx().Make();
|
||||
public Xow_portal_mgr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.sidebar_mgr = new Xowh_sidebar_mgr(wiki);
|
||||
@@ -53,7 +54,7 @@ public class Xow_portal_mgr implements Gfo_invk {
|
||||
byte[] wiki_user_name = wiki.User().Name();
|
||||
div_personal_bry = Init_fmtr(tmp_bfr, eval_mgr, div_personal_fmtr, Bry_.Add(Xoh_href_.Bry__wiki, wiki.Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__user).Name_db_w_colon(), wiki_user_name), wiki_user_name, Ns_cls_by_id(wiki.Ns_mgr(), Xow_ns_.Tid__user), Bry_.Add(Xoh_href_.Bry__wiki, wiki.Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__user_talk).Name_db_w_colon(), wiki_user_name), Ns_cls_by_id(wiki.Ns_mgr(), Xow_ns_.Tid__user_talk));
|
||||
byte[] main_page_href_bry = tmp_bfr.Add(Xoh_href_.Bry__site).Add(wiki.Domain_bry()).Add(Xoh_href_.Bry__wiki).To_bry_and_clear(); // NOTE: build /site/en.wikipedia.org/wiki/ href; no Main_Page, as that will be inserted by Xoh_href_parser
|
||||
div_logo_bry = Init_fmtr(tmp_bfr, eval_mgr, div_logo_fmtr, main_page_href_bry, gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx.Encode_to_file_protocol(wiki.Appe().Usere().Fsys_mgr().Wiki_root_dir().GenSubFil_nest(wiki.Domain_str(), "html", "logo.png")));
|
||||
div_logo_bry = Init_fmtr(tmp_bfr, eval_mgr, div_logo_fmtr, main_page_href_bry, fsys_lnx_encoder.Encode_to_file_protocol(wiki.Appe().Usere().Fsys_mgr().Wiki_root_dir().GenSubFil_nest(wiki.Domain_str(), "html", "logo.png")));
|
||||
div_home_bry = Init_fmtr(tmp_bfr, eval_mgr, div_home_fmtr);
|
||||
div_wikis_fmtr.Eval_mgr_(eval_mgr);
|
||||
Xow_msg_mgr msg_mgr = wiki.Msg_mgr();
|
||||
|
||||
@@ -28,8 +28,8 @@ public class Xowh_sidebar_mgr implements Gfo_invk {
|
||||
try {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Xol_msg_itm sidebar_msg = Xol_msg_mgr_.Get_msg_itm(bfr, wiki, wiki.Lang(), CONST_sidebar_ttl);
|
||||
if ( sidebar_msg.Src() == Xol_msg_itm.Src_missing
|
||||
|| ( sidebar_msg.Src() == Xol_msg_itm.Src_lang
|
||||
if ( sidebar_msg.Defined_in() == Xol_msg_itm.Defined_in__none
|
||||
|| ( sidebar_msg.Defined_in() == Xol_msg_itm.Defined_in__lang
|
||||
&& wiki.Domain_tid() == gplx.xowa.wikis.domains.Xow_domain_tid_.Int__home
|
||||
)) {
|
||||
html_bry = Bry_.Empty;
|
||||
|
||||
Reference in New Issue
Block a user