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:
@@ -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