mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.6.4.1'
This commit is contained in:
@@ -17,10 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.addons.bldrs.infos.*;
|
||||
public class Xobc_task_addon implements Xoax_addon_itm, Xoax_addon_itm__special, Xoax_addon_itm__json {
|
||||
public Xow_special_page[] Special_pages() {
|
||||
return new Xow_special_page[]
|
||||
{ Xobc_task_special.Prototype
|
||||
, Xobc_info_special.Prototype
|
||||
};
|
||||
}
|
||||
public Bridge_cmd_itm[] Json_cmds() {
|
||||
|
||||
@@ -19,9 +19,10 @@ package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; impo
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.cmds.*;
|
||||
public class Xobc_task_bridge implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
|
||||
public void Init_by_app(Xoa_app app) {}
|
||||
private Xoa_app app;
|
||||
public void Init_by_app(Xoa_app app) {this.app = app;}
|
||||
public String Exec(Json_nde data) {
|
||||
Xobc_task_mgr task_mgr = Xobc_task_special.Task_mgr;
|
||||
Xobc_task_mgr task_mgr = Xobc_task_special.Task_mgr(app);
|
||||
byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Msg__proc, null), Byte_ascii.Max_7_bit);
|
||||
Json_nde args = data.Get_kv(Msg__args).Val_as_nde();
|
||||
switch (proc_id) {
|
||||
|
||||
@@ -36,7 +36,6 @@ class Xobc_task_html extends Xow_special_wtr__base {
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xobc.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_htm_frag(addon_dir.GenSubFil_nest("bin", "xobc.row.mustache.html"), "xobc.row"));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.log.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.ajax.listener.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.app.js")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", Get_app_js_file(app))));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("js", "xo.elem.js")));
|
||||
|
||||
@@ -18,16 +18,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.*; import gplx.core.net.qargs.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xobc_task_special implements Xow_special_page {
|
||||
public static Xobc_task_mgr Task_mgr;
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
// init task_mgr
|
||||
page.Html_data().Cbk_enabled_(true); // apply cbk_enabled early to capture logging statements
|
||||
Xoa_app app = wiki.App();
|
||||
if (Task_mgr == null) Task_mgr = New_task_mgr(app);
|
||||
Task_mgr.Load_or_init();
|
||||
if (task_mgr == null) task_mgr = New_task_mgr(app);
|
||||
task_mgr.Load_or_init();
|
||||
|
||||
new Xobc_task_html().Bld_page_by_mustache(app, page, this);
|
||||
}
|
||||
public static Xobc_task_mgr Task_mgr(Xoa_app app) {
|
||||
if (task_mgr == null) {
|
||||
task_mgr = New_task_mgr(app);
|
||||
}
|
||||
return task_mgr;
|
||||
} private static Xobc_task_mgr task_mgr;
|
||||
private static Xobc_task_mgr New_task_mgr(Xoa_app app) {
|
||||
Io_url data_db_url = app.Fsys_mgr().Bin_addon_dir().GenSubFil_nest("bldr", "central", "bldr_central.data_db.xowa");
|
||||
app.User().User_db_mgr().Init_site_mgr();
|
||||
|
||||
@@ -54,14 +54,4 @@ public class Xobc_data_db {
|
||||
tbl__import_step.Delete(step_id);
|
||||
}
|
||||
}
|
||||
private final gplx.core.lists.hashs.Hash_adp__int host_hash = new gplx.core.lists.hashs.Hash_adp__int();
|
||||
public String Bld_src_http_url(gplx.core.brys.evals.Bry_eval_mgr eval_mgr, int host_id, String file_name) {
|
||||
Xobc_host_regy_itm host_itm = (Xobc_host_regy_itm)host_hash.Get_by_or_null(host_id);
|
||||
if (host_itm == null) {
|
||||
host_itm = tbl__host_regy.Select(host_id);
|
||||
host_hash.Add(host_id, host_itm);
|
||||
}
|
||||
String host_dir = String_.new_u8(eval_mgr.Eval(Bry_.new_u8(host_itm.Host_data_dir())));
|
||||
return String_.Format("http://{0}/{1}/{2}", host_itm.Host_domain(), host_dir, file_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,16 @@ public class Xobc_step_map_tbl implements Db_tbl {
|
||||
} finally {rdr.Rls();}
|
||||
throw Err_.new_("", "xobc:could not find next sort", "task_id", task_id);
|
||||
}
|
||||
public List_adp Select_all(int task_id) {
|
||||
List_adp rv = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_id).Crt_int(fld_task_id, task_id).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
rv.Add(rdr.Read_int("step_id"));
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
return rv;
|
||||
}
|
||||
public void Insert(int sm_id, int task_id, int step_id, int step_seqn) {
|
||||
if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
insert_stmt.Clear().Val_int(fld_sm_id, sm_id).Val_int(fld_task_id, task_id).Val_int(fld_step_id, step_id).Val_int(fld_step_seqn, step_seqn)
|
||||
|
||||
@@ -56,6 +56,11 @@ public class Xobc_task_regy_tbl implements Db_tbl {
|
||||
try {return rdr.Move_next() ? rdr.Read_int(fld_task_id) : -1;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public String Select_key_by_id_or_null(int id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_task_id).Crt_int(fld_task_id, id).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? rdr.Read_str(fld_task_key) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Insert(int task_id, int task_seqn, int step_count, String task_key, String task_name) {
|
||||
if (insert_stmt == null) insert_stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
insert_stmt.Clear().Val_int(fld_task_id, task_id).Val_int(fld_task_seqn, task_seqn).Val_int(fld_step_count, step_count)
|
||||
|
||||
@@ -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.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*;
|
||||
import gplx.core.brys.evals.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Host_eval_itm {
|
||||
private final Bry_eval_mgr mgr = Bry_eval_mgr.Dflt();
|
||||
private final Host_eval_wkr wkr = new Host_eval_wkr();
|
||||
private final Hash_adp host_hash = Hash_adp_.New();
|
||||
public Host_eval_itm() {
|
||||
mgr.Add_many(wkr);
|
||||
}
|
||||
public byte[] Eval_dir_name(Xow_domain_itm domain_itm) {
|
||||
wkr.Domain_itm_(domain_itm);
|
||||
return mgr.Eval(Bry_.new_u8("Xowa_~{host_regy|wiki_abrv}_latest"));
|
||||
}
|
||||
public String Eval_src_fil(Xobc_data_db data_db, int host_id, Xow_domain_itm domain, String file_name) {
|
||||
return Eval_src_dir(data_db, host_id, domain) + file_name;
|
||||
}
|
||||
public String Eval_src_dir(Xobc_data_db data_db, int host_id, Xow_domain_itm domain) {
|
||||
Xobc_host_regy_itm host_itm = (Xobc_host_regy_itm)host_hash.Get_by(host_id);
|
||||
if (host_itm == null) {
|
||||
host_itm = data_db.Tbl__host_regy().Select(host_id);
|
||||
host_hash.Add(host_id, host_itm);
|
||||
}
|
||||
wkr.Domain_itm_(domain);
|
||||
String host_dir = String_.new_u8(mgr.Eval(Bry_.new_u8(host_itm.Host_data_dir())));
|
||||
return String_.Format("http://{0}/{1}/", host_itm.Host_domain(), host_dir);
|
||||
}
|
||||
}
|
||||
@@ -15,18 +15,23 @@ 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.bldrs.centrals.utils; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
package gplx.xowa.addons.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.brys.evals.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Bry_eval_wkr__host_regy implements Bry_eval_wkr {
|
||||
public class Host_eval_wkr implements Bry_eval_wkr {
|
||||
private Xow_domain_itm domain_itm;
|
||||
public String Key() {return "host_regy";}
|
||||
public Bry_eval_wkr__host_regy Domain_itm_(Xow_domain_itm domain_itm) {this.domain_itm = domain_itm; return this;}
|
||||
public Host_eval_wkr Domain_itm_(Xow_domain_itm domain_itm) {this.domain_itm = domain_itm; return this;}
|
||||
public void Resolve(Bry_bfr rv, byte[] src, int args_bgn, int args_end) {
|
||||
// EX: "~{host_regy|wiki_abrv}" -> "enwiki"
|
||||
int type = hash.Get_as_byte_or(src, args_bgn, args_end, Byte_.Max_value_127);
|
||||
switch (type) {
|
||||
case Type__wiki_abrv: rv.Add(domain_itm.Abrv_wm()); break;
|
||||
case Type__wiki_abrv:
|
||||
byte[] lang_key = domain_itm.Lang_orig_key();
|
||||
if (lang_key == Bry_.Empty) lang_key = Bry_.new_a7("en"); // handle species
|
||||
rv.Add(lang_key);
|
||||
rv.Add_str_a7("wiki");
|
||||
break;
|
||||
default: throw Err_.new_unhandled_default(type);
|
||||
}
|
||||
}
|
||||
@@ -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.bldrs.centrals.hosts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Host_eval_wkr__tst {
|
||||
private final Host_eval_wkr__fxt fxt = new Host_eval_wkr__fxt();
|
||||
@Test public void En_w() {fxt.Test__resolve_quick("en.wikipedia.org" , "Xowa_enwiki_latest");}
|
||||
@Test public void Fr_d() {fxt.Test__resolve_quick("fr.wiktionary.org" , "Xowa_frwiki_latest");}
|
||||
@Test public void Species() {fxt.Test__resolve_quick("species.wikimedia.org" , "Xowa_enwiki_latest");}
|
||||
}
|
||||
class Host_eval_wkr__fxt {
|
||||
public void Test__resolve_quick(String domain_str, String expd) {
|
||||
Host_eval_itm eval_itm = new Host_eval_itm();
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_str));
|
||||
Gftest.Eq__bry(Bry_.new_u8(expd), eval_itm.Eval_dir_name(domain_itm));
|
||||
}
|
||||
}
|
||||
@@ -18,19 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.bldrs.centrals.steps; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.core.brys.evals.*; import gplx.core.primitives.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.tasks.*; import gplx.xowa.addons.bldrs.centrals.cmds.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.utils.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.hosts.*;
|
||||
import gplx.xowa.addons.bldrs.exports.merges.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xobc_step_factory {
|
||||
private final Xobc_task_mgr task_mgr;
|
||||
private final Xobc_data_db data_db;
|
||||
private final Bry_eval_mgr eval_mgr = Bry_eval_mgr.Dflt(), eval_mgr__host_regy = Bry_eval_mgr.Dflt();
|
||||
private final Bry_eval_wkr__host_regy eval_wkr__host_regy = new Bry_eval_wkr__host_regy();
|
||||
private final Bry_eval_mgr eval_mgr = Bry_eval_mgr.Dflt(); private final Host_eval_itm host_eval = new Host_eval_itm();
|
||||
private final Host_eval_wkr eval_wkr__host_regy = new Host_eval_wkr();
|
||||
public Xobc_step_factory(Xobc_task_mgr task_mgr, Xobc_data_db data_db, Io_url wiki_dir) {
|
||||
this.task_mgr = task_mgr;
|
||||
this.data_db = data_db;
|
||||
eval_mgr.Add_many(new Bry_eval_wkr__builder_central(wiki_dir));
|
||||
eval_mgr__host_regy.Add_many(eval_wkr__host_regy);
|
||||
}
|
||||
public void Load(Xobc_task_itm task, int step_id, int cmd_idx) {
|
||||
int step_type = data_db.Tbl__step_regy().Select_type(step_id);
|
||||
@@ -57,7 +56,7 @@ public class Xobc_step_factory {
|
||||
String file_name = import_itm.Import_name;
|
||||
step_name.Val_(file_name);
|
||||
eval_wkr__host_regy.Domain_itm_(domain_itm);
|
||||
String src_http_url = data_db.Bld_src_http_url(eval_mgr__host_regy, import_itm.Host_id, file_name);
|
||||
String src_http_url = host_eval.Eval_src_fil(data_db, import_itm.Host_id, domain_itm, file_name);
|
||||
Io_url zip_file_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__download_fil, wiki_domain, file_name));
|
||||
Io_url unzip_dir_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__unzip_dir, wiki_domain, file_name));
|
||||
Io_url wiki_dir_url = Eval_url(Bry_eval_wkr__builder_central.Make_str(Bry_eval_wkr__builder_central.Type__wiki_dir, wiki_domain, file_name));
|
||||
|
||||
Reference in New Issue
Block a user