mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.9.2.1'
This commit is contained in:
@@ -70,7 +70,7 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk {
|
||||
byte[] lang_key = domain_itm.Lang_actl_key();
|
||||
if (lang_key == Xol_lang_stub_.Key__unknown) lang_key = Xol_lang_itm_.Key_en; // unknown langs default to english; note that this makes nonwmf english by default
|
||||
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_new(lang_key);
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Tid__other) {
|
||||
lang = new Xol_lang_itm(app.Lang_mgr(), Xol_lang_itm_.Key_en).Kwd_mgr__strx_(true); // create a new english lang, but enable strx functions; DATE:2015-08-23
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.brys.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.apps.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.bins.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.addons.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
@@ -29,7 +29,7 @@ import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.specials.mgrs.*;
|
||||
import gplx.xowa.addons.wikis.htmls.css.bldrs.*; import gplx.xowa.addons.wikis.htmls.css.mgrs.*;
|
||||
import gplx.xowa.addons.wikis.htmls.css.bldrs.*; import gplx.xowa.addons.wikis.htmls.css.mgrs.*; import gplx.xowa.addons.wikis.ctgs.htmls.pageboxs.*;
|
||||
public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
private final Xof_fsdb_mgr__sql fsdb_mgr; private Fsdb_db_mgr db_core_mgr;
|
||||
private boolean init_needed = true;
|
||||
@@ -41,6 +41,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
this.domain_abrv = Xow_abrv_wm_.To_abrv(Xow_domain_itm_.parse(domain_bry));
|
||||
this.ns_mgr = Xow_ns_mgr_.default_(app.Utl_case_mgr());
|
||||
this.lang = app.Lang_mgr().Get_by_or_en(domain_itm.Lang_actl_key()); // NOTE: must not be null, or causes null ref exception on redlinks in drd; DATE:2016-06-28
|
||||
this.msg_mgr = new Xow_msg_mgr(this, lang);
|
||||
this.html__hdump_mgr = new Xow_hdump_mgr(this);
|
||||
this.special_mgr = new Xosp_special_mgr(this);
|
||||
this.fsys_mgr = new Xow_fsys_mgr(wiki_root_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
|
||||
@@ -72,6 +73,9 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public boolean Html__css_installing() {return html__css_installing;} public void Html__css_installing_(boolean v) {html__css_installing = v;} private boolean html__css_installing;
|
||||
public Xoh_page_wtr_mgr Html__wtr_mgr() {return html__wtr_mgr;} private final Xoh_page_wtr_mgr html__wtr_mgr = new Xoh_page_wtr_mgr(Bool_.Y);
|
||||
public Xoctg_pagebox_wtr Html__ctg_pagebox_wtr() {return ctg_pagebox_wtr;} private final Xoctg_pagebox_wtr ctg_pagebox_wtr = new Xoctg_pagebox_wtr();
|
||||
public Xow_msg_mgr Msg_mgr() {return msg_mgr;} private final Xow_msg_mgr msg_mgr;
|
||||
public byte[] Wtxt__expand_tmpl(byte[] src) {return src;}
|
||||
public Xow_mw_parser_mgr Mw_parser_mgr() {return mw_parser_mgr;} private final Xow_mw_parser_mgr mw_parser_mgr = new Xow_mw_parser_mgr();
|
||||
public Xow_wiki_props Props() {return props;} private final Xow_wiki_props props = new Xow_wiki_props();
|
||||
public Xol_lang_itm Lang() {return lang;} private final Xol_lang_itm lang;
|
||||
@@ -105,6 +109,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
data_mgr__core_mgr.Db__core().Tbl__site_stats().Select(stats);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
app.Addon_mgr().Load_by_wiki(this);
|
||||
ctg_pagebox_wtr.Init_by_wiki(this);
|
||||
}
|
||||
public void Init_by_wiki__force() {init_needed = true; Init_by_wiki();}
|
||||
public void Init_by_make(Xowd_core_db_props props, gplx.xowa.bldrs.infos.Xob_info_session info_session) {
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoa_ctg_mgr implements Gfo_invk {
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
pagectgs_wtr = new Xoctg_pagelist_wtr().Init_by_app(app);
|
||||
}
|
||||
public boolean Pagecats_grouping_enabled() {return pagecats_grouping_enabled;} private boolean pagecats_grouping_enabled = false;
|
||||
public Xoctg_pagelist_wtr Pagectgs_wtr() {return pagectgs_wtr;} private Xoctg_pagelist_wtr pagectgs_wtr;
|
||||
public byte Missing_ctg_cls_tid() {return missing_ctg_cls_tid;} private byte missing_ctg_cls_tid = Missing_ctg_cls_red_tid;
|
||||
public byte[] Missing_ctg_cls_css() {
|
||||
switch (missing_ctg_cls_tid) {
|
||||
case Missing_ctg_cls_normal_tid: return Missing_ctg_cls_normal_css;
|
||||
case Missing_ctg_cls_hide_tid: return Missing_ctg_cls_hide_css;
|
||||
case Missing_ctg_cls_red_tid: return Missing_ctg_cls_red_css;
|
||||
default: throw Err_.new_unhandled(missing_ctg_cls_tid);
|
||||
}
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_missing_ctg_cls)) return Missing_ctg_cls_tid_print(missing_ctg_cls_tid);
|
||||
else if (ctx.Match(k, Invk_missing_ctg_cls_)) missing_ctg_cls_tid = Missing_ctg_cls_tid_parse(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_missing_ctg_cls_list)) return Options_missing_ctg_cls_list;
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled)) return Yn.To_str(pagecats_grouping_enabled);
|
||||
else if (ctx.Match(k, Invk_pagecats_grouping_enabled_)) pagecats_grouping_enabled = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_missing_ctg_cls = "missing_ctg_cls", Invk_missing_ctg_cls_ = "missing_ctg_cls_", Invk_missing_ctg_cls_list = "missing_ctg_cls_list", Invk_pagecats_grouping_enabled = "pagecats_grouping_enabled", Invk_pagecats_grouping_enabled_ = "pagecats_grouping_enabled_";
|
||||
private static final byte Missing_ctg_cls_normal_tid = 0, Missing_ctg_cls_hide_tid = 1, Missing_ctg_cls_red_tid = 2;
|
||||
private static final String Missing_ctg_cls_normal_str = "normal", Missing_ctg_cls_hide_str = "hide", Missing_ctg_cls_red_str = "red_link";
|
||||
private static final byte[] Missing_ctg_cls_normal_css = Bry_.new_a7(".xowa-missing-category-entry {}"), Missing_ctg_cls_hide_css = Bry_.new_a7(".xowa-missing-category-entry {display: none;}"), Missing_ctg_cls_red_css = Bry_.new_a7(".xowa-missing-category-entry {color: red;}");
|
||||
private static Keyval[] Options_missing_ctg_cls_list = Keyval_.Ary(Keyval_.new_(Missing_ctg_cls_normal_str), Keyval_.new_(Missing_ctg_cls_hide_str), Keyval_.new_(Missing_ctg_cls_red_str));
|
||||
private static byte Missing_ctg_cls_tid_parse(String v) {
|
||||
if (String_.Eq(v, Missing_ctg_cls_normal_str)) return Missing_ctg_cls_normal_tid;
|
||||
else if (String_.Eq(v, Missing_ctg_cls_hide_str)) return Missing_ctg_cls_hide_tid;
|
||||
else if (String_.Eq(v, Missing_ctg_cls_red_str)) return Missing_ctg_cls_red_tid;
|
||||
else throw Err_.new_unhandled(v);
|
||||
}
|
||||
private static String Missing_ctg_cls_tid_print(byte v) {
|
||||
switch (v) {
|
||||
case Missing_ctg_cls_normal_tid: return Missing_ctg_cls_normal_str;
|
||||
case Missing_ctg_cls_hide_tid: return Missing_ctg_cls_hide_str;
|
||||
case Missing_ctg_cls_red_tid: return Missing_ctg_cls_red_str;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
public static final byte Version_null = Byte_.Zero, Version_1 = 1, Version_2 = 2;
|
||||
public static final byte Tid_null = Byte_.Max_value_127, Tid_subc = 0, Tid_file = 1, Tid_page = 2, Tid__max = 3;
|
||||
public static final byte Hidden_n = Byte_.Zero, Hidden_y = (byte)1;
|
||||
public static final String Html__cls__str = "CategoryTreeLabel CategoryTreeLabelNs14 CategoryTreeLabelCategory";
|
||||
public static final byte[] Html__cls__bry = Bry_.new_a7(Html__cls__str);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoctg_data_cache {
|
||||
private Hash_adp_bry regy = Hash_adp_bry.cs(); // NOTE: changed to cs from ci; cache is hashing page_ttls by ctg_name which is always ttl.Page_txt(); DATE:2014-07-07
|
||||
public Xoctg_data_ctg Get_or_null(byte[] ctg_name) {return (Xoctg_data_ctg)regy.Get_by_bry(ctg_name);}
|
||||
public Xoctg_data_ctg Load_or_null(Xowe_wiki wiki, byte[] ctg_name) {
|
||||
Gfo_usr_dlg usr_dlg = wiki.Appe().Usr_dlg();
|
||||
usr_dlg.Prog_many("", "", "loading file for category: ~{0}", String_.new_u8(ctg_name));
|
||||
Xoctg_data_ctg rv = new Xoctg_data_ctg(ctg_name);
|
||||
boolean found = wiki.Db_mgr().Load_mgr().Load_ctg_v2(rv, ctg_name); if (!found) return null;
|
||||
regy.Add(ctg_name, rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoctg_data_ctg {
|
||||
public Xoctg_data_ctg(byte[] ctg_name) {this.ctg_name = ctg_name;}
|
||||
public byte[] Ctg_name() {return ctg_name;} private byte[] ctg_name;
|
||||
public boolean Db_mgr_is_txt() {return db_mgr_is_txt;} public Xoctg_data_ctg Db_mgr_is_txt_(boolean v) {db_mgr_is_txt = v; return this;} private boolean db_mgr_is_txt = true;
|
||||
public int Total_by_tid(byte tid) {
|
||||
Xoctg_idx_mgr grp = Grp_by_tid(tid);
|
||||
return grp == null ? 0 : grp.Total();
|
||||
}
|
||||
public int Total_count() {
|
||||
int rv = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Xoctg_idx_mgr grp_mgr = grp_mgrs[i];
|
||||
if (grp_mgr != null) rv += grp_mgr.Total();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public boolean Hidden() {return hidden;} public Xoctg_data_ctg Hidden_(boolean v) {hidden = v; return this;} private boolean hidden;
|
||||
public Xoctg_idx_mgr[] Grp_mgrs() {return grp_mgrs;} private Xoctg_idx_mgr[] grp_mgrs = new Xoctg_idx_mgr[3];
|
||||
public Xoctg_idx_mgr Grp_by_tid(byte i) {return grp_mgrs[i];}
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.htmls.core.htmls.*; import gplx.langs.htmls.encoders.*;
|
||||
class Xoctg_fmtr_all {
|
||||
public Xoctg_fmtr_all(byte tid) {this.Ctor(tid);}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Div_id() {return div_id;} private byte[] div_id;
|
||||
public int Msg_id_label() {return msg_id_label;} private int msg_id_label;
|
||||
public int Msg_id_stats() {return msg_id_stats;} private int msg_id_stats;
|
||||
public boolean Grps_enabled() {return grps_enabled;} private boolean grps_enabled;
|
||||
public Xoctg_fmtr_itm Fmtr_itm() {return fmtr_itm;} private Xoctg_fmtr_itm fmtr_itm;
|
||||
public int Grp_max() {return grp_max;} public Xoctg_fmtr_all Grp_max_(int v) {grp_max = v; return this;} private int grp_max = Xoctg_html_mgr.Grp_max_default;
|
||||
public Bry_fmtr Html_all() {return html_all;} Bry_fmtr html_all = Bry_fmtr.new_();
|
||||
public Bry_fmtr Html_nav() {return html_nav;} Bry_fmtr html_nav = Bry_fmtr.new_();
|
||||
public Bry_fmtr Html_itm() {return html_itm;} Bry_fmtr html_itm = Bry_fmtr.new_();
|
||||
public Bry_fmtr Html_itm_missing() {return html_itm_missing;} Bry_fmtr html_itm_missing = Bry_fmtr.new_();
|
||||
public byte[] Url_arg_bgn() {return url_arg_bgn;} private byte[] url_arg_bgn = null;
|
||||
public byte[] Url_arg_end() {return url_arg_end;} private byte[] url_arg_end = null;
|
||||
private void Ctor(byte tid) {
|
||||
this.tid = tid;
|
||||
switch (tid) {
|
||||
case Xoa_ctg_mgr.Tid_subc: grps_enabled = Bool_.Y; msg_id_label = Xol_msg_itm_.Id_ctg_subc_label ; msg_id_stats = Xol_msg_itm_.Id_ctg_subc_count; div_id = Div_id_subc; url_arg_bgn = Url_arg_subc_bgn; url_arg_end = Url_arg_subc_end; this.fmtr_itm = new Xoctg_fmtr_itm_subc(); break;
|
||||
case Xoa_ctg_mgr.Tid_page: grps_enabled = Bool_.Y; msg_id_label = Xol_msg_itm_.Id_ctg_page_header; msg_id_stats = Xol_msg_itm_.Id_ctg_page_count; div_id = Div_id_page; url_arg_bgn = Url_arg_page_bgn; url_arg_end = Url_arg_page_end; this.fmtr_itm = new Xoctg_fmtr_itm_page(); break;
|
||||
case Xoa_ctg_mgr.Tid_file: grps_enabled = Bool_.Y; msg_id_label = Xol_msg_itm_.Id_ctg_file_header; msg_id_stats = Xol_msg_itm_.Id_ctg_file_count; div_id = Div_id_file; url_arg_bgn = Url_arg_file_bgn; url_arg_end = Url_arg_file_end; this.fmtr_itm = new Xoctg_fmtr_itm_file(); break;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
html_all.Fmt_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"~{div_id}\">"
|
||||
, " <h2>~{all_label}</h2>"
|
||||
, " <p>~{all_stats}</p>~{all_navs}"
|
||||
, " <div lang=\"~{lang_key}\" dir=\"~{lang_ltr}\" class=\"mw-content-~{lang_ltr}\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">~{grps}"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>~{all_navs}"
|
||||
, "</div>"
|
||||
))
|
||||
.Keys_
|
||||
("div_id", "all_label", "all_stats", "all_navs", "lang_key", "lang_ltr", "grps");
|
||||
html_nav.Fmt_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " (<a href=\"~{nav_href}\" class=\"xowa_nav\" title=\"~{nav_title}\">~{nav_text}</a>)"
|
||||
))
|
||||
.Keys_("nav_href", "nav_title", "nav_text");
|
||||
html_itm.Fmt_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <li><a href=\"~{itm_href}\"~{itm_atr_cls} title=\"~{itm_title}\">~{itm_text}</a></li>"
|
||||
))
|
||||
.Keys_("itm_href", "itm_title", "itm_text", "itm_id", "itm_atr_cls");
|
||||
html_itm_missing.Fmt_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <li class=\"xowa-missing-category-entry\"><span title=\"id not found: #~{itm_id} might be talk/user page\">~{itm_text} (missing)</li>"
|
||||
))
|
||||
.Keys_("itm_href", "itm_title", "itm_text", "itm_id");
|
||||
switch (tid) {
|
||||
case Xoa_ctg_mgr.Tid_subc:
|
||||
html_itm.Fmt_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <li>"
|
||||
, " <div class=\"CategoryTreeSection\">"
|
||||
, " <div class=\"CategoryTreeItem\">"
|
||||
, " <span class=\"CategoryTreeBullet\">"
|
||||
, " <span class=\"CategoryTreeToggle\" style=\"display: none;\" data-ct-title=\"~{itm_data_title}\" title=\"~{itm_title}\" data-ct-state=\"collapsed\">"
|
||||
, " </span> "
|
||||
, " </span>"
|
||||
, " <a href=\"~{itm_href}\" class=\"" + Xoa_ctg_mgr.Html__cls__str + "\">~{itm_text}"
|
||||
, " </a>"
|
||||
, " <span title=\"~{itm_contains_title}\" dir=\"ltr\">~{itm_contains_text}"
|
||||
, " </span>"
|
||||
, " </div>"
|
||||
, " <div class=\"CategoryTreeChildren\" style=\"display:none\"></div>"
|
||||
, " </div>"
|
||||
, " </li>"
|
||||
)).Keys_("itm_data_title", "itm_title", "itm_href", "itm_text","itm_contains_title", "itm_contains_text");
|
||||
break;
|
||||
case Xoa_ctg_mgr.Tid_page:
|
||||
break;
|
||||
case Xoa_ctg_mgr.Tid_file:
|
||||
// html_all.Fmt_(String_.Concat_lines_nl_skip_last
|
||||
// ( ""
|
||||
// , "<div id=\"~{div_id}\">"
|
||||
// , " <h2>~{all_label}</h2>"
|
||||
// , " <p>~{all_stats}</p>"
|
||||
// , " <ul id=\"xowa_gallery_ul_0\" class=\"gallery\">~{grps}"
|
||||
// , " </ul>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
break;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public byte[] Bld_bwd_fwd(Xowe_wiki wiki, Xoa_ttl ttl, Xoctg_view_grp view_grp) {
|
||||
if (view_grp.Total() < grp_max) return Bry_.Empty;
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_k004();
|
||||
Html_nav_bry(bfr, wiki, ttl, view_grp, Bool_.N);
|
||||
Html_nav_bry(bfr, wiki, ttl, view_grp, Bool_.Y);
|
||||
return bfr.To_bry_and_rls();
|
||||
}
|
||||
private void Html_nav_bry(Bry_bfr bfr, Xowe_wiki wiki, Xoa_ttl ttl, Xoctg_view_grp view_grp, boolean fill_at_bgn) {
|
||||
Bry_bfr href_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Xoae_app app = wiki.Appe();
|
||||
wiki.Html__href_wtr().Build_to_bfr(href_bfr, app, Xoh_wtr_ctx.Basic, wiki.Domain_bry(), ttl);
|
||||
byte[] arg_idx_lbl = null; byte[] arg_sortkey = null;
|
||||
if (fill_at_bgn) {
|
||||
arg_idx_lbl = url_arg_bgn;
|
||||
arg_sortkey = view_grp.Itms_last_sortkey();
|
||||
if (arg_sortkey == null)
|
||||
arg_sortkey = view_grp.Itms_at_last().Sort_key();
|
||||
}
|
||||
else {
|
||||
arg_idx_lbl = url_arg_end;
|
||||
arg_sortkey = view_grp.Itms_at_first().Sort_key();
|
||||
}
|
||||
href_bfr.Add_byte(Byte_ascii.Question).Add(arg_idx_lbl).Add_byte(Byte_ascii.Eq); // filefrom=
|
||||
Gfo_url_encoder_.Http_url.Encode(href_bfr, arg_sortkey); // Abc
|
||||
href_bfr.Add_byte(Byte_ascii.Hash).Add(div_id); // #mw-subcategories
|
||||
byte[] nav_href = href_bfr.To_bry_and_rls();
|
||||
byte[] nav_ttl = ttl.Full_url();
|
||||
int nav_text_id = fill_at_bgn ? Xol_msg_itm_.Id_next_results : Xol_msg_itm_.Id_prev_results;
|
||||
byte[] nav_text = wiki.Msg_mgr().Val_by_id_args(nav_text_id, grp_max); // fill_at_bgn 200 / previous 200
|
||||
html_nav.Bld_bfr(bfr, nav_href, nav_ttl, nav_text);
|
||||
}
|
||||
public static final byte[]
|
||||
Url_arg_from = Bry_.new_a7("from")
|
||||
, Url_arg_until = Bry_.new_a7("until")
|
||||
, Url_arg_subc_bgn = Bry_.new_a7("subcatfrom")
|
||||
, Url_arg_subc_end = Bry_.new_a7("subcatuntil")
|
||||
, Url_arg_page_bgn = Bry_.new_a7("pagefrom")
|
||||
, Url_arg_page_end = Bry_.new_a7("pageuntil")
|
||||
, Url_arg_file_bgn = Bry_.new_a7("filefrom")
|
||||
, Url_arg_file_end = Bry_.new_a7("fileuntil")
|
||||
, Div_id_subc = Bry_.new_a7("mw-subcategories")
|
||||
, Div_id_page = Bry_.new_a7("mw-pages")
|
||||
, Div_id_file = Bry_.new_a7("mw-category-media")
|
||||
;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
class Xoctg_fmtr_grp implements gplx.core.brys.Bfr_arg {
|
||||
public void Init_from_all(Xowe_wiki wiki, Xol_lang_itm lang, Xoh_wtr_ctx hctx, Xoctg_view_ctg ctg, Xoctg_fmtr_all mgr, Xoctg_view_grp itms_list) {
|
||||
this.wiki = wiki; this.mgr = mgr; this.itms_fmtr = mgr.Fmtr_itm(); this.itms_list = itms_list; len = itms_list.Len();
|
||||
itms_fmtr.Init_from_all(wiki, lang, hctx, ctg, mgr, itms_list, len);
|
||||
} private Xowe_wiki wiki; Xoctg_fmtr_itm itms_fmtr; Xoctg_view_grp itms_list; int len; Xoctg_fmtr_all mgr;
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (mgr.Grps_enabled()) {
|
||||
if (len == 0) return;
|
||||
int cur_idx = itms_list.Bgn(); int col_bgn = cur_idx;
|
||||
byte[] ttl_char_0 = Bry_.Empty; int col_idx = -1; boolean col_bgn_needed = true;
|
||||
while (cur_idx < len) {
|
||||
Xoctg_view_itm itm = itms_list.Itms()[cur_idx];
|
||||
byte[] itm_sortkey = itm.Sort_key();
|
||||
byte[] ttl_char_0_new = gplx.core.intls.Utf8_.Get_char_at_pos_as_bry(itm_sortkey, 0);
|
||||
byte[] grp_name = ttl_char_0_new;
|
||||
if (Bry_.Eq(ttl_char_0, ttl_char_0_new)) {
|
||||
grp_name = Bry_.Add(ttl_char_0, Byte_ascii.Space_bry, wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_list_continues));
|
||||
}
|
||||
ttl_char_0 = ttl_char_0_new;
|
||||
if (col_bgn_needed) {
|
||||
col_bgn = cur_idx;
|
||||
itms_fmtr.Col_idx_(++col_idx, col_bgn);
|
||||
html_col_bgn.Bld_bfr_many(bfr, 100 / Xoctg_html_mgr.Cols_max);
|
||||
}
|
||||
itms_fmtr.Init_from_grp(ttl_char_0, cur_idx);
|
||||
html_tbl.Bld_bfr_many(bfr, grp_name, itms_fmtr);
|
||||
cur_idx = itms_fmtr.Grp_end_idx(); col_bgn_needed = itms_fmtr.Grp_end_at_col();
|
||||
if (col_bgn_needed)
|
||||
html_col_end.Bld_bfr_many(bfr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
itms_fmtr.Col_idx_(0, len);
|
||||
itms_fmtr.Init_from_grp(Bry_.Empty, itms_list.Bgn());
|
||||
html_none.Bld_bfr_many(bfr, itms_fmtr);
|
||||
}
|
||||
}
|
||||
Bry_fmtr html_none = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "~{itms}"
|
||||
), "itms"
|
||||
);
|
||||
Bry_fmtr html_tbl = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <h3>~{grp_name}</h3>"
|
||||
, " <ul>~{itms}"
|
||||
, " </ul>"
|
||||
), "grp_name", "itms"
|
||||
);
|
||||
Bry_fmtr html_col_bgn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <td style=\"width: ~{width}%;\">"
|
||||
), "width"
|
||||
);
|
||||
Bry_fmtr html_col_end = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " </td>"
|
||||
));
|
||||
public static int Calc_col_max(int cols_total, int len, int col_idx) {
|
||||
if (len == 0) return 0;
|
||||
int col_max = ((len - 1) / cols_total) + 1; // NOTE: example is easiest explanation; EX: 4, 5, 6 should have max of 2, so (a) subtract 1; (b) divide by 3; (c) add 1
|
||||
return col_idx <= ((len - 1) % cols_total) ? col_max : col_max - 1; // NOTE: example is easiest explanation; EX: 4=2,1,1; 5=2,2,1; 6=2,2,2
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
interface Xoctg_fmtr_itm extends gplx.core.brys.Bfr_arg {
|
||||
int Grp_end_idx();
|
||||
boolean Grp_end_at_col();
|
||||
int Col_idx(); void Col_idx_(int col_idx, int col_bgn);
|
||||
void Init_from_all(Xowe_wiki wiki, Xol_lang_itm lang, Xoh_wtr_ctx hctx, Xoctg_view_ctg ctg, Xoctg_fmtr_all mgr, Xoctg_view_grp itms_list, int itms_list_len);
|
||||
void Init_from_grp(byte[] grp_ttl, int i);
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
abstract class Xoctg_fmtr_itm_base implements gplx.core.brys.Bfr_arg, Xoctg_fmtr_itm {
|
||||
private Xou_history_mgr history_mgr; private Xoh_wtr_ctx hctx;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
protected Xowe_wiki wiki; Xol_lang_itm lang; Xoctg_view_ctg ctg; protected int len; protected Xoh_href_parser href_parser; protected Bry_fmtr html_itm, html_itm_missing; protected Xoctg_view_grp list; protected Xow_msg_mgr msg_mgr;
|
||||
public void Init_from_all(Xowe_wiki wiki, Xol_lang_itm lang, Xoh_wtr_ctx hctx, Xoctg_view_ctg ctg, Xoctg_fmtr_all mgr, Xoctg_view_grp itms_list, int itms_list_len) {
|
||||
this.wiki = wiki; this.lang = lang; this.hctx = hctx; this.ctg = ctg; this.list = itms_list; this.len = itms_list_len; this.msg_mgr = wiki.Msg_mgr();
|
||||
href_parser = wiki.Appe().Html__href_parser();
|
||||
html_itm = mgr.Html_itm();
|
||||
html_itm_missing = mgr.Html_itm_missing();
|
||||
history_mgr = wiki.Appe().Usere().History_mgr();
|
||||
}
|
||||
public void Init_from_grp(byte[] ttl_char_0, int col_bgn) {this.ttl_char_0 = ttl_char_0; this.col_bgn = col_bgn;} private byte[] ttl_char_0; int col_bgn; int col_end;
|
||||
public int Col_idx() {return col_idx;}
|
||||
public void Col_idx_(int col_idx, int col_bgn) {
|
||||
this.col_idx = col_idx;
|
||||
this.col_bgn = col_bgn;
|
||||
col_end = col_bgn + Xoctg_fmtr_grp.Calc_col_max(Xoctg_html_mgr.Cols_max, len, col_idx);
|
||||
} int col_idx;
|
||||
public int Grp_end_idx() {return grp_end_idx;} private int grp_end_idx;
|
||||
public boolean Grp_end_at_col() {return grp_end_at_col;} private boolean grp_end_at_col;
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
for (int i = col_bgn; i < len; i++) {
|
||||
if (i == col_end) {
|
||||
grp_end_idx = i;
|
||||
grp_end_at_col = true;
|
||||
return;
|
||||
}
|
||||
Xoctg_view_itm itm = list.Itms()[i];
|
||||
Xoa_ttl ttl = itm.Ttl();
|
||||
byte[] itm_sortkey = itm.Sort_key();
|
||||
byte[] ttl_bry = ttl.Page_txt();
|
||||
if (!Bry_.Has_at_bgn(itm_sortkey, ttl_char_0, 0, itm_sortkey.length)) {
|
||||
grp_end_idx = i;
|
||||
grp_end_at_col = i == col_end;
|
||||
return;
|
||||
}
|
||||
Bld_html(bfr, wiki, hctx, itm, ttl, ttl_bry, href_parser, html_itm);
|
||||
}
|
||||
grp_end_idx = len;
|
||||
grp_end_at_col = true;
|
||||
}
|
||||
@gplx.Virtual public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
byte[] itm_href = wiki.Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
byte[] itm_full_ttl = gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(tmp_bfr, ttl.Full_txt_w_ttl_case());// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
|
||||
byte[] itm_atr_cls = hctx.Mode_is_hdump() ? Bry_.Empty : Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
Bry_fmtr fmtr = itm.Missing() ? html_itm_missing : html_itm;
|
||||
fmtr.Bld_bfr_many(bfr, itm_href, itm_full_ttl, itm_full_ttl, itm.Page_id(), itm_atr_cls);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
class Xoctg_fmtr_itm_page extends Xoctg_fmtr_itm_base {
|
||||
}
|
||||
class Xoctg_fmtr_itm_file extends Xoctg_fmtr_itm_base {
|
||||
// public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
// html_itm = wiki.Html_mgr().Gallery_xtn_mgr().Html_gallery_itm_img();
|
||||
// for (int i = list.Bgn(); i < len; i++) {
|
||||
// Xoctg_view_itm itm = list.Itms()[i];
|
||||
// Xoa_ttl ttl = itm.Ttl();
|
||||
// byte[] ttl_page = ttl.Page_txt();
|
||||
// byte[] itm_href = href_parser.Build_to_bry(ttl, wiki);
|
||||
// html_itm.Bld_bfr_many(bfr
|
||||
// , 155 // "itm_box_width"
|
||||
// , 155 // "itm_div_width"
|
||||
// , 15 // "itm_margin"
|
||||
// , -1 // "img_id"
|
||||
// , ttl_page // "img_ttl"
|
||||
// , itm_href // "img_href"
|
||||
// , Bry_.Empty // "html_src"
|
||||
// , -1 // "img_width"
|
||||
// , -1 // "img_height"
|
||||
// , ttl_page // "itm_caption"
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.langs.msgs.*;
|
||||
class Xoctg_fmtr_itm_subc extends Xoctg_fmtr_itm_base {
|
||||
@Override public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
byte[] itm_href = wiki.Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
int sub_ctgs = 0; // itm.Subs_ctgs();
|
||||
int sub_pages = 0; // itm.Subs_pages();
|
||||
int sub_files = 0; // itm.Subs_files();
|
||||
byte[] contains_title = msg_mgr.Val_by_id_args(Xol_msg_itm_.Id_ctgtree_subc_counts, sub_ctgs, sub_pages, sub_files);
|
||||
byte[] contains_text = Bld_contains_text(sub_ctgs, sub_pages, sub_files);
|
||||
html_itm.Bld_bfr_many(bfr, ttl.Page_db(), ttl_page, itm_href, ttl_page, contains_title, contains_text);
|
||||
}
|
||||
byte[] Bld_contains_text(int sub_ctgs, int sub_pages, int sub_files) {
|
||||
if (sub_ctgs == 0 && sub_pages == 0 && sub_files == 0) return Bry_.Empty;
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b128();
|
||||
bfr.Add_byte(Byte_ascii.Paren_bgn);
|
||||
Bld_contains_text_itm(bfr, Xol_msg_itm_.Id_ctgtree_subc_counts_ctg, sub_ctgs);
|
||||
Bld_contains_text_itm(bfr, Xol_msg_itm_.Id_ctgtree_subc_counts_page, sub_pages);
|
||||
Bld_contains_text_itm(bfr, Xol_msg_itm_.Id_ctgtree_subc_counts_file, sub_files);
|
||||
bfr.Add_byte(Byte_ascii.Paren_end);
|
||||
return bfr.To_bry_and_rls();
|
||||
}
|
||||
private void Bld_contains_text_itm(Bry_bfr bfr, int msg_id, int val) {
|
||||
if (val == 0) return;
|
||||
if (bfr.Len() > 1) bfr.Add(Bld_contains_text_itm_dlm); // NOTE: 1 b/c Paren_bgn is always added
|
||||
bfr.Add(msg_mgr.Val_by_id_args(msg_id, val));
|
||||
} private static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xoctg_html_mgr implements Gfo_invk {
|
||||
@gplx.Internal protected Xoctg_fmtr_grp Fmtr_grp() {return fmtr_grp;} private Xoctg_fmtr_grp fmtr_grp = new Xoctg_fmtr_grp();
|
||||
private final Xoctg_fmtr_all mgr_subcs = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_subc);
|
||||
private final Xoctg_fmtr_all mgr_pages = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_page);
|
||||
private final Xoctg_fmtr_all mgr_files = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_file);
|
||||
public Xoctg_data_cache Data_cache() {return data_cache;} private Xoctg_data_cache data_cache = new Xoctg_data_cache();
|
||||
public void Bld_html(Xowe_wiki wiki, Xoae_page page, Xoh_wtr_ctx hctx, Bry_bfr bfr) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||
try {
|
||||
if (wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_2)
|
||||
Bld_html_v2(wiki, page, hctx, tmp_bfr);
|
||||
else
|
||||
Bld_html_v1(wiki, page, hctx, tmp_bfr);
|
||||
bfr.Add_bfr_and_preserve(tmp_bfr);
|
||||
tmp_bfr.Mkr_rls();
|
||||
}
|
||||
catch (Exception e) { // ctg error should never cause page to fail
|
||||
tmp_bfr.Mkr_rls();
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to generate category: title=~{0} err=~{1}", String_.new_u8(page.Ttl().Full_txt_w_ttl_case()), Err_.Message_gplx_full(e));
|
||||
}
|
||||
} private Xoctg_url url_ctg = new Xoctg_url();
|
||||
private void Bld_html_v2(Xowe_wiki wiki, Xoae_page page, Xoh_wtr_ctx hctx, Bry_bfr bfr) {
|
||||
byte[] ttl_bry = page.Ttl().Page_db();
|
||||
Xoctg_view_ctg view_ctg = new Xoctg_view_ctg().Name_(page.Ttl().Page_txt());
|
||||
url_ctg.Parse(wiki.Appe().Usr_dlg(), page.Url());
|
||||
wiki.Db_mgr().Load_mgr().Load_ctg_v2a(view_ctg, url_ctg, ttl_bry, Grp_max_default, wiki.App().Mode().Tid_is_cmd());
|
||||
Bld_all(bfr, wiki, page.Lang(), hctx, view_ctg, Xoa_ctg_mgr.Tid_subc);
|
||||
Bld_all(bfr, wiki, page.Lang(), hctx, view_ctg, Xoa_ctg_mgr.Tid_page);
|
||||
Bld_all(bfr, wiki, page.Lang(), hctx, view_ctg, Xoa_ctg_mgr.Tid_file);
|
||||
}
|
||||
public void Get_titles(Gfo_usr_dlg usr_dlg, Xowe_wiki wiki, Xoctg_view_ctg ctg) {
|
||||
title_list.Clear();
|
||||
Add_titles(title_list, ctg.Subcs());
|
||||
Add_titles(title_list, ctg.Files());
|
||||
Add_titles(title_list, ctg.Pages());
|
||||
title_list.Sort_by(Xoctg_view_itm_sorter_id.Instance);
|
||||
int len = title_list.Count();
|
||||
int pct = len / 16;
|
||||
Xowd_page_itm dbo_page = new Xowd_page_itm();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoctg_view_itm itm = (Xoctg_view_itm)title_list.Get_at(i);
|
||||
if (pct != 0 && i % pct == 0) usr_dlg.Prog_many("", "", "loading title data: ~{0} / ~{1} -- ~{2}", i, len, String_.new_u8(itm.Sort_key()));
|
||||
boolean id_exists = wiki.Db_mgr().Load_mgr().Load_by_id(dbo_page, itm.Page_id());
|
||||
Xoa_ttl itm_ttl = null;
|
||||
if (id_exists)
|
||||
itm_ttl = Xoa_ttl.Parse(wiki, dbo_page.Ns_id(), dbo_page.Ttl_page_db());
|
||||
else {
|
||||
itm_ttl = Xoa_ttl.Parse(wiki, itm.Sort_key());
|
||||
if (itm_ttl == null)
|
||||
itm_ttl = Xoa_ttl.Parse(wiki, Bry_missing);
|
||||
itm.Missing_y_();
|
||||
}
|
||||
itm.Set__ttl__sortkey(itm_ttl, itm.Sort_key());
|
||||
}
|
||||
} List_adp title_list = List_adp_.New(); static final byte[] Bry_missing = Bry_.new_a7("missing");
|
||||
private void Add_titles(List_adp title_list, Xoctg_view_grp grp) {
|
||||
int len = grp.Itms().length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoctg_view_itm itm = grp.Itms()[i];
|
||||
title_list.Add(itm);
|
||||
}
|
||||
}
|
||||
private void Bld_html_v1(Xowe_wiki wiki, Xoae_page page, Xoh_wtr_ctx hctx, Bry_bfr bfr) {
|
||||
Xoctg_view_ctg ctg = new Xoctg_view_ctg().Name_(page.Ttl().Page_txt());
|
||||
boolean found = wiki.Db_mgr().Load_mgr().Load_ctg_v1(ctg, page.Ttl().Page_db()); if (!found) return;
|
||||
Bld_all(bfr, wiki, page.Lang(), hctx, ctg, Xoa_ctg_mgr.Tid_subc);
|
||||
Bld_all(bfr, wiki, page.Lang(), hctx, ctg, Xoa_ctg_mgr.Tid_page);
|
||||
Bld_all(bfr, wiki, page.Lang(), hctx, ctg, Xoa_ctg_mgr.Tid_file);
|
||||
}
|
||||
@gplx.Internal protected void Bld_all(Bry_bfr bfr, Xowe_wiki wiki, Xol_lang_itm lang, Xoh_wtr_ctx hctx, Xoctg_view_ctg view_ctg, byte tid) {
|
||||
Xoctg_view_grp view_grp = view_ctg.Grp_by_tid(tid);
|
||||
int view_grp_len = view_grp.Itms().length; if (view_grp_len == 0) return;
|
||||
view_grp.End_(view_grp_len);
|
||||
Xoctg_fmtr_all fmtr_all = Fmtr(tid);
|
||||
Xow_msg_mgr msg_mgr = wiki.Msg_mgr();
|
||||
byte[] all_label = msg_mgr.Val_by_id_args(fmtr_all.Msg_id_label(), view_ctg.Name());
|
||||
byte[] all_stats = msg_mgr.Val_by_id_args(fmtr_all.Msg_id_stats(), view_grp.Len(), view_grp.Total());
|
||||
Xoa_ttl ctg_ttl = Xoa_ttl.Parse(wiki, Xow_ns_.Tid__category, view_ctg.Name());
|
||||
byte[] all_navs = fmtr_all.Bld_bwd_fwd(wiki, ctg_ttl, view_grp);
|
||||
Array_.Sort(view_grp.Itms(), Xoctg_view_itm_sorter_sortkey.Instance);
|
||||
fmtr_grp.Init_from_all(wiki, lang, hctx, view_ctg, fmtr_all, view_grp); // NOTE: must assert sorted for v1; PAGE:s.w:Category:Computer_science; DATE:2015-11-22
|
||||
fmtr_all.Html_all().Bld_bfr_many(bfr, fmtr_all.Div_id(), all_label, all_stats, all_navs, lang.Key_bry(), lang.Dir_ltr_bry(), fmtr_grp);
|
||||
}
|
||||
public static final int Cols_max = 3;
|
||||
@gplx.Internal protected Xoctg_fmtr_all Fmtr(byte tid) {
|
||||
switch (tid) {
|
||||
case Xoa_ctg_mgr.Tid_subc: return mgr_subcs;
|
||||
case Xoa_ctg_mgr.Tid_page: return mgr_pages;
|
||||
case Xoa_ctg_mgr.Tid_file: return mgr_files;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public static final int Grp_max_default = 200;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_grp_max)) return mgr_subcs.Grp_max();
|
||||
else if (ctx.Match(k, Invk_grp_max_)) {int grp_max = m.ReadInt("v"); mgr_subcs.Grp_max_(grp_max); mgr_files.Grp_max_(grp_max); mgr_pages.Grp_max_(grp_max);}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_grp_max = "grp_max", Invk_grp_max_ = "grp_max_";
|
||||
}
|
||||
class Xoctg_view_itm_sorter_id implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xoctg_view_itm lhs = (Xoctg_view_itm)lhsObj;
|
||||
Xoctg_view_itm rhs = (Xoctg_view_itm)rhsObj;
|
||||
return Int_.Compare(lhs.Page_id(), rhs.Page_id());
|
||||
}
|
||||
public static final Xoctg_view_itm_sorter_id Instance = new Xoctg_view_itm_sorter_id();
|
||||
}
|
||||
class Xoctg_view_itm_sorter_sortkey implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xoctg_view_itm lhs = (Xoctg_view_itm)lhsObj;
|
||||
Xoctg_view_itm rhs = (Xoctg_view_itm)rhsObj;
|
||||
return Bry_.Compare(lhs.Sort_key(), rhs.Sort_key());
|
||||
}
|
||||
public static final Xoctg_view_itm_sorter_sortkey Instance = new Xoctg_view_itm_sorter_sortkey();
|
||||
}
|
||||
@@ -1,300 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoctg_html_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoh_ctg_page_fxt fxt = new Xoh_ctg_page_fxt();
|
||||
@Test public void Page_itm() {
|
||||
fxt .Init_itm_page("A1")
|
||||
.Test_html_page(Xoa_ctg_mgr.Tid_page, Byte_ascii.Ltr_A, "\n <li><a href=\"/wiki/A1\" title=\"A1\">A1</a></li>")
|
||||
;
|
||||
}
|
||||
@Test public void Page_itm_missing() {
|
||||
fxt .Init_itm_page("A1");
|
||||
fxt .Ctg().Grp_by_tid(Xoa_ctg_mgr.Tid_page).Itms()[0].Missing_y_();
|
||||
fxt .Test_html_page(Xoa_ctg_mgr.Tid_page, Byte_ascii.Ltr_A, "\n <li class=\"xowa-missing-category-entry\"><span title=\"id not found: #0 might be talk/user page\">A1 (missing)</li>");
|
||||
}
|
||||
@Test public void Visited_doesnt_work_for_space() {// PURPOSE: xowa-visited not inserted for pages with space
|
||||
byte[] page_bry = Bry_.new_a7("A 1");
|
||||
Xoa_url url = Xoa_url.New(Bry_.new_a7("en.wikipedia.org"), page_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(fxt.Wiki(), page_bry);
|
||||
fxt.Wiki().Appe().Usere().History_mgr().Add(url, ttl, page_bry);
|
||||
fxt .Init_itm_page("A_1").Init_ctg_name_("Ctg_1").Init_ctg_pages_(0, 1)
|
||||
.Test_html_all(Xoa_ctg_mgr.Tid_page, String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-pages\">"
|
||||
, " <h2>Pages in category \"Ctg_1\"</h2>"
|
||||
, " <p>The following page is in this category, out of 0 total.</p>"
|
||||
, " <div lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>A</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/A_1\" class=\"xowa-visited\" title=\"A 1\">A 1</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Page_all() {
|
||||
fxt .Init_itm_page("A1").Init_ctg_name_("Ctg_1").Init_ctg_pages_(0, 1)
|
||||
.Test_html_all(Xoa_ctg_mgr.Tid_page, String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-pages\">"
|
||||
, " <h2>Pages in category \"Ctg_1\"</h2>"
|
||||
, " <p>The following page is in this category, out of 0 total.</p>"
|
||||
, " <div lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>A</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/A1\" title=\"A1\">A1</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void File_all() {
|
||||
fxt .Init_itm_file("File:A1.png").Init_ctg_name_("Ctg_1").Init_ctg_files_(0, 1)
|
||||
.Test_html_all(Xoa_ctg_mgr.Tid_file, String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-category-media\">"
|
||||
, " <h2>Media in category \"Ctg_1\"</h2>"
|
||||
, " <p>The following file is in this category, out of 0 total.</p>"
|
||||
, " <div lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>A</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/File:A1.png\" title=\"File:A1.png\">File:A1.png</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
// , " <ul id=\"xowa_gallery_ul_0\" class=\"gallery\">"
|
||||
// , " <li class=\"gallerybox\" style=\"width:155px;\">"
|
||||
// , " <div style=\"width:155px;\">"
|
||||
// , " <div class=\"thumb\" style=\"width:155px;\">"
|
||||
// , " <div id=\"xowa_gallery_div3_-1\" style=\"margin:15px auto;\">"
|
||||
// , " <a href=\"/wiki/File:A1.png\" class=\"image\">"
|
||||
// , " <img id=\"xoimg_-1\" alt=\"A1.png\" src=\"\" width=\"-1\" height=\"-1\" />"
|
||||
// , " </a>"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"gallerytext\">A1.png"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , " </li>"
|
||||
// , ""
|
||||
// , " </ul>"
|
||||
}
|
||||
@Test public void Subc_all() {
|
||||
fxt .Init_itm_ctg("Category:Subc_1").Init_ctg_name_("Ctg_1").Init_ctg_files_(0, 1)
|
||||
.Test_html_all(Xoa_ctg_mgr.Tid_subc, String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-subcategories\">"
|
||||
, " <h2>Subcategories</h2>"
|
||||
, " <p>This category has the following subcategory, out of 0 total.</p>"
|
||||
, " <div lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>S</h3>"
|
||||
, " <ul>"
|
||||
, " <li>"
|
||||
, " <div class=\"CategoryTreeSection\">"
|
||||
, " <div class=\"CategoryTreeItem\">"
|
||||
, " <span class=\"CategoryTreeBullet\">"
|
||||
, " <span class=\"CategoryTreeToggle\" style=\"display: none;\" data-ct-title=\"Subc_1\" title=\"Subc 1\" data-ct-state=\"collapsed\">"
|
||||
, " </span> "
|
||||
, " </span>"
|
||||
, " <a href=\"/wiki/Category:Subc_1\" class=\"CategoryTreeLabel CategoryTreeLabelNs14 CategoryTreeLabelCategory\">Subc 1"
|
||||
, " </a>"
|
||||
, " <span title=\"contains 0 subcategories, 0 pages, and 0 files\" dir=\"ltr\">"
|
||||
, " </span>"
|
||||
, " </div>"
|
||||
, " <div class=\"CategoryTreeChildren\" style=\"display:none\"></div>"
|
||||
, " </div>"
|
||||
, " </li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Page_all_cols() {
|
||||
fxt .Init_itm_page("A1", "A2", "A3", "B1", "C1").Init_ctg_name_("Ctg_1").Init_ctg_pages_(0, 5)
|
||||
.Test_html_all(Xoa_ctg_mgr.Tid_page, String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-pages\">"
|
||||
, " <h2>Pages in category \"Ctg_1\"</h2>"
|
||||
, " <p>The following 5 pages are in this category, out of 0 total.</p>"
|
||||
, " <div lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>A</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/A1\" title=\"A1\">A1</a></li>"
|
||||
, " <li><a href=\"/wiki/A2\" title=\"A2\">A2</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>A cont.</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/A3\" title=\"A3\">A3</a></li>"
|
||||
, " </ul>"
|
||||
, " <h3>B</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/B1\" title=\"B1\">B1</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>C</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/C1\" title=\"C1\">C1</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Title__escape_quotes() {// PURPOSE: quotes in title should be escaped; DATE:2015-12-28
|
||||
fxt .Init_itm_page("A\"1").Init_ctg_name_("Ctg_1").Init_ctg_pages_(0, 1)
|
||||
.Test_html_all(Xoa_ctg_mgr.Tid_page, String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-pages\">"
|
||||
, " <h2>Pages in category \"Ctg_1\"</h2>"
|
||||
, " <p>The following page is in this category, out of 0 total.</p>"
|
||||
, " <div lang=\"en\" dir=\"ltr\" class=\"mw-content-ltr\">"
|
||||
, " <table style=\"width: 100%;\">"
|
||||
, " <tr style=\"vertical-align: top;\">"
|
||||
, " <td style=\"width: 33%;\">"
|
||||
, " <h3>A</h3>"
|
||||
, " <ul>"
|
||||
, " <li><a href=\"/wiki/A%221\" title=\"A"1\">A"1</a></li>"
|
||||
, " </ul>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, " </table>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Bld_rslts_lnk() {
|
||||
fxt.Init_itm_page("A1").Init_ctg_name_("Ctg_1").Init_ctg_pages_(1, 1)
|
||||
.Test_bld_rslts_lnk(Bool_.Y, "Category:Ctg_1", String_.Concat_lines_nl
|
||||
( ""
|
||||
, " (<a href=\"/wiki/Category:Ctg_1?pageuntil=A1#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">previous 0</a>)"
|
||||
, " (<a href=\"/wiki/Category:Ctg_1?pagefrom=A1#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">next 0</a>)"
|
||||
));
|
||||
}
|
||||
@Test public void Bld_rslts_lnk__encoded() { // escape quotes and spaces; DATE:2016-01-11
|
||||
fxt.Init_itm_page("A\" b").Init_ctg_name_("Ctg_1").Init_ctg_pages_(1, 1)
|
||||
.Test_bld_rslts_lnk(Bool_.Y, "Category:Ctg_1", String_.Concat_lines_nl
|
||||
( ""
|
||||
, " (<a href=\"/wiki/Category:Ctg_1?pageuntil=A%22+b#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">previous 0</a>)"
|
||||
, " (<a href=\"/wiki/Category:Ctg_1?pagefrom=A%22+b#mw-pages\" class=\"xowa_nav\" title=\"Category:Ctg_1\">next 0</a>)"
|
||||
));
|
||||
}
|
||||
@Test public void Calc_col_max() {
|
||||
Tst_calc_col_max(3, 10, 0, 4);
|
||||
Tst_calc_col_max(3, 10, 1, 3);
|
||||
Tst_calc_col_max(3, 10, 2, 3);
|
||||
Tst_calc_col_max(3, 11, 0, 4);
|
||||
Tst_calc_col_max(3, 11, 1, 4);
|
||||
Tst_calc_col_max(3, 11, 2, 3);
|
||||
Tst_calc_col_max(3, 12, 0, 4);
|
||||
Tst_calc_col_max(3, 12, 1, 4);
|
||||
Tst_calc_col_max(3, 12, 2, 4);
|
||||
} public void Tst_calc_col_max(int cols_total, int len, int col_idx, int expd) {Tfds.Eq(expd, Xoctg_fmtr_grp.Calc_col_max(cols_total, len, col_idx));}
|
||||
}
|
||||
class Xoh_ctg_page_fxt {
|
||||
public Xoh_ctg_page_fxt Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
ctg_html = wiki.Html_mgr().Ns_ctg();
|
||||
ctg = new Xoctg_view_ctg();
|
||||
}
|
||||
return this;
|
||||
} private Xoae_app app; private Xoctg_html_mgr ctg_html;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public Xoctg_view_ctg Ctg() {return ctg;} private Xoctg_view_ctg ctg;
|
||||
public void Test_bld_rslts_lnk(boolean next, String ctg_str, String expd) {
|
||||
byte[] actl = ctg_html.Fmtr(Xoa_ctg_mgr.Tid_page).Grp_max_(0).Bld_bwd_fwd(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7(ctg_str)), ctg.Grp_by_tid(Xoa_ctg_mgr.Tid_page));
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
public Xoh_ctg_page_fxt Init_ctg_name_(String v) {ctg.Name_(Bry_.new_u8(v)); return this;}
|
||||
public Xoh_ctg_page_fxt Init_ctg_pages_(int bgn, int count) {ctg.Pages().Bgn_(bgn).All_(count).End_(count); return this;}
|
||||
public Xoh_ctg_page_fxt Init_ctg_files_(int bgn, int count) {ctg.Files().Bgn_(bgn).All_(count).End_(count); return this;}
|
||||
public Xoh_ctg_page_fxt Init_itm_page(String... titles) {ctg.Pages().Itms_(itms_(Xoa_ctg_mgr.Tid_page, titles)).End_(titles.length); return this;}
|
||||
public Xoh_ctg_page_fxt Init_itm_file(String... titles) {ctg.Files().Itms_(itms_(Xoa_ctg_mgr.Tid_file, titles)).End_(titles.length); return this;}
|
||||
public Xoh_ctg_page_fxt Init_itm_ctg(String... titles) {ctg.Subcs().Itms_(itms_(Xoa_ctg_mgr.Tid_subc, titles)).End_(titles.length); return this;}
|
||||
Xoctg_view_itm[] itms_(byte tid, String... titles) {
|
||||
int len = titles.length;
|
||||
Xoctg_view_itm[] rv = new Xoctg_view_itm[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
String title = titles[i];
|
||||
byte[] title_bry = Bry_.new_u8(title);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, title_bry);
|
||||
rv[i] = new Xoctg_view_itm().Set__page(tid, 0).Set__ttl__sortkey(ttl, ttl.Page_txt());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Test_html_page(byte tid, byte grp_char_0, String expd) {
|
||||
Xoctg_fmtr_all list_mgr = ctg_html.Fmtr(tid);
|
||||
Xoctg_fmtr_itm fmtr_itm = list_mgr.Fmtr_itm();
|
||||
Xoctg_view_grp list = ctg.Grp_by_tid(tid);
|
||||
fmtr_itm.Init_from_all(wiki, wiki.Lang(), Xoh_wtr_ctx.Basic, ctg, list_mgr, list, list.Len());
|
||||
fmtr_itm.Init_from_grp(new byte[] {grp_char_0}, 0);
|
||||
fmtr_itm.Col_idx_(0, 0);
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
fmtr_itm.Bfr_arg__add(bfr);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_rls());
|
||||
}
|
||||
public void Test_html_grp(byte tid, String expd) {
|
||||
Xoctg_fmtr_all list_mgr = ctg_html.Fmtr(tid);
|
||||
Xoctg_fmtr_grp fmtr_grp = ctg_html.Fmtr_grp();
|
||||
fmtr_grp.Init_from_all(wiki, wiki.Lang(), Xoh_wtr_ctx.Basic, ctg, list_mgr, ctg.Grp_by_tid(tid));
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
fmtr_grp.Bfr_arg__add(bfr);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_rls());
|
||||
}
|
||||
public void Test_html_all(byte tid, String expd) {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
ctg_html.Bld_all(bfr, wiki, wiki.Lang(), Xoh_wtr_ctx.Basic, ctg, tid);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_rls());
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.flds.*;
|
||||
public class Xoctg_idx_itm {
|
||||
public int Pos() {return pos;} public Xoctg_idx_itm Pos_(int v) {pos = v; return this;} private int pos = -1;
|
||||
public int Id() {return id;} private int id;
|
||||
public int Timestamp() {return timestamp;} private int timestamp;
|
||||
public byte[] Sortkey() {return sortkey;} private byte[] sortkey;
|
||||
public int compareTo(Object obj) {Xoctg_idx_itm comp = (Xoctg_idx_itm)obj; return Int_.Compare(pos, comp.Pos());}
|
||||
public Xoctg_idx_itm Parse(Gfo_fld_rdr fld_rdr, int pos) {
|
||||
this.pos = pos;
|
||||
id = fld_rdr.Read_int_base85_len5();
|
||||
timestamp = fld_rdr.Read_int_base85_len5();
|
||||
sortkey = fld_rdr.Read_bry_escape();
|
||||
return this;
|
||||
}
|
||||
public void Load(int id, byte[] sortkey, int timestamp) {
|
||||
this.id = id; this.sortkey = sortkey; this.timestamp = timestamp;
|
||||
}
|
||||
public void Copy(Xoctg_idx_itm orig) {
|
||||
this.pos = orig.pos;
|
||||
this.id = orig.id;
|
||||
this.timestamp = orig.timestamp;
|
||||
this.sortkey = orig.sortkey;
|
||||
}
|
||||
}
|
||||
class Xoctg_idx_itm_sorter_sortkey implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Xoctg_idx_itm lhs = (Xoctg_idx_itm)lhsObj;
|
||||
Xoctg_idx_itm rhs = (Xoctg_idx_itm)rhsObj;
|
||||
return Bry_.Compare(lhs.Sortkey(), rhs.Sortkey());
|
||||
}
|
||||
public static final Xoctg_idx_itm_sorter_sortkey Instance = new Xoctg_idx_itm_sorter_sortkey();
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.flds.*;
|
||||
public class Xoctg_idx_mgr implements Gfo_invk {
|
||||
List_adp itms = List_adp_.New();
|
||||
public int Block_len() {return block_len;} public Xoctg_idx_mgr Block_len_(int v) {this.block_len = v; return this;} private int block_len = Io_mgr.Len_mb;
|
||||
public int Itms_len() {return itms.Count();}
|
||||
public Xoctg_idx_itm Itms_get_at(int i) {return (Xoctg_idx_itm)itms.Get_at(i);}
|
||||
public void Itms_add(Xoctg_idx_itm itm) {itms.Add(itm);}
|
||||
public byte[] Src() {return src;} public Xoctg_idx_mgr Src_(byte[] v) {src = v; return this;} private byte[] src;
|
||||
public int Total() {return total;} public Xoctg_idx_mgr Total_(int v) {total = v; return this;} private int total;
|
||||
public void Index(Gfo_usr_dlg usr_dlg, byte[] ctg, byte[] src) {
|
||||
int len = src.length;
|
||||
// if (len < block_len) return; NOTE: do not exit early; need at least one entry or Itms_binary_search will fail
|
||||
itms.Clear();
|
||||
fld_rdr.Data_(src);
|
||||
int pipe_pos_cur = -1, pipe_pos_prv = -1;
|
||||
for (int i = block_len; i < len; i += block_len) {
|
||||
usr_dlg.Prog_many("", "", "indexing ~{0} ~{1}", i, len);
|
||||
pipe_pos_cur = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, i, len); if (pipe_pos_cur == Bry_find_.Not_found) throw Err_.new_wo_type("ctg_idx_mgr could not find pipe.next", "ctg", String_.new_a7(ctg), "pos", i);
|
||||
if (pipe_pos_cur == len - 1) break;
|
||||
Index_itm(ctg, src, pipe_pos_cur + 1, len); // +1 to skip pipe
|
||||
pipe_pos_prv = pipe_pos_cur;
|
||||
}
|
||||
pipe_pos_cur = Bry_find_.Find_bwd(src, Byte_ascii.Pipe, len - 1, 0); if (pipe_pos_cur == Bry_find_.Not_found) pipe_pos_cur = 0; // 1 entry only; will not have preceding pipe
|
||||
if (pipe_pos_cur != pipe_pos_prv) // if last itm was not indexed, index it
|
||||
Index_itm(ctg, src, pipe_pos_cur + 1, len);
|
||||
}
|
||||
private void Index_itm(byte[] ctg, byte[] src, int bgn, int len) {
|
||||
int end = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, bgn, len); if (end == Bry_find_.Not_found) throw Err_.new_wo_type("Ctg_idx_mgr could not find pipe.end", "ctg", String_.new_a7(ctg), "pos", bgn);
|
||||
fld_rdr.Pos_(bgn);
|
||||
Xoctg_idx_itm itm = new Xoctg_idx_itm().Parse(fld_rdr, bgn);
|
||||
itms.Add(itm);
|
||||
}
|
||||
public Xoctg_idx_itm Itms_binary_search(byte[] find, Int_obj_ref comp_rslt) {
|
||||
int max = itms.Count() - 1;
|
||||
int dif = max / 2;
|
||||
int pos = dif;
|
||||
Xoctg_idx_itm rv = null;
|
||||
int comp_prv = Int_.Min_value, comp_cur = 0;
|
||||
while (true) {
|
||||
rv = (Xoctg_idx_itm)itms.Get_at(pos);
|
||||
comp_cur = Bry_.Compare(find, rv.Sortkey());
|
||||
// Tfds.Dbg(dif, pos, comp_cur, comp_prv, String_.new_a7(find), String_.new_a7(rv.Sortkey()));
|
||||
if (comp_cur == CompareAble_.Same) break; // exact match; stop
|
||||
dif /= 2;
|
||||
if (dif == 0) dif = 1; // make sure dif is at least 1
|
||||
if (dif == 1 && comp_cur != comp_prv) break; // if dif == 1 && comp has switched; i.e: "interval is as small as it can be, and search has bounced over result (found item above and found item below)"
|
||||
pos = comp_cur == CompareAble_.More ? pos + dif : pos - dif;
|
||||
if (pos < 0 || pos > max) break;
|
||||
comp_prv = comp_cur;
|
||||
}
|
||||
comp_rslt.Val_(comp_cur);
|
||||
return rv;
|
||||
}
|
||||
public Xoctg_idx_itm Find_itm_near_bmk(byte[] src, int src_len, byte[] find, boolean arg_is_from, int bmk_comp, int bmk_bgn) {
|
||||
/*
|
||||
if arg_is_from
|
||||
. if find > idx.key, search bwd until find < idx; EX: A50 is find; A48A is idx; search bwd; A49 (still >); A48 (< break); take prv
|
||||
. if find < idx.key, search fwd until find > idx; EX: A50 is find; A51A is idx; search fwd; A51 (still <); A52 (> break); take cur
|
||||
else if arg_is_until
|
||||
. if find > idx.key, search fwd until find < idx; EX: A50 is find; A48A is idx; search bwd; A49 (still >); A48 (< break); take cur
|
||||
. if find < idx.key, search bwd until find > idx; EX: A50 is find; A51A is idx; search fwd; A51 (still <); A52 (> break); take prv
|
||||
*/
|
||||
boolean dir_fwd = bmk_comp == CompareAble_.More; // bmk is > than find; move forward
|
||||
fld_rdr.Data_(src);
|
||||
int comp_prv = bmk_comp, comp_cur = Int_.Min_value; int pos_cur = bmk_bgn;
|
||||
tmp_prv_itm.Parse(fld_rdr.Pos_(pos_cur), pos_cur); // fill prv_itm to whatever binary search found
|
||||
while (true) {
|
||||
int itm_bgn = dir_fwd ? Bry_find_.Find_fwd(src, Byte_ascii.Pipe, pos_cur, src_len) : Bry_find_.Find_bwd(src, Byte_ascii.Pipe, pos_cur);
|
||||
if (itm_bgn == Bry_find_.Not_found) { // stop: at first && searched bwd; note that at last && searched fwd will never return Bry_find_.Not_found b/c all srcs are terminated with |
|
||||
if (!arg_is_from) return null; // arg is until and nothing found; return null: EX: range of B-Y and find of until=A; no results
|
||||
else break; // arg is from; stop loop; (will use first item)
|
||||
}
|
||||
++itm_bgn; // position after pipe
|
||||
if (itm_bgn == src_len) { // stop: at last && searched fwd
|
||||
if (arg_is_from) return null; // arg is from and nothing found; return null: EX: range of B-Y and find of from=Z; no results
|
||||
else break; // arg is until; stop loop; (will use last item)
|
||||
}
|
||||
tmp_cur_itm.Parse(fld_rdr.Pos_(itm_bgn), itm_bgn);
|
||||
comp_cur = Bry_.Compare(find, tmp_cur_itm.Sortkey());
|
||||
if (comp_cur != comp_prv) break; // stop: comp_val switched; see note above
|
||||
pos_cur = dir_fwd ? itm_bgn : itm_bgn - 1; // -1 to position at pipe (note that -1 in FindBwd will position before)
|
||||
tmp_prv_itm.Copy(tmp_cur_itm);
|
||||
}
|
||||
// Tfds.Dbg(arg_is_from, dir_fwd, String_.new_u8(find), String_.new_u8(tmp_cur_itm.Sortkey()), String_.new_u8(tmp_prv_itm.Sortkey()));
|
||||
if (comp_cur == CompareAble_.Same) return tmp_cur_itm;
|
||||
return (arg_is_from && dir_fwd) || (!arg_is_from && !dir_fwd) ? tmp_cur_itm : tmp_prv_itm; // see note above
|
||||
} private Xoctg_idx_itm tmp_cur_itm = new Xoctg_idx_itm(), tmp_prv_itm = new Xoctg_idx_itm(); Gfo_fld_rdr fld_rdr = Gfo_fld_rdr.xowa_();
|
||||
public void Find(List_adp rv, byte[] src, boolean arg_is_from, byte[] find, int find_count, Xoctg_view_itm last_plus_one) {
|
||||
int tmp_pos = 0; int src_len = src.length;
|
||||
last_plus_one.Clear();
|
||||
if (find != null) { // find == null when no args passed; EX: "en.wikipedia.org/wiki/Category:A" (vs "en.wikipedia.org/wiki/Category:A?from=B")
|
||||
Xoctg_idx_itm itm_0 = Itms_binary_search(find, find_rslt.Val_(Byte_.Zero));
|
||||
if (find_rslt.Val() != CompareAble_.Same) {
|
||||
itm_0 = Find_itm_near_bmk(src, src_len, find, arg_is_from, find_rslt.Val(), itm_0.Pos());
|
||||
if (itm_0 == null) return; // itm out of range; EX: pages are B-Y and find is A or Z
|
||||
}
|
||||
tmp_pos = itm_0.Pos();
|
||||
if (!arg_is_from && Bry_.Compare(find, itm_0.Sortkey()) != CompareAble_.More) { // "until" means do *not* include last; go back one more; note: only do this logic if find is either < or == to slot; EX: find=AM && slot=AL; do not go back one more
|
||||
tmp_pos = Bry_find_.Find_bwd(src, Byte_ascii.Pipe, tmp_pos - 1); // -1 to position before pipe
|
||||
if (tmp_pos == Bry_find_.Not_found) return; // already 1st and nothing found
|
||||
else tmp_pos++;
|
||||
}
|
||||
}
|
||||
fld_rdr.Data_(src);
|
||||
for (int i = 0; i < find_count; i++) {
|
||||
fld_rdr.Pos_(tmp_pos);
|
||||
Xoctg_view_itm itm = new Xoctg_view_itm().Parse(fld_rdr.Pos_(tmp_pos), tmp_pos);
|
||||
rv.Add(itm);
|
||||
if (!arg_is_from && tmp_pos == 0) break; // 1st item and moving bwd; stop; note that 1st item does not have preceding |
|
||||
tmp_pos = arg_is_from ? Bry_find_.Find_fwd(src, Byte_ascii.Pipe, tmp_pos, src_len) : Bry_find_.Find_bwd(src, Byte_ascii.Pipe, tmp_pos - 1); // -1 to position before pipe
|
||||
if (tmp_pos == Bry_find_.Not_found) {
|
||||
if (arg_is_from) // moving fwd and no pipe found; exit;
|
||||
break;
|
||||
else // moving bwd and no pipe found; position at 1st item (which doesn't have a pipe); note that -1 will become 0
|
||||
tmp_pos = -1;
|
||||
}
|
||||
++tmp_pos; // position after pipe
|
||||
if (tmp_pos == src_len) break; // last pipe; stop
|
||||
}
|
||||
if (!arg_is_from)
|
||||
rv.Sort_by(Xoctg_view_itm_sorter_sortkey.Instance);
|
||||
int rv_count = rv.Count();
|
||||
if (rv_count > 0) {
|
||||
Xoctg_view_itm last_itm = (Xoctg_view_itm)rv.Get_at(rv_count - 1);
|
||||
int last_itm_pos = last_itm.Sort_idx();
|
||||
tmp_pos = Bry_find_.Find_fwd(src, Byte_ascii.Pipe, last_itm_pos);
|
||||
if (tmp_pos != Bry_find_.Not_found && tmp_pos < src_len - 1) {
|
||||
++tmp_pos; // position after pipe
|
||||
last_plus_one.Parse(fld_rdr.Pos_(tmp_pos), tmp_pos);
|
||||
}
|
||||
}
|
||||
} Int_obj_ref find_rslt = Int_obj_ref.New_zero();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_block_len)) return block_len;
|
||||
else if (ctx.Match(k, Invk_block_len_)) block_len = m.ReadInt("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_block_len = "block_len", Invk_block_len_ = "block_len_";
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.core.primitives.*;
|
||||
public class Xoctg_idx_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoctg_idx_mgr_fxt fxt = new Xoctg_idx_mgr_fxt();
|
||||
@Test public void Index() {
|
||||
fxt .Init_block_len(Itm_len * 2);
|
||||
fxt .Test_index(fxt.Make_src(5), "A02", "A04");
|
||||
}
|
||||
@Test public void Binary_search_small() {
|
||||
fxt .Init_itms(Itm_len * 2, fxt.Make_src(5));
|
||||
fxt .Test_itms_binary_search("A02", "A02", CompareAble_.Same); // exact match
|
||||
fxt .Test_itms_binary_search("A03", "A02", CompareAble_.More); // >
|
||||
fxt .Test_itms_binary_search("A01", "A02", CompareAble_.Less); // <
|
||||
}
|
||||
@Test public void Binary_search_large() {
|
||||
fxt .Init_itms(Itm_len * 5, fxt.Make_src(99));
|
||||
fxt .Test_itms_binary_search("A50" , "A50", CompareAble_.Same);
|
||||
fxt .Test_itms_binary_search("A49" , "A50", CompareAble_.Less);
|
||||
fxt .Test_itms_binary_search("A51" , "A50", CompareAble_.More);
|
||||
fxt .Test_itms_binary_search("A44" , "A45", CompareAble_.Less);
|
||||
fxt .Test_itms_binary_search("A56" , "A55", CompareAble_.More);
|
||||
fxt .Test_itms_binary_search("A00" , "A05", CompareAble_.Less);
|
||||
fxt .Test_itms_binary_search("A99" , "A98", CompareAble_.More);
|
||||
}
|
||||
@Test public void Find_itm_near_bmk() {
|
||||
fxt .Init_src(fxt.Make_src(7));
|
||||
fxt .Test_find_itm_near_bmk(3, "A05A", CompareAble_.More, Bool_.Y, "A06");
|
||||
fxt .Test_find_itm_near_bmk(3, "A02A", CompareAble_.Less, Bool_.Y, "A03");
|
||||
fxt .Test_find_itm_near_bmk(3, "A05A", CompareAble_.More, Bool_.N, "A05");
|
||||
fxt .Test_find_itm_near_bmk(3, "A02A", CompareAble_.Less, Bool_.N, "A02");
|
||||
fxt .Test_find_itm_near_bmk(3, "A" , CompareAble_.Less, Bool_.Y, "A00");
|
||||
fxt .Test_find_itm_near_bmk(3, "A" , CompareAble_.Less, Bool_.N, null);
|
||||
fxt .Test_find_itm_near_bmk(3, "A99A", CompareAble_.More, Bool_.Y, null);
|
||||
fxt .Test_find_itm_near_bmk(3, "A05" , CompareAble_.More, Bool_.N, "A05"); // PURPOSE: if exact item found, return it
|
||||
}
|
||||
@Test public void Find() {
|
||||
fxt .Init_src(fxt.Make_src(99)).Init_block_len(100); // 100 bytes is roughly 7 items
|
||||
fxt .Test_find("A50" , Bool_.Y, String_.Ary("A50", "A51", "A52"), "A53");
|
||||
fxt .Test_find("A50" , Bool_.N, String_.Ary("A47", "A48", "A49"), "A50"); // check that "until" returns 49 (should not include 50)
|
||||
fxt .Test_find("A50A", Bool_.Y, String_.Ary("A51", "A52", "A53"), "A54");
|
||||
fxt .Test_find("A50A", Bool_.N, String_.Ary("A48", "A49", "A50"), "A51"); // check that "until" returns 50
|
||||
fxt .Test_find("A99A", Bool_.N, String_.Ary("A96", "A97", "A98"), null);
|
||||
fxt .Test_find("A99A", Bool_.Y, String_.Ary_empty, null);
|
||||
fxt .Test_find("A" , Bool_.Y, String_.Ary("A00", "A01", "A02"), "A03");
|
||||
fxt .Test_find("A" , Bool_.N, String_.Ary_empty, null);
|
||||
fxt .Test_find("A49A", Bool_.N, String_.Ary("A47", "A48", "A49"), "A50"); // check that "until" returns 49
|
||||
fxt .Test_find("A00" , Bool_.Y, String_.Ary("A00", "A01", "A02"), "A03"); // PURPOSE: special code for 1st item (which doesn't have a preceding pipe)
|
||||
fxt .Test_find("A98" , Bool_.Y, String_.Ary("A98"), null); // PURPOSE: handle premature end
|
||||
}
|
||||
public static final int Itm_len = 16; // 6(id|) + 6(timestamp|) + 4(A01|)
|
||||
}
|
||||
class Xoctg_idx_mgr_fxt {
|
||||
public Xoctg_idx_mgr_fxt Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
idx_mgr = new Xoctg_idx_mgr();
|
||||
}
|
||||
return this;
|
||||
} private Xoae_app app; Xowe_wiki wiki; Xoctg_idx_mgr idx_mgr; static final byte[] Ctg_name = Bry_.new_a7("Ctg_test");
|
||||
public byte[] Make_src(int len) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
bfr.Add_byte_pipe(); // always have leading pipe
|
||||
for (int i = 0; i < len; i++) {
|
||||
bfr.Add_base85_len_5(i).Add_byte(Byte_ascii.Semic); // idx.Id() = i
|
||||
bfr.Add_base85_len_5(0).Add_byte(Byte_ascii.Semic); // idx.Timestamp() = ignore;
|
||||
bfr.Add_byte(Byte_ascii.Ltr_A);
|
||||
if (i < 10) bfr.Add_byte(Byte_ascii.Num_0);
|
||||
bfr.Add_int_variable(i).Add_byte_pipe();
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public Xoctg_idx_mgr_fxt Init_itms(int block_len, byte[] src) {idx_mgr.Block_len_(block_len); idx_mgr.Index(Gfo_usr_dlg_.Test(), Ctg_name, src); return this;}
|
||||
public Xoctg_idx_mgr_fxt Init_block_len(int block_len) {idx_mgr.Block_len_(block_len); return this;}
|
||||
public Xoctg_idx_mgr_fxt Init_src(byte[] v) {src = v; src_len = v.length; return this;} private byte[] src; int src_len;
|
||||
public Xoctg_idx_mgr_fxt Test_index(byte[] src, String... expd) {
|
||||
idx_mgr.Index(Gfo_usr_dlg_.Test(), Ctg_name, src);
|
||||
Tfds.Eq_ary_str(expd, Idx_mgr_itms(idx_mgr));
|
||||
return this;
|
||||
}
|
||||
String[] Idx_mgr_itms(Xoctg_idx_mgr idx_mgr) {
|
||||
int len = idx_mgr.Itms_len();
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
rv[i] = String_.new_a7(idx_mgr.Itms_get_at(i).Sortkey());
|
||||
return rv;
|
||||
}
|
||||
public Xoctg_idx_mgr_fxt Test_itms_binary_search(String find, String expd, int expd_comp) {
|
||||
comp_rslt.Val_zero_();
|
||||
Xoctg_idx_itm rslt = idx_mgr.Itms_binary_search(Bry_.new_a7(find), comp_rslt);
|
||||
Tfds.Eq(expd, String_.new_a7(rslt.Sortkey()));
|
||||
Tfds.Eq(expd_comp, comp_rslt.Val());
|
||||
return this;
|
||||
} Int_obj_ref comp_rslt = Int_obj_ref.New_zero();
|
||||
public Xoctg_idx_mgr_fxt Test_find_itm_near_bmk(int idx_bgn, String find, int bmk_comp, boolean find_dir, String expd) {
|
||||
int idx_pos = (idx_bgn * Xoctg_idx_mgr_tst.Itm_len) + (bmk_comp == CompareAble_.Less ? 1 : 0);
|
||||
Xoctg_idx_itm rslt = idx_mgr.Find_itm_near_bmk(src, src_len, Bry_.new_a7(find), find_dir, bmk_comp, idx_pos);
|
||||
String actl = rslt == null ? null : String_.new_a7(rslt.Sortkey());
|
||||
Tfds.Eq(expd, actl);
|
||||
return this;
|
||||
}
|
||||
public Xoctg_idx_mgr_fxt Test_find(String find, boolean fill_at_bgn, String[] expd_ary, String last_plus_one) {
|
||||
if (tmp_list == null) tmp_list = List_adp_.New();
|
||||
idx_mgr.Index(Gfo_usr_dlg_.Test(), Bry_.Empty, src);
|
||||
tmp_list.Clear();
|
||||
idx_mgr.Find(tmp_list, src, fill_at_bgn, Bry_.new_a7(find), 3, tmp_last_plus_one);
|
||||
Tfds.Eq_ary(expd_ary, To_str_ary(tmp_list));
|
||||
Tfds.Eq(last_plus_one, String_.new_a7(tmp_last_plus_one.Sort_key()));
|
||||
return this;
|
||||
} List_adp tmp_list; Xoctg_view_itm tmp_last_plus_one = new Xoctg_view_itm();
|
||||
String[] To_str_ary(List_adp list) {
|
||||
int len = list.Count();
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
rv[i] = String_.new_a7(((Xoctg_view_itm)list.Get_at(i)).Sort_key());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoctg_page_xtn {
|
||||
public Xoctg_page_xtn(byte tid, byte[] sortkey) {this.tid = tid; this.sortkey = sortkey;}
|
||||
public byte[] Sortkey() {return sortkey;} public void Sortkey_(byte[] v) {this.sortkey = v;} private byte[] sortkey;
|
||||
public byte Tid() {return tid;} public void Tid_(byte v) {this.tid = v;} private byte tid;
|
||||
public byte Hidden() {return hidden;} public void Hidden_(byte v) {hidden = v;} private byte hidden = Bool_.__byte;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xoctg_pagelist_grp implements gplx.core.brys.Bfr_arg {
|
||||
public void Init_app(Xoae_app app, boolean type_is_normal, Bry_fmtr fmtr_grp, Bry_fmtr fmtr_itm) {
|
||||
this.type_is_normal = type_is_normal;
|
||||
this.fmtr_grp = fmtr_grp;
|
||||
itms.Init_app(app, fmtr_itm);
|
||||
} private Bry_fmtr fmtr_grp;
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Xoh_wtr_ctx hctx) {
|
||||
lbl_ctg_text = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_ctg_tbl_hdr);
|
||||
lbl_ctg_help = Xol_msg_mgr_.Get_msg_val(wiki, wiki.Lang(), Key_pagecategorieslink, Bry_.Ary_empty);
|
||||
lbl_hidden = wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_ctg_tbl_hidden);
|
||||
itms.Init_wiki(wiki, hctx);
|
||||
} private byte[] lbl_ctg_help, lbl_ctg_text, lbl_hidden; private static final byte[] Key_pagecategorieslink = Bry_.new_a7("pagecategorieslink");
|
||||
public boolean Type_is_normal() {return type_is_normal;} private boolean type_is_normal;
|
||||
public Xoctg_pagelist_itms Itms() {return itms;} private Xoctg_pagelist_itms itms = new Xoctg_pagelist_itms();
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (type_is_normal)
|
||||
fmtr_grp.Bld_bfr_many(bfr, lbl_ctg_help, lbl_ctg_text, itms);
|
||||
else
|
||||
fmtr_grp.Bld_bfr_many(bfr, lbl_hidden, itms);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
public class Xoctg_pagelist_itms implements gplx.core.brys.Bfr_arg {
|
||||
private Xoh_href_wtr href_wtr; private Xou_history_mgr history_mgr; private Bry_fmtr fmtr_itm;
|
||||
public void Init_app(Xoae_app app, Bry_fmtr fmtr_itm) {
|
||||
this.history_mgr = app.Usere().History_mgr();
|
||||
this.fmtr_itm = fmtr_itm;
|
||||
}
|
||||
public void Init_wiki(Xowe_wiki wiki, Xoh_wtr_ctx hctx) {
|
||||
this.wiki = wiki; this.hctx = hctx;
|
||||
this.href_wtr = wiki.Html__href_wtr();
|
||||
} private Xowe_wiki wiki; private Xoh_wtr_ctx hctx;
|
||||
public void Itms_clear() {itms.Clear();} private List_adp itms = List_adp_.New();
|
||||
public void Itms_add(Xowd_page_itm page) {itms.Add(page);}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
int len = itms.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowd_page_itm page = (Xowd_page_itm)itms.Get_at(i);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Xow_ns_.Tid__category, page.Ttl_page_db());
|
||||
byte[] lnki_cls = hctx.Mode_is_hdump() ? Bry_.Empty : Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
byte[] lnki_href = href_wtr.Build_to_bry(wiki, ttl);
|
||||
byte[] lnki_ttl = ttl.Full_txt_w_ttl_case();
|
||||
byte[] lnki_text = ttl.Page_txt();
|
||||
fmtr_itm.Bld_bfr_many(bfr, lnki_cls, lnki_href, lnki_ttl, lnki_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoctg_pagelist_mgr implements gplx.core.brys.Bfr_arg {
|
||||
public Xoctg_pagelist_mgr Init_by_app(Xoae_app app, Xoctg_pagelist_wtr hidden_wtr) {
|
||||
this.fmtr_all = hidden_wtr.Fmtr_all();
|
||||
grp_normal.Init_app(app, Bool_.Y, hidden_wtr.Fmtr_grp_normal(), hidden_wtr.Fmtr_itm());
|
||||
grp_hidden.Init_app(app, Bool_.N, hidden_wtr.Fmtr_grp_hidden(), hidden_wtr.Fmtr_itm());
|
||||
return this;
|
||||
} private Bry_fmtr fmtr_all;
|
||||
public void Init_by_wiki(Xowe_wiki wiki, Xoh_wtr_ctx hctx) {
|
||||
grp_normal.Init_by_wiki(wiki, hctx);
|
||||
grp_hidden.Init_by_wiki(wiki, hctx);
|
||||
}
|
||||
public Xoctg_pagelist_grp Grp_normal() {return grp_normal;} private Xoctg_pagelist_grp grp_normal = new Xoctg_pagelist_grp();
|
||||
public Xoctg_pagelist_grp Grp_hidden() {return grp_hidden;} private Xoctg_pagelist_grp grp_hidden = new Xoctg_pagelist_grp();
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
fmtr_all.Bld_bfr_many(bfr, grp_normal, grp_hidden);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.users.history.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xoctg_pagelist_wtr {
|
||||
private Xoctg_pagelist_mgr pagelist_mgr = new Xoctg_pagelist_mgr();
|
||||
public Xoctg_pagelist_wtr Init_by_app(Xoae_app app) {pagelist_mgr.Init_by_app(app, this); return this;}
|
||||
public void Write(Bry_bfr bfr, Xowe_wiki wiki, Xoae_page page, Xoh_wtr_ctx hctx) {
|
||||
Xowd_page_itm[] page_ary = wiki.Db_mgr().Load_mgr().Load_ctg_list(page.Category_list());
|
||||
Print_hidden(bfr, wiki, page_ary, hctx);
|
||||
}
|
||||
public void Print_hidden(Bry_bfr bfr, Xowe_wiki wiki, Xowd_page_itm[] page_ary, Xoh_wtr_ctx hctx) {
|
||||
int len = page_ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowd_page_itm page = page_ary[i];
|
||||
Xowd_category_itm ctg_xtn = (Xowd_category_itm)page.Xtn();
|
||||
Xoctg_pagelist_grp list = ctg_xtn != null && ctg_xtn.Hidden() ? pagelist_mgr.Grp_hidden() : pagelist_mgr.Grp_normal();
|
||||
list.Itms().Itms_add(page);
|
||||
}
|
||||
pagelist_mgr.Init_by_wiki(wiki, hctx);
|
||||
pagelist_mgr.Bfr_arg__add(bfr);
|
||||
pagelist_mgr.Grp_hidden().Itms().Itms_clear();
|
||||
pagelist_mgr.Grp_normal().Itms().Itms_clear();
|
||||
}
|
||||
public Bry_fmtr Fmtr_all() {return fmtr_all;} private Bry_fmtr fmtr_all = Bry_fmtr.new_(String_.Concat_lines_nl
|
||||
( "<div id=\"catlinks\" class=\"catlinks\">~{grp_normal}~{grp_hidden}"
|
||||
, "</div>"
|
||||
), "grp_normal", "grp_hidden"
|
||||
);
|
||||
public Bry_fmtr Fmtr_grp_normal() {return fmtr_grp_normal;} private Bry_fmtr fmtr_grp_normal = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"
|
||||
, "<a href=\"/wiki/~{ctg_help_page}\" title=\"~{ctg_help_page}\">~{ctg_text}</a>:"
|
||||
, "<ul>~{grp_itms}"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
), "ctg_help_page", "ctg_text", "grp_itms"
|
||||
);
|
||||
public Bry_fmtr Fmtr_grp_hidden() {return fmtr_grp_hidden;} private Bry_fmtr fmtr_grp_hidden = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks mw-hidden-cats-user-shown\">~{hidden_ctg_txt}:"
|
||||
, "<ul>~{grp_itms}"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
), "hidden_ctg_txt", "grp_itms"
|
||||
);
|
||||
public Bry_fmtr Fmtr_itm() {return fmtr_itm;} private Bry_fmtr fmtr_itm = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, "<li>"
|
||||
, "<a~{lnki_cls} href=\"~{lnki_href}\" title=\"~{lnki_ttl}\">~{lnki_text}</a>"
|
||||
, "</li>"
|
||||
), "lnki_cls", "lnki_href", "lnki_ttl", "lnki_text"
|
||||
);
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xoctg_pagelist_wtr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoctg_pagelist_mgr_fxt fxt = new Xoctg_pagelist_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init_ctg_hidden("A", "B", "C");
|
||||
fxt.Init_ctg_normal("D", "E", "F");
|
||||
fxt.Test_print_hidden(String_.Concat_lines_nl
|
||||
( "<div id=\"catlinks\" class=\"catlinks\">"
|
||||
, "<div id=\"mw-normal-catlinks\" class=\"mw-normal-catlinks\">"
|
||||
, "<a href=\"/wiki/Special:Categories\" title=\"Special:Categories\">Categories</a>:"
|
||||
, "<ul>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:D\" title=\"Category:D\">D</a>"
|
||||
, "</li>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:E\" title=\"Category:E\">E</a>"
|
||||
, "</li>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:F\" title=\"Category:F\">F</a>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks mw-hidden-cats-user-shown\">Hidden categories:"
|
||||
, "<ul>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:A\" title=\"Category:A\">A</a>"
|
||||
, "</li>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:B\" title=\"Category:B\">B</a>"
|
||||
, "</li>"
|
||||
, "<li>"
|
||||
, "<a href=\"/wiki/Category:C\" title=\"Category:C\">C</a>"
|
||||
, "</li>"
|
||||
, "</ul>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Xoctg_pagelist_mgr_fxt {
|
||||
public void Clear() {
|
||||
fxt = new Xop_fxt();
|
||||
app = fxt.App();
|
||||
hidden_wtr = new Xoctg_pagelist_wtr();
|
||||
hidden_wtr.Init_by_app(app);
|
||||
init_ctgs.Clear();
|
||||
} private Xop_fxt fxt; private Xoae_app app; private Xoctg_pagelist_wtr hidden_wtr;
|
||||
public void Init_ctg_normal(String... ary) {Init_ctg(Bool_.N, ary);}
|
||||
public void Init_ctg_hidden(String... ary) {Init_ctg(Bool_.Y, ary);}
|
||||
public void Init_ctg(boolean hidden, String[] ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
String ttl = ary[i];
|
||||
Xowd_page_itm page = new Xowd_page_itm();
|
||||
Xowd_category_itm ctg_xtn = Xowd_category_itm.load_(0, 0, hidden, 0, 0, 0);
|
||||
page.Xtn_(ctg_xtn);
|
||||
page.Ttl_page_db_(Bry_.new_a7(ttl));
|
||||
init_ctgs.Add_many(page);
|
||||
}
|
||||
} private List_adp init_ctgs = List_adp_.New();
|
||||
public void Test_print_hidden(String expd) {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xowd_page_itm[] page_ary = (Xowd_page_itm[])init_ctgs.To_ary_and_clear(Xowd_page_itm.class);
|
||||
hidden_wtr.Print_hidden(bfr, fxt.Wiki(), page_ary, gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Basic);
|
||||
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
|
||||
// Tfds.Dbg(bfr.To_bry_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.net.qargs.*;
|
||||
public class Xoctg_url {
|
||||
public byte[][] Grp_idxs() {return grp_idxs;} private byte[][] grp_idxs = new byte[3][];
|
||||
public byte[] Grp_fwds() {return grp_fwds;} private byte[] grp_fwds = new byte[3];
|
||||
private void Clear() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
grp_fwds[i] = Bool_.__byte;
|
||||
grp_idxs[i] = null;
|
||||
}
|
||||
}
|
||||
public Xoctg_url Parse(Gfo_usr_dlg usr_dlg, Xoa_url url) {
|
||||
this.Clear();
|
||||
Gfo_qarg_itm[] args = url.Qargs_ary();
|
||||
int len = args.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Gfo_qarg_itm arg = args[i];
|
||||
byte[] arg_key = arg.Key_bry();
|
||||
Object tid_obj = Arg_keys.Get_by_bry(arg_key);
|
||||
if (tid_obj == null) {usr_dlg.Warn_many("", "", "unknown arg_key: ~{0}", String_.new_u8(arg_key)); continue;} // ignore invalid args
|
||||
byte[] arg_val = arg.Val_bry();
|
||||
byte tid = ((Byte_obj_val)tid_obj).Val();
|
||||
switch (tid) {
|
||||
case Tid_all_bgn: Set_grp(arg_val, Bool_.Y_byte, Xoa_ctg_mgr.Tid_subc, Xoa_ctg_mgr.Tid_file, Xoa_ctg_mgr.Tid_page); break; // if "from", default all grps to val; DATE:2014-02-05
|
||||
case Tid_all_end: Set_grp(arg_val, Bool_.N_byte, Xoa_ctg_mgr.Tid_subc, Xoa_ctg_mgr.Tid_file, Xoa_ctg_mgr.Tid_page); break;
|
||||
case Tid_subc_bgn: Set_grp(arg_val, Bool_.Y_byte, Xoa_ctg_mgr.Tid_subc); break;
|
||||
case Tid_subc_end: Set_grp(arg_val, Bool_.N_byte, Xoa_ctg_mgr.Tid_subc); break;
|
||||
case Tid_file_bgn: Set_grp(arg_val, Bool_.Y_byte, Xoa_ctg_mgr.Tid_file); break;
|
||||
case Tid_file_end: Set_grp(arg_val, Bool_.N_byte, Xoa_ctg_mgr.Tid_file); break;
|
||||
case Tid_page_bgn: Set_grp(arg_val, Bool_.Y_byte, Xoa_ctg_mgr.Tid_page); break;
|
||||
case Tid_page_end: Set_grp(arg_val, Bool_.N_byte, Xoa_ctg_mgr.Tid_page); break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
private void Set_grp(byte[] val, byte fwd, byte... tids) {
|
||||
int tids_len = tids.length;
|
||||
for (int i = 0; i < tids_len; i++) {
|
||||
byte tid = tids[i];
|
||||
grp_fwds[tid] = fwd;
|
||||
grp_idxs[tid] = val;
|
||||
}
|
||||
}
|
||||
public static final byte Tid_all_bgn = 0, Tid_subc_bgn = 1, Tid_subc_end = 2, Tid_file_bgn = 3, Tid_file_end = 4, Tid_page_bgn = 5, Tid_page_end = 6, Tid_all_end = 8;
|
||||
public static final Hash_adp_bry Arg_keys = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_from, Tid_all_bgn)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_until, Tid_all_end)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_subc_bgn, Tid_subc_bgn)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_subc_end, Tid_subc_end)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_file_bgn, Tid_file_bgn)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_file_end, Tid_file_end)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_page_bgn, Tid_page_bgn)
|
||||
.Add_bry_byte(Xoctg_fmtr_all.Url_arg_page_end, Tid_page_end)
|
||||
;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.apps.urls.*;
|
||||
public class Xoctg_url_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xoctg_url_fxt fxt = new Xoctg_url_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test_parse("A?subcatfrom=B&filefrom=C&pagefrom=D", fxt.url().Grp_idxs_("B", "C", "D").Grp_fwds_(Bool_.Y_byte, Bool_.Y_byte, Bool_.Y_byte));
|
||||
fxt.Test_parse("A?subcatuntil=B&fileuntil=C&pageuntil=D", fxt.url().Grp_idxs_("B", "C", "D").Grp_fwds_(Bool_.N_byte, Bool_.N_byte, Bool_.N_byte));
|
||||
fxt.Test_parse("A?from=B", fxt.url().Grp_idxs_("B", "B", "B").Grp_fwds_(Bool_.Y_byte, Bool_.Y_byte, Bool_.Y_byte));
|
||||
fxt.Test_parse("A?until=B", fxt.url().Grp_idxs_("B", "B", "B").Grp_fwds_(Bool_.N_byte, Bool_.N_byte, Bool_.N_byte));
|
||||
}
|
||||
}
|
||||
class Xoctg_url_fxt {
|
||||
public Xoctg_url_chkr url() {return expd.Clear();} private Xoctg_url_chkr expd;
|
||||
public void Clear() {
|
||||
if (parser == null) {
|
||||
Xoa_app app = Xoa_app_fxt.Make__app__edit();
|
||||
parser = app.User().Wikii().Utl__url_parser();
|
||||
page_url = Xoa_url.blank();
|
||||
ctg_url = new Xoctg_url();
|
||||
expd = new Xoctg_url_chkr();
|
||||
}
|
||||
} private Xow_url_parser parser; Xoa_url page_url; Xoctg_url ctg_url;
|
||||
public void Test_parse(String url_str, Xoctg_url_chkr expd) {
|
||||
page_url = parser.Parse(Bry_.new_u8(url_str));
|
||||
ctg_url.Parse(Gfo_usr_dlg_.Test(), page_url);
|
||||
expd.Chk(ctg_url);
|
||||
expd.Clear();
|
||||
}
|
||||
}
|
||||
class Xoctg_url_chkr {
|
||||
public Xoctg_url_chkr Grp_idxs_(String subc, String file, String page) {
|
||||
grp_idxs[Xoa_ctg_mgr.Tid_subc] = Bry_.new_a7(subc);
|
||||
grp_idxs[Xoa_ctg_mgr.Tid_file] = Bry_.new_a7(file);
|
||||
grp_idxs[Xoa_ctg_mgr.Tid_page] = Bry_.new_a7(page);
|
||||
return this;
|
||||
} byte[][] grp_idxs = new byte[Xoa_ctg_mgr.Tid__max][];
|
||||
public Xoctg_url_chkr Grp_fwds_(byte subc, byte file, byte page) {
|
||||
grp_fwds[Xoa_ctg_mgr.Tid_subc] = subc;
|
||||
grp_fwds[Xoa_ctg_mgr.Tid_file] = file;
|
||||
grp_fwds[Xoa_ctg_mgr.Tid_page] = page;
|
||||
return this;
|
||||
} byte[] grp_fwds = new byte[Xoa_ctg_mgr.Tid__max];
|
||||
public void Chk(Xoctg_url actl) {
|
||||
Tfds.Eq_ary_str(String_.Ary(grp_idxs), String_.Ary(actl.Grp_idxs()));
|
||||
Tfds.Eq_ary(grp_fwds, actl.Grp_fwds());
|
||||
}
|
||||
public Xoctg_url_chkr Clear() {
|
||||
int len = Xoa_ctg_mgr.Tid__max;
|
||||
for (int i = 0; i < len; i++) {
|
||||
grp_idxs[i] = null;
|
||||
grp_fwds[i] = Bool_.__byte;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoctg_view_ctg {
|
||||
public byte[] Name() {return name;} public Xoctg_view_ctg Name_(byte[] v) {name = v; return this;} private byte[] name;
|
||||
public int Total_count() {return subcs.Total() + pages.Total() + files.Total();}
|
||||
public Xoctg_view_grp Subcs() {return subcs;} private Xoctg_view_grp subcs = new Xoctg_view_grp(Xoa_ctg_mgr.Tid_subc);
|
||||
public Xoctg_view_grp Pages() {return pages;} private Xoctg_view_grp pages = new Xoctg_view_grp(Xoa_ctg_mgr.Tid_page);
|
||||
public Xoctg_view_grp Files() {return files;} private Xoctg_view_grp files = new Xoctg_view_grp(Xoa_ctg_mgr.Tid_file).Hdr_exists_(false);
|
||||
public Xoctg_view_grp Grp_by_tid(byte tid) {
|
||||
switch (tid) {
|
||||
case Xoa_ctg_mgr.Tid_subc: return subcs;
|
||||
case Xoa_ctg_mgr.Tid_page: return pages;
|
||||
case Xoa_ctg_mgr.Tid_file: return files;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
public boolean Hidden() {return hidden;} private boolean hidden;
|
||||
public void Num_(Xoctg_data_ctg data_ctg) {
|
||||
this.hidden = data_ctg.Hidden();
|
||||
Num_set(data_ctg, Xoa_ctg_mgr.Tid_subc);
|
||||
Num_set(data_ctg, Xoa_ctg_mgr.Tid_file);
|
||||
Num_set(data_ctg, Xoa_ctg_mgr.Tid_page);
|
||||
}
|
||||
private void Num_set(Xoctg_data_ctg data_ctg, byte tid) {
|
||||
Xoctg_idx_mgr idx_mgr = data_ctg.Grp_by_tid(tid);
|
||||
if (idx_mgr != null) Grp_by_tid(tid).Total_(idx_mgr.Total());
|
||||
}
|
||||
public void Fill(Xoctg_url url_ctg, Xoctg_data_ctg data_ctg) {
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
Fill_grp(url_ctg, data_ctg, i);
|
||||
}
|
||||
}
|
||||
private void Fill_grp(Xoctg_url url_ctg, Xoctg_data_ctg data_ctg, byte i) {
|
||||
Xoctg_view_grp view_grp = Grp_by_tid(i);
|
||||
Xoctg_idx_mgr data_grp = data_ctg.Grp_by_tid(i); if (data_grp == null) return; // no itms in grp
|
||||
byte[] url_bmk = url_ctg.Grp_idxs()[i]; byte url_bmk_fwd = url_ctg.Grp_fwds()[i];
|
||||
data_grp.Find(view_grp.Itms_list(), data_grp.Src(), url_bmk_fwd != Bool_.N_byte, url_bmk, 200, tmp_last_plus_one);
|
||||
view_grp.Itms_last_sortkey_(tmp_last_plus_one.Sort_key());
|
||||
view_grp.Itms_make();
|
||||
} private Xoctg_view_itm tmp_last_plus_one = new Xoctg_view_itm();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xoctg_view_grp {
|
||||
public Xoctg_view_grp(byte tid) {this.tid = tid;}
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public boolean Hdr_exists() {return hdr_exists;} public Xoctg_view_grp Hdr_exists_(boolean v) {hdr_exists = v; return this;} private boolean hdr_exists = true;
|
||||
public int Bgn() {return bgn;} public Xoctg_view_grp Bgn_(int v) {bgn = v; return this;} private int bgn;
|
||||
public int End() {return end;} public Xoctg_view_grp End_(int v) {end = v; return this;} private int end;
|
||||
public int Len() {return end - bgn;}
|
||||
public int Max() {return max;} public Xoctg_view_grp Max_(int v) {max = v; return this;} private int max;
|
||||
public int All() {return all;} public Xoctg_view_grp All_(int v) {all = v; return this;} private int all;
|
||||
public int Total() {return total;} public Xoctg_view_grp Total_(int v) {total = v; return this;} private int total;
|
||||
public Xoctg_view_itm[] Itms() {return itms;} public Xoctg_view_grp Itms_(Xoctg_view_itm[] v) {itms = v; return this;} private Xoctg_view_itm[] itms = Xoctg_view_itm.Ary_empty;
|
||||
public Xoctg_view_itm Itms_at_first() {return Itms_at(0);}
|
||||
public Xoctg_view_itm Itms_at_last() {return Itms_at(itms.length - 1);}
|
||||
Xoctg_view_itm Itms_at(int i) {
|
||||
if (i < 0 || i >= itms.length) throw Err_.new_wo_type("ctg.view: i is out of bounds", "i", i, "len", itms.length, "tid", tid);
|
||||
Xoctg_view_itm rv = itms[i]; if (rv == null) throw Err_.new_wo_type("ctg.view: itm is null", "i", i, "len", itms.length, "tid", tid);
|
||||
return rv;
|
||||
}
|
||||
public void Itms_add(Xoctg_view_itm sub) {tmp_list.Add(sub);}
|
||||
public List_adp Itms_list() {return tmp_list;} private final List_adp tmp_list = List_adp_.New();
|
||||
public void Itms_make() {itms = (Xoctg_view_itm[])tmp_list.To_ary(Xoctg_view_itm.class);}
|
||||
public byte[] Itms_last_sortkey() {return itms_last_sortkey;} public Xoctg_view_grp Itms_last_sortkey_(byte[] v) {itms_last_sortkey = v; return this;} private byte[] itms_last_sortkey;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
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.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.flds.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xoctg_view_itm implements gplx.CompareAble {
|
||||
public byte Tid() {return tid;} private byte tid; // Xoa_ctg_mgr.Tid*
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public Xoa_ttl Ttl() {return ttl;} private Xoa_ttl ttl;
|
||||
public byte[] Sort_key() {return sort_key;} private byte[] sort_key;
|
||||
public int Sort_idx() {return sort_idx;} private int sort_idx;
|
||||
public boolean Missing() {return missing;} private boolean missing; public void Missing_y_() {missing = true;}
|
||||
public Xoctg_view_itm Set__page(byte tid, int page_id) {this.tid = tid; this.page_id = page_id; return this;}
|
||||
public Xoctg_view_itm Set__ttl__sortkey(Xoa_ttl ttl, byte[] sort_key) {
|
||||
this.ttl = ttl;
|
||||
Sort_key_(sort_key);
|
||||
return this;
|
||||
}
|
||||
public Xoctg_view_itm Parse(Gfo_fld_rdr fld_rdr, int sort_idx) { // NOTE: XO stores data as "page_id|ctg_added_on|sortkey"
|
||||
this.sort_idx = sort_idx;
|
||||
page_id = fld_rdr.Read_int_base85_len5();
|
||||
fld_rdr.Read_int_base85_len5(); // skip ctg_added_on; not used
|
||||
Sort_key_(fld_rdr.Read_bry_escape());
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
sort_idx = page_id = 0;
|
||||
sort_key = null;
|
||||
}
|
||||
private void Sort_key_(byte[] v) {
|
||||
this.sort_key = v;
|
||||
if (sort_key.length == 0) // v1 will not have sortkey data; PAGE:s.w:Category:Computer_science DATE:2015-11-22
|
||||
sort_key = ttl.Page_db();
|
||||
}
|
||||
public int compareTo(Object obj) {Xoctg_view_itm comp = (Xoctg_view_itm)obj; return Int_.Compare(page_id, comp.Page_id());}
|
||||
public static final Xoctg_view_itm[] Ary_empty = new Xoctg_view_itm[0];
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class Xow_db_file {
|
||||
public Xowd_site_ns_tbl Tbl__ns() {return tbl__ns;} private final Xowd_site_ns_tbl tbl__ns;
|
||||
public Xowd_page_tbl Tbl__page() {return tbl__page;} private Xowd_page_tbl tbl__page;
|
||||
public Xowd_text_tbl Tbl__text() {return tbl__text;} private final Xowd_text_tbl tbl__text;
|
||||
public Xowd_html_tbl Tbl__html() {return tbl__html;} private final Xowd_html_tbl tbl__html;
|
||||
public Xowd_html_tbl Tbl__html() {return tbl__html;} private final Xowd_html_tbl tbl__html;
|
||||
public Xowd_css_core_tbl Tbl__css_core() {return tbl__css_core;} private final Xowd_css_core_tbl tbl__css_core;
|
||||
public Xowd_css_file_tbl Tbl__css_file() {return tbl__css_file;} private final Xowd_css_file_tbl tbl__css_file;
|
||||
public Xowd_cat_core_tbl Tbl__cat_core() {return tbl__cat_core;} private final Xowd_cat_core_tbl tbl__cat_core;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class Xow_db_file__core_ {
|
||||
|
||||
public static boolean Is_core_fil_name(String domain_name, String fil_name) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_name));
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Tid__other) {
|
||||
return String_.Has_at_end(fil_name, ".xowa");
|
||||
}
|
||||
String domain_str = domain_itm.Domain_str();
|
||||
|
||||
56
400_xowa/src/gplx/xowa/wikis/data/tbls/Select_in_cbk.java
Normal file
56
400_xowa/src/gplx/xowa/wikis/data/tbls/Select_in_cbk.java
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
public interface Select_in_cbk {
|
||||
void Write_sql(Bry_bfr bfr, int idx);
|
||||
void Read_data(Db_rdr rdr);
|
||||
int Hash_max();
|
||||
}
|
||||
class Select_in_wkr {
|
||||
private final byte[] sql_bgn;
|
||||
public Select_in_wkr(byte[] sql_bgn) {this.sql_bgn = sql_bgn;}
|
||||
public int Make_sql_or_null(Bry_bfr bfr, Select_in_cbk cbk, int bgn) {
|
||||
// read 50 at a time
|
||||
int max = cbk.Hash_max();
|
||||
int end = bgn + 50; if (end > max) end = max;
|
||||
if (bgn == end) return -1; // at eos; return;
|
||||
|
||||
// concat itms
|
||||
bfr.Add(sql_bgn);
|
||||
for (int i = bgn; i < end; ++i) {
|
||||
if (i != bgn) bfr.Add_str_a7(", ");
|
||||
cbk.Write_sql(bfr, i);
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Paren_end);
|
||||
return end;
|
||||
}
|
||||
public static Select_in_wkr New(Bry_bfr bfr, String tbl_name, String[] select_flds, String where_fld) {
|
||||
bfr.Add_str_a7("SELECT ");
|
||||
int select_flds_len = select_flds.length;
|
||||
for (int i = 0; i < select_flds_len; ++i) {
|
||||
String select_fld = select_flds[i];
|
||||
if (i != 0) bfr.Add_str_a7(", ");
|
||||
bfr.Add_str_u8(select_fld);
|
||||
}
|
||||
bfr.Add_str_a7(" FROM ").Add_str_u8(tbl_name);
|
||||
bfr.Add_str_a7(" WHERE ").Add_str_u8(where_fld);
|
||||
bfr.Add_str_a7(" IN (");
|
||||
return new Select_in_wkr(bfr.To_bry_and_clear());
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xowd_cat_core_tbl implements Rls_able {
|
||||
public class Xowd_cat_core_tbl implements Db_tbl {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_id, fld_pages, fld_subcats, fld_files, fld_hidden, fld_link_db_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_update, stmt_select;
|
||||
@@ -37,7 +37,8 @@ public class Xowd_cat_core_tbl implements Rls_able {
|
||||
in_wkr.Ctor(this, tbl_name, flds, fld_id);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Xowd_cat_core_tbl Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds)); return this;}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__cat_core__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int id, int pages, int subcats, int files, byte hidden, int link_db_id) {
|
||||
@@ -61,6 +62,20 @@ public class Xowd_cat_core_tbl implements Rls_able {
|
||||
in_wkr.Init(rv);
|
||||
in_wkr.Select_in(cancelable, conn, bgn, end);
|
||||
}
|
||||
public void Select_by_cat_id_many(Select_in_cbk cbk) {
|
||||
int pos = 0;
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Select_in_wkr wkr = Select_in_wkr.New(bfr, tbl_name, String_.Ary(fld_id, fld_pages, fld_subcats, fld_files, fld_hidden), fld_id);
|
||||
while (true) {
|
||||
pos = wkr.Make_sql_or_null(bfr, cbk, pos);
|
||||
if (pos == -1) break;
|
||||
Db_rdr rdr = conn.Stmt_sql(bfr.To_str_and_clear()).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next())
|
||||
cbk.Read_data(rdr);
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
}
|
||||
public Xowd_category_itm new_itm(Db_rdr rdr) {
|
||||
return Xowd_category_itm.load_
|
||||
( rdr.Read_int(fld_id)
|
||||
|
||||
@@ -16,12 +16,11 @@ 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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.ctgs.*;
|
||||
public class Xowd_cat_link_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.addons.wikis.ctgs.*;
|
||||
public class Xowd_cat_link_tbl implements Db_tbl {
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_from, fld_to_id, fld_sortkey, fld_timestamp, fld_type_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert, stmt_select_in;
|
||||
public Db_conn Conn() {return conn;}
|
||||
private Db_stmt stmt_insert, stmt_select_in;
|
||||
public Xowd_cat_link_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = schema_is_1 ? "categorylinks" : "cat_link";
|
||||
@@ -32,7 +31,9 @@ public class Xowd_cat_link_tbl implements Rls_able {
|
||||
fld_timestamp = flds.Add_str ("cl_timestamp", 14);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Xowd_cat_link_tbl Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds)); return this;}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {
|
||||
conn.Meta_idx_create(Xoa_app_.Usr_dlg()
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "main", fld_to_id, fld_type_id, fld_sortkey, fld_from)
|
||||
@@ -51,6 +52,7 @@ public class Xowd_cat_link_tbl implements Rls_able {
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Delete_all() {conn.Stmt_delete(tbl_name, Dbmeta_fld_itm.Str_ary_empty).Exec_delete();}
|
||||
|
||||
public int Select_by_type(List_adp list, int cat_page_id, byte arg_tid, byte[] arg_sortkey, boolean arg_is_from, int limit) {
|
||||
String arg_sortkey_str = arg_sortkey == null ? "" : String_.new_u8(arg_sortkey);
|
||||
gplx.core.criterias.Criteria comp_crt = !arg_is_from
|
||||
|
||||
@@ -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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.wikis.ctgs.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.addons.wikis.ctgs.*;
|
||||
public class Xowd_category_itm {
|
||||
public int Id() {return id;} private int id;
|
||||
public Int_obj_val Id_val() {if (id_val == null) id_val = new Int_obj_val(id); return id_val;} Int_obj_val id_val;
|
||||
|
||||
@@ -28,9 +28,10 @@ public class Xowd_page_itm {
|
||||
public boolean Redirected() {return redirected;} public Xowd_page_itm Redirected_(boolean v) {redirected = v; return this;} private boolean redirected;
|
||||
public int Text_len() {return text_len;} public Xowd_page_itm Text_len_(int v) {text_len = v; return this;} private int text_len;
|
||||
public int Text_db_id() {return text_db_id;} public Xowd_page_itm Text_db_id_(int v) {text_db_id = v; return this;} private int text_db_id;
|
||||
public int Html_db_id() {return html_db_id;} private int html_db_id;
|
||||
public int Cat_db_id() {return cat_db_id;} private int cat_db_id;
|
||||
public byte[] Text() {return text;} public Xowd_page_itm Text_(byte[] v) {text = v; if (v != null) text_len = v.length; return this;} private byte[] text;
|
||||
public int Random_int() {return random_int;} private int random_int;
|
||||
public int Html_db_id() {return html_db_id;} private int html_db_id;
|
||||
public int Redirect_id() {return redirect_id;} private int redirect_id;
|
||||
public DateAdp Modified_on() {return modified_on;} public Xowd_page_itm Modified_on_(DateAdp v) {modified_on = v; return this;} private DateAdp modified_on;
|
||||
public boolean Exists() {return exists;} private boolean exists;
|
||||
@@ -48,14 +49,16 @@ public class Xowd_page_itm {
|
||||
public void Init_by_load__idx(int id, int ns_id, byte[] ttl_page_db, int text_len) {
|
||||
this.exists = true; // COMMENT: DATE:2016-08-28
|
||||
this.id = id;
|
||||
this.id_val = null;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
this.text_len = text_len;
|
||||
}
|
||||
public void Init_by_load__all(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int random_int, int text_db_id, int html_db_id, int redirect_id, int score) {
|
||||
public void Init_by_load__all(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int random_int, int text_db_id, int html_db_id, int redirect_id, int score, int cat_db_id) {
|
||||
// same as Init_by_load__idx; COMMENT: DATE:2016-08-28
|
||||
this.exists = true;
|
||||
this.id = id;
|
||||
this.id_val = null;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
this.text_len = text_len;
|
||||
@@ -68,11 +71,13 @@ public class Xowd_page_itm {
|
||||
this.html_db_id = html_db_id;
|
||||
this.redirect_id = redirect_id;
|
||||
this.score = score;
|
||||
this.cat_db_id = cat_db_id;
|
||||
}
|
||||
public void Init_by_tdb(int id, int text_db_id, int tdb_row_idx, boolean redirected, int text_len, int ns_id, byte[] ttl_page_db) {
|
||||
// same as Init_by_load__idx; COMMENT: DATE:2016-08-28
|
||||
this.exists = true;
|
||||
this.id = id;
|
||||
this.id_val = null;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
this.text_len = text_len;
|
||||
@@ -120,7 +125,7 @@ public class Xowd_page_itm {
|
||||
redirected = exists = false;
|
||||
modified_on = DateAdp_.MinValue;
|
||||
id_val = null;
|
||||
html_db_id = -1;
|
||||
html_db_id = cat_db_id = -1;
|
||||
redirect_id = -1;
|
||||
return this;
|
||||
}
|
||||
@@ -139,6 +144,7 @@ public class Xowd_page_itm {
|
||||
this.modified_on = orig.modified_on;
|
||||
this.id_val = null;
|
||||
this.html_db_id = orig.html_db_id;
|
||||
this.cat_db_id = orig.cat_db_id;
|
||||
}
|
||||
public void Srl_save(Bry_bfr bfr) {gplx.xowa.wikis.tdbs.Xotdb_page_itm_.Txt_id_save(bfr, this);}
|
||||
public static final int Id_null = -1, Modified_on_null_int = 0, Redirect_id_null = -1;
|
||||
|
||||
@@ -32,8 +32,8 @@ public class Xowd_page_itm_sorter implements ComparerAble {
|
||||
case Tid_id: return Int_.Compare(lhs.Id(), rhs.Id());
|
||||
case Tid_ttl: return Bry_.Compare(lhs.Ttl_page_db(), rhs.Ttl_page_db());
|
||||
case Tid_ctg_tid_sortkey:
|
||||
gplx.xowa.wikis.ctgs.Xoctg_page_xtn lhs_xtn = (gplx.xowa.wikis.ctgs.Xoctg_page_xtn)lhs.Xtn();
|
||||
gplx.xowa.wikis.ctgs.Xoctg_page_xtn rhs_xtn = (gplx.xowa.wikis.ctgs.Xoctg_page_xtn)rhs.Xtn();
|
||||
gplx.xowa.addons.wikis.ctgs.Xoctg_page_xtn lhs_xtn = (gplx.xowa.addons.wikis.ctgs.Xoctg_page_xtn)lhs.Xtn();
|
||||
gplx.xowa.addons.wikis.ctgs.Xoctg_page_xtn rhs_xtn = (gplx.xowa.addons.wikis.ctgs.Xoctg_page_xtn)rhs.Xtn();
|
||||
if (lhs_xtn == null || rhs_xtn == null) return CompareAble_.Same;
|
||||
int tid_comparable = Byte_.Compare(lhs_xtn.Tid(), rhs_xtn.Tid());
|
||||
if (tid_comparable != CompareAble_.Same) return tid_comparable;
|
||||
@@ -45,9 +45,9 @@ public class Xowd_page_itm_sorter implements ComparerAble {
|
||||
byte compareType; int order;
|
||||
static final byte Tid_ns_ttl = 0, Tid_itm_len = 2, Tid_id = 3, Tid_ttl = 4, Tid_ctg_tid_sortkey = 5;
|
||||
static final int Asc = 1, Dsc = -1;
|
||||
public static final Xowd_page_itm_sorter TitleAsc = new Xowd_page_itm_sorter(Tid_ttl , Asc);
|
||||
public static final Xowd_page_itm_sorter EnyLenDsc = new Xowd_page_itm_sorter(Tid_itm_len , Dsc);
|
||||
public static final Xowd_page_itm_sorter IdAsc = new Xowd_page_itm_sorter(Tid_id , Asc);
|
||||
public static final Xowd_page_itm_sorter Ns_id_TtlAsc = new Xowd_page_itm_sorter(Tid_ns_ttl , Asc);
|
||||
public static final Xowd_page_itm_sorter Ctg_tid_sortkey_asc = new Xowd_page_itm_sorter(Tid_ctg_tid_sortkey , Asc);
|
||||
public static final Xowd_page_itm_sorter TitleAsc = new Xowd_page_itm_sorter(Tid_ttl , Asc);
|
||||
public static final Xowd_page_itm_sorter EnyLenDsc = new Xowd_page_itm_sorter(Tid_itm_len , Dsc);
|
||||
public static final Xowd_page_itm_sorter IdAsc = new Xowd_page_itm_sorter(Tid_id , Asc);
|
||||
public static final Xowd_page_itm_sorter Ns_id_TtlAsc = new Xowd_page_itm_sorter(Tid_ns_ttl , Asc);
|
||||
public static final Xowd_page_itm_sorter Ctg_tid_sortkey_asc = new Xowd_page_itm_sorter(Tid_ctg_tid_sortkey , Asc);
|
||||
}
|
||||
|
||||
@@ -23,15 +23,20 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
private final Object thread_lock = new Object();
|
||||
private final String tbl_name = "page";
|
||||
public final boolean schema_is_1;
|
||||
private String fld_id, fld_ns, fld_title, fld_is_redirect, fld_touched, fld_len, fld_random_int, fld_score, fld_text_db_id, fld_html_db_id, fld_redirect_id;
|
||||
private String fld_id, fld_ns, fld_title, fld_is_redirect, fld_touched, fld_len, fld_random_int, fld_score, fld_text_db_id, fld_html_db_id, fld_redirect_id, fld_cat_db_id;
|
||||
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private Db_stmt stmt_select_all_by_ttl, stmt_select_all_by_id, stmt_select_id_by_ttl, stmt_insert;
|
||||
private final String[] flds_select_all, flds_select_idx;
|
||||
public Xowd_page_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn; this.schema_is_1 = schema_is_1;
|
||||
String fld_text_db_id_name = "";
|
||||
String fld_cat_db_id_name = Dbmeta_fld_itm.Key_null;
|
||||
if (schema_is_1) {fld_text_db_id_name = "page_file_idx";}
|
||||
else {fld_text_db_id_name = "page_text_db_id";}
|
||||
else {
|
||||
fld_text_db_id_name = "page_text_db_id";
|
||||
if (conn.Meta_fld_exists(tbl_name, "page_cat_db_id"))
|
||||
fld_cat_db_id_name = "page_cat_db_id";
|
||||
}
|
||||
fld_id = flds.Add_int_pkey("page_id"); // int(10); unsigned -- MW:same
|
||||
fld_ns = flds.Add_int("page_namespace"); // int(11); -- MW:same
|
||||
fld_title = flds.Add_str("page_title", 255); // varbinary(255); -- MW:blob
|
||||
@@ -43,7 +48,9 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
fld_html_db_id = flds.Add_int_dflt("page_html_db_id", -1); // MW:XOWA
|
||||
fld_redirect_id = flds.Add_int_dflt("page_redirect_id", -1); // MW:XOWA
|
||||
fld_score = flds.Add_int_dflt(Fld__page_score__key, -1); // MW:XOWA
|
||||
flds_select_all = String_.Ary_wo_null(fld_id, fld_ns, fld_title, fld_touched, fld_is_redirect, fld_len, fld_random_int, fld_text_db_id, fld_html_db_id, fld_redirect_id, fld_score);
|
||||
if (fld_cat_db_id_name != Dbmeta_fld_itm.Key_null)
|
||||
fld_cat_db_id = flds.Add_int_dflt(fld_cat_db_id_name, -1);// MW:XOWA
|
||||
flds_select_all = String_.Ary_wo_null(fld_id, fld_ns, fld_title, fld_touched, fld_is_redirect, fld_len, fld_random_int, fld_text_db_id, fld_html_db_id, fld_redirect_id, fld_score, fld_cat_db_id);
|
||||
flds_select_idx = String_.Ary_wo_null(fld_ns, fld_title, fld_id, fld_len, fld_score);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
@@ -89,6 +96,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
.Val_int(fld_html_db_id, html_db_id)
|
||||
.Val_int(fld_redirect_id, -1)
|
||||
.Val_int(fld_score, -1)
|
||||
.Val_int(fld_cat_db_id, -1)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Insert_by_itm(Db_stmt stmt, Xowd_page_itm itm, int html_db_id) {
|
||||
@@ -104,8 +112,14 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
.Val_int (fld_html_db_id , html_db_id)
|
||||
.Val_int (fld_redirect_id , itm.Redirect_id())
|
||||
.Val_int (fld_score , itm.Score())
|
||||
.Val_int (fld_cat_db_id , -1)
|
||||
.Exec_insert();
|
||||
}
|
||||
public Xowd_page_itm Select_by_ttl_as_itm_or_null(Xoa_ttl ttl) {
|
||||
Xowd_page_itm rv = new Xowd_page_itm();
|
||||
return Select_by_ttl(rv, ttl) ? rv : null;
|
||||
}
|
||||
public boolean Select_by_ttl(Xowd_page_itm rv, Xoa_ttl ttl) {return Select_by_ttl(rv, ttl.Ns(), ttl.Page_db());}
|
||||
public boolean Select_by_ttl(Xowd_page_itm rv, Xow_ns ns, byte[] ttl) {
|
||||
if (stmt_select_all_by_ttl == null) stmt_select_all_by_ttl = conn.Stmt_select(tbl_name, flds, String_.Ary(fld_ns, fld_title));
|
||||
synchronized (thread_lock) { // LOCK:stmt-rls; DATE:2016-07-06
|
||||
@@ -287,6 +301,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
// handle page_score defaulting to page_len
|
||||
int page_len = rdr.Read_int(fld_len);
|
||||
int page_score = fld_score == Dbmeta_fld_itm.Key_null ? page_len : rdr.Read_int(fld_score);
|
||||
int cat_db_id = fld_cat_db_id == Dbmeta_fld_itm.Key_null ? -1 : rdr.Read_int(fld_cat_db_id);
|
||||
|
||||
page.Init_by_load__all
|
||||
( rdr.Read_int(fld_id)
|
||||
@@ -300,6 +315,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
, rdr.Read_int(fld_html_db_id)
|
||||
, rdr.Read_int(fld_redirect_id)
|
||||
, page_score
|
||||
, cat_db_id
|
||||
);
|
||||
}
|
||||
public void Update__html_db_id(int page_id, int html_db_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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import org.junit.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.ctgs.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import org.junit.*; import gplx.xowa.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xowd_page_tbl_tst {
|
||||
private Xowd_page_tbl_fxt fxt = new Xowd_page_tbl_fxt();
|
||||
@Test public void Find_search_end() {
|
||||
|
||||
@@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*;
|
||||
public interface Xodb_load_mgr {
|
||||
void Load_init (Xowe_wiki wiki);
|
||||
void Load_page (Xowd_page_itm rv, Xow_ns ns);
|
||||
@@ -27,9 +28,8 @@ public interface Xodb_load_mgr {
|
||||
boolean Load_by_ttl (Xowd_page_itm rv, Xow_ns ns, byte[] ttl);
|
||||
void Load_by_ttls (Cancelable cancelable, Ordered_hash rv, boolean fill_idx_fields_only, int bgn, int end);
|
||||
int Load_ctg_count (byte[] ttl);
|
||||
boolean Load_ctg_v1 (Xoctg_view_ctg rv, byte[] ttl);
|
||||
boolean Load_ctg_v2 (Xoctg_data_ctg rv, byte[] ttl);
|
||||
void Load_ctg_v2a (Xoctg_view_ctg rv, Xoctg_url url_ctg, byte[] ttl_bry, int limit, boolean app_is_cmd);
|
||||
boolean Load_ctg_v1 (Xoctg_catpage_ctg rv, byte[] ttl);
|
||||
void Load_ctg_v2a (Xoctg_catpage_ctg rv, Xoctg_catpage_url url_ctg, byte[] ttl_bry, int limit, boolean app_is_cmd);
|
||||
Xowd_page_itm[] Load_ctg_list (byte[][] ctg_ttls);
|
||||
void Load_ttls_for_all_pages (Cancelable cancelable, List_adp rslt_list, Xowd_page_itm rslt_nxt, Xowd_page_itm rslt_prv, Int_obj_ref rslt_count, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item);
|
||||
void Load_ttls_for_search_suggest(Cancelable cancelable, List_adp rslt_list, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item);
|
||||
|
||||
@@ -17,10 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.addons.wikis.ctgs.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.addons.wikis.searchs.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*;
|
||||
public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
private Xodb_mgr_sql db_mgr; Xow_db_mgr fsys_mgr;
|
||||
public Xodb_load_mgr_sql(Xow_wiki wiki, Xodb_mgr_sql db_mgr, Xow_db_mgr fsys_mgr) {this.db_mgr = db_mgr; this.fsys_mgr = fsys_mgr;}
|
||||
@@ -57,20 +58,19 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
}
|
||||
public boolean Load_by_id (Xowd_page_itm rv, int id) {return db_mgr.Core_data_mgr().Tbl__page().Select_by_id(rv, id);}
|
||||
public void Load_by_ids(Cancelable cancelable, List_adp rv, int bgn, int end) {db_mgr.Core_data_mgr().Tbl__page().Select_in__id(cancelable, false, true, rv, bgn, end);}
|
||||
public boolean Load_ctg_v1(Xoctg_view_ctg rv, byte[] ctg_bry) {
|
||||
public boolean Load_ctg_v1(Xoctg_catpage_ctg rv, byte[] ctg_bry) {
|
||||
int cat_page_id = db_mgr.Core_data_mgr().Tbl__page().Select_id(Xow_ns_.Tid__category, ctg_bry); if (cat_page_id == Xowd_page_itm.Id_null) return false;
|
||||
Xowd_category_itm ctg = fsys_mgr.Db__cat_core().Tbl__cat_core().Select(cat_page_id); if (ctg == Xowd_category_itm.Null) return false;
|
||||
return Ctg_select_v1(db_mgr.Wiki(), db_mgr.Core_data_mgr(), rv, ctg.File_idx(), ctg);
|
||||
}
|
||||
public boolean Load_ctg_v2(Xoctg_data_ctg rv, byte[] ctg_bry) {throw Err_.new_unimplemented();}
|
||||
public void Load_ctg_v2a(Xoctg_view_ctg rv, Xoctg_url ctg_url, byte[] ctg_ttl, int load_max, boolean app_is_cmd) {
|
||||
public void Load_ctg_v2a(Xoctg_catpage_ctg rv, Xoctg_catpage_url ctg_url, byte[] ctg_ttl, int load_max, boolean app_is_cmd) {
|
||||
int cat_page_id = db_mgr.Core_data_mgr().Tbl__page().Select_id(Xow_ns_.Tid__category, ctg_ttl); if (cat_page_id == Xowd_page_itm.Id_null) return;
|
||||
Xowd_category_itm ctg = fsys_mgr.Db__cat_core().Tbl__cat_core().Select(cat_page_id); if (ctg == Xowd_category_itm.Null) return;
|
||||
List_adp list = List_adp_.New();
|
||||
Load_ctg_v2a_db_retrieve(rv, ctg_url, cat_page_id, load_max, ctg.File_idx(), list, app_is_cmd);
|
||||
Load_ctg_v2a_ui_sift(rv, ctg, list);
|
||||
}
|
||||
private void Load_ctg_v2a_db_retrieve(Xoctg_view_ctg rv, Xoctg_url ctg_url, int cat_page_id, int load_max, int cat_link_db_idx, List_adp list, boolean app_is_cmd) {
|
||||
private void Load_ctg_v2a_db_retrieve(Xoctg_catpage_ctg rv, Xoctg_catpage_url ctg_url, int cat_page_id, int load_max, int cat_link_db_idx, List_adp list, boolean app_is_cmd) {
|
||||
int len = Xoa_ctg_mgr.Tid__max;
|
||||
for (byte i = Xoa_ctg_mgr.Tid_subc; i < len; i++) {
|
||||
boolean arg_is_from = ctg_url.Grp_fwds()[i] == Bool_.N_byte;
|
||||
@@ -80,16 +80,16 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
if (found > 0 && found == load_max + 1) {
|
||||
Xowd_page_itm last_page = (Xowd_page_itm)List_adp_.Pop(list);
|
||||
Xoctg_page_xtn last_ctg = (Xoctg_page_xtn)last_page.Xtn();
|
||||
rv.Grp_by_tid(i).Itms_last_sortkey_(last_ctg.Sortkey());
|
||||
rv.Grp_by_tid(i).Itms__nth_sortkey_(last_ctg.Sortkey());
|
||||
}
|
||||
}
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_in__id(Cancelable_.Never, !app_is_cmd, list);
|
||||
}
|
||||
private void Load_ctg_v2a_ui_sift(Xoctg_view_ctg rv, Xowd_category_itm ctg, List_adp list) {
|
||||
private void Load_ctg_v2a_ui_sift(Xoctg_catpage_ctg rv, Xowd_category_itm ctg, List_adp list) {
|
||||
int len = list.Count();
|
||||
Xowe_wiki wiki = this.db_mgr.Wiki();
|
||||
byte prv_tid = Byte_.Max_value_127;
|
||||
Xoctg_view_grp view_grp = null;
|
||||
Xoctg_catpage_grp view_grp = null;
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xowd_page_itm db_page = (Xowd_page_itm)list.Get_at(i);
|
||||
if (db_page.Ns_id() == Int_.Min_value) continue; // HACK: page not found; ignore
|
||||
@@ -100,17 +100,10 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
prv_tid = cur_tid;
|
||||
}
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, db_page.Ns_id(), db_page.Ttl_page_db());
|
||||
Xoctg_view_itm view_itm = new Xoctg_view_itm();
|
||||
view_itm.Set__page(cur_tid, db_page.Id());
|
||||
view_itm.Set__ttl__sortkey(ttl, db_ctg.Sortkey());
|
||||
view_grp.Itms_add(view_itm);
|
||||
}
|
||||
len = Xoa_ctg_mgr.Tid__max;
|
||||
for (byte i = Xoa_ctg_mgr.Tid_subc; i < len; i++) {
|
||||
view_grp = rv.Grp_by_tid(i);
|
||||
view_grp.Itms_make();
|
||||
view_grp.Total_(ctg.Count_by_tid(i));
|
||||
Xoctg_catpage_itm view_itm = new Xoctg_catpage_itm(db_page.Id(), ttl, db_ctg.Sortkey());
|
||||
view_grp.Itms__add(view_itm);
|
||||
}
|
||||
rv.Make_itms();
|
||||
}
|
||||
public void Load_ttls_for_all_pages(Cancelable cancelable, List_adp rslt_list, Xowd_page_itm rslt_nxt, Xowd_page_itm rslt_prv, Int_obj_ref rslt_count, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item) {
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_for_special_all_pages(cancelable, rslt_list, rslt_nxt, rslt_prv, rslt_count, ns, key, max_results, min_page_len, browse_len, include_redirects, fetch_prv_item);
|
||||
@@ -152,7 +145,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
db_mgr.Core_data_mgr().Db__cat_core().Tbl__cat_core().Select_by_cat_id_in(Cancelable_.Never, hash2, 0, len);
|
||||
return (Xowd_page_itm[])hash.To_ary(Xowd_page_itm.class);
|
||||
}
|
||||
private static boolean Ctg_select_v1(Xowe_wiki wiki, Xow_db_mgr core_data_mgr, Xoctg_view_ctg view_ctg, int link_db_id, Xowd_category_itm ctg) {
|
||||
private static boolean Ctg_select_v1(Xowe_wiki wiki, Xow_db_mgr core_data_mgr, Xoctg_catpage_ctg view_ctg, int link_db_id, Xowd_category_itm ctg) {
|
||||
List_adp link_list = List_adp_.New();
|
||||
core_data_mgr.Dbs__get_by_id_or_fail(link_db_id).Tbl__cat_link().Select_in(link_list, ctg.Id());
|
||||
int link_list_len = link_list.Count();
|
||||
@@ -163,19 +156,20 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
for (int i = 0; i < link_list.Count(); i++) {
|
||||
Xowd_page_itm page = (Xowd_page_itm)link_list.Get_at(i);
|
||||
if (page.Ns_id() == Int_.Min_value) continue; // HACK: page not found; ignore
|
||||
byte ctg_tid = Xodb_load_mgr_txt.Load_ctg_v1_tid(page.Ns_id());
|
||||
Xoctg_view_grp ctg_grp = view_ctg.Grp_by_tid(ctg_tid);
|
||||
Xoctg_view_itm ctg_itm = new Xoctg_view_itm();
|
||||
ctg_itm.Set__page(ctg_tid, page.Id());
|
||||
ctg_itm.Set__ttl__sortkey(Xoa_ttl.Parse(wiki, page.Ns_id(), page.Ttl_page_db()), page.Ttl_page_db());
|
||||
ctg_grp.Itms_add(ctg_itm);
|
||||
byte ctg_tid = Load_ctg_v1_tid(page.Ns_id());
|
||||
Xoctg_catpage_grp ctg_grp = view_ctg.Grp_by_tid(ctg_tid);
|
||||
Xoctg_catpage_itm ctg_itm = new Xoctg_catpage_itm(page.Id(), Xoa_ttl.Parse(wiki, page.Ns_id(), page.Ttl_page_db()), page.Ttl_page_db());
|
||||
ctg_grp.Itms__add(ctg_itm);
|
||||
rv = true;
|
||||
}
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
Xoctg_view_grp ctg_grp = view_ctg.Grp_by_tid(i);
|
||||
ctg_grp.Itms_make();
|
||||
ctg_grp.Total_(ctg_grp.Itms().length);
|
||||
}
|
||||
view_ctg.Make_itms();
|
||||
return rv;
|
||||
}
|
||||
public static byte Load_ctg_v1_tid(int ns_id) {
|
||||
switch (ns_id) {
|
||||
case Xow_ns_.Tid__category: return Xoa_ctg_mgr.Tid_subc;
|
||||
case Xow_ns_.Tid__file: return Xoa_ctg_mgr.Tid_file;
|
||||
default: return Xoa_ctg_mgr.Tid_page;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ 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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.bldrs.*; import gplx.xowa.wikis.ctgs.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.nss.*;
|
||||
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*; import gplx.xowa.addons.wikis.ctgs.dbs.*;
|
||||
public class Xodb_load_mgr_sql_tst {
|
||||
@Before public void init() {if (Xoa_test_.Db_skip()) return; fxt.Clear();} private Xodb_load_mgr_sql_fxt fxt = new Xodb_load_mgr_sql_fxt();
|
||||
@After public void term() {if (Xoa_test_.Db_skip()) return; fxt.Rls();}
|
||||
@@ -31,9 +32,9 @@ public class Xodb_load_mgr_sql_tst {
|
||||
fxt.Test_load_ctg_list(ctgs);
|
||||
}
|
||||
}
|
||||
class Xoctg_url_mok extends Xoctg_url { public Xoctg_url_mok Page_bgn_(String v) {return Grp(Xoa_ctg_mgr.Tid_page, Bool_.Y, v);}
|
||||
public Xoctg_url_mok Page_end_(String v) {return Grp(Xoa_ctg_mgr.Tid_page, Bool_.N, v);}
|
||||
Xoctg_url_mok Grp(byte tid, boolean v, String bmk) {
|
||||
class Xoctg_catpage_url_mok extends Xoctg_catpage_url { public Xoctg_catpage_url_mok Page_bgn_(String v) {return Grp(Xoa_ctg_mgr.Tid_page, Bool_.Y, v);}
|
||||
public Xoctg_catpage_url_mok Page_end_(String v) {return Grp(Xoa_ctg_mgr.Tid_page, Bool_.N, v);}
|
||||
Xoctg_catpage_url_mok Grp(byte tid, boolean v, String bmk) {
|
||||
this.Grp_fwds()[tid] = v ? Bool_.Y_byte : Bool_.N_byte;
|
||||
this.Grp_idxs()[tid] = Bry_.new_a7(bmk);
|
||||
return this;
|
||||
@@ -61,7 +62,8 @@ class Xodb_load_mgr_sql_fxt {
|
||||
public void Init_save_ctgs(Xowd_page_itm[] ary) {
|
||||
int len = ary.length;
|
||||
Xodb_mgr_sql db_mgr = wiki.Db_mgr_as_sql();
|
||||
Xowd_cat_core_tbl cat_core_tbl = db_mgr.Core_data_mgr().Db__cat_core().Tbl__cat_core().Create_tbl();
|
||||
Xowd_cat_core_tbl cat_core_tbl = Xodb_cat_db_.Get_cat_core_or_fail(db_mgr.Core_data_mgr());
|
||||
cat_core_tbl.Create_tbl();
|
||||
DateAdp modified = Datetime_now.Get();
|
||||
Xowd_page_tbl tbl_page = wiki.Db_mgr_as_sql().Core_data_mgr().Tbl__page();
|
||||
tbl_page.Insert_bgn();
|
||||
@@ -96,25 +98,25 @@ class Xodb_load_mgr_sql_fxt {
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
public Xoctg_url_mok ctg_url_() {return new Xoctg_url_mok();}
|
||||
public Xoctg_catpage_url_mok ctg_url_() {return new Xoctg_catpage_url_mok();}
|
||||
public Xodb_load_mgr_sql_fxt Init_limit_(int v) {limit = v; return this;} private int limit = 3;
|
||||
public void Test_select(Xoctg_url ctg_url, Xoctg_mok_ctg expd) {
|
||||
Xoctg_view_ctg view_ctg = new Xoctg_view_ctg();
|
||||
public void Test_select(Xoctg_catpage_url ctg_url, Xoctg_mok_ctg expd) {
|
||||
Xoctg_catpage_ctg view_ctg = new Xoctg_catpage_ctg(expd.Ttl());
|
||||
wiki.Db_mgr_as_sql().Load_mgr().Load_ctg_v2a(view_ctg, ctg_url, expd.Ttl(), limit, false);
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
Xoctg_view_grp view_grp = view_ctg.Grp_by_tid(i);
|
||||
Xoctg_catpage_grp view_grp = view_ctg.Grp_by_tid(i);
|
||||
Xoctg_mok_grp mok_grp = expd.Grps_get_or_new(i);
|
||||
Tfds.Eq_ary_str(Xto_str(mok_grp), Xto_str(view_grp));
|
||||
Tfds.Eq(String_.new_a7(mok_grp.Last_plus_one_sortkey()), String_.new_a7(view_grp.Itms_last_sortkey()));
|
||||
Tfds.Eq(String_.new_a7(mok_grp.Last_plus_one_sortkey()), String_.new_a7(view_grp.Itms__nth_sortkey()));
|
||||
}
|
||||
}
|
||||
String[] Xto_str(Xoctg_view_grp grp) {
|
||||
Xoctg_view_itm[] ary = grp.Itms();
|
||||
String[] Xto_str(Xoctg_catpage_grp grp) {
|
||||
Xoctg_catpage_itm[] ary = grp.Itms();
|
||||
int len = ary.length;
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i< len; i++) {
|
||||
Xoctg_view_itm itm = ary[i];
|
||||
rv[i] = itm.Ttl().Page_db_as_str();
|
||||
Xoctg_catpage_itm itm = ary[i];
|
||||
rv[i] = itm.Page_ttl().Page_db_as_str();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.flds.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.bldrs.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*; import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.addons.wikis.searchs.specials.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*;
|
||||
public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
private final Xob_xdat_file tmp_xdat_file = new Xob_xdat_file(); private final Xob_xdat_itm tmp_xdat_itm = new Xob_xdat_itm();
|
||||
private final Xowd_page_itm tmp_page = new Xowd_page_itm();
|
||||
@@ -129,57 +130,6 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
// if (match.Itms_len() == max_results) break;
|
||||
}
|
||||
}
|
||||
public boolean Load_ctg_v2(Xoctg_data_ctg ctg, byte[] name) {
|
||||
boolean rv = Load_xdat_itm(tmp_xdat_itm, Xotdb_dir_info_.Tid_category2_link, name, true); if (!rv) return false;
|
||||
byte[] src = tmp_xdat_itm.Itm_bry();
|
||||
Load_ctg_v2_data(wiki.Appe().Usr_dlg(), wiki.Appe().Utl_fld_rdr(), ctg, name, src, tmp_ctg_grp_lens);
|
||||
Load_ctg_v2_main(ctg, name);
|
||||
return true;
|
||||
} int[] tmp_ctg_grp_lens = new int[3];
|
||||
private void Load_ctg_v2_data(Gfo_usr_dlg usr_dlg, Gfo_fld_rdr fld_rdr, Xoctg_data_ctg ctg, byte[] ctg_name, byte[] src, int[] tmp_grp_lens) { // Name|subc_len|file_len|page_len|subc_bfr|file_bfr|page_bfr
|
||||
fld_rdr.Data_(src); fld_rdr.Read_bry_escape(); // 1st field is name; skip;
|
||||
Load_ctg_v2_data_lens(fld_rdr, tmp_grp_lens);
|
||||
Load_ctg_v2_data_mgrs(usr_dlg, ctg_name, src, fld_rdr.Pos(), tmp_grp_lens, ctg.Grp_mgrs());
|
||||
}
|
||||
private void Load_ctg_v2_data_lens(Gfo_fld_rdr fld_rdr, int[] grp_lens) {
|
||||
for (int i = 0; i < 3; i++)
|
||||
grp_lens[i] = fld_rdr.Read_int_base85_len5();
|
||||
}
|
||||
private void Load_ctg_v2_data_mgrs(Gfo_usr_dlg usr_dlg, byte[] ctg_name, byte[] src, int bgn, int[] grp_lens, Xoctg_idx_mgr[] grp_mgrs) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int grp_len = grp_lens[i]; if (grp_len == 0) continue;
|
||||
int end = bgn + grp_len;
|
||||
Xoctg_idx_mgr grp_mgr = new Xoctg_idx_mgr();
|
||||
byte[] grp_src = Bry_.Mid(src, bgn, end);
|
||||
grp_mgr.Src_(grp_src);
|
||||
grp_mgr.Index(usr_dlg, ctg_name, grp_src);
|
||||
grp_mgrs[i] = grp_mgr;
|
||||
bgn = end;
|
||||
}
|
||||
}
|
||||
private void Load_ctg_v2_main(Xoctg_data_ctg rv, byte[] name) {
|
||||
if (!Load_xdat_itm(tmp_xdat_itm, Xotdb_dir_info_.Tid_category2_main, name, true)) return;
|
||||
if (tmp_xdat_itm.Missing()) return;
|
||||
byte[] bry = tmp_xdat_itm.Itm_bry();
|
||||
int bgn = name.length + 1;
|
||||
boolean hidden = bry[bgn] == Byte_ascii.Ltr_y;
|
||||
int count_subcs = Base85_.To_int_by_bry(bry, bgn + 2, bgn + 6);
|
||||
int count_files = Base85_.To_int_by_bry(bry, bgn + 8, bgn + 12);
|
||||
int count_pages = Base85_.To_int_by_bry(bry, bgn + 14, bgn + 18);
|
||||
rv.Hidden_(hidden);
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
Xoctg_idx_mgr idx_mgr = rv.Grp_by_tid(i);
|
||||
if (idx_mgr == null) continue;
|
||||
int count = 0;
|
||||
switch (i) {
|
||||
case Xoa_ctg_mgr.Tid_subc: count = count_subcs; break;
|
||||
case Xoa_ctg_mgr.Tid_file: count = count_files; break;
|
||||
case Xoa_ctg_mgr.Tid_page: count = count_pages; break;
|
||||
default: throw Err_.new_unhandled(i);
|
||||
}
|
||||
idx_mgr.Total_(count);
|
||||
}
|
||||
}
|
||||
public boolean Load_by_id(Xowd_page_itm page, int id) {Base85_.Set_bry(id, tmp_id_bry, 0, 5); return Load_by_id(page, tmp_id_bry);} private byte[] tmp_id_bry = new byte[5];
|
||||
boolean Load_by_id(Xowd_page_itm page, byte[] id_bry) {
|
||||
if (!Load_xdat_itm(tmp_xdat_itm, Xotdb_dir_info_.Tid_id, id_bry, true)) return false;;
|
||||
@@ -286,8 +236,8 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
count.Val_(tmp_count);
|
||||
return rv;
|
||||
}
|
||||
public boolean Load_ctg_v1(Xoctg_view_ctg view_ctg, byte[] ctg_ttl) {return Load_ctg_v1_wkr(view_ctg, ctg_ttl, null);}
|
||||
private boolean Load_ctg_v1_wkr(Xoctg_view_ctg view_ctg, byte[] ctg_ttl, Int_obj_ref count_only) {
|
||||
public boolean Load_ctg_v1(Xoctg_catpage_ctg view_ctg, byte[] ctg_ttl) {return Load_ctg_v1_wkr(view_ctg, ctg_ttl, null);}
|
||||
private boolean Load_ctg_v1_wkr(Xoctg_catpage_ctg view_ctg, byte[] ctg_ttl, Int_obj_ref count_only) {
|
||||
Xowd_regy_mgr ctg_regy = Get_regy_by_site(Xotdb_dir_info_.Tid_category);
|
||||
int fil_idx = ctg_regy.Files_find(ctg_ttl);
|
||||
if (fil_idx == Xowd_regy_mgr.Regy_null) return false; // NOTE: must check for -1, not 0; else defect in which entries in file 0 are ignored; DATE:2013-04-11
|
||||
@@ -308,17 +258,11 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
}
|
||||
for (int i = 0; i < ctgs_len; i++) {
|
||||
Xowd_page_itm itm = (Xowd_page_itm)ctgs.Get_at(i);
|
||||
byte itm_tid = Load_ctg_v1_tid(itm.Ns_id());
|
||||
Xoctg_view_itm sub = new Xoctg_view_itm();
|
||||
sub.Set__page(itm_tid, itm.Id());
|
||||
sub.Set__ttl__sortkey(Xoa_ttl.Parse(wiki, itm.Ns_id(), itm.Ttl_page_db()), itm.Ttl_page_db());
|
||||
view_ctg.Grp_by_tid(itm_tid).Itms_add(sub);
|
||||
}
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
Xoctg_view_grp grp = view_ctg.Grp_by_tid(i);
|
||||
grp.Itms_make();
|
||||
grp.Total_(grp.Itms().length);
|
||||
byte itm_tid = Xodb_load_mgr_sql.Load_ctg_v1_tid(itm.Ns_id());
|
||||
Xoctg_catpage_itm sub = new Xoctg_catpage_itm(itm.Id(), Xoa_ttl.Parse(wiki, itm.Ns_id(), itm.Ttl_page_db()), itm.Ttl_page_db());
|
||||
view_ctg.Grp_by_tid(itm_tid).Itms__add(sub);
|
||||
}
|
||||
view_ctg.Make_itms();
|
||||
return true;
|
||||
}
|
||||
private static void Load_ctg_v1_parse(List_adp rv, Gfo_usr_dlg usr_dlg, byte[] ary) {
|
||||
@@ -345,13 +289,6 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static byte Load_ctg_v1_tid(int ns_id) {
|
||||
switch (ns_id) {
|
||||
case Xow_ns_.Tid__category: return Xoa_ctg_mgr.Tid_subc;
|
||||
case Xow_ns_.Tid__file: return Xoa_ctg_mgr.Tid_file;
|
||||
default: return Xoa_ctg_mgr.Tid_page;
|
||||
}
|
||||
}
|
||||
public static boolean Load_page_or_false(Xowd_page_itm page, Xob_xdat_itm xdat, int ns_id) {
|
||||
byte[] src = xdat.Src(); int itm_end = xdat.Itm_end();
|
||||
int bgn = xdat.Itm_bgn();
|
||||
@@ -502,18 +439,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
Xob_xdat_itm pid_itm = Load_xdat_itm_by_dir(pids_root.GenSubDir(String_.new_u8(lang_key)), pid_name); if (pid_itm == null) return gplx.xowa.xtns.wbases.Wdata_wiki_mgr.Pid_null;
|
||||
return Bry_.To_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wbases.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
} Io_url pids_root;
|
||||
public int Load_ctg_count(byte[] ttl) {return wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_1 ? Load_ctg_count_v1(ttl) : Load_ctg_count_v2(ttl);}
|
||||
int Load_ctg_count_v1(byte[] ttl) {
|
||||
Xoctg_view_ctg view_ctg = new Xoctg_view_ctg();
|
||||
Int_obj_ref count = Int_obj_ref.New_zero();
|
||||
Load_ctg_v1_wkr(view_ctg, ttl, count);
|
||||
return count.Val();
|
||||
}
|
||||
int Load_ctg_count_v2(byte[] ttl) {
|
||||
Xoctg_data_ctg data_ctg = new Xoctg_data_ctg(ttl);
|
||||
Load_ctg_v2(data_ctg, ttl);
|
||||
return data_ctg.Total_count();
|
||||
}
|
||||
public int Load_ctg_count(byte[] ttl) {throw Err_.new_deprecated("XOWA no longer supports categories for text databases");}
|
||||
Xob_xdat_itm Load_xdat_itm_by_dir(Io_url dir, byte[] ttl) {
|
||||
Xoa_hive_mgr hive_mgr = wiki.Appe().Hive_mgr();
|
||||
int fil_idx = hive_mgr.Find_fil(dir, ttl); if (fil_idx == Xowd_regy_mgr.Regy_null) return null; // sub_dir not found; EX: commonswiki if qid; fr if pid;
|
||||
@@ -521,36 +447,8 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
rdr.Find(tmp_xdat_itm, ttl, 0, Byte_ascii.Pipe, true);
|
||||
return tmp_xdat_itm.Found_exact() ? tmp_xdat_itm : null;
|
||||
}
|
||||
public void Load_ctg_v2a(Xoctg_view_ctg rv, Xoctg_url url_ctg, byte[] ttl_bry, int limit, boolean app_is_cmd) {
|
||||
Xoctg_html_mgr ctg_mgr = wiki.Html_mgr().Ns_ctg();
|
||||
Xoctg_data_cache data_cache = ctg_mgr.Data_cache();
|
||||
Xoctg_data_ctg data_ctg = data_cache.Get_or_null(ttl_bry);
|
||||
if (data_ctg == null) {
|
||||
data_ctg = data_cache.Load_or_null(wiki, ttl_bry);
|
||||
if (data_ctg == null) return;
|
||||
}
|
||||
rv.Fill(url_ctg, data_ctg);
|
||||
ctg_mgr.Get_titles(wiki.Appe().Usr_dlg(), wiki, rv);
|
||||
rv.Num_(data_ctg);
|
||||
}
|
||||
public Xowd_page_itm[] Load_ctg_list(byte[][] ttls) {
|
||||
int len = ttls.length;
|
||||
Xowd_page_itm[] rv = new Xowd_page_itm[len];
|
||||
Xow_ns ns = wiki.Ns_mgr().Ns_category();
|
||||
|
||||
Xoctg_data_ctg ctg_temp = new Xoctg_data_ctg(Bry_.Empty);
|
||||
for (int i = 0; i < len; i++) {
|
||||
byte[] ttl = Xoa_ttl.Replace_spaces(ttls[i]); // NOTE: ctg_ttls has spaces since v1 rendered it literally;
|
||||
Xowd_page_itm page = new Xowd_page_itm();
|
||||
this.Load_by_ttl(page, ns, ttl);
|
||||
|
||||
Load_ctg_v2_main(ctg_temp, page.Ttl_page_db());
|
||||
Xowd_category_itm ctg_itm = Xowd_category_itm.load_(page.Id(), page.Text_db_id(), ctg_temp.Hidden(), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_subc), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_file), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_page));
|
||||
page.Xtn_(ctg_itm);
|
||||
rv[i] = page;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Load_ctg_v2a(Xoctg_catpage_ctg rv, Xoctg_catpage_url url_ctg, byte[] ttl_bry, int limit, boolean app_is_cmd) {throw Err_.new_deprecated("XOWA no longer supports categories for text databases");}
|
||||
public Xowd_page_itm[] Load_ctg_list(byte[][] ttls) {throw Err_.new_deprecated("XOWA no longer supports categories for text databases");}
|
||||
public Xodb_page_rdr Get_page_rdr(Xowe_wiki wiki) {return new Xodb_page_rdr__tdb(wiki);}
|
||||
static final String GRP_KEY = "xowa.wiki.db.load";
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.engines.sqlite.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xodb_mgr_sql implements Xodb_mgr, Gfo_invk {
|
||||
public Xodb_mgr_sql(Xowe_wiki wiki) {
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.htmls.core.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.addons.wikis.ctgs.*; import gplx.xowa.htmls.core.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xodb_mgr_txt implements Xodb_mgr {
|
||||
public Xodb_mgr_txt(Xowe_wiki wiki, Xow_page_mgr data_mgr) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
}
|
||||
public void Data_update(Xoae_page page, byte[] text) {Data_update_under(page, text, null);}
|
||||
public void Data_rename(Xoae_page page, int trg_ns, byte[] trg_ttl) {
|
||||
if (wiki.Domain_tid() != Xow_domain_tid_.Int__home) {
|
||||
if (wiki.Domain_tid() != Xow_domain_tid_.Tid__home) {
|
||||
wiki.Appe().Usr_dlg().Warn_many("", "", "Only pages in the home wiki can be renamed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,22 +50,22 @@ public class Xow_abrv_wm_ {
|
||||
domain_type = ((Int_obj_ref)o).Val();
|
||||
}
|
||||
switch (domain_type) {
|
||||
case Xow_domain_tid_.Int__wmfblog: return Xow_domain_itm_.Bry__wmforg;
|
||||
case Xow_domain_tid_.Int__wikidata: return Xow_domain_itm_.Bry__wikidata;
|
||||
case Xow_domain_tid_.Int__mediawiki: return Xow_domain_itm_.Bry__mediawiki;
|
||||
case Xow_domain_tid_.Int__commons: return Xow_domain_itm_.Bry__commons;
|
||||
case Xow_domain_tid_.Int__species: return Xow_domain_itm_.Bry__species;
|
||||
case Xow_domain_tid_.Int__meta: return Xow_domain_itm_.Bry__meta;
|
||||
case Xow_domain_tid_.Int__incubator: return Xow_domain_itm_.Bry__incubator;
|
||||
case Xow_domain_tid_.Int__wikipedia:
|
||||
case Xow_domain_tid_.Int__wiktionary:
|
||||
case Xow_domain_tid_.Int__wikisource:
|
||||
case Xow_domain_tid_.Int__wikibooks:
|
||||
case Xow_domain_tid_.Int__wikiversity:
|
||||
case Xow_domain_tid_.Int__wikiquote:
|
||||
case Xow_domain_tid_.Int__wikinews:
|
||||
case Xow_domain_tid_.Int__wikivoyage:
|
||||
case Xow_domain_tid_.Int__wikimedia:
|
||||
case Xow_domain_tid_.Tid__wmfblog: return Xow_domain_itm_.Bry__wmforg;
|
||||
case Xow_domain_tid_.Tid__wikidata: return Xow_domain_itm_.Bry__wikidata;
|
||||
case Xow_domain_tid_.Tid__mediawiki: return Xow_domain_itm_.Bry__mediawiki;
|
||||
case Xow_domain_tid_.Tid__commons: return Xow_domain_itm_.Bry__commons;
|
||||
case Xow_domain_tid_.Tid__species: return Xow_domain_itm_.Bry__species;
|
||||
case Xow_domain_tid_.Tid__meta: return Xow_domain_itm_.Bry__meta;
|
||||
case Xow_domain_tid_.Tid__incubator: return Xow_domain_itm_.Bry__incubator;
|
||||
case Xow_domain_tid_.Tid__wikipedia:
|
||||
case Xow_domain_tid_.Tid__wiktionary:
|
||||
case Xow_domain_tid_.Tid__wikisource:
|
||||
case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity:
|
||||
case Xow_domain_tid_.Tid__wikiquote:
|
||||
case Xow_domain_tid_.Tid__wikinews:
|
||||
case Xow_domain_tid_.Tid__wikivoyage:
|
||||
case Xow_domain_tid_.Tid__wikimedia:
|
||||
if (lang == null) {
|
||||
lang = Bry_.Mid(src, 0, trv.Pos() + 1); // en
|
||||
if (Bry_.Has(lang, Byte_ascii.Underline)) // convert "_" to "-"; note that wmf_keys have a strict format of langtype; EX: "zh_yuewiki"; DATE:2014-10-06
|
||||
@@ -84,14 +84,14 @@ public class Xow_abrv_wm_ {
|
||||
public static void To_abrv(Bry_bfr bfr, byte[] lang_key, Int_obj_ref domain_type) {
|
||||
byte[] suffix_bry = (byte[])int_hash.Get_by(domain_type); if (suffix_bry == null) return;
|
||||
switch (domain_type.Val()) {
|
||||
case Xow_domain_tid_.Int__commons:
|
||||
case Xow_domain_tid_.Int__species:
|
||||
case Xow_domain_tid_.Int__meta:
|
||||
case Xow_domain_tid_.Int__incubator:
|
||||
case Xow_domain_tid_.Int__wikidata:
|
||||
case Xow_domain_tid_.Int__mediawiki:
|
||||
case Xow_domain_tid_.Int__wmfblog: bfr.Add(suffix_bry); break;
|
||||
case Xow_domain_tid_.Int__other: break;
|
||||
case Xow_domain_tid_.Tid__commons:
|
||||
case Xow_domain_tid_.Tid__species:
|
||||
case Xow_domain_tid_.Tid__meta:
|
||||
case Xow_domain_tid_.Tid__incubator:
|
||||
case Xow_domain_tid_.Tid__wikidata:
|
||||
case Xow_domain_tid_.Tid__mediawiki:
|
||||
case Xow_domain_tid_.Tid__wmfblog: bfr.Add(suffix_bry); break;
|
||||
case Xow_domain_tid_.Tid__other: break;
|
||||
default: bfr.Add(lang_key).Add(suffix_bry); break;
|
||||
}
|
||||
}
|
||||
@@ -99,22 +99,22 @@ public class Xow_abrv_wm_ {
|
||||
int tid = domain_itm.Domain_type_id();
|
||||
byte[] suffix = (byte[])int_hash.Get_by(Int_obj_ref.New(tid)); if (suffix == null) return null;
|
||||
switch (tid) {
|
||||
case Xow_domain_tid_.Int__commons:
|
||||
case Xow_domain_tid_.Int__species:
|
||||
case Xow_domain_tid_.Int__meta:
|
||||
case Xow_domain_tid_.Int__incubator:
|
||||
case Xow_domain_tid_.Int__wikidata:
|
||||
case Xow_domain_tid_.Int__mediawiki:
|
||||
case Xow_domain_tid_.Int__wmfblog: return suffix;
|
||||
case Xow_domain_tid_.Int__wikipedia:
|
||||
case Xow_domain_tid_.Int__wiktionary:
|
||||
case Xow_domain_tid_.Int__wikisource:
|
||||
case Xow_domain_tid_.Int__wikibooks:
|
||||
case Xow_domain_tid_.Int__wikiversity:
|
||||
case Xow_domain_tid_.Int__wikiquote:
|
||||
case Xow_domain_tid_.Int__wikinews:
|
||||
case Xow_domain_tid_.Int__wikivoyage:
|
||||
case Xow_domain_tid_.Int__wikimedia: return Bry_.Add(domain_itm.Lang_orig_key(), suffix);
|
||||
case Xow_domain_tid_.Tid__commons:
|
||||
case Xow_domain_tid_.Tid__species:
|
||||
case Xow_domain_tid_.Tid__meta:
|
||||
case Xow_domain_tid_.Tid__incubator:
|
||||
case Xow_domain_tid_.Tid__wikidata:
|
||||
case Xow_domain_tid_.Tid__mediawiki:
|
||||
case Xow_domain_tid_.Tid__wmfblog: return suffix;
|
||||
case Xow_domain_tid_.Tid__wikipedia:
|
||||
case Xow_domain_tid_.Tid__wiktionary:
|
||||
case Xow_domain_tid_.Tid__wikisource:
|
||||
case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity:
|
||||
case Xow_domain_tid_.Tid__wikiquote:
|
||||
case Xow_domain_tid_.Tid__wikinews:
|
||||
case Xow_domain_tid_.Tid__wikivoyage:
|
||||
case Xow_domain_tid_.Tid__wikimedia: return Bry_.Add(domain_itm.Lang_orig_key(), suffix);
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
}
|
||||
@@ -123,22 +123,22 @@ public class Xow_abrv_wm_ {
|
||||
private static Btrie_bwd_mgr Init_trie() {
|
||||
int_hash = Hash_adp_.New();
|
||||
Btrie_bwd_mgr rv = new Btrie_bwd_mgr(false);
|
||||
Init_trie_itm(rv, int_hash, "wiki" , Xow_domain_tid_.Int__wikipedia);
|
||||
Init_trie_itm(rv, int_hash, "wiktionary" , Xow_domain_tid_.Int__wiktionary);
|
||||
Init_trie_itm(rv, int_hash, "wikisource" , Xow_domain_tid_.Int__wikisource);
|
||||
Init_trie_itm(rv, int_hash, "wikibooks" , Xow_domain_tid_.Int__wikibooks);
|
||||
Init_trie_itm(rv, int_hash, "wikiversity" , Xow_domain_tid_.Int__wikiversity);
|
||||
Init_trie_itm(rv, int_hash, "wikiquote" , Xow_domain_tid_.Int__wikiquote);
|
||||
Init_trie_itm(rv, int_hash, "wikinews" , Xow_domain_tid_.Int__wikinews);
|
||||
Init_trie_itm(rv, int_hash, "wikivoyage" , Xow_domain_tid_.Int__wikivoyage);
|
||||
Init_trie_itm(rv, int_hash, "wikimedia" , Xow_domain_tid_.Int__wikimedia);
|
||||
Init_trie_itm(rv, int_hash, "commonswiki" , Xow_domain_tid_.Int__commons);
|
||||
Init_trie_itm(rv, int_hash, "specieswiki" , Xow_domain_tid_.Int__species);
|
||||
Init_trie_itm(rv, int_hash, "metawiki" , Xow_domain_tid_.Int__meta);
|
||||
Init_trie_itm(rv, int_hash, "incubatorwiki" , Xow_domain_tid_.Int__incubator);
|
||||
Init_trie_itm(rv, int_hash, "wikidatawiki" , Xow_domain_tid_.Int__wikidata);
|
||||
Init_trie_itm(rv, int_hash, "mediawikiwiki" , Xow_domain_tid_.Int__mediawiki);
|
||||
Init_trie_itm(rv, int_hash, "foundationwiki" , Xow_domain_tid_.Int__wmfblog);
|
||||
Init_trie_itm(rv, int_hash, "wiki" , Xow_domain_tid_.Tid__wikipedia);
|
||||
Init_trie_itm(rv, int_hash, "wiktionary" , Xow_domain_tid_.Tid__wiktionary);
|
||||
Init_trie_itm(rv, int_hash, "wikisource" , Xow_domain_tid_.Tid__wikisource);
|
||||
Init_trie_itm(rv, int_hash, "wikibooks" , Xow_domain_tid_.Tid__wikibooks);
|
||||
Init_trie_itm(rv, int_hash, "wikiversity" , Xow_domain_tid_.Tid__wikiversity);
|
||||
Init_trie_itm(rv, int_hash, "wikiquote" , Xow_domain_tid_.Tid__wikiquote);
|
||||
Init_trie_itm(rv, int_hash, "wikinews" , Xow_domain_tid_.Tid__wikinews);
|
||||
Init_trie_itm(rv, int_hash, "wikivoyage" , Xow_domain_tid_.Tid__wikivoyage);
|
||||
Init_trie_itm(rv, int_hash, "wikimedia" , Xow_domain_tid_.Tid__wikimedia);
|
||||
Init_trie_itm(rv, int_hash, "commonswiki" , Xow_domain_tid_.Tid__commons);
|
||||
Init_trie_itm(rv, int_hash, "specieswiki" , Xow_domain_tid_.Tid__species);
|
||||
Init_trie_itm(rv, int_hash, "metawiki" , Xow_domain_tid_.Tid__meta);
|
||||
Init_trie_itm(rv, int_hash, "incubatorwiki" , Xow_domain_tid_.Tid__incubator);
|
||||
Init_trie_itm(rv, int_hash, "wikidatawiki" , Xow_domain_tid_.Tid__wikidata);
|
||||
Init_trie_itm(rv, int_hash, "mediawikiwiki" , Xow_domain_tid_.Tid__mediawiki);
|
||||
Init_trie_itm(rv, int_hash, "foundationwiki" , Xow_domain_tid_.Tid__wmfblog);
|
||||
return rv;
|
||||
}
|
||||
private static void Init_trie_itm(Btrie_bwd_mgr trie, Hash_adp hash, String str, int tid) {
|
||||
@@ -161,13 +161,13 @@ class Xow_abrv_wm_override {
|
||||
private static Hash_adp_bry itm_hash__make() {
|
||||
Hash_adp_bry rv = Hash_adp_bry.cs();
|
||||
lang_hash = Hash_adp_bry.cs();
|
||||
itm_hash__add(rv, lang_hash, "ar.wikimedia.org", "arwikimedia", "ar", Xol_lang_stub_.Id_es, Xow_domain_tid_.Int__wikimedia); // NOTE: ar means Argentina not Arabic
|
||||
itm_hash__add(rv, lang_hash, "br.wikimedia.org", "brwikimedia", "br", Xol_lang_stub_.Id_es, Xow_domain_tid_.Int__wikimedia); // NOTE: br means Brazil not Breto
|
||||
itm_hash__add(rv, lang_hash, "co.wikimedia.org", "cowikimedia", "co", Xol_lang_stub_.Id_es, Xow_domain_tid_.Int__wikimedia); // NOTE: co means Columbia not Corsican
|
||||
itm_hash__add(rv, lang_hash, "ua.wikimedia.org", "ukwikimedia", "ua", Xol_lang_stub_.Id_uk, Xow_domain_tid_.Int__wikimedia); // NOTE: ua means Ukrainian; NOTE: uk does not means United Kingdom (which redirects to https://wikimedia.org.uk)
|
||||
itm_hash__add(rv, lang_hash, "ca.wikimedia.org", "cawikimedia", "ca", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikimedia); // NOTE: ca means Canada not Catalan
|
||||
itm_hash__add(rv, lang_hash, "be.wikimedia.org", "bewikimedia", "be", Xol_lang_stub_.Id_en, Xow_domain_tid_.Int__wikimedia); // NOTE: be means Belgium not Belarusian
|
||||
itm_hash__add(rv, lang_hash, "se.wikimedia.org", "sewikimedia", "se", Xol_lang_stub_.Id_sv, Xow_domain_tid_.Int__wikimedia); // NOTE: se means Swedish not Northern Sami
|
||||
itm_hash__add(rv, lang_hash, "ar.wikimedia.org", "arwikimedia", "ar", Xol_lang_stub_.Id_es, Xow_domain_tid_.Tid__wikimedia); // NOTE: ar means Argentina not Arabic
|
||||
itm_hash__add(rv, lang_hash, "br.wikimedia.org", "brwikimedia", "br", Xol_lang_stub_.Id_es, Xow_domain_tid_.Tid__wikimedia); // NOTE: br means Brazil not Breto
|
||||
itm_hash__add(rv, lang_hash, "co.wikimedia.org", "cowikimedia", "co", Xol_lang_stub_.Id_es, Xow_domain_tid_.Tid__wikimedia); // NOTE: co means Columbia not Corsican
|
||||
itm_hash__add(rv, lang_hash, "ua.wikimedia.org", "ukwikimedia", "ua", Xol_lang_stub_.Id_uk, Xow_domain_tid_.Tid__wikimedia); // NOTE: ua means Ukrainian; NOTE: uk does not means United Kingdom (which redirects to https://wikimedia.org.uk)
|
||||
itm_hash__add(rv, lang_hash, "ca.wikimedia.org", "cawikimedia", "ca", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikimedia); // NOTE: ca means Canada not Catalan
|
||||
itm_hash__add(rv, lang_hash, "be.wikimedia.org", "bewikimedia", "be", Xol_lang_stub_.Id_en, Xow_domain_tid_.Tid__wikimedia); // NOTE: be means Belgium not Belarusian
|
||||
itm_hash__add(rv, lang_hash, "se.wikimedia.org", "sewikimedia", "se", Xol_lang_stub_.Id_sv, Xow_domain_tid_.Tid__wikimedia); // NOTE: se means Swedish not Northern Sami
|
||||
return rv;
|
||||
}
|
||||
private static void itm_hash__add(Hash_adp_bry hash, Hash_adp_bry lang_hash, String domain, String raw, String lang_domain, int lang_actl, int domain_type) {
|
||||
|
||||
@@ -20,28 +20,28 @@ import org.junit.*; import gplx.xowa.langs.*;
|
||||
public class Xow_abrv_wm_tst {
|
||||
private Xow_abrv_wm_fxt fxt = new Xow_abrv_wm_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Test_parse("foundationwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__wmfblog);
|
||||
fxt.Test_parse("wikidatawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__wikidata);
|
||||
fxt.Test_parse("mediawikiwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__mediawiki);
|
||||
fxt.Test_parse("commonswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__commons);
|
||||
fxt.Test_parse("specieswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__species);
|
||||
fxt.Test_parse("metawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__meta);
|
||||
fxt.Test_parse("incubatorwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Int__incubator);
|
||||
fxt.Test_parse("enwiki" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikipedia);
|
||||
fxt.Test_parse("enwiktionary" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wiktionary);
|
||||
fxt.Test_parse("enwikisource" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikisource);
|
||||
fxt.Test_parse("enwikibooks" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikibooks);
|
||||
fxt.Test_parse("enwikiversity" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikiversity);
|
||||
fxt.Test_parse("enwikiquote" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikiquote);
|
||||
fxt.Test_parse("enwikinews" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikinews);
|
||||
fxt.Test_parse("enwikivoyage" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Int__wikivoyage);
|
||||
fxt.Test_parse("frwiki" , Xol_lang_stub_.Id_fr , Xow_domain_tid_.Int__wikipedia);
|
||||
fxt.Test_parse("foundationwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wmfblog);
|
||||
fxt.Test_parse("wikidatawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__wikidata);
|
||||
fxt.Test_parse("mediawikiwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__mediawiki);
|
||||
fxt.Test_parse("commonswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__commons);
|
||||
fxt.Test_parse("specieswiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__species);
|
||||
fxt.Test_parse("metawiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__meta);
|
||||
fxt.Test_parse("incubatorwiki" , Xol_lang_stub_.Id__intl , Xow_domain_tid_.Tid__incubator);
|
||||
fxt.Test_parse("enwiki" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Test_parse("enwiktionary" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wiktionary);
|
||||
fxt.Test_parse("enwikisource" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikisource);
|
||||
fxt.Test_parse("enwikibooks" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikibooks);
|
||||
fxt.Test_parse("enwikiversity" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiversity);
|
||||
fxt.Test_parse("enwikiquote" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikiquote);
|
||||
fxt.Test_parse("enwikinews" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikinews);
|
||||
fxt.Test_parse("enwikivoyage" , Xol_lang_stub_.Id_en , Xow_domain_tid_.Tid__wikivoyage);
|
||||
fxt.Test_parse("frwiki" , Xol_lang_stub_.Id_fr , Xow_domain_tid_.Tid__wikipedia);
|
||||
fxt.Test_parse_null("unknown");
|
||||
fxt.Test_parse("plwikimedia" , Xol_lang_stub_.Id_pl , Xow_domain_tid_.Int__wikimedia);
|
||||
fxt.Test_parse("plwikimedia" , Xol_lang_stub_.Id_pl , Xow_domain_tid_.Tid__wikimedia);
|
||||
}
|
||||
@Test public void Parse_override() {
|
||||
fxt.Test_parse("arwikimedia" , Xol_lang_stub_.Id_es , Xow_domain_tid_.Int__wikimedia);
|
||||
fxt.Test_parse("ukwikimedia" , Xol_lang_stub_.Id_uk , Xow_domain_tid_.Int__wikimedia);
|
||||
fxt.Test_parse("arwikimedia" , Xol_lang_stub_.Id_es , Xow_domain_tid_.Tid__wikimedia);
|
||||
fxt.Test_parse("ukwikimedia" , Xol_lang_stub_.Id_uk , Xow_domain_tid_.Tid__wikimedia);
|
||||
}
|
||||
@Test public void To_domain_itm() {
|
||||
fxt.Test_to_domain_itm("enwiki" , "en" , "en.wikipedia.org");
|
||||
@@ -59,7 +59,7 @@ public class Xow_abrv_wm_tst {
|
||||
fxt.Test_to_abrv("commons.wikimedia.org" , "commonswiki");
|
||||
}
|
||||
@Test public void To_abrv_by_lang() {
|
||||
fxt.Test_to_abrv_by_lang("en", Xow_domain_tid_.Int__wikipedia, "enwiki");
|
||||
fxt.Test_to_abrv_by_lang("en", Xow_domain_tid_.Tid__wikipedia, "enwiki");
|
||||
}
|
||||
}
|
||||
class Xow_abrv_wm_fxt {
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_itm_ {
|
||||
public static final Xow_domain_itm[] Ary_empty = new Xow_domain_itm[0];
|
||||
public static final Xow_domain_itm[] Ary_empty = new Xow_domain_itm[0];
|
||||
public static Xow_domain_itm parse(byte[] raw) {
|
||||
/*
|
||||
~{type}.org EX: wikimediafoundation
|
||||
@@ -37,43 +37,43 @@ public class Xow_domain_itm_ {
|
||||
int dot_1 = Bry_find_.Find_fwd(raw, Byte_ascii.Dot, dot_0 + 1, raw_len);
|
||||
if (dot_1 == Bry_find_.Not_found) { // 1 dot; check for "wikimediafoundation.org"
|
||||
return Bry_.Match(raw, 0, dot_0, Xow_domain_tid_.Bry__wmforg)
|
||||
? Xow_domain_itm.new_(raw, Xow_domain_tid_.Int__wmfblog, Xol_lang_stub_.Key__unknown)
|
||||
? Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__wmfblog, Xol_lang_stub_.Key__unknown)
|
||||
: new_other(raw);
|
||||
}
|
||||
// 2 dots
|
||||
int seg_1_tid = Xow_domain_tid_.Get_type_as_tid(raw, dot_0 + 1, dot_1); // parse middle; EX: ".wikipedia."
|
||||
if (seg_1_tid == Xow_domain_tid_.Int__null) return new_other(raw); // seg_1 is unknown; return other;
|
||||
if (seg_1_tid == Xow_domain_tid_.Tid__null) return new_other(raw); // seg_1 is unknown; return other;
|
||||
switch (seg_1_tid) {
|
||||
case Xow_domain_tid_.Int__wikipedia: case Xow_domain_tid_.Int__wiktionary: case Xow_domain_tid_.Int__wikisource: case Xow_domain_tid_.Int__wikibooks:
|
||||
case Xow_domain_tid_.Int__wikiversity: case Xow_domain_tid_.Int__wikiquote: case Xow_domain_tid_.Int__wikinews: case Xow_domain_tid_.Int__wikivoyage: // ~{lang}.~{type}.org
|
||||
case Xow_domain_tid_.Tid__wikipedia: case Xow_domain_tid_.Tid__wiktionary: case Xow_domain_tid_.Tid__wikisource: case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity: case Xow_domain_tid_.Tid__wikiquote: case Xow_domain_tid_.Tid__wikinews: case Xow_domain_tid_.Tid__wikivoyage: // ~{lang}.~{type}.org
|
||||
byte[] lang_orig = Bry_.Mid(raw, 0, dot_0);
|
||||
byte[] lang_actl = Get_lang_code_for_mw_messages_file(lang_orig);
|
||||
return Xow_domain_itm.new_(raw, seg_1_tid, lang_actl, lang_orig); // NOTE: seg_tids must match wiki_tids
|
||||
case Xow_domain_tid_.Int__wikidata: case Xow_domain_tid_.Int__mediawiki:// ~www.~{type}.org
|
||||
case Xow_domain_tid_.Tid__wikidata: case Xow_domain_tid_.Tid__mediawiki:// ~www.~{type}.org
|
||||
return Xow_domain_itm.new_(raw, seg_1_tid, Xol_lang_stub_.Key__unknown);
|
||||
case Xow_domain_tid_.Int__wikimedia: // ~{type}.wikimedia.org;
|
||||
case Xow_domain_tid_.Tid__wikimedia: // ~{type}.wikimedia.org;
|
||||
int seg_0_tid = Xow_domain_tid_.Get_type_as_tid(raw, 0, dot_0); // try to get "incubator", "meta", etc..
|
||||
if (seg_0_tid == Xow_domain_tid_.Int__null) { // not a known name; try language
|
||||
if (seg_0_tid == Xow_domain_tid_.Tid__null) { // not a known name; try language
|
||||
byte[] lang_override = Xow_abrv_wm_override.To_lang_key_or_null(raw); // handle "lang-like" wikimedia domains like "ar.wikimedia.org" which is actually to "Argentina Wikimedia"
|
||||
if (lang_override == null) {
|
||||
Xol_lang_stub wikimedia_lang = Xol_lang_stub_.Get_by_key_or_null(raw, 0, dot_0);
|
||||
return wikimedia_lang == null ? new_other(raw) : Xow_domain_itm.new_(raw, Xow_domain_tid_.Int__wikimedia, wikimedia_lang.Key());
|
||||
return wikimedia_lang == null ? new_other(raw) : Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__wikimedia, wikimedia_lang.Key());
|
||||
}
|
||||
else
|
||||
return Xow_domain_itm.new_(raw, Xow_domain_tid_.Int__wikimedia, lang_override, Bry_.Mid(raw, 0, dot_0));
|
||||
return Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__wikimedia, lang_override, Bry_.Mid(raw, 0, dot_0));
|
||||
}
|
||||
switch (seg_0_tid) {
|
||||
case Xow_domain_tid_.Int__commons: case Xow_domain_tid_.Int__species: case Xow_domain_tid_.Int__meta: case Xow_domain_tid_.Int__incubator:
|
||||
case Xow_domain_tid_.Tid__commons: case Xow_domain_tid_.Tid__species: case Xow_domain_tid_.Tid__meta: case Xow_domain_tid_.Tid__incubator:
|
||||
return Xow_domain_itm.new_(raw, seg_0_tid, Xol_lang_stub_.Key__unknown); // NOTE: seg_tids must match wiki_tids; NOTE: lang_key is "en" (really, "multi" but making things easier)
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
case Xow_domain_tid_.Int__other:
|
||||
case Xow_domain_tid_.Tid__other:
|
||||
default:
|
||||
return new_other(raw);
|
||||
}
|
||||
}
|
||||
private static Xow_domain_itm new_other(byte[] raw) {return Xow_domain_itm.new_(raw, Xow_domain_tid_.Int__other, Xol_lang_stub_.Key__unknown);}
|
||||
private static Xow_domain_itm new_other(byte[] raw) {return Xow_domain_itm.new_(raw, Xow_domain_tid_.Tid__other, Xol_lang_stub_.Key__unknown);}
|
||||
private static byte[] Get_lang_code_for_mw_messages_file(byte[] v) {
|
||||
Object o = alt_domain__lang_by_subdomain.Get_by_bry(v);
|
||||
return o == null ? v : (byte[])o;
|
||||
@@ -82,12 +82,12 @@ public class Xow_domain_itm_ {
|
||||
Object o = alt_domain__subdomain_by_lang.Get_by_bry(lang);
|
||||
return o == null ? lang : (byte[])o;
|
||||
}
|
||||
private static final Hash_adp_bry alt_domain__lang_by_subdomain = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
private static final Hash_adp_bry alt_domain__lang_by_subdomain = 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"))
|
||||
;
|
||||
private static final Hash_adp_bry alt_domain__subdomain_by_lang = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
private static final Hash_adp_bry alt_domain__subdomain_by_lang = Hash_adp_bry.ci_a7() // ASCII:lang_code
|
||||
.Add_str_obj("lzh" , Bry_.new_a7("zh-classical"))
|
||||
.Add_str_obj("nb" , Bry_.new_a7("no"))
|
||||
;
|
||||
@@ -102,7 +102,7 @@ public class Xow_domain_itm_ {
|
||||
, Str__wmforg = "wikimediafoundation.org"
|
||||
, Str__home = "home"
|
||||
;
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Bry__enwiki = Bry_.new_a7(Str__enwiki)
|
||||
, Bry__species = Bry_.new_a7(Str__species)
|
||||
, Bry__commons = Bry_.new_a7(Str__commons)
|
||||
@@ -114,5 +114,5 @@ public class Xow_domain_itm_ {
|
||||
, Bry__home = Bry_.new_a7(Str__home)
|
||||
, Bry__simplewiki = Bry_.new_a7("simple.wikipedia.org")
|
||||
;
|
||||
public static final byte[] Seg__org = Bry_.new_a7("org"), Seg__www = Bry_.new_a7("www");
|
||||
public static final byte[] Seg__org = Bry_.new_a7("org"), Seg__www = Bry_.new_a7("www");
|
||||
}
|
||||
|
||||
@@ -18,19 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_itm_tst {
|
||||
private final Xow_domain_fxt fxt = new Xow_domain_fxt();
|
||||
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , "en" , Xow_domain_tid_.Int__wikipedia);}
|
||||
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , "fr" , Xow_domain_tid_.Int__wikipedia);}
|
||||
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , "en" , Xow_domain_tid_.Int__wiktionary);}
|
||||
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "zh-classical" , "lzh" , Xow_domain_tid_.Int__wikipedia);}
|
||||
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , "" , Xow_domain_tid_.Int__commons);}
|
||||
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , "" , Xow_domain_tid_.Int__species);}
|
||||
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , "ru" , Xow_domain_tid_.Int__wikimedia);}
|
||||
@Test public void Parse_home() {fxt.Test_parse("home" , "" , "" , Xow_domain_tid_.Int__home);}
|
||||
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , "" , Xow_domain_tid_.Int__other);}
|
||||
@Test public void Parse_ua_wikimedia_org() {fxt.Test_parse("ua.wikimedia.org" , "ua" , "uk" , Xow_domain_tid_.Int__wikimedia);}
|
||||
@Test public void Parse_ar_wikimedia_org() {fxt.Test_parse("ar.wikimedia.org" , "ar" , "es" , Xow_domain_tid_.Int__wikimedia);}
|
||||
@Test public void Parse_blank() {fxt.Test_parse("" , "" , "" , Xow_domain_tid_.Int__other);}
|
||||
private final Xow_domain_fxt fxt = new Xow_domain_fxt();
|
||||
@Test public void Parse_en_wikipedia() {fxt.Test_parse("en.wikipedia.org" , "en" , "en" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_fr_wikipedia() {fxt.Test_parse("fr.wikipedia.org" , "fr" , "fr" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_en_wiktionary() {fxt.Test_parse("en.wiktionary.org" , "en" , "en" , Xow_domain_tid_.Tid__wiktionary);}
|
||||
@Test public void Parse_zh_classical_wikipedia() {fxt.Test_parse("zh-classical.wikipedia.org" , "zh-classical" , "lzh" , Xow_domain_tid_.Tid__wikipedia);}
|
||||
@Test public void Parse_commons() {fxt.Test_parse("commons.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__commons);}
|
||||
@Test public void Parse_species() {fxt.Test_parse("species.wikimedia.org" , "" , "" , Xow_domain_tid_.Tid__species);}
|
||||
@Test public void Parse_ru_wikimedia_org() {fxt.Test_parse("ru.wikimedia.org" , "ru" , "ru" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_home() {fxt.Test_parse("home" , "" , "" , Xow_domain_tid_.Tid__home);}
|
||||
@Test public void Parse_other() {fxt.Test_parse("other.wiki" , "" , "" , Xow_domain_tid_.Tid__other);}
|
||||
@Test public void Parse_ua_wikimedia_org() {fxt.Test_parse("ua.wikimedia.org" , "ua" , "uk" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_ar_wikimedia_org() {fxt.Test_parse("ar.wikimedia.org" , "ar" , "es" , Xow_domain_tid_.Tid__wikimedia);}
|
||||
@Test public void Parse_blank() {fxt.Test_parse("" , "" , "" , Xow_domain_tid_.Tid__other);}
|
||||
}
|
||||
class Xow_domain_fxt {
|
||||
public void Test_parse(String domain, String expd_orig_lang, String expd_actl_lang, int expd_tid) {
|
||||
|
||||
@@ -845,6 +845,7 @@ public class Xow_domain_regy {
|
||||
, "azb.wikipedia.org"
|
||||
, "ady.wikipedia.org"
|
||||
, "jam.wikipedia.org"
|
||||
, "tcy.wikipedia.org"
|
||||
};
|
||||
//, "als.wikisource.org"
|
||||
//, "als.wikinews.org"
|
||||
|
||||
@@ -21,20 +21,19 @@ public class Xow_domain_tid {
|
||||
this.multi_lang = multi_lang; this.src = src; this.tid = tid; this.key_bry = key_bry; this.abrv = abrv; this.domain_bry = domain_bry;
|
||||
this.key_str = String_.new_u8(key_bry);
|
||||
}
|
||||
public boolean Multi_lang() {return multi_lang;} private final boolean multi_lang; // EX: y
|
||||
public int Src() {return src;} private final int src; // EX: 1 (wm,mw,wk,xo)
|
||||
public int Tid() {return tid;} private final int tid; // EX: 1 (Tid_wikipedia)
|
||||
public String Key_str() {return key_str;} private final String key_str; // EX: wikipedia
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: wikipedia
|
||||
public byte[] Abrv() {return abrv;} private final byte[] abrv; // EX: w
|
||||
public boolean Multi_lang() {return multi_lang;} private final boolean multi_lang; // EX: y
|
||||
public int Src() {return src;} private final int src; // EX: 1 (wm,mw,wk,xo)
|
||||
public int Tid() {return tid;} private final int tid; // EX: 1 (Tid_wikipedia)
|
||||
public String Key_str() {return key_str;} private final String key_str; // EX: wikipedia
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: wikipedia
|
||||
public byte[] Abrv() {return abrv;} private final byte[] abrv; // EX: w
|
||||
public byte[] Domain_bry() {return domain_bry;} private byte[] domain_bry; // EX: .wikipedia.org
|
||||
public byte[] Display_bry() {return Bry_.Ucase__1st(key_bry);} // EX: Wikipedia
|
||||
}
|
||||
class Xow_domain_type_src_ {
|
||||
|
||||
public static final int
|
||||
Int__wmf = 1 // administered by wmf; wikipedia, etc.
|
||||
, Int__wikia = 2 // *.wikia.com
|
||||
, Int__mw = 3 // mediawiki installations not part of wmf, wikia
|
||||
, Int__xowa = 4 // xowa
|
||||
Src__wmf = 1 // administered by wmf; wikipedia, etc.
|
||||
, Src__wikia = 2 // *.wikia.com
|
||||
, Src__mw = 3 // mediawiki installations not part of wmf, wikia
|
||||
, Src__xowa = 4 // xowa
|
||||
;
|
||||
}
|
||||
|
||||
@@ -18,26 +18,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_domain_tid_ {
|
||||
public static final int
|
||||
Int__null = 0
|
||||
, Int__wikipedia = 1
|
||||
, Int__wiktionary = 2
|
||||
, Int__wikisource = 3
|
||||
, Int__wikivoyage = 4
|
||||
, Int__wikiquote = 5
|
||||
, Int__wikibooks = 6
|
||||
, Int__wikiversity = 7
|
||||
, Int__wikinews = 8
|
||||
, Int__wikimedia = 9
|
||||
, Int__species = 10
|
||||
, Int__commons = 11
|
||||
, Int__wikidata = 12
|
||||
, Int__mediawiki = 13
|
||||
, Int__meta = 14
|
||||
, Int__incubator = 15
|
||||
, Int__wmfblog = 16
|
||||
, Int__home = 17
|
||||
, Int__other = 18
|
||||
, Int___len = 19
|
||||
Tid__null = 0
|
||||
, Tid__wikipedia = 1
|
||||
, Tid__wiktionary = 2
|
||||
, Tid__wikisource = 3
|
||||
, Tid__wikivoyage = 4
|
||||
, Tid__wikiquote = 5
|
||||
, Tid__wikibooks = 6
|
||||
, Tid__wikiversity = 7
|
||||
, Tid__wikinews = 8
|
||||
, Tid__wikimedia = 9
|
||||
, Tid__species = 10
|
||||
, Tid__commons = 11
|
||||
, Tid__wikidata = 12
|
||||
, Tid__mediawiki = 13
|
||||
, Tid__meta = 14
|
||||
, Tid__incubator = 15
|
||||
, Tid__wmfblog = 16
|
||||
, Tid__home = 17
|
||||
, Tid__other = 18
|
||||
, Tid___len = 19
|
||||
;
|
||||
public static final String // SERIALIZED:xowa.gfs
|
||||
Str__wikipedia = "wikipedia"
|
||||
@@ -79,28 +79,28 @@ public class Xow_domain_tid_ {
|
||||
, Bry__home = Bry_.new_a7(Str__home)
|
||||
, Bry__other = Bry_.new_a7(Str__other)
|
||||
;
|
||||
private static final Xow_domain_tid[] ary = new Xow_domain_tid[Int___len];
|
||||
private static final Xow_domain_tid[] ary = new Xow_domain_tid[Tid___len];
|
||||
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_tid
|
||||
Itm__wikipedia = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikipedia , Bry__wikipedia , "w" , ".wikipedia.org")
|
||||
, Itm__wiktionary = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wiktionary , Bry__wiktionary , "d" , ".wiktionary.org")
|
||||
, Itm__wikisource = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikisource , Bry__wikisource , "s" , ".wikisource.org")
|
||||
, Itm__wikivoyage = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikivoyage , Bry__wikivoyage , "v" , ".wikivoyage.org")
|
||||
, Itm__wikiquote = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikiquote , Bry__wikiquote , "q" , ".wikiquote.org")
|
||||
, Itm__wikibooks = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikibooks , Bry__wikibooks , "b" , ".wikibooks.org")
|
||||
, Itm__wikiversity = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikiversity , Bry__wikiversity , "u" , ".wikiversity.org")
|
||||
, Itm__wikinews = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikinews , Bry__wikinews , "n" , ".wikinews.org")
|
||||
, Itm__wikimedia = new_(Bool_.Y , Xow_domain_type_src_.Int__wmf , Int__wikimedia , Bry__wikimedia , "m" , ".wikimedia.org")
|
||||
, Itm__species = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__species , Bry__species , "species" , Xow_domain_itm_.Str__species)
|
||||
, Itm__commons = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__commons , Bry__commons , "c" , Xow_domain_itm_.Str__commons)
|
||||
, Itm__wikidata = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__wikidata , Bry__wikidata , "wd" , Xow_domain_itm_.Str__wikidata)
|
||||
, Itm__mediawiki = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__mediawiki , Bry__mediawiki , "mw" , Xow_domain_itm_.Str__mediawiki)
|
||||
, Itm__meta = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__meta , Bry__meta , "meta" , Xow_domain_itm_.Str__meta)
|
||||
, Itm__incubator = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__incubator , Bry__incubator , "qb" , Xow_domain_itm_.Str__incubator)
|
||||
, Itm__wmforg = new_(Bool_.N , Xow_domain_type_src_.Int__wmf , Int__wmfblog , Bry__wmforg , "wmf" , Xow_domain_itm_.Str__wmforg)
|
||||
, Itm__home = new_(Bool_.N , Xow_domain_type_src_.Int__xowa, Int__home , Bry__home , "home" , Xow_domain_itm_.Str__home)
|
||||
, Itm__other = new_(Bool_.N , Xow_domain_type_src_.Int__mw , Int__other , Bry__other , "" , "")
|
||||
Itm__wikipedia = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikipedia , Bry__wikipedia , "w" , ".wikipedia.org")
|
||||
, Itm__wiktionary = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wiktionary , Bry__wiktionary , "d" , ".wiktionary.org")
|
||||
, Itm__wikisource = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikisource , Bry__wikisource , "s" , ".wikisource.org")
|
||||
, Itm__wikivoyage = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikivoyage , Bry__wikivoyage , "v" , ".wikivoyage.org")
|
||||
, Itm__wikiquote = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikiquote , Bry__wikiquote , "q" , ".wikiquote.org")
|
||||
, Itm__wikibooks = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikibooks , Bry__wikibooks , "b" , ".wikibooks.org")
|
||||
, Itm__wikiversity = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikiversity , Bry__wikiversity , "u" , ".wikiversity.org")
|
||||
, Itm__wikinews = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikinews , Bry__wikinews , "n" , ".wikinews.org")
|
||||
, Itm__wikimedia = new_(Bool_.Y , Xow_domain_tid.Src__wmf , Tid__wikimedia , Bry__wikimedia , "m" , ".wikimedia.org")
|
||||
, Itm__species = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__species , Bry__species , "species" , Xow_domain_itm_.Str__species)
|
||||
, Itm__commons = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__commons , Bry__commons , "c" , Xow_domain_itm_.Str__commons)
|
||||
, Itm__wikidata = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__wikidata , Bry__wikidata , "wd" , Xow_domain_itm_.Str__wikidata)
|
||||
, Itm__mediawiki = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__mediawiki , Bry__mediawiki , "mw" , Xow_domain_itm_.Str__mediawiki)
|
||||
, Itm__meta = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__meta , Bry__meta , "meta" , Xow_domain_itm_.Str__meta)
|
||||
, Itm__incubator = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__incubator , Bry__incubator , "qb" , Xow_domain_itm_.Str__incubator)
|
||||
, Itm__wmforg = new_(Bool_.N , Xow_domain_tid.Src__wmf , Tid__wmfblog , Bry__wmforg , "wmf" , Xow_domain_itm_.Str__wmforg)
|
||||
, Itm__home = new_(Bool_.N , Xow_domain_tid.Src__xowa, Tid__home , Bry__home , "home" , Xow_domain_itm_.Str__home)
|
||||
, Itm__other = new_(Bool_.N , Xow_domain_tid.Src__mw , Tid__other , Bry__other , "" , "")
|
||||
;
|
||||
private static Xow_domain_tid new_(boolean multi_lang, int src, int tid, byte[] key_bry, String abrv_xo_str, String domain_bry) {
|
||||
byte[] abrv_xo_bry = Bry_.new_u8(abrv_xo_str);
|
||||
@@ -116,6 +116,6 @@ public class Xow_domain_tid_ {
|
||||
public static int Get_type_as_tid(byte[] src) {return Get_type_as_tid(src, 0, src.length);}
|
||||
public static int Get_type_as_tid(byte[] src, int bgn, int end) {
|
||||
Object o = type_regy.Get_by_mid(src, bgn, end);
|
||||
return o == null ? Xow_domain_tid_.Int__null : ((Xow_domain_tid)o).Tid();
|
||||
return o == null ? Xow_domain_tid_.Tid__null : ((Xow_domain_tid)o).Tid();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,23 +44,23 @@ public class Xow_domain_uid_ {
|
||||
public static int To_int(Xow_domain_itm domain) {
|
||||
int domain_tid = 0;
|
||||
switch (domain.Domain_type_id()) {
|
||||
case Xow_domain_tid_.Int__home: return Tid_xowa;
|
||||
case Xow_domain_tid_.Int__commons: return Tid_commons;
|
||||
case Xow_domain_tid_.Int__wikidata: return Tid_wikidata;
|
||||
case Xow_domain_tid_.Int__mediawiki: return Tid_mediawiki;
|
||||
case Xow_domain_tid_.Int__meta: return Tid_meta;
|
||||
case Xow_domain_tid_.Int__incubator: return Tid_incubator;
|
||||
case Xow_domain_tid_.Int__wmfblog: return Tid_wmfblog;
|
||||
case Xow_domain_tid_.Int__species: return Tid_species;
|
||||
case Xow_domain_tid_.Int__wikipedia: domain_tid = Tid_sub_wikipedia; break;
|
||||
case Xow_domain_tid_.Int__wiktionary: domain_tid = Tid_sub_wiktionary; break;
|
||||
case Xow_domain_tid_.Int__wikisource: domain_tid = Tid_sub_wikisource; break;
|
||||
case Xow_domain_tid_.Int__wikivoyage: domain_tid = Tid_sub_wikivoyage; break;
|
||||
case Xow_domain_tid_.Int__wikiquote: domain_tid = Tid_sub_wikiquote; break;
|
||||
case Xow_domain_tid_.Int__wikibooks: domain_tid = Tid_sub_wikibooks; break;
|
||||
case Xow_domain_tid_.Int__wikiversity: domain_tid = Tid_sub_wikiversity; break;
|
||||
case Xow_domain_tid_.Int__wikinews: domain_tid = Tid_sub_wikinews; break;
|
||||
case Xow_domain_tid_.Int__wikimedia: domain_tid = Tid_sub_wikimedia; break;
|
||||
case Xow_domain_tid_.Tid__home: return Tid_xowa;
|
||||
case Xow_domain_tid_.Tid__commons: return Tid_commons;
|
||||
case Xow_domain_tid_.Tid__wikidata: return Tid_wikidata;
|
||||
case Xow_domain_tid_.Tid__mediawiki: return Tid_mediawiki;
|
||||
case Xow_domain_tid_.Tid__meta: return Tid_meta;
|
||||
case Xow_domain_tid_.Tid__incubator: return Tid_incubator;
|
||||
case Xow_domain_tid_.Tid__wmfblog: return Tid_wmfblog;
|
||||
case Xow_domain_tid_.Tid__species: return Tid_species;
|
||||
case Xow_domain_tid_.Tid__wikipedia: domain_tid = Tid_sub_wikipedia; break;
|
||||
case Xow_domain_tid_.Tid__wiktionary: domain_tid = Tid_sub_wiktionary; break;
|
||||
case Xow_domain_tid_.Tid__wikisource: domain_tid = Tid_sub_wikisource; break;
|
||||
case Xow_domain_tid_.Tid__wikivoyage: domain_tid = Tid_sub_wikivoyage; break;
|
||||
case Xow_domain_tid_.Tid__wikiquote: domain_tid = Tid_sub_wikiquote; break;
|
||||
case Xow_domain_tid_.Tid__wikibooks: domain_tid = Tid_sub_wikibooks; break;
|
||||
case Xow_domain_tid_.Tid__wikiversity: domain_tid = Tid_sub_wikiversity; break;
|
||||
case Xow_domain_tid_.Tid__wikinews: domain_tid = Tid_sub_wikinews; break;
|
||||
case Xow_domain_tid_.Tid__wikimedia: domain_tid = Tid_sub_wikimedia; break;
|
||||
default: throw Err_.new_unhandled(domain.Domain_type_id());
|
||||
}
|
||||
return Const_system_reserved // reserve first 100 slots
|
||||
@@ -70,29 +70,29 @@ public class Xow_domain_uid_ {
|
||||
}
|
||||
public static Xow_domain_itm To_domain(int tid) {
|
||||
switch (tid) {
|
||||
case Tid_xowa: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__home, Xow_domain_tid_.Int__home, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_commons: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__commons, Xow_domain_tid_.Int__commons, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_wikidata: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__wikidata, Xow_domain_tid_.Int__commons, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_mediawiki: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__mediawiki, Xow_domain_tid_.Int__mediawiki, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_meta: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__meta, Xow_domain_tid_.Int__meta, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_incubator: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__incubator, Xow_domain_tid_.Int__incubator, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_wmfblog: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__wmforg, Xow_domain_tid_.Int__wmfblog, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_species: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__species, Xow_domain_tid_.Int__species, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_xowa: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__home, Xow_domain_tid_.Tid__home, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_commons: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__commons, Xow_domain_tid_.Tid__commons, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_wikidata: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__wikidata, Xow_domain_tid_.Tid__commons, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_mediawiki: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__mediawiki, Xow_domain_tid_.Tid__mediawiki, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_meta: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__meta, Xow_domain_tid_.Tid__meta, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_incubator: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__incubator, Xow_domain_tid_.Tid__incubator, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_wmfblog: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__wmforg, Xow_domain_tid_.Tid__wmfblog, Xol_lang_stub_.Key__unknown);
|
||||
case Tid_species: return Xow_domain_itm.new_(Xow_domain_itm_.Bry__species, Xow_domain_tid_.Tid__species, Xol_lang_stub_.Key__unknown);
|
||||
}
|
||||
int tmp = tid - Const_system_reserved;
|
||||
int lang_id = tmp / 20;
|
||||
int type_id = tmp % 20;
|
||||
int tid_int = 0; byte[] tid_bry = null;
|
||||
switch (type_id) {
|
||||
case Tid_sub_wikipedia: tid_int = Xow_domain_tid_.Int__wikipedia; tid_bry = Xow_domain_tid_.Bry__wikipedia; break;
|
||||
case Tid_sub_wiktionary: tid_int = Xow_domain_tid_.Int__wiktionary; tid_bry = Xow_domain_tid_.Bry__wiktionary; break;
|
||||
case Tid_sub_wikisource: tid_int = Xow_domain_tid_.Int__wikisource; tid_bry = Xow_domain_tid_.Bry__wikisource; break;
|
||||
case Tid_sub_wikivoyage: tid_int = Xow_domain_tid_.Int__wikivoyage; tid_bry = Xow_domain_tid_.Bry__wikivoyage; break;
|
||||
case Tid_sub_wikiquote: tid_int = Xow_domain_tid_.Int__wikiquote; tid_bry = Xow_domain_tid_.Bry__wikiquote; break;
|
||||
case Tid_sub_wikibooks: tid_int = Xow_domain_tid_.Int__wikibooks; tid_bry = Xow_domain_tid_.Bry__wikibooks; break;
|
||||
case Tid_sub_wikiversity: tid_int = Xow_domain_tid_.Int__wikiversity; tid_bry = Xow_domain_tid_.Bry__wikiversity; break;
|
||||
case Tid_sub_wikinews: tid_int = Xow_domain_tid_.Int__wikinews; tid_bry = Xow_domain_tid_.Bry__wikinews; break;
|
||||
case Tid_sub_wikimedia: tid_int = Xow_domain_tid_.Int__wikimedia; tid_bry = Xow_domain_tid_.Bry__wikimedia; break;
|
||||
case Tid_sub_wikipedia: tid_int = Xow_domain_tid_.Tid__wikipedia; tid_bry = Xow_domain_tid_.Bry__wikipedia; break;
|
||||
case Tid_sub_wiktionary: tid_int = Xow_domain_tid_.Tid__wiktionary; tid_bry = Xow_domain_tid_.Bry__wiktionary; break;
|
||||
case Tid_sub_wikisource: tid_int = Xow_domain_tid_.Tid__wikisource; tid_bry = Xow_domain_tid_.Bry__wikisource; break;
|
||||
case Tid_sub_wikivoyage: tid_int = Xow_domain_tid_.Tid__wikivoyage; tid_bry = Xow_domain_tid_.Bry__wikivoyage; break;
|
||||
case Tid_sub_wikiquote: tid_int = Xow_domain_tid_.Tid__wikiquote; tid_bry = Xow_domain_tid_.Bry__wikiquote; break;
|
||||
case Tid_sub_wikibooks: tid_int = Xow_domain_tid_.Tid__wikibooks; tid_bry = Xow_domain_tid_.Bry__wikibooks; break;
|
||||
case Tid_sub_wikiversity: tid_int = Xow_domain_tid_.Tid__wikiversity; tid_bry = Xow_domain_tid_.Bry__wikiversity; break;
|
||||
case Tid_sub_wikinews: tid_int = Xow_domain_tid_.Tid__wikinews; tid_bry = Xow_domain_tid_.Bry__wikinews; break;
|
||||
case Tid_sub_wikimedia: tid_int = Xow_domain_tid_.Tid__wikimedia; tid_bry = Xow_domain_tid_.Bry__wikimedia; break;
|
||||
default: throw Err_.new_unhandled(type_id);
|
||||
}
|
||||
Xol_lang_stub lang = Xol_lang_stub_.Get_by_id(lang_id);
|
||||
|
||||
@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xow_domain_uid__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xow_domain_uid__fxt fxt = new Xow_domain_uid__fxt();
|
||||
@Before public void init() {fxt.Clear();} private final Xow_domain_uid__fxt fxt = new Xow_domain_uid__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test(Xow_domain_uid_.Tid_commons , "commons.wikimedia.org" , "", Xow_domain_tid_.Int__commons);
|
||||
fxt.Test(100 , "en.wikipedia.org" , "en", Xow_domain_tid_.Int__wikipedia);
|
||||
fxt.Test(Xow_domain_uid_.Tid_commons , "commons.wikimedia.org" , "", Xow_domain_tid_.Tid__commons);
|
||||
fxt.Test(100 , "en.wikipedia.org" , "en", Xow_domain_tid_.Tid__wikipedia);
|
||||
}
|
||||
}
|
||||
class Xow_domain_uid__fxt {
|
||||
|
||||
@@ -34,14 +34,14 @@ class Xow_domain_crt_itm__in implements Xow_domain_crt_itm {
|
||||
class Xow_domain_crt_itm__any_standard implements Xow_domain_crt_itm {
|
||||
public boolean Matches(Xow_domain_itm cur, Xow_domain_itm comp) {
|
||||
switch (comp.Domain_type_id()) {
|
||||
case Xow_domain_tid_.Int__wikipedia:
|
||||
case Xow_domain_tid_.Int__wiktionary:
|
||||
case Xow_domain_tid_.Int__wikisource:
|
||||
case Xow_domain_tid_.Int__wikivoyage:
|
||||
case Xow_domain_tid_.Int__wikiquote:
|
||||
case Xow_domain_tid_.Int__wikibooks:
|
||||
case Xow_domain_tid_.Int__wikiversity:
|
||||
case Xow_domain_tid_.Int__wikinews: return true;
|
||||
case Xow_domain_tid_.Tid__wikipedia:
|
||||
case Xow_domain_tid_.Tid__wiktionary:
|
||||
case Xow_domain_tid_.Tid__wikisource:
|
||||
case Xow_domain_tid_.Tid__wikivoyage:
|
||||
case Xow_domain_tid_.Tid__wikiquote:
|
||||
case Xow_domain_tid_.Tid__wikibooks:
|
||||
case Xow_domain_tid_.Tid__wikiversity:
|
||||
case Xow_domain_tid_.Tid__wikinews: return true;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class Xow_domain_crt_itm_parser {
|
||||
int raw_len = raw.length;
|
||||
if (Bry_.Has_at_bgn(raw, Wild_lang)) { // EX: *.wikipedia
|
||||
int wiki_tid = Xow_domain_tid_.Get_type_as_tid(raw, Wild_lang.length, raw_len);
|
||||
return wiki_tid == Xow_domain_tid_.Int__null ? Xow_domain_crt_itm_.Null : new Xow_domain_crt_itm__type(wiki_tid);
|
||||
return wiki_tid == Xow_domain_tid_.Tid__null ? Xow_domain_crt_itm_.Null : new Xow_domain_crt_itm__type(wiki_tid);
|
||||
}
|
||||
else if (Bry_.Has_at_end(raw, Wild_type)) { // EX: en.*
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(raw, 0, raw_len - Wild_type.length);
|
||||
|
||||
@@ -31,6 +31,10 @@ public class Xowe_page_mgr {
|
||||
page.Html_data().Hdump_exists_(hdump_exists);
|
||||
Wait_for_popups(wiki.App());
|
||||
|
||||
// auto-update
|
||||
gplx.xowa.addons.wikis.pages.syncs.core.Xosync_read_mgr read_mgr = new gplx.xowa.addons.wikis.pages.syncs.core.Xosync_read_mgr();
|
||||
read_mgr.Auto_update(wiki, page, ttl);
|
||||
|
||||
// load page text
|
||||
boolean parse = true;
|
||||
if (hdump_exists) {
|
||||
|
||||
@@ -28,5 +28,5 @@ public class Xopg_db_protection {
|
||||
this.protection_expiry = Bry__protection_expiry__infinite;
|
||||
}
|
||||
|
||||
public static final byte[] Bry__protection_expiry__infinite = Bry_.new_a7("infinity");// NOTE: per en.w:Module:Effective_protection_expiry DATE:2016-08-05
|
||||
public static final byte[] Bry__protection_expiry__infinite = Bry_.new_a7("infinity");// NOTE: means page never expires; must be "infinity" as per en.w:Module:Effective_protection_expiry DATE:2016-08-05
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.tags.*; impor
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.addons.htmls.tocs.*;
|
||||
import gplx.xowa.xtns.pagebanners.*; import gplx.xowa.xtns.indicators.*;
|
||||
public class Xopg_html_data {
|
||||
private Ordered_hash ctg_hash;
|
||||
public Xopg_lnki_list Redlink_list() {return redlink_list;} private final Xopg_lnki_list redlink_list = new Xopg_lnki_list();
|
||||
|
||||
public boolean Html_restricted() {return html_restricted;} private boolean html_restricted = true;
|
||||
@@ -87,17 +86,9 @@ public class Xopg_html_data {
|
||||
xtn_pgbnr = null;
|
||||
module_mgr.Clear();
|
||||
custom_html = custom_tab_name = null;
|
||||
if (ctg_hash != null) ctg_hash.Clear();
|
||||
indicators.Clear();
|
||||
this.mode_wtxt_shown = false;
|
||||
}
|
||||
public byte[][] Ctgs_to_ary() {return ctg_hash == null ? Bry_.Ary_empty : (byte[][])ctg_hash.To_ary(byte[].class);}
|
||||
public void Ctgs_add(Xoa_ttl ttl) {
|
||||
if (ctg_hash == null) ctg_hash = Ordered_hash_.New_bry();
|
||||
byte[] ttl_bry = ttl.Page_txt();
|
||||
if (ctg_hash.Has(ttl_bry)) return;
|
||||
ctg_hash.Add(ttl_bry, ttl_bry);
|
||||
}
|
||||
public void Init_by_page(Xoa_ttl ttl) {
|
||||
redlink_list.Disabled_(ttl.Ns().Id_is_module());
|
||||
}
|
||||
|
||||
@@ -17,8 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.pages.wtxts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xopg_wtxt_data {
|
||||
public Xopg_toc_mgr Toc() {return toc;} private final Xopg_toc_mgr toc = new Xopg_toc_mgr();
|
||||
public Xopg_toc_mgr Toc() {return toc;} private final Xopg_toc_mgr toc = new Xopg_toc_mgr();
|
||||
public int Ctgs__len() {return ctg_hash == null ? 0 : ctg_hash.Len();} private Ordered_hash ctg_hash;
|
||||
public Xoa_ttl Ctgs__get_at(int i) {return (Xoa_ttl)ctg_hash.Get_at(i);}
|
||||
public Xoa_ttl[] Ctgs__to_ary() {return (Xoa_ttl[])ctg_hash.To_ary(Xoa_ttl.class);}
|
||||
public void Ctgs__add(Xoa_ttl ttl) {
|
||||
if (ctg_hash == null) ctg_hash = Ordered_hash_.New_bry();
|
||||
ctg_hash.Add_if_dupe_use_1st(ttl.Full_db(), ttl);
|
||||
}
|
||||
public void Clear() {
|
||||
if (ctg_hash != null) ctg_hash.Clear();
|
||||
toc.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
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_.Int__commons // commons should never be considered an xwiki_lang; EX:[[commons:A]] PAGE:species:Scarabaeidae; DATE:2014-09-10
|
||||
&& 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
|
||||
;
|
||||
|
||||
@@ -18,25 +18,25 @@ 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();
|
||||
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_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
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_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
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_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "en");
|
||||
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_.Int__wikipedia, "en.wikipedia.org", "enwiki"), "simple");
|
||||
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_.Int__commons, "commons.wikimedia.org", "commonswiki"), "en");
|
||||
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_.Int__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_.Int__wikipedia, "zh-classical.wikipedia.org", "lzwwiki"), "zh");
|
||||
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 {
|
||||
|
||||
@@ -77,9 +77,9 @@ public class Xow_xwiki_mgr {
|
||||
}
|
||||
private static int Xwiki_tid(int tid) {
|
||||
switch (tid) {
|
||||
case Xow_domain_tid_.Int__commons: case Xow_domain_tid_.Int__species: case Xow_domain_tid_.Int__incubator:
|
||||
case Xow_domain_tid_.Int__mediawiki: case Xow_domain_tid_.Int__wmfblog: case Xow_domain_tid_.Int__home:
|
||||
return Xow_domain_tid_.Int__wikipedia; // set xwiki_tid to wikipedia; allows [[da:Page]] to point to da.wikipedia.org; PAGE:species:Puccinia; DATE:2014-09-14
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public class Xow_xwiki_itm_bldr {
|
||||
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_.Int__wikipedia // cur_domain is not wikipedia
|
||||
&& domain_itm.Domain_type_id() == Xow_domain_tid_.Int__wikipedia // domain_itm is wikipedia
|
||||
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")
|
||||
|
||||
@@ -18,15 +18,15 @@ 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_.Int__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_.Int__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_.Int__wikipedia , Xol_lang_stub_.Id_fr);}
|
||||
@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_.Int__wikivoyage, Xol_lang_itm_.Key_en); // NOTE: use "en.wikivoyage.org" to domain_name; needed for "Related sites"
|
||||
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);
|
||||
|
||||
@@ -60,7 +60,7 @@ public class Xow_xwiki_itm_parser extends Dsv_wkr_base {
|
||||
default: throw Err_.new_unhandled(cur_tid);
|
||||
}
|
||||
byte[] abrv_wm = null;
|
||||
int lang_id = Xol_lang_stub_.Id__unknown, domain_tid = Xow_domain_tid_.Int__other;
|
||||
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);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xow_xwiki_mgr_tst {
|
||||
}
|
||||
@Test public void Add_bulk_langs_grp_commons() {
|
||||
fxt.Init_langs();
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_sitelink_mgr(Xow_domain_tid_.Int__wikipedia);
|
||||
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() {
|
||||
@@ -75,7 +75,7 @@ class Xow_xwiki_mgr_fxt {
|
||||
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_.Int__other, Bry_.Empty, Bry_.Empty);}
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user