mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Source: Restore broken commit
This commit is contained in:
72
400_xowa/src/gplx/xowa/apps/apis/Xoapi_root.java
Normal file
72
400_xowa/src/gplx/xowa/apps/apis/Xoapi_root.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.guis.cmds.*;
|
||||
public class Xoapi_root implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
public Xoapi_root(Xoae_app app) {
|
||||
app_api.Ctor_by_app(app);
|
||||
usr_api.Ctor_by_app(app);
|
||||
bldr_api.Ctor_by_app(app);
|
||||
html_api.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
app_api.Init_by_kit(app);
|
||||
nav_api.Init_by_kit(app);
|
||||
gui_api.Init_by_kit(app);
|
||||
html_api.Init_by_kit(app);
|
||||
usr_api.Init_by_kit(app);
|
||||
xtns_api.Init_by_kit(app);
|
||||
}
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
html_api.Init_by_app(app);
|
||||
usr_api.Init_by_app(app);
|
||||
}
|
||||
public Xoapi_addon Addon() {return addon_api;} private final Xoapi_addon addon_api = new Xoapi_addon();
|
||||
public Xoapi_app App() {return app_api;} private final Xoapi_app app_api = new Xoapi_app();
|
||||
public Xoapi_nav Nav() {return nav_api;} private final Xoapi_nav nav_api = new Xoapi_nav();
|
||||
public Xoapi_gui Gui() {return gui_api;} private final Xoapi_gui gui_api = new Xoapi_gui();
|
||||
public Xoapi_html Html() {return html_api;} private final Xoapi_html html_api = new Xoapi_html();
|
||||
public Xoapi_bldr Bldr() {return bldr_api;} private final Xoapi_bldr bldr_api = new Xoapi_bldr();
|
||||
public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr();
|
||||
public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
|
||||
public String Test_str() {return test_str;} public void Test_str_(String v) {test_str = v;} private String test_str; // TEST
|
||||
private void Exec(String key) {
|
||||
Xog_cmd_itm cmd_itm = app.Gui_mgr().Cmd_mgr().Get_or_null(key);
|
||||
if (cmd_itm == null) app.Usr_dlg().Warn_many("", "", "could not find cmd; key=~{0}", key);
|
||||
app.Gfs_mgr().Run_str_for(app, cmd_itm.Cmd());
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_app)) return app_api;
|
||||
else if (ctx.Match(k, Invk_addon)) return addon_api;
|
||||
else if (ctx.Match(k, Invk_bldr)) return bldr_api;
|
||||
else if (ctx.Match(k, Invk_nav)) return nav_api;
|
||||
else if (ctx.Match(k, Invk_gui)) return gui_api;
|
||||
else if (ctx.Match(k, Invk_html)) return html_api;
|
||||
else if (ctx.Match(k, Invk_usr)) return usr_api;
|
||||
else if (ctx.Match(k, Invk_xtns)) return xtns_api;
|
||||
else if (ctx.Match(k, Invk_exec)) Exec(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_test_str)) return test_str;
|
||||
else if (ctx.Match(k, Invk_test_str_)) test_str = m.ReadStr("v");
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exec = "exec", Invk_test_str = "test_str", Invk_test_str_ = "test_str_"
|
||||
, Invk_app = "app", Invk_addon = "addon"
|
||||
, Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_usr = "usr", Invk_xtns = "xtns";
|
||||
}
|
||||
30
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_addon.java
Normal file
30
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_addon.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.apis.xowa.addons.*;
|
||||
public class Xoapi_addon implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoa_app app) {}
|
||||
public Xoapi_addon_search Search() {return search;} private final Xoapi_addon_search search = new Xoapi_addon_search();
|
||||
public Xoapi_addon_bldr Bldr() {return bldr;} private final Xoapi_addon_bldr bldr = new Xoapi_addon_bldr();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__search)) return search;
|
||||
else if (ctx.Match(k, Invk__bldr)) return bldr;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk__search = "search", Invk__bldr = "bldr";
|
||||
}
|
||||
38
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app.java
Normal file
38
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_app.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.apps.apis.xowa.apps.*;
|
||||
public class Xoapi_app implements Gfo_invk {
|
||||
private Xog_win_itm win;
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
fsys.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
public Xoapi_fsys Fsys() {return fsys;} private Xoapi_fsys fsys = new Xoapi_fsys();
|
||||
public void Exit() {win.App__exit();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_exit)) this.Exit();
|
||||
else if (ctx.Match(k, Invk_fsys)) return fsys;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exit = "exit", Invk_fsys = "fsys";
|
||||
}
|
||||
28
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_bldr.java
Normal file
28
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_bldr.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.*;
|
||||
public class Xoapi_bldr implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoa_app app) {wiki.Ctor_by_app(app);}
|
||||
public Xoapi_bldr_wiki Wiki() {return wiki;} private final Xoapi_bldr_wiki wiki = new Xoapi_bldr_wiki();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_wiki)) return wiki;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_wiki = "wiki";
|
||||
}
|
||||
36
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_gui.java
Normal file
36
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_gui.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
public class Xoapi_gui implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
browser.Init_by_kit(app);
|
||||
font.Init_by_kit(app);
|
||||
page.Init_by_kit(app);
|
||||
}
|
||||
public Xoapi_browser Browser() {return browser;} private Xoapi_browser browser = new Xoapi_browser();
|
||||
public Xoapi_font Font() {return font;} private Xoapi_font font = new Xoapi_font();
|
||||
public Xoapi_page Page() {return page;} private Xoapi_page page = new Xoapi_page();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_browser)) return browser;
|
||||
else if (ctx.Match(k, Invk_font)) return font;
|
||||
else if (ctx.Match(k, Invk_page)) return page;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_browser = "browser", Invk_font = "font", Invk_page = "page";
|
||||
}
|
||||
34
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_html.java
Normal file
34
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_html.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.*;
|
||||
public class Xoapi_html implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
page.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_app(Xoae_app app) {page.Init_by_app(app);}
|
||||
public void Init_by_kit(Xoae_app app) {modules.Init_by_kit(app);}
|
||||
public Xoapi_modules Modules() {return modules;} private final Xoapi_modules modules = new Xoapi_modules();
|
||||
public Xoapi_page Page() {return page;} private final Xoapi_page page = new Xoapi_page();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_modules)) return modules;
|
||||
else if (ctx.Match(k, Invk_page)) return page;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_modules = "modules", Invk_page = "page";
|
||||
}
|
||||
40
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_nav.java
Normal file
40
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_nav.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.apps.apis.xowa.navs.*;
|
||||
public class Xoapi_nav implements Gfo_invk {
|
||||
private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
wiki.Init_by_kit(app);
|
||||
}
|
||||
public Xoapi_nav_wiki Wiki() {return wiki;} private Xoapi_nav_wiki wiki = new Xoapi_nav_wiki();
|
||||
public void Goto(String page) {win.Page__navigate_by_url_bar(page);}
|
||||
public void Go_bwd() {win.Page__navigate_by_history(Bool_.N);}
|
||||
public void Go_fwd() {win.Page__navigate_by_history(Bool_.Y);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_go_bwd)) this.Go_bwd();
|
||||
else if (ctx.Match(k, Invk_go_fwd)) this.Go_fwd();
|
||||
else if (ctx.Match(k, Invk_goto)) this.Goto(m.ReadStr("v"));
|
||||
else if (ctx.Match(k, Invk_wiki)) return wiki;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_go_bwd = "go_bwd", Invk_go_fwd = "go_fwd", Invk_goto = "goto", Invk_wiki = "wiki";
|
||||
}
|
||||
39
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_usr.java
Normal file
39
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_usr.java
Normal 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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.apis.xowa.usrs.*;
|
||||
public class Xoapi_usr implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
bookmarks.Ctor_by_app(app);
|
||||
history.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
bookmarks.Init_by_kit(app);
|
||||
history.Init_by_kit(app);
|
||||
}
|
||||
public Xoapi_bookmarks Bookmarks() {return bookmarks;} private final Xoapi_bookmarks bookmarks = new Xoapi_bookmarks();
|
||||
public Xoapi_history History() {return history;} private final Xoapi_history history = new Xoapi_history();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_bookmarks)) return bookmarks;
|
||||
else if (ctx.Match(k, Invk_history)) return history;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_bookmarks = "bookmarks", Invk_history = "history";
|
||||
}
|
||||
30
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_xtns.java
Normal file
30
400_xowa/src/gplx/xowa/apps/apis/xowa/Xoapi_xtns.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
|
||||
import gplx.xowa.apps.apis.xowa.xtns.*;
|
||||
public class Xoapi_xtns implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
wikibase.Init_by_app(app);
|
||||
}
|
||||
public Xoapi_wikibase Wikibase() {return wikibase;} private final Xoapi_wikibase wikibase = new Xoapi_wikibase();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_wikibase)) return wikibase;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_wikibase = "wikibase";
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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.apps.apis.xowa.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.apis.xowa.addons.bldrs.*;
|
||||
public class Xoapi_addon_bldr implements Gfo_invk {
|
||||
public Xoapi_central_api Central() {return central;} private final Xoapi_central_api central = new Xoapi_central_api();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__central)) return central;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk__central = "central";
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.apps.apis.xowa.addons; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*;
|
||||
import gplx.xowa.apps.apis.xowa.addons.searchs.*;
|
||||
public class Xoapi_addon_search implements Gfo_invk {
|
||||
@gplx.Internal protected Xoapi_search_box Search_box() {return search_box;} private final Xoapi_search_box search_box = new Xoapi_search_box();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__search_box)) return search_box;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk__search_box = "search_box";
|
||||
}
|
||||
class Xoapi_search_box implements Gfo_invk {
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.addons.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
|
||||
public class Xoapi_central_api implements Gfo_invk {
|
||||
public boolean Log_verbose() {return log_verbose;} private boolean log_verbose = false;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__log_verbose_)) log_verbose = m.ReadBool("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk__log_verbose_ = "log_verbose_"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.addons.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
public class Xopg_match_mgr {
|
||||
private String scope_raw;
|
||||
private Ordered_hash wikis;
|
||||
private boolean wildcard_exists;
|
||||
private Xopg_match_wiki wildcard_wiki;
|
||||
public void Set(String v) {
|
||||
this.scope_raw = v;
|
||||
this.wikis = null;
|
||||
this.wildcard_exists = false;
|
||||
this.wildcard_wiki = null;
|
||||
}
|
||||
public boolean Match(Xow_wiki wiki, byte[] page_ttl) {
|
||||
if (wikis == null) Init(wiki.App());
|
||||
|
||||
if (wildcard_exists) return true;
|
||||
if (wildcard_wiki != null) {
|
||||
if (wildcard_wiki.Has(page_ttl))
|
||||
return true;
|
||||
}
|
||||
Xopg_match_wiki match_wiki = (Xopg_match_wiki)wikis.Get_by(wiki.Domain_bry());
|
||||
if (match_wiki == null) return false;
|
||||
return match_wiki.Has(page_ttl);
|
||||
}
|
||||
private void Init(Xoa_app app) {
|
||||
this.wikis = Ordered_hash_.New_bry();
|
||||
String[] lines = String_.SplitLines_nl(scope_raw);
|
||||
Xow_url_parser url_parser = app.User().Wikii().Utl__url_parser();
|
||||
for (String line : lines) {
|
||||
if (String_.Eq(line, "*")) {
|
||||
wildcard_exists = true;
|
||||
}
|
||||
else {
|
||||
byte[] wiki_domain = null, page_db = null;
|
||||
boolean cur_is_wildcard_wiki = false;
|
||||
if (String_.Has_at_bgn(line, "*:")) {
|
||||
wiki_domain = Byte_ascii.Star_bry;
|
||||
page_db = Bry_.Mid(Bry_.new_u8(line), 2);
|
||||
cur_is_wildcard_wiki = true;
|
||||
}
|
||||
else {
|
||||
Xoa_url url = url_parser.Parse_by_urlbar_or_null(line);
|
||||
wiki_domain = url.Wiki_bry();
|
||||
page_db = url.Page_bry();
|
||||
}
|
||||
Xopg_match_wiki match_wiki = (Xopg_match_wiki)wikis.Get_by(wiki_domain);
|
||||
if (match_wiki == null) {
|
||||
match_wiki = new Xopg_match_wiki(wiki_domain);
|
||||
wikis.Add(wiki_domain, match_wiki);
|
||||
if (cur_is_wildcard_wiki) {
|
||||
wildcard_wiki = match_wiki;
|
||||
}
|
||||
}
|
||||
match_wiki.Add(page_db);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Xopg_match_wiki {
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
private boolean wildcard_exists;
|
||||
public Xopg_match_wiki(byte[] domain_bry) {
|
||||
this.domain_bry = domain_bry;
|
||||
}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public boolean Has(byte[] page_db) {
|
||||
return wildcard_exists ? true : hash.Has(page_db);
|
||||
}
|
||||
public void Add(byte[] page_db) {
|
||||
if (Bry_.Eq(page_db, Byte_ascii.Star_bry)) {
|
||||
wildcard_exists = true;
|
||||
}
|
||||
else {
|
||||
hash.Add_if_dupe_use_1st(page_db, page_db);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
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.apps.apis.xowa.addons.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xopg_match_mgr__tst {
|
||||
private final Xopg_match_mgr__fxt fxt = new Xopg_match_mgr__fxt();
|
||||
@Before public void init() {fxt.Clear();}
|
||||
@Test public void Specific() {
|
||||
fxt.Init__set("en.w:A");
|
||||
fxt.Test__match_y("A");
|
||||
fxt.Test__match_n("AB");
|
||||
}
|
||||
@Test public void Other_wiki() {
|
||||
fxt.Init__set("fr.w:A");
|
||||
fxt.Test__match_n("A"); // note that test defaults to "en.w" as primary wiki
|
||||
}
|
||||
@Test public void Wildcard__app() {
|
||||
fxt.Init__set("*");
|
||||
fxt.Test__match_y("A", "B");
|
||||
}
|
||||
@Test public void Wildcard__page() {
|
||||
fxt.Init__set("en.w:*");
|
||||
fxt.Test__match_y("A", "B");
|
||||
}
|
||||
@Test public void Wildcard__page__other() {
|
||||
fxt.Init__set("fr.w:*");
|
||||
fxt.Test__match_n("A", "B");
|
||||
}
|
||||
@Test public void Wildcard__wiki() {
|
||||
fxt.Init__set("*:A");
|
||||
fxt.Test__match_y("A");
|
||||
fxt.Test__match_n("B");
|
||||
}
|
||||
}
|
||||
class Xopg_match_mgr__fxt {
|
||||
private final Xopg_match_mgr match_mgr = new Xopg_match_mgr();
|
||||
private Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
app.User().Wikii().Xwiki_mgr().Add_by_atrs(wiki.Domain_bry(), wiki.Domain_bry());
|
||||
}
|
||||
public void Init__set(String url) {
|
||||
match_mgr.Set(url);
|
||||
}
|
||||
public void Test__match_y(String... urls) {Test__match(Bool_.Y, urls);}
|
||||
public void Test__match_n(String... urls) {Test__match(Bool_.N, urls);}
|
||||
private void Test__match(boolean expd, String... urls) {
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
String url = urls[i];
|
||||
boolean actl = match_mgr.Match(wiki, Bry_.new_u8(url));
|
||||
Gftest.Eq__bool(expd, actl, "match failed", "expd", expd, "url", url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.addons.searchs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.addons.*;
|
||||
public class Xoapi_search_mode_ {
|
||||
public static final int Tid__title_full = 0, Tid__title_word = 1;
|
||||
public static final String Str__title_full = "title.full", Str__title_word = "title.word";
|
||||
public static String To_str(int v) {
|
||||
switch (v) {
|
||||
case Tid__title_full: return Str__title_full;
|
||||
case Tid__title_word: return Str__title_word;
|
||||
default: throw Err_.new_unhandled_default(v);
|
||||
}
|
||||
}
|
||||
public static int To_int(String v) {
|
||||
if (String_.Eq(v, Str__title_full)) return Tid__title_full;
|
||||
else if (String_.Eq(v, Str__title_word)) return Tid__title_word;
|
||||
else throw Err_.new_unhandled_default(v);
|
||||
}
|
||||
}
|
||||
33
400_xowa/src/gplx/xowa/apps/apis/xowa/apps/Xoapi_fsys.java
Normal file
33
400_xowa/src/gplx/xowa/apps/apis/xowa/apps/Xoapi_fsys.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.apps.apis.xowa.apps; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.core.envs.*;
|
||||
public class Xoapi_fsys implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
this.plat_jar = Env_.AppUrl();
|
||||
this.root_dir = app.Fsys_mgr().Root_dir();
|
||||
}
|
||||
public Io_url Plat_jar() {return plat_jar;} private Io_url plat_jar;
|
||||
public Io_url Plat_url(String s) {return Io_url_.new_any_(root_dir.Gen_sub_path_for_os(s));} private Io_url root_dir;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_plat_jar)) return plat_jar;
|
||||
else if (ctx.Match(k, Invk_plat_url)) return Plat_url(m.ReadStr("v"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_plat_jar = "plat_jar", Invk_plat_url = "plat_url";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.filters.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.runners.*;
|
||||
public class Xoapi_bldr_wiki implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoa_app app) {
|
||||
runner.Ctor_by_app(app);
|
||||
}
|
||||
public Xoapi_import Import() {return import_api;} private final Xoapi_import import_api = new Xoapi_import();
|
||||
public Xoapi_runner Runner() {return runner;} private final Xoapi_runner runner = new Xoapi_runner();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_import)) return import_api;
|
||||
else if (ctx.Match(k, Invk_runner)) return runner;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_import = "import", Invk_runner = "runner";
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
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.apps.apis.xowa.bldrs.filters.titles; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*; import gplx.xowa.apps.apis.xowa.bldrs.filters.*;
|
||||
public class Xoapi_title implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
// wordlist_dir = app.Fsys_mgr().Bin_xtns_dir().GenSubDir_nest("xowa", "DansGuardian");
|
||||
}
|
||||
public boolean Enabled() {return enabled;} private boolean enabled = Bool_.Y;
|
||||
public Io_url Wordlist_dir() {return wordlist_dir;} private Io_url wordlist_dir;
|
||||
public int Score_init() {return score_init;} private int score_init = 0;
|
||||
public int Score_pass() {return score_pass;} private int score_pass = 0;
|
||||
public boolean Log_enabled() {return log_enabled;} private boolean log_enabled = Bool_.Y;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(enabled);
|
||||
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_wordlist_dir)) return Int_.To_str(score_init);
|
||||
else if (ctx.Match(k, Invk_wordlist_dir_)) wordlist_dir= m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk_score_init)) return Int_.To_str(score_init);
|
||||
else if (ctx.Match(k, Invk_score_init_)) score_init = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_score_pass)) return Int_.To_str(score_pass);
|
||||
else if (ctx.Match(k, Invk_score_pass_)) score_pass = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_log_enabled)) return Yn.To_str(enabled);
|
||||
else if (ctx.Match(k, Invk_log_enabled_)) log_enabled = m.ReadYn("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_enabled = "enabled" , Invk_enabled_ = "enabled_"
|
||||
, Invk_wordlist_dir = "wordlist_dir" , Invk_wordlist_dir_ = "wordlist_dir_"
|
||||
, Invk_score_init = "score_init" , Invk_score_init_ = "score_init_"
|
||||
, Invk_score_pass = "score_pas" , Invk_score_pass_ = "score_pass_"
|
||||
, Invk_log_enabled = "log_enabled" , Invk_log_enabled_ = "log_enabled_"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.bldrs.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*;
|
||||
import gplx.core.ios.*; import gplx.core.ios.streams.*;
|
||||
import gplx.xowa.wikis.data.*;
|
||||
public class Xoapi_import implements Gfo_invk {
|
||||
public long Cat_link_db_max() {return cat_link_db_max;} private long cat_link_db_max = Io_size_.To_long_by_int_mb(1500); // 3.6 GB; v1
|
||||
public String User_name() {return user_name;} private String user_name = "anonymous";
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_cat_link_db_max)) return Io_size_.To_str_mb(cat_link_db_max);
|
||||
else if (ctx.Match(k, Invk_cat_link_db_max_)) cat_link_db_max = Io_size_.To_long_by_msg_mb(m, cat_link_db_max);
|
||||
else if (ctx.Match(k, Invk_user_name)) return user_name;
|
||||
else if (ctx.Match(k, Invk_user_name_)) user_name = m.ReadStr("v");
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_cat_link_db_max = "cat_link_db_max" , Invk_cat_link_db_max_ = "cat_link_db_max_"
|
||||
, Invk_user_name = "user_name" , Invk_user_name_ = "user_name_"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.bldrs.runners; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.bldrs.*;
|
||||
public class Xoapi_runner implements Gfo_invk {
|
||||
// private Xoa_app app;
|
||||
public void Ctor_by_app(Xoa_app app) {}//this.app = app;}
|
||||
private void Exec(GfoMsg msg) {
|
||||
// int len = msg.Args_count();
|
||||
// String cmd = (String)msg.Args_getAt(0).Val();
|
||||
// Keyval[] args = new Keyval[len - 1];
|
||||
// for (int i = 1; i < len; ++i) {
|
||||
// String arg = (String)msg.Args_getAt(i).Val();
|
||||
// int eq_pos = String_.FindFwd(arg, "=");
|
||||
// String key = String_.Mid(arg, 0, eq_pos);
|
||||
// String val = String_.Mid(arg, eq_pos + 1);
|
||||
// args[i - 1] = Keyval_.new_(key, val);
|
||||
// }
|
||||
// gplx.core.ios.zips.Io_zip_decompress_task task = new gplx.core.ios.zips.Io_zip_decompress_task();
|
||||
// task.Init(true, Gfo
|
||||
// app.Gui__cbk_mgr().Send_prog("test", "key_0", "val_0");
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_exec)) Exec(m);
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_exec = "exec";
|
||||
}
|
||||
// class Xodl_prog_ui : gplx.core.progs.Gfo_prog_ui {
|
||||
// public void Prog__update_val(long cur, long max) {}
|
||||
// public void Prog__end() {}
|
||||
// }
|
||||
53
400_xowa/src/gplx/xowa/apps/apis/xowa/gui/Xoapi_browser.java
Normal file
53
400_xowa/src/gplx/xowa/apps/apis/xowa/gui/Xoapi_browser.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.apis.xowa.gui.browsers.*;
|
||||
public class Xoapi_browser implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
url.Init_by_kit(app);
|
||||
tabs.Init_by_kit(app);
|
||||
html.Init_by_kit(app);
|
||||
search.Init_by_kit(app);
|
||||
find.Init_by_kit(app);
|
||||
prog.Init_by_kit(app);
|
||||
info.Init_by_kit(app);
|
||||
prog_log.Init_by_kit(app);
|
||||
}
|
||||
public Xoapi_url Url() {return url;} private Xoapi_url url = new Xoapi_url();
|
||||
public Xoapi_tabs Tabs() {return tabs;} private Xoapi_tabs tabs = new Xoapi_tabs();
|
||||
public Xoapi_html_box Html() {return html;} private Xoapi_html_box html = new Xoapi_html_box();
|
||||
public Xoapi_search Search() {return search;} private Xoapi_search search = new Xoapi_search();
|
||||
public Xoapi_find Find() {return find;} private Xoapi_find find = new Xoapi_find();
|
||||
public Xoapi_prog Prog() {return prog;} private Xoapi_prog prog = new Xoapi_prog();
|
||||
public Xoapi_info Info() {return info;} private Xoapi_info info = new Xoapi_info();
|
||||
public Xoapi_prog_log Prog_log() {return prog_log;} private Xoapi_prog_log prog_log = new Xoapi_prog_log();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_url)) return url;
|
||||
else if (ctx.Match(k, Invk_tabs)) return tabs;
|
||||
else if (ctx.Match(k, Invk_html)) return html;
|
||||
else if (ctx.Match(k, Invk_search)) return search;
|
||||
else if (ctx.Match(k, Invk_find)) return find;
|
||||
else if (ctx.Match(k, Invk_prog)) return prog;
|
||||
else if (ctx.Match(k, Invk_info)) return info;
|
||||
else if (ctx.Match(k, Invk_prog_log)) return prog_log;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String
|
||||
Invk_url = "url", Invk_tabs = "tabs", Invk_html = "html", Invk_search = "search"
|
||||
, Invk_find = "find", Invk_prog = "prog", Invk_info = "info", Invk_prog_log = "prog_log";
|
||||
}
|
||||
51
400_xowa/src/gplx/xowa/apps/apis/xowa/gui/Xoapi_font.java
Normal file
51
400_xowa/src/gplx/xowa/apps/apis/xowa/gui/Xoapi_font.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.cfgs.*; import gplx.xowa.htmls.*;
|
||||
public class Xoapi_font implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public void Increase() {Adj(1);}
|
||||
public void Decrease() {Adj(-1);}
|
||||
public void Reset() {Set(false, Xoh_page_mgr.Font_size_default, Xocfg_win.Font_size_default);}
|
||||
public void Adj(int adj) {
|
||||
float html_font_size = app.Html_mgr().Page_mgr().Font_size() + adj;
|
||||
float gui_font_size = app.Gui_mgr().Win_cfg().Font().Size() + adj; // (html_font_size * .75f) - 4; // .75f b/c 16px = 12 pt; -4 b/c gui font is currently 4 pt smaller
|
||||
if (html_font_size < 1 || gui_font_size < 1) return;
|
||||
Set(true, html_font_size, gui_font_size);
|
||||
}
|
||||
private void Set(boolean enabled, float html_font_size, float gui_font_size) {
|
||||
if (html_font_size <= 0) return; // font must be positive
|
||||
app.Cfg().Set_bool_app(gplx.xowa.htmls.Xoh_page_mgr.Cfg__font_enabled, enabled);
|
||||
app.Cfg().Set_float_app(gplx.xowa.htmls.Xoh_page_mgr.Cfg__font_size, html_font_size);
|
||||
app.Cfg().Set_float_app(gplx.xowa.guis.langs.Xol_font_info.Cfg__font_size, gui_font_size);
|
||||
app.Gui_mgr().Browser_win().Page__reload(); // NOTE: force reload; needed if viewing home/wiki/Options/HTML, else Font size won't update
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_increase)) this.Increase();
|
||||
else if (ctx.Match(k, Invk_decrease)) this.Decrease();
|
||||
else if (ctx.Match(k, Invk_reset)) this.Reset();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_increase = "increase", Invk_decrease = "decrease", Invk_reset = "reset"
|
||||
;
|
||||
}
|
||||
36
400_xowa/src/gplx/xowa/apps/apis/xowa/gui/Xoapi_page.java
Normal file
36
400_xowa/src/gplx/xowa/apps/apis/xowa/gui/Xoapi_page.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.apis.xowa.gui.pages.*;
|
||||
public class Xoapi_page implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
view.Init_by_kit(app);
|
||||
selection.Init_by_kit(app);
|
||||
edit.Init_by_kit(app);
|
||||
}
|
||||
public Xoapi_view View() {return view;} private Xoapi_view view = new Xoapi_view();
|
||||
public Xoapi_edit Edit() {return edit;} private Xoapi_edit edit = new Xoapi_edit();
|
||||
public Xoapi_selection Selection() {return selection;} private Xoapi_selection selection = new Xoapi_selection();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_view)) return view;
|
||||
else if (ctx.Match(k, Invk_selection)) return selection;
|
||||
else if (ctx.Match(k, Invk_edit)) return edit;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_view = "view", Invk_selection = "selection", Invk_edit = "edit";
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.gfui.controls.standards.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_find implements Gfo_invk {
|
||||
private Xog_find_box find_box;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
find_box = new Xog_find_box(app);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_show)) find_box.Show();
|
||||
else if (ctx.Match(k, Invk_show_by_paste)) find_box.Show_by_paste();
|
||||
else if (ctx.Match(k, Invk_exec)) find_box.Exec();
|
||||
else if (ctx.Match(k, Invk_type)) find_box.Exec(); // NOTE: same as exec; provided so that exec doesn't accidentally overwrite auto-type for find
|
||||
else if (ctx.Match(k, Invk_find_fwd)) find_box.Exec_by_dir(Bool_.Y);
|
||||
else if (ctx.Match(k, Invk_find_bwd)) find_box.Exec_by_dir(Bool_.N);
|
||||
else if (ctx.Match(k, Invk_case_toggle)) find_box.Case_toggle();
|
||||
else if (ctx.Match(k, Invk_wrap_toggle)) find_box.Wrap_toggle();
|
||||
else if (ctx.Match(k, Invk_hide)) find_box.Hide();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_show = "show", Invk_show_by_paste = "show_by_paste", Invk_hide = "hide", Invk_exec = "exec", Invk_type = "type"
|
||||
, Invk_find_bwd = "find_bwd", Invk_find_fwd = "find_fwd", Invk_case_toggle = "case_toggle", Invk_wrap_toggle = "wrap_toggle";
|
||||
}
|
||||
class Xog_find_box {
|
||||
private Xoae_app app; private Xog_win_itm win; private GfuiTextBox find_box;
|
||||
private String prv_find_text = ""; // NOTE: must set to "", else will fail during Hide
|
||||
private boolean dir_fwd = true, case_match = false, wrap_search = true;
|
||||
public Xog_find_box(Xoae_app app) {
|
||||
this.app = app;
|
||||
this.win = app.Gui_mgr().Browser_win();
|
||||
this.find_box = win.Find_box();
|
||||
}
|
||||
public void Show() {app.Gui_mgr().Layout().Find_show();}
|
||||
public void Hide() {
|
||||
app.Gui_mgr().Layout().Find_close();
|
||||
Xog_tab_itm tab = win.Tab_mgr().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
if (tab.View_mode() == Xopg_page_.Tid_read) // do not fire find("") for edit / html, else focus issues; DATE:2015-06-10
|
||||
Exec_find(prv_find_text, Bool_.N);
|
||||
}
|
||||
public void Show_by_paste() {
|
||||
this.Show();
|
||||
if (win.Tab_mgr().Active_tab_is_null()) return; // if no active_tab, just show box; don't try to copy what's on tab;
|
||||
find_box.Text_(win.Active_html_itm().Html_selected_get_text_or_href());
|
||||
}
|
||||
public void Exec_by_dir(boolean fwd) {
|
||||
boolean changed = dir_fwd != fwd;
|
||||
dir_fwd = fwd;
|
||||
Exec();
|
||||
if (changed) // clicking on buttons calls Exec_by_dir; in case of repeated clicks on same button, don't flash changed message again
|
||||
win.Usr_dlg().Prog_direct("Find direction changed to " + (fwd ? "forward" : "backward"));
|
||||
}
|
||||
public void Exec() {
|
||||
prv_find_text = find_box.Text();
|
||||
Exec_find(prv_find_text, Bool_.Y);
|
||||
}
|
||||
private void Exec_find(String find, boolean highlight_matches) {
|
||||
Xog_tab_itm tab = win.Tab_mgr().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
find = String_.Replace(find, "\\", "\\\\"); // NOTE: backslashes are always literal, never escape codes; EX: "C:\new" "\n" means "\n", not (byte)10; DATE:2015-08-17
|
||||
boolean find_in_hdoc = tab.View_mode() == Xopg_page_.Tid_read;
|
||||
if (find_in_hdoc)
|
||||
tab.Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Win__find_in_hdoc , find, dir_fwd, case_match, wrap_search, highlight_matches);
|
||||
else
|
||||
tab.Html_box().Html_js_eval_proc_as_str(Xog_js_procs.Win__find_in_textarea , find, dir_fwd, case_match, wrap_search);
|
||||
win.Usr_dlg().Prog_direct("");
|
||||
}
|
||||
public void Case_toggle() {
|
||||
case_match = !case_match;
|
||||
win.Usr_dlg().Prog_direct("Case match " + (case_match ? "enabled" : "disabled"));
|
||||
}
|
||||
public void Wrap_toggle() {
|
||||
wrap_search = !wrap_search;
|
||||
win.Usr_dlg().Prog_direct("Wrap search " + (wrap_search ? "enabled" : "disabled"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.gfui.controls.gxws.*; import gplx.gfui.controls.standards.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_html_box implements Gfo_invk {
|
||||
private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoae_app app) {this.win = app.Gui_mgr().Browser_win();}
|
||||
public void Focus() {
|
||||
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
Gfui_html html_box = tab.Html_itm().Html_box();
|
||||
html_box.Focus();
|
||||
if (tab.View_mode() != Xopg_page_.Tid_read) // if edit / html, place focus in edit box
|
||||
html_box.Html_js_eval_proc_as_str(Xog_js_procs.Doc__elem_focus, Xog_html_itm.Elem_id__xowa_edit_data_box);
|
||||
}
|
||||
public void Selection_focus() {
|
||||
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
Gfui_html html_box = tab.Html_itm().Html_box();
|
||||
html_box.Html_js_eval_proc_as_str(Xog_js_procs.Selection__toggle_focus_for_anchor);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else if (ctx.Match(k, Invk_selection_focus_toggle)) this.Selection_focus();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus", Invk_selection_focus_toggle = "selection_focus_toggle";
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_info implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
|
||||
public void Focus() {this.Win().Info_box().Focus();}
|
||||
public void Clear() {app.Usr_dlg().Gui_wkr().Clear();}
|
||||
public void Launch() {
|
||||
Io_url session_fil = app.Log_wtr().Session_fil();
|
||||
app.Prog_mgr().App_view_text().Run(session_fil);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else if (ctx.Match(k, Invk_clear)) this.Clear();
|
||||
else if (ctx.Match(k, Invk_launch)) this.Launch();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus", Invk_clear = "clear", Invk_launch = "launch";
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_prog implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
|
||||
public void Focus() {this.Win().Prog_box().Focus();}
|
||||
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus";
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_prog_log implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
public void Show() {app.Gui_mgr().Show_prog();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_show)) this.Show();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_show = "show";
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.gfui.controls.standards.*; import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_search implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
|
||||
private GfuiTextBox Search_box() {return app.Gui_mgr().Browser_win().Search_box();}
|
||||
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
|
||||
public void Focus() {this.Search_box().Focus_select_all();}
|
||||
public void Exec() {this.Win().Page__navigate_by_search();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else if (ctx.Match(k, Invk_exec)) this.Exec();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus";
|
||||
public static final String Invk_exec = "exec";
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_tabs implements Gfo_invk {
|
||||
private Xog_tab_mgr tab_mgr;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.tab_mgr = app.Gui_mgr().Browser_win().Tab_mgr();
|
||||
}
|
||||
private boolean Active_tab_is_null() {return tab_mgr.Active_tab_is_null();}
|
||||
public void New_dupe(boolean focus) {tab_mgr.Tabs_new_dupe(focus);}
|
||||
public void New_dflt(boolean focus) {tab_mgr.Tabs_new_dflt(focus);}
|
||||
public void New_link(boolean focus, String link) {tab_mgr.Tabs_new_link(focus, link);}
|
||||
public void New_href(boolean focus) {
|
||||
Xog_tab_itm tab = tab_mgr.Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
String link = tab.Html_itm().Html_selected_get_href_or_text();
|
||||
if (String_.Len_eq_0(link)) {tab_mgr.Win().Usr_dlg().Prog_many("", "", "no link or text selected"); return;}
|
||||
tab_mgr.Tabs_new_dflt(true);
|
||||
tab_mgr.Win().Page__navigate_by_url_bar(link);
|
||||
}
|
||||
public void Close_cur() {tab_mgr.Tabs_close_cur();}
|
||||
public void Select_bwd() {tab_mgr.Tabs_select(Bool_.N);}
|
||||
public void Select_fwd() {tab_mgr.Tabs_select(Bool_.Y);}
|
||||
public void Select_by_idx(int v) {tab_mgr.Tabs_select_by_idx(v - List_adp_.Base1);}
|
||||
public void Move_bwd() {tab_mgr.Tabs_move(Bool_.N);}
|
||||
public void Move_fwd() {tab_mgr.Tabs_move(Bool_.Y);}
|
||||
public void Close_others() {tab_mgr.Tabs_close_others();}
|
||||
public void Close_to_bgn() {tab_mgr.Tabs_close_to_bgn();}
|
||||
public void Close_to_end() {tab_mgr.Tabs_close_to_end();}
|
||||
public void Close_undo() {tab_mgr.Tabs_close_undo();}
|
||||
public void Pin_toggle() {if (this.Active_tab_is_null()) return; tab_mgr.Active_tab().Pin_toggle();}
|
||||
public void Tab_bookmark_all() {}//app.Gui_mgr().Browser_win().Tab_mgr().Tabs_close_others();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_new_dflt__at_dflt__focus_y)) this.New_dflt(Bool_.Y);
|
||||
else if (ctx.Match(k, Invk_new_link__at_dflt__focus_n)) this.New_link(Bool_.N, m.ReadStrOr("v", null));
|
||||
else if (ctx.Match(k, Invk_new_link__at_dflt__focus_y)) this.New_link(Bool_.Y, m.ReadStrOr("v", null));
|
||||
else if (ctx.Match(k, Invk_new_href__at_dflt__focus_y)) this.New_href(Bool_.Y);
|
||||
else if (ctx.Match(k, Invk_new_dupe__at_dflt__focus_y)) this.New_dupe(Bool_.Y);
|
||||
else if (ctx.Match(k, Invk_close_cur)) this.Close_cur();
|
||||
else if (ctx.Match(k, Invk_select_bwd)) this.Select_bwd();
|
||||
else if (ctx.Match(k, Invk_select_fwd)) this.Select_fwd();
|
||||
else if (ctx.Match(k, Invk_move_bwd)) this.Move_bwd();
|
||||
else if (ctx.Match(k, Invk_move_fwd)) this.Move_fwd();
|
||||
else if (ctx.Match(k, Invk_close_others)) this.Close_others();
|
||||
else if (ctx.Match(k, Invk_close_to_bgn)) this.Close_to_bgn();
|
||||
else if (ctx.Match(k, Invk_close_to_end)) this.Close_to_end();
|
||||
else if (ctx.Match(k, Invk_close_undo)) this.Close_undo();
|
||||
else if (ctx.Match(k, Invk_pin_toggle)) this.Pin_toggle();
|
||||
else if (ctx.Match(k, Invk_select_by_idx_1)) this.Select_by_idx(1);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_2)) this.Select_by_idx(2);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_3)) this.Select_by_idx(3);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_4)) this.Select_by_idx(4);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_5)) this.Select_by_idx(5);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_6)) this.Select_by_idx(6);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_7)) this.Select_by_idx(7);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_8)) this.Select_by_idx(8);
|
||||
else if (ctx.Match(k, Invk_select_by_idx_9)) this.Select_by_idx(9);
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_new_dflt__at_dflt__focus_y = "new_dflt__at_dflt__focus_y"
|
||||
, Invk_new_link__at_dflt__focus_n = "new_link__at_dflt__focus_n"
|
||||
, Invk_new_link__at_dflt__focus_y = "new_link__at_dflt__focus_y"
|
||||
, Invk_new_href__at_dflt__focus_y = "new_href__at_dflt__focus_y"
|
||||
, Invk_new_dupe__at_dflt__focus_y = "new_dupe__at_dflt__focus_y"
|
||||
, Invk_close_cur = "close_cur"
|
||||
, Invk_select_bwd = "select_bwd", Invk_select_fwd = "select_fwd"
|
||||
, Invk_move_bwd = "move_bwd", Invk_move_fwd = "move_fwd"
|
||||
, Invk_close_others = "close_others", Invk_close_to_bgn = "close_to_bgn", Invk_close_to_end = "close_to_end", Invk_close_undo = "close_undo"
|
||||
, Invk_pin_toggle = "pin_toggle"
|
||||
, Invk_select_by_idx_1 = "select_by_idx_1", Invk_select_by_idx_2 = "select_by_idx_2", Invk_select_by_idx_3 = "select_by_idx_3", Invk_select_by_idx_4 = "select_by_idx_4", Invk_select_by_idx_5 = "select_by_idx_5"
|
||||
, Invk_select_by_idx_6 = "select_by_idx_6", Invk_select_by_idx_7 = "select_by_idx_7", Invk_select_by_idx_8 = "select_by_idx_8", Invk_select_by_idx_9 = "select_by_idx_9"
|
||||
;
|
||||
}
|
||||
@@ -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.apps.apis.xowa.gui.browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.gfui.envs.*; import gplx.gfui.controls.standards.*;
|
||||
import gplx.xowa.guis.views.*; import gplx.core.envs.*;
|
||||
public class Xoapi_url implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
private GfuiComboBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}
|
||||
public void Focus() {this.Url_box().Focus(); this.Url_box().Sel_(0, String_.Len(this.Url_box().Text()));}
|
||||
public void Exec() {Exec_wkr(Bool_.N, this.Url_box().Text());}
|
||||
public void Exec_by_paste() {Exec_wkr(Bool_.N, ClipboardAdp_.GetText());}
|
||||
public void Exec_new_tab_by_paste() {Exec_wkr(Bool_.Y, ClipboardAdp_.GetText());}
|
||||
public void Restore() {
|
||||
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab(); if (tab == Xog_tab_itm_.Null) return;
|
||||
this.Url_box().Text_(tab.Page().Url().To_str());
|
||||
}
|
||||
void Type() {
|
||||
app.Addon_mgr().Itms__search__urlbar().Search();
|
||||
}
|
||||
private void Exec_wkr(boolean new_tab, String urls_text) {
|
||||
if (Op_sys.Cur().Tid_is_wnt())
|
||||
urls_text = String_.Replace(urls_text, Op_sys.Wnt.Nl_str(), Op_sys.Lnx.Nl_str());
|
||||
String[] urls = String_.Split(String_.Trim(urls_text), Op_sys.Lnx.Nl_str());
|
||||
int urls_len = urls.length;
|
||||
if (urls_len == 0) return;
|
||||
if (urls_len == 1) { // 1 url; most cases
|
||||
String url = urls[0];
|
||||
gplx.core.threads.Thread_adp_.Sleep(1); // HACK: sleep 1 ms, else rapid keystrokes may cause last keystroke to not register; EX: typing "w:" may show just "w" instead of "w:"; DATE:2016-03-27
|
||||
GfuiComboBox combo = this.Url_box();
|
||||
String[] itms_ary = combo.DataSource_as_str_ary();
|
||||
if ( itms_ary.length > 0 // results exist...
|
||||
&& combo.List_visible()) { // and dropdown is visible; use selected-item
|
||||
int sel_idx = combo.List_sel_idx(); // get selected item
|
||||
if (sel_idx == -1) sel_idx = 0; // if nothing selected, default to 1st; allows typing first few characters and picking 1st item from list
|
||||
String itms_sel = itms_ary[sel_idx];
|
||||
// if (String_.Has(String_.Lower(itms_sel), String_.Lower(url))) // make sure itms_sel contains url; handles slow machines, where dropdown may not be updated yet
|
||||
url = Xog_win_itm.Remove_redirect_if_exists(itms_sel);
|
||||
}
|
||||
combo.Text_(url);
|
||||
app.Gui_mgr().Browser_win().Page__navigate_by_url_bar(url);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < urls_len; i++) {
|
||||
String url = urls[i];
|
||||
if (String_.Has_at_bgn(url, "\"") && String_.Has_at_bgn(url, "\""))
|
||||
url = String_.Mid(url, 1, String_.Len(url) - 1);
|
||||
app.Gui_mgr().Browser_win().Tab_mgr().Tabs_new_link(url, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_focus)) this.Focus();
|
||||
else if (ctx.Match(k, Invk_exec)) this.Exec();
|
||||
else if (ctx.Match(k, Invk_exec_by_paste)) this.Exec_by_paste();
|
||||
else if (ctx.Match(k, Invk_exec_new_tab_by_paste)) this.Exec_new_tab_by_paste();
|
||||
else if (ctx.Match(k, Invk_restore)) this.Restore();
|
||||
else if (ctx.Match(k, Invk_type)) this.Type();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_focus = "focus", Invk_exec_by_paste = "exec_by_paste", Invk_exec_new_tab_by_paste = "exec_new_tab_by_paste", Invk_restore = "restore", Invk_type = "type";
|
||||
public static final String Invk_exec = "exec";
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.kits.core.*;
|
||||
import gplx.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xoapi_edit implements Gfo_invk {
|
||||
private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
|
||||
private boolean Active_tab_is_edit() {return !win.Tab_mgr().Active_tab_is_null() && win.Tab_mgr().Active_tab().View_mode() == Xopg_page_.Tid_edit;}
|
||||
public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());}
|
||||
public void Select_all() {if (Active_tab_is_null()) return; Gfo_invk_.Invk_by_key(win.Win_box().Kit().Clipboard(), Gfui_clipboard_.Invk_select_all);}
|
||||
public void Save() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);}
|
||||
public void Save_draft() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);}
|
||||
public void Preview() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());}
|
||||
public void Dbg_tmpl() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xopg_page_.Tid_edit);}
|
||||
public void Dbg_html() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xopg_page_.Tid_html);}
|
||||
public void Focus_edit_box(){if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);}
|
||||
public void Exec() {
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_copy)) this.Copy();
|
||||
else if (ctx.Match(k, Invk_select_all)) this.Select_all();
|
||||
else if (ctx.Match(k, Invk_save)) this.Save();
|
||||
else if (ctx.Match(k, Invk_save_draft)) this.Save_draft();
|
||||
else if (ctx.Match(k, Invk_preview)) this.Preview();
|
||||
else if (ctx.Match(k, Invk_focus_edit_box)) this.Focus_edit_box();
|
||||
else if (ctx.Match(k, Invk_dbg_tmpl)) this.Dbg_tmpl();
|
||||
else if (ctx.Match(k, Invk_dbg_html)) this.Dbg_html();
|
||||
else if (ctx.Match(k, Invk_exec)) this.Exec();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_copy = "copy"
|
||||
, Invk_select_all = "select_all"
|
||||
, Invk_save = "save", Invk_save_draft = "save_draft", Invk_preview = "preview"
|
||||
, Invk_focus_edit_box = "focus_edit_box"
|
||||
, Invk_dbg_tmpl = "dbg_tmpl", Invk_dbg_html = "dbg_html", Invk_exec = "exec"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.gfui.kits.core.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.core.envs.*;
|
||||
public class Xoapi_selection implements Gfo_invk {
|
||||
private Xoae_app app; private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app;
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
|
||||
public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());}
|
||||
public void Select_all() {if (Active_tab_is_null()) return; Gfo_invk_.Invk_by_key(win.Win_box().Kit().Clipboard(), Gfui_clipboard_.Invk_select_all);}
|
||||
public void Save_file_as() {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
Xog_html_itm html_itm = win.Tab_mgr().Active_tab().Html_itm();
|
||||
String src = html_itm.Html_selected_get_src_or_empty();
|
||||
if (String_.Len_eq_0(src)) {app.Usr_dlg().Prog_many("", "", "no file selected: tab=~{0}", html_itm.Owner_tab().Page().Url().To_str()); return;}
|
||||
Io_url src_url = Io_url_.New__http_or_fail(src);
|
||||
String trg_name = src_url.NameAndExt();
|
||||
if (String_.Has(src, "/thumb/")) trg_name = src_url.OwnerDir().NameOnly();
|
||||
String trg = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(trg_name).Ask();
|
||||
if (String_.Len_eq_0(trg)) return;
|
||||
Io_url trg_url = Io_url_.new_fil_(trg);
|
||||
Io_mgr.Instance.CopyFil(src_url, trg_url, true);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_copy)) this.Copy();
|
||||
else if (ctx.Match(k, Invk_select_all)) this.Select_all();
|
||||
else if (ctx.Match(k, Invk_save_file_as)) this.Save_file_as();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_copy = "copy", Invk_select_all = "select_all", Invk_save_file_as = "save_file_as"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
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.apps.apis.xowa.gui.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.gui.*;
|
||||
import gplx.gfui.*; import gplx.gfui.kits.core.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.langs.htmls.encoders.*;
|
||||
public class Xoapi_view implements Gfo_invk {
|
||||
private Xoae_app app; private Xog_win_itm win;
|
||||
private final Gfo_url_encoder fsys_encoder = Gfo_url_encoder_.New__fsys_wnt().Make();
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.app = app; this.win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
|
||||
public void Mode_read() {Mode(Xopg_page_.Tid_read);}
|
||||
public void Mode_edit() {Mode(Xopg_page_.Tid_edit);}
|
||||
public void Mode_html() {Mode(Xopg_page_.Tid_html);}
|
||||
private void Mode(byte v) {if (Active_tab_is_null()) return; win.Page__mode_(v);}
|
||||
public void Reload() {if (Active_tab_is_null()) return; win.Page__reload();}
|
||||
public void Refresh() {if (Active_tab_is_null()) return; win.Page__refresh();}
|
||||
public void Print() {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
win.Active_html_box().Html_js_eval_proc_as_str(Xog_js_procs.Win__print_preview);
|
||||
}
|
||||
public void Save_as() {
|
||||
if (this.Active_tab_is_null()) return;
|
||||
Xog_tab_itm tab = win.Tab_mgr().Active_tab();
|
||||
String file_name = fsys_encoder.Encode_str(String_.new_u8(tab.Page().Ttl().Full_url())) + ".html";
|
||||
String file_url = app.Gui_mgr().Kit().New_dlg_file(Gfui_kit_.File_dlg_type_save, "Select file to save to:").Init_file_(file_name).Ask();
|
||||
if (String_.Len_eq_0(file_url)) return;
|
||||
Io_mgr.Instance.SaveFilStr(file_url, tab.Html_box().Text());
|
||||
app.Usr_dlg().Prog_many("", "", "saved page: file=~{0}", file_url);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_mode_read)) this.Mode_read();
|
||||
else if (ctx.Match(k, Invk_mode_edit)) this.Mode_edit();
|
||||
else if (ctx.Match(k, Invk_mode_html)) this.Mode_html();
|
||||
else if (ctx.Match(k, Invk_reload)) this.Reload();
|
||||
else if (ctx.Match(k, Invk_refresh)) this.Refresh();
|
||||
else if (ctx.Match(k, Invk_print)) this.Print();
|
||||
else if (ctx.Match(k, Invk_save_as)) this.Save_as();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_mode_read = "mode_read", Invk_mode_edit = "mode_edit", Invk_mode_html = "mode_html"
|
||||
, Invk_reload = "reload", Invk_refresh = "refresh"
|
||||
, Invk_print = "print", Invk_save_as = "save_as"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.apps.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
public class Xoapi_modules implements Gfo_invk {
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
popups.Init_by_app(app);
|
||||
}
|
||||
public Xoapi_popups Popups() {return popups;} private Xoapi_popups popups = new Xoapi_popups();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_popups)) return popups;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_popups = "popups";
|
||||
}
|
||||
30
400_xowa/src/gplx/xowa/apps/apis/xowa/html/Xoapi_page.java
Normal file
30
400_xowa/src/gplx/xowa/apps/apis/xowa/html/Xoapi_page.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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.apps.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
public class Xoapi_page implements Gfo_invk {
|
||||
public void Ctor_by_app(Xoae_app app) {
|
||||
toggle_mgr.Ctor_by_app(app);
|
||||
}
|
||||
public void Init_by_app(Xoae_app app) {toggle_mgr.Init_by_app(app);}
|
||||
public Xoapi_toggle_mgr Toggle_mgr() {return toggle_mgr;} private final Xoapi_toggle_mgr toggle_mgr = new Xoapi_toggle_mgr();
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_toggles)) return toggle_mgr;
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
}
|
||||
private static final String Invk_toggles = "toggles";
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
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.apps.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
public class Xoapi_toggle_itm {
|
||||
private final Xoae_app app; // NOTE: needed to get "img_dir" below
|
||||
private byte[] img_title_val_y, img_title_val_n;
|
||||
public Xoapi_toggle_itm(Xoae_app app, byte[] key_bry) {
|
||||
this.app = app; this.key_bry = key_bry;
|
||||
}
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
|
||||
public byte[] Heading_bry() {return heading_bry;} private byte[] heading_bry;
|
||||
public byte[] Icon_src() {return icon_src;} private byte[] icon_src = Bry_.Empty;
|
||||
public byte[] Icon_title() {return icon_title;} private byte[] icon_title = Bry_.Empty;
|
||||
public byte[] Elem_display() {return elem_display;} private byte[] elem_display = Bry_.Empty;
|
||||
public byte[] Html_toggle_hdr_cls() {return html_toggle_hdr_cls;} public Xoapi_toggle_itm Html_toggle_hdr_cls_(byte[] v) {html_toggle_hdr_cls = v; return this;} private byte[] html_toggle_hdr_cls = Bry_.Empty;
|
||||
public boolean Visible() {return visible;} private boolean visible;
|
||||
public void Visible_(boolean v) {
|
||||
this.visible = v;
|
||||
Html_toggle_gen();
|
||||
}
|
||||
public Xoapi_toggle_itm Init(byte[] heading_bry) {
|
||||
this.heading_bry = heading_bry; // NOTE: sets "Wikis" or "In other languages"; Wikidata twisties are empty;
|
||||
this.icon_title = app.Usere().Msg_mgr().Val_by_key_obj(visible ? Img_title_msg_y : Img_title_msg_n); // set title ("show" or "hide")
|
||||
Html_toggle_gen();
|
||||
return this;
|
||||
}
|
||||
public Xoapi_toggle_itm Init_fsys(Io_url img_dir) {
|
||||
if (Img_src_y == null) {
|
||||
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
|
||||
Img_src_n = img_dir.GenSubFil("twisty_right.png").To_http_file_bry();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public void Init_msgs(byte[] img_title_val_y, byte[] img_title_val_n) {
|
||||
this.img_title_val_y = img_title_val_y;
|
||||
this.img_title_val_n = img_title_val_n;
|
||||
Html_toggle_gen();
|
||||
}
|
||||
public byte[] Html_toggle_btn() {return html_toggle_btn;} private byte[] html_toggle_btn;
|
||||
public byte[] Html_toggle_hdr() {return html_toggle_hdr;} private byte[] html_toggle_hdr;
|
||||
private void Assert_img_src() {
|
||||
if (Img_src_y == null) {
|
||||
Io_url img_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("app.general");
|
||||
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
|
||||
Img_src_n = img_dir.GenSubFil("twisty_right.png").To_http_file_bry();
|
||||
}
|
||||
}
|
||||
private void Html_toggle_gen() {
|
||||
Assert_img_src();// NOTE: must call Assert_img_src else wikidata twisties will be missing img; DATE:2015-08-05
|
||||
if (visible) {
|
||||
icon_src = Img_src_y;
|
||||
icon_title = img_title_val_y;
|
||||
elem_display = Img_display_y;
|
||||
}
|
||||
else {
|
||||
icon_src = Img_src_n;
|
||||
icon_title = img_title_val_n;
|
||||
elem_display = Img_display_n;
|
||||
}
|
||||
Bry_fmtr fmtr = Bry_fmtr.new_(); Bry_bfr bfr = Bry_bfr_.New_w_size(8);
|
||||
html_toggle_btn
|
||||
= fmtr.Fmt_("<a href='javascript:xowa_toggle_visible(\"~{key}\");' style='text-decoration: none !important;'>~{heading}<img id='~{key}-toggle-icon' src='~{src}' title='~{title}' /></a>")
|
||||
.Keys_("key", "src", "title", "heading").Bld_bry_many(bfr, key_bry, icon_src, icon_title, heading_bry)
|
||||
;
|
||||
html_toggle_hdr
|
||||
= fmtr.Fmt_(" id='~{key}-toggle-elem' style='~{display}~{toggle_hdr_cls}'")
|
||||
.Keys_("key", "display", "toggle_hdr_cls").Bld_bry_many(bfr, key_bry, elem_display, html_toggle_hdr_cls)
|
||||
;
|
||||
}
|
||||
private static byte[] Img_src_y, Img_src_n; // assume these are the same for all itms
|
||||
private static final byte[]
|
||||
Img_title_msg_y = Bry_.new_a7("hide"), Img_title_msg_n = Bry_.new_a7("show")
|
||||
, Img_display_y = Bry_.new_a7("display:;"), Img_display_n = Bry_.new_a7("display:none;")
|
||||
;
|
||||
}
|
||||
101
400_xowa/src/gplx/xowa/apps/apis/xowa/html/Xoapi_toggle_mgr.java
Normal file
101
400_xowa/src/gplx/xowa/apps/apis/xowa/html/Xoapi_toggle_mgr.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
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.apps.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.apps.cfgs.*;
|
||||
public class Xoapi_toggle_mgr implements Gfo_invk {
|
||||
private Xoae_app app;
|
||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||
public void Ctor_by_app(Xoae_app app) {this.app = app;}
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
Io_url img_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("app.general");
|
||||
int len = hash.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoapi_toggle_itm itm = (Xoapi_toggle_itm)hash.Get_at(i);
|
||||
itm.Init_fsys(img_dir);
|
||||
}
|
||||
|
||||
app.Cfg().Bind_many_app(this
|
||||
, Cfg__toggles__offline_wikis
|
||||
, Cfg__toggles__wikidata_langs
|
||||
, Cfg__toggles__claim
|
||||
, Cfg__toggles__slink_w
|
||||
, Cfg__toggles__slink_d
|
||||
, Cfg__toggles__slink_s
|
||||
, Cfg__toggles__slink_v
|
||||
, Cfg__toggles__slink_q
|
||||
, Cfg__toggles__slink_b
|
||||
, Cfg__toggles__slink_u
|
||||
, Cfg__toggles__slink_n
|
||||
, Cfg__toggles__slink_special
|
||||
, Cfg__toggles__label
|
||||
, Cfg__toggles__descr
|
||||
, Cfg__toggles__alias
|
||||
, Cfg__toggles__json
|
||||
);
|
||||
}
|
||||
public Xoapi_toggle_itm Get_or_new(String key_str) {
|
||||
byte[] key_bry = Bry_.new_u8(key_str);
|
||||
Xoapi_toggle_itm rv = (Xoapi_toggle_itm)hash.Get_by(key_bry);
|
||||
if (rv == null) {
|
||||
rv = new Xoapi_toggle_itm(app, key_bry);
|
||||
hash.Add(key_bry, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.MatchIn(k
|
||||
, Cfg__toggles__offline_wikis
|
||||
, Cfg__toggles__wikidata_langs
|
||||
, Cfg__toggles__claim
|
||||
, Cfg__toggles__slink_w
|
||||
, Cfg__toggles__slink_d
|
||||
, Cfg__toggles__slink_s
|
||||
, Cfg__toggles__slink_v
|
||||
, Cfg__toggles__slink_q
|
||||
, Cfg__toggles__slink_b
|
||||
, Cfg__toggles__slink_u
|
||||
, Cfg__toggles__slink_n
|
||||
, Cfg__toggles__slink_special
|
||||
, Cfg__toggles__label
|
||||
, Cfg__toggles__descr
|
||||
, Cfg__toggles__alias
|
||||
, Cfg__toggles__json)) {
|
||||
this.Get_or_new(String_.Replace(k, "xowa.html.toggles.", "")).Visible_(m.ReadYn("v"));
|
||||
}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Cfg__toggles__offline_wikis = "xowa.html.toggles.offline-wikis"
|
||||
, Cfg__toggles__wikidata_langs = "xowa.html.toggles.wikidata-langs"
|
||||
, Cfg__toggles__claim = "xowa.html.toggles.wikidatawiki-claim"
|
||||
, Cfg__toggles__slink_w = "xowa.html.toggles.wikidatawiki-slink-wikipedia"
|
||||
, Cfg__toggles__slink_d = "xowa.html.toggles.wikidatawiki-slink-wiktionary"
|
||||
, Cfg__toggles__slink_s = "xowa.html.toggles.wikidatawiki-slink-wikisource"
|
||||
, Cfg__toggles__slink_v = "xowa.html.toggles.wikidatawiki-slink-wikivoyage"
|
||||
, Cfg__toggles__slink_q = "xowa.html.toggles.wikidatawiki-slink-wikiquote"
|
||||
, Cfg__toggles__slink_b = "xowa.html.toggles.wikidatawiki-slink-wikibooks"
|
||||
, Cfg__toggles__slink_u = "xowa.html.toggles.wikidatawiki-slink-wikiversity"
|
||||
, Cfg__toggles__slink_n = "xowa.html.toggles.wikidatawiki-slink-wikinews"
|
||||
, Cfg__toggles__slink_special = "xowa.html.toggles.wikidatawiki-slink-special"
|
||||
, Cfg__toggles__label = "xowa.html.toggles.wikidatawiki-label"
|
||||
, Cfg__toggles__descr = "xowa.html.toggles.wikidatawiki-descr"
|
||||
, Cfg__toggles__alias = "xowa.html.toggles.wikidatawiki-alias"
|
||||
, Cfg__toggles__json = "xowa.html.toggles.wikidatawiki-json"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.apps.apis.xowa.html.modules; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*; import gplx.xowa.apps.apis.xowa.html.*;
|
||||
import gplx.xowa.htmls.modules.popups.*;
|
||||
public class Xoapi_popups implements Gfo_invk, Gfo_evt_mgr_owner {
|
||||
private Xoae_app app;
|
||||
public Xoapi_popups() {
|
||||
evt_mgr = new Gfo_evt_mgr(this);
|
||||
}
|
||||
public Gfo_evt_mgr Evt_mgr() {return evt_mgr;} private Gfo_evt_mgr evt_mgr;
|
||||
public void Init_by_app(Xoae_app app) {this.app = app;}
|
||||
public void Show_more(String popup_id) {
|
||||
Xowe_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Wiki();
|
||||
wiki.Html_mgr().Head_mgr().Popup_mgr().Show_more(popup_id);
|
||||
}
|
||||
public void Show_all(String popup_id) {
|
||||
Xowe_wiki wiki = app.Gui_mgr().Browser_win().Active_tab().Wiki();
|
||||
wiki.Html_mgr().Head_mgr().Popup_mgr().Show_all(popup_id);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_show_more)) Show_more(m.ReadStr("popup_id"));
|
||||
else if (ctx.Match(k, Invk_show_all)) Show_all (m.ReadStr("popup_id"));
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_show_more = "show_more", Invk_show_all = "show_all"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.apps.apis.xowa.navs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.htmls.hrefs.*;
|
||||
public class Xoapi_nav_wiki implements Gfo_invk {
|
||||
private Xog_win_itm win;
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
win = app.Gui_mgr().Browser_win();
|
||||
}
|
||||
public void Random() {win.Page__navigate_by_url_bar("Special:Random");}
|
||||
public void Sandbox() {win.Page__navigate_by_url_bar("Project:Sandbox");}
|
||||
public void Main_page() {
|
||||
win.Tab_mgr().Active_tab_assert(); // force an active tab in case all tabs are closed; needed for win.Active_page() below; DATE:2014-09-17
|
||||
win.Page__navigate_by_url_bar(win.Active_tab().Wiki().Domain_str() + Xoh_href_.Str__wiki); // NOTE: add "/wiki/" to generate non-page like url; EX: "home" -> "home/wiki/" which will be interpreted as a url, as opposed to "home" which will be intrepretted as page; DATE:2014-04-14
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_main_page)) this.Main_page();
|
||||
else if (ctx.Match(k, Invk_random)) this.Random();
|
||||
else if (ctx.Match(k, Invk_sandbox)) this.Sandbox();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_main_page = "main_page", Invk_random = "random", Invk_sandbox = "sandbox";
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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.apps.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.guis.history.*; import gplx.xowa.guis.views.*;
|
||||
import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xoapi_bookmarks implements Gfo_invk {
|
||||
private Xoae_app app; private Xog_win_itm win;
|
||||
private boolean enabled = true;
|
||||
public void Ctor_by_app(Xoae_app app) {this.app = app;}
|
||||
public void Init_by_kit(Xoae_app app) {
|
||||
this.win = app.Gui_mgr().Browser_win();
|
||||
app.Cfg().Bind_many_app(this, Cfg__enabled);
|
||||
}
|
||||
public boolean Delete_confirm() {return delete_confirm;} private boolean delete_confirm = true;
|
||||
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaBookmarks");}
|
||||
public String Add(String url_str) {
|
||||
if (!enabled) return app.Html__bridge_mgr().Msg_bldr().To_json_str__empty();
|
||||
Xoa_url url = null;
|
||||
if (url_str == null) {
|
||||
Xog_tab_itm tab = win.Active_tab(); if (tab == Xog_tab_itm_.Null) return app.Html__bridge_mgr().Msg_bldr().Clear().Notify_pass_("bookmark added").To_json_str(); // called by http_server; return success
|
||||
url = tab.Page().Url();
|
||||
}
|
||||
else
|
||||
url = app.User().Wikii().Utl__url_parser().Parse(Bry_.new_u8(url_str));
|
||||
app.User().User_db_mgr().Bmk_mgr().Itms__add(Xoud_bmk_mgr.Owner_root, url);
|
||||
String msg = "bookmark added: " + String_.new_u8(url.Page_bry());
|
||||
String rv = app.Html__bridge_mgr().Msg_bldr().Clear().Notify_pass_(msg).To_json_str();
|
||||
win.Active_tab().Html_box().Html_js_eval_proc_as_str("xowa.cmds.exec_by_str", "xowa.notify", "{\"text\":\"" + msg + "\",\"status\":\"success\"}");
|
||||
return rv;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Cfg__enabled)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_delete_confirm)) return Yn.To_str(delete_confirm);
|
||||
else if (ctx.Match(k, Invk_delete_confirm_)) delete_confirm = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_add)) return this.Add(m.ReadStrOr("v", null));
|
||||
else if (ctx.Match(k, Invk_show)) this.Show();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String
|
||||
Invk_delete_confirm = "delete_confirm", Invk_delete_confirm_ = "delete_confirm_"
|
||||
, Invk_add = "add", Invk_show = "show"
|
||||
, Cfg__enabled = "xowa.app.bookmarks.enabled"
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.apps.apis.xowa.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xoapi_history implements Gfo_invk {
|
||||
private Xoae_app app; private Xog_win_itm win;
|
||||
public void Ctor_by_app(Xoae_app app) {this.app = app;}
|
||||
public void Init_by_kit(Xoae_app app) {this.win = app.Gui_mgr().Browser_win();}
|
||||
public void Goto_recent() {win.Page__navigate_by_url_bar(app.Usere().History_mgr().Get_at_last());}
|
||||
public void Show() {win.Page__navigate_by_url_bar("home/wiki/Special:XowaPageHistory");}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_goto_recent)) this.Goto_recent();
|
||||
else if (ctx.Match(k, Invk_show)) this.Show();
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
private static final String Invk_goto_recent = "goto_recent", Invk_show = "show";
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.apps.apis.xowa.xtns; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
|
||||
import gplx.xowa.xtns.wbases.*;
|
||||
public class Xoapi_wikibase implements Gfo_invk, Gfo_evt_mgr_owner {
|
||||
public Xoapi_wikibase() {
|
||||
evt_mgr = new Gfo_evt_mgr(this);
|
||||
}
|
||||
public Gfo_evt_mgr Evt_mgr() {return evt_mgr;} private Gfo_evt_mgr evt_mgr;
|
||||
public byte[][] Core_langs() {return core_langs;} private byte[][] core_langs = Bry_.Ary("en");
|
||||
public byte[][] Sort_langs() {return sort_langs;} private byte[][] sort_langs = Bry_.Ary("en", "de", "es", "fr", "it", "nl", "pl", "ru", "sv");
|
||||
public byte[] Link_wikis() {return link_wikis;} private byte[] link_wikis = Bry_.new_a7("enwiki");
|
||||
public void Init_by_app(Xoae_app app) {
|
||||
app.Cfg().Bind_many_app(this, Cfg__core_langs, Cfg__link_wikis, Cfg__sort_langs);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Cfg__core_langs)) {core_langs = m.ReadBryAry("v", Byte_ascii.Semic); Gfo_evt_mgr_.Pub_val(this, Evt_core_langs_changed, core_langs);}
|
||||
else if (ctx.Match(k, Cfg__sort_langs)) {sort_langs = m.ReadBryAry("v", Byte_ascii.Semic); Gfo_evt_mgr_.Pub_val(this, Evt_sort_langs_changed, sort_langs);}
|
||||
else if (ctx.Match(k, Cfg__link_wikis)) {link_wikis = m.ReadBry("v"); Gfo_evt_mgr_.Pub_val(this, Evt_link_wikis_changed, link_wikis);}
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
}
|
||||
public static final String
|
||||
Evt_core_langs_changed = "core_langs_changed"
|
||||
, Evt_sort_langs_changed = "sort_langs_changed"
|
||||
, Evt_link_wikis_changed = "link_wikis_changed"
|
||||
;
|
||||
private static final String
|
||||
Cfg__core_langs = "xowa.addon.wikibase.langs.core_langs"
|
||||
, Cfg__sort_langs = "xowa.addon.wikibase.langs.sort_langs"
|
||||
, Cfg__link_wikis = "xowa.addon.wikibase.xwikis.link_wikis"
|
||||
;
|
||||
}
|
||||
Reference in New Issue
Block a user