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-08-17 02:09:16 -04:00
parent 34c34f227c
commit df10db140c
421 changed files with 4867 additions and 2429 deletions

View File

@@ -59,8 +59,9 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
search_bry = ttl.Leaf_txt_wo_qarg(); // assume search is in leaf; EX: Special:Search/Earth
args_mgr.Search_bry_(search_bry);
}
if (Bry_.Len_eq_0(search_bry)) return; // emptry String; exit now, else null ref error; DATE:2015-08-11
if ( search_suggest_mgr.Auto_wildcard() // add * automatically if option set
&& wiki.Db_mgr().Tid() == gplx.xowa.dbs.Xodb_mgr_sql.Tid_sql // only apply to sql
&& wiki.Db_mgr().Tid() == gplx.xowa.dbs.Xodb_mgr_sql.Tid_sql // only apply to sql
&& Bry_finder.Find_fwd(search_bry, Byte_ascii.Star) == -1 // search term does not have asterisk
)
search_bry = Bry_.Add(search_bry, Byte_ascii.Star);

View File

@@ -53,8 +53,8 @@ class Xows_ui_async_fxt {
int expd_len = expd.length;
Tfds.Eq(expd_len, js_wkr.Log__len());
for (int i = 0; i < expd_len; ++i) {
String expd_str = String_.ConcatWith_any("\n", expd[i]);
String actl_str = String_.ConcatWith_any("\n", js_wkr.Log__get_at(i));
String expd_str = String_.Concat_with_obj("\n", expd[i]);
String actl_str = String_.Concat_with_obj("\n", js_wkr.Log__get_at(i));
Tfds.Eq_str_lines(expd_str, actl_str);
}
js_wkr.Log__clear();

View File

@@ -21,6 +21,7 @@ import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*; import gplx.xowa.html.bridges.dbuis.tbls.*; import gplx.xowa.html.bridges.dbuis.fmtrs.*;
public class Dbui_tbl_itm__bmk implements Dbui_tbl_itm {
private final Xoa_app app; private final Xoud_bmk_itm_tbl tbl;
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
private final Dbui_cells_fmtr cells_fmtr = new Dbui_cells_fmtr(); private final Dbui_val_fmtr edit_val_fmtr = Dbui_val_fmtr_.new_edit(); private final Dbui_val_fmtr view_val_fmtr = Dbui_val_fmtr_.new_view();
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
private final Bridge_msg_bldr msg_bldr;
@@ -29,7 +30,6 @@ public class Dbui_tbl_itm__bmk implements Dbui_tbl_itm {
public Dbui_btn_itm[] View_btns() {return view_btns;}
public Dbui_btn_itm[] Edit_btns() {return edit_btns;}
public Dbui_col_itm[] Cols() {return cols;}
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
public void Reg(Bridge_cmd_mgr bridge_mgr) {
Dbui_cmd_mgr dbui_mgr = Dbui_cmd_mgr.I;
dbui_mgr.Init_by_bridge(bridge_mgr);

View File

@@ -0,0 +1,95 @@
/*
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.xowa.bookmarks; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import gplx.core.json.*; import gplx.html.*;
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*; import gplx.xowa.html.bridges.dbuis.tbls.*; import gplx.xowa.html.bridges.dbuis.fmtrs.*;
public class Dbui_tbl_itm__history implements Dbui_tbl_itm {
private final Xoa_app app; private final Xoud_history_tbl tbl;
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
private final Bridge_msg_bldr msg_bldr;
public Dbui_tbl_itm__history(Xoa_app app, Xoud_history_tbl tbl) {this.app = app; this.tbl = tbl; this.msg_bldr = app.Html__bridge_mgr().Msg_bldr();}
public byte[] Key() {return key;} private static final byte[] key = Bry_.new_a7("history");
public Dbui_btn_itm[] View_btns() {return view_btns;}
public Dbui_btn_itm[] Edit_btns() {return Dbui_btn_itm.Ary_empty;}
public Dbui_col_itm[] Cols() {return cols;}
public void Reg(Bridge_cmd_mgr bridge_mgr) {
Dbui_cmd_mgr dbui_mgr = Dbui_cmd_mgr.I;
dbui_mgr.Init_by_bridge(bridge_mgr);
dbui_mgr.Add(this);
}
private final List_adp select_list = List_adp_.new_();
public void Select(Bry_bfr bfr, int top) {
tbl.Select_by_top(select_list, 100);
Xoud_history_row[] db_rows = (Xoud_history_row[])select_list.To_ary_and_clear(Xoud_history_row.class);
byte[] option_link = app.Html__lnki_bldr().Href_(Bry_.new_a7("home"), app.User().Wikii().Ttl_parse(Bry_.new_a7("Help:Options/PageHistory"))).Img_16x16(gplx.xowa.html.wtrs.Xoh_img_path.Img_option).Bld_to_bry();
byte[] delete_confirm_msg = app.Api_root().Usr().Bookmarks().Delete_confirm() ? Msg__delete_confirm : Bry_.Empty;
tbl_fmtr.Write(bfr, this, option_link, delete_confirm_msg, To_ui_rows(db_rows));
} private static final byte[] Msg__delete_confirm = Bry_.new_a7(" data-dbui-delete_confirm_msg='Are you sure you want to delete this row?'");
public String Del(byte[] row_id, byte[] row_pkey) {
Xoud_history_row db_row = Get_db_row(row_pkey); if (db_row == null) return Fail_missing_row(row_pkey);
tbl.Delete(db_row.Id());
return msg_bldr.To_json_str__empty();
}
public String Edit(byte[] row_id, byte[] row_pkey) {throw Err_.new_unimplemented();}
public String Save(byte[] row_id, byte[] row_pkey, Dbui_val_hash vals) {throw Err_.new_unimplemented();}
public String Reorder(byte[][] pkeys, int owner) {throw Err_.new_unimplemented();}
public Dbui_row_itm[] To_ui_rows(Xoud_history_row[] db_rows) {
int len = db_rows.length;
Dbui_row_itm[] rv = new Dbui_row_itm[len];
for (int i = 0; i < len; ++i)
rv[i] = Get_ui_row(db_rows[i]);
return rv;
}
private Xoud_history_row Get_db_row(byte[] pkey) {
int id = Bry_.To_int(pkey);
return tbl.Select_or_null(id);
}
private Dbui_row_itm Get_ui_row(Xoud_history_row row) {return Get_ui_row(Int_.Xto_bry(row.Id()), row.Wiki(), row.Url(), row.Count(), row.Time());}
private Dbui_row_itm Get_ui_row(byte[] pkey, byte[] wiki, byte[] url, int count, DateAdp time) {
Dbui_val_itm[] vals = new Dbui_val_itm[4];
vals[0] = new Dbui_val_itm(url, url_fmtr.Bld_bry_many(tmp_bfr, Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, url)));
vals[1] = new Dbui_val_itm(wiki, wiki);
byte[] count_bry = Int_.Xto_bry(count);
vals[2] = new Dbui_val_itm(count_bry, count_bry);
byte[] time_bry = Bry_.new_u8(time.XtoStr_fmt_yyyy_MM_dd_HH_mm_ss());
vals[3] = new Dbui_val_itm(time_bry, time_bry);
return new Dbui_row_itm(this, pkey, vals);
}
private String Fail_missing_row(byte[] row_pkey) {
return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Item has been deleted", "key", row_pkey)).Notify_hint_("Please reload the page").To_json_str();
}
private static final Dbui_col_itm[] cols = new Dbui_col_itm[]
{ new Dbui_col_itm(Dbui_col_itm.Type_id_str , 300, "page" , "Page")
, new Dbui_col_itm(Dbui_col_itm.Type_id_str , 150, "wiki" , "Wiki")
, new Dbui_col_itm(Dbui_col_itm.Type_id_int , 80, "views" , "Views")
, new Dbui_col_itm(Dbui_col_itm.Type_id_datetime, 100, "time" , "Time")
};
private static final Dbui_btn_itm[] view_btns = new Dbui_btn_itm[]
{ new Dbui_btn_itm("rows__delete" , "delete.png" , "delete")
};
private static final Bry_fmtr url_fmtr = Bry_fmtr.new_("<a href='/site/~{url}'>~{url}</a>", "url");
public static Dbui_tbl_itm__history get_or_new(Xoa_app app, Xoud_history_tbl db_tbl) {
if (I == null) {
I = new Dbui_tbl_itm__history(app, db_tbl);
I.Reg(app.Html__bridge_mgr().Cmd_mgr());
}
return I;
} private static Dbui_tbl_itm__history I;
}

View File

@@ -36,7 +36,7 @@ public class System_data_page implements Xows_page {
Xoae_app app = wiki.Appe();
switch (type) {
case Type_log_session: return app.Log_wtr().Session_fil();
case Type_cfg_app: return app.Fsys_mgr().Root_dir().GenSubFil("xowa.gfs");
case Type_cfg_app: return app.Fsys_mgr().Cfg_app_fil();
case Type_cfg_lang: return Xol_lang_.xo_lang_fil_(app.Fsys_mgr(), wiki.Lang().Key_str());
case Type_cfg_user: return app.Usere().Fsys_mgr().App_data_cfg_user_fil();
case Type_cfg_custom: return app.Usere().Fsys_mgr().App_data_cfg_custom_fil();