1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

'v3.7.2.1'

This commit is contained in:
gnosygnu
2016-07-10 23:35:32 -04:00
parent f5f48bb9b1
commit b333db45f8
366 changed files with 4468 additions and 3460 deletions

View File

@@ -30,9 +30,11 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk {
public Xow_script_mgr Scripts() {return scripts;} private final Xow_script_mgr scripts = new Xow_script_mgr();
public Wdata_wiki_mgr Wdata_mgr() {return wdata_mgr;} private final Wdata_wiki_mgr wdata_mgr;
public Xowe_wiki Wiki_commons() {
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(Xow_domain_itm_.Bry__commons);
if (rv != null) rv.Init_assert();
return rv;
synchronized (this) { // LOCK:app-level; DATE:2016-07-06
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(Xow_domain_itm_.Bry__commons);
if (rv != null) rv.Init_assert();
return rv;
}
}
public void Init_by_app() {wdata_mgr.Init_by_app();}
public int Count() {return list.Count();}
@@ -41,9 +43,11 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk {
public Xowe_wiki Get_at_or_null(int i) {return Int_.Between(i, 0, this.Count() - 1) ? (Xowe_wiki)list.Get_at(i) : null;}
public Xow_wiki Get_by_or_null(byte[] key) {return Bry_.Len_eq_0(key) ? null : (Xowe_wiki)hash.Get_by(key);}
public Xow_wiki Get_by_or_make_init_y(byte[] key) {
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(key); if (rv == null) rv = Make_and_add(key);
rv.Init_assert();
return rv;
synchronized (this) { // LOCK:app-level; DATE:2016-07-06
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(key); if (rv == null) rv = Make_and_add(key);
rv.Init_assert();
return rv;
}
}
public Xow_wiki Get_by_or_make_init_n(byte[] key) {return Get_by_or_make(key);}
public Xowe_wiki Get_by_or_make(byte[] key) {

View File

@@ -118,12 +118,8 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
html__hdump_mgr.Load_mgr().Load(rv, ttl);
}
public Xoa_ttl Ttl_parse(byte[] ttl) {return Ttl_parse(ttl, 0, ttl.length);}
public Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end) {return Xoa_ttl.parse(app.Utl__bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), src, src_bgn, src_end);}
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {
Xow_ns ns = ns_mgr.Ids_get_or_null(ns_id);
byte[] raw = Bry_.Add(ns.Name_db_w_colon(), ttl);
return Xoa_ttl.parse(app.Utl__bfr_mkr(), app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, app.Utl_msg_log(), raw, 0, raw.length);
}
public Xoa_ttl Ttl_parse(byte[] src, int src_bgn, int src_end) {return Xoa_ttl.Parse(app.Utl_amp_mgr(), app.Utl_case_mgr(), xwiki_mgr, ns_mgr, src, src_bgn, src_end);}
public Xoa_ttl Ttl_parse(int ns_id, byte[] ttl) {return Xoa_ttl.Parse(this, ns_id, ttl);}
public void Init_needed_y_() {this.init_needed = true;}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {throw Err_.new_unimplemented_w_msg("implemented for Xoa_cfg_mgr");}
}

View File

@@ -17,8 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
public class Xow_page_cache {
private Xowe_wiki wiki;
private Hash_adp_bry cache = Hash_adp_bry.cs(); // NOTE: wiki titles are not case-sensitive when ns is "1st-letter" (EX: w:earth an w:Earth); in these cases, two entries will be stored
private final Xowe_wiki wiki;
private final Hash_adp_bry cache = Hash_adp_bry.cs(); // NOTE: wiki titles are not case-sensitive when ns is "1st-letter" (EX: w:earth an w:Earth); in these cases, two entries will be stored
public Xow_page_cache(Xowe_wiki wiki) {this.wiki = wiki;}
public byte[] Get_or_load_as_src(Xoa_ttl ttl) {
Xow_page_cache_itm rv = Get_or_load_as_itm(ttl);
@@ -26,28 +26,36 @@ public class Xow_page_cache {
}
public Xow_page_cache_itm Get_or_load_as_itm(Xoa_ttl ttl) {
byte[] ttl_full_db = ttl.Full_db();
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.Missing()) {
rv = new Xow_page_cache_itm(page.Ttl(), page.Data_raw(), page.Redirected_src());
cache.Add_bry_obj(ttl_full_db, rv);
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());
cache.Add_bry_obj(ttl_full_db, rv);
}
}
return rv;
}
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();
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.Missing() // page exists
|| page.Redirected_src() != null) { // 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.Data_raw(), page.Redirected_src());
cache.Add_bry_obj(ttl_full_db, rv);
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());
cache.Add_bry_obj(ttl_full_db, rv);
}
}
return rv;
}
}
public void Free_mem_all() {
synchronized (this) { // LOCK:app-level; DATE:2016-07-06
cache.Clear();
}
return rv;
}
public void Free_mem_all() {cache.Clear();}
}

View File

@@ -63,11 +63,11 @@ public class Xoctg_html_mgr implements Gfo_invk {
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());
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());
itm_ttl = Xoa_ttl.Parse(wiki, itm.Sort_key());
if (itm_ttl == null)
itm_ttl = Xoa_ttl.parse(wiki, Bry_missing);
itm_ttl = Xoa_ttl.Parse(wiki, Bry_missing);
itm.Missing_y_();
}
itm.Set__ttl__sortkey(itm_ttl, itm.Sort_key());
@@ -95,7 +95,7 @@ public class Xoctg_html_mgr implements Gfo_invk {
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());
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

View File

@@ -31,8 +31,8 @@ public class Xoctg_html_mgr_tst {
}
@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);
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
@@ -253,7 +253,7 @@ class Xoh_ctg_page_fxt {
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));
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;}
@@ -268,7 +268,7 @@ class Xoh_ctg_page_fxt {
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);
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;

View File

@@ -34,7 +34,7 @@ public class Xoctg_pagelist_itms implements gplx.core.brys.Bfr_arg {
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());
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();

View File

@@ -132,18 +132,18 @@ class Xow_data_mgr_fxt {
wiki.Db_mgr().Save_mgr().Page_id_next_(0);
}
public Xow_data_mgr_fxt Create(String ttl_str, String data) {
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str));
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
wiki.Db_mgr().Save_mgr().Data_create(ttl, Bry_.new_u8(data));
return this;
}
public Xow_data_mgr_fxt Update(String ttl_str, String data) {
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str));
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
Xoae_page page = Xoae_page.New_test(wiki, ttl);
wiki.Db_mgr().Save_mgr().Data_update(page, Bry_.new_u8(data));
return this;
}
public Xow_data_mgr_fxt Rename(String old_ttl, String new_ttl) {
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(old_ttl));
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(old_ttl));
Xoae_page page = Xoae_page.New_test(wiki, ttl);
wiki.Db_mgr().Save_mgr().Data_rename(page, ttl.Ns().Id(), Bry_.new_u8(new_ttl));
return this;

View File

@@ -32,7 +32,7 @@ public class Xow_db_file {
this.tbl__site_stats = new Xow_site_stats_tbl(conn, schema_is_1);
this.tbl__page = new Xowd_page_tbl(conn, schema_is_1);
this.tbl__text = new Xowd_text_tbl(conn, schema_is_1, props.Zip_tid_text());
this.tbl__html = new Xoh_page_tbl(conn);
this.tbl__html = new Xowd_html_tbl(conn);
this.tbl__css_core = new Xowd_css_core_tbl(conn);
this.tbl__css_file = new Xowd_css_file_tbl(conn);
this.tbl__cat_core = new Xowd_cat_core_tbl(conn, schema_is_1);
@@ -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 Xoh_page_tbl Tbl__html() {return tbl__html;} private final Xoh_page_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;

View File

@@ -20,8 +20,8 @@ public class Xow_page_fetcher_wiki implements Xow_page_fetcher {
public Xow_page_fetcher Wiki_(Xowe_wiki v) {this.wiki = v; return this;} private Xowe_wiki wiki;
public void Clear() {}
public byte[] Get_by(int ns_id, byte[] ttl_bry) {
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ns_id, ttl_bry);
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ns_id, ttl_bry);
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // go through data_mgr in case of redirects
return page.Missing() ? null : page.Data_raw();
return page.Db().Page().Exists_n() ? null : page.Db().Text().Text_bry();
}
}

View File

@@ -20,6 +20,7 @@ import gplx.core.primitives.*; import gplx.core.criterias.*;
import gplx.dbs.*; import gplx.xowa.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.qrys.*;
import gplx.xowa.wikis.nss.*;
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;
@@ -107,15 +108,17 @@ public class Xowd_page_tbl implements Rls_able {
}
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));
Db_rdr rdr = stmt_select_all_by_ttl.Clear().Crt_int(fld_ns, ns.Id()).Crt_bry_as_str(fld_title, ttl).Exec_select__rls_manual();
try {
if (rdr.Move_next()) {
Read_page__all(rv, rdr);
return true;
synchronized (thread_lock) { // LOCK:stmt-rls; DATE:2016-07-06
Db_rdr rdr = stmt_select_all_by_ttl.Clear().Crt_int(fld_ns, ns.Id()).Crt_bry_as_str(fld_title, ttl).Exec_select__rls_manual();
try {
if (rdr.Move_next()) {
Read_page__all(rv, rdr);
return true;
}
}
finally {rdr.Rls();}
return false;
}
finally {rdr.Rls();}
return false;
}
public boolean Select_by_id(Xowd_page_itm rv, int page_id) {
if (stmt_select_all_by_id == null) stmt_select_all_by_id = conn.Stmt_select(tbl_name, flds_select_all, fld_id);
@@ -344,10 +347,12 @@ public class Xowd_page_tbl implements Rls_able {
return fld_score == Dbmeta_fld_itm.Key_null ? page_len : rdr.Read_int(fld_score);
}
public void Rls() {
stmt_select_all_by_ttl = Db_stmt_.Rls(stmt_select_all_by_ttl);
stmt_select_all_by_id = Db_stmt_.Rls(stmt_select_all_by_id);
stmt_select_id_by_ttl = Db_stmt_.Rls(stmt_select_id_by_ttl);
stmt_insert = Db_stmt_.Rls(stmt_insert);
synchronized (thread_lock) {// LOCK:stmt-rls; DATE:2016-07-06
stmt_select_all_by_ttl = Db_stmt_.Rls(stmt_select_all_by_ttl);
stmt_select_all_by_id = Db_stmt_.Rls(stmt_select_all_by_id);
stmt_select_id_by_ttl = Db_stmt_.Rls(stmt_select_id_by_ttl);
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
}
public static final String Page_touched_fmt = "yyyyMMddHHmmss";
}

View File

@@ -18,6 +18,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.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xowd_text_tbl implements Rls_able {
private final Object thread_lock = new Object();
private final String tbl_name = "text"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld_page_id, fld_text_data;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
@@ -43,21 +44,25 @@ public class Xowd_text_tbl implements Rls_able {
stmt.Clear().Val_bry(fld_text_data, text).Crt_int(fld_page_id, page_id).Exec_update();
}
public byte[] Select(int page_id) {
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_page_id);
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, page_id).Exec_select__rls_manual();
try {
byte[] rv = Bry_.Empty;
if (rdr.Move_next()) {
rv = rdr.Read_bry(fld_text_data);
if (rv == null) rv = Bry_.Empty; // NOTE: defect wherein blank page inserts null not ""; for now always convert null to empty String; DATE:2015-11-08
rv = zip_mgr.Unzip(zip_tid, rv);
}
return rv;
} finally {rdr.Rls();}
synchronized (thread_lock) { // LOCK:stmt-rls; DATE:2016-07-06
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_page_id);
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, page_id).Exec_select__rls_manual();
try {
byte[] rv = Bry_.Empty;
if (rdr.Move_next()) {
rv = rdr.Read_bry(fld_text_data);
if (rv == null) rv = Bry_.Empty; // NOTE: defect wherein blank page inserts null not ""; for now always convert null to empty String; DATE:2015-11-08
rv = zip_mgr.Unzip(zip_tid, rv);
}
return rv;
} finally {rdr.Rls();}
}
}
public byte[] Zip(byte[] data) {return zip_mgr.Zip(zip_tid, data);}
public void Rls() {
stmt_select = Db_stmt_.Rls(stmt_select);
stmt_insert = Db_stmt_.Rls(stmt_insert);
synchronized (thread_lock) { // LOCK:stmt-rls; DATE:2016-07-06
stmt_select = Db_stmt_.Rls(stmt_select);
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
}
}

View File

@@ -18,6 +18,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_wbase_qid_tbl implements Rls_able {
private final Object thread_lock = new Object();
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld_src_wiki, fld_src_ns, fld_src_ttl, fld_trg_ttl;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
@@ -44,16 +45,20 @@ public class Xowd_wbase_qid_tbl implements Rls_able {
}
public byte[] Select_qid(byte[] src_wiki, byte[] src_ns, byte[] src_ttl) {
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_src_wiki, fld_src_ns, fld_src_ttl);
if (src_ttl_has_spaces) src_ttl = Xoa_ttl.Replace_unders(src_ttl); // NOTE: v2.4.2.1-v2.4.3.2 stores ttl in spaces ("A B"), while xowa will use under form ("A_B"); DATE:2015-04-21
Db_rdr rdr = stmt_select.Clear()
.Crt_bry_as_str(fld_src_wiki, src_wiki).Crt_int(fld_src_ns, Bry_.To_int_or_neg1(src_ns)).Crt_bry_as_str(fld_src_ttl, src_ttl)
.Exec_select__rls_manual();
try {
return rdr.Move_next() ? rdr.Read_bry_by_str(fld_trg_ttl) : null;
} finally {rdr.Rls();}
synchronized (stmt_select) { // LOCK:stmt-rls; DATE:2016-07-06
if (src_ttl_has_spaces) src_ttl = Xoa_ttl.Replace_unders(src_ttl); // NOTE: v2.4.2.1-v2.4.3.2 stores ttl in spaces ("A B"), while xowa will use under form ("A_B"); DATE:2015-04-21
Db_rdr rdr = stmt_select.Clear()
.Crt_bry_as_str(fld_src_wiki, src_wiki).Crt_int(fld_src_ns, Bry_.To_int_or_neg1(src_ns)).Crt_bry_as_str(fld_src_ttl, src_ttl)
.Exec_select__rls_manual();
try {
return rdr.Move_next() ? rdr.Read_bry_by_str(fld_trg_ttl) : null;
} finally {rdr.Rls();}
}
}
public void Rls() {
stmt_insert = Db_stmt_.Rls(stmt_insert);
stmt_select = Db_stmt_.Rls(stmt_select);
synchronized (thread_lock) {
stmt_insert = Db_stmt_.Rls(stmt_insert);
stmt_select = Db_stmt_.Rls(stmt_select);
}
}
}

View File

@@ -99,7 +99,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
view_grp = rv.Grp_by_tid(cur_tid);
prv_tid = cur_tid;
}
Xoa_ttl ttl = Xoa_ttl.parse(wiki, db_page.Ns_id(), db_page.Ttl_page_db());
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());
@@ -167,7 +167,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
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_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);
rv = true;
}

View File

@@ -312,7 +312,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
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());
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++) {

View File

@@ -61,19 +61,19 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
}
public void Data_update(Xoae_page page, byte[] text_raw) {
boolean redirect = db_mgr.Wiki().Redirect_mgr().Is_redirect(text_raw, text_raw.length);
DateAdp modified = update_modified_on_enabled ? DateAdp_.Now() : page.Revision_data().Modified_on();
int page_id = page.Revision_data().Id();
DateAdp modified = update_modified_on_enabled ? DateAdp_.Now() : page.Db().Page().Modified_on();
int page_id = page.Db().Page().Id();
db_mgr.Core_data_mgr().Tbl__page().Update__redirect__modified(page_id, redirect, modified);
Xowd_page_itm db_page = new Xowd_page_itm();
db_mgr.Load_mgr().Load_by_id(db_page, page.Revision_data().Id());
db_mgr.Load_mgr().Load_by_id(db_page, page_id);
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id_or_fail(db_page.Text_db_id()).Tbl__text();
text_tbl.Update(page.Revision_data().Id(), text_raw);
text_tbl.Update(page_id, text_raw);
// int html_db_id = db_page.Html_db_id();
// if (html_db_id != -1)
// db_mgr.Core_data_mgr().Tbl__page().Update__html_db_id(page_id, -1); // zap html_db_id so that next load will repopulate it
}
public void Data_rename(Xoae_page page, int trg_ns, byte[] trg_ttl) {
db_mgr.Core_data_mgr().Tbl__page().Update__ns__ttl(page.Revision_data().Id(), trg_ns, trg_ttl);
db_mgr.Core_data_mgr().Tbl__page().Update__ns__ttl(page.Db().Page().Id(), trg_ns, trg_ttl);
}
public void Clear() {}
}

View File

@@ -88,7 +88,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
DateAdp modified_on = tmp_page.Modified_on();
if (update_modified_on_enabled) {
modified_on = DateAdp_.Now();
page.Revision_data().Modified_on_(modified_on);
page.Db().Page().Modified_on_(modified_on);
}
Xotdb_page_itm_.Txt_page_save(tmp_bfr, db_page.Id(), modified_on, ttl_bry, text, true);
page_rdr.Update(tmp_bfr, page_itm, tmp_bfr.To_bry_and_clear());

View File

@@ -844,6 +844,7 @@ public class Xow_domain_regy {
, "lrc.wikipedia.org"
, "azb.wikipedia.org"
, "ady.wikipedia.org"
, "jam.wikipedia.org"
};
//, "als.wikisource.org"
//, "als.wikinews.org"

View File

@@ -20,7 +20,7 @@ import gplx.xowa.langs.msgs.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
import gplx.xowa.htmls.hrefs.*;
public class Xow_wiki_props implements Gfo_invk {
public byte[] Main_page() {return main_page;} private byte[] main_page = Xoa_page_.Main_page_bry; // HACK: default to Main_Page b/c some code tries to do Xoa_ttl.parse() which will not work with ""; DATE:2014-02-16
public byte[] Main_page() {return main_page;} private byte[] main_page = Xoa_page_.Main_page_bry; // HACK: default to Main_Page b/c some code tries to do Xoa_ttl.Parse() which will not work with ""; DATE:2014-02-16
public Xow_wiki_props Main_page_(byte[] v) {main_page = v; return this;}
public void Main_page_update(Xowe_wiki wiki) {
siteinfo_mainpage = main_page; // note that main_page came from <siteinfo>; store old value for record's sake

View File

@@ -21,9 +21,10 @@ import gplx.xowa.bldrs.installs.*;
import gplx.xowa.xtns.scribunto.*;
public class Xow_ns_mgr implements Gfo_invk, gplx.core.lists.ComparerAble {
private Ordered_hash id_hash = Ordered_hash_.New(); // hash for retrieval by id
private Hash_adp_bry name_hash; // hash for retrieval by name; note that ns names are case-insensitive "File:" == "fILe:"
private Hash_adp_bry tmpl_hash; // hash for retrieval by name; PERF for templates
private Hash_adp_bry name_hash; // hash for retrieval by name; note that ns names are case-insensitive "File:" == "fILe:"
private Hash_adp_bry tmpl_hash; // hash for retrieval by name; PERF for templates
private Ordered_hash aliases = Ordered_hash_.New(); // hash to store aliases; used to populate name_hash;
private final Int_obj_ref id_hash_ref = Int_obj_ref.New_zero();
public Xow_ns_mgr(Xol_case_mgr case_mgr) {
name_hash = Hash_adp_bry.ci_u8(case_mgr);
tmpl_hash = Hash_adp_bry.ci_u8(case_mgr);
@@ -55,7 +56,7 @@ public class Xow_ns_mgr implements Gfo_invk, gplx.core.lists.ComparerAble {
public Xow_ns Ords_get_at(int ord) {return ords[ord];}
public int Ids_len() {return id_hash.Count();}
public Xow_ns Ids_get_at(int idx) {return (Xow_ns)id_hash.Get_at(idx);}
public Xow_ns Ids_get_or_null(int id) {return (Xow_ns)id_hash.Get_by(ns_hash_lkp.Val_(id));} private Int_obj_ref ns_hash_lkp = Int_obj_ref.New_zero();
public Xow_ns Ids_get_or_null(int id) {synchronized (id_hash_ref) {return (Xow_ns)id_hash.Get_by(id_hash_ref.Val_(id));}} // LOCK:hash-key; DATE:2016-07-06
private Xow_ns Ids_get_or_empty(int id) {
Xow_ns rv = Ids_get_or_null(id);
return rv == null ? Ns__empty : rv;
@@ -161,8 +162,10 @@ public class Xow_ns_mgr implements Gfo_invk, gplx.core.lists.ComparerAble {
break;
}
++ns_count;
if (!id_hash.Has(ns_hash_lkp.Val_(ns_id))) // NOTE: do not add if already exists; avoids alias
synchronized (id_hash_ref) { // LOCK:hash-key; DATE:2016-07-06
if (!id_hash.Has(id_hash_ref.Val_(ns_id))) // NOTE: do not add if already exists; avoids alias
id_hash.Add(Int_obj_ref.New(ns.Id()), ns);
}
name_hash.Add_if_dupe_use_nth(ns.Name_db(), new Xow_ns_mgr_name_itm(ns.Name_db(), ns));
return this;
}

View File

@@ -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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.wikis.pages.tags.*;
import gplx.xowa.wikis.pages.tags.*; import gplx.xowa.wikis.pages.htmls.*;
public class Xopage_html_data {
public Xopage_html_data(byte[] display_ttl, byte[] body) {
this.display_ttl = display_ttl;

View File

@@ -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.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.files.*;
import gplx.xowa.wikis.pages.lnkis.*;
public class Xopg_hdump_data {
public byte[] Body() {return body;} public void Body_(byte[] v) {body = v;} private byte[] body;
public List_adp Imgs() {return imgs;} private final List_adp imgs = List_adp_.New();
public void Imgs_add(Xohd_img_itm itm) {imgs.Add(itm);}
public void Imgs_add_img(Xohd_img_itm__base img, Xof_file_itm xfer, int tid) {
img.Data_init_base
( xfer.Lnki_ttl(), xfer.Lnki_type(), xfer.Lnki_upright(), xfer.Lnki_w(), xfer.Lnki_h(), xfer.Lnki_time(), xfer.Lnki_page()
, xfer.Orig_repo_id(), xfer.Orig_ext().Id(), xfer.File_is_orig(), xfer.File_w()
, xfer.Html_uid(), xfer.Html_w(), xfer.Html_h()
);
imgs.Add(img);
}
public void Clear() {
body = null;
imgs.Clear();
}
}

View File

@@ -17,6 +17,7 @@ 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.core.brys.*; import gplx.core.brys.fmtrs.*;
import gplx.xowa.wikis.pages.htmls.*;
public class Xopg_page_heading implements Bfr_arg {
private Xopg_html_data html_data;
private byte[] display_title;

View File

@@ -19,6 +19,7 @@ package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xo
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.*;
public class Xow_page_mgr implements Gfo_invk {
private final Xowe_wiki wiki;
public Xow_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
@@ -35,11 +36,10 @@ public class Xow_page_mgr implements Gfo_invk {
switch (ns.Id()) {
case Xow_ns_.Tid__special: // Special pages are built (not loaded from db)
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
if (rv.Redirect_to_ttl() != null) {
ttl = wiki.Ttl_parse(rv.Redirect_to_ttl());
url = wiki.Utl__url_parser().Parse(ttl.Raw());
rv.Redirect_to_ttl_(null);
Load_by_ns(rv, url, ttl, called_from_msg);
Xopg_redirect_itm redirect_itm = rv.Redirect().Itms__get_at_nth_or_null();
if (redirect_itm != null) {
rv.Redirect().Clear(); // clear needed; EX: Special:Random -> [[Redirected_page]] -> {must clear here} -> [[Page]]
Load_by_ns(rv, redirect_itm.Url(), redirect_itm.Ttl(), called_from_msg);
}
return;
case Xow_ns_.Tid__mediawiki: // MediaWiki msgs can either be loaded from memory, or from database
@@ -51,7 +51,7 @@ public class Xow_page_mgr implements Gfo_invk {
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
msg_key = lang.Case_mgr().Case_build_1st_lower(tmp_bfr, msg_key, 0, msg_key.length);
byte[] msg_val = Xol_msg_mgr_.Get_msg_itm(tmp_bfr, wiki, wiki.Lang(), msg_key).Val(); // NOTE: do not change to Get_msg_val; Get_msg_val, also replaces $1 with values, and $1 needs to be preserved for callers;
rv.Data_raw_(msg_val);
rv.Db().Text().Text_bry_(msg_val);
tmp_bfr.Mkr_rls();
return;
}
@@ -59,20 +59,21 @@ public class Xow_page_mgr implements Gfo_invk {
}
Load_from_db(rv, ns, ttl, url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}
private void Load_from_db(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean redirect_force) {
public void Load_from_db(Xoae_page rv, Xow_ns ns, Xoa_ttl ttl, boolean redirect_force) {
int redirects = 0;
Xowd_page_itm page_row = Xowd_page_itm.new_tmp();
while (true) { // loop until (a) no more redirects or (b) page not found
// load from page table
boolean exists = wiki.Db_mgr().Load_mgr().Load_by_ttl(page_row, ns, ttl.Page_db());
if (!exists) {rv.Missing_(); return;}
if (!exists) {rv.Db().Page().Exists_n_(); return;}
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 from text table
wiki.Db_mgr().Load_mgr().Load_page(page_row, ns);
byte[] wtxt = page_row.Text();
rv.Data_raw_(wtxt).Revision_data().Modified_on_(page_row.Modified_on()).Id_(page_row.Id()).Html_db_id_(page_row.Html_db_id());
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
// handle redirects
@@ -82,8 +83,7 @@ public class Xow_page_mgr implements Gfo_invk {
return;
// redirect; do some bookkeeping and reset ns / ttl
rv.Redirected_ttls().Add(ttl.Full_url()); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
if (rv.Redirected_src() == null) rv.Redirected_src_(wtxt); // only add src for first redirect; DATE:2014-07-11
rv.Redirect().Itms__add__article(Xoa_url.New(wiki, redirect_ttl), redirect_ttl, wtxt); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
rv.Ttl_(redirect_ttl);
ns = redirect_ttl.Ns();
ttl = redirect_ttl;
@@ -93,17 +93,17 @@ public class Xow_page_mgr implements Gfo_invk {
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();
Xoae_page page = Xoae_page.New(wiki, ttl); page.Tab_data().Tab_(tab);
// COMMENT: breaks bookmark; if (tab != null) tab.Page_ref_(page); // HACK: (1) null check for http server; (2) Page_ref_(page) needed for log in xobc
// COMMENT: breaks position-restore when moving back from history; if (tab != null) tab.Page_ref_(page); // HACK: (1) null check for http server; (2) Page_ref_(page) needed for log in xobc
this.Load_by_ns(page, url, ttl, false);
if (page.Missing()) { // page doesn't exist; try variants
if (page.Db().Page().Exists_n()) { // page doesn't exist; try variants
boolean vnt_missing = true;
Xol_vnt_mgr vnt_mgr = lang.Vnt_mgr();
if (vnt_mgr.Enabled()) { // if vnt enabled, then try to load by vnt form; DATE:2015-09-15
gplx.xowa.wikis.data.tbls.Xowd_page_itm page_itm = vnt_mgr.Convert_mgr().Convert_ttl(wiki, ttl);
if (page_itm != null && page_itm.Exists()) {
Xoa_ttl vnt_ttl = Xoa_ttl.parse(wiki, ttl.Ns().Id(), page_itm.Ttl_page_db());
Xoa_ttl vnt_ttl = Xoa_ttl.Parse(wiki, ttl.Ns().Id(), page_itm.Ttl_page_db());
page = this.Load_page(vnt_ttl, false);
vnt_missing = page.Missing();
vnt_missing = page.Db().Page().Exists_n();
}
}
if (vnt_missing) {
@@ -112,23 +112,25 @@ public class Xow_page_mgr implements Gfo_invk {
if (commons_wiki != null) { // commons exists
if (!Bry_.Eq(wiki.Domain_bry(), commons_wiki.Domain_bry())) { // !Bry_.Eq is recursion guard
Xoae_page rv = commons_wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, true);
if (rv.Exists()) {
if (rv.Db().Page().Exists()) {
rv.Commons_mgr().Source_wiki_(wiki);
return rv;
}
else {
page.Missing_(false);
rv.Db().Page().Exists_y_();
page.Commons_mgr().Xowa_mockup_(true);
return page;
}
}
}
}
else
return page.Missing_();
else {
page.Db().Page().Exists_n_();
return page;
}
}
}
if (page.Missing()) return page; // NOTE: commons can return null page
if (page.Db().Page().Exists_n()) return page; // NOTE: commons can return null page
page.Tab_data().Tab_(tab);
page.Lang_(lang);
if (parse_page)
@@ -136,9 +138,10 @@ public class Xow_page_mgr implements Gfo_invk {
return page;
}
public void Redirect(Xoae_page page, byte[] page_bry) {
Xoa_ttl trg_ttl = Xoa_ttl.parse(wiki, page_bry);
Xoa_url trg_url = Xoa_url.new_(wiki.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url).Redirected_(true);
Xoa_ttl trg_ttl = Xoa_ttl.Parse(wiki, page_bry);
Xoa_url trg_url = Xoa_url.New(wiki.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url);
page.Redirect().Itms__add__special(trg_url, trg_ttl);
wiki.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}

View File

@@ -27,7 +27,7 @@ public class Xowe_page_mgr {
// load page meta; wait_for_popups
Xoae_page page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
boolean hdump_exists = page.Revision_data().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred();
boolean hdump_exists = page.Db().Page().Html_db_id() != -1 && wiki.Appe().Api_root().Wiki().Hdump().Read_preferred();
page.Html_data().Hdump_exists_(hdump_exists);
Wait_for_popups(wiki.App());
@@ -35,7 +35,7 @@ public class Xowe_page_mgr {
boolean parse = true;
if (hdump_exists) {
wiki.Html__hdump_mgr().Load_mgr().Load_by_edit(page);
parse = Bry_.Len_eq_0(page.Hdump_data().Body()); // NOTE: need to check if actually empty for archive.org wikis which included html_db_id without html_dbs; DATE:2016-06-22
parse = Bry_.Len_eq_0(page.Db().Html().Html_bry()); // NOTE: need to check if actually empty for archive.org wikis which included html_db_id without html_dbs; DATE:2016-06-22
}
if (parse)
wiki.Parser_mgr().Parse(page, false);

View File

@@ -0,0 +1,30 @@
/*
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.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_db_data {
public Xopg_db_page Page() {return page;} private final Xopg_db_page page = new Xopg_db_page();
public Xopg_db_text Text() {return text;} private final Xopg_db_text text = new Xopg_db_text();
public Xopg_db_html Html() {return html;} private final Xopg_db_html html = new Xopg_db_html();
public Xopg_db_protection Protection() {return protection;} private final Xopg_db_protection protection = new Xopg_db_protection();
public void Clear() {
page.Clear();
html.Clear();
// text.Clear();
// protection.Clear();
}
}

View File

@@ -0,0 +1,28 @@
/*
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.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 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;
}
}

View File

@@ -0,0 +1,60 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.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 {
// from page table
public boolean Exists() {return exists;} private boolean exists = true;
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 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 Redirect_to_id() {return redirect_to_id;} private int redirect_to_id;
public int Score() {return score;} private int score;
public void Exists_y_() {this.Exists_(Bool_.Y);}
public void Exists_n_() {this.Exists_(Bool_.N);}
public void Exists_(boolean v) {this.exists = v;}
public Xopg_db_page Id_(int v) {this.id = v; return this;}
public Xopg_db_page Modified_on_(DateAdp v) {this.modified_on = v; return this;}
public Xopg_db_page Html_db_id_(int v) {this.html_db_id = v; return this;}
// wiki-related
public Xow_ns Ns() {return ns;} private Xow_ns ns;
public Xoa_ttl Ttl() {return ttl;} private Xoa_ttl ttl;
// init methods
public Xopg_db_page Init_by_db(int id, int ns_id, byte[] ttl_bry, DateAdp modified_on, int text_len, int text_db_id, int html_db_id, int redirect_to_id, int score) {
this.id = id; this.ns_id = ns_id; this.ttl_bry = ttl_bry; this.modified_on = modified_on;
this.text_len = text_len; this.text_db_id = text_db_id; this.html_db_id = html_db_id; this.redirect_to_id = redirect_to_id; this.score = score;
this.ns = null; this.ttl = null;
return this;
}
public Xopg_db_page Init_by_wiki(Xow_wiki wiki) {
this.ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
this.ttl = wiki.Ttl_parse(ns_id, ttl_bry);
return this;
}
public void Clear() {
exists = true;
}
}

View File

@@ -15,14 +15,11 @@ 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; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
public class Xopg_revision_data {
public int Id() {return id;} public Xopg_revision_data Id_(int v) {id = v; return this;} private int id;
public DateAdp Modified_on() {return modified_on;} public Xopg_revision_data Modified_on_(DateAdp v) {modified_on = v; return this;} private DateAdp modified_on = DateAdp_.MinValue;
public byte[] User() {return user;} public Xopg_revision_data User_(byte[] v) {user = v; return this;} private byte[] user = Bry_.Empty;
public byte[] Protection_level() {return protection_level;} public Xopg_revision_data Protection_level_(byte[] v) {protection_level = v; return this;} private byte[] protection_level = Bry_.Empty;
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 int Html_db_id() {return html_db_id;} public void Html_db_id_(int v) {html_db_id = v;} private int html_db_id = -1;
public void Clear() {}// NOTE: do not clear data b/c saving in Edit will call clear and id will be reset to 0
public static final byte[] Bry__protection_expiry__infinite = Bry_.new_a7("infinite");
public static final byte[] Bry__protection_expiry__infinite = Bry_.new_a7("infinite");
}

View File

@@ -15,15 +15,8 @@ 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 class Xowd_html_row {
public Xowd_html_row(int page_id, int tid, byte[] data) {this.page_id = page_id; this.tid = tid; this.data = data;}
public int Page_id() {return page_id;} private final int page_id;
public int Tid() {return tid;} private final int tid;
public byte[] Data() {return data;} private final byte[] data;
public static final int // SERIALIZED
Tid__html = 0
, Tid__img = 1
, Tid__redlink = 2
;
package gplx.xowa.wikis.pages.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
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;}
}

View File

@@ -0,0 +1,27 @@
/*
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.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import gplx.xowa.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();
}
}

View File

@@ -15,11 +15,14 @@ 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; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.xtns.indicators.*;
import gplx.xowa.xtns.pagebanners.*; import gplx.xowa.wikis.pages.tags.*;
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.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;
public void Html_restricted_(boolean v) {html_restricted = v;} public void Html_restricted_n_() {Html_restricted_(Bool_.N);} public void Html_restricted_y_() {Html_restricted_(Bool_.Y);}
public byte[] Display_ttl() {
@@ -64,6 +67,8 @@ public class Xopg_html_data {
public byte[] Custom_body() {return custom_body;} public Xopg_html_data Custom_body_(byte[] v) {custom_body = v; return this;} private byte[] custom_body;
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();
html_restricted = true;
display_ttl = content_sub = display_ttl_vnt = null;
lang_convert_content = lang_convert_title = true;
@@ -89,4 +94,7 @@ public class Xopg_html_data {
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());
}
}

View File

@@ -35,7 +35,7 @@ public class Xopg_lnki_list {
if ( ns.Id_is_file_or_media() // ignore files which will usually not be in local wiki (most are in commons), and whose html is built up separately
|| (ns.Id_is_ctg() && !ttl.ForceLiteralLink()) // ignore ctgs which have their own html builder, unless it is literal; EX: [[:Category:A]]; DATE:2014-02-24
|| ns.Id_is_special() // ignore special, especially Search; EX: Special:Search/Earth
|| ttl.Anch_bgn() == Xoa_ttl.Anch_bgn_anchor_only // anchor only link; EX: [[#anchor]]
|| ttl.Anch_bgn() == Anch_bgn_anchor_only // anchor only link; EX: [[#anchor]]
|| ttl.Wik_itm() != null // xwiki lnki; EX: simplewiki links in homewiki; [[simplewiki:Earth]]
)
return;
@@ -47,4 +47,5 @@ public class Xopg_lnki_list {
}
public static final String Lnki_id_prefix = "xolnki_";
private static final int Anch_bgn_anchor_only = 1; // signifies lnki which is only anchor; EX: [[#anchor]]
}

View File

@@ -24,7 +24,7 @@ public class Xopg_redlink_mgr implements Gfo_invk {
public Xopg_redlink_mgr(Xoa_page page, Xog_js_wkr js_wkr) {this.page = page; this.js_wkr = js_wkr; }
private void Redlink() {
// init; exit if redlink disabled (on Module pages)
Xopg_lnki_list lnki_list = page.Redlink_list(); if (lnki_list.Disabled()) return;
Xopg_lnki_list lnki_list = page.Html_data().Redlink_list(); if (lnki_list.Disabled()) return;
Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
Xow_wiki wiki = page.Wiki();
Ordered_hash lnki_hash = Ordered_hash_.New_bry();

View File

@@ -0,0 +1,34 @@
/*
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.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_redirect_data {
private final List_adp itms = List_adp_.New();
public int Itms__len() {return itms.Len();}
public byte[] Itms__get_at_0th_or_null() {return itms.Len() == 0 ? null : this.Itms__get_at(0).Wikitext();}
public Xopg_redirect_itm Itms__get_at_nth_or_null() {return itms.Len() == 0 ? null : (Xopg_redirect_itm)itms.Get_at(itms.Len() - 1);}
public Xopg_redirect_itm Itms__get_at(int i) {return (Xopg_redirect_itm)itms.Get_at(i);}
public void Itms__add__article(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {Itms__add(url, ttl, wikitext);}
public void Itms__add__special(Xoa_url url, Xoa_ttl ttl) {Itms__add(url, ttl, null);}
private void Itms__add(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {
Xopg_redirect_itm itm = new Xopg_redirect_itm(url, ttl, wikitext);
itms.Add(itm);
}
public void Clear() {
itms.Clear();
}
}

View File

@@ -0,0 +1,29 @@
/*
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.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_redirect_itm {
public Xopg_redirect_itm(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {
this.url = url;
this.ttl = ttl;
this.wikitext = wikitext;
}
public Xoa_url Url() {return url;} private final Xoa_url url; // EX: "en.wikipedia.org/wiki/A"
public Xoa_ttl Ttl() {return ttl;} private final Xoa_ttl ttl; // EX: "A"
public byte[] Wikitext() {return wikitext;} private final byte[] wikitext; // EX: "#REDIRECT [[A]]"
public boolean By_wikitext() {return wikitext != null;} // true if by "#REDIRECT [[A]]"; false if by Special:Random, Special:Search, etc.;
}

View File

@@ -92,7 +92,7 @@ class Xowd_hive_mgr_fxt {
return this;
}
// public void Get(String ttl_str, boolean exists) {
// Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str));
// Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
// Xowd_page_itm row = mgr.Get(ttl.Ns(), ttl.Full_txt());
// Tfds.Eq(exists, row != null);
// }

View File

@@ -0,0 +1,33 @@
/*
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.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xoa_ttl__err_tst {
@Before public void init() {fxt.Clear();} private final Xoa_ttl_fxt fxt = new Xoa_ttl_fxt();
@Test public void Invalid__angle() {fxt.Parse("<!--a").Test__null();}
@Test public void Invalid__brace() {fxt.Parse("[[a]]").Test__null();}
@Test public void Invalid__curly() {fxt.Parse("{{a}}").Test__null();}
@Test public void Colon_is_last() {fxt.Parse("Help:").Test__null();}
@Test public void Len_max() {fxt.Parse(String_.Repeat("A", 512)).Test__page_txt(String_.Repeat("A", 512));}
@Test public void Len_0() {
fxt.Parse("").Test__null();
fxt.Parse(" ").Test__null();
fxt.Parse("_").Test__null();
fxt.Parse("_ _").Test__null();
}
}

View File

@@ -0,0 +1,35 @@
/*
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.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.tests.*;
public class Xoa_ttl_fxt {
private Xowe_wiki wiki;
private String raw;
private Xoa_ttl ttl;
public void Clear() {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
}
public Xoa_ttl_fxt Parse(String raw) {
this.raw = raw;
this.ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(raw));
return this;
}
public void Test__null() {Gftest.Eq__bool_y(ttl == null, "ttl is not null", "raw", raw);}
public void Test__page_txt(String expd) {Gftest.Eq__str(expd, String_.new_u8(ttl.Page_txt()), "page_txt", "raw", raw);}
}

View File

@@ -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.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.log_msgs.*;
public class Xop_ttl_log {
private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "ttl");
public static final Gfo_msg_itm
Len_0 = Gfo_msg_itm_.new_warn_(owner, "Len_0")
, Len_max = Gfo_msg_itm_.new_warn_(owner, "Len_max")
, Ttl_has_ns_but_no_page = Gfo_msg_itm_.new_warn_(owner, "Ttl_has_ns_but_no_page")
, Ttl_is_ns_only = Gfo_msg_itm_.new_warn_(owner, "Ttl_is_ns_only")
, Amp_unknown = Gfo_msg_itm_.new_warn_(owner, "Amp_unknown")
, Comment_eos = Gfo_msg_itm_.new_warn_(owner, "Comment_eos")
, Invalid_char = Gfo_msg_itm_.new_warn_(owner, "Invalid_char")
;
}
class Xop_redirect_log {
private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "redirect");
public static final Gfo_msg_itm
False_match = Gfo_msg_itm_.new_warn_(owner, "False_match")
, Lnki_not_found = Gfo_msg_itm_.new_warn_(owner, "Lnki_not_found")
;
}
class Xop_tag_log {
private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "tag");
public static final Gfo_msg_itm
Invalid = Gfo_msg_itm_.new_warn_(owner, "Invalid")
;
}
// class Pf_func_lang_log {
// private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "tmpl_func_lang");
// public static final Gfo_msg_itm
// Arg_out_of_bounds = Gfo_msg_itm_.new_warn_(owner, "Arg_out_of_bounds")
// ;
// }
// class Mwl_expr_log {
// private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "expr");
// public static final Gfo_msg_itm
// Divide_by_zero = Gfo_msg_itm_.new_warn_(owner, "Divide_by_zero")
// , Expr_len0 = Gfo_msg_itm_.new_warn_(owner, "Expr_len0")
// ;
// }

View File

@@ -1,39 +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.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import org.junit.*;
public class Xow_ttl__err_tst {
@Before public void init() {fxt.Reset();} private Xow_ttl_fxt fxt = new Xow_ttl_fxt();
@Test public void Invalid() {fxt.Init_ttl("<!--A").Expd_err(Xop_ttl_log.Comment_eos).Test();}
@Test public void Invalid_brace() {fxt.Init_ttl("[[a]]").Expd_err(Xop_ttl_log.Invalid_char).Test();}
@Test public void Invalid_curly() {fxt.Init_ttl("{{a}}").Expd_err(Xop_ttl_log.Invalid_char).Test();}
@Test public void Len_0() {
fxt.Init_ttl("").Expd_err(Xop_ttl_log.Len_0).Test();
fxt.Init_ttl(" ").Expd_err(Xop_ttl_log.Len_0).Test();
fxt.Init_ttl("_").Expd_err(Xop_ttl_log.Len_0).Test();
fxt.Init_ttl("_ _").Expd_err(Xop_ttl_log.Len_0).Test();
}
@Test public void Len_max() {
fxt.Init_ttl(String_.Repeat("A", 512)).Expd_page_txt(String_.Repeat("A", 512)).Test();
// fxt.Init_ttl("File:" + String_.Repeat("A", 255)).Expd_page_txt(String_.Repeat("A", 255)).Test(); // DELETE: removing multi-byte check; DATE:2013-02-02
// fxt.Init_ttl(String_.Repeat("A", 256)).Expd_err(Xop_ttl_log.Len_max).Test();
// fxt.Init_ttl("Special:" + String_.Repeat("A", 255)).Expd_ns_id(Xow_ns_.Tid__special).Expd_page_txt(String_.Repeat("A", 255)).Test();
// fxt.Init_ttl("Special:" + String_.Repeat("A", 512 + 8)).Expd_err(Xop_ttl_log.Len_max).Test(); // 8="Special:".length
}
@Test public void Colon_is_last_ns() {fxt.Init_ttl("Help:").Expd_err(Xop_ttl_log.Ttl_is_ns_only).Test();}
}

View File

@@ -57,7 +57,7 @@ class Xow_ttl_fxt {
fxt.Log_clear();
}
public void Test() {
Xoa_ttl actl = Xoa_ttl.parse(fxt.Wiki(), Bry_.new_u8(test_raw));
Xoa_ttl actl = Xoa_ttl.Parse(fxt.Wiki(), Bry_.new_u8(test_raw));
if (expd_err == null) {
if (expd_ns_id != Int_.Min_value) Tfds.Eq(expd_ns_id, actl.Ns().Id(), "ns");
if (expd_xwik_txt != null) Tfds.Eq(expd_xwik_txt, String_.new_u8(actl.Wik_txt()), "Wiki");

View File

@@ -48,7 +48,7 @@ class Xoa_sitelink_div_wtr_fxt {
Xoae_app app;
public void tst(String raw, String expd) {
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
ctx.Page().Ttl_(Xoa_ttl.parse(wiki, Bry_.new_a7("test_page")));
ctx.Page().Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7("test_page")));
byte[] raw_bry = Bry_.new_u8(raw);
Bry_bfr bfr = Bry_bfr_.New();
Xop_root_tkn root = ctx.Tkn_mkr().Root(raw_bry);