mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.3.1'
This commit is contained in:
@@ -23,7 +23,7 @@ import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; 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.*; 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.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
@@ -65,6 +65,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
public Xof_orig_mgr File__orig_mgr() {return orig_mgr;} private final Xof_orig_mgr orig_mgr = new Xof_orig_mgr();
|
||||
public Xof_bin_mgr File__bin_mgr() {return fsdb_mgr.Bin_mgr();}
|
||||
public Fsm_mnt_mgr File__mnt_mgr() {return fsdb_mgr.Mnt_mgr();}
|
||||
public Xoh_href_wtr Html__href_wtr() {return html__href_wtr;} private final Xoh_href_wtr html__href_wtr = new Xoh_href_wtr();
|
||||
public boolean Html__hdump_enabled() {return Bool_.Y;}
|
||||
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;
|
||||
|
||||
@@ -18,18 +18,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
public class Xow_cache_mgr {
|
||||
private Xowe_wiki wiki;
|
||||
private final Xowe_wiki wiki;
|
||||
public Xow_cache_mgr(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
page_cache = new Xow_page_cache(wiki);
|
||||
defn_cache = new Xow_defn_cache(wiki.Lang());
|
||||
lst_cache = new Xow_defn_cache(wiki.Lang());
|
||||
this.page_cache = new Xow_page_cache(wiki);
|
||||
this.defn_cache = new Xow_defn_cache(wiki.Lang());
|
||||
this.lst_cache = new Xow_defn_cache(wiki.Lang());
|
||||
}
|
||||
public Hash_adp Tmpl_result_cache() {return tmpl_result_cache;} private Hash_adp tmpl_result_cache = Hash_adp_bry.cs();
|
||||
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
|
||||
public Xow_defn_cache Defn_cache() {return defn_cache;} private Xow_defn_cache defn_cache;
|
||||
public Xow_defn_cache Lst_cache() {return lst_cache;} private Xow_defn_cache lst_cache;
|
||||
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New();
|
||||
public Hash_adp Tmpl_result_cache() {return tmpl_result_cache;} private final Hash_adp tmpl_result_cache = Hash_adp_bry.cs();
|
||||
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
|
||||
public Xow_defn_cache Defn_cache() {return defn_cache;} private final Xow_defn_cache defn_cache;
|
||||
public Xow_defn_cache Lst_cache() {return lst_cache;} private final Xow_defn_cache lst_cache;
|
||||
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New();
|
||||
public void Page_cache_(Xow_page_cache v) {this.page_cache = v;}
|
||||
public Keyval[] Scrib_lang_names() {
|
||||
if (scrib_lang_names == null) {
|
||||
List_adp list = List_adp_.New();
|
||||
@@ -44,10 +45,11 @@ public class Xow_cache_mgr {
|
||||
}
|
||||
return scrib_lang_names;
|
||||
}
|
||||
public void Free_mem_all() {
|
||||
public void Free_mem_all() {this.Free_mem_all(Bool_.Y);}
|
||||
public void Free_mem_all(boolean free_page_cache) {
|
||||
if (free_page_cache) page_cache.Free_mem_all();
|
||||
tmpl_result_cache.Clear();
|
||||
defn_cache.Free_mem_all();
|
||||
page_cache.Free_mem_all();
|
||||
misc_cache.Clear();
|
||||
lst_cache.Free_mem_all();
|
||||
scrib_lang_names = null;
|
||||
|
||||
@@ -24,34 +24,51 @@ public class Xow_page_cache {
|
||||
Xow_page_cache_itm rv = Get_or_load_as_itm(ttl);
|
||||
return rv == null ? null : rv.Wtxt__direct();
|
||||
}
|
||||
public void Add(byte[] ttl_full_db, Xow_page_cache_itm itm) {
|
||||
cache.Add(ttl_full_db, itm);
|
||||
}
|
||||
public Xow_page_cache_itm Get_or_load_as_itm(Xoa_ttl ttl) {
|
||||
byte[] ttl_full_db = ttl.Full_db();
|
||||
synchronized (this) { // LOCK:app-level; DATE:2016-07-06
|
||||
Xow_page_cache_itm rv = (Xow_page_cache_itm)cache.Get_by_bry(ttl_full_db);
|
||||
if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if (page.Db().Page().Exists()) {
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect().Itms__get_at_0th_or_null());
|
||||
Xow_page_cache_itm rv = (Xow_page_cache_itm)cache.Get_by_bry(ttl_full_db);
|
||||
if (rv == Xow_page_cache_itm.Missing) return null;
|
||||
else if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if (page.Db().Page().Exists()) {
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect().Itms__get_at_0th_or_null());
|
||||
synchronized (this) { // LOCK:high-usage;DATE:2016-07-14
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
else {
|
||||
synchronized (this) { // LOCK:high-usage;DATE:2016-07-14
|
||||
cache.Add_bry_obj(ttl_full_db, Xow_page_cache_itm.Missing);
|
||||
rv = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Xow_page_cache_itm Get_or_load_as_itm_2(Xoa_ttl ttl) { // NOTE: same as Get_or_load_as_itm, but handles redirects to missing pages; DATE:2016-05-02
|
||||
byte[] ttl_full_db = ttl.Full_db();
|
||||
synchronized (this) { // LOCK:app-level; DATE:2016-07-06
|
||||
Xow_page_cache_itm rv = (Xow_page_cache_itm)cache.Get_by_bry(ttl_full_db);
|
||||
if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if ( page.Db().Page().Exists() // page exists
|
||||
|| page.Redirect().Itms__len() > 0 ) { // page redirects to missing page; note that page.Missing == true and page.Redirected_src() != null; PAGE: en.w:Shah_Rukh_Khan; DATE:2016-05-02
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect().Itms__get_at_0th_or_null());
|
||||
Xow_page_cache_itm rv = (Xow_page_cache_itm)cache.Get_by_bry(ttl_full_db);
|
||||
if (rv == Xow_page_cache_itm.Missing) return null;
|
||||
else if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if ( page.Db().Page().Exists() // page exists
|
||||
|| page.Redirect().Itms__len() > 0 ) { // page redirects to missing page; note that page.Missing == true and page.Redirected_src() != null; PAGE: en.w:Shah_Rukh_Khan; DATE:2016-05-02
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect().Itms__get_at_0th_or_null());
|
||||
synchronized (this) { // LOCK:high-usage;DATE:2016-07-14
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
else {
|
||||
synchronized (this) { // LOCK:high-usage;DATE:2016-07-14
|
||||
cache.Add_bry_obj(ttl_full_db, Xow_page_cache_itm.Missing);
|
||||
rv = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Free_mem_all() {
|
||||
synchronized (this) { // LOCK:app-level; DATE:2016-07-06
|
||||
|
||||
@@ -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.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xow_page_cache_itm {
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xow_page_cache_itm implements Xowd_text_bry_owner {
|
||||
public Xow_page_cache_itm(Xoa_ttl ttl, byte[] wtxt__direct, byte[] wtxt__redirect) {
|
||||
this.ttl = ttl; this.wtxt__direct = wtxt__direct; this.wtxt__redirect = wtxt__redirect;
|
||||
}
|
||||
@@ -26,5 +27,17 @@ public class Xow_page_cache_itm {
|
||||
public byte[] Wtxt__redirect_or_direct() {
|
||||
return wtxt__redirect == null ? wtxt__direct : wtxt__redirect;
|
||||
}
|
||||
|
||||
// used by xomp
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public int Redirect_id() {return redirect_id;} private int redirect_id;
|
||||
public void Set_text_bry_by_db(byte[] v) {this.wtxt__direct = v;}
|
||||
public void Set_page_ids(int page_id, int redirect_id) {this.page_id = page_id; this.redirect_id = redirect_id;}
|
||||
public void Set_redirect_bry(byte[] trg_wtxt) {
|
||||
this.wtxt__redirect = wtxt__direct;
|
||||
this.wtxt__direct = trg_wtxt;
|
||||
}
|
||||
|
||||
public static final Xow_page_cache_itm Null = null;
|
||||
public static final Xow_page_cache_itm Missing = new Xow_page_cache_itm(null, null, null);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ class Xoctg_fmtr_all {
|
||||
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 = Xoctg_fmtr_itm_subc.Instance; 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 = Xoctg_fmtr_itm_page.Instance; 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 = Xoctg_fmtr_itm_file.Instance; break;
|
||||
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
|
||||
@@ -118,7 +118,7 @@ class Xoctg_fmtr_all {
|
||||
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();
|
||||
app.Html__href_wtr().Build_to_bfr(href_bfr, app, Xoh_wtr_ctx.Basic, wiki.Domain_bry(), ttl);
|
||||
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;
|
||||
|
||||
@@ -61,7 +61,7 @@ abstract class Xoctg_fmtr_itm_base implements gplx.core.brys.Bfr_arg, Xoctg_fmtr
|
||||
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.App().Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
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(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;
|
||||
|
||||
@@ -17,7 +17,6 @@ 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 {
|
||||
public static final Xoctg_fmtr_itm_page Instance = new Xoctg_fmtr_itm_page(); Xoctg_fmtr_itm_page() {}
|
||||
}
|
||||
class Xoctg_fmtr_itm_file extends Xoctg_fmtr_itm_base {
|
||||
// public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
@@ -41,5 +40,4 @@ class Xoctg_fmtr_itm_file extends Xoctg_fmtr_itm_base {
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
public static final Xoctg_fmtr_itm_file Instance = new Xoctg_fmtr_itm_file(); Xoctg_fmtr_itm_file() {}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ 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.App().Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
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();
|
||||
@@ -43,6 +43,5 @@ class Xoctg_fmtr_itm_subc extends Xoctg_fmtr_itm_base {
|
||||
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));
|
||||
} static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
|
||||
public static final Xoctg_fmtr_itm_subc Instance = new Xoctg_fmtr_itm_subc(); Xoctg_fmtr_itm_subc() {}
|
||||
} static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ public class Xoctg_html_mgr implements Gfo_invk {
|
||||
Bld_html_v2(wiki, page, hctx, tmp_bfr);
|
||||
else
|
||||
Bld_html_v1(wiki, page, hctx, tmp_bfr);
|
||||
bfr.Add_bfr_and_preserve(tmp_bfr.Mkr_rls());
|
||||
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();
|
||||
@@ -43,7 +44,7 @@ public class Xoctg_html_mgr implements Gfo_invk {
|
||||
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.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);
|
||||
|
||||
@@ -23,11 +23,13 @@ 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.href_wtr = app.Html__href_wtr();
|
||||
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;} private Xowe_wiki wiki; private Xoh_wtr_ctx hctx;
|
||||
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) {
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xoctg_view_grp {
|
||||
return rv;
|
||||
}
|
||||
public void Itms_add(Xoctg_view_itm sub) {tmp_list.Add(sub);}
|
||||
public List_adp Itms_list() {return tmp_list;} List_adp tmp_list = List_adp_.New();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ public class Xowd_cat_link_tbl implements Rls_able {
|
||||
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
|
||||
? Db_crt_.New_mte(fld_sortkey, arg_sortkey_str) // from: sortkey >= 'val'
|
||||
? Db_crt_.New_mte(fld_sortkey, arg_sortkey_str) // from: sortkey >= 'val'
|
||||
: Db_crt_.New_lte(fld_sortkey, arg_sortkey_str); // until: sortkey <= 'val'
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().Cols_(fld_from, fld_sortkey).From_(tbl_name)
|
||||
.Where_(gplx.core.criterias.Criteria_.And_many(Db_crt_.New_eq(fld_to_id, -1), Db_crt_.New_eq(fld_type_id, arg_tid), comp_crt))
|
||||
.Order_(fld_sortkey, !arg_is_from)
|
||||
.Limit_(limit + 1); // + 1 to get last_plus_one for next page / previous page
|
||||
.Limit_(limit + 1); // + 1 to get last_plus_one for next page / previous page
|
||||
Db_rdr rdr = conn.Stmt_new(qry).Crt_int(fld_to_id, cat_page_id).Crt_byte(fld_type_id, arg_tid).Crt_str(fld_sortkey, arg_sortkey_str).Exec_select__rls_auto();
|
||||
int count = 0;
|
||||
try {
|
||||
|
||||
@@ -156,9 +156,8 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
wkr.Init(this, ns_mgr, rv);
|
||||
wkr.Select_in(cancelable, conn, bgn, end);
|
||||
}
|
||||
public boolean Select_in__id(Cancelable cancelable, List_adp rv) {return Select_in__id(cancelable, false, rv, 0, rv.Count());}
|
||||
public boolean Select_in__id(Cancelable cancelable, boolean skip_table_read, List_adp rv) {return Select_in__id(cancelable, skip_table_read, rv, 0, rv.Count());}
|
||||
public boolean Select_in__id(Cancelable cancelable, boolean skip_table_read, List_adp rv, int bgn, int end) {
|
||||
public boolean Select_in__id(Cancelable cancelable, boolean show_progress, List_adp rv) {return Select_in__id(cancelable, false, show_progress, rv, 0, rv.Count());}
|
||||
public boolean Select_in__id(Cancelable cancelable, boolean skip_table_read, boolean show_progress, List_adp rv, int bgn, int end) {
|
||||
Xowd_page_itm[] page_ary = (Xowd_page_itm[])rv.To_ary(Xowd_page_itm.class);
|
||||
int len = page_ary.length; if (len == 0) return false;
|
||||
Ordered_hash hash = Ordered_hash_.New();
|
||||
@@ -169,13 +168,9 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
hash.Add(p.Id_val(), p);
|
||||
}
|
||||
hash.Sort_by(Xowd_page_itm_sorter.IdAsc); // sort by ID to reduce disk thrashing; DATE:2015-03-31
|
||||
conn.Txn_bgn("schema__page__select_in");
|
||||
try {
|
||||
Xowd_page_tbl__id wkr = new Xowd_page_tbl__id();
|
||||
wkr.Ctor(this, tbl_name, fld_id);
|
||||
wkr.Init(rv, hash);
|
||||
wkr.Select_in(cancelable, conn, bgn, end);
|
||||
} finally {conn.Txn_end();}
|
||||
Xowd_page_tbl__id wkr = new Xowd_page_tbl__id(rv, hash, show_progress);
|
||||
wkr.Ctor(this, tbl_name, fld_id);
|
||||
wkr.Select_in(cancelable, conn, bgn, end);
|
||||
return true;
|
||||
}
|
||||
public byte[] Select_random(Xow_ns ns) {// ns should be ns_main
|
||||
|
||||
@@ -19,10 +19,14 @@ package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.core.criterias.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
class Xowd_page_tbl__id extends Xowd_page_tbl__in_wkr__base {
|
||||
private List_adp list; // list is original list of ids which may have dupes; needed to fill statement (which takes range of bgn - end); DATE:2013-12-08
|
||||
private Ordered_hash hash; // hash is unique list of ids; needed for fetch from rdr (which indexes by id)
|
||||
public void Init(List_adp list, Ordered_hash hash) {this.list = list; this.hash = hash; this.Fill_idx_fields_only_(true);}
|
||||
@Override protected boolean Show_progress() {return true;}
|
||||
private final List_adp list; // list is original list of ids which may have dupes; needed to fill statement (which takes range of bgn - end); DATE:2013-12-08
|
||||
private final Ordered_hash hash; // hash is unique list of ids; needed for fetch from rdr (which indexes by id)
|
||||
public Xowd_page_tbl__id(List_adp list, Ordered_hash hash, boolean show_progress) {
|
||||
this.show_progress = show_progress;
|
||||
this.list = list; this.hash = hash;
|
||||
this.Fill_idx_fields_only_(true);
|
||||
}
|
||||
@Override protected boolean Show_progress() {return show_progress;} private final boolean show_progress;
|
||||
@Override protected Criteria In_filter(Object[] part_ary) {
|
||||
return Db_crt_.New_in(this.In_fld_name(), part_ary);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.*;
|
||||
public interface Xowd_text_bry_owner {
|
||||
int Page_id();
|
||||
void Set_text_bry_by_db(byte[] v);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public interface Xodb_load_mgr {
|
||||
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);
|
||||
void Load_ctg_v2a (Xoctg_view_ctg rv, Xoctg_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);
|
||||
|
||||
@@ -56,21 +56,21 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
rv.Text_(text_bry);
|
||||
}
|
||||
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, rv, bgn, end);}
|
||||
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) {
|
||||
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) {
|
||||
public void Load_ctg_v2a(Xoctg_view_ctg rv, Xoctg_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);
|
||||
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) {
|
||||
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) {
|
||||
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;
|
||||
@@ -83,7 +83,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
rv.Grp_by_tid(i).Itms_last_sortkey_(last_ctg.Sortkey());
|
||||
}
|
||||
}
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_in__id(Cancelable_.Never, list);
|
||||
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) {
|
||||
int len = list.Count();
|
||||
@@ -157,7 +157,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
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();
|
||||
link_list.Sort_by(Xowd_page_itm_sorter.IdAsc);
|
||||
core_data_mgr.Tbl__page().Select_in__id(Cancelable_.Never, false, link_list, 0, link_list_len);
|
||||
core_data_mgr.Tbl__page().Select_in__id(Cancelable_.Never, false, true, link_list, 0, link_list_len);
|
||||
link_list.Sort_by(Xowd_page_itm_sorter.Ns_id_TtlAsc);
|
||||
boolean rv = false;
|
||||
for (int i = 0; i < link_list.Count(); i++) {
|
||||
|
||||
@@ -100,7 +100,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
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();
|
||||
wiki.Db_mgr_as_sql().Load_mgr().Load_ctg_v2a(view_ctg, ctg_url, expd.Ttl(), limit);
|
||||
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_mok_grp mok_grp = expd.Grps_get_or_new(i);
|
||||
|
||||
@@ -522,7 +522,7 @@ 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) {
|
||||
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);
|
||||
|
||||
@@ -22,10 +22,11 @@ public class Xow_abrv_wm_ {
|
||||
public static Xow_abrv_wm Parse_to_abrv_or_null(byte[] src) { // EX: parse "enwiki" to abrv_itm
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return null; // empty bry
|
||||
Object o = bry_trie.Match_bgn(src, src_len - 1, -1); if (o == null) return null;
|
||||
Btrie_rv trv = new Btrie_rv();
|
||||
Object o = bry_trie.Match_at(trv, src, src_len - 1, -1); if (o == null) return null;
|
||||
Xow_abrv_wm rv = Xow_abrv_wm_override.To_abrv_itm_or_null(src); if (rv != null) return rv;
|
||||
int domain_type = ((Int_obj_ref)o).Val();
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_intl(src, 0, bry_trie.Match_pos() + 1);
|
||||
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_intl(src, 0, trv.Pos() + 1);
|
||||
return new Xow_abrv_wm(src, lang_itm.Key(), lang_itm, domain_type);
|
||||
}
|
||||
public static Xow_domain_itm Parse_to_domain_itm(byte[] src) { // EX: parse "enwiki" to "en.wikipedia.org" itm
|
||||
@@ -36,7 +37,8 @@ public class Xow_abrv_wm_ {
|
||||
public static byte[] Parse_to_domain_bry(byte[] src) { // EX: parse "enwiki" to en.wikipedia.org
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return null; // empty bry
|
||||
Object o = bry_trie.Match_bgn(src, src_len - 1, - 1); if (o == null) return null;
|
||||
Btrie_rv trv = new Btrie_rv();
|
||||
Object o = bry_trie.Match_at(trv, src, src_len - 1, - 1); if (o == null) return null;
|
||||
int domain_type = -1;
|
||||
byte[] lang = null;
|
||||
Xow_abrv_wm rv = Xow_abrv_wm_override.To_abrv_itm_or_null(src);
|
||||
@@ -49,11 +51,11 @@ public class Xow_abrv_wm_ {
|
||||
}
|
||||
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__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__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:
|
||||
@@ -65,7 +67,7 @@ public class Xow_abrv_wm_ {
|
||||
case Xow_domain_tid_.Int__wikivoyage:
|
||||
case Xow_domain_tid_.Int__wikimedia:
|
||||
if (lang == null) {
|
||||
lang = Bry_.Mid(src, 0, bry_trie.Match_pos() + 1); // en
|
||||
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
|
||||
lang = Bry_.Replace_create(lang, Byte_ascii.Underline, Byte_ascii.Dash);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.langs.vnts.*;
|
||||
import gplx.xowa.guis.views.*; import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.wikis.pages.redirects.*;
|
||||
import gplx.xowa.guis.views.*; import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.wikis.pages.dbs.*; import gplx.xowa.wikis.pages.redirects.*;
|
||||
public class Xow_page_mgr implements Gfo_invk {
|
||||
private final Xowe_wiki wiki;
|
||||
public Xow_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
@@ -69,12 +69,21 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
if (wiki.App().Mode().Tid_is_gui()) // NOTE: must check if gui, else will write during mass build; DATE:2014-05-03
|
||||
wiki.Appe().Usr_dlg().Prog_many("", "", "loading page for ~{0}", ttl.Raw());
|
||||
|
||||
// load page_info
|
||||
rv.Db().Page().Id_(page_row.Id()).Modified_on_(page_row.Modified_on()).Html_db_id_(page_row.Html_db_id());
|
||||
|
||||
// load from text table
|
||||
wiki.Db_mgr().Load_mgr().Load_page(page_row, ns);
|
||||
byte[] wtxt = page_row.Text();
|
||||
rv.Db().Text().Text_bry_(wtxt);
|
||||
rv.Db().Page().Id_(page_row.Id()).Modified_on_(page_row.Modified_on()).Html_db_id_(page_row.Html_db_id());
|
||||
if (redirect_force) return; // redirect_force passed; return page now, even if page is a redirect elsewhere
|
||||
if (redirect_force) return; // redirect_force passed; return page now, even if page is a redirect elsewhere; NOTE: only applies to WTXT, not HTML
|
||||
|
||||
// handle redirects for html_dbs
|
||||
if ( page_row.Redirect_id() > 0 // redirect exists
|
||||
&& Bry_.Len_eq_0(wtxt)) { // wikitext is not found
|
||||
Redirect_to_html_page(rv, wiki, page_row);
|
||||
return;
|
||||
}
|
||||
|
||||
// handle redirects
|
||||
Xoa_ttl redirect_ttl = wiki.Redirect_mgr().Extract_redirect(wtxt);
|
||||
@@ -89,6 +98,20 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
ttl = redirect_ttl;
|
||||
}
|
||||
}
|
||||
private void Redirect_to_html_page(Xoae_page rv, Xowe_wiki wiki, Xowd_page_itm page_row) { // handle redirects for HtmlDbs; PAGE:fr.b:Wikibooks DATE:2016-07-14
|
||||
// load redirect
|
||||
Xowd_page_itm redirect_row = new Xowd_page_itm();
|
||||
wiki.Db_mgr().Load_mgr().Load_by_id(redirect_row, page_row.Redirect_id());
|
||||
if (rv.Db().Page().Exists_n()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// set redirect data
|
||||
rv.Db().Page().Id_(redirect_row.Id()).Modified_on_(redirect_row.Modified_on()).Html_db_id_(redirect_row.Html_db_id());
|
||||
Xoa_ttl redirect_ttl = wiki.Ttl_parse(redirect_row.Ns_id(), redirect_row.Ttl_page_db());
|
||||
rv.Ttl_(redirect_ttl);
|
||||
rv.Redirect().Itms__add__article(Xoa_url.New(wiki, redirect_ttl), redirect_ttl, Bry_.Empty); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
}
|
||||
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl) {return Load_page_and_parse(url, ttl, wiki.Lang(), wiki.Appe().Gui_mgr().Browser_win().Active_tab(), true);}
|
||||
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl, Xol_lang_itm lang, Xog_tab_itm tab, boolean parse_page) {
|
||||
wiki.Init_assert();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class Xopg_db_data {
|
||||
public void Clear() {
|
||||
page.Clear();
|
||||
html.Clear();
|
||||
// text.Clear();
|
||||
// protection.Clear();
|
||||
text.Clear();
|
||||
protection.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xopg_db_html {
|
||||
public byte[] Html_bry() {return html_bry;} private byte[] html_bry = Bry_.Empty; // NOTE: if null, will cause NullPointer exception on Special pages like Special:XowaDownloadCentral; DATE:2016-07-05
|
||||
public Xopg_db_html() {this.Clear();}
|
||||
public byte[] Html_bry() {return html_bry;} private byte[] html_bry;
|
||||
public void Html_bry_(byte[] v) {this.html_bry = v;}
|
||||
public int Zip_tid() {return zip_tid;} private int zip_tid;
|
||||
public int Hzip_tid() {return hzip_tid;} private int hzip_tid;
|
||||
public void Zip_tids_(int zip_tid, int hzip_tid) {this.zip_tid = zip_tid; this.hzip_tid = hzip_tid;}
|
||||
public void Clear() {
|
||||
html_bry = null; zip_tid = -1; hzip_tid = -1;
|
||||
html_bry = Bry_.Empty; // NOTE: if null, will cause NullPointer exception on Special pages like Special:XowaDownloadCentral; DATE:2016-07-05
|
||||
zip_tid = 0;
|
||||
hzip_tid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,16 +18,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xopg_db_page {
|
||||
public Xopg_db_page() {this.Clear();}
|
||||
// from page table
|
||||
public boolean Exists() {return exists;} private boolean exists = true;
|
||||
public boolean Exists() {return exists;} private boolean exists;
|
||||
public boolean Exists_n() {return !exists;}
|
||||
public int Id() {return id;} private int id;
|
||||
public int Ns_id() {return ns_id;} private int ns_id;
|
||||
public byte[] Ttl_bry() {return ttl_bry;} private byte[] ttl_bry;
|
||||
public DateAdp Modified_on() {return modified_on;} private DateAdp modified_on = DateAdp_.MinValue; // NOTE: must set to MinValue else some tests will fail
|
||||
public DateAdp Modified_on() {return modified_on;} private DateAdp modified_on;
|
||||
public int Text_len() {return text_len;} private int text_len;
|
||||
public int Text_db_id() {return text_db_id;} private int text_db_id;
|
||||
public int Html_db_id() {return html_db_id;} private int html_db_id;
|
||||
public int Html_db_id() {return html_db_id;} private int html_db_id;
|
||||
public int Redirect_to_id() {return redirect_to_id;} private int redirect_to_id;
|
||||
public int Score() {return score;} private int score;
|
||||
|
||||
@@ -55,6 +56,8 @@ public class Xopg_db_page {
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
exists = true;
|
||||
this.exists = true;
|
||||
this.modified_on = DateAdp_.MinValue; // NOTE: must set to MinValue else some tests will fail
|
||||
this.html_db_id = -1; // NOTE: must set to -1 b/c code checks for -1 to indicate no html; DATE:2016-07-14
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xopg_db_protection {
|
||||
public byte[] User() {return user;} public Xopg_db_protection User_(byte[] v) {user = v; return this;} private byte[] user = Bry_.Empty;
|
||||
public byte[] Protection_level() {return protection_level;} public Xopg_db_protection Protection_level_(byte[] v) {protection_level = v; return this;} private byte[] protection_level = Bry_.Empty;
|
||||
public byte[] Protection_expiry() {return protection_expiry;} private byte[] protection_expiry = Bry__protection_expiry__infinite;
|
||||
public Xopg_db_protection() {this.Clear();}
|
||||
public byte[] User() {return user;} public Xopg_db_protection User_(byte[] v) {user = v; return this;} private byte[] user;
|
||||
public byte[] Protection_level() {return protection_level;} public Xopg_db_protection Protection_level_(byte[] v) {protection_level = v; return this;} private byte[] protection_level;
|
||||
public byte[] Protection_expiry() {return protection_expiry;} private byte[] protection_expiry;
|
||||
|
||||
public void Clear() {
|
||||
this.user = Bry_.Empty;
|
||||
this.protection_level = Bry_.Empty;
|
||||
this.protection_expiry = Bry__protection_expiry__infinite;
|
||||
}
|
||||
|
||||
public static final byte[] Bry__protection_expiry__infinite = Bry_.new_a7("infinite");
|
||||
}
|
||||
|
||||
@@ -19,4 +19,7 @@ package gplx.xowa.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gpl
|
||||
public class Xopg_db_text {
|
||||
public byte[] Text_bry() {return text_bry;} private byte[] text_bry = Bry_.Empty; // NOTE: if null, will cause NullPointer exception on Special pages like Special:XowaDownloadCentral; DATE:2016-07-05
|
||||
public void Text_bry_(byte[] v) {this.text_bry = v;}
|
||||
public void Clear() {
|
||||
// text_bry = Bry_.Empty; // TOMBSTONE: do not set to Bry_.Empty else causes mass parse to noop; also causes Options/Files.Clear to noop; DATE:2016-07-15
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@ 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.pages.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.htmls.tocs.*;
|
||||
import gplx.xowa.addons.htmls.tocs.*;
|
||||
public class Xopg_hdump_data {
|
||||
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.New();
|
||||
public Xoh_toc_wtr Toc_wtr() {return toc_wtr;} private final Xoh_toc_wtr toc_wtr = new Xoh_toc_wtr();
|
||||
public void Clear() {
|
||||
imgs.Clear();
|
||||
toc_wtr.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.pages.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.heads.*;
|
||||
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;
|
||||
@@ -48,6 +48,9 @@ public class Xopg_html_data {
|
||||
public boolean Cbk_enabled() {return cbk_enabled;} private boolean cbk_enabled; public void Cbk_enabled_(boolean v) {this.cbk_enabled = v;}
|
||||
public boolean Hdump_exists() {return hdump_exists;} private boolean hdump_exists; public void Hdump_exists_(boolean v) {this.hdump_exists = v;}
|
||||
|
||||
public boolean Writing_hdr_for_toc() {return writing_hdr_for_toc;} private boolean writing_hdr_for_toc; public void Writing_hdr_for_toc_y_() {writing_hdr_for_toc = Bool_.Y;} public void Writing_hdr_for_toc_n_() {writing_hdr_for_toc = Bool_.N;}
|
||||
public Xoh_toc_mgr Toc_mgr() {return toc_mgr;} private final Xoh_toc_mgr toc_mgr = new Xoh_toc_mgr();
|
||||
|
||||
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
|
||||
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
|
||||
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
|
||||
@@ -68,6 +71,7 @@ public class Xopg_html_data {
|
||||
public byte[] Custom_tab_name() {return custom_tab_name;} public Xopg_html_data Custom_tab_name_(byte[] v) {custom_tab_name = v; return this;} private byte[] custom_tab_name;
|
||||
public void Clear() {
|
||||
redlink_list.Clear();
|
||||
toc_mgr.Clear();
|
||||
|
||||
html_restricted = true;
|
||||
display_ttl = content_sub = display_ttl_vnt = null;
|
||||
|
||||
57
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_toc_mgr.java
Normal file
57
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_toc_mgr.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.pages.wtxts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.hdrs.*;
|
||||
public class Xopg_toc_mgr {
|
||||
private Xop_hdr_tkn[] hdrs_ary = Xop_hdr_tkn.Ary_empty; private int hdrs_max, hdrs_len;
|
||||
public boolean Enabled() {
|
||||
return !flag__notoc // __NOTOC__ not set
|
||||
&& hdrs_len != 0 // never show TOC if 0 headers, even when __FORCETOC__
|
||||
&& ( hdrs_len > Hdrs_min // show TOC automatically if 4 or more headers
|
||||
|| flag__toc // or when __TOC__ specified (EX: 2 headers)
|
||||
|| flag__forcetoc // or when __FORCETOC__ to (a) show TOC when < 4 headers or (b) let TOC show at default position; __TOC__ would force TOC to show at __TOC__; __FORCETOC__ can be placed at bottom of page
|
||||
)
|
||||
;
|
||||
}
|
||||
public boolean Flag__toc() {return flag__toc;}
|
||||
public void Flag__toc_y_() {flag__toc = true;} private boolean flag__toc; // __TOC__
|
||||
public void Flag__forcetoc_y_() {flag__forcetoc = true;} private boolean flag__forcetoc; // __FORCETOC__
|
||||
public void Flag__notoc_y_() {flag__notoc = true;} private boolean flag__notoc; // __NOTOC__
|
||||
|
||||
public int Len() {return hdrs_len;}
|
||||
public Xop_hdr_tkn Get_at(int i) {return hdrs_ary[i];}
|
||||
public void Add(Xop_hdr_tkn hdr) {
|
||||
// add tkn
|
||||
if (hdrs_len == 0) hdr.First_in_doc_y_(); // if 1st hdr, mark it; easier for toc-insertion logic later
|
||||
|
||||
// add to list; logic for bounds checking
|
||||
int new_len = hdrs_len + 1;
|
||||
if (new_len > hdrs_max) {
|
||||
hdrs_max = (new_len * 2) + 1;
|
||||
hdrs_ary = (Xop_hdr_tkn[])Array_.Resize(hdrs_ary, hdrs_max);
|
||||
}
|
||||
hdrs_ary[hdrs_len] = hdr;
|
||||
hdrs_len = new_len;
|
||||
}
|
||||
public void Clear() {
|
||||
flag__toc = flag__forcetoc = flag__notoc = false;
|
||||
hdrs_len = 0; hdrs_max = 0;
|
||||
hdrs_ary = Xop_hdr_tkn.Ary_empty;
|
||||
}
|
||||
public static final int Hdrs_min = 3;
|
||||
}
|
||||
24
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_wtxt_data.java
Normal file
24
400_xowa/src/gplx/xowa/wikis/pages/wtxts/Xopg_wtxt_data.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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.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 void Clear() {
|
||||
toc.Clear();
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ class Xoa_sitelink_div_wtr_fxt {
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(raw_bry);
|
||||
wiki.Parser_mgr().Main().Parse_page_all_clear(root, ctx, ctx.Tkn_mkr(), raw_bry);
|
||||
wiki.Html_mgr().Html_wtr().Write_all(bfr, ctx, raw_bry, root);
|
||||
wiki.Html_mgr().Html_wtr().Write_doc(bfr, ctx, raw_bry, root);
|
||||
|
||||
Bry_bfr html_bfr = Bry_bfr_.New();
|
||||
wiki.App().Xwiki_mgr__sitelink_mgr().Write_html(html_bfr, wiki, ctx.Page().Slink_list(), gplx.xowa.xtns.wdatas.Wdata_xwiki_link_wtr.Qid_null);
|
||||
|
||||
Reference in New Issue
Block a user