diff --git a/100_core/src_110_primitive/gplx/Bry_bfr.java b/100_core/src_110_primitive/gplx/Bry_bfr.java
index de0b0c2e1..35d687e8a 100644
--- a/100_core/src_110_primitive/gplx/Bry_bfr.java
+++ b/100_core/src_110_primitive/gplx/Bry_bfr.java
@@ -161,6 +161,7 @@ public class Bry_bfr {
public Bry_bfr Add_byte_space() {return Add_byte(Byte_ascii.Space);}
public Bry_bfr Add_byte_nl() {return Add_byte(Byte_ascii.Nl);}
public Bry_bfr Add_byte_dot() {return Add_byte(Byte_ascii.Dot);}
+ public Bry_bfr Add_byte_colon() {return Add_byte(Byte_ascii.Colon);}
public Bry_bfr Add_byte(byte val) {
int new_pos = bfr_len + 1;
if (new_pos > bfr_max) Resize(bfr_len * 2);
diff --git a/100_core/src_140_list/gplx/Hash_adp_bry.java b/100_core/src_140_list/gplx/Hash_adp_bry.java
index 6d82b8100..2ab022b44 100644
--- a/100_core/src_140_list/gplx/Hash_adp_bry.java
+++ b/100_core/src_140_list/gplx/Hash_adp_bry.java
@@ -33,6 +33,7 @@ public class Hash_adp_bry extends gplx.lists.Hash_adp_base implements Hash_adp {
public Hash_adp_bry Add_bry_int(byte[] key, int val) {this.Add_base(key, Int_obj_val.new_(val)); return this;}
public Hash_adp_bry Add_bry_bry(byte[] key) {this.Add_base(key, key); return this;}
public Hash_adp_bry Add_str_byte(String key, byte val) {this.Add_base(Bry_.new_u8(key), Byte_obj_val.new_(val)); return this;}
+ public Hash_adp_bry Add_str_int(String key, int val) {this.Add_base(Bry_.new_u8(key), Int_obj_val.new_(val)); return this;}
public Hash_adp_bry Add_str_obj(String key, Object val) {this.Add_base(Bry_.new_u8(key), val); return this;}
public Hash_adp_bry Add_bry_obj(byte[] key, Object val) {this.Add_base(key, val); return this;}
public Hash_adp_bry Add_many_str(String... ary) {
diff --git a/140_dbs/src/gplx/dbs/Db_conn.java b/140_dbs/src/gplx/dbs/Db_conn.java
index 87ae3d134..b8205982a 100644
--- a/140_dbs/src/gplx/dbs/Db_conn.java
+++ b/140_dbs/src/gplx/dbs/Db_conn.java
@@ -21,6 +21,7 @@ public class Db_conn {
private final List_adp rls_list = List_adp_.new_(); private final Db_engine engine;
public Db_conn(Db_engine engine) {this.engine = engine;}
public Db_conn_info Conn_info() {return engine.Conn_info();}
+ public boolean Eq(Db_conn comp) {return String_.Eq(engine.Conn_info().Xto_api(), comp.Conn_info().Xto_api());}
public void Txn_bgn() {engine.Txn_bgn("");}
public void Txn_bgn(String name) {engine.Txn_bgn(name);}
public void Txn_end() {engine.Txn_end();}
diff --git a/400_xowa/src/gplx/core/net/Http_client_rdr.java b/400_xowa/src/gplx/core/net/Http_client_rdr.java
new file mode 100644
index 000000000..d640b6cd2
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_client_rdr.java
@@ -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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public interface Http_client_rdr {
+ void Stream_(Object o);
+ String Read_line();
+ byte[] Read_line_as_bry();
+ void Rls();
+}
diff --git a/400_xowa/src/gplx/core/net/Http_client_rdr_.java b/400_xowa/src/gplx/core/net/Http_client_rdr_.java
new file mode 100644
index 000000000..b287cdf32
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_client_rdr_.java
@@ -0,0 +1,21 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public class Http_client_rdr_ {
+ public static Http_client_rdr new_stream() {return new Http_client_rdr__stream();}
+}
diff --git a/400_xowa/src/gplx/core/net/Http_client_rdr__stream.java b/400_xowa/src/gplx/core/net/Http_client_rdr__stream.java
new file mode 100644
index 000000000..cbf402446
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_client_rdr__stream.java
@@ -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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+import java.io.*;
+class Http_client_rdr__stream implements Http_client_rdr {
+ private BufferedReader br;
+ public void Stream_(Object o) {
+ this.br = new BufferedReader(new InputStreamReader((InputStream)o, java.nio.charset.Charset.forName("UTF-8")));
+ }
+ public String Read_line() {
+ try {return br.readLine();}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+ public byte[] Read_line_as_bry() {return Bry_.new_u8(Read_line());}
+ public void Rls() {
+ try {br.close();}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+}
diff --git a/400_xowa/src/gplx/core/net/Http_client_wtr.java b/400_xowa/src/gplx/core/net/Http_client_wtr.java
new file mode 100644
index 000000000..943f80d69
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_client_wtr.java
@@ -0,0 +1,25 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public interface Http_client_wtr {
+ void Stream_(Object o);
+ void Write_bry(byte[] bry);
+ void Write_str(String s);
+ void Write_mid(byte[] bry, int bgn, int end);
+ void Rls();
+}
diff --git a/400_xowa/src/gplx/core/net/Http_client_wtr_.java b/400_xowa/src/gplx/core/net/Http_client_wtr_.java
new file mode 100644
index 000000000..b6376df8c
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_client_wtr_.java
@@ -0,0 +1,21 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public class Http_client_wtr_ {
+ public static Http_client_wtr new_stream() {return new Http_client_wtr__stream();}
+}
diff --git a/400_xowa/src/gplx/core/net/Http_client_wtr__stream.java b/400_xowa/src/gplx/core/net/Http_client_wtr__stream.java
new file mode 100644
index 000000000..cacba6a8b
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_client_wtr__stream.java
@@ -0,0 +1,43 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+import java.io.*;
+class Http_client_wtr__stream implements Http_client_wtr {
+ private DataOutputStream stream;
+ public void Stream_(Object o) {
+ this.stream = new DataOutputStream((OutputStream)o);
+ }
+ public void Write_bry(byte[] bry) {
+ try {stream.write(bry);}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+ public void Write_str(String s) {
+ try {stream.writeBytes(s);}
+ catch (Exception e) {
+ throw Err_.err_(e);
+ }
+ }
+ public void Write_mid(byte[] bry, int bgn, int end) {
+ try {stream.write(bry, bgn, end - bgn);}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+ public void Rls() {
+ try {stream.close();}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+}
diff --git a/400_xowa/src/gplx/core/net/Http_request_parser.java b/400_xowa/src/gplx/core/net/Http_request_parser.java
new file mode 100644
index 000000000..77d6e1693
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_request_parser.java
@@ -0,0 +1,72 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+import gplx.core.btries.*;
+class Http_request_parser {
+ public void Init(Http_client_rdr rdr) {
+// String line = rdr.Read_line();
+// Init_line0(line);
+// while (true) {
+// String line = rdr.Read_line();
+// break;
+// }
+ }
+// private void Init_request_type(String line) {
+// if (String_.Has_at_bgn(line, "GET "))
+//
+// else if (String_.Has_at_bgn(line, "POST "))
+//
+// else throw Err_.unhandled(line);
+// }
+// private static final int Tid_post = 1, Tid_get = 2, Tid_host = 3, Tid_user_agent = 4, Tid_accept = 5, Tid_accept_language = 6, Tid_accept_encoding = 7, Tid_dnt = 8, Tid_referer = 9
+// , Tid_content_length = 10, Tid_content_type = 11, Tid_connection = 12, Tid_pragma = 13, Tid_cache_control = 14;
+// private static final Hash_adp hash = Hash_adp_bry.ci_ascii_()
+// .Add_str_int("POST" , Tid_post)
+// .Add_str_int("Host:" , Tid_host)
+// .Add_str_int("User-Agent:" , Tid_user_agent)
+// .Add_str_int("Accept:" , Tid_accept)
+// .Add_str_int("Accept-Language:" , Tid_accept_language)
+// .Add_str_int("Accept-Encoding:" , Tid_accept_encoding)
+// .Add_str_int("DNT:" , Tid_dnt)
+// .Add_str_int("Referer:" , Tid_referer)
+// .Add_str_int("Content-length:" , Tid_content_length)
+// .Add_str_int("Content-Type:" , Tid_content_type)
+// .Add_str_int("Connection:" , Tid_connection)
+// .Add_str_int("Pragma:" , Tid_pragma)
+// .Add_str_int("Cache-Control:" , Tid_cache_control)
+// ;
+}
+class Http_request_itm {
+ /*
+ public boolean Type_is_get() {return type_is_get;} private final boolean type_is_get;
+ public String Url() {return url;} private final String url;
+ public String Protocol() {return protocol;} private final String protocol;
+ public String Host() {return host;} private final String host;
+ public String User_agent() {return user_agent;} private final String user_agent;
+ public String Accept() {return accept;} private final String accept;
+ public String Accept_encoding() {return accept_encoding;} private final String accept_encoding;
+ public boolean Dnt() {return dnt;} private final boolean dnt;
+ public String Referer() {return referer;} private final String referer;
+ public long Content_length() {return content_length;} private final long content_length;
+ public String Content_type() {return content_type;} private final String content_type;
+ public String Content_type_boundary() {return content_type_boundary;} private final String content_type_boundary;
+ public String Connection() {return connection;} private final String connection;
+ public String Pragma() {return pragma;} private final String pragma;
+ public String Cache_control() {return cache_control;} private final String cache_control;
+ */
+}
diff --git a/400_xowa/src/gplx/core/net/Http_server_wtr.java b/400_xowa/src/gplx/core/net/Http_server_wtr.java
new file mode 100644
index 000000000..6a3d9a62b
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_server_wtr.java
@@ -0,0 +1,21 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public interface Http_server_wtr {
+ void Write_str_w_nl(String s);
+}
diff --git a/400_xowa/src/gplx/core/net/Http_server_wtr_.java b/400_xowa/src/gplx/core/net/Http_server_wtr_.java
new file mode 100644
index 000000000..2bb04afb4
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_server_wtr_.java
@@ -0,0 +1,21 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public class Http_server_wtr_ {
+ public static Http_server_wtr new_console() {return new Http_server_wtr__console();}
+}
diff --git a/400_xowa/src/gplx/core/net/Http_server_wtr__console.java b/400_xowa/src/gplx/core/net/Http_server_wtr__console.java
new file mode 100644
index 000000000..b7200e80c
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Http_server_wtr__console.java
@@ -0,0 +1,21 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+class Http_server_wtr__console implements Http_server_wtr {
+ public void Write_str_w_nl(String s) {ConsoleAdp._.WriteLine(s);}
+}
diff --git a/400_xowa/src/gplx/core/net/Socket_adp.java b/400_xowa/src/gplx/core/net/Socket_adp.java
new file mode 100644
index 000000000..05e8849d8
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Socket_adp.java
@@ -0,0 +1,23 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+public interface Socket_adp {
+ Object Get_input_stream();
+ Object Get_output_stream();
+ void Rls();
+}
diff --git a/400_xowa/src/gplx/core/net/Socket_adp__base.java b/400_xowa/src/gplx/core/net/Socket_adp__base.java
new file mode 100644
index 000000000..4cb39d18b
--- /dev/null
+++ b/400_xowa/src/gplx/core/net/Socket_adp__base.java
@@ -0,0 +1,36 @@
+/*
+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 .
+*/
+package gplx.core.net; import gplx.*; import gplx.core.*;
+import java.io.IOException;
+import java.net.*;
+public class Socket_adp__base implements Socket_adp {
+ private final Socket socket;
+ public Socket_adp__base(Socket socket) {this.socket = socket;}
+ public Object Get_input_stream() {
+ try {return socket.getInputStream();}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+ public Object Get_output_stream() {
+ try {return socket.getOutputStream();}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+ public void Rls() {
+ try {socket.close();}
+ catch (IOException e) {throw Err_.err_(e);}
+ }
+}
diff --git a/400_xowa/src/gplx/fsdb/Fsdb_db_mgr__v1.java b/400_xowa/src/gplx/fsdb/Fsdb_db_mgr__v1.java
index 5cebc315e..296a669ad 100644
--- a/400_xowa/src/gplx/fsdb/Fsdb_db_mgr__v1.java
+++ b/400_xowa/src/gplx/fsdb/Fsdb_db_mgr__v1.java
@@ -46,7 +46,13 @@ public class Fsdb_db_mgr__v1 implements Fsdb_db_mgr {
String bin_name = (mnt_is_main ? bin_prefix__main : bin_prefix__user) + Int_.Xto_str_pad_bgn_zero(bin_id, 4) + ".sqlite3";
String mnt_name = mnt_is_main ? Fsm_mnt_tbl.Mnt_name_main : Fsm_mnt_tbl.Mnt_name_user;
Io_url url = file_dir.GenSubFil_nest(mnt_name, bin_name); // EX: /xowa/enwiki/fsdb.main/fsdb.bin.0000.sqlite3
- return new Fsdb_db_file(url, Db_conn_bldr.I.Get(url));
+ Db_conn conn = Db_conn_bldr.I.Get(url);
+ if (conn == null) { // NOTE: handle wikis with missing bin files; EX:sv.w missing bin.0010; DATE:2015-07-04
+ gplx.xowa.Xoa_app_.Usr_dlg().Warn_many("", "", "fsdb.v1: missing db; db=~{0}", url.Raw());
+ return Fsdb_db_mgr__v1_bldr.I.new_db__bin(url);
+ }
+ else
+ return new Fsdb_db_file(url, conn);
}
public Fsdb_db_file File__bin_file__new(int mnt_id, String file_name) {
String mnt_name = mnt_id == Fsm_mnt_mgr.Mnt_idx_main ? Fsm_mnt_tbl.Mnt_name_main : Fsm_mnt_tbl.Mnt_name_user;
@@ -94,9 +100,14 @@ class Fsdb_db_mgr__v1_bldr {
Fsd_fil_tbl fil_tbl = new Fsd_fil_tbl(db_atr.Conn(), schema_is_1, mnt_id); fil_tbl.Create_tbl();
Fsd_thm_tbl thm_tbl = new Fsd_thm_tbl(db_atr.Conn(), schema_is_1, mnt_id, Bool_.Y); thm_tbl.Create_tbl();
// make bin_fil
- Fsdb_db_file db_bin = new_db(mnt_dir.GenSubFil("fsdb.bin.0000.sqlite3"));
- Fsd_bin_tbl bin_tbl = new Fsd_bin_tbl(db_bin.Conn(), schema_is_1); bin_tbl.Create_tbl();
+ new_db__bin(mnt_dir.GenSubFil("fsdb.bin.0000.sqlite3"));
}
private Fsdb_db_file new_db(Io_url url) {return new Fsdb_db_file(url, Db_conn_bldr.I.New(url));}
+ public Fsdb_db_file new_db__bin(Io_url url) {
+ Fsdb_db_file rv = new_db(url);
+ Fsd_bin_tbl bin_tbl = new Fsd_bin_tbl(rv.Conn(), true); // NOTE: schema_is_1 is always true b/c it is in Fsdb_db_mgr__v1_bldr
+ bin_tbl.Create_tbl();
+ return rv;
+ }
public static final Fsdb_db_mgr__v1_bldr I = new Fsdb_db_mgr__v1_bldr(); Fsdb_db_mgr__v1_bldr() {}
}
diff --git a/400_xowa/src/gplx/json/Json_doc.java b/400_xowa/src/gplx/json/Json_doc.java
index 1f3d02b9f..5731e92e8 100644
--- a/400_xowa/src/gplx/json/Json_doc.java
+++ b/400_xowa/src/gplx/json/Json_doc.java
@@ -61,5 +61,7 @@ public class Json_doc {
public static Json_doc new_apos_concat_nl(String... ary) {return new_apos_(String_.Concat_lines_nl(ary));}
public static Json_doc new_apos_(String v) {return new_(Bry_.Replace(Bry_.new_u8(v), Byte_ascii.Apos, Byte_ascii.Quote));}
public static Json_doc new_(String v) {return new_(Bry_.new_u8(v));}
- public static Json_doc new_(byte[] v) {return parser.Parse(v);} static Json_parser parser = new Json_parser();
+ public static Json_doc new_(byte[] v) {
+ synchronized (parser) {return parser.Parse(v);}
+ } private static final Json_parser parser = new Json_parser();
}
\ No newline at end of file
diff --git a/400_xowa/src/gplx/json/Json_doc_srl.java b/400_xowa/src/gplx/json/Json_doc_srl.java
index 06ec1312d..09f9e6f85 100644
--- a/400_xowa/src/gplx/json/Json_doc_srl.java
+++ b/400_xowa/src/gplx/json/Json_doc_srl.java
@@ -50,7 +50,7 @@ public class Json_doc_srl {
}
private void Write_kv_str(boolean comma, byte[] key, String val) {
Write_key(comma, key); // "key":
- Write_str(Bry_.new_u8(val)); // "val"
+ Write_str(Bry_.new_u8(val)); // "val"
Write_new_line(); // \n
}
private void Write_key(boolean comma, byte[] key) { // "key":
diff --git a/400_xowa/src/gplx/json/Json_itm_nde.java b/400_xowa/src/gplx/json/Json_itm_nde.java
index 64a0bb67c..d69e78efe 100644
--- a/400_xowa/src/gplx/json/Json_itm_nde.java
+++ b/400_xowa/src/gplx/json/Json_itm_nde.java
@@ -35,6 +35,15 @@ public class Json_itm_nde extends Json_itm_base implements Json_grp {
}
return null;
}
+ public byte[] Subs_get_val_by_key_as_bry(byte[] key, byte[] or) {
+ Json_itm kv_obj = Subs_get_by_key(key);
+ if (kv_obj == null) return or; // key not found;
+ if (kv_obj.Tid() != Json_itm_.Tid_kv) return or; // key is not a key_val
+ Json_itm_kv kv = (Json_itm_kv)kv_obj;
+ Json_itm val = kv.Val();
+ if (val == null) return or;
+ return val.Data_bry();
+ }
public Json_itm_nde Subs_add_many(Json_itm... ary) {
int len = ary.length;
for (int i = 0; i < len; i++)
diff --git a/400_xowa/src/gplx/json/Json_wtr.java b/400_xowa/src/gplx/json/Json_wtr.java
new file mode 100644
index 000000000..73565cc3b
--- /dev/null
+++ b/400_xowa/src/gplx/json/Json_wtr.java
@@ -0,0 +1,129 @@
+/*
+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 .
+*/
+package gplx.json; import gplx.*;
+public class Json_wtr {
+ private final Bry_bfr bfr = Bry_bfr.new_(255);
+ private int indent;
+ private boolean nde_itm_is_first;
+ private boolean ary_itm_is_first;
+ public byte Quote_byte() {return quote_byte;} public Json_wtr Quote_byte_(byte v) {quote_byte = v; return this;} private byte quote_byte = Byte_ascii.Quote;
+ public byte[] To_bry_and_clear() {return bfr.Xto_bry_and_clear();}
+ public String To_str_and_clear() {return bfr.Xto_str_and_clear();}
+ public Json_wtr Clear() {
+ indent = 0;
+ nde_itm_is_first = ary_itm_is_first = false;
+ return this;
+ }
+ public Json_wtr Doc_bgn() {return Add_grp_bgn(Sym_nde_bgn);}
+ public Json_wtr Doc_end() {return Add_grp_end(Sym_nde_end);}
+ public Json_wtr Nde_bgn(String nde) {
+ Add_indent_itm(nde_itm_is_first);
+ Add_key(Bry_.new_u8(nde));
+ bfr.Add_byte_nl();
+ return Add_grp_bgn(Sym_nde_bgn);
+ }
+ public Json_wtr Nde_end() {return Add_grp_end(Sym_nde_end);}
+ public Json_wtr Ary_bgn(String nde) {
+ Add_indent_itm(nde_itm_is_first);
+ Add_key(Bry_.new_u8(nde));
+ bfr.Add_byte_nl();
+ ary_itm_is_first = true;
+ return Add_grp_bgn(Sym_ary_bgn);
+ }
+ public Json_wtr Ary_itm_str(String itm) {
+ Add_indent_itm(ary_itm_is_first);
+ Add_itm_bry(Bry_.new_u8(itm));
+ bfr.Add_byte_nl();
+ ary_itm_is_first = false;
+ return this;
+ }
+ public Json_wtr Ary_end() {
+ return Add_grp_end(Sym_ary_end);
+ }
+ public Json_wtr Kv_str(String key, String val) {
+ Add_indent_itm(nde_itm_is_first);
+ Add_key(Bry_.new_u8(key));
+ Add_itm_bry(Bry_.new_u8(val));
+ bfr.Add_byte_nl();
+ nde_itm_is_first = false;
+ return this;
+ }
+ public Json_wtr Kv_bfr(String key, Bry_bfr val) {
+ Add_indent_itm(nde_itm_is_first);
+ Add_key(Bry_.new_u8(key));
+ Add_itm_bry(val.Bfr(), 0, val.Len());
+ bfr.Add_byte_nl();
+ nde_itm_is_first = false;
+ val.Clear();
+ return this;
+ }
+ private Json_wtr Add_grp_bgn(byte[] grp_sym) {
+ Add_indent(0);
+ bfr.Add(grp_sym);
+ ++indent;
+ nde_itm_is_first = true;
+ return this;
+ }
+ private Json_wtr Add_grp_end(byte[] grp_sym) {
+ --indent;
+ nde_itm_is_first = false;
+ Add_indent(0);
+ bfr.Add(grp_sym);
+ return this;
+ }
+ private Json_wtr Add_key(byte[] bry) {
+ Add_itm_bry(bry);
+ bfr.Add_byte_colon();
+ return this;
+ }
+ private void Add_itm_bry(byte[] bry) {Add_itm_bry(bry, 0, bry.length);}
+ private void Add_itm_bry(byte[] bry, int bgn, int end) {
+ bfr.Add_byte(quote_byte);
+ for (int i = bgn; i < end; i++) {
+ byte b = bry[i];
+ switch (b) {
+ case Byte_ascii.Backslash: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(b); break; // "\" -> "\\"; needed else js will usurp \ as escape; EX: "\&" -> "&"; DATE:2014-06-24
+ case Byte_ascii.Quote: bfr.Add_byte(Byte_ascii.Backslash).Add_byte(b); break;
+ case Byte_ascii.Apos: bfr.Add_byte(b); break;
+ case Byte_ascii.Nl: bfr.Add_byte_repeat(Byte_ascii.Backslash, 2).Add_byte(Byte_ascii.Ltr_n); break; // "\n" -> "\\n"
+ case Byte_ascii.Cr: break;// skip
+ default: bfr.Add_byte(b); break;
+ }
+ }
+ bfr.Add_byte(quote_byte);
+ }
+ private void Add_indent_itm(boolean v) {
+ if (v)
+ Add_indent(0);
+ else {
+ Add_indent(-1);
+ bfr.Add(Sym_itm_spr);
+ }
+ }
+ private void Add_indent(int adj) {
+ int level = indent + adj;
+ if (level > 0) bfr.Add_byte_repeat(Byte_ascii.Space, level * 2);
+ }
+ private static final byte[]
+ Sym_nde_bgn = Bry_.new_a7("{\n")
+ , Sym_nde_end = Bry_.new_a7("}\n")
+ , Sym_ary_bgn = Bry_.new_a7("[\n")
+ , Sym_ary_end = Bry_.new_a7("]\n")
+ , Sym_itm_spr = Bry_.new_a7(", ")
+ ;
+}
diff --git a/400_xowa/src/gplx/json/Json_wtr_tst.java b/400_xowa/src/gplx/json/Json_wtr_tst.java
new file mode 100644
index 000000000..536ee4012
--- /dev/null
+++ b/400_xowa/src/gplx/json/Json_wtr_tst.java
@@ -0,0 +1,100 @@
+/*
+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 .
+*/
+package gplx.json; import gplx.*;
+import org.junit.*;
+public class Json_wtr_tst {
+ @Before public void init() {fxt.Clear();} private final Json_wtr_fxt fxt = new Json_wtr_fxt();
+ @Test public void Root() {
+ fxt.Wtr().Doc_bgn().Doc_end();
+ fxt.Test
+ ( "{"
+ , "}"
+ );
+ }
+ @Test public void Kv() {
+ fxt.Wtr()
+ .Doc_bgn()
+ .Kv_str("k0", "v0")
+ .Kv_str("k1", "v1")
+ .Doc_end();
+ fxt.Test
+ ( "{"
+ , " 'k0':'v0'"
+ , ", 'k1':'v1'"
+ , "}"
+ );
+ }
+ @Test public void Nde() {
+ fxt.Wtr()
+ .Doc_bgn()
+ .Nde_bgn("s0")
+ .Nde_bgn("s00")
+ .Nde_end()
+ .Nde_end()
+ .Nde_bgn("s1")
+ .Nde_bgn("s10")
+ .Nde_end()
+ .Nde_end()
+ .Doc_end();
+ fxt.Test
+ ( "{"
+ , " 's0':"
+ , " {"
+ , " 's00':"
+ , " {"
+ , " }"
+ , " }"
+ , ", 's1':"
+ , " {"
+ , " 's10':"
+ , " {"
+ , " }"
+ , " }"
+ , "}"
+ );
+ }
+ @Test public void Ary() {
+ fxt.Wtr()
+ .Doc_bgn()
+ .Ary_bgn("a0")
+ .Ary_itm_str("v0")
+ .Ary_itm_str("v1")
+ .Ary_end()
+ .Doc_end();
+ fxt.Test
+ ( "{"
+ , " 'a0':"
+ , " ["
+ , " 'v0'"
+ , " , 'v1'"
+ , " ]"
+ , "}"
+ );
+ }
+}
+class Json_wtr_fxt {
+ private final Json_wtr wtr = new Json_wtr().Quote_byte_(Byte_ascii.Apos);
+ public void Clear() {}
+ public Json_wtr Wtr() {return wtr;}
+ public void Test(String... expd) {
+ Tfds.Eq_ary_str
+ ( String_.Ary_add(expd, String_.Ary("")) // json_wtr always ends with "}\n"; rather than add "\n" to each test, just add it here
+ , String_.SplitLines_nl(String_.new_u8(wtr.To_bry_and_clear()))
+ );
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/Xoa_app.java b/400_xowa/src/gplx/xowa/Xoa_app.java
index f8d079692..ce2f6e58b 100644
--- a/400_xowa/src/gplx/xowa/Xoa_app.java
+++ b/400_xowa/src/gplx/xowa/Xoa_app.java
@@ -23,7 +23,7 @@ import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.urls.encoders.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wmfs.*;
-import gplx.xowa.html.wtrs.*;
+import gplx.xowa.html.hrefs.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.js.*;
import gplx.xowa.users.*;
public interface Xoa_app {
Xoa_app_type App_type();
@@ -35,6 +35,7 @@ public interface Xoa_app {
Xoh_href_parser Html__href_parser();
Xoh_lnki_bldr Html__lnki_bldr();
Xoa_css_extractor Html__css_installer();
+ Xoh_json_exec Html__json_exec();
Xou_user User();
Xowmf_mgr Wmf_mgr();
boolean Xwiki_mgr__missing(byte[] domain);
diff --git a/400_xowa/src/gplx/xowa/Xoa_app_.java b/400_xowa/src/gplx/xowa/Xoa_app_.java
index d31cb6978..56c462a00 100644
--- a/400_xowa/src/gplx/xowa/Xoa_app_.java
+++ b/400_xowa/src/gplx/xowa/Xoa_app_.java
@@ -26,7 +26,7 @@ public class Xoa_app_ {
boot_mgr.Run(args);
}
public static final String Name = "xowa";
- public static final String Version = "2.6.5.1";
+ public static final String Version = "2.7.1.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys;
public static String User_agent = "";
diff --git a/400_xowa/src/gplx/xowa/Xoae_app.java b/400_xowa/src/gplx/xowa/Xoae_app.java
index f3bb773db..1c0d2cd80 100644
--- a/400_xowa/src/gplx/xowa/Xoae_app.java
+++ b/400_xowa/src/gplx/xowa/Xoae_app.java
@@ -22,7 +22,7 @@ import gplx.xowa.langs.*; import gplx.xowa.specials.*; import gplx.xowa.cfgs2.*;
import gplx.xowa.bldrs.css.*;
import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.wikis.*; import gplx.xowa.users.*; import gplx.xowa.gui.*; import gplx.xowa.cfgs.*; import gplx.xowa.ctgs.*; import gplx.xowa.html.tocs.*; import gplx.xowa.fmtrs.*; import gplx.xowa.html.*;
-import gplx.xowa.html.wtrs.*; import gplx.xowa.html.ns_files.*;
+import gplx.xowa.html.hrefs.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.ns_files.*; import gplx.xowa.html.js.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.tblws.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.math.*;
import gplx.xowa.parsers.logs.*; import gplx.xowa.servers.tcp.*; import gplx.xowa.servers.http.*;
@@ -62,6 +62,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
cfg_regy = new Xocfg_regy(this);
html_mgr = new Xoh_html_mgr(this);
this.html__lnki_bldr = new Xoh_lnki_bldr(this, href_parser);
+ this.html__json_exec = new Xoh_json_exec(this);
}
public Xoa_app_type App_type() {return app_type;} private final Xoa_app_type app_type;
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
@@ -71,6 +72,7 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
public Xoh_href_parser Html__href_parser() {return href_parser;} private Xoh_href_parser href_parser;
public Xoh_lnki_bldr Html__lnki_bldr() {return html__lnki_bldr;} private final Xoh_lnki_bldr html__lnki_bldr;
public Xoa_css_extractor Html__css_installer() {return html__css_installer;} private final Xoa_css_extractor html__css_installer = new Xoa_css_extractor();
+ public Xoh_json_exec Html__json_exec() {return html__json_exec;} private final Xoh_json_exec html__json_exec;
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
public Url_encoder_mgr Utl__encoder_mgr() {return Xoa_app_.Utl__encoder_mgr();}
diff --git a/400_xowa/src/gplx/xowa/apis/Xoapi_doc.java b/400_xowa/src/gplx/xowa/apis/Xoapi_doc.java
index 5c25c1ac8..200b1ee30 100644
--- a/400_xowa/src/gplx/xowa/apis/Xoapi_doc.java
+++ b/400_xowa/src/gplx/xowa/apis/Xoapi_doc.java
@@ -103,6 +103,7 @@ gui {
}
prog {
focus();
+ show_short_link;
}
info {
focus();
@@ -148,8 +149,7 @@ gui {
}
}
}
-html {
-
+html {
}
net {
}
diff --git a/400_xowa/src/gplx/xowa/apis/xowa/gui/browsers/Xoapi_prog.java b/400_xowa/src/gplx/xowa/apis/xowa/gui/browsers/Xoapi_prog.java
index ebe530aed..0e4f2aa48 100644
--- a/400_xowa/src/gplx/xowa/apis/xowa/gui/browsers/Xoapi_prog.java
+++ b/400_xowa/src/gplx/xowa/apis/xowa/gui/browsers/Xoapi_prog.java
@@ -19,12 +19,16 @@ package gplx.xowa.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; imp
import gplx.gfui.*; import gplx.xowa.gui.views.*;
public class Xoapi_prog implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
- private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
+ private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
+ public boolean Show_short_url() {return show_short_url;} private boolean show_short_url;
public void Focus() {this.Win().Prog_box().Focus();}
+
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
+ else if (ctx.Match(k, Invk_show_short_url)) return Yn.Xto_str(show_short_url);
+ else if (ctx.Match(k, Invk_show_short_url_)) show_short_url = m.ReadBool("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
- private static final String Invk_focus = "focus";
+ private static final String Invk_focus = "focus", Invk_show_short_url = "show_short_url", Invk_show_short_url_ = "show_short_url_";
}
diff --git a/400_xowa/src/gplx/xowa/apis/xowa/navs/Xoapi_wiki.java b/400_xowa/src/gplx/xowa/apis/xowa/navs/Xoapi_wiki.java
index 828144b66..708749cb7 100644
--- a/400_xowa/src/gplx/xowa/apis/xowa/navs/Xoapi_wiki.java
+++ b/400_xowa/src/gplx/xowa/apis/xowa/navs/Xoapi_wiki.java
@@ -17,6 +17,7 @@ along with this program. If not, see .
*/
package gplx.xowa.apis.xowa.navs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
import gplx.xowa.gui.views.*;
+import gplx.xowa.html.hrefs.*;
public class Xoapi_wiki implements GfoInvkAble {
private Xog_win_itm win;
public void Init_by_kit(Xoae_app app) {
diff --git a/400_xowa/src/gplx/xowa/apis/xowa/usrs/Xoapi_bookmarks.java b/400_xowa/src/gplx/xowa/apis/xowa/usrs/Xoapi_bookmarks.java
index de3bd9d3e..57b11b15c 100644
--- a/400_xowa/src/gplx/xowa/apis/xowa/usrs/Xoapi_bookmarks.java
+++ b/400_xowa/src/gplx/xowa/apis/xowa/usrs/Xoapi_bookmarks.java
@@ -51,7 +51,7 @@ public class Xoapi_bookmarks implements GfoInvkAble {
// url = app.Utl__url_parser().Parse(Bry_.new_u8(url_str));
// app.User().User_db_mgr().Bmk_mgr().Add(url);
// }
-// public void Show() {win.Page__navigate_by_url_bar("home/wiki/System:XowaBookmarks");}
+// public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaBookmarks");}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
diff --git a/400_xowa/src/gplx/xowa/apps/Xoa_shell.java b/400_xowa/src/gplx/xowa/apps/Xoa_shell.java
index cd9d9a072..62a5cfd22 100644
--- a/400_xowa/src/gplx/xowa/apps/Xoa_shell.java
+++ b/400_xowa/src/gplx/xowa/apps/Xoa_shell.java
@@ -27,7 +27,9 @@ public class Xoa_shell implements GfoInvkAble {
return this;
}
private String Fetch_page(GfoMsg m) {
- return String_.new_u8(app.Gui_mgr().Browser_win().App__retrieve_by_url(m.ReadStr("url"), m.ReadStrOr("output_type", "html")));
+ String url = m.ReadStr("url");
+ if (String_.Has_at_bgn(url, "//")) url = String_.Replace(url, "//", ""); // NOTE: handle Firefox_addon which sometimes sends urls of the form "//wiki/" when coming from the sidebar; DATE:2015-07-04
+ return String_.new_u8(app.Gui_mgr().Browser_win().App__retrieve_by_url(url, m.ReadStrOr("output_type", "html")));
}
private static final String Invk_fetch_page = "fetch_page"
, Invk_chars_per_line_max_ = "chars_per_line_max_"
diff --git a/400_xowa/src/gplx/xowa/bldrs/cmds/files/Xob_fsdb_make_cmd.java b/400_xowa/src/gplx/xowa/bldrs/cmds/files/Xob_fsdb_make_cmd.java
index 1461ea10c..69b814bdd 100644
--- a/400_xowa/src/gplx/xowa/bldrs/cmds/files/Xob_fsdb_make_cmd.java
+++ b/400_xowa/src/gplx/xowa/bldrs/cmds/files/Xob_fsdb_make_cmd.java
@@ -73,8 +73,9 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
this.trg_atr_fil = trg_mnt_itm.Atr_mgr().Db__core();
this.trg_cfg_mgr = trg_mnt_itm.Cfg_mgr();
bin_db_mgr.Init_by_mnt_mgr(trg_mnt_mgr);
- trg_atr_fil.Conn().Txn_bgn();
- trg_cfg_mgr.Tbl().Conn().Txn_bgn();
+ trg_atr_fil.Conn().Txn_bgn();
+ if (!trg_atr_fil.Conn().Eq(trg_cfg_mgr.Tbl().Conn())) // need to create txn for v1; DATE:2015-07-04
+ trg_cfg_mgr.Tbl().Conn().Txn_bgn();
// bldr_db
Xob_db_file bldr_db = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir());
this.bldr_conn = bldr_db.Conn();
@@ -122,22 +123,6 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
}
exec_done = true;
}
- public void Cmd_end() {
- usr_dlg.Note_many("", "", "fsdb_make.done: count=~{0} rate=~{1}", exec_count, DecimalAdp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).Xto_str("#,###.000"));
- if (src_fsdb_wkr != null) {
- src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Txn_end(); // NOTE: src_fsdb_wkr will be null if no src db defined
- }
- trg_atr_fil.Conn().Txn_end(); trg_atr_fil.Conn().Rls_conn();
- trg_cfg_mgr.Tbl().Conn().Txn_end(); trg_cfg_mgr.Tbl().Conn().Rls_conn();
- if (!trg_mnt_itm.Db_mgr().File__solo_file()) {
- trg_bin_fil.Conn().Txn_end(); trg_bin_fil.Conn().Rls_conn();
- }
- if (exec_done) {
- bldr_cfg_tbl.Delete_grp(Cfg_fsdb_make); // delete bmks for future reruns; DATE:2014-08-20
- Io_mgr.I.DeleteFil_args(wiki.Fsys_mgr().Root_dir().GenSubFil("xowa.file.make.cfg.gfs")).MissingFails_off().Exec();
- }
- bldr_conn.Rls_conn();
- }
private void Init_bldr_bmks() {
if (!resume_enabled) // clear cfg entries if resume disabled; note that disabled by default; DATE:2014-10-24
bldr_cfg_tbl.Delete_grp(Cfg_fsdb_make);
@@ -241,18 +226,22 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
finally {src_rdr.Rls();}
}
private void Make_trg_bin_file(boolean try_nth, Xodb_tbl_oimg_xfer_itm fsdb, long src_rdr_len) {
- if ( trg_bin_fil != null // null-check needed for 1st call
- && !trg_mnt_itm.Db_mgr().File__solo_file()) // don't close if one file
- trg_bin_fil.Conn().Txn_end(); // close txn
- boolean make = true;
+ boolean make = true, txn_bgn = true;
int tier_id = fsdb.Lnki_tier_id();
Xob_bin_db_itm nth_bin_db = bin_db_mgr.Get_nth_by_tier(tier_id);
if (try_nth) { // try_nth is true; occurs for new runs or changed tier
if ( nth_bin_db.Id() != -1 // nth exists;
- && nth_bin_db.Db_len() + src_rdr_len < trg_bin_db_max) // if src_rdr_len exceeds
- make = false; // do not make; use existing
+ && nth_bin_db.Db_len() + src_rdr_len < trg_bin_db_max) { // if src_rdr_len exceeds
+ make = false; // do not make; use existing
+ txn_bgn = false;
+ }
}
if (make) { // no nth; make it;
+ if (trg_bin_fil != null) { // pre-existing bin_file;
+ trg_bin_fil.Conn().Txn_end(); // close txn before making new db
+ if (trg_mnt_itm.Db_mgr().File__solo_file())
+ txn_bgn = false;
+ }
int ns_id = bin_db_mgr.Get_ns_id(tier_id);
int pt_id = bin_db_mgr.Increment_pt_id(nth_bin_db);
String new_bin_db_name = bin_db_mgr.Gen_name(wiki.Domain_str(), ns_id, pt_id);
@@ -267,7 +256,8 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
this.trg_bin_fil = trg_mnt_itm.Bin_mgr().Dbs__get_at(nth_bin_db.Id());
trg_bin_fil.Bin_len_(nth_bin_db.Db_len());
}
- trg_bin_fil.Conn().Txn_bgn();
+ if (txn_bgn)
+ trg_bin_fil.Conn().Txn_bgn();
}
private void Txn_sav() {
usr_dlg.Prog_many("", "", "committing data: count=~{0} failed=~{1}", exec_count, exec_fail);
@@ -276,7 +266,8 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
bldr_cfg_tbl.Conn().Txn_sav();
trg_cfg_mgr.Next_id_commit();
trg_atr_fil.Conn().Txn_sav();
- trg_cfg_mgr.Tbl().Conn().Txn_sav();
+ if (!trg_atr_fil.Conn().Eq(trg_cfg_mgr.Tbl().Conn())) // need to create txn for v1
+ trg_cfg_mgr.Tbl().Conn().Txn_sav();
if (src_bin_mgr__fsdb_version != null && src_bin_mgr__fsdb_skip_wkrs != null) {
src_fsdb_wkr.Skip_mgr().Skip_term(src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Cfg_mgr());
}
@@ -284,6 +275,24 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
trg_bin_fil.Conn().Txn_sav();
if (exit_after_commit) exit_now = true;
}
+ public void Cmd_end() {
+ usr_dlg.Note_many("", "", "fsdb_make.done: count=~{0} rate=~{1}", exec_count, DecimalAdp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).Xto_str("#,###.000"));
+ if (src_fsdb_wkr != null) {
+ src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Txn_end(); // NOTE: src_fsdb_wkr will be null if no src db defined
+ }
+ trg_atr_fil.Conn().Txn_end(); trg_atr_fil.Conn().Rls_conn();
+ if (!trg_atr_fil.Conn().Eq(trg_cfg_mgr.Tbl().Conn())) // need to create txn for v1
+ trg_cfg_mgr.Tbl().Conn().Txn_end();
+ trg_cfg_mgr.Tbl().Conn().Rls_conn();
+ if (!trg_mnt_itm.Db_mgr().File__solo_file()) {
+ trg_bin_fil.Conn().Txn_end(); trg_bin_fil.Conn().Rls_conn();
+ }
+ if (exec_done) {
+ bldr_cfg_tbl.Delete_grp(Cfg_fsdb_make); // delete bmks for future reruns; DATE:2014-08-20
+ Io_mgr.I.DeleteFil_args(wiki.Fsys_mgr().Root_dir().GenSubFil("xowa.file.make.cfg.gfs")).MissingFails_off().Exec();
+ }
+ bldr_conn.Rls_conn();
+ }
private void Print_progress(Xodb_tbl_oimg_xfer_itm itm) {
int time_elapsed = Env_.TickCount_elapsed_in_sec(time_bgn);
usr_dlg.Prog_many("", "", "prog: num=~{0} err=~{1} time=~{2} rate=~{3} page=~{4} lnki=~{5} ttl=~{6}", exec_count, exec_fail, time_elapsed, Math_.Div_safe_as_int(exec_count, time_elapsed), page_id_val, lnki_id_val, itm.Orig_ttl());
diff --git a/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_extractor.java b/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_extractor.java
index b555cd93b..e8ce7808e 100644
--- a/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_extractor.java
+++ b/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_extractor.java
@@ -49,16 +49,20 @@ public class Xoa_css_extractor {
wiki.Html__page_wtr_mgr().Init_css_urls(css_comm_fil, css_wiki_fil);
if (wiki.Domain_tid() == Xow_domain_type_.Tid_home || Env_.Mode_testing()) return; // NOTE: do not download if home_wiki; also needed for TEST
if (Io_mgr.I.ExistsFil(css_wiki_fil)) return; // css file exists; nothing to generate
+ if (wiki.Html__css_installing()) return;
+ wiki.Html__css_installing_(true);
wiki.App().Usr_dlg().Log_many("", "", "generating css for '~{0}'", wiki.Domain_str());
if (css_key != null) {
if (Install_by_db(wiki, wiki_html_dir, css_key)) return;
}
if (wiki.Type_is_edit())
this.Install_by_wmf((Xowe_wiki)wiki, wiki_html_dir);
+ wiki.Html__css_installing_(false);
}
catch (Exception e) { // if error, failover; paranoia catch for outliers like bad network connectivity fail, or MediaWiki: message not existing; DATE:2013-11-21
wiki.App().Usr_dlg().Warn_many("", "", "failed to get css; failing over; wiki='~{0}' err=~{1}", wiki.Domain_str(), Err_.Message_gplx(e));
Css_common_failover(); // only failover xowa_common.css; xowa_wiki.css comes from MediaWiki:Common.css / Vector.css
+ wiki.Html__css_installing_(false);
}
}
private void Install_by_wmf(Xowe_wiki wiki, Io_url wiki_html_dir) {
@@ -87,8 +91,7 @@ public class Xoa_css_extractor {
return false;
}
Xowd_db_file core_db = core_db_mgr.Db__core();
- gplx.xowa.html.css.Xowd_css_core_mgr.Get(core_db.Tbl__css_core(), core_db.Tbl__css_file(), wiki_html_dir, css_key);
- return true;
+ return gplx.xowa.html.css.Xowd_css_core_mgr.Get(core_db.Tbl__css_core(), core_db.Tbl__css_file(), wiki_html_dir, css_key);
}
public void Css_common_setup() {
if (opt_download_css_common)
diff --git a/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_img_downloader.java b/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_img_downloader.java
index a5082ae80..04a635a7e 100644
--- a/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_img_downloader.java
+++ b/400_xowa/src/gplx/xowa/bldrs/css/Xoa_css_img_downloader.java
@@ -158,7 +158,7 @@ public class Xoa_css_img_downloader {
String src = ary[i];
Io_url trg = css_dir.GenSubFil_nest(Op_sys.Cur().Fsys_http_frag_to_url_str(Replace_invalid_chars_str(src)));
if (Io_mgr.I.ExistsFil(trg)) continue;
- download_wkr.Download(true, "http://" + src, trg, "download: " + src); // ILN
+ download_wkr.Download(true, "https://" + src, trg, "download: " + src); // ILN
}
}
String Replace_invalid_chars_str(String raw_str) {return String_.new_u8(Replace_invalid_chars(Bry_.new_u8(raw_str)));}
diff --git a/400_xowa/src/gplx/xowa/bldrs/wiki_cfgs/Xoi_wiki_props_api.java b/400_xowa/src/gplx/xowa/bldrs/wiki_cfgs/Xoi_wiki_props_api.java
index 7f7634079..7807c48b8 100644
--- a/400_xowa/src/gplx/xowa/bldrs/wiki_cfgs/Xoi_wiki_props_api.java
+++ b/400_xowa/src/gplx/xowa/bldrs/wiki_cfgs/Xoi_wiki_props_api.java
@@ -20,7 +20,7 @@ import gplx.xmls.*; import gplx.ios.*;
public class Xoi_wiki_props_api {
private IoEngine_xrg_downloadFil download_args = IoEngine_xrg_downloadFil.new_("", Io_url_.Empty);
public String Api_src(String wiki_domain) {
- return String_.Concat("http://", wiki_domain, "/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases|namespaces");
+ return String_.Concat("https://", wiki_domain, "/w/api.php?action=query&format=xml&meta=siteinfo&siprop=namespacealiases|namespaces");
}
public byte[] Exec_api(String src) {
return download_args.Exec_as_bry(src);
diff --git a/400_xowa/src/gplx/xowa/cfgs/gui/Xocfg_html.java b/400_xowa/src/gplx/xowa/cfgs/gui/Xocfg_html.java
index 0d98ea99c..7a9267974 100644
--- a/400_xowa/src/gplx/xowa/cfgs/gui/Xocfg_html.java
+++ b/400_xowa/src/gplx/xowa/cfgs/gui/Xocfg_html.java
@@ -19,15 +19,13 @@ package gplx.xowa.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.
public class Xocfg_html implements GfoInvkAble {
public Xocfg_html() {
this.content_editable = false; // CFG: default to false for general user
- this.link_hover_full = false; // CFG: default to false b/c it is easier to read
}
- public boolean Link_hover_full() {return link_hover_full;} public Xocfg_html Link_hover_full_(boolean v) {link_hover_full = v; return this;} private boolean link_hover_full;
public boolean Content_editable() {return content_editable;} public Xocfg_html Content_editable_(boolean v) {content_editable = v; return this;} private boolean content_editable;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_content_editable)) return Yn.Xto_str(content_editable);
else if (ctx.Match(k, Invk_content_editable_)) content_editable = m.ReadYn_toggle("v", content_editable);
- else if (ctx.Match(k, Invk_link_hover_full_)) link_hover_full = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
- } private static final String Invk_link_hover_full_ = "link_hover_full_", Invk_content_editable = "content_editable", Invk_content_editable_ = "content_editable_";
+ }
+ private static final String Invk_content_editable = "content_editable", Invk_content_editable_ = "content_editable_";
}
diff --git a/400_xowa/src/gplx/xowa/ctgs/Xoctg_fmtr_itm.java b/400_xowa/src/gplx/xowa/ctgs/Xoctg_fmtr_itm.java
index d09f81f31..d6ee4c428 100644
--- a/400_xowa/src/gplx/xowa/ctgs/Xoctg_fmtr_itm.java
+++ b/400_xowa/src/gplx/xowa/ctgs/Xoctg_fmtr_itm.java
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.ctgs; import gplx.*; import gplx.xowa.*;
-import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*;
+import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.lnkis.*;
import gplx.xowa.users.history.*;
abstract class Xoctg_fmtr_itm_base implements Xoctg_fmtr_itm {
public void Init_from_all(Xowe_wiki wiki, Xol_lang lang, Xoctg_view_ctg ctg, Xoctg_fmtr_all mgr, Xoctg_view_grp itms_list, int itms_list_len) {
diff --git a/400_xowa/src/gplx/xowa/ctgs/Xoctg_pagelist_itms.java b/400_xowa/src/gplx/xowa/ctgs/Xoctg_pagelist_itms.java
index 2fe1930bc..1a14b2126 100644
--- a/400_xowa/src/gplx/xowa/ctgs/Xoctg_pagelist_itms.java
+++ b/400_xowa/src/gplx/xowa/ctgs/Xoctg_pagelist_itms.java
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.ctgs; import gplx.*; import gplx.xowa.*;
-import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.wikis.data.tbls.*;
+import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.users.history.*;
public class Xoctg_pagelist_itms implements Bry_fmtr_arg {
public void Init_app(Xoae_app app, Bry_fmtr fmtr_itm) {
diff --git a/400_xowa/src/gplx/xowa/dbs/Xodb_mgr_sql.java b/400_xowa/src/gplx/xowa/dbs/Xodb_mgr_sql.java
index c4e04c0ff..e6e767f53 100644
--- a/400_xowa/src/gplx/xowa/dbs/Xodb_mgr_sql.java
+++ b/400_xowa/src/gplx/xowa/dbs/Xodb_mgr_sql.java
@@ -22,7 +22,7 @@ import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
public Xodb_mgr_sql(Xowe_wiki wiki) {
this.wiki = wiki;
- this.core_data_mgr = new Xowd_db_mgr(wiki.Fsys_mgr().Root_dir(), wiki.Domain_itm());
+ this.core_data_mgr = new Xowd_db_mgr(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Domain_itm());
this.load_mgr = new Xodb_load_mgr_sql(this, core_data_mgr);
this.save_mgr = new Xodb_save_mgr_sql(this, wiki.Page_mgr());
}
diff --git a/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr.java b/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr.java
index 6049fe1cb..0185f77dc 100644
--- a/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr.java
+++ b/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr.java
@@ -17,6 +17,7 @@ along with this program. If not, see .
*/
package gplx.xowa.gui.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*;
+import gplx.xowa.html.hrefs.*;
import gplx.xowa.gui.views.*;
public class Xog_url_wkr {
private Xoh_href href = new Xoh_href();
diff --git a/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr_tst.java b/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr_tst.java
index 1b974dfbf..45860cd4c 100644
--- a/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr_tst.java
+++ b/400_xowa/src/gplx/xowa/gui/urls/Xog_url_wkr_tst.java
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.gui.urls; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
-import org.junit.*; import gplx.xowa.gui.views.*;
+import org.junit.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.gui.views.*;
public class Xog_url_wkr_tst {
@Before public void init() {fxt.Clear();} private Xog_url_wkr_fxt fxt = new Xog_url_wkr_fxt();
@Test public void term() {fxt.Clear();}
diff --git a/400_xowa/src/gplx/xowa/gui/views/Xog_html_itm.java b/400_xowa/src/gplx/xowa/gui/views/Xog_html_itm.java
index 5b4778b58..a53b8fb77 100644
--- a/400_xowa/src/gplx/xowa/gui/views/Xog_html_itm.java
+++ b/400_xowa/src/gplx/xowa/gui/views/Xog_html_itm.java
@@ -18,7 +18,7 @@ along with this program. If not, see .
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
import gplx.core.primitives.*; import gplx.core.btries.*;
import gplx.gfui.*; import gplx.xowa.gui.menus.*; import gplx.xowa.gui.menus.dom.*; import gplx.xowa.files.gui.*;
-import gplx.html.*; import gplx.xowa.html.modules.*; import gplx.xowa.pages.*;
+import gplx.html.*; import gplx.xowa.html.js.*; import gplx.xowa.html.modules.*; import gplx.xowa.pages.*;
public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
private Xoae_app app; private final Object thread_lock = new Object();
private final String_obj_ref scroll_top = String_obj_ref.null_(), node_path = String_obj_ref.null_();
@@ -26,7 +26,7 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
public Xog_html_itm(Xog_tab_itm owner_tab) {
this.owner_tab = owner_tab;
app = owner_tab.Tab_mgr().Win().App();
- js_cbk = new Xog_html_js_cbk(this);
+ js_cbk = new Xoh_js_cbk(this);
Gfui_kit kit = owner_tab.Tab_mgr().Win().Kit();
cmd_sync = kit.New_cmd_sync(this); // NOTE: always use sync; async will cause some images to be "lost" in update;
cmd_async = kit.New_cmd_async(this);
@@ -35,7 +35,7 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
public Xog_tab_itm Owner_tab() {return owner_tab;} private Xog_tab_itm owner_tab;
public Gfui_html Html_box() {return html_box;} private Gfui_html html_box;
- public Xog_html_js_cbk Js_cbk() {return js_cbk;} private Xog_html_js_cbk js_cbk;
+ public Xoh_js_cbk Js_cbk() {return js_cbk;} private Xoh_js_cbk js_cbk;
public GfoInvkAble Cmd_sync() {return cmd_sync;} private GfoInvkAble cmd_sync;
public GfoInvkAble Cmd_async() {return cmd_async;} private GfoInvkAble cmd_async;
public void Switch_mem(Xog_html_itm comp) {
@@ -83,8 +83,8 @@ public class Xog_html_itm implements Xog_js_wkr, GfoInvkAble, GfoEvObj {
Xog_html_itm src_itm = this;
Gfui_html src_html = html_box;
Gfui_html trg_html = trg_itm.html_box;
- Xog_html_js_cbk src_js_cbk = js_cbk;
- Xog_html_js_cbk trg_js_cbk = trg_itm.js_cbk;
+ Xoh_js_cbk src_js_cbk = js_cbk;
+ Xoh_js_cbk trg_js_cbk = trg_itm.js_cbk;
src_itm.html_box = trg_html;
trg_itm.html_box = src_html;
src_itm.js_cbk = trg_js_cbk;
diff --git a/400_xowa/src/gplx/xowa/gui/views/Xog_win_itm__prog_href_mgr.java b/400_xowa/src/gplx/xowa/gui/views/Xog_win_itm__prog_href_mgr.java
index 0484841d2..da11afb64 100644
--- a/400_xowa/src/gplx/xowa/gui/views/Xog_win_itm__prog_href_mgr.java
+++ b/400_xowa/src/gplx/xowa/gui/views/Xog_win_itm__prog_href_mgr.java
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
-import gplx.gfui.*;
+import gplx.gfui.*; import gplx.xowa.html.hrefs.*;
public class Xog_win_itm__prog_href_mgr {
private static Xoh_href tmp_href = new Xoh_href();
private static Bry_bfr tmp_bfr = Bry_bfr.reset_(512);
@@ -34,7 +34,7 @@ public class Xog_win_itm__prog_href_mgr {
return;
}
app.Href_parser().Parse(tmp_href, href, wiki, page.Ttl().Page_url());
- tmp_href.Print_to_bfr(tmp_bfr, wiki.Gui_mgr().Cfg_browser().Link_hover_full());
+ tmp_href.Print_to_bfr(tmp_bfr, !app.Api_root().Gui().Browser().Prog().Show_short_url());
usr_dlg.Prog_direct(tmp_bfr.Xto_str_and_clear());
}
}
diff --git a/400_xowa/src/gplx/xowa/html/css/Xowd_css_core_mgr.java b/400_xowa/src/gplx/xowa/html/css/Xowd_css_core_mgr.java
index dfa06124f..8a8db185f 100644
--- a/400_xowa/src/gplx/xowa/html/css/Xowd_css_core_mgr.java
+++ b/400_xowa/src/gplx/xowa/html/css/Xowd_css_core_mgr.java
@@ -42,16 +42,18 @@ public class Xowd_css_core_mgr {
}
catch (Exception e) {conn.Txn_cxl(); throw Err_.err_(e);}
}
- public static void Get(Xowd_css_core_tbl core_tbl, Xowd_css_file_tbl file_tbl, Io_url css_dir, String key) {
- int css_id = core_tbl.Select_id_by_key(key); if (css_id == Xowd_css_core_tbl.Id_null) throw Err_.new_("skin:unknown key: {0}", key);
+ public static boolean Get(Xowd_css_core_tbl core_tbl, Xowd_css_file_tbl file_tbl, Io_url css_dir, String key) {
+ int css_id = core_tbl.Select_id_by_key(key); if (css_id == Xowd_css_core_tbl.Id_null) return false; // unknown key; return false (not found)
Xowd_css_file_itm[] file_list = file_tbl.Select_by_owner(css_id);
// Io_mgr.I.DeleteDirDeep(css_dir); // NOTE: do not delete existing files; just overwrite;
int len = file_list.length;
+ if (len == 0) return false; // no css files in db
for (int i = 0; i < len; ++i) {
Xowd_css_file_itm file = file_list[i];
Io_url file_url = Io_url_.new_fil_(css_dir.Gen_sub_path_for_os(file.Path()));
Io_mgr.I.SaveFilBry(file_url, file.Data());
}
+ return true;
}
public static final String Key_default = "xowa.default", Key_mobile = "xowa.mobile";
}
diff --git a/400_xowa/src_310_url/gplx/xowa/Xoh_href.java b/400_xowa/src/gplx/xowa/html/hrefs/Xoh_href.java
similarity index 95%
rename from 400_xowa/src_310_url/gplx/xowa/Xoh_href.java
rename to 400_xowa/src/gplx/xowa/html/hrefs/Xoh_href.java
index 53bb23a82..9a2c631d0 100644
--- a/400_xowa/src_310_url/gplx/xowa/Xoh_href.java
+++ b/400_xowa/src/gplx/xowa/html/hrefs/Xoh_href.java
@@ -15,7 +15,7 @@ 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 .
*/
-package gplx.xowa; import gplx.*;
+package gplx.xowa.html.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
public class Xoh_href {
public byte[] Raw() {return raw;} public Xoh_href Raw_(byte[] v) {raw = v; return this;} private byte[] raw;
public byte[] Wiki() {return wiki;} public Xoh_href Wiki_(byte[] v) {wiki = v; return this;} private byte[] wiki;
diff --git a/400_xowa/src_310_url/gplx/xowa/Xoh_href_parser.java b/400_xowa/src/gplx/xowa/html/hrefs/Xoh_href_parser.java
similarity index 97%
rename from 400_xowa/src_310_url/gplx/xowa/Xoh_href_parser.java
rename to 400_xowa/src/gplx/xowa/html/hrefs/Xoh_href_parser.java
index 944b39918..8f95c4d63 100644
--- a/400_xowa/src_310_url/gplx/xowa/Xoh_href_parser.java
+++ b/400_xowa/src/gplx/xowa/html/hrefs/Xoh_href_parser.java
@@ -15,7 +15,7 @@ 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 .
*/
-package gplx.xowa; import gplx.*;
+package gplx.xowa.html.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.core.btries.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.net.*; import gplx.xowa.parsers.lnkes.*;
import gplx.xowa.wikis.*;
public class Xoh_href_parser {
diff --git a/400_xowa/src_310_url/gplx/xowa/Xoh_href_parser_tst.java b/400_xowa/src/gplx/xowa/html/hrefs/Xoh_href_parser_tst.java
similarity index 86%
rename from 400_xowa/src_310_url/gplx/xowa/Xoh_href_parser_tst.java
rename to 400_xowa/src/gplx/xowa/html/hrefs/Xoh_href_parser_tst.java
index 3cd191d66..d5cca1816 100644
--- a/400_xowa/src_310_url/gplx/xowa/Xoh_href_parser_tst.java
+++ b/400_xowa/src/gplx/xowa/html/hrefs/Xoh_href_parser_tst.java
@@ -15,7 +15,7 @@ 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 .
*/
-package gplx.xowa; import gplx.*;
+package gplx.xowa.html.hrefs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*;
import gplx.xowa.net.*;
public class Xoh_href_parser_tst {
@@ -132,14 +132,14 @@ public class Xoh_href_parser_tst {
.Test_parse();
}
- @Test public void Parse_brief_wiki() {fxt.Init_hover_full_n_().Test_parse("file:///wiki/A" , "A");}
- @Test public void Parse_brief_http() {fxt.Init_hover_full_n_().Test_parse("http://a.org/b" , "http://a.org/b");}
- @Test public void Parse_brief_file() {fxt.Init_hover_full_n_().Test_parse("file:///C/xowa/file/a.png" , "file:///C/xowa/file/a.png");}
- @Test public void Parse_brief_anchor() {fxt.Init_hover_full_n_().Test_parse("#a" , "#a");}
- @Test public void Parse_brief_anchor_file() {fxt.Init_hover_full_n_().Test_parse("file:///#a" , "#a");}
- @Test public void Parse_brief_xwiki() {fxt.Init_hover_full_n_().Test_parse("file:///site/en.wikt.org/wiki/Page" , "en.wikt.org/Page");}
- @Test public void Parse_brief_xwiki_2() {fxt.Init_hover_full_n_().Expd_page_("a").Test_parse("/wiki/wikt:a" , "en.wiktionary.org/a");}
- @Test public void Parse_brief_error() {fxt.Init_hover_full_n_().Test_parse("file:///wiki/{{{extlink}}}" , "");} // {{{extlink}}} not a valid title; return empty
+ @Test public void Hover_string_wiki() {fxt.Init_hover_full_n_().Test_hover_string("file:///wiki/A" , "A");}
+ @Test public void Hover_string_http() {fxt.Init_hover_full_n_().Test_hover_string("http://a.org/b" , "http://a.org/b");}
+ @Test public void Hover_string_file() {fxt.Init_hover_full_n_().Test_hover_string("file:///C/xowa/file/a.png" , "file:///C/xowa/file/a.png");}
+ @Test public void Hover_string_anchor() {fxt.Init_hover_full_n_().Test_hover_string("#a" , "#a");}
+ @Test public void Hover_string_anchor_file() {fxt.Init_hover_full_n_().Test_hover_string("file:///#a" , "#a");}
+ @Test public void Hover_string_xwiki() {fxt.Init_hover_full_n_().Test_hover_string("file:///site/en.wikt.org/wiki/Page" , "en.wikt.org/Page");}
+ @Test public void Hover_string_xwiki_2() {fxt.Init_hover_full_n_().Expd_page_("a").Test_hover_string("/wiki/wikt:a" , "en.wiktionary.org/a");}
+ @Test public void Hover_string_error() {fxt.Init_hover_full_n_().Test_hover_string("file:///wiki/{{{extlink}}}" , "");} // {{{extlink}}} not a valid title; return empty
// @Test public void Parse_site_qarg() {fxt.Prep_raw_("/site/en.wikt.org/wiki/A?action=edit").Expd_tid_(Xoh_href.Tid_site).Expd_full_("en.wikt.org/wiki/A").Expd_page_("A").Expd_qarg_("action=edit").Test_parse();}
// @Test public void Parse_wiki_qarg() {fxt.Prep_raw_("/wiki/A?action=edit").Expd_tid_(Xoh_href.Tid_wiki).Expd_full_("en.wikipedia.org/wiki/A").Expd_page_("A").Expd_qarg_("action=edit").Test_parse();}
//@Test public void Parse_site_anchor() {fxt.Prep_raw_("/site/en.wikt.org/wiki/A#b_c" ).Expd_tid_(Xoh_href.Tid_site).Expd_full_("en.wikt.org/wiki/A#b_c").Expd_page_("A").Expd_anch_("b_c").Test_parse();}
@@ -213,7 +213,7 @@ class Xoh_href_parser_fxt {
}
public Xoh_href_parser_fxt Init_hover_full_y_() {return Init_hover_full_(Bool_.Y);}
public Xoh_href_parser_fxt Init_hover_full_n_() {return Init_hover_full_(Bool_.N);}
- public Xoh_href_parser_fxt Init_hover_full_(boolean v) {wiki.Gui_mgr().Cfg_browser().Link_hover_full_(v); return this;}
+ public Xoh_href_parser_fxt Init_hover_full_(boolean v) {show_full_hover_string = v; return this;}
public Xoh_href_parser_fxt Prep_raw_(String v) {this.prep_raw = v; return this;} private String prep_raw;
public Xoh_href_parser_fxt Expd_tid_(byte v) {this.expd_tid = v; return this;} private byte expd_tid;
public Xoh_href_parser_fxt Expd_full_(String v) {this.expd_full = v; return this;} private String expd_full;
@@ -231,9 +231,10 @@ class Xoh_href_parser_fxt {
Tfds.Eq(expd_full, tmp_bfr.Xto_str_and_clear());
}
}
- public void Test_parse(String raw, String expd) {
+ private boolean show_full_hover_string = false;
+ public void Test_hover_string(String raw, String expd) {
href_parser.Parse(href, raw, wiki, Page_1_ttl);
- href.Print_to_bfr(tmp_bfr, wiki.Gui_mgr().Cfg_browser().Link_hover_full());
+ href.Print_to_bfr(tmp_bfr, show_full_hover_string);
Tfds.Eq(expd, tmp_bfr.Xto_str_and_clear());
}
public void Test_build(String raw, String expd) {
diff --git a/400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk.java b/400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk.java
similarity index 92%
rename from 400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk.java
rename to 400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk.java
index b45923c2b..b3424dd49 100644
--- a/400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk.java
+++ b/400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk.java
@@ -15,14 +15,17 @@ 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 .
*/
-package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
+package gplx.xowa.html.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.core.threads.*; import gplx.xowa.xtns.pfuncs.ifs.*; import gplx.xowa.wikis.data.tbls.*;
-public class Xog_html_js_cbk implements GfoInvkAble {
+import gplx.json.*;
+import gplx.xowa.html.js.*;
+import gplx.xowa.gui.views.*;
+public class Xoh_js_cbk implements GfoInvkAble {
private Xoae_app app;
private Xog_html_itm html_itm;
private Xop_root_tkn root = new Xop_root_tkn();
- private Bry_bfr bfr = Bry_bfr.reset_(255);
- public Xog_html_js_cbk(Xog_html_itm html_itm) {this.html_itm = html_itm; this.app = html_itm.Owner_tab().Tab_mgr().Win().App();}
+ private final Bry_bfr bfr = Bry_bfr.reset_(255);
+ public Xoh_js_cbk(Xog_html_itm html_itm) {this.html_itm = html_itm; this.app = html_itm.Owner_tab().Tab_mgr().Win().App();}
private String Xowa_exec_test(GfoMsg m) { // concat args with pipe; EX: xowa_exec('proc', 'arg0', 'arg1'); -> proc|arg0|arg1
bfr.Clear();
bfr.Add_str(m.Key());
@@ -181,12 +184,14 @@ public class Xog_html_js_cbk implements GfoInvkAble {
else if (ctx.Match(k, Invk_get_current_url)) return String_.new_u8(html_itm.Owner_tab().Page().Url().Raw());
else if (ctx.Match(k, Invk_xowa_exec_test)) return Xowa_exec_test(m);
else if (ctx.Match(k, Invk_xowa_exec_test_as_array)) return Xowa_exec_test_as_array(m);
+ else if (ctx.Match(k, Invk_exec_json)) return app.Html__json_exec().Exec_json(m);
else return GfoInvkAble_.Rv_unhandled;
}
public static final String Invk_parse_to_html = "parse_to_html", Invk_wikidata_get_label = "wikidata_get_label", Invk_get_page = "get_page", Invk_cmd = "cmd", Invk_scripts_exec = "scripts_exec"
, Invk_get_search_suggestions = "get_search_suggestions", Invk_get_titles_meta = "get_titles_meta", Invk_get_titles_exists = "get_titles_exists", Invk_get_current_url = "get_current_url"
, Invk_xowa_exec_test = "xowa_exec_test", Invk_xowa_exec_test_as_array = "xowa_exec_test_as_array"
, Invk_popups_get_async_bgn = "popups_get_async_bgn"
- , Invk_popups_get_html = "popups_get_html"
+ , Invk_popups_get_html = "popups_get_html"
+ , Invk_exec_json = "exec_json"
;
}
diff --git a/400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk_tst.java b/400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk_tst.java
similarity index 77%
rename from 400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk_tst.java
rename to 400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk_tst.java
index b89e992bf..2f4e905d5 100644
--- a/400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk_tst.java
+++ b/400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk_tst.java
@@ -15,17 +15,18 @@ 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 .
*/
-package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
+package gplx.xowa.html.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*; import gplx.xowa.xtns.wdatas.*;
-public class Xog_html_js_cbk_tst {
- @Before public void init() {fxt.Clear();} private Xog_html_js_cbk_fxt fxt = new Xog_html_js_cbk_fxt();
+import gplx.xowa.gui.views.*;
+public class Xoh_js_cbk_tst {
+ @Before public void init() {fxt.Clear();} private Xoh_js_cbk_fxt fxt = new Xoh_js_cbk_fxt();
@Test public void Get_title() {
fxt.Fxt().Init_page_create("exists");
fxt.Test_get_title("exists", "1" , "0" , Int_.Xto_str(Int_.MinValue), "Exists", "false", "0001-01-01 00:00:00", "0");
fxt.Test_get_title("absent", "0", "-1", Int_.Xto_str(Int_.MinValue), null , "false", "0001-01-01 00:00:00", "0");
}
}
-class Xog_html_js_cbk_fxt {
+class Xoh_js_cbk_fxt {
public void Clear() {
fxt = new Xop_fxt();
Xoa_app_fxt.Init_gui(fxt.App(), fxt.Wiki());
@@ -37,9 +38,9 @@ class Xog_html_js_cbk_fxt {
Xoae_page page = Xoae_page.test_(wiki, Xoa_ttl.parse_(wiki, Bry_.new_a7("mock_page")));
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab();
tab.Page_(page);
- Xog_html_js_cbk exec = tab.Html_itm().Js_cbk();
- GfoMsg msg = GfoMsg_.new_cast_(Xog_html_js_cbk.Invk_get_titles_meta).Add("ttl", ttl);
- String[][] actl = (String[][])GfoInvkAble_.InvkCmd_msg(exec, Xog_html_js_cbk.Invk_get_titles_meta, msg);
+ Xoh_js_cbk exec = tab.Html_itm().Js_cbk();
+ GfoMsg msg = GfoMsg_.new_cast_(Xoh_js_cbk.Invk_get_titles_meta).Add("ttl", ttl);
+ String[][] actl = (String[][])GfoInvkAble_.InvkCmd_msg(exec, Xoh_js_cbk.Invk_get_titles_meta, msg);
Tfds.Eq_ary_str(expd, actl[0]);
}
}
diff --git a/400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk_wdata_labels_tst.java b/400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk_wdata_labels_tst.java
similarity index 85%
rename from 400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk_wdata_labels_tst.java
rename to 400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk_wdata_labels_tst.java
index dc721eed0..feab53703 100644
--- a/400_xowa/src/gplx/xowa/gui/views/Xog_html_js_cbk_wdata_labels_tst.java
+++ b/400_xowa/src/gplx/xowa/html/js/Xoh_js_cbk_wdata_labels_tst.java
@@ -15,9 +15,9 @@ 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 .
*/
-package gplx.xowa.gui.views; import gplx.*; import gplx.xowa.*; import gplx.xowa.gui.*;
+package gplx.xowa.html.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import org.junit.*; import gplx.xowa.xtns.wdatas.*;
-public class Xog_html_js_cbk_wdata_labels_tst {
+public class Xoh_js_cbk_wdata_labels_tst {
@Before public void init() {fxt.Init();} Wdata_wiki_mgr_fxt fxt = new Wdata_wiki_mgr_fxt();
@Test public void Basic() {
fxt.Init_pages_add(fxt.Wdoc_bldr("q1").Add_label("en", "en_q1").Xto_wdoc());
@@ -52,12 +52,12 @@ public class Xog_html_js_cbk_wdata_labels_tst {
}
private void Tst_wikidata_label_get(String[] args, String[] expd) {
Xoa_app_fxt.Init_gui(fxt.App(), fxt.Wiki());
- Xog_html_js_cbk exec = fxt.App().Gui_mgr().Browser_win().Active_html_itm().Js_cbk();
- GfoMsg msg = GfoMsg_.new_cast_(Xog_html_js_cbk.Invk_wikidata_get_label);
+ Xoh_js_cbk exec = fxt.App().Gui_mgr().Browser_win().Active_html_itm().Js_cbk();
+ GfoMsg msg = GfoMsg_.new_cast_(Xoh_js_cbk.Invk_wikidata_get_label);
int args_len = args.length;
for (int i = 0; i < args_len; i++)
msg.Add("v", args[i]);
- String[] actl = (String[])GfoInvkAble_.InvkCmd_msg(exec, Xog_html_js_cbk.Invk_wikidata_get_label, msg);
+ String[] actl = (String[])GfoInvkAble_.InvkCmd_msg(exec, Xoh_js_cbk.Invk_wikidata_get_label, msg);
Tfds.Eq_ary_str(expd, actl);
}
}
diff --git a/400_xowa/src/gplx/xowa/html/js/Xoh_json_exec.java b/400_xowa/src/gplx/xowa/html/js/Xoh_json_exec.java
new file mode 100644
index 000000000..2814cffaf
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/js/Xoh_json_exec.java
@@ -0,0 +1,53 @@
+/*
+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 .
+*/
+package gplx.xowa.html.js; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
+import gplx.core.primitives.*;
+import gplx.json.*;
+public class Xoh_json_exec {
+ private final Xoa_app app;
+ public Xoh_json_exec(Xoa_app app) {this.app = app;}
+ public String Exec_json(GfoMsg m) {
+ if (m.Args_count() == 0) throw Err_.new_("xowa_exec.json; no json specified for json_exec");
+ return Exec_json(m.Args_getAt(0).Val_to_bry());
+ }
+ public String Exec_json(byte[] jdoc_bry) {
+ Json_doc jdoc = null;
+ try {jdoc = Json_doc.new_(jdoc_bry);}
+ catch (Exception e) {throw Err_.new_("xowa_exec.json; invalid json; json={0} err={1}", jdoc_bry, Err_.Message_gplx_brief(e));}
+ return Xoui_exec(jdoc, jdoc.Root());
+ }
+ private String Xoui_exec(Json_doc jdoc, Json_itm_nde nde) {
+ byte[] wiki_bry = nde.Subs_get_val_by_key_as_bry(Key_wiki, null); if (wiki_bry == null) throw Err_.new_("xoui_exec.json; no wiki specified; json={0}", jdoc.Src());
+ byte[] proc_bry = nde.Subs_get_val_by_key_as_bry(Key_proc, null); if (proc_bry == null) throw Err_.new_("xoui_exec.json; no proc specified; json={0}", jdoc.Src());
+ Xow_wiki wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(wiki_bry);
+ Object tid_obj = proc_hash.Get_by(proc_bry); if (tid_obj == null) throw Err_.new_("xoui_exec.json; invalid tid; json={0}", jdoc.Src());
+ switch (((Byte_obj_val)tid_obj).Val()) {
+ case Tid_edit : return wiki.Html__xoui_tbl_mgr().Edit(jdoc);
+ case Tid_save : return wiki.Html__xoui_tbl_mgr().Save(jdoc);
+ case Tid_delete : return wiki.Html__xoui_tbl_mgr().Del(jdoc);
+ }
+ throw Err_.new_("xoui_exec.json; cmd not handled; json={0}", jdoc.Src());
+ }
+ private static final byte[] Key_wiki = Bry_.new_a7("wiki"), Key_proc = Bry_.new_a7("proc");
+ private static final byte Tid_edit = 1, Tid_save = 2, Tid_delete = 3;
+ private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs_()
+ .Add_str_byte("xowa.xoui.grid.edit" , Tid_edit)
+ .Add_str_byte("xowa.xoui.grid.save" , Tid_save)
+ .Add_str_byte("xowa.xoui.grid.delete" , Tid_delete)
+ ;
+}
diff --git a/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm_.java b/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm_.java
index e041180af..657501a86 100644
--- a/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm_.java
+++ b/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm_.java
@@ -31,5 +31,6 @@ public class Xoh_module_itm_ {
, Key_title_rewrite = Bry_.new_a7("title_rewrite")
, Key_toc = Bry_.new_a7("toc")
, Key_top_icon = Bry_.new_a7("top_icon")
+ , Key_xoui = Bry_.new_a7("xoui")
;
}
diff --git a/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm__xoui.java b/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm__xoui.java
new file mode 100644
index 000000000..e778e5f36
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/modules/Xoh_module_itm__xoui.java
@@ -0,0 +1,47 @@
+/*
+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 .
+*/
+package gplx.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
+import gplx.xowa.gui.*;
+public class Xoh_module_itm__xoui implements Xoh_module_itm {
+ public byte[] Key() {return Xoh_module_itm_.Key_xoui;}
+ public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
+ public void Clear() {enabled = false;}
+ public Xoh_module_itm__xoui Init(Xoae_app app) {
+ if (dir_url == null) {
+ dir_url = app.Fsys_mgr().Bin_any_dir().GenSubDir_nest("xowa", "html", "res", "src", "xowa", "xoui");
+ url_hui_js = dir_url.GenSubFil("xoui.js").To_http_file_bry();
+ }
+ return this;
+ }
+ public void Write_css_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
+ public void Write_css_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
+ public void Write_js_include(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
+ if (!enabled) return;
+ wtr.Write_js_include(url_hui_js);
+ }
+ public void Write_js_head_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {
+ if (!enabled) return;
+ wtr.Write_js_line(Bry_.new_a7("var xoui__ctx = {"));
+ wtr.Write_js_line(Bry_.new_a7(" img_dir : '" + Img_dir().To_http_file_str() + "',"));
+ wtr.Write_js_line(Bry_.new_a7(" wiki : '" + wiki.Domain_str() + "',"));
+ wtr.Write_js_line(Bry_.new_a7("}"));
+ }
+ public void Write_js_tail_script(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
+ public void Write_js_head_global(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Xoh_module_wtr wtr) {}
+ public static Io_url Img_dir() {return dir_url.GenSubDir("img");} private static Io_url dir_url; private static byte[] url_hui_js;
+}
diff --git a/400_xowa/src/gplx/xowa/html/modules/Xoh_module_mgr.java b/400_xowa/src/gplx/xowa/html/modules/Xoh_module_mgr.java
index 08f9a455a..996630cea 100644
--- a/400_xowa/src/gplx/xowa/html/modules/Xoh_module_mgr.java
+++ b/400_xowa/src/gplx/xowa/html/modules/Xoh_module_mgr.java
@@ -20,7 +20,10 @@ public class Xoh_module_mgr implements Bry_fmtr_arg {
private Xoae_app app; private Xowe_wiki wiki; private Xoae_page page; private Xoh_module_itm[] itms; private int itms_len;
private Xoh_module_wtr wtr = new Xoh_module_wtr();
public Xoh_module_mgr() {
- Itms_add(itm__css, itm__globals, itm__popups, itm__toc, itm__collapsible, itm__navframe, itm__gallery, itm__mathjax, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline);
+ Itms_add(itm__css, itm__globals, itm__popups, itm__toc, itm__collapsible, itm__navframe, itm__gallery
+ , itm__mathjax, itm__hiero, itm__top_icon, itm__title_rewrite, itm__search_suggest, itm__timeline
+ , itm__xoui
+ );
}
public Xoh_module_itm__css Itm__css() {return itm__css;} private Xoh_module_itm__css itm__css = new Xoh_module_itm__css();
public Xoh_module_itm__globals Itm__globals() {return itm__globals;} private Xoh_module_itm__globals itm__globals = new Xoh_module_itm__globals();
@@ -35,6 +38,7 @@ public class Xoh_module_mgr implements Bry_fmtr_arg {
public Xoh_module_itm__search_suggest Itm__search_suggest() {return itm__search_suggest;} private Xoh_module_itm__search_suggest itm__search_suggest = new Xoh_module_itm__search_suggest();
public Xoh_module_itm__timeline Itm__timeline() {return itm__timeline;} private Xoh_module_itm__timeline itm__timeline = new Xoh_module_itm__timeline();
public Xoh_module_itm__title_rewrite Itm__title_rewrite() {return itm__title_rewrite;} private Xoh_module_itm__title_rewrite itm__title_rewrite = new Xoh_module_itm__title_rewrite();
+ public Xoh_module_itm__xoui Itm__xoui() {return itm__xoui;} private Xoh_module_itm__xoui itm__xoui = new Xoh_module_itm__xoui();
public Xoh_module_mgr Init(Xoae_app app, Xowe_wiki wiki, Xoae_page page) {
this.app = app; this.wiki = wiki; this.page = page;
return this;
diff --git a/400_xowa/src/gplx/xowa/html/modules/popups/Xow_popup_mgr.java b/400_xowa/src/gplx/xowa/html/modules/popups/Xow_popup_mgr.java
index a81bd2e9f..d7709209c 100644
--- a/400_xowa/src/gplx/xowa/html/modules/popups/Xow_popup_mgr.java
+++ b/400_xowa/src/gplx/xowa/html/modules/popups/Xow_popup_mgr.java
@@ -19,6 +19,7 @@ package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import
import gplx.core.primitives.*; import gplx.core.threads.*;
import gplx.core.js.*;
import gplx.xowa.gui.views.*;
+import gplx.xowa.html.hrefs.*;
import gplx.xowa.specials.*; import gplx.xowa.specials.search.*;
import gplx.xowa.apis.xowa.html.modules.*;
public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
diff --git a/400_xowa/src/gplx/xowa/html/portal/Xoh_subpages_bldr.java b/400_xowa/src/gplx/xowa/html/portal/Xoh_subpages_bldr.java
index 2c870f2e6..05531ae75 100644
--- a/400_xowa/src/gplx/xowa/html/portal/Xoh_subpages_bldr.java
+++ b/400_xowa/src/gplx/xowa/html/portal/Xoh_subpages_bldr.java
@@ -16,6 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.html.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
+import gplx.xowa.html.hrefs.*;
public class Xoh_subpages_bldr implements Bry_fmtr_arg {
private Xoae_app app;
private Bry_bfr tmp_bfr = Bry_bfr.reset_(255), ttl_bfr = Bry_bfr.reset_(255);
diff --git a/400_xowa/src/gplx/xowa/html/portal/Xow_portal_mgr.java b/400_xowa/src/gplx/xowa/html/portal/Xow_portal_mgr.java
index ae36bc8c6..5faa8f966 100644
--- a/400_xowa/src/gplx/xowa/html/portal/Xow_portal_mgr.java
+++ b/400_xowa/src/gplx/xowa/html/portal/Xow_portal_mgr.java
@@ -17,6 +17,7 @@ along with this program. If not, see .
*/
package gplx.xowa.html.portal; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.xowa.wikis.*; import gplx.xowa.gui.*; import gplx.xowa.html.sidebar.*; import gplx.xowa.pages.*; import gplx.xowa.langs.vnts.*;
+import gplx.xowa.html.hrefs.*;
import gplx.xowa.apis.xowa.html.*; import gplx.xowa.apis.xowa.html.skins.*;
public class Xow_portal_mgr implements GfoInvkAble {
private Xowe_wiki wiki; private boolean lang_is_rtl; private Xoapi_toggle_itm toggle_itm;
@@ -107,11 +108,11 @@ public class Xow_portal_mgr implements GfoInvkAble {
return tmp_bfr.To_bry_and_rls();
}
public byte[] Missing_ns_cls() {return missing_ns_cls;} public Xow_portal_mgr Missing_ns_cls_(byte[] v) {missing_ns_cls = v; return this;} private byte[] missing_ns_cls; // NOTE: must be null due to Init check above
- private Bry_fmtr div_personal_fmtr = Bry_fmtr.new_("~{portal_personal_subj_href};~{portal_personal_subj_text};~{portal_personal_talk_cls};~{portal_personal_talk_href};~{portal_personal_talk_cls};", "portal_personal_subj_href", "portal_personal_subj_text", "portal_personal_subj_cls", "portal_personal_talk_href", "portal_personal_talk_cls");
- private Bry_fmtr div_ns_fmtr = Bry_fmtr.new_("~{portal_ns_subj_href};~{portal_ns_subj_cls};~{portal_ns_talk_href};~{portal_ns_talk_cls};~{portal_div_vnts}", "portal_ns_subj_href", "portal_ns_subj_cls", "portal_ns_talk_href", "portal_ns_talk_cls", "portal_div_vnts");
- private Bry_fmtr div_view_fmtr = Bry_fmtr.new_("", "portal_view_read_cls", "portal_view_edit_cls", "portal_view_html_cls", "search_text");
- private Bry_fmtr div_logo_fmtr = Bry_fmtr.new_("", "portal_nav_main_href", "portal_logo_url");
- private Bry_fmtr div_wikis_fmtr = Bry_fmtr.new_("", "toggle_btn", "toggle_hdr");
+ private final Bry_fmtr div_personal_fmtr = Bry_fmtr.new_("~{portal_personal_subj_href};~{portal_personal_subj_text};~{portal_personal_talk_cls};~{portal_personal_talk_href};~{portal_personal_talk_cls};", "portal_personal_subj_href", "portal_personal_subj_text", "portal_personal_subj_cls", "portal_personal_talk_href", "portal_personal_talk_cls");
+ private final Bry_fmtr div_ns_fmtr = Bry_fmtr.new_("~{portal_ns_subj_href};~{portal_ns_subj_cls};~{portal_ns_talk_href};~{portal_ns_talk_cls};~{portal_div_vnts}", "portal_ns_subj_href", "portal_ns_subj_cls", "portal_ns_talk_href", "portal_ns_talk_cls", "portal_div_vnts");
+ private final Bry_fmtr div_view_fmtr = Bry_fmtr.new_("", "portal_view_read_cls", "portal_view_edit_cls", "portal_view_html_cls", "search_text");
+ private final Bry_fmtr div_logo_fmtr = Bry_fmtr.new_("", "portal_nav_main_href", "portal_logo_url");
+ private final Bry_fmtr div_wikis_fmtr = Bry_fmtr.new_("", "toggle_btn", "toggle_hdr");
private byte[] Reverse_li(byte[] bry) {
return lang_is_rtl ? Xoh_rtl_utl.Reverse_li(bry) : bry;
}
diff --git a/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_bldr.java b/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_bldr.java
index 9d1eb1997..146dcc617 100644
--- a/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_bldr.java
+++ b/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_bldr.java
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.html.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
-import gplx.html.*;
+import gplx.html.*; import gplx.xowa.html.hrefs.*;
public class Xoh_lnki_bldr {
private final Xoa_app app; private final Xoh_href_parser href_parser; private final byte[] img_root_dir;
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
diff --git a/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_wtr_utl.java b/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_wtr_utl.java
index d6c087172..f7eabbd59 100644
--- a/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_wtr_utl.java
+++ b/400_xowa/src/gplx/xowa/html/wtrs/Xoh_lnki_wtr_utl.java
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.html.wtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
-import gplx.html.*;
+import gplx.html.*; import gplx.xowa.html.hrefs.*;
public class Xoh_lnki_wtr_utl {
private final Xoa_app app; private final Xow_wiki wiki; private final Xoh_href_parser href_parser; private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
public Xoh_lnki_wtr_utl(Xow_wiki wiki, Xoh_href_parser href_parser) {
diff --git a/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_cells_fmtr.java b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_cells_fmtr.java
new file mode 100644
index 000000000..1e886baaf
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_cells_fmtr.java
@@ -0,0 +1,77 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+import gplx.xowa.html.xouis.tbls.*;
+public class Xoui_cells_fmtr implements Bry_fmtr_arg {
+ private final Xoui_cell_fmtr cell_fmtr = new Xoui_cell_fmtr();
+ private final Xoui_btn_fmtr btn_fmtr = new Xoui_btn_fmtr();
+ private Xoui_btn_itm[] btns;
+ private byte[] row_key; private Xoui_row_itm row_itm;
+ public void Ctor(Xoui_val_fmtr val_fmtr, Xoui_btn_itm[] btns) {
+ cell_fmtr.Ctor(val_fmtr); this.btns = btns;
+ }
+ public Xoui_cells_fmtr Init(byte[] row_key, Xoui_row_itm row_itm) {
+ this.row_key = row_key; this.row_itm = row_itm;
+ return this;
+ }
+ public void XferAry(Bry_bfr bfr, int idx) {
+ fmtr.Bld_bfr_many(bfr, row_key, cell_fmtr.Init(row_key, row_itm), btn_fmtr.Init(row_key, btns));
+ }
+ private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , "~{vals}"
+ , "
~{btns}"
+ , "
"
+ ), "row_key", "vals", "btns");
+}
+class Xoui_cell_fmtr implements Bry_fmtr_arg {
+ private byte[] row_key; private Xoui_row_itm row_itm;
+ private Xoui_val_fmtr val_fmtr;
+ public void Ctor(Xoui_val_fmtr val_fmtr) {this.val_fmtr = val_fmtr;}
+ public Xoui_cell_fmtr Init(byte[] row_key, Xoui_row_itm row_itm) {this.row_key = row_key; this.row_itm = row_itm; return this;}
+ public void XferAry(Bry_bfr bfr, int idx) {
+ Xoui_col_itm[] cols = row_itm.Tbl().Cols();
+ Xoui_val_itm[] vals = row_itm.Vals(); int len = vals.length;
+ for (int i = 0; i < len; ++i) {
+ Xoui_val_itm val = vals[i];
+ fmtr.Bld_bfr_many(bfr, row_key, i, val_fmtr.Init(cols[i], val));
+ }
+ }
+ private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , "
~{html}
"
+ ), "row_key", "val_idx", "html");
+}
+class Xoui_btn_fmtr implements Bry_fmtr_arg {
+ private byte[] row_key; private Xoui_btn_itm[] btns;
+ public Xoui_btn_fmtr Init(byte[] row_key, Xoui_btn_itm[] btns) {
+ this.row_key = row_key; this.btns = btns; return this;
+ }
+ public void XferAry(Bry_bfr bfr, int idx) {
+ int len = btns.length;
+ Io_url img_dir = gplx.xowa.html.modules.Xoh_module_itm__xoui.Img_dir();
+ for (int i = 0; i < len; ++i) {
+ Xoui_btn_itm btn = btns[i];
+ fmtr.Bld_bfr_many(bfr, row_key, btn.Key(), btn.Cmd(), img_dir.GenSubFil(btn.Img()).To_http_file_bry(), btn.Text());
+ }
+ }
+ private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , " "
+ ), "row_key", "btn_key", "btn_cmd", "btn_img", "btn_text");
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_tbl_fmtr.java b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_tbl_fmtr.java
new file mode 100644
index 000000000..ae3bd8663
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_tbl_fmtr.java
@@ -0,0 +1,71 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+import gplx.xowa.html.xouis.tbls.*;
+public class Xoui_tbl_fmtr {
+ private final Xoui_head_cell_fmtr head_cell_fmtr = new Xoui_head_cell_fmtr();
+ private final Xoui_row_fmtr row_fmtr = new Xoui_row_fmtr();
+ public void Write(Bry_bfr bfr, Xoui_tbl_itm tbl) {
+ tbl_fmtr.Bld_bfr_many(bfr, tbl.Key(), head_cell_fmtr.Init(tbl), row_fmtr.Init(tbl));
+ }
+ private static final Bry_fmtr tbl_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , "
"
+ , "
~{head_cells}"
+ , "
~{data_rows}"
+ , "
"
+ ), "tbl_key", "head_cells", "data_rows");
+}
+class Xoui_head_cell_fmtr implements Bry_fmtr_arg {
+ private Xoui_tbl_itm tbl;
+ public Xoui_head_cell_fmtr Init(Xoui_tbl_itm tbl) {this.tbl = tbl; return this;}
+ public void XferAry(Bry_bfr bfr, int idx) {
+ Xoui_col_itm[] cols = tbl.Cols(); int len = cols.length;
+ for (int i = 0; i < len; ++i) {
+ Xoui_col_itm col = cols[i];
+ fmtr.Bld_bfr_many(bfr, col.Width(), col.Display());
+ }
+ }
+ private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , "
~{display}
"
+ ), "width", "display");
+}
+class Xoui_row_fmtr implements Bry_fmtr_arg {
+ private final Xoui_cells_fmtr cells_fmtr = new Xoui_cells_fmtr();
+ private final Xoui_val_fmtr val_fmtr = Xoui_val_fmtr_.new_view();
+ private final Bry_bfr row_key_bfr = Bry_bfr.new_(255);
+ private Xoui_tbl_itm tbl;
+ public Xoui_row_fmtr Init(Xoui_tbl_itm tbl) {this.tbl = tbl; return this;}
+ public void XferAry(Bry_bfr bfr, int idx) {
+ byte[] tbl_key = tbl.Key();
+ Xoui_row_itm[] rows = tbl.Rows(); int len = rows.length;
+ cells_fmtr.Ctor(val_fmtr, tbl.View_btns());
+ for (int i = 0; i < len; ++i) {
+ Xoui_row_itm row = rows[i];
+ row_key_bfr.Add(tbl_key).Add_byte(Byte_ascii.Underline).Add_int_variable(i);
+ byte[] row_key = row_key_bfr.Xto_bry_and_clear();
+ fmtr.Bld_bfr_many(bfr, row_key, row.Pkey(), cells_fmtr.Init(row_key, row));
+ }
+ }
+ private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , "
~{cells}"
+ , "
"
+ ), "row_key", "pkey", "cells");
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_tbl_fmtr_tst.java b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_tbl_fmtr_tst.java
new file mode 100644
index 000000000..b9ee42cd9
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_tbl_fmtr_tst.java
@@ -0,0 +1,41 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+import gplx.xowa.html.xouis.tbls.*;
+import org.junit.*;
+public class Xoui_tbl_fmtr_tst {
+ @Before public void init() {fxt.Clear();} private final Xoui_tbl_fmtr_fxt fxt = new Xoui_tbl_fmtr_fxt();
+ @Test public void Basic() {
+// fxt.Test_write
+// ( fxt.Make_tbl()
+// , String_.Concat_lines_nl_skip_last()
+// );
+ }
+}
+class Xoui_tbl_fmtr_fxt {
+ private final Bry_bfr bfr = Bry_bfr.new_(255);
+ private final Xoui_tbl_fmtr tbl_fmtr = new Xoui_tbl_fmtr();
+ public void Clear() {}
+ public Xoui_tbl_itm Make_tbl() {
+ return null;
+ }
+ public void Test_write(Xoui_tbl_itm tbl, String expd) {
+ tbl_fmtr.Write(bfr, tbl);
+ Tfds.Eq_str_lines(expd, bfr.Xto_str_and_clear());
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_val_fmtr.java b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_val_fmtr.java
new file mode 100644
index 000000000..9ccf241ce
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_val_fmtr.java
@@ -0,0 +1,43 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+import gplx.xowa.html.xouis.tbls.*;
+public interface Xoui_val_fmtr {
+ Xoui_val_fmtr Init(Xoui_col_itm col, Xoui_val_itm val);
+}
+class Xoui_val_fmtr__view implements Bry_fmtr_arg, Xoui_val_fmtr {
+ private Xoui_val_itm val;
+ public Xoui_val_fmtr Init(Xoui_col_itm col, Xoui_val_itm val) {this.val = val; return this;}
+ public void XferAry(Bry_bfr bfr, int idx) {
+ bfr.Add(val.Html());
+ }
+}
+class Xoui_val_fmtr__edit implements Bry_fmtr_arg, Xoui_val_fmtr {
+ private Xoui_col_itm col; private Xoui_val_itm val;
+ public Xoui_val_fmtr Init(Xoui_col_itm col, Xoui_val_itm val) {this.col = col; this.val = val; return this;}
+ public void XferAry(Bry_bfr bfr, int idx) {
+ switch (col.Type()) {
+ case Xoui_col_itm.Type_id_str: fmtr_str.Bld_bfr_many(bfr, col.Key(), val.Data().length * 8, val.Data()); break;
+ default: throw Err_.not_implemented_();
+ }
+ }
+ private static final Bry_fmtr fmtr_str = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
+ ( ""
+ , " "
+ ), "col_key", "width", "value");
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_val_fmtr_.java b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_val_fmtr_.java
new file mode 100644
index 000000000..09a49fbc9
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/fmtrs/Xoui_val_fmtr_.java
@@ -0,0 +1,22 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public class Xoui_val_fmtr_ {
+ public static Xoui_val_fmtr new_view() {return new Xoui_val_fmtr__view();}
+ public static Xoui_val_fmtr new_edit() {return new Xoui_val_fmtr__edit();}
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_btn_itm.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_btn_itm.java
new file mode 100644
index 000000000..df9c638f6
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_btn_itm.java
@@ -0,0 +1,25 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public class Xoui_btn_itm {
+ public Xoui_btn_itm(String cmd, String img, String text) {this.cmd = cmd; this.img = img; this.text = text;}
+ public String Key() {return text;}
+ public String Cmd() {return cmd;} private final String cmd;
+ public String Img() {return img;} private final String img;
+ public String Text() {return text;} private final String text;
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_col_itm.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_col_itm.java
new file mode 100644
index 000000000..0b4172776
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_col_itm.java
@@ -0,0 +1,26 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public class Xoui_col_itm {
+ public Xoui_col_itm(int type, int width, String key, String display) {this.type = type; this.width = width; this.key = key; this.display = display;}
+ public int Type() {return type;} private final int type;
+ public String Key() {return key;} private final String key;
+ public String Display() {return display;} private final String display;
+ public int Width() {return width;} private final int width;
+ public static final int Type_id_str = 1;
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_row_itm.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_row_itm.java
new file mode 100644
index 000000000..4d3c44225
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_row_itm.java
@@ -0,0 +1,26 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public class Xoui_row_itm {
+ public Xoui_row_itm(Xoui_tbl_itm tbl, byte[] pkey, Xoui_val_itm[] vals) {
+ this.tbl = tbl; this.pkey = pkey; this.vals = vals;
+ }
+ public Xoui_tbl_itm Tbl() {return tbl;} private final Xoui_tbl_itm tbl;
+ public byte[] Pkey() {return pkey;} private final byte[] pkey;
+ public Xoui_val_itm[] Vals() {return vals;} private Xoui_val_itm[] vals;
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_tbl_itm.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_tbl_itm.java
new file mode 100644
index 000000000..aee467939
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_tbl_itm.java
@@ -0,0 +1,29 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public interface Xoui_tbl_itm {
+ byte[] Key();
+ Xoui_col_itm[] Cols();
+ Xoui_row_itm[] Rows(); void Rows_(Xoui_row_itm[] v);
+ Xoui_btn_itm[] View_btns();
+ Xoui_btn_itm[] Edit_btns();
+ void Del(byte[] row_pkey_bry);
+ String Edit(byte[] row_key, byte[] row_pkey_bry);
+ String Save(byte[] row_key, byte[] row_pkey_bry, Xoui_val_hash ary);
+ void Set_order_adj(byte[] row_pkey, boolean adj_down);
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_tbl_mgr.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_tbl_mgr.java
new file mode 100644
index 000000000..2e67f133c
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_tbl_mgr.java
@@ -0,0 +1,82 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+import gplx.json.*;
+import gplx.xowa.html.xouis.fmtrs.*;
+public class Xoui_tbl_mgr {
+ private final Ordered_hash tbl_hash = Ordered_hash_.new_bry_();
+ private final Xoui_tbl_fmtr tbl_fmtr = new Xoui_tbl_fmtr();
+ public String Del(Json_doc jdoc) {
+ Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
+ byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
+ tbl_itm.Del(row_pkey);
+ return "{}";
+ }
+ public void Write(Bry_bfr bfr, Xoui_tbl_itm tbl) {
+ tbl_hash.Del(tbl.Key());
+ tbl_hash.Add(tbl.Key(), tbl);
+ tbl_fmtr.Write(bfr, tbl);
+ }
+ public String Edit(Json_doc jdoc) {
+ Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
+ byte[] row_id = Get_row_key_in_jdoc(jdoc);
+ byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
+ return tbl_itm.Edit(row_id, row_pkey);
+ }
+ public String Save(Json_doc jdoc) {
+ Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
+ byte[] row_id = Get_row_key_in_jdoc(jdoc);
+ byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
+ return tbl_itm.Save(row_id, row_pkey, To_hash(jdoc.Get_grp(Arg_data)));
+ }
+ public void Adj_order(Json_doc jdoc) {
+ Xoui_tbl_itm tbl_itm = Get_tbl_by_jdoc(jdoc);
+ byte[] row_pkey = Get_row_pkey_in_jdoc(jdoc);
+ boolean adj_down = Yn.parse_by_char_or(String_.new_a7(jdoc.Get_val_as_bry_or(Arg_adj_down, null)), false);
+ tbl_itm.Set_order_adj(row_pkey, adj_down);
+ }
+ private Xoui_tbl_itm Get_tbl_by_jdoc(Json_doc jdoc) {
+ byte[] key = jdoc.Get_val_as_bry_or(Arg_tbl_key, null); if (key == null) throw Err_.new_("dbui.mgr; unknown tbl; jdoc=~{0}", jdoc.Src());
+ Xoui_tbl_itm tbl = (Xoui_tbl_itm)tbl_hash.Get_by(key); if (tbl == null) throw Err_.new_("dbui.mgr; unknown tbl key; key=~{0}", key);
+ return tbl;
+ }
+ private byte[] Get_row_pkey_in_jdoc(Json_doc jdoc) {
+ byte[] rv = jdoc.Get_val_as_bry_or(Arg_row_pkey, null); if (rv == null) throw Err_.new_("dbui.mgr; unknown row_pkey; jdoc=~{0}", jdoc.Src());
+ return rv;
+ }
+ private byte[] Get_row_key_in_jdoc(Json_doc jdoc) {
+ byte[] rv = jdoc.Get_val_as_bry_or(Arg_row_id, null); if (rv == null) throw Err_.new_("dbui.mgr; unknown row_id; jdoc=~{0}", jdoc.Src());
+ return rv;
+ }
+ private Xoui_val_hash To_hash(Json_grp grp) {
+ Xoui_val_hash rv = new Xoui_val_hash();
+ int len = grp.Subs_len();
+ for (int i = 0; i < len; ++i) {
+ Json_itm_kv kv = (Json_itm_kv)grp.Subs_get_at(i);
+ Json_itm_nde nde = (Json_itm_nde)kv.Val();
+ Json_itm_kv key = (Json_itm_kv)nde.Subs_get_by_key(Arg_key);
+ Json_itm_kv val = (Json_itm_kv)nde.Subs_get_by_key(Arg_val);
+ Xoui_val_itm fld = new Xoui_val_itm(val.Val().Data_bry(), Bry_.Empty);
+ rv.Add(key.Val().Data_bry(), fld);
+ }
+ return rv;
+ }
+ private static final byte[]
+ Arg_tbl_key = Bry_.new_a7("tbl_key"), Arg_row_pkey = Bry_.new_a7("row_pkey"), Arg_row_id = Bry_.new_a7("row_id"), Arg_data = Bry_.new_a7("data")
+ , Arg_adj_down = Bry_.new_a7("adj_down"), Arg_key = Bry_.new_a7("key"), Arg_val = Bry_.new_a7("val");
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_val_hash.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_val_hash.java
new file mode 100644
index 000000000..e0f46f27c
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_val_hash.java
@@ -0,0 +1,26 @@
+/*
+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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public class Xoui_val_hash {
+ private final Ordered_hash hash = Ordered_hash_.new_bry_();
+ public void Add(byte[] key, Xoui_val_itm itm) {hash.Add(key, itm);}
+ public byte[] Get_val_as_bry_or_fail(byte[] key) {
+ Xoui_val_itm itm = (Xoui_val_itm)hash.Get_by(key); if (itm == null) throw Err_.new_("dbui.val_hash; unknown key; key={0}", key);
+ return itm.Data();
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_val_itm.java b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_val_itm.java
new file mode 100644
index 000000000..3bd7a0972
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/html/xouis/tbls/Xoui_val_itm.java
@@ -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 .
+*/
+package gplx.xowa.html.xouis.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.xouis.*;
+public class Xoui_val_itm {
+ public Xoui_val_itm(byte[] data, byte[] html) {this.data = data; this.html = html;}
+ public byte[] Data() {return data;} private byte[] data;
+ public byte[] Html() {return html;} private final byte[] html;
+ public void Data_(byte[] v) {this.data = v;}
+}
diff --git a/400_xowa/src/gplx/xowa/parsers/lnkes/Xoh_lnke_wtr.java b/400_xowa/src/gplx/xowa/parsers/lnkes/Xoh_lnke_wtr.java
index e3237b8d9..4c24638c7 100644
--- a/400_xowa/src/gplx/xowa/parsers/lnkes/Xoh_lnke_wtr.java
+++ b/400_xowa/src/gplx/xowa/parsers/lnkes/Xoh_lnke_wtr.java
@@ -16,7 +16,8 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
package gplx.xowa.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
-import gplx.xowa.html.*; import gplx.xowa.net.*;
+import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*;
+import gplx.xowa.net.*;
public class Xoh_lnke_wtr {
private Xoae_app app;
public Xoh_lnke_wtr(Xowe_wiki wiki) {this.app = wiki.Appe();}
diff --git a/400_xowa/src/gplx/xowa/servers/http/Http_server_mgr.java b/400_xowa/src/gplx/xowa/servers/http/Http_server_mgr.java
index d4b157d84..db2f69450 100644
--- a/400_xowa/src/gplx/xowa/servers/http/Http_server_mgr.java
+++ b/400_xowa/src/gplx/xowa/servers/http/Http_server_mgr.java
@@ -34,6 +34,7 @@ along with this program. If not, see .
*/
package gplx.xowa.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.servers.*;
import gplx.ios.*; import gplx.json.*; import gplx.xowa.gui.*; import gplx.xowa.pages.*;
+import gplx.core.net.*; import gplx.core.threads.*;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.Console;
@@ -195,6 +196,31 @@ class Http_server_wkr implements Runnable {
}
}
}
+// public void run() {
+// try {
+// if (server_socket == null)
+// server_socket = new ServerSocket(port);
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// while (true) {// Listen for a TCP connection request.
+// try {
+// if (canceled) {
+// if (server_socket != null)
+// server_socket.close();
+// server_socket = null;
+// canceled = false;
+// break;
+// }
+// Socket connectionSocket = server_socket.accept(); //Construct object to process HTTP request message
+// Socket_adp client_socket = new Socket_adp__base(connectionSocket);
+// Xosrv_http_wkr wkr = new Xosrv_http_wkr(client_socket, webserver.App());
+// Thread_adp_.invk_(wkr, Xosrv_http_wkr.Invk_run).Start();
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+// }
+// }
}
class HttpRequest implements Runnable{
private static final String CRLF = "\r\n";
@@ -314,7 +340,7 @@ class HttpRequest implements Runnable{
try{
strm.writeBytes("HTTP/1.1 200 OK: ");
strm.writeBytes("Content-Type: text/html; charset=utf-8" + CRLF);
- strm.writeBytes("Access-Control-Allow-Origin: *" + CRLF); // No 'Access-Control-Allow-Origin' header is present on the requested resource.
+// strm.writeBytes("Access-Control-Allow-Origin: *" + CRLF); // No 'Access-Control-Allow-Origin' header is present on the requested resource.
strm.writeBytes(CRLF);
strm.write(page_html.getBytes(Charset.forName("UTF-8")));
strm.close();
diff --git a/400_xowa/src/gplx/xowa/servers/http/Http_server_wkr_v2.java b/400_xowa/src/gplx/xowa/servers/http/Http_server_wkr_v2.java
new file mode 100644
index 000000000..7da55e88c
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/servers/http/Http_server_wkr_v2.java
@@ -0,0 +1,214 @@
+/*
+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 .
+*/
+package gplx.xowa.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.servers.*;
+import gplx.ios.*;
+import gplx.core.net.*;
+import gplx.xowa.html.js.*;
+class Xosrv_http_wkr implements GfoInvkAble {
+ private final Http_server_wtr server_wtr = Http_server_wtr_.new_console();
+ private final Http_client_wtr client_wtr = Http_client_wtr_.new_stream();
+ private final Http_client_rdr client_rdr = Http_client_rdr_.new_stream();
+ private Socket_adp socket;
+ private Xoae_app app;
+ private String app_root_dir;
+ public Xosrv_http_wkr(Socket_adp socket, Xoae_app app){
+ this.socket = socket;
+ this.app = app;
+ this.app_root_dir = app.Fsys_mgr().Root_dir().To_http_file_str();
+ }
+ public void run(){
+ try {
+ String req = Get_request();
+ if (req == null) return;
+ client_wtr.Stream_(socket.Get_output_stream());
+ String wiki_domain = "home";
+ String page_name = "Main_Page";
+
+ if(!String_.Has(req, "%file%")){
+ if(String_.Eq(req, "/")) { // no page; EX:"localhost:8080" vs "localhost:8080/en.wikipedia.org/wiki/Earth"
+ String home_url = app.Http_server().Home();
+ if (String_.Has_at_bgn(home_url, "file://")) {
+ Io_url file_url = Io_url_.http_any_(home_url, Op_sys.Cur().Tid_is_wnt());
+ String page_html = Io_mgr.I.LoadFilStr(file_url);
+ Write_page(client_wtr, page_html, app_root_dir, wiki_domain);
+ }
+ else {
+ req += app.Http_server().Home();
+ }
+ }
+ req = Http_server_wkr_.Assert_main_page(app, req);
+ }
+
+ if(String_.Has(req, "%xowa-cmd%") || String_.Has(req, "/xowa-cmd:")){
+ Write_xocmd(req, server_wtr, client_wtr);
+ }
+ else if(String_.Has(req, "%file%")){
+ Write_file(req, server_wtr, client_wtr);
+ client_rdr.Rls();
+ socket.Rls();
+ }else{
+ Write_wiki(req, server_wtr, client_wtr, wiki_domain, page_name);
+ }
+ }
+ catch (Exception e) {
+ String err_msg = String_.Format("error retrieving page. Please make sure your url is of the form: http://localhost:8080/home/wiki/Main_Page; err_msg={0}", Err_.Message_gplx(e));
+ server_wtr.Write_str_w_nl(err_msg);
+ }
+ }
+ private void Write_xocmd(String req, Http_server_wtr server_wtr, Http_client_wtr client_wtr) {
+ String cmd = "";
+ if (String_.Has(req, "%xowa-cmd%"))
+ cmd = String_.Mid(req, String_.FindFwd(req, "%xowa-cmd%") + 20);
+ else
+ cmd = String_.Mid(req, String_.FindFwd(req, "/xowa-cmd:") + 10);
+ server_wtr.Write_str_w_nl("Command output:" + cmd);
+ app.Http_server().Run_xowa_cmd(app, cmd);
+ server_wtr.Write_str_w_nl("Command sent, see console log for more details.");
+ client_wtr.Rls();
+ }
+ private void Write_file(String req, Http_server_wtr server_wtr, Http_client_wtr client_wtr) {
+ String path = String_.Replace(req, "/%file%/", app_root_dir);
+ path = String_.Mid(path, String_.FindFwd(path, app_root_dir)+5);
+ Url_encoder url_converter = Url_encoder.new_http_url_();
+ path = url_converter.Decode_str(path);
+ if (String_.Has(path, "?")) {
+ path = String_.Mid(path, 0, String_.FindFwd(path, "?"));
+ }
+ client_wtr.Write_str("HTTP/1.1 200 OK: ");
+ client_wtr.Write_str("Content-Type: " + contentType(path) + Str_nl);
+ client_wtr.Write_str(Str_nl);
+ Io_stream_rdr file_rdr = Io_stream_rdr_.new_by_url_(Io_url_.new_fil_(path));
+ file_rdr.Open();
+ Write_file_bytes(file_rdr, client_wtr);
+ file_rdr.Rls();
+ client_wtr.Rls();
+ }
+ private void Write_wiki(String req, Http_server_wtr server_wtr, Http_client_wtr client_wtr, String wiki_domain, String page_name) {
+ String[] req_split = String_.Split(req, "/");
+ server_wtr.Write_str_w_nl("Request: " + req);
+ if(req_split.length >= 1){
+ wiki_domain = req_split[1];
+ }
+ if(req_split.length >= 4){
+ page_name = req_split[3];
+ for(int i = 4; i <= req_split.length-1; i++){
+ page_name += "/"+req_split[i];
+ }
+ Url_encoder url_converter = Url_encoder.new_http_url_();
+ page_name = url_converter.Decode_str(page_name);
+ //page_name = app.Url_converter_url().Decode_str(page_name);
+ }
+ try{
+ String page_html = app.Http_server().Parse_page_to_html(app, wiki_domain, page_name);
+ Write_page(client_wtr, page_html, app_root_dir, wiki_domain);
+ }catch(Exception err) {
+ client_wtr.Write_str("Site not found. Check address please, or see console log.\n" + Err_.Message_lang(err));
+ client_wtr.Rls();
+ }
+ }
+ private void Write_file_bytes(Io_stream_rdr file_rdr, Http_client_wtr client_wtr) {
+ byte[] bry = new byte[1024];
+ int read = 0;
+ while (true) {
+ read = file_rdr.Read(bry, 0, 1024);
+ if (read == -1) break;
+ client_wtr.Write_mid(bry, 0, read);
+ }
+ }
+ private static void Write_page(Http_client_wtr client_wtr, String page_html, String app_file_dir, String wiki_domain) {
+ page_html = Convert_page(page_html, app_file_dir, wiki_domain);
+ Write_to_stream(client_wtr, page_html);
+ }
+ private static String Convert_page(String page_html, String app_file_dir, String wiki_domain) {
+ page_html = String_.Replace(page_html, app_file_dir , "%file%/");
+ page_html = String_.Replace(page_html, "xowa-cmd" , "%xowa-cmd%/xowa-cmd");
+ page_html = String_.Replace(page_html, ".
*/
package gplx.xowa.specials.allPages; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
-import gplx.core.primitives.*; import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*;
+import gplx.core.primitives.*;
+import gplx.xowa.html.*; import gplx.xowa.html.hrefs.*; import gplx.xowa.html.lnkis.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.tbls.*;
public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page {
public Xows_page_allpages(Xowe_wiki wiki) {
diff --git a/400_xowa/src/gplx/xowa/specials/movePage/Move_page.java b/400_xowa/src/gplx/xowa/specials/movePage/Move_page.java
index 8d9b08d7a..2d7db9fc8 100644
--- a/400_xowa/src/gplx/xowa/specials/movePage/Move_page.java
+++ b/400_xowa/src/gplx/xowa/specials/movePage/Move_page.java
@@ -17,6 +17,7 @@ along with this program. If not, see .
*/
package gplx.xowa.specials.movePage; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.core.primitives.*; import gplx.xowa.wikis.data.tbls.*;
+import gplx.xowa.html.hrefs.*;
public class Move_page implements Xows_page {
private Move_trg_ns_list_fmtr ns_list_fmtr = new Move_trg_ns_list_fmtr();
private Move_url_args args = new Move_url_args();
diff --git a/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xoui_tbl_itm__bmk.java b/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xoui_tbl_itm__bmk.java
new file mode 100644
index 000000000..818bae481
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xoui_tbl_itm__bmk.java
@@ -0,0 +1,105 @@
+/*
+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 .
+*/
+package gplx.xowa.specials.xowa.bookmarks; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
+import gplx.json.*;
+import gplx.xowa.users.data.*;
+import gplx.xowa.html.xouis.tbls.*; import gplx.xowa.html.xouis.fmtrs.*;
+public class Xoui_tbl_itm__bmk implements Xoui_tbl_itm {
+ private final Xoud_bmk_tbl tbl;
+ private final Json_wtr json_wtr = new Json_wtr();
+ private final Xoui_cells_fmtr cells_fmtr = new Xoui_cells_fmtr();
+ private final Xoui_val_fmtr edit_val_fmtr = Xoui_val_fmtr_.new_edit();
+ private final Xoui_val_fmtr view_val_fmtr = Xoui_val_fmtr_.new_view();
+ private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
+ public Xoui_tbl_itm__bmk(Xoud_bmk_tbl tbl) {this.tbl = tbl;}
+ public byte[] Key() {return key;} private static final byte[] key = Bry_.new_a7("bmk");
+ public Xoui_btn_itm[] View_btns() {return view_btns;}
+ public Xoui_btn_itm[] Edit_btns() {return edit_btns;}
+ public Xoui_col_itm[] Cols() {return cols;}
+ public Xoui_row_itm[] Rows() {return rows;} public void Rows_(Xoui_row_itm[] v) {this.rows = v;} private Xoui_row_itm[] rows;
+ public void Del(byte[] row_pkey_bry) {
+ int bmk_id = To_bmk_id(row_pkey_bry);
+ tbl.Delete(bmk_id);
+ }
+ private Xoui_row_itm Get_row_by_pkey(byte[] row_pkey_bry) {
+ int len = rows.length;
+ for (int i = 0; i < len; ++i) {
+ Xoui_row_itm row = rows[i];
+ if (Bry_.Eq(row.Pkey(), row_pkey_bry)) return row;
+ }
+ return null;
+ }
+ private String Write_cells(Xoui_val_fmtr val_fmtr, Xoui_btn_itm[] btns, byte[] row_id, Xoui_row_itm row) {
+ cells_fmtr.Ctor(val_fmtr, btns);
+ cells_fmtr.Init(row_id, row);
+ cells_fmtr.XferAry(tmp_bfr, 0);
+ json_wtr.Doc_bgn();
+ json_wtr.Kv_bfr("html", tmp_bfr);
+ json_wtr.Doc_end();
+ return json_wtr.To_str_and_clear();
+ }
+ public String Edit(byte[] row_id, byte[] row_pkey_bry) {
+ return Write_cells(edit_val_fmtr, edit_btns, row_id, Get_row_by_pkey(row_pkey_bry));
+ }
+ public String Save(byte[] row_id, byte[] row_pkey_bry, Xoui_val_hash hash) {
+ int bmk_id = To_bmk_id(row_pkey_bry);
+ byte[] name = hash.Get_val_as_bry_or_fail(Key_name);
+ byte[] url = hash.Get_val_as_bry_or_fail(Key_url);
+ Xoui_row_itm row_itm = Get_row_by_pkey(row_pkey_bry);
+ Set_vals(tmp_bfr, row_itm.Vals(), name, url);
+ tbl.Update(bmk_id, name, url);
+ return Write_cells(view_val_fmtr, view_btns, row_id, row_itm);
+ }
+ public void Set_order_adj(byte[] row_pkey, boolean adj_down) {throw Err_.not_implemented_();}
+
+ private int To_bmk_id(byte[] row_pkey_bry) {return Bry_.Xto_int_or_fail(row_pkey_bry);}
+ private static final byte[] Key_name = Bry_.new_a7("name"), Key_url = Bry_.new_a7("url");
+ private static final Xoui_col_itm[] cols = new Xoui_col_itm[]
+ { new Xoui_col_itm(Xoui_col_itm.Type_id_str, 150, "name" , "Name")
+ , new Xoui_col_itm(Xoui_col_itm.Type_id_str, 350, "url" , "Url")
+ };
+ private static final Xoui_btn_itm[] view_btns = new Xoui_btn_itm[]
+ { new Xoui_btn_itm("rows__edit" , "edit.png" , "edit")
+ , new Xoui_btn_itm("rows__delete" , "delete.png" , "delete")
+ };
+ private static final Xoui_btn_itm[] edit_btns = new Xoui_btn_itm[]
+ { new Xoui_btn_itm("rows__save" , "save.png" , "save")
+ , new Xoui_btn_itm("rows__cancel" , "cancel.png" , "cancel")
+ };
+ private static final Bry_fmtr url_fmtr = Bry_fmtr.new_("~{url}", "url");
+ public static Xoui_tbl_itm new_(Xoud_bmk_tbl dom_tbl, Xoud_bmk_row[] dom_rows) {
+ Xoui_tbl_itm rv = new Xoui_tbl_itm__bmk(dom_tbl);
+ int len = dom_rows.length;
+ Xoui_row_itm[] gui_rows = new Xoui_row_itm[len];
+ Bry_bfr tmp_bfr = Bry_bfr.new_(255);
+ for (int i = 0; i < len; ++i) {
+ Xoud_bmk_row dom_row = dom_rows[i];
+ Xoui_val_itm[] vals = new Xoui_val_itm[2];
+ Set_vals(tmp_bfr, vals, dom_row.Name(), dom_row.Url());
+ Xoui_row_itm gui_row = new Xoui_row_itm(rv, Int_.Xto_bry(dom_row.Id()), vals);
+ gui_rows[i] = gui_row;
+ }
+ rv.Rows_(gui_rows);
+ return rv;
+ }
+ private static void Set_vals(Bry_bfr tmp_bfr, Xoui_val_itm[] vals, byte[] name, byte[] url) {
+ vals[0] = new Xoui_val_itm(name, name);
+ url_fmtr.Bld_bfr_many(tmp_bfr, url);
+ vals[1] = new Xoui_val_itm(url, tmp_bfr.Xto_bry_and_clear());
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xows_bmk_page.java b/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xows_bmk_page.java
index bb41d8c74..b4a6d8900 100644
--- a/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xows_bmk_page.java
+++ b/400_xowa/src/gplx/xowa/specials/xowa/bookmarks/Xows_bmk_page.java
@@ -17,12 +17,17 @@ along with this program. If not, see .
*/
package gplx.xowa.specials.xowa.bookmarks; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
import gplx.core.primitives.*;
+import gplx.xowa.users.data.*;
+import gplx.xowa.html.xouis.tbls.*;
public class Xows_bmk_page implements Xows_page {
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__bookmarks;}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
- Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_m001();
- wiki.App().User().User_db_mgr().Bmk_mgr().Get_all(tmp_bfr);
- page.Data_raw_(tmp_bfr.To_bry_and_rls());
- page.Html_data().Html_restricted_n_();
+ Xoud_bmk_mgr bmk_mgr = wiki.App().User().User_db_mgr().Bmk_mgr();
+ page.Html_data().Module_mgr().Itm__xoui().Init(wiki.Appe()).Enabled_y_();
+ Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_m001();
+ Xoud_bmk_row[] rows = bmk_mgr.Get_all();
+ Xoui_tbl_itm hui_tbl = Xoui_tbl_itm__bmk.new_(bmk_mgr.Tbl(), rows);
+ wiki.Html__xoui_tbl_mgr().Write(bfr, hui_tbl);
+ page.Hdump_data().Body_(bfr.To_bry_and_rls());
}
}
diff --git a/400_xowa/src/gplx/xowa/users/data/Html_grid_wtr.java b/400_xowa/src/gplx/xowa/users/data/Html_grid_wtr.java
deleted file mode 100644
index a9d564316..000000000
--- a/400_xowa/src/gplx/xowa/users/data/Html_grid_wtr.java
+++ /dev/null
@@ -1,143 +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 .
-*/
-package gplx.xowa.users.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.users.*;
-class Hgrid_tbl_data {
- public Hgrid_tbl_data(Hgrid_col_data[] cols, Hgrid_row_data[] rows) {this.cols = cols; this.rows = rows;}
- public Hgrid_col_data[] Cols() {return cols;} private final Hgrid_col_data[] cols;
- public Hgrid_row_data[] Rows() {return rows;} private final Hgrid_row_data[] rows;
-}
-class Hgrid_col_data {
- public Hgrid_col_data(int type, String key, String display) {this.type = type; this.key = key; this.display = display;}
- public int Type() {return type;} private final int type;
- public String Key() {return key;} private final String key;
- public String Display() {return display;} private final String display;
- public static final int Type_id_str = 1;
-}
-class Hgrid_row_data {
- public Hgrid_row_data(Hgrid_tbl_data tbl, String pkey, Hgrid_cell_data[] cells, Hgrid_btn_data[] btns) {this.tbl = tbl; this.pkey = pkey; this.cells = cells; this.btns = btns;}
- public Hgrid_tbl_data Tbl() {return tbl;} private final Hgrid_tbl_data tbl;
- public String Pkey() {return pkey;} private final String pkey;
- public Hgrid_cell_data[] Cells() {return cells;} private Hgrid_cell_data[] cells;
- public Hgrid_btn_data[] Btns() {return btns;} private Hgrid_btn_data[] btns;
-}
-class Hgrid_cell_data {
- public Hgrid_cell_data(String data, String html) {this.data = data; this.html = html;}
- public String Data() {return data;} private final String data;
- public String Html() {return html;} private final String html;
-}
-class Hgrid_btn_data {
- public Hgrid_btn_data(String cmd, String img, String text) {this.cmd = cmd; this.img = img; this.text = text;}
- public String Cmd() {return cmd;} private final String cmd;
- public String Img() {return img;} private final String img;
- public String Text() {return text;} private final String text;
-}
-class Hgrid_tbl_fmtr {
- private final Hgrid_head_row_fmtr head_row_fmtr = new Hgrid_head_row_fmtr();
- private final Hgrid_data_rows_fmtr data_rows_fmtr = new Hgrid_data_rows_fmtr();
- public void Write(Bry_bfr bfr, Hgrid_tbl_data data) {
- tbl_fmtr.Bld_bry_many(bfr, head_row_fmtr.Init(data), data_rows_fmtr.Init(data));
- }
- private static final Bry_fmtr tbl_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
- ( "
"
- , "
~{head_cells}"
- , "
~{data_rows}"
- , "
"
- ), "head_cells", "data_rows");
-}
-class Hgrid_head_row_fmtr implements Bry_fmtr_arg {
- private Hgrid_tbl_data data;
- public Hgrid_head_row_fmtr Init(Hgrid_tbl_data data) {this.data = data; return this;}
- public void XferAry(Bry_bfr bfr, int idx) {
- Hgrid_col_data[] cols = data.Cols(); int len = cols.length;
- for (int i = 0; i < len; ++i) {
- Hgrid_col_data col = cols[i];
- fmtr.Bld_bfr_many(bfr, col.Display());
- }
- }
- private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
- ( "
~{display}
"
- ), "display");
-}
-class Hgrid_data_rows_fmtr implements Bry_fmtr_arg {
- private final Hgrid_data_cell_fmtr cells_fmtr = new Hgrid_data_cell_fmtr();
- private Hgrid_tbl_data data;
- public Hgrid_data_rows_fmtr Init(Hgrid_tbl_data data) {this.data = data; return this;}
- public void XferAry(Bry_bfr bfr, int idx) {
- Hgrid_row_data[] rows = data.Rows(); int len = rows.length;
- for (int i = 0; i < len; ++i) {
- Hgrid_row_data row = rows[i];
- fmtr.Bld_bfr_many(bfr, i, row.Pkey(), cells_fmtr.Init(i, row));
- }
- }
- private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
- ( "
~{cells}~{cmds}"
- , "
"
- ), "id", "pkey", "cells");
-}
-class Hgrid_data_cell_fmtr implements Bry_fmtr_arg {
- private int row_idx; private Hgrid_row_data data;
- public Hgrid_data_cell_fmtr Init(int row_idx, Hgrid_row_data data) {this.row_idx = row_idx; this.data = data; return this;}
- public void XferAry(Bry_bfr bfr, int idx) {
- Hgrid_cell_data[] cells = data.Cells(); int len = cells.length;
- Hgrid_col_data[] cols = data.Tbl().Cols();
- for (int i = 0; i < len; ++i) {
- Hgrid_cell_data cell = cells[i];
- fmtr.Bld_bfr_many(bfr, row_idx, cols[i].Key(), i, cell.Data(), cell.Html());
- }
- }
- private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
- ( "
~{html}
"
- ), "row", "col", "idx", "data", "html");
-}
-class Hgrid_row_btns_fmtr implements Bry_fmtr_arg {
- private int row_idx; private Hgrid_row_data data;
- public Hgrid_row_btns_fmtr Init(int row_idx, Hgrid_row_data data) {this.row_idx = row_idx; this.data = data; return this;}
- public void XferAry(Bry_bfr bfr, int idx) {
- Hgrid_btn_data[] btns = data.Btns(); int len = btns.length;
- for (int i = 0; i < len; ++i) {
- Hgrid_btn_data btn = btns[i];
- fmtr.Bld_bfr_many(bfr, row_idx, btn.Cmd(), btn.Img(), btn.Text());
- }
- }
- private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
- ( " "
- ), "row", "cmd", "img", "text");
-}
-/*
-