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

v2.11.1.1

This commit is contained in:
gnosygnu
2015-11-01 20:50:05 -05:00
parent 4f43f51b18
commit b990ec409f
858 changed files with 6758 additions and 4187 deletions

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.drds; import gplx.*; import gplx.xowa.*;
import gplx.xowa.drds.pages.*;
import gplx.xowa.apps.*; import gplx.xowa.wikis.data.tbls.*;
public class Xod_app {
private final Xoav_app app;
private final Xod_page_mgr page_mgr = new Xod_page_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));
return page_mgr.Get_page(wiki, page_ttl);
}
}

View File

@@ -0,0 +1,58 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.drds; import gplx.*; import gplx.xowa.*;
import org.junit.*; import gplx.xowa.drds.pages.*; import gplx.xowa.wikis.*; import gplx.xowa.htmls.sections.*;
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")));
}
}
class Xod_app_tstr {
private final gplx.xowa.apps.Xoav_app app; private final Xowv_wiki wiki;
private final Xod_app drd_provider;
public Xod_app_tstr() {
this.app = Xoa_app_fxt.Make__app__view();
this.wiki = Xoa_app_fxt.Make__wiki__view(app);
data_mgr.Wiki_(wiki);
Xoa_test_.Init__db__mem(wiki);
drd_provider = new Xod_app(app);
}
public Xowd_data_tstr Data_mgr() {return data_mgr;} private final Xowd_data_tstr data_mgr = new Xowd_data_tstr();
public void Init_mem() {
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);
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) {
Xod_page_itm rv = new Xod_page_itm();
rv.Init(page_id, page_id, ttl, ttl, null, null, modified_on, Bool_.N, Bool_.N, Bool_.N, 1, null, null, null);
int len = section_ary.length;
for (int i = 0; i < len; ++i) {
Xoh_section_itm itm = section_ary[i];
rv.Section_list().Add(itm);
}
return rv;
}
public Xoh_section_itm Make_section(int id, int level, String anchor, String heading, String content) {return new Xoh_section_itm(id, level, Bry_.new_u8(anchor), Bry_.new_u8(heading)).Content_(Bry_.new_u8(content));}
}

View File

@@ -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.drds; import gplx.*; import gplx.xowa.*;
public interface Xod_img_loader {
void Show_img(int html_uid);
}
/*
int uid
*/

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.drds; import gplx.*; import gplx.xowa.*;
import gplx.xowa.wikis.data.*;
import gplx.xowa.htmls.*; import gplx.xowa.wikis.data.tbls.*;
public class Xowd_data_tstr {
public void Wiki_(Xow_wiki wiki) {this.wiki = wiki;} private Xow_wiki wiki;
public void Page__insert(int page_id, String ttl_str, String modified_on) {Page__insert(page_id, ttl_str, modified_on, Bool_.N, 0, page_id, 0, 0);}
public void Page__insert(int page_id, String ttl_str, String modified_on, boolean page_is_redirect, int page_len, int random_int, int text_db_id, int html_db_id) {
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(ttl_str));
wiki.Data__core_mgr().Tbl__page().Insert(page_id, ttl.Ns().Id(), ttl.Page_db(), page_is_redirect, DateAdp_.parse_iso8561(modified_on), page_len, page_id, text_db_id, html_db_id);
}
public void Html__insert(int page_id, String html) {
Xowd_db_file html_db = wiki.Data__core_mgr().Db__html();
if (html_db == null) {
html_db = wiki.Data__core_mgr().Db__core();
html_db.Tbl__html_page().Create_tbl();
}
byte[] html_bry = Bry_.new_u8(html);
Xoh_page gui_page = new Xoh_page();
gui_page.Body_(html_bry);
byte[] data = html_bry;
html_db.Tbl__html_page().Insert(page_id, 0, 0, Bry_.Empty, Bry_.Empty, Bry_.Empty, data);
}
}

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.drds.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
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;
public String Ttl_db() {return ttl_db;} private String ttl_db;
public String Redirected() {return redirected;} private String redirected;
public String Description() {return description;} private String description;
public String Modified_on() {return modified_on;} private String modified_on;
public boolean Is_editable() {return is_editable;} private boolean is_editable;
public boolean Is_main_page() {return is_main_page;} private boolean is_main_page;
public boolean Is_disambiguation() {return is_disambiguation;} private boolean is_disambiguation;
public int Lang_count() {return lang_count;} private int lang_count;
public String Head_url() {return head_url;} private String head_url;
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 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
, String head_url, String head_ttl
, String first_allowed_editor_role
) {
this.page_id = page_id; this.rev_id = rev_id;
this.ttl_text = ttl_text; this.ttl_db = ttl_db; this.redirected = redirected; this.description = description; this.modified_on = modified_on;
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) {
this.page_id = db_page.Id();
this.rev_id = page_id;
this.ttl_text = String_.new_u8(ttl.Page_txt());
this.ttl_db = ttl.Page_db_as_str();
this.modified_on = db_page.Modified_on().XtoStr_fmt_iso_8561();
this.lang_count = 1;
this.redirected = null;
this.description = null;
this.is_editable = false;
this.is_main_page = false;
this.is_disambiguation = false;
this.head_url = null;
this.head_ttl = null;
this.first_allowed_editor_role = null;
}
public String To_str() {
Bry_bfr bfr = Bry_bfr.new_();
bfr .Add_int_variable(page_id).Add_byte_pipe()
.Add_long_variable(rev_id).Add_byte_pipe()
.Add_str_u8(ttl_text).Add_byte_pipe()
.Add_str_u8(ttl_db).Add_byte_pipe()
.Add_str_a7_null(modified_on).Add_byte_pipe()
.Add_int_variable(lang_count).Add_byte_pipe()
.Add_str_a7_null(redirected).Add_byte_pipe()
.Add_str_a7_null(description).Add_byte_pipe()
.Add_yn(is_editable).Add_byte_pipe()
.Add_yn(is_main_page).Add_byte_pipe()
.Add_yn(is_disambiguation).Add_byte_pipe()
.Add_str_a7_null(head_url).Add_byte_pipe()
.Add_str_a7_null(head_ttl).Add_byte_pipe()
.Add_str_a7_null(first_allowed_editor_role).Add_byte_nl()
;
int len = section_list.Count();
for (int i = 0; i < len; ++i) {
Xoh_section_itm section = (Xoh_section_itm)section_list.Get_at(i);
section.To_bfr(bfr);
}
return bfr.To_str_and_clear();
}
}

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.drds.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.drds.*;
import gplx.xowa.wikis.data.tbls.*;
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);
// load page data
Xoh_page hpg = new Xoh_page();
hpg.Init(wiki, Xoa_url.new_(wiki.Domain_bry(), ttl.Page_db()), ttl, 1);
wiki.Html__hdump_mgr().Load_mgr().Load(hpg, ttl);
Load_sections(rv, hpg);
return rv;
}
private void Load_sections(Xod_page_itm rv, Xoh_page hpg) {
Xoh_section_mgr section_mgr = hpg.Section_mgr();
int len = section_mgr.Len();
for (int i = 0; i < len; ++i) {
Xoh_section_itm itm = section_mgr.Get_at(i);
rv.Section_list().Add(itm);
}
}
}