1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00
This commit is contained in:
gnosygnu 2015-04-19 12:33:25 -04:00
parent 551120b906
commit 299e19d455
74 changed files with 1267 additions and 719 deletions

View File

@ -19,6 +19,6 @@ package gplx;
public class Guid_adp_ {
public static final String Cls_ref_name = "Guid";
public static final Guid_adp Empty = parse_("00000000-0000-0000-0000-000000000000");
public static Guid_adp random_() {return new Guid_adp(java.util.UUID.randomUUID());}
public static Guid_adp new_() {return new Guid_adp(java.util.UUID.randomUUID());}
public static Guid_adp parse_(String s) {return new Guid_adp(java.util.UUID.fromString(s));}
}

View File

@ -49,7 +49,7 @@ public class IoEngine_xrg_recycleFil extends IoEngine_xrg_fil_affects1_base {
public IoEngine_xrg_recycleFil(int v) {
mode = v;
time = DateAdp_.Now();
uuid = Guid_adp_.random_();
uuid = Guid_adp_.new_();
rootDirNames = ListAdp_.new_(); rootDirNames.Add("z_trash");
}
public static IoEngine_xrg_recycleFil sysm_(Io_url url) {return new IoEngine_xrg_recycleFil(SysmConst);}

View File

@ -89,25 +89,25 @@ public class GfsCore implements GfoInvkAble {
}
class GfsCore_ {
public static final String Arg_primitive = "v";
public static Object Exec(GfsCtx ctx, GfoInvkAble ownerInvk, GfoMsg ownerMsg, Object ownerPrimitive, int depth) {
if (ownerMsg.Args_count() == 0 && ownerMsg.Subs_count() == 0 && String_.Eq(ownerMsg.Key(), "")) {UsrDlg_._.Warn("empty msg"); return GfoInvkAble_.Rv_unhandled;}
if (ownerPrimitive != null) ownerMsg.Parse_(false).Add(GfsCore_.Arg_primitive, ownerPrimitive);
Object rv = ownerInvk.Invk(ctx, 0, ownerMsg.Key(), ownerMsg);
public static Object Exec(GfsCtx ctx, GfoInvkAble owner_invk, GfoMsg owner_msg, Object owner_primitive, int depth) {
if (owner_msg.Args_count() == 0 && owner_msg.Subs_count() == 0 && String_.Eq(owner_msg.Key(), "")) {UsrDlg_._.Warn("empty msg"); return GfoInvkAble_.Rv_unhandled;}
if (owner_primitive != null) owner_msg.Parse_(false).Add(GfsCore_.Arg_primitive, owner_primitive);
Object rv = owner_invk.Invk(ctx, 0, owner_msg.Key(), owner_msg);
if (rv == GfoInvkAble_.Rv_cancel) return rv;
else if (rv == GfoInvkAble_.Rv_unhandled) {
if (ctx.Fail_if_unhandled())
throw Err_.new_("Object does not support key").Add("key", ownerMsg.Key()).Add("ownerType", ClassAdp_.FullNameOf_obj(ownerInvk));
throw Err_.new_("Object does not support key").Add("key", owner_msg.Key()).Add("ownerType", ClassAdp_.FullNameOf_obj(owner_invk));
else {
Gfo_usr_dlg usr_dlg = ctx.Usr_dlg();
if (usr_dlg != null) usr_dlg.Warn_many(GRP_KEY, "unhandled_key", "Object does not support key: key=~{0} ownerType=~{1}", ownerMsg.Key(), ClassAdp_.FullNameOf_obj(ownerInvk));
if (usr_dlg != null) usr_dlg.Warn_many(GRP_KEY, "unhandled_key", "Object does not support key: key=~{0} ownerType=~{1}", owner_msg.Key(), ClassAdp_.FullNameOf_obj(owner_invk));
return GfoInvkAble_.Null;
}
}
if (ownerMsg.Subs_count() == 0) { // msg is leaf
if (owner_msg.Subs_count() == 0) { // msg is leaf
GfsRegyItm regyItm = GfsRegyItm.as_(rv);
if (regyItm == null) return rv; // rv is primitive or other non-regy Object
if (regyItm.IsCmd()) // rv is cmd; invk cmd
return regyItm.InvkAble().Invk(ctx, 0, ownerMsg.Key(), ownerMsg);
return regyItm.InvkAble().Invk(ctx, 0, owner_msg.Key(), owner_msg);
else // rv is host
return regyItm.InvkAble();
}
@ -123,9 +123,9 @@ class GfsCore_ {
primitive = rv;
}
Object exec_rv = null;
int len = ownerMsg.Subs_count();
int len = owner_msg.Subs_count();
for (int i = 0; i < len; i++) // iterate over subs; needed for a{b;c;d;}
exec_rv = Exec(ctx, invk, ownerMsg.Subs_getAt(i), primitive, depth + 1);
exec_rv = Exec(ctx, invk, owner_msg.Subs_getAt(i), primitive, depth + 1);
return exec_rv;
}
}

View File

@ -20,7 +20,7 @@ public interface Gfui_kit extends GfoInvkAble {
byte Tid();
String Key();
void Cfg_set(String type, String key, Object val);
boolean Kit_init_done();
boolean Kit_mode__ready();
void Kit_init(Gfo_usr_dlg gui_wtr);
void Kit_run();
void Kit_term();

View File

@ -25,7 +25,7 @@ public abstract class Gfui_kit_base implements Gfui_kit {
public Gfui_clipboard Clipboard() {return Gfui_clipboard_null.Null;}
public GfoInvkAbleCmd Kit_term_cbk() {return kit_term_cbk;} public void Kit_term_cbk_(GfoInvkAbleCmd v) {kit_term_cbk = v;} private GfoInvkAbleCmd kit_term_cbk;
public void Cfg_set(String type, String key, Object val) {}
public boolean Kit_init_done() {return true;}
public boolean Kit_mode__ready() {return true;}
public void Kit_init(Gfo_usr_dlg gui_wtr) {}
@gplx.Virtual public void Kit_run() {}
@gplx.Virtual public void Kit_term() {kit_term_cbk.Invk();}

View File

@ -42,46 +42,40 @@ 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;
import gplx.threads.*;
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 Swt_msg_wkr_stop msg_wkr_stop;
private KeyValHash nullArgs = KeyValHash.new_();
private final KeyValHash ctor_args = KeyValHash.new_(); private final KeyValHash ctor_args_null = KeyValHash.new_();
private final HashAdp kit_args = HashAdp_.new_(); private Swt_msg_wkr_stop msg_wkr_stop;
private Gfo_usr_dlg gui_wtr; private String xul_runner_path = null;
private final Bry_fmtr ask_fmtr = Bry_fmtr.new_().Fail_when_invalid_escapes_(false); private final Bry_bfr ask_bfr = Bry_bfr.new_();
private final Object thread_lock = new Object();
public byte Tid() {return Gfui_kit_.Swt_tid;}
public String Key() {return "swt";}
Display Swt_display() {return display;} private Display display;
public Display Swt_display() {return display;} private Display display;
public Shell Swt_shell() {return shell;} private Shell shell;
public Gfui_clipboard Clipboard() {return clipboard;} private Swt_clipboard clipboard;
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 int Kit_mode() {synchronized (thread_lock) {return mode;}} private int mode = Swt_kit_mode.Tid_ctor;
public void Kit_mode_(int v) {synchronized (thread_lock) {mode = v;}}
public boolean Kit_mode__ready() {return Kit_mode() == Swt_kit_mode.Tid_ready;}
public boolean Kit_mode__term() {return Kit_mode() == Swt_kit_mode.Tid_term;}
public boolean Kit_sync_cmd_exists() {synchronized (thread_lock) {return sync_cmd_list.Count() != 0;}} private final ListAdp sync_cmd_list = ListAdp_.new_();
public void Kit_sync_cmd_add(Swt_gui_cmd cmd) {synchronized (thread_lock) {sync_cmd_list.Add(cmd);}}
public void Kit_sync_cmd_del(Swt_gui_cmd cmd) {synchronized (thread_lock) {sync_cmd_list.Del(cmd);}}
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)) {
if (String_.Eq(key, "XulRunnerPath")) {
xulRunnerPath = (String)val;
return;
}
}
KeyValHash typeCfg = (KeyValHash)kit_args.Fetch(type);
if (typeCfg == null) {
typeCfg = KeyValHash.new_();
kit_args.Add(type, typeCfg);
}
typeCfg.AddReplace(key, val);
}
public boolean Kit_init_done() {return kit_init_done;} private boolean kit_init_done;
public Gfui_html_cfg Html_cfg() {return html_cfg;} private final Gfui_html_cfg html_cfg = new Gfui_html_cfg();
public void Kit_init(Gfo_usr_dlg gui_wtr) {
this.gui_wtr = gui_wtr;
msg_wkr_stop = new Swt_msg_wkr_stop(this, gui_wtr);
display = new Display();
clipboard = new Swt_clipboard(display);
this.msg_wkr_stop = new Swt_msg_wkr_stop(this, gui_wtr);
this.display = new Display();
this.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;
if (xul_runner_path != null) System.setProperty("org.eclipse.swt.browser.XULRunnerPath", xul_runner_path);
this.Kit_mode_(Swt_kit_mode.Tid_ready);
gui_wtr.Log_many("", "", "swt.kit.init.done");
} private Gfo_usr_dlg gui_wtr;
}
public void Kit_run() {
shell.addListener(SWT.Close, new Swt_shell_close_lnr(this));
shell.addListener(SWT.Close, new Swt_shell_close_lnr(this, gui_wtr));
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
@ -92,12 +86,24 @@ 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");
}
public Shell Main_shell() {return shell;}
public void Kit_term() {
clipboard.Rls(); gui_wtr.Log_many("", "", "swt.kit.term:clipboard");
msg_wkr_stop.Rls(); gui_wtr.Log_many("", "", "swt.kit.term:usrMsgWkr");
shell.close();
}
public void Cfg_set(String type, String key, Object val) {
// XulRunnerPath gets set immediately; do not add to widget_cfg_hash
if (String_.Eq(type, Gfui_kit_.Cfg_HtmlBox) && String_.Eq(key, "XulRunnerPath")) {
this.xul_runner_path = (String)val;
return;
}
// add kv to widget_cfg_hash; new controls will get properties from cfg_hash
KeyValHash widget_cfg_hash = (KeyValHash)kit_args.Fetch(type);
if (widget_cfg_hash == null) {
widget_cfg_hash = KeyValHash.new_();
kit_args.Add(type, widget_cfg_hash);
}
widget_cfg_hash.AddReplace(key, val);
}
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);
@ -107,7 +113,7 @@ public class Swt_kit implements Gfui_kit {
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_ok, Gfui_dlg_msg_.Btn_cancel).Init_ico_(Gfui_dlg_msg_.Ico_question);
display.syncExec(dlg);
return dlg.Ask_rslt == Gfui_dlg_msg_.Btn_ok;
} Bry_fmtr ask_fmtr = Bry_fmtr.new_().Fail_when_invalid_escapes_(false); Bry_bfr ask_bfr = Bry_bfr.new_();
}
public int Ask_yes_no_cancel(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, Gfui_dlg_msg_.Btn_cancel).Init_ico_(Gfui_dlg_msg_.Ico_question);
display.syncExec(dlg);
@ -119,13 +125,12 @@ public class Swt_kit implements Gfui_kit {
}
public GfuiInvkCmd New_cmd_sync (GfoInvkAble invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, Bool_.N);}
public GfuiInvkCmd New_cmd_async(GfoInvkAble invk) {return new Swt_gui_cmd(this, gui_wtr, display, invk, Bool_.Y);}
public GfuiWin New_win_utl(String key, GfuiWin owner, KeyVal... args) {return GfuiWin_.kit_(this, key, new Swt_win(shell), nullArgs); }
public GfuiWin New_win_utl(String key, GfuiWin owner, KeyVal... args) {return GfuiWin_.kit_(this, key, new Swt_win(shell), ctor_args_null); }
public GfuiWin New_win_app(String key, KeyVal... args) {
Swt_win win = new Swt_win(display);
this.shell = win.UnderShell();
shell.setLayout(null);
GfuiWin rv = GfuiWin_.kit_(this, key, win, nullArgs);
return rv;
return GfuiWin_.kit_(this, key, win, ctor_args_null);
}
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);
@ -134,18 +139,18 @@ public class Swt_kit implements Gfui_kit {
}
public Gfui_html New_html(String key, GfuiElem owner, KeyVal... args) {
ctor_args.Clear();
Object htmlBox_args_obj = kit_args.Fetch(Gfui_kit_.Cfg_HtmlBox);
if (htmlBox_args_obj != null) {
KeyValHash htmlBox_args = (KeyValHash)htmlBox_args_obj;
KeyVal browser_type = htmlBox_args.FetchOrNull(Cfg_Html_BrowserType);
// check cfg for browser type
KeyValHash html_cfg_args = (KeyValHash)kit_args.Fetch(Gfui_kit_.Cfg_HtmlBox);
if (html_cfg_args != null) {
KeyVal browser_type = html_cfg_args.FetchOrNull(Cfg_Html_BrowserType);
if (browser_type != null) ctor_args.Add(browser_type);
}
Swt_html html_control = new Swt_html(this, Swt_control_.cast_or_fail(owner), ctor_args);
Gfui_html rv = Gfui_html.kit_(this, key, html_control, ctor_args);
((Swt_html)rv.UnderElem()).Under_control().addMenuDetectListener(new Swt_lnr__menu_detect(rv));
rv.Owner_(owner);
html_control.Delete_elems_(owner, rv);
return rv;
Swt_html swt_html = new Swt_html(this, Swt_control_.cast_or_fail(owner), ctor_args);
Gfui_html gfui_html = Gfui_html.kit_(this, key, swt_html, ctor_args);
swt_html.Under_control().addMenuDetectListener(new Swt_lnr__menu_detect(gfui_html));
gfui_html.Owner_(owner);
swt_html.Delete_elems_(owner, gfui_html);
return gfui_html;
}
public Gfui_tab_mgr New_tab_mgr(String key, GfuiElem owner, KeyVal... args) {
ctor_args.Clear();
@ -199,20 +204,11 @@ public class Swt_kit implements Gfui_kit {
return 8;
}
}
public boolean Window_is_disposed() {
return shell.isDisposed();
}
public void Set_mnu_popup(GfuiElem owner, Gfui_mnu_grp grp) {
Control control = Swt_control_.cast_or_fail(owner).Under_menu_control();
Swt_popup_grp popup = (Swt_popup_grp)grp;
control.setMenu(popup.Under_menu());
}
public static final Swt_kit _ = new Swt_kit(); private Swt_kit() {} // singleton b/c of following line "In particular, some platforms which SWT supports will not allow more than one active display" (http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html)
public static final String Cfg_Html_BrowserType = "BrowserType";
public static int Cfg_Html_BrowserType_parse(String v) {
if (String_.Eq(v, "mozilla")) return Swt_html.Browser_tid_mozilla;
else return Swt_html.Browser_tid_none;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (String_.Eq(k, Invk_Cfg_add)) {
String type = m.ReadStrOr("type", "");
@ -221,16 +217,24 @@ public class Swt_kit implements Gfui_kit {
if (ctx.Deny()) return this;
if (String_.Eq(type, Gfui_kit_.Cfg_HtmlBox)) {
if (String_.Eq(key, "XulRunnerPath"))
xulRunnerPath = val;
xul_runner_path = val;
else if (String_.Eq(key, Swt_kit.Cfg_Html_BrowserType))
Cfg_set(type, Swt_kit.Cfg_Html_BrowserType, Cfg_Html_BrowserType_parse(val));
}
}
else if (String_.Eq(k, Invk_HtmlBox)) {return html_cfg;}
else if (String_.Eq(k, Invk_ask_file)) return this.New_dlg_file(Gfui_kit_.File_dlg_type_open, m.Args_getAt(0).Val_to_str_or_empty()).Ask();
else if (String_.Eq(k, Invk_shell_close)) shell.close();
return this;
} public static final String Invk_Cfg_add = "Cfg_add", Invk_HtmlBox = "HtmlBox", Invk_ask_file = "ask_file";
public static boolean Html_box_focus_automatically = false;
}
public static final String Invk_Cfg_add = "Cfg_add", Invk_HtmlBox = "HtmlBox", Invk_ask_file = "ask_file"; // private or public?
public static final String Invk_shell_close = "shell_close"; // public
public static final Swt_kit _ = new Swt_kit(); private Swt_kit() {} // singleton b/c of following line "In particular, some platforms which SWT supports will not allow more than one active display" (http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/widgets/Display.html)
public static final String Cfg_Html_BrowserType = "BrowserType";
public static int Cfg_Html_BrowserType_parse(String v) {
if (String_.Eq(v, "mozilla")) return Swt_html.Browser_tid_mozilla;
else return Swt_html.Browser_tid_none;
}
public static FontAdp Control_font_get(Font font, GxwCore_base owner) {
FontData fontData = font.getFontData()[0];
FontAdp rv = FontAdp.new_(fontData.getName(), fontData.getHeight(), FontStyleAdp_.lang_(fontData.getStyle())); // NOTE: swt style constants match swing
@ -244,27 +248,53 @@ public class Swt_kit implements Gfui_kit {
control.setFont(rv);
}
}
class Swt_shell_close_lnr implements Listener {
public Swt_shell_close_lnr(Swt_kit kit) {this.kit = kit;} private Swt_kit kit;
class Swt_shell_close_lnr implements Listener, GfoInvkAble {
private final Swt_kit kit; private final Gfo_usr_dlg usr_dlg;
public Swt_shell_close_lnr(Swt_kit kit, Gfo_usr_dlg usr_dlg) {this.kit = kit; this.usr_dlg = usr_dlg;}
@Override public void handleEvent(Event event) {
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
if (kit.Kit_mode__term()) return; // NOTE: will be term if called again from wait_for_sync_cmd
kit.Kit_mode_(Swt_kit_mode.Tid_term); // NOTE: must mark kit as shutting down, else writing to status_bar will create stack overflow; DATE:2014-05-05
boolean rslt = Bool_.cast_(kit.Kit_term_cbk().Invk()); // call bgn term
if (!rslt) {
event.doit = false; // cbk canceled term; stop close
kit.Kit_mode_(Swt_kit_mode.Tid_ready); // reset kit back to "running" mode;
return;
}
if (kit.Kit_sync_cmd_exists()) { // sync cmd is running; cannot shut down app else app just hangs; DATE:2015-04-13
event.doit = false; // cancel shutdown
ThreadAdp_.invk_(this, Invk_wait_for_sync_cmd).Start(); // wait for sync_cmd to end in background thread; call shutdown again when it does
}
}
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();
kit.Ask_ok("xowa.gui", "stop", msg);
gui_wtr.Log_many("", "", msg);
private void Wait_for_sync_cmd() { // THREAD:non-GUI
int loop_count = 0, loop_max = 50, loop_wait = 100; // loop for 100 ms for no more than 5 seconds
while (loop_count < loop_max) {
usr_dlg.Log_many("", "", "swt:waiting for sync cmd; loop=~{0}", loop_count);
if (!kit.Kit_sync_cmd_exists()) {
usr_dlg.Log_many("", "", "swt:sync cmd done; shutting down");
break;
}
ThreadAdp_.Sleep(loop_wait);
loop_count++;
}
if (loop_count == loop_max)
usr_dlg.Log_many("", "", "swt:sync_wait failed", loop_count);
GfoInvkAble_.InvkCmd(kit.New_cmd_sync(kit), Swt_kit.Invk_shell_close); // shutdown again; note that cmd must be called on GUI thread
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_wait_for_sync_cmd)) Wait_for_sync_cmd();
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_wait_for_sync_cmd = "wait_for_sync_cmd";
}
class Swt_kit_mode {
public static final int
Tid_ctor = 0
, Tid_ready = 1
, Tid_term = 2
;
}
class Swt_gui_cmd implements GfuiInvkCmd, Runnable {
private Swt_kit kit; private Gfo_usr_dlg usr_dlg; private GfoInvkAble target; private Display display; private boolean async;
private final Swt_kit kit; private final Gfo_usr_dlg usr_dlg; private final Display display; private final GfoInvkAble target; private final boolean async;
private GfsCtx invk_ctx; private int invk_ikey; private String invk_key; private GfoMsg invk_msg;
public Swt_gui_cmd(Swt_kit kit, Gfo_usr_dlg usr_dlg, Display display, GfoInvkAble target, boolean async) {
this.kit = kit; this.usr_dlg = usr_dlg; this.display = display; this.target = target; this.async = async;
@ -273,21 +303,30 @@ class Swt_gui_cmd implements GfuiInvkCmd, Runnable {
this.invk_ctx = ctx; this.invk_ikey = ikey; this.invk_key = k; this.invk_msg = m;
if (async)
display.asyncExec(this);
else
display.syncExec(this);
else {
kit.Kit_sync_cmd_add(this);
try {display.syncExec(this);}
finally {kit.Kit_sync_cmd_del(this);}
}
return this;
}
@Override public void run() {
try {
target.Invk(invk_ctx, invk_ikey, invk_key, invk_msg);
}
try {target.Invk(invk_ctx, invk_ikey, invk_key, invk_msg);}
catch (Exception e) {
if (kit.Mode_is_shutdown()) return; // NOTE: if shutting down, don't warn; warn will try to write to status.bar, which will fail b/c SWT is shutting down; failures will try to write to status.bar again, causing StackOverflow exception; DATE:2014-05-04
if (kit.Kit_mode__term()) return; // NOTE: if shutting down, don't warn; warn will try to write to status.bar, which will fail b/c SWT is shutting down; failures will try to write to status.bar again, causing StackOverflow exception; DATE:2014-05-04
usr_dlg.Warn_many("", "", "fatal error while running; key=~{0} err=~{1}", invk_key, Err_.Message_gplx_brief(e));
}
}
public void Rls() {
usr_dlg = null; target = null; display = null;
invk_ctx = null; invk_key = null; invk_msg = null;
this.invk_ctx = null; this.invk_key = null; this.invk_msg = null;
}
}
class Swt_msg_wkr_stop implements UsrMsgWkr {
private final Swt_kit kit; private final Gfo_usr_dlg gui_wtr;
public Swt_msg_wkr_stop(Swt_kit kit, Gfo_usr_dlg gui_wtr) {this.kit = kit; this.gui_wtr = gui_wtr;}
public void ExecUsrMsg(int type, UsrMsg umsg) {
String msg = umsg.XtoStr();
kit.Ask_ok("xowa.gui", "stop", msg);
gui_wtr.Log_many("", "", msg);
}
}

View File

@ -216,7 +216,7 @@ class Swt_html_lnr_status implements StatusTextListener {
public Swt_html_lnr_status(Swt_html html_box) {this.html_box = html_box;} private Swt_html html_box;
public void Host_set(GfoEvObj host) {this.host = host;} GfoEvObj host;
@Override public void changed(StatusTextEvent ev) {
if (html_box.Kit().Mode_is_shutdown())
if (html_box.Kit().Kit_mode__term())
return; // shutting down raises status changed events; ignore, else SWT exception thrown; DATE:2014-05-29
String ev_text = ev.text;
// if (String_.Has(ev_text, "Loading [MathJax]")) return; // suppress MathJax messages; // NOTE: disabled for 2.1 (which no longer outputs messages to status); DATE:2013-05-03

View File

@ -60,6 +60,7 @@ public class Db_cfg_tbl implements RlsAble {
if (stmt_update == null) stmt_update = conn.Stmt_update_exclude(tbl_name, flds, fld_grp, fld_key);
stmt_update.Clear().Val_str(fld_val, val).Crt_str(fld_grp, grp).Crt_str(fld_key, key).Exec_update();
}
public void Upsert_int (String grp, String key, int val) {Upsert_str(grp, key, Int_.Xto_str(val));}
public void Upsert_str (String grp, String key, String val) {
String cur_val = this.Select_str_or(grp, key, null);
if (cur_val == null) this.Insert_str(grp, key, val);

View File

@ -18,12 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.fsdb; import gplx.*;
import gplx.dbs.*; import gplx.xowa.*; import gplx.xowa.wikis.data.*;
public class Fsdb_db_mgr_ {
public static Fsdb_db_mgr new_detect(String domain_str, Io_url wiki_dir, Io_url file_dir) {
public static Fsdb_db_mgr new_detect(Xow_wiki wiki, Io_url wiki_dir, Io_url file_dir) {
Gfo_usr_dlg usr_dlg = Xoa_app_.Usr_dlg();
String domain_str = wiki.Domain_str();
Fsdb_db_mgr rv = null;
rv = load_or_null(Xowd_db_layout.Itm_few, usr_dlg, wiki_dir, domain_str); if (rv != null) return rv;
rv = load_or_null(Xowd_db_layout.Itm_lot, usr_dlg, wiki_dir, domain_str); if (rv != null) return rv;
rv = load_or_null(Xowd_db_layout.Itm_all, usr_dlg, wiki_dir, domain_str); if (rv != null) return rv;
rv = load_or_null(Xowd_db_layout.Itm_few, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
rv = load_or_null(Xowd_db_layout.Itm_lot, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
rv = load_or_null(Xowd_db_layout.Itm_all, usr_dlg, wiki_dir, wiki, domain_str); if (rv != null) return rv;
Io_url url = file_dir.GenSubFil(Fsdb_db_mgr__v1.Mnt_name); // EX: /xowa/file/en.wikipedia.org/wiki.mnt.sqlite3
if (Db_conn_bldr.I.Exists(url)) {
usr_dlg.Log_many("", "", "fsdb.db_core.v1: url=~{0}", url.Raw());
@ -32,12 +33,14 @@ public class Fsdb_db_mgr_ {
usr_dlg.Log_many("", "", "fsdb.db_core.none: wiki_dir=~{0} file_dir=~{1}", wiki_dir.Raw(), file_dir.Raw());
return null;
}
private static Fsdb_db_mgr load_or_null(Xowd_db_layout layout, Gfo_usr_dlg usr_dlg, Io_url wiki_dir, String domain_str) {
private static Fsdb_db_mgr load_or_null(Xowd_db_layout layout, Gfo_usr_dlg usr_dlg, Io_url wiki_dir, Xow_wiki wiki, String domain_str) {
Io_url main_core_url = wiki_dir.GenSubFil(Fsdb_db_mgr__v2_bldr.Main_core_name(layout, domain_str));
if (!Db_conn_bldr.I.Exists(main_core_url)) return null;
usr_dlg.Log_many("", "", "fsdb.db_core.v2: type=~{0} url=~{1}", layout.Name(), main_core_url.Raw());
Db_conn main_core_conn = Db_conn_bldr.I.Get(main_core_url);
Io_url user_core_url = wiki_dir.GenSubFil(Fsdb_db_mgr__v2_bldr.Make_user_name(domain_str));
if (!Db_conn_bldr.I.Exists(user_core_url)) // if user file does not exist, create it; needed b/c offline packages don't include file; DATE:2015-04-19
Fsdb_db_mgr__v2_bldr.I.Make_core_file_user(wiki, wiki_dir, user_core_url.NameAndExt(), main_core_url.NameAndExt());
Db_conn user_core_conn = Db_conn_bldr.I.Get(user_core_url);
return new Fsdb_db_mgr__v2(Fsdb_db_mgr__v2.Cfg__layout_file__get(main_core_conn), wiki_dir, new Fsdb_db_file(main_core_url, main_core_conn), new Fsdb_db_file(user_core_url, user_core_conn));
}

View File

@ -41,6 +41,10 @@ public class Fsdb_db_mgr__v2 implements Fsdb_db_mgr {
if (layout.Tid_is_all_or_few()) return file_main_core;
Io_url url = wiki_dir.GenSubFil(file_name);
Db_conn conn = Db_conn_bldr.I.Get(url);
if (conn == null) { // bin file deleted or not downloaded; use Noop Db_conn and continue; do not fail; DATE:2015-04-16
Gfo_usr_dlg_.I.Warn_many("", "", "fsdb.bin:file does not exist; url=~{0}", url);
conn = Db_conn_.Empty;
}
return new Fsdb_db_file(url, conn);
}
public Fsdb_db_file File__bin_file__new(int mnt_id, String file_name) {

View File

@ -39,7 +39,7 @@ public class Fsdb_db_mgr__v2_bldr {
conn.Txn_end();
return rv;
}
private Fsdb_db_file Make_core_file_user(Xowe_wiki wiki, Io_url wiki_dir, String user_file_name, String main_core_name) { // always create file; do not create mnt_tbl;
public Fsdb_db_file Make_core_file_user(Xow_wiki wiki, Io_url wiki_dir, String user_file_name, String main_core_name) { // always create file; do not create mnt_tbl;
Io_url url = wiki_dir.GenSubFil(user_file_name);
Db_conn conn = Db_conn_bldr.I.New(url);
conn.Txn_bgn();
@ -91,11 +91,11 @@ public class Fsdb_db_mgr__v2_bldr {
default: throw Err_.not_implemented_();
}
}
public static void Make_cfg_data(Xowe_wiki wiki, String file_core_name, Fsdb_db_file file, byte file_tid, int part_id) {
public static void Make_cfg_data(Xow_wiki wiki, String file_core_name, Fsdb_db_file file, byte file_tid, int part_id) {
Db_cfg_tbl cfg_tbl = file.Tbl__cfg();
Xowd_db_file core_db = wiki.Data_mgr__core_mgr().Db__core();
core_db.Info_session().Save(cfg_tbl);
Xob_info_file info_file = new Xob_info_file(-1, Xowd_db_file_.To_key(file_tid), Xob_info_file.Ns_ids_empty, part_id, Guid_adp_.random_(), 2, file_core_name, file.Url().NameAndExt());
Xob_info_file info_file = new Xob_info_file(-1, Xowd_db_file_.To_key(file_tid), Xob_info_file.Ns_ids_empty, part_id, Guid_adp_.new_(), 2, file_core_name, file.Url().NameAndExt());
info_file.Save(cfg_tbl);
}
private static String Main_core_name_all(String wiki_domain) {return wiki_domain + ".xowa";} // EX: en.wikipedia.org.xowa

View File

@ -69,6 +69,8 @@ public class Fsd_fil_tbl implements RlsAble {
.Val_int(fld_bin_db_id, bin_db_id)
.Val_bry_as_str(fld_name, name)
.Val_long(fld_size, size)
.Val_str(fld_modified, String_.Empty)
.Val_str(fld_hash, String_.Empty)
.Crt_int(fld_id, id)
.Exec_update();
}

View File

@ -26,7 +26,7 @@ public class Xoa_app_ {
boot_mgr.Run(args);
}
public static final String Name = "xowa";
public static final String Version = "2.4.2.1";
public static final String Version = "2.4.3.1";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys;
public static String User_agent = "";

View File

@ -156,9 +156,9 @@ public class Xoae_app implements Xoa_app, GfoInvkAble {
if (setup_mgr.Cmd_mgr().Working()) {
if (!gui_mgr.Kit().Ask_yes_no("", "", "An import is in progress. Are you sure you want to exit?")) return false;
}
if (!gui_mgr.Browser_win().Tab_mgr().Tabs__pub_close_all()) return false;
gui_mgr.Browser_win().Usr_dlg().Canceled_y_();
user.App_term(); usr_dlg.Log_many("", "", "term:app_term");
gui_mgr.Browser_win().Tab_mgr().Tabs_close_all();
log_wtr.Term(); usr_dlg.Log_many("", "", "term:log_wtr");
log_mgr.Rls(); usr_dlg.Log_many("", "", "term:log_mgr");
if (Scrib_core.Core() != null) {Scrib_core.Core().Term(); usr_dlg.Log_many("", "", "term:scrib");}

View File

@ -16,19 +16,39 @@ 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.apis.xowa.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
public class Xoapi_search implements GfoInvkAble {
import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.crts.*;
public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
private final Xow_domain_crt_kv_mgr multi_wiki_rules_mgr = new Xow_domain_crt_kv_mgr(); private String multi_wiki_rules_str = "*.*|<self>";
public Xoapi_search() {
this.evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public int Results_per_page() {return results_per_page;} private int results_per_page = 20;
public boolean Async_db() {return async_db;} private boolean async_db = true;
public void Multi_wiki_rule_str_(String v) {
if (!multi_wiki_rules_mgr.Parse(Bry_.new_utf8_(v))) return;
this.multi_wiki_rules_str = v;
GfoEvMgr_.PubVal(this, Evt_multi_wiki_rules_changed, v);
}
public Xow_domain_crt_itm Multi_wiki_crt(Xow_domain cur_domain) {
return multi_wiki_rules_mgr.Find(cur_domain, cur_domain);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_results_per_page)) return results_per_page;
else if (ctx.Match(k, Invk_results_per_page_)) results_per_page = m.ReadInt("v");
else if (ctx.Match(k, Invk_async_db)) return Yn.Xto_str(async_db);
else if (ctx.Match(k, Invk_async_db_)) async_db = m.ReadYn("v");
else if (ctx.Match(k, Invk_multi_wiki_rules)) return multi_wiki_rules_str;
else if (ctx.Match(k, Invk_multi_wiki_rules_)) multi_wiki_rules_str = m.ReadStr("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_results_per_page = "results_per_page" , Invk_results_per_page_ = "results_per_page_"
, Invk_async_db = "async_db" , Invk_async_db_ = "async_db_"
, Invk_multi_wiki_rules = "multi_wiki_rules" , Invk_multi_wiki_rules_ = "multi_wiki_rules_"
;
public static final String
Evt_multi_wiki_rules_changed = "multi_wiki_rules_changed"
;
}

View File

@ -61,7 +61,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
}
// trg_mnt_itm
this.trg_bin_db_max = app.Api_root().Bldr().Wiki().Import().File_db_max();
Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki.Domain_str(), wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.I.Make(wiki);
Fsm_mnt_mgr trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(trg_db_mgr);
trg_mnt_mgr.Mnts__get_insert_idx_(Fsm_mnt_mgr.Mnt_idx_main); // NOTE: do not delete; mnt_mgr default to Mnt_idx_user; DATE:2014-04-25
@ -119,7 +119,7 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
}
public void Cmd_end() {
usr_dlg.Note_many("", "", "fsdb_make.done: count=~{0} rate=~{1}", exec_count, DecimalAdp_.divide_safe_(exec_count, Env_.TickCount_elapsed_in_sec(time_bgn)).Xto_str("#,###.000"));
src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Txn_end();
if (src_fsdb_wkr != null) src_fsdb_wkr.Mnt_mgr().Mnts__get_main().Txn_end(); // NOTE: src_fsdb_wkr will be null if no src db defined
trg_atr_fil.Conn().Txn_end(); trg_atr_fil.Conn().Rls_conn();
if (!trg_mnt_itm.Db_mgr().File__solo_file()) {
trg_bin_fil.Conn().Txn_end(); trg_bin_fil.Conn().Rls_conn();
@ -303,10 +303,10 @@ public class Xob_fsdb_make_cmd extends Xob_itm_basic_base implements Xob_cmd {
}
else if (String_.Eq(version, "v2")) {
url = wiki.Fsys_mgr().Root_dir().GenSubDir("prv"); // v2: EX: /xowa/wiki/en.wikipedia.org/prv/
rv = Fsdb_db_mgr_.new_detect(domain_str, url, url); // note that v2 is prioritized over v1
rv = Fsdb_db_mgr_.new_detect(wiki, url, url); // note that v2 is prioritized over v1
}
else throw Err_.new_("fsdb.make:unknown fsdb_type; version={0}", version);
if (!Io_mgr._.ExistsFil(rv.File__mnt_file().Url())) throw Err_.new_("fsdb.make:source fsdb not found; version={0} url={1}", version, url.Raw());
if (rv == null) throw Err_.new_("fsdb.make:source fsdb not found; version={0} url={1}", version, url.Raw());
return rv;
}
private static final byte Select_rv_stop = 0, Select_rv_process = 1, Select_rv_next_page = 2;

View File

@ -27,6 +27,7 @@ public class Xob_term_cmd extends Xob_term_base {
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp_wiki_init, "props.main_page", wiki.Props().Main_page());
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp_wiki_init, "props.siteinfo_misc", wiki.Props().Siteinfo_misc());
cfg_tbl.Insert_bry(Xow_cfg_consts.Grp_wiki_init, "props.siteinfo_mainpage", wiki.Props().Siteinfo_mainpage());
// gplx.fsdb.Fsdb_db_mgr__v2_bldr.I.Make(wiki);// bld wiki
wiki.Data_mgr__core_mgr().Rls();
}
}

View File

@ -56,6 +56,6 @@ public class Xob_info_session {
, Cfg_key__time = "time" // EX: 20150102 030405
, Cfg_key__guid = "guid" // EX: 00000000-0000-0000-0000-000000000000
;
public static Xob_info_session new_(String user, String wiki_domain, String dump_name) {return new Xob_info_session(user, Xoa_app_.Version, wiki_domain, dump_name, DateAdp_.Now(), Guid_adp_.Empty);}
public static Xob_info_session new_(String user, String wiki_domain, String dump_name) {return new Xob_info_session(user, Xoa_app_.Version, wiki_domain, dump_name, DateAdp_.Now(), Guid_adp_.new_());}
public static final Xob_info_session Test = new_("anonymous", "en.wikipedia.org", "enwiki-latest-pages-articles");
}

View File

@ -104,7 +104,7 @@ public class Xol_mw_lang_parser {
try {
Xol_lang lang = lang_mgr.Get_by_key_or_new(Bry_.new_utf8_(fil.NameOnly()));
Xob_i18n_parser.Load_msgs(true, lang, fil);
} catch (Exception exc) {Err_.Noop(exc); Tfds.WriteText(String_.Format("failed to parse json file; url={0} err={1}", fil.Raw(), Err_.Message_gplx_brief(exc)));}
} catch (Exception exc) {Err_.Noop(exc); Tfds.WriteText(String_.Format("failed to parse json file; url={0} err={1}\n", fil.Raw(), Err_.Message_gplx_brief(exc)));}
}
}
}

View File

@ -39,7 +39,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
if (cur_page_id > max_page_id) max_page_id = cur_page_id;
}
page_id = max_page_id + 1;
db_mgr.Core_data_mgr().Tbl__cfg().Insert_int("db", "page.id_next", page_id + 1);
db_mgr.Core_data_mgr().Tbl__cfg().Upsert_int("db", "page.id_next", page_id + 1);
} finally {rdr.Rls();}
}
@ -52,7 +52,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
page_core_tbl.Insert_bgn();
page_text_tbl.Insert_bgn();
try {
page_mgr.Create(page_core_tbl, page_text_tbl, page_id, ns_id, text_raw, redirect, DateAdp_.Now(), text_zip, text_raw.length, ns_count, page_text_db.Id(), -1);
page_mgr.Create(page_core_tbl, page_text_tbl, page_id, ns_id, ttl.Page_db(), redirect, DateAdp_.Now(), text_zip, text_raw.length, ns_count, page_text_db.Id(), -1);
db_file.Tbl__ns().Update_ns_count(ns_id, ns_count);
db_file.Tbl__cfg().Update_int("db", "page.id_next", page_id + 1);
} finally {

View File

@ -29,7 +29,7 @@ public interface Xof_file_itm {
byte Orig_repo_id();
byte[] Orig_repo_name();
byte[] Orig_ttl();
int Orig_ext();
Xof_ext Orig_ext();
int Orig_w();
int Orig_h();
byte[] Orig_redirect();

View File

@ -64,7 +64,7 @@ public class Xof_file_wkr implements Gfo_thread_wkr {
}
public static void Show_img(byte exec_tid, Xof_fsdb_itm fsdb, Gfo_usr_dlg usr_dlg, Xof_bin_mgr bin_mgr, Fsm_mnt_mgr mnt_mgr, Xof_cache_mgr cache_mgr, Xow_repo_mgr repo_mgr, Xog_js_wkr js_wkr, Xof_img_size img_size, Xof_url_bldr url_bldr, Xoa_page hpg) {
try {
if (fsdb.Orig_ext() < 0) {
if (fsdb.Orig_ext() == null) {
usr_dlg.Warn_many("", "", "file.missing.ext: file=~{0} width=~{1} page=~{2}", fsdb.Lnki_ttl(), fsdb.Lnki_w(), hpg.Ttl().Full_db());
return;
}
@ -104,7 +104,7 @@ public class Xof_file_wkr implements Gfo_thread_wkr {
byte repo_id = orig.Repo();
Xof_repo_pair repo_pair = repo_mgr.Repos_get_by_id(repo_id);
Xof_repo_itm repo_itm = repo_pair.Trg();
fsdb.Ctor_by_orig(repo_id, repo_pair.Wiki_domain(), orig.Page(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
fsdb.Ctor_by_orig(repo_id, repo_pair.Wiki_domain(), orig.Page(), Xof_ext_.new_by_id_(orig.Ext()), orig.W(), orig.H(), orig.Redirect());
fsdb.Ctor_for_html(exec_tid, img_size, repo_itm, url_bldr);
}
private static void Save_bin(Xof_fsdb_itm itm, Fsm_mnt_mgr mnt_mgr) {

View File

@ -28,7 +28,7 @@ public class Xof_img_size {
}
public void Html_size_calc(byte exec_tid, int lnki_w, int lnki_h, byte lnki_type, int upright_patch, double lnki_upright, int lnki_ext, int orig_w, int orig_h, int thm_dflt_w) {
this.Clear(); // always clear before calc; caller should be responsible, but just to be safe.
if (lnki_type == Xop_lnki_type.Id_frame // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
if (Enm_.HasInt(lnki_type, Xop_lnki_type.Id_frame) // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
&& lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22
html_w = file_w = orig_w;
html_h = file_h = orig_h;

View File

@ -74,6 +74,9 @@ public class Xof_img_size_tst {
@Test public void Frame() { // PURPOSE: frame incorrectly defaulted to file_is_orig; [[File:MESSENGER.jpg|200x200px|framed]]; DATE:2013-12-22
fxt.Lnki_type_(Xop_lnki_type.Id_frame).Lnki_ext_(Xof_ext_.Id_png).Lnki_(200, 200).Orig_(2038, 1529).Test_html(200, 150, Bool_.N);
}
@Test public void Frame_and_thumb(){ // PURPOSE: frame and thumb should be treated as frame; Enm.Has(val, Id_frame) vs val == Id_frame; PAGE:en.w:History_of_Western_Civilization; DATE:2015-04-16
fxt.Lnki_type_(Enm_.Add_byte(Xop_lnki_type.Id_frame, Xop_lnki_type.Id_thumb)).Lnki_(200, -1).Test_html(400, 200, Bool_.Y); // mut return same as Lnki_lt_orig_frame above
}
}
class Xof_img_size_fxt {
private Xof_img_size img_size = new Xof_img_size();

View File

@ -65,6 +65,7 @@ public class Xof_url_bldr {
public Io_url Xto_url() {Bld(); Io_url rv = Io_url_.new_fil_(bfr.Xto_str()); Clear(); return rv;}
public Io_url To_url_trg(Xof_repo_itm repo_itm, Xof_fsdb_itm itm, boolean orig) {
byte mode = orig ? Xof_repo_itm.Mode_orig : Xof_repo_itm.Mode_thumb;
// return this.Init_for_trg_file(mode, repo_itm, itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url();
return this.Init_for_trg_file(mode, repo_itm, itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url();
}
private void Bld() {

View File

@ -30,7 +30,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
public byte Orig_repo_id() {return orig_repo_id;} private byte orig_repo_id = Xof_repo_itm.Repo_null;
public byte[] Orig_repo_name() {return orig_repo_name;} private byte[] orig_repo_name;
public byte[] Orig_ttl() {return orig_ttl;} private byte[] orig_ttl;
public int Orig_ext() {return orig_ext;} private int orig_ext;
public Xof_ext Orig_ext() {return orig_ext;} private Xof_ext orig_ext;
public int Orig_w() {return orig_w;} private int orig_w;
public int Orig_h() {return orig_h;} private int orig_h;
public byte[] Orig_redirect() {return orig_redirect;} private byte[] orig_redirect;
@ -66,7 +66,8 @@ public class Xof_xfer_itm implements Xof_file_itm {
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() {
lnki_type = orig_repo_id = Byte_.Max_value_127;
lnki_w = lnki_h = file_w = orig_ext = orig_w = orig_h = html_w = html_h = gallery_mgr_h = Int_.Neg1;
lnki_w = lnki_h = file_w = orig_w = orig_h = html_w = html_h = gallery_mgr_h = Int_.Neg1;
orig_ext = null;
lnki_upright = Int_.Neg1; lnki_time = Xof_lnki_time.Null; lnki_page = Xof_lnki_page.Null;
file_found = file_exists = img_is_thumbable = false;
orig_file_len = 0; // NOTE: cannot be -1, or else will always download orig; see ext rule chk and (orig_file_len < 0)
@ -104,14 +105,16 @@ public class Xof_xfer_itm implements Xof_file_itm {
public void Init_by_orig_old(int w, int h, int orig_file_len) {
this.orig_w = w; this.orig_h = h; this.orig_file_len = orig_file_len;
}
public void Init_by_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, int orig_ext, int orig_w, int orig_h, byte[] orig_redirect, int orig_file_len) {
public void Init_by_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, Xof_ext orig_ext, int orig_w, int orig_h, byte[] orig_redirect, int orig_file_len) {
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
this.orig_ttl = orig_ttl; this.orig_ext = orig_ext;
this.orig_w = orig_w; this.orig_h = orig_h; this.orig_redirect = orig_redirect;
if (orig_ext != lnki_ext.Id())
this.Lnki_ext_(Xof_ext_.new_by_id_(orig_ext)); // overwrite ext with whatever's in file_orig; needed for ogg -> oga / ogv
if (orig_ext.Id() != lnki_ext.Id())
this.Lnki_ext_(orig_ext); // overwrite ext with whatever's in file_orig; needed for ogg -> oga / ogv
if (Bry_.Len_gt_0(orig_redirect)) // redirect exists; EX: A.png redirected to B.png
this.Lnki_ttl_(orig_redirect); // update fsdb with atrs of B.png
else if (!Bry_.Eq(lnki_ttl, orig_ttl)) // ttls differ; EX: "A_.png" vs "A.png"
this.Lnki_ttl_(orig_ttl);
this.orig_file_len = orig_file_len;
}
private void Lnki_ttl_(byte[] v) {

View File

@ -115,7 +115,7 @@ public class Xow_file_mgr implements GfoInvkAble {
}
public void Init_file_mgr_by_load(Xow_wiki wiki) {
if (db_core != null) return; // already init'd
this.db_core = Fsdb_db_mgr_.new_detect(wiki.Domain_str(), wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
this.db_core = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
if (db_core == null ) return; // no fsdb_core found; exit
this.version = Version_2;
this.fsdb_mode = Xof_fsdb_mode.new_view();

View File

@ -62,43 +62,43 @@ public class Xof_bin_mgr {
if (!Env_.Mode_testing()) cache_mgr.Reg(itm, rdr.Len());
return trg;
}
public Io_stream_rdr Find_as_rdr(byte exec_tid, Xof_fsdb_itm itm) {
public Io_stream_rdr Find_as_rdr(byte exec_tid, Xof_fsdb_itm fsdb) {
Io_stream_rdr rv = Io_stream_rdr_.Null;
Xof_repo_itm repo = repo_mgr.Repos_get_by_wiki(itm.Orig_repo_name()).Trg();
boolean file_is_orig = itm.File_is_orig();
Xof_repo_itm repo = repo_mgr.Repos_get_by_wiki(fsdb.Orig_repo_name()).Trg();
boolean file_is_orig = fsdb.File_is_orig();
if (file_is_orig || exec_tid == Xof_exec_tid.Tid_viewer_app) { // orig or viewer_app; note that viewer_app always return orig
Io_url trg = url_bldr.To_url_trg(repo, itm, Bool_.Y);
itm.Html_view_url_(trg);
Io_url trg = url_bldr.To_url_trg(repo, fsdb, Bool_.Y);
fsdb.Html_view_url_(trg);
for (int i = 0; i < wkrs_len; i++) {
Xof_bin_wkr wkr = wkrs[i];
rv = wkr.Get_as_rdr(itm, Bool_.N, itm.Html_w());
rv = wkr.Get_as_rdr(fsdb, Bool_.N, fsdb.Html_w());
if (rv == Io_stream_rdr_.Null) continue; // orig not found; continue;
itm.File_exists_y_();
fsdb.File_exists_y_();
return rv;
}
}
else { // thumb
Io_url trg = url_bldr.To_url_trg(repo, itm, Bool_.N);
itm.Html_view_url_(trg);
Io_url trg = url_bldr.To_url_trg(repo, fsdb, Bool_.N);
fsdb.Html_view_url_(trg);
for (int i = 0; i < wkrs_len; i++) {
Xof_bin_wkr wkr = wkrs[i];
rv = wkr.Get_as_rdr(itm, Bool_.Y, itm.Html_w()); // get thumb's bin
rv = wkr.Get_as_rdr(fsdb, Bool_.Y, fsdb.Html_w()); // get thumb's bin
if (rv != Io_stream_rdr_.Null) { // thumb's bin exists;
itm.File_exists_y_();
fsdb.File_exists_y_();
return rv;
}
usr_dlg.Log_direct(String_.Format("thumb not found; ttl={0} w={1} ", String_.new_utf8_(itm.Lnki_ttl()), itm.Lnki_w()));
rv = wkr.Get_as_rdr(itm, Bool_.N, itm.Orig_w()); // thumb missing; get orig;
usr_dlg.Log_direct(String_.Format("thumb not found; ttl={0} w={1} ", String_.new_utf8_(fsdb.Lnki_ttl()), fsdb.Lnki_w()));
rv = wkr.Get_as_rdr(fsdb, Bool_.N, fsdb.Orig_w()); // thumb missing; get orig;
if (rv == Io_stream_rdr_.Null) {
usr_dlg.Log_direct(String_.Format("orig not found;"));
continue; // nothing found; continue;
}
if (!wkr.Resize_allowed()) continue;
Io_url orig = url_bldr.To_url_trg(repo, itm, Bool_.Y); // get orig url
Io_url orig = url_bldr.To_url_trg(repo, fsdb, Bool_.Y); // get orig url
Io_stream_wtr_.Save_rdr(orig, rv);
boolean resized = Resize(exec_tid, itm, file_is_orig, orig, trg);
boolean resized = Resize(exec_tid, fsdb, file_is_orig, orig, trg);
if (!resized) continue;
itm.File_exists_y_();
fsdb.File_exists_y_();
rv = Io_stream_rdr_.file_(trg); // return stream of resized url; (result of imageMagick / inkscape)
rv.Open();
return rv;

View File

@ -16,47 +16,42 @@ 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.files.bins; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
import gplx.core.primitives.*; import gplx.dbs.*; import gplx.ios.*; import gplx.cache.*; import gplx.xowa.files.fsdb.*;
import gplx.dbs.*; import gplx.ios.*; import gplx.cache.*; import gplx.xowa.files.fsdb.*;
import gplx.fsdb.*; import gplx.fsdb.data.*; import gplx.fsdb.meta.*;
public class Xof_bin_wkr__fsdb_sql implements Xof_bin_wkr {
private final Int_obj_ref tmp_itm_id = Int_obj_ref.neg1_(), tmp_bin_id = Int_obj_ref.neg1_(), tmp_mnt_id = Int_obj_ref.neg1_();
private final Xof_bin_wkr_ids tmp_ids = new Xof_bin_wkr_ids();
Xof_bin_wkr__fsdb_sql(Fsm_mnt_mgr mnt_mgr) {this.mnt_mgr = mnt_mgr;}
public byte Tid() {return Xof_bin_wkr_.Tid_fsdb_xowa;}
public String Key() {return Xof_bin_wkr_.Key_fsdb_wiki;}
public Fsm_mnt_mgr Mnt_mgr() {return mnt_mgr;} private final Fsm_mnt_mgr mnt_mgr;
public boolean Resize_allowed() {return bin_wkr_resize;} public void Resize_allowed_(boolean v) {bin_wkr_resize = v;} private boolean bin_wkr_resize = false;
public Io_stream_rdr Get_as_rdr(Xof_fsdb_itm itm, boolean is_thumb, int w) {
Find_ids(itm, is_thumb, w, tmp_itm_id, tmp_bin_id, tmp_mnt_id);
int bin_db_id = tmp_bin_id.Val(); if (bin_db_id == Fsd_bin_tbl.Bin_db_id_null) return gplx.ios.Io_stream_rdr_.Null;
Fsm_bin_fil bin_db = mnt_mgr.Bins__at(tmp_mnt_id.Val(), bin_db_id);
return bin_db.Select_as_rdr(tmp_itm_id.Val());
Find_ids(itm, is_thumb, w);
int bin_db_id = tmp_ids.Bin_db_id(); if (bin_db_id == Fsd_bin_tbl.Bin_db_id_null) return gplx.ios.Io_stream_rdr_.Null;
Fsm_bin_fil bin_db = mnt_mgr.Bins__at(tmp_ids.Mnt_id(), bin_db_id);
return bin_db.Select_as_rdr(tmp_ids.Itm_id());
}
public boolean Get_to_fsys(Xof_fsdb_itm itm, boolean is_thumb, int w, Io_url bin_url) {return Get_to_fsys(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), is_thumb, w, itm.Lnki_time(), itm.Lnki_page(), bin_url);}
private boolean Get_to_fsys(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
Find_ids(orig_repo, orig_ttl, orig_ext.Id(), lnki_time, lnki_page, lnki_is_thumb, file_w, tmp_itm_id, tmp_bin_id, tmp_mnt_id);
int bin_db_id = tmp_bin_id.Val(); if (bin_db_id == Fsd_bin_tbl.Bin_db_id_null) return false;
Fsm_bin_fil bin_db = mnt_mgr.Bins__at(tmp_mnt_id.Val(), bin_db_id);
return bin_db.Select_to_url(tmp_itm_id.Val(), file_url);
Find_ids(orig_repo, orig_ttl, orig_ext.Id(), lnki_time, lnki_page, lnki_is_thumb, file_w);
int bin_db_id = tmp_ids.Bin_db_id(); if (bin_db_id == Fsd_bin_tbl.Bin_db_id_null) return false;
Fsm_bin_fil bin_db = mnt_mgr.Bins__at(tmp_ids.Mnt_id(), bin_db_id);
return bin_db.Select_to_url(tmp_ids.Itm_id(), file_url);
}
private void Find_ids(Xof_fsdb_itm itm, boolean is_thumb, int w, Int_obj_ref tmp_itm_id, Int_obj_ref tmp_bin_id, Int_obj_ref tmp_mnt_id) {Find_ids(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_ext().Id(), itm.Lnki_time(), itm.Lnki_page(), is_thumb, w, tmp_itm_id, tmp_bin_id, tmp_mnt_id);}
private void Find_ids(byte[] orig_repo, byte[] orig_ttl, int orig_ext, double lnki_time, int lnki_page, boolean is_thumb, int w, Int_obj_ref tmp_itm_id, Int_obj_ref tmp_bin_id, Int_obj_ref tmp_mnt_id) {
synchronized (tmp_bin_id) {
private void Find_ids(Xof_fsdb_itm itm, boolean is_thumb, int w) {Find_ids(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_ext().Id(), itm.Lnki_time(), itm.Lnki_page(), is_thumb, w);}
private void Find_ids(byte[] orig_repo, byte[] orig_ttl, int orig_ext, double lnki_time, int lnki_page, boolean is_thumb, int w) {
synchronized (tmp_ids) {
byte[] dir = orig_repo, fil = orig_ttl;
double time = Xof_lnki_time.Convert_to_fsdb_thumbtime(orig_ext, lnki_time, lnki_page);
if (is_thumb) {
Fsd_thm_itm thm_itm = Fsd_thm_itm.new_();
thm_itm.Init_by_req(w, lnki_time, lnki_page);
boolean found = Select_thm_bin(thm_itm, dir, fil);
tmp_itm_id.Val_(thm_itm.Thm_id());
tmp_bin_id.Val_(found ? thm_itm.Db_bin_id() : Fsd_bin_tbl.Bin_db_id_null);
tmp_mnt_id.Val_(thm_itm.Mnt_id());
tmp_ids.Init_by_thm(found, thm_itm);
}
else {
Fsd_fil_itm fil_itm = Select_fil_bin(dir, fil, is_thumb, w, time);
if (fil_itm == Fsd_fil_itm.Null) return;
tmp_itm_id.Val_(fil_itm.Fil_id());
tmp_bin_id.Val_(fil_itm.Bin_db_id());
tmp_mnt_id.Val_(fil_itm.Mnt_id());
tmp_ids.Init_by_fil(fil_itm);
}
}
}
@ -83,3 +78,32 @@ public class Xof_bin_wkr__fsdb_sql implements Xof_bin_wkr {
public void Txn_end() {mnt_mgr.Mnts__get_insert().Txn_end();}
public static Xof_bin_wkr__fsdb_sql new_(Fsm_mnt_mgr mnt_mgr) {return new Xof_bin_wkr__fsdb_sql(mnt_mgr);}
}
class Xof_bin_wkr_ids {
public Xof_bin_wkr_ids() {this.Clear();}
public int Mnt_id() {return mnt_id;} private int mnt_id;
public int Bin_db_id() {return bin_db_id;} private int bin_db_id;
public int Itm_id() {return itm_id;} private int itm_id;
public void Init_by_thm(boolean found, Fsd_thm_itm thm) {
if (found) {
this.mnt_id = thm.Mnt_id();
this.bin_db_id = thm.Db_bin_id();
this.itm_id = thm.Thm_id();
}
else
this.Clear();
}
public void Init_by_fil(Fsd_fil_itm fil) {
if (fil == Fsd_fil_itm.Null)
this.Clear();
else {
this.mnt_id = fil.Mnt_id();
this.bin_db_id = fil.Bin_db_id();
this.itm_id = fil.Fil_id();
}
}
private void Clear() {
this.mnt_id = -1;
this.bin_db_id = Fsd_bin_tbl.Bin_db_id_null;
this.itm_id = -1;
}
}

View File

@ -46,7 +46,7 @@ public class Xof_cache_mgr2 {
Xof_cache_itm itm = Get_or_null(fsdb.Lnki_ttl(), fsdb.Lnki_type(), fsdb.Lnki_upright(), fsdb.Lnki_w(), fsdb.Lnki_h(), fsdb.Lnki_time(), fsdb.Lnki_page());
if (itm == Xof_cache_itm.Null) {
itm = new Xof_cache_itm(key_bfr, Db_cmd_mode.Tid_create, site, fsdb.Lnki_ttl(), fsdb.Lnki_type(), fsdb.Lnki_upright(), fsdb.Lnki_w(), fsdb.Lnki_h(), fsdb.Lnki_time(), fsdb.Lnki_page()
, fsdb.Orig_repo_id(), fsdb.Orig_ttl(), fsdb.Orig_ext(), fsdb.Orig_w(), fsdb.Orig_h()
, fsdb.Orig_repo_id(), fsdb.Orig_ttl(), fsdb.Orig_ext().Id(), fsdb.Orig_w(), fsdb.Orig_h()
, fsdb.Lnki_time(), fsdb.Lnki_page(), fsdb.Temp_file_size(), 1, DateAdp_.Now().Timestamp_unix(), fsdb.Temp_file_w())
;
hash.Add(itm.Lnki_key(), itm);

View File

@ -30,7 +30,7 @@ public class Xof_fsdb_itm {
public byte Orig_repo_id() {return orig_repo_id;} private byte orig_repo_id = Xof_repo_itm.Repo_null;
public byte[] Orig_repo_name() {return orig_repo_name;} private byte[] orig_repo_name;
public byte[] Orig_ttl() {return orig_ttl;} private byte[] orig_ttl;
public int Orig_ext() {return orig_ext;} private int orig_ext;
public Xof_ext Orig_ext() {return orig_ext;} private Xof_ext orig_ext;
public int Orig_w() {return orig_w;} private int orig_w = Xop_lnki_tkn.Width_null;
public int Orig_h() {return orig_h;} private int orig_h = Xop_lnki_tkn.Height_null;
public byte[] Orig_redirect() {return orig_redirect;} private byte[] orig_redirect = Bry_.Empty;
@ -59,14 +59,16 @@ public class Xof_fsdb_itm {
// this.file_is_orig = !(Xop_lnki_type.Id_defaults_to_thumb(lnki_type) || lnki_w != Xop_lnki_tkn.Width_null || lnki_h != Xop_lnki_tkn.Height_null); // DELETE: overriden below.
this.Lnki_ttl_(lnki_ttl);
} private int lnki_upright_patch;
public void Ctor_by_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, int orig_ext, int orig_w, int orig_h, byte[] orig_redirect) {
public void Ctor_by_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, Xof_ext orig_ext, int orig_w, int orig_h, byte[] orig_redirect) {
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
this.orig_ttl = orig_ttl; this.orig_ext = orig_ext;
this.orig_w = orig_w; this.orig_h = orig_h; this.orig_redirect = orig_redirect;
if (orig_ext != lnki_ext.Id())
this.Lnki_ext_(Xof_ext_.new_by_id_(orig_ext)); // overwrite ext with whatever's in file_orig; needed for ogg -> oga / ogv
if (orig_ext != null && orig_ext.Id() != lnki_ext.Id())
this.Lnki_ext_(orig_ext); // overwrite ext with whatever's in file_orig; needed for ogg -> oga / ogv
if (Bry_.Len_gt_0(orig_redirect)) // redirect exists; EX: A.png redirected to B.png
this.Lnki_ttl_(orig_redirect); // update fsdb with atrs of B.png
else if (!Bry_.Eq(lnki_ttl, orig_ttl)) // ttls differ; EX: "A_.png" vs "A.png"
this.Lnki_ttl_(orig_ttl);
}
public void Ctor_for_html(byte exec_tid, Xof_img_size img_size, Xof_repo_itm repo, Xof_url_bldr url_bldr) {
Calc_html_size(exec_tid, img_size);

View File

@ -33,7 +33,7 @@ public class Xof_fsdb_mgr__sql implements Xof_fsdb_mgr, GfoInvkAble {
Xoa_app app = wiki.App();
this.cache_mgr = app.File_mgr__cache_mgr(); this.url_bldr = Xof_url_bldr.new_v2_();
this.repo_mgr = wiki.File_mgr__repo_mgr(); Xof_img_mgr img_mgr = app.File_mgr__img_mgr();
Fsdb_db_mgr core = Fsdb_db_mgr_.new_detect(wiki.Domain_str(), wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
Fsdb_db_mgr core = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
if (core == null) return;
fsdb_enabled = true;
mnt_mgr.Ctor_by_load(core);

View File

@ -26,7 +26,7 @@ public class Xob_orig_tbl_bldr extends Xob_itm_basic_base implements Xob_cmd {
Xof_fsdb_mode fsdb_mode = wiki.File_mgr__fsdb_mode();
fsdb_mode.Tid_make_y_();
wiki.Init_assert();
Fsdb_db_mgr db_core_mgr = Fsdb_db_mgr_.new_detect(wiki.Domain_str(), wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
Fsdb_db_mgr db_core_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Fsys_mgr().File_dir());
conn = db_core_mgr.File__orig_tbl_ary()[gplx.fsdb.meta.Fsm_mnt_mgr.Mnt_idx_main].Conn();
Io_url make_db_url = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Url();
Sqlite_engine_.Db_attach(conn, "make_db", make_db_url.Raw());

View File

@ -37,9 +37,8 @@ public class Xof_orig_mgr {
public Xof_orig_itm Find_by_ttl_or_null(byte[] ttl) {
for (int i = 0; i < wkrs_len; i++) {
Xof_orig_wkr wkr = wkrs[i];
Xof_orig_itm orig = wkr.Find_as_itm(ttl);
if (orig == Xof_orig_itm.Null) continue;
if (orig.Insert_new()) this.Insert(orig.Repo(), orig.Page(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
Xof_orig_itm orig = wkr.Find_as_itm(ttl); if (orig == Xof_orig_itm.Null) continue;
if (orig.Insert_new()) this.Insert(orig.Repo(), ttl, orig.Ext(), orig.W(), orig.H(), orig.Redirect()); // NOTE: orig_page must be same as find_arg not orig.Page() else will not be found for next call; DATE:2015-04-14
return orig;
}
return Xof_orig_itm.Null;
@ -54,9 +53,8 @@ public class Xof_orig_mgr {
try {
Xof_fsdb_itm fsdb = (Xof_fsdb_itm)itms.FetchAt(i);
fsdb.Orig_exists_n_(); // default to status = missing
Xof_orig_itm orig = (Xof_orig_itm)rv.Fetch(fsdb.Lnki_ttl());
if (orig == Xof_orig_itm.Null) continue;
if (orig.Insert_new()) this.Insert(orig.Repo(), orig.Page(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
Xof_orig_itm orig = (Xof_orig_itm)rv.Fetch(fsdb.Lnki_ttl()); if (orig == Xof_orig_itm.Null) continue;
if (orig.Insert_new()) this.Insert(orig.Repo(), fsdb.Lnki_ttl(), orig.Ext(), orig.W(), orig.H(), orig.Redirect()); // NOTE: orig_page must be same as find_arg not orig.Page() else will not be found for next call; DATE:2015-04-14
Xof_file_wkr.Eval_orig(exec_tid, orig, fsdb, url_bldr, repo_mgr, img_size);
if (!Io_mgr._.ExistsFil(fsdb.Html_view_url()))
fsdb.File_exists_n_();

View File

@ -57,7 +57,7 @@ public class Xog_mnu_grp extends Xog_mnu_base {
}
public void Build() {
Xoa_gui_mgr gui_mgr = app.Gui_mgr(); Gfui_kit kit = gui_mgr.Kit(); Xog_win_itm win = gui_mgr.Browser_win();
if (!kit.Kit_init_done()) return; // NOTE: .gfs will fire Build before Kit.Init; check that kit is inited
if (!kit.Kit_mode__ready()) return; // NOTE: .gfs will fire Build before Kit.Init; check that kit is inited
if (under_mnu == null) {
if (mnu_is_popup) {
if (String_.Eq(key, Xog_popup_mnu_mgr.Root_key_tabs_btns))

View File

@ -122,7 +122,7 @@ public class Xog_tab_mgr implements GfoEvObj {
}
public void Tabs_close_cur() {
if (this.Active_tab_is_null()) return;
if (!active_tab.Page().Tab_data().Close_mgr().When_close(active_tab)) return;
Tabs__pub_close(active_tab);
tab_mgr.Tabs_close_by_idx(active_tab.Tab_idx());
Xog_tab_itm cur_tab = this.Active_tab(); // get new current tab for line below
if (cur_tab != null) cur_tab.Html_box().Focus(); // NOTE: needed to focus tab box else tab button will be focused; DATE:2014-07-13
@ -133,11 +133,24 @@ public class Xog_tab_mgr implements GfoEvObj {
public void Tabs_close_rng(int bgn, int end) {
for (int i = bgn; i < end; i++) {
Xog_tab_itm tab = Tabs_get_at(bgn);
if (tab.Page().Tab_data().Close_mgr().When_close(tab))
tab_mgr.Tabs_close_by_idx(bgn);
if (!Tabs__pub_close(tab)) return;
}
for (int i = bgn; i < end; i++)
tab_mgr.Tabs_close_by_idx(bgn); // NOTE: close at bgn, not at i, b/c each close will remove a tab from collection
}
public boolean Tabs__pub_close_all() {return Tabs__pub_close_rng(0, this.Tabs_len());}
public boolean Tabs__pub_close_rng(int bgn, int end) {
boolean rv = true;
for (int i = bgn; i < end; i++) {
Xog_tab_itm tab = Tabs_get_at(i);
boolean close_allowed = Tabs__pub_close(tab);
if (!close_allowed) rv = false;
}
return rv;
}
public boolean Tabs__pub_close(Xog_tab_itm tab) {
return tab.Page().Tab_data().Close_mgr().When_close(tab);
}
public void Tabs_close_all() {Tabs_close_rng(0, Tabs_len());}
public void Tabs_close_undo() {
if (closed_undo_list.Count() == 0) return;
String url = (String)ListAdp_.Pop(closed_undo_list);

View File

@ -180,6 +180,8 @@ public class Xog_win_itm implements GfoInvkAble, GfoEvObj {
Xoae_page cur_page = tab.Page(); Xowe_wiki cur_wiki = tab.Wiki();
Xoae_page new_page = tab.History_mgr().Go_by_dir(cur_wiki, fwd);
if (new_page.Missing()) return;
if (new_page.Wikie().Special_mgr().Page_search().Match_ttl(new_page.Ttl())) // if Special:Search, reload page; needed for async loading; DATE:2015-04-19
new_page = new_page.Wikie().GetPageByTtl(new_page.Url(), new_page.Ttl()); // NOTE: must reparse page if (a) Edit -> Read; or (b) "Options" save
byte history_nav_type = fwd ? Xog_history_stack.Nav_fwd : Xog_history_stack.Nav_bwd;
boolean new_page_is_same = Bry_.Eq(cur_page.Ttl().Full_txt(), new_page.Ttl().Full_txt());
Xog_tab_itm_read_mgr.Show_page(tab, new_page, true, new_page_is_same, false, history_nav_type);

View File

@ -211,12 +211,11 @@ public class Xoh_file_wtr__basic {
return scratch_bfr.Xto_bry_and_clear();
}
private static byte[] Arg_anchor_title(Bry_bfr tmp_bfr, byte[] src, Xop_lnki_tkn lnki, byte[] lnki_ttl, Xoh_lnki_title_fmtr anchor_title_wkr) {
switch (lnki.Lnki_type()) {
case Xop_lnki_type.Id_thumb: // If the image is a thumb, do not add a title / alt, even if a caption is available
case Xop_lnki_type.Id_frame:
if ( Enm_.HasInt(lnki.Lnki_type(), Xop_lnki_type.Id_thumb)
|| Enm_.HasInt(lnki.Lnki_type(), Xop_lnki_type.Id_frame) // If the image is a thumb, do not add a title / alt, even if a caption is available
)
return Bry_.Empty;
case Xop_lnki_type.Id_frameless: // If the image is frameless, add the caption as a title / alt. If no caption is available, do not add a title / alt
break;
else if ( Enm_.HasInt(lnki.Lnki_type(), Xop_lnki_type.Id_frameless)) { // If the image is frameless, add the caption as a title / alt. If no caption is available, do not add a title / alt
}
Xop_tkn_itm anchor_title_tkn = lnki.Caption_tkn();
if (anchor_title_tkn == Xop_tkn_null.Null_tkn) return Bry_.Empty; // no caption; return empty; (do not use lnki); DATE:2013-12-31

View File

@ -98,6 +98,26 @@ public class Xoh_file_wtr_basic_tst {
, ""
));
}
@Test public void Img_frame_and_thumb() { // PURPOSE: lnki with "frame and thumb" was not showing box due to bit-adding; PAGE:en.w:History_of_Western_Civilization DATE:2015-04-16
fxt.Test_parse_page_wiki_str
( "[[File:A.png|frame|thumb|220x110px|b]]" // NOTE: frame AND thumb
, String_.Concat_lines_nl_skip_last
( "<div class=\"thumb tright\">"
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">"
, " <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/220px.png\" width=\"220\" height=\"110\" /></a>"
, " <div class=\"thumbcaption\">"
, " <div class=\"magnify\">"
, " <a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\">"
, " <img src=\"file:///mem/xowa/user/test_user/app/img/file/magnify-clip.png\" width=\"15\" height=\"11\" alt=\"\" />"
, " </a>"
, " </div>"
, " b"
, " </div>"
, " </div>"
, "</div>"
, ""
));
}
@Test public void Cls_border() {
fxt.Test_parse_page_wiki_str
( "[[File:A.png|border]]"

File diff suppressed because it is too large Load Diff

View File

@ -229,8 +229,7 @@ class HttpRequest implements Runnable{
else
req += app.Http_server().Home();
}
if(req.endsWith("wiki/")) req+="Main_Page";
if(req.endsWith("wiki")) req+="/Main_Page";
req = Http_server_wkr_.Assert_main_page(app, req);
}
if(req.contains("%xowa-cmd%") || req.contains("/xowa-cmd:")){

View File

@ -0,0 +1,39 @@
/*
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.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.servers.*;
import gplx.xowa.wikis.*; import gplx.xowa.langs.*;
class Http_server_wkr_ {
public static String Assert_main_page(Xoae_app app, String req) {
int mode = -1;
String[] req_array = String_.Split(req, "/");
if (String_.HasAtEnd(req, "wiki/")) mode = 0;
else if (String_.HasAtEnd(req, "wiki")) mode = 1;
else if (req_array.length == 3) mode = 2;
if (mode == -1) return req; // not a link to a Main Page; EX:localhost:8080/en.wikipedia.org/wiki/Earth
if (req_array.length < 3) return req; // shouldn't happen; EX: "localhost:8080wiki"
byte[] wiki_domain = Bry_.new_utf8_(req_array[1]);
Xow_domain domain_itm = Xow_domain_.parse(wiki_domain);
if (domain_itm.Domain_tid() == Xow_domain_.Tid_int_other && domain_itm.Lang_itm().Id() == Xol_lang_itm_.Id__intl) return req;
Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(wiki_domain);
wiki.Init_assert();
String main_page = String_.new_utf8_(wiki.Props().Main_page());
if (mode == 1) main_page = "/" + main_page;
else if (mode == 2) main_page = "wiki/" + main_page;
return req + main_page;
}
}

View File

@ -0,0 +1,42 @@
/*
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.servers.http; import gplx.*; import gplx.xowa.*; import gplx.xowa.servers.*;
import org.junit.*;
public class Http_server_wkr__tst {
@Before public void init() {fxt.Clear();} private Http_server_wkr__fxt fxt = new Http_server_wkr__fxt();
@Test public void Assert_main_page() {
fxt.Init_wiki_main_page("fr.wikiversity.org", "Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/" , "/fr.wikiversity.org/wiki/Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/wiki" , "/fr.wikiversity.org/wiki/Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/wiki/" , "/fr.wikiversity.org/wiki/Accueil");
fxt.Test_assert_main_page("/fr.wikiversity.org/wiki/A" , "/fr.wikiversity.org/wiki/A");
}
}
class Http_server_wkr__fxt {
private Xoae_app app;
public void Clear() {
this.app = Xoa_app_fxt.app_();
}
public void Init_wiki_main_page(String domain, String main_page) {
Xowe_wiki wiki = app.Wiki_mgr().Get_by_key_or_make(Bry_.new_utf8_(domain));
wiki.Props().Main_page_(Bry_.new_utf8_(main_page));
}
public void Test_assert_main_page(String url, String expd) {
Tfds.Eq(expd, Http_server_wkr_.Assert_main_page(app, url));
}
}

View File

@ -41,7 +41,7 @@ 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() { // MAINT:QUARTERLY:2015-03-01
// @Test public void Update() { // MAINT:QUARTERLY:2015-03-01; must run C:\xowa\ and update dump status
// 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"

View File

@ -34,6 +34,7 @@ class Xows_db_wkr {
, wiki.Data_mgr__core_mgr().Db__search().Tbl__search_word()
);
}
Xoa_app_.Usr_dlg().Prog_many("", "", "search started (please wait)");
// load pages for each word
Xows_db_matcher matcher = cache.Matcher();
Xows_db_word[] word_ary = cache.Words();

View File

@ -78,7 +78,7 @@ class Xows_html_wkr {
private static final Bry_fmtr fmtr_tbl = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<table class='wikitable sortable'>"
, " <tr>"
, " <th colspan='2' style='text-align:left'><a href='/site/home/wiki/Help:Special/Search'>Help</a>"
, " <th colspan='2' style='text-align:left'><a href='/site/home/wiki/Help:Special/Search'>Help</a>" // SERVER:"<a href='"; DATE:2015-04-16
, " </th>"
, " </tr>"
, " <tr>"
@ -95,8 +95,8 @@ class Xows_html_wkr {
, " </tr>"
, "</table>"
), "wiki", "cancel", "hdr_len", "hdr_ttl", "insert_key", "rows");
private static final Bry_fmtr fmtr_link = Bry_fmtr.new_("<a href='~{a_href}' title='~{a_title}'>~{a_text}</a>", "a_href", "a_title", "a_text");
private static final Bry_fmtr fmtr_link_id = Bry_fmtr.new_("<a id='~{a_id}' href='~{a_href}' title='~{a_title}'>~{a_text}</a>", "a_id", "a_href", "a_title", "a_text");
private static final Bry_fmtr fmtr_link = Bry_fmtr.new_("<a href='~{a_href}' title='~{a_title}'>~{a_text}</a>", "a_href", "a_title", "a_text"); // SERVER:"<a href='"; DATE:2015-04-16
private static final Bry_fmtr fmtr_link_id = Bry_fmtr.new_("<a href='~{a_href}' title='~{a_title}' id='~{a_id}'>~{a_text}</a>", "a_id", "a_href", "a_title", "a_text"); // SERVER:"<a href='"; DATE:2015-04-16
private static final Bry_fmtr_vals fmtr_paging_bwd = Bry_fmtr_vals.new_(fmtr_link);
private static final Bry_fmtr_vals fmtr_paging_fwd = Bry_fmtr_vals.new_(fmtr_link);
private static final Bry_fmtr_vals fmtr_paging_cxl = Bry_fmtr_vals.new_(fmtr_link_id);
@ -126,7 +126,7 @@ class Xows_html_row implements Bry_fmtr_arg {
, " <tr id='~{page_key}'>"
, " <td>~{page_len}"
, " </td>"
, " <td><a href='~{a_href}' title='~{a_title}'>~{a_text}</a>"
, " <td><a href='~{a_href}' title='~{a_title}'>~{a_text}</a>" // SERVER:"<a href='"; DATE:2015-04-16
, " </td>"
, " </tr>"
), "page_key", "page_len", "a_href", "a_title", "a_text");

View File

@ -17,13 +17,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.specials.search; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
import gplx.core.primitives.*; import gplx.xowa.wikis.*; import gplx.xowa.apis.xowa.specials.*;
public class Xows_page__search implements Xows_page {
import gplx.xowa.wikis.domains.crts.*;
public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
private final Xow_domain wiki_domain; private final Xoapi_search search_api;
private final Xows_core search_mgr; private final Xows_arg_mgr args_mgr = new Xows_arg_mgr();
private Xow_domain_crt_itm multi_wiki_crt;
public Xows_page__search(Xowe_wiki wiki) {
this.wiki_domain = wiki.Domain_itm();
this.search_mgr = new Xows_core(wiki.Appe().Wiki_mgr());
this.ev_mgr = GfoEvMgr.new_(this);
this.search_api = wiki.Appe().Api_root().Special().Search();
}
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Xoapi_search.Evt_multi_wiki_rules_changed)) this.multi_wiki_crt = search_api.Multi_wiki_crt(wiki_domain);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
public boolean Match_ttl(Xoa_ttl ttl) {
return ttl.Ns().Id_special() && Bry_.Eq(ttl.Root_txt(), Bry_search);
}
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
if (wiki.Domain_tid() == Xow_domain_.Tid_int_home) return; // do not allow search in home wiki; will throw null ref error b/c no search_ttl dirs
if (multi_wiki_crt == null) {
this.multi_wiki_crt = search_api.Multi_wiki_crt(wiki.Domain_itm());
GfoEvMgr_.SubSame_many(search_api, this, Xoapi_search.Evt_multi_wiki_rules_changed);
}
// get args
Xog_search_suggest_mgr search_suggest_mgr = wiki.Appe().Gui_mgr().Search_suggest_mgr();
args_mgr.Clear();
@ -56,7 +75,6 @@ public class Xows_page__search implements Xows_page {
}
page.Html_data().Html_restricted_n_();
page.Html_data().Xtn_search_text_(search_bry);
Xoapi_search search_api = wiki.Appe().Api_root().Special().Search();
Xows_ui_qry qry = new Xows_ui_qry(search_bry, args_mgr.Paging_idx(), search_api.Results_per_page(), args_mgr.Sort_tid(), args_mgr.Ns_mgr(), search_api.Async_db(), Bry_.Ary(wiki.Domain_bry()));
search_mgr.Search(wiki, page, qry);
}
@ -71,5 +89,5 @@ public class Xows_page__search implements Xows_page {
}
public static final byte Match_tid_all = 0, Match_tid_bgn = 1;
public static final byte Version_null = 0, Version_1 = 1, Version_2 = 2;
private static final byte[] Bry_special_name = Bry_.new_ascii_("Special:Search");
private static final byte[] Bry_special_name = Bry_.new_ascii_("Special:Search"), Bry_search = Bry_.new_ascii_("Search");
}

View File

@ -48,6 +48,7 @@ class Xows_ui_cmd implements GfoInvkAble, Cancelable, Xog_tab_close_lnr {
if (canceled) return; // NOTE: must check else throws SWT exception
}
js_wkr.Html_atr_set("xowa_cancel_" + wiki.Domain_str(), "style", "display:none;");
qry.Page_max_(cache.Count() / qry.Page_len());
Xoa_app_.Usr_dlg().Prog_many("", "", "");
}
public boolean Search() {
@ -55,7 +56,7 @@ class Xows_ui_cmd implements GfoInvkAble, Cancelable, Xog_tab_close_lnr {
boolean rv = false;
if (qry.Itms_end() > cache.Count() && !cache.Done()) {
if (async)
ThreadAdp_.invk_(this, Invk_search_db).Start();
ThreadAdp_.invk_("xowa.special.search", this, Invk_search_db).Start();
else
Search_db();
rv = true;

View File

@ -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.wikis; import gplx.*; import gplx.xowa.*;
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*; import gplx.xowa.wikis.domains.crts.*;
public class Xoa_wiki_mgr implements GfoInvkAble {
private Xoae_app app;
private ListAdp list = ListAdp_.new_(); private Hash_adp_bry hash = Hash_adp_bry.ci_ascii_(); // ASCII:url_domain; EX:en.wikipedia.org
@ -42,6 +42,15 @@ public class Xoa_wiki_mgr implements GfoInvkAble {
if (rv == null) rv = New_wiki(key);
return rv;
}
public Xowe_wiki[] Get_by_crt(Xow_domain cur, Xow_domain_crt_itm crt) {
ListAdp rv = ListAdp_.new_();
int len = this.Count();
for (int i = 0; i < len; ++i) {
Xow_wiki wiki = this.Get_at(i);
if (crt.Matches(cur, wiki.Domain_itm())) rv.Add(wiki);
}
return (Xowe_wiki[])rv.Xto_ary_and_clear(Xowe_wiki.class);
}
public Xowe_wiki Wiki_commons() {
Xowe_wiki rv = this.Get_by_key_or_null(Xow_domain_.Domain_bry_commons);
if (rv != null) rv.Init_assert();

View File

@ -34,7 +34,7 @@ public class Xow_domain_ {
, Domain_bry_wikimediafoundation = Bry_.new_ascii_("wikimediafoundation.org")
, Domain_bry_species = Bry_.new_ascii_("species.wikimedia.org")
;
private static final byte Tid_int_null = Byte_.Max_value_127;
public static final byte Tid_int_null = Byte_.Max_value_127;
public static final int
Tid_int_other = 0, Tid_int_home = 1
, Tid_int_wikipedia = 2, Tid_int_wiktionary = 3, Tid_int_wikisource = 4, Tid_int_wikibooks = 5, Tid_int_wikiversity = 6, Tid_int_wikiquote = 7, Tid_int_wikinews = 8, Tid_int_wikivoyage = 9
@ -86,8 +86,9 @@ public class Xow_domain_ {
.Add_bry_int(Tid_bry_other , Tid_int_other)
;
public static byte[] Tid__get_bry(int tid) {return Tid_bry__ary[tid];}
public static int Tid__get_int(byte[] key) {
Object o = hash_tid_by_bry.Get_by_bry(key);
public static int Tid__get_int(byte[] key) {return Tid__get_int(key, 0, key.length);}
public static int Tid__get_int(byte[] key, int bgn, int end) {
Object o = hash_tid_by_bry.Get_by_mid(key, bgn, end);
return o == null ? Tid_int_null : ((Int_obj_val)o).Val();
}
public static Xow_domain parse(byte[] raw) {

View File

@ -73,7 +73,7 @@ public class Xowd_db_file {
public static final Xowd_db_file Null = null;
public static Xowd_db_file make_(Xob_info_session info_session, Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, String core_file_name, Db_conn conn) {
Guid_adp guid = Guid_adp_.random_();
Guid_adp guid = Guid_adp_.new_();
Xob_info_file info_file = new Xob_info_file(id, Xowd_db_file_.To_key(tid), ns_ids, part_id, guid, props.Schema(), core_file_name, url.NameAndExt());
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg");
Xowd_db_file rv = new Xowd_db_file(cfg_tbl, info_session, info_file, props, Xowd_db_file_schema_props.make_(), id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_create);

View File

@ -94,7 +94,7 @@ public class Xowd_db_mgr {
switch (db.Tid()) {
case Xowd_db_file_.Tid_wiki_solo:
case Xowd_db_file_.Tid_text_solo:
case Xowd_db_file_.Tid_core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__search = db; break;}
case Xowd_db_file_.Tid_core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__search = db__text = db; break;}
case Xowd_db_file_.Tid_text : {db__text = db; break;}
case Xowd_db_file_.Tid_html_data : {db__html = db; break;}
case Xowd_db_file_.Tid_search_core : {if (db__search == null) db__search = db; break;}

View File

@ -210,7 +210,10 @@ public class Xowd_page_tbl implements RlsAble {
;
int limit = fwd ? max_results + 1 : max_results; // + 1 to get next item
Db_qry__select_cmd qry = Db_qry_.select_cols_(tbl_name, crt, cols).Limit_(limit).OrderBy_(fld_title, fwd);
return conn.Stmt_new(qry).Crt_int(fld_ns, ns_id).Crt_str(fld_title, ttl_frag_str).Crt_int(fld_len, min_page_len).Exec_select__rls_auto();
Db_stmt stmt = conn.Stmt_new(qry).Crt_int(fld_ns, ns_id).Crt_str(fld_title, ttl_frag_str).Crt_int(fld_len, min_page_len);
if (!include_redirects)
stmt.Crt_bool_as_byte(fld_is_redirect, include_redirects);
return stmt.Exec_select__rls_auto();
}
public void Select_for_special_all_pages(Cancelable cancelable, ListAdp rslt_list, Xowd_page_itm rslt_nxt, Xowd_page_itm rslt_prv, Int_obj_ref rslt_count, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item) {
Xowd_page_itm nxt_itm = null;

View File

@ -58,11 +58,15 @@ public class Xowd_search_word_tbl implements RlsAble {
ListAdp list = ListAdp_.new_();
Db_rdr rdr = stmt_select_in.Clear().Crt_bry_as_str(fld_text, Bry_.Replace(word, Byte_ascii.Asterisk, Byte_ascii.Percent)).Exec_select__rls_manual();
try {
int row_count = 0;
while (rdr.Move_next()) {
synchronized (cxl) {
if (cxl.Canceled()) break;
}
list.Add(new_row(rdr));
Xowd_search_word_row word_row = new_row(rdr);
if (++row_count % 100 == 0)
Xoa_app_.Usr_dlg().Prog_many("", "", "search; reading pages for word: word=~{0} pages=~{1}", word_row.Text(), word_row.Page_count());
list.Add(word_row);
}
}
finally {rdr.Rls();}

View File

@ -0,0 +1,22 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
import gplx.core.primitives.*;
public interface Xow_domain_crt_itm {
boolean Matches(Xow_domain cur, Xow_domain comp);
}

View File

@ -0,0 +1,81 @@
/*
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.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
class Xow_domain_crt_itm__any_wiki implements Xow_domain_crt_itm {
public boolean Matches(Xow_domain cur, Xow_domain comp) {return true;}
public static final Xow_domain_crt_itm__any_wiki I = new Xow_domain_crt_itm__any_wiki(); Xow_domain_crt_itm__any_wiki() {}
}
class Xow_domain_crt_itm__in implements Xow_domain_crt_itm {
private final Xow_domain_crt_itm[] ary;
public Xow_domain_crt_itm__in(Xow_domain_crt_itm[] ary) {this.ary = ary;}
public boolean Matches(Xow_domain cur, Xow_domain comp) {
int len = ary.length;
for (int i = 0; i < len; ++i) {
Xow_domain_crt_itm itm = ary[i];
if (itm.Matches(cur, comp)) return true;
}
return false;
}
}
class Xow_domain_crt_itm__any_standard implements Xow_domain_crt_itm {
public boolean Matches(Xow_domain cur, Xow_domain comp) {
switch (comp.Domain_tid()) {
case Xow_domain_.Tid_int_wikipedia:
case Xow_domain_.Tid_int_wiktionary:
case Xow_domain_.Tid_int_wikisource:
case Xow_domain_.Tid_int_wikivoyage:
case Xow_domain_.Tid_int_wikiquote:
case Xow_domain_.Tid_int_wikibooks:
case Xow_domain_.Tid_int_wikiversity:
case Xow_domain_.Tid_int_wikinews: return true;
default: return false;
}
}
public static final Xow_domain_crt_itm__any_standard I = new Xow_domain_crt_itm__any_standard(); Xow_domain_crt_itm__any_standard() {}
}
class Xow_domain_crt_itm__null implements Xow_domain_crt_itm {
public boolean Matches(Xow_domain cur, Xow_domain comp) {throw Err_.not_implemented_msg_("null criteria should not be called");}
public static final Xow_domain_crt_itm I = new Xow_domain_crt_itm__null(); Xow_domain_crt_itm__null() {}
}
class Xow_domain_crt_itm__self implements Xow_domain_crt_itm {
public boolean Matches(Xow_domain cur, Xow_domain comp) {return Bry_.Eq(cur.Domain_bry(), comp.Domain_bry());}
public static final Xow_domain_crt_itm__self I = new Xow_domain_crt_itm__self(); Xow_domain_crt_itm__self() {}
}
class Xow_domain_crt_itm__same_lang implements Xow_domain_crt_itm {
public boolean Matches(Xow_domain cur, Xow_domain comp) {return cur.Lang_uid() == comp.Lang_uid();}
public static final Xow_domain_crt_itm__same_lang I = new Xow_domain_crt_itm__same_lang(); Xow_domain_crt_itm__same_lang() {}
}
class Xow_domain_crt_itm__same_type implements Xow_domain_crt_itm {
public boolean Matches(Xow_domain cur, Xow_domain comp) {return cur.Domain_tid() == comp.Domain_tid();}
public static final Xow_domain_crt_itm__same_type I = new Xow_domain_crt_itm__same_type(); Xow_domain_crt_itm__same_type() {}
}
class Xow_domain_crt_itm__lang implements Xow_domain_crt_itm {
private final int lang_uid;
public Xow_domain_crt_itm__lang(int lang_uid) {this.lang_uid = lang_uid;}
public boolean Matches(Xow_domain cur, Xow_domain comp) {return comp.Lang_uid() == lang_uid;}
}
class Xow_domain_crt_itm__type implements Xow_domain_crt_itm {
private final int wiki_tid;
public Xow_domain_crt_itm__type(int wiki_tid) {this.wiki_tid = wiki_tid;}
public boolean Matches(Xow_domain cur, Xow_domain comp) {return comp.Domain_tid() == wiki_tid;}
}
class Xow_domain_crt_itm__wiki implements Xow_domain_crt_itm {
private final byte[] domain;
public Xow_domain_crt_itm__wiki(byte[] domain) {this.domain = domain;}
public boolean Matches(Xow_domain cur, Xow_domain comp) {return Bry_.Eq(comp.Domain_bry(), domain);}
}

View File

@ -0,0 +1,69 @@
/*
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.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
import gplx.xowa.langs.*;
class Xow_domain_crt_itm_parser {
public Xow_domain_crt_kv[] Parse_as_kv_ary_or_null(byte[] raw) {
ListAdp rv = ListAdp_.new_();
byte[][] line_ary = Bry_.Split_lines(raw);
int line_len = line_ary.length;
for (int i = 0; i < line_len; ++i) {
byte[] line = line_ary[i];
if (line.length == 0) continue; // ignore blank lines
byte[][] word_ary = Bry_.Split(line, Byte_ascii.Pipe);
int word_len = word_ary.length;
if (word_len != 2) return null; // not A|B; exit now;
Xow_domain_crt_itm key_itm = Xow_domain_crt_itm_parser.I.Parse_as_in(word_ary[0]);
if (key_itm == Xow_domain_crt_itm__null.I) return null; // invalid key; exit
Xow_domain_crt_itm val_itm = Xow_domain_crt_itm_parser.I.Parse_as_in(word_ary[1]);
if (val_itm == Xow_domain_crt_itm__null.I) return null; // invalid val; exit
rv.Add(new Xow_domain_crt_kv(key_itm, val_itm));
}
return (Xow_domain_crt_kv[])rv.Xto_ary_and_clear(Xow_domain_crt_kv.class);
}
public Xow_domain_crt_itm Parse_as_in(byte[] raw) {
byte[][] terms = Bry_.Split(raw, Byte_ascii.Comma, Bool_.Y);
int len = terms.length;
Xow_domain_crt_itm[] rv_ary = new Xow_domain_crt_itm[len];
for (int i = 0; i < len; ++i)
rv_ary[i] = Parse_itm(terms[i]);
return new Xow_domain_crt_itm__in(rv_ary);
}
public Xow_domain_crt_itm Parse_itm(byte[] raw) {
Xow_domain_crt_itm rv = (Xow_domain_crt_itm)itm_hash.Get_by_bry(raw); if (rv != null) return rv; // singleton; EX: <self>, <same_type>, etc..
int raw_len = raw.length;
if (Bry_.HasAtBgn(raw, Wild_lang)) { // EX: *.wikipedia
int wiki_tid = Xow_domain_.Tid__get_int(raw, Wild_lang.length, raw_len);
return wiki_tid == Xow_domain_.Tid_int_null ? Xow_domain_crt_itm__null.I : new Xow_domain_crt_itm__type(wiki_tid);
}
else if (Bry_.HasAtEnd(raw, Wild_type)) { // EX: en.*
Xol_lang_itm lang_itm = Xol_lang_itm_.Get_by_key(raw, 0, raw_len - Wild_type.length);
return lang_itm == null ? Xow_domain_crt_itm__null.I : new Xow_domain_crt_itm__lang(lang_itm.Id());
}
else
return new Xow_domain_crt_itm__wiki(raw); // EX: en.wikipedia.org
}
private static final Hash_adp_bry itm_hash = Hash_adp_bry.cs_()
.Add_str_obj("<self>" , Xow_domain_crt_itm__self.I)
.Add_str_obj("<same_type>" , Xow_domain_crt_itm__same_type.I)
.Add_str_obj("<same_lang>" , Xow_domain_crt_itm__same_lang.I)
.Add_str_obj("*.*" , Xow_domain_crt_itm__any_standard.I)
;
private static final byte[] Wild_lang = Bry_.new_ascii_("*."), Wild_type = Bry_.new_ascii_(".*");
public static final Xow_domain_crt_itm_parser I = new Xow_domain_crt_itm_parser(); Xow_domain_crt_itm_parser() {}
}

View File

@ -0,0 +1,45 @@
/*
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.wikis.domains.crts; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*;
public class Xow_domain_crt_kv_mgr {
private final ListAdp list = ListAdp_.new_();
public void Clear() {list.Clear();}
@gplx.Internal protected void Add(Xow_domain_crt_kv itm) {list.Add(list);}
public boolean Parse(byte[] raw) {
Xow_domain_crt_kv[] ary = Xow_domain_crt_itm_parser.I.Parse_as_kv_ary_or_null(raw);
if (ary == null) return false; // invalid parse; leave current value as is and exit;
this.Clear();
int len = ary.length;
for (int i = 0; i < len; ++i)
this.Add(ary[i]);
return true;
}
public Xow_domain_crt_itm Find(Xow_domain cur, Xow_domain comp) {
int len = list.Count();
for (int i = 0; i < len; ++i) {
Xow_domain_crt_kv kv = (Xow_domain_crt_kv)list.FetchAt(i);
if (kv.Key().Matches(cur, comp)) return kv.Val();
}
return Xow_domain_crt_itm__null.I;
}
}
class Xow_domain_crt_kv {
public Xow_domain_crt_kv(Xow_domain_crt_itm key, Xow_domain_crt_itm val) {this.key = key; this.val = val;}
public Xow_domain_crt_itm Key() {return key;} private final Xow_domain_crt_itm key;
public Xow_domain_crt_itm Val() {return val;} private final Xow_domain_crt_itm val;
}

View File

@ -62,6 +62,11 @@ public class Gallery_itm_parser {
if (cur_itm.Link_bgn() != -1)
lnki_tkn.Link_tkn_(new Arg_nde_tkn_mock("link", String_.new_utf8_(src, cur_itm.Link_bgn(), cur_itm.Link_end()))); // NOTE: hackish, but add the link as arg_nde, since gallery link is not parsed like a regular lnki
cur_itm.Lnki_tkn_(lnki_tkn);
if (cur_itm.Page_bgn() != -1) {
int page_val = Bry_.Xto_int_or(src, cur_itm.Page_bgn(), cur_itm.Page_end(), -1);
if (page_val == -1) Xoa_app_.Usr_dlg().Warn_many("", "", "page is not an int: wiki=~{0} ttl=~{1} page=~{2}", wiki.Domain_str(), ctx.Cur_page().Ttl().Page_db(), String_.new_utf8_(src, cur_itm.Page_bgn(), cur_itm.Page_end()));
lnki_tkn.Page_(page_val);
}
byte[] lnki_caption = cur_itm.Caption_bry();
if (Bry_.Len_gt_0(lnki_caption)) {
Xop_root_tkn caption_tkn = wiki.Parser().Parse_text_to_wdom_old_ctx(ctx, lnki_caption, true);

View File

@ -80,6 +80,12 @@ public class Gallery_mgr_base_basic_tst {
@Test public void Link() {
fxt.Test_html_frag("<gallery>File:A.png|b|link=c</gallery>", "<a href=\"/wiki/C\" class=\"image\"");
}
@Test public void Page() { // PURPOSE: page was not being set; PAGE:pt.s:Portal:Diccionario_geographico_do_Brazil; DATE:2015-04-16
fxt.Test_html_frag
( "<gallery>File:A.pdf|b|page=8</gallery>"
, "A.pdf/120px-8.jpg" // make sure page 8 shows up
);
}
@Test public void Alt_caption_multiple() {
fxt.Test_html_frag("<gallery>File:A.png|alt=b|c[[d|e]]f</gallery>", "<div class=\"gallerytext\"><p>c<a href=\"/wiki/D\">ef</a>\n</p>");
}

View File

@ -60,8 +60,8 @@ public class Scrib_invoke_func extends Pf_func_base {
String invoke_error = Err_msg_make(e);
Error(bfr, wiki.Msg_mgr(), invoke_error);
bfr.Add(Html_tag_.Comm_bgn).Add_str(Err_.Message_gplx_brief(e)).Add(Html_tag_.Comm_end);
Scrib_err_filter_mgr err_filter_mgr = invoke_wkr.Err_filter_mgr();
if (err_filter_mgr.Count_gt_0() && err_filter_mgr.Match(String_.new_utf8_(mod_name), String_.new_utf8_(fnc_name), invoke_error))
Scrib_err_filter_mgr err_filter_mgr = invoke_wkr == null ? null : invoke_wkr.Err_filter_mgr();
if (err_filter_mgr == null || (err_filter_mgr.Count_gt_0() && err_filter_mgr.Match(String_.new_utf8_(mod_name), String_.new_utf8_(fnc_name), invoke_error)))
ctx.App().Usr_dlg().Warn_many("", "", "invoke failed: ~{0} ~{1} ~{2}", String_.new_utf8_(ctx.Cur_page().Ttl().Raw()), String_.new_utf8_(src, self.Src_bgn(), self.Src_end()), Err_.Message_gplx_brief(e));
Scrib_core.Core_invalidate_when_page_changes(); // NOTE: invalidate core when page changes, not for rest of page, else page with many errors will be very slow due to multiple invalidations; PAGE:th.d:all; DATE:2014-10-03
}

View File

@ -16,14 +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.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
interface Xow_wmf_api_wkr {
void Api_init();
void Api_term();
boolean Api_wiki_enabled(String wiki_domain);
String Api_qargs();
boolean Api_exec(String wiki_domain, byte[] rslt);
}
class Xow_wmf_api_mgr {
public class Xow_wmf_api_mgr {
public void Trg_engine_key(String v) {this.trg_engine_key = v;} private String trg_engine_key = gplx.ios.IoEngine_.SysKey;
public void Api_exec(Xow_wmf_api_wkr wkr) {this.Api_exec(Wikis, wkr);}
public void Api_exec(String[] wiki_ary, Xow_wmf_api_wkr wkr) {
@ -864,6 +857,9 @@ class Xow_wmf_api_mgr {
, "zu.wikipedia.org"
, "zu.wiktionary.org"
, "zu.wikibooks.org"
, "ne.wikipedia.org"
, "ne.wiktionary.org"
, "ne.wikibooks.org"
};
//, "als.wikisource.org"
//, "als.wikinews.org"

View File

@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
public interface Xow_wmf_api_wkr {
void Api_init();
void Api_term();
boolean Api_wiki_enabled(String wiki_domain);
String Api_qargs();
boolean Api_exec(String wiki_domain, byte[] rslt);
}

View File

@ -72,7 +72,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser {
data_mgr__core_mgr = new Xowd_db_mgr(fsys_mgr.Root_dir(), domain_itm);
Io_url core_url = gplx.xowa.wikis.Xow_fsys_mgr.Find_core_fil(fsys_mgr.Root_dir(), domain_str);
data_mgr__core_mgr.Init_by_load(core_url);
this.db_core_mgr = Fsdb_db_mgr_.new_detect(domain_str, fsys_mgr.Root_dir(), fsys_mgr.File_dir());
this.db_core_mgr = Fsdb_db_mgr_.new_detect(this, fsys_mgr.Root_dir(), fsys_mgr.File_dir());
if (db_core_mgr != null) // will be null for xowa db
fsdb_mgr.Mnt_mgr().Ctor_by_load(db_core_mgr);
file_mgr__repo_mgr.Add_repo(app, fsys_mgr.File_dir(), Bry_.new_utf8_("commons.wikimedia.org"), Bry_.new_utf8_("simple.wikipedia.org"));

View File

@ -95,7 +95,7 @@ public class Xow_ns implements GfoInvkAble {
public boolean Exists() {return exists;} public Xow_ns Exists_(boolean v) {exists = v; return this;} private boolean exists;
public Xob_ns_file_itm Bldr_data() {return bldr_data;} public void Bldr_data_(Xob_ns_file_itm v) {bldr_data = v;} private Xob_ns_file_itm bldr_data;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_subpages_enabled_)) subpages_enabled = m.ReadYn("v");
if (ctx.Match(k, Invk_subpages_enabled_)) this.subpages_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_id)) return id;
else if (ctx.Match(k, Invk_name_txt)) return name_txt;
else if (ctx.Match(k, Invk_name_ui)) return Name_ui();

View File

@ -217,31 +217,30 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble {
}
init_in_process = true;
if (app.Stage() == Xoa_stage_.Tid_launch) init_needed = false; // NOTE: only mark inited if app fully launched; otherwise statements in xowa.gfs can fire and prematurely set home to inited; DATE:2013-03-24
Gfo_log_bfr log_bfr = app.Log_bfr();
log_bfr.Add("wiki.init.bgn: " + domain_str);
Gfo_log_bfr log_bfr = app.Log_bfr(); log_bfr.Add("wiki.init.bgn: " + domain_str);
app.Cfg_mgr().Init(this);
file_mgr.Cfg_download().Enabled_(app.File_mgr().Wmf_mgr().Enabled()); // default download to app global; can be overriden below
app.Gfs_mgr().Run_url_for(this, tdb_fsys_mgr.Cfg_wiki_stats_fil());
app.Gfs_mgr().Run_url_for(this, app.Fsys_mgr().Cfg_wiki_core_dir().GenSubFil(domain_str + ".gfs")); // run cfg for wiki by user ; EX: /xowa/user/anonymous/wiki/en.wikipedia.org/cfg/user_wiki.gfs
Init_db_mgr();
// FIXME: commented out; fires multiple times during import process
if (!app.Bldr().Import_marker().Chk(this)) {app.Wiki_mgr().Del(domain_bry); init_needed = false; return;} // NOTE: must call after Db_mgr_create_as_sql(); also, must delete wiki from mgr; DATE:2014-08-24
db_mgr.Load_mgr().Load_init(this);
app.Gfs_mgr().Run_url_for(this, tdb_fsys_mgr.Cfg_wiki_core_fil());
gplx.xowa.utls.upgrades.Xoa_upgrade_mgr.Check(this);
// init ns_mgr
if (lang.Init_by_load()) {
if (domain_tid == Xow_domain_.Tid_int_wikipedia) // NOTE: if type is wikipedia, add "Wikipedia" as an alias; PAGE:en.w:pt.wikipedia.org/wiki/Página principal which redirects to Wikipedia:Página principal
ns_mgr.Aliases_add(Xow_ns_.Id_project, Xow_ns_.Ns_name_wikipedia);
}
app.Gfs_mgr().Run_url_for(this, app.Fsys_mgr().Cfg_wiki_core_dir().GenSubFil(domain_str + ".gfs")); // NOTE: must be run after lang.Init_by_load b/c lang will reload ns_mgr; DATE:2015-04-17run cfg for wiki by user ; EX: /xowa/user/anonymous/wiki/en.wikipedia.org/cfg/user_wiki.gfs
cfg_parser.Xtns().Itm_pages().Init(ns_mgr); // init ns_mgr for Page / Index ns just before rebuild; usually set by #cfg file
Xow_ns_mgr_.rebuild_(lang, ns_mgr); // always rebuild; may be changed by user_wiki.gfs; different lang will change namespaces; EX: de.wikisource.org will have Seite for File and none of {{#lst}} will work
// push lang changes
fragment_mgr.Evt_lang_changed(lang);
parser.Init_by_lang(lang);
html_mgr.Init_by_lang(lang);
lang.Vnt_mgr().Init_by_wiki(this);
Bry_fmtr.Null.Eval_mgr().Enabled_(false);
app.Wiki_mgr().Scripts().Exec(this);
Bry_fmtr.Null.Eval_mgr().Enabled_(true);
// other init
Bry_fmtr.Null.Eval_mgr().Enabled_(false); app.Wiki_mgr().Scripts().Exec(this); Bry_fmtr.Null.Eval_mgr().Enabled_(true);
app.Css_installer().Install_assert(Bool_.Y, this, user.Fsys_mgr().Wiki_html_dir(domain_str));
Html_mgr__hdump_enabled_(html_mgr__hdump_enabled);
html_mgr.Init_by_wiki(this);

View File

@ -73,13 +73,13 @@ public class Xof_xfer_queue {
Xof_fsdb_itm fsdb = new Xof_fsdb_itm();
fsdb.Ctor_by_lnki(xfer.Lnki_ttl(), xfer.Lnki_type(), xfer.Lnki_w(), xfer.Lnki_h(), upright_patch, xfer.Lnki_upright(), xfer.Lnki_time(), xfer.Lnki_page());
fsdb.Lnki_ext_(xfer.Lnki_ext());
if (xfer.Orig_ext() > 0)
if (xfer.Orig_ext() != null)
fsdb.Ctor_by_orig(xfer.Orig_repo_id(), xfer.Orig_repo_name(), xfer.Orig_ttl(), xfer.Orig_ext(), xfer.Orig_w(), xfer.Orig_h(), xfer.Orig_redirect());
else { // NOTE: orig_ext doesn't exist; try to get again, b/c Xof_file_wkr won't get it; DATE:2015-04-05
Xof_orig_itm orig = wiki.File_mgr().Orig_mgr().Find_by_ttl_or_null(xfer.Lnki_ttl());
if (orig != null) {; // no orig;
gplx.xowa.files.repos.Xof_repo_pair repo_pair = wiki.File_mgr__repo_mgr().Repos_get_by_id(orig.Repo());
fsdb.Ctor_by_orig(orig.Repo(), repo_pair.Trg().Wiki_key(), orig.Page(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
fsdb.Ctor_by_orig(orig.Repo(), repo_pair.Trg().Wiki_key(), orig.Page(), Xof_ext_.new_by_id_(orig.Ext()), orig.W(), orig.H(), orig.Redirect());
}
}
fsdb.Html_uid_(xfer.Html_uid());

View File

@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa; import gplx.*;
import org.junit.*;
import gplx.brys.*; import gplx.threads.*; import gplx.xowa.wikis.*; import gplx.xowa.setup.maints.*;
import gplx.brys.*; import gplx.threads.*; import gplx.xowa.wikis.*; import gplx.xowa.setup.maints.*; import gplx.xowa.xtns.wdatas.imports.*;
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; last run: DATE:2014-09-09
@Test public void Run() { // MAINT
// Bld_import_list(Xow_wmf_api_mgr.Wikis);
// Bld_cfg_files(Xow_wmf_api_mgr.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;

View File

@ -19,50 +19,47 @@ package gplx.xowa; import gplx.*;
public class Xop_lnki_type {
public static final byte Id_null = 0, Id_none = 1, Id_frameless = 2, Id_frame = 4, Id_thumb = 8;
public static boolean Id_is_thumbable(byte id) {
switch (id) {
case Id_thumb: case Id_frame: // for purposes of displaying images on page, thumb and frame both create a thumb box
return ( Enm_.HasInt(id, Id_thumb) // for purposes of displaying images on page, thumb and frame both create a thumb box
|| Enm_.HasInt(id, Id_frame)
);
}
public static boolean Id_defaults_to_thumb(byte id) { // assuming original of 400,200
if ( Enm_.HasInt(id, Id_thumb) // [[File:A.png|thumb]] -> 220,-1
|| Enm_.HasInt(id, Id_frameless) // [[File:A.png|frameless]] -> 220,-1
)
return true;
default:
else if ( Enm_.HasInt(id, Id_frame) // [[File:A.png|frame]] -> 400,200 (frame is always default size)
|| id == Id_null // [[File:A.png]] -> 400,200 (default to original size)
|| Enm_.HasInt(id, Id_none) // TODO: deprecate
)
return false;
else // TODO: throw err; should not happen
return false;
}
}
public static boolean Id_defaults_to_thumb(byte id) {
switch (id) { // assuming original of 400,200
case Id_thumb: // [[File:A.png|thumb]] -> 220,-1
case Id_frameless: // [[File:A.png|frameless]] -> 220,-1
public static boolean Id_limits_large_size(byte id) {// Linker.php|makeThumbLink2|Do not present an image bigger than the source, for bitmap-style images; assuming original of 400,200
if ( Enm_.HasInt(id, Id_thumb) // [[File:A.png|600px|thumb]] -> 400,200
|| Enm_.HasInt(id, Id_frameless) // [[File:A.png|600px|frameless]] -> 400,200
|| Enm_.HasInt(id, Id_frame) // [[File:A.png|600px|frame]] -> 400,200 (frame is always default size)
)
return true;
case Id_null: // [[File:A.png]] -> 400,200 (default to original size)
case Id_frame: // [[File:A.png|frame]] -> 400,200 (frame is always default size)
case Id_none: // TODO: deprecate
else if ( id == Id_null // [[File:A.png|600px]] -> 600,400; uses orig file of 400,200, but <img> tag src_width / src_height set to 600,400
|| Enm_.HasInt(id, Id_none) // TODO: deprecate
)
return false;
default: // TODO: deprecate
return Enm_.HasInt(id, Xop_lnki_type.Id_thumb) || Enm_.HasInt(id, Xop_lnki_type.Id_frameless);
}
}
public static boolean Id_limits_large_size(byte id) {// Linker.php|makeThumbLink2|Do not present an image bigger than the source, for bitmap-style images
switch (id) { // assuming original of 400,200
case Id_thumb: // [[File:A.png|600px|thumb]] -> 400,200
case Id_frameless: // [[File:A.png|600px|frameless]] -> 400,200
case Id_frame: // [[File:A.png|600px|frame]] -> 400,200 (frame is always default size)
else // TODO: throw err; should not happen;
return true;
case Id_null: // [[File:A.png|600px]] -> 600,400; uses orig file of 400,200, but <img> tag src_width / src_height set to 600,400
case Id_none: // TODO: deprecate
return false;
default: // TODO: deprecate
return !Enm_.HasInt(id, Xop_lnki_type.Id_none);
}
}
public static boolean Id_supports_upright(byte id) {// REF:Linker.php|makeImageLink;if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) DATE:2014-05-22
switch (id) {
case Id_thumb:
case Id_frame:
case Id_frameless:
if ( Enm_.HasInt(id, Id_thumb)
|| Enm_.HasInt(id, Id_frameless)
|| Enm_.HasInt(id, Id_frame)
)
return true;
case Id_null:
case Id_none:
else if ( id == Id_null
|| Enm_.HasInt(id, Id_none)
)
return false;
default: // TODO: deprecate
return Enm_.HasInt(id, Xop_lnki_type.Id_thumb) || Enm_.HasInt(id, Xop_lnki_type.Id_frameless);
}
else // TODO: throw err; should not happen;
return true;
}
}

View File

@ -634,12 +634,9 @@ public class Xop_xnde_wkr implements Xop_ctx_wkr {
case Xop_xnde_tag_.Tid_imageMap: xnde_xtn = tkn_mkr.Xnde_imageMap(); break;
case Xop_xnde_tag_.Tid_hiero: xnde_xtn = tkn_mkr.Xnde_hiero(); break;
case Xop_xnde_tag_.Tid_inputBox: xnde_xtn = tkn_mkr.Xnde_inputbox(); break;
case Xop_xnde_tag_.Tid_dynamicPageList:
case Xop_xnde_tag_.Tid_pages: {
switch (tag_id) {
case Xop_xnde_tag_.Tid_pages: xnde_xtn = tkn_mkr.Xnde_pages(); break;
case Xop_xnde_tag_.Tid_dynamicPageList: xnde_xtn = tkn_mkr.Xnde_dynamicPageList(); break;
}
case Xop_xnde_tag_.Tid_pages: {
xnde_xtn = tkn_mkr.Xnde_pages();
boolean enabled = ctx.Wiki().Xtn_mgr().Xtn_proofread().Enabled();
if (!enabled) { // if Page / Index ns does not exist, disable xtn and escape content; DATE:2014-11-28
escaped = true;