RandomRootPage: Do not fail to find page for some random selections; also, do not show 'Redirected from redirected_title' [#719]

staging
gnosygnu 4 years ago
parent a6331f5c89
commit a2fe75f402

@ -1,31 +1,61 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs; import gplx.*;
import gplx.core.stores.*; import gplx.dbs.metas.*; import gplx.dbs.engines.*; import gplx.dbs.qrys.*; import gplx.dbs.sys.*; import gplx.dbs.conn_props.*; import gplx.dbs.qrys.bats.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs;
import gplx.Bool_;
import gplx.Double_;
import gplx.Err_;
import gplx.Gfo_log_;
import gplx.Gfo_usr_dlg;
import gplx.Gfo_usr_dlg_;
import gplx.Int_;
import gplx.Io_url;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.Rls_able;
import gplx.String_;
import gplx.core.stores.DataRdr;
import gplx.core.stores.DataRdr_;
import gplx.dbs.conn_props.Db_conn_props_mgr;
import gplx.dbs.engines.Db_engine;
import gplx.dbs.metas.Dbmeta_idx_fld;
import gplx.dbs.metas.Dbmeta_tbl_mgr;
import gplx.dbs.qrys.Db_qry__select_in_tbl;
import gplx.dbs.qrys.Db_qry_delete;
import gplx.dbs.qrys.Db_qry_insert;
import gplx.dbs.qrys.Db_qry_sql;
import gplx.dbs.qrys.Db_qry_update;
import gplx.dbs.qrys.bats.Db_batch_mgr;
import gplx.dbs.sys.Db_sys_mgr;
import gplx.dbs.wkrs.SqlWkrMgr;
public class Db_conn {
private final List_adp rls_list = List_adp_.New();
public Db_conn(Db_engine engine) {
this.engine = engine;
this.sys_mgr = new Db_sys_mgr(this);
this.wkrMgr = new SqlWkrMgr(this);
engine.CtorConn(wkrMgr);
}
public Db_conn_info Conn_info() {return engine.Conn_info();}
public Db_conn_props_mgr Props() {return engine.Props();}
public Db_batch_mgr Batch_mgr() {return engine.Batch_mgr();}
public Db_engine Engine() {return engine;} private final Db_engine engine;
public Db_sys_mgr Sys_mgr() {return sys_mgr;} private final Db_sys_mgr sys_mgr; // autonum and other functions
public Db_engine Engine() {return engine;} private final Db_engine engine;
public Db_sys_mgr Sys_mgr() {return sys_mgr;} private final Db_sys_mgr sys_mgr; // autonum and other functions
public SqlWkrMgr WkrMgr() {return wkrMgr;} private final SqlWkrMgr wkrMgr;
public boolean Eq(Db_conn comp) {return String_.Eq(engine.Conn_info().Db_api(), comp.Conn_info().Db_api());}
public void Txn_bgn(String name) {engine.Txn_bgn(name);}
public void Txn_end() {engine.Txn_end();}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs; import gplx.*;
import gplx.core.criterias.*;
public class Db_crt_ {
@ -28,6 +28,7 @@ public class Db_crt_ {
public static Criteria_fld New_between (String key, Comparable lo, Comparable hi) {return Criteria_fld.new_(key, Criteria_.between_(lo, hi));}
public static Criteria_fld New_in (String key, Object... vals) {return Criteria_fld.new_(key, Criteria_.in_(vals));}
public static Criteria_fld New_like (String key, String pattern) {return Criteria_fld.new_(key, Criteria_.like_(pattern));}
public static Criteria_fld New_like_not (String key, String pattern) {return Criteria_fld.new_(key, Criteria_.Not(Criteria_.like_(pattern)));}
public static Criteria eq_many_(String... ary) {
Criteria rv = null;

@ -1,26 +1,44 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines; import gplx.*; import gplx.dbs.*;
import gplx.core.stores.*; import gplx.dbs.metas.*; import gplx.dbs.sqls.*; import gplx.dbs.conn_props.*; import gplx.dbs.qrys.bats.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines;
import gplx.Gfo_usr_dlg;
import gplx.Io_url;
import gplx.core.stores.DataRdr;
import gplx.dbs.Db_conn;
import gplx.dbs.Db_conn_info;
import gplx.dbs.Db_qry;
import gplx.dbs.Db_rdr;
import gplx.dbs.Db_stmt;
import gplx.dbs.Dbmeta_fld_itm;
import gplx.dbs.Dbmeta_idx_itm;
import gplx.dbs.Dbmeta_tbl_itm;
import gplx.dbs.conn_props.Db_conn_props_mgr;
import gplx.dbs.metas.Dbmeta_tbl_mgr;
import gplx.dbs.qrys.bats.Db_batch_mgr;
import gplx.dbs.sqls.Sql_qry_wtr;
import gplx.dbs.wkrs.SqlWkrMgr;
public interface Db_engine {
String Tid();
Db_conn_info Conn_info();
Db_conn_props_mgr Props();
Db_batch_mgr Batch_mgr();
Sql_qry_wtr Sql_wtr();
void CtorConn(SqlWkrMgr wkrMgr);
Db_engine New_clone(Db_conn_info conn_info);
void Conn_open();
void Conn_term();

@ -1,20 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines.mems; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
import gplx.core.stores.*; import gplx.dbs.metas.*; import gplx.dbs.sqls.*; import gplx.dbs.conn_props.*; import gplx.dbs.qrys.bats.*;
import gplx.dbs.wkrs.SqlWkrMgr;
public class Mem_engine implements Db_engine {
private final Hash_adp tbl_hash = Hash_adp_.New();
Mem_engine(Db_conn_info conn_info) {
@ -27,6 +29,7 @@ public class Mem_engine implements Db_engine {
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
public Mem_exec_select Qry_runner() {return qry_runner;} private Mem_exec_select qry_runner;
public Sql_qry_wtr Sql_wtr() {return sql_wtr;} private final Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__basic();
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
public Db_engine New_clone(Db_conn_info conn_info) {return new Mem_engine(conn_info);}
public Db_stmt Stmt_by_qry(Db_qry qry) {return new Mem_stmt(this, qry);}
public Mem_tbl Tbls__get(String name) {return (Mem_tbl)tbl_hash.Get_by(name);}

@ -1,24 +1,27 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines.mysql; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
import java.sql.*;
public class Mysql_engine extends Db_engine_sql_base {
import gplx.dbs.wkrs.SqlWkrMgr;
import java.sql.*;
public class Mysql_engine extends Db_engine_sql_base {
@Override public String Tid() {return Mysql_conn_info.Tid_const;}
@Override public Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__mysql();}
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
@Override public Db_engine New_clone(Db_conn_info connectInfo) {
Mysql_engine rv = new Mysql_engine();
rv.Ctor(connectInfo);
@ -33,7 +36,7 @@ public class Mysql_engine extends Db_engine_sql_base {
}
public static final Mysql_engine Instance = new Mysql_engine(); Mysql_engine() {}
}
class Mysql_rdr extends Db_data_rdr {
class Mysql_rdr extends Db_data_rdr {
//PATCH:MYSQL:byte actually returned as int by Jdbc ResultSet (or MYSQL impmentation); convert to byte
@Override public byte ReadByte(String key) {return ReadByteOr(key, Byte.MAX_VALUE);}
@Override public byte ReadByteOr(String key, byte or) {

@ -1,26 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines.noops; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
import gplx.core.stores.*; import gplx.dbs.metas.*; import gplx.dbs.sqls.*; import gplx.dbs.conn_props.*; import gplx.dbs.qrys.bats.*;
import gplx.dbs.wkrs.SqlWkrMgr;
public class Noop_engine implements Db_engine {
public String Tid() {return Noop_conn_info.Tid_const;}
public Db_conn_info Conn_info() {return Db_conn_info_.Null;}
public Db_conn_props_mgr Props() {return props;} private final Db_conn_props_mgr props = new Db_conn_props_mgr();
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
public Sql_qry_wtr Sql_wtr() {return sql_wtr;} private final Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__basic();
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
public void Conn_open() {}
public void Conn_term() {}
public Db_engine New_clone(Db_conn_info url) {return this;}

@ -1,24 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines.postgres; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.sqls.*; import gplx.dbs.metas.*;
import java.sql.*;
import gplx.dbs.wkrs.SqlWkrMgr;
import java.sql.Connection;
import java.sql.ResultSet;
public class Postgres_engine extends Db_engine_sql_base {
@Override public String Tid() {return Postgres_conn_info.Tid_const;}
@Override public Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__mysql();}
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
@Override public Db_engine New_clone(Db_conn_info connectInfo) {
Postgres_engine rv = new Postgres_engine();
rv.Ctor(connectInfo);

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines.sqlite; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
import java.sql.*;
import gplx.core.stores.*; import gplx.dbs.engines.*; import gplx.dbs.engines.sqlite.*; import gplx.dbs.metas.*; import gplx.dbs.sqls.*;
@ -21,6 +21,8 @@ import gplx.core.consoles.Console_adp_;
import gplx.core.consoles.Console_adp__sys;
import gplx.core.ios.IoItmFil;
import gplx.dbs.wkrs.SqlWkrMgr;
import gplx.dbs.wkrs.randoms.SqliteRandomWkr;
import org.sqlite.SQLiteConnection;
public class Sqlite_engine extends Db_engine_sql_base {
private final Sqlite_txn_mgr txn_mgr; private final Sqlite_schema_mgr schema_mgr;
@ -30,6 +32,10 @@ public class Sqlite_engine extends Db_engine_sql_base {
}
@Override public String Tid() {return Sqlite_conn_info.Key_const;}
@Override public gplx.dbs.sqls.Sql_qry_wtr Sql_wtr() {return Sql_qry_wtr_.New__sqlite();}
public void CtorConn(SqlWkrMgr wkrMgr) {
wkrMgr.Set(new SqliteRandomWkr());
}
@Override public Db_engine New_clone(Db_conn_info connectInfo) {
Sqlite_engine rv = new Sqlite_engine();
rv.Ctor(connectInfo);
@ -89,7 +95,7 @@ public class Sqlite_engine extends Db_engine_sql_base {
catch (SQLException e) {Gfo_usr_dlg_.Instance.Warn_many("", "", "failed to set busy timeout; err=~{0}", Err_.Message_gplx_log(e));}
return rv;
}
public static final Sqlite_engine Instance = new Sqlite_engine();
public static final Sqlite_engine Instance = new Sqlite_engine();
}
class Db_rdr__sqlite extends Db_rdr__basic { @Override public byte Read_byte(String k) {try {return (byte)Int_.Cast(rdr.getObject(k));} catch (Exception e) {throw Err_.new_exc(e, "db", "read failed", "k", k, "type", Byte_.Cls_val_name);}}
@Override public boolean Read_bool_by_byte(String k) {

@ -1,20 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.engines.tdbs; import gplx.*; import gplx.dbs.*; import gplx.dbs.engines.*;
import gplx.core.stores.*; import gplx.dbs.metas.*; import gplx.dbs.conn_props.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*; import gplx.dbs.qrys.bats.*;
import gplx.dbs.wkrs.SqlWkrMgr;
public class TdbEngine implements Db_engine {
public String Tid() {return Tdb_conn_info.Tid_const;}
public Db_conn_info Conn_info() {return conn_info;} private Db_conn_info conn_info;
@ -22,6 +24,7 @@ public class TdbEngine implements Db_engine {
public Db_batch_mgr Batch_mgr() {return batch_mgr;} private final Db_batch_mgr batch_mgr = new Db_batch_mgr();
public Sql_qry_wtr Sql_wtr() {return sql_wtr;} private final Sql_qry_wtr sql_wtr = Sql_qry_wtr_.New__basic();
public TdbDatabase Db() {return db;} TdbDatabase db;
@Override public void CtorConn(SqlWkrMgr wkrMgr) {}
public void Conn_open() {
Tdb_conn_info tdb_url = (Tdb_conn_info)conn_info;
String url_str = tdb_url.Server();

@ -0,0 +1,20 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.wkrs;
public interface SqlWkr {
String Key();
}

@ -0,0 +1,43 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.wkrs;
import gplx.dbs.Db_conn;
import gplx.dbs.wkrs.randoms.SqlRandomWkr;
import java.util.HashMap;
import java.util.Map;
public class SqlWkrMgr {
private final Map<String, SqlWkr> map = new HashMap<>();
private final Db_conn conn;
public SqlWkrMgr(Db_conn conn) {
this.conn = conn;
}
public SqlWkr Get(String key) {
return map.get(key);
}
public void Set(SqlWkr wkr) {
map.put(wkr.Key(), wkr);
}
public Object ExecRandomObj(String select, String from, String where) {
SqlRandomWkr wkr = (SqlRandomWkr)map.get(SqlWkrMgr.WKR_RANDOM);
return wkr.SelectRandomRow(conn, select, from, where)[0];
}
public static final String WKR_RANDOM = "random";
}

@ -0,0 +1,23 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.wkrs.randoms;
import gplx.dbs.Db_conn;
import gplx.dbs.wkrs.SqlWkr;
public interface SqlRandomWkr extends SqlWkr {
Object[] SelectRandomRow(Db_conn conn, String select, String from, String where);
}

@ -0,0 +1,60 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.wkrs.randoms;
import gplx.RandomAdp_;
import gplx.dbs.Db_conn;
import gplx.dbs.Db_rdr;
import gplx.dbs.Db_rdr_;
import gplx.dbs.wkrs.SqlWkrMgr;
public class SqliteRandomWkr implements SqlRandomWkr {
@Override public String Key() {return SqlWkrMgr.WKR_RANDOM;}
// NOTE: selects only 1 random row to simplify method signature
// * uses COUNT, LIMIT, OFFSET, so should also work for MySQL
// * to return many rows, look at https://stackoverflow.com/questions/4114940/select-random-rows-in-sqlite
// EX: SELECT * FROM table WHERE id IN (SELECT id FROM table ORDER BY RANDOM() LIMIT x)
// Also, note that SQLite does not support TYPE_FORWARD_ONLY so can't jump back and forth thru ResultSet
@Override public Object[] SelectRandomRow(Db_conn conn, String select, String from, String where) {
Db_rdr rdr = Db_rdr_.Empty;
try {
String sqlSuffix = ("FROM " + from + " WHERE " + where);
// get rowCount of resultSet
rdr = conn.Stmt_sql("SELECT COUNT(*) AS RowCount " + sqlSuffix).Exec_select__rls_auto();
int rowCount = rdr.Read_int("RowCount");
// get random row
int random = RandomAdp_.new_().Next(rowCount);
rdr = conn.Stmt_sql("SELECT " + select + " " + sqlSuffix + " LIMIT 1 OFFSET " + random).Exec_select__rls_auto();
// return result
int fldsLen = rdr.Fld_len();
Object[] rv = new Object[fldsLen];
for (int i = 0; i < fldsLen; i++) {
rv[i] = rdr.Read_at(i);
}
return rv;
}
catch (Exception exc) { // for debugging; should log
throw exc;
}
finally {
rdr.Rls();
}
}
}

@ -0,0 +1,51 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.dbs.wkrs.randoms;
import gplx.dbs.Db_conn;
import gplx.dbs.wkrs.SqlWkrMgr;
import java.util.ArrayList;
import java.util.List;
public class TestRandomWkr implements SqlRandomWkr {
private final List<Object[]> list = new ArrayList<>();
private int index = 0;
public void AddRow(Object... ary) {
list.add(ary);
}
public void Clear() {
list.clear();
index = 0;
}
public String SelectRandomRowSelect() {return selectRandomRowSelect;} private String selectRandomRowSelect;
public String SelectRandomRowFrom() {return selectRandomRowFrom;} private String selectRandomRowFrom;
public String SelectRandomRowWhere() {return selectRandomRowWhere;} private String selectRandomRowWhere;
@Override public String Key() {return SqlWkrMgr.WKR_RANDOM;}
@Override public Object[] SelectRandomRow(Db_conn conn, String select, String from, String where) {
this.selectRandomRowSelect = select;
this.selectRandomRowFrom = from;
this.selectRandomRowWhere = where;
return list.get(index++);
}
public static TestRandomWkr New(Db_conn conn) {
TestRandomWkr wkr = new TestRandomWkr();
conn.WkrMgr().Set(wkr);
return wkr;
}
}

@ -1,33 +1,66 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.pages.randoms.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.pages.*; import gplx.xowa.addons.wikis.pages.randoms.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.specials.*;
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.pages.randoms.specials;
import gplx.Bry_;
import gplx.String_;
import gplx.xowa.Xoa_page;
import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xoa_url;
import gplx.xowa.Xoae_page;
import gplx.xowa.Xow_wiki;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.specials.Xow_special_meta;
import gplx.xowa.specials.Xow_special_meta_;
import gplx.xowa.specials.Xow_special_page;
import gplx.xowa.wikis.data.tbls.Xowd_page_tbl;
import gplx.xowa.wikis.nss.Xow_ns;
public class Rndm_root_special implements Xow_special_page {
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
@Override public Xow_special_meta Special__meta() {return new Xow_special_meta(Xow_special_meta_.Src__mw, SPECIAL_KEY);}
@Override public Xow_special_page Special__clone() {return this;}
@Override public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
// get ns
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
Xow_ns ns = wiki.Ns_mgr().Names_get_or_main(ttl.Rest_txt());
// Rndm_addon.Get(wiki).Mgr().Regy().Get_rndm_page_by_ns(ns);
byte[] random_ttl_bry = wiki.Db_mgr().Load_mgr().Find_random_ttl(ns);
byte[] root_bry = Xoa_ttl.Parse(wiki, random_ttl_bry).Root_txt();
wiki.Data_mgr().Redirect(page, ns.Gen_ttl(root_bry));
// get random ttl
String randomTitleString = selectRandomTitle(wiki, ns.Id());
wiki.Data_mgr().RedirectWithoutLoading(page, ns.Gen_ttl(Bry_.new_u8(randomTitleString)));
}
private String selectRandomTitle(Xow_wiki wiki, int ns_id) {
// ISSUE#:719; find pages without "/" and not redirect
// REF.MW:https://github.com/wikimedia/mediawiki/blob/master/includes/specials/SpecialRandomrootpage.php
Xowd_page_tbl pageTbl = wiki.Data__core_mgr().Db__core().Tbl__page();
String where = String_.Format
("p.{0} = {1} AND p.{2} = {3} AND p.{4} NOT LIKE '%/%'"
, pageTbl.Fld_page_ns(), ns_id
, pageTbl.Fld_redirect_id(), Xowd_page_tbl.INVALID_PAGE_ID
, pageTbl.Fld_page_title()
);
return (String)pageTbl.Conn().WkrMgr().ExecRandomObj
( pageTbl.Fld_page_title()
, pageTbl.Tbl_name() + " p"
, where
);
}
public static final String SPECIAL_KEY = "RandomRootPage";
public static final byte[] Display_ttl = Bry_.new_a7("Random Root Page");
public Xow_special_meta Special__meta() {return new Xow_special_meta(Xow_special_meta_.Src__mw, SPECIAL_KEY);}
public static final Xow_special_page Prototype = new Rndm_root_special();
public Xow_special_page Special__clone() {return this;}
public static final byte[] Display_ttl = Bry_.new_a7("Random Root Page");
public static final Xow_special_page Prototype = new Rndm_root_special();
}

@ -1,54 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.pages.randoms.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.pages.*; import gplx.xowa.addons.wikis.pages.randoms.*;
import org.junit.*; import gplx.xowa.specials.*;
public class Rndm_root_special_tst {
@Before public void init() {fxt.Clear();} private Rndm_root_special_fxt fxt = new Rndm_root_special_fxt();
@Test public void Ns_main() {
fxt.Init_create_page("A");
fxt.Init_create_page("A/B/C");
fxt.Test_open("Special:RandomRootPage/Main", "A"); // NOTE: result will always be "A"; "A" -> "A"; "A/B/C" -> "A"
}
@Test public void Ns_help() {
fxt.Init_create_page("Help:A");
fxt.Init_create_page("Help:A/B/C");
fxt.Test_open("Special:RandomRootPage/Help", "Help:A");
}
}
class Rndm_root_special_fxt {
private Xop_fxt parser_fxt; private Rndm_root_special special_page; private Xowe_wiki wiki;
public void Clear() {
parser_fxt = new Xop_fxt();
parser_fxt.Reset();
wiki = parser_fxt.Wiki();
special_page = new gplx.xowa.addons.wikis.pages.randoms.specials.Rndm_root_special();
}
public void Init_create_page(String page) {parser_fxt.Init_page_create(page, page);}
public void Test_open(String special_url, String expd) {
Xoae_page page = Test_special_open(wiki, special_page, special_url);
Tfds.Eq(expd, String_.new_a7(page.Url().Page_bry()));
Tfds.Eq(expd, String_.new_a7(page.Db().Text().Text_bry()));
}
public static Xoae_page Test_special_open(Xowe_wiki wiki, Xow_special_page special_page, String special_url) {
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));
page.Ttl_(ttl);
special_page.Special__gen(wiki, page, url, ttl);
return page;
}
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
import gplx.core.primitives.*; import gplx.core.criterias.*;
import gplx.dbs.*; import gplx.xowa.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.qrys.*;
@ -254,7 +254,7 @@ public class Xowd_page_tbl implements Db_tbl {
private Db_rdr Load_ttls_starting_with_rdr(int ns_id, byte[] ttl_frag, boolean include_redirects, int max_results, int min_page_len, int browse_len, boolean fwd, boolean search_suggest) {
String ttl_frag_str = String_.new_u8(ttl_frag);
Criteria crt_ttl = fwd ? Db_crt_.New_mte(fld_title, ttl_frag_str) : Db_crt_.New_lt(fld_title, ttl_frag_str);
Criteria crt = Criteria_.And_many(Db_crt_.New_eq(fld_ns, ns_id), crt_ttl, Db_crt_.New_mte(fld_len, min_page_len));
Criteria crt = Criteria_.And_many(Db_crt_.New_eq(fld_ns, ns_id), crt_ttl, Db_crt_.New_mte(fld_len, (Integer)min_page_len));
if (!include_redirects)
crt = Criteria_.And(crt, Db_crt_.New_eq(fld_is_redirect, Byte_.Zero));
String[] cols = search_suggest
@ -409,4 +409,5 @@ public class Xowd_page_tbl implements Db_tbl {
public static final String TBL_NAME = "page", FLD__page_cat_db_id = "page_cat_db_id";
public static Xowd_page_tbl Get_by_key(Db_tbl_owner owner) {return (Xowd_page_tbl)owner.Tbls__get_by_key(TBL_NAME);}
public static final int INVALID_PAGE_ID = -1;
public static final int REDIRECT_IS_NULL = -1;
}

@ -1,18 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
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.*;
@ -180,12 +180,12 @@ public class Xow_page_mgr implements Gfo_invk {
page.Redirect_trail().Itms__add__article(trg_url, trg_ttl, null);
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));
}
public void Redirect2(Xowe_wiki wiki2, Xoae_page page, byte[] page_bry) {
Xoa_ttl trg_ttl = Xoa_ttl.Parse(wiki2, page_bry);
Xoa_url trg_url = Xoa_url.New(wiki2.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url);
page.Redirect_trail().Itms__add__article(trg_url, trg_ttl, null);
wiki2.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));
public void RedirectWithoutLoading(Xoae_page page, byte[] ttl_bry) {
// ISSUE#:719:redirect should not call .Load_from_db else redirect info will get lost; EX:"Redirected from trg_ttl" instead of "Redirected from src_ttl"; PAGE:en.s; DATE:2020-05-13
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
Xoa_url url = Xoa_url.New(wiki.Domain_bry(), ttl.Full_db());
page.Ttl_(ttl).Url_(url);
page.Redirect_trail().Itms__add__article(url, ttl, null);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

@ -0,0 +1,98 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.addons.wikis.pages.randoms.specials;
import gplx.Bry_;
import gplx.String_;
import gplx.core.tests.Gftest;
import gplx.dbs.wkrs.randoms.TestRandomWkr;
import gplx.xowa.Xoa_app_fxt;
import gplx.xowa.Xoa_test_;
import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xoa_url;
import gplx.xowa.Xoae_app;
import gplx.xowa.Xoae_page;
import gplx.xowa.Xop_fxt;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.specials.Xow_special_page;
import gplx.xowa.wikis.nss.Xow_ns_;
import org.junit.Test;
public class Rndm_root_specialTest {
private final RandomRootTstr tstr = new RandomRootTstr();
@Test public void NsMain() {
tstr.InitCreatePage("A", "A/B/C");
tstr.Test("Special:RandomRootPage/Main", Xow_ns_.Tid__main, "A"); // NOTE: will always be rootPage; EX: "A" -> "A"; "A/B/C" -> "A"
}
@Test public void NsHelp() {
tstr.InitCreatePage("Help:A", "Help:A/B/C");
tstr.Test("Special:RandomRootPage/Help", Xow_ns_.Tid__help, "Help:A");
}
}
class RandomRootTstr {
private Xowe_wiki wiki;
private Xop_fxt parserTstr;
private TestRandomWkr testRandomWkr;
public RandomRootTstr() {
// init db-aware wiki
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
Xoa_test_.Init__db__edit(wiki);
wiki.Data__core_mgr().Db__text().Tbl__text().Create_tbl(); // NOTE: need to call text.Create_tbl b/c Init__db__edit does not create it
// init parserTstr
this.parserTstr = new Xop_fxt(app, wiki);
// init testRandomWkr
this.testRandomWkr = TestRandomWkr.New(wiki.Data__core_mgr().Db__core().Conn());
}
public void InitCreatePage(String... ary) {
for (String page : ary) {
parserTstr.Init_page_create(page, page);
// add ttl.Root to the testRandomWkr
Xoa_ttl pageTtl = wiki.Ttl_parse(Bry_.new_u8(page));
testRandomWkr.AddRow(String_.new_u8(pageTtl.Root_txt()));
}
}
public void Test(String special_url, int expd_ns, String expd) {
// call Special:RandomRoot
Rndm_root_special special_page = new gplx.xowa.addons.wikis.pages.randoms.specials.Rndm_root_special();
Xoae_page page = Test_special_open(wiki, special_page, special_url);
// test sql
Gftest.Eq__str("page_title", testRandomWkr.SelectRandomRowSelect());
Gftest.Eq__str("page p", testRandomWkr.SelectRandomRowFrom());
Gftest.Eq__str("p.page_namespace = " + expd_ns + " AND p.page_redirect_id = -1 AND p.page_title NOT LIKE '%/%'", testRandomWkr.SelectRandomRowWhere());
// test page
Gftest.Eq__str(expd, page.Url().Page_bry());
Gftest.Eq__str("", page.Db().Text().Text_bry()); // ISSUE#:719:redirect should not load page else redirect info will get lost; EX:"Redirected from trg_ttl" instead of "Redirected from src_ttl"; PAGE:en.s; DATE:2020-05-13
}
public static Xoae_page Test_special_open(Xowe_wiki wiki, Xow_special_page special_page, String special_url) {
Xoae_page page = Init_page(wiki, special_url);
special_page.Special__gen(wiki, page, page.Url(), page.Ttl());
return page;
}
private static Xoae_page Init_page(Xowe_wiki wiki, String url_str) {
// basic boot-strapping to make sure ctx.Page has .Url and .Ttl
byte[] url_bry = Bry_.new_u8(url_str);
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
page.Url_(wiki.Utl__url_parser().Parse(url_bry));
page.Ttl_(Xoa_ttl.Parse(wiki, url_bry));
return page;
}
}
Loading…
Cancel
Save