mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.7.2.1'
This commit is contained in:
@@ -16,38 +16,34 @@ 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.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.redirects.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.tocs.*;
|
||||
import gplx.xowa.wikis.pages.dbs.*; import gplx.xowa.wikis.pages.hdumps.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xoh_page implements Xoa_page {
|
||||
// core
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Xoa_url Url() {return page_url;} private Xoa_url page_url;
|
||||
public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public Xow_wiki Wiki() {return wiki;} private Xow_wiki wiki;
|
||||
public Xoa_url Url() {return page_url;} private Xoa_url page_url;
|
||||
public Xoa_ttl Ttl() {return page_ttl;} private Xoa_ttl page_ttl;
|
||||
public Xopg_db_data Db() {return db;} private final Xopg_db_data db = new Xopg_db_data();
|
||||
public Xopg_redirect_data Redirect() {return redirect;} private final Xopg_redirect_data redirect = new Xopg_redirect_data();
|
||||
public Xopg_html_data Html_data() {return html;} private final Xopg_html_data html = new Xopg_html_data();
|
||||
public Xopg_hdump_data Hdump_mgr() {return hdump;} private final Xopg_hdump_data hdump = new Xopg_hdump_data();
|
||||
|
||||
public void Xtn_gallery_packed_exists_y_() {}
|
||||
public boolean Xtn__timeline_exists() {return xtn__timeline_exists;} private boolean xtn__timeline_exists; public void Xtn__timeline_exists_y_() {xtn__timeline_exists = true;}
|
||||
public boolean Xtn__gallery_exists() {return xtn__gallery_exists;} private boolean xtn__gallery_exists; public void Xtn__gallery_exists_y_() {xtn__gallery_exists = true;}
|
||||
|
||||
// props
|
||||
public boolean Exists() {return exists;} public Xoh_page Exists_n_() {exists = false; return this;} private boolean exists = true;
|
||||
public int Page_id() {return page_id;} private int page_id;
|
||||
public byte[] Body() {return body;} public void Body_(byte[] v) {this.body = v;} private byte[] body;
|
||||
public int Body_zip_tid() {return body_zip_tid;} private int body_zip_tid;
|
||||
public int Body_hzip_tid() {return body_hzip_tid;} private int body_hzip_tid;
|
||||
public byte[] Display_ttl() {return display_ttl;} private byte[] display_ttl;
|
||||
public byte[] Content_sub() {return content_sub;} private byte[] content_sub;
|
||||
public byte[] Sidebar_div() {return sidebar_div;} private byte[] sidebar_div;
|
||||
public Xoh_section_mgr Section_mgr() {return section_mgr;} private final Xoh_section_mgr section_mgr = new Xoh_section_mgr();
|
||||
public Xoh_img_mgr Img_mgr() {return img_mgr;} private Xoh_img_mgr img_mgr = new Xoh_img_mgr();
|
||||
public Ordered_hash Redlink_uids() {return redlink_uids;} private final Ordered_hash redlink_uids = Ordered_hash_.New();
|
||||
public Xohd_img_itm__base[] Img_itms() {return img_itms;} public void Img_itms_(Xohd_img_itm__base[] v) {this.img_itms = v;} private Xohd_img_itm__base[] img_itms = Xohd_img_itm__base.Ary_empty;
|
||||
public Ordered_hash Gallery_itms() {return gallery_itms;} private Ordered_hash gallery_itms = Ordered_hash_.New();
|
||||
public Xopg_module_mgr Head_mgr() {return head_mgr;} private Xopg_module_mgr head_mgr = new Xopg_module_mgr();
|
||||
public void Xtn_gallery_packed_exists_y_() {}
|
||||
public boolean Xtn__timeline_exists() {return xtn__timeline_exists;} private boolean xtn__timeline_exists; public void Xtn__timeline_exists_y_() {xtn__timeline_exists = true;}
|
||||
public boolean Xtn__gallery_exists() {return xtn__gallery_exists;} private boolean xtn__gallery_exists; public void Xtn__gallery_exists_y_() {xtn__gallery_exists = true;}
|
||||
public Xopg_revision_data Revision_data() {return revision_data;} private Xopg_revision_data revision_data = new Xopg_revision_data();
|
||||
public Xopg_html_data Html_data() {return html_data;} private Xopg_html_data html_data = new Xopg_html_data();
|
||||
public byte[] Redirect_to_ttl() {return redirect_to_ttl;} private byte[] redirect_to_ttl; public void Redirect_to_ttl_(byte[] v) {this.redirect_to_ttl = v;}
|
||||
|
||||
// util
|
||||
public Xopg_lnki_list Redlink_list() {return redlink_list;} private Xopg_lnki_list redlink_list = new Xopg_lnki_list();
|
||||
public Xoa_page__commons_mgr Commons_mgr() {return commons_mgr;} private final Xoa_page__commons_mgr commons_mgr = new Xoa_page__commons_mgr();
|
||||
public int Exec_tid() {return exec_tid;} private int exec_tid = Xof_exec_tid.Tid_wiki_page;
|
||||
public byte[] Html_head_xtn() {return html_head_xtn;} public void Html_head_xtn_(byte[] v) {html_head_xtn = v;} private byte[] html_head_xtn = Bry_.Empty; // drd:web_browser
|
||||
@@ -55,31 +51,41 @@ public class Xoh_page implements Xoa_page {
|
||||
public void Init(Xow_wiki wiki, Xoa_url page_url, Xoa_ttl page_ttl, int page_id) {
|
||||
this.wiki = wiki; this.page_url = page_url; this.page_ttl = page_ttl; this.page_id = page_id;
|
||||
this.Clear();
|
||||
redlink_list.Disabled_(page_ttl.Ns().Id_is_module()); // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
html.Redlink_list().Disabled_(page_ttl.Ns().Id_is_module()); // never redlink in Module ns; particularly since Lua has multi-line comments for [[ ]]
|
||||
hdump.Toc_wtr().Init(wiki.Lang().Msg_mgr().Itm_by_id_or_null(gplx.xowa.langs.msgs.Xol_msg_itm_.Id_toc).Val(), page_url.Raw());
|
||||
}
|
||||
public void Ctor_by_db(int head_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, int zip_tid, int hzip_tid, byte[] body) {
|
||||
head_mgr.Flag_(head_flag);
|
||||
this.display_ttl = display_ttl; this.content_sub = content_sub; this.sidebar_div = sidebar_div; this.body = body; this.body_zip_tid = zip_tid; this.body_hzip_tid = hzip_tid;
|
||||
this.display_ttl = display_ttl; this.content_sub = content_sub; this.sidebar_div = sidebar_div;
|
||||
db.Html().Html_bry_(body);
|
||||
db.Html().Zip_tids_(zip_tid, hzip_tid);
|
||||
}
|
||||
public Xoh_page Ctor_by_page(Bry_bfr tmp_bfr, Xoae_page page) {
|
||||
this.page_id = page.Revision_data().Id();
|
||||
this.page_id = page.Db().Page().Id();
|
||||
this.wiki = page.Wiki();
|
||||
this.body = page.Hdump_data().Body();
|
||||
db.Html().Html_bry_(page.Db().Html().Html_bry());
|
||||
this.page_url = page.Url();
|
||||
Xopg_html_data html_data = page.Html_data();
|
||||
Xoh_head_mgr mod_mgr = html_data.Head_mgr();
|
||||
Xopg_html_data html = page.Html_data();
|
||||
html.Init_by_page(page.Ttl());
|
||||
Xoh_head_mgr mod_mgr = html.Head_mgr();
|
||||
head_mgr.Init(mod_mgr.Itm__mathjax().Enabled(), mod_mgr.Itm__popups().Bind_hover_area(), mod_mgr.Itm__gallery().Enabled(), mod_mgr.Itm__hiero().Enabled());
|
||||
this.display_ttl = html_data.Display_ttl();
|
||||
this.content_sub = html_data.Content_sub();
|
||||
this.sidebar_div = Xoh_page_.Save_sidebars(tmp_bfr, page, html_data);
|
||||
this.display_ttl = html.Display_ttl();
|
||||
this.content_sub = html.Content_sub();
|
||||
this.sidebar_div = Xoh_page_.Save_sidebars(tmp_bfr, page, html);
|
||||
return this;
|
||||
}
|
||||
public void Clear() {
|
||||
this.body_zip_tid = -1; this.body_hzip_tid = -1;
|
||||
redirect.Clear();
|
||||
html.Clear();
|
||||
hdump.Clear();
|
||||
|
||||
display_ttl = content_sub = sidebar_div = Bry_.Empty;
|
||||
img_itms = Xohd_img_itm__base.Ary_empty;
|
||||
head_mgr.Clear(); gallery_itms.Clear(); redlink_uids.Clear(); commons_mgr.Clear();
|
||||
head_mgr.Clear(); commons_mgr.Clear();
|
||||
section_mgr.Clear(); img_mgr.Clear();
|
||||
redlink_list.Clear();
|
||||
}
|
||||
public static Xoh_page New_missing() {
|
||||
Xoh_page rv = new Xoh_page();
|
||||
rv.Db().Page().Exists_n_();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
package gplx.xowa.htmls; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xoh_page_ {
|
||||
public static byte[] Save_sidebars(Bry_bfr tmp_bfr, Xoae_page page, Xopg_html_data html_data) {
|
||||
Xopg_xtn_skin_mgr mgr = html_data.Xtn_skin_mgr();
|
||||
|
||||
@@ -20,6 +20,7 @@ import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.langs.htmls.*; import gplx.xowa.langs.vnts.*; import gplx.xowa.htmls.core.htmls.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.domains.*; import gplx.xowa.parsers.*; import gplx.xowa.xtns.wdatas.*;
|
||||
import gplx.xowa.xtns.pagebanners.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.htmls.portal.*;
|
||||
public class Xoh_page_wtr_wkr {
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); private final Object thread_lock_1 = new Object(), thread_lock_2 = new Object();
|
||||
@@ -73,7 +74,7 @@ public class Xoh_page_wtr_wkr {
|
||||
if (root_dir_bry == null) this.root_dir_bry = app.Fsys_mgr().Root_dir().To_http_file_bry();
|
||||
Xoa_ttl page_ttl = page.Ttl(); int page_ns_id = page_ttl.Ns().Id();
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), page_ns_id, page_ttl.Page_db());
|
||||
DateAdp modified_on = page.Revision_data().Modified_on();
|
||||
DateAdp modified_on = page.Db().Page().Modified_on();
|
||||
byte[] modified_on_msg = wiki.Msg_mgr().Val_by_id_args(Xol_msg_itm_.Id_portal_lastmodified, modified_on.XtoStr_fmt_yyyy_MM_dd(), modified_on.XtoStr_fmt_HHmm());
|
||||
byte[] page_body_class = Xoh_page_body_cls.Calc(tmp_bfr, page_ttl, page_tid);
|
||||
byte[] html_content_editable = wiki.Gui_mgr().Cfg_browser().Content_editable() ? Content_editable_bry : Bry_.Empty;
|
||||
@@ -84,7 +85,7 @@ public class Xoh_page_wtr_wkr {
|
||||
byte[] converted_title = vnt_mgr.Convert_lang().Converted_title(); // prefer converted title
|
||||
if (converted_title == null) // converted title does not exist; use regular page title and convert it
|
||||
converted_title = vnt_mgr.Convert_lang().Auto_convert(vnt_mgr.Cur_itm(), page_ttl.Page_txt());
|
||||
page_ttl = Xoa_ttl.parse(wiki, page_ttl.Ns().Id(), converted_title);
|
||||
page_ttl = Xoa_ttl.Parse(wiki, page_ttl.Ns().Id(), converted_title);
|
||||
}
|
||||
byte[] page_name = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, null); // NOTE: page_name does not show display_title (<i>). always pass in null
|
||||
byte[] page_display_title = Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, page_ttl, page.Html_data().Display_ttl());
|
||||
@@ -92,12 +93,12 @@ public class Xoh_page_wtr_wkr {
|
||||
Xow_portal_mgr portal_mgr = wiki.Html_mgr().Portal_mgr().Init_assert();
|
||||
fmtr.Bld_bfr_many(bfr
|
||||
, root_dir_bry, Xoa_app_.Version, Xoa_app_.Build_date, app.Tcp_server().Running_str()
|
||||
, page.Revision_data().Id()
|
||||
, page.Db().Page().Id()
|
||||
, page_name, page.Html_data().Page_heading().Init(page.Html_data(), page_display_title)
|
||||
, modified_on_msg
|
||||
, mgr.Css_common_bry(), mgr.Css_wiki_bry(), page.Html_data().Head_mgr().Init(app, wiki, page).Init_dflts()
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(ctx, page, hctx, page_data), page_body_class, html_content_editable
|
||||
, page_data, wdata_lang_wtr
|
||||
, page.Lang().Dir_ltr_bry(), page.Html_data().Indicators(), page_content_sub, wiki.Html_mgr().Portal_mgr().Div_jump_to(), wiki.Xtn_mgr().Xtn_pgbnr().Write_html(page, ctx, hctx), page_body_class, html_content_editable
|
||||
, page_data, wdata_lang_wtr
|
||||
, portal_mgr.Div_personal_bry(), portal_mgr.Div_ns_bry(app.Utl__bfr_mkr(), page_ttl, wiki.Ns_mgr()), portal_mgr.Div_view_bry(app.Utl__bfr_mkr(), html_gen_tid, page.Html_data().Xtn_search_text())
|
||||
, portal_mgr.Div_logo_bry(), portal_mgr.Div_home_bry(), new Xopg_xtn_skin_fmtr_arg(page, Xopg_xtn_skin_itm_tid.Tid_sidebar), portal_mgr.Div_wikis_bry(app.Utl__bfr_mkr()), portal_mgr.Sidebar_mgr().Html_bry()
|
||||
, mgr.Edit_rename_div_bry(page_ttl), page.Html_data().Edit_preview_w_dbg(), js_edit_toolbar_bry
|
||||
@@ -105,12 +106,18 @@ public class Xoh_page_wtr_wkr {
|
||||
Xoh_page_wtr_wkr_.Bld_head_end(bfr, tmp_bfr, page); // add after </head>
|
||||
Xoh_page_wtr_wkr_.Bld_html_end(bfr, tmp_bfr, page); // add after </html>
|
||||
}
|
||||
public void Write_hdump(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page wpg) {
|
||||
if (wpg.Html_data().Xtn_pgbnr() != null) {
|
||||
ctx.Wiki().Xtn_mgr().Xtn_pgbnr().Write_html(wpg, ctx, hctx).Bfr_arg__add(bfr); // if pgbnr exists, write to top of html
|
||||
}
|
||||
this.Write_body(bfr, ctx, hctx, wpg);
|
||||
}
|
||||
public void Write_body(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page page) {
|
||||
synchronized (thread_lock_2) {
|
||||
this.page = page; this.wiki = page.Wikie(); this.app = wiki.Appe();
|
||||
Xoa_ttl page_ttl = page.Ttl(); int page_ns_id = page_ttl.Ns().Id();
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), page_ns_id, page_ttl.Page_db()); // NOTE: can't cache page_tid b/c Write_body is called directly; DATE:2014-10-02
|
||||
byte[] data_raw = page.Data_raw();
|
||||
byte[] data_raw = page.Db().Text().Text_bry();
|
||||
int bfr_page_bgn = bfr.Len();
|
||||
boolean page_tid_uses_pre = false;
|
||||
if (page_mode == Xopg_page_.Tid_edit)
|
||||
@@ -132,7 +139,7 @@ public class Xoh_page_wtr_wkr {
|
||||
}
|
||||
private void Write_body_wikitext(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, byte[] data_raw, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page page, byte page_tid, int ns_id) {
|
||||
// dump and exit if pre-generated html from html dumps
|
||||
byte[] hdump_data = page.Hdump_data().Body();
|
||||
byte[] hdump_data = page.Db().Html().Html_bry();
|
||||
if (Bry_.Len_gt_0(hdump_data)) {
|
||||
bfr.Add(hdump_data);
|
||||
return;
|
||||
@@ -178,7 +185,7 @@ public class Xoh_page_wtr_wkr {
|
||||
}
|
||||
// translate if variants are enabled
|
||||
Xol_vnt_mgr vnt_mgr = wiki.Lang().Vnt_mgr();
|
||||
if (vnt_mgr.Enabled()) bfr.Add(vnt_mgr.Convert_lang().Parse_page(vnt_mgr.Cur_itm(), page.Revision_data().Id(), bfr.To_bry_and_clear()));
|
||||
if (vnt_mgr.Enabled()) bfr.Add(vnt_mgr.Convert_lang().Parse_page(vnt_mgr.Cur_itm(), page.Db().Page().Id(), bfr.To_bry_and_clear()));
|
||||
}
|
||||
private void Write_body_pre(Bry_bfr bfr, Xoae_app app, Xowe_wiki wiki, byte[] data_raw, Bry_bfr tmp_bfr) {
|
||||
Xoh_html_wtr_escaper.Escape(app.Parser_amp_mgr(), tmp_bfr, data_raw, 0, data_raw.length, false, false);
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xoh_page_wtr_wkr_ {
|
||||
public static byte[] Bld_page_content_sub(Xoae_app app, Xowe_wiki wiki, Xoae_page page, Bry_bfr tmp_bfr) {
|
||||
byte[] subpages = app.Html_mgr().Page_mgr().Subpages_bldr().Bld(wiki.Ns_mgr(), page.Ttl());
|
||||
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.Redirected_ttls());
|
||||
byte[] redirect_msg = Xop_redirect_mgr.Bld_redirect_msg(app, wiki, page.Redirect());
|
||||
return Bry_.Add(subpages, page_content_sub, redirect_msg);
|
||||
}
|
||||
public static byte[] Bld_page_name(Bry_bfr tmp_bfr, Xoa_ttl ttl, byte[] display_ttl) {
|
||||
|
||||
@@ -49,15 +49,15 @@ class Xoh_page_wtr_fxt {
|
||||
} private Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); private Xowe_wiki wiki;
|
||||
public Xoae_app App() {return app;} private Xoae_app app;
|
||||
public void Test_page_name_by_display(String ttl, String display, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.parse(wiki, Bry_.new_a7(ttl)), Bry_.new_a7(display))));
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)), Bry_.new_a7(display))));
|
||||
}
|
||||
public void Test_page_name_by_ttl(String raw, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.parse(wiki, Bry_.new_a7(raw)), null)));
|
||||
Tfds.Eq(expd, String_.new_a7(Xoh_page_wtr_wkr_.Bld_page_name(tmp_bfr, Xoa_ttl.Parse(wiki, Bry_.new_a7(raw)), null)));
|
||||
}
|
||||
public void Test_edit(String raw, String expd) {
|
||||
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true);
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
page.Data_raw_(Bry_.new_u8(raw));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
||||
Xoh_page_wtr_mgr mgr = wiki.Html_mgr().Page_wtr_mgr();
|
||||
Xoh_page_wtr_wkr wkr = mgr.Wkr(Xopg_page_.Tid_edit);
|
||||
wkr.Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Basic, page);
|
||||
@@ -66,8 +66,8 @@ class Xoh_page_wtr_fxt {
|
||||
public void Test_read(String page_name, String page_text, String expd) {
|
||||
wiki.Html_mgr().Page_wtr_mgr().Html_capable_(true);
|
||||
Xoae_page page = wiki.Parser_mgr().Ctx().Page();
|
||||
page.Ttl_(Xoa_ttl.parse(wiki, Bry_.new_a7(page_name)));
|
||||
page.Data_raw_(Bry_.new_u8(page_text));
|
||||
page.Ttl_(Xoa_ttl.Parse(wiki, Bry_.new_a7(page_name)));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(page_text));
|
||||
Xoh_page_wtr_mgr mgr = wiki.Html_mgr().Page_wtr_mgr();
|
||||
Xoh_page_wtr_wkr wkr = mgr.Wkr(Xopg_page_.Tid_read);
|
||||
wkr.Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Basic, page);
|
||||
|
||||
@@ -37,8 +37,7 @@ public class Xow_hdump_mgr {
|
||||
Xowd_core_db_props props = wiki.Data__core_mgr().Props();
|
||||
dflt_zip_tid = props.Zip_tid_html();
|
||||
dflt_hzip_enable = props.Hzip_enabled();
|
||||
// dflt_hzip_enable = props.Hzip_enabled();
|
||||
// mode_is_b256 = true;
|
||||
// mode_is_b256 = true;
|
||||
}
|
||||
Init_by_db(dflt_zip_tid, dflt_hzip_enable, mode_is_b256);
|
||||
}
|
||||
|
||||
@@ -19,20 +19,20 @@ package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xow
|
||||
import gplx.core.ios.*;
|
||||
import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.makes.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.skins.*; import gplx.xowa.wikis.pages.lnkis.*; import gplx.xowa.wikis.pages.htmls.*;
|
||||
public class Xow_hdump_mgr__load {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Bry_bfr tmp_bfr; private final Xowd_page_itm tmp_dbpg = new Xowd_page_itm();
|
||||
private Xow_override_mgr override_mgr__html, override_mgr__page;
|
||||
public Xow_hdump_mgr__load(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg, Bry_bfr tmp_bfr) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg; this.tmp_bfr = tmp_bfr;
|
||||
this.make_mgr = new Xoh_make_mgr(wiki.App().Usr_dlg(), wiki.App().Fsys_mgr(), gplx.langs.htmls.encoders.Gfo_url_encoder_.Fsys_lnx, wiki.Domain_bry());
|
||||
this.make_mgr = new Xoh_make_mgr();
|
||||
}
|
||||
public Xoh_make_mgr Make_mgr() {return make_mgr;} private final Xoh_make_mgr make_mgr;
|
||||
public void Load_by_edit(Xoae_page wpg) {
|
||||
tmp_hpg.Init(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Revision_data().Id());
|
||||
tmp_hpg.Init(wpg.Wiki(), wpg.Url(), wpg.Ttl(), wpg.Db().Page().Id());
|
||||
Load(tmp_hpg, wpg.Ttl());
|
||||
wpg.Hdump_data().Body_(tmp_hpg.Body());
|
||||
wpg.Db().Html().Html_bry_(tmp_hpg.Db().Html().Html_bry());
|
||||
wpg.Root_(new gplx.xowa.parsers.Xop_root_tkn()); // HACK: set root, else load page will fail
|
||||
Fill_page(wpg, tmp_hpg);
|
||||
}
|
||||
@@ -48,13 +48,13 @@ public class Xow_hdump_mgr__load {
|
||||
if (!loaded) { // nothing in "page" table
|
||||
byte[] page_override = override_mgr__page.Get_or_same(ttl.Page_db(), null);
|
||||
if (page_override == null) return Load__fail(hpg);
|
||||
hpg.Body_(page_override);
|
||||
hpg.Db().Html().Html_bry_(page_override);
|
||||
return true;
|
||||
}
|
||||
Xow_db_file html_db = wiki.Data__core_mgr().Dbs__get_by_id_or_fail(tmp_dbpg.Html_db_id());
|
||||
if (!html_db.Tbl__html().Select_by_page(hpg)) return Load__fail(hpg); // nothing in "html" table
|
||||
byte[] src = Parse(hpg, hpg.Body_zip_tid(), hpg.Body_hzip_tid(), hpg.Body());
|
||||
hpg.Body_(src);
|
||||
byte[] src = Parse(hpg, hpg.Db().Html().Zip_tid(), hpg.Db().Html().Hzip_tid(), hpg.Db().Html().Html_bry());
|
||||
hpg.Db().Html().Html_bry_(src);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -85,25 +85,27 @@ public class Xow_hdump_mgr__load {
|
||||
wpg_head.Itm__hiero().Enabled_ (hpg_head.Hiero_exists());
|
||||
wpg_head.Itm__timeline().Enabled_ (hpg.Xtn__timeline_exists());
|
||||
wpg_head.Itm__gallery_styles().Enabled_ (hpg.Xtn__gallery_exists());
|
||||
wpg_head.Itm__toc().Enabled_(hpg.Hdump_mgr().Toc_wtr().Exists());
|
||||
wpg_head.Itm__pgbnr().Enabled_(hpg.Html_data().Head_mgr().Itm__pgbnr().Enabled());
|
||||
|
||||
// transfer images from Xoh_page to Xoae_page
|
||||
Xoh_img_mgr src_imgs = hpg.Img_mgr();
|
||||
int len = src_imgs.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
gplx.xowa.files.Xof_fsdb_itm itm = src_imgs.Get_at(i);
|
||||
wpg.Hdump_data().Imgs().Add(itm);
|
||||
wpg.Hdump_mgr().Imgs().Add(itm);
|
||||
wpg.File_queue().Add(itm); // add to file_queue for http_server
|
||||
}
|
||||
|
||||
// transfer redlinks
|
||||
Xopg_lnki_list src_list = hpg.Redlink_list();
|
||||
Xopg_lnki_list trg_list = wpg.Redlink_list();
|
||||
Xopg_lnki_list src_list = hpg.Html_data().Redlink_list();
|
||||
Xopg_lnki_list trg_list = wpg.Html_data().Redlink_list();
|
||||
len = src_list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
trg_list.Add_direct(src_list.Get_at(i));
|
||||
}
|
||||
}
|
||||
private static boolean Load__fail(Xoh_page hpg) {hpg.Exists_n_(); return false;}
|
||||
private static boolean Load__fail(Xoh_page hpg) {hpg.Db().Page().Exists_n_(); return false;}
|
||||
private static boolean Load__dbpg(Xow_wiki wiki, Xowd_page_itm dbpg, Xoh_page hpg, Xoa_ttl ttl) {
|
||||
wiki.Data__core_mgr().Tbl__page().Select_by_ttl(dbpg, ttl.Ns(), ttl.Page_db());
|
||||
if (dbpg.Redirect_id() != -1) Load__dbpg__redirects(wiki, dbpg);
|
||||
|
||||
@@ -1,161 +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.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.xtns.hieros.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
public class Xow_hdump_mgr__load_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xohd_hdump_wtr_fxt fxt = new Xohd_hdump_wtr_fxt();
|
||||
@Test public void Stub() {}
|
||||
// @Test public void Image_full() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.Y, Xof_ext_.Id_png));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.png|test_caption]]"
|
||||
// , "<a xtid='a_img_full' xatrs='1|0|0||0|test_caption'/>"
|
||||
// );
|
||||
// }
|
||||
// @Test public void Image_thumb() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.png", 0, 0, 0, Bool_.N, Xof_ext_.Id_png));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.png|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
|
||||
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" xowa_img='0' /></a>"
|
||||
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
|
||||
// , " test_caption"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Audio_thumb() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.oga", 0, 220, -1, Bool_.N, Xof_ext_.Id_oga));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.oga|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
|
||||
// , " <div class=\"xowa_media_div\"><xowa_play id='0'/><xowa_info id='0'/>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
|
||||
// , " test_caption"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Video_thumb() {
|
||||
// fxt.Expd_itms_xfers(fxt.Make_xfer("A.ogv", 0, 0, 0, Bool_.N, Xof_ext_.Id_ogv));
|
||||
// fxt.Test_write_all
|
||||
// ( "[[File:A.ogv|thumb|test_caption]]", String_.Concat_lines_nl_skip_last
|
||||
// ( "<div class=\"thumb tright\">"
|
||||
// , " <div id=\"xowa_file_div_0\" class=\"thumbinner\" xowa_img_style='0'>"
|
||||
// , " <div class=\"xowa_media_div\">"
|
||||
// , " <div>"
|
||||
// , " <a href=\"/wiki/File:A.ogv\" class=\"image\" title=\"A.ogv\">"
|
||||
// , " <img id=\"xoimg_0\" xowa_img='0' alt=\"\" />"
|
||||
// , " </a>"
|
||||
// , " </div><xowa_play id='0'/>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"thumbcaption\"><xowa_mgnf id='0'/>"
|
||||
// , " test_caption"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , "</div>"
|
||||
// ));
|
||||
// }
|
||||
// @Test public void Hiero() {
|
||||
// Hiero_html_mgr_fxt hiero_fxt = new Hiero_html_mgr_fxt(fxt.Fxt());
|
||||
// hiero_fxt.Reset();
|
||||
// hiero_fxt.Init_hiero_A1_B1();
|
||||
// fxt.Test_write_frag("<hiero>A1</hiero>", "src='~{xowa_hiero_dir}hiero_A1.png'");
|
||||
// }
|
||||
// @Test public void Gallery() {
|
||||
// Gallery_mgr_base.File_found_mode = Bool_.__byte;
|
||||
// fxt.Test_write_all
|
||||
// ( "<gallery>File:A.png|A1</gallery>", String_.Concat_lines_nl_skip_last
|
||||
// ( "<ul id=\"xowa_gallery_ul_0\" class=\"gallery mw-gallery-traditional\" xowa_gly_box_max='0'>"
|
||||
// , " <li id=\"xowa_gallery_li_0\" class=\"gallerybox\" xowa_gly_box_w='0'>"
|
||||
// , " <div xowa_gly_box_w='0'>"
|
||||
// , " <div class=\"thumb\" style=\"width: 150px;\">"
|
||||
// , " <div xowa_gly_img_pad='0'>"
|
||||
// , " <a href=\"/wiki/File:A.png\" class=\"image\" xowa_title=\"A.png\"><img id=\"xoimg_0\" alt=\"\" xowa_img='0' /></a>"
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , " <div class=\"gallerytext\"><p>A1"
|
||||
// , "</p>"
|
||||
// , ""
|
||||
// , " </div>"
|
||||
// , " </div>"
|
||||
// , " </li>"
|
||||
// , "</ul>"
|
||||
// ));
|
||||
// }
|
||||
}
|
||||
class Xodb_hdump_mgr__base_fxt {
|
||||
protected Bry_bfr bfr = Bry_bfr_.Reset(255);
|
||||
protected Xowe_wiki wiki; protected Xoae_page page;
|
||||
private Xow_hdump_mgr hdump_mgr;
|
||||
public Xop_fxt Fxt() {return fxt;} protected Xop_fxt fxt;
|
||||
public void Clear() {
|
||||
if (fxt == null) {
|
||||
fxt = new Xop_fxt();
|
||||
wiki = fxt.Wiki();
|
||||
page = wiki.Parser_mgr().Ctx().Page();
|
||||
hdump_mgr = wiki.Html__hdump_mgr();
|
||||
hdump_mgr.Init_by_db(gplx.core.ios.streams.Io_stream_.Tid_raw, false, false);
|
||||
}
|
||||
fxt.Reset();
|
||||
page.Revision_data().Id_(0);
|
||||
this.Clear_end();
|
||||
}
|
||||
@gplx.Virtual public void Clear_end() {}
|
||||
@gplx.Virtual public void Exec_write(String raw) {
|
||||
Xop_root_tkn root = fxt.Exec_parse_page_all_as_root(Bry_.new_u8(raw));
|
||||
page.Root_(root);
|
||||
hdump_mgr.Save_mgr().Bld_hdump(page);
|
||||
}
|
||||
public Xohd_img_itm__base Make_xfer(String lnki_ttl, int html_uid, int html_w, int html_h, boolean file_is_orig, int file_ext_id) {
|
||||
return new Xohd_img_itm__img().Data_init_base
|
||||
(Bry_.new_u8(lnki_ttl), Byte_.Zero, Xof_img_size.Upright_null, 0, 0, Xof_lnki_time.Null, Xof_lnki_page.Null, Xohd_img_itm__base.File_repo_id_null, file_ext_id, file_is_orig, html_w, html_uid, html_w, html_h);
|
||||
}
|
||||
}
|
||||
class Xohd_hdump_wtr_fxt extends Xodb_hdump_mgr__base_fxt {
|
||||
private List_adp expd_itms_xfers = List_adp_.New();
|
||||
@Override public void Clear_end() {expd_itms_xfers.Clear();}
|
||||
public void Expd_itms_xfers(Xohd_img_itm__base... itms) {expd_itms_xfers.Add_many((Object[])itms);}
|
||||
public void Test_write_all (String raw, String expd_html) {Test_write(Bool_.N, raw, expd_html);}
|
||||
public void Test_write_frag(String raw, String expd_frag) {Test_write(Bool_.Y, raw, expd_frag);}
|
||||
public void Test_write(boolean frag, String raw, String expd_html) {
|
||||
this.Exec_write(raw);
|
||||
String actl_html = String_.new_u8(page.Hdump_data().Body());
|
||||
if (frag)
|
||||
Tfds.Eq_true(String_.Has(actl_html, expd_html), actl_html);
|
||||
else
|
||||
Tfds.Eq_str_lines(expd_html, actl_html);
|
||||
if (expd_itms_xfers.Count() > 0) Tfds.Eq_ary_str(Xfer_to_str_ary(expd_itms_xfers), Xfer_to_str_ary(page.Hdump_data().Imgs()));
|
||||
}
|
||||
private static String[] Xfer_to_str_ary(List_adp list) {
|
||||
int len = list.Count();
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xohd_img_itm__base itm = (Xohd_img_itm__base)list.Get_at(i);
|
||||
rv[i] = itm.Data_print();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -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/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.primitives.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.pages.*;
|
||||
public class Xow_hdump_mgr__save {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
@@ -34,19 +34,19 @@ public class Xow_hdump_mgr__save {
|
||||
Bld_hdump(page);
|
||||
tmp_hpg.Ctor_by_page(tmp_bfr, page);
|
||||
Xow_db_file html_db = Get_html_db(wiki, page, html_db_is_new.Val_n_());
|
||||
return Save(tmp_hpg, html_db, html_db_is_new.Val());
|
||||
return Save(tmp_hpg, html_db.Tbl__html(), html_db_is_new.Val());
|
||||
}
|
||||
}
|
||||
public int Save(Xoh_page hpg, Xow_db_file html_db, boolean insert) {
|
||||
byte[] db_body = Write(tmp_bfr, wiki, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, dflt_hzip_tid, hpg.Body());
|
||||
if (insert) html_db.Tbl__html().Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_db.Tbl__html().Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
public int Save(Xoh_page hpg, Xowd_html_tbl html_tbl, boolean insert) {
|
||||
byte[] db_body = Write(tmp_bfr, wiki, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, dflt_hzip_tid, hpg.Db().Html().Html_bry());
|
||||
if (insert) html_tbl.Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_tbl.Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
return db_body.length;
|
||||
}
|
||||
public void Bld_hdump(Xoae_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will keep incrementing upwards
|
||||
wiki.Html__wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_body(tmp_bfr, page.Wikie().Parser_mgr().Ctx(), Xoh_wtr_ctx.Hdump, page); // save as hdump_fmt
|
||||
page.Hdump_data().Body_(tmp_bfr.To_bry_and_clear());
|
||||
page.Db().Html().Html_bry_(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
private byte[] Write(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
if (hzip_tid != Xoh_hzip_dict_.Hzip__none) src = hzip_mgr.Encode_as_bry((Xoh_hzip_bfr)bfr.Clear(), wiki, hpg, src);
|
||||
@@ -58,14 +58,14 @@ public class Xow_hdump_mgr__save {
|
||||
private static Xow_db_file Get_html_db(Xow_wiki wiki, Xoae_page page, Bool_obj_ref html_db_is_new) {
|
||||
Xow_db_file rv = Xow_db_file.Null;
|
||||
Xow_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int html_db_id = page.Revision_data().Html_db_id();
|
||||
int html_db_id = page.Db().Page().Html_db_id();
|
||||
if (html_db_id == -1) {
|
||||
html_db_is_new.Val_y_();
|
||||
rv = core_data_mgr.Db__html();
|
||||
if (rv == null) rv = core_data_mgr.Dbs__make_by_tid(Xow_db_file_.Tid__html_data);
|
||||
html_db_id = rv.Id();
|
||||
page.Revision_data().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Revision_data().Id(), html_db_id);
|
||||
page.Db().Page().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Db().Page().Id(), html_db_id);
|
||||
}
|
||||
else {
|
||||
rv = core_data_mgr.Dbs__get_by_id_or_fail(html_db_id);
|
||||
|
||||
@@ -16,54 +16,57 @@ 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.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.brys.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*;
|
||||
import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
import gplx.core.brys.*; import gplx.dbs.*;
|
||||
import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.apps.apis.xowa.bldrs.imports.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xob_hdump_bldr implements Gfo_invk {
|
||||
private boolean enabled, hzip_enabled, hzip_diff, hzip_b256; private byte zip_tid = Byte_.Max_value_127;
|
||||
private Xowe_wiki wiki; private Xow_hdump_mgr hdump_mgr;
|
||||
private Xob_ns_to_db_mgr ns_to_db_mgr; int prv_row_len = 0;
|
||||
private Xoh_stat_tbl stats_tbl; private Xoh_stat_itm tmp_stat_itm;
|
||||
private Xowe_wiki wiki; private Xow_hdump_mgr hdump_mgr; private Xob_hdump_tbl_retriever html_tbl_retriever;
|
||||
private Xoh_stat_tbl stat_tbl; private Xoh_stat_itm stat_itm;
|
||||
private int prv_row_len = 0;
|
||||
private final Xoh_page tmp_hpg = new Xoh_page(); private final Bry_bfr tmp_bfr = Bry_bfr_.New();
|
||||
private boolean op_sys_is_wnt;
|
||||
public boolean Init(Xowe_wiki wiki, Db_conn make_conn) {
|
||||
public boolean Init(Xowe_wiki wiki, Db_conn make_conn, Xob_hdump_tbl_retriever html_tbl_retriever) {
|
||||
if (!enabled) return false;
|
||||
this.op_sys_is_wnt = gplx.core.envs.Op_sys.Cur().Tid_is_wnt();
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.tmp_stat_itm = hdump_mgr.Hzip_mgr().Hctx().Hzip__stat();
|
||||
this.stats_tbl = new Xoh_stat_tbl(make_conn);
|
||||
this.wiki = wiki; this.hdump_mgr = wiki.Html__hdump_mgr(); this.html_tbl_retriever = html_tbl_retriever;
|
||||
this.stat_tbl = new Xoh_stat_tbl(make_conn); this.stat_itm = hdump_mgr.Hzip_mgr().Hctx().Hzip__stat();
|
||||
|
||||
Xoapi_import import_cfg = wiki.Appe().Api_root().Bldr().Wiki().Import();
|
||||
if (zip_tid == Byte_.Max_value_127) zip_tid = import_cfg.Zip_tid_html();
|
||||
hdump_mgr.Init_by_db(zip_tid, hzip_enabled, hzip_b256);
|
||||
Xow_db_mgr core_data_mgr = wiki.Db_mgr_as_sql().Core_data_mgr();
|
||||
this.ns_to_db_mgr = new Xob_ns_to_db_mgr(new Xob_ns_to_db_wkr__html(core_data_mgr.Db__core()), core_data_mgr, import_cfg.Html_db_max());
|
||||
Xob_ns_file_itm.Init_ns_bldr_data(Xow_db_file_.Tid__html_data, wiki.Ns_mgr(), gplx.xowa.apps.apis.xowa.bldrs.imports.Xoapi_import.Ns_file_map__each);
|
||||
return true;
|
||||
}
|
||||
public void Insert(Xoae_page page) {
|
||||
tmp_hpg.Clear(); // NOTE: must clear tmp_hpg or else will leak memory during mass build; DATE:2016-01-09
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_body(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Hdump, page); // write to html in hdump mode
|
||||
public void Insert(Xoae_page wpg) {
|
||||
// clear
|
||||
tmp_hpg.Clear(); // NOTE: must clear tmp_hpg or else will leak memory during mass build; DATE:2016-01-09
|
||||
wpg.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will resume from last
|
||||
|
||||
// write to html
|
||||
wiki.Html_mgr().Page_wtr_mgr().Wkr(Xopg_page_.Tid_read).Write_hdump(tmp_bfr, wiki.Parser_mgr().Ctx(), Xoh_wtr_ctx.Hdump, wpg);
|
||||
byte[] orig_bry = tmp_bfr.To_bry_and_clear();
|
||||
page.Hdump_data().Body_(orig_bry); // write to body bry
|
||||
Xow_db_file html_db = ns_to_db_mgr.Get_by_ns(page.Ttl().Ns().Bldr_data(), prv_row_len); // get html_db
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, page), html_db, true); // save to db
|
||||
if (hzip_diff) Hzip_exec(orig_bry);
|
||||
stats_tbl.Insert(tmp_hpg, tmp_stat_itm, page.Root().Root_src().length, tmp_hpg.Body().length, prv_row_len); // save stats
|
||||
wpg.Db().Html().Html_bry_(orig_bry);
|
||||
|
||||
// save to db
|
||||
Xowd_html_tbl html_tbl = html_tbl_retriever.Get_html_tbl(wpg.Ttl().Ns(), prv_row_len); // get html_tbl
|
||||
this.prv_row_len = hdump_mgr.Save_mgr().Save(tmp_hpg.Ctor_by_page(tmp_bfr, wpg), html_tbl, true); // save to db
|
||||
stat_tbl.Insert(tmp_hpg, stat_itm, wpg.Root().Root_src().length, tmp_hpg.Db().Html().Html_bry().length, prv_row_len); // save stats
|
||||
|
||||
// run hzip diff if enabled
|
||||
if (hzip_diff) {
|
||||
byte[] expd_bry = op_sys_is_wnt ? Bry_.Replace(tmp_bfr, orig_bry, Byte_ascii.Cr_lf_bry, Byte_ascii.Nl_bry) : orig_bry; // tidy adds crlf if wnt
|
||||
byte[] actl_bry = hdump_mgr.Load_mgr().Decode_as_bry(tmp_bfr, tmp_hpg, hdump_mgr.Save_mgr().Src_as_hzip(), Bool_.Y);
|
||||
byte[][] diff = Bry_diff_.Diff_1st_line(expd_bry, actl_bry);
|
||||
if (diff != null)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", String_.Format("hzip diff: page={0} lhs='{1}' rhs='{2}'", tmp_hpg.Url_bry_safe(), diff[0], diff[1]));
|
||||
}
|
||||
}
|
||||
public void Bld_term() {this.Commit(); ns_to_db_mgr.Rls_all();}
|
||||
public void Commit() {
|
||||
ns_to_db_mgr.Commit();
|
||||
html_tbl_retriever.Commit();
|
||||
// wiki_db_mgr.Tbl__cfg().Update_long(Cfg_grp_hdump_make, Cfg_itm_hdump_size, hdump_db_size); // update cfg; should happen after commit entries
|
||||
}
|
||||
private void Hzip_exec(byte[] orig_bry) {
|
||||
byte[] expd_bry = op_sys_is_wnt ? Bry_.Replace(tmp_bfr, orig_bry, Byte_ascii.Cr_lf_bry, Byte_ascii.Nl_bry) : orig_bry;
|
||||
byte[] actl_bry = hdump_mgr.Load_mgr().Decode_as_bry(tmp_bfr, tmp_hpg, hdump_mgr.Save_mgr().Src_as_hzip(), Bool_.Y);
|
||||
byte[][] diff = Bry_diff_.Diff_1st_line(expd_bry, actl_bry);
|
||||
if (diff != null)
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", String_.Format("hzip diff: page={0} lhs='{1}' rhs='{2}'", tmp_hpg.Url_bry_safe(), diff[0], diff[1]));
|
||||
}
|
||||
public void Term() {this.Commit(); html_tbl_retriever.Rls_all();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_enabled_)) enabled = m.ReadYn("v");
|
||||
else if (ctx.Match(k, Invk_zip_tid_)) zip_tid = m.ReadByte("v");
|
||||
|
||||
@@ -1,116 +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.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.bldrs.*; import gplx.xowa.bldrs.wkrs.*; import gplx.xowa.htmls.core.makes.imgs.*;
|
||||
import gplx.xowa.files.*;
|
||||
import gplx.xowa.guis.*;
|
||||
class Xob_hdump_img_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
public Xob_hdump_img_cmd(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
public String Cmd_key() {return Key_const;} public static final String Key_const = "hdump.make.imgs";
|
||||
public void Cmd_init(Xob_bldr bldr) {}
|
||||
public void Cmd_bgn(Xob_bldr bldr) {}
|
||||
public void Cmd_run() {Exec_main();}
|
||||
public void Cmd_end() {}
|
||||
public void Cmd_term() {}
|
||||
private void Exec_main() {
|
||||
Bry_bfr bfr = Bry_bfr_.Reset(Io_mgr.Len_mb);
|
||||
Db_conn conn = Xob_db_file.New__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
|
||||
Db_rdr rdr = conn.Stmt_sql(Sql_select_clause).Exec_select__rls_auto();
|
||||
// html_tbl = new Xowd_html_tbl(conn, wiki.Db_mgr_as_sql().Core_data_mgr().Props().Zip_tid_text());
|
||||
int cur_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
int lnki_page_id = rdr.Read_int("lnki_page_id");
|
||||
if (lnki_page_id != cur_page_id) {
|
||||
Save(cur_page_id, bfr.To_bry_and_clear());
|
||||
cur_page_id = lnki_page_id;
|
||||
}
|
||||
// int html_uid = rdr.Read_int(1);
|
||||
// byte[] lnki_ttl = rdr.Read_bry(2);
|
||||
// int html_w = rdr.Read_int(3);
|
||||
// int html_h = rdr.Read_int(4);
|
||||
// int file_repo_id = rdr.Read_int(5);
|
||||
// int file_ext_id = rdr.Read_int(6);
|
||||
// boolean file_is_orig = rdr.Read_int(7) == 1;
|
||||
// double file_time = rdr.Read_double(8);
|
||||
// int file_page = rdr.Read_int(9);
|
||||
// Xohd_img_itm__base.Data_write_static(bfr, 0, lnki_ttl, Byte_.Zero, 0, 0, Xof_img_size.Upright_null, html_uid, html_w, html_h, file_repo_id, file_ext_id, file_is_orig, html_w, file_time, file_page);
|
||||
}
|
||||
Save(cur_page_id, bfr.To_bry_and_clear());;
|
||||
}
|
||||
private void Save(int page_id, byte[] data) {
|
||||
if (page_id == -1 || data.length == 0) return;
|
||||
// html_tbl.Insert(page_id, Xohd_img_tid.Tid_img, data);
|
||||
}
|
||||
private static final String Sql_select_clause = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT lt.lnki_page_id"
|
||||
, ", lt.html_uid"
|
||||
, ", lt.lnki_ttl"
|
||||
, ", xr.file_w"
|
||||
, ", xr.file_h"
|
||||
, ", xr.orig_repo"
|
||||
, ", xr.lnki_ext"
|
||||
, ", xr.file_is_orig"
|
||||
, ", xr.lnki_time"
|
||||
, ", xr.lnki_page"
|
||||
, "FROM xfer_regy xr"
|
||||
, " JOIN lnki_temp lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
// , " LEFT JOIN xtn_gallery lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
// , " LEFT JOIN xtn_imap lt ON xr.file_ttl = lt.lnki_ttl"
|
||||
, "ORDER BY "
|
||||
, " lt.lnki_page_id"
|
||||
, ", lt.lnki_uid"
|
||||
);
|
||||
}
|
||||
interface Page_async_cmd {
|
||||
void Prep();
|
||||
void Exec();
|
||||
}
|
||||
// class Page_async_cmd__img : Page_async_cmd {
|
||||
// private Xoh_page hpg;
|
||||
// private List_adp missing = List_adp_.New();
|
||||
// public Page_async_cmd__img(Xoh_page hpg) {this.hpg = hpg;}
|
||||
// public void Prep() {
|
||||
//// int len = hpg.Img_count();
|
||||
//// Xohd_img_itm__base[] ary = hpg.Img_itms();
|
||||
//// missing.Clear();
|
||||
//// for (int i = 0; i < len; ++i) {
|
||||
//// Xohd_img_itm__base itm = ary[i];
|
||||
//// boolean exists = Io_mgr.Instance.ExistsFil(itm.Html_view_url());
|
||||
//// if (!exists) missing.Add(itm);
|
||||
//// }
|
||||
// }
|
||||
// public void Exec() {
|
||||
// int len = missing.Count();
|
||||
// for (int i = 0; i < len; ++i) {
|
||||
//// Xohd_img_itm__base itm = (Xohd_img_itm__base)missing.Get_at(i);
|
||||
//// byte[] bytes = null; //fsdb.Db_get()ttl, file_w,....):
|
||||
//// Write file(bytes);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// /*
|
||||
// CREATE TABLE xtn_gallery
|
||||
// ( src_page_id integer NOT NULL
|
||||
// , html_uid integer NOT NULL
|
||||
// , box_max integer NOT NULL
|
||||
// , box_w integer NOT NULL
|
||||
// , img_w integer NOT NULL
|
||||
// , img_pad integer NOT NULL
|
||||
// );
|
||||
// */
|
||||
@@ -15,9 +15,10 @@ 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.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
public interface Xohd_img_itm {
|
||||
int Data_tid();
|
||||
void Data_write(Bry_bfr bfr);
|
||||
String Data_print();
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
public interface Xob_hdump_tbl_retriever {
|
||||
Xowd_html_tbl Get_html_tbl(Xow_ns ns, int prv_row_len);
|
||||
void Commit();
|
||||
void Rls_all();
|
||||
}
|
||||
@@ -18,12 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.htmls.core.bldrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
class Xob_ns_to_db_wkr__html implements Xob_ns_to_db_wkr {
|
||||
public class Xob_ns_to_db_wkr__html implements Xob_ns_to_db_wkr {
|
||||
private final Xow_db_file page_db;
|
||||
public Xob_ns_to_db_wkr__html(Xow_db_file page_db) {this.page_db = page_db;}
|
||||
public byte Db_tid() {return Xow_db_file_.Tid__html_data;}
|
||||
public void Tbl_init(Xow_db_file db) {
|
||||
Xoh_page_tbl tbl = db.Tbl__html();
|
||||
Xowd_html_tbl tbl = db.Tbl__html();
|
||||
tbl.Create_tbl();
|
||||
tbl.Insert_bgn();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Xob_redlink_mkr_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
int page_id = rdr.Read_int(page_tbl.Fld_page_id());
|
||||
if (cur_page_id != page_id) {
|
||||
if (cur_page_id != -1) Commit(redlink_tbl, cur_page_id, bfr);
|
||||
bfr.Add_int_variable(gplx.xowa.htmls.core.makes.imgs.Xohd_img_tid.Tid_redlink).Add_byte_pipe();
|
||||
bfr.Add_int_variable(2).Add_byte_pipe(); // 2=gplx.xowa.htmls.core.makes.imgs.Xohd_img_tid.Tid_redlink
|
||||
cur_page_id = page_id;
|
||||
}
|
||||
// add html_uid to cur_page's bfr
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
public class Xoh_page_row {
|
||||
public class Xowd_html_row {
|
||||
public void Load(int page_id, int head_flag, int body_flag, byte[] display_ttl, byte[] content_sub, byte[] sidebar_div, byte[] body) {
|
||||
this.page_id = page_id;
|
||||
this.head_flag = head_flag;
|
||||
@@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.core.brys.*;
|
||||
public class Xoh_page_tbl implements Rls_able {
|
||||
public class Xowd_html_tbl implements Db_tbl {
|
||||
private final String fld_page_id, fld_head_flag, fld_body_flag, fld_display_ttl, fld_content_sub, fld_sidebar_div, fld_body;
|
||||
private Db_stmt stmt_select, stmt_insert, stmt_delete, stmt_update;
|
||||
private final Int_flag_bldr body_flag_bldr = new Int_flag_bldr().Pow_ary_bld_(3, 2); // 8 different zip types; 4 different hzip types
|
||||
public Xoh_page_tbl(Db_conn conn) {
|
||||
public Xowd_html_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.fld_page_id = flds.Add_int_pkey("page_id");
|
||||
this.fld_head_flag = flds.Add_int("head_flag");
|
||||
@@ -75,7 +75,7 @@ public class Xoh_page_tbl implements Rls_able {
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public boolean Select_as_row(Xoh_page_row rv, int page_id) {
|
||||
public boolean Select_as_row(Xowd_html_row rv, int page_id) {
|
||||
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, fld_page_id);
|
||||
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, page_id).Exec_select__rls_manual();
|
||||
try {
|
||||
@@ -223,7 +223,7 @@ public class Xoh_html_wtr {
|
||||
if (hctx.Mode_is_alt()) return;
|
||||
switch (under.Under_tid()) {
|
||||
case Xol_kwd_grp_.Id_toc:
|
||||
wiki.Html_mgr().Toc_mgr().Html(page, hctx, src, bfr, true);
|
||||
wiki.Html_mgr().Toc_mgr().Html(page, hctx, bfr, false);
|
||||
break;
|
||||
case Xol_kwd_grp_.Id_notoc: case Xol_kwd_grp_.Id_forcetoc: // NOTE: skip output; changes flag on page only
|
||||
break;
|
||||
|
||||
46
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_bfr_mgr.java
Normal file
46
400_xowa/src/gplx/xowa/htmls/core/hzips/Xoh_bfr_mgr.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
class Xoh_bfr_mgr {
|
||||
private Xoh_page hpg;
|
||||
private Bry_bfr html_bfr;
|
||||
private Bry_bfr bfr_0 = Bry_bfr_.New(), bfr_1 = Bry_bfr_.New();
|
||||
private boolean toc_mode_is_pgbnr;
|
||||
public Bry_bfr Init(Xoh_page hpg, Bry_bfr html_bfr) {
|
||||
this.hpg = hpg; this.html_bfr = html_bfr;
|
||||
this.toc_mode_is_pgbnr = false;
|
||||
return bfr_0;
|
||||
}
|
||||
public Bry_bfr Split_by_toc(Xoh_data_itm data_itm) {
|
||||
hpg.Hdump_mgr().Toc_wtr().Exists_y_();
|
||||
this.toc_mode_is_pgbnr = ((Xoh_toc_data)data_itm).Toc_mode() == Xoh_toc_data.Toc_mode__pgbnr;
|
||||
if (toc_mode_is_pgbnr)
|
||||
hpg.Html_data().Head_mgr().Itm__pgbnr().Enabled_y_();
|
||||
return bfr_1;
|
||||
}
|
||||
public void Commit() {
|
||||
html_bfr.Add_bfr_and_clear(bfr_0);
|
||||
|
||||
// calc toc by iterating sections
|
||||
if (hpg.Hdump_mgr().Toc_wtr().Exists())
|
||||
html_bfr.Add(hpg.Hdump_mgr().Toc_wtr().To_html(toc_mode_is_pgbnr));
|
||||
|
||||
html_bfr.Add_bfr_and_clear(bfr_1);
|
||||
}
|
||||
}
|
||||
@@ -21,18 +21,20 @@ public class Xoh_hzip_dict_ {
|
||||
public static final byte Escape = Byte_.By_int(27); // SERIALIZED: 27=escape byte
|
||||
public static final byte[] Escape_bry = Bry_.New_by_ints(27); // SERIALIZED
|
||||
public static final int
|
||||
Tid__timeline = -10
|
||||
, Tid__gallery = -11
|
||||
, Tid__root = 0
|
||||
, Tid__escape = 1
|
||||
, Tid__xnde = 2
|
||||
, Tid__lnke = 3
|
||||
, Tid__lnki = 4
|
||||
, Tid__hdr = 5
|
||||
, Tid__img = 6
|
||||
, Tid__thm = 7
|
||||
, Tid__gly = 8
|
||||
, Tid__img_bare = 9
|
||||
Tid__timeline = -10
|
||||
, Tid__gallery = -11
|
||||
, Tid__root = 0
|
||||
, Tid__escape = 1
|
||||
, Tid__xnde = 2
|
||||
, Tid__lnke = 3
|
||||
, Tid__lnki = 4
|
||||
, Tid__hdr = 5
|
||||
, Tid__img = 6
|
||||
, Tid__thm = 7
|
||||
, Tid__gly = 8
|
||||
, Tid__img_bare = 9
|
||||
, Tid__toc = 10
|
||||
, Tid__pgbnr = 11
|
||||
;
|
||||
public static final String
|
||||
Key__timeline = "timeline"
|
||||
@@ -46,6 +48,8 @@ public class Xoh_hzip_dict_ {
|
||||
, Key__gly = "gly"
|
||||
, Key__xnde = "xnde"
|
||||
, Key__img_bare = "img_bare"
|
||||
, Key__toc = "toc"
|
||||
, Key__pgbnr = "pgbnr"
|
||||
;
|
||||
public static final int Hzip__none = 0, Hzip__v1 = 1;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
private final Xoh_hdoc_wkr hdoc_wkr = new Xoh_hdoc_wkr__hzip();
|
||||
private final Xoh_hdoc_parser hdoc_parser;
|
||||
private final Bry_rdr rdr = new Bry_rdr().Dflt_dlm_(Xoh_hzip_dict_.Escape);
|
||||
private final Xoh_bfr_mgr bfr_mgr = new Xoh_bfr_mgr();
|
||||
public Xoh_hzip_mgr() {this.hdoc_parser = new Xoh_hdoc_parser(hdoc_wkr);}
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__lnke;}
|
||||
public String Key() {return "root";}
|
||||
@@ -40,8 +41,10 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
rdr.Init_by_page(hpg.Url_bry_safe(), src, src.length);
|
||||
Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, 0, src.length, null);
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
public void Decode1(Bry_bfr html_bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
int pos = src_bgn, txt_bgn = -1;
|
||||
boolean toc_enabled = !gplx.core.envs.Op_sys.Cur().Tid_is_drd() && !hctx.Mode_is_diff();
|
||||
Bry_bfr bfr = toc_enabled ? bfr_mgr.Init(hpg, html_bfr) : html_bfr;
|
||||
while (true) {
|
||||
if (pos == src_end) break;
|
||||
byte b = src[pos];
|
||||
@@ -57,6 +60,11 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
try {
|
||||
rdr.Init_by_sect(wkr.Key(), pos, pos + hook_len);
|
||||
Xoh_data_itm data = hctx.Pool_mgr__data().Get_by_tid(wkr.Tid());
|
||||
if ( data != null
|
||||
&& toc_enabled
|
||||
&& data.Tid() == Xoh_hzip_dict_.Tid__toc) {
|
||||
bfr = bfr_mgr.Split_by_toc(data);
|
||||
}
|
||||
wkr.Decode1(bfr, hdoc_wkr, hctx, hpg, rdr, src, pos, src_end, data);
|
||||
Xoh_wtr_itm wtr = hctx.Pool_mgr__wtr().Get_by_tid(wkr.Tid());
|
||||
if (data != null && wtr != null) {
|
||||
@@ -74,6 +82,7 @@ public class Xoh_hzip_mgr implements Xoh_hzip_wkr {
|
||||
}
|
||||
}
|
||||
if (txt_bgn != -1) bfr.Add_mid(src, txt_bgn, src_end);
|
||||
if (toc_enabled) bfr_mgr.Commit();
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_hzip_mgr rv = new Xoh_hzip_mgr(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
|
||||
@@ -19,15 +19,16 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.btries.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
public class Xoh_pool_mgr__data {
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery;
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__toc, pool__timeline, pool__gallery;
|
||||
public Xoh_pool_mgr__data() {
|
||||
pool__hdr = New_pool(new Xoh_hdr_data());
|
||||
pool__lnke = New_pool(new Xoh_lnke_data());
|
||||
pool__img = New_pool(new Xoh_img_data());
|
||||
pool__img_bare = New_pool(new Xoh_img_bare_data());
|
||||
pool__toc = New_pool(new Xoh_toc_data());
|
||||
pool__timeline = New_pool(new Xoh_timeline_data());
|
||||
pool__gallery = New_pool(new Xoh_gallery_data());
|
||||
}
|
||||
@@ -38,6 +39,7 @@ public class Xoh_pool_mgr__data {
|
||||
case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break;
|
||||
case Xoh_hzip_dict_.Tid__img: pool = pool__img; break;
|
||||
case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break;
|
||||
case Xoh_hzip_dict_.Tid__toc: pool = pool__toc; break;
|
||||
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
|
||||
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
|
||||
default: return null;
|
||||
|
||||
@@ -19,11 +19,11 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.btries.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
public class Xoh_pool_mgr__hzip {
|
||||
private final Btrie_slim_mgr trie = Btrie_slim_mgr.cs();
|
||||
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline;
|
||||
private Gfo_poolable_mgr mkr__escape, mkr__xnde, mkr__lnke, mkr__lnki, mkr__hdr, mkr__img, mkr__thm, mkr__gly, mkr__img_bare, mkr__gallery, mkr__timeline, mkr__toc;
|
||||
public Xoh_escape_hzip Mw__escape() {return (Xoh_escape_hzip) mkr__escape.Get_fast();}
|
||||
public Xoh_xnde_hzip Mw__xnde() {return (Xoh_xnde_hzip) mkr__xnde.Get_fast();}
|
||||
public Xoh_hdr_hzip Mw__hdr() {return (Xoh_hdr_hzip) mkr__hdr.Get_fast();}
|
||||
@@ -33,6 +33,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
public Xoh_img_bare_hzip Mw__img_bare() {return (Xoh_img_bare_hzip) mkr__img_bare.Get_fast();}
|
||||
public Xoh_thm_hzip Mw__thm() {return (Xoh_thm_hzip) mkr__thm.Get_fast();}
|
||||
public Xoh_gly_hzip Mw__gly() {return (Xoh_gly_hzip) mkr__gly.Get_fast();}
|
||||
public Xoh_toc_hzip Mw__toc() {return (Xoh_toc_hzip) mkr__toc.Get_fast();}
|
||||
public Xoh_gallery_hzip Mw__gallery() {return (Xoh_gallery_hzip) mkr__gallery.Get_fast();}
|
||||
public Xoh_timeline_hzip Mw__timeline() {return (Xoh_timeline_hzip) mkr__timeline.Get_fast();}
|
||||
public void Init() {
|
||||
@@ -53,6 +54,7 @@ public class Xoh_pool_mgr__hzip {
|
||||
mkr__thm = Reg(New_hook_len2(mode_is_b256, hook__mw , 5) , new Xoh_thm_hzip());
|
||||
mkr__gly = Reg(New_hook_len2(mode_is_b256, hook__mw , 6) , new Xoh_gly_hzip());
|
||||
mkr__img_bare = Reg(New_hook_len2(mode_is_b256, hook__mw , 7) , new Xoh_img_bare_hzip());
|
||||
mkr__toc = Reg(New_hook_len2(mode_is_b256, hook__mw , 8) , new Xoh_toc_hzip());
|
||||
mkr__gallery = Reg(Xoh_gallery_data.Hook_bry , new Xoh_gallery_hzip());
|
||||
mkr__timeline = Reg(Xoh_timeline_data.Hook_bry , new Xoh_timeline_hzip());
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@ package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gp
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*;
|
||||
import gplx.xowa.htmls.core.wkrs.escapes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.addons.timelines.*; import gplx.xowa.htmls.core.wkrs.addons.gallerys.*;
|
||||
public class Xoh_pool_mgr__wtr {
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__timeline, pool__gallery;
|
||||
private final Gfo_poolable_mgr pool__hdr, pool__lnke, pool__img, pool__img_bare, pool__toc, pool__timeline, pool__gallery;
|
||||
public Xoh_pool_mgr__wtr() {
|
||||
pool__hdr = New_pool(new Xoh_hdr_wtr());
|
||||
pool__lnke = New_pool(new Xoh_lnke_wtr());
|
||||
pool__img = New_pool(new Xoh_img_wtr());
|
||||
pool__img_bare = New_pool(new Xoh_img_bare_wtr());
|
||||
pool__toc = New_pool(new Xoh_toc_wtr());
|
||||
pool__timeline = New_pool(new Xoh_timeline_wtr());
|
||||
pool__gallery = New_pool(new Xoh_gallery_wtr());
|
||||
}
|
||||
@@ -38,6 +39,7 @@ public class Xoh_pool_mgr__wtr {
|
||||
case Xoh_hzip_dict_.Tid__lnke: pool = pool__lnke; break;
|
||||
case Xoh_hzip_dict_.Tid__img: pool = pool__img; break;
|
||||
case Xoh_hzip_dict_.Tid__img_bare: pool = pool__img_bare; break;
|
||||
case Xoh_hzip_dict_.Tid__toc: pool = pool__toc; break;
|
||||
case Xoh_hzip_dict_.Tid__timeline: pool = pool__timeline; break;
|
||||
case Xoh_hzip_dict_.Tid__gallery: pool = pool__gallery; break;
|
||||
default: return null;
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.hzips; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.pages.*;
|
||||
public class Xoh_stat_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hdump_stats"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
@@ -48,7 +48,7 @@ public class Xoh_stat_tbl implements Rls_able {
|
||||
.Val_int(fld_wtxt_len , wtxt_len)
|
||||
.Val_int(fld_row_orig_len , row_orig_len)
|
||||
.Val_int(fld_row_zip_len , row_zip_len)
|
||||
.Val_int(fld_body_len , Len_or_0(hpg.Body()))
|
||||
.Val_int(fld_body_len , Len_or_0(hpg.Db().Html().Html_bry()))
|
||||
.Val_int(fld_display_ttl_len , Len_or_0(hpg.Display_ttl()))
|
||||
.Val_int(fld_content_sub_len , Len_or_0(hpg.Content_sub()))
|
||||
.Val_int(fld_sidebar_div_len , Len_or_0(hpg.Sidebar_div()))
|
||||
|
||||
@@ -16,28 +16,11 @@ 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.htmls.core.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.brys.fmtrs.*; import gplx.core.btries.*; import gplx.langs.htmls.encoders.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.wkrs.lnkis.htmls.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.repos.*; import gplx.xowa.xtns.gallery.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.apps.fsys.*;
|
||||
import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_make_mgr {
|
||||
private final Xoh_hzip_bfr bfr = Xoh_hzip_bfr.New_txt(255); private final Bry_bfr tmp_bfr = Bry_bfr_.Reset(255); private final Bry_rdr_old bry_rdr = new Bry_rdr_old(); private Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance;
|
||||
private Xoh_cfg_file cfg_file; private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2(); private Xoh_file_html_fmtr__base html_fmtr;
|
||||
private final byte[] root_dir, file_dir; private byte[] file_dir_comm, file_dir_wiki, hiero_img_dir; private final byte[] wiki_domain;
|
||||
private final Bry_rdr parser = new Bry_rdr();
|
||||
private final Xoh_hzip_bfr bfr = Xoh_hzip_bfr.New_txt(255);
|
||||
private final Xoh_hdoc_ctx hctx = new Xoh_hdoc_ctx();
|
||||
private final Xoh_hdoc_parser make_parser = new Xoh_hdoc_parser(new Xoh_hdoc_wkr__make());
|
||||
public Xoh_make_mgr(Gfo_usr_dlg usr_dlg, Xoa_fsys_mgr fsys_mgr, Gfo_url_encoder fsys_encoder, byte[] wiki_domain) {
|
||||
this.usr_dlg = usr_dlg;
|
||||
this.root_dir = fsys_mgr.Root_dir().To_http_file_bry();
|
||||
this.file_dir = fsys_mgr.File_dir().To_http_file_bry();
|
||||
this.hiero_img_dir = gplx.xowa.xtns.hieros.Hiero_xtn_mgr.Hiero_root_dir(fsys_mgr).GenSubDir("img").To_http_file_bry();
|
||||
this.cfg_file = new Xoh_cfg_file(fsys_encoder, fsys_mgr.Bin_xowa_dir());
|
||||
this.html_fmtr = Xoh_file_html_fmtr__hdump.Base;
|
||||
this.wiki_domain = wiki_domain;
|
||||
}
|
||||
public byte[] Parse(byte[] src, Xoh_page hpg, Xow_wiki wiki) {
|
||||
hctx.Init_by_page(wiki, hpg);
|
||||
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
|
||||
@@ -45,100 +28,4 @@ public class Xoh_make_mgr {
|
||||
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src.length);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Parse_old(Xoh_page hpg, byte[] src) {
|
||||
this.file_dir_comm = tmp_bfr.Add(file_dir).Add(Xow_domain_itm_.Bry__commons).Add_byte_slash().To_bry_and_clear();
|
||||
this.file_dir_wiki = tmp_bfr.Add(file_dir).Add(wiki_domain).Add_byte_slash().To_bry_and_clear();
|
||||
int src_len = src.length;
|
||||
bry_rdr.Init(src);
|
||||
hpg.Section_mgr().Add(0, 2, Bry_.Empty, Bry_.Empty).Content_bgn_(0); // +1 to skip \n
|
||||
Xohd_img_itm__base[] imgs = hpg.Img_itms(); int imgs_len = hpg.Img_itms().length;
|
||||
int pos = 0; int rng_bgn = -1;
|
||||
parser.Init_by_page(hpg.Url_bry_safe(), src, src_len);
|
||||
while (pos < src_len) {
|
||||
byte b = src[pos];
|
||||
Object o = trie.Match_bgn_w_byte(b, src, pos, src_len);
|
||||
if (o == null) { // regular char; set bgn and move to next char
|
||||
if (rng_bgn == -1) rng_bgn = pos;
|
||||
++pos;
|
||||
}
|
||||
else { // special tkn
|
||||
if (rng_bgn != -1) { // pending rng exists; add it
|
||||
bfr.Add_mid(src, rng_bgn, pos);
|
||||
rng_bgn = -1;
|
||||
}
|
||||
pos = Parse_itm(bfr, html_fmtr, hpg, src, src_len, imgs, imgs_len, pos, trie.Match_pos(), (Xoh_make_trie_itm)o);
|
||||
}
|
||||
}
|
||||
if (rng_bgn != -1) bfr.Add_mid(src, rng_bgn, src_len);
|
||||
hpg.Section_mgr().Set_content(hpg.Section_mgr().Len() - 1, src, src_len);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
private int Parse_itm(Bry_bfr bfr, Xoh_file_html_fmtr__base fmtr, Xoh_page hpg, byte[] src, int src_len, Xohd_img_itm__base[] imgs, int imgs_len, int hook_bgn, int hook_end, Xoh_make_trie_itm itm) {
|
||||
bry_rdr.Pos_(hook_end);
|
||||
int uid = itm.Subst_end_byte() == Byte_ascii.Escape ? -1 : bry_rdr.Read_int_to(itm.Subst_end_byte());
|
||||
int uid_end = bry_rdr.Pos(); // set uid_end after subst_end
|
||||
int rv = uid_end;
|
||||
byte tid = itm.Tid();
|
||||
switch (tid) {
|
||||
case Xoh_make_trie_.Tid__dir: bfr.Add(root_dir); return rv;
|
||||
case Xoh_make_trie_.Tid__hiero_dir: bfr.Add(hiero_img_dir); return rv;
|
||||
}
|
||||
if (itm.Elem_is_xnde()) rv += 2; // if xnde, skip "/>"
|
||||
if (uid == bry_rdr.Or_int()) {usr_dlg.Warn_many("", "", "index is not a valid int; hpg=~{0} text=~{1}", hpg.Url().To_str(), Bry_.Mid_safe(src, hook_end, uid_end)); return uid_end;}
|
||||
if (!Int_.Between(uid, 0, imgs_len)) {usr_dlg.Warn_many("", "", "index is out of range; hpg=~{0} idx=~{1} len=~{2}", hpg.Url().To_str(), uid, imgs_len); return uid_end;}
|
||||
if (uid >= imgs.length) return rv;
|
||||
Xohd_img_itm__base img = imgs[uid];
|
||||
int img_view_w = img.Html_w();
|
||||
switch (tid) {
|
||||
case Xoh_make_trie_.Tid__img_style:
|
||||
bfr.Add(Xoh_make_trie_.Bry_img_style_bgn);
|
||||
bfr.Add_int_variable(img_view_w);
|
||||
bfr.Add(Xoh_make_trie_.Bry_img_style_end);
|
||||
return rv;
|
||||
}
|
||||
byte[] a_title = img.Lnki_ttl();
|
||||
byte[] a_href = Bry_.Add(Xoh_make_trie_.A_href_bgn, a_title);
|
||||
try {
|
||||
switch (tid) {
|
||||
case Xoh_make_trie_.Tid__file_info: fmtr.Html_thumb_part_info (bfr, uid, true, a_href, cfg_file.Img_media_info_btn()); return rv;
|
||||
case Xoh_make_trie_.Tid__file_mgnf: fmtr.Html_thumb_part_magnify(bfr, uid, a_href, a_title, cfg_file.Img_thumb_magnify()); return rv;
|
||||
case Xoh_make_trie_.Tid__file_play: fmtr.Html_thumb_part_play (bfr, uid, true, img_view_w, Xoh_file_wtr__basic.Play_btn_max_width, a_href, a_title, cfg_file.Img_media_play_btn()); return rv;
|
||||
case Xoh_make_trie_.Tid__gallery_box_max: {
|
||||
Xohd_img_itm__gallery_mgr gly = (Xohd_img_itm__gallery_mgr)hpg.Gallery_itms().Get_by(uid);
|
||||
if (gly != null) { // -1 means no box_max
|
||||
byte[] style = Gallery_mgr_wtr_.Fmtr__ul__style.Bld_bry_many(tmp_bfr, gly.Box_max());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
case Xoh_make_trie_.Tid__gallery_box_w: {
|
||||
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
|
||||
byte[] style = Gallery_mgr_wtr_.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Box_w());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
return rv;
|
||||
}
|
||||
case Xoh_make_trie_.Tid__gallery_img_w: {
|
||||
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
|
||||
byte[] style = Gallery_mgr_wtr_.hdump_box_w_fmtr.Bld_bry_many(tmp_bfr, gly.Img_w());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
return rv;
|
||||
}
|
||||
case Xoh_make_trie_.Tid__gallery_img_pad: {
|
||||
Xohd_img_itm__gallery_itm gly = (Xohd_img_itm__gallery_itm)img;
|
||||
byte[] style = Gallery_mgr_wtr_.hdump_img_pad_fmtr.Bld_bry_many(tmp_bfr, gly.Img_pad());
|
||||
Gfh_wtr.Write_atr_bry(bfr, Bool_.N, Byte_ascii.Quote, Gfh_atr_.Bry__style, style);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
url_bldr.Init_by_root(img.Orig_repo_id() == Xof_repo_itm_.Repo_remote ? file_dir_comm : file_dir_wiki, Byte_ascii.Slash, false, false, 2);
|
||||
url_bldr.Init_by_itm(img.File_is_orig() ? Xof_repo_itm_.Mode_orig : Xof_repo_itm_.Mode_thumb, img.Lnki_ttl(), Xof_file_wkr_.Md5(img.Lnki_ttl()), Xof_ext_.new_by_id_(img.Orig_ext()), img.File_w(), img.Lnki_time(), img.Lnki_page());
|
||||
byte[] img_src = url_bldr.Xto_bry();
|
||||
if (tid == Xoh_make_trie_.Tid__img) {
|
||||
fmtr_img.Bld_bfr_many(bfr, img_src, img_view_w, img.Html_h());
|
||||
}
|
||||
} catch (Exception e) {Xoa_app_.Usr_dlg().Warn_many("", "", "abrv.read: page=~{0} itm=~{1} err=~{2}", hpg.Url_bry_safe(), img == null ? "<NULL>" : img.Data_print(), Err_.Message_gplx_full(e));}
|
||||
return rv;
|
||||
}
|
||||
public static final Bry_fmtr fmtr_img = Bry_fmtr.new_("src='~{src}' width='~{w}' height='~{h}'", "src", "w", "h");
|
||||
private static final Btrie_slim_mgr trie = Xoh_make_trie_.new_trie();
|
||||
}
|
||||
|
||||
@@ -1,68 +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.htmls.core.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.primitives.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.files.*; import gplx.xowa.parsers.lnkis.*;
|
||||
class Xoh_make_mgr_fxt {
|
||||
private final List_adp img_list = List_adp_.New();
|
||||
private final Xoh_page hpg = new Xoh_page();
|
||||
private Xoh_make_mgr hswap_mgr; private Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
this.wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
this.wiki.Init_by_wiki();
|
||||
this.hswap_mgr = wiki.Html__hdump_mgr().Load_mgr().Make_mgr();
|
||||
}
|
||||
public void Clear_imgs() {img_list.Clear();}
|
||||
public Xoh_make_mgr_fxt Init_body(String body) {hpg.Body_(Bry_.new_u8(body)); return this;}
|
||||
public Xoh_make_mgr_fxt Init_data_gly(int uid, int box_max) {hpg.Gallery_itms().Add(uid, new Xohd_img_itm__gallery_mgr(uid, box_max)); return this;}
|
||||
public Xoh_make_mgr_fxt Init_data_img_basic(String ttl, int html_uid, int html_w, int html_h) {
|
||||
Xohd_img_itm__img img = new Xohd_img_itm__img();
|
||||
img.Data_init_base(Bry_.new_u8(ttl), Xop_lnki_type.Id_none, Xof_img_size.Upright_null, Xof_img_size.Null, Xof_img_size.Null
|
||||
, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xohd_img_itm__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w
|
||||
, html_uid, html_w, html_h
|
||||
);
|
||||
img_list.Add(img);
|
||||
return this;
|
||||
}
|
||||
public Xoh_make_mgr_fxt Init_data_img_gly(String ttl, int html_uid, int html_w, int html_h, int box_w, int img_w, int img_pad) {
|
||||
Xohd_img_itm__gallery_itm img = new Xohd_img_itm__gallery_itm();
|
||||
img.Data_init_gallery(box_w, img_w, img_pad);
|
||||
img.Data_init_base(Bry_.new_u8(ttl), Xop_lnki_type.Id_none, Xof_img_size.Upright_null, Xof_img_size.Null, Xof_img_size.Null
|
||||
, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xohd_img_itm__base.File_repo_id_commons, Xof_ext_.Id_png, Bool_.N, html_w
|
||||
, html_uid, html_w, html_h
|
||||
);
|
||||
img_list.Add(img);
|
||||
return this;
|
||||
}
|
||||
public Xoh_make_mgr_fxt Init_data_redlink(int... uids) {
|
||||
int uids_len = uids.length;
|
||||
for (int i = 0; i < uids_len; ++i) {
|
||||
Int_obj_ref redlink_uid = Int_obj_ref.New(uids[i]);
|
||||
hpg.Redlink_uids().Add(redlink_uid, redlink_uid);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Xoh_make_mgr_fxt Test_html(String expd) {
|
||||
if (img_list.Count() > 0) hpg.Img_itms_((Xohd_img_itm__base[])img_list.To_ary_and_clear(Xohd_img_itm__base.class));
|
||||
byte[] actl = hswap_mgr.Parse(hpg.Body(), hpg, wiki);
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,66 +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.htmls.core.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
import gplx.core.btries.*;
|
||||
public class Xoh_make_trie_ {
|
||||
public static final byte
|
||||
Tid__dir = 1, Tid__img = 2, Tid__img_style = 3, Tid__file_play = 4, Tid__file_info = 5, Tid__file_mgnf = 6
|
||||
, Tid__hiero_dir = 7, Tid__gallery_box_max = 8, Tid__gallery_box_w = 9, Tid__gallery_img_w = 10, Tid__gallery_img_pad = 11
|
||||
, Tid__toc = 12, Tid__hdr = 13
|
||||
;
|
||||
public static final byte[]
|
||||
Bry__dir = Bry_.new_a7("~{xowa_dir}")
|
||||
, Bry__img = Bry_.new_a7("xowa_img=\"")
|
||||
, Bry__img_style = Bry_.new_a7("xowa_img_style=\"")
|
||||
, Bry__file_play = Bry_.new_a7("<xowa_play id='")
|
||||
, Bry__file_info = Bry_.new_a7("<xowa_info id='")
|
||||
, Bry__file_mgnf = Bry_.new_a7("<xowa_mgnf id=\"")
|
||||
// , Bry__hiero_dir = Bry_.new_a7("~{xowa_hiero_dir}")
|
||||
// , Bry__gallery_box_max = Bry_.new_a7("xowa_gly_box_max='")
|
||||
// , Bry__gallery_box_w = Bry_.new_a7("xowa_gly_box_w='")
|
||||
// , Bry__gallery_img_w = Bry_.new_a7("xowa_gly_img_w='")
|
||||
// , Bry__gallery_img_pad = Bry_.new_a7("xowa_gly_img_pad='")
|
||||
, Bry__toc = Bry_.new_a7("~{xowa_toc}")
|
||||
;
|
||||
public static final byte[]
|
||||
A_href_bgn = Bry_.new_a7("/wiki/File:")
|
||||
, Bry_img_style_bgn = Bry_.new_a7("style='width:")
|
||||
, Bry_img_style_end = Bry_.new_a7("px;'")
|
||||
;
|
||||
public static Btrie_slim_mgr new_trie() {
|
||||
Btrie_slim_mgr rv = Btrie_slim_mgr.cs();
|
||||
trie_itm(rv, Tid__dir , Byte_ascii.Escape , Bry__dir);
|
||||
trie_itm(rv, Tid__img , Byte_ascii.Apos , Bry__img);
|
||||
trie_itm(rv, Tid__img_style , Byte_ascii.Apos , Bry__img_style);
|
||||
trie_itm(rv, Tid__file_play , Byte_ascii.Apos , Bry__file_play);
|
||||
trie_itm(rv, Tid__file_info , Byte_ascii.Apos , Bry__file_info);
|
||||
trie_itm(rv, Tid__file_mgnf , Byte_ascii.Apos , Bry__file_mgnf);
|
||||
// trie_itm(rv, Tid__hiero_dir , Byte_ascii.Escape , Bry__hiero_dir);
|
||||
// trie_itm(rv, Tid__gallery_box_max , Byte_ascii.Apos , Bry__gallery_box_max);
|
||||
// trie_itm(rv, Tid__gallery_box_w , Byte_ascii.Apos , Bry__gallery_box_w);
|
||||
// trie_itm(rv, Tid__gallery_img_w , Byte_ascii.Apos , Bry__gallery_img_w);
|
||||
// trie_itm(rv, Tid__gallery_img_pad , Byte_ascii.Apos , Bry__gallery_img_pad);
|
||||
trie_itm(rv, Tid__toc , Byte_ascii.Escape , Bry__toc);
|
||||
return rv;
|
||||
}
|
||||
private static void trie_itm(Btrie_slim_mgr trie, byte tid, byte subst_end_byte, byte[] key_bry) {
|
||||
boolean elem_is_xnde = key_bry[0] == Byte_ascii.Lt;
|
||||
Xoh_make_trie_itm itm = new Xoh_make_trie_itm(tid, elem_is_xnde, subst_end_byte, key_bry);
|
||||
trie.Add_obj(key_bry, itm);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.makes; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*;
|
||||
class Xoh_make_trie_itm {
|
||||
public Xoh_make_trie_itm(byte tid, boolean elem_is_xnde, byte subst_end_byte, byte[] key) {this.tid = tid; this.key = key; this.elem_is_xnde = elem_is_xnde; this.subst_end_byte = subst_end_byte;}
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public byte[] Key() {return key;} private final byte[] key;
|
||||
public boolean Elem_is_xnde() {return elem_is_xnde;} private final boolean elem_is_xnde;
|
||||
public byte Subst_end_byte() {return subst_end_byte;} private final byte subst_end_byte;
|
||||
}
|
||||
@@ -1,101 +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.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.core.brys.*; import gplx.xowa.files.repos.*;
|
||||
public abstract class Xohd_img_itm__base implements Xohd_img_itm {
|
||||
public abstract int Img_tid();
|
||||
public int Data_tid() {return Xohd_img_tid.Tid_img;}
|
||||
public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
|
||||
public byte Lnki_type() {return lnki_type;} private byte lnki_type;
|
||||
public double Lnki_upright() {return lnki_upright;} private double lnki_upright;
|
||||
public int Lnki_w() {return lnki_w;} private int lnki_w;
|
||||
public int Lnki_h() {return lnki_h;} private int lnki_h;
|
||||
public double Lnki_time() {return lnki_time;} private double lnki_time;
|
||||
public int Lnki_page() {return lnki_page;} private int lnki_page;
|
||||
public int Orig_repo_id() {return orig_repo_id;} private int orig_repo_id;
|
||||
public int Orig_ext() {return orig_ext;} private int orig_ext;
|
||||
public boolean File_is_orig() {return file_is_orig;} private boolean file_is_orig;
|
||||
public int File_w() {return file_w;} private int file_w;
|
||||
public int Html_uid() {return html_uid;} private int html_uid;
|
||||
public int Html_w() {return html_w;} private int html_w;
|
||||
public int Html_h() {return html_h;} private int html_h;
|
||||
public Io_url Html_view_url() {return html_view_url;} public void File_url_(Io_url v) {html_view_url = v;} private Io_url html_view_url;
|
||||
public abstract byte Html_elem_tid();
|
||||
public Xohd_img_itm__base Data_init_base
|
||||
( byte[] lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page
|
||||
, int orig_repo_id, int orig_ext, boolean file_is_orig, int file_w
|
||||
, int html_uid, int html_w, int html_h
|
||||
) {
|
||||
this.lnki_ttl = lnki_ttl; this.orig_ext = orig_ext; this.lnki_type = lnki_type;
|
||||
this.lnki_w = lnki_w; this.lnki_h = lnki_h; this.lnki_upright = lnki_upright; this.lnki_time = lnki_time; this.lnki_page = lnki_page;
|
||||
this.orig_repo_id = orig_repo_id; this.file_is_orig = file_is_orig; this.file_w = file_w;
|
||||
this.html_uid = html_uid; this.html_w = html_w; this.html_h = html_h;
|
||||
return this;
|
||||
}
|
||||
public void Data_write(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(Xohd_img_tid.Tid_img).Add_byte_pipe()
|
||||
.Add_int_variable(this.Img_tid()).Add_byte_pipe()
|
||||
.Add(lnki_ttl).Add_byte_pipe()
|
||||
.Add_int_variable(orig_ext).Add_byte_pipe()
|
||||
.Add_byte(lnki_type).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_w).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_h).Add_byte_pipe()
|
||||
.Add_double(lnki_upright).Add_byte_pipe()
|
||||
.Add_double(lnki_time).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_page).Add_byte_pipe()
|
||||
.Add_int_variable(orig_repo_id).Add_byte_pipe()
|
||||
.Add_yn(file_is_orig).Add_byte_pipe()
|
||||
.Add_int_variable(file_w).Add_byte_pipe()
|
||||
.Add_int_variable(html_uid).Add_byte_pipe()
|
||||
.Add_int_variable(html_w).Add_byte_pipe()
|
||||
.Add_int_variable(html_h).Add_byte_pipe()
|
||||
;
|
||||
Data_write_hook(bfr);
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
public String Data_print() {
|
||||
return String_.Concat_with_str("|", Int_.To_str(this.Img_tid()), String_.new_u8(lnki_ttl), Int_.To_str(html_uid), Int_.To_str(html_w), Int_.To_str(html_h)
|
||||
, Int_.To_str(orig_repo_id), Int_.To_str(orig_ext), Yn.To_str(file_is_orig), Int_.To_str(file_w), Double_.To_str(lnki_time), Int_.To_str(lnki_page)
|
||||
);
|
||||
}
|
||||
@gplx.Virtual public void Data_parse(Bry_rdr_old rdr) {
|
||||
this.lnki_ttl = gplx.langs.htmls.encoders.Gfo_url_encoder_.Http_url.Decode(rdr.Read_bry_to_pipe());
|
||||
this.orig_ext = rdr.Read_int_to_pipe();
|
||||
this.lnki_type = rdr.Read_byte_to_pipe();
|
||||
this.lnki_w = rdr.Read_int_to_pipe();
|
||||
this.lnki_h = rdr.Read_int_to_pipe();
|
||||
this.lnki_upright = rdr.Read_double_to_pipe();
|
||||
this.lnki_time = rdr.Read_double_to_pipe();
|
||||
this.lnki_page = rdr.Read_int_to_pipe();
|
||||
this.orig_repo_id = rdr.Read_int_to_pipe();
|
||||
this.file_is_orig = rdr.Read_yn_to_pipe();
|
||||
this.file_w = rdr.Read_int_to_pipe();
|
||||
this.html_uid = rdr.Read_int_to_pipe();
|
||||
this.html_w = rdr.Read_int_to_pipe();
|
||||
this.html_h = rdr.Read_int_to_pipe();
|
||||
}
|
||||
@gplx.Virtual public void Data_write_hook(Bry_bfr bfr) {}
|
||||
@Override public String toString() {return this.Data_print();} // TEST
|
||||
public static final int Tid_basic = 0, Tid_gallery = 1;
|
||||
public static final int
|
||||
File_repo_id_commons = Xof_repo_itm_.Repo_remote
|
||||
, File_repo_id_local = Xof_repo_itm_.Repo_local
|
||||
, File_repo_id_null = Xof_repo_itm_.Repo_null
|
||||
;
|
||||
public static final Xohd_img_itm__base[] Ary_empty = new Xohd_img_itm__base[0];
|
||||
}
|
||||
@@ -1,44 +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.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.core.brys.*; import gplx.xowa.files.*;
|
||||
public class Xohd_img_itm__gallery_itm extends Xohd_img_itm__base {
|
||||
@Override public int Img_tid() {return Xohd_img_itm__base.Tid_gallery;}
|
||||
@Override public byte Html_elem_tid() {return Xof_html_elem.Tid_img;}
|
||||
public int Box_w() {return box_w;} private int box_w;
|
||||
public int Img_w() {return img_w;} private int img_w;
|
||||
public int Img_pad() {return img_pad;} private int img_pad;
|
||||
public Xohd_img_itm__gallery_itm Data_init_gallery(int box_w, int img_w, int img_pad) {
|
||||
this.box_w = box_w;
|
||||
this.img_w = img_w;
|
||||
this.img_pad = img_pad;
|
||||
return this;
|
||||
}
|
||||
@Override public void Data_write_hook(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(box_w).Add_byte_pipe()
|
||||
.Add_int_variable(img_w).Add_byte_pipe()
|
||||
.Add_int_variable(img_pad).Add_byte_pipe()
|
||||
;
|
||||
}
|
||||
@Override public void Data_parse(Bry_rdr_old rdr) {
|
||||
super.Data_parse(rdr);
|
||||
this.box_w = rdr.Read_int_to_pipe();
|
||||
this.img_w = rdr.Read_int_to_pipe();
|
||||
this.img_pad = rdr.Read_int_to_pipe();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +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.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
public class Xohd_img_itm__gallery_mgr implements Xohd_img_itm {
|
||||
public Xohd_img_itm__gallery_mgr(int uid, int box_max) {
|
||||
this.uid = uid;
|
||||
this.box_max = box_max;
|
||||
}
|
||||
public int Data_tid() {return Xohd_img_tid.Tid_gallery;}
|
||||
public void Data_write(Bry_bfr bfr) {
|
||||
bfr .Add_int_variable(Xohd_img_tid.Tid_gallery).Add_byte_pipe()
|
||||
.Add_int_variable(uid).Add_byte_pipe()
|
||||
.Add_int_variable(box_max).Add_byte_pipe()
|
||||
;
|
||||
bfr.Add_byte_nl();
|
||||
}
|
||||
public String Data_print() {return Int_.To_str(box_max);}
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public int Box_max() {return box_max;} private int box_max;
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
public class Xohd_img_tid { // SERIALIZED
|
||||
public static final int
|
||||
Tid_img = 1
|
||||
, Tid_redlink = 2
|
||||
, Tid_gallery = 3
|
||||
, Tid_imap = 4
|
||||
;
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public class Xoh_make_fxt {
|
||||
parser_fxt.Reset();
|
||||
page_chkr.Clear();
|
||||
}
|
||||
public Xoh_page_chkr Page_chkr() {return page_chkr;} private final Xoh_page_chkr page_chkr = new Xoh_page_chkr();
|
||||
public Xop_fxt Parser_fxt() {return parser_fxt;} private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
public Xoh_page_chkr Page_chkr() {return page_chkr;} private final Xoh_page_chkr page_chkr = new Xoh_page_chkr();
|
||||
public Xop_fxt Parser_fxt() {return parser_fxt;} private final Xop_fxt parser_fxt = new Xop_fxt();
|
||||
public void Init_img_cache
|
||||
( String wiki_abrv, String lnki_ttl, byte lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page
|
||||
, boolean repo_is_commons, String html_ttl, int html_w, int html_h, double html_time, int html_page
|
||||
@@ -47,7 +47,7 @@ public class Xoh_make_fxt {
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Test_console();
|
||||
Xoh_make_mgr make_mgr = parser_fxt.Wiki().Html__hdump_mgr().Load_mgr().Make_mgr();
|
||||
byte[] actl_body = make_mgr.Parse(Bry_.new_u8(html), actl, parser_fxt.Wiki());
|
||||
actl.Body_(actl_body);
|
||||
actl.Db().Html().Html_bry_(actl_body);
|
||||
Gfo_usr_dlg_.Instance = Gfo_usr_dlg_.Noop;
|
||||
chkr.Check(actl);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Xoh_page_chkr {
|
||||
return this;
|
||||
}
|
||||
public void Check(Xoh_page actl) {
|
||||
if (expd_body != null) Tfds.Eq_str_lines(expd_body, String_.new_u8(actl.Body()));
|
||||
if (expd_body != null) Tfds.Eq_str_lines(expd_body, String_.new_u8(actl.Db().Html().Html_bry()));
|
||||
if (expd_section_mgr.Len() > 0)
|
||||
Tfds.Eq_str_lines(To_str__section_mgr(expd_section_mgr), To_str__section_mgr(actl.Section_mgr()));
|
||||
if (expd_img_mgr.Len() > 0)
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.htmls.core.wkrs; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
|
||||
private final Xoh_stat_itm stat_itm = new Xoh_stat_itm();
|
||||
private final Xoh_stat_itm stat_itm = new Xoh_stat_itm();
|
||||
private Xoh_hzip_bfr bfr; private Xoh_hdoc_ctx hctx; private byte[] src;
|
||||
private Xoh_page hpg;
|
||||
public void On_new_page(Xoh_hzip_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, int src_bgn, int src_end) {
|
||||
@@ -39,6 +39,7 @@ public class Xoh_hdoc_wkr__hzip implements Xoh_hdoc_wkr {
|
||||
case Xoh_hzip_dict_.Tid__lnke: wkr = hctx.Pool_mgr__hzip().Mw__lnke(); break;
|
||||
case Xoh_hzip_dict_.Tid__img: wkr = hctx.Pool_mgr__hzip().Mw__img(); break;
|
||||
case Xoh_hzip_dict_.Tid__img_bare: wkr = hctx.Pool_mgr__hzip().Mw__img_bare(); break;
|
||||
case Xoh_hzip_dict_.Tid__toc: wkr = hctx.Pool_mgr__hzip().Mw__toc(); break;
|
||||
default: throw Err_.new_unhandled(data.Tid());
|
||||
}
|
||||
wkr.Encode1(bfr, this, hctx, hpg, Bool_.Y, src, data).Pool__rls();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.addons.pgbnrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_pgbnr_data implements Xoh_data_itm {// NOTE: some galleries fail hzip; use Hook_bry to catch them; PAGE:en.d:a; DATE:2016-06-24
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__pgbnr;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public void Clear() {
|
||||
this.src_bgn = this.src_end = -1;
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag pgbnr_lhs, Gfh_tag unused) {
|
||||
this.Clear();
|
||||
this.src_bgn = pgbnr_lhs.Src_bgn();
|
||||
this.src_end = pgbnr_lhs.Src_end();
|
||||
return true;
|
||||
}
|
||||
public void Init_by_decode(int src_bgn, int src_end) {
|
||||
}
|
||||
public boolean Init_by_edit(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag pgbnr_lhs, Gfh_tag unused) {
|
||||
this.Clear();
|
||||
this.src_bgn = pgbnr_lhs.Src_bgn();
|
||||
this.src_end = pgbnr_lhs.Src_end();
|
||||
return true;
|
||||
}
|
||||
// public static final byte[] Hook_bry = Bry_.new_a7(" class=\"pgbnr mw-pgbnr");
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_pgbnr_data rv = new Xoh_pgbnr_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
}
|
||||
@@ -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.htmls.core.wkrs.addons.pgbnrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.addons.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_pgbnr_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__pgbnr;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__pgbnr;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_pgbnr_data data = (Xoh_pgbnr_data)data_obj;
|
||||
|
||||
bfr.Add_mid(src, data.Src_bgn(), data.Src_end());
|
||||
|
||||
hctx.Hzip__stat().Gallery_add();
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
int pgbnr_bgn = src_bgn;
|
||||
int pgbnr_end = Bry_find_.Find_fwd(src, Byte_ascii.Gt, src_bgn, src_end);
|
||||
if (pgbnr_end == -1) {
|
||||
Gfo_log_.Instance.Warn("hzip.pgbnr.end_not_found", "page", hpg.Url_bry_safe(), "src_bgn", src_bgn);
|
||||
pgbnr_end = pgbnr_bgn;
|
||||
}
|
||||
else
|
||||
++pgbnr_end;
|
||||
|
||||
Xoh_pgbnr_data data = (Xoh_pgbnr_data)data_itm;
|
||||
data.Init_by_decode(pgbnr_bgn, pgbnr_end);
|
||||
rdr.Move_to(pgbnr_end);
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_pgbnr_hzip rv = new Xoh_pgbnr_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import gplx.xowa.htmls.core.htmls.*;
|
||||
public class Xoh_hdr_html {
|
||||
public void Write_html(Bry_bfr bfr, Xoh_html_wtr wtr, Xowe_wiki wiki, Xoae_page page, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoh_html_wtr_cfg cfg, Xop_tkn_grp grp, int sub_idx, byte[] src, Xop_hdr_tkn hdr) {
|
||||
if (hdr.Hdr_html_first() && cfg.Toc__show() && !page.Hdr_mgr().Toc_manual()) // __TOC__ not specified; place at top; NOTE: if __TOC__ was specified, then it would be placed wherever __TOC__ appears
|
||||
wiki.Html_mgr().Toc_mgr().Html(ctx.Page(), hctx, src, bfr, true);
|
||||
wiki.Html_mgr().Toc_mgr().Html(ctx.Page(), hctx, bfr, page.Html_data().Xtn_pgbnr() != null);
|
||||
|
||||
int hdr_len = hdr.Hdr_level();
|
||||
if (hdr_len > 0) { // NOTE: need to check hdr_len b/c it could be dangling
|
||||
@@ -47,7 +47,7 @@ public class Xoh_hdr_html {
|
||||
bfr.Add(Bry__hdr_rhs_end); // '>\n'
|
||||
}
|
||||
}
|
||||
private static final byte[] Bry__hdr_lhs_bgn = Bry_.new_a7("<h"), Bry__hdr_rhs_bgn = Bry_.new_a7("</h"), Bry__hdr_rhs_end = Bry_.new_a7(">\n")
|
||||
private static final byte[] Bry__hdr_lhs_bgn = Bry_.new_a7("<h"), Bry__hdr_rhs_bgn = Bry_.new_a7("</h"), Bry__hdr_rhs_end = Bry_.new_a7(">\n")
|
||||
, Bry__span_lhs_bgn = Bry_.new_a7("<span class=\"mw-headline\" id=\""), Bry__span_lhs_end = Bry_.new_a7("\">")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ 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.htmls.core.wkrs.hdrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
import org.junit.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.tocs.*;
|
||||
public class Xoh_hdr_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt();
|
||||
@Before public void init() {Xoh_toc_wtr.Enabled = false;}
|
||||
@After public void term() {Xoh_toc_wtr.Enabled = true;}
|
||||
@Test public void Same() {
|
||||
fxt.Test__bicode(String_.Concat_lines_nl_skip_last
|
||||
( "~\"'A~"
|
||||
|
||||
@@ -36,6 +36,7 @@ public class Xoh_hdr_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
|
||||
else
|
||||
hdr_id = Bry_.Replace(hdr_content, Byte_ascii.Space, Byte_ascii.Underline);
|
||||
hdr_capt_rhs = data.Capt_rhs_exists() ? Bry_.Mid(src, data.Capt_rhs_bgn(), data.Capt_rhs_end()) : Bry_.Empty;
|
||||
hpg.Hdump_mgr().Toc_wtr().Add(hdr_num, hdr_content);
|
||||
return true;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
|
||||
@@ -66,16 +66,17 @@ public class Xoh_img_data implements Xoh_data_itm {
|
||||
tag_rdr.Tag__move_fwd_head(); // next <div>
|
||||
anch_head = tag_rdr.Tag__move_fwd_head(); // next <div>
|
||||
}
|
||||
this.src_bgn = anch_head.Src_bgn(); // <a
|
||||
if (!anch_href.Parse(err_wkr, hctx, src, anch_head)) return false; // href='/wiki/File:A.png'
|
||||
if (!anch_cls.Parse(err_wkr, src, anch_head)) return false; // class='image'
|
||||
Gfh_atr anch_title = anch_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__title); // title='abc'
|
||||
this.src_bgn = anch_head.Src_bgn(); // <a
|
||||
if (!anch_href.Parse(err_wkr, hctx, src, anch_head)) return false; // href='/wiki/File:A.png'
|
||||
if (!anch_cls.Parse(err_wkr, src, anch_head)) return false; // class='image'
|
||||
Gfh_atr anch_title = anch_head.Atrs__get_by_or_empty(Gfh_atr_.Bry__title); // title='abc'
|
||||
anch_title_bgn = anch_title.Val_bgn(); anch_title_end = anch_title.Val_end();
|
||||
Gfh_atr xowa_title = anch_head.Atrs__get_by_or_empty(Bry__atr__xowa_title); // xowa_title='A.png'
|
||||
Gfh_atr xowa_title = anch_head.Atrs__get_by_or_empty(Bry__atr__xowa_title); // xowa_title='A.png'
|
||||
if (xowa_title.Val_dat_exists()) anch_page.Val_(xowa_title.Val());
|
||||
img_tag = tag_rdr.Tag__move_fwd_head();
|
||||
}
|
||||
img_tag.Chk_name_or_fail(Gfh_tag_.Id__img); // <img
|
||||
// if (img_tag.Atrs__cls_has(gplx.xowa.xtns.pagebanners.Pgbnr_xtn_mgr.Bry__cls__wpb_banner_image)) return false; // ignore pagebanner; EX: <img class="wpb-banner-image">
|
||||
img_xoimg.Parse(err_wkr, src, img_tag); // data-xoimg='...'
|
||||
this.img_w = img_tag.Atrs__get_as_int_or(Gfh_atr_.Bry__width, Xof_img_size.Size__neg1); // width='220'
|
||||
this.img_h = img_tag.Atrs__get_as_int_or(Gfh_atr_.Bry__height, Xof_img_size.Size__neg1); // height='110'
|
||||
|
||||
@@ -89,7 +89,8 @@ public class Xoh_img_xoimg_data implements Bfr_arg_clearable {
|
||||
bfr.Add_int_variable(lnki_page);
|
||||
}
|
||||
public static final byte[]
|
||||
Bry__data_xowa_image = Bry_.new_a7("data-xoimg")
|
||||
, Bry__data_xowa_title = Bry_.new_a7("data-xowa-title")
|
||||
Bry__data_xowa_image = Bry_.new_a7("data-xoimg")
|
||||
, Bry__data_xowa_title = Bry_.new_a7("data-xowa-title")
|
||||
, Bry__data_xowa_image__full = Bry_.new_a7("0|-1|-1|-1|-1|-1") // for pagebanner
|
||||
;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public class Xoh_lnki_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
try {
|
||||
Xoa_ttl ttl = hpg.Wiki().Ttl_parse(Gfo_url_encoder_.Href.Decode(href_bry));
|
||||
Xopg_lnki_itm__hdump lnki_itm = new Xopg_lnki_itm__hdump(ttl);
|
||||
hpg.Redlink_list().Add(lnki_itm);
|
||||
hpg.Html_data().Redlink_list().Add(lnki_itm);
|
||||
html_uid = lnki_itm.Html_uid();
|
||||
} catch (Exception e) {Gfo_log_.Instance.Warn("failed to add lnki to redlinks", "page", hpg.Url_bry_safe(), "href_bry", href_bry, "e", Err_.Message_gplx_log(e));}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
public class Xoh_arg_img_core__hdump implements gplx.core.brys.Bfr_arg, Xoh_arg_img_core {
|
||||
private int uid;
|
||||
public Xoh_arg_img_core Init(int uid, byte[] img_src, int img_w, int img_h) {
|
||||
this.uid = uid;
|
||||
return this;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
bfr.Add_byte_space();
|
||||
bfr.Add(gplx.xowa.htmls.core.makes.Xoh_make_trie_.Bry__img);
|
||||
bfr.Add_int_variable(uid);
|
||||
bfr.Add_byte_quote();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.core.wkrs.lnkis.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.wkrs.lnkis.*;
|
||||
import gplx.core.brys.*; import gplx.core.bits.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.makes.imgs.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.encoders.*; import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.imgs.atrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
import gplx.xowa.wikis.nss.*; import gplx.xowa.files.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.lnkis.*; import gplx.xowa.parsers.tmpls.*;
|
||||
@@ -86,9 +86,6 @@ public class Xoh_file_wtr__basic {
|
||||
else // image
|
||||
this.Write_file_image(bfr, ctx, hctx, src, lnki, xfer_itm, uid, lnki_is_thumbable, div_width, lnki_halign, lnki_halign_bry, lnki_ttl, orig_ext, lnki_href, img_view_src, img_orig_src, img_alt);
|
||||
}
|
||||
if (hctx.Mode_is_hdump() && Xof_html_elem.Tid_is_file(xfer_itm.Html_elem_tid())) {
|
||||
page.Hdump_data().Imgs_add_img(new Xohd_img_itm__img(), xfer_itm, Xohd_img_itm__gallery_itm.Tid_basic);
|
||||
}
|
||||
}
|
||||
private void Write_file_ns_media(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xop_lnki_tkn lnki, byte[] img_orig_src) {
|
||||
html_fmtr.Html_full_media(bfr, hctx.Mode_is_hdump(), img_orig_src, lnki.Ttl().Page_txt(), Arg_caption(ctx, src, Xoh_wtr_ctx.Basic, lnki)); // NOTE: use orig_src not view_src; DATE:2014-01-19
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Xoh_lnki_wtr {
|
||||
public void Init_by_page(Xop_ctx ctx, Xoh_wtr_ctx hctx, byte[] src, Xoae_page page) {
|
||||
this.ctx = ctx; this.page = page; // NOTE: must set ctx for file.v2; DATE:2014-06-22
|
||||
this.wiki = ctx.Wiki();
|
||||
redlinks_mgr = page.Redlink_list(); // NOTE: need to set redlinks_mgr, else toc parse may fail; EX:pl.d:head_sth_off;DATE:2014-05-07
|
||||
redlinks_mgr = page.Html_data().Redlink_list(); // NOTE: need to set redlinks_mgr, else toc parse may fail; EX:pl.d:head_sth_off;DATE:2014-05-07
|
||||
file_wtr.Init_by_page(hctx, page);
|
||||
this.history_mgr = app.Usere().History_mgr();
|
||||
if (hctx.Mode_is_hdump()) cfg.Lnki__id_(false);
|
||||
|
||||
@@ -20,7 +20,7 @@ import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*;
|
||||
import gplx.xowa.htmls.core.wkrs.lnkes.*; import gplx.xowa.htmls.core.wkrs.lnkis.*; import gplx.xowa.htmls.core.wkrs.hdrs.*; import gplx.xowa.htmls.core.wkrs.xndes.*;
|
||||
import gplx.xowa.htmls.core.wkrs.imgs.*; import gplx.xowa.htmls.core.wkrs.thms.*; import gplx.xowa.htmls.core.wkrs.glys.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
import gplx.xowa.wikis.ttls.*;
|
||||
public class Xoh_tag_parser implements Gfh_doc_wkr {
|
||||
private final Xoh_hdoc_wkr hdoc_wkr;
|
||||
@@ -77,6 +77,8 @@ public class Xoh_tag_parser implements Gfh_doc_wkr {
|
||||
}
|
||||
else if (cur.Atrs__cls_has(Xoh_thm_data.Atr__id__xowa_media_div))
|
||||
rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__img);
|
||||
else if (cur.Atrs__cls_has(Xoh_toc_wtr.Atr__class__toc))
|
||||
rv = Parse_by_data(hdoc_wkr, hctx, tag_rdr, src, cur, null, Xoh_hzip_dict_.Tid__toc);
|
||||
break;
|
||||
case Gfh_tag_.Id__ul:
|
||||
if (cur.Atrs__cls_has(Xoh_gly_grp_data.Atr__cls__gallery)) {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.threads.poolables.*;
|
||||
import gplx.langs.htmls.*; import gplx.langs.htmls.docs.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_toc_data implements Xoh_data_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__toc;}
|
||||
public int Src_bgn() {return src_bgn;} private int src_bgn;
|
||||
public int Src_end() {return src_end;} private int src_end;
|
||||
public byte Toc_mode() {return toc_mode;} private byte toc_mode;
|
||||
public void Clear() {
|
||||
this.src_bgn = this.src_end = -1;
|
||||
this.toc_mode = Toc_mode__basic;
|
||||
}
|
||||
public boolean Init_by_parse(Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Gfh_tag_rdr tag_rdr, byte[] src, Gfh_tag toc_lhs, Gfh_tag unused) {
|
||||
this.Clear();
|
||||
this.src_bgn = toc_lhs.Src_bgn();
|
||||
this.toc_mode = toc_lhs.Atrs__has(Xoh_toc_wtr.Atr__data__toc__mode) ? Toc_mode__pgbnr : Toc_mode__basic;
|
||||
Gfh_tag toc_rhs = tag_rdr.Tag__move_fwd_tail(toc_lhs.Name_id());
|
||||
this.src_end = toc_rhs.Src_end();
|
||||
return true;
|
||||
}
|
||||
public void Init_by_decode(byte toc_mode) {
|
||||
this.toc_mode = toc_mode;
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_toc_data rv = new Xoh_toc_data(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
|
||||
public static final byte Toc_mode__basic = 0, Toc_mode__pgbnr = 1;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*; import gplx.core.threads.poolables.*; import gplx.xowa.wikis.ttls.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_toc_hzip implements Xoh_hzip_wkr, Gfo_poolable_itm {
|
||||
public int Tid() {return Xoh_hzip_dict_.Tid__toc;}
|
||||
public String Key() {return Xoh_hzip_dict_.Key__toc;}
|
||||
public byte[] Hook() {return hook;} private byte[] hook;
|
||||
public Gfo_poolable_itm Encode1(Xoh_hzip_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, boolean wkr_is_root, byte[] src, Object data_obj) {
|
||||
Xoh_toc_data data = (Xoh_toc_data)data_obj;
|
||||
bfr.Add(hook);
|
||||
flag_bldr.Set(Flag__toc_mode , data.Toc_mode());
|
||||
Gfo_hzip_int_.Encode(1, bfr, flag_bldr.Encode());
|
||||
return this;
|
||||
}
|
||||
public void Decode1(Bry_bfr bfr, Xoh_hdoc_wkr hdoc_wkr, Xoh_hdoc_ctx hctx, Xoh_page hpg, Bry_rdr rdr, byte[] src, int src_bgn, int src_end, Xoh_data_itm data_itm) {
|
||||
Xoh_toc_data data = (Xoh_toc_data)data_itm;
|
||||
int flag = rdr.Read_hzip_int(1); flag_bldr.Decode(flag);
|
||||
byte toc_mode = flag_bldr.Get_as_byte(Flag__toc_mode);
|
||||
data.Init_by_decode(toc_mode);
|
||||
}
|
||||
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_toc_hzip rv = new Xoh_toc_hzip(); rv.pool_mgr = mgr; rv.pool_idx = idx; rv.hook = (byte[])args[0]; return rv;}
|
||||
|
||||
private final Int_flag_bldr flag_bldr = new Int_flag_bldr().Pow_ary_bld_(2);
|
||||
private static final int // SERIALIZED
|
||||
Flag__toc_mode = 0 // 4: 0=basic; 1=pgbnr; 2,3=reserved
|
||||
;
|
||||
}
|
||||
@@ -15,9 +15,11 @@ 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.htmls.core.makes.imgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.makes.*;
|
||||
import gplx.xowa.files.*;
|
||||
public class Xohd_img_itm__img extends Xohd_img_itm__base {
|
||||
@Override public int Img_tid() {return Xohd_img_itm__base.Tid_basic;}
|
||||
@Override public byte Html_elem_tid() {return Xof_html_elem.Tid_img;}
|
||||
package gplx.xowa.htmls.core.wkrs.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.htmls.core.makes.tests.*;
|
||||
public class Xoh_toc_hzip_tst {
|
||||
private final Xoh_hzip_fxt fxt = new Xoh_hzip_fxt().Init_mode_diff_y_();
|
||||
@Test public void Basic() { // EX: <div class='xo-toc'/>
|
||||
fxt.Test__bicode("~)!", "<div class=\"xo-toc\"></div>");
|
||||
}
|
||||
}
|
||||
51
400_xowa/src/gplx/xowa/htmls/core/wkrs/tocs/Xoh_toc_wtr.java
Normal file
51
400_xowa/src/gplx/xowa/htmls/core/wkrs/tocs/Xoh_toc_wtr.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
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.htmls.core.wkrs.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.wkrs.*;
|
||||
import gplx.core.brys.*; import gplx.core.primitives.*; import gplx.core.brys.fmtrs.*; import gplx.core.threads.poolables.*; import gplx.core.brys.args.*;
|
||||
import gplx.langs.htmls.*; import gplx.xowa.htmls.core.wkrs.bfr_args.*;
|
||||
import gplx.xowa.htmls.sections.*; import gplx.xowa.htmls.core.hzips.*;
|
||||
public class Xoh_toc_wtr implements gplx.core.brys.Bfr_arg, Xoh_wtr_itm {
|
||||
private byte toc_mode;
|
||||
public void Init_by_parse(Bry_bfr bfr, Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_toc_data data) {
|
||||
Init_by_decode(hpg, hctx, src, data);
|
||||
this.Bfr_arg__add(bfr);
|
||||
}
|
||||
public boolean Init_by_decode(Xoh_page hpg, Xoh_hdoc_ctx hctx, byte[] src, Xoh_data_itm data_itm) {
|
||||
Xoh_toc_data data = (Xoh_toc_data)data_itm;
|
||||
this.toc_mode = data.Toc_mode();
|
||||
return true;
|
||||
}
|
||||
public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
Write_tag(bfr, toc_mode == Xoh_toc_data.Toc_mode__pgbnr);
|
||||
}
|
||||
public void Pool__rls () {pool_mgr.Rls_fast(pool_idx);} private Gfo_poolable_mgr pool_mgr; private int pool_idx;
|
||||
public Gfo_poolable_itm Pool__make (Gfo_poolable_mgr mgr, int idx, Object[] args) {Xoh_toc_wtr rv = new Xoh_toc_wtr(); rv.pool_mgr = mgr; rv.pool_idx = idx; return rv;}
|
||||
|
||||
public static final byte[]
|
||||
Atr__class__toc = Bry_.new_a7("xo-toc")
|
||||
, Atr__data__toc__mode = Bry_.new_a7("data-toc-mode")
|
||||
;
|
||||
public static void Write_tag(Bry_bfr bfr, boolean pgbnr_enabled) {
|
||||
bfr.Add(Gfh_tag_.Div_lhs_bgn);
|
||||
Gfh_atr_.Add(bfr, Gfh_atr_.Bry__class, Atr__class__toc);
|
||||
if (pgbnr_enabled)
|
||||
Gfh_atr_.Add(bfr, Atr__data__toc__mode, Xoh_toc_data.Toc_mode__pgbnr);
|
||||
Gfh_tag_.Lhs_end_nde(bfr);
|
||||
bfr.Add(Gfh_tag_.Div_rhs);
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class Xoh_href_wtr_fxt {
|
||||
}
|
||||
public Xoh_href_wtr_fxt Prep_xwiki_by_many(String raw) {wiki.Xwiki_mgr().Add_by_csv(Bry_.new_u8(raw)); return this;} // need to add to wiki's xwiki_mgr for ttl_parse
|
||||
public void Test_build(String raw, String expd) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(raw));
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(raw));
|
||||
href_wtr.Build_to_bfr(tmp_bfr, app, wiki.Domain_bry(), ttl);
|
||||
Tfds.Eq(expd, tmp_bfr.To_str_and_clear());
|
||||
}
|
||||
|
||||
@@ -64,9 +64,9 @@ public class Xoh_js_cbk implements Gfo_invk {
|
||||
private String Get_page(GfoMsg m) {
|
||||
Xowe_wiki wiki = html_itm.Owner_tab().Wiki();
|
||||
try {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, m.Args_getAt(0).Val_to_bry());
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, m.Args_getAt(0).Val_to_bry());
|
||||
Xoae_page page = wiki.Data_mgr().Load_page_by_ttl(ttl);
|
||||
return String_.new_u8(page.Data_raw());
|
||||
return String_.new_u8(page.Db().Text().Text_bry());
|
||||
} catch (Exception e) {Err_.Noop(e); return null;}
|
||||
}
|
||||
private String Popups_get_async_bgn(GfoMsg m) {
|
||||
@@ -87,7 +87,7 @@ public class Xoh_js_cbk implements Gfo_invk {
|
||||
private String[] Get_title_meta(Xowe_wiki wiki, byte[] ttl_bry) {
|
||||
synchronized (tmp_page) {
|
||||
tmp_page.Clear();
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttl(tmp_page, ttl.Ns(), ttl.Page_db());
|
||||
}
|
||||
return String_.Ary(tmp_page.Exists() ? "1" : "0", Int_.To_str(tmp_page.Id()), Int_.To_str(tmp_page.Ns_id()), String_.new_u8(tmp_page.Ttl_page_db()), Bool_.To_str_lower(tmp_page.Redirected()), tmp_page.Modified_on().XtoStr_fmt("yyyy-MM-dd HH:mm:ss"), Int_.To_str(tmp_page.Text_len()));
|
||||
|
||||
@@ -35,7 +35,7 @@ class Xoh_js_cbk_fxt {
|
||||
public void Test_get_title(String ttl, Object... expd) {
|
||||
Xoae_app app = fxt.App();
|
||||
Xowe_wiki wiki = fxt.Wiki();
|
||||
Xoae_page page = Xoae_page.New_test(wiki, Xoa_ttl.parse(wiki, Bry_.new_a7("mock_page")));
|
||||
Xoae_page page = Xoae_page.New_test(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7("mock_page")));
|
||||
Xog_tab_itm tab = app.Gui_mgr().Browser_win().Active_tab();
|
||||
tab.Page_(page);
|
||||
Xoh_js_cbk exec = tab.Html_itm().Js_cbk();
|
||||
|
||||
@@ -46,8 +46,8 @@ public class Xow_popup_html_mkr {
|
||||
, String_.new_u8(page.Ttl().Full_txt_w_ttl_case())
|
||||
, popup_itm.Popup_id()
|
||||
, Xow_popup_html_bldr_.Bld_fmtr_wiki(fmtr_wiki, wrdx_bfr, cur_wiki.Domain_bry(), page.Wiki().Domain_bry()) // NOTE: use cur_wiki, not page_wiki; DATE:2014-06-28
|
||||
, gplx.core.ios.Io_size_.To_str(page.Data_raw().length)
|
||||
, page.Revision_data().Modified_on().XtoStr_fmt_yyyy_MM_dd_HH_mm_ss()
|
||||
, gplx.core.ios.Io_size_.To_str(page.Db().Text().Text_bry().length)
|
||||
, page.Db().Page().Modified_on().XtoStr_fmt_yyyy_MM_dd_HH_mm_ss()
|
||||
, Xow_popup_html_bldr_.Bld_fmtr_viewed(fmtr_viewed, app, wiki, wrdx_bfr, page.Ttl())
|
||||
, app.Fsys_mgr().Root_dir().To_http_file_bry()
|
||||
);
|
||||
|
||||
@@ -122,7 +122,7 @@ public class Xow_popup_mgr implements Gfo_invk, Gfo_evt_itm {
|
||||
if (!Xoa_url_.Tid_is_pagelike(tmp_url.Tid())) return Bry_.Empty; // NOTE: do not get popups for "file:///"; DATE:2015-04-05
|
||||
Xowe_wiki popup_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_null(tmp_url.Wiki_bry());
|
||||
popup_wiki.Init_assert();
|
||||
Xoa_ttl popup_ttl = Xoa_ttl.parse(popup_wiki, tmp_url.To_bry_page_w_anch());
|
||||
Xoa_ttl popup_ttl = Xoa_ttl.Parse(popup_wiki, tmp_url.To_bry_page_w_anch());
|
||||
switch (popup_ttl.Ns().Id()) {
|
||||
case Xow_ns_.Tid__media:
|
||||
case Xow_ns_.Tid__file:
|
||||
@@ -277,7 +277,7 @@ class Load_popup_wkr implements Gfo_thread_wkr {
|
||||
if (!Xoa_url_.Tid_is_pagelike(tmp_url.Tid())) return; // NOTE: do not get popups for "file:///"; DATE:2015-04-05
|
||||
Xowe_wiki popup_wiki = (Xowe_wiki)app.Wiki_mgr().Get_by_or_null(tmp_url.Wiki_bry());
|
||||
popup_wiki.Init_assert();
|
||||
Xoa_ttl popup_ttl = Xoa_ttl.parse(popup_wiki, tmp_url.To_bry_page_w_anch());
|
||||
Xoa_ttl popup_ttl = Xoa_ttl.Parse(popup_wiki, tmp_url.To_bry_page_w_anch());
|
||||
switch (popup_ttl.Ns().Id()) {
|
||||
case Xow_ns_.Tid__media:
|
||||
case Xow_ns_.Tid__file:
|
||||
|
||||
@@ -74,7 +74,7 @@ public class Xow_popup_parser {
|
||||
data.Wrdx_bfr().Add(app.Wiki_mgr().Wdata_mgr().Popup_text(page));
|
||||
}
|
||||
else {
|
||||
byte[] tmpl_src = page.Data_raw(); int tmpl_len = tmpl_src.length; if (tmpl_len == 0) return Bry_.Empty;
|
||||
byte[] tmpl_src = page.Db().Text().Text_bry(); int tmpl_len = tmpl_src.length; if (tmpl_len == 0) return Bry_.Empty;
|
||||
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();
|
||||
|
||||
@@ -21,7 +21,7 @@ import gplx.xowa.apps.apis.xowa.html.modules.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xow_popup_parser_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xop_popup_parser_fxt fxt = new Xop_popup_parser_fxt();
|
||||
@Before public void init() {fxt.Clear();} private final Xop_popup_parser_fxt fxt = new Xop_popup_parser_fxt();
|
||||
@Test public void Text_chars_one() {
|
||||
fxt.Test_parse
|
||||
( "a b c d", String_.Concat_lines_nl_skip_last
|
||||
@@ -505,8 +505,8 @@ class Xop_popup_parser_fxt {
|
||||
}
|
||||
public void Test_parse(String raw, String expd) {Test_parse(raw, "Test_1", expd);}
|
||||
public void Test_parse(String raw, String ttl, String expd) {
|
||||
Xoae_page page = Xoae_page.New_edit(wiki, Xoa_ttl.parse(wiki, Bry_.new_a7(ttl)));
|
||||
page.Data_raw_(Bry_.new_u8(raw));
|
||||
Xoae_page page = Xoae_page.New_edit(wiki, Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)));
|
||||
page.Db().Text().Text_bry_(Bry_.new_u8(raw));
|
||||
Xow_popup_itm itm = new Xow_popup_itm(1, Bry_.new_u8(raw), Bry_.Empty, word_min);
|
||||
itm.Init(wiki.Domain_bry(), page.Ttl());
|
||||
byte[] actl = parser.Parse(wiki, page, null, itm);
|
||||
|
||||
@@ -95,7 +95,7 @@ class Xoh_ns_file_page_mgr_fxt {
|
||||
}
|
||||
public void tst(String expd) {
|
||||
byte[] ttl_bry = Bry_.new_u8(ttl_str);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, ttl_bry);
|
||||
file.Init_at_gallery_end(html_w, html_h, Io_url_.mem_fil_(html_src), Io_url_.mem_fil_(html_orig_src));
|
||||
// file.Orig_ttl_and_redirect_(ttl_bry, Bry_.Empty);
|
||||
file.Init_at_orig(Byte_.Zero, wiki.Domain_bry(), ttl_bry, Xof_ext_.new_by_ttl_(ttl_bry), 0, 0, Bry_.Empty);
|
||||
|
||||
@@ -48,7 +48,7 @@ class Xoh_page_body_cls_fxt {
|
||||
tmp_bfr = Bry_bfr_.Reset(255);
|
||||
wiki.Ns_mgr().Add_new(Wdata_wiki_mgr.Ns_property, Wdata_wiki_mgr.Ns_property_name);
|
||||
}
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str));
|
||||
Xoa_ttl ttl = Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str));
|
||||
Tfds.Eq(expd, String_.new_u8(Xoh_page_body_cls.Calc(tmp_bfr, ttl, page_tid)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class Xoh_subpages_bldr_fxt {
|
||||
wiki.Ns_mgr().Ids_get_or_null(Xow_ns_.Tid__help).Subpages_enabled_(true);
|
||||
}
|
||||
public void Test_bld(String ttl_str, String expd) {
|
||||
byte[] actl = subpages_bldr.Bld(wiki.Ns_mgr(), Xoa_ttl.parse(wiki, Bry_.new_u8(ttl_str)));
|
||||
byte[] actl = subpages_bldr.Bld(wiki.Ns_mgr(), Xoa_ttl.Parse(wiki, Bry_.new_u8(ttl_str)));
|
||||
Tfds.Eq_str_lines(expd, String_.new_u8(actl));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Xowh_portal_mgr_fxt {
|
||||
}
|
||||
} private Xoae_app app; Xowe_wiki wiki;
|
||||
public void Test_div_ns_bry(String ttl, String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Html_mgr().Portal_mgr().Div_ns_bry(wiki.Utl__bfr_mkr(), Xoa_ttl.parse(wiki, Bry_.new_a7(ttl)), wiki.Ns_mgr())));
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Html_mgr().Portal_mgr().Div_ns_bry(wiki.Utl__bfr_mkr(), Xoa_ttl.Parse(wiki, Bry_.new_a7(ttl)), wiki.Ns_mgr())));
|
||||
}
|
||||
public void Test_div_personal_bry(String expd) {
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Html_mgr().Portal_mgr().Div_personal_bry()));
|
||||
|
||||
@@ -25,9 +25,9 @@ class Xoh_toc_htmlr implements gplx.core.brys.Bfr_arg {
|
||||
public void Clear() {
|
||||
prv_lvl = 0;
|
||||
}
|
||||
public byte[] To_html(Ordered_hash itms, byte[] toc_title, boolean page_banner) {
|
||||
public byte[] To_html(Ordered_hash itms, byte[] toc_title, boolean toc_mode_is_pgbnr) {
|
||||
this.itms = itms;
|
||||
fmtr_div.Bld_many(bfr, page_banner ? Bry_.Empty : Bry_toc_cls, toc_title, this);
|
||||
fmtr_div.Bld_many(bfr, toc_mode_is_pgbnr ? Bry_.Empty : Bry_toc_cls, toc_title, this);
|
||||
return bfr.To_bry_and_clear();
|
||||
}
|
||||
public byte[] Test__to_html(Ordered_hash itms) {
|
||||
|
||||
@@ -165,11 +165,11 @@ class Xoh_toc_htmlr__basic__fxt {
|
||||
private final Xoh_toc_wtr wtr = new Xoh_toc_wtr();
|
||||
public void Clear() {wtr.Clear();}
|
||||
public void Init__add(int hdr_num, String hdr_txt) {wtr.Add(hdr_num, Bry_.new_u8(hdr_txt));}
|
||||
public void Init__init_page(String toc_title, boolean page_banner) {wtr.Init(Bry_.new_u8(toc_title), page_banner);}
|
||||
public void Init__init_page(String toc_title, boolean page_banner) {wtr.Init(Bry_.new_u8(toc_title), Bry_.Empty);}
|
||||
public void Test__html_itms(String... expd_ary) {
|
||||
Gftest.Eq__ary(expd_ary, String_.Ary(Bry_split_.Split_lines(wtr.Test__to_html())));
|
||||
}
|
||||
public void Test__html_div(String... expd_ary) {
|
||||
Gftest.Eq__ary(expd_ary, String_.Ary(Bry_split_.Split_lines(wtr.To_html())));
|
||||
Gftest.Eq__ary(expd_ary, String_.Ary(Bry_split_.Split_lines(wtr.To_html(false))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
class Xoh_toc_itm {// EX: <li class="toclevel-3 tocsection-3"><a href="#aaa"><span class="tocnumber">1.1.1</span> <span class="toctext">aaa</span></a></li>
|
||||
public class Xoh_toc_itm {// EX: <li class="toclevel-3 tocsection-3"><a href="#aaa"><span class="tocnumber">1.1.1</span> <span class="toctext">aaa</span></a></li>
|
||||
public int Uid() {return uid;} private int uid; // uid of itm; HTML: "tocsection-3"
|
||||
public int Lvl() {return lvl;} private int lvl; // indent level; HTML: "toclevel-3"
|
||||
public int[] Path() {return path;} private int[] path; // path of itm; HTML: "1.1.1"
|
||||
|
||||
@@ -24,13 +24,14 @@ class Xoh_toc_wkr__txt {
|
||||
private final Gfo_url_encoder anch_encoder = Gfo_url_encoder_.New__id();
|
||||
private final Xop_amp_mgr amp_mgr = Xop_amp_mgr.Instance;
|
||||
private final Hash_adp anch_hash = Hash_adp_bry.ci_u8(gplx.xowa.langs.cases.Xol_case_mgr_.U8());
|
||||
private byte[] page_name = Bry_.Empty;
|
||||
private byte[] page_name;
|
||||
public void Clear() {
|
||||
anch_bfr.Clear();
|
||||
text_bfr.Clear();
|
||||
anch_hash.Clear();
|
||||
}
|
||||
public void Calc_anch_text(Xoh_toc_itm rv, byte[] src) { // text within hdr; EX: <h2>Abc</h2> -> Abc
|
||||
public void Calc_anch_text(Xoh_toc_itm rv, byte[] page_name, byte[] src) { // text within hdr; EX: <h2>Abc</h2> -> Abc
|
||||
this.page_name = page_name;
|
||||
int end = src.length;
|
||||
src = Remove_comment(text_bfr, src, 0, end);
|
||||
end = src.length;
|
||||
@@ -38,15 +39,17 @@ class Xoh_toc_wkr__txt {
|
||||
Calc_anch_text_recurse(src, 0, end);
|
||||
|
||||
byte[] anch_bry = anch_bfr.To_bry_and_clear_and_trim(Bool_.Y, Bool_.Y, id_trim_ary);
|
||||
Int_obj_ref anch_idx_ref = (Int_obj_ref)anch_hash.Get_by(anch_bry);
|
||||
if (anch_idx_ref == null) {
|
||||
anch_hash.Add(anch_bry, Int_obj_ref.New(2));
|
||||
}
|
||||
else {
|
||||
int anch_idx = anch_idx_ref.Val();
|
||||
anch_bry = Bry_.Add(anch_bry, Byte_ascii.Underline_bry, Int_.To_bry(anch_idx));
|
||||
anch_idx_ref.Val_(anch_idx + 1);
|
||||
if (anch_hash.Has(anch_bry)) {
|
||||
int anch_idx = 2;
|
||||
while (true) { // NOTE: this is not big-O performant, but it mirrors MW; DATE:2016-07-09
|
||||
byte[] anch_tmp = Bry_.Add(anch_bry, Byte_ascii.Underline_bry, Int_.To_bry(anch_idx++));
|
||||
if (!anch_hash.Has(anch_tmp)) {
|
||||
anch_bry = anch_tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
anch_hash.Add_as_key_and_val(anch_bry);
|
||||
rv.Set__txt
|
||||
( anch_bry
|
||||
, text_bfr.To_bry_and_clear_and_trim()); // NOTE: both id and text trim ends
|
||||
@@ -97,12 +100,30 @@ class Xoh_toc_wkr__txt {
|
||||
// get lhs / rhs vars
|
||||
byte[] lhs_bry = lhs.Name_bry();
|
||||
int lhs_end = lhs.Src_end();
|
||||
boolean lhs_is_pair = !lhs.Tag_is_inline();
|
||||
|
||||
// ignore tags which are not closed by tidy as default; EX: <br> not <br>a</br> or <br/>
|
||||
boolean lhs_is_dangling = false;
|
||||
switch (tag_id) {
|
||||
case Gfh_tag_.Id__img:
|
||||
case Gfh_tag_.Id__br:
|
||||
case Gfh_tag_.Id__hr:
|
||||
lhs_is_dangling = true;
|
||||
break;
|
||||
}
|
||||
boolean lhs_is_pair = !lhs.Tag_is_inline() && !lhs_is_dangling;
|
||||
int rhs_bgn = -1, rhs_end = -1, new_pos = lhs_end;
|
||||
if (lhs_is_pair) { // get rhs unless inline
|
||||
Gfh_tag rhs = tag_rdr.Tag__move_fwd_tail(tag_id);
|
||||
rhs_bgn = rhs.Src_bgn(); rhs_end = rhs.Src_end();
|
||||
new_pos = rhs_end;
|
||||
if (lhs_is_pair) { // get rhs unless inline
|
||||
if (tag_id == Gfh_tag_.Id__any) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "unknown tag: page=~{0} tag=~{1}", page_name, lhs_bry);
|
||||
Gfh_tag rhs = tag_rdr.Tag__move_fwd_tail(lhs_bry);
|
||||
rhs_bgn = rhs.Src_bgn(); rhs_end = rhs.Src_end();
|
||||
new_pos = rhs_end;
|
||||
}
|
||||
else {
|
||||
Gfh_tag rhs = tag_rdr.Tag__move_fwd_tail(tag_id);
|
||||
rhs_bgn = rhs.Src_bgn(); rhs_end = rhs.Src_end();
|
||||
new_pos = rhs_end;
|
||||
}
|
||||
}
|
||||
|
||||
// print "<tag></tag>"; also, recurse
|
||||
|
||||
@@ -31,11 +31,6 @@ public class Xoh_toc_wkr__txt__basic__tst {
|
||||
@Test public void Encode() {
|
||||
fxt.Test__both("a+b", "a.2Bb", "a+b");
|
||||
}
|
||||
@Test public void Dupe() {
|
||||
fxt.Test__both("a", "a", "a");
|
||||
fxt.Test__both("a", "a_2", "a");
|
||||
fxt.Test__both("A", "A_3", "A");
|
||||
}
|
||||
@Test public void Comment() {
|
||||
fxt.Test__text("a<!--b-->c", "ac");
|
||||
}
|
||||
@@ -54,11 +49,11 @@ class Xoh_toc_wkr__txt__fxt {
|
||||
private final Xoh_toc_itm itm = new Xoh_toc_itm();
|
||||
private final Bry_bfr tmp = Bry_bfr_.New();
|
||||
public void Clear() {wkr.Clear();}
|
||||
public void Test__id (String html, String expd_id) {Test__both(html, expd_id, null);}
|
||||
public void Test__anch(String html, String expd_anch) {Test__both(html, expd_anch, null);}
|
||||
public void Test__text(String html, String expd_text) {Test__both(html, null, expd_text);}
|
||||
public void Test__both(String html, String expd) {Test__both(html, expd, expd);}
|
||||
public void Test__both(String html, String expd_anch, String expd_text) {
|
||||
wkr.Calc_anch_text(itm, Bry_.new_u8(html));
|
||||
wkr.Calc_anch_text(itm, Bry_.Empty, Bry_.new_u8(html));
|
||||
if (expd_anch != null) Gftest.Eq__str(expd_anch, itm.Anch(), "anch");
|
||||
if (expd_text != null) Gftest.Eq__str(expd_text, itm.Text(), "text");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import org.junit.*; import gplx.core.tests.*;
|
||||
public class Xoh_toc_wkr__txt__dupe__tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xoh_toc_wkr__txt__fxt fxt = new Xoh_toc_wkr__txt__fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Test__anch("a" , "a");
|
||||
fxt.Test__anch("a" , "a_2");
|
||||
}
|
||||
@Test public void Case_insensitive() {
|
||||
fxt.Test__anch("a" , "a");
|
||||
fxt.Test__anch("A" , "A_2");
|
||||
}
|
||||
@Test public void Autonumber_exists() { // PAGE:fr.w:Itanium; EX: Itanium,Itanium_2,Itanium
|
||||
fxt.Test__anch("a" , "a");
|
||||
fxt.Test__anch("a_2" , "a_2");
|
||||
fxt.Test__anch("a" , "a_3");
|
||||
}
|
||||
@Test public void Autonumber_exists_2() {
|
||||
fxt.Test__anch("a_2" , "a_2");
|
||||
fxt.Test__anch("a" , "a");
|
||||
fxt.Test__anch("a" , "a_3");
|
||||
fxt.Test__anch("a" , "a_4");
|
||||
fxt.Test__anch("a_2" , "a_2_2");
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,10 @@ public class Xoh_toc_wkr__txt__xnde__tst {
|
||||
@Test public void A() {fxt.Test__both("<a href=\"/wiki/A\">b</a>" , "b");}
|
||||
@Test public void A__nest() {fxt.Test__both("<a href=\"/wiki/A\">b<i>c</i>d</a>" , "bcd", "b<i>c</i>d");}
|
||||
@Test public void Br() {fxt.Test__both("a<br/>b" , "ab");}
|
||||
@Test public void Br__dangling() {fxt.Test__both("a<br>b" , "ab");}
|
||||
@Test public void H2() {fxt.Test__both("a<h2>b</h2>c" , "abc");} // NOTE: not a valid test; MW actually generates "ab" b/c of tidy; see corresponding edit test; DATE:2016-06-28
|
||||
@Test public void Li() {fxt.Test__text("a<ul><li>b</li></ul>c" , "abc");}
|
||||
@Test public void Table() {fxt.Test__text("a<table><tr><td>b</td></tr></table>c" , "abc");}
|
||||
@Test public void Unknown__i() {fxt.Test__both("a<unknown>b<i>c</i>d</unknown>e" , "abcde", "ab<i>c</i>de");} // PURPOSE: unknown tags should not fail; DATE:2016-07-09
|
||||
@Test public void Unknown__a() {fxt.Test__both("a<unknown>b<a>c</a>d</unknown>e" , "abcde");} // PURPOSE: unknown tags should not fail; DATE:2016-07-09
|
||||
}
|
||||
|
||||
@@ -16,32 +16,36 @@ 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.htmls.tocs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
class Xoh_toc_wtr {
|
||||
import gplx.xowa.htmls.core.wkrs.tocs.*;
|
||||
public class Xoh_toc_wtr {
|
||||
private final Ordered_hash itms = Ordered_hash_.New_bry();
|
||||
private final Xoh_toc_wkr__lvl lvl_wkr = new Xoh_toc_wkr__lvl();
|
||||
private final Xoh_toc_wkr__txt txt_wkr = new Xoh_toc_wkr__txt();
|
||||
private final Xoh_toc_htmlr htmlr = new Xoh_toc_htmlr();
|
||||
private byte[] toc_title; private boolean page_banner;
|
||||
private byte[] toc_title, page_name;
|
||||
public void Clear() {
|
||||
itms.Clear();
|
||||
lvl_wkr.Clear();
|
||||
txt_wkr.Clear();
|
||||
htmlr.Clear();
|
||||
this.exists = false;
|
||||
}
|
||||
public void Init(byte[] toc_title, boolean page_banner) {
|
||||
public boolean Exists() {return exists && Enabled;} private boolean exists;
|
||||
public void Exists_y_() {exists = true;}
|
||||
public void Init(byte[] toc_title, byte[] page_name) {
|
||||
this.Clear();
|
||||
this.toc_title = toc_title;
|
||||
this.page_banner = page_banner;
|
||||
this.page_name = page_name;
|
||||
}
|
||||
public void Add(int hdr_num, byte[] hdr_txt) {
|
||||
Xoh_toc_itm itm = new Xoh_toc_itm();
|
||||
lvl_wkr.Calc_level(itm, hdr_num);
|
||||
txt_wkr.Calc_anch_text(itm, hdr_txt);
|
||||
txt_wkr.Calc_anch_text(itm, page_name, hdr_txt);
|
||||
itms.Add(itm.Anch(), itm);
|
||||
}
|
||||
public byte[] To_html() {
|
||||
return htmlr.To_html(itms, toc_title, page_banner);
|
||||
}
|
||||
public byte[] To_html(boolean toc_mode_is_pgbnr) {return htmlr.To_html(itms, toc_title, toc_mode_is_pgbnr);}
|
||||
public byte[] Test__to_html() {
|
||||
return htmlr.Test__to_html(itms);
|
||||
}
|
||||
public static boolean Enabled = true;
|
||||
}
|
||||
|
||||
@@ -190,12 +190,15 @@ public class Xow_toc_mgr implements gplx.core.brys.Bfr_arg {
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Html(Xoae_page page, Xoh_wtr_ctx hctx, byte[] src, Bry_bfr bfr, boolean write_toc_cls) { // write_toc_cls needed for Page_banner
|
||||
public void Html(Xoae_page page, Xoh_wtr_ctx hctx, Bry_bfr bfr, boolean pgbnr_mode) { // write_toc_cls needed for Page_banner
|
||||
if (!page.Hdr_mgr().Toc_enabled()) return; // REF.MW: Parser.php|formatHeadings
|
||||
if (hctx.Mode_is_hdump()) return;
|
||||
if (hctx.Mode_is_hdump()) {
|
||||
gplx.xowa.htmls.core.wkrs.tocs.Xoh_toc_wtr.Write_tag(bfr, pgbnr_mode);
|
||||
return;
|
||||
}
|
||||
this.page = page;
|
||||
byte[] bry_contents = page.Wikie().Msg_mgr().Val_by_id(Xol_msg_itm_.Id_toc);
|
||||
bfmtr_main.Bld_bfr_many(bfr, write_toc_cls ? Bry_toc_cls : Bry_.Empty, Bfr_arg_.New_bry(bry_contents), this);
|
||||
bfmtr_main.Bld_bfr_many(bfr, pgbnr_mode ? Bry_.Empty : Bry_toc_cls, Bfr_arg_.New_bry(bry_contents), this);
|
||||
}
|
||||
private static final byte[]
|
||||
Bry_list_bgn = Bry_.new_a7(" <ul>\n")
|
||||
|
||||
@@ -568,7 +568,7 @@ class Xow_toc_mgr_fxt {
|
||||
byte[] raw_bry = Bry_.new_u8(raw);
|
||||
Xop_root_tkn root = fxt.Ctx().Tkn_mkr().Root(raw_bry);
|
||||
fxt.Parser().Parse_page_all_clear(root, fxt.Ctx(), fxt.Ctx().Tkn_mkr(), raw_bry);
|
||||
toc_mgr.Html(fxt.Page(), Xoh_wtr_ctx.Basic, raw_bry, tmp, true);
|
||||
toc_mgr.Html(fxt.Page(), Xoh_wtr_ctx.Basic, tmp, false);
|
||||
Tfds.Eq_ary(String_.SplitLines_nl(expd), String_.SplitLines_nl(tmp.To_str_and_clear()), raw);
|
||||
}
|
||||
public void Test_html_all(String raw, String expd) {
|
||||
|
||||
Reference in New Issue
Block a user