diff --git a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java
index 6d05b086e..6b7e1e575 100644
--- a/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java
+++ b/400_xowa/src/gplx/xowa/addons/bldrs/centrals/hosts/Host_eval_wkr.java
@@ -27,9 +27,11 @@ public class Host_eval_wkr implements Bry_eval_wkr {
int type = hash.Get_as_byte_or(src, args_bgn, args_end, Byte_.Max_value_127);
switch (type) {
case Type__wiki_abrv:
- // handle wikidata separately; DATE:2016-10-19
- if (String_.Eq(domain_itm.Domain_str(), "www.wikidata.org"))
+ // handle wikidata, commonswiki separately; DATE:2016-10-20
+ if (String_.Eq(domain_itm.Domain_str(), "www.wikidata.org"))
rv.Add_str_a7("wikidatawiki");
+ else if (String_.Eq(domain_itm.Domain_str(), "commons.wikimedia.org"))
+ rv.Add_str_a7("commonswiki");
// do not use Abrv_mw(); all other wikis will be "generalized" to their language url; EX:"en.wiktionary.org" -> "enwiki" x> "enwiktionary"
else {
byte[] lang_key = domain_itm.Lang_orig_key();
diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip.java
index ceffe3719..aefb43507 100644
--- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip.java
+++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip.java
@@ -244,7 +244,11 @@ public class Xoh_img_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|| href_ns_id != Xow_ns_.Tid__main) { // or if site and !main_ns; handles /site/en.wiktionary.org/wiki/Special:Search but not /site/creativecommons.org/wiki/by/2.5; DATE:2015-12-28
if (href_page.length == 0) { // handle invalid titles in link arg; EX:[[File:A.png|link=wikt:]]; PAGE:en.w:List_of_Saint_Petersburg_Metro_stations; DATE:2016-01-04
Xow_ns href_ns = hctx.Wiki__ttl_parser().Ns_mgr().Ids_get_or_null(href_ns_id);
- ttl_full = href_ns.Name_db_w_colon(); // ASSUME:use db_name not ui_name; EX: "Category_talk" vs "Category talk"
+
+ // 2 notes:
+ // (1) use db_name not ui_name; EX: "Category_talk" vs "Category talk"
+ // (2) use canonical name, not local name; EX: "Help:A" not "Aide:A"; DATE:2016-10-28
+ ttl_full = Xow_ns_canonical_.To_canonical_or_local_as_bry_w_colon(href_ns);
}
else {
if (anch__ns_is_custom) // handle ns aliases; EX: "Image:Page"; EX:WP; PAGE:en.w:Wikipedia:WikiProject_Molecular_and_Cell_Biology; DATE:2016-01-11
diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip__dump__link__tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip__dump__link__tst.java
index d18411cd8..518520f56 100644
--- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip__dump__link__tst.java
+++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/imgs/Xoh_img_hzip__dump__link__tst.java
@@ -108,4 +108,12 @@ public class Xoh_img_hzip__dump__link__tst {
, ""
));
}
+ @Test public void Link__xwiki_foreign() { // PURPOSE:ns in linked wikis should use canonical name, not current wiki's name PAGE:pl.w:Terytoria_Północno-Zachodnie DATE:2016-10-28
+ fxt.Wiki().Ns_mgr().Ids_get_or_null(gplx.xowa.wikis.nss.Xow_ns_.Tid__help).Name_bry_(Bry_.new_a7("Aide")); // simulate non-English wiki with non-english names
+ fxt.Test__bicode // fails if "Aide:" instead of "Help:"
+ ( "~%.qen.wiktionary.org|~A.png~/Help~)#Sabc~"
+ , "
"
+ );
+ fxt.Wiki().Ns_mgr().Ids_get_or_null(gplx.xowa.wikis.nss.Xow_ns_.Tid__help).Name_bry_(Bry_.new_a7("Help")); // revert
+ }
}
diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__basic__tst.java
similarity index 97%
rename from 400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__tst.java
rename to 400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__basic__tst.java
index 32ecaec9c..a5c2969f0 100644
--- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__tst.java
+++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__basic__tst.java
@@ -17,7 +17,7 @@ along with this program. If not, see .
*/
package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
import org.junit.*; import gplx.xowa.files.*;
-public class Xoh_file_wtr__image__tst {
+public class Xoh_file_wtr__image__basic__tst {
private final Xop_fxt fxt = new Xop_fxt();
@Before public void init() {fxt.Reset();}
@Test public void Img__full() { // PURPOSE: full with title was outputting invalid html; DATE:2013-12-31
diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__link__tst.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__link__tst.java
new file mode 100644
index 000000000..7747f7522
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_file_wtr__image__link__tst.java
@@ -0,0 +1,46 @@
+/*
+XOWA: the XOWA Offline Wiki Application
+Copyright (C) 2012 gnosygnu@gmail.com
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
+import org.junit.*; import gplx.xowa.files.*;
+public class Xoh_file_wtr__image__link__tst {
+ private final Xop_fxt fxt = new Xop_fxt();
+ @Before public void init() {fxt.Reset();}
+ @Test public void Link__file() { // PURPOSE.FIX: link=file:/// was creating "href='/wiki/file'" handle IPA links; EX:[[File:Speakerlink-new.svg|11px|link=file:///C:/xowa/file/commons.wikimedia.org/orig/c/7/a/3/En-LudwigVanBeethoven.ogg|Listen]]; PAGE:en.w:Beethoven DATE:2015-12-28
+ fxt.Test_parse_page_wiki_str
+ ( "[[File:A.png|11px|link=file:///C:/A.ogg|b]]", String_.Concat_lines_nl_skip_last
+ ( ""
+ + "
"
+ + ""
+ ));
+ }
+ @Test public void Link__empty() { // empty link should not create anchor; EX:[[File:A.png|link=|abc]]; PAGE:en.w:List_of_counties_in_New_York; DATE:2016-01-10
+ fxt.Test_parse_page_wiki_str
+ ( "[[File:A.png|11px|link=|abc]]", String_.Concat_lines_nl_skip_last
+ ( "
"
+ ));
+ }
+ @Test public void Link__lc() { // links to items in same Srch_rslt_cbk should automatically title-case words; DATE:2016-01-11
+ fxt.Init_xwiki_add_wiki_and_user_("en", "en.wikipedia.org");
+ fxt.Test_parse_page_wiki_str
+ ( "[[File:A.png|11px|link=en:Help:a?b=c#d|abc]]", String_.Concat_lines_nl_skip_last
+ ( "" // "Help:A" not "Help:a"
+ + "
"
+ + ""));
+ fxt.Init_xwiki_clear();
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/wikis/nss/Xow_ns_canonical_.java b/400_xowa/src/gplx/xowa/wikis/nss/Xow_ns_canonical_.java
index 360fda042..393e14287 100644
--- a/400_xowa/src/gplx/xowa/wikis/nss/Xow_ns_canonical_.java
+++ b/400_xowa/src/gplx/xowa/wikis/nss/Xow_ns_canonical_.java
@@ -101,4 +101,30 @@ public class Xow_ns_canonical_ {
default: return ns.Name_ui();
}
}
+ public static byte[] To_canonical_or_local_as_bry_w_colon(Xow_ns ns) {
+ byte[] rv = null;
+ switch (ns.Id()) {
+ case Xow_ns_.Tid__media: rv = Xow_ns_.Bry__media; break;
+ case Xow_ns_.Tid__special: rv = Xow_ns_.Bry__special; break;
+ case Xow_ns_.Tid__talk: rv = Xow_ns_.Bry__talk; break;
+ case Xow_ns_.Tid__user: rv = Xow_ns_.Bry__user; break;
+ case Xow_ns_.Tid__user_talk: rv = Xow_ns_.Bry__user_talk; break;
+ case Xow_ns_.Tid__project: rv = Xow_ns_.Bry__project; break;
+ case Xow_ns_.Tid__project_talk: rv = Xow_ns_.Bry__project_talk; break;
+ case Xow_ns_.Tid__file: rv = Xow_ns_.Bry__file; break;
+ case Xow_ns_.Tid__file_talk: rv = Xow_ns_.Bry__file_talk; break;
+ case Xow_ns_.Tid__mediawiki: rv = Xow_ns_.Bry__mediawiki; break;
+ case Xow_ns_.Tid__mediawiki_talk: rv = Xow_ns_.Bry__mediawiki_talk; break;
+ case Xow_ns_.Tid__template: rv = Xow_ns_.Bry__template; break;
+ case Xow_ns_.Tid__template_talk: rv = Xow_ns_.Bry__template_talk; break;
+ case Xow_ns_.Tid__help: rv = Xow_ns_.Bry__help; break;
+ case Xow_ns_.Tid__help_talk: rv = Xow_ns_.Bry__help_talk; break;
+ case Xow_ns_.Tid__category: rv = Xow_ns_.Bry__category; break;
+ case Xow_ns_.Tid__category_talk: rv = Xow_ns_.Bry__category_talk; break;
+ case Xow_ns_.Tid__module: rv = Xow_ns_.Bry__module; break;
+ case Xow_ns_.Tid__module_talk: rv = Xow_ns_.Bry__module_talk; break;
+ default: return ns.Name_db_w_colon();
+ }
+ return Bry_.Add(rv, Byte_ascii.Colon_bry);
+ }
}