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
2015-07-12 21:10:02 -04:00
commit 794b5a232f
3099 changed files with 238212 additions and 0 deletions

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.users.bmks; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
public class Xoud_bmk_dir_row {
public Xoud_bmk_dir_row(int id, int owner, int sort, byte[] name) {
this.id = id; this.owner = owner; this.sort = sort; this.name = name;
}
public int Id() {return id;} private final int id;
public int Owner() {return owner;} private final int owner;
public int Sort() {return sort;} private final int sort;
public byte[] Name() {return name;} private final byte[] name;
}

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.users.bmks; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
import gplx.dbs.*; import gplx.dbs.qrys.*;
public class Xoud_bmk_dir_tbl implements RlsAble {
private final String tbl_name = "bmk_dir"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private final String fld_id, fld_owner, fld_sort, fld_name;
public Xoud_bmk_dir_tbl(Db_conn conn) {
this.conn = conn;
fld_id = flds.Add_int_pkey_autonum("dir_id");
fld_owner = flds.Add_int("dir_owner");
fld_sort = flds.Add_int("dir_sort");
fld_name = flds.Add_str("dir_name", 255);
conn.Rls_reg(this);
}
public Db_conn Conn() {return conn;} private final Db_conn conn;
public String Tbl_name() {return tbl_name;}
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds.To_fld_ary()));}
public void Insert(int owner, int sort, byte[] name) {
Db_stmt stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear()
.Val_int(fld_owner, owner).Val_int(fld_sort, sort).Val_bry_as_str(fld_name, name)
.Exec_insert();
}
public void Update(int id, int owner, int sort, byte[] name) {
Db_stmt stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_id);
stmt_update.Clear()
.Val_int(fld_owner, owner).Val_int(fld_sort, sort).Val_bry_as_str(fld_name, name)
.Crt_int(fld_id, id)
.Exec_update();
}
public void Delete(int id) {
Db_stmt stmt_delete = conn.Stmt_delete(tbl_name, fld_id);
stmt_delete.Clear().Crt_int(fld_id, id).Exec_delete();
}
// private Xoud_bmk_dir_row new_row(Db_rdr rdr) {
// return new Xoud_bmk_dir_row
// ( rdr.Read_int(fld_id)
// , rdr.Read_int(fld_owner)
// , rdr.Read_int(fld_sort)
// , rdr.Read_bry_by_str(fld_name)
// );
// }
public void Rls() {}
}

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.users.bmks; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
public class Xoud_bmk_itm_row {
public Xoud_bmk_itm_row(int id, int owner, int sort, byte[] name, byte[] wiki, byte[] url, byte[] comment) {
this.id = id; this.owner = owner; this.sort = sort; this.name = name; this.wiki = wiki; this.url = url; this.comment = comment;
}
public int Id() {return id;} private final int id;
public int Owner() {return owner;} private final int owner;
public int Sort() {return sort;} private final int sort;
public byte[] Name() {return name;} private final byte[] name;
public byte[] Wiki() {return wiki;} private final byte[] wiki;
public byte[] Url() {return url;} private final byte[] url;
public byte[] Comment() {return comment;} private final byte[] comment;
}

View File

@@ -0,0 +1,92 @@
/*
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.users.bmks; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
import gplx.dbs.*; import gplx.dbs.qrys.*;
public class Xoud_bmk_itm_tbl implements RlsAble {
private final String tbl_name = "bmk_itm"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private final String fld_id, fld_owner, fld_sort, fld_name, fld_wiki, fld_url, fld_comment;
public Xoud_bmk_itm_tbl(Db_conn conn) {
this.conn = conn;
fld_id = flds.Add_int_pkey_autonum("itm_id");
fld_owner = flds.Add_int("itm_owner");
fld_sort = flds.Add_int("itm_sort");
fld_name = flds.Add_str("itm_name", 255);
fld_wiki = flds.Add_str("itm_wiki", 255);
fld_url = flds.Add_str("itm_url", 255);
fld_comment = flds.Add_str("itm_comment", 255);
conn.Rls_reg(this);
}
public Db_conn Conn() {return conn;} private final Db_conn conn;
public String Tbl_name() {return tbl_name;}
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds.To_fld_ary()));}
public void Insert(int owner, int sort, byte[] name, byte[] wiki, byte[] url, byte[] comment) {
Db_stmt stmt_insert = conn.Stmt_insert(tbl_name, flds);
stmt_insert.Clear()
.Val_int(fld_owner, owner).Val_int(fld_sort, sort).Val_bry_as_str(fld_name, name)
.Val_bry_as_str(fld_wiki, wiki).Val_bry_as_str(fld_url, url).Val_bry_as_str(fld_comment, comment)
.Exec_insert();
}
public void Update(int id, int owner, int sort, byte[] name, byte[] wiki, byte[] url, byte[] comment) {
Db_stmt stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_id);
stmt_update.Clear()
.Val_int(fld_owner, owner).Val_int(fld_sort, sort).Val_bry_as_str(fld_name, name)
.Val_bry_as_str(fld_wiki, wiki).Val_bry_as_str(fld_url, url).Val_bry_as_str(fld_comment, comment)
.Crt_int(fld_id, id)
.Exec_update();
}
public void Delete(int id) {
Db_stmt stmt_delete = conn.Stmt_delete(tbl_name, fld_id);
stmt_delete.Clear().Crt_int(fld_id, id).Exec_delete();
}
public Xoud_bmk_itm_row[] Select_grp(int owner) {
List_adp list = List_adp_.new_();
Db_rdr rdr = conn.Stmt_select_order(tbl_name, flds, String_.Ary(fld_owner), fld_sort)
.Crt_int(fld_owner, owner)
.Exec_select__rls_auto();
try {
while (rdr.Move_next())
list.Add(new_row(rdr));
}
finally {rdr.Rls();}
return (Xoud_bmk_itm_row[])list.To_ary_and_clear(Xoud_bmk_itm_row.class);
}
public int Select_sort_next(int owner) {
Db_rdr rdr = conn.Stmt_select_max(tbl_name, fld_sort, fld_owner).Crt_int(fld_owner, owner).Exec_select__rls_manual();
try {
int rv = 0;
if (rdr.Move_next()) {
Object rv_obj = rdr.Read_obj(fld_sort);
rv = rv_obj == null ? 0 : Int_.cast_(rv_obj) + 1;
}
return rv;
}
finally {rdr.Rls();}
}
private Xoud_bmk_itm_row new_row(Db_rdr rdr) {
return new Xoud_bmk_itm_row
( rdr.Read_int(fld_id)
, rdr.Read_int(fld_owner)
, rdr.Read_int(fld_sort)
, rdr.Read_bry_by_str(fld_name)
, rdr.Read_bry_by_str(fld_wiki)
, rdr.Read_bry_by_str(fld_url)
, rdr.Read_bry_by_str(fld_comment)
);
}
public void Rls() {}
}

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.users.bmks; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
import gplx.dbs.*;
public class Xoud_bmk_mgr {
public Xoud_bmk_itm_tbl Tbl__itm() {return tbl__itm;} private Xoud_bmk_itm_tbl tbl__itm;
public Xoud_bmk_dir_tbl Tbl__dir() {return tbl__dir;} private Xoud_bmk_dir_tbl tbl__dir;
public void Conn_(Db_conn conn, boolean created) {
this.tbl__dir = new Xoud_bmk_dir_tbl(conn);
this.tbl__itm = new Xoud_bmk_itm_tbl(conn);
// if (!conn.Meta_tbl_exists(tbl__dir.Tbl_name())) tbl__dir.Create_tbl(); // bmk_v2
// if (!conn.Meta_tbl_exists(tbl__itm.Tbl_name())) tbl__itm.Create_tbl();
}
public void Itms__add(int owner, Xoa_url url) {
tbl__itm.Insert(owner, tbl__itm.Select_sort_next(owner), Xoa_ttl.Replace_unders(url.Page_bry()), url.Wiki_bry(), url.Raw(), Bry_.Empty);
}
public Xoud_bmk_itm_row[] Itms__get(int owner) {return tbl__itm.Select_grp(owner);}
public static final int Owner_root = -1;
}