mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Parser: Fix doubling up of images
This commit is contained in:
parent
8332509b60
commit
f999febe6d
@ -258,6 +258,15 @@ public class Bry_find_ {
|
||||
}
|
||||
return end;
|
||||
}
|
||||
public static boolean[] Find_fwd_while_in_gen(byte... ary) {
|
||||
boolean[] rv = new boolean[256];
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
rv[ary[i]] = true;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static int Find_fwd_until(byte[] src, int cur, int end, byte until_byte) {
|
||||
while (true) {
|
||||
if ( cur == end
|
||||
|
@ -41,7 +41,6 @@ public class Xoh_file_mgr {
|
||||
bfr.Add_str_u8("<span style='color:red'>FAIL.PARSER.LINK:" + link_text + "</span>");
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "fatal err when parsing link; link=~{0} err=~{1}", link_text, Err_.Message_gplx_log(e));
|
||||
}
|
||||
file_wtr.Write_file(bfr, ctx, hctx, src, lnki, this.Lnki_eval(Xof_exec_tid.Tid_wiki_page, ctx, page, lnki), alt_text);
|
||||
}
|
||||
public Xof_file_itm Lnki_eval(int exec_tid, Xop_ctx ctx, Xoae_page page, Xop_lnki_tkn lnki) {return Lnki_eval(exec_tid, ctx, page, page.File_queue(), lnki.Ttl().Page_url(), lnki.Lnki_type(), lnki.Upright(), lnki.W(), lnki.H(), lnki.Time(), lnki.Page(), lnki.Ns_id() == Xow_ns_.Tid__media);}
|
||||
public Xof_file_itm Lnki_eval(int exec_tid, Xop_ctx ctx, Xoae_page page, Xof_xfer_queue queue, byte[] lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page, boolean lnki_is_media_ns) {
|
||||
|
@ -17,14 +17,17 @@ package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.langs.jsons.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.parsers.*; import gplx.xowa.xtns.wbases.claims.itms.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
import gplx.xowa.xtns.wbases.mediawiki.client.includes.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto.*;
|
||||
import gplx.xowa.xtns.wbases.mediawiki.client.includes.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto.*;
|
||||
public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
private Wbase_entity_accessor entity_accessor;
|
||||
private WikibaseLanguageIndependentLuaBindings wikibaseLanguageIndependentLuaBindings;
|
||||
public Scrib_lib_wikibase(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public Scrib_lua_mod Mod() {return mod;} private Scrib_lua_mod mod;
|
||||
public Scrib_lib Init() {
|
||||
procs.Init_by_lib(this, Proc_names);
|
||||
this.entity_accessor = new Wbase_entity_accessor(core.App().Wiki_mgr().Wdata_mgr().Doc_mgr);
|
||||
Wbase_doc_mgr entityMgr = core.App().Wiki_mgr().Wdata_mgr().Doc_mgr;
|
||||
this.entity_accessor = new Wbase_entity_accessor(entityMgr);
|
||||
this.wikibaseLanguageIndependentLuaBindings = new WikibaseLanguageIndependentLuaBindings(entityMgr);
|
||||
return this;
|
||||
}
|
||||
public Scrib_lib Clone_lib(Scrib_core core) {return new Scrib_lib_wikibase(core);}
|
||||
@ -147,30 +150,13 @@ public function formatValues( $snaksSerialization ) {
|
||||
throw new ScribuntoException( 'wikibase-error-deserialize-error' );
|
||||
}
|
||||
}
|
||||
public function getLabelByLanguage( $prefixedEntityId, $languageCode ) {
|
||||
$this->checkType( 'getLabelByLanguage', 1, $prefixedEntityId, 'String' );
|
||||
$this->checkType( 'getLabelByLanguage', 2, $languageCode, 'String' );
|
||||
return [ $this->getLanguageIndependentLuaBindings()->getLabelByLanguage( $prefixedEntityId, $languageCode ) ];
|
||||
}
|
||||
private function getLanguageIndependentLuaBindings() {
|
||||
if ( $this->languageIndependentLuaBindings === null ) {
|
||||
$this->languageIndependentLuaBindings = $this->newLanguageIndependentLuaBindings();
|
||||
*/
|
||||
public boolean GetLabelByLanguage(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] prefixedEntityId = args.Pull_bry(0);
|
||||
byte[] languageCode = args.Pull_bry(1);
|
||||
return rslt.Init_obj(wikibaseLanguageIndependentLuaBindings.getLabelByLanguage(prefixedEntityId, languageCode));
|
||||
}
|
||||
return $this->languageIndependentLuaBindings;
|
||||
}
|
||||
private function newLanguageIndependentLuaBindings() {
|
||||
$wikibaseClient = WikibaseClient::getDefaultInstance();
|
||||
return new WikibaseLanguageIndependentLuaBindings(
|
||||
$wikibaseClient->getStore()->getSiteLinkLookup(),
|
||||
$wikibaseClient->getSettings(),
|
||||
$this->getUsageAccumulator(),
|
||||
$this->getEntityIdParser(),
|
||||
$wikibaseClient->getTermLookup(),
|
||||
$wikibaseClient->getTermsLanguages(),
|
||||
$wikibaseClient->getSettings()->getSetting( 'siteGlobalID' )
|
||||
);
|
||||
} */
|
||||
private static Wdata_doc Get_wdoc_or_null(Scrib_proc_args args, Scrib_core core) {
|
||||
private static Wdata_doc Get_wdoc_or_null(Scrib_proc_args args, Scrib_core core) {
|
||||
// get qid / pid from scrib_arg[0]; if none, return null;
|
||||
byte[] xid_bry = args.Pull_bry(0); if (Bry_.Len_eq_0(xid_bry)) return null; // NOTE: some Modules do not pass in an argument; return early, else spurious warning "invalid qid for ttl" (since ttl is blank); EX:w:Module:Authority_control; DATE:2013-10-27
|
||||
|
||||
|
@ -15,7 +15,13 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.client.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.*; import gplx.xowa.xtns.wbases.mediawiki.client.includes.dataAccess.*;
|
||||
import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.claims.enums.*;
|
||||
import gplx.xowa.xtns.wbases.mediawiki.lib.includes.Store.*;
|
||||
public class WikibaseLanguageIndependentLuaBindings {
|
||||
private final EntityRetrievingTermLookup termLookup;
|
||||
public WikibaseLanguageIndependentLuaBindings(Wbase_doc_mgr entity_mgr) {
|
||||
this.termLookup = new EntityRetrievingTermLookup(entity_mgr);
|
||||
}
|
||||
public byte[] getLabelByLanguage(byte[] prefixedEntityId, byte[] languageCode) {
|
||||
return termLookup.getLabel(prefixedEntityId, languageCode);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,16 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.wbases.mediawiki.vendor.wikibase.data_model_services.src.Lookup; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.vendor.*; import gplx.xowa.xtns.wbases.mediawiki.vendor.wikibase.*; import gplx.xowa.xtns.wbases.mediawiki.vendor.wikibase.data_model_services.*; import gplx.xowa.xtns.wbases.mediawiki.vendor.wikibase.data_model_services.src.*;
|
||||
package gplx.xowa.xtns.wbases.mediawiki.lib.includes.Store; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.mediawiki.*; import gplx.xowa.xtns.wbases.mediawiki.lib.*; import gplx.xowa.xtns.wbases.mediawiki.lib.includes.*;
|
||||
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.claims.itms.*;
|
||||
public class EntityRetrievingTermLookup {
|
||||
private final Wbase_doc_mgr entity_mgr;
|
||||
public EntityRetrievingTermLookup(Wbase_doc_mgr entity_mgr) {
|
||||
this.entity_mgr = entity_mgr;
|
||||
}
|
||||
|
||||
public byte[] getLabel(byte[] entityId, byte[] languageCode) {
|
||||
Wdata_doc entity = entity_mgr.Get_by_xid_or_null(entityId);
|
||||
return entity.Label_list__get(languageCode);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user