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

v2.12.1.1

This commit is contained in:
gnosygnu
2015-12-06 23:12:52 -05:00
parent 097e6c7f80
commit 9509363f46
337 changed files with 3473 additions and 1917 deletions

View File

@@ -16,16 +16,23 @@ 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.drds; import gplx.*; import gplx.xowa.*;
import gplx.xowa.drds.pages.*;
import gplx.xowa.drds.pages.*; import gplx.xowa.drds.files.*;
import gplx.xowa.apps.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.files.gui.*;
public class Xod_app {
private final Xoav_app app;
private final Xod_page_mgr page_mgr = new Xod_page_mgr();
private final Xod_file_mgr file_mgr = new Xod_file_mgr();
public Xod_app(Xoav_app app) {
this.app = app;
}
public Xod_page_itm Get_page(String wiki_domain, String page_ttl) {
Xow_wiki wiki = app.Wiki_mgri().Get_by_key_or_make_init_y(Bry_.new_u8(wiki_domain));
public Xow_wiki Get_wiki(String wiki_domain) {
return app.Wiki_mgri().Get_by_key_or_make_init_y(Bry_.new_u8(wiki_domain));
}
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
return page_mgr.Get_page(wiki, page_ttl);
}
public void Load_files(Xow_wiki wiki, Xod_page_itm pg, Xog_js_wkr js_wkr) {
file_mgr.Load_files(wiki, pg, js_wkr);
}
}

View File

@@ -21,9 +21,9 @@ public class Xod_app_tst {
private final Xod_app_tstr tstr = new Xod_app_tstr();
@Before public void init() {tstr.Init_mem();}
@Test public void Get() {
// tstr.Data_mgr().Page__insert(1, "A", "2015-10-19 00:01:02");
// tstr.Data_mgr().Html__insert(1, "abc");
// tstr.Test__get("A", tstr.Make_page(1, "A", "2015-10-19 00:01:02", tstr.Make_section(0, 2, "", "", "abc")));
tstr.Data_mgr().Page__insert(1, "A", "2015-10-19 00:01:02");
tstr.Data_mgr().Html__insert(1, "abc");
tstr.Test__get("A", tstr.Make_page(1, "A", "2015-10-19 00:01:02", tstr.Make_section(0, 2, "", "", "abc")));
}
}
class Xod_app_tstr {
@@ -41,7 +41,8 @@ class Xod_app_tstr {
Io_mgr.Instance.InitEngine_mem();
}
public void Test__get(String ttl, Xod_page_itm expd) {
Xod_page_itm itm = drd_provider.Get_page("en.wikipedia.org", ttl);
Xow_wiki wiki = drd_provider.Get_wiki("en.wikipedia.org");
Xod_page_itm itm = drd_provider.Get_page(wiki, ttl);
Tfds.Eq(expd.To_str(), itm.To_str());
}
public Xod_page_itm Make_page(int page_id, String ttl, String modified_on, Xoh_section_itm... section_ary) {

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.drds.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
import gplx.core.threads.*;
import gplx.xowa.drds.pages.*;
import gplx.xowa.files.*; import gplx.xowa.files.gui.*;
import gplx.xowa.htmls.*;
public class Xod_file_mgr {
private final Gfo_thread_pool thread_pool = new Gfo_thread_pool();
public void Load_files(Xow_wiki wiki, Xod_page_itm pg, Xog_js_wkr js_wkr) {
Xoh_page hpg = pg.Hpg();
List_adp img_list = To_img_list(hpg.Img_mgr());
Xof_file_wkr img_wkr = new Xof_file_wkr(wiki.File__orig_mgr(), wiki.File__bin_mgr(), wiki.File__mnt_mgr(), wiki.App().User().User_db_mgr().Cache_mgr(), wiki.File__repo_mgr(), js_wkr, hpg, img_list);
thread_pool.Add_at_end(img_wkr);
thread_pool.Run();
}
private static List_adp To_img_list(Xoh_img_mgr img_mgr) {
List_adp rv = List_adp_.new_();
int len = img_mgr.Len();
for (int i = 0; i < len; ++i)
rv.Add(img_mgr.Get_at(i));
return rv;
}
}

View File

@@ -16,10 +16,9 @@ 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.drds.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
import gplx.xowa.htmls.sections.*;
import gplx.xowa.htmls.*; import gplx.xowa.htmls.sections.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xod_page_itm {
public Xod_page_itm() {}
public int Page_id() {return page_id;} private int page_id;
public long Rev_id() {return rev_id;} private long rev_id;
public String Ttl_text() {return ttl_text;} private String ttl_text;
@@ -35,6 +34,7 @@ public class Xod_page_itm {
public String Head_name() {return head_ttl;} private String head_ttl;
public String First_allowed_editor_role() {return first_allowed_editor_role;} private String first_allowed_editor_role;
public List_adp Section_list() {return section_list;} private List_adp section_list = List_adp_.new_();
public Xoh_page Hpg() {return hpg;} private Xoh_page hpg;
public void Init(int page_id, int rev_id
, String ttl_text, String ttl_db, String redirected, String description, String modified_on
, boolean is_editable, boolean is_main_page, boolean is_disambiguation, int lang_count
@@ -46,8 +46,7 @@ public class Xod_page_itm {
this.is_editable = is_editable; this.is_main_page = is_main_page; this.is_disambiguation = is_disambiguation; this.lang_count = lang_count;
this.head_url = head_url; this.head_ttl= head_ttl; this.first_allowed_editor_role = first_allowed_editor_role;
}
public void Init() {}
public void Init(Xoa_ttl ttl, Xowd_page_itm db_page) {
public void Init_by_dbpg(Xoa_ttl ttl, Xowd_page_itm db_page) {
this.page_id = db_page.Id();
this.rev_id = page_id;
this.ttl_text = String_.new_u8(ttl.Page_txt());
@@ -63,6 +62,9 @@ public class Xod_page_itm {
this.head_ttl = null;
this.first_allowed_editor_role = null;
}
public void Init_by_hpg(Xoh_page hpg) {
this.hpg = hpg;
}
public String To_str() {
Bry_bfr bfr = Bry_bfr.new_();
bfr .Add_int_variable(page_id).Add_byte_pipe()

View File

@@ -21,15 +21,17 @@ import gplx.xowa.htmls.*; import gplx.xowa.htmls.sections.*;
public class Xod_page_mgr {
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
Xod_page_itm rv = new Xod_page_itm();
// load meta info like page_id, modified, etc
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(page_ttl));
Xowd_page_itm dbpg = new Xowd_page_itm();
wiki.Data__core_mgr().Tbl__page().Select_by_ttl(dbpg, ttl.Ns(), ttl.Page_db());
rv.Init(ttl, dbpg);
rv.Init_by_dbpg(ttl, dbpg);
// load page data
Xoh_page hpg = new Xoh_page();
hpg.Init(wiki, Xoa_url.new_(wiki.Domain_bry(), ttl.Page_db()), ttl, 1);
rv.Init_by_hpg(hpg);
wiki.Html__hdump_mgr().Load_mgr().Load(hpg, ttl);
Load_sections(rv, hpg);
return rv;