mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.8.1.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.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.xtns.wbases.*;
|
||||
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, Gfo_invk {
|
||||
private final Xoae_app app;
|
||||
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.xtns.wbases.*;
|
||||
public class Xow_page_tid {
|
||||
public static byte Identify(int wiki_tid, int ns_id, byte[] ttl) {
|
||||
switch (ns_id) {
|
||||
@@ -37,6 +37,6 @@ public class Xow_page_tid {
|
||||
else if (Bry_.Has_at_end(ttl, Ext_js)) return Tid_js;
|
||||
else return Tid_wikitext;
|
||||
}
|
||||
private static final byte[] Ext_js = Bry_.new_a7(".js"), Ext_css = Bry_.new_a7(".css"), Ext_doc= Bry_.new_a7("/doc");
|
||||
private static final byte[] Ext_js = Bry_.new_a7(".js"), Ext_css = Bry_.new_a7(".css"), Ext_doc= Bry_.new_a7("/doc");
|
||||
public static final byte Tid_wikitext = 1, Tid_json = 2, Tid_js = 3, Tid_css = 4, Tid_lua = 5;
|
||||
}
|
||||
|
||||
@@ -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.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*;
|
||||
import gplx.core.primitives.*; import gplx.core.net.*; import gplx.core.brys.*; import gplx.core.ios.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.apps.*;
|
||||
import gplx.xowa.guis.*;
|
||||
@@ -75,7 +75,9 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, Gfo_invk {
|
||||
public Xol_lang_itm Lang() {return lang;} private final Xol_lang_itm lang;
|
||||
public Xol_case_mgr Case_mgr() {if (case_mgr == null) case_mgr = Xol_case_mgr_.U8(); return case_mgr;} private Xol_case_mgr case_mgr;
|
||||
public Xow_site_stats_mgr Stats() {return stats;} private final Xow_site_stats_mgr stats;
|
||||
public Xow_url_parser Utl__url_parser() {return url__parser;} private final Xow_url_parser url__parser;
|
||||
public Bry_bfr_mkr Utl__bfr_mkr() {return utl__bry_bfr_mkr;} private final Bry_bfr_mkr utl__bry_bfr_mkr = new Bry_bfr_mkr();
|
||||
public Io_stream_zip_mgr Utl__zip_mgr() {return utl__zip_mgr;} private final Io_stream_zip_mgr utl__zip_mgr = new Io_stream_zip_mgr();
|
||||
public Xow_url_parser Utl__url_parser() {return url__parser;} private final Xow_url_parser url__parser;
|
||||
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
|
||||
public Xosp_special_mgr Special_mgr() {return special_mgr;} private Xosp_special_mgr special_mgr;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private final Xow_xwiki_mgr xwiki_mgr;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class Xow_page_cache {
|
||||
else if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if (page.Db().Page().Exists()) {
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect().Itms__get_at_0th_or_null());
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect_trail().Itms__get_wtxt_at_0th_or_null());
|
||||
synchronized (this) { // LOCK:high-usage;DATE:2016-07-14
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
}
|
||||
@@ -55,8 +55,8 @@ public class Xow_page_cache {
|
||||
else if (rv == null) {
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl); // NOTE: do not call Db_mgr.Load_page; need to handle redirects
|
||||
if ( page.Db().Page().Exists() // page exists
|
||||
|| page.Redirect().Itms__len() > 0 ) { // page redirects to missing page; note that page.Missing == true and page.Redirected_src() != null; PAGE: en.w:Shah_Rukh_Khan; DATE:2016-05-02
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect().Itms__get_at_0th_or_null());
|
||||
|| page.Redirect_trail().Itms__len() > 0 ) { // page redirects to missing page; note that page.Missing == true and page.Redirected_src() != null; PAGE: en.w:Shah_Rukh_Khan; DATE:2016-05-02
|
||||
rv = new Xow_page_cache_itm(page.Ttl(), page.Db().Text().Text_bry(), page.Redirect_trail().Itms__get_wtxt_at_0th_or_null());
|
||||
synchronized (this) { // LOCK:high-usage;DATE:2016-07-14
|
||||
cache.Add_bry_obj(ttl_full_db, rv);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ public class Xow_page_cache_itm implements Xowd_text_bry_owner {
|
||||
public int Redirect_id() {return redirect_id;} private int redirect_id;
|
||||
public void Set_text_bry_by_db(byte[] v) {this.wtxt__direct = v;}
|
||||
public void Set_page_ids(int page_id, int redirect_id) {this.page_id = page_id; this.redirect_id = redirect_id;}
|
||||
public void Set_redirect_bry(byte[] trg_wtxt) {
|
||||
public void Set_redirect(Xoa_ttl ttl, byte[] trg_wtxt) {
|
||||
this.ttl = ttl;
|
||||
this.wtxt__redirect = wtxt__direct;
|
||||
this.wtxt__direct = trg_wtxt;
|
||||
}
|
||||
|
||||
@@ -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.wikis.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xoctg_data_ctg_tst {
|
||||
// @Before public void init() {fxt.Clear();} private Xoctg_idx_mgr_fxt fxt = new Xoctg_idx_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
abstract class Xoctg_fmtr_itm_base implements gplx.core.brys.Bfr_arg, Xoctg_fmtr_itm {
|
||||
private Xou_history_mgr history_mgr; private Xoh_wtr_ctx hctx;
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
protected Xowe_wiki wiki; Xol_lang_itm lang; Xoctg_view_ctg ctg; protected int len; protected Xoh_href_parser href_parser; protected Bry_fmtr html_itm, html_itm_missing; protected Xoctg_view_grp list; protected Xow_msg_mgr msg_mgr;
|
||||
public void Init_from_all(Xowe_wiki wiki, Xol_lang_itm lang, Xoh_wtr_ctx hctx, Xoctg_view_ctg ctg, Xoctg_fmtr_all mgr, Xoctg_view_grp itms_list, int itms_list_len) {
|
||||
this.wiki = wiki; this.lang = lang; this.hctx = hctx; this.ctg = ctg; this.list = itms_list; this.len = itms_list_len; this.msg_mgr = wiki.Msg_mgr();
|
||||
@@ -62,7 +63,7 @@ abstract class Xoctg_fmtr_itm_base implements gplx.core.brys.Bfr_arg, Xoctg_fmtr
|
||||
}
|
||||
@gplx.Virtual public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
byte[] itm_href = wiki.Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
byte[] itm_full_ttl = gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(ttl.Full_txt_w_ttl_case());// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
|
||||
byte[] itm_full_ttl = gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(tmp_bfr, ttl.Full_txt_w_ttl_case());// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
|
||||
byte[] itm_atr_cls = hctx.Mode_is_hdump() ? Bry_.Empty : Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
Bry_fmtr fmtr = itm.Missing() ? html_itm_missing : html_itm;
|
||||
fmtr.Bld_bfr_many(bfr, itm_href, itm_full_ttl, itm_full_ttl, itm.Page_id(), itm_atr_cls);
|
||||
|
||||
@@ -76,7 +76,7 @@ class Xoctg_idx_mgr_fxt {
|
||||
return this;
|
||||
} private Xoae_app app; Xowe_wiki wiki; Xoctg_idx_mgr idx_mgr; static final byte[] Ctg_name = Bry_.new_a7("Ctg_test");
|
||||
public byte[] Make_src(int len) {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_k004().Mkr_rls();
|
||||
Bry_bfr bfr = Bry_bfr_.New();
|
||||
bfr.Add_byte_pipe(); // always have leading pipe
|
||||
for (int i = 0; i < len; i++) {
|
||||
bfr.Add_base85_len_5(i).Add_byte(Byte_ascii.Semic); // idx.Id() = i
|
||||
|
||||
@@ -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.wikis.ctgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import org.junit.*;
|
||||
public class Xoctg_view_ctg_tst {
|
||||
// @Before public void init() {fxt.Clear();} private Xoctg_idx_mgr_fxt fxt = new Xoctg_idx_mgr_fxt();
|
||||
@Test public void Basic() {
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@ import org.junit.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_data_mgr_tst {
|
||||
Xow_data_mgr_fxt fxt = new Xow_data_mgr_fxt();
|
||||
@Before public void init() {fxt.Clear(); Tfds.Now_enabled_y_();}
|
||||
@After public void term() {Tfds.Now_enabled_n_();}
|
||||
@Before public void init() {fxt.Clear(); Datetime_now.Manual_y_();}
|
||||
@After public void term() {Datetime_now.Manual_n_();}
|
||||
@Test public void Create() {
|
||||
fxt .Create("A1", "A1 data")
|
||||
.Create("B12", "B12 data")
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.core.primitives.*; import gplx.xowa.wikis.ctgs.*;
|
||||
public class Xowd_category_itm {
|
||||
public int Id() {return id;} private int id;
|
||||
public Int_obj_val Id_val() {if (id_val == null) id_val = Int_obj_val.new_(id); return id_val;} Int_obj_val id_val;
|
||||
public Int_obj_val Id_val() {if (id_val == null) id_val = new Int_obj_val(id); return id_val;} Int_obj_val id_val;
|
||||
public int File_idx() {return file_idx;} private int file_idx;
|
||||
public boolean Hidden() {return hidden;} private boolean hidden;
|
||||
public int Count_all() {return count_subcs + count_files + count_pages;}
|
||||
@@ -40,5 +40,5 @@ public class Xowd_category_itm {
|
||||
rv.count_subcs = count_subcs; rv.count_files = count_files; rv.count_pages = count_pages;
|
||||
return rv;
|
||||
}
|
||||
public static final Xowd_category_itm Null = new Xowd_category_itm(); Xowd_category_itm() {}
|
||||
public static final Xowd_category_itm Null = new Xowd_category_itm(); Xowd_category_itm() {}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_page_itm {
|
||||
public Xowd_page_itm() {this.Clear();}
|
||||
public int Id() {return id;} public Xowd_page_itm Id_(int v) {id = v; id_val = null; return this;} private int id;
|
||||
public Int_obj_val Id_val() {if (id_val == null) id_val = Int_obj_val.new_(id); return id_val;} private Int_obj_val id_val;
|
||||
public Int_obj_val Id_val() {if (id_val == null) id_val = new Int_obj_val(id); return id_val;} private Int_obj_val id_val;
|
||||
public int Ns_id() {return ns_id;} public Xowd_page_itm Ns_id_(int v) {ns_id = v; return this;} private int ns_id;
|
||||
public byte[] Ttl_page_db() {return ttl_page_db;} public Xowd_page_itm Ttl_page_db_(byte[] v) {ttl_page_db = v; return this;} private byte[] ttl_page_db; // EX: Category1
|
||||
public byte[] Ttl_full_db() {return ttl_full_db;} private byte[] ttl_full_db; // EX: Category:Category1
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Xowd_text_tbl implements Rls_able {
|
||||
private final String tbl_name = "text"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_page_id, fld_text_data;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private final Io_stream_zip_mgr zip_mgr = Xoa_app_.Utl__zip_mgr(); private final byte zip_tid;
|
||||
private final Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr(); private final byte zip_tid;
|
||||
public String Fld_text_data() {return fld_text_data;}
|
||||
public Xowd_text_tbl(Db_conn conn, boolean schema_is_1, byte zip_tid) {
|
||||
this.conn = conn; this.zip_tid = zip_tid;
|
||||
|
||||
@@ -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.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.dbs.*; import gplx.xowa.xtns.wbases.*;
|
||||
public class Xowd_wbase_pid_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_src_lang, fld_src_ttl, fld_trg_ttl;
|
||||
|
||||
@@ -62,7 +62,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
int len = ary.length;
|
||||
Xodb_mgr_sql db_mgr = wiki.Db_mgr_as_sql();
|
||||
Xowd_cat_core_tbl cat_core_tbl = db_mgr.Core_data_mgr().Db__cat_core().Tbl__cat_core().Create_tbl();
|
||||
DateAdp modified = DateAdp_.Now();
|
||||
DateAdp modified = Datetime_now.Get();
|
||||
Xowd_page_tbl tbl_page = wiki.Db_mgr_as_sql().Core_data_mgr().Tbl__page();
|
||||
tbl_page.Insert_bgn();
|
||||
cat_core_tbl.Insert_bgn();
|
||||
|
||||
@@ -500,8 +500,8 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
public int Load_pid(byte[] lang_key, byte[] pid_name) {
|
||||
if (pids_root == null)
|
||||
pids_root = wiki.Appe().Wiki_mgr().Wdata_mgr().Wdata_wiki().Tdb_fsys_mgr().Site_dir().GenSubDir_nest("data", "pid");
|
||||
Xob_xdat_itm pid_itm = Load_xdat_itm_by_dir(pids_root.GenSubDir(String_.new_u8(lang_key)), pid_name); if (pid_itm == null) return gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null;
|
||||
return Bry_.To_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wdatas.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
Xob_xdat_itm pid_itm = Load_xdat_itm_by_dir(pids_root.GenSubDir(String_.new_u8(lang_key)), pid_name); if (pid_itm == null) return gplx.xowa.xtns.wbases.Wdata_wiki_mgr.Pid_null;
|
||||
return Bry_.To_int_or(pid_itm.Src(), pid_itm.Itm_bgn() + pid_name.length + 1 + 1, pid_itm.Itm_end(), gplx.xowa.xtns.wbases.Wdata_wiki_mgr.Pid_null); // extract pid; note that all itms have format of "ttl|pid"; +1=skip pipe; +1 skip p
|
||||
} Io_url pids_root;
|
||||
public int Load_ctg_count(byte[] ttl) {return wiki.Db_mgr().Category_version() == Xoa_ctg_mgr.Version_1 ? Load_ctg_count_v1(ttl) : Load_ctg_count_v2(ttl);}
|
||||
int Load_ctg_count_v1(byte[] ttl) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
page_core_tbl.Insert_bgn();
|
||||
page_text_tbl.Insert_bgn();
|
||||
try {
|
||||
db_mgr.Core_data_mgr().Create_page(page_core_tbl, page_text_tbl, page_id, ns_id, ttl.Page_db(), redirect, DateAdp_.Now(), text_zip, text_raw.length, ns_count, page_text_db.Id(), -1);
|
||||
db_mgr.Core_data_mgr().Create_page(page_core_tbl, page_text_tbl, page_id, ns_id, ttl.Page_db(), redirect, Datetime_now.Get(), text_zip, text_raw.length, ns_count, page_text_db.Id(), -1);
|
||||
db_file.Tbl__ns().Update_ns_count(ns_id, ns_count);
|
||||
db_file.Tbl__cfg().Update_int("db", "page.id_next", page_id + 1);
|
||||
} finally {
|
||||
@@ -61,7 +61,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
}
|
||||
public void Data_update(Xoae_page page, byte[] text_raw) {
|
||||
boolean redirect = db_mgr.Wiki().Redirect_mgr().Is_redirect(text_raw, text_raw.length);
|
||||
DateAdp modified = update_modified_on_enabled ? DateAdp_.Now() : page.Db().Page().Modified_on();
|
||||
DateAdp modified = update_modified_on_enabled ? Datetime_now.Get() : page.Db().Page().Modified_on();
|
||||
int page_id = page.Db().Page().Id();
|
||||
db_mgr.Core_data_mgr().Tbl__page().Update__redirect__modified(page_id, redirect, modified);
|
||||
Xowd_page_itm db_page = new Xowd_page_itm();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
int page_id = page_id_next++;
|
||||
int fil_idx = 0;
|
||||
int ns_id = ttl.Ns().Id();
|
||||
Xotdb_page_itm_.Txt_page_save(tmp, page_id, DateAdp_.Now(), ttl_bry, text, true);
|
||||
Xotdb_page_itm_.Txt_page_save(tmp, page_id, Datetime_now.Get(), ttl_bry, text, true);
|
||||
Io_url page_rdr_url = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_page, ns_id, fil_idx);
|
||||
byte[] page_rdr_bry = gplx.core.ios.streams.Io_stream_rdr_.Load_all(page_rdr_url);
|
||||
Xob_xdat_file page_rdr = new Xob_xdat_file();
|
||||
@@ -87,7 +87,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
int text_len = text.length;
|
||||
DateAdp modified_on = tmp_page.Modified_on();
|
||||
if (update_modified_on_enabled) {
|
||||
modified_on = DateAdp_.Now();
|
||||
modified_on = Datetime_now.Get();
|
||||
page.Db().Page().Modified_on_(modified_on);
|
||||
}
|
||||
Xotdb_page_itm_.Txt_page_save(tmp_bfr, db_page.Id(), modified_on, ttl_bry, text, true);
|
||||
|
||||
@@ -96,10 +96,7 @@ public class Xow_domain_uid_ {
|
||||
default: throw Err_.new_unhandled(type_id);
|
||||
}
|
||||
Xol_lang_stub lang = Xol_lang_stub_.Get_by_id(lang_id);
|
||||
Bry_bfr bfr = Xoa_app_.Utl__bfr_mkr().Get_b128();
|
||||
bfr.Add(lang.Key()).Add_byte_dot().Add(tid_bry).Add_byte_dot().Add(Xow_domain_itm_.Seg__org);
|
||||
byte[] domain_bry = bfr.To_bry_and_clear();
|
||||
bfr.Mkr_rls();
|
||||
byte[] domain_bry = Bry_.Add(lang.Key(), Byte_ascii.Dot_bry, tid_bry, Byte_ascii.Dot_bry, Xow_domain_itm_.Seg__org);
|
||||
return Xow_domain_itm.new_(domain_bry, tid_int, lang, lang.Key());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ public class Xow_ns implements Gfo_invk {
|
||||
}
|
||||
this.num_str = Int_.To_str_pad_bgn_zero(id, 3);
|
||||
this.num_bry = Bry_.new_a7(num_str);
|
||||
this.name_enc = Xoa_url_encoder.Instance.Encode(name_db);
|
||||
synchronized (url_encoder) { // LOCK:static-obj
|
||||
this.name_enc = url_encoder.Encode(name_db);
|
||||
}
|
||||
this.name_ui = Bry_.Replace(name_enc, Byte_ascii.Underline, Byte_ascii.Space);
|
||||
this.name_ui_w_colon = Bry_.Replace(name_db_w_colon, Byte_ascii.Underline, Byte_ascii.Space);
|
||||
}
|
||||
@@ -102,4 +104,6 @@ public class Xow_ns implements Gfo_invk {
|
||||
else return Gfo_invk_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_subpages_enabled_ = "subpages_enabled_", Invk_id = "id", Invk_name_txt = "name_txt", Invk_name_ui = "name_ui";
|
||||
|
||||
private static final Xoa_url_encoder url_encoder = new Xoa_url_encoder();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.nss; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xow_ns_canonical_ {
|
||||
public static final Xow_ns[] Ary = new Xow_ns[] // REF.MW: Namespace.php|$wgCanonicalNamespaceNames
|
||||
public static final Xow_ns[] Ary = new Xow_ns[] // REF.MW: Namespace.php|$wgCanonicalNamespaceNames
|
||||
{ New_itm(Xow_ns_.Tid__media , Xow_ns_.Key__media)
|
||||
, New_itm(Xow_ns_.Tid__special , Xow_ns_.Key__special)
|
||||
, New_itm(Xow_ns_.Tid__talk , Xow_ns_.Key__talk)
|
||||
@@ -47,7 +47,7 @@ public class Xow_ns_canonical_ {
|
||||
int len = Ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xow_ns ns = Ary[i];
|
||||
id_hash.Add(ns.Name_db(), Int_obj_val.new_(ns.Id()));
|
||||
id_hash.Add(ns.Name_db(), new Int_obj_val(ns.Id()));
|
||||
}
|
||||
}
|
||||
Object rv_obj = id_hash.Get_by(key);
|
||||
|
||||
@@ -84,7 +84,7 @@ public class Xow_ns_mgr implements Gfo_invk, gplx.core.lists.ComparerAble {
|
||||
}
|
||||
public void Aliases_clear() {aliases.Clear();}
|
||||
public Xow_ns_mgr Aliases_add(int ns_id, String name) {
|
||||
Keyval kv = Keyval_.new_(name, Int_obj_val.new_(ns_id));
|
||||
Keyval kv = Keyval_.new_(name, new Int_obj_val(ns_id));
|
||||
aliases.Add_if_dupe_use_nth(name, kv);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
switch (ns.Id()) {
|
||||
case Xow_ns_.Tid__special: // Special pages are built (not loaded from db)
|
||||
wiki.Special_mgr().Special__gen(wiki.App(), wiki, rv, url, ttl);
|
||||
Xopg_redirect_itm redirect_itm = rv.Redirect().Itms__get_at_nth_or_null();
|
||||
Xopg_redirect_itm redirect_itm = rv.Redirect_trail().Itms__get_at_nth_or_null();
|
||||
if (redirect_itm != null) {
|
||||
rv.Redirect().Clear(); // clear needed; EX: Special:Random -> [[Redirected_page]] -> {must clear here} -> [[Page]]
|
||||
rv.Redirect_trail().Clear(); // clear needed; EX: Special:Random -> [[Redirected_page]] -> {must clear here} -> [[Page]]
|
||||
Load_by_ns(rv, redirect_itm.Url(), redirect_itm.Ttl(), called_from_msg);
|
||||
}
|
||||
return;
|
||||
@@ -92,7 +92,8 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
return;
|
||||
|
||||
// redirect; do some bookkeeping and reset ns / ttl
|
||||
rv.Redirect().Itms__add__article(Xoa_url.New(wiki, redirect_ttl), redirect_ttl, wtxt); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
// NOTE: this adds the target ttl to redirect_mgr (#REDIRECT [[A]]); note that special redirects will add source ttl; DATE:2016-07-31
|
||||
rv.Redirect_trail().Itms__add__article(Xoa_url.New(wiki, rv.Ttl()), rv.Ttl(), wtxt);// NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
rv.Ttl_(redirect_ttl);
|
||||
ns = redirect_ttl.Ns();
|
||||
ttl = redirect_ttl;
|
||||
@@ -110,7 +111,7 @@ public class Xow_page_mgr implements Gfo_invk {
|
||||
rv.Db().Page().Id_(redirect_row.Id()).Modified_on_(redirect_row.Modified_on()).Html_db_id_(redirect_row.Html_db_id());
|
||||
Xoa_ttl redirect_ttl = wiki.Ttl_parse(redirect_row.Ns_id(), redirect_row.Ttl_page_db());
|
||||
rv.Ttl_(redirect_ttl);
|
||||
rv.Redirect().Itms__add__article(Xoa_url.New(wiki, redirect_ttl), redirect_ttl, Bry_.Empty); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
rv.Redirect_trail().Itms__add__article(Xoa_url.New(wiki, redirect_ttl), redirect_ttl, Bry_.Empty); // NOTE: must be url_encoded; EX: "en.wikipedia.org/?!" should generate link of "en.wikipedia.org/%3F!?redirect=no"
|
||||
}
|
||||
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl) {return Load_page_and_parse(url, ttl, wiki.Lang(), wiki.Appe().Gui_mgr().Browser_win().Active_tab(), true);}
|
||||
public Xoae_page Load_page_and_parse(Xoa_url url, Xoa_ttl ttl, Xol_lang_itm lang, Xog_tab_itm tab, boolean parse_page) {
|
||||
@@ -164,7 +165,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__article(trg_url, trg_ttl, null);
|
||||
page.Redirect_trail().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));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ 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 byte[] Itms__get_wtxt_at_0th_or_null() {return itms.Len() == 0 ? null : this.Itms__get_at(0).Wikitext();}
|
||||
public Xopg_redirect_itm Itms__get_at_0th_or_null() {return itms.Len() == 0 ? null : (Xopg_redirect_itm)itms.Get_at(0);}
|
||||
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);}
|
||||
|
||||
@@ -81,8 +81,9 @@ class Xof_file_regy_fxt {
|
||||
Xof_meta_thumb[] To_ary(String[] ary) {
|
||||
int len = ary.length;
|
||||
Xof_meta_thumb[] rv = new Xof_meta_thumb[len];
|
||||
Int_ary_parser parser = new Int_ary_parser();
|
||||
for (int i = 0; i < len; i++) {
|
||||
int[] size = Int_ary_parser.Instance.Parse_ary(ary[i], Byte_ascii.Comma);
|
||||
int[] size = parser.Parse_ary(ary[i], Byte_ascii.Comma);
|
||||
rv[i] = new Xof_meta_thumb().Width_(size[0]).Height_(size[1]).Exists_y_();
|
||||
}
|
||||
return rv;
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.tdbs.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.tdbs.*;
|
||||
import gplx.core.primitives.*;
|
||||
public class Xof_meta_thumb_parser extends Obj_ary_parser_base {
|
||||
Number_parser num_parser = new Number_parser();
|
||||
Int_ary_parser int_ary_parser = new Int_ary_parser();
|
||||
private final Gfo_number_parser number_parser = new Gfo_number_parser();
|
||||
private final Int_ary_parser int_ary_parser = new Int_ary_parser();
|
||||
public Xof_meta_thumb[] Ary() {return ary;} private Xof_meta_thumb[] ary = new Xof_meta_thumb[Ary_max]; static final int Ary_max = 16;
|
||||
public int Len() {return ary_idx;} private int ary_idx;
|
||||
public void Parse_ary(byte[] bry, int bgn, int end) {super.Parse_core(bry, bgn, end, Byte_ascii.Semic, Byte_ascii.Null);}
|
||||
@@ -50,11 +50,11 @@ public class Xof_meta_thumb_parser extends Obj_ary_parser_base {
|
||||
byte b = bry[pos];
|
||||
switch (b) {
|
||||
case Dlm_width: // "," found; assume width; note that seek commas will be handled by seek
|
||||
itm.Width_(num_parser.Parse(bry, num_bgn, pos).Rv_as_int());
|
||||
itm.Width_(number_parser.Parse(bry, num_bgn, pos).Rv_as_int());
|
||||
num_bgn = pos + Int_.Const_dlm_len;
|
||||
break;
|
||||
case Dlm_seek:
|
||||
itm.Height_(num_parser.Parse(bry, num_bgn, pos).Rv_as_int());
|
||||
itm.Height_(number_parser.Parse(bry, num_bgn, pos).Rv_as_int());
|
||||
num_bgn = pos + Int_.Const_dlm_len;
|
||||
height_found = true;
|
||||
itm.Seeks_(int_ary_parser.Parse_ary(bry, num_bgn, end, Byte_ascii.Comma));
|
||||
@@ -64,7 +64,7 @@ public class Xof_meta_thumb_parser extends Obj_ary_parser_base {
|
||||
++pos;
|
||||
}
|
||||
if (!height_found) // handle '1:2,3' as opposed to '1:2,3@4'
|
||||
itm.Height_(num_parser.Parse(bry, num_bgn, end).Rv_as_int());
|
||||
itm.Height_(number_parser.Parse(bry, num_bgn, end).Rv_as_int());
|
||||
ary[ary_idx++] = itm;
|
||||
}
|
||||
static final String GRP_KEY = "xowa.meta.itm.file";
|
||||
|
||||
@@ -19,9 +19,9 @@ package gplx.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.apps.apis.xowa.html.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.xtns.wdatas.core.*;
|
||||
import gplx.xowa.xtns.wbases.core.*;
|
||||
public class Xoa_sitelink_div_wtr {
|
||||
private final Xoa_sitelink_grp_wtr grp_wtr = new Xoa_sitelink_grp_wtr();
|
||||
private final Xoa_sitelink_grp_wtr grp_wtr = new Xoa_sitelink_grp_wtr();
|
||||
public void Write(Bry_bfr bfr, Xowe_wiki wiki, Xoa_sitelink_mgr mgr, List_adp slink_list, byte[] qid) {
|
||||
Xoa_sitelink_grp_mgr grp_mgr = mgr.Grp_mgr(); Xoa_sitelink_itm_mgr itm_mgr = mgr.Itm_mgr();
|
||||
// reset grps
|
||||
@@ -52,12 +52,14 @@ public class Xoa_sitelink_div_wtr {
|
||||
// write html
|
||||
Xoapi_toggle_itm toggle_itm = wiki.Appe().Api_root().Html().Page().Toggle_mgr().Get_or_new("wikidata-langs");
|
||||
toggle_itm.Init(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_page_lang_header));
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b128().Mkr_rls();
|
||||
byte[] wikidata_link = Bry_.Len_eq_0(qid) ? Bry_.Empty : wbase_fmtr.Bld_bry_many(tmp_bfr, qid);
|
||||
div_fmtr.Bld_bfr_many(bfr, slink_len, wikidata_link, toggle_itm.Html_toggle_btn(), toggle_itm.Html_toggle_hdr(), grp_wtr.Fmt__init(grp_mgr));
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b128();
|
||||
try {
|
||||
byte[] wikidata_link = Bry_.Len_eq_0(qid) ? Bry_.Empty : wbase_fmtr.Bld_bry_many(tmp_bfr, qid);
|
||||
div_fmtr.Bld_bfr_many(bfr, slink_len, wikidata_link, toggle_itm.Html_toggle_btn(), toggle_itm.Html_toggle_hdr(), grp_wtr.Fmt__init(grp_mgr));
|
||||
} finally {tmp_bfr.Mkr_rls();}
|
||||
}
|
||||
private static final Bry_fmtr wbase_fmtr = Bry_fmtr.new_(" (<a href=\"/site/www.wikidata.org/wiki/~{qid}\">wikidata</a>)", "qid");
|
||||
private static final Bry_fmtr div_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
private static final Bry_fmtr wbase_fmtr = Bry_fmtr.new_(" (<a href=\"/site/www.wikidata.org/wiki/~{qid}\">wikidata</a>)", "qid");
|
||||
private static final Bry_fmtr div_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"xowa-lang\">"
|
||||
, " <h5>~{toggle_btn} (links: ~{len}) ~{wikidata_link}</h5>"
|
||||
, " <div~{toggle_hdr}>~{grps}"
|
||||
|
||||
@@ -56,7 +56,7 @@ class Xoa_sitelink_div_wtr_fxt {
|
||||
wiki.Html_mgr().Html_wtr().Write_doc(bfr, ctx, raw_bry, root);
|
||||
|
||||
Bry_bfr html_bfr = Bry_bfr_.New();
|
||||
wiki.App().Xwiki_mgr__sitelink_mgr().Write_html(html_bfr, wiki, ctx.Page().Slink_list(), gplx.xowa.xtns.wdatas.Wdata_xwiki_link_wtr.Qid_null);
|
||||
wiki.App().Xwiki_mgr__sitelink_mgr().Write_html(html_bfr, wiki, ctx.Page().Slink_list(), gplx.xowa.xtns.wbases.Wdata_xwiki_link_wtr.Qid_null);
|
||||
Tfds.Eq_str_lines(expd, html_bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.xwikis.sitelinks.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
class Xoa_sitelink_grp_wtr implements gplx.core.brys.Bfr_arg {
|
||||
private final Xoa_sitelink_itm_wtr itm_wtr = new Xoa_sitelink_itm_wtr();
|
||||
private final Xoa_sitelink_itm_wtr itm_wtr = new Xoa_sitelink_itm_wtr();
|
||||
private Xoa_sitelink_grp_mgr mgr;
|
||||
public void Init_by_app(Xoa_app app) {itm_wtr.Init_by_app(app);}
|
||||
public Xoa_sitelink_grp_wtr Fmt__init(Xoa_sitelink_grp_mgr mgr) {this.mgr = mgr; return this;}
|
||||
@@ -30,7 +30,7 @@ class Xoa_sitelink_grp_wtr implements gplx.core.brys.Bfr_arg {
|
||||
fmtr.Bld_bfr_many(bfr, grp.Name(), itm_wtr.Fmt__init(grp));
|
||||
}
|
||||
}
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
private static final Bry_fmtr fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <h4>~{all_name}</h4>"
|
||||
, " <table style='width: 100%;'>~{grps}"
|
||||
|
||||
Reference in New Issue
Block a user