1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

v2.10.3.1

This commit is contained in:
gnosygnu
2015-10-18 22:17:57 -04:00
parent 8e18af05b6
commit 4f43f51b18
1935 changed files with 12500 additions and 12889 deletions

View File

@@ -19,7 +19,7 @@ package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
public class Xoa_app_eval implements Bry_fmtr_eval_mgr {
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public byte[] Eval(byte[] cmd) {
Object rslt = GfsCore._.Exec_bry(cmd);
Object rslt = GfsCore.Instance.Exec_bry(cmd);
return Bry_.new_u8(Object_.Xto_str_strict_or_null_mark(rslt));
}
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*;
import gplx.xowa.apps.gfss.*;
import gplx.xowa.apps.gfs.*;
public class Xoa_app_eval_tst {
Xoa_app_eval_fxt fxt = new Xoa_app_eval_fxt();
@Before public void init() {fxt.Clear();}

View File

@@ -0,0 +1,65 @@
/*
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; import gplx.*; import gplx.xowa.*;
import gplx.core.primitives.*;
public class Xoa_app_mode {
Xoa_app_mode(int tid) {this.tid = tid;}
public int Tid() {return tid;} private final int tid;
public boolean Tid_is_gui() {return tid == Tid_gui;}
public boolean Tid_is_tcp() {return tid == Tid_tcp;}
public boolean Tid_is_http() {return tid == Tid_http;}
public boolean Tid_supports_js() {
switch (tid) {
case Tid_gui:
case Tid_tcp: return true;
default: return false;
}
}
public byte[] Name() {
switch (tid) {
case Tid_cmd: return Key_cmd;
case Tid_gui: return Key_gui;
case Tid_http: return Key_http;
case Tid_tcp: return Key_tcp;
case Tid_file: return Key_file;
default: return Key_cmd; // see parse
}
}
private static final int Tid_cmd = 1, Tid_gui = 2, Tid_tcp = 3, Tid_http = 4, Tid_file = 5;
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_gui = Bry_.new_a7("gui"), Key_tcp = Bry_.new_a7("server"), Key_http = Bry_.new_a7("http_server"), Key_file = Bry_.new_a7("file");
public static final Xoa_app_mode Itm_cmd = new Xoa_app_mode(Tid_cmd), Itm_gui = new Xoa_app_mode(Tid_gui), Itm_tcp = new Xoa_app_mode(Tid_tcp), Itm_http = new Xoa_app_mode(Tid_http), Itm_file = new Xoa_app_mode(Tid_file);
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
.Add_bry_int(Key_cmd , Tid_cmd)
.Add_bry_int(Key_gui , Tid_gui)
.Add_bry_int(Key_http , Tid_http)
.Add_bry_int(Key_tcp , Tid_tcp)
.Add_bry_int(Key_file , Tid_file)
;
public static Xoa_app_mode parse(String s) {
Object o = type_hash.Get_by(Bry_.new_u8(s)); if (o == null) return Itm_cmd; // default to cmd as per early behaviour; handles mistaken "--app_mode wrong"
int tid = ((Int_obj_val)o).Val();
switch (tid) {
case Tid_cmd: return Itm_cmd;
case Tid_gui: return Itm_gui;
case Tid_http: return Itm_http;
case Tid_tcp: return Itm_tcp;
case Tid_file: return Itm_file;
default: throw Err_.new_unhandled(tid);
}
}
}

View File

@@ -1,65 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.core.primitives.*;
public class Xoa_app_type {
Xoa_app_type(int uid) {this.uid = uid;}
public int Uid() {return uid;} private final int uid;
public boolean Uid_is_gui() {return uid == Uid_gui;}
public boolean Uid_is_tcp() {return uid == Uid_tcp;}
public boolean Uid_is_http() {return uid == Uid_http;}
public boolean Uid_supports_js() {
switch (uid) {
case Uid_gui:
case Uid_tcp: return true;
default: return false;
}
}
public byte[] Name() {
switch (uid) {
case Uid_cmd: return Key_cmd;
case Uid_gui: return Key_gui;
case Uid_http: return Key_http;
case Uid_tcp: return Key_tcp;
case Uid_file: return Key_file;
default: return Key_cmd; // see parse
}
}
private static final int Uid_cmd = 1, Uid_gui = 2, Uid_tcp = 3, Uid_http = 4, Uid_file = 5;
private static final byte[] Key_cmd = Bry_.new_a7("cmd"), Key_gui = Bry_.new_a7("gui"), Key_tcp = Bry_.new_a7("server"), Key_http = Bry_.new_a7("http_server"), Key_file = Bry_.new_a7("file");
private static final Hash_adp_bry type_hash = Hash_adp_bry.cs()
.Add_bry_int(Key_cmd , Uid_cmd)
.Add_bry_int(Key_gui , Uid_gui)
.Add_bry_int(Key_http , Uid_http)
.Add_bry_int(Key_tcp , Uid_tcp)
.Add_bry_int(Key_file , Uid_file)
;
public static final Xoa_app_type Itm_cmd = new Xoa_app_type(Uid_cmd), Itm_gui = new Xoa_app_type(Uid_gui), Itm_tcp = new Xoa_app_type(Uid_tcp), Itm_http = new Xoa_app_type(Uid_http), Itm_file = new Xoa_app_type(Uid_file);
public static Xoa_app_type parse(String s) {
Object o = type_hash.Get_by(Bry_.new_u8(s)); if (o == null) return Itm_cmd; // default to cmd as per early behaviour; handles mistaken "--app_mode wrong"
int uid = ((Int_obj_val)o).Val();
switch (uid) {
case Uid_cmd: return Itm_cmd;
case Uid_gui: return Itm_gui;
case Uid_http: return Itm_http;
case Uid_tcp: return Itm_tcp;
case Uid_file: return Itm_file;
default: throw Err_.new_unhandled(uid);
}
}
}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.xowa.gui.views.*;
import gplx.xowa.guis.views.*;
public class Xoa_cur implements GfoInvkAble {
public Xoa_cur(Xoae_app app) {this.app = app;} private Xoae_app app;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@@ -18,14 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.core.consoles.*;
import gplx.xowa.wikis.*;
import gplx.xowa.html.hrefs.*;
import gplx.xowa.htmls.hrefs.*;
public class Xoa_shell implements GfoInvkAble {
public Xoa_shell(Xoae_app app) {this.app = app;} private Xoae_app app;
public boolean Fetch_page_exec_async() {return fetch_page_exec_async;} private boolean fetch_page_exec_async = true;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_fetch_page)) return Fetch_page(m);
else if (ctx.Match(k, Invk_chars_per_line_max_)) Console_adp__sys.I.Chars_per_line_max_(m.ReadInt("v"));
else if (ctx.Match(k, Invk_backspace_by_bytes_)) Console_adp__sys.I.Backspace_by_bytes_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_chars_per_line_max_)) Console_adp__sys.Instance.Chars_per_line_max_(m.ReadInt("v"));
else if (ctx.Match(k, Invk_backspace_by_bytes_)) Console_adp__sys.Instance.Backspace_by_bytes_(m.ReadYn("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import org.junit.*; import gplx.xowa.apps.gfss.*;
import org.junit.*; import gplx.xowa.apps.gfs.*;
public class Xoa_shell_tst {
@Test public void Fetch_page() { // PURPOSE.fix: fetch_page failed with nullRef; DATE:2013-04-12
Xop_fxt parser_fxt = new Xop_fxt();

View File

@@ -22,14 +22,14 @@ public class Xoa_sys_cfg implements GfoInvkAble {
public Xoa_sys_cfg(Xoae_app app) {this.app = app;}
public byte[] Lang() {return lang_key;}
public Xoa_sys_cfg Lang_(byte[] v) {
lang_key = Xol_lang_itm_.Get_by_key_or_en(v).Key();
lang_key = Xol_lang_stub_.Get_by_key_or_en(v).Key();
if (app.Stage() == gplx.xowa.apps.Xoa_stage_.Tid_launch) { // do not update user lang unless launched; DATE:2014-05-26
Xol_lang lang = app.Lang_mgr().Get_by_key_or_load(lang_key);
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_load(lang_key);
app.Usere().Lang_(lang);
app.Usere().Wiki().Html_mgr().Portal_mgr().Init();
}
return this;
} private byte[] lang_key = Xol_lang_.Key_en;
} private byte[] lang_key = Xol_lang_itm_.Key_en;
public int Options_version() {return options_version;} public Xoa_sys_cfg Options_version_(int v) {options_version = v; return this;} private int options_version = 1;
public KeyVal[] Options_lang_list() {if (options_lang_list == null) options_lang_list = Options_list_lang_.new_(); return options_lang_list;} private KeyVal[] options_lang_list;
public long Free_mem_when() {return free_mem_when;} long free_mem_when;
@@ -50,35 +50,35 @@ public class Xoa_sys_cfg implements GfoInvkAble {
}
class Options_list_lang_ {
public static KeyVal[] new_() {
Ordered_hash translated = Ordered_hash_.new_bry_();
Ordered_hash translated = Ordered_hash_.New_bry();
List_adp untranslated = List_adp_.new_();
Add_itm_many(translated, Xol_lang_itm_.Id_en, Xol_lang_itm_.Id_de, Xol_lang_itm_.Id_pl, Xol_lang_itm_.Id_zh_hans, Xol_lang_itm_.Id_zh_hant); // add langs with translations first, so they alphabetize to top of list
int len = Xol_lang_itm_.Id__max;
Add_itm_many(translated, Xol_lang_stub_.Id_en, Xol_lang_stub_.Id_de, Xol_lang_stub_.Id_pl, Xol_lang_stub_.Id_zh_hans, Xol_lang_stub_.Id_zh_hant); // add langs with translations first, so they alphabetize to top of list
int len = Xol_lang_stub_.Id__max;
for (int i = 0; i < len; i++) { // add rest of langs, but sort by code
Xol_lang_itm itm = Xol_lang_itm_.Get_by_id(i);
Xol_lang_stub itm = Xol_lang_stub_.Get_by_id(i);
if (translated.Has(itm.Key())) continue;
untranslated.Add(itm);
}
untranslated.Sort_by(Xol_lang_itm_.Comparer_key);
untranslated.Sort_by(Xol_lang_stub_.Comparer_key);
KeyVal[] rv = new KeyVal[len];
int translated_max = translated.Count();
for (int i = 0; i < translated_max; i++)
rv[i] = new_itm((Xol_lang_itm)translated.Get_at(i));
rv[i] = new_itm((Xol_lang_stub)translated.Get_at(i));
for (int i = translated_max; i < len; i++)
rv[i] = new_itm((Xol_lang_itm)untranslated.Get_at(i - translated_max));
rv[i] = new_itm((Xol_lang_stub)untranslated.Get_at(i - translated_max));
return rv;
}
private static KeyVal new_itm(Xol_lang_itm itm) {
private static KeyVal new_itm(Xol_lang_stub itm) {
String key_str = String_.new_u8(itm.Key());
String name_str = String_.new_u8(itm.Localized_name());
String name_str = String_.new_u8(itm.Canonical_name());
return KeyVal_.new_(key_str, name_str + " [" + key_str + "]");
}
private static void Add_itm_many(Ordered_hash translated, int... langs) {
int langs_len = langs.length;
for (int i = 0; i < langs_len; i++) {
Xol_lang_itm itm = Xol_lang_itm_.Get_by_id(langs[i]);
Xol_lang_stub itm = Xol_lang_stub_.Get_by_id(langs[i]);
translated.Add_if_dupe_use_nth(itm.Key(), itm);
}
}

View File

@@ -18,19 +18,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.core.net.*; import gplx.langs.jsons.*;
import gplx.ios.*;
import gplx.dbs.*; import gplx.xowa.apis.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.core.intls.*; import gplx.xowa.users.data.*;
import gplx.xowa.apps.urls.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.dbs.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.fsys.*; import gplx.xowa.apps.metas.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.langs.cases.*; import gplx.core.intls.*; import gplx.xowa.users.data.*;
import gplx.xowa.apps.site_cfgs.*; import gplx.xowa.apps.urls.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.imgs.*;
import gplx.xowa.bldrs.css.*;
import gplx.xowa.html.hrefs.*; import gplx.xowa.html.wtrs.*; import gplx.xowa.html.bridges.*;
import gplx.xowa.apps.gfs.*;
import gplx.xowa.htmls.hrefs.*; import gplx.xowa.htmls.wtrs.*; import gplx.xowa.htmls.bridges.*;
import gplx.xowa.users.*;
import gplx.xowa.wikis.*;
import gplx.xowa.wms.*;
import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.parsers.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
import gplx.xowa.langs.*;
import gplx.xowa.bldrs.wms.*;
import gplx.langs.htmls.encoders.*;
public class Xoav_app implements Xoa_app {
public Xoav_app(Gfo_usr_dlg usr_dlg, Xoa_app_type app_type, String plat_name, Io_url root_dir, Io_url file_dir, Io_url css_dir) {
Xoa_app_.Usr_dlg_(usr_dlg); this.usr_dlg = usr_dlg; this.app_type = app_type;
public class Xoav_app implements Xoa_app, GfoInvkAble {
public Xoav_app(Gfo_usr_dlg usr_dlg, Xoa_app_mode mode, String plat_name, Io_url root_dir, Io_url file_dir, Io_url css_dir) {
Xoa_app_.Usr_dlg_(usr_dlg); this.usr_dlg = usr_dlg; this.mode = mode;
this.fsys_mgr = new Xoa_fsys_mgr(plat_name, root_dir, root_dir.GenSubDir("wiki"), file_dir, css_dir);
this.lang_mgr = new Xoa_lang_mgr(this);
this.meta_mgr = new Xoa_meta_mgr(this);
this.gfs_mgr = new Xoa_gfs_mgr(this, fsys_mgr, null);
this.file__cache_mgr = new Xof_cache_mgr(usr_dlg, null, null);
this.file__img_mgr = new Xof_img_mgr();
this.wiki_mgr = new Xoav_wiki_mgr(this, utl_case_mgr);
@@ -39,13 +43,17 @@ public class Xoav_app implements Xoa_app {
this.html__bridge_mgr = new Xoh_bridge_mgr(utl__json_parser);
this.user = new Xouv_user("anonymous");
this.api_root = null;
this.site_cfg_mgr = new Xoa_site_cfg_mgr(this);
}
public boolean Tid_is_edit() {return Bool_.N;}
public Xoa_app_mode Mode() {return mode;} private final Xoa_app_mode mode;
public Xou_user User() {return user;} private final Xouv_user user;
public Xoapi_root Api_root() {return api_root;} private final Xoapi_root api_root;
public Xoa_app_type App_type() {return app_type;} private final Xoa_app_type app_type;
public Xoa_fsys_mgr Fsys_mgr() {return fsys_mgr;} private final Xoa_fsys_mgr fsys_mgr;
public Xoav_wiki_mgr Wiki_mgr() {return wiki_mgr;} private final Xoav_wiki_mgr wiki_mgr;
public Xoa_wiki_mgr Wiki_mgri() {return wiki_mgr;}
public Xoa_lang_mgr Lang_mgr() {return lang_mgr;} private final Xoa_lang_mgr lang_mgr;
public Xoa_gfs_mgr Gfs_mgr() {return gfs_mgr;} private final Xoa_gfs_mgr gfs_mgr;
public Xof_cache_mgr File__cache_mgr() {return file__cache_mgr;} private final Xof_cache_mgr file__cache_mgr;
public Xof_img_mgr File__img_mgr() {return file__img_mgr;} private final Xof_img_mgr file__img_mgr;
public Io_download_fmt File__download_fmt() {return file__download_fmt;} private final Io_download_fmt file__download_fmt = new Io_download_fmt();
@@ -55,9 +63,12 @@ public class Xoav_app implements Xoa_app {
public Xoa_css_extractor Html__css_installer() {return html__css_installer;} private final Xoa_css_extractor html__css_installer = new Xoa_css_extractor();
public Xoh_bridge_mgr Html__bridge_mgr() {return html__bridge_mgr;} private final Xoh_bridge_mgr html__bridge_mgr;
public Xoa_meta_mgr Meta_mgr() {return meta_mgr;} private final Xoa_meta_mgr meta_mgr;
public Gfo_inet_conn Utl__inet_conn() {return inet_conn;} public void Utl__inet_conn_(Gfo_inet_conn v) {this.inet_conn = v;} private Gfo_inet_conn inet_conn;
public Gfo_inet_conn Utl__inet_conn() {return inet_conn;} private final Gfo_inet_conn inet_conn = Gfo_inet_conn_.new_();
public Xoa_site_cfg_mgr Site_cfg_mgr() {return site_cfg_mgr;} private final Xoa_site_cfg_mgr site_cfg_mgr;
public boolean Xwiki_mgr__missing(byte[] domain) {return wiki_mgr.Get_by_domain(domain) == null;}
public Xoa_sitelink_mgr Xwiki_mgr__sitelink_mgr() {return xwiki_mgr__sitelink_mgr;} private final Xoa_sitelink_mgr xwiki_mgr__sitelink_mgr = new Xoa_sitelink_mgr();
public Xow_xwiki_itm_parser Xwiki_mgr__itm_parser() {return xwiki_mgr__itm_parser;} private final Xow_xwiki_itm_parser xwiki_mgr__itm_parser = new Xow_xwiki_itm_parser();
public Xowmf_mgr Wmf_mgr() {return wmf_mgr;} private final Xowmf_mgr wmf_mgr = new Xowmf_mgr();
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} public void Usr_dlg_(Gfo_usr_dlg v) {usr_dlg = v; Xoa_app_.Usr_dlg_(usr_dlg);} private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Noop;
public Bry_bfr_mkr Utl__bfr_mkr() {return Xoa_app_.Utl__bfr_mkr();}
@@ -65,13 +76,13 @@ public class Xoav_app implements Xoa_app {
public Json_parser Utl__json_parser() {return utl__json_parser;} private final Json_parser utl__json_parser = new Json_parser();
public boolean Bldr__running() {return bldr__running;} public void Bldr__running_(boolean v) {this.bldr__running = v;} private boolean bldr__running;
public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = Xop_amp_mgr.I;
public Xop_amp_mgr Utl_amp_mgr() {return utl_amp_mgr;} private Xop_amp_mgr utl_amp_mgr = Xop_amp_mgr.Instance;
public Xol_case_mgr Utl_case_mgr() {return utl_case_mgr;} private Xol_case_mgr utl_case_mgr = Xol_case_mgr_.U8();
public Url_encoder Utl_encoder_fsys() {return utl_encoder_fsys;} private Url_encoder utl_encoder_fsys = Url_encoder.new_fsys_lnx_();
public Gfo_msg_log Utl_msg_log() {return utl_msg_log;} private Gfo_msg_log utl_msg_log;
public Xoav_url_parser Utl_url_parser_xo() {return utl_url_parser_xo;} private Xoav_url_parser utl_url_parser_xo = new Xoav_url_parser();
public Gfo_url_parser Utl_url_parser_gfo() {return utl_url_parser_gfo;} private final Gfo_url_parser utl_url_parser_gfo = new Gfo_url_parser();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {throw Err_.new_unimplemented_w_msg("implemented for Xoa_cfg_mgr");}
public void Init_by_app(Io_url user_db_url) {
user.Init_db(this, wiki_mgr, user_db_url);
}

View File

@@ -19,8 +19,10 @@ package gplx.xowa.apps; import gplx.*; import gplx.xowa.*;
import gplx.xowa.*; import gplx.xowa.langs.cases.*; import gplx.xowa.users.data.*;
import gplx.xowa.wikis.*;
public class Xoav_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
private final Xoav_app app; private final Ordered_hash hash = Ordered_hash_.new_bry_();
private final Xoav_app app; private final Ordered_hash hash = Ordered_hash_.New_bry();
public Xoav_wiki_mgr(Xoav_app app, Xol_case_mgr case_mgr) {this.app = app;}
public int Count() {return hash.Count();}
public Xow_wiki Get_at_i(int i) {return (Xow_wiki)hash.Get_at(i);}
public Xowv_wiki Get_by_domain(byte[] domain) {return (Xowv_wiki)hash.Get_by(domain);}
public Xowv_wiki Import_by_fil(Io_url fil) {
Io_url wiki_dir = fil.OwnerDir();
@@ -40,6 +42,7 @@ public class Xoav_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
return Load(Gen_domain_str(fil.NameOnly()), fil.OwnerDir());
}
public boolean Has(byte[] key) {return hash.Has(key);}
public Xow_wiki Get_by_key_or_null_i(byte[] key) {return (Xowv_wiki)hash.Get_by(key);}
public Xow_wiki Get_by_key_or_make_init_y(byte[] key) {
Xow_wiki rv = this.Get_by_domain(key);
// if (rv == null) rv = New_wiki(key); // TODO: must init wiki, but need wiki_url; DATE:2015-05-23
@@ -47,7 +50,7 @@ public class Xoav_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
}
public Xow_wiki Get_by_key_or_make_init_n(byte[] key) {return Get_by_key_or_make_init_y(key);}
public void Load_by_dir(Io_url wiki_root_dir) {
Io_url[] wiki_dirs = Io_mgr.I.QueryDir_args(wiki_root_dir).DirOnly_().ExecAsUrlAry();
Io_url[] wiki_dirs = Io_mgr.Instance.QueryDir_args(wiki_root_dir).DirOnly_().ExecAsUrlAry();
for (Io_url wiki_dir : wiki_dirs) {
String wiki_dir_url = wiki_dir.Raw();
if (String_.Has_at_bgn(wiki_dir_url, "#")) continue;

View File

@@ -0,0 +1,178 @@
/*
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.*;
class Xoapi_doc {}
/*
xowa {
app {
exit();
env {
version_previous;
}
fsys {
plat_jar;
plat_url();
}
startup {
tabs {
type; // [blank,xowa,custom,previous]
previous;
custom;
custom_is_expr;
}
}
}
nav {
go_bwd();
go_fwd();
goto();
wiki {
main_page();
random();
sandbox();
}
}
gui {
browser {
url {
focus();
exec_by_paste();
exec_new_tab_by_paste();
restore();
exec();
}
search {
focus();
exec();
}
tabs {
new_dflt__at_dflt__focus_y();
new_link__at_dflt__focus_n();
new_link__at_dflt__focus_y();
new_href__at_dflt__focus_y();
new_dupe__at_dflt__focus_y();
close_cur();
select_bwd();
select_fwd();
move_bwd();
move_fwd();
close_others();
close_to_bgn();
close_to_end();
close_undo();
pin_toggle();
select_by_idx_1();
select_by_idx_2();
select_by_idx_3();
select_by_idx_4();
select_by_idx_5();
select_by_idx_6();
select_by_idx_7();
select_by_idx_8();
select_by_idx_9();
}
html {
focus();
selection_focus_toggle();
load_tid; // [mem,url]
}
find {
show();
show_by_paste();
hide();
exec();
type();
find_bwd();
find_fwd();
case_toggle();
wrap_toggle();
}
prog {
focus();
show_short_link;
}
info {
focus();
clear();
launch();
warn_enabled;
note_enabled;
}
prog_log {
show();
}
}
font {
increase();
decrease();
reset();
}
page {
edit {
copy();
select_all();
save();
save_draft();
preview();
focus_edit_box();
dbg_tmpl();
dbg_html();
exec();
}
selection {
copy();
select_all();
save_file_as();
}
view {
mode_read();
mode_edit();
mode_html();
reload();
refresh();
print();
save_as();
}
}
}
html {
}
net {
}
usr {
}
special {
}
xtns {
}
bldr {
wikis {
filters {
dansguardians {
}
}
imports {
one_file = 'y';
schema_is_1 = 'y';
text_zip_tid = '.gz';
html_zip_tid = '.gz';
}
}
}
}
*/

View File

@@ -0,0 +1,81 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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 GfoInvkAble {
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);
net_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) {
Io_url img_dir = app.Fsys_mgr().Bin_xowa_file_dir().GenSubDir_nest("app.general");
html_api.Page().Toggle_mgr().Img_dir_(img_dir);
usr_api.Init_by_app(app);
}
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_net Net() {return net_api;} private final Xoapi_net net_api = new Xoapi_net();
public Xoapi_usr Usr() {return usr_api;} private final Xoapi_usr usr_api = new Xoapi_usr();
public Xoapi_special Special() {return special_api;} private final Xoapi_special special_api = new Xoapi_special();
public Xoapi_xtns Xtns() {return xtns_api;} private final Xoapi_xtns xtns_api = new Xoapi_xtns();
public Xoapi_app_wikis Wikis() {return app_wikis;} private final Xoapi_app_wikis app_wikis = new Xoapi_app_wikis();
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_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_net)) return net_api;
else if (ctx.Match(k, Invk_usr)) return usr_api;
else if (ctx.Match(k, Invk_special)) return special_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_wikis)) return app_wikis;
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_app = "app", Invk_bldr = "bldr", Invk_nav = "nav", Invk_gui = "gui", Invk_html = "html", Invk_net = "net", Invk_usr = "usr", Invk_special = "special", Invk_xtns = "xtns"
, Invk_test_str = "test_str", Invk_test_str_ = "test_str_"
, Invk_wikis = "wikis"
;
}

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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.*; import gplx.xowa.apps.apis.xowa.envs.*; import gplx.xowa.apps.apis.xowa.startups.*;
public class Xoapi_app implements GfoInvkAble {
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 Xoapi_env Env() {return env;} private Xoapi_env env = new Xoapi_env();
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
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 if (ctx.Match(k, Invk_startup)) return startup;
else if (ctx.Match(k, Invk_env)) return env;
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_exit = "exit", Invk_startup = "startup", Invk_env = "env", Invk_fsys = "fsys";
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
import gplx.xowa.apps.apis.xowa.wikis.*;
public class Xoapi_app_wiki implements GfoInvkAble {
public Xoapi_wiki_lang Lang() {return lang;} private final Xoapi_wiki_lang lang = new Xoapi_wiki_lang();
public void Subscribe(GfoEvObj sub) {lang.Subscribe(sub);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_lang)) return lang;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_lang = "lang";
public static final Xoapi_app_wiki Dflt = new Xoapi_app_wiki();
}

View 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.*;
public class Xoapi_app_wikis implements GfoInvkAble {
private final Ordered_hash hash = Ordered_hash_.New_bry();
public Xoapi_app_wiki Get(byte[] domain) {
Xoapi_app_wiki rv = (Xoapi_app_wiki)hash.Get_by(domain);
if (rv == null) {
rv = new Xoapi_app_wiki();
hash.Add(domain, rv);
}
return rv;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_get = "get";
}

View 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 GfoInvkAble {
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 GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_wiki = "wiki";
}

View 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 GfoInvkAble {
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";
}

View 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.apps.apis.xowa.html.*;
public class Xoapi_html implements GfoInvkAble {
public void Ctor_by_app(Xoae_app app) {
page.Ctor_by_app(app);
}
public void Init_by_kit(Xoae_app app) {
tidy.Init_by_kit(app);
modules.Init_by_kit(app);
}
public Xoapi_tidy Tidy() {return tidy;} private final Xoapi_tidy tidy = new Xoapi_tidy();
public Xoapi_modules Modules() {return modules;} private final Xoapi_modules modules = new Xoapi_modules();
public Xoapi_skins Skins() {return skins;} private final Xoapi_skins skins = new Xoapi_skins();
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_tidy)) return tidy;
else if (ctx.Match(k, Invk_modules)) return modules;
else if (ctx.Match(k, Invk_skins)) return skins;
else if (ctx.Match(k, Invk_page)) return page;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_tidy = "tidy", Invk_modules = "modules", Invk_skins = "skins", Invk_page = "page";
}

View 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 GfoInvkAble {
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_wiki Wiki() {return wiki;} private Xoapi_wiki wiki = new Xoapi_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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_go_bwd = "go_bwd", Invk_go_fwd = "go_fwd", Invk_goto = "goto", Invk_wiki = "wiki";
}

View File

@@ -0,0 +1,42 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
public class Xoapi_net implements GfoInvkAble, GfoEvObj {
public Xoapi_net() {this.ev_mgr = GfoEvMgr.new_(this);}
public GfoEvMgr EvMgr() {return ev_mgr;} private GfoEvMgr ev_mgr;
public void Init_by_kit(Xoae_app app) {
}
public boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {
this.enabled = v;
gplx.ios.IoEngine_system.Web_access_enabled = v;
GfoEvMgr_.PubVal(this, gplx.xowa.guis.menus.dom.Xog_mnu_evt_mgr.Evt_selected_changed, v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return this.Enabled();
else if (ctx.Match(k, Invk_enabled_n_)) this.Enabled_(Bool_.N);
else if (ctx.Match(k, Invk_enabled_y_)) this.Enabled_(Bool_.Y);
else if (ctx.Match(k, Invk_enabled_x_)) this.Enabled_(this.Enabled());
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_n_ = "enabled_n_", Invk_enabled_y_ = "enabled_y_", Invk_enabled_x_ = "enabled_x_"
;
public static final String Evt_enabled_changed = "enabled_changed";
}

View File

@@ -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; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*;
import gplx.xowa.apps.apis.xowa.specials.*;
public class Xoapi_special implements GfoInvkAble {
public void Ctor_by_app(Xoae_app app) {
}
public void Init_by_kit(Xoae_app app) {
}
public Xoapi_search Search() {return search;} private Xoapi_search search = new Xoapi_search();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_search)) return search;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_search = "search";
}

View File

@@ -0,0 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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 GfoInvkAble {
public void Ctor_by_app(Xoae_app app) {
bookmarks.Ctor_by_app(app);
history.Ctor_by_app(app);
logs.Ctor_by_app(app);
}
public void Init_by_app(Xoa_app app) {
cache.Init_by_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 Xoapi_logs Logs() {return logs;} private final Xoapi_logs logs = new Xoapi_logs();
public Xoapi_cache Cache() {return cache;} private final Xoapi_cache cache = new Xoapi_cache();
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 if (ctx.Match(k, Invk_logs)) return logs;
else if (ctx.Match(k, Invk_cache)) return cache;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_bookmarks = "bookmarks", Invk_history = "history", Invk_logs = "logs", Invk_cache = "cache";
}

View File

@@ -0,0 +1,35 @@
/*
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 GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
scribunto.Init_by_kit(app);
}
public Xoapi_scribunto Scribunto() {return scribunto;} private final Xoapi_scribunto scribunto = new Xoapi_scribunto();
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_scribunto)) return scribunto;
else if (ctx.Match(k, Invk_wikibase)) return wikibase;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String
Invk_scribunto = "scribunto"
, Invk_wikibase = "wikibase"
;
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.apps; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
public class Xoapi_fsys implements GfoInvkAble {
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 GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_plat_jar = "plat_jar", Invk_plat_url = "plat_url";
}

View File

@@ -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.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.*;
public class Xoapi_bldr_wiki implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {filter.Ctor_by_app(app);}
public Xoapi_filter Filter() {return filter;} private final Xoapi_filter filter = new Xoapi_filter();
public Xoapi_import Import() {return import_api;} private final Xoapi_import import_api = new Xoapi_import();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_filter)) return filter;
else if (ctx.Match(k, Invk_import)) return import_api;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_filter = "filter", Invk_import = "import";
}

View 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.bldrs.filters; 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.dansguardians.*;
public class Xoapi_filter implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {dansguardian.Ctor_by_app(app);}
public Xoapi_dansguardian Dansguardian() {return dansguardian;} private final Xoapi_dansguardian dansguardian = new Xoapi_dansguardian();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_dansguardian)) return dansguardian;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_dansguardian = "dansguardian";
}

View File

@@ -0,0 +1,76 @@
/*
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.dansguardians; 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.*;
import gplx.ios.*; import gplx.xowa.bldrs.filters.dansguardians.*;
public class Xoapi_dansguardian implements GfoInvkAble {
public void Ctor_by_app(Xoa_app app) {
root_dir = app.Fsys_mgr().Bin_xowa_dir().GenSubDir_nest("cfg", "bldr", "filter");
}
public boolean Enabled() {return enabled;} private boolean enabled = Bool_.N;
public Io_url Root_dir() {return root_dir;} private Io_url root_dir;
public int Score_init() {return score_init;} private int score_init = 0;
public int Score_fail() {return score_fail;} private int score_fail = 0;
public boolean Case_match() {return case_match;} private boolean case_match = Bool_.N;
public boolean Wildcard_enabled() {return wildcard_enabled;} private boolean wildcard_enabled = Bool_.N;
public byte[] Wildcard_char() {return wildcard_char;} private byte[] wildcard_char = Byte_ascii.Space_bry;
public byte[][] Wildcard_list() {return wildcard_list;} private byte[][] wildcard_list = Bry_.Ary(Byte_ascii.Space_bry);// \s,.!?:;'"-() /@#$%^&*()[]{}<>_+=|\~`
public int Target_tid() {return target_tid;} private int target_tid = Dg_match_mgr.Target_tid_wikitext;
public boolean Log_enabled() {return log_enabled;} private boolean log_enabled = Bool_.Y;
public Dg_match_mgr New_mgr(String domain_str, Io_url wiki_root_dir) {
if (!enabled) return null;
Io_url log_url = wiki_root_dir.GenSubFil("dansguardian_log.sqlite3");
Dg_match_mgr rv = new Dg_match_mgr(root_dir.GenSubDir(domain_str), score_init, score_fail, case_match, log_enabled, log_url);
return rv;
}
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_root_dir)) return root_dir.Raw();
else if (ctx.Match(k, Invk_root_dir_)) root_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_fail)) return Int_.To_str(score_fail);
else if (ctx.Match(k, Invk_score_fail_)) score_fail = m.ReadInt("v");
else if (ctx.Match(k, Invk_case_match)) return Yn.To_str(case_match);
else if (ctx.Match(k, Invk_case_match_)) case_match = m.ReadYn("v");
else if (ctx.Match(k, Invk_wildcard_enabled)) return Yn.To_str(wildcard_enabled);
else if (ctx.Match(k, Invk_wildcard_enabled_)) wildcard_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_wildcard_char)) return String_.new_u8(wildcard_char);
else if (ctx.Match(k, Invk_wildcard_char_)) wildcard_char = m.ReadBry("v");
else if (ctx.Match(k, Invk_wildcard_list)) return "";
else if (ctx.Match(k, Invk_wildcard_list_)) {}
else if (ctx.Match(k, Invk_target_tid)) return Int_.To_str(target_tid);
else if (ctx.Match(k, Invk_target_tid_)) target_tid = m.ReadInt("v");
else if (ctx.Match(k, Invk_log_enabled)) return Yn.To_str(log_enabled);
else if (ctx.Match(k, Invk_log_enabled_)) log_enabled = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled" , Invk_enabled_ = "enabled_"
, Invk_root_dir = "root_dir" , Invk_root_dir_ = "root_dir_"
, Invk_score_init = "score_init" , Invk_score_init_ = "score_init_"
, Invk_score_fail = "score_fail" , Invk_score_fail_ = "score_fail_"
, Invk_case_match = "case_match" , Invk_case_match_ = "case_match_"
, Invk_wildcard_enabled = "wildcard_enabled" , Invk_wildcard_enabled_ = "wildcard_enabled_"
, Invk_wildcard_char = "wildcard_char" , Invk_wildcard_char_ = "wildcard_char_"
, Invk_wildcard_list = "wildcard_list" , Invk_wildcard_list_ = "wildcard_list_"
, Invk_target_tid = "target_tid" , Invk_target_tid_ = "target_tid_"
, Invk_log_enabled = "log_enabled" , Invk_log_enabled_ = "log_enabled_"
;
}

View File

@@ -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 GfoInvkAble {
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 GfoInvkAble_.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_"
;
}

View File

@@ -0,0 +1,93 @@
/*
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.ios.*; import gplx.xowa.wikis.data.*;
public class Xoapi_import implements GfoInvkAble {
public long Layout_all_max() {return layout_all_max;} private long layout_all_max = 0; // disable by default; may set to 200 MB in future
public long Layout_text_max() {return layout_text_max;} private long layout_text_max = Io_size_.To_long_by_int_mb(1500); // 1.5 GB
public long Layout_html_max() {return layout_html_max;} private long layout_html_max = Io_size_.To_long_by_int_mb(1500); // 1.5 GB
public long Layout_file_max() {return layout_file_max;} private long layout_file_max = Io_size_.To_long_by_int_mb(1500); // 1.5 GB
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 long Text_db_max() {return text_db_max;} private long text_db_max = Io_size_.To_long_by_int_mb(1500); // 3.0 GB; v1
public long Html_db_max() {return html_db_max;} private long html_db_max = Io_size_.To_long_by_int_mb(1500); // 3.0 GB; v2; use same as text
public long File_db_max() {return file_db_max;} private long file_db_max = Io_size_.To_long_by_int_mb(1500); // 3.2 GB; v2
public byte[] Ns_file_map() {return ns_file_map;} private byte[] ns_file_map = Ns_file_map__each;
public byte Zip_tid_text() {return zip_tid_text;} private byte zip_tid_text = Io_stream_.Tid_gzip;
public byte Zip_tid_html() {return zip_tid_html;} private byte zip_tid_html = Io_stream_.Tid_gzip;
public String User_name() {return user_name;} private String user_name = "anonymous";
public Xowd_core_db_props New_props(String domain_str, long dump_file_size) {
Xowd_db_layout layout_text, layout_html, layout_file;
if (dump_file_size < layout_all_max)
layout_text = layout_html = layout_file = Xowd_db_layout.Itm_all;
else {
layout_text = dump_file_size < layout_text_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
layout_html = dump_file_size < layout_html_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
layout_file = dump_file_size < layout_file_max ? Xowd_db_layout.Itm_few : Xowd_db_layout.Itm_lot;
}
return new Xowd_core_db_props(2, layout_text, layout_html, layout_file, zip_tid_text, zip_tid_html);
}
public byte[] New_ns_file_map(long dump_file_size) {
return dump_file_size < layout_text_max ? Bry_.Empty : Ns_file_map__each;
}
public void Zip_tid_text_raw_() {zip_tid_text = Io_stream_.Tid_raw;} // TEST:
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_layout_all_max)) return Io_size_.To_str_mb(layout_all_max);
else if (ctx.Match(k, Invk_layout_all_max_)) layout_all_max = Io_size_.To_long_by_msg_mb(m, layout_all_max);
else if (ctx.Match(k, Invk_layout_text_max)) return Io_size_.To_str_mb(layout_text_max);
else if (ctx.Match(k, Invk_layout_text_max_)) layout_text_max = Io_size_.To_long_by_msg_mb(m, layout_text_max);
else if (ctx.Match(k, Invk_layout_html_max)) return Io_size_.To_str_mb(layout_html_max);
else if (ctx.Match(k, Invk_layout_html_max_)) layout_html_max = Io_size_.To_long_by_msg_mb(m, layout_html_max);
else if (ctx.Match(k, Invk_layout_file_max)) return Io_size_.To_str_mb(layout_file_max);
else if (ctx.Match(k, Invk_layout_file_max_)) layout_file_max = Io_size_.To_long_by_msg_mb(m, layout_file_max);
else 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_text_db_max)) return Io_size_.To_str_mb(text_db_max);
else if (ctx.Match(k, Invk_text_db_max_)) text_db_max = Io_size_.To_long_by_msg_mb(m, text_db_max);
else if (ctx.Match(k, Invk_html_db_max)) return Io_size_.To_str_mb(html_db_max);
else if (ctx.Match(k, Invk_html_db_max_)) html_db_max = Io_size_.To_long_by_msg_mb(m, html_db_max);
else if (ctx.Match(k, Invk_file_db_max)) return Io_size_.To_str_mb(file_db_max);
else if (ctx.Match(k, Invk_file_db_max_)) file_db_max = Io_size_.To_long_by_msg_mb(m, file_db_max);
else if (ctx.Match(k, Invk_ns_file_map)) return String_.new_u8(ns_file_map);
else if (ctx.Match(k, Invk_ns_file_map_)) ns_file_map = m.ReadBry("v");
else if (ctx.Match(k, Invk_zip_tid_text)) return Io_stream_.To_str(zip_tid_text);
else if (ctx.Match(k, Invk_zip_tid_text_)) zip_tid_text = Io_stream_.To_tid(m.ReadStr("v"));
else if (ctx.Match(k, Invk_zip_tid_list)) return Options_zip_tid__list;
else if (ctx.Match(k, Invk_zip_tid_html)) return Io_stream_.To_str(zip_tid_html);
else if (ctx.Match(k, Invk_zip_tid_html_)) zip_tid_html = Io_stream_.To_tid(m.ReadStr("v"));
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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static KeyVal[] Options_zip_tid__list = KeyVal_.Ary(KeyVal_.new_("raw", "text"), KeyVal_.new_("gzip"), KeyVal_.new_("bzip2"));
private static final String
Invk_layout_all_max = "layout_all_max" , Invk_layout_all_max_ = "layout_all_max_"
, Invk_layout_text_max = "layout_text_max" , Invk_layout_text_max_ = "layout_text_max_"
, Invk_layout_html_max = "layout_html_max" , Invk_layout_html_max_ = "layout_html_max_"
, Invk_layout_file_max = "layout_file_max" , Invk_layout_file_max_ = "layout_file_max_"
, Invk_cat_link_db_max = "cat_link_db_max" , Invk_cat_link_db_max_ = "cat_link_db_max_"
, Invk_text_db_max = "text_db_max" , Invk_text_db_max_ = "text_db_max_"
, Invk_html_db_max = "html_db_max" , Invk_html_db_max_ = "html_db_max_"
, Invk_file_db_max = "file_db_max" , Invk_file_db_max_ = "file_db_max_"
, Invk_ns_file_map = "ns_file_map" , Invk_ns_file_map_ = "ns_file_map_"
, Invk_zip_tid_text = "zip_tid_text" , Invk_zip_tid_text_ = "zip_tid_text_", Invk_zip_tid_list = "zip_tid_list"
, Invk_zip_tid_html = "zip_tid_html" , Invk_zip_tid_html_ = "zip_tid_html_"
, Invk_user_name = "user_name" , Invk_user_name_ = "user_name_"
;
public static final byte[] Ns_file_map__each = Bry_.new_a7("<each>");
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.envs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
public class Xoapi_env implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {}
public String Version_previous() {return version_previous;} private String version_previous = "";
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_version_previous)) return version_previous;
else if (ctx.Match(k, Invk_version_previous_)) version_previous = m.ReadStr("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_version_previous = "version_previous", Invk_version_previous_ = "version_previous_";
}

View 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 GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
url.Init_by_kit(app);
search.Init_by_kit(app);
tabs.Init_by_kit(app);
html.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_search Search() {return search;} private Xoapi_search search = new Xoapi_search();
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_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_search)) return search;
else if (ctx.Match(k, Invk_tabs)) return tabs;
else if (ctx.Match(k, Invk_html)) return html;
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 GfoInvkAble_.Rv_unhandled;
}
private static final String
Invk_url = "url", Invk_search = "search", Invk_tabs = "tabs", Invk_html = "html"
, Invk_find = "find", Invk_prog = "prog", Invk_info = "info", Invk_prog_log = "prog_log";
}

View File

@@ -0,0 +1,55 @@
/*
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.gui.*; import gplx.xowa.htmls.*;
public class Xoapi_font implements GfoInvkAble {
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);}
private 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.Html_mgr().Page_mgr().Font_enabled_(enabled);
app.Html_mgr().Page_mgr().Font_size_(html_font_size);
app.Cfg_mgr().Set_by_app("app.html.page.font_enabled", "y");
app.Cfg_mgr().Set_by_app("app.html.page.font_size", Float_.To_str(app.Html_mgr().Page_mgr().Font_size()));
app.Gui_mgr().Win_cfg().Font().Size_(gui_font_size);
app.Cfg_mgr().Set_by_app("app.gui.win_opts.font.size", Float_.To_str(gui_font_size));
app.Cfg_mgr().Db_save_txt();
app.Gui_mgr().Browser_win().Page__reload(); // NOTE: force reload; needed if viewing Help: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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_increase = "increase", Invk_decrease = "decrease", Invk_reset = "reset"
;
}

View 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 GfoInvkAble {
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 GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_view = "view", Invk_selection = "selection", Invk_edit = "edit";
}

View File

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

View 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.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.wikis.pages.*; import gplx.xowa.guis.*; import gplx.xowa.guis.views.*;
public class Xoapi_html_box implements GfoInvkAble, GfoEvMgrOwner {
private Xog_win_itm win;
public Xoapi_html_box() {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public void Init_by_kit(Xoae_app app) {this.win = app.Gui_mgr().Browser_win();}
public byte Load_tid() {return load_tid;} private byte load_tid;
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 if (ctx.Match(k, Invk_load_tid)) return Gxw_html_load_tid_.Xto_key(load_tid);
else if (ctx.Match(k, Invk_load_tid_)) {load_tid = Gxw_html_load_tid_.Xto_tid(m.ReadStr("v")); GfoEvMgr_.PubVal(this, Evt_load_tid_changed, load_tid);}
else if (ctx.Match(k, Invk_load_tid_list)) return Gxw_html_load_tid_.Options__list;
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus", Invk_selection_focus_toggle = "selection_focus_toggle"
, Invk_load_tid = "load_tid", Invk_load_tid_ = "load_tid_", Invk_load_tid_list = "load_tid_list"
;
public static final String Evt_load_tid_changed = "load_tid_changed";
}

View File

@@ -0,0 +1,46 @@
/*
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_usr_dlg__gui__opt, GfoInvkAble {
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
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 boolean Warn_enabled() {return warn_enabled;} private boolean warn_enabled;
public boolean Note_enabled() {return note_enabled;} private boolean note_enabled;
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 if (ctx.Match(k, Invk_warn_enabled)) return Yn.To_str(warn_enabled);
else if (ctx.Match(k, Invk_warn_enabled_)) warn_enabled = m.ReadYn("v");
else if (ctx.Match(k, Invk_note_enabled)) return Yn.To_str(note_enabled);
else if (ctx.Match(k, Invk_note_enabled_)) note_enabled = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus", Invk_clear = "clear", Invk_launch = "launch"
, Invk_warn_enabled = "warn_enabled", Invk_warn_enabled_ = "warn_enabled_"
, Invk_note_enabled = "note_enabled", Invk_note_enabled_ = "note_enabled_"
;
}

View 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.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 GfoInvkAble {
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private Xog_win_itm Win() {return app.Gui_mgr().Browser_win();}
public boolean Show_short_url() {return show_short_url;} private boolean show_short_url;
public void Focus() {this.Win().Prog_box().Focus();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_focus)) this.Focus();
else if (ctx.Match(k, Invk_show_short_url)) return Yn.To_str(show_short_url);
else if (ctx.Match(k, Invk_show_short_url_)) show_short_url = m.ReadBool("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus", Invk_show_short_url = "show_short_url", Invk_show_short_url_ = "show_short_url_";
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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 GfoInvkAble {
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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_show = "show";
}

View 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.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_search implements GfoInvkAble {
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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_focus = "focus";
public static final String Invk_exec = "exec";
}

View File

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

View File

@@ -0,0 +1,62 @@
/*
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_url implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {this.app = app;} private Xoae_app app;
private GfuiTextBox Url_box() {return app.Gui_mgr().Browser_win().Url_box();}
public void Focus() {this.Url_box().Focus_select_all();}
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());
}
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) {
String url = urls[0];
this.Url_box().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 return GfoInvkAble_.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";
public static final String Invk_exec = "exec";
}

View File

@@ -0,0 +1,57 @@
/*
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.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*;
public class Xoapi_edit implements GfoInvkAble {
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; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.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 GfoInvkAble_.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"
;
}

View File

@@ -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.xowa.guis.*; import gplx.xowa.guis.views.*;
public class Xoapi_selection implements GfoInvkAble {
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; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.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_.http_any_(src, Op_sys.Cur().Tid_is_wnt());
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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_copy = "copy", Invk_select_all = "select_all", Invk_save_file_as = "save_file_as"
;
}

View File

@@ -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.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.xowa.guis.*; import gplx.xowa.guis.views.*; import gplx.xowa.wikis.pages.*;
public class Xoapi_view implements GfoInvkAble {
private Xoae_app app; private Xog_win_itm win;
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 = Xoa_app_.Utl__encoder_mgr().Fsys_safe().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 GfoInvkAble_.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"
;
}

View 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.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 GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
popups.Init_by_app(app);
}
public Xoapi_collapsible Collapsible() {return collapsible;} private Xoapi_collapsible collapsible = new Xoapi_collapsible();
public Xoapi_navframe Navframe() {return navframe;} private Xoapi_navframe navframe = new Xoapi_navframe();
public Xoapi_toc Toc() {return toc;} private Xoapi_toc toc = new Xoapi_toc();
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_collapsible)) return collapsible;
else if (ctx.Match(k, Invk_navframe)) return navframe;
else if (ctx.Match(k, Invk_toc)) return toc;
else if (ctx.Match(k, Invk_popups)) return popups;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_collapsible = "collapsible", Invk_navframe = "navframe", Invk_toc = "toc", Invk_popups = "popups";
}

View 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.*;
import gplx.core.btries.*;
public class Xoapi_page implements GfoInvkAble {
public void Ctor_by_app(Xoae_app app) {
toggle_mgr.Ctor_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 GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_toggles = "toggles";
}

View File

@@ -0,0 +1,35 @@
/*
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.skins.*;
public class Xoapi_skins implements GfoInvkAble {
private Hash_adp hash = Hash_adp_.new_();
public Xoapi_skins() {
server.Sidebar_home_enabled_(true);
hash.Add("desktop", desktop);
hash.Add("server", server);
}
public Xoapi_skin_app_base Desktop() {return desktop;} private Xoapi_skin_app_base desktop = new Xoapi_skin_app_base();
public Xoapi_skin_app_base Server () {return server ;} private Xoapi_skin_app_base server = new Xoapi_skin_app_base();
private GfoInvkAble Get(String key) {return (GfoInvkAble)hash.Get_by(key);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get(m.ReadStr("v"));
return this;
}
private static final String Invk_get = "get";
}

View 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.html; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.xowa.htmls.tidy.*;
public class Xoapi_tidy implements GfoInvkAble {
private Xoae_app app;
public void Init_by_kit(Xoae_app app) {
this.app = app;
}
public void Toggle() {
app.Html_mgr().Tidy_mgr().Enabled_toggle();
app.Gui_mgr().Browser_win().Page__refresh();
}
public void Engine_(byte v) {
app.Html_mgr().Tidy_mgr().Wkr_tid_(v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_toggle)) this.Toggle();
else if (ctx.Match(k, Invk_engine_tidy_)) Engine_(Xoh_tidy_wkr_.Tid_tidy);
else if (ctx.Match(k, Invk_engine_jtidy_)) Engine_(Xoh_tidy_wkr_.Tid_jtidy);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_toggle = "toggle", Invk_engine_tidy_ = "engine_tidy_", Invk_engine_jtidy_ = "engine_jtidy_";
}

View File

@@ -0,0 +1,93 @@
/*
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_toggle_itm implements GfoInvkAble {
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 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_(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)
;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_visible)) return Yn.To_str(visible);
else if (ctx.Match(k, Invk_visible_)) this.visible = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_visible = "visible", Invk_visible_ = "visible_";
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;")
;
}

View File

@@ -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.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 GfoInvkAble {
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 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 void Img_dir_(Io_url v) {
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(v);
}
}
public void Save(Xoa_cfg_mgr cfg_mgr) {
int len = hash.Count();
for (int i = 0; i < len; ++i) {
Xoapi_toggle_itm itm = (Xoapi_toggle_itm)hash.Get_at(i);
cfg_mgr.Set_by_app("xowa.api.html.page.toggles.get('" + String_.new_u8(itm.Key_bry()) + "').visible", Yn.To_str(itm.Visible()));
}
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return this.Get_or_new(m.ReadStr("key"));
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_get = "get";
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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.*;
public class Xoapi_collapsible implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsed)) return Yn.To_str(collapsed);
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_collapsed = "collapsed", Invk_collapsed_ = "collapsed_"
;
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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.*;
public class Xoapi_navframe implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsed)) return Yn.To_str(collapsed);
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_collapsed = "collapsed", Invk_collapsed_ = "collapsed_"
;
}

View File

@@ -0,0 +1,242 @@
/*
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 GfoInvkAble, GfoEvMgrOwner {
private Xoae_app app;
public Xoapi_popups() {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public void Init_by_app(Xoae_app app) {this.app = app;}
public boolean Enabled() {return enabled;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled = true;
public int Show_init_word_count() {return show_init_word_count;} private int show_init_word_count = Dflt_show_init_word_count;
public int Show_more_word_count() {return show_more_word_count;} private int show_more_word_count = Dflt_show_more_word_count;
public int Show_all_if_less_than() {return show_all_if_less_than;} private int show_all_if_less_than = Dflt_show_all_if_less_than;
public int Win_show_delay() {return win_show_delay;} private int win_show_delay = Dflt_win_show_delay;
public int Win_hide_delay() {return win_hide_delay;} private int win_hide_delay = Dflt_win_hide_delay;
public int Win_max_w() {return win_max_w;} private int win_max_w = Dflt_win_max_w;
public int Win_max_h() {return win_max_h;} private int win_max_h = Dflt_win_max_h;
public int Win_show_all_max_w() {return win_show_all_max_w;} private int win_show_all_max_w = Dflt_win_show_all_max_w;
public boolean Win_bind_focus_blur() {return win_bind_focus_blur;} private boolean win_bind_focus_blur = Dflt_win_bind_focus_blur;
public byte[] Xnde_ignore_ids() {return xnde_ignore_ids;} private byte[] xnde_ignore_ids = Dflt_xnde_ignore_ids;
public int Scan_len() {return scan_len;} private int scan_len = Dflt_scan_len;
public int Scan_max() {return scan_max;} private int scan_max = Dflt_scan_max;
public byte[] Ns_allowed() {return ns_allowed;} private byte[] ns_allowed = Dflt_ns_allowed;
public int Read_til_stop_fwd() {return read_til_stop_fwd;} private int read_til_stop_fwd = Dflt_read_til_stop_fwd;
public int Read_til_stop_bwd() {return read_til_stop_bwd;} private int read_til_stop_bwd = Dflt_read_til_stop_bwd;
public int Stop_if_hdr_after() {return stop_if_hdr_after;} private int stop_if_hdr_after = Dflt_stop_if_hdr_after;
public int Tmpl_tkn_max() {return tmpl_tkn_max;} private int tmpl_tkn_max = Dflt_tmpl_tkn_max;
public byte[] Tmpl_keeplist() {return tmpl_keeplist;} private byte[] tmpl_keeplist = Dflt_tmpl_keeplist;
public byte[] Html_fmtr_popup() {return html_fmtr_popup;} private byte[] html_fmtr_popup = Dflt_html_fmtr_popup;
public byte[] Html_fmtr_popup_dflt() {return html_fmtr_popup_dflt;} private byte[] html_fmtr_popup_dflt = Dflt_html_fmtr_popup;
public byte[] Html_fmtr_viewed() {return html_fmtr_viewed;} private byte[] html_fmtr_viewed = Dflt_html_fmtr_viewed;
public byte[] Html_fmtr_viewed_dflt() {return html_fmtr_viewed_dflt;} private byte[] html_fmtr_viewed_dflt = Dflt_html_fmtr_viewed;
public byte[] Html_fmtr_wiki() {return html_fmtr_wiki;} private byte[] html_fmtr_wiki = Dflt_html_fmtr_wiki;
public byte[] Html_fmtr_wiki_dflt() {return html_fmtr_wiki_dflt;} private byte[] html_fmtr_wiki_dflt = Dflt_html_fmtr_wiki;
public byte[] Html_fmtr_next_sect_fmt() {return html_fmtr_next_sect;} private byte[] html_fmtr_next_sect = Dflt_html_fmtr_next_sect;
public byte[] Html_fmtr_next_sect_fmt_dflt() {return html_fmtr_next_sect_dflt;} private byte[] html_fmtr_next_sect_dflt = Dflt_html_fmtr_next_sect;
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_enabled)) return Yn.To_str(enabled);
else if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
else 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 if (ctx.Match(k, Invk_show_init_word_count)) return show_init_word_count;
else if (ctx.Match(k, Invk_show_init_word_count_)) {show_init_word_count = Set_int_gt_0(m, show_init_word_count, Evt_show_init_word_count_changed);}
else if (ctx.Match(k, Invk_show_more_word_count)) return show_more_word_count;
else if (ctx.Match(k, Invk_show_more_word_count_)) {show_more_word_count = Set_int_gt_0(m, show_more_word_count, Evt_show_more_word_count_changed);}
else if (ctx.Match(k, Invk_show_all_if_less_than)) return show_all_if_less_than;
else if (ctx.Match(k, Invk_show_all_if_less_than_)) {show_all_if_less_than = Set_int(m, show_all_if_less_than, Evt_show_all_if_less_than_changed);}
else if (ctx.Match(k, Invk_win_show_delay)) return win_show_delay;
else if (ctx.Match(k, Invk_win_show_delay_)) {win_show_delay = Set_int(m, win_show_delay, Evt_win_show_delay_changed);}
else if (ctx.Match(k, Invk_win_hide_delay)) return win_hide_delay;
else if (ctx.Match(k, Invk_win_hide_delay_)) {win_hide_delay = Set_int(m, win_hide_delay, Evt_win_hide_delay_changed);}
else if (ctx.Match(k, Invk_win_max_w)) return win_max_w;
else if (ctx.Match(k, Invk_win_max_w_)) {win_max_w = Set_int(m, win_max_w, Evt_win_max_w_changed);}
else if (ctx.Match(k, Invk_win_max_h)) return win_max_h;
else if (ctx.Match(k, Invk_win_max_h_)) {win_max_h = Set_int(m, win_max_h, Evt_win_max_h_changed);}
else if (ctx.Match(k, Invk_win_show_all_max_w)) return win_show_all_max_w;
else if (ctx.Match(k, Invk_win_show_all_max_w_)) {win_show_all_max_w = m.ReadInt("v");}
else if (ctx.Match(k, Invk_win_bind_focus_blur)) return Yn.To_str(win_bind_focus_blur);
else if (ctx.Match(k, Invk_win_bind_focus_blur_)) win_bind_focus_blur = m.ReadYn("v");
else if (ctx.Match(k, Invk_xnde_ignore_ids)) return String_.new_u8(xnde_ignore_ids);
else if (ctx.Match(k, Invk_xnde_ignore_ids_)) {xnde_ignore_ids = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_xnde_ignore_ids_changed, xnde_ignore_ids);}
else if (ctx.Match(k, Invk_scan_len)) return scan_len;
else if (ctx.Match(k, Invk_scan_len_)) {scan_len = Set_int_gt_0(m, scan_len, Evt_scan_len_changed);}
else if (ctx.Match(k, Invk_scan_max)) return scan_max;
else if (ctx.Match(k, Invk_scan_max_)) {scan_max = Set_int_gt_0(m, scan_max, Evt_scan_max_changed);}
else if (ctx.Match(k, Invk_read_til_stop_fwd)) return read_til_stop_fwd;
else if (ctx.Match(k, Invk_read_til_stop_fwd_)) {read_til_stop_fwd = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_read_til_stop_fwd_changed, read_til_stop_fwd);}
else if (ctx.Match(k, Invk_read_til_stop_bwd)) return read_til_stop_bwd;
else if (ctx.Match(k, Invk_read_til_stop_bwd_)) {read_til_stop_bwd = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_read_til_stop_bwd_changed, read_til_stop_bwd);}
else if (ctx.Match(k, Invk_stop_if_hdr_after)) return stop_if_hdr_after;
else if (ctx.Match(k, Invk_stop_if_hdr_after_)) {stop_if_hdr_after = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_stop_if_hdr_after_changed, stop_if_hdr_after);}
else if (ctx.Match(k, Invk_ns_allowed)) return String_.new_u8(ns_allowed);
else if (ctx.Match(k, Invk_ns_allowed_)) {ns_allowed = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_ns_allowed_changed, ns_allowed);}
else if (ctx.Match(k, Invk_tmpl_tkn_max)) return tmpl_tkn_max;
else if (ctx.Match(k, Invk_tmpl_tkn_max_)) {tmpl_tkn_max = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_tmpl_tkn_max_changed, tmpl_tkn_max);}
else if (ctx.Match(k, Invk_tmpl_keeplist)) return String_.new_u8(tmpl_keeplist);
else if (ctx.Match(k, Invk_tmpl_keeplist_)) {tmpl_keeplist = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_tmpl_keeplist_changed, tmpl_keeplist);}
else if (ctx.Match(k, Invk_html_fmtr_popup)) return String_.new_u8(html_fmtr_popup);
else if (ctx.Match(k, Invk_html_fmtr_popup_)) {html_fmtr_popup = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_html_fmtr_popup_changed, html_fmtr_popup);}
else if (ctx.Match(k, Invk_html_fmtr_popup_dflt)) return String_.new_u8(html_fmtr_popup_dflt);
else if (ctx.Match(k, Invk_html_fmtr_popup_dflt_)) {html_fmtr_popup_dflt = m.ReadBry("v");}
else if (ctx.Match(k, Invk_html_fmtr_viewed)) return String_.new_u8(html_fmtr_viewed);
else if (ctx.Match(k, Invk_html_fmtr_viewed_)) {html_fmtr_viewed = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_html_fmtr_viewed_changed, html_fmtr_viewed);}
else if (ctx.Match(k, Invk_html_fmtr_viewed_dflt)) return String_.new_u8(html_fmtr_viewed_dflt);
else if (ctx.Match(k, Invk_html_fmtr_viewed_dflt_)) {html_fmtr_viewed_dflt = m.ReadBry("v");}
else if (ctx.Match(k, Invk_html_fmtr_wiki)) return String_.new_u8(html_fmtr_wiki);
else if (ctx.Match(k, Invk_html_fmtr_wiki_)) {html_fmtr_wiki = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_html_fmtr_wiki_changed, html_fmtr_wiki);}
else if (ctx.Match(k, Invk_html_fmtr_wiki_dflt)) return String_.new_u8(html_fmtr_wiki_dflt);
else if (ctx.Match(k, Invk_html_fmtr_wiki_dflt_)) {html_fmtr_wiki_dflt = m.ReadBry("v");}
else if (ctx.Match(k, Invk_html_fmtr_next_sect)) return String_.new_u8(html_fmtr_next_sect);
else if (ctx.Match(k, Invk_html_fmtr_next_sect_)) {html_fmtr_next_sect = m.ReadBry("v"); GfoEvMgr_.PubVal(this, Evt_html_fmtr_next_sect_changed, html_fmtr_next_sect);}
else if (ctx.Match(k, Invk_html_fmtr_next_sect_dflt)) return String_.new_u8(html_fmtr_next_sect_dflt);
else if (ctx.Match(k, Invk_html_fmtr_next_sect_dflt_)) {html_fmtr_next_sect_dflt = m.ReadBry("v");}
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private int Set_int_gt_0(GfoMsg m, int cur_val, String evt) {
int tmp = m.ReadInt("v");
if (tmp < 1) return cur_val;
GfoEvMgr_.PubVal(this, evt, tmp);
return tmp;
}
private int Set_int(GfoMsg m, int cur_val, String evt) {
int tmp = m.ReadInt("v");
GfoEvMgr_.PubVal(this, evt, tmp);
return tmp;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_ = "enabled_"
, Invk_show_init_word_count = "show_init_word_count", Invk_show_init_word_count_ = "show_init_word_count_"
, Invk_show_more_word_count = "show_more_word_count", Invk_show_more_word_count_ = "show_more_word_count_"
, Invk_show_all_if_less_than = "show_all_if_less_than", Invk_show_all_if_less_than_ = "show_all_if_less_than_"
, Invk_xnde_ignore_ids = "xnde_ignore_ids", Invk_xnde_ignore_ids_ = "xnde_ignore_ids_"
, Invk_scan_len = "scan_len", Invk_scan_len_ = "scan_len_"
, Invk_scan_max = "scan_max", Invk_scan_max_ = "scan_max_"
, Invk_show_more = "show_more", Invk_show_all = "show_all"
, Invk_html_fmtr_popup = "html_fmtr_popup" , Invk_html_fmtr_popup_ = "html_fmtr_popup"
, Invk_html_fmtr_viewed = "html_fmtr_viewed" , Invk_html_fmtr_viewed_ = "html_fmtr_viewed_"
, Invk_html_fmtr_wiki = "html_fmtr_wiki" , Invk_html_fmtr_wiki_ = "html_fmtr_wiki_"
, Invk_html_fmtr_next_sect = "html_fmtr_next_sect" , Invk_html_fmtr_next_sect_ = "html_fmtr_next_sect_"
, Invk_html_fmtr_popup_dflt = "html_fmtr_popup_dflt" , Invk_html_fmtr_popup_dflt_ = "html_fmtr_popup_dflt_"
, Invk_html_fmtr_viewed_dflt = "html_fmtr_viewed_dflt" , Invk_html_fmtr_viewed_dflt_ = "html_fmtr_viewed_dflt_"
, Invk_html_fmtr_wiki_dflt = "html_fmtr_wiki_dflt" , Invk_html_fmtr_wiki_dflt_ = "html_fmtr_wiki_dflt_"
, Invk_html_fmtr_next_sect_dflt = "html_fmtr_next_sect_dflt" , Invk_html_fmtr_next_sect_dflt_ = "html_fmtr_next_sect_dflt_"
, Invk_win_show_delay = "win_show_delay", Invk_win_show_delay_ = "win_show_delay_"
, Invk_win_hide_delay = "win_hide_delay", Invk_win_hide_delay_ = "win_hide_delay_"
, Invk_win_bind_focus_blur = "win_bind_focus_blur", Invk_win_bind_focus_blur_ = "win_bind_focus_blur_"
, Invk_win_max_w = "win_max_w", Invk_win_max_w_ = "win_max_w_"
, Invk_win_max_h = "win_max_h", Invk_win_max_h_ = "win_max_h_"
, Invk_win_show_all_max_w = "win_show_all_max_w", Invk_win_show_all_max_w_ = "win_show_all_max_w_"
, Invk_read_til_stop_fwd = "read_til_stop_fwd", Invk_read_til_stop_fwd_ = "read_til_stop_fwd_"
, Invk_read_til_stop_bwd = "read_til_stop_bwd", Invk_read_til_stop_bwd_ = "read_til_stop_bwd_"
, Invk_stop_if_hdr_after = "stop_if_hdr_after", Invk_stop_if_hdr_after_ = "stop_if_hdr_after_"
, Invk_ns_allowed = "ns_allowed", Invk_ns_allowed_ = "ns_allowed_"
, Invk_tmpl_tkn_max = "tmpl_tkn_max", Invk_tmpl_tkn_max_ = "tmpl_tkn_max_"
, Invk_tmpl_keeplist = "tmpl_keeplist", Invk_tmpl_keeplist_ = "tmpl_keeplist_"
;
public static final String
Evt_show_init_word_count_changed = "show_init_word_count_changed"
, Evt_show_more_word_count_changed = "show_more_word_count_changed"
, Evt_show_all_if_less_than_changed = "show_all_if_less_than_changed"
, Evt_win_show_delay_changed = "win_show_delay_changed"
, Evt_win_hide_delay_changed = "win_hide_delay_changed"
, Evt_win_max_w_changed = "win_max_w_changed"
, Evt_win_max_h_changed = "win_max_h_changed"
, Evt_xnde_ignore_ids_changed = "xnde_ignore_ids_changed"
, Evt_scan_len_changed = "scan_len_changed"
, Evt_scan_max_changed = "scan_max_changed"
, Evt_read_til_stop_fwd_changed = "read_til_stop_fwd_changed"
, Evt_read_til_stop_bwd_changed = "read_til_stop_bwd_changed"
, Evt_stop_if_hdr_after_changed = "stop_if_hdr_after_changed"
, Evt_ns_allowed_changed = "ns_allowed_changed"
, Evt_tmpl_tkn_max_changed = "tmpl_tkn_max_changed"
, Evt_tmpl_keeplist_changed = "tmpl_keeplist"
, Evt_html_fmtr_popup_changed = "html_fmtr_popup_changed"
, Evt_html_fmtr_viewed_changed = "html_fmtr_viewed_changed"
, Evt_html_fmtr_wiki_changed = "html_fmtr_wiki_changed"
, Evt_html_fmtr_next_sect_changed = "html_fmtr_next_sect_changed"
;
public static final byte[]
Dflt_xnde_ignore_ids = Bry_.new_a7("coordinates")
, Dflt_tmpl_keeplist = Bry_.new_a7("en.wikipedia.org|formatnum;age;age_in_days;age_in_years_and_days*;nts;number_table_sorting*;as_of;oldstyledatedy;gregorian_serial_date;currentminute;currentsecond;dmca;spaced_ndash;trim;month*;convert*;worldpop*;ipa*;lang*;nowrap*;h:*;mvar;math;vgy;audio;iso_639_name;transl;translate;linktext;zh;nihongo*;japanese_name;ko-hhrm;mp|\n")
, Dflt_html_fmtr_popup = Bry_.new_a7(String_.Concat_lines_nl_skip_last
( "<div dir=~{page_lang_ltr}>"
, " <div>~{content}"
, " </div>"
, " <hr/>"
, " <div>"
, " <span class='data_val'><b>~{page_title}</b></span>~{wiki_item}"
, " <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.size-name');<>}</span><span class='data_val'>~{page_size}</span>"
, " <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.edited-name');<>}</span><span class='data_val'>~{edit_time}</span>~{view_time_item}"
, " </div>"
, " <hr/>"
, " <div style='float:bottom;'>"
, " <span><a href='xowa-cmd:xowa.api.nav.goto(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.gui.browser.url.exec-name');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/page/open.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.gui.browser.tabs.new_link__at_dflt__focus_y-name');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/tabs/new.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_n(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.gui.browser.tabs.new_link__at_dflt__focus_n-name');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/tabs/new_background.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.usr.bookmarks.add(\"~{page_url}\");' title='~{<>msgs.get('api-xowa.usr.bookmarks.add-name');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/bookmarks/add.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.html.modules.popups.show_more(\"~{popup_id}\");' title='~{<>msgs.get('api-xowa.html.modules.popups.show_more-tip');<>}'><img src='~{xowa_root_dir}bin/any/xowa/html/res/src/xowa/popups/imgs/show_more.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.html.modules.popups.show_all (\"~{popup_id}\");' title='~{<>msgs.get('api-xowa.html.modules.popups.show_all-tip');<>}'> <img src='~{xowa_root_dir}bin/any/xowa/html/res/src/xowa/popups/imgs/show_all.png' ></a></span>"
, " <span><a href='/wiki/Special:XowaPopupHistory' title='~{<>msgs.get('api-xowa.html.modules.popups.history-tip');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/history/show.png'></a></span>"
, " <span><a href='xowa-cmd:xowa.api.gui.browser.tabs.new_link__at_dflt__focus_y(\"home/wiki/Help:Options/Popups\");' title='~{<>msgs.get('api-xowa.nav.cfg.main-name');<>}'><img src='~{xowa_root_dir}bin/any/xowa/file/app.menu/tools/options.png'></a></span>"
, " </div>"
, "</div>"
))
, Dflt_html_fmtr_viewed = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.view_time-name');<>}</span><span class='data_val'>~{viewed_val}</span>")
, Dflt_html_fmtr_wiki = Bry_.new_a7("\n <span class='data_key'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.wiki-name');<>}</span><span class='data_val'>~{wiki_val}</span>")
, Dflt_html_fmtr_next_sect = Bry_.new_a7("\n\n<span class='next_sect'>~{<>msgs.get('api-xowa.html.modules.popups.msgs.next_sect-name');<>}~{next_sect_val}</span>")
;
public static final String[]
Dflt_html_fmtr_popup_keys = String_.Ary("content", "page_lang_ltr", "page_url", "page_title", "popup_id", "wiki_item", "page_size", "edit_time", "view_time_item", "xowa_root_dir")
, Dflt_html_fmtr_viewed_keys = String_.Ary("viewed_val")
, Dflt_html_fmtr_wiki_keys = String_.Ary("wiki_val")
, Dflt_html_fmtr_next_sect_keys = String_.Ary("next_sect_val")
;
public static final byte[]
Dflt_ns_allowed = Bry_.Empty
;
public static final int
Dflt_show_init_word_count = 128
, Dflt_show_more_word_count = 192
, Dflt_show_all_if_less_than = -1
, Dflt_show_all_win_max_w = -1
, Dflt_win_show_delay = 600, Dflt_win_hide_delay = 400
, Dflt_win_max_w = -1, Dflt_win_max_h = -1
, Dflt_win_show_all_max_w = 800
, Dflt_scan_len = 1 * Io_mgr.Len_kb
, Dflt_scan_max = 32 * Io_mgr.Len_kb
, Dflt_read_til_stop_fwd = 32
, Dflt_read_til_stop_bwd = 16
, Dflt_stop_if_hdr_after = 96
, Dflt_tmpl_tkn_max = 8 * Io_mgr.Len_kb
;
public static final boolean
Dflt_win_bind_focus_blur = false
;
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.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.*;
public class Xoapi_toc implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
}
public boolean Collapsed() {return collapsed;} private boolean collapsed = false;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_collapsed)) return Yn.To_str(collapsed);
else if (ctx.Match(k, Invk_collapsed_)) collapsed = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_collapsed = "collapsed", Invk_collapsed_ = "collapsed_"
;
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.html.skins; 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.*;
public class Xoapi_skin_app_base implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
}
public boolean Sidebar_home_enabled() {return sidebar_home_enabled;} public void Sidebar_home_enabled_(boolean v) {sidebar_home_enabled = v;} private boolean sidebar_home_enabled;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_sidebar_home_enabled)) return Yn.To_str(sidebar_home_enabled);
else if (ctx.Match(k, Invk_sidebar_home_enabled_)) sidebar_home_enabled = m.ReadYn("v");
return this;
}
private static final String Invk_sidebar_home_enabled = "sidebar_home_enabled", Invk_sidebar_home_enabled_ = "sidebar_home_enabled_";
}

View 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.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_wiki implements GfoInvkAble {
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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_main_page = "main_page", Invk_random = "random", Invk_sandbox = "sandbox";
}

View File

@@ -0,0 +1,73 @@
/*
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.specials; 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.*;
public class Xoapi_search implements GfoInvkAble, GfoEvMgrOwner {
private final Xow_domain_crt_kv_itm_mgr multi_wikis_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_wikis_bry = Dflt_multi_wikis_bry;
private final Xow_domain_crt_kv_itm_mgr multi_sorts_mgr = new Xow_domain_crt_kv_itm_mgr(); private byte[] multi_sorts_bry = Dflt_multi_sorts_bry;
public Xoapi_search() {
this.evMgr = GfoEvMgr.new_(this);
multi_wikis_mgr.Parse_as_itms(multi_wikis_bry);
multi_sorts_mgr.Parse_as_arys(multi_sorts_bry);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public int Results_per_page() {return results_per_page;} private int results_per_page = 20;
public boolean Async_db() {return async_db;} private boolean async_db = true;
public void Multi_wikis_bry_(byte[] v) {
if (!multi_wikis_mgr.Parse_as_itms(v)) return;
this.multi_wikis_bry = v;
GfoEvMgr_.PubVal(this, Evt_multi_wikis_changed, v);
}
public Xow_domain_crt_itm Multi_wikis_crt(Xow_domain_itm cur_domain) {
return multi_wikis_mgr.Find_itm(cur_domain, cur_domain);
}
public void Multi_sorts_bry_(byte[] v) {
if (!multi_sorts_mgr.Parse_as_arys(v)) return;
this.multi_sorts_bry = v;
GfoEvMgr_.PubVal(this, Evt_multi_sorts_changed, v);
}
public Xow_domain_crt_itm[] Multi_sorts_crt(Xow_domain_itm cur_domain) {
return multi_sorts_mgr.Find_ary(cur_domain, cur_domain);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_results_per_page)) return results_per_page;
else if (ctx.Match(k, Invk_results_per_page_)) results_per_page = m.ReadInt("v");
else if (ctx.Match(k, Invk_async_db)) return Yn.To_str(async_db);
else if (ctx.Match(k, Invk_async_db_)) async_db = m.ReadYn("v");
else if (ctx.Match(k, Invk_multi_wikis)) return String_.new_u8(multi_wikis_bry);
else if (ctx.Match(k, Invk_multi_wikis_)) Multi_wikis_bry_(m.ReadBry("v"));
else if (ctx.Match(k, Invk_multi_sorts)) return String_.new_u8(multi_sorts_bry);
else if (ctx.Match(k, Invk_multi_sorts_)) Multi_sorts_bry_(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_results_per_page = "results_per_page" , Invk_results_per_page_ = "results_per_page_"
, Invk_async_db = "async_db" , Invk_async_db_ = "async_db_"
, Invk_multi_wikis = "multi_wikis" , Invk_multi_wikis_ = "multi_wikis_"
, Invk_multi_sorts = "multi_sorts" , Invk_multi_sorts_ = "multi_sorts_"
;
public static final String
Evt_multi_wikis_changed = "multi_wikis_changed"
, Evt_multi_sorts_changed = "multi_sorts_changed"
;
public static final byte[]
Dflt_multi_wikis_bry = Bry_.new_a7("<any>|<self>")
, Dflt_multi_sorts_bry = Bry_.new_a7("<any>|<self>,*.wikipedia,*.wikivoyage,*.wiktionary,*.wikisource,*.wikiquote,*.wikibooks,*.wikiversity,*.wikinews")
;
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.startups; 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.startups.tabs.*;
public class Xoapi_startups implements GfoInvkAble {
public void Init_by_kit(Xoae_app app) {
}
public Xoapi_startup_tabs Tabs() {return tabs;} private Xoapi_startup_tabs tabs = new Xoapi_startup_tabs();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_tabs)) return tabs;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_tabs = "tabs";
}

View File

@@ -0,0 +1,87 @@
/*
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.startups.tabs; 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.startups.*;
import gplx.xowa.specials.*;
public class Xoapi_startup_tabs implements GfoInvkAble {
public String Custom() {return custom;} private String custom;
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
public String Previous() {return previous;} private String previous;
public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual;
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_previous;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type);
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v"));
else if (ctx.Match(k, Invk_type_list)) return Xoapi_startup_tabs_tid_.Options__list;
else if (ctx.Match(k, Invk_previous)) return previous;
else if (ctx.Match(k, Invk_previous_)) previous = m.ReadStr("v");
else if (ctx.Match(k, Invk_custom)) return custom;
else if (ctx.Match(k, Invk_custom_)) custom = m.ReadStr("v");
else if (ctx.Match(k, Invk_custom_is_expr)) return Yn.To_str(custom_is_expr);
else if (ctx.Match(k, Invk_custom_is_expr_)) custom_is_expr = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_type = "type", Invk_type_ = "type_", Invk_type_list = "type_list"
, Invk_custom = "custom", Invk_custom_ = "custom_"
, Invk_previous = "previous", Invk_previous_ = "previous_"
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
;
public String[] Calc_startup_strs(Xoae_app app) {
List_adp rv = List_adp_.new_();
String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
if (manual == null) {
switch (type) {
case Xoapi_startup_tabs_tid_.Tid_blank: rv.Add(Xows_special_meta_.Itm__default_tab.Ttl_str()); break;
case Xoapi_startup_tabs_tid_.Tid_xowa: rv.Add(xowa_home); break;
case Xoapi_startup_tabs_tid_.Tid_custom: Add_ary(rv, custom); break;
case Xoapi_startup_tabs_tid_.Tid_previous: Add_ary(rv, previous); break;
default: throw Err_.new_unhandled(type);
}
}
else
rv.Add(manual);
Add_xowa_home_if_new_version(rv, app, xowa_home);
return rv.To_str_ary();
}
private static void Add_ary(List_adp list, String s) {
if (String_.Len_eq_0(s)) return;
String[] ary = String_.SplitLines_nl(String_.Trim(s));
int len = ary.length;
for (int i = 0; i < len; ++i) {
String itm = ary[i];
if (String_.Len_eq_0(itm)) continue;
list.Add(itm);
}
}
private static void Add_xowa_home_if_new_version(List_adp rv, Xoae_app app, String xowa_home) {
if (gplx.xowa.apps.versions.Xoa_version_.Compare(app.Api_root().App().Env().Version_previous(), Xoa_app_.Version) == CompareAble_.Less) {
boolean xowa_home_exists = false;
int len = rv.Count();
for (int i = 0; i < len; ++i) {
String itm = (String)rv.Get_at(i);
if (String_.Eq(itm, xowa_home)) {
xowa_home_exists = true;
break;
}
}
if (!xowa_home_exists)
rv.Add(xowa_home);
}
}
}

View File

@@ -0,0 +1,39 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.apis.xowa.startups.tabs; 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.startups.*;
public class Xoapi_startup_tabs_tid_ {
public static final byte Tid_blank = 0, Tid_xowa = 1, Tid_previous = 2, Tid_custom = 3;
public static final String Key_blank = "blank", Key_xowa = "xowa", Key_previous = "previous", Key_custom = "custom";
public static String Xto_key(byte v) {
switch (v) {
case Tid_blank: return Key_blank;
case Tid_xowa: return Key_xowa;
case Tid_previous: return Key_previous;
case Tid_custom: return Key_custom;
default: throw Err_.new_unimplemented();
}
}
public static byte Xto_tid(String s) {
if (String_.Eq(s, Key_blank)) return Tid_blank;
else if (String_.Eq(s, Key_xowa)) return Tid_xowa;
else if (String_.Eq(s, Key_previous)) return Tid_previous;
else if (String_.Eq(s, Key_custom)) return Tid_custom;
else throw Err_.new_unimplemented();
}
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_blank), KeyVal_.new_(Key_xowa), KeyVal_.new_(Key_previous), KeyVal_.new_(Key_custom));
}

View File

@@ -0,0 +1,59 @@
/*
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 GfoInvkAble {
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 boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {enabled = v;}
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, Invk_enabled)) return Yn.To_str(enabled);
else if (ctx.Match(k, Invk_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 GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_enabled = "enabled", Invk_enabled_ = "enabled_"
, Invk_delete_confirm = "delete_confirm", Invk_delete_confirm_ = "delete_confirm_"
, Invk_add = "add", Invk_show = "show";
}

View 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.usrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.apis.*; import gplx.xowa.apps.apis.xowa.*;
import gplx.ios.*; import gplx.xowa.files.caches.*;
public class Xoapi_cache implements GfoInvkAble {
private Xou_cache_mgr cache_mgr;
public void Init_by_app(Xoa_app app) {this.cache_mgr = app.User().User_db_mgr().Cache_mgr();}
private String Info() {
cache_mgr.Page_bgn();
Bry_bfr bfr = Bry_bfr.new_(255);
KeyVal[] ary = cache_mgr.Info();
int len = ary.length;
for (int i = 0; i < len; ++i) {
KeyVal kv = ary[i];
bfr.Add_str_a7(kv.Key()).Add_str_a7(": ").Add_str_u8(kv.Val_to_str_or_empty()).Add_byte_nl();
}
return bfr.To_str_and_clear();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_fsys_size_min)) return cache_mgr.Fsys_size_min() / Io_mgr.Len_mb;
else if (ctx.Match(k, Invk_fsys_size_min_)) cache_mgr.Fsys_size_min_(Io_size_.To_long_by_msg_mb(m, cache_mgr.Fsys_size_min()));
else if (ctx.Match(k, Invk_fsys_size_max)) return cache_mgr.Fsys_size_max() / Io_mgr.Len_mb;
else if (ctx.Match(k, Invk_fsys_size_max_)) cache_mgr.Fsys_size_max_(Io_size_.To_long_by_msg_mb(m, cache_mgr.Fsys_size_max()));
else if (ctx.Match(k, Invk_info)) return Info();
else if (ctx.Match(k, Invk_reduce_to_min)) cache_mgr.Reduce(cache_mgr.Fsys_size_min());
else if (ctx.Match(k, Invk_reduce_to_zero)) cache_mgr.Reduce(0);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_fsys_size_min = "fsys_size_min" , Invk_fsys_size_min_ = "fsys_size_min_"
, Invk_fsys_size_max = "fsys_size_max" , Invk_fsys_size_max_ = "fsys_size_max_"
, Invk_info = "info"
, Invk_reduce_to_min = "reduce_to_min" , Invk_reduce_to_zero = "reduce_to_zero"
;
}

View File

@@ -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.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 GfoInvkAble {
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 boolean Enabled() {return enabled;} private boolean enabled = true;
public void Enabled_(boolean v) {enabled = v;}
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_enabled)) return Yn.To_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else if (ctx.Match(k, Invk_goto_recent)) this.Goto_recent();
else if (ctx.Match(k, Invk_show)) this.Show();
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_goto_recent = "goto_recent", Invk_show = "show";
}

View File

@@ -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.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_logs implements GfoInvkAble {
private Xoae_app app;
public void Ctor_by_app(Xoae_app app) {this.app = app;}
public void Init_by_kit(Xoae_app app) {}
public boolean Enabled() {return app.Log_wtr().Enabled();}
public void Enabled_(boolean v) {
app.Log_wtr().Enabled_(v);
if (!v)
Io_mgr.Instance.DeleteFil_args(app.Log_wtr().Session_fil()).MissingFails_off().Exec();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(this.Enabled());
else if (ctx.Match(k, Invk_enabled_)) Enabled_(m.ReadYn("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_";
}

View 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.wikis; 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.wikis.langs.*;
public class Xoapi_wiki_lang implements GfoInvkAble {
public Xoap_lang_variants Variants() {return variants;} private final Xoap_lang_variants variants = new Xoap_lang_variants();
public void Subscribe(GfoEvObj sub) {variants.Subscribe(sub);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_variants)) return variants;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_variants = "variants";
}

View File

@@ -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.wikis.langs; 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.wikis.*;
public class Xoap_lang_variants implements GfoInvkAble, GfoEvMgrOwner {
public Xoap_lang_variants() {
this.ev_mgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return ev_mgr;} private final GfoEvMgr ev_mgr;
public byte[] Current() {return current;} private byte[] current;
public void Current_(byte[] v) {
this.current = v;
GfoEvMgr_.PubVal(this, Evt_current_changed, v);
}
public void Subscribe(GfoEvObj sub) {
GfoEvMgr_.SubSame(this, Evt_current_changed, sub);
if (current != null) GfoInvkAble_.InvkCmd_val(sub, Evt_current_changed, current);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_current)) return String_.new_u8(current);
else if (ctx.Match(k, Invk_current_)) Current_(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_current = "current", Invk_current_ = "current_";
public static final String
Evt_current_changed = "current_changed"
;
}

View 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.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.scribunto.*; import gplx.xowa.xtns.scribunto.engines.*;
public class Xoapi_scribunto implements GfoInvkAble {
private Xoae_app app;
public void Init_by_kit(Xoae_app app) {
this.app = app;
}
public void Engine_(byte v) {
Scrib_xtn_mgr scrib_xtn = (Scrib_xtn_mgr)app.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
scrib_xtn.Engine_type_(v);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_engine_lua_)) Engine_(Scrib_engine_type.Type_lua);
else if (ctx.Match(k, Invk_engine_luaj_)) Engine_(Scrib_engine_type.Type_luaj);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_engine_lua_ = "engine_lua_", Invk_engine_luaj_ = "engine_luaj_"
;
}

View File

@@ -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.wdatas.*;
public class Xoapi_wikibase implements GfoInvkAble, GfoEvMgrOwner {
public Xoapi_wikibase() {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
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 Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_core_langs)) return Bry_.Add_w_dlm(Byte_ascii.Semic, core_langs);
else if (ctx.Match(k, Invk_core_langs_)) {core_langs = m.ReadBryAry(k, Byte_ascii.Semic); GfoEvMgr_.PubVal(this, Evt_core_langs_changed, core_langs);}
else if (ctx.Match(k, Invk_sort_langs)) return Bry_.Add_w_dlm(Byte_ascii.Semic, sort_langs);
else if (ctx.Match(k, Invk_sort_langs_)) {sort_langs = m.ReadBryAry(k, Byte_ascii.Semic); GfoEvMgr_.PubVal(this, Evt_sort_langs_changed, sort_langs);}
else if (ctx.Match(k, Invk_link_wikis)) return String_.new_u8(link_wikis);
else if (ctx.Match(k, Invk_link_wikis_)) {link_wikis = m.ReadBry(k); GfoEvMgr_.PubVal(this, Evt_link_wikis_changed, link_wikis);}
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_core_langs = "core_langs", Invk_core_langs_ = "core_langs_"
, Invk_sort_langs = "sort_langs", Invk_sort_langs_ = "sort_langs_"
, Invk_link_wikis = "link_wikis", Invk_link_wikis_ = "link_wikis_"
;
public static final String
Evt_core_langs_changed = "core_langs_changed"
, Evt_link_wikis_changed = "link_wikis_changed"
, Evt_sort_langs_changed = "sort_langs_changed"
;
}

View File

@@ -0,0 +1,125 @@
/*
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.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.core.consoles.*;
import gplx.dbs.*;
import gplx.gfui.*; import gplx.xowa.guis.views.boots.*;
import gplx.xowa.langs.*;
import gplx.xowa.users.*;
public class Xoa_boot_mgr {
private Gfo_usr_dlg usr_dlg; private Gfo_usr_dlg__log log_wtr;
public void Run(String[] args, Xoa_cmd_arg_mgr arg_mgr) {
try {
Init_env(args);
if (arg_mgr.Process(usr_dlg, args, Env_.AppUrl().OwnerDir()))
Run_app(arg_mgr);
}
catch (Exception e) {
String err_str = Err_.Message_gplx_full(e);
log_wtr.Log_to_err(err_str);
Console_adp__sys.Instance.Write_str_w_nl(err_str);
if (log_wtr.Log_dir() == null) log_wtr.Log_dir_(Env_.AppUrl().OwnerDir().GenSubFil("xowa.log"));
log_wtr.Queue_enabled_(false);
}
}
private void Init_env(String[] args) {
Gfo_usr_dlg_.Instance = usr_dlg = Xoa_app_.usr_dlg_console_();
log_wtr = usr_dlg.Log_wkr(); log_wtr.Log_to_session_fmt("env.init: version=~{0}", Xoa_app_.Version);
GfuiEnv_.Init_swt(args, Xoa_app_.class);
Io_url jar_url = Env_.AppUrl();
Xoa_app_.Build_date = Io_mgr.Instance.QueryFil(jar_url).ModifiedTime().XtoUtc().XtoStr_fmt("yyyy-MM-dd HH:mm");
log_wtr.Log_to_session_fmt("env.init: jar_url=~{0}; build_date=~{1}", jar_url.NameAndExt(), Xoa_app_.Build_date);
log_wtr.Log_to_session_fmt("env.init: op_sys=~{0}", Op_sys.Cur().To_str());
}
private void Run_app(Xoa_cmd_arg_mgr arg_mgr) {
boolean app_type_is_gui = false;
Xoae_app app = null;
try {
// init vars
Io_url root_dir = arg_mgr.Fsys__root_dir();
Xoa_app_.Op_sys_str = arg_mgr.Fsys__bin_dir();
Xoa_app_.User_agent = String_.Format("XOWA/{0} ({1}) [gnosygnu@gmail.com]", Xoa_app_.Version, Xoa_app_.Op_sys_str);
Xoa_app_mode app_type = arg_mgr.App_type();
app_type_is_gui = app_type.Tid_is_gui();
Xog_splash_win splash_win = new Xog_splash_win(app_type_is_gui);
Db_conn_bldr.Instance.Reg_default_sqlite();
// init app
app = new Xoae_app(usr_dlg, app_type
, root_dir
, arg_mgr.Fsys__wiki_dir()
, root_dir.GenSubDir("file")
, arg_mgr.Fsys__user_dir()
, root_dir.GenSubDir_nest("user", "anonymous", "wiki")
, Xoa_app_.Op_sys_str);
usr_dlg.Log_wkr().Queue_enabled_(false); log_wtr.Log_to_session_fmt("app.init");
try {
app.Sys_cfg().Lang_(System_lang());
String launch_url = arg_mgr.Gui__home_page();
if (launch_url != null) app.Api_root().App().Startup().Tabs().Manual_(launch_url);
app.Tcp_server().Rdr_port_(arg_mgr.Tcp__port_recv()).Wtr_port_(arg_mgr.Tcp__port_send());
gplx.xowa.apps.servers.http.Http_server_mgr server_mgr = app.Http_server();
server_mgr.Port_(arg_mgr.Http__port());
server_mgr.Home_(Bry_.new_u8(arg_mgr.Http__home_page()));
server_mgr.Wkr_pool().Init(arg_mgr.Http__max_clients(), arg_mgr.Http__max_clients_timeout());
app.Init_by_app();
}
catch (Exception e) {usr_dlg.Warn_many("", "", "app init failed: ~{0}", Err_.Message_gplx_full(e));}
app.Usr_dlg().Log_wkr_(app.Log_wtr()); // NOTE: log_wtr must be set for cmd-line (else process will fail);
// run gfs
gplx.xowa.users.prefs.Prefs_rename_mgr.Instance.Check(app.Usere().Fsys_mgr().App_data_cfg_user_fil());
Io_url cmd_file = arg_mgr.Cmd__file();
try {app.Gfs_mgr().Run_url(cmd_file);}
catch (Exception e) {
usr_dlg.Warn_many("", "", "script file failed: ~{0} ~{1}", cmd_file.Raw(), Err_.Message_gplx_full(e));
if (app_type_is_gui)
GfuiEnv_.ShowMsg(Err_.Message_gplx_full(e));
}
gplx.xowa.apps.setups.Xoa_setup_mgr.Delete_old_files(app);
// launch
app.Launch();
if (app_type.Tid_is_tcp()) app.Tcp_server().Run();
else if (app_type.Tid_is_http()) app.Http_server().Run();
else {
String cmd_text = arg_mgr.Cmd__text();
if (cmd_text != null) {
gplx.xowa.apps.servers.Gxw_html_server.Init_gui_for_server(app, null); // NOTE: must init kit else "app.shell.fetch_page" will fail; DATE:2015-04-30
Console_adp__sys.Instance.Write_str_w_nl_utf8(Object_.Xto_str_strict_or_empty(app.Gfs_mgr().Run_str(cmd_text)));
}
if (app_type_is_gui)
app.Gui_mgr().Run(splash_win);
else // teardown app, else lua will keep process running
if (gplx.xowa.xtns.scribunto.Scrib_core.Core() != null) gplx.xowa.xtns.scribunto.Scrib_core.Core().Term();
}
}
catch (Exception e) {usr_dlg.Warn_many("", "", "app launch failed: ~{0}", Err_.Message_gplx_full(e));}
finally {
if (app != null && app_type_is_gui) // only cancel if app_type_is_gui is true; (force cmd_line to end process)
app.Setup_mgr().Cmd_mgr().Canceled_y_();
}
}
private static byte[] System_lang() {
String lang_code = Env_.Env_prop__user_language();
byte[] lang_code_bry = Bry_.new_a7(lang_code);
Xol_lang_stub lang_itm = Xol_lang_stub_.Get_by_key_or_null(lang_code_bry);
return lang_itm == null ? Xol_lang_itm_.Key_en : lang_itm.Key();
}
}

View File

@@ -0,0 +1,102 @@
/*
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.boots; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.core.consoles.*;
import gplx.xowa.apps.*;
public class Xoa_cmd_arg_mgr {
Xoa_cmd_arg_mgr(Gfo_cmd_arg_mgr arg_mgr) {this.arg_mgr = arg_mgr;}
public Gfo_cmd_arg_mgr Arg_mgr() {return arg_mgr;} private final Gfo_cmd_arg_mgr arg_mgr;
public Xoa_app_mode App_type() {return app_type;} private Xoa_app_mode app_type;
public Io_url Fsys__root_dir() {return fsys__root_dir;} private Io_url fsys__root_dir;
public String Fsys__bin_dir() {return fsys__bin_dir;} private String fsys__bin_dir;
public Io_url Fsys__user_dir() {return fsys__user_dir;} private Io_url fsys__user_dir;
public Io_url Fsys__wiki_dir() {return fsys__wiki_dir;} private Io_url fsys__wiki_dir;
public Io_url Cmd__file() {return cmd__file;} private Io_url cmd__file;
public String Cmd__text() {return cmd__text;} private String cmd__text;
public int Tcp__port_recv() {return tcp__port_recv;} private int tcp__port_recv;
public int Tcp__port_send() {return tcp__port_send;} private int tcp__port_send;
public int Http__port() {return http__port;} private int http__port;
public String Http__home_page() {return http__home_page;} private String http__home_page;
public int Http__max_clients() {return http__max_clients;} private int http__max_clients;
public int Http__max_clients_timeout() {return http__max_clients_timeout;} private int http__max_clients_timeout;
public String Gui__home_page() {return gui__home_page;} private String gui__home_page;
public boolean Process(Gfo_usr_dlg usr_dlg, String[] args, Io_url jar_dir) {
arg_mgr.Parse(args);
if (!Print(usr_dlg)) return false;
this.app_type = Xoa_app_mode.parse(arg_mgr.Get_by("app_mode").Val_as_str_or("gui"));
this.fsys__root_dir = arg_mgr.Get_by("root_dir").Val_as_url__rel_dir_or(jar_dir, jar_dir);
this.fsys__user_dir = arg_mgr.Get_by("user_dir").Val_as_url__rel_dir_or(fsys__root_dir.GenSubDir("user"), fsys__root_dir.GenSubDir_nest("user", User_name_default));
this.fsys__wiki_dir = arg_mgr.Get_by("wiki_dir").Val_as_url__rel_dir_or(fsys__root_dir.GenSubDir("wiki"), fsys__root_dir.GenSubDir("wiki"));
this.cmd__file = arg_mgr.Get_by("cmd_file").Val_as_url__rel_fil_or(jar_dir, fsys__root_dir.GenSubFil_nest("bin", "any", "xowa", "cfg" ,"app", "xowa.gfs"));
this.cmd__text = arg_mgr.Get_by("cmd_text").Val_as_str_or(null);
this.tcp__port_recv = arg_mgr.Get_by("server_port_recv").Val_as_int_or(55000);
this.tcp__port_send = arg_mgr.Get_by("server_port_send").Val_as_int_or(55001);
this.http__port = arg_mgr.Get_by("http_server_port").Val_as_int_or(8080);
this.http__home_page = arg_mgr.Get_by("http_server_home").Val_as_str_or("home/wiki/Main_Page");
this.http__max_clients = arg_mgr.Get_by("http_server.max_clients").Val_as_int_or(0);
this.http__max_clients_timeout = arg_mgr.Get_by("http_server.max_clients_timeout").Val_as_int_or(50);
this.gui__home_page = arg_mgr.Get_by("url").Val_as_str_or(null);
this.fsys__bin_dir = arg_mgr.Get_by("bin_dir_name").Val_as_str_or(Bin_dir_name());
return true;
}
private boolean Print(Gfo_usr_dlg usr_dlg) {
String header = String_.Concat_lines_nl_skip_last
( Env_.GenHdr(false, "XOWA", "XOWA: the XOWA Offline Wiki Application\n", "")
, String_.Repeat("-", 80)
, ""
, "version: " + Xoa_app_.Version + "; build date: " + Xoa_app_.Build_date
);
Gfo_cmd_arg_mgr_printer printer = new Gfo_cmd_arg_mgr_printer(arg_mgr);
return printer.Print(usr_dlg, header, Xoa_app_.Name, "help", "show_license", "show_args");
}
public static Xoa_cmd_arg_mgr new_() {
Gfo_cmd_arg_mgr arg_mgr = new Gfo_cmd_arg_mgr().Reg_many
( Gfo_cmd_arg_itm_.opt_("root_dir").Example_url_("C:\\xowa").Note_("root directory for xowa; defaults to current directory of xowa.jar")
, Gfo_cmd_arg_itm_.opt_("user_dir").Example_url_("C:\\xowa\\user\\" + User_name_default).Note_("directory for user_data; defaults to '/xowa/user/" + User_name_default + "'")
, Gfo_cmd_arg_itm_.opt_("wiki_dir").Example_url_("C:\\xowa\\wiki\\").Note_("directory for wikis; defaults to '/xowa/wiki/'")
, Gfo_cmd_arg_itm_.opt_("bin_dir_name").Example_("windows").Note_("platform-dependent directory name inside /xowa/bin/; valid values are 'linux', 'macosx', 'windows', 'linux_64', 'macosx_64', 'windows_64'; defaults to detected version")
, Gfo_cmd_arg_itm_.opt_("app_mode").Example_("gui").Note_("type of app to run; valid values are 'gui', 'cmd', 'server', 'http_server'; defaults to 'gui'")
, Gfo_cmd_arg_itm_.opt_("cmd_file").Example_url_("C:\\xowa\\bin\\any\\xowa\\cfg\\app\\xowa.gfs").Note_("file_path of script to execute; defaults to 'xowa.gfs'")
, Gfo_cmd_arg_itm_.opt_("cmd_text").Example_("\"app.shell.fetch_page('en.wikipedia.org/wiki/Earth', 'html');\"").Note_("script to run; runs after cmd_file; does nothing if empty; default is empty.\nCurrently a useful cmd is to do 'java -jar xowa_your_platform.jar --app_mode cmd --show_license n --show_args n --cmd_text \"app.shell.fetch_page('en.wikipedia.org/wiki/Earth' 'html');\"'. This will output the page's html to the console. You can also change 'html' to 'wiki' to get the wikitext.")
, Gfo_cmd_arg_itm_.opt_("url").Example_("en.wikipedia.org/wiki/Earth").Note_("url to be shown when xowa first launches; default is home/wiki/Main_Page")
, Gfo_cmd_arg_itm_.opt_("server_port_recv").Example_("55000").Note_("applies to --app_mode server; port where xowa server will receive messages; clients should send messages to this port")
, Gfo_cmd_arg_itm_.opt_("server_port_send").Example_("55001").Note_("applies to --app_mode server; port where xowa server will send messages; clients should listen for messages from this port")
, Gfo_cmd_arg_itm_.opt_("http_server_port").Example_("8080").Note_("applies to --app_mode http_server; port used by http_server; default is 8080")
, Gfo_cmd_arg_itm_.opt_("http_server_home").Example_("home/wiki/Main_Page").Note_("applies to --app_mode http_server; default home page for root address. EX: navigating to localhost:8080 will navigate to localhost:8080/home/wiki/Main_Page")
, Gfo_cmd_arg_itm_.opt_("http_server.max_clients").Example_("15").Note_("applies to --app_mode http_server; limits maximum number of concurrent connections; default is 0 (no limit)")
, Gfo_cmd_arg_itm_.opt_("http_server.max_clients_timeout").Example_("50").Note_("applies to --app_mode http_server; time in milliseconds to wait before checking again to see if a connection is free; default is 50 (wait 50 ms)")
, Gfo_cmd_arg_itm_.sys_("show_license").Dflt_(true)
, Gfo_cmd_arg_itm_.sys_("show_args").Dflt_(true)
, Gfo_cmd_arg_itm_.new_(Gfo_cmd_arg_itm_.Tid_system, "help", Bool_.N, Gfo_cmd_arg_itm_.Val_tid_string)
);
return new Xoa_cmd_arg_mgr(arg_mgr);
}
private static final String User_name_default = gplx.xowa.users.Xoue_user.Key_xowa_user;
private static String Bin_dir_name() {
String rv = "";
Op_sys op_sys = Op_sys.Cur();
switch (op_sys.Tid()) {
case Op_sys.Tid_lnx: rv = "linux"; break;
case Op_sys.Tid_wnt: rv = "windows"; break;
case Op_sys.Tid_osx: rv = "macosx"; break;
default: throw Err_.new_unhandled("unknown platform " + Op_sys.Cur());
}
if (op_sys.Bitness() == Op_sys.Bitness_64) rv += "_64";
return rv;
}
}

View File

@@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public interface Xoa_cfg_db {
void Cfg_reset_all(Xoa_cfg_mgr cfg_mgr);
void Cfg_save_bgn(Xoa_cfg_mgr cfg_mgr);
void Cfg_save_end(Xoa_cfg_mgr cfg_mgr);
void Cfg_save_run(Xoa_cfg_mgr cfg_mgr, Xoa_cfg_grp cfg_grp, Xoa_cfg_itm cfg_itm);
void Cfg_load_run(Xoa_cfg_mgr cfg_mgr);
}

View File

@@ -0,0 +1,45 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.apps.gfs.*;
public class Xoa_cfg_db_txt implements Xoa_cfg_db {
private Bry_fmtr fmtr = Bry_fmtr.new_("app.cfgs.get('~{msg}', '~{wiki}').val = '~{val}';\n", "msg", "wiki", "val");
public void Cfg_reset_all(Xoa_cfg_mgr cfg_mgr) {
Io_url src_url = this.Cfg_url(cfg_mgr);
Io_url trg_url = src_url.GenNewNameAndExt("xowa_user_cfg." + DateAdp_.Now().XtoStr_fmt_yyyyMMdd_HHmmss() + ".gfs");
Io_mgr.Instance.MoveFil_args(src_url, trg_url, true).Exec();
if (cfg_mgr.App().Tid_is_edit())
((Xoae_app)cfg_mgr.App()).Gui_mgr().Kit().Ask_ok("", "", "Options cleared. Please restart XOWA.");
}
public void Cfg_load_run(Xoa_cfg_mgr cfg_mgr) {
String load = Io_mgr.Instance.LoadFilStr(Cfg_url(cfg_mgr));
cfg_mgr.App().Gfs_mgr().Run_str(load);
}
public void Cfg_save_bgn(Xoa_cfg_mgr cfg_mgr) {
bfr.ClearAndReset();
} private Bry_bfr bfr = Bry_bfr.new_();
public void Cfg_save_end(Xoa_cfg_mgr cfg_mgr) {
Xoa_app_.Usr_dlg().Log_many("", "", "shutting down app; saving cfg: len=~{0}", bfr.Len());
Io_mgr.Instance.SaveFilBfr(Cfg_url(cfg_mgr), bfr);
}
public void Cfg_save_run(Xoa_cfg_mgr cfg_mgr, Xoa_cfg_grp cfg_grp, Xoa_cfg_itm cfg_itm) {
fmtr.Bld_bfr_many(bfr, Xoa_gfs_wtr_.Escape(cfg_grp.Key_bry()), Xoa_gfs_wtr_.Escape(cfg_itm.Key()), Xoa_gfs_wtr_.Escape(cfg_itm.Val()));
}
public Io_url Cfg_url(Xoa_cfg_mgr cfg_mgr) {return ((Xoae_app)cfg_mgr.App()).Usere().Fsys_mgr().App_data_cfg_dir().GenSubFil(File_name);}
public static final String File_name = "xowa_user_cfg.gfs";
}

View File

@@ -0,0 +1,64 @@
/*
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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wikis.domains.*;
public class Xoa_cfg_grp {
private final Ordered_hash hash = Ordered_hash_.New_bry(); private final Xoa_cfg_mgr mgr;
public Xoa_cfg_grp(Xoa_cfg_mgr mgr, Xoa_cfg_grp_tid tid, byte[] key_bry) {
this.mgr = mgr; this.tid = tid; this.key_bry = key_bry; this.key_str = String_.new_u8(key_bry);
}
public Xoa_cfg_grp_tid Tid() {return tid;} private final Xoa_cfg_grp_tid tid;
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry;
public String Key_str() {return key_str;} private final String key_str;
public boolean Notify(Xoa_cfg_itm itm) {return mgr.Notify(this, itm);}
public Xoa_cfg_itm Get_by_or_null(byte[] key) {return (Xoa_cfg_itm)hash.Get_by(key);}
public Xoa_cfg_itm Get_by_or_make(byte[] key) {
Xoa_cfg_itm rv = (Xoa_cfg_itm)hash.Get_by(key);
if (rv == null) {
rv = new Xoa_cfg_itm(this, key);
hash.Add(key, rv);
}
return rv;
}
public Xoa_cfg_itm Get_by_wiki(byte[] domain_bry, int domain_tid) {
Xoa_cfg_itm rv = (Xoa_cfg_itm)hash.Get_by(domain_bry);
if (rv == null) { // match by domain_bry failed; try tid
rv = (Xoa_cfg_itm)hash.Get_by(Xow_domain_tid_.Get_type_as_bry(domain_tid));
if (rv == null) // match by type failed; try all
rv = (Xoa_cfg_itm)hash.Get_by(Xoa_cfg_grp_tid.Key_all_bry);
if (rv == null) // match by all failed; try app
rv = (Xoa_cfg_itm)hash.Get_by(Xoa_cfg_grp_tid.Key_app_bry);
}
return rv;
}
public void Db_load_end() {
int len = hash.Count();
for (int i = 0; i < len; ++i) {
Xoa_cfg_itm itm = (Xoa_cfg_itm)hash.Get_at(i);
itm.Val_load_done();
}
}
public void Db_save(Xoa_cfg_db db) {
int len = hash.Count();
for (int i = 0; i < len; ++i) {
Xoa_cfg_itm itm = (Xoa_cfg_itm)hash.Get_at(i);
if (!itm.Val_is_customized() && !itm.Val_is_dirty()) continue; // system default and unchanged; no need to save
db.Cfg_save_run(mgr, this, itm);
}
}
}

View File

@@ -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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wikis.domains.*;
public class Xoa_cfg_grp_tid {
public byte Tid() {return tid;} private byte tid;
public byte[] Key() {return key;} private byte[] key;
public int Wiki_tid() {return wiki_tid;} private int wiki_tid;
public static final byte Tid_null = 0, Tid_all = 1, Tid_type = 2, Tid_wiki = 3, Tid_app = 4;
public static final String Key_app_str = "app";
public static final byte[] Key_all_bry = Bry_.new_a7("*"), Key_app_bry = Bry_.new_a7(Key_app_str);
public static Xoa_cfg_grp_tid parse(byte[] key) {
Xoa_cfg_grp_tid rv = (Xoa_cfg_grp_tid)factory.Get_by_bry(key);
if (rv == null) {
rv = new Xoa_cfg_grp_tid();
if (Bry_.Eq(key, Key_all_bry)) rv.tid = Tid_all;
else if (Bry_.Eq(key, Key_app_bry)) rv.tid = Tid_app;
else {
Xow_domain_itm wiki_type = Xow_domain_itm_.parse(key);
if (wiki_type.Domain_type_id() == Xow_domain_tid_.Int__other)
rv.tid = Tid_wiki;
else {
rv.tid = Tid_type;
rv.wiki_tid = wiki_type.Domain_type_id();
}
}
rv.key = key;
factory.Add(key, rv);
}
return rv;
} static Hash_adp_bry factory = Hash_adp_bry.cs();
}

View File

@@ -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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_cfg_itm implements GfoInvkAble {
public Xoa_cfg_itm(Xoa_cfg_grp grp, byte[] key) {this.grp = grp; this.key = key;}
public Xoa_cfg_grp Grp() {return grp;} private final Xoa_cfg_grp grp;
public byte[] Key() {return key;} private final byte[] key;
public String Val() {return val;} private String val;
public boolean Val_is_dirty() {return val_is_dirty;} private boolean val_is_dirty;
public boolean Val_is_customized() {return val_is_customized;} private boolean val_is_customized; // false if value is system default; true if changed by user
public void Val_(String v) {
this.val = v;
if (grp.Notify(this)) {
val_is_customized = true;
val_is_dirty = true;
}
}
public void Val_load_done() {
val_is_dirty = false;
val_is_customized = true;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_val)) return val;
else if (ctx.Match(k, Invk_val_)) Val_(m.ReadStr("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_val = "val", Invk_val_ = "val_";
}

View File

@@ -0,0 +1,123 @@
/*
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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wikis.domains.*;
public class Xoa_cfg_mgr implements GfoInvkAble {
private final Ordered_hash hash = Ordered_hash_.New_bry();
public Xoa_cfg_mgr(Xoa_app app) {this.app = app;}
public Xoa_app App() {return app;} private final Xoa_app app;
public Xoa_cfg_itm Get_itm_or_null(byte[] grp_key, byte[] itm_key) {
Xoa_cfg_grp grp = (Xoa_cfg_grp)hash.Get_by(grp_key);
return grp == null ? null : grp.Get_by_or_null(itm_key);
}
public Xoa_cfg_itm Get_itm_or_make(byte[] grp_key, byte[] itm_key) {
Xoa_cfg_grp grp = null;
Object grp_obj = hash.Get_by(grp_key);
if (grp_obj == null) {
Xoa_cfg_grp_tid tid = Xoa_cfg_grp_tid.parse(itm_key);
grp = new Xoa_cfg_grp(this, tid, grp_key);
hash.Add(grp_key, grp);
}
else
grp = (Xoa_cfg_grp)grp_obj;
return grp.Get_by_or_make(itm_key);
}
public void Set_by_app(String grp_key, String val) {Set(Bry_.new_u8(grp_key), Xoa_cfg_grp_tid.Key_app_bry, val);}
public void Set_by_all(String grp_key, String val) {Set(Bry_.new_u8(grp_key), Xoa_cfg_grp_tid.Key_all_bry, val);}
public void Set_by_type(String grp_key, byte tid, String val) {Set(Bry_.new_u8(grp_key), Xow_domain_tid_.Get_type_as_bry(tid), val);}
private void Set(byte[] grp_key, byte[] tid_key, String val) {Get_itm_or_make(grp_key, tid_key).Val_(val);}
public void Init(Xow_wiki wiki) {
int len = hash.Count();
for (int i = 0; i < len; i++) {
Xoa_cfg_grp grp = (Xoa_cfg_grp)hash.Get_at(i);
Xoa_cfg_itm itm = grp.Get_by_wiki(wiki.Domain_bry(), wiki.Domain_tid());
if (itm == null) continue; // grp exists, but not for wiki; EX: rule exists for download.enabled and enwiki, but frwiki loaded
if (itm.Grp().Tid().Tid() == Xoa_cfg_grp_tid.Tid_app) continue; // rule is for app; don't run for wiki init
Eval_set(wiki, grp.Key_str(), itm.Val());
}
}
public boolean Notify(Xoa_cfg_grp grp, Xoa_cfg_itm itm) {
Xoa_cfg_grp_tid grp_tid = grp.Tid();
byte tid_byte = grp_tid.Tid();
switch (tid_byte) {
case Xoa_cfg_grp_tid.Tid_app:
return Eval_set(app, grp.Key_str(), itm.Val());
case Xoa_cfg_grp_tid.Tid_all:
case Xoa_cfg_grp_tid.Tid_type:
boolean all = tid_byte == Xoa_cfg_grp_tid.Tid_all;
int wiki_count = app.Wiki_mgri().Count();
boolean rv = true;
for (int i = 0; i < wiki_count; i++) {
Xow_wiki wiki = app.Wiki_mgri().Get_at_i(i);
if (all || wiki.Domain_tid() == grp_tid.Wiki_tid()) {
if (!Eval_set(wiki, grp.Key_str(), itm.Val()))
rv = false;
}
}
return rv;
case Xoa_cfg_grp_tid.Tid_wiki: {
Xow_wiki wiki = app.Wiki_mgri().Get_by_key_or_null_i(itm.Key());
if (wiki == null) return true; // wiki not installed; return true (no error)
return Eval_set(wiki, grp.Key_str(), itm.Val());
}
default:
throw Err_.new_unhandled(tid_byte);
}
}
public void Reset_all() {
hash.Clear();
db_txt.Cfg_reset_all(this);
}
public void Db_load_txt() {Db_load(db_txt);}
public void Db_load(Xoa_cfg_db db) {
db.Cfg_load_run(this);
this.Db_load_end();
}
private void Db_load_end() {
int len = hash.Count();
for (int i = 0; i < len; i++) {
Xoa_cfg_grp grp = (Xoa_cfg_grp)hash.Get_at(i);
grp.Db_load_end();
}
}
public void Db_save_txt() {Db_save(db_txt);} private final Xoa_cfg_db_txt db_txt = new Xoa_cfg_db_txt();
public void Db_save(Xoa_cfg_db db) {
int len = hash.Count();
db.Cfg_save_bgn(this);
for (int i = 0; i < len; i++) {
Xoa_cfg_grp grp = (Xoa_cfg_grp)hash.Get_at(i);
grp.Db_save(db);
}
db.Cfg_save_end(this);
}
private boolean Eval_set(GfoInvkAble invk, String key, String val) {
String msg_str = key + "_(<:['\n" + val + "\n']:>);";
Object rslt = app.Gfs_mgr().Run_str_for(invk, msg_str);
return rslt != GfoInvkAble_.Rv_error;
}
public Object Eval_get(GfoInvkAble invk, String key) {
String msg_str = key + ";";
return app.Gfs_mgr().Run_str_for(invk, msg_str);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get_itm_or_make(m.ReadBry("itm_key"), m.ReadBry("grp_key"));
else if (ctx.Match(k, Invk_reset_all)) Reset_all();
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_get = "get", Invk_reset_all = "reset_all";
}

View File

@@ -0,0 +1,86 @@
/*
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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.dbs.*;
public class Xoa_cfg_mgr_tst {
@Before public void init() {fxt.Clear();} private Xoa_cfg_mgr_fxt fxt = new Xoa_cfg_mgr_fxt();
@Test public void Init() {
fxt.Init_cfg_all("import.db_text_max", "1000");
fxt.Test_init_wiki("simple.wikipedia.org", "import.db_text_max", "1000");
fxt.Test_cfg_itm("simple.wikipedia.org", "import.db_text_max", false, false);
}
@Test public void Notify() {
fxt.Exec_make_wiki("simple.wikipedia.org");
fxt.Test_cfg_set("app.cfgs.get('import.db_text_max', 'simple.wikipedia.org').val = '2000';", "simple.wikipedia.org", "import.db_text_max", "2000");
fxt.Test_cfg_itm("simple.wikipedia.org", "import.db_text_max", true, true);
fxt.Test_save("app.cfgs.get('import.db_text_max', 'simple.wikipedia.org').val = '2000';\n");
}
@Test public void Notify_quote() {
fxt.Test_cfg_set("app.cfgs.get('app.gui.html.css_xtn', 'app').val = 'a''b';", "*", "app.gui.html.css_xtn", "a'b");
fxt.Test_cfg_itm("app", "app.gui.html.css_xtn", true, true);
fxt.Test_save("app.cfgs.get('app.gui.html.css_xtn', 'app').val = 'a''b';\n");
}
@Test public void Init_should_not_notify_if_app() {
fxt.Init_cfg_app("import.db_text_max", "1000");
fxt.Test_init_wiki("simple.wikipedia.org", "import.db_text_max", "3000"); // 3000 is default; itm shouldn't change b/c cfg is app level; DATE:2013-07-14
}
}
class Xoa_cfg_mgr_fxt {
public void Clear() {
// if (app == null) {
app = Xoa_app_fxt.app_();
cfg_mgr = app.Cfg_mgr();
// }
} private Xoae_app app; Xoa_cfg_mgr cfg_mgr;
public void Init_cfg_all(String key, String val) {Init_cfg(key, val, Xoa_cfg_grp_tid.Key_all_bry);}
public void Init_cfg_app(String key, String val) {Init_cfg(key, val, Xoa_cfg_grp_tid.Key_app_bry);}
private void Init_cfg(String key, String val, byte[] tid) {
Xoa_cfg_itm itm = app.Cfg_mgr().Get_itm_or_make(Bry_.new_a7(key), tid);
itm.Val_(val);
}
public Xowe_wiki Exec_make_wiki(String wiki_key_str) {return Exec_make_wiki(Bry_.new_a7(wiki_key_str));}
public Xowe_wiki Exec_make_wiki(byte[] wiki_key_bry) {return app.Wiki_mgr().Get_by_key_or_make(wiki_key_bry);}
public void Test_init_wiki(String wiki_key_str, String itm_key_str, String expd_val) {
byte[] wiki_key_bry = Bry_.new_a7(wiki_key_str);
Xowe_wiki wiki = Exec_make_wiki(wiki_key_bry);
wiki.Init_assert();
Test_cfg_get(wiki, itm_key_str, expd_val);
}
public void Test_cfg_set(String cfg_msg, String wiki_key_str, String prop_key, String expd_val) {
byte[] wiki_key_bry = Bry_.new_a7(wiki_key_str);
app.Gfs_mgr().Run_str_for(app, cfg_msg);
Xowe_wiki wiki = Exec_make_wiki(wiki_key_bry);
Test_cfg_get(wiki, prop_key, expd_val);
}
private void Test_cfg_get(GfoInvkAble invk, String prop, String expd) {
Tfds.Eq(expd, Object_.Xto_str_strict_or_null_mark(app.Cfg_mgr().Eval_get(invk, prop)));
}
public void Test_cfg_itm(String wiki, String prop, boolean expd_customized, boolean expd_dirty) {
Test_cfg_itm(Bry_.new_a7(wiki), Bry_.new_a7(prop), expd_customized, expd_dirty);
}
public void Test_cfg_itm(byte[] wiki, byte[] prop, boolean expd_customized, boolean expd_dirty) {
Xoa_cfg_itm itm = cfg_mgr.Get_itm_or_make(prop, wiki);
Tfds.Eq(itm.Val_is_customized(), expd_customized);
Tfds.Eq(itm.Val_is_dirty(), expd_dirty);
}
public void Test_save(String expd) {
Xoa_cfg_db_txt db = new Xoa_cfg_db_txt();
cfg_mgr.Db_save(db);
Tfds.Eq(expd, Io_mgr.Instance.LoadFilStr(db.Cfg_url(cfg_mgr)));
}
}

View 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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.parsers.lnkis.cfgs.*;
public class Xowc_parser implements GfoInvkAble {
public Xowc_parser(Xowe_wiki wiki) {
lnki_cfg = new Xoc_lnki_cfg(wiki);
}
public Xoc_lnki_cfg Lnki_cfg() {return lnki_cfg;} private Xoc_lnki_cfg lnki_cfg;
public Xowc_xtns Xtns() {return xtns;} private Xowc_xtns xtns = new Xowc_xtns();
public boolean Display_title_restrict() {return display_title_restrict;} public void Display_title_restrict_(boolean v) {display_title_restrict = v;} private boolean display_title_restrict = true;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_xtns)) return xtns;
else if (ctx.Match(k, Invk_lnki)) return lnki_cfg;
else if (ctx.Match(k, Invk_display_title_restrict)) return display_title_restrict;
else if (ctx.Match(k, Invk_display_title_restrict_)) display_title_restrict = m.ReadYn("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_xtns = "xtns", Invk_lnki = "lnki", Invk_display_title_restrict = "display_title_restrict", Invk_display_title_restrict_ = "display_title_restrict_";
}

View File

@@ -0,0 +1,81 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.wikis.nss.*;
public class Xowc_xtn_pages implements GfoInvkAble {
public boolean Init_needed() {return init_needed;} private boolean init_needed = true;
public int Ns_page_id() {return ns_page_id;} private int ns_page_id = Int_.Min_value;
public int Ns_page_talk_id() {return ns_page_talk_id;} private int ns_page_talk_id = Int_.Min_value;
public int Ns_index_id() {return ns_index_id;} private int ns_index_id = Int_.Min_value;
public int Ns_index_talk_id() {return ns_index_talk_id;} private int ns_index_talk_id = Int_.Min_value;
public void Ns_names_(byte[] page_name, byte[] page_talk_name, byte[] index_name, byte[] index_talk_name) {
this.page_name = page_name; this.page_talk_name = page_talk_name; this.index_name = index_name; this.index_talk_name = index_talk_name;
}
private byte[]
page_name = Default_ns_page_name
, page_talk_name = Default_ns_page_talk_name
, index_name = Default_ns_index_name
, index_talk_name = Default_ns_index_talk_name;
public void Reset() {
ns_page_id = ns_page_talk_id = ns_index_id = ns_index_talk_id = Int_.Min_value;
init_needed = true;
}
public void Init(Xow_ns_mgr ns_mgr) {
init_needed = false;
int len = ns_mgr.Ords_len();
for (int i = 0; i < len; i++) { // Page / Index ns_ids are variable per wiki; iterate over ns, and set ns_id
Xow_ns ns = ns_mgr.Ords_get_at(i); if (ns == null) continue;
byte[] ns_name = ns.Name_enc();
if (Bry_.Eq(ns_name, page_name)) {ns_page_id = ns.Id(); ns_mgr.Ns_page_id_(ns_page_id);}
else if (Bry_.Eq(ns_name, page_talk_name)) ns_page_talk_id = ns.Id();
else if (Bry_.Eq(ns_name, index_name)) ns_index_id = ns.Id();
else if (Bry_.Eq(ns_name, index_talk_name)) ns_index_talk_id = ns.Id();
}
int aliases_added = 0;
aliases_added = Set_canonical(ns_mgr, aliases_added, ns_page_id , Default_ns_page_name);
aliases_added = Set_canonical(ns_mgr, aliases_added, ns_page_talk_id , Default_ns_page_talk_name);
aliases_added = Set_canonical(ns_mgr, aliases_added, ns_index_id , Default_ns_index_name);
aliases_added = Set_canonical(ns_mgr, aliases_added, ns_index_talk_id , Default_ns_index_talk_name);
if (aliases_added > 0) // NOTE: will probably only be 0 for English Wikisource
ns_mgr.Init_w_defaults();
}
private int Set_canonical(Xow_ns_mgr ns_mgr, int aliases_added, int id, byte[] name) {
Xow_ns ns = ns_mgr.Ids_get_or_null(id);
if ( ns == null // ns doesn't exist; should throw error;
|| !Bry_.Eq(ns.Name_bry(), name) // ns exists, but name doesn't match canonical
) {
ns_mgr.Aliases_add(id, String_.new_a7(name));
++aliases_added;
}
return aliases_added;
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_ns_names_)) Ns_names_(m.ReadBry("page"), m.ReadBry("page_talk"), m.ReadBry("index"), m.ReadBry("index_talk"));
else return GfoInvkAble_.Rv_unhandled;
return this;
} private static final String Invk_ns_names_ = "ns_names_";
public static final byte[] Xtn_key = Bry_.new_a7("pages");
public static final int Ns_index_id_default = 102, Ns_page_id_default = 104;
private static final byte[]
Default_ns_page_name = Bry_.new_a7("Page")
, Default_ns_page_talk_name = Bry_.new_a7("Page_talk")
, Default_ns_index_name = Bry_.new_a7("Index")
, Default_ns_index_talk_name = Bry_.new_a7("Index_talk")
;
}

View File

@@ -0,0 +1,65 @@
/*
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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import org.junit.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.nss.*;
public class Xowc_xtn_pages_tst {
@Before public void init() {fxt.Clear();} private Xowc_xtn_pages_fxt fxt = new Xowc_xtn_pages_fxt();
@Test public void Init() {
fxt.Init_ns(200, "Foreign_page").Init_ns(201, "Foreign_page_talk").Init_ns(202, "Foreign_index").Init_ns(203, "Foreign_index_talk"); // ns set by <siteinfo>
fxt.Init_names("Foreign_page", "Foreign_page_talk", "Foreign_index", "Foreign_index_talk"); // ns set by .gfs files in /user/wiki/#cfg
fxt.Exec_init();
fxt.Test_ns_ids(200, 201, 202, 203);
fxt.Test_ns_canonical("Page", "Page_talk", "Index", "Index_talk");
}
}
class Xowc_xtn_pages_fxt {
private Xow_ns_mgr ns_mgr;
private Xowc_xtn_pages cfg_pages;
public void Clear() {
ns_mgr = Xow_ns_mgr_.default_(gplx.xowa.langs.cases.Xol_case_mgr_.A7());
cfg_pages = new Xowc_xtn_pages();
}
public Xowc_xtn_pages_fxt Init_ns(int id, String name) {
ns_mgr.Add_new(id, name);
return this;
}
public void Init_names(String page_name, String page_talk_name, String index_name, String index_talk_name) {
cfg_pages.Ns_names_(Bry_.new_a7(page_name), Bry_.new_a7(page_talk_name), Bry_.new_a7(index_name), Bry_.new_a7(index_talk_name));
}
public void Exec_init() {
ns_mgr.Init_w_defaults(); // init ns_msg
cfg_pages.Init(ns_mgr); // init cfg
}
public void Test_ns_ids(int page_id, int page_talk_id, int index_id, int index_talk_id) {
Tfds.Eq(page_id , cfg_pages.Ns_page_id());
Tfds.Eq(page_talk_id , cfg_pages.Ns_page_talk_id());
Tfds.Eq(index_id , cfg_pages.Ns_index_id());
Tfds.Eq(index_talk_id , cfg_pages.Ns_index_talk_id());
}
public void Test_ns_canonical(String page_name, String page_talk_name, String index_name, String index_talk_name) {
Test_ns_canonical_itm(page_name , cfg_pages.Ns_page_id());
Test_ns_canonical_itm(page_talk_name , cfg_pages.Ns_page_talk_id());
Test_ns_canonical_itm(index_name , cfg_pages.Ns_index_id());
Test_ns_canonical_itm(index_talk_name , cfg_pages.Ns_index_talk_id());
}
private void Test_ns_canonical_itm(String name, int expd_ns_id) {
Xow_ns ns = ns_mgr.Names_get_or_null(Bry_.new_a7(name));
int actl_ns_id = ns == null ? Int_.Min_value : ns.Id();
Tfds.Eq(expd_ns_id, actl_ns_id);
}
}

View 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.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xowc_xtns implements GfoInvkAble {
private Hash_adp_bry hash = Hash_adp_bry.ci_a7();
public Xowc_xtns() {hash.Add(Xowc_xtn_pages.Xtn_key, itm_pages);}
public Xowc_xtn_pages Itm_pages() {return itm_pages;} private Xowc_xtn_pages itm_pages = new Xowc_xtn_pages();
public Object Get_by_key(byte[] key) {return hash.Get_by_bry(key);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return (GfoInvkAble)hash.Get_by_bry(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
} private static final String Invk_get = "get";
}

View File

@@ -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.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_gui_mgr implements GfoInvkAble {
public Xocfg_gui_mgr(Xoae_app app) {
win_cfg = new Xocfg_win(app);
}
public Xocfg_win Win() {return win_cfg;} private Xocfg_win win_cfg;
public Xocfg_html Html() {return html_cfg;} private Xocfg_html html_cfg = new Xocfg_html();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_win)) return win_cfg;
else if (ctx.Match(k, Invk_html)) return html_cfg;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_win = "win", Invk_html = "html";
}

View File

@@ -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.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_html implements GfoInvkAble {
public Xocfg_html() {
this.content_editable = false; // CFG: default to false for general user
}
public boolean Content_editable() {return content_editable;} public Xocfg_html Content_editable_(boolean v) {content_editable = v; return this;} private boolean content_editable;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_content_editable)) return Yn.To_str(content_editable);
else if (ctx.Match(k, Invk_content_editable_)) content_editable = m.ReadYn_toggle("v", content_editable);
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_content_editable = "content_editable", Invk_content_editable_ = "content_editable_";
}

View File

@@ -0,0 +1,106 @@
/*
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.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
class Test_api implements GfoInvkAble {
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_meta)) return meta_mgr.Get_or_null(m.ReadStr("v"));
else return GfoInvkAble_.Rv_unhandled;
// return this;
} private static final String Invk_meta = "meta";
private static final String Invk_prop_1 = "prop_1", Invk_prop_2 = "prop_2", Invk_prop_3 = "prop_3", Invk_prop_bry = "bry", Invk_prop_enm = "enm";
private static final boolean Dflt_prop_1 = false;
private static final int Dflt_prop_2 = 2;
private static final String Dflt_prop_3 = "3";
private static final byte[] Dflt_prop_bry = Bry_.new_a7("bry");
private static final int Dflt_prop_enm = 5;
private static final Xocfg_meta_mgr meta_mgr = new Xocfg_meta_mgr().Add
( Xocfg_meta_itm_.bool_ (Invk_prop_1, Dflt_prop_1)
, Xocfg_meta_itm_.int_ (Invk_prop_2, Dflt_prop_2).Rng_bgn_(-1)
, Xocfg_meta_itm_.str_ (Invk_prop_3, Dflt_prop_3)
, Xocfg_meta_itm_.bry_ (Invk_prop_bry, Dflt_prop_bry)
, Xocfg_meta_itm_.enm_ (Invk_prop_enm, Dflt_prop_enm).Itms_list_("a", "b", "c")
, Xocfg_meta_itm_.str_ (Invk_prop_3, Dflt_prop_3).Gui_itm_(Xocfg_gui_itm_.memo_(40, 60))
// , Xocfg_meta_itm_.enum_ (Invk_prop_3, Dflt_prop_3).Add("a", "b").Add("b", "c").Data(Xocfg_gui.list("a"))
)
;
}
interface Xocfg_gui_itm {
}
class Xocfg_gui_itm_ {
public static Xocfg_gui_itm_memo memo_(int box_w, int box_h) {return new Xocfg_gui_itm_memo(box_w, box_h);}
}
class Xocfg_gui_itm_fld {
}
class Xocfg_gui_itm_memo implements Xocfg_gui_itm {
public Xocfg_gui_itm_memo(int box_w, int box_h) {this.box_w = box_w; this.box_h = box_h;}
public int Box_w() {return box_w;} private int box_w;
public int Box_h() {return box_h;} private int box_h;
}
class Xocfg_meta_mgr {
private Hash_adp hash = Hash_adp_.new_();
public Xocfg_meta_mgr Add(Xocfg_meta_itm_base... ary) {
int len = ary.length;
for (int i = 0; i < len; i++) {
Xocfg_meta_itm_base itm = (Xocfg_meta_itm_base)ary[i];
hash.Add(itm.Prop_key(), itm);
}
return this;
}
public Xocfg_meta_itm_base Get_or_null(String key) {return (Xocfg_meta_itm_base)hash.Get_by(key);}
}
abstract class Xocfg_meta_itm_base {
public void Set(int prop_type, String prop_key, Object prop_dflt) {
this.prop_key = prop_key; this.prop_type = prop_type; this.prop_dflt = prop_dflt;
}
public String Prop_key() {return prop_key;} private String prop_key;
public Object Prop_dflt() {return prop_dflt;} private Object prop_dflt;
public int Prop_type() {return prop_type;} private int prop_type;
}
class Xocfg_meta_itm_ {
public static Xocfg_meta_itm_bool bool_(String key, boolean dflt) {return new Xocfg_meta_itm_bool(key, dflt);}
public static Xocfg_meta_itm_int int_(String key, int dflt) {return new Xocfg_meta_itm_int(key, dflt);}
public static Xocfg_meta_itm_str str_(String key, String dflt) {return new Xocfg_meta_itm_str(key, dflt);}
public static Xocfg_meta_itm_bry bry_(String key, byte[] dflt) {return new Xocfg_meta_itm_bry(key, dflt);}
public static Xocfg_meta_itm_enm enm_(String key, int dflt) {return new Xocfg_meta_itm_enm(key, dflt);}
}
class Xodfg_pref_itm_type_ {
public static final int Tid_bool = 1, Tid_int = 2, Tid_str = 3, Tid_bry = 4, Tid_enm = 5;
}
class Xocfg_meta_itm_bool extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_bool(String prop_key, boolean prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_bool, prop_key, prop_dflt);}
}
class Xocfg_meta_itm_int extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_int(String prop_key, int prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_int, prop_key, prop_dflt);}
public Xocfg_meta_itm_int Rng_bgn_(int bgn) {return Rng_(bgn, Int_.Max_value);}
public Xocfg_meta_itm_int Rng_(int bgn, int end) {
return this;
}
}
class Xocfg_meta_itm_str extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_str(String prop_key, String prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_str, prop_key, prop_dflt);}
public Xocfg_gui_itm Gui_itm() {return gui_itm;} public Xocfg_meta_itm_base Gui_itm_(Xocfg_gui_itm v) {gui_itm = v; return this;} private Xocfg_gui_itm gui_itm;
}
class Xocfg_meta_itm_bry extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_bry(String prop_key, byte[] prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_bry, prop_key, prop_dflt);}
}
class Xocfg_meta_itm_enm extends Xocfg_meta_itm_base {
public Xocfg_meta_itm_enm(String prop_key, int prop_dflt) {this.Set(Xodfg_pref_itm_type_.Tid_enm, prop_key, prop_dflt);}
public Xocfg_meta_itm_enm Itms_list_(String... ary) {
return this;
}
}

View File

@@ -0,0 +1,32 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.xowa.guis.langs.*;
public class Xocfg_win implements GfoInvkAble {
public Xocfg_win(Xoae_app app) {}
public Xol_font_info Font() {return font;} private Xol_font_info font = new Xol_font_info("Arial", 8, gplx.gfui.FontStyleAdp_.Plain);
public Bry_fmtr Search_box_fmtr() {return search_box_fmtr;} private Bry_fmtr search_box_fmtr = Bry_fmtr.new_("Special:Allpages?from=", "search");
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_font)) return font;
else if (ctx.Match(k, Invk_search_box_fmt_)) search_box_fmtr.Fmt_(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_search_box_fmt_ = "search_box_fmt_", Invk_font = "font";
public static final float Font_size_default = 8;
}

View File

@@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xow_gui_mgr implements GfoInvkAble {
public Xocfg_html Cfg_browser() {return cfg_browser;} private Xocfg_html cfg_browser = new Xocfg_html();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_cfg_browser)) return cfg_browser;
else return GfoInvkAble_.Rv_unhandled;
} private static final String Invk_cfg_browser = "cfg_browser";
}

View File

@@ -0,0 +1,59 @@
/*
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.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.gfui.*; import gplx.xowa.guis.bnds.*; import gplx.xowa.guis.cmds.*;
import gplx.langs.gfs.*; import gplx.xowa.apps.*;
public class Xocfg_bnd_itm implements GfoInvkAble {
private Xocfg_bnd_mgr mgr;
public Xocfg_bnd_itm(Xocfg_bnd_mgr mgr, Xog_cmd_itm cmd, Xog_bnd_itm bnd) {
this.mgr = mgr; this.cmd = cmd; this.bnd = bnd;
}
public Xog_bnd_itm Bnd() {return bnd;} private Xog_bnd_itm bnd;
public Xog_cmd_itm Cmd() {return cmd;} private Xog_cmd_itm cmd;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_cmd_name)) return cmd.Name_or_missing();
else if (ctx.Match(k, Invk_cmd_tip)) return cmd.Tip_or_missing();
else if (ctx.Match(k, Invk_cmd_uid)) return cmd.Uid();
else if (ctx.Match(k, Invk_cmd_ctg_name)) return cmd.Ctg().Name();
else if (ctx.Match(k, Invk_cmd_ctg_sort)) return cmd.Ctg().Tid();
else if (ctx.Match(k, Invk_bnd_key)) return bnd.Key();
else if (ctx.Match(k, Invk_bnd_uid)) return bnd.Uid();
else if (ctx.Match(k, Invk_bnd_sys)) return Yn.To_str(bnd.Sys());
else if (ctx.Match(k, Invk_bnd_cmd)) return bnd.Cmd();
else if (ctx.Match(k, Invk_bnd_cmd_)) bnd.Cmd_(m.ReadStr("v"));
else if (ctx.Match(k, Invk_bnd_box)) return Xog_bnd_box_.Xto_gui_str(bnd.Box());
else if (ctx.Match(k, Invk_bnd_box_idx)) return bnd.Box();
else if (ctx.Match(k, Invk_bnd_ipt)) return mgr.Bnd_mgr().Bnd_parser().Xto_norm(bnd.Ipt().Key());
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_cmd_uid = "cmd_uid"
, Invk_cmd_name = "cmd_name"
, Invk_cmd_tip = "cmd_tip"
, Invk_cmd_ctg_name = "cmd_ctg_name"
, Invk_cmd_ctg_sort = "cmd_ctg_sort"
, Invk_bnd_key = "bnd_key"
, Invk_bnd_uid = "bnd_uid"
, Invk_bnd_sys = "bnd_sys"
, Invk_bnd_box = "bnd_box"
, Invk_bnd_box_idx = "bnd_box_idx"
, Invk_bnd_ipt = "bnd_ipt"
, Invk_bnd_cmd = "bnd_cmd", Invk_bnd_cmd_ = "bnd_cmd_"
;
}

View 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.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.gfui.*; import gplx.xowa.guis.bnds.*;
import gplx.langs.gfs.*; import gplx.xowa.apps.gfs.*;
public class Xocfg_bnd_itm_srl implements GfoInvkAble {
private Xoae_app app;
public Xocfg_bnd_itm_srl(Xoae_app app, String key) {
this.app = app;
this.key = key;
}
public String Key() {return key;} private String key;
public int Box() {return box;} private int box;
public IptArg Ipt() {return ipt;} private IptArg ipt;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_src_)) Src_(app, this, m.ReadStr("v"));
else if (ctx.Match(k, Invk_box_)) box = Xog_bnd_box_.Xto_sys_int(m.ReadStr("v"));
else if (ctx.Match(k, Invk_ipt_)) ipt = IptArg_.parse(m.ReadStr("v"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_src_ = "src_", Invk_box_ = "box_", Invk_ipt_ = "ipt_";
public static String Src(Xoae_app app, int box, IptArg ipt) { // box_('browser').ipt_('mod.c+key.q');
Gfs_wtr wtr = app.Gfs_mgr().Wtr();
wtr.Add_set_eq(Key_box, Bry_.new_a7(Xog_bnd_box_.Xto_sys_str(box)));
wtr.Add_set_eq(Key_ipt, Bry_.new_a7(ipt.Key()));
return wtr.Bfr().To_str_and_clear();
} private static final byte[] Key_box = Bry_.new_a7("box"), Key_ipt = Bry_.new_a7("ipt");
public static void Src_(Xoae_app app, Xocfg_bnd_itm_srl itm, String v) {
Xoa_gfs_mgr gfs_mgr = app.Gfs_mgr();
gfs_mgr.Run_str_for(itm, v);
Xog_bnd_itm bnd = app.Gui_mgr().Bnd_mgr().Get_or_null(itm.Key());
if (bnd != null) // should not happen, but guard against backward compatibility issues (deprecating old bindings)
app.Gui_mgr().Bnd_mgr().Set(bnd, itm.Box(), itm.Ipt());
}
}

View File

@@ -0,0 +1,69 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.gfui.*; import gplx.xowa.guis.bnds.*; import gplx.xowa.guis.cmds.*;
import gplx.xowa.apps.fmtrs.*;
public class Xocfg_bnd_mgr implements GfoInvkAble, Gfo_sort_able {
private Xog_bnd_mgr_srl bnd_mgr_srl; private Xog_cmd_mgr cmd_mgr;
private Xoa_fmtr_sort_mgr sorter;
public Xocfg_bnd_mgr(Xoae_app app) {
this.app = app; this.bnd_mgr = app.Gui_mgr().Bnd_mgr(); this.cmd_mgr = app.Gui_mgr().Cmd_mgr();
bnd_mgr_srl = new Xog_bnd_mgr_srl(app, bnd_mgr);
sorter = new Xoa_fmtr_sort_mgr(this);
}
public Xoae_app App() {return app;} private Xoae_app app;
public Xog_bnd_mgr Bnd_mgr() {return bnd_mgr;} private Xog_bnd_mgr bnd_mgr;
private Ordered_hash regy;
public void Init() {
regy = Ordered_hash_.New();
int len = bnd_mgr.Len();
for (int i = 0; i < len; i++) {
Xog_bnd_itm bnd = bnd_mgr.Get_at(i);
Xog_cmd_itm cmd = cmd_mgr.Get_or_null(bnd.Cmd()); if (cmd == null) throw Err_.new_unhandled(bnd.Cmd());
Xocfg_bnd_itm cfg_itm = new Xocfg_bnd_itm(this, cmd, bnd);
regy.Add(bnd.Key(), cfg_itm);
}
}
private Xocfg_bnd_itm_srl Init(String key) {return new Xocfg_bnd_itm_srl(app, key);}
public Xocfg_bnd_itm Get_at(int i) {return (Xocfg_bnd_itm)regy.Get_at(i);}
public int Len() {return regy.Count();}
public void Sort(gplx.lists.ComparerAble comparer) {regy.Sort_by(comparer);}
private void Set_bulk(byte[] src) {
try {
bnd_mgr_srl.Load_by_bry(src);
}
catch (Exception e) { // catch errors, so that next cmd (which is page.reload) can still execute
app.Usr_dlg().Warn_many("", "", "failed to set bnds; src=~{0} err=~{1}", String_.new_u8(src), Err_.Message_gplx_full(e));
}
}
private void Show_shortcut_win(String uid, String name, String binding) {
Xog_bnd_win win = new Xog_bnd_win();
win.Show(app.Gui_mgr().Kit(), app.Gui_mgr().Browser_win().Win_box(), bnd_mgr.Bnd_parser(), name, binding);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Xoa_fmtr_itm.Invk_get_at)) return this.Get_at(m.ReadInt("v"));
else if (ctx.Match(k, Xoa_fmtr_itm.Invk_len)) return this.Len();
else if (ctx.Match(k, Xoa_fmtr_itm.Invk_sorter)) return sorter;
else if (ctx.Match(k, Invk_set_bulk)) Set_bulk(m.ReadBry("v"));
else if (ctx.Match(k, Invk_init)) return Init(m.ReadStr("v"));
else if (ctx.Match(k, Invk_show_shortcut_win)) Show_shortcut_win(m.ReadStr("uid"), m.ReadStr("name"), m.ReadStr("binding"));
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_set_bulk = "set_bulk", Invk_init = "init", Invk_show_shortcut_win = "show_shortcut_win";
}

View File

@@ -0,0 +1,29 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_gui_mgr implements GfoInvkAble {
public Xocfg_gui_mgr(Xoae_app app) {bnd_mgr = new Xocfg_bnd_mgr(app);}
public Xocfg_tab_mgr Tab_mgr() {return tab_mgr;} private Xocfg_tab_mgr tab_mgr = new Xocfg_tab_mgr();
public Xocfg_bnd_mgr Bnd_mgr() {return bnd_mgr;} private Xocfg_bnd_mgr bnd_mgr;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_tabs)) return tab_mgr;
else if (ctx.Match(k, Invk_bnds)) return bnd_mgr;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_tabs = "tabs", Invk_bnds = "bnds";
}

View 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.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_regy implements GfoInvkAble {
public Xocfg_regy(Xoae_app app) {
app_cfg = new Xocfg_root(app, Xocfg_root_.Tid_app);
}
public Xocfg_root App() {return app_cfg;} private Xocfg_root app_cfg;
public Xocfg_root Get_or_null(String key) {
if (String_.Eq(key, Key_app)) return app_cfg;
else throw Err_.new_unhandled(key);
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get_or_null(m.ReadStrOr("v", Key_app));
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_get = "get";
public static final String Key_app = null;
}

View File

@@ -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.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_root implements GfoInvkAble {
public Xocfg_root(Xoae_app app, byte tid) {
this.tid = tid;
this.gui_mgr = new Xocfg_gui_mgr(app);
}
public byte Tid() {return tid;} private byte tid;
public Xocfg_gui_mgr Gui_mgr() {return gui_mgr;} private Xocfg_gui_mgr gui_mgr;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_gui)) return gui_mgr;
else return GfoInvkAble_.Rv_unhandled;
}
private static final String Invk_gui = "gui";
}

View File

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

View File

@@ -0,0 +1,69 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
import gplx.xowa.guis.views.*;
public class Xocfg_tab_btn_mgr implements GfoInvkAble, GfoEvMgrOwner {
public Xocfg_tab_btn_mgr() {
evMgr = GfoEvMgr.new_(this);
}
public GfoEvMgr EvMgr() {return evMgr;} private GfoEvMgr evMgr;
public int Height() {return height;} private int height = 20;
public boolean Place_on_top() {return place_on_top;} private boolean place_on_top = true;
public boolean Curved() {return curved;} private boolean curved = false;
public boolean Close_visible() {return close_visible;} private boolean close_visible = true;
public boolean Unselected_close_visible() {return unselected_close_visible;} private boolean unselected_close_visible = true;
public int Text_min_chars() {return text_min_chars;} public Xocfg_tab_btn_mgr Text_min_chars_(int v) {text_min_chars = v; return this;} private int text_min_chars = -1;
public int Text_max_chars() {return text_max_chars;} public Xocfg_tab_btn_mgr Text_max_chars_(int v) {text_max_chars = v; return this;} private int text_max_chars = 40;
public boolean Hide_if_one() {return hide_if_one;} public Xocfg_tab_btn_mgr Hide_if_one_(boolean v) {hide_if_one = v; return this;} private boolean hide_if_one;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_place_on_top)) return Yn.To_str(place_on_top);
else if (ctx.Match(k, Invk_place_on_top_)) {place_on_top = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_place_on_top_changed, place_on_top);}
else if (ctx.Match(k, Invk_curved)) return Yn.To_str(curved);
else if (ctx.Match(k, Invk_curved_)) {curved = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_curved_changed, curved);}
else if (ctx.Match(k, Invk_height)) return height;
else if (ctx.Match(k, Invk_height_)) {height = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_height_changed, height);}
else if (ctx.Match(k, Invk_close_visible)) return Yn.To_str(close_visible);
else if (ctx.Match(k, Invk_close_visible_)) {close_visible = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_close_visible_changed, close_visible);}
else if (ctx.Match(k, Invk_unselected_close_visible)) return Yn.To_str(unselected_close_visible);
else if (ctx.Match(k, Invk_unselected_close_visible_)) {unselected_close_visible = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_unselected_close_visible_changed, unselected_close_visible);}
else if (ctx.Match(k, Invk_text_min_chars)) return text_min_chars;
else if (ctx.Match(k, Invk_text_min_chars_)) {text_min_chars = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_text_min_chars_changed, text_min_chars);}
else if (ctx.Match(k, Invk_text_max_chars)) return text_max_chars;
else if (ctx.Match(k, Invk_text_max_chars_)) {text_max_chars = m.ReadInt("v"); GfoEvMgr_.PubVal(this, Evt_text_max_chars_changed, text_max_chars);}
else if (ctx.Match(k, Invk_hide_if_one)) return Yn.To_str(hide_if_one);
else if (ctx.Match(k, Invk_hide_if_one_)) {hide_if_one = m.ReadYn("v"); GfoEvMgr_.PubVal(this, Evt_hide_if_one_changed, hide_if_one);}
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String
Invk_place_on_top = "place_on_top", Invk_place_on_top_ = "place_on_top_"
, Invk_curved = "curved", Invk_curved_ = "curved_"
, Invk_height = "height", Invk_height_ = "height_"
, Invk_close_visible = "close_visible", Invk_close_visible_ = "close_visible_"
, Invk_unselected_close_visible = "unselected_close_visible", Invk_unselected_close_visible_ = "unselected_close_visible_"
, Invk_text_min_chars = "text_min_chars", Invk_text_min_chars_ = "text_min_chars_"
, Invk_text_max_chars = "text_max_chars", Invk_text_max_chars_ = "text_max_chars_"
, Invk_hide_if_one = "hide_if_one", Invk_hide_if_one_ = "hide_if_one_"
;
public static final String
Evt_place_on_top_changed = "place_on_top_changed", Evt_curved_changed = "curved_changed", Evt_height_changed = "height_changed"
, Evt_close_visible_changed = "close_visible_changed", Evt_unselected_close_visible_changed = "unselected_close_visible_changed"
, Evt_text_min_chars_changed = "text_min_chars_changed", Evt_text_max_chars_changed = "text_max_chars_changed"
, Evt_hide_if_one_changed = "hide_if_one_changed"
;
}

View File

@@ -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.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_tab_mgr implements GfoInvkAble {
public Xocfg_tab_new_mgr New_mgr() {return new_mgr;} private Xocfg_tab_new_mgr new_mgr = new Xocfg_tab_new_mgr();
public Xocfg_tab_btn_mgr Btn_mgr() {return btn_mgr;} private Xocfg_tab_btn_mgr btn_mgr = new Xocfg_tab_btn_mgr();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_new)) return new_mgr;
else if (ctx.Match(k, Invk_btns)) return btn_mgr;
else return GfoInvkAble_.Rv_unhandled;
} private static final String Invk_new = "new", Invk_btns = "btns";
}

View File

@@ -0,0 +1,50 @@
/*
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.cfgs.old; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*; import gplx.xowa.apps.cfgs.*;
public class Xocfg_tab_new_mgr implements GfoInvkAble {
public byte Insert_pos() {return insert_pos;} private byte insert_pos = Xocfg_new_tab_pos.Tid_cur_nxt;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_insert_pos)) return Xocfg_new_tab_pos.Xto_str(insert_pos);
else if (ctx.Match(k, Invk_insert_pos_)) insert_pos = Xocfg_new_tab_pos.Xto_tid(m.ReadStr("v"));
else if (ctx.Match(k, Invk_insert_pos_list)) return Xocfg_new_tab_pos.Options__all;
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_insert_pos = "insert_pos", Invk_insert_pos_ = "insert_pos_", Invk_insert_pos_list = "insert_pos_list";
}
class Xocfg_new_tab_pos {
public static final byte Tid_all_bgn = 0, Tid_all_end = 1, Tid_cur_prv = 2, Tid_cur_nxt = 3;
public static final String Key_all_bgn = "first", Key_all_end = "last", Key_cur_prv = "before", Key_cur_nxt = "after";
public static byte Xto_tid(String v) {
if (String_.Eq(v, Key_all_bgn)) return Tid_all_bgn;
else if (String_.Eq(v, Key_all_end)) return Tid_all_end;
else if (String_.Eq(v, Key_cur_prv)) return Tid_all_end;
else if (String_.Eq(v, Key_cur_nxt)) return Tid_all_end;
else throw Err_.new_unhandled(v);
}
public static String Xto_str(byte v) {
switch (v) {
case Tid_all_bgn: return Key_all_bgn;
case Tid_all_end: return Key_all_end;
case Tid_cur_prv: return Key_cur_prv;
case Tid_cur_nxt: return Key_cur_nxt;
default: throw Err_.new_unhandled(v);
}
}
public static KeyVal[] Options__all = KeyVal_.Ary(KeyVal_.new_(Key_all_bgn), KeyVal_.new_(Key_all_end), KeyVal_.new_(Key_cur_prv), KeyVal_.new_(Key_cur_nxt));
}

View File

@@ -35,7 +35,7 @@ public class Xoa_fmtr_itm implements GfoInvkAble {
eval_mgr.Invk_(itm_invk);
fmtr.Bld_bfr(bfr, Bry_.Ary_empty);
}
return bfr.Xto_str_and_clear();
return bfr.To_str_and_clear();
}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_src)) return src;

View File

@@ -31,7 +31,7 @@ class Xoa_fmtr_itm_fxt {
app = Xoa_app_fxt.app_();
Xoa_app_fxt.wiki_tst_(app); // create enwiki
itm = new Xoa_fmtr_itm(app);
GfsCore._.MsgParser_(gplx.langs.gfss.Gfs_msg_bldr._);
GfsCore.Instance.MsgParser_(gplx.langs.gfs.Gfs_msg_bldr.Instance);
}
public Xoa_fmtr_itm_fxt Init_src(String v) {itm.Src_(v); return this;}
public Xoa_fmtr_itm_fxt Init_fmt(String v) {itm.Fmt_(Bry_.new_a7(v)); return this;}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.fmtrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_fmtr_sort_mgr implements GfoInvkAble {
private Ordered_hash itms = Ordered_hash_.new_();
private Ordered_hash itms = Ordered_hash_.New();
private Xoa_fmtr_sort_wkr wkr = new Xoa_fmtr_sort_wkr();
private Gfo_sort_able sort_able;
public Xoa_fmtr_sort_mgr(Gfo_sort_able sort_able) {this.sort_able = sort_able;}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.apps.fsys; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
import gplx.xowa.apps.gfss.*;
import gplx.xowa.apps.gfs.*;
import gplx.xowa.wikis.domains.*;
public class Xoa_fsys_mgr implements GfoInvkAble {
public Xoa_fsys_mgr(String plat_name, Io_url root_dir, Io_url wiki_dir, Io_url file_dir, Io_url css_dir) {

Some files were not shown because too many files have changed in this diff Show More