1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-08-17 23:27:07 -04:00
parent 56128795f5
commit df7fcf8eae
231 changed files with 2433 additions and 3347 deletions

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa; import gplx.*;
import gplx.xowa.gui.*; import gplx.xowa.gui.views.*; import gplx.xowa.html.*; import gplx.xowa.pages.*;
import gplx.xowa.files.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.html.tocs.*;
import gplx.xowa.html.modules.popups.*;
import gplx.xowa.html.modules.popups.*; import gplx.xowa.dbs.hdumps.*;
public class Xoa_page {
Xoa_page(Xow_wiki wiki, Xoa_ttl ttl) {
this.wiki = wiki; this.ttl = ttl;
@@ -35,7 +35,7 @@ public class Xoa_page {
public Xoa_ttl Ttl() {return ttl;} public Xoa_page Ttl_(Xoa_ttl v) {ttl = v; url.Wiki_bry_(wiki.Domain_bry()).Page_bry_(v.Full_url()); return this;} private Xoa_ttl ttl;
public Xoa_url Url() {return url;} public Xoa_page Url_(Xoa_url v) {url = v; return this;} private Xoa_url url = Xoa_url.blank_();
public Xog_tab_itm Tab() {return tab;} public void Tab_(Xog_tab_itm v) {tab = v;} private Xog_tab_itm tab;
public Xopg_hdump_data Hdump_data() {return hdump_data;} private Xopg_hdump_data hdump_data = new Xopg_hdump_data();
public boolean Missing() {return missing;} public Xoa_page Missing_() {return Missing_(true);} public Xoa_page Missing_(boolean v) {missing = v; return this;} private boolean missing;
public boolean Redirected() {return redirected;} public Xoa_page Redirected_(boolean v) {redirected = v; return this;} private boolean redirected;
public ListAdp Redirected_ttls() {return redirected_ttls;} private ListAdp redirected_ttls = ListAdp_.new_();
@@ -79,6 +79,7 @@ public class Xoa_page {
file_queue.Clear();
ref_mgr.Grps_clear();
html_cmd_mgr.Clear();
hdump_data.Clear();
wdata_external_lang_links.Reset();
gplx.xowa.xtns.scribunto.Scrib_core.Core_page_changed(this);
lang_convert_content = lang_convert_title = true;

View File

@@ -16,7 +16,7 @@ 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; import gplx.*;
import gplx.xowa.html.*;
import gplx.html.*;
public class Xoh_dom_ {
private static final byte[] Lt_bry = Bry_.new_ascii_("<"), Space_bry = Bry_.new_ascii_(" ");
public static byte[] Query_val_by_where(Xoh_find rv, byte[] src, byte[] where_nde, byte[] where_key, byte[] where_val, byte[] query_key, int bgn) {
@@ -49,18 +49,18 @@ public class Xoh_dom_ {
int tag_end = Bry_finder.Find_fwd(src, Byte_ascii.Gt, tag_bgn, rng_end); if (tag_end == Bry_.NotFound) return false;
int key_bgn = Bry_finder.Find_fwd(src, key, tag_bgn, tag_end); if (key_bgn == Bry_.NotFound) return false;
int key_end = key_bgn + key.length;
int val_bgn = Bry_finder.Find_fwd(src, Byte_ascii.Quote, key_end, tag_end); if (val_bgn == Bry_.NotFound) return false;
int val_bgn = Bry_finder.Find_fwd(src, Byte_ascii.Quote, key_end, tag_end); if (val_bgn == Bry_.NotFound) return false;
++val_bgn;
int val_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, val_bgn, tag_end); if (val_end == Bry_.NotFound) return false;
int val_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, val_bgn, tag_end); if (val_end == Bry_.NotFound) return false;
rv.Set_all(tag_bgn, tag_end, key_bgn, key_end, val_bgn, val_end);
return true;
}
public static boolean Find_atr_val_in_tag(Xoh_find rv, byte[] src, byte[] key, int tag_bgn, int tag_end) {
int key_bgn = Bry_finder.Find_fwd(src, key, tag_bgn, tag_end); if (key_bgn == Bry_.NotFound) return false;
int key_end = key_bgn + key.length;
int val_bgn = Bry_finder.Find_fwd(src, Byte_ascii.Quote, key_end, tag_end); if (val_bgn == Bry_.NotFound) return false;
int val_bgn = Bry_finder.Find_fwd(src, Byte_ascii.Quote, key_end, tag_end); if (val_bgn == Bry_.NotFound) return false;
++val_bgn;
int val_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, val_bgn, tag_end); if (val_end == Bry_.NotFound) return false;
int val_end = Bry_finder.Find_fwd(src, Byte_ascii.Quote, val_bgn, tag_end); if (val_end == Bry_.NotFound) return false;
rv.Set_all(tag_bgn, tag_end, key_bgn, key_end, val_bgn, val_end);
return true;
}
@@ -71,7 +71,7 @@ public class Xoh_dom_ {
bfr.Add_mid(href_dec, 0, slash_pos + Int_.Const_dlm_len); // include trailing slash
bfr.Add(name_enc);
byte[] href_enc = bfr.XtoAryAndClear();
byte[] xowa_title = Xoh_dom_.Query_val_by_where(dom_find, html_src, Xoh_html_tag.Nde_a_bry, Xoh_html_tag.Nde_href_bry, href_enc, Xoh_html_tag.Nde_xowa_title_bry, 0);
byte[] xowa_title = Xoh_dom_.Query_val_by_where(dom_find, html_src, Html_tag_.A_name_bry, Html_atr_.Href_bry, href_enc, gplx.xowa.html.Xoh_consts.Atr_xowa_title_bry, 0);
return String_.new_utf8_(xowa_title);
} static final Xoh_find dom_find = new Xoh_find();
}

View File

@@ -29,7 +29,7 @@ class Xoh_file_main_alts implements Bry_fmtr_arg {
Int_2_ref size = size_alts[i];
if (xfer_itm.Html_w() < size.Val_0()) continue;
xfer_itm.Init_by_lnki(orig_itm.Lnki_ttl(), orig_itm.Lnki_redirect(), Xop_lnki_type.Id_none, size.Val_0(), size.Val_1(), Xop_lnki_tkn.Upright_null, Xof_doc_thumb.Null, Xof_doc_page.Null);
xfer_itm.Atrs_calc_for_html();
xfer_itm.Calc_by_meta();
opt.Html_alts().Bld_bfr_many(bfr, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_src(), i == len - 1 ? opt.Html_alt_dlm_last() : opt.Html_alt_dlm_default());
}
}

View File

@@ -105,8 +105,8 @@ class Xoh_fil_main_fxt {
public void tst(String expd) {
byte[] ttl_bry = Bry_.new_utf8_(ttl_str);
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry);
file.Atrs_by_html_for_tests(html_w, html_h, Bry_.new_utf8_(html_src), Bry_.new_utf8_(html_orig_src));
file.Atrs_by_ttl(ttl_bry, Bry_.Empty);
file.Init_for_test__img(html_w, html_h, Bry_.new_utf8_(html_src), Bry_.new_utf8_(html_orig_src));
file.Set__ttl(ttl_bry, Bry_.Empty);
wkr.Bld_html(wiki, bfr, file, ttl, opt, Bry_.XtoStrBytesByInt(html_file_size, 0), play_btn_icon, 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.XtoStrAndClear());
} static final byte[] play_btn_icon = Bry_.new_ascii_("file:///mem/xowa/user/test_user/app/img/file/play.png");

View File

@@ -16,7 +16,7 @@ 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; import gplx.*;
import gplx.xowa.html.*;
import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*;
import gplx.xowa.files.*;
public class Xoh_file_main_wkr implements Bry_fmtr_arg {
private Xof_xfer_itm xfer_itm; private Xoh_file_main_alts alts = new Xoh_file_main_alts(); private Xoh_file_page opt;
@@ -31,20 +31,19 @@ public class Xoh_file_main_wkr implements Bry_fmtr_arg {
Xof_repo_itm trg_repo = null;
trg_repo = meta_itm.Repo_itm(wiki);
if (trg_repo == null) trg_repo = wiki.File_mgr().Repo_mgr().Repos_get_at(0).Trg();
xfer_itm.Atrs_by_meta(meta_itm, trg_repo, Xof_repo_itm.Thumb_default_null);
xfer_itm.Atrs_by_orig(meta_itm.Orig_w(), meta_itm.Orig_h(), Xof_img_size.Size_null);
xfer_itm.Set__meta(meta_itm, trg_repo, Xof_repo_itm.Thumb_default_null);
xfer_itm.Set__orig(meta_itm.Orig_w(), meta_itm.Orig_h(), Xof_img_size.Size_null);
xfer_itm.Trg_repo_idx_(meta_itm.Vrtl_repo());
play_btn_icon = wiki.Html_mgr().Img_media_play_btn();
file_size_bry = Bry_.Empty;
if (xfer_itm.Atrs_calc_for_html(true)) {
if (xfer_itm.Calc_by_meta(true)) {
long file_size = Io_mgr._.QueryFil(xfer_itm.Trg_file(Xof_repo_itm.Mode_orig, Xof_img_size.Size_null_deprecated)).Size();
file_size_bry = Bry_.new_ascii_(gplx.ios.Io_size_.Xto_str(file_size));
}
else { // NOTE: commons.wikimedia.org/wiki/File:Solar_Life_Cycle.svg would not load on subsequent views; note that "xfer_itm.Atrs_calc_for_html(true)" resizes image b/c it is .svg; DATE:2013-03-01
xfer_itm = Xoh_lnki_file_wtr.Queue_add_manual(queue, xfer_itm);
else { // NOTE: PAGE:c:File:Solar_Life_Cycle.svg would not load on subsequent views; note that "xfer_itm.Atrs_calc_for_html(true)" resizes image b/c it is .svg; DATE:2013-03-01
xfer_itm = xfer_itm.Clone();
queue.Add(xfer_itm);
}
opt.Html_main().Bld_bfr_many(bfr, this);
} private byte[] play_btn_icon; private Bool_obj_ref queue_add_ref = Bool_obj_ref.n_();
@@ -59,8 +58,9 @@ public class Xoh_file_main_wkr implements Bry_fmtr_arg {
if (ext.Id_is_thumbable_img())
opt.Html_main_img().Bld_bfr_many(bfr, xfer_itm.Orig_w(), xfer_itm.Orig_h(), xfer_itm.Html_orig_src(), file_size_bry, ext.Mime_type(), elem_id_val, xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Html_view_src(), ttl.Full_txt(), wiki.App().Encoder_mgr().Url().Encode(ttl.Page_url()), alts);
else if (ext.Id_is_video()) // NOTE: video must precede audio else File:***.ogg will not show thumbs
opt.Html_main_vid().Bld_bfr_many(bfr, elem_id_val, xfer_itm.Html_view_src(), Xoh_lnki_file_wtr.Bry_class_internal, ttl.Page_db(), xfer_itm.Html_view_src(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_src(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
opt.Html_main_vid().Bld_bfr_many(bfr, elem_id_val, xfer_itm.Html_view_src(), Atr_class_image, ttl.Page_db(), xfer_itm.Html_view_src(), xfer_itm.Html_w(), xfer_itm.Html_h(), Bry_.Empty, xfer_itm.Html_orig_src(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
else if (ext.Id_is_audio())
opt.Html_main_aud().Bld_bfr_many(bfr, xfer_itm.Html_orig_src(), ttl.Page_db(), xfer_itm.Html_w(), xfer_itm.Html_w(), play_btn_icon);
}
private static final byte[] Atr_class_image = Bry_.new_ascii_("image");
}