mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.3.1
This commit is contained in:
@@ -122,7 +122,7 @@ public class Xof_ext_ {
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean Id_supports_thumbtime(int v) { // identifies if tid supports thumbtime in lnki; EX: [[File:A.ogv|thumbtime=1]];
|
||||
public static boolean Id_supports_time(int v) { // identifies if tid supports thumbtime in lnki; EX: [[File:A.ogv|thumbtime=1]];
|
||||
switch (v) {
|
||||
case Id_ogg: case Id_ogv: case Id_webm: return true;
|
||||
default: return false;
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.consoles.*;
|
||||
public class Xof_file_wkr_ {
|
||||
public static final Url_encoder Md5_decoder = Url_encoder.new_http_url_().Itms_raw_same_many(Byte_ascii.Plus);
|
||||
public static byte[] Md5_fast(byte[] v) {return Bry_.new_a7(gplx.security.HashAlgo_.Md5.CalcHash(Console_adp_.Noop, gplx.ios.IoStream_.ary_(v)));}
|
||||
public static byte[] Md5_(byte[] ttl) {
|
||||
public static byte[] Md5(byte[] ttl) {
|
||||
ttl = Md5_decoder.Decode_lax(Ttl_standardize(ttl));
|
||||
return Xof_file_wkr_.Md5_fast(ttl); // NOTE: md5 is calculated off of url_decoded ttl; EX: A%2Cb is converted to A,b and then md5'd. note that A%2Cb still remains the title
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Xof_fsdb_itm implements Xof_file_itm {
|
||||
this.orig_ext = orig_ext; // NOTE: always use orig_ext since this comes directly from wmf_api; DATE:2015-05-17
|
||||
}
|
||||
public void Init_at_lnki_by_near(int file_w) {
|
||||
this.lnki_w = file_w; this.lnki_h = Xof_img_size.Size_null_deprecated;
|
||||
this.lnki_w = file_w; this.lnki_h = Xof_img_size.Size__neg1;
|
||||
}
|
||||
public void Init_at_html(int exec_tid, Xof_img_size img_size, Xof_repo_itm repo, Xof_url_bldr url_bldr) {
|
||||
Calc_html_size(exec_tid, img_size);
|
||||
@@ -116,6 +116,9 @@ public class Xof_fsdb_itm implements Xof_file_itm {
|
||||
public void Init_at_xfer(int idx, int len) {
|
||||
this.xfer_idx = idx; this.xfer_len = len;
|
||||
}
|
||||
public void Change_repo(byte orig_repo_id, byte[] orig_repo_name) {
|
||||
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
|
||||
}
|
||||
public void File_is_orig_(boolean v) {this.file_is_orig = v;}
|
||||
public void Orig_repo_name_(byte[] v) {orig_repo_name = v;}
|
||||
public void Html_elem_tid_(byte v) {this.html_elem_tid = v;}
|
||||
|
||||
80
400_xowa/src/gplx/xowa/files/Xof_fsdb_itm_fxt.java
Normal file
80
400_xowa/src/gplx/xowa/files/Xof_fsdb_itm_fxt.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
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.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.files.repos.*;
|
||||
public class Xof_fsdb_itm_fxt {
|
||||
private byte[] wiki_abrv;
|
||||
private byte[] lnki_ttl;
|
||||
private byte lnki_type;
|
||||
private double lnki_upright;
|
||||
private int lnki_w;
|
||||
private int lnki_h;
|
||||
private double lnki_time;
|
||||
private int lnki_page;
|
||||
private byte orig_repo_id;
|
||||
private byte[] orig_repo_name;
|
||||
private byte[] orig_ttl;
|
||||
private Xof_ext orig_ext;
|
||||
private int orig_w;
|
||||
private int orig_h;
|
||||
private byte[] orig_redirect;
|
||||
public Xof_fsdb_itm_fxt() {this.Clear();}
|
||||
public void Clear() {
|
||||
this.wiki_abrv = lnki_ttl = null;
|
||||
this.lnki_type = Xop_lnki_type.Id_null;
|
||||
this.lnki_upright = Xof_img_size.Upright_null;
|
||||
this.lnki_w = this.lnki_h = this.orig_w = this.orig_h = Xof_img_size.Size__neg1;
|
||||
this.lnki_h = Xof_img_size.Size__neg1;
|
||||
this.lnki_time = Xof_lnki_time.Null;
|
||||
this.lnki_page = Xof_lnki_page.Null;
|
||||
this.orig_repo_id = Xof_repo_itm_.Repo_null;
|
||||
this.orig_repo_name = orig_ttl = orig_redirect = null;
|
||||
this.orig_ext = null;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Lnki__en_w(String lnki_ttl_str) {
|
||||
this.wiki_abrv = Abrv__en_w;
|
||||
this.lnki_ttl = Bry_.new_u8(lnki_ttl_str);
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Orig__commons__lnki() {
|
||||
this.orig_repo_name = Xow_domain_.Domain_bry_commons;
|
||||
this.orig_repo_id = Xof_repo_itm_.Repo_remote;
|
||||
this.orig_ttl = lnki_ttl;
|
||||
this.orig_ext = Xof_ext_.new_by_ttl_(orig_ttl);
|
||||
this.orig_w = 880;
|
||||
this.orig_w = 440;
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm_fxt Orig__enwiki__lnki() {
|
||||
this.orig_repo_name = Xow_domain_.Domain_bry_enwiki;
|
||||
this.orig_repo_id = Xof_repo_itm_.Repo_local;
|
||||
this.orig_ttl = lnki_ttl;
|
||||
this.orig_ext = Xof_ext_.new_by_ttl_(orig_ttl);
|
||||
this.orig_w = 880;
|
||||
this.orig_w = 440;
|
||||
return this;
|
||||
}
|
||||
public Xof_fsdb_itm Make() {
|
||||
Xof_fsdb_itm rv = new Xof_fsdb_itm();
|
||||
rv.Init_at_lnki(Xof_exec_tid.Tid_wiki_page, wiki_abrv, lnki_ttl, lnki_type, lnki_upright, lnki_w, lnki_h, lnki_time, lnki_page, Xof_patch_upright_tid_.Tid_all);
|
||||
rv.Init_at_orig(orig_repo_id, orig_repo_name, orig_ttl, orig_ext, orig_w, orig_h, orig_redirect);
|
||||
return rv;
|
||||
}
|
||||
private final static byte[] Abrv__en_w = Bry_.new_a7("en.w");
|
||||
}
|
||||
@@ -27,59 +27,63 @@ public class Xof_img_size {
|
||||
file_is_orig = false;
|
||||
}
|
||||
public void Html_size_calc(int exec_tid, int lnki_w, int lnki_h, byte lnki_type, int upright_patch, double lnki_upright, int orig_ext, int orig_w, int orig_h, int thm_dflt_w) {
|
||||
this.Clear(); // always clear before calc; caller should be responsible, but just to be safe.
|
||||
if (Enm_.HasInt(lnki_type, Xop_lnki_type.Id_frame) // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
|
||||
&& lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22
|
||||
html_w = file_w = orig_w;
|
||||
html_h = file_h = orig_h;
|
||||
file_is_orig = Xof_ext_.Orig_file_is_img(orig_ext); // file_is_orig = true, unless svg, ogv, pdf
|
||||
if (file_is_orig)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
return;
|
||||
}
|
||||
html_w = lnki_w; html_h = lnki_h; // set html vals to lnki vals
|
||||
file_is_orig = false;
|
||||
if (html_w == Null && html_h == Null) { // no size set; NOTE: do not default to thumb if only height is set; EX: x900px should have w=0 h=900
|
||||
if (Xop_lnki_type.Id_defaults_to_thumb(lnki_type))
|
||||
html_w = thm_dflt_w;
|
||||
else if ( orig_ext == Xof_ext_.Id_pdf // pdf and viewing on page; default to 220
|
||||
&& exec_tid == Xof_exec_tid.Tid_wiki_page)
|
||||
html_w = thm_dflt_w;
|
||||
else
|
||||
html_w = orig_w;
|
||||
}
|
||||
html_w = Upright_calc(upright_patch, lnki_upright, html_w, lnki_w, lnki_h, lnki_type);
|
||||
if (orig_w == Null) return; // no orig_w; just use html_w and html_h (html_h will likely be -1 and wrong)
|
||||
|
||||
boolean ext_is_svg = orig_ext == Xof_ext_.Id_svg;
|
||||
if (html_w == Xof_img_size.Null) {
|
||||
if ( ext_is_svg // following strange MW logic; REF.MW:Linker.php|makeImageLink|If its a vector image, and user only specifies height, we don't want it to be limited by its "normal" width; DATE: 2013-11-26
|
||||
&& html_h != Xof_img_size.Null)
|
||||
html_w = Svg_max_width;
|
||||
else
|
||||
html_w = orig_w; // html_w missing >>> use orig_w; REF.MW:Linker.php|makeImageLink2|$hp['width'] = $file->getWidth( $page );
|
||||
}
|
||||
if (html_h != Xof_img_size.Null) { // html_h exists; REF.MW:ImageHandler.php|normaliseParams|if ( isset( $params['height'] ) && $params['height'] != -1 ) {
|
||||
if ( (long)html_w * (long)orig_h
|
||||
> (long)html_h * (long)orig_w) // html ratio > orig ratio; recalc html_w; SEE:NOTE_2; NOTE: casting to long to prevent int overflow; [[File:A.png|9999999999x90px]]; DATE:2014-04-26
|
||||
html_w = Calc_w(orig_w, orig_h, html_h);
|
||||
}
|
||||
html_h = Scale_h(orig_w, orig_h, html_w); // calc html_h
|
||||
if ( html_w >= orig_w // html >= orig
|
||||
&& ( Xof_ext_.Orig_file_is_img(orig_ext) // orig is img (ignore for svg, ogv, pdf, etc)
|
||||
|| ext_is_svg && exec_tid == Xof_exec_tid.Tid_wiki_file // limit to size if svg and [[File]] page
|
||||
)
|
||||
) {
|
||||
file_is_orig = true; // use orig img (don't create thumb)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
if (Xop_lnki_type.Id_limits_large_size(lnki_type)) {// do not allow html_w > orig_w; REF.MW:Generic.php|normaliseParams
|
||||
html_w = orig_w;
|
||||
html_h = orig_h;
|
||||
synchronized (this) {
|
||||
this.Clear(); // always clear before calc; caller should be responsible, but just to be safe.
|
||||
if (Xof_ext_.Id_supports_time(orig_ext) && lnki_w == Xof_img_size.Null) // use orig_w if no size specified for video; EX:[[File:A.ogv]] -> [[File:A.ogv|550px]] where 550px is orig_w; DATE:2015-08-07
|
||||
lnki_w = orig_w;
|
||||
if (Enm_.HasInt(lnki_type, Xop_lnki_type.Id_frame) // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
|
||||
&& lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22
|
||||
html_w = file_w = orig_w;
|
||||
html_h = file_h = orig_h;
|
||||
file_is_orig = Xof_ext_.Orig_file_is_img(orig_ext); // file_is_orig = true, unless svg, ogv, pdf
|
||||
if (file_is_orig)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
return;
|
||||
}
|
||||
html_w = lnki_w; html_h = lnki_h; // set html vals to lnki vals
|
||||
file_is_orig = false;
|
||||
if (html_w == Null && html_h == Null) { // no size set; NOTE: do not default to thumb if only height is set; EX: x900px should have w=0 h=900
|
||||
if (Xop_lnki_type.Id_defaults_to_thumb(lnki_type))
|
||||
html_w = thm_dflt_w;
|
||||
else if ( orig_ext == Xof_ext_.Id_pdf // pdf and viewing on page; default to 220
|
||||
&& exec_tid == Xof_exec_tid.Tid_wiki_page)
|
||||
html_w = thm_dflt_w;
|
||||
else
|
||||
html_w = orig_w;
|
||||
}
|
||||
html_w = Upright_calc(upright_patch, lnki_upright, html_w, lnki_w, lnki_h, lnki_type);
|
||||
if (orig_w == Null) return; // no orig_w; just use html_w and html_h (html_h will likely be -1 and wrong)
|
||||
|
||||
boolean ext_is_svg = orig_ext == Xof_ext_.Id_svg;
|
||||
if (html_w == Xof_img_size.Null) {
|
||||
if ( ext_is_svg // following strange MW logic; REF.MW:Linker.php|makeImageLink|If its a vector image, and user only specifies height, we don't want it to be limited by its "normal" width; DATE: 2013-11-26
|
||||
&& html_h != Xof_img_size.Null)
|
||||
html_w = Svg_max_width;
|
||||
else
|
||||
html_w = orig_w; // html_w missing >>> use orig_w; REF.MW:Linker.php|makeImageLink2|$hp['width'] = $file->getWidth( $page );
|
||||
}
|
||||
if (html_h != Xof_img_size.Null) { // html_h exists; REF.MW:ImageHandler.php|normaliseParams|if ( isset( $params['height'] ) && $params['height'] != -1 ) {
|
||||
if ( (long)html_w * (long)orig_h
|
||||
> (long)html_h * (long)orig_w) // html ratio > orig ratio; recalc html_w; SEE:NOTE_2; NOTE: casting to long to prevent int overflow; [[File:A.png|9999999999x90px]]; DATE:2014-04-26
|
||||
html_w = Calc_w(orig_w, orig_h, html_h);
|
||||
}
|
||||
html_h = Scale_h(orig_w, orig_h, html_w); // calc html_h
|
||||
if ( html_w >= orig_w // html >= orig
|
||||
&& ( Xof_ext_.Orig_file_is_img(orig_ext) // orig is img (ignore for svg, ogv, pdf, etc)
|
||||
|| ext_is_svg && exec_tid == Xof_exec_tid.Tid_wiki_file // limit to size if svg and [[File]] page
|
||||
)
|
||||
) {
|
||||
file_is_orig = true; // use orig img (don't create thumb)
|
||||
file_w = file_h = Size__same_as_orig;
|
||||
if (Xop_lnki_type.Id_limits_large_size(lnki_type)) {// do not allow html_w > orig_w; REF.MW:Generic.php|normaliseParams
|
||||
html_w = orig_w;
|
||||
html_h = orig_h;
|
||||
}
|
||||
}
|
||||
else { // html < orig
|
||||
file_w = html_w;
|
||||
file_h = html_h;
|
||||
}
|
||||
}
|
||||
else { // html < orig
|
||||
file_w = html_w;
|
||||
file_h = html_h;
|
||||
}
|
||||
}
|
||||
// private static boolean Calc_limit_size(int exec_tid, int lnki_type, int lnki_ext) {
|
||||
@@ -135,7 +139,7 @@ public class Xof_img_size {
|
||||
public static final int Null = -1;
|
||||
public static final int Thumb_width_img = 220, Thumb_width_ogv = 220;
|
||||
public static final double Upright_null = -1, Upright_default_marker = 0; // REF:MW: if ( isset( $fp['upright'] ) && $fp['upright'] == 0 )
|
||||
public static final int Size_null_deprecated = -1, Size_null = 0; // Size_null = 0, b/c either imageMagick / inkscape fails when -1 is passed
|
||||
public static final int Size__neg1 = -1, Size_null = 0; // Size_null = 0, b/c either imageMagick / inkscape fails when -1 is passed
|
||||
public static final int Size__same_as_orig = -1;
|
||||
private static final int Svg_max_width = 2048;
|
||||
}
|
||||
|
||||
@@ -17,11 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xof_img_size_tst {
|
||||
public class Xof_img_size_tst {
|
||||
private final Xof_img_size_fxt fxt = new Xof_img_size_fxt();
|
||||
@Before public void init() {
|
||||
fxt.Reset();
|
||||
fxt.Orig_(400, 200);
|
||||
} private Xof_img_size_fxt fxt = new Xof_img_size_fxt();
|
||||
}
|
||||
@Test public void Lnki_lt_orig_null() {fxt.Lnki_type_(Xop_lnki_type.Id_null) .Lnki_(200, 100).Test_html(200, 100, Bool_.N);} // [[File:A.png|200px]] -> 200,100; File_is_orig = n
|
||||
@Test public void Lnki_lt_orig_thumb() {fxt.Lnki_type_(Xop_lnki_type.Id_thumb) .Lnki_(200, 100).Test_html(200, 100, Bool_.N);} // [[File:A.png|thumb|200px]] -> 200,100; File_is_orig = n
|
||||
@Test public void Lnki_lt_orig_frameless() {fxt.Lnki_type_(Xop_lnki_type.Id_frameless) .Lnki_(200, 100).Test_html(200, 100, Bool_.N);} // [[File:A.png|frameless|200px]] -> 200,100; File_is_orig = n
|
||||
@@ -77,6 +78,9 @@ public class Xof_img_size_tst {
|
||||
@Test public void Frame_and_thumb(){ // PURPOSE: frame and thumb should be treated as frame; Enm.Has(val, Id_frame) vs val == Id_frame; PAGE:en.w:History_of_Western_Civilization; DATE:2015-04-16
|
||||
fxt.Lnki_type_(Enm_.Add_byte(Xop_lnki_type.Id_frame, Xop_lnki_type.Id_thumb)).Lnki_(200, -1).Test_html(400, 200, Bool_.Y); // mut return same as Lnki_lt_orig_frame above
|
||||
}
|
||||
@Test public void Video__use_orig_w(){ // PURPOSE: video should use orig_w; DATE:2015-08-07
|
||||
fxt.Lnki_type_(Xop_lnki_type.Id_none).Lnki_ext_(Xof_ext_.Id_ogv).Lnki_(-1, -1).Orig_(500, 250).Test_html(500, 250, Bool_.N);
|
||||
}
|
||||
}
|
||||
class Xof_img_size_fxt {
|
||||
private Xof_img_size img_size = new Xof_img_size();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xof_lnki_time {
|
||||
public static boolean Null_n(double v) {return v != Null;}
|
||||
public static final int Null_as_int = -1;
|
||||
|
||||
public static double Convert_to_xowa_thumbtime (int ext, double val) {return Xof_ext_.Id_supports_thumbtime(ext) ? val : Null;}
|
||||
public static double Convert_to_xowa_thumbtime (int ext, double val) {return Xof_ext_.Id_supports_time(ext) ? val : Null;}
|
||||
public static int Convert_to_xowa_page (int ext, double val) {return Xof_ext_.Id_supports_page(ext) ? (int)val : Xof_lnki_page.Null;}
|
||||
public static double Convert_to_fsdb_thumbtime (int ext, double thumbtime, int page) {
|
||||
return page != Xof_lnki_page.Null
|
||||
|
||||
@@ -50,10 +50,11 @@ public class Xof_url_bldr {
|
||||
return Init(Bool_.N, Bool_.N, Byte_ascii.Slash, repo.Root_http()
|
||||
, repo.Mode_names()[mode], repo.Dir_depth(), repo.Gen_name_trg(ttl, md5, ext), md5, ext, mode, file_w, time, page);
|
||||
}
|
||||
public Xof_url_bldr Init(boolean wmf_dir_hive, boolean wmf_protocol_is_file, byte dir_spr
|
||||
private Xof_url_bldr Init(boolean wmf_dir_hive, boolean wmf_protocol_is_file, byte dir_spr
|
||||
, byte[] root, byte[] area, int md5_dir_depth
|
||||
, byte[] ttl, byte[] md5, Xof_ext ext
|
||||
, byte file_mode, int file_w, double time, int page) {
|
||||
, byte file_mode, int file_w, double time, int page
|
||||
) {
|
||||
this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.dir_spr = dir_spr;
|
||||
this.root = root; this.area = area; this.md5_dir_depth = md5_dir_depth;
|
||||
this.ttl = ttl; this.md5 = md5; this.ext = ext;
|
||||
@@ -126,10 +127,12 @@ public class Xof_url_bldr {
|
||||
case Xof_ext_.Id_ogg:
|
||||
case Xof_ext_.Id_ogv:
|
||||
case Xof_ext_.Id_webm:
|
||||
bfr.Add_int_variable(file_w); // add file_w; EX: "220"; PAGE:en.w:Alice_Brady; DATE:2015-08-06
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
if (Xof_lnki_time.Null_n(time))
|
||||
bfr.Add(Bry_seek).Add_str(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
bfr.Add(Bry_seek).Add_str(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
else
|
||||
bfr.Add(Bry_mid); // add mid; EX: "mid-"
|
||||
bfr.Add_byte(Byte_ascii.Dash); // add mid; EX: "-"; NOTE: was "mid-"; DATE:2015-08-06
|
||||
break;
|
||||
case Xof_ext_.Id_tif:
|
||||
case Xof_ext_.Id_tiff:
|
||||
@@ -148,7 +151,13 @@ public class Xof_url_bldr {
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
break;
|
||||
}
|
||||
bfr.Add(encoder_src_http.Encode(ttl)); // add ttl again; EX: "A.png"
|
||||
int ttl_len = ttl.length;
|
||||
if (ttl_len > 160) { // long file name
|
||||
bfr.Add(Bry_thumnbail_w_dot);
|
||||
bfr.Add(ext.Ext());
|
||||
}
|
||||
else
|
||||
bfr.Add(encoder_src_http.Encode(ttl)); // add ttl again; EX: "A.png"
|
||||
switch (file_ext_id) {
|
||||
case Xof_ext_.Id_svg:
|
||||
case Xof_ext_.Id_bmp:
|
||||
@@ -178,7 +187,8 @@ public class Xof_url_bldr {
|
||||
}
|
||||
private Xof_url_bldr Clear() {
|
||||
root = area = ttl = md5 = null;
|
||||
file_w = 0; time = Xof_lnki_time.Null;
|
||||
file_w = Xof_img_size.Null;
|
||||
time = Xof_lnki_time.Null;
|
||||
ext = null;
|
||||
bfr.Clear();
|
||||
return this;
|
||||
@@ -186,7 +196,8 @@ public class Xof_url_bldr {
|
||||
public static final byte[]
|
||||
Bry_reg = Bry_.new_a7("reg.csv")
|
||||
, Bry_px = Bry_.new_a7("px"), Bry_px_dash = Bry_.new_a7("px-")
|
||||
, Bry_thumb = Bry_.new_a7("thumb"), Bry_mid = Bry_.new_a7("mid-")
|
||||
, Bry_thumb = Bry_.new_a7("thumb")
|
||||
, Bry_thumnbail_w_dot = Bry_.new_a7("thumbnail.")
|
||||
;
|
||||
private static final byte[]
|
||||
Bry_lossy_page = Bry_.new_a7("lossy-page"), Bry_page = Bry_.new_a7("page")
|
||||
|
||||
@@ -19,34 +19,44 @@ package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
|
||||
public class Xof_url_bldr_tst {
|
||||
private Xof_url_bldr_fxt fxt = new Xof_url_bldr_fxt();
|
||||
@Before public void init() {fxt.ini();}
|
||||
@Test public void Ogv() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/thumb/d/d0/A.ogv/mid-A.ogv.jpg").tst();}
|
||||
@Test public void Ogv_seek() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/thumb/d/d0/A.ogv/seek%3D5-A.ogv.jpg").Seek_(5).tst();}
|
||||
@Test public void Xcf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("44").Ttl_("A.xcf").Expd_src_("http://test/thumb/4/44/A.xcf/0px-A.xcf.png").tst();}
|
||||
@Test public void Bmp() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("70").Ttl_("A.bmp").Expd_src_("http://test/thumb/7/70/A.bmp/0px-A.bmp.png").tst();}
|
||||
@Test public void Pdf_none() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Expd_src_("http://test/thumb/e/ef/A.pdf/page1-0px-A.pdf.jpg").tst();}
|
||||
@Test public void Pdf_page_2() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Page_(2).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-0px-A.pdf.jpg").tst();}
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Ogv() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").W_(220).Expd_src_("http://test/thumb/d/d0/A.ogv/220px--A.ogv.jpg").Test();}
|
||||
@Test public void Ogv__seek() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").W_(220).Expd_src_("http://test/thumb/d/d0/A.ogv/220px-seek%3D5-A.ogv.jpg").Seek_(5).Test();}
|
||||
@Test public void Ogv__no_w() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").W_( -1).Expd_src_("http://test/thumb/d/d0/A.ogv/-1px--A.ogv.jpg").Test();} // TODO: use orig_w, not -1
|
||||
@Test public void Xcf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("44").Ttl_("A.xcf").W_(220).Expd_src_("http://test/thumb/4/44/A.xcf/220px-A.xcf.png").Test();}
|
||||
@Test public void Bmp() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("70").Ttl_("A.bmp").W_(220).Expd_src_("http://test/thumb/7/70/A.bmp/220px-A.bmp.png").Test();}
|
||||
@Test public void Pdf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page1-220px-A.pdf.jpg").Test();}
|
||||
@Test public void Pdf__page_2() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").W_(220).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-220px-A.pdf.jpg").Page_(2).Test();}
|
||||
@Test public void Long() {
|
||||
String filename = String_.Repeat("A", 200) + ".png";
|
||||
fxt.Dir_spr_http_().Root_("http://test/").Md5_("14").Ttl_(filename).W_(220)
|
||||
.Expd_src_("http://test/thumb/1/14/" + filename + "/220px-thumbnail.png")
|
||||
.Test()
|
||||
;
|
||||
}
|
||||
}
|
||||
class Xof_url_bldr_fxt {
|
||||
private final Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
public Xof_url_bldr_fxt ini() {this.Clear(); return this;}
|
||||
public Xof_url_bldr_fxt Clear() {
|
||||
dir_spr = Byte_.Zero; ext = null; root = md5 = ttl = expd_src = null;
|
||||
seek = Xof_lnki_time.Null;
|
||||
page = Xof_lnki_page.Null;
|
||||
w = Xof_img_size.Null;
|
||||
return this;
|
||||
}
|
||||
public Xof_url_bldr_fxt Dir_spr_http_() {return Dir_spr_(Byte_ascii.Slash);}
|
||||
public Xof_url_bldr_fxt Dir_spr_fsys_wnt_() {return Dir_spr_(Byte_ascii.Backslash);}
|
||||
public Xof_url_bldr_fxt Dir_spr_(byte v) {dir_spr = v; return this;} private byte dir_spr;
|
||||
public Xof_url_bldr_fxt Root_(String v) {root = v; return this;} private String root;
|
||||
public Xof_url_bldr_fxt Md5_(String v) {md5 = v; return this;} private String md5;
|
||||
public Xof_url_bldr_fxt Ttl_(String v) {ttl = v; ext = Xof_ext_.new_by_ttl_(Bry_.new_u8(v)); return this;} private String ttl; Xof_ext ext;
|
||||
public Xof_url_bldr_fxt W_(int v) {this.w = v; return this;} private int w;
|
||||
public Xof_url_bldr_fxt Page_(int v) {page = v; return this;} private int page = Xof_lnki_page.Null;
|
||||
public Xof_url_bldr_fxt Seek_(int v) {seek = v; return this;} private double seek = Xof_lnki_time.Null;
|
||||
public Xof_url_bldr_fxt Expd_src_(String v) {expd_src = v; return this;} private String expd_src;
|
||||
private void Clear() {
|
||||
dir_spr = Byte_.Zero; ext = null; root = md5 = ttl = expd_src = null;
|
||||
seek = Xof_lnki_time.Null;
|
||||
page = Xof_lnki_page.Null;
|
||||
}
|
||||
public Xof_url_bldr_fxt tst() {
|
||||
public Xof_url_bldr_fxt Test() {
|
||||
url_bldr.Init_by_root(Bry_.new_u8(root), dir_spr, Bool_.Y, Bool_.N, 2);
|
||||
url_bldr.Init_by_itm (Xof_repo_itm_.Mode_thumb, Bry_.new_u8(ttl), Bry_.new_u8(md5), ext, 0, seek, page);
|
||||
url_bldr.Init_by_itm (Xof_repo_itm_.Mode_thumb, Bry_.new_u8(ttl), Bry_.new_u8(md5), ext, w, seek, page);
|
||||
Tfds.Eq(expd_src, url_bldr.Xto_str());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
}
|
||||
public void Init_at_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, Xof_ext orig_ext, int orig_w, int orig_h, byte[] orig_redirect) {
|
||||
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
|
||||
this.orig_ttl = orig_ttl; this.orig_ttl_md5 = Xof_file_wkr_.Md5_(orig_ttl);
|
||||
this.orig_ttl = orig_ttl; this.orig_ttl_md5 = Xof_file_wkr_.Md5(orig_ttl);
|
||||
this.orig_w = orig_w; this.orig_h = orig_h; this.orig_redirect = orig_redirect;
|
||||
if (Bry_.Len_gt_0(orig_redirect)) // redirect exists; EX: A.png redirected to B.png
|
||||
this.Orig_ttl_(orig_redirect); // update fsdb with atrs of B.png
|
||||
@@ -185,14 +185,14 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
if (meta_itm == null || trg_repo_itm == null) return false;
|
||||
if (meta_itm.Ptr_ttl_exists()) {
|
||||
lnki_ttl = meta_itm.Ptr_ttl();
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5_(lnki_ttl);
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5(lnki_ttl);
|
||||
}
|
||||
boolean limit_size = !orig_ext.Id_is_svg() || (orig_ext.Id_is_svg() && caller_is_file_page);
|
||||
if (orig_ext.Id_is_media() && html_w < 1) // if media and no width, set to default; NOTE: must be set or else dynamic download will resize play button to small size; DATE:20121227
|
||||
html_w = Xof_img_size.Thumb_width_ogv;
|
||||
if (!file_is_orig) { // file is thumb
|
||||
if (orig_ext.Id_is_video()) { // video is a special case; src is thumb_w but html_w / html_h is based on calc
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
if (meta_itm.Thumbs_indicates_oga() && orig_ext.Id_is_ogv()) {orig_ext = Xof_ext_.new_by_ext_(Xof_ext_.Bry_oga); return true;} // if audio, do not thumb; NOTE: must happen after html_orig_bry, b/c html must still be generated to auto-download files; NOTE: must change ext to oga b/c ogg may trigger video code elsewhere
|
||||
Xof_meta_thumb thumb = meta_itm.Thumbs_get_vid(Xof_lnki_time.X_int(lnki_time));
|
||||
if (thumb != null) {
|
||||
@@ -204,7 +204,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
}
|
||||
}
|
||||
else { // regular thumb
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
html_orig_url = Trg_view_url(Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
if (orig_ext.Id_is_audio()) return true; // if audio, do not thumb; even if user requests thumb;
|
||||
Xof_meta_thumb[] thumbs = meta_itm.Thumbs(); int thumbs_len = thumbs.length; Xof_meta_thumb thumb = null;
|
||||
if (lnki_h > 0 && orig_w < 1 && thumbs_len > 0) { // if height is specified and no orig, then iterate over thumbs to find similar height; NOTE: this is a fallback case; orig_w/h is optimal; EX: c:Jacques-Louis David and <gallery>
|
||||
|
||||
@@ -117,10 +117,10 @@ public class Xow_file_mgr implements GfoInvkAble {
|
||||
public void Init_file_mgr_by_load(Xow_wiki wiki) {
|
||||
if (db_core != null) return; // already init'd
|
||||
this.db_core = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
|
||||
// if (db_core == null) return; // no fsdb_core found; exit
|
||||
if (db_core == null) {
|
||||
db_core = Fsdb_db_mgr__v2_bldr.I.Get_or_make(wiki, false);
|
||||
}
|
||||
if ( db_core == null // "-file-core.xowa" not found
|
||||
&& !wiki.Data__core_mgr().Props().Layout_file().Tid_is_all() // DATE:2015-08-10
|
||||
)
|
||||
db_core = Fsdb_db_mgr__v2_bldr.I.Get_or_make(wiki, false); // make it
|
||||
this.version = Version_2;
|
||||
this.fsdb_mode = Xof_fsdb_mode.new_v2_gui();
|
||||
orig_mgr.Init_by_wiki(wiki, fsdb_mode, db_core.File__orig_tbl_ary(), Xof_url_bldr.new_v2());
|
||||
|
||||
22
400_xowa/src/gplx/xowa/files/bins/Io_download_mgr.java
Normal file
22
400_xowa/src/gplx/xowa/files/bins/Io_download_mgr.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*;
|
||||
public interface Io_download_mgr {
|
||||
Io_stream_rdr Download_as_rdr(String src);
|
||||
}
|
||||
31
400_xowa/src/gplx/xowa/files/bins/Io_download_mgr_.java
Normal file
31
400_xowa/src/gplx/xowa/files/bins/Io_download_mgr_.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*;
|
||||
public class Io_download_mgr_ {
|
||||
public static Io_download_mgr new_system() {return new Io_download_mgr__system();}
|
||||
public static Io_download_mgr__memory new_memory() {return new Io_download_mgr__memory();}
|
||||
}
|
||||
class Io_download_mgr__system implements Io_download_mgr {
|
||||
private final IoEngine_xrg_downloadFil download_wkr = IoEngine_xrg_downloadFil.new_("", Io_url_.Empty);
|
||||
public void Upload_data(String url, byte[] data) {throw Err_.new_unimplemented();}
|
||||
public Io_stream_rdr Download_as_rdr(String url) {
|
||||
download_wkr.Init(url, Io_url_.Empty);
|
||||
return download_wkr.Exec_as_rdr();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*;
|
||||
public class Io_download_mgr__memory implements Io_download_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.new_();
|
||||
public void Clear() {hash.Clear();}
|
||||
public void Upload_data(String url, byte[] data) {hash.Add(url, data);}
|
||||
public Io_stream_rdr Download_as_rdr(String url) {
|
||||
byte[] data = (byte[])hash.Get_by(url); if (data == null) return Io_stream_rdr_.Noop;
|
||||
return Io_stream_rdr_.mem_(data);
|
||||
}
|
||||
}
|
||||
@@ -16,21 +16,38 @@ 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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import gplx.ios.*; import gplx.core.threads.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.ios.*; import gplx.core.threads.*;
|
||||
import gplx.xowa.apps.*;
|
||||
import gplx.xowa.files.fsdb.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
private final Xow_repo_mgr repo_mgr; private final IoEngine_xrg_downloadFil download_wkr;
|
||||
private final Io_download_mgr download_mgr;
|
||||
private final Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
public Xof_bin_wkr__http_wmf(Xow_repo_mgr repo_mgr, gplx.ios.IoEngine_xrg_downloadFil download_wkr) {this.repo_mgr = repo_mgr; this.download_wkr = download_wkr;}
|
||||
public Xof_bin_wkr__http_wmf(Xow_repo_mgr repo_mgr, Io_download_mgr download_mgr, IoEngine_xrg_downloadFil download_wkr) {
|
||||
this.repo_mgr = repo_mgr; this.download_mgr = download_mgr; this.download_wkr = download_wkr;
|
||||
}
|
||||
public byte Tid() {return Xof_bin_wkr_.Tid_http_wmf;}
|
||||
public String Key() {return Xof_bin_wkr_.Key_http_wmf;}
|
||||
public boolean Resize_allowed() {return bin_wkr_resize;} public void Resize_allowed_(boolean v) {bin_wkr_resize = v;} private boolean bin_wkr_resize = true;
|
||||
public int Fail_timeout() {return fail_timeout;} public Xof_bin_wkr__http_wmf Fail_timeout_(int v) {fail_timeout = v; return this;} private int fail_timeout = 0; // NOTE: always default to 0; manually set to 1000 for fsdb_make only; DATE:2014-06-21
|
||||
public Io_stream_rdr Get_as_rdr(Xof_fsdb_itm fsdb, boolean is_thumb, int w) {
|
||||
Download_init(fsdb.Orig_repo_name(), fsdb.Orig_ttl(), fsdb.Orig_ttl_md5(), fsdb.Orig_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Empty);
|
||||
Io_stream_rdr rdr = download_wkr.Exec_as_rdr();
|
||||
String src = Make_src(fsdb.Orig_repo_name(), fsdb.Orig_ttl(), fsdb.Orig_ttl_md5(), fsdb.Orig_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Empty);
|
||||
Io_stream_rdr rdr = download_mgr.Download_as_rdr(src);
|
||||
boolean rv = rdr.Exists(); // NOTE: use Exists which detects for response_code 200, not content length > 0; DATE:2015-05-20
|
||||
if (!rv) Handle_error();
|
||||
fsdb.Fsdb_insert_y_();
|
||||
if (!rv) {
|
||||
Handle_error();
|
||||
if (!rv && fsdb.Orig_repo_id() == Xof_repo_itm_.Repo_local) { // image is not found in local; check commons; occurs with bldr which relies on inaccurate data in image dumps; PAGE:en.w:Apollo_13; DATE:2015-08-05
|
||||
src = Make_src(Xow_domain_.Domain_bry_commons, fsdb.Orig_ttl(), fsdb.Orig_ttl_md5(), fsdb.Orig_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Empty);
|
||||
rdr = download_mgr.Download_as_rdr(src);
|
||||
rv = rdr.Exists();
|
||||
if (rv)
|
||||
fsdb.Change_repo(Xof_repo_itm_.Repo_remote, Xow_domain_.Domain_bry_commons); // set commons.wikimedia.org; DATE:2015-08-05
|
||||
else
|
||||
Handle_error();
|
||||
}
|
||||
}
|
||||
if (rv) fsdb.Fsdb_insert_y_();
|
||||
return rv ? rdr : Io_stream_rdr_.Noop;
|
||||
}
|
||||
public boolean Get_to_fsys(Xof_fsdb_itm fsdb, boolean is_thumb, int w, Io_url bin_url) {
|
||||
@@ -39,7 +56,7 @@ public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
return rv;
|
||||
}
|
||||
private boolean Get_to_fsys(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
Download_init(orig_repo, orig_ttl, orig_md5, orig_ext, lnki_is_thumb, file_w, lnki_time, lnki_page, file_url);
|
||||
Init_download(orig_repo, orig_ttl, orig_md5, orig_ext, lnki_is_thumb, file_w, lnki_time, lnki_page, file_url);
|
||||
boolean rv = download_wkr.Exec();
|
||||
if (!rv) Handle_error();
|
||||
return rv;
|
||||
@@ -48,16 +65,22 @@ public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
if (fail_timeout > 0)
|
||||
Thread_adp_.Sleep(fail_timeout); // as per WMF policy, pause 1 second for every cache miss; http://lists.wikimedia.org/pipermail/wikitech-l/2013-September/071948.html
|
||||
}
|
||||
private void Download_init(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
private void Init_download(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
byte mode = lnki_is_thumb ? Xof_repo_itm_.Mode_thumb : Xof_repo_itm_.Mode_orig;
|
||||
Xof_repo_pair repo_itm = repo_mgr.Repos_get_by_wiki(orig_repo);
|
||||
String src = url_bldr.Init_for_src_file(mode, repo_itm.Src(), orig_ttl, orig_md5, orig_ext, file_w, lnki_time, lnki_page).Xto_str();
|
||||
download_wkr.Init(src, file_url);
|
||||
}
|
||||
private String Make_src(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
byte mode = lnki_is_thumb ? Xof_repo_itm_.Mode_thumb : Xof_repo_itm_.Mode_orig;
|
||||
Xof_repo_pair repo_itm = repo_mgr.Repos_get_by_wiki(orig_repo);
|
||||
return url_bldr.Init_for_src_file(mode, repo_itm.Src(), orig_ttl, orig_md5, orig_ext, file_w, lnki_time, lnki_page).Xto_str();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_fail_timeout_)) fail_timeout = m.ReadInt("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_fail_timeout_ = "fail_timeout_";
|
||||
public static Xof_bin_wkr__http_wmf new_(Xow_wiki wiki) {return new Xof_bin_wkr__http_wmf(wiki.File__repo_mgr(), wiki.App().Wmf_mgr().Download_wkr().Download_xrg());}
|
||||
public static Xof_bin_wkr__http_wmf new_(Xow_wiki wiki) {return new_(wiki, Io_download_mgr_.new_system());}
|
||||
public static Xof_bin_wkr__http_wmf new_(Xow_wiki wiki, Io_download_mgr download_mgr) {return new Xof_bin_wkr__http_wmf(wiki.File__repo_mgr(), download_mgr, wiki.App().Wmf_mgr().Download_wkr().Download_xrg());}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
import org.junit.*; import gplx.ios.*; import gplx.xowa.files.repos.*;
|
||||
public class Xof_bin_wkr__http_wmf__tst {
|
||||
private final Xof_bin_wkr__http_wmf__fxt fxt = new Xof_bin_wkr__http_wmf__fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.Init__Http("mem/http/commons.wikimedia.org/thumb/7/70/A.png/220px-A.png", "test_data");
|
||||
fxt.Exec__Get_as_rdr(fxt.Fsdb_itm_mkr().Lnki__en_w("A.png").Orig__commons__lnki(), Bool_.Y, 220);
|
||||
fxt.Test__Get_as_rdr__rdr("test_data");
|
||||
}
|
||||
@Test public void Enwiki_fails__fallback_to_commons() {
|
||||
fxt.Init__Http("mem/http/commons.wikimedia.org/thumb/7/70/A.png/220px-A.png", "test_data"); // put file in commons
|
||||
Xof_fsdb_itm fsdb_itm = fxt.Fsdb_itm_mkr().Lnki__en_w("A.png").Orig__enwiki__lnki().Make();
|
||||
fxt.Exec__Get_as_rdr(fsdb_itm, Bool_.Y, 220); // look in enwiki
|
||||
fxt.Test__Get_as_rdr__rdr("test_data"); // test that enwiki tries commons again
|
||||
Tfds.Eq_str("commons.wikimedia.org", fsdb_itm.Orig_repo_name(), "repo_name"); // test that it's now commons
|
||||
Tfds.Eq_byte(Xof_repo_itm_.Repo_remote, fsdb_itm.Orig_repo_id(), "repo_tid"); // test that it's now commons
|
||||
}
|
||||
@Test public void Long_filename_becomes_thumbnail() {
|
||||
String filename = String_.Repeat("A", 200) + ".png";
|
||||
fxt.Init__Http("mem/http/commons.wikimedia.org/thumb/1/14/" + filename + "/220px-thumbnail.png", "test_data"); // add file as "thumbnail.png"
|
||||
Xof_fsdb_itm fsdb_itm = fxt.Fsdb_itm_mkr().Lnki__en_w(filename).Orig__enwiki__lnki().Make();
|
||||
fxt.Exec__Get_as_rdr(fsdb_itm, Bool_.Y, 220); // look in enwiki
|
||||
fxt.Test__Get_as_rdr__rdr("test_data"); // test that file is there
|
||||
}
|
||||
}
|
||||
class Xof_bin_wkr__http_wmf__fxt {
|
||||
private final Xof_bin_wkr__http_wmf wkr;
|
||||
private final Io_download_mgr__memory download_mgr;
|
||||
private Io_stream_rdr get_as_rdr__rdr;
|
||||
public Xof_fsdb_itm_fxt Fsdb_itm_mkr() {return fsdb_itm_mkr;} private final Xof_fsdb_itm_fxt fsdb_itm_mkr = new Xof_fsdb_itm_fxt();
|
||||
public Xof_bin_wkr__http_wmf__fxt() {
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
Xoa_app_fxt.repo2_(app, wiki);
|
||||
this.download_mgr = Io_download_mgr_.new_memory();
|
||||
this.wkr = Xof_bin_wkr__http_wmf.new_(wiki, download_mgr);
|
||||
}
|
||||
public void Clear() {
|
||||
download_mgr.Clear();
|
||||
}
|
||||
public void Init__Http(String url, String data) {download_mgr.Upload_data(url, Bry_.new_u8(data));}
|
||||
public void Exec__Get_as_rdr(Xof_fsdb_itm_fxt fsdb_itm_mkr, boolean is_thumb, int w) {Exec__Get_as_rdr(fsdb_itm_mkr.Make(), is_thumb, w);}
|
||||
public void Exec__Get_as_rdr(Xof_fsdb_itm fsdb_itm , boolean is_thumb, int w) {
|
||||
this.get_as_rdr__rdr = wkr.Get_as_rdr(fsdb_itm, is_thumb, w);
|
||||
}
|
||||
public void Test__Get_as_rdr__rdr(String expd) {
|
||||
Tfds.Eq_str(expd, Io_stream_rdr_.Load_all_as_str(get_as_rdr__rdr), "rdr_contents");
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class Xofc_fil_mgr {
|
||||
long cur_size = 0, actl_size = 0;
|
||||
Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
List_adp deleted = List_adp_.new_();
|
||||
tbl.Conn().Txn_bgn();
|
||||
tbl.Conn().Txn_bgn("user__file_cache__compress");
|
||||
long compress_to = cfg_mgr.Cache_min();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xofc_fil_itm itm = (Xofc_fil_itm)hash.Get_at(i);
|
||||
@@ -124,7 +124,7 @@ class Xofc_fil_mgr {
|
||||
wiki.Init_assert();
|
||||
Xof_repo_itm trg_repo = repo_mgr.Get_by_primary(wiki_domain);
|
||||
byte[] ttl = itm.Name();
|
||||
byte[] md5 = Xof_file_wkr_.Md5_(ttl);
|
||||
byte[] md5 = Xof_file_wkr_.Md5(ttl);
|
||||
int itm_ext_id = itm.Ext().Id();
|
||||
Io_url fil_url = url_bldr.Init_for_trg_file(mode_id, trg_repo, ttl, md5, itm.Ext(), itm.W()
|
||||
, Xof_lnki_time.Convert_to_xowa_thumbtime (itm_ext_id, itm.Time())
|
||||
|
||||
@@ -100,7 +100,7 @@ public class Xou_cache_mgr {
|
||||
synchronized (thread_lock) {
|
||||
Db_conn conn = cache_tbl.Conn();
|
||||
try {
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("user__file_cache__save");
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xou_cache_itm itm = (Xou_cache_itm)hash.Get_at(i);
|
||||
@@ -136,14 +136,16 @@ public class Xou_cache_mgr {
|
||||
for (int i = 0; i < len; ++i) { // iterate and find items to delete
|
||||
Xou_cache_grp grp = (Xou_cache_grp)grp_hash.Get_at(i);
|
||||
fsys_size_temp = fsys_size_calc + grp.File_size();
|
||||
if (fsys_size_temp > reduce_to) // fsys_size_cur exceeded; mark itm for deletion
|
||||
if ( fsys_size_temp > reduce_to // fsys_size_cur exceeded; mark itm for deletion
|
||||
|| fsys_size_temp == -1 // fsys_size sometimes -1; note -1 b/c file is missing; should fix, but for now, consider -1 size deleted; DATE:2015-08-05
|
||||
)
|
||||
deleted.Add(grp);
|
||||
else
|
||||
fsys_size_calc = fsys_size_temp;
|
||||
}
|
||||
len = deleted.Count();
|
||||
Db_conn conn = cache_tbl.Conn();
|
||||
conn.Txn_bgn();
|
||||
conn.Txn_bgn("user__file_cache__delete");
|
||||
for (int i = 0; i < len; i++) { // iterate and delete
|
||||
Xou_cache_grp grp = (Xou_cache_grp)deleted.Get_at(i);
|
||||
grp.Delete(hash, cache_tbl);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xof_img_wkr_resize_img_mok implements Xof_img_wkr_resize_img {
|
||||
int src_w = src_size.Width(), src_h = src_size.Height();
|
||||
if (trg_w < 1) throw Err_.new_wo_type("trg_w must be > 0", "trg_w", trg_w);
|
||||
if (trg_h < 1) trg_h = Xof_xfer_itm_.Scale_h(src_w, src_h, trg_w);
|
||||
Io_mgr.I.SaveFilStr(trg, SizeAdp_.new_(trg_w, trg_h).XtoStr());
|
||||
Io_mgr.I.SaveFilStr(trg, SizeAdp_.new_(trg_w, trg_h).To_str());
|
||||
return true;
|
||||
}
|
||||
public static final Xof_img_wkr_resize_img_mok _ = new Xof_img_wkr_resize_img_mok(); Xof_img_wkr_resize_img_mok() {}
|
||||
|
||||
@@ -61,7 +61,7 @@ class Fs_root_dir_fxt {
|
||||
}
|
||||
public static void Save_img(String url, int w, int h) {
|
||||
gplx.gfui.SizeAdp img_size = gplx.gfui.SizeAdp_.new_(w, h);
|
||||
Io_mgr.I.SaveFilStr(url, img_size.XtoStr());
|
||||
Io_mgr.I.SaveFilStr(url, img_size.To_str());
|
||||
}
|
||||
public void Test_xto_fil_bry(String url_str, String expd) {
|
||||
Io_url url = Io_url_.new_fil_(url_str);
|
||||
|
||||
@@ -30,7 +30,7 @@ class Xof_img_wkr_convert_djvu_to_tiff_app implements Xof_img_wkr_convert_djvu_t
|
||||
class Xof_img_wkr_convert_djvu_to_tiff_mok implements Xof_img_wkr_convert_djvu_to_tiff {
|
||||
public Xof_img_wkr_convert_djvu_to_tiff_mok(int w, int h) {this.w = w; this.h = h;} private int w, h;
|
||||
public boolean Exec(Io_url src, Io_url trg) {
|
||||
Io_mgr.I.SaveFilStr(trg, gplx.gfui.SizeAdp_.new_(w, h).XtoStr());
|
||||
Io_mgr.I.SaveFilStr(trg, gplx.gfui.SizeAdp_.new_(w, h).To_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xof_orig_wkr__xo_meta implements Xof_orig_wkr {
|
||||
public byte Tid() {return Xof_orig_wkr_.Tid_xowa_meta;}
|
||||
public void Find_by_list(Ordered_hash rv, List_adp itms) {Xof_orig_wkr_.Find_by_list(this, rv, itms);}
|
||||
public Xof_orig_itm Find_as_itm(byte[] ttl, int list_idx, int list_len) {
|
||||
byte[] md5 = Xof_file_wkr_.Md5_(ttl);
|
||||
byte[] md5 = Xof_file_wkr_.Md5(ttl);
|
||||
url_bfr.Add(wiki_meta_dir.RawBry()) // /xowa/file/#meta/simple.wikipedia.org/
|
||||
.Add_byte(md5[0]).Add_byte(dir_spr_byte) // 0/
|
||||
.Add_byte(md5[1]).Add_byte(dir_spr_byte) // 6/
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Xowe_repo_mgr implements Xow_repo_mgr, GfoInvkAble {
|
||||
}
|
||||
byte[] Xfer_by_meta__find_main_ptr(Xof_meta_itm meta_itm, Xof_xfer_itm xfer_itm) {
|
||||
byte[] redirect = meta_itm.Ptr_ttl(); int redirect_tries = 0;
|
||||
byte[] md5 = Xof_file_wkr_.Md5_(redirect);
|
||||
byte[] md5 = Xof_file_wkr_.Md5(redirect);
|
||||
while (true) {
|
||||
boolean found = page_finder.Locate(tmp_rslt, repos, redirect);
|
||||
if (!found) return null;
|
||||
|
||||
@@ -73,8 +73,8 @@ public class Xof_xfer_mgr {
|
||||
}
|
||||
|
||||
// BLOCK: orig; get orig for convert; note that Img_download will not download file again if src exists
|
||||
src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
if (!Img_download(src_str, trg_url, false)) return false;
|
||||
trg_url = rslt.Trg();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Xof_xfer_mgr {
|
||||
}
|
||||
if (!Bry_.Eq(rslts.Orig_page(), orig_ttl)) {
|
||||
orig_ttl = rslts.Orig_page();
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5_(orig_ttl);
|
||||
orig_ttl_md5 = Xof_file_wkr_.Md5(orig_ttl);
|
||||
meta_itm.Ptr_ttl_(orig_ttl);
|
||||
}
|
||||
meta_itm.Vrtl_repo_(xfer_itm.Orig_repo_id());
|
||||
@@ -138,7 +138,7 @@ public class Xof_xfer_mgr {
|
||||
if (!wmf_api_found) return false; // not found in wmf_api; exit now
|
||||
}
|
||||
else if (src_repo.Tarball()) {
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
meta_itm.Orig_exists_(Xof_meta_itm.Exists_unknown); // mark exists unknown; note need to assertively mark unknown b/c it may have been marked n in previous pass through multiple repos; DATE:20121227
|
||||
meta_itm.Vrtl_repo_(Xof_meta_itm.Repo_unknown); // mark repo unknown;
|
||||
if (!Cmd_query_size(Io_url_.new_fil_(src_str))) {
|
||||
@@ -256,8 +256,8 @@ public class Xof_xfer_mgr {
|
||||
}
|
||||
boolean Make_other() {
|
||||
if (!Orig_max_download() && !force_orig) return false;
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
Io_url trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
String src_str = this.Src_url(src_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
Io_url trg_url = this.Trg_url(trg_repo, Xof_repo_itm_.Mode_orig, Xof_img_size.Size__neg1);
|
||||
return Cmd_download(src_str, trg_url, true);
|
||||
}
|
||||
boolean Orig_max_download() {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
@Test public void Ogg_vid_thumb() {
|
||||
fxt .ini_page_create_commons ("File:A.ogg");
|
||||
fxt .Lnki_orig_("A.ogg")
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/4/42/A.ogg/mid-A.ogg.jpg", 300, 40))
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/4/42/A.ogg/-1px--A.ogg.jpg", 300, 40))
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/4/2/A.ogg/300px.jpg", 300, 40)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/4/42.csv", "A.ogg|0||0?0,0|1?300,40")
|
||||
);
|
||||
@@ -234,7 +234,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
fxt.Src_en_wiki_repo().Ext_rules().Get_or_new(Xof_ext_.Bry_ogv).View_max_(0);
|
||||
Io_mgr.I.SaveFilStr("mem/xowa/file/#meta/en.wikipedia.org/d/d0.csv", "A.ogv|0||2?0,0|1?300,40\n"); // simulate (a)
|
||||
fxt .Lnki_("A.ogv", true, -1, -1, -1, 5)
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/seek%3D5-A.ogv.jpg", 300, 40)
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/-1px-seek%3D5-A.ogv.jpg", 300, 40)
|
||||
)
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/d/0/A.ogv/300px@5.jpg", 300, 40)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/d/d0.csv", "A.ogv|0||2?0,0|1?300,40@5")
|
||||
@@ -246,7 +246,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
fxt .ini_page_create_commons ("File:A.webm");
|
||||
fxt .Lnki_thumb_("A.webm", 220)
|
||||
.Src( fxt.ogg_("mem/src/commons.wikimedia.org/3/34/A.webm")
|
||||
, fxt.img_("mem/src/commons.wikimedia.org/thumb/3/34/A.webm/mid-A.webm.jpg", 300, 40)
|
||||
, fxt.img_("mem/src/commons.wikimedia.org/thumb/3/34/A.webm/220px--A.webm.jpg", 300, 40)
|
||||
)
|
||||
.Trg( fxt.ogg_("mem/trg/commons.wikimedia.org/raw/3/4/A.webm")
|
||||
, fxt.img_("mem/trg/commons.wikimedia.org/fit/3/4/A.webm/300px.jpg", 300, 40)
|
||||
@@ -257,7 +257,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
@Test public void Ogv_thumb() {// d00d1d5019e37cc219a91a2f8ad47bfe
|
||||
fxt .ini_page_create_commons ("File:A.ogv");
|
||||
fxt .Lnki_orig_("A.ogv")
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/mid-A.ogv.jpg", 300, 40))
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/d/d0/A.ogv/-1px--A.ogv.jpg", 300, 40))
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/d/0/A.ogv/300px.jpg", 300, 40)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/d/d0.csv", "A.ogv|0||0?0,0|1?300,40")
|
||||
)
|
||||
@@ -269,7 +269,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
}
|
||||
@Test public void Thumbtime_ignored_if_non_media() { // PURPOSE: ignore thumbtime if not media; PAGE:en.w:Moon; EX:[[File:A.png|thumbtime=0.02]] DATE:2014-07-22
|
||||
fxt .ini_page_create_en_wiki("File:A.png");
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, 2) // thumbtime of 2 specified; will be ignored below
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, 2) // thumbtime of 2 specified; will be ignored below
|
||||
.Src( fxt.img_("mem/src/en.wikipedia.org/thumb/7/70/A.png/90px-A.png", 90, 80))
|
||||
.Trg( fxt.img_("mem/trg/en.wikipedia.org/fit/7/0/A.png/90px.png", 90, 80)
|
||||
, fxt.reg_("mem/xowa/file/#meta/en.wikipedia.org/7/70.csv", "A.png|y||2?0,0|1?90,80")
|
||||
|
||||
@@ -25,8 +25,8 @@ public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
super.Clear(src_repo_is_wmf);
|
||||
this.Api_size().Clear();
|
||||
}
|
||||
public Xof_xfer_queue_html_fxt Lnki_orig_ (String lnki_ttl) {return Lnki_(lnki_ttl, Bool_.N, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_thumb_(String lnki_ttl, int lnki_w) {return Lnki_(lnki_ttl, Bool_.Y, lnki_w, Xof_img_size.Size_null_deprecated, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_orig_ (String lnki_ttl) {return Lnki_(lnki_ttl, Bool_.N, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_thumb_(String lnki_ttl, int lnki_w) {return Lnki_(lnki_ttl, Bool_.Y, lnki_w, Xof_img_size.Size__neg1, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_thumb_(String lnki_ttl, int lnki_w, int lnki_h) {return Lnki_(lnki_ttl, Bool_.Y, lnki_w, lnki_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null_as_int);}
|
||||
public Xof_xfer_queue_html_fxt Lnki_(String lnki_ttl, boolean thumb, int lnki_w, int lnki_h, double upright, int seek_time) { // NOTE: only one xfer_itm; supports one Lnki_ per test only
|
||||
Xowe_wiki wiki = this.En_wiki();
|
||||
|
||||
@@ -158,7 +158,7 @@ public class Xof_xfer_queue_html_wmf_api_tst {
|
||||
@Test public void Imap() { // PURPOSE: check that imap downloads orig, even when thumb is requested; DATE:2014-08-08
|
||||
fxt .ini_page_create_commons("File:A.png");
|
||||
fxt .ini_page_api("commons", "A.png", "", 180, 160);
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size_null_deprecated, Xof_img_size.Size_null_deprecated, Xof_lnki_time.Null_as_int); // thumbtime of 2 specified; will be ignored below
|
||||
fxt .Lnki_("A.png", true, 90, Xof_img_size.Size__neg1, Xof_img_size.Size__neg1, Xof_lnki_time.Null_as_int); // thumbtime of 2 specified; will be ignored below
|
||||
fxt .Xfer_itm().Html_elem_tid_(Xof_html_elem.Tid_imap);
|
||||
fxt .Src( fxt.img_("mem/src/commons.wikimedia.org/thumb/7/70/A.png/90px-A.png", 90, 80))
|
||||
.Trg( fxt.img_("mem/trg/commons.wikimedia.org/fit/7/0/A.png/90px.png", 90, 80)
|
||||
|
||||
Reference in New Issue
Block a user