mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.5.1
This commit is contained in:
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.dbs.metas.*;
|
||||
import gplx.xowa.files.caches.*;
|
||||
import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.users.bmks.*; import gplx.xowa.users.history.*;
|
||||
public class Xou_db_file {
|
||||
private final Db_conn conn;
|
||||
public Xou_db_file(Db_conn conn) {
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import gplx.core.threads.*; import gplx.dbs.*; import gplx.dbs.metas.updates.*; import gplx.dbs.metas.*;
|
||||
import gplx.xowa.files.caches.*;
|
||||
import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.users.bmks.*; import gplx.xowa.users.history.*;
|
||||
public class Xou_db_mgr {
|
||||
private final Xoa_app app;
|
||||
private final Xoud_id_mgr id_mgr;
|
||||
@@ -41,6 +41,7 @@ public class Xou_db_mgr {
|
||||
this.cache_mgr = new Xou_cache_mgr(app.Wiki_mgri(), app.Fsys_mgr().File_dir(), db_file);
|
||||
this.xfer_itm_finder = new Xou_file_itm_finder(cache_mgr);
|
||||
this.bmk_mgr.Conn_(conn, created);
|
||||
// this.history_mgr.Conn_(conn, created);
|
||||
if (drd) {
|
||||
cfg_mgr.Conn_(conn, created);
|
||||
site_mgr.Conn_(conn, created);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Xoud_cfg_mgr {
|
||||
}
|
||||
public int Select_int_or(String grp, String key, int or) {
|
||||
String rv = Select_str_or(grp, key, null);
|
||||
return rv == null ? or : Int_.parse_or_(rv, or);
|
||||
return rv == null ? or : Int_.parse_or(rv, or);
|
||||
}
|
||||
public byte[] Select_bry_or(String key, byte[] or) {return Select_bry_or("" , key, or);}
|
||||
public byte[] Select_bry_or(String grp, String key, byte[] or) {
|
||||
|
||||
@@ -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.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import gplx.core.threads.*; import gplx.dbs.*;
|
||||
import gplx.xowa.specials.*;
|
||||
public class Xoud_history_mgr implements GfoInvkAble {
|
||||
private Xoud_history_tbl history_tbl;
|
||||
public void Conn_(Db_conn new_conn, boolean created) {
|
||||
history_tbl = new Xoud_history_tbl(new_conn);
|
||||
if (created) history_tbl.Create_tbl();
|
||||
}
|
||||
public void Update_async(Gfo_async_mgr async_mgr, Xoa_ttl ttl, Xoa_url url) {
|
||||
// if (Skip_history(ttl)) return;
|
||||
// async_mgr.Queue(this, Invk_update, "wiki", String_.new_u8(url.Wiki_bry()), "page", String_.new_u8(url.Page_bry()), "qarg", String_.new_u8(url.Args_all_as_bry()));
|
||||
}
|
||||
private void Update(String wiki, String page, String qarg) {
|
||||
// Xoud_history_row row = history_tbl.Select_by_page(wiki, page, qarg);
|
||||
// DateAdp time = DateAdp_.Now();
|
||||
// if (row == null)
|
||||
// history_tbl.Insert(wiki, page, qarg, time, 1);
|
||||
// else
|
||||
// history_tbl.Update(wiki, page, qarg, time, row.Count() + 1);
|
||||
}
|
||||
public void Select(List_adp rv, int top) {
|
||||
history_tbl.Select_by_top(rv, top);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_update)) Update(m.ReadStr("wiki"), m.ReadStr("page"), m.ReadStr("qarg"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_update = "update";
|
||||
public static boolean Skip_history(Xoa_ttl ttl) {
|
||||
byte[] page_db = ttl.Page_db();
|
||||
return ( ttl.Ns().Id_special()
|
||||
&& ( Bry_.Eq(page_db, gplx.xowa.users.history.Xou_history_mgr.Ttl_name) // do not add XowaPageHistory to history
|
||||
|| Bry_.Eq(page_db, Xows_special_meta_.Itm__popup_history.Key_bry())
|
||||
|| Bry_.Eq(page_db, Xows_special_meta_.Itm__default_tab.Key_bry())
|
||||
|| Bry_.Eq(page_db, Xows_special_meta_.Itm__page_history.Key_bry())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +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.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
public class Xoud_history_row {
|
||||
public Xoud_history_row(int id, byte[] wiki, byte[] url, DateAdp time, int count) {
|
||||
this.id = id;
|
||||
this.wiki = wiki; this.url = url;
|
||||
this.time = time; this.count = count;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Wiki() {return wiki;} private final byte[] wiki;
|
||||
public byte[] Url() {return url;} private final byte[] url;
|
||||
public DateAdp Time() {return time;} private final DateAdp time;
|
||||
public int Count() {return count;} private final int count;
|
||||
}
|
||||
@@ -1,31 +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.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import gplx.xowa.specials.*;
|
||||
import gplx.xowa.specials.xowa.bookmarks.*;
|
||||
public class Xoud_history_special implements Xows_page {
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__page_history;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xoa_app app = wiki.App();
|
||||
Dbui_tbl_itm__history ui_tbl = Dbui_tbl_itm__history.get_or_new(app, app.User().User_db_mgr().Db_file().Tbl__history());
|
||||
page.Html_data().Head_mgr().Itm__dbui().Init(app).Enabled_y_();
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||
ui_tbl.Select(bfr, 100);
|
||||
page.Hdump_data().Body_(bfr.To_bry_and_rls());
|
||||
}
|
||||
}
|
||||
@@ -1,95 +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.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
|
||||
import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.dbs.metas.*; import gplx.dbs.metas.updates.*;
|
||||
public class Xoud_history_tbl implements RlsAble {
|
||||
private final String tbl_name = "user_history"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
|
||||
private final String fld_id, fld_wiki, fld_url, fld_time, fld_count;
|
||||
private final Db_conn conn; private Db_stmt stmt_select_by_page, stmt_select_by_top, stmt_insert, stmt_update, stmt_delete;
|
||||
public Xoud_history_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_id = flds.Add_int_pkey_autonum("hist_id");
|
||||
fld_wiki = flds.Add_str("hist_wiki", 255);
|
||||
fld_url = flds.Add_str("hist_url", 255);
|
||||
fld_time = flds.Add_str("hist_time", 20);
|
||||
fld_count = flds.Add_int("hist_count");
|
||||
stmt_insert = stmt_update = stmt_delete = stmt_select_by_page = stmt_select_by_top = null;
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds, Db_meta_idx.new_unique_by_tbl(tbl_name, "pkey", fld_wiki, fld_url)));}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_update = Db_stmt_.Rls(stmt_update);
|
||||
stmt_delete = Db_stmt_.Rls(stmt_delete);
|
||||
stmt_select_by_page = Db_stmt_.Rls(stmt_select_by_page);
|
||||
stmt_select_by_top = Db_stmt_.Rls(stmt_select_by_top);
|
||||
}
|
||||
public void Insert(byte[] wiki, byte[] url, DateAdp time, int count) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear()
|
||||
.Val_bry_as_str(fld_wiki, wiki)
|
||||
.Val_bry_as_str(fld_url , url)
|
||||
.Val_str(fld_time, time.XtoStr_fmt_iso_8561())
|
||||
.Val_int(fld_count, count)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Update(int id, DateAdp time, int count) {
|
||||
if (stmt_update == null) stmt_update = conn.Stmt_update(tbl_name, String_.Ary(fld_id), fld_time, fld_count);
|
||||
stmt_update.Clear()
|
||||
.Val_str(fld_time, time.XtoStr_fmt_iso_8561())
|
||||
.Val_int(fld_count, count)
|
||||
.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_history_row Select_or_null(int id) {
|
||||
if (stmt_select_by_page == null) stmt_select_by_page = conn.Stmt_select(tbl_name, flds, fld_id);
|
||||
Db_rdr rdr = stmt_select_by_page.Clear().Crt_int(fld_id, id).Exec_select__rls_manual();
|
||||
try {
|
||||
return rdr.Move_next() ? new_row(rdr) : null;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Select_by_top(List_adp rv, int count) {
|
||||
if (stmt_select_by_top == null) {
|
||||
Db_qry__select_in_tbl qry = new Db_qry__select_in_tbl(tbl_name, flds.To_str_ary(), null, null, null, fld_time + " DESC", " LIMIT " + Int_.Xto_str(count));
|
||||
stmt_select_by_top = conn.Stmt_new(qry);
|
||||
}
|
||||
Db_rdr rdr = stmt_select_by_top.Clear().Exec_select__rls_manual();
|
||||
try {
|
||||
rv.Clear();
|
||||
while (rdr.Move_next()) {
|
||||
Xoud_history_row row = new_row(rdr);
|
||||
rv.Add(row);
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xoud_history_row new_row(Db_rdr rdr) {
|
||||
return new Xoud_history_row
|
||||
( rdr.Read_int(fld_id)
|
||||
, rdr.Read_bry_by_str(fld_wiki)
|
||||
, rdr.Read_bry_by_str(fld_url)
|
||||
, rdr.Read_date_by_str(fld_time)
|
||||
, rdr.Read_int(fld_count)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class Xoud_opt_scope_parser {
|
||||
}
|
||||
public Xoud_opt_scope Parse_itm(byte[] src, int bgn, int end) {
|
||||
int lang_dot = Bry_finder.Find_fwd(src, Byte_ascii.Dot, bgn, end); if (lang_dot == Bry_finder.Not_found) return Warn("scope.parse.missing_lang_dot: src=~{0}", src, bgn, end);
|
||||
int lang_id = Int_.MinValue;
|
||||
int lang_id = Int_.Min_value;
|
||||
if (lang_dot == 1 && src[bgn] == Byte_ascii.Star)
|
||||
lang_id = Xoud_opt_scope.Lang_id_wildcard;
|
||||
else {
|
||||
|
||||
@@ -22,7 +22,7 @@ class Xoud_user_mgr {
|
||||
public void Conn_(Db_conn conn, boolean created) {tbl.Conn_(conn, created);}
|
||||
public int Get_id_or_new(String name) {
|
||||
int rv = tbl.Select_id_by_name(name);
|
||||
if (rv == Int_.MinValue) {
|
||||
if (rv == Int_.Min_value) {
|
||||
rv = tbl.Select_id_next();
|
||||
tbl.Insert(rv, name);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class Xoud_user_tbl {
|
||||
public int Select_id_by_name(String name) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_name).Crt_str(fld_name, name).Exec_select__rls_auto();
|
||||
try {
|
||||
return rdr.Move_next() ? rdr.Read_int(fld_id) : Int_.MinValue;
|
||||
return rdr.Move_next() ? rdr.Read_int(fld_id) : Int_.Min_value;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user