mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.1.1
This commit is contained in:
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
public interface Xoa_wiki_mgr {
|
||||
boolean Has(byte[] key);
|
||||
Xow_wiki Get_by_key_or_make_init_y(byte[] key);
|
||||
Xow_wiki Get_by_key_or_make_init_n(byte[] key);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,13 @@ package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoa_wiki_regy {
|
||||
private Xoae_app app;
|
||||
private boolean init_needed = true;
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs_();
|
||||
private Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_wiki_regy(Xoae_app app) {this.app = app;}
|
||||
public boolean Has(byte[] domain) {if (init_needed) Init(); return hash.Has(domain);}
|
||||
public void Clear() {
|
||||
hash.Clear();
|
||||
init_needed = true;
|
||||
}
|
||||
public boolean Url_is_invalid_domain(Xoa_url url) {
|
||||
if (!Bry_.Eq(url.Page_bry(), Xoa_page_.Main_page_bry)) return false; // page is not "Main_Page"; assume not an invalid domain str; EX: "uk/wiki/Main_Page"
|
||||
if ( Bry_.Eq(Xow_domain_type_.Key_bry_home, url.Wiki_bry()) // wiki is "home"
|
||||
@@ -30,6 +34,7 @@ public class Xoa_wiki_regy {
|
||||
return !this.Has(url.Wiki_bry());
|
||||
}
|
||||
private void Init() {
|
||||
init_needed = false;
|
||||
Io_url[] wiki_dirs = Io_mgr.I.QueryDir_args(app.Fsys_mgr().Wiki_dir()).DirInclude_(true).Recur_(false).ExecAsUrlAry();
|
||||
int wiki_dirs_len = wiki_dirs.length;
|
||||
for (int i = 0; i < wiki_dirs_len; i++) {
|
||||
@@ -37,7 +42,6 @@ public class Xoa_wiki_regy {
|
||||
byte[] domain_bry = Bry_.new_u8(wiki_dir.NameOnly());
|
||||
hash.Add(domain_bry, domain_bry);
|
||||
}
|
||||
init_needed = true;
|
||||
}
|
||||
public static void Make_wiki_dir(Xoa_app app, String domain_str) { // TEST: fake wiki_dir for Parse_from_url_bar; DATE:2014-02-16
|
||||
Io_url wiki_dir = app.Fsys_mgr().Wiki_dir();
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
private Xoae_app app;
|
||||
private List_adp list = List_adp_.new_(); private Hash_adp_bry hash = Hash_adp_bry.ci_ascii_(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
private List_adp list = List_adp_.new_(); private Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
public Xoae_wiki_mgr(Xoae_app app) {
|
||||
this.app = app;
|
||||
wiki_regy = new Xoa_wiki_regy(app);
|
||||
@@ -34,6 +34,7 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
}
|
||||
public int Count() {return hash.Count();}
|
||||
public void Del(byte[] key) {hash.Del(key);}
|
||||
public boolean Has(byte[] key) {return hash.Has(key);}
|
||||
public Xowe_wiki Get_at(int i) {return Int_.Between(i, 0, this.Count() - 1) ? (Xowe_wiki)list.Get_at(i) : null;}
|
||||
public Xowe_wiki Get_by_key_or_null(byte[] key) {return Bry_.Len_eq_0(key) ? null : (Xowe_wiki)hash.Get_by(key);}
|
||||
public Xowe_wiki Get_by_key_or_null(byte[] src, int bgn, int end) {return (Xowe_wiki)hash.Get_by_mid(src, bgn, end);}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class Xow_domain_ {
|
||||
Object o = lang_to_gfs_hash.Get_by_bry(v);
|
||||
return o == null ? v : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry lang_to_gfs_hash = Hash_adp_bry.ci_ascii_() // ASCII:lang_code
|
||||
private static final Hash_adp_bry lang_to_gfs_hash = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
.Add_str_obj("simple" , Bry_.new_a7("en"))
|
||||
.Add_str_obj("zh-classical" , Bry_.new_a7("lzh"))
|
||||
.Add_str_obj("no" , Bry_.new_a7("nb"))
|
||||
|
||||
@@ -80,8 +80,8 @@ public class Xow_domain_type_ {
|
||||
, Key_bry_other = Bry_.new_a7(Key_str_other)
|
||||
;
|
||||
private static final Xow_domain_type[] ary = new Xow_domain_type[Tid__len];
|
||||
private static final Hash_adp_bry type_regy = Hash_adp_bry.ci_ascii_(); // LOC:must go before new_()
|
||||
private static final Hash_adp_bry abrv_regy = Hash_adp_bry.cs_(); // LOC:must go before new_()
|
||||
private static final Hash_adp_bry type_regy = Hash_adp_bry.ci_a7(); // LOC:must go before new_()
|
||||
private static final Hash_adp_bry abrv_regy = Hash_adp_bry.cs(); // LOC:must go before new_()
|
||||
public static final Xow_domain_type
|
||||
Itm_wikipedia = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wikipedia , Key_bry_wikipedia , "w" , ".wikipedia.org")
|
||||
, Itm_wiktionary = new_(Bool_.Y , Xow_domain_type_src_.Tid_wmf , Tid_wiktionary , Key_bry_wiktionary , "d" , ".wiktionary.org")
|
||||
|
||||
@@ -213,7 +213,7 @@ public class Xow_wiki_alias {
|
||||
alias_val_hash.Add(domain_bval, alias_bry);
|
||||
}
|
||||
private static void Init_tids() {
|
||||
tid_bry_trie = Btrie_slim_mgr.ci_ascii_(); // NOTE:ci.ascii:MW_const.en
|
||||
tid_bry_trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en
|
||||
tid_val_hash = Hash_adp_.new_();
|
||||
Init_tid(Key_pages_articles , Tid_pages_articles);
|
||||
Init_tid(Key_pages_meta_current , Tid_pages_meta_current);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xow_cache_mgr {
|
||||
defn_cache = new Xow_defn_cache(wiki.Lang());
|
||||
lst_cache = new Xow_defn_cache(wiki.Lang());
|
||||
}
|
||||
public Hash_adp Tmpl_result_cache() {return tmpl_result_cache;} private Hash_adp tmpl_result_cache = Hash_adp_bry.cs_();
|
||||
public Hash_adp Tmpl_result_cache() {return tmpl_result_cache;} private Hash_adp tmpl_result_cache = Hash_adp_bry.cs();
|
||||
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
|
||||
public Xow_defn_cache Defn_cache() {return defn_cache;} private Xow_defn_cache defn_cache;
|
||||
public Xow_defn_cache Lst_cache() {return lst_cache;} private Xow_defn_cache lst_cache;
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_page_cache {
|
||||
private Xowe_wiki wiki;
|
||||
private Hash_adp_bry cache = Hash_adp_bry.cs_(); // NOTE: wiki titles are not case-sensitive when ns is "1st-letter" (EX: w:earth an w:Earth); in these cases, two entries will be stored
|
||||
private Hash_adp_bry cache = Hash_adp_bry.cs(); // NOTE: wiki titles are not case-sensitive when ns is "1st-letter" (EX: w:earth an w:Earth); in these cases, two entries will be stored
|
||||
public Xow_page_cache(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public byte[] Get_or_load_as_src(Xoa_ttl ttl) {
|
||||
Xow_page_cache_itm rv = Get_or_load_as_itm(ttl);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Xowd_page_itm_tst {
|
||||
class Xowd_page_itm_fxt {
|
||||
public void Init() {
|
||||
if (ns_mgr == null) {
|
||||
ns_mgr = new Xow_ns_mgr(gplx.xowa.langs.cases.Xol_case_mgr_.Ascii());
|
||||
ns_mgr = new Xow_ns_mgr(gplx.xowa.langs.cases.Xol_case_mgr_.A7());
|
||||
ns_mgr.Add_new(Xow_ns_.Id_main, "");
|
||||
ns_mgr.Add_new(Xow_ns_.Id_user_talk, "User talk");
|
||||
ns_mgr.Init_w_defaults();
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Xowd_wbase_pid_tbl implements RlsAble {
|
||||
try {
|
||||
if (!rdr.Move_next()) return Wdata_wiki_mgr.Pid_null; // occurs when pid exists, but does not have entry for language; see hu.w:Marco Polo argali; DATE: 2014-02-01
|
||||
byte[] pid_bry = rdr.Read_bry_by_str(fld_trg_ttl);
|
||||
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.Xto_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
|
||||
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.To_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
public void Rls() {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Xowd_wbase_qid_tbl implements RlsAble {
|
||||
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_src_wiki, fld_src_ns, fld_src_ttl);
|
||||
if (src_ttl_has_spaces) src_ttl = Xoa_ttl.Replace_unders(src_ttl); // NOTE: v2.4.2.1-v2.4.3.2 stores ttl in spaces ("A B"), while xowa will use under form ("A_B"); DATE:2015-04-21
|
||||
Db_rdr rdr = stmt_select.Clear()
|
||||
.Crt_bry_as_str(fld_src_wiki, src_wiki).Crt_int(fld_src_ns, Bry_.Xto_int(src_ns)).Crt_bry_as_str(fld_src_ttl, src_ttl)
|
||||
.Crt_bry_as_str(fld_src_wiki, src_wiki).Crt_int(fld_src_ns, Bry_.To_int_or_neg1(src_ns)).Crt_bry_as_str(fld_src_ttl, src_ttl)
|
||||
.Exec_select__rls_manual();
|
||||
try {
|
||||
return rdr.Move_next() ? rdr.Read_bry_by_str(fld_trg_ttl) : null;
|
||||
|
||||
@@ -80,7 +80,7 @@ class Xow_domain_crt_itm_parser {
|
||||
else
|
||||
return new Xow_domain_crt_itm__wiki(raw); // EX: en.wikipedia.org
|
||||
}
|
||||
private static final Hash_adp_bry itm_hash = Hash_adp_bry.cs_()
|
||||
private static final Hash_adp_bry itm_hash = Hash_adp_bry.cs()
|
||||
.Add_str_obj("<self>" , Xow_domain_crt_itm__self.I)
|
||||
.Add_str_obj("<same_type>" , Xow_domain_crt_itm__same_type.I)
|
||||
.Add_str_obj("<same_lang>" , Xow_domain_crt_itm__same_lang.I)
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.html.heads.*; import gplx.xowa.html.modules.popups.*;
|
||||
public class Xow_module_mgr implements GfoInvkAble {
|
||||
private Hash_adp_bry regy = Hash_adp_bry.cs_();
|
||||
private Hash_adp_bry regy = Hash_adp_bry.cs();
|
||||
public Xow_module_mgr(Xowe_wiki wiki) {
|
||||
this.popup_mgr = new Xow_popup_mgr(wiki);
|
||||
regy.Add_bry_obj(Xoh_head_itm_.Key__top_icon , itm__top_icon);
|
||||
|
||||
@@ -20,24 +20,29 @@ import org.junit.*;
|
||||
import gplx.xowa.langs.cases.*;
|
||||
public class Xow_ttl__i18n_tst {
|
||||
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
|
||||
@Test public void Bidi() {
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(226, 128, 142)) + "B").Expd_page_txt("AB").Test();
|
||||
fxt.Init_ttl("A" + String_.new_u8(Bry_.ints_(226, 128, 97)) + "B").Expd_page_txt("A" + String_.new_u8(Bry_.ints_(226, 128, 97)) + "B").Test();
|
||||
@Test public void Bidi() { // PURPOSE: handle bidirectional characters; DATE:2015-07-28
|
||||
fxt.Init_ttl("A\u00E2\u0080\u008E\u00E2\u0080\u008F\u00E2\u0080\u00AA\u00E2\u0080\u00AB\u00E2\u0080\u00AC\u00E2\u0080\u00AD\u00E2\u0080\u00AEB").Expd_page_txt("AB").Test();
|
||||
}
|
||||
@Test public void Multi_byte_char2() { // PURPOSE: multi-byte HTML entity causes array out of index error; EX: w:List_of_Unicode_characters; DATE:2013-12-25
|
||||
fxt.Init_ttl("ⱥ").Expd_full_txt("ⱥ").Test();
|
||||
}
|
||||
@Test public void First_char_is_multi_byte() { // PURPOSE: if multi-byte, uppercasing is complicated; EX: µ -> Μ; DATE:2013-11-27
|
||||
fxt.Wiki().Lang().Case_mgr_utf8_();
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Init_ttl("µ").Expd_full_txt("Μ").Test(); // NOTE: this is not an ASCII "Μ"
|
||||
fxt.Init_ttl("µab").Expd_full_txt("Μab").Test(); // check that rest of title works fine
|
||||
fxt.Init_ttl("Help:µab").Expd_full_txt("Help:Μab").Test(); // check ns
|
||||
fxt.Init_ttl("Ι").Expd_full_txt("Ι").Test(); // check that Ι is not upper-cased to COMBINING GREEK YPOGEGRAMMENI; DATE:2014-02-24
|
||||
}
|
||||
@Test public void First_char_is_multi_byte_assymetrical() { // PURPOSE: test multi-byte asymmetry (lc is 3 bytes; uc is 2 bytes)
|
||||
fxt.Wiki().Lang().Case_mgr_utf8_();
|
||||
fxt.Wiki().Lang().Case_mgr_u8_();
|
||||
fxt.Init_ttl("ⱥ").Expd_full_txt("Ⱥ").Test();
|
||||
fxt.Init_ttl("ⱥab").Expd_full_txt("Ⱥab").Test(); // check that rest of title works fine
|
||||
fxt.Init_ttl("Help:ⱥab").Expd_full_txt("Help:Ⱥab").Test(); // check ns
|
||||
}
|
||||
@Test public void Ws__basic() { // PURPOSE: replace other whitespace with underscore; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
|
||||
fxt.Init_ttl("A B").Expd_full_txt("A B").Test();
|
||||
}
|
||||
@Test public void Ws__many() { // PURPOSE: replace other whitespace with underscore; PAGE:ja.w:Template:Location_map_USA New_York; DATE:2015-07-28
|
||||
fxt.Init_ttl("A\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000B").Expd_full_txt("A B").Test();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ public class Xow_lang_mgr {
|
||||
}
|
||||
public Bry_fmtr Html_div() {return html_div;} private final Bry_fmtr html_div = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5>~{toggle_btn}~{wikidata_link}</h5>"
|
||||
, " <h5>~{toggle_btn} (links: ~{len}) ~{wikidata_link}</h5>"
|
||||
, " <div~{toggle_hdr}>~{grps}"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
), "wikidata_link", "toggle_btn", "toggle_hdr", "grps");
|
||||
), "len", "wikidata_link", "toggle_btn", "toggle_hdr", "grps");
|
||||
public Bry_fmtr Html_wikidata_link() {return html_wikidata_link;} private final Bry_fmtr html_wikidata_link = Bry_fmtr.new_(" (<a href=\"/site/www.wikidata.org/wiki/~{qid}\">wikidata</a>)", "qid");
|
||||
public void Clear() {hash.Clear();}
|
||||
public void Itms_reg(Xow_xwiki_itm xwiki, Xoac_lang_itm lang) {
|
||||
@@ -111,7 +111,7 @@ class Xow_lang_html implements Bry_fmtr_arg {
|
||||
byte[] msg_lang = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_page_lang_header);
|
||||
byte[] wikidata_link = Bry_.Len_eq_0(qid) ? Bry_.Empty : lang_mgr.Html_wikidata_link().Bld_bry_many(tmp_bfr, qid);
|
||||
toggle_itm.Init(wiki, msg_lang);
|
||||
lang_mgr.Html_div().Bld_bfr_many(bfr, wikidata_link, toggle_itm.Html_toggle_btn(), toggle_itm.Html_toggle_hdr(), this);
|
||||
lang_mgr.Html_div().Bld_bfr_many(bfr, ttl_list.Count(), wikidata_link, toggle_itm.Html_toggle_btn(), toggle_itm.Html_toggle_hdr(), this);
|
||||
stage = 0;
|
||||
break;
|
||||
}
|
||||
@@ -141,9 +141,9 @@ class Xow_lang_html implements Bry_fmtr_arg {
|
||||
byte[] local_name = itm.Lang_name();
|
||||
byte[] badge_cls = Badge_cls(tmp_bfr, itm.Page_badges());
|
||||
if (wiki.Appe().Usere().Wiki().Xwiki_mgr().Get_by_key(domain) == null)
|
||||
tmp_bfr.Add(Xoh_href_parser.Href_https_bry).Add(domain).Add(Xoh_href_parser.Href_wiki_bry);
|
||||
tmp_bfr.Add(Xoh_href_.Bry__https).Add(domain).Add(Xoh_href_.Bry__wiki);
|
||||
else
|
||||
tmp_bfr.Add(Xoh_href_parser.Href_site_bry).Add(domain).Add(Xoh_href_parser.Href_wiki_bry);
|
||||
tmp_bfr.Add(Xoh_href_.Bry__site).Add(domain).Add(Xoh_href_.Bry__wiki);
|
||||
if (!itm.Empty_xwiki()) tmp_bfr.Add(page_name);
|
||||
grp.Html_itm().Bld_bfr_many(bfr, lang_key, domain, local_name, tmp_bfr.Xto_bry_and_clear(), page_name, badge_cls);
|
||||
++grp_counter;
|
||||
@@ -183,7 +183,7 @@ class Xow_lang_html implements Bry_fmtr_arg {
|
||||
Badge_none_cls = Bry_.new_a7("badge-none")
|
||||
, Cls_bgn = Bry_.new_a7(" class='")
|
||||
;
|
||||
private static Hash_adp_bry badges_hash = Hash_adp_bry.ci_ascii_()
|
||||
private static Hash_adp_bry badges_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_obj("Q17437798", Bry_.new_a7("badge-goodarticle"))
|
||||
.Add_str_obj("Q17437796", Bry_.new_a7("badge-featuredarticle"))
|
||||
.Add_str_obj("Q17559452", Bry_.new_a7("badge-recommendedarticle"))
|
||||
|
||||
@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_lang_mgr_tst {
|
||||
private Xow_lang_mgr_fxt fxt = new Xow_lang_mgr_fxt();
|
||||
private final Xow_lang_mgr_fxt fxt = new Xow_lang_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
fxt.tst("[[simple:Earth]] [[fr:Terre]] [[es:Tierra]] [[de:Erde]] [[it:Terre]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a></h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 5) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
@@ -47,7 +47,7 @@ public class Xow_lang_mgr_tst {
|
||||
@Test public void Empty() {
|
||||
fxt.tst("[[simple:]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a></h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
@@ -63,7 +63,7 @@ public class Xow_lang_mgr_tst {
|
||||
// fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_a7("zh"), Bry_.new_a7("zh.wikipedia.org"), Bry_.new_a7("http://zh.wikipedia.org/~{0}"));
|
||||
fxt.tst("[[zh:Earth]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a></h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
@@ -78,7 +78,7 @@ public class Xow_lang_mgr_tst {
|
||||
@Test public void Anchor() {// PURPOSE: A#b was not showing anchor "#b"; DATE:2013-10-23
|
||||
fxt.tst("[[simple:A#b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a></h5>"
|
||||
, " <h5><a href='javascript:xowa_toggle_visible(\"wikidata-langs\");' style='text-decoration: none !important;'>In other languages<img id='wikidata-langs-toggle-icon' src='file:///mem/xowa/user/test_user/app/img/window/portal/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
public Xow_xwiki_itm(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry, byte[] domain_name) {
|
||||
@@ -46,9 +47,9 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
return new Xow_xwiki_itm(key_bry, url_fmt, lang_id, domain_tid, domain_bry, domain_bry);
|
||||
}
|
||||
public static Xow_xwiki_itm new_by_mw(Bry_bfr bfr, Gfo_url_parser url_parser, Gfo_url url, byte[] key, byte[] mw_url, byte[] domain_name) {// EX: "commons|//commons.wikimedia.org/wiki/Category:$1|Wikimedia Commons" "DMOZ|http://www.dmoz.org/Regional/Europe/$1/"|DMOZ"
|
||||
byte[] gfs_url = gplx.xowa.apps.Xoa_gfs_php_mgr.Xto_gfs(bfr, mw_url); // EX: "//commons.wikimedia.org/wiki/Category:$1" -> "//commons.wikimedia.org/wiki/Category:~{0}"
|
||||
byte[] gfs_url = gplx.xowa.apps.Xoa_gfs_php_mgr.Xto_gfs(bfr, mw_url); // EX: "//commons.wikimedia.org/wiki/Category:$1" -> "//commons.wikimedia.org/wiki/Category:~{0}"
|
||||
url_parser.Parse(url, gfs_url, 0, gfs_url.length);
|
||||
byte[] domain_bry = url.Site(); // extract "commons.wikimedia.org"
|
||||
byte[] domain_bry = url.Segs__get_at_1st(); // extract "commons.wikimedia.org"
|
||||
Xow_domain domain = Xow_domain_.parse(domain_bry);
|
||||
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key(domain.Lang_key());
|
||||
int lang_id = lang_itm == null ? Xol_lang_itm_.Id__unknown : lang_itm.Id();
|
||||
|
||||
@@ -16,7 +16,7 @@ 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.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.core.net.*; import gplx.xowa.wikis.*; import gplx.xowa.langs.*;
|
||||
public class Xow_xwiki_itm_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_xwiki_itm_fxt fxt = new Xow_xwiki_itm_fxt();
|
||||
@Test public void Commons() {fxt.Test_new_by_mw("commons.wikimedia.org/wiki/$1" , "commons.wikimedia.org" , "commons.wikimedia.org/wiki/~{0}" , Xow_domain_type_.Tid_commons , Xol_lang_itm_.Id__unknown);}
|
||||
|
||||
@@ -16,17 +16,20 @@ 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.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.html.hrefs.*;
|
||||
public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
private Xowe_wiki wiki; private Xow_xwiki_mgr_srl srl;
|
||||
private final Ordered_hash list = Ordered_hash_.new_bry_();
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.ci_a7();
|
||||
public Xow_xwiki_mgr() {} // FIXME: current placeholder for viewer
|
||||
public Xow_xwiki_mgr(Xowe_wiki wiki, Gfo_url_parser url_parser) {
|
||||
this.wiki = wiki;
|
||||
srl = new Xow_xwiki_mgr_srl(this, url_parser);
|
||||
}
|
||||
public Xow_lang_mgr Lang_mgr() {return lang_mgr;} private final Xow_lang_mgr lang_mgr = Xow_lang_mgr.dflt_();
|
||||
public int Len() {return list.Count();} private Ordered_hash list = Ordered_hash_.new_bry_(); private Hash_adp_bry hash = Hash_adp_bry.ci_ascii_(); // ASCII:lang_code
|
||||
public int Len() {return list.Count();}
|
||||
public void Clear() {hash.Clear(); list.Clear();}
|
||||
public Xow_xwiki_itm Get_at(int i) {return (Xow_xwiki_itm)list.Get_at(i);}
|
||||
public Xow_xwiki_itm Get_by_key(byte[] key) {return (Xow_xwiki_itm)hash.Get_by_bry(key);}
|
||||
@@ -91,13 +94,13 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
&& Bry_.Eq(alias, lang_itm.Key())) // alias == lang.key; only assign langs to aliases that have lang key; EX: w|en.wikipedia.org; "w" alias should not be registered for "en"; DATE:2013-07-25
|
||||
lang_id = lang_itm.Id();
|
||||
}
|
||||
byte[] url_fmt = Bry_.Add(Xoh_href_parser.Href_https_bry, domain_bry, Xoh_href_parser.Href_wiki_bry, Arg_0);
|
||||
byte[] url_fmt = Bry_.Add(Xoh_href_.Bry__https, domain_bry, Xoh_href_.Bry__wiki, Arg_0);
|
||||
return Xow_xwiki_itm.new_(alias, url_fmt, lang_id, domain.Domain_tid(), domain_bry);
|
||||
} static final byte[] Arg_0 = Bry_.new_a7("~{0}");
|
||||
String Exec_itms_print(byte[] raw) {
|
||||
Bry_fmtr fmtr = Bry_fmtr.new_bry_(raw, "wiki_key");//, "wiki_type_url", "wiki_lang", "wiki_name", "wiki_logo_url");
|
||||
Bry_bfr tmp_bfr = Xoa_app_.Utl__bfr_mkr().Get_k004();
|
||||
Hash_adp_bry seen = Hash_adp_bry.ci_ascii_(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
Hash_adp_bry seen = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
int wikis_len = list.Count();
|
||||
for (int i = 0; i < wikis_len; i++) {
|
||||
Xow_xwiki_itm itm = (Xow_xwiki_itm)list.Get_at(i);
|
||||
@@ -195,7 +198,7 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
list.Add_if_dupe_use_nth(xwiki_key, xwiki); // only add to list if domain is new; some wikis like commons will be added multiple times under different aliases (commons, c, commons.wikimedia.org); need to check domain and add only once DATE:2014-11-07
|
||||
}
|
||||
hash.Add_if_dupe_use_nth(xwiki_key, xwiki);
|
||||
} private final Hash_adp_bry domain_hash = Hash_adp_bry.ci_ascii_();
|
||||
} private final Hash_adp_bry domain_hash = Hash_adp_bry.ci_a7();
|
||||
public void Add_many(byte[] v) {srl.Load_by_bry(v);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_count)) return list.Count();
|
||||
|
||||
@@ -16,6 +16,7 @@ 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.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.srls.dsvs.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
class Xow_xwiki_mgr_srl extends Dsv_wkr_base {
|
||||
private byte[] key, url_fmt, name;
|
||||
|
||||
Reference in New Issue
Block a user