mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wiki: Support renamed folders (fix)
This commit is contained in:
@@ -1,47 +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.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);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +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.files.*; import gplx.xowa.guis.cbks.js.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*; 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_fmtr, Js_img_wkr {
|
||||
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 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 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 Add_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);
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
if (xfer_itm.Orig_exists()) {
|
||||
img_w = xfer_itm.Html_w();
|
||||
img_h = xfer_itm.Html_h();
|
||||
}
|
||||
else {
|
||||
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();
|
||||
}
|
||||
}
|
||||
Write_imap_div(tmp_bfr, hctx, uid, img_w, img_h, img_src, xfer_itm.Orig_exists(), xfer_itm.Orig_w(), xfer_itm.Orig_h(), a_xowa_title);
|
||||
}
|
||||
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, Xof_ext orig_ext, 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 > 0, 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, Xoh_wtr_ctx hctx, int html_uid, int html_w, int html_h, byte[] img_src, boolean orig_exists, 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, orig_exists);
|
||||
Imap_html_fmtrs.All.Bld_bfr_many(bfr, html_uid, Calc_desc_style(desc, html_w, html_h), map_arg, img_arg);
|
||||
}
|
||||
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 = 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 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;
|
||||
if (denominator <= 0 || numerator <= 0) return 1; // return identity; note that MW does "return self::error( 'imagemap_invalid_image' );"
|
||||
return (double)numerator / (double)denominator;
|
||||
}
|
||||
}
|
||||
@@ -1,238 +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.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.*;
|
||||
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_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;
|
||||
private final Btrie_rv trv = new Btrie_rv();
|
||||
public Imap_parser(Imap_xtn_mgr xtn_mgr) {this.xtn_mgr = xtn_mgr;}
|
||||
public void Init(Xowe_wiki wiki, Xoae_page page, Gfo_usr_dlg usr_dlg) {// SCOPE.PAGE
|
||||
this.app = wiki.Appe(); this.wiki = wiki; this.page_url = page.Url(); this.usr_dlg = usr_dlg;
|
||||
this.wiki_ctx = wiki.Parser_mgr().Ctx();
|
||||
imap_ctx = Xop_ctx.New__top(wiki, page.Ttl().Raw()); // NOTE: must update page ttl for Modules; PAGE:it.s:Patria_Esercito_Re/Indice_generale; DATE:2015-12-02
|
||||
imap_root = app.Parser_mgr().Tkn_mkr().Root(Bry_.Empty);
|
||||
}
|
||||
public void Clear() {
|
||||
this.itm_idx = 0;
|
||||
imap_img = null; imap_img_src = null; imap_desc = null; imap_dflt = null;
|
||||
shapes.Clear(); pts.Clear(); errs.Clear();
|
||||
}
|
||||
public Imap_map Parse(Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
|
||||
Imap_map rv = new Imap_map(ctx.Page().Html_data().Xtn_imap_next_id());
|
||||
Init(wiki, ctx.Page(), wiki.Appe().Usr_dlg());
|
||||
this.Parse(rv, src, xnde.Tag_open_end(), xnde.Tag_close_bgn());
|
||||
return rv;
|
||||
}
|
||||
public void Parse(Imap_map rv, byte[] src, int src_bgn, int src_end) {
|
||||
this.Clear();
|
||||
this.src = src;
|
||||
itm_bgn = src_bgn; itm_end = src_bgn - 1;
|
||||
while (true) {
|
||||
if (itm_end == src_end) break;
|
||||
itm_bgn = Bry_find_.Trim_fwd_space_tab(src, itm_end + 1, src_end); // trim ws at start, and look for first char
|
||||
if (itm_bgn == src_end) break; // line is entirely ws and terminated by eos; EX: "\n EOS"
|
||||
itm_end = Bry_find_.Find_fwd_until(src, itm_bgn, src_end, Byte_ascii.Nl); // look for \n
|
||||
if (itm_end == Bry_find_.Not_found) itm_end = src_end; // no \n; make EOS = \n
|
||||
itm_end = Bry_find_.Trim_bwd_space_tab(src, itm_end, itm_bgn); // trim any ws at end
|
||||
if (itm_end - itm_bgn == 0) continue; // line is entirely ws; continue;
|
||||
byte b = src[itm_bgn];
|
||||
if (b == Byte_ascii.Hash) {
|
||||
Parse_comment(itm_bgn, itm_end);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (itm_idx == 0)
|
||||
itm_end = Parse_img(rv, itm_bgn, itm_end, src_end);
|
||||
else {
|
||||
Object tid_obj = tid_trie.Match_at_w_b0(trv, b, src, itm_bgn, itm_end);
|
||||
byte tid_val = tid_obj == null ? Imap_part_.Tid_invalid : ((Byte_obj_val)tid_obj).Val();
|
||||
int tid_end_pos = trv.Pos();
|
||||
switch (tid_val) {
|
||||
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_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_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) {
|
||||
Btrie_slim_mgr trie = xtn_mgr.Desc_trie();
|
||||
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_part_desc(tid_desc);
|
||||
return true;
|
||||
}
|
||||
private void Parse_dflt(int itm_bgn, int itm_end) {
|
||||
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_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.parse:No valid link was found");}
|
||||
int num_bgn = -1, comma_pos = -1, pts_len = 0;
|
||||
while (true) {
|
||||
boolean last = pos == grp_end;
|
||||
byte b = last ? Byte_ascii.Space : src[pos];
|
||||
switch (b) {
|
||||
case Byte_ascii.Comma: if (comma_pos == -1) comma_pos = pos; break;
|
||||
default: if (num_bgn == -1) num_bgn = pos; break;
|
||||
case Byte_ascii.Space: case Byte_ascii.Tab:
|
||||
if (num_bgn != -1) {
|
||||
byte[] num_bry
|
||||
= comma_pos == -1 // if commas exist, treat first as decimal; echo(intval(round('1,2,3,4' * 1))) -> 1; PAGE:fr.w:Gouesnou; DATE:2014-08-12
|
||||
|| comma_pos < num_bgn // if comma is at start of number, ignore; EX: "poly ,1 2"; PAGE:en.w:Area_codes_281,_346,_713,_and_832; DATE:2015-07-31
|
||||
? Bry_.Mid(src, num_bgn, pos)
|
||||
: Bry_.Mid(src, num_bgn, comma_pos)
|
||||
;
|
||||
double num = Bry_.To_double_or(num_bry, Double_.NaN);
|
||||
if (Double_.IsNaN(num)) {
|
||||
if (shape_is_poly) // poly code in ImageMap_body.php accepts invalid words and converts to 0; EX:"word1"; PAGE:uk.w:Стратосфера; DATE:2014-07-26
|
||||
num = 0;
|
||||
else
|
||||
return Add_err(Bool_.Y, itm_bgn, itm_end, "imagemap_invalid_coord");
|
||||
}
|
||||
num_bgn = -1; comma_pos = -1;
|
||||
pts.Add(Double_obj_val.new_(num));
|
||||
++pts_len;
|
||||
if (pts_len == reqd_pts) // NOTE: MW allows more points, but doesn't show them; EX: rect 1 2 3 4 5 -> rect 1 2 3 4; PAGE:en.w:Kilauea DATE:2014-07-28; EX:1 2 3 4 <!-- --> de.w:Wilhelm_Angele DATE:2014-10-30
|
||||
last = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (last) break;
|
||||
++pos;
|
||||
}
|
||||
if (reqd_pts == Reqd_poly) {
|
||||
if (pts_len == 0) return Add_err(Bool_.Y, itm_bgn, itm_end, "imagemap_missing_coord");
|
||||
else if (pts_len % 2 != 0) return Add_err(Bool_.Y, itm_bgn, itm_end, "imagemap_poly_odd");
|
||||
}
|
||||
else {
|
||||
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_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;
|
||||
}
|
||||
private boolean Add_err(boolean clear_pts, int bgn, int end, String err_key) {
|
||||
usr_dlg.Warn_many("", "", err_key + ": page=~{0} line=~{1}", page_url.To_str(), String_.new_u8(src, bgn, end));
|
||||
errs.Add(new Imap_err(itm_idx, err_key));
|
||||
if (clear_pts) pts.Clear();
|
||||
return false;
|
||||
}
|
||||
private void Init_link_owner(Imap_link_owner link_owner, byte[] src, int bgn, int end) {
|
||||
byte[] link_tkn_src = Bry_.Mid(src, bgn, end);
|
||||
Xop_tkn_itm link_tkn = Parse_link(link_tkn_src);
|
||||
if (link_tkn == null) {Add_err(Bool_.N, bgn, end, "imap.invalid link_owner"); return;} // exit early if invalid; PAGE:de.u:PPA/Raster/TK25/51/18/12/20; DATE:2015-02-02
|
||||
link_tkn_src = imap_root.Data_mid(); // NOTE:must re-set link_tkn_src since link_tkn is expanded wikitext; i.e.: not "{{A}}" but "expanded"; PAGE:fr.w:Arrondissements_de_Lyon DATE:2014-08-12
|
||||
Imap_link_owner_.Init(link_owner, app, wiki, link_tkn_src, link_tkn);
|
||||
}
|
||||
private Xop_tkn_itm Parse_link(byte[] raw) {
|
||||
imap_root.Clear();
|
||||
imap_ctx.Clear(false); // NOTE: imap should not reset scrib; PAGE:it.s:La_guerra_del_vespro_siciliano/Indice DATE:2015-12-02
|
||||
wiki.Parser_mgr().Main().Parse_text_to_wdom(imap_root, imap_ctx, wiki.Appe().Parser_mgr().Tkn_mkr(), raw, 0);
|
||||
int subs_len = imap_root.Subs_len();
|
||||
for (int i = 0; i < subs_len; ++i) {
|
||||
Xop_tkn_itm sub = imap_root.Subs_get(i);
|
||||
switch (sub.Tkn_tid()) {
|
||||
case Xop_tkn_itm_.Tid_lnki:
|
||||
case Xop_tkn_itm_.Tid_lnke:
|
||||
return sub;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private int Parse_img(Imap_map imap, int itm_bgn, int itm_end, int src_end) {
|
||||
int img_bgn = Bry_find_.Trim_fwd_space_tab(src, itm_bgn, itm_end); // trim ws
|
||||
int img_end = Parse_img__get_img_end(itm_end, src_end);
|
||||
imap_img_src = Bry_.Add(Xop_tkn_.Lnki_bgn, Bry_.Mid(src, img_bgn, img_end), Xop_tkn_.Lnki_end);
|
||||
Xop_tkn_itm tkn_itm = Parse_link(imap_img_src); // NOTE: need to parse before imap_root.Data_mid() below
|
||||
imap_img_src = imap_root.Data_mid(); // need to re-set src to pick up templates; EX: <imagemap>File:A.png|thumb|{{Test_template}}\n</imagemap>; PAGE:en.w:Kilauea; DATE:2014-07-27
|
||||
if ( tkn_itm == null // no lnki or lnke
|
||||
|| tkn_itm.Tkn_tid() != Xop_tkn_itm_.Tid_lnki // no lnki; occurs with badly constructed maps; PAGE:en.w:Demography_of_the_United_Kingdom DATE:2015-01-22
|
||||
)
|
||||
Xoa_app_.Usr_dlg().Note_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_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
|
||||
}
|
||||
return img_end;
|
||||
}
|
||||
private int Parse_img__get_img_end(int line_end, int src_end) { // heuristic to handle images that span more than one line via ref; en.w:Archaea DATE:2014-08-22
|
||||
int rv = line_end;
|
||||
int pos = line_end + 1;
|
||||
while (pos < src_end) {
|
||||
pos = Bry_find_.Trim_fwd_space_tab(src, pos, src_end); // trim ws
|
||||
if (pos == src_end) break;
|
||||
byte b = src[pos];
|
||||
if (b == Byte_ascii.Nl) // new-line; end
|
||||
break;
|
||||
else {
|
||||
Object tid_obj = tid_trie.Match_bgn_w_byte(b, src, pos, src_end);
|
||||
if (tid_obj == null) { // not a known imap line; assume continuation of img line and skip to next line
|
||||
Xoa_app_.Usr_dlg().Log_many("", "", "image_map extending image over multiple lines; page=~{0} imageMap=~{1}", page_url.To_str(), imap_img_src);
|
||||
int next_line = Bry_find_.Find_fwd(src, Byte_ascii.Nl, pos);
|
||||
if (next_line == Bry_find_.Not_found) next_line = src_end;
|
||||
rv = next_line;
|
||||
pos = rv + 1;
|
||||
}
|
||||
else // known imap line; stop
|
||||
break;
|
||||
}
|
||||
}
|
||||
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_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;
|
||||
}
|
||||
@@ -1,77 +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 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));}
|
||||
@Test public void Rect_pass_many() {fxt.Test_shape("rect 1 2 3 4 5 6[[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));} // PURPOSE: MW allows extra points to be passed; PAGE:en.w:Kilauea DATE:2014-07-28
|
||||
@Test public void Rect_pass_invalid() {fxt.Test_shape("rect 1 2 3 4 a b [[A]]" , fxt.itm_rect_("[[A]]", 1, 2, 3, 4));} // PURPOSE: MW only scans first 4 tokens for numbers; PAGE:de.w:Wilhelm_Angele DATE:2014-10-30
|
||||
@Test public void Circle_pass() {fxt.Test_shape("circle 1 2 3 [[A]]" , fxt.itm_circle_("[[A]]", 1, 2, 3));}
|
||||
@Test public void Poly_pass() {fxt.Test_shape("poly 1 2 3 4 5 6 [[A]]" , fxt.itm_poly_("[[A]]", 1, 2, 3, 4, 5, 6));}
|
||||
@Test public void Poly_pass_chars() {fxt.Test_shape("poly a b [[A]]" , fxt.itm_poly_("[[A]]", 0, 0));} // PURPOSE: non-numeric should be converted to 0; PAGE:uk.w:Стратосфера; DATE:2014-07-26
|
||||
@Test public void Poly_pass_chars_2() {fxt.Test_shape("poly 1a 2a [[A]]" , fxt.itm_poly_("[[A]]", 0, 0));} // PURPOSE: non-numeric should be converted to 0; PAGE:ru.w:Системный_блок; DATE:2014-10-22
|
||||
@Test public void Poly_pass_dots() {fxt.Test_shape("poly 1.2 3.4 [[A]]" , fxt.itm_poly_("[[A]]", 1.2d, 3.4d));} // PURPOSE: make sure decimals are handled correctly
|
||||
@Test public void Poly_pass_commas() {fxt.Test_shape("poly 1, 2, 3, 4 [[A]]" , fxt.itm_poly_("[[A]]", 1, 2, 3, 4));} // PURPOSE: commas should be ignored; PAGE:de.w:Kaimnitz; DATE:2014-08-05
|
||||
@Test public void Poly_pass_commas_2() {fxt.Test_shape("poly 1,2 3,4 [[A]]" , fxt.itm_poly_("[[A]]", 1, 3));} // PURPOSE: commas should be ignored for purpose of parse; PAGE:fr.w:Gouesnou; DATE:2014-08-12
|
||||
@Test public void Poly_pass_commas_3() {fxt.Test_shape("poly ,1 2 [[A]]" , fxt.itm_poly_("[[A]]", 1, 2));} // PURPOSE: do not fail if comma is at start of number; PAGE:en.w:Area_codes_281,_346,_713,_and_832; DATE:2015-07-31
|
||||
@Test public void Rect_fail() {fxt.Test_shape_err("rect 1 2 3 [[A]]" , "imagemap_missing_coord");}
|
||||
@Test public void Circle_fail() {fxt.Test_shape_err("circle 1 2 [[A]]" , "imagemap_missing_coord");}
|
||||
@Test public void Poly_fail_odd() {fxt.Test_shape_err("poly 1 2 3 [[A]]" , "imagemap_poly_odd");}
|
||||
@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_parser_fxt extends Imap_base_fxt {
|
||||
private Imap_parser parser;
|
||||
private Imap_map imap;
|
||||
@Override public void Reset() {
|
||||
super.Reset();
|
||||
byte[] ttl_bry = Bry_.new_a7("Test_1");
|
||||
Imap_xtn_mgr xtn_mgr = new Imap_xtn_mgr();
|
||||
Xoae_page page = Xoae_page.New(wiki, wiki.Ttl_parse(ttl_bry));
|
||||
parser = new Imap_parser(xtn_mgr);
|
||||
parser.Init(wiki, page, Gfo_usr_dlg_.Noop);
|
||||
parser.Clear();
|
||||
imap = new Imap_map(1);
|
||||
}
|
||||
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_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.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()));
|
||||
}
|
||||
Tfds.Eq(0, imap.Errs().length, "expd 0 errors");
|
||||
}
|
||||
public void Test_shape_err(String raw_str, String expd_err) {
|
||||
raw_str = "File:A.png\n" + raw_str;
|
||||
byte[] raw = Bry_.new_u8(raw_str);
|
||||
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_msg());
|
||||
}
|
||||
}
|
||||
@@ -1,42 +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.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) {
|
||||
// init
|
||||
xtn_mgr = wiki.Xtn_mgr().Xtn_imap().Xtn_assert();
|
||||
Xoae_page page = ctx.Page();
|
||||
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, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) {
|
||||
if (imap_data.Invalid()) return;
|
||||
html_wtr.Write_tkn_to_html(bfr, ctx, hctx, imap_data.Img_src(), xnde, Xoh_html_wtr.Sub_idx_null, imap_data.Img().Img_link());
|
||||
}
|
||||
}
|
||||
@@ -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.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 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;
|
||||
}
|
||||
@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_")
|
||||
;
|
||||
}
|
||||
@@ -1,48 +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.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\" 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>"
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,208 +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.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_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>"
|
||||
, "File:A.png|thumb|123px|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 id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // 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 id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
@Test public void Caption_xml() { // PURPOSE: xnde in caption was being escaped; PAGE:en.w:Council_of_Europe; DATE:2014-07-25
|
||||
fxt.Test_html_full_frag("<imagemap>File:A.png|thumb|<b>c</b>\n</imagemap>", "<b>c</b>");
|
||||
}
|
||||
@Test public void Default() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|a1"
|
||||
, "default [[B|b1]]"
|
||||
, "</imagemap>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // 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\">"
|
||||
, " </map>"
|
||||
, " <a href=\"/wiki/B\" title=\"b1\">"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" usemap=\"#imageMap_1_1\"/>"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " <div class=\"thumbcaption\">"
|
||||
, "<div class=\"magnify\"><a href=\"/wiki/File:A.png\" class=\"internal\" title=\"Enlarge\"></a></div>a1"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
, "</div>"
|
||||
));
|
||||
}
|
||||
@Test public void Desc() {
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|123px|a1"
|
||||
, "desc top-left"
|
||||
, "</imagemap>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"imap_div_0\" class=\"noresize\" style=\"height:0px; width: 123px;\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"a1\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" usemap=\"#imageMap_1_1\"/>"
|
||||
, " <div style=\"margin-left:0px; margin-top:1px; text-align:left;\">"
|
||||
, " <a href=\"/wiki/File:A.png\" title=\"click here\">"
|
||||
, " <img alt=\"click here\" src=\"file:///mem/xowa/bin/any/xowa/xtns/ImageMap/imgs/desc-20.png\" style=\"border: none;\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
, " </div>"
|
||||
));
|
||||
}
|
||||
@Test public void Lnke() { // PURPOSE: handle shapes with lnke; PAGE:en.w:Cholesterolt DATE:2014-07-25
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|a1"
|
||||
, "circle 0 0 5 [[http://b.org b1]]"
|
||||
, "desc none"
|
||||
, "</imagemap>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // 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=\"http://b.org\" shape=\"circle\" coords=\"0,0,5\" alt=\"b1\" title=\"b1\"/>"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
@Test public void Err_trailing_ws() { // PURPOSE: empty 1st line causes failure
|
||||
fxt.Test_html_full_frag(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap> "
|
||||
, "File:A.png|thumb|test_caption"
|
||||
, "</imagemap>"
|
||||
), "test_caption" // no error if test_caption appears;
|
||||
);
|
||||
}
|
||||
@Test public void Para_omitted() { // PURPOSE: imagemap should not be automatically enclosed in para; PAGE:cs.w:Seznam_clenu_ctrn<72>ct<63>ho_Knesetu; DATE:2014-05-08;
|
||||
fxt.Fxt().Init_para_y_();
|
||||
fxt.Test_html_full_str("<imagemap>File:A.png</imagemap> a", fxt.Frag_html_full() + " a"); // NOTE: "a" no longer enclosed in <p>; DATE:2014-07-25
|
||||
fxt.Fxt().Init_para_n_();
|
||||
}
|
||||
@Test public void Xnde_double_pipe() {// PURPOSE: if || is inside table and imagemap, treat as lnki; EX:w:United_States_presidential_election,_1992; DATE:2014-03-29; DATE:2014-05-06
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "{|"
|
||||
, "|-"
|
||||
, "| z"
|
||||
, "<imagemap>"
|
||||
, "File:A.png||123px|b" // NOTE: "||" should not be tblw; also should not be pipe + text; if it is pipe + text, then caption will be "|123px" and width will be -1; DATE:2014-05-06
|
||||
, "</imagemap>"
|
||||
, "|}"
|
||||
) , String_.Concat_lines_nl_skip_last
|
||||
( "<table>"
|
||||
, " <tr>"
|
||||
, " <td> z"
|
||||
, "<div id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"b\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" usemap=\"#imageMap_1_1\"/>" // NOTE: width must be 123, not 0
|
||||
, " </div>"
|
||||
, " </td>"
|
||||
, " </tr>"
|
||||
, "</table>"
|
||||
, ""
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Template_image() { // PURPOSE: handle templates in caption; PAGE:en.w:Kilauea; DATE:2014-07-27
|
||||
fxt.Fxt().Init_page_create("Template:Test_template", "xyz");
|
||||
fxt.Test_html_full_frag("<imagemap>File:A.png|thumb|{{Test_template}}\n</imagemap>", "xyz");
|
||||
}
|
||||
@Test public void Template_shape() { // PURPOSE: handle templates in shape; PAGE:fr.w:Arrondissements_de_Lyon DATE:2014-08-12
|
||||
fxt.Fxt().Init_page_create("Template:B1", "<b>b1</b>"); // note that an xnde is a better example as it will throw ArrayOutOfBounds error
|
||||
fxt.Test_html_full_str(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|123px|a1"
|
||||
, "circle 0 0 5 [[B|{{b1}}]]"
|
||||
, "desc none"
|
||||
, "</imagemap>"
|
||||
), String_.Concat_lines_nl_skip_last
|
||||
( "<div class=\"thumb tright\">"
|
||||
, " <div id=\"xowa_file_div_0\" class=\"thumbinner\" style=\"width:220px;\">" // 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\"/>"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/thumb/7/0/A.png/123px.png\" width=\"123\" height=\"0\" 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>"
|
||||
));
|
||||
}
|
||||
@Test public void Template_multi_line() { // PURPOSE: handle multiple-line captions; PAGE:en.w:Archaea; DATE:2014-08-22
|
||||
fxt.Test_html_full_frag(String_.Concat_lines_nl_skip_last
|
||||
( "<imagemap>"
|
||||
, "File:A.png|thumb|<ref>text"
|
||||
, "</ref>"
|
||||
, "</imagemap>"
|
||||
), "id=\"cite_ref-0\"");
|
||||
}
|
||||
}
|
||||
class Imap_xnde_html_fxt {
|
||||
public void Reset() {
|
||||
fxt.Reset();
|
||||
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 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() {
|
||||
return String_.Concat_lines_nl_skip_last
|
||||
( "<div id=\"imap_div_0\" class=\"noresize\">"
|
||||
, " <map name=\"imageMap_1_1\">"
|
||||
, " </map>"
|
||||
, " <img id=\"xoimg_0\" alt=\"\" src=\"file:///mem/wiki/repo/trg/orig/7/0/A.png\" width=\"0\" height=\"0\" usemap=\"#imageMap_1_1\"/>"
|
||||
, " </div>"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,65 +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.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.brys.fmtrs.*;
|
||||
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>"
|
||||
), "imap_id", "desc_style", "map", "img"
|
||||
)
|
||||
, Map = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <map name=\"imageMap_1_~{imap_id}\">~{shapes}"
|
||||
, " </map>"
|
||||
), "imap_id", "shapes"
|
||||
)
|
||||
, Area = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( "\n <area href=\"~{href}\" shape=\"~{shape}\" coords=\"~{coords}\" alt=\"~{title}\" title=\"~{title}\"/>"
|
||||
), "href", "shape", "coords", "title")
|
||||
, Img_anchor_none = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <img id=\"xoimg_~{img_elem_id}\" alt=\"~{img_alt}\"~{img_core}~{img_cls} usemap=\"#imageMap_1_~{imap_id}\"/>"
|
||||
), "imap_id", "img_elem_id", "img_alt", "img_core", "img_cls", "anchor_href", "anchor_title"
|
||||
)
|
||||
, Img_anchor_lnki = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <a href=\"~{anchor_href}\" title=\"~{anchor_title}\">"
|
||||
, " <img id=\"xoimg_~{img_elem_id}\" alt=\"~{img_alt}\"~{img_core}~{img_cls} usemap=\"#imageMap_1_~{imap_id}\"/>"
|
||||
, " </a>"
|
||||
), "imap_id", "img_elem_id", "img_alt", "img_core", "img_cls", "anchor_href", "anchor_title"
|
||||
)
|
||||
, Img_anchor_lnke = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <a href=\"~{anchor_href}\" title=~{anchor_title} class=\"plainlinks\" rel=\"nofollow\">"
|
||||
, " <img id=\"xoimg_~{img_elem_id}\" alt=\"~{img_alt}\"~{img_core}~{img_cls} usemap=\"#imageMap_1_~{imap_id}\"/>"
|
||||
, " </a>"
|
||||
), "imap_id", "img_elem_id", "img_alt", "img_core", "img_cls", "anchor_href", "anchor_title"
|
||||
)
|
||||
, Desc_style = Bry_fmtr.new_(" style=\"height:~{div_h}px; width: ~{div_w}px;\"", "div_w", "div_h")
|
||||
, Desc_main = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
|
||||
( ""
|
||||
, " <div style=\"margin-left:~{margin_left}px; margin-top:~{margin_top}px; text-align:left;\">"
|
||||
, " <a href=\"~{img_href}\" title=\"~{msg_desc}\">"
|
||||
, " <img alt=\"~{msg_desc}\" src=\"~{icon_url}\" style=\"border: none;\" />"
|
||||
, " </a>"
|
||||
, " </div>"
|
||||
), "margin_left", "margin_top", "img_href", "msg_desc", "icon_url"
|
||||
);
|
||||
}
|
||||
@@ -1,78 +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.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.*;
|
||||
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();
|
||||
private final boolean orig_exists;
|
||||
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, boolean orig_exists) {
|
||||
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;
|
||||
this.orig_exists = orig_exists;
|
||||
}
|
||||
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_part_dflt itm_dflt = map.Dflt();
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
Bry_bfr tmp_bfr = Bry_bfr_.Get();
|
||||
try {
|
||||
byte[] data_xowa_image = Xoh_file_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();
|
||||
int img_w_tmp = img_w; int img_h_tmp = img_h;
|
||||
byte[] img_src_tmp = img_src;
|
||||
if (orig_exists) {
|
||||
data_xowa_image = data_xowa_title = Bry_.Empty;
|
||||
}
|
||||
else {
|
||||
img_w_tmp = img_h_tmp = 0;
|
||||
img_src_tmp = Bry_.Empty;
|
||||
}
|
||||
Xoh_file_fmtr__hdump.Add_anch_n(tmp_bfr, data_xowa_title, data_xowa_image, img_src_tmp, img_w_tmp, img_h_tmp, Xoh_img_cls_.Tid__none, 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_arg();
|
||||
img_core_fmtr.Init(img_elem_id, img_src, img_w, img_h);
|
||||
if (itm_dflt != null) {
|
||||
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_part_desc itm_desc = map.Desc();
|
||||
if (itm_desc != null) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +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.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);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +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.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*;
|
||||
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];
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +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.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()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +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.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_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());
|
||||
}
|
||||
}
|
||||
@@ -1,70 +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.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
import gplx.core.primitives.*; import gplx.core.btries.*;
|
||||
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[]
|
||||
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 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();
|
||||
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)
|
||||
Add_to_trie(rv, lang_types);
|
||||
return rv;
|
||||
}
|
||||
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);
|
||||
trie.Add_bry_byte(ary[3] ,Tid_tl);
|
||||
trie.Add_bry_byte(ary[4] ,Tid_none);
|
||||
}
|
||||
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
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +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.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;
|
||||
}
|
||||
@@ -1,25 +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.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);
|
||||
}
|
||||
@@ -1,77 +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.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.*;
|
||||
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 {
|
||||
int tkn_tid = tkn.Tkn_tid();
|
||||
link_owner.Link_tid_(tkn_tid, tkn);
|
||||
switch (tkn_tid) {
|
||||
case Xop_tkn_itm_.Tid_lnki: {
|
||||
Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)tkn;
|
||||
link_owner.Link_href_(wiki.Html__href_wtr().Build_to_bry(wiki, lnki_tkn.Ttl()));
|
||||
wiki.Html_mgr().Html_wtr().Lnki_wtr().Write_caption(bfr, Xoh_wtr_ctx.Alt, src, lnki_tkn, lnki_tkn.Ttl());
|
||||
link_owner.Link_text_(bfr.To_bry_and_clear());
|
||||
break;
|
||||
}
|
||||
case Xop_tkn_itm_.Tid_lnke: {
|
||||
Xop_lnke_tkn lnke = (Xop_lnke_tkn)tkn;
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
|
||||
int lnke_bgn = lnke.Lnke_href_bgn(), lnke_end = lnke.Lnke_href_end(); boolean proto_is_xowa = lnke.Proto_tid() == Gfo_protocol_itm.Tid_xowa;
|
||||
Xoh_lnke_html lnke_wtr = wiki.Html_mgr().Html_wtr().Wkr__lnke();
|
||||
lnke_wtr.Write_href(bfr, Xoh_wtr_ctx.Basic, ctx, src, lnke, lnke_bgn, lnke_end, proto_is_xowa);
|
||||
link_owner.Link_href_(bfr.To_bry_and_clear());
|
||||
lnke_wtr.Write_caption(bfr, wiki.Html_mgr().Html_wtr(), Xoh_wtr_ctx.Basic, ctx, src, lnke, lnke_bgn, lnke_end, proto_is_xowa);
|
||||
link_owner.Link_text_(bfr.To_bry_and_clear());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
public static void Write_todo(Imap_link_owner link_owner, Xoae_app app, Xowe_wiki wiki, Xoh_wtr_ctx hctx, byte[] src) {
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
try {
|
||||
switch (link_owner.Link_tid()) {
|
||||
case Xop_tkn_itm_.Tid_lnki: {
|
||||
Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)link_owner.Link_tkn();
|
||||
link_owner.Link_href_(wiki.Html__href_wtr().Build_to_bry(wiki, lnki_tkn.Ttl()));
|
||||
wiki.Html_mgr().Html_wtr().Lnki_wtr().Write_caption(bfr, hctx, src, lnki_tkn, lnki_tkn.Ttl());
|
||||
link_owner.Link_text_(bfr.To_bry_and_clear());
|
||||
break;
|
||||
}
|
||||
case Xop_tkn_itm_.Tid_lnke: {
|
||||
Xop_lnke_tkn lnke = (Xop_lnke_tkn)link_owner.Link_tkn();
|
||||
Xop_ctx ctx = wiki.Parser_mgr().Ctx();
|
||||
int lnke_bgn = lnke.Lnke_href_bgn(), lnke_end = lnke.Lnke_href_end(); boolean proto_is_xowa = lnke.Proto_tid() == Gfo_protocol_itm.Tid_xowa;
|
||||
Xoh_lnke_html lnke_wtr = wiki.Html_mgr().Html_wtr().Wkr__lnke();
|
||||
lnke_wtr.Write_href(bfr, Xoh_wtr_ctx.Basic, ctx, src, lnke, lnke_bgn, lnke_end, proto_is_xowa);
|
||||
link_owner.Link_href_(bfr.To_bry_and_clear());
|
||||
lnke_wtr.Write_caption(bfr, wiki.Html_mgr().Html_wtr(), hctx, ctx, src, lnke, lnke_bgn, lnke_end, proto_is_xowa);
|
||||
link_owner.Link_text_(bfr.To_bry_and_clear());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,21 +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.itms; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.imaps.*;
|
||||
public interface Imap_part {
|
||||
byte Part_tid();
|
||||
}
|
||||
@@ -1,45 +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.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +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.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;
|
||||
}
|
||||
@@ -1,26 +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.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;}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.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;
|
||||
}
|
||||
@@ -1,34 +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.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;
|
||||
}
|
||||
Reference in New Issue
Block a user