mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Custom_wiki: Open up file in image viewer when clicking on pages in File namespace
This commit is contained in:
parent
ac13d00ef8
commit
9c700e4b34
@ -51,6 +51,7 @@ public interface Xof_file_itm {
|
||||
int Hdump_mode();
|
||||
|
||||
void File_exists_(boolean v);
|
||||
void Html_orig_url_(Io_url v);
|
||||
void Html_img_wkr_(Js_img_wkr v);
|
||||
void Html_elem_tid_(byte v);
|
||||
void Html_size_(int w, int h);
|
||||
|
@ -73,6 +73,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
public int Hdump_mode() {return hdump_mode;} private int hdump_mode = Xof_fsdb_itm.Hdump_mode__null;
|
||||
|
||||
public void File_exists_y_() {file_exists = Bool_.Y;} public void File_exists_n_() {file_exists = Bool_.N;} public void File_exists_(boolean v) {file_exists = v;}
|
||||
public void Html_orig_url_(Io_url v) {html_orig_url = v;}
|
||||
public void Init_at_lnki(int exec_tid, byte[] wiki_abrv, byte[] ttl, byte lnki_type, double upright, int w, int h, double time, int page, int lnki_upright_patch) {
|
||||
this.lnki_exec_tid = exec_tid; this.lnki_wiki_abrv = wiki_abrv;
|
||||
this.lnki_type = lnki_type; this.lnki_upright = upright; this.lnki_w = w; this.lnki_h = h; this.lnki_time = time; this.lnki_page = page;
|
||||
|
@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files.fsdb; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
public interface Xof_fsdb_mgr {
|
||||
String Key();
|
||||
gplx.xowa.files.bins.Xof_bin_mgr Bin_mgr();
|
||||
gplx.fsdb.meta.Fsm_mnt_mgr Mnt_mgr();
|
||||
void Init_by_wiki(Xow_wiki wiki);
|
||||
|
@ -24,6 +24,7 @@ import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files
|
||||
public class Xof_fsdb_mgr__sql implements Xof_fsdb_mgr, Gfo_invk {
|
||||
private boolean init = false; private boolean fsdb_enabled = false;
|
||||
private Xow_repo_mgr repo_mgr; private Xof_url_bldr url_bldr; private final Xof_img_size img_size = new Xof_img_size();
|
||||
public String Key() {return "fsdb.sql";}
|
||||
public Xof_bin_mgr Bin_mgr() {return bin_mgr;} private Xof_bin_mgr bin_mgr;
|
||||
public Fsm_mnt_mgr Mnt_mgr() {return mnt_mgr;} private Fsm_mnt_mgr mnt_mgr = new Fsm_mnt_mgr();
|
||||
public void Init_by_wiki(Xow_wiki wiki) {
|
||||
|
@ -24,11 +24,16 @@ public class Fs_root_core implements Xof_fsdb_mgr, Gfo_invk { // reads images fr
|
||||
this.Init_by_wiki(wiki);
|
||||
this.mgr = new Fs_root_mgr(wiki);
|
||||
}
|
||||
public String Key() {return Fsdb_mgr_key;}
|
||||
public gplx.xowa.files.bins.Xof_bin_mgr Bin_mgr() {throw Err_.new_unimplemented();}
|
||||
public gplx.fsdb.meta.Fsm_mnt_mgr Mnt_mgr() {return null;}
|
||||
public void Init_by_wiki(Xow_wiki wiki) {
|
||||
this.wiki = (Xowe_wiki)wiki;
|
||||
}
|
||||
public Io_url Get_orig_url_or_null(byte[] lnki_ttl) {
|
||||
Orig_fil_row rv = mgr.Wkr().Get_by_ttl(lnki_ttl);
|
||||
return rv == null ? null : rv.Url();
|
||||
}
|
||||
public void Fsdb_search_by_list(List_adp itms, Xow_wiki wiki, Xoa_page page, Xog_js_wkr js_wkr) {
|
||||
int itms_len = itms.Count();
|
||||
|
||||
@ -66,4 +71,5 @@ public class Fs_root_core implements Xof_fsdb_mgr, Gfo_invk { // reads images fr
|
||||
file_mgr.Orig_mgr().Wkrs__set(new Xof_orig_wkr__fs_root(rv.mgr.Wkr()));
|
||||
return rv;
|
||||
}
|
||||
public static final String Fsdb_mgr_key = "fs.dir";
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class Fs_root_wkr {
|
||||
int sub_dirs_len = sub_dirs.length;
|
||||
for (int i = 0; i < sub_dirs_len; i++) {
|
||||
Io_url sub_dir = sub_dirs[i];
|
||||
if (String_.Len(sub_dir.NameOnly()) != 1) continue; // only look at subdirs with 1 char; EX: "/orig_dir/a/" vs "/orig_dir/math/"
|
||||
// if (String_.Len(sub_dir.NameOnly()) != 1) continue; // only look at subdirs with 1 char; EX: "/orig_dir/a/" vs "/orig_dir/math/"
|
||||
|
||||
// loop over all fils in that 1-char dir
|
||||
Io_url[] fils = Io_mgr.Instance.QueryDir_args(sub_dir).Recur_(recurse).ExecAsUrlAry();
|
||||
|
@ -20,6 +20,7 @@ import gplx.core.primitives.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.xfers.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.files.fsdb.*; import gplx.xowa.files.fsdb.fs_roots.*;
|
||||
public class Xoh_ns_file_page_mgr implements gplx.core.brys.Bfr_arg {
|
||||
private Xoa_ttl ttl; private Xoh_file_page_wtr html_wtr; private final Xoh_file_page__other_resolutions alt_wtr = new Xoh_file_page__other_resolutions();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
@ -31,18 +32,35 @@ public class Xoh_ns_file_page_mgr implements gplx.core.brys.Bfr_arg {
|
||||
this.ttl = ttl; this.html_wtr = html_wtr; this.repo_mgr = wiki.File__repo_mgr();
|
||||
this.xfer_itm = wiki.Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(Xof_exec_tid.Tid_wiki_file, ctx, ctx.Page(), queue, ttl.Page_txt()
|
||||
, Xop_lnki_type.Id_thumb, Xop_lnki_tkn.Upright_null, html_wtr.Main_img_w(), html_wtr.Main_img_h(), Xof_lnki_time.Null, Xof_lnki_page.Null, Bool_.N);
|
||||
|
||||
// get orig
|
||||
Xof_orig_itm orig = wiki.File_mgr().Orig_mgr().Find_by_ttl_or_null(xfer_itm.Lnki_ttl());
|
||||
if (orig == Xof_orig_itm.Null) return; // no orig;
|
||||
Xof_repo_itm repo = wiki.File__repo_mgr().Get_trg_by_id_or_null(orig.Repo(), xfer_itm.Lnki_ttl(), Bry_.Empty);
|
||||
if (repo == null) return;
|
||||
xfer_itm.Init_at_orig(orig.Repo(), repo.Wiki_domain(), orig.Ttl(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
|
||||
xfer_itm.Init_at_html(Xof_exec_tid.Tid_wiki_file, img_size, repo, url_bldr);
|
||||
|
||||
// if non-wmf, point orig_url to fs_dir, not cache_dir; DATE:2017-02-01
|
||||
if (wiki.Domain_tid() == gplx.xowa.wikis.domains.Xow_domain_tid_.Tid__other) {
|
||||
Xof_fsdb_mgr fsdb_mgr = cur_wiki.File_mgr().Fsdb_mgr();
|
||||
if (String_.Eq(fsdb_mgr.Key(), Fs_root_core.Fsdb_mgr_key)) {
|
||||
Fs_root_core fs_dir_core = (Fs_root_core)fsdb_mgr;
|
||||
Io_url orig_url = fs_dir_core.Get_orig_url_or_null(xfer_itm.Lnki_ttl());
|
||||
if (orig_url != null)
|
||||
xfer_itm.Html_orig_url_(orig_url);
|
||||
}
|
||||
}
|
||||
|
||||
// get file size
|
||||
this.file_size_bry = Bry_.Empty;
|
||||
if (xfer_itm.File_exists()) { // file exists
|
||||
long file_size = Io_mgr.Instance.QueryFil(xfer_itm.Html_orig_url()).Size();
|
||||
if (file_size == -1) file_size = 0; // QueryFil returns -1 if file doesn't exist
|
||||
this.file_size_bry = Bry_.new_a7(gplx.core.ios.Io_size_.To_str(file_size));
|
||||
}
|
||||
|
||||
// get commons notice
|
||||
String commons_notice = page.Commons_mgr().Xowa_mockup()
|
||||
? String_.Format(Str_commons_notice, gplx.langs.htmls.Gfh_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, page.Ttl().Full_db_as_str()))
|
||||
: "";
|
||||
|
Loading…
Reference in New Issue
Block a user