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

'v3.7.4.1'

This commit is contained in:
gnosygnu
2016-07-25 21:59:51 -04:00
parent 7a851a41a5
commit 8e91ac0bc4
175 changed files with 2079 additions and 933 deletions

View File

@@ -100,6 +100,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
data_mgr__core_mgr.Db__core().Tbl__ns().Select_all(ns_mgr);
data_mgr__core_mgr.Db__core().Tbl__site_stats().Select(stats);
html__hdump_mgr.Init_by_db(this);
app.Addon_mgr().Load_by_wiki(this);
}
public void Init_by_wiki__force() {init_needed = true; Init_by_wiki();}
public void Init_by_make(Xowd_core_db_props props, gplx.xowa.bldrs.infos.Xob_info_session info_session) {

View File

@@ -16,6 +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.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.caches.*;
import gplx.xowa.wikis.xwikis.sitelinks.*;
public class Xow_cache_mgr {
private final Xowe_wiki wiki;
@@ -30,7 +31,12 @@ public class Xow_cache_mgr {
public Xow_defn_cache Defn_cache() {return defn_cache;} private final Xow_defn_cache defn_cache;
public Xow_defn_cache Lst_cache() {return lst_cache;} private final Xow_defn_cache lst_cache;
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New();
public void Page_cache_(Xow_page_cache v) {this.page_cache = v;}
public Gfo_cache_mgr Commons_cache() {return commons_cache;} private Gfo_cache_mgr commons_cache = new Gfo_cache_mgr().Max_size_(64 * Io_mgr.Len_mb).Reduce_by_(32 * Io_mgr.Len_mb);
public Gfo_cache_mgr Ifexist_cache() {return ifexist_cache;} private Gfo_cache_mgr ifexist_cache = new Gfo_cache_mgr().Max_size_(64 * Io_mgr.Len_mb).Reduce_by_(32 * Io_mgr.Len_mb);
public Xow_cache_mgr Page_cache_(Xow_page_cache v) {this.page_cache = v; return this;}
public Xow_cache_mgr Commons_cache_(Gfo_cache_mgr v) {this.commons_cache = v; return this;}
public Xow_cache_mgr Ifexist_cache_(Gfo_cache_mgr v) {this.ifexist_cache = v; return this;}
public Keyval[] Scrib_lang_names() {
if (scrib_lang_names == null) {
List_adp list = List_adp_.New();
@@ -47,7 +53,12 @@ public class Xow_cache_mgr {
}
public void Free_mem_all() {this.Free_mem_all(Bool_.Y);}
public void Free_mem_all(boolean free_page_cache) {
if (free_page_cache) page_cache.Free_mem_all();
if (free_page_cache) {
page_cache.Free_mem_all();
commons_cache.Clear();
ifexist_cache.Clear();
wiki.Appe().Wiki_mgr().Wdata_mgr().Clear(); // moved from ctx.Clear(); DATE:2016-07-21
}
tmpl_result_cache.Clear();
defn_cache.Free_mem_all();
misc_cache.Clear();

View File

@@ -27,7 +27,6 @@ public class Xow_defn_cache { // stores compiled Xot_defn
public Xow_defn_cache(Xol_lang_itm lang) {this.lang = lang;}
public Xot_defn Get_by_key(byte[] name) {return (Xot_defn)cache.Get_by_key(name);}
public void Free_mem_all() {cache.Clear();}
public void Free_mem_some() {cache.Reduce_recent();}
public void Add(Xot_defn defn, byte case_match) {
byte[] name = defn.Name();
int cache_size = defn.Cache_size(); // OBSOLETE: * 2 b/c it has src and root;

View File

@@ -49,7 +49,15 @@ public class Xowd_wbase_pid_tbl implements Rls_able {
if (!rdr.Move_next()) return Wdata_wiki_mgr.Pid_null; // occurs when pid exists, but does not have entry for language; see hu.w:Marco Polo argali; DATE: 2014-02-01
byte[] pid_bry = rdr.Read_bry_by_str(fld_trg_ttl);
return pid_bry == null ? Wdata_wiki_mgr.Pid_null : Bry_.To_int_or(pid_bry, 1, pid_bry.length, Wdata_wiki_mgr.Pid_null);
} finally {rdr.Rls();}
}
catch (Exception e) {
Gfo_usr_dlg_.Instance.Warn_many("", "", "db.wdata_pids:failed to select pid; lang=~{0} src_ttl=~{1} err=~{2}", src_lang, src_ttl, Err_.Message_gplx_log(e));
try {stmt_select.Rls();}
catch (Exception e2) {Gfo_usr_dlg_.Instance.Warn_many("", "", "db.wdata_pids: failed to rls stmt; err=~{0}", Err_.Message_gplx_log(e2));}
stmt_select = null;
return Wdata_wiki_mgr.Pid_null;
}
finally {rdr.Rls();}
}
public void Rls() {
stmt_insert = Db_stmt_.Rls(stmt_insert);

View File

@@ -164,7 +164,7 @@ public class Xow_page_mgr implements Gfo_invk {
Xoa_ttl trg_ttl = Xoa_ttl.Parse(wiki, page_bry);
Xoa_url trg_url = Xoa_url.New(wiki.Domain_bry(), page_bry);
page.Ttl_(trg_ttl).Url_(trg_url);
page.Redirect().Itms__add__special(trg_url, trg_ttl);
page.Redirect().Itms__add__article(trg_url, trg_ttl, null);
wiki.Data_mgr().Load_from_db(page, trg_ttl.Ns(), trg_ttl, trg_url.Qargs_mgr().Match(Xoa_url_.Qarg__redirect, Xoa_url_.Qarg__redirect__no));
}

View File

@@ -16,14 +16,36 @@ 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.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
public class Xopg_redirect_data {
import gplx.xowa.specials.*;
public class Xopg_redirect_mgr {
private final List_adp itms = List_adp_.New();
public int Itms__len() {return itms.Len();}
public byte[] Itms__get_at_0th_or_null() {return itms.Len() == 0 ? null : this.Itms__get_at(0).Wikitext();}
public Xopg_redirect_itm Itms__get_at_nth_or_null() {return itms.Len() == 0 ? null : (Xopg_redirect_itm)itms.Get_at(itms.Len() - 1);}
public Xopg_redirect_itm Itms__get_at(int i) {return (Xopg_redirect_itm)itms.Get_at(i);}
public void Itms__add__article(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {Itms__add(url, ttl, wikitext);}
public void Itms__add__special(Xoa_url url, Xoa_ttl ttl) {Itms__add(url, ttl, null);}
public void Itms__add__special(Xow_wiki wiki, Xow_special_meta meta, Keyval... url_args) {
// build url and include args if available
byte[] url_bry = meta.Ttl_bry();
int url_args_len = url_args.length;
if (url_args_len > 0) {
Bry_bfr bfr = Bry_bfr_.New();
bfr.Add(url_bry);
for (int i = 0; i < url_args_len; ++i) {
Keyval url_arg = url_args[i];
bfr.Add_byte(i == 0 ? Byte_ascii.Question : Byte_ascii.Amp);
bfr.Add_str_u8(url_arg.Key());
bfr.Add_byte(Byte_ascii.Eq);
bfr.Add_obj(url_arg.Val());
}
url_bry = bfr.To_bry_and_clear();
}
// create objects and add to list
Xoa_url url = wiki.Utl__url_parser().Parse(url_bry);
Xoa_ttl ttl = wiki.Ttl_parse(meta.Ttl_bry());
this.Itms__add(url, ttl, null);
}
private void Itms__add(Xoa_url url, Xoa_ttl ttl, byte[] wikitext) {
Xopg_redirect_itm itm = new Xopg_redirect_itm(url, ttl, wikitext);
itms.Add(itm);

View File

@@ -0,0 +1,53 @@
/*
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.redirects; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.pages.*;
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.specials.*;
public class Xopg_redirect_mgr__tst {
@Before public void init() {fxt.Clear();} private final Xopg_redirect_mgr__fxt fxt = new Xopg_redirect_mgr__fxt();
@Test public void Basic() {
fxt.Test__Itms__add__special(fxt.Make_meta("XowaTest"), Keyval_.Ary_empty, fxt.Make__itm("en.wikipedia.org/wiki/Special:XowaTest", "Special:XowaTest", null));
}
@Test public void Args() {
fxt.Test__Itms__add__special
( fxt.Make_meta("XowaTest"), Keyval_.Ary(Keyval_.new_("k1", "v1"), Keyval_.new_("k2", "v2"), Keyval_.new_("k3", "v3"))
, fxt.Make__itm("en.wikipedia.org/wiki/Special:XowaTest?k1=v1&k2=v2&k3=v3", "Special:XowaTest", null)
);
}
}
class Xopg_redirect_mgr__fxt {
private Xow_wiki wiki;
private final Xopg_redirect_mgr mgr = new Xopg_redirect_mgr();
public void Clear() {
mgr.Clear();
Xoae_app app = Xoa_app_fxt.Make__app__edit();
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
}
public Xow_special_meta Make_meta(String key) {return Xow_special_meta.New_xo(key, "test display name");}
public Xopg_redirect_itm Make__itm(String url_str, String ttl_str, String wikitext) {
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(url_str));
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(ttl_str));
return new Xopg_redirect_itm(url, ttl, Bry_.new_u8_safe(wikitext));
}
public void Test__Itms__add__special(Xow_special_meta meta, Keyval[] url_args, Xopg_redirect_itm expd) {
mgr.Itms__add__special(wiki, meta, url_args);
Xopg_redirect_itm actl = mgr.Itms__get_at(0);
Gftest.Eq__bry(expd.Ttl().Raw(), actl.Ttl().Raw(), "ttl");
Gftest.Eq__str(expd.Url().To_str(), actl.Url().To_str(), "url");
Gftest.Eq__bry(expd.Wikitext(), actl.Wikitext(), "wikitext");
}
}

View File

@@ -79,17 +79,5 @@ public class Xotdb_fsys_mgr {
return rv;
}
public static Io_url Url_fil(Io_url root_dir, int fil_idx, byte[] ext) {return Xos_url_gen.bld_fil_(root_dir, fil_idx, ext);} private static final String Const_url_cfg = "cfg";
public static Io_url Find_file_or_fail(Io_url dir, String file_name, String file_ext_0, String file_ext_1) {
Io_url url = Find_file_or_null(dir, file_name, file_ext_0, file_ext_1);
if (url == null) throw Err_.new_wo_type("could not find file", "dir", dir.Raw(), "name", file_name, "ext_0", file_ext_0, "ext_1", file_ext_1);
return url;
}
public static Io_url Find_file_or_null(Io_url dir, String file_name, String file_ext_0, String file_ext_1) {
Io_url url = Xob_page_wkr_cmd.Find_fil_by(dir, file_name + file_ext_0);
if (url == null) {
url = Xob_page_wkr_cmd.Find_fil_by(dir, file_name + file_ext_1);
if (url == null) return null;
}
return url;
}
}