mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v1.9.3.1
This commit is contained in:
parent
a022d7f26c
commit
985863b224
7
.directory
Normal file
7
.directory
Normal file
@ -0,0 +1,7 @@
|
||||
[Dolphin]
|
||||
Timestamp=2014,9,14,23,29,45
|
||||
Version=3
|
||||
ViewMode=1
|
||||
|
||||
[Settings]
|
||||
HiddenFilesShown=true
|
@ -26,6 +26,6 @@
|
||||
<classpathentry kind="src" path="xtn"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="lib" path="lib/commons-compress-1.5.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -32,15 +32,77 @@ public class Bry_ {
|
||||
rv[i] = (byte)ary[i];
|
||||
return rv;
|
||||
}
|
||||
public static byte[] new_ascii_(String s) {
|
||||
try {
|
||||
if (s == null) return null;
|
||||
int s_len = s.length();
|
||||
if (s_len == 0) return Bry_.Empty;
|
||||
byte[] rv = new byte[s_len];
|
||||
for (int i = 0; i < s_len; ++i) {
|
||||
char c = s.charAt(i);
|
||||
if (c > 128) c = '?';
|
||||
rv[i] = (byte)c;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
catch (Exception e) {throw Err_.err_(e, "invalid ASCII sequence; s={0}", s);}
|
||||
}
|
||||
public static byte[] new_ascii_safe_null_(String s) {return s == null ? null : new_ascii_(s);}
|
||||
public static byte[] new_ascii_lang(String s) {
|
||||
try {return s.getBytes("ASCII");}
|
||||
catch (Exception e) {throw Err_.err_(e, "unsupported encoding");}
|
||||
}
|
||||
public static byte[] new_utf8_(String s) {
|
||||
try {
|
||||
int s_len = s.length();
|
||||
int b_pos = 0;
|
||||
for (int i = 0; i < s_len; ++i) {
|
||||
char c = s.charAt(i);
|
||||
int c_len = 0;
|
||||
if ( c < 128) c_len = 1; // 1 << 7
|
||||
else if ( c < 2048) c_len = 2; // 1 << 11
|
||||
else if ( (c > 55295) // 0xD800
|
||||
&& (c < 56320)) c_len = 4; // 0xDFFF
|
||||
else c_len = 3; // 1 << 16
|
||||
if (c_len == 4) ++i; // surrogate is 2 wide, not 1
|
||||
b_pos += c_len;
|
||||
}
|
||||
byte[] rv = new byte[b_pos];
|
||||
b_pos = -1;
|
||||
for (int i = 0; i < s_len; ++i) {
|
||||
char c = s.charAt(i);
|
||||
if ( c < 128) {
|
||||
rv[++b_pos] = (byte)c;
|
||||
}
|
||||
else if ( c < 2048) {
|
||||
rv[++b_pos] = (byte)(0xC0 | (c >> 6));
|
||||
rv[++b_pos] = (byte)(0x80 | (c & 0x3F));
|
||||
}
|
||||
else if ( (c > 55295) // 0xD800
|
||||
&& (c < 56320)) { // 0xDFFF
|
||||
if (i >= s_len) throw Err_.new_fmt_("incomplete surrogate pair at end of String; char={0}", c);
|
||||
char nxt_char = s.charAt(i + 1);
|
||||
int v = 0x10000 + (c - 0xD800) * 0x400 + (nxt_char - 0xDC00);
|
||||
rv[++b_pos] = (byte)(0xF0 | (v >> 18));
|
||||
rv[++b_pos] = (byte)(0x80 | (v >> 12) & 0x3F);
|
||||
rv[++b_pos] = (byte)(0x80 | (v >> 6) & 0x3F);
|
||||
rv[++b_pos] = (byte)(0x80 | (v & 0x3F));
|
||||
++i;
|
||||
}
|
||||
else {
|
||||
rv[++b_pos] = (byte)(0xE0 | (c >> 12));
|
||||
rv[++b_pos] = (byte)(0x80 | (c >> 6) & 0x3F);
|
||||
rv[++b_pos] = (byte)(0x80 | (c & 0x3F));
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
catch (Exception e) {throw Err_.err_(e, "invalid UTF-8 sequence; s={0}", s);}
|
||||
}
|
||||
public static byte[] new_utf8_lang(String s) {
|
||||
try {return s.getBytes("UTF-8");}
|
||||
catch (Exception e) {throw Err_.err_(e, "unsupported encoding");}
|
||||
}
|
||||
public static byte[] new_ascii_(String s) {
|
||||
try {return s == null ? null : s.getBytes("ASCII");}
|
||||
catch (Exception e) {throw Err_.err_(e, "unsupported encoding");}
|
||||
}
|
||||
public static byte[] new_ascii_safe_null_(String s) {return s == null ? null : new_ascii_(s);}
|
||||
public static byte[] Coalesce(byte[] orig, byte[] val_if_not_blank) {return Bry_.Len_eq_0(val_if_not_blank) ? orig : val_if_not_blank;}
|
||||
public static int While_fwd(byte[] src, byte while_byte, int bgn, int end) {
|
||||
for (int i = bgn; i < end; i++)
|
||||
|
@ -248,25 +248,32 @@ public class Bry__tst {
|
||||
void Tst_match_bwd_any(String src, int src_end, int src_bgn, String find, boolean expd) {
|
||||
Tfds.Eq(expd, Bry_.Match_bwd_any(Bry_.new_ascii_(src), src_end, src_bgn, Bry_.new_ascii_(find)));
|
||||
}
|
||||
private ByteAry_fxt fxt = new ByteAry_fxt();
|
||||
private Bry__fxt fxt = new Bry__fxt();
|
||||
@Test public void Trim_end() {
|
||||
fxt.Test_trim_end("a " , Byte_ascii.Space, "a"); // trim.one
|
||||
fxt.Test_trim_end("a " , Byte_ascii.Space, "a"); // trim.many
|
||||
fxt.Test_trim_end("a" , Byte_ascii.Space, "a"); // trim.none
|
||||
fxt.Test_trim_end("" , Byte_ascii.Space, ""); // empty
|
||||
}
|
||||
@Test public void XtoByteAry() {
|
||||
fxt.Test_new_utf8_("a" , Bry_.ints_(97));
|
||||
fxt.Test_new_utf8_("a b" , Bry_.ints_(97, 32, 98));
|
||||
fxt.Test_new_utf8_("©" , Bry_.ints_(194, 169));
|
||||
@Test public void new_ascii_() {
|
||||
fxt.Test_new_ascii_("a" , Bry_.ints_(97)); // one
|
||||
fxt.Test_new_ascii_("abc" , Bry_.ints_(97, 98, 99)); // many
|
||||
fxt.Test_new_ascii_("" , Bry_.Empty); // none
|
||||
fxt.Test_new_ascii_("¢€𤭢" , Bry_.ints_(63, 63, 63, 63)); // non-ascii -> ?
|
||||
}
|
||||
@Test public void new_utf8_() {
|
||||
fxt.Test_new_utf8_("a" , Bry_.ints_(97)); // one
|
||||
fxt.Test_new_utf8_("abc" , Bry_.ints_(97, 98, 99)); // many
|
||||
fxt.Test_new_utf8_("¢" , Bry_.ints_(194, 162)); // bry_len=2; cent
|
||||
fxt.Test_new_utf8_("€" , Bry_.ints_(226, 130, 172)); // bry_len=3; euro
|
||||
fxt.Test_new_utf8_("𤭢" , Bry_.ints_(240, 164, 173, 162)); // bry_len=3; example from en.w:UTF-8
|
||||
}
|
||||
}
|
||||
class ByteAry_fxt {
|
||||
class Bry__fxt {
|
||||
public void Test_trim_end(String raw, byte trim, String expd) {
|
||||
byte[] raw_bry = Bry_.new_ascii_(raw);
|
||||
Tfds.Eq(expd, String_.new_utf8_(Bry_.Trim_end(raw_bry, trim, raw_bry.length)));
|
||||
}
|
||||
public void Test_new_utf8_(String raw, byte[] expd_bry) {
|
||||
Tfds.Eq_ary(expd_bry, Bry_.new_utf8_(raw));
|
||||
}
|
||||
public void Test_new_utf8_(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_utf8_(raw));}
|
||||
public void Test_new_ascii_(String raw, byte[] expd) {Tfds.Eq_ary(expd, Bry_.new_ascii_(raw));}
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ public class Bry_bfr {
|
||||
public Bry_bfr Add_byte_eq() {return Add_byte(Byte_ascii.Eq);}
|
||||
public Bry_bfr Add_byte_pipe() {return Add_byte(Byte_ascii.Pipe);}
|
||||
public Bry_bfr Add_byte_comma() {return Add_byte(Byte_ascii.Comma);}
|
||||
public Bry_bfr Add_byte_semic() {return Add_byte(Byte_ascii.Semic);}
|
||||
public Bry_bfr Add_byte_apos() {return Add_byte(Byte_ascii.Apos);}
|
||||
public Bry_bfr Add_byte_slash() {return Add_byte(Byte_ascii.Slash);}
|
||||
public Bry_bfr Add_byte_backslash() {return Add_byte(Byte_ascii.Backslash);}
|
||||
|
@ -31,7 +31,7 @@ public class Long_ {
|
||||
};
|
||||
public static String Xto_str(long v) {return Long.toString(v);}
|
||||
public static String Xto_str_PadBgn(long v, int reqdPlaces) {return String_.Pad(Xto_str(v), reqdPlaces, "0", true);} // ex: 1, 3 returns 001
|
||||
public static long parse_or_(String raw, int or) {
|
||||
public static long parse_or_(String raw, long or) {
|
||||
if (raw == null) return or;
|
||||
try {
|
||||
int rawLen = String_.Len(raw);
|
||||
|
@ -20,8 +20,8 @@ import org.junit.*;
|
||||
public class Utf16__tst {
|
||||
private Utf16__fxt fxt = new Utf16__fxt();
|
||||
@Test public void Encode_decode() {
|
||||
fxt.Test_encode_decode(162, 194, 162); // cent
|
||||
fxt.Test_encode_decode(8364, 226, 130, 172); // euro
|
||||
// fxt.Test_encode_decode(162, 194, 162); // cent
|
||||
// fxt.Test_encode_decode(8364, 226, 130, 172); // euro
|
||||
fxt.Test_encode_decode(150370, 240, 164, 173, 162); // example from [[UTF-8]]; should be encoded as two bytes
|
||||
}
|
||||
@Test public void Encode_as_bry_by_hex() {
|
||||
|
@ -17,15 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx;
|
||||
public class GfoInvkAbleCmd {
|
||||
public GfoInvkAble InvkAble() {return invkAble;} GfoInvkAble invkAble;
|
||||
private GfoMsg m;
|
||||
public GfoInvkAble InvkAble() {return invkAble;} private GfoInvkAble invkAble;
|
||||
public String Cmd() {return cmd;} private String cmd;
|
||||
public Object Arg() {return arg;} Object arg;
|
||||
public Object Arg() {return arg;} private Object arg;
|
||||
public Object Invk() {
|
||||
if (this == null) return GfoInvkAble_.Rv_unhandled;
|
||||
return invkAble.Invk(GfsCtx._, 0, cmd, m);
|
||||
}
|
||||
GfoMsg m;
|
||||
|
||||
public static final GfoInvkAbleCmd Null = new GfoInvkAbleCmd();
|
||||
public static GfoInvkAbleCmd new_(GfoInvkAble invkAble, String cmd) {return arg_(invkAble, cmd, null);}
|
||||
public static GfoInvkAbleCmd arg_(GfoInvkAble invkAble, String cmd, Object arg) {
|
||||
|
@ -50,4 +50,7 @@ public class Db_stmt_ {
|
||||
public static Db_stmt new_select_as_rdr(Db_provider provider, Db_qry__select_in_tbl qry) {
|
||||
return provider.Prepare(qry);
|
||||
}
|
||||
public static Db_stmt new_select_as_rdr(Db_provider provider, String sql) {
|
||||
return provider.Prepare(Db_qry_sql.rdr_(sql));
|
||||
}
|
||||
}
|
||||
|
@ -41,15 +41,18 @@ import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.omg.PortableServer.THREAD_POLICY_ID;
|
||||
public class Swt_kit implements Gfui_kit {
|
||||
private Shell shell;
|
||||
private String xulRunnerPath = null;
|
||||
private KeyValHash ctor_args = KeyValHash.new_(); private HashAdp kit_args = HashAdp_.new_();
|
||||
private KeyValHash ctor_args = KeyValHash.new_(); private HashAdp kit_args = HashAdp_.new_(); private Swt_msg_wkr_stop msg_wkr_stop;
|
||||
private KeyValHash nullArgs = KeyValHash.new_();
|
||||
public byte Tid() {return Gfui_kit_.Swt_tid;}
|
||||
public String Key() {return "swt";}
|
||||
Display Swt_display() {return display;} private Display display;
|
||||
public Gfui_clipboard Clipboard() {return clipboard;} private Swt_clipboard clipboard;
|
||||
public Display Swt_display() {return display;} private Display display;
|
||||
public boolean Mode_is_shutdown() {return mode_is_shutdown;} private boolean mode_is_shutdown = false;
|
||||
public boolean Mode_is_shutdown() {return mode_is_shutdown;} public void Mode_is_shutdown_y_() {mode_is_shutdown = true;} private boolean mode_is_shutdown = false;
|
||||
public GfoInvkAbleCmd Kit_term_cbk() {return term_cbk;} public void Kit_term_cbk_(GfoInvkAbleCmd v) {this.term_cbk = v;} private GfoInvkAbleCmd term_cbk = GfoInvkAbleCmd.Null;
|
||||
public Gfui_html_cfg Html_cfg() {return html_cfg;} private Gfui_html_cfg html_cfg = new Gfui_html_cfg();
|
||||
public void Cfg_set(String type, String key, Object val) {
|
||||
if (String_.Eq(type, Gfui_kit_.Cfg_HtmlBox)) {
|
||||
@ -68,18 +71,17 @@ public class Swt_kit implements Gfui_kit {
|
||||
public boolean Kit_init_done() {return kit_init_done;} private boolean kit_init_done;
|
||||
public void Kit_init(Gfo_usr_dlg gui_wtr) {
|
||||
this.gui_wtr = gui_wtr;
|
||||
usrMsgWkr_Stop = new Swt_UsrMsgWkr_Stop(this, gui_wtr);
|
||||
msg_wkr_stop = new Swt_msg_wkr_stop(this, gui_wtr);
|
||||
display = new Display();
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Warn, GfoConsoleWin._);
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Stop, usrMsgWkr_Stop);
|
||||
clipboard = new Swt_clipboard(display);
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Warn, GfoConsoleWin._);
|
||||
UsrDlg_._.Reg(UsrMsgWkr_.Type_Stop, msg_wkr_stop);
|
||||
if (xulRunnerPath != null) System.setProperty("org.eclipse.swt.browser.XULRunnerPath", xulRunnerPath);
|
||||
kit_init_done = true;
|
||||
gui_wtr.Log_many("", "", "swt.kit.init.done");
|
||||
} private Gfo_usr_dlg gui_wtr;
|
||||
public void Kit_term_cbk_(GfoInvkAbleCmd v) {this.term_cbk = v;} GfoInvkAbleCmd term_cbk = GfoInvkAbleCmd.Null;
|
||||
public void Kit_run() {
|
||||
shell.addListener(SWT.Close, new Swt_lnr_shell_close(this));
|
||||
shell.addListener(SWT.Close, new Swt_shell_close_lnr(this));
|
||||
shell.open();
|
||||
Cursor cursor = new Cursor(display, SWT.CURSOR_ARROW);
|
||||
shell.setCursor(cursor); // set cursor to hand else cursor defaults to Hourglass until mouse is moved; DATE: 2014-01-31
|
||||
@ -89,14 +91,12 @@ public class Swt_kit implements Gfui_kit {
|
||||
}
|
||||
gui_wtr.Log_many("", "", "swt.kit.term:bgn");
|
||||
cursor.dispose(); gui_wtr.Log_many("", "", "swt.kit.term:cursor");
|
||||
Kit_term();
|
||||
}
|
||||
public void Kit_term() {
|
||||
mode_is_shutdown = true; // NOTE: must mark kit as shutting down, else writing to status.bar will create stack overflow exception; DATE:2014-05-05
|
||||
usrMsgWkr_Stop.Rls(); gui_wtr.Log_many("", "", "swt.kit.term:usrMsgWkr");
|
||||
clipboard.Rls(); gui_wtr.Log_many("", "", "swt.kit.term:clipboard");
|
||||
display.dispose(); gui_wtr.Log_many("", "", "swt.kit.term:display");
|
||||
} private Swt_UsrMsgWkr_Stop usrMsgWkr_Stop;
|
||||
msg_wkr_stop.Rls(); gui_wtr.Log_many("", "", "swt.kit.term:usrMsgWkr");
|
||||
shell.close();
|
||||
}
|
||||
public boolean Ask_yes_no(String grp_key, String msg_key, String fmt, Object... args) {
|
||||
Swt_dlg_msg dlg = (Swt_dlg_msg)New_dlg_msg(ask_fmtr.Bld_str_many(ask_bfr, fmt, args)).Init_btns_(Gfui_dlg_msg_.Btn_yes, Gfui_dlg_msg_.Btn_no).Init_ico_(Gfui_dlg_msg_.Ico_question);
|
||||
display.syncExec(dlg);
|
||||
@ -124,9 +124,8 @@ public class Swt_kit implements Gfui_kit {
|
||||
this.shell = win.UnderShell();
|
||||
shell.setLayout(null);
|
||||
GfuiWin rv = GfuiWin_.kit_(this, key, win, nullArgs);
|
||||
main_win = rv;
|
||||
return rv;
|
||||
} Shell shell; GfuiWin main_win;
|
||||
}
|
||||
public GfuiBtn New_btn(String key, GfuiElem owner, KeyVal... args) {
|
||||
GfuiBtn rv = GfuiBtn_.kit_(this, key, new Swt_btn_no_border(Swt_control_.cast_or_fail(owner), ctor_args), ctor_args);
|
||||
owner.SubElems().Add(rv);
|
||||
@ -241,17 +240,18 @@ public class Swt_kit implements Gfui_kit {
|
||||
control.setFont(rv);
|
||||
}
|
||||
}
|
||||
class Swt_lnr_shell_close implements Listener {
|
||||
public Swt_lnr_shell_close(Swt_kit kit) {this.kit = kit;} private Swt_kit kit;
|
||||
class Swt_shell_close_lnr implements Listener {
|
||||
public Swt_shell_close_lnr(Swt_kit kit) {this.kit = kit;} private Swt_kit kit;
|
||||
@Override public void handleEvent(Event event) {
|
||||
if (kit.term_cbk.Cmd() == null) return; // close_cmd not defined
|
||||
boolean rslt = Bool_.cast_(kit.term_cbk.Invk());
|
||||
if (!rslt)
|
||||
event.doit = false;
|
||||
kit.Mode_is_shutdown_y_(); // NOTE: must mark kit as shutting down, else writing to status_bar will create stack overflow; DATE:2014-05-05
|
||||
GfoInvkAbleCmd term_cbk = kit.Kit_term_cbk();
|
||||
if (term_cbk.Cmd() == null) return; // term_cbk not defined; exit
|
||||
boolean rslt = Bool_.cast_(term_cbk.Invk()); // term_cbk defined; call it
|
||||
if (!rslt) event.doit = false; // term_cbk canceled term; stop close
|
||||
}
|
||||
}
|
||||
class Swt_UsrMsgWkr_Stop implements UsrMsgWkr, RlsAble {
|
||||
public Swt_UsrMsgWkr_Stop(Swt_kit kit, Gfo_usr_dlg gui_wtr) {this.kit = kit; this.gui_wtr = gui_wtr;} Swt_kit kit; Gfo_usr_dlg gui_wtr;
|
||||
class Swt_msg_wkr_stop implements UsrMsgWkr, RlsAble {
|
||||
public Swt_msg_wkr_stop(Swt_kit kit, Gfo_usr_dlg gui_wtr) {this.kit = kit; this.gui_wtr = gui_wtr;} private Swt_kit kit; private Gfo_usr_dlg gui_wtr;
|
||||
@Override public void Rls() {this.kit = null;}
|
||||
public void ExecUsrMsg(int type, UsrMsg umsg) {
|
||||
String msg = umsg.XtoStr();
|
||||
|
@ -19,6 +19,7 @@ package gplx.gfui;
|
||||
import java.security.acl.Owner;
|
||||
|
||||
import gplx.*;
|
||||
import gplx.threads.ThreadAdp_;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.browser.*;
|
||||
import org.eclipse.swt.events.*;
|
||||
@ -83,7 +84,14 @@ class Swt_html implements Gxw_html, Swt_control, FocusListener {
|
||||
public String Html_js_eval_script(String script) {return Eval_script_as_str(script);}
|
||||
public boolean Html_elem_img_update(String elem_id, String elem_src, int elem_width, int elem_height) {
|
||||
elem_src = Escape_quotes(elem_src);
|
||||
return Eval_script_as_bool(kit.Html_cfg().Elem_img_update(elem_id, elem_src, elem_width, elem_height));
|
||||
int count = 0;
|
||||
while (count < 5) {
|
||||
boolean rv = Eval_script_as_bool(kit.Html_cfg().Elem_img_update(elem_id, elem_src, elem_width, elem_height));
|
||||
if (rv) return rv;
|
||||
ThreadAdp_.Sleep(100);
|
||||
count++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public String Html_active_atr_get_str(String atr_key, String or) {
|
||||
Object rv_obj = Eval_script(kit.Html_cfg().Active_atr_get_str(atr_key));
|
||||
|
@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui;
|
||||
import gplx.*;
|
||||
import gplx.threads.ThreadAdp_;
|
||||
|
||||
import org.eclipse.swt.*;
|
||||
import org.eclipse.swt.custom.*;
|
||||
@ -25,7 +26,8 @@ import org.eclipse.swt.graphics.*;
|
||||
import org.eclipse.swt.layout.*;
|
||||
import org.eclipse.swt.widgets.*;
|
||||
public class Swt_tab_mgr implements Gxw_tab_mgr, Swt_control, FocusListener, GfoEvMgrOwner {
|
||||
private GfuiInvkCmd cmd_async; // NOTE: async needed for some actions like responding to key_down and calling .setSelection; else app hangs; DATE:2014-04-30
|
||||
private GfuiInvkCmd cmd_sync;
|
||||
// private GfuiInvkCmd cmd_async; // NOTE: async needed for some actions like responding to key_down and calling .setSelection; else app hangs; DATE:2014-04-30
|
||||
public Swt_tab_mgr(Swt_kit kit, Swt_control owner_control, KeyValHash ctorArgs) {
|
||||
this.kit = kit;
|
||||
tab_folder = new CTabFolder(owner_control.Under_composite(), SWT.BORDER);
|
||||
@ -38,7 +40,8 @@ public class Swt_tab_mgr implements Gxw_tab_mgr, Swt_control, FocusListener, Gfo
|
||||
new Swt_tab_mgr_lnr_drag_drop(this, tab_folder);
|
||||
tab_folder.addCTabFolder2Listener(new Swt_tab_mgr_lnr_close(this));
|
||||
core = new Swt_core_cmds(tab_folder);
|
||||
cmd_async = kit.New_cmd_async(this);
|
||||
// cmd_async = kit.New_cmd_async(this);
|
||||
cmd_sync = kit.New_cmd_sync(this);
|
||||
}
|
||||
public Swt_kit Kit() {return kit;} private Swt_kit kit;
|
||||
public CTabFolder Under_ctabFolder() {return tab_folder;}
|
||||
@ -82,15 +85,15 @@ public class Swt_tab_mgr implements Gxw_tab_mgr, Swt_control, FocusListener, Gfo
|
||||
CTabItem itm = tab_folder.getItems()[i];
|
||||
Gfui_tab_itm_data tab_data = Get_tab_data(itm);
|
||||
CTabItem next_tab = Tabs_select_after_closing_itm(tab_data); // NOTE: must calc next_tab before calling Pub_tab_closed; latter will recalc idx
|
||||
this.Tabs_select_by_itm(next_tab); // NOTE: select tab before closing; DATE:2014-09-10
|
||||
Pub_tab_closed(tab_data.Key()); // NOTE: dispose does not call event for .close; must manually raise event;
|
||||
this.Tabs_select_by_itm(next_tab);
|
||||
itm.dispose();
|
||||
}
|
||||
@Override public void Tabs_select_by_idx(int i) {
|
||||
if (i == Gfui_tab_itm_data.Idx_null) return; // 0 tabs; return;
|
||||
msg_tabs_select_by_idx_swt.Clear();
|
||||
msg_tabs_select_by_idx_swt.Add("v", i);
|
||||
cmd_async.Invk(GfsCtx._, 0, Invk_tabs_select_by_idx_swt, msg_tabs_select_by_idx_swt);
|
||||
cmd_sync.Invk(GfsCtx._, 0, Invk_tabs_select_by_idx_swt, msg_tabs_select_by_idx_swt);
|
||||
} private GfoMsg msg_tabs_select_by_idx_swt = GfoMsg_.new_cast_(Invk_tabs_select_by_idx_swt);
|
||||
@Override public void Tabs_switch(int src, int trg) {Tabs_switch(tab_folder.getItem(src), tab_folder.getItem(trg));}
|
||||
public boolean Tabs_switch(CTabItem src_tab_itm, CTabItem trg_tab_itm) {
|
||||
@ -117,7 +120,7 @@ public class Swt_tab_mgr implements Gxw_tab_mgr, Swt_control, FocusListener, Gfo
|
||||
if (itm == null) return; // 0 tabs; return;
|
||||
msg_tabs_select_by_itm_swt.Clear();
|
||||
msg_tabs_select_by_itm_swt.Add("v", itm);
|
||||
cmd_async.Invk(GfsCtx._, 0, Invk_tabs_select_by_itm_swt, msg_tabs_select_by_itm_swt);
|
||||
cmd_sync.Invk(GfsCtx._, 0, Invk_tabs_select_by_itm_swt, msg_tabs_select_by_itm_swt);
|
||||
} private GfoMsg msg_tabs_select_by_itm_swt = GfoMsg_.new_cast_(Invk_tabs_select_by_itm_swt);
|
||||
private void Tabs_select_by_idx_swt(int idx) {
|
||||
tab_folder.setSelection(idx);
|
||||
|
@ -28,8 +28,8 @@
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/150_gfui"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/140_dbs"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="lib" path="lib/luaj_xowa.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jtidy_xowa.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/100_jre_1_7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
@ -32,6 +32,8 @@ public class Bry_rdr {
|
||||
if (find_pos != Bry_finder.Not_found) pos = find_pos;
|
||||
return find_pos;
|
||||
}
|
||||
public int Read_int_to_semic() {return Read_int_to(Byte_ascii.Semic);}
|
||||
public int Read_int_to_comma() {return Read_int_to(Byte_ascii.Comma);}
|
||||
public int Read_int_to_pipe() {return Read_int_to(Byte_ascii.Pipe);}
|
||||
public int Read_int_to_nl() {return Read_int_to(Byte_ascii.NewLine);}
|
||||
public int Read_int_to(byte to_char) {
|
||||
@ -70,4 +72,14 @@ public class Bry_rdr {
|
||||
}
|
||||
return bgn == pos ? or_bry : Bry_.Mid(src, bgn, src_len);
|
||||
}
|
||||
public boolean Read_yn_to_pipe() {
|
||||
boolean rv = src[pos] == Byte_ascii.Ltr_y;
|
||||
pos += 2; // 1 for y/n; 1 for pipe
|
||||
return rv;
|
||||
}
|
||||
public double Read_double_to_pipe() {return Read_double_to(Byte_ascii.Pipe);}
|
||||
public double Read_double_to(byte to_char) {
|
||||
byte[] double_bry = Read_bry_to(to_char);
|
||||
return Double_.parse_(String_.new_ascii_(double_bry)); // double will never have utf8
|
||||
}
|
||||
}
|
@ -30,10 +30,11 @@ public class Xoa_app implements GfoInvkAble {
|
||||
cfg_mgr = new Xoa_cfg_mgr(this);
|
||||
api_root = new Xoapi_root(this);
|
||||
url_cmd_eval = new Xoa_fsys_eval(this);
|
||||
fsys_mgr = new Xoa_fsys_mgr(this, root_dir, bin_dir_name);
|
||||
fsys_mgr = new Xoa_fsys_mgr(root_dir, bin_dir_name);
|
||||
launcher = new Launcher_app_mgr(this);
|
||||
fsys_mgr.Init_by_app(launcher);
|
||||
user = new Xou_user(this, user_dir);
|
||||
log_wtr.Log_dir_(user.Fsys_mgr().App_temp_dir().GenSubDir("log"));
|
||||
fsys_mgr.Temp_dir_(user.Fsys_mgr().App_temp_dir());
|
||||
lang_mgr = new Xoa_lang_mgr(this);
|
||||
wiki_mgr = new Xoa_wiki_mgr(this);
|
||||
gui_mgr = new Xoa_gui_mgr(this);
|
||||
@ -61,10 +62,10 @@ public class Xoa_app implements GfoInvkAble {
|
||||
public NumberParser Utl_num_parser() {return utl_num_parser;} private NumberParser utl_num_parser = new NumberParser();
|
||||
public void Init() {
|
||||
stage = Xoa_stage_.Tid_init;
|
||||
launcher.Init();
|
||||
xtn_mgr.Init_by_app(this);
|
||||
log_wtr.Init();
|
||||
gui_mgr.Init_by_app();
|
||||
fsys_mgr.Init();
|
||||
user.Init_by_app();
|
||||
file_mgr.Init_by_app();
|
||||
wiki_mgr.Init_by_app();
|
||||
@ -115,7 +116,6 @@ public class Xoa_app implements GfoInvkAble {
|
||||
public Xop_amp_mgr Parser_amp_mgr() {return parser_amp_mgr;} private Xop_amp_mgr parser_amp_mgr = new Xop_amp_mgr();
|
||||
public Xoa_thread_mgr Thread_mgr() {return thread_mgr;} private Xoa_thread_mgr thread_mgr = new Xoa_thread_mgr();
|
||||
public Url_encoder_mgr Encoder_mgr() {return encoder_mgr;} private Url_encoder_mgr encoder_mgr = new Url_encoder_mgr();
|
||||
|
||||
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xoa_fsys_mgr fsys_mgr;
|
||||
public Xoa_hive_mgr Hive_mgr() {return hive_mgr;} private Xoa_hive_mgr hive_mgr;
|
||||
public Xoa_url_parser Url_parser() {return url_parser;} private Xoa_url_parser url_parser = new Xoa_url_parser();
|
||||
@ -125,6 +125,7 @@ public class Xoa_app implements GfoInvkAble {
|
||||
public Xop_xnde_tag_regy Xnde_tag_regy() {return xnde_tag_regy;} private Xop_xnde_tag_regy xnde_tag_regy = new Xop_xnde_tag_regy();
|
||||
public Xof_math_subst_regy Math_subst_regy() {return math_subst_regy;} private Xof_math_subst_regy math_subst_regy = new Xof_math_subst_regy();
|
||||
public Gfo_usr_dlg Gui_wtr() {return gui_mgr.Browser_win().Usr_dlg();}
|
||||
public Launcher_app_mgr Launcher() {return launcher;} private Launcher_app_mgr launcher;
|
||||
|
||||
public Xoi_setup_mgr Setup_mgr() {return setup_mgr;} private Xoi_setup_mgr setup_mgr;
|
||||
public Gfo_msg_log Msg_log() {return msg_log;} private Gfo_msg_log msg_log = new Gfo_msg_log(Xoa_app_.Name);
|
||||
|
@ -23,7 +23,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "1.9.2.1";
|
||||
public static final String Version = "1.9.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
|
@ -24,7 +24,7 @@ public class Xoapi_info implements Gfo_usr_dlg_ui_opt, GfoInvkAble {
|
||||
public void Clear() {app.Usr_dlg().Ui_wkr().Clear();}
|
||||
public void Launch() {
|
||||
Io_url session_fil = app.Log_wtr().Session_fil();
|
||||
app.Fsys_mgr().App_mgr().App_view_text().Run(session_fil);
|
||||
app.Launcher().App_view_text().Run(session_fil);
|
||||
}
|
||||
public boolean Warn_enabled() {return warn_enabled;} private boolean warn_enabled;
|
||||
public boolean Note_enabled() {return note_enabled;} private boolean note_enabled;
|
||||
|
@ -17,37 +17,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
public class Xoa_fsys_mgr implements GfoInvkAble {
|
||||
public Xoa_fsys_mgr(Xoa_app app, Io_url root_dir, String bin_dir_name) {
|
||||
public Xoa_fsys_mgr(Io_url root_dir, String plat_name) {
|
||||
this.root_dir = root_dir;
|
||||
bin_any_dir = root_dir.GenSubDir("bin").GenSubDir("any");
|
||||
bin_plat_dir = root_dir.GenSubDir("bin").GenSubDir(bin_dir_name);
|
||||
bin_extensions_dir = bin_any_dir.GenSubDir_nest("xowa", "xtns");
|
||||
file_dir = root_dir.GenSubDir("file");
|
||||
file_dir_bry_len = file_dir.To_http_file_bry().length;
|
||||
wiki_dir = root_dir.GenSubDir("wiki");
|
||||
bin_plat_dir = root_dir.GenSubDir("bin").GenSubDir(plat_name);
|
||||
bin_any_dir = root_dir.GenSubDir("bin").GenSubDir("any");
|
||||
bin_xtns_dir = bin_any_dir.GenSubDir_nest("xowa", "xtns");
|
||||
cfg_lang_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "lang", "core");
|
||||
cfg_wiki_core_dir = bin_any_dir.GenSubDir_nest("xowa", "cfg", "wiki", "core");
|
||||
temp_dir = root_dir.GenSubDir("tmp");
|
||||
app_mgr = new Launcher_app_mgr(app);
|
||||
}
|
||||
public Io_url Root_dir() {return root_dir;} private final Io_url root_dir;
|
||||
public Io_url File_dir() {return file_dir;} private final Io_url file_dir;
|
||||
public int File_dir_bry_len() {return file_dir_bry_len;} private final int file_dir_bry_len;
|
||||
public Io_url Wiki_dir() {return wiki_dir;} public Xoa_fsys_mgr Wiki_dir_(Io_url v) {wiki_dir = v; return this;} private Io_url wiki_dir;
|
||||
public Io_url Bin_plat_dir() {return bin_plat_dir;} private final Io_url bin_plat_dir;
|
||||
public Io_url Bin_any_dir() {return bin_any_dir;} private final Io_url bin_any_dir;
|
||||
public Io_url Bin_xowa_dir() {return bin_any_dir.GenSubDir("xowa");}
|
||||
public Io_url Bin_xtns_dir() {return bin_xtns_dir;} private final Io_url bin_xtns_dir;
|
||||
public Io_url Cfg_lang_core_dir() {return cfg_lang_core_dir;} private final Io_url cfg_lang_core_dir;
|
||||
public Io_url Cfg_wiki_core_dir() {return cfg_wiki_core_dir;} private final Io_url cfg_wiki_core_dir;
|
||||
public Io_url Temp_dir() {return temp_dir;} public Xoa_fsys_mgr Temp_dir_(Io_url v) {temp_dir = v; return this;} private Io_url temp_dir; // set to /xowa/user/<name>/temp
|
||||
public Io_url Bin_any_dir() {return bin_any_dir;} private final Io_url bin_any_dir;
|
||||
public Io_url Bin_extensions_dir() {return bin_extensions_dir;} private final Io_url bin_extensions_dir;
|
||||
public Io_url Bin_plat_dir() {return bin_plat_dir;} private final Io_url bin_plat_dir;
|
||||
public Io_url Bin_db_dir() {return bin_any_dir.GenSubDir_nest("sql", "xowa");}
|
||||
public Io_url Bin_data_os_cfg_fil() {return bin_plat_dir.GenSubFil_nest("xowa", "cfg", Xoa_gfs_mgr.Cfg_os);}
|
||||
public Launcher_app_mgr App_mgr() {return app_mgr;} Launcher_app_mgr app_mgr;
|
||||
public void Init() {
|
||||
app_mgr.Init();
|
||||
}
|
||||
public void Init_by_app(GfoInvkAble app_mgr_invk) {
|
||||
this.app_mgr_invk = app_mgr_invk;
|
||||
} private GfoInvkAble app_mgr_invk;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_apps)) return app_mgr;
|
||||
if (ctx.Match(k, Invk_apps)) return app_mgr_invk;
|
||||
else if (ctx.Match(k, Invk_root_dir)) return root_dir;
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class Xob_wiki_cfg_bldr_tst {
|
||||
));
|
||||
String[] wikis = new String[] {"en.wikipedia.org"}; String protocol = "mem/";
|
||||
Tfds.Eq_str_lines(Query_ns(protocol, gplx.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
|
||||
( "app.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
|
||||
( "app.bldr.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
|
||||
, "4|WP"
|
||||
, "5|WT"
|
||||
, "6|Image"
|
||||
@ -131,7 +131,7 @@ public class Xob_wiki_cfg_bldr_tst {
|
||||
if (xml == null) continue; // not found
|
||||
gplx.xmls.XmlDoc xdoc = gplx.xmls.XmlDoc_.parse_(xml);
|
||||
gplx.xmls.XmlNde xnde = gplx.xmls.Xpath_.SelectFirst(xdoc.Root(), "query/namespacealiases");
|
||||
sb.Add("app.wiki_cfg_bldr.get('").Add(wiki).Add("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
|
||||
sb.Add("app.bldr.wiki_cfg_bldr.get('").Add(wiki).Add("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
|
||||
int xndes_len = xnde.SubNdes().Count();
|
||||
for (int j = 0; j < xndes_len; j++) {
|
||||
gplx.xmls.XmlNde ns_nde = xnde.SubNdes().FetchAt(j);
|
||||
|
@ -19,14 +19,15 @@ package gplx.xowa.bldrs.files; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.dbs.tbls.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.bldrs.oimgs.*; import gplx.fsdb.*; import gplx.xowa.files.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.gui.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.parsers.logs.*;
|
||||
import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.wdatas.*;
|
||||
public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_logger {
|
||||
private Db_provider provider; private Db_stmt stmt;
|
||||
private boolean wdata_enabled = true, xtn_ref_enabled = true, gen_html = false;
|
||||
private boolean wdata_enabled = true, xtn_ref_enabled = true, gen_html, gen_hdump;
|
||||
private Xop_log_invoke_wkr invoke_wkr; private Xop_log_property_wkr property_wkr;
|
||||
private int[] ns_ids = Int_.Ary(Xow_ns_.Id_main);// , Xow_ns_.Id_category, Xow_ns_.Id_template
|
||||
private boolean wiki_ns_file_is_case_match_all = true; private Xow_wiki commons_wiki;
|
||||
private Xob_hdump_bldr hdump_bldr; private long hdump_max = Io_mgr.Len_gb;
|
||||
public Xob_lnki_temp_wkr(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
@Override public String Cmd_key() {return KEY_oimg;} public static final String KEY_oimg = "file.lnki_temp";
|
||||
@Override public byte Init_redirect() {return Bool_.N_byte;} // lnki will never be found in a redirect
|
||||
@ -67,6 +68,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
|
||||
Fsdb_mnt_mgr trg_mnt_mgr = trg_fsdb_mgr.Mnt_mgr();
|
||||
trg_mnt_mgr.Insert_to_mnt_(Fsdb_mnt_mgr.Mnt_idx_main);
|
||||
Fsdb_mnt_mgr.Patch(trg_mnt_mgr); // NOTE: see fsdb_make; DATE:2014-04-26
|
||||
if (gen_hdump) hdump_bldr = new Xob_hdump_bldr(wiki, provider, hdump_max);
|
||||
provider.Txn_mgr().Txn_bgn_if_none();
|
||||
log_mgr.Txn_bgn();
|
||||
}
|
||||
@ -88,14 +90,19 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
|
||||
page.Root_(root);
|
||||
wiki.Html_mgr().Page_wtr_mgr().Gen(ctx.Cur_page(), Xopg_view_mode.Tid_read);
|
||||
}
|
||||
if (gen_hdump) {
|
||||
page.Root_(root);
|
||||
hdump_bldr.Insert_page(page);
|
||||
}
|
||||
root.Clear();
|
||||
}
|
||||
}
|
||||
// private void Gen_html(Xop_root_tkn root, Xop_ctx ctx) {}
|
||||
@Override public void Exec_commit_hook() {
|
||||
provider.Txn_mgr().Txn_end_all_bgn_if_none(); // save lnki_temp
|
||||
if (gen_hdump) hdump_bldr.Commit();
|
||||
}
|
||||
@Override public void Exec_end_hook() {
|
||||
if (gen_hdump) hdump_bldr.Bld_term();
|
||||
wiki.App().Log_mgr().Txn_end();
|
||||
provider.Txn_mgr().Txn_end();
|
||||
}
|
||||
@ -117,6 +124,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
|
||||
if (ctx.Match(k, Invk_wdata_enabled_)) wdata_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_xtn_ref_enabled_)) xtn_ref_enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_gen_html_)) gen_html = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_gen_hdump_)) gen_hdump = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_ns_ids_)) ns_ids = Int_.Ary_parse(m.ReadStr("v"), "|");
|
||||
else if (ctx.Match(k, Invk_ns_ids_by_aliases)) ns_ids = Xob_lnki_temp_wkr_.Ns_ids_by_aliases(wiki, m.ReadStrAry("v", "|"));
|
||||
else if (ctx.Match(k, Invk_property_wkr)) return this.Property_wkr();
|
||||
@ -127,7 +135,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
|
||||
private static final String Invk_wdata_enabled_ = "wdata_enabled_", Invk_xtn_ref_enabled_ = "xtn_ref_enabled_"
|
||||
, Invk_ns_ids_ = "ns_ids_", Invk_ns_ids_by_aliases = "ns_ids_by_aliases"
|
||||
, Invk_invoke_wkr = "invoke_wkr", Invk_property_wkr = "property_wkr"
|
||||
, Invk_gen_html_ = "gen_html_"
|
||||
, Invk_gen_html_ = "gen_html_", Invk_gen_hdump_ = "gen_hdump_"
|
||||
;
|
||||
private Xop_log_invoke_wkr Invoke_wkr() {
|
||||
if (invoke_wkr == null) invoke_wkr = ((Scrib_xtn_mgr)bldr.App().Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY)).Invoke_wkr_or_new();
|
||||
|
@ -20,7 +20,7 @@ public class Xob_unzip_wkr {
|
||||
private ProcessAdp decompress_bz2, decompress_zip, decompress_gz, process;
|
||||
public int Process_exit_code() {return process.Exit_code();}
|
||||
public byte Process_run_mode() {return process_run_mode;} public Xob_unzip_wkr Process_run_mode_(byte v) {process_run_mode = v; return this;} private byte process_run_mode = ProcessAdp.Run_mode_async;
|
||||
public Xob_unzip_wkr Init(Xoa_app app) {return Init(app.Fsys_mgr().App_mgr().App_decompress_bz2(), app.Fsys_mgr().App_mgr().App_decompress_zip(), app.Fsys_mgr().App_mgr().App_decompress_gz());}
|
||||
public Xob_unzip_wkr Init(Xoa_app app) {return Init(app.Launcher().App_decompress_bz2(), app.Launcher().App_decompress_zip(), app.Launcher().App_decompress_gz());}
|
||||
public Xob_unzip_wkr Init(ProcessAdp decompress_bz2, ProcessAdp decompress_zip, ProcessAdp decompress_gz) {
|
||||
this.decompress_bz2 = decompress_bz2;
|
||||
this.decompress_zip = decompress_zip;
|
||||
|
@ -40,7 +40,7 @@ public class Xob_import_cfg {
|
||||
Chk_file_ext(wiki.App(), src_fil_bz2, ".bz2", "xml");
|
||||
Xoa_app app = wiki.App();
|
||||
if (app.Setup_mgr().Dump_mgr().Import_bz2_by_stdout()) {
|
||||
ProcessAdp process = app.Fsys_mgr().App_mgr().App_decompress_bz2_by_stdout();
|
||||
ProcessAdp process = app.Launcher().App_decompress_bz2_by_stdout();
|
||||
return Io_stream_rdr_process.new_(process.Exe_url(), src_fil_bz2, process.Xto_process_bldr_args(src_fil_bz2.Raw()));
|
||||
}
|
||||
else
|
||||
|
@ -41,7 +41,7 @@ public class Xobc_core_decompress_bz extends Xob_itm_basic_base implements Xob_c
|
||||
static final String GRP_KEY = "xowa.bldr.cmd.decompress_bz2";
|
||||
public static boolean Decompress(Xoa_app app, String src_fil, Io_url trg_fil) {
|
||||
Io_mgr._.CreateDirIfAbsent(trg_fil.OwnerDir()); // 7zip will fail if dir does not exist
|
||||
ProcessAdp decompress = app.Fsys_mgr().App_mgr().App_decompress_bz2();
|
||||
ProcessAdp decompress = app.Launcher().App_decompress_bz2();
|
||||
decompress.Prog_dlg_(app.Usr_dlg()).Run_mode_(ProcessAdp.Run_mode_async);
|
||||
decompress.Run(src_fil, trg_fil, trg_fil.OwnerDir().Xto_api());
|
||||
while (decompress.Exit_code() == ProcessAdp.Exit_init) {
|
||||
|
@ -26,7 +26,7 @@ public class Xoi_wiki_props_api {
|
||||
return download_args.Exec_as_bry(src);
|
||||
}
|
||||
public void Build_cfg(Bry_bfr bfr, Xoi_wiki_props_wiki wiki) {
|
||||
bfr.Add_str("app.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
|
||||
bfr.Add_str("app.bldr.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str("').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\"\n");
|
||||
int len = 0;
|
||||
len = wiki.Alias_ary().length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
@ -34,7 +34,7 @@ public class Xoi_wiki_props_api {
|
||||
bfr.Add_int_variable(alias.Id()).Add_byte_pipe().Add_str(alias.Alias()).Add_byte_nl();
|
||||
}
|
||||
bfr.Add_str("\");');\n");
|
||||
bfr.Add_str("app.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str("').new_cmd_('wiki.ns_mgr.subpages', \"");
|
||||
bfr.Add_str("app.bldr.wiki_cfg_bldr.get('").Add(wiki.Wiki_domain()).Add_str("').new_cmd_('wiki.ns_mgr.subpages', \"");
|
||||
len = wiki.Ns_ary().length;
|
||||
boolean first = true;
|
||||
for (int i = 0; i < len; i++) {
|
||||
|
@ -41,14 +41,14 @@ public class Xoi_wiki_props_api_tst {
|
||||
.Ns_ary_(fxt.ns_(0, false), fxt.ns_(1, true))
|
||||
);
|
||||
}
|
||||
@Test public void Build() {
|
||||
// @Test public void Build() {
|
||||
// fxt.Test_build(fxt.wiki_("enwiki")
|
||||
// .Alias_ary_(fxt.alias_(4, "WP"), fxt.alias_(5, "WT"))
|
||||
// .Ns_ary_(fxt.ns_(0, false), fxt.ns_(1, true))
|
||||
// , "");
|
||||
}
|
||||
// }
|
||||
// Tfds.Eq_str_lines(Query_ns(protocol, gplx.ios.IoEngine_.MemKey, wikis), String_.Concat_lines_nl
|
||||
// ( "app.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
|
||||
// ( "app.bldr.wiki_cfg_bldr.get('en.wikipedia.org').new_cmd_('wiki.ns_mgr.aliases', 'ns_mgr.add_alias_bulk(\""
|
||||
// , "4|WP"
|
||||
// , "5|WT"
|
||||
// , "6|Image"
|
||||
|
@ -22,7 +22,8 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
private boolean html_db_enabled;
|
||||
public Xodb_mgr_sql(Xow_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
fsys_mgr = new Xodb_fsys_mgr(wiki.App().Fsys_mgr().Bin_db_dir(), wiki.Fsys_mgr().Root_dir(), wiki.Domain_str());
|
||||
Io_url bin_db_dir = wiki.App().Fsys_mgr().Bin_any_dir().GenSubDir_nest("sql", "xowa");
|
||||
fsys_mgr = new Xodb_fsys_mgr(bin_db_dir, wiki.Fsys_mgr().Root_dir(), wiki.Domain_str());
|
||||
load_mgr = new Xodb_load_mgr_sql(this, fsys_mgr);
|
||||
save_mgr = new Xodb_save_mgr_sql(this);
|
||||
tbl_text = new Xodb_text_tbl(this);
|
||||
|
@ -23,6 +23,7 @@ public class Xodb_xowa_cfg_tbl {
|
||||
Db_qry qry = Db_qry_.select_cols_(Tbl_name, Db_crt_.eq_(Fld_cfg_grp, grp), Fld_cfg_key, Fld_cfg_val);
|
||||
return provider.Exec_qry_as_rdr(qry);
|
||||
}
|
||||
public long Select_val_as_long_or(String grp, String key, long or) {return Long_.parse_or_(Select_val(grp, key), or);}
|
||||
public int Select_val_as_int(String grp, String key) {return Int_.parse_(Select_val(grp, key));}
|
||||
public String Select_val(String grp, String key) {return Select_val_or(grp, key, null);}
|
||||
public String Select_val_or(String grp, String key, String or) {
|
||||
|
@ -22,7 +22,7 @@ public class Xof_lnki_file_mgr {
|
||||
private boolean page_init_needed = true;
|
||||
private ListAdp fsdb_list = ListAdp_.new_();
|
||||
private OrderedHash xfer_list = OrderedHash_.new_bry_();
|
||||
private Xof_url_bldr url_bldr = new Xof_url_bldr().Thumbtime_dlm_dash_();
|
||||
private Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_();
|
||||
private Xof_img_size tmp_img_size = new Xof_img_size();
|
||||
public void Clear() {
|
||||
page_init_needed = true;
|
||||
|
@ -15,58 +15,44 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.gfui.*;
|
||||
import gplx.xowa.files.*;
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
public class Xof_url_bldr {
|
||||
private Bry_bfr bfr = Bry_bfr.reset_(400);
|
||||
private byte[] area; private boolean wmf_protocol_is_file;
|
||||
public byte Dir_spr() {return dir_spr;} public Xof_url_bldr Dir_spr_(byte v) {dir_spr = v; return this;} private byte dir_spr;
|
||||
public byte[] Root() {return root;} public Xof_url_bldr Root_(byte[] v) {root = v; return this;} private byte[] root;
|
||||
public byte[] Ttl() {return ttl;} public Xof_url_bldr Ttl_(byte[] v) {ttl = v; return this;} private byte[] ttl;
|
||||
public byte[] Md5() {return md5;} public Xof_url_bldr Md5_(byte[] v) {md5 = v; return this;} private byte[] md5;
|
||||
public Xof_ext Ext() {return ext;} public Xof_url_bldr Ext_(Xof_ext v) {ext = v; return this;} private Xof_ext ext;
|
||||
public int Width() {return width;} public Xof_url_bldr Width_(int v) {width = v; return this;} private int width;
|
||||
public Xof_url_bldr Thumbtime_(double v) {thumbtime = v; return this;} private double thumbtime = Xof_doc_thumb.Null;
|
||||
public Xof_url_bldr Page_(int v) {page = v; return this;} private int page = Xof_doc_page.Null;
|
||||
public Xof_url_bldr Wmf_dir_hive_(boolean v) {wmf_dir_hive = v; return this;} private boolean wmf_dir_hive;
|
||||
public boolean Thumb() {return thumb;} public Xof_url_bldr Thumb_(boolean v) {thumb = v; return this;} private boolean thumb;
|
||||
public byte Thumbtime_dlm() {return thumbtime_dlm;} private byte thumbtime_dlm = Byte_ascii.At;
|
||||
public Xof_url_bldr Thumbtime_dlm_dash_() {thumbtime_dlm = Byte_ascii.Dash; return this;}
|
||||
public Xof_url_bldr Set_trg_html_(byte mode, Xof_repo_itm repo, byte[] ttl, byte[] md5, Xof_ext ext, int width, double thumbtime, int page) {
|
||||
this.wmf_dir_hive = false; this.thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
this.dir_spr = Byte_ascii.Slash; this.root = repo.Root_http(); this.ttl = repo.Gen_name_trg(ttl, md5, ext); this.area = repo.Mode_names()[mode];
|
||||
this.md5 = md5; this.ext = ext; this.width = width; this.thumbtime = thumbtime; this.page = page;
|
||||
this.repo_dir_depth = repo.Dir_depth();
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(400);
|
||||
private byte[] ttl; private byte[] md5; private Xof_ext ext; private boolean file_is_thumb; private int file_w;
|
||||
private double time = Xof_doc_thumb.Null; private int page = Xof_doc_page.Null; private byte time_dlm = Byte_ascii.At;
|
||||
private byte[] root; private byte dir_spr; private boolean fsys_tid_is_wnt; private boolean wmf_dir_hive; private boolean wmf_protocol_is_file; private int md5_dir_depth; private byte[] area;
|
||||
public Xof_url_bldr Root_(byte[] v) {root = v; return this;}
|
||||
public Xof_url_bldr Init_by_root(byte[] root, byte dir_spr, boolean wmf_dir_hive, boolean wmf_protocol_is_file, int md5_dir_depth) {
|
||||
this.root = root; this.dir_spr = dir_spr; this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.md5_dir_depth = md5_dir_depth;
|
||||
this.fsys_tid_is_wnt = Op_sys.Cur().Tid_is_wnt();
|
||||
return this;
|
||||
} private int repo_dir_depth;
|
||||
public Xof_url_bldr Set_src_file_(byte mode, Xof_repo_itm repo, byte[] ttl, byte[] md5, Xof_ext ext, int width, double thumbtime, int page) {
|
||||
this.wmf_dir_hive = true; this.thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
}
|
||||
public Xof_url_bldr Init_by_itm(byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
|
||||
this.ttl = ttl; this.md5 = md5; this.ext = ext; this.file_w = file_w; this.time = time; this.page = page;
|
||||
if (wmf_protocol_is_file && fsys_tid_is_wnt) this.ttl = Xof_repo_itm.Ttl_invalid_fsys_chars(ttl); // NOTE: changed ttl does not change md5
|
||||
this.file_is_thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
this.area = Xof_repo_itm.Mode_names_key[mode];
|
||||
return this;
|
||||
}
|
||||
public Xof_url_bldr Init_for_src_file(byte mode, Xof_repo_itm repo, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
|
||||
this.wmf_dir_hive = Bool_.Y; this.file_is_thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
this.dir_spr = repo.Dir_spr(); this.root = repo.Root(); this.ttl = repo.Gen_name_src(ttl); this.area = repo.Mode_names()[mode];
|
||||
this.md5 = md5; this.ext = ext; this.width = width; this.thumbtime = thumbtime; this.page = page;
|
||||
this.md5 = md5; this.ext = ext; this.file_w = file_w; this.time = time; this.page = page;
|
||||
this.wmf_protocol_is_file = repo.Tarball();
|
||||
return this;
|
||||
}
|
||||
public Xof_url_bldr Set_trg_file_(byte mode, Xof_repo_itm repo, byte[] ttl, byte[] md5, Xof_ext ext, int width, double thumbtime, int page) {
|
||||
this.wmf_dir_hive = false; this.thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
public Xof_url_bldr Init_for_trg_file(byte mode, Xof_repo_itm repo, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
|
||||
this.wmf_dir_hive = Bool_.N; this.file_is_thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
this.dir_spr = repo.Dir_spr(); this.root = repo.Root(); this.ttl = repo.Gen_name_trg(ttl, md5, ext); this.area = repo.Mode_names()[mode];
|
||||
this.md5 = md5; this.ext = ext; this.width = width; this.thumbtime = thumbtime; this.page = page;
|
||||
this.repo_dir_depth = repo.Dir_depth();
|
||||
this.md5 = md5; this.ext = ext; this.file_w = file_w; this.time = time; this.page = page;
|
||||
this.md5_dir_depth = repo.Dir_depth();
|
||||
return this;
|
||||
}
|
||||
public Xof_url_bldr Init_by_root(byte[] root, byte dir_spr, boolean wmf_dir_hive, boolean wmf_protocol_is_file, int repo_dir_depth) {
|
||||
this.root = root; this.dir_spr = dir_spr; this.wmf_dir_hive = wmf_dir_hive; this.wmf_protocol_is_file = wmf_protocol_is_file; this.repo_dir_depth = repo_dir_depth;
|
||||
this.fsys_tid_is_wnt = Op_sys.Cur().Tid_is_wnt();
|
||||
return this;
|
||||
} private boolean fsys_tid_is_wnt;
|
||||
public Xof_url_bldr Init_by_itm(byte mode, byte[] ttl, byte[] md5, Xof_ext ext, int width, double thumbtime) {
|
||||
this.thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
this.area = Xof_repo_itm.Mode_names_key[mode];
|
||||
this.ttl = ttl;
|
||||
if (wmf_protocol_is_file && fsys_tid_is_wnt)
|
||||
this.ttl = Xof_repo_itm.Ttl_invalid_fsys_chars(ttl);
|
||||
this.md5 = md5; // NOTE: the md5 is the orig ttl, even if ttl gets changed b/c of invalid_chars or exceeds_len
|
||||
this.ext = ext; this.width = width; this.thumbtime = thumbtime;
|
||||
public Xof_url_bldr Init_for_trg_html(byte mode, Xof_repo_itm repo, byte[] ttl, byte[] md5, Xof_ext ext, int file_w, double time, int page) {
|
||||
this.wmf_dir_hive = Bool_.N; this.file_is_thumb = mode == Xof_repo_itm.Mode_thumb;
|
||||
this.dir_spr = Byte_ascii.Slash; this.root = repo.Root_http(); this.ttl = repo.Gen_name_trg(ttl, md5, ext); this.area = repo.Mode_names()[mode];
|
||||
this.md5 = md5; this.ext = ext; this.file_w = file_w; this.time = time; this.page = page;
|
||||
this.md5_dir_depth = repo.Dir_depth();
|
||||
return this;
|
||||
}
|
||||
public byte[] Xto_bry() {Bld(); byte[] rv = bfr.XtoAryAndClear(); Clear(); return rv;}
|
||||
@ -74,14 +60,14 @@ public class Xof_url_bldr {
|
||||
public Io_url Xto_url() {Bld(); Io_url rv = Io_url_.new_fil_(bfr.XtoStr()); Clear(); return rv;}
|
||||
private void Bld() {
|
||||
Add_core();
|
||||
if (thumb) {
|
||||
if (file_is_thumb) {
|
||||
if (wmf_dir_hive) Add_thumb_wmf();
|
||||
else Add_thumb_xowa();
|
||||
}
|
||||
}
|
||||
private Xof_url_bldr Add_core() {
|
||||
bfr.Add(root); // add root; EX: "C:\xowa\file\"; assume trailing dir_spr
|
||||
if (area != null && !(wmf_dir_hive && !thumb)) // !(wmf_dir_hive && !thumb) means never add if wmf_dir_hive and orig
|
||||
if (area != null && !(wmf_dir_hive && !file_is_thumb)) // !(wmf_dir_hive && !thumb) means never add if wmf_dir_hive and orig
|
||||
bfr.Add(area).Add_byte(dir_spr); // add area; EX: "thumb\"
|
||||
byte b0 = md5[0];
|
||||
if (wmf_dir_hive) {
|
||||
@ -89,7 +75,7 @@ public class Xof_url_bldr {
|
||||
bfr.Add_byte(b0).Add_byte(md5[1]).Add_byte(dir_spr); // add md5_01 EX: "01/"
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < repo_dir_depth; i++)
|
||||
for (int i = 0; i < md5_dir_depth; i++)
|
||||
bfr.Add_byte(md5[i]).Add_byte(dir_spr); // add md5_0123 EX: "0/1/2/3"
|
||||
}
|
||||
if (wmf_dir_hive) {
|
||||
@ -104,13 +90,13 @@ public class Xof_url_bldr {
|
||||
}
|
||||
private Xof_url_bldr Add_thumb_xowa() {
|
||||
bfr.Add_byte(dir_spr); // add dir_spr; EX: "\"
|
||||
bfr.Add_int_variable(width).Add(Bry_px); // add width; EX: "220px"
|
||||
if (Xof_doc_thumb.Null_n(thumbtime))
|
||||
bfr.Add_byte(thumbtime_dlm).Add_str(Xof_doc_thumb.X_str(thumbtime)); // add thumbtime EX: "@5"
|
||||
bfr.Add_int_variable(file_w).Add(Bry_px); // add file_w; EX: "220px"
|
||||
if (Xof_doc_thumb.Null_n(time))
|
||||
bfr.Add_byte(time_dlm).Add_str(Xof_doc_thumb.X_str(time)); // add time EX: "@5"
|
||||
else if (page != Xof_doc_page.Null)
|
||||
bfr.Add_byte(Byte_ascii.Dash).Add_int_variable(page); // add page EX: "-5"
|
||||
bfr.Add_byte(Byte_ascii.Dot); // add . EX: "."
|
||||
if (thumb)
|
||||
if (file_is_thumb)
|
||||
bfr.Add(ext.Ext_view()); // add view_ext EX: ".png"
|
||||
else
|
||||
bfr.Add(ext.Ext()); // add orig_ext EX: ".svg"
|
||||
@ -123,25 +109,25 @@ public class Xof_url_bldr {
|
||||
case Xof_ext_.Id_ogg:
|
||||
case Xof_ext_.Id_ogv:
|
||||
case Xof_ext_.Id_webm:
|
||||
if (Xof_doc_thumb.Null_n(thumbtime))
|
||||
bfr.Add(Bry_seek).Add_str(Xof_doc_thumb.X_str(thumbtime)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
if (Xof_doc_thumb.Null_n(time))
|
||||
bfr.Add(Bry_seek).Add_str(Xof_doc_thumb.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
else
|
||||
bfr.Add(Bry_mid); // add mid; EX: "mid-"
|
||||
break;
|
||||
case Xof_ext_.Id_tif:
|
||||
case Xof_ext_.Id_tiff:
|
||||
Add_thumb_wmf_page(Bry_lossy_page1, Bry_lossy_page);
|
||||
bfr.Add_int_variable(width); // add file_w; EX: "220"
|
||||
bfr.Add_int_variable(file_w); // add file_w; EX: "220"
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
break;
|
||||
case Xof_ext_.Id_pdf:
|
||||
case Xof_ext_.Id_djvu:
|
||||
Add_thumb_wmf_page(Bry_page1, Bry_page);
|
||||
bfr.Add_int_variable(width); // add file_w; EX: "220"
|
||||
bfr.Add_int_variable(file_w); // add file_w; EX: "220"
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
break;
|
||||
default:
|
||||
bfr.Add_int_variable(width); // add file_w; EX: "220"
|
||||
bfr.Add_int_variable(file_w); // add file_w; EX: "220"
|
||||
bfr.Add(Bry_px_dash); // add px; EX: "px-"
|
||||
break;
|
||||
}
|
||||
@ -175,12 +161,13 @@ public class Xof_url_bldr {
|
||||
}
|
||||
private Xof_url_bldr Clear() {
|
||||
root = area = ttl = md5 = null;
|
||||
width = 0; thumbtime = Xof_doc_thumb.Null;
|
||||
file_w = 0; time = Xof_doc_thumb.Null;
|
||||
ext = null;
|
||||
bfr.Clear();
|
||||
return this;
|
||||
}
|
||||
public static final byte[] Bry_reg = Bry_.new_ascii_("reg.csv")
|
||||
public static final byte[]
|
||||
Bry_reg = Bry_.new_ascii_("reg.csv")
|
||||
, Bry_px = Bry_.new_ascii_("px"), Bry_px_dash = Bry_.new_ascii_("px-")
|
||||
, Bry_thumb = Bry_.new_ascii_("thumb"), Bry_mid = Bry_.new_ascii_("mid-")
|
||||
;
|
||||
@ -189,5 +176,9 @@ public class Xof_url_bldr {
|
||||
, Bry_lossy_page1 = Bry_.new_ascii_("lossy-page1-"), Bry_page1 = Bry_.new_ascii_("page1-"), Bry_seek = Bry_.new_ascii_("seek%3D");
|
||||
public static final Xof_url_bldr Temp = new Xof_url_bldr();
|
||||
private static final Url_encoder encoder_src_http = Url_encoder.new_http_url_(); // NOTE: changed from new_html_href_mw_ to new_url_ on 2012-11-19; issues with A%2Cb becoming A%252Cb
|
||||
public static Xof_url_bldr new_v2_() {return new Xof_url_bldr().Thumbtime_dlm_dash_();}
|
||||
public static Xof_url_bldr new_v2_() {
|
||||
Xof_url_bldr rv = new Xof_url_bldr();
|
||||
rv.time_dlm = Byte_ascii.Dash;
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -15,19 +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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.gfui.*;
|
||||
import gplx.xowa.files.*;
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
public class Xof_url_bldr_tst {
|
||||
Xof_url_bldr_fxt fxt = new Xof_url_bldr_fxt();
|
||||
private Xof_url_bldr_fxt fxt = new Xof_url_bldr_fxt();
|
||||
@Before public void init() {fxt.ini();}
|
||||
@Test public void Ogv() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/d/d0/A.ogv/mid-A.ogv.jpg").tst();}
|
||||
@Test public void Ogv_seek() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/d/d0/A.ogv/seek%3D5-A.ogv.jpg").Seek_(5).tst();}
|
||||
@Test public void Xcf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("44").Ttl_("A.xcf").Expd_src_("http://test/4/44/A.xcf/0px-A.xcf.png").tst();}
|
||||
@Test public void Bmp() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("70").Ttl_("A.bmp").Expd_src_("http://test/7/70/A.bmp/0px-A.bmp.png").tst();}
|
||||
@Test public void Pdf_none() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Expd_src_("http://test/e/ef/A.pdf/page1-0px-A.pdf.jpg").tst();}
|
||||
@Test public void Pdf_page_2() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Page_(2).Expd_src_("http://test/e/ef/A.pdf/page2-0px-A.pdf.jpg").tst();}
|
||||
@Test public void Ogv() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/thumb/d/d0/A.ogv/mid-A.ogv.jpg").tst();}
|
||||
@Test public void Ogv_seek() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("d0").Ttl_("A.ogv").Expd_src_("http://test/thumb/d/d0/A.ogv/seek%3D5-A.ogv.jpg").Seek_(5).tst();}
|
||||
@Test public void Xcf() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("44").Ttl_("A.xcf").Expd_src_("http://test/thumb/4/44/A.xcf/0px-A.xcf.png").tst();}
|
||||
@Test public void Bmp() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("70").Ttl_("A.bmp").Expd_src_("http://test/thumb/7/70/A.bmp/0px-A.bmp.png").tst();}
|
||||
@Test public void Pdf_none() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Expd_src_("http://test/thumb/e/ef/A.pdf/page1-0px-A.pdf.jpg").tst();}
|
||||
@Test public void Pdf_page_2() {fxt.Dir_spr_http_().Root_("http://test/").Md5_("ef").Ttl_("A.pdf").Page_(2).Expd_src_("http://test/thumb/e/ef/A.pdf/page2-0px-A.pdf.jpg").tst();}
|
||||
}
|
||||
class Xof_url_bldr_fxt {
|
||||
public Xof_url_bldr_fxt ini() {this.Clear(); return this;}
|
||||
@ -47,7 +45,8 @@ class Xof_url_bldr_fxt {
|
||||
page = Xof_doc_page.Null;
|
||||
}
|
||||
public Xof_url_bldr_fxt tst() {
|
||||
url_bldr.Wmf_dir_hive_(true).Thumb_(true).Dir_spr_(dir_spr).Root_(Bry_.new_utf8_(root)).Md5_(Bry_.new_utf8_(md5)).Ttl_(Bry_.new_utf8_(ttl)).Ext_(ext).Thumbtime_(seek).Page_(page);
|
||||
url_bldr.Init_by_root(Bry_.new_utf8_(root), dir_spr, Bool_.Y, Bool_.N, 2);
|
||||
url_bldr.Init_by_itm (Xof_repo_itm.Mode_thumb, Bry_.new_utf8_(ttl), Bry_.new_utf8_(md5), ext, 0, seek, page);
|
||||
Tfds.Eq(expd_src, url_bldr.Xto_str());
|
||||
return this;
|
||||
}
|
@ -53,8 +53,8 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
} private Xof_repo_itm trg_repo;
|
||||
public int Trg_repo_idx() {return trg_repo_idx;} public Xof_xfer_itm Trg_repo_idx_(int trg_repo_idx) {this.trg_repo_idx = trg_repo_idx; return this;} private int trg_repo_idx = Xof_meta_itm.Repo_unknown;
|
||||
public byte[] Trg_repo_root() {return trg_repo_root;} private byte[] trg_repo_root = Bry_.Empty; // HACK: needed for hdump
|
||||
private byte[] Trg_html(byte mode_id, int width) {return url_bldr.Set_trg_html_(mode_id, trg_repo, lnki_ttl, lnki_md5, lnki_ext, width, lnki_thumbtime, lnki_page).Xto_bry();}
|
||||
public Io_url Trg_file(byte mode_id, int width) {return url_bldr.Set_trg_file_(mode_id, trg_repo, lnki_ttl, lnki_md5, lnki_ext, width, lnki_thumbtime, lnki_page).Xto_url();}
|
||||
private byte[] Trg_html(byte mode_id, int width) {return url_bldr.Init_for_trg_html(mode_id, trg_repo, lnki_ttl, lnki_md5, lnki_ext, width, lnki_thumbtime, lnki_page).Xto_bry();}
|
||||
public Io_url Trg_file(byte mode_id, int width) {return url_bldr.Init_for_trg_file(mode_id, trg_repo, lnki_ttl, lnki_md5, lnki_ext, width, lnki_thumbtime, lnki_page).Xto_url();}
|
||||
public Xof_url_bldr Url_bldr(){ return url_bldr;}
|
||||
public Xof_xfer_itm Url_bldr_(Xof_url_bldr v) {url_bldr = v; return this;} private Xof_url_bldr url_bldr = Xof_url_bldr.Temp;
|
||||
public Xof_xfer_itm Clear() {
|
||||
|
@ -95,8 +95,8 @@ public class Xof_bin_mgr implements GfoInvkAble {
|
||||
private Io_url Get_url(Xof_fsdb_itm itm, byte mode, boolean src) {
|
||||
Xof_repo_pair repo = repo_mgr.Repos_get_by_wiki(itm.Orig_wiki());
|
||||
return src
|
||||
? url_bldr.Set_src_file_(mode, repo.Src(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_thumbtime(), itm.Lnki_page()).Xto_url()
|
||||
: url_bldr.Set_trg_file_(mode, repo.Trg(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_thumbtime(), itm.Lnki_page()).Xto_url()
|
||||
? url_bldr.Init_for_src_file(mode, repo.Src(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_thumbtime(), itm.Lnki_page()).Xto_url()
|
||||
: url_bldr.Init_for_trg_file(mode, repo.Trg(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_thumbtime(), itm.Lnki_page()).Xto_url()
|
||||
;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
@ -23,17 +23,17 @@ public abstract class Xof_bin_wkr_fsys_base implements Xof_bin_wkr, GfoInvkAble
|
||||
public boolean Bin_wkr_resize() {return bin_wkr_resize;} public void Bin_wkr_resize_(boolean v) {bin_wkr_resize = v;} private boolean bin_wkr_resize = false;
|
||||
public gplx.ios.Io_stream_rdr Bin_wkr_get_as_rdr(ListAdp temp_files, Xof_fsdb_itm itm, boolean is_thumb, int w) {
|
||||
byte mode = is_thumb ? Xof_repo_itm.Mode_thumb : Xof_repo_itm.Mode_orig;
|
||||
Io_url src_url = this.Get_src_url(mode, String_.new_utf8_(itm.Orig_wiki()), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), w, itm.Lnki_thumbtime());
|
||||
Io_url src_url = this.Get_src_url(mode, String_.new_utf8_(itm.Orig_wiki()), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), w, itm.Lnki_thumbtime(), itm.Lnki_page());
|
||||
return (src_url == Io_url_.Null) ? gplx.ios.Io_stream_rdr_.Null : gplx.ios.Io_stream_rdr_.file_(src_url);
|
||||
}
|
||||
public boolean Bin_wkr_get_to_url(ListAdp temp_files, Xof_fsdb_itm itm, boolean is_thumb, int w, Io_url bin_url) {
|
||||
byte mode = is_thumb ? Xof_repo_itm.Mode_thumb : Xof_repo_itm.Mode_orig;
|
||||
Io_url src_url = this.Get_src_url(mode, String_.new_utf8_(itm.Orig_wiki()), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), w, itm.Lnki_thumbtime());
|
||||
Io_url src_url = this.Get_src_url(mode, String_.new_utf8_(itm.Orig_wiki()), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), w, itm.Lnki_thumbtime(), itm.Lnki_page());
|
||||
if (src_url == Io_url_.Null) return false;
|
||||
byte[] bin = Io_mgr._.LoadFilBry(src_url);
|
||||
return bin != Io_mgr.LoadFilBry_fail;
|
||||
}
|
||||
protected abstract Io_url Get_src_url(byte mode, String wiki, byte[] ttl_wo_ns, byte[] md5, Xof_ext ext, int w, double thumbtime);
|
||||
protected abstract Io_url Get_src_url(byte mode, String wiki, byte[] ttl_wo_ns, byte[] md5, Xof_ext ext, int w, double time, int page);
|
||||
public abstract void Url_(Io_url v);
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_url_)) this.Url_(m.ReadIoUrl("v"));
|
||||
@ -45,8 +45,8 @@ abstract class Xof_bin_wkr_fsys_wmf_base extends Xof_bin_wkr_fsys_base {
|
||||
public Xof_url_bldr Url_bldr() {return url_bldr;} private Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
public abstract void Init_by_root();
|
||||
@Override public void Url_(Io_url v) {url_bldr.Root_(Bry_.new_utf8_(v.Raw()));}
|
||||
@Override protected Io_url Get_src_url(byte mode, String wiki, byte[] ttl_wo_ns, byte[] md5, Xof_ext ext, int w, double thumbtime) {
|
||||
return this.Url_bldr().Init_by_itm(mode, ttl_wo_ns, md5, ext, w, thumbtime).Xto_url();
|
||||
@Override protected Io_url Get_src_url(byte mode, String wiki, byte[] ttl_wo_ns, byte[] md5, Xof_ext ext, int w, double time, int page) {
|
||||
return this.Url_bldr().Init_by_itm(mode, ttl_wo_ns, md5, ext, w, time, page).Xto_url();
|
||||
}
|
||||
}
|
||||
class Xof_bin_wkr_fsys_wmf extends Xof_bin_wkr_fsys_wmf_base {
|
||||
|
@ -48,7 +48,7 @@ public class Xof_bin_wkr_http_wmf implements Xof_bin_wkr {
|
||||
Xof_repo_pair repo_itm = repo_mgr.Repos_get_by_wiki(itm.Orig_wiki());
|
||||
String queue_msg = String_.Format("downloading ~{0} of ~{1}: ~{2};", 0, 0, String_.new_utf8_(itm.Lnki_ttl()));
|
||||
download.Prog_fmt_hdr_(queue_msg);
|
||||
String src = url_bldr.Set_src_file_(mode, repo_itm.Src(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), w, itm.Lnki_thumbtime(), itm.Lnki_page()).Xto_str();
|
||||
String src = url_bldr.Init_for_src_file(mode, repo_itm.Src(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), w, itm.Lnki_thumbtime(), itm.Lnki_page()).Xto_str();
|
||||
download.Init(src, bin_url);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
@ -91,8 +91,8 @@ public class Xof_fsdb_itm {
|
||||
byte[] name_bry = Bry_.Len_eq_0(orig_redirect) ? lnki_ttl : orig_redirect;
|
||||
if (!lnki_ext.Id_is_media() && lnki_thumbtime != Xof_doc_thumb.Null) // file is not media, but has thumbtime; this check can't be moved to Lnki_thumbtime_() b/c it needs ext
|
||||
lnki_thumbtime = Xof_doc_thumb.Null; // set thumbtime to null; needed else url will reference thumbtime; PAGE:en.w:Moon; EX:[[File:Lunar libration with phase Oct 2007 450px.gif|thumbtime=0:02]]; DATE:2014-07-20
|
||||
html_url = url_bldr.Set_trg_file_(lnki_type_as_mode, repo, name_bry, lnki_md5, lnki_ext, html_w, lnki_thumbtime, lnki_page).Xto_url();
|
||||
html_orig_url = url_bldr.Set_trg_file_(Xof_repo_itm.Mode_orig, repo, name_bry, lnki_md5, lnki_ext, Xof_img_size.Size_null_deprecated, Xof_doc_thumb.Null, Xof_doc_page.Null).Xto_url();
|
||||
html_url = url_bldr.Init_for_trg_file(lnki_type_as_mode, repo, name_bry, lnki_md5, lnki_ext, html_w, lnki_thumbtime, lnki_page).Xto_url();
|
||||
html_orig_url = url_bldr.Init_for_trg_file(Xof_repo_itm.Mode_orig, repo, name_bry, lnki_md5, lnki_ext, Xof_img_size.Size_null_deprecated, Xof_doc_thumb.Null, Xof_doc_page.Null).Xto_url();
|
||||
}
|
||||
public Io_url Html_orig_url() {return html_orig_url;} public Xof_fsdb_itm Html_orig_url_(Io_url v) {this.html_orig_url = v; return this;} private Io_url html_orig_url = Io_url_.Null;
|
||||
public int Gallery_mgr_h() {return gallery_mgr_h;} public Xof_fsdb_itm Gallery_mgr_h_(int v) {gallery_mgr_h = v; return this;} private int gallery_mgr_h = Int_.Neg1;
|
||||
|
@ -127,7 +127,7 @@ class Cache_fil_mgr {
|
||||
byte[] ttl = itm.Fil_name();
|
||||
byte[] md5 = Xof_xfer_itm_.Md5_(ttl);
|
||||
int itm_ext_id = itm.Fil_ext().Id();
|
||||
Io_url fil_url = url_bldr.Set_trg_file_(mode_id, trg_repo, ttl, md5, itm.Fil_ext(), itm.Fil_w()
|
||||
Io_url fil_url = url_bldr.Init_for_trg_file(mode_id, trg_repo, ttl, md5, itm.Fil_ext(), itm.Fil_w()
|
||||
, Xof_doc_thumb.Convert_to_xowa_thumbtime (itm_ext_id, itm.Fil_thumbtime())
|
||||
, Xof_doc_thumb.Convert_to_xowa_page (itm_ext_id, itm.Fil_thumbtime())
|
||||
).Xto_url();
|
||||
|
@ -75,7 +75,7 @@ class Xof_wiki_orig_tbl_evaluator {
|
||||
if (Bry_.Len_gt_0(regy_itm.Orig_redirect())) // redirect exists;
|
||||
fsdb_itm.Init_by_redirect(regy_itm.Orig_redirect());
|
||||
fsdb_itm.Html_size_calc(img_size, exec_tid);
|
||||
Io_url html_url = url_bldr.Set_trg_file_(fsdb_itm.Lnki_type_as_mode(), repo, fsdb_itm.Lnki_ttl(), fsdb_itm.Lnki_md5(), fsdb_itm.Lnki_ext(), fsdb_itm.Html_w(), fsdb_itm.Lnki_thumbtime(), fsdb_itm.Lnki_page()).Xto_url();
|
||||
Io_url html_url = url_bldr.Init_for_trg_file(fsdb_itm.Lnki_type_as_mode(), repo, fsdb_itm.Lnki_ttl(), fsdb_itm.Lnki_md5(), fsdb_itm.Lnki_ext(), fsdb_itm.Html_w(), fsdb_itm.Lnki_thumbtime(), fsdb_itm.Lnki_page()).Xto_url();
|
||||
fsdb_itm.Html_url_(html_url);
|
||||
if (!Io_mgr._.ExistsFil(html_url))
|
||||
fsdb_itm.Rslt_reg_(Xof_wiki_orig_wkr_.Tid_missing_reg);
|
||||
|
@ -47,7 +47,7 @@ public class Xog_url_wkr {
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_http(Xoa_app app) { // EX: http:a.org
|
||||
app.Fsys_mgr().App_mgr().Exec_view_web(href.Raw());
|
||||
app.Launcher().Exec_view_web(href.Raw());
|
||||
return Rslt_handled;
|
||||
}
|
||||
private Xoa_url Exec_url_anchor(Xog_win_itm win) { // EX: #anchor
|
||||
@ -85,7 +85,7 @@ public class Xog_url_wkr {
|
||||
page.Wiki().File_mgr().Repo_mgr().Xfer_mgr().Force_orig_n_();
|
||||
}
|
||||
if (Io_mgr._.ExistsFil(href_url)) {
|
||||
ProcessAdp media_player = app.Fsys_mgr().App_mgr().App_by_ext(href_url.Ext());
|
||||
ProcessAdp media_player = app.Launcher().App_by_ext(href_url.Ext());
|
||||
media_player.Run(href_url);
|
||||
}
|
||||
return Rslt_handled;
|
||||
|
@ -77,7 +77,6 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
else if (ctx.Match(k, Invk_page_goto_recent)) Page__navigate_by_url_bar(app.User().History_mgr().Get_at_last(app));
|
||||
else if (ctx.Match(k, Invk_history_bwd)) {Page__navigate_by_history(Bool_.N);}
|
||||
else if (ctx.Match(k, Invk_history_fwd)) {Page__navigate_by_history(Bool_.Y);}
|
||||
else if (ctx.Match(k, Invk_app_exit)) App__exit();
|
||||
else if (ctx.Match(k, Invk_eval)) App__eval(m.ReadStr("cmd"));
|
||||
else if (ctx.Match(k, Invk_page_async_cancel_wait)) Page__async__cancel__wait();
|
||||
else if (ctx.Match(k, Invk_page_async_restart)) Page__async__restart();
|
||||
@ -104,7 +103,6 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
, Invk_page_edit_focus_box = "page_edit_focus_box", Invk_page_edit_focus_first = "page_edit_focus_first"
|
||||
, Invk_page_edit_save = "page_edit_save", Invk_page_edit_save_draft = "page_edit_save_draft", Invk_page_edit_preview = "page_edit_preview", Invk_page_edit_rename = "page_edit_rename"
|
||||
, Invk_page_dbg_wiki = "page_dbg_wiki", Invk_page_dbg_html = "page_dbg_html"
|
||||
, Invk_app_exit = "app_exit"
|
||||
, Invk_eval = "eval"
|
||||
// xowa.gfs: shortcuts
|
||||
, Invk_page_goto = "page_goto", Invk_page_goto_recent = "page_goto_recent"
|
||||
@ -134,8 +132,7 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
|
||||
app.User().History_mgr().Add(page.Url(), page.Ttl(), Bry_.Add_w_dlm(Byte_ascii.Hash, page.Url().Page_bry(), anchor_bry));
|
||||
}
|
||||
public void App__exit() {
|
||||
if (!app.Term_cbk()) return; // NOTE: exit called by keyboard shortcut, or exit link; must call Term_cbk manually; Alt-F4/X button will call Term_cbk in closing event
|
||||
app.Gui_mgr().Kit().Kit_term();
|
||||
kit.Kit_term(); // NOTE: Kit_term calls shell.close() which in turn is hooked up to app.Term_cbk() event; DATE:2014-09-09
|
||||
}
|
||||
private void App__eval(String s) {
|
||||
String snippet = this.Active_html_box().Html_elem_atr_get_str(s, Gfui_html.Atr_innerHTML);
|
||||
|
90
400_xowa/src/gplx/xowa/hdumps/Xob_hdump_bldr.java
Normal file
90
400_xowa/src/gplx/xowa/hdumps/Xob_hdump_bldr.java
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*; import gplx.xowa.dbs.*; import gplx.xowa.dbs.tbls.*; import gplx.xowa.hdumps.saves.*; import gplx.xowa.hdumps.dbs.*;
|
||||
public class Xob_hdump_bldr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(Io_mgr.Len_mb);
|
||||
private Xow_wiki wiki; private Xodb_file core_db; private Xodb_xowa_cfg_tbl cfg_tbl; private Db_stmt cfg_update_stmt;
|
||||
private int hdump_db_id; private long hdump_db_size, hdump_db_max; private Db_provider hdump_db_provider;
|
||||
private Xodb_hdump_mgr hdump_mgr; private Hdump_save_mgr hdump_save_mgr;
|
||||
public Xob_hdump_bldr(Xow_wiki wiki, Db_provider make_provider, long hdump_db_max) {
|
||||
this.wiki = wiki; this.hdump_db_max = hdump_db_max;
|
||||
core_db = wiki.Db_mgr_as_sql().Fsys_mgr().Get_tid_root(Xodb_file_tid.Tid_core);
|
||||
hdump_mgr = wiki.Db_mgr_as_sql().Hdump_mgr(); hdump_save_mgr = hdump_mgr.Save_mgr();
|
||||
cfg_tbl = new Xodb_xowa_cfg_tbl().Provider_(make_provider); cfg_update_stmt = cfg_tbl.Update_stmt();
|
||||
Init_hdump_db(Db_get_last_or_make(wiki), cfg_tbl.Select_val_as_long_or(Cfg_grp_hdump_make, Cfg_itm_hdump_size, 0));
|
||||
hdump_db_provider.Txn_mgr().Txn_bgn_if_none();
|
||||
//wiki.Db_mgr().Data_storage_format_(gplx.ios.Io_stream_.Tid_gzip);
|
||||
}
|
||||
public void Insert_page(Xoa_page page) {
|
||||
hdump_mgr.Write(tmp_bfr, page);
|
||||
int body_len = hdump_save_mgr.Insert_body(page, page.Revision_data().Id());
|
||||
hdump_db_size += body_len;
|
||||
if (hdump_db_size > hdump_db_max) {
|
||||
Db_term(core_db, hdump_db_provider, hdump_db_id);
|
||||
Init_hdump_db(wiki.Db_mgr_as_sql().Fsys_mgr().Make(Xodb_file_tid.Tid_html), 0);
|
||||
Db_init(hdump_db_provider);
|
||||
}
|
||||
}
|
||||
public void Commit() {
|
||||
hdump_db_provider.Txn_mgr().Txn_end_all_bgn_if_none();
|
||||
cfg_tbl.Update(cfg_update_stmt, Cfg_grp_hdump_make, Cfg_itm_hdump_size, Long_.Xto_str(hdump_db_size));
|
||||
}
|
||||
public void Bld_term() {
|
||||
this.Commit();
|
||||
Db_term(core_db, hdump_db_provider, hdump_db_id);
|
||||
}
|
||||
private void Init_hdump_db(Xodb_file db_file, long hdump_db_size) {
|
||||
this.hdump_db_id = db_file.Id();
|
||||
this.hdump_db_provider = db_file.Provider();
|
||||
this.hdump_db_size = hdump_db_size;
|
||||
this.hdump_save_mgr.Tbl().Provider_(hdump_db_provider);
|
||||
}
|
||||
private static Xodb_file Db_get_last_or_make(Xow_wiki wiki) {
|
||||
Xodb_fsys_mgr fsys_mgr = wiki.Db_mgr_as_sql().Fsys_mgr();
|
||||
Xodb_file rv = fsys_mgr.Get_tid_root(Xodb_file_tid.Tid_html);
|
||||
if (rv == null) {
|
||||
rv = fsys_mgr.Make(Xodb_file_tid.Tid_html);
|
||||
Db_init(rv.Provider());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static void Db_init(Db_provider p) {p.Exec_sql(Hdump_text_tbl.Tbl_sql);}
|
||||
private static void Db_term(Xodb_file core_db_file, Db_provider hdump_db_provider, int hdump_db_id) {
|
||||
hdump_db_provider.Txn_mgr().Txn_end();
|
||||
Sqlite_engine_.Db_attach(hdump_db_provider, "page_db", core_db_file.Url().Raw());
|
||||
hdump_db_provider.Exec_sql(String_.Format(Sql_update_page, hdump_db_id)); // update all page_html_db_id entries in page_db
|
||||
Sqlite_engine_.Db_detach(hdump_db_provider, "page_db");
|
||||
hdump_db_provider.Txn_mgr().Txn_end_all();
|
||||
}
|
||||
private static final String Cfg_grp_hdump_make = "hdump.make", Cfg_itm_hdump_size = "hdump.size";
|
||||
private static final String Sql_update_page = String_.Concat_lines_nl_skip_last
|
||||
( "REPLACE INTO page_db.page"
|
||||
, "SELECT p.page_id"
|
||||
, ", p.page_namespace"
|
||||
, ", p.page_title"
|
||||
, ", p.page_is_redirect"
|
||||
, ", p.page_touched"
|
||||
, ", p.page_len"
|
||||
, ", p.page_random_int"
|
||||
, ", p.page_file_idx"
|
||||
, ", {0}"
|
||||
, "FROM page_db.page p"
|
||||
, " JOIN html_text h ON p.page_id = h.page_id"
|
||||
);
|
||||
}
|
@ -24,6 +24,7 @@ public class Xodb_hdump_mgr {
|
||||
this.wiki = wiki;
|
||||
load_mgr = new Hdump_load_mgr(this);
|
||||
Tbl_(new Hdump_text_tbl());
|
||||
text_tbl.Init_by_wiki(wiki);
|
||||
Xoa_app app = wiki.App();
|
||||
html_mgr.Init_by_app(app);
|
||||
}
|
||||
@ -51,7 +52,7 @@ public class Xodb_hdump_mgr {
|
||||
wiki.Db_mgr_as_sql().Tbl_page().Update_html_db_id(page.Revision_data().Id(), hdump_db_file.Id());
|
||||
tmp_bfr.Mkr_rls();
|
||||
}
|
||||
@gplx.Internal protected void Write(Bry_bfr bfr, Xoa_page page) {
|
||||
public void Write(Bry_bfr bfr, Xoa_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
Xoh_page_wtr_wkr wkr = wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_view_mode.Tid_read);
|
||||
wkr.Write_body(bfr, Xoh_wtr_ctx.Hdump, page);
|
||||
|
@ -27,8 +27,8 @@ public class Xodb_hdump_mgr__save_tst {
|
||||
fxt.Test_save("a[[File:A.png|test_caption]]b[[File:B.png|test_caption]]"
|
||||
, fxt.Make_row_body(2, "a<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"test_caption\" xowa_img='0' /></a>b<a href=\"/wiki/File:B.png\" class=\"image\" xowa_title=\"B.png\"><img id=\"xowa_file_img_1\" alt=\"test_caption\" xowa_img='1' /></a>")
|
||||
, fxt.Make_row_img
|
||||
( fxt.Make_img(0, 0, 0, "A.png", "trg/orig/7/0/A.png")
|
||||
, fxt.Make_img(1, 0, 0, "B.png", "trg/orig/5/7/B.png")
|
||||
( fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png)
|
||||
, fxt.Make_xfer("B.png", 1, 0, 0, Bool_.Y, Xof_ext_.Id_png)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -63,6 +63,13 @@ public class Xodb_hdump_mgr__save_tst {
|
||||
, "<xo_5/>bcd"
|
||||
));
|
||||
}
|
||||
@Test public void Redlink() {
|
||||
fxt.Init_redlinks(1);
|
||||
fxt.Test_save("[[A]] [[B]]"
|
||||
, fxt.Make_row_body(0, "<a href=\"/wiki/A\" xowa_redlink='1'>A</a> <a href=\"/wiki/B\" xowa_redlink='2'>B</a>")
|
||||
, fxt.Make_row_redlink(1)
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xodb_hdump_mgr__save_fxt extends Xodb_hdump_mgr__base_fxt {
|
||||
private int page_id = 0;
|
||||
@ -71,20 +78,41 @@ class Xodb_hdump_mgr__save_fxt extends Xodb_hdump_mgr__base_fxt {
|
||||
@Override public void Clear_end() {
|
||||
hdump_mgr.Tbl_mem_();
|
||||
hdump_mgr.Text_tbl().Provider_(Hdump_text_tbl_mem.Null_provider);
|
||||
init_redlinks = null;
|
||||
}
|
||||
public void Init_redlinks(int... uids) {
|
||||
this.init_redlinks = uids;
|
||||
page.Lnki_redlinks_mgr().Page_bgn();
|
||||
} private int[] init_redlinks;
|
||||
public Hdump_text_row Make_row_body(int imgs_count, String body) {
|
||||
page.Hdump_data().Body_(Bry_.new_utf8_(body));
|
||||
page.Hdump_data().Data_count_imgs_(imgs_count);
|
||||
Hdump_page_body_srl.Save(tmp_bfr, page);
|
||||
return new Hdump_text_row(page_id, Hdump_text_row_tid.Tid_body, tmp_bfr.XtoAryAndClear());
|
||||
}
|
||||
public Hdump_data_img__base Make_img(int uid, int img_w, int img_h, String lnki_ttl, String img_src_rel) {return new Hdump_data_img__basic().Init_by_base(uid, img_w, img_h, Bry_.new_utf8_(lnki_ttl), Bry_.new_utf8_(img_src_rel));}
|
||||
public Hdump_text_row Make_row_img(Hdump_data_img__base... itms) {
|
||||
ListAdp tmp_list = ListAdp_.new_();
|
||||
tmp_list.AddMany((Object[])itms);
|
||||
byte[] imgs_bry = Hdump_save_mgr.Write_imgs(tmp_bfr, tmp_list);
|
||||
return new Hdump_text_row(page_id, Hdump_text_row_tid.Tid_data, imgs_bry);
|
||||
}
|
||||
public Hdump_text_row Make_row_redlink(int... uids) {
|
||||
Xopg_redlink_mgr redlink_mgr = new Xopg_redlink_mgr();
|
||||
for (int uid : uids)
|
||||
redlink_mgr.Add(uid);
|
||||
byte[] redlinks_bry = Hdump_save_mgr.Write_redlinks(tmp_bfr, redlink_mgr);
|
||||
return new Hdump_text_row(page_id, Hdump_data_tid.Tid_redlink, redlinks_bry);
|
||||
}
|
||||
@Override public void Exec_write(String raw) {
|
||||
super.Exec_write(raw);
|
||||
if (init_redlinks != null) {
|
||||
Xopg_redlink_mgr redlink_mgr = page.Hdump_data().Redlink_mgr();
|
||||
int len = init_redlinks.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
redlink_mgr.Add(init_redlinks[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Test_write(String raw, String expd) {
|
||||
this.Exec_write(raw);
|
||||
Hdump_page_body_srl.Save(tmp_bfr, page);
|
||||
|
@ -17,17 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps; import gplx.*; import gplx.xowa.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.xtns.hieros.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Xodb_hdump_mgr__write_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xodb_hdump_mgr__write_fxt fxt = new Xodb_hdump_mgr__write_fxt();
|
||||
@Test public void Image_full() {
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer(0, 0, 0, "A.png", "trg/orig/7/0/A.png"));
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png));
|
||||
fxt.Test_write_all
|
||||
( "[[File:A.png|test_caption]]"
|
||||
, "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"test_caption\" xowa_img='0' /></a>");
|
||||
}
|
||||
@Test public void Image_thumb() {
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer(0, 0, 0, "A.png", "trg/thumb/7/0/A.png/220px.png"));
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.N, Xof_ext_.Id_png));
|
||||
fxt.Test_write_all
|
||||
( "[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
@ -41,7 +41,7 @@ public class Xodb_hdump_mgr__write_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Audio_thumb() {
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer(0, 220, -1, "A.oga", ""));
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer("A.oga", 0, 220, -1, Bool_.N, Xof_ext_.Id_oga));
|
||||
fxt.Test_write_all
|
||||
( "[[File:A.oga|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
@ -56,7 +56,7 @@ public class Xodb_hdump_mgr__write_tst {
|
||||
));
|
||||
}
|
||||
@Test public void Video_thumb() {
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer(0, 0, 0, "A.ogv", ""));
|
||||
fxt.Expd_itms_xfers(fxt.Make_xfer("A.ogv", 0, 0, 0, Bool_.N, Xof_ext_.Id_ogv));
|
||||
fxt.Test_write_all
|
||||
( "[[File:A.ogv|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
@ -82,6 +82,7 @@ public class Xodb_hdump_mgr__write_tst {
|
||||
fxt.Test_write_frag("<hiero>A1</hiero>", "src='~{xowa_hiero_dir}hiero_A1.png'");
|
||||
}
|
||||
@Test public void Gallery() {
|
||||
Gallery_mgr_base.File_found_mode = Bool_.__byte;
|
||||
fxt.Test_write_all
|
||||
( "<gallery>File:A.png|A1</gallery>", String_.Concat_lines_nl_skip_last
|
||||
( "<ul id=\"xowa_gallery_ul_0\" class=\"gallery mw-gallery-traditional\" xowa_gly_box_max='0'>"
|
||||
@ -115,16 +116,18 @@ class Xodb_hdump_mgr__base_fxt {
|
||||
this.Clear_end();
|
||||
}
|
||||
@gplx.Virtual public void Clear_end() {}
|
||||
public void Exec_write(String raw) {
|
||||
@gplx.Virtual public void Exec_write(String raw) {
|
||||
Xop_root_tkn root = fxt.Exec_parse_page_all_as_root(Bry_.new_utf8_(raw));
|
||||
page.Root_(root);
|
||||
hdump_mgr.Write(bfr, page);
|
||||
}
|
||||
public Hdump_data_img__base Make_xfer(String lnki_ttl, int html_uid, int html_w, int html_h, boolean file_is_orig, int file_ext_id) {
|
||||
return new Hdump_data_img__basic().Init_by_base(Bry_.new_utf8_(lnki_ttl), html_uid, html_w, html_h, Hdump_data_img__base.File_repo_id_null, file_ext_id, file_is_orig, html_w, Xof_doc_thumb.Null, Xof_doc_page.Null);
|
||||
}
|
||||
}
|
||||
class Xodb_hdump_mgr__write_fxt extends Xodb_hdump_mgr__base_fxt {
|
||||
private ListAdp expd_itms_xfers = ListAdp_.new_();
|
||||
@Override public void Clear_end() {expd_itms_xfers.Clear();}
|
||||
public Hdump_data_img__base Make_xfer(int uid, int img_w, int img_h, String lnki_ttl, String img_src) {return new Hdump_data_img__basic().Init_by_base(uid, img_w, img_h, Bry_.new_utf8_(lnki_ttl), Bry_.new_utf8_(img_src));}
|
||||
public void Expd_itms_xfers(Hdump_data_img__base... itms) {expd_itms_xfers.AddMany((Object[])itms);}
|
||||
public void Test_write_all (String raw, String expd_html) {Test_write(Bool_.N, raw, expd_html);}
|
||||
public void Test_write_frag(String raw, String expd_frag) {Test_write(Bool_.Y, raw, expd_frag);}
|
||||
|
@ -18,38 +18,60 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.xowa.hdumps.dbs.*;
|
||||
public abstract class Hdump_data_img__base implements Hdump_data_itm {
|
||||
public Hdump_data_img__base Init_by_base(int uid, int view_w, int view_h, byte[] lnki_ttl, byte[] view_src) {
|
||||
this.uid = uid;
|
||||
this.view_w = view_w;
|
||||
this.view_h = view_h;
|
||||
public Hdump_data_img__base Init_by_base(byte[] lnki_ttl, int html_uid, int html_w, int html_h, int file_repo_id, int file_ext_id, boolean file_is_orig, int file_w, double file_time, int file_page) {
|
||||
this.lnki_ttl = lnki_ttl;
|
||||
this.view_src = view_src;
|
||||
this.html_uid = html_uid;
|
||||
this.html_w = html_w;
|
||||
this.html_h = html_h;
|
||||
this.file_repo_id = file_repo_id;
|
||||
this.file_ext_id = file_ext_id;
|
||||
this.file_is_orig = file_is_orig;
|
||||
this.file_w = file_w;
|
||||
this.file_time = file_time;
|
||||
this.file_page = file_page;
|
||||
return this;
|
||||
}
|
||||
public int Data_tid() {return Hdump_data_tid.Tid_img;}
|
||||
public abstract int Img_tid();
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public int View_w() {return view_w;} private int view_w;
|
||||
public int View_h() {return view_h;} private int view_h;
|
||||
public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
|
||||
public byte[] View_src() {return view_src;} private byte[] view_src;
|
||||
public int Html_uid() {return html_uid;} private int html_uid;
|
||||
public int Html_w() {return html_w;} private int html_w;
|
||||
public int Html_h() {return html_h;} private int html_h;
|
||||
public int File_repo_id() {return file_repo_id;} private int file_repo_id;
|
||||
public int File_ext_id() {return file_ext_id;} private int file_ext_id;
|
||||
public boolean File_is_orig() {return file_is_orig;} private boolean file_is_orig;
|
||||
public int File_w() {return file_w;} private int file_w;
|
||||
public double File_time() {return file_time;} private double file_time;
|
||||
public int File_page() {return file_page;} private int file_page;
|
||||
public Io_url File_url() {return file_url;} public void File_url_(Io_url v) {file_url = v;} private Io_url file_url;
|
||||
public String Data_print() {
|
||||
return String_.Concat_with_str("|", Int_.Xto_str(this.Img_tid()), Int_.Xto_str(uid), Int_.Xto_str(view_w), Int_.Xto_str(view_h), String_.new_utf8_(lnki_ttl), String_.new_utf8_(view_src));
|
||||
return String_.Concat_with_str("|", Int_.Xto_str(this.Img_tid()), String_.new_utf8_(lnki_ttl), Int_.Xto_str(html_uid), Int_.Xto_str(html_w), Int_.Xto_str(html_h)
|
||||
, Int_.Xto_str(file_repo_id), Int_.Xto_str(file_ext_id), Yn.Xto_str(file_is_orig), Int_.Xto_str(file_w), Double_.Xto_str(file_time), Int_.Xto_str(file_page)
|
||||
);
|
||||
}
|
||||
public void Data_write(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(Hdump_data_tid.Tid_img).Add_byte_pipe()
|
||||
.Add_int_variable(this.Img_tid()).Add_byte_pipe()
|
||||
.Add_int_variable(uid).Add_byte_pipe()
|
||||
.Add_int_variable(view_w).Add_byte_pipe()
|
||||
.Add_int_variable(view_h).Add_byte_pipe()
|
||||
.Add(lnki_ttl).Add_byte_pipe()
|
||||
.Add(view_src).Add_byte_pipe()
|
||||
;
|
||||
Data_write_static(bfr, this.Img_tid(), lnki_ttl, html_uid, html_w, html_h, file_repo_id, file_ext_id, file_is_orig, file_w, file_time, file_page);
|
||||
Data_write_hook(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
public static void Data_write_static(Bry_bfr bfr, int img_tid, byte[] lnki_ttl, int html_uid, int html_w, int html_h, int file_repo_id, int file_ext_id, boolean file_is_orig, int file_w, double file_time, int file_page) {
|
||||
bfr .Add_int_variable(Hdump_data_tid.Tid_img).Add_byte_pipe()
|
||||
.Add_int_variable(img_tid).Add_byte_pipe()
|
||||
.Add(lnki_ttl).Add_byte_pipe()
|
||||
.Add_int_variable(html_uid).Add_byte_pipe()
|
||||
.Add_int_variable(html_w).Add_byte_pipe()
|
||||
.Add_int_variable(html_h).Add_byte_pipe()
|
||||
.Add_int_variable(file_repo_id).Add_byte_pipe()
|
||||
.Add_int_variable(file_ext_id).Add_byte_pipe()
|
||||
.Add_yn(file_is_orig).Add_byte_pipe()
|
||||
.Add_int_variable(file_w).Add_byte_pipe()
|
||||
.Add_double(file_time).Add_byte_pipe()
|
||||
.Add_int_variable(file_page).Add_byte_pipe()
|
||||
;
|
||||
}
|
||||
@gplx.Virtual public void Data_write_hook(Bry_bfr bfr) {}
|
||||
public static final Hdump_data_img__base[] Ary_empty = new Hdump_data_img__base[0];
|
||||
public static final int Tid_basic = 0, Tid_gallery = 1;
|
||||
@Override public String toString() {return this.Data_print();} // TEST
|
||||
public static final int File_repo_id_commons = Xof_repo_itm.Repo_remote, File_repo_id_local = Xof_repo_itm.Repo_local, File_repo_id_null = Xof_repo_itm.Repo_null;
|
||||
}
|
||||
|
104
400_xowa/src/gplx/xowa/hdumps/core/Hdump_img_bldr.java
Normal file
104
400_xowa/src/gplx/xowa/hdumps/core/Hdump_img_bldr.java
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.dbs.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.oimgs.*;
|
||||
class Hdump_img_bldr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
private Hdump_text_tbl text_tbl = new Hdump_text_tbl();
|
||||
public Hdump_img_bldr_cmd(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Cmd_key() {return Key_const;} public static final String Key_const = "hdump.make.imgs";
|
||||
public void Cmd_ini(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_run() {Exec_main();}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_print() {}
|
||||
private void Exec_main() {
|
||||
Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_mb);
|
||||
Db_provider provider = Xodb_db_file.init__file_make(wiki.Fsys_mgr().Root_dir()).Provider();
|
||||
Db_stmt stmt = Db_stmt_.new_select_as_rdr(provider, Sql_select);
|
||||
Db_rdr rdr = stmt.Exec_select_as_rdr();
|
||||
int cur_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_page_id = rdr.Read_int(1);
|
||||
if (lnki_page_id != cur_page_id) {
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());
|
||||
cur_page_id = lnki_page_id;
|
||||
}
|
||||
int html_uid = rdr.Read_int(2);
|
||||
byte[] lnki_ttl = rdr.Read_bry(3);
|
||||
int html_w = rdr.Read_int(4);
|
||||
int html_h = rdr.Read_int(5);
|
||||
int file_repo_id = rdr.Read_int(6);
|
||||
int file_ext_id = rdr.Read_int(7);
|
||||
boolean file_is_orig = rdr.Read_int(8) == 1;
|
||||
double file_time = rdr.Read_double(9);
|
||||
int file_page = rdr.Read_int(10);
|
||||
Hdump_data_img__base.Data_write_static(bfr, 0, lnki_ttl, html_uid, html_w, html_h, file_repo_id, file_ext_id, file_is_orig, html_w, file_time, file_page);
|
||||
}
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());;
|
||||
}
|
||||
private void Save(int page_id, byte[] data) {
|
||||
if (page_id == -1 || data.length == 0) return;
|
||||
text_tbl.Insert(page_id, Hdump_data_tid.Tid_img, data);
|
||||
}
|
||||
private static final String Sql_select = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT lt.lnki_page_id"
|
||||
, ", lt.html_uid"
|
||||
, ", lt.lnki_ttl"
|
||||
, ", xr.file_w"
|
||||
, ", xr.file_h"
|
||||
, ", xr.orig_repo"
|
||||
, ", xr.lnki_ext"
|
||||
, ", xr.file_is_orig"
|
||||
, ", xr.lnki_time"
|
||||
, ", xr.lnki_page"
|
||||
, "FROM xfer_regy xr"
|
||||
, " JOIN lnki_temp lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
// , " LEFT JOIN xtn_gallery lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
// , " LEFT JOIN xtn_imap lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
, "ORDER BY "
|
||||
, " lt.lnki_page_id"
|
||||
, ", lt.lnki_uid"
|
||||
);
|
||||
}
|
||||
interface Page_async_cmd {
|
||||
void Prep();
|
||||
void Exec();
|
||||
}
|
||||
class Page_async_cmd__img implements Page_async_cmd {
|
||||
private Hdump_page hpg;
|
||||
private ListAdp missing = ListAdp_.new_();
|
||||
public Page_async_cmd__img(Hdump_page hpg) {this.hpg = hpg;}
|
||||
public void Prep() {
|
||||
int len = hpg.Img_count();
|
||||
Hdump_data_img__base[] ary = hpg.Img_itms();
|
||||
missing.Clear();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Hdump_data_img__base itm = ary[i];
|
||||
boolean exists = Io_mgr._.ExistsFil(itm.File_url());
|
||||
if (!exists) missing.Add(itm);
|
||||
}
|
||||
}
|
||||
public void Exec() {
|
||||
int len = missing.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
// Hdump_data_img__base itm = (Hdump_data_img__base)missing.FetchAt(i);
|
||||
// byte[] bytes = null; //fsdb.Db_get()ttl, file_w,....):
|
||||
// Write file(bytes);
|
||||
}
|
||||
}
|
||||
}
|
219
400_xowa/src/gplx/xowa/hdumps/core/Xob_lnki_regy_mgr.java
Normal file
219
400_xowa/src/gplx/xowa/hdumps/core/Xob_lnki_regy_mgr.java
Normal file
@ -0,0 +1,219 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.oimgs.*;
|
||||
class Redlink_regy_mgr {
|
||||
private final OrderedHash hash = OrderedHash_.new_bry_(); private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private Rl_dump_tbl dump_tbl = new Rl_dump_tbl(); private Db_stmt dump_insert;
|
||||
private int itm_count, itm_max = 10000000;
|
||||
public void Init_by_wiki(Xodb_db_file make) {
|
||||
dump_insert = dump_tbl.Insert_stmt(make.Provider());
|
||||
}
|
||||
public void Page_bgn(int page_id) {this.page_id = page_id;} private int page_id;
|
||||
public void Add(int uid, int ns_id, byte[] ttl) {
|
||||
Redlink_regy_itm regy_itm = Get_or_new(ns_id, ttl);
|
||||
regy_itm.Pages().Add(new Redlink_page_itm(page_id, uid));
|
||||
if (++itm_count > itm_max)
|
||||
Save();
|
||||
}
|
||||
private Redlink_regy_itm Get_or_new(int ns_id, byte[] ttl) {
|
||||
byte[] hash_key = tmp_bfr.Add_int_variable(ns_id).Add_byte_pipe().Add(ttl).XtoAryAndClear();
|
||||
Redlink_regy_itm rv = (Redlink_regy_itm)hash.Fetch(hash_key);
|
||||
if (rv == null) {
|
||||
rv = new Redlink_regy_itm(hash_key, ns_id, ttl);
|
||||
hash.Add(hash_key, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public void Save() {
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Redlink_regy_itm itm = (Redlink_regy_itm)hash.FetchAt(i);
|
||||
dump_tbl.Insert(dump_insert, itm.Ns_id(), itm.Ttl(), itm.Pages_to_bry(tmp_bfr));
|
||||
}
|
||||
}
|
||||
}
|
||||
class Redlink_regy_itm {
|
||||
public Redlink_regy_itm(byte[] key, int ns_id, byte[] ttl) {this.key = key; this.ns_id = ns_id; this.ttl = ttl;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public int Ns_id() {return ns_id;} private final int ns_id;
|
||||
public byte[] Ttl() {return ttl;} private final byte[] ttl;
|
||||
public ListAdp Pages() {return pages;} private final ListAdp pages = ListAdp_.new_();
|
||||
public byte[] Pages_to_bry(Bry_bfr bfr) {
|
||||
int len = pages.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Redlink_page_itm page_itm = (Redlink_page_itm)pages.FetchAt(i);
|
||||
page_itm.Write_to_bfr(bfr);
|
||||
}
|
||||
return bfr.XtoAryAndClear();
|
||||
}
|
||||
}
|
||||
class Redlink_page_itm {
|
||||
public Redlink_page_itm(int page_id, int lnki_uid) {this.page_id = page_id; this.lnki_uid = lnki_uid;}
|
||||
public int Page_id() {return page_id;} private final int page_id;
|
||||
public int Lnki_uid() {return lnki_uid;} private final int lnki_uid;
|
||||
public void Write_to_bfr(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(page_id).Add_byte_comma()
|
||||
.Add_int_variable(lnki_uid).Add_byte_semic()
|
||||
;
|
||||
}
|
||||
}
|
||||
class Redlink_wkr {
|
||||
public void Bld() {
|
||||
Bry_bfr bfr = Bry_bfr.reset_(Io_mgr.Len_mb);
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
int cur_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_page_id = rdr.Read_int(1);
|
||||
if (lnki_page_id != cur_page_id) {
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());
|
||||
cur_page_id = lnki_page_id;
|
||||
}
|
||||
int html_uid = rdr.Read_int(2);
|
||||
bfr.Add_int_variable(html_uid).Add_byte_pipe();
|
||||
}
|
||||
Save(cur_page_id, bfr.XtoAryAndClear());;
|
||||
}
|
||||
private void Save(int page_id, byte[] data) {
|
||||
if (page_id == -1 || data.length == 0) return;
|
||||
}
|
||||
public void Gen() {
|
||||
Bry_rdr bry_rdr = new Bry_rdr();
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
Db_stmt stmt = Db_stmt_.Null;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_id = rdr.Read_int(1);
|
||||
int lnki_page_id = rdr.Read_int(2);
|
||||
byte[] page_ids = rdr.Read_bry(3);
|
||||
Save_rl_html(stmt, lnki_id, lnki_page_id, bry_rdr.Src_(page_ids));
|
||||
}
|
||||
}
|
||||
private void Save_rl_html(Db_stmt stmt, int lnki_id, int lnki_page_id, Bry_rdr rdr) {
|
||||
while (!rdr.Pos_is_eos()) {
|
||||
int page_id = rdr.Read_int_to_comma();
|
||||
int html_uid = rdr.Read_int_to_semic();
|
||||
stmt.Val_int_(page_id).Val_int_(html_uid).Val_int_(lnki_id).Exec_insert();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
CREATE TABLE xtn_gallery
|
||||
( page_id integer NOT NULL
|
||||
, html_uid integer NOT NULL
|
||||
, box_max integer NOT NULL
|
||||
, box_w integer NOT NULL
|
||||
, img_w integer NOT NULL
|
||||
, img_pad integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE rl_dump
|
||||
( lnki_ns int NOT NULL
|
||||
, lnki_ttl varchar(255) NOT NULL
|
||||
, page_ids varchar(max) NOT NULL --pair of page_id,html_uid; 0,1;5,2
|
||||
);
|
||||
|
||||
CREATE TABLE rl_regy
|
||||
( lnki_id integer NOT NULL PRIMARY KEY AUTOINCREMENT
|
||||
, lnki_ns integer NOT NULL
|
||||
, lnki_ttl varchar(255) NOT NULL
|
||||
, page_id integer NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO rl_regy (lnki_ns, lnki_ttl)
|
||||
SELECT lnki_ns, lnki_ttl
|
||||
FROM rl_dump
|
||||
GROUP BY lnki_ns, lnki_ttl
|
||||
;
|
||||
|
||||
CREATE UNIQUE INDEX rl_regy__lnki_ns_ttl ON rl_regy (lnki_ns, lnki_ttl);
|
||||
|
||||
REPLACE INTO rl_regy
|
||||
SELECT r.lnki_id
|
||||
, r.lnki_ns
|
||||
, r.lnki_ttl
|
||||
, Coalesce(p.page_id, -1)
|
||||
FROM rl_regy r
|
||||
LEFT JOIN page_db.page p ON r.lnki_ns = p.page_namespace AND r.lnki_ttl = p.page_title
|
||||
;
|
||||
|
||||
--CREATE UNIQUE INDEX rl_regy__lnki_ns_ttl ON rl_regy (lnki_ns, lnki_ttl);
|
||||
|
||||
SELECT r.lnki_ns
|
||||
, r.lnki_ttl
|
||||
, r.page_id
|
||||
, r.lnki_id
|
||||
, d.page_ids
|
||||
FROM rl_dump d
|
||||
JOIN rl_regy r ON d.lnki_ns = r.lnki_ns AND d.lnki_ttl = r.lnki_ttl
|
||||
WHERE r.page_id = -1
|
||||
ORDER BY r.lnki_id
|
||||
;
|
||||
|
||||
CREATE TABLE rl_html
|
||||
( page_id integer NOT NULL
|
||||
, html_uid integer NOT NULL
|
||||
, lnki_id integer NOT NULL
|
||||
, lnki_page_id integer NOT NULL
|
||||
)
|
||||
|
||||
SELECT page_id
|
||||
, html_uid
|
||||
, lnki_id
|
||||
, lnki_page_id
|
||||
WHERE lnki_page_id = -1
|
||||
ORDER BY page_id, html_uid
|
||||
;
|
||||
*/
|
||||
class Rl_dump_tbl {
|
||||
public Db_stmt Insert_stmt(Db_provider provider) {return Db_stmt_.new_insert_(provider, Tbl_name, Fld_lnki_ns, Fld_lnki_ttl, Fld_page_ids);}
|
||||
public void Insert(Db_stmt stmt, int lnki_ns, byte[] lnki_ttl, byte[] page_ids) {
|
||||
stmt.Val_int_(lnki_ns).Val_str_by_bry_(lnki_ttl).Val_bry_(page_ids).Exec_insert();
|
||||
}
|
||||
public static final String Tbl_name = "rl_dump", Fld_lnki_ns = "lnki_ns", Fld_lnki_ttl = "lnki_ttl", Fld_page_ids = "page_ids";
|
||||
public static final String Tbl_sql = String_.Concat_lines_crlf_skipLast
|
||||
( "CREATE TABLE rl_dump"
|
||||
, "( lnki_ns integer NOT NULL"
|
||||
, ", lnki_ttl varchar(255) NOT NULL"
|
||||
, ", page_ids mediumblob NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
public static final Db_idx_itm
|
||||
Idx_lnki_ns_ttl = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS rl_dump__lnki_ns_ttl ON rl_dump (lnki_ns, lnki_ttl);")
|
||||
;
|
||||
}
|
||||
class Rl_html_tbl {
|
||||
public static final String Tbl_name = "rl_html", Fld_page_id = "page_id", Fld_html_uid = "html_uid", Fld_lnki_id = "lnki_id", Fld_lnki_page_id = "lnki_page_id";
|
||||
// CREATE TABLE rl_html
|
||||
// ( page_id integer NOT NULL
|
||||
// , html_uid integer NOT NULL
|
||||
// , lnki_id integer NOT NULL
|
||||
// , lnki_page_id integer NOT NULL
|
||||
// )
|
||||
public static final String Tbl_sql = String_.Concat_lines_crlf_skipLast
|
||||
( "CREATE TABLE rl_html"
|
||||
, "( page_id integer NOT NULL"
|
||||
, ", html_uid integer NOT NULL"
|
||||
, ", lnki_id integer NOT NULL"
|
||||
, ", lnki_page_id integer NOT NULL"
|
||||
, ");"
|
||||
);
|
||||
public static final Db_idx_itm
|
||||
Idx_lnki_ns_ttl = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS rl_dump__lnki_ns_ttl ON rl_dump (lnki_ns, lnki_ttl);")
|
||||
;
|
||||
}
|
32
400_xowa/src/gplx/xowa/hdumps/core/Xopg_redlink_mgr.java
Normal file
32
400_xowa/src/gplx/xowa/hdumps/core/Xopg_redlink_mgr.java
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
public class Xopg_redlink_mgr {
|
||||
private final Int_list list = new Int_list();
|
||||
public int Len() {return list.Len();}
|
||||
public int Max() {return max;} private int max;
|
||||
public int Get_at(int i) {return list.Get_at(i);}
|
||||
public void Clear() {
|
||||
list.Clear();
|
||||
max = 0;
|
||||
}
|
||||
public void Add(int i) {
|
||||
list.Add(i);
|
||||
if (i > max) max = i;
|
||||
}
|
||||
}
|
@ -16,10 +16,12 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.ios.*; import gplx.dbs.*; import gplx.xowa.dbs.*;
|
||||
public class Hdump_text_tbl {
|
||||
public static final String Tbl_name = "html_text", Fld_page_id = "page_id", Fld_text_tid = "text_tid", Fld_text_data = "text_data";
|
||||
private Xodb_mgr db_mgr; private Io_stream_zip_mgr zip_mgr;
|
||||
private Db_stmt stmt_select, stmt_insert, stmt_delete;
|
||||
public void Init_by_wiki(Xow_wiki wiki) {this.db_mgr = wiki.Db_mgr(); this.zip_mgr = wiki.App().Zip_mgr();}
|
||||
public Db_provider Provider() {return provider;} public Hdump_text_tbl Provider_(Db_provider v) {this.Rls_all(); provider = v; return this;} private Db_provider provider;
|
||||
@gplx.Virtual public void Delete_by_page(int page_id) {
|
||||
if (stmt_delete == null) stmt_delete = Db_stmt_.new_delete_(provider, Tbl_name, Fld_page_id);
|
||||
@ -28,44 +30,30 @@ public class Hdump_text_tbl {
|
||||
}
|
||||
@gplx.Virtual public void Insert(int page_id, int tid, byte[] data) {
|
||||
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all);
|
||||
if (zip_mgr != null) data = zip_mgr.Zip(db_mgr.Data_storage_format(), data);
|
||||
try {stmt_insert.Clear().Val_int_(page_id).Val_int_(tid).Val_str_by_bry_(data).Exec_insert();}
|
||||
catch (Exception exc) {stmt_insert = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
|
||||
}
|
||||
private static final String[] Select_by_page_flds = new String[] {Fld_page_id, Fld_text_tid, Fld_text_data};
|
||||
@gplx.Virtual public void Select_by_page(ListAdp rv, int page_id) {
|
||||
if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_page_id), Flds_all);
|
||||
if (stmt_select == null) stmt_select = Db_stmt_.new_select_as_rdr(provider, Db_qry__select_in_tbl.new_(Tbl_name, String_.Ary(Fld_page_id), Select_by_page_flds));
|
||||
try {
|
||||
DataRdr rdr = stmt_select.Clear().Val_int_(page_id).Exec_select();
|
||||
while(rdr.MoveNextPeer()) {
|
||||
Db_rdr rdr = stmt_select.Clear().Val_int_(page_id).Exec_select_as_rdr();
|
||||
while(rdr.Move_next()) {
|
||||
byte[] data = rdr.Read_bry(2);
|
||||
if (zip_mgr != null) data = zip_mgr.Unzip(db_mgr.Data_storage_format(), data);
|
||||
Hdump_text_row row = new Hdump_text_row
|
||||
( rdr.ReadInt(Fld_page_id)
|
||||
, rdr.ReadInt(Fld_text_tid)
|
||||
, rdr.ReadBryByStr(Fld_text_data)
|
||||
( rdr.Read_int(0)
|
||||
, rdr.Read_int(1)
|
||||
, data
|
||||
);
|
||||
rv.Add(row);
|
||||
}
|
||||
rdr.Rls();
|
||||
rdr.Close();
|
||||
}
|
||||
catch (Exception exc) {stmt_select = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
|
||||
finally {stmt_select.Rls();}
|
||||
}
|
||||
// private static final String[] Select_by_page_flds = new String[] {Fld_page_id, Fld_text_tid, Fld_text_data};
|
||||
// public virtual void Select_by_page2(ListAdp rv, int page_id) {
|
||||
// // if (stmt_select == null) stmt_select = provider.Stmt_select(Tbl_name, Select_by_page_flds, String_.Ary(Fld_page_id));
|
||||
// try {
|
||||
// Db_rdr rdr = null; //stmt_select.Clear().Val_int_(page_id).Exec_select_as_rdr();
|
||||
// while(rdr.Move_next()) {
|
||||
// Hdump_text_row row = new Hdump_text_row
|
||||
// ( rdr.Read_int(0)
|
||||
// , rdr.Read_int(1)
|
||||
// , rdr.Read_bry_by_str(2)
|
||||
// );
|
||||
// rv.Add(row);
|
||||
// }
|
||||
// rdr.Close();
|
||||
// }
|
||||
// catch (Exception exc) {stmt_select = null; throw Err_.err_(exc, "stmt failed");} // must reset stmt, else next call will fail
|
||||
// finally {stmt_select.Rls();}
|
||||
// }
|
||||
public void Rls_all() {
|
||||
if (stmt_select != null) {stmt_select.Rls(); stmt_select = null;}
|
||||
if (stmt_insert != null) {stmt_insert.Rls(); stmt_insert = null;}
|
||||
|
@ -16,22 +16,33 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.html.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
|
||||
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.html.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.apps.fsys.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.xtns.gallery.*;
|
||||
public class Hdump_html_body implements Bry_fmtr_arg {
|
||||
private Bry_rdr bry_rdr = new Bry_rdr();
|
||||
private Xow_wiki wiki; private Hdump_page page;
|
||||
private Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_();
|
||||
private Xow_wiki wiki; private Hdump_page hpg;
|
||||
private byte[] root_remote, root_local;
|
||||
private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_._; private byte[] root_dir, file_dir, hiero_img_dir; private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private Xoh_cfg_file cfg_file;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
this.usr_dlg = app.Usr_dlg();
|
||||
this.root_dir = app.Fsys_mgr().Root_dir().To_http_file_bry();
|
||||
this.file_dir = app.Fsys_mgr().File_dir().To_http_file_bry();
|
||||
this.hiero_img_dir = gplx.xowa.xtns.hieros.Hiero_xtn_mgr.Hiero_root_dir(app).GenSubDir("img").To_http_file_bry();
|
||||
cfg_file = new Xoh_cfg_file(app.Encoder_mgr().Fsys(), app.Fsys_mgr().Bin_xowa_dir());
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki, Hdump_page hpg) {
|
||||
this.wiki = wiki; this.hpg = hpg;
|
||||
root_remote = tmp_bfr.Add(file_dir).Add(Xow_wiki_.Domain_commons_bry).Add_byte_slash().XtoAryAndClear();
|
||||
root_local = tmp_bfr.Add(file_dir).Add(wiki.Domain_bry()).Add_byte_slash().XtoAryAndClear();
|
||||
}
|
||||
public void Init_by_drd(Url_encoder fsys_encoder, Xoa_fsys_mgr fsys_mgr) {
|
||||
cfg_file = new Xoh_cfg_file(fsys_encoder, fsys_mgr.Bin_xowa_dir());
|
||||
}
|
||||
public void Init_by_page(Xow_wiki wiki, Hdump_page page) {this.wiki = wiki; this.page = page;}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
byte[] src = page.Page_body(); int len = src.length;
|
||||
Hdump_data_img__base[] imgs = page.Img_itms(); int imgs_len = page.Img_itms().length;
|
||||
byte[] src = hpg.Page_body(); int len = src.length;
|
||||
Hdump_data_img__base[] imgs = hpg.Img_itms(); int imgs_len = hpg.Img_itms().length;
|
||||
bry_rdr.Src_(src);
|
||||
int pos = 0; int rng_bgn = -1;
|
||||
Xow_html_mgr html_mgr = wiki.Html_mgr();
|
||||
@ -50,12 +61,21 @@ public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
|
||||
}
|
||||
pos = trie.Match_pos(); // position after match; EX: "xowa_img='" positions after "'"
|
||||
Hdump_html_fmtr_itm itm = (Hdump_html_fmtr_itm)o;
|
||||
pos = Write_data(bfr, html_mgr, html_fmtr, page, src, imgs, imgs_len, pos, itm); // note no +1; Write_data return pos after }
|
||||
pos = Write_data(bfr, html_fmtr, hpg, src, imgs, imgs_len, pos, itm); // note no +1; Write_data return pos after }
|
||||
}
|
||||
}
|
||||
if (rng_bgn != -1) bfr.Add_mid(src, rng_bgn, len);
|
||||
}
|
||||
private int Write_data(Bry_bfr bfr, Xow_html_mgr html_mgr, Xoh_file_html_fmtr__base fmtr, Hdump_page hpg, byte[] src, Hdump_data_img__base[] imgs, int imgs_len, int uid_bgn, Hdump_html_fmtr_itm itm) {
|
||||
private int Write_redlink(Bry_bfr bfr, Hdump_page hpg, int uid, int rv) {
|
||||
int[] redlink_uids = hpg.Redlink_uids(); if (redlink_uids == null) return rv;
|
||||
int redlink_uid_max = redlink_uids.length;
|
||||
if (uid < redlink_uid_max && redlink_uids[uid] == 1)
|
||||
bfr.Add(Redlink_cls_new);
|
||||
else
|
||||
bfr.Del_by_1();
|
||||
return rv;
|
||||
} private static final byte[] Redlink_cls_new = Bry_.new_ascii_("class='new'");
|
||||
private int Write_data(Bry_bfr bfr, Xoh_file_html_fmtr__base fmtr, Hdump_page hpg, byte[] src, Hdump_data_img__base[] imgs, int imgs_len, int uid_bgn, Hdump_html_fmtr_itm itm) {
|
||||
bry_rdr.Pos_(uid_bgn);
|
||||
int uid = itm.Subst_end_byte() == Byte_ascii.Nil ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
|
||||
int uid_end = bry_rdr.Pos(); // set uid_end after subst_end
|
||||
@ -64,12 +84,14 @@ public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
|
||||
switch (tid) {
|
||||
case Hdump_html_consts.Tid_dir: bfr.Add(root_dir); return rv;
|
||||
case Hdump_html_consts.Tid_hiero_dir: bfr.Add(hiero_img_dir); return rv;
|
||||
case Hdump_html_consts.Tid_redlink: return Write_redlink(bfr, hpg, uid, rv);
|
||||
}
|
||||
if (itm.Elem_is_xnde()) rv += 2; // if xnde, skip "/>"
|
||||
if (uid == bry_rdr.Or_int()) {usr_dlg.Warn_many("", "", "index is not a valid int; page=~{0} text=~{1}", hpg.Page_url().Xto_full_str_safe(), Bry_.Mid_safe(src, uid_bgn, uid_end)); return uid_end;}
|
||||
if (!Int_.Between(uid, 0, imgs_len)) {usr_dlg.Warn_many("", "", "index is out of range; page=~{0} idx=~{1} len=~{2}", hpg.Page_url().Xto_full_str_safe(), uid, imgs_len); return uid_end;}
|
||||
if (uid == bry_rdr.Or_int()) {usr_dlg.Warn_many("", "", "index is not a valid int; hpg=~{0} text=~{1}", hpg.Page_url().Xto_full_str_safe(), Bry_.Mid_safe(src, uid_bgn, uid_end)); return uid_end;}
|
||||
if (!Int_.Between(uid, 0, imgs_len)) {usr_dlg.Warn_many("", "", "index is out of range; hpg=~{0} idx=~{1} len=~{2}", hpg.Page_url().Xto_full_str_safe(), uid, imgs_len); return uid_end;}
|
||||
if (uid >= imgs.length) return rv;
|
||||
Hdump_data_img__base img = imgs[uid];
|
||||
int img_view_w = img.View_w();
|
||||
int img_view_w = img.Html_w();
|
||||
switch (tid) {
|
||||
case Hdump_html_consts.Tid_img_style:
|
||||
bfr.Add(Hdump_html_consts.Bry_img_style_bgn);
|
||||
@ -80,9 +102,9 @@ public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
|
||||
byte[] a_title = img.Lnki_ttl();
|
||||
byte[] a_href = Bry_.Add(Hdump_html_consts.A_href_bgn, a_title);
|
||||
switch (tid) {
|
||||
case Hdump_html_consts.Tid_file_info: fmtr.Html_thumb_part_info (bfr, uid, a_href, html_mgr.Img_media_info_btn()); return rv;
|
||||
case Hdump_html_consts.Tid_file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, html_mgr.Img_thumb_magnify()); return rv;
|
||||
case Hdump_html_consts.Tid_file_play: fmtr.Html_thumb_part_play (bfr, uid, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, html_mgr.Img_media_play_btn()); return rv;
|
||||
case Hdump_html_consts.Tid_file_info: fmtr.Html_thumb_part_info (bfr, uid, a_href, cfg_file.Img_media_info_btn()); return rv;
|
||||
case Hdump_html_consts.Tid_file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, cfg_file.Img_thumb_magnify()); return rv;
|
||||
case Hdump_html_consts.Tid_file_play: fmtr.Html_thumb_part_play (bfr, uid, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, cfg_file.Img_media_play_btn()); return rv;
|
||||
case Hdump_html_consts.Tid_gallery_box_max: {
|
||||
Hdump_data_gallery gly = (Hdump_data_gallery)hpg.Gly_itms().Fetch(uid);
|
||||
if (gly != null) { // -1 means no box_max
|
||||
@ -110,9 +132,11 @@ public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
byte[] img_src = Bry_.Add(file_dir, img.View_src());
|
||||
url_bldr.Init_by_root(img.File_repo_id() == Xof_repo_itm.Repo_remote ? root_remote : root_local, Byte_ascii.Slash, false, false, 2);
|
||||
url_bldr.Init_by_itm(img.File_is_orig() ? Xof_repo_itm.Mode_orig : Xof_repo_itm.Mode_thumb, img.Lnki_ttl(), Xof_xfer_itm_.Md5_(img.Lnki_ttl()), Xof_ext_.new_by_id_(img.File_ext_id()), img.File_w(), img.File_time(), img.File_page());
|
||||
byte[] img_src = url_bldr.Xto_bry();
|
||||
if (tid == Hdump_html_consts.Tid_img) {
|
||||
fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.View_h());
|
||||
fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.Html_h());
|
||||
}
|
||||
return rv;
|
||||
}
|
@ -26,6 +26,7 @@ public class Hdump_html_consts {
|
||||
public static final byte
|
||||
Tid_dir = 1, Tid_img = 2, Tid_img_style = 3, Tid_file_play = 4, Tid_file_info = 5, Tid_file_mgnf = 6
|
||||
, Tid_hiero_dir = 7, Tid_gallery_box_max = 8, Tid_gallery_box_w = 9, Tid_gallery_img_w = 10, Tid_gallery_img_pad = 11
|
||||
, Tid_redlink = 12
|
||||
;
|
||||
public static final byte[]
|
||||
Key_dir = Bry_.new_ascii_("~{xowa_dir}")
|
||||
@ -39,6 +40,11 @@ public class Hdump_html_consts {
|
||||
, Key_gallery_box_w = Bry_.new_ascii_("xowa_gly_box_w='")
|
||||
, Key_gallery_img_w = Bry_.new_ascii_("xowa_gly_img_w='")
|
||||
, Key_gallery_img_pad = Bry_.new_ascii_("xowa_gly_img_pad='")
|
||||
, Key_redlink = Bry_.new_ascii_("xowa_redlink='")
|
||||
;
|
||||
public static final byte[]
|
||||
Html_redlink_bgn = Bry_.Add(Bry_.new_ascii_("\" "), Key_redlink)
|
||||
, Html_redlink_end = Bry_.new_ascii_("'>")
|
||||
;
|
||||
public static Btrie_slim_mgr trie_() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.cs_();
|
||||
@ -53,6 +59,7 @@ public class Hdump_html_consts {
|
||||
trie_itm(rv, Tid_gallery_box_w , Byte_ascii.Apos , Key_gallery_box_w);
|
||||
trie_itm(rv, Tid_gallery_img_w , Byte_ascii.Apos , Key_gallery_img_w);
|
||||
trie_itm(rv, Tid_gallery_img_pad , Byte_ascii.Apos , Key_gallery_img_pad);
|
||||
trie_itm(rv, Tid_redlink , Byte_ascii.Apos , Key_redlink);
|
||||
return rv;
|
||||
}
|
||||
private static void trie_itm(Btrie_slim_mgr trie, byte tid, byte subst_end_byte, byte[] key_bry) {
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.xowa.hdumps.core.*;
|
||||
public class Hdump_html_mgr {
|
||||
private Hdump_html_fmtr__body body_fmtr = new Hdump_html_fmtr__body();
|
||||
private Hdump_html_body body_fmtr = new Hdump_html_body();
|
||||
public Hdump_html_mgr Init_by_app(Xoa_app app) {body_fmtr.Init_by_app(app); return this;}
|
||||
public void Write(Bry_bfr bfr, Xow_wiki wiki, Hdump_page page) {
|
||||
body_fmtr.Init_by_page(wiki, page);
|
||||
|
@ -16,15 +16,15 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import org.junit.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*;
|
||||
import org.junit.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*; import gplx.xowa.files.*;
|
||||
public class Hdump_html_mgr_tst {
|
||||
@Before public void init() {
|
||||
fxt.Clear();
|
||||
fxt.Init_data_img_basic(0, 220, 110, "A.png", "commons.wikimedia.org/thumb/7/0/A.png/220.png");
|
||||
fxt.Init_data_img_basic("A.png", 0, 220, 110);
|
||||
} private Hdump_html_mgr_fxt fxt = new Hdump_html_mgr_fxt();
|
||||
@Test public void Img() {
|
||||
fxt .Init_body("<img xowa_img='0' />")
|
||||
.Test_html("<img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220.png' width='220' height='110' />");
|
||||
.Test_html("<img src='file:///mem/xowa/file/commons.wikimedia.org/thumb/7/0/A.png/220px.png' width='220' height='110' />");
|
||||
}
|
||||
@Test public void Img_style() {
|
||||
fxt .Init_body("<div xowa_img_style='0'>")
|
||||
@ -36,7 +36,7 @@ public class Hdump_html_mgr_tst {
|
||||
( ""
|
||||
, " <div>"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"image\" title=\"About this file\">"
|
||||
, " <img src=\"file:///mem/xowa/user/test_user/app/img/file/info.png\" width=\"22\" height=\"22\" />"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mw.file/info.png\" width=\"22\" height=\"22\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
));
|
||||
@ -47,7 +47,7 @@ public class Hdump_html_mgr_tst {
|
||||
( ""
|
||||
, " <div class=\"magnify\">"
|
||||
, " <a href=\"/wiki/File:A.png\" class=\"internal\" title=\"A.png\">"
|
||||
, " <img src=\"file:///mem/xowa/user/test_user/app/img/file/magnify-clip.png\" width=\"15\" height=\"11\" alt=\"\" />"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mw.file/magnify-clip.png\" width=\"15\" height=\"11\" alt=\"\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
));
|
||||
@ -58,7 +58,7 @@ public class Hdump_html_mgr_tst {
|
||||
( ""
|
||||
, " <div>"
|
||||
, " <a id=\"xowa_file_play_0\" href=\"/wiki/File:A.png\" xowa_title=\"A.png\" class=\"xowa_anchor_button\" style=\"width:220px;max-width:1024px;\">"
|
||||
, " <img src=\"file:///mem/xowa/user/test_user/app/img/file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " <img src=\"file:///mem/xowa/bin/any/xowa/file/mw.file/play.png\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
));
|
||||
@ -70,7 +70,7 @@ public class Hdump_html_mgr_tst {
|
||||
@Test public void Gallery() {
|
||||
fxt.Clear_imgs();
|
||||
fxt .Init_data_gly(0, 800);
|
||||
fxt .Init_data_img_gly(0, 220, 110, "A.png", "commons.wikimedia.org/thumb/7/0/A.png/220.png", 155, 150, 15);
|
||||
fxt .Init_data_img_gly("A.png", 0, 220, 110, 155, 150, 15);
|
||||
fxt .Init_body(String_.Concat_lines_nl_skip_last
|
||||
( "<ul xowa_gly_box_max='0'>"
|
||||
, " <li class='gallerybox' xowa_gly_box_w='0'>"
|
||||
@ -86,6 +86,19 @@ public class Hdump_html_mgr_tst {
|
||||
, " <div style=\"margin:15px auto;\">"
|
||||
));
|
||||
}
|
||||
@Test public void Redlink() {
|
||||
fxt .Init_data_redlink(2, 1, 2);
|
||||
fxt .Init_body(String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/A\" xowa_redlink='1'>A</a>"
|
||||
, "<a href=\"/wiki/B\" xowa_redlink='2'>B</a>"
|
||||
, "<a href=\"/wiki/C\" xowa_redlink='3'>C</a>"
|
||||
))
|
||||
.Test_html(String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/A\" class='new'>A</a>"
|
||||
, "<a href=\"/wiki/B\" class='new'>B</a>"
|
||||
, "<a href=\"/wiki/C\">C</a>"
|
||||
));
|
||||
}
|
||||
}
|
||||
class Hdump_html_mgr_fxt {
|
||||
private Hdump_html_mgr html_mgr;
|
||||
@ -101,8 +114,29 @@ class Hdump_html_mgr_fxt {
|
||||
public void Clear_imgs() {img_list.Clear();}
|
||||
public Hdump_html_mgr_fxt Init_body(String body) {hpg.Page_body_(Bry_.new_utf8_(body)); return this;}
|
||||
public Hdump_html_mgr_fxt Init_data_gly(int uid, int box_max) {hpg.Gly_itms().Add(uid, new Hdump_data_gallery(uid, box_max)); return this;}
|
||||
public Hdump_html_mgr_fxt Init_data_img_basic(int uid, int w, int h, String ttl, String src) {img_list.Add(new Hdump_data_img__basic().Init_by_base(uid, w, h, Bry_.new_utf8_(ttl), Bry_.new_utf8_(src))); return this;}
|
||||
public Hdump_html_mgr_fxt Init_data_img_gly(int uid, int w, int h, String ttl, String src, int box_w, int img_w, int img_pad) {img_list.Add(new Hdump_data_img__gallery().Init_by_gallery(box_w, img_w, img_pad).Init_by_base(uid, w, h, Bry_.new_utf8_(ttl), Bry_.new_utf8_(src))); return this;}
|
||||
public Hdump_html_mgr_fxt Init_data_img_basic(String ttl, int html_uid, int html_w, int html_h) {
|
||||
Hdump_data_img__basic img = new Hdump_data_img__basic();
|
||||
img.Init_by_base(Bry_.new_utf8_(ttl), html_uid, html_w, html_h, Hdump_data_img__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w, Xof_doc_thumb.Null, Xof_doc_page.Null);
|
||||
img_list.Add(img);
|
||||
return this;
|
||||
}
|
||||
public Hdump_html_mgr_fxt Init_data_img_gly(String ttl, int html_uid, int html_w, int html_h, int box_w, int img_w, int img_pad) {
|
||||
Hdump_data_img__gallery img = new Hdump_data_img__gallery();
|
||||
img.Init_by_gallery(box_w, img_w, img_pad);
|
||||
img.Init_by_base(Bry_.new_utf8_(ttl), html_uid, html_w, html_h, Hdump_data_img__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w, Xof_doc_thumb.Null, Xof_doc_page.Null);
|
||||
img_list.Add(img);
|
||||
return this;
|
||||
}
|
||||
public Hdump_html_mgr_fxt Init_data_redlink(int max, int... uids) {
|
||||
int[] ary = new int[max + ListAdp_.Base1];
|
||||
int uids_len = uids.length;
|
||||
for (int i = 0; i < uids_len; ++i) {
|
||||
int uid = uids[i];
|
||||
ary[uid] = 1;
|
||||
}
|
||||
hpg.Redlink_uids_(ary);
|
||||
return this;
|
||||
}
|
||||
public Hdump_html_mgr_fxt Test_html(String expd) {
|
||||
if (img_list.Count() > 0) hpg.Img_itms_((Hdump_data_img__base[])img_list.XtoAryAndClear(Hdump_data_img__base.class));
|
||||
html_mgr.Write(bfr, wiki, hpg);
|
||||
|
@ -55,16 +55,22 @@ public class Hdump_load_mgr {
|
||||
}
|
||||
private void Load_data_img() {
|
||||
int tid = rdr.Read_int_to_pipe();
|
||||
int uid = rdr.Read_int_to_pipe();
|
||||
int w = rdr.Read_int_to_pipe();
|
||||
int h = rdr.Read_int_to_pipe();
|
||||
byte[] ttl = rdr.Read_bry_to_pipe();
|
||||
byte[] src = rdr.Read_bry_to_pipe();
|
||||
byte[] lnki_ttl = rdr.Read_bry_to_pipe();
|
||||
int html_uid = rdr.Read_int_to_pipe();
|
||||
int html_w = rdr.Read_int_to_pipe();
|
||||
int html_h = rdr.Read_int_to_pipe();
|
||||
int file_repo_id = rdr.Read_int_to_pipe();
|
||||
int file_ext_id = rdr.Read_int_to_pipe();
|
||||
boolean file_is_orig = rdr.Read_yn_to_pipe();
|
||||
int file_w = rdr.Read_int_to_pipe();
|
||||
double file_time = rdr.Read_double_to_pipe();
|
||||
int file_page = rdr.Read_int_to_pipe();
|
||||
Hdump_data_img__base img_itm = null;
|
||||
switch (tid) {
|
||||
case Hdump_data_img__base.Tid_basic : img_itm = new Hdump_data_img__basic().Init_by_base(uid, w, h, ttl, src); break;
|
||||
case Hdump_data_img__base.Tid_gallery : img_itm = new Hdump_data_img__gallery().Init_by_gallery(rdr.Read_int_to_pipe(), rdr.Read_int_to_pipe(), rdr.Read_int_to_pipe()).Init_by_base(uid, w, h, ttl, src); break;
|
||||
case Hdump_data_img__base.Tid_basic : img_itm = new Hdump_data_img__basic(); break;
|
||||
case Hdump_data_img__base.Tid_gallery : img_itm = new Hdump_data_img__gallery().Init_by_gallery(rdr.Read_int_to_pipe(), rdr.Read_int_to_pipe(), rdr.Read_int_to_pipe()); break;
|
||||
}
|
||||
img_itm.Init_by_base(lnki_ttl, html_uid, html_w, html_h, file_repo_id, file_ext_id, file_is_orig, file_w, file_time, file_page);
|
||||
rdr.Pos_add_one();
|
||||
img_itms.Add(img_itm);
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ public class Hdump_load_mgr_tst {
|
||||
}
|
||||
@Test public void Img() {
|
||||
fxt.Init_row_img
|
||||
( fxt.Make_img(0, 220, 110, "A.png", "commons.wikimedia.org/thumb/7/0/A.png/220.png")
|
||||
, fxt.Make_img(1, 200, 100, "B.png", "commons.wikimedia.org/thumb/7/0/B.png/200.png")
|
||||
( fxt.Make_img("A.png", 0, 220, 110)
|
||||
, fxt.Make_img("B.png", 1, 200, 100)
|
||||
);
|
||||
fxt.Expd_img(0, 220, 110, "A.png", "commons.wikimedia.org/thumb/7/0/A.png/220.png");
|
||||
fxt.Expd_img(1, 200, 100, "B.png", "commons.wikimedia.org/thumb/7/0/B.png/200.png");
|
||||
fxt.Expd_img(fxt.Make_img("A.png", 0, 220, 110));
|
||||
fxt.Expd_img(fxt.Make_img("B.png", 1, 200, 100));
|
||||
fxt.Test_load(0);
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,9 @@ class Hdump_load_mgr_fxt {
|
||||
expd_imgs.Clear();
|
||||
page_url = Xoa_url.new_(Bry_.new_ascii_("enwiki"), Bry_.new_ascii_("Page_1"));
|
||||
}
|
||||
public Hdump_data_img__base Make_img(int uid, int img_w, int img_h, String lnki_ttl, String img_src_rel) {return new Hdump_data_img__basic().Init_by_base(uid, img_w, img_h, Bry_.new_utf8_(lnki_ttl), Bry_.new_utf8_(img_src_rel));}
|
||||
public Hdump_data_img__base Make_img(String lnki_ttl, int html_uid, int html_w, int html_h) {
|
||||
return new Hdump_data_img__basic().Init_by_base(Bry_.new_utf8_(lnki_ttl), html_uid, html_w, html_h, Hdump_data_img__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w, Xof_doc_thumb.Null, Xof_doc_page.Null);
|
||||
}
|
||||
public void Init_row_img(Hdump_data_img__base... itms) {
|
||||
ListAdp tmp_list = ListAdp_.new_();
|
||||
Bry_bfr bfr = Bry_bfr.new_(255);
|
||||
@ -83,7 +85,7 @@ class Hdump_load_mgr_fxt {
|
||||
public Hdump_load_mgr_fxt Expd_display_ttl(String v) {this.expd_display_ttl = v; return this;}
|
||||
public Hdump_load_mgr_fxt Expd_content_sub(String v) {this.expd_content_sub = v; return this;}
|
||||
public Hdump_load_mgr_fxt Expd_sidebar_div(String v) {this.expd_sidebar_div = v; return this;}
|
||||
public Hdump_load_mgr_fxt Expd_img(int idx, int w, int h, String ttl, String src) {expd_imgs.Add(new Hdump_data_img__basic().Init_by_base(idx, w, h, Bry_.new_utf8_(ttl), Bry_.new_utf8_(src))); return this;}
|
||||
public Hdump_load_mgr_fxt Expd_img(Hdump_data_img__base img) {expd_imgs.Add(img); return this;}
|
||||
public Hdump_load_mgr_fxt Test_load(int page_id) {
|
||||
load_mgr.Load_rows(hpg, page_id, page_url, init_rows);
|
||||
if (expd_body != null) Tfds.Eq(expd_body, String_.new_utf8_(hpg.Page_body()));
|
||||
|
@ -18,15 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.hdumps.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.files.*;
|
||||
public class Xopg_hdump_data {
|
||||
private final int file_dir_bry_len;
|
||||
public Xopg_hdump_data(Xoa_app app) {file_dir_bry_len = app.Fsys_mgr().File_dir_bry_len();}
|
||||
public Xopg_redlink_mgr Redlink_mgr() {return redlink_mgr;} private Xopg_redlink_mgr redlink_mgr = new Xopg_redlink_mgr();
|
||||
public int Data_count_imgs() {return data_count_imgs;} public void Data_count_imgs_(int v) {data_count_imgs = v;} private int data_count_imgs;
|
||||
public ListAdp Data() {return data;} private final ListAdp data = ListAdp_.new_();
|
||||
public void Data_add(Hdump_data_itm itm) {data.Add(itm);}
|
||||
public void Data_add_img(Hdump_data_img__base img, Xof_xfer_itm xfer_itm, int tid) {
|
||||
byte[] img_src = xfer_itm.Html_view_src();
|
||||
img_src = Bry_.Len_eq_0(img_src) ? Bry_.Empty : Bry_.Mid(img_src, file_dir_bry_len);
|
||||
img.Init_by_base(xfer_itm.Html_uid(), xfer_itm.Html_w(), xfer_itm.Html_h(), xfer_itm.Lnki_ttl(), img_src);
|
||||
img.Init_by_base(xfer_itm.Lnki_ttl(), xfer_itm.Html_uid(), xfer_itm.Html_w(), xfer_itm.Html_h()
|
||||
, xfer_itm.Trg_repo_idx(), xfer_itm.Lnki_ext().Id(), xfer_itm.Img_is_orig(), xfer_itm.File_w(), xfer_itm.Lnki_thumbtime(), xfer_itm.Lnki_page());
|
||||
data.Add(img);
|
||||
++data_count_imgs;
|
||||
}
|
||||
@ -35,5 +33,6 @@ public class Xopg_hdump_data {
|
||||
data_count_imgs = 0;
|
||||
data.Clear();
|
||||
body = null;
|
||||
redlink_mgr.Clear();
|
||||
}
|
||||
}
|
||||
|
@ -20,22 +20,26 @@ import gplx.dbs.*; import gplx.xowa.files.*; import gplx.xowa.hdumps.dbs.*;
|
||||
import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.pages.*; import gplx.xowa.pages.*; import gplx.xowa.pages.skins.*; import gplx.xowa.hdumps.loads.*;
|
||||
public class Hdump_save_mgr {
|
||||
private Bry_bfr tmp_bfr = Bry_bfr.reset_(10 * Io_mgr.Len_mb);
|
||||
private Hdump_text_tbl text_tbl;
|
||||
public void Tbl_(Hdump_text_tbl v) {text_tbl = v;}
|
||||
public Hdump_text_tbl Tbl() {return text_tbl;} public void Tbl_(Hdump_text_tbl v) {text_tbl = v;} private Hdump_text_tbl text_tbl;
|
||||
public void Update(Xoa_page page) {
|
||||
int page_id = page.Revision_data().Id();
|
||||
text_tbl.Delete_by_page(page_id);
|
||||
this.Insert(page);
|
||||
}
|
||||
public void Insert(Xoa_page page) {
|
||||
Hdump_page_body_srl.Save(tmp_bfr, page);
|
||||
int page_id = page.Revision_data().Id();
|
||||
text_tbl.Insert(page_id, Hdump_text_row_tid.Tid_body, tmp_bfr.XtoAryAndClear());
|
||||
byte[] redlinks_bry = Write_redlinks(tmp_bfr, page.Html_data().Redlink_mgr());
|
||||
Insert_body(page, page_id);
|
||||
byte[] redlinks_bry = Write_redlinks(tmp_bfr, page.Hdump_data().Redlink_mgr());
|
||||
if (redlinks_bry != null) text_tbl.Insert(page_id, Hdump_data_tid.Tid_redlink, redlinks_bry);
|
||||
byte[] imgs_bry = Write_imgs(tmp_bfr, page.Hdump_data().Data());
|
||||
if (imgs_bry != null) text_tbl.Insert(page_id, Hdump_data_tid.Tid_img, imgs_bry);
|
||||
}
|
||||
public int Insert_body(Xoa_page page, int page_id) {
|
||||
Hdump_page_body_srl.Save(tmp_bfr, page);
|
||||
byte[] body_bry = tmp_bfr.XtoAryAndClear();
|
||||
text_tbl.Insert(page_id, Hdump_text_row_tid.Tid_body, body_bry);
|
||||
return body_bry.length;
|
||||
}
|
||||
public static byte[] Write_imgs(Bry_bfr bfr, ListAdp imgs) {
|
||||
int len = imgs.Count(); if (len == 0) return null; // no images; exit early, else will write blank String
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@ -44,9 +48,9 @@ public class Hdump_save_mgr {
|
||||
}
|
||||
return bfr.XtoAryAndClear();
|
||||
}
|
||||
private static byte[] Write_redlinks(Bry_bfr bfr, Int_list redlink_mgr) {
|
||||
public static byte[] Write_redlinks(Bry_bfr bfr, Xopg_redlink_mgr redlink_mgr) {
|
||||
int len = redlink_mgr.Len(); if (len == 0) return null;
|
||||
bfr.Add_int_variable(len);
|
||||
bfr.Add_int_variable(redlink_mgr.Max());
|
||||
for (int i = 0; i < len; ++i) {
|
||||
bfr.Add_byte_pipe().Add_int_variable(redlink_mgr.Get_at(i));
|
||||
}
|
||||
|
29
400_xowa/src/gplx/xowa/html/Xoh_cfg_file.java
Normal file
29
400_xowa/src/gplx/xowa/html/Xoh_cfg_file.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
|
||||
public class Xoh_cfg_file {
|
||||
public Xoh_cfg_file(Url_encoder url_encoder, Io_url xowa_dir) {
|
||||
Io_url mw_file_dir = xowa_dir.GenSubDir_nest("file", "mw.file");
|
||||
img_media_play_btn = url_encoder.Encode_http(mw_file_dir.GenSubFil("play.png"));
|
||||
img_media_info_btn = url_encoder.Encode_http(mw_file_dir.GenSubFil("info.png"));
|
||||
img_thumb_magnify = url_encoder.Encode_http(mw_file_dir.GenSubFil("magnify-clip.png"));
|
||||
}
|
||||
public byte[] Img_media_play_btn() {return img_media_play_btn;} private final byte[] img_media_play_btn;
|
||||
public byte[] Img_media_info_btn() {return img_media_info_btn;} private final byte[] img_media_info_btn;
|
||||
public byte[] Img_thumb_magnify() {return img_thumb_magnify;} private final byte[] img_thumb_magnify;
|
||||
}
|
@ -41,16 +41,20 @@ public class Xoh_lnki_wtr {
|
||||
}
|
||||
public void Write(Bry_bfr bfr, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki) {
|
||||
Xoa_ttl lnki_ttl = lnki.Ttl();
|
||||
Xow_xwiki_itm lang = lnki_ttl == null ? null : lnki_ttl.Wik_itm();
|
||||
if (lang != null && lang.Type_is_lang(wiki.Lang().Lang_id()) && !lnki_ttl.ForceLiteralLink()) {
|
||||
page.Xwiki_langs().Add(lnki_ttl);
|
||||
return;
|
||||
}
|
||||
if (lnki_ttl == null) {// NOTE: parser failed to properly invalidate lnki; escape tkn now and warn; DATE:2014-06-06
|
||||
app.Usr_dlg().Warn_many("", "", "invalid lnki evaded parser; page=~{0} ex=~{1}", ctx.Cur_page().Url().Xto_full_str(), String_.new_utf8_(src, lnki.Src_bgn(), lnki.Src_end()));
|
||||
Xoh_html_wtr_escaper.Escape(app, bfr, src, lnki.Src_bgn(), lnki.Src_end(), true, false);
|
||||
return;
|
||||
}
|
||||
Xow_xwiki_itm xwiki_lang = lnki_ttl.Wik_itm();
|
||||
if ( xwiki_lang != null // lnki is xwiki; EX: [[commons:]] [[en:]] [[wikt:]]
|
||||
&& xwiki_lang.Wiki_tid() == wiki.Xwiki_domain_tid() // xwiki is same type as cur wiki; EX: cur=w xwiki=w -> add to xwiki_langs; cur=w xwikid=d -> don't add to xwiki_langs; DATE:2014-09-14
|
||||
&& xwiki_lang.Type_is_xwiki_lang(wiki.Domain_itm().Lang_orig_id()) // NOTE: use Lang_orig_id to handle xwikis between s.w and en.w; PAGE:s.q:Anonymous DATE:2014-09-10
|
||||
&& !lnki_ttl.ForceLiteralLink() // not literal; [[:en:A]]
|
||||
) {
|
||||
page.Xwiki_langs().Add(lnki_ttl);
|
||||
return;
|
||||
}
|
||||
boolean literal_link = lnki_ttl.ForceLiteralLink(); // NOTE: if literal link, then override ns behavior; for File, do not show image; for Ctg, do not display at bottom of page
|
||||
redlinks_mgr.Lnki_add(lnki);
|
||||
boolean stage_is_alt = hctx.Mode_is_alt();
|
||||
@ -102,10 +106,17 @@ public class Xoh_lnki_wtr {
|
||||
if (cfg.Lnki_title())
|
||||
bfr .Add(Xoh_consts.A_bgn_lnki_0) // '" title=\"'
|
||||
.Add(lnki_ttl.Page_txt()); // 'Abcd' NOTE: use Page_txt to (a) replace underscores with spaces; (b) get title casing; EX:[[roman_empire]] -> Roman empire
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
bfr.Add(gplx.xowa.hdumps.htmls.Hdump_html_consts.Html_redlink_bgn);
|
||||
bfr.Add_int_variable(lnki.Html_id());
|
||||
bfr.Add(gplx.xowa.hdumps.htmls.Hdump_html_consts.Html_redlink_end);
|
||||
}
|
||||
else {
|
||||
if (cfg.Lnki_visited()
|
||||
&& history_mgr.Has(wiki.Domain_bry(), ttl_bry))
|
||||
bfr.Add(Bry_xowa_visited); // '" class="xowa-visited'
|
||||
bfr.Add(Xoh_consts.__end_quote); // '">'
|
||||
}
|
||||
if (lnki_ttl.Anch_bgn() != -1 && !lnki_ttl.Ns().Id_main()) { // anchor exists and not main_ns; anchor must be manually added b/c Xoa_ttl does not handle # for non main-ns
|
||||
byte[] anch_txt = lnki_ttl.Anch_txt();
|
||||
byte anch_spr
|
||||
|
@ -33,8 +33,9 @@ public class Xoh_module_itm__popups implements Xoh_module_itm {
|
||||
public void Write_js_head_script(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoh_module_wtr wtr) {}
|
||||
public void Write_js_tail_script(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
wtr.Write_js_line(Jquery_init); // NOTE: must assert that jquery is init'd, else popup.js will not compile after going back / forward; DATE:2014-09-10
|
||||
wtr.Write_js_tail_load_lib(app.Fsys_mgr().Bin_any_dir().GenSubFil_nest("xowa", "html", "modules", "xowa.popups", "xowa.popups.js"));
|
||||
}
|
||||
} private static final byte[] Jquery_init = Bry_.new_utf8_("xowa.js.jquery.init();");
|
||||
public void Write_js_head_global(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoh_module_wtr wtr) {
|
||||
if (!enabled) return;
|
||||
Xoapi_popups api_popups = app.Api_root().Html().Modules().Popups();
|
||||
|
53
400_xowa/src/gplx/xowa/html/tidy/Xoh_tidy_wkr_jtidy_tst.java
Normal file
53
400_xowa/src/gplx/xowa/html/tidy/Xoh_tidy_wkr_jtidy_tst.java
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.html.tidy; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import org.w3c.tidy.Tidy;
|
||||
import org.junit.*;
|
||||
public class Xoh_tidy_wkr_jtidy_tst {
|
||||
@Before public void init() {fxt.Clear();} private Jtidy_fxt fxt = new Jtidy_fxt();
|
||||
@Test public void Image_full() {
|
||||
fxt.Test_tidy("<a href='http://𐎍𐎁_𐎜'>𐎍𐎁_𐎜</a>", "<a href='http://%F0%90%8E%8D%F0%90%8E%81_%F0%90%8E%9C'>𐎍𐎁_𐎜</a>\r\n");
|
||||
}
|
||||
}
|
||||
class Jtidy_fxt {
|
||||
public void Clear() {
|
||||
}
|
||||
public void Test_tidy(String raw, String expd) {
|
||||
Tidy tidy = new Tidy();
|
||||
tidy.setPrintBodyOnly(true);
|
||||
tidy.setWraplen(0);
|
||||
tidy.setQuiet(true);
|
||||
tidy.setShowWarnings(false);
|
||||
tidy.setShowErrors(0);
|
||||
ByteArrayInputStream rdr = null;
|
||||
try {
|
||||
rdr = new ByteArrayInputStream(raw.getBytes("UTF-8"));
|
||||
} catch (Exception e) {}
|
||||
ByteArrayOutputStream wtr = new ByteArrayOutputStream();
|
||||
tidy.parse(rdr, wtr);
|
||||
String actl = wtr.toString();
|
||||
Test_mgr.Eq_str(expd, actl);
|
||||
}
|
||||
}
|
||||
class Test_mgr {
|
||||
public static void Eq_str(String expd, String actl) {
|
||||
if (!expd.equals(actl)) throw new RuntimeException(String.format("expd != actl; expd:%s actl:%s", expd, actl));
|
||||
}
|
||||
}
|
@ -48,7 +48,6 @@ public class Xopg_html_data {
|
||||
public byte[] Xtn_search_text() {return xtn_search_txt;} public void Xtn_search_text_(byte[] v) {xtn_search_txt = v;} private byte[] xtn_search_txt = Bry_.Empty;
|
||||
public byte[] Xtn_scribunto_dbg() {return xtn_scribunto_dbg;} public void Xtn_scribunto_dbg_(byte[] v) {xtn_scribunto_dbg = Bry_.Add(xtn_scribunto_dbg, v);} private byte[] xtn_scribunto_dbg = Bry_.Empty;
|
||||
public Xoh_module_mgr Module_mgr() {return module_mgr;} private Xoh_module_mgr module_mgr = new Xoh_module_mgr();
|
||||
public Int_list Redlink_mgr() {return redlink_mgr;} private Int_list redlink_mgr = new Int_list();
|
||||
public byte[] Custom_html() {return custom_html;} public Xopg_html_data Custom_html_(byte[] v) {custom_html = v; return this;} private byte[] custom_html;
|
||||
public byte[] Custom_name() {return custom_name;} public Xopg_html_data Custom_name_(byte[] v) {custom_name = v; return this;} private byte[] custom_name;
|
||||
public byte[] Custom_head_end() {return custom_head_end;}
|
||||
@ -77,7 +76,6 @@ public class Xopg_html_data {
|
||||
xtn_search_txt = Bry_.Empty;
|
||||
xtn_scribunto_dbg = Bry_.Empty;
|
||||
module_mgr.Clear();
|
||||
redlink_mgr.Clear();
|
||||
custom_html = custom_html_end = custom_head_end = custom_name = null;
|
||||
if (ctg_hash != null) ctg_hash.Clear();
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.parsers.lnkis.redlinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
|
||||
import gplx.xowa.dbs.tbls.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*;
|
||||
import gplx.xowa.langs.vnts.*; import gplx.xowa.gui.views.*; import gplx.xowa.pages.*; import gplx.xowa.hdumps.core.*;
|
||||
public class Xop_lnki_logger_redlinks_wkr implements GfoInvkAble {
|
||||
private Xow_wiki wiki; private Xog_win_itm win; private Xoa_page page;
|
||||
private ListAdp lnki_list; private boolean log_enabled; private Gfo_usr_dlg usr_dlg;
|
||||
@ -72,7 +72,7 @@ public class Xop_lnki_logger_redlinks_wkr implements GfoInvkAble {
|
||||
Bry_bfr bfr = null;
|
||||
boolean variants_enabled = wiki.Lang().Vnt_mgr().Enabled();
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
Int_list redlink_mgr = page.Html_data().Redlink_mgr();
|
||||
Xopg_redlink_mgr redlink_mgr = page.Hdump_data().Redlink_mgr();
|
||||
for (int j = 0; j < len; j++) {
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)work_list.FetchAt(j);
|
||||
byte[] full_db = lnki.Ttl().Full_db();
|
||||
@ -109,3 +109,15 @@ public class Xop_lnki_logger_redlinks_wkr implements GfoInvkAble {
|
||||
public static final Xop_lnki_logger_redlinks_wkr Null = new Xop_lnki_logger_redlinks_wkr(); Xop_lnki_logger_redlinks_wkr() {}
|
||||
private static final int Batch_size = 32;
|
||||
}
|
||||
class Xog_redlink_wkr {
|
||||
public static void Redlink(Xog_html_itm html_itm, Int_list list) {
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int uid = list.Get_at(i);
|
||||
Redlink(html_itm, uid);
|
||||
}
|
||||
}
|
||||
public static void Redlink(Xog_html_itm html_itm, int uid) {
|
||||
gplx.xowa.files.gui.Js_img_mgr.Update_link_missing(html_itm, Xop_lnki_logger_redlinks_mgr.Lnki_id_prefix + Int_.Xto_str(uid));
|
||||
}
|
||||
}
|
||||
|
@ -41,65 +41,65 @@ public class Wmf_dump_list_parser_tst {
|
||||
, fxt.itm("zh-classicalwiki", "20131128", Wmf_dump_itm.Status_tid_complete, "Dump complete", "2013-11-28 06:08:56")
|
||||
);
|
||||
}
|
||||
// @Test public void Update() { // 2014-07-06
|
||||
// Hash_adp_bry excluded_domains = Hash_adp_bry.cs_().Add_many_str
|
||||
// ( "advisory.wikipedia.org", "beta.wikiversity.org", "donate.wikipedia.org", "login.wikipedia.org"
|
||||
// , "nostalgia.wikipedia.org", "outreach.wikipedia.org", "quality.wikipedia.org", "sources.wikipedia.org"
|
||||
// , "strategy.wikipedia.org", "ten.wikipedia.org", "test2.wikipedia.org", "test.wikipedia.org"
|
||||
// , "usability.wikipedia.org", "vote.wikipedia.org");
|
||||
// Wmf_dump_itm[] itms = new Wmf_dump_list_parser().Parse(Io_mgr._.LoadFilBry("C:\\xowa\\bin\\any\\html\\xowa\\maint\\backup-index.html"));
|
||||
// Array_.Sort(itms);
|
||||
// Bry_bfr sql_bfr = Bry_bfr.new_();
|
||||
// Bry_bfr bld_bfr = Bry_bfr.new_();
|
||||
// int itms_len = itms.length;
|
||||
// int counter = 1;
|
||||
// for (int i = 0; i < itms_len; i++) {
|
||||
// Wmf_dump_itm itm = itms[i];
|
||||
// byte[] abrv = itm.Wiki_abrv();
|
||||
// if (Bry_.Eq(abrv, Bry_.new_ascii_("testwikidatawiki"))) continue;
|
||||
// byte[] domain_bry = Xob_bz2_file.Parse__domain_name(abrv, 0, abrv.length);
|
||||
// if (domain_bry == null) continue; // not a standard WMF wiki; ignore
|
||||
// if (Bry_finder.Find_fwd(domain_bry, Bry_.new_ascii_("wikimania")) != Bry_.NotFound) continue;
|
||||
// if (excluded_domains.Has(domain_bry)) continue;
|
||||
// Xow_wiki_domain domain_itm = Xow_wiki_domain_.parse_by_domain(domain_bry);
|
||||
// byte[] tid_name = Xto_display_name(Xow_wiki_domain_.Key_by_tid(domain_itm.Tid()));
|
||||
// sql_bfr
|
||||
// .Add_byte(Byte_ascii.Paren_bgn)
|
||||
// .Add_int_variable(counter++)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_int_variable(1)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add(domain_itm.Lang_orig())
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add(tid_name)
|
||||
// .Add_byte(Byte_ascii.Apos)
|
||||
// .Add_byte(Byte_ascii.Paren_end)
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_str("--" + String_.new_utf8_(abrv))
|
||||
// .Add_byte_nl()
|
||||
// ;
|
||||
// bld_bfr
|
||||
// .Add_byte(Byte_ascii.Comma)
|
||||
// .Add_byte(Byte_ascii.Space)
|
||||
// .Add_byte(Byte_ascii.Quote)
|
||||
// .Add(domain_bry)
|
||||
// .Add_byte(Byte_ascii.Quote)
|
||||
// .Add_byte_nl()
|
||||
// ;
|
||||
// }
|
||||
// Io_url temp = Io_url_.new_fil_("C:\\import_update.txt");
|
||||
// Io_mgr._.SaveFilBfr(temp, sql_bfr);
|
||||
//// Io_mgr._.AppendFilBfr(temp, bld_bfr);
|
||||
// }
|
||||
// private static byte[] Xto_display_name(byte[] v) {
|
||||
// if (Bry_.Eq(v, Xow_wiki_domain_.Key_wikimediafoundation_bry)) return Bry_.new_ascii_("Wikimedia Foundation");
|
||||
// else if (Bry_.Eq(v, Xow_wiki_domain_.Key_species_bry)) return Bry_.new_ascii_("Wikispecies");
|
||||
// else if (Bry_.Eq(v, Xow_wiki_domain_.Key_mediawiki_bry)) return Bry_.new_ascii_("MediaWiki");
|
||||
// else return Bry_.Add(Byte_ascii.Case_upper(v[0]), Bry_.Mid(v, 1, v.length));
|
||||
// }
|
||||
@Test public void Update() { // 2014-07-06
|
||||
Hash_adp_bry excluded_domains = Hash_adp_bry.cs_().Add_many_str
|
||||
( "advisory.wikipedia.org", "beta.wikiversity.org", "donate.wikipedia.org", "login.wikipedia.org"
|
||||
, "nostalgia.wikipedia.org", "outreach.wikipedia.org", "quality.wikipedia.org", "sources.wikipedia.org"
|
||||
, "strategy.wikipedia.org", "ten.wikipedia.org", "test2.wikipedia.org", "test.wikipedia.org"
|
||||
, "usability.wikipedia.org", "vote.wikipedia.org");
|
||||
Wmf_dump_itm[] itms = new Wmf_dump_list_parser().Parse(Io_mgr._.LoadFilBry("C:\\xowa\\bin\\any\\html\\xowa\\maint\\backup-index.html"));
|
||||
Array_.Sort(itms);
|
||||
Bry_bfr sql_bfr = Bry_bfr.new_();
|
||||
Bry_bfr bld_bfr = Bry_bfr.new_();
|
||||
int itms_len = itms.length;
|
||||
int counter = 1;
|
||||
for (int i = 0; i < itms_len; i++) {
|
||||
Wmf_dump_itm itm = itms[i];
|
||||
byte[] abrv = itm.Wiki_abrv();
|
||||
if (Bry_.Eq(abrv, Bry_.new_ascii_("testwikidatawiki"))) continue;
|
||||
byte[] domain_bry = Xob_bz2_file.Parse__domain_name(abrv, 0, abrv.length);
|
||||
if (domain_bry == null) continue; // not a standard WMF wiki; ignore
|
||||
if (Bry_finder.Find_fwd(domain_bry, Bry_.new_ascii_("wikimania")) != Bry_.NotFound) continue;
|
||||
if (excluded_domains.Has(domain_bry)) continue;
|
||||
Xow_wiki_domain domain_itm = Xow_wiki_domain_.parse_by_domain(domain_bry);
|
||||
byte[] tid_name = Xto_display_name(Xow_wiki_domain_.Key_by_tid(domain_itm.Tid()));
|
||||
sql_bfr
|
||||
.Add_byte(Byte_ascii.Paren_bgn)
|
||||
.Add_int_variable(counter++)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_int_variable(1)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add(domain_itm.Lang_orig())
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add(tid_name)
|
||||
.Add_byte(Byte_ascii.Apos)
|
||||
.Add_byte(Byte_ascii.Paren_end)
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_str("--" + String_.new_utf8_(abrv))
|
||||
.Add_byte_nl()
|
||||
;
|
||||
bld_bfr
|
||||
.Add_byte(Byte_ascii.Comma)
|
||||
.Add_byte(Byte_ascii.Space)
|
||||
.Add_byte(Byte_ascii.Quote)
|
||||
.Add(domain_bry)
|
||||
.Add_byte(Byte_ascii.Quote)
|
||||
.Add_byte_nl()
|
||||
;
|
||||
}
|
||||
Io_url temp = Io_url_.new_fil_("C:\\import_update.txt");
|
||||
Io_mgr._.SaveFilBfr(temp, sql_bfr);
|
||||
// Io_mgr._.AppendFilBfr(temp, bld_bfr);
|
||||
}
|
||||
private static byte[] Xto_display_name(byte[] v) {
|
||||
if (Bry_.Eq(v, Xow_wiki_domain_.Key_wikimediafoundation_bry)) return Bry_.new_ascii_("Wikimedia Foundation");
|
||||
else if (Bry_.Eq(v, Xow_wiki_domain_.Key_species_bry)) return Bry_.new_ascii_("Wikispecies");
|
||||
else if (Bry_.Eq(v, Xow_wiki_domain_.Key_mediawiki_bry)) return Bry_.new_ascii_("MediaWiki");
|
||||
else return Bry_.Add(Byte_ascii.Case_upper(v[0]), Bry_.Mid(v, 1, v.length));
|
||||
}
|
||||
}
|
||||
class Wmf_dump_list_parser_fxt {
|
||||
public void Clear() {}
|
||||
|
@ -57,15 +57,11 @@ class Xop_statistics_stats_page_grp implements Bry_fmtr_arg {
|
||||
, " <th colspan=\"2\">~{lbl_header_pages}</th>"
|
||||
, " </tr>"
|
||||
, " <tr class=\"mw-statistics-articles\">"
|
||||
, " <td>"
|
||||
, " ~{lbl_articles}"
|
||||
, " </td>"
|
||||
, " <td>~{lbl_articles}</td>"
|
||||
, " <td class=\"mw-statistics-numbers\" style='text-align:right'>~{page_count_main}</td>"
|
||||
, " </tr>"
|
||||
, " <tr class=\"mw-statistics-pages\">"
|
||||
, " <td>~{lbl_pages}<br />"
|
||||
, " <small class=\"mw-statistic-desc\"> ~{lbl_pages_desc}</small>"
|
||||
, " </td>"
|
||||
, " <td>~{lbl_pages}<br /><small class=\"mw-statistic-desc\"> ~{lbl_pages_desc}</small></td>"
|
||||
, " <td class=\"mw-statistics-numbers\" style='text-align:right'>~{page_count_all}</td>"
|
||||
, " </tr>"
|
||||
), "lbl_header_pages", "lbl_articles", "lbl_pages", "lbl_pages_desc", "page_count_main", "page_count_all");
|
||||
|
@ -27,15 +27,11 @@ public class Xop_statistics_page_tst {
|
||||
, " <th colspan=\"2\">Page statistics</th>"
|
||||
, " </tr>"
|
||||
, " <tr class=\"mw-statistics-articles\">"
|
||||
, " <td>"
|
||||
, " Content pages"
|
||||
, " </td>"
|
||||
, " <td>Content pages</td>"
|
||||
, " <td class=\"mw-statistics-numbers\" style='text-align:right'>0</td>"
|
||||
, " </tr>"
|
||||
, " <tr class=\"mw-statistics-pages\">"
|
||||
, " <td>Pages<br />"
|
||||
, " <small class=\"mw-statistic-desc\"> All pages in the wiki, including talk pages, redirects, etc.</small>"
|
||||
, " </td>"
|
||||
, " <td>Pages<br /><small class=\"mw-statistic-desc\"> All pages in the wiki, including talk pages, redirects, etc.</small></td>"
|
||||
, " <td class=\"mw-statistics-numbers\" style='text-align:right'>0</td>"
|
||||
, " </tr>"
|
||||
, " <tr>"
|
||||
|
@ -17,10 +17,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
public class Xow_wiki_domain {
|
||||
public Xow_wiki_domain(byte[] raw, byte tid, byte[] lang) {this.raw = raw; this.tid = tid; this.lang = this.lang_orig = lang;}
|
||||
public Xow_wiki_domain(byte[] raw, byte tid, byte[] lang, byte[] lang_orig) {this.raw = raw; this.tid = tid; this.lang = lang; this.lang_orig = lang_orig;}
|
||||
public Xow_wiki_domain(byte[] raw, byte tid, byte[] lang) {
|
||||
this.raw = raw; this.tid = tid; this.lang = this.lang_orig = lang;
|
||||
Lang_orig_id_();
|
||||
}
|
||||
public Xow_wiki_domain(byte[] raw, byte tid, byte[] lang, byte[] lang_orig) {
|
||||
this.raw = raw; this.tid = tid; this.lang = lang; this.lang_orig = lang_orig;
|
||||
Lang_orig_id_();
|
||||
}
|
||||
public byte[] Raw() {return raw;} private byte[] raw;
|
||||
public byte Tid() {return tid;} private byte tid;
|
||||
public byte[] Lang_orig() {return lang_orig;} private byte[] lang_orig;
|
||||
public int Lang_orig_id() {return lang_orig_id;} private int lang_orig_id;
|
||||
public byte[] Lang() {return lang;} private byte[] lang;
|
||||
private void Lang_orig_id_() {
|
||||
// if (Bry_.Eq(lang_orig, Commons_bry))
|
||||
// lang_orig_id = Xol_lang_itm_.Id_en;
|
||||
// else
|
||||
lang_orig_id = Xol_lang_itm_.Get_by_key_or_intl(lang_orig, 0, lang_orig.length).Id();
|
||||
} // private static final byte[] Commons_bry = Bry_.new_ascii_("commons");
|
||||
}
|
||||
|
@ -23,6 +23,17 @@ public class Xow_wiki_domain_ {
|
||||
Object o = key_hash.Get_by_bry(key);
|
||||
return o == null ? Tid_by_key_null : ((Byte_obj_val)o).Val();
|
||||
}
|
||||
public static byte Xwiki_tid(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid_commons:
|
||||
case Tid_species:
|
||||
case Tid_incubator:
|
||||
case Tid_mediawiki:
|
||||
case Tid_wikimediafoundation:
|
||||
case Tid_home: return Tid_wikipedia; // set xwiki_tid to wikipedia; allows [[da:Page]] to point to da.wikipedia.org; PAGE:species:Puccinia; DATE:2014-09-14
|
||||
default: return tid;
|
||||
}
|
||||
}
|
||||
public static Xow_wiki_domain new_other_(byte[] raw) {return new Xow_wiki_domain(raw, Xow_wiki_domain_.Tid_other, Xol_lang_itm_.Key__unknown);}
|
||||
public static Xow_wiki_domain parse_by_domain(byte[] raw) {
|
||||
/*
|
||||
|
@ -21,14 +21,23 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
this.key_bry = key_bry; this.key_str = String_.new_utf8_(key_bry);
|
||||
this.fmt = fmt; this.wiki_tid = wiki_tid; this.lang_id = lang_id; this.domain = domain;
|
||||
this.name = key_bry;
|
||||
if (Bry_.Eq(domain, Xow_wiki_domain_.Url_commons))
|
||||
domain_is_commons = true;
|
||||
}
|
||||
private boolean domain_is_commons;
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
public String Key_str() {return key_str;} private String key_str;
|
||||
public byte[] Fmt() {return fmt;} private byte[] fmt;
|
||||
public byte[] Domain() {return domain;} private byte[] domain;
|
||||
public byte Wiki_tid() {return wiki_tid;} private byte wiki_tid;
|
||||
public int Lang_id() {return lang_id;} private int lang_id;
|
||||
public boolean Type_is_lang(int cur_lang_id) {return lang_id != Xol_lang_itm_.Id__unknown && cur_lang_id != lang_id && Bry_.Len_gt_0(fmt);}
|
||||
public boolean Type_is_xwiki_lang(int cur_lang_id) {
|
||||
return lang_id != Xol_lang_itm_.Id__unknown // valid lang code
|
||||
&& !domain_is_commons // commons should never be considered an xwiki_lang; EX:[[commons:A]] PAGE:species:Scarabaeidae; DATE:2014-09-10
|
||||
&& lang_id != cur_lang_id // lang is different than current; EX: [[en:A]] in en.wikipedia.org shouldn't link back to self
|
||||
&& Bry_.Len_gt_0(fmt) // fmt exists
|
||||
;
|
||||
}
|
||||
public byte[] Name() {return name;} public Xow_xwiki_itm Name_(byte[] v) {name = v; return this;} private byte[] name;
|
||||
public boolean Offline() {return offline;} public Xow_xwiki_itm Offline_(boolean v) {offline = v; return this;} private boolean offline;
|
||||
public int compareTo(Object obj) {Xow_xwiki_itm comp = (Xow_xwiki_itm)obj; return Bry_.Compare(key_bry, comp.key_bry);}
|
||||
|
@ -111,7 +111,6 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
if (lang_key_bry == Xol_lang_itm_.Key__unknown) lang_key_bry = Xol_lang_.Key_en; // default non-lang wikis to english
|
||||
String lang_key_str = String_.new_utf8_(lang_key_bry);
|
||||
int lang_id = Xol_lang_itm_.Get_by_key(lang_key_bry).Id();
|
||||
byte wiki_tid = wiki.Domain_tid();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xoac_wiki_itm wiki_itm = (Xoac_wiki_itm)peers.FetchAt(i);
|
||||
byte[] wiki_name_bry = wiki_itm.Key_bry();
|
||||
@ -136,7 +135,7 @@ public class Xow_xwiki_mgr implements GfoInvkAble {
|
||||
for (int j = 0; j < aliases_len; j++) {
|
||||
byte[] alias = wiki_itm.Aliases()[j];
|
||||
if (wiki.Ns_mgr().Names_get_or_null(alias, 0, alias.length) != null) continue; // NOTE: do not add xwiki if alias matches namespace; EX: en.wiktionary.org has ns of "Wiktionary"; do not add alias of "wiktionary"; note that wikipedia does have an alias to wiktionary
|
||||
Xow_xwiki_itm xwiki = new Xow_xwiki_itm(alias, Bry_.new_utf8_(fmt), wiki_tid, lang_id, domain_bry).Offline_(offline_exists);
|
||||
Xow_xwiki_itm xwiki = new Xow_xwiki_itm(alias, Bry_.new_utf8_(fmt), xwiki_tid_val, lang_id, domain_bry).Offline_(offline_exists); // NOTE: xwiki_tid_val must be used, not wiki.Domain_tid; DATE:2014-09-14
|
||||
Add_itm(xwiki, null);
|
||||
}
|
||||
}
|
||||
|
@ -18,24 +18,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*; import gplx.xowa.wikis.*; import gplx.xowa.langs.*;
|
||||
public class Xow_xwiki_mgr_tst {
|
||||
Xow_xwiki_mgr_fxt fxt = new Xow_xwiki_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Add_bulk_wiki_en() {fxt.Tst_add_bulk("w|en.wikipedia.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_wikipedia , "w" , "http://en.wikipedia.org/wiki/~{0}", "en.wikipedia.org");}
|
||||
@Test public void Add_bulk_wiki_fr() {fxt.Tst_add_bulk("fr|fr.wikipedia.org" , Xol_lang_itm_.Id_fr , Xow_wiki_domain_.Tid_wikipedia , "fr" , "http://fr.wikipedia.org/wiki/~{0}", "fr.wikipedia.org");}
|
||||
@Test public void Add_bulk_wikt_en() {fxt.Tst_add_bulk("wikt|en.wiktionary.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_wiktionary , "wikt" , "http://en.wiktionary.org/wiki/~{0}", "en.wiktionary.org");}
|
||||
@Test public void Add_bulk_commons() {fxt.Tst_add_bulk("commons|commons.wikimedia.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_commons , "commons" , "http://commons.wikimedia.org/wiki/~{0}", "commons.wikimedia.org");}
|
||||
@Test public void Add_bulk_commons_cap() {fxt.Tst_add_bulk("Commons|commons.wikimedia.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_commons , "Commons" , "http://commons.wikimedia.org/wiki/~{0}", "commons.wikimedia.org");}
|
||||
@Test public void Add_bulk_langs_wiki() {fxt.Langs_ini().Tst_add_bulk_langs("wiki", fxt.xwiki_("en", "en.wikipedia.org", "http://en.wikipedia.org/wiki/~{0}"), fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"), fxt.xwiki_("ja", "ja.wikipedia.org", "http://ja.wikipedia.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_langs_grps() {fxt.Langs_ini().Tst_add_bulk_langs("europe_west~asia_east", fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"), fxt.xwiki_("ja", "ja.wikipedia.org", "http://ja.wikipedia.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_langs_grp_itm() {fxt.Langs_ini().Tst_add_bulk_langs("europe_west~ja", fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"), fxt.xwiki_("ja", "ja.wikipedia.org", "http://ja.wikipedia.org/wiki/~{0}"));}
|
||||
@Before public void init() {fxt.Clear();} private Xow_xwiki_mgr_fxt fxt = new Xow_xwiki_mgr_fxt();
|
||||
@Test public void Add_bulk_wiki_en() {fxt.Test_add_bulk("w|en.wikipedia.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_wikipedia , "w" , "http://en.wikipedia.org/wiki/~{0}", "en.wikipedia.org");}
|
||||
@Test public void Add_bulk_wiki_fr() {fxt.Test_add_bulk("fr|fr.wikipedia.org" , Xol_lang_itm_.Id_fr , Xow_wiki_domain_.Tid_wikipedia , "fr" , "http://fr.wikipedia.org/wiki/~{0}", "fr.wikipedia.org");}
|
||||
@Test public void Add_bulk_wikt_en() {fxt.Test_add_bulk("wikt|en.wiktionary.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_wiktionary , "wikt" , "http://en.wiktionary.org/wiki/~{0}", "en.wiktionary.org");}
|
||||
@Test public void Add_bulk_commons() {fxt.Test_add_bulk("commons|commons.wikimedia.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_commons , "commons" , "http://commons.wikimedia.org/wiki/~{0}", "commons.wikimedia.org");}
|
||||
@Test public void Add_bulk_commons_cap() {fxt.Test_add_bulk("Commons|commons.wikimedia.org" , Xol_lang_itm_.Id__unknown , Xow_wiki_domain_.Tid_commons , "Commons" , "http://commons.wikimedia.org/wiki/~{0}", "commons.wikimedia.org");}
|
||||
@Test public void Add_bulk_langs_wiki() {fxt.Init_langs().Test_add_bulk_langs("wiki", fxt.xwiki_("en", "en.wikipedia.org", "http://en.wikipedia.org/wiki/~{0}"), fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"), fxt.xwiki_("ja", "ja.wikipedia.org", "http://ja.wikipedia.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_langs_grps() {fxt.Init_langs().Test_add_bulk_langs("europe_west~asia_east", fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"), fxt.xwiki_("ja", "ja.wikipedia.org", "http://ja.wikipedia.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_langs_grp_itm() {fxt.Init_langs().Test_add_bulk_langs("europe_west~ja", fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"), fxt.xwiki_("ja", "ja.wikipedia.org", "http://ja.wikipedia.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_langs_grp_commons() {
|
||||
fxt.Langs_ini();
|
||||
fxt.Init_langs();
|
||||
fxt.Wiki().Xwiki_mgr().Add_bulk_langs(Bry_.new_ascii_("europe_west"), Xow_wiki_domain_.Tid_wikipedia);
|
||||
fxt.Tst_itms(fxt.xwiki_("de", "de.wikipedia.org", "http://de.wikipedia.org/wiki/~{0}"), fxt.xwiki_("fr", "fr.wikipedia.org", "http://fr.wikipedia.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers() {fxt.Peers_ini().Tst_add_bulk_peers("peer", fxt.xwiki_null_("commons"), fxt.xwiki_null_("m"), fxt.xwiki_("wikt", "en.wiktionary.org", "http://en.wiktionary.org/wiki/~{0}"), fxt.xwiki_("wiktionary", "en.wiktionary.org", "http://en.wiktionary.org/wiki/~{0}"), fxt.xwiki_("s", "en.wikisource.org", "http://en.wikisource.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_peers_skip_self() {fxt.Peers_ini().Tst_add_bulk_peers("peer", fxt.xwiki_null_("wikipedia"), fxt.xwiki_("w", "en.wikipedia.org", "http://en.wikipedia.org/wiki/~{0}"));} // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is namespace; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
@Test public void Add_bulk_core_wikidata() {fxt.Peers_ini().Tst_add_bulk_peers("core", fxt.xwiki_("d", "www.wikidata.org", "http://www.wikidata.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_peers() {fxt.Init_peers().Test_add_bulk_peers("peer", fxt.xwiki_null_("commons"), fxt.xwiki_null_("m"), fxt.xwiki_("wikt", "en.wiktionary.org", "http://en.wiktionary.org/wiki/~{0}"), fxt.xwiki_("wiktionary", "en.wiktionary.org", "http://en.wiktionary.org/wiki/~{0}"), fxt.xwiki_("s", "en.wikisource.org", "http://en.wikisource.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_peers_skip_self() {fxt.Init_peers().Test_add_bulk_peers("peer", fxt.xwiki_null_("wikipedia"), fxt.xwiki_("w", "en.wikipedia.org", "http://en.wikipedia.org/wiki/~{0}"));} // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is namespace; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
@Test public void Add_bulk_core_wikidata() {fxt.Init_peers().Test_add_bulk_peers("core", fxt.xwiki_("d", "www.wikidata.org", "http://www.wikidata.org/wiki/~{0}"));}
|
||||
@Test public void Add_bulk_peers_tid() { // PURPOSE:wikt should generate wiki_tid of wiktionary, not wikipedia; PAGE:en.s:Main_Page DATE:2014-09-14
|
||||
fxt.Init_wikt ().Test_add_bulk_peers("peer", fxt.xwiki_("wikt", "en.wiktionary.org", "http://en.wiktionary.org/wiki/~{0}"));
|
||||
}
|
||||
}
|
||||
class Xow_xwiki_mgr_fxt {
|
||||
Xow_xwiki_mgr xwiki_mgr; Xoa_lang_mgr lang_mgr; String_bldr sb = String_bldr_.new_(); Xoa_app app; Xow_wiki wiki;
|
||||
@ -51,8 +53,11 @@ class Xow_xwiki_mgr_fxt {
|
||||
}
|
||||
public Xow_wiki Wiki() {return wiki;}
|
||||
public Xow_xwiki_itm xwiki_null_(String key) {return new Xow_xwiki_itm(Bry_.new_utf8_(key), Bry_.Empty, Xow_wiki_domain_.Tid_other, Xol_lang_itm_.Id__unknown, Bry_.Empty);}
|
||||
public Xow_xwiki_itm xwiki_(String key, String domain, String fmt) {return new Xow_xwiki_itm(Bry_.new_utf8_(key), Bry_.new_utf8_(fmt), Xow_wiki_domain_.Tid_other, Xol_lang_itm_.Id__unknown, Bry_.new_utf8_(domain));}
|
||||
public Xow_xwiki_mgr_fxt Tst_add_bulk(String raw, int lang_tid, byte wiki_tid, String alias, String fmt, String domain) {
|
||||
public Xow_xwiki_itm xwiki_(String key, String domain, String fmt) {
|
||||
Xow_wiki_domain domain_itm = Xow_wiki_domain_.parse_by_domain(Bry_.new_utf8_(domain));
|
||||
return new Xow_xwiki_itm(Bry_.new_utf8_(key), Bry_.new_utf8_(fmt), domain_itm.Tid(), Xol_lang_itm_.Id__unknown, Bry_.new_utf8_(domain));
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk(String raw, int lang_tid, byte wiki_tid, String alias, String fmt, String domain) {
|
||||
Xow_xwiki_itm itm = xwiki_mgr.Add_bulk_row(Xol_lang_itm_.Regy(), Bry_.new_ascii_(raw));
|
||||
Tfds.Eq(alias, String_.new_ascii_(itm.Key_bry()));
|
||||
Tfds.Eq(fmt, String_.new_ascii_(itm.Fmt()));
|
||||
@ -60,7 +65,7 @@ class Xow_xwiki_mgr_fxt {
|
||||
Tfds.Eq(lang_tid, itm.Lang_id(), "lang_id");
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Langs_ini() {
|
||||
public Xow_xwiki_mgr_fxt Init_langs() {
|
||||
lang_mgr.Groups().Set_bulk(Bry_.new_utf8_(String_.Concat_lines_nl
|
||||
( "+||grp|wiki"
|
||||
, "+|wiki|grp|english"
|
||||
@ -73,7 +78,7 @@ class Xow_xwiki_mgr_fxt {
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Peers_ini() {
|
||||
public Xow_xwiki_mgr_fxt Init_peers() {
|
||||
app.Wiki_mgr().Groups().Set_bulk(Bry_.new_utf8_(String_.Concat_lines_nl
|
||||
( "+|core|itm|commons|commons"
|
||||
, "+|core|itm|meta|meta;m"
|
||||
@ -84,13 +89,19 @@ class Xow_xwiki_mgr_fxt {
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Tst_add_bulk_langs(String langs, Xow_xwiki_itm... itms) {
|
||||
public Xow_xwiki_mgr_fxt Init_wikt() {
|
||||
app.Wiki_mgr().Groups().Set_bulk(Bry_.new_utf8_(String_.Concat_lines_nl
|
||||
( "+|peer|itm|wiktionary|wikt;wiktionary"
|
||||
)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_langs(String langs, Xow_xwiki_itm... itms) {
|
||||
xwiki_mgr.Add_bulk_langs(Bry_.new_utf8_(langs));
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(Xto_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
public Xow_xwiki_mgr_fxt Tst_add_bulk_peers(String exclude, Xow_xwiki_itm... itms) {
|
||||
xwiki_mgr.Add_bulk_peers(Bry_.new_utf8_(exclude));
|
||||
public Xow_xwiki_mgr_fxt Test_add_bulk_peers(String peers, Xow_xwiki_itm... itms) {
|
||||
xwiki_mgr.Add_bulk_peers(Bry_.new_utf8_(peers));
|
||||
Tfds.Eq_str_lines(Xto_str(itms), Xto_str(Xto_ary(itms)));
|
||||
return this;
|
||||
}
|
||||
@ -116,7 +127,7 @@ class Xow_xwiki_mgr_fxt {
|
||||
if (Bry_.Len_eq_0(itm.Domain())) // "null", ignore
|
||||
sb.Add(itm.Key_bry()).Add_char_nl();
|
||||
else {
|
||||
sb.Add(itm.Key_bry()).Add_char_pipe().Add(itm.Domain()).Add_char_pipe().Add(itm.Fmt()).Add_char_nl();
|
||||
sb.Add(itm.Key_bry()).Add_char_pipe().Add(itm.Domain()).Add_char_pipe().Add(itm.Fmt()).Add_char_pipe().Add(itm.Wiki_tid()).Add_char_nl();
|
||||
}
|
||||
}
|
||||
return sb.XtoStrAndClear();
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.xtns; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.xtns.relatedSites.*; import gplx.xowa.xtns.insiders.*;
|
||||
import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.xtns.relatedSites.*; import gplx.xowa.xtns.insiders.*; import gplx.xowa.xtns.proofreadPage.*;
|
||||
public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
private OrderedHash regy = OrderedHash_.new_bry_();
|
||||
public int Count() {return regy.Count();}
|
||||
@ -25,11 +25,13 @@ public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
public Imap_xtn_mgr Xtn_imap() {return xtn_imap;} private Imap_xtn_mgr xtn_imap;
|
||||
public Sites_xtn_mgr Xtn_sites() {return xtn_sites;} private Sites_xtn_mgr xtn_sites;
|
||||
public Insider_xtn_mgr Xtn_insider() {return xtn_insider;} private Insider_xtn_mgr xtn_insider;
|
||||
public Pp_xtn_mgr Xtn_proofread() {return xtn_proofread;} private Pp_xtn_mgr xtn_proofread;
|
||||
public Xow_xtn_mgr Ctor_by_app(Xoa_app app) { // NOTE: needed for options
|
||||
Add(app, new Cite_xtn_mgr());
|
||||
Add(app, new Imap_xtn_mgr());
|
||||
Add(app, new Sites_xtn_mgr());
|
||||
Add(app, new Insider_xtn_mgr());
|
||||
Add(app, new Pp_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.scribunto.Scrib_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.gallery.Gallery_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.poems.Poem_xtn_mgr());
|
||||
@ -38,7 +40,6 @@ public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
Add(app, new gplx.xowa.xtns.listings.Listing_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.titleBlacklists.Blacklist_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.pfuncs.scribunto.Pfunc_xtn_mgr());
|
||||
Add(app, new gplx.xowa.xtns.proofreadPage.Pp_xtn_mgr());
|
||||
return this;
|
||||
}
|
||||
public Xow_xtn_mgr Ctor_by_wiki(Xow_wiki wiki) {
|
||||
@ -85,14 +86,16 @@ public class Xow_xtn_mgr implements GfoInvkAble {
|
||||
case Tid_sites: xtn_sites = (Sites_xtn_mgr)mgr; break;
|
||||
case Tid_insider: xtn_insider = (Insider_xtn_mgr)mgr; break;
|
||||
case Tid_imap: xtn_imap = (Imap_xtn_mgr)mgr; break;
|
||||
case Tid_proofread: xtn_proofread = (Pp_xtn_mgr)mgr; break;
|
||||
}
|
||||
}
|
||||
private static final byte Tid_cite = 0, Tid_sites = 1, Tid_insider = 2, Tid_imap = 3;
|
||||
private static final byte Tid_cite = 0, Tid_sites = 1, Tid_insider = 2, Tid_imap = 3, Tid_proofread = 4;
|
||||
private static final Btrie_slim_mgr xtn_tid_trie = Btrie_slim_mgr.cs_()
|
||||
.Add_bry_bval(Cite_xtn_mgr.XTN_KEY , Tid_cite)
|
||||
.Add_bry_bval(Sites_xtn_mgr.XTN_KEY , Tid_sites)
|
||||
.Add_bry_bval(Insider_xtn_mgr.XTN_KEY , Tid_insider)
|
||||
.Add_bry_bval(Imap_xtn_mgr.XTN_KEY , Tid_imap)
|
||||
.Add_bry_bval(Pp_xtn_mgr.XTN_KEY , Tid_proofread)
|
||||
;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get_or_fail(m.ReadBry("v"));
|
||||
|
@ -25,14 +25,16 @@ public abstract class Xox_mgr_base implements Xox_mgr {
|
||||
public abstract Xox_mgr Clone_new();
|
||||
public boolean Enabled() {return enabled;} private boolean enabled;
|
||||
@gplx.Virtual public boolean Enabled_default() {return true;}
|
||||
public void Enabled_y_() {enabled = true;} public void Enabled_n_() {enabled = false;} // TEST:
|
||||
public void Enabled_y_() {enabled = true; enabled_manually = true;} public void Enabled_n_() {enabled = false; enabled_manually = true;} // TEST:
|
||||
public void Enabled_(boolean v) {enabled = v;}
|
||||
public boolean Enabled_manually() {return enabled_manually;} private boolean enabled_manually;
|
||||
@gplx.Virtual public void Xtn_ctor_by_app(Xoa_app app) {}
|
||||
@gplx.Virtual public void Xtn_ctor_by_wiki(Xow_wiki wiki) {}
|
||||
@gplx.Virtual public void Xtn_init_by_app(Xoa_app app) {}
|
||||
@gplx.Virtual public void Xtn_init_by_wiki(Xow_wiki wiki) {}
|
||||
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.Xto_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_enabled_)) {enabled = m.ReadYn("v"); enabled_manually = true;}
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
@ -58,7 +60,7 @@ public abstract class Xox_mgr_base implements Xox_mgr {
|
||||
}
|
||||
public static void Xtn_load_i18n(Xow_wiki wiki, byte[] xtn_key) {
|
||||
Xoa_app app = wiki.App();
|
||||
Io_url url = app.Fsys_mgr().Bin_extensions_dir().GenSubFil_nest(String_.new_utf8_(xtn_key), "i18n", wiki.Lang().Key_str() + ".json");
|
||||
Io_url url = app.Fsys_mgr().Bin_xtns_dir().GenSubFil_nest(String_.new_utf8_(xtn_key), "i18n", wiki.Lang().Key_str() + ".json");
|
||||
wiki.App().Bldr().I18n_parser().Load_msgs(false, wiki.Lang(), url);
|
||||
}
|
||||
private static final byte[] Xowa_not_implemented = Bry_.new_ascii_("XOWA does not support this extension: ");
|
||||
|
@ -27,7 +27,7 @@ public class References_nde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
case Xatr_id_group: group = xatr.Val_as_bry(src); break;
|
||||
}
|
||||
}
|
||||
public void Xtn_parse(Xow_wiki wiki, Xop_ctx ctx, Xop_root_tkn cur_root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
public void Xtn_parse(Xow_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
if (ctx.Tid_is_popup()) return;
|
||||
Ref_itm_mgr ref_mgr = ctx.Cur_page().Ref_mgr();
|
||||
if (ref_mgr.References__recursing()) return; // skip nested <references> else refs will be lost; EX:"<references><references/></references>"; PAGE:en.w:Hwair; DATE:2014-06-27
|
||||
@ -39,10 +39,10 @@ public class References_nde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
references_ctx.Para().Enabled_n_(); // disable para during <references> parsing
|
||||
byte[] references_src = Bry_.Mid(src, itm_bgn, itm_end);
|
||||
Xop_tkn_mkr tkn_mkr = ctx.Tkn_mkr();
|
||||
Xop_root_tkn root = tkn_mkr.Root(src);
|
||||
Xop_root_tkn sub_root = tkn_mkr.Root(src);
|
||||
boolean prv_recursing = ref_mgr.References__recursing();
|
||||
ref_mgr.References__recursing_(true);
|
||||
wiki.Parser().Parse_text_to_wdom(root, references_ctx, tkn_mkr, references_src, Xop_parser_.Doc_bgn_char_0); // NOTE: parse @gplx.Internal protected contents, but root will be discarded; only picking up <ref> tags; DATE:2014-06-27
|
||||
wiki.Parser().Parse_text_to_wdom(sub_root, references_ctx, tkn_mkr, references_src, Xop_parser_.Doc_bgn_char_0); // NOTE: parse @gplx.Internal protected contents, but root will be discarded; only picking up <ref> tags; DATE:2014-06-27
|
||||
ref_mgr.References__recursing_(prv_recursing);
|
||||
}
|
||||
list_idx = ref_mgr.Grps_get(group).Grp_seal(); // NOTE: needs to be sealed at end; else inner refs will end up in new group; EX: <references><ref>don't seal prematurely</ref></references>
|
||||
|
@ -52,5 +52,5 @@ public class Hiero_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
}
|
||||
public static final String Invk_prefabs = "prefabs", Invk_files = "files", Invk_phonemes = "phonemes";
|
||||
public static Io_url Hiero_root_dir(Xoa_app app) {return app.Fsys_mgr().Bin_extensions_dir().GenSubDir("Wikihiero");}
|
||||
public static Io_url Hiero_root_dir(Xoa_app app) {return app.Fsys_mgr().Bin_xtns_dir().GenSubDir("Wikihiero");}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class Imap_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
|
||||
if (desc_trie != null) return;
|
||||
desc_trie = Imap_desc_tid.trie_(wiki);
|
||||
desc_msg = wiki.Msg_mgr().Val_by_key_obj("imagemap_description");
|
||||
desc_icon_url = wiki.App().Fsys_mgr().Bin_extensions_dir().GenSubFil_nest("ImageMap", "imgs", "desc-20.png").To_http_file_bry();
|
||||
desc_icon_url = wiki.App().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("ImageMap", "imgs", "desc-20.png").To_http_file_bry();
|
||||
}
|
||||
public Btrie_slim_mgr Desc_trie() {return desc_trie;} private Btrie_slim_mgr desc_trie;
|
||||
public byte[] Desc_msg() {return desc_msg;} private byte[] desc_msg;
|
||||
|
@ -22,7 +22,7 @@ public class Xof_math_mgr implements GfoInvkAble {
|
||||
public ProcessAdp Cmd_convert_tex_to_dvi() {return cmd_convert_tex_to_dvi;} private ProcessAdp cmd_convert_tex_to_dvi = new ProcessAdp();
|
||||
public ProcessAdp Cmd_convert_dvi_to_png() {return cmd_convert_dvi_to_png;} private ProcessAdp cmd_convert_dvi_to_png = new ProcessAdp();
|
||||
public void Init(Xoa_app app) {
|
||||
Launcher_app_mgr app_mgr = app.Fsys_mgr().App_mgr();
|
||||
Launcher_app_mgr app_mgr = app.Launcher();
|
||||
cmd_convert_tex_to_dvi = app_mgr.App_convert_tex_to_dvi();
|
||||
cmd_convert_dvi_to_png = app_mgr.App_convert_dvi_to_png();
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class Xof_math_mgr implements GfoInvkAble {
|
||||
}
|
||||
public boolean MakePng(byte[] math, String hash, Io_url png_url, String prog_fmt) {
|
||||
if (!enabled) return false;
|
||||
Io_url tmp_dir = app.Fsys_mgr().Temp_dir().GenSubDir("math"); // cmd_convert_tex_to_dvi.Tmp_dir();
|
||||
Io_url tmp_dir = app.User().Fsys_mgr().App_temp_dir().GenSubDir("math"); // cmd_convert_tex_to_dvi.Tmp_dir();
|
||||
Io_url tex_url = tmp_dir.GenSubFil("xowa_math_temp.tex");
|
||||
String latex = Latex_wrap(math);
|
||||
prog_fmt = String_.Replace(prog_fmt, "~", "~~"); // double-up ~ or else will break in progress bar
|
||||
|
@ -26,7 +26,7 @@ public class Pfunc_scrib_lib implements Scrib_lib {
|
||||
public Scrib_lua_mod Register(Scrib_core core, Io_url script_dir) {
|
||||
this.core = core;
|
||||
Init();
|
||||
mod = core.RegisterInterface(this, core.App().Fsys_mgr().Bin_extensions_dir().GenSubFil_nest("ParserFunctions", "mw.ext.ParserFunctions.lua"));
|
||||
mod = core.RegisterInterface(this, core.App().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("ParserFunctions", "mw.ext.ParserFunctions.lua"));
|
||||
return mod;
|
||||
}
|
||||
public Scrib_proc_mgr Procs() {return procs;} private Scrib_proc_mgr procs = new Scrib_proc_mgr();
|
||||
|
@ -33,7 +33,7 @@ public class Pfunc_filepath extends Pf_func_base {
|
||||
if (tmp_rslt .Repo_idx() == Byte_.MaxValue_127) return;
|
||||
Xof_repo_itm trg_repo = wiki.File_mgr().Repo_mgr().Repos_get_at(tmp_rslt.Repo_idx()).Trg();
|
||||
xfer_itm.Set__ttl(ttl_bry, Bry_.Empty); // redirect is empty b/c Get_page does all redirect lookups
|
||||
byte[] url = url_bldr.Set_trg_html_(Xof_repo_itm.Mode_orig, trg_repo, ttl_bry, xfer_itm.Lnki_md5(), xfer_itm.Lnki_ext(), Xof_img_size.Size_null_deprecated, Xof_doc_thumb.Null, Xof_doc_page.Null).Xto_bry();
|
||||
byte[] url = url_bldr.Init_for_trg_html(Xof_repo_itm.Mode_orig, trg_repo, ttl_bry, xfer_itm.Lnki_md5(), xfer_itm.Lnki_ext(), Xof_img_size.Size_null_deprecated, Xof_doc_thumb.Null, Xof_doc_page.Null).Xto_bry();
|
||||
bb.Add(url);
|
||||
} private static final byte[] Bry_file = Bry_.new_ascii_("File:");
|
||||
private static final Xof_xfer_itm xfer_itm = new Xof_xfer_itm();
|
||||
|
@ -52,6 +52,7 @@ public class Pp_pages_nde implements Xox_xnde, Xop_xnde_atr_parser {
|
||||
}
|
||||
}
|
||||
public void Xtn_parse(Xow_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
// if (!wiki.Xtn_mgr().Xtn_proofread().Enabled()) return;
|
||||
if (!Init_vars(wiki, ctx, src, xnde)) return;
|
||||
Xoa_page page = ctx.Cur_page();
|
||||
if (page.Pages_recursed()) return; // moved from Pp_index_parser; DATE:2014-05-21s
|
||||
|
@ -21,6 +21,7 @@ public class Pp_pages_nde_basic_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void Init() {
|
||||
Io_mgr._.InitEngine_mem();
|
||||
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
|
||||
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
|
||||
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
|
||||
}
|
||||
@ -95,4 +96,12 @@ public class Pp_pages_nde_basic_tst {
|
||||
, "</p>"
|
||||
));
|
||||
}
|
||||
@Test public void Disable() { // PURPOSE: simulate disabled wiki; PAGE:en.w:Wikipedia:Requests_for_adminship/Phantomsteve DATE:2014-09-08
|
||||
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_n_();
|
||||
fxt.Init_page_create("Page:A/1", "A");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "<pages index=\"A\" from=1 to=1>a</pages>"
|
||||
, "<pages index="A" from=1 to=1>a"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class Pp_pages_nde_hdr_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void Init() {
|
||||
Io_mgr._.InitEngine_mem();
|
||||
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
|
||||
fxt.Wiki().Cache_mgr().Page_cache().Free_mem_all();
|
||||
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
|
||||
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
|
||||
|
@ -21,6 +21,7 @@ public class Pp_pages_nde_index_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void Init() {
|
||||
Io_mgr._.InitEngine_mem();
|
||||
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
|
||||
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
|
||||
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class Pp_pages_nde_recursion_tst {
|
||||
private Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void Init() {
|
||||
Io_mgr._.InitEngine_mem();
|
||||
fxt.Wiki().Xtn_mgr().Xtn_proofread().Enabled_y_();
|
||||
fxt.Wiki().Db_mgr().Load_mgr().Clear(); // must clear; otherwise fails b/c files get deleted, but wiki.data_mgr caches the Xowd_regy_mgr (the .reg file) in memory;
|
||||
fxt.Wiki().Ns_mgr().Add_new(Xowc_xtn_pages.Ns_page_id_default, "Page").Add_new(Xowc_xtn_pages.Ns_index_id_default, "Index").Init();
|
||||
}
|
||||
|
@ -22,5 +22,7 @@ public class Pp_xtn_mgr extends Xox_mgr_base {
|
||||
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_ascii_("ProofreadPages");
|
||||
@Override public Xox_mgr Clone_new() {return new Pp_xtn_mgr();}
|
||||
@Override public void Xtn_init_by_wiki(Xow_wiki wiki) {
|
||||
if (!this.Enabled_manually())
|
||||
this.Enabled_(wiki.Domain_tid() == Xow_wiki_domain_.Tid_wikisource); // only enable for wikisource
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class Score_xnde implements Xox_xnde, Xop_xnde_atr_parser, Xoh_cmd_itm {
|
||||
Xow_wiki wiki = ctx.Wiki(); Xoa_page page = ctx.Cur_page();
|
||||
Score_xtn_mgr score_xtn = (Score_xtn_mgr)wiki.Xtn_mgr().Get_or_fail(Score_xtn_mgr.XTN_KEY);
|
||||
if (!score_xtn.Enabled()) {Html_write_code_as_pre(bfr, app); return;}
|
||||
ProcessAdp ly_process = app.Fsys_mgr().App_mgr().App_lilypond();
|
||||
ProcessAdp ly_process = app.Launcher().App_lilypond();
|
||||
if (ly_process.Exe_exists() == Bool_.__byte && ly_process.Exe_url() != null) { // TEST: ly_process.Exe_url() is null
|
||||
boolean exists = Io_mgr._.ExistsFil(ly_process.Exe_url());
|
||||
ly_process.Exe_exists_(exists ? Bool_.Y_byte : Bool_.N_byte);
|
||||
@ -113,12 +113,12 @@ public class Score_xnde implements Xox_xnde, Xop_xnde_atr_parser, Xoh_cmd_itm {
|
||||
Score_xtn_mgr score_xtn = (Score_xtn_mgr)wiki.Xtn_mgr().Get_or_fail(Score_xtn_mgr.XTN_KEY);
|
||||
Io_url ly_file = output_dir.GenSubFil(sha1_prefix + ".ly");
|
||||
byte[] ly_text = null;
|
||||
ProcessAdp ly_process = app.Fsys_mgr().App_mgr().App_lilypond();
|
||||
ProcessAdp ly_process = app.Launcher().App_lilypond();
|
||||
if (Score_xtn_mgr.Lilypond_version == null) Score_xtn_mgr.Lilypond_version = Get_lilypond_version(ly_process);
|
||||
if (lang_is_abc) {
|
||||
Io_url abc_file = output_dir.GenSubFil(sha1_prefix + ".abc");
|
||||
Io_mgr._.SaveFilBry(abc_file, code);
|
||||
ProcessAdp abc2ly_process = app.Fsys_mgr().App_mgr().App_abc2ly();
|
||||
ProcessAdp abc2ly_process = app.Launcher().App_abc2ly();
|
||||
if (!abc2ly_process.Run(abc_file, ly_file).Exit_code_pass()) {
|
||||
fail_msg = abc2ly_process.Rslt_out();
|
||||
app.Usr_dlg().Warn_many("", "", "abc2ly failed: ~{0}", fail_msg);
|
||||
@ -141,7 +141,7 @@ public class Score_xnde implements Xox_xnde, Xop_xnde_atr_parser, Xoh_cmd_itm {
|
||||
return;
|
||||
}
|
||||
if (output_ogg) {
|
||||
ProcessAdp timidity_process = app.Fsys_mgr().App_mgr().App_convert_midi_to_ogg();
|
||||
ProcessAdp timidity_process = app.Launcher().App_convert_midi_to_ogg();
|
||||
Io_url ogg_file = ly_file.GenNewExt(".ogg");
|
||||
if (!timidity_process.Run(ly_file.GenNewExt(".midi"), ogg_file).Exit_code_pass()) { // NOTE: do not exit; timidity currently not working for windows
|
||||
fail_msg = timidity_process.Rslt_out();
|
||||
@ -152,7 +152,7 @@ public class Score_xnde implements Xox_xnde, Xop_xnde_atr_parser, Xoh_cmd_itm {
|
||||
Io_mgr._.DeleteFil(ly_file);
|
||||
Io_url png_file_untrimmed = png_file.GenNewNameOnly("untrimmed");
|
||||
Io_mgr._.MoveFil(png_file, png_file_untrimmed);
|
||||
app.Fsys_mgr().App_mgr().App_trim_img().Run(png_file_untrimmed, png_file);
|
||||
app.Launcher().App_trim_img().Run(png_file_untrimmed, png_file);
|
||||
Io_mgr._.DeleteFil(png_file_untrimmed);
|
||||
fail_msg = null;
|
||||
} private String fail_msg = null;
|
||||
|
@ -24,7 +24,7 @@ public class Scrib_core {
|
||||
this.app = app; this.ctx = ctx;
|
||||
this.wiki = ctx.Wiki(); this.page = ctx.Cur_page(); // NOTE: wiki / page needed for title reg; DATE:2014-02-05
|
||||
this.Engine_(Scrib_engine_type.Type_lua, false); // TEST: default to lua
|
||||
fsys_mgr.Root_dir_(app.Fsys_mgr().Bin_extensions_dir().GenSubDir_nest("Scribunto"));
|
||||
fsys_mgr.Root_dir_(app.Fsys_mgr().Bin_xtns_dir().GenSubDir_nest("Scribunto"));
|
||||
lib_mw = new Scrib_lib_mw(this);
|
||||
lib_uri = new Scrib_lib_uri(this);
|
||||
lib_ustring = new Scrib_lib_ustring(this);
|
||||
@ -69,7 +69,7 @@ public class Scrib_core {
|
||||
enabled = xtn_mgr.Enabled();
|
||||
Io_url root_dir = fsys_mgr.Root_dir(), script_dir = fsys_mgr.Script_dir();
|
||||
engine.Server().Init
|
||||
( app.Fsys_mgr().App_mgr().App_lua().Exe_url().Raw()
|
||||
( app.Launcher().App_lua().Exe_url().Raw()
|
||||
, root_dir.GenSubFil_nest("engines", "LuaStandalone", "mw_main.lua").Raw()
|
||||
, root_dir.Raw()
|
||||
);
|
||||
|
@ -22,7 +22,7 @@ public class Blacklist_scrib_lib implements Scrib_lib {
|
||||
public Scrib_lib Init() {procs.Init_by_lib(this, Proc_names); return this;}
|
||||
public Scrib_lua_mod Register(Scrib_core core, Io_url script_dir) {
|
||||
Init();
|
||||
mod = core.RegisterInterface(this, core.App().Fsys_mgr().Bin_extensions_dir().GenSubFil_nest("TitleBlacklist", "mw.ext.TitleBlacklist.lua"));
|
||||
mod = core.RegisterInterface(this, core.App().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("TitleBlacklist", "mw.ext.TitleBlacklist.lua"));
|
||||
return mod;
|
||||
}
|
||||
public Scrib_proc_mgr Procs() {return procs;} private Scrib_proc_mgr procs = new Scrib_proc_mgr();
|
||||
|
@ -35,4 +35,10 @@ public class Int_list {
|
||||
ary = Int_.Ary_empty;
|
||||
ary_len = ary_max = 0;
|
||||
}
|
||||
public static Int_list new_(int... ary) {
|
||||
Int_list rv = new Int_list();
|
||||
int len = ary.length;
|
||||
rv.ary = ary; rv.ary_len = len; rv.ary_max = len;
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,9 @@ public class Xow_wiki implements GfoInvkAble {
|
||||
public Xow_wiki(Xoa_app app, Io_url wiki_dir, Xow_ns_mgr ns_mgr, Xol_lang lang) {
|
||||
this.app = app; this.ns_mgr = ns_mgr; this.lang = lang;
|
||||
domain_str = wiki_dir.NameOnly(); domain_bry = Bry_.new_utf8_(domain_str);
|
||||
Xow_wiki_domain domain = Xow_wiki_domain_.parse_by_domain(domain_bry);
|
||||
domain_tid = domain.Tid();
|
||||
domain_itm = Xow_wiki_domain_.parse_by_domain(domain_bry);
|
||||
domain_tid = domain_itm.Tid();
|
||||
xwiki_domain_tid = Xow_wiki_domain_.Xwiki_tid(domain_tid);
|
||||
fsys_mgr = new Xow_fsys_mgr(this, wiki_dir);
|
||||
redirect_mgr = new Xop_redirect_mgr(this);
|
||||
data_mgr = new Xow_data_mgr(this);
|
||||
@ -72,6 +73,8 @@ public class Xow_wiki implements GfoInvkAble {
|
||||
public String Domain_str() {return domain_str;} private String domain_str;
|
||||
public byte Domain_tid() {return domain_tid;} private byte domain_tid;
|
||||
public byte[] Domain_abrv() {return domain_abrv;} private byte[] domain_abrv;
|
||||
public Xow_wiki_domain Domain_itm() {return domain_itm;} private Xow_wiki_domain domain_itm;
|
||||
public byte Xwiki_domain_tid() {return xwiki_domain_tid;} private byte xwiki_domain_tid;
|
||||
public Xol_lang Lang() {return lang;} private Xol_lang lang;
|
||||
public Xow_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xow_fsys_mgr fsys_mgr;
|
||||
public Xow_utl_mgr Utl_mgr() {return utl_mgr;} private Xow_utl_mgr utl_mgr;
|
||||
|
@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa; import gplx.*;
|
||||
public class Xol_lang_itm {
|
||||
public Xol_lang_itm(int id, byte[] key, byte[] canonical_name) {this.id = id; this.key = key; this.canonical_name = canonical_name; this.local_name = canonical_name;}
|
||||
public int Id() {return id;} private int id;
|
||||
public byte[] Key() {return key;} private byte[] key;
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public byte[] Canonical_name() {return canonical_name;} private byte[] canonical_name;
|
||||
public byte[] Local_name() {return local_name;} private byte[] local_name;
|
||||
public byte[] Local_grp() {return local_grp;} private byte[] local_grp = Bry_.Empty;
|
||||
|
@ -854,9 +854,9 @@ Regy_add(regy, Id_zu, "zu", "isiZulu");
|
||||
}
|
||||
return regy;
|
||||
}
|
||||
private static Hash_adp_bry regy; static Xol_lang_itm[] langs = new Xol_lang_itm[Id__max];
|
||||
private static Hash_adp_bry regy; private static Xol_lang_itm[] langs = new Xol_lang_itm[Id__max];
|
||||
private static void Regy_add(Hash_adp_bry regy, int id, String code_str, String canonical) {
|
||||
byte[] code = Bry_.new_utf8_(code_str);
|
||||
byte[] code = Bry_.new_ascii_(code_str); // ASCII:lang_code should always be ASCII
|
||||
Xol_lang_itm itm = new Xol_lang_itm(id, code, Bry_.new_utf8_(canonical));
|
||||
langs[id] = itm;
|
||||
regy.Add(code, itm);
|
||||
|
@ -24,7 +24,7 @@ public class Xof_img_mgr {
|
||||
public int Thumb_w_img() {return thumb_w_img;} private int thumb_w_img = Xof_img_size.Thumb_width_img;
|
||||
public int Thumb_w_ogv() {return thumb_w_ogv;} private int thumb_w_ogv = Xof_img_size.Thumb_width_ogv;
|
||||
public void Init_app(Xoa_app app) {
|
||||
Launcher_app_mgr app_mgr = app.Fsys_mgr().App_mgr();
|
||||
Launcher_app_mgr app_mgr = app.Launcher();
|
||||
wkr_query_img_size = new Xof_img_wkr_query_img_size_imageMagick(app, app_mgr.App_query_img_size());
|
||||
wkr_resize_img = new Xof_img_wkr_resize_img_imageMagick(app, app_mgr.App_resize_img(), app_mgr.App_convert_svg_to_png());
|
||||
wkr_convert_djvu_to_tiff = new Xof_img_wkr_convert_djvu_to_tiff_app(app_mgr.App_convert_djvu_to_tiff());
|
||||
|
@ -348,8 +348,8 @@ public class Xof_xfer_mgr {
|
||||
file_w = file_size.Width(); file_h = file_size.Height();
|
||||
return true;
|
||||
}
|
||||
String Src_url(Xof_repo_itm repo, byte mode, int lnki_w) {return url_bldr.Set_src_file_(mode, repo, ttl, md5, ext, lnki_w, lnki_thumbtime, lnki_page).Xto_str();}
|
||||
Io_url Trg_url(Xof_repo_itm repo, byte mode, int lnki_w) {return url_bldr.Set_trg_file_(mode, repo, ttl, md5, ext, lnki_w, lnki_thumbtime, lnki_page).Xto_url();}
|
||||
String Src_url(Xof_repo_itm repo, byte mode, int lnki_w) {return url_bldr.Init_for_src_file(mode, repo, ttl, md5, ext, lnki_w, lnki_thumbtime, lnki_page).Xto_str();}
|
||||
Io_url Trg_url(Xof_repo_itm repo, byte mode, int lnki_w) {return url_bldr.Init_for_trg_file(mode, repo, ttl, md5, ext, lnki_w, lnki_thumbtime, lnki_page).Xto_url();}
|
||||
private Xof_url_bldr url_bldr = new Xof_url_bldr();
|
||||
}
|
||||
/*
|
||||
|
@ -118,7 +118,7 @@ public class Xoi_cmd_mgr implements GfoInvkAble {
|
||||
Gfo_thread_cmd Cmd_new(GfoMsg m) {
|
||||
String cmd_key = m.ReadStr("v");
|
||||
if (String_.Eq(cmd_key, Gfo_thread_cmd_download.KEY)) return new Gfo_thread_cmd_download().Init("downloading", m.ReadStr("src"), Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("trg"))).Url_eval_mgr_(app.Url_cmd_eval()).Owner_(this).Ctor(app.Usr_dlg(), app.Gui_mgr().Kit());
|
||||
else if (String_.Eq(cmd_key, Gfo_thread_cmd_unzip.KEY)) return new Gfo_thread_cmd_unzip().Url_eval_mgr_(app.Url_cmd_eval()).Owner_(this).Init(app.Usr_dlg(), app.Gui_mgr().Kit(), app.Fsys_mgr().App_mgr().App_decompress_bz2(), app.Fsys_mgr().App_mgr().App_decompress_zip(), app.Fsys_mgr().App_mgr().App_decompress_gz(), Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("src")), Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("trg")));
|
||||
else if (String_.Eq(cmd_key, Gfo_thread_cmd_unzip.KEY)) return new Gfo_thread_cmd_unzip().Url_eval_mgr_(app.Url_cmd_eval()).Owner_(this).Init(app.Usr_dlg(), app.Gui_mgr().Kit(), app.Launcher().App_decompress_bz2(), app.Launcher().App_decompress_zip(), app.Launcher().App_decompress_gz(), Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("src")), Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("trg")));
|
||||
else if (String_.Eq(cmd_key, Gfo_thread_cmd_replace.KEY)) return new Gfo_thread_cmd_replace().Url_eval_mgr_(app.Url_cmd_eval()).Owner_(this).Init(app.Usr_dlg(), app.Gui_mgr().Kit(), Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("fil")));
|
||||
else if (String_.Eq(cmd_key, Xoi_cmd_wiki_image_cfg.KEY_dump)) return new Xoi_cmd_wiki_image_cfg(app, Bry_fmtr_eval_mgr_.Eval_url(app.Url_cmd_eval(), m.ReadBry("fil"))).Owner_(this);
|
||||
else if (String_.Eq(cmd_key, Xoi_cmd_wiki_goto_page.KEY)) return new Xoi_cmd_wiki_goto_page(app, m.ReadStr("v")).Owner_(this);
|
||||
|
@ -65,7 +65,7 @@ class Xoi_cmd_wiki_unzip extends Gfo_thread_cmd_unzip implements Gfo_thread_cmd
|
||||
}
|
||||
Io_url src = urls[urls.length - 1];
|
||||
Io_url trg = app.Fsys_mgr().Wiki_dir().GenSubFil_nest(wiki_key, src.NameOnly()); // NOTE: NameOnly() will strip trailing .bz2; EX: a.xml.bz2 -> a.xml
|
||||
super.Init(app.Usr_dlg(), app.Gui_mgr().Kit(), app.Fsys_mgr().App_mgr().App_decompress_bz2(), app.Fsys_mgr().App_mgr().App_decompress_zip(), app.Fsys_mgr().App_mgr().App_decompress_gz(), src, trg);
|
||||
super.Init(app.Usr_dlg(), app.Gui_mgr().Kit(), app.Launcher().App_decompress_bz2(), app.Launcher().App_decompress_zip(), app.Launcher().App_decompress_gz(), src, trg);
|
||||
this.Term_cmd_for_src_(Term_cmd_for_src_move);
|
||||
this.Term_cmd_for_src_url_(app.Fsys_mgr().Wiki_dir().GenSubFil_nest("#dump", "done", src.NameAndExt()));
|
||||
if (Io_mgr._.ExistsFil(trg)) {
|
||||
|
@ -21,7 +21,7 @@ import gplx.brys.*; import gplx.threads.*; import gplx.xowa.wikis.*;
|
||||
public class Xoi_cmd_wiki_tst {
|
||||
@Test public void Run() {
|
||||
// Bld_import_list(Wikis);
|
||||
// Bld_cfg_files(Wikis); // NOTE: remember to carry over the wikisource / page / index commands from the existing xowa_build_cfg.gfs; also, only run the xowa_build_cfg.gfs once; DATE:2013-10-15
|
||||
// Bld_cfg_files(Wikis); // NOTE: remember to carry over the wikisource / page / index commands from the existing xowa_build_cfg.gfs; also, only run the xowa_build_cfg.gfs once; DATE:2013-10-15; last run: DATE:2014-09-09
|
||||
}
|
||||
public void Bld_import_list(String... ary) {
|
||||
int ary_len = ary.length;
|
||||
@ -82,7 +82,7 @@ public class Xoi_cmd_wiki_tst {
|
||||
ConsoleAdp._.WriteLine(Err_.Message_gplx_brief(e));
|
||||
}
|
||||
}
|
||||
bfr.Add_str("app.wiki_cfg_bldr.run;").Add_byte_nl();
|
||||
bfr.Add_str("app.bldr.wiki_cfg_bldr.run;").Add_byte_nl();
|
||||
Io_mgr._.SaveFilStr("C:\\xowa_build_cfg.gfs", bfr.XtoStr());
|
||||
}
|
||||
public static String[] Wikis = new String[]
|
||||
|
@ -24,7 +24,7 @@ public class Xoa_page {
|
||||
Xoa_page(Xow_wiki wiki, Xoa_ttl ttl) {
|
||||
this.wiki = wiki; this.ttl = ttl;
|
||||
this.app = wiki.App(); this.lang = wiki.Lang(); // default to wiki.lang; can be override later by wikitext
|
||||
hdump_data = new Xopg_hdump_data(app);
|
||||
hdump_data = new Xopg_hdump_data();
|
||||
hdr_mgr = new Xow_hdr_mgr(wiki, this);
|
||||
lnki_redlinks_mgr = new Xop_lnki_logger_redlinks_mgr(this);
|
||||
Ttl_(ttl);
|
||||
|
@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa; import gplx.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.net.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.net.*; import gplx.xowa.files.*;
|
||||
public class Xoa_url_parser {
|
||||
private Url_encoder encoder = Url_encoder.new_html_href_mw_().Itms_raw_same_many(Byte_ascii.Underline); private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
public Gfo_url_parser Url_parser() {return url_parser;} private Gfo_url_parser url_parser = new Gfo_url_parser(); private Gfo_url gfo_url = new Gfo_url();
|
||||
@ -151,7 +151,7 @@ public class Xoa_url_parser {
|
||||
if (Bry_.Len_gt_0(wiki_bry)) { // NOTE: wiki_bry null when passing in Category:A from home_wiki
|
||||
Xow_xwiki_itm xwiki_itm = app.User().Wiki().Xwiki_mgr().Get_by_key(wiki_bry); // see if url.Wiki_bry is actually wiki;
|
||||
if ( xwiki_itm != null // null-check
|
||||
&& !xwiki_itm.Type_is_lang(cur_wiki.Lang().Lang_id())) // in xwiki, but not lang; EX: "fr.wikipedia.org" vs "fr"; ca.s:So/Natura_del_so; DATE:2014-04-26
|
||||
&& !xwiki_itm.Type_is_xwiki_lang(cur_wiki.Lang().Lang_id())) // in xwiki, but not lang; EX: "fr.wikipedia.org" vs "fr"; ca.s:So/Natura_del_so; DATE:2014-04-26
|
||||
wiki = app.Wiki_mgr().Get_by_key_or_make(xwiki_itm.Domain());
|
||||
}
|
||||
if (rv.Page_bry() == null) { // 1 seg; EX: "Earth"; "fr.wikipedia.org"
|
||||
@ -214,7 +214,7 @@ public class Xoa_url_parser {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, page_bry);
|
||||
if (ttl != null) { // can still be empty; EX: "en.wikipedia.org"
|
||||
Xow_xwiki_itm lang_xwiki = ttl.Wik_itm();
|
||||
if (lang_xwiki != null && lang_xwiki.Type_is_lang(wiki.Lang().Lang_id())) { // format of http://en.wikipedia.org/wiki/fr:A
|
||||
if (lang_xwiki != null && lang_xwiki.Type_is_xwiki_lang(wiki.Lang().Lang_id())) { // format of http://en.wikipedia.org/wiki/fr:A
|
||||
wiki = app.Wiki_mgr().Get_by_key_or_make(lang_xwiki.Domain());
|
||||
page_bry = ttl.Page_txt();
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ public class Xop_fxt {
|
||||
}
|
||||
public static void Reg_xwiki_alias(Xow_wiki wiki, String alias, String domain) {
|
||||
byte[] domain_bry = Bry_.new_ascii_(domain);
|
||||
wiki.Xwiki_mgr().Add_full(Bry_.new_ascii_(alias), domain_bry);
|
||||
wiki.Xwiki_mgr().Add_full(Bry_.new_ascii_(alias), domain_bry, Bry_.Add(domain_bry, Bry_.new_ascii_("/wiki/~{0}")));
|
||||
wiki.App().User().Wiki().Xwiki_mgr().Add_full(domain_bry, domain_bry);
|
||||
}
|
||||
public static String html_img_none(String trg, String alt, String src, String ttl) {
|
||||
|
@ -261,52 +261,6 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
, ""
|
||||
));
|
||||
}
|
||||
@Test public void Xwiki_file() { // PURPOSE: if xwiki and File, ignore xwiki (hackish); DATE:2013-12-22
|
||||
Reg_xwiki_alias("test", "test.wikimedia.org"); // must register xwiki, else ttl will not parse it
|
||||
fxt.Wiki().Cfg_parser().Lnki_cfg().Xwiki_repo_mgr().Add_or_mod(Bry_.new_ascii_("test")); // must add to xwiki_repo_mgr
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[test:File:A.png|12x10px]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xowa_file_img_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/12px.png\" width=\"12\" height=\"10\" /></a>"
|
||||
));
|
||||
fxt.Wiki().Cfg_parser_lnki_xwiki_repos_enabled_(false); // disable for other tests
|
||||
}
|
||||
@Test public void Xwiki_anchor() {
|
||||
Reg_xwiki_alias("test", "test.wikimedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[test:A#b]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/site/test.wikimedia.org/wiki/A#b\">test:A#b</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Xwiki_empty() {
|
||||
Reg_xwiki_alias("test", "test.wikimedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[test:]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/site/test.wikimedia.org/wiki/\">test:</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Xwiki_empty_literal() {
|
||||
Reg_xwiki_alias("test", "test.wikimedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[:test:]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/site/test.wikimedia.org/wiki/\">test:</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Xwiki_not_registered() {
|
||||
fxt.App().User().Wiki().Xwiki_mgr().Clear();
|
||||
fxt.Wiki().Xwiki_mgr().Add_full(Bry_.new_ascii_("test"), Bry_.new_ascii_("test.wikimedia.org")); // register alias only, but not in user_wiki
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[test:A|A]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"http://test.wikimedia.org/wiki/A\">A</a>"
|
||||
));
|
||||
}
|
||||
@Test public void Literal_lang() {
|
||||
Reg_xwiki_alias("fr", "fr.wikipedia.org");
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[:fr:A]]", String_.Concat_lines_nl_skip_last
|
||||
( "<a href=\"/site/fr.wikipedia.org/wiki/A\">A</a>"
|
||||
));
|
||||
Tfds.Eq(0, fxt.Page().Xwiki_langs().Count());
|
||||
}
|
||||
@Test public void Html_ent_pound() {
|
||||
fxt.Test_parse_page_wiki_str
|
||||
( "[[A#b|c]]", String_.Concat_lines_nl_skip_last
|
||||
@ -323,9 +277,6 @@ public class Xop_lnki_wkr__basic_tst {
|
||||
fxt.Test_parse_page_wiki_str("[[Page1|]]" , "<a href=\"/wiki/Page1\">Page1</a>");
|
||||
fxt.Test_parse_page_wiki_str("[[Help:Page1|]]" , "<a href=\"/wiki/Help:Page1\">Page1</a>");
|
||||
}
|
||||
private void Reg_xwiki_alias(String alias, String domain) {
|
||||
Xop_fxt.Reg_xwiki_alias(fxt.Wiki(), alias, domain);
|
||||
}
|
||||
@Test public void Thumb_first_align_trumps_all() { // PURPOSE: if there are multiple alignment instructions, take the first EX:[[File:A.png|thumb|center|left]] DATE:20121226
|
||||
fxt.Test_parse_page_wiki_str("[[File:A.png|thumb|right|center]]" // NOTE: right trumps center
|
||||
, String_.Concat_lines_nl_skip_last
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user