mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.11.2.1
This commit is contained in:
@@ -101,7 +101,7 @@ class Dpl_itm {
|
||||
switch (key_id) {
|
||||
case Dpl_itm_keys.Key_category: if (ctg_includes == null) ctg_includes = List_adp_.new_(); ctg_includes.Add(Xoa_ttl.Replace_spaces(val)); break;
|
||||
case Dpl_itm_keys.Key_notcategory: if (ctg_excludes == null) ctg_excludes = List_adp_.new_(); ctg_excludes.Add(Xoa_ttl.Replace_spaces(val)); break;
|
||||
case Dpl_itm_keys.Key_ns: {Xow_ns ns = (Xow_ns)wiki.Ns_mgr().Names_get_or_null(val, 0, val.length); ns_filter = ns == null ? Xow_ns_.Id_main : ns.Id(); break;}
|
||||
case Dpl_itm_keys.Key_ns: {Xow_ns ns = (Xow_ns)wiki.Ns_mgr().Names_get_or_null(val, 0, val.length); ns_filter = ns == null ? Xow_ns_.Tid__main : ns.Id(); break;}
|
||||
case Dpl_itm_keys.Key_order: sort_ascending = Dpl_sort.Parse_as_bool_byte(val); break;
|
||||
case Dpl_itm_keys.Key_suppresserrors: suppress_errors = Dpl_itm_keys.Parse_as_bool(val, false); break;
|
||||
case Dpl_itm_keys.Key_nofollow: no_follow = Dpl_itm_keys.Parse_as_bool(val, true); break; // NOTE: default to true; allows passing nofollow=nofollow; MW: if ('false' != $arg)
|
||||
|
||||
@@ -228,7 +228,7 @@ class Dpl_xnde_fxt {
|
||||
Xoae_page page_obj = fxt.Wiki().Data_mgr().Get_page(page_ttl, false);
|
||||
if (page_obj.Missing()) {
|
||||
fxt.Init_page_create(ttl);
|
||||
fxt.Init_id_create (id, 0, 0, false, 5, Xow_ns_.Id_main, ttl);
|
||||
fxt.Init_id_create (id, 0, 0, false, 5, Xow_ns_.Tid__main, ttl);
|
||||
}
|
||||
page_ids[i] = id;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Gallery_html_wtr {
|
||||
byte[] itm_caption = Gallery_html_wtr_.Bld_caption(wiki, ctx, wtr, hctx, itm);
|
||||
Xoa_ttl itm_ttl = itm.Ttl();
|
||||
if ( itm_ttl != null // ttl does not have invalid characters
|
||||
&& itm_ttl.Ns().Id_file() // ttl is in file ns;
|
||||
&& itm_ttl.Ns().Id_is_file() // ttl is in file ns;
|
||||
) {
|
||||
Xop_lnki_tkn lnki = ctx.Tkn_mkr().Lnki(itm.Ttl_bgn(), itm.Ttl_end()).Ttl_(itm_ttl).W_(mgr.Itm_w()).H_(mgr.Itm_h());
|
||||
Xof_file_itm xfer_itm = wtr.Lnki_wtr().File_wtr().Lnki_eval(Xof_exec_tid.Tid_wiki_page, ctx, page, lnki);
|
||||
|
||||
@@ -179,8 +179,8 @@ public class Gallery_itm_parser {
|
||||
)
|
||||
cur_itm.Reset();
|
||||
else {
|
||||
if (!ttl.Ns().Id_file_or_media()) // ttl does not have "File:"; MW allows non-ns names; EX: "A.png" instead of "File:A.png"; DATE:2013-11-18
|
||||
ttl = Xoa_ttl.parse(wiki, Xow_ns_.Id_file, ttl_bry);
|
||||
if (!ttl.Ns().Id_is_file_or_media()) // ttl does not have "File:"; MW allows non-ns names; EX: "A.png" instead of "File:A.png"; DATE:2013-11-18
|
||||
ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__file, ttl_bry);
|
||||
cur_itm.Ttl_(ttl);
|
||||
cur_itm.Ext_(Xof_ext_.new_by_ttl_(ttl_bry));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ public abstract class Gallery_mgr_base {
|
||||
@gplx.Virtual public int Get_gb_width(int thm_w, int thm_h) {// REF.MW: getGBWidth; Width of gallerybox <li>. Generally is the width of the image, plus padding on image plus padding on gallerybox.s
|
||||
return itm_default_w + this.Get_thumb_padding() + this.Get_gb_padding();
|
||||
}
|
||||
@gplx.Virtual public void Get_modules(Xoae_page page) {} // REF.MW: getModules; Get a list of modules to include in the page.
|
||||
@gplx.Virtual public void Get_modules(Xoae_page page) { // REF.MW: getModules; Get a list of modules to include in the page.
|
||||
page.Html_data().Head_mgr().Itm__gallery_styles().Enabled_y_(); // enable styles or some galleries will show up as list items; PAGE:s.w:Gothic_architecture DATE:2015-11-06
|
||||
}
|
||||
@gplx.Virtual public void Init(int itms_per_row, int itm_default_w, int itm_default_h) {
|
||||
this.itms_per_row = itms_per_row;
|
||||
this.itm_default_w = itm_default_w;
|
||||
@@ -100,7 +102,7 @@ public abstract class Gallery_mgr_base {
|
||||
file_found = File_found_mode == Bool_.Y_byte;
|
||||
int vpad = -1, img_div_w = -1;
|
||||
if ( !hctx_is_hdump // always write img if hdump; DATE:2015-04-27
|
||||
&& ( !ttl.Ns().Id_file()
|
||||
&& ( !ttl.Ns().Id_is_file()
|
||||
|| !file_found
|
||||
)
|
||||
) { // itm is not a file, or is not found; write text
|
||||
@@ -190,7 +192,7 @@ public abstract class Gallery_mgr_base {
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
private static void Box_hdr_write(Bry_bfr bfr, Xop_xatr_whitelist_mgr whitelist_mgr, byte[] src, byte[] gallery_ul_uid, byte[] cls, byte[] style, List_adp xatr_list, boolean hctx_is_hdump, int uid) {
|
||||
bfr.Add_byte(Byte_ascii.Lt).Add(Html_tag_.Ul_name_bry);
|
||||
bfr.Add_byte(Byte_ascii.Lt).Add(Html_tag_.Bry__ul);
|
||||
Html_wtr.Write_atr_bry(bfr, Html_atr_.Bry__id, gallery_ul_uid);
|
||||
Html_wtr.Write_atr_bry(bfr, Html_atr_.Bry__class, cls);
|
||||
if (hctx_is_hdump) {
|
||||
|
||||
@@ -57,7 +57,10 @@ public class Gallery_mgr_base_basic_tst {
|
||||
, " </li>"
|
||||
, "</ul>"
|
||||
));
|
||||
fxt.Test_html_modules_js("");
|
||||
fxt.Test_html_modules_js(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <link rel=\"stylesheet\" href=\"file:///mem/xowa/bin/any/xowa/html/res/src/mediawiki.page/mediawiki.page.gallery.css\" type='text/css'>"
|
||||
));
|
||||
}
|
||||
@Test public void Tmpl() {
|
||||
fxt.Fxt().Init_defn_add("test_tmpl", "b");
|
||||
@@ -112,6 +115,7 @@ public class Gallery_mgr_base_basic_tst {
|
||||
fxt.Test_html_frag("<gallery mode=packed heights=300px>File:A.png|a</gallery>", "<ul id=\"xowa_gallery_ul_0\" class=\"gallery mw-gallery-packed\">");
|
||||
fxt.Test_html_modules_js(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <link rel=\"stylesheet\" href=\"file:///mem/xowa/bin/any/xowa/html/res/src/mediawiki.page/mediawiki.page.gallery.css\" type='text/css'>"
|
||||
, " <script type='text/javascript'>"
|
||||
, " var xowa_global_values = {"
|
||||
, " 'gallery-packed-enabled' : true,"
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Gallery_mgr_packed_base extends Gallery_mgr_base {
|
||||
}
|
||||
@Override public void Itms_per_row_(int v) {}
|
||||
@Override public void Get_modules(Xoae_page page) {
|
||||
super.Get_modules(page);
|
||||
page.Html_data().Head_mgr().Itm__gallery().Enabled_y_();
|
||||
}
|
||||
@Override public int Get_thumb_padding() {return 0;}
|
||||
|
||||
@@ -16,8 +16,9 @@ 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.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.files.gui.*; import gplx.xowa.guis.views.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.files.gui.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
public class Imap_map implements Xoh_file_img_wkr, Js_img_wkr {
|
||||
private static final Imap_map_fmtr map_fmtr_arg = new Imap_map_fmtr();
|
||||
public Imap_map(int id) {this.id = id;}
|
||||
@@ -55,7 +56,7 @@ public class Imap_map implements Xoh_file_img_wkr, Js_img_wkr {
|
||||
private void Write_imap_div(Bry_bfr bfr, Xoh_wtr_ctx hctx, int html_uid, int html_w, int html_h, byte[] html_src, int orig_w, int orig_h) {
|
||||
byte[] desc_style = Calc_desc_style(html_w, html_h);
|
||||
map_fmtr_arg.Init(id, shapes, Calc_scale(orig_w, orig_h, html_w, html_h));
|
||||
img_fmtr_arg.Init(hctx, xtn_mgr, this, html_uid, img_alt, html_src, html_w, html_h, Xoh_lnki_consts.Img_cls_to_bry(img_cls_tid, img_cls_other), a_href);
|
||||
img_fmtr_arg.Init(hctx, xtn_mgr, this, html_uid, img_alt, html_src, html_w, html_h, Xoh_img_cls_.To_html(img_cls_tid, img_cls_other), a_href);
|
||||
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, desc_style, map_fmtr_arg, img_fmtr_arg);
|
||||
}
|
||||
private byte[] Calc_desc_style(int html_w, int html_h) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Insider_html_bldr implements Bry_fmtr_arg {
|
||||
Url_encoder href_encoder = Xoa_app_.Utl__encoder_mgr().Href();
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
byte[] itm = (byte[])list.Get_at(i);
|
||||
Xoa_ttl user_ttl = Xoa_ttl.parse(wiki, Xow_ns_.Id_user, itm);
|
||||
Xoa_ttl user_ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__user, itm);
|
||||
if (user_ttl == null) continue;
|
||||
byte[] user_ttl_bry = user_ttl.Full_db();
|
||||
if (hash.Has(user_ttl_bry)) continue;
|
||||
|
||||
@@ -34,8 +34,8 @@ public class Pfunc_ifexist_mgr {
|
||||
Xow_ns ttl_ns = ttl.Ns();
|
||||
boolean rv = false;
|
||||
switch (ttl_ns.Id()) {
|
||||
case Xow_ns_.Id_special: rv = true; break; // NOTE: some pages call for [[Special]]; always return true for now; DATE:2014-07-17
|
||||
case Xow_ns_.Id_media: rv = Find_ttl_for_media_ns(exists_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
case Xow_ns_.Tid__special: rv = true; break; // NOTE: some pages call for [[Special]]; always return true for now; DATE:2014-07-17
|
||||
case Xow_ns_.Tid__media: rv = Find_ttl_for_media_ns(exists_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
default: rv = Find_ttl_in_db(exists_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
}
|
||||
exists_itm.Exists_(rv);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Pfunc_filepath extends Pf_func_base {
|
||||
@Override public void Func_evaluate(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk self, Bry_bfr bfr) {
|
||||
byte[] val_ary = Eval_argx(ctx, src, caller, self); if (val_ary == Bry_.Empty) return;
|
||||
Xowe_wiki wiki = ctx.Wiki();
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(Xow_ns_.Id_file, val_ary); if (ttl == null) return; // text is not valid ttl; exit;
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(Xow_ns_.Tid__file, val_ary); if (ttl == null) return; // text is not valid ttl; exit;
|
||||
Xoae_page page = Load_page(wiki, ttl); if (page.Missing()) return; // page not found in wiki or commons; exit;
|
||||
byte[] ttl_bry = page.Ttl().Page_url();
|
||||
|
||||
|
||||
@@ -37,21 +37,21 @@ public class Pfunc_ns extends Pf_func_base { // EX: {{ns:6}} -> File
|
||||
o = canonical.Get_by_mid(val_dat_ary, 0, val_dat_ary_len);
|
||||
if (o != null) {
|
||||
Xow_ns itm = (Xow_ns)o;
|
||||
if (itm.Id() == Xow_ns_.Id_file) itm = ctx.Wiki().Ns_mgr().Ns_file(); // handles "Image" -> "File"
|
||||
bfr.Add(encode ? itm.Name_enc() : itm.Name_txt());
|
||||
if (itm.Id() == Xow_ns_.Tid__file) itm = ctx.Wiki().Ns_mgr().Ns_file(); // handles "Image" -> "File"
|
||||
bfr.Add(encode ? itm.Name_enc() : itm.Name_ui());
|
||||
}
|
||||
}
|
||||
else {
|
||||
Xow_ns itm = (Xow_ns)ctx.Wiki().Ns_mgr().Ids_get_or_null(ns_id);
|
||||
if (itm == null) return; // occurs when ns_id is not known; EX: {{ns:999}}; SEE: Wiktionary:Grease pit archive/2007/October; "{{ns:114}}"
|
||||
bfr.Add(encode ? itm.Name_enc() : itm.Name_txt());
|
||||
bfr.Add(encode ? itm.Name_enc() : itm.Name_ui());
|
||||
}
|
||||
}
|
||||
private static Hash_adp_bry canonical;
|
||||
private static void canonical_() {
|
||||
canonical = Hash_adp_bry.ci_a7(); // ASCII:canonical English names
|
||||
for (Xow_ns ns : Xow_ns_.Canonical)
|
||||
canonical_add(ns.Id(), ns.Name_bry());
|
||||
for (Xow_ns ns : Xow_ns_canonical_.Ary)
|
||||
canonical_add(ns.Id(), ns.Name_db());
|
||||
}
|
||||
private static void canonical_add(int ns_id, byte[] ns_name) {
|
||||
Xow_ns ns = new Xow_ns(ns_id, Xow_ns_case_.Tid__all, ns_name, false);
|
||||
|
||||
@@ -38,11 +38,11 @@ public class Pfunc_ttl extends Pf_func_base {
|
||||
case Xol_kwd_grp_.Id_ttl_talk_txt: bfr.Add(ttl.Talk_txt()); break;
|
||||
case Xol_kwd_grp_.Id_ttl_talk_url: bfr.Add(ttl.Talk_url()); break;
|
||||
case Xol_kwd_grp_.Id_ns_num: bfr.Add_int_variable(ttl.Ns().Id()); break;
|
||||
case Xol_kwd_grp_.Id_ns_txt: bfr.Add(ttl.Ns().Name_txt()); break;
|
||||
case Xol_kwd_grp_.Id_ns_txt: bfr.Add(ttl.Ns().Name_ui()); break;
|
||||
case Xol_kwd_grp_.Id_ns_url: bfr.Add(ttl.Ns().Name_enc()); break;
|
||||
case Xol_kwd_grp_.Id_ns_subj_txt: bfr.Add(ctx.Wiki().Ns_mgr().Ords_get_at(ttl.Ns().Ord_subj_id()).Name_txt()); break;
|
||||
case Xol_kwd_grp_.Id_ns_subj_txt: bfr.Add(ctx.Wiki().Ns_mgr().Ords_get_at(ttl.Ns().Ord_subj_id()).Name_ui()); break;
|
||||
case Xol_kwd_grp_.Id_ns_subj_url: bfr.Add(ctx.Wiki().Ns_mgr().Ords_get_at(ttl.Ns().Ord_subj_id()).Name_enc()); break;
|
||||
case Xol_kwd_grp_.Id_ns_talk_txt: bfr.Add(ctx.Wiki().Ns_mgr().Ords_get_at(ttl.Ns().Ord_talk_id()).Name_txt()); break;
|
||||
case Xol_kwd_grp_.Id_ns_talk_txt: bfr.Add(ctx.Wiki().Ns_mgr().Ords_get_at(ttl.Ns().Ord_talk_id()).Name_ui()); break;
|
||||
case Xol_kwd_grp_.Id_ns_talk_url: bfr.Add(ctx.Wiki().Ns_mgr().Ords_get_at(ttl.Ns().Ord_talk_id()).Name_enc()); break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Pfunc_pagesincategory extends Pf_func_base {
|
||||
if (Bry_.Len_eq_0(ctg_ttl_bry)) {bfr.Add_int_digits(1, 0); return;} // no title; EX: "{{PAGESINCATEGORY:}}"
|
||||
Xowe_wiki wiki = ctx.Wiki();
|
||||
Xowd_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int ctg_id = core_data_mgr.Tbl__page().Select_id(Xow_ns_.Id_category, Xoa_ttl.Replace_spaces(ctg_ttl_bry));
|
||||
int ctg_id = core_data_mgr.Tbl__page().Select_id(Xow_ns_.Tid__category, Xoa_ttl.Replace_spaces(ctg_ttl_bry));
|
||||
if (ctg_id == Xowd_page_itm.Id_null) {bfr.Add_int_digits(1, 0); return;} // category doesn't exist; EX: "{{PAGESINCATEGORY:Unknown_category}}"
|
||||
Xowd_category_itm ctg_itm = core_data_mgr.Db__cat_core().Tbl__cat_core().Select(ctg_id);
|
||||
if (ctg_itm == null) {bfr.Add_int_digits(1, 0); return;} // category counts don't exist; shouldn't happen
|
||||
|
||||
@@ -53,7 +53,7 @@ class Pfunc_pagesincategory_tstr {
|
||||
public void Init_category_counts(String category_title, int pages, int subcs, int files) {
|
||||
int page_id = 1;
|
||||
page_tbl.Insert_bgn();
|
||||
page_tbl.Insert_cmd_by_batch(page_id, Xow_ns_.Id_category, Bry_.new_u8(category_title), Bool_.N, DateAdp_.Now(), 1, 1, 1, 1);
|
||||
page_tbl.Insert_cmd_by_batch(page_id, Xow_ns_.Tid__category, Bry_.new_u8(category_title), Bool_.N, DateAdp_.Now(), 1, 1, 1, 1);
|
||||
page_tbl.Insert_end();
|
||||
cat_core_tbl.Insert_bgn();
|
||||
cat_core_tbl.Insert_cmd_by_batch(page_id, pages, subcs, files, Byte_.Zero, 1);
|
||||
|
||||
@@ -68,7 +68,7 @@ class Pp_index_parser {
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)sub;
|
||||
int sub_ns_id = lnki.Ns_id();
|
||||
if (sub_ns_id == ns_page_id) rv.Page_ttls().Add(lnki.Ttl());
|
||||
else if (sub_ns_id == Xow_ns_.Id_main) rv.Main_lnkis().Add(lnki);
|
||||
else if (sub_ns_id == Xow_ns_.Tid__main) rv.Main_lnkis().Add(lnki);
|
||||
break;
|
||||
}
|
||||
case Xop_tkn_itm_.Tid_xnde: {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Scrib_invoke_func extends Pf_func_base {
|
||||
byte[] mod_raw = null;
|
||||
Scrib_lua_mod mod = core.Mods_get(mod_name);
|
||||
if (mod == null) {
|
||||
Xow_ns module_ns = wiki.Ns_mgr().Ids_get_or_null(Scrib_xtn_mgr.Ns_id_module);
|
||||
Xow_ns module_ns = wiki.Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__module);
|
||||
Xoa_ttl mod_ttl = Xoa_ttl.parse(wiki, Bry_.Add(module_ns.Name_db_w_colon(), mod_name));
|
||||
mod_raw = wiki.Cache_mgr().Page_cache().Get_or_load_as_src(mod_ttl);
|
||||
if (mod_raw == null) {Error(bfr, wiki.Msg_mgr(), Err_mod_missing); return;} // EX: "{{#invoke:missing_mod}}"
|
||||
|
||||
@@ -75,6 +75,4 @@ public class Scrib_xtn_mgr extends Xox_mgr_base {
|
||||
}
|
||||
public static Err err_(String fmt, Object... args) {return Err_.new_wo_type(fmt, args).Trace_ignore_add_1_();}
|
||||
public static Err err_(Exception e, String msg, Object... args) {return Err_.new_exc(e, "xo", msg, args).Trace_ignore_add_1_();}
|
||||
public static final int Ns_id_module = 828, Ns_id_module_talk = 829;
|
||||
public static final String Ns_name_module = "Module", Ns_name_module_talk = "Module talk";
|
||||
}
|
||||
|
||||
@@ -304,12 +304,12 @@ public class Scrib_lib_mw implements Scrib_lib {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(cur_wiki, ttl_bry); // parse directly; handles titles where template is already part of title; EX: "Template:A"
|
||||
if (ttl == null) return rslt.Init_ary_empty(); // invalid ttl;
|
||||
if (!ttl.ForceLiteralLink() && ttl.Ns().Id_main()) // title is not literal and is not prefixed with Template; parse again as template; EX: ":A" and "Template:A" are fine; "A" is parsed again as "Template:A"
|
||||
if (!ttl.ForceLiteralLink() && ttl.Ns().Id_is_main()) // title is not literal and is not prefixed with Template; parse again as template; EX: ":A" and "Template:A" are fine; "A" is parsed again as "Template:A"
|
||||
ttl = Xoa_ttl.parse(cur_wiki, Bry_.Add(cur_wiki.Ns_mgr().Ns_template().Name_db_w_colon(), ttl_bry)); // parse again, but add "Template:"
|
||||
KeyVal[] args_ary = args.Pull_kv_ary(2);
|
||||
// BLOCK.bgn:Xot_invk_tkn.Transclude; cannot reuse b/c Transclude needs invk_tkn, and invk_tkn is manufactured late; DATE:2014-01-02
|
||||
byte[] sub_src = null;
|
||||
if (ttl.Ns().Id_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
|
||||
if (ttl.Ns().Id_is_tmpl()) { // ttl is template; check tmpl_regy first before going to data_mgr
|
||||
Xot_defn_tmpl tmpl = (Xot_defn_tmpl)core.Wiki().Cache_mgr().Defn_cache().Get_by_key(ttl.Page_db());
|
||||
if (tmpl != null) sub_src = tmpl.Data_raw();
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Scrib_lib_mw__invoke_tst {
|
||||
@Test public void GetAllExpandedArguments_ws_prm_key_missing() { // PURPOSE: do not trim val if key missing; parameterized value ("{{{1}}}")
|
||||
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0|{{{1}}}}}");
|
||||
fxt.Init_page("{{test| a }}");
|
||||
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("current"), "\n a "); // " a " -> " a "
|
||||
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getAllExpandedArguments, Object_.Ary("current"), "\n a"); // " a " -> " a" // tmpl.trim_end: always trim end; DATE:2015-11-07
|
||||
}
|
||||
@Test public void GetAllExpandedArguments__ignore_empty_key() {// PURPOSE: ignore arguents that have an empty key (|=8|); EX:w:Fool's_mate; DATE:2014-03-05
|
||||
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0}}");
|
||||
@@ -45,7 +45,7 @@ public class Scrib_lib_mw__invoke_tst {
|
||||
}
|
||||
@Test public void GetExpandedArgument_ws_key_missing() { // PURPOSE: do not trim val if key missing; literal value
|
||||
fxt.Init_page("{{#invoke:Mod_0|Prc_0| a }}");
|
||||
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a "); // " a " -> " a "
|
||||
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a"); // " a " -> " a" // tmpl.trim_end: always trim end; DATE:2015-11-07
|
||||
}
|
||||
@Test public void GetExpandedArgument_ws_key_prm_key_exists() { // PURPOSE: trim val if key exists; parameterized value ("key={{{1}}}")
|
||||
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0|key1={{{1}}}}}");
|
||||
@@ -55,7 +55,7 @@ public class Scrib_lib_mw__invoke_tst {
|
||||
@Test public void GetExpandedArgument_ws_key_prm_key_missing() { // PURPOSE: do not trim val if key missing; parameterized value ("{{{1}}}")
|
||||
fxt.Init_tmpl("{{#invoke:Mod_0|Prc_0|{{{1}}}}}");
|
||||
fxt.Init_page("{{test| a }}");
|
||||
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a "); // " a " -> " a "
|
||||
fxt.Test_lib_proc(lib, Scrib_lib_mw.Invk_getExpandedArgument, Object_.Ary("current", "1") , " a"); // " a " -> " a" // tmpl.trim_end: always trim end; DATE:2015-11-07
|
||||
}
|
||||
@Test public void Preprocess() {
|
||||
this.Init_preprocess();
|
||||
|
||||
@@ -140,20 +140,20 @@ public class Scrib_lib_site implements Scrib_lib {
|
||||
}
|
||||
private KeyVal[] Bld_ns(Xowe_wiki wiki, Xow_ns ns, int ns_id) {
|
||||
int len = 16;
|
||||
if (ns_id < Xow_ns_.Id_main) len = 14;
|
||||
else if (ns_id == Xow_ns_.Id_main) len = 17;
|
||||
if (ns_id < Xow_ns_.Tid__main) len = 14;
|
||||
else if (ns_id == Xow_ns_.Tid__main) len = 17;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
rv[ 0] = KeyVal_.new_("id" , ns_id);
|
||||
rv[ 1] = KeyVal_.new_("name" , ns.Name_txt());
|
||||
rv[ 2] = KeyVal_.new_("canonicalName" , ns.Name_str()); // strtr( $canonical, "_", " " ),
|
||||
rv[ 1] = KeyVal_.new_("name" , ns.Name_ui());
|
||||
rv[ 2] = KeyVal_.new_("canonicalName" , ns.Name_db_str()); // strtr( $canonical, "_", " " ),
|
||||
rv[ 3] = KeyVal_.new_("hasSubpages" , ns.Subpages_enabled()); // MWNs::hasSubpages( $ns ),
|
||||
rv[ 4] = KeyVal_.new_("hasGenderDistinction" , ns.Is_gender_aware()); // MWNs::hasGenderDistinction( $ns ),
|
||||
rv[ 5] = KeyVal_.new_("isCapitalized" , ns.Is_capitalized()); // MWNs::isCapitalized( $ns ),
|
||||
rv[ 6] = KeyVal_.new_("isContent" , ns.Is_content()); // MWNs::isContent( $ns ),
|
||||
rv[ 7] = KeyVal_.new_("isIncludable" , ns.Is_includable()); // !MWNs::isNonincludable( $ns ),
|
||||
rv[ 8] = KeyVal_.new_("isMovable" , ns.Is_movable()); // MWNs::isMovable( $ns ),
|
||||
rv[ 9] = KeyVal_.new_("isSubject" , ns.Id_subj());
|
||||
rv[10] = KeyVal_.new_("isTalk" , ns.Id_talk());
|
||||
rv[ 9] = KeyVal_.new_("isSubject" , ns.Id_is_subj());
|
||||
rv[10] = KeyVal_.new_("isTalk" , ns.Id_is_talk());
|
||||
rv[11] = KeyVal_.new_("defaultContentModel" , null); // MWNs::getNsContentModel( $ns ), ASSUME: always null?
|
||||
rv[12] = KeyVal_.new_("aliases" , ns.Aliases_as_scrib_ary()); // DATE:2014-02-15
|
||||
if (ns_id < 0)
|
||||
@@ -162,7 +162,7 @@ public class Scrib_lib_site implements Scrib_lib {
|
||||
rv[13] = KeyVal_.new_("subject" , ns_id); // MWNs::getSubject( $ns );
|
||||
rv[14] = KeyVal_.new_("talk" , ns.Id_talk_id()); // MWNs::getTalk( $ns );
|
||||
rv[15] = KeyVal_.new_("associated" , ns.Id_alt_id()); // MWNs::getAssociated( $ns );
|
||||
if (ns_id == Xow_ns_.Id_main)
|
||||
if (ns_id == Xow_ns_.Tid__main)
|
||||
rv[16] = KeyVal_.new_("displayName" , wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_ns_blankns)); // MWNs::getAssociated( $ns );
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -42,11 +42,11 @@ public class Scrib_lib_site_tst {
|
||||
fxt.Parser_fxt().Wiki().Stats().NumPages_(1).NumArticles_(2).NumFiles_(3).NumEdits_(4).NumViews_(5).NumUsers_(6).NumUsersActive_(7).NumAdmins_(8);
|
||||
wiki.Ns_mgr()
|
||||
.Clear()
|
||||
.Add_new(Scrib_xtn_mgr.Ns_id_module, "Module")
|
||||
.Add_new(Scrib_xtn_mgr.Ns_id_module_talk, "Module talk")
|
||||
.Add_new(Xow_ns_.Id_special, "Special")
|
||||
.Add_new(Xow_ns_.Id_main, "")
|
||||
.Add_new(Xow_ns_.Id_talk, "Talk")
|
||||
.Add_new(Xow_ns_.Tid__module , Xow_ns_.Key__module)
|
||||
.Add_new(Xow_ns_.Tid__module_talk , Xow_ns_.Key__module_talk)
|
||||
.Add_new(Xow_ns_.Tid__special , Xow_ns_.Key__special)
|
||||
.Add_new(Xow_ns_.Tid__main , "")
|
||||
.Add_new(Xow_ns_.Tid__talk , Xow_ns_.Key__talk)
|
||||
.Init_w_defaults()
|
||||
;
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_site.Invk_init_site_for_wiki, Object_.Ary_empty, String_.Concat_lines_nl_skip_last
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
Init();
|
||||
mod = core.RegisterInterface(this, script_dir.GenSubFil("mw.title.lua")
|
||||
, KeyVal_.new_("thisTitle", "") // NOTE: pass blank; will be updated by GetCurrentTitle
|
||||
, KeyVal_.new_("NS_MEDIA", Xow_ns_.Id_media) // NOTE: MW passes down NS_MEDIA; this should be -2 on all wikis...
|
||||
, KeyVal_.new_("NS_MEDIA", Xow_ns_.Tid__media) // NOTE: MW passes down NS_MEDIA; this should be -2 on all wikis...
|
||||
);
|
||||
notify_page_changed_fnc = mod.Fncs_get_by_key("notify_page_changed");
|
||||
return mod;
|
||||
@@ -108,7 +108,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
int ns_id = Int_.cast(ns_obj);
|
||||
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
|
||||
if (ns != null)
|
||||
return ns.Name_bry();
|
||||
return ns.Name_db();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -153,9 +153,9 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
Xowe_wiki wiki = core.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
if ( ttl == null
|
||||
|| !ttl.Ns().Id_file_or_media()
|
||||
|| !ttl.Ns().Id_is_file_or_media()
|
||||
) return rslt.Init_obj(GetFileInfo_absent);
|
||||
if (ttl.Ns().Id_media()) ttl = Xoa_ttl.parse(wiki, Xow_ns_.Id_file, ttl.Page_db()); // if [[Media:]] change to [[File:]]; theoretically, this should be changed in Get_page, but not sure if I want to put this logic that low; DATE:2014-01-07
|
||||
if (ttl.Ns().Id_is_media()) ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__file, ttl.Page_db()); // if [[Media:]] change to [[File:]]; theoretically, this should be changed in Get_page, but not sure if I want to put this logic that low; DATE:2014-01-07
|
||||
// Xoae_page file_page = Pfunc_filepath.Load_page(wiki, ttl); // EXPENSIVE
|
||||
// boolean exists = !file_page.Missing();
|
||||
// if (!exists) return rslt.Init_obj(KeyVal_.Ary(KeyVal_.new_("exists", false))); // NOTE: do not reinstate; will exit early if commons is not installed; DATE:2015-01-25; NOTE: Media objects are often flagged as absent in offline mode
|
||||
@@ -207,24 +207,24 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
public static final KeyVal[] CascadingProtection_rv = KeyVal_.Ary(KeyVal_.new_("sources", Bool_.N), KeyVal_.new_("restrictions", KeyVal_.Ary_empty));
|
||||
private KeyVal[] GetInexpensiveTitleData(Xoa_ttl ttl) {
|
||||
Xow_ns ns = ttl.Ns();
|
||||
boolean ns_file_or_media = ns.Id_file_or_media(), ns_special = ns.Id_special();
|
||||
boolean ns_file_or_media = ns.Id_is_file_or_media(), ns_special = ns.Id_is_special();
|
||||
int rv_len = 7, rv_idx = 7;
|
||||
if (ns_special) ++rv_len;
|
||||
if (!ns_file_or_media) ++rv_len;
|
||||
Xow_xwiki_itm xwiki_itm = ttl.Wik_itm();
|
||||
String xwiki_str = xwiki_itm == null ? "" : xwiki_itm.Key_str();
|
||||
KeyVal[] rv = new KeyVal[rv_len];
|
||||
rv[ 0] = KeyVal_.new_("isLocal" , true); // title.isLocal; NOTE: always true; passing "http:" also returns true; not sure how to handle "Interwiki::fetch( $this->mInterwiki )->isLocal()"
|
||||
rv[ 1] = KeyVal_.new_("interwiki" , xwiki_str); // $title->getInterwiki(),
|
||||
rv[ 2] = KeyVal_.new_("namespace" , ns.Id()); // $ns,
|
||||
rv[ 3] = KeyVal_.new_("nsText" , ns.Name_str()); // $title->getNsText(),
|
||||
rv[ 4] = KeyVal_.new_("text" , ttl.Page_txt()); // $title->getText(),
|
||||
rv[ 5] = KeyVal_.new_("fragment" , ttl.Anch_txt()); // $title->getFragment(),
|
||||
rv[ 6] = KeyVal_.new_("thePartialUrl" , ttl.Page_db()); // $title->getPartialUrl(),
|
||||
rv[ 0] = KeyVal_.new_("isLocal" , true); // title.isLocal; NOTE: always true; passing "http:" also returns true; not sure how to handle "Interwiki::fetch( $this->mInterwiki )->isLocal()"
|
||||
rv[ 1] = KeyVal_.new_("interwiki" , xwiki_str); // $title->getInterwiki(),
|
||||
rv[ 2] = KeyVal_.new_("namespace" , ns.Id()); // $ns,
|
||||
rv[ 3] = KeyVal_.new_("nsText" , Xow_ns_canonical_.To_canonical_or_local(ns)); // $title->getNsText(), NOTE: needed b/c some modules expect English "Template"; PAGE:sh.w:Koprno DATE:2015-11-08
|
||||
rv[ 4] = KeyVal_.new_("text" , ttl.Page_txt()); // $title->getText(),
|
||||
rv[ 5] = KeyVal_.new_("fragment" , ttl.Anch_txt()); // $title->getFragment(),
|
||||
rv[ 6] = KeyVal_.new_("thePartialUrl" , ttl.Page_db()); // $title->getPartialUrl(),
|
||||
if (ns_special)
|
||||
rv[rv_idx++] = KeyVal_.new_("exists" , false); // TODO: lookup specials
|
||||
rv[rv_idx++] = KeyVal_.new_("exists" , false); // TODO: lookup specials
|
||||
if (!ns_file_or_media)
|
||||
rv[rv_idx++] = KeyVal_.new_("file" , false); // REF.MW: if ( $ns !== NS_FILE && $ns !== NS_MEDIA ) $ret['file'] = false;
|
||||
rv[rv_idx++] = KeyVal_.new_("file" , false); // REF.MW: if ( $ns !== NS_FILE && $ns !== NS_MEDIA ) $ret['file'] = false;
|
||||
return rv;
|
||||
} private static final Xowd_page_itm tmp_db_page = Xowd_page_itm.new_tmp();
|
||||
public static final String Key_wikitexet = "wikitext";
|
||||
|
||||
@@ -32,6 +32,10 @@ public class Scrib_lib_title_tst {
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A"));
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("a[b") , Scrib_invoke_func_fxt.Null_rslt_ary); // invalid
|
||||
}
|
||||
@Test public void NewTitle__foreign() {// PURPOSE: always return English name b/c some modules expect English "Template"; PAGE:sh.w:Koprno DATE:2015-11-08
|
||||
fxt.Core().Wiki().Ns_mgr().Ns_template().Name_bry_(Bry_.new_a7("Template_in_nonenglish_name"));
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_newTitle, Object_.Ary("A", "Template") , ttl_fast(10 , "Template", "A")); // "Template" not "Template_in_nonenglish_name"
|
||||
}
|
||||
@Test public void GetUrl() {
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl") , "//en.wikipedia.org/wiki/Main_Page");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "action=edit") , "//en.wikipedia.org/wiki/Main_Page?action=edit");
|
||||
@@ -155,15 +159,3 @@ public class Scrib_lib_title_tst {
|
||||
);
|
||||
}
|
||||
}
|
||||
//0000: '' != '1=isLocal=True'
|
||||
//0001: ' true;false;;828;Module;A;0;;wikitext;A;false;false' != 'isRedirect=False'
|
||||
//0002: <<N/A>> != 'interwiki='
|
||||
//0003: <<N/A>> != 'namespace=828'
|
||||
//0004: <<N/A>> != 'nsText=Module'
|
||||
//0005: <<N/A>> != 'text=A'
|
||||
//0006: <<N/A>> != 'id=0'
|
||||
//0007: <<N/A>> != 'fragment='
|
||||
//0008: <<N/A>> != 'contentModel=wikitext'
|
||||
//0009: <<N/A>> != 'thePartialUrl=A'
|
||||
//0010: <<N/A>> != 'exists=False'
|
||||
//0011: <<N/A>> != 'fileExists=False'
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Scrib_lib_uri implements Scrib_lib {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
if (ttl == null) return rslt.Init_null();
|
||||
Bry_bfr bfr = core.App().Utl__bfr_mkr().Get_b512();
|
||||
if (ttl.Ns().Id() == Xow_ns_.Id_media) { // change "Media:" -> "File:"
|
||||
if (ttl.Ns().Id() == Xow_ns_.Tid__media) { // change "Media:" -> "File:"
|
||||
bfr.Add(wiki.Ns_mgr().Ns_file().Name_db_w_colon());
|
||||
bfr.Add(ttl.Page_db());
|
||||
ttl_bry = bfr.To_bry_and_clear();
|
||||
|
||||
@@ -48,7 +48,9 @@ public class Scrib_lib_wikibase_entity implements Scrib_lib {
|
||||
Wdata_wiki_mgr wdata_mgr = app.Wiki_mgr().Wdata_mgr();
|
||||
byte[] lang = wiki.Wdata_wiki_lang();
|
||||
Wdata_doc wdoc = wdata_mgr.Pages_get(qid); if (wdoc == null) {Wdata_wiki_mgr.Log_missing_qid(core.Ctx(), qid); return rslt.Init_str_empty();} // NOTE: return empty String, not nil; PAGE:fr.s:Henri_Bergson; DATE:2014-08-13
|
||||
int pid_int = wdata_mgr.Pids_get(lang, pid); if (pid_int == Wdata_wiki_mgr.Pid_null) return rslt.Init_str_empty();
|
||||
int pid_int = wdata_mgr.Pids__parse_as_int_or_null(pid); // parse as num; EX: p123 -> 123; PAGE:hr.w:Hepatitis DATE:2015-11-08
|
||||
if (pid_int == Wdata_wiki_mgr.Pid_null) pid_int = wdata_mgr.Pids__get_by_name(lang, pid); // parse as name; EX: name > 123
|
||||
if (pid_int == Wdata_wiki_mgr.Pid_null) return rslt.Init_str_empty();
|
||||
Wdata_claim_grp prop_grp = wdoc.Claim_list_get(pid_int); if (prop_grp == null) return rslt.Init_str_empty();
|
||||
Bry_bfr bfr = app.Utl__bfr_mkr().Get_b512();
|
||||
wdata_mgr.Resolve_to_bfr(bfr, prop_grp, lang);
|
||||
|
||||
@@ -29,8 +29,9 @@ public class Scrib_lib_wikibase_entity_tst {
|
||||
@Test public void FormatPropertyValues() {
|
||||
Wdata_wiki_mgr_fxt wdata_fxt = new Wdata_wiki_mgr_fxt().Init(fxt.Parser_fxt(), false);
|
||||
wdata_fxt.Init_pages_add(wdata_fxt.Wdoc_bldr("Q2").Add_claims(wdata_fxt.Make_claim_str(3, "P3_val")).Xto_wdoc());
|
||||
wdata_fxt.Init_pids_add("en", "P3", 3);
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3"), "P3_val");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3") , "P3_val"); // lookup by id
|
||||
wdata_fxt.Init_pids_add("en", "P3_val", 3);
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3_val") , "P3_val"); // lookup by name
|
||||
}
|
||||
@Test public void FormatPropertyValues__not_found() { // PURPOSE: should return "" not null; PAGE:fr.s:Auteur:Henri_Bergson; DATE:2014-08-13
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_wikibase_entity.Invk_formatPropertyValues, Object_.Ary("Q2", "P3"), "");
|
||||
|
||||
@@ -141,11 +141,12 @@ class Scrib_lib_wikibase_srl {
|
||||
private static KeyVal[] Srl_claims_prop_itm_core(String pid, Wdata_claim_itm_core itm) {
|
||||
boolean snak_is_valued = itm.Snak_tid() != Wdata_dict_snak_tid.Tid_novalue;
|
||||
int snak_is_valued_adj = snak_is_valued ? 1 : 0;
|
||||
KeyVal[] rv = new KeyVal[2 + snak_is_valued_adj];
|
||||
KeyVal[] rv = new KeyVal[3 + snak_is_valued_adj];
|
||||
if (snak_is_valued) // NOTE: novalue must not return slot (no datavalue node in json); PAGE:ru.w:Лимонов,_Эдуард_Вениаминович; DATE:2015-02-16; ALSO: sv.w:Joseph_Jaquet; DATE:2015-07-31
|
||||
rv[0] = KeyVal_.new_("datavalue", Srl_claims_prop_itm_core_val(itm));
|
||||
rv[0 + snak_is_valued_adj] = KeyVal_.new_("property", pid);
|
||||
rv[1 + snak_is_valued_adj] = KeyVal_.new_("snaktype", Wdata_dict_snak_tid.Xto_str(itm.Snak_tid()));
|
||||
rv[2 + snak_is_valued_adj] = KeyVal_.new_("datatype", Wdata_dict_val_tid.To_str__srl(itm.Val_tid())); // NOTE: datatype needed for Modules; PAGE:eo.w:WikidataKoord; DATE:2015-11-08
|
||||
return rv;
|
||||
}
|
||||
private static final Scrib_lib_wikibase_srl_visitor visitor = new Scrib_lib_wikibase_srl_visitor();
|
||||
|
||||
@@ -138,6 +138,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " value:'Moon'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'string'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -156,6 +157,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " value:''"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'somevalue'"
|
||||
, " datatype:'unknown'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -171,6 +173,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " mainsnak:"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'novalue'"
|
||||
, " datatype:'unknown'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -191,6 +194,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " numeric-id:'3'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'wikibase-entityid'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -211,6 +215,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " numeric-id:'3'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'wikibase-entityid'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, " p2:"
|
||||
@@ -224,6 +229,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " numeric-id:'3'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'wikibase-entityid'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -248,6 +254,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " calendarmodel:'http://www.wikidata.org/entity/Q1985727'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'time'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -271,6 +278,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " precision:'1.0E-5'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'globe-coordinate'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -287,12 +295,13 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " datavalue:"
|
||||
, " type:'quantity'"
|
||||
, " value:"
|
||||
, " amount:'+1,234'"
|
||||
, " amount:'1234'"
|
||||
, " unit:'2'"
|
||||
, " upperBound:'+1,236'"
|
||||
, " lowerBound:'+1232'"
|
||||
, " upperBound:'1236'"
|
||||
, " lowerBound:'1232'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'quantity'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -313,6 +322,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " language:'en'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'monolingualtext'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
@@ -332,6 +342,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " value:'Earth'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'string'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, " qualifiers:"
|
||||
@@ -348,6 +359,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " calendarmodel:'http://www.wikidata.org/entity/Q1985727'"
|
||||
, " property:'P3'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'time'"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ class Scrib_lib_wikibase_srl_visitor implements Wdata_claim_visitor {
|
||||
}
|
||||
private static KeyVal[] Quantity_value(Wdata_claim_itm_quantity itm) {
|
||||
KeyVal[] rv = new KeyVal[4];
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_quantity.Str_amount , String_.new_u8(itm.Amount()));
|
||||
rv[0] = KeyVal_.new_(Wdata_dict_value_quantity.Str_amount , itm.Amount_as_num().To_str()); // NOTE: must be num b/c Module code will directly do math calc on it; EX: "99" not "+99"; PAGE:eo.w:Mud<75>; DATE:2015-11-08
|
||||
rv[1] = KeyVal_.new_(Wdata_dict_value_quantity.Str_unit , String_.new_u8(itm.Unit()));
|
||||
rv[2] = KeyVal_.new_(Wdata_dict_value_quantity.Str_upperbound , String_.new_u8(itm.Ubound()));
|
||||
rv[3] = KeyVal_.new_(Wdata_dict_value_quantity.Str_lowerbound , String_.new_u8(itm.Lbound()));
|
||||
rv[2] = KeyVal_.new_(Wdata_dict_value_quantity.Str_upperbound , itm.Ubound_as_num().To_str());
|
||||
rv[3] = KeyVal_.new_(Wdata_dict_value_quantity.Str_lowerbound , itm.Lbound_as_num().To_str());
|
||||
return rv;
|
||||
}
|
||||
public void Visit_time(Wdata_claim_itm_time itm) {
|
||||
|
||||
@@ -75,9 +75,19 @@ public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
|
||||
return Bry_.Len_eq_0(rv) ? null : rv; // JAVA: convert Bry_.Empty to null
|
||||
}
|
||||
public Int_obj_val Pids_add(byte[] pids_key, int pid_id) {Int_obj_val rv = Int_obj_val.new_(pid_id); pids_cache.Add(pids_key, rv); return rv;}
|
||||
public int Pids_get(byte[] lang_key, byte[] pid_name) {
|
||||
public int Pids__parse_as_int_or_null(byte[] pid_ttl) { // EX: "p123" -> "123"
|
||||
int len = pid_ttl.length; if (len == 0) return Wdata_wiki_mgr.Pid_null;
|
||||
byte ltr_p = pid_ttl[0]; // make sure 1st char is "P" or "p"
|
||||
switch (ltr_p) {
|
||||
case Byte_ascii.Ltr_P:
|
||||
case Byte_ascii.Ltr_p: break;
|
||||
default: return Wdata_wiki_mgr.Pid_null;
|
||||
}
|
||||
return Bry_.To_int_or(pid_ttl, 1, len, Wdata_wiki_mgr.Pid_null);
|
||||
}
|
||||
public int Pids__get_by_name(byte[] lang_key, byte[] pid_name) {
|
||||
if (!enabled) return Pid_null;
|
||||
byte[] pids_key = Bry_.Add(lang_key, Byte_ascii.Pipe_bry, pid_name);
|
||||
byte[] pids_key = Bry_.Add(lang_key, Byte_ascii.Pipe_bry, pid_name); // EX: "en|name"
|
||||
Int_obj_val rv = (Int_obj_val)pids_cache.Get_by(pids_key);
|
||||
if (rv == null) {
|
||||
int pid_id = this.Wdata_wiki().Db_mgr().Load_mgr().Load_pid(lang_key, pid_name); if (pid_id == Pid_null) return Pid_null;
|
||||
@@ -224,7 +234,7 @@ public class Wdata_wiki_mgr implements GfoEvObj, GfoInvkAble {
|
||||
public static boolean Wiki_page_is_json(int wiki_tid, int ns_id) {
|
||||
switch (wiki_tid) {
|
||||
case Xow_domain_tid_.Int__wikidata:
|
||||
if (ns_id == Xow_ns_.Id_main || ns_id == gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Ns_property)
|
||||
if (ns_id == Xow_ns_.Tid__main || ns_id == gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Ns_property)
|
||||
return true;
|
||||
break;
|
||||
case Xow_domain_tid_.Int__home:
|
||||
|
||||
@@ -117,7 +117,7 @@ public class Wdata_wiki_mgr_fxt {
|
||||
public void Test_get_low_qid(String qid, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Wdata_wiki_mgr.Get_low_qid(Bry_.new_a7(qid))));
|
||||
}
|
||||
public void Test_link(String ttl_str, String expd) {Test_link(Xoa_ttl.parse(wiki, Xow_ns_.Id_main, Bry_.new_u8(ttl_str)), expd);}
|
||||
public void Test_link(String ttl_str, String expd) {Test_link(Xoa_ttl.parse(wiki, Xow_ns_.Tid__main, Bry_.new_u8(ttl_str)), expd);}
|
||||
public void Test_link(Xoa_ttl ttl, String expd) {
|
||||
byte[] qid_ttl = wdata_mgr.Qids_get(wiki, ttl);
|
||||
Tfds.Eq(expd, String_.new_u8(qid_ttl));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Wdata_xwiki_link_wtr implements Bry_fmtr_arg {
|
||||
List_adp slink_list = page.Slink_list();
|
||||
Xoa_ttl page_ttl = page.Ttl();
|
||||
byte[] qid = Write_wdata_links(slink_list, page.Wikie(), page_ttl, page.Wdata_external_lang_links());
|
||||
if (!Bry_.Eq(qid, Qid_null) && !page_ttl.Ns().Id_special()) // don't write "In other languages" if no qid; also skip Special ns; needed for pages with wbase page, but no sitelinks; PAGE:en.w:Tintinan; DATE:2015-08-03
|
||||
if (!Bry_.Eq(qid, Qid_null) && !page_ttl.Ns().Id_is_special()) // don't write "In other languages" if no qid; also skip Special ns; needed for pages with wbase page, but no sitelinks; PAGE:en.w:Tintinan; DATE:2015-08-03
|
||||
page.Wiki().App().Xwiki_mgr__sitelink_mgr().Write_html(bfr, page.Wikie(), slink_list, qid);
|
||||
}
|
||||
public static byte[] Write_wdata_links(List_adp slink_list, Xowe_wiki wiki, Xoa_ttl ttl, Wdata_external_lang_links_data external_links_mgr) {
|
||||
|
||||
@@ -70,6 +70,18 @@ public class Wdata_dict_val_tid {
|
||||
default : return Str_unknown;
|
||||
}
|
||||
}
|
||||
public static String To_str__srl(byte tid) { // for scrib.wbase
|
||||
switch (tid) {
|
||||
case Tid_string : return Str_string;
|
||||
case Tid_entity : return Str_entity;
|
||||
case Tid_time : return Str_time;
|
||||
case Tid_globecoordinate : return "globe-coordinate";
|
||||
case Tid_quantity : return Str_quantity;
|
||||
case Tid_monolingualtext : return Str_monolingualtext;
|
||||
case Tid_bad : return Str_bad; // NOTE: wikidata identifies several entries as "bad"; Q1615351|'s-Graveland, Q107538|Baco; DATE:2013-10-20
|
||||
default : return Str_unknown;
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(byte[] src) {return Xto_tid(src, 0, src.length);}
|
||||
public static byte Xto_tid(byte[] src, int bgn, int end) {
|
||||
Object bval_obj = Dict.Get_by_mid(src, bgn, end);
|
||||
|
||||
@@ -28,7 +28,7 @@ class Xob_wbase_ns_parser {
|
||||
}
|
||||
public void Find(Xob_wbase_ns_parser_rslt rv, byte[] wiki_abrv, byte[] ttl) { // enwiki, Category:Abc
|
||||
Xow_ns_mgr ns_mgr = (Xow_ns_mgr)ns_mgr_hash.Get_by_bry(wiki_abrv);
|
||||
rv.Init(Xow_ns_.Id_main, 0); // default to Main ns
|
||||
rv.Init(Xow_ns_.Tid__main, 0); // default to Main ns
|
||||
int ttl_len = ttl.length;
|
||||
int colon_pos = Bry_find_.Find_fwd(ttl, Byte_ascii.Colon, 0, ttl_len); if (colon_pos == Bry_find_.Not_found) return;
|
||||
if (ns_mgr == null) { // ns_mgr not found; load from db
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Xob_wdata_db_cmd extends Xob_dump_mgr_base implements Xob_cmd {
|
||||
public Xob_wdata_db_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
@Override public String Cmd_key() {return Xob_cmd_keys.Key_wbase_db;}
|
||||
@Override public byte Init_redirect() {return Bool_.N_byte;} // json will never be found in a redirect
|
||||
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Id_main, Wdata_wiki_mgr.Ns_property);}
|
||||
@Override public int[] Init_ns_ary() {return Int_.Ary(Xow_ns_.Tid__main, Wdata_wiki_mgr.Ns_property);}
|
||||
@Override protected void Init_reset(Db_conn p) {
|
||||
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(p, "xowa_cfg");
|
||||
cfg_tbl.Delete_all();
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class Xob_wdata_qid_base extends Xob_itm_dump_base implements Xo
|
||||
this.Qid_bgn();
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
if (page.Ns_id() != Xow_ns_.Id_main) return; // qid pages are only in the Main namespace
|
||||
if (page.Ns_id() != Xow_ns_.Tid__main) return; // qid pages are only in the Main namespace
|
||||
Json_doc jdoc = parser.Parse(page.Text());
|
||||
if (jdoc == null) {bldr.Usr_dlg().Warn_many("", "", "json is invalid: ns=~{0} id=~{1}", page.Ns_id(), String_.new_u8(page.Ttl_page_db())); return;}
|
||||
this.Parse_jdoc(jdoc);
|
||||
@@ -51,7 +51,7 @@ public abstract class Xob_wdata_qid_base extends Xob_itm_dump_base implements Xo
|
||||
byte[] sitelink_site = sitelink.Site(), sitelink_ttl = sitelink.Name();
|
||||
ns_parser.Find(ns_parser_rslt, sitelink_site, sitelink_ttl);
|
||||
int sitelink_ns = ns_parser_rslt.Ns_id();
|
||||
if (sitelink_ns != Xow_ns_.Id_main) // ttl not in main; chop off ns portion; EX:Aide:French_title -> French_title
|
||||
if (sitelink_ns != Xow_ns_.Tid__main) // ttl not in main; chop off ns portion; EX:Aide:French_title -> French_title
|
||||
sitelink_ttl = Bry_.Mid(sitelink_ttl, ns_parser_rslt.Ttl_bgn(), sitelink_ttl.length);
|
||||
sitelink_ttl = wiki.Lang().Case_mgr().Case_build_1st_upper(tmp_bfr, sitelink_ttl, 0, sitelink_ttl.length);
|
||||
this.Qid_add(sitelink.Site(), sitelink_ns, Xoa_ttl.Replace_spaces(sitelink_ttl), qid); // NOTE: always convert spaces to underscores; EX: "A B" -> "A_B" DATE:2015-04-21
|
||||
|
||||
@@ -60,8 +60,8 @@ public class Xob_wdata_qid_base_tst {
|
||||
// setup db
|
||||
Site_core_db json_db = new Site_core_db(fxt.App().Fsys_mgr().Cfg_site_meta_fil());
|
||||
Site_namespace_tbl ns_tbl = json_db.Tbl__namespace();
|
||||
ns_tbl.Insert(Bry_.new_a7("en.w"), Xow_ns_.Id_help, Xow_ns_case_.Bry__1st, Bry_.Empty, Bry_.new_a7("Help"), Bool_.N, Bool_.N, Bry_.Empty);
|
||||
ns_tbl.Insert(Bry_.new_a7("fr.w"), Xow_ns_.Id_help, Xow_ns_case_.Bry__1st, Bry_.Empty, Bry_.new_a7("Aide"), Bool_.N, Bool_.N, Bry_.Empty);
|
||||
ns_tbl.Insert(Bry_.new_a7("en.w"), Xow_ns_.Tid__help, Xow_ns_case_.Bry__1st, Bry_.Empty, Bry_.new_a7("Help"), Bool_.N, Bool_.N, Bry_.Empty);
|
||||
ns_tbl.Insert(Bry_.new_a7("fr.w"), Xow_ns_.Tid__help, Xow_ns_case_.Bry__1st, Bry_.Empty, Bry_.new_a7("Aide"), Bool_.N, Bool_.N, Bry_.Empty);
|
||||
// run test
|
||||
fxt.doc_ary_
|
||||
( fxt.doc_wo_date_(1, "11", Xob_wdata_pid_base_tst.json_("q1", "links", String_.Ary("enwiki", "Help:Q1_en", "frwiki", "Aide:Q1_fr")))
|
||||
|
||||
@@ -41,9 +41,9 @@ public class Wdata_pf_property extends Pf_func_base {
|
||||
Wdata_pf_property_data data = new Wdata_pf_property_data();
|
||||
data.Init_by_parse(ctx, src, caller, self, this, id);
|
||||
Wdata_doc prop_doc = wdata_mgr.Pages_get(wiki, ttl, data); if (prop_doc == null) return; // NOTE: some pages will not exist in qid; EX: {{#property:P345}} for "Unknown_page" will not even had a qid; if no qid, then no pid
|
||||
int pid = data.Id_int();
|
||||
if (pid == Wdata_wiki_mgr.Pid_null)
|
||||
pid = wdata_mgr.Pids_get(wiki.Wdata_wiki_lang(), data.Id());
|
||||
int pid = data.Id_int(); // check if arg is number; EX: {{#property:p1}}
|
||||
if (pid == Wdata_wiki_mgr.Pid_null) // arg is name of property; EX: {{#property:name}}
|
||||
pid = wdata_mgr.Pids__get_by_name(wiki.Wdata_wiki_lang(), data.Id());
|
||||
if (pid == Wdata_wiki_mgr.Pid_null) {Print_self(app.Usr_dlg(), bfr, src, self, "prop_not_found", "prop id not found: ~{0} ~{1} ~{2}", wiki.Domain_str(), ttl.Page_db_as_str(), data.Id()); return;}
|
||||
Wdata_claim_grp prop_grp = prop_doc.Claim_list_get(pid); if (prop_grp == null) return;// NOTE: some props may not exist; EX: {{#property:P345}} for "Unknown_movie" may have a qid, but doesn't have a defined pid
|
||||
wdata_mgr.Resolve_to_bfr(bfr, prop_grp, wiki.Wdata_wiki_lang()); // NOTE: was ctx.Cur_page().Lang().Key_bry(), but fails in simplewiki; DATE:2013-12-02
|
||||
|
||||
Reference in New Issue
Block a user