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

'v3.6.3.1'

This commit is contained in:
gnosygnu
2016-06-19 23:58:10 -04:00
parent 96636f3161
commit d4e8590345
1960 changed files with 20790 additions and 9272 deletions

View File

@@ -19,7 +19,7 @@ package gplx.xowa.xtns; import gplx.*; import gplx.xowa.*;
import gplx.core.primitives.*; import gplx.core.btries.*;
import gplx.xowa.xtns.cites.*; import gplx.xowa.xtns.imaps.*; import gplx.xowa.xtns.relatedSites.*; import gplx.xowa.xtns.proofreadPage.*; import gplx.xowa.xtns.wdatas.*;
import gplx.xowa.xtns.insiders.*; import gplx.xowa.xtns.indicators.*; import gplx.xowa.xtns.pagebanners.*;
public class Xow_xtn_mgr implements GfoInvkAble {
public class Xow_xtn_mgr implements Gfo_invk {
private Ordered_hash regy = Ordered_hash_.New_bry();
public int Count() {return regy.Count();}
public Cite_xtn_mgr Xtn_cite() {return xtn_cite;} private Cite_xtn_mgr xtn_cite;
@@ -56,7 +56,7 @@ public class Xow_xtn_mgr implements GfoInvkAble {
int regy_len = app_xtn_mgr.Count();
for (int i = 0; i < regy_len; i++) {
Xox_mgr proto = (Xox_mgr)app_xtn_mgr.Get_at(i);
Xox_mgr mgr = proto.Clone_new();
Xox_mgr mgr = proto.Xtn_clone_new();
mgr.Xtn_ctor_by_wiki(wiki);
regy.Add(mgr.Xtn_key(), mgr);
Set_members(mgr);
@@ -101,7 +101,7 @@ public class Xow_xtn_mgr implements GfoInvkAble {
}
}
private static final byte Tid_cite = 0, Tid_sites = 1, Tid_insider = 2, Tid_imap = 3, Tid_proofread = 4, Tid_wikibase = 5, Tid_indicator = 6, Tid_pgbnr = 7;
private static final Btrie_slim_mgr xtn_tid_trie = Btrie_slim_mgr.cs()
private static final Btrie_slim_mgr xtn_tid_trie = Btrie_slim_mgr.cs()
.Add_bry_byte(Cite_xtn_mgr.XTN_KEY , Tid_cite)
.Add_bry_byte(Sites_xtn_mgr.XTN_KEY , Tid_sites)
.Add_bry_byte(Insider_xtn_mgr.XTN_KEY , Tid_insider)
@@ -113,6 +113,6 @@ public class Xow_xtn_mgr implements GfoInvkAble {
;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_get)) return Get_or_fail(m.ReadBry("v"));
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
} private static final String Invk_get = "get";
}

View File

@@ -16,11 +16,11 @@ 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; import gplx.*; import gplx.xowa.*;
public interface Xox_mgr extends GfoInvkAble {
byte[] Xtn_key();
void Xtn_ctor_by_app(Xoae_app app);
void Xtn_ctor_by_wiki(Xowe_wiki wiki);
void Xtn_init_by_app(Xoae_app app);
void Xtn_init_by_wiki(Xowe_wiki wiki);
Xox_mgr Clone_new();
public interface Xox_mgr extends Gfo_invk {
byte[] Xtn_key();
void Xtn_ctor_by_app(Xoae_app app);
void Xtn_ctor_by_wiki(Xowe_wiki wiki);
void Xtn_init_by_app(Xoae_app app);
void Xtn_init_by_wiki(Xowe_wiki wiki);
Xox_mgr Xtn_clone_new();
}

View File

@@ -22,24 +22,26 @@ public abstract class Xox_mgr_base implements Xox_mgr {
public Xox_mgr_base() {
this.enabled = Enabled_default();
}
public abstract byte[] Xtn_key();
public abstract Xox_mgr Clone_new();
public boolean Enabled() {return enabled;} private boolean enabled;
@gplx.Virtual public boolean Enabled_default() {return true;}
public void Enabled_y_() {enabled = true; enabled_manually = true;} public void Enabled_n_() {enabled = false; enabled_manually = true;} // TEST:
public void Enabled_(boolean v) {enabled = v;}
public boolean Enabled_manually() {return enabled_manually;} private boolean enabled_manually;
@gplx.Virtual public void Xtn_ctor_by_app(Xoae_app app) {}
@gplx.Virtual public void Xtn_ctor_by_wiki(Xowe_wiki wiki) {}
@gplx.Virtual public void Xtn_init_by_app(Xoae_app app) {}
@gplx.Virtual public void Xtn_init_by_wiki(Xowe_wiki wiki) {}
public abstract byte[] Xtn_key();
public boolean Enabled() {return enabled;} private boolean enabled;
@gplx.Virtual public boolean Enabled_default() {return true;}
public void Enabled_y_() {enabled = true; enabled_manually = true;} public void Enabled_n_() {enabled = false; enabled_manually = true;} // TEST:
public void Enabled_(boolean v) {enabled = v;}
public boolean Enabled_manually() {return enabled_manually;} private boolean enabled_manually;
public abstract Xox_mgr Xtn_clone_new();
@gplx.Virtual public void Xtn_ctor_by_app(Xoae_app app) {}
@gplx.Virtual public void Xtn_ctor_by_wiki(Xowe_wiki wiki) {}
@gplx.Virtual public void Xtn_init_by_app(Xoae_app app) {}
@gplx.Virtual public void Xtn_init_by_wiki(Xowe_wiki wiki) {}
@gplx.Virtual public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_enabled)) return Yn.To_str(enabled);
else if (ctx.Match(k, Invk_enabled_)) {enabled = m.ReadYn("v"); enabled_manually = true;}
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
return this;
}
private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_";
public static void Xtn_write_escape(Xoae_app app, Bry_bfr bfr, byte[] src, Xop_xnde_tkn xnde) {Xtn_write_escape(app, bfr, src, xnde.Src_bgn(), xnde.Src_end());}
public static void Xtn_write_escape(Xoae_app app, Bry_bfr bfr, byte[] src) {Xtn_write_escape(app, bfr, src, 0, src.length);}
public static void Xtn_write_escape(Xoae_app app, Bry_bfr bfr, byte[] src, int bgn, int end) {Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), bfr, src, bgn, end, true, false);}
@@ -65,6 +67,6 @@ public abstract class Xox_mgr_base implements Xox_mgr {
Io_url url = app.Fsys_mgr().Bin_xtns_dir().GenSubFil_nest(String_.new_u8(xtn_key), "i18n", wiki.Lang().Key_str() + ".json");
Xob_i18n_parser.Load_msgs(false, wiki.Lang(), url);
}
private static final byte[] Xowa_not_implemented = Bry_.new_a7("XOWA does not support this extension: ");
private static final byte[] Xowa_not_implemented = Bry_.new_a7("XOWA does not support this extension: ");
public static final byte Parse_content_tid_none = 0, Parse_content_tid_escape = 1, Parse_content_tid_html = 2;
}

View File

@@ -17,15 +17,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.cites; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
public class Cite_xtn_mgr extends Xox_mgr_base {
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("cite");
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("cite");
// public byte[] Group_default_name() {return group_default_name;} private byte[] group_default_name = Bry_.new_a7("lower-alpha");
public static byte[] Group_default_name() {return group_default_name;} private static byte[] group_default_name = Bry_.new_a7("lower-alpha");
@Override public Xox_mgr Clone_new() {return new Cite_xtn_mgr();}
@Override public Xox_mgr Xtn_clone_new() {return new Cite_xtn_mgr();}
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_group_default_name)) return String_.new_u8(group_default_name);
else if (ctx.Match(k, Invk_group_default_name_)) group_default_name = m.ReadBry("v");
else return super.Invk(ctx, ikey, k, m);
return this;
}
private static final String Invk_group_default_name = "group_default_name", Invk_group_default_name_ = "group_default_name_";
private static final String Invk_group_default_name = "group_default_name", Invk_group_default_name_ = "group_default_name_";
}

View File

@@ -74,7 +74,7 @@ public class Ref_html_wtr {
int itms_len = lst.Itms_len();
for (int j = 0; j < itms_len; j++) { // iterate over itms in grp
Ref_nde head_itm = lst.Itms_get_at(j);
Bry_bfr tmp = Bry_bfr.new_();
Bry_bfr tmp = Bry_bfr_.New();
int list_len = List_len(head_itm);
grp_list_fmtr.Init(ctx.Wiki(), cfg, head_itm);
Ref_nde text_itm = grp_list_fmtr.IdentifyTxt(); // find the item that has the text (there should only be 0 or 1)
@@ -121,7 +121,7 @@ class Xoh_ref_list_fmtr implements gplx.core.brys.Bfr_arg {
Ref_nde rel = itm.Related_get(i);
if (HasTxt(rel)) return rel;
}
return itm; // no itm has text; TODO:WARN
return itm; // no itm has text; TODO_OLD:WARN
}
private boolean HasTxt(Ref_nde v) {return v.Body() != null && v.Body().Root_src().length > 0;}
public void Bfr_arg__add(Bry_bfr bfr) {

View File

@@ -40,8 +40,8 @@ public class Ref_html_wtr_cfg {
backlabels = v;
backlabels_len = v.length;
}
public static final byte[] Msg_backlabels_err = Bry_.new_a7("cite_error_no_link_label_group");
private static final byte[] Msg_backlabels = Bry_.new_a7("cite_references_link_many_format_backlink_labels");
public static final byte[] Msg_backlabels_err = Bry_.new_a7("cite_error_no_link_label_group");
private static final byte[] Msg_backlabels = Bry_.new_a7("cite_references_link_many_format_backlink_labels");
public static Ref_html_wtr_cfg new_() {
Ref_html_wtr_cfg rv = new Ref_html_wtr_cfg();
rv.Itm_html_ ("<sup id=\"cite_ref-~{itm_id}\" class=\"reference\"><a href=\"#cite_note-~{grp_id}\">[~{grp_key}]</a></sup>");
@@ -59,7 +59,7 @@ public class Ref_html_wtr_cfg {
rv.Backlabels_ (Ref_backlabels_default);
return rv;
} Ref_html_wtr_cfg() {}
private static final byte[][] Ref_backlabels_default = Ref_backlabels_xby_str_ary(String_.Ary // TEST:default backlabels for test only; actual backlabels will be overrriden by MediaWiki:Cite_references_link_many_format_backlink_labels; DATE:2014-06-07
private static final byte[][] Ref_backlabels_default = Ref_backlabels_xby_str_ary(String_.Ary // TEST:default backlabels for test only; actual backlabels will be overrriden by MediaWiki:Cite_references_link_many_format_backlink_labels; DATE:2014-06-07
( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
, "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", "al", "am", "an", "ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax", "ay", "az"
, "ba", "bb", "bc", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", "bt", "bu", "bv", "bw", "bx", "by", "bz"
@@ -97,7 +97,7 @@ public class Ref_html_wtr_cfg {
}
public static byte[][] Ref_backlabels_xby_bry(byte[] raw) {
if (raw == null) return Ref_backlabels_default;
List_adp list = List_adp_.new_();
List_adp list = List_adp_.New();
int len = raw.length, pos = 0, bgn = -1;
while (true) {
boolean last = pos == len;

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.cites; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
public class Ref_itm_grp {
private List_adp lsts = List_adp_.new_();
private List_adp lsts = List_adp_.New();
public Ref_itm_grp(byte[] grp_name) {this.grp_name = grp_name;}
public byte[] Grp_name() {return grp_name;} private byte[] grp_name;
public int Grp_seal() {

View File

@@ -59,5 +59,5 @@ public class Ref_itm_lst {
list.Clear();
idx_major_last = 0;
}
Hash_adp hash = Hash_adp_bry.cs(); List_adp list = List_adp_.new_();
Hash_adp hash = Hash_adp_bry.cs(); List_adp list = List_adp_.New();
}

View File

@@ -52,7 +52,7 @@ class Ref_itm_mgr_fxt {
actl[i] = lst.Itms_get_at(i);
tst_mgr.Tst_ary("", chkr_ary, actl);
return this;
} List_adp actl_list = List_adp_.new_();
} List_adp actl_list = List_adp_.New();
}
class Xtn_ref_nde_chkr implements Tst_chkr {
public Class<?> TypeOf() {return Ref_nde.class;}

View File

@@ -18,9 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.cldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.dbs.*;
class Cldr_lang_tbl implements Rls_able {
private final String tbl_name = "cldr_lang"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
private final String fld_cldr_code, fld_lang_code, fld_lang_name;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
private final String tbl_name = "cldr_lang"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld_cldr_code, fld_lang_code, fld_lang_name;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert;
public Cldr_lang_tbl(Db_conn conn) {
this.conn = conn;
this.fld_cldr_code = flds.Add_str("cldr_code", 32);

View File

@@ -103,8 +103,8 @@ class Dpl_itm {
sub_root.Clear();
val = wiki.Parser_mgr().Main().Parse_text_to_wtxt(sub_root, sub_ctx, sub_tkn_mkr, val);
switch (key_id) {
case Dpl_itm_keys.Key_category: if (ctg_includes == null) ctg_includes = List_adp_.new_(); ctg_includes.Add(Xoa_ttl.Replace_spaces(val)); break;
case Dpl_itm_keys.Key_notcategory: if (ctg_excludes == null) ctg_excludes = List_adp_.new_(); ctg_excludes.Add(Xoa_ttl.Replace_spaces(val)); break;
case Dpl_itm_keys.Key_category: if (ctg_includes == null) ctg_includes = List_adp_.New(); ctg_includes.Add(Xoa_ttl.Replace_spaces(val)); break;
case Dpl_itm_keys.Key_notcategory: if (ctg_excludes == null) ctg_excludes = List_adp_.New(); ctg_excludes.Add(Xoa_ttl.Replace_spaces(val)); break;
case Dpl_itm_keys.Key_ns: {Xow_ns ns = (Xow_ns)wiki.Ns_mgr().Names_get_or_null(val, 0, val.length); ns_filter = ns == null ? Xow_ns_.Tid__main : ns.Id(); break;}
case Dpl_itm_keys.Key_order: sort_ascending = Dpl_sort.Parse_as_bool_byte(val); break;
case Dpl_itm_keys.Key_suppresserrors: suppress_errors = Dpl_itm_keys.Parse_as_bool(val, false); break;

View File

@@ -21,7 +21,7 @@ import gplx.langs.htmls.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.
import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.amps.*;
public class Dpl_xnde implements Xox_xnde {
private Dpl_itm itm = new Dpl_itm(); private List_adp pages = List_adp_.new_();
private Dpl_itm itm = new Dpl_itm(); private List_adp pages = List_adp_.New();
public void Xatr__set(Xowe_wiki wiki, byte[] src, Mwh_atr_itm xatr, Object xatr_id_obj) {} // NOTE: <dynamicPageList> has no attributes
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
itm.Parse(wiki, ctx, ctx.Page().Ttl().Full_txt_w_ttl_case(), src, xnde);
@@ -65,7 +65,7 @@ public class Dpl_xnde implements Xox_xnde {
bfr.Add_byte(Byte_ascii.Gt);
Xoh_html_wtr_escaper.Escape(amp_mgr, bfr, ttl_page_txt, 0, ttl_page_txt.length, false, false);
bfr.Add(Gfh_bldr_.Bry__a_rhs).Add(html_mode.Itm_end()).Add_byte_nl();
// TODO: lnki_wtr.Clear().Href_wiki_(ttl).Title_(ttl).Nofollow_().Write_head(bfr).Write_text(bfr).Write_tail(bfr)
// TODO_OLD: lnki_wtr.Clear().Href_wiki_(ttl).Title_(ttl).Nofollow_().Write_head(bfr).Write_text(bfr).Write_tail(bfr)
break;
default:
break;
@@ -84,8 +84,8 @@ class Dpl_page_finder {
Ordered_hash old_regy = Ordered_hash_.New(), new_regy = Ordered_hash_.New(), cur_regy = Ordered_hash_.New();
Xodb_load_mgr load_mgr = wiki.Db_mgr().Load_mgr();
Xowd_page_itm tmp_page = new Xowd_page_itm();
Int_obj_ref tmp_id = Int_obj_ref.zero_();
List_adp del_list = List_adp_.new_();
Int_obj_ref tmp_id = Int_obj_ref.New_zero();
List_adp del_list = List_adp_.New();
int ns_filter = itm.Ns_filter();
Ordered_hash exclude_pages = Ordered_hash_.New();
Find_excludes(exclude_pages, load_mgr, tmp_page, tmp_id, itm.Ctg_excludes());
@@ -126,7 +126,7 @@ class Dpl_page_finder {
Xoctg_view_itm ctg_itm = ctg_mgr.Itms()[i];
int ctg_itm_id = ctg_itm.Page_id();
if (list.Has(tmp_id.Val_(ctg_itm_id))) continue;
list.Add(Int_obj_ref.new_(ctg_itm_id), ctg_itm);
list.Add(Int_obj_ref.New(ctg_itm_id), ctg_itm);
// if (ctg_tid == Xoa_ctg_mgr.Tid_subc) { // recurse subcategories
// load_mgr.Load_by_id(tmp_page, ctg_itm_id);
// Find_pages_in_ctg(list, load_mgr, tmp_page, tmp_id, tmp_page.Ttl_wo_ns());
@@ -158,7 +158,7 @@ class Dpl_page_finder {
if (i != 0) { // skip logic for first ctg (which doesn't have a predecessor)
if (!old_regy.Has(tmp_id)) continue; // cur_itm not in old_regy; ignore
}
new_regy.Add_as_key_and_val(Int_obj_ref.new_(cur_itm.Page_id()));
new_regy.Add_as_key_and_val(Int_obj_ref.New(cur_itm.Page_id()));
}
}
}

View File

@@ -272,7 +272,7 @@ class Dpl_xnde_fxt {
int id = page.Id();
String ttl = page.Ttl();
Xoa_ttl page_ttl = Xoa_ttl.parse(fxt.Wiki(), Bry_.new_u8(ttl));
Xoae_page page_obj = fxt.Wiki().Data_mgr().Get_page(page_ttl, false);
Xoae_page page_obj = fxt.Wiki().Data_mgr().Load_page_by_ttl(page_ttl);
if (page_obj.Missing()) {
fxt.Init_page_create(ttl);
fxt.Init_id_create (id, 0, 0, false, 5, Xow_ns_.Tid__main, ttl);

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.flaggedRevs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.xtns.scribunto.*; import gplx.xowa.xtns.flaggedRevs.scribunto.*;
public class Flagged_revs_xtn_mgr extends Xox_mgr_base {
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("FlaggedRevs");
@Override public Xox_mgr Clone_new() {return new Flagged_revs_xtn_mgr();}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("FlaggedRevs");
@Override public Xox_mgr Xtn_clone_new() {return new Flagged_revs_xtn_mgr();}
@Override public void Xtn_init_by_app(Xoae_app app) {
Scrib_xtn_mgr scrib_xtn = (Scrib_xtn_mgr)app.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
scrib_xtn.Lib_mgr().Add(new Flagged_revs_lib());

View File

@@ -45,7 +45,7 @@ public class Gallery_itm implements Js_img_wkr {
this.xnde = xnde; this.xfer_itm = xfer_itm;
this.wiki = wiki; this.ctx = ctx; this.src = src; this.gallery_li_id_bry = gallery_li_id_bry; this.gallery_itm_idx = gallery_itm_idx;
}
public void Html_update(Xoa_page page, Xog_js_wkr js_wkr, int html_uid, int html_w, int html_h, Io_url html_view_url, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl) {
public void Js_wkr__update_hdoc(Xoa_page page, Xog_js_wkr js_wkr, int html_uid, int html_w, int html_h, Io_url html_view_url, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl) {
Gallery_mgr_base gallery_mgr = xnde.Gallery_mgr();
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_k004(), tmp_bfr = wiki.Utl__bfr_mkr().Get_k004();
try {

View File

@@ -28,7 +28,7 @@ public class Gallery_itm_parser {
private int cur_pos; private byte cur_byte;
private byte cur_fld;
private int itm_bgn;
private Bry_bfr caption_bfr = Bry_bfr.reset_(255); private int caption_bgn;
private Bry_bfr caption_bfr = Bry_bfr_.Reset(255); private int caption_bgn;
private Xop_ctx ctx;
public Gallery_itm_parser Init_by_wiki(Xowe_wiki wiki) {
this.wiki = wiki; Xol_lang_itm lang = wiki.Lang();

View File

@@ -85,7 +85,7 @@ class Gallery_itm_parser_fxt {
parser.Init_by_wiki(wiki);
}
public void Test_parse(String raw, String[]... expd) {
List_adp actl = List_adp_.new_();
List_adp actl = List_adp_.New();
byte[] src = Bry_.new_a7(raw);
parser.Parse_all(actl, Gallery_mgr_base_.New_by_mode(Gallery_mgr_base_.Traditional_tid), new Gallery_xnde(), src, 0, src.length);
Tfds.Eq_ary(String_.Ary_flatten(expd), String_.Ary_flatten(Xto_str_ary(src, actl)));

View File

@@ -33,6 +33,7 @@ public abstract class Gallery_mgr_base {
@gplx.Virtual public int Get_gb_borders() {return 8;} // REF.MW: getGBBorders; Get how much extra space the borders around the image takes up. For this mode, it is 2px borders on each side + 2px implied padding on each side from the stylesheet, giving us 2*2+2*2 = 8.
@gplx.Virtual public int Get_all_padding() {return this.Get_thumb_padding() + this.Get_gb_padding() + this.Get_gb_borders();} // REF.MW: getAllPadding; How many pixels of whitespace surround the thumbnail.
@gplx.Virtual public int Get_vpad(int itm_h, int thm_h) { // REF.MW: getVPad; Get vertical padding for a thumbnail; Generally this is the total height minus how high the thumb is.
if (thm_h == -1) thm_h = itm_h; // NOTE: thm_h will be -1 on 1st pass; set to dflt_h, else will end up with 115px for hdump; PAGE:en.w:National_Gallery_of_Art DATE:2016-06-19
return (this.Get_thumb_padding() + itm_h - thm_h) / 2;
}
@gplx.Virtual public int Get_thumb_div_width(int thm_w) { // REF.MW: getThumbDivWidth; Get the width of the inner div that contains the thumbnail in question. This is the div with the class of "thumb".
@@ -157,7 +158,7 @@ public abstract class Gallery_mgr_base {
if (hctx_is_hdump)
page.Hdump_data().Imgs_add_img(new Xohd_img_itm__gallery_itm().Data_init_gallery(itm_div_width, img_div_w, vpad), xfer_itm, Xohd_img_itm__gallery_itm.Tid_gallery);
}
private static final byte[]
private static final byte[]
Wrap_gallery_text_bgn = Bry_.new_a7("\n <div class=\"gallerytext\">") // NOTE: The newline after <div class="gallerytext"> is needed to accommodate htmltidy
, Wrap_gallery_text_end = Bry_.new_a7("\n </div>") // NOTE: prepend "\n"; will cause extra \n when caption exists, but needed when caption doesn't exists; EX: "<div class='caption'> </div>"; \n puts
;
@@ -166,7 +167,7 @@ public abstract class Gallery_mgr_base {
lnki.H_(itm_default_h);
}
@gplx.Virtual public void Adjust_image_parameters(Xof_file_itm xfer_itm) {} // REF.MW: Adjust the image parameters for a thumbnail. Used by a subclass to insert extra high resolution images.
private static final byte[]
private static final byte[]
itm_li_end_bry = Bry_.new_a7 ( "\n </div>"
+ "\n </li>")
, box_html_end_bry = Bry_.new_a7 ( "\n</ul>")

View File

@@ -72,6 +72,7 @@ public class Gallery_mgr_base_basic_tst {
@Test public void Height_fix() {
fxt.Fxt().Wiki().File_mgr().Cfg_set(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults, "y");
fxt.Test_html_frag("<gallery heights=250>File:A.png|a<br/>c</gallery>", " width=\"120\" height=\"250\"");
fxt.Test_html_frag("<div style=\"margin:15px auto;\">");
fxt.Fxt().Wiki().File_mgr().Cfg_set(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults, "n");
}
@Test public void Alt() {
@@ -154,7 +155,7 @@ public class Gallery_mgr_base_basic_tst {
@Test public void Alt__quotes() { // PURPOSE: file name with quotes will cause broken alt; PAGE:en.w:en.w:Alexandria,_Romania; DATE:2015-12-27
fxt.Test_html_frag("<gallery>File:A\"b.png", "alt=\"A&quot;b.png\""); // NOTE: not 'alt="A"b.png"'
}
// @Test public void Ttl_caption() { // TODO: category entries get rendered with name only (no ns)
// @Test public void Ttl_caption() { // TODO_OLD: category entries get rendered with name only (no ns)
// fxt.Test_html_frag
// ( "<gallery>Category:A</gallery>"
// , "<li class='gallerycaption'>B</li>"
@@ -167,18 +168,23 @@ public class Gallery_mgr_base_basic_tst {
, "</ul>"
));
}
@Test public void Hdump__div_1_w() {// PURPOSE: handle hdump and div_1_width == 115 instead of 15; PAGE:en.w:National_Gallery_of_Art; DATE:2016-06-19
fxt.Fxt().Hctx_(gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx.Hdump);
fxt.Fxt().Wiki().File__fsdb_mode().Tid_v2_bld_y_(); // NOTE: must set to v2 mode; dflt will call old v1 img code which "guesses" at html_h;
fxt.Test_html_frag("<gallery widths=200px heights=200px perrow=5>File:A.png|a</gallery>", "<div style=\"margin:15px auto;\">");
}
}
class Gallery_mgr_base_fxt {
public void Reset() {
fxt.Wiki().Xtn_mgr().Init_by_wiki(fxt.Wiki());
Gallery_mgr_base.File_found_mode = Bool_.Y_byte;
}
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
public void Init_files_missing_y_() {
Gallery_mgr_base.File_found_mode = Bool_.N_byte;
}
public void Test_html_str(String raw, String expd) {fxt.Test_html_full_str(raw, expd);}
public void Test_html_frag(String raw, String... expd_frags) {fxt.Test_html_full_frag(raw, expd_frags);} // TODO: change to wiki_str; currently uids do not get reset if wiki
public void Test_html_frag(String raw, String... expd_frags) {fxt.Test_html_full_frag(raw, expd_frags);} // TODO_OLD: change to wiki_str; currently uids do not get reset if wiki
public void Test_html_frag_n(String raw, String... expd_frags) {fxt.Test_html_full_frag_n(raw, expd_frags);}
public void Test_html_modules_js(String expd) {
fxt.Page().Html_data().Head_mgr().Itm__globals().Enabled_n_();

View File

@@ -57,7 +57,7 @@ public class Gallery_mgr_base_xnde_atrs_tst {
, "<ul id=\"xowa_gallery_ul_0\" class=\"gallery mw-gallery-traditional\">"
);
}
// @Test public void Ttl_caption() { // TODO: PURPOSE: category entries get rendered with name only (no ns)
// @Test public void Ttl_caption() { // TODO_OLD: PURPOSE: category entries get rendered with name only (no ns)
// fxt.Test_html_frag
// ( "<gallery>Category:A</gallery>"
// , "<li class='gallerycaption'>B</li>"

View File

@@ -34,7 +34,7 @@ public class Gallery_xnde implements Xox_xnde, Mwh_atr_itm_owner1 {
public List_adp Atrs_other() {return atrs_other;} private List_adp atrs_other;
public int Itm_w_or_default() {return itm_w == Null ? Default : itm_w;}
public int Itm_h_or_default() {return itm_h == Null ? Default : itm_h;}
public int Itms_len() {return itms.Count();} private List_adp itms = List_adp_.new_();
public int Itms_len() {return itms.Count();} private List_adp itms = List_adp_.New();
public Gallery_itm Itms_get_at(int i) {return (Gallery_itm)itms.Get_at(i);}
public Gallery_mgr_base Gallery_mgr() {return gallery_mgr;} private Gallery_mgr_base gallery_mgr;
private boolean html_wtr_v1 = false;
@@ -53,7 +53,7 @@ public class Gallery_xnde implements Xox_xnde, Mwh_atr_itm_owner1 {
}
}
else {
if (atrs_other == null) atrs_other = List_adp_.new_();
if (atrs_other == null) atrs_other = List_adp_.New();
atrs_other.Add(xatr);
}
}

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.gallery; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.htmls.modules.*;
public class Gallery_xtn_mgr extends Xox_mgr_base {
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("gallery");
@Override public Xox_mgr Clone_new() {return new Gallery_xtn_mgr();}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("gallery");
@Override public Xox_mgr Xtn_clone_new() {return new Gallery_xtn_mgr();}
public Gallery_itm_parser Parser() {return parser;} private Gallery_itm_parser parser;
public Gallery_html_wtr Html_wtr() {return html_wtr;} private Gallery_html_wtr html_wtr;
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {

View File

@@ -16,11 +16,11 @@ 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.gallery; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
public class Xoh_cfg_gallery implements GfoInvkAble {
public class Xoh_cfg_gallery implements Gfo_invk {
public int Imgs_per_row() {return imgs_per_row;} public Xoh_cfg_gallery Imgs_per_row_(int v) {imgs_per_row = v; return this;} private int imgs_per_row = 8; // changed from 4 to 8; DATE:2014-02-04
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_imgs_per_row_)) imgs_per_row = m.ReadInt("v");
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
return this;
} private static final String Invk_imgs_per_row_ = "imgs_per_row_";
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.hieros; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.langs.dsvs.*;
class Hiero_file_mgr implements GfoInvkAble {
class Hiero_file_mgr implements Gfo_invk {
private Ordered_hash hash = Ordered_hash_.New_bry();
private Hiero_file_srl srl;
public Hiero_file_mgr() {srl = new Hiero_file_srl(this);}
@@ -28,7 +28,7 @@ class Hiero_file_mgr implements GfoInvkAble {
public Hiero_file_itm Get_by_key(byte[] key) {return (Hiero_file_itm)hash.Get_by(key);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_srl)) return srl;
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
} private static final String Invk_srl = "srl";
}
class Hiero_file_itm {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.hieros; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
class Hiero_html_mgr {
private Bry_bfr html_bfr = Bry_bfr.reset_(Io_mgr.Len_kb), content_bfr = Bry_bfr.reset_(255), tbl_content_bfr = Bry_bfr.reset_(Io_mgr.Len_kb), temp_bfr = Bry_bfr.reset_(255);
private Bry_bfr html_bfr = Bry_bfr_.Reset(Io_mgr.Len_kb), content_bfr = Bry_bfr_.Reset(255), tbl_content_bfr = Bry_bfr_.Reset(Io_mgr.Len_kb), temp_bfr = Bry_bfr_.Reset(255);
private boolean cartouche_opened = false;
public static int scale = 100;
private Hiero_prefab_mgr prefab_mgr; private Hiero_file_mgr file_mgr; private Hiero_phoneme_mgr phoneme_mgr;
@@ -227,8 +227,8 @@ class Hiero_html_mgr {
public static final int Image_margin = 1;
public static final int Cartouche_width = 2;
public static final int Max_height = 44;
private static final byte[] Bry_cls_mirrored = Bry_.new_a7("class=\"mw-mirrored\" ");
private static final byte[]
private static final byte[] Bry_cls_mirrored = Bry_.new_a7("class=\"mw-mirrored\" ");
private static final byte[]
Tkn_lt = new byte[] {Byte_ascii.Lt}
, Tkn_gt = new byte[] {Byte_ascii.Gt}
, Tkn_dot = new byte[] {Byte_ascii.Dot}

View File

@@ -20,7 +20,7 @@ import gplx.core.brys.fmtrs.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*;
class Hiero_html_wtr {
private Hiero_phoneme_mgr phoneme_mgr;
private Bry_bfr temp_bfr = Bry_bfr.reset_(255);
private Bry_bfr temp_bfr = Bry_bfr_.Reset(255);
public Hiero_html_wtr(Hiero_html_mgr mgr, Hiero_phoneme_mgr phoneme_mgr) {this.phoneme_mgr = phoneme_mgr;}
public void Init_for_write(Xoh_wtr_ctx hctx) {this.hiero_img_dir = Hiero_xtn_mgr.Img_src_dir;} private byte[] hiero_img_dir = null;
public void Hr(Bry_bfr bfr) {bfr.Add(Gfh_tag_.Hr_inl).Add_byte_nl();}
@@ -28,22 +28,22 @@ class Hiero_html_wtr {
public byte[] Td_height(int height) {
return temp_bfr.Add(Option_bgn_bry).Add_int_variable(height).Add(Option_end_bry).To_bry_and_clear();
}
private static final byte[]
private static final byte[]
Option_bgn_bry = Bry_.new_a7("height: ")
, Option_end_bry = Bry_.new_a7("px;")
;
public void Td(Bry_bfr bfr, byte[] glyph) {
bfr.Add(Td_bgn_bry).Add(glyph).Add(Td_end_bry);
}
private static final byte[]
private static final byte[]
Td_bgn_bry = Bry_.new_a7("\n <td>")
, Td_end_bry = Bry_.new_a7("\n </td>")
;
public void Cartouche_bgn(Bry_bfr bfr) {
bfr.Add(Cartouche_bgn_lhs_bry).Add_int_variable((Hiero_html_mgr.Cartouche_width * Hiero_html_mgr.scale) / 100).Add(Cartouche_bgn_rhs_bry);
}
private static final String Tbl_bgn_str = "<table class=\"mw-hiero-table\">";
private static final byte[]
private static final String Tbl_bgn_str = "<table class=\"mw-hiero-table\">";
private static final byte[]
Cartouche_bgn_lhs_bry = Bry_.new_a7(String_.Concat_lines_nl_skip_last
( ""
, " <td>"
@@ -63,7 +63,7 @@ class Hiero_html_wtr {
public void Cartouche_end(Bry_bfr bfr) {
bfr.Add(Cartouche_end_lhs_bry).Add_int_variable((Hiero_html_mgr.Cartouche_width * Hiero_html_mgr.scale) / 100).Add(Cartouche_end_rhs_bry);
}
private static final byte[]
private static final byte[]
Cartouche_end_lhs_bry = Bry_.new_a7(String_.Concat_lines_nl_skip_last
( ""
, " </tr>"
@@ -87,7 +87,7 @@ class Hiero_html_wtr {
byte[] title = bgn ? Gfh_entity_.Lt_bry : Gfh_entity_.Gt_bry;
return cartouche_img_fmtr.Bld_bry_many(temp_bfr, hiero_img_dir, code, height, title);
}
private static final Bry_fmtr cartouche_img_fmtr = Bry_fmtr.new_(String_.Concat
private static final Bry_fmtr cartouche_img_fmtr = Bry_fmtr.new_(String_.Concat
( "\n <img src='~{path}hiero_~{code}.png'"
, " height='~{height}' title='~{title}'"
, " alt='~{title}' />"
@@ -96,7 +96,7 @@ class Hiero_html_wtr {
public void Tbl_inner(Bry_bfr html_bfr, Bry_bfr text_bfr) {
html_bfr.Add(Tbl_inner_bgn).Add_bfr_and_clear(text_bfr).Add(Tbl_inner_end); // $html .= self::TABLE_START . "<tr>\n" . $tableContentHtml . '</tr></table>';
}
private static final byte[]
private static final byte[]
Tbl_inner_bgn = Bry_.new_u8(String_.Concat_lines_nl_skip_last
( " <table class=\"mw-hiero-table\">"
, " <tr>"
@@ -112,7 +112,7 @@ class Hiero_html_wtr {
bfr.Add_bfr_and_clear(html_bfr);
bfr.Add(Outer_tbl_end);
}
private static final byte[]
private static final byte[]
Outer_tbl_bgn = Bry_.new_a7(String_.Concat_lines_nl_skip_last
( "<table class='mw-hiero-table mw-hiero-outer' dir='ltr'>"
, " <tr>"
@@ -137,7 +137,7 @@ class Hiero_html_wtr {
byte[] img_src = Bld_img_src(hiero_img_dir, img_src_name);
return glyph_img_fmtr.Bld_bry_many(temp_bfr, img_cls, Hiero_html_mgr.Image_margin, td_height, img_src, img_title, glyph);
}
private static final byte[]
private static final byte[]
Tbl_eol_bry = Bry_.new_a7(String_.Concat_lines_nl_skip_last
( ""
, " </tr>"
@@ -145,7 +145,7 @@ class Hiero_html_wtr {
, " " + Tbl_bgn_str
, " <tr>"
));
private static final Bry_fmtr glyph_img_fmtr = Bry_fmtr.new_
private static final Bry_fmtr glyph_img_fmtr = Bry_fmtr.new_
( "\n <img ~{img_cls}style='margin: ~{img_margin}px; ~{option}' src='~{img_src}' title='~{img_title}' alt='~{glyph}' />"
, "img_cls", "img_margin", "option", "img_src", "img_title", "glyph");
public byte[] Void(boolean half) { // render void
@@ -153,7 +153,7 @@ class Hiero_html_wtr {
if (half) width /= 2;
return void_fmtr.Bld_bry_many(temp_bfr, width);
}
private static final Bry_fmtr void_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
private static final Bry_fmtr void_fmtr = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( ""
, " <table class=\"mw-hiero-table\" style=\"width: ~{width}px;\">"
, " <tr>"
@@ -165,7 +165,7 @@ class Hiero_html_wtr {
private static byte[] Bld_img_src(byte[] hiero_img_dir, byte[] name) {
return Bry_.Add(hiero_img_dir, Img_src_prefix, name, Img_src_ext);
}
private static final byte[] Img_src_prefix = Bry_.new_a7("hiero_")
private static final byte[] Img_src_prefix = Bry_.new_a7("hiero_")
, Img_src_ext = Bry_.new_a7(".png")
;
}

View File

@@ -69,7 +69,7 @@ public class Hiero_mw_tables_parser {
}
}
private void Parse_phonemes(Hiero_phoneme_mgr mgr, Php_line_assign line) { // $wh_phonemes = array(k => v, k => v ...);
List_adp tmp_list = List_adp_.new_(); Byte_obj_ref tmp_rslt = Byte_obj_ref.zero_(); Bry_bfr tmp_bfr = Bry_bfr.new_();
List_adp tmp_list = List_adp_.New(); Byte_obj_ref tmp_rslt = Byte_obj_ref.zero_(); Bry_bfr tmp_bfr = Bry_bfr_.New();
Php_itm_ary ary = (Php_itm_ary)line.Val();
int subs_len = ary.Subs_len();
for (int i = 0; i < subs_len; i++) {

View File

@@ -19,9 +19,9 @@ package gplx.xowa.xtns.hieros; import gplx.*; import gplx.xowa.*; import gplx.xo
import gplx.core.btries.*; import gplx.langs.htmls.*; import gplx.xowa.htmls.*;
class Hiero_parser {
private Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
private List_adp blocks = List_adp_.new_();
private List_adp blocks = List_adp_.New();
private Hiero_block cur_block;
private Bry_bfr cur_tkn = Bry_bfr.reset_(16);
private Bry_bfr cur_tkn = Bry_bfr_.Reset(16);
public Hiero_block[] Parse(byte[] src, int bgn, int end) {
blocks.Clear();
this.cur_block = new Hiero_block();
@@ -125,7 +125,7 @@ class Hiero_parser_itm {
public static final byte Tid_block_spr = 1, Tid_tkn_spr = 2, Tid_single_char = 3, Tid_dot = 4, Tid_comment = 5;
}
class Hiero_block {
private List_adp list = List_adp_.new_();
private List_adp list = List_adp_.New();
public int Len() {return list.Count();}
public byte[] Get_at(int i) {return (byte[])list.Get_at(i);}
public void Add(byte[] v) {list.Add(v);}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.hieros; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.langs.dsvs.*;
class Hiero_phoneme_mgr implements GfoInvkAble {
class Hiero_phoneme_mgr implements Gfo_invk {
private Ordered_hash hash = Ordered_hash_.New_bry();
private Hiero_phoneme_srl srl;
public Hiero_phoneme_mgr() {srl = new Hiero_phoneme_srl(this);}
@@ -28,7 +28,7 @@ class Hiero_phoneme_mgr implements GfoInvkAble {
public Hiero_phoneme_itm Get_by_key(byte[] key) {return (Hiero_phoneme_itm)hash.Get_by(key);}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_srl)) return srl;
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
}
public static final String Invk_srl = "srl";
}

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.hieros; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.langs.dsvs.*;
class Hiero_prefab_mgr implements GfoInvkAble {
class Hiero_prefab_mgr implements Gfo_invk {
private Ordered_hash hash = Ordered_hash_.New_bry();
private Hiero_prefab_srl srl;
public Hiero_prefab_mgr() {srl = new Hiero_prefab_srl(this);}
@@ -28,7 +28,7 @@ class Hiero_prefab_mgr implements GfoInvkAble {
public void Clear() {hash.Clear();}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_srl)) return srl;
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
} private static final String Invk_srl = "srl";
}
class Hiero_prefab_itm {

View File

@@ -17,10 +17,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.hieros; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.wikis.*; import gplx.xowa.htmls.modules.*; import gplx.xowa.apps.fsys.*;
public class Hiero_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
public class Hiero_xtn_mgr extends Xox_mgr_base implements Gfo_invk {
@Override public boolean Enabled_default() {return true;}
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_a7("hiero");
@Override public Xox_mgr Clone_new() {return new Hiero_xtn_mgr();}
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_a7("hiero");
@Override public Xox_mgr Xtn_clone_new() {return new Hiero_xtn_mgr();}
public static byte[] Img_src_dir;
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {}
private static boolean xtn_init_done = false;
@@ -35,10 +35,10 @@ public class Hiero_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
parser.Init();
xtn_init_done = true;
}
@gplx.Internal protected Hiero_parser Parser() {return parser;} private static final Hiero_parser parser = new Hiero_parser();
@gplx.Internal protected Hiero_prefab_mgr Prefab_mgr() {return prefab_mgr;} private static final Hiero_prefab_mgr prefab_mgr = new Hiero_prefab_mgr();
@gplx.Internal protected Hiero_file_mgr File_mgr() {return file_mgr;} private static final Hiero_file_mgr file_mgr = new Hiero_file_mgr();
@gplx.Internal protected Hiero_phoneme_mgr Phoneme_mgr() {return phoneme_mgr;} private static final Hiero_phoneme_mgr phoneme_mgr = new Hiero_phoneme_mgr();
@gplx.Internal protected Hiero_parser Parser() {return parser;} private static final Hiero_parser parser = new Hiero_parser();
@gplx.Internal protected Hiero_prefab_mgr Prefab_mgr() {return prefab_mgr;} private static final Hiero_prefab_mgr prefab_mgr = new Hiero_prefab_mgr();
@gplx.Internal protected Hiero_file_mgr File_mgr() {return file_mgr;} private static final Hiero_file_mgr file_mgr = new Hiero_file_mgr();
@gplx.Internal protected Hiero_phoneme_mgr Phoneme_mgr() {return phoneme_mgr;} private static final Hiero_phoneme_mgr phoneme_mgr = new Hiero_phoneme_mgr();
@gplx.Internal protected Hiero_html_mgr Html_wtr() {return html_wtr;} private static Hiero_html_mgr html_wtr;
public void Clear() {
prefab_mgr.Clear();

View File

@@ -0,0 +1,47 @@
/*
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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.primitives.*;
import gplx.xowa.parsers.*;
import gplx.xowa.xtns.imaps.itms.*;
public class Imap_base_fxt {
protected Xoae_app app; protected Xowe_wiki wiki;
@gplx.Virtual public void Reset() {
app = Xoa_app_fxt.Make__app__edit();
wiki = Xoa_app_fxt.Make__wiki__edit(app);
wiki.Parser_mgr().Ctx().Para().Enabled_n_();
}
public Imap_part_shape itm_rect_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_rect, link, pts_ary);}
public Imap_part_shape itm_circle_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_circle, link, pts_ary);}
public Imap_part_shape itm_poly_(String link, double... pts_ary) {return itm_shape_(Imap_part_.Tid_shape_poly, link, pts_ary);}
private Imap_part_shape itm_shape_(byte tid, String link, double... pts_ary) {
int pts_len = pts_ary.length;
Double_obj_val[] pts_doubles = new Double_obj_val[pts_len];
for (int i = 0; i < pts_len; ++i)
pts_doubles[i] = Double_obj_val.new_(pts_ary[i]);
byte[] link_bry = Bry_.new_u8(link);
Imap_part_shape rv = new Imap_part_shape(tid, pts_doubles);
Imap_link_owner_.Init(rv, app, wiki, link_bry, Make_link_tkn(link_bry));
return rv;
}
private Xop_tkn_itm Make_link_tkn(byte[] src) {
Xop_root_tkn root_tkn = new Xop_root_tkn();
wiki.Parser_mgr().Main().Parse_text_to_wdom(root_tkn, wiki.Parser_mgr().Ctx(), app.Parser_mgr().Tkn_mkr(), src, Xop_parser_.Doc_bgn_bos);
return root_tkn.Subs_get(0);
}
}

View File

@@ -1,62 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*;
interface Imap_itm {
byte Itm_tid();
}
class Imap_itm_ {
public static final byte Tid_invalid = 0, Tid_img = 1, Tid_desc = 2, Tid_comment = 3, Tid_dflt = 4, Tid_shape_rect = 5, Tid_shape_circle = 6, Tid_shape_poly = 7;
public static final byte[]
Key_dflt = Bry_.new_a7("default")
, Key_shape_rect = Bry_.new_a7("rect")
, Key_shape_circle = Bry_.new_a7("circle")
, Key_shape_poly = Bry_.new_a7("poly")
;
public static byte[] Xto_key(byte v) {
switch (v) {
case Tid_shape_rect : return Key_shape_rect;
case Tid_shape_circle : return Key_shape_circle;
case Tid_shape_poly : return Key_shape_poly;
default : throw Err_.new_unhandled(v);
}
}
}
class Imap_itm_img implements Imap_itm {
public Imap_itm_img(Xop_lnki_tkn img_link) {this.img_link = img_link;}
public byte Itm_tid() {return Imap_itm_.Tid_img;}
public Xop_lnki_tkn Img_link() {return img_link;} private Xop_lnki_tkn img_link;
}
class Imap_itm_desc implements Imap_itm {
public Imap_itm_desc(byte desc_tid) {this.desc_tid = desc_tid;}
public byte Itm_tid() {return Imap_itm_.Tid_desc;}
public byte Desc_tid() {return desc_tid;} private byte desc_tid;
}
class Imap_itm_dflt implements Imap_itm, Imap_link_owner {
public byte Itm_tid() {return Imap_itm_.Tid_dflt;}
public int Link_tid() {return link_tid;} private int link_tid;
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn;
public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
public byte[] Link_href() {return link_href;} public void Link_href_(byte[] v) {this.link_href = v;} private byte[] link_href;
public byte[] Link_text() {return link_text;} public void Link_text_(byte[] v) {this.link_text = v;} private byte[] link_text;
}
class Imap_err {
public Imap_err(int itm_idx, String err_key) {this.itm_idx = itm_idx; this.err_key = err_key;}
public int Itm_idx() {return itm_idx;} private int itm_idx;
public String Err_key() {return err_key;} private String err_key;
}

View File

@@ -16,60 +16,59 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.files.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.files.gui.*; import gplx.xowa.guis.views.*;
import gplx.xowa.htmls.core.makes.imgs.*;
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
import gplx.xowa.files.*; import gplx.xowa.files.gui.*;
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
import gplx.xowa.xtns.imaps.itms.*; import gplx.xowa.xtns.imaps.htmls.*;
public class Imap_map implements Xoh_file_img_wkr, Js_img_wkr {
private static final Imap_map_fmtr map_fmtr_arg = new Imap_map_fmtr();
private byte img_cls_tid; private Imap_xtn_mgr xtn_mgr;
private byte[] a_href, img_alt, img_cls_other;
public Imap_map(int id) {this.id = id;}
public Imap_xtn_mgr Xtn_mgr() {return xtn_mgr;} private Imap_xtn_mgr xtn_mgr;
@gplx.Internal protected void Init(Imap_xtn_mgr xtn_mgr, byte[] img_src, Imap_itm_img img, Imap_itm_dflt dflt, Imap_itm_desc desc, Imap_itm_shape[] shapes, Imap_err[] errs) {
public void Init(Imap_xtn_mgr xtn_mgr, byte[] img_src, Imap_part_img img, Imap_part_dflt dflt, Imap_part_desc desc, Imap_part_shape[] shapes, Imap_err[] errs) {
this.xtn_mgr = xtn_mgr; this.img_src = img_src; this.img = img; this.dflt = dflt; this.desc = desc; this.shapes = shapes; this.errs = errs;
}
public boolean Invalid() {return img == null;} // invalid if missing image; PAGE:en.w:Wikipedia:WikiProject_Games/Advert EX: <imagemap>|thumb;</imagemap>; DATE:2014-08-12
public int Id() {return id;} private int id;
public byte[] Img_src() {return img_src;} private byte[] img_src;
@gplx.Internal protected Imap_itm_img Img() {return img;} private Imap_itm_img img;
@gplx.Internal protected Imap_itm_dflt Dflt() {return dflt;} private Imap_itm_dflt dflt;
@gplx.Internal protected Imap_itm_desc Desc() {return desc;} private Imap_itm_desc desc;
@gplx.Internal protected Imap_itm_shape[] Shapes() {return shapes;} private Imap_itm_shape[] shapes;
@gplx.Internal protected Imap_err[] Errs() {return errs;} private Imap_err[] errs;
private byte img_cls_tid;
private byte[] a_href, img_alt, img_cls_other;
public int Id() {return id;} private final int id;
public byte[] Img_src() {return img_src;} private byte[] img_src;
public Imap_part_img Img() {return img;} private Imap_part_img img;
public Imap_part_dflt Dflt() {return dflt;} private Imap_part_dflt dflt;
public Imap_part_desc Desc() {return desc;} private Imap_part_desc desc;
public Imap_part_shape[] Shapes() {return shapes;} private Imap_part_shape[] shapes;
public Imap_err[] Errs() {return errs;} private Imap_err[] errs;
public boolean Invalid() {return img == null;} // invalid if missing image; PAGE:en.w:Wikipedia:WikiProject_Games/Advert EX: <imagemap>|thumb;</imagemap>; DATE:2014-08-12
public void Html_full_img(Bry_bfr tmp_bfr, Xoh_wtr_ctx hctx, Xoae_page page, byte[] src, Xof_file_itm xfer_itm, int uid
, byte[] a_href, boolean a_href_is_file, byte a_cls, byte a_rel, byte[] a_title, byte[] a_xowa_title
, int img_w, int img_h, byte[] img_src, byte[] img_alt, byte img_cls, byte[] img_cls_other
) {
this.a_href = a_href; this.img_alt = img_alt; this.img_cls_tid = img_cls; this.img_cls_other = img_cls_other;
xfer_itm.Html_img_wkr_(this);
xfer_itm.Html_elem_tid_(Xof_html_elem.Tid_imap);
this.a_href = a_href; this.img_alt = img_alt; this.img_cls_tid = img_cls; this.img_cls_other = img_cls_other;
Write_imap_div(tmp_bfr, page.Wikie(), hctx, src, uid, img_w, img_h, img_src, xfer_itm.Orig_w(), xfer_itm.Orig_h(), a_xowa_title);
if (hctx.Mode_is_hdump())
page.Hdump_data().Imgs_add_img(new Xohd_img_itm__img(), xfer_itm, Xohd_img_itm__gallery_itm.Tid_basic);
if (hctx.Mode_is_hdump()) {
img_w = xfer_itm.Lnki_w(); // NOTE: hdump must dump lnki_w, not img_w; GUI will either (a) write -1 and update later thru js_wkr; (b) get correct img_w from cache; hdump can do neither (a) nor (b); DATE:2016-06-17
img_h = xfer_itm.Lnki_h();
page.Hdump_data().Imgs_add_img(new Xohd_img_itm__img(), xfer_itm, Xohd_img_itm__gallery_itm.Tid_basic); // DELETE: no need to add img to global collection during hdump; was here presumably to write entries to "imgs" table; DATE:2016-06-17
}
Write_imap_div(tmp_bfr, hctx, uid, img_w, img_h, img_src, xfer_itm.Orig_w(), xfer_itm.Orig_h(), a_xowa_title);
}
public void Html_update(Xoa_page page, Xog_js_wkr js_wkr, int html_uid, int html_w, int html_h, Io_url html_view_url, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl) {
Xowe_wiki wiki = xtn_mgr.Wiki();
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_k004();
Write_imap_div(tmp_bfr, (Xowe_wiki)page.Wiki(), Xoh_wtr_ctx.Basic, Bry_.Empty, html_uid, html_w, html_h, html_view_url.To_http_file_bry(), orig_w, orig_h, lnki_ttl);
js_wkr.Html_elem_replace_html("imap_div_" + Int_.To_str(html_uid), tmp_bfr.To_str_and_rls());
public void Js_wkr__update_hdoc(Xoa_page page, Xog_js_wkr js_wkr, int html_uid
, int html_w, int html_h, Io_url html_view_url
, int orig_w, int orig_h, Io_url html_orig_url, byte[] lnki_ttl) {
Bry_bfr tmp_bfr = Bry_bfr_.Get();
try {
Write_imap_div(tmp_bfr, Xoh_wtr_ctx.Basic, html_uid, html_w, html_h, html_view_url.To_http_file_bry(), orig_w, orig_h, lnki_ttl);
js_wkr.Html_elem_replace_html("imap_div_" + Int_.To_str(html_uid), tmp_bfr.To_str_and_rls());
} finally {tmp_bfr.Mkr_rls();}
}
private void Write_imap_div(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, byte[] src, int html_uid, int html_w, int html_h, byte[] html_src, int orig_w, int orig_h, byte[] lnki_ttl) {
byte[] desc_style = Calc_desc_style(html_w, html_h);
// int shapes_len = shapes.length;
// for (int i = 0; i < shapes_len; ++i) {
// Imap_itm_shape shape = shapes[i];
// Imap_link_owner_.Write(shape, wiki.Appe(), wiki, hctx, src);
// }
map_fmtr_arg.Init(id, shapes, Calc_scale(orig_w, orig_h, html_w, html_h));
img_fmtr_arg.Init(hctx, xtn_mgr, this, src, html_uid, img_alt, html_src, html_w, html_h, Xoh_img_cls_.To_html(img_cls_tid, img_cls_other), a_href, lnki_ttl);
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, desc_style, map_fmtr_arg, img_fmtr_arg);
private void Write_imap_div(Bry_bfr bfr, Xoh_wtr_ctx hctx, int html_uid, int html_w, int html_h, byte[] img_src, int orig_w, int orig_h, byte[] lnki_ttl) {
Imap_map_arg map_arg = new Imap_map_arg(id, shapes, Calc_scale(orig_w, orig_h, html_w, html_h));
Imap_img_arg img_arg = new Imap_img_arg(hctx, xtn_mgr, this, html_uid, img_alt, img_src, html_w, html_h, Xoh_img_cls_.To_html(img_cls_tid, img_cls_other), a_href, lnki_ttl);
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, Calc_desc_style(desc, html_w, html_h), map_arg, img_arg);
}
private byte[] Calc_desc_style(int html_w, int html_h) {
private static byte[] Calc_desc_style(Imap_part_desc desc, int html_w, int html_h) {
if (desc == null) return Bry_.Empty;
Bry_bfr tmp_bfr = xtn_mgr.Wiki().Utl__bfr_mkr().Get_b128().Mkr_rls();
return Imap_html_fmtrs.Desc_style.Bld_bry_many(tmp_bfr, html_w, html_h);
Bry_bfr tmp_bfr = Bry_bfr_.Get();
try {return Imap_html_fmtrs.Desc_style.Bld_bry_many(tmp_bfr, html_w, html_h);}
finally {tmp_bfr.Mkr_rls();}
}
private static final Imap_img_fmtr_arg img_fmtr_arg = new Imap_img_fmtr_arg();
private static double Calc_scale(int orig_w, int orig_h, int html_w, int html_h) {
int denominator = orig_w + orig_h;
int numerator = html_w + html_h;

View File

@@ -1,51 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.brys.fmtrs.*;
class Imap_map_fmtr implements gplx.core.brys.Bfr_arg {
private int imap_id;
public void Init(int imap_id, Imap_itm_shape[] shapes, double scale) {this.imap_id = imap_id; shapes_fmtr_arg.Init(shapes, scale);}
public Imap_pts_fmtr_arg Pts_fmtr() {return shapes_fmtr_arg.Pts_fmtr();}
public void Bfr_arg__add(Bry_bfr bfr) {
Imap_html_fmtrs.Map.Bld_bfr_many(bfr, imap_id, shapes_fmtr_arg);
}
private static final Imap_shapes_fmtr shapes_fmtr_arg = new Imap_shapes_fmtr();
}
class Imap_shapes_fmtr implements gplx.core.brys.Bfr_arg {
private Imap_itm_shape[] shapes;
public void Init(Imap_itm_shape[] shapes, double scale) {this.shapes = shapes; pts_fmtr_arg.Scale_(scale);}
public Imap_pts_fmtr_arg Pts_fmtr() {return pts_fmtr_arg;}
public void Bfr_arg__add(Bry_bfr bfr) {
int shapes_len = shapes.length;
Bry_fmtr fmtr = Imap_html_fmtrs.Area;
for (int i = 0; i < shapes_len; ++i) {
Imap_itm_shape shape = shapes[i];
Fmt_shape(bfr, fmtr, pts_fmtr_arg, shape);
}
}
@gplx.Internal protected static void Fmt_shape(Bry_bfr bfr, Bry_fmtr fmtr, Imap_pts_fmtr_arg pts_fmtr, Imap_itm_shape shape) {
pts_fmtr_arg.Pts_(shape.Shape_pts());
fmtr.Bld_bfr_many(bfr
, shape.Link_href()
, Imap_itm_.Xto_key(shape.Itm_tid())
, pts_fmtr_arg
, shape.Link_text()
);
}
private static final Imap_pts_fmtr_arg pts_fmtr_arg = new Imap_pts_fmtr_arg();
}

View File

@@ -18,13 +18,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.btries.*; import gplx.core.primitives.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.files.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.tmpls.*;
class Imap_parser {
import gplx.xowa.xtns.imaps.itms.*;
public class Imap_parser {
private Imap_xtn_mgr xtn_mgr; private Xoa_url page_url; private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
private byte[] imap_img_src;
private Imap_itm_img imap_img;
private Imap_itm_dflt imap_dflt;
private Imap_itm_desc imap_desc;
private List_adp shapes = List_adp_.new_(), pts = List_adp_.new_(), errs = List_adp_.new_();
private Imap_part_img imap_img;
private Imap_part_dflt imap_dflt;
private Imap_part_desc imap_desc;
private List_adp shapes = List_adp_.New(), pts = List_adp_.New(), errs = List_adp_.New();
private byte[] src;
private int itm_idx; private int itm_bgn, itm_end;
private Xoae_app app; private Xowe_wiki wiki; private Xop_ctx wiki_ctx, imap_ctx; private Xop_root_tkn imap_root;
@@ -68,43 +69,42 @@ class Imap_parser {
itm_end = Parse_img(rv, itm_bgn, itm_end, src_end);
else {
Object tid_obj = tid_trie.Match_bgn_w_byte(b, src, itm_bgn, itm_end);
byte tid_val = tid_obj == null ? Imap_itm_.Tid_invalid : ((Byte_obj_val)tid_obj).Val();
byte tid_val = tid_obj == null ? Imap_part_.Tid_invalid : ((Byte_obj_val)tid_obj).Val();
int tid_end_pos = tid_trie.Match_pos();
switch (tid_val) {
case Imap_itm_.Tid_desc: Parse_desc(tid_end_pos, itm_end); break;
case Imap_itm_.Tid_dflt: Parse_dflt(tid_end_pos, itm_end); break;
case Imap_itm_.Tid_shape_rect: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 4); break;
case Imap_itm_.Tid_shape_poly: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, Reqd_poly); break;
case Imap_itm_.Tid_shape_circle: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 3); break;
case Imap_part_.Tid_desc: Parse_desc(tid_end_pos, itm_end); break;
case Imap_part_.Tid_dflt: Parse_dflt(tid_end_pos, itm_end); break;
case Imap_part_.Tid_shape_rect: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 4); break;
case Imap_part_.Tid_shape_poly: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, Reqd_poly); break;
case Imap_part_.Tid_shape_circle: Parse_shape(tid_val, tid_end_pos, itm_bgn, itm_end, 3); break;
default:
case Imap_itm_.Tid_invalid: Parse_invalid(itm_bgn, itm_end); break;
case Imap_part_.Tid_invalid: Parse_invalid(itm_bgn, itm_end); break;
}
}
} catch (Exception e) {usr_dlg.Warn_many("", "", "imap.parse:skipping line; page=~{0} line=~{1} err=~{2}", page_url.To_str(), Bry_.Mid_safe(src, itm_bgn, itm_end), Err_.Message_gplx_log(e));}
++itm_idx;
}
rv.Init(xtn_mgr, imap_img_src, imap_img, imap_dflt, imap_desc, (Imap_itm_shape[])shapes.To_ary_and_clear(Imap_itm_shape.class), (Imap_err[])errs.To_ary_and_clear(Imap_err.class));
rv.Init(xtn_mgr, imap_img_src, imap_img, imap_dflt, imap_desc, (Imap_part_shape[])shapes.To_ary_and_clear(Imap_part_shape.class), (Imap_err[])errs.To_ary_and_clear(Imap_err.class));
}
private void Parse_comment(int itm_bgn, int itm_end) {} // noop comments; EX: "# comment\n"
private void Parse_invalid(int itm_bgn, int itm_end) {usr_dlg.Warn_many("", "", "imap has invalid line: page=~{0} line=~{1}", page_url.To_str(), String_.new_u8(src, itm_bgn, itm_end));}
private boolean Parse_desc(int itm_bgn, int itm_end) {
xtn_mgr.Desc_assert();
Btrie_slim_mgr trie = xtn_mgr.Desc_trie();
byte tid_desc = Imap_desc_tid.parse(trie, src, Bry_find_.Trim_fwd_space_tab(src, itm_bgn, itm_end), Bry_find_.Trim_bwd_space_tab(src, itm_end, itm_bgn));
byte tid_desc = Imap_desc_tid.Parse_to_tid(trie, src, Bry_find_.Trim_fwd_space_tab(src, itm_bgn, itm_end), Bry_find_.Trim_bwd_space_tab(src, itm_end, itm_bgn));
switch (tid_desc) {
case Imap_desc_tid.Tid_null: return Add_err(Bool_.N, itm_bgn, itm_end, "imagemap_invalid_coord");
case Imap_desc_tid.Tid_none: return true;
}
if (imap_img == null || imap_img.Img_link().Lnki_type() == Xop_lnki_type.Id_thumb) return true; // thumbs don't get desc
imap_desc = new Imap_itm_desc(tid_desc);
imap_desc = new Imap_part_desc(tid_desc);
return true;
}
private void Parse_dflt(int itm_bgn, int itm_end) {
imap_dflt = new Imap_itm_dflt();
imap_dflt = new Imap_part_dflt();
Init_link_owner(imap_dflt, src, itm_bgn, itm_end);
}
private boolean Parse_shape(byte shape_tid, int tid_end_pos, int itm_bgn, int itm_end, int reqd_pts) {
boolean shape_is_poly = shape_tid == Imap_itm_.Tid_shape_poly;
boolean shape_is_poly = shape_tid == Imap_part_.Tid_shape_poly;
int pos = Bry_find_.Trim_fwd_space_tab(src, tid_end_pos, itm_end); // gobble any leading spaces
int grp_end = Bry_find_.Find_fwd(src, Byte_ascii.Brack_bgn, pos, itm_end); // find first "["; note that this is a lazy way of detecting start of lnki / lnke; MW has complicated regex, but hopefully this will be enough; DATE:2014-10-22
if (grp_end == -1) {return Add_err(Bool_.Y, itm_bgn, itm_end, "imap_No valid link was found");}
@@ -149,7 +149,7 @@ class Imap_parser {
if (pts_len < reqd_pts) return Add_err(Bool_.Y, itm_bgn, itm_end, "imagemap_missing_coord");
}
pos = Bry_find_.Trim_fwd_space_tab(src, pos, itm_end);
Imap_itm_shape shape_itm = new Imap_itm_shape(shape_tid, (Double_obj_val[])pts.To_ary_and_clear(Double_obj_val.class));
Imap_part_shape shape_itm = new Imap_part_shape(shape_tid, (Double_obj_val[])pts.To_ary_and_clear(Double_obj_val.class));
Init_link_owner(shape_itm, src, pos, itm_end);
shapes.Add(shape_itm);
return true;
@@ -194,7 +194,7 @@ class Imap_parser {
Xoa_app_.Usr_dlg().Warn_many("", "", "image_map failed to find lnki; page=~{0} imageMap=~{1}", page_url.To_str(), imap_img_src);
else {
Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)tkn_itm;
imap_img = new Imap_itm_img(lnki_tkn);
imap_img = new Imap_part_img(lnki_tkn);
lnki_tkn.Lnki_file_wkr_(imap);
wiki_ctx.Page().Lnki_list().Add(lnki_tkn);
wiki_ctx.Lnki().File_logger().Log_file(wiki_ctx, lnki_tkn, Xop_file_logger_.Tid__imap); // NOTE: do not do imap_ctx.Lnki(); imap_ctx is brand new
@@ -226,12 +226,12 @@ class Imap_parser {
return rv;
}
private static Btrie_slim_mgr tid_trie = Btrie_slim_mgr.ci_a7() // names are not i18n'd; // NOTE:ci.ascii:MW_const.en
.Add_str_byte("desc" , Imap_itm_.Tid_desc)
.Add_str_byte("#" , Imap_itm_.Tid_comment)
.Add_bry_byte(Imap_itm_.Key_dflt , Imap_itm_.Tid_dflt)
.Add_bry_byte(Imap_itm_.Key_shape_rect , Imap_itm_.Tid_shape_rect)
.Add_bry_byte(Imap_itm_.Key_shape_circle , Imap_itm_.Tid_shape_circle)
.Add_bry_byte(Imap_itm_.Key_shape_poly , Imap_itm_.Tid_shape_poly)
.Add_str_byte("desc" , Imap_part_.Tid_desc)
.Add_str_byte("#" , Imap_part_.Tid_comment)
.Add_bry_byte(Imap_part_.Key_dflt , Imap_part_.Tid_dflt)
.Add_bry_byte(Imap_part_.Key_shape_rect , Imap_part_.Tid_shape_rect)
.Add_bry_byte(Imap_part_.Key_shape_circle , Imap_part_.Tid_shape_circle)
.Add_bry_byte(Imap_part_.Key_shape_poly , Imap_part_.Tid_shape_poly)
;
private static final int Reqd_poly = -1;
}

View File

@@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.parsers.*;
import org.junit.*; import gplx.core.primitives.*; import gplx.xowa.parsers.*; import gplx.xowa.xtns.imaps.itms.*;
public class Imap_parser_tst {
@Before public void init() {fxt.Reset();} private Imap_parser_fxt fxt = new Imap_parser_fxt();
@Test public void Rect_pass() {fxt.Test_shape("rect 1 2 3 4 [[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));}
@@ -36,33 +36,7 @@ public class Imap_parser_tst {
@Test public void Poly_fail_zero() {fxt.Test_shape_err("poly [[A]]" , "imagemap_missing_coord");}
@Test public void Circle_fail_invalid() {fxt.Test_shape_err("rect 1 2..3 4 [[A]]" , "imagemap_invalid_coord");}
}
class Imap_fxt_base {
protected Xoae_app app; protected Xowe_wiki wiki;
@gplx.Virtual public void Reset() {
app = Xoa_app_fxt.Make__app__edit();
wiki = Xoa_app_fxt.Make__wiki__edit(app);
wiki.Parser_mgr().Ctx().Para().Enabled_n_();
}
public Imap_itm_shape itm_rect_(String link, double... pts_ary) {return itm_shape_(Imap_itm_.Tid_shape_rect, link, pts_ary);}
public Imap_itm_shape itm_circle_(String link, double... pts_ary) {return itm_shape_(Imap_itm_.Tid_shape_circle, link, pts_ary);}
public Imap_itm_shape itm_poly_(String link, double... pts_ary) {return itm_shape_(Imap_itm_.Tid_shape_poly, link, pts_ary);}
private Imap_itm_shape itm_shape_(byte tid, String link, double... pts_ary) {
int pts_len = pts_ary.length;
Double_obj_val[] pts_doubles = new Double_obj_val[pts_len];
for (int i = 0; i < pts_len; ++i)
pts_doubles[i] = Double_obj_val.new_(pts_ary[i]);
byte[] link_bry = Bry_.new_u8(link);
Imap_itm_shape rv = new Imap_itm_shape(tid, pts_doubles);
Imap_link_owner_.Init(rv, app, wiki, link_bry, Make_link_tkn(link_bry));
return rv;
}
private Xop_tkn_itm Make_link_tkn(byte[] src) {
Xop_root_tkn root_tkn = new Xop_root_tkn();
wiki.Parser_mgr().Main().Parse_text_to_wdom(root_tkn, wiki.Parser_mgr().Ctx(), app.Parser_mgr().Tkn_mkr(), src, Xop_parser_.Doc_bgn_bos);
return root_tkn.Subs_get(0);
}
}
class Imap_parser_fxt extends Imap_fxt_base {
class Imap_parser_fxt extends Imap_base_fxt {
private Imap_parser parser;
private Imap_map imap;
@Override public void Reset() {
@@ -75,17 +49,17 @@ class Imap_parser_fxt extends Imap_fxt_base {
parser.Clear();
imap = new Imap_map(1);
}
public void Test_shape(String raw_str, Imap_itm_shape expd) {
public void Test_shape(String raw_str, Imap_part_shape expd) {
raw_str = "File:A.png\n" + raw_str;
byte[] raw = Bry_.new_u8(raw_str);
parser.Parse(imap, raw, 0, raw.length);
Imap_itm_shape[] actl_ary = imap.Shapes();
Imap_itm_shape actl = actl_ary == null | actl_ary.length != 1 ? null : (Imap_itm_shape)actl_ary[0];
Imap_part_shape[] actl_ary = imap.Shapes();
Imap_part_shape actl = actl_ary == null | actl_ary.length != 1 ? null : (Imap_part_shape)actl_ary[0];
if (actl == null && expd == null) {} // noop; test passed
else if (actl == null && expd != null) {Tfds.Fail("actl should not be null", raw);}
else if (actl != null && expd == null) {Tfds.Fail("actl should be null", raw);}
else {
Tfds.Eq(expd.Itm_tid(), actl.Itm_tid(), "tid");
Tfds.Eq(expd.Part_tid(), actl.Part_tid(), "tid");
Tfds.Eq_ary(expd.Shape_pts(), actl.Shape_pts(), "pts");
Tfds.Eq(String_.new_u8(expd.Link_href()), String_.new_u8(actl.Link_href()));
Tfds.Eq(String_.new_u8(expd.Link_text()), String_.new_u8(actl.Link_text()));
@@ -98,6 +72,6 @@ class Imap_parser_fxt extends Imap_fxt_base {
parser.Parse(imap, raw, 0, raw.length);
Imap_err[] err_ary = imap.Errs();
Tfds.Eq(1, err_ary.length, "expd 1 err");
Tfds.Eq(expd_err, err_ary[0].Err_key());
Tfds.Eq(expd_err, err_ary[0].Err_msg());
}
}

View File

@@ -16,22 +16,25 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.htmls.core.htmls.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*; import gplx.xowa.parsers.xndes.*;
public class Imap_xnde implements Xox_xnde {
private Imap_xtn_mgr xtn_mgr;
private Imap_map imap_data;
public void Xtn_parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
xtn_mgr = wiki.Xtn_mgr().Xtn_imap();
xtn_mgr.Xtn_assert();
// init
xtn_mgr = wiki.Xtn_mgr().Xtn_imap().Xtn_assert();
Xoae_page page = ctx.Page();
page.Html_data().Head_mgr().Itm__popups().Bind_hover_area_(true);
page.Html_data().Xtn_imap_exists_y_();
page.Html_data().Head_mgr().Itm__popups().Bind_hover_area_(true);
// parse imap
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
imap_data = xtn_mgr.Parser().Parse(wiki, ctx, root, src, xnde);
ctx.Para().Process_block__xnde(xnde.Tag(), Xop_xnde_tag.Block_end);
boolean log_wkr_enabled = Log_wkr != Xop_log_basic_wkr.Null; if (log_wkr_enabled) Log_wkr.Log_end_xnde(ctx.Page(), Xop_log_basic_wkr.Tid_imageMap, src, xnde);
} public static Xop_log_basic_wkr Log_wkr = Xop_log_basic_wkr.Null;
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 (imap_data.Invalid()) return;
html_wtr.Write_tkn(bfr, ctx, hctx, imap_data.Img_src(), xnde, Xoh_html_wtr.Sub_idx_null, imap_data.Img().Img_link());

View File

@@ -16,35 +16,34 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.btries.*; import gplx.xowa.wikis.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
public class Imap_xtn_mgr extends Xox_mgr_base implements GfoInvkAble {
import gplx.core.btries.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
import gplx.xowa.xtns.imaps.itms.*;
public class Imap_xtn_mgr extends Xox_mgr_base implements Gfo_invk {
private boolean init;
@Override public boolean Enabled_default() {return true;}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("imageMap");
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
@gplx.Internal protected Imap_parser Parser() {return parser;} private Imap_parser parser;
public void Desc_assert() {
if (desc_trie != null) return;
desc_trie = Imap_desc_tid.trie_(wiki);
desc_msg = wiki.Msg_mgr().Val_by_key_obj("imagemap_description");
desc_icon_url = wiki.Appe().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("ImageMap", "imgs", "desc-20.png").To_http_file_bry();
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("imageMap");
@Override public boolean Enabled_default() {return true;}
public Xoh_arg_img_core Img_core_arg() {return img_core_arg;} private final Xoh_arg_img_core__basic img_core_arg = new Xoh_arg_img_core__basic();
public Imap_parser Parser() {return parser;} private Imap_parser parser;
public byte[] Desc_msg() {return desc_msg;} private byte[] desc_msg;
public byte[] Desc_icon_url() {return desc_icon_url;} private byte[] desc_icon_url;
public Btrie_slim_mgr Desc_trie() {
if (desc_trie == null) {
this.desc_trie = Imap_desc_tid.New_trie(wiki);
this.desc_msg = wiki.Msg_mgr().Val_by_key_obj("imagemap_description");
this.desc_icon_url = wiki.Appe().Fsys_mgr().Bin_xtns_dir().GenSubFil_nest("ImageMap", "imgs", "desc-20.png").To_http_file_bry();
}
return desc_trie;
} private Btrie_slim_mgr desc_trie;
public Imap_xtn_mgr Xtn_assert() {
if (init) return this;
this.init = true;
this.parser = new Imap_parser(this);
return this;
}
public Btrie_slim_mgr Desc_trie() {return desc_trie;} private Btrie_slim_mgr desc_trie;
public byte[] Desc_msg() {return desc_msg;} private byte[] desc_msg;
public byte[] Desc_icon_url() {return desc_icon_url;} private byte[] desc_icon_url;
public final Xoh_arg_img_core Img_core_fmtr = new Xoh_arg_img_core__basic();
public final Xoh_file_html_fmtr__hdump Img_html_hdump_bldr = Xoh_file_html_fmtr__hdump.Hdump;
public final Bry_bfr Tmp_bfr = Bry_bfr.new_(255);
@Override public Xox_mgr Clone_new() {return new Imap_xtn_mgr();}
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
this.wiki = wiki;
}
public void Xtn_assert() {
if (init) return;
parser = new Imap_parser(this);
init = true;
}
public static final byte[]
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
@Override public Xox_mgr Xtn_clone_new() {return new Imap_xtn_mgr();}
public static final byte[]
Bry__usemap__html = Bry_.new_a7(" usemap=\"#imagemap_1_")
, Bry__usemap__name = Bry_.new_a7("usemap")
, Bry__usemap__prefix = Bry_.new_a7("#imagemap_1_")

View File

@@ -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.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import org.junit.*;
import gplx.xowa.htmls.core.htmls.*;
public class Imap_html__hdump__tst {
@Before public void init() {fxt.Reset(); fxt.Fxt().Hctx_(Xoh_wtr_ctx.Hdump);} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
@Test public void Basic() {
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
( "<imagemap>"
, "File:A.png|thumb|100x200px|a1"
, "circle 0 0 5 [[B|b1]]"
, "rect 0 0 4 8 [[C|c1]]"
, "desc none"
, "</imagemap>"
), String_.Concat_lines_nl_skip_last
( "<div class=\"thumb tright\">"
, " <div class=\"thumbinner\" style=\"width:100px;\">" // NOTE:220px is default w for "non-found" thumb; DATE:2014-09-24
, " <div id='imap_div_0' class=\"noresize\">"
, " <map name=\"imageMap_1_1\">"
, " <area href=\"/wiki/B\" shape=\"circle\" coords=\"0,0,5\" alt=\"b1\" title=\"b1\"/>"
, " <area href=\"/wiki/C\" shape=\"rect\" coords=\"0,0,4,8\" alt=\"c1\" title=\"c1\"/>"
, " </map>"
, " <img data-xowa-title=\"A.png\" data-xoimg=\"1|100|200|-1|-1|-1\" src=\"\" width=\"0\" height=\"0\" class=\"thumbimage\" alt=\"\" usemap=\"#imagemap_1_1\"/>"
, " </div>"
, " <div class=\"thumbcaption\">"
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>a1"
, " </div>"
, " </div>"
, "</div>"
));
}
}

View File

@@ -15,10 +15,10 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import org.junit.*; import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
public class Imap_xnde_html_all_tst {
@Before public void init() {fxt.Reset();} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
public class Imap_html__hview__tst {
@Before public void init() {fxt.Reset();} private final Imap_xnde_html_fxt fxt = new Imap_xnde_html_fxt();
@Test public void Basic() {
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
( "<imagemap>"
@@ -193,7 +193,7 @@ class Imap_xnde_html_fxt {
Xol_msg_itm msg = fxt.Wiki().Msg_mgr().Get_or_make(Bry_.new_a7("imagemap_description"));
msg.Atrs_set(Bry_.new_a7("click here"), false, false);
}
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
public Xop_fxt Fxt() {return fxt;} private final Xop_fxt fxt = new Xop_fxt();
public void Test_html_full_str(String raw, String expd) {fxt.Test_html_full_str(raw, expd);}
public void Test_html_full_frag(String raw, String expd) {fxt.Test_html_full_frag(raw, expd);}
public String Frag_html_full() {

View File

@@ -15,10 +15,10 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.brys.fmtrs.*;
class Imap_html_fmtrs {
public static final Bry_fmtr
public class Imap_html_fmtrs {
public static final Bry_fmtr
All = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<div id='imap_div_~{imap_id}' class=\"noresize\"~{desc_style}>~{map}~{img}"
, " </div>"

View File

@@ -15,18 +15,20 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*;
import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
import gplx.xowa.parsers.*;
class Imap_img_fmtr_arg implements gplx.core.brys.Bfr_arg {
private Xoh_wtr_ctx hctx; private Imap_map map; private Imap_xtn_mgr xtn_mgr; // private byte[] src;
private int img_elem_id, img_w, img_h;
private byte[] img_alt, img_src, img_cls, img_href, lnki_ttl;
private Int_2_ref margin_calc = new Int_2_ref();
public void Init(Xoh_wtr_ctx hctx, Imap_xtn_mgr xtn_mgr, Imap_map map, byte[] src, int img_elem_id, byte[] img_alt, byte[] img_src, int img_w, int img_h, byte[] img_cls, byte[] img_href, byte[] lnki_ttl) {
this.hctx = hctx; this.map = map; this.xtn_mgr = xtn_mgr; // this.src = src;
import gplx.xowa.xtns.imaps.itms.*;
public class Imap_img_arg implements gplx.core.brys.Bfr_arg {
private final Xoh_wtr_ctx hctx; private final Imap_map map; private final Imap_xtn_mgr xtn_mgr;
private final int img_elem_id, img_w, img_h;
private final byte[] img_alt, img_src, img_cls, img_href, lnki_ttl;
private final Int_2_ref margin_calc = new Int_2_ref();
public Imap_img_arg(Xoh_wtr_ctx hctx, Imap_xtn_mgr xtn_mgr, Imap_map map
, int img_elem_id, byte[] img_alt, byte[] img_src, int img_w, int img_h, byte[] img_cls, byte[] img_href, byte[] lnki_ttl) {
this.hctx = hctx; this.map = map; this.xtn_mgr = xtn_mgr;
this.img_elem_id = img_elem_id; this.img_w = img_w; this.img_h = img_h;
this.img_alt = img_alt; this.img_src = img_src; this.img_cls = img_cls; this.img_href = img_href;
this.lnki_ttl = lnki_ttl;
@@ -34,31 +36,31 @@ class Imap_img_fmtr_arg implements gplx.core.brys.Bfr_arg {
public void Bfr_arg__add(Bry_bfr bfr) {
Bry_fmtr fmtr = Imap_html_fmtrs.Img_anchor_none;
byte[] anchor_href = Bry_.Empty, anchor_text = Bry_.Empty;
Imap_itm_dflt itm_dflt = map.Dflt();
Imap_part_dflt itm_dflt = map.Dflt();
if (hctx.Mode_is_hdump()) {
Bry_bfr tmp_bfr = xtn_mgr.Tmp_bfr;
byte[] data_xowa_image = Xoh_file_html_fmtr__hdump.Bld_xowa_image_data(tmp_bfr, Xop_lnki_type.Id_none, img_w, img_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null);
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, lnki_ttl);
byte[] usemap = tmp_bfr.Add(Imap_xtn_mgr.Bry__usemap__html).Add_int_variable(map.Id()).Add_byte_quote().To_bry_and_clear();
Xoh_file_html_fmtr__hdump.Bld_anch_n(tmp_bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.Tid__thumbimage, Bry_.Empty, Bry_.Empty, usemap);
bfr.Add_bfr_and_clear(tmp_bfr);
Bry_bfr tmp_bfr = Bry_bfr_.Get();
try {
byte[] data_xowa_image = Xoh_file_html_fmtr__hdump.Bld_xowa_image_data(tmp_bfr, Xop_lnki_type.Id_none, img_w, img_h, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null);
byte[] data_xowa_title = Gfh_atr_.Make(tmp_bfr, Xoh_img_xoimg_data.Bry__data_xowa_title, lnki_ttl);
byte[] usemap = tmp_bfr.Add(Imap_xtn_mgr.Bry__usemap__html).Add_int_variable(map.Id()).Add_byte_quote().To_bry_and_clear();
Xoh_file_html_fmtr__hdump.Bld_anch_n(tmp_bfr, data_xowa_title, data_xowa_image, Xoh_img_cls_.Tid__thumbimage, Bry_.Empty, Bry_.Empty, usemap);
bfr.Add_byte_nl().Add_byte_repeat(Byte_ascii.Space, 6);
bfr.Add_bfr_and_clear(tmp_bfr);
} finally {tmp_bfr.Mkr_rls();}
}
else {
Xoh_arg_img_core img_core_fmtr = xtn_mgr.Img_core_fmtr;
Xoh_arg_img_core img_core_fmtr = xtn_mgr.Img_core_arg();
img_core_fmtr.Init(img_elem_id, img_src, img_w, img_h);
if (itm_dflt != null) {
// Xowe_wiki wiki = map.Xtn_mgr().Wiki();
// if (src.length != 0) // imap update will pass 0 src
// Imap_link_owner_.Write(itm_dflt, wiki.Appe(), wiki, hctx, src);
fmtr = itm_dflt.Link_tid() == Xop_tkn_itm_.Tid_lnki ? Imap_html_fmtrs.Img_anchor_lnki : Imap_html_fmtrs.Img_anchor_lnke;
anchor_href = itm_dflt.Link_href();
anchor_text = itm_dflt.Link_text();
}
fmtr.Bld_bfr_many(bfr, map.Id(), img_elem_id, img_alt, img_core_fmtr, img_cls, anchor_href, anchor_text);
}
Imap_itm_desc itm_desc = map.Desc();
Imap_part_desc itm_desc = map.Desc();
if (itm_desc != null) {
Imap_desc_tid.Calc_desc_margins(margin_calc, itm_desc.Desc_tid(), img_w, img_h);
Imap_desc_tid.Calc_margins(margin_calc, itm_desc.Desc_tid(), img_w, img_h);
Imap_html_fmtrs.Desc_main.Bld_bfr_many(bfr, margin_calc.Val_0(), margin_calc.Val_1(), img_href, xtn_mgr.Desc_msg(), xtn_mgr.Desc_icon_url());
}
}

View File

@@ -0,0 +1,31 @@
/*
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.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.brys.fmtrs.*;
import gplx.xowa.xtns.imaps.itms.*;
public class Imap_map_arg implements gplx.core.brys.Bfr_arg {
private final int imap_id;
private final Imap_shapes_arg shapes_arg;
public Imap_map_arg(int imap_id, Imap_part_shape[] shapes, double scale) {
this.imap_id = imap_id;
this.shapes_arg = new Imap_shapes_arg(shapes, scale);
}
public void Bfr_arg__add(Bry_bfr bfr) {
Imap_html_fmtrs.Map.Bld_bfr_many(bfr, imap_id, shapes_arg);
}
}

View File

@@ -15,19 +15,21 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.primitives.*;
class Imap_pts_fmtr_arg implements gplx.core.brys.Bfr_arg {
private double scale = 1; private Double_obj_val[] pts;
public void Scale_(double v) {this.scale = v;}
public class Imap_shape_pts_arg implements gplx.core.brys.Bfr_arg {
private final double scale; private Double_obj_val[] pts;
public Imap_shape_pts_arg(double scale) {
this.scale = scale;
}
public void Pts_(Double_obj_val[] v) {this.pts = v;}
public void Bfr_arg__add(Bry_bfr bfr) {
int pts_len = pts.length;
for (int i = 0; i < pts_len; ++i) {
Double_obj_val pt = pts[i];
if (i != 0) bfr.Add_byte_comma();
int pt_int = (int)pt.Val();
pt_int = (int)Math_.Round(scale * pt_int, 0);
if (i != 0) bfr.Add_byte_comma();
bfr.Add_int_variable(pt_int);
}
}

View 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.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.xowa.xtns.imaps.itms.*; import gplx.core.brys.fmtrs.*;
public class Imap_shapes_arg implements gplx.core.brys.Bfr_arg {
private final Imap_part_shape[] shapes;
private final Imap_shape_pts_arg pts_arg;
public Imap_shapes_arg(Imap_part_shape[] shapes, double scale) {
this.shapes = shapes;
this.pts_arg = new Imap_shape_pts_arg(scale);
}
public void Bfr_arg__add(Bry_bfr bfr) {
Bry_fmtr fmtr = Imap_html_fmtrs.Area;
int len = shapes.length;
for (int i = 0; i < len; ++i)
Fmt_shape(bfr, fmtr, pts_arg, shapes[i]);
}
public static void Fmt_shape(Bry_bfr bfr, Bry_fmtr fmtr, Imap_shape_pts_arg pts_arg, Imap_part_shape shape) {
pts_arg.Pts_(shape.Shape_pts());
fmtr.Bld_bfr_many(bfr
, shape.Link_href()
, Imap_part_.To_shape_key(shape.Part_tid())
, pts_arg
, shape.Link_text()
);
}
}

View File

@@ -15,19 +15,19 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*;
public class Imap_xnde_html_itm_tst {
@Before public void init() {fxt.Reset();} private Imap_html_bldr_fxt fxt = new Imap_html_bldr_fxt();
package gplx.xowa.xtns.imaps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import org.junit.*; import gplx.xowa.xtns.imaps.itms.*;
public class Imap_shapes_arg_tst {
@Before public void init() {fxt.Reset();} private Imap_shapes_arg_fxt fxt = new Imap_shapes_arg_fxt();
@Test public void Rect() {fxt.Test_shape_html(fxt.itm_rect_("[[A|b]]", 1, 2, 3, 4), "\n <area href=\"/wiki/A\" shape=\"rect\" coords=\"1,2,3,4\" alt=\"b\" title=\"b\"/>");}
@Test public void Circle() {fxt.Test_shape_html(fxt.itm_circle_("[[A|b]]", 1, 2, 3 ), "\n <area href=\"/wiki/A\" shape=\"circle\" coords=\"1,2,3\" alt=\"b\" title=\"b\"/>");}
@Test public void Poly() {fxt.Test_shape_html(fxt.itm_poly_("[[A|b]]", 1, 2, 3, 4), "\n <area href=\"/wiki/A\" shape=\"poly\" coords=\"1,2,3,4\" alt=\"b\" title=\"b\"/>");}
}
class Imap_html_bldr_fxt extends Imap_fxt_base {
private Bry_bfr bfr = Bry_bfr.new_();
private Imap_pts_fmtr_arg pts_fmtr_arg = new Imap_pts_fmtr_arg();
public void Test_shape_html(Imap_itm_shape shape, String expd) {
Imap_shapes_fmtr.Fmt_shape(bfr, Imap_html_fmtrs.Area, pts_fmtr_arg, shape);
class Imap_shapes_arg_fxt extends Imap_base_fxt {
public void Test_shape_html(Imap_part_shape shape, String expd) {
Bry_bfr bfr = Bry_bfr_.New();
Imap_shape_pts_arg pts_fmtr_arg = new Imap_shape_pts_arg(1);
Imap_shapes_arg.Fmt_shape(bfr, Imap_html_fmtrs.Area, pts_fmtr_arg, shape);
Tfds.Eq(expd, bfr.To_str_and_clear());
}
}

View File

@@ -15,26 +15,42 @@ 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.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
package gplx.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.primitives.*; import gplx.core.btries.*;
class Imap_desc_tid {
public class Imap_desc_tid {
public static final byte Tid_tr = 0, Tid_br = 1, Tid_bl = 2, Tid_tl = 3, Tid_none = 4, Tid_null = 5;
public static final byte[]
public static final byte[]
Key_tr = Bry_.new_a7("top-right")
, Key_br = Bry_.new_a7("bottom-right")
, Key_bl = Bry_.new_a7("bottom-left")
, Key_tl = Bry_.new_a7("top-left")
, Key_none = Bry_.new_a7("none")
;
public static Btrie_slim_mgr trie_(Xowe_wiki wiki) {
public static byte Parse_to_tid(Btrie_slim_mgr trie, byte[] src, int bgn, int end) {
Object rv = trie.Match_bgn(src, bgn, end);
return rv == null ? Tid_null : ((Byte_obj_val)rv).Val();
}
public static void Calc_margins(Int_2_ref rv, byte tid, int html_w, int html_h) {
int margin_l
= tid == Tid_tl || tid == Tid_bl
? 0
: html_w - 20;
int margin_t
= tid == Tid_tl || tid == Tid_tr
? -html_h + 1 // 1px hack for IE, to stop it poking out the top
: -20;
rv.Val_all_(margin_l, margin_t);
}
public static Btrie_slim_mgr New_trie(Xowe_wiki wiki) {
Btrie_slim_mgr rv = Btrie_slim_mgr.ci_u8();
trie_add(rv, Key_tr, Key_br, Key_bl, Key_tl, Key_none);
Add_to_trie(rv, Key_tr, Key_br, Key_bl, Key_tl, Key_none);
byte[][] lang_types = Parse_lang_types(wiki);
if (lang_types != null)
trie_add(rv, lang_types);
Add_to_trie(rv, lang_types);
return rv;
}
private static void trie_add(Btrie_slim_mgr trie, byte[]... ary) {
private static void Add_to_trie(Btrie_slim_mgr trie, byte[]... ary) {
trie.Add_bry_byte(ary[0] ,Tid_tr);
trie.Add_bry_byte(ary[1] ,Tid_br);
trie.Add_bry_byte(ary[2] ,Tid_bl);
@@ -44,28 +60,11 @@ class Imap_desc_tid {
private static byte[][] Parse_lang_types(Xowe_wiki wiki) {
byte[] val = wiki.Msg_mgr().Val_by_key_obj("imagemap_desc_types");
if (Bry_.Len_eq_0(val)) return null; // no msg in lang; return;
byte[][] ary = Bry_split_.Split(val, Byte_ascii.Comma); // msg is 5 words concatenated by comma: EX:top-right,bottom-right-bottom-left,top-left,none
byte[][] ary = Bry_split_.Split(val, Byte_ascii.Comma); // msg is 5 words concatenated by comma: EX:top-right,bottom-right-bottom-left,top-left,none
int ary_len = ary.length;
if (ary_len != 5) wiki.Appe().Usr_dlg().Warn_many("", "", "imap_desc does not have 5 items; wiki=~{0} val=~{1}", wiki.Domain_bry(), val);
for (int i = 0; i < 5; ++i)
ary[i] = Bry_.Trim(ary[i]); // note that items will have trailing ws; EX: "top-right, bottom-right, bottom-left, top-left, none"
return ary;
}
public static byte parse(Btrie_slim_mgr trie, byte[] src, int bgn, int end) {
Object rv = trie.Match_bgn(src, bgn, end);
return rv == null ? Tid_null : ((Byte_obj_val)rv).Val();
}
public static void Calc_desc_margins(Int_2_ref rv, byte tid, int html_w, int html_h) {
int margin_l
= tid == Tid_tl || tid == Tid_bl
? 0
: html_w - 20
;
int margin_t
= tid == Tid_tl || tid == Tid_tr
? -html_h + 1 // 1px hack for IE, to stop it poking out the top
: -20
;
rv.Val_all_(margin_l, margin_t);
}
}

View File

@@ -0,0 +1,23 @@
/*
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.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
public class Imap_err {
public Imap_err(int itm_idx, String err_msg) {this.itm_idx = itm_idx; this.err_msg = err_msg;}
public int Itm_idx() {return itm_idx;} private final int itm_idx;
public String Err_msg() {return err_msg;} private final String err_msg;
}

View File

@@ -0,0 +1,25 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.xowa.parsers.*;
public interface Imap_link_owner {
int Link_tid(); void Link_tid_(int v, Xop_tkn_itm tkn);
Xop_tkn_itm Link_tkn();
void Link_href_(byte[] v);
void Link_text_(byte[] v);
}

View File

@@ -15,18 +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.xtns.imaps; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
package gplx.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.primitives.*; import gplx.core.net.*;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkes.*;
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.lnkes.*;
interface Imap_link_owner {
int Link_tid();
Xop_tkn_itm Link_tkn();
void Link_tid_(int v, Xop_tkn_itm tkn);
void Link_href_(byte[] v);
void Link_text_(byte[] v);
}
class Imap_link_owner_ {
public class Imap_link_owner_ {
public static void Init(Imap_link_owner link_owner, Xoae_app app, Xowe_wiki wiki, byte[] src, Xop_tkn_itm tkn) {
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
try {
@@ -82,17 +75,3 @@ class Imap_link_owner_ {
finally {bfr.Mkr_rls();} // release buffer in case of null error; PAGE:de.u:PPA/Raster/TK25/51/18/12/20; DATE:2015-02-02
}
}
class Imap_itm_shape implements Imap_itm, Imap_link_owner {
public Imap_itm_shape(byte shape_tid, Double_obj_val[] shape_pts) {
this.shape_tid = shape_tid;
this.shape_pts = shape_pts;
}
public byte Itm_tid() {return shape_tid;} private byte shape_tid;
public Double_obj_val[] Shape_pts() {return shape_pts;} private Double_obj_val[] shape_pts;
public int Link_tid() {return link_tid;} private int link_tid;
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn;
public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
public byte[] Link_href() {return link_href;} public void Link_href_(byte[] v) {this.link_href = v;} private byte[] link_href;
public byte[] Link_text() {return link_text;} public void Link_text_(byte[] v) {this.link_text = v;} private byte[] link_text;
public static final byte Tid_default = 0, Tid_rect = 4, Tid_circle = 3, Tid_poly = 5;
}

View File

@@ -0,0 +1,21 @@
/*
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.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
public interface Imap_part {
byte Part_tid();
}

View File

@@ -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.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
public class Imap_part_ {
public static final byte
Tid_invalid = 0
, Tid_img = 1
, Tid_desc = 2
, Tid_comment = 3
, Tid_dflt = 4
, Tid_shape_rect = 5
, Tid_shape_circle = 6
, Tid_shape_poly = 7
;
public static final byte[]
Key_dflt = Bry_.new_a7("default")
, Key_shape_rect = Bry_.new_a7("rect")
, Key_shape_circle = Bry_.new_a7("circle")
, Key_shape_poly = Bry_.new_a7("poly")
;
public static byte[] To_shape_key(byte v) {
switch (v) {
case Tid_shape_rect : return Key_shape_rect;
case Tid_shape_circle : return Key_shape_circle;
case Tid_shape_poly : return Key_shape_poly;
default : throw Err_.new_unhandled(v);
}
}
}

View File

@@ -0,0 +1,23 @@
/*
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.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
public class Imap_part_desc implements Imap_part {
public Imap_part_desc(byte desc_tid) {this.desc_tid = desc_tid;}
public byte Part_tid() {return Imap_part_.Tid_desc;}
public byte Desc_tid() {return desc_tid;} private final byte desc_tid;
}

View File

@@ -0,0 +1,26 @@
/*
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.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.xowa.parsers.*;
public class Imap_part_dflt implements Imap_part, Imap_link_owner {
public byte Part_tid() {return Imap_part_.Tid_dflt;}
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn;
public int Link_tid() {return link_tid;} private int link_tid; public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
public byte[] Link_href() {return link_href;} private byte[] link_href; public void Link_href_(byte[] v) {this.link_href = v;}
public byte[] Link_text() {return link_text;} private byte[] link_text; public void Link_text_(byte[] v) {this.link_text = v;}
}

View File

@@ -0,0 +1,24 @@
/*
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.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.xowa.parsers.lnkis.*;
public class Imap_part_img implements Imap_part {
public Imap_part_img(Xop_lnki_tkn img_link) {this.img_link = img_link;}
public byte Part_tid() {return Imap_part_.Tid_img;}
public Xop_lnki_tkn Img_link() {return img_link;} private final Xop_lnki_tkn img_link;
}

View File

@@ -0,0 +1,34 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.imaps.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
import gplx.core.primitives.*;
import gplx.xowa.parsers.*;
public class Imap_part_shape implements Imap_part, Imap_link_owner {
public Imap_part_shape(byte shape_tid, Double_obj_val[] shape_pts) {
this.shape_tid = shape_tid;
this.shape_pts = shape_pts;
}
public byte Part_tid() {return shape_tid;} private final byte shape_tid;
public Double_obj_val[] Shape_pts() {return shape_pts;} private final Double_obj_val[] shape_pts;
public int Link_tid() {return link_tid;} private int link_tid;
public Xop_tkn_itm Link_tkn() {return link_tkn;} private Xop_tkn_itm link_tkn; public void Link_tid_(int tid, Xop_tkn_itm tkn) {link_tid = tid; link_tkn = tkn;}
public byte[] Link_href() {return link_href;} private byte[] link_href; public void Link_href_(byte[] v) {this.link_href = v;}
public byte[] Link_text() {return link_text;} private byte[] link_text; public void Link_text_(byte[] v) {this.link_text = v;}
public static final byte Tid_default = 0, Tid_rect = 4, Tid_circle = 3, Tid_poly = 5;
}

View File

@@ -59,7 +59,7 @@ class Indicator_html_bldr_fxt {
indicators.Add(xnde);
}
public void Test_bld(String expd) {
Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
page.Html_data().Indicators().Bfr_arg__add(tmp_bfr);
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
}

View File

@@ -21,6 +21,6 @@ public class Indicator_xtn_mgr extends Xox_mgr_base {
public Indicator_xtn_mgr() {
}
@Override public boolean Enabled_default() {return false;}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("Indicator");
@Override public Xox_mgr Clone_new() {return new Indicator_xtn_mgr();}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("Indicator");
@Override public Xox_mgr Xtn_clone_new() {return new Indicator_xtn_mgr();}
}

View File

@@ -22,11 +22,11 @@ import gplx.xowa.wikis.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wiki
import gplx.xowa.htmls.hrefs.*;
import gplx.xowa.wikis.nss.*;
class Insider_xtn_skin_itm implements Xopg_xtn_skin_itm {
private List_adp itms = List_adp_.new_();
private List_adp itms = List_adp_.New();
private Insider_html_bldr html_bldr;
public Insider_xtn_skin_itm(Insider_html_bldr html_bldr) {this.html_bldr = html_bldr;}
public byte Tid() {return Xopg_xtn_skin_itm_tid.Tid_sidebar;}
public byte[] Key() {return KEY;} public static final byte[] KEY = Bry_.new_a7("Insider");
public byte[] Key() {return KEY;} public static final byte[] KEY = Bry_.new_a7("Insider");
public List_adp Itms() {return itms;}
public void Add(byte[] itm) {itms.Add(itm);}
public void Write(Bry_bfr bfr, Xoae_page page) {
@@ -35,7 +35,7 @@ class Insider_xtn_skin_itm implements Xopg_xtn_skin_itm {
}
public class Insider_html_bldr implements gplx.core.brys.Bfr_arg {
private Insider_xtn_mgr xtn_mgr;
private Bry_bfr tmp_ttl = Bry_bfr.reset_(255);
private Bry_bfr tmp_ttl = Bry_bfr_.Reset(255);
private List_adp list; private int list_len;
private Hash_adp_bry hash = Hash_adp_bry.cs();
public Insider_html_bldr(Insider_xtn_mgr xtn_mgr) {this.xtn_mgr = xtn_mgr;}
@@ -59,7 +59,7 @@ public class Insider_html_bldr implements gplx.core.brys.Bfr_arg {
fmtr_itm.Bld_bfr(bfr, user_ttl_bry, user_ttl.Page_txt());
}
}
private static final Bry_fmtr
private static final Bry_fmtr
fmtr_grp = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<div id='p-insiders' class='portal' role='navigation'>"
, " <h3>~{hdr}</h3>"

View File

@@ -55,7 +55,7 @@ class Insider_html_bldr_fxt {
skin_itm.Add(Bry_.new_u8(lnki_ttl));
}
public void Test_bld(String expd) {
Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
skin_itm.Write(tmp_bfr, page);
Tfds.Eq_str_lines(expd, tmp_bfr.To_str_and_clear());
}

View File

@@ -22,8 +22,8 @@ public class Insider_xtn_mgr extends Xox_mgr_base {
html_bldr = new Insider_html_bldr(this);
}
@Override public boolean Enabled_default() {return false;}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("Insider");
@Override public Xox_mgr Clone_new() {return new Insider_xtn_mgr();}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("Insider");
@Override public Xox_mgr Xtn_clone_new() {return new Insider_xtn_mgr();}
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
this.wiki = wiki;
if (!Enabled()) return;

View File

@@ -22,8 +22,8 @@ import gplx.xowa.wikis.*;
import gplx.xowa.parsers.*;
public class Listing_xtn_mgr extends Xox_mgr_base {
@Override public boolean Enabled_default() {return false;}
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_a7("Listings");
@Override public Xox_mgr Clone_new() {return new Listing_xtn_mgr();}
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_a7("Listings");
@Override public Xox_mgr Xtn_clone_new() {return new Listing_xtn_mgr();}
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
if (!Enabled()) return;
this.Reset(wiki);

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.xtns.lst; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
public class Lst_section_nde_mgr {
public int Count() {return list.Count();} private List_adp list = List_adp_.new_();
public int Count() {return list.Count();} private List_adp list = List_adp_.New();
public Lst_section_nde Get_at(int i) {return (Lst_section_nde)list.Get_at(i);}
public void Add(Lst_section_nde xnde) {list.Add(xnde);}
public void Clear() {list.Clear();}

View File

@@ -112,7 +112,7 @@ class Map_math {// REF.MW:MapSources_math.php
}
step = 2;
}
private static final byte[] Bry_deg = Bry_.new_u8("°"), Bry_quot = Bry_.new_a7("&quot;");
private static final byte[] Bry_deg = Bry_.new_u8("°"), Bry_quot = Bry_.new_a7("&quot;");
public byte[] Get_dms(byte[] plus, byte[] minus) { // REF.MW: getDMSString
if (step < 2) Set_coord();
double deg = coord_deg;
@@ -244,7 +244,7 @@ class Map_math {// REF.MW:MapSources_math.php
else if (val == -1) return 9;
else return 4;
}
private Bry_bfr tmp_bfr = Bry_bfr.reset_(32);
private Bry_bfr tmp_bfr = Bry_bfr_.Reset(32);
public static byte[] Parse_input_normalize(Bry_bfr bfr, byte[] src) {
/*
$w = str_replace( array( '', '', '' ), "'", $input );
@@ -260,23 +260,23 @@ class Map_math {// REF.MW:MapSources_math.php
return Bry_.Trim(src);
}
private static final byte Dir_unknown_id = 0, Dir_lat_id = 1, Dir_long_id = 2;
public static final byte[] Dir_lat_bry = Bry_.new_a7("lat"), Dir_long_bry = Bry_.new_a7("long");
private static final Btrie_slim_mgr Dir_trie = Btrie_slim_mgr.ci_a7() // NOTE:ci.ascii:MW_const.en
public static final byte[] Dir_lat_bry = Bry_.new_a7("lat"), Dir_long_bry = Bry_.new_a7("long");
private static final Btrie_slim_mgr Dir_trie = Btrie_slim_mgr.ci_a7() // NOTE:ci.ascii:MW_const.en
.Add_bry_byte(Dir_lat_bry , Dir_lat_id)
.Add_bry_byte(Dir_long_bry , Dir_long_id)
;
private static final byte[]
private static final byte[]
Compass_N = new byte[] {Byte_ascii.Ltr_N}
, Compass_E = new byte[] {Byte_ascii.Ltr_E}
, Compass_S = new byte[] {Byte_ascii.Ltr_S}
, Compass_W = new byte[] {Byte_ascii.Ltr_W}
;
private static final byte Input_byte_degree = Byte_ascii.Slash; // NOTE: ugly cheat to avoid using multi-byte char; note that all "/" are swapped out to " ", so any remaining "/" was added by the normalizer; EX: "123° 4/5" -> "123/ 4 5"
private static final byte[] Input_units = new byte[] {Input_byte_degree, Byte_ascii.Apos, Byte_ascii.Quote, Byte_ascii.Space};
private static final int Input_units_len = Input_units.length;
private static final Btrie_slim_mgr Trie__normalize__apos = Btrie_slim_mgr.cs()
private static final byte[] Input_units = new byte[] {Input_byte_degree, Byte_ascii.Apos, Byte_ascii.Quote, Byte_ascii.Space};
private static final int Input_units_len = Input_units.length;
private static final Btrie_slim_mgr Trie__normalize__apos = Btrie_slim_mgr.cs()
.Add_replace_many (Byte_ascii.Apos_bry , "", "", "");
private static final Btrie_slim_mgr Trie__normalize__rest = Btrie_slim_mgr.cs()
private static final Btrie_slim_mgr Trie__normalize__rest = Btrie_slim_mgr.cs()
.Add_replace_many ("' " , "'")
.Add_replace_many ("\" " , "\"", "''", "", "", "")
.Add_replace_many (Byte_ascii.Dash_bry , "-", "") // NOTE: emdash and endash
@@ -286,5 +286,5 @@ class Map_math {// REF.MW:MapSources_math.php
.Add_replace_many (" S" , "S", "s")
.Add_replace_many (" E" , "E", "e")
.Add_replace_many (" W" , "W", "w");
public static final Map_math Instance = new Map_math();
public static final Map_math Instance = new Map_math();
}

View File

@@ -24,7 +24,7 @@ public class Message_target_func extends Pf_func_base {
@Override public Pf_func New(int id, byte[] name) {return new Message_target_func().Name_(name);}
@Override public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {
byte[] argx = Eval_argx(ctx, src, caller, self); if (argx == null) return;
bfr.Add(Xop_tkn_.Lnki_bgn).Add(argx).Add(Xop_tkn_.Lnki_end); // TODO: evaluate 2nd arg; {{#target:A|en.wikipedia.org}}
bfr.Add(Xop_tkn_.Lnki_bgn).Add(argx).Add(Xop_tkn_.Lnki_end); // TODO_OLD: evaluate 2nd arg; {{#target:A|en.wikipedia.org}}
}
public static final Message_target_func Instance = new Message_target_func(); Message_target_func() {}
public static final Message_target_func Instance = new Message_target_func(); Message_target_func() {}
}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.math; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.brys.fmtrs.*; import gplx.core.strings.*; import gplx.core.consoles.*; import gplx.core.envs.*;
import gplx.xowa.apps.progs.*;
public class Xof_math_mgr implements GfoInvkAble {
public class Xof_math_mgr implements Gfo_invk {
private static final gplx.core.security.Hash_algo md5_hash = gplx.core.security.Hash_algo_.New__md5();
private Xoae_app app;
public Process_adp Cmd_convert_tex_to_dvi() {return cmd_convert_tex_to_dvi;} private Process_adp cmd_convert_tex_to_dvi = new Process_adp();
@@ -100,7 +100,7 @@ public class Xof_math_mgr implements GfoInvkAble {
else if (ctx.Match(k, Invk_renderer)) return renderer_is_mathjax ? "mathjax" : "latex";
else if (ctx.Match(k, Invk_renderer_)) renderer_is_mathjax = String_.Eq(m.ReadStr("v"), "mathjax");
else if (ctx.Match(k, Invk_renderer_list)) return Options_renderer_list;
else return GfoInvkAble_.Rv_unhandled;
else return Gfo_invk_.Rv_unhandled;
return this;
} private static final String Invk_enabled = "enabled", Invk_enabled_ = "enabled_", Invk_renderer = "renderer", Invk_renderer_ = "renderer_", Invk_renderer_list = "renderer_list";
private static Keyval[] Options_renderer_list = Keyval_.Ary(Keyval_.new_("mathjax", "MathJax"), Keyval_.new_("latex", "LaTeX"));

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.math; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.btries.*;
public class Xof_math_subst_regy {
Bry_bfr bfr = Bry_bfr.new_();
Bry_bfr bfr = Bry_bfr_.New();
public byte[] Subst(byte[] src) {
if (!init) Init();
int src_len = src.length;

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.math.texvcs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
import gplx.xowa.xtns.math.texvcs.tkns.*; import gplx.xowa.xtns.math.texvcs.funcs.*;
class Texvc_checker {
private final List_adp func_stack = List_adp_.new_();
private final List_adp func_stack = List_adp_.New();
private Texvc_root root; private int root_idx, root_len;
private boolean fail;
public void Check(byte[] src, Texvc_root root) {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.math.texvcs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.math.*;
import org.junit.*; import gplx.xowa.xtns.math.texvcs.tkns.*; import gplx.xowa.xtns.math.texvcs.funcs.*;
public class Texvc_parser_tst {
private final Texvc_parser_fxt fxt = new Texvc_parser_fxt();
private final Texvc_parser_fxt fxt = new Texvc_parser_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Text() {
fxt.Test_parse("abc"
@@ -78,8 +78,8 @@ public class Texvc_parser_tst {
}
}
class Texvc_tkn_mkr_fxt {
private final Texvc_ctx ctx;
private final Texvc_root root;
private final Texvc_ctx ctx;
private final Texvc_root root;
public Texvc_tkn_mkr_fxt(Texvc_ctx ctx) {
this.ctx = ctx;
this.root = new Texvc_root();
@@ -115,16 +115,16 @@ class Texvc_tkn_mkr_fxt {
}
}
class Texvc_parser_fxt {
protected final Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
private final Texvc_parser parser = new Texvc_parser();
private final Texvc_root actl_root;
private final Texvc_ctx ctx;
protected final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255);
private final Texvc_parser parser = new Texvc_parser();
private final Texvc_root actl_root;
private final Texvc_ctx ctx;
public Texvc_parser_fxt() {
this.actl_root = new Texvc_root();
this.ctx = new Texvc_ctx();
this.mkr_fxt = new Texvc_tkn_mkr_fxt(ctx);
}
public Texvc_tkn_mkr_fxt Mkr() {return mkr_fxt;} private final Texvc_tkn_mkr_fxt mkr_fxt;
public Texvc_tkn_mkr_fxt Mkr() {return mkr_fxt;} private final Texvc_tkn_mkr_fxt mkr_fxt;
public void Clear() {
mkr_fxt.Clear();
actl_root.Init_as_root(ctx.Tkn_mkr(), Bry_.Empty, 0, 8);

View File

@@ -18,20 +18,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pagebanners; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.core.primitives.*;
public class Pgbnr_cfg {
private final Hash_adp ns_hash = Hash_adp_.new_(); private final Int_obj_ref tmp_ns_key = Int_obj_ref.neg1_();
private final Hash_adp ns_hash = Hash_adp_.New(); private final Int_obj_ref tmp_ns_key = Int_obj_ref.New_neg1();
public Pgbnr_cfg(boolean enabled, boolean enable_heading_override, boolean enable_default_banner, int[] ns_ary, int dflt_img_wdata_prop, byte[] dflt_img_title, int[] standard_sizes) {
this.enabled = enabled; this.enable_heading_override = enable_heading_override; this.enable_default_banner = enable_default_banner;
this.standard_sizes = standard_sizes;
this.dflt_img_wdata_prop = dflt_img_wdata_prop; this.dflt_img_title = dflt_img_title;
for (int ns : ns_ary)
this.ns_hash.Add_as_key_and_val(Int_obj_ref.new_(ns));
this.ns_hash.Add_as_key_and_val(Int_obj_ref.New(ns));
}
public final boolean enabled;
public final boolean enable_heading_override;
public final boolean enable_default_banner;
public final int dflt_img_wdata_prop;
public final byte[] dflt_img_title;
public final int[] standard_sizes;
public final boolean enabled;
public final boolean enable_heading_override;
public final boolean enable_default_banner;
public final int dflt_img_wdata_prop;
public final byte[] dflt_img_title;
public final int[] standard_sizes;
public boolean Chk_pgbnr_allowed(Xoa_ttl ttl, Xowe_wiki wiki) {
boolean enabled_in_ns = ns_hash.Has(tmp_ns_key.Val_(ttl.Ns().Id()));
return enabled_in_ns // chk if ns allows banner

View File

@@ -32,7 +32,7 @@ public class Pgbnr_func extends Pf_func_base {
boolean bottomtoc = false;;
double data_pos_x = 0, data_pos_y = 0;
List_adp icons_list = null;
Bry_bfr tmp_bfr = Bry_bfr.new_();
Bry_bfr tmp_bfr = Bry_bfr_.New();
int args_len = self.Args_len();
Xop_func_arg_itm func_arg = new Xop_func_arg_itm();
for (int i = 0; i < args_len; ++i) {
@@ -56,7 +56,7 @@ public class Pgbnr_func extends Pf_func_base {
&& Bry_.Len_gt_0(val) // if ( !isset( $$value ) )
) { // REF.MW:addIcons
tid = Arg__icon;
if (icons_list == null) icons_list = List_adp_.new_();
if (icons_list == null) icons_list = List_adp_.New();
byte[] icon_key = Bry_.Mid(key, 5);
byte[] icon_name = Xop_sanitizer.Escape_cls(icon_key);
byte[] icon_title = icon_name;
@@ -128,7 +128,7 @@ public class Pgbnr_func extends Pf_func_base {
}
public static byte[] Get_banner_html(Xowe_wiki wiki, Xop_ctx ctx, byte[] src, Pgbnr_cfg cfg, Xoa_ttl banner_ttl, Pgbnr_itm itm) {
byte[][] urls = Get_standard_size_urls(wiki, cfg, banner_ttl); if (urls == null) return null;
Bry_bfr tmp_bfr = Bry_bfr.new_();
Bry_bfr tmp_bfr = Bry_bfr_.New();
int urls_len = urls.length;
int[] sizes = cfg.standard_sizes;
for (int i = 0; i < urls_len; ++i) {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pagebanners; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import org.junit.*; import gplx.core.brys.*; import gplx.xowa.wikis.pages.skins.*;
public class Pgbnr_func_tst {
private final Pgbnr_func_fxt fxt = new Pgbnr_func_fxt();
private final Pgbnr_func_fxt fxt = new Pgbnr_func_fxt();
@Test public void Basic() {
fxt.Test__parse__eq("{{PAGEBANNER:A.png|icon-star=Star_article}}", String_.Concat_lines_nl_apos_skip_last
( "<div class='ext-wpb-pagebanner noprint pre-content'>"
@@ -35,7 +35,7 @@ public class Pgbnr_func_tst {
}
}
class Pgbnr_func_fxt {
private final Xop_fxt fxt;
private final Xop_fxt fxt;
public Pgbnr_func_fxt() {
Xoae_app app = Xoa_app_fxt.Make__app__edit();
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app, "en.wikivoyage.org");
@@ -44,7 +44,7 @@ class Pgbnr_func_fxt {
public void Test__parse__eq(String raw, String expd) {
fxt.Exec_parse_page_all_as_str(raw);
Bfr_arg arg = fxt.Wiki().Xtn_mgr().Xtn_pgbnr().Write_html(fxt.Ctx(), fxt.Page(), null, null);
Bry_bfr bfr = Bry_bfr.new_();
Bry_bfr bfr = Bry_bfr_.New();
arg.Bfr_arg__add(bfr);
Tfds.Eq_str_lines(expd, bfr.To_str_and_clear());
}

View File

@@ -21,12 +21,12 @@ import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.wik
import gplx.xowa.htmls.core.htmls.*;
public class Pgbnr_xtn_mgr extends Xox_mgr_base implements Bfr_arg {
@Override public byte[] Xtn_key() {return Xtn_key_static;} public static final byte[] Xtn_key_static = Bry_.new_a7("pagebanner");
@Override public Xox_mgr Clone_new() {return new Pgbnr_xtn_mgr();}
@Override public Xox_mgr Xtn_clone_new() {return new Pgbnr_xtn_mgr();}
public Pgbnr_cfg Cfg() {return cfg;} private Pgbnr_cfg cfg;
public Mustache_tkn_itm Template_root() {return template_root;} private Mustache_tkn_itm template_root;
@Override public void Xtn_init_by_app(Xoae_app app) {}
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
// load config; TODO: load by file
// load config; TODO_OLD: load by file
boolean enabled = false, enable_heading_override = true, enable_default_banner = false;
int[] ns_ary = Int_.Ary(Xow_ns_.Tid__main, Xow_ns_.Tid__user);
int[] standard_sizes = new int[] {640, 1280, 2560};

View File

@@ -27,7 +27,7 @@ public class Pf_func_ {
public static byte[] Eval_arg_or(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk self, int self_args_len, int i, byte[] or) {
if (i >= self_args_len) return or;
Arg_nde_tkn nde = self.Args_get_by_idx(i);
Bry_bfr bfr = Bry_bfr.new_();
Bry_bfr bfr = Bry_bfr_.New();
Eval_arg_or(bfr, ctx, src, caller, self, nde, or);
return bfr.To_bry_and_clear_and_trim();
}
@@ -38,7 +38,7 @@ public class Pf_func_ {
}
public static byte[] Eval_val_or(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk self, int self_args_len, int i, byte[] or) {
if (i >= self_args_len) return or;
Bry_bfr bfr = Bry_bfr.new_();
Bry_bfr bfr = Bry_bfr_.New();
Arg_nde_tkn nde = self.Args_get_by_idx(i);
nde.Val_tkn().Tmpl_evaluate(ctx, src, caller, bfr);
return bfr.To_bry_and_clear_and_trim();
@@ -76,7 +76,7 @@ public class Pf_func_ {
public static int[] Ary_get(Xow_domain_itm domain_itm, boolean wmf) {
if (wmf && domain_itm != null && domain_itm.Domain_type().Tid() != Xow_domain_tid_.Int__home) return Ary_wmf;
if (Ary_nonwmf == null) {
List_adp list = List_adp_.new_();
List_adp list = List_adp_.New();
int len = Ary_wmf.length;
for (int i = 0; i < len; ++i) {
list.Add(Ary_wmf[i]);

View File

@@ -34,7 +34,7 @@ public abstract class Pf_func_base implements Pf_func {
Arg_itm_tkn name_val_tkn = self.Name_tkn().Val_tkn();
int subs_len = name_val_tkn.Subs_len();
if (subs_len > 0) {
Bry_bfr tmp = Bry_bfr.new_();
Bry_bfr tmp = Bry_bfr_.New();
for (int i = 0; i < subs_len; i++)
name_val_tkn.Subs_get(i).Tmpl_evaluate(ctx, src, caller, tmp);
argx_dat = tmp.To_bry_and_clear_and_trim();
@@ -60,7 +60,7 @@ public abstract class Pf_func_base implements Pf_func {
}
}
else {
Bry_bfr tmp = Bry_bfr.new_();
Bry_bfr tmp = Bry_bfr_.New();
for (int i = 0; i < subs_len; i++)
name_val_tkn.Subs_get(i).Tmpl_evaluate(ctx, src, caller, tmp);
argx_dat = tmp.To_bry_and_clear_and_trim();
@@ -68,5 +68,5 @@ public abstract class Pf_func_base implements Pf_func {
}
return argx_dat;
}
public static final byte[] Eval_arg_or_null_is_null = null, Eval_arg_or_null_is_empty = Bry_.Empty;
public static final byte[] Eval_arg_or_null_is_null = null, Eval_arg_or_null_is_empty = Bry_.Empty;
}

View File

@@ -23,8 +23,8 @@ public class Pfunc_expr_shunter {
Btrie_fast_mgr trie = expression_();
Val_stack val_stack = new Val_stack();
Func_tkn_stack prc_stack = new Func_tkn_stack();
public static final Decimal_adp Null_rslt = null;
public Bry_bfr Err() {return err_bfr;} Bry_bfr err_bfr = Bry_bfr.new_();
public static final Decimal_adp Null_rslt = null;
public Bry_bfr Err() {return err_bfr;} Bry_bfr err_bfr = Bry_bfr_.New();
public Decimal_adp Err_set(Xop_ctx ctx, int msgId) {return Err_set(ctx, msgId, Bry_.Empty);}
public Decimal_adp Err_set(Xop_ctx ctx, int msg_id, byte[] arg) {
byte[] msg_val = ctx.Wiki().Msg_mgr().Val_by_id(msg_id);
@@ -32,7 +32,7 @@ public class Pfunc_expr_shunter {
tmp_fmtr.Fmt_(msg_val).Bld_bfr_one(err_bfr, arg);
err_bfr.Add(Err_end_ary);
return Null_rslt;
} static final byte[] Err_bgn_ary = Bry_.new_a7("<strong class=\"error\">"), Err_end_ary = Bry_.new_a7("</strong>"); Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_();
} static final byte[] Err_bgn_ary = Bry_.new_a7("<strong class=\"error\">"), Err_end_ary = Bry_.new_a7("</strong>"); Bry_fmtr tmp_fmtr = Bry_fmtr.tmp_();
public void Rslt_set(byte[] bry) {
err_bfr.Add(bry);
}
@@ -218,5 +218,5 @@ public class Pfunc_expr_shunter {
return rv;
}
private static void Trie_add(Btrie_fast_mgr trie, Expr_tkn tkn) {trie.Add(tkn.Val_ary(), tkn);}
public static final Pfunc_expr_shunter Instance = new Pfunc_expr_shunter(); Pfunc_expr_shunter() {}
public static final Pfunc_expr_shunter Instance = new Pfunc_expr_shunter(); Pfunc_expr_shunter() {}
}

View File

@@ -24,7 +24,7 @@ public class Xop_xowa_dbg extends Pf_func_base {
bfr.Add(argx);
Argx_list.Add(argx);
}
public static final List_adp Argx_list = List_adp_.new_();
public static final List_adp Argx_list = List_adp_.New();
@Override public int Id() {return Xol_kwd_grp_.Id_xowa_dbg;}
@Override public Pf_func New(int id, byte[] name) {return new Xop_xowa_dbg().Name_(name);}
}

View File

@@ -48,12 +48,12 @@ public class Pfunc_gender extends Pf_func_base {
int user_name_len = user_name.length;
switch (user_name_len) {
case 0: return Xol_gender_.Tid_unknown; // EX: {{gender:|m|f}}
case 1: if (user_name[0] == Byte_ascii.Dot) return Xol_gender_.Tid_unknown; break; // EX: {{gender:.|m|f}}; TODO: should define default gender for wiki
case 1: if (user_name[0] == Byte_ascii.Dot) return Xol_gender_.Tid_unknown; break; // EX: {{gender:.|m|f}}; TODO_OLD: should define default gender for wiki
}
Object o = gender_cache.Get_by_bry(user_name);
return o == null ? user.Gender() : ((Int_obj_val)o).Val();
}
private static final Hash_adp_bry gender_cache = Hash_adp_bry.cs() // for tests
private static final Hash_adp_bry gender_cache = Hash_adp_bry.cs() // for tests
.Add_str_int("xowa_male" , Xol_gender_.Tid_male)
.Add_str_int("xowa_female" , Xol_gender_.Tid_female)
;

View File

@@ -20,7 +20,7 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*;
import gplx.xowa.wikis.pages.*; import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*;
public class Pfunc_rev_props extends Pf_func_base {
public Pfunc_rev_props(int id) {this.id = id;}
@Override public int Id() {return id;} private final int id;
@Override public int Id() {return id;} private final int id;
@Override public Pf_func New(int id, byte[] name) {return new Pfunc_rev_props(id).Name_(name);}
@Override public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {
byte[] argx = Eval_argx(ctx, src, caller, self);
@@ -41,7 +41,7 @@ public class Pfunc_rev_props extends Pf_func_base {
bfr.Add_byte(Byte_ascii.Num_0);
return;
}
Xoae_page argx_page = ctx.Wiki().Data_mgr().Get_page(argx_ttl, false);
Xoae_page argx_page = ctx.Wiki().Data_mgr().Load_page_by_ttl(argx_ttl);
if (!argx_page.Missing()) {
bfr.Add_int_variable(argx_page.Data_raw().length);
return;
@@ -52,5 +52,5 @@ public class Pfunc_rev_props extends Pf_func_base {
default: throw Err_.new_unhandled(id);
}
}
public static final Pfunc_rev_props Instance = new Pfunc_rev_props(-1);
public static final Pfunc_rev_props Instance = new Pfunc_rev_props(-1);
}

View File

@@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pfuncs.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.xtns.scribunto.*;
public class Pfunc_xtn_mgr extends Xox_mgr_base {
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("ParserFunctions");
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("ParserFunctions");
@Override public void Xtn_init_by_app(Xoae_app app) {
Scrib_xtn_mgr scrib_xtn = (Scrib_xtn_mgr)app.Xtn_mgr().Get_or_fail(Scrib_xtn_mgr.XTN_KEY);
scrib_xtn.Lib_mgr().Add(new Pfunc_scrib_lib());
}
@Override public Xox_mgr Clone_new() {return new Pfunc_xtn_mgr();}
@Override public Xox_mgr Xtn_clone_new() {return new Pfunc_xtn_mgr();}
}

View File

@@ -44,7 +44,7 @@ public class Pfunc_tag extends Pf_func_base {
}
}
tmp.Add_byte(Byte_ascii.Gt);
if (args_len > 0) // TODO: trim should not be called on content; WHEN: adding src[] back to tmpl_eval
if (args_len > 0) // TODO_OLD: trim should not be called on content; WHEN: adding src[] back to tmpl_eval
tmp.Add(Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, args_len, 0));
tmp.Add_byte(Byte_ascii.Lt).Add_byte(Byte_ascii.Slash).Add(tag_name).Add_byte(Byte_ascii.Gt);
if (tag_is_ref) // <ref>; add <xtag_end> to handle nested refs; PAGE:en.w:Battle_of_Midway; DATE:2014-06-27
@@ -58,7 +58,7 @@ public class Pfunc_tag extends Pf_func_base {
, Xtag_bgn = 14 // <xtag_bgn id='
, Id_len = 10
;
public static final byte[]
public static final byte[]
Xtag_bgn_lhs = Bry_.new_a7("<xtag_bgn id='")
, Xtag_end_lhs = Bry_.new_a7("<xtag_end id='")
, Xtag_rhs = Bry_.new_a7("'/>")

View File

@@ -56,7 +56,7 @@ public class Pft_fmt_itm_ {
, Tid_hijiri_month_name = 33
;
public static final Pft_fmt_itm
public static final Pft_fmt_itm
Year_len4 = new Pft_fmt_itm_seg_int(DateAdp_.SegIdx_year , 4, Bool_.Y)
, Year_len2 = new Pft_fmt_itm_seg_int(DateAdp_.SegIdx_year , 2, Bool_.Y)
, Month_int_len2 = new Pft_fmt_itm_seg_int(DateAdp_.SegIdx_month , 2, Bool_.Y)
@@ -110,7 +110,7 @@ public class Pft_fmt_itm_ {
, Hijiri_day_idx = new Pft_fmt_itm_hijiri_day_idx()
, Hijiri_month_name = new Pft_fmt_itm_hijiri_month_name()
;
public static final Btrie_fast_mgr Regy = Btrie_fast_mgr.cs()
public static final Btrie_fast_mgr Regy = Btrie_fast_mgr.cs()
.Add(Byte_ascii.Ltr_Y , Pft_fmt_itm_.Year_len4) // 2012
.Add(Byte_ascii.Ltr_y , Pft_fmt_itm_.Year_len2) // 12
.Add(Byte_ascii.Ltr_L , Pft_fmt_itm_.Year_isLeap) // 1,0
@@ -161,7 +161,7 @@ public class Pft_fmt_itm_ {
.Add("xmF" , Pft_fmt_itm_.Hijiri_month_name)
.Add("xmn" , Pft_fmt_itm_.Hijiri_month_idx)
.Add("xmY" , Pft_fmt_itm_.Hijiri_year_idx)
// TODO: space; "
// TODO_OLD: space; "
;
public static Pft_fmt_itm[] Parse(Xop_ctx ctx, byte[] fmt) {
Btrie_fast_mgr trie = Pft_fmt_itm_.Regy;
@@ -211,5 +211,5 @@ public class Pft_fmt_itm_ {
}
if (raw_bgn != String_.Pos_neg1) {fmt_itms.Add(fmt_len - raw_bgn == 1 ? new Pft_fmt_itm_raw_byt(fmt[fmt_len - 1]) : (Pft_fmt_itm)new Pft_fmt_itm_raw_ary(fmt, raw_bgn, fmt_len)); raw_bgn = String_.Pos_neg1;}
return (Pft_fmt_itm[])fmt_itms.To_ary(Pft_fmt_itm.class);
} private static List_adp fmt_itms = List_adp_.new_();
} private static List_adp fmt_itms = List_adp_.New();
}

View File

@@ -30,7 +30,7 @@ class Pft_fmt_itm_seg_int implements Pft_fmt_itm {
class Pft_fmt_itm_raw implements Pft_fmt_itm {
public int TypeId() {return Pft_fmt_itm_.Tid_raw;}
public void Fmt(Bry_bfr bfr, Xowe_wiki wiki, Xol_lang_itm lang, DateAdp date, Pft_func_formatdate_bldr bldr) {
// TODO: should flag .Raw() on bldr to skip transliterating numerals in foreign languages; DATE:2013-12-31
// TODO_OLD: should flag .Raw() on bldr to skip transliterating numerals in foreign languages; DATE:2013-12-31
}
}
class Pft_fmt_itm_seg_str implements Pft_fmt_itm {
@@ -90,7 +90,7 @@ class Pft_fmt_itm_am_pm implements Pft_fmt_itm {
else if (!am && lower) val = Ary_pm_lower;
else if (!am && !lower) val = Ary_pm_upper;
bfr.Add(val);
} static final byte[] Ary_am_upper = Bry_.new_a7("AM"), Ary_pm_upper = Bry_.new_a7("PM"), Ary_am_lower = Bry_.new_a7("am"), Ary_pm_lower = Bry_.new_a7("pm");
} static final byte[] Ary_am_upper = Bry_.new_a7("AM"), Ary_pm_upper = Bry_.new_a7("PM"), Ary_am_lower = Bry_.new_a7("am"), Ary_pm_lower = Bry_.new_a7("pm");
public Pft_fmt_itm_am_pm(boolean lower) {this.lower = lower;} private boolean lower;
}
class Pft_fmt_itm_dow_base0 implements Pft_fmt_itm {
@@ -120,7 +120,7 @@ class Pft_fmt_itm_rfc_5322 implements Pft_fmt_itm {
bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space);
bfr.Add_str_a7(date.XtoStr_fmt("dd MMM yyyy HH:mm:ss")); // NOTE: always UTC time
bfr.Add(CONST_timezone); // NOTE: always UTC time zone
} static final byte[] CONST_timezone = Bry_.new_a7(" +0000");
} static final byte[] CONST_timezone = Bry_.new_a7(" +0000");
}
class Pft_fmt_itm_timezone_offset implements Pft_fmt_itm {
public Pft_fmt_itm_timezone_offset() {}

View File

@@ -28,7 +28,7 @@ public class Pft_func_time extends Pf_func_base {
Pft_fmt_itm[] fmt_ary = Pft_fmt_itm_.Parse(ctx, arg_fmt);
byte[] arg_date = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 0);
byte[] arg_lang = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 1);
Bry_bfr error_bfr = Bry_bfr.new_();
Bry_bfr error_bfr = Bry_bfr_.New();
DateAdp date = ParseDate(arg_date, utc, error_bfr);
if (date == null || error_bfr.Len() > 0)
bfr.Add_str_a7("<strong class=\"error\">").Add_bfr_and_clear(error_bfr).Add_str_a7("</strong>");
@@ -56,7 +56,7 @@ public class Pft_func_time extends Pf_func_base {
return null;
}
}
public static final Pft_func_time _Lcl = new Pft_func_time(false), _Utc = new Pft_func_time(true);
public static final Pft_func_time _Lcl = new Pft_func_time(false), _Utc = new Pft_func_time(true);
}
class DateAdpTranslator_xapp {
public static void Translate(Xowe_wiki wiki, Xol_lang_itm lang, int type, int val, Bry_bfr bb) {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
class Pft_func_time_foreign_fxt {
private final Xop_fxt fxt = new Xop_fxt();
private final Xop_fxt fxt = new Xop_fxt();
public void Clear() {
fxt.Reset();
Tfds.Now_set(DateAdp_.new_(2012, 1, 2, 3, 4, 5, 6));
@@ -35,7 +35,7 @@ class Pft_func_time_foreign_fxt {
fxt.Test_parse_tmpl_str_test(raw, "{{test}}", expd);
}
public void Test_Roman(int v, String expd) {
Bry_bfr bfr = Bry_bfr.new_(16);
Bry_bfr bfr = Bry_bfr_.New_w_size(16);
Pfxtp_roman.ToRoman(v, bfr);
String actl = bfr.To_str_and_clear();
Tfds.Eq(expd, actl);

View File

@@ -267,7 +267,7 @@ class Pxd_itm_int_ {
Pxd_itm itm = tkns[i];
switch (itm.Tkn_tid()) {
case Pxd_itm_.Tid_dash:
dash_itm = itm; // TODO: throw error if "--"; {{#time:U|@--1}}
dash_itm = itm; // TODO_OLD: throw error if "--"; {{#time:U|@--1}}
break;
case Pxd_itm_.Tid_int:
case Pxd_itm_.Tid_int_dmy_14:

View File

@@ -41,7 +41,7 @@ class Pxd_parser {
if (itm == null) return;
Bry_fmtr fmtr = itm.Fmtr();
fmtr.Bld_bfr(error_bfr, args);
} private Bry_bfr error_bfr = Bry_bfr.new_(32);
} private Bry_bfr error_bfr = Bry_bfr_.New_w_size(32);
public DateAdp Parse(byte[] src, Bry_bfr error_bfr) {
Tokenize(src); // NOTE: should check if Tokenize failed, but want to be liberal as date parser is not fully implemented; this will always default to 1st day of year; DATE:2014-03-27
return Evaluate(src, error_bfr);
@@ -171,15 +171,15 @@ class Pxd_parser_ {
}
return trie;
} static Btrie_slim_mgr trie;
private static final String[] Names_month_full = {"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"};
private static final String[] Names_month_abrv = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};
private static final String[] Names_month_roman = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"};
private static final String[] Names_day_suffix = {"st", "nd", "rd", "th"};
private static final String[] Names_day_full = {"sunday", "monday", "tuesday", "wednesday" , "thursday", "friday", "saturday"};
private static final String[] Names_day_abrv = {"sun", "mon", "tue", "wed" , "thu", "fri", "sat"};
//TODO:
//private static final String[] Names_day_text = {"weekday", "weekdays"};
//private static final String[] Names_ordinal_num = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"};
private static final String[] Names_month_full = {"january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"};
private static final String[] Names_month_abrv = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"};
private static final String[] Names_month_roman = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"};
private static final String[] Names_day_suffix = {"st", "nd", "rd", "th"};
private static final String[] Names_day_full = {"sunday", "monday", "tuesday", "wednesday" , "thursday", "friday", "saturday"};
private static final String[] Names_day_abrv = {"sun", "mon", "tue", "wed" , "thu", "fri", "sat"};
//TODO_OLD:
//private static final String[] Names_day_text = {"weekday", "weekdays"};
//private static final String[] Names_ordinal_num = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"};
private static void Init_unit(int seg_idx, String... name_ary) {Init_unit(seg_idx, 1, name_ary);}
private static void Init_unit(int seg_idx, int seg_val, String... name_ary) {
@@ -189,7 +189,7 @@ class Pxd_parser_ {
trie.Add_obj(name_bry, new Pxd_itm_unit(-1, name_bry, seg_idx, seg_val));
}
}
public static final byte[]
public static final byte[]
Unit_name_month = Bry_.new_a7("month")
, Unit_name_day = Bry_.new_a7("day")
, Unit_name_hour = Bry_.new_a7("hour")

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.pfuncs.times; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
import org.junit.*;
public class Pxd_parser_tst {
Bry_bfr bfr = Bry_bfr.new_(16); Pxd_parser parser = new Pxd_parser();
Bry_bfr bfr = Bry_bfr_.New_w_size(16); Pxd_parser parser = new Pxd_parser();
@Before public void init() {Tfds.Now_enabled_y_(); Tfds.Now_set(test_date);} DateAdp test_date = DateAdp_.parse_fmt("2012-02-27", "yyyy-MM-dd");
@After public void teardown() {Tfds.Now_enabled_n_();}
@Test public void Month_name_0__day__year() {tst_date_("Mar 2 2001" , "2001-03-02");} // y:Mar-02-2001;Mar.02.2001;Mar 02, 2001 n:Mar/02/2001;Feb,05,2011

View File

@@ -46,15 +46,15 @@ public class Pfunc_filepath extends Pf_func_base {
byte[] url = url_bldr.Init_for_trg_html(Xof_repo_itm_.Mode_orig, trg_repo, ttl_bry, xfer_itm.Orig_ttl_md5(), xfer_itm.Orig_ext(), Xof_img_size.Size__neg1, Xof_lnki_time.Null, Xof_lnki_page.Null).Xto_bry();
bfr.Add(url);
}
private static final Xof_xfer_itm xfer_itm = new Xof_xfer_itm();
private static final Xof_url_bldr url_bldr = new Xof_url_bldr();
private static final Xof_xfer_itm xfer_itm = new Xof_xfer_itm();
private static final Xof_url_bldr url_bldr = new Xof_url_bldr();
private static Xoae_page Load_page(Xowe_wiki wiki, Xoa_ttl ttl) {
Xoae_page page = wiki.Data_mgr().Get_page(ttl, false);
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl);
if (page.Missing()) { // file not found in current wiki; try commons;
Xowe_wiki commons_wiki = (Xowe_wiki)wiki.Appe().Wiki_mgr().Get_by_or_null(wiki.Commons_wiki_key());
if (commons_wiki != null) { // commons_wiki not installed; exit; DATE:2013-06-08
if (!Env_.Mode_testing()) commons_wiki.Init_assert();// must assert load else page_zip never detected; DATE:2013-03-10
page = commons_wiki.Data_mgr().Get_page(ttl, false);
page = commons_wiki.Data_mgr().Load_page_by_ttl(ttl);
}
}
return page;

View File

@@ -21,8 +21,8 @@ import gplx.xowa.wikis.tdbs.*;
import gplx.xowa.files.*; import gplx.xowa.files.exts.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.repos.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*;
public class Pfunc_filepath_tst {
private final Xop_fxt fxt = new Xop_fxt();
private final Xofw_wiki_wkr_mock mock_wkr = new Xofw_wiki_wkr_mock();
private final Xop_fxt fxt = new Xop_fxt();
private final Xofw_wiki_wkr_mock mock_wkr = new Xofw_wiki_wkr_mock();
private Xowe_wiki en_wiki, commons_wiki;
@Before public void init() {
fxt.Reset();
@@ -49,7 +49,7 @@ public class Pfunc_filepath_tst {
}
@Test public void Wiki_is_commons() {
fxt.Init_page_create(commons_wiki, "File:A.png", "");
commons_wiki.Tdb_fsys_mgr().Tdb_dir_regy()[Xotdb_dir_info_.Tid_page].Ext_tid_(gplx.core.ios.Io_stream_.Tid_raw);
commons_wiki.Tdb_fsys_mgr().Tdb_dir_regy()[Xotdb_dir_info_.Tid_page].Ext_tid_(gplx.core.ios.streams.Io_stream_.Tid_raw);
mock_wkr.Redirect_("A.png", "A.png").Repo_idx_(1);
fxt.Test_parse_tmpl_str_test("{{filepath:A.png}}", "{{test}}", "file:///mem/xowa/file/commons/trg/orig/7/0/1/c/A.png");
}

View File

@@ -24,11 +24,11 @@ public class Pfunc_rel2abs extends Pf_func_base {
private static final byte[] Ary_dot_slash = Bry_.new_a7("./"), Ary_dot_dot = Bry_.new_a7(".."), Ary_dot_dot_slash = Bry_.new_a7("../");
private static void qry_bgns_with_init() {
qry_bgns_with = Btrie_fast_mgr.cs();
qry_bgns_with.Add(Byte_ascii.Slash, Int_obj_ref.new_(Id_slash));
qry_bgns_with.Add(Byte_ascii.Dot, Int_obj_ref.new_(Id_dot));
qry_bgns_with.Add(Ary_dot_slash, Int_obj_ref.new_(Id_dot_slash));
qry_bgns_with.Add(Ary_dot_dot, Int_obj_ref.new_(Id_dot_dot));
qry_bgns_with.Add(Ary_dot_dot_slash, Int_obj_ref.new_(Id_dot_dot_slash));
qry_bgns_with.Add(Byte_ascii.Slash, Int_obj_ref.New(Id_slash));
qry_bgns_with.Add(Byte_ascii.Dot, Int_obj_ref.New(Id_dot));
qry_bgns_with.Add(Ary_dot_slash, Int_obj_ref.New(Id_dot_slash));
qry_bgns_with.Add(Ary_dot_dot, Int_obj_ref.New(Id_dot_dot));
qry_bgns_with.Add(Ary_dot_dot_slash, Int_obj_ref.New(Id_dot_dot_slash));
} static Btrie_fast_mgr qry_bgns_with;
@Override public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {// REF.MW:ParserFunctions_body.php
byte[] qry = Eval_argx(ctx, src, caller, self);
@@ -57,7 +57,7 @@ public class Pfunc_rel2abs extends Pf_func_base {
}
return rv;
}
private static final Int_obj_ref ignore_rel2abs_tid = Int_obj_ref.zero_();
private static final Int_obj_ref ignore_rel2abs_tid = Int_obj_ref.New_zero();
public static byte[] Rel2abs(Bry_bfr tmp_bfr, byte[] qry, byte[] src) {return Rel2abs(tmp_bfr, qry, src, ignore_rel2abs_tid);}
public static byte[] Rel2abs(Bry_bfr tmp_bfr, byte[] qry, byte[] src, Int_obj_ref rel2abs_tid) {
if (qry_bgns_with == null) qry_bgns_with_init();

View File

@@ -27,5 +27,5 @@ public class Pfunc_urlencode extends Pf_func_base { // EX: {{urlencode:a b}} ->
gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url.Encode(urlEncodeBfr, argx);
bfr.Add_bfr_and_preserve(urlEncodeBfr);
urlEncodeBfr.Clear();
} private Bry_bfr urlEncodeBfr = Bry_bfr.new_(128);
} private Bry_bfr urlEncodeBfr = Bry_bfr_.New_w_size(128);
}

View File

@@ -27,7 +27,7 @@ public class Pfunc_pagesincategory extends Pf_func_base {
byte[] ctg_ttl_bry = Eval_argx(ctx, src, caller, self);
if (Bry_.Len_eq_0(ctg_ttl_bry)) {bfr.Add_int_digits(1, 0); return;} // no title; EX: "{{PAGESINCATEGORY:}}"
Xowe_wiki wiki = ctx.Wiki();
Xowd_db_mgr core_data_mgr = wiki.Data__core_mgr();
Xow_db_mgr core_data_mgr = wiki.Data__core_mgr();
int ctg_id = core_data_mgr.Tbl__page().Select_id(Xow_ns_.Tid__category, Xoa_ttl.Replace_spaces(ctg_ttl_bry));
if (ctg_id == Xowd_page_itm.Id_null) {bfr.Add_int_digits(1, 0); return;} // category doesn't exist; EX: "{{PAGESINCATEGORY:Unknown_category}}"
Xowd_category_itm ctg_itm = core_data_mgr.Db__cat_core().Tbl__cat_core().Select(ctg_id);

View File

@@ -36,7 +36,7 @@ public class Pfunc_pagesincategory_tst {
class Pfunc_pagesincategory_tstr {
private final Xop_fxt parser_tstr;
private final Xoae_app app; private final Xowe_wiki wiki;
private final Xowd_db_mgr core_data_mgr;
private final Xow_db_mgr core_data_mgr;
private final Xowd_page_tbl page_tbl; private final Xowd_cat_core_tbl cat_core_tbl;
public Pfunc_pagesincategory_tstr() {
Xoa_test_.Inet__init();

View File

@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.poems; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
import gplx.xowa.parsers.*;
public class Poem_xtn_mgr extends Xox_mgr_base {
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("poem");
@Override public Xox_mgr Clone_new() {return new Poem_xtn_mgr();}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("poem");
@Override public Xox_mgr Xtn_clone_new() {return new Poem_xtn_mgr();}
public Xop_parser Parser() {return parser;} private Xop_parser parser;
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
parser = Xop_parser.new_(wiki, wiki.Parser_mgr().Main().Tmpl_lxr_mgr(), wiki.Parser_mgr().Main().Wtxt_lxr_mgr());

View File

@@ -90,13 +90,13 @@ class Pp_index_parser {
class Pp_index_page {
public Pp_index_page() {}
public byte[] Src() {return src;} public Pp_index_page Src_(byte[] v) {src = v; return this;} private byte[] src;
public List_adp Pagelist_xndes() {return pagelist_xndes;} private List_adp pagelist_xndes = List_adp_.new_();
public List_adp Page_ttls() {return page_ttls;} private List_adp page_ttls = List_adp_.new_();
public List_adp Main_lnkis() {return main_lnkis;} private List_adp main_lnkis = List_adp_.new_();
public List_adp Invk_args() {return invk_args;} private List_adp invk_args = List_adp_.new_();
public List_adp Pagelist_xndes() {return pagelist_xndes;} private List_adp pagelist_xndes = List_adp_.New();
public List_adp Page_ttls() {return page_ttls;} private List_adp page_ttls = List_adp_.New();
public List_adp Main_lnkis() {return main_lnkis;} private List_adp main_lnkis = List_adp_.New();
public List_adp Invk_args() {return invk_args;} private List_adp invk_args = List_adp_.New();
public Xoa_ttl[] Get_ttls_rng(Xowe_wiki wiki, int ns_page_id, byte[] bgn_page_bry, byte[] end_page_bry, Int_obj_ref bgn_page_ref, Int_obj_ref end_page_ref) {
int list_len = page_ttls.Count(); if (list_len == 0) return Pp_pages_nde.Ttls_null;
List_adp rv = List_adp_.new_();
List_adp rv = List_adp_.New();
Xoa_ttl bgn_page_ttl = new_ttl_(wiki, ns_page_id, bgn_page_bry), end_page_ttl = new_ttl_(wiki, ns_page_id, end_page_bry);
boolean add = bgn_page_ttl == Xoa_ttl.Null; // if from is missing, default to bgn; EX: <pages index=A to="A/5"/>
for (int i = 0; i < list_len; i++) { // REF.MW:ProofreadPageRenderer|renderPages
@@ -113,7 +113,7 @@ class Pp_index_page {
return (Xoa_ttl[])rv.To_ary(Xoa_ttl.class);
}
private static Xoa_ttl new_ttl_(Xowe_wiki wiki, int ns_page_id, byte[] bry) {return bry == null ? Xoa_ttl.Null : Xoa_ttl.parse(wiki, ns_page_id, bry);}
public static final Pp_index_page Null = new Pp_index_page();
public static final Pp_index_page Null = new Pp_index_page();
}
class Pp_index_arg {
public Pp_index_arg(byte[] key, byte[] val) {this.key = key; this.val = val;}

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.xtns.proofreadPage; 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.logs.*; import gplx.xowa.parsers.xndes.*; import gplx.xowa.parsers.htmls.*;
public class Pp_pagelist_nde implements Xox_xnde { // TODO:
public class Pp_pagelist_nde implements Xox_xnde { // TODO_OLD:
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) {
boolean log_wkr_enabled = Log_wkr != Xop_log_basic_wkr.Null; if (log_wkr_enabled) Log_wkr.Log_end_xnde(ctx.Page(), Xop_log_basic_wkr.Tid_hiero, src, xnde);

View File

@@ -109,7 +109,7 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
) // NOTE: this simulates MW's if (empty($links)); REF.MW:ProofreadPageRenderer.php|renderPages
ttls = Get_ttls_from_xnde_args();
else {
Int_obj_ref bgn_page_ref = Int_obj_ref.neg1_(), end_page_ref = Int_obj_ref.neg1_();
Int_obj_ref bgn_page_ref = Int_obj_ref.New_neg1(), end_page_ref = Int_obj_ref.New_neg1();
ttls = index_page.Get_ttls_rng(wiki, ns_page_id, bgn_page_bry, end_page_bry, bgn_page_ref, end_page_ref);
bgn_page_int = bgn_page_ref.Val();
end_page_int = end_page_ref.Val();
@@ -212,7 +212,7 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
}
private Xoa_ttl[] Get_ttls_from_xnde_args() {
if (!Chk_step()) return Ttls_null;
List_adp list = List_adp_.new_();
List_adp list = List_adp_.New();
list = Get_ttls_from_xnde_args__include(list); if (list == null) return Ttls_null;
list = Get_ttls_from_xnde_args__rng(list); if (list == null) return Ttls_null;
list = Get_ttls_from_xnde_args__exclude(list); if (list == null) return Ttls_null;
@@ -262,8 +262,8 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
return list;
}
private int Get_max_page_idx(Xowe_wiki wiki, Xoa_ttl index_ttl) {
List_adp rslt = List_adp_.new_();
Int_obj_ref rslt_count = Int_obj_ref.zero_();
List_adp rslt = List_adp_.New();
Int_obj_ref rslt_count = Int_obj_ref.New_zero();
wiki.Db_mgr().Load_mgr().Load_ttls_for_all_pages(Cancelable_.Never, rslt, tmp_page, tmp_page, rslt_count, ns_page, index_ttl.Page_db(), Int_.Max_value, 0, Int_.Max_value, false, false);
int len = rslt_count.Val();
int page_leaf_max = 0;
@@ -280,14 +280,14 @@ public class Pp_pages_nde implements Xox_xnde, Mwh_atr_itm_owner1 {
if (Bry_.Len_eq_0(exclude)) return list; // exclude is blank; exit early;
int[] exclude_pages = Int_ary_.Parse_list_or(exclude, null);
if (exclude_pages == null) return list; // ignore invalid exclude; DATE:2014-02-22
Hash_adp exclude_pages_hash = Hash_adp_.new_();
Hash_adp exclude_pages_hash = Hash_adp_.New();
int exclude_pages_len = exclude_pages.length;
for (int i = 0; i < exclude_pages_len; i++) {
Int_obj_val exclude_page = Int_obj_val.new_(exclude_pages[i]);
if (!exclude_pages_hash.Has(exclude_page))
exclude_pages_hash.Add(exclude_page, exclude_page);
}
List_adp new_list = List_adp_.new_();
List_adp new_list = List_adp_.New();
int list_len = list.Count();
for (int i = 0; i < list_len; i++) {
Int_obj_val page = (Int_obj_val)list.Get_at(i);

View File

@@ -20,8 +20,8 @@ import gplx.langs.htmls.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.*;
public class Pp_xtn_mgr extends Xox_mgr_base {
@Override public boolean Enabled_default() {return false;}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("ProofreadPages");
@Override public Xox_mgr Clone_new() {return new Pp_xtn_mgr();}
@Override public byte[] Xtn_key() {return XTN_KEY;} public static final byte[] XTN_KEY = Bry_.new_a7("ProofreadPages");
@Override public Xox_mgr Xtn_clone_new() {return new Pp_xtn_mgr();}
@Override public void Xtn_init_by_wiki(Xowe_wiki wiki) {
if (!this.Enabled_manually())
this.Enabled_(wiki.Domain_tid() == Xow_domain_tid_.Int__wikisource); // only enable for wikisource

Some files were not shown because too many files have changed in this diff Show More