mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.12.1.1
This commit is contained in:
@@ -16,8 +16,20 @@ 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.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
|
||||
import gplx.core.bits.*;
|
||||
public class Xop_lnki_type {
|
||||
public static final byte Id_null = 0, Id_none = 1, Id_frameless = 2, Id_frame = 4, Id_thumb = 8;
|
||||
public static final byte Tid_null = 0, Tid_none = 1, Tid_frameless = 2, Tid_frame = 3, Tid_thumb = 4; // SERIALIZED
|
||||
public static byte To_tid(byte flag) {
|
||||
switch (flag) {
|
||||
case Xop_lnki_type.Id_null: return Xop_lnki_type.Tid_null;
|
||||
case Xop_lnki_type.Id_none: return Xop_lnki_type.Tid_none;
|
||||
case Xop_lnki_type.Id_frameless: return Xop_lnki_type.Tid_frameless;
|
||||
case Xop_lnki_type.Id_frame: return Xop_lnki_type.Tid_frame;
|
||||
case Xop_lnki_type.Id_thumb: return Xop_lnki_type.Tid_thumb;
|
||||
default: throw Err_.new_unhandled(flag);
|
||||
}
|
||||
}
|
||||
public static boolean Id_is_thumbable(byte id) {
|
||||
return ( Bitmask_.Has_int(id, Id_thumb) // for purposes of displaying images on page, thumb and frame both create a thumb box
|
||||
|| Bitmask_.Has_int(id, Id_frame)
|
||||
|
||||
@@ -265,14 +265,26 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
@Test public void Encoded_url() { // PURPOSE.fix: url-encoded characters broke parser when embedded in link; DATE:2013-03-01
|
||||
fxt.Init_xwiki_add_user_("commons.wikimedia.org");
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|link=//commons.wikimedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0?uselang=ru|b]]"
|
||||
, "<a href=\"/site/commons.wikimedia.org/wiki/Заглавная_страница?uselang=ru\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>");
|
||||
, "<a href=\"/site/commons.wikimedia.org/wiki/%D0%97%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%BD%D0%B0%D1%8F_%D1%81%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D0%B0?uselang=ru\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>");
|
||||
}
|
||||
@Test public void Link_invalid() { // PURPOSE.fix: do not render invalid text; EX: link={{{1}}}; [[Fil:Randers_-_Hadsund_railway.png|120x160px|link={{{3}}}|Randers-Hadsund Jernbane]]; DATE:2013-03-04
|
||||
@Test public void Link__invalid() { // PURPOSE.fix: do not render invalid text; EX: link={{{1}}}; [[Fil:Randers_-_Hadsund_railway.png|120x160px|link={{{3}}}|Randers-Hadsund Jernbane]]; DATE:2013-03-04
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|12x10px|link={{{1}}}|c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"c\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" /></a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link__html_ent() {// PURPOSE:html entities should be converted to chars; EX: -> _; DATE:2013-12-16
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|link=b c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/B_c\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link__encode() {// PURPOSE:spaces should become underscore; DATE:2015-11-27
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|link=File:A b ç.ogg]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A_b_%C3%A7.ogg\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
));
|
||||
}
|
||||
@Test public void Href_anchor_leading_space() { // PURPOSE: ?action=edit should be encoded; DATE:2013-02-10
|
||||
fxt.Test_parse_page_all_str("[[A #b]]", "<a href=\"/wiki/A#b\">A #b</a>");
|
||||
}
|
||||
@@ -292,19 +304,13 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
fxt.Test_parse_page_all_str("[[Ab]]çd e", "<a href=\"/wiki/Ab\">Abçd</a> e");
|
||||
lnki_trail_mgr.Del(ltr_c_in_french);
|
||||
}
|
||||
@Test public void Link_html_ent() {// PURPOSE:html entities should be converted to chars; EX: -> _; DATE:2013-12-16
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|link=b c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/B_c\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" /></a>"
|
||||
));
|
||||
}
|
||||
@Test public void Page() {
|
||||
fxt.Test_parse_page_wiki("[[File:A.pdf|page=12]]" , fxt.tkn_lnki_().Page_(12));
|
||||
}
|
||||
@Test public void Visited() { // PURPOSE: show redirected titles as visited; EX:fr.w:Alpes_Pennines; DATE:2014-02-28
|
||||
Xowe_wiki wiki = fxt.Wiki();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7("Src")); // simulate requrest for "Src" page
|
||||
Xoae_page previous_page = Xoae_page.test_(wiki, ttl);
|
||||
Xoae_page previous_page = Xoae_page.New_test(wiki, ttl);
|
||||
previous_page.Redirected_ttls().Add(Bry_.new_a7("Src")); // simulate redirect from "Src"
|
||||
fxt.App().Usere().History_mgr().Add(previous_page); // simulate "Src" already being clicked once; this is the key call
|
||||
fxt.Wtr_cfg().Lnki_visited_y_();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xop_lnki_wkr__link_tst {
|
||||
@Test public void Link_file_system() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[File:A.png|12x10px|link=file:///C/B.png|c]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"file:///C/B.png\" class=\"image\" xowa_title=\"B.png\"><img id=\"xowa_file_img_0\" alt=\"c\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" /></a>"
|
||||
( "<a href=\"file:///C/B.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"c\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" /></a>"
|
||||
));
|
||||
}
|
||||
@Test public void Link_file_ns() {
|
||||
|
||||
Reference in New Issue
Block a user