1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00
This commit is contained in:
gnosygnu 2014-07-28 01:40:51 -04:00
parent e882217c62
commit 7b6e65b088
247 changed files with 2985 additions and 1618 deletions

View File

@ -120,10 +120,12 @@ public class Bry_bfr {
return this; return this;
} }
public Bry_bfr Add_byte_eq() {return Add_byte(Byte_ascii.Eq);} public Bry_bfr Add_byte_eq() {return Add_byte(Byte_ascii.Eq);}
public Bry_bfr Add_byte_pipe() {return Add_byte(Byte_ascii.Pipe);} public Bry_bfr Add_byte_pipe() {return Add_byte(Byte_ascii.Pipe);}
public Bry_bfr Add_byte_apos() {return Add_byte(Byte_ascii.Apos);} public Bry_bfr Add_byte_comma() {return Add_byte(Byte_ascii.Comma);}
public Bry_bfr Add_byte_quote() {return Add_byte(Byte_ascii.Quote);} public Bry_bfr Add_byte_apos() {return Add_byte(Byte_ascii.Apos);}
public Bry_bfr Add_byte_space() {return Add_byte(Byte_ascii.Space);} public Bry_bfr Add_byte_backslash() {return Add_byte(Byte_ascii.Backslash);}
public Bry_bfr Add_byte_quote() {return Add_byte(Byte_ascii.Quote);}
public Bry_bfr Add_byte_space() {return Add_byte(Byte_ascii.Space);}
public Bry_bfr Add_byte_nl() {return Add_byte(Byte_ascii.NewLine);} public Bry_bfr Add_byte_nl() {return Add_byte(Byte_ascii.NewLine);}
public Bry_bfr Add_byte(byte val) { public Bry_bfr Add_byte(byte val) {
int newPos = bfr_len + 1; int newPos = bfr_len + 1;

View File

@ -100,6 +100,16 @@ public class Bry_finder {
} }
return rv; return rv;
} }
public static int Find_bwd_ws(byte[] src, int cur, int end) {
for (int i = cur; i > -1; --i) {
byte b = src[i];
switch (b) {
case Byte_ascii.Space: case Byte_ascii.Tab: case Byte_ascii.NewLine: case Byte_ascii.CarriageReturn:
return i;
}
}
return Bry_finder.Not_found;
}
public static int Find_fwd_last_ws(byte[] src, int cur) { public static int Find_fwd_last_ws(byte[] src, int cur) {
int end = src.length; int end = src.length;
if (cur >= end) return Bry_finder.Not_found; if (cur >= end) return Bry_finder.Not_found;
@ -165,6 +175,18 @@ public class Bry_finder {
cur++; cur++;
} }
} }
public static int Find_fwd_until_space_or_tab(byte[] src, int cur, int end) {
while (true) {
if (cur == end) return Bry_finder.Not_found;
switch (src[cur]) {
case Byte_ascii.Space: case Byte_ascii.Tab:
return cur;
default:
++cur;
break;
}
}
}
public static int Find_fwd_while_space_or_tab(byte[] src, int cur, int end) { public static int Find_fwd_while_space_or_tab(byte[] src, int cur, int end) {
while (true) { while (true) {
if (cur == end) return cur; if (cur == end) return cur;

View File

@ -76,7 +76,9 @@ public class Byte_ascii {
, Lt_bry = new byte[] {Byte_ascii.Lt} , Lt_bry = new byte[] {Byte_ascii.Lt}
, Gt_bry = new byte[] {Byte_ascii.Gt} , Gt_bry = new byte[] {Byte_ascii.Gt}
, Brack_bgn_bry = new byte[] {Byte_ascii.Brack_bgn} , Brack_bgn_bry = new byte[] {Byte_ascii.Brack_bgn}
, Brack_end_bry = new byte[] {Byte_ascii.Brack_end}
, Apos_bry = new byte[] {Byte_ascii.Apos} , Apos_bry = new byte[] {Byte_ascii.Apos}
, Quote_bry = new byte[] {Byte_ascii.Quote}
, Pipe_bry = new byte[] {Byte_ascii.Pipe} , Pipe_bry = new byte[] {Byte_ascii.Pipe}
, Underline_bry = new byte[] {Byte_ascii.Underline} , Underline_bry = new byte[] {Byte_ascii.Underline}
, Asterisk_bry = new byte[] {Byte_ascii.Asterisk} , Asterisk_bry = new byte[] {Byte_ascii.Asterisk}

View File

@ -43,6 +43,7 @@ public class Int_ implements GfoInvkAble {
rv[i] = bgn + i; rv[i] = bgn + i;
return rv; return rv;
} }
public static boolean Bounds_chk(int bgn, int end, int len) {return bgn > -1 && end < len;}
public static final int public static final int
MinValue = Integer.MIN_VALUE MinValue = Integer.MIN_VALUE
, MaxValue = Integer.MAX_VALUE , MaxValue = Integer.MAX_VALUE

View File

@ -152,7 +152,7 @@ public class String_ implements GfoInvkAble {
rv[i] = (int)s.charAt(i); rv[i] = (int)s.charAt(i);
return rv; return rv;
} }
public static String Coalesce(String s, String alt) {return Len(s) == 0 ? alt : s;} public static String Coalesce(String s, String alt) {return Len_eq_0(s) ? alt : s;}
public static boolean In(String s, String... ary) { public static boolean In(String s, String... ary) {
for (String itm : ary) for (String itm : ary)
if (String_.Eq(s, itm)) return true; if (String_.Eq(s, itm)) return true;

View File

@ -186,11 +186,17 @@ public class Swt_kit implements Gfui_kit {
public Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner) {return Swt_popup_grp.new_bar(key, owner);} public Gfui_mnu_grp New_mnu_bar(String key, GfuiWin owner) {return Swt_popup_grp.new_bar(key, owner);}
public float Calc_font_height(GfuiElem elem, String s) { public float Calc_font_height(GfuiElem elem, String s) {
if (String_.Len_eq_0(s)) return 8; if (String_.Len_eq_0(s)) return 8;
String old_text = elem.Text(); try {
elem.Text_(s); String old_text = elem.Text();
float rv = ((Swt_text_w_border)(elem.UnderElem())).Under_text().getFont().getFontData()[0].height; elem.Text_(s);
shell.setText(old_text); float rv = ((Swt_text_w_border)(elem.UnderElem())).Under_text().getFont().getFontData()[0].height;
return rv; elem.Text_(old_text); // was shell.setText(old_text); DATE:2014-07-25
return rv;
}
catch (Exception e) {
Gfo_usr_dlg_._.Warn_many("", "", "error while calculating font height; err=~{0}", Err_.Message_gplx_brief(e));
return 8;
}
} }
public void Set_mnu_popup(GfuiElem owner, Gfui_mnu_grp grp) { public void Set_mnu_popup(GfuiElem owner, Gfui_mnu_grp grp) {
Control control = Swt_control_.cast_or_fail(owner).Under_menu_control(); Control control = Swt_control_.cast_or_fail(owner).Under_menu_control();

View File

@ -19,16 +19,11 @@
<classpathentry kind="src" path="src_400_parser"/> <classpathentry kind="src" path="src_400_parser"/>
<classpathentry kind="src" path="src_405_tkn"/> <classpathentry kind="src" path="src_405_tkn"/>
<classpathentry kind="src" path="src_409_tkn_misc"/> <classpathentry kind="src" path="src_409_tkn_misc"/>
<classpathentry kind="src" path="src_420_apos"/>
<classpathentry kind="src" path="src_430_lnke"/>
<classpathentry kind="src" path="src_440_lnki"/> <classpathentry kind="src" path="src_440_lnki"/>
<classpathentry kind="src" path="src_450_hdr"/>
<classpathentry kind="src" path="src_460_para"/> <classpathentry kind="src" path="src_460_para"/>
<classpathentry kind="src" path="src_470_list"/>
<classpathentry kind="src" path="src_480_tblw"/> <classpathentry kind="src" path="src_480_tblw"/>
<classpathentry kind="src" path="src_490_xnde"/> <classpathentry kind="src" path="src_490_xnde"/>
<classpathentry kind="src" path="src_500_tmpl"/> <classpathentry kind="src" path="src_500_tmpl"/>
<classpathentry kind="src" path="src_510_pf_core"/>
<classpathentry kind="src" path="xtn"/> <classpathentry kind="src" path="xtn"/>
<classpathentry combineaccessrules="false" kind="src" path="/100_core"/> <classpathentry combineaccessrules="false" kind="src" path="/100_core"/>
<classpathentry combineaccessrules="false" kind="src" path="/150_gfui"/> <classpathentry combineaccessrules="false" kind="src" path="/150_gfui"/>

View File

@ -111,9 +111,10 @@ public class Fsdb_mnt_mgr implements GfoInvkAble {
public static final int Mnt_idx_main = 0, Mnt_idx_user = 1, Insert_to_bin_null = -1; public static final int Mnt_idx_main = 0, Mnt_idx_user = 1, Insert_to_bin_null = -1;
public static void Patch(Fsdb_mnt_mgr mnt_mgr) { public static void Patch(Fsdb_mnt_mgr mnt_mgr) {
mnt_mgr.Abc_mgr_at(Fsdb_mnt_mgr.Mnt_idx_main).Cfg_mgr() mnt_mgr.Abc_mgr_at(Fsdb_mnt_mgr.Mnt_idx_main).Cfg_mgr()
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults, "y") .Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_fix_defaults , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_packed, "y") .Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_gallery_packed , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_patch, "y") .Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_use_thumb_w , "y")
.Update(Xof_fsdb_mgr_cfg.Grp_xowa, Xof_fsdb_mgr_cfg.Key_upright_fix_default , "y")
; ;
} }
} }

View File

@ -29,6 +29,6 @@ public class Html_entity_ {
, Nl_bry = Bry_.new_ascii_(Nl_str), Space_bry = Bry_.new_ascii_("&#32;") , Nl_bry = Bry_.new_ascii_(Nl_str), Space_bry = Bry_.new_ascii_("&#32;")
, Pipe_bry = Bry_.new_ascii_("&#124;") , Pipe_bry = Bry_.new_ascii_("&#124;")
, Colon_bry = Bry_.new_ascii_("&#58;"), Underline_bry = Bry_.new_ascii_("&#95;"), Asterisk_bry = Bry_.new_ascii_("&#42;") , Colon_bry = Bry_.new_ascii_("&#58;"), Underline_bry = Bry_.new_ascii_("&#95;"), Asterisk_bry = Bry_.new_ascii_("&#42;")
, Brack_bgn_bry = Bry_.new_ascii_("&#91;") , Brack_bgn_bry = Bry_.new_ascii_("&#91;"), Brack_end_bry = Bry_.new_ascii_("&#93;")
; ;
} }

View File

@ -21,8 +21,12 @@ public class Html_tag_ {
Ul_name_bry = Bry_.new_ascii_("ul") Ul_name_bry = Bry_.new_ascii_("ul")
; ;
public static final byte[] public static final byte[]
Body_lhs = Bry_.new_ascii_("<body>") Br_inl = Bry_.new_ascii_("<br/>")
, Body_rhs = Bry_.new_ascii_("</body>") , Hr_inl = Bry_.new_ascii_("<hr/>")
, Body_lhs = Bry_.new_ascii_("<body>") , Body_rhs = Bry_.new_ascii_("</body>")
, B_lhs = Bry_.new_ascii_("<b>") , B_rhs = Bry_.new_ascii_("</b>")
, I_lhs = Bry_.new_ascii_("<i>") , I_rhs = Bry_.new_ascii_("</i>")
, P_lhs = Bry_.new_ascii_("<p>") , P_rhs = Bry_.new_ascii_("</p>")
, Html_rhs = Bry_.new_ascii_("</html>") , Html_rhs = Bry_.new_ascii_("</html>")
, Head_lhs_bgn = Bry_.new_ascii_("<head") , Head_lhs_bgn = Bry_.new_ascii_("<head")
, Head_rhs = Bry_.new_ascii_("</head>") , Head_rhs = Bry_.new_ascii_("</head>")
@ -31,7 +35,6 @@ public class Html_tag_ {
, Script_lhs = Bry_.new_ascii_("<script>") , Script_lhs = Bry_.new_ascii_("<script>")
, Script_lhs_w_type = Bry_.new_ascii_("<script type='text/javascript'>") , Script_lhs_w_type = Bry_.new_ascii_("<script type='text/javascript'>")
, Script_rhs = Bry_.new_ascii_("</script>") , Script_rhs = Bry_.new_ascii_("</script>")
, Hr_bry = Bry_.new_ascii_("<hr/>")
; ;
public static final String public static final String
Comm_bgn_str = "<!--" Comm_bgn_str = "<!--"

View File

@ -20,9 +20,11 @@ import gplx.core.btries.*;
public class Html_utl { public class Html_utl {
public static byte[] Escape_for_atr_val_as_bry(Bry_bfr tmp_bfr, byte quote_byte, String s) { public static byte[] Escape_for_atr_val_as_bry(Bry_bfr tmp_bfr, byte quote_byte, String s) {
if (s == null) return null; if (s == null) return null;
byte[] bry = Bry_.new_utf8_(s); return Escape_for_atr_val_as_bry(tmp_bfr, quote_byte, Bry_.new_utf8_(s));
int bry_len = bry.length; }
boolean dirty = Escape_for_atr_val_as_bry(tmp_bfr, quote_byte, bry, 0, bry_len); public static byte[] Escape_for_atr_val_as_bry(Bry_bfr tmp_bfr, byte quote_byte, byte[] bry) {
if (bry == null) return null;
boolean dirty = Escape_for_atr_val_as_bry(tmp_bfr, quote_byte, bry, 0, bry.length);
return dirty ? tmp_bfr.XtoAryAndClear() : bry; return dirty ? tmp_bfr.XtoAryAndClear() : bry;
} }
public static boolean Escape_for_atr_val_as_bry(Bry_bfr tmp_bfr, byte quote_byte, byte[] src, int bgn, int end) { public static boolean Escape_for_atr_val_as_bry(Bry_bfr tmp_bfr, byte quote_byte, byte[] src, int bgn, int end) {

View File

@ -23,7 +23,7 @@ public class Xoa_app_ {
boot_mgr.Run(args); boot_mgr.Run(args);
} }
public static final String Name = "xowa"; public static final String Name = "xowa";
public static final String Version = "1.7.3.1"; public static final String Version = "1.7.4.1";
public static String Build_date = "2012-12-30 00:00:00"; public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys; public static String Op_sys;
public static String User_agent = ""; public static String User_agent = "";

View File

@ -17,19 +17,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; package gplx.xowa.apis.xowa; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*;
import gplx.xowa.gui.views.*; import gplx.xowa.gui.views.*;
import gplx.xowa.apis.xowa.startups.*; import gplx.xowa.apis.xowa.envs.*; import gplx.xowa.apis.xowa.startups.*;
public class Xoapi_app implements GfoInvkAble { public class Xoapi_app implements GfoInvkAble {
private Xog_win_itm win; private Xog_win_itm win;
public void Init_by_kit(Xoa_app app) { public void Init_by_kit(Xoa_app app) {
win = app.Gui_mgr().Browser_win(); win = app.Gui_mgr().Browser_win();
} }
public void Exit() {win.App__exit();} public void Exit() {win.App__exit();}
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups(); public Xoapi_env Env() {return env;} private Xoapi_env env = new Xoapi_env();
public Xoapi_startups Startup() {return startup;} private Xoapi_startups startup = new Xoapi_startups();
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_exit)) this.Exit(); if (ctx.Match(k, Invk_exit)) this.Exit();
else if (ctx.Match(k, Invk_startup)) return startup; else if (ctx.Match(k, Invk_startup)) return startup;
else if (ctx.Match(k, Invk_env)) return env;
else return GfoInvkAble_.Rv_unhandled; else return GfoInvkAble_.Rv_unhandled;
return this; return this;
} }
private static final String Invk_exit = "exit", Invk_startup = "startup"; private static final String Invk_exit = "exit", Invk_startup = "startup", Invk_env = "env";
} }

View File

@ -0,0 +1,29 @@
/*
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.apis.xowa.envs; import gplx.*; import gplx.xowa.*; import gplx.xowa.apis.*; import gplx.xowa.apis.xowa.*;
public class Xoapi_env implements GfoInvkAble {
public void Init_by_kit(Xoa_app app) {}
public String Version_previous() {return version_previous;} private String version_previous = "";
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_version_previous)) return version_previous;
else if (ctx.Match(k, Invk_version_previous_)) version_previous = m.ReadStr("v");
else return GfoInvkAble_.Rv_unhandled;
return this;
}
private static final String Invk_version_previous = "version_previous", Invk_version_previous_ = "version_previous_";
}

View File

@ -23,14 +23,15 @@ public class Xoapi_edit implements GfoInvkAble {
win = app.Gui_mgr().Browser_win(); win = app.Gui_mgr().Browser_win();
} }
private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();} private boolean Active_tab_is_null() {return win.Tab_mgr().Active_tab_is_null();}
private boolean Active_tab_is_edit() {return !win.Tab_mgr().Active_tab_is_null() && win.Tab_mgr().Active_tab().View_mode() == Xog_page_mode.Tid_edit;}
public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());} public void Copy() {if (Active_tab_is_null()) return; win.Kit().Clipboard().Copy(win.Active_html_itm().Html_selected_get_text_or_href());}
public void Select_all() {if (Active_tab_is_null()) return; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.Gfui_clipboard_.Invk_select_all);} public void Select_all() {if (Active_tab_is_null()) return; GfoInvkAble_.InvkCmd(win.Win_box().Kit().Clipboard(), gplx.gfui.Gfui_clipboard_.Invk_select_all);}
public void Save() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);} public void Save() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), false);}
public void Save_draft() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);} public void Save_draft() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Save(win.Active_tab(), true);}
public void Preview() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());} public void Preview() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Preview(win.Active_tab());}
public void Dbg_tmpl() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_edit);} public void Dbg_tmpl() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_edit);}
public void Dbg_html() {if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_html);} public void Dbg_html() {if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Debug(win, Xog_page_mode.Tid_html);}
public void Focus_edit_box(){if (Active_tab_is_null()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);} public void Focus_edit_box(){if (!Active_tab_is_edit()) return; Xog_tab_itm_edit_mgr.Focus(win, Xog_html_itm.Elem_id__xowa_edit_data_box);}
public void Exec() { public void Exec() {
} }
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {

View File

@ -19,9 +19,9 @@ package gplx.xowa.apis.xowa.startups.tabs; import gplx.*; import gplx.xowa.*; im
public class Xoapi_startup_tabs implements GfoInvkAble { public class Xoapi_startup_tabs implements GfoInvkAble {
public String Custom() {return custom;} private String custom; public String Custom() {return custom;} private String custom;
public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr; public boolean Custom_is_expr() {return custom_is_expr;} private boolean custom_is_expr;
public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous = ""; public String Previous() {return previous;} public Xoapi_startup_tabs Previous_(String v) {previous = v; return this;} private String previous;
public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual; public String Manual() {return manual;} public void Manual_(String v) {manual = v;} private String manual;
public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_xowa; public byte Type() {return type;} private byte type = Xoapi_startup_tabs_tid_.Tid_previous;
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type); if (ctx.Match(k, Invk_type)) return Xoapi_startup_tabs_tid_.Xto_key(type);
else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v")); else if (ctx.Match(k, Invk_type_)) type = Xoapi_startup_tabs_tid_.Xto_tid(m.ReadStr("v"));
@ -41,14 +41,46 @@ public class Xoapi_startup_tabs implements GfoInvkAble {
, Invk_previous = "previous", Invk_previous_ = "previous_" , Invk_previous = "previous", Invk_previous_ = "previous_"
, Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_" , Invk_custom_is_expr = "custom_is_expr", Invk_custom_is_expr_ = "custom_is_expr_"
; ;
public String[] Calc_startup_strs() { public String[] Calc_startup_strs(Xoa_app app) {
if (manual != null) return new String[] {manual}; ListAdp rv = ListAdp_.new_();
switch (type) { String xowa_home = gplx.xowa.users.Xouc_pages_mgr.Page_xowa;
case Xoapi_startup_tabs_tid_.Tid_blank: return new String[] {gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str}; if (manual == null) {
case Xoapi_startup_tabs_tid_.Tid_xowa: return new String[] {gplx.xowa.users.Xouc_pages_mgr.Page_xowa}; switch (type) {
case Xoapi_startup_tabs_tid_.Tid_custom: return String_.SplitLines_nl(String_.Trim(custom)); case Xoapi_startup_tabs_tid_.Tid_blank: rv.Add(gplx.xowa.specials.xowa.default_tab.Default_tab_page.Ttl_full_str); break;
case Xoapi_startup_tabs_tid_.Tid_previous: return String_.SplitLines_nl(String_.Trim(previous)); case Xoapi_startup_tabs_tid_.Tid_xowa: rv.Add(xowa_home); break;
default: throw Err_.unhandled(type); case Xoapi_startup_tabs_tid_.Tid_custom: Add_ary(rv, custom); break;
case Xoapi_startup_tabs_tid_.Tid_previous: Add_ary(rv, previous); break;
default: throw Err_.unhandled(type);
}
}
else
rv.Add(manual);
Add_xowa_home_if_new_version(rv, app, xowa_home);
return rv.XtoStrAry();
}
private static void Add_ary(ListAdp list, String s) {
if (String_.Len_eq_0(s)) return;
String[] ary = String_.SplitLines_nl(String_.Trim(s));
int len = ary.length;
for (int i = 0; i < len; ++i) {
String itm = ary[i];
if (String_.Len_eq_0(itm)) continue;
list.Add(itm);
}
}
private static void Add_xowa_home_if_new_version(ListAdp rv, Xoa_app app, String xowa_home) {
if (gplx.xowa.apps.versions.Xoa_version_.Compare(app.Api_root().App().Env().Version_previous(), Xoa_app_.Version) == CompareAble_.Less) {
boolean xowa_home_exists = false;
int len = rv.Count();
for (int i = 0; i < len; ++i) {
String itm = (String)rv.FetchAt(i);
if (String_.Eq(itm, xowa_home)) {
xowa_home_exists = true;
break;
}
}
if (!xowa_home_exists)
rv.Add(xowa_home);
} }
} }
} }

View File

@ -26,16 +26,15 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
eval_mgr = new Xoa_app_eval(app); eval_mgr = new Xoa_app_eval(app);
} private Xoa_app app; } private Xoa_app app;
public Xoa_app_eval Eval_mgr() {return eval_mgr;} private Xoa_app_eval eval_mgr; public Xoa_app_eval Eval_mgr() {return eval_mgr;} private Xoa_app_eval eval_mgr;
public static boolean Fail_if_unhandled = false;
public static final String Cfg_user_file = "xowa_user_cfg.gfs", Cfg_user_custom_file = "user_custom_cfg.gfs";
private void Run_url_by_type(String type) { private void Run_url_by_type(String type) {
Xou_fsys_mgr fsys_mgr = app.User().Fsys_mgr(); Xou_fsys_mgr fsys_mgr = app.User().Fsys_mgr();
Io_url app_data_dir = fsys_mgr.App_data_dir(); Io_url app_data_dir = fsys_mgr.App_data_dir();
Io_url url = null; Io_url url = null;
if (String_.Eq(type, "user_system_cfg")) url = app_data_dir.GenSubFil_nest("cfg", "user_system_cfg.gfs"); if (String_.Eq(type, "user_system_cfg")) url = app_data_dir.GenSubFil_nest("cfg", "user_system_cfg.gfs");
else if (String_.Eq(type, "user_custom_cfg")) url = fsys_mgr.App_data_cfg_custom_fil(); else if (String_.Eq(type, "xowa_cfg_custom")) url = fsys_mgr.App_data_cfg_custom_fil();
else if (String_.Eq(type, "xowa_user_cfg")) url = fsys_mgr.App_data_cfg_user_fil(); else if (String_.Eq(type, "xowa_cfg_user")) url = fsys_mgr.App_data_cfg_user_fil();
else if (String_.Eq(type, "xowa")) url = app.Fsys_mgr().Root_dir().GenSubFil("xowa.gfs"); else if (String_.Eq(type, "xowa_cfg_os")) {url = app.Fsys_mgr().Bin_data_os_cfg_fil(); Xoa_gfs_mgr_.Cfg_os_assert(url);}
else if (String_.Eq(type, "xowa_cfg_app")) url = app.Fsys_mgr().Root_dir().GenSubFil("xowa.gfs");
else throw Err_mgr._.fmt_(GRP_KEY, "invalid_gfs_type", "invalid gfs type: ~{0}", type); else throw Err_mgr._.fmt_(GRP_KEY, "invalid_gfs_type", "invalid gfs type: ~{0}", type);
try {Run_url(url);} try {Run_url(url);}
catch (Exception e) { // gfs is corrupt; may happen if multiple XOWAs opened, and "Close all" chosen in OS; DATE:2014-07-01 catch (Exception e) { // gfs is corrupt; may happen if multiple XOWAs opened, and "Close all" chosen in OS; DATE:2014-07-01
@ -111,4 +110,16 @@ public class Xoa_gfs_mgr implements GfoInvkAble, GfoInvkRootWkr {
} }
return Build_code_bfr.XtoStrAndClear(); return Build_code_bfr.XtoStrAndClear();
} static final Bry_bfr Build_code_bfr = Bry_bfr.new_(); } static final Bry_bfr Build_code_bfr = Bry_bfr.new_();
public static final String Cfg_user_file = "xowa_user_cfg.gfs", Cfg_user_custom_file = "user_custom_cfg.gfs", Cfg_os = "xowa_cfg_os.gfs";
public static boolean Fail_if_unhandled = false;
}
class Xoa_gfs_mgr_ {
public static void Cfg_os_assert(Io_url orig_url) {
Io_url dflt_url = orig_url.GenNewNameOnly(orig_url.NameOnly() + "_default");
if (!Io_mgr._.ExistsFil(dflt_url)) return; // no dflt
if (!Io_mgr._.ExistsFil(orig_url)) {
Io_mgr._.CopyFil(dflt_url, orig_url, true);
Gfo_usr_dlg_._.Log_many("", "", "xowa_cfg_os generated; url=~{0}", orig_url.Raw());
}
}
} }

View File

@ -27,15 +27,16 @@ public class Xoa_fsys_mgr implements GfoInvkAble {
temp_dir = root_dir.GenSubDir("tmp"); temp_dir = root_dir.GenSubDir("tmp");
app_mgr = new Launcher_app_mgr(app); app_mgr = new Launcher_app_mgr(app);
} }
public Io_url Root_dir() {return root_dir;} private Io_url root_dir; public Io_url Root_dir() {return root_dir;} private Io_url root_dir;
public Io_url File_dir() {return file_dir;} private Io_url file_dir; public Io_url File_dir() {return file_dir;} private Io_url file_dir;
public Io_url Wiki_dir() {return wiki_dir;} public Xoa_fsys_mgr Wiki_dir_(Io_url v) {wiki_dir = v; return this;} private Io_url wiki_dir; public Io_url Wiki_dir() {return wiki_dir;} public Xoa_fsys_mgr Wiki_dir_(Io_url v) {wiki_dir = v; return this;} private Io_url wiki_dir;
public Io_url Temp_dir() {return temp_dir;} public Xoa_fsys_mgr Temp_dir_(Io_url v) {temp_dir = v; return this;} private Io_url temp_dir; // set to /xowa/user/<name>/temp public Io_url Temp_dir() {return temp_dir;} public Xoa_fsys_mgr Temp_dir_(Io_url v) {temp_dir = v; return this;} private Io_url temp_dir; // set to /xowa/user/<name>/temp
public Io_url Bin_any_dir() {return bin_any_dir;} private Io_url bin_any_dir; public Io_url Bin_any_dir() {return bin_any_dir;} private Io_url bin_any_dir;
public Io_url Bin_extensions_dir() {return bin_extensions_dir;} private Io_url bin_extensions_dir; public Io_url Bin_extensions_dir() {return bin_extensions_dir;} private Io_url bin_extensions_dir;
public Io_url Bin_plat_dir() {return bin_plat_dir;} private Io_url bin_plat_dir; public Io_url Bin_plat_dir() {return bin_plat_dir;} private Io_url bin_plat_dir;
public Io_url Bin_db_dir() {return bin_any_dir.GenSubDir_nest("sql", "xowa");} public Io_url Bin_db_dir() {return bin_any_dir.GenSubDir_nest("sql", "xowa");}
public Launcher_app_mgr App_mgr() {return app_mgr;} Launcher_app_mgr app_mgr; public Io_url Bin_data_os_cfg_fil() {return bin_plat_dir.GenSubFil_nest("xowa", "cfg", Xoa_gfs_mgr.Cfg_os);}
public Launcher_app_mgr App_mgr() {return app_mgr;} Launcher_app_mgr app_mgr;
public void Init() { public void Init() {
app_mgr.Init(); app_mgr.Init();
} }

View File

@ -0,0 +1,38 @@
/*
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.apps.versions; import gplx.*; import gplx.xowa.*; import gplx.xowa.apps.*;
public class Xoa_version_ {
public static int Compare(String lhs_str, String rhs_str) {
String[] lhs_ary = String_.Split(lhs_str, ".");
String[] rhs_ary = String_.Split(rhs_str, ".");
return Compare_as_int(lhs_ary, rhs_ary);
}
private static int Compare_as_int(String[] lhs_ary, String[] rhs_ary) {
int lhs_ary_len = lhs_ary.length;
int rhs_ary_len = lhs_ary.length;
int len_comp = Int_.Compare(lhs_ary_len, rhs_ary_len);
if (len_comp != CompareAble_.Same) return len_comp;
for (int i = 0; i < lhs_ary_len; ++i) {
String lhs_itm = lhs_ary[i];
String rhs_itm = rhs_ary[i];
int itm_comp = Int_.Compare(Int_.parse_or_(lhs_itm, 0), Int_.parse_or_(rhs_itm, 0));
if (itm_comp != CompareAble_.Same) return itm_comp;
}
return CompareAble_.Same;
}
}

View File

@ -60,7 +60,7 @@ class Xob_diff_regy_sql_runner {
} }
public void Run_sql(Xoa_app app) { public void Run_sql(Xoa_app app) {
Xow_wiki wiki = app.Wiki_mgr().Get_by_key_or_null(Bry_.new_utf8_(wiki_domain)); Xow_wiki wiki = app.Wiki_mgr().Get_by_key_or_null(Bry_.new_utf8_(wiki_domain));
app.Usr_dlg().Prog_many("", "", "running sql: url=~{0}", url.Raw()); app.Usr_dlg().Prog_many("", "", "running sql: url=~{0}", url.NameAndExt());
Db_provider provider = Get_provider(wiki, fsdb_db_id, fsdb_db_tid); Db_provider provider = Get_provider(wiki, fsdb_db_id, fsdb_db_tid);
provider.Exec_sql(Io_mgr._.LoadFilStr(url)); provider.Exec_sql(Io_mgr._.LoadFilStr(url));
if (fsdb_db_tid == Fsdb_db_tid_.Tid_bin) if (fsdb_db_tid == Fsdb_db_tid_.Tid_bin)

View File

@ -32,13 +32,18 @@ public class Xob_diff_regy_make_cmd extends Xob_itm_basic_base implements Xob_cm
this.Make_delete_sql(make_db_provider); this.Make_delete_sql(make_db_provider);
} }
private void Make_join_indexes(Db_provider make_db_provider) { private void Make_join_indexes(Db_provider make_db_provider) {
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_fsdb_regy__join); try {
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_xfer_regy__join); Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_fsdb_regy__join);
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_xfer_regy__join);
}
catch (Exception exc) {
app.Usr_dlg().Warn_many("", "", "error while making indexes: err=~{0}", Err_.Message_gplx(exc));
}
} }
private void Make_diff_regy(Db_provider make_db_provider) { private void Make_diff_regy(Db_provider make_db_provider) {
Sqlite_engine_.Tbl_create_and_delete(make_db_provider, Xob_diff_regy_tbl.Tbl_name, Xob_diff_regy_tbl.Tbl_sql); Sqlite_engine_.Tbl_create_and_delete(make_db_provider, Xob_diff_regy_tbl.Tbl_name, Xob_diff_regy_tbl.Tbl_sql);
make_db_provider.Exec_sql(Xob_diff_regy_tbl.Make_diff_regy); make_db_provider.Exec_sql(Xob_diff_regy_tbl.Make_diff_regy);
Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_xfer_regy__join); Sqlite_engine_.Idx_create(make_db_provider, Xob_diff_regy_tbl.Idx_diff_regy__load);
} }
private void Make_delete_sql(Db_provider make_db_provider) { private void Make_delete_sql(Db_provider make_db_provider) {
DataRdr rdr = make_db_provider.Exec_sql_as_rdr(Xob_diff_regy_tbl.Make_deletes); DataRdr rdr = make_db_provider.Exec_sql_as_rdr(Xob_diff_regy_tbl.Make_deletes);

View File

@ -58,10 +58,10 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xop_lnki_log
wiki.App().Wiki_mgr().Wdata_mgr().Enabled_(wdata_enabled); wiki.App().Wiki_mgr().Wdata_mgr().Enabled_(wdata_enabled);
if (!xtn_ref_enabled) gplx.xowa.xtns.cite.References_nde.Enabled = false; if (!xtn_ref_enabled) gplx.xowa.xtns.cite.References_nde.Enabled = false;
gplx.xowa.xtns.gallery.Gallery_xnde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y); gplx.xowa.xtns.gallery.Gallery_xnde.Log_wkr = log_mgr.Make_wkr().Save_src_str_(Bool_.Y);
gplx.xowa.xtns.imageMap.Xop_imageMap_xnde.Log_wkr = log_mgr.Make_wkr(); gplx.xowa.xtns.imaps.Imap_xnde.Log_wkr = log_mgr.Make_wkr();
gplx.xowa.Xop_xnde_wkr.Timeline_log_wkr = log_mgr.Make_wkr(); gplx.xowa.Xop_xnde_wkr.Timeline_log_wkr = log_mgr.Make_wkr();
gplx.xowa.xtns.scores.Score_xnde.Log_wkr = log_mgr.Make_wkr(); gplx.xowa.xtns.scores.Score_xnde.Log_wkr = log_mgr.Make_wkr();
gplx.xowa.xtns.hiero.Hiero_xnde.Log_wkr = log_mgr.Make_wkr(); gplx.xowa.xtns.hieros.Hiero_xnde.Log_wkr = log_mgr.Make_wkr();
Xof_fsdb_mgr_sql trg_fsdb_mgr = new Xof_fsdb_mgr_sql(wiki); Xof_fsdb_mgr_sql trg_fsdb_mgr = new Xof_fsdb_mgr_sql(wiki);
trg_fsdb_mgr.Init_by_wiki(wiki); trg_fsdb_mgr.Init_by_wiki(wiki);
Fsdb_mnt_mgr trg_mnt_mgr = trg_fsdb_mgr.Mnt_mgr(); Fsdb_mnt_mgr trg_mnt_mgr = trg_fsdb_mgr.Mnt_mgr();

View File

@ -27,7 +27,7 @@ public class Xob_orig_regy_cmd extends Xob_itm_basic_base implements Xob_cmd {
Xob_orig_regy_tbl.Create_table(provider); Xob_orig_regy_tbl.Create_table(provider);
Xow_wiki commons_wiki = bldr.App().Wiki_mgr().Get_by_key_or_make(Xow_wiki_.Domain_commons_bry).Init_assert(); Xow_wiki commons_wiki = bldr.App().Wiki_mgr().Get_by_key_or_make(Xow_wiki_.Domain_commons_bry).Init_assert();
Xow_wiki repo_0 = wiki, repo_1 = commons_wiki; Xow_wiki repo_0 = wiki, repo_1 = commons_wiki;
if (repo_0_is_remote) { if (repo_0_is_remote) { // NOTE: default is false; local_wiki will be preferred over commons_wiki
repo_0 = commons_wiki; repo_0 = commons_wiki;
repo_1 = wiki; repo_1 = wiki;
} }

View File

@ -28,7 +28,7 @@ class Xob_orig_regy_tbl {
byte repo_0_tid = Xof_repo_itm.Repo_local, repo_1_tid = Xof_repo_itm.Repo_remote; byte repo_0_tid = Xof_repo_itm.Repo_local, repo_1_tid = Xof_repo_itm.Repo_remote;
boolean local_is_remote = Bry_.Eq(repo_0_wiki.Domain_bry(), repo_1_wiki.Domain_bry()); boolean local_is_remote = Bry_.Eq(repo_0_wiki.Domain_bry(), repo_1_wiki.Domain_bry());
if ( repo_0_is_remote // .gfs manually marked specifes repo_0 as remote if ( repo_0_is_remote // .gfs manually marked specifes repo_0 as remote
|| ( Bry_.Eq(repo_0_wiki.Domain_bry(), Xow_wiki_.Domain_commons_bry) // repo_0 = commons; force repo_0 to be remote; else all orig_repo will be 1; DATE:2014-02-01 || ( Bry_.Eq(repo_0_wiki.Domain_bry(), Xow_wiki_.Domain_commons_bry) // repo_0 = commons; force repo_0 to be remote; else all orig_repo will be 1; DATE:2014-02-01
&& local_is_remote // repo_0 = repo_1 && local_is_remote // repo_0 = repo_1
) )
) { ) {
@ -47,7 +47,7 @@ class Xob_orig_regy_tbl {
Sqlite_engine_.Idx_create(usr_dlg, p, "orig_regy", Idx_xfer_temp); Sqlite_engine_.Idx_create(usr_dlg, p, "orig_regy", Idx_xfer_temp);
} }
private static void Create_data_for_repo(Gfo_usr_dlg usr_dlg, Db_provider cur, byte wiki_tid, Io_url join) { private static void Create_data_for_repo(Gfo_usr_dlg usr_dlg, Db_provider cur, byte wiki_tid, Io_url join) {
usr_dlg.Note_many("", "", "inserting page: ~{0}", join.NameOnly()); usr_dlg.Note_many("", "", "inserting page for xowa.wiki.image: ~{0}", join.OwnerDir().NameOnly());
Sqlite_engine_.Db_attach(cur, "image_db", join.Raw()); Sqlite_engine_.Db_attach(cur, "image_db", join.Raw());
cur.Exec_sql(String_.Format(Sql_update_repo_page, wiki_tid)); cur.Exec_sql(String_.Format(Sql_update_repo_page, wiki_tid));
cur.Exec_sql(String_.Format(Sql_update_repo_redirect, wiki_tid)); cur.Exec_sql(String_.Format(Sql_update_repo_redirect, wiki_tid));
@ -57,18 +57,19 @@ class Xob_orig_regy_tbl {
p.Exec_sql(Xob_orig_regy_tbl.Sql_cs_mark_dupes); // orig_regy: find dupes; see note in SQL p.Exec_sql(Xob_orig_regy_tbl.Sql_cs_mark_dupes); // orig_regy: find dupes; see note in SQL
p.Exec_sql(Xob_orig_regy_tbl.Sql_cs_update_ttls); // orig_regy: update lnki_ttl with lnki_commons_ttl p.Exec_sql(Xob_orig_regy_tbl.Sql_cs_update_ttls); // orig_regy: update lnki_ttl with lnki_commons_ttl
Create_data_for_repo(usr_dlg, p, Xof_repo_itm.Repo_remote, repo_remote_dir.GenSubFil(Xodb_db_file.Name__wiki_image)); Create_data_for_repo(usr_dlg, p, Xof_repo_itm.Repo_remote, repo_remote_dir.GenSubFil(Xodb_db_file.Name__wiki_image));
p.Exec_sql(Xob_lnki_regy_tbl.Sql_cs_mark_changed); // lnki_regy: update lnki_ttl with lnki_commons_ttl p.Exec_sql(Xob_lnki_regy_tbl.Sql_cs_mark_changed); // lnki_regy: update lnki_commons_flag
p.Exec_sql(Xob_lnki_regy_tbl.Sql_cs_update_ttls); // lnki_regy: update lnki_ttl with lnki_commons_ttl p.Exec_sql(Xob_lnki_regy_tbl.Sql_cs_update_ttls); // lnki_regy: update cs
} }
public static final String Tbl_name = "orig_regy" public static final String Tbl_name = "orig_regy"
, Fld_lnki_id = "lnki_id", Fld_lnki_ttl = "lnki_ttl", Fld_lnki_ext = "lnki_ext", Fld_lnki_count = "lnki_count" , Fld_lnki_id = "lnki_id", Fld_lnki_ttl = "lnki_ttl", Fld_lnki_ext = "lnki_ext", Fld_lnki_count = "lnki_count"
, Fld_orig_repo = "orig_repo", Fld_orig_page_id = "orig_page_id" , Fld_orig_repo = "orig_repo", Fld_orig_page_id = "orig_page_id"
, Fld_orig_redirect_id = "orig_redirect_id", Fld_orig_redirect_ttl = "orig_redirect_ttl", Fld_orig_file_id = "orig_file_id", Fld_orig_file_ttl = "orig_file_ttl" , Fld_orig_redirect_id = "orig_redirect_id", Fld_orig_redirect_ttl = "orig_redirect_ttl", Fld_orig_file_id = "orig_file_id", Fld_orig_file_ttl = "orig_file_ttl"
, Fld_orig_size = "orig_size", Fld_orig_w = "orig_w", Fld_orig_h = "orig_h", Fld_orig_bits = "orig_bits" , Fld_orig_size = "orig_size", Fld_orig_w = "orig_w", Fld_orig_h = "orig_h", Fld_orig_bits = "orig_bits"
, Fld_orig_media_type = "orig_media_type", Fld_orig_minor_mime = "orig_minor_mime", Fld_orig_file_ext = "orig_file_ext"; , Fld_orig_media_type = "orig_media_type", Fld_orig_minor_mime = "orig_minor_mime", Fld_orig_file_ext = "orig_file_ext", Fld_orig_timestamp = "orig_timestamp"
;
private static final Db_idx_itm private static final Db_idx_itm
Idx_ttl = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS orig_regy__ttl ON orig_regy (lnki_ttl);") Idx_ttl = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS orig_regy__ttl ON orig_regy (lnki_ttl);")
, Idx_xfer_temp = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS orig_regy__xfer_temp ON orig_regy (lnki_ttl, orig_file_ttl);") , Idx_xfer_temp = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS orig_regy__xfer_temp ON orig_regy (lnki_ttl, orig_file_ttl, orig_timestamp);")
; ;
private static final String private static final String
Tbl_sql = String_.Concat_lines_nl Tbl_sql = String_.Concat_lines_nl
@ -92,16 +93,18 @@ class Xob_orig_regy_tbl {
, ", orig_bits smallint NULL" , ", orig_bits smallint NULL"
, ", orig_media_type varchar(64) NULL" , ", orig_media_type varchar(64) NULL"
, ", orig_minor_mime varchar(32) NULL" , ", orig_minor_mime varchar(32) NULL"
, ", orig_timestamp varchar(14) NULL"
, ");" , ");"
) )
, Sql_create_data = String_.Concat_lines_nl , Sql_create_data = String_.Concat_lines_nl
( "INSERT INTO orig_regy (lnki_id, lnki_ttl, lnki_commons_ttl, orig_commons_flag, lnki_ext, lnki_count)" ( "INSERT INTO orig_regy (lnki_id, lnki_ttl, lnki_commons_ttl, orig_commons_flag, lnki_ext, lnki_count, orig_timestamp)"
, "SELECT Min(lnki_id)" , "SELECT Min(lnki_id)"
, ", lnki_ttl" , ", lnki_ttl"
, ", lnki_commons_ttl" , ", lnki_commons_ttl"
, ", NULL" , ", NULL"
, ", lnki_ext" , ", lnki_ext"
, ", Sum(lnki_count)" , ", Sum(lnki_count)"
, ", ''"
, "FROM lnki_regy" , "FROM lnki_regy"
, "GROUP BY lnki_ttl" , "GROUP BY lnki_ttl"
, ", lnki_ext" , ", lnki_ext"
@ -129,10 +132,11 @@ class Xob_orig_regy_tbl {
, ", i.img_bits" , ", i.img_bits"
, ", i.img_media_type" , ", i.img_media_type"
, ", i.img_minor_mime" , ", i.img_minor_mime"
, ", i.img_timestamp"
, "FROM orig_regy o" , "FROM orig_regy o"
, " JOIN image_db.image i ON o.lnki_ttl = i.img_name" , " JOIN image_db.image i ON o.lnki_ttl = i.img_name"
, " JOIN page_db.page_regy m ON m.repo_id = {0} AND m.itm_tid = 0 AND o.lnki_ttl = m.src_ttl" , " JOIN page_db.page_regy m ON m.repo_id = {0} AND m.itm_tid = 0 AND o.lnki_ttl = m.src_ttl"
, "WHERE o.orig_file_ttl IS NULL" , "WHERE i.img_timestamp > o.orig_timestamp" // NOTE: this handles an image in local and remote by taking later version; DATE:2014-07-22
, "ORDER BY 1" // must order by lnki_id since it is PRIMARY KEY, else sqlite will spend hours shuffling rows in table , "ORDER BY 1" // must order by lnki_id since it is PRIMARY KEY, else sqlite will spend hours shuffling rows in table
, ";" , ";"
) )
@ -157,10 +161,11 @@ class Xob_orig_regy_tbl {
, ", i.img_bits" , ", i.img_bits"
, ", i.img_media_type" , ", i.img_media_type"
, ", i.img_minor_mime" , ", i.img_minor_mime"
, ", i.img_timestamp"
, "FROM orig_regy o" , "FROM orig_regy o"
, " JOIN page_db.page_regy m ON m.repo_id = {0} AND m.itm_tid = 1 AND o.lnki_ttl = m.src_ttl" , " JOIN page_db.page_regy m ON m.repo_id = {0} AND m.itm_tid = 1 AND o.lnki_ttl = m.src_ttl"
, " JOIN image_db.image i ON m.trg_ttl = i.img_name" , " JOIN image_db.image i ON m.trg_ttl = i.img_name"
, "WHERE o.orig_file_ttl IS NULL" , "WHERE i.img_timestamp > o.orig_timestamp" // NOTE: this handles an image in local and remote by taking later version; DATE:2014-07-22
, "ORDER BY 1" // must order by lnki_id since it is PRIMARY KEY, else sqlite will spend hours shuffling rows in table , "ORDER BY 1" // must order by lnki_id since it is PRIMARY KEY, else sqlite will spend hours shuffling rows in table
, ";" , ";"
) )
@ -185,9 +190,10 @@ class Xob_orig_regy_tbl {
, ", o.orig_bits" , ", o.orig_bits"
, ", o.orig_media_type" , ", o.orig_media_type"
, ", o.orig_minor_mime" , ", o.orig_minor_mime"
, ", o.orig_timestamp"
, "FROM orig_regy o" , "FROM orig_regy o"
, " JOIN orig_regy o2 ON o.lnki_commons_ttl = o2.lnki_ttl" // EX: 2 rows in table (1) A.jpg; and (2) "a.jpg,A.jpg"; do not insert row (2) b/c row (1) exists; , " JOIN orig_regy o2 ON o.lnki_commons_ttl = o2.lnki_ttl" // EX: 2 rows in table (1) A.jpg; and (2) "a.jpg,A.jpg"; do not insert row (2) b/c row (1) exists;
, "WHERE o.orig_file_ttl IS NULL" , "WHERE o.orig_file_ttl IS NULL" // NOTE: don't use timestamp logic here
, "ORDER BY 1" // must order by lnki_id since it is PRIMARY KEY, else sqlite will spend hours shuffling rows in table , "ORDER BY 1" // must order by lnki_id since it is PRIMARY KEY, else sqlite will spend hours shuffling rows in table
, ";" , ";"
) )

View File

@ -111,7 +111,7 @@ class Xob_xfer_temp_itm {
chk_tid = Chk_tid_ns_is_media; chk_tid = Chk_tid_ns_is_media;
return false; return false;
} }
boolean upright_patch = true; // all future blds will have upright_patch int upright_patch = Xof_patch_upright_tid_.Tid_all; // all future blds will have upright_patch
img_size.Html_size_calc(Xof_exec_tid.Tid_wiki_page, lnki_w, lnki_h, lnki_type, upright_patch, lnki_upright, lnki_ext, orig_w, orig_h, Xof_img_size.Thumb_width_img); img_size.Html_size_calc(Xof_exec_tid.Tid_wiki_page, lnki_w, lnki_h, lnki_type, upright_patch, lnki_upright, lnki_ext, orig_w, orig_h, Xof_img_size.Thumb_width_img);
return true; return true;
} }

View File

@ -20,7 +20,7 @@ import gplx.ios.*; import gplx.xowa.bldrs.*; import gplx.dbs.*; import gplx.xowa
public class Xob_wiki_image_sql extends Xob_itm_dump_base implements Xob_cmd, GfoInvkAble, Sql_file_parser_cmd { public class Xob_wiki_image_sql extends Xob_itm_dump_base implements Xob_cmd, GfoInvkAble, Sql_file_parser_cmd {
private Db_provider provider = null; private Db_stmt stmt = null; private Db_provider provider = null; private Db_stmt stmt = null;
private Xob_wiki_image_tbl tbl_image = new Xob_wiki_image_tbl(); private Xob_wiki_image_tbl tbl_image = new Xob_wiki_image_tbl();
private byte[] cur_ttl, cur_media_type, cur_minor_mime; private int cur_size, cur_width, cur_height, cur_bits, cur_ext_id; private byte[] cur_ttl, cur_media_type, cur_minor_mime, cur_timestamp; private int cur_size, cur_width, cur_height, cur_bits, cur_ext_id;
private int commit_count = 10000; private int commit_count = 10000;
public Xob_wiki_image_sql(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);} public Xob_wiki_image_sql(Xob_bldr bldr, Xow_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
public String Cmd_key() {return KEY;} public static final String KEY = "wiki.image"; public String Cmd_key() {return KEY;} public static final String KEY = "wiki.image";
@ -34,7 +34,7 @@ public class Xob_wiki_image_sql extends Xob_itm_dump_base implements Xob_cmd, Gf
src_fil = Xobd_rdr.Find_fil_by(wiki.Fsys_mgr().Root_dir(), "*-image.sql"); src_fil = Xobd_rdr.Find_fil_by(wiki.Fsys_mgr().Root_dir(), "*-image.sql");
if (src_fil == null) throw Err_mgr._.fmt_(Xob_cmd_mgr.GRP_KEY, "sql_file_missing", ".sql file not found in dir: ~{0}", wiki.Fsys_mgr().Root_dir()); if (src_fil == null) throw Err_mgr._.fmt_(Xob_cmd_mgr.GRP_KEY, "sql_file_missing", ".sql file not found in dir: ~{0}", wiki.Fsys_mgr().Root_dir());
} }
parser.Src_fil_(src_fil).Trg_fil_gen_(dump_url_gen).Fld_cmd_(this).Flds_req_idx_(20, Fld_img_name, Fld_img_size, Fld_img_width, Fld_img_height, Fld_img_bits, Fld_img_media_type, Fld_img_minor_mime); parser.Src_fil_(src_fil).Trg_fil_gen_(dump_url_gen).Fld_cmd_(this).Flds_req_idx_(20, Fld_img_name, Fld_img_size, Fld_img_width, Fld_img_height, Fld_img_bits, Fld_img_media_type, Fld_img_minor_mime, Fld_img_timestamp);
provider = Xodb_db_file.init__wiki_image(wiki.Fsys_mgr().Root_dir()).Provider(); provider = Xodb_db_file.init__wiki_image(wiki.Fsys_mgr().Root_dir()).Provider();
provider.Txn_mgr().Txn_bgn_if_none(); provider.Txn_mgr().Txn_bgn_if_none();
@ -55,9 +55,10 @@ public class Xob_wiki_image_sql extends Xob_itm_dump_base implements Xob_cmd, Gf
case Fld_img_height: cur_height = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break; case Fld_img_height: cur_height = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
case Fld_img_bits: cur_bits = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break; case Fld_img_bits: cur_bits = Bry_.Xto_int_or(src, fld_bgn, fld_end, -1); break;
case Fld_img_media_type: cur_media_type = Bry_.Mid(src, fld_bgn, fld_end); break; case Fld_img_media_type: cur_media_type = Bry_.Mid(src, fld_bgn, fld_end); break;
case Fld_img_minor_mime: cur_minor_mime = Bry_.Mid(src, fld_bgn, fld_end); case Fld_img_minor_mime: cur_minor_mime = Bry_.Mid(src, fld_bgn, fld_end); break;
case Fld_img_timestamp: cur_timestamp = Bry_.Mid(src, fld_bgn, fld_end);
cur_ext_id = Calc_ext_id(show_issues ? app.Usr_dlg() : Gfo_usr_dlg_.Null, cur_ttl, cur_media_type, cur_minor_mime, cur_width, cur_height); cur_ext_id = Calc_ext_id(show_issues ? app.Usr_dlg() : Gfo_usr_dlg_.Null, cur_ttl, cur_media_type, cur_minor_mime, cur_width, cur_height);
tbl_image.Insert(stmt, cur_ttl, cur_media_type, cur_minor_mime, cur_size, cur_width, cur_height, cur_bits, cur_ext_id); tbl_image.Insert(stmt, cur_ttl, cur_media_type, cur_minor_mime, cur_size, cur_width, cur_height, cur_bits, cur_ext_id, cur_timestamp);
++commit_count; ++commit_count;
if ((commit_count % 10000) == 0) { if ((commit_count % 10000) == 0) {
usr_dlg.Prog_many("", "", "committing: count=~{0} last=~{1}", commit_count, String_.new_utf8_(cur_ttl)); usr_dlg.Prog_many("", "", "committing: count=~{0} last=~{1}", commit_count, String_.new_utf8_(cur_ttl));
@ -69,7 +70,7 @@ public class Xob_wiki_image_sql extends Xob_itm_dump_base implements Xob_cmd, Gf
public void Cmd_end() {} public void Cmd_end() {}
public void Cmd_print() {} public void Cmd_print() {}
private boolean show_issues = true; private boolean show_issues = true;
private static final int Fld_img_name = 0, Fld_img_size = 1, Fld_img_width = 2, Fld_img_height = 3, Fld_img_bits = 5, Fld_img_media_type = 6, Fld_img_minor_mime = 8; private static final int Fld_img_name = 0, Fld_img_size = 1, Fld_img_width = 2, Fld_img_height = 3, Fld_img_bits = 5, Fld_img_media_type = 6, Fld_img_minor_mime = 8, Fld_img_timestamp = 12;
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { @Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_src_fil_)) src_fil = m.ReadIoUrl("v"); if (ctx.Match(k, Invk_src_fil_)) src_fil = m.ReadIoUrl("v");
else if (ctx.Match(k, Invk_show_issues_)) show_issues = m.ReadYn("v"); else if (ctx.Match(k, Invk_show_issues_)) show_issues = m.ReadYn("v");

View File

@ -20,8 +20,8 @@ import gplx.dbs.*;
public class Xob_wiki_image_tbl { public class Xob_wiki_image_tbl {
public Xob_wiki_image_tbl Create_table(Db_provider p) {Sqlite_engine_.Tbl_create_and_delete(p, Tbl_name, Tbl_sql); return this;} public Xob_wiki_image_tbl Create_table(Db_provider p) {Sqlite_engine_.Tbl_create_and_delete(p, Tbl_name, Tbl_sql); return this;}
public Xob_wiki_image_tbl Create_index(Db_provider p) {Sqlite_engine_.Idx_create(p, Idx_img_name); return this;} public Xob_wiki_image_tbl Create_index(Db_provider p) {Sqlite_engine_.Idx_create(p, Idx_img_name); return this;}
public Db_stmt Insert_stmt(Db_provider p) {return Db_stmt_.new_insert_(p, Tbl_name, Fld_img_name, Fld_img_media_type, Fld_img_minor_mime, Fld_img_size, Fld_img_width, Fld_img_height, Fld_img_bits, Fld_img_ext_id);} public Db_stmt Insert_stmt(Db_provider p) {return Db_stmt_.new_insert_(p, Tbl_name, Fld_img_name, Fld_img_media_type, Fld_img_minor_mime, Fld_img_size, Fld_img_width, Fld_img_height, Fld_img_bits, Fld_img_ext_id, Fld_img_timestamp);}
public void Insert(Db_stmt stmt, byte[] ttl, byte[] media_type, byte[] minor_mime, int size, int w, int h, int bits, int ext_id) { public void Insert(Db_stmt stmt, byte[] ttl, byte[] media_type, byte[] minor_mime, int size, int w, int h, int bits, int ext_id, byte[] img_timestamp) {
stmt.Clear() stmt.Clear()
.Val_str_by_bry_(ttl) .Val_str_by_bry_(ttl)
.Val_str_by_bry_(media_type) .Val_str_by_bry_(media_type)
@ -31,11 +31,13 @@ public class Xob_wiki_image_tbl {
.Val_int_(h) .Val_int_(h)
.Val_int_(bits) .Val_int_(bits)
.Val_int_(ext_id) .Val_int_(ext_id)
.Val_str_by_bry_(img_timestamp)
.Exec_insert(); .Exec_insert();
} }
public static final String Tbl_name = "image" public static final String Tbl_name = "image"
, Fld_img_name = "img_name", Fld_img_media_type = "img_media_type", Fld_img_minor_mime = "img_minor_mime" , Fld_img_name = "img_name", Fld_img_media_type = "img_media_type", Fld_img_minor_mime = "img_minor_mime"
, Fld_img_size = "img_size", Fld_img_width = "img_width", Fld_img_height = "img_height", Fld_img_bits = "img_bits", Fld_img_ext_id = "img_ext_id" , Fld_img_size = "img_size", Fld_img_width = "img_width", Fld_img_height = "img_height", Fld_img_bits = "img_bits", Fld_img_ext_id = "img_ext_id"
, Fld_img_timestamp = "img_timestamp"
; ;
private static final String Tbl_sql = String_.Concat_lines_nl private static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS image" ( "CREATE TABLE IF NOT EXISTS image"
@ -47,9 +49,10 @@ public class Xob_wiki_image_tbl {
, ", img_height integer NOT NULL -- int(5)" , ", img_height integer NOT NULL -- int(5)"
, ", img_bits smallint NOT NULL -- int(3)" , ", img_bits smallint NOT NULL -- int(3)"
, ", img_ext_id int NOT NULL -- xowa" , ", img_ext_id int NOT NULL -- xowa"
, ", img_timestamp varchar(14) NOT NULL -- 20140101155749"
, ");" , ");"
); );
private static final Db_idx_itm private static final Db_idx_itm
Idx_img_name = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS image__img_name ON image (img_name);") Idx_img_name = Db_idx_itm.sql_("CREATE INDEX IF NOT EXISTS image__img_name ON image (img_name, img_timestamp);")
; ;
} }

View File

@ -0,0 +1,52 @@
/*
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
import gplx.ios.*;
public class Hdump_frag_row {
public int Frag_id() {return frag_id;} private int frag_id;
public int Page_id() {return page_id;} private int page_id;
public int Frag_tid() {return frag_tid;} private int frag_tid;
public byte[] Frag_key() {return frag_key;} private byte[] frag_key;
public byte[] Frag_text() {return frag_text;} private byte[] frag_text;
public Hdump_frag_row Ctor(int frag_id, int page_id, int frag_tid, byte[] frag_key, byte[] frag_text) {
this.frag_id = frag_id;
this.page_id = page_id;
this.frag_tid = frag_tid;
this.frag_key = frag_key;
this.frag_text = frag_text;
return this;
}
}
class Hdump_frag_tid {
public static final int Tid_file = 1, Tid_title = 2, Tid_sidebar = 3;
public static final String Key_file = "file", Key_title = "title", Key_sidebar = "sidebar";
public static String Xto_key(int v) {
switch (v) {
case Tid_file : return Key_file;
case Tid_title : return Key_title;
case Tid_sidebar : return Key_sidebar;
default : throw Err_.unhandled(v);
}
}
public static byte Xto_tid(String v) {
if (String_.Eq(v, Key_file)) return Tid_file;
else if (String_.Eq(v, Key_title)) return Tid_title;
else if (String_.Eq(v, Key_sidebar)) return Tid_sidebar;
else throw Err_.unhandled("v");
}
}

View File

@ -0,0 +1,93 @@
/*
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
import gplx.dbs.*; import gplx.ios.*;
public class Hdump_frag_tbl {
private Db_stmt stmt_select, stmt_insert, stmt_update, stmt_delete;
@gplx.Virtual public void Insert(Db_provider provider, int frag_id, int page_id, int frag_tid, byte[] frag_key, byte[] frag_text) {
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all);
try {
stmt_insert.Val_int_(frag_id).Val_int_(page_id).Val_int_(frag_tid).Val_str_by_bry_(frag_key).Val_str_by_bry_(frag_text).Exec_insert();
} finally {stmt_insert.Rls();}
}
@gplx.Virtual public void Update(Db_provider provider, int frag_id, int page_id, int frag_tid, byte[] frag_key, byte[] frag_text) {
if (stmt_update == null) stmt_update = Db_stmt_.new_update_(provider, Tbl_name, Flds_all);
try {
stmt_update.Val_int_(frag_id).Val_int_(page_id).Val_int_(frag_tid).Val_str_by_bry_(frag_key).Val_str_by_bry_(frag_text).Exec_update();
} finally {stmt_update.Rls();}
}
@gplx.Virtual public void Select(Db_provider provider, Hdump_frag_row rv, int frag_id) {
if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_frag_id), Flds_all);
try {
DataRdr rdr = stmt_select.Val_int_(frag_id).Exec_select();
rv.Ctor
( rdr.ReadInt(Fld_frag_id)
, rdr.ReadInt(Fld_page_id)
, rdr.ReadInt(Fld_frag_tid)
, rdr.ReadBryByStr(Fld_frag_key)
, rdr.ReadBryByStr(Fld_frag_text)
);
rdr.Rls();
} finally {stmt_select.Rls();}
}
@gplx.Virtual public void Delete(Db_provider provider, int frag_id) {
if (stmt_delete == null) stmt_delete = Db_stmt_.new_delete_(provider, Tbl_name, Fld_frag_id);
try {
stmt_delete.Val_int_(frag_id).Exec_delete();
} finally {stmt_delete.Rls();}
}
@gplx.Virtual public void Delete_all(Db_provider provider) {
Db_qry_.delete_tbl_(Tbl_name).Exec_qry(provider);
}
public void Rls() {
stmt_select = stmt_insert = stmt_update = stmt_delete = null;
}
public static final String Tbl_name = "html_frag"
, Fld_frag_id = "frag_id", Fld_page_id = "page_id", Fld_frag_tid = "frag_tid"
, Fld_frag_key = "frag_key", Fld_frag_text = "frag_text";
private static final String[] Flds_all = new String[] {Fld_frag_id, Fld_page_id, Fld_frag_tid, Fld_frag_key, Fld_frag_text};
public static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS html_frag"
, "( frag_id integer NOT NULL PRIMARY KEY"
, ", page_id integer NOT NULL"
, ", frag_tid integer NOT NULL"
, ", frag_key varchar(255) NOT NULL"
, ", frag_text mediumblob NOT NULL"
, ");"
);
}
class Hdump_frag_tbl_mem extends Hdump_frag_tbl { private OrderedHash hash = OrderedHash_.new_();
@Override public void Insert(Db_provider provider, int frag_id, int page_id, int frag_tid, byte[] frag_key, byte[] frag_text) {
Hdump_frag_row row = new Hdump_frag_row().Ctor(frag_id, page_id, frag_tid, frag_key, frag_text);
hash.Add(frag_id, row);
}
@Override public void Update(Db_provider provider, int frag_id, int page_id, int frag_tid, byte[] frag_key, byte[] frag_text) {
Hdump_frag_row row = (Hdump_frag_row)hash.Fetch(frag_id);
row.Ctor(frag_id, page_id, frag_tid, frag_key, frag_text);
}
@Override public void Select(Db_provider provider, Hdump_frag_row rv, int frag_id) {
Hdump_frag_row row = (Hdump_frag_row)hash.Fetch(frag_id);
rv.Ctor(row.Frag_id(), row.Page_id(), row.Frag_tid(), row.Frag_key(), row.Frag_text());
}
@Override public void Delete(Db_provider provider, int frag_id) {
hash.Del(frag_id);
}
@Override public void Delete_all(Db_provider provider) {
hash.Clear();
}
}

View File

@ -18,13 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*; package gplx.xowa.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
import gplx.ios.*; import gplx.ios.*;
public class Hdump_page_row { public class Hdump_page_row {
public int Id() {return id;} private int id; public int Page_id() {return page_id;} private int page_id;
public byte[] Html() {return html;} private byte[] html; public byte[] Page_html() {return page_html;} private byte[] page_html;
public int Frags_len() {return frags_len;} private int frags_len; public int Frags_len() {return frags_len;} private int frags_len;
public int Make_id() {return make_id;} private int make_id; public int Make_id() {return make_id;} private int make_id;
public Hdump_page_row Ctor(int id, byte[] html, int frags_len, int make_id) { public Hdump_page_row Ctor(int page_id, byte[] page_html, int frags_len, int make_id) {
this.id = id; this.page_id = page_id;
this.html = html; this.page_html = page_html;
this.frags_len = frags_len; this.frags_len = frags_len;
this.make_id = make_id; this.make_id = make_id;
return this; return this;

View File

@ -18,67 +18,76 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*; package gplx.xowa.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
import gplx.dbs.*; import gplx.ios.*; import gplx.dbs.*; import gplx.ios.*;
public class Hdump_page_tbl { public class Hdump_page_tbl {
private Db_stmt stmt_select, stmt_insert, stmt_update; private Db_stmt stmt_select, stmt_insert, stmt_update, stmt_delete;
private Io_stream_zip_mgr zip_mgr; private byte zip_tid; private Io_stream_zip_mgr zip_mgr; private byte zip_tid;
public void Ctor(Io_stream_zip_mgr zip_mgr, byte zip_tid) {this.zip_mgr = zip_mgr; this.zip_tid = zip_tid;} public void Ctor(Io_stream_zip_mgr zip_mgr, byte zip_tid) {this.zip_mgr = zip_mgr; this.zip_tid = zip_tid;}
@gplx.Virtual public void Insert(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) { @gplx.Virtual public void Insert(Db_provider provider, int page_id, byte[] page_html, int frags_len, int make_id) {
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all); if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all);
try { try {
html = zip_mgr.Zip(zip_tid, html); page_html = zip_mgr.Zip(zip_tid, page_html);
stmt_insert.Val_int_(page_id).Val_bry_(html).Val_int_(frags_len).Val_int_(make_id).Exec_insert(); stmt_insert.Val_int_(page_id).Val_str_by_bry_(page_html).Val_int_(frags_len).Val_int_(make_id).Exec_insert();
} finally {stmt_insert.Rls();} } finally {stmt_insert.Rls();}
} }
@gplx.Virtual public void Update(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) { @gplx.Virtual public void Update(Db_provider provider, int page_id, byte[] page_html, int frags_len, int make_id) {
if (stmt_update == null) stmt_update = Db_stmt_.new_update_(provider, Tbl_name, Flds_all); if (stmt_update == null) stmt_update = Db_stmt_.new_update_(provider, Tbl_name, Flds_all);
try { try {
html = zip_mgr.Zip(zip_tid, html); page_html = zip_mgr.Zip(zip_tid, page_html);
stmt_update.Val_int_(page_id).Val_bry_(html).Val_int_(frags_len).Val_int_(make_id).Exec_update(); stmt_update.Val_int_(page_id).Val_str_by_bry_(page_html).Val_int_(frags_len).Val_int_(make_id).Exec_update();
} finally {stmt_update.Rls();} } finally {stmt_update.Rls();}
} }
@gplx.Virtual public void Select(Db_provider provider, Hdump_page_row rv, int page_id) { @gplx.Virtual public void Select(Db_provider provider, Hdump_page_row rv, int page_id) {
if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_page_id), Flds_all); if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_page_id), Flds_all);
try { try {
DataRdr rdr = stmt_select.Exec_select(); DataRdr rdr = stmt_select.Val_int_(page_id).Exec_select();
rv.Ctor rv.Ctor
( rdr.ReadInt(Fld_page_id) ( rdr.ReadInt(Fld_page_id)
, zip_mgr.Unzip(zip_tid, rdr.ReadBry(Fld_page_text)) , zip_mgr.Unzip(zip_tid, rdr.ReadBry(Fld_page_html))
, rdr.ReadInt(Fld_frags_len) , rdr.ReadInt(Fld_frags_len)
, rdr.ReadInt(Fld_make_id) , rdr.ReadInt(Fld_make_id)
); );
rdr.Rls(); rdr.Rls();
} finally {stmt_select.Rls();} } finally {stmt_select.Rls();}
} }
@gplx.Virtual public void Delete(Db_provider provider, int page_id) {
if (stmt_delete == null) stmt_delete = Db_stmt_.new_delete_(provider, Tbl_name, Fld_page_id);
try {
stmt_delete.Val_int_(page_id).Exec_delete();
} finally {stmt_delete.Rls();}
}
@gplx.Virtual public void Delete_all(Db_provider provider) { @gplx.Virtual public void Delete_all(Db_provider provider) {
Db_qry_.delete_tbl_(Tbl_name).Exec_qry(provider); Db_qry_.delete_tbl_(Tbl_name).Exec_qry(provider);
} }
public void Rls() { public void Rls() {
stmt_select = stmt_insert = stmt_update = null; stmt_select = stmt_insert = stmt_update = stmt_delete = null;
zip_mgr = null; zip_mgr = null;
} }
public static final String Tbl_name = "html_page" public static final String Tbl_name = "html_page"
, Fld_page_id = "page_id", Fld_page_text = "page_text", Fld_frags_len = "frags_len", Fld_make_id= "make_id"; , Fld_page_id = "page_id", Fld_page_html = "page_html", Fld_frags_len = "frags_len", Fld_make_id= "make_id";
private static final String[] Flds_all = new String[] {Fld_page_id, Fld_page_text, Fld_frags_len, Fld_make_id}; private static final String[] Flds_all = new String[] {Fld_page_id, Fld_page_html, Fld_frags_len, Fld_make_id};
public static final String Tbl_sql = String_.Concat_lines_nl public static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS html_page" ( "CREATE TABLE IF NOT EXISTS html_page"
, "( page_id integer NOT NULL PRIMARY KEY" , "( page_id integer NOT NULL PRIMARY KEY"
, ", page_text mediumblob NOT NULL" , ", page_html mediumblob NOT NULL"
, ", frags_len integer NOT NULL" , ", frags_len integer NOT NULL"
, ", make_id integer NOT NULL" , ", make_id integer NOT NULL"
, ");" , ");"
); );
} }
class Hdump_page_tbl_mem extends Hdump_page_tbl { private OrderedHash hash = OrderedHash_.new_(); class Hdump_page_tbl_mem extends Hdump_page_tbl { private OrderedHash hash = OrderedHash_.new_();
@Override public void Insert(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) { @Override public void Insert(Db_provider provider, int page_id, byte[] page_html, int frags_len, int make_id) {
Hdump_page_row row = new Hdump_page_row().Ctor(page_id, html, frags_len, make_id); Hdump_page_row row = new Hdump_page_row().Ctor(page_id, page_html, frags_len, make_id);
hash.Add(page_id, row); hash.Add(page_id, row);
} }
@Override public void Update(Db_provider provider, int page_id, byte[] html, int frags_len, int make_id) { @Override public void Update(Db_provider provider, int page_id, byte[] page_html, int frags_len, int make_id) {
Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id); Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id);
row.Ctor(page_id, html, frags_len, make_id); row.Ctor(page_id, page_html, frags_len, make_id);
} }
@Override public void Select(Db_provider provider, Hdump_page_row rv, int page_id) { @Override public void Select(Db_provider provider, Hdump_page_row rv, int page_id) {
Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id); Hdump_page_row row = (Hdump_page_row)hash.Fetch(page_id);
rv.Ctor(row.Id(), row.Html(), row.Frags_len(), row.Make_id()); rv.Ctor(row.Page_id(), row.Page_html(), row.Frags_len(), row.Make_id());
}
@Override public void Delete(Db_provider provider, int page_id) {
hash.Del(page_id);
} }
@Override public void Delete_all(Db_provider provider) { @Override public void Delete_all(Db_provider provider) {
hash.Clear(); hash.Clear();

View File

@ -0,0 +1,28 @@
/*
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
import gplx.ios.*;
public class Hdump_skin_row {
public int Skin_id() {return skin_id;} private int skin_id;
public byte[] Skin_html() {return skin_html;} private byte[] skin_html;
public Hdump_skin_row Ctor(int skin_id, byte[] skin_html) {
this.skin_id = skin_id;
this.skin_html = skin_html;
return this;
}
}

View File

@ -0,0 +1,86 @@
/*
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.dbs.hdumps; import gplx.*; import gplx.xowa.*; import gplx.xowa.dbs.*;
import gplx.dbs.*; import gplx.ios.*;
public class Hdump_skin_tbl {
private Db_stmt stmt_select, stmt_insert, stmt_update, stmt_delete;
@gplx.Virtual public void Insert(Db_provider provider, int skin_id, byte[] skin_text) {
if (stmt_insert == null) stmt_insert = Db_stmt_.new_insert_(provider, Tbl_name, Flds_all);
try {
stmt_insert.Val_int_(skin_id).Val_str_by_bry_(skin_text).Exec_insert();
} finally {stmt_insert.Rls();}
}
@gplx.Virtual public void Update(Db_provider provider, int skin_id, byte[] skin_text) {
if (stmt_update == null) stmt_update = Db_stmt_.new_update_(provider, Tbl_name, Flds_all);
try {
stmt_update.Val_int_(skin_id).Val_str_by_bry_(skin_text).Exec_update();
} finally {stmt_update.Rls();}
}
@gplx.Virtual public void Select(Db_provider provider, Hdump_skin_row rv, int skin_id) {
if (stmt_select == null) stmt_select = Db_stmt_.new_select_(provider, Tbl_name, String_.Ary(Fld_skin_id), Flds_all);
try {
DataRdr rdr = stmt_select.Val_int_(skin_id).Exec_select();
rv.Ctor
( rdr.ReadInt(Fld_skin_id)
, rdr.ReadBryByStr(Fld_skin_text)
);
rdr.Rls();
} finally {stmt_select.Rls();}
}
@gplx.Virtual public void Delete(Db_provider provider, int skin_id) {
if (stmt_delete == null) stmt_delete = Db_stmt_.new_delete_(provider, Tbl_name, Fld_skin_id);
try {
stmt_delete.Val_int_(skin_id).Exec_delete();
} finally {stmt_delete.Rls();}
}
@gplx.Virtual public void Delete_all(Db_provider provider) {
Db_qry_.delete_tbl_(Tbl_name).Exec_qry(provider);
}
public void Rls() {
stmt_select = stmt_insert = stmt_update = stmt_delete = null;
}
public static final String Tbl_name = "html_skin"
, Fld_skin_id = "skin_id", Fld_skin_text = "skin_text";
private static final String[] Flds_all = new String[] {Fld_skin_id, Fld_skin_text};
public static final String Tbl_sql = String_.Concat_lines_nl
( "CREATE TABLE IF NOT EXISTS html_skin"
, "( skin_id integer NOT NULL PRIMARY KEY"
, ", skin_text mediumblob NOT NULL"
, ");"
);
}
class Hdump_skin_tbl_mem extends Hdump_skin_tbl { private OrderedHash hash = OrderedHash_.new_();
@Override public void Insert(Db_provider provider, int skin_id, byte[] skin_text) {
Hdump_skin_row row = new Hdump_skin_row().Ctor(skin_id, skin_text);
hash.Add(skin_id, row);
}
@Override public void Update(Db_provider provider, int skin_id, byte[] skin_text) {
Hdump_skin_row row = (Hdump_skin_row)hash.Fetch(skin_id);
row.Ctor(skin_id, skin_text);
}
@Override public void Select(Db_provider provider, Hdump_skin_row rv, int skin_id) {
Hdump_skin_row row = (Hdump_skin_row)hash.Fetch(skin_id);
rv.Ctor(row.Skin_id(), row.Skin_html());
}
@Override public void Delete(Db_provider provider, int skin_id) {
hash.Del(skin_id);
}
@Override public void Delete_all(Db_provider provider) {
hash.Clear();
}
}

View File

@ -27,7 +27,7 @@ public class Xof_img_size {
html_w = html_h = file_w = file_h = 0; html_w = html_h = file_w = file_h = 0;
file_is_orig = false; file_is_orig = false;
} }
public void Html_size_calc(byte exec_tid, int lnki_w, int lnki_h, byte lnki_type, boolean upright_patch, double lnki_upright, int lnki_ext, int orig_w, int orig_h, int thm_dflt_w) { public void Html_size_calc(byte exec_tid, int lnki_w, int lnki_h, byte lnki_type, int upright_patch, double lnki_upright, int lnki_ext, int orig_w, int orig_h, int thm_dflt_w) {
this.Clear(); // always clear before calc; caller should be responsible, but just to be safe. this.Clear(); // always clear before calc; caller should be responsible, but just to be safe.
if (lnki_type == Xop_lnki_type.Id_frame // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale if (lnki_type == Xop_lnki_type.Id_frame // frame: always return orig size; Linker.php!makeThumbLink2; // Use image dimensions, don't scale
&& lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22 && lnki_h == Null) { // unless lnki_h specified; DATE:2013-12-22
@ -102,15 +102,18 @@ public class Xof_img_size {
? 0 ? 0
: (int)Math_.Round(((double)lnki_w * file_h) / file_w, 0); // NOTE: (double) needed else result will be int and fraction will be truncated : (int)Math_.Round(((double)lnki_w * file_h) / file_w, 0); // NOTE: (double) needed else result will be int and fraction will be truncated
} }
public static int Upright_calc(boolean upright_patch, double upright, int cur_w, int lnki_w, int lnki_h, byte lnki_type) { public static int Upright_calc(int upright_patch_tid, double upright, int cur_w, int lnki_w, int lnki_h, byte lnki_type) {
if (upright_patch) { boolean upright_patch_use_thumb_w = Xof_patch_upright_tid_.Split_use_thumb_w(upright_patch_tid);
boolean upright_patch_fix_default = Xof_patch_upright_tid_.Split_fix_default(upright_patch_tid);
double upright_default_val = upright_patch_fix_default ? .75f : 1f;
if (upright_patch_use_thumb_w) {
if (upright != Upright_null // upright set if (upright != Upright_null // upright set
&& lnki_w == Null // w is null; EX: ( -1, 220); must exit early or will become 0; DATE:2013-11-23 && lnki_w == Null // w is null; EX: ( -1, 220); must exit early or will become 0; DATE:2013-11-23
&& lnki_h == Null // h is null; EX: (220, -1); REF:Linker.php|makeImageLink|"if (... !$hp['width'] ); && lnki_h == Null // h is null; EX: (220, -1); REF:Linker.php|makeImageLink|"if (... !$hp['width'] );
&& Xop_lnki_type.Id_supports_upright(lnki_type) && Xop_lnki_type.Id_supports_upright(lnki_type)
) { ) {
if (upright == Upright_default) upright = .75f; // upright is default; set val to .75; EX: [[File:A.png|upright]] if (upright == Upright_default_marker) upright = upright_default_val; // upright is default; set val to .75; EX: [[File:A.png|upright]]
int rv = (int)(Thumb_width_img * upright); int rv = (int)(Thumb_width_img * upright);
return Round_10p2(rv); return Round_10p2(rv);
} }
else else
@ -118,7 +121,7 @@ public class Xof_img_size {
} }
else { // support old broken calc else { // support old broken calc
if (upright == Upright_null) return cur_w; // upright is null; return width if (upright == Upright_null) return cur_w; // upright is null; return width
else if (upright == 1) upright = .75f; // upright is default; set val to .75; NOTE: wrong b/c [[File:A.png|upright=1]] -> .75 else if (upright == Upright_default_marker)upright = upright_default_val; // upright is default; set val to .75; NOTE: wrong b/c [[File:A.png|upright=1]] -> .75
if (cur_w == Null) return Null; // width is null (-1); must exit early or will become 0; DATE:2013-11-23 if (cur_w == Null) return Null; // width is null (-1); must exit early or will become 0; DATE:2013-11-23
int rv = (int)(cur_w * upright); // NOTE: wrong b/c should be Thumb_width_img, not cur_w int rv = (int)(cur_w * upright); // NOTE: wrong b/c should be Thumb_width_img, not cur_w
return Round_10p2(rv); return Round_10p2(rv);
@ -132,7 +135,7 @@ public class Xof_img_size {
} }
public static final int Null = -1; public static final int Null = -1;
public static final int Thumb_width_img = 220, Thumb_width_ogv = 220; public static final int Thumb_width_img = 220, Thumb_width_ogv = 220;
public static final double Upright_null = -1, Upright_default = -2; public static final double Upright_null = -1, Upright_default_marker = 0; // REF:MW: if ( isset( $fp['upright'] ) && $fp['upright'] == 0 )
public static final int Size_null_deprecated = -1, Size_null = 0; // Size_null = 0, b/c either imageMagick / inkscape fails when -1 is passed public static final int Size_null_deprecated = -1, Size_null = 0; // Size_null = 0, b/c either imageMagick / inkscape fails when -1 is passed
public static final int Size__same_as_orig = -1; public static final int Size__same_as_orig = -1;
private static final int Svg_max_width = 2048; private static final int Svg_max_width = 2048;

View File

@ -91,7 +91,7 @@ class Xof_img_size_fxt {
public Xof_img_size_fxt Lnki_(int w, int h) {lnki_w = w; lnki_h = h; return this;} private int lnki_w, lnki_h; public Xof_img_size_fxt Lnki_(int w, int h) {lnki_w = w; lnki_h = h; return this;} private int lnki_w, lnki_h;
public void Test_html(int expd_w, int expd_h) {Test_html(expd_w, expd_h, false);} public void Test_html(int expd_w, int expd_h) {Test_html(expd_w, expd_h, false);}
public void Test_html(int expd_html_w, int expd_html_h, boolean expd_file_is_orig) { public void Test_html(int expd_html_w, int expd_html_h, boolean expd_file_is_orig) {
img_size.Html_size_calc(Xof_exec_tid.Tid_wiki_page, lnki_w, lnki_h, lnki_type, true, lnki_upright, lnki_ext, orig_w, orig_h, Xof_img_size.Thumb_width_img); img_size.Html_size_calc(Xof_exec_tid.Tid_wiki_page, lnki_w, lnki_h, lnki_type, Xof_patch_upright_tid_.Tid_all, lnki_upright, lnki_ext, orig_w, orig_h, Xof_img_size.Thumb_width_img);
Tfds.Eq(expd_html_w, img_size.Html_w(), "html_w"); Tfds.Eq(expd_html_w, img_size.Html_w(), "html_w");
Tfds.Eq(expd_html_h, img_size.Html_h(), "html_h"); Tfds.Eq(expd_html_h, img_size.Html_h(), "html_h");
Tfds.Eq(expd_file_is_orig, img_size.File_is_orig(), "file_is_orig"); Tfds.Eq(expd_file_is_orig, img_size.File_is_orig(), "file_is_orig");

View File

@ -48,6 +48,7 @@ public class Xof_lnki_file_mgr {
xfer_itm.Lnki_ext_(fsdb_itm.Lnki_ext()); // WORKAROUND: hacky, but fsdb_itm knows when ogg is ogv whereas xfer_itm does not; so, always override xfer_itm.ext with fsdb's; DATE:2014-02-02 xfer_itm.Lnki_ext_(fsdb_itm.Lnki_ext()); // WORKAROUND: hacky, but fsdb_itm knows when ogg is ogv whereas xfer_itm does not; so, always override xfer_itm.ext with fsdb's; DATE:2014-02-02
xfer_itm.Url_bldr_(url_bldr); // default Url_bldr for xfer_itm uses @ for thumbtime; switch to -; DATE:2014-02-02 xfer_itm.Url_bldr_(url_bldr); // default Url_bldr for xfer_itm uses @ for thumbtime; switch to -; DATE:2014-02-02
Init_fsdb_by_xfer(fsdb_itm, xfer_itm); // copy xfer itm props to fsdb_itm; Init_fsdb_by_xfer(fsdb_itm, xfer_itm); // copy xfer itm props to fsdb_itm;
xfer_itm.Atrs_by_orig(fsdb_itm.Orig_w(), fsdb_itm.Orig_h(), xfer_itm.Orig_file_len()); // copy orig props from orig_itm to xfer_itm
fsdb_itm.Html__init(wiki.File_mgr().Repo_mgr(), url_bldr, tmp_img_size, exec_tid); fsdb_itm.Html__init(wiki.File_mgr().Repo_mgr(), url_bldr, tmp_img_size, exec_tid);
xfer_itm.Html_orig_src_(Bry_.new_utf8_(fsdb_itm.Html_orig_url().To_http_file_str())); // always set orig_url; note that w,h are not necessary for orig url; orig url needed for [[Media:]] links; DATE:2014-01-19 xfer_itm.Html_orig_src_(Bry_.new_utf8_(fsdb_itm.Html_orig_url().To_http_file_str())); // always set orig_url; note that w,h are not necessary for orig url; orig url needed for [[Media:]] links; DATE:2014-01-19
gplx.ios.IoItmFil fil = Io_mgr._.QueryFil(fsdb_itm.Html_url()); gplx.ios.IoItmFil fil = Io_mgr._.QueryFil(fsdb_itm.Html_url());
@ -71,7 +72,7 @@ public class Xof_lnki_file_mgr {
return false; return false;
} }
} }
private void Create_xfer_itms(ListAdp lnki_list, boolean upright_patch) { private void Create_xfer_itms(ListAdp lnki_list, int upright_patch) {
int len = lnki_list.Count(); int len = lnki_list.Count();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)lnki_list.FetchAt(i); Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)lnki_list.FetchAt(i);
@ -95,7 +96,7 @@ public class Xof_lnki_file_mgr {
) )
xfer_list.Add(key, itm); xfer_list.Add(key, itm);
} }
private void Init_fsdb_by_lnki(Xof_fsdb_itm fsdb_itm, Xop_lnki_tkn lnki_tkn, boolean lnki_upright_patch) { private void Init_fsdb_by_lnki(Xof_fsdb_itm fsdb_itm, Xop_lnki_tkn lnki_tkn, int lnki_upright_patch) {
byte[] lnki_ttl = lnki_tkn.Ttl().Page_db(); byte[] lnki_ttl = lnki_tkn.Ttl().Page_db();
Xof_ext lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl); Xof_ext lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl);
byte[] lnki_md5 = Xof_xfer_itm_.Md5_(lnki_ttl); byte[] lnki_md5 = Xof_xfer_itm_.Md5_(lnki_ttl);

View File

@ -0,0 +1,30 @@
/*
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.files; import gplx.*; import gplx.xowa.*;
public class Xof_patch_upright_tid_ {
public static final int Tid_unpatched = 0, Tid_use_thumb_w = 1, Tid_fix_default = 2;
public static final int Tid_all = Tid_use_thumb_w | Tid_fix_default;
public static int Merge(boolean use_thumb_w, boolean fix_default) {
if (use_thumb_w && fix_default) return Enm_.AddInt(Tid_use_thumb_w, Tid_fix_default);
else if (use_thumb_w) return Tid_use_thumb_w;
else if (fix_default) return Tid_fix_default;
else return Tid_unpatched;
}
public static boolean Split_use_thumb_w(int tid) {return Enm_.HasInt(tid, Tid_use_thumb_w);}
public static boolean Split_fix_default(int tid) {return Enm_.HasInt(tid, Tid_fix_default);}
}

View File

@ -93,6 +93,14 @@ public class Xof_xfer_itm implements Xof_file_itm {
this.html_pass = true; this.html_pass = true;
this.file_found = true; this.file_found = true;
} }
public Xof_xfer_itm Init_by_lnki(byte[] ttl, byte[] redirect, byte lnki_type, int w, int h, double upright, double thumbtime, int lnki_page) {
this.Atrs_by_ttl(ttl, redirect);
this.lnki_type = lnki_type; this.lnki_w = w; this.lnki_h = h; this.lnki_upright = upright; this.lnki_thumbtime = thumbtime; this.lnki_page = lnki_page;
lnki_thumbable = Xof_xfer_itm_.Lnki_thumbable_calc(lnki_type, lnki_w, lnki_h);
if (lnki_thumbtime != Xof_doc_thumb.Null && !lnki_ext.Id_is_media()) // thumbtime is set, but ext is not media; PAGE:en.w:Moon; EX:[[File:A.png|thumbtime=0:02]] DATE:2014-07-22
lnki_thumbtime = Xof_doc_thumb.Null; // disable thumbtime
return this;
}
public void Atrs_by_meta(Xof_meta_itm meta_itm, Xof_repo_itm trg_repo, int thumb_w_img) {this.meta_itm = meta_itm; this.trg_repo = trg_repo; this.thumb_w_img = thumb_w_img;} private int thumb_w_img; public void Atrs_by_meta(Xof_meta_itm meta_itm, Xof_repo_itm trg_repo, int thumb_w_img) {this.meta_itm = meta_itm; this.trg_repo = trg_repo; this.thumb_w_img = thumb_w_img;} private int thumb_w_img;
public void Atrs_by_meta_only(Xof_meta_itm meta_itm) {this.meta_itm = meta_itm; Atrs_by_ttl(meta_itm.Ttl(), meta_itm.Ptr_ttl());} public void Atrs_by_meta_only(Xof_meta_itm meta_itm) {this.meta_itm = meta_itm; Atrs_by_ttl(meta_itm.Ttl(), meta_itm.Ptr_ttl());}
public Xof_xfer_itm Atrs_by_ttl(byte[] ttl, byte[] redirect) { public Xof_xfer_itm Atrs_by_ttl(byte[] ttl, byte[] redirect) {
@ -103,11 +111,6 @@ public class Xof_xfer_itm implements Xof_file_itm {
this.lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl); this.lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl);
return this; return this;
} }
public Xof_xfer_itm Atrs_by_lnki(byte lnki_type, int w, int h, double upright, double thumbtime, int lnki_page) {
this.lnki_type = lnki_type; this.lnki_w = w; this.lnki_h = h; this.lnki_upright = upright; this.lnki_thumbtime = thumbtime; this.lnki_page = lnki_page;
lnki_thumbable = Xof_xfer_itm_.Lnki_thumbable_calc(lnki_type, lnki_w, lnki_h);
return this;
}
public Xof_xfer_itm Atrs_by_orig(int w, int h, int orig_file_len) {this.orig_w = w; this.orig_h = h; this.orig_file_len = orig_file_len; return this;} public Xof_xfer_itm Atrs_by_orig(int w, int h, int orig_file_len) {this.orig_w = w; this.orig_h = h; this.orig_file_len = orig_file_len; return this;}
public void Atrs_calc_by_fsdb(int html_w, int html_h, Io_url view_url, Io_url orig_url) { public void Atrs_calc_by_fsdb(int html_w, int html_h, Io_url view_url, Io_url orig_url) {
html_pass = true; html_pass = true;

View File

@ -30,7 +30,7 @@ public class Xof_xfer_itm_ {
if (lnki_thumb) rv_w = thumb_default_w; // do not default to thumb if only height is set; EX: x900px should have w=0 h=900 if (lnki_thumb) rv_w = thumb_default_w; // do not default to thumb if only height is set; EX: x900px should have w=0 h=900
else rv_w = file_w; else rv_w = file_w;
} }
rv_w = Xof_img_size.Upright_calc(true, lnki_upright, rv_w, lnki_w, lnki_h, lnki_type); // only v1 calls Calc_xfer_size rv_w = Xof_img_size.Upright_calc(Xof_patch_upright_tid_.Tid_all, lnki_upright, rv_w, lnki_w, lnki_h, lnki_type); // only v1 calls Calc_xfer_size
if (file_w < 1) rv.Val_all_(rv_w, rv_h); if (file_w < 1) rv.Val_all_(rv_w, rv_h);
else Xof_xfer_itm_.Calc_view(rv, lnki_type, rv_w, rv_h, file_w, file_h, thumb_width_must_be_lt_file_width); else Xof_xfer_itm_.Calc_view(rv, lnki_type, rv_w, rv_h, file_w, file_h, thumb_width_must_be_lt_file_width);
} }

View File

@ -46,9 +46,9 @@ public class Xow_file_mgr implements GfoInvkAble {
this.fsdb_mgr = fsdb_mgr; this.fsdb_mgr = fsdb_mgr;
version = Version_2; version = Version_2;
} }
public boolean Patch_upright() { public int Patch_upright() {
return this.Version() == Version_1 return this.Version() == Version_1
? true ? Xof_patch_upright_tid_.Tid_all
: fsdb_mgr.Patch_upright() : fsdb_mgr.Patch_upright()
; ;
} }

View File

@ -30,7 +30,7 @@ public class Xof_fsdb_itm {
public double Lnki_upright() {return lnki_upright;} private double lnki_upright; public double Lnki_upright() {return lnki_upright;} private double lnki_upright;
public double Lnki_thumbtime() {return lnki_thumbtime;} public Xof_fsdb_itm Lnki_thumbtime_(double v) {lnki_thumbtime = v; return this;} private double lnki_thumbtime = Xof_doc_thumb.Null; public double Lnki_thumbtime() {return lnki_thumbtime;} public Xof_fsdb_itm Lnki_thumbtime_(double v) {lnki_thumbtime = v; return this;} private double lnki_thumbtime = Xof_doc_thumb.Null;
public int Lnki_page() {return lnki_page;} public Xof_fsdb_itm Lnki_page_(int v) {lnki_page = v; return this;} private int lnki_page = Xof_doc_page.Null; public int Lnki_page() {return lnki_page;} public Xof_fsdb_itm Lnki_page_(int v) {lnki_page = v; return this;} private int lnki_page = Xof_doc_page.Null;
public Xof_fsdb_itm Init_by_lnki(byte[] lnki_ttl, Xof_ext ext, byte[] md5, byte lnki_type, int lnki_w, int lnki_h, boolean lnki_upright_patch, double lnki_upright, double lnki_thumbtime, int lnki_page) { public Xof_fsdb_itm Init_by_lnki(byte[] lnki_ttl, Xof_ext ext, byte[] md5, byte lnki_type, int lnki_w, int lnki_h, int lnki_upright_patch, double lnki_upright, double lnki_thumbtime, int lnki_page) {
this.lnki_ttl = lnki_ttl; this.lnki_ext = ext; this.lnki_md5 = md5; this.lnki_ttl = lnki_ttl; this.lnki_ext = ext; this.lnki_md5 = md5;
this.lnki_w = lnki_w; this.lnki_h = lnki_h; this.lnki_w = lnki_w; this.lnki_h = lnki_h;
this.lnki_upright_patch = lnki_upright_patch; this.lnki_upright_patch = lnki_upright_patch;
@ -39,7 +39,7 @@ public class Xof_fsdb_itm {
this.orig_ttl = lnki_ttl; this.orig_ttl = lnki_ttl;
return this; return this;
} }
private boolean lnki_upright_patch; private int lnki_upright_patch;
public void Lnki_type_(byte v) { public void Lnki_type_(byte v) {
this.lnki_type = v; this.lnki_type = v;
if (lnki_ext.Id_is_audio_strict()) if (lnki_ext.Id_is_audio_strict())

View File

@ -21,7 +21,7 @@ import gplx.xowa.files.fsdb.caches.*;
import gplx.xowa.files.gui.*; import gplx.xowa.files.gui.*;
public interface Xof_fsdb_mgr extends RlsAble { public interface Xof_fsdb_mgr extends RlsAble {
boolean Tid_is_mem(); boolean Tid_is_mem();
boolean Patch_upright(); int Patch_upright();
Xow_wiki Wiki(); Xow_wiki Wiki();
Xof_qry_mgr Qry_mgr(); Xof_qry_mgr Qry_mgr();
Xof_bin_mgr Bin_mgr(); Xof_bin_mgr Bin_mgr();

View File

@ -18,9 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.files.fsdb; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*; package gplx.xowa.files.fsdb; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
public class Xof_fsdb_mgr_cfg { public class Xof_fsdb_mgr_cfg {
public static final String public static final String
Grp_xowa = "xowa" Grp_xowa = "xowa"
, Key_gallery_fix_defaults = "gallery.fix_defaults" , Key_gallery_fix_defaults = "gallery.fix_defaults"
, Key_gallery_packed = "gallery.packed" , Key_gallery_packed = "gallery.packed"
, Key_upright_patch = "file.upright_ignores_lnki_w" , Key_upright_use_thumb_w = "file.upright_ignores_lnki_w"
, Key_upright_fix_default = "file.upright_fix_default"
; ;
} }

View File

@ -22,7 +22,7 @@ public class Xof_fsdb_mgr_mem implements Xof_fsdb_mgr, Xof_bin_wkr {
private Hash_adp_bry bin_hash = Hash_adp_bry.cs_(); private Bry_bfr bin_key_bfr = Bry_bfr.new_(); private Hash_adp_bry bin_hash = Hash_adp_bry.cs_(); private Bry_bfr bin_key_bfr = Bry_bfr.new_();
private Hash_adp_bry reg_hash = Hash_adp_bry.cs_(); private Hash_adp_bry reg_hash = Hash_adp_bry.cs_();
public boolean Tid_is_mem() {return true;} public boolean Tid_is_mem() {return true;}
public boolean Patch_upright() {return true;} public int Patch_upright() {return Xof_patch_upright_tid_.Tid_all;}
public Xof_qry_mgr Qry_mgr() {return qry_mgr;} private Xof_qry_mgr qry_mgr = new Xof_qry_mgr(); public Xof_qry_mgr Qry_mgr() {return qry_mgr;} private Xof_qry_mgr qry_mgr = new Xof_qry_mgr();
public Xof_bin_mgr Bin_mgr() {return bin_mgr;} private Xof_bin_mgr bin_mgr; public Xof_bin_mgr Bin_mgr() {return bin_mgr;} private Xof_bin_mgr bin_mgr;
public Xof_bin_wkr Bin_wkr_fsdb() {return this;} public Xof_bin_wkr Bin_wkr_fsdb() {return this;}

View File

@ -28,17 +28,20 @@ public class Xof_fsdb_mgr_sql implements Xof_fsdb_mgr, GfoInvkAble {
public Xof_bin_wkr Bin_wkr_fsdb() {return bin_wkr_fsdb;} private Xof_bin_wkr_fsdb_sql bin_wkr_fsdb; public Xof_bin_wkr Bin_wkr_fsdb() {return bin_wkr_fsdb;} private Xof_bin_wkr_fsdb_sql bin_wkr_fsdb;
public void Db_bin_max_(long v) {mnt_mgr.Bin_db_max_(v);} public void Db_bin_max_(long v) {mnt_mgr.Bin_db_max_(v);}
public Fsdb_mnt_mgr Mnt_mgr() {return mnt_mgr;} private Fsdb_mnt_mgr mnt_mgr = new Fsdb_mnt_mgr(); public Fsdb_mnt_mgr Mnt_mgr() {return mnt_mgr;} private Fsdb_mnt_mgr mnt_mgr = new Fsdb_mnt_mgr();
public boolean Patch_upright() { public int Patch_upright() {
if (patch_upright_null) { if (patch_upright_null) {
if (mnt_mgr.Abc_mgr_len() > 0) { if (mnt_mgr.Abc_mgr_len() > 0) {
patch_upright = mnt_mgr.Abc_mgr_at(0).Cfg_mgr().Grps_get_or_load(Xof_fsdb_mgr_cfg.Grp_xowa).Get_yn_or(Xof_fsdb_mgr_cfg.Key_upright_patch, false); Fsdb_cfg_grp cfg_grp = mnt_mgr.Abc_mgr_at(0).Cfg_mgr().Grps_get_or_load(Xof_fsdb_mgr_cfg.Grp_xowa);
boolean use_thumb_w = cfg_grp.Get_yn_or(Xof_fsdb_mgr_cfg.Key_upright_use_thumb_w, Bool_.N);
boolean fix_default = cfg_grp.Get_yn_or(Xof_fsdb_mgr_cfg.Key_upright_fix_default, Bool_.N);
patch_upright_tid = Xof_patch_upright_tid_.Merge(use_thumb_w, fix_default);
} }
else // TEST: no cfg dbs else // TEST: no cfg dbs
patch_upright = true; patch_upright_tid = Xof_patch_upright_tid_.Tid_all;
patch_upright_null = false; patch_upright_null = false;
} }
return patch_upright; return patch_upright_tid;
} private boolean patch_upright_null = true, patch_upright = false; } private boolean patch_upright_null = true; private int patch_upright_tid;
public Io_url Db_dir() {return db_dir;} public Xof_fsdb_mgr_sql Db_dir_(Io_url v) {db_dir = v; mnt_mgr.Init(db_dir); return this;} private Io_url db_dir; public Io_url Db_dir() {return db_dir;} public Xof_fsdb_mgr_sql Db_dir_(Io_url v) {db_dir = v; mnt_mgr.Init(db_dir); return this;} private Io_url db_dir;
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Null; public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Null;
public Cache_mgr Cache_mgr() {return cache_mgr;} private Cache_mgr cache_mgr; public Cache_mgr Cache_mgr() {return cache_mgr;} private Cache_mgr cache_mgr;

View File

@ -29,7 +29,7 @@ public class Fs_root_fsdb_mgr implements Xof_fsdb_mgr, GfoInvkAble {
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} private Gfo_usr_dlg usr_dlg; public Gfo_usr_dlg Usr_dlg() {return usr_dlg;} private Gfo_usr_dlg usr_dlg;
public Cache_mgr Cache_mgr() {throw Err_.not_implemented_();} public Cache_mgr Cache_mgr() {throw Err_.not_implemented_();}
public void Db_bin_max_(long v) {throw Err_.not_implemented_();} public void Db_bin_max_(long v) {throw Err_.not_implemented_();}
public boolean Patch_upright() {return true;} public int Patch_upright() {return Xof_patch_upright_tid_.Tid_all;}
public Fsdb_mnt_mgr Mnt_mgr() {throw Err_.not_implemented_();} public Fsdb_mnt_mgr Mnt_mgr() {throw Err_.not_implemented_();}
public void Img_insert(Fsdb_xtn_img_itm rv, byte[] dir, byte[] fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {throw Err_.not_implemented_();} public void Img_insert(Fsdb_xtn_img_itm rv, byte[] dir, byte[] fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {throw Err_.not_implemented_();}
public void Thm_insert(Fsdb_xtn_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int thm_w, int thm_h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {throw Err_.not_implemented_();} public void Thm_insert(Fsdb_xtn_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int thm_w, int thm_h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {throw Err_.not_implemented_();}

View File

@ -37,7 +37,7 @@ public class Fs_root_wkr_fsdb {
} }
else { else {
String thumb_rel = orig_url.GenRelUrl_orEmpty(orig_dir); String thumb_rel = orig_url.GenRelUrl_orEmpty(orig_dir);
boolean upright_patch = wiki.File_mgr().Fsdb_mgr().Patch_upright(); int upright_patch = wiki.File_mgr().Fsdb_mgr().Patch_upright();
img_size.Html_size_calc(exec_tid, fsdb_itm.Lnki_w(), fsdb_itm.Lnki_h(), fsdb_itm.Lnki_type(), upright_patch, fsdb_itm.Lnki_upright(), fsdb_itm.Lnki_ext().Id(), orig_itm.Fil_w(), orig_itm.Fil_h(), Xof_img_size.Thumb_width_img); img_size.Html_size_calc(exec_tid, fsdb_itm.Lnki_w(), fsdb_itm.Lnki_h(), fsdb_itm.Lnki_type(), upright_patch, fsdb_itm.Lnki_upright(), fsdb_itm.Lnki_ext().Id(), orig_itm.Fil_w(), orig_itm.Fil_h(), Xof_img_size.Thumb_width_img);
int html_w = img_size.Html_w(), html_h = img_size.Html_h(); int html_w = img_size.Html_w(), html_h = img_size.Html_h();
String thumb_name = Int_.XtoStr(html_w) + orig_url.Ext(); String thumb_name = Int_.XtoStr(html_w) + orig_url.Ext();

View File

@ -96,7 +96,7 @@ class Xof_file_fxt {
byte[] ttl_bry = Bry_.new_ascii_(ttl_str); byte[] ttl_bry = Bry_.new_ascii_(ttl_str);
byte[] md5 = Xof_xfer_itm_.Md5_(ttl_bry); byte[] md5 = Xof_xfer_itm_.Md5_(ttl_bry);
Xof_ext ext = Xof_ext_.new_by_ttl_(ttl_bry); Xof_ext ext = Xof_ext_.new_by_ttl_(ttl_bry);
return new Xof_fsdb_itm().Init_by_lnki(ttl_bry, ext, md5, type, w, h, true, upright, thumbtime, Xof_doc_page.Null); return new Xof_fsdb_itm().Init_by_lnki(ttl_bry, ext, md5, type, w, h, Xof_patch_upright_tid_.Tid_all, upright, thumbtime, Xof_doc_page.Null);
} }
public void Test_itm_ext(Xof_fsdb_itm itm, int expd_ext_id) {Tfds.Eq(expd_ext_id, itm.Lnki_ext().Id());} public void Test_itm_ext(Xof_fsdb_itm itm, int expd_ext_id) {Tfds.Eq(expd_ext_id, itm.Lnki_ext().Id());}
public void Rls() {fsdb_mgr.Rls();} public void Rls() {fsdb_mgr.Rls();}

View File

@ -71,7 +71,7 @@ public class Xof_offline_png_tst {
if (fxt.Db_skip()) return; if (fxt.Db_skip()) return;
fxt.Init_qry_xowa(Xof_fsdb_arg_init_qry.new_().Init_commons("A.png", 1378, 1829)); fxt.Init_qry_xowa(Xof_fsdb_arg_init_qry.new_().Init_commons("A.png", 1378, 1829));
fxt.Init_bin_fsdb(Xof_fsdb_arg_init_bin.new_().Init_commons_thumb("A.png", 170, 226)); fxt.Init_bin_fsdb(Xof_fsdb_arg_init_bin.new_().Init_commons_thumb("A.png", 170, 226));
fxt.Exec_get(Xof_fsdb_arg_exec_get.new_().Init_thumb("A.png", Xop_lnki_tkn.Width_null, Xop_lnki_tkn.Height_null).Lnki_upright_(Xof_img_size.Upright_default)); fxt.Exec_get(Xof_fsdb_arg_exec_get.new_().Init_thumb("A.png", Xop_lnki_tkn.Width_null, Xop_lnki_tkn.Height_null).Lnki_upright_(Xof_img_size.Upright_default_marker));
fxt.Test_fsys("mem/root/common/thumb/7/0/A.png/170px.png", "170,226"); fxt.Test_fsys("mem/root/common/thumb/7/0/A.png/170px.png", "170,226");
} }
} }

View File

@ -32,7 +32,7 @@ public class Js_img_mgr {
if (Env_.Mode_testing()) return; if (Env_.Mode_testing()) return;
Xog_html_itm html_itm = page.Tab().Html_itm(); Xog_html_itm html_itm = page.Tab().Html_itm();
if (elem_tid == Xof_html_elem.Tid_gallery_v2) { if (elem_tid == Xof_html_elem.Tid_gallery_v2) {
img_wkr.Html_update(html_itm, w, h, view_src, orig_src); img_wkr.Html_update(page, html_itm, w, h, view_src, orig_src);
return; return;
} }
String html_id = "xowa_file_img_" + uid; String html_id = "xowa_file_img_" + uid;

View File

@ -18,5 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.files.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*; package gplx.xowa.files.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
import gplx.xowa.gui.views.*; import gplx.xowa.gui.views.*;
public interface Js_img_wkr { public interface Js_img_wkr {
void Html_update(Xog_html_itm html_itm, int w, int h, String view_src, String orig_src); void Html_update(Xoa_page page, Xog_html_itm html_itm, int w, int h, String view_src, String orig_src);
} }

View File

@ -32,13 +32,15 @@ public class Xof_wiki_orig_cmd extends Xob_itm_basic_base implements Xob_cmd {
public void Cmd_end() {} public void Cmd_end() {}
public void Cmd_print() {} public void Cmd_print() {}
private void Exec() { private void Exec() {
usr_dlg.Prog_many("", "", "deleting wiki_orig"); provider.Exec_sql(Sql_delete_wiki_orig); // always delete wiki_orig, else will not pick up changed sizes / moved repos; DATE:2014-07-21
usr_dlg.Prog_many("", "", "inserting xfer direct"); provider.Exec_sql(Sql_create_xfer_direct); usr_dlg.Prog_many("", "", "inserting xfer direct"); provider.Exec_sql(Sql_create_xfer_direct);
usr_dlg.Prog_many("", "", "inserting xfer redirect"); provider.Exec_sql(Sql_create_xfer_redirect); usr_dlg.Prog_many("", "", "inserting xfer redirect"); provider.Exec_sql(Sql_create_xfer_redirect);
usr_dlg.Prog_many("", "", "inserting orig direct"); provider.Exec_sql(Sql_create_orig_direct); usr_dlg.Prog_many("", "", "inserting orig direct"); provider.Exec_sql(Sql_create_orig_direct);
usr_dlg.Prog_many("", "", "inserting orig redirect"); provider.Exec_sql(Sql_create_orig_redirect); usr_dlg.Prog_many("", "", "inserting orig redirect"); provider.Exec_sql(Sql_create_orig_redirect);
} }
private static final String private static final String
Sql_create_xfer_direct = String_.Concat_lines_nl Sql_delete_wiki_orig = "DELETE FROM wiki_orig;"
, Sql_create_xfer_direct = String_.Concat_lines_nl
( "INSERT INTO wiki_orig " ( "INSERT INTO wiki_orig "
, "(orig_ttl, status, orig_repo, orig_ext, orig_w, orig_h, orig_redirect)" , "(orig_ttl, status, orig_repo, orig_ext, orig_w, orig_h, orig_redirect)"
, "SELECT DISTINCT" , "SELECT DISTINCT"

View File

@ -65,7 +65,6 @@ public class Xoa_gui_mgr implements GfoInvkAble {
app.Api_root().Init_by_kit(app); app.Api_root().Init_by_kit(app);
menu_mgr.Menu_bldr().Init_by_kit(app, kit, app.User().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "menu")); menu_mgr.Menu_bldr().Init_by_kit(app, kit, app.User().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "menu"));
menu_mgr.Init_by_kit(); menu_mgr.Init_by_kit();
browser_win.Tab_mgr().Tabs_new_init();
bnd_mgr.Init_by_kit(app); bnd_mgr.Init_by_kit(app);
} }
public void Lang_changed(Xol_lang lang) { public void Lang_changed(Xol_lang lang) {

View File

@ -76,7 +76,7 @@ public class Xog_url_wkr {
if (!Io_mgr._.ExistsFil(href_url)) { if (!Io_mgr._.ExistsFil(href_url)) {
Xof_xfer_itm xfer_itm = new Xof_xfer_itm(); Xof_xfer_itm xfer_itm = new Xof_xfer_itm();
byte[] title = app.Encoder_mgr().Url().Decode(Bry_.new_utf8_(xowa_ttl)); byte[] title = app.Encoder_mgr().Url().Decode(Bry_.new_utf8_(xowa_ttl));
xfer_itm.Atrs_by_lnki(Xop_lnki_type.Id_none, -1, -1, -1, Xof_doc_thumb.Null, Xof_doc_page.Null).Atrs_by_ttl(title, Bry_.Empty); xfer_itm.Init_by_lnki(title, Bry_.Empty, Xop_lnki_type.Id_none, -1, -1, -1, Xof_doc_thumb.Null, Xof_doc_page.Null);
page.Wiki().File_mgr().Find_meta(xfer_itm); page.Wiki().File_mgr().Find_meta(xfer_itm);
page.File_queue().Clear(); page.File_queue().Clear();
page.File_queue().Add(xfer_itm); // NOTE: set elem_id to "impossible" number, otherwise it will auto-update an image on the page with a super-large size; [[File:Alfred Sisley 062.jpg]] page.File_queue().Add(xfer_itm); // NOTE: set elem_id to "impossible" number, otherwise it will auto-update an image on the page with a super-large size; [[File:Alfred Sisley 062.jpg]]

View File

@ -77,7 +77,8 @@ public class Xog_html_js_cbk implements GfoInvkAble {
try { try {
int popups_id = Int_.Xby_double_(Double_.cast_(m.Args_getAt(0).Val())); int popups_id = Int_.Xby_double_(Double_.cast_(m.Args_getAt(0).Val()));
byte[] href_bry = m.Args_getAt(1).Val_to_bry(); byte[] href_bry = m.Args_getAt(1).Val_to_bry();
return html_itm.Owner_tab().Page().Wiki().Html_mgr().Module_mgr().Popup_mgr().Show_init(href_bry, popups_id); byte[] tooltip_bry = m.Args_getAt(2).Val_to_bry();
return html_itm.Owner_tab().Page().Wiki().Html_mgr().Module_mgr().Popup_mgr().Show_init(popups_id, href_bry, tooltip_bry);
} catch (Exception e) {Err_.Noop(e); return null;} } catch (Exception e) {Err_.Noop(e); return null;}
} }
private String[] Get_title_meta(Xow_wiki wiki, byte[] ttl_bry) { private String[] Get_title_meta(Xow_wiki wiki, byte[] ttl_bry) {

View File

@ -33,13 +33,12 @@ class Xog_launcher_tabs {
app.Gui_wtr().Log_wtr().Log_msg_to_session_direct(log_bfr.Xto_str()); app.Gui_wtr().Log_wtr().Log_msg_to_session_direct(log_bfr.Xto_str());
} }
private boolean Restore_tabs(Xoa_app app, Xow_wiki home_wiki, Xog_win_itm win, Io_fil_marker fil_marker) { private boolean Restore_tabs(Xoa_app app, Xow_wiki home_wiki, Xog_win_itm win, Io_fil_marker fil_marker) {
Xog_tab_itm tab = win.Active_tab(); String[] launch_urls = app.Api_root().App().Startup().Tabs().Calc_startup_strs(app);
String[] launch_urls = app.Api_root().App().Startup().Tabs().Calc_startup_strs();
try { try {
int launch_urls_len = launch_urls.length; int launch_urls_len = launch_urls.length;
for (int i = 0; i < launch_urls_len; ++i) { for (int i = 0; i < launch_urls_len; ++i) {
String launch_url = launch_urls[i]; String launch_url = launch_urls[i];
tab = i == 0 ? win.Active_tab() : win.Tab_mgr().Tabs_new_init(); Xog_tab_itm tab = win.Tab_mgr().Tabs_new_init();
Launch_tab(tab, win, home_wiki, launch_url); Launch_tab(tab, win, home_wiki, launch_url);
} }
fil_marker.End(); fil_marker.End();
@ -55,18 +54,11 @@ class Xog_launcher_tabs {
Launch_tab(win.Active_tab(), win, home_wiki, gplx.xowa.users.Xouc_pages_mgr.Page_xowa); Launch_tab(win.Active_tab(), win, home_wiki, gplx.xowa.users.Xouc_pages_mgr.Page_xowa);
} }
private void Launch_tab(Xog_tab_itm tab, Xog_win_itm win, Xow_wiki home_wiki, String launch_str) { private void Launch_tab(Xog_tab_itm tab, Xog_win_itm win, Xow_wiki home_wiki, String launch_str) {
Xoa_page launch_page = Launch_page(win, home_wiki, launch_str);
if (launch_page.Missing()) return;
Xog_tab_itm_read_mgr.Show_page(tab, launch_page, false);
tab.History_mgr().Add(launch_page);
}
private Xoa_page Launch_page(Xog_win_itm win, Xow_wiki home_wiki, String launch_str) {
Xoa_url launch_url = Xoa_url_parser.Parse_from_url_bar(win.App(), home_wiki, launch_str); Xoa_url launch_url = Xoa_url_parser.Parse_from_url_bar(win.App(), home_wiki, launch_str);
Xow_wiki launch_wiki = launch_url.Wiki(); Xow_wiki launch_wiki = launch_url.Wiki();
Xoa_ttl launch_ttl = Xoa_ttl.parse_(launch_wiki, launch_url.Page_bry()); Xoa_ttl launch_ttl = Xoa_ttl.parse_(launch_wiki, launch_url.Page_bry());
Xoa_page rv = launch_wiki.GetPageByTtl(launch_url, launch_ttl).Url_(launch_url); // FUTURE: .Url_() should not be called (needed for anchor); EX: en.wikipedia.org/Earth#Biosphere tab.Page_(Xoa_page.new_(launch_wiki, launch_ttl)); // WORKAROUND: set the tab to an empty page, else null ref later; DATE:2014-07-23
win.Active_page_(rv); // set to blank page tab.Show_url_bgn(launch_url);
return rv;
} }
public static final Xog_launcher_tabs _ = new Xog_launcher_tabs(); Xog_launcher_tabs() {} public static final Xog_launcher_tabs _ = new Xog_launcher_tabs(); Xog_launcher_tabs() {}
} }

View File

@ -174,7 +174,11 @@ public class Xog_tab_itm implements GfoInvkAble {
String page_ttl_str = String_.new_utf8_(page.Ttl().Raw()); String page_ttl_str = String_.new_utf8_(page.Ttl().Raw());
if (xfer_len > 0){ if (xfer_len > 0){
usr_dlg.Prog_one("", "", "downloading images: ~{0}", xfer_len); usr_dlg.Prog_one("", "", "downloading images: ~{0}", xfer_len);
try {page.File_queue().Exec(gplx.xowa.files.Xof_exec_tid.Tid_wiki_page, usr_dlg, wiki, page);} try {
page.File_queue().Exec(gplx.xowa.files.Xof_exec_tid.Tid_wiki_page, usr_dlg, wiki, page);
if (page.Html_data().Gallery_packed_exists()) // packed_gallery exists; fire js once; PAGE:en.w:National_Sculpture_Museum_(Valladolid); DATE:2014-07-21
html_itm.Html_gallery_packed_exec();
}
catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.image: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_brief(e));} catch (Exception e) {usr_dlg.Warn_many("", "", "page.thread.image: page=~{0} err=~{1}", page_ttl_str, Err_.Message_gplx_brief(e));}
} }
xfer_len = page.File_math().Count(); xfer_len = page.File_math().Count();

View File

@ -33,11 +33,9 @@ public class Xog_tab_itm_read_mgr {
win.Usr_dlg().Prog_none("", "", "locating images"); win.Usr_dlg().Prog_none("", "", "locating images");
try {tab.Html_itm().Show(new_page);} try {tab.Html_itm().Show(new_page);}
catch (Exception e) { catch (Exception e) {
if (String_.Eq(Err_.Message_lang(e), "class org.eclipse.swt.SWTException Widget is disposed")) return; // ignore errors caused by user closing tab early; DATE:2014-07-26
if (show_is_err) { // trying to show error page, but failed; don't show again, else recursion until out of memory; TODO:always load error page; no reason it should fail; WHEN:html_skin; DATE:2014-06-08 if (show_is_err) { // trying to show error page, but failed; don't show again, else recursion until out of memory; TODO:always load error page; no reason it should fail; WHEN:html_skin; DATE:2014-06-08
String new_page_url = new_page.Url().Xto_full_str_safe(); app.Usr_dlg().Warn_many("", "", "fatal error trying to load error page; page=~{0} err=~{1}" + new_page.Url().Xto_full_str_safe(), Err_.Message_gplx(e));
String err_msg = "fatal error trying to load error page; page=" + new_page_url;
app.Usr_dlg().Warn_many("", "", err_msg);
app.Gui_mgr().Kit().Ask_ok("", "", err_msg);
return; return;
} }
else else

View File

@ -17,30 +17,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html; import gplx.*; import gplx.xowa.*; package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
public class Xoh_consts { public class Xoh_consts {
// public static final String Comm_bgn_str = "<!--";
public static final byte[] public static final byte[]
__end = Bry_.new_ascii_(">") __end = Bry_.new_ascii_(">")
, __end_quote = Bry_.new_ascii_("\">") , __end_quote = Bry_.new_ascii_("\">")
, __inline_quote = Bry_.new_ascii_("\"/>") , __inline_quote = Bry_.new_ascii_("\"/>")
, Space_2 = Bry_.new_ascii_(" ") , Space_2 = Bry_.new_ascii_(" ")
// , Comm_bgn = Bry_.new_ascii_(Comm_bgn_str)
// , Comm_end = Bry_.new_ascii_("-->")
, Br = Bry_.new_ascii_("<br/>")
, B_bgn = Bry_.new_ascii_("<b>"), B_end = Bry_.new_ascii_("</b>")
, I_bgn = Bry_.new_ascii_("<i>"), I_end = Bry_.new_ascii_("</i>")
, P_bgn = Bry_.new_ascii_("<p>"), P_end = Bry_.new_ascii_("</p>")
, A_bgn = Bry_.new_ascii_("<a href=\""), A_bgn_lnki_0 = Bry_.new_ascii_("\" title=\""), A_mid_xowa_title = Bry_.new_ascii_("\" xowa_title=\"") , A_bgn = Bry_.new_ascii_("<a href=\""), A_bgn_lnki_0 = Bry_.new_ascii_("\" title=\""), A_mid_xowa_title = Bry_.new_ascii_("\" xowa_title=\"")
, A_mid_id = Bry_.new_ascii_("\" id=\"xowa_lnki_") , A_mid_id = Bry_.new_ascii_("\" id=\"xowa_lnki_")
, A_bgn_lnke_0 = Bry_.new_ascii_("\" class=\"external text\" rel=\"nofollow\">")
, A_bgn_lnke_0_xowa = Bry_.new_ascii_("\">")
, A_end = Bry_.new_ascii_("</a>") , A_end = Bry_.new_ascii_("</a>")
, Div_bgn_open = Bry_.new_ascii_("<div ") , Div_bgn_open = Bry_.new_ascii_("<div ")
, Div_end = Bry_.new_ascii_("</div>") , Div_end = Bry_.new_ascii_("</div>")
, Img_bgn = Bry_.new_ascii_("<img src=\"") , Img_bgn = Bry_.new_ascii_("<img src=\"")
, Span_bgn_open = Bry_.new_ascii_("<span") , Span_bgn_open = Bry_.new_ascii_("<span")
, Span_end = Bry_.new_ascii_("</span>") , Span_end = Bry_.new_ascii_("</span>")
, Span_bgn = Bry_.new_ascii_("<span>") , Span_bgn = Bry_.new_ascii_("<span>")

View File

@ -17,21 +17,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html; import gplx.*; import gplx.xowa.*; package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.net.*; import gplx.core.btries.*; import gplx.html.*; import gplx.xowa.wikis.*; import gplx.xowa.net.*;
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.lnkes.*; import gplx.xowa.parsers.hdrs.*; import gplx.xowa.parsers.lists.*;
import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.dynamicPageList.*; import gplx.xowa.xtns.math.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.xtns.cite.*;
public class Xoh_html_wtr { public class Xoh_html_wtr {
private Xow_wiki wiki; private Xoa_app app; private Xoa_page page; private Xop_xatr_whitelist_mgr whitelist_mgr; private Xow_wiki wiki; private Xoa_app app; private Xoa_page page; private Xop_xatr_whitelist_mgr whitelist_mgr;
public Xoh_html_wtr(Xow_wiki wiki, Xow_html_mgr html_mgr) { public Xoh_html_wtr(Xow_wiki wiki, Xow_html_mgr html_mgr) {
this.wiki = wiki; this.app = wiki.App(); this.whitelist_mgr = app.Html_mgr().Whitelist_mgr(); this.wiki = wiki; this.app = wiki.App(); this.whitelist_mgr = app.Html_mgr().Whitelist_mgr();
this.html_mgr = html_mgr;
lnki_wtr = new Xoh_lnki_wtr(this, wiki, html_mgr, cfg); lnki_wtr = new Xoh_lnki_wtr(this, wiki, html_mgr, cfg);
ref_wtr = new Ref_html_wtr(wiki); ref_wtr = new Ref_html_wtr(wiki);
lnke_wtr = new Xoh_lnke_wtr(wiki);
} }
public void Init_by_wiki(Xow_wiki wiki) { public void Init_by_wiki(Xow_wiki wiki) {
cfg.Toc_show_(true).Lnki_title_(true).Lnki_visited_(true).Lnki_id_(true); // NOTE: set during Init_by_wiki, b/c all tests assume these are false cfg.Toc_show_(true).Lnki_title_(true).Lnki_visited_(true).Lnki_id_(true); // NOTE: set during Init_by_wiki, b/c all tests assume these are false
ref_wtr.Init_by_wiki(wiki); ref_wtr.Init_by_wiki(wiki);
} }
public Xow_html_mgr Html_mgr() {return html_mgr;} private Xow_html_mgr html_mgr;
public Xoh_html_wtr_cfg Cfg() {return cfg;} private Xoh_html_wtr_cfg cfg = new Xoh_html_wtr_cfg(); public Xoh_html_wtr_cfg Cfg() {return cfg;} private Xoh_html_wtr_cfg cfg = new Xoh_html_wtr_cfg();
public Xoh_lnki_wtr Lnki_wtr() {return lnki_wtr;} private Xoh_lnki_wtr lnki_wtr; public Xoh_lnki_wtr Lnki_wtr() {return lnki_wtr;} private Xoh_lnki_wtr lnki_wtr;
public Xoh_lnke_wtr Lnke_wtr() {return lnke_wtr;} private Xoh_lnke_wtr lnke_wtr;
public Ref_html_wtr Ref_wtr() {return ref_wtr;} private Ref_html_wtr ref_wtr; public Ref_html_wtr Ref_wtr() {return ref_wtr;} private Ref_html_wtr ref_wtr;
public void Init_by_page(Xop_ctx ctx, Xoa_page page) {this.page = page; lnki_wtr.Init_by_page(ctx, page);} public void Init_by_page(Xop_ctx ctx, Xoa_page page) {this.page = page; lnki_wtr.Init_by_page(ctx, page);}
public void Write_all(Bry_bfr bfr, Xop_ctx ctx, byte[] src, Xop_root_tkn root) {Write_all(bfr, ctx, Xoh_html_wtr_ctx.Basic, src, root);} public void Write_all(Bry_bfr bfr, Xop_ctx ctx, byte[] src, Xop_root_tkn root) {Write_all(bfr, ctx, Xoh_html_wtr_ctx.Basic, src, root);}
@ -68,7 +72,7 @@ public class Xoh_html_wtr {
case Xop_tkn_itm_.Tid_hr: Hr(ctx, hctx, bfr, src, (Xop_hr_tkn)tkn); break; case Xop_tkn_itm_.Tid_hr: Hr(ctx, hctx, bfr, src, (Xop_hr_tkn)tkn); break;
case Xop_tkn_itm_.Tid_hdr: Hdr(ctx, hctx, bfr, src, (Xop_hdr_tkn)tkn); break; case Xop_tkn_itm_.Tid_hdr: Hdr(ctx, hctx, bfr, src, (Xop_hdr_tkn)tkn); break;
case Xop_tkn_itm_.Tid_apos: Apos(ctx, hctx, bfr, src, (Xop_apos_tkn)tkn); break; case Xop_tkn_itm_.Tid_apos: Apos(ctx, hctx, bfr, src, (Xop_apos_tkn)tkn); break;
case Xop_tkn_itm_.Tid_lnke: Lnke(ctx, hctx, bfr, src, (Xop_lnke_tkn)tkn); break; case Xop_tkn_itm_.Tid_lnke: lnke_wtr.Write_all(bfr, this, hctx, ctx, src, (Xop_lnke_tkn)tkn); break;
case Xop_tkn_itm_.Tid_lnki: lnki_wtr.Write(bfr, hctx, src, (Xop_lnki_tkn)tkn); break; case Xop_tkn_itm_.Tid_lnki: lnki_wtr.Write(bfr, hctx, src, (Xop_lnki_tkn)tkn); break;
case Xop_tkn_itm_.Tid_list: List(ctx, hctx, bfr, src, (Xop_list_tkn)tkn); break; case Xop_tkn_itm_.Tid_list: List(ctx, hctx, bfr, src, (Xop_list_tkn)tkn); break;
case Xop_tkn_itm_.Tid_xnde: Xnde(ctx, hctx, bfr, src, (Xop_xnde_tkn)tkn); break; case Xop_tkn_itm_.Tid_xnde: Xnde(ctx, hctx, bfr, src, (Xop_xnde_tkn)tkn); break;
@ -134,66 +138,22 @@ public class Xoh_html_wtr {
if (literal_apos > 0) if (literal_apos > 0)
bfr.Add_byte_repeat(Byte_ascii.Apos, literal_apos); bfr.Add_byte_repeat(Byte_ascii.Apos, literal_apos);
switch (apos.Apos_cmd()) { switch (apos.Apos_cmd()) {
case Xop_apos_tkn_.Cmd_b_bgn: bfr.Add(Xoh_consts.B_bgn); break; case Xop_apos_tkn_.Cmd_b_bgn: bfr.Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_b_end: bfr.Add(Xoh_consts.B_end); break; case Xop_apos_tkn_.Cmd_b_end: bfr.Add(Html_tag_.B_rhs); break;
case Xop_apos_tkn_.Cmd_i_bgn: bfr.Add(Xoh_consts.I_bgn); break; case Xop_apos_tkn_.Cmd_i_bgn: bfr.Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_i_end: bfr.Add(Xoh_consts.I_end); break; case Xop_apos_tkn_.Cmd_i_end: bfr.Add(Html_tag_.I_rhs); break;
case Xop_apos_tkn_.Cmd_bi_bgn: bfr.Add(Xoh_consts.B_bgn).Add(Xoh_consts.I_bgn); break; case Xop_apos_tkn_.Cmd_bi_bgn: bfr.Add(Html_tag_.B_lhs).Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_ib_end: bfr.Add(Xoh_consts.I_end).Add(Xoh_consts.B_end); break; case Xop_apos_tkn_.Cmd_ib_end: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_rhs); break;
case Xop_apos_tkn_.Cmd_ib_bgn: bfr.Add(Xoh_consts.I_bgn).Add(Xoh_consts.B_bgn); break; case Xop_apos_tkn_.Cmd_ib_bgn: bfr.Add(Html_tag_.I_lhs).Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_bi_end: bfr.Add(Xoh_consts.B_end).Add(Xoh_consts.I_end);; break; case Xop_apos_tkn_.Cmd_bi_end: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_rhs);; break;
case Xop_apos_tkn_.Cmd_bi_end__b_bgn: bfr.Add(Xoh_consts.B_end).Add(Xoh_consts.I_end).Add(Xoh_consts.B_bgn); break; case Xop_apos_tkn_.Cmd_bi_end__b_bgn: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_rhs).Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_ib_end__i_bgn: bfr.Add(Xoh_consts.I_end).Add(Xoh_consts.B_end).Add(Xoh_consts.I_bgn); break; case Xop_apos_tkn_.Cmd_ib_end__i_bgn: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_rhs).Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_b_end__i_bgn: bfr.Add(Xoh_consts.B_end).Add(Xoh_consts.I_bgn); break; case Xop_apos_tkn_.Cmd_b_end__i_bgn: bfr.Add(Html_tag_.B_rhs).Add(Html_tag_.I_lhs); break;
case Xop_apos_tkn_.Cmd_i_end__b_bgn: bfr.Add(Xoh_consts.I_end).Add(Xoh_consts.B_bgn); break; case Xop_apos_tkn_.Cmd_i_end__b_bgn: bfr.Add(Html_tag_.I_rhs).Add(Html_tag_.B_lhs); break;
case Xop_apos_tkn_.Cmd_nil: break; case Xop_apos_tkn_.Cmd_nil: break;
default: throw Err_.unhandled(apos.Apos_cmd()); default: throw Err_.unhandled(apos.Apos_cmd());
} }
} }
private void Lnke(Xop_ctx ctx, Xoh_html_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_lnke_tkn lnke) {
int lnke_bgn = lnke.Lnke_bgn(), lnke_end = lnke.Lnke_end();
byte[] lnke_xwiki_wiki = lnke.Lnke_xwiki_wiki();
boolean proto_is_xowa = lnke.Proto_tid() == Xoo_protocol_itm.Tid_xowa;
if (!hctx.Mode_is_alt()) {
if (lnke_xwiki_wiki == null) {
if (lnke.Lnke_relative()) // relative; EX: //a.org
bfr.Add(Xoh_consts.A_bgn).Add(app.Url_parser().Url_parser().Relative_url_protocol_bry()).Add_mid(src, lnke_bgn, lnke_end).Add(Xoh_consts.A_bgn_lnke_0);
else { // xowa or regular; EX: http://a.org
if (proto_is_xowa) {
bfr.Add(Xoh_consts.A_bgn).Add(Xop_lnke_wkr.Bry_xowa_protocol);
ctx.App().Encoder_mgr().Gfs().Encode(bfr, src, lnke_bgn, lnke_end);
bfr.Add(Xoh_consts.A_bgn_lnke_0_xowa);
}
else // regular; add href
bfr.Add(Xoh_consts.A_bgn).Add_mid(src, lnke_bgn, lnke_end).Add(Xoh_consts.A_bgn_lnke_0);
}
}
else { // xwiki
Url_encoder href_encoder = ctx.App().Encoder_mgr().Href_quotes();
bfr.Add(Xoh_consts.A_bgn).Add(Xoh_href_parser.Href_site_bry).Add(lnke_xwiki_wiki).Add(Xoh_href_parser.Href_wiki_bry)
.Add(href_encoder.Encode(lnke.Lnke_xwiki_page())); // NOTE: must encode page; EX:%22%3D -> '">' which will end attribute; PAGE:en.w:List_of_Category_A_listed_buildings_in_West_Lothian DATE:2014-07-15
if (lnke.Lnke_xwiki_qargs() != null)
Xoa_url_arg_hash.Concat_bfr(bfr, href_encoder, lnke.Lnke_xwiki_qargs()); // NOTE: must encode args
bfr.Add(Xoh_consts.__end_quote);
}
}
int subs_len = lnke.Subs_len();
if (subs_len == 0) { // no text; auto-number; EX: "[1]"
if (lnke.Lnke_typ() == Xop_lnke_tkn.Lnke_typ_text)
bfr.Add_mid(src, lnke.Lnke_bgn(), lnke.Lnke_end());
else
bfr.Add_byte(Byte_ascii.Brack_bgn).Add_int_variable(page.Html_data().Lnke_autonumber_next()).Add_byte(Byte_ascii.Brack_end);
}
else { // text available
for (int i = 0; i < subs_len; i++)
Write_tkn(bfr, ctx, hctx, src, lnke, i, lnke.Subs_get(i));
}
if (!hctx.Mode_is_alt()) {
if (proto_is_xowa) // add <img />
bfr.Add(Xoh_consts.Img_bgn).Add(wiki.Html_mgr().Img_xowa_protocol()).Add(Xoh_consts.__inline_quote);
bfr.Add(Xoh_consts.A_end);
}
}
public static byte[] Ttl_to_title(byte[] ttl) {return ttl;} // FUTURE: swap html chars? public static byte[] Ttl_to_title(byte[] ttl) {return ttl;} // FUTURE: swap html chars?
public void List(Xop_ctx ctx, Xoh_html_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_list_tkn list) { public void List(Xop_ctx ctx, Xoh_html_wtr_ctx hctx, Bry_bfr bfr, byte[] src, Xop_list_tkn list) {
if (hctx.Mode_is_alt()) { // alt; add literally; EX: "*" for "\n*"; note that \n is added in NewLine() if (hctx.Mode_is_alt()) { // alt; add literally; EX: "*" for "\n*"; note that \n is added in NewLine()
@ -373,16 +333,8 @@ public class Xoh_html_wtr {
case Xop_xnde_tag_.Tid_table: case Xop_xnde_tag_.Tid_tr: case Xop_xnde_tag_.Tid_td: case Xop_xnde_tag_.Tid_th: case Xop_xnde_tag_.Tid_caption: case Xop_xnde_tag_.Tid_tbody: case Xop_xnde_tag_.Tid_table: case Xop_xnde_tag_.Tid_tr: case Xop_xnde_tag_.Tid_td: case Xop_xnde_tag_.Tid_th: case Xop_xnde_tag_.Tid_caption: case Xop_xnde_tag_.Tid_tbody:
case Xop_xnde_tag_.Tid_ruby: case Xop_xnde_tag_.Tid_rt: case Xop_xnde_tag_.Tid_rb: case Xop_xnde_tag_.Tid_rp: case Xop_xnde_tag_.Tid_ruby: case Xop_xnde_tag_.Tid_rt: case Xop_xnde_tag_.Tid_rb: case Xop_xnde_tag_.Tid_rp:
case Xop_xnde_tag_.Tid_time: case Xop_xnde_tag_.Tid_bdi: case Xop_xnde_tag_.Tid_data: case Xop_xnde_tag_.Tid_mark: case Xop_xnde_tag_.Tid_wbr: case Xop_xnde_tag_.Tid_bdo: // HTML 5: write literally and let browser handle them case Xop_xnde_tag_.Tid_time: case Xop_xnde_tag_.Tid_bdi: case Xop_xnde_tag_.Tid_data: case Xop_xnde_tag_.Tid_mark: case Xop_xnde_tag_.Tid_wbr: case Xop_xnde_tag_.Tid_bdo: // HTML 5: write literally and let browser handle them
{
// byte[] name = tag.Name_bry();
// bfr.Add_byte(Tag__bgn).Add(name);
// if (xnde.Atrs_bgn() > Xop_tblw_wkr.Atrs_ignore_check) Xnde_atrs(tag_id, hctx, src, xnde.Atrs_bgn(), xnde.Atrs_end(), xnde.Atrs_ary(), bfr);
// bfr.Add_byte(Tag__end);
// Xnde_subs(hctx, bfr, src, xnde, depth); // NOTE: do not escape; <p>, <table> etc may have nested nodes
// bfr.Add(Tag__end_bgn).Add(name).Add_byte(Tag__end); // NOTE: inline is never written as <b/>; will be written as <b></b>; SEE: NOTE_1
Write_xnde(bfr, ctx, hctx, xnde, tag, tag_id, src); Write_xnde(bfr, ctx, hctx, xnde, tag, tag_id, src);
break; break;
}
case Xop_xnde_tag_.Tid_pre: { case Xop_xnde_tag_.Tid_pre: {
if (xnde.Tag_open_end() == xnde.Tag_close_bgn()) return; // ignore empty tags, else blank pre line will be printed; DATE:2014-03-12 if (xnde.Tag_open_end() == xnde.Tag_close_bgn()) return; // ignore empty tags, else blank pre line will be printed; DATE:2014-03-12
byte[] name = tag.Name_bry(); byte[] name = tag.Name_bry();

View File

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html; import gplx.*; import gplx.xowa.*; package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
import org.junit.*; import org.junit.*;
public class Xoh_html_wtr_tst { public class Xoh_html_wtr_tst {
private Xop_fxt fxt = new Xop_fxt(); private Xop_fxt fxt = new Xop_fxt();
@After public void term() {fxt.Init_para_n_(); fxt.Reset();} @After public void term() {fxt.Init_para_n_(); fxt.Reset();}
@Test public void Hr_basic() {fxt.Test_parse_page_wiki_str("----" , "<hr/>");} @Test public void Hr_basic() {fxt.Test_parse_page_wiki_str("----" , "<hr/>");}
@ -57,19 +57,6 @@ public class Xoh_html_wtr_tst {
@Test public void Apos_ib() {fxt.Test_parse_page_wiki_str("'''''a'''''" , "<i><b>a</b></i>");} @Test public void Apos_ib() {fxt.Test_parse_page_wiki_str("'''''a'''''" , "<i><b>a</b></i>");}
@Test public void Html_ent() {fxt.Test_parse_page_wiki_str("&#33;" , "!");} @Test public void Html_ent() {fxt.Test_parse_page_wiki_str("&#33;" , "!");}
@Test public void Html_ref() {fxt.Test_parse_page_wiki_str("&gt;" , "&gt;");} @Test public void Html_ref() {fxt.Test_parse_page_wiki_str("&gt;" , "&gt;");}
@Test public void Lnke_basic() {fxt.Test_parse_page_wiki_str("[irc://a]" , "<a href=\"irc://a\" class=\"external text\" rel=\"nofollow\">[1]</a>");}
@Test public void Lnke_autonumber() {fxt.Test_parse_page_wiki_str("[irc://a] [irc://b]" , "<a href=\"irc://a\" class=\"external text\" rel=\"nofollow\">[1]</a> <a href=\"irc://b\" class=\"external text\" rel=\"nofollow\">[2]</a>");}
@Test public void Lnke_caption() {fxt.Test_parse_page_wiki_str("[irc://a b]" , "<a href=\"irc://a\" class=\"external text\" rel=\"nofollow\">b</a>");}
@Test public void Lnke_caption_fmt() {fxt.Test_parse_page_wiki_str("[irc://a ''b'']" , "<a href=\"irc://a\" class=\"external text\" rel=\"nofollow\"><i>b</i></a>");}
@Test public void Lnke_xowa() {
String img = "<img src=\"file:///mem/xowa/user/test_user/app/img/xowa/protocol.png\"/>";
fxt.Wiki().Sys_cfg().Xowa_proto_enabled_(true);
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a\" z]" , "<a href=\"xowa-cmd:a\">z" + img + "</a>");
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a.b('c_d');\" z]" , "<a href=\"xowa-cmd:a.b('c_d');\">z" + img + "</a>");
fxt.Test_parse_page_wiki_str("[xowa-cmd:*\"a\"b*c\"* z]" , "<a href=\"xowa-cmd:a%22b%2Ac\">z" + img + "</a>");
fxt.Wiki().Sys_cfg().Xowa_proto_enabled_(false);
fxt.Test_parse_page_wiki_str("[xowa-cmd:\"a\" b]" , "[xowa-cmd:&quot;a&quot; b]"); // protocol is disabled: literalize String (i.e.: don't make it an anchor)
}
@Test public void List_1_itm() { @Test public void List_1_itm() {
fxt.Test_parse_page_wiki_str("*a", String_.Concat_lines_nl_skip_last fxt.Test_parse_page_wiki_str("*a", String_.Concat_lines_nl_skip_last
( "<ul>" ( "<ul>"

View File

@ -0,0 +1,31 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
import gplx.xowa.files.*;
public interface Xoh_lnki_file_wkr {
void Write_img_full(Bry_bfr bfr, Xof_xfer_itm xfer_itm, int elem_id, byte[] link_ref, byte[] html_view_src, int html_w, int html_h, byte[] lnki_alt_text, byte[] lnki_ttl, byte[] anchor_cls, byte[] anchor_rel, byte[] anchor_title, byte[] itm_cls);
}
class Xoh_lnki_file_wkr_basic implements Xoh_lnki_file_wkr {
private Bry_fmtr img_full_fmtr;
public void Init(Bry_fmtr img_full_fmtr) {
this.img_full_fmtr = img_full_fmtr;
}
public void Write_img_full(Bry_bfr bfr, Xof_xfer_itm xfer_itm, int elem_id, byte[] lnki_href, byte[] html_view_src, int html_w, int html_h, byte[] lnki_alt_text, byte[] lnki_ttl, byte[] anchor_cls, byte[] anchor_rel, byte[] anchor_title, byte[] itm_cls) {
img_full_fmtr.Bld_bfr_many(bfr, elem_id, lnki_href, html_view_src, html_w, html_h, lnki_alt_text, lnki_ttl, anchor_cls, anchor_rel, anchor_title, itm_cls);
}
}

View File

@ -17,11 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html; import gplx.*; import gplx.xowa.*; package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
import gplx.xowa.files.*; import gplx.xowa.files.*;
import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.lnkis.*;
public class Xoh_lnki_file_wtr { public class Xoh_lnki_file_wtr {
private Xoh_lnki_file_wkr_basic lnki_file_wkr_basic = new Xoh_lnki_file_wkr_basic();
public Xoh_lnki_file_wtr(Xow_wiki wiki, Xow_html_mgr html_mgr, Xoh_html_wtr html_wtr) { public Xoh_lnki_file_wtr(Xow_wiki wiki, Xow_html_mgr html_mgr, Xoh_html_wtr html_wtr) {
this.html_mgr = html_mgr; this.html_mgr = html_mgr;
this.wiki = wiki; this.html_wtr = html_wtr; bfr_mkr = wiki.Utl_bry_bfr_mkr(); this.wiki = wiki; this.html_wtr = html_wtr; bfr_mkr = wiki.Utl_bry_bfr_mkr();
lnki_file_wkr_basic.Init(html_mgr.Lnki_full_image());
} private Xow_html_mgr html_mgr; private boolean lnki_title_enabled; } private Xow_html_mgr html_mgr; private boolean lnki_title_enabled;
private Xow_wiki wiki; private Xoh_html_wtr html_wtr; private Xow_wiki wiki; private Xoh_html_wtr html_wtr;
private Xoh_lnki_txt_fmtr media_alt_fmtr = new Xoh_lnki_txt_fmtr(), caption_fmtr = new Xoh_lnki_txt_fmtr(); private Bry_bfr_mkr bfr_mkr; private Xoh_lnki_txt_fmtr media_alt_fmtr = new Xoh_lnki_txt_fmtr(), caption_fmtr = new Xoh_lnki_txt_fmtr(); private Bry_bfr_mkr bfr_mkr;
@ -42,7 +44,7 @@ public class Xoh_lnki_file_wtr {
public Xof_xfer_itm Lnki_eval(Xop_ctx ctx, Xof_xfer_queue queue, byte[] lnki_ttl, byte lnki_type, int lnki_w, int lnki_h, double lnki_upright, double lnki_thumbtime, int lnki_page, boolean lnki_is_media_ns, Bool_obj_ref queue_add_ref) { public Xof_xfer_itm Lnki_eval(Xop_ctx ctx, Xof_xfer_queue queue, byte[] lnki_ttl, byte lnki_type, int lnki_w, int lnki_h, double lnki_upright, double lnki_thumbtime, int lnki_page, boolean lnki_is_media_ns, Bool_obj_ref queue_add_ref) {
this.ctx = ctx; this.ctx = ctx;
queue_add_ref.Val_n_(); queue_add_ref.Val_n_();
tmp_xfer_itm.Clear().Atrs_by_ttl(lnki_ttl, Bry_.Empty).Atrs_by_lnki(lnki_type, lnki_w, lnki_h, lnki_upright, lnki_thumbtime, lnki_page); tmp_xfer_itm.Clear().Init_by_lnki(lnki_ttl, Bry_.Empty, lnki_type, lnki_w, lnki_h, lnki_upright, lnki_thumbtime, lnki_page);
boolean found = Find_file(ctx, tmp_xfer_itm); boolean found = Find_file(ctx, tmp_xfer_itm);
boolean file_queue_add = File_queue_add(wiki, tmp_xfer_itm, lnki_is_media_ns, found); boolean file_queue_add = File_queue_add(wiki, tmp_xfer_itm, lnki_is_media_ns, found);
Xof_xfer_itm rv = tmp_xfer_itm; Xof_xfer_itm rv = tmp_xfer_itm;
@ -102,7 +104,7 @@ public class Xoh_lnki_file_wtr {
byte[] html_orig_src = xfer_itm.Html_orig_src(); byte[] html_orig_src = xfer_itm.Html_orig_src();
byte[] html_view_src = xfer_itm.Html_view_src(); byte[] html_view_src = xfer_itm.Html_view_src();
byte[] content = Bry_.Empty; byte[] content = Bry_.Empty;
byte[] lnki_ttl = lnki.Ttl().Page_txt(); byte[] lnki_ttl = lnki.Ttl().Page_txt();
Xof_ext lnki_ext = xfer_itm.Lnki_ext(); Xof_ext lnki_ext = xfer_itm.Lnki_ext();
if ( html_mgr.Img_suppress_missing_src() // option to suppress src when file is missing if ( html_mgr.Img_suppress_missing_src() // option to suppress src when file is missing
&& !xfer_itm.Html_pass() // file is missing; wipe values and wait for "correct" info before regenerating; mostly to handle unknown redirects && !xfer_itm.Html_pass() // file is missing; wipe values and wait for "correct" info before regenerating; mostly to handle unknown redirects
@ -152,9 +154,10 @@ public class Xoh_lnki_file_wtr {
byte[] anchor_title = lnki_title_enabled byte[] anchor_title = lnki_title_enabled
? Make_anchor_title(tmp_bfr, src, lnki, lnki_ttl, anchor_title_wkr) // NOTE: Make_anchor_title should only be called if there is no caption, else refs may not show; DATE:2014-03-05 ? Make_anchor_title(tmp_bfr, src, lnki, lnki_ttl, anchor_title_wkr) // NOTE: Make_anchor_title should only be called if there is no caption, else refs may not show; DATE:2014-03-05
: Bry_.Empty; : Bry_.Empty;
Xoh_lnki_file_wkr lnki_file_wkr = lnki.Lnki_file_wkr(); if (lnki_file_wkr == null) lnki_file_wkr = lnki_file_wkr_basic;
if (Xop_lnki_type.Id_is_thumbable(lnki.Lnki_type())) { // is "thumb" if (Xop_lnki_type.Id_is_thumbable(lnki.Lnki_type())) { // is "thumb"
if (bfr.Len() > 0) bfr.Add_byte_nl(); if (bfr.Len() > 0) bfr.Add_byte_nl();
content = Image_thumb(src, hctx, lnki, xfer_itm, elem_id, lnki_href, html_view_src, html_orig_src, lnki_alt_text, lnki_ttl, anchor_title); content = Image_thumb(lnki_file_wkr, src, hctx, lnki, xfer_itm, elem_id, lnki_href, html_view_src, html_orig_src, lnki_alt_text, lnki_ttl, anchor_title);
html_mgr.Lnki_thumb_core().Bld_bfr_many(bfr, div_width, lnki_halign_bry, content, elem_id); html_mgr.Lnki_thumb_core().Bld_bfr_many(bfr, div_width, lnki_halign_bry, content, elem_id);
} }
else { else {
@ -164,7 +167,6 @@ public class Xoh_lnki_file_wtr {
Caption(src, lnki, Xoh_html_wtr_ctx.Alt, html_orig_src).XferAry(tmp_bfr, 0); Caption(src, lnki, Xoh_html_wtr_ctx.Alt, html_orig_src).XferAry(tmp_bfr, 0);
lnki_alt_text = tmp_bfr.XtoAryAndClear(); lnki_alt_text = tmp_bfr.XtoAryAndClear();
} }
// if (lnki_img_type == Xop_lnki_type.Id_none) bfr.Add(Bry_div_float_none).Add_byte_nl();
switch (lnki.Align_h()) { switch (lnki.Align_h()) {
case Xop_lnki_align_h.Left: bfr.Add(Bry_div_float_left).Add_byte_nl(); break; case Xop_lnki_align_h.Left: bfr.Add(Bry_div_float_left).Add_byte_nl(); break;
case Xop_lnki_align_h.Right: bfr.Add(Bry_div_float_right).Add_byte_nl(); break; case Xop_lnki_align_h.Right: bfr.Add(Bry_div_float_right).Add_byte_nl(); break;
@ -172,7 +174,7 @@ public class Xoh_lnki_file_wtr {
} }
Arg_nde_tkn lnki_link_tkn = lnki.Link_tkn(); Arg_nde_tkn lnki_link_tkn = lnki.Link_tkn();
if (lnki_link_tkn == Arg_nde_tkn.Null) if (lnki_link_tkn == Arg_nde_tkn.Null)
html_mgr.Lnki_full_image().Bld_bfr_many(bfr, elem_id, lnki_href, html_view_src, xfer_itm.Html_w(), xfer_itm.Html_h(), lnki_alt_text, lnki_ttl, Xow_html_mgr.Bry_anchor_class_image, Xow_html_mgr.Bry_anchor_rel_blank, anchor_title, Img_cls(lnki)); lnki_file_wkr.Write_img_full(bfr, xfer_itm, elem_id, lnki_href, html_view_src, xfer_itm.Html_w(), xfer_itm.Html_h(), lnki_alt_text, lnki_ttl, Xow_html_mgr.Bry_anchor_class_image, Xow_html_mgr.Bry_anchor_rel_blank, anchor_title, Img_cls(lnki));
else { else {
Arg_itm_tkn link_tkn = lnki_link_tkn.Val_tkn(); Arg_itm_tkn link_tkn = lnki_link_tkn.Val_tkn();
byte[] link_ref = link_tkn.Dat_to_bry(src); byte[] link_ref = link_tkn.Dat_to_bry(src);
@ -180,7 +182,7 @@ public class Xoh_lnki_file_wtr {
link_ref = link_ref_new == null ? lnki_href: link_ref_new; // if parse fails, then assign to lnki_href; EX:link={{{1}}} link_ref = link_ref_new == null ? lnki_href: link_ref_new; // if parse fails, then assign to lnki_href; EX:link={{{1}}}
link_ref = ctx.App().Encoder_mgr().Href_quotes().Encode(link_ref); // must encode quotes; PAGE:en.w:List_of_cultural_heritage_sites_in_Punjab,_Pakistan; DATE:2014-07-16 link_ref = ctx.App().Encoder_mgr().Href_quotes().Encode(link_ref); // must encode quotes; PAGE:en.w:List_of_cultural_heritage_sites_in_Punjab,_Pakistan; DATE:2014-07-16
lnki_ttl = Bry_.Coalesce(lnki_ttl, tmp_link_parser.Html_xowa_ttl()); lnki_ttl = Bry_.Coalesce(lnki_ttl, tmp_link_parser.Html_xowa_ttl());
html_mgr.Lnki_full_image().Bld_bfr_many(bfr, elem_id, link_ref, html_view_src, xfer_itm.Html_w(), xfer_itm.Html_h(), lnki_alt_text, lnki_ttl, tmp_link_parser.Html_anchor_cls(), tmp_link_parser.Html_anchor_rel(), anchor_title, Img_cls(lnki)); lnki_file_wkr.Write_img_full(bfr, xfer_itm, elem_id, link_ref, html_view_src, xfer_itm.Html_w(), xfer_itm.Html_h(), lnki_alt_text, lnki_ttl, tmp_link_parser.Html_anchor_cls(), tmp_link_parser.Html_anchor_rel(), anchor_title, Img_cls(lnki));
} }
switch (lnki.Align_h()) { switch (lnki.Align_h()) {
case Xop_lnki_align_h.Left: case Xop_lnki_align_h.Left:
@ -220,13 +222,13 @@ public class Xoh_lnki_file_wtr {
html_mgr.Lnki_thumb_file_video().Bld_bfr_many(tmp_bfr, Play_btn(elem_id, play_btn_width, play_btn_width, html_orig_src, lnki.Ttl().Page_txt()), Img_thumb(lnki, xfer_itm, elem_id, lnki_href, html_view_src, lnki_alt_text), Bry_.Empty, Bry_.Empty); html_mgr.Lnki_thumb_file_video().Bld_bfr_many(tmp_bfr, Play_btn(elem_id, play_btn_width, play_btn_width, html_orig_src, lnki.Ttl().Page_txt()), Img_thumb(lnki, xfer_itm, elem_id, lnki_href, html_view_src, lnki_alt_text), Bry_.Empty, Bry_.Empty);
return tmp_bfr.Mkr_rls().XtoAryAndClear(); return tmp_bfr.Mkr_rls().XtoAryAndClear();
} }
private byte[] Image_thumb(byte[] src, Xoh_html_wtr_ctx hctx, Xop_lnki_tkn lnki, Xof_xfer_itm xfer_itm, int elem_id, byte[] lnki_href, byte[] html_view_src, byte[] html_orig_src, byte[] lnki_alt_text, byte[] lnki_ttl, byte[] anchor_title) { private byte[] Image_thumb(Xoh_lnki_file_wkr lnki_file_wkr, byte[] src, Xoh_html_wtr_ctx hctx, Xop_lnki_tkn lnki, Xof_xfer_itm xfer_itm, int elem_id, byte[] lnki_href, byte[] html_view_src, byte[] html_orig_src, byte[] lnki_alt_text, byte[] lnki_ttl, byte[] anchor_title) {
byte[] lnki_alt_html = Alt_html(src, lnki); byte[] lnki_alt_html = Alt_html(src, lnki);
Bry_bfr tmp_bfr = bfr_mkr.Get_k004(); Bry_bfr tmp_bfr = bfr_mkr.Get_k004();
byte[] lnki_class = xfer_itm.Html_pass() byte[] lnki_class = xfer_itm.Html_pass()
? Xow_html_mgr.Bry_img_class_thumbimage ? Xow_html_mgr.Bry_img_class_thumbimage
: Xow_html_mgr.Bry_img_class_none; : Xow_html_mgr.Bry_img_class_none;
html_mgr.Lnki_full_image().Bld_bfr_many(tmp_bfr, elem_id, lnki_href, html_view_src, xfer_itm.Html_w(), xfer_itm.Html_h(), lnki_alt_text, lnki_ttl, Xow_html_mgr.Bry_anchor_class_image, Xow_html_mgr.Bry_anchor_rel_blank, anchor_title, lnki_class); lnki_file_wkr.Write_img_full(tmp_bfr, xfer_itm, elem_id, lnki_href, html_view_src, xfer_itm.Html_w(), xfer_itm.Html_h(), lnki_alt_text, lnki_ttl, Xow_html_mgr.Bry_anchor_class_image, Xow_html_mgr.Bry_anchor_rel_blank, anchor_title, lnki_class);
byte[] thumb = tmp_bfr.XtoAryAndClear(); byte[] thumb = tmp_bfr.XtoAryAndClear();
if (!wiki.Html_mgr().Imgs_mgr().Alt_in_caption().Val()) lnki_alt_html = Bry_.Empty; if (!wiki.Html_mgr().Imgs_mgr().Alt_in_caption().Val()) lnki_alt_html = Bry_.Empty;
html_mgr.Lnki_thumb_file_image().Bld_bfr_many(tmp_bfr, thumb, Caption_div(src, lnki, html_orig_src, lnki_href), lnki_alt_html); html_mgr.Lnki_thumb_file_image().Bld_bfr_many(tmp_bfr, thumb, Caption_div(src, lnki, html_orig_src, lnki_href), lnki_alt_html);

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html; import gplx.*; import gplx.xowa.*; package gplx.xowa.html; import gplx.*; import gplx.xowa.*;
import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.users.history.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.html.*; import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.redlinks.*; import gplx.xowa.users.history.*; import gplx.xowa.xtns.pfuncs.ttls.*;
public class Xoh_lnki_wtr { public class Xoh_lnki_wtr {
private Xoa_app app; private Xow_wiki wiki; private Xoa_page page; private Xop_ctx ctx; private Xoa_app app; private Xow_wiki wiki; private Xoa_page page; private Xop_ctx ctx;
private Xoh_html_wtr_cfg cfg; private Xoh_html_wtr_cfg cfg;
@ -72,14 +72,17 @@ public class Xoh_lnki_wtr {
public void Write_plain_by_tkn(Bry_bfr bfr, Xoh_html_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xoa_ttl lnki_ttl) { public void Write_plain_by_tkn(Bry_bfr bfr, Xoh_html_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xoa_ttl lnki_ttl) {
Write_plain(bfr, hctx, src, lnki, lnki_ttl, caption_tkn_wtr); Write_plain(bfr, hctx, src, lnki, lnki_ttl, caption_tkn_wtr);
} }
public void Write_caption(Bry_bfr bfr, Xoh_html_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xoa_ttl lnki_ttl) {
Write_caption(bfr, ctx, hctx, src, lnki, lnki.Ttl_ary(), true, caption_tkn_wtr);
}
private void Write_plain(Bry_bfr bfr, Xoh_html_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xoa_ttl lnki_ttl, Xop_lnki_caption_wtr caption_wkr) { private void Write_plain(Bry_bfr bfr, Xoh_html_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, Xoa_ttl lnki_ttl, Xop_lnki_caption_wtr caption_wkr) {
byte[] ttl_bry = lnki.Ttl_ary(); byte[] ttl_bry = lnki.Ttl_ary();
if (Bry_.Len_eq_0(ttl_bry)) ttl_bry = lnki_ttl.Full_txt_raw(); // NOTE: handles ttls like [[fr:]] and [[:fr;]] which have an empty Page_txt, but a valued Full_txt_raw if (Bry_.Len_eq_0(ttl_bry)) ttl_bry = lnki_ttl.Full_txt_raw(); // NOTE: handles ttls like [[fr:]] and [[:fr;]] which have an empty Page_txt, but a valued Full_txt_raw
if (Bry_.Eq(lnki_ttl.Full_txt(), page.Ttl().Full_txt())) { // lnki is same as pagename; bold; SEE: Month widget on day pages will bold current day; PAGE:en.w:January 1 if (Bry_.Eq(lnki_ttl.Full_txt(), page.Ttl().Full_txt())) { // lnki is same as pagename; bold; SEE: Month widget on day pages will bold current day; PAGE:en.w:January 1
if (lnki_ttl.Anch_bgn() == -1 && Bry_.Eq(lnki_ttl.Wik_txt(), page.Ttl().Wik_txt())) { // only bold if lnki is not pointing to anchor on same page; PAGE:en.w:Comet; [[Comet#Physical characteristics|ion tail]] if (lnki_ttl.Anch_bgn() == -1 && Bry_.Eq(lnki_ttl.Wik_txt(), page.Ttl().Wik_txt())) { // only bold if lnki is not pointing to anchor on same page; PAGE:en.w:Comet; [[Comet#Physical characteristics|ion tail]]
bfr.Add(Xoh_consts.B_bgn); bfr.Add(Html_tag_.B_lhs);
Write_caption(bfr, ctx, hctx, src, lnki, ttl_bry, true, caption_wkr); Write_caption(bfr, ctx, hctx, src, lnki, ttl_bry, true, caption_wkr);
bfr.Add(Xoh_consts.B_end); bfr.Add(Html_tag_.B_rhs);
return; return;
} }
} }

View File

@ -21,7 +21,7 @@ public class Xoh_page_wtr_wkr_ {
public static byte[] Bld_page_content_sub(Xoa_app app, Xow_wiki wiki, Xoa_page page, Bry_bfr tmp_bfr) { public static byte[] Bld_page_content_sub(Xoa_app app, Xow_wiki wiki, Xoa_page page, Bry_bfr tmp_bfr) {
byte[] page_content_sub = page.Html_data().Content_sub(); // contentSub exists; SEE: {{#isin}} byte[] page_content_sub = page.Html_data().Content_sub(); // contentSub exists; SEE: {{#isin}}
byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page); byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page);
return tmp_bfr.Concat_skip_empty(Xoh_consts.Br, page_content_sub, redirect_msg).XtoAryAndClear(); return tmp_bfr.Concat_skip_empty(Html_tag_.Br_inl, page_content_sub, redirect_msg).XtoAryAndClear();
} }
public static byte[] Bld_page_name(Bry_bfr tmp_bfr, Xoa_ttl ttl, byte[] display_ttl) { public static byte[] Bld_page_name(Bry_bfr tmp_bfr, Xoa_ttl ttl, byte[] display_ttl) {
if (display_ttl != null) return display_ttl; // display_ttl explicitly set; use it if (display_ttl != null) return display_ttl; // display_ttl explicitly set; use it

View File

@ -57,85 +57,85 @@ public class Xow_html_mgr implements GfoInvkAble {
public Xoctg_html_mgr Ns_ctg() {return ns_ctg;} private Xoctg_html_mgr ns_ctg = new Xoctg_html_mgr(); public Xoctg_html_mgr Ns_ctg() {return ns_ctg;} private Xoctg_html_mgr ns_ctg = new Xoctg_html_mgr();
public Xoh_imgs_mgr Imgs_mgr() {return imgs_mgr;} private Xoh_imgs_mgr imgs_mgr; public Xoh_imgs_mgr Imgs_mgr() {return imgs_mgr;} private Xoh_imgs_mgr imgs_mgr;
public Bry_fmtr Lnki_full_image() {return lnki_full_image;} Bry_fmtr lnki_full_image = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_full_image() {return lnki_full_image;} Bry_fmtr lnki_full_image = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<a href=\"~{href}\"~{anchor_class}~{anchor_rel}~{anchor_title} xowa_title=\"~{lnki_title}\"><img id=\"xowa_file_img_~{elem_id}\" alt=\"~{alt}\" src=\"~{src}\" width=\"~{width}\" height=\"~{height}\"~{img_class} /></a>" ( "<a href=\"~{href}\"~{anchor_class}~{anchor_rel}~{anchor_title} xowa_title=\"~{lnki_title}\"><img id=\"xowa_file_img_~{elem_id}\" alt=\"~{alt}\" src=\"~{src}\" width=\"~{width}\" height=\"~{height}\"~{img_class} /></a>"
), "elem_id", "href", "src", "width", "height", "alt", "lnki_title", "anchor_class", "anchor_rel", "anchor_title", "img_class" ), "elem_id", "href", "src", "width", "height", "alt", "lnki_title", "anchor_class", "anchor_rel", "anchor_title", "img_class"
); );
public Bry_fmtr Lnki_full_media() {return lnki_full_media;} Bry_fmtr lnki_full_media = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_full_media() {return lnki_full_media;} Bry_fmtr lnki_full_media = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "<a href=\"~{lnki_src}\" xowa_title=\"~{lnki_title}\">~{lnki_caption}" ( "<a href=\"~{lnki_src}\" xowa_title=\"~{lnki_title}\">~{lnki_caption}"
, "</a>" , "</a>"
), "lnki_src", "lnki_title", "lnki_caption" ), "lnki_src", "lnki_title", "lnki_caption"
); );
public Bry_fmtr Lnki_thumb_core() {return lnki_thumb_core;} Bry_fmtr lnki_thumb_core = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last // REF.MW: Linker.php|makeImageLink2 public Bry_fmtr Lnki_thumb_core() {return lnki_thumb_core;} Bry_fmtr lnki_thumb_core = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last // REF.MW: Linker.php|makeImageLink2
( "<div class=\"thumb t~{lnki_halign}\">" ( "<div class=\"thumb t~{lnki_halign}\">"
, " <div id=\"xowa_file_div_~{elem_id}\" class=\"thumbinner\" style=\"width:~{div_width}px;\">" , " <div id=\"xowa_file_div_~{elem_id}\" class=\"thumbinner\" style=\"width:~{div_width}px;\">"
, "~{lnki_content}" , "~{lnki_content}"
, " </div>" , " </div>"
, "</div>" , "</div>"
, "" , ""
), "div_width", "lnki_halign", "lnki_content", "elem_id" ), "div_width", "lnki_halign", "lnki_content", "elem_id"
); );
public Bry_fmtr Lnki_thumb_file_image() {return lnki_thumb_file_image;} Bry_fmtr lnki_thumb_file_image = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_file_image() {return lnki_thumb_file_image;} Bry_fmtr lnki_thumb_file_image = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( " ~{thumb_image}~{lnki_caption}~{lnki_alt}" ( " ~{thumb_image}~{lnki_caption}~{lnki_alt}"
), "thumb_image", "lnki_caption", "lnki_alt"); ), "thumb_image", "lnki_caption", "lnki_alt");
public Bry_fmtr Lnki_thumb_file_video() {return lnki_thumb_file_video;} Bry_fmtr lnki_thumb_file_video = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_file_video() {return lnki_thumb_file_video;} Bry_fmtr lnki_thumb_file_video = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( " <div id=\"xowa_media_div\">~{video_thumb}~{play_btn}" ( " <div id=\"xowa_media_div\">~{video_thumb}~{play_btn}"
, " </div>~{lnki_caption}~{lnki_alt}" , " </div>~{lnki_caption}~{lnki_alt}"
), "play_btn", "video_thumb", "lnki_caption", "lnki_alt"); ), "play_btn", "video_thumb", "lnki_caption", "lnki_alt");
public Bry_fmtr Lnki_thumb_file_audio() {return lnki_thumb_file_audio;} Bry_fmtr lnki_thumb_file_audio = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_file_audio() {return lnki_thumb_file_audio;} Bry_fmtr lnki_thumb_file_audio = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( " <div id=\"xowa_media_div\">~{play_btn}~{info_btn}" ( " <div id=\"xowa_media_div\">~{play_btn}~{info_btn}"
, " </div>~{lnki_caption}~{lnki_alt}" , " </div>~{lnki_caption}~{lnki_alt}"
), "play_btn", "info_btn", "lnki_caption", "lnki_alt"); ), "play_btn", "info_btn", "lnki_caption", "lnki_alt");
public Bry_fmtr Lnki_thumb_part_image() {return lnki_thumb_part_image;} Bry_fmtr lnki_thumb_part_image = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_part_image() {return lnki_thumb_part_image;} Bry_fmtr lnki_thumb_part_image = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "" ( ""
, " <div>" , " <div>"
, " <a href=\"~{lnki_href}\" class=\"~{lnki_class}\" title=\"~{lnki_title}\">" , " <a href=\"~{lnki_href}\" class=\"~{lnki_class}\" title=\"~{lnki_title}\">"
, " <img id=\"xowa_file_img_~{elem_id}\" src=\"~{lnki_src}\" width=\"~{lnki_width}\" height=\"~{lnki_height}\" alt=\"~{lnki_alt}\" />" , " <img id=\"xowa_file_img_~{elem_id}\" src=\"~{lnki_src}\" width=\"~{lnki_width}\" height=\"~{lnki_height}\" alt=\"~{lnki_alt}\" />"
, " </a>" , " </a>"
, " </div>" , " </div>"
), "elem_id", "lnki_class", "lnki_href", "lnki_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt"); ), "elem_id", "lnki_class", "lnki_href", "lnki_title", "lnki_src", "lnki_width", "lnki_height", "lnki_alt");
public Bry_fmtr Lnki_thumb_part_caption() {return lnki_thumb_part_caption;} Bry_fmtr lnki_thumb_part_caption = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_part_caption() {return lnki_thumb_part_caption;} Bry_fmtr lnki_thumb_part_caption = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "" ( ""
, " <div class=\"thumbcaption\">~{magnify_btn}" , " <div class=\"thumbcaption\">~{magnify_btn}"
, " ~{lnki_caption}" , " ~{lnki_caption}"
, " </div>" , " </div>"
), "magnify_btn", "lnki_caption"); ), "magnify_btn", "lnki_caption");
public Bry_fmtr Lnki_thumb_part_alt() {return lnki_thumb_part_alt;} Bry_fmtr lnki_thumb_part_alt = Bry_fmtr.new_ public Bry_fmtr Lnki_thumb_part_alt() {return lnki_thumb_part_alt;} Bry_fmtr lnki_thumb_part_alt = Bry_fmtr.new_
(String_.Concat_lines_nl_skip_last (String_.Concat_lines_nl_skip_last
( "" ( ""
, " <hr/>" , " <hr/>"
, " <div class=\"thumbcaption\">" , " <div class=\"thumbcaption\">"
, "~{alt_html}" , "~{alt_html}"
, " </div>" , " </div>"
) )
, "alt_html"); , "alt_html");
public Bry_fmtr Lnki_thumb_part_magnfiy_btn() {return lnki_thumb_part_magnify_btn;} Bry_fmtr lnki_thumb_part_magnify_btn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_part_magnfiy_btn() {return lnki_thumb_part_magnify_btn;} Bry_fmtr lnki_thumb_part_magnify_btn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "" ( ""
, " <div class=\"magnify\">" , " <div class=\"magnify\">"
, " <a href=\"~{lnki_src}\" class=\"internal\" title=\"~{lnki_enlarge_msg}\">" , " <a href=\"~{lnki_src}\" class=\"internal\" title=\"~{lnki_enlarge_msg}\">"
, " <img src=\"~{magnify_icon}\" width=\"15\" height=\"11\" alt=\"\" />" , " <img src=\"~{magnify_icon}\" width=\"15\" height=\"11\" alt=\"\" />"
, " </a>" , " </a>"
, " </div>" , " </div>"
), "magnify_icon", "lnki_src", "lnki_enlarge_msg"); ), "magnify_icon", "lnki_src", "lnki_enlarge_msg");
public Bry_fmtr Lnki_thumb_part_play_btn() {return lnki_thumb_part_play_btn;} Bry_fmtr lnki_thumb_part_play_btn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_part_play_btn() {return lnki_thumb_part_play_btn;} Bry_fmtr lnki_thumb_part_play_btn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "" ( ""
, " <div>" , " <div>"
, " <a id=\"xowa_file_play_~{play_id}\" href=\"~{lnki_url}\" xowa_title=\"~{lnki_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">" , " <a id=\"xowa_file_play_~{play_id}\" href=\"~{lnki_url}\" xowa_title=\"~{lnki_title}\" class=\"xowa_anchor_button\" style=\"width:~{play_width}px;max-width:~{play_max_width}px;\">"
, " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />" , " <img src=\"~{play_icon}\" width=\"22\" height=\"22\" alt=\"Play sound\" />"
, " </a>" , " </a>"
, " </div>" , " </div>"
), "play_id", "play_icon", "play_width", "play_max_width", "lnki_url", "lnki_title"); ), "play_id", "play_icon", "play_width", "play_max_width", "lnki_url", "lnki_title");
public Bry_fmtr Lnki_thumb_part_info_btn() {return lnki_thumb_part_info_btn;} Bry_fmtr lnki_thumb_part_info_btn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Lnki_thumb_part_info_btn() {return lnki_thumb_part_info_btn;} Bry_fmtr lnki_thumb_part_info_btn = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "" ( ""
, " <div>" , " <div>"
, " <a href=\"~{lnki_href}\" class=\"image\" title=\"About this file\">" , " <a href=\"~{lnki_href}\" class=\"image\" title=\"About this file\">"
, " <img src=\"~{info_icon}\" width=\"22\" height=\"22\" />" , " <img src=\"~{info_icon}\" width=\"22\" height=\"22\" />"
, " </a>" , " </a>"
, " </div>" , " </div>"
), "info_icon", "lnki_href"); ), "info_icon", "lnki_href");
public Bry_fmtr Plain() {return plain;} Bry_fmtr plain = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last public Bry_fmtr Plain() {return plain;} Bry_fmtr plain = Bry_fmtr.new_(String_.Concat_lines_nl_skip_last
( "~{val}" ( "~{val}"
), "val"); ), "val");
public void Copy_cfg(Xow_html_mgr html_mgr) {imgs_mgr.Copy_cfg(html_mgr.Imgs_mgr());} public void Copy_cfg(Xow_html_mgr html_mgr) {imgs_mgr.Copy_cfg(html_mgr.Imgs_mgr());}
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) { public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
if (ctx.Match(k, Invk_lnki_full_image_)) lnki_full_image.Fmt_(m.ReadBry("v")); if (ctx.Match(k, Invk_lnki_full_image_)) lnki_full_image.Fmt_(m.ReadBry("v"));

View File

@ -65,12 +65,12 @@ public class Xoh_module_itm__globals implements Xoh_module_itm {
bfr.Add_byte(Byte_ascii.Brack_bgn).Add_byte(Byte_ascii.Apos).Add_byte(Byte_ascii.Apos); bfr.Add_byte(Byte_ascii.Brack_bgn).Add_byte(Byte_ascii.Apos).Add_byte(Byte_ascii.Apos);
for (int i = january_id; i <= december_id; i++) { for (int i = january_id; i <= december_id; i++) {
bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space).Add_byte(Byte_ascii.Apos); bfr.Add_byte(Byte_ascii.Comma).Add_byte(Byte_ascii.Space).Add_byte(Byte_ascii.Apos);
bfr.Add(msg_mgr.Val_by_id(i)); bfr.Add(Bry_.Replace(msg_mgr.Val_by_id(i), Byte_ascii.Apos_bry, Apos_escape));
bfr.Add_byte(Byte_ascii.Apos); bfr.Add_byte(Byte_ascii.Apos);
} }
bfr.Add_byte(Byte_ascii.Brack_end); bfr.Add_byte(Byte_ascii.Brack_end);
return bfr.XtoAryAndClear(); return bfr.XtoAryAndClear();
} } private static final byte[] Apos_escape = Bry_.new_ascii_("\\'");
private static byte[] Html_js_table_num_format_separators(Bry_bfr bfr, Xol_transform_mgr separator_mgr) { private static byte[] Html_js_table_num_format_separators(Bry_bfr bfr, Xol_transform_mgr separator_mgr) {
byte[] dec_spr = separator_mgr.Get_val_or_self(Xol_num_mgr.Separators_key__dec); byte[] dec_spr = separator_mgr.Get_val_or_self(Xol_num_mgr.Separators_key__dec);
bfr.Add_byte(Byte_ascii.Brack_bgn) .Add_byte(Byte_ascii.Apos).Add(dec_spr).Add_byte(Byte_ascii.Tab).Add_byte(Byte_ascii.Dot).Add_byte(Byte_ascii.Apos); bfr.Add_byte(Byte_ascii.Brack_bgn) .Add_byte(Byte_ascii.Apos).Add(dec_spr).Add_byte(Byte_ascii.Tab).Add_byte(Byte_ascii.Dot).Add_byte(Byte_ascii.Apos);

View File

@ -20,6 +20,7 @@ import gplx.xowa.gui.*;
import gplx.xowa.apis.xowa.html.modules.*; import gplx.xowa.apis.xowa.html.modules.*;
public class Xoh_module_itm__popups implements Xoh_module_itm { public class Xoh_module_itm__popups implements Xoh_module_itm {
public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled; public boolean Enabled() {return enabled;} public void Enabled_y_() {enabled = true;} public void Enabled_(boolean v) {enabled = v;} private boolean enabled;
public boolean Bind_hover_area() {return bind_hover_area;} public void Bind_hover_area_(boolean v) {bind_hover_area = v;} private boolean bind_hover_area;
public void Clear() {enabled = false;} public void Clear() {enabled = false;}
public byte[] Key() {return Key_const;} private static final byte[] Key_const = Bry_.new_ascii_("popups"); public byte[] Key() {return Key_const;} private static final byte[] Key_const = Bry_.new_ascii_("popups");
public void Write_css_script(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoh_module_wtr wtr) {} public void Write_css_script(Xoa_app app, Xow_wiki wiki, Xoa_page page, Xoh_module_wtr wtr) {}
@ -51,6 +52,7 @@ public class Xoh_module_itm__popups implements Xoh_module_itm {
wtr.Write_js_global_ini_atr_val(Key_win_max_h , api_popups.Win_max_h()); wtr.Write_js_global_ini_atr_val(Key_win_max_h , api_popups.Win_max_h());
wtr.Write_js_global_ini_atr_val(Key_win_show_all_max_w , api_popups.Win_show_all_max_w()); wtr.Write_js_global_ini_atr_val(Key_win_show_all_max_w , api_popups.Win_show_all_max_w());
wtr.Write_js_global_ini_atr_val(Key_win_bind_focus_blur , api_popups.Win_bind_focus_blur()); wtr.Write_js_global_ini_atr_val(Key_win_bind_focus_blur , api_popups.Win_bind_focus_blur());
wtr.Write_js_global_ini_atr_val(Key_win_bind_hover_area , bind_hover_area);
} }
private static byte[] Css_url, Js_line_2; private static byte[] Css_url, Js_line_2;
private static final byte[] private static final byte[]
@ -63,5 +65,6 @@ public class Xoh_module_itm__popups implements Xoh_module_itm {
, Key_win_max_h = Bry_.new_ascii_("popups-win-max_h") , Key_win_max_h = Bry_.new_ascii_("popups-win-max_h")
, Key_win_show_all_max_w = Bry_.new_ascii_("popups-win-show_all_max_w") , Key_win_show_all_max_w = Bry_.new_ascii_("popups-win-show_all_max_w")
, Key_win_bind_focus_blur = Bry_.new_ascii_("popups-win-bind_focus_blur") , Key_win_bind_focus_blur = Bry_.new_ascii_("popups-win-bind_focus_blur")
, Key_win_bind_hover_area = Bry_.new_ascii_("popups-win-bind_hover_area")
; ;
} }

View File

@ -40,7 +40,7 @@ public class Xoh_module_mgr_tst {
, " 'toc-enabled' : true," , " 'toc-enabled' : true,"
, " 'mw_hidetoc' : '0'," , " 'mw_hidetoc' : '0',"
, " 'showtoc' : 'Sh\"ow'," , " 'showtoc' : 'Sh\"ow',"
, " 'hidetoc' : 'Hi''de'," , " 'hidetoc' : 'Hi\\'de',"
, " }" , " }"
, " </script>" , " </script>"
)); ));

View File

@ -92,7 +92,7 @@ public class Xoh_module_wtr {
private void Write_js_global_ini_atr(byte[] key, boolean quote_val, byte[] val) { private void Write_js_global_ini_atr(byte[] key, boolean quote_val, byte[] val) {
Write_js_global_ini_atr_bgn(key); Write_js_global_ini_atr_bgn(key);
if (quote_val) if (quote_val)
Write_quote(Byte_ascii.Apos, val); Write_js_quote(Byte_ascii.Apos, val);
else else
bfr.Add(val); bfr.Add(val);
bfr.Add_byte(Byte_ascii.Comma); bfr.Add_byte(Byte_ascii.Comma);
@ -115,7 +115,7 @@ public class Xoh_module_wtr {
bfr.Add(key); bfr.Add(key);
bfr.Add(Js_var_mid); bfr.Add(Js_var_mid);
if (quote_val) if (quote_val)
Write_quote(Byte_ascii.Apos, val); Write_js_quote(Byte_ascii.Apos, val);
else else
bfr.Add(val); bfr.Add(val);
bfr.Add(Js_var_end); bfr.Add(Js_var_end);
@ -124,12 +124,12 @@ public class Xoh_module_wtr {
Indent(); Indent();
bfr.Add(v); bfr.Add(v);
} }
private void Write_quote(byte quote_byte, byte[] val) { private void Write_js_quote(byte quote_byte, byte[] val) {
int val_len = val.length; int val_len = val.length;
bfr.Add_byte(quote_byte); bfr.Add_byte(quote_byte);
for (int i = 0; i < val_len; i++) { for (int i = 0; i < val_len; i++) {
byte b = val[i]; byte b = val[i];
if (b == quote_byte) bfr.Add_byte(b); // double up quotes if (b == quote_byte) bfr.Add_byte_backslash(); // escape quote
bfr.Add_byte(b); bfr.Add_byte(b);
} }
bfr.Add_byte(quote_byte); bfr.Add_byte(quote_byte);

View File

@ -38,7 +38,7 @@ public class Xoh_module_wtr_tst {
, "var xowa_global_values = {" , "var xowa_global_values = {"
, " 'key_1' : 'val_1'," , " 'key_1' : 'val_1',"
, " 'key_2' : 'val_2'," , " 'key_2' : 'val_2',"
, " 'key_3' : 'apos_''_1'," , " 'key_3' : 'apos_\\'_1',"
, "}" , "}"
)); ));
} }

View File

@ -0,0 +1,69 @@
/*
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.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
class Xow_popup_anchor_finder {
private byte[] src, find;
private int src_len, nl_lhs;
public int Find(byte[] src, int src_len, byte[] find, int bgn) {
this.src = src; this.src_len = src_len; this.find = find; this.nl_lhs = bgn;
if (bgn == Xop_parser_.Doc_bgn_bos && Find_hdr(bgn)) return Xop_parser_.Doc_bgn_bos;// handle BOS separately which won't fit "\n=" search below; EX: "BOS==A==\n"
int lhs_bgn = bgn;
while (true) {
lhs_bgn = Bry_finder.Find_fwd(src, Hdr_bgn, nl_lhs, src_len);
if (lhs_bgn == Bry_.NotFound) break; // "\n=" not found; exit;
if (Find_hdr(lhs_bgn)) return lhs_bgn;
}
return Find_id(bgn);
}
private boolean Find_hdr(int lhs_bgn) {
int nl_rhs = Bry_finder.Find_fwd(src, Byte_ascii.NewLine, nl_lhs + 1, src_len); // look for \n
if (nl_rhs == Bry_finder.Not_found) nl_rhs = src_len - 1; // no more \n; set to last idx
nl_lhs = nl_rhs; // update nl_lhs for loop
int lhs_end = Bry_finder.Find_fwd_while(src, lhs_bgn + 1, nl_rhs, Byte_ascii.Eq); // skip eq; EX: "\n==="; +1 to skip eq
int rhs_end = Bry_finder.Trim_bwd_space_tab(src, nl_rhs, lhs_end); // skip ws bwd; EX: "== \n"
int rhs_bgn = Bry_finder.Find_bwd_while(src, rhs_end, lhs_end, Byte_ascii.Eq); // skip eq; EX: "==\n" -> pos before =
if (rhs_bgn < lhs_end) return false; // eq found, but is actually lhs_eq; no rhs_eq, so exit; EX: "\n== \n"
++rhs_bgn; // rhs_bgn is 1st char before eq; position at eq; neede for txt_end below
int txt_bgn = Bry_finder.Trim_fwd_space_tab(src, lhs_end, nl_rhs); // trim ws
int txt_end = Bry_finder.Trim_bwd_space_tab(src, rhs_bgn, lhs_end); // trim ws
return Bry_.Eq(find, src, txt_bgn, txt_end); // check for strict match
}
private int Find_id(int bgn) {
byte[] quoted = Bry_.Add(Byte_ascii.Quote_bry, find, Byte_ascii.Quote_bry);
int rv = Find_id_by_quoted(bgn, quoted);
if (rv == Bry_finder.Not_found) {
quoted[0] = Byte_ascii.Apos; quoted[quoted.length - 1] = Byte_ascii.Apos;
rv = Find_id_by_quoted(bgn, quoted);
}
return rv;
}
private int Find_id_by_quoted(int bgn, byte[] quoted) {
int rv = Bry_finder.Not_found;
int pos = Bry_finder.Find_fwd(src, quoted, bgn);
if (pos == Bry_finder.Not_found) return rv;
pos = Bry_finder.Trim_bwd_space_tab(src, pos, bgn);
if (src[pos - 1] != Byte_ascii.Eq) return rv;
int id_end = Bry_finder.Trim_bwd_space_tab(src, pos - 1, bgn);
int id_bgn = Bry_finder.Find_bwd_ws(src, id_end - 1, bgn);
boolean id_match = Int_.Bounds_chk(id_bgn, id_end, src_len) && Bry_.Eq(Id_bry, src, id_bgn + 1, id_end);
if (!id_match) return rv;
rv = Bry_finder.Find_bwd(src, Byte_ascii.NewLine, id_bgn);
return rv == Bry_finder.Not_found ? 0 : rv;
}
private static final byte[] Hdr_bgn = Bry_.new_ascii_("\n="), Id_bry = Bry_.new_ascii_("id");
}

View File

@ -19,7 +19,7 @@ package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import
import org.junit.*; import org.junit.*;
import gplx.xowa.apis.xowa.html.modules.*; import gplx.xowa.apis.xowa.html.modules.*;
import gplx.xowa.gui.views.*; import gplx.xowa.gui.views.*;
public class Xow_popup_hdr_finder_tst { public class Xow_popup_anchor_finder__hdr_tst {
@Before public void init() {fxt.Clear();} private Xop_popup_hdr_finder_fxt fxt = new Xop_popup_hdr_finder_fxt(); @Before public void init() {fxt.Clear();} private Xop_popup_hdr_finder_fxt fxt = new Xop_popup_hdr_finder_fxt();
@Test public void Basic() { @Test public void Basic() {
String src_str = String_.Concat_lines_nl_skip_last String src_str = String_.Concat_lines_nl_skip_last
@ -27,7 +27,7 @@ public class Xow_popup_hdr_finder_tst {
, "==b1==" , "==b1=="
, "c" , "c"
); );
fxt.Test_find(src_str, "b1", 2); fxt.Test_find(src_str, "b1", 1);
fxt.Test_find_not(src_str, "b"); fxt.Test_find_not(src_str, "b");
fxt.Test_find_not(src_str, "a"); fxt.Test_find_not(src_str, "a");
} }
@ -39,25 +39,41 @@ public class Xow_popup_hdr_finder_tst {
, "==d==" , "==d=="
, "e" , "e"
); );
fxt.Test_find(src_str, "d", 10); fxt.Test_find(src_str, "d", 9);
} }
@Test public void Eos() { @Test public void Eos() {
String src_str = String_.Concat_lines_nl_skip_last String src_str = String_.Concat_lines_nl_skip_last
( "a" ( "a"
, "==b==" , "==b=="
); );
fxt.Test_find(src_str, "b", 2); fxt.Test_find(src_str, "b", 1);
} }
@Test public void Bos() { @Test public void Bos() {
String src_str = String_.Concat_lines_nl_skip_last String src_str = String_.Concat_lines_nl_skip_last
( "==a==" ( "==a=="
, "b" , "b"
); );
fxt.Test_find(src_str, "a", 0); fxt.Test_find(src_str, "a", -1);
}
@Test public void Trim() {
String src_str = String_.Concat_lines_nl_skip_last
( "a"
, "== b =="
, "c"
);
fxt.Test_find(src_str, "b", 1);
}
@Test public void Ws() {
String src_str = String_.Concat_lines_nl_skip_last
( "a"
, "== b c =="
, "d"
);
fxt.Test_find(src_str, "b c", 1);
} }
} }
class Xop_popup_hdr_finder_fxt { class Xop_popup_hdr_finder_fxt {
private Xow_popup_hdr_finder finder = new Xow_popup_hdr_finder(); private Xow_popup_anchor_finder finder = new Xow_popup_anchor_finder();
public void Clear() { public void Clear() {
} }
public void Test_find_not(String src_str, String hdr_str) {Test_find(src_str, hdr_str, Bry_finder.Not_found);} public void Test_find_not(String src_str, String hdr_str) {Test_find(src_str, hdr_str, Bry_finder.Not_found);}

View File

@ -0,0 +1,50 @@
/*
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.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
import org.junit.*;
import gplx.xowa.apis.xowa.html.modules.*;
import gplx.xowa.gui.views.*;
public class Xow_popup_anchor_finder__id_tst {
@Before public void init() {fxt.Clear();} private Xop_popup_hdr_finder_fxt fxt = new Xop_popup_hdr_finder_fxt();
@Test public void Basic() {
String src_str = String_.Concat_lines_nl_skip_last
( "b"
, "<span id=\"a\"/>"
, "c"
);
fxt.Test_find(src_str, "a", 1);
fxt.Test_find_not(src_str, "b");
fxt.Test_find_not(src_str, "c");
}
@Test public void Ws() {
String src_str = String_.Concat_lines_nl_skip_last
( "b"
, "<span id = \"a\"/>"
, "c"
);
fxt.Test_find(src_str, "a", 1);
}
@Test public void Fail() {
String src_str = String_.Concat_lines_nl_skip_last
( "b"
, "<span xid = \"a\"/>"
, "c"
);
fxt.Test_find_not(src_str, "a");
}
}

View File

@ -1,49 +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.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
class Xow_popup_hdr_finder {
private byte[] src, hdr;
private int src_len;
private int nl_pos;
public int Find(byte[] src, int src_len, byte[] hdr, int bgn) {
this.src = src; this.src_len = src_len; this.hdr = hdr;
int lhs_bgn = bgn;
while (true) {
boolean found = Find_hdr(lhs_bgn);
if (found) return lhs_bgn;
lhs_bgn = Bry_finder.Find_fwd(src, Hdr_bgn, nl_pos, src_len);
if (lhs_bgn == Bry_.NotFound) break; // "\n=" not found; exit;
++lhs_bgn; // skip \n
}
return Bry_finder.Not_found;
}
private boolean Find_hdr(int lhs_bgn) {
nl_pos = Bry_finder.Find_fwd(src, Byte_ascii.NewLine, lhs_bgn, src_len); // look for \n
if (nl_pos == Bry_finder.Not_found) nl_pos = src_len - 1; // no more \n; set to last idx
int lhs_end = Bry_finder.Find_fwd_while(src, lhs_bgn, nl_pos, Byte_ascii.Eq); // skip eq; EX: "\n==="
int rhs_end = Bry_finder.Find_bwd_non_ws_or_end(src, nl_pos, lhs_end); // skip ws bwd; EX: "== \n"
int rhs_bgn = Bry_finder.Find_bwd_while(src, rhs_end, lhs_end, Byte_ascii.Eq); // skip eq
if (rhs_bgn < lhs_end) return false; // eq found, but < lhs_end; exit; EX: "\n== \n"
++rhs_bgn; // rhs_bgn is 1st char before eq; position at eq;
if (rhs_end - rhs_bgn < 1) return false; // no eq; exit; EX: "\n==abc \n"
int txt_end = Bry_finder.Find_bwd_non_ws_or_end(src, rhs_bgn, lhs_end); // skip ws before ==; EX: "\n==a ==\n"
int txt_bgn = Bry_finder.Find_fwd_while_space_or_tab(src, lhs_end, nl_pos); // skip spaces after eq
return Bry_.Eq(hdr, src, txt_bgn, txt_end); // check for strict match
}
private static final byte[] Hdr_bgn = Bry_.new_ascii_("\n=");
}

View File

@ -17,10 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*; package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
public class Xow_popup_itm implements Cancelable { public class Xow_popup_itm implements Cancelable {
public Xow_popup_itm(int id, byte[] page_href, int init_words_needed) { public Xow_popup_itm(int id, byte[] page_href, byte[] tooltip, int init_words_needed) {
this.popup_id = "popup_" + Int_.XtoStr(id); this.popup_id = "popup_" + Int_.XtoStr(id);
this.words_needed = init_words_needed; this.words_needed = init_words_needed;
this.page_href = page_href; this.page_href = page_href;
this.tooltip = tooltip;
} }
public boolean Canceled() {return canceled;} private boolean canceled = false; public boolean Canceled() {return canceled;} private boolean canceled = false;
public void Cancel() {canceled = true;} public void Cancel() {canceled = true;}
@ -39,6 +40,7 @@ public class Xow_popup_itm implements Cancelable {
} }
public String Popup_id() {return popup_id;} private String popup_id; public String Popup_id() {return popup_id;} private String popup_id;
public byte[] Popup_html() {return popup_html;} public void Popup_html_(byte[] v) {popup_html = v;} private byte[] popup_html; public byte[] Popup_html() {return popup_html;} public void Popup_html_(byte[] v) {popup_html = v;} private byte[] popup_html;
public byte[] Tooltip() {return tooltip;} private byte[] tooltip;
public byte[] Wiki_domain() {return wiki_domain;} private byte[] wiki_domain; public byte[] Wiki_domain() {return wiki_domain;} private byte[] wiki_domain;
public byte[] Page_href() {return page_href;} private byte[] page_href; public byte[] Page_href() {return page_href;} private byte[] page_href;
public Xoa_ttl Page_ttl() {return page_ttl;} private Xoa_ttl page_ttl; public Xoa_ttl Page_ttl() {return page_ttl;} private Xoa_ttl page_ttl;

View File

@ -60,11 +60,11 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
, Xoapi_popups.Evt_html_fmtr_popup_changed, Xoapi_popups.Evt_html_fmtr_viewed_changed, Xoapi_popups.Evt_html_fmtr_wiki_changed, Xoapi_popups.Evt_html_fmtr_next_sect_changed , Xoapi_popups.Evt_html_fmtr_popup_changed, Xoapi_popups.Evt_html_fmtr_viewed_changed, Xoapi_popups.Evt_html_fmtr_wiki_changed, Xoapi_popups.Evt_html_fmtr_next_sect_changed
); );
} }
public String Show_init(byte[] href, int id) { public String Show_init(int id, byte[] href, byte[] tooltip) {
Xoa_page cur_page = Cur_page(); Xoa_page cur_page = Cur_page();
Xog_tab_itm tab = cur_page.Tab(); Xog_tab_itm tab = cur_page.Tab();
if (tab != null && tab.Tab_is_loading()) return ""; // NOTE: tab is null when previewing if (tab != null && tab.Tab_is_loading()) return ""; // NOTE: tab is null when previewing
Xow_popup_itm itm = new Xow_popup_itm(id, href, show_init_word_count); Xow_popup_itm itm = new Xow_popup_itm(id, href, tooltip, show_init_word_count);
String rv = String_.new_utf8_(Get_popup_html(cur_page, itm)); String rv = String_.new_utf8_(Get_popup_html(cur_page, itm));
return tab != null && tab.Tab_is_loading() ? "" : rv; return tab != null && tab.Tab_is_loading() ? "" : rv;
} }
@ -84,7 +84,7 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
if (Bry_.HasAtBgn(href, gplx.xowa.parsers.lnkes.Xop_lnke_wkr.Bry_xowa_protocol)) return null; // ignore xowa-cmd if (Bry_.HasAtBgn(href, gplx.xowa.parsers.lnkes.Xop_lnke_wkr.Bry_xowa_protocol)) return null; // ignore xowa-cmd
synchronized (async_thread_guard) { synchronized (async_thread_guard) {
if (async_itm != null) async_itm.Cancel(); if (async_itm != null) async_itm.Cancel();
async_itm = new Xow_popup_itm(++async_id_next, href, show_init_word_count); async_itm = new Xow_popup_itm(++async_id_next, href, Bry_.Empty, show_init_word_count);
String id_str = async_itm.Popup_id(); String id_str = async_itm.Popup_id();
ThreadAdp_.invk_(id_str, this, Invk_show_popup_async).Start(); ThreadAdp_.invk_(id_str, this, Invk_show_popup_async).Start();
return id_str; return id_str;
@ -98,12 +98,12 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
app.Href_parser().Parse(temp_href, itm.Page_href(), wiki, cur_page.Ttl().Page_url()); app.Href_parser().Parse(temp_href, itm.Page_href(), wiki, cur_page.Ttl().Page_url());
Xow_wiki popup_wiki = app.Wiki_mgr().Get_by_key_or_null(temp_href.Wiki()); Xow_wiki popup_wiki = app.Wiki_mgr().Get_by_key_or_null(temp_href.Wiki());
popup_wiki.Init_assert(); popup_wiki.Init_assert();
Xoa_ttl popup_ttl = Xoa_ttl.parse_(popup_wiki, temp_href.Page()); Xoa_ttl popup_ttl = Xoa_ttl.parse_(popup_wiki, temp_href.Page_and_anchor());
if (ns_allowed_regy.Count() > 0 && !ns_allowed_regy.Has(ns_allowed_regy_key.Val_(popup_ttl.Ns().Id()))) return Bry_.Empty; if (ns_allowed_regy.Count() > 0 && !ns_allowed_regy.Has(ns_allowed_regy_key.Val_(popup_ttl.Ns().Id()))) return Bry_.Empty;
itm.Init(popup_wiki.Domain_bry(), popup_ttl); itm.Init(popup_wiki.Domain_bry(), popup_ttl);
Xoa_page popup_page = popup_wiki.Data_mgr().Get_page(popup_ttl, false); Xoa_page popup_page = popup_wiki.Data_mgr().Get_page(popup_ttl, false);
byte[] rv = popup_wiki.Html_mgr().Module_mgr().Popup_mgr().Parser().Parse(wiki, popup_page, cur_page.Tab(), itm); byte[] rv = popup_wiki.Html_mgr().Module_mgr().Popup_mgr().Parser().Parse(wiki, popup_page, cur_page.Tab(), itm);
Xog_win_itm__prog_href_mgr.Hover(app, cur_page, String_.new_utf8_(itm.Page_href())); // set page ttl again in prog bar; DATE:2014-06-28 Update_progress_bar(app, cur_page, itm);
return rv; return rv;
} }
} }
@ -112,6 +112,13 @@ public class Xow_popup_mgr implements GfoInvkAble, GfoEvObj {
return null; return null;
} }
} }
private static void Update_progress_bar(Xoa_app app, Xoa_page cur_page, Xow_popup_itm itm) {
byte[] href = itm.Page_href();
byte[] tooltip = itm.Tooltip();
if (Bry_.Len_gt_0(tooltip))
href = Bry_.Add(tooltip);
Xog_win_itm__prog_href_mgr.Hover(app, cur_page, String_.new_utf8_(href)); // set page ttl again in prog bar; DATE:2014-06-28
}
public void Show_popup_html(String cbk, byte[] mode, Xow_popup_itm popup_itm) { public void Show_popup_html(String cbk, byte[] mode, Xow_popup_itm popup_itm) {
Xog_tab_itm cur_tab = app.Gui_mgr().Browser_win().Active_tab(); Xog_tab_itm cur_tab = app.Gui_mgr().Browser_win().Active_tab();
cur_tab.Html_box().Html_js_eval_script(Xow_popup_mgr_.Bld_js_cmd(js_wtr, cbk, mode, popup_itm.Page_href(), popup_itm.Popup_html())); cur_tab.Html_box().Html_js_eval_script(Xow_popup_mgr_.Bld_js_cmd(js_wtr, cbk, mode, popup_itm.Page_href(), popup_itm.Popup_html()));

View File

@ -17,14 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*; package gplx.xowa.html.modules.popups; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; import gplx.xowa.html.modules.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.xowa.apis.xowa.html.modules.*; import gplx.xowa.apis.xowa.html.modules.*; import gplx.xowa.html.modules.popups.keeplists.*;
import gplx.xowa.gui.views.*; import gplx.xowa.gui.views.*; import gplx.xowa.parsers.hdrs.*;
import gplx.xowa.html.modules.popups.keeplists.*;
public class Xow_popup_parser { public class Xow_popup_parser {
private Xoa_app app; private Xow_wiki wiki; private Xop_parser parser; private Xoa_app app; private Xow_wiki wiki; private Xop_parser parser;
private Btrie_fast_mgr tmpl_trie, wtxt_trie; private Xop_tkn_mkr tkn_mkr; private Btrie_fast_mgr tmpl_trie, wtxt_trie; private Xop_tkn_mkr tkn_mkr;
private Xop_ctx tmpl_ctx; private Xop_root_tkn tmpl_root, wtxt_root; private Xot_compile_data tmpl_props = new Xot_compile_data(); private Xop_ctx tmpl_ctx; private Xop_root_tkn tmpl_root, wtxt_root; private Xot_compile_data tmpl_props = new Xot_compile_data();
private Xoh_html_wtr_ctx hctx = Xoh_html_wtr_ctx.Popup; private Xoh_html_wtr_ctx hctx = Xoh_html_wtr_ctx.Popup;
private Xow_popup_anchor_finder hdr_finder = new Xow_popup_anchor_finder();
public Xow_popup_cfg Cfg() {return cfg;} private Xow_popup_cfg cfg = new Xow_popup_cfg(); public Xow_popup_cfg Cfg() {return cfg;} private Xow_popup_cfg cfg = new Xow_popup_cfg();
public Xow_popup_wrdx_mkr Wrdx_mkr() {return wrdx_mkr;} private Xow_popup_wrdx_mkr wrdx_mkr = new Xow_popup_wrdx_mkr(); public Xow_popup_wrdx_mkr Wrdx_mkr() {return wrdx_mkr;} private Xow_popup_wrdx_mkr wrdx_mkr = new Xow_popup_wrdx_mkr();
public Xow_popup_html_mkr Html_mkr() {return html_mkr;} private Xow_popup_html_mkr html_mkr = new Xow_popup_html_mkr(); public Xow_popup_html_mkr Html_mkr() {return html_mkr;} private Xow_popup_html_mkr html_mkr = new Xow_popup_html_mkr();
@ -69,7 +69,8 @@ public class Xow_popup_parser {
} }
public byte[] Parse(Xow_wiki cur_wiki, Xoa_page page, Xog_tab_itm cur_tab, Xow_popup_itm popup_itm) { // NOTE: must pass cur_wiki for xwiki label; DATE:2014-07-02 public byte[] Parse(Xow_wiki cur_wiki, Xoa_page page, Xog_tab_itm cur_tab, Xow_popup_itm popup_itm) { // NOTE: must pass cur_wiki for xwiki label; DATE:2014-07-02
byte[] tmpl_src = page.Data_raw(); int tmpl_len = tmpl_src.length; if (tmpl_len == 0) return Bry_.Empty; byte[] tmpl_src = page.Data_raw(); int tmpl_len = tmpl_src.length; if (tmpl_len == 0) return Bry_.Empty;
int tmpl_bgn = Xop_parser_.Doc_bgn_bos; int tmpl_bgn_orig = Xow_popup_parser_.Tmpl_bgn_get_(app, popup_itm, page.Ttl(), hdr_finder, tmpl_src, tmpl_len);
int tmpl_bgn = tmpl_bgn_orig;
int tmpl_read_len_cur = cfg.Tmpl_read_len(); int tmpl_read_len_cur = cfg.Tmpl_read_len();
wrdx_mkr.Init(); wrdx_mkr.Init();
data.Init(cfg, popup_itm, tmpl_len); data.Init(cfg, popup_itm, tmpl_len);
@ -100,8 +101,8 @@ public class Xow_popup_parser {
} }
tmpl_bgn = new_tmpl_bgn; tmpl_bgn = new_tmpl_bgn;
data.Tmpl_loop_count_add(); data.Tmpl_loop_count_add();
if ( tmpl_bgn == tmpl_len // end of template if ( tmpl_bgn == tmpl_len // end of template
|| tmpl_bgn > data.Tmpl_max() // too much read; stop and give whatever's available || tmpl_bgn - tmpl_bgn_orig > data.Tmpl_max() // too much read; stop and give whatever's available
) )
break; break;
} }
@ -200,6 +201,13 @@ public class Xow_popup_parser {
} }
} }
class Xow_popup_parser_ { class Xow_popup_parser_ {
public static int Tmpl_bgn_get_(Xoa_app app, Xow_popup_itm itm, Xoa_ttl page_ttl, Xow_popup_anchor_finder hdr_finder, byte[] src, int src_len) {
int rv = Xop_parser_.Doc_bgn_bos; if (itm.Mode_all()) return rv;
byte[] anch = itm.Page_href()[0] == Byte_ascii.Hash ? Bry_.Mid(app.Encoder_mgr().Href().Decode(itm.Page_href()), 1) : page_ttl.Anch_txt();
if (anch == null) return rv;
int hdr_bgn = hdr_finder.Find(src, src_len, anch, rv); // NOTE: starting search from Xop_parser_.Doc_bgn_bos
return hdr_bgn == Bry_finder.Not_found ? rv : hdr_bgn;
}
public static int Calc_read_len(Xop_ctx ctx, int tmpl_read_cur, int tmpl_read_len, byte[] src, int bgn, int end) {// DATE:2014-07-19 public static int Calc_read_len(Xop_ctx ctx, int tmpl_read_cur, int tmpl_read_len, byte[] src, int bgn, int end) {// DATE:2014-07-19
int rv_default = tmpl_read_cur + tmpl_read_len; int rv_default = tmpl_read_cur + tmpl_read_len;
Xop_tkn_itm tkn = Get_expensive_dangling_tkn(ctx); Xop_tkn_itm tkn = Get_expensive_dangling_tkn(ctx);

View File

@ -370,6 +370,32 @@ public class Xow_popup_parser_tst {
, "<h2>c</h2>" , "<h2>c</h2>"
)); ));
} }
@Test public void Anchor() {
fxt.Test_parse(String_.Concat_lines_nl_skip_last
( "a b c d"
, ""
, "== e =="
, "f g h i"
), "#e", String_.Concat_lines_nl_skip_last
( "<h2> e </h2>"
, ""
, "<p>f"
, "</p>"
));
}
@Test public void Anchor_underline() {
fxt.Test_parse(String_.Concat_lines_nl_skip_last
( "a b c d"
, ""
, "== e f =="
, "g h i"
), "#e_f", String_.Concat_lines_nl_skip_last
( "<h2> e f </h2>"
, ""
, "<p>g"
, "</p>"
));
}
@Test public void Tmpl_tkn_max() { @Test public void Tmpl_tkn_max() {
fxt.Init_tmpl_tkn_max_(5).Init_page("Template:A", "a"); // eval fxt.Init_tmpl_tkn_max_(5).Init_page("Template:A", "a"); // eval
fxt.Test_parse fxt.Test_parse
@ -469,10 +495,11 @@ class Xop_popup_parser_fxt {
Tfds.Eq_ary(expd, Int_obj_ref.Ary_xto_int_ary(ids)); Tfds.Eq_ary(expd, Int_obj_ref.Ary_xto_int_ary(ids));
return this; return this;
} }
public void Test_parse(String raw, String expd) { public void Test_parse(String raw, String expd) {Test_parse(raw, "Test_1", expd);}
Xoa_page page = Xoa_page.create_(wiki, Xoa_ttl.parse_(wiki, Bry_.new_ascii_("Test_1"))); public void Test_parse(String raw, String ttl, String expd) {
Xoa_page page = Xoa_page.create_(wiki, Xoa_ttl.parse_(wiki, Bry_.new_ascii_(ttl)));
page.Data_raw_(Bry_.new_utf8_(raw)); page.Data_raw_(Bry_.new_utf8_(raw));
Xow_popup_itm itm = new Xow_popup_itm(1, Bry_.new_utf8_(raw), word_min); Xow_popup_itm itm = new Xow_popup_itm(1, Bry_.new_utf8_(raw), Bry_.Empty, word_min);
itm.Init(wiki.Domain_bry(), page.Ttl()); itm.Init(wiki.Domain_bry(), page.Ttl());
byte[] actl = parser.Parse(wiki, page, null, itm); byte[] actl = parser.Parse(wiki, page, null, itm);
Tfds.Eq_str_lines(expd, String_.new_utf8_(actl)); Tfds.Eq_str_lines(expd, String_.new_utf8_(actl));

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; package gplx.xowa.html.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.hdrs.*;
public class Xow_hdr_mgr { public class Xow_hdr_mgr {
private Xow_wiki wiki; private Xoa_page page; private Xow_wiki wiki; private Xoa_page page;
private Xop_hdr_tkn[] hdrs_ary = new Xop_hdr_tkn[0]; private int hdrs_max, hdrs_len; private Xop_hdr_tkn[] hdrs_ary = new Xop_hdr_tkn[0]; private int hdrs_max, hdrs_len;

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.html.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*; package gplx.xowa.html.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.html.*;
import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.apos.*; import gplx.xowa.parsers.amps.*; import gplx.xowa.parsers.hdrs.*;
public class Xow_toc_mgr implements Bry_fmtr_arg { public class Xow_toc_mgr implements Bry_fmtr_arg {
private static final int Toc_levels = 32; // assume 6 max levels * 5 max heading (9999.); add 2 for good measure private static final int Toc_levels = 32; // assume 6 max levels * 5 max heading (9999.); add 2 for good measure
private Xoa_page page; private Xop_toc_itm[] path_ary; private Bry_bfr path_bfr = Bry_bfr.reset_(Toc_levels); private Xoa_page page; private Xop_toc_itm[] path_ary; private Bry_bfr path_bfr = Bry_bfr.reset_(Toc_levels);

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.langs; import gplx.*; import gplx.xowa.*; package gplx.xowa.langs; import gplx.*; import gplx.xowa.*;
import gplx.core.btries.*; import gplx.intl.*; import gplx.core.btries.*; import gplx.intl.*; import gplx.xowa.xtns.pfuncs.*;
public class Xol_func_name_regy { public class Xol_func_name_regy {
private Xol_func_name_itm finder = new Xol_func_name_itm(); private Xol_func_name_itm finder = new Xol_func_name_itm();
private Btrie_slim_mgr cs_trie = Btrie_slim_mgr.cs_(), ci_trie = Btrie_slim_mgr.ci_utf_8_(); private Btrie_slim_mgr cs_trie = Btrie_slim_mgr.cs_(), ci_trie = Btrie_slim_mgr.ci_utf_8_();

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.apos; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_apos_log { public class Xop_apos_log {
private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "apos"); private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "apos");
public static final Gfo_msg_itm public static final Gfo_msg_itm
@ -23,7 +23,4 @@ public class Xop_apos_log {
, Dangling_apos = Gfo_msg_itm_.new_note_(owner, "Dangling_apos") , Dangling_apos = Gfo_msg_itm_.new_note_(owner, "Dangling_apos")
, Multiple_apos = Gfo_msg_itm_.new_note_(owner, "Multiple_apos") , Multiple_apos = Gfo_msg_itm_.new_note_(owner, "Multiple_apos")
; ;
// public final RscStrItm_arg
// Dangling_apos_typ = new RscStrItm_arg(_mgr, "closing_typ")
// ;
} }

View File

@ -15,8 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.apos; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.xowa.parsers.apos.*;
public class Xop_apos_tkn_chkr extends Xop_tkn_chkr_base { public class Xop_apos_tkn_chkr extends Xop_tkn_chkr_base {
@Override public Class<?> TypeOf() {return Xop_apos_tkn.class;} @Override public Class<?> TypeOf() {return Xop_apos_tkn.class;}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_apos;} @Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_apos;}

View File

@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.parsers.apos; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; package gplx.xowa.parsers.apos; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import org.junit.*;
import gplx.xowa.parsers.lists.*;
public class Xop_apos_wkr_tst { public class Xop_apos_wkr_tst {
private Xop_fxt fxt = new Xop_fxt(); private Xop_fxt fxt = new Xop_fxt();
@Test public void Basic() { @Test public void Basic() {

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_hdr_log {
private static final Gfo_msg_grp owner = Gfo_msg_grp_.new_(Xoa_app_.Nde, "hdr");
public static final Gfo_msg_itm
Dangling_hdr = Gfo_msg_itm_.new_warn_(owner, "dangling_hdr")
, Mismatched = Gfo_msg_itm_.new_warn_(owner, "mismatched")
, Len_1 = Gfo_msg_itm_.new_warn_(owner, "len_1")
, Len_7_or_more = Gfo_msg_itm_.new_warn_(owner, "len_7_or_more")
;
}

View File

@ -15,9 +15,9 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.btries.*; import gplx.core.btries.*;
class Xop_hdr_lxr implements Xop_lxr { public class Xop_hdr_lxr implements Xop_lxr {
public byte Lxr_tid() {return Xop_lxr_.Tid_hdr;} public byte Lxr_tid() {return Xop_lxr_.Tid_hdr;}
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook_bgn, this);} static final byte[] Hook_bgn = new byte[] {Byte_ascii.NewLine, Byte_ascii.Eq}; public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {core_trie.Add(Hook_bgn, this);} static final byte[] Hook_bgn = new byte[] {Byte_ascii.NewLine, Byte_ascii.Eq};
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {} public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_hdr_tkn extends Xop_tkn_itm_base { public class Xop_hdr_tkn extends Xop_tkn_itm_base {
public Xop_hdr_tkn(int bgn, int end, int hdr_len) {this.Tkn_ini_pos(false, bgn, end); this.hdr_len = hdr_len;} public Xop_hdr_tkn(int bgn, int end, int hdr_len) {this.Tkn_ini_pos(false, bgn, end); this.hdr_len = hdr_len;}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_hdr;} @Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_hdr;}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_hdr_tkn_chkr extends Xop_tkn_chkr_base { public class Xop_hdr_tkn_chkr extends Xop_tkn_chkr_base {
@Override public Class<?> TypeOf() {return Xop_hdr_tkn.class;} @Override public Class<?> TypeOf() {return Xop_hdr_tkn.class;}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_hdr;} @Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_hdr;}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_hdr_wkr implements Xop_ctx_wkr { public class Xop_hdr_wkr implements Xop_ctx_wkr {
public void Ctor_ctx(Xop_ctx ctx) {} public void Ctor_ctx(Xop_ctx ctx) {}
public void Page_bgn(Xop_ctx ctx, Xop_root_tkn root) {} public void Page_bgn(Xop_ctx ctx, Xop_root_tkn root) {}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import org.junit.*;
public class Xop_hdr_wkr_basic_tst { public class Xop_hdr_wkr_basic_tst {
@Before public void init() {fxt.Reset();} private Xop_fxt fxt = new Xop_fxt(); @Before public void init() {fxt.Reset();} private Xop_fxt fxt = new Xop_fxt();
@ -106,14 +106,14 @@ public class Xop_hdr_wkr_basic_tst {
, "" , ""
)); ));
} }
// @Test public void Pfunc() {// PAGE:en.w:Wikipedia:WikiProject_Articles_for_creation/Submissions/List DATE:2014-06-24 @Test public void Pfunc() {// multiple = should not be interpreted as key-val equals; PAGE:en.w:Wikipedia:Picture_of_the_day/June_2014 DATE:2014-07-21
// fxt.Test_parse_page_all_str fxt.Test_parse_page_all_str
// ( "{{#if:exists|==a==|no}}" ( "{{#if:exists|==a==|no}}"
// , String_.Concat_lines_nl_skip_last , String_.Concat_lines_nl_skip_last
// ( "<h2>a</h2>" ( "<h2>a</h2>"
// , "" , ""
// )); ));
// } }
// @Test public void Hdr_inside_dangling_tmpl_fix_2() { // PURPOSE: hdr == inside dangling tmpl; DATE:2014-06-10 // @Test public void Hdr_inside_dangling_tmpl_fix_2() { // PURPOSE: hdr == inside dangling tmpl; DATE:2014-06-10
// fxt.Init_defn_add("Print", "{{{1}}}"); // fxt.Init_defn_add("Print", "{{{1}}}");
// fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last // fxt.Test_parse_page_all_str(String_.Concat_lines_nl_skip_last

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import org.junit.*;
public class Xop_hdr_wkr_para_tst { public class Xop_hdr_wkr_para_tst {
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt(); @Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();

View File

@ -15,9 +15,9 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import gplx.core.btries.*; import gplx.core.btries.*;
class Xop_list_lxr implements Xop_lxr {//20111222 public class Xop_list_lxr implements Xop_lxr {//20111222
public byte Lxr_tid() {return Xop_lxr_.Tid_list;} public byte Lxr_tid() {return Xop_lxr_.Tid_list;}
public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {Add_ary(core_trie, this, Xop_list_tkn_.Hook_ul, Xop_list_tkn_.Hook_ol, Xop_list_tkn_.Hook_dt, Xop_list_tkn_.Hook_dd);} public void Init_by_wiki(Xow_wiki wiki, Btrie_fast_mgr core_trie) {Add_ary(core_trie, this, Xop_list_tkn_.Hook_ul, Xop_list_tkn_.Hook_ol, Xop_list_tkn_.Hook_dt, Xop_list_tkn_.Hook_dd);}
public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {} public void Init_by_lang(Xol_lang lang, Btrie_fast_mgr core_trie) {}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_list_tkn extends Xop_tkn_itm_base { public class Xop_list_tkn extends Xop_tkn_itm_base {
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_list;} @Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_list;}
public int List_uid() {return list_uid;} public Xop_list_tkn List_uid_(int v) {list_uid = v; return this;} private int list_uid = -1; public int List_uid() {return list_uid;} public Xop_list_tkn List_uid_(int v) {list_uid = v; return this;} private int list_uid = -1;

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_list_tkn_ { public class Xop_list_tkn_ {
public static final byte[] public static final byte[]
Hook_ul = new byte[] {Byte_ascii.NewLine, Byte_ascii.Asterisk}, Hook_ol = new byte[] {Byte_ascii.NewLine, Byte_ascii.Hash} Hook_ul = new byte[] {Byte_ascii.NewLine, Byte_ascii.Asterisk}, Hook_ol = new byte[] {Byte_ascii.NewLine, Byte_ascii.Hash}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_list_tkn_chkr extends Xop_tkn_chkr_base { public class Xop_list_tkn_chkr extends Xop_tkn_chkr_base {
@Override public Class<?> TypeOf() {return Xop_list_tkn.class;} @Override public Class<?> TypeOf() {return Xop_list_tkn.class;}
@Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_list;} @Override public byte Tkn_tid() {return Xop_tkn_itm_.Tid_list;}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_list_wkr implements Xop_ctx_wkr { public class Xop_list_wkr implements Xop_ctx_wkr {
private int listId = 0; byte[] curSymAry = new byte[Max_list_depth]; int curSymLen = 0; byte[] prvSymAry = Bry_.Empty; private int listId = 0; byte[] curSymAry = new byte[Max_list_depth]; int curSymLen = 0; byte[] prvSymAry = Bry_.Empty;
private HierPosAryBldr posBldr = new HierPosAryBldr(Max_list_depth); private HierPosAryBldr posBldr = new HierPosAryBldr(Max_list_depth);
@ -203,47 +203,3 @@ public class Xop_list_wkr implements Xop_ctx_wkr {
} }
public static final int Max_list_depth = 256; public static final int Max_list_depth = 256;
} }
class Xop_list_wkr_ {
public static byte[] MakeSymAry(byte[] curSymAry, int curSymLen) {
byte[] rv = new byte[curSymLen];
for (int i = 0; i < curSymLen; i++)
rv[i] = curSymAry[i];
return rv;
}
public static byte Compare_normalize(byte b) { // convert : to ; for sake of determining levels; EX: ";:" is actually same group
switch (b) {
case Byte_ascii.Asterisk:
case Byte_ascii.Hash:
case Byte_ascii.Semic: return b;
case Byte_ascii.Colon: return Byte_ascii.Semic;
default: throw Err_.unhandled(b);
}
}
public static void Close_list_if_present(Xop_ctx ctx, Xop_root_tkn root, byte[] src, int bgn_pos, int cur_pos) {
if (ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_tmpl_invk) != Xop_ctx.Stack_not_found) return; // list is inside template; do not close;
while (true) { // close all list tkns on stack; EX: *** n should close all 3 stars; used to only close 1
int acs_pos = -1, acs_len = ctx.Stack_len();
for (int i = acs_len - 1; i > -1; i--) { // find auto-close pos
byte cur_acs_tid = ctx.Stack_get(i).Tkn_tid();
switch (cur_acs_tid) {
case Xop_tkn_itm_.Tid_tblw_tb: // do not bypass tbl_elem; EX: ": {| |- *a |b }" should not close ":"
case Xop_tkn_itm_.Tid_tblw_tc:
case Xop_tkn_itm_.Tid_tblw_te:
case Xop_tkn_itm_.Tid_tblw_td:
case Xop_tkn_itm_.Tid_tblw_th:
case Xop_tkn_itm_.Tid_tblw_tr:
i = -1; // force break;
break;
case Xop_tkn_itm_.Tid_list:
acs_pos = i;
break;
default:
break;
}
}
// int acs_idx = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_list);
if (acs_pos == Xop_ctx.Stack_not_found) break; // no more list tokens found
ctx.Stack_pop_til(root, src, acs_pos, true, bgn_pos, cur_pos, Xop_tkn_itm_.Tid_list);
}
}
}

View 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.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
public class Xop_list_wkr_ {
public static byte[] MakeSymAry(byte[] curSymAry, int curSymLen) {
byte[] rv = new byte[curSymLen];
for (int i = 0; i < curSymLen; i++)
rv[i] = curSymAry[i];
return rv;
}
public static byte Compare_normalize(byte b) { // convert : to ; for sake of determining levels; EX: ";:" is actually same group
switch (b) {
case Byte_ascii.Asterisk:
case Byte_ascii.Hash:
case Byte_ascii.Semic: return b;
case Byte_ascii.Colon: return Byte_ascii.Semic;
default: throw Err_.unhandled(b);
}
}
public static void Close_list_if_present(Xop_ctx ctx, Xop_root_tkn root, byte[] src, int bgn_pos, int cur_pos) {
if (ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_tmpl_invk) != Xop_ctx.Stack_not_found) return; // list is inside template; do not close;
while (true) { // close all list tkns on stack; EX: *** n should close all 3 stars; used to only close 1
int acs_pos = -1, acs_len = ctx.Stack_len();
for (int i = acs_len - 1; i > -1; i--) { // find auto-close pos
byte cur_acs_tid = ctx.Stack_get(i).Tkn_tid();
switch (cur_acs_tid) {
case Xop_tkn_itm_.Tid_tblw_tb: // do not bypass tbl_elem; EX: ": {| |- *a |b }" should not close ":"
case Xop_tkn_itm_.Tid_tblw_tc:
case Xop_tkn_itm_.Tid_tblw_te:
case Xop_tkn_itm_.Tid_tblw_td:
case Xop_tkn_itm_.Tid_tblw_th:
case Xop_tkn_itm_.Tid_tblw_tr:
i = -1; // force break;
break;
case Xop_tkn_itm_.Tid_list:
acs_pos = i;
break;
default:
break;
}
}
// int acs_idx = ctx.Stack_idx_typ(Xop_tkn_itm_.Tid_list);
if (acs_pos == Xop_ctx.Stack_not_found) break; // no more list tokens found
ctx.Stack_pop_til(root, src, acs_pos, true, bgn_pos, cur_pos, Xop_tkn_itm_.Tid_list);
}
}
}

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import org.junit.*;
public class Xop_list_wkr_basic_tst { public class Xop_list_wkr_basic_tst {
private Xop_fxt fxt = new Xop_fxt(); private Xop_fxt fxt = new Xop_fxt();

View File

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa; import gplx.*; package gplx.xowa.parsers.lists; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*;
import org.junit.*; import org.junit.*;
public class Xop_list_wkr_para_tst { public class Xop_list_wkr_para_tst {
@Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt(); @Before public void init() {fxt.Reset(); fxt.Init_para_y_();} private Xop_fxt fxt = new Xop_fxt();

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