"
@@ -56,7 +57,7 @@ public class Xodb_hdump_mgr__write_tst {
}
@Test public void Video_thumb() {
fxt.Expd_itms_xfers(fxt.Make_xfer(0, 0, 0, "A.ogv", ""));
- fxt.Test_write
+ fxt.Test_write_all
( "[[File:A.ogv|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
( "
"
, "
"
@@ -74,12 +75,34 @@ public class Xodb_hdump_mgr__write_tst {
, "
"
));
}
+ @Test public void Hiero() {
+ Hiero_html_mgr_fxt hiero_fxt = new Hiero_html_mgr_fxt(fxt.Fxt());
+ hiero_fxt.Reset();
+ hiero_fxt.Init_hiero_A1_B1();
+ fxt.Test_write_frag("
A1", "src='~{xowa_hiero_dir}hiero_A1.png'");
+ }
+ @Test public void Gallery() {
+ fxt.Test_write_all
+ ( "
File:A.png|A1", String_.Concat_lines_nl_skip_last
+ ( "
"
+ , " - "
+ , "
"
+ , "
A.png
"
+ , "
"
+ , "
"
+ , " "
+ , "
"
+ ));
+ }
}
class Xodb_hdump_mgr__base_fxt {
protected Xodb_hdump_mgr hdump_mgr;
protected Bry_bfr bfr = Bry_bfr.reset_(255);
protected Xow_wiki wiki; protected Xoa_page page;
- public Xop_fxt Fxt() {return fxt;} protected Xop_fxt fxt;
+ public Xop_fxt Fxt() {return fxt;} protected Xop_fxt fxt;
public void Clear() {
if (fxt == null) {
fxt = new Xop_fxt();
@@ -101,23 +124,25 @@ class Xodb_hdump_mgr__base_fxt {
class Xodb_hdump_mgr__write_fxt extends Xodb_hdump_mgr__base_fxt {
private ListAdp expd_itms_xfers = ListAdp_.new_();
@Override public void Clear_end() {expd_itms_xfers.Clear();}
- public Xof_xfer_itm Make_xfer(int uid, int img_w, int img_h, String lnki_ttl, String img_src) {
- Xof_xfer_itm rv = new Xof_xfer_itm();
- rv.Init_for_test__hdump(uid, img_w, img_h, Bry_.new_utf8_(lnki_ttl), Bry_.new_utf8_(img_src));
- return rv;
- }
- public void Expd_itms_xfers(Xof_xfer_itm... itms) {expd_itms_xfers.AddMany((Object[])itms);}
- public void Test_write(String raw, String expd_html) {
+ public Hdump_data_img__base Make_xfer(int uid, int img_w, int img_h, String lnki_ttl, String img_src) {return new Hdump_data_img__basic().Init_by_base(uid, img_w, img_h, Bry_.new_utf8_(lnki_ttl), Bry_.new_utf8_(img_src));}
+ public void Expd_itms_xfers(Hdump_data_img__base... itms) {expd_itms_xfers.AddMany((Object[])itms);}
+ public void Test_write_all (String raw, String expd_html) {Test_write(Bool_.N, raw, expd_html);}
+ public void Test_write_frag(String raw, String expd_frag) {Test_write(Bool_.Y, raw, expd_frag);}
+ public void Test_write(boolean frag, String raw, String expd_html) {
this.Exec_write(raw);
- Tfds.Eq_str_lines(expd_html, String_.new_utf8_(page.Hdump_data().Body()));
+ String actl_html = String_.new_utf8_(page.Hdump_data().Body());
+ if (frag)
+ Tfds.Eq_true(String_.Has(actl_html, expd_html), actl_html);
+ else
+ Tfds.Eq_str_lines(expd_html, actl_html);
if (expd_itms_xfers.Count() > 0) Tfds.Eq_ary_str(Xfer_to_str_ary(expd_itms_xfers), Xfer_to_str_ary(page.Hdump_data().Imgs()));
}
private static String[] Xfer_to_str_ary(ListAdp list) {
int len = list.Count();
String[] rv = new String[len];
for (int i = 0; i < len; ++i) {
- Xof_xfer_itm itm = (Xof_xfer_itm)list.FetchAt(i);
- rv[i] = String_.Concat_with_str("|", Int_.XtoStr(itm.Html_uid()), Int_.XtoStr(itm.Html_w()), Int_.XtoStr(itm.Html_h()), String_.new_utf8_(itm.Html_view_src_rel()));
+ Hdump_data_img__base itm = (Hdump_data_img__base)list.FetchAt(i);
+ rv[i] = itm.XtoStr();
}
return rv;
}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_img_itm.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__base.java
similarity index 50%
rename from 400_xowa/src/gplx/xowa/hdumps/core/Hdump_img_itm.java
rename to 400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__base.java
index 2cfd6e3c6..e6db07333 100644
--- a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_img_itm.java
+++ b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__base.java
@@ -16,21 +16,38 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
.
*/
package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
-public class Hdump_img_itm {
- public Hdump_img_itm(int idx, int view_w, int view_h, byte[] lnki_ttl, byte[] view_src) {
- this.idx = idx;
+import gplx.xowa.hdumps.dbs.*;
+public abstract class Hdump_data_img__base implements XtoStrAble {
+ public Hdump_data_img__base Init_by_base(int uid, int view_w, int view_h, byte[] lnki_ttl, byte[] view_src) {
+ this.uid = uid;
this.view_w = view_w;
this.view_h = view_h;
this.lnki_ttl = lnki_ttl;
this.view_src = view_src;
+ return this;
}
- public int Idx() {return idx;} private int idx;
- public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
+ public abstract int Tid();
+ public int Uid() {return uid;} private int uid;
public int View_w() {return view_w;} private int view_w;
public int View_h() {return view_h;} private int view_h;
+ public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
public byte[] View_src() {return view_src;} private byte[] view_src;
- @Override public String toString() {
- return String_.Concat_with_str("|", Int_.XtoStr(idx), Int_.XtoStr(view_w), Int_.XtoStr(view_h), String_.new_utf8_(lnki_ttl), String_.new_utf8_(view_src));
+ public String XtoStr() {
+ return String_.Concat_with_str("|", Int_.XtoStr(this.Tid()), Int_.XtoStr(uid), Int_.XtoStr(view_w), Int_.XtoStr(view_h), String_.new_utf8_(lnki_ttl), String_.new_utf8_(view_src));
}
- public static final Hdump_img_itm[] Ary_empty = new Hdump_img_itm[0];
+ public void Write(Bry_bfr bfr) {
+ bfr .Add_int_variable(Hdump_data_tid.Tid_img).Add_byte_pipe()
+ .Add_int_variable(this.Tid()).Add_byte_pipe()
+ .Add_int_variable(uid).Add_byte_pipe()
+ .Add_int_variable(view_w).Add_byte_pipe()
+ .Add_int_variable(view_h).Add_byte_pipe()
+ .Add(lnki_ttl).Add_byte_pipe()
+ .Add(view_src).Add_byte_pipe()
+ ;
+ Write_hook(bfr);
+ bfr.Add_byte_nl();
+ }
+ @gplx.Virtual public void Write_hook(Bry_bfr bfr) {}
+ public static final Hdump_data_img__base[] Ary_empty = new Hdump_data_img__base[0];
+ public static final int Tid_basic = 0, Tid_gallery = 1;
}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__basic.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__basic.java
new file mode 100644
index 000000000..38253991e
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__basic.java
@@ -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
.
+*/
+package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
+public class Hdump_data_img__basic extends Hdump_data_img__base {
+ @Override public int Tid() {return Hdump_data_img__base.Tid_basic;}
+}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__gallery.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__gallery.java
new file mode 100644
index 000000000..7d52f80cd
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_data_img__gallery.java
@@ -0,0 +1,39 @@
+/*
+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
.
+*/
+package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
+public class Hdump_data_img__gallery extends Hdump_data_img__base {
+ @Override public int Tid() {return Hdump_data_img__base.Tid_gallery;}
+ public Hdump_data_img__base Init_by_gallery(int box_max, int box_w, int img_w, int img_pad) {
+ this.box_max = box_max;
+ this.box_w = box_w;
+ this.img_w = img_w;
+ this.img_pad = img_pad;
+ return this;
+ }
+ public int Box_max() {return box_max;} private int box_max;
+ public int Box_w() {return box_w;} private int box_w;
+ public int Img_w() {return img_w;} private int img_w;
+ public int Img_pad() {return img_pad;} private int img_pad;
+ @Override public void Write_hook(Bry_bfr bfr) {
+ bfr .Add_int_variable(box_max).Add_byte_pipe()
+ .Add_int_variable(box_w).Add_byte_pipe()
+ .Add_int_variable(img_w).Add_byte_pipe()
+ .Add_int_variable(img_pad).Add_byte_pipe()
+ ;
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_file_itm.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_file_itm.java
deleted file mode 100644
index 3f5d61c59..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_file_itm.java
+++ /dev/null
@@ -1,59 +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
.
-*/
-package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
-class Hdump_file_itm {
- public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
- public byte Lnki_tid() {return lnki_tid;} private byte lnki_tid;
- public int Lnki_w() {return lnki_w;} private int lnki_w;
- public int Lnki_h() {return lnki_h;} private int lnki_h;
- public byte Lnki_align_x() {return lnki_align_x;} private byte lnki_align_x;
- public byte Lnki_align_y() {return lnki_align_y;} private byte lnki_align_y;
- public byte Lnki_border() {return lnki_border;} private byte lnki_border;
- public double Lnki_upright() {return lnki_upright;} private double lnki_upright;
- public double Lnki_time() {return lnki_time;} private double lnki_time;
- public int Lnki_page() {return lnki_page;} private int lnki_page;
- public boolean Lnki_media_icon() {return lnki_media_icon;} private boolean lnki_media_icon;
- public byte[] Lnki_alt() {return lnki_alt;} private byte[] lnki_alt;
- public byte[] Lnki_caption() {return lnki_caption;} private byte[] lnki_caption;
- public void Parse(byte[] src) {
- int len = src.length;
- int pos = 0;
- int fld_idx = 0, fld_bgn = 0;
- while (pos < len) {
- byte b = src[pos];
- if (b == Byte_ascii.Pipe) {
- switch (fld_idx) {
- case 0: lnki_ttl = Bry_.Mid(src, fld_bgn, pos); break;
- case 2: lnki_tid = Bry_.Xto_byte_by_int(src, fld_bgn, pos, Byte_.MaxValue_127); break;
- case 3: lnki_w = Bry_.Xto_int_or(src, fld_bgn, pos, -1); break;
- case 4: lnki_h = Bry_.Xto_int_or(src, fld_bgn, pos, -1); break;
- case 5: lnki_align_x = Bry_.Xto_byte_by_int(src, fld_bgn, pos, Byte_.MaxValue_127); break;
- case 6: lnki_align_y = Bry_.Xto_byte_by_int(src, fld_bgn, pos, Byte_.MaxValue_127); break;
- case 7: lnki_border = Bry_.Xto_byte_by_int(src, fld_bgn, pos, Byte_.MaxValue_127); break;
- case 8: lnki_upright = Bry_.XtoDoubleByPos(src, fld_bgn, pos); break;
- case 9: lnki_time = Bry_.XtoDoubleByPos(src, fld_bgn, pos); break;
- case 10: lnki_page = Bry_.Xto_int_or(src, fld_bgn, pos, -1); break;
- case 11: lnki_media_icon = src[pos] == Byte_ascii.Ltr_y; break;
- case 12: lnki_alt = Bry_.Mid(src, fld_bgn, pos); break;
- case 13: lnki_caption = Bry_.Mid(src, fld_bgn, pos); break;
- }
- ++fld_idx;
- }
- }
- }
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_module_mgr.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_module_mgr.java
new file mode 100644
index 000000000..fef97a5aa
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_module_mgr.java
@@ -0,0 +1,27 @@
+/*
+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
.
+*/
+package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
+public class Hdump_module_mgr {
+ public boolean Math_exists() {return math_exists;} public void Math_exists_(boolean v) {math_exists = v;} private boolean math_exists;
+ public boolean Imap_exists() {return imap_exists;} public void Imap_exists_(boolean v) {imap_exists = v;} private boolean imap_exists;
+ public boolean Gallery_packed_exists() {return gallery_packed_exists;} public void Gallery_packed_exists_(boolean v) {gallery_packed_exists = v;} private boolean gallery_packed_exists;
+ public boolean Hiero_exists() {return hiero_exists;} public void Hiero_exists_(boolean v) {hiero_exists = v;} private boolean hiero_exists;
+ public void Clear() {
+ math_exists = imap_exists = gallery_packed_exists = hiero_exists = false;
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page.java
new file mode 100644
index 000000000..27e7b3d55
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page.java
@@ -0,0 +1,41 @@
+/*
+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
.
+*/
+package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
+public class Hdump_page {
+ public int Page_id() {return page_id;} private int page_id;
+ public Xoa_url Page_url() {return page_url;} private Xoa_url page_url;
+ public int Version_id() {return version_id;} public void Version_id_(int v) {version_id = v;} private int version_id;
+ public int Img_count() {return img_count;} public void Img_count_(int v) {img_count = v;} private int img_count;
+ public Hdump_module_mgr Module_mgr() {return module_mgr;} private Hdump_module_mgr module_mgr = new Hdump_module_mgr();
+ public byte[] Page_body() {return page_body;} public void Page_body_(byte[] v) {this.page_body = v;} private byte[] page_body;
+ public byte[] Display_ttl() {return display_ttl;} public void Display_ttl_(byte[] v) {this.display_ttl = v;} private byte[] display_ttl;
+ public byte[] Content_sub() {return content_sub;} public void Content_sub_(byte[] v) {this.content_sub = v;} private byte[] content_sub;
+ public byte[] Sidebar_div() {return sidebar_div;} public void Sidebar_div_(byte[] v) {this.sidebar_div = v;} private byte[] sidebar_div;
+ public int[] Redlink_uids() {return redlink_uids;} public void Redlink_uids_(int[] v) {redlink_uids = v;} private int[] redlink_uids;
+ public Hdump_data_img__base[] Img_itms() {return img_itms;} public void Img_itms_(Hdump_data_img__base[] v) {this.img_itms = v;} private Hdump_data_img__base[] img_itms;
+ public OrderedHash Gly_itms() {return gly_itms;} private OrderedHash gly_itms = OrderedHash_.new_();
+ public void Init(int page_id, Xoa_url page_url) {
+ this.page_id = page_id;
+ this.page_url = page_url;
+ content_sub = sidebar_div = Bry_.Empty;
+ display_ttl = null;
+ img_itms = Hdump_data_img__base.Ary_empty;
+ module_mgr.Clear();
+ gly_itms.Clear();
+ }
+}
diff --git a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page_itm.java b/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page_itm.java
deleted file mode 100644
index f2f6e65d1..000000000
--- a/400_xowa/src/gplx/xowa/hdumps/core/Hdump_page_itm.java
+++ /dev/null
@@ -1,38 +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
.
-*/
-package gplx.xowa.hdumps.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
-public class Hdump_page_itm {
- public int Page_id() {return page_id;} private int page_id;
- public Xoa_url Page_url() {return page_url;} private Xoa_url page_url;
- public int Version_id() {return version_id;} public void Version_id_(int v) {version_id = v;} private int version_id;
- public byte[] Page_body() {return page_body;} public void Page_body_(byte[] v) {this.page_body = v;} private byte[] page_body = Bry_.Empty;
- public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl = Bry_.Empty;
- public byte[] Content_sub() {return content_sub;} private byte[] content_sub = Bry_.Empty;
- public byte[][] Sidebar_divs() {return sidebar_divs;} private byte[][] sidebar_divs = Bry_.Ary_empty;
- public Hdump_img_itm[] Img_itms() {return img_itms;} public void Img_itms_(Hdump_img_itm[] v) {this.img_itms = v;} private Hdump_img_itm[] img_itms = Hdump_img_itm.Ary_empty;
- public void Init(int page_id, Xoa_url page_url, int version_id, byte[] display_ttl, byte[] content_sub, byte[] page_body, byte[][] sidebar_divs, Hdump_img_itm[] img_itms) {
- this.page_id = page_id;
- this.page_url = page_url;
- this.version_id = version_id;
- this.display_ttl = display_ttl;
- this.content_sub = content_sub;
- this.page_body = page_body;
- this.sidebar_divs = sidebar_divs;
- this.img_itms = img_itms;
- }
-}
diff --git a/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_data_tid.java b/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_data_tid.java
new file mode 100644
index 000000000..7ce219178
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_data_tid.java
@@ -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
.
+*/
+package gplx.xowa.hdumps.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
+public class Hdump_data_tid { // SERIALIZED
+ public static final int Tid_img = 1, Tid_redlink = 2, Tid_gallery = 3, Tid_imap = 4;
+}
diff --git a/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_row_tid.java b/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_row_tid.java
index af12051cc..618029ba8 100644
--- a/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_row_tid.java
+++ b/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_row_tid.java
@@ -17,5 +17,5 @@ along with this program. If not, see
.
*/
package gplx.xowa.hdumps.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
public class Hdump_text_row_tid { // NOTE: SERIALIZED
- public static final int Tid_body = 0, Tid_img = 1, Tid_gallery = 2, Tid_imap = 3, Tid_display_ttl = 4, Tid_content_sub = 5, Tid_sidebar_div = 6;
+ public static final int Tid_body = 0, Tid_data = 1;
}
diff --git a/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_tbl.java b/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_tbl.java
index f1205fcb9..561db3667 100644
--- a/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_tbl.java
+++ b/400_xowa/src/gplx/xowa/hdumps/dbs/Hdump_text_tbl.java
@@ -19,7 +19,7 @@ package gplx.xowa.hdumps.dbs; import gplx.*; import gplx.xowa.*; import gplx.xow
import gplx.dbs.*;
public class Hdump_text_tbl {
private Db_stmt stmt_select, stmt_insert, stmt_delete;
- public Db_provider Provider() {return provider;} public void Provider_(Db_provider v) {this.Rls_all(); provider = v;} private Db_provider provider;
+ public Db_provider Provider() {return provider;} public Hdump_text_tbl Provider_(Db_provider v) {this.Rls_all(); provider = v; return this;} private Db_provider provider;
@gplx.Virtual public void Delete_by_page(int page_id) {
if (stmt_delete == null) stmt_delete = Db_stmt_.new_delete_(provider, Tbl_name, Fld_page_id);
try {stmt_delete.Clear().Val_int_(page_id).Exec_delete();}
diff --git a/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_consts.java b/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_consts.java
new file mode 100644
index 000000000..a9dbb496a
--- /dev/null
+++ b/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_consts.java
@@ -0,0 +1,63 @@
+/*
+XOWA: the XOWA Offline Wiki Application
+Copyright (C) 2012 gnosygnu@gmail.com
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see
.
+*/
+package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
+import gplx.core.btries.*;
+public class Hdump_html_consts {
+ public static final byte[]
+ A_href_bgn = Bry_.new_ascii_("/wiki/File:")
+ , Bry_img_style_bgn = Bry_.new_ascii_("style='width:")
+ , Bry_img_style_end = Bry_.new_ascii_("px;'")
+ ;
+ public static final byte
+ Tid_dir = 1, Tid_img = 2, Tid_img_style = 3, Tid_file_play = 4, Tid_file_info = 5, Tid_file_mgnf = 6
+ , Tid_hiero_dir = 7, Tid_gallery_box_max = 8, Tid_gallery_box_w = 9, Tid_gallery_img_w = 10, Tid_gallery_img_pad = 11
+ ;
+ public static final byte[]
+ Key_dir = Bry_.new_ascii_("~{xowa_dir}")
+ , Key_img = Bry_.new_ascii_("xowa_img='")
+ , Key_img_style = Bry_.new_ascii_("xowa_img_style='")
+ , Key_file_play = Bry_.new_ascii_("
.
*/
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
-import gplx.core.brys.*; import gplx.core.btries.*; import gplx.xowa.html.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.hdumps.core.*;
+import gplx.core.brys.*; import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.html.*;
+import gplx.xowa.hdumps.core.*; import gplx.xowa.html.lnkis.*; import gplx.xowa.xtns.gallery.*;
public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
private Bry_rdr bry_rdr = new Bry_rdr();
- private Xow_wiki wiki; private Hdump_page_itm page;
- private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_._; private byte[] file_dir;
- public void Init_by_app(Gfo_usr_dlg usr_dlg, byte [] file_dir) {this.usr_dlg = usr_dlg; this.file_dir = file_dir;}
- public void Init_by_page(Xow_wiki wiki, Hdump_page_itm page) {this.wiki = wiki; this.page = page;}
+ private Xow_wiki wiki; private Hdump_page page;
+ private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_._; private byte[] root_dir, file_dir, hiero_img_dir; private Bry_bfr tmp_bfr = Bry_bfr.reset_(255);
+ public void Init_by_app(Xoa_app app) {
+ this.usr_dlg = app.Usr_dlg();
+ this.root_dir = app.Fsys_mgr().Root_dir().To_http_file_bry();
+ this.file_dir = app.Fsys_mgr().File_dir().To_http_file_bry();
+ this.hiero_img_dir = gplx.xowa.xtns.hieros.Hiero_xtn_mgr.Hiero_root_dir(app).GenSubDir("img").To_http_file_bry();
+ }
+ public void Init_by_page(Xow_wiki wiki, Hdump_page page) {this.wiki = wiki; this.page = page;}
public void XferAry(Bry_bfr bfr, int idx) {
byte[] src = page.Page_body(); int len = src.length;
- Hdump_img_itm[] imgs = page.Img_itms(); int imgs_len = page.Img_itms().length;
+ Hdump_data_img__base[] imgs = page.Img_itms(); int imgs_len = page.Img_itms().length;
bry_rdr.Src_(src);
int pos = 0; int rng_bgn = -1;
Xow_html_mgr html_mgr = wiki.Html_mgr();
@@ -44,71 +50,79 @@ public class Hdump_html_fmtr__body implements Bry_fmtr_arg {
}
pos = trie.Match_pos(); // position after match; EX: "xowa_img='" positions after "'"
Hdump_html_fmtr_itm itm = (Hdump_html_fmtr_itm)o;
- pos = Write_img(bfr, html_mgr, html_fmtr, page, src, imgs, imgs_len, pos, itm); // note no +1; Write_img return pos after }
+ pos = Write_data(bfr, html_mgr, html_fmtr, page, src, imgs, imgs_len, pos, itm); // note no +1; Write_data return pos after }
}
}
if (rng_bgn != -1) bfr.Add_mid(src, rng_bgn, len);
}
- private int Write_img(Bry_bfr bfr, Xow_html_mgr html_mgr, Xoh_file_html_fmtr__base fmtr, Hdump_page_itm page, byte[] src, Hdump_img_itm[] imgs, int imgs_len, int uid_bgn, Hdump_html_fmtr_itm itm) {
+ private int Write_data(Bry_bfr bfr, Xow_html_mgr html_mgr, Xoh_file_html_fmtr__base fmtr, Hdump_page hpg, byte[] src, Hdump_data_img__base[] imgs, int imgs_len, int uid_bgn, Hdump_html_fmtr_itm itm) {
bry_rdr.Pos_(uid_bgn);
- int uid = bry_rdr.Read_int_to(Byte_ascii.Apos);
- int uid_end = bry_rdr.Pos(); // set uid_end after "'"
+ int uid = itm.Subst_end_byte() == Byte_ascii.Nil ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
+ int uid_end = bry_rdr.Pos(); // set uid_end after subst_end
int rv = uid_end;
- if (itm.Elem_is_xnde()) rv += 2; // if xnde, skip "/>"
- if (uid == bry_rdr.Or_int()) {usr_dlg.Warn_many("", "", "index is not a valid int; page=~{0} text=~{1}", page.Page_url().Xto_full_str_safe(), Bry_.Mid_safe(src, uid_bgn, uid_end)); return uid_end;}
- if (!Int_.Between(uid, 0, imgs_len)) {usr_dlg.Warn_many("", "", "index is out of range; page=~{0} idx=~{1} len=~{2}", page.Page_url().Xto_full_str_safe(), uid, imgs_len); return uid_end;}
- Hdump_img_itm img = imgs[uid];
- int img_view_w = img.View_w();
byte tid = itm.Tid();
- if (tid == Tid_img_style) {
- bfr.Add(Bry_img_style_bgn);
- bfr.Add_int_variable(img_view_w);
- bfr.Add(Bry_img_style_end);
- return rv;
+ switch (tid) {
+ case Hdump_html_consts.Tid_dir: bfr.Add(root_dir); return rv;
+ case Hdump_html_consts.Tid_hiero_dir: bfr.Add(hiero_img_dir); return rv;
+ }
+ if (itm.Elem_is_xnde()) rv += 2; // if xnde, skip "/>"
+ if (uid == bry_rdr.Or_int()) {usr_dlg.Warn_many("", "", "index is not a valid int; page=~{0} text=~{1}", hpg.Page_url().Xto_full_str_safe(), Bry_.Mid_safe(src, uid_bgn, uid_end)); return uid_end;}
+ if (!Int_.Between(uid, 0, imgs_len)) {usr_dlg.Warn_many("", "", "index is out of range; page=~{0} idx=~{1} len=~{2}", hpg.Page_url().Xto_full_str_safe(), uid, imgs_len); return uid_end;}
+ Hdump_data_img__base img = imgs[uid];
+ int img_view_w = img.View_w();
+ switch (tid) {
+ case Hdump_html_consts.Tid_img_style:
+ bfr.Add(Hdump_html_consts.Bry_img_style_bgn);
+ bfr.Add_int_variable(img_view_w);
+ bfr.Add(Hdump_html_consts.Bry_img_style_end);
+ return rv;
}
byte[] a_title = img.Lnki_ttl();
- byte[] a_href = Bry_.Add(A_href_bgn, a_title);
+ byte[] a_href = Bry_.Add(Hdump_html_consts.A_href_bgn, a_title);
switch (tid) {
- case Tid_file_info: fmtr.Html_thumb_part_info (bfr, uid, a_href, html_mgr.Img_media_info_btn()); return rv;
- case Tid_file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, html_mgr.Img_thumb_magnify()); return rv;
- case Tid_file_play: fmtr.Html_thumb_part_play (bfr, uid, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, html_mgr.Img_media_play_btn()); return rv;
+ case Hdump_html_consts.Tid_file_info: fmtr.Html_thumb_part_info (bfr, uid, a_href, html_mgr.Img_media_info_btn()); return rv;
+ case Hdump_html_consts.Tid_file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, html_mgr.Img_thumb_magnify()); return rv;
+ case Hdump_html_consts.Tid_file_play: fmtr.Html_thumb_part_play (bfr, uid, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, html_mgr.Img_media_play_btn()); return rv;
+ case Hdump_html_consts.Tid_gallery_box_max: {
+ Hdump_data_img__gallery gly = (Hdump_data_img__gallery)img;
+ if (gly.Box_max() > 0) { // -1 means no box_max
+ byte[] style = Gallery_mgr_base.box_style_max_width_fmtr.Bld_bry_many(tmp_bfr, gly.Box_max());
+ Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Style_bry, style);
+ }
+ return rv;
+ }
+ case Hdump_html_consts.Tid_gallery_box_w: {
+ Hdump_data_img__gallery gly = (Hdump_data_img__gallery)img;
+ byte[] style = Gallery_mgr_base.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Box_w());
+ Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Style_bry, style);
+ return rv;
+ }
+ case Hdump_html_consts.Tid_gallery_img_w: {
+ Hdump_data_img__gallery gly = (Hdump_data_img__gallery)img;
+ byte[] style = Gallery_mgr_base.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Img_w());
+ Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Style_bry, style);
+ return rv;
+ }
+ case Hdump_html_consts.Tid_gallery_img_pad: {
+ Hdump_data_img__gallery gly = (Hdump_data_img__gallery)img;
+ byte[] style = Gallery_mgr_base.hdump_img_pad_fmtr.Bld_bry_many(tmp_bfr, gly.Img_pad());
+ Html_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Html_atr_.Style_bry, style);
+ return rv;
+ }
}
byte[] img_src = Bry_.Add(file_dir, img.View_src());
- if (tid == Tid_img) {
- fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.View_h());
+ if (tid == Hdump_html_consts.Tid_img) {
+ fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.View_h());
}
return rv;
}
- private static final Bry_fmtr fmtr_img = Bry_fmtr.new_("src='~{src}' width='~{w}' height='~{h}'", "src", "w", "h");
- private static final byte[] A_href_bgn = Bry_.new_ascii_("/wiki/File:"), Bry_img_style_bgn = Bry_.new_ascii_("style='width:"), Bry_img_style_end = Bry_.new_ascii_("px;'");
- public static final byte[]
- Key_img = Bry_.new_ascii_("xowa_img='")
- , Key_img_style = Bry_.new_ascii_("xowa_img_style='")
- , Key_file_play = Bry_.new_ascii_("
.
*/
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
- import gplx.xowa.hdumps.core.*;
+import gplx.xowa.hdumps.core.*;
public class Hdump_html_mgr {
- private Hdump_html_fmtr__sidebars sidebars_fmtr = new Hdump_html_fmtr__sidebars();
private Hdump_html_fmtr__body body_fmtr = new Hdump_html_fmtr__body();
- public Hdump_html_mgr Init_by_app(Gfo_usr_dlg usr_dlg, byte[] file_dir) {body_fmtr.Init_by_app(usr_dlg, file_dir); return this;}
- public Bry_fmtr Skin_fmtr() {return skin_fmtr;} private Bry_fmtr skin_fmtr = Bry_fmtr.new_("~{display_ttl}~{content_sub}~{sidebar_divs}~{body_html}", "display_ttl", "content_sub", "sidebar_divs", "body_html");
- public void Write(Bry_bfr bfr, Xow_wiki wiki, Hdump_page_itm page) {
+ public Hdump_html_mgr Init_by_app(Xoa_app app) {body_fmtr.Init_by_app(app); return this;}
+ public void Write(Bry_bfr bfr, Xow_wiki wiki, Hdump_page page) {
body_fmtr.Init_by_page(wiki, page);
- sidebars_fmtr.Init_by_page(page);
- skin_fmtr.Bld_bfr_many(bfr, page.Display_ttl(), page.Content_sub(), sidebars_fmtr, body_fmtr);
+ body_fmtr.XferAry(bfr, 0);
}
}
diff --git a/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_mgr_tst.java b/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_mgr_tst.java
index d4ddbf5e7..eb264d3a9 100644
--- a/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_mgr_tst.java
+++ b/400_xowa/src/gplx/xowa/hdumps/htmls/Hdump_html_mgr_tst.java
@@ -16,8 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see
.
*/
package gplx.xowa.hdumps.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.hdumps.*;
- import gplx.xowa.hdumps.core.*;
-import org.junit.*;
+import org.junit.*; import gplx.xowa.hdumps.core.*; import gplx.xowa.hdumps.dbs.*;
public class Hdump_html_mgr_tst {
@Before public void init() {
fxt.Clear();
@@ -64,23 +63,47 @@ public class Hdump_html_mgr_tst {
, "
");
+ }
+ @Test public void Gallery() {
+ fxt.Clear_imgs();
+ fxt .Init_gly(0, 220, 110, "A.png", "commons.wikimedia.org/thumb/7/0/A.png/220.png", 800, 155, 150, 15);
+ fxt .Init_body(String_.Concat_lines_nl_skip_last
+ ( "