mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Hzip: Use canonical name, not local name, for images linking to namespaces in other wikis
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -108,4 +108,12 @@ public class Xoh_img_hzip__dump__link__tst {
|
||||
, "</a>"
|
||||
));
|
||||
}
|
||||
@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~"
|
||||
, "<a href='/site/en.wiktionary.org/wiki/Help:' class='image' title='abc' xowa_title='A.png'><img data-xowa-title='A.png' data-xoimg='0|220|-1|-1|-1|-1' src='' width='0' height='0' alt='abc'></a>"
|
||||
);
|
||||
fxt.Wiki().Ns_mgr().Ids_get_or_null(gplx.xowa.wikis.nss.Xow_ns_.Tid__help).Name_bry_(Bry_.new_a7("Help")); // revert
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
( "<a href=\"file:///C:/A.ogg\" class=\"image\" xowa_title=\"A.ogg\">"
|
||||
+ "<img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"
|
||||
));
|
||||
}
|
||||
@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
|
||||
( "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
));
|
||||
}
|
||||
@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
|
||||
( "<a href=\"/wiki/Help:A?b=c#d\" class=\"image\" xowa_title=\"A.png\">" // "Help:A" not "Help:a"
|
||||
+ "<img id=\"xoimg_0\" alt=\"abc\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/11px.png\" width=\"11\" height=\"0\" />"
|
||||
+ "</a>"));
|
||||
fxt.Init_xwiki_clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user