mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.4.1'
This commit is contained in:
21
400_xowa/src/gplx/xowa/addons/Xoax_addon_itm__json.java
Normal file
21
400_xowa/src/gplx/xowa/addons/Xoax_addon_itm__json.java
Normal 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.addons; import gplx.*; import gplx.xowa.*;
|
||||
public interface Xoax_addon_itm__json {
|
||||
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] Json__cmds();
|
||||
}
|
||||
@@ -17,6 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public interface Xoax_addon_itm__sp {
|
||||
public interface Xoax_addon_itm__special {
|
||||
gplx.xowa.specials.Xows_page[] Pages_ary();
|
||||
}
|
||||
@@ -35,13 +35,20 @@ public class Xoax_addon_mgr {
|
||||
( gplx.xowa.bldrs.cmds.utils.Xob_alert_cmd.Prototype
|
||||
);
|
||||
app.Addon_mgr().Itms__add_many
|
||||
// bldrs
|
||||
( new gplx.xowa.addons.builds.files .Xoax_builds_files_addon()
|
||||
, new gplx.xowa.addons.builds.pagelinks .Xoax_builds_pagelinks_addon()
|
||||
, new gplx.xowa.addons.builds.utils_rankings .Xoax_builds_utils_rankings_addon()
|
||||
, new gplx.xowa.addons.apps.searchs .Xoax_builds_search_addon()
|
||||
, new gplx.xowa.addons.apps.file_browsers .Fbrow_addon()
|
||||
, new gplx.xowa.addons.updates.files .Xoax_updates_files_addon()
|
||||
, new gplx.xowa.addons.builds.htmls .Html__dump_to_fsys__addon()
|
||||
|
||||
// specials
|
||||
, new gplx.xowa.addons.apps.file_browsers .Fbrow_addon()
|
||||
, new gplx.xowa.addons.updates.downloads .Xoax_downloads_addon()
|
||||
|
||||
// jsons
|
||||
, new gplx.xowa.addons.servers.https .Xoax_long_poll_addon()
|
||||
);
|
||||
return this;
|
||||
}
|
||||
@@ -53,10 +60,17 @@ public class Xoax_addon_mgr {
|
||||
Xoax_addon_itm__bldr addon_bldr = (Xoax_addon_itm__bldr)addon;
|
||||
app.Bldr().Cmd_regy().Add_many(addon_bldr.Cmds_ary());
|
||||
}
|
||||
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__sp.class)) {
|
||||
Xoax_addon_itm__sp addon_sp = (Xoax_addon_itm__sp)addon;
|
||||
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__special.class)) {
|
||||
Xoax_addon_itm__special addon_sp = (Xoax_addon_itm__special)addon;
|
||||
app.Special_regy().Add_many(addon_sp.Pages_ary());
|
||||
}
|
||||
if (Type_adp_.Implements_intf_obj(addon, Xoax_addon_itm__json.class)) {
|
||||
Xoax_addon_itm__json addon_json = (Xoax_addon_itm__json)addon;
|
||||
gplx.xowa.htmls.bridges.Bridge_cmd_itm[] json_cmds = addon_json.Json__cmds();
|
||||
for (gplx.xowa.htmls.bridges.Bridge_cmd_itm json_cmd : json_cmds)
|
||||
app.Html__bridge_mgr().Cmd_mgr().Add(json_cmd);
|
||||
}
|
||||
}
|
||||
app.Gui__cbk_mgr().Reg(gplx.xowa.addons.servers.https.Xog_cbk_wkr__http.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.specials.*;
|
||||
public class Fbrow_addon implements Xoax_addon_itm, Xoax_addon_itm__sp {
|
||||
public class Fbrow_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
|
||||
public Xows_page[] Pages_ary() {
|
||||
return new Xows_page[]
|
||||
{ Fbrow_special_page.Prototype
|
||||
|
||||
@@ -16,9 +16,8 @@ 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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.core.ios.*; import gplx.core.net.*;
|
||||
import gplx.xowa.specials.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Fbrow_special_page implements Xows_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xopage_html_data html_data = Write_html(wiki.App(), url.Qargs_ary());
|
||||
|
||||
@@ -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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.ios.*; import gplx.core.net.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Wikis_list_page implements Xows_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xoa_url_arg_mgr arg_mgr = new Xoa_url_arg_mgr(null).Init(url.Qargs_ary());
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
class Xoa_url_arg_mgr {
|
||||
public class Xoa_url_arg_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
private final Xoa_url_enum_mgr enm_mgr;
|
||||
public Xoa_url_arg_mgr(Xoa_url_enum_mgr enm_mgr) {this.enm_mgr = enm_mgr;}
|
||||
@@ -48,27 +48,3 @@ class Xoa_url_arg_mgr {
|
||||
return arg == null ? null : String_.new_u8(arg.Val_bry());
|
||||
}
|
||||
}
|
||||
class Xoa_url_enum_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_url_enum_mgr(Xoa_url_enum_itm... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_url_enum_itm itm = ary[i];
|
||||
hash.Add_bry_obj(itm.Key(), itm);
|
||||
}
|
||||
}
|
||||
public Xoa_url_enum_itm Get(byte[] key) {return (Xoa_url_enum_itm)hash.Get_by_bry(key);}
|
||||
}
|
||||
class Xoa_url_enum_itm {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_url_enum_itm(byte[] key) {this.key = key;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public Xoa_url_enum_itm Add(String key, int val) {
|
||||
hash.Add_bry_obj(Bry_.new_u8(key), Int_obj_val.new_(val));
|
||||
return this;
|
||||
}
|
||||
public int Get_as_int_or(byte[] val, int or) {
|
||||
Int_obj_val rv = (Int_obj_val)hash.Get_by_bry(val);
|
||||
return rv == null ? or : rv.Val();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
public class Xoa_url_enum_itm {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_url_enum_itm(byte[] key) {this.key = key;}
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public Xoa_url_enum_itm Add(String key, int val) {
|
||||
hash.Add_bry_int(Bry_.new_u8(key), val);
|
||||
return this;
|
||||
}
|
||||
public int Get_as_int_or(byte[] val, int or) {return hash.Get_as_int_or(val, or);}
|
||||
}
|
||||
@@ -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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
public class Xoa_url_enum_mgr {
|
||||
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||
public Xoa_url_enum_mgr(Xoa_url_enum_itm... ary) {
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_url_enum_itm itm = ary[i];
|
||||
hash.Add_bry_obj(itm.Key(), itm);
|
||||
}
|
||||
}
|
||||
public Xoa_url_enum_itm Get(byte[] key) {return (Xoa_url_enum_itm)hash.Get_by_bry(key);}
|
||||
}
|
||||
@@ -1,40 +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.addons.apps.file_browsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xopage_html_data {
|
||||
public Xopage_html_data(byte[] display_ttl, byte[] body) {
|
||||
this.display_ttl = display_ttl;
|
||||
this.body = body;
|
||||
}
|
||||
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
|
||||
public byte[] Body() {return body;} private final byte[] body;
|
||||
public Xopg_tag_mgr Head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr();
|
||||
public Xopg_tag_mgr Tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr();
|
||||
|
||||
public void Apply(Xoa_page page) {
|
||||
page.Html_data().Html_restricted_n_();
|
||||
page.Html_data().Skip_parse_(Bool_.Y);
|
||||
page.Html_data().Display_ttl_(display_ttl);
|
||||
page.Html_data().Custom_body_(this.Body());
|
||||
page.Html_data().Custom_head_tags().Copy(head_tags);
|
||||
page.Html_data().Custom_tail_tags().Copy(head_tags);
|
||||
}
|
||||
|
||||
public static Xopage_html_data err_(String msg) {return new Xopage_html_data(Bry_.Empty, Bry_.new_u8(msg));}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class Xobldr__fsdb_db__create_data extends Xob_cmd__base implements Xob_c
|
||||
this.trg_bin_db_max = app.Api_root().Bldr().Wiki().Import().File_db_max();
|
||||
Io_url trg_file_dir_v1 = String_.Eq(trg_bin_mgr__fsdb_version, "v1") ? wiki.Fsys_mgr().File_dir().GenNewNameOnly(wiki.Domain_str() + "-prv") : wiki.Fsys_mgr().File_dir(); // NOTE: convoluted way of setting trg to -prv if trg_bin_mgr__fsdb_version_v1 is set; otherwise set to "en.wikipedia.org" which will noop; DATE:2015-12-02
|
||||
Fsdb_db_mgr trg_db_mgr = Fsdb_db_mgr_.new_detect(wiki, wiki.Fsys_mgr().Root_dir(), trg_file_dir_v1);
|
||||
if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, Bool_.Y);
|
||||
if (trg_db_mgr == null) trg_db_mgr = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
|
||||
Fsm_mnt_mgr trg_mnt_mgr = new Fsm_mnt_mgr(); trg_mnt_mgr.Ctor_by_load(trg_db_mgr);
|
||||
trg_mnt_mgr.Mnts__get_insert_idx_(Fsm_mnt_mgr.Mnt_idx_main); // NOTE: do not delete; mnt_mgr default to Mnt_idx_user; DATE:2014-04-25
|
||||
this.trg_mnt_itm = trg_mnt_mgr.Mnts__get_insert();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Xobldr__lnki_temp__create extends Xob_dump_mgr_base implements gplx
|
||||
gplx.xowa.xtns.math.Math_nde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y); // enabled; DATE:2015-10-10
|
||||
Xof_fsdb_mgr__sql trg_fsdb_mgr = new Xof_fsdb_mgr__sql();
|
||||
wiki.File__fsdb_mode().Tid_v2_bld_y_();
|
||||
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Instance.Get_or_make(wiki, Bool_.Y);
|
||||
Fsdb_db_mgr__v2 fsdb_core = Fsdb_db_mgr__v2_bldr.Get_or_make(wiki, Bool_.Y);
|
||||
trg_fsdb_mgr.Init_by_wiki(wiki);
|
||||
Fsm_mnt_mgr trg_mnt_mgr = trg_fsdb_mgr.Mnt_mgr();
|
||||
wiki.File_mgr().Init_file_mgr_by_load(wiki); // must happen after fsdb.make
|
||||
|
||||
@@ -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.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
|
||||
public class Http_long_poll_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
|
||||
private final List_adp msgs = List_adp_.new_();
|
||||
private long send_time_prv = 0;
|
||||
public int Sleep_interval = 100;
|
||||
public int Send_interval = 1000;
|
||||
|
||||
public void Send_msg(String msg) {
|
||||
msgs.Add(msg);
|
||||
}
|
||||
public String Exec(gplx.langs.jsons.Json_nde data) {
|
||||
while (true) {
|
||||
if (msgs.Len() == 0) {
|
||||
gplx.core.threads.Thread_adp_.Sleep(Sleep_interval);
|
||||
}
|
||||
else {
|
||||
long send_time_cur = gplx.core.envs.Env_.TickCount();
|
||||
if (send_time_cur - send_time_prv > Send_interval) {
|
||||
send_time_prv = send_time_cur;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return String_.Concat_lines_nl(msgs.To_str_ary_and_clear());
|
||||
}
|
||||
|
||||
public byte[] Key() {return BRIDGE_KEY;}
|
||||
public static final byte[] BRIDGE_KEY = Bry_.new_a7("long_poll");
|
||||
public static final Http_long_poll_cmd Instance = new Http_long_poll_cmd(); Http_long_poll_cmd() {}
|
||||
}
|
||||
@@ -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.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
|
||||
public class Http_send_msg_cmd implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
|
||||
public String Exec(gplx.langs.jsons.Json_nde data) {
|
||||
gplx.langs.jsons.Json_nde jnde = (gplx.langs.jsons.Json_nde)data.Get_as_itm_or_null(Bry_.new_a7("msg"));
|
||||
Http_long_poll_cmd.Instance.Send_msg(jnde.Print_as_json());
|
||||
return "{}";
|
||||
}
|
||||
|
||||
public byte[] Key() {return BRIDGE_KEY;}
|
||||
public static final byte[] BRIDGE_KEY = Bry_.new_a7("send_msg");
|
||||
}
|
||||
@@ -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.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.htmls.bridges.*;
|
||||
public class Xoax_long_poll_addon implements Xoax_addon_itm, Xoax_addon_itm__json {
|
||||
public Bridge_cmd_itm[] Json__cmds() {
|
||||
return new Bridge_cmd_itm[]
|
||||
{ Http_long_poll_cmd.Instance
|
||||
, new Http_send_msg_cmd()
|
||||
};
|
||||
}
|
||||
|
||||
public static final byte[] ADDON_KEY = Bry_.new_a7("xowa.servers.https.long_poll");
|
||||
public byte[] Addon__key() {return ADDON_KEY;}
|
||||
}
|
||||
@@ -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.addons.servers.https; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.servers.*;
|
||||
import gplx.xowa.guis.cbks.*;
|
||||
public class Xog_cbk_wkr__http implements Xog_cbk_wkr {
|
||||
public void Send_prog(String head) {
|
||||
Http_long_poll_cmd.Instance.Send_msg(head);
|
||||
}
|
||||
public static final Xog_cbk_wkr__http Instance = new Xog_cbk_wkr__http(); Xog_cbk_wkr__http() {}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
|
||||
import gplx.xowa.specials.*;
|
||||
public class Xoax_downloads_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
|
||||
public Xows_page[] Pages_ary() {
|
||||
return new Xows_page[]
|
||||
{ Xodl_special_page.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
public static final byte[] ADDON_KEY = Bry_.new_a7("xowa.imports.downloads");
|
||||
public byte[] Addon__key() {return ADDON_KEY;}
|
||||
}
|
||||
// class Xodl_core_regy {
|
||||
// public void Update() {} // update from http
|
||||
// public void Load() {} // load bin/
|
||||
// }
|
||||
// class Xodl_user_regy {
|
||||
// public void Load() {}
|
||||
// public void Apply() {} // mark already downloaded items
|
||||
// }
|
||||
// class Xodl_main_mgr {
|
||||
// public void Show_ui() {} // show list for ui
|
||||
// public void Process() {} // process choices
|
||||
// }
|
||||
@@ -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.addons.updates.downloads; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
|
||||
import gplx.xowa.addons.updates.downloads.core.*;
|
||||
import gplx.xowa.addons.updates.downloads.itms.*;
|
||||
class Xodl_download_mgr implements Gfo_download_cbk {
|
||||
public void Download(Gfo_download_wkr download_wkr, Xodl_itm_pack[] packs) {
|
||||
download_wkr.Download__bgn(this, packs);
|
||||
}
|
||||
public void Download__end_itm(Gfo_download_itm itm) {
|
||||
// unzip; start
|
||||
}
|
||||
public void Download__end_all(Gfo_download_itm[] itms) {}
|
||||
public void Unzip__end(Gfo_download_itm[] itms) {
|
||||
// register
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.addons.updates.downloads.itms.*; import gplx.xowa.addons.updates.downloads.core.*;
|
||||
import gplx.xowa.addons.apps.file_browsers.*;
|
||||
public class Xodl_special_page implements Xows_page {
|
||||
public static Gfo_download_wkr Download_wkr = Gfo_download_wkr_.Noop;
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Io_url addon_dir = wiki.App().Fsys_mgr().Bin_addon_dir().GenSubDir_nest("import", "wiki_download");
|
||||
Xoa_url_arg_mgr arg_mgr = new Xoa_url_arg_mgr(null).Init(url.Qargs_ary());
|
||||
byte[] ids_bry = arg_mgr.Read_bry_or_null("ids");
|
||||
if (ids_bry == null) {
|
||||
Xopage_html_data html_data = Write_html(wiki.App(), addon_dir);
|
||||
html_data.Apply(page);
|
||||
}
|
||||
else {
|
||||
Xodl_itm_regy regy = Load_regy(addon_dir);
|
||||
int[] ids_ary = Int_.Ary_parse(String_.new_u8(ids_bry), ",");
|
||||
Xodl_itm_pack[] packs = regy.Packs__select(ids_ary);
|
||||
if (packs.length > 0) {
|
||||
Xodl_download_mgr download_mgr = new Xodl_download_mgr();
|
||||
download_mgr.Download(Download_wkr, packs);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static Xodl_itm_regy Load_regy(Io_url addon_dir) {
|
||||
return Xodl_itm_regy.Load_by_json(addon_dir.GenSubFil_nest("data", "wiki_download.json"));
|
||||
}
|
||||
private static Xopage_html_data Write_html(Xoa_app app, Io_url addon_dir) {
|
||||
// write body
|
||||
Xodl_itm_regy owner_itm = Load_regy(addon_dir);
|
||||
byte[] template_src = Io_mgr.Instance.LoadFilBry(addon_dir.GenSubFil_nest("bin", "wiki_download.mustache.html"));
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
byte[] body = gplx.langs.mustaches.Mustache_wtr_.Write_to_bry(tmp_bfr, template_src, owner_itm);
|
||||
|
||||
// write head
|
||||
Xopage_html_data rv = new Xopage_html_data(Display_ttl, body);
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "wiki_download.css")));
|
||||
return rv;
|
||||
}
|
||||
|
||||
public static final String SPECIAL_KEY = "XowaWikiDownload";
|
||||
public static final byte[] Display_ttl = Bry_.new_a7("Download wikis");
|
||||
public Xows_special_meta Special__meta() {return new Xows_special_meta(Xows_special_meta_.Src__xowa, SPECIAL_KEY);}
|
||||
public static final Xows_page Prototype = new Xodl_special_page();
|
||||
public Xows_page Special__clone() {return this;}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public interface Gfo_download_cbk {
|
||||
void Download__end_itm(Gfo_download_itm itm);
|
||||
void Download__end_all(Gfo_download_itm[] itms);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public interface Gfo_download_itm {
|
||||
String Download__src();
|
||||
Io_url Download__trg();
|
||||
void Download__trg_(Io_url v);
|
||||
}
|
||||
@@ -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.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public interface Gfo_download_wkr {
|
||||
void Download__bgn(Gfo_download_cbk cbk, Gfo_download_itm[] itms);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public class Gfo_download_wkr_ {
|
||||
public static final Gfo_download_wkr Noop = new Gfo_download_wkr__noop();
|
||||
}
|
||||
class Gfo_download_wkr__noop implements Gfo_download_wkr {
|
||||
public void Download__bgn(Gfo_download_cbk cbk, Gfo_download_itm[] itms) {cbk.Download__end_all(itms);}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
import gplx.langs.jsons.*; import gplx.langs.mustaches.*;
|
||||
import gplx.xowa.addons.updates.downloads.core.*;
|
||||
public class Xodl_itm_pack implements Mustache_doc_itm, Gfo_download_itm {
|
||||
public int Id = -1; // EX: 1
|
||||
public String Wiki = ""; // EX: 'simple.wikipedia.org'
|
||||
public String Date = ""; // EX: '2016-04-07'
|
||||
public String Type = ""; // EX: 'html' or 'file'
|
||||
public String Name = ""; // EX: 'html: complete'
|
||||
public long Size = 0; // EX: 1234
|
||||
public String Url = ""; // EX: https://archive.org/download/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-06_html.7z
|
||||
public int Ns = -1; // EX: 0
|
||||
public int Part = -1; // EX: 1, 2
|
||||
public Xodl_itm_pack() {}
|
||||
public Xodl_itm_pack(int id, String wiki, String date, String type, int ns, int part, String name, long size, String url) {
|
||||
this.Id = id;
|
||||
this.Wiki = wiki;
|
||||
this.Date = date;
|
||||
this.Type = type;
|
||||
this.Ns = ns;
|
||||
this.Part = part;
|
||||
this.Name = name;
|
||||
this.Size = size;
|
||||
this.Url = url;
|
||||
}
|
||||
public String Download__src() {return Url;}
|
||||
public Io_url Download__trg() {return trg;} private Io_url trg; public void Download__trg_(Io_url v) {this.trg = v;}
|
||||
public void To_json(Json_wtr wtr) {
|
||||
wtr.Kv_int("id", Id);
|
||||
wtr.Kv_str("wiki", Wiki);
|
||||
wtr.Kv_str("date", Date);
|
||||
wtr.Kv_str("type", Type);
|
||||
wtr.Kv_str("name", Name);
|
||||
wtr.Kv_long("size", Size);
|
||||
wtr.Kv_str("url", Url);
|
||||
if (Ns != -1) wtr.Kv_int("ns", Ns);
|
||||
if (Part != -1) wtr.Kv_int("part", Part);
|
||||
}
|
||||
public void By_json(Json_nde nde) {
|
||||
this.Id = nde.Get_as_int("id");
|
||||
this.Wiki = nde.Get_as_str("wiki");
|
||||
this.Date = nde.Get_as_str("date");
|
||||
this.Type = nde.Get_as_str("type");
|
||||
this.Name = nde.Get_as_str("name");
|
||||
this.Size = nde.Get_as_long("size");
|
||||
this.Url = nde.Get_as_str("url");
|
||||
this.Ns = nde.Get_as_int_or("ns", -1);
|
||||
this.Part = nde.Get_as_int_or("part", -1);
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
if (String_.Eq(key, "id")) bfr.Add_int(Id);
|
||||
else if (String_.Eq(key, "wiki")) bfr.Add_str_u8(Wiki);
|
||||
else if (String_.Eq(key, "date")) bfr.Add_str_u8(Date);
|
||||
else if (String_.Eq(key, "type")) bfr.Add_str_u8(Type);
|
||||
else if (String_.Eq(key, "name")) bfr.Add_str_u8(Name);
|
||||
else if (String_.Eq(key, "size")) bfr.Add_long(Size);
|
||||
else if (String_.Eq(key, "url")) bfr.Add_str_u8(Url);
|
||||
else if (String_.Eq(key, "ns")) bfr.Add_int(Ns);
|
||||
else if (String_.Eq(key, "part")) bfr.Add_int(Part);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {return Mustache_doc_itm_.Ary__empty;}
|
||||
public static final Xodl_itm_pack[] Ary_empty = new Xodl_itm_pack[0];
|
||||
}
|
||||
@@ -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.addons.updates.downloads.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
import gplx.langs.jsons.*; import gplx.langs.mustaches.*;
|
||||
public class Xodl_itm_regy implements Mustache_doc_itm {
|
||||
public Xodl_itm_pack[] Packs = Xodl_itm_pack.Ary_empty;
|
||||
public Xodl_itm_regy() {}
|
||||
public Xodl_itm_regy(Xodl_itm_pack[] pack_ary) {this.Packs = pack_ary;}
|
||||
public Xodl_itm_pack[] Packs__select(int[] ids) {
|
||||
Hash_adp packs_hash = Hash_adp_.new_();
|
||||
int packs_len = Packs.length;
|
||||
for (int i = 0; i < packs_len; ++i) {
|
||||
Xodl_itm_pack pack = Packs[i];
|
||||
packs_hash.Add(pack.Id, pack);
|
||||
}
|
||||
|
||||
List_adp rv = List_adp_.new_();
|
||||
int ids_len = ids.length;
|
||||
for (int i = 0; i < ids_len; ++i) {
|
||||
int id = ids[i];
|
||||
Xodl_itm_pack pack = (Xodl_itm_pack)packs_hash.Get_by(id);
|
||||
if (pack != null)
|
||||
rv.Add(pack);
|
||||
}
|
||||
return (Xodl_itm_pack[])rv.To_ary_and_clear(Xodl_itm_pack.class);
|
||||
}
|
||||
public void To_json(Json_wtr wtr) {
|
||||
wtr.Doc_ary_bgn();
|
||||
int wikis_len = Packs.length;
|
||||
for (int i = 0; i < wikis_len; ++i) {
|
||||
wtr.Nde_bgn_ary();
|
||||
Xodl_itm_pack wiki = Packs[i];
|
||||
wiki.To_json(wtr);
|
||||
wtr.Nde_end();
|
||||
}
|
||||
wtr.Doc_ary_end();
|
||||
}
|
||||
public void By_json(Json_grp ary) {
|
||||
int len = ary.Len();
|
||||
Packs = new Xodl_itm_pack[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Json_nde sub_nde = ary.Get_as_nde(i);
|
||||
Xodl_itm_pack sub_itm = new Xodl_itm_pack();
|
||||
Packs[i] = sub_itm;
|
||||
sub_itm.By_json(sub_nde);
|
||||
}
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {return false;}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "packs")) return Packs;
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
public static Xodl_itm_regy Load_by_json(Io_url url) {return Load_by_json(Io_mgr.Instance.LoadFilBry(url));}
|
||||
public static Xodl_itm_regy Load_by_json(byte[] bry) {
|
||||
Xodl_itm_regy rv = new Xodl_itm_regy();
|
||||
Json_parser parser = new Json_parser();
|
||||
Json_doc jdoc = parser.Parse(bry);
|
||||
rv.By_json(jdoc.Root_grp());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.addons.updates.downloads.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Xodl_itm_regy_tst {
|
||||
private final Xodl_itm_regy_fxt fxt = new Xodl_itm_regy_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__srl
|
||||
( Json_doc.Make_str_ary_by_apos
|
||||
( "["
|
||||
, " { 'id':1"
|
||||
, " , 'wiki':'simple.wikipedia.org'"
|
||||
, " , 'date':'2016-04-07'"
|
||||
, " , 'type':'html'"
|
||||
, " , 'name':'html: complete'"
|
||||
, " , 'size':1234"
|
||||
, " , 'url':'http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_html.zip'"
|
||||
, " }"
|
||||
, ","
|
||||
, " { 'id':2"
|
||||
, " , 'wiki':'simple.wikipedia.org'"
|
||||
, " , 'date':'2016-04-07'"
|
||||
, " , 'type':'file'"
|
||||
, " , 'name':'file: complete'"
|
||||
, " , 'size':4321"
|
||||
, " , 'url':'http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_file.zip'"
|
||||
, " }"
|
||||
, "]"
|
||||
)
|
||||
, fxt.Make__regy
|
||||
( fxt.Make__pack(1, "simple.wikipedia.org", "2016-04-07", "html", -1, -1, "html: complete", 1234, "http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_html.zip")
|
||||
, fxt.Make__pack(2, "simple.wikipedia.org", "2016-04-07", "file", -1, -1, "file: complete", 4321, "http://archive.org/Xowa_simplewiki_latest/Xowa_simplewiki_2016-04-07_file.zip")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
class Xodl_itm_regy_fxt {
|
||||
private final Json_wtr wtr = new Json_wtr();
|
||||
public Xodl_itm_regy Make__regy(Xodl_itm_pack... pack_ary) {return new Xodl_itm_regy(pack_ary);}
|
||||
public Xodl_itm_pack Make__pack(int id, String wiki, String date, String type, int ns, int part, String name, long size, String url) {return new Xodl_itm_pack(id, wiki, date, type, ns, part, name, size, url);}
|
||||
public Xodl_itm_regy_fxt Test__srl(String[] json, Xodl_itm_regy regy) {
|
||||
regy.To_json(wtr);
|
||||
byte[][] json_bry = wtr.Bfr().To_bry_ary_and_clear();
|
||||
Gftest.Eq__ary(json, json_bry, "to_json");
|
||||
|
||||
regy = Xodl_itm_regy.Load_by_json(Bry_.Add(json_bry));
|
||||
regy.To_json(wtr);
|
||||
json_bry = wtr.Bfr().To_bry_ary_and_clear();
|
||||
Gftest.Eq__ary(json, json_bry, "by_json");
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -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.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public interface Gfo_unzip_cbk {
|
||||
void Unzip__end_itm(Gfo_unzip_itm itm);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public interface Gfo_unzip_itm {
|
||||
Io_url Unzip__src_fil();
|
||||
Io_url Unzip__trg_dir();
|
||||
}
|
||||
@@ -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.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
public interface Gfo_unzip_wkr {
|
||||
void Unzip__bgn(Gfo_unzip_cbk cbk, Gfo_unzip_itm itm);
|
||||
}
|
||||
class Gfo_unzip_wkr__noop implements Gfo_unzip_wkr {
|
||||
public void Unzip__bgn(Gfo_unzip_cbk cbk, Gfo_unzip_itm itm) {cbk.Unzip__end_itm(itm);}
|
||||
public static final Gfo_unzip_wkr__noop Instance = new Gfo_unzip_wkr__noop(); Gfo_unzip_wkr__noop() {}
|
||||
}
|
||||
@@ -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.addons.updates.downloads.unzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*; import gplx.xowa.addons.updates.downloads.*;
|
||||
import gplx.core.ios.zips.*;
|
||||
|
||||
class Gfo_unzip_wkr__jre implements Gfo_unzip_wkr {
|
||||
public void Unzip__bgn(Gfo_unzip_cbk cbk, Gfo_unzip_itm itm) {
|
||||
Io_zip_mgr_base.Instance.Unzip_to_dir(itm.Unzip__src_fil(), itm.Unzip__trg_dir());
|
||||
cbk.Unzip__end_itm(itm);
|
||||
}
|
||||
public static final Gfo_unzip_wkr__jre Instance = new Gfo_unzip_wkr__jre(); Gfo_unzip_wkr__jre() {}
|
||||
}
|
||||
Reference in New Issue
Block a user