1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2016-01-28 11:29:27 -05:00
parent 686d56fdab
commit 52c36aa4f8
138 changed files with 1415 additions and 646 deletions

View File

@@ -73,7 +73,7 @@ public class Xows_page_allpages implements gplx.core.brys.Bfr_arg, GfoInvkAble,
public int Rslt_list_len() {return rslt_list_len;} public void Rslt_list_len_(int v) {rslt_list_len = v;} private int rslt_list_len;
public Xowd_page_itm[] Rslt_list_ttls() {return rslt_list_ttls;} private Xowd_page_itm[] rslt_list_ttls;
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
wiki.Parser_mgr().Ctx().Cur_page().Html_data().Display_ttl_(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_sp_allpages_hdr));
wiki.Parser_mgr().Ctx().Page().Html_data().Display_ttl_(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_sp_allpages_hdr));
url.Page_bry_(Bry_.Add(Bry_.new_a7("Special:"), ttl.Page_txt_wo_qargs())); // HACK: need to re-set Page b/c href_wtr does not eliminate qargs; DATE:2013-02-08
if (wiki.Domain_tid() == Xow_domain_tid_.Int__home) {wiki.Appe().Usr_dlg().Prog_many(GRP_KEY, "home.invalid", "AllPages not implemented for home wiki"); return;}
if (rslt_list_ttls == null) this.Itms_per_page_(itms_per_page);

View File

@@ -173,8 +173,8 @@ class Xows_page_allpages_fxt {
public Xows_page_allpages_fxt Test_special_gen() {
init_url = app.User().Wikii().Utl__url_parser().Parse(Xows_special_meta_.Itm__all_pages.Ttl_bry());
Xoa_ttl init_ttl = Make_init_ttl();
allpages.Special_gen(wiki, wiki.Parser_mgr().Ctx().Cur_page(), init_url, init_ttl);
if (expd_display_ttl != null) Tfds.Eq(expd_display_ttl, String_.new_u8(wiki.Parser_mgr().Ctx().Cur_page().Html_data().Display_ttl()));
allpages.Special_gen(wiki, wiki.Parser_mgr().Ctx().Page(), init_url, init_ttl);
if (expd_display_ttl != null) Tfds.Eq(expd_display_ttl, String_.new_u8(wiki.Parser_mgr().Ctx().Page().Html_data().Display_ttl()));
if (expd_address_page != null) Tfds.Eq(expd_address_page, String_.new_u8(init_url.Page_bry()));
return this;
}
@@ -191,8 +191,8 @@ class Xows_page_allpages_fxt {
} private Xoa_url init_url = Xoa_url.blank();
public Xows_page_allpages_fxt Test_build_html(String expd) {
Exec_build();
allpages.Build_html(wiki.Parser_mgr().Ctx().Cur_page());
Tfds.Eq_str_lines(expd, String_.new_a7(wiki.Parser_mgr().Ctx().Cur_page().Data_raw()));
allpages.Build_html(wiki.Parser_mgr().Ctx().Page());
Tfds.Eq_str_lines(expd, String_.new_a7(wiki.Parser_mgr().Ctx().Page().Data_raw()));
return this;
}
private void Exec_build() {

View 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
public class Rndm_core_row {
public Rndm_core_row(int type, int total, int interval) {this.type = type; this.total = total; this.interval = interval;}
public final int type;
public final int total;
public final int interval;
}

View File

@@ -0,0 +1,49 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
public class Rndm_core_tbl implements Rls_able {
private final String tbl_name = "rndm_core"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
private final String fld_rndm_uid, fld_rndm_total, fld_rndm_interval;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
public Rndm_core_tbl(Db_conn conn) {
this.conn = conn;
fld_rndm_uid = flds.Add_int("rndm_uid");
fld_rndm_total = flds.Add_int("rndm_total");
fld_rndm_interval = flds.Add_int("rndm_interval");
conn.Rls_reg(this);
}
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_name(tbl_name, "core", fld_rndm_uid)));}
public void Insert(int uid, int total, int interval) {
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear().Val_int(fld_rndm_uid, uid).Val_int(fld_rndm_total, total).Val_int(interval).Exec_insert();
}
public Rndm_core_row Select(int uid) {
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_rndm_uid);
Db_rdr rdr = stmt_select.Clear().Val_int(fld_rndm_uid, uid).Exec_select__rls_manual();
try {
int total = rdr.Read_int(fld_rndm_total);
int interval = rdr.Read_int(fld_rndm_interval);
return new Rndm_core_row(uid, total, interval);
} finally {rdr.Rls();}
}
public void Rls() {
stmt_select = Db_stmt_.Rls(stmt_select);
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
}

View 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
public class Rndm_range_tbl implements Rls_able {
private final String tbl_name = "rng_range"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
private final String fld_rng_uid, fld_rng_idx, fld_rng_page_id;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
public Rndm_range_tbl(Db_conn conn) {
this.conn = conn;
fld_rng_uid = flds.Add_int("rng_uid");
fld_rng_idx = flds.Add_int("rng_idx");
fld_rng_page_id = flds.Add_int("rng_page_id");
conn.Rls_reg(this);
}
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_name(tbl_name, "core", fld_rng_uid, fld_rng_idx)));}
public void Insert(int uid, int idx, int page_id) {
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear().Val_int(fld_rng_uid, uid).Val_int(fld_rng_idx, idx).Val_int(fld_rng_page_id, page_id).Exec_insert();
}
public void Select(int type) {
// if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_rng_uid);
// Db_rdr rdr = stmt_select.Clear().Val_int(fld_rng_type, type).Exec_select__rls_manual();
// try {
// int total = rdr.Read_int(fld_rng_total);
// int interval = rdr.Read_int(fld_rng_interval);
// return new Rndm_core_row(type, total, interval);
// } finally {rdr.Rls();}
}
public void Rls() {
stmt_select = Db_stmt_.Rls(stmt_select);
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
public void Get_random(int uid) {
// Rndm_core_row core_row = core_tbl.Get(uid);
// int rnd = RandomAdp_.new_().Next(core_row.total);
// int idx = rnd / core_row.interval;
// int off = rnd % core_row.interval;
// Rndm_rng_row rng_row = rng_tbl.Get(uid, idx);
// Xowd_page page = page_tbl.Get_by_page_offset(rng_row.page_id_bgn, off);
}
}

View File

@@ -44,7 +44,7 @@ class Xop_randomRootPage_page_fxt {
Tfds.Eq(expd, String_.new_a7(page.Data_raw()));
}
public static Xoae_page Test_special_open(Xowe_wiki wiki, Xows_page special_page, String special_url) {
Xoae_page page = wiki.Parser_mgr().Ctx().Cur_page();
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(special_url));
page.Url_(url);
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7(special_url));

View File

@@ -201,7 +201,7 @@ public class Xosrh_core_tst {
// byte[] url_raw = Bry_.new_a7("Special:Search/" + ttl_str + ((match_tid == Xows_page__search.Match_tid_all) ? "" : "*") + "?fulltext=y" + Xosrh_rslt_itm_sorter.Xto_url_arg(sort_tid) + "&xowa_page_size=1&xowa_page_index=" + page_idx);
// Xoa_url url = url_parser.Parse(url_raw);
// Xoa_ttl ttl = Xoa_ttl.parse(wiki, url_raw);
// Xoae_page page = wiki.Ctx().Cur_page();
// Xoae_page page = wiki.Ctx().Page();
// search_mgr.Special_gen(url, page, wiki, ttl);
// Xosrh_rslt_grp cur_grp = search_mgr.Cur_grp();
// bfr.Mkr_rls();