1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2016-01-03 21:27:38 -05:00
parent 9509363f46
commit 096045614c
647 changed files with 11693 additions and 7648 deletions

View File

@@ -19,6 +19,7 @@ package gplx.xowa.drds; import gplx.*; import gplx.xowa.*;
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.*;
import gplx.xowa.specials.search.*;
public class Xod_app {
private final Xoav_app app;
private final Xod_page_mgr page_mgr = new Xod_page_mgr();
@@ -26,13 +27,29 @@ public class Xod_app {
public Xod_app(Xoav_app app) {
this.app = app;
}
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 int Get_wiki_count() {
int rv = app.Wiki_mgri().Count();
return rv - 1; // ignore home wiki
}
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
return page_mgr.Get_page(wiki, page_ttl);
public Xow_wiki Get_wiki(String wiki_domain) {
Xow_wiki rv = app.Wiki_mgri().Get_by_key_or_make_init_y(Bry_.new_u8(wiki_domain));
if (rv.Data__core_mgr() == null) rv.Init_by_wiki();
return rv;
}
public Xod_page_itm Get_page(Xow_wiki wiki, Xoa_url page_url) {
return page_mgr.Get_page(wiki, page_url);
}
public void Load_files(Xow_wiki wiki, Xod_page_itm pg, Xog_js_wkr js_wkr) {
file_mgr.Load_files(wiki, pg, js_wkr);
}
public String[] Search_titles(Cancelable cancelable, Xow_wiki wiki, Xows_ui_async ui_async, String search) {
Xows_db_wkr search_wkr = new Xows_db_wkr();
Xows_db_row[] rows = search_wkr.Search_by_drd(cancelable, wiki, ui_async, Bry_.new_u8(search), 50);
int len = rows.length;
String[] rv = new String[len];
for (int i = 0; i < len; ++i) {
rv[i] = String_.new_u8(rows[i].Page_ttl().Page_txt());
}
return rv;
}
}

View File

@@ -23,7 +23,7 @@ public class Xod_app_tst {
@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.Test__get("A", tstr.Make_page(1, "A", "2015-10-19T00:01:02Z", tstr.Make_section(0, 2, "", "", "abc")));
}
}
class Xod_app_tstr {
@@ -42,7 +42,8 @@ class Xod_app_tstr {
}
public void Test__get(String ttl, Xod_page_itm expd) {
Xow_wiki wiki = drd_provider.Get_wiki("en.wikipedia.org");
Xod_page_itm itm = drd_provider.Get_page(wiki, ttl);
Xoa_url page_url = wiki.Utl__url_parser().Parse(Bry_.new_u8(ttl));
Xod_page_itm itm = drd_provider.Get_page(wiki, page_url);
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

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

View File

@@ -51,7 +51,7 @@ public class Xod_page_itm {
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.modified_on = db_page.Modified_on().XtoStr_fmt_iso_8561_w_tz();
this.lang_count = 1;
this.redirected = null;
this.description = null;

View File

@@ -18,12 +18,14 @@ 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.*;
import gplx.core.net.*; import gplx.xowa.specials.xowa.file_browsers.*;
public class Xod_page_mgr {
public Xod_page_itm Get_page(Xow_wiki wiki, String page_ttl) {
public Xod_page_itm Get_page(Xow_wiki wiki, Xoa_url page_url) {
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));
Xoa_ttl ttl = wiki.Ttl_parse(page_url.Page_bry());
if (ttl.Ns().Id_is_special()) return Load_special(rv, wiki, ttl, page_url.Qargs_ary());
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_by_dbpg(ttl, dbpg);
@@ -44,4 +46,13 @@ public class Xod_page_mgr {
rv.Section_list().Add(itm);
}
}
private Xod_page_itm Load_special(Xod_page_itm rv, Xow_wiki wiki, Xoa_ttl ttl, Gfo_qarg_itm[] qargs) {
Xosp_fbrow_rslt rslt = Xosp_fbrow_special.Gen(qargs, wiki.App().Wiki_mgri());
rv.Init(-1, -1, String_.new_u8(ttl.Page_txt()), String_.new_u8(ttl.Page_db()), null, null, DateAdp_.Now().XtoStr_fmt_iso_8561(), false, false, false, 0, "", "", "");
rv.Init_by_hpg(new Xoh_page());
Xoh_section_itm section = new Xoh_section_itm(1, 1, Bry_.Empty, Bry_.Empty);
section.Content_(rslt.Html_body());
rv.Section_list().Add(section);
return rv;
}
}