mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Search: Fix no search results for en.d [#606]
This commit is contained in:
parent
11810c4fff
commit
e2aa551feb
@ -41,7 +41,7 @@ class Srch_rslt_cbk__js implements Srch_rslt_cbk {
|
||||
Srch_rslt_row row = rslts_list.Get_at(i);
|
||||
Highlight(ctx, row); // always highlight title first; needed for suggest_box to update highlighting when increasing word; EX: Eart -> Earth; "Earth" should be highlighted, not "Eart"
|
||||
js_wtr.Ary_bry(row.Page_ttl.Full_txt_w_ttl_case());
|
||||
js_wtr.Ary_bry(row.Page_ttl_display(Bool_.Y));
|
||||
js_wtr.Ary_bry(row.To_display(Srch_rslt_row.Display_type__suggest));
|
||||
}
|
||||
js_wtr.Ary_term();
|
||||
js_wtr.Func_term();
|
||||
|
@ -51,7 +51,7 @@ public class Srch_rslt_cbk__url_bar implements Srch_rslt_cbk, Gfo_invk {
|
||||
if (i >= max_results) break;
|
||||
if (i < rslts_len) {
|
||||
Srch_rslt_row rslt = rslts_list.Get_at(i);
|
||||
cbo_itm = String_.new_u8(rslt.Page_ttl_display(Bool_.N));
|
||||
cbo_itm = String_.new_u8(rslt.To_display(Srch_rslt_row.Display_type__url_bar));
|
||||
}
|
||||
cbo_ary[i] = cbo_itm;
|
||||
}
|
||||
|
@ -33,16 +33,28 @@ public class Srch_rslt_row {
|
||||
public final int Page_ns;
|
||||
public final byte[] Page_ttl_wo_ns;
|
||||
public final int Page_len;
|
||||
public final int Page_redirect_id;
|
||||
public int Page_redirect_id;
|
||||
public final int Page_score;
|
||||
public byte[] Page_redirect_ttl;
|
||||
public byte[] Page_ttl_highlight;
|
||||
public byte[] Page_ttl_display(boolean html) {
|
||||
byte[] rv = html ? Page_ttl_highlight : Page_ttl.Full_txt_w_ttl_case();
|
||||
public byte[] Page_ttl_highlight;
|
||||
|
||||
public byte[] To_display(int display_type) {
|
||||
// NOTE: use Highlight for suggest only; note that url_bar also sets Highlight
|
||||
byte[] rv
|
||||
= display_type == Srch_rslt_row.Display_type__suggest
|
||||
? this.Page_ttl_highlight
|
||||
: Page_ttl.Full_txt_w_ttl_case();
|
||||
|
||||
// no redirect; just return it; EX: "Actual page"
|
||||
if (Page_redirect_id == Page_redirect_id_null)
|
||||
return rv;
|
||||
// redirect exists; add it to display; EX: "Redirect -> Actual page"
|
||||
else {
|
||||
byte[] redirect_dlm = html ? Bry__redirect__html : Bry__redirect__text;
|
||||
// NOTE: "→" does not work for SWT GUI
|
||||
byte[] redirect_dlm
|
||||
= display_type == Srch_rslt_row.Display_type__url_bar
|
||||
? Bry__redirect__text
|
||||
: Bry__redirect__html;
|
||||
return Bry_.Add(rv, redirect_dlm, Page_redirect_ttl);
|
||||
}
|
||||
}
|
||||
@ -56,4 +68,9 @@ public class Srch_rslt_row {
|
||||
private static final byte[]
|
||||
Bry__redirect__html = Bry_.new_u8(" → ") // 8592; 8594
|
||||
, Bry__redirect__text = Bry_.new_a7(Str__redirect__text);
|
||||
public static final int
|
||||
Display_type__url_bar = 1
|
||||
, Display_type__suggest = 2
|
||||
, Display_type__special_page = 3
|
||||
;
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.addons.wikis.searchs.searchers.rslts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.searchs.*; import gplx.xowa.addons.wikis.searchs.searchers.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Srch_rslt_row_tst {
|
||||
private final Srch_rslt_row_fxt fxt = new Srch_rslt_row_fxt();
|
||||
@Test public void To_display() {
|
||||
Srch_rslt_row row_straight = fxt.Make__row_straight("Ab", "<b>A</b>b");
|
||||
Srch_rslt_row row_redirect = fxt.Make__row_redirect("Ab", "<b>A</b>b", "C");
|
||||
|
||||
int type = Srch_rslt_row.Display_type__suggest;
|
||||
fxt.Test__To_display(row_straight, type, "<b>A</b>b");
|
||||
fxt.Test__To_display(row_redirect, type, "<b>A</b>b → C");
|
||||
|
||||
type = Srch_rslt_row.Display_type__url_bar;
|
||||
fxt.Test__To_display(row_straight, type, "Ab");
|
||||
fxt.Test__To_display(row_redirect, type, "Ab -> C");
|
||||
|
||||
type = Srch_rslt_row.Display_type__special_page;
|
||||
fxt.Test__To_display(row_straight, type, "Ab");
|
||||
fxt.Test__To_display(row_redirect, type, "Ab → C");
|
||||
}
|
||||
}
|
||||
class Srch_rslt_row_fxt {
|
||||
private final Xow_wiki wiki;
|
||||
public Srch_rslt_row_fxt() {
|
||||
Xoa_app app = Xoa_app_fxt.Make__app__view();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__view(app);
|
||||
}
|
||||
public void Test__To_display(Srch_rslt_row row, int type, String expd) {
|
||||
Gftest.Eq__bry(Bry_.new_u8(expd), row.To_display(type));
|
||||
}
|
||||
public Srch_rslt_row Make__row_straight(String ttl, String highlight) {
|
||||
Srch_rslt_row rv = Srch_rslt_row.New(wiki.Domain_bry(), wiki.Ttl_parse(Bry_.new_u8(ttl)), 123, 100, 999, Srch_rslt_row.Page_redirect_id_null);
|
||||
rv.Page_ttl_highlight = Bry_.new_u8(highlight);
|
||||
return rv;
|
||||
}
|
||||
public Srch_rslt_row Make__row_redirect(String ttl, String highlight, String redirect) {
|
||||
Srch_rslt_row rv = Make__row_straight(ttl, highlight);
|
||||
rv.Page_redirect_id = 321;
|
||||
rv.Page_redirect_ttl = Bry_.new_u8(redirect);
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -77,7 +77,6 @@ class Srch_html_page_bldr_fxt {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
++page_id;
|
||||
Srch_rslt_row rv = new Srch_rslt_row(Srch_rslt_row.Bld_key(wiki_bry, page_id), wiki_bry, wiki.Ttl_parse(ttl_bry), gplx.xowa.wikis.nss.Xow_ns_.Tid__main, ttl_bry, page_id, len, len, Srch_rslt_row.Page_redirect_id_null);
|
||||
rv.Page_ttl_highlight = rv.Page_ttl.Full_txt_w_ttl_case();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class Srch_html_row_bldr implements gplx.core.brys.Bfr_arg {
|
||||
synchronized (thread_lock) {
|
||||
lnki_bldr.Href_(row.Wiki_bry, row.Page_ttl);
|
||||
lnki_bldr.Title_(row.Page_ttl.Full_txt_w_ttl_case());
|
||||
lnki_bldr.Caption_direct_(row.Page_ttl_display(Bool_.Y));
|
||||
lnki_bldr.Caption_direct_(row.To_display(Srch_rslt_row.Display_type__special_page));
|
||||
fmtr.Bld_many(bfr, Gfh_utl.Encode_id_as_str(row.Key), row.Page_score, lnki_bldr.Bld_to_bry());
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,22 @@ public class Srch_html_row_wkr {
|
||||
}
|
||||
public void Set(int i, Srch_rslt_row row) {rows[i] = row;}
|
||||
public void On_rslt_found(Srch_rslt_row new_row) {
|
||||
// get last row
|
||||
Srch_rslt_row last_row = rows[rows_len - 1];
|
||||
if (last_row != null) {
|
||||
if (Compare(new_row, last_row) == CompareAble_.More_or_same) return; // new_row is < last_row; exit
|
||||
}
|
||||
int new_row_slot = Find_insert_slot(new_row); if (new_row_slot == -1) return;
|
||||
|
||||
// find where new row goes
|
||||
int new_row_slot = Find_insert_slot(new_row);
|
||||
if (new_row_slot == -1) return;
|
||||
|
||||
// get row and add it
|
||||
Srch_rslt_row insert_row = rows[new_row_slot];
|
||||
byte[] insert_key = insert_row == null ? insert_new_key : insert_row.Key;
|
||||
Displace(new_row_slot, new_row);
|
||||
|
||||
// generate html
|
||||
html_row_bldr.Bld_html(bfr, new_row);
|
||||
String html_tbl = bfr.To_str_and_clear();
|
||||
js_wkr.Html_elem_append_above(Gfh_utl.Encode_id_as_str(insert_key), html_tbl);
|
||||
|
@ -458,13 +458,11 @@ if (!window.xowa) {
|
||||
elem.insertAdjacentHTML('beforebegin', html);
|
||||
|
||||
xowa.js.doc.process_new_elem(elem.parentNode); // NOTE: elem is placeholder item; html is inserted after it; need to call process_new_elem on parentNode; DATE:2015-08-03
|
||||
return true;
|
||||
};
|
||||
/*
|
||||
xowa.js.doc.ElemAdd.publish()
|
||||
*/
|
||||
// PURPOSE: process new element such as adding bindings; DATE:2015-07-09
|
||||
xowa.js.doc.process_new_elem = function(elem) {
|
||||
xowa.js.doc.EvtElemAdd.pub(elem);
|
||||
xowa.js.doc.evtElemAdd.pub(elem);
|
||||
}
|
||||
|
||||
// PURPOSE: async search; gallery; imap
|
||||
|
Loading…
Reference in New Issue
Block a user