mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
User_wikis: Add dirty implementation to load existing user wiki
This commit is contained in:
parent
1f7a54c1e6
commit
1711d52985
@ -26,7 +26,7 @@ public class Xoa_url_ {
|
||||
}
|
||||
public static void Invalid_warn(String url) {Xoa_app_.Usr_dlg().Plog_many("", "", "invalid url; url=~{0}", url);}
|
||||
public static String Main_page__home_str = gplx.xowa.wikis.domains.Xow_domain_itm_.Str__home + gplx.xowa.htmls.hrefs.Xoh_href_.Str__wiki + gplx.xowa.Xoa_page_.Main_page_str; // EX:home/wiki/Main_Page
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Qarg__redirect = Bry_.new_a7("redirect")
|
||||
, Qarg__redirect__no = Bry_.new_a7("no")
|
||||
, Qarg__action = Bry_.new_a7("action")
|
||||
|
@ -159,6 +159,7 @@ public class Xoae_app implements Xoa_app, Gfo_invk {
|
||||
api_root.Init_by_app(this);
|
||||
wmf_mgr.Init_by_app(this);
|
||||
gplx.core.net.emails.Gfo_email_mgr_.Instance = gplx.core.net.emails.Gfo_email_mgr_.New_jre();
|
||||
gplx.xowa.addons.users.wikis.regys.Xou_regy_addon.Init(this);
|
||||
}
|
||||
public boolean Launch_done() {return stage == Xoa_stage_.Tid_launch;}
|
||||
public void Launch() {
|
||||
|
@ -16,9 +16,14 @@ 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.users.wikis.regys; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.users.*; import gplx.xowa.addons.users.wikis.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.specials.*;
|
||||
import gplx.xowa.addons.users.wikis.regys.specials.registers.*;
|
||||
import gplx.xowa.addons.users.wikis.regys.dbs.*; import gplx.xowa.addons.users.wikis.regys.specials.registers.*;
|
||||
public class Xou_regy_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
|
||||
public Xou_regy_addon(Db_conn conn) {
|
||||
db_mgr = new Xouw_db_mgr(conn);
|
||||
}
|
||||
public Xouw_db_mgr Db_mgr() {return db_mgr;} private final Xouw_db_mgr db_mgr;
|
||||
public Xow_special_page[] Special_pages() {
|
||||
return new Xow_special_page[]
|
||||
{ Xouw_register_special.Prototype
|
||||
@ -26,4 +31,34 @@ public class Xou_regy_addon implements Xoax_addon_itm, Xoax_addon_itm__special {
|
||||
}
|
||||
|
||||
public String Addon__key() {return ADDON__KEY;} private static final String ADDON__KEY = "xowa.user.wiki.regy";
|
||||
// public static Xou_regy_addon Addon__get(Xow_wiki wiki) {
|
||||
// Xou_regy_addon rv = (Xou_regy_addon)wiki.Addon_mgr().Itms__get_or_null(ADDON__KEY);
|
||||
// if (rv == null) {
|
||||
// rv = new Xou_regy_addon(wiki.App().User().User_db_mgr().Conn());
|
||||
// wiki.Addon_mgr().Itms__add(rv);
|
||||
// }
|
||||
// return rv;
|
||||
// }
|
||||
public static void Init(Xoae_app app) {
|
||||
// exit if none found
|
||||
Db_conn conn = app.User().User_db_mgr().Conn();
|
||||
if (!conn.Meta_tbl_exists(Xou_wiki_tbl.Tbl_name_dflt)) return;
|
||||
|
||||
// register
|
||||
Xou_regy_addon addon = new Xou_regy_addon(conn);
|
||||
Xou_wiki_itm[] itms = addon.Db_mgr().Tbl__wiki().Select_all();
|
||||
int len = itms.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xou_wiki_itm itm = itms[i];
|
||||
Xowe_wiki wiki = new Xowe_wiki
|
||||
( app
|
||||
, gplx.xowa.langs.Xol_lang_itm_.Lang_en_make(app.Lang_mgr())
|
||||
, gplx.xowa.wikis.nss.Xow_ns_mgr_.default_(gplx.xowa.langs.cases.Xol_case_mgr_.A7())
|
||||
, gplx.xowa.wikis.domains.Xow_domain_itm_.parse(Bry_.new_u8(itm.Domain()))
|
||||
, itm.Url().OwnerDir());
|
||||
wiki.Init_assert();
|
||||
wiki.Appe().Wiki_mgr().Add(wiki);
|
||||
app.User().Wikii().Xwiki_mgr().Add_by_atrs(itm.Domain(), itm.Domain());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
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.users.wikis.regys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.users.*; import gplx.xowa.addons.users.wikis.*; import gplx.xowa.addons.users.wikis.regys.*;
|
||||
public class Xou_wiki_itm {
|
||||
public Xou_wiki_itm(int id, int type, String domain, String name, Io_url url, String data) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.domain = domain;
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.data = data;
|
||||
}
|
||||
public int Id() {return id;} private int id;
|
||||
public int Type() {return type;} private int type;
|
||||
public String Domain() {return domain;} private String domain;
|
||||
public String Name() {return name;} private String name;
|
||||
public Io_url Url() {return url;} private Io_url url;
|
||||
public String Data() {return data;} private String data;
|
||||
}
|
@ -23,7 +23,7 @@ public class Xou_wiki_tbl implements Db_tbl {
|
||||
private final Db_conn conn;
|
||||
public Xou_wiki_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "user_wiki";
|
||||
this.tbl_name = Tbl_name_dflt;
|
||||
this.fld__wiki_id = flds.Add_int_pkey("wiki_id");
|
||||
this.fld__wiki_type = flds.Add_int("wiki_type"); // enum: 0=user; 1=wmf; 2=wikia;
|
||||
this.fld__wiki_domain = flds.Add_str("wiki_domain", 255); // EX: "en.wikipedia.org"
|
||||
@ -45,6 +45,24 @@ public class Xou_wiki_tbl implements Db_tbl {
|
||||
.Exec_insert()
|
||||
;
|
||||
}
|
||||
public Xou_wiki_itm[] Select_all() {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds).Exec_select__rls_auto();
|
||||
try {
|
||||
List_adp list = List_adp_.New();
|
||||
while (rdr.Move_next()) {
|
||||
list.Add(Make(rdr));
|
||||
}
|
||||
return (Xou_wiki_itm[])list.To_ary_and_clear(Xou_wiki_itm.class);
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xou_wiki_itm Make(Db_rdr rdr) {
|
||||
return new Xou_wiki_itm(rdr.Read_int(fld__wiki_id), rdr.Read_int(fld__wiki_type)
|
||||
, rdr.Read_str(fld__wiki_domain), rdr.Read_str(fld__wiki_name), Io_url_.new_fil_(rdr.Read_str(fld__wiki_core_url)), rdr.Read_str(fld__wiki_data)
|
||||
);
|
||||
}
|
||||
|
||||
public void Rls() {}
|
||||
|
||||
public static final String Tbl_name_dflt = "user_wiki";
|
||||
}
|
||||
|
@ -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.users.wikis.regys.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.users.*; import gplx.xowa.addons.users.wikis.*; import gplx.xowa.addons.users.wikis.regys.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xouw_db_mgr {
|
||||
public Xouw_db_mgr(Db_conn conn) {
|
||||
tbl__wiki = new Xou_wiki_tbl(conn);
|
||||
}
|
||||
public Xou_wiki_tbl Tbl__wiki() {return tbl__wiki;} private final Xou_wiki_tbl tbl__wiki;
|
||||
}
|
Loading…
Reference in New Issue
Block a user