mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v1.7.3.1
This commit is contained in:
@@ -31,7 +31,7 @@ public class Xoaf_download_mgr implements GfoInvkAble {
|
||||
public Xof_download_wkr Download_wkr() {return download_wkr;} public Xoaf_download_mgr Download_wkr_(Xof_download_wkr v) {download_wkr = v; return this;} private Xof_download_wkr download_wkr;
|
||||
public Xof_img_wkr_api_size_base Api_size_wkr() {return api_size_wkr;} public Xoaf_download_mgr Api_size_wkr_(Xof_img_wkr_api_size_base v) {api_size_wkr = v; return this;} private Xof_img_wkr_api_size_base api_size_wkr = new Xof_img_wkr_api_size_base_wmf();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.X_to_str(enabled);
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
|
||||
@@ -163,8 +163,8 @@ public class Xof_ext_ {
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public static boolean Id_is_video(int id) {return id == Xof_ext_.Id_ogv || id == Xof_ext_.Id_ogg || id == Xof_ext_.Id_webm;} // NOTE: ogg can be vid; EX.WP: Comet; Encke_tail_rip_off.ogg
|
||||
public static boolean Id_is_video_strict(int id) {return id == Xof_ext_.Id_ogv || id == Xof_ext_.Id_webm;} // NOTE: ogg can be aud / vid; EX.WP: Comet; Encke_tail_rip_off.ogg
|
||||
public static boolean Id_is_video(int id) {return id == Xof_ext_.Id_ogv || id == Xof_ext_.Id_ogg || id == Xof_ext_.Id_webm;} // NOTE: ogg can be vid; PAGE:en.w:Comet; Encke_tail_rip_off.ogg
|
||||
public static boolean Id_is_video_strict(int id) {return id == Xof_ext_.Id_ogv || id == Xof_ext_.Id_webm;} // NOTE: ogg can be aud / vid; PAGE:en.w:Comet; Encke_tail_rip_off.ogg
|
||||
public static boolean Id_is_audio_strict(int id) { // same as above, but deliberately exclude ambiguous ogg
|
||||
switch (id) {
|
||||
case Xof_ext_.Id_mid: case Xof_ext_.Id_oga: case Xof_ext_.Id_flac: return true;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Xof_repo_itm implements GfoInvkAble {
|
||||
root_url = App_cmd_arg.Val_as_url_rel_url_or(root_str, mgr.App().Fsys_mgr().File_dir(), Io_url_.new_dir_(root_str), true);
|
||||
root = root_url.RawBry();
|
||||
dir_spr = root_url.Info().DirSpr_byte();
|
||||
root_http = mgr.App().Url_converter_fsys().Encode_http(root_url);
|
||||
root_http = mgr.App().Encoder_mgr().Fsys().Encode_http(root_url);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Xof_url_bldr {
|
||||
if (wmf_protocol_is_file) // sitting on local file system (as opposed to http)
|
||||
bfr.Add(ttl); // NOTE: file_names are not url-encoded; this includes symbols (') and foreign characters (ö)
|
||||
else // wmf_http
|
||||
bfr.Add(encoder_src_http.Encode(ttl)); // NOTE: file_names must be url-encoded; JAVA will default to native charset which on Windows will be 1252; foreign character urls will fail due to conversion mismatch (1252 on windows; UTF-8 on WMF); EX.WP:Möbius strip
|
||||
bfr.Add(encoder_src_http.Encode(ttl)); // NOTE: file_names must be url-encoded; JAVA will default to native charset which on Windows will be 1252; foreign character urls will fail due to conversion mismatch (1252 on windows; UTF-8 on WMF); PAGE:en.w:Möbius strip
|
||||
}
|
||||
else
|
||||
bfr.Add(ttl); // add title; EX: "A.png"
|
||||
|
||||
@@ -51,7 +51,7 @@ class Xofo_lnki_parser extends Obj_ary_parser_base {
|
||||
private void Exec_val(Xofo_lnki lnki, int fld_idx, int eq_pos, byte[] bry, int fld_bgn, int i) {
|
||||
int fld_val = -1;
|
||||
if (fld_idx < 3) {
|
||||
fld_val = Bry_.X_to_int_or(bry, fld_bgn, i, Int_.MinValue);
|
||||
fld_val = Bry_.Xto_int_or(bry, fld_bgn, i, Int_.MinValue);
|
||||
if (fld_val == Int_.MinValue) throw Err_.new_fmt_("invalid int: {0}", String_.new_utf8_(bry, fld_bgn, i));
|
||||
switch (fld_idx) {
|
||||
case 0: lnki.Lnki_type_((byte)fld_val); break;
|
||||
@@ -66,7 +66,7 @@ class Xofo_lnki_parser extends Obj_ary_parser_base {
|
||||
lnki.Lnki_upright_(upright);
|
||||
}
|
||||
else if (Bry_.Match(bry, fld_bgn, eq_pos, Xop_lnki_arg_parser.Bry_thumbtime)) {
|
||||
fld_val = Bry_.X_to_int_or(bry, eq_pos + 1, i, Int_.MinValue); // +1 to position after eq
|
||||
fld_val = Bry_.Xto_int_or(bry, eq_pos + 1, i, Int_.MinValue); // +1 to position after eq
|
||||
if (fld_val == Int_.MinValue) throw Err_.new_fmt_("invalid int: {0}", String_.new_utf8_(bry, eq_pos + 1, i));
|
||||
lnki.Lnki_thumbtime_(Xof_doc_thumb.X_int(fld_val));
|
||||
}
|
||||
|
||||
@@ -21,29 +21,6 @@ public interface Xofw_wiki_finder {
|
||||
void Find(ListAdp repo_pairs, Xof_xfer_itm file);
|
||||
boolean Locate(Xofw_file_finder_rslt rv, ListAdp repo_pairs, byte[] ttl_bry);
|
||||
}
|
||||
class Xofw_wiki_wkr_mock implements Xofw_wiki_finder {
|
||||
int repo_idx; byte[] repo_wiki_key;
|
||||
public Xofw_wiki_wkr_mock Clear_en_wiki() {return Clear(1, Bry_en_wiki);}
|
||||
public Xofw_wiki_wkr_mock Clear_commons() {return Clear(0, Bry_commons);}
|
||||
Xofw_wiki_wkr_mock Clear(int repo_idx, byte[] repo_wiki_key) {
|
||||
this.repo_idx = repo_idx; this.repo_wiki_key = repo_wiki_key;
|
||||
if_ttl = then_redirect = Bry_.Empty;
|
||||
return this;
|
||||
} static final byte[] Bry_commons = Bry_.new_ascii_("commons.wikimedia.org"), Bry_en_wiki = Bry_.new_ascii_("en.wikipedia.org");
|
||||
public Xofw_wiki_wkr_mock Repo_idx_(int v) {this.repo_idx = v; return this;}
|
||||
public Xofw_wiki_wkr_mock Redirect_(String if_ttl_str, String then_redirect_str) {this.if_ttl = Bry_.new_utf8_(if_ttl_str); this.then_redirect = Bry_.new_utf8_(then_redirect_str); return this;} private byte[] if_ttl, then_redirect;
|
||||
public void Find(ListAdp repo_pairs, Xof_xfer_itm file) {
|
||||
byte[] ttl = file.Lnki_ttl();
|
||||
if (Bry_.Eq(ttl, if_ttl) && repo_idx != -1) {file.Atrs_by_ttl(ttl, then_redirect); file.Trg_repo_idx_(repo_idx);}
|
||||
else {file.Atrs_by_ttl(ttl, Bry_.Empty); file.Trg_repo_idx_(Xof_meta_itm.Repo_unknown);} // FUTURE: this should be missing, but haven't implemented unknown yet
|
||||
}
|
||||
public boolean Locate(Xofw_file_finder_rslt rv, ListAdp repo_pairs, byte[] ttl) {
|
||||
rv.Init(ttl);
|
||||
byte[] redirect = Bry_.Eq(ttl, if_ttl) ? then_redirect : null;
|
||||
rv.Done(repo_idx, repo_wiki_key, redirect);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
class Xofw_wiki_wkr_base implements Xofw_wiki_finder {
|
||||
public Xofw_wiki_wkr_base(Xow_wiki wiki, Xoa_wiki_mgr wiki_mgr) {this.wiki = wiki; this.wiki_mgr = wiki_mgr;} private Xow_wiki wiki; Xoa_wiki_mgr wiki_mgr;
|
||||
public void Find(ListAdp repo_pairs, Xof_xfer_itm file) {
|
||||
|
||||
42
400_xowa/src_160_file/gplx/xowa/Xofw_wiki_wkr_mock.java
Normal file
42
400_xowa/src_160_file/gplx/xowa/Xofw_wiki_wkr_mock.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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.files.*;
|
||||
public class Xofw_wiki_wkr_mock implements Xofw_wiki_finder {
|
||||
int repo_idx; byte[] repo_wiki_key;
|
||||
public Xofw_wiki_wkr_mock Clear_en_wiki() {return Clear(1, Bry_en_wiki);}
|
||||
public Xofw_wiki_wkr_mock Clear_commons() {return Clear(0, Bry_commons);}
|
||||
Xofw_wiki_wkr_mock Clear(int repo_idx, byte[] repo_wiki_key) {
|
||||
this.repo_idx = repo_idx; this.repo_wiki_key = repo_wiki_key;
|
||||
if_ttl = then_redirect = Bry_.Empty;
|
||||
return this;
|
||||
} static final byte[] Bry_commons = Bry_.new_ascii_("commons.wikimedia.org"), Bry_en_wiki = Bry_.new_ascii_("en.wikipedia.org");
|
||||
public Xofw_wiki_wkr_mock Repo_idx_(int v) {this.repo_idx = v; return this;}
|
||||
public Xofw_wiki_wkr_mock Redirect_(String if_ttl_str, String then_redirect_str) {this.if_ttl = Bry_.new_utf8_(if_ttl_str); this.then_redirect = Bry_.new_utf8_(then_redirect_str); return this;} private byte[] if_ttl, then_redirect;
|
||||
public void Find(ListAdp repo_pairs, Xof_xfer_itm file) {
|
||||
byte[] ttl = file.Lnki_ttl();
|
||||
if (Bry_.Eq(ttl, if_ttl) && repo_idx != -1) {file.Atrs_by_ttl(ttl, then_redirect); file.Trg_repo_idx_(repo_idx);}
|
||||
else {file.Atrs_by_ttl(ttl, Bry_.Empty); file.Trg_repo_idx_(Xof_meta_itm.Repo_unknown);} // FUTURE: this should be missing, but haven't implemented unknown yet
|
||||
}
|
||||
public boolean Locate(Xofw_file_finder_rslt rv, ListAdp repo_pairs, byte[] ttl) {
|
||||
rv.Init(ttl);
|
||||
byte[] redirect = Bry_.Eq(ttl, if_ttl) ? then_redirect : null;
|
||||
rv.Done(repo_idx, repo_wiki_key, redirect);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user