mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-13 12:54:14 +00:00
Parser: Show page name for [[Media:]] links without caption (XOWA-122)
This commit is contained in:
parent
ffe4c0d094
commit
3b4a3a5af5
@ -85,8 +85,14 @@ public class Xoh_file_wtr__basic implements Gfo_invk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// main html build
|
// main html build
|
||||||
if (lnki.Ns_id() == Xow_ns_.Tid__media) // NOTE: regardless of ext (ogg vs jpeg) and literal status (Media vs :Media), [[Media]] links are always rendered the same way; REF.MW:Linker.php|makeMediaLinkObj; PAGE:en.w:Beethoven; EX: [[:Media:De-Ludwig_van_Beethoven.ogg|listen]]); [[File:Beethoven 3.jpg|The [[Media:BeethovenWithLyreGuitar( W. J. Mahler - 1804).jpg|complete painting]]...]]
|
// if [[Media:]], (a) render like any other ns, not [[File:]]; (b) doo not add to download queue; REF.MW:Linker.php|makeMediaLinkObj;
|
||||||
html_fmtr.Add_media(bfr, hctx.Mode_is_hdump(), img_orig_src, lnki_ttl_bry, Bld_caption(ctx, Xoh_wtr_ctx.Basic, src, lnki)); // NOTE: use orig_src not view_src; DATE:2014-01-19
|
// PAGE:en.w:Beethoven; EX: [[:Media:De-Ludwig_van_Beethoven.ogg|listen]]); [[File:Beethoven 3.jpg|The [[Media:BeethovenWithLyreGuitar( W. J. Mahler - 1804).jpg|complete painting]]...]]
|
||||||
|
if (lnki.Ns_id() == Xow_ns_.Tid__media) {
|
||||||
|
byte[] media_html = lnki.Caption_exists()
|
||||||
|
? caption_fmtr.To_bry(ctx, hctx, src, lnki.Caption_val_tkn(), Bool_.N, Xoh_lnki_text_fmtr.Null__fmt)
|
||||||
|
: lnki.Ttl().Full_db();
|
||||||
|
html_fmtr.Add_media(bfr, hctx.Mode_is_hdump(), img_orig_src, lnki_ttl_bry, media_html); // NOTE: use orig_src not view_src; DATE:2014-01-19
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// orig_is_video
|
// orig_is_video
|
||||||
boolean orig_is_video = Xof_ext_.Id_is_video_strict(orig_ext.Id());
|
boolean orig_is_video = Xof_ext_.Id_is_video_strict(orig_ext.Id());
|
||||||
|
@ -16,14 +16,20 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
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.*;
|
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 org.junit.*;
|
||||||
public class Xoh_file_wtr__media__tst {
|
public class Xoh_file_wtr__media__tst {
|
||||||
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
@Before public void init() {fxt.Reset();} private final Xop_fxt fxt = new Xop_fxt();
|
||||||
@Test public void Lnki_caption_nested_media() { // PAGE:en.w:Beethoven;
|
@Test public void Page_only() { // if no caption, then use page name; DATE:2017-05-20
|
||||||
fxt.Test_parse_page_wiki_str("[[File:A.png|thumb|b [[Media:A.ogg]] c]]", String_.Concat_lines_nl_skip_last
|
fxt.Test_parse_page_wiki_str("[[Media:A.png]]", String_.Concat_lines_nl_skip_last
|
||||||
|
( "<a href=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" xowa_title=\"A.png\">Media:A.png"
|
||||||
|
, "</a>"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
@Test public void Nested_caption() { // PAGE:en.w:Beethoven;
|
||||||
|
fxt.Test_parse_page_wiki_str("[[File:A.png|thumb|b [[Media:A.ogg|media_caption]] c]]", String_.Concat_lines_nl_skip_last
|
||||||
( "<div class=\"thumb tright\">"
|
( "<div class=\"thumb tright\">"
|
||||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
|
||||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"0\" height=\"0\" /></a>"
|
, " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/220px.png\" width=\"0\" height=\"0\" /></a>"
|
||||||
, " <div class=\"thumbcaption\">"
|
, " <div class=\"thumbcaption\">"
|
||||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>b <a href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\">"
|
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>b <a href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\">media_caption"
|
||||||
, "</a> c"
|
, "</a> c"
|
||||||
, " </div>"
|
, " </div>"
|
||||||
, " </div>"
|
, " </div>"
|
||||||
@ -31,19 +37,19 @@ public class Xoh_file_wtr__media__tst {
|
|||||||
, ""
|
, ""
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@Test public void Lnki_media_normal() {
|
@Test public void Caption() {
|
||||||
fxt.Test_parse_page_wiki_str("[[Media:A.png|b]]", String_.Concat_lines_nl_skip_last
|
fxt.Test_parse_page_wiki_str("[[Media:A.png|b]]", String_.Concat_lines_nl_skip_last
|
||||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" xowa_title=\"A.png\">b"
|
( "<a href=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" xowa_title=\"A.png\">b"
|
||||||
, "</a>"
|
, "</a>"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@Test public void Lnki_media_literal() {
|
@Test public void Literal() {
|
||||||
fxt.Test_parse_page_wiki_str("[[:Media:A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
fxt.Test_parse_page_wiki_str("[[:Media:A.ogg|b]]", String_.Concat_lines_nl_skip_last
|
||||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\">b"
|
( "<a href=\"file:///mem/wiki/repo/trg/orig/4/2/A.ogg\" xowa_title=\"A.ogg\">b"
|
||||||
, "</a>"
|
, "</a>"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@Test public void Lnki_media_literal_pdf() {
|
@Test public void Literal_w_missing() {
|
||||||
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(true); // simulate missing file; DATE:2014-01-30
|
fxt.Wiki().Html_mgr().Img_suppress_missing_src_(true); // simulate missing file; DATE:2014-01-30
|
||||||
fxt.Test_parse_page_wiki_str("[[Media:A.pdf|b]]", String_.Concat_lines_nl_skip_last
|
fxt.Test_parse_page_wiki_str("[[Media:A.pdf|b]]", String_.Concat_lines_nl_skip_last
|
||||||
( "<a href=\"file:///mem/wiki/repo/trg/orig/e/f/A.pdf\" xowa_title=\"A.pdf\">b"
|
( "<a href=\"file:///mem/wiki/repo/trg/orig/e/f/A.pdf\" xowa_title=\"A.pdf\">b"
|
||||||
|
Loading…
Reference in New Issue
Block a user