1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Parser:Add extra method overload to Log_file [#553]

This commit is contained in:
gnosygnu 2019-09-25 23:37:35 -04:00
parent b17cb05edf
commit 115ae8139e
6 changed files with 25 additions and 19 deletions

View File

@ -121,7 +121,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
&& page.Redirect_trail().Itms__len() == 0) // don't generate html for redirected pages
wiki.Html_mgr().Page_wtr_mgr().Gen(ctx.Page().Root_(root), Xopg_view_mode_.Tid__read);
if (gen_hdump)
hdump_bldr.Insert(ctx, page.Root_(root));
hdump_bldr.Insert(ctx, page.Root_(root), gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Hdump); // was hard-coded as Hdump in Xob_hdump_bldr.Insert DATE:2019-09-07
root.Clear();
}
}
@ -140,19 +140,20 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
wiki.Appe().Log_mgr().Txn_end();
tbl.Insert_end();
}
public void Log_file(Xop_ctx ctx, Xop_lnki_tkn lnki, byte caller_tid) {
if (lnki.Ttl().ForceLiteralLink()) return; // ignore literal links which creat a link to file, but do not show the image; EX: [[:File:A.png|thumb|120px]] creates a link to File:A.png, regardless of other display-oriented args
byte[] ttl = lnki.Ttl().Page_db();
public void Log_file(byte caller_tid, Xop_ctx ctx, Xop_lnki_tkn lnki) {
Log_file(caller_tid, ctx, lnki.Ttl(), lnki.Ns_id(), lnki.Lnki_type(), lnki.W(), lnki.H(), lnki.Upright(), lnki.Time(), lnki.Page());
}
public void Log_file(byte caller_tid, Xop_ctx ctx, Xoa_ttl lnki_ttl, int ns_id, byte lnki_type, int lnki_w, int lnki_h, double lnki_upright, double lnki_time, int lnki_page) {
if (lnki_ttl.ForceLiteralLink()) return; // ignore literal links which creat a link to file, but do not show the image; EX: [[:File:A.png|thumb|120px]] creates a link to File:A.png, regardless of other display-oriented args
byte[] ttl = lnki_ttl.Page_db();
Xof_ext ext = Xof_ext_.new_by_ttl_(ttl);
double lnki_time = lnki.Time();
int lnki_page = lnki.Page();
byte[] ttl_commons = Xomp_lnki_temp_wkr.To_commons_ttl(ns_file_is_case_match_all, commons_wiki, ttl);
if ( Xof_lnki_page.Null_n(lnki_page) // page set
&& Xof_lnki_time.Null_n(lnki_time)) // thumbtime set
usr_dlg.Warn_many("", "", "page and thumbtime both set; this may be an issue with fsdb: page=~{0} ttl=~{1}", ctx.Page().Ttl().Page_db_as_str(), String_.new_u8(ttl));
if (lnki.Ns_id() == Xow_ns_.Tid__media)
if (ns_id == Xow_ns_.Tid__media)
caller_tid = Xop_file_logger_.Tid__media;
tbl.Insert_cmd_by_batch(ctx.Page().Bldr__ns_ord(), ctx.Page().Db().Page().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki.Lnki_type(), caller_tid, lnki.W(), lnki.H(), lnki.Upright(), lnki_time, lnki_page);
tbl.Insert_cmd_by_batch(ctx.Page().Bldr__ns_ord(), ctx.Page().Db().Page().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki_type, caller_tid, lnki_w, lnki_h, lnki_upright, lnki_time, lnki_page);
}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_wdata_enabled_)) wdata_enabled = m.ReadYn("v");

View File

@ -30,17 +30,20 @@ public class Xomp_lnki_temp_wkr implements Xop_file_logger {
public void Bgn() {
tbl.Insert_stmt_make();
}
public void Log_file(Xop_ctx ctx, Xop_lnki_tkn lnki, byte caller_tid) {
if (lnki.Ttl().ForceLiteralLink()) return; // ignore literal links which create a link to file, but do not show the image; EX: [[:File:A.png|thumb|120px]] creates a link to File:A.png, regardless of other display-oriented args
public void Log_file(byte caller_tid, Xop_ctx ctx, Xop_lnki_tkn lnki) {
Log_file(caller_tid, ctx, lnki.Ttl(), lnki.Ns_id(), lnki.Lnki_type(), lnki.W(), lnki.H(), lnki.Upright(), lnki.Time(), lnki.Page());
}
public void Log_file(byte caller_tid, Xop_ctx ctx, Xoa_ttl lnki_ttl, int ns_id, byte lnki_type, int lnki_w, int lnki_h, double lnki_upright, double lnki_time, int lnki_page) {
if (lnki_ttl.ForceLiteralLink()) return; // ignore literal links which create a link to file, but do not show the image; EX: [[:File:A.png|thumb|120px]] creates a link to File:A.png, regardless of other display-oriented args
// get lnki_data
byte[] ttl = lnki.Ttl().Page_db();
byte[] ttl = lnki_ttl.Page_db();
Xof_ext ext = Xof_ext_.new_by_ttl_(ttl);
byte[] ttl_commons = Xomp_lnki_temp_wkr.To_commons_ttl(ns_file_is_case_match_all, commons_wiki, ttl);
if (lnki.Ns_id() == Xow_ns_.Tid__media) caller_tid = Xop_file_logger_.Tid__media;
if (ns_id == Xow_ns_.Tid__media) caller_tid = Xop_file_logger_.Tid__media;
// do insert
tbl.Insert_cmd_by_batch(ctx.Page().Bldr__ns_ord(), ctx.Page().Db().Page().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki.Lnki_type(), caller_tid, lnki.W(), lnki.H(), lnki.Upright(), lnki.Time(), lnki.Page());
tbl.Insert_cmd_by_batch(ctx.Page().Bldr__ns_ord(), ctx.Page().Db().Page().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki_type, caller_tid, lnki_w, lnki_h, lnki_upright, lnki_time, lnki_page);
}
public void End() {}
public static byte[] To_commons_ttl(boolean ns_file_is_case_match_all, Xowe_wiki commons_wiki, byte[] ttl_bry) { // handle case-sensitive wikis (en.d) vs case-insensitive commons

View File

@ -15,8 +15,10 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.parsers.lnkis.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
public interface Xop_file_logger {
void Log_file(Xop_ctx ctx, Xop_lnki_tkn lnki, byte caller_tid);
void Log_file(byte caller_tid, Xop_ctx ctx, Xop_lnki_tkn lnki);
void Log_file(byte caller_tid, Xop_ctx ctx, Xoa_ttl lnki_ttl, int ns_id, byte lnki_type, int lnki_w, int lnki_h, double lnki_upright, double lnki_time, int lnki_page);
}
class Xop_file_logger__noop implements Xop_file_logger {
public void Log_file(Xop_ctx ctx, Xop_lnki_tkn lnki, byte caller_tid) {}
public void Log_file(byte caller_tid, Xop_ctx ctx, Xoa_ttl lnki_ttl, int ns_id, byte lnki_type, int lnki_w, int lnki_h, double lnki_upright, double lnki_time, int lnki_page) {}
public void Log_file(byte caller_tid, Xop_ctx ctx, Xop_lnki_tkn lnki) {}
}

View File

@ -15,6 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.parsers.lnkis.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
public class Xop_file_logger_ {
public static final Xop_file_logger Noop = new Xop_file_logger__noop();
public static final byte Tid__file = 0, Tid__media = 1, Tid__gallery = 2, Tid__imap = 3, Tid__pgbnr_main = 4;
public static final Xop_file_logger Noop = new Xop_file_logger__noop();
public static final byte Tid__file = 0, Tid__media = 1, Tid__gallery = 2, Tid__imap = 3, Tid__pgbnr_main = 4, Tid__graph = 5;
}

View File

@ -79,7 +79,7 @@ public class Gallery_parser {
}
ctx.Page().Lnki_list().Add(lnki_tkn);
mgr.Get_thumb_size(lnki_tkn, cur_itm.Ext()); // NOTE: set thumb size, so that lnki.temp parse picks it up
ctx.Lnki().File_logger().Log_file(ctx, lnki_tkn, Xop_file_logger_.Tid__gallery); // NOTE: do not set file_wkr ref early (as member var); parse_all sets late
ctx.Lnki().File_logger().Log_file(Xop_file_logger_.Tid__gallery, ctx, lnki_tkn); // NOTE: do not set file_wkr ref early (as member var); parse_all sets late
lnki_tkn.W_(-1).H_(-1); // NOTE: reset lnki back to defaults, else itm will show as large missing caption
}
private byte Parse_itm() {

View File

@ -196,7 +196,7 @@ public class Pgbnr_func extends Pf_func_base {
private static Xof_file_itm File__make_tkn(Xop_ctx ctx, byte tid, Xoa_ttl file_ttl, int file_w, int file_h) {
Xop_lnki_tkn lnki = ctx.Tkn_mkr().Lnki(file_w, file_h).Ttl_(file_ttl);
ctx.Page().Lnki_list().Add(lnki);
ctx.Lnki().File_logger().Log_file(ctx, lnki, tid); // NOTE: do not set file_wkr ref early (as member var); parse_all sets late
ctx.Lnki().File_logger().Log_file(tid, ctx, lnki); // NOTE: do not set file_wkr ref early (as member var); parse_all sets late
Xof_file_itm file_itm = ctx.Wiki().Html_mgr().Html_wtr().Lnki_wtr().File_wtr().Lnki_eval(Xof_exec_tid.Tid_wiki_page, ctx, ctx.Page(), lnki);
return file_itm;
}