mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Parser: Fix doubling up of images
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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.core.lists.hashs; import gplx.*; import gplx.core.*; import gplx.core.lists.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Hash_adp__int {
|
||||
private final Hash_adp hash = Hash_adp_.New();
|
||||
private final Int_obj_ref tmp_key = Int_obj_ref.New_neg1();
|
||||
public void Clear() {hash.Clear();}
|
||||
public int Len() {return hash.Count();}
|
||||
public Object Get_by_or_fail(int key) {synchronized (tmp_key) {return hash.Get_by_or_fail(tmp_key.Val_(key));}} // LOCK:used by Xomp_ns_ord_mgr in xomp; DATE:2016-10-18
|
||||
public Object Get_by_or_null(int key) {synchronized (tmp_key) {return hash.Get_by(tmp_key.Val_(key));}} // LOCK:used by Xomp_ns_ord_mgr in xomp; DATE:2016-10-18
|
||||
public void Add(int key, Object obj) {hash.Add(Int_obj_ref.New(key), obj);}
|
||||
public void Add(Int_obj_ref key, Object obj) {hash.Add(key, obj);}
|
||||
public void Add_if_dupe_use_1st(int key, Object obj) {hash.Add_if_dupe_use_1st(Int_obj_ref.New(key), obj);}
|
||||
public void Add_if_dupe_use_nth(Int_obj_ref key, Object obj) {hash.Add_if_dupe_use_nth(key, obj);}
|
||||
public Hash_adp__int Add_as_bry(int key, String val) {hash.Add(Int_obj_ref.New(key), Bry_.new_u8(val)); return this;}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user