mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Source: Restore broken commit
This commit is contained in:
60
400_xowa/src/gplx/xowa/wikis/xwikis/Xow_xwiki_itm.java
Normal file
60
400_xowa/src/gplx/xowa/wikis/xwikis/Xow_xwiki_itm.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
private final boolean show_in_sitelangs_base;
|
||||
public Xow_xwiki_itm(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry, byte[] domain_name, byte[] abrv_wm) {
|
||||
this.key_bry = key_bry; this.key_str = String_.new_u8(key_bry);
|
||||
this.url_fmt = url_fmt; this.lang_id = lang_id;
|
||||
this.url_fmtr = Bry_.Len_eq_0(url_fmt) ? null : Bry_fmtr.new_(url_fmt, "0");
|
||||
this.domain_tid = domain_tid; this.domain_bry = domain_bry; this.domain_name = domain_name; this.abrv_wm = abrv_wm;
|
||||
this.show_in_sitelangs_base = Calc_show_in_sitelangs(key_bry, url_fmt, lang_id, domain_tid, domain_bry);
|
||||
}
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: commons
|
||||
public String Key_str() {return key_str;} private final String key_str;
|
||||
public byte[] Url_fmt() {return url_fmt;} private final byte[] url_fmt; // EX: //commons.wikimedia.org/wiki/Category:$1
|
||||
public Bry_fmtr Url_fmtr(){return url_fmtr;} private final Bry_fmtr url_fmtr;
|
||||
public int Lang_id() {return lang_id;} private final int lang_id; // EX: Id__unknown
|
||||
public int Domain_tid() {return domain_tid;} private final int domain_tid; // EX: Tid_int_commons
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry; // EX: commons.wikimedia.org
|
||||
public byte[] Domain_name() {return domain_name;} private final byte[] domain_name; // EX: Wikimedia Commons
|
||||
public byte[] Abrv_wm() {return abrv_wm;} private final byte[] abrv_wm; // EX: enwiki; needed for sitelinks
|
||||
public boolean Offline() {return offline;} public Xow_xwiki_itm Offline_(boolean v) {offline = v; return this;} private boolean offline;
|
||||
public int compareTo(Object obj) {Xow_xwiki_itm comp = (Xow_xwiki_itm)obj; return Bry_.Compare(key_bry, comp.key_bry);}
|
||||
public boolean Show_in_sitelangs(byte[] cur_lang_key) {
|
||||
return show_in_sitelangs_base
|
||||
&& !Bry_.Eq(key_bry, cur_lang_key) // lang is different than current; EX: [[en:A]] in en.wikipedia.org shouldn't link back to self
|
||||
;
|
||||
}
|
||||
public static Xow_xwiki_itm new_(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry, byte[] abrv_wm) {
|
||||
return new Xow_xwiki_itm(key_bry, url_fmt, lang_id, domain_tid, domain_bry, domain_bry, abrv_wm);
|
||||
}
|
||||
private static boolean Calc_show_in_sitelangs(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry) {
|
||||
key_bry = Xow_domain_itm_.Alt_domain__get_subdomain_by_lang(key_bry); // handle "nb" as alias for "no.wikipedia.org"; PAGE: nn.w:; DATE:2015-12-04
|
||||
int key_len = key_bry.length;
|
||||
boolean key_matches_domain_bgn = Bry_.Match(domain_bry, 0, key_len, key_bry) && key_len + 1 < domain_bry.length && domain_bry[key_len] == Byte_ascii.Dot; // key + . matches start of domain; EX: "en" and "en.wikipedia.org"
|
||||
return lang_id != Xol_lang_stub_.Id__unknown // valid lang code
|
||||
&& domain_tid != Xow_domain_tid_.Tid__commons // commons should never be considered an xwiki_lang; EX:[[commons:A]] PAGE:species:Scarabaeidae; DATE:2014-09-10
|
||||
&& Bry_.Len_gt_0(url_fmt) // url_fmt exists
|
||||
&& key_matches_domain_bgn
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
49
400_xowa/src/gplx/xowa/wikis/xwikis/Xow_xwiki_itm_tst.java
Normal file
49
400_xowa/src/gplx/xowa/wikis/xwikis/Xow_xwiki_itm_tst.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_tst {
|
||||
private final Xow_xwiki_itm_fxt fxt = new Xow_xwiki_itm_fxt();
|
||||
@Test public void Show_in_sitelangs__basic() { // PURPOSE: basic test for show in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__lang_like() { // PURPOSE: only consider xwikis with key similar to domain; EX: [[w:A]] in simplewiki; PAGE:Main_Page; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("w", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__same() { // PURPOSE: same wiki should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("en", "en.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "en");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__no_url_fmt() { // PURPOSE: xwikis with no format should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("en", "", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__commons() { // PURPOSE: commons should not appear in "In other languages"; DATE:2015-11-06
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.N, fxt.Make__xwiki("c", "commons.wikimedia.org/wiki/{0}", Xol_lang_stub_.Id__intl, Xow_domain_tid_.Tid__commons, "commons.wikimedia.org", "commonswiki"), "en");
|
||||
}
|
||||
@Test public void Show_in_sitelangs__nb() { // PURPOSE: handle special wikis like nb, lzh, simple; EX: [[nb:]] -> no.w; PAGE:nn.w:; DATE:2015-12-04
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("nb", "no.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_no, Xow_domain_tid_.Tid__wikipedia, "no.wikipedia.org", "nbwiki"), "nn");
|
||||
fxt.Test__type_is_xwiki_lang(Bool_.Y, fxt.Make__xwiki("lzh", "zh-classical.wikipedia.org/wiki/{0}", Xol_lang_stub_.Id_zh, Xow_domain_tid_.Tid__wikipedia, "zh-classical.wikipedia.org", "lzwwiki"), "zh");
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_itm_fxt {
|
||||
public Xow_xwiki_itm Make__xwiki(String key_bry, String url_fmt, int lang_id, int domain_tid, String domain_bry, String abrv_wm) {
|
||||
return Xow_xwiki_itm.new_(Bry_.new_u8(key_bry), Bry_.new_u8(url_fmt), lang_id, domain_tid, Bry_.new_u8(domain_bry), Bry_.new_u8(abrv_wm));
|
||||
}
|
||||
public void Test__type_is_xwiki_lang(boolean expd, Xow_xwiki_itm xwiki_itm, String cur_lang_key) {
|
||||
Tfds.Eq_bool(expd, xwiki_itm.Show_in_sitelangs(Bry_.new_u8(cur_lang_key)));
|
||||
}
|
||||
}
|
||||
92
400_xowa/src/gplx/xowa/wikis/xwikis/Xow_xwiki_mgr.java
Normal file
92
400_xowa/src/gplx/xowa/wikis/xwikis/Xow_xwiki_mgr.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.htmls.hrefs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
public class Xow_xwiki_mgr {
|
||||
private final Ordered_hash list = Ordered_hash_.New_bry(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7();
|
||||
private final Xow_wiki wiki;
|
||||
public Xow_xwiki_mgr(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.xwiki_domain_tid = Xwiki_tid(wiki.Domain_tid());
|
||||
}
|
||||
public int Xwiki_domain_tid() {return xwiki_domain_tid;} private int xwiki_domain_tid;
|
||||
public int Len() {return list.Count();}
|
||||
public void Clear() {hash.Clear(); list.Clear();}
|
||||
public void Sort_by_key() {list.Sort();}
|
||||
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);}
|
||||
public Xow_xwiki_itm Get_by_mid(byte[] src, int bgn, int end) {return (Xow_xwiki_itm)hash.Get_by_mid(src, bgn, end);}
|
||||
public Xow_xwiki_itm Add_by_atrs(String key, String domain) {return Add_by_atrs(Bry_.new_a7(key), Bry_.new_a7(domain), null);}
|
||||
public Xow_xwiki_itm Add_by_atrs(byte[] key, byte[] domain) {return Add_by_atrs(key, domain, null);}
|
||||
public Xow_xwiki_itm Add_by_atrs(byte[] key, byte[] domain_bry, byte[] url_fmt) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
Xow_xwiki_itm itm = Xow_xwiki_itm.new_(key, url_fmt, domain_itm.Lang_actl_uid(), domain_itm.Domain_type_id(), domain_bry, domain_itm.Abrv_wm());
|
||||
Add_itm(itm);
|
||||
return itm;
|
||||
}
|
||||
public void Add_by_sitelink_mgr() {Add_by_sitelink_mgr(wiki.Domain_tid());}
|
||||
public void Add_by_sitelink_mgr(int domain_tid) {
|
||||
String wiki_tid_name_str = String_.new_u8(Xow_domain_tid_.Get_type_as_bry(domain_tid));
|
||||
Xoa_sitelink_itm_mgr itm_mgr = wiki.App().Xwiki_mgr__sitelink_mgr().Itm_mgr();
|
||||
int len = itm_mgr.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_itm itm = (Xoa_sitelink_itm)itm_mgr.Get_at(i);
|
||||
byte[] itm_key = itm.Key(); // EX: "fr" as in "[[fr:]]"
|
||||
byte[] domain_bry = Bry_.new_u8(String_.Format("{0}.{1}.org", String_.new_u8(itm_key), wiki_tid_name_str)); // EX: fr.wikipedia.org
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
byte[] abrv_wm = domain_itm == null ? null : domain_itm.Abrv_wm();
|
||||
Xow_xwiki_itm xwiki = Xow_xwiki_itm.new_(itm_key, Bld_url_fmt(domain_bry), domain_itm.Lang_actl_uid(), domain_tid, domain_bry, abrv_wm);
|
||||
Add_itm(xwiki);
|
||||
}
|
||||
}
|
||||
public void Add_by_csv(byte[] src) {
|
||||
synchronized (list) { // THREAD: parser stores state at app-level
|
||||
Xow_xwiki_itm_parser itm_parser = wiki.App().Xwiki_mgr__itm_parser();
|
||||
itm_parser.Init_by_wiki(wiki.Domain_itm());
|
||||
itm_parser.Load_by_bry(src);
|
||||
Ordered_hash xwiki_list = itm_parser.Xwiki_list();
|
||||
int len = xwiki_list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_xwiki_itm itm = (Xow_xwiki_itm)xwiki_list.Get_at(i);
|
||||
Add_itm(itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Add_itm(Xow_xwiki_itm itm) {
|
||||
byte[] key_bry = itm.Key_bry();
|
||||
if (wiki.Ns_mgr().Names_get_or_null(key_bry) != null) return;// NOTE: do not add xwiki if key matches Srch_rslt_cbk; EX: en.wiktionary.org has ns of "Wiktionary"; do not add key of "wiktionary"; note that wikipedia does have an key to wiktionary
|
||||
list.Add_if_dupe_use_nth(key_bry, itm); // NOTE: 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(key_bry, itm);
|
||||
}
|
||||
private static int Xwiki_tid(int tid) {
|
||||
switch (tid) {
|
||||
case Xow_domain_tid_.Tid__commons: case Xow_domain_tid_.Tid__species: case Xow_domain_tid_.Tid__incubator:
|
||||
case Xow_domain_tid_.Tid__mediawiki: case Xow_domain_tid_.Tid__wmfblog: case Xow_domain_tid_.Tid__home:
|
||||
return Xow_domain_tid_.Tid__wikipedia; // set xwiki_tid to wikipedia; allows [[da:Page]] to point to da.wikipedia.org; PAGE:species:Puccinia; DATE:2014-09-14
|
||||
default: return tid;
|
||||
}
|
||||
}
|
||||
public static byte[] Get_domain_from_url(Gfo_url_parser url_parser, byte[] url_fmt) { // extract "commons.wikimedia.org" from "http://commons.wikimedia.org/wiki/Category:~{0}"
|
||||
Gfo_url url = url_parser.Parse(url_fmt, 0, url_fmt.length);
|
||||
return url.Segs__get_at_1st();
|
||||
}
|
||||
public static byte[] Bld_url_fmt(byte[] domain_bry) {return Bry_.Add(gplx.core.net.Gfo_protocol_itm.Itm_https.Text_bry(), domain_bry, Bry__url_fmt_end);}
|
||||
private static final byte[] Bry__url_fmt_end = Bry_.new_a7("/wiki/~{0}");
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.apps.gfs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_bldr {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||
public Xow_xwiki_itm Bld_mw(Xow_domain_itm cur_domain, byte[] key, byte[] mw_url, byte[] domain_name) {return Bld_xo(cur_domain, key, Gfs_php_converter.To_gfs(tmp_bfr, mw_url), domain_name);} // EX: "//commons.wikimedia.org/wiki/Category:$1" -> "//commons.wikimedia.org/wiki/Category:~{0}"
|
||||
public Xow_xwiki_itm Bld_xo(Xow_domain_itm cur_domain, byte[] key, byte[] xo_url, byte[] domain_name) {
|
||||
byte[] domain_bry = Xow_xwiki_mgr.Get_domain_from_url(url_parser, xo_url);
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(domain_itm.Lang_actl_key());
|
||||
int lang_id = lang_itm == null ? Xol_lang_stub_.Id__unknown : lang_itm.Id();
|
||||
if (domain_name == null) { // no hard-coded name; currently dmoz or commons
|
||||
domain_name = (byte[])domain_name_hash.Get_by_bry(domain_bry); // NOTE: domain_name is needed for "Related Sites" in wikivoyage
|
||||
if (domain_name == null) {
|
||||
if ( cur_domain.Domain_type_id() != Xow_domain_tid_.Tid__wikipedia // cur_domain is not wikipedia
|
||||
&& domain_itm.Domain_type_id() == Xow_domain_tid_.Tid__wikipedia // domain_itm is wikipedia
|
||||
&& cur_domain.Lang_actl_uid() == domain_itm.Lang_actl_uid() // cur_domain lang matches domain_lang
|
||||
) {
|
||||
domain_name = Bry__domain_name__wikipedia; // EX: in "en.wikivoyage.org", "en.wikipedia.org" should have name of "Wikipedia" (not "en.wikipedia.org")
|
||||
}
|
||||
else
|
||||
domain_name = domain_bry; // default to domain_bry
|
||||
}
|
||||
}
|
||||
return new Xow_xwiki_itm(key, xo_url, lang_id, domain_itm.Domain_type_id(), domain_bry, domain_name, cur_domain.Abrv_wm());
|
||||
}
|
||||
private static final Hash_adp_bry domain_name_hash = Hash_adp_bry.cs()
|
||||
.Add_str_obj("commons.wikimedia.org" , Bry_.new_a7("Wikimedia Commons"))
|
||||
.Add_str_obj("www.dmoz.org" , Bry_.new_a7("DMOZ"))
|
||||
;
|
||||
private static final byte[] Bry__domain_name__wikipedia = Bry_.new_a7("Wikipedia");
|
||||
public static final Xow_xwiki_itm_bldr Instance = new Xow_xwiki_itm_bldr(); Xow_xwiki_itm_bldr() {}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_bldr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_xwiki_itm_bldr_fxt fxt = new Xow_xwiki_itm_bldr_fxt();
|
||||
@Test public void Commons() {fxt.Test_bld("commons.wikimedia.org/wiki/$1" , "commons.wikimedia.org" , "commons.wikimedia.org/wiki/~{0}" , Xow_domain_tid_.Tid__commons , Xol_lang_stub_.Id__unknown);}
|
||||
@Test public void Wiktionary() {fxt.Test_bld("fr.wiktionary.org/wiki/$1" , "fr.wiktionary.org" , "fr.wiktionary.org/wiki/~{0}" , Xow_domain_tid_.Tid__wiktionary , Xol_lang_stub_.Id_fr);}
|
||||
@Test public void Lang() {fxt.Test_bld("fr.wikipedia.org/wiki/$1" , "fr.wikipedia.org" , "fr.wikipedia.org/wiki/~{0}" , Xow_domain_tid_.Tid__wikipedia , Xol_lang_stub_.Id_fr);}
|
||||
}
|
||||
class Xow_xwiki_itm_bldr_fxt {
|
||||
private Xow_domain_itm domain_itm;
|
||||
public void Clear() {
|
||||
domain_itm = Xow_domain_itm.new_(Bry_.new_a7("en.wikivoyage.org"), Xow_domain_tid_.Tid__wikivoyage, Xol_lang_itm_.Key_en); // NOTE: use "en.wikivoyage.org" to domain_name; needed for "Related sites"
|
||||
}
|
||||
public void Test_bld(String url, String expd_domain, String expd_url_fmt, int expd_wiki_tid, int expd_lang_tid) {
|
||||
Xow_xwiki_itm itm = Xow_xwiki_itm_bldr.Instance.Bld_mw(domain_itm, domain_itm.Domain_bry(), Bry_.new_u8(url), null);
|
||||
Tfds.Eq(expd_domain , String_.new_u8(itm.Domain_bry()));
|
||||
Tfds.Eq(expd_url_fmt , String_.new_u8(itm.Url_fmt()));
|
||||
Tfds.Eq(expd_wiki_tid , itm.Domain_tid(), "wiki");
|
||||
Tfds.Eq(expd_lang_tid , itm.Lang_id(), "lang");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.langs.dsvs.*;
|
||||
import gplx.xowa.langs.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.bldrs.*;
|
||||
public class Xow_xwiki_itm_parser extends Dsv_wkr_base {
|
||||
private Xow_domain_itm owner_domain_itm;
|
||||
private int cur_tid = -1; private byte[] cur_fld1, cur_fld2, cur_fld3;
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser();
|
||||
public Ordered_hash Xwiki_list() {return xwiki_list;} private final Ordered_hash xwiki_list = Ordered_hash_.New();
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {return new Dsv_fld_parser[] {Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser};}
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
switch (fld_idx) {
|
||||
case 0: cur_tid = Bry_.To_int_or(src, bgn, end, -1); return true;
|
||||
case 1: cur_fld1 = Bry_.Mid(src, bgn, end); return true;
|
||||
case 2: cur_fld2 = Bry_.Mid(src, bgn, end); return true;
|
||||
case 3: cur_fld3 = Bry_.Mid(src, bgn, end); return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
public Xow_xwiki_itm_parser Init_by_wiki(Xow_domain_itm owner_domain_itm) {this.owner_domain_itm = owner_domain_itm; return this;}
|
||||
@Override public void Load_by_bry_bgn() {xwiki_list.Clear();}
|
||||
@Override public void Commit_itm(Dsv_tbl_parser parser, int pos) {
|
||||
byte[][] key_ary = Bry_split_.Split(cur_fld1, Byte_ascii.Semic); // allow multiple key defs; EX: "w;wikipedia"
|
||||
boolean xwiki_is_mw = true;
|
||||
byte[] domain_name = cur_fld3; // NOTE: by happenstance, domain_name is always cur_fld3
|
||||
byte[] url_fmt = null, domain_bry = null;
|
||||
switch (cur_tid) {
|
||||
case Tid__manual: // EX: "0|domz|http://www.dmoz.org/~{0}|DMOZ"
|
||||
xwiki_is_mw = false;
|
||||
url_fmt = cur_fld2;
|
||||
domain_bry = Xow_xwiki_mgr.Get_domain_from_url(url_parser, url_fmt);
|
||||
break;
|
||||
case Tid__mw_domain: // EX: "1|w|en.wikipedia.org"
|
||||
domain_bry = cur_fld2;
|
||||
break;
|
||||
case Tid__wm_peer: // EX: "2|wikt|wikipedia"
|
||||
domain_bry = Bry_.Add(owner_domain_itm.Lang_actl_key(), Byte_ascii.Dot_bry, cur_fld2, gplx.xowa.apps.urls.Xow_url_parser.Bry_dot_org);
|
||||
break;
|
||||
case Tid__wm_lang: // EX: "3|en;english|en|English"
|
||||
domain_bry = Bry_.Add(cur_fld2, Byte_ascii.Dot_bry, owner_domain_itm.Domain_type().Key_bry(), gplx.xowa.apps.urls.Xow_url_parser.Bry_dot_org);
|
||||
break;
|
||||
default: throw Err_.new_unhandled(cur_tid);
|
||||
}
|
||||
byte[] abrv_wm = null;
|
||||
int lang_id = Xol_lang_stub_.Id__unknown, domain_tid = Xow_domain_tid_.Tid__other;
|
||||
if (xwiki_is_mw) {
|
||||
url_fmt = Xow_xwiki_mgr.Bld_url_fmt(domain_bry);
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
if (Bry_.Len_eq_0(domain_name)) { // no name; build default
|
||||
Xol_lang_stub stub_itm = Xol_lang_stub_.Get_by_key_or_null(domain_itm.Lang_actl_itm().Key());
|
||||
byte[] lang_name = stub_itm == null ? Bry_.Empty : stub_itm.Canonical_name();
|
||||
domain_name = Bry_.Add_w_dlm(Byte_ascii.Space, lang_name, domain_itm.Domain_type().Display_bry());
|
||||
}
|
||||
abrv_wm = domain_itm.Abrv_wm();
|
||||
lang_id = domain_itm.Lang_actl_uid();
|
||||
domain_tid = domain_itm.Domain_type_id();
|
||||
}
|
||||
Create_xwikis(key_ary, url_fmt, lang_id, domain_tid, domain_bry, domain_name, abrv_wm);
|
||||
cur_tid = -1;
|
||||
cur_fld1 = cur_fld2 = cur_fld3 = null;
|
||||
}
|
||||
private void Create_xwikis(byte[][] key_ary, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry, byte[] domain_name, byte[] abrv_wm) {
|
||||
for (byte[] key : key_ary) {
|
||||
Xow_xwiki_itm itm = Xow_xwiki_itm_bldr.Instance.Bld_xo(owner_domain_itm, key, url_fmt, domain_name);
|
||||
xwiki_list.Add(key, itm);
|
||||
}
|
||||
}
|
||||
public static final int
|
||||
Tid__manual = 0
|
||||
, Tid__mw_domain = 1
|
||||
, Tid__wm_peer = 2
|
||||
, Tid__wm_lang = 3
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm_parser_tst {
|
||||
private final Xow_xwiki_itm_parser_fxt fxt = new Xow_xwiki_itm_parser_fxt();
|
||||
@Test public void Manual() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "0|a|https://a.org/~{0}|A"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "a|https://a.org/~{0}|A"
|
||||
));
|
||||
}
|
||||
@Test public void Mw_domain() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "1|w|en.wikipedia.org|Wikipedia"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "w|https://en.wikipedia.org/wiki/~{0}|Wikipedia"
|
||||
));
|
||||
}
|
||||
@Test public void Wm_peer() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt|wiktionary|Wiktionary"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
));
|
||||
}
|
||||
@Test public void Wm_lang() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "3|fr|fr|French"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "fr|https://fr.wikipedia.org/wiki/~{0}|French"
|
||||
));
|
||||
}
|
||||
@Test public void Multiple() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt;wiktionary|wiktionary|Wiktionary"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
, "wiktionary|https://en.wiktionary.org/wiki/~{0}|Wiktionary"
|
||||
));
|
||||
}
|
||||
@Test public void Default_name() {
|
||||
fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
( "2|wikt|wiktionary|"
|
||||
));
|
||||
fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
( "wikt|https://en.wiktionary.org/wiki/~{0}|English Wiktionary"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_itm_parser_fxt {
|
||||
private final Xow_xwiki_itm_parser parser = new Xow_xwiki_itm_parser();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public Xow_xwiki_itm_parser_fxt() {
|
||||
parser.Init_by_wiki(Xow_domain_itm_.parse(Bry_.new_a7("en.wikipedia.org")));
|
||||
}
|
||||
public void Exec_parse(String raw) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Load_by_bry(src);
|
||||
}
|
||||
public void Test_parse(String expd) {
|
||||
Tfds.Eq_str_lines(expd, To_str());
|
||||
}
|
||||
private String To_str() {
|
||||
Ordered_hash list = parser.Xwiki_list();
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_xwiki_itm itm = (Xow_xwiki_itm)list.Get_at(i);
|
||||
tmp_bfr.Add(itm.Key_bry()).Add_byte_pipe();
|
||||
tmp_bfr.Add(itm.Url_fmt()).Add_byte_pipe();
|
||||
tmp_bfr.Add(itm.Domain_name()).Add_byte_nl();
|
||||
}
|
||||
list.Clear();
|
||||
return tmp_bfr.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.langs.*;
|
||||
public class Xow_xwiki_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_xwiki_mgr_fxt fxt = new Xow_xwiki_mgr_fxt();
|
||||
@Test public void Add_bulk_langs_wiki() {
|
||||
fxt.Init_langs();
|
||||
fxt.Test_add_bulk_langs
|
||||
( fxt.xwiki_("en", "en.wikipedia.org", "https://en.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("de", "de.wikipedia.org", "https://de.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("fr", "fr.wikipedia.org", "https://fr.wikipedia.org/wiki/~{0}")
|
||||
, fxt.xwiki_("ja", "ja.wikipedia.org", "https://ja.wikipedia.org/wiki/~{0}")
|
||||
);
|
||||
}
|
||||
@Test public void Add_bulk_langs_grp_commons() {
|
||||
fxt.Init_langs();
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_sitelink_mgr(Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Tst_itms(fxt.xwiki_("de", "de.wikipedia.org", "https://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "https://fr.wikipedia.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers() {
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_("wikt", "en.wiktionary.org"
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("wiktionary", "en.wiktionary.org"
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("s", "en.wikisource.org", "https://en.wikisource.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_skip_self() { // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is Srch_rslt_cbk; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_null_("wikipedia")
|
||||
, fxt.xwiki_("w", "en.wikipedia.org", "https://en.wikipedia.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_tid() { // PURPOSE:wikt should generate wiki_tid of wiktionary, not wikipedia; PAGE:en.s:Main_Page DATE:2014-09-14
|
||||
fxt.Init_wikt ().Test_add_bulk_peers(fxt.xwiki_("wikt", "en.wiktionary.org", "https://en.wiktionary.org/wiki/~{0}"));
|
||||
}
|
||||
// @Test public void Duplicate() { // PURPOSE.FIX: multiple aliases for same domain should only be added once to Get_at's list; DATE:2014-11-07
|
||||
// fxt.Exec_parse(String_.Concat_lines_nl_skip_last
|
||||
// ( "0|a1|a.org"
|
||||
// , "0|a2|a.org"
|
||||
// ));
|
||||
// fxt.Test_parse(String_.Concat_lines_nl_skip_last
|
||||
// ( "a1|https://a.org//~{0}"
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
class Xow_xwiki_mgr_fxt {
|
||||
Xow_xwiki_mgr xwiki_mgr; Xoa_lang_mgr lang_mgr; String_bldr sb = String_bldr_.new_(); Xoae_app app; Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
if (xwiki_mgr == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
xwiki_mgr = wiki.Xwiki_mgr();
|
||||
lang_mgr = app.Lang_mgr();
|
||||
}
|
||||
xwiki_mgr.Clear();
|
||||
lang_mgr.Clear();
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;}
|
||||
public Xow_xwiki_itm xwiki_null_(String key) {return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.Empty, Xol_lang_stub_.Id__unknown, Xow_domain_tid_.Tid__other, Bry_.Empty, Bry_.Empty);}
|
||||
public Xow_xwiki_itm xwiki_(String key, String domain_str, String url_fmt) {
|
||||
Xow_domain_itm domain = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
return Xow_xwiki_itm.new_(Bry_.new_u8(key), Bry_.new_u8(url_fmt), domain.Lang_actl_itm().Id(), domain.Domain_type_id(), domain.Domain_bry(), domain.Abrv_wm());
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_langs() {
|
||||
app.Xwiki_mgr__sitelink_mgr().Parse(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "0|english"
|
||||
, "1|en|English"
|
||||
, "0|europe_west"
|
||||
, "1|fr|French"
|
||||
, "1|de|German"
|
||||
, "0|asia_east"
|
||||
, "1|ja|Japanese"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_peers() {
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "1|d|www.wikidata.org"
|
||||
, "2|wikt;wiktionary|wiktionary"
|
||||
, "2|s|wikisource"
|
||||
, "2|w;wikipedia|wikipedia"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Init_wikt() {
|
||||
wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "2|wikt;wiktionary|wiktionary"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_langs(Xow_xwiki_itm... itms) {
|
||||
xwiki_mgr.Add_by_sitelink_mgr();
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_peers(Xow_xwiki_itm... itms) {
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Tst_itms(Xow_xwiki_itm... itms) {
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(To_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_len(int expd) {Tfds.Eq(expd, xwiki_mgr.Len()); return this;}
|
||||
Xow_xwiki_itm[] To_ary(Xow_xwiki_itm[] itms) {
|
||||
int len = itms.length;
|
||||
List_adp rv = List_adp_.New();
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] alias = itms[i].Key_bry();
|
||||
Xow_xwiki_itm itm = xwiki_mgr.Get_by_key(alias);
|
||||
if (itm == null) itm = xwiki_null_(String_.new_u8(alias)); // "null", ignore
|
||||
rv.Add(itm);
|
||||
}
|
||||
return (Xow_xwiki_itm[])rv.To_ary(Xow_xwiki_itm.class);
|
||||
}
|
||||
String Xto_str(Xow_xwiki_itm[] itms) {
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xow_xwiki_itm itm = itms[i];
|
||||
if (Bry_.Len_eq_0(itm.Domain_bry())) // "null", ignore
|
||||
sb.Add(itm.Key_bry()).Add_char_nl();
|
||||
else {
|
||||
sb.Add(itm.Key_bry()).Add_char_pipe().Add(itm.Domain_bry()).Add_char_pipe().Add(itm.Url_fmt()).Add_char_pipe().Add(itm.Domain_tid()).Add_char_nl();
|
||||
}
|
||||
}
|
||||
return sb.To_str_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xoa_sitelink_grp implements gplx.CompareAble {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
public Xoa_sitelink_grp(byte[] name, int sort) {
|
||||
this.name = name;
|
||||
this.sort = sort;
|
||||
}
|
||||
public byte[] Name() {return name;} private final byte[] name;
|
||||
public int Sort() {return sort;} private final int sort;
|
||||
public int Len() {return hash.Count();}
|
||||
public Xoa_sitelink_itm Get_at(int i) {return (Xoa_sitelink_itm)hash.Get_at(i);}
|
||||
public void Add(Xoa_sitelink_itm itm) {hash.Add(itm.Key(), itm);}
|
||||
public void Del(byte[] key) {hash.Del(key);}
|
||||
public void Active_len__add() {++active_len;}
|
||||
public int Active_len() {return active_len;} private int active_len;
|
||||
public void Reset() {
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_itm itm = (Xoa_sitelink_itm)hash.Get_at(i);
|
||||
itm.Init_by_page(null, null, false, null); // clear out pre-existing page names; needed b/c this struct is a singleton for entire wiki
|
||||
}
|
||||
active_len = 0;
|
||||
}
|
||||
public int compareTo(Object obj) {Xoa_sitelink_grp comp = (Xoa_sitelink_grp)obj; return Int_.Compare(sort, comp.sort);}
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
bfr.Add_int_digits(1, Xoa_sitelink_mgr_parser.Tid__grp).Add_byte_pipe();
|
||||
bfr.Add(name).Add_byte_nl();
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_itm itm = (Xoa_sitelink_itm)hash.Get_at(i);
|
||||
itm.To_bfr(bfr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
public class Xoa_sitelink_grp_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
public Xoa_sitelink_grp_mgr() {
|
||||
this.default_grp = new Xoa_sitelink_grp(Bry_.new_a7("Others"), 1024);
|
||||
hash.Add(default_grp.Name(), default_grp);
|
||||
}
|
||||
public Xoa_sitelink_grp Default_grp() {return default_grp;} private final Xoa_sitelink_grp default_grp;
|
||||
public int Len() {return hash.Count();}
|
||||
public void Clear() {hash.Clear();}
|
||||
public Xoa_sitelink_grp Get_at(int idx) {return (Xoa_sitelink_grp)hash.Get_at(idx);}
|
||||
public Xoa_sitelink_grp Get_by_or_new(byte[] key) {
|
||||
Xoa_sitelink_grp rv = (Xoa_sitelink_grp)hash.Get_by(key);
|
||||
if (rv == null) {
|
||||
rv = new Xoa_sitelink_grp(key, hash.Count());
|
||||
hash.Add(key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Sort() {hash.Sort();}
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_grp grp = (Xoa_sitelink_grp)hash.Get_at(i);
|
||||
grp.To_bfr(bfr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_sitelink_itm {
|
||||
public Xoa_sitelink_itm(Xoa_sitelink_grp grp, byte[] key, byte[] name) {
|
||||
this.grp = grp; this.key = key; this.name = name;
|
||||
grp.Add(this);
|
||||
}
|
||||
public byte[] Key() {return key;} private final byte[] key; // EX: "en", "c"; NOTE: usually lang_key, but can be xwiki key
|
||||
public byte[] Name() {return name;} private byte[] name; // EX: "English", "Commons"
|
||||
public Xoa_sitelink_grp Grp() {return grp;} private Xoa_sitelink_grp grp; // EX: "Tier 1"
|
||||
public Xow_domain_itm Site_domain() {return site_domain;} private Xow_domain_itm site_domain; // EX: "en.wikipedia.org"; "commons.wikimedia.org"
|
||||
public byte[] Page_name() {return page_name;} private byte[] page_name; // EX: "Earth", "Terre"
|
||||
public boolean Page_name_is_empty() {return page_name_is_empty;} private boolean page_name_is_empty; // EX: [[fr:]]
|
||||
public byte[][] Page_badges() {return page_badges;} private byte[][] page_badges;
|
||||
|
||||
public void Init_by_page(Xow_domain_itm site_domain, byte[] page_name, boolean page_name_is_empty, byte[][] page_badges) {
|
||||
this.site_domain = site_domain;
|
||||
this.page_name = page_name; this.page_name_is_empty = page_name_is_empty; this.page_badges = page_badges;
|
||||
grp.Active_len__add();
|
||||
}
|
||||
public void Move_to(Xoa_sitelink_grp new_grp) {
|
||||
if (Bry_.Eq(new_grp.Name(), grp.Name())) return; // same grp
|
||||
grp.Del(key);
|
||||
new_grp.Add(this);
|
||||
this.grp = new_grp;
|
||||
}
|
||||
public void Grp_(Xoa_sitelink_grp v) {this.grp = v;}
|
||||
public void Site_name_(byte[] v) {this.name = v;}
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
bfr.Add_int_digits(1, Xoa_sitelink_mgr_parser.Tid__itm).Add_byte_pipe();
|
||||
bfr.Add(key).Add_byte_pipe();
|
||||
bfr.Add(name).Add_byte_nl();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xoa_sitelink_itm_mgr {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private final Xoa_sitelink_grp default_grp;
|
||||
public Xoa_sitelink_itm_mgr(Xoa_sitelink_grp default_grp) {this.default_grp = default_grp;}
|
||||
public int Len() {return hash.Count();}
|
||||
public void Clear() {hash.Clear();}
|
||||
public void Add(Xoa_sitelink_itm itm) {hash.Add(itm.Key(), itm);}
|
||||
public Xoa_sitelink_itm Get_at(int idx) {return (Xoa_sitelink_itm)hash.Get_at(idx);}
|
||||
public Xoa_sitelink_itm Get_by(byte[] key) {return (Xoa_sitelink_itm)hash.Get_by(key);}
|
||||
public Xoa_sitelink_itm Get_by_or_new(byte[] key) {
|
||||
Xoa_sitelink_itm rv = (Xoa_sitelink_itm)hash.Get_by(key);
|
||||
if (rv == null) {
|
||||
rv = new Xoa_sitelink_itm(default_grp, key, Bry_.Empty);
|
||||
hash.Add(key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.xowa.wikis.xwikis.sitelinks.htmls.*; import gplx.xowa.langs.*;
|
||||
public class Xoa_sitelink_mgr {
|
||||
private final Xoa_sitelink_div_wtr div_wtr = new Xoa_sitelink_div_wtr();
|
||||
public Xoa_sitelink_itm_mgr Itm_mgr() {return itm_mgr;} private final Xoa_sitelink_itm_mgr itm_mgr;
|
||||
public Xoa_sitelink_grp_mgr Grp_mgr() {return grp_mgr;} private final Xoa_sitelink_grp_mgr grp_mgr = new Xoa_sitelink_grp_mgr();
|
||||
public Xoa_sitelink_mgr() {
|
||||
this.itm_mgr = new Xoa_sitelink_itm_mgr(grp_mgr.Default_grp());
|
||||
}
|
||||
public void Init_by_app() { // add all langs
|
||||
Xoa_sitelink_grp default_grp = grp_mgr.Default_grp();
|
||||
Xol_lang_stub[] ary = Xol_lang_stub_.Ary();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xol_lang_stub stub = ary[i];
|
||||
Xoa_sitelink_itm itm = itm_mgr.Get_by(stub.Key());
|
||||
if (itm == null) { // note that some itms may already exist if user has defined custom names
|
||||
itm = new Xoa_sitelink_itm(default_grp, stub.Key(), stub.Canonical_name());
|
||||
itm_mgr.Add(itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Parse(byte[] src) {
|
||||
Xoa_sitelink_mgr_parser parser = new Xoa_sitelink_mgr_parser(this);
|
||||
parser.Load_by_bry(src);
|
||||
grp_mgr.Sort(); // sort again to put "Others" at bottom
|
||||
}
|
||||
public void Write_html(Bry_bfr bfr, Xowe_wiki wiki, List_adp slink_list, byte[] qid) {
|
||||
div_wtr.Write(bfr, wiki, this, slink_list, qid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import gplx.langs.dsvs.*;
|
||||
class Xoa_sitelink_mgr_parser extends Dsv_wkr_base {
|
||||
private final Xoa_sitelink_grp_mgr grp_mgr;
|
||||
private final Xoa_sitelink_itm_mgr itm_mgr;
|
||||
private int cur_tid = -1;
|
||||
private byte[] cur_fld1, cur_fld2;
|
||||
private Xoa_sitelink_grp cur_grp;
|
||||
public Xoa_sitelink_mgr_parser(Xoa_sitelink_mgr mgr) {this.grp_mgr = mgr.Grp_mgr(); this.itm_mgr = mgr.Itm_mgr();}
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {return new Dsv_fld_parser[] {Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser};}
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
switch (fld_idx) {
|
||||
case 0: cur_tid = Bry_.To_int_or(src, bgn, end, -1); return true;
|
||||
case 1: cur_fld1 = Bry_.Mid(src, bgn, end); return true;
|
||||
case 2: cur_fld2 = Bry_.Mid(src, bgn, end); return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
@Override public void Commit_itm(Dsv_tbl_parser parser, int pos) {
|
||||
switch (cur_tid) {
|
||||
case Tid__grp:
|
||||
cur_grp = grp_mgr.Get_by_or_new(cur_fld1);
|
||||
break;
|
||||
case Tid__itm:
|
||||
Xoa_sitelink_itm itm = itm_mgr.Get_by_or_new(cur_fld1);
|
||||
itm.Move_to(cur_grp);
|
||||
itm.Site_name_(cur_fld2);
|
||||
break;
|
||||
default: throw Err_.new_unhandled(cur_tid);
|
||||
}
|
||||
cur_tid = -1;
|
||||
cur_fld1 = cur_fld2 = null;
|
||||
}
|
||||
public static final int Tid__grp = 0, Tid__itm = 1;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_sitelink_mgr_parser_tst {
|
||||
private final Xoa_sitelink_mgr_parser_fxt fxt = new Xoa_sitelink_mgr_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Basic() {
|
||||
String raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|de|German"
|
||||
, "1|en|English"
|
||||
, "0|Tier 1"
|
||||
, "1|ar|Arabic"
|
||||
, "1|ca|Catalan"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
fxt.Test_parse(raw);
|
||||
}
|
||||
@Test public void Move() {
|
||||
String raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|de|German"
|
||||
, "0|Tier 1"
|
||||
, "1|ar|Arabic"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
raw = String_.Concat_lines_nl_skip_last
|
||||
( "0|Tier 0"
|
||||
, "1|ar|Arabic"
|
||||
, "0|Tier 1"
|
||||
, "1|de|German"
|
||||
);
|
||||
fxt.Exec_parse(raw);
|
||||
fxt.Test_parse(raw);
|
||||
}
|
||||
}
|
||||
class Xoa_sitelink_mgr_parser_fxt {
|
||||
private final Xoa_sitelink_mgr mgr = new Xoa_sitelink_mgr();
|
||||
private final Xoa_sitelink_mgr_parser parser;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
public void Clear() {mgr.Grp_mgr().Clear();}
|
||||
public Xoa_sitelink_mgr_parser_fxt() {
|
||||
this.parser = new Xoa_sitelink_mgr_parser(mgr);
|
||||
}
|
||||
public void Exec_parse(String raw) {
|
||||
byte[] src = Bry_.new_u8(raw);
|
||||
parser.Load_by_bry(src);
|
||||
}
|
||||
public void Test_parse(String expd) {
|
||||
mgr.Grp_mgr().To_bfr(tmp_bfr);
|
||||
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.xtns.wbases.core.*;
|
||||
public class Xoa_sitelink_div_wtr {
|
||||
private final Xoa_sitelink_grp_wtr grp_wtr = new Xoa_sitelink_grp_wtr();
|
||||
public void Write(Bry_bfr bfr, Xowe_wiki wiki, Xoa_sitelink_mgr mgr, List_adp slink_list, byte[] qid) {
|
||||
Xoa_sitelink_grp_mgr grp_mgr = mgr.Grp_mgr(); Xoa_sitelink_itm_mgr itm_mgr = mgr.Itm_mgr();
|
||||
// reset grps
|
||||
grp_wtr.Init_by_app(wiki.App());
|
||||
int grp_len = grp_mgr.Len();
|
||||
for (int i = 0; i < grp_len; ++i) {
|
||||
Xoa_sitelink_grp grp = grp_mgr.Get_at(i);
|
||||
grp.Reset();
|
||||
}
|
||||
// add itms to each grp
|
||||
int slink_len = slink_list.Count();
|
||||
for (int i = 0; i < slink_len; i++) {
|
||||
Wdata_sitelink_itm slink = (Wdata_sitelink_itm)slink_list.Get_at(i);
|
||||
Xoa_ttl ttl = slink.Page_ttl();
|
||||
Xoa_sitelink_itm itm = itm_mgr.Get_by(ttl.Wik_itm().Key_bry());
|
||||
if (itm == null) {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "sitelink itm missing; wiki=~{0} key=~{1} lnki_ttl=~{2}", wiki.Domain_bry(), ttl.Wik_itm().Key_bry(), ttl.Raw());
|
||||
continue;
|
||||
}
|
||||
byte[] ttl_bry = ttl.Page_txt_w_anchor();
|
||||
boolean ttl_is_empty = false;
|
||||
if (Bry_.Len_eq_0(ttl_bry)) { // NOTE: handles ttls like [[fr:]] and [[:fr;]] which have an empty Page_txt, but a valued Full_txt_raw
|
||||
ttl_bry = wiki.Parser_mgr().Ctx().Page().Ttl().Page_txt();
|
||||
ttl_is_empty = true;
|
||||
}
|
||||
itm.Init_by_page(slink.Domain_info(), ttl_bry, ttl_is_empty, slink.Badges());
|
||||
}
|
||||
// write html
|
||||
Xoapi_toggle_itm toggle_itm = wiki.Appe().Api_root().Html().Page().Toggle_mgr().Get_or_new("wikidata-langs");
|
||||
toggle_itm.Init(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_page_lang_header));
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b128();
|
||||
try {
|
||||
byte[] wikidata_link = Bry_.Len_eq_0(qid) ? Bry_.Empty : wbase_fmtr.Bld_bry_many(tmp_bfr, qid);
|
||||
div_fmtr.Bld_bfr_many(bfr, slink_len, wikidata_link, toggle_itm.Html_toggle_btn(), toggle_itm.Html_toggle_hdr(), grp_wtr.Fmt__init(grp_mgr));
|
||||
} finally {tmp_bfr.Mkr_rls();}
|
||||
}
|
||||
private static final Bry_fmtr wbase_fmtr = Bry_fmtr.new_(" (<a href=\"/site/www.wikidata.org/wiki/~{qid}\">wikidata</a>)", "qid");
|
||||
private static final Bry_fmtr div_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5>~{toggle_btn} (links: ~{len}) ~{wikidata_link}</h5>"
|
||||
, " <div~{toggle_hdr}>~{grps}"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
), "len", "wikidata_link", "toggle_btn", "toggle_hdr", "grps");
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.parsers.*;
|
||||
class Xoa_sitelink_div_wtr_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Init_langs(wiki);
|
||||
}
|
||||
public static void Init_langs(Xowe_wiki wiki) {
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Xwiki_mgr__sitelink_mgr().Parse(Bry_.new_u8(String_.Concat_lines_nl
|
||||
( "0|grp1"
|
||||
, "1|simple|Simple"
|
||||
, "1|es|Spanish"
|
||||
, "1|it|Italian"
|
||||
, "1|zh|Chinese"
|
||||
, "0|grp2"
|
||||
, "1|fr|French"
|
||||
, "1|de|German"
|
||||
)));
|
||||
wiki.Xwiki_mgr().Add_by_sitelink_mgr();
|
||||
wiki.Appe().Usere().Wiki().Xwiki_mgr().Add_by_csv(Bry_.new_a7(String_.Concat_lines_nl
|
||||
( "1|simple.wikipedia.org|simple.wikipedia.org"
|
||||
, "1|fr.wikipedia.org|fr.wikipedia.org"
|
||||
, "1|es.wikipedia.org|es.wikipedia.org"
|
||||
, "1|de.wikipedia.org|de.wikipedia.org"
|
||||
, "1|it.wikipedia.org|it.wikipedia.org"
|
||||
)));
|
||||
}
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
Xoae_app app;
|
||||
public void tst(String raw, String expd) {
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
|
||||
ctx.Page().Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7("test_page")));
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(raw_bry);
|
||||
wiki.Parser_mgr().Main().Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), raw_bry);
|
||||
wiki.Html_mgr().Html_wtr().Write_doc(bfr, ctx, raw_bry, root);
|
||||
|
||||
Bry_bfr html_bfr = Bry_bfr_.New();
|
||||
wiki.App().Xwiki_mgr__sitelink_mgr().Write_html(html_bfr, wiki, ctx.Page().Slink_list(), gplx.xowa.xtns.wbases.Wdata_xwiki_link_wtr.Qid_null);
|
||||
Tfds.Eq_str_lines(expd, html_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import org.junit.*;
|
||||
public class Xoa_sitelink_div_wtr_tst {
|
||||
private final Xoa_sitelink_div_wtr_fxt fxt = new Xoa_sitelink_div_wtr_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/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 5) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"Earth\" href=\"/site/simple.wikipedia.org/wiki/Earth\">Earth</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Spanish</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"es\" title=\"Tierra\" href=\"/site/es.wikipedia.org/wiki/Tierra\">Tierra</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Italian</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"it\" title=\"Terre\" href=\"/site/it.wikipedia.org/wiki/Terre\">Terre</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " <h4>grp2</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>French</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"fr\" title=\"Terre\" href=\"/site/fr.wikipedia.org/wiki/Terre\">Terre</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>German</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"de\" title=\"Erde\" href=\"/site/de.wikipedia.org/wiki/Erde\">Erde</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@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/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"Test page\" href=\"/site/simple.wikipedia.org/wiki/\">Test page</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Unregistered() {
|
||||
// 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/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Chinese</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"zh\" title=\"Earth\" href=\"https://zh.wikipedia.org/wiki/Earth\">Earth</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@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/bin/any/xowa/file/app.general/twisty_right.png' title='' /></a> (links: 1) </h5>"
|
||||
, " <div id='wikidata-langs-toggle-elem' style='display:none;'>"
|
||||
, " <h4>grp1</h4>"
|
||||
, " <table style='width: 100%;'>"
|
||||
, " <tr>"
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>Simple</td><td style='width: 20%; padding-bottom: 5px;'><li class='badge-none'><a hreflang=\"en\" title=\"A#b\" href=\"/site/simple.wikipedia.org/wiki/A#b\">A#b</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
, " <td/>"
|
||||
, " <td/>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
class Xoa_sitelink_grp_wtr implements gplx.core.brys.Bfr_arg {
|
||||
private final Xoa_sitelink_itm_wtr itm_wtr = new Xoa_sitelink_itm_wtr();
|
||||
private Xoa_sitelink_grp_mgr mgr;
|
||||
public void Init_by_app(Xoa_app app) {itm_wtr.Init_by_app(app);}
|
||||
public Xoa_sitelink_grp_wtr Fmt__init(Xoa_sitelink_grp_mgr mgr) {this.mgr = mgr; return this;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int len = mgr.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_grp grp = mgr.Get_at(i);
|
||||
if (grp.Active_len() == 0) continue; // skip grps with no items
|
||||
fmtr.Bld_bfr_many(bfr, grp.Name(), itm_wtr.Fmt__init(grp));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <h4>~{all_name}</h4>"
|
||||
, " <table style='width: 100%;'>~{grps}"
|
||||
, " </table>"
|
||||
), "all_name", "grps");
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
class Xoa_sitelink_itm_wtr implements gplx.core.brys.Bfr_arg {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(255);
|
||||
private Xoa_app app; private Xoa_sitelink_grp grp;
|
||||
public void Init_by_app(Xoa_app app) {this.app = app;}
|
||||
public Xoa_sitelink_itm_wtr Fmt__init(Xoa_sitelink_grp grp) {this.grp = grp; return this;}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int len = grp.Len();
|
||||
boolean tr_opened = false; int td_idx = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_itm itm = grp.Get_at(i);
|
||||
if (Bry_.Len_eq_0(itm.Page_name())) continue; // xwiki does not exist for current page
|
||||
if (td_idx == 0) {
|
||||
bfr.Add(tr_bgn);
|
||||
tr_opened = true;
|
||||
}
|
||||
Xow_domain_itm domain_itm = itm.Site_domain();
|
||||
byte[] domain_bry = domain_itm.Domain_bry();
|
||||
byte[] page_name = itm.Page_name();
|
||||
byte[] url_protocol = app.Xwiki_mgr__missing(domain_bry) ? Xoh_href_.Bry__https : Xoh_href_.Bry__site; // if wiki exists, "/site/", else "https://"
|
||||
byte[] url_page = itm.Page_name_is_empty() ? Bry_.Empty : page_name;
|
||||
byte[] url = Bry_.Add(url_protocol, domain_bry, Xoh_href_.Bry__wiki, url_page);
|
||||
td_fmtr.Bld_bfr_many(bfr, domain_itm.Lang_actl_key(), domain_itm.Domain_bry(), itm.Name(), url, page_name, Xoa_sitelink_itm_wtr__badge.Bld_badge_class(tmp_bfr, itm.Page_badges()));
|
||||
++td_idx;
|
||||
if (td_idx == td_max) {
|
||||
tr_opened = false;
|
||||
bfr.Add(tr_end);
|
||||
td_idx = 0;
|
||||
}
|
||||
}
|
||||
if (tr_opened) {
|
||||
for (int i = td_idx; i < td_max; ++i)
|
||||
bfr.Add(td_nil);
|
||||
bfr.Add(tr_end);
|
||||
}
|
||||
}
|
||||
private static final int td_max = 3;
|
||||
private static final byte[] tr_bgn = Bry_.new_a7("\n <tr>");
|
||||
private static final byte[] td_nil = Bry_.new_a7("\n <td/>");
|
||||
private static final byte[] tr_end = Bry_.new_a7("\n </tr>");
|
||||
private static final Bry_fmtr td_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <td style='width: 10%; padding-bottom: 5px;'>~{lang_name}</td><td style='width: 20%; padding-bottom: 5px;'><li~{page_badge}><a hreflang=\"~{lang_code}\" title=\"~{pagename_translation}\" href=\"~{lang_href}\">~{pagename_translation}</a></li></td><td style='width: 3%; padding-bottom: 5px;'></td>"
|
||||
), "lang_code", "lang_domain", "lang_name", "lang_href", "pagename_translation", "page_badge");
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
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.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
class Xoa_sitelink_itm_wtr__badge {
|
||||
public static byte[] Bld_badge_class(Bry_bfr bfr, byte[][] badge_ary) { // EX: "Q17437798", "Q17437796" -> "class='badge-goodarticle,badge-featuredarticle'"
|
||||
if (badge_ary == null) badge_ary = Bry_.Ary_empty;
|
||||
bfr.Add(Cls_bgn);
|
||||
int badges_len = badge_ary.length;
|
||||
if (badges_len == 0)
|
||||
bfr.Add(Badge_none_cls);
|
||||
else {
|
||||
for (int i = 0; i < badges_len; ++i) {
|
||||
if (i != 0) bfr.Add_byte_comma();
|
||||
byte[] badge_itm = badge_ary[i];
|
||||
byte[] badge_cls = (byte[])badges_hash.Get_by_bry(badge_itm);
|
||||
if (badge_cls == null)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "unknown badge: badge=~{0}", String_.new_u8(badge_itm));
|
||||
else
|
||||
bfr.Add(badge_cls);
|
||||
}
|
||||
}
|
||||
bfr.Add_byte_apos();
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
private static final byte[]
|
||||
Badge_none_cls = Bry_.new_a7("badge-none")
|
||||
, Cls_bgn = Bry_.new_a7(" class='")
|
||||
;
|
||||
private static final 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"))
|
||||
.Add_str_obj("Q17506997", Bry_.new_a7("badge-featuredlist"))
|
||||
.Add_str_obj("Q17580674", Bry_.new_a7("badge-featuredportal"))
|
||||
;
|
||||
}
|
||||
Reference in New Issue
Block a user