1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-05-24 22:43:55 -04:00
parent 6eec99a713
commit 51e6188c1e
1577 changed files with 11555 additions and 10080 deletions

View File

@@ -19,11 +19,11 @@ package gplx.xowa; import gplx.*;
public class Xop_lnki_align_h {
public static final byte Null = 0, None = 1, Left = 2, Center = 3, Right = 4;
public static final byte[][] Html_names = new byte[][]
{ Bry_.new_ascii_("null")
, Bry_.new_ascii_("none")
, Bry_.new_ascii_("left")
, Bry_.new_ascii_("center")
, Bry_.new_ascii_("right")
{ Bry_.new_a7("null")
, Bry_.new_a7("none")
, Bry_.new_a7("left")
, Bry_.new_a7("center")
, Bry_.new_a7("right")
};
}
class Xop_lnki_align_v {

View File

@@ -123,7 +123,7 @@ public class Xop_lnki_arg_parser {
bwd_trie.Add(word_bry, Byte_obj_val.new_(Tid_dim));
}
}
public static final byte[] Bry_upright = Bry_.new_utf8_("upright"), Bry_thumbtime = Bry_.new_utf8_("thumbtime");
public static final byte[] Bry_upright = Bry_.new_u8("upright"), Bry_thumbtime = Bry_.new_u8("thumbtime");
public static final byte
Tid_unknown = 0, Tid_thumb = 1, Tid_left = 2, Tid_right = 3, Tid_none = 4, Tid_center = 5, Tid_frame = 6, Tid_frameless = 7, Tid_upright = 8, Tid_border = 9
, Tid_alt = 10, Tid_link = 11, Tid_baseline = 12, Tid_sub = 13, Tid_super = 14, Tid_top = 15, Tid_text_top = 16, Tid_middle = 17, Tid_bottom = 18, Tid_text_bottom = 19
@@ -133,7 +133,7 @@ public class Xop_lnki_arg_parser {
, Tid_noplayer = 24, Tid_noicon = 25, Tid_thumbtime = 26
, Tid_class = 27
;
private static final byte[] X_bry = Bry_.new_utf8_("x");
private static final byte[] X_bry = Bry_.new_u8("x");
private static final byte Key_dim_num = 0, Key_dim_x = 1, Key_dim_px = 2, Key_space = 3;
private static final int[][] Keys_ids = new int[][]
{ new int[] {Xol_kwd_grp_.Id_img_thumbnail , Tid_thumb}

View File

@@ -44,7 +44,7 @@ public class Xop_lnki_tkn extends Xop_tkn_itm_base {
public boolean Alt_exists() {return alt_tkn != Arg_nde_tkn.Null;}
public int Subpage_tid() {return subpage_tid;} public Xop_lnki_tkn Subpage_tid_(int v) {subpage_tid = v; return this;} private int subpage_tid = Pfunc_rel2abs.Id_null;
public boolean Subpage_slash_at_end() {return subpage_slash_at_end;} public Xop_lnki_tkn Subpage_slash_at_end_(boolean v) {subpage_slash_at_end = v; return this;} private boolean subpage_slash_at_end;
public int Html_id() {return html_id;} public Xop_lnki_tkn Html_id_(int v) {html_id = v; return this;} private int html_id;
public int Html_uid() {return html_uid;} public Xop_lnki_tkn Html_uid_(int v) {html_uid = v; return this;} private int html_uid;
public int Pipe_count() {return pipe_count;} private int pipe_count;
public boolean Pipe_count_is_zero() {return pipe_count++ == 0;}
public boolean Xtn_sites_link() {return xtn_sites_link;} public void Xtn_sites_link_(boolean v) {xtn_sites_link = v;} private boolean xtn_sites_link;

View File

@@ -170,8 +170,8 @@ public class Xop_lnki_wkr implements Xop_ctx_wkr, Xop_arg_wkr {
}
return true;
} catch (Exception e) {
ctx.App().Usr_dlg().Warn_many("", "", "fatal error in lnki: page=~{0} src=~{1} err=~{2}", String_.new_utf8_(ctx.Cur_page().Ttl().Full_db()), String_.new_utf8_(src, lnki.Src_bgn(), lnki.Src_end()), Err_.Message_gplx(e));
ctx.App().Usr_dlg().Warn_many("", "", "fatal error in lnki: page=~{0} src=~{1} err=~{2}", String_.new_u8(ctx.Cur_page().Ttl().Full_db()), String_.new_u8(src, lnki.Src_bgn(), lnki.Src_end()), Err_.Message_gplx(e));
return false;
}
} private static final byte[] Const_pipe = Bry_.new_ascii_("|");
} private static final byte[] Const_pipe = Bry_.new_a7("|");
}

View File

@@ -40,7 +40,7 @@ public class Xop_lnki_wkr_ {
public static boolean Parse_ttl(Xop_ctx ctx, byte[] src, Xop_lnki_tkn lnki, int ttl_bgn, int ttl_end) {
Xoae_app app = ctx.App();
byte[] ttl_bry = Bry_.Mid(src, ttl_bgn, ttl_end);
ttl_bry = Xoa_app_.Utl__encoder_mgr().Url_ttl().Decode(ttl_bry);
ttl_bry = Xoa_app_.Utl__encoder_mgr().Http_url_ttl().Decode(ttl_bry);
int ttl_bry_len = ttl_bry.length;
Xoa_ttl page_ttl = ctx.Cur_page().Ttl();
if (page_ttl.Ns().Subpages_enabled()

View File

@@ -323,7 +323,7 @@ public class Xop_lnki_wkr__basic_tst {
fxt.Test_parse_page_all_str("[[Ab]]cd e", "<a href=\"/wiki/Ab\">Abcd</a> e");
}
@Test public void Trail_fr() {
byte[] ltr_c_in_french = Bry_.new_utf8_("ç");
byte[] ltr_c_in_french = Bry_.new_u8("ç");
Xol_lnki_trail_mgr lnki_trail_mgr = fxt.Wiki().Lang().Lnki_trail_mgr();
lnki_trail_mgr.Add(ltr_c_in_french);
fxt.Test_parse_page_all_str("[[Ab]]çd e", "<a href=\"/wiki/Ab\">Abçd</a> e");
@@ -340,10 +340,10 @@ public class Xop_lnki_wkr__basic_tst {
}
@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_ascii_("Src")); // simulate requrest for "Src" page
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);
previous_page.Redirected_ttls().Add(Bry_.new_ascii_("Src")); // simulate redirect from "Src"
fxt.App().User().History_mgr().Add(previous_page); // simulate "Src" already being clicked once; this is the key call
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_(true);
fxt.Test_parse_page_all_str("[[Src]]" , "<a href=\"/wiki/Src\" class=\"xowa-visited\">Src</a>"); // show [[Src]] as visited since it exists in history
fxt.Test_parse_page_all_str("[[Other]]" , "<a href=\"/wiki/Other\">Other</a>"); // show other pages as not visited

View File

@@ -21,7 +21,7 @@ public class Xop_lnki_wkr__xwiki_tst {
@Before public void init() {fxt.Reset(); fxt.Init_para_n_();} private Xop_fxt fxt = new Xop_fxt();
@Test public void Xwiki_file() { // PURPOSE: if xwiki and File, ignore xwiki (hackish); DATE:2013-12-22
Reg_xwiki_alias("test", "test.wikimedia.org"); // must register xwiki, else ttl will not parse it
fxt.Wiki().Cfg_parser().Lnki_cfg().Xwiki_repo_mgr().Add_or_mod(Bry_.new_ascii_("test")); // must add to xwiki_repo_mgr
fxt.Wiki().Cfg_parser().Lnki_cfg().Xwiki_repo_mgr().Add_or_mod(Bry_.new_a7("test")); // must add to xwiki_repo_mgr
fxt.Test_parse_page_wiki_str
( "[[test:File:A.png|12x10px]]", 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=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" /></a>"
@@ -50,8 +50,8 @@ public class Xop_lnki_wkr__xwiki_tst {
));
}
@Test public void Xwiki_not_registered() {
fxt.App().User().Wiki().Xwiki_mgr().Clear();
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_ascii_("test"), Bry_.new_ascii_("test.wikimedia.org")); // register alias only, but not in user_wiki
fxt.App().Usere().Wiki().Xwiki_mgr().Clear();
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("test"), Bry_.new_a7("test.wikimedia.org")); // register alias only, but not in user_wiki
fxt.Test_parse_page_wiki_str
( "[[test:A|A]]", String_.Concat_lines_nl_skip_last
( "<a href=\"http://test.wikimedia.org/wiki/A\">A</a>"