mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v1.11.3.1
This commit is contained in:
parent
da8180ea44
commit
1b0042ef8a
@ -34,6 +34,10 @@ public class Bry_finder {
|
||||
if (src[i] == lkp) return i;
|
||||
return Bry_finder.Not_found;
|
||||
}
|
||||
public static int Move_fwd(byte[] src, byte[] lkp, int cur, int end) {
|
||||
int rv = Find_fwd(src, lkp, 0, src.length);
|
||||
return rv == Bry_finder.Not_found ? rv : rv + lkp.length;
|
||||
}
|
||||
public static int Find_fwd(byte[] src, byte[] lkp) {return Find(src, lkp, 0 , src.length, true);}
|
||||
public static int Find_fwd(byte[] src, byte[] lkp, int cur) {return Find(src, lkp, cur , src.length, true);}
|
||||
public static int Find_fwd(byte[] src, byte[] lkp, int cur, int end) {return Find(src, lkp, cur , end, true);}
|
||||
|
@ -24,7 +24,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "1.11.2.1";
|
||||
public static final String Version = "1.11.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
|
@ -65,12 +65,6 @@ public class Xog_tab_itm_edit_mgr {
|
||||
win_itm.Page__mode_(Xopg_view_mode.Tid_edit);
|
||||
html_itm.Scroll_page_by_id_gui(Xog_html_itm.Elem_id__first_heading);// NOTE: was originally directly; changed to call on thread; DATE:2014-05-03
|
||||
win_itm.Page__async__bgn(tab); // NOTE: needed to show images during preview; DATE:2014-06-21
|
||||
try {
|
||||
tab.Async();
|
||||
}
|
||||
catch (Exception e) {
|
||||
tab.Tab_mgr().Win().App().Usr_dlg().Warn_many("error while running file wkr; page=~{0} err=~{1}", tab.Page().Url().Xto_full_str(), Err_.Message_gplx_brief(e));
|
||||
}
|
||||
}
|
||||
public static void Rename(Xog_tab_itm tab) {
|
||||
if (tab.View_mode() != Xopg_view_mode.Tid_edit) return; // exit if not edit; handles ctrl+r being pressed
|
||||
|
@ -24,7 +24,7 @@ public class Xodb_hdump_mgr__write_tst {
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png));
|
||||
fxt.Test_write_all
|
||||
( "[[File:A.png|test_caption]]"
|
||||
, "<a xtid='a_img_full' xatrs='1|0|0|test_caption'/>"
|
||||
, "<a xtid='a_img_full' xatrs='1|0|0||0|test_caption'/>"
|
||||
);
|
||||
}
|
||||
@Test public void Image_thumb() {
|
||||
|
@ -29,6 +29,8 @@ class Hdump_stats_tbl {
|
||||
, js_mgr.Math_exists(), js_mgr.Imap_exists(), js_mgr.Gallery_packed_exists(), js_mgr.Hiero_exists()
|
||||
, hzip.A_rhs(), hzip.Lnki_text_n(), hzip.Lnki_text_y()
|
||||
, hzip.Lnke_txt(), hzip.Lnke_brk_text_n(), hzip.Lnke_brk_text_y()
|
||||
, hzip.Hdr_1(), hzip.Hdr_2(), hzip.Hdr_3(), hzip.Hdr_4(), hzip.Hdr_5(), hzip.Hdr_6()
|
||||
, hzip.Img_full()
|
||||
);
|
||||
}
|
||||
private int Len_or_0(byte[] bry) {return bry == null ? 0 : bry.length;}
|
||||
@ -38,6 +40,8 @@ class Hdump_stats_tbl {
|
||||
, boolean js_math, boolean js_imap, boolean js_packed, boolean js_hiero
|
||||
, int a_rhs, int lnki_text_n, int lnki_text_y
|
||||
, int lnke_txt, int lnke_brk_text_n, int lnke_brk_text_y
|
||||
, int hdr_1, int hdr_2, int hdr_3, int hdr_4, int hdr_5, int hdr_6
|
||||
, int img_full
|
||||
) {
|
||||
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds__all);
|
||||
try {
|
||||
@ -47,6 +51,8 @@ class Hdump_stats_tbl {
|
||||
.Val_byte_by_bool_(js_math).Val_byte_by_bool_(js_imap).Val_byte_by_bool_(js_packed).Val_byte_by_bool_(js_hiero)
|
||||
.Val_int_(a_rhs).Val_int_(lnki_text_n).Val_int_(lnki_text_y)
|
||||
.Val_int_(lnke_txt).Val_int_(lnke_brk_text_n).Val_int_(lnke_brk_text_y)
|
||||
.Val_int_(hdr_1).Val_int_(hdr_2).Val_int_(hdr_3).Val_int_(hdr_4).Val_int_(hdr_5).Val_int_(hdr_6)
|
||||
.Val_int_(img_full)
|
||||
.Exec_insert();
|
||||
}
|
||||
catch (Exception exc) {stmt_insert = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
|
||||
@ -61,6 +67,8 @@ class Hdump_stats_tbl {
|
||||
, Fld_js_math = "js_math", Fld_js_imap = "js_imap", Fld_js_packed = "js_packed", Fld_js_hiero = "js_hiero"
|
||||
, Fld_a_rhs = "a_rhs", Fld_lnki_text_n = "lnki_text_n", Fld_lnki_text_y = "lnki_text_y"
|
||||
, Fld_lnke_txt = "lnke_txt", Fld_lnke_brk_text_n = "lnke_brk_text_n", Fld_lnke_brk_text_y = "lnke_brk_text_y"
|
||||
, Fld_hdr_1 = "hdr_1", Fld_hdr_2 = "hdr_2", Fld_hdr_3 = "hdr_3", Fld_hdr_4 = "hdr_", Fld_hdr_5 = "hdr_", Fld_hdr_6 = "hdr_6"
|
||||
, Fld_img_full = "img_full"
|
||||
;
|
||||
private static final String[] Flds__all = new String[]
|
||||
{ Fld_page_id, Fld_wtxt_len, Fld_row_orig_len, Fld_row_zip_len
|
||||
@ -68,6 +76,8 @@ class Hdump_stats_tbl {
|
||||
, Fld_js_math, Fld_js_imap, Fld_js_packed, Fld_js_hiero
|
||||
, Fld_a_rhs, Fld_lnki_text_n, Fld_lnki_text_y
|
||||
, Fld_lnke_txt, Fld_lnke_brk_text_n, Fld_lnke_brk_text_y
|
||||
, Fld_hdr_1, Fld_hdr_2, Fld_hdr_3, Fld_hdr_4, Fld_hdr_5, Fld_hdr_6
|
||||
, Fld_img_full
|
||||
};
|
||||
public static final String Tbl_sql = String_.Concat_lines_nl
|
||||
( "CREATE TABLE IF NOT EXISTS hdump_stats"
|
||||
@ -89,6 +99,13 @@ class Hdump_stats_tbl {
|
||||
, ", lnke_txt integer NOT NULL"
|
||||
, ", lnke_brk_text_n integer NOT NULL"
|
||||
, ", lnke_brk_text_y integer NOT NULL"
|
||||
, ", hdr_1 integer NOT NULL"
|
||||
, ", hdr_2 integer NOT NULL"
|
||||
, ", hdr_3 integer NOT NULL"
|
||||
, ", hdr_4 integer NOT NULL"
|
||||
, ", hdr_5 integer NOT NULL"
|
||||
, ", hdr_6 integer NOT NULL"
|
||||
, ", img_full integer NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
}
|
||||
|
@ -16,9 +16,10 @@ 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.html.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import gplx.html.*; import gplx.xowa.apps.ttls.*; import gplx.xowa.hdumps.srls.*;
|
||||
import gplx.core.brys.*; import gplx.html.*; import gplx.xowa.apps.ttls.*; import gplx.xowa.hdumps.srls.*;
|
||||
public class Xow_hzip_itm__anchor {
|
||||
private Xow_hzip_mgr hzip_mgr; private Xoa_ttl_parser ttl_parser; private Byte_obj_ref xtid_ref = Byte_obj_ref.zero_();
|
||||
// private Bry_rdr bry_rdr = new Bry_rdr();
|
||||
public Xow_hzip_itm__anchor(Xow_hzip_mgr hzip_mgr, Xoa_ttl_parser ttl_parser) {this.hzip_mgr = hzip_mgr; this.ttl_parser = ttl_parser;}
|
||||
public int Save_a_rhs(Bry_bfr bfr, Xow_hzip_stats stats, byte[] src, int src_len, int bgn, int pos) {
|
||||
bfr.Add(Xow_hzip_dict.Bry_a_rhs);
|
||||
@ -34,10 +35,24 @@ public class Xow_hzip_itm__anchor {
|
||||
case Xow_hzip_dict.Tid_lnke_txt:
|
||||
case Xow_hzip_dict.Tid_lnke_brk_text_n:
|
||||
case Xow_hzip_dict.Tid_lnke_brk_text_y: return Save_lnke(bfr, stats, src, src_len, bgn, xtid_end, xtid_val);
|
||||
case Xow_hzip_dict.Tid_img_full: return Save_img_full(bfr, stats, src, src_len, bgn, xtid_end);
|
||||
default: return hzip_mgr.Warn_by_pos("a.xtid_unknown", bgn, pos);
|
||||
}
|
||||
}
|
||||
// // <a href="/wiki/File:The_Earth_seen_from_Apollo_17.jpg" class="image" xowa_title="The Earth seen from Apollo 17.jpg">
|
||||
private int Save_img_full(Bry_bfr bfr, Xow_hzip_stats stats, byte[] src, int src_len, int bgn, int pos) {
|
||||
// tmp_bfr.Add_str_ascii(a_cls == Xoh_lnki_consts.Tid_a_cls_none ? "0|" : "1|"); // a_cls : "" || image
|
||||
// tmp_bfr.Add_str_ascii(a_rel == Xoh_lnki_consts.Tid_a_rel_none ? "0|" : "1|"); // a_rel : "" || nofollow
|
||||
// tmp_bfr.Add_int_fixed(img_cls, 1).Add_byte_pipe(); // img_cls : "" || thumbborder || thumbimage || other
|
||||
// tmp_bfr.Add_safe(img_cls_other).Add_byte_pipe(); // img_cls_other : "" || {other}
|
||||
// tmp_bfr.Add_int_variable(uid).Add_byte_pipe();
|
||||
// Html_utl.Escape_html_to_bfr(tmp_bfr, img_alt, 0, img_alt.length, Bool_.N, Bool_.N, Bool_.N, Bool_.N, Bool_.Y);
|
||||
return Xow_hzip_mgr.Unhandled;
|
||||
// int xatrs_bgn = Bry_finder.Move_fwd(src, Find_img_xatrs, pos, src_len); if (xatrs_bgn == Bry_finder.Not_found) return hzip_mgr.Warn_by_pos_add_dflt("a.img_xatrs_missing", bgn, pos);
|
||||
// byte a_cls = src[xatrs_bgn ] - Byte_ascii.Num_0;
|
||||
// byte a_rel = src[xatrs_bgn + 2] - Byte_ascii.Num_0;
|
||||
// byte img_rel = src[xatrs_bgn + 4] - Byte_ascii.Num_0;
|
||||
// byte meta = img_cls + Enm_.Add_byte(2, img_rel);
|
||||
}
|
||||
public int Save_lnki(Bry_bfr bfr, Xow_hzip_stats stats, byte[] src, int src_len, int bgn, int pos, boolean caption) {
|
||||
int ttl_bgn = Bry_finder.Find_fwd(src, Find_href_wiki_bry, pos, src_len); if (ttl_bgn == Bry_finder.Not_found) return Xow_hzip_mgr.Unhandled;//hzip_mgr.Warn_by_pos_add_dflt("a.ttl_bgn_missing", bgn, pos);
|
||||
ttl_bgn += Find_href_wiki_len;
|
||||
@ -143,13 +158,11 @@ public class Xow_hzip_itm__anchor {
|
||||
public void Html_plain(Bry_bfr bfr, Xop_lnki_tkn lnki) {
|
||||
bfr.Add_str(lnki.Caption_exists() ? "<a xtid='a_lnki_text_y' href=\"" : "<a xtid='a_lnki_text_n' href=\"");
|
||||
}
|
||||
public void Html_file(Bry_bfr bfr, Xop_lnki_tkn lnki) {
|
||||
// bfr.Add_str("<a xtid='a_lnki_file'");
|
||||
}
|
||||
private static final byte[]
|
||||
Find_href_wiki_bry = Bry_.new_ascii_("href=\"/wiki/")
|
||||
, Find_href_bry = Bry_.new_ascii_("href=\"")
|
||||
, Find_a_rhs_bgn_bry = Bry_.new_ascii_("</a>")
|
||||
// , Find_img_xatrs = Bry_.new_ascii_("xatrs='")
|
||||
;
|
||||
private static final int
|
||||
Find_href_wiki_len = Find_href_wiki_bry.length
|
||||
|
@ -21,7 +21,7 @@ public class Xow_hzip_itm__file_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_hzip_mgr_fxt fxt = new Xow_hzip_mgr_fxt();
|
||||
@Test public void Srl_img_full() {
|
||||
// byte[][] brys = Bry_.Ary(Xow_hzip_dict.Bry_img_full, Bry_.ints_(2), Bry_.new_ascii_("A"), Xow_hzip_dict.Escape_bry);
|
||||
// fxt.Test_save(brys, "<a xtid='a_lnki_text_n' href=\"/wiki/A\" id='xowa_lnki_0' title='A'>A</a>");
|
||||
// fxt.Test_save(brys, "<a xtid='a_img_full' href=\"/wiki/A\" id='xowa_lnki_0' title='A'>A</a>");
|
||||
// fxt.Test_load(brys, "<a href='/wiki/A' title='A'>A</a>");
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Xow_hzip_itm__header {
|
||||
bfr.Add_mid(src, span_lhs_end, hdr_end);
|
||||
hdr_end += Hdr_end.length;
|
||||
bfr.Add(Xow_hzip_dict.Escape_bry);
|
||||
stats.Hdr_add();
|
||||
stats.Hdr_add(hdr_num);
|
||||
return hdr_end + 12; // +12 = "</span></h2>"
|
||||
}
|
||||
public int Load(Bry_bfr bfr, byte[] src, int src_len, int bgn) {
|
||||
|
@ -18,7 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.html.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
public class Xow_hzip_stats {
|
||||
public void Clear() {
|
||||
a_rhs = lnki_text_n = lnki_text_y = lnke_txt = lnke_brk_text_n = lnke_brk_text_y = hdr = 0;
|
||||
a_rhs = lnki_text_n = lnki_text_y = lnke_txt = lnke_brk_text_n = lnke_brk_text_y = 0;
|
||||
hdr_1 = hdr_2 = hdr_3 = hdr_4 = hdr_5 = hdr_6 = 0;
|
||||
img_full = 0;
|
||||
}
|
||||
public int A_rhs() {return a_rhs;} public void A_rhs_add() {++a_rhs;} private int a_rhs;
|
||||
public int Lnki_text_n() {return lnki_text_n;} public void Lnki_text_n_add() {++lnki_text_n;} private int lnki_text_n;
|
||||
@ -26,5 +28,22 @@ public class Xow_hzip_stats {
|
||||
public int Lnke_txt() {return lnke_txt;} public void Lnke_txt_add() {++lnke_txt;} private int lnke_txt;
|
||||
public int Lnke_brk_text_n() {return lnke_brk_text_n;} public void Lnke_brk_text_n_add() {++lnke_brk_text_n;} private int lnke_brk_text_n;
|
||||
public int Lnke_brk_text_y() {return lnke_brk_text_y;} public void Lnke_brk_text_y_add() {++lnke_brk_text_y;} private int lnke_brk_text_y;
|
||||
public int Hdr() {return hdr;} public void Hdr_add() {++hdr;} private int hdr;
|
||||
public int Img_full() {return img_full;} public void Img_full_add() {++img_full;} private int img_full;
|
||||
public int Hdr_1() {return hdr_1;} private int hdr_1;
|
||||
public int Hdr_2() {return hdr_2;} private int hdr_2;
|
||||
public int Hdr_3() {return hdr_3;} private int hdr_3;
|
||||
public int Hdr_4() {return hdr_4;} private int hdr_4;
|
||||
public int Hdr_5() {return hdr_5;} private int hdr_5;
|
||||
public int Hdr_6() {return hdr_6;} private int hdr_6;
|
||||
public void Hdr_add(byte hdr_num) {
|
||||
switch (hdr_num) {
|
||||
case 1: ++hdr_1; break;
|
||||
case 2: ++hdr_2; break;
|
||||
case 3: ++hdr_3; break;
|
||||
case 4: ++hdr_4; break;
|
||||
case 5: ++hdr_5; break;
|
||||
case 6: ++hdr_6; break;
|
||||
default: throw Err_.unhandled(hdr_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,11 @@ public class Xoh_file_html_fmtr__hdump extends Xoh_file_html_fmtr__base {
|
||||
, byte[] a_href, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
|
||||
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other) {
|
||||
tmp_bfr.Add_str_ascii("<a xtid='a_img_full' xatrs='");
|
||||
tmp_bfr.Add_str_ascii(a_cls == Xoh_lnki_consts.Tid_a_cls_none ? "0|" : "1|"); // "" || "cls=image"
|
||||
tmp_bfr.Add_str_ascii(a_rel == Xoh_lnki_consts.Tid_a_rel_none ? "0|" : "1|"); // "" || "rel=nofollow"
|
||||
tmp_bfr.Add_str_ascii(a_cls == Xoh_lnki_consts.Tid_a_cls_none ? "0|" : "1|"); // a_cls : "" || image
|
||||
tmp_bfr.Add_str_ascii(a_rel == Xoh_lnki_consts.Tid_a_rel_none ? "0|" : "1|"); // a_rel : "" || nofollow
|
||||
tmp_bfr.Add_int_fixed(img_cls, 1).Add_byte_pipe(); // img_cls : "" || thumbborder || thumbimage || other
|
||||
tmp_bfr.Add_safe(img_cls_other).Add_byte_pipe(); // img_cls_other : "" || {other}
|
||||
tmp_bfr.Add_int_variable(uid).Add_byte_pipe();
|
||||
tmp_bfr.Add(Xoh_lnki_consts.Img_cls_to_bry(img_cls, img_cls_other)); // "" || "cls=thumbborder || thumbimage || other"
|
||||
Html_utl.Escape_html_to_bfr(tmp_bfr, img_alt, 0, img_alt.length, Bool_.N, Bool_.N, Bool_.N, Bool_.N, Bool_.Y);
|
||||
tmp_bfr.Add_str_ascii("'/>");
|
||||
}
|
||||
|
@ -41,7 +41,12 @@ public class Xopg_html_data {
|
||||
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
|
||||
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
|
||||
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
|
||||
public Indicator_html_bldr Indicators() {return indicators;} public void Indicators_(Indicator_html_bldr v) {indicators = v;} private Indicator_html_bldr indicators;
|
||||
public Indicator_html_bldr Indicators() {return indicators;}
|
||||
public Indicator_html_bldr Indicators_or_new() {
|
||||
if (indicators == null)
|
||||
indicators = new Indicator_html_bldr();
|
||||
return indicators;
|
||||
} private Indicator_html_bldr indicators;
|
||||
public int Xtn_gallery_next_id() {return ++xtn_gallery_next_id;} private int xtn_gallery_next_id = -1;
|
||||
public boolean Xtn_gallery_packed_exists() {return xtn_gallery_packed_exists;} public void Xtn_gallery_packed_exists_y_() {xtn_gallery_packed_exists = true;} private boolean xtn_gallery_packed_exists;
|
||||
public boolean Xtn_imap_exists() {return xtn_imap_exists;} public void Xtn_imap_exists_y_() {xtn_imap_exists = true;} private boolean xtn_imap_exists;
|
||||
|
@ -37,7 +37,7 @@ class Indicator_html_bldr_itm implements Bry_fmtr_arg {
|
||||
public void Init(ListAdp list) {this.list = list;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
int list_len = list.Count();
|
||||
for (int i = 0; i < list_len; ++i) {
|
||||
for (int i = list_len - 1; i > -1; --i) { // reverse order
|
||||
Indicator_xnde xnde = (Indicator_xnde)list.FetchAt(i);
|
||||
fmtr_itm.Bld_bfr(bfr, xnde.Name(), xnde.Html());
|
||||
}
|
||||
@ -45,7 +45,7 @@ class Indicator_html_bldr_itm implements Bry_fmtr_arg {
|
||||
private static final Bry_fmtr
|
||||
fmtr_itm = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='mw-indicator-~{name}' class='mw-indicator'>~{html}</div>"
|
||||
, " <div id='mw-indicator-~{name}' class='mw-indicator'>~{html}</div>"
|
||||
), "name", "html")
|
||||
;
|
||||
}
|
||||
|
@ -20,11 +20,13 @@ import org.junit.*; import gplx.xowa.xtns.indicators.*;
|
||||
public class Indicator_html_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Indicator_html_bldr_fxt fxt = new Indicator_html_bldr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init_indicator("a", "b");
|
||||
fxt.Init_indicator("a", "a1");
|
||||
fxt.Init_indicator("b", "b1");
|
||||
fxt.Test_bld(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div class='mw-indicators'>"
|
||||
, " <div class='mw-indicator-a' class='mw-indicator'>b</div>"
|
||||
, " <div id='mw-indicator-b' class='mw-indicator'>b1</div>"
|
||||
, " <div id='mw-indicator-a' class='mw-indicator'>a1</div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@ -43,9 +45,8 @@ class Indicator_html_bldr_fxt {
|
||||
public void Init_indicator(String name, String html) {
|
||||
Indicator_xnde xnde = new Indicator_xnde();
|
||||
xnde.Init_for_test(Bry_.new_utf8_(name), Bry_.new_utf8_(html));
|
||||
Indicator_html_bldr indicators = new Indicator_html_bldr();
|
||||
Indicator_html_bldr indicators = page.Html_data().Indicators_or_new();
|
||||
indicators.Add(xnde);
|
||||
page.Html_data().Indicators_(indicators);
|
||||
}
|
||||
public void Test_bld(String expd) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
|
@ -30,12 +30,8 @@ public class Indicator_xnde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
}
|
||||
public void Xtn_parse(Xow_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
Xop_xatr_itm.Xatr_parse(wiki.App(), this, xatrs_hash, wiki, src, xnde);
|
||||
html = wiki.Parser().Parse_text_to_html(ctx, Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn()));
|
||||
Indicator_html_bldr html_bldr = ctx.Cur_page().Html_data().Indicators();
|
||||
if (html_bldr == null) {
|
||||
html_bldr = new Indicator_html_bldr();
|
||||
ctx.Cur_page().Html_data().Indicators_(html_bldr);
|
||||
}
|
||||
html = Xop_parser_.Parse_text_to_html(wiki, ctx.Cur_page().Ttl(), Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn()), false);
|
||||
Indicator_html_bldr html_bldr = ctx.Cur_page().Html_data().Indicators_or_new();
|
||||
html_bldr.Add(this);
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoa_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
|
@ -257,16 +257,14 @@ public class Poem_nde_tst {
|
||||
( "<p><div class=\"poem\">"
|
||||
, "<p>"
|
||||
, "a<br/>"
|
||||
, "b<br/>"
|
||||
, " <div class=\"poem\">"
|
||||
, "b"
|
||||
, "</p>"
|
||||
, "</div> <div class=\"poem\">"
|
||||
, "<p>"
|
||||
, "c<br/>" // NOTE: "<br/>" not "<br/><br/>"
|
||||
, "d<br/>"
|
||||
, " "
|
||||
, "d"
|
||||
, "</p>"
|
||||
, "</div>"
|
||||
, "</p>"
|
||||
, "</div>"
|
||||
, "</div> "
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class Scrib_lib_wikibase_srl {
|
||||
}
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_labels , Srl_langtexts (Wdata_dict_langtext.Str_language , Wdata_dict_langtext.Str_value, wdoc.Label_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_descriptions , Srl_langtexts (Wdata_dict_langtext.Str_language , Wdata_dict_langtext.Str_value, wdoc.Descr_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_sitelinks , Srl_sitelinks (Wdata_dict_sitelink.Str_site , Wdata_dict_sitelink.Str_title, wdoc.Slink_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_sitelinks , Srl_sitelinks (Wdata_dict_sitelink.Str_site , Wdata_dict_sitelink.Str_title, wdoc.Slink_list(), base_adj));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_aliases , Srl_aliases (base_adj, wdoc.Alias_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_claims , Srl_claims (base_adj, legacy_style, wdoc.Claim_list()));
|
||||
return (KeyVal[])rv.Xto_ary(KeyVal.class);
|
||||
@ -48,17 +48,27 @@ class Scrib_lib_wikibase_srl {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal[] Srl_sitelinks(String key_label, String val_label, OrderedHash list) {
|
||||
private static KeyVal[] Srl_sitelinks(String key_label, String val_label, OrderedHash list, int base_adj) {
|
||||
int len = list.Count(); if (len == 0) return null;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Wdata_sitelink_itm itm = (Wdata_sitelink_itm)list.FetchAt(i);
|
||||
String site = String_.new_utf8_(itm.Site());
|
||||
String name = String_.new_utf8_(itm.Name());
|
||||
rv[i] = KeyVal_.new_(site, KeyVal_.Ary(KeyVal_.new_(key_label, site), KeyVal_.new_(val_label, name)));
|
||||
rv[i] = KeyVal_.new_(site, KeyVal_.Ary(KeyVal_.new_(key_label, site), KeyVal_.new_(val_label, name), Srl_sitelinks_badges(itm.Badges(), base_adj)));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static KeyVal Srl_sitelinks_badges(byte[][] badges, int base_adj) {
|
||||
if (badges == null) badges = Bry_.Ary_empty; // null badges -> badges:[]
|
||||
int len = badges.length;
|
||||
KeyVal[] kvs = len == 0 ? KeyVal_.Ary_empty : new KeyVal[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] badge = badges[i];
|
||||
kvs[i] = KeyVal_.int_(i + base_adj, String_.new_utf8_(badge));
|
||||
}
|
||||
return KeyVal_.new_("badges", kvs);
|
||||
}
|
||||
private static KeyVal[] Srl_aliases(int base_adj, OrderedHash list) {
|
||||
int len = list.Count(); if (len == 0) return null;
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
|
@ -59,12 +59,15 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " enwiki:"
|
||||
, " site:'enwiki'"
|
||||
, " title:'Earth'"
|
||||
, " badges:"
|
||||
, " frwiki:"
|
||||
, " site:'frwiki'"
|
||||
, " title:'Terre'"
|
||||
, " badges:"
|
||||
, " dewiki:"
|
||||
, " site:'dewiki'"
|
||||
, " title:'Erde'"
|
||||
, " badges:"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@ -74,7 +77,7 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, ", 'links':"
|
||||
, " {"
|
||||
, " 'enwiki':'Earth'" // old format
|
||||
, " , 'frwiki':{'name':'Terre','badges':[]}" // new format
|
||||
, " , 'frwiki':{'name':'Terre','badges':['Q3']}" // new format
|
||||
, " }"
|
||||
, "}"
|
||||
);
|
||||
@ -85,9 +88,12 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
, " enwiki:"
|
||||
, " site:'enwiki'"
|
||||
, " title:'Earth'"
|
||||
, " badges:"
|
||||
, " frwiki:"
|
||||
, " site:'frwiki'"
|
||||
, " title:'Terre'"
|
||||
, " badges:"
|
||||
, " 1:'Q3'"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
|
@ -131,12 +131,14 @@ public class Wdata_wiki_mgr_fxt {
|
||||
, "+|grp1|itm|en|English"
|
||||
, "+|grp1|itm|fr|French"
|
||||
, "+|grp1|itm|de|German"
|
||||
, "+|grp1|itm|pl|Polish"
|
||||
)));
|
||||
wiki.Xwiki_mgr().Add_bulk_langs(Bry_.new_ascii_("wiki"));
|
||||
String bulk = String_.Concat_lines_nl
|
||||
( "en.wikipedia.org|en.wikipedia.org"
|
||||
, "fr.wikipedia.org|fr.wikipedia.org"
|
||||
, "de.wikipedia.org|de.wikipedia.org"
|
||||
, "pl.wikipedia.org|pl.wikipedia.org"
|
||||
);
|
||||
wiki.App().User().Wiki().Xwiki_mgr().Add_bulk(Bry_.new_ascii_(bulk));
|
||||
|
||||
|
@ -78,9 +78,15 @@ public class Wdata_xwiki_link_wtr_tst {
|
||||
fxt.Test_xwiki_links("Q1_en", "q1_de", "q1_fr");
|
||||
}
|
||||
@Test public void Badges() {
|
||||
fxt.Init_xwikis_add("de", "fr");
|
||||
fxt.Init_xwikis_add("de", "fr", "pl");
|
||||
fxt.Init_qids_add("en", Xow_wiki_domain_.Tid_wikipedia, "Q1_en", "Q1");
|
||||
fxt.Init_pages_add(fxt.Wdoc_bldr("Q1").Add_sitelink("enwiki", "Q1_en").Add_sitelink("dewiki", "Q1_de", "Q17437796").Add_sitelink("frwiki", "Q1_fr", "Q17437798").Xto_wdoc());
|
||||
fxt.Init_pages_add
|
||||
( fxt.Wdoc_bldr("Q1")
|
||||
.Add_sitelink("enwiki", "Q1_en")
|
||||
.Add_sitelink("dewiki", "Q1_de", "Q17437796")
|
||||
.Add_sitelink("frwiki", "Q1_fr", "Q17437798")
|
||||
.Add_sitelink("plwiki", "Q1_pl", "Q17559452")
|
||||
.Xto_wdoc());
|
||||
fxt.Test_parse_langs("", String_.Concat_lines_nl
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5>In other languages (<a href=\"/site/www.wikidata.org/wiki/Q1\">wikidata</a>)<a href='javascript:xowa_toggle_visible(\"wikidata-langs\");'><img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a></h5>"
|
||||
@ -90,6 +96,7 @@ public class Wdata_xwiki_link_wtr_tst {
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>German</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-featuredarticle'><a hreflang=\"de\" title=\"Q1 de\" href=\"/site/de.wikipedia.org/wiki/Q1 de\">Q1 de</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>French</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-goodarticle'><a hreflang=\"fr\" title=\"Q1 fr\" href=\"/site/fr.wikipedia.org/wiki/Q1 fr\">Q1 fr</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Polish</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-recommendedarticle'><a hreflang=\"pl\" title=\"Q1 pl\" href=\"/site/pl.wikipedia.org/wiki/Q1 pl\">Q1 pl</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
|
@ -172,20 +172,22 @@ class Xow_lang_html implements Bry_fmtr_arg {
|
||||
for (int i = 0; i < badges_len; ++i) {
|
||||
if (i != 0) bfr.Add_byte_comma();
|
||||
byte[] badge = badges[i];
|
||||
if (Bry_.Eq(badge, Badge_good_qid)) bfr.Add(Badge_good_cls);
|
||||
else if (Bry_.Eq(badge, Badge_feat_qid)) bfr.Add(Badge_feat_cls);
|
||||
else Gfo_usr_dlg_._.Warn_many("", "", "unknown badge: badge~{0}", String_.new_utf8_(badge));
|
||||
byte[] badge_cls = (byte[])badges_hash.Get_by_bry(badge);
|
||||
if (badge_cls == null) Gfo_usr_dlg_._.Warn_many("", "", "unknown badge: badge~{0}", String_.new_utf8_(badge));
|
||||
else bfr.Add(badge_cls);
|
||||
}
|
||||
}
|
||||
bfr.Add_byte_apos();
|
||||
return bfr.Xto_bry_and_clear();
|
||||
}
|
||||
private static final byte[]
|
||||
Badge_good_qid = Bry_.new_ascii_("Q17437798")
|
||||
, Badge_good_cls = Bry_.new_ascii_("badge-goodarticle")
|
||||
, Badge_feat_qid = Bry_.new_ascii_("Q17437796")
|
||||
, Badge_feat_cls = Bry_.new_ascii_("badge-featuredarticle")
|
||||
, Badge_none_cls = Bry_.new_ascii_("badge-none")
|
||||
Badge_none_cls = Bry_.new_ascii_("badge-none")
|
||||
, Cls_bgn = Bry_.new_ascii_(" class='")
|
||||
;
|
||||
private static Hash_adp_bry badges_hash = Hash_adp_bry.ci_ascii_()
|
||||
.Add_str_obj("Q17437798", Bry_.new_ascii_("badge-goodarticle"))
|
||||
.Add_str_obj("Q17437796", Bry_.new_ascii_("badge-featuredarticle"))
|
||||
.Add_str_obj("Q17559452", Bry_.new_ascii_("badge-recommendedarticle"))
|
||||
.Add_str_obj("Q17506997", Bry_.new_ascii_("badge-featuredlist"))
|
||||
;
|
||||
}
|
@ -20,4 +20,18 @@ import gplx.xowa.langs.vnts.*;
|
||||
public class Xop_parser_ {
|
||||
public static final byte Parse_tid_null = 0, Parse_tid_tmpl = 1, Parse_tid_page_tmpl = 2, Parse_tid_page_wiki = 3;
|
||||
public static final int Doc_bgn_bos = -1, Doc_bgn_char_0 = 0;
|
||||
public static byte[] Parse_text_to_html(Xow_wiki wiki, Xoa_ttl ttl, byte[] src, boolean para_enabled) {
|
||||
Bry_bfr bfr = wiki.Utl_bry_bfr_mkr().Get_b512();
|
||||
Xoa_page page = Xoa_page.new_(wiki, ttl);
|
||||
Xop_ctx ctx = Xop_ctx.new_sub_(wiki, page);
|
||||
Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
|
||||
Xop_root_tkn root = tkn_mkr.Root(src);
|
||||
Xop_parser parser = wiki.Parser();
|
||||
byte[] wtxt = parser.Parse_text_to_wtxt(root, ctx, tkn_mkr, src);
|
||||
root.Reset();
|
||||
ctx.Para().Enabled_(para_enabled);
|
||||
parser.Parse_wtxt_to_wdom(root, ctx, ctx.Tkn_mkr(), wtxt, Xop_parser_.Doc_bgn_bos);
|
||||
wiki.Html_mgr().Html_wtr().Write_all(bfr, ctx, wtxt, root);
|
||||
return bfr.Mkr_rls().Xto_bry_and_clear();
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,10 @@ public class Xop_xnde_tkn extends Xop_tkn_itm_base implements Xop_tblw_tkn {
|
||||
for (int i = 0; i < subs_len; i++) // always evaluate subs; handle <poem>{{{1}}}</poem>; DATE:2014-03-03
|
||||
this.Subs_get(i).Tmpl_evaluate(ctx, src, caller, bfr);
|
||||
bfr.Add_mid(src, tag_close_bgn, tag_close_end); // write tag_end
|
||||
if (tag_close_bgn == Int_.MinValue) {// xtn is unclosed; add a </xtn> else rest of page will be gobbled; DATE:2014-11-13
|
||||
bfr.Add(tag.XtnEndTag());
|
||||
bfr.Add(Byte_ascii.Gt_bry);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user