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

@@ -0,0 +1,70 @@
/*
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;
}
}

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

@@ -0,0 +1,77 @@
/*
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_(app.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_(app.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
}
}

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;
}