mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.4.2.1'
This commit is contained in:
@@ -16,7 +16,7 @@ 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.wikis; import gplx.*; import gplx.xowa.*;
|
||||
public interface Xoa_wiki_mgr extends GfoInvkAble {
|
||||
public interface Xoa_wiki_mgr {
|
||||
int Count();
|
||||
boolean Has(byte[] key);
|
||||
Xow_wiki Get_at(int idx);
|
||||
@@ -24,4 +24,6 @@ public interface Xoa_wiki_mgr extends GfoInvkAble {
|
||||
Xow_wiki Get_by_or_make_init_y(byte[] key);
|
||||
Xow_wiki Get_by_or_make_init_n(byte[] key);
|
||||
void Add(Xow_wiki wiki);
|
||||
Xow_wiki Make(byte[] domain_bry, Io_url wiki_root_dir);
|
||||
Xow_wiki Import_by_url(Io_url fil);
|
||||
}
|
||||
|
||||
33
400_xowa/src/gplx/xowa/wikis/Xoa_wiki_mgr_.java
Normal file
33
400_xowa/src/gplx/xowa/wikis/Xoa_wiki_mgr_.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.dbs.cfgs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Xoa_wiki_mgr_ {
|
||||
public static Xow_wiki Import_by_url(Xoa_app app, Xoa_wiki_mgr wiki_mgr, Io_url url) {
|
||||
Db_conn conn = Db_conn_bldr.Instance.Get_or_noop(url); if (conn == Db_conn_.Noop) return null; // invalid url
|
||||
Db_cfg_tbl cfg_tbl = Xowd_cfg_tbl_.Get_or_null(conn); if (cfg_tbl == null) return null; // no xowa_cfg;
|
||||
byte[] wiki_domain = cfg_tbl.Select_bry(Xow_cfg_consts.Grp__bldr_session, Xob_info_session.Cfg_key__wiki_domain); if (wiki_domain == null) return null;
|
||||
Io_url wiki_root_dir = url.OwnerDir();
|
||||
Xow_wiki rv = wiki_mgr.Make(wiki_domain, wiki_root_dir);
|
||||
wiki_mgr.Add(rv);
|
||||
// byte[] modified_last = cfg_tbl.Select_bry(Xow_cfg_consts.Grp__wiki_init, "props.modified_latest");
|
||||
app.User().User_db_mgr().Site_mgr().Import(rv.Domain_str(), rv.Domain_str(), wiki_root_dir.Raw(), "");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,16 @@ package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*;
|
||||
public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
private final Xoae_app app;
|
||||
private final List_adp list = List_adp_.new_(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
private final Xoae_app app;
|
||||
private final List_adp list = List_adp_.new_(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
|
||||
public Xoae_wiki_mgr(Xoae_app app) {
|
||||
this.app = app;
|
||||
this.wiki_regy = new Xoa_wiki_regy(app);
|
||||
this.wdata_mgr = new Wdata_wiki_mgr(app);
|
||||
}
|
||||
public Xoa_wiki_regy Wiki_regy() {return wiki_regy;} private final Xoa_wiki_regy wiki_regy;
|
||||
public Xow_script_mgr Scripts() {return scripts;} private final Xow_script_mgr scripts = new Xow_script_mgr();
|
||||
public Wdata_wiki_mgr Wdata_mgr() {return wdata_mgr;} private final Wdata_wiki_mgr wdata_mgr;
|
||||
public Xoa_wiki_regy Wiki_regy() {return wiki_regy;} private final Xoa_wiki_regy wiki_regy;
|
||||
public Xow_script_mgr Scripts() {return scripts;} private final Xow_script_mgr scripts = new Xow_script_mgr();
|
||||
public Wdata_wiki_mgr Wdata_mgr() {return wdata_mgr;} private final Wdata_wiki_mgr wdata_mgr;
|
||||
public Xowe_wiki Wiki_commons() {
|
||||
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(Xow_domain_itm_.Bry__commons);
|
||||
if (rv != null) rv.Init_assert();
|
||||
@@ -41,13 +41,13 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
public Xowe_wiki Get_at_or_null(int i) {return Int_.Between(i, 0, this.Count() - 1) ? (Xowe_wiki)list.Get_at(i) : null;}
|
||||
public Xow_wiki Get_by_or_null(byte[] key) {return Bry_.Len_eq_0(key) ? null : (Xowe_wiki)hash.Get_by(key);}
|
||||
public Xow_wiki Get_by_or_make_init_y(byte[] key) {
|
||||
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(key); if (rv == null) rv = New_wiki(key);
|
||||
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(key); if (rv == null) rv = Make_and_add(key);
|
||||
rv.Init_assert();
|
||||
return rv;
|
||||
}
|
||||
public Xow_wiki Get_by_or_make_init_n(byte[] key) {return Get_by_or_make(key);}
|
||||
public Xowe_wiki Get_by_or_make(byte[] key) {
|
||||
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(key); if (rv == null) rv = New_wiki(key);
|
||||
Xowe_wiki rv = (Xowe_wiki)this.Get_by_or_null(key); if (rv == null) rv = Make_and_add(key);
|
||||
return rv;
|
||||
}
|
||||
public void Add(Xow_wiki wiki) {
|
||||
@@ -55,6 +55,25 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
hash.Add(wiki.Domain_bry(), wiki);
|
||||
list.Add(wiki);
|
||||
}
|
||||
public Xowe_wiki Make_and_add(byte[] domain_bry) {
|
||||
Io_url wiki_root_url = app.Fsys_mgr().Wiki_dir().GenSubDir(String_.new_a7(domain_bry));
|
||||
Xowe_wiki rv = (Xowe_wiki)Make(domain_bry, wiki_root_url);
|
||||
Add(rv);
|
||||
return rv;
|
||||
}
|
||||
public Xow_wiki Make(byte[] domain_bry, Io_url wiki_root_dir) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(domain_bry);
|
||||
byte[] lang_key = domain_itm.Lang_actl_key();
|
||||
if (lang_key == Xol_lang_stub_.Key__unknown) lang_key = Xol_lang_itm_.Key_en; // unknown langs default to english; note that this makes nonwmf english by default
|
||||
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_new(lang_key);
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
lang = new Xol_lang_itm(app.Lang_mgr(), Xol_lang_itm_.Key_en).Kwd_mgr__strx_(true); // create a new english lang, but enable strx functions; DATE:2015-08-23
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
}
|
||||
Xow_ns_mgr ns_mgr = Xow_ns_mgr_.default_(lang.Case_mgr()); //app.Dbmeta_mgr().Ns__get_or_load(key);
|
||||
return new Xowe_wiki(app, lang, ns_mgr, domain_itm, wiki_root_dir);
|
||||
}
|
||||
public Xow_wiki Import_by_url(Io_url url) {return Xoa_wiki_mgr_.Import_by_url(app, this, url);}
|
||||
public void Del(byte[] key) {hash.Del(key);}
|
||||
public void Clear() {hash.Clear(); list.Clear();}
|
||||
public void Free_mem(boolean clear_ctx) {
|
||||
@@ -82,20 +101,5 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_get_at)) return this.Get_at_or_null(m.ReadInt("v"));
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
} private static final String Invk_get = "get", Invk_scripts = "scripts", Invk_wdata = "wdata";
|
||||
private static final String Invk_len = "len", Invk_get_at = "get_at";
|
||||
private Xowe_wiki New_wiki(byte[] key) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(key);
|
||||
byte[] lang_key = domain_itm.Lang_actl_key();
|
||||
if (lang_key == Xol_lang_stub_.Key__unknown) lang_key = Xol_lang_itm_.Key_en; // unknown langs default to english; note that this makes nonwmf english by default
|
||||
Xol_lang_itm lang = app.Lang_mgr().Get_by_or_new(lang_key);
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
lang = new Xol_lang_itm(app.Lang_mgr(), Xol_lang_itm_.Key_en).Kwd_mgr__strx_(true); // create a new english lang, but enable strx functions; DATE:2015-08-23
|
||||
Xol_lang_itm_.Lang_init(lang);
|
||||
}
|
||||
Xow_ns_mgr ns_mgr = Xow_ns_mgr_.default_(lang.Case_mgr()); //app.Dbmeta_mgr().Ns__get_or_load(key);
|
||||
Io_url wiki_dir = app.Fsys_mgr().Wiki_dir().GenSubDir(domain_itm.Domain_str());
|
||||
Xowe_wiki rv = new Xowe_wiki(app, lang, ns_mgr, domain_itm, wiki_dir);
|
||||
Add(rv);
|
||||
return rv;
|
||||
}
|
||||
private static final String Invk_len = "len", Invk_get_at = "get_at";
|
||||
}
|
||||
|
||||
@@ -26,5 +26,6 @@ public class Xow_cfg_consts {
|
||||
, Grp__wiki_init = "wiki.init"
|
||||
, Key__init__main_page = "props.main_page"
|
||||
, Key__init__bldr_version = "props.bldr_version"
|
||||
, Key__init__modified_latest = "props.modified_latest"
|
||||
;
|
||||
}
|
||||
|
||||
@@ -22,12 +22,13 @@ import gplx.xowa.apps.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.bins.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.specials.*; import gplx.xowa.addons.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.addons.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.css.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.addons.apps.specials.*;
|
||||
public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
private final Xof_fsdb_mgr__sql fsdb_mgr; private Fsdb_db_mgr db_core_mgr;
|
||||
private boolean init_needed = true;
|
||||
|
||||
@@ -118,7 +118,7 @@ class Xoctg_fmtr_all {
|
||||
private void Html_nav_bry(Bry_bfr bfr, Xowe_wiki wiki, Xoa_ttl ttl, Xoctg_view_grp view_grp, boolean fill_at_bgn) {
|
||||
Bry_bfr href_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Xoae_app app = wiki.Appe();
|
||||
app.Html__href_wtr().Build_to_bfr(href_bfr, app, Xoh_wtr_ctx.Mode_basic, wiki.Domain_bry(), ttl);
|
||||
app.Html__href_wtr().Build_to_bfr(href_bfr, app, Xoh_wtr_ctx.Basic, wiki.Domain_bry(), ttl);
|
||||
byte[] arg_idx_lbl = null; byte[] arg_sortkey = null;
|
||||
if (fill_at_bgn) {
|
||||
arg_idx_lbl = url_arg_bgn;
|
||||
@@ -139,7 +139,7 @@ class Xoctg_fmtr_all {
|
||||
byte[] nav_text = wiki.Msg_mgr().Val_by_id_args(nav_text_id, grp_max); // fill_at_bgn 200 / previous 200
|
||||
html_nav.Bld_bfr(bfr, nav_href, nav_ttl, nav_text);
|
||||
}
|
||||
public static final byte[]
|
||||
public static final byte[]
|
||||
Url_arg_from = Bry_.new_a7("from")
|
||||
, Url_arg_until = Bry_.new_a7("until")
|
||||
, Url_arg_subc_bgn = Bry_.new_a7("subcatfrom")
|
||||
|
||||
@@ -40,7 +40,7 @@ public class Xow_data_mgr implements GfoInvkAble {
|
||||
Xow_ns ns = ttl.Ns();
|
||||
switch (ns.Id()) {
|
||||
case Xow_ns_.Tid__special:
|
||||
wiki.Special_mgr().Special_gen(wiki, rv, url, ttl);
|
||||
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
|
||||
return rv;
|
||||
case Xow_ns_.Tid__mediawiki:
|
||||
if ( !called_from_msg // if called from msg, fall through to actual data retrieval below, else infinite loop; DATE:2014-05-09
|
||||
|
||||
28
400_xowa/src/gplx/xowa/wikis/data/Xowd_cfg_tbl_.java
Normal file
28
400_xowa/src/gplx/xowa/wikis/data/Xowd_cfg_tbl_.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
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.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_cfg_tbl_ {
|
||||
public static final String Tbl_name = "xowa_cfg";
|
||||
public static Db_cfg_tbl New(gplx.dbs.Db_conn conn) {
|
||||
return new Db_cfg_tbl(conn, Tbl_name);
|
||||
}
|
||||
public static Db_cfg_tbl Get_or_null(gplx.dbs.Db_conn conn) {
|
||||
return conn.Meta_tbl_exists(Tbl_name) ? new Db_cfg_tbl(conn, Tbl_name) : null;
|
||||
}
|
||||
}
|
||||
@@ -26,15 +26,15 @@ public class Xowd_core_db_props {
|
||||
this.zip_tid_text = zip_tid_text; this.zip_tid_html = zip_tid_html;
|
||||
this.hzip_enabled = hzip_enabled; this.hzip_mode_is_b256 = hzip_mode_is_b256;
|
||||
}
|
||||
public int Schema() {return schema;} private final int schema;
|
||||
public int Schema() {return schema;} private final int schema;
|
||||
public boolean Schema_is_1() {return schema == 1;}
|
||||
public Xowd_db_layout Layout_text() {return layout_text;} private final Xowd_db_layout layout_text;
|
||||
public Xowd_db_layout Layout_html() {return layout_html;} private final Xowd_db_layout layout_html;
|
||||
public Xowd_db_layout Layout_file() {return layout_file;} private final Xowd_db_layout layout_file;
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private final byte zip_tid_text;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private final byte zip_tid_html;
|
||||
public boolean Hzip_enabled() {return hzip_enabled;} private final boolean hzip_enabled;
|
||||
public boolean Hzip_mode_is_b256() {return hzip_mode_is_b256;} private final boolean hzip_mode_is_b256;
|
||||
public Xowd_db_layout Layout_text() {return layout_text;} private final Xowd_db_layout layout_text;
|
||||
public Xowd_db_layout Layout_html() {return layout_html;} private final Xowd_db_layout layout_html;
|
||||
public Xowd_db_layout Layout_file() {return layout_file;} private final Xowd_db_layout layout_file;
|
||||
public byte Zip_tid_text() {return zip_tid_text;} private final byte zip_tid_text;
|
||||
public byte Zip_tid_html() {return zip_tid_html;} private final byte zip_tid_html;
|
||||
public boolean Hzip_enabled() {return hzip_enabled;} private final boolean hzip_enabled;
|
||||
public boolean Hzip_mode_is_b256() {return hzip_mode_is_b256;} private final boolean hzip_mode_is_b256;
|
||||
public void Cfg_save(Db_cfg_tbl tbl) {
|
||||
tbl.Conn().Txn_bgn("make__core__cfg__save");
|
||||
tbl.Insert_int (Cfg_grp, Cfg_key__schema_version , schema);
|
||||
@@ -48,7 +48,7 @@ public class Xowd_core_db_props {
|
||||
tbl.Conn().Txn_end();
|
||||
}
|
||||
public static Xowd_core_db_props Cfg_load(Io_url url, Db_conn conn) {
|
||||
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg");
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
|
||||
return cfg_tbl.Select_int_or(Cfg_grp, Cfg_key__schema_version, 1) == 1
|
||||
? new Xowd_core_db_props
|
||||
( 1, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, cfg_tbl.Select_byte_or(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format
|
||||
@@ -78,5 +78,5 @@ public class Xowd_core_db_props {
|
||||
, Cfg_key__hzip_enabled = "hzip_enabled"
|
||||
, Cfg_key__hzip_mode_is_b256 = "hzip_mode_is_b256"
|
||||
;
|
||||
public static final Xowd_core_db_props Test = new Xowd_core_db_props(2, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Io_stream_.Tid_raw, Io_stream_.Tid_raw, Bool_.Y, Bool_.Y);
|
||||
public static final Xowd_core_db_props Test = new Xowd_core_db_props(2, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Io_stream_.Tid_raw, Io_stream_.Tid_raw, Bool_.Y, Bool_.Y);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Xowd_db_file {
|
||||
public static Xowd_db_file make_(Xob_info_session info_session, Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, String core_file_name, Db_conn conn) {
|
||||
Guid_adp guid = Guid_adp_.new_();
|
||||
Xob_info_file info_file = new Xob_info_file(id, Xowd_db_file_.To_key(tid), ns_ids, part_id, guid, props.Schema(), core_file_name, url.NameAndExt());
|
||||
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg");
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn);
|
||||
Xowd_db_file rv = new Xowd_db_file(cfg_tbl, info_session, info_file, props, Xowd_db_file_schema_props.make_(), id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_create);
|
||||
cfg_tbl.Create_tbl(); // always create cfg in each db
|
||||
return rv;
|
||||
@@ -87,7 +87,7 @@ public class Xowd_db_file {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "wiki.db:missing db; tid=~{0} url=~{1}", Xowd_db_file_.To_key(tid), url.Raw());
|
||||
conn = Db_conn_.Noop;
|
||||
}
|
||||
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg"); // NOTE: this loads the cfg tbl for the current db, not the core db
|
||||
Db_cfg_tbl cfg_tbl = gplx.xowa.wikis.data.Xowd_cfg_tbl_.New(conn); // NOTE: this loads the cfg tbl for the current db, not the core db
|
||||
Xob_info_session info_session = Xob_info_session.Load(cfg_tbl);
|
||||
Xob_info_file info_file = Xob_info_file.Load(cfg_tbl);
|
||||
return new Xowd_db_file(cfg_tbl, info_session, info_file, props, Xowd_db_file_schema_props.load_(cfg_tbl, tid, info_session.Version()), id, tid, url, ns_ids, part_id, guid, conn, Db_cmd_mode.Tid_ignore);
|
||||
|
||||
@@ -159,6 +159,17 @@ public class Xowd_db_mgr {
|
||||
default: throw Err_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static boolean Maybe_core(String domain_name, String fil_name) {
|
||||
Xow_domain_itm domain_itm = Xow_domain_itm_.parse(Bry_.new_u8(domain_name));
|
||||
if (domain_itm.Domain_type_id() == Xow_domain_tid_.Int__other) {
|
||||
return String_.Has_at_end(fil_name, ".xowa");
|
||||
}
|
||||
String domain_str = domain_itm.Domain_str();
|
||||
return ( String_.Eq(fil_name, domain_str + "-text.xowa")
|
||||
|| String_.Eq(fil_name, domain_str + "-core.xowa")
|
||||
|| String_.Eq(fil_name, domain_str + ".xowa")
|
||||
);
|
||||
}
|
||||
private static byte Core_db_tid(Xowd_db_layout layout) {
|
||||
switch (layout.Tid()) {
|
||||
case Xowd_db_layout.Const_all: return Xowd_db_file_.Tid_wiki_solo;
|
||||
|
||||
@@ -269,7 +269,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
}
|
||||
public void Read_page__all(Xowd_page_itm page, Db_rdr rdr) {
|
||||
int html_db_id = rdr.Read_int(fld_html_db_id);
|
||||
int redirected_id = rdr.Read_int(fld_html_db_id);
|
||||
int redirected_id = rdr.Read_int(fld_redirect_id);
|
||||
int page_len = rdr.Read_int(fld_len);
|
||||
int page_score = page_len;
|
||||
if (fld_score != Dbmeta_fld_itm.Key_null)
|
||||
@@ -329,5 +329,5 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
stmt_select_id_by_ttl = Db_stmt_.Rls(stmt_select_id_by_ttl);
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
private static final String Page_touched_fmt = "yyyyMMddHHmmss";
|
||||
public static final String Page_touched_fmt = "yyyyMMddHHmmss";
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xopg_html_data {
|
||||
public boolean Mode_wtxt_shown() {synchronized (this) {return mode_wtxt_shown;}} public void Mode_wtxt_shown_y_() {synchronized (this) {this.mode_wtxt_shown = true;}} private boolean mode_wtxt_shown;
|
||||
public byte[] Display_ttl_vnt() {return display_ttl_vnt;} public void Display_ttl_vnt_(byte[] v) {display_ttl_vnt = v;} private byte[] display_ttl_vnt;
|
||||
public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {content_sub = v;} private byte[] content_sub;
|
||||
public Xopg_page_heading Page_heading() {return page_heading;} private final Xopg_page_heading page_heading = new Xopg_page_heading();
|
||||
public Xopg_page_heading Page_heading() {return page_heading;} private final Xopg_page_heading page_heading = new Xopg_page_heading();
|
||||
public String Bmk_pos() {return html_bmk_pos;} public void Bmk_pos_(String v) {html_bmk_pos = v;} private String html_bmk_pos;
|
||||
public Bry_bfr Portal_div_xtn() {return portal_div_xtn;} private Bry_bfr portal_div_xtn = Bry_bfr.reset_(255);
|
||||
public byte[] Edit_preview_w_dbg() {return Bry_.Add(xtn_scribunto_dbg, edit_preview);} public void Edit_preview_(byte[] v) {edit_preview = v;} private byte[] edit_preview = Bry_.Empty;
|
||||
@@ -45,7 +45,7 @@ public class Xopg_html_data {
|
||||
public boolean Lang_convert_content() {return lang_convert_content;} public void Lang_convert_content_(boolean v) {lang_convert_content = v;} private boolean lang_convert_content = true;
|
||||
public boolean Lang_convert_title() {return lang_convert_title;} public void Lang_convert_title_(boolean v) {lang_convert_title = v;} private boolean lang_convert_title = true;
|
||||
public Xopg_xtn_skin_mgr Xtn_skin_mgr() {return xtn_skin_mgr;} private Xopg_xtn_skin_mgr xtn_skin_mgr = new Xopg_xtn_skin_mgr();
|
||||
public Indicator_html_bldr Indicators() {return indicators;} private final Indicator_html_bldr indicators = new Indicator_html_bldr();
|
||||
public Indicator_html_bldr Indicators() {return indicators;} private final Indicator_html_bldr indicators = new Indicator_html_bldr();
|
||||
public int Xtn_gallery_next_id() {return ++xtn_gallery_next_id;} private int xtn_gallery_next_id = -1;
|
||||
public boolean Xtn_gallery_packed_exists() {return xtn_gallery_packed_exists;} public void Xtn_gallery_packed_exists_y_() {xtn_gallery_packed_exists = true;} private boolean xtn_gallery_packed_exists;
|
||||
public boolean Xtn_imap_exists() {return xtn_imap_exists;} public void Xtn_imap_exists_y_() {xtn_imap_exists = true;} private boolean xtn_imap_exists;
|
||||
@@ -54,7 +54,11 @@ public class Xopg_html_data {
|
||||
public byte[] Xtn_scribunto_dbg() {return xtn_scribunto_dbg;} public void Xtn_scribunto_dbg_(byte[] v) {xtn_scribunto_dbg = Bry_.Add(xtn_scribunto_dbg, v);} private byte[] xtn_scribunto_dbg = Bry_.Empty;
|
||||
public Pgbnr_itm Xtn_pgbnr() {return xtn_pgbnr;} public void Xtn_pgbnr_(Pgbnr_itm v) {xtn_pgbnr = v;} private Pgbnr_itm xtn_pgbnr;
|
||||
public Xoh_head_mgr Head_mgr() {return module_mgr;} private Xoh_head_mgr module_mgr = new Xoh_head_mgr();
|
||||
public boolean Skip_parse() {return skip_parse;} public void Skip_parse_(boolean v) {skip_parse = v;} private boolean skip_parse;
|
||||
public Xopg_tag_mgr Custom_head_tags() {return head_tags;} private final Xopg_tag_mgr head_tags = new Xopg_tag_mgr();
|
||||
public Xopg_tag_mgr Custom_tail_tags() {return tail_tags;} private final Xopg_tag_mgr tail_tags = new Xopg_tag_mgr();
|
||||
public byte[] Custom_html() {return custom_html;} public Xopg_html_data Custom_html_(byte[] v) {custom_html = v; return this;} private byte[] custom_html;
|
||||
public byte[] Custom_body() {return custom_body;} public Xopg_html_data Custom_body_(byte[] v) {custom_body = v; return this;} private byte[] custom_body;
|
||||
public byte[] Custom_tab_name() {return custom_tab_name;} public Xopg_html_data Custom_tab_name_(byte[] v) {custom_tab_name = v; return this;} private byte[] custom_tab_name;
|
||||
public byte[] Custom_head_end() {return custom_head_end;}
|
||||
public byte[] Custom_html_end() {return custom_html_end;}
|
||||
|
||||
58
400_xowa/src/gplx/xowa/wikis/pages/Xopg_tag_itm.java
Normal file
58
400_xowa/src/gplx/xowa/wikis/pages/Xopg_tag_itm.java
Normal 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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xopg_tag_itm {
|
||||
public Xopg_tag_itm(String name, String text, Keyval... atrs_ary) {
|
||||
this.Name = name;
|
||||
this.Text = text;
|
||||
this.Atrs_ary = atrs_ary;
|
||||
}
|
||||
public final String Name;
|
||||
public final String Text;
|
||||
public final Keyval[] Atrs_ary;
|
||||
public void To_html(Bry_bfr bfr) {
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn);
|
||||
bfr.Add_str_a7(Name);
|
||||
int len = Atrs_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
bfr.Add_byte_space();
|
||||
Keyval atr = Atrs_ary[i];
|
||||
bfr.Add_str_a7(atr.Key());
|
||||
bfr.Add_byte(Byte_ascii.Eq);
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
bfr.Add_str_a7(atr.Val_to_str_or_empty());
|
||||
bfr.Add_byte(Byte_ascii.Quote);
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
if (String_.Eq(Name, "link")) return;
|
||||
if (Text != null) bfr.Add_str_u8(Text);
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
|
||||
bfr.Add_str_a7(Name);
|
||||
bfr.Add_byte(Byte_ascii.Angle_end);
|
||||
}
|
||||
|
||||
public static Xopg_tag_itm New_css(Io_url href) {
|
||||
return new Xopg_tag_itm("link" , null, Keyval_.new_("type", "text/css"), Keyval_.new_("rel", "stylesheet"), Keyval_.new_("href", href.To_http_file_str()));
|
||||
}
|
||||
public static Xopg_tag_itm New_script_file(Io_url src) {
|
||||
return new Xopg_tag_itm("script", null, Keyval_.new_("type", "text/javascript"), Keyval_.new_("src", src.To_http_file_str()));
|
||||
}
|
||||
public static Xopg_tag_itm New_script_code(String code) {
|
||||
return new Xopg_tag_itm("script", code, Keyval_.new_("type", "text/javascript"));
|
||||
}
|
||||
}
|
||||
38
400_xowa/src/gplx/xowa/wikis/pages/Xopg_tag_mgr.java
Normal file
38
400_xowa/src/gplx/xowa/wikis/pages/Xopg_tag_mgr.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
public class Xopg_tag_mgr {
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public int Len() {return list.Len();}
|
||||
public Xopg_tag_itm Get_at(int i) {return (Xopg_tag_itm)list.Get_at(i);}
|
||||
public void Add(Xopg_tag_itm... ary) {for (Xopg_tag_itm itm : ary) list.Add(itm);}
|
||||
public void Copy(Xopg_tag_mgr src) {
|
||||
int len = src.Len();
|
||||
for (int i = 0; i < len; ++i)
|
||||
this.Add(src.Get_at(i));
|
||||
}
|
||||
public byte[] To_html(Bry_bfr bfr) {
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm tag = this.Get_at(i);
|
||||
tag.To_html(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
@@ -1,54 +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.wikis.specials; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.net.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.specials.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.file_browsers.*;
|
||||
import gplx.xowa.htmls.*;
|
||||
public class Xosp_special_mgr {
|
||||
private final Xowv_wiki wiki;
|
||||
private final Hash_adp_bry hash;
|
||||
public Xosp_special_mgr(Xowv_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
// hash.Add_str_obj(Xows_special_meta_.Key__statistics , page_statistics);
|
||||
this.hash = Hash_adp_bry.cs();
|
||||
}
|
||||
public void Get_by_ttl(Xoh_page rv, Gfo_url url, Xoa_ttl ttl) {
|
||||
Xosp_fbrow_rslt rslt = Xosp_fbrow_special.Gen(url.Qargs(), wiki.Appv().Wiki_mgr());
|
||||
rv.Init(wiki, null, ttl, -1);
|
||||
rv.Body_(rslt.Html_body());
|
||||
rv.Html_head_xtn_(rslt.Html_head());
|
||||
}
|
||||
public void Get_by_url(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
int slash_pos = Bry_find_.Find_fwd(ttl.Page_txt_wo_qargs(), Xoa_ttl.Subpage_spr); // check for slash
|
||||
byte[] special_name = slash_pos == Bry_find_.Not_found
|
||||
? ttl.Base_txt_wo_qarg() // no slash found; use base_txt; ignore qry args and just get page_names; EX: Search/Earth?fulltext=y; Allpages?from=Earth...
|
||||
: Bry_.Mid(ttl.Page_txt_wo_qargs(), 0, slash_pos); // slash found; use root page; EX: Special:ItemByTitle/enwiki/Earth
|
||||
Object o = hash.Get_by_bry(special_name);
|
||||
if (o == null) {
|
||||
Xol_specials_itm special_itm = wiki.Lang().Specials_mgr().Get_by_alias(special_name);
|
||||
if (special_itm != null)
|
||||
o = hash.Get_by_bry(special_itm.Special());
|
||||
}
|
||||
if (o != null) {
|
||||
// Xows_page special = (Xows_page)o;
|
||||
// page.Revision_data().Modified_on_(DateAdp_.Now());
|
||||
// special.Special_gen(wiki, page, url, ttl);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user