mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
'v3.4.3.1'
This commit is contained in:
parent
14471ca656
commit
ad140a93fe
@ -265,6 +265,12 @@ public class Bry_ {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static boolean Has_at_end(byte[] src, byte lkp) {
|
||||
if (src == null) return false;
|
||||
int src_len = src.length;
|
||||
if (src_len == 0) return false;
|
||||
return src[src_len - 1] == lkp;
|
||||
}
|
||||
public static boolean Has_at_end(byte[] src, byte[] lkp) {int src_len = src.length; return Has_at_end(src, lkp, src_len - lkp.length, src_len);}
|
||||
public static boolean Has_at_end(byte[] src, byte[] lkp, int src_bgn, int src_end) {
|
||||
int lkp_len = lkp.length;
|
||||
@ -585,6 +591,9 @@ public class Bry_ {
|
||||
else if (b2 != 0) return new byte[] {b2, b3};
|
||||
else return new byte[] {b3};
|
||||
}
|
||||
public static boolean To_bool_or(byte[] raw, boolean or) {
|
||||
return Bry_.Eq(raw, Bool_.True_bry) ? true : or;
|
||||
}
|
||||
public static boolean To_bool_by_int(byte[] ary) {
|
||||
int rv = To_int_or(ary, 0, ary.length, Int_.Min_value, Bool_.Y, null);
|
||||
switch (rv) {
|
||||
|
@ -21,8 +21,8 @@ public interface GfoInvkAble {
|
||||
}
|
||||
/*
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_set)) {}
|
||||
if (ctx.Match(k, Invk__set)) {}
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk_set = "set";
|
||||
} private static final String Invk__set = "set";
|
||||
*/
|
||||
|
@ -138,9 +138,9 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
public static void Err_has(Exception e, String hdr) {
|
||||
Tfds.Eq_true(String_.Has(Err_.Message_gplx_full(e), hdr), "could not find '{0}' in '{1}'", hdr, Err_.Message_gplx_full(e));
|
||||
}
|
||||
static final String EmptyStr = TfdsMsgBldr.EmptyStr;
|
||||
static final String EmptyStr = TfdsMsgBldr.EmptyStr;
|
||||
static TfdsMsgBldr msgBldr = TfdsMsgBldr.new_();
|
||||
public static final Io_url RscDir = Io_url_.Usr().GenSubDir_nest("000", "200_dev", "190_tst");
|
||||
public static final Io_url RscDir = Io_url_.Usr().GenSubDir_nest("000", "200_dev", "190_tst");
|
||||
public static DateAdp Now_time0_add_min(int minutes) {return time0.Add_minute(minutes);}
|
||||
@gplx.Internal protected static boolean Now_enabled() {return now_enabled;} private static boolean now_enabled; private static boolean now_freeze;
|
||||
public static void Now_enabled_n_() {now_enabled = false; now_freeze = false;}
|
||||
@ -152,7 +152,7 @@ public class Tfds { // URL:doc/gplx.tfds/Tfds.txt
|
||||
if (!now_freeze) nowTime = rv.Add_minute(1);
|
||||
return rv;
|
||||
}
|
||||
private static final DateAdp time0 = DateAdp_.parse_gplx("2001-01-01 00:00:00.000");
|
||||
private static final DateAdp time0 = DateAdp_.parse_gplx("2001-01-01 00:00:00.000");
|
||||
private static DateAdp nowTime; // NOTE: cannot set to time0 due to static initialization;
|
||||
public static void WriteText(String text) {Console_adp__sys.Instance.Write_str(text);}
|
||||
public static void Write(byte[] s, int b, int e) {Write(Bry_.Mid(s, b, e));}
|
||||
@ -170,7 +170,7 @@ class TfdsEqListItmStr_cls_default implements TfdsEqListItmStr {
|
||||
public String To_str(Object cur, Object actl) {
|
||||
return Object_.Xto_str_strict_or_null_mark(cur);
|
||||
}
|
||||
public static final TfdsEqListItmStr_cls_default Instance = new TfdsEqListItmStr_cls_default(); TfdsEqListItmStr_cls_default() {}
|
||||
public static final TfdsEqListItmStr_cls_default Instance = new TfdsEqListItmStr_cls_default(); TfdsEqListItmStr_cls_default() {}
|
||||
}
|
||||
class TfdsEqAryItm {
|
||||
public int Idx() {return idx;} public TfdsEqAryItm Idx_(int v) {idx = v; return this;} int idx;
|
||||
@ -244,5 +244,5 @@ class TfdsMsgBldr {
|
||||
);
|
||||
}
|
||||
public static TfdsMsgBldr new_() {return new TfdsMsgBldr();} TfdsMsgBldr() {}
|
||||
public static final String EmptyStr = "";
|
||||
public static final String EmptyStr = "";
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class Db_conn {
|
||||
public Db_batch_mgr Batch_mgr() {return engine.Batch_mgr();}
|
||||
public Db_engine Engine() {return engine;} private final Db_engine engine;
|
||||
public Db_sys_mgr Sys_mgr() {return sys_mgr;} private final Db_sys_mgr sys_mgr; // autonum and other functions
|
||||
public boolean Eq(Db_conn comp) {return String_.Eq(engine.Conn_info().Db_api(), comp.Conn_info().Db_api());}
|
||||
public boolean Eq(Db_conn comp) {return String_.Eq(engine.Conn_info().Db_api(), comp.Conn_info().Db_api());}
|
||||
public void Txn_bgn(String name) {engine.Txn_bgn(name);}
|
||||
public void Txn_end() {engine.Txn_end();}
|
||||
public void Txn_cxl() {engine.Txn_cxl();}
|
||||
@ -45,9 +45,9 @@ public class Db_conn {
|
||||
public void Meta_idx_create(Gfo_usr_dlg usr_dlg, Dbmeta_idx_itm... idxs) {engine.Meta_idx_create(usr_dlg, idxs);}
|
||||
public void Meta_fld_append(String tbl, Dbmeta_fld_itm fld) {engine.Meta_fld_append(tbl, fld);}
|
||||
public void Meta_fld_assert(String tbl, String fld, Dbmeta_fld_tid tid, Object dflt) {if (!Meta_fld_exists(tbl, fld)) this.Meta_fld_append(tbl, new Dbmeta_fld_itm(fld, tid).Default_(dflt));}
|
||||
public boolean Meta_tbl_exists(String tbl) {return engine.Meta_tbl_exists(tbl);}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return engine.Meta_fld_exists(tbl, fld);}
|
||||
public boolean Meta_idx_exists(String idx) {return engine.Meta_idx_exists(idx);}
|
||||
public boolean Meta_tbl_exists(String tbl) {return engine.Meta_tbl_exists(tbl);}
|
||||
public boolean Meta_fld_exists(String tbl, String fld) {return engine.Meta_fld_exists(tbl, fld);}
|
||||
public boolean Meta_idx_exists(String idx) {return engine.Meta_idx_exists(idx);}
|
||||
public Dbmeta_tbl_mgr Meta_mgr() {return engine.Meta_mgr();}
|
||||
public Db_stmt Stmt_insert(String tbl, Dbmeta_fld_list flds) {return engine.Stmt_by_qry(Db_qry_insert.new_(tbl, flds.To_str_ary_wo_autonum()));}
|
||||
public Db_stmt Stmt_insert(String tbl, String... cols) {return engine.Stmt_by_qry(Db_qry_insert.new_(tbl, cols));}
|
||||
|
@ -15,11 +15,7 @@ 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.bldrs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
interface Xowd_page_cmd {
|
||||
String Cmd_key();
|
||||
void Cmd_bgn(Xob_bldr bldr);
|
||||
void Cmd_run(Xowd_page_itm page);
|
||||
void Cmd_end();
|
||||
package gplx.core.brys; import gplx.*; import gplx.core.*;
|
||||
public interface Bry_bfr_able {
|
||||
void To_bfr(Bry_bfr bfr);
|
||||
}
|
37
400_xowa/src/gplx/core/brys/Bry_bfr_able_.java
Normal file
37
400_xowa/src/gplx/core/brys/Bry_bfr_able_.java
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.core.brys; import gplx.*; import gplx.core.*;
|
||||
public class Bry_bfr_able_ {
|
||||
public static byte[][] To_bry_ary(Bry_bfr tmp_bfr, Bry_bfr_able[] ary) {
|
||||
int len = ary.length;
|
||||
byte[][] rv = new byte[len][];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Bry_bfr_able itm = ary[i];
|
||||
if (itm != null) {
|
||||
itm.To_bfr(tmp_bfr);
|
||||
rv[i] = tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static byte[] To_bry_or_null(Bry_bfr tmp_bfr, Bry_bfr_able itm) {
|
||||
if (itm == null) return null;
|
||||
itm.To_bfr(tmp_bfr);
|
||||
return tmp_bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
102
400_xowa/src/gplx/core/tests/Gftest.java
Normal file
102
400_xowa/src/gplx/core/tests/Gftest.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
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.core.tests; import gplx.*; import gplx.core.*;
|
||||
import gplx.core.brys.*;
|
||||
public class Gftest {
|
||||
private static Bry_bfr bfr = Bry_bfr.new_();
|
||||
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary) {Eq__ary(expd_ary, actl_ary, null);}
|
||||
public static void Eq__ary(Bry_bfr_able[] expd_ary, Bry_bfr_able[] actl_ary, String msg_fmt, Object... msg_args) {
|
||||
byte[][] expd_bry_ary = Bry_bfr_able_.To_bry_ary(bfr, expd_ary);
|
||||
byte[][] actl_bry_ary = Bry_bfr_able_.To_bry_ary(bfr, actl_ary);
|
||||
boolean[] failures = Calc__failures(Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
|
||||
if (failures != null) {
|
||||
bfr.Add(Bry__line_bgn);
|
||||
if (msg_fmt != null) {
|
||||
bfr.Add_str_u8(String_.Format(msg_fmt, msg_args));
|
||||
bfr.Add(Bry__line_mid);
|
||||
}
|
||||
Write__failures(bfr, failures, Type_adp_.Tid__bry, expd_bry_ary, actl_bry_ary);
|
||||
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
||||
}
|
||||
}
|
||||
private static void Write__failures(Bry_bfr bfr, boolean[] failures, int type_id, Object expd_ary, Object actl_ary) {
|
||||
int len = failures.length;
|
||||
int expd_len = Array_.Len(expd_ary);
|
||||
int actl_len = Array_.Len(actl_ary);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
boolean failure = failures[i];
|
||||
bfr.Add_int_pad_bgn(Byte_ascii.Num_0, 5 - Int_.DigitCount(i), i).Add_byte_colon().Add_byte_space();
|
||||
Write__itm(bfr, type_id, expd_ary, expd_len, i);
|
||||
if (failure) {
|
||||
bfr.Add(Bry__item__eq_n).Add_byte_repeat(Byte_ascii.Space, 3);
|
||||
Write__itm(bfr, type_id, actl_ary, actl_len, i);
|
||||
}
|
||||
}
|
||||
bfr.Add(Bry__line_end);
|
||||
}
|
||||
private static void Write__itm(Bry_bfr bfr, int type_id, Object ary, int len, int idx) {
|
||||
if (idx < len) {
|
||||
switch (type_id) {
|
||||
case Type_adp_.Tid__bry: bfr.Add((byte[])Array_.Get_at(ary, idx)); break;
|
||||
default: throw Err_.new_unhandled_default(type_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
bfr.Add(Bry__null);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
private static boolean[] Calc__failures(int tid, Object expd_ary, Object actl_ary) {
|
||||
int expd_len = Array_.Len(expd_ary);
|
||||
int actl_len = Array_.Len(actl_ary);
|
||||
int max_len = expd_len > actl_len ? expd_len : actl_len; if (max_len == 0) return null;
|
||||
boolean[] rv = null;
|
||||
for (int i = 0; i < max_len; ++i) {
|
||||
Object expd_obj = i < expd_len ? Array_.Get_at(expd_ary, i) : null;
|
||||
Object actl_obj = i < actl_len ? Array_.Get_at(actl_ary, i) : null;
|
||||
boolean eq = false;
|
||||
switch (tid) {
|
||||
case Type_adp_.Tid__bry: eq = Bry_.Eq((byte[])expd_obj, (byte[])actl_obj); break;
|
||||
}
|
||||
if (!eq) {
|
||||
if (rv == null) {
|
||||
rv = new boolean[max_len];
|
||||
}
|
||||
rv[i] = true;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static final byte[] Bry__item__eq_n = Bry_.new_a7("!= ") // Bry__item__eq_y = Bry_.new_a7("== "),
|
||||
, Bry__null = Bry_.new_a7("<<NULL>>")
|
||||
, Bry__line_bgn = Bry_.new_a7("\n************************************************************************************************\n")
|
||||
, Bry__line_mid = Bry_.new_a7("\n------------------------------------------------------------------------------------------------\n")
|
||||
, Bry__line_end = Bry_.new_a7( "________________________________________________________________________________________________")
|
||||
;
|
||||
}
|
||||
/*
|
||||
package ns;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Cls1_tst {
|
||||
private final Cls1_fxt fxt = new Cls1_fxt();
|
||||
@Test public void Basic() {}
|
||||
}
|
||||
class Cls1_fxt {
|
||||
private final Cls1 mgr = new Cls1();
|
||||
public Cls1_fxt Test() {return this;}
|
||||
}
|
||||
*/
|
@ -66,6 +66,7 @@ public class Db_cfg_tbl implements Rls_able {
|
||||
public void Upsert_int (String grp, String key, int val) {Upsert_str(grp, key, Int_.To_str(val));}
|
||||
public void Upsert_date (String grp, String key, DateAdp val) {Upsert_str(grp, key, val.XtoStr_fmt_yyyyMMdd_HHmmss());}
|
||||
public void Upsert_guid (String grp, String key, Guid_adp val) {Upsert_str(grp, key, val.To_str());}
|
||||
public void Upsert_bry (String grp, String key, byte[] val) {Upsert_str(grp, key, String_.new_u8(val));}
|
||||
public void Upsert_str (String grp, String key, String val) {
|
||||
String cur_val = this.Select_str_or(grp, key, null);
|
||||
if (cur_val == null) this.Insert_str(grp, key, val);
|
||||
|
@ -43,6 +43,10 @@ public class Gfh_tag_ {
|
||||
, Bry__ul = Bry_.new_a7("ul")
|
||||
, Bry__td = Bry_.new_a7("td")
|
||||
, Bry__th = Bry_.new_a7("th")
|
||||
, Bry__div = Bry_.new_a7("div")
|
||||
, Bry__link = Bry_.new_a7("link")
|
||||
, Bry__style = Bry_.new_a7("style")
|
||||
, Bry__script = Bry_.new_a7("script")
|
||||
;
|
||||
public static final Hash_adp_bry Hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_int(Bry__a , Id__a)
|
||||
|
@ -34,7 +34,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "3.4.2.1";
|
||||
public static final String Version = "3.4.3.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
@ -47,7 +47,7 @@ public class Xowe_wiki implements Xow_wiki, GfoInvkAble, GfoEvObj {
|
||||
file_mgr = new Xow_file_mgr(this);
|
||||
parser_mgr = new Xow_parser_mgr(this);
|
||||
cfg_parser = new Xowc_parser(this);
|
||||
props.SiteName_(domain_tid).ServerName_(domain_bry);
|
||||
props.Init_props(domain_tid, domain_bry);
|
||||
props.ContentLanguage_(lang.Key_bry());
|
||||
stats = new Xow_site_stats_mgr(this);
|
||||
Pf_func_.Reg(domain_itm, lang.Func_regy(), lang);
|
||||
|
@ -41,6 +41,7 @@ public class Xoax_addon_mgr {
|
||||
, new gplx.xowa.addons.apps.searchs .Xoax_builds_search_addon()
|
||||
, new gplx.xowa.addons.apps.file_browsers .Fbrow_addon()
|
||||
, new gplx.xowa.addons.updates.files .Xoax_updates_files_addon()
|
||||
, new gplx.xowa.addons.builds.htmls .Html__dump_to_fsys__addon()
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class Fbrow_special_page implements Xows_page {
|
||||
|
||||
// write head
|
||||
Xopage_html_data rv = new Xopage_html_data(Display_ttl, body);
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css(addon_dir.GenSubFil_nest("bin", "file_browser.css")));
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "file_browser.css")));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class Wikis_list_wtr {
|
||||
|
||||
// write to html
|
||||
Xopage_html_data rv = new Xopage_html_data(Wikis_list_page.Display_ttl, body);
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css(addon_dir.GenSubFil_nest("bin", "wiki_list.css")));
|
||||
rv.Head_tags().Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "wiki_list.css")));
|
||||
return rv;
|
||||
}
|
||||
private static byte[] Get_root_url() {
|
||||
|
@ -30,9 +30,6 @@ public class Xopage_html_data {
|
||||
public void Apply(Xoa_page page) {
|
||||
page.Html_data().Html_restricted_n_();
|
||||
page.Html_data().Skip_parse_(Bool_.Y);
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
page.Html_data().Custom_head_end_concat(head_tags.To_html(bfr));
|
||||
page.Html_data().Custom_html_end_concat(tail_tags.To_html(bfr));
|
||||
page.Html_data().Display_ttl_(display_ttl);
|
||||
page.Html_data().Custom_body_(this.Body());
|
||||
page.Html_data().Custom_head_tags().Copy(head_tags);
|
||||
|
@ -16,20 +16,21 @@ 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.apps.searchs.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.searchs.*;
|
||||
import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Srch_bldr_wkr implements Xob_page_wkr {
|
||||
private final Xowe_wiki wiki;
|
||||
private final Srch_temp_tbl_wkr temp_tbl_wkr = new Srch_temp_tbl_wkr();
|
||||
public Srch_bldr_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public String Wkr_key() {return Xob_cmd_keys.Key_text_search_wkr;}
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
public String Page_wkr__key() {return Xob_cmd_keys.Key_text_search_wkr;}
|
||||
public void Page_wkr__bgn() {
|
||||
temp_tbl_wkr.Init(Bool_.N, wiki);
|
||||
}
|
||||
public void Wkr_run(gplx.xowa.wikis.data.tbls.Xowd_page_itm page) {
|
||||
public void Page_wkr__run(gplx.xowa.wikis.data.tbls.Xowd_page_itm page) {
|
||||
try {temp_tbl_wkr.Exec_by_wkr(page.Id(), page.Ttl_page_db());}
|
||||
catch (Exception e) {Gfo_usr_dlg_.Instance.Warn_many("", "", "search:error: page=~{0} err=~{1}", page.Ttl_page_db(), Err_.Message_gplx_full(e));}
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Page_wkr__end() {
|
||||
temp_tbl_wkr.Term();
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
|
@ -50,10 +50,10 @@ class Srch_temp_tbl_wkr implements Srch_text_parser_wkr {
|
||||
Db_conn word_conn = search_temp_tbl.conn;
|
||||
|
||||
// update search_word ids if they exist
|
||||
Srch_db_mgr.Optimize_unsafe_(word_conn, Bool_.Y);
|
||||
// Srch_db_mgr.Optimize_unsafe_(word_conn, Bool_.Y); // NOTE: fails in multi-db due to transaction
|
||||
Update_word_id(word_conn, wiki);
|
||||
Search_word__insert(word_conn);
|
||||
Srch_db_mgr.Optimize_unsafe_(word_conn, Bool_.N);
|
||||
// Srch_db_mgr.Optimize_unsafe_(word_conn, Bool_.N);
|
||||
|
||||
// create search_link
|
||||
Db_conn page_conn = wiki.Data__core_mgr().Tbl__page().conn;
|
||||
|
@ -39,10 +39,10 @@ public class Srch_temp_tbl {
|
||||
}
|
||||
public void Insert_end() {
|
||||
conn.Txn_end();
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
Srch_db_mgr.Optimize_unsafe_(conn, Bool_.Y);
|
||||
conn.Meta_idx_create(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "word_text__word_id", fld_word_text, fld_word_id));
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
// Srch_db_mgr.Optimize_unsafe_(conn, Bool_.Y); // NOTE: fails in multi-db due to transaction
|
||||
conn.Meta_idx_create(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "word_text__word_id", fld_word_text, fld_word_id));
|
||||
// conn.Meta_idx_create(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "page_id", fld_page_id));
|
||||
Srch_db_mgr.Optimize_unsafe_(conn, Bool_.N);
|
||||
// Srch_db_mgr.Optimize_unsafe_(conn, Bool_.N);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
/*
|
||||
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.builds.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Html__dump_to_fsys__addon implements Xoax_addon_itm, Xoax_addon_itm__bldr {
|
||||
public Xob_cmd[] Cmds_ary() {
|
||||
return new Xob_cmd[]
|
||||
{ Html__dump_to_fsys__cmd.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
public static final byte[] ADDON_KEY = Bry_.new_a7("xowa.builds.htmls");
|
||||
public byte[] Addon__key() {return ADDON_KEY;}
|
||||
}
|
@ -15,43 +15,54 @@ 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.updates.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.updates.*;
|
||||
package gplx.xowa.addons.builds.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.xowa.files.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
public class Xobldr__deletion_db__temp extends Xob_cmd__base {
|
||||
private Io_url template_url, dump_root;
|
||||
public Xobldr__deletion_db__temp(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Html__dump_to_fsys__cmd extends Xob_cmd__base {
|
||||
private Io_url template_url, fsys_root;
|
||||
private byte[] http_root, page_root;
|
||||
private boolean skip_unchanged = true;
|
||||
public Html__dump_to_fsys__cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
// init mustache
|
||||
Mustache_tkn_parser parser = new Mustache_tkn_parser();
|
||||
Mustache_tkn_itm root = parser.Parse(Io_mgr.Instance.LoadFilBry(template_url));
|
||||
Mustache_render_ctx ctx = new Mustache_render_ctx();
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
Mustache_bfr mbfr = new Mustache_bfr(bfr);
|
||||
Xo_page_dump_to_html page_itm = new Xo_page_dump_to_html();
|
||||
Html_page_itm page_itm = new Html_page_itm();
|
||||
|
||||
// load rdr
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.File_dump(page_root, Bry_.new_a7(".html"));
|
||||
wiki.Init_assert();
|
||||
gplx.xowa.wikis.data.tbls.Xowd_page_tbl page_tbl = wiki.Data__core_mgr().Db__core().Tbl__page();
|
||||
Db_conn conn = page_tbl.conn;
|
||||
Db_rdr rdr = conn.Exec_rdr("SELECT page_id, page_title, page_touched FROM page WHERE page_namespace = 0;");
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.File_dump(Bry_.new_a7("/page/"), Bry_.new_a7(".html"));
|
||||
while (rdr.Move_next()) {
|
||||
String page_ttl = rdr.Read_str("page_title");
|
||||
String page_ttl_str = rdr.Read_str("page_title");
|
||||
try {
|
||||
Xoa_ttl ttl = wiki.Ttl_parse(Bry_.new_u8(page_ttl));
|
||||
DateAdp page_modified_last = DateAdp_.parse_fmt(rdr.Read_str("page_touched"), gplx.xowa.wikis.data.tbls.Xowd_page_tbl.Page_touched_fmt);
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(wiki.Utl__url_parser().Parse(Bry_.new_u8(page_ttl)), ttl);
|
||||
// load page
|
||||
Xoa_ttl page_ttl = wiki.Ttl_parse(Bry_.new_u8(page_ttl_str));
|
||||
DateAdp page_modified_on = DateAdp_.parse_fmt(rdr.Read_str("page_touched"), gplx.xowa.wikis.data.tbls.Xowd_page_tbl.Page_touched_fmt);
|
||||
Io_url dump_fil_url = Io_url_.new_fil_(fsys_root.Gen_sub_path_for_os(page_ttl_str) + ".html");
|
||||
if (skip_unchanged && Io_mgr.Instance.QueryFil(dump_fil_url).ModifiedTime().Eq(page_modified_on)) continue;
|
||||
|
||||
// parse page
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(wiki.Utl__url_parser().Parse(page_ttl.Page_db()), page_ttl);
|
||||
wiki.Parser_mgr().Parse(page, true);
|
||||
page.Wikie().Html_mgr().Page_wtr_mgr().Page_read_fmtr().Fmt_("~{page_data}");
|
||||
page.Wikie().Html_mgr().Page_wtr_mgr().Wkr(gplx.xowa.wikis.pages.Xopg_page_.Tid_read).Write_body(bfr, hctx, page);
|
||||
byte[] html_src = bfr.To_bry_and_clear();//page.Wikie().Html_mgr().Page_wtr_mgr().Gen(page, gplx.xowa.wikis.pages.Xopg_page_.Tid_read); // NOTE: must use wiki of page, not of owner tab; DATE:2015-03-05
|
||||
page_itm.Init(page_ttl, Bry_.Empty, Bry_.Empty, html_src);
|
||||
byte[] html_head = page.Html_data().Custom_head_tags().To_html__style(bfr);
|
||||
|
||||
// fmt with mustache; write to file
|
||||
page_itm.Init(http_root, page_root, page_ttl.Page_txt(), html_head, Bry_.Empty, html_src);
|
||||
root.Render(mbfr, ctx.Init(page_itm));
|
||||
Io_url dump_fil_url = Io_url_.new_fil_(dump_root.Gen_sub_path_for_os(page_ttl) + ".html");
|
||||
if (Io_mgr.Instance.QueryFil(dump_fil_url).ModifiedTime().Eq(page_modified_last)) continue;
|
||||
Io_mgr.Instance.SaveFilBry(dump_fil_url, mbfr.To_bry_and_clear());
|
||||
Io_mgr.Instance.UpdateFilModifiedTime(dump_fil_url, page_modified_last);
|
||||
Io_mgr.Instance.UpdateFilModifiedTime(dump_fil_url, page_modified_on);
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "err: ~{0}", Err_.Message_gplx_log(e));
|
||||
}
|
||||
@ -59,37 +70,19 @@ public class Xobldr__deletion_db__temp extends Xob_cmd__base {
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__template_url_)) this.template_url = m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk__dump_root_)) this.dump_root = m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk__fsys_root_)) this.fsys_root = m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk__http_root_)) this.http_root = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk__page_root_)) this.page_root = m.ReadBry("v");
|
||||
else if (ctx.Match(k, Invk__skip_unchanged_)) this.skip_unchanged = m.ReadYn("v");
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} private static final String Invk__template_url_ = "template_url_", Invk__dump_root_ = "dump_root_";
|
||||
}
|
||||
private static final String Invk__template_url_ = "template_url_", Invk__fsys_root_ = "fsys_root_"
|
||||
, Invk__http_root_ = "http_root_", Invk__page_root_ = "page_root_"
|
||||
, Invk__skip_unchanged_ = "skip_unchanged_";
|
||||
|
||||
public static final String BLDR_CMD_KEY = "html.dump_to_file";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
public static final Xob_cmd Prototype = new Xobldr__deletion_db__temp(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Xobldr__deletion_db__temp(bldr, wiki);}
|
||||
}
|
||||
class Xo_page_dump_to_html implements Mustache_doc_itm {
|
||||
private String page_title;
|
||||
private byte[] page_head_extra;
|
||||
private byte[] page_caption;
|
||||
private byte[] page_body;
|
||||
public Xo_page_dump_to_html Init(String page_title, byte[] page_head_extra, byte[] page_caption, byte[] page_body) {
|
||||
this.page_title = page_title;
|
||||
this.page_head_extra = page_head_extra;
|
||||
this.page_caption = page_caption;
|
||||
this.page_body = page_body;
|
||||
return this;
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr mbfr) {
|
||||
if (String_.Eq(key, "page_title")) mbfr.Add_str_u8(page_title);
|
||||
else if (String_.Eq(key, "page_head_extra")) mbfr.Add_bry(page_head_extra);
|
||||
else if (String_.Eq(key, "page_caption")) mbfr.Add_bry(page_caption);
|
||||
else if (String_.Eq(key, "page_body")) mbfr.Add_bry(page_body);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
public static final Xob_cmd Prototype = new Html__dump_to_fsys__cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Html__dump_to_fsys__cmd(bldr, wiki);}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
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.builds.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
class Html_page_itm implements Mustache_doc_itm {
|
||||
private byte[] http_root;
|
||||
private byte[] page_root;
|
||||
private byte[] page_title;
|
||||
private byte[] page_head_extra;
|
||||
private byte[] page_caption;
|
||||
private byte[] page_body;
|
||||
public Html_page_itm Init(byte[] http_root, byte[] page_root, byte[] page_title, byte[] page_head_extra, byte[] page_caption, byte[] page_body) {
|
||||
this.http_root = http_root;
|
||||
this.page_root = page_root;
|
||||
this.page_title = page_title;
|
||||
this.page_head_extra = page_head_extra;
|
||||
this.page_caption = page_caption;
|
||||
this.page_body = page_body;
|
||||
return this;
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr mbfr) {
|
||||
if (String_.Eq(key, "page_title")) mbfr.Add_bry(page_title);
|
||||
else if (String_.Eq(key, "http_root")) mbfr.Add_bry(http_root);
|
||||
else if (String_.Eq(key, "page_root")) mbfr.Add_bry(page_root);
|
||||
else if (String_.Eq(key, "page_head_extra")) mbfr.Add_bry(page_head_extra);
|
||||
else if (String_.Eq(key, "page_caption")) mbfr.Add_bry(page_caption);
|
||||
else if (String_.Eq(key, "page_body")) mbfr.Add_bry(page_body);
|
||||
else return false;
|
||||
return true;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ public class Pglnk_page_link_temp_tbl implements Rls_able {
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Meta_idx_create(Gfo_usr_dlg_.Instance, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "main", fld_src_id, fld_trg_ns, fld_trg_ttl));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__page_link__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_bgn() {conn.Txn_bgn("page_link__insert_bulk"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(int src_id, int trg_ns, byte[] trg_ttl) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.core.brys.*;
|
||||
class Volume_make_itm implements Bry_bfr_able {
|
||||
public int Uid = 0;
|
||||
public int Prep_id = 0;
|
||||
public int Item_type = 0; // 0=page;1=thm
|
||||
public int Item_id = 0; // either page_id or fsdb_id
|
||||
public String Item_name = ""; // friendly-name
|
||||
public byte[] Item_ttl = Bry_.Empty; // actual name
|
||||
public long Item_size = 0; // size of page / file
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
}
|
||||
}
|
||||
/*
|
||||
1|p|Earth|123|100
|
||||
1|f|Earth.png|124|200
|
||||
1|f|Moon.png|125|300
|
||||
4|p|Sun|123|100
|
||||
*/
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.xowa.parsers.lnkis.*; import gplx.xowa.wikis.nss.*;
|
||||
interface Volume_page_loader {
|
||||
boolean Load(Volume_page_itm rv, byte[] ttl);
|
||||
}
|
||||
class Volume_page_loader__wiki implements Volume_page_loader {
|
||||
private final Xowe_wiki wiki;
|
||||
public Volume_page_loader__wiki(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public boolean Load(Volume_page_itm rv, byte[] ttl) {
|
||||
Xoa_ttl page_ttl = wiki.Ttl_parse(ttl); if (page_ttl == null) return false;
|
||||
Xoa_url page_url = wiki.Utl__url_parser().Parse(ttl);
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(page_url, page_ttl);
|
||||
Load_links(rv, page.Lnki_list());
|
||||
return true;
|
||||
}
|
||||
private void Load_links(Volume_page_itm rv, List_adp list) {
|
||||
int len = list.Len();
|
||||
//gplx.xowa.wikis.data.tbls.Xowd_page_tbl page_tbl; page_tbl.Select_in__ttl
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)list.Get_at(i);
|
||||
int ns_id = lnki.Ns_id();
|
||||
switch (ns_id) {
|
||||
case Xow_ns_.Tid__special:
|
||||
case Xow_ns_.Tid__media:
|
||||
break;
|
||||
case Xow_ns_.Tid__file:
|
||||
break; // file
|
||||
default:
|
||||
Volume_make_itm make_itm = new Volume_make_itm();
|
||||
make_itm.Item_ttl = lnki.Ttl().Page_db();
|
||||
make_itm.Item_size = 1;
|
||||
rv.Link_list().Add(make_itm);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Volume_page_itm {
|
||||
public void Init(Xoa_ttl page_ttl, Xoa_url page_url) {
|
||||
this.page_ttl = page_ttl; this.page_url = page_url;
|
||||
}
|
||||
public Xoa_ttl Page_ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public Xoa_url Page_url() {return page_url;} private Xoa_url page_url;
|
||||
public List_adp Link_list() {return link_list;} private final List_adp link_list = List_adp_.new_();
|
||||
public List_adp File_list() {return file_list;} private final List_adp file_list = List_adp_.new_();
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Volume_prep_cmd extends Xob_cmd__base {
|
||||
private Io_url prep_url, make_url;
|
||||
public Volume_prep_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
Volume_prep_itm[] page_itms = new Volume_prep_rdr().Parse(prep_url);
|
||||
Volume_prep_mgr prep_mgr = new Volume_prep_mgr(new Volume_page_loader__wiki(wiki));
|
||||
Volume_make_itm[] make_itms = prep_mgr.Calc_makes(page_itms);
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
for (Volume_make_itm make_itm : make_itms) {
|
||||
make_itm.To_bfr(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
Io_mgr.Instance.SaveFilBfr(make_url, bfr);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk__prep_url_)) prep_url = m.ReadIoUrl("v");
|
||||
else if (ctx.Match(k, Invk__make_url_)) make_url = m.ReadIoUrl("v");
|
||||
else return super.Invk(ctx, ikey, k, m);
|
||||
return this;
|
||||
}
|
||||
private static final String Invk__prep_url_ = "prep_url_", Invk__make_url_ = "make_url_";
|
||||
|
||||
public static final String BLDR_CMD_KEY = "volume.prep";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
public static final Xob_cmd Prototype = new Volume_prep_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Volume_prep_cmd(bldr, wiki);}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import gplx.core.brys.*;
|
||||
class Volume_prep_itm implements Bry_bfr_able {
|
||||
public int Prep_id = 0;
|
||||
public byte[] Page_ttl = null;
|
||||
public long Max_bytes = 0;
|
||||
public int Max_depth = 2;
|
||||
public int Max_article_count = -1;
|
||||
public int Max_link_count_per_page = -1;
|
||||
public boolean Skip_navbox = false;
|
||||
public int Max_file_count = -1;
|
||||
public long Max_file_size = -1;
|
||||
public boolean Skip_audio = true;
|
||||
public static final Volume_prep_itm[] Ary_empty = new Volume_prep_itm[0];
|
||||
public void To_bfr(Bry_bfr bfr) {
|
||||
bfr.Add(Page_ttl);
|
||||
}
|
||||
}
|
||||
// Earth|2|100|10|100|100MB
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
class Volume_prep_mgr {
|
||||
private final Volume_page_loader loader;
|
||||
private final Volume_page_itm tmp_page = new Volume_page_itm();
|
||||
private final List_adp list = List_adp_.new_();
|
||||
public Volume_prep_mgr(Volume_page_loader loader) {this.loader = loader;}
|
||||
public Volume_make_itm[] Calc_makes(Volume_prep_itm[] ary) {
|
||||
Volume_prep_ctx ctx = new Volume_prep_ctx();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Volume_prep_itm itm = ary[i];
|
||||
ctx.Init(ctx, itm);
|
||||
Calc_make(ctx, itm.Page_ttl);
|
||||
}
|
||||
return (Volume_make_itm[])list.To_ary_and_clear(Volume_make_itm.class);
|
||||
}
|
||||
private void Calc_make(Volume_prep_ctx ctx, byte[] page_ttl) {
|
||||
if (!loader.Load(tmp_page, page_ttl)) return;
|
||||
if (ctx.Bytes_max != -1 && ctx.Bytes_count > ctx.Bytes_max) return;
|
||||
if (ctx.Depth_count > ctx.Depth_max) return;
|
||||
List_adp files_list = tmp_page.File_list();
|
||||
int files_len = files_list.Len();
|
||||
for (int i = 0; i < files_len; ++i) {
|
||||
Volume_make_itm file_itm = (Volume_make_itm)files_list.Get_at(i);
|
||||
list.Add(file_itm);
|
||||
}
|
||||
List_adp links_list = tmp_page.Link_list();
|
||||
int links_len = links_list.Len();
|
||||
for (int i = 0; i < links_len; ++i) {
|
||||
if (ctx.Page_max != -1 && ctx.Page_count++ > ctx.Page_max) return;
|
||||
Volume_make_itm link_itm = (Volume_make_itm)links_list.Get_at(i);
|
||||
list.Add(link_itm);
|
||||
ctx.Depth_count++;
|
||||
Calc_make(ctx, link_itm.Item_ttl);
|
||||
ctx.Depth_count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
class Volume_prep_ctx {
|
||||
public long Bytes_count;
|
||||
public long Bytes_max;
|
||||
public int Page_count;
|
||||
public int Page_max;
|
||||
public int Depth_count;
|
||||
public int Depth_max;
|
||||
public void Init(Volume_prep_ctx prv_ctx, Volume_prep_itm itm) {
|
||||
this.Bytes_count = prv_ctx.Bytes_count;
|
||||
this.Bytes_max = itm.Max_bytes;
|
||||
this.Page_count = 1;
|
||||
this.Page_max = itm.Max_article_count;
|
||||
this.Depth_count = 0;
|
||||
this.Depth_max = itm.Max_depth;
|
||||
}
|
||||
// public int Max_link_count_per_page = -1;
|
||||
// public int Max_file_count = -1;
|
||||
// public long Max_file_size = -1;
|
||||
// public boolean Skip_navbox = false;
|
||||
// public boolean Skip_audio = true;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
class Volume_prep_rdr {
|
||||
public Volume_prep_itm[] Parse(Io_url url) {return Parse(Io_mgr.Instance.LoadFilBryOr(url, null));}
|
||||
public Volume_prep_itm[] Parse(byte[] src) {
|
||||
if (src == null) return Volume_prep_itm.Ary_empty;
|
||||
List_adp rv = List_adp_.new_();
|
||||
byte[][] lines = Bry_split_.Split_lines(src);
|
||||
int lines_len = lines.length;
|
||||
for (int i = 0; i < lines_len; ++i) {
|
||||
Volume_prep_itm itm = Parse_line_or_null(lines[i]);
|
||||
if (itm != null) rv.Add(itm);
|
||||
}
|
||||
return (Volume_prep_itm[])rv.To_ary_and_clear(Volume_prep_itm.class);
|
||||
}
|
||||
private Volume_prep_itm Parse_line_or_null(byte[] line) {
|
||||
byte[][] flds = Bry_split_.Split(line, Byte_ascii.Pipe);
|
||||
int flds_len = flds.length; if (flds_len == 0) return null;
|
||||
Volume_prep_itm rv = new Volume_prep_itm();
|
||||
for (int i = 0; i < flds_len; ++i) {
|
||||
byte[] fld = flds[i];
|
||||
switch (i) {
|
||||
case 0: rv.Page_ttl = fld; break;
|
||||
default: throw Err_.new_unhandled_default(i);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
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.builds.volumes; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.builds.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Volume_prep_rdr_tst {
|
||||
private final Volume_prep_rdr_fxt fxt = new Volume_prep_rdr_fxt();
|
||||
@Test public void Parse() {
|
||||
fxt.Test__parse(String_.Concat_lines_nl_skip_last("A", "", "B")
|
||||
, fxt.Make__itm("A")
|
||||
, fxt.Make__itm("B")
|
||||
);
|
||||
}
|
||||
}
|
||||
class Volume_prep_rdr_fxt {
|
||||
private final Volume_prep_rdr rdr = new Volume_prep_rdr();
|
||||
public Volume_prep_rdr_fxt Test__parse(String raw, Volume_prep_itm... expd) {
|
||||
Gftest.Eq__ary(expd, rdr.Parse(Bry_.new_u8(raw)));
|
||||
return this;
|
||||
}
|
||||
public Volume_prep_itm Make__itm(String page_ttl) {
|
||||
Volume_prep_itm rv = new Volume_prep_itm();
|
||||
rv.Page_ttl = Bry_.new_u8(page_ttl);
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -24,7 +24,6 @@ public class Xoax_updates_files_addon implements Xoax_addon_itm, Xoax_addon_itm_
|
||||
{ Xobldr__deletion_db__make.Prototype
|
||||
, Xobldr__deletion_db__exec.Prototype
|
||||
, Xobldr__deletion_db__small_files.Prototype
|
||||
, Xobldr__deletion_db__temp.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,12 @@ 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
package gplx.xowa.addons.wikis.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.addons.wikis.randoms.dbs.*;
|
||||
public class Rndm_mgr implements Rls_able {
|
||||
private Rndm_core_tbl core_tbl; private final Rndm_core_row core_row = new Rndm_core_row();
|
||||
private Rndm_core_tbl core_tbl; private final Rndm_core_row core_row = new Rndm_core_row();
|
||||
private Rndm_range_tbl rng_tbl;
|
||||
private Xowd_page_tbl page_tbl; private Db_stmt stmt__page__random;
|
||||
public void Init(Db_conn conn, Xowd_page_tbl page_tbl) {
|
||||
@ -77,7 +78,7 @@ public class Rndm_mgr implements Rls_able {
|
||||
public void Rls() {
|
||||
stmt__page__random = Db_stmt_.Rls(stmt__page__random);
|
||||
}
|
||||
private static final Bry_fmt fmt_sql = Bry_fmt.New(String_.Concat_lines_nl_skip_last
|
||||
private static final Bry_fmt fmt_sql = Bry_fmt.New(String_.Concat_lines_nl_skip_last
|
||||
( "SELECT p.~{page_id}"
|
||||
, "FROM ~{page} p"
|
||||
, "WHERE p.~{~page_id} > ~{page_id_bgn}"
|
||||
@ -86,5 +87,5 @@ public class Rndm_mgr implements Rls_able {
|
||||
, "LIMIT 1"
|
||||
, "OFFSET ~{offset};"
|
||||
), "page", "page_id", "where_sql", "page_id_bgn", "offset");
|
||||
private static final Bry_fmt fmt_where = Bry_fmt.New("", "page_namespace", "page_is_redirect");
|
||||
private static final Bry_fmt fmt_where = Bry_fmt.New("", "page_namespace", "page_is_redirect");
|
||||
}
|
@ -15,18 +15,16 @@ 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
package gplx.xowa.addons.wikis.randoms.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.randoms.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xob_rnd_cmd implements Xob_cmd {
|
||||
private final Xowe_wiki wiki;
|
||||
public class Rndm_bldr_cmd extends Xob_cmd__base {
|
||||
private int rndm_uid = 0; private String rndm_where_sql = "AND ~{page_namespace} = 0 AND ~{page_is_redirect} = 0"; private int rndm_interval = 1000;
|
||||
public Xob_rnd_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public String Cmd_key() {return Xob_cmd_keys.Key_util_random;}
|
||||
public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return null;}
|
||||
public void Cmd_run() {
|
||||
wiki.Special_mgr().Page_random().Mgr().Rebuild(rndm_uid, rndm_where_sql, rndm_interval);
|
||||
public Rndm_bldr_cmd(Xob_bldr bldr, Xowe_wiki wiki) {super(bldr, wiki);}
|
||||
@Override public void Cmd_run() {
|
||||
// wiki.Special_mgr().Page_random().Mgr().Rebuild(rndm_uid, rndm_where_sql, rndm_interval);
|
||||
Tfds.Write(rndm_uid, rndm_where_sql, rndm_interval);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_rndm_uid_)) rndm_uid = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_rndm_where_sql_)) rndm_where_sql = m.ReadStr("v");
|
||||
else if (ctx.Match(k, Invk_rndm_interval_)) rndm_interval = m.ReadInt("v");
|
||||
@ -34,8 +32,8 @@ public class Xob_rnd_cmd implements Xob_cmd {
|
||||
return this;
|
||||
} private static final String Invk_rndm_uid_ = "rndm_uid_", Invk_rndm_where_sql_ = "rndm_where_sql_", Invk_rndm_interval_ = "rndm_interval_";
|
||||
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_term() {}
|
||||
public static final String BLDR_CMD_KEY = "wiki.random";
|
||||
@Override public String Cmd_key() {return BLDR_CMD_KEY;}
|
||||
public static final Xob_cmd Prototype = new Rndm_bldr_cmd(null, null);
|
||||
@Override public Xob_cmd Cmd_clone(Xob_bldr bldr, Xowe_wiki wiki) {return new Rndm_bldr_cmd(bldr, wiki);}
|
||||
}
|
@ -15,7 +15,7 @@ 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
package gplx.xowa.addons.wikis.randoms.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.randoms.*;
|
||||
public class Rndm_core_row {
|
||||
public void Load(int uid, String where_sql, int total, int interval) {this.uid = uid; this.where_sql = where_sql; this.total = total; this.interval = interval;}
|
||||
public int uid;
|
@ -15,12 +15,12 @@ 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
package gplx.xowa.addons.wikis.randoms.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.randoms.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Rndm_core_tbl implements Rls_able {
|
||||
private final String tbl_name = "rndm_core"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_uid, fld_where_sql, fld_total, fld_interval;
|
||||
private final Db_conn conn; private Db_stmt stmt_select;
|
||||
private final String tbl_name = "rndm_core"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_uid, fld_where_sql, fld_total, fld_interval;
|
||||
private final Db_conn conn; private Db_stmt stmt_select;
|
||||
public Rndm_core_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_uid = flds.Add_int_pkey("rndm_uid");
|
@ -15,12 +15,12 @@ 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.specials.randoms; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*;
|
||||
package gplx.xowa.addons.wikis.randoms.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.wikis.*; import gplx.xowa.addons.wikis.randoms.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Rndm_range_tbl implements Rls_able {
|
||||
private final String tbl_name = "rng_range"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_rng_uid, fld_rng_idx, fld_rng_page_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
private final String tbl_name = "rndm_range"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_rng_uid, fld_rng_idx, fld_rng_page_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
|
||||
public Rndm_range_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_rng_uid = flds.Add_int("rng_uid");
|
@ -20,6 +20,8 @@ import gplx.xowa.parsers.lnkis.cfgs.*;
|
||||
public class Xowc_parser implements GfoInvkAble {
|
||||
public Xowc_parser(Xowe_wiki wiki) {
|
||||
lnki_cfg = new Xoc_lnki_cfg(wiki);
|
||||
if (wiki.Domain_tid() == gplx.xowa.wikis.domains.Xow_domain_tid_.Int__home)
|
||||
display_title_restrict = false;
|
||||
}
|
||||
public Xoc_lnki_cfg Lnki_cfg() {return lnki_cfg;} private Xoc_lnki_cfg lnki_cfg;
|
||||
public Xowc_xtns Xtns() {return xtns;} private Xowc_xtns xtns = new Xowc_xtns();
|
||||
|
@ -42,7 +42,10 @@ public class Xocfg_bnd_mgr implements GfoInvkAble, Gfo_sort_able {
|
||||
private Xocfg_bnd_itm_srl Init(String key) {return new Xocfg_bnd_itm_srl(app, key);}
|
||||
public Xocfg_bnd_itm Get_at(int i) {return (Xocfg_bnd_itm)regy.Get_at(i);}
|
||||
public int Len() {return regy.Count();}
|
||||
public void Sort(gplx.core.lists.ComparerAble comparer) {regy.Sort_by(comparer);}
|
||||
public void Sort(gplx.core.lists.ComparerAble comparer) {
|
||||
if (regy == null) Init(); // NOTE: null when called during html.dump_to_file for home/wiki/Options/Shortcuts; DATE:2016-04-12
|
||||
regy.Sort_by(comparer);
|
||||
}
|
||||
private void Set_bulk(byte[] src) {
|
||||
try {
|
||||
bnd_mgr_srl.Load_by_bry(src);
|
||||
|
@ -35,7 +35,7 @@ class Xoa_site_cfg_loader__db implements Xoa_site_cfg_loader {
|
||||
public void Save_bry(int loader_tid, String db_key, byte[] val) {
|
||||
byte[] meta = Bry_.new_a7(Bld_meta(loader_tid));
|
||||
byte[] data = Bry_.Len_eq_0(val) ? meta : Bry_.Add(meta, Byte_ascii.Nl_bry, val);
|
||||
cfg_tbl.Assert_bry(Grp__xowa_wm_api, db_key, data);
|
||||
cfg_tbl.Upsert_bry(Grp__xowa_wm_api, db_key, data);
|
||||
}
|
||||
public static String Bld_meta(int loader_tid) {
|
||||
return String_.Format("//#xowa|{0}|{1}|{2}", Xoa_app_.Version, Xoa_site_cfg_loader_.Get_key(loader_tid), DateAdp_.Now().XtoUtc().XtoStr_fmt_yyyyMMdd_HHmmss());
|
||||
|
@ -20,7 +20,7 @@ import gplx.core.net.*; import gplx.xowa.bldrs.wms.*;
|
||||
import gplx.langs.jsons.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xoa_site_cfg_loader__inet implements Xoa_site_cfg_loader {
|
||||
private final Gfo_inet_conn inet_conn; private final Json_parser json_parser;
|
||||
private final Gfo_inet_conn inet_conn; private final Json_parser json_parser;
|
||||
private String api_url; private boolean call_api = true; private Json_doc jdoc;
|
||||
public Xoa_site_cfg_loader__inet(Gfo_inet_conn inet_conn, Json_parser json_parser) {this.inet_conn = inet_conn; this.json_parser = json_parser;}
|
||||
public int Tid() {return Xoa_site_cfg_loader_.Tid__inet;}
|
||||
@ -47,17 +47,16 @@ public class Xoa_site_cfg_loader__inet implements Xoa_site_cfg_loader {
|
||||
int len = itm_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_site_cfg_itm__base itm = itm_ary[i];
|
||||
byte[] itm_key = itm.Key_bry();
|
||||
if (db_hash.Has(itm_key)) continue;
|
||||
// if (db_hash.Has(itm_key)) continue; // TOMBSTONE: always add itm to url, even if in db; note that fallback gets saved to db; DATE:2016-04-13
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
bfr.Add_byte_pipe();
|
||||
bfr.Add(itm.Key_bry());
|
||||
}
|
||||
return Xowm_api_mgr.Bld_api_url(domain_str, Qarg__bgn + bfr.To_str_and_rls());
|
||||
}
|
||||
return first ? null : Xowm_api_mgr.Bld_api_url(domain_str, Qarg__bgn + bfr.To_str_and_rls());
|
||||
}
|
||||
private static final byte[] Bry__query = Bry_.new_a7("query");
|
||||
private static final byte[] Bry__query = Bry_.new_a7("query");
|
||||
public static final String
|
||||
Qarg__all = "action=query&format=json&rawcontinue=&meta=siteinfo&siprop=general|namespaces|statistics|interwikimap|namespacealiases|specialpagealiases|libraries|extensions|skins|magicwords|functionhooks|showhooks|extensiontags|protocols|defaultoptions|languages"
|
||||
, Qarg__bgn = "action=query&format=json&rawcontinue=&meta=siteinfo&siprop="
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.apps.site_cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
|
||||
import gplx.xowa.bldrs.wms.sites.*;
|
||||
public class Xoa_site_cfg_mgr {
|
||||
private final Xoa_site_cfg_loader__db loader__db = new Xoa_site_cfg_loader__db();
|
||||
private final Xoa_site_cfg_loader__db loader__db = new Xoa_site_cfg_loader__db();
|
||||
public Xoa_site_cfg_mgr(Xoa_app app) {
|
||||
this.itm_ary = new Xoa_site_cfg_itm__base[]
|
||||
{ new Xoa_site_cfg_itm__extensiontags()
|
||||
@ -31,9 +31,9 @@ public class Xoa_site_cfg_mgr {
|
||||
, new Xoa_site_cfg_loader__fallback()
|
||||
};
|
||||
}
|
||||
public Xoa_site_cfg_loader[] Loader_ary() {return loader_ary;} private final Xoa_site_cfg_loader[] loader_ary;
|
||||
public Xoa_site_cfg_itm__base[] Itm_ary() {return itm_ary;} private final Xoa_site_cfg_itm__base[] itm_ary;
|
||||
public Hash_adp_bry Data_hash() {return data_hash;} private final Hash_adp_bry data_hash = Hash_adp_bry.cs();
|
||||
public Xoa_site_cfg_loader[] Loader_ary() {return loader_ary;} private final Xoa_site_cfg_loader[] loader_ary;
|
||||
public Xoa_site_cfg_itm__base[] Itm_ary() {return itm_ary;} private final Xoa_site_cfg_itm__base[] itm_ary;
|
||||
public Hash_adp_bry Data_hash() {return data_hash;} private final Hash_adp_bry data_hash = Hash_adp_bry.cs();
|
||||
public void Init_loader_bgn(Xow_wiki wiki) {
|
||||
data_hash.Clear();
|
||||
int loader_len = loader_ary.length;
|
||||
|
@ -22,7 +22,7 @@ import gplx.dbs.cfgs.*;
|
||||
import gplx.langs.jsons.*; import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.bldrs.wms.*;
|
||||
public class Xoa_site_cfg_mgr_tst {
|
||||
private final Xoa_site_cfg_mgr_fxt fxt = new Xoa_site_cfg_mgr_fxt();
|
||||
private final Xoa_site_cfg_mgr_fxt fxt = new Xoa_site_cfg_mgr_fxt();
|
||||
@Before public void init() {fxt.Init();}
|
||||
@After public void term() {fxt.Term();}
|
||||
@Test public void Extensiontags__cfg() {
|
||||
@ -56,21 +56,16 @@ public class Xoa_site_cfg_mgr_tst {
|
||||
fxt.Exec_load();
|
||||
fxt.Test_db(Xoa_site_cfg_loader__inet.Qarg__interwikimap, fxt.Make_data(Xoa_site_cfg_loader_.Tid__inet, 2, "w", "https://en.wikipedia.org", "c", "https://commons.wikimedia.org"));
|
||||
}
|
||||
@Test public void Inet__once() {
|
||||
fxt.Init_db(Xoa_site_cfg_loader__inet.Qarg__extensiontags, fxt.Make_data(Xoa_site_cfg_loader_.Tid__inet, 1, "math", "source"));
|
||||
fxt.Exec_load();
|
||||
fxt.Test_inet_qarg("interwikimap"); // should not have extensiontags
|
||||
}
|
||||
// @Test public void Print() {
|
||||
// String s = fxt.Make_api(fxt.Make_api_interwikimap("k1", "v1", "k2", "v2"), fxt.Make_api_extensiontags2("k3", "v3", "k4", "v4"));
|
||||
// Tfds.Dbg(s);
|
||||
// }
|
||||
}
|
||||
class Xoa_site_cfg_mgr_fxt {
|
||||
private final Xoae_app app; private final Xowe_wiki wiki;
|
||||
private final Xoa_site_cfg_mgr site_cfg_mgr;
|
||||
private final Db_cfg_tbl cfg_tbl;
|
||||
private final Json_printer printer = new Json_printer();
|
||||
private final Xoae_app app; private final Xowe_wiki wiki;
|
||||
private final Xoa_site_cfg_mgr site_cfg_mgr;
|
||||
private final Db_cfg_tbl cfg_tbl;
|
||||
private final Json_printer printer = new Json_printer();
|
||||
public Xoa_site_cfg_mgr_fxt() {
|
||||
// Xoa_app_.Usr_dlg_(Xoa_app_.usr_dlg_console_());
|
||||
Xoa_test_.Inet__init();
|
||||
|
@ -68,12 +68,12 @@ public class Xob_base_fxt {
|
||||
cmd.Cmd_end();
|
||||
}
|
||||
public static void Run_wkr(Xob_bldr bldr, Xob_page_wkr wkr, Xowd_page_itm[] page_ary) {
|
||||
wkr.Wkr_bgn(bldr);
|
||||
wkr.Page_wkr__bgn();
|
||||
int page_ary_len = page_ary.length;
|
||||
for (int i = 0; i < page_ary_len; i++) {
|
||||
Xowd_page_itm page = page_ary[i];
|
||||
wkr.Wkr_run(page);
|
||||
wkr.Page_wkr__run(page);
|
||||
}
|
||||
wkr.Wkr_end();
|
||||
wkr.Page_wkr__end();
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class Xob_fxt {
|
||||
return rv;
|
||||
}
|
||||
public Xob_fxt Run_ctg() {
|
||||
Xobd_parser parser = new Xobd_parser();
|
||||
Xobd_parser parser = new Xobd_parser(bldr);
|
||||
gplx.xowa.bldrs.cmds.ctgs.Xob_ctg_v1_base ctg_wkr = new gplx.xowa.bldrs.cmds.ctgs.Xob_ctg_v1_txt().Ctor(bldr, wiki);
|
||||
byte[] bry = Bry_.new_a7("[[Category:");
|
||||
ctg_wkr.Wkr_hooks().Add(bry, bry);
|
||||
@ -75,12 +75,12 @@ public class Xob_fxt {
|
||||
return this;
|
||||
}
|
||||
private void Run_wkr(Xob_page_wkr wkr) {
|
||||
wkr.Wkr_bgn(bldr);
|
||||
wkr.Page_wkr__bgn();
|
||||
for (int i = 0; i < doc_ary.length; i++) {
|
||||
Xowd_page_itm page = doc_ary[i];
|
||||
wkr.Wkr_run(page);
|
||||
wkr.Page_wkr__run(page);
|
||||
}
|
||||
wkr.Wkr_end();
|
||||
wkr.Page_wkr__end();
|
||||
}
|
||||
private void tst_fils(Io_url[] ary) {
|
||||
Io_fil[] actls = Get_actl(ary);
|
||||
@ -105,7 +105,7 @@ public class Xob_fxt {
|
||||
}
|
||||
public Xob_fxt Run_page_title() {return Run(new gplx.xowa.bldrs.cmds.texts.tdbs.Xob_page_txt(bldr, wiki));}
|
||||
public Xob_fxt Run(Xobd_parser_wkr... wkrs) {
|
||||
Xobd_parser parser_wkr = new Xobd_parser();
|
||||
Xobd_parser parser_wkr = new Xobd_parser(bldr);
|
||||
int len = wkrs.length;
|
||||
for (int i = 0; i < len; i++)
|
||||
parser_wkr.Wkr_add(wkrs[i]);
|
||||
@ -116,12 +116,12 @@ public class Xob_fxt {
|
||||
int doc_ary_len = doc_ary.length;
|
||||
for (int j = 0; j < wkrs.length; j++) {
|
||||
Xob_page_wkr wkr = wkrs[j];
|
||||
wkr.Wkr_bgn(bldr);
|
||||
wkr.Page_wkr__bgn();
|
||||
for (int i = 0; i < doc_ary_len; i++) {
|
||||
Xowd_page_itm page = doc_ary[i];
|
||||
wkr.Wkr_run(page);
|
||||
wkr.Page_wkr__run(page);
|
||||
}
|
||||
wkr.Wkr_end();
|
||||
wkr.Page_wkr__end();
|
||||
}
|
||||
Test_expd_files();
|
||||
return this;
|
||||
|
@ -27,7 +27,7 @@ public class Xob_page_wkr_cmd implements Xob_cmd {
|
||||
public void Cmd_run() {
|
||||
Xob_page_wkr[] wkr_ary = (Xob_page_wkr[])wkrs.To_ary(Xob_page_wkr.class); int wkr_ary_len = wkr_ary.length;
|
||||
for (int i = 0; i < wkr_ary_len; i++)
|
||||
wkr_ary[i].Wkr_bgn(bldr);
|
||||
wkr_ary[i].Page_wkr__bgn();
|
||||
Io_buffer_rdr fil = Io_buffer_rdr.Null; Xowd_page_itm page = new Xowd_page_itm(); Xow_ns_mgr ns_mgr = wiki.Ns_mgr();
|
||||
Xob_xml_parser parser = bldr.Dump_parser().Data_bfr_len_(Io_mgr.Len_mb);
|
||||
long fil_len = 0;
|
||||
@ -46,7 +46,7 @@ public class Xob_page_wkr_cmd implements Xob_cmd {
|
||||
prv_pos = cur_pos;
|
||||
try {
|
||||
for (int i = 0; i < wkr_ary_len; i++)
|
||||
wkr_ary[i].Wkr_run(page);
|
||||
wkr_ary[i].Page_wkr__run(page);
|
||||
}
|
||||
catch (Exception e) {
|
||||
Err_.Noop(e);
|
||||
@ -57,6 +57,8 @@ public class Xob_page_wkr_cmd implements Xob_cmd {
|
||||
Console_adp__sys.Instance.Write_str_w_nl(msg);
|
||||
}
|
||||
}
|
||||
for (int i = wkr_ary_len - 1; i > -1; --i) // NOTE: release in reverse order; needed to make sure txns are released correctly
|
||||
wkr_ary[i].Page_wkr__run_cleanup();
|
||||
}
|
||||
catch (Exception e) {
|
||||
String msg = Err_.Message_lang(e);
|
||||
@ -67,17 +69,17 @@ public class Xob_page_wkr_cmd implements Xob_cmd {
|
||||
finally {fil.Rls();}
|
||||
bldr.Usr_dlg().Prog_none("", "", "reading completed: performing post-processing clean-up");
|
||||
for (int i = wkr_ary_len - 1; i > -1; --i) // NOTE: release in reverse order; needed to make sure txns are released correctly
|
||||
wkr_ary[i].Wkr_end();
|
||||
wkr_ary[i].Page_wkr__end();
|
||||
}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_term() {}
|
||||
public void Wkr_add(Xob_page_wkr wkr) {wkrs.Add(wkr.Wkr_key(), wkr);} private Ordered_hash wkrs = Ordered_hash_.New();
|
||||
public void Wkr_add(Xob_page_wkr wkr) {wkrs.Add(wkr.Page_wkr__key(), wkr);} private Ordered_hash wkrs = Ordered_hash_.New();
|
||||
public Xob_page_wkr Wkr_get(String key) {return (Xob_page_wkr)wkrs.Get_by(key);}
|
||||
public Xobd_parser Page_parser_assert() {
|
||||
if (page_parser == null) {
|
||||
page_parser = new Xobd_parser();
|
||||
page_parser = new Xobd_parser(bldr);
|
||||
this.Wkr_add(page_parser);
|
||||
}
|
||||
return page_parser;
|
||||
|
@ -16,18 +16,20 @@ 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.bldrs; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.core.btries.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xobd_parser implements Xob_page_wkr {
|
||||
private Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en; ctg.v1 assumes [[Category:
|
||||
private List_adp wkr_list = List_adp_.new_();
|
||||
public String Wkr_key() {return KEY;} static final String KEY = "page_parser";
|
||||
private final Xob_bldr bldr;
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.ci_a7(); // NOTE:ci.ascii:MW_const.en; ctg.v1 assumes [[Category:
|
||||
private final List_adp wkr_list = List_adp_.new_();
|
||||
public String Page_wkr__key() {return KEY;} static final String KEY = "page_parser";
|
||||
public Xobd_parser(Xob_bldr bldr) {this.bldr = bldr;}
|
||||
public void Wkr_add(Xobd_parser_wkr wkr) {wkr_list.Add(wkr);}
|
||||
public void Wkr_bgn(Xob_bldr app) {
|
||||
public void Page_wkr__bgn() {
|
||||
int wkr_list_len = wkr_list.Count();
|
||||
for (int i = 0; i < wkr_list_len; i++) {
|
||||
Xobd_parser_wkr wkr = (Xobd_parser_wkr)wkr_list.Get_at(i);
|
||||
wkr.Wkr_bgn(app);
|
||||
wkr.Wkr_bgn(bldr);
|
||||
int hooks_len = wkr.Wkr_hooks().Count();
|
||||
for (int j = 0; j < hooks_len; j++) {
|
||||
byte[] bry = (byte[])wkr.Wkr_hooks().Get_at(j);
|
||||
@ -35,7 +37,7 @@ public class Xobd_parser implements Xob_page_wkr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
byte[] src = page.Text(); int src_len = src.length;
|
||||
int pos = 0;
|
||||
while (true) {
|
||||
@ -49,7 +51,8 @@ public class Xobd_parser implements Xob_page_wkr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Page_wkr__end() {
|
||||
int wkr_list_len = wkr_list.Count();
|
||||
for (int i = 0; i < wkr_list_len; i++) {
|
||||
Xobd_parser_wkr wkr = (Xobd_parser_wkr)wkr_list.Get_at(i);
|
||||
|
@ -32,17 +32,17 @@ class Xowd_page_wkr_ctg_fxt {
|
||||
byte[] src;
|
||||
public Xowd_page_wkr_ctg_fxt ini_(String s) {src = Bry_.new_u8(s); return this;}
|
||||
public Xowd_page_wkr_ctg_fxt tst_(String... expd) {
|
||||
Xobd_parser mgr = new Xobd_parser();
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Xob_bldr bldr = Xoa_app_fxt.bldr_(app);
|
||||
Xobd_parser mgr = new Xobd_parser(bldr);
|
||||
Xobd_parser_wkr_ctg_tstr wkr = (Xobd_parser_wkr_ctg_tstr)new Xobd_parser_wkr_ctg_tstr().Ctor(bldr, wiki);
|
||||
byte[] bry = Bry_.new_a7("[[Category:");
|
||||
wkr.Wkr_hooks().Add(bry, bry);
|
||||
mgr.Wkr_add(wkr);
|
||||
Xowd_page_itm page = new Xowd_page_itm().Text_(src);//.Ttl_(Bry_.new_a7("Test"), new Xow_ns_mgr());
|
||||
mgr.Wkr_bgn(bldr);
|
||||
mgr.Wkr_run(page);
|
||||
mgr.Page_wkr__bgn();
|
||||
mgr.Page_wkr__run(page);
|
||||
byte[][] ttl = (byte[][])wkr.Found().To_ary(byte[].class);
|
||||
String[] actl = new String[ttl.length];
|
||||
for (int i = 0; i < actl.length; i++) {
|
||||
|
@ -28,8 +28,8 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xob_page_wkr, Gf
|
||||
private DateAdp modified_latest = DateAdp_.MinValue; private int page_count_all, page_count_main = 0; private int commit_interval = 100000; // 100 k
|
||||
private Dg_match_mgr dg_match_mgr; private Xob_ns_to_db_mgr ns_to_db_mgr;
|
||||
public Xob_page_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Wkr_key() {return Xob_cmd_keys.Key_text_page;}
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
public String Page_wkr__key() {return Xob_cmd_keys.Key_text_page;}
|
||||
public void Page_wkr__bgn() {
|
||||
Xoae_app app = wiki.Appe();
|
||||
Xoapi_import import_cfg = app.Api_root().Bldr().Wiki().Import();
|
||||
this.redirect_mgr = wiki.Redirect_mgr();
|
||||
@ -50,7 +50,7 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xob_page_wkr, Gf
|
||||
page_core_tbl.Insert_bgn();
|
||||
usr_dlg.Prog_many("", "", "import.page.bgn");
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
int id = page.Id();
|
||||
DateAdp modified = page.Modified_on(); if (modified.compareTo(modified_latest) == CompareAble_.More) modified_latest = modified;
|
||||
byte[] text_raw = page.Text(); int text_raw_len = page.Text_len();
|
||||
@ -77,9 +77,12 @@ public class Xob_page_cmd extends Xob_itm_basic_base implements Xob_page_wkr, Gf
|
||||
if (dg_match_mgr != null) dg_match_mgr.Commit();
|
||||
}
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__run_cleanup() {
|
||||
usr_dlg.Log_many("", "", "import.page: insert done; committing pages; pages=~{0}", page_count_all);
|
||||
page_core_tbl.Insert_end(); ns_to_db_mgr.Rls_all();
|
||||
ns_to_db_mgr.Rls_all();
|
||||
page_core_tbl.Insert_end();
|
||||
}
|
||||
public void Page_wkr__end() {
|
||||
if (dg_match_mgr != null) dg_match_mgr.Rls();
|
||||
usr_dlg.Log_many("", "", "import.page: updating core stats");
|
||||
Xow_ns_mgr ns_mgr = wiki.Ns_mgr();
|
||||
|
@ -20,17 +20,17 @@ import gplx.core.primitives.*; import gplx.core.ios.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.bldrs.wtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public abstract class Srch_bldr_wkr_base extends Xob_itm_dump_base implements Xob_page_wkr {
|
||||
private final Ordered_hash list = Ordered_hash_.New(); private Xol_lang_itm lang;
|
||||
public abstract String Wkr_key();
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
private final Ordered_hash list = Ordered_hash_.New(); private Xol_lang_itm lang;
|
||||
public abstract String Page_wkr__key();
|
||||
public void Page_wkr__bgn() {
|
||||
make_dir = wiki.Tdb_fsys_mgr().Ns_dir();
|
||||
this.Init_dump(this.Wkr_key(), make_dir);
|
||||
this.Init_dump(this.Page_wkr__key(), make_dir);
|
||||
lang = wiki.Lang(); // wiki.Appe().Lang_mgr().Lang_en(); // NOTE: was .Lang_en which is wrong (should match lang of wiki); DATE:2013-05-11
|
||||
tmp_wtr_mgr = new Xob_tmp_wtr_mgr(new Xob_tmp_wtr_wkr__ttl(temp_dir, dump_fil_len));
|
||||
if (wiki.Db_mgr().Tid() == Xodb_mgr_sql.Tid_sql) // if sqlite, hard-code to ns_main; aggregates all ns into one
|
||||
ns_main = wiki.Ns_mgr().Ns_main();
|
||||
} private Xob_tmp_wtr_mgr tmp_wtr_mgr; private Xow_ns ns_main;
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
// if (page.Ns_id() != Xow_ns_.Tid__main) return; // limit to main ns for now
|
||||
try {
|
||||
byte[] ttl = page.Ttl_page_db();
|
||||
@ -51,7 +51,8 @@ public abstract class Srch_bldr_wkr_base extends Xob_itm_dump_base implements Xo
|
||||
}
|
||||
} catch (Exception e) {bldr.Usr_dlg().Warn_many("", "", "search_index:fatal error: err=~{0}", Err_.Message_gplx_full(e));} // never let single page crash entire import
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Page_wkr__end() {
|
||||
tmp_wtr_mgr.Flush_all(bldr.Usr_dlg());
|
||||
dump_bfr.ClearAndReset();
|
||||
Xobdc_merger.Ns(bldr.Usr_dlg(), tmp_wtr_mgr.Regy(), Xotdb_dir_info_.Name_search_ttl, temp_dir, make_dir, sort_mem_len, Io_line_rdr_key_gen_.first_pipe, this.Make_cmd_site());
|
||||
|
@ -20,16 +20,17 @@ import gplx.core.ios.*; import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.da
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xob_make_id_wkr extends Xob_itm_dump_base implements Xob_page_wkr, GfoInvkAble {
|
||||
public Xob_make_id_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Wkr_key() {return KEY;} public static final String KEY = "core.make_id";
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
public String Page_wkr__key() {return KEY;} public static final String KEY = "core.make_id";
|
||||
public void Page_wkr__bgn() {
|
||||
this.Init_dump(KEY, wiki.Tdb_fsys_mgr().Site_dir().GenSubDir(Xotdb_dir_info_.Name_id));
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
byte[] ttl = page.Ttl_page_db();
|
||||
if (dump_bfr.Len() + row_fixed_len + ttl.length > dump_fil_len) Io_mgr.Instance.AppendFilBfr(dump_url_gen.Nxt_url(), dump_bfr);
|
||||
Xotdb_page_itm_.Txt_id_save(dump_bfr, page);
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Page_wkr__end() {
|
||||
this.Term_dump(new Xob_make_cmd_site(bldr.Usr_dlg(), make_dir, make_fil_len));
|
||||
if (delete_temp) Io_mgr.Instance.DeleteDirDeep(temp_dir);
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ import gplx.xowa.parsers.utils.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.xdats.*; import gplx.xowa.wikis.tdbs.stats.*;
|
||||
public class Xob_page_txt extends Xob_itm_dump_base implements Xob_page_wkr, GfoInvkAble {
|
||||
public Xob_page_txt(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Wkr_key() {return Xob_cmd_keys.Key_tdb_make_page;}
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
public String Page_wkr__key() {return Xob_cmd_keys.Key_tdb_make_page;}
|
||||
public void Page_wkr__bgn() {
|
||||
redirect_mgr = wiki.Redirect_mgr(); page_storage_type = wiki.Appe().Setup_mgr().Dump_mgr().Data_storage_format();
|
||||
fsys_mgr = wiki.Tdb_fsys_mgr();
|
||||
make_dir = fsys_mgr.Ns_dir();
|
||||
@ -36,7 +36,7 @@ public class Xob_page_txt extends Xob_itm_dump_base implements Xob_page_wkr, Gfo
|
||||
int page_file_len = 512 * Io_mgr.Len_kb, title_file_len = 64 * Io_mgr.Len_kb; Xob_tmp_wtr_mgr ttl_wtr_mgr;
|
||||
Xob_xdat_file_wtr[] page_wtr_regy = new Xob_xdat_file_wtr[Ns_ordinal_max]; static final int Ns_ordinal_max = Xow_ns_mgr_.Ordinal_max; // ASSUME: no more than 128 ns in a wiki
|
||||
Xob_stat_type data_rpt_typ; Xob_stat_mgr stat_mgr = new Xob_stat_mgr(); byte page_storage_type;
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
int id = page.Id(); byte[] ttl_wo_ns = page.Ttl_page_db(), text = page.Text(); int ttl_len = ttl_wo_ns.length, text_len = text.length; Xow_ns ns = page.Ns();
|
||||
boolean redirect = redirect_mgr.Is_redirect(text, text_len);
|
||||
page.Redirected_(redirect);
|
||||
@ -54,7 +54,8 @@ public class Xob_page_txt extends Xob_itm_dump_base implements Xob_page_wkr, Gfo
|
||||
if (ttl_wtr.FlushNeeded(Xotdb_page_itm_.Txt_ttl_len__fixed + ttl_len)) ttl_wtr.Flush(bldr.Usr_dlg());
|
||||
Xotdb_page_itm_.Txt_ttl_save(ttl_wtr.Bfr(), id, file_idx, row_idx, redirect, text_len, ttl_wo_ns);
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Page_wkr__end() {
|
||||
Flush_page(page_wtr_regy);
|
||||
ttl_wtr_mgr.Flush_all(bldr.Usr_dlg());
|
||||
Xobdc_merger.Ns(bldr.Usr_dlg(), ttl_wtr_mgr.Regy(), Xotdb_dir_info_.Name_title, temp_dir, make_dir, sort_mem_len, Io_line_rdr_key_gen_.last_pipe, new Io_sort_cmd_ns(bldr.Usr_dlg()));
|
||||
|
@ -20,16 +20,17 @@ import gplx.core.ios.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wik
|
||||
import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xob_parse_dump_templates_cmd extends Xob_itm_dump_base implements Xob_page_wkr, GfoInvkAble {
|
||||
public Xob_parse_dump_templates_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Wkr_key() {return KEY;} public static final String KEY = "parse.dump_templates";
|
||||
public String Page_wkr__key() {return KEY;} public static final String KEY = "parse.dump_templates";
|
||||
public static final int FixedLen_page = 1 + 5 + 1 + 5 + 1 + 1 + 1; // \tid|date|title|text\n
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
public void Page_wkr__bgn() {
|
||||
Init_dump(KEY);
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
if (page.Ns_id() != Xow_ns_.Tid__template) return;
|
||||
int id = page.Id(); byte[] title = page.Ttl_page_db(), text = page.Text(); int title_len = title.length, text_len = text.length;
|
||||
if (FixedLen_page + title_len + text_len + dump_bfr.Len() > dump_fil_len) super.Flush_dump();
|
||||
Xotdb_page_itm_.Txt_page_save(dump_bfr, id, page.Modified_on(), title, text, true);
|
||||
}
|
||||
public void Wkr_end() {super.Flush_dump();}
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Page_wkr__end() {super.Flush_dump();}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.bldrs.cmds.texts.tdbs; import gplx.*; import gplx.xowa.*; impo
|
||||
import gplx.xowa.addons.apps.searchs.bldrs.*;
|
||||
public class Xob_search_tdb extends Srch_bldr_wkr_base {
|
||||
public Xob_search_tdb(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
@Override public String Wkr_key() {return Xob_cmd_keys.Key_tdb_make_search_title;}
|
||||
@Override public String Page_wkr__key() {return Xob_cmd_keys.Key_tdb_make_search_title;}
|
||||
@Override public gplx.core.ios.Io_make_cmd Make_cmd_site() {
|
||||
return new Xob_make_cmd_site(bldr.Usr_dlg(), this.make_dir, this.make_fil_len);
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ 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.bldrs; import gplx.*; import gplx.xowa.*;
|
||||
package gplx.xowa.bldrs.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
public interface Xob_page_wkr extends GfoInvkAble {
|
||||
String Wkr_key();
|
||||
void Wkr_bgn(Xob_bldr bldr);
|
||||
void Wkr_run(gplx.xowa.wikis.data.tbls.Xowd_page_itm page);
|
||||
void Wkr_end();
|
||||
String Page_wkr__key();
|
||||
void Page_wkr__bgn();
|
||||
void Page_wkr__run(gplx.xowa.wikis.data.tbls.Xowd_page_itm page);
|
||||
void Page_wkr__run_cleanup(); // close txns opened during Page_wkr__run
|
||||
void Page_wkr__end();
|
||||
}
|
@ -19,7 +19,7 @@ package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xoh_page_wtr_mgr implements GfoInvkAble {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
|
||||
private Xoh_page_wtr_wkr edit_wtr, html_wtr, read_wtr;
|
||||
public Xoh_page_wtr_mgr(boolean html_capable) {
|
||||
this.html_capable = html_capable;
|
||||
@ -79,9 +79,9 @@ public class Xoh_page_wtr_mgr implements GfoInvkAble {
|
||||
, " </a>"
|
||||
), "src_full_db");
|
||||
public static final String Invk_page_read_ = "page_read_", Invk_page_edit_ = "page_edit_", Invk_page_html_ = "page_html_", Invk_xowa_div_edit_rename_ = "xowa_div_edit_rename_";
|
||||
private static final String[] Fmtr_keys = new String[]
|
||||
private static final String[] Fmtr_keys = new String[]
|
||||
{ "app_root_dir", "app_version", "app_build_date", "xowa_mode_is_server"
|
||||
, "page_id", "page_name", "page_title", "page_modified_on_msg", "page_heading"
|
||||
, "page_id", "page_name", "page_heading", "page_modified_on_msg"
|
||||
, "html_css_common_path", "html_css_wiki_path", "xowa_head"
|
||||
, "page_lang_ltr", "page_indicators", "page_content_sub", "page_jumpto", "page_pgbnr", "page_body_cls", "html_content_editable"
|
||||
, "page_data", "page_langs"
|
||||
|
@ -87,14 +87,14 @@ public class Xoh_page_wtr_wkr {
|
||||
page_ttl = Xoa_ttl.parse(wiki, page_ttl.Ns().Id(), converted_title);
|
||||
}
|
||||
byte[] page_name = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, null); // NOTE: page_name does not show display_title (<i>). always pass in null
|
||||
byte[] page_display = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl());
|
||||
byte[] page_display_title = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl());
|
||||
page.Html_data().Custom_tab_name_(page_name); // set tab_name to page_name; note that if null, gui code will ignore and use Ttl.Page_txt; PAGE: zh.w:釣魚臺列嶼主權問題 DATE:2015-10-05
|
||||
Xow_portal_mgr portal_mgr = wiki.Html_mgr().Portal_mgr().Init_assert();
|
||||
fmtr.Bld_bfr_many(bfr
|
||||
, root_dir_bry, Xoa_app_.Version, Xoa_app_.Build_date, app.Tcp_server().Running_str()
|
||||
, page.Revision_data().Id()
|
||||
, page_name, page_display
|
||||
, modified_on_msg, page.Html_data().Page_heading().Init(page)
|
||||
, page_name, page.Html_data().Page_heading().Init(page.Html_data(), page_display_title)
|
||||
, modified_on_msg
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Head_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(ctx, page, hctx, page_data), page_body_class, html_content_editable
|
||||
, page_data, wdata_lang_wtr
|
||||
@ -102,8 +102,8 @@ public class Xoh_page_wtr_wkr {
|
||||
, portal_mgr.Div_logo_bry(), portal_mgr.Div_home_bry(), new Xopg_xtn_skin_fmtr_arg(page, Xopg_xtn_skin_itm_tid.Tid_sidebar), portal_mgr.Div_wikis_bry(app.Utl__bfr_mkr()), portal_mgr.Sidebar_mgr().Html_bry()
|
||||
, mgr.Edit_rename_div_bry(page_ttl), page.Html_data().Edit_preview_w_dbg(), js_edit_toolbar_bry
|
||||
);
|
||||
Xoh_page_wtr_wkr_.Bld_head_end(bfr, page); // add after </head>
|
||||
Xoh_page_wtr_wkr_.Bld_html_end(bfr, page); // add after </html>
|
||||
Xoh_page_wtr_wkr_.Bld_head_end(bfr, tmp_bfr, page); // add after </head>
|
||||
Xoh_page_wtr_wkr_.Bld_html_end(bfr, tmp_bfr, page); // add after </html>
|
||||
}
|
||||
public void Write_body(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xoae_page page) {
|
||||
synchronized (thread_lock_2) {
|
||||
|
@ -35,9 +35,9 @@ public class Xoh_page_wtr_wkr_ {
|
||||
else
|
||||
return ttl.Full_txt_w_ttl_case(); // NOTE: include ns with ttl as per defect d88a87b3
|
||||
}
|
||||
public static void Bld_head_end(Bry_bfr html_bfr, Xoae_page page) {
|
||||
byte[] head_end = page.Html_data().Custom_head_end();
|
||||
if (head_end == null) return;
|
||||
public static void Bld_head_end(Bry_bfr html_bfr, Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
byte[] head_end = page.Html_data().Custom_head_tags().To_html(tmp_bfr);
|
||||
if (Bry_.Len_eq_0(head_end)) return;
|
||||
int insert_pos = Bry_find_.Find_fwd(html_bfr.Bfr(), Gfh_tag_.Head_rhs);
|
||||
if (insert_pos == Bry_find_.Not_found) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "could not find </head>");
|
||||
@ -45,8 +45,8 @@ public class Xoh_page_wtr_wkr_ {
|
||||
}
|
||||
html_bfr.Insert_at(insert_pos, head_end);
|
||||
}
|
||||
public static void Bld_html_end(Bry_bfr html_bfr, Xoae_page page) {
|
||||
byte[] html_end = page.Html_data().Custom_html_end();
|
||||
public static void Bld_html_end(Bry_bfr html_bfr, Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
byte[] html_end = page.Html_data().Custom_tail_tags().To_html(tmp_bfr);
|
||||
if (html_end == null) return;
|
||||
int insert_pos = Bry_find_.Find_bwd(html_bfr.Bfr(), Gfh_tag_.Html_rhs, html_bfr.Len());
|
||||
if (insert_pos == Bry_find_.Not_found) {
|
||||
|
@ -38,7 +38,7 @@ public class Xoh_html_wtr {
|
||||
public Xow_html_mgr Html_mgr() {return html_mgr;} private Xow_html_mgr html_mgr;
|
||||
public Xoh_html_wtr_cfg Cfg() {return cfg;} private Xoh_html_wtr_cfg cfg = new Xoh_html_wtr_cfg();
|
||||
public Xoh_lnke_html Wkr__lnke() {return wkr__lnke;} private Xoh_lnke_html wkr__lnke = new Xoh_lnke_html();
|
||||
public Xoh_hdr_html Wkr__hdr() {return wkr__hdr;} private final Xoh_hdr_html wkr__hdr = new Xoh_hdr_html();
|
||||
public Xoh_hdr_html Wkr__hdr() {return wkr__hdr;} private final Xoh_hdr_html wkr__hdr = new Xoh_hdr_html();
|
||||
public Xoh_lnki_wtr Lnki_wtr() {return lnki_wtr;} private Xoh_lnki_wtr lnki_wtr;
|
||||
public Ref_html_wtr Ref_wtr() {return ref_wtr;} private Ref_html_wtr ref_wtr;
|
||||
public void Init_by_page(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xoae_page page) {this.page = page; lnki_wtr.Init_by_page(ctx, hctx, src, page);}
|
||||
@ -515,7 +515,7 @@ public class Xoh_html_wtr {
|
||||
bfr.Add_byte_if_not_last(Byte_ascii.Nl);
|
||||
}
|
||||
}
|
||||
public static final byte[] Tag__end_quote = Bry_.new_a7("\">"), Tag__end_bgn = Bry_.new_a7("</")
|
||||
public static final byte[] Tag__end_quote = Bry_.new_a7("\">"), Tag__end_bgn = Bry_.new_a7("</")
|
||||
, Tag_hr = Bry_.new_a7("<hr/>"), Tag_br = Bry_.new_a7("<br/>")
|
||||
, Tag_list_grp_ul_bgn = Bry_.new_a7("<ul>"), Tag_list_grp_ul_end = Bry_.new_a7("</ul>")
|
||||
, Tag_list_grp_ol_bgn = Bry_.new_a7("<ol>"), Tag_list_grp_ol_end = Bry_.new_a7("</ol>")
|
||||
@ -536,7 +536,7 @@ public class Xoh_html_wtr {
|
||||
public static final int Sub_idx_null = -1; // nonsense placeholder
|
||||
}
|
||||
class Xoh_display_ttl_wtr {
|
||||
private static final byte[]
|
||||
private static final byte[]
|
||||
Atr_key_style = Bry_.new_a7("style")
|
||||
, Msg_style_restricted = Bry_.new_a7(" style='/* attempt to bypass $wgRestrictDisplayTitle */'")
|
||||
;
|
||||
@ -561,7 +561,7 @@ class Xoh_display_ttl_wtr {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static final Xoh_display_ttl_wtr Instance = new Xoh_display_ttl_wtr(); Xoh_display_ttl_wtr() {}
|
||||
public static final Xoh_display_ttl_wtr Instance = new Xoh_display_ttl_wtr(); Xoh_display_ttl_wtr() {}
|
||||
}
|
||||
/*
|
||||
NOTE_1:inline always written as <tag></tag>, not <tag/>
|
||||
|
@ -21,9 +21,17 @@ import gplx.langs.htmls.*; import gplx.xowa.htmls.hrefs.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkes.*;
|
||||
import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_lnke_html {
|
||||
private static final byte[] Disabled_button = Bry_.new_a7("⊗");
|
||||
public void Write_html(Bry_bfr bfr, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke) {
|
||||
int href_bgn = lnke.Lnke_href_bgn(), href_end = lnke.Lnke_href_end(); boolean proto_is_xowa = lnke.Proto_tid() == Gfo_protocol_itm.Tid_xowa;
|
||||
byte lnke_type = Calc_type(lnke);
|
||||
if (proto_is_xowa && hctx.Mode() == Xoh_wtr_ctx.Mode_file_dump) { // if protocol and file-dump, then don't write link; DATE:2016-04-12
|
||||
bfr.Add(Gfh_tag_.Div_lhs);
|
||||
Write_caption(bfr, html_wtr, hctx, ctx, src, lnke, href_bgn, href_end, proto_is_xowa);
|
||||
bfr.Add(Gfh_entity_.Nbsp_num_bry).Add(Disabled_button);
|
||||
bfr.Add(Gfh_tag_.Div_rhs);
|
||||
return;
|
||||
}
|
||||
if (!hctx.Mode_is_alt()) { // do not write "<a ...>" if mode is alt
|
||||
bfr.Add(Gfh_bldr_.Bry__a_lhs_w_href);
|
||||
if (Write_href(bfr, hctx, ctx, src, lnke, href_bgn, href_end, proto_is_xowa))
|
||||
@ -40,7 +48,7 @@ public class Xoh_lnke_html {
|
||||
public boolean Write_href(Bry_bfr bfr, Xoh_wtr_ctx hctx, Xop_ctx ctx, byte[] src, Xop_lnke_tkn lnke, int href_bgn, int href_end, boolean proto_is_xowa) {
|
||||
byte[] lnke_xwiki_wiki = lnke.Lnke_xwiki_wiki();
|
||||
if ( lnke_xwiki_wiki == null
|
||||
|| hctx.Mode_is_hdump() // if hdump, never write xwiki format (/site/); always write in url format (https:); note that xwiki is set when wiki is installed locally
|
||||
|| hctx.Mode_is_hdump() // if hdump, never write xwiki format (/site/); always write in url format (https:); note that xwiki is set when wiki is installed locally
|
||||
|| hctx.Mode() == Xoh_wtr_ctx.Mode_file_dump
|
||||
) {
|
||||
if (lnke.Lnke_relative()) { // relative; EX: //a.org
|
||||
|
@ -99,7 +99,9 @@ public class Xoh_href_wtr {
|
||||
encoder.Encode(encoder_bfr, ttl_full, page_bgn, page_end); // add page
|
||||
if (hctx.Mode() == Xoh_wtr_ctx.Mode_file_dump) {
|
||||
byte[] href_end = hctx.Anch__href__end();
|
||||
if (href_end != null) encoder_bfr.Add(href_end);
|
||||
if ( href_end != null
|
||||
&& page_end - page_bgn > 0) // handle [[#A]] which will have no page; else will dump "home/page/.html#A"; DATE:2016-04-12
|
||||
encoder_bfr.Add(href_end);
|
||||
}
|
||||
encoder.Encode(encoder_bfr, ttl_full, anch_bgn, ttl_full.length); // add anchor
|
||||
}
|
||||
|
@ -42,9 +42,15 @@ public class Xow_parser_mgr {
|
||||
Xop_root_tkn root = ctx.Tkn_mkr().Root(page.Data_raw());
|
||||
if (clear) {page.Clear_all();}
|
||||
Xoa_ttl ttl = page.Ttl();
|
||||
if ( Xow_page_tid.Identify(wiki.Domain_tid(), ttl.Ns().Id(), ttl.Page_db()) == Xow_page_tid.Tid_wikitext) // only parse page if wikitext; skip .js, .css, Module; DATE:2013-11-10
|
||||
main.Parse_text_to_wdom(root, ctx, tkn_mkr, page.Data_raw(), Xop_parser_.Doc_bgn_bos);
|
||||
if ( Xow_page_tid.Identify(wiki.Domain_tid(), ttl.Ns().Id(), ttl.Page_db()) == Xow_page_tid.Tid_wikitext) { // only parse page if wikitext; skip .js, .css, Module; DATE:2013-11-10
|
||||
byte[] data_raw = page.Data_raw();
|
||||
// if (wiki.Domain_tid() == gplx.xowa.wikis.domains.Xow_domain_tid_.Int__home) {
|
||||
// data_raw = Bry_.Add(Temp__page_title, data_raw);
|
||||
// }
|
||||
main.Parse_text_to_wdom(root, ctx, tkn_mkr, data_raw , Xop_parser_.Doc_bgn_bos);
|
||||
}
|
||||
page.Root_(root);
|
||||
root.Data_htm_(root.Root_src());
|
||||
}
|
||||
// private static final byte[] Temp__page_title = Bry_.new_a7("{{PageTitle}}");
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
if ( cache_itm != null
|
||||
// && Bry_.Eq(cache_itm.Ttl().Full_db(), ctx.Page().Page_ttl().Full_db()) // make sure that transcluded item is not same as page_ttl; DATE:2014-01-10
|
||||
) {
|
||||
transclude_src = cache_itm.Wtxt();
|
||||
transclude_src = cache_itm.Wtxt__direct();
|
||||
page_ttl = cache_itm.Ttl();
|
||||
}
|
||||
}
|
||||
@ -372,7 +372,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
}
|
||||
public static Xot_defn_tmpl Load_defn(Xowe_wiki wiki, Xop_ctx ctx, Xot_invk_tkn invk_tkn, Xoa_ttl ttl, byte[] name_ary) {
|
||||
Xow_page_cache_itm tmpl_page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm(ttl);
|
||||
byte[] tmpl_page_bry = tmpl_page_itm == null ? null : tmpl_page_itm.Wtxt();
|
||||
byte[] tmpl_page_bry = tmpl_page_itm == null ? null : tmpl_page_itm.Wtxt__direct();
|
||||
Xot_defn_tmpl rv = null;
|
||||
if (tmpl_page_bry != null) {
|
||||
byte old_parse_tid = ctx.Parse_tid(); // NOTE: reusing ctxs is a bad idea; will change Parse_tid and cause strange errors; however, keeping for PERF reasons
|
||||
@ -409,7 +409,7 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
|
||||
Xow_page_cache_itm cache_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm(page_ttl);
|
||||
if ( cache_itm != null) {
|
||||
if (!Bry_.Eq(cache_itm.Ttl().Full_db(), ctx.Page().Ttl().Full_db())) { // make sure that transcluded item is not same as page_ttl; DATE:2014-01-10
|
||||
transclude_tmpl = ctx.Wiki().Parser_mgr().Main().Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), page_ttl.Ns(), page_ttl.Page_db(), cache_itm.Wtxt());
|
||||
transclude_tmpl = ctx.Wiki().Parser_mgr().Main().Parse_text_to_defn_obj(ctx, ctx.Tkn_mkr(), page_ttl.Ns(), page_ttl.Page_db(), cache_itm.Wtxt__direct());
|
||||
page_ttl = cache_itm.Ttl();
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import gplx.xowa.langs.*;
|
||||
public class Xop_xnde_tag_ {
|
||||
public static final int Bgn_mode__normal = 0, Bgn_mode__inline = 1;
|
||||
public static final int End_mode__normal = 0, End_mode__inline = 1, End_mode__escape = 2; // escape is for hr which does not support </hr>
|
||||
public static final byte[] Bry__onlyinclude = Bry_.new_a7("onlyinclude");
|
||||
public static final byte[] Bry__end_tag_bgn = Bry_.new_a7("</");
|
||||
public static final byte[] Bry__onlyinclude = Bry_.new_a7("onlyinclude");
|
||||
public static final byte[] Bry__end_tag_bgn = Bry_.new_a7("</");
|
||||
public static final int
|
||||
Tid__null = -1
|
||||
, Tid__b = 0
|
||||
@ -144,13 +144,13 @@ public class Xop_xnde_tag_ {
|
||||
, Tid__tabview = 117
|
||||
;
|
||||
public static final int Tid__len = 118;
|
||||
public static final Xop_xnde_tag[] Ary = new Xop_xnde_tag[Tid__len];
|
||||
public static final Xop_xnde_tag[] Ary = new Xop_xnde_tag[Tid__len];
|
||||
private static Xop_xnde_tag New(int id, String name) {
|
||||
Xop_xnde_tag rv = new Xop_xnde_tag(id, name);
|
||||
Ary[id] = rv;
|
||||
return rv;
|
||||
}
|
||||
public static final Xop_xnde_tag
|
||||
public static final Xop_xnde_tag
|
||||
Tag__b = New(Tid__b, "b").No_inline_()
|
||||
, Tag__strong = New(Tid__strong, "strong").No_inline_()
|
||||
, Tag__i = New(Tid__i, "i").No_inline_()
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.specials.randoms; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xows_page_random implements Xows_page {
|
||||
public Xows_page_random(Xowe_wiki wiki) {}
|
||||
public Rndm_mgr Mgr() {return mgr;} private final Rndm_mgr mgr = new Rndm_mgr();
|
||||
// public Rndm_mgr Mgr() {return mgr;} private final Rndm_mgr mgr = new Rndm_mgr();
|
||||
public Xows_special_meta Special__meta() {return Xows_special_meta_.Itm__random;}
|
||||
public void Special__gen(Xow_wiki wikii, Xoa_page pagei, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xowe_wiki wiki = (Xowe_wiki)wikii; Xoae_page page = (Xoae_page)pagei;
|
||||
|
@ -22,7 +22,7 @@ public class Xow_page_cache {
|
||||
public Xow_page_cache(Xowe_wiki wiki) {this.wiki = wiki;}
|
||||
public byte[] Get_or_load_as_src(Xoa_ttl ttl) {
|
||||
Xow_page_cache_itm rv = Get_or_load_as_itm(ttl);
|
||||
return rv == null ? null : rv.Wtxt();
|
||||
return rv == null ? null : rv.Wtxt__direct();
|
||||
}
|
||||
public Xow_page_cache_itm Get_or_load_as_itm(Xoa_ttl ttl) {
|
||||
byte[] ttl_full_db = ttl.Full_db();
|
||||
|
@ -17,11 +17,14 @@ 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.*;
|
||||
public class Xow_page_cache_itm {
|
||||
public Xow_page_cache_itm(Xoa_ttl ttl, byte[] wtxt, byte[] redirected_src_wtxt) {
|
||||
this.ttl = ttl; this.wtxt = wtxt; this.redirected_src_wtxt = redirected_src_wtxt;
|
||||
public Xow_page_cache_itm(Xoa_ttl ttl, byte[] wtxt__direct, byte[] wtxt__redirect) {
|
||||
this.ttl = ttl; this.wtxt__direct = wtxt__direct; this.wtxt__redirect = wtxt__redirect;
|
||||
}
|
||||
public Xoa_ttl Ttl() {return ttl;} private Xoa_ttl ttl;
|
||||
public byte[] Wtxt() {return wtxt;} private byte[] wtxt;
|
||||
public byte[] Redirected_src_wtxt() {return redirected_src_wtxt;} private byte[] redirected_src_wtxt;
|
||||
public static final Xow_page_cache_itm Null = null;
|
||||
public byte[] Wtxt__direct() {return wtxt__direct;} private byte[] wtxt__direct;
|
||||
public byte[] Wtxt__redirect() {return wtxt__redirect;} private byte[] wtxt__redirect;
|
||||
public byte[] Wtxt__redirect_or_direct() {
|
||||
return wtxt__redirect == null ? wtxt__direct : wtxt__redirect;
|
||||
}
|
||||
public static final Xow_page_cache_itm Null = null;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class Xowd_db_file_ {
|
||||
, Tid_wiki_solo = 8, Tid_text_solo = 9
|
||||
, Tid_html_solo = 10, Tid_html_data = 11
|
||||
, Tid_file_solo = 12, Tid_file_core = 13, Tid_file_data = 14, Tid_file_user = 15
|
||||
, Tid_search_link = 16
|
||||
, Tid_search_link = 16, Tid_random = 17
|
||||
;
|
||||
private static final String
|
||||
Key_core = "core", Key_text = "text", Key_cat = "xtn.category", Key_search_core = "xtn.search.core", Key_wbase = "core.wbase"
|
||||
@ -32,7 +32,7 @@ public class Xowd_db_file_ {
|
||||
, Key_text_solo = "text.solo", Key_wiki_solo = "wiki.solo"
|
||||
, Key_html_solo = "html.solo", Key_html_data = "html"
|
||||
, Key_file_solo = "file.solo", Key_file_core = "file.core", Key_file_data = "file.data", Key_file_user = "file.user"
|
||||
, Key_search_link = "xtn.search.link"
|
||||
, Key_search_link = "xtn.search.link", Key_random = "xtn.random"
|
||||
;
|
||||
public static String To_key(byte v) {
|
||||
switch (v) {
|
||||
@ -52,6 +52,7 @@ public class Xowd_db_file_ {
|
||||
case Tid_file_data: return Key_file_data;
|
||||
case Tid_file_user: return Key_file_user;
|
||||
case Tid_search_link: return Key_search_link;
|
||||
case Tid_random: return Key_random;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,10 @@ public class Xowd_db_mgr {
|
||||
Dbs__set_by_tid(rv);
|
||||
return rv;
|
||||
}
|
||||
public Xowd_db_file Dbs__remake_by_tid(byte tid) {
|
||||
Dbs__delete_by_tid(tid);
|
||||
return Dbs__make_by_tid(tid);
|
||||
}
|
||||
public void Dbs__delete_by_tid(byte... tids) {
|
||||
int len = dbs__ary_len;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
|
@ -69,7 +69,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
this.Insert_cmd_by_batch(page_id, ns_id, ttl_wo_ns, page_is_redirect, modified_on, page_len, random_int, text_db_id, html_db_id);
|
||||
this.Insert_end();
|
||||
}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__page__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_bgn() {conn.Txn_bgn("page__insert_bulk"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int page_id, int ns_id, byte[] ttl_wo_ns, boolean page_is_redirect, DateAdp modified_on, int page_len, int random_int, int text_db_id, int html_db_id) {
|
||||
stmt_insert.Clear()
|
||||
|
@ -26,11 +26,11 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
siteinfo_mainpage = main_page; // note that main_page came from <siteinfo>; store old value for record's sake
|
||||
main_page = Xow_mainpage_finder.Find_or(wiki, siteinfo_mainpage); // get new main_page from mainpage_finder
|
||||
}
|
||||
public byte Protocol_tid() {return protocol_tid;} private final byte protocol_tid = gplx.core.net.Gfo_protocol_itm.Tid_https; // NOTE: default protocol to https; handles external links like [//a.org]; may need to be changed for wikia or other non-WMF wikis; DATE:2015-07-27
|
||||
public byte Protocol_tid() {return protocol_tid;} private final byte protocol_tid = gplx.core.net.Gfo_protocol_itm.Tid_https; // NOTE: default protocol to https; handles external links like [//a.org]; may need to be changed for wikia or other non-WMF wikis; DATE:2015-07-27
|
||||
|
||||
public byte[] Site_name() {return site_name;} private byte[] site_name = Bry_.Empty;
|
||||
public byte[] ServerName() {return serverName;} public Xow_wiki_props ServerName_(byte[] v) {serverName = v; server = Bry_.Add(bry_http, v); return this;} private byte[] serverName = Bry_.new_a7("localhost");
|
||||
public byte[] Server() {return server;} private byte[] server = Bry_.new_a7("http://localhost"); static final byte[] bry_http = Bry_.new_a7("http://");
|
||||
public byte[] Server_name() {return server_name;} private byte[] server_name = Bry_.new_a7("localhost");
|
||||
public byte[] Server() {return server;} private byte[] server = Bry_.new_a7("http://localhost");
|
||||
public byte[] ArticlePath() {return articlePath;} public Xow_wiki_props ArticlePath_(byte[] v) {articlePath = v; return this;} private byte[] articlePath = Xoh_href_.Bry__wiki;
|
||||
public byte[] ScriptPath() {return scriptPath;} public Xow_wiki_props ScriptPath_(byte[] v) {scriptPath = v; return this;} private byte[] scriptPath = Bry_.new_a7("/wiki");
|
||||
public byte[] StylePath() {return stylePath;} public Xow_wiki_props StylePath_(byte[] v) {stylePath = v; return this;} private byte[] stylePath = Bry_.new_a7("/wiki/skins");
|
||||
@ -42,7 +42,12 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
public byte[] Siteinfo_misc() {return siteinfo_misc;}
|
||||
public byte[] Siteinfo_mainpage() {return siteinfo_mainpage;} private byte[] siteinfo_mainpage = Bry_.Empty;
|
||||
public DateAdp Modified_latest() {return modified_latest;} private DateAdp modified_latest;
|
||||
public Xow_wiki_props SiteName_(int v) {site_name = Bry_.new_a7(String_.UpperFirst(String_.new_a7(Xow_domain_tid_.Get_type_as_bry(v)))); return this;}
|
||||
public Xow_wiki_props Init_props(int domain_tid, byte[] domain_bry) {
|
||||
this.site_name = Bry_.new_a7(String_.UpperFirst(String_.new_a7(Xow_domain_tid_.Get_type_as_bry(domain_tid)))); // EX: "Wikipedia"
|
||||
this.server_name = domain_bry; // EX: "en.wikipedia.org"
|
||||
this.server = Bry_.Add(gplx.core.net.Gfo_protocol_itm.Itm_https.Text_bry(), domain_bry); // EX: "https://en.wikipedia.org"
|
||||
return this;
|
||||
}
|
||||
public Xow_wiki_props Siteinfo_misc_(byte[] v) {
|
||||
siteinfo_misc = v;
|
||||
int pipe_0 = Bry_find_.Find_fwd(v, Byte_ascii.Pipe);
|
||||
@ -73,5 +78,5 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
, Invk_css_version_ = "css_version_"
|
||||
, Invk_modified_latest_ = "modified_latest_"
|
||||
;
|
||||
private static final byte[] Current_version_const = Bry_.new_a7("1.21wmf11"); // approximate level of compatibility
|
||||
private static final byte[] Current_version_const = Bry_.new_a7("1.21wmf11"); // approximate level of compatibility
|
||||
}
|
||||
|
@ -60,20 +60,6 @@ public class Xopg_html_data {
|
||||
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;}
|
||||
public void Custom_head_end_concat(byte[] v) {
|
||||
if (v == null)
|
||||
custom_head_end = v;
|
||||
else
|
||||
custom_head_end = Bry_.Add(custom_head_end, v);
|
||||
} private byte[] custom_head_end;
|
||||
public void Custom_html_end_concat(byte[] v) {
|
||||
if (v == null)
|
||||
custom_html_end = v;
|
||||
else
|
||||
custom_html_end = Bry_.Add(custom_html_end, v);
|
||||
} private byte[] custom_html_end;
|
||||
public void Clear() {
|
||||
html_restricted = true;
|
||||
display_ttl = content_sub = display_ttl_vnt = null;
|
||||
@ -88,7 +74,7 @@ public class Xopg_html_data {
|
||||
xtn_scribunto_dbg = Bry_.Empty;
|
||||
xtn_pgbnr = null;
|
||||
module_mgr.Clear();
|
||||
custom_html = custom_html_end = custom_head_end = custom_tab_name = null;
|
||||
custom_html = custom_tab_name = null;
|
||||
if (ctg_hash != null) ctg_hash.Clear();
|
||||
indicators.Clear();
|
||||
this.mode_wtxt_shown = false;
|
||||
|
@ -19,15 +19,15 @@ package gplx.xowa.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import gplx.core.brys.*; import gplx.core.brys.fmtrs.*;
|
||||
public class Xopg_page_heading implements Bfr_arg {
|
||||
private Xopg_html_data html_data;
|
||||
private Xoa_ttl page_ttl;
|
||||
public Xopg_page_heading Init(Xoae_page page) {
|
||||
this.html_data = page.Html_data();
|
||||
this.page_ttl = page.Ttl();
|
||||
private byte[] display_title;
|
||||
public Xopg_page_heading Init(Xopg_html_data html_data, byte[] display_title) {
|
||||
this.html_data = html_data;
|
||||
this.display_title = display_title;
|
||||
return this;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
if (html_data.Xtn_pgbnr() != null) return; // pgbnr exists; don't add title
|
||||
fmtr.Bld_many(bfr, page_ttl.Page_txt());
|
||||
fmtr.Bld_many(bfr, display_title);
|
||||
}
|
||||
private final Bry_fmt fmtr = Bry_fmt.New(Bry_.New_u8_nl_apos("<h1 id='firstHeading' class='firstHeading'><span>~{page_title}</span></h1>"), "page_title");
|
||||
private final Bry_fmt fmtr = Bry_fmt.New(Bry_.New_u8_nl_apos("<h1 id='firstHeading' class='firstHeading'><span>~{page_title}</span></h1>"), "page_title");
|
||||
}
|
||||
|
@ -16,18 +16,19 @@ 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.*;
|
||||
import gplx.langs.htmls.*;
|
||||
public class Xopg_tag_itm {
|
||||
public Xopg_tag_itm(String name, String text, Keyval... atrs_ary) {
|
||||
public Xopg_tag_itm(byte[] name, byte[] 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 byte[] Name;
|
||||
public final byte[] 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);
|
||||
bfr.Add(Name);
|
||||
int len = Atrs_ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
bfr.Add_byte_space();
|
||||
@ -39,20 +40,27 @@ public class Xopg_tag_itm {
|
||||
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);
|
||||
if (Bry_.Eq(Name, Gfh_tag_.Bry__link)) return;
|
||||
if (Text != null) {
|
||||
bfr.Add_byte_nl();
|
||||
bfr.Add(Text);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
bfr.Add_byte(Byte_ascii.Angle_bgn).Add_byte(Byte_ascii.Slash);
|
||||
bfr.Add_str_a7(Name);
|
||||
bfr.Add(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_css_file(Io_url href) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__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_css_code(byte[] code) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__style , code, Keyval_.new_("type", "text/css"));
|
||||
}
|
||||
public static Xopg_tag_itm New_script_code(String code) {
|
||||
return new Xopg_tag_itm("script", code, Keyval_.new_("type", "text/javascript"));
|
||||
public static Xopg_tag_itm New_js_file(Io_url src) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__script , null, Keyval_.new_("type", "text/javascript"), Keyval_.new_("src", src.To_http_file_str()));
|
||||
}
|
||||
public static Xopg_tag_itm New_js_code(byte[] code) {
|
||||
return new Xopg_tag_itm(Gfh_tag_.Bry__script , code, Keyval_.new_("type", "text/javascript"));
|
||||
}
|
||||
}
|
||||
|
@ -35,4 +35,17 @@ public class Xopg_tag_mgr {
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] To_html__style(Bry_bfr bfr) {
|
||||
int len = this.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xopg_tag_itm tag = this.Get_at(i);
|
||||
if ( Bry_.Eq(tag.Name, gplx.langs.htmls.Gfh_tag_.Bry__style)
|
||||
&& tag.Text != null
|
||||
) {
|
||||
tag.To_html(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
}
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
|
@ -43,4 +43,9 @@ public class Xox_xnde_ {
|
||||
rv.Init(ctx.Page().Url_bry_safe(), src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
return rv;
|
||||
}
|
||||
public static byte[] Extract_body_or_null(byte[] src, Xop_xnde_tkn xnde) {
|
||||
int body_bgn = xnde.Tag_open_end();
|
||||
int body_end = xnde.Tag_close_bgn();
|
||||
return body_bgn != -1 && body_end > body_bgn ? Bry_.Mid(src, body_bgn, body_end) : null;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class Pfunc_ifexist_mgr {
|
||||
boolean rv = false;
|
||||
switch (ttl_ns.Id()) {
|
||||
case Xow_ns_.Tid__special: rv = true; break; // NOTE: some pages call for [[Special]]; always return true for now; DATE:2014-07-17
|
||||
case Xow_ns_.Tid__media: rv = Find_ttl_for_media_ns(exists_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
case Xow_ns_.Tid__media: rv = Find_ttl_for_media_ns(exists_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
default: rv = Find_ttl_in_db(exists_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
}
|
||||
exists_itm.Exists_(rv);
|
||||
|
@ -49,5 +49,5 @@ public class Pfunc_displaytitle extends Pf_func_base {
|
||||
byte[] rv = case_mgr.Case_build_lower(val); // lower-case
|
||||
return Bry_.Replace(rv, Byte_ascii.Space, Byte_ascii.Underline); // force underline; PAGE:de.w:Mod_qos DATE:2014-11-06
|
||||
}
|
||||
public static final Pfunc_displaytitle Instance = new Pfunc_displaytitle(); Pfunc_displaytitle() {}
|
||||
public static final Pfunc_displaytitle Instance = new Pfunc_displaytitle(); Pfunc_displaytitle() {}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class Pfunc_urlfunc extends Pf_func_base { // EX: {{lc:A}} -> a
|
||||
Bry_bfr tmp_bfr = ctx.App().Utl__bfr_mkr().Get_b512().Mkr_rls();
|
||||
switch (tid) {
|
||||
case Tid_local: tmp_bfr.Add(ctx.Wiki().Props().ArticlePath());break;
|
||||
case Tid_full: tmp_bfr.Add(Bry_relative_url).Add(ctx.Wiki().Props().ServerName()).Add(ctx.Wiki().Props().ArticlePath()); break;
|
||||
case Tid_full: tmp_bfr.Add(Bry_relative_url).Add(ctx.Wiki().Props().Server_name()).Add(ctx.Wiki().Props().ArticlePath()); break;
|
||||
case Tid_canonical: tmp_bfr.Add(ctx.Wiki().Props().Server()).Add(ctx.Wiki().Props().ArticlePath()); break;
|
||||
default: throw Err_.new_unhandled(tid);
|
||||
}
|
||||
@ -58,7 +58,7 @@ public class Pfunc_urlfunc extends Pf_func_base { // EX: {{lc:A}} -> a
|
||||
@Override public int Id() {return id;} private int id;
|
||||
@Override public Pf_func New(int id, byte[] name) {return new Pfunc_urlfunc(id, tid, encode).Name_(name);}
|
||||
public static final byte Tid_local = 0, Tid_full = 1, Tid_canonical = 2;
|
||||
public static final byte[] Bry_relative_url = Bry_.new_a7("//");
|
||||
public static final byte[] Bry_relative_url = Bry_.new_a7("//");
|
||||
}
|
||||
/*
|
||||
NOTE: Both fullurle: and localurle: performed additional character escaping on the resulting link, but no example is known where that still has any additional effect.
|
||||
|
@ -18,15 +18,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.pfuncs.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import org.junit.*;
|
||||
public class Pfunc_urlfunc_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Localurl() {fxt.Test_parse_tmpl_str_test("{{localurl:a&b! c}}" , "{{test}}", "/wiki/A%26b!_c");}
|
||||
@Test public void Fullurl() {fxt.Test_parse_tmpl_str_test("{{fullurl:a&b! c}}" , "{{test}}", "//en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Canonicalurl() {fxt.Test_parse_tmpl_str_test("{{canonicalurl:a&b! c}}" , "{{test}}", "http://en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Canonicalurl_case() {fxt.Test_parse_tmpl_str_test("{{CANONICALURL:a&b! c}}" , "{{test}}", "http://en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Localurle() {fxt.Test_parse_tmpl_str_test("{{localurle:a&b! c}}" , "{{test}}", "/wiki/A%26b!_c");}
|
||||
@Test public void Canonicalurl() {fxt.Test_parse_tmpl_str_test("{{canonicalurl:a&b! c}}" , "{{test}}", "https://en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Canonicalurl_case() {fxt.Test_parse_tmpl_str_test("{{CANONICALURL:a&b! c}}" , "{{test}}", "https://en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Localurle() {fxt.Test_parse_tmpl_str_test("{{localurle:a&b! c}}" , "{{test}}", "/wiki/A%26b!_c");}
|
||||
@Test public void Fullurle() {fxt.Test_parse_tmpl_str_test("{{fullurle:a&b! c}}" , "{{test}}", "//en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Canonicalurle() {fxt.Test_parse_tmpl_str_test("{{canonicalurle:a&b! c}}" , "{{test}}", "http://en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Canonicalurle() {fxt.Test_parse_tmpl_str_test("{{canonicalurle:a&b! c}}" , "{{test}}", "https://en.wikipedia.org/wiki/A%26b!_c");}
|
||||
@Test public void Fullurl_arg() {fxt.Test_parse_tmpl_str_test("{{fullurle:a&b! c|action=edit}}" , "{{test}}", "//en.wikipedia.org/wiki/A%26b!_c?action=edit");}
|
||||
@Test public void Random() {fxt.Test_parse_tmpl_str_test("{{fullurle:a&b! c|action=edit}}" , "{{test|a|b|c}}", "//en.wikipedia.org/wiki/A%26b!_c?action=edit");}
|
||||
@Test public void Xwiki() {
|
||||
|
@ -27,7 +27,7 @@ public class Pfunc_wiki_props extends Pf_func_base {
|
||||
switch (id) {
|
||||
case Xol_kwd_grp_.Id_site_sitename: bfr.Add(props.Site_name()); break;
|
||||
case Xol_kwd_grp_.Id_site_server: bfr.Add(props.Server()); break;
|
||||
case Xol_kwd_grp_.Id_site_servername: bfr.Add(props.ServerName()); break;
|
||||
case Xol_kwd_grp_.Id_site_servername: bfr.Add(props.Server_name()); break;
|
||||
case Xol_kwd_grp_.Id_site_articlepath: bfr.Add(props.ArticlePath()); break;
|
||||
case Xol_kwd_grp_.Id_site_scriptpath: bfr.Add(props.ScriptPath()); break;
|
||||
case Xol_kwd_grp_.Id_site_stylepath: bfr.Add(props.StylePath()); break;
|
||||
@ -38,5 +38,5 @@ public class Pfunc_wiki_props extends Pf_func_base {
|
||||
}
|
||||
}
|
||||
@Override public Pf_func New(int id, byte[] name) {return new Pfunc_wiki_props(id).Name_(name);}
|
||||
public static final Pfunc_wiki_props Instance = new Pfunc_wiki_props(-1);
|
||||
public static final Pfunc_wiki_props Instance = new Pfunc_wiki_props(-1);
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.pfuncs.wikis; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import org.junit.*;
|
||||
public class Pfunc_wiki_stats_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void setup() {fxt.Reset();}
|
||||
@Test public void SiteName() {fxt.Test_parse_tmpl_str_test("{{SITENAME}}" , "{{test}}", "Wikipedia");}
|
||||
@Test public void ServerName() {fxt.Test_parse_tmpl_str_test("{{SERVERNAME}}" , "{{test}}", "en.wikipedia.org");}
|
||||
@Test public void Server() {fxt.Test_parse_tmpl_str_test("{{SERVER}}" , "{{test}}", "http://en.wikipedia.org");}
|
||||
@Test public void Server() {fxt.Test_parse_tmpl_str_test("{{SERVER}}" , "{{test}}", "https://en.wikipedia.org");}
|
||||
@Test public void ArticlePath() {fxt.Test_parse_tmpl_str_test("{{ARTICLEPATH}}" , "{{test}}", "/wiki/");} // FUTURE: should be /wiki/$1
|
||||
@Test public void ScriptPath() {fxt.Test_parse_tmpl_str_test("{{SCRIPTPATH}}" , "{{test}}", "/wiki");}
|
||||
@Test public void StylePath() {fxt.Test_parse_tmpl_str_test("{{STYLEPATH}}" , "{{test}}", "/wiki/skins");}
|
||||
|
@ -87,13 +87,18 @@ class Luaj_value_ {
|
||||
if (o == null) return LuaValue.NIL;
|
||||
Class<?> c = Type_adp_.ClassOf_obj(o);
|
||||
if (Object_.Eq(c, Bool_.Cls_ref_type)) return LuaValue.valueOf((Boolean)o);
|
||||
else if (Object_.Eq(c, Byte_.Cls_ref_type)) return LuaValue.valueOf((Byte)o);
|
||||
else if (Object_.Eq(c, Int_.Cls_ref_type)) return LuaValue.valueOf((Integer)o);
|
||||
else if (Object_.Eq(c, Double_.Cls_ref_type)) return LuaValue.valueOf((Double)o);
|
||||
else if (Object_.Eq(c, String_.Cls_ref_type)) return LuaValue.valueOf((String)o);
|
||||
else if (Object_.Eq(c, Double_.Cls_ref_type)) return LuaValue.valueOf((Double)o);
|
||||
else if (Object_.Eq(c, byte[].class)) return LuaValue.valueOf(String_.new_u8((byte[])o));
|
||||
else if (Object_.Eq(c, Keyval.class)) return X_kv_ary_to_tbl(server, (Keyval)o);
|
||||
else if (Object_.Eq(c, Keyval[].class)) return X_kv_ary_to_tbl(server, (Keyval[])o);
|
||||
else if (Object_.Eq(c, Long_.Cls_ref_type)) return LuaValue.valueOf((Long)o);
|
||||
else if (Object_.Eq(c, Scrib_lua_proc.class)) return server.Get_closure_by_id(((Scrib_lua_proc)o).Id());
|
||||
else if (Object_.Eq(c, Float_.Cls_ref_type)) return LuaValue.valueOf((Float)o);
|
||||
else if (Object_.Eq(c, Char_.Cls_ref_type)) return LuaValue.valueOf((char)o);
|
||||
else if (Object_.Eq(c, Short_.Cls_ref_type)) return LuaValue.valueOf((Short)o);
|
||||
else return LuaValue.NIL;
|
||||
}
|
||||
private static LuaTable X_kv_ary_to_tbl(Luaj_server server, Keyval... ary) {
|
@ -145,7 +145,7 @@ public class Scrib_lib_site implements Scrib_lib {
|
||||
private void Bld_info(Keyval[] rv) {
|
||||
Xow_wiki_props props = core.Wiki().Props();
|
||||
rv[0] = Keyval_.new_("siteName" , props.Site_name());
|
||||
rv[1] = Keyval_.new_("server" , props.Server());
|
||||
rv[1] = Keyval_.new_("server" , Bry_.Add(gplx.core.net.Gfo_protocol_itm.Bry_relative, props.Server_name())); // NOTE: should generate "//en.wikipedia.org", not "de.wikipedia.org"; PAGE:de.w:Giro_d<EFBFBD>Italia_1996 DATE:2016-04-17
|
||||
rv[2] = Keyval_.new_("scriptPath" , props.ScriptPath());
|
||||
rv[3] = Keyval_.new_("stylePath" , props.StylePath());
|
||||
rv[4] = Keyval_.new_("currentVersion" , props.Current_version());
|
||||
|
@ -67,7 +67,7 @@ public class Scrib_lib_site_tst {
|
||||
fxt.Test__proc__objs__nest(lib, Scrib_lib_site.Invk_init_site_for_wiki, Object_.Ary_empty, String_.Concat_lines_nl_skip_last
|
||||
( "1="
|
||||
, " siteName=Wikipedia"
|
||||
, " server=http://en.wikipedia.org"
|
||||
, " server=//en.wikipedia.org"
|
||||
, " scriptPath=/wiki"
|
||||
, " stylePath=/wiki/skins"
|
||||
, " currentVersion=1.21wmf11"
|
||||
|
@ -55,7 +55,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
, Invk_getUrl = "getUrl", Invk_getContent = "getContent", Invk_getFileInfo = "getFileInfo", Invk_getCurrentTitle = "getCurrentTitle"
|
||||
, Invk_protectionLevels = "protectionLevels", Invk_cascadingProtection = "cascadingProtection"
|
||||
;
|
||||
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getExpensiveData, Invk_getUrl, Invk_getContent, Invk_getFileInfo, Invk_getCurrentTitle, Invk_protectionLevels, Invk_cascadingProtection);
|
||||
private static final String[] Proc_names = String_.Ary(Invk_newTitle, Invk_makeTitle, Invk_getExpensiveData, Invk_getUrl, Invk_getContent, Invk_getFileInfo, Invk_getCurrentTitle, Invk_protectionLevels, Invk_cascadingProtection);
|
||||
public boolean NewTitle(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
if (args.Len() == 0) return rslt.Init_obj(null); // invalid title, return null; EX:{{#invoke:Message box|fmbox}} DATE:2015-03-04
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
@ -95,12 +95,12 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
Pfunc_urlfunc.UrlString(core.Ctx(), url_func_tid, false, ttl_bry, bfr, qry_bry);
|
||||
return rslt.Init_obj(bfr.To_str_and_rls());
|
||||
}
|
||||
private static final Hash_adp_bry url_func_hash = Hash_adp_bry.ci_a7()
|
||||
private static final Hash_adp_bry url_func_hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("fullUrl", Pfunc_urlfunc.Tid_full)
|
||||
.Add_str_byte("localUrl", Pfunc_urlfunc.Tid_local)
|
||||
.Add_str_byte("canonicalUrl", Pfunc_urlfunc.Tid_canonical);
|
||||
// private static final byte[] Proto_relative = Bry_.new_a7("relative");
|
||||
// private static final Hash_adp_bry proto_hash = Hash_adp_bry.ci_a7().Add_str_obj("http", Bry_.new_a7("http://")).Add_str_obj("https", Bry_.new_a7("https://")).Add_str_obj("relative", Bry_.new_a7("//")).Add_str_obj("canonical", Bry_.new_a7("1"));
|
||||
// private static final byte[] Proto_relative = Bry_.new_a7("relative");
|
||||
// private static final Hash_adp_bry proto_hash = Hash_adp_bry.ci_a7().Add_str_obj("http", Bry_.new_a7("http://")).Add_str_obj("https", Bry_.new_a7("https://")).Add_str_obj("relative", Bry_.new_a7("//")).Add_str_obj("canonical", Bry_.new_a7("1"));
|
||||
private byte[] Parse_ns(Xowe_wiki wiki, Object ns_obj) {
|
||||
if (Type_adp_.Eq_typeSafe(ns_obj, String.class))
|
||||
return Bry_.new_u8(String_.cast(ns_obj));
|
||||
@ -171,7 +171,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
);
|
||||
return rslt.Init_obj(rv);
|
||||
}
|
||||
private static final Keyval[] GetFileInfo_absent = Keyval_.Ary(Keyval_.new_("exists", false));
|
||||
private static final Keyval[] GetFileInfo_absent = Keyval_.Ary(Keyval_.new_("exists", false));
|
||||
public boolean GetContent(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
byte[] ttl_bry = args.Pull_bry(0);
|
||||
Xowe_wiki wiki = core.Wiki();
|
||||
@ -179,13 +179,13 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
Xow_page_cache_itm page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm(ttl);
|
||||
byte[] rv = null;
|
||||
if (page_itm != null) {
|
||||
byte[] redirected_src = page_itm.Redirected_src_wtxt();
|
||||
byte[] redirected_src = page_itm.Wtxt__redirect();
|
||||
if (redirected_src != null) { // page is redirect; use its src, not its target's src; DATE:2014-07-11
|
||||
rv = redirected_src;
|
||||
core.Frame_parent().Rslt_is_redirect_(true); // flag frame as redirect, so that \n won't be prepended; EX:"#REDIRECT" x> "\n#REDIRECT"
|
||||
}
|
||||
else
|
||||
rv = page_itm.Wtxt();
|
||||
rv = page_itm.Wtxt__direct();
|
||||
}
|
||||
return rv == null ? rslt.Init_obj(null) : rslt.Init_obj(String_.new_u8(rv));
|
||||
}
|
||||
@ -204,7 +204,7 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry); if (ttl == null) return rslt.Init_obj(null);
|
||||
return rslt.Init_obj(CascadingProtection_rv);
|
||||
}
|
||||
public static final Keyval[] CascadingProtection_rv = Keyval_.Ary(Keyval_.new_("sources", Bool_.N), Keyval_.new_("restrictions", Keyval_.Ary_empty));
|
||||
public static final Keyval[] CascadingProtection_rv = Keyval_.Ary(Keyval_.new_("sources", Bool_.N), Keyval_.new_("restrictions", Keyval_.Ary_empty));
|
||||
private Keyval[] GetInexpensiveTitleData(Xoa_ttl ttl) {
|
||||
Xow_ns ns = ttl.Ns();
|
||||
boolean ns_file_or_media = ns.Id_is_file_or_media(), ns_special = ns.Id_is_special();
|
||||
@ -226,6 +226,6 @@ public class Scrib_lib_title implements Scrib_lib {
|
||||
if (!ns_file_or_media)
|
||||
rv[rv_idx++] = Keyval_.new_("file" , false); // REF.MW: if ( $ns !== NS_FILE && $ns !== NS_MEDIA ) $ret['file'] = false;
|
||||
return rv;
|
||||
} private static final Xowd_page_itm tmp_db_page = Xowd_page_itm.new_tmp();
|
||||
} private static final Xowd_page_itm tmp_db_page = Xowd_page_itm.new_tmp();
|
||||
public static final String Key_wikitexet = "wikitext";
|
||||
}
|
||||
|
@ -40,11 +40,11 @@ public class Scrib_lib_title_tst {
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl") , "//en.wikipedia.org/wiki/Main_Page");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "action=edit") , "//en.wikipedia.org/wiki/Main_Page?action=edit");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "localUrl") , "/wiki/Main_Page");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl") , "http://en.wikipedia.org/wiki/Main_Page");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl") , "https://en.wikipedia.org/wiki/Main_Page");
|
||||
// fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "fullUrl", "", "http") , "http://en.wikipedia.org/wiki/Main_Page"); // TODO
|
||||
}
|
||||
@Test public void GetUrl__args_many() { // PUPROSE: GetUrl sometimes passes in kvs for qry_args; fr.w:Wikip<EFBFBD>dia:Image_du_jour/Date; DATE:2013-12-24
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl", Keyval_.Ary(Keyval_.new_("action", "edit"), Keyval_.new_("preload", "b"))), "http://en.wikipedia.org/wiki/Main_Page?action=edit&preload=b");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_title.Invk_getUrl, Object_.Ary("Main_Page", "canonicalUrl", Keyval_.Ary(Keyval_.new_("action", "edit"), Keyval_.new_("preload", "b"))), "https://en.wikipedia.org/wiki/Main_Page?action=edit&preload=b");
|
||||
}
|
||||
@Test public void MakeTitle() {
|
||||
fxt.Test_scrib_proc_str_ary(lib, Scrib_lib_title.Invk_makeTitle, Object_.Ary("Module", "A") , ttl_fast(828, "Module", "A"));
|
||||
|
@ -25,7 +25,7 @@ public class Scrib_lib_uri_tst {
|
||||
@Test public void Url() {
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("a&b! c" ), "/wiki/A%26b!_c");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_fullUrl , Object_.Ary("a&b! c" ), "//en.wikipedia.org/wiki/A%26b!_c");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_canonicalUrl , Object_.Ary("a&b! c" ), "http://en.wikipedia.org/wiki/A%26b!_c");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_canonicalUrl , Object_.Ary("a&b! c" ), "https://en.wikipedia.org/wiki/A%26b!_c");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("a&b! c" , "action=edit" ), "/wiki/A%26b!_c?action=edit");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("Media:A.png" ), "/wiki/File:A.png");
|
||||
fxt.Test_scrib_proc_str(lib, Scrib_lib_uri.Invk_localUrl , Object_.Ary("[bad]" ), Scrib_invoke_func_fxt.Null_rslt); // handle invalid titles; EX:it.w:Billy_the_Kid; DATE:2014-01-20
|
||||
|
@ -55,7 +55,7 @@ class Xob_wbase_json_dump_db {
|
||||
this.page_modified_on = DateAdp_.Now();
|
||||
this.page_core_tbl = db_mgr.Tbl__page();
|
||||
page_tbl.Insert_bgn();
|
||||
qid_cmd.Wkr_bgn(bldr);
|
||||
qid_cmd.Page_wkr__bgn();
|
||||
pid_cmd.Pid_bgn();
|
||||
}
|
||||
private int page_id = 0, page_count_main = 0;
|
||||
|
@ -21,16 +21,16 @@ import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public abstract class Xob_wdata_pid_base extends Xob_itm_dump_base implements Xob_page_wkr, GfoInvkAble {
|
||||
private Json_parser parser;
|
||||
public Xob_wdata_pid_base Ctor(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); return this;}
|
||||
public abstract String Wkr_key();
|
||||
public abstract String Page_wkr__key();
|
||||
public abstract void Pid_bgn();
|
||||
public abstract void Pid_add(byte[] src_lang, byte[] src_ttl, byte[] trg_ttl);
|
||||
public abstract void Pid_end();
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
this.Init_dump(this.Wkr_key(), wiki.Tdb_fsys_mgr().Site_dir().GenSubDir_nest("data", "pid")); // NOTE: must pass in correct make_dir in order to delete earlier version (else make_dirs will append)
|
||||
public void Page_wkr__bgn() {
|
||||
this.Init_dump(this.Page_wkr__key(), wiki.Tdb_fsys_mgr().Site_dir().GenSubDir_nest("data", "pid")); // NOTE: must pass in correct make_dir in order to delete earlier version (else make_dirs will append)
|
||||
parser = bldr.App().Wiki_mgr().Wdata_mgr().Jdoc_parser();
|
||||
this.Pid_bgn();
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
if (page.Ns_id() != Wdata_wiki_mgr.Ns_property) return;
|
||||
Json_doc jdoc = parser.Parse(page.Text());
|
||||
if (jdoc == null) {
|
||||
@ -39,6 +39,7 @@ public abstract class Xob_wdata_pid_base extends Xob_itm_dump_base implements Xo
|
||||
}
|
||||
Parse_jdoc(jdoc);
|
||||
}
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Parse_jdoc(Json_doc jdoc) {
|
||||
Wdata_doc_parser wdoc_parser = app.Wiki_mgr().Wdata_mgr().Wdoc_parser(jdoc);
|
||||
byte[] qid = wdoc_parser.Parse_qid(jdoc);
|
||||
@ -49,6 +50,6 @@ public abstract class Xob_wdata_pid_base extends Xob_itm_dump_base implements Xo
|
||||
this.Pid_add(label.Lang(), label.Text(), qid);
|
||||
}
|
||||
}
|
||||
public void Wkr_end() {this.Pid_end();}
|
||||
public void Page_wkr__end() {this.Pid_end();}
|
||||
static final String GRP_KEY = "xowa.wdata.pid_wkr";
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xob_wdata_pid_sql extends Xob_wdata_pid_base {
|
||||
private Xowd_wbase_pid_tbl tbl;
|
||||
@Override public String Wkr_key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_wbase_pid;}
|
||||
@Override public String Page_wkr__key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_wbase_pid;}
|
||||
@Override public void Pid_bgn() {
|
||||
Xowd_db_mgr db_mgr = wiki.Data__core_mgr();
|
||||
tbl = db_mgr.Db__wbase().Tbl__wbase_pid();
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
public class Xob_wdata_pid_txt extends Xob_wdata_pid_base {
|
||||
@Override public String Wkr_key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_tdb_text_wdata_pid;}
|
||||
@Override public String Page_wkr__key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_tdb_text_wdata_pid;}
|
||||
@Override public void Pid_bgn() {
|
||||
pid_bldr = new Wdata_idx_bldr_pid(this, bldr, wiki, dump_fil_len);
|
||||
} Wdata_idx_bldr_pid pid_bldr;
|
||||
|
@ -21,24 +21,25 @@ import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*;
|
||||
import gplx.xowa.bldrs.wms.sites.*;
|
||||
public abstract class Xob_wdata_qid_base extends Xob_itm_dump_base implements Xob_page_wkr, GfoInvkAble {
|
||||
private Json_parser parser; private Xob_wbase_ns_parser ns_parser; private final Xob_wbase_ns_parser_rslt ns_parser_rslt = new Xob_wbase_ns_parser_rslt();
|
||||
private Json_parser parser; private Xob_wbase_ns_parser ns_parser; private final Xob_wbase_ns_parser_rslt ns_parser_rslt = new Xob_wbase_ns_parser_rslt();
|
||||
public Xob_wdata_qid_base Ctor(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki); return this;}
|
||||
public abstract String Wkr_key();
|
||||
public abstract String Page_wkr__key();
|
||||
public abstract void Qid_bgn();
|
||||
public abstract void Qid_add(byte[] wiki_key, int ns_id, byte[] ttl, byte[] qid);
|
||||
public abstract void Qid_end();
|
||||
public void Wkr_bgn(Xob_bldr bldr) {
|
||||
this.Init_dump(this.Wkr_key(), wiki.Tdb_fsys_mgr().Site_dir().GenSubDir_nest("data", "qid")); // NOTE: must pass in correct make_dir in order to delete earlier version (else make_dirs will append)
|
||||
public void Page_wkr__bgn() {
|
||||
this.Init_dump(this.Page_wkr__key(), wiki.Tdb_fsys_mgr().Site_dir().GenSubDir_nest("data", "qid")); // NOTE: must pass in correct make_dir in order to delete earlier version (else make_dirs will append)
|
||||
this.parser = bldr.App().Wiki_mgr().Wdata_mgr().Jdoc_parser();
|
||||
this.ns_parser = new Xob_wbase_ns_parser(bldr.App().Fsys_mgr().Cfg_site_meta_fil());
|
||||
this.Qid_bgn();
|
||||
}
|
||||
public void Wkr_run(Xowd_page_itm page) {
|
||||
public void Page_wkr__run(Xowd_page_itm page) {
|
||||
if (page.Ns_id() != Xow_ns_.Tid__main) return; // qid pages are only in the Main Srch_rslt_cbk
|
||||
Json_doc jdoc = parser.Parse(page.Text());
|
||||
if (jdoc == null) {bldr.Usr_dlg().Warn_many("", "", "json is invalid: ns=~{0} id=~{1}", page.Ns_id(), String_.new_u8(page.Ttl_page_db())); return;}
|
||||
this.Parse_jdoc(jdoc);
|
||||
}
|
||||
public void Page_wkr__run_cleanup() {}
|
||||
public void Parse_jdoc(Json_doc jdoc) {
|
||||
Wdata_doc_parser wdoc_parser = app.Wiki_mgr().Wdata_mgr().Wdoc_parser(jdoc);
|
||||
byte[] qid = wdoc_parser.Parse_qid(jdoc);
|
||||
@ -56,7 +57,7 @@ public abstract class Xob_wdata_qid_base extends Xob_itm_dump_base implements Xo
|
||||
this.Qid_add(sitelink.Site(), sitelink_ns, Xoa_ttl.Replace_spaces(sitelink_ttl), qid); // NOTE: always convert spaces to underscores; EX: "A B" -> "A_B" DATE:2015-04-21
|
||||
}
|
||||
}
|
||||
public void Wkr_end() {
|
||||
public void Page_wkr__end() {
|
||||
this.Qid_end();
|
||||
// wiki.Data__core_mgr().Db__wbase().Tbl__cfg().Insert_int("", "", 1);
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.xowa.wikis.data.*; import gplx.dbs.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xob_wdata_qid_sql extends Xob_wdata_qid_base {
|
||||
private Xowd_wbase_qid_tbl tbl;
|
||||
@Override public String Wkr_key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_wbase_qid;}
|
||||
@Override public String Page_wkr__key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_wbase_qid;}
|
||||
@Override public void Qid_bgn() {
|
||||
Xowd_db_mgr db_mgr = wiki.Db_mgr_as_sql().Core_data_mgr();
|
||||
boolean db_is_all_or_few = db_mgr.Props().Layout_text().Tid_is_all_or_few();
|
||||
|
@ -19,7 +19,7 @@ package gplx.xowa.xtns.wdatas.imports; import gplx.*; import gplx.xowa.*; import
|
||||
import gplx.xowa.bldrs.*;
|
||||
public class Xob_wdata_qid_txt extends Xob_wdata_qid_base {
|
||||
private Wdata_idx_bldr_qid qid_bldr;
|
||||
@Override public String Wkr_key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_tdb_text_wdata_qid;}
|
||||
@Override public String Page_wkr__key() {return gplx.xowa.bldrs.Xob_cmd_keys.Key_tdb_text_wdata_qid;}
|
||||
@Override public void Qid_bgn() {qid_bldr = new Wdata_idx_bldr_qid().Ctor(this, bldr, wiki, dump_fil_len);}
|
||||
@Override public void Qid_add(byte[] wiki_key, int ns_id, byte[] ttl, byte[] qid) {
|
||||
qid_bldr.Add(String_.new_u8(wiki_key), Int_.To_str_pad_bgn_zero(ns_id, 3), ttl, qid);
|
||||
|
@ -78,9 +78,9 @@ public class Random_selection_xnde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
int options_len = options_ary.length;
|
||||
for (int i = 0; i < options_len; ++i) {
|
||||
Rndsel_option_itm option = options_ary[i];
|
||||
rnd -= option.Weight();
|
||||
rnd -= option.Weight;
|
||||
if (rnd <= 0) {
|
||||
option_bry = option.Text();
|
||||
option_bry = option.Text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class Random_selection_xnde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
public static int Rnd_test = -1;
|
||||
}
|
||||
class Rndsel_option_itm {
|
||||
public Rndsel_option_itm(int weight, byte[] text) {this.weight = weight; this.text = text;}
|
||||
public int Weight() {return weight;} private final int weight;
|
||||
public byte[] Text() {return text;} private final byte[] text;
|
||||
public Rndsel_option_itm(int weight, byte[] text) {this.Weight = weight; this.Text = text;}
|
||||
public final int Weight;
|
||||
public final byte[] Text;
|
||||
}
|
||||
|
51
400_xowa/src/gplx/xowa/xtns/wikias/Tabber_tab_itm.java
Normal file
51
400_xowa/src/gplx/xowa/xtns/wikias/Tabber_tab_itm.java
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.langs.htmls.*;
|
||||
class Tabber_tab_itm {
|
||||
public Tabber_tab_itm(boolean active, byte[] name, byte[] text) {
|
||||
this.Active = active;
|
||||
this.Name = name;
|
||||
this.Text = text;
|
||||
}
|
||||
public final boolean Active;
|
||||
public final byte[] Name;
|
||||
public final byte[] Text;
|
||||
public static void Write(Bry_bfr bfr, byte[] id, Tabber_tab_itm[] ary) {
|
||||
bfr.Add_str_a7("<div id=\"tabber-");
|
||||
bfr.Add(id);
|
||||
bfr.Add_str_a7("\" class=\"tabber\">\n");
|
||||
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Tabber_tab_itm itm = ary[i];
|
||||
bfr.Add_str_a7("<div class=\"tabbertab\" title=\"");
|
||||
bfr.Add(Gfh_utl.Escape_html_as_bry(itm.Name));
|
||||
bfr.Add_str_a7("\"");
|
||||
if (itm.Active) {
|
||||
bfr.Add_str_a7(" data-active=\"true\"");
|
||||
}
|
||||
bfr.Add_str_a7(">\n");
|
||||
bfr.Add(Gfh_tag_.P_lhs);
|
||||
bfr.Add(itm.Text);
|
||||
bfr.Add(Gfh_tag_.P_rhs).Add_byte_nl();
|
||||
bfr.Add(Gfh_tag_.Div_rhs).Add_byte_nl();
|
||||
}
|
||||
bfr.Add(Gfh_tag_.Div_rhs);
|
||||
}
|
||||
}
|
@ -19,43 +19,45 @@ package gplx.xowa.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import gplx.xowa.htmls.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Tabber_xnde implements Xox_xnde {
|
||||
private static final byte[] Spr__tab_itms = Bry_.new_a7("|-|");
|
||||
private byte[] html;
|
||||
private byte[] id;
|
||||
private Tabber_tab_itm[] tab_itms_ary;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_bgn);
|
||||
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
tmp_bfr.Add_str_a7("<div id=\"tabber-\" "); // TODO: add key which is md5 of inner src
|
||||
tmp_bfr.Add_str_a7("class=\"tabber\">\n");
|
||||
|
||||
// split on "|-|"; EX: "A|-|B" -> tab_1='A'; tab_2='B'
|
||||
byte[][] tab_itms = Bry_split_.Split(src, xnde.Tag_open_end(), xnde.Tag_close_bgn(), Spr__tab_itms);
|
||||
List_adp tab_itms_list = List_adp_.new_();
|
||||
byte[] xnde_body = Xox_xnde_.Extract_body_or_null(src, xnde); if (xnde_body == null) return;
|
||||
this.id = Id_test == null ? gplx.core.security.HashAlgo_.Md5.Calc_hash_bry(xnde_body) : Id_test;
|
||||
byte[][] tab_itms = Bry_split_.Split(xnde_body, Spr__tab_itms);
|
||||
for (int i = 0; i < tab_itms.length; ++i) {
|
||||
byte[] tab_itm = tab_itms[i];
|
||||
tab_itm = Bry_.Trim(tab_itm);
|
||||
int tab_itm_len = tab_itm.length; if (tab_itm_len == 0) continue;
|
||||
|
||||
// split on "="; EX: A=B -> tab_name='A'; tab_body = 'B'
|
||||
byte[][] tab_parts = Bry_split_.Split(tab_itm, Byte_ascii.Eq);
|
||||
byte[] tab_head = tab_parts[0];
|
||||
byte[] tab_body = tab_parts.length == 1 ? Bry_.Empty : Xop_parser_.Parse_text_to_html(wiki, ctx.Page(), ctx.Page().Ttl(), tab_parts[1], false);
|
||||
|
||||
tmp_bfr.Add_str_a7("<div class=\"tabbertab\" title=\"");
|
||||
tmp_bfr.Add(Gfh_utl.Escape_html_as_bry(tab_head));
|
||||
tmp_bfr.Add_str_a7("\">\n");
|
||||
tmp_bfr.Add(Gfh_tag_.P_lhs);
|
||||
tmp_bfr.Add(tab_body);
|
||||
tmp_bfr.Add(Gfh_tag_.P_rhs).Add_byte_nl();
|
||||
tmp_bfr.Add(Gfh_tag_.Div_rhs).Add_byte_nl();
|
||||
byte[] tab_head = null, tab_body = null;
|
||||
int eq_pos = Bry_find_.Find_fwd(tab_itm, Byte_ascii.Eq);
|
||||
if (eq_pos == Bry_find_.Not_found) {
|
||||
tab_head = tab_itm;
|
||||
tab_body = Bry_.Empty;
|
||||
}
|
||||
else {
|
||||
tab_head = Bry_.Mid(tab_itm, 0, eq_pos);
|
||||
tab_body = Bry_.Mid(tab_itm, eq_pos + 1, tab_itm_len);
|
||||
tab_body = Xop_parser_.Parse_text_to_html(wiki, ctx.Page(), ctx.Page().Ttl(), tab_body, false);
|
||||
}
|
||||
tab_itms_list.Add(new Tabber_tab_itm(Bool_.N, tab_head, tab_body));
|
||||
}
|
||||
tmp_bfr.Add(Gfh_tag_.Div_rhs);
|
||||
html = tmp_bfr.To_bry_and_clear();
|
||||
tab_itms_ary = (Tabber_tab_itm[])tab_itms_list.To_ary_and_clear(Tabber_tab_itm.class);
|
||||
|
||||
ctx.Page().Html_data().Head_mgr().Itm__tabber().Enabled_y_();
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
if (html != null) bfr.Add(html);
|
||||
if (tab_itms_ary != null) Tabber_tab_itm.Write(bfr, id, tab_itms_ary);
|
||||
}
|
||||
|
||||
public static byte[] Id_test;
|
||||
private static final byte[] Spr__tab_itms = Bry_.new_a7("|-|");
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ package gplx.xowa.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xo
|
||||
import org.junit.*;
|
||||
public class Tabber_xnde_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Before public void init() {
|
||||
fxt.Reset();
|
||||
Tabber_xnde.Id_test = Bry_.new_a7("test");
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<tabber>"
|
||||
@ -28,7 +31,7 @@ public class Tabber_xnde_tst {
|
||||
, "tab2=''b''"
|
||||
, "</tabber>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"tabber-\" class=\"tabber\">"
|
||||
( "<div id=\"tabber-test\" class=\"tabber\">"
|
||||
, "<div class=\"tabbertab\" title=\"tab1\">"
|
||||
, "<p><i>a</i></p>"
|
||||
, "</div>"
|
||||
@ -38,17 +41,30 @@ public class Tabber_xnde_tst {
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Eq_missing() {
|
||||
@Test public void Eq__missing() {
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<tabber>"
|
||||
, "tab1"
|
||||
, "</tabber>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"tabber-\" class=\"tabber\">"
|
||||
( "<div id=\"tabber-test\" class=\"tabber\">"
|
||||
, "<div class=\"tabbertab\" title=\"tab1\">"
|
||||
, "<p></p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Eq__many() {
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<tabber>"
|
||||
, "tab1=A=B"
|
||||
, "</tabber>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"tabber-test\" class=\"tabber\">"
|
||||
, "<div class=\"tabbertab\" title=\"tab1\">"
|
||||
, "<p>A=B</p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -18,14 +18,136 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
|
||||
public class Tabview_xnde implements Xox_xnde {
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {}
|
||||
public class Tabview_xnde implements Xox_xnde, Mwh_atr_itm_owner2 {
|
||||
private byte[] id;
|
||||
private Tabber_tab_itm[] tab_itms_ary;
|
||||
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, byte xatr_id) {
|
||||
switch (xatr_id) {
|
||||
case Xatr__id: id = xatr.Val_as_bry(); break;
|
||||
}
|
||||
}
|
||||
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_bgn);
|
||||
ctx.Page().Html_data().Head_mgr().Itm__graph().Enabled_y_();
|
||||
Xox_xnde_.Parse_xatrs(wiki, this, xatrs_hash, src, xnde);
|
||||
|
||||
// get id
|
||||
id = Keep_alphanum(id);
|
||||
if (Bry_.Len_eq_0(id)) id = Int_.To_bry(global_id++);
|
||||
|
||||
// parse src
|
||||
byte[] tabs_src = Bry_.Mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
tabs_src = Bry_.Trim(tabs_src); // if(isset($tabs[0]) && $tabs[0] == "") {unset($tabs[0]);} if($tabs[count($tabs)] == "") {unset($tabs[count($tabs)]);}
|
||||
byte[][] tabs_ary = Bry_split_.Split_lines(tabs_src);
|
||||
List_adp tabs_list = List_adp_.new_();
|
||||
int tabs_len = tabs_ary.length;
|
||||
for (int i = 0; i < tabs_len; ++i) {
|
||||
Tabview_tab_itm itm = Tabview_tab_itm.Parse(wiki, ctx, tabs_ary[i]);
|
||||
if (itm != null)
|
||||
tabs_list.Add(itm);
|
||||
}
|
||||
ctx.Page().Html_data().Head_mgr().Itm__tabber().Enabled_y_();
|
||||
Tabview_tab_itm[] ary = (Tabview_tab_itm[])tabs_list.To_ary_and_clear(Tabview_tab_itm.class);
|
||||
tab_itms_ary = Tabview_tab_itm.To_tabber_ary(ary);
|
||||
|
||||
ctx.Page().Html_data().Head_mgr().Itm__tabber().Enabled_y_();
|
||||
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
|
||||
}
|
||||
public void Xtn_write(Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xop_xnde_tkn xnde, byte[] src) {
|
||||
bfr.Add_mid(src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
if (tab_itms_ary != null) Tabber_tab_itm.Write(bfr, id, tab_itms_ary);
|
||||
// write html
|
||||
//Bry_bfr bfr = Bry_bfr.new_();
|
||||
//bfr.Add_str_a7("<div id=\"flytabs_");
|
||||
//bfr.Add(id);
|
||||
//bfr.Add_str_a7("\">\n<ul>\n");
|
||||
//int ary_len = ary.length;
|
||||
//for (int i = 0; i < ary_len; ++i) {
|
||||
// Tabview_tab_itm itm = ary[i];
|
||||
// bfr.Add_str_a7("<li><a href=");
|
||||
// // href
|
||||
// bfr.Add_str_a7("><span>");
|
||||
// bfr.Add(itm.Tab_name);
|
||||
// bfr.Add_str_a7("</span></a></li>");
|
||||
//}
|
||||
//bfr.Add_str_a7("</ul>\n</div>\n");
|
||||
}
|
||||
|
||||
private int global_id = 0;
|
||||
public static final byte Xatr__id = 0;
|
||||
private static final Hash_adp_bry xatrs_hash = Hash_adp_bry.ci_a7().Add_str_byte("id", Xatr__id);
|
||||
private static byte[] Keep_alphanum(byte[] src) {
|
||||
if (src == null) return null;
|
||||
int src_len = src.length; if (src_len == 0) return src;
|
||||
Bry_bfr bfr = null;
|
||||
for (int i = 0; i < src_len; ++i) {
|
||||
byte b = src[i];
|
||||
if ( Byte_ascii.Is_ltr(b)
|
||||
|| Byte_ascii.Is_num(b)) {
|
||||
if (bfr != null) bfr.Add_byte(b);
|
||||
}
|
||||
else { // not alphanum;
|
||||
if (bfr == null) { // 1st occurrence; create bfr and add initial to it
|
||||
bfr = Bry_bfr.new_();
|
||||
bfr.Add_mid(src, 0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bfr == null ? src : bfr.To_bry_and_clear();
|
||||
}
|
||||
}
|
||||
class Tabview_tab_itm {
|
||||
public Tabview_tab_itm(boolean active, boolean cache, byte[] tab_name, byte[] page_ttl_bry, byte[] page_body) {
|
||||
this.Active = active;
|
||||
this.Cache = cache;
|
||||
this.Tab_name = tab_name;
|
||||
this.Page_ttl_bry = page_ttl_bry;
|
||||
this.Page_body = page_body;
|
||||
}
|
||||
public final boolean Active;
|
||||
public final boolean Cache;
|
||||
public final byte[] Tab_name;
|
||||
public final byte[] Page_ttl_bry;
|
||||
public final byte[] Page_body;
|
||||
|
||||
public static Tabview_tab_itm Parse(Xowe_wiki wiki, Xop_ctx ctx, byte[] src) {
|
||||
byte[][] args_ary = Bry_split_.Split(src, Byte_ascii.Pipe);
|
||||
int args_len = args_ary.length;
|
||||
|
||||
boolean cache = false, active = false;
|
||||
byte[] tab_name = null, page_ttl_bry = null, page_body = null;
|
||||
for (int i = 0; i < args_len; ++i) {
|
||||
byte[] args_itm = args_ary[i];
|
||||
switch (i) {
|
||||
case 0:
|
||||
page_ttl_bry = args_itm;
|
||||
if (Bry_.Has_at_bgn(page_ttl_bry, Byte_ascii.Angle_bgn) || Bry_.Has_at_end(page_ttl_bry, Byte_ascii.Angle_end)) return null;
|
||||
Xoa_ttl page_ttl = wiki.Ttl_parse(page_ttl_bry);
|
||||
if (page_ttl == null) return null;
|
||||
gplx.xowa.wikis.caches.Xow_page_cache_itm page_itm = wiki.Cache_mgr().Page_cache().Get_or_load_as_itm(page_ttl);
|
||||
if (page_itm == null) return null;
|
||||
page_body = page_itm.Wtxt__redirect_or_direct();
|
||||
page_body = Xop_parser_.Parse_text_to_html(wiki, ctx.Page(), ctx.Page().Ttl(), page_body, false);
|
||||
break;
|
||||
case 1:
|
||||
tab_name = args_itm;
|
||||
if (Bry_.Has_at_bgn(tab_name, Byte_ascii.Angle_bgn) || Bry_.Has_at_end(tab_name, Byte_ascii.Angle_end)) return null;
|
||||
break;
|
||||
case 2:
|
||||
cache = Bry_.To_bool_or(args_itm, false);
|
||||
break;
|
||||
case 3:
|
||||
active = Bry_.To_bool_or(args_itm, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Tabview_tab_itm(active, cache, tab_name, page_ttl_bry, page_body);
|
||||
}
|
||||
public static Tabber_tab_itm[] To_tabber_ary(Tabview_tab_itm[] ary) {
|
||||
int len = ary.length;
|
||||
Tabber_tab_itm[] rv = new Tabber_tab_itm[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Tabview_tab_itm src = ary[i];
|
||||
rv[i] = new Tabber_tab_itm(src.Active, src.Tab_name, src.Page_body);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
42
400_xowa/src/gplx/xowa/xtns/wikias/Tabview_xnde_tst.java
Normal file
42
400_xowa/src/gplx/xowa/xtns/wikias/Tabview_xnde_tst.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
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.xtns.wikias; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import org.junit.*;
|
||||
public class Tabview_xnde_tst {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
@Before public void init() {fxt.Reset();}
|
||||
@Test public void Basic() {
|
||||
fxt.Init_page_create("A", "''a''");
|
||||
fxt.Init_page_create("B", "''b''");
|
||||
fxt.Test__parse__tmpl_to_html(String_.Concat_lines_nl_skip_last
|
||||
( "<tabview id='test'>"
|
||||
, "A|tab1"
|
||||
, "B|tab2||true"
|
||||
, "</tabview>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"tabber-test\" class=\"tabber\">"
|
||||
, "<div class=\"tabbertab\" title=\"tab1\">"
|
||||
, "<p><i>a</i></p>"
|
||||
, "</div>"
|
||||
, "<div class=\"tabbertab\" title=\"tab2\" data-active=\"true\">"
|
||||
, "<p><i>b</i></p>"
|
||||
, "</div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
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.xtns.xowa_cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.langs.htmls.*;
|
||||
class Xo_custom_html_pos_ {
|
||||
public static final byte Tid__head_end = 1, Tid__tail = 2;
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.ci_a7()
|
||||
.Add_str_byte("head_end", Tid__head_end)
|
||||
.Add_str_byte("tail", Tid__tail)
|
||||
;
|
||||
public static byte To_tid(byte[] bry) {
|
||||
byte tid = hash.Get_as_byte_or(bry, Byte_.Max_value_127);
|
||||
if (tid == Byte_.Max_value_127) throw Err_.new_wo_type("unknown pos", "pos", bry);
|
||||
return tid;
|
||||
}
|
||||
}
|
||||
class Xo_custom_html_type_ {
|
||||
public static final byte Tid__css_code = 1, Tid__js_code = 2;
|
||||
private static final Hash_adp_bry hash = Hash_adp_bry.ci_a7()
|
||||
.Add_bry_byte(Gfh_tag_.Bry__style , Tid__css_code)
|
||||
.Add_bry_byte(Gfh_tag_.Bry__script , Tid__js_code)
|
||||
;
|
||||
public static byte[] To_bry(byte tid) {
|
||||
switch (tid) {
|
||||
case Tid__css_code: return Gfh_tag_.Bry__style;
|
||||
case Tid__js_code : return Gfh_tag_.Bry__script;
|
||||
default: throw Err_.new_unhandled_default(tid);
|
||||
}
|
||||
}
|
||||
public static byte To_tid(byte[] bry) {
|
||||
byte tid = hash.Get_as_byte_or(bry, Byte_.Max_value_127); if (tid == Byte_.Max_value_127) throw Err_.new_wo_type("unknown type", "type", bry);
|
||||
return tid;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user