mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.2.4.1
This commit is contained in:
@@ -1,33 +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; import gplx.*;
|
||||
import gplx.ios.*;
|
||||
public abstract class Xof_img_wkr_api_size_base {
|
||||
public boolean Api_query_size(Xof_img_wkr_api_size_base_rslts rv, Xow_wiki wiki, byte[] ttl, int width, int height) {
|
||||
Gfo_usr_dlg usr_dlg = wiki.App().Usr_dlg();
|
||||
Xow_repo_mgr repo_mgr = wiki.File_mgr().Repo_mgr();
|
||||
int len = repo_mgr.Repos_len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xof_repo_pair repo_pair = repo_mgr.Repos_get_at(i);
|
||||
if (Api_query_size_exec(rv, wiki, ttl, width, height, usr_dlg, repo_pair.Wiki_key())) return true;
|
||||
}
|
||||
usr_dlg.Warn_many(Xof_img_wkr_api_size_base_wmf.GRP_KEY, "download_failed", "download_failed: ~{0}", String_.new_utf8_(ttl));
|
||||
return false;
|
||||
}
|
||||
public abstract boolean Api_query_size_exec(Xof_img_wkr_api_size_base_rslts rv, Xow_wiki wiki, byte[] ttl, int width, int height, Gfo_usr_dlg usr_dlg, byte[] repo_wiki_key);
|
||||
}
|
||||
@@ -1,41 +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; import gplx.*;
|
||||
public class Xof_img_wkr_api_size_base_fxt {
|
||||
Xoa_app app; Xow_wiki wiki; Xof_img_wkr_api_size_base_rslts rv = new Xof_img_wkr_api_size_base_rslts();
|
||||
public void Clear() {
|
||||
this.app = Xoa_app_fxt.app_();
|
||||
this.wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
}
|
||||
public void Bld_api_url_tst(String ttl_str, int w, int h, String expd) {
|
||||
String actl = Xof_img_wkr_api_size_base_wmf.Bld_api_url(wiki.Domain_bry(), Bry_.new_utf8_(ttl_str), w, h);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
public void Parse_size_tst(String xml_str, int expd_w, int expd_h) {
|
||||
byte[] xml_bry = Bry_.new_utf8_(xml_str);
|
||||
Xof_img_wkr_api_size_base_wmf.Parse_xml(rv, app.Usr_dlg(), xml_bry);
|
||||
Tfds.Eq(expd_w, rv.Orig_w());
|
||||
Tfds.Eq(expd_h, rv.Orig_h());
|
||||
}
|
||||
public void Parse_reg_tst(String xml_str, String expd_wiki, String expd_page) {
|
||||
byte[] xml_bry = Bry_.new_utf8_(xml_str);
|
||||
Xof_img_wkr_api_size_base_wmf.Parse_xml(rv, app.Usr_dlg(), xml_bry);
|
||||
Tfds.Eq(expd_wiki, String_.new_utf8_(rv.Reg_wiki()));
|
||||
Tfds.Eq(expd_page, String_.new_utf8_(rv.Reg_page()));
|
||||
}
|
||||
}
|
||||
@@ -1,36 +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; import gplx.*;
|
||||
public class Xof_img_wkr_api_size_base_mok extends Xof_img_wkr_api_size_base {
|
||||
public Xof_img_wkr_api_size_base_mok Ini(String wiki_str, String ttl_str, String redirect_str, int orig_w, int orig_h, boolean pass) {
|
||||
this.wiki_str = wiki_str; this.ttl_str = ttl_str; this.redirect_str = redirect_str; this.orig_w = orig_w; this.orig_h = orig_h; this.fail = !pass;
|
||||
return this;
|
||||
} String wiki_str = ""; String ttl_str = ""; String redirect_str = ""; int orig_w; int orig_h; boolean fail = false;
|
||||
public void Clear() {wiki_str = ttl_str = redirect_str = ""; orig_w = orig_h = 0;}
|
||||
@Override public boolean Api_query_size_exec(Xof_img_wkr_api_size_base_rslts rv, Xow_wiki wiki, byte[] ttl, int width, int height, Gfo_usr_dlg usr_dlg, byte[] repo_wiki_key) {
|
||||
if (!Bry_.Eq(ttl, Bry_.new_utf8_(ttl_str))) return false;
|
||||
if (!String_.Eq(wiki_str, String_.new_ascii_(repo_wiki_key))) return false;
|
||||
if (fail) return false;
|
||||
rv.Orig_w_(orig_w);
|
||||
rv.Orig_h_(orig_h);
|
||||
rv.Reg_wiki_(repo_wiki_key);
|
||||
rv.Reg_page_(String_.Eq(redirect_str, "") ? ttl : Bry_.new_utf8_(redirect_str));
|
||||
return true;
|
||||
}
|
||||
public static final Xof_img_wkr_api_size_base_mok _ = new Xof_img_wkr_api_size_base_mok(); Xof_img_wkr_api_size_base_mok() {}
|
||||
}
|
||||
@@ -1,28 +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; import gplx.*;
|
||||
public class Xof_img_wkr_api_size_base_rslts {
|
||||
public int Orig_w() {return orig_w;} public Xof_img_wkr_api_size_base_rslts Orig_w_(int v) {orig_w = v; return this;} private int orig_w;
|
||||
public int Orig_h() {return orig_h;} public Xof_img_wkr_api_size_base_rslts Orig_h_(int v) {orig_h = v; return this;} private int orig_h;
|
||||
public byte[] Reg_wiki() {return reg_wiki;} public Xof_img_wkr_api_size_base_rslts Reg_wiki_(byte[] v) {reg_wiki = v; return this;} private byte[] reg_wiki;
|
||||
public byte[] Reg_page() {return reg_page;} public Xof_img_wkr_api_size_base_rslts Reg_page_(byte[] v) {reg_page = v; return this;} private byte[] reg_page;
|
||||
public void Clear() {
|
||||
orig_w = orig_h = 0;
|
||||
reg_wiki = reg_page = null;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +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; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class Xof_img_wkr_api_size_base_tst {
|
||||
Xof_img_wkr_api_size_base_fxt fxt = new Xof_img_wkr_api_size_base_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Bld_api_url() {
|
||||
fxt.Bld_api_url_tst("A.png" , 220, 110, "http://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A.png&iiurlwidth=220&iiurlheight=110");
|
||||
fxt.Bld_api_url_tst("A.png" , 220, 0, "http://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A.png&iiurlwidth=220");
|
||||
fxt.Bld_api_url_tst("A.png" , 0, 110, "http://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A.png"); // assert that null width does not write height
|
||||
fxt.Bld_api_url_tst("A b.png" , 220, 0, "http://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A_b.png&iiurlwidth=220");
|
||||
fxt.Bld_api_url_tst("A&b.png" , 220, 0, "http://en.wikipedia.org/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:A%26b.png&iiurlwidth=220");
|
||||
}
|
||||
@Test public void Parse_size() {
|
||||
String raw = "<api><query><pages><page ns=\"6\" title=\"File:A.png\" missing=\"\" imagerepository=\"shared\"><imageinfo><ii size=\"1234\" width=\"220\" height=\"110\" /></imageinfo></page></pages></query></api>";
|
||||
fxt.Parse_size_tst(raw, 220, 110);
|
||||
}
|
||||
@Test public void Parse_reg() {
|
||||
String raw = "<api><query><pages><page ns=\"6\" title=\"File:A.png\" missing=\"\" imagerepository=\"shared\"><imageinfo><ii descriptionurl=\"http://commons.wikimedia.org/wiki/File:Berkheyde-Haarlem.png\" /></imageinfo></page></pages></query></api>";
|
||||
fxt.Parse_reg_tst(raw, "commons.wikimedia.org", "Berkheyde-Haarlem.png");
|
||||
}
|
||||
}
|
||||
@@ -1,87 +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; import gplx.*;
|
||||
public class Xof_img_wkr_api_size_base_wmf extends Xof_img_wkr_api_size_base {
|
||||
@Override public boolean Api_query_size_exec(Xof_img_wkr_api_size_base_rslts rv, Xow_wiki wiki, byte[] ttl, int width, int height, Gfo_usr_dlg usr_dlg, byte[] repo_wiki_key) {
|
||||
String src = Bld_api_url(repo_wiki_key, ttl, width, height);
|
||||
// xrg.Prog_fmt_hdr_(); // NOTE: do not uncomment; api will reuse whatever's in place
|
||||
byte[] xml = wiki.App().File_mgr().Download_mgr().Download_wkr().Download_xrg().Exec_as_bry(src);
|
||||
return xml == null ? false : Parse_xml(rv, usr_dlg, xml);
|
||||
}
|
||||
public static boolean Parse_xml(Xof_img_wkr_api_size_base_rslts rv, Gfo_usr_dlg usr_dlg, byte[] xml) {
|
||||
rv.Clear();
|
||||
int xml_len = xml.length;
|
||||
int pos = 0;
|
||||
pos = Bry_finder.Find_fwd(xml, Bry_xml_ii , pos, xml_len); if (pos == Bry_.NotFound) return Parse_xml_failed(usr_dlg, xml);
|
||||
pos += Bry_xml_ii.length;
|
||||
|
||||
if (Parse_xml_val(parse_xml_rng, usr_dlg, xml, xml_len, pos, Bry_xml_width))
|
||||
rv.Orig_w_(Bry_.Xto_int_or(xml, parse_xml_rng.Val_0(), parse_xml_rng.Val_1(), 0));
|
||||
|
||||
if (Parse_xml_val(parse_xml_rng, usr_dlg, xml, xml_len, pos, Bry_xml_height))
|
||||
rv.Orig_h_(Bry_.Xto_int_or(xml, parse_xml_rng.Val_0(), parse_xml_rng.Val_1(), 0));
|
||||
|
||||
if (Parse_xml_val(parse_xml_rng, usr_dlg, xml, xml_len, pos, Bry_xml_descriptionurl)) {
|
||||
byte[] file_url = Bry_.Mid(xml, parse_xml_rng.Val_0(), parse_xml_rng.Val_1());
|
||||
url_parser.Parse(url, file_url, 0, file_url.length);
|
||||
rv.Reg_wiki_(url.Site());
|
||||
byte[] page = Xoa_ttl.Replace_spaces(url.Page());
|
||||
int colon_pos = Bry_finder.Find_fwd(page, Byte_ascii.Colon, 0, page.length);
|
||||
if (colon_pos != Bry_.NotFound)
|
||||
page = Bry_.Mid(page, colon_pos + 1, page.length);
|
||||
rv.Reg_page_(page);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static Int_2_ref parse_xml_rng = new Int_2_ref(); static Xoa_url parse_xml_url = Xoa_url.blank_();
|
||||
private static Gfo_url_parser url_parser = new Gfo_url_parser(); static Gfo_url url = new Gfo_url();
|
||||
private static boolean Parse_xml_val(Int_2_ref rv, Gfo_usr_dlg usr_dlg, byte[] xml, int xml_len, int pos, byte[] key) {
|
||||
int bgn = 0, end = 0;
|
||||
bgn = Bry_finder.Find_fwd(xml, key , pos, xml_len); if (bgn == Bry_.NotFound) return false;
|
||||
bgn += key.length;
|
||||
end = Bry_finder.Find_fwd(xml, Byte_ascii.Quote , bgn, xml_len); if (end == Bry_.NotFound) return false;
|
||||
rv.Val_all_(bgn, end);
|
||||
return true;
|
||||
}
|
||||
private static boolean Parse_xml_failed(Gfo_usr_dlg usr_dlg, byte[] xml) {usr_dlg.Log_many(GRP_KEY, "api_failed", "api failed: ~{0}", String_.new_utf8_(xml)); return false;}
|
||||
public static String Bld_api_url(byte[] wiki_key, byte[] ttl, int width, int height) {
|
||||
bfr .Add(Xoh_href_parser.Href_http_bry) // "http://"
|
||||
.Add(wiki_key) // "commons.wikimedia.org"
|
||||
.Add(Bry_api) // "/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&titles=File:"
|
||||
.Add(encoder.Encode(ttl)) // "A%20B.png"
|
||||
;
|
||||
if (width > 0)
|
||||
bfr.Add(Bry_width).Add_int_variable(width); // "&iiurlwidth=800"
|
||||
if (height > 0 && width > 0) // NOTE: height cannot be used alone; width must also exist; "iiurlheight cannot be used without iiurlwidth"
|
||||
bfr.Add(Bry_height).Add_int_variable(height); // "&iiurlheight=600"
|
||||
return bfr.Xto_str_and_clear();
|
||||
}
|
||||
private static Url_encoder encoder = Url_encoder.new_http_url_().Itms_raw_diff(Byte_ascii.Space, Byte_ascii.Underline);
|
||||
Io_url trg = Io_url_.mem_fil_("mem/temp/api.txt");
|
||||
private static final Bry_bfr bfr = Bry_bfr.new_();
|
||||
private static final byte[]
|
||||
Bry_api = Bry_.new_ascii_("/w/api.php?action=query&format=xml&prop=imageinfo&iiprop=size|url&redirects&titles=File:") // NOTE: using File b/c it should be canonical
|
||||
, Bry_width = Bry_.new_ascii_("&iiurlwidth=")
|
||||
, Bry_height = Bry_.new_ascii_("&iiurlheight=")
|
||||
, Bry_xml_ii = Bry_.new_ascii_("<ii ")
|
||||
, Bry_xml_width = Bry_.new_ascii_("width=\"")
|
||||
, Bry_xml_height = Bry_.new_ascii_("height=\"")
|
||||
, Bry_xml_descriptionurl = Bry_.new_ascii_("descriptionurl=\"")
|
||||
;
|
||||
public static final String GRP_KEY = "xowa.file.wmf.api";
|
||||
}
|
||||
@@ -1,35 +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; import gplx.*;
|
||||
import gplx.gfui.*;
|
||||
public interface Xof_img_wkr_query_img_size {
|
||||
SizeAdp Exec(Io_url url);
|
||||
}
|
||||
class Xof_img_wkr_query_img_size_imageMagick implements Xof_img_wkr_query_img_size {
|
||||
public Xof_img_wkr_query_img_size_imageMagick(Xoa_app app, ProcessAdp cmd) {this.app = app; this.cmd = cmd;} private Xoa_app app; ProcessAdp cmd;
|
||||
public SizeAdp Exec(Io_url url) {
|
||||
cmd.Prog_fmt_(String_.Replace(app.File_mgr().Download_mgr().Download_wkr().Download_xrg().Prog_fmt_hdr(), "~", "~~") + " querying: ~{process_seconds} second(s); ~{process_exe_name} ~{process_exe_args}");
|
||||
cmd.Run(url);
|
||||
String size_str = cmd.Rslt_out();
|
||||
int pos_bgn = String_.FindFwd(size_str, "<{", 0); if (pos_bgn == String_.Find_none) return SizeAdp_.Zero; // NOTE: RE: "FindFwd(,0)"; multiple frames are possible; 1st frame must be used as last frame is not accurate; EX:w.Chess:[[File:ChessCastlingMovie.gif|thumb|250px]]
|
||||
int pos_end = String_.FindFwd(size_str, "}>", pos_bgn); if (pos_end == String_.Find_none) return SizeAdp_.Zero;
|
||||
size_str = String_.Mid(size_str, pos_bgn + Marker_bgn_len, pos_end);
|
||||
return SizeAdp_.parse_or_(size_str, SizeAdp_.Zero);
|
||||
}
|
||||
static final String Marker_bgn = "<{", Marker_end = "}>"; static final int Marker_bgn_len = String_.Len(Marker_bgn);
|
||||
}
|
||||
@@ -1,25 +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; import gplx.*;
|
||||
import gplx.gfui.*;
|
||||
public class Xof_img_wkr_query_img_size_test implements Xof_img_wkr_query_img_size {
|
||||
public SizeAdp Exec(Io_url url) {
|
||||
ImageAdp image = ImageAdp_.txt_fil_(url);
|
||||
return image.Size();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +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; import gplx.*;
|
||||
public class Xof_repo_pair implements GfoInvkAble {
|
||||
public Xof_repo_pair(int id, Xof_repo_itm src, Xof_repo_itm trg, Xof_meta_mgr trg_meta_mgr, byte[] wiki_key) {
|
||||
this.id = (byte)id; this.src = src; this.trg = trg; this.trg_meta_mgr = trg_meta_mgr; this.wiki_key = wiki_key;
|
||||
this.repo_id = this.id;
|
||||
}
|
||||
public byte Id() {return id;} private byte id;
|
||||
public byte Repo_id() {return repo_id;} private byte repo_id;
|
||||
public Xof_repo_itm Src() {return src;} private Xof_repo_itm src;
|
||||
public Xof_repo_itm Trg() {return trg;} private Xof_repo_itm trg;
|
||||
public Xof_meta_mgr Trg_meta_mgr() {return trg_meta_mgr;} private Xof_meta_mgr trg_meta_mgr;
|
||||
public byte[] Wiki_key() {return wiki_key;} private byte[] wiki_key;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_repo_id_)) repo_id = m.ReadByte("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_repo_id_ = "repo_id_";
|
||||
}
|
||||
@@ -16,9 +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; import gplx.*;
|
||||
import gplx.core.primitives.*; import gplx.gfui.*; import gplx.xowa.files.*;
|
||||
import gplx.core.primitives.*; import gplx.gfui.*; import gplx.xowa.files.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wmfs.*; import gplx.xowa.wmfs.apis.*; import gplx.xowa.files.exts.*;
|
||||
public class Xof_xfer_mgr {
|
||||
public Xof_xfer_mgr(Xof_file_mgr file_mgr) {this.file_mgr = file_mgr;} private Xof_file_mgr file_mgr;
|
||||
public Xof_xfer_mgr(Xof_file_mgr file_mgr, Xowmf_mgr wmf_mgr) {this.file_mgr = file_mgr; this.wmf_mgr = wmf_mgr;} private final Xof_file_mgr file_mgr; private final Xowmf_mgr wmf_mgr;
|
||||
public Xof_xfer_rslt Rslt() {return rslt;} private Xof_xfer_rslt rslt = new Xof_xfer_rslt();
|
||||
public boolean Force_orig() {return force_orig;} public Xof_xfer_mgr Force_orig_(boolean v) {force_orig = v; return this;} private boolean force_orig;
|
||||
public Xof_xfer_mgr Force_orig_y_() {return Force_orig_(Bool_.Y);} public Xof_xfer_mgr Force_orig_n_() {return Force_orig_(Bool_.N);}
|
||||
@@ -36,12 +37,12 @@ public class Xof_xfer_mgr {
|
||||
orig_w = 0; orig_h = 0; file_w = 0; file_h = 0;
|
||||
} private byte lnki_type;
|
||||
private Xof_xfer_itm xfer_itm; private double lnki_thumbtime = Xof_doc_thumb.Null; private boolean lnki_thumbable; private int lnki_w, lnki_h, file_w, file_h; private double lnki_upright;
|
||||
private Xof_ext ext; private Xoft_rule_itm ext_rule; private Xof_repo_itm src_repo, trg_repo; private boolean src_repo_is_wmf; private byte[] ttl, md5; private int orig_w, orig_h, orig_file_len;
|
||||
private Xof_ext ext; private Xof_rule_itm ext_rule; private Xof_repo_itm src_repo, trg_repo; private boolean src_repo_is_wmf; private byte[] ttl, md5; private int orig_w, orig_h, orig_file_len;
|
||||
private int lnki_page = Xof_doc_page.Null;
|
||||
public Xof_meta_itm Meta_itm() {return meta_itm;} private Xof_meta_itm meta_itm;
|
||||
public boolean Download_allowed_by_ext() {return orig_file_len < ext_rule.Make_max();}
|
||||
public Xof_xfer_mgr Check_file_exists_before_xfer_n_() {check_file_exists_before_xfer = false; return this;} private boolean check_file_exists_before_xfer = true;
|
||||
public boolean Make_file(Xow_wiki wiki) {
|
||||
public boolean Make_file(Xowe_wiki wiki) {
|
||||
rslt.Clear(); this.wiki = wiki;
|
||||
if ( src_repo.Wmf_api() // make sure wmf_api enabled
|
||||
&& ( ( ext.Id() == Xof_ext_.Id_ogg // file is ogg; could be audio; DATE:2013-08-03
|
||||
@@ -54,13 +55,14 @@ public class Xof_xfer_mgr {
|
||||
else if (ext.Id_is_video()&& !meta_itm.Thumbs_indicates_oga()) Make_vid();
|
||||
else Make_other();
|
||||
return rslt.Pass();
|
||||
} private Xow_wiki wiki; Xof_img_wkr_api_size_base_rslts rslts = new Xof_img_wkr_api_size_base_rslts();
|
||||
} private Xowe_wiki wiki; Xoapi_orig_rslts rslts = new Xoapi_orig_rslts();
|
||||
private boolean Make_img() {
|
||||
String src_str; Io_url trg_url;
|
||||
// BLOCK: thumb
|
||||
if (lnki_thumbable) { // lnki is thumb with known width >>> try to do thumb
|
||||
if (lnki_w < 1 && lnki_h < 1) { // NOTE: only give default thumb if both w and h are < 1; if h > 0, then skip; EX:Paris;[[File:IMA-Ile-St-Louis.jpg|thumb|x220]]
|
||||
lnki_w = Xof_img_size.Upright_calc(wiki.File_mgr().Fsdb_mgr().Patch_upright(), lnki_upright, lnki_w, lnki_w, lnki_h, lnki_type);
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki(wiki);
|
||||
lnki_w = Xof_img_size.Upright_calc(wiki.File_mgr().Patch_upright(), lnki_upright, lnki_w, lnki_w, lnki_h, lnki_type);
|
||||
if (lnki_w < 1)
|
||||
lnki_w = wiki.Html_mgr().Img_thumb_width(); // NOTE: used to be src_repo.Thumb_w()
|
||||
}
|
||||
@@ -81,7 +83,7 @@ public class Xof_xfer_mgr {
|
||||
Io_url src_url = trg_url;
|
||||
if (ext.Id_is_djvu()) { // NOTE: this block converts djvu -> tiff b/c vanilla imageMagick cannot do djvu -> jpeg
|
||||
trg_url = this.Trg_url(trg_repo, Xof_repo_itm.Mode_thumb, lnki_w).GenNewExt(".tiff"); // NOTE: manually change ext to tiff; note that djvu has view type of jpeg
|
||||
wiki.App().File_mgr().Img_mgr().Wkr_convert_djvu_to_tiff().Exec(src_url, trg_url);
|
||||
wiki.Appe().File_mgr().Img_mgr().Wkr_convert_djvu_to_tiff().Exec(src_url, trg_url);
|
||||
if (!Cmd_query_size(trg_url)) return false;
|
||||
// meta_itm.Update_orig_size(file_w, file_h); // NOTE that thumb size is always orig size
|
||||
src_url = trg_url;
|
||||
@@ -96,20 +98,21 @@ public class Xof_xfer_mgr {
|
||||
return true;
|
||||
} Int_2_ref calc_size = new Int_2_ref();
|
||||
boolean Call_wmf_api() {
|
||||
boolean found = wiki.App().File_mgr().Download_mgr().Api_size_wkr().Api_query_size(rslts, wiki, ttl, lnki_w, lnki_h);
|
||||
Xof_download_wkr download_wkr = wiki.App().Wmf_mgr().Download_wkr(); Xowe_repo_mgr repo_mgr = wiki.File_mgr().Repo_mgr();
|
||||
boolean found = wiki.App().Wmf_mgr().Api_mgr().Api_orig().Api_query_size(rslts, download_wkr, repo_mgr, ttl, lnki_w, lnki_h);
|
||||
if (found) {
|
||||
if (rslts.Reg_wiki() != null) {
|
||||
src_repo = wiki.App().File_mgr().Repo_mgr().Get_by_wmf(rslts.Reg_wiki());
|
||||
trg_repo = wiki.App().File_mgr().Repo_mgr().Get_primary(rslts.Reg_wiki());
|
||||
if (Bry_.Eq(rslts.Reg_wiki(), wiki.Domain_bry())) // wmf returned same wiki as current
|
||||
if (rslts.Orig_wiki() != null) {
|
||||
src_repo = wiki.Appe().File_mgr().Repo_mgr().Get_by_wmf_fsys(rslts.Orig_wiki());
|
||||
trg_repo = wiki.Appe().File_mgr().Repo_mgr().Get_by_primary(rslts.Orig_wiki());
|
||||
if (Bry_.Eq(rslts.Orig_wiki(), wiki.Domain_bry())) // wmf returned same wiki as current
|
||||
xfer_itm.Trg_repo_idx_(Xof_meta_itm.Repo_same); // set repo to "same"
|
||||
else { // wmf returned other wiki (which is 99% likely to be commons)
|
||||
Xof_repo_pair trg_repo_pair = wiki.File_mgr().Repo_mgr().Repos_get_by_wiki(rslts.Reg_wiki()); // need to do this b/c commons is not always first; see wikinews; DATE:2013-12-04
|
||||
int trg_repo_idx = trg_repo_pair == null ? 0 : (int)trg_repo_pair.Id(); // 0=commons
|
||||
Xof_repo_pair trg_repo_pair = wiki.File_mgr().Repo_mgr().Repos_get_by_wiki(rslts.Orig_wiki()); // need to do this b/c commons is not always first; see wikinews; DATE:2013-12-04
|
||||
int trg_repo_idx = trg_repo_pair == null ? 0 : (int)trg_repo_pair.Repo_idx(); // 0=commons
|
||||
xfer_itm.Trg_repo_idx_(trg_repo_idx);
|
||||
}
|
||||
if (!Bry_.Eq(rslts.Reg_page(), ttl)) {
|
||||
ttl = rslts.Reg_page();
|
||||
if (!Bry_.Eq(rslts.Orig_page(), ttl)) {
|
||||
ttl = rslts.Orig_page();
|
||||
md5 = Xof_xfer_itm_.Md5_(ttl);
|
||||
meta_itm.Ptr_ttl_(ttl);
|
||||
}
|
||||
@@ -259,8 +262,8 @@ public class Xof_xfer_mgr {
|
||||
boolean Orig_max_download() {
|
||||
long ext_max = ext_rule.View_max();
|
||||
return (orig_file_len < ext_max) // file_len is less than defined max
|
||||
|| (ext_max == Xoft_rule_itm.Max_wildcard); // max is defined as wildcard
|
||||
// return !(orig_file_len < ext_max || (ext_max == Xoft_rule_itm.Max_wildcard && orig_file_len < 1));
|
||||
|| (ext_max == Xof_rule_itm.Max_wildcard); // max is defined as wildcard
|
||||
// return !(orig_file_len < ext_max || (ext_max == Xof_rule_itm.Max_wildcard && orig_file_len < 1));
|
||||
}
|
||||
boolean Img_download(String src_str, Io_url trg_url, boolean cur_is_thumb) {
|
||||
rslt.Atrs_src_trg_(src_str, trg_url); // NOTE: must be set at start; Img_rename_by_size may overwrite trg
|
||||
@@ -324,7 +327,7 @@ public class Xof_xfer_mgr {
|
||||
if (exists)
|
||||
pass = true;
|
||||
else {
|
||||
byte download_rslt = file_mgr.Download_mgr().Download_wkr().Download(src_repo_is_wmf, src_str, trg_url, file_mgr.Download_mgr().Download_wkr().Download_xrg().Prog_fmt_hdr());
|
||||
byte download_rslt = wmf_mgr.Download_wkr().Download(src_repo_is_wmf, src_str, trg_url, wmf_mgr.Download_wkr().Download_xrg().Prog_fmt_hdr());
|
||||
if (download_rslt == gplx.ios.IoEngine_xrg_downloadFil.Rslt_fail_host_not_found) {
|
||||
wiki.File_mgr().Cfg_download().Enabled_(false);
|
||||
throw Err_mgr._.fmt_("xowa.xfer_mgr", "download_failed", "download_failed: host not found");
|
||||
|
||||
@@ -34,22 +34,22 @@ public class Xof_xfer_queue {
|
||||
if (!dirty.Has(dirty_key.Val_(meta_mgr_key)))
|
||||
dirty.AddReplace(meta_mgr_key, meta_mgr); // only add if new
|
||||
}
|
||||
public void Exec(byte exec_tid, Gfo_usr_dlg wtr, Xow_wiki wiki, Xoa_page page) {
|
||||
public void Exec(byte exec_tid, Gfo_usr_dlg wtr, Xowe_wiki wiki, Xoae_page page) {
|
||||
if (wiki.File_mgr().Version() == Xow_file_mgr.Version_2)
|
||||
Exec_v2(exec_tid, wtr, wiki, page);
|
||||
else
|
||||
Exec_v1(exec_tid, wtr, wiki, page);
|
||||
}
|
||||
private void Exec_v1(byte exec_tid, Gfo_usr_dlg wtr, Xow_wiki wiki, Xoa_page page) {
|
||||
private void Exec_v1(byte exec_tid, Gfo_usr_dlg wtr, Xowe_wiki wiki, Xoae_page page) {
|
||||
Xof_meta_mgr meta_mgr = null;
|
||||
int xfer_len = list.Count();
|
||||
for (int i = 0; i < xfer_len; i++) {
|
||||
if (wiki.App().Gui_wtr().Canceled()) break;
|
||||
if (wiki.Appe().Usr_dlg().Canceled()) break;
|
||||
Xof_xfer_itm xfer_itm = (Xof_xfer_itm)list.FetchAt(i);
|
||||
meta_mgr = xfer_itm.Meta_itm().Owner_fil().Owner_mgr();
|
||||
Add_dirty_if_new(meta_mgr); // only add if new
|
||||
String queue_msg = wtr.Prog_many(GRP_KEY, "download.bgn", "downloading ~{0} of ~{1}: ~{2};", i + ListAdp_.Base1, xfer_len, xfer_itm.Lnki_ttl());
|
||||
wiki.App().File_mgr().Download_mgr().Download_wkr().Download_xrg().Prog_fmt_hdr_(queue_msg);
|
||||
wiki.App().Wmf_mgr().Download_wkr().Download_xrg().Prog_fmt_hdr_(queue_msg);
|
||||
wiki.File_mgr().Repo_mgr().Xfer_by_meta(xfer_itm, this);
|
||||
xfer_itm.Set__meta(xfer_itm.Meta_itm(), xfer_itm.Meta_itm().Repo_itm(wiki), wiki.Html_mgr().Img_thumb_width());
|
||||
xfer_itm.Calc_by_meta();
|
||||
@@ -65,9 +65,9 @@ public class Xof_xfer_queue {
|
||||
}
|
||||
this.Clear();
|
||||
}
|
||||
private void Exec_v2(byte exec_tid, Gfo_usr_dlg wtr, Xow_wiki wiki, Xoa_page page) {
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki__add_bin_wkrs(wiki);
|
||||
wiki.File_mgr().Fsdb_mgr().Fsdb_search_by_list(page, exec_tid, Xfer_itms_to_fsdb_itms(list, wiki.File_mgr().Fsdb_mgr().Patch_upright()));
|
||||
private void Exec_v2(byte exec_tid, Gfo_usr_dlg wtr, Xowe_wiki wiki, Xoae_page page) {
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki(wiki);
|
||||
wiki.File_mgr().Fsdb_mgr().Fsdb_search_by_list(exec_tid, Xfer_itms_to_fsdb_itms(list, wiki.File_mgr().Patch_upright()), page);
|
||||
}
|
||||
private ListAdp Xfer_itms_to_fsdb_itms(ListAdp list, int upright_patch) {
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
@@ -75,7 +75,7 @@ public class Xof_xfer_queue {
|
||||
for (int i = 0; i < list_len; i++) {
|
||||
Xof_xfer_itm xfer_itm = (Xof_xfer_itm)list.FetchAt(i);
|
||||
Xof_fsdb_itm fsdb_itm = new Xof_fsdb_itm();
|
||||
fsdb_itm.Init_by_lnki(xfer_itm.Lnki_ttl(), xfer_itm.Lnki_ext(), xfer_itm.Lnki_md5(), xfer_itm.Lnki_type(), xfer_itm.Lnki_w(), xfer_itm.Lnki_h(), upright_patch, xfer_itm.Lnki_upright(), xfer_itm.Lnki_thumbtime(), xfer_itm.Lnki_page());
|
||||
fsdb_itm.Ctor_by_lnki(xfer_itm.Lnki_ttl(), xfer_itm.Lnki_ext(), xfer_itm.Lnki_md5(), xfer_itm.Lnki_type(), xfer_itm.Lnki_w(), xfer_itm.Lnki_h(), upright_patch, xfer_itm.Lnki_upright(), xfer_itm.Lnki_thumbtime(), xfer_itm.Lnki_page());
|
||||
fsdb_itm.Html_uid_(xfer_itm.Html_uid());
|
||||
fsdb_itm.Html_elem_tid_(xfer_itm.Html_elem_tid());
|
||||
fsdb_itm.Gallery_mgr_h_(xfer_itm.Gallery_mgr_h());
|
||||
|
||||
@@ -16,34 +16,35 @@ 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.ios.*; import gplx.xowa.files.cnvs.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.*; import gplx.xowa.files.cnvs.*; import gplx.xowa.files.repos.*;
|
||||
import gplx.xowa.wmfs.apis.*; import gplx.xowa.files.exts.*; import gplx.xowa.files.imgs.*;
|
||||
public class Xof_xfer_queue_base_fxt {
|
||||
public Xof_img_wkr_api_size_base_mok Api_size() {return api_size;} private Xof_img_wkr_api_size_base_mok api_size = Xof_img_wkr_api_size_base_mok._;
|
||||
public Xoapi_orig_mok Api_size() {return api_size;} private Xoapi_orig_mok api_size = Xoapi_orig_mok._;
|
||||
public Xof_repo_itm Src_commons_repo() {return src_commons_repo;} private Xof_repo_itm src_commons_repo;
|
||||
public Xof_repo_itm Src_en_wiki_repo() {return src_en_wiki_repo;} private Xof_repo_itm src_en_wiki_repo;
|
||||
@gplx.Virtual public void Clear(boolean src_repo_is_wmf) {
|
||||
Io_mgr._.InitEngine_mem();
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
en_wiki = Xoa_app_fxt.wiki_(app, Xow_wiki_.Domain_enwiki_str);
|
||||
commons = Xoa_app_fxt.wiki_(app, Xow_wiki_.Domain_commons_str);
|
||||
en_wiki = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_enwiki);
|
||||
commons = Xoa_app_fxt.wiki_(app, Xow_domain_.Domain_str_commons);
|
||||
app.Wiki_mgr().Add(commons);
|
||||
app.Wiki_mgr().Add(en_wiki);
|
||||
|
||||
Xof_file_mgr file_mgr = app.File_mgr();
|
||||
file_mgr.Img_mgr().Wkr_resize_img_(Xof_img_wkr_resize_img_mok._);
|
||||
file_mgr.Img_mgr().Wkr_query_img_size_(new Xof_img_wkr_query_img_size_test());
|
||||
file_mgr.Download_mgr().Api_size_wkr_(api_size);
|
||||
app.Wmf_mgr().Api_mgr().Api_orig_(api_size);
|
||||
|
||||
byte[] src_commons = Bry_.new_ascii_("src_commons");
|
||||
byte[] src_en_wiki = Bry_.new_ascii_("src_en_wiki");
|
||||
byte[] trg_commons = Bry_.new_ascii_("trg_commons");
|
||||
byte[] trg_en_wiki = Bry_.new_ascii_("trg_en_wiki");
|
||||
src_commons_repo = Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_wiki_.Domain_commons_str, false);
|
||||
src_en_wiki_repo = Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/" , Xow_wiki_.Domain_enwiki_str, false);
|
||||
Ini_repo_add(file_mgr, trg_commons, "mem/trg/commons.wikimedia.org/", Xow_wiki_.Domain_commons_str, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, trg_en_wiki, "mem/trg/en.wikipedia.org/" , Xow_wiki_.Domain_enwiki_str, true).Primary_(true);
|
||||
Xow_repo_mgr wiki_repo_mgr = en_wiki.File_mgr().Repo_mgr();
|
||||
src_commons_repo = Ini_repo_add(file_mgr, src_commons, "mem/src/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, false);
|
||||
src_en_wiki_repo = Ini_repo_add(file_mgr, src_en_wiki, "mem/src/en.wikipedia.org/" , Xow_domain_.Domain_str_enwiki, false);
|
||||
Ini_repo_add(file_mgr, trg_commons, "mem/trg/commons.wikimedia.org/", Xow_domain_.Domain_str_commons, true).Primary_(true);
|
||||
Ini_repo_add(file_mgr, trg_en_wiki, "mem/trg/en.wikipedia.org/" , Xow_domain_.Domain_str_enwiki, true).Primary_(true);
|
||||
Xowe_repo_mgr wiki_repo_mgr = en_wiki.File_mgr().Repo_mgr();
|
||||
Xof_repo_pair pair = null;
|
||||
pair = wiki_repo_mgr.Add_repo(src_commons, trg_commons);
|
||||
pair.Src().Fsys_is_wnt_(true).Wmf_fsys_(src_repo_is_wmf).Tarball_(!src_repo_is_wmf);
|
||||
@@ -59,20 +60,20 @@ public class Xof_xfer_queue_base_fxt {
|
||||
html_src = null;
|
||||
html_w = html_h = -1;
|
||||
}
|
||||
public Xoa_app App() {return app;} private Xoa_app app;
|
||||
public Xow_wiki En_wiki() {return en_wiki;} private Xow_wiki en_wiki;
|
||||
public Xow_wiki Commons() {return commons;} private Xow_wiki commons;
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
public Xowe_wiki En_wiki() {return en_wiki;} private Xowe_wiki en_wiki;
|
||||
public Xowe_wiki Commons() {return commons;} private Xowe_wiki commons;
|
||||
public void ini_page_create_commons(String ttl) {Init_page_create(commons, ttl, "");}
|
||||
public void ini_page_create_commons_redirect(String ttl, String redirect) {Init_page_create(commons, ttl, "#REDIRECT [[" + redirect + "]]");}
|
||||
public void ini_page_create_en_wiki(String ttl) {Init_page_create(en_wiki, ttl, "");}
|
||||
public void ini_page_create_en_wiki_redirect(String ttl, String redirect) {Init_page_create(en_wiki, ttl, "#REDIRECT [[" + redirect + "]]");}
|
||||
public void Init_page_create(Xow_wiki wiki, String ttl, String txt) {
|
||||
public void Init_page_create(Xowe_wiki wiki, String ttl, String txt) {
|
||||
Xoa_ttl page_ttl = Xoa_ttl.parse_(wiki, Bry_.new_utf8_(ttl));
|
||||
byte[] page_raw = Bry_.new_utf8_(txt);
|
||||
wiki.Db_mgr().Save_mgr().Data_create(page_ttl, page_raw);
|
||||
}
|
||||
Xof_repo_itm Ini_repo_add(Xof_file_mgr file_mgr, byte[] key, String root, String wiki, boolean trg) {
|
||||
Xof_repo_itm repo = file_mgr.Repo_mgr().Set(String_.new_utf8_(key), root, wiki).Ext_rules_(Xoft_rule_grp.Grp_app_default).Dir_depth_(2);
|
||||
Xof_repo_itm repo = file_mgr.Repo_mgr().Set(String_.new_utf8_(key), root, wiki).Ext_rules_(Xof_rule_grp.Grp_app_default).Dir_depth_(2);
|
||||
if (trg) {
|
||||
byte[][] ary = repo.Mode_names();
|
||||
ary[0] = Bry_.new_ascii_("raw");
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.imgs.*;
|
||||
public class Xof_xfer_queue_html_cases_tst {
|
||||
Xof_xfer_queue_html_fxt fxt = new Xof_xfer_queue_html_fxt();
|
||||
@Before public void init() {
|
||||
@@ -73,7 +73,7 @@ public class Xof_xfer_queue_html_cases_tst {
|
||||
}
|
||||
@Test public void Img_thumb_djvu() {// PURPOSE: exact djvu thumbs are not on server; always seems to retrieve 1 off;
|
||||
fxt .ini_page_create_commons ("File:A.djvu");
|
||||
fxt .App().File_mgr().Img_mgr().Wkr_convert_djvu_to_tiff_(new Xof_img_wkr_convert_djvu_to_tiff_mok(199, 299));
|
||||
fxt .App().File_mgr().Img_mgr().Wkr_convert_djvu_to_tiff_(Xof_img_wkr_convert_djvu_to_tiff_.new_mok(199, 299));
|
||||
fxt .Lnki_thumb_("A.djvu", 200)
|
||||
.Src( fxt.img_("mem/src/commons.wikimedia.org/7/76/A.djvu", 1990, 2990)
|
||||
)
|
||||
|
||||
@@ -16,10 +16,11 @@ 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.core.primitives.*;
|
||||
import gplx.ios.*; import gplx.xowa.files.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.*;
|
||||
import gplx.ios.*; import gplx.xowa.wikis.*; import gplx.xowa.files.*;
|
||||
public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
@Override public void Clear(boolean src_repo_is_wmf) {
|
||||
Db_conn_bldr.I.Reg_default_mem();
|
||||
super.Clear(src_repo_is_wmf);
|
||||
this.Api_size().Clear();
|
||||
}
|
||||
@@ -27,7 +28,7 @@ public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
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_doc_thumb.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_doc_thumb.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
|
||||
Xow_wiki wiki = this.En_wiki();
|
||||
Xowe_wiki wiki = this.En_wiki();
|
||||
xfer_itm = wiki.Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(wiki.Ctx(), queue, Bry_.new_utf8_(lnki_ttl), thumb ? Xop_lnki_type.Id_thumb : Xop_lnki_type.Id_null, lnki_w, lnki_h, upright, Xof_doc_thumb.X_int(seek_time), Xof_doc_page.Null, false, queue_add_ref);
|
||||
return this;
|
||||
} private Xof_xfer_itm xfer_itm = new Xof_xfer_itm(); Bool_obj_ref queue_add_ref = Bool_obj_ref.n_();
|
||||
@@ -40,16 +41,16 @@ public class Xof_xfer_queue_html_fxt extends Xof_xfer_queue_base_fxt {
|
||||
public Xof_xfer_queue_html_fxt Html_orig_src_(String v) {html_orig_src = v; return this;} private String html_orig_src;
|
||||
public Xof_xfer_queue_html_fxt ini_page_api(String wiki_str, String ttl_str, String redirect_str, int orig_w, int orig_h) {return ini_page_api(wiki_str, ttl_str, redirect_str, orig_w, orig_h, true);}
|
||||
public Xof_xfer_queue_html_fxt ini_page_api(String wiki_str, String ttl_str, String redirect_str, int orig_w, int orig_h, boolean pass) {
|
||||
String wiki_key = String_.Eq(wiki_str, "commons") ? Xow_wiki_.Domain_commons_str : Xow_wiki_.Domain_enwiki_str;
|
||||
String wiki_key = String_.Eq(wiki_str, "commons") ? Xow_domain_.Domain_str_commons : Xow_domain_.Domain_str_enwiki;
|
||||
this.Api_size().Ini(wiki_key, ttl_str, redirect_str, orig_w, orig_h, pass);
|
||||
return this;
|
||||
}
|
||||
@gplx.Virtual public void tst() {
|
||||
Xow_wiki wiki = this.En_wiki();
|
||||
Xowe_wiki wiki = this.En_wiki();
|
||||
ini_src_fils();
|
||||
wiki.App().File_mgr().Download_mgr().Enabled_(true);
|
||||
wiki.Appe().File_mgr().Wmf_mgr().Enabled_(true);
|
||||
wiki.File_mgr().Cfg_download().Enabled_(true);
|
||||
queue.Exec(Xof_exec_tid.Tid_wiki_page, usr_dlg, wiki, Xoa_page.Empty);
|
||||
queue.Exec(Xof_exec_tid.Tid_wiki_page, usr_dlg, wiki, Xoae_page.Empty);
|
||||
tst_trg_fils();
|
||||
if (this.html_orig_src != null) Tfds.Eq(this.html_orig_src , String_.new_utf8_(xfer_itm.Html_orig_src()));
|
||||
if (this.Html_view_src() != null) Tfds.Eq(this.Html_view_src(), String_.new_utf8_(xfer_itm.Html_view_src()));
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.files.*;
|
||||
public class Xof_xfer_queue_html_wmf_api_tst {
|
||||
Xof_xfer_queue_html_fxt fxt = new Xof_xfer_queue_html_fxt();
|
||||
private final Xof_xfer_queue_html_fxt fxt = new Xof_xfer_queue_html_fxt();
|
||||
@Before public void init() {fxt.Clear(true); fxt.Src_commons_repo().Wmf_api_(true); fxt.Src_en_wiki_repo().Wmf_api_(true);}
|
||||
@Test public void Thumb() {
|
||||
fxt .ini_page_api("en_wiki", "A.png", "", 2200, 2000);
|
||||
|
||||
@@ -1,241 +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; import gplx.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.files.*;
|
||||
public class Xow_repo_mgr implements GfoInvkAble {
|
||||
public Xow_repo_mgr(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
Xoa_app app = wiki.App();
|
||||
xfer_mgr = new Xof_xfer_mgr(app.File_mgr());
|
||||
page_finder = new Xofw_wiki_wkr_base(wiki, app.Wiki_mgr());
|
||||
} private Xow_wiki wiki;
|
||||
public Xof_xfer_mgr Xfer_mgr() {return xfer_mgr;} private Xof_xfer_mgr xfer_mgr;
|
||||
public Xofw_wiki_finder Page_finder() {return page_finder;} public Xow_repo_mgr Page_finder_(Xofw_wiki_finder v) {page_finder = v; return this;} private Xofw_wiki_finder page_finder;
|
||||
public int Repos_len() {return repos.Count();} ListAdp repos = ListAdp_.new_();
|
||||
public Xof_repo_pair Repos_get_by_wiki(byte[] wiki) {
|
||||
int len = repos.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xof_repo_pair pair = (Xof_repo_pair)repos.FetchAt(i);
|
||||
if (Bry_.Eq(wiki, pair.Wiki_key()))
|
||||
return pair;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Xof_repo_pair Repos_get_at(int i) {return (Xof_repo_pair)repos.FetchAt(i);}
|
||||
public Xof_repo_pair Repos_get_by_id(int id) {
|
||||
int len = repos.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xof_repo_pair pair = (Xof_repo_pair)repos.FetchAt(i);
|
||||
if (pair.Repo_id() == id) return pair;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public boolean Xfer_by_meta(Xof_xfer_itm xfer_itm, Xof_xfer_queue queue) {
|
||||
byte[] ttl = xfer_itm.Lnki_ttl();
|
||||
Xof_meta_itm meta_itm = xfer_itm.Meta_itm();
|
||||
boolean chk_all = false;
|
||||
byte[] src_wiki_key = wiki.Domain_bry();
|
||||
if (meta_itm.State_new()) {
|
||||
byte rslt = Xfer_by_meta__find_file(ttl, meta_itm, wiki.Domain_bry());
|
||||
switch (rslt) {
|
||||
case Xof_meta_itm.Tid_null: xfer_itm.Trg_repo_idx_(0); chk_all = true; break; // NOTE: src_wiki_key becomes wiki.Key_bry() for sake of simplicity
|
||||
case Xof_meta_itm.Tid_main: xfer_itm.Trg_repo_idx_(Xof_meta_itm.Repo_same); break;
|
||||
case Xof_meta_itm.Tid_ptr: src_wiki_key = Xfer_by_meta__find_main_ptr(meta_itm, xfer_itm); break;
|
||||
case Xof_meta_itm.Tid_vrtl: src_wiki_key = Xfer_by_meta__find_main_vrtl(meta_itm, xfer_itm); break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Xof_repo_itm src_repo = meta_itm.Repo_itm(wiki);
|
||||
src_wiki_key = src_repo.Wiki_key();
|
||||
xfer_itm.Trg_repo_idx_(meta_itm.Vrtl_repo()); // NOTE: set trg_repo_idx b/c xfer_mgr will always set meta_itm.Vrtl_repo() with trg_repo_idx
|
||||
}
|
||||
if (meta_itm.Ptr_ttl_exists())
|
||||
xfer_itm.Set__ttl(meta_itm.Ttl(), meta_itm.Ptr_ttl());
|
||||
boolean main_exists_unknown = src_wiki_key == null; // WORKAROUND/HACK: SEE:NOTE_1:reset_main_exists
|
||||
boolean rv = Xfer_by_meta__exec(chk_all, xfer_itm, meta_itm, src_wiki_key, queue, false);
|
||||
if (!rv && (!chk_all && !main_exists_unknown)) { // xfer failed even with page found in wiki; try again, but chk all
|
||||
rv = Xfer_by_meta__exec(true, xfer_itm, meta_itm, src_wiki_key, queue, true);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
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_xfer_itm_.Md5_(redirect);
|
||||
while (true) {
|
||||
boolean found = page_finder.Locate(tmp_rslt, repos, redirect);
|
||||
if (!found) return null;
|
||||
Xow_wiki trg_wiki = wiki;
|
||||
int repo_idx = tmp_rslt.Repo_idx();
|
||||
byte[] trg_wiki_key = Bry_.Empty;
|
||||
if (repo_idx != Xof_meta_itm.Repo_unknown) {
|
||||
trg_wiki_key = wiki.File_mgr().Repo_mgr().Repos_get_at(repo_idx).Wiki_key();
|
||||
trg_wiki = wiki.App().Wiki_mgr().Get_by_key_or_make(trg_wiki_key);
|
||||
}
|
||||
Xof_meta_itm redirect_meta = trg_wiki.File_mgr().Meta_mgr().Get_itm_or_new(redirect, md5);
|
||||
if (tmp_rslt.Redirect() == Xop_redirect_mgr.Redirect_null_bry) {
|
||||
if (redirect_meta.State_new()) {
|
||||
if (repo_idx == Xof_meta_itm.Repo_unknown) {
|
||||
// meta_itm.Vrtl_repo_(Xof_meta_itm.Repo_same);
|
||||
xfer_itm.Trg_repo_idx_(Xof_meta_itm.Repo_same);
|
||||
}
|
||||
else {
|
||||
if (!Bry_.Eq(trg_wiki_key, wiki.Domain_bry())) {
|
||||
// meta_itm.Vrtl_repo_(tmp_rslt.Repo_idx());
|
||||
xfer_itm.Trg_repo_idx_(tmp_rslt.Repo_idx());
|
||||
}
|
||||
else {
|
||||
// meta_itm.Vrtl_repo_(Xof_meta_itm.Repo_same);
|
||||
xfer_itm.Trg_repo_idx_(Xof_meta_itm.Repo_same);
|
||||
}
|
||||
}
|
||||
}
|
||||
return trg_wiki_key;
|
||||
}
|
||||
redirect = tmp_rslt.Redirect();
|
||||
if (++redirect_tries > Xop_redirect_mgr.Redirect_max_allowed) return null;
|
||||
}
|
||||
}
|
||||
byte[] Xfer_by_meta__find_main_vrtl(Xof_meta_itm meta_itm, Xof_xfer_itm xfer_itm) {
|
||||
int repo_idx = meta_itm.Vrtl_repo();
|
||||
if (repo_idx == Xof_meta_itm.Repo_unknown) return null;;
|
||||
Xof_repo_itm trg_repo = wiki.File_mgr().Repo_mgr().Repos_get_at(repo_idx).Trg();
|
||||
xfer_itm.Trg_repo_idx_(repo_idx);
|
||||
return trg_repo.Wiki_key();
|
||||
}
|
||||
boolean Xfer_by_meta__exec(boolean chk_all, Xof_xfer_itm xfer_itm, Xof_meta_itm meta_itm, byte[] main_wiki_key, Xof_xfer_queue queue, boolean second_chance) {
|
||||
int repos_len = repos.Count();
|
||||
for (int i = 0; i < repos_len; i++) { // iterate over all repo pairs
|
||||
Xof_repo_pair pair = (Xof_repo_pair)repos.FetchAt(i);
|
||||
Xof_repo_itm pair_src = pair.Src();
|
||||
boolean main_wiki_key_is_pair_src = Bry_.Eq(main_wiki_key, pair_src.Wiki_key());
|
||||
if ( (chk_all && !main_wiki_key_is_pair_src) // only do chk_all if main_wiki is not pair_src; note that chk_all will only be called in two ways (1) with main_wiki_key as null; (2) with main_key_as val
|
||||
|| (!chk_all && main_wiki_key_is_pair_src)) { // pair.Src.Wiki == main.Wiki; note that there can be multiple pairs with same src; EX: have 2 pairs for commons: one for file and another for http
|
||||
xfer_mgr.Atrs_by_itm(xfer_itm, pair_src, pair.Trg());
|
||||
boolean make = xfer_mgr.Make_file(wiki);
|
||||
if (make) {
|
||||
xfer_itm.Trg_repo_(pair.Trg());
|
||||
if (second_chance && xfer_itm.Meta_itm().Vrtl_repo() == 0) // second_chance and item found; change vrtl_repo from commons back to same; EX: tarball and [[Image:Rembrandt De aartsengel verlaat Tobias en zijn gezin. 1637.jpg|120px]]
|
||||
xfer_itm.Meta_itm().Vrtl_repo_(Xof_meta_itm.Repo_same);
|
||||
return true; // file was made; return; if not continue looking at other repos
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public Xofw_file_finder_rslt Page_finder_locate(byte[] ttl_bry) {page_finder.Locate(tmp_rslt, repos, ttl_bry); return tmp_rslt;}
|
||||
byte Xfer_by_meta__find_file(byte[] ttl_bry, Xof_meta_itm meta_itm, byte[] cur_wiki_key) {
|
||||
byte new_tid = Byte_.Max_value_127;
|
||||
boolean found = page_finder.Locate(tmp_rslt, repos, ttl_bry);
|
||||
if (found) {
|
||||
if (Bry_.Eq(cur_wiki_key, tmp_rslt.Repo_wiki_key())) { // itm is in same repo as cur wiki
|
||||
new_tid = Xof_meta_itm.Tid_main;
|
||||
byte[] redirect = tmp_rslt.Redirect();
|
||||
if (redirect != Xop_redirect_mgr.Redirect_null_bry) { // redirect found
|
||||
meta_itm.Ptr_ttl_(redirect);
|
||||
}
|
||||
meta_itm.Vrtl_repo_(Xof_meta_itm.Repo_same);
|
||||
}
|
||||
else { // itm is in diff repo
|
||||
new_tid = Xof_meta_itm.Tid_vrtl;
|
||||
meta_itm.Vrtl_repo_(tmp_rslt.Repo_idx());
|
||||
meta_itm.Ptr_ttl_(tmp_rslt.Redirect());
|
||||
}
|
||||
}
|
||||
else { // itm not found; has to be vrtl, but mark repo as unknown
|
||||
meta_itm.Vrtl_repo_(Xof_meta_itm.Repo_unknown);
|
||||
}
|
||||
return new_tid;
|
||||
} private Xofw_file_finder_rslt tmp_rslt = new Xofw_file_finder_rslt();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_add)) return Add_repo(m.ReadBry("src"), m.ReadBry("trg"));
|
||||
else if (ctx.Match(k, Invk_clear)) repos.Clear();
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_add = "add", Invk_clear = "clear";
|
||||
public Xof_repo_pair Add_repo(byte[] src_repo_key, byte[] trg_repo_key) {
|
||||
Xof_meta_mgr trg_meta = wiki.File_mgr().Meta_mgr();
|
||||
Xoa_repo_mgr repo_mgr = wiki.App().File_mgr().Repo_mgr();
|
||||
Xof_repo_itm src_repo = repo_mgr.Get_by(src_repo_key), trg_repo = repo_mgr.Get_by(trg_repo_key);
|
||||
byte[] src_wiki_key = src_repo.Wiki_key(), trg_wiki_key = trg_repo.Wiki_key();
|
||||
if (!Bry_.Eq(src_wiki_key, trg_wiki_key) && !Bry_.Eq(src_wiki_key, Xow_wiki_domain_.Key_home_bry)) throw Err_mgr._.fmt_(GRP_KEY, "add_repo", "wiki keys do not match: ~{0} ~{1}", String_.new_utf8_(src_wiki_key), String_.new_utf8_(trg_wiki_key));
|
||||
Xof_repo_pair pair = new Xof_repo_pair(repos.Count(), src_repo, trg_repo, trg_meta, src_wiki_key);
|
||||
repos.Add(pair);
|
||||
return pair;
|
||||
}
|
||||
public boolean Xfer_file(Xof_xfer_itm file) {
|
||||
int repo_idx = file.Trg_repo_idx();
|
||||
boolean wiki_is_unknown = repo_idx == Xof_meta_itm.Repo_unknown;
|
||||
boolean make_pass = false;
|
||||
int len = repos.Count();
|
||||
if (!wiki_is_unknown) make_pass = Xfer_file_exec(file, this.Repos_get_at(repo_idx), repo_idx);
|
||||
if (make_pass) return true;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xof_repo_pair pair = (Xof_repo_pair)repos.FetchAt(i);
|
||||
if (i != repo_idx) { // try other wikis
|
||||
file.Meta_itm().Orig_exists_(Xof_meta_itm.Exists_unknown); // always reset orig exists; this may have been flagged to missing above and should be cleared
|
||||
make_pass = Xfer_file_exec(file, pair, i);
|
||||
if (make_pass) break;
|
||||
}
|
||||
}
|
||||
return make_pass;
|
||||
}
|
||||
private boolean Xfer_file_exec(Xof_xfer_itm file, Xof_repo_pair pair, int repo_idx) {
|
||||
xfer_mgr.Atrs_by_itm(file, pair.Src(), pair.Trg());
|
||||
Xof_meta_itm meta_itm = xfer_mgr.Meta_itm();
|
||||
boolean rv = xfer_mgr.Make_file(wiki);
|
||||
if (rv) {
|
||||
meta_itm.Vrtl_repo_(repo_idx); // update repo_idx to whatever is found
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final String GRP_KEY = "Xow_repo_mgr";
|
||||
}
|
||||
/*
|
||||
NOTE_1:reset_main_exists
|
||||
this is primarily for Img_missing_wiki_1 and [[Image:Alcott-L.jpg|thumb|right|Louisa May Alcott]]
|
||||
first some details:
|
||||
. file pages exist in both en_wiki and in commons_wiki; w:File:Alcott-L.jpg; c:File:Alcott-L.jpg
|
||||
. images are slightly different (w: is darker than c:)
|
||||
. c was recently updated to redirect to File:Louisa May Alcott (1881 illustration).jpg
|
||||
|
||||
the actual effect:
|
||||
. [[Image:Alcott-L.jpg|thumb|right|Louisa May Alcott]] in en.wikipedia should pull the w: one (not the c:) one
|
||||
. this behavior seems contrary to all other wiki behavior where c: is given primacy over w:
|
||||
.. EX: [[File:Tanks of WWI.ogg|thumb|thumbtime=12|alt=Primitive]] exists in both en_wiki and in commons, but the file only exists in commons
|
||||
. moreover this page has a special note about the image deliberately remainining in en_wiki
|
||||
|
||||
the workaround/hack (described via intended sequence):
|
||||
1: commons is defined as first repo_pair
|
||||
2: image found in commons page (note that en_wiki is not checked for PERF reasons)
|
||||
3: image is searched for in commons, but not found; note that both thumb and orig are missing
|
||||
4: image will be searched for in en_wiki and found
|
||||
|
||||
note that (4) however reuses the same meta which is marked as "not found" from the commons attempt
|
||||
. item will then have orig marked falsely as not-found
|
||||
|
||||
one approach would be to create a new meta and send that into the chk_all function. this turned out to be problematic
|
||||
|
||||
so, the workaround:
|
||||
if going into chk_all
|
||||
...and orig was previous unknown
|
||||
...but is now marked no
|
||||
then reset to unknown to give it a "clean" slate for the chk all
|
||||
|
||||
in theory, the above statement seems fine, but it does seem hackish...
|
||||
*/
|
||||
Reference in New Issue
Block a user