mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-09-30 07:20:52 +00:00
Mw_parse: Add initial implementation for thumbnails
This commit is contained in:
parent
8011f9e979
commit
b30f10b647
@ -74,8 +74,8 @@ public class Gftest {
|
|||||||
public static void Eq__bry(byte[] expd, byte[] actl, String msg_fmt, Object... msg_args) {
|
public static void Eq__bry(byte[] expd, byte[] actl, String msg_fmt, Object... msg_args) {
|
||||||
if (Bry_.Eq(expd, actl)) return;
|
if (Bry_.Eq(expd, actl)) return;
|
||||||
Write_fail_head(bfr, msg_fmt, msg_args);
|
Write_fail_head(bfr, msg_fmt, msg_args);
|
||||||
bfr.Add_str_a7("expd: ").Add(expd).Add_byte_nl();
|
bfr.Add_str_a7("expd: ").Add_safe(expd).Add_byte_nl();
|
||||||
bfr.Add_str_a7("actl: ").Add(actl).Add_byte_nl();
|
bfr.Add_str_a7("actl: ").Add_safe(actl).Add_byte_nl();
|
||||||
bfr.Add(Bry__line_end);
|
bfr.Add(Bry__line_end);
|
||||||
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
throw Err_.new_wo_type(bfr.To_str_and_clear());
|
||||||
}
|
}
|
||||||
|
@ -44,21 +44,20 @@ public class Xomw_MagicWordArray {
|
|||||||
for (int i = 0; i < synonyms_len; i++) {
|
for (int i = 0; i < synonyms_len; i++) {
|
||||||
Xomw_MagicWordSynonym synonym = synonyms[i];
|
Xomw_MagicWordSynonym synonym = synonyms[i];
|
||||||
switch (synonym.arg1_tid) {
|
switch (synonym.arg1_tid) {
|
||||||
|
case Xomw_MagicWordSynonym.Arg1__nil:
|
||||||
case Xomw_MagicWordSynonym.Arg1__end:
|
case Xomw_MagicWordSynonym.Arg1__end:
|
||||||
if (fwd_trie == null) fwd_trie = word.case_match ? Btrie_slim_mgr.cs() : Btrie_slim_mgr.ci_u8();
|
if (fwd_trie == null) fwd_trie = word.case_match ? Btrie_slim_mgr.cs() : Btrie_slim_mgr.ci_u8();
|
||||||
fwd_trie.Add_obj(synonym.text, synonym);
|
fwd_trie.Add_obj(synonym.text_wo_arg1, synonym);
|
||||||
break;
|
break;
|
||||||
case Xomw_MagicWordSynonym.Arg1__bgn:
|
case Xomw_MagicWordSynonym.Arg1__bgn:
|
||||||
if (bwd_trie == null) bwd_trie = Btrie_bwd_mgr.c__(word.case_match);
|
if (bwd_trie == null) bwd_trie = Btrie_bwd_mgr.c__(word.case_match);
|
||||||
bwd_trie.Add(synonym.text, synonym);
|
bwd_trie.Add(synonym.text_wo_arg1, synonym);
|
||||||
break;
|
break;
|
||||||
// ignore if mid / mix
|
// ignore if mid / mix
|
||||||
case Xomw_MagicWordSynonym.Arg1__mid:
|
case Xomw_MagicWordSynonym.Arg1__mid:
|
||||||
case Xomw_MagicWordSynonym.Arg1__mix:
|
case Xomw_MagicWordSynonym.Arg1__mix:
|
||||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "MagicWordArray: unsupported arg_1_tid: tid=~{0}", synonym.arg1_tid);
|
Gfo_usr_dlg_.Instance.Warn_many("", "", "MagicWordArray: unsupported arg_1_tid: tid=~{0}", synonym.arg1_tid);
|
||||||
continue;
|
continue;
|
||||||
case Xomw_MagicWordSynonym.Arg1__nil:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,7 +252,7 @@ public class Xomw_MagicWordArray {
|
|||||||
|
|
||||||
// check bwd; EX: "$1px"
|
// check bwd; EX: "$1px"
|
||||||
if (bwd_trie != null) {
|
if (bwd_trie != null) {
|
||||||
Object o = bwd_trie.Match_at(trv, src, src_end, -1);
|
Object o = bwd_trie.Match_at(trv, src, src_end - 1, -1);
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
return ((Xomw_MagicWordSynonym)o).magic_name;
|
return ((Xomw_MagicWordSynonym)o).magic_name;
|
||||||
}
|
}
|
||||||
|
62
400_xowa/src/gplx/xowa/mws/Xomw_MagicWordArray__tst.java
Normal file
62
400_xowa/src/gplx/xowa/mws/Xomw_MagicWordArray__tst.java
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
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.mws; import gplx.*; import gplx.xowa.*;
|
||||||
|
import org.junit.*; import gplx.core.tests.*;
|
||||||
|
public class Xomw_MagicWordArray__tst {
|
||||||
|
private final Xomw_MagicWordArray__fxt fxt = new Xomw_MagicWordArray__fxt();
|
||||||
|
@Test public void Nil() {
|
||||||
|
fxt.Init__word(Bool_.Y, "nil", "nil");
|
||||||
|
fxt.Init__ary("nil");
|
||||||
|
fxt.Test__matchVariableStartToEnd("nil", "nil", "nila");
|
||||||
|
}
|
||||||
|
@Test public void Bgn() {
|
||||||
|
fxt.Init__word(Bool_.Y, "bgn", "bgn$1");
|
||||||
|
fxt.Init__ary("bgn");
|
||||||
|
fxt.Test__matchVariableStartToEnd("bgn", "bgn", "bgna");
|
||||||
|
}
|
||||||
|
@Test public void End() {
|
||||||
|
fxt.Init__word(Bool_.Y, "end", "$1end");
|
||||||
|
fxt.Init__ary("end");
|
||||||
|
fxt.Test__matchVariableStartToEnd("end", "end", "aend");
|
||||||
|
}
|
||||||
|
@Test public void Smoke() {
|
||||||
|
fxt.Init__word(Bool_.Y, "img_upright", "upright", "upright=$1", "upright $1");
|
||||||
|
fxt.Init__word(Bool_.Y, "img_width", "$1px");
|
||||||
|
fxt.Init__ary("img_upright", "img_width");
|
||||||
|
|
||||||
|
fxt.Test__matchVariableStartToEnd("img_upright", "upright", "upright=123", "upright 123");
|
||||||
|
fxt.Test__matchVariableStartToEnd("img_width", "123px");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Xomw_MagicWordArray__fxt {
|
||||||
|
private final Xomw_MagicWordMgr magic_word_mgr = new Xomw_MagicWordMgr();
|
||||||
|
private Xomw_MagicWordArray magic_word_ary;
|
||||||
|
public void Init__word(boolean cs, String word, String... synonyms) {
|
||||||
|
magic_word_mgr.Add(Bry_.new_u8(word), cs, Bry_.Ary(synonyms));
|
||||||
|
}
|
||||||
|
public void Init__ary(String... words) {
|
||||||
|
magic_word_ary = new Xomw_MagicWordArray(magic_word_mgr, Bry_.Ary(words));
|
||||||
|
}
|
||||||
|
public void Test__matchVariableStartToEnd(String expd_str, String... vals) {
|
||||||
|
byte[] expd = Bry_.new_u8(expd_str);
|
||||||
|
for (String val : vals) {
|
||||||
|
byte[] actl = magic_word_ary.matchVariableStartToEnd(Bry_.new_u8(val));
|
||||||
|
Gftest.Eq__bry(expd, actl, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.mws; import gplx.*; import gplx.xowa.*;
|
package gplx.xowa.mws; import gplx.*; import gplx.xowa.*;
|
||||||
public class Xomw_MagicWordMgr {
|
public class Xomw_MagicWordMgr {
|
||||||
|
private final Hash_adp_bry hash = Hash_adp_bry.cs();
|
||||||
|
public void Add(byte[] name, boolean cs, byte[]... synonyms) {
|
||||||
|
Xomw_MagicWord mw = new Xomw_MagicWord(name, cs, synonyms);
|
||||||
|
hash.Add(name, mw);
|
||||||
|
}
|
||||||
public Xomw_MagicWord Get(byte[] name) {
|
public Xomw_MagicWord Get(byte[] name) {
|
||||||
return null;
|
return (Xomw_MagicWord)hash.Get_by(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,24 @@ public class Xomw_MagicWordSynonym {
|
|||||||
public final byte[] magic_name;
|
public final byte[] magic_name;
|
||||||
public final boolean case_match;
|
public final boolean case_match;
|
||||||
public final byte[] text;
|
public final byte[] text;
|
||||||
|
public final byte[] text_wo_arg1;
|
||||||
public final byte arg1_tid;
|
public final byte arg1_tid;
|
||||||
public Xomw_MagicWordSynonym(byte[] magic_name, boolean case_match, byte[] text) {
|
public Xomw_MagicWordSynonym(byte[] magic_name, boolean case_match, byte[] text) {
|
||||||
this.magic_name = magic_name;
|
this.magic_name = magic_name;
|
||||||
this.case_match = case_match;
|
this.case_match = case_match;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.arg1_tid = Get_arg1_tid(text);
|
this.arg1_tid = Get_arg1_tid(text);
|
||||||
|
switch (arg1_tid) {
|
||||||
|
case Arg1__bgn:
|
||||||
|
text_wo_arg1 = Bry_.Mid(text, 2);
|
||||||
|
break;
|
||||||
|
case Arg1__end:
|
||||||
|
text_wo_arg1 = Bry_.Mid(text, 0, text.length - 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text_wo_arg1 = text;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte Get_arg1_tid(byte[] src) {
|
private static byte Get_arg1_tid(byte[] src) {
|
||||||
@ -53,11 +65,11 @@ public class Xomw_MagicWordSynonym {
|
|||||||
else if (rv == Arg1__mid)
|
else if (rv == Arg1__mid)
|
||||||
rv = Arg1__mix;
|
rv = Arg1__mix;
|
||||||
}
|
}
|
||||||
cur += 3;
|
cur += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cur += 2;
|
cur += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
|
|
||||||
Xomw_image_params tmp_img_params = new Xomw_image_params();
|
Xomw_image_params tmp_img_params = new Xomw_image_params();
|
||||||
this.getImageParams(tmp_img_params, handler2);
|
this.getImageParams(tmp_img_params, handler2);
|
||||||
// Xomw_param_map paramMap = tmp_img_params.paramMap;
|
Xomw_param_map paramMap = tmp_img_params.paramMap;
|
||||||
Xomw_MagicWordArray mwArray = tmp_img_params.mwArray;
|
Xomw_MagicWordArray mwArray = tmp_img_params.mwArray;
|
||||||
|
|
||||||
// XO.MW.UNSUPPORTED.TrackingCategory:
|
// XO.MW.UNSUPPORTED.TrackingCategory:
|
||||||
@ -498,8 +498,8 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
// Process the input parameters
|
// Process the input parameters
|
||||||
byte[] caption = Bry_.Empty;
|
byte[] caption = Bry_.Empty;
|
||||||
// XO.MW: $params = [ 'frame' => [], 'handler' => [], 'horizAlign' => [], 'vertAlign' => [] ];
|
// XO.MW: $params = [ 'frame' => [], 'handler' => [], 'horizAlign' => [], 'vertAlign' => [] ];
|
||||||
Xomw_prm_mgr param_map = new Xomw_prm_mgr();
|
// Xomw_prm_mgr param_map = new Xomw_prm_mgr();
|
||||||
Xomw_prm_mgr param_mgr = new Xomw_prm_mgr();
|
// Xomw_prm_mgr param_mgr = new Xomw_prm_mgr();
|
||||||
Xomw_img_prms frame = new Xomw_img_prms();
|
Xomw_img_prms frame = new Xomw_img_prms();
|
||||||
Xomw_mda_prms handler = new Xomw_mda_prms();
|
Xomw_mda_prms handler = new Xomw_mda_prms();
|
||||||
boolean seen_format = false;
|
boolean seen_format = false;
|
||||||
@ -510,15 +510,14 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
byte[] part = parts[i];
|
byte[] part = parts[i];
|
||||||
part = Bry_.Trim(part);
|
part = Bry_.Trim(part);
|
||||||
byte[] magic_name = mwArray.matchVariableStartToEnd(part);
|
byte[] magic_name = mwArray.matchVariableStartToEnd(part);
|
||||||
// byte[] magic_name = null;
|
|
||||||
boolean validated = false;
|
boolean validated = false;
|
||||||
|
|
||||||
Xomw_prm_itm prm_itm = param_map.Get_or_null(magic_name);
|
Xomw_param_itm prm_itm = paramMap.Get_by(magic_name);
|
||||||
if (prm_itm != null) {
|
if (prm_itm != null) {
|
||||||
int prm_type = prm_itm.type;
|
int prm_type = -1;
|
||||||
int prm_name = prm_itm.name_type;
|
int paramNameType = prm_itm.name_type;
|
||||||
// Special case; width and height come in one variable together
|
// Special case; width and height come in one variable together
|
||||||
if (prm_type == Xomw_prm_itm.Type__handler && prm_name == Xomw_prm_itm.Name__width) {
|
if (prm_type == Xomw_prm_itm.Type__handler && paramNameType == Xomw_prm_itm.Name__width) {
|
||||||
// $parsedWidthParam = $this->parseWidthParam($value);
|
// $parsedWidthParam = $this->parseWidthParam($value);
|
||||||
// if (isset($parsedWidthParam['width'])) {
|
// if (isset($parsedWidthParam['width'])) {
|
||||||
// $width = $parsedWidthParam['width'];
|
// $width = $parsedWidthParam['width'];
|
||||||
@ -543,17 +542,17 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Validate @gplx.Internal protected parameters
|
// Validate @gplx.Internal protected parameters
|
||||||
switch (prm_name) {
|
switch (paramNameType) {
|
||||||
case Xomw_prm_itm.Name__manual_thumb:
|
case Xomw_param_itm.Name__manual_thumb:
|
||||||
case Xomw_prm_itm.Name__alt:
|
case Xomw_param_itm.Name__alt:
|
||||||
case Xomw_prm_itm.Name__class:
|
case Xomw_param_itm.Name__class:
|
||||||
// @todo FIXME: Possibly check validity here for
|
// @todo FIXME: Possibly check validity here for
|
||||||
// manualthumb? downstream behavior seems odd with
|
// manualthumb? downstream behavior seems odd with
|
||||||
// missing manual thumbs.
|
// missing manual thumbs.
|
||||||
validated = true;
|
validated = true;
|
||||||
// $value = $this->stripAltText($value, $holders);
|
// $value = $this->stripAltText($value, $holders);
|
||||||
break;
|
break;
|
||||||
case Xomw_prm_itm.Name__link:
|
case Xomw_param_itm.Name__link:
|
||||||
// $chars = self::EXT_LINK_URL_CLASS;
|
// $chars = self::EXT_LINK_URL_CLASS;
|
||||||
// $addr = self::EXT_LINK_ADDR;
|
// $addr = self::EXT_LINK_ADDR;
|
||||||
// $prots = $this->mUrlProtocols;
|
// $prots = $this->mUrlProtocols;
|
||||||
@ -581,12 +580,13 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case Xomw_prm_itm.Name__frameless:
|
case Xomw_param_itm.Name__frameless:
|
||||||
case Xomw_prm_itm.Name__framed:
|
case Xomw_param_itm.Name__framed:
|
||||||
case Xomw_prm_itm.Name__thumbnail:
|
case Xomw_param_itm.Name__thumbnail:
|
||||||
// use first appearing option, discard others.
|
// use first appearing option, discard others.
|
||||||
validated = !seen_format;
|
validated = !seen_format;
|
||||||
seen_format = true;
|
seen_format = true;
|
||||||
|
frame.thumbnail = Bry_.Empty;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Most other things appear to be empty or numeric...
|
// Most other things appear to be empty or numeric...
|
||||||
@ -595,9 +595,9 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if ( $validated ) {
|
if (validated) {
|
||||||
// $params[$type][$paramName] = $value;
|
// $params[$type][$paramName] = $value;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
if (!validated) {
|
if (!validated) {
|
||||||
caption = part;
|
caption = part;
|
||||||
@ -605,13 +605,13 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process alignment parameters
|
// Process alignment parameters
|
||||||
Xomw_prm_itm tmp = param_mgr.Get_or_null(Xomw_prm_mgr.Name__horiz_align);
|
Xomw_param_itm tmp = paramMap.Get_by(Xomw_prm_mgr.Name__horiz_align);
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
frame.align = tmp.val;
|
// frame.align = tmp.val;
|
||||||
}
|
}
|
||||||
tmp = param_mgr.Get_or_null(Xomw_prm_mgr.Name__vert_align);
|
tmp = paramMap.Get_by(Xomw_prm_mgr.Name__vert_align);
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
frame.valign = tmp.val;
|
// frame.valign = tmp.val;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.caption = caption;
|
frame.caption = caption;
|
||||||
@ -706,7 +706,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
|
|||||||
internalParamNames = new Xomw_param_list[]
|
internalParamNames = new Xomw_param_list[]
|
||||||
{ Xomw_param_list.New("horizAlign", "left", "right", "center", "none")
|
{ Xomw_param_list.New("horizAlign", "left", "right", "center", "none")
|
||||||
, Xomw_param_list.New("vertAlign", "baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom")
|
, Xomw_param_list.New("vertAlign", "baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom")
|
||||||
, Xomw_param_list.New("thumbnail", "manual_thumb", "framed", "frameless", "upright", "border", "link", "alt", "class")
|
, Xomw_param_list.New("frame", "thumbnail", "manual_thumb", "framed", "frameless", "upright", "border", "link", "alt", "class")
|
||||||
};
|
};
|
||||||
|
|
||||||
internalParamMap = new Xomw_param_map();
|
internalParamMap = new Xomw_param_map();
|
||||||
@ -830,48 +830,3 @@ class Xomw_image_params {
|
|||||||
public Xomw_param_map paramMap = null;
|
public Xomw_param_map paramMap = null;
|
||||||
public Xomw_MagicWordArray mwArray = null;
|
public Xomw_MagicWordArray mwArray = null;
|
||||||
}
|
}
|
||||||
class Xomw_param_map {
|
|
||||||
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
|
||||||
public byte[][] Keys() {
|
|
||||||
int len = hash.Len();
|
|
||||||
byte[][] rv = new byte[len][];
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
rv[i] = ((Xomw_param_itm)hash.Get_at(i)).magic;
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
public void Add(byte[] magic, byte[] type, byte[] name) {
|
|
||||||
Xomw_param_itm itm = new Xomw_param_itm(magic, type, name);
|
|
||||||
hash.Add(magic, itm);
|
|
||||||
}
|
|
||||||
public Xomw_param_map Clone() {
|
|
||||||
Xomw_param_map rv = new Xomw_param_map();
|
|
||||||
int len = hash.Len();
|
|
||||||
for (int i = 0; i < len; i++) {
|
|
||||||
Xomw_param_itm itm = (Xomw_param_itm)hash.Get_at(i);
|
|
||||||
rv.Add(itm.magic, itm.type, itm.name);
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Xomw_param_itm {
|
|
||||||
public final byte[] magic;
|
|
||||||
public final byte[] type;
|
|
||||||
public final byte[] name;
|
|
||||||
public Xomw_param_itm(byte[] magic, byte[] type, byte[] name) {
|
|
||||||
this.magic = magic;
|
|
||||||
this.type = type;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
class Xomw_param_list {
|
|
||||||
public byte[] type;
|
|
||||||
public byte[][] names;
|
|
||||||
|
|
||||||
public static Xomw_param_list New(String type, String... names) {
|
|
||||||
Xomw_param_list rv = new Xomw_param_list();
|
|
||||||
rv.type = Bry_.new_u8(type);
|
|
||||||
rv.names = Bry_.Ary(names);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -26,4 +26,7 @@ public class Xomw_lnki_wkr__file__tst {
|
|||||||
@Test public void Plain() {
|
@Test public void Plain() {
|
||||||
fxt.Test__to_html("[[File:A.png]]", "<img alt='A.png' src='/orig/7/70/A.png' />");
|
fxt.Test__to_html("[[File:A.png]]", "<img alt='A.png' src='/orig/7/70/A.png' />");
|
||||||
}
|
}
|
||||||
|
@Test public void Thumb() {
|
||||||
|
fxt.Test__to_html("[[File:A.png|thumb]]", "<div class='thumb t'><div class='thumbinner' style='width:2px;'> <div class='thumbcaption'></div></div></div><img alt='A.png' src='/orig/7/70/A.png' />");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ class Xomw_lnki_wkr__fxt {
|
|||||||
|
|
||||||
// env
|
// env
|
||||||
parser.Env().File_finder_(file_finder);
|
parser.Env().File_finder_(file_finder);
|
||||||
|
parser.Env().Magic_word_mgr().Add(Bry_.new_u8("img_thumbnail"), Bool_.Y, Bry_.Ary("thumb"));
|
||||||
parser.Init_by_wiki(wiki);
|
parser.Init_by_wiki(wiki);
|
||||||
|
|
||||||
// ctx
|
// ctx
|
||||||
|
42
400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_param_itm.java
Normal file
42
400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_param_itm.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
XOWA: the XOWA Offline Wiki Application
|
||||||
|
Copyright (C) 2012 gnosygnu@gmail.com
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
|
||||||
|
public class Xomw_param_itm {
|
||||||
|
public final byte[] magic;
|
||||||
|
public final byte[] type;
|
||||||
|
public final byte[] name;
|
||||||
|
public final int name_type;
|
||||||
|
public Xomw_param_itm(byte[] magic, byte[] type, byte[] name) {
|
||||||
|
this.magic = magic;
|
||||||
|
this.type = type;
|
||||||
|
this.name = name;
|
||||||
|
this.name_type = name_types.Get_as_int_or(name, -1);
|
||||||
|
}
|
||||||
|
public static final int
|
||||||
|
Name__width = 0
|
||||||
|
, Name__manual_thumb = 1
|
||||||
|
, Name__alt = 2
|
||||||
|
, Name__class = 3
|
||||||
|
, Name__link = 4
|
||||||
|
, Name__frameless = 5
|
||||||
|
, Name__framed = 6
|
||||||
|
, Name__thumbnail = 7
|
||||||
|
;
|
||||||
|
private static final Hash_adp_bry name_types = Hash_adp_bry.cs()
|
||||||
|
.Add_str_int("thumbnail", Name__thumbnail);
|
||||||
|
}
|
59
400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_param_map.java
Normal file
59
400_xowa/src/gplx/xowa/mws/parsers/lnkis/Xomw_param_map.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
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.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
|
||||||
|
public class Xomw_param_map {
|
||||||
|
private final Ordered_hash hash = Ordered_hash_.New_bry();
|
||||||
|
public Xomw_param_itm Get_by(byte[] name) {
|
||||||
|
return (Xomw_param_itm)hash.Get_by(name);
|
||||||
|
}
|
||||||
|
public Xomw_param_itm Get_by(int name_type) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public byte[][] Keys() {
|
||||||
|
int len = hash.Len();
|
||||||
|
byte[][] rv = new byte[len][];
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
rv[i] = ((Xomw_param_itm)hash.Get_at(i)).magic;
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
public void Add(byte[] magic, byte[] type, byte[] name) {
|
||||||
|
Xomw_param_itm itm = new Xomw_param_itm(magic, type, name);
|
||||||
|
hash.Add(magic, itm);
|
||||||
|
}
|
||||||
|
public Xomw_param_map Clone() {
|
||||||
|
Xomw_param_map rv = new Xomw_param_map();
|
||||||
|
int len = hash.Len();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
Xomw_param_itm itm = (Xomw_param_itm)hash.Get_at(i);
|
||||||
|
rv.Add(itm.magic, itm.type, itm.name);
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Xomw_param_list {
|
||||||
|
public byte[] type;
|
||||||
|
public byte[][] names;
|
||||||
|
|
||||||
|
public static Xomw_param_list New(String type, String... names) {
|
||||||
|
Xomw_param_list rv = new Xomw_param_list();
|
||||||
|
rv.type = Bry_.new_u8(type);
|
||||||
|
rv.names = Bry_.Ary(names);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user