From c7f54287af2cf7b1bbd21444213062f25ed3f3a8 Mon Sep 17 00:00:00 2001 From: gnosygnu Date: Sun, 2 Jun 2019 21:11:51 -0400 Subject: [PATCH] Html: Change self-link pages from to [#478] --- .../htmls/core/htmls/Xoh_html_wtr_tst.java | 2 +- .../core/wkrs/lnkis/htmls/Xoh_lnki_wtr.java | 19 ++++++++++++------- .../proofreadPage/Pp_pages_nde_hdr_tst.java | 10 +++++----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java b/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java index be16a461e..be75f3338 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java +++ b/400_xowa/src/gplx/xowa/htmls/core/htmls/Xoh_html_wtr_tst.java @@ -37,7 +37,7 @@ public class Xoh_html_wtr_tst { } @Test public void Lnki_category() {fxt.Test_parse_page_wiki_str("[[Category:A]]" , "");} // NOTE: Category does not get written in main page bfr @Test public void Lnki_category_force() {fxt.Test_parse_page_wiki_str("[[:Category:A]]" , "Category:A");} - @Test public void Lnki_matches_page() {fxt.Test_parse_page_wiki_str("[[test page|t1]]", "t1");} // NOTE: "Test page" is hardcoded to be the test page name + @Test public void Lnki_matches_page() {fxt.Test_parse_page_wiki_str("[[test page|t1]]", "t1");} // NOTE: "Test page" is hardcoded to be the test page name @Test public void Lnki_matches_page_but_has_anchor() {fxt.Test_parse_page_wiki_str("[[Test page#a|test 1]]", "test 1");} // NOTE: "Test page" is hardcoded to be the test page name @Test public void Lnki_anchor() {fxt.Test_parse_page_wiki_str("[[A#b]]" , "A#b");} // @Test public void Img_invalid_wnt_char() { diff --git a/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_lnki_wtr.java b/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_lnki_wtr.java index 39617e90c..751805b0c 100644 --- a/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_lnki_wtr.java +++ b/400_xowa/src/gplx/xowa/htmls/core/wkrs/lnkis/htmls/Xoh_lnki_wtr.java @@ -102,14 +102,18 @@ public class Xoh_lnki_wtr { private void Write_plain(Bry_bfr bfr, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xoa_ttl lnki_ttl, Xop_lnki_caption_wtr caption_wkr) { byte[] ttl_bry = lnki.Ttl_ary(); if (Bry_.Len_eq_0(ttl_bry)) ttl_bry = lnki_ttl.Full_txt_raw(); // NOTE: handles ttls like [[fr:]] and [[:fr;]] which have an empty Page_txt, but a valued Full_txt_raw - if (Bry_.Eq(lnki_ttl.Full_txt_by_orig(), page.Ttl().Full_txt_by_orig())) { // lnki is same as pagename; bold; SEE: Month widget on day pages will bold current day; PAGE:en.w:January 1 - if (lnki_ttl.Anch_bgn() == -1 && Bry_.Eq(lnki_ttl.Wik_txt(), page.Ttl().Wik_txt())) { // only bold if lnki is not pointing to anchor on same page; PAGE:en.w:Comet; [[Comet#Physical characteristics|ion tail]] - bfr.Add(Gfh_tag_.B_lhs); - Write_caption(bfr, ctx, hctx, src, lnki, ttl_bry, true, caption_wkr); - bfr.Add(Gfh_tag_.B_rhs); - return; - } + + // lnki is same as pagename; PAGE:en.w:January 1 + if ( Bry_.Eq(lnki_ttl.Full_txt_by_orig(), page.Ttl().Full_txt_by_orig()) + && lnki_ttl.Anch_bgn() == -1 && Bry_.Eq(lnki_ttl.Wik_txt(), page.Ttl().Wik_txt())) { // only bold if lnki is not pointing to anchor on same page; PAGE:en.w:Comet; [[Comet#Physical characteristics|ion tail]] + bfr.Add(Gfh_bldr_.Bry__a_lhs_bgn); + Gfh_wtr.Write_atr_bry(bfr, Gfh_atr_.Bry__class, Bry__selflink); + bfr.Add(Gfh_bldr_.Bry__lhs_end_head); + Write_caption(bfr, ctx, hctx, src, lnki, ttl_bry, true, caption_wkr); + bfr.Add(Gfh_bldr_.Bry__a_rhs); + return; } + if (lnki.Xtn_sites_link()) return; // lnki marked for relatedSites; don't write to page page.Stat_itm().Lnki_count++; if (hctx.Mode_is_alt()) @@ -195,6 +199,7 @@ public class Xoh_lnki_wtr { return history_mgr.Has(wiki_key, page_ttl) ? Lnki_cls_visited_bry : Bry_.Empty; } private static final byte[] Lnki_cls_visited_bry = Bry_.new_a7(" class=\"xowa-visited\""); private static final byte[] Bry_xowa_visited = Bry_.new_a7("\" class=\"xowa-visited"); + private static final byte[] Bry__selflink = Bry_.new_a7("mw-selflink selflink"); public static final int Lnki_id_ignore = 0, Lnki_id_min = 1; } interface Xop_lnki_caption_wtr { diff --git a/400_xowa/src/gplx/xowa/xtns/proofreadPage/Pp_pages_nde_hdr_tst.java b/400_xowa/src/gplx/xowa/xtns/proofreadPage/Pp_pages_nde_hdr_tst.java index 52115842c..cf0d3f7fc 100644 --- a/400_xowa/src/gplx/xowa/xtns/proofreadPage/Pp_pages_nde_hdr_tst.java +++ b/400_xowa/src/gplx/xowa/xtns/proofreadPage/Pp_pages_nde_hdr_tst.java @@ -74,7 +74,7 @@ public class Pp_pages_nde_hdr_tst { // next only fxt.Page_ttl_("Page/1"); fxt.Test_parse_page_wiki_str("", String_.Concat_lines_nl - ( "

value=toc;current=Page/1;next=Page/2;" + ( "

value=toc;current=Page/1;next=Page/2;" , "

" , "" , "


" @@ -84,7 +84,7 @@ public class Pp_pages_nde_hdr_tst { // next and prev fxt.Page_ttl_("Page/2"); fxt.Test_parse_page_wiki_str("", String_.Concat_lines_nl - ( "

value=toc;current=Page/2;prev=Page/1;next=Page/3;" + ( "

value=toc;current=Page/2;prev=Page/1;next=Page/3;" , "

" , "" , "


" @@ -94,7 +94,7 @@ public class Pp_pages_nde_hdr_tst { // prev only fxt.Page_ttl_("Page/3"); fxt.Test_parse_page_wiki_str("", String_.Concat_lines_nl - ( "

value=toc;current=Page/3;prev=Page/2;" + ( "

value=toc;current=Page/3;prev=Page/2;" , "

" , "" , "


" @@ -129,7 +129,7 @@ public class Pp_pages_nde_hdr_tst { fxt.Page_ttl_("Page/2"); fxt.Test_parse_page_wiki_str("", String_.Concat_lines_nl - ( "

value=toc;current=Page/2;prev=Caption_1;next=Page/3;" + ( "

value=toc;current=Page/2;prev=Caption_1;next=Page/3;" , "

" , "" , "


" @@ -145,7 +145,7 @@ public class Pp_pages_nde_hdr_tst { // next only fxt.Page_ttl_("Page/1"); fxt.Test_parse_page_wiki_str("", String_.Concat_lines_nl - ( "

value=toc;current=Page/1;next=File:A.png;" + ( "

value=toc;current=Page/1;next=File:A.png;" , "

" , "" , "


"